From a6bfefc4864c40f5fba4a6c98b27bd5e29345b5b Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 19 Aug 2015 11:45:54 +0200 Subject: [PATCH] Import cargo_0.3.0.orig-deps.tar.gz --- deps/advapi32-sys-0.1.1/Cargo.toml | 20 + deps/advapi32-sys-0.1.1/README.md | 4 + deps/advapi32-sys-0.1.1/build.rs | 6 + deps/advapi32-sys-0.1.1/src/lib.rs | 931 +++ deps/aho-corasick-0.2.1/.gitignore | 9 + deps/aho-corasick-0.2.1/.travis.yml | 12 + deps/aho-corasick-0.2.1/COPYING | 3 + deps/aho-corasick-0.2.1/Cargo.toml | 36 + deps/aho-corasick-0.2.1/LICENSE-MIT | 21 + deps/aho-corasick-0.2.1/Makefile | 14 + deps/aho-corasick-0.2.1/README.md | 55 + deps/aho-corasick-0.2.1/UNLICENSE | 24 + deps/aho-corasick-0.2.1/benches/bench.rs | 258 + deps/aho-corasick-0.2.1/benches/random.txt | 513 ++ deps/aho-corasick-0.2.1/ctags.rust | 11 + .../examples/dict-search.rs | 87 + deps/aho-corasick-0.2.1/session.vim | 1 + deps/aho-corasick-0.2.1/src/autiter.rs | 325 + deps/aho-corasick-0.2.1/src/full.rs | 116 + deps/aho-corasick-0.2.1/src/lib.rs | 863 +++ deps/aho-corasick-0.2.1/src/main.rs | 13 + deps/bitflags-0.1.1/.gitignore | 2 + deps/bitflags-0.1.1/.travis.yml | 19 + deps/bitflags-0.1.1/Cargo.toml | 13 + deps/bitflags-0.1.1/LICENSE-APACHE | 201 + deps/bitflags-0.1.1/LICENSE-MIT | 25 + deps/bitflags-0.1.1/README.md | 25 + deps/bitflags-0.1.1/src/lib.rs | 481 ++ deps/curl-0.2.10/.gitignore | 2 + deps/curl-0.2.10/.gitmodules | 3 + deps/curl-0.2.10/Cargo.toml | 42 + deps/curl-0.2.10/LICENSE | 19 + deps/curl-0.2.10/README.md | 63 + deps/curl-0.2.10/src/ffi/consts.rs | 1 + deps/curl-0.2.10/src/ffi/easy.rs | 241 + deps/curl-0.2.10/src/ffi/err.rs | 138 + deps/curl-0.2.10/src/ffi/info.rs | 9 + deps/curl-0.2.10/src/ffi/list.rs | 49 + deps/curl-0.2.10/src/ffi/mod.rs | 10 + deps/curl-0.2.10/src/ffi/opt.rs | 283 + deps/curl-0.2.10/src/ffi/version.rs | 217 + deps/curl-0.2.10/src/http/body.rs | 53 + deps/curl-0.2.10/src/http/handle.rs | 406 + deps/curl-0.2.10/src/http/header.rs | 224 + deps/curl-0.2.10/src/http/mod.rs | 12 + deps/curl-0.2.10/src/http/response.rs | 62 + deps/curl-0.2.10/src/lib.rs | 24 + deps/curl-0.2.10/test/server.rs | 258 + deps/curl-0.2.10/test/test.rs | 38 + deps/curl-0.2.10/test/test_delete.rs | 52 + deps/curl-0.2.10/test/test_get.rs | 114 + deps/curl-0.2.10/test/test_head.rs | 26 + deps/curl-0.2.10/test/test_keep_alive.rs | 68 + deps/curl-0.2.10/test/test_patch.rs | 53 + deps/curl-0.2.10/test/test_post.rs | 107 + deps/curl-0.2.10/test/test_proxy.rs | 30 + deps/curl-0.2.10/test/test_put.rs | 53 + deps/curl-sys-0.1.24/Cargo.toml | 40 + deps/curl-sys-0.1.24/build.rs | 194 + deps/curl-sys-0.1.24/lib.rs | 483 ++ deps/docopt-0.6.67/.gitignore | 6 + deps/docopt-0.6.67/.travis.yml | 17 + deps/docopt-0.6.67/COPYING | 3 + deps/docopt-0.6.67/Cargo.toml | 25 + deps/docopt-0.6.67/LICENSE-MIT | 21 + deps/docopt-0.6.67/Makefile | 18 + deps/docopt-0.6.67/README.md | 314 + deps/docopt-0.6.67/UNLICENSE | 24 + .../completions/docopt-wordlist.bash | 79 + deps/docopt-0.6.67/ctags.rust | 11 + deps/docopt-0.6.67/examples/cargo.rs | 51 + deps/docopt-0.6.67/examples/cp.rs | 28 + deps/docopt-0.6.67/examples/decode.rs | 44 + deps/docopt-0.6.67/examples/hashmap.rs | 37 + .../examples/optional_command.rs | 50 + .../examples/verbose_multiple.rs | 36 + deps/docopt-0.6.67/scripts/mk-testcases | 80 + deps/docopt-0.6.67/session.vim | 3 + deps/docopt-0.6.67/src/dopt.rs | 873 +++ deps/docopt-0.6.67/src/lib.rs | 241 + deps/docopt-0.6.67/src/parse.rs | 1358 ++++ deps/docopt-0.6.67/src/synonym.rs | 107 + deps/docopt-0.6.67/src/test/mod.rs | 68 + deps/docopt-0.6.67/src/test/suggestions.rs | 72 + deps/docopt-0.6.67/src/test/testcases.docopt | 990 +++ deps/docopt-0.6.67/src/test/testcases.rs | 651 ++ deps/docopt-0.6.67/src/wordlist.rs | 104 + deps/encoding-0.2.32/.gitignore | 2 + deps/encoding-0.2.32/.travis.yml | 13 + deps/encoding-0.2.32/AUTHORS.txt | 34 + deps/encoding-0.2.32/Cargo.toml | 47 + deps/encoding-0.2.32/LICENSE.txt | 22 + deps/encoding-0.2.32/Makefile | 39 + deps/encoding-0.2.32/README.md | 216 + deps/encoding-0.2.32/examples/recode.rs | 94 + deps/encoding-0.2.32/src/all.rs | 143 + deps/encoding-0.2.32/src/codec/ascii.rs | 163 + deps/encoding-0.2.32/src/codec/error.rs | 94 + deps/encoding-0.2.32/src/codec/japanese.rs | 1343 ++++ deps/encoding-0.2.32/src/codec/korean.rs | 280 + deps/encoding-0.2.32/src/codec/simpchinese.rs | 779 ++ deps/encoding-0.2.32/src/codec/singlebyte.rs | 131 + deps/encoding-0.2.32/src/codec/tradchinese.rs | 277 + deps/encoding-0.2.32/src/codec/utf_16.rs | 593 ++ deps/encoding-0.2.32/src/codec/utf_8.rs | 828 +++ deps/encoding-0.2.32/src/codec/whatwg.rs | 34 + .../src/examples/UTF-8-test.txt | Bin 0 -> 20334 bytes .../src/examples/outer-space-treaty.html | 959 +++ deps/encoding-0.2.32/src/index/gen_index.py | 386 + deps/encoding-0.2.32/src/label.rs | 356 + deps/encoding-0.2.32/src/lib.rs | 276 + deps/encoding-0.2.32/src/testutils.rs | 309 + deps/encoding-0.2.32/src/types.rs | 513 ++ deps/encoding-0.2.32/src/util.rs | 322 + .../Cargo.toml | 18 + .../jis0208.rs | 3372 +++++++++ .../jis0212.rs | 2764 +++++++ .../lib.rs | 28 + .../Cargo.toml | 18 + .../euc_kr.rs | 5723 ++++++++++++++ .../encoding-index-korean-1.20141219.5/lib.rs | 21 + .../Cargo.toml | 18 + .../gb18030.rs | 4983 +++++++++++++ .../gb18030_ranges.rs | 91 + .../lib.rs | 33 + .../Cargo.toml | 18 + .../ibm866.rs | 83 + .../iso_8859_10.rs | 72 + .../iso_8859_13.rs | 72 + .../iso_8859_14.rs | 79 + .../iso_8859_15.rs | 70 + .../iso_8859_16.rs | 76 + .../iso_8859_2.rs | 66 + .../iso_8859_3.rs | 64 + .../iso_8859_4.rs | 66 + .../iso_8859_5.rs | 72 + .../iso_8859_6.rs | 62 + .../iso_8859_7.rs | 73 + .../iso_8859_8.rs | 71 + .../koi8_r.rs | 87 + .../koi8_u.rs | 88 + .../lib.rs | 95 + .../macintosh.rs | 139 + .../windows_1250.rs | 80 + .../windows_1251.rs | 79 + .../windows_1252.rs | 79 + .../windows_1253.rs | 76 + .../windows_1254.rs | 81 + .../windows_1255.rs | 81 + .../windows_1256.rs | 87 + .../windows_1257.rs | 80 + .../windows_1258.rs | 85 + .../windows_874.rs | 74 + .../x_mac_cyrillic.rs | 86 + .../Cargo.toml | 18 + .../big5.rs | 6602 +++++++++++++++++ .../lib.rs | 22 + deps/encoding_index_tests-0.1.4/Cargo.toml | 13 + .../encoding_index_tests-0.1.4/index_tests.rs | 210 + deps/env_logger-0.3.1/Cargo.toml | 19 + deps/env_logger-0.3.1/src/lib.rs | 464 ++ deps/filetime-0.1.4/.gitignore | 2 + deps/filetime-0.1.4/.travis.yml | 23 + deps/filetime-0.1.4/Cargo.toml | 13 + deps/filetime-0.1.4/LICENSE-APACHE | 201 + deps/filetime-0.1.4/LICENSE-MIT | 25 + deps/filetime-0.1.4/README.md | 25 + deps/filetime-0.1.4/appveyor.yml | 11 + deps/filetime-0.1.4/src/lib.rs | 183 + deps/flate2-0.2.7/.gitignore | 2 + deps/flate2-0.2.7/.travis.yml | 21 + deps/flate2-0.2.7/Cargo.toml | 23 + deps/flate2-0.2.7/LICENSE-APACHE | 201 + deps/flate2-0.2.7/LICENSE-MIT | 25 + deps/flate2-0.2.7/README.md | 61 + deps/flate2-0.2.7/src/crc.rs | 50 + deps/flate2-0.2.7/src/deflate.rs | 190 + deps/flate2-0.2.7/src/gz.rs | 542 ++ deps/flate2-0.2.7/src/lib.rs | 179 + deps/flate2-0.2.7/src/raw.rs | 259 + deps/flate2-0.2.7/src/stream.rs | 145 + deps/flate2-0.2.7/src/zlib.rs | 190 + deps/flate2-0.2.7/tests/corrupt-file.gz | Bin 0 -> 7128 bytes deps/flate2-0.2.7/tests/good-file.gz | Bin 0 -> 6766 bytes deps/flate2-0.2.7/tests/good-file.txt | 733 ++ deps/flate2-0.2.7/tests/gunzip.rs | 31 + deps/gcc-0.3.8/.gitignore | 2 + deps/gcc-0.3.8/.travis.yml | 25 + deps/gcc-0.3.8/Cargo.toml | 14 + deps/gcc-0.3.8/LICENSE-APACHE | 201 + deps/gcc-0.3.8/LICENSE-MIT | 25 + deps/gcc-0.3.8/README.md | 82 + deps/gcc-0.3.8/appveyor.yml | 11 + deps/gcc-0.3.8/src/lib.rs | 498 ++ deps/git2-0.2.12/.gitignore | 3 + deps/git2-0.2.12/.gitmodules | 3 + deps/git2-0.2.12/.travis.yml | 30 + deps/git2-0.2.12/Cargo.toml | 31 + deps/git2-0.2.12/LICENSE-APACHE | 201 + deps/git2-0.2.12/LICENSE-MIT | 25 + deps/git2-0.2.12/README.md | 31 + deps/git2-0.2.12/examples/add.rs | 84 + deps/git2-0.2.12/examples/blame.rs | 105 + deps/git2-0.2.12/examples/cat-file.rs | 143 + deps/git2-0.2.12/examples/clone.rs | 117 + deps/git2-0.2.12/examples/diff.rs | 283 + deps/git2-0.2.12/examples/fetch.rs | 130 + deps/git2-0.2.12/examples/init.rs | 151 + deps/git2-0.2.12/examples/log.rs | 261 + deps/git2-0.2.12/examples/ls-remote.rs | 63 + deps/git2-0.2.12/examples/rev-list.rs | 95 + deps/git2-0.2.12/examples/rev-parse.rs | 69 + deps/git2-0.2.12/examples/status.rs | 373 + deps/git2-0.2.12/examples/tag.rs | 133 + deps/git2-0.2.12/src/blame.rs | 303 + deps/git2-0.2.12/src/blob.rs | 86 + deps/git2-0.2.12/src/branch.rs | 166 + deps/git2-0.2.12/src/buf.rs | 67 + deps/git2-0.2.12/src/build.rs | 465 ++ deps/git2-0.2.12/src/call.rs | 160 + deps/git2-0.2.12/src/cert.rs | 97 + deps/git2-0.2.12/src/commit.rs | 322 + deps/git2-0.2.12/src/config.rs | 500 ++ deps/git2-0.2.12/src/cred.rs | 469 ++ deps/git2-0.2.12/src/diff.rs | 1020 +++ deps/git2-0.2.12/src/error.rs | 113 + deps/git2-0.2.12/src/index.rs | 565 ++ deps/git2-0.2.12/src/lib.rs | 608 ++ deps/git2-0.2.12/src/note.rs | 126 + deps/git2-0.2.12/src/object.rs | 119 + deps/git2-0.2.12/src/oid.rs | 128 + deps/git2-0.2.12/src/panic.rs | 76 + deps/git2-0.2.12/src/pathspec.rs | 284 + deps/git2-0.2.12/src/push.rs | 135 + deps/git2-0.2.12/src/reference.rs | 340 + deps/git2-0.2.12/src/reflog.rs | 167 + deps/git2-0.2.12/src/refspec.rs | 88 + deps/git2-0.2.12/src/remote.rs | 526 ++ deps/git2-0.2.12/src/remote_callbacks.rs | 343 + deps/git2-0.2.12/src/repo.rs | 1528 ++++ deps/git2-0.2.12/src/revspec.rs | 26 + deps/git2-0.2.12/src/revwalk.rs | 209 + deps/git2-0.2.12/src/signature.rs | 171 + deps/git2-0.2.12/src/status.rs | 396 + deps/git2-0.2.12/src/string_array.rs | 106 + deps/git2-0.2.12/src/submodule.rs | 255 + deps/git2-0.2.12/src/tag.rs | 155 + deps/git2-0.2.12/src/test.rs | 40 + deps/git2-0.2.12/src/time.rs | 67 + deps/git2-0.2.12/src/transport.rs | 341 + deps/git2-0.2.12/src/tree.rs | 278 + deps/git2-0.2.12/src/util.rs | 143 + deps/git2-curl-0.2.4/Cargo.toml | 33 + deps/git2-curl-0.2.4/src/lib.rs | 211 + deps/git2-curl-0.2.4/tests/all.rs | 68 + deps/git2-curl-0.2.4/tests/tempdir.rs | 18 + deps/glob-0.2.10/.gitignore | 2 + deps/glob-0.2.10/.travis.yml | 19 + deps/glob-0.2.10/Cargo.toml | 15 + deps/glob-0.2.10/LICENSE-APACHE | 201 + deps/glob-0.2.10/LICENSE-MIT | 25 + deps/glob-0.2.10/README.md | 24 + deps/glob-0.2.10/src/lib.rs | 1245 ++++ deps/glob-0.2.10/tests/glob-std.rs | 278 + deps/kernel32-sys-0.1.2/Cargo.toml | 20 + deps/kernel32-sys-0.1.2/README.md | 4 + deps/kernel32-sys-0.1.2/build.rs | 6 + deps/kernel32-sys-0.1.2/src/lib.rs | 1768 +++++ deps/libc-0.1.8/Cargo.toml | 23 + deps/libc-0.1.8/rust/src/liblibc/lib.rs | 6386 ++++++++++++++++ deps/libgit2-sys-0.2.17/Cargo.toml | 55 + deps/libgit2-sys-0.2.17/build.rs | 167 + deps/libgit2-sys-0.2.17/lib.rs | 2168 ++++++ deps/libgit2-sys-0.2.17/libgit2/.HEADER | 24 + deps/libgit2-sys-0.2.17/libgit2/.editorconfig | 14 + .../libgit2-sys-0.2.17/libgit2/.gitattributes | 2 + deps/libgit2-sys-0.2.17/libgit2/.gitignore | 33 + deps/libgit2-sys-0.2.17/libgit2/.mailmap | 21 + deps/libgit2-sys-0.2.17/libgit2/.travis.yml | 77 + deps/libgit2-sys-0.2.17/libgit2/AUTHORS | 75 + deps/libgit2-sys-0.2.17/libgit2/CHANGELOG.md | 332 + .../libgit2-sys-0.2.17/libgit2/CMakeLists.txt | 562 ++ .../libgit2/CONTRIBUTING.md | 146 + .../libgit2-sys-0.2.17/libgit2/CONVENTIONS.md | 234 + deps/libgit2-sys-0.2.17/libgit2/COPYING | 914 +++ .../libgit2-sys-0.2.17/libgit2/Makefile.embed | 60 + deps/libgit2-sys-0.2.17/libgit2/PROJECTS.md | 101 + deps/libgit2-sys-0.2.17/libgit2/README.md | 244 + deps/libgit2-sys-0.2.17/libgit2/THREADING.md | 89 + deps/libgit2-sys-0.2.17/libgit2/api.docurium | 13 + deps/libgit2-sys-0.2.17/libgit2/appveyor.yml | 38 + .../cmake/Modules/AddCFlagIfSupported.cmake | 16 + .../libgit2/cmake/Modules/FindGSSAPI.cmake | 324 + .../cmake/Modules/FindHTTP_Parser.cmake | 39 + .../libgit2/cmake/Modules/FindIconv.cmake | 43 + .../libgit2/docs/checkout-internals.md | 204 + .../libgit2/docs/diff-internals.md | 92 + .../libgit2/docs/error-handling.md | 270 + .../libgit2/docs/merge-df_conflicts.txt | 41 + .../libgit2/git.git-authors | 74 + .../libgit2-sys-0.2.17/libgit2/include/git2.h | 65 + .../libgit2/include/git2/annotated_commit.h | 116 + .../libgit2/include/git2/attr.h | 245 + .../libgit2/include/git2/blame.h | 212 + .../libgit2/include/git2/blob.h | 223 + .../libgit2/include/git2/branch.h | 280 + .../libgit2/include/git2/buffer.h | 128 + .../libgit2/include/git2/checkout.h | 349 + .../libgit2/include/git2/cherrypick.h | 90 + .../libgit2/include/git2/clone.h | 208 + .../libgit2/include/git2/commit.h | 357 + .../libgit2/include/git2/common.h | 250 + .../libgit2/include/git2/config.h | 694 ++ .../libgit2/include/git2/cred_helpers.h | 53 + .../libgit2/include/git2/describe.h | 163 + .../libgit2/include/git2/diff.h | 1245 ++++ .../libgit2/include/git2/errors.h | 160 + .../libgit2/include/git2/filter.h | 168 + .../libgit2/include/git2/global.h | 44 + .../libgit2/include/git2/graph.h | 55 + .../libgit2/include/git2/ignore.h | 78 + .../libgit2/include/git2/index.h | 734 ++ .../libgit2/include/git2/indexer.h | 76 + .../libgit2/include/git2/inttypes.h | 309 + .../libgit2/include/git2/merge.h | 550 ++ .../libgit2/include/git2/message.h | 44 + .../libgit2/include/git2/net.h | 59 + .../libgit2/include/git2/notes.h | 217 + .../libgit2/include/git2/object.h | 242 + .../libgit2/include/git2/odb.h | 495 ++ .../libgit2/include/git2/odb_backend.h | 134 + .../libgit2/include/git2/oid.h | 269 + .../libgit2/include/git2/oidarray.h | 40 + .../libgit2/include/git2/pack.h | 228 + .../libgit2/include/git2/patch.h | 274 + .../libgit2/include/git2/pathspec.h | 263 + .../libgit2/include/git2/push.h | 64 + .../libgit2/include/git2/rebase.h | 270 + .../libgit2/include/git2/refdb.h | 68 + .../libgit2/include/git2/reflog.h | 170 + .../libgit2/include/git2/refs.h | 735 ++ .../libgit2/include/git2/refspec.h | 104 + .../libgit2/include/git2/remote.h | 693 ++ .../libgit2/include/git2/repository.h | 754 ++ .../libgit2/include/git2/reset.h | 110 + .../libgit2/include/git2/revert.h | 89 + .../libgit2/include/git2/revparse.h | 113 + .../libgit2/include/git2/revwalk.h | 295 + .../libgit2/include/git2/signature.h | 90 + .../libgit2/include/git2/stash.h | 126 + .../libgit2/include/git2/status.h | 369 + .../libgit2/include/git2/stdint.h | 247 + .../libgit2/include/git2/strarray.h | 60 + .../libgit2/include/git2/submodule.h | 650 ++ .../libgit2/include/git2/sys/commit.h | 80 + .../libgit2/include/git2/sys/config.h | 113 + .../libgit2/include/git2/sys/diff.h | 94 + .../libgit2/include/git2/sys/filter.h | 309 + .../libgit2/include/git2/sys/hashsig.h | 106 + .../libgit2/include/git2/sys/index.h | 177 + .../libgit2/include/git2/sys/mempack.h | 85 + .../libgit2/include/git2/sys/odb_backend.h | 108 + .../libgit2/include/git2/sys/openssl.h | 38 + .../libgit2/include/git2/sys/refdb_backend.h | 217 + .../libgit2/include/git2/sys/reflog.h | 21 + .../libgit2/include/git2/sys/refs.h | 49 + .../libgit2/include/git2/sys/repository.h | 140 + .../libgit2/include/git2/sys/stream.h | 42 + .../libgit2/include/git2/sys/transport.h | 373 + .../libgit2/include/git2/tag.h | 352 + .../libgit2/include/git2/trace.h | 67 + .../libgit2/include/git2/transaction.h | 111 + .../libgit2/include/git2/transport.h | 311 + .../libgit2/include/git2/tree.h | 415 ++ .../libgit2/include/git2/types.h | 425 ++ .../libgit2/include/git2/version.h | 18 + deps/libgit2-sys-0.2.17/libgit2/libgit2.pc.in | 10 + .../libgit2/libgit2_clar.supp | 49 + .../libgit2/script/appveyor-mingw.sh | 23 + .../libgit2/script/cibuild.sh | 60 + .../libgit2/script/coverity.sh | 57 + .../libgit2/script/install-deps-linux.sh | 6 + .../libgit2/script/install-deps-osx.sh | 5 + .../libgit2/src/annotated_commit.c | 149 + .../libgit2/src/annotated_commit.h | 22 + deps/libgit2-sys-0.2.17/libgit2/src/array.h | 85 + deps/libgit2-sys-0.2.17/libgit2/src/attr.c | 543 ++ deps/libgit2-sys-0.2.17/libgit2/src/attr.h | 13 + .../libgit2/src/attr_file.c | 867 +++ .../libgit2/src/attr_file.h | 216 + .../libgit2/src/attrcache.c | 455 ++ .../libgit2/src/attrcache.h | 57 + deps/libgit2-sys-0.2.17/libgit2/src/bitvec.h | 75 + deps/libgit2-sys-0.2.17/libgit2/src/blame.c | 511 ++ deps/libgit2-sys-0.2.17/libgit2/src/blame.h | 93 + .../libgit2/src/blame_git.c | 628 ++ .../libgit2/src/blame_git.h | 20 + deps/libgit2-sys-0.2.17/libgit2/src/blob.c | 368 + deps/libgit2-sys-0.2.17/libgit2/src/blob.h | 33 + deps/libgit2-sys-0.2.17/libgit2/src/branch.c | 666 ++ deps/libgit2-sys-0.2.17/libgit2/src/branch.h | 17 + .../libgit2-sys-0.2.17/libgit2/src/buf_text.c | 317 + .../libgit2-sys-0.2.17/libgit2/src/buf_text.h | 123 + deps/libgit2-sys-0.2.17/libgit2/src/buffer.c | 766 ++ deps/libgit2-sys-0.2.17/libgit2/src/buffer.h | 209 + deps/libgit2-sys-0.2.17/libgit2/src/cache.c | 280 + deps/libgit2-sys-0.2.17/libgit2/src/cache.h | 67 + .../libgit2/src/cc-compat.h | 87 + .../libgit2-sys-0.2.17/libgit2/src/checkout.c | 2669 +++++++ .../libgit2-sys-0.2.17/libgit2/src/checkout.h | 25 + .../libgit2/src/cherrypick.c | 229 + deps/libgit2-sys-0.2.17/libgit2/src/clone.c | 566 ++ deps/libgit2-sys-0.2.17/libgit2/src/clone.h | 12 + deps/libgit2-sys-0.2.17/libgit2/src/commit.c | 510 ++ deps/libgit2-sys-0.2.17/libgit2/src/commit.h | 36 + .../libgit2/src/commit_list.c | 200 + .../libgit2/src/commit_list.h | 51 + deps/libgit2-sys-0.2.17/libgit2/src/common.h | 205 + deps/libgit2-sys-0.2.17/libgit2/src/config.c | 1418 ++++ deps/libgit2-sys-0.2.17/libgit2/src/config.h | 85 + .../libgit2/src/config_cache.c | 128 + .../libgit2/src/config_file.c | 1792 +++++ .../libgit2/src/config_file.h | 61 + deps/libgit2-sys-0.2.17/libgit2/src/crlf.c | 360 + deps/libgit2-sys-0.2.17/libgit2/src/date.c | 904 +++ .../libgit2/src/delta-apply.c | 135 + .../libgit2/src/delta-apply.h | 50 + deps/libgit2-sys-0.2.17/libgit2/src/delta.c | 443 ++ deps/libgit2-sys-0.2.17/libgit2/src/delta.h | 114 + .../libgit2-sys-0.2.17/libgit2/src/describe.c | 892 +++ deps/libgit2-sys-0.2.17/libgit2/src/diff.c | 1647 ++++ deps/libgit2-sys-0.2.17/libgit2/src/diff.h | 155 + .../libgit2/src/diff_driver.c | 524 ++ .../libgit2/src/diff_driver.h | 49 + .../libgit2/src/diff_file.c | 429 ++ .../libgit2/src/diff_file.h | 60 + .../libgit2/src/diff_patch.c | 943 +++ .../libgit2/src/diff_patch.h | 47 + .../libgit2/src/diff_print.c | 634 ++ .../libgit2/src/diff_stats.c | 336 + .../libgit2/src/diff_tform.c | 1123 +++ .../libgit2/src/diff_xdiff.c | 241 + .../libgit2/src/diff_xdiff.h | 28 + deps/libgit2-sys-0.2.17/libgit2/src/errors.c | 176 + deps/libgit2-sys-0.2.17/libgit2/src/fetch.c | 139 + deps/libgit2-sys-0.2.17/libgit2/src/fetch.h | 25 + .../libgit2/src/fetchhead.c | 302 + .../libgit2/src/fetchhead.h | 32 + deps/libgit2-sys-0.2.17/libgit2/src/filebuf.c | 486 ++ deps/libgit2-sys-0.2.17/libgit2/src/filebuf.h | 87 + deps/libgit2-sys-0.2.17/libgit2/src/fileops.c | 967 +++ deps/libgit2-sys-0.2.17/libgit2/src/fileops.h | 355 + deps/libgit2-sys-0.2.17/libgit2/src/filter.c | 957 +++ deps/libgit2-sys-0.2.17/libgit2/src/filter.h | 52 + deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.c | 235 + deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.h | 49 + deps/libgit2-sys-0.2.17/libgit2/src/global.c | 401 + deps/libgit2-sys-0.2.17/libgit2/src/global.h | 35 + deps/libgit2-sys-0.2.17/libgit2/src/graph.c | 192 + deps/libgit2-sys-0.2.17/libgit2/src/hash.c | 47 + deps/libgit2-sys-0.2.17/libgit2/src/hash.h | 41 + .../libgit2/src/hash/hash_common_crypto.h | 44 + .../libgit2/src/hash/hash_generic.c | 288 + .../libgit2/src/hash/hash_generic.h | 23 + .../libgit2/src/hash/hash_openssl.h | 44 + .../libgit2/src/hash/hash_win32.c | 276 + .../libgit2/src/hash/hash_win32.h | 140 + deps/libgit2-sys-0.2.17/libgit2/src/hashsig.c | 359 + deps/libgit2-sys-0.2.17/libgit2/src/ident.c | 127 + deps/libgit2-sys-0.2.17/libgit2/src/ignore.c | 532 ++ deps/libgit2-sys-0.2.17/libgit2/src/ignore.h | 63 + deps/libgit2-sys-0.2.17/libgit2/src/index.c | 2805 +++++++ deps/libgit2-sys-0.2.17/libgit2/src/index.h | 126 + deps/libgit2-sys-0.2.17/libgit2/src/indexer.c | 1077 +++ deps/libgit2-sys-0.2.17/libgit2/src/integer.h | 96 + .../libgit2-sys-0.2.17/libgit2/src/iterator.c | 1708 +++++ .../libgit2-sys-0.2.17/libgit2/src/iterator.h | 287 + deps/libgit2-sys-0.2.17/libgit2/src/khash.h | 622 ++ deps/libgit2-sys-0.2.17/libgit2/src/map.h | 46 + deps/libgit2-sys-0.2.17/libgit2/src/merge.c | 2762 +++++++ deps/libgit2-sys-0.2.17/libgit2/src/merge.h | 145 + .../libgit2/src/merge_file.c | 292 + .../libgit2/src/merge_file.h | 14 + deps/libgit2-sys-0.2.17/libgit2/src/message.c | 62 + deps/libgit2-sys-0.2.17/libgit2/src/message.h | 15 + deps/libgit2-sys-0.2.17/libgit2/src/mwindow.c | 430 ++ deps/libgit2-sys-0.2.17/libgit2/src/mwindow.h | 53 + deps/libgit2-sys-0.2.17/libgit2/src/netops.c | 282 + deps/libgit2-sys-0.2.17/libgit2/src/netops.h | 98 + deps/libgit2-sys-0.2.17/libgit2/src/notes.c | 694 ++ deps/libgit2-sys-0.2.17/libgit2/src/notes.h | 32 + deps/libgit2-sys-0.2.17/libgit2/src/object.c | 469 ++ deps/libgit2-sys-0.2.17/libgit2/src/object.h | 31 + .../libgit2/src/object_api.c | 129 + deps/libgit2-sys-0.2.17/libgit2/src/odb.c | 1157 +++ deps/libgit2-sys-0.2.17/libgit2/src/odb.h | 103 + .../libgit2/src/odb_loose.c | 978 +++ .../libgit2/src/odb_mempack.c | 184 + .../libgit2-sys-0.2.17/libgit2/src/odb_pack.c | 691 ++ deps/libgit2-sys-0.2.17/libgit2/src/offmap.h | 66 + deps/libgit2-sys-0.2.17/libgit2/src/oid.c | 441 ++ deps/libgit2-sys-0.2.17/libgit2/src/oid.h | 47 + .../libgit2-sys-0.2.17/libgit2/src/oidarray.c | 21 + .../libgit2-sys-0.2.17/libgit2/src/oidarray.h | 18 + deps/libgit2-sys-0.2.17/libgit2/src/oidmap.h | 52 + .../libgit2/src/openssl_stream.c | 381 + .../libgit2/src/openssl_stream.h | 14 + .../libgit2/src/pack-objects.c | 1686 +++++ .../libgit2/src/pack-objects.h | 104 + deps/libgit2-sys-0.2.17/libgit2/src/pack.c | 1381 ++++ deps/libgit2-sys-0.2.17/libgit2/src/pack.h | 170 + deps/libgit2-sys-0.2.17/libgit2/src/path.c | 1531 ++++ deps/libgit2-sys-0.2.17/libgit2/src/path.h | 522 ++ .../libgit2-sys-0.2.17/libgit2/src/pathspec.c | 725 ++ .../libgit2-sys-0.2.17/libgit2/src/pathspec.h | 75 + deps/libgit2-sys-0.2.17/libgit2/src/pool.c | 325 + deps/libgit2-sys-0.2.17/libgit2/src/pool.h | 148 + deps/libgit2-sys-0.2.17/libgit2/src/posix.c | 259 + deps/libgit2-sys-0.2.17/libgit2/src/posix.h | 161 + deps/libgit2-sys-0.2.17/libgit2/src/pqueue.c | 117 + deps/libgit2-sys-0.2.17/libgit2/src/pqueue.h | 56 + deps/libgit2-sys-0.2.17/libgit2/src/push.c | 694 ++ deps/libgit2-sys-0.2.17/libgit2/src/push.h | 159 + deps/libgit2-sys-0.2.17/libgit2/src/rebase.c | 1171 +++ deps/libgit2-sys-0.2.17/libgit2/src/refdb.c | 263 + deps/libgit2-sys-0.2.17/libgit2/src/refdb.h | 57 + .../libgit2-sys-0.2.17/libgit2/src/refdb_fs.c | 1957 +++++ .../libgit2-sys-0.2.17/libgit2/src/refdb_fs.h | 15 + deps/libgit2-sys-0.2.17/libgit2/src/reflog.c | 232 + deps/libgit2-sys-0.2.17/libgit2/src/reflog.h | 40 + deps/libgit2-sys-0.2.17/libgit2/src/refs.c | 1305 ++++ deps/libgit2-sys-0.2.17/libgit2/src/refs.h | 112 + deps/libgit2-sys-0.2.17/libgit2/src/refspec.c | 356 + deps/libgit2-sys-0.2.17/libgit2/src/refspec.h | 49 + deps/libgit2-sys-0.2.17/libgit2/src/remote.c | 2396 ++++++ deps/libgit2-sys-0.2.17/libgit2/src/remote.h | 47 + .../libgit2/src/repo_template.h | 58 + .../libgit2/src/repository.c | 2290 ++++++ .../libgit2/src/repository.h | 216 + deps/libgit2-sys-0.2.17/libgit2/src/reset.c | 198 + deps/libgit2-sys-0.2.17/libgit2/src/revert.c | 231 + .../libgit2-sys-0.2.17/libgit2/src/revparse.c | 913 +++ deps/libgit2-sys-0.2.17/libgit2/src/revwalk.c | 648 ++ deps/libgit2-sys-0.2.17/libgit2/src/revwalk.h | 50 + .../libgit2-sys-0.2.17/libgit2/src/settings.c | 162 + .../libgit2/src/sha1_lookup.c | 249 + .../libgit2/src/sha1_lookup.h | 23 + .../libgit2/src/signature.c | 283 + .../libgit2/src/signature.h | 21 + .../libgit2/src/socket_stream.c | 212 + .../libgit2/src/socket_stream.h | 21 + .../libgit2/src/sortedcache.c | 380 + .../libgit2/src/sortedcache.h | 178 + deps/libgit2-sys-0.2.17/libgit2/src/stash.c | 653 ++ deps/libgit2-sys-0.2.17/libgit2/src/status.c | 558 ++ deps/libgit2-sys-0.2.17/libgit2/src/status.h | 23 + deps/libgit2-sys-0.2.17/libgit2/src/stream.h | 53 + deps/libgit2-sys-0.2.17/libgit2/src/strmap.c | 32 + deps/libgit2-sys-0.2.17/libgit2/src/strmap.h | 78 + deps/libgit2-sys-0.2.17/libgit2/src/strnlen.h | 24 + .../libgit2/src/submodule.c | 2227 ++++++ .../libgit2/src/submodule.h | 170 + deps/libgit2-sys-0.2.17/libgit2/src/sysdir.c | 252 + deps/libgit2-sys-0.2.17/libgit2/src/sysdir.h | 101 + deps/libgit2-sys-0.2.17/libgit2/src/tag.c | 511 ++ deps/libgit2-sys-0.2.17/libgit2/src/tag.h | 28 + .../libgit2/src/thread-utils.c | 55 + .../libgit2/src/thread-utils.h | 286 + deps/libgit2-sys-0.2.17/libgit2/src/trace.c | 38 + deps/libgit2-sys-0.2.17/libgit2/src/trace.h | 62 + .../libgit2/src/transaction.c | 352 + .../libgit2/src/transport.c | 220 + .../libgit2/src/transports/auth.c | 71 + .../libgit2/src/transports/auth.h | 63 + .../libgit2/src/transports/auth_negotiate.c | 275 + .../libgit2/src/transports/auth_negotiate.h | 27 + .../libgit2/src/transports/cred.c | 326 + .../libgit2/src/transports/cred.h | 14 + .../libgit2/src/transports/cred_helpers.c | 52 + .../libgit2/src/transports/git.c | 363 + .../libgit2/src/transports/http.c | 1038 +++ .../libgit2/src/transports/local.c | 716 ++ .../libgit2/src/transports/smart.c | 419 ++ .../libgit2/src/transports/smart.h | 189 + .../libgit2/src/transports/smart_pkt.c | 596 ++ .../libgit2/src/transports/smart_protocol.c | 1035 +++ .../libgit2/src/transports/ssh.c | 830 +++ .../libgit2/src/transports/winhttp.c | 1351 ++++ .../libgit2/src/tree-cache.c | 269 + .../libgit2/src/tree-cache.h | 37 + deps/libgit2-sys-0.2.17/libgit2/src/tree.c | 982 +++ deps/libgit2-sys-0.2.17/libgit2/src/tree.h | 64 + deps/libgit2-sys-0.2.17/libgit2/src/tsort.c | 385 + .../libgit2-sys-0.2.17/libgit2/src/unix/map.c | 68 + .../libgit2/src/unix/posix.h | 50 + .../libgit2/src/unix/realpath.c | 31 + .../libgit2-sys-0.2.17/libgit2/src/userdiff.h | 208 + deps/libgit2-sys-0.2.17/libgit2/src/util.c | 767 ++ deps/libgit2-sys-0.2.17/libgit2/src/util.h | 473 ++ deps/libgit2-sys-0.2.17/libgit2/src/vector.c | 354 + deps/libgit2-sys-0.2.17/libgit2/src/vector.h | 117 + .../libgit2/src/win32/dir.c | 119 + .../libgit2/src/win32/dir.h | 43 + .../libgit2/src/win32/error.c | 53 + .../libgit2/src/win32/error.h | 13 + .../libgit2/src/win32/findfile.c | 217 + .../libgit2/src/win32/findfile.h | 16 + .../libgit2/src/win32/git2.rc | 44 + .../libgit2/src/win32/map.c | 122 + .../libgit2/src/win32/mingw-compat.h | 29 + .../libgit2/src/win32/msvc-compat.h | 25 + .../libgit2/src/win32/path_w32.c | 305 + .../libgit2/src/win32/path_w32.h | 82 + .../libgit2/src/win32/posix.h | 55 + .../libgit2/src/win32/posix_w32.c | 776 ++ .../libgit2/src/win32/precompiled.c | 1 + .../libgit2/src/win32/precompiled.h | 23 + .../libgit2/src/win32/pthread.c | 267 + .../libgit2/src/win32/pthread.h | 92 + .../libgit2/src/win32/reparse.h | 57 + .../libgit2/src/win32/utf-conv.c | 166 + .../libgit2/src/win32/utf-conv.h | 55 + .../libgit2/src/win32/version.h | 37 + .../libgit2/src/win32/w32_util.c | 139 + .../libgit2/src/win32/w32_util.h | 55 + .../libgit2/src/xdiff/xdiff.h | 135 + .../libgit2/src/xdiff/xdiffi.c | 572 ++ .../libgit2/src/xdiff/xdiffi.h | 63 + .../libgit2/src/xdiff/xemit.c | 253 + .../libgit2/src/xdiff/xemit.h | 36 + .../libgit2/src/xdiff/xhistogram.c | 371 + .../libgit2/src/xdiff/xinclude.h | 46 + .../libgit2/src/xdiff/xmacros.h | 54 + .../libgit2/src/xdiff/xmerge.c | 619 ++ .../libgit2/src/xdiff/xpatience.c | 358 + .../libgit2/src/xdiff/xprepare.c | 483 ++ .../libgit2/src/xdiff/xprepare.h | 34 + .../libgit2/src/xdiff/xtypes.h | 67 + .../libgit2/src/xdiff/xutils.c | 419 ++ .../libgit2/src/xdiff/xutils.h | 49 + deps/libgit2-sys-0.2.17/libgit2/src/zstream.c | 156 + deps/libgit2-sys-0.2.17/libgit2/src/zstream.h | 39 + deps/libssh2-sys-0.1.25/.gitattributes | 2 + deps/libssh2-sys-0.1.25/Cargo.toml | 43 + deps/libssh2-sys-0.1.25/build.rs | 161 + deps/libssh2-sys-0.1.25/lib.rs | 520 ++ deps/libz-sys-0.1.6/.gitignore | 2 + deps/libz-sys-0.1.6/Cargo.toml | 18 + deps/libz-sys-0.1.6/LICENSE-APACHE | 201 + deps/libz-sys-0.1.6/LICENSE-MIT | 25 + deps/libz-sys-0.1.6/README.md | 11 + deps/libz-sys-0.1.6/build.rs | 71 + deps/libz-sys-0.1.6/src/lib.rs | 176 + deps/log-0.3.1/.gitignore | 2 + deps/log-0.3.1/.travis.yml | 20 + deps/log-0.3.1/Cargo.toml | 20 + deps/log-0.3.1/LICENSE-APACHE | 201 + deps/log-0.3.1/LICENSE-MIT | 25 + deps/log-0.3.1/README.md | 80 + deps/log-0.3.1/src/lib.rs | 773 ++ deps/log-0.3.1/src/macros.rs | 145 + deps/log-0.3.1/tests/filters.rs | 64 + deps/matches-0.1.2/Cargo.toml | 14 + deps/matches-0.1.2/lib.rs | 28 + deps/memchr-0.1.3/.gitignore | 9 + deps/memchr-0.1.3/.travis.yml | 12 + deps/memchr-0.1.3/COPYING | 3 + deps/memchr-0.1.3/Cargo.toml | 20 + deps/memchr-0.1.3/LICENSE-MIT | 21 + deps/memchr-0.1.3/Makefile | 14 + deps/memchr-0.1.3/README.md | 23 + deps/memchr-0.1.3/UNLICENSE | 24 + deps/memchr-0.1.3/benches/bench.rs | 26 + deps/memchr-0.1.3/ctags.rust | 11 + deps/memchr-0.1.3/session.vim | 1 + deps/memchr-0.1.3/src/lib.rs | 95 + deps/miniz-sys-0.1.5/Cargo.toml | 22 + deps/miniz-sys-0.1.5/build.rs | 8 + deps/miniz-sys-0.1.5/lib.rs | 72 + deps/miniz-sys-0.1.5/miniz.c | 4986 +++++++++++++ deps/num_cpus-0.2.6/.gitignore | 2 + deps/num_cpus-0.2.6/Cargo.toml | 12 + deps/num_cpus-0.2.6/LICENSE | 20 + deps/num_cpus-0.2.6/README.md | 25 + deps/num_cpus-0.2.6/src/lib.rs | 96 + deps/openssl-sys-0.6.3/Cargo.toml | 37 + deps/openssl-sys-0.6.3/LICENSE-MIT | 25 + deps/openssl-sys-0.6.3/build.rs | 95 + deps/openssl-sys-0.6.3/src/lib.rs | 615 ++ deps/openssl-sys-0.6.3/src/old_openssl_shim.c | 49 + deps/openssl-sys-0.6.3/src/probe.rs | 73 + deps/pkg-config-0.3.5/.gitignore | 2 + deps/pkg-config-0.3.5/.travis.yml | 25 + deps/pkg-config-0.3.5/Cargo.toml | 13 + deps/pkg-config-0.3.5/LICENSE-APACHE | 201 + deps/pkg-config-0.3.5/LICENSE-MIT | 25 + deps/pkg-config-0.3.5/README.md | 25 + deps/pkg-config-0.3.5/src/lib.rs | 291 + deps/pkg-config-0.3.5/tests/foo.pc | 16 + deps/pkg-config-0.3.5/tests/framework.pc | 16 + deps/pkg-config-0.3.5/tests/test.rs | 86 + deps/regex-0.1.38/.gitignore | 4 + deps/regex-0.1.38/.travis.yml | 34 + deps/regex-0.1.38/Cargo.toml | 44 + deps/regex-0.1.38/LICENSE-APACHE | 201 + deps/regex-0.1.38/LICENSE-MIT | 25 + deps/regex-0.1.38/README.md | 35 + deps/regex-0.1.38/appveyor.yml | 23 + deps/regex-0.1.38/examples/regexdna-input.txt | 1671 +++++ .../regex-0.1.38/examples/regexdna-output.txt | 13 + .../examples/shootout-regex-dna.rs | 71 + deps/regex-0.1.38/examples/tiny.rs | 28 + deps/regex-0.1.38/run-shootout-test | 8 + .../regex-0.1.38/scripts/regex-match-tests.py | 107 + deps/regex-0.1.38/scripts/unicode.py | 297 + deps/regex-0.1.38/src/backtrack.rs | 269 + deps/regex-0.1.38/src/char.rs | 107 + deps/regex-0.1.38/src/compile.rs | 249 + deps/regex-0.1.38/src/input.rs | 114 + deps/regex-0.1.38/src/lib.rs | 431 ++ deps/regex-0.1.38/src/nfa.rs | 300 + deps/regex-0.1.38/src/pool.rs | 93 + deps/regex-0.1.38/src/prefix.rs | 157 + deps/regex-0.1.38/src/program.rs | 480 ++ deps/regex-0.1.38/src/re.rs | 1148 +++ deps/regex-0.1.38/src/testdata/LICENSE | 19 + deps/regex-0.1.38/src/testdata/README | 17 + deps/regex-0.1.38/src/testdata/basic.dat | 221 + .../regex-0.1.38/src/testdata/nullsubexpr.dat | 79 + deps/regex-0.1.38/src/testdata/repetition.dat | 163 + deps/regex-syntax-0.1.2/Cargo.toml | 13 + deps/regex-syntax-0.1.2/src/lib.rs | 1184 +++ deps/regex-syntax-0.1.2/src/parser.rs | 2327 ++++++ deps/regex-syntax-0.1.2/src/properties.rs | 407 + deps/regex-syntax-0.1.2/src/unicode.rs | 5053 +++++++++++++ deps/rustc-serialize-0.3.15/.gitignore | 2 + deps/rustc-serialize-0.3.15/.travis.yml | 26 + deps/rustc-serialize-0.3.15/Cargo.toml | 18 + deps/rustc-serialize-0.3.15/LICENSE-APACHE | 201 + deps/rustc-serialize-0.3.15/LICENSE-MIT | 25 + deps/rustc-serialize-0.3.15/README.md | 24 + deps/rustc-serialize-0.3.15/appveyor.yml | 11 + deps/rustc-serialize-0.3.15/benches/base64.rs | 48 + deps/rustc-serialize-0.3.15/benches/hex.rs | 28 + deps/rustc-serialize-0.3.15/benches/json.rs | 84 + deps/rustc-serialize-0.3.15/src/base64.rs | 468 ++ .../src/collection_impls.rs | 186 + deps/rustc-serialize-0.3.15/src/hex.rs | 209 + deps/rustc-serialize-0.3.15/src/json.rs | 3906 ++++++++++ deps/rustc-serialize-0.3.15/src/lib.rs | 55 + deps/rustc-serialize-0.3.15/src/serialize.rs | 732 ++ deps/semver-0.1.19/.gitignore | 3 + deps/semver-0.1.19/.travis.yml | 20 + deps/semver-0.1.19/Cargo.toml | 12 + deps/semver-0.1.19/LICENSE-APACHE | 201 + deps/semver-0.1.19/LICENSE-MIT | 25 + deps/semver-0.1.19/README.md | 104 + deps/semver-0.1.19/src/lib.rs | 138 + deps/semver-0.1.19/src/version.rs | 491 ++ deps/semver-0.1.19/src/version_req.rs | 877 +++ deps/strsim-0.3.0/.gitignore | 2 + deps/strsim-0.3.0/.travis.yml | 5 + deps/strsim-0.3.0/Cargo.toml | 15 + deps/strsim-0.3.0/LICENSE | 22 + deps/strsim-0.3.0/README.md | 49 + deps/strsim-0.3.0/src/lib.rs | 470 ++ deps/strsim-0.3.0/tests/lib.rs | 33 + deps/tar-0.2.14/.gitignore | 2 + deps/tar-0.2.14/.travis.yml | 28 + deps/tar-0.2.14/Cargo.toml | 27 + deps/tar-0.2.14/LICENSE-APACHE | 201 + deps/tar-0.2.14/LICENSE-MIT | 25 + deps/tar-0.2.14/README.md | 76 + deps/tar-0.2.14/appveyor.yml | 13 + deps/tar-0.2.14/src/lib.rs | 992 +++ deps/tar-0.2.14/src/tests/directory.tar | Bin 0 -> 10240 bytes deps/tar-0.2.14/src/tests/duplicate_dirs.tar | Bin 0 -> 2048 bytes deps/tar-0.2.14/src/tests/empty_filename.tar | Bin 0 -> 512 bytes deps/tar-0.2.14/src/tests/reading_files.tar | Bin 0 -> 10240 bytes deps/tar-0.2.14/src/tests/simple.tar | Bin 0 -> 10240 bytes deps/tar-0.2.14/src/tests/spaces.tar | Bin 0 -> 2048 bytes deps/term-0.2.9/.gitignore | 2 + deps/term-0.2.9/.travis.yml | 25 + deps/term-0.2.9/Cargo.toml | 20 + deps/term-0.2.9/LICENSE-APACHE | 201 + deps/term-0.2.9/LICENSE-MIT | 25 + deps/term-0.2.9/README.md | 25 + deps/term-0.2.9/appveyor.yml | 23 + deps/term-0.2.9/src/lib.rs | 247 + deps/term-0.2.9/src/terminfo/mod.rs | 275 + deps/term-0.2.9/src/terminfo/parm.rs | 707 ++ .../src/terminfo/parser/compiled.rs | 359 + deps/term-0.2.9/src/terminfo/searcher.rs | 79 + deps/term-0.2.9/src/win.rs | 274 + deps/threadpool-0.1.4/.gitignore | 2 + deps/threadpool-0.1.4/.travis.yml | 20 + deps/threadpool-0.1.4/Cargo.toml | 16 + deps/threadpool-0.1.4/LICENSE-APACHE | 201 + deps/threadpool-0.1.4/LICENSE-MIT | 25 + deps/threadpool-0.1.4/README.md | 24 + deps/threadpool-0.1.4/src/lib.rs | 363 + deps/time-0.1.26/.gitignore | 2 + deps/time-0.1.26/.travis.yml | 27 + deps/time-0.1.26/Cargo.toml | 23 + deps/time-0.1.26/LICENSE-APACHE | 201 + deps/time-0.1.26/LICENSE-MIT | 25 + deps/time-0.1.26/README.md | 24 + deps/time-0.1.26/appveyor.yml | 13 + deps/time-0.1.26/benches/precise_time_ns.rs | 11 + deps/time-0.1.26/build.rs | 16 + deps/time-0.1.26/src/display.rs | 260 + deps/time-0.1.26/src/duration.rs | 560 ++ deps/time-0.1.26/src/lib.rs | 1553 ++++ deps/time-0.1.26/src/parse.rs | 390 + deps/time-0.1.26/src/time_helpers.c | 183 + deps/toml-0.1.21/.gitignore | 2 + deps/toml-0.1.21/.travis.yml | 28 + deps/toml-0.1.21/Cargo.toml | 25 + deps/toml-0.1.21/LICENSE-APACHE | 201 + deps/toml-0.1.21/LICENSE-MIT | 25 + deps/toml-0.1.21/README.md | 25 + deps/toml-0.1.21/examples/toml2json.rs | 57 + deps/toml-0.1.21/src/decoder/mod.rs | 205 + .../src/decoder/rustc_serialize.rs | 368 + deps/toml-0.1.21/src/display.rs | 202 + deps/toml-0.1.21/src/encoder/mod.rs | 210 + .../src/encoder/rustc_serialize.rs | 689 ++ deps/toml-0.1.21/src/lib.rs | 263 + deps/toml-0.1.21/src/parser.rs | 1418 ++++ deps/toml-0.1.21/tests/README.md | 1 + .../array-mixed-types-ints-and-floats.json | 15 + deps/toml-0.1.21/tests/invalid.rs | 78 + .../array-mixed-types-arrays-and-ints.toml | 1 + .../array-mixed-types-ints-and-floats.toml | 1 + .../array-mixed-types-strings-and-ints.toml | 1 + .../invalid/datetime-malformed-no-leads.toml | 1 + .../invalid/datetime-malformed-no-secs.toml | 1 + .../invalid/datetime-malformed-no-t.toml | 1 + .../invalid/datetime-malformed-no-z.toml | 1 + .../datetime-malformed-with-milli.toml | 1 + .../tests/invalid/duplicate-key-table.toml | 5 + .../tests/invalid/duplicate-keys.toml | 2 + .../tests/invalid/duplicate-tables.toml | 2 + .../tests/invalid/empty-implicit-table.toml | 1 + .../tests/invalid/empty-table.toml | 1 + .../tests/invalid/float-no-leading-zero.toml | 2 + .../invalid/float-no-trailing-digits.toml | 2 + .../tests/invalid/key-two-equals.toml | 1 + .../tests/invalid/string-bad-byte-escape.toml | 1 + .../tests/invalid/string-bad-escape.toml | 1 + .../tests/invalid/string-byte-escapes.toml | 1 + .../tests/invalid/string-no-close.toml | 1 + .../tests/invalid/table-array-implicit.toml | 14 + .../table-array-malformed-bracket.toml | 2 + .../invalid/table-array-malformed-empty.toml | 2 + .../invalid/table-nested-brackets-close.toml | 2 + .../invalid/table-nested-brackets-open.toml | 2 + .../invalid/text-after-array-entries.toml | 4 + .../tests/invalid/text-after-integer.toml | 1 + .../tests/invalid/text-after-string.toml | 1 + .../tests/invalid/text-after-table.toml | 1 + .../invalid/text-before-array-separator.toml | 4 + .../tests/invalid/text-in-array.toml | 5 + deps/toml-0.1.21/tests/valid.rs | 180 + deps/toml-0.1.21/tests/valid/array-empty.json | 11 + deps/toml-0.1.21/tests/valid/array-empty.toml | 1 + .../tests/valid/array-nospaces.json | 10 + .../tests/valid/array-nospaces.toml | 1 + .../tests/valid/arrays-hetergeneous.json | 19 + .../tests/valid/arrays-hetergeneous.toml | 1 + .../tests/valid/arrays-nested.json | 13 + .../tests/valid/arrays-nested.toml | 1 + deps/toml-0.1.21/tests/valid/arrays.json | 34 + deps/toml-0.1.21/tests/valid/arrays.toml | 9 + deps/toml-0.1.21/tests/valid/bool.json | 4 + deps/toml-0.1.21/tests/valid/bool.toml | 2 + .../tests/valid/comments-everywhere.json | 12 + .../tests/valid/comments-everywhere.toml | 24 + deps/toml-0.1.21/tests/valid/datetime.json | 3 + deps/toml-0.1.21/tests/valid/datetime.toml | 1 + deps/toml-0.1.21/tests/valid/empty.json | 1 + deps/toml-0.1.21/tests/valid/empty.toml | 0 .../tests/valid/example-v0.3.0.json | 1 + .../tests/valid/example-v0.3.0.toml | 182 + .../tests/valid/example-v0.4.0.json | 1 + .../tests/valid/example-v0.4.0.toml | 235 + deps/toml-0.1.21/tests/valid/example.json | 14 + deps/toml-0.1.21/tests/valid/example.toml | 5 + deps/toml-0.1.21/tests/valid/example2.json | 1 + deps/toml-0.1.21/tests/valid/example2.toml | 47 + deps/toml-0.1.21/tests/valid/float.json | 4 + deps/toml-0.1.21/tests/valid/float.toml | 2 + .../toml-0.1.21/tests/valid/hard_example.json | 1 + .../toml-0.1.21/tests/valid/hard_example.toml | 33 + .../valid/implicit-and-explicit-after.json | 10 + .../valid/implicit-and-explicit-after.toml | 5 + .../valid/implicit-and-explicit-before.json | 10 + .../valid/implicit-and-explicit-before.toml | 5 + .../tests/valid/implicit-groups.json | 9 + .../tests/valid/implicit-groups.toml | 2 + deps/toml-0.1.21/tests/valid/integer.json | 4 + deps/toml-0.1.21/tests/valid/integer.toml | 2 + .../tests/valid/key-equals-nospace.json | 3 + .../tests/valid/key-equals-nospace.toml | 1 + .../tests/valid/key-special-chars.json | 5 + .../tests/valid/key-special-chars.toml | 1 + .../tests/valid/key-with-pound.json | 3 + .../tests/valid/key-with-pound.toml | 1 + deps/toml-0.1.21/tests/valid/long-float.json | 4 + deps/toml-0.1.21/tests/valid/long-float.toml | 2 + .../toml-0.1.21/tests/valid/long-integer.json | 4 + .../toml-0.1.21/tests/valid/long-integer.toml | 2 + .../toml-0.1.21/tests/valid/string-empty.json | 6 + .../toml-0.1.21/tests/valid/string-empty.toml | 1 + .../tests/valid/string-escapes.json | 34 + .../tests/valid/string-escapes.toml | 8 + .../tests/valid/string-simple.json | 6 + .../tests/valid/string-simple.toml | 1 + .../tests/valid/string-with-pound.json | 7 + .../tests/valid/string-with-pound.toml | 2 + .../tests/valid/table-array-implicit.json | 7 + .../tests/valid/table-array-implicit.toml | 2 + .../tests/valid/table-array-many.json | 16 + .../tests/valid/table-array-many.toml | 11 + .../tests/valid/table-array-nest.json | 18 + .../tests/valid/table-array-nest.toml | 17 + .../tests/valid/table-array-one.json | 8 + .../tests/valid/table-array-one.toml | 3 + deps/toml-0.1.21/tests/valid/table-empty.json | 3 + deps/toml-0.1.21/tests/valid/table-empty.toml | 1 + .../tests/valid/table-sub-empty.json | 3 + .../tests/valid/table-sub-empty.toml | 2 + .../tests/valid/table-whitespace.json | 3 + .../tests/valid/table-whitespace.toml | 1 + .../tests/valid/table-with-pound.json | 5 + .../tests/valid/table-with-pound.toml | 2 + .../tests/valid/unicode-escape.json | 3 + .../tests/valid/unicode-escape.toml | 1 + .../tests/valid/unicode-literal.json | 3 + .../tests/valid/unicode-literal.toml | 1 + deps/url-0.2.35/.gitignore | 3 + deps/url-0.2.35/.travis.yml | 9 + deps/url-0.2.35/Cargo.toml | 25 + deps/url-0.2.35/LICENSE-APACHE | 201 + deps/url-0.2.35/LICENSE-MIT | 26 + deps/url-0.2.35/Makefile | 17 + deps/url-0.2.35/README.md | 24 + deps/url-0.2.35/appveyor.yml | 13 + deps/url-0.2.35/github.png | Bin 0 -> 7786 bytes deps/url-0.2.35/make_encode_sets.py | 41 + deps/url-0.2.35/src/encode_sets.rs | 260 + deps/url-0.2.35/src/encoding.rs | 97 + deps/url-0.2.35/src/form_urlencoded.rs | 174 + deps/url-0.2.35/src/format.rs | 141 + deps/url-0.2.35/src/host.rs | 280 + deps/url-0.2.35/src/lib.rs | 1024 +++ deps/url-0.2.35/src/parser.rs | 747 ++ deps/url-0.2.35/src/percent_encoding.rs | 146 + deps/url-0.2.35/src/punycode.rs | 267 + deps/url-0.2.35/src/punycode_tests.json | 120 + deps/url-0.2.35/src/tests.rs | 287 + deps/url-0.2.35/src/urltestdata.txt | 329 + deps/url-0.2.35/src/urlutils.rs | 169 + deps/winapi-0.1.23/.gitignore | 2 + deps/winapi-0.1.23/.travis.yml | 16 + deps/winapi-0.1.23/CONTRIBUTING.md | 14 + deps/winapi-0.1.23/Cargo.toml | 33 + deps/winapi-0.1.23/LICENSE.md | 21 + deps/winapi-0.1.23/README.md | 454 ++ deps/winapi-0.1.23/src/audioclient.rs | 120 + deps/winapi-0.1.23/src/basetsd.rs | 99 + deps/winapi-0.1.23/src/bcrypt.rs | 4 + deps/winapi-0.1.23/src/commctrl.rs | 26 + deps/winapi-0.1.23/src/d3d9.rs | 718 ++ deps/winapi-0.1.23/src/d3d9caps.rs | 362 + deps/winapi-0.1.23/src/d3d9types.rs | 1562 ++++ deps/winapi-0.1.23/src/dbghelp.rs | 346 + deps/winapi-0.1.23/src/dwmapi.rs | 10 + deps/winapi-0.1.23/src/fileapi.rs | 47 + deps/winapi-0.1.23/src/heapapi.rs | 13 + deps/winapi-0.1.23/src/inaddr.rs | 7 + deps/winapi-0.1.23/src/lib.rs | 1976 +++++ deps/winapi-0.1.23/src/libloaderapi.rs | 5 + deps/winapi-0.1.23/src/minwinbase.rs | 165 + deps/winapi-0.1.23/src/minwindef.rs | 90 + deps/winapi-0.1.23/src/mmdeviceapi.rs | 86 + deps/winapi-0.1.23/src/mmreg.rs | 268 + deps/winapi-0.1.23/src/mmsystem.rs | 212 + deps/winapi-0.1.23/src/objidl.rs | 50 + deps/winapi-0.1.23/src/objidlbase.rs | 80 + deps/winapi-0.1.23/src/processthreadsapi.rs | 46 + deps/winapi-0.1.23/src/propsys.rs | 4 + deps/winapi-0.1.23/src/schannel.rs | 365 + deps/winapi-0.1.23/src/shellapi.rs | 6 + deps/winapi-0.1.23/src/shobjidl.rs | 224 + deps/winapi-0.1.23/src/shtypes.rs | 41 + deps/winapi-0.1.23/src/sspi.rs | 663 ++ deps/winapi-0.1.23/src/synchapi.rs | 5 + deps/winapi-0.1.23/src/timezoneapi.rs | 32 + deps/winapi-0.1.23/src/unknwnbase.rs | 21 + deps/winapi-0.1.23/src/vadefs.rs | 7 + deps/winapi-0.1.23/src/winbase.rs | 158 + deps/winapi-0.1.23/src/wincon.rs | 231 + deps/winapi-0.1.23/src/wincred.rs | 79 + deps/winapi-0.1.23/src/wincrypt.rs | 1394 ++++ deps/winapi-0.1.23/src/windef.rs | 9 + deps/winapi-0.1.23/src/windowsx.rs | 22 + deps/winapi-0.1.23/src/winerror.rs | 6057 +++++++++++++++ deps/winapi-0.1.23/src/wingdi.rs | 233 + deps/winapi-0.1.23/src/winioctl.rs | 244 + deps/winapi-0.1.23/src/winnetwk.rs | 320 + deps/winapi-0.1.23/src/winnls.rs | 10 + deps/winapi-0.1.23/src/winnt.rs | 1353 ++++ deps/winapi-0.1.23/src/winsock2.rs | 24 + deps/winapi-0.1.23/src/winsvc.rs | 209 + deps/winapi-0.1.23/src/winuser.rs | 654 ++ deps/winapi-0.1.23/src/ws2def.rs | 176 + deps/winapi-0.1.23/src/wtypesbase.rs | 9 + deps/winapi-0.1.23/tests/advapi32.rs | 95 + deps/winapi-0.1.23/tests/dwmapi.rs | 10 + deps/winapi-0.1.23/tests/gdi32.rs | 36 + deps/winapi-0.1.23/tests/kernel32.rs | 11 + deps/winapi-0.1.23/tests/ktmw32.rs | 12 + deps/winapi-0.1.23/tests/mpr.rs | 48 + deps/winapi-0.1.23/tests/shell32.rs | 35 + deps/winapi-0.1.23/tests/user32.rs | 200 + deps/winapi-0.1.23/tests/uuid.rs | 127 + deps/winapi-0.1.23/tests/winmm.rs | 50 + deps/winapi-build-0.1.0/Cargo.toml | 11 + deps/winapi-build-0.1.0/src/lib.rs | 14 + 1030 files changed, 262708 insertions(+) create mode 100644 deps/advapi32-sys-0.1.1/Cargo.toml create mode 100644 deps/advapi32-sys-0.1.1/README.md create mode 100644 deps/advapi32-sys-0.1.1/build.rs create mode 100644 deps/advapi32-sys-0.1.1/src/lib.rs create mode 100644 deps/aho-corasick-0.2.1/.gitignore create mode 100644 deps/aho-corasick-0.2.1/.travis.yml create mode 100644 deps/aho-corasick-0.2.1/COPYING create mode 100644 deps/aho-corasick-0.2.1/Cargo.toml create mode 100644 deps/aho-corasick-0.2.1/LICENSE-MIT create mode 100644 deps/aho-corasick-0.2.1/Makefile create mode 100644 deps/aho-corasick-0.2.1/README.md create mode 100644 deps/aho-corasick-0.2.1/UNLICENSE create mode 100644 deps/aho-corasick-0.2.1/benches/bench.rs create mode 100644 deps/aho-corasick-0.2.1/benches/random.txt create mode 100644 deps/aho-corasick-0.2.1/ctags.rust create mode 100644 deps/aho-corasick-0.2.1/examples/dict-search.rs create mode 100644 deps/aho-corasick-0.2.1/session.vim create mode 100644 deps/aho-corasick-0.2.1/src/autiter.rs create mode 100644 deps/aho-corasick-0.2.1/src/full.rs create mode 100644 deps/aho-corasick-0.2.1/src/lib.rs create mode 100644 deps/aho-corasick-0.2.1/src/main.rs create mode 100644 deps/bitflags-0.1.1/.gitignore create mode 100644 deps/bitflags-0.1.1/.travis.yml create mode 100644 deps/bitflags-0.1.1/Cargo.toml create mode 100644 deps/bitflags-0.1.1/LICENSE-APACHE create mode 100644 deps/bitflags-0.1.1/LICENSE-MIT create mode 100644 deps/bitflags-0.1.1/README.md create mode 100644 deps/bitflags-0.1.1/src/lib.rs create mode 100644 deps/curl-0.2.10/.gitignore create mode 100644 deps/curl-0.2.10/.gitmodules create mode 100644 deps/curl-0.2.10/Cargo.toml create mode 100644 deps/curl-0.2.10/LICENSE create mode 100644 deps/curl-0.2.10/README.md create mode 100644 deps/curl-0.2.10/src/ffi/consts.rs create mode 100644 deps/curl-0.2.10/src/ffi/easy.rs create mode 100644 deps/curl-0.2.10/src/ffi/err.rs create mode 100644 deps/curl-0.2.10/src/ffi/info.rs create mode 100644 deps/curl-0.2.10/src/ffi/list.rs create mode 100644 deps/curl-0.2.10/src/ffi/mod.rs create mode 100644 deps/curl-0.2.10/src/ffi/opt.rs create mode 100644 deps/curl-0.2.10/src/ffi/version.rs create mode 100644 deps/curl-0.2.10/src/http/body.rs create mode 100644 deps/curl-0.2.10/src/http/handle.rs create mode 100644 deps/curl-0.2.10/src/http/header.rs create mode 100644 deps/curl-0.2.10/src/http/mod.rs create mode 100644 deps/curl-0.2.10/src/http/response.rs create mode 100644 deps/curl-0.2.10/src/lib.rs create mode 100644 deps/curl-0.2.10/test/server.rs create mode 100644 deps/curl-0.2.10/test/test.rs create mode 100644 deps/curl-0.2.10/test/test_delete.rs create mode 100644 deps/curl-0.2.10/test/test_get.rs create mode 100644 deps/curl-0.2.10/test/test_head.rs create mode 100644 deps/curl-0.2.10/test/test_keep_alive.rs create mode 100644 deps/curl-0.2.10/test/test_patch.rs create mode 100644 deps/curl-0.2.10/test/test_post.rs create mode 100644 deps/curl-0.2.10/test/test_proxy.rs create mode 100644 deps/curl-0.2.10/test/test_put.rs create mode 100644 deps/curl-sys-0.1.24/Cargo.toml create mode 100644 deps/curl-sys-0.1.24/build.rs create mode 100644 deps/curl-sys-0.1.24/lib.rs create mode 100644 deps/docopt-0.6.67/.gitignore create mode 100644 deps/docopt-0.6.67/.travis.yml create mode 100644 deps/docopt-0.6.67/COPYING create mode 100644 deps/docopt-0.6.67/Cargo.toml create mode 100644 deps/docopt-0.6.67/LICENSE-MIT create mode 100644 deps/docopt-0.6.67/Makefile create mode 100644 deps/docopt-0.6.67/README.md create mode 100644 deps/docopt-0.6.67/UNLICENSE create mode 100644 deps/docopt-0.6.67/completions/docopt-wordlist.bash create mode 100644 deps/docopt-0.6.67/ctags.rust create mode 100644 deps/docopt-0.6.67/examples/cargo.rs create mode 100644 deps/docopt-0.6.67/examples/cp.rs create mode 100644 deps/docopt-0.6.67/examples/decode.rs create mode 100644 deps/docopt-0.6.67/examples/hashmap.rs create mode 100644 deps/docopt-0.6.67/examples/optional_command.rs create mode 100644 deps/docopt-0.6.67/examples/verbose_multiple.rs create mode 100755 deps/docopt-0.6.67/scripts/mk-testcases create mode 100644 deps/docopt-0.6.67/session.vim create mode 100644 deps/docopt-0.6.67/src/dopt.rs create mode 100644 deps/docopt-0.6.67/src/lib.rs create mode 100644 deps/docopt-0.6.67/src/parse.rs create mode 100644 deps/docopt-0.6.67/src/synonym.rs create mode 100644 deps/docopt-0.6.67/src/test/mod.rs create mode 100644 deps/docopt-0.6.67/src/test/suggestions.rs create mode 100644 deps/docopt-0.6.67/src/test/testcases.docopt create mode 100644 deps/docopt-0.6.67/src/test/testcases.rs create mode 100644 deps/docopt-0.6.67/src/wordlist.rs create mode 100644 deps/encoding-0.2.32/.gitignore create mode 100644 deps/encoding-0.2.32/.travis.yml create mode 100644 deps/encoding-0.2.32/AUTHORS.txt create mode 100644 deps/encoding-0.2.32/Cargo.toml create mode 100644 deps/encoding-0.2.32/LICENSE.txt create mode 100644 deps/encoding-0.2.32/Makefile create mode 100644 deps/encoding-0.2.32/README.md create mode 100644 deps/encoding-0.2.32/examples/recode.rs create mode 100644 deps/encoding-0.2.32/src/all.rs create mode 100644 deps/encoding-0.2.32/src/codec/ascii.rs create mode 100644 deps/encoding-0.2.32/src/codec/error.rs create mode 100644 deps/encoding-0.2.32/src/codec/japanese.rs create mode 100644 deps/encoding-0.2.32/src/codec/korean.rs create mode 100644 deps/encoding-0.2.32/src/codec/simpchinese.rs create mode 100644 deps/encoding-0.2.32/src/codec/singlebyte.rs create mode 100644 deps/encoding-0.2.32/src/codec/tradchinese.rs create mode 100644 deps/encoding-0.2.32/src/codec/utf_16.rs create mode 100644 deps/encoding-0.2.32/src/codec/utf_8.rs create mode 100644 deps/encoding-0.2.32/src/codec/whatwg.rs create mode 100644 deps/encoding-0.2.32/src/examples/UTF-8-test.txt create mode 100644 deps/encoding-0.2.32/src/examples/outer-space-treaty.html create mode 100644 deps/encoding-0.2.32/src/index/gen_index.py create mode 100644 deps/encoding-0.2.32/src/label.rs create mode 100644 deps/encoding-0.2.32/src/lib.rs create mode 100644 deps/encoding-0.2.32/src/testutils.rs create mode 100644 deps/encoding-0.2.32/src/types.rs create mode 100644 deps/encoding-0.2.32/src/util.rs create mode 100644 deps/encoding-index-japanese-1.20141219.5/Cargo.toml create mode 100644 deps/encoding-index-japanese-1.20141219.5/jis0208.rs create mode 100644 deps/encoding-index-japanese-1.20141219.5/jis0212.rs create mode 100644 deps/encoding-index-japanese-1.20141219.5/lib.rs create mode 100644 deps/encoding-index-korean-1.20141219.5/Cargo.toml create mode 100644 deps/encoding-index-korean-1.20141219.5/euc_kr.rs create mode 100644 deps/encoding-index-korean-1.20141219.5/lib.rs create mode 100644 deps/encoding-index-simpchinese-1.20141219.5/Cargo.toml create mode 100644 deps/encoding-index-simpchinese-1.20141219.5/gb18030.rs create mode 100644 deps/encoding-index-simpchinese-1.20141219.5/gb18030_ranges.rs create mode 100644 deps/encoding-index-simpchinese-1.20141219.5/lib.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/Cargo.toml create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/ibm866.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_10.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_13.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_14.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_15.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_16.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_2.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_3.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_4.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_5.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_6.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_7.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/iso_8859_8.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/koi8_r.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/koi8_u.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/lib.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/macintosh.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1250.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1251.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1252.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1253.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1254.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1255.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1256.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1257.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_1258.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/windows_874.rs create mode 100644 deps/encoding-index-singlebyte-1.20141219.5/x_mac_cyrillic.rs create mode 100644 deps/encoding-index-tradchinese-1.20141219.5/Cargo.toml create mode 100644 deps/encoding-index-tradchinese-1.20141219.5/big5.rs create mode 100644 deps/encoding-index-tradchinese-1.20141219.5/lib.rs create mode 100644 deps/encoding_index_tests-0.1.4/Cargo.toml create mode 100644 deps/encoding_index_tests-0.1.4/index_tests.rs create mode 100644 deps/env_logger-0.3.1/Cargo.toml create mode 100644 deps/env_logger-0.3.1/src/lib.rs create mode 100644 deps/filetime-0.1.4/.gitignore create mode 100644 deps/filetime-0.1.4/.travis.yml create mode 100644 deps/filetime-0.1.4/Cargo.toml create mode 100644 deps/filetime-0.1.4/LICENSE-APACHE create mode 100644 deps/filetime-0.1.4/LICENSE-MIT create mode 100644 deps/filetime-0.1.4/README.md create mode 100644 deps/filetime-0.1.4/appveyor.yml create mode 100644 deps/filetime-0.1.4/src/lib.rs create mode 100644 deps/flate2-0.2.7/.gitignore create mode 100644 deps/flate2-0.2.7/.travis.yml create mode 100644 deps/flate2-0.2.7/Cargo.toml create mode 100644 deps/flate2-0.2.7/LICENSE-APACHE create mode 100644 deps/flate2-0.2.7/LICENSE-MIT create mode 100644 deps/flate2-0.2.7/README.md create mode 100644 deps/flate2-0.2.7/src/crc.rs create mode 100644 deps/flate2-0.2.7/src/deflate.rs create mode 100644 deps/flate2-0.2.7/src/gz.rs create mode 100644 deps/flate2-0.2.7/src/lib.rs create mode 100644 deps/flate2-0.2.7/src/raw.rs create mode 100644 deps/flate2-0.2.7/src/stream.rs create mode 100644 deps/flate2-0.2.7/src/zlib.rs create mode 100644 deps/flate2-0.2.7/tests/corrupt-file.gz create mode 100644 deps/flate2-0.2.7/tests/good-file.gz create mode 100644 deps/flate2-0.2.7/tests/good-file.txt create mode 100644 deps/flate2-0.2.7/tests/gunzip.rs create mode 100644 deps/gcc-0.3.8/.gitignore create mode 100644 deps/gcc-0.3.8/.travis.yml create mode 100644 deps/gcc-0.3.8/Cargo.toml create mode 100644 deps/gcc-0.3.8/LICENSE-APACHE create mode 100644 deps/gcc-0.3.8/LICENSE-MIT create mode 100644 deps/gcc-0.3.8/README.md create mode 100644 deps/gcc-0.3.8/appveyor.yml create mode 100644 deps/gcc-0.3.8/src/lib.rs create mode 100644 deps/git2-0.2.12/.gitignore create mode 100644 deps/git2-0.2.12/.gitmodules create mode 100644 deps/git2-0.2.12/.travis.yml create mode 100644 deps/git2-0.2.12/Cargo.toml create mode 100644 deps/git2-0.2.12/LICENSE-APACHE create mode 100644 deps/git2-0.2.12/LICENSE-MIT create mode 100644 deps/git2-0.2.12/README.md create mode 100644 deps/git2-0.2.12/examples/add.rs create mode 100644 deps/git2-0.2.12/examples/blame.rs create mode 100644 deps/git2-0.2.12/examples/cat-file.rs create mode 100644 deps/git2-0.2.12/examples/clone.rs create mode 100644 deps/git2-0.2.12/examples/diff.rs create mode 100644 deps/git2-0.2.12/examples/fetch.rs create mode 100644 deps/git2-0.2.12/examples/init.rs create mode 100644 deps/git2-0.2.12/examples/log.rs create mode 100644 deps/git2-0.2.12/examples/ls-remote.rs create mode 100644 deps/git2-0.2.12/examples/rev-list.rs create mode 100644 deps/git2-0.2.12/examples/rev-parse.rs create mode 100644 deps/git2-0.2.12/examples/status.rs create mode 100644 deps/git2-0.2.12/examples/tag.rs create mode 100644 deps/git2-0.2.12/src/blame.rs create mode 100644 deps/git2-0.2.12/src/blob.rs create mode 100644 deps/git2-0.2.12/src/branch.rs create mode 100644 deps/git2-0.2.12/src/buf.rs create mode 100644 deps/git2-0.2.12/src/build.rs create mode 100644 deps/git2-0.2.12/src/call.rs create mode 100644 deps/git2-0.2.12/src/cert.rs create mode 100644 deps/git2-0.2.12/src/commit.rs create mode 100644 deps/git2-0.2.12/src/config.rs create mode 100644 deps/git2-0.2.12/src/cred.rs create mode 100644 deps/git2-0.2.12/src/diff.rs create mode 100644 deps/git2-0.2.12/src/error.rs create mode 100644 deps/git2-0.2.12/src/index.rs create mode 100644 deps/git2-0.2.12/src/lib.rs create mode 100644 deps/git2-0.2.12/src/note.rs create mode 100644 deps/git2-0.2.12/src/object.rs create mode 100644 deps/git2-0.2.12/src/oid.rs create mode 100644 deps/git2-0.2.12/src/panic.rs create mode 100644 deps/git2-0.2.12/src/pathspec.rs create mode 100644 deps/git2-0.2.12/src/push.rs create mode 100644 deps/git2-0.2.12/src/reference.rs create mode 100644 deps/git2-0.2.12/src/reflog.rs create mode 100644 deps/git2-0.2.12/src/refspec.rs create mode 100644 deps/git2-0.2.12/src/remote.rs create mode 100644 deps/git2-0.2.12/src/remote_callbacks.rs create mode 100644 deps/git2-0.2.12/src/repo.rs create mode 100644 deps/git2-0.2.12/src/revspec.rs create mode 100644 deps/git2-0.2.12/src/revwalk.rs create mode 100644 deps/git2-0.2.12/src/signature.rs create mode 100644 deps/git2-0.2.12/src/status.rs create mode 100644 deps/git2-0.2.12/src/string_array.rs create mode 100644 deps/git2-0.2.12/src/submodule.rs create mode 100644 deps/git2-0.2.12/src/tag.rs create mode 100644 deps/git2-0.2.12/src/test.rs create mode 100644 deps/git2-0.2.12/src/time.rs create mode 100644 deps/git2-0.2.12/src/transport.rs create mode 100644 deps/git2-0.2.12/src/tree.rs create mode 100644 deps/git2-0.2.12/src/util.rs create mode 100644 deps/git2-curl-0.2.4/Cargo.toml create mode 100644 deps/git2-curl-0.2.4/src/lib.rs create mode 100644 deps/git2-curl-0.2.4/tests/all.rs create mode 100644 deps/git2-curl-0.2.4/tests/tempdir.rs create mode 100644 deps/glob-0.2.10/.gitignore create mode 100644 deps/glob-0.2.10/.travis.yml create mode 100644 deps/glob-0.2.10/Cargo.toml create mode 100644 deps/glob-0.2.10/LICENSE-APACHE create mode 100644 deps/glob-0.2.10/LICENSE-MIT create mode 100644 deps/glob-0.2.10/README.md create mode 100644 deps/glob-0.2.10/src/lib.rs create mode 100644 deps/glob-0.2.10/tests/glob-std.rs create mode 100644 deps/kernel32-sys-0.1.2/Cargo.toml create mode 100644 deps/kernel32-sys-0.1.2/README.md create mode 100644 deps/kernel32-sys-0.1.2/build.rs create mode 100644 deps/kernel32-sys-0.1.2/src/lib.rs create mode 100644 deps/libc-0.1.8/Cargo.toml create mode 100644 deps/libc-0.1.8/rust/src/liblibc/lib.rs create mode 100644 deps/libgit2-sys-0.2.17/Cargo.toml create mode 100644 deps/libgit2-sys-0.2.17/build.rs create mode 100644 deps/libgit2-sys-0.2.17/lib.rs create mode 100644 deps/libgit2-sys-0.2.17/libgit2/.HEADER create mode 100644 deps/libgit2-sys-0.2.17/libgit2/.editorconfig create mode 100644 deps/libgit2-sys-0.2.17/libgit2/.gitattributes create mode 100644 deps/libgit2-sys-0.2.17/libgit2/.gitignore create mode 100644 deps/libgit2-sys-0.2.17/libgit2/.mailmap create mode 100644 deps/libgit2-sys-0.2.17/libgit2/.travis.yml create mode 100644 deps/libgit2-sys-0.2.17/libgit2/AUTHORS create mode 100644 deps/libgit2-sys-0.2.17/libgit2/CHANGELOG.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/CMakeLists.txt create mode 100644 deps/libgit2-sys-0.2.17/libgit2/CONTRIBUTING.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/CONVENTIONS.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/COPYING create mode 100644 deps/libgit2-sys-0.2.17/libgit2/Makefile.embed create mode 100644 deps/libgit2-sys-0.2.17/libgit2/PROJECTS.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/README.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/THREADING.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/api.docurium create mode 100644 deps/libgit2-sys-0.2.17/libgit2/appveyor.yml create mode 100644 deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/AddCFlagIfSupported.cmake create mode 100644 deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindGSSAPI.cmake create mode 100644 deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindHTTP_Parser.cmake create mode 100644 deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindIconv.cmake create mode 100644 deps/libgit2-sys-0.2.17/libgit2/docs/checkout-internals.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/docs/diff-internals.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/docs/error-handling.md create mode 100644 deps/libgit2-sys-0.2.17/libgit2/docs/merge-df_conflicts.txt create mode 100644 deps/libgit2-sys-0.2.17/libgit2/git.git-authors create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/annotated_commit.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/attr.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/blame.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/blob.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/branch.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/buffer.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/checkout.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/cherrypick.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/clone.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/commit.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/common.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/config.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/cred_helpers.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/describe.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/diff.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/errors.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/filter.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/global.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/graph.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/ignore.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/index.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/indexer.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/inttypes.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/merge.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/message.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/net.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/notes.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/object.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/odb.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/odb_backend.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/oid.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/oidarray.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/pack.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/patch.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/pathspec.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/push.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/rebase.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/refdb.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/reflog.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/refs.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/refspec.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/remote.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/repository.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/reset.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/revert.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/revparse.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/revwalk.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/signature.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/stash.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/status.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/stdint.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/strarray.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/submodule.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/commit.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/config.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/diff.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/filter.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/hashsig.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/index.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/mempack.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/odb_backend.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/openssl.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refdb_backend.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/reflog.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refs.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/repository.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/stream.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/transport.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/tag.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/trace.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/transaction.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/transport.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/tree.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/types.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/include/git2/version.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/libgit2.pc.in create mode 100644 deps/libgit2-sys-0.2.17/libgit2/libgit2_clar.supp create mode 100755 deps/libgit2-sys-0.2.17/libgit2/script/appveyor-mingw.sh create mode 100755 deps/libgit2-sys-0.2.17/libgit2/script/cibuild.sh create mode 100755 deps/libgit2-sys-0.2.17/libgit2/script/coverity.sh create mode 100755 deps/libgit2-sys-0.2.17/libgit2/script/install-deps-linux.sh create mode 100755 deps/libgit2-sys-0.2.17/libgit2/script/install-deps-osx.sh create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/array.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/attr.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/attr.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/attr_file.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/attr_file.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/attrcache.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/attrcache.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/bitvec.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/blame.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/blame.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/blame_git.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/blame_git.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/blob.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/blob.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/branch.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/branch.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/buf_text.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/buf_text.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/buffer.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/buffer.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/cache.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/cache.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/cc-compat.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/checkout.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/checkout.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/cherrypick.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/clone.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/clone.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/commit.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/commit.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/commit_list.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/commit_list.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/common.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/config.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/config.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/config_cache.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/config_file.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/config_file.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/crlf.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/date.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/delta.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/delta.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/describe.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_file.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_file.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_print.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_stats.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_tform.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/errors.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fetch.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fetch.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/filebuf.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/filebuf.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fileops.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fileops.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/filter.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/filter.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/global.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/global.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/graph.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_common_crypto.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_openssl.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/hashsig.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/ident.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/ignore.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/ignore.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/index.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/index.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/indexer.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/integer.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/iterator.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/iterator.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/khash.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/map.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/merge.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/merge.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/merge_file.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/merge_file.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/message.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/message.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/mwindow.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/mwindow.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/netops.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/netops.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/notes.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/notes.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/object.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/object.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/object_api.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/odb.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/odb.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/odb_loose.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/odb_mempack.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/odb_pack.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/offmap.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/oid.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/oid.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/oidarray.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/oidarray.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/oidmap.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pack.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pack.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/path.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/path.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pathspec.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pathspec.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pool.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pool.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/posix.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/posix.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pqueue.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/pqueue.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/push.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/push.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/rebase.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refdb.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refdb.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/reflog.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/reflog.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refs.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refs.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refspec.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/refspec.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/remote.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/remote.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/repo_template.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/repository.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/repository.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/reset.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/revert.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/revparse.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/revwalk.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/revwalk.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/settings.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/signature.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/signature.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/stash.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/status.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/status.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/stream.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/strmap.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/strmap.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/strnlen.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/submodule.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/submodule.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/sysdir.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/sysdir.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tag.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tag.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/trace.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/trace.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transaction.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transport.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/cred_helpers.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/git.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/http.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/local.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_pkt.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_protocol.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/ssh.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/transports/winhttp.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tree.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tree.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/tsort.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/unix/map.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/unix/posix.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/unix/realpath.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/userdiff.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/util.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/util.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/vector.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/vector.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/error.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/error.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/git2.rc create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/map.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/mingw-compat.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/msvc-compat.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/posix.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/posix_w32.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/reparse.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/version.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiff.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xhistogram.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xinclude.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmacros.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmerge.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xpatience.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xtypes.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.h create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/zstream.c create mode 100644 deps/libgit2-sys-0.2.17/libgit2/src/zstream.h create mode 100644 deps/libssh2-sys-0.1.25/.gitattributes create mode 100644 deps/libssh2-sys-0.1.25/Cargo.toml create mode 100644 deps/libssh2-sys-0.1.25/build.rs create mode 100644 deps/libssh2-sys-0.1.25/lib.rs create mode 100644 deps/libz-sys-0.1.6/.gitignore create mode 100644 deps/libz-sys-0.1.6/Cargo.toml create mode 100644 deps/libz-sys-0.1.6/LICENSE-APACHE create mode 100644 deps/libz-sys-0.1.6/LICENSE-MIT create mode 100644 deps/libz-sys-0.1.6/README.md create mode 100644 deps/libz-sys-0.1.6/build.rs create mode 100644 deps/libz-sys-0.1.6/src/lib.rs create mode 100644 deps/log-0.3.1/.gitignore create mode 100644 deps/log-0.3.1/.travis.yml create mode 100644 deps/log-0.3.1/Cargo.toml create mode 100644 deps/log-0.3.1/LICENSE-APACHE create mode 100644 deps/log-0.3.1/LICENSE-MIT create mode 100644 deps/log-0.3.1/README.md create mode 100644 deps/log-0.3.1/src/lib.rs create mode 100644 deps/log-0.3.1/src/macros.rs create mode 100644 deps/log-0.3.1/tests/filters.rs create mode 100644 deps/matches-0.1.2/Cargo.toml create mode 100644 deps/matches-0.1.2/lib.rs create mode 100644 deps/memchr-0.1.3/.gitignore create mode 100644 deps/memchr-0.1.3/.travis.yml create mode 100644 deps/memchr-0.1.3/COPYING create mode 100644 deps/memchr-0.1.3/Cargo.toml create mode 100644 deps/memchr-0.1.3/LICENSE-MIT create mode 100644 deps/memchr-0.1.3/Makefile create mode 100644 deps/memchr-0.1.3/README.md create mode 100644 deps/memchr-0.1.3/UNLICENSE create mode 100644 deps/memchr-0.1.3/benches/bench.rs create mode 100644 deps/memchr-0.1.3/ctags.rust create mode 100644 deps/memchr-0.1.3/session.vim create mode 100644 deps/memchr-0.1.3/src/lib.rs create mode 100644 deps/miniz-sys-0.1.5/Cargo.toml create mode 100644 deps/miniz-sys-0.1.5/build.rs create mode 100644 deps/miniz-sys-0.1.5/lib.rs create mode 100644 deps/miniz-sys-0.1.5/miniz.c create mode 100644 deps/num_cpus-0.2.6/.gitignore create mode 100644 deps/num_cpus-0.2.6/Cargo.toml create mode 100644 deps/num_cpus-0.2.6/LICENSE create mode 100644 deps/num_cpus-0.2.6/README.md create mode 100644 deps/num_cpus-0.2.6/src/lib.rs create mode 100644 deps/openssl-sys-0.6.3/Cargo.toml create mode 100644 deps/openssl-sys-0.6.3/LICENSE-MIT create mode 100644 deps/openssl-sys-0.6.3/build.rs create mode 100644 deps/openssl-sys-0.6.3/src/lib.rs create mode 100644 deps/openssl-sys-0.6.3/src/old_openssl_shim.c create mode 100644 deps/openssl-sys-0.6.3/src/probe.rs create mode 100644 deps/pkg-config-0.3.5/.gitignore create mode 100644 deps/pkg-config-0.3.5/.travis.yml create mode 100644 deps/pkg-config-0.3.5/Cargo.toml create mode 100644 deps/pkg-config-0.3.5/LICENSE-APACHE create mode 100644 deps/pkg-config-0.3.5/LICENSE-MIT create mode 100644 deps/pkg-config-0.3.5/README.md create mode 100644 deps/pkg-config-0.3.5/src/lib.rs create mode 100644 deps/pkg-config-0.3.5/tests/foo.pc create mode 100644 deps/pkg-config-0.3.5/tests/framework.pc create mode 100644 deps/pkg-config-0.3.5/tests/test.rs create mode 100644 deps/regex-0.1.38/.gitignore create mode 100644 deps/regex-0.1.38/.travis.yml create mode 100644 deps/regex-0.1.38/Cargo.toml create mode 100644 deps/regex-0.1.38/LICENSE-APACHE create mode 100644 deps/regex-0.1.38/LICENSE-MIT create mode 100644 deps/regex-0.1.38/README.md create mode 100644 deps/regex-0.1.38/appveyor.yml create mode 100644 deps/regex-0.1.38/examples/regexdna-input.txt create mode 100644 deps/regex-0.1.38/examples/regexdna-output.txt create mode 100644 deps/regex-0.1.38/examples/shootout-regex-dna.rs create mode 100644 deps/regex-0.1.38/examples/tiny.rs create mode 100755 deps/regex-0.1.38/run-shootout-test create mode 100755 deps/regex-0.1.38/scripts/regex-match-tests.py create mode 100755 deps/regex-0.1.38/scripts/unicode.py create mode 100644 deps/regex-0.1.38/src/backtrack.rs create mode 100644 deps/regex-0.1.38/src/char.rs create mode 100644 deps/regex-0.1.38/src/compile.rs create mode 100644 deps/regex-0.1.38/src/input.rs create mode 100644 deps/regex-0.1.38/src/lib.rs create mode 100644 deps/regex-0.1.38/src/nfa.rs create mode 100644 deps/regex-0.1.38/src/pool.rs create mode 100644 deps/regex-0.1.38/src/prefix.rs create mode 100644 deps/regex-0.1.38/src/program.rs create mode 100644 deps/regex-0.1.38/src/re.rs create mode 100644 deps/regex-0.1.38/src/testdata/LICENSE create mode 100644 deps/regex-0.1.38/src/testdata/README create mode 100644 deps/regex-0.1.38/src/testdata/basic.dat create mode 100644 deps/regex-0.1.38/src/testdata/nullsubexpr.dat create mode 100644 deps/regex-0.1.38/src/testdata/repetition.dat create mode 100644 deps/regex-syntax-0.1.2/Cargo.toml create mode 100644 deps/regex-syntax-0.1.2/src/lib.rs create mode 100644 deps/regex-syntax-0.1.2/src/parser.rs create mode 100644 deps/regex-syntax-0.1.2/src/properties.rs create mode 100644 deps/regex-syntax-0.1.2/src/unicode.rs create mode 100644 deps/rustc-serialize-0.3.15/.gitignore create mode 100644 deps/rustc-serialize-0.3.15/.travis.yml create mode 100644 deps/rustc-serialize-0.3.15/Cargo.toml create mode 100644 deps/rustc-serialize-0.3.15/LICENSE-APACHE create mode 100644 deps/rustc-serialize-0.3.15/LICENSE-MIT create mode 100644 deps/rustc-serialize-0.3.15/README.md create mode 100644 deps/rustc-serialize-0.3.15/appveyor.yml create mode 100644 deps/rustc-serialize-0.3.15/benches/base64.rs create mode 100644 deps/rustc-serialize-0.3.15/benches/hex.rs create mode 100644 deps/rustc-serialize-0.3.15/benches/json.rs create mode 100644 deps/rustc-serialize-0.3.15/src/base64.rs create mode 100644 deps/rustc-serialize-0.3.15/src/collection_impls.rs create mode 100644 deps/rustc-serialize-0.3.15/src/hex.rs create mode 100644 deps/rustc-serialize-0.3.15/src/json.rs create mode 100644 deps/rustc-serialize-0.3.15/src/lib.rs create mode 100644 deps/rustc-serialize-0.3.15/src/serialize.rs create mode 100644 deps/semver-0.1.19/.gitignore create mode 100644 deps/semver-0.1.19/.travis.yml create mode 100644 deps/semver-0.1.19/Cargo.toml create mode 100644 deps/semver-0.1.19/LICENSE-APACHE create mode 100644 deps/semver-0.1.19/LICENSE-MIT create mode 100644 deps/semver-0.1.19/README.md create mode 100644 deps/semver-0.1.19/src/lib.rs create mode 100644 deps/semver-0.1.19/src/version.rs create mode 100644 deps/semver-0.1.19/src/version_req.rs create mode 100644 deps/strsim-0.3.0/.gitignore create mode 100644 deps/strsim-0.3.0/.travis.yml create mode 100644 deps/strsim-0.3.0/Cargo.toml create mode 100644 deps/strsim-0.3.0/LICENSE create mode 100644 deps/strsim-0.3.0/README.md create mode 100644 deps/strsim-0.3.0/src/lib.rs create mode 100644 deps/strsim-0.3.0/tests/lib.rs create mode 100644 deps/tar-0.2.14/.gitignore create mode 100644 deps/tar-0.2.14/.travis.yml create mode 100644 deps/tar-0.2.14/Cargo.toml create mode 100644 deps/tar-0.2.14/LICENSE-APACHE create mode 100644 deps/tar-0.2.14/LICENSE-MIT create mode 100644 deps/tar-0.2.14/README.md create mode 100644 deps/tar-0.2.14/appveyor.yml create mode 100644 deps/tar-0.2.14/src/lib.rs create mode 100644 deps/tar-0.2.14/src/tests/directory.tar create mode 100644 deps/tar-0.2.14/src/tests/duplicate_dirs.tar create mode 100644 deps/tar-0.2.14/src/tests/empty_filename.tar create mode 100644 deps/tar-0.2.14/src/tests/reading_files.tar create mode 100644 deps/tar-0.2.14/src/tests/simple.tar create mode 100755 deps/tar-0.2.14/src/tests/spaces.tar create mode 100644 deps/term-0.2.9/.gitignore create mode 100644 deps/term-0.2.9/.travis.yml create mode 100644 deps/term-0.2.9/Cargo.toml create mode 100644 deps/term-0.2.9/LICENSE-APACHE create mode 100644 deps/term-0.2.9/LICENSE-MIT create mode 100644 deps/term-0.2.9/README.md create mode 100644 deps/term-0.2.9/appveyor.yml create mode 100644 deps/term-0.2.9/src/lib.rs create mode 100644 deps/term-0.2.9/src/terminfo/mod.rs create mode 100644 deps/term-0.2.9/src/terminfo/parm.rs create mode 100644 deps/term-0.2.9/src/terminfo/parser/compiled.rs create mode 100644 deps/term-0.2.9/src/terminfo/searcher.rs create mode 100644 deps/term-0.2.9/src/win.rs create mode 100644 deps/threadpool-0.1.4/.gitignore create mode 100644 deps/threadpool-0.1.4/.travis.yml create mode 100644 deps/threadpool-0.1.4/Cargo.toml create mode 100644 deps/threadpool-0.1.4/LICENSE-APACHE create mode 100644 deps/threadpool-0.1.4/LICENSE-MIT create mode 100644 deps/threadpool-0.1.4/README.md create mode 100644 deps/threadpool-0.1.4/src/lib.rs create mode 100644 deps/time-0.1.26/.gitignore create mode 100644 deps/time-0.1.26/.travis.yml create mode 100644 deps/time-0.1.26/Cargo.toml create mode 100644 deps/time-0.1.26/LICENSE-APACHE create mode 100644 deps/time-0.1.26/LICENSE-MIT create mode 100644 deps/time-0.1.26/README.md create mode 100644 deps/time-0.1.26/appveyor.yml create mode 100644 deps/time-0.1.26/benches/precise_time_ns.rs create mode 100644 deps/time-0.1.26/build.rs create mode 100644 deps/time-0.1.26/src/display.rs create mode 100644 deps/time-0.1.26/src/duration.rs create mode 100644 deps/time-0.1.26/src/lib.rs create mode 100644 deps/time-0.1.26/src/parse.rs create mode 100644 deps/time-0.1.26/src/time_helpers.c create mode 100644 deps/toml-0.1.21/.gitignore create mode 100644 deps/toml-0.1.21/.travis.yml create mode 100644 deps/toml-0.1.21/Cargo.toml create mode 100644 deps/toml-0.1.21/LICENSE-APACHE create mode 100644 deps/toml-0.1.21/LICENSE-MIT create mode 100644 deps/toml-0.1.21/README.md create mode 100644 deps/toml-0.1.21/examples/toml2json.rs create mode 100644 deps/toml-0.1.21/src/decoder/mod.rs create mode 100644 deps/toml-0.1.21/src/decoder/rustc_serialize.rs create mode 100644 deps/toml-0.1.21/src/display.rs create mode 100644 deps/toml-0.1.21/src/encoder/mod.rs create mode 100644 deps/toml-0.1.21/src/encoder/rustc_serialize.rs create mode 100644 deps/toml-0.1.21/src/lib.rs create mode 100644 deps/toml-0.1.21/src/parser.rs create mode 100644 deps/toml-0.1.21/tests/README.md create mode 100644 deps/toml-0.1.21/tests/invalid-encoder/array-mixed-types-ints-and-floats.json create mode 100644 deps/toml-0.1.21/tests/invalid.rs create mode 100644 deps/toml-0.1.21/tests/invalid/array-mixed-types-arrays-and-ints.toml create mode 100644 deps/toml-0.1.21/tests/invalid/array-mixed-types-ints-and-floats.toml create mode 100644 deps/toml-0.1.21/tests/invalid/array-mixed-types-strings-and-ints.toml create mode 100644 deps/toml-0.1.21/tests/invalid/datetime-malformed-no-leads.toml create mode 100644 deps/toml-0.1.21/tests/invalid/datetime-malformed-no-secs.toml create mode 100644 deps/toml-0.1.21/tests/invalid/datetime-malformed-no-t.toml create mode 100644 deps/toml-0.1.21/tests/invalid/datetime-malformed-no-z.toml create mode 100644 deps/toml-0.1.21/tests/invalid/datetime-malformed-with-milli.toml create mode 100644 deps/toml-0.1.21/tests/invalid/duplicate-key-table.toml create mode 100644 deps/toml-0.1.21/tests/invalid/duplicate-keys.toml create mode 100644 deps/toml-0.1.21/tests/invalid/duplicate-tables.toml create mode 100644 deps/toml-0.1.21/tests/invalid/empty-implicit-table.toml create mode 100644 deps/toml-0.1.21/tests/invalid/empty-table.toml create mode 100644 deps/toml-0.1.21/tests/invalid/float-no-leading-zero.toml create mode 100644 deps/toml-0.1.21/tests/invalid/float-no-trailing-digits.toml create mode 100644 deps/toml-0.1.21/tests/invalid/key-two-equals.toml create mode 100644 deps/toml-0.1.21/tests/invalid/string-bad-byte-escape.toml create mode 100644 deps/toml-0.1.21/tests/invalid/string-bad-escape.toml create mode 100644 deps/toml-0.1.21/tests/invalid/string-byte-escapes.toml create mode 100644 deps/toml-0.1.21/tests/invalid/string-no-close.toml create mode 100644 deps/toml-0.1.21/tests/invalid/table-array-implicit.toml create mode 100644 deps/toml-0.1.21/tests/invalid/table-array-malformed-bracket.toml create mode 100644 deps/toml-0.1.21/tests/invalid/table-array-malformed-empty.toml create mode 100644 deps/toml-0.1.21/tests/invalid/table-nested-brackets-close.toml create mode 100644 deps/toml-0.1.21/tests/invalid/table-nested-brackets-open.toml create mode 100644 deps/toml-0.1.21/tests/invalid/text-after-array-entries.toml create mode 100644 deps/toml-0.1.21/tests/invalid/text-after-integer.toml create mode 100644 deps/toml-0.1.21/tests/invalid/text-after-string.toml create mode 100644 deps/toml-0.1.21/tests/invalid/text-after-table.toml create mode 100644 deps/toml-0.1.21/tests/invalid/text-before-array-separator.toml create mode 100644 deps/toml-0.1.21/tests/invalid/text-in-array.toml create mode 100644 deps/toml-0.1.21/tests/valid.rs create mode 100644 deps/toml-0.1.21/tests/valid/array-empty.json create mode 100644 deps/toml-0.1.21/tests/valid/array-empty.toml create mode 100644 deps/toml-0.1.21/tests/valid/array-nospaces.json create mode 100644 deps/toml-0.1.21/tests/valid/array-nospaces.toml create mode 100644 deps/toml-0.1.21/tests/valid/arrays-hetergeneous.json create mode 100644 deps/toml-0.1.21/tests/valid/arrays-hetergeneous.toml create mode 100644 deps/toml-0.1.21/tests/valid/arrays-nested.json create mode 100644 deps/toml-0.1.21/tests/valid/arrays-nested.toml create mode 100644 deps/toml-0.1.21/tests/valid/arrays.json create mode 100644 deps/toml-0.1.21/tests/valid/arrays.toml create mode 100644 deps/toml-0.1.21/tests/valid/bool.json create mode 100644 deps/toml-0.1.21/tests/valid/bool.toml create mode 100644 deps/toml-0.1.21/tests/valid/comments-everywhere.json create mode 100644 deps/toml-0.1.21/tests/valid/comments-everywhere.toml create mode 100644 deps/toml-0.1.21/tests/valid/datetime.json create mode 100644 deps/toml-0.1.21/tests/valid/datetime.toml create mode 100644 deps/toml-0.1.21/tests/valid/empty.json create mode 100644 deps/toml-0.1.21/tests/valid/empty.toml create mode 100644 deps/toml-0.1.21/tests/valid/example-v0.3.0.json create mode 100644 deps/toml-0.1.21/tests/valid/example-v0.3.0.toml create mode 100644 deps/toml-0.1.21/tests/valid/example-v0.4.0.json create mode 100644 deps/toml-0.1.21/tests/valid/example-v0.4.0.toml create mode 100644 deps/toml-0.1.21/tests/valid/example.json create mode 100644 deps/toml-0.1.21/tests/valid/example.toml create mode 100644 deps/toml-0.1.21/tests/valid/example2.json create mode 100644 deps/toml-0.1.21/tests/valid/example2.toml create mode 100644 deps/toml-0.1.21/tests/valid/float.json create mode 100644 deps/toml-0.1.21/tests/valid/float.toml create mode 100644 deps/toml-0.1.21/tests/valid/hard_example.json create mode 100644 deps/toml-0.1.21/tests/valid/hard_example.toml create mode 100644 deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.json create mode 100644 deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.toml create mode 100644 deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.json create mode 100644 deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.toml create mode 100644 deps/toml-0.1.21/tests/valid/implicit-groups.json create mode 100644 deps/toml-0.1.21/tests/valid/implicit-groups.toml create mode 100644 deps/toml-0.1.21/tests/valid/integer.json create mode 100644 deps/toml-0.1.21/tests/valid/integer.toml create mode 100644 deps/toml-0.1.21/tests/valid/key-equals-nospace.json create mode 100644 deps/toml-0.1.21/tests/valid/key-equals-nospace.toml create mode 100644 deps/toml-0.1.21/tests/valid/key-special-chars.json create mode 100644 deps/toml-0.1.21/tests/valid/key-special-chars.toml create mode 100644 deps/toml-0.1.21/tests/valid/key-with-pound.json create mode 100644 deps/toml-0.1.21/tests/valid/key-with-pound.toml create mode 100644 deps/toml-0.1.21/tests/valid/long-float.json create mode 100644 deps/toml-0.1.21/tests/valid/long-float.toml create mode 100644 deps/toml-0.1.21/tests/valid/long-integer.json create mode 100644 deps/toml-0.1.21/tests/valid/long-integer.toml create mode 100644 deps/toml-0.1.21/tests/valid/string-empty.json create mode 100644 deps/toml-0.1.21/tests/valid/string-empty.toml create mode 100644 deps/toml-0.1.21/tests/valid/string-escapes.json create mode 100644 deps/toml-0.1.21/tests/valid/string-escapes.toml create mode 100644 deps/toml-0.1.21/tests/valid/string-simple.json create mode 100644 deps/toml-0.1.21/tests/valid/string-simple.toml create mode 100644 deps/toml-0.1.21/tests/valid/string-with-pound.json create mode 100644 deps/toml-0.1.21/tests/valid/string-with-pound.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-array-implicit.json create mode 100644 deps/toml-0.1.21/tests/valid/table-array-implicit.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-array-many.json create mode 100644 deps/toml-0.1.21/tests/valid/table-array-many.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-array-nest.json create mode 100644 deps/toml-0.1.21/tests/valid/table-array-nest.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-array-one.json create mode 100644 deps/toml-0.1.21/tests/valid/table-array-one.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-empty.json create mode 100644 deps/toml-0.1.21/tests/valid/table-empty.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-sub-empty.json create mode 100644 deps/toml-0.1.21/tests/valid/table-sub-empty.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-whitespace.json create mode 100644 deps/toml-0.1.21/tests/valid/table-whitespace.toml create mode 100644 deps/toml-0.1.21/tests/valid/table-with-pound.json create mode 100644 deps/toml-0.1.21/tests/valid/table-with-pound.toml create mode 100644 deps/toml-0.1.21/tests/valid/unicode-escape.json create mode 100644 deps/toml-0.1.21/tests/valid/unicode-escape.toml create mode 100644 deps/toml-0.1.21/tests/valid/unicode-literal.json create mode 100644 deps/toml-0.1.21/tests/valid/unicode-literal.toml create mode 100644 deps/url-0.2.35/.gitignore create mode 100644 deps/url-0.2.35/.travis.yml create mode 100644 deps/url-0.2.35/Cargo.toml create mode 100644 deps/url-0.2.35/LICENSE-APACHE create mode 100644 deps/url-0.2.35/LICENSE-MIT create mode 100644 deps/url-0.2.35/Makefile create mode 100644 deps/url-0.2.35/README.md create mode 100644 deps/url-0.2.35/appveyor.yml create mode 100644 deps/url-0.2.35/github.png create mode 100644 deps/url-0.2.35/make_encode_sets.py create mode 100644 deps/url-0.2.35/src/encode_sets.rs create mode 100644 deps/url-0.2.35/src/encoding.rs create mode 100644 deps/url-0.2.35/src/form_urlencoded.rs create mode 100644 deps/url-0.2.35/src/format.rs create mode 100644 deps/url-0.2.35/src/host.rs create mode 100644 deps/url-0.2.35/src/lib.rs create mode 100644 deps/url-0.2.35/src/parser.rs create mode 100644 deps/url-0.2.35/src/percent_encoding.rs create mode 100644 deps/url-0.2.35/src/punycode.rs create mode 100644 deps/url-0.2.35/src/punycode_tests.json create mode 100644 deps/url-0.2.35/src/tests.rs create mode 100644 deps/url-0.2.35/src/urltestdata.txt create mode 100644 deps/url-0.2.35/src/urlutils.rs create mode 100644 deps/winapi-0.1.23/.gitignore create mode 100644 deps/winapi-0.1.23/.travis.yml create mode 100644 deps/winapi-0.1.23/CONTRIBUTING.md create mode 100644 deps/winapi-0.1.23/Cargo.toml create mode 100644 deps/winapi-0.1.23/LICENSE.md create mode 100644 deps/winapi-0.1.23/README.md create mode 100644 deps/winapi-0.1.23/src/audioclient.rs create mode 100644 deps/winapi-0.1.23/src/basetsd.rs create mode 100644 deps/winapi-0.1.23/src/bcrypt.rs create mode 100644 deps/winapi-0.1.23/src/commctrl.rs create mode 100644 deps/winapi-0.1.23/src/d3d9.rs create mode 100644 deps/winapi-0.1.23/src/d3d9caps.rs create mode 100644 deps/winapi-0.1.23/src/d3d9types.rs create mode 100644 deps/winapi-0.1.23/src/dbghelp.rs create mode 100644 deps/winapi-0.1.23/src/dwmapi.rs create mode 100644 deps/winapi-0.1.23/src/fileapi.rs create mode 100644 deps/winapi-0.1.23/src/heapapi.rs create mode 100644 deps/winapi-0.1.23/src/inaddr.rs create mode 100644 deps/winapi-0.1.23/src/lib.rs create mode 100644 deps/winapi-0.1.23/src/libloaderapi.rs create mode 100644 deps/winapi-0.1.23/src/minwinbase.rs create mode 100644 deps/winapi-0.1.23/src/minwindef.rs create mode 100644 deps/winapi-0.1.23/src/mmdeviceapi.rs create mode 100644 deps/winapi-0.1.23/src/mmreg.rs create mode 100644 deps/winapi-0.1.23/src/mmsystem.rs create mode 100644 deps/winapi-0.1.23/src/objidl.rs create mode 100644 deps/winapi-0.1.23/src/objidlbase.rs create mode 100644 deps/winapi-0.1.23/src/processthreadsapi.rs create mode 100644 deps/winapi-0.1.23/src/propsys.rs create mode 100644 deps/winapi-0.1.23/src/schannel.rs create mode 100644 deps/winapi-0.1.23/src/shellapi.rs create mode 100644 deps/winapi-0.1.23/src/shobjidl.rs create mode 100644 deps/winapi-0.1.23/src/shtypes.rs create mode 100644 deps/winapi-0.1.23/src/sspi.rs create mode 100644 deps/winapi-0.1.23/src/synchapi.rs create mode 100644 deps/winapi-0.1.23/src/timezoneapi.rs create mode 100644 deps/winapi-0.1.23/src/unknwnbase.rs create mode 100644 deps/winapi-0.1.23/src/vadefs.rs create mode 100644 deps/winapi-0.1.23/src/winbase.rs create mode 100644 deps/winapi-0.1.23/src/wincon.rs create mode 100644 deps/winapi-0.1.23/src/wincred.rs create mode 100644 deps/winapi-0.1.23/src/wincrypt.rs create mode 100644 deps/winapi-0.1.23/src/windef.rs create mode 100644 deps/winapi-0.1.23/src/windowsx.rs create mode 100644 deps/winapi-0.1.23/src/winerror.rs create mode 100644 deps/winapi-0.1.23/src/wingdi.rs create mode 100644 deps/winapi-0.1.23/src/winioctl.rs create mode 100644 deps/winapi-0.1.23/src/winnetwk.rs create mode 100644 deps/winapi-0.1.23/src/winnls.rs create mode 100644 deps/winapi-0.1.23/src/winnt.rs create mode 100644 deps/winapi-0.1.23/src/winsock2.rs create mode 100644 deps/winapi-0.1.23/src/winsvc.rs create mode 100644 deps/winapi-0.1.23/src/winuser.rs create mode 100644 deps/winapi-0.1.23/src/ws2def.rs create mode 100644 deps/winapi-0.1.23/src/wtypesbase.rs create mode 100644 deps/winapi-0.1.23/tests/advapi32.rs create mode 100644 deps/winapi-0.1.23/tests/dwmapi.rs create mode 100644 deps/winapi-0.1.23/tests/gdi32.rs create mode 100644 deps/winapi-0.1.23/tests/kernel32.rs create mode 100644 deps/winapi-0.1.23/tests/ktmw32.rs create mode 100644 deps/winapi-0.1.23/tests/mpr.rs create mode 100644 deps/winapi-0.1.23/tests/shell32.rs create mode 100644 deps/winapi-0.1.23/tests/user32.rs create mode 100644 deps/winapi-0.1.23/tests/uuid.rs create mode 100644 deps/winapi-0.1.23/tests/winmm.rs create mode 100644 deps/winapi-build-0.1.0/Cargo.toml create mode 100644 deps/winapi-build-0.1.0/src/lib.rs diff --git a/deps/advapi32-sys-0.1.1/Cargo.toml b/deps/advapi32-sys-0.1.1/Cargo.toml new file mode 100644 index 000000000..889bfc447 --- /dev/null +++ b/deps/advapi32-sys-0.1.1/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "advapi32-sys" +version = "0.1.1" +authors = ["Peter Atashian "] +description = "FFI bindings to advapi32." +documentation = "https://retep998.github.io/doc/advapi32-sys/" +repository = "https://github.com/retep998/winapi-rs" +readme = "README.md" +keywords = ["Windows", "FFI", "WinSDK"] +license = "MIT" +build = "build.rs" +links = "advapi32" + +[lib] +name = "advapi32" + +[dependencies] +winapi = { version = "*", path = "../.." } +[build-dependencies] +winapi-build = { version = "*", path = "../../build" } diff --git a/deps/advapi32-sys-0.1.1/README.md b/deps/advapi32-sys-0.1.1/README.md new file mode 100644 index 000000000..593ccfea6 --- /dev/null +++ b/deps/advapi32-sys-0.1.1/README.md @@ -0,0 +1,4 @@ +# advapi32-sys # +FFI bindings to advapi32. + +[Documentation](https://retep998.github.io/doc/advapi32-sys/) diff --git a/deps/advapi32-sys-0.1.1/build.rs b/deps/advapi32-sys-0.1.1/build.rs new file mode 100644 index 000000000..639d0b305 --- /dev/null +++ b/deps/advapi32-sys-0.1.1/build.rs @@ -0,0 +1,6 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License +extern crate build; +fn main() { + build::link("advapi32", false) +} diff --git a/deps/advapi32-sys-0.1.1/src/lib.rs b/deps/advapi32-sys-0.1.1/src/lib.rs new file mode 100644 index 000000000..5b40ca072 --- /dev/null +++ b/deps/advapi32-sys-0.1.1/src/lib.rs @@ -0,0 +1,931 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License +//! FFI bindings to advapi32. +#![cfg(windows)] +extern crate winapi; +use winapi::*; +extern "system" { + // pub fn AbortSystemShutdownA(); + // pub fn AbortSystemShutdownW(); + // pub fn AccessCheck(); + // pub fn AccessCheckAndAuditAlarmA(); + // pub fn AccessCheckAndAuditAlarmW(); + // pub fn AccessCheckByType(); + // pub fn AccessCheckByTypeAndAuditAlarmA(); + // pub fn AccessCheckByTypeAndAuditAlarmW(); + // pub fn AccessCheckByTypeResultList(); + // pub fn AccessCheckByTypeResultListAndAuditAlarmA(); + // pub fn AccessCheckByTypeResultListAndAuditAlarmByHandleA(); + // pub fn AccessCheckByTypeResultListAndAuditAlarmByHandleW(); + // pub fn AccessCheckByTypeResultListAndAuditAlarmW(); + // pub fn AddAccessAllowedAce(); + // pub fn AddAccessAllowedAceEx(); + // pub fn AddAccessAllowedObjectAce(); + // pub fn AddAccessDeniedAce(); + // pub fn AddAccessDeniedAceEx(); + // pub fn AddAccessDeniedObjectAce(); + // pub fn AddAce(); + // pub fn AddAuditAccessAce(); + // pub fn AddAuditAccessAceEx(); + // pub fn AddAuditAccessObjectAce(); + // pub fn AddConditionalAce(); + // pub fn AddMandatoryAce(); + // pub fn AddUsersToEncryptedFile(); + // pub fn AddUsersToEncryptedFileEx(); + // pub fn AdjustTokenGroups(); + pub fn AdjustTokenPrivileges( + TokenHandle: HANDLE, DisableAllPrivileges: BOOL, NewState: PTOKEN_PRIVILEGES, + BufferLength: DWORD, PreviousState: PTOKEN_PRIVILEGES, ReturnLength: PDWORD, + ) -> BOOL; + // pub fn AllocateAndInitializeSid(); + // pub fn AllocateLocallyUniqueId(); + // pub fn AreAllAccessesGranted(); + // pub fn AreAnyAccessesGranted(); + // pub fn AuditComputeEffectivePolicyBySid(); + // pub fn AuditComputeEffectivePolicyByToken(); + // pub fn AuditEnumerateCategories(); + // pub fn AuditEnumeratePerUserPolicy(); + // pub fn AuditEnumerateSubCategories(); + // pub fn AuditFree(); + // pub fn AuditLookupCategoryGuidFromCategoryId(); + // pub fn AuditLookupCategoryIdFromCategoryGuid(); + // pub fn AuditLookupCategoryNameA(); + // pub fn AuditLookupCategoryNameW(); + // pub fn AuditLookupSubCategoryNameA(); + // pub fn AuditLookupSubCategoryNameW(); + // pub fn AuditQueryGlobalSaclA(); + // pub fn AuditQueryGlobalSaclW(); + // pub fn AuditQueryPerUserPolicy(); + // pub fn AuditQuerySecurity(); + // pub fn AuditQuerySystemPolicy(); + // pub fn AuditSetGlobalSaclA(); + // pub fn AuditSetGlobalSaclW(); + // pub fn AuditSetPerUserPolicy(); + // pub fn AuditSetSecurity(); + // pub fn AuditSetSystemPolicy(); + // pub fn BackupEventLogA(); + // pub fn BackupEventLogW(); + // pub fn BaseRegCloseKey(); + // pub fn BaseRegCreateKey(); + // pub fn BaseRegDeleteKeyEx(); + // pub fn BaseRegDeleteValue(); + // pub fn BaseRegFlushKey(); + // pub fn BaseRegGetVersion(); + // pub fn BaseRegLoadKey(); + // pub fn BaseRegOpenKey(); + // pub fn BaseRegRestoreKey(); + // pub fn BaseRegSaveKeyEx(); + // pub fn BaseRegSetKeySecurity(); + // pub fn BaseRegSetValue(); + // pub fn BaseRegUnLoadKey(); + // pub fn BuildExplicitAccessWithNameA(); + // pub fn BuildExplicitAccessWithNameW(); + // pub fn BuildImpersonateExplicitAccessWithNameA(); + // pub fn BuildImpersonateExplicitAccessWithNameW(); + // pub fn BuildImpersonateTrusteeA(); + // pub fn BuildImpersonateTrusteeW(); + // pub fn BuildSecurityDescriptorA(); + // pub fn BuildSecurityDescriptorW(); + // pub fn BuildTrusteeWithNameA(); + // pub fn BuildTrusteeWithNameW(); + // pub fn BuildTrusteeWithObjectsAndNameA(); + // pub fn BuildTrusteeWithObjectsAndNameW(); + // pub fn BuildTrusteeWithObjectsAndSidA(); + // pub fn BuildTrusteeWithObjectsAndSidW(); + // pub fn BuildTrusteeWithSidA(); + // pub fn BuildTrusteeWithSidW(); + // pub fn CancelOverlappedAccess(); + // pub fn ChangeServiceConfig2A(); + // pub fn ChangeServiceConfig2W(); + // pub fn ChangeServiceConfigA(); + // pub fn ChangeServiceConfigW(); + // pub fn CheckForHiberboot(); + // pub fn CheckTokenMembership(); + // pub fn ClearEventLogA(); + // pub fn ClearEventLogW(); + // pub fn CloseCodeAuthzLevel(); + // pub fn CloseEncryptedFileRaw(); + // pub fn CloseEventLog(); + pub fn CloseServiceHandle(hSCObject: SC_HANDLE) -> BOOL; + // pub fn CloseThreadWaitChainSession(); + // pub fn CloseTrace(); + // pub fn CommandLineFromMsiDescriptor(); + // pub fn ComputeAccessTokenFromCodeAuthzLevel(); + pub fn ControlService( + hService: SC_HANDLE, dwControl: DWORD, lpServiceStatus: LPSERVICE_STATUS, + ) -> BOOL; + // pub fn ControlServiceExA(); + // pub fn ControlServiceExW(); + // pub fn ControlTraceA(); + // pub fn ControlTraceW(); + // pub fn ConvertAccessToSecurityDescriptorA(); + // pub fn ConvertAccessToSecurityDescriptorW(); + // pub fn ConvertSDToStringSDDomainW(); + // pub fn ConvertSDToStringSDRootDomainA(); + // pub fn ConvertSDToStringSDRootDomainW(); + // pub fn ConvertSecurityDescriptorToAccessA(); + // pub fn ConvertSecurityDescriptorToAccessNamedA(); + // pub fn ConvertSecurityDescriptorToAccessNamedW(); + // pub fn ConvertSecurityDescriptorToAccessW(); + // pub fn ConvertSecurityDescriptorToStringSecurityDescriptorA(); + // pub fn ConvertSecurityDescriptorToStringSecurityDescriptorW(); + // pub fn ConvertSidToStringSidA(); + // pub fn ConvertSidToStringSidW(); + // pub fn ConvertStringSDToSDDomainA(); + // pub fn ConvertStringSDToSDDomainW(); + // pub fn ConvertStringSDToSDRootDomainA(); + // pub fn ConvertStringSDToSDRootDomainW(); + // pub fn ConvertStringSecurityDescriptorToSecurityDescriptorA(); + // pub fn ConvertStringSecurityDescriptorToSecurityDescriptorW(); + // pub fn ConvertStringSidToSidA(); + // pub fn ConvertStringSidToSidW(); + // pub fn ConvertToAutoInheritPrivateObjectSecurity(); + // pub fn CopySid(); + // pub fn CreateCodeAuthzLevel(); + // pub fn CreatePrivateObjectSecurity(); + // pub fn CreatePrivateObjectSecurityEx(); + // pub fn CreatePrivateObjectSecurityWithMultipleInheritance(); + // pub fn CreateProcessAsUserA(); + // pub fn CreateProcessAsUserW(); + // pub fn CreateProcessWithLogonW(); + // pub fn CreateProcessWithTokenW(); + // pub fn CreateRestrictedToken(); + pub fn CreateServiceA( + hSCManager: SC_HANDLE, lpServiceName: LPCSTR, lpDisplayName: LPCSTR, + dwDesiredAccess: DWORD, dwServiceType: DWORD, dwStartType: DWORD, dwErrorControl: DWORD, + lpBinaryPathName: LPCSTR, lpLoadOrderGroup: LPCSTR, lpdwTagId: LPDWORD, + lpDependencies: LPCSTR, lpServiceStartName: LPCSTR, lpPassword: LPCSTR, + ) -> SC_HANDLE; + pub fn CreateServiceW( + hSCManager: SC_HANDLE, lpServiceName: LPCWSTR, lpDisplayName: LPCWSTR, + dwDesiredAccess: DWORD, dwServiceType: DWORD, dwStartType: DWORD, dwErrorControl: DWORD, + lpBinaryPathName: LPCWSTR, lpLoadOrderGroup: LPCWSTR, lpdwTagId: LPDWORD, + lpDependencies: LPCWSTR, lpServiceStartName: LPCWSTR, lpPassword: LPCWSTR, + ) -> SC_HANDLE; + // pub fn CreateTraceInstanceId(); + // pub fn CreateWellKnownSid(); + pub fn CredDeleteA(TargetName: LPCSTR, Type: DWORD, Flags: DWORD) -> BOOL; + pub fn CredDeleteW(TargetName: LPCWSTR, Type: DWORD, Flags: DWORD) -> BOOL; + // pub fn CredEnumerateA(); + // pub fn CredEnumerateW(); + // pub fn CredFindBestCredentialA(); + // pub fn CredFindBestCredentialW(); + pub fn CredFree(Buffer: PVOID); + // pub fn CredGetSessionTypes(); + // pub fn CredGetTargetInfoA(); + // pub fn CredGetTargetInfoW(); + // pub fn CredIsMarshaledCredentialA(); + // pub fn CredIsMarshaledCredentialW(); + // pub fn CredIsProtectedA(); + // pub fn CredIsProtectedW(); + // pub fn CredMarshalCredentialA(); + // pub fn CredMarshalCredentialW(); + // pub fn CredProtectA(); + // pub fn CredProtectW(); + pub fn CredReadA( + TargetName: LPCSTR, Type: DWORD, Flags: DWORD, Credential: *mut PCREDENTIALA, + ) -> BOOL; + // pub fn CredReadDomainCredentialsA(); + // pub fn CredReadDomainCredentialsW(); + pub fn CredReadW( + TargetName: LPCWSTR, Type: DWORD, Flags: DWORD, Credential: *mut PCREDENTIALW, + ) -> BOOL; + // pub fn CredRenameA(); + // pub fn CredRenameW(); + // pub fn CredUnmarshalCredentialA(); + // pub fn CredUnmarshalCredentialW(); + // pub fn CredUnprotectA(); + // pub fn CredUnprotectW(); + pub fn CredWriteA(Credential: PCREDENTIALA, Flags: DWORD) -> BOOL; + // pub fn CredWriteDomainCredentialsA(); + // pub fn CredWriteDomainCredentialsW(); + pub fn CredWriteW(Credential: PCREDENTIALW, Flags: DWORD) -> BOOL; + pub fn CryptAcquireContextA( + phProv: *mut HCRYPTPROV, szContainer: LPCSTR, szProvider: LPCSTR, dwProvType: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptAcquireContextW( + phProv: *mut HCRYPTPROV, szContainer: LPCWSTR, szProvider: LPCWSTR, dwProvType: DWORD, + dwFlags: DWORD, + ) -> BOOL; + // pub fn CryptContextAddRef(); + pub fn CryptCreateHash( + hProv: HCRYPTPROV, Algid: ALG_ID, hKey: HCRYPTKEY, dwFlags: DWORD, phHash: *mut HCRYPTHASH, + ) -> BOOL; + // pub fn CryptDecrypt(); + // pub fn CryptDeriveKey(); + pub fn CryptDestroyHash(hHash: HCRYPTHASH) -> BOOL; + // pub fn CryptDestroyKey(); + // pub fn CryptDuplicateHash(); + // pub fn CryptDuplicateKey(); + // pub fn CryptEncrypt(); + // pub fn CryptEnumProviderTypesA(); + // pub fn CryptEnumProviderTypesW(); + // pub fn CryptEnumProvidersA(); + // pub fn CryptEnumProvidersW(); + // pub fn CryptExportKey(); + // pub fn CryptGenKey(); + // pub fn CryptGenRandom(); + // pub fn CryptGetDefaultProviderA(); + // pub fn CryptGetDefaultProviderW(); + pub fn CryptGetHashParam( + hHash: HCRYPTHASH, dwParam: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + // pub fn CryptGetKeyParam(); + // pub fn CryptGetProvParam(); + // pub fn CryptGetUserKey(); + pub fn CryptHashData( + hHash: HCRYPTHASH, pbData: *const BYTE, dwDataLen: DWORD, dwFlags: DWORD, + ) -> BOOL; + // pub fn CryptHashSessionKey(); + // pub fn CryptImportKey(); + pub fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL; + // pub fn CryptSetHashParam(); + // pub fn CryptSetKeyParam(); + // pub fn CryptSetProvParam(); + // pub fn CryptSetProviderA(); + // pub fn CryptSetProviderExA(); + // pub fn CryptSetProviderExW(); + // pub fn CryptSetProviderW(); + // pub fn CryptSignHashA(); + // pub fn CryptSignHashW(); + // pub fn CryptVerifySignatureA(); + // pub fn CryptVerifySignatureW(); + // pub fn DecryptFileA(); + // pub fn DecryptFileW(); + // pub fn DeleteAce(); + pub fn DeleteService(hService: SC_HANDLE) -> BOOL; + // pub fn DeregisterEventSource(); + // pub fn DestroyPrivateObjectSecurity(); + // pub fn DuplicateEncryptionInfoFile(); + // pub fn DuplicateToken(); + // pub fn DuplicateTokenEx(); + // pub fn ElfBackupEventLogFileA(); + // pub fn ElfBackupEventLogFileW(); + // pub fn ElfChangeNotify(); + // pub fn ElfClearEventLogFileA(); + // pub fn ElfClearEventLogFileW(); + // pub fn ElfCloseEventLog(); + // pub fn ElfDeregisterEventSource(); + // pub fn ElfFlushEventLog(); + // pub fn ElfNumberOfRecords(); + // pub fn ElfOldestRecord(); + // pub fn ElfOpenBackupEventLogA(); + // pub fn ElfOpenBackupEventLogW(); + // pub fn ElfOpenEventLogA(); + // pub fn ElfOpenEventLogW(); + // pub fn ElfReadEventLogA(); + // pub fn ElfReadEventLogW(); + // pub fn ElfRegisterEventSourceA(); + // pub fn ElfRegisterEventSourceW(); + // pub fn ElfReportEventA(); + // pub fn ElfReportEventAndSourceW(); + // pub fn ElfReportEventW(); + // pub fn EnableTrace(); + // pub fn EnableTraceEx(); + // pub fn EnableTraceEx2(); + // pub fn EncryptFileA(); + // pub fn EncryptFileW(); + // pub fn EncryptedFileKeyInfo(); + // pub fn EncryptionDisable(); + // pub fn EnumDependentServicesA(); + // pub fn EnumDependentServicesW(); + // pub fn EnumDynamicTimeZoneInformation(); + // pub fn EnumServiceGroupW(); + // pub fn EnumServicesStatusA(); + // pub fn EnumServicesStatusExA(); + // pub fn EnumServicesStatusExW(); + // pub fn EnumServicesStatusW(); + // pub fn EnumerateTraceGuids(); + // pub fn EnumerateTraceGuidsEx(); + // pub fn EqualDomainSid(); + // pub fn EqualPrefixSid(); + // pub fn EqualSid(); + // pub fn EtwLogSysConfigExtension(); + // pub fn EventAccessControl(); + // pub fn EventAccessQuery(); + // pub fn EventAccessRemove(); + // pub fn EventActivityIdControl(); + // pub fn EventEnabled(); + // pub fn EventProviderEnabled(); + // pub fn EventRegister(); + // pub fn EventSetInformation(); + // pub fn EventUnregister(); + // pub fn EventWrite(); + // pub fn EventWriteEndScenario(); + // pub fn EventWriteEx(); + // pub fn EventWriteStartScenario(); + // pub fn EventWriteString(); + // pub fn EventWriteTransfer(); + // pub fn FileEncryptionStatusA(); + // pub fn FileEncryptionStatusW(); + // pub fn FindFirstFreeAce(); + // pub fn FlushEfsCache(); + // pub fn FlushTraceA(); + // pub fn FlushTraceW(); + // pub fn FreeEncryptedFileKeyInfo(); + // pub fn FreeEncryptedFileMetadata(); + // pub fn FreeEncryptionCertificateHashList(); + // pub fn FreeInheritedFromArray(); + // pub fn FreeSid(); + // pub fn GetAccessPermissionsForObjectA(); + // pub fn GetAccessPermissionsForObjectW(); + // pub fn GetAce(); + // pub fn GetAclInformation(); + // pub fn GetAuditedPermissionsFromAclA(); + // pub fn GetAuditedPermissionsFromAclW(); + // pub fn GetCurrentHwProfileA(); + // pub fn GetCurrentHwProfileW(); + // pub fn GetDynamicTimeZoneInformationEffectiveYears(); + // pub fn GetEffectiveRightsFromAclA(); + // pub fn GetEffectiveRightsFromAclW(); + // pub fn GetEncryptedFileMetadata(); + // pub fn GetEventLogInformation(); + // pub fn GetExplicitEntriesFromAclA(); + // pub fn GetExplicitEntriesFromAclW(); + // pub fn GetFileSecurityA(); + // pub fn GetFileSecurityW(); + // pub fn GetInformationCodeAuthzLevelW(); + // pub fn GetInformationCodeAuthzPolicyW(); + // pub fn GetInheritanceSourceA(); + // pub fn GetInheritanceSourceW(); + // pub fn GetKernelObjectSecurity(); + // pub fn GetLengthSid(); + // pub fn GetLocalManagedApplicationData(); + // pub fn GetLocalManagedApplications(); + // pub fn GetManagedApplicationCategories(); + // pub fn GetManagedApplications(); + // pub fn GetMultipleTrusteeA(); + // pub fn GetMultipleTrusteeOperationA(); + // pub fn GetMultipleTrusteeOperationW(); + // pub fn GetMultipleTrusteeW(); + // pub fn GetNamedSecurityInfoA(); + // pub fn GetNamedSecurityInfoExA(); + // pub fn GetNamedSecurityInfoExW(); + // pub fn GetNamedSecurityInfoW(); + // pub fn GetNumberOfEventLogRecords(); + // pub fn GetOldestEventLogRecord(); + // pub fn GetOverlappedAccessResults(); + // pub fn GetPrivateObjectSecurity(); + // pub fn GetSecurityDescriptorControl(); + // pub fn GetSecurityDescriptorDacl(); + // pub fn GetSecurityDescriptorGroup(); + // pub fn GetSecurityDescriptorLength(); + // pub fn GetSecurityDescriptorOwner(); + // pub fn GetSecurityDescriptorRMControl(); + // pub fn GetSecurityDescriptorSacl(); + // pub fn GetSecurityInfo(); + // pub fn GetSecurityInfoExA(); + // pub fn GetSecurityInfoExW(); + // pub fn GetServiceDisplayNameA(); + // pub fn GetServiceDisplayNameW(); + // pub fn GetServiceKeyNameA(); + // pub fn GetServiceKeyNameW(); + // pub fn GetSidIdentifierAuthority(); + // pub fn GetSidLengthRequired(); + // pub fn GetSidSubAuthority(); + // pub fn GetSidSubAuthorityCount(); + // pub fn GetStringConditionFromBinary(); + // pub fn GetThreadWaitChain(); + // pub fn GetTokenInformation(); + // pub fn GetTraceEnableFlags(); + // pub fn GetTraceEnableLevel(); + // pub fn GetTraceLoggerHandle(); + // pub fn GetTrusteeFormA(); + // pub fn GetTrusteeFormW(); + // pub fn GetTrusteeNameA(); + // pub fn GetTrusteeNameW(); + // pub fn GetTrusteeTypeA(); + // pub fn GetTrusteeTypeW(); + // pub fn GetUserNameA(); + // pub fn GetUserNameW(); + // pub fn GetWindowsAccountDomainSid(); + // pub fn I_ScSetServiceBitsA(); + // pub fn I_ScSetServiceBitsW(); + // pub fn IdentifyCodeAuthzLevelW(); + // pub fn ImpersonateAnonymousToken(); + // pub fn ImpersonateLoggedOnUser(); + // pub fn ImpersonateNamedPipeClient(); + // pub fn ImpersonateSelf(); + // pub fn InitializeAcl(); + // pub fn InitializeSecurityDescriptor(); + // pub fn InitializeSid(); + // pub fn InitiateShutdownA(); + // pub fn InitiateShutdownW(); + // pub fn InitiateSystemShutdownA(); + // pub fn InitiateSystemShutdownExA(); + // pub fn InitiateSystemShutdownExW(); + // pub fn InitiateSystemShutdownW(); + // pub fn InstallApplication(); + // pub fn IsTextUnicode(); + // pub fn IsTokenRestricted(); + // pub fn IsTokenUntrusted(); + // pub fn IsValidAcl(); + // pub fn IsValidRelativeSecurityDescriptor(); + // pub fn IsValidSecurityDescriptor(); + // pub fn IsValidSid(); + // pub fn IsWellKnownSid(); + // pub fn LockServiceDatabase(); + // pub fn LogonUserA(); + // pub fn LogonUserExA(); + // pub fn LogonUserExExW(); + // pub fn LogonUserExW(); + // pub fn LogonUserW(); + // pub fn LookupAccountNameA(); + // pub fn LookupAccountNameW(); + // pub fn LookupAccountSidA(); + // pub fn LookupAccountSidW(); + // pub fn LookupPrivilegeDisplayNameA(); + // pub fn LookupPrivilegeDisplayNameW(); + // pub fn LookupPrivilegeNameA(); + // pub fn LookupPrivilegeNameW(); + // pub fn LookupPrivilegeValueA(); + // pub fn LookupPrivilegeValueW(); + // pub fn LookupSecurityDescriptorPartsA(); + // pub fn LookupSecurityDescriptorPartsW(); + // pub fn LsaAddAccountRights(); + // pub fn LsaAddPrivilegesToAccount(); + // pub fn LsaClearAuditLog(); + // pub fn LsaClose(); + // pub fn LsaCreateAccount(); + // pub fn LsaCreateSecret(); + // pub fn LsaCreateTrustedDomain(); + // pub fn LsaCreateTrustedDomainEx(); + // pub fn LsaDelete(); + // pub fn LsaDeleteTrustedDomain(); + // pub fn LsaEnumerateAccountRights(); + // pub fn LsaEnumerateAccounts(); + // pub fn LsaEnumerateAccountsWithUserRight(); + // pub fn LsaEnumeratePrivileges(); + // pub fn LsaEnumeratePrivilegesOfAccount(); + // pub fn LsaEnumerateTrustedDomains(); + // pub fn LsaEnumerateTrustedDomainsEx(); + // pub fn LsaFreeMemory(); + // pub fn LsaGetAppliedCAPIDs(); + // pub fn LsaGetQuotasForAccount(); + // pub fn LsaGetRemoteUserName(); + // pub fn LsaGetSystemAccessAccount(); + // pub fn LsaGetUserName(); + // pub fn LsaICLookupNames(); + // pub fn LsaICLookupNamesWithCreds(); + // pub fn LsaICLookupSids(); + // pub fn LsaICLookupSidsWithCreds(); + // pub fn LsaLookupNames(); + // pub fn LsaLookupNames2(); + // pub fn LsaLookupPrivilegeDisplayName(); + // pub fn LsaLookupPrivilegeName(); + // pub fn LsaLookupPrivilegeValue(); + // pub fn LsaLookupSids(); + // pub fn LsaLookupSids2(); + // pub fn LsaManageSidNameMapping(); + // pub fn LsaNtStatusToWinError(); + // pub fn LsaOpenAccount(); + // pub fn LsaOpenPolicy(); + // pub fn LsaOpenPolicySce(); + // pub fn LsaOpenSecret(); + // pub fn LsaOpenTrustedDomain(); + // pub fn LsaOpenTrustedDomainByName(); + // pub fn LsaQueryCAPs(); + // pub fn LsaQueryDomainInformationPolicy(); + // pub fn LsaQueryForestTrustInformation(); + // pub fn LsaQueryInfoTrustedDomain(); + // pub fn LsaQueryInformationPolicy(); + // pub fn LsaQuerySecret(); + // pub fn LsaQuerySecurityObject(); + // pub fn LsaQueryTrustedDomainInfo(); + // pub fn LsaQueryTrustedDomainInfoByName(); + // pub fn LsaRemoveAccountRights(); + // pub fn LsaRemovePrivilegesFromAccount(); + // pub fn LsaRetrievePrivateData(); + // pub fn LsaSetCAPs(); + // pub fn LsaSetDomainInformationPolicy(); + // pub fn LsaSetForestTrustInformation(); + // pub fn LsaSetInformationPolicy(); + // pub fn LsaSetInformationTrustedDomain(); + // pub fn LsaSetQuotasForAccount(); + // pub fn LsaSetSecret(); + // pub fn LsaSetSecurityObject(); + // pub fn LsaSetSystemAccessAccount(); + // pub fn LsaSetTrustedDomainInfoByName(); + // pub fn LsaSetTrustedDomainInformation(); + // pub fn LsaStorePrivateData(); + // pub fn MIDL_user_free_Ext(); + // pub fn MSChapSrvChangePassword(); + // pub fn MSChapSrvChangePassword2(); + // pub fn MakeAbsoluteSD(); + // pub fn MakeAbsoluteSD2(); + // pub fn MakeSelfRelativeSD(); + // pub fn MapGenericMask(); + // pub fn NotifyBootConfigStatus(); + // pub fn NotifyChangeEventLog(); + // pub fn NotifyServiceStatusChange(); + // pub fn NotifyServiceStatusChangeA(); + // pub fn NotifyServiceStatusChangeW(); + // pub fn ObjectCloseAuditAlarmA(); + // pub fn ObjectCloseAuditAlarmW(); + // pub fn ObjectDeleteAuditAlarmA(); + // pub fn ObjectDeleteAuditAlarmW(); + // pub fn ObjectOpenAuditAlarmA(); + // pub fn ObjectOpenAuditAlarmW(); + // pub fn ObjectPrivilegeAuditAlarmA(); + // pub fn ObjectPrivilegeAuditAlarmW(); + // pub fn OpenBackupEventLogA(); + // pub fn OpenBackupEventLogW(); + // pub fn OpenEncryptedFileRawA(); + // pub fn OpenEncryptedFileRawW(); + // pub fn OpenEventLogA(); + // pub fn OpenEventLogW(); + pub fn OpenProcessToken( + ProcessHandle: HANDLE, DesiredAccess: DWORD, TokenHandle: PHANDLE, + ) -> BOOL; + pub fn OpenSCManagerA( + lpMachineName: LPCSTR, lpDatabaseName: LPCSTR, dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn OpenSCManagerW( + lpMachineName: LPCWSTR, lpDatabaseName: LPCWSTR, dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn OpenServiceA( + hSCManager: SC_HANDLE, lpServiceName: LPCSTR, dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn OpenServiceW( + hSCManager: SC_HANDLE, lpServiceName: LPCWSTR, dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + // pub fn OpenThreadToken(); + // pub fn OpenThreadWaitChainSession(); + // pub fn OpenTraceA(); + // pub fn OpenTraceW(); + // pub fn OperationEnd(); + // pub fn OperationStart(); + // pub fn PerfAddCounters(); + // pub fn PerfCloseQueryHandle(); + // pub fn PerfCreateInstance(); + // pub fn PerfDecrementULongCounterValue(); + // pub fn PerfDecrementULongLongCounterValue(); + // pub fn PerfDeleteCounters(); + // pub fn PerfDeleteInstance(); + // pub fn PerfEnumerateCounterSet(); + // pub fn PerfEnumerateCounterSetInstances(); + // pub fn PerfIncrementULongCounterValue(); + // pub fn PerfIncrementULongLongCounterValue(); + // pub fn PerfOpenQueryHandle(); + // pub fn PerfQueryCounterData(); + // pub fn PerfQueryCounterInfo(); + // pub fn PerfQueryCounterSetRegistrationInfo(); + // pub fn PerfQueryInstance(); + // pub fn PerfRegCloseKey(); + // pub fn PerfRegEnumKey(); + // pub fn PerfRegEnumValue(); + // pub fn PerfRegQueryInfoKey(); + // pub fn PerfRegQueryValue(); + // pub fn PerfRegSetValue(); + // pub fn PerfSetCounterRefValue(); + // pub fn PerfSetCounterSetInfo(); + // pub fn PerfSetULongCounterValue(); + // pub fn PerfSetULongLongCounterValue(); + // pub fn PerfStartProvider(); + // pub fn PerfStartProviderEx(); + // pub fn PerfStopProvider(); + // pub fn PrivilegeCheck(); + // pub fn PrivilegedServiceAuditAlarmA(); + // pub fn PrivilegedServiceAuditAlarmW(); + // pub fn ProcessTrace(); + // pub fn QueryAllTracesA(); + // pub fn QueryAllTracesW(); + // pub fn QueryRecoveryAgentsOnEncryptedFile(); + // pub fn QuerySecurityAccessMask(); + // pub fn QueryServiceConfig2A(); + // pub fn QueryServiceConfig2W(); + // pub fn QueryServiceConfigA(); + // pub fn QueryServiceConfigW(); + // pub fn QueryServiceDynamicInformation(); + // pub fn QueryServiceLockStatusA(); + // pub fn QueryServiceLockStatusW(); + // pub fn QueryServiceObjectSecurity(); + pub fn QueryServiceStatus(hService: SC_HANDLE, lpServiceStatus: LPSERVICE_STATUS) -> BOOL; + pub fn QueryServiceStatusEx( + hService: SC_HANDLE, InfoLevel: SC_STATUS_TYPE, lpBuffer: LPBYTE, cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + // pub fn QueryTraceA(); + // pub fn QueryTraceW(); + // pub fn QueryUsersOnEncryptedFile(); + // pub fn ReadEncryptedFileRaw(); + // pub fn ReadEventLogA(); + // pub fn ReadEventLogW(); + pub fn RegCloseKey(hKey: HKEY) -> LONG; + pub fn RegConnectRegistryA(lpMachineName: LPCSTR, hKey: HKEY, phkResult: PHKEY) -> LONG; + // pub fn RegConnectRegistryExA(); + // pub fn RegConnectRegistryExW(); + pub fn RegConnectRegistryW(lpMachineName: LPCWSTR, hKey: HKEY, phkResult: PHKEY) -> LONG; + pub fn RegCopyTreeA(hKeySrc: HKEY, lpSubKey: LPCSTR, hKeyDest: HKEY) -> LONG; + pub fn RegCopyTreeW(hKeySrc: HKEY, lpSubKey: LPCWSTR, hKeyDest: HKEY) -> LONG; + // pub fn RegCreateKeyA(); + pub fn RegCreateKeyExA( + hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD, lpClass: LPSTR, dwOptions: DWORD, + samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, + lpdwDisposition: LPDWORD, + ) -> LONG; + pub fn RegCreateKeyExW( + hKey: HKEY, lpSubKey: LPCWSTR, Reserved: DWORD, lpClass: LPWSTR, dwOptions: DWORD, + samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, + lpdwDisposition: LPDWORD, + ) -> LONG; + pub fn RegCreateKeyTransactedA( + hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD, lpClass: LPSTR, dwOptions: DWORD, + samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, + lpdwDisposition: LPDWORD, hTransaction: HANDLE, pExtendedParemeter: PVOID, + ) -> LONG; + pub fn RegCreateKeyTransactedW( + hKey: HKEY, lpSubKey: LPCWSTR, Reserved: DWORD, lpClass: LPWSTR, dwOptions: DWORD, + samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, + lpdwDisposition: LPDWORD, hTransaction: HANDLE, pExtendedParemeter: PVOID, + ) -> LONG; + // pub fn RegCreateKeyW(); + pub fn RegDeleteKeyA(hKey: HKEY, lpSubKey: LPCSTR) -> LONG; + pub fn RegDeleteKeyExA( + hKey: HKEY, lpSubKey: LPCSTR, samDesired: REGSAM, Reserved: DWORD, + ) -> LONG; + pub fn RegDeleteKeyExW( + hKey: HKEY, lpSubKey: LPCWSTR, samDesired: REGSAM, Reserved: DWORD, + ) -> LONG; + pub fn RegDeleteKeyTransactedA( + hKey: HKEY, lpSubKey: LPCSTR, samDesired: REGSAM, Reserved: DWORD, + hTransaction: HANDLE, pExtendedParemeter: PVOID, + ) -> LONG; + pub fn RegDeleteKeyTransactedW( + hKey: HKEY, lpSubKey: LPCWSTR, samDesired: REGSAM, Reserved: DWORD, + hTransaction: HANDLE, pExtendedParemeter: PVOID, + ) -> LONG; + pub fn RegDeleteKeyValueA(hKey: HKEY, lpSubKey: LPCSTR, lpValueName: LPCSTR) -> LONG; + pub fn RegDeleteKeyValueW(hKey: HKEY, lpSubKey: LPCWSTR, lpValueName: LPCWSTR) -> LONG; + pub fn RegDeleteKeyW(hKey: HKEY, lpSubKey: LPCWSTR) -> LONG; + pub fn RegDeleteTreeA(hKey: HKEY, lpSubKey: LPCSTR) -> LONG; + pub fn RegDeleteTreeW(hKey: HKEY, lpSubKey: LPCWSTR) -> LONG; + pub fn RegDeleteValueA(hKey: HKEY, lpValueName: LPCSTR) -> LONG; + pub fn RegDeleteValueW(hKey: HKEY, lpValueName: LPCWSTR) -> LONG; + pub fn RegDisablePredefinedCache() -> LONG; + pub fn RegDisablePredefinedCacheEx() -> LONG; + pub fn RegDisableReflectionKey(hBase: HKEY) -> LONG; + pub fn RegEnableReflectionKey(hBase: HKEY) -> LONG; + // pub fn RegEnumKeyA(); + pub fn RegEnumKeyExA( + hKey: HKEY, dwIndex: DWORD, lpName: LPSTR, lpcName: LPDWORD, lpReserved: LPDWORD, + lpClass: LPSTR, lpcClass: LPDWORD, lpftLastWriteTime: PFILETIME, + ) -> LONG; + pub fn RegEnumKeyExW( + hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR, lpcName: LPDWORD, lpReserved: LPDWORD, + lpClass: LPWSTR, lpcClass: LPDWORD, lpftLastWriteTime: PFILETIME, + ) -> LONG; + // pub fn RegEnumKeyW(); + pub fn RegEnumValueA( + hKey: HKEY, dwIndex: DWORD, lpValueName: LPSTR, lpcchValueName: LPDWORD, + lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD, + ) -> LONG; + pub fn RegEnumValueW( + hKey: HKEY, dwIndex: DWORD, lpValueName: LPWSTR, lpcchValueName: LPDWORD, + lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD, + ) -> LONG; + pub fn RegFlushKey(hKey: HKEY) -> LONG; + // pub fn RegGetKeySecurity(); + pub fn RegGetValueA( + hkey: HKEY, lpSubKey: LPCSTR, lpValue: LPCSTR, dwFlags: DWORD, pdwType: LPDWORD, + pvData: PVOID, pcbData: LPDWORD, + ) -> LONG; + pub fn RegGetValueW( + hkey: HKEY, lpSubKey: LPCWSTR, lpValue: LPCWSTR, dwFlags: DWORD, pdwType: LPDWORD, + pvData: PVOID, pcbData: LPDWORD, + ) -> LONG; + // pub fn RegLoadAppKeyA(); + // pub fn RegLoadAppKeyW(); + // pub fn RegLoadKeyA(); + // pub fn RegLoadKeyW(); + // pub fn RegLoadMUIStringA(); + pub fn RegLoadMUIStringW( + hKey: HKEY, pszValue: LPCWSTR, pszOutBuf: LPWSTR, cbOutBuf: DWORD, pcbData: LPDWORD, + Flags: DWORD, pszDirectory: LPCWSTR, + ) -> LONG; + pub fn RegNotifyChangeKeyValue( + hKey: HKEY, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, hEvent: HANDLE, + fAsynchronous: BOOL, + ) -> LONG; + pub fn RegOpenCurrentUser(samDesired: REGSAM, phkResult: PHKEY) -> LONG; + // pub fn RegOpenKeyA(); + pub fn RegOpenKeyExA( + hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, + ) -> LONG; + pub fn RegOpenKeyExW( + hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, + ) -> LONG; + pub fn RegOpenKeyTransactedA( + hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, + hTransaction: HANDLE, pExtendedParemeter: PVOID, + ) -> LONG; + pub fn RegOpenKeyTransactedW( + hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, + hTransaction: HANDLE, pExtendedParemeter: PVOID, + ) -> LONG; + // pub fn RegOpenKeyW(); + pub fn RegOpenUserClassesRoot( + hToken: HANDLE, dwOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, + ) -> LONG; + pub fn RegOverridePredefKey(hKey: HKEY, hNewHKey: HKEY) -> LONG; + pub fn RegQueryInfoKeyA( + hKey: HKEY, lpClass: LPSTR, lpcClass: LPDWORD, lpReserved: LPDWORD, lpcSubKeys: LPDWORD, + lpcMaxSubKeyLen: LPDWORD, lpcMaxClassLen: LPDWORD, lpcValues: LPDWORD, + lpcMaxValueNameLen: LPDWORD, lpcMaxValueLen: LPDWORD, lpcbSecurityDescriptor: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LONG; + pub fn RegQueryInfoKeyW( + hKey: HKEY, lpClass: LPWSTR, lpcClass: LPDWORD, lpReserved: LPDWORD, lpcSubKeys: LPDWORD, + lpcMaxSubKeyLen: LPDWORD, lpcMaxClassLen: LPDWORD, lpcValues: LPDWORD, + lpcMaxValueNameLen: LPDWORD, lpcMaxValueLen: LPDWORD, lpcbSecurityDescriptor: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LONG; + pub fn RegQueryMultipleValuesA( + hKey: HKEY, val_list: PVALENTA, num_vals: DWORD, lpValueBuf: LPSTR, ldwTotsize: LPDWORD, + ) -> LONG; + pub fn RegQueryMultipleValuesW( + hKey: HKEY, val_list: PVALENTW, num_vals: DWORD, lpValueBuf: LPWSTR, ldwTotsize: LPDWORD, + ) -> LONG; + pub fn RegQueryReflectionKey(hBase: HKEY, bIsReflectionDisabled: PBOOL) -> LONG; + pub fn RegQueryValueExA( + hKey: HKEY, lpValueName: LPCSTR, lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LONG; + pub fn RegQueryValueExW( + hKey: HKEY, lpValueName: LPCWSTR, lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LONG; + // pub fn RegQueryValueW(); + // pub fn RegRenameKey(); + // pub fn RegReplaceKeyA(); + // pub fn RegReplaceKeyW(); + // pub fn RegRestoreKeyA(); + // pub fn RegRestoreKeyW(); + // pub fn RegSaveKeyA(); + // pub fn RegSaveKeyExA(); + // pub fn RegSaveKeyExW(); + // pub fn RegSaveKeyW(); + // pub fn RegSetKeySecurity(); + pub fn RegSetKeyValueA( + hKey: HKEY, lpSubKey: LPCSTR, lpValueName: LPCSTR, dwType: DWORD, lpData: LPCVOID, + cbData: DWORD, + ) -> LONG; + pub fn RegSetValueExA( + hKey: HKEY, lpValueName: LPCSTR, Reserved: DWORD, dwType: DWORD, lpData: *const BYTE, + cbData: DWORD, + ) -> LONG; + pub fn RegSetValueExW( + hKey: HKEY, lpValueName: LPCWSTR, Reserved: DWORD, dwType: DWORD, lpData: *const BYTE, + cbData: DWORD, + ) -> LONG; + pub fn RegSetKeyValueW( + hKey: HKEY, lpSubKey: LPCWSTR, lpValueName: LPCWSTR, dwType: DWORD, lpData: LPCVOID, + cbData: DWORD, + ) -> LONG; + // pub fn RegUnLoadKeyA(); + // pub fn RegUnLoadKeyW(); + // pub fn RegisterEventSourceA(); + // pub fn RegisterEventSourceW(); + pub fn RegisterServiceCtrlHandlerA( + lpServiceName: LPCSTR, lpHandlerProc: LPHANDLER_FUNCTION, + ) -> SERVICE_STATUS_HANDLE; + pub fn RegisterServiceCtrlHandlerExA( + lpServiceName: LPCSTR, lpHandlerProc: LPHANDLER_FUNCTION_EX, lpContext: LPVOID, + ) -> SERVICE_STATUS_HANDLE; + pub fn RegisterServiceCtrlHandlerExW( + lpServiceName: LPCWSTR, lpHandlerProc: LPHANDLER_FUNCTION_EX, lpContext: LPVOID, + ) -> SERVICE_STATUS_HANDLE; + pub fn RegisterServiceCtrlHandlerW( + lpServiceName: LPCWSTR, lpHandlerProc: LPHANDLER_FUNCTION, + ) -> SERVICE_STATUS_HANDLE; + // pub fn RegisterTraceGuidsA(); + // pub fn RegisterTraceGuidsW(); + // pub fn RegisterWaitChainCOMCallback(); + // pub fn RemoteRegEnumKeyWrapper(); + // pub fn RemoteRegEnumValueWrapper(); + // pub fn RemoteRegQueryInfoKeyWrapper(); + // pub fn RemoteRegQueryValueWrapper(); + // pub fn RemoveTraceCallback(); + // pub fn RemoveUsersFromEncryptedFile(); + // pub fn ReportEventA(); + // pub fn ReportEventW(); + // pub fn RevertToSelf(); + // pub fn SafeBaseRegGetKeySecurity(); + // pub fn SaferCloseLevel(); + // pub fn SaferComputeTokenFromLevel(); + // pub fn SaferCreateLevel(); + // pub fn SaferGetLevelInformation(); + // pub fn SaferGetPolicyInformation(); + // pub fn SaferIdentifyLevel(); + // pub fn SaferRecordEventLogEntry(); + // pub fn SaferSetLevelInformation(); + // pub fn SaferSetPolicyInformation(); + // pub fn SaferiIsExecutableFileType(); + // pub fn SetAclInformation(); + // pub fn SetEncryptedFileMetadata(); + // pub fn SetEntriesInAccessListA(); + // pub fn SetEntriesInAccessListW(); + // pub fn SetEntriesInAclA(); + // pub fn SetEntriesInAclW(); + // pub fn SetEntriesInAuditListA(); + // pub fn SetEntriesInAuditListW(); + // pub fn SetFileSecurityA(); + // pub fn SetFileSecurityW(); + // pub fn SetInformationCodeAuthzLevelW(); + // pub fn SetInformationCodeAuthzPolicyW(); + // pub fn SetKernelObjectSecurity(); + // pub fn SetNamedSecurityInfoA(); + // pub fn SetNamedSecurityInfoExA(); + // pub fn SetNamedSecurityInfoExW(); + // pub fn SetNamedSecurityInfoW(); + // pub fn SetPrivateObjectSecurity(); + // pub fn SetPrivateObjectSecurityEx(); + // pub fn SetSecurityAccessMask(); + // pub fn SetSecurityDescriptorControl(); + // pub fn SetSecurityDescriptorDacl(); + // pub fn SetSecurityDescriptorGroup(); + // pub fn SetSecurityDescriptorOwner(); + // pub fn SetSecurityDescriptorRMControl(); + // pub fn SetSecurityDescriptorSacl(); + // pub fn SetSecurityInfo(); + // pub fn SetSecurityInfoExA(); + // pub fn SetSecurityInfoExW(); + // pub fn SetServiceBits(); + // pub fn SetServiceObjectSecurity(); + pub fn SetServiceStatus( + hServiceStatus: SERVICE_STATUS_HANDLE, lpServiceStatus: LPSERVICE_STATUS, + ) -> BOOL; + // pub fn SetThreadToken(); + // pub fn SetTokenInformation(); + // pub fn SetTraceCallback(); + // pub fn SetUserFileEncryptionKey(); + // pub fn SetUserFileEncryptionKeyEx(); + // pub fn StartServiceA(); + pub fn StartServiceCtrlDispatcherA(lpServiceStartTable: *const SERVICE_TABLE_ENTRYA) -> BOOL; + pub fn StartServiceCtrlDispatcherW(lpServiceStartTable: *const SERVICE_TABLE_ENTRYW) -> BOOL; + // pub fn StartServiceW(); + // pub fn StartTraceA(); + // pub fn StartTraceW(); + // pub fn StopTraceA(); + // pub fn StopTraceW(); + // pub fn SystemFunction001(); + // pub fn SystemFunction002(); + // pub fn SystemFunction003(); + // pub fn SystemFunction004(); + // pub fn SystemFunction005(); + // pub fn SystemFunction006(); + // pub fn SystemFunction007(); + // pub fn SystemFunction008(); + // pub fn SystemFunction009(); + // pub fn SystemFunction010(); + // pub fn SystemFunction011(); + // pub fn SystemFunction012(); + // pub fn SystemFunction013(); + // pub fn SystemFunction014(); + // pub fn SystemFunction015(); + // pub fn SystemFunction016(); + // pub fn SystemFunction017(); + // pub fn SystemFunction018(); + // pub fn SystemFunction019(); + // pub fn SystemFunction020(); + // pub fn SystemFunction021(); + // pub fn SystemFunction022(); + // pub fn SystemFunction023(); + // pub fn SystemFunction024(); + // pub fn SystemFunction025(); + // pub fn SystemFunction026(); + // pub fn SystemFunction027(); + // pub fn SystemFunction028(); + // pub fn SystemFunction029(); + // pub fn SystemFunction030(); + // pub fn SystemFunction031(); + // pub fn SystemFunction032(); + // pub fn SystemFunction033(); + // pub fn SystemFunction034(); + // pub fn SystemFunction036(); + // pub fn SystemFunction040(); + // pub fn SystemFunction041(); + // pub fn TraceEvent(); + // pub fn TraceEventInstance(); + // pub fn TraceMessage(); + // pub fn TraceMessageVa(); + // pub fn TraceQueryInformation(); + // pub fn TraceSetInformation(); + // pub fn TreeResetNamedSecurityInfoA(); + // pub fn TreeResetNamedSecurityInfoW(); + // pub fn TreeSetNamedSecurityInfoA(); + // pub fn TreeSetNamedSecurityInfoW(); + // pub fn TrusteeAccessToObjectA(); + // pub fn TrusteeAccessToObjectW(); + // pub fn UninstallApplication(); + // pub fn UnlockServiceDatabase(); + // pub fn UnregisterTraceGuids(); + // pub fn UpdateTraceA(); + // pub fn UpdateTraceW(); + // pub fn UsePinForEncryptedFilesA(); + // pub fn UsePinForEncryptedFilesW(); + // pub fn WaitServiceState(); + // pub fn WriteEncryptedFileRaw(); +} diff --git a/deps/aho-corasick-0.2.1/.gitignore b/deps/aho-corasick-0.2.1/.gitignore new file mode 100644 index 000000000..d24edbd87 --- /dev/null +++ b/deps/aho-corasick-0.2.1/.gitignore @@ -0,0 +1,9 @@ +.*.swp +doc +tags +examples/ss10pusa.csv +build +target +Cargo.lock +scratch* +bench_large/huge diff --git a/deps/aho-corasick-0.2.1/.travis.yml b/deps/aho-corasick-0.2.1/.travis.yml new file mode 100644 index 000000000..faea53eef --- /dev/null +++ b/deps/aho-corasick-0.2.1/.travis.yml @@ -0,0 +1,12 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc + - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then + cargo bench --verbose; + fi diff --git a/deps/aho-corasick-0.2.1/COPYING b/deps/aho-corasick-0.2.1/COPYING new file mode 100644 index 000000000..bb9c20a09 --- /dev/null +++ b/deps/aho-corasick-0.2.1/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/deps/aho-corasick-0.2.1/Cargo.toml b/deps/aho-corasick-0.2.1/Cargo.toml new file mode 100644 index 000000000..d8597f205 --- /dev/null +++ b/deps/aho-corasick-0.2.1/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "aho-corasick" +version = "0.2.1" #:version +authors = ["Andrew Gallant "] +description = "Fast multiple substring searching with finite state machines." +documentation = "http://burntsushi.net/rustdoc/aho_corasick/" +homepage = "https://github.com/BurntSushi/aho-corasick" +repository = "https://github.com/BurntSushi/aho-corasick" +readme = "README.md" +keywords = ["string", "search", "text", "aho", "corasick"] +license = "Unlicense/MIT" + +[lib] +name = "aho_corasick" + +[[bin]] +name = "aho-corasick-dot" +test = false +doc = false +bench = false + +[dependencies] +memchr = "0.1.*" + +[dev-dependencies] +csv = "*" +docopt = "*" +quickcheck = "*" +rand = "*" +rustc-serialize = "*" + +[[bench]] +name = "bench" +path = "benches/bench.rs" +test = false +bench = true diff --git a/deps/aho-corasick-0.2.1/LICENSE-MIT b/deps/aho-corasick-0.2.1/LICENSE-MIT new file mode 100644 index 000000000..3b0a5dc09 --- /dev/null +++ b/deps/aho-corasick-0.2.1/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/aho-corasick-0.2.1/Makefile b/deps/aho-corasick-0.2.1/Makefile new file mode 100644 index 000000000..9f956f4c4 --- /dev/null +++ b/deps/aho-corasick-0.2.1/Makefile @@ -0,0 +1,14 @@ +all: + echo Nothing to do... + +ctags: + ctags --recurse --options=ctags.rust --languages=Rust + +docs: + cargo doc + in-dir ./target/doc fix-perms + rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/ + +push: + git push origin master + git push github master diff --git a/deps/aho-corasick-0.2.1/README.md b/deps/aho-corasick-0.2.1/README.md new file mode 100644 index 000000000..7b7b000d3 --- /dev/null +++ b/deps/aho-corasick-0.2.1/README.md @@ -0,0 +1,55 @@ +This crate provides an implementation of the +[Aho-Corasick](http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm) +algorithm. Its intended use case is for fast substring matching, particularly +when matching multiple substrings in a search text. This is achieved by +compiling the substrings into a finite state machine. + +This implementation provides optimal algorithmic time complexity. Construction +of the finite state machine is `O(p)` where `p` is the length of the substrings +concatenated. Matching against search text is `O(n + p + m)`, where `n` is +the length of the search text and `m` is the number of matches. + +[![Build status](https://api.travis-ci.org/BurntSushi/aho-corasick.png)](https://travis-ci.org/BurntSushi/aho-corasick) +[![](http://meritbadge.herokuapp.com/aho-corasick)](https://crates.io/crates/aho-corasick) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +[http://burntsushi.net/rustdoc/aho_corasick/](http://burntsushi.net/rustdoc/aho_corasick/). + + +### Example + +The documentation contains several examples, and there is a more complete +example as a full program in `examples/dict-search.rs`. + +Here is a quick example showing simple substring matching: + +```rust +use aho_corasick::{AcAutomaton, Match}; + +let aut = AcAutomaton::new(vec!["apple", "maple"]); +let mut it = aut.find("I like maple apples."); +assert_eq!(it.next(), Some(Match { + pati: 1, + start: 7, + end: 12, +})); +assert_eq!(it.next(), Some(Match { + pati: 0, + start: 13, + end: 18, +})); +assert_eq!(it.next(), None); +``` + + +### Alternatives + +Aho-Corasick is useful for matching multiple substrings against many long +strings. If your long string is fixed, then you might consider building a +[suffix array](https://github.com/BurntSushi/suffix) +of the search text (which takes `O(n)` time). Matches can then be found in +`O(plogn)` time. diff --git a/deps/aho-corasick-0.2.1/UNLICENSE b/deps/aho-corasick-0.2.1/UNLICENSE new file mode 100644 index 000000000..68a49daad --- /dev/null +++ b/deps/aho-corasick-0.2.1/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/deps/aho-corasick-0.2.1/benches/bench.rs b/deps/aho-corasick-0.2.1/benches/bench.rs new file mode 100644 index 000000000..ab4ddd03d --- /dev/null +++ b/deps/aho-corasick-0.2.1/benches/bench.rs @@ -0,0 +1,258 @@ +#![feature(test)] + +extern crate aho_corasick; +extern crate test; + +use std::iter; + +use aho_corasick::{Automaton, AcAutomaton, Transitions}; +use test::Bencher; + +const HAYSTACK_RANDOM: &'static str = include_str!("random.txt"); + +fn bench_aut_no_match( + b: &mut Bencher, + aut: AcAutomaton, + haystack: &str, +) { + b.bytes = haystack.len() as u64; + b.iter(|| assert!(aut.find(haystack).next().is_none())); +} + +fn bench_full_aut_no_match( + b: &mut Bencher, + aut: AcAutomaton, + haystack: &str, +) { + let aut = aut.into_full(); + b.bytes = haystack.len() as u64; + b.iter(|| assert!(aut.find(haystack).next().is_none())); +} + +fn bench_naive_no_match(b: &mut Bencher, needles: Vec, haystack: &str) + where S: Into { + b.bytes = haystack.len() as u64; + let needles: Vec = needles.into_iter().map(Into::into).collect(); + b.iter(|| assert!(!naive_find(&needles, haystack))); +} + +fn haystack_same(letter: char) -> String { + iter::repeat(letter).take(10000).collect() +} + +macro_rules! aut_benches { + ($prefix:ident, $aut:expr, $bench:expr) => { mod $prefix { +#![allow(unused_imports)] +use aho_corasick::{Automaton, AcAutomaton, Sparse}; +use test::Bencher; + +use super::{ + HAYSTACK_RANDOM, haystack_same, + bench_aut_no_match, bench_full_aut_no_match, +}; + +#[bench] +fn ac_one_byte(b: &mut Bencher) { + let aut = $aut(vec!["a"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_one_prefix_byte_no_match(b: &mut Bencher) { + let aut = $aut(vec!["zbc"]); + $bench(b, aut, &haystack_same('y')); +} + +#[bench] +fn ac_one_prefix_byte_every_match(b: &mut Bencher) { + // We lose the benefit of `memchr` because the first byte matches + // in every position in the haystack. + let aut = $aut(vec!["zbc"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_one_prefix_byte_random(b: &mut Bencher) { + let aut = $aut(vec!["zbc\x00"]); + $bench(b, aut, HAYSTACK_RANDOM); +} + +#[bench] +fn ac_two_bytes(b: &mut Bencher) { + let aut = $aut(vec!["a", "b"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_two_diff_prefix(b: &mut Bencher) { + let aut = $aut(vec!["abcdef", "bmnopq"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_two_one_prefix_byte_every_match(b: &mut Bencher) { + let aut = $aut(vec!["zbcdef", "zmnopq"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_two_one_prefix_byte_no_match(b: &mut Bencher) { + let aut = $aut(vec!["zbcdef", "zmnopq"]); + $bench(b, aut, &haystack_same('y')); +} + +#[bench] +fn ac_two_one_prefix_byte_random(b: &mut Bencher) { + let aut = $aut(vec!["zbcdef\x00", "zmnopq\x00"]); + $bench(b, aut, HAYSTACK_RANDOM); +} + +#[bench] +fn ac_ten_bytes(b: &mut Bencher) { + let aut = $aut(vec!["a", "b", "c", "d", "e", + "f", "g", "h", "i", "j"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_ten_diff_prefix(b: &mut Bencher) { + let aut = $aut(vec!["abcdef", "bbcdef", "cbcdef", "dbcdef", + "ebcdef", "fbcdef", "gbcdef", "hbcdef", + "ibcdef", "jbcdef"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_ten_one_prefix_byte_every_match(b: &mut Bencher) { + let aut = $aut(vec!["zacdef", "zbcdef", "zccdef", "zdcdef", + "zecdef", "zfcdef", "zgcdef", "zhcdef", + "zicdef", "zjcdef"]); + $bench(b, aut, &haystack_same('z')); +} + +#[bench] +fn ac_ten_one_prefix_byte_no_match(b: &mut Bencher) { + let aut = $aut(vec!["zacdef", "zbcdef", "zccdef", "zdcdef", + "zecdef", "zfcdef", "zgcdef", "zhcdef", + "zicdef", "zjcdef"]); + $bench(b, aut, &haystack_same('y')); +} + +#[bench] +fn ac_ten_one_prefix_byte_random(b: &mut Bencher) { + let aut = $aut(vec!["zacdef\x00", "zbcdef\x00", "zccdef\x00", + "zdcdef\x00", "zecdef\x00", "zfcdef\x00", + "zgcdef\x00", "zhcdef\x00", "zicdef\x00", + "zjcdef\x00"]); + $bench(b, aut, HAYSTACK_RANDOM); +} +}}} + +aut_benches!(dense, AcAutomaton::new, bench_aut_no_match); +aut_benches!(sparse, AcAutomaton::::with_transitions, + bench_aut_no_match); +aut_benches!(full, AcAutomaton::new, bench_full_aut_no_match); + +// A naive multi-pattern search. +// We use this to benchmark *throughput*, so it should never match anything. +fn naive_find(needles: &[String], haystack: &str) -> bool { + for hi in 0..haystack.len() { + let rest = &haystack.as_bytes()[hi..]; + for needle in needles { + let needle = needle.as_bytes(); + if needle.len() > rest.len() { + continue; + } + if needle == &rest[..needle.len()] { + // should never happen in throughput benchmarks. + return true; + } + } + } + false +} + +#[bench] +fn naive_one_byte(b: &mut Bencher) { + bench_naive_no_match(b, vec!["a"], &haystack_same('z')); +} + +#[bench] +fn naive_one_prefix_byte_no_match(b: &mut Bencher) { + bench_naive_no_match(b, vec!["zbc"], &haystack_same('y')); +} + +#[bench] +fn naive_one_prefix_byte_every_match(b: &mut Bencher) { + bench_naive_no_match(b, vec!["zbc"], &haystack_same('z')); +} + +#[bench] +fn naive_one_prefix_byte_random(b: &mut Bencher) { + bench_naive_no_match(b, vec!["zbc\x00"], HAYSTACK_RANDOM); +} + +#[bench] +fn naive_two_bytes(b: &mut Bencher) { + bench_naive_no_match(b, vec!["a", "b"], &haystack_same('z')); +} + +#[bench] +fn naive_two_diff_prefix(b: &mut Bencher) { + bench_naive_no_match(b, vec!["abcdef", "bmnopq"], &haystack_same('z')); +} + +#[bench] +fn naive_two_one_prefix_byte_every_match(b: &mut Bencher) { + bench_naive_no_match(b, vec!["zbcdef", "zmnopq"], &haystack_same('z')); +} + +#[bench] +fn naive_two_one_prefix_byte_no_match(b: &mut Bencher) { + bench_naive_no_match(b, vec!["zbcdef", "zmnopq"], &haystack_same('y')); +} + +#[bench] +fn naive_two_one_prefix_byte_random(b: &mut Bencher) { + bench_naive_no_match(b, vec!["zbcdef\x00", "zmnopq\x00"], HAYSTACK_RANDOM); +} + +#[bench] +fn naive_ten_bytes(b: &mut Bencher) { + let needles = vec!["a", "b", "c", "d", "e", + "f", "g", "h", "i", "j"]; + bench_naive_no_match(b, needles, &haystack_same('z')); +} + +#[bench] +fn naive_ten_diff_prefix(b: &mut Bencher) { + let needles = vec!["abcdef", "bbcdef", "cbcdef", "dbcdef", + "ebcdef", "fbcdef", "gbcdef", "hbcdef", + "ibcdef", "jbcdef"]; + bench_naive_no_match(b, needles, &haystack_same('z')); +} + +#[bench] +fn naive_ten_one_prefix_byte_every_match(b: &mut Bencher) { + let needles = vec!["zacdef", "zbcdef", "zccdef", "zdcdef", + "zecdef", "zfcdef", "zgcdef", "zhcdef", + "zicdef", "zjcdef"]; + bench_naive_no_match(b, needles, &haystack_same('z')); +} + +#[bench] +fn naive_ten_one_prefix_byte_no_match(b: &mut Bencher) { + let needles = vec!["zacdef", "zbcdef", "zccdef", "zdcdef", + "zecdef", "zfcdef", "zgcdef", "zhcdef", + "zicdef", "zjcdef"]; + bench_naive_no_match(b, needles, &haystack_same('y')); +} + +#[bench] +fn naive_ten_one_prefix_byte_random(b: &mut Bencher) { + let needles = vec!["zacdef\x00", "zbcdef\x00", "zccdef\x00", + "zdcdef\x00", "zecdef\x00", "zfcdef\x00", + "zgcdef\x00", "zhcdef\x00", "zicdef\x00", + "zjcdef\x00"]; + bench_naive_no_match(b, needles, HAYSTACK_RANDOM); +} diff --git a/deps/aho-corasick-0.2.1/benches/random.txt b/deps/aho-corasick-0.2.1/benches/random.txt new file mode 100644 index 000000000..dfae5cd14 --- /dev/null +++ b/deps/aho-corasick-0.2.1/benches/random.txt @@ -0,0 +1,513 @@ + +mnxnsynfvuugtbxsxbfxwreuspglnplefzwsp +tacfqcwnmodnmgnyiuvqoco +z + +qjuozfkexn +zoaxzncje +sldhqtmgxzyurfyzwazmmu +bbeuv +mzsrihycwcb +xzfqozfmlnpmrzpxxxytqs +xrg +mcplby +nmslhfgjowhzfxsvyddydnsyehdskbydbjksqtpet +indvfw +bvjvvw + +pddufodyqtyixbndtumndyz +xjjhtuvmsxhuwqulqtjhqrdqrmtbcphvyuqllocrnkpfv +zemshhz +wss +xewlrxfmgxnwgphcgefa +mbgsgbzrtthxweimcqzcaaheurdmd +osqefupespvh +z +tvvlakwzwjbrgjzfgubsmmonav +pjdskxcfgapsm +zqktqgkrcdrlskx +zwwfebhguskho +zlvvw +czwm +gojnpmboehlsazbexjjnuscqftrfufngygjdxcydib +d +afigycivicnknfxl +ljuwuopctiftfwctxecwipjnljyef +jonwbkodomzhqvlf +jdkizhognqsdogunwedjsmsdzho +zxvni +oynfjf +muvokjuqz +azuwrwtuxzfopwrcex +ixrjinlvxjmn +blaegnmbhsgsbmebwazaeguugtkowexgnqtbfkldadddv +tzabyoftyov +ctbtqbzscxzviuvcigwuwusrdro +ljynr +gnnnyyxslrhsbj +hhzlw +hijalf +rxlfqk +mhaofforwznvmcgplinludpgkucpa +gvvxsqqfmu +xxqhoyosixjfhjuxpv +faadjpvamjekreepizurntvwdynozfawsfawyms + +lcbutr +aqyxvpozkjrecrkl +lfmochahrr +ptqyomjlwo +vcmslulznx +lmlsskcihrmxauztuarydlp +beiqsrfnmvmlmybmwpektjbikvpggthpabqsgmjhnthvysuhwbigillugjsp +dfsuegseffwcsnvsrqedytblbpzbfeyfsq +kypvqctrkuds +ylqeduokzgdqaxelhftxnxbidu +bprzyayfopxdsmfhhfqowa +ymiutdtlfaaxpbtaeslv +ggago + +owpbicekdeykzfgcbgzobdvvrtetvcv +xsrlgingstiez +gyncqvq +xasohmeiwyscpehctmzmsnjklg +xsudghakxlw +dzqlfptjogzpkvwuticcyugnyopypuqqc +wlxshxbhdvuherumoppcc + +znyaptivzncvkpeyeipynqefjxjjcsgfqbnezeebtowdrbjaqjlbxwvyikrmxjwoxngqgvfpbniftnmszuxg +umwpwwyvufy +pallkjtnrmtauqxauewgygwkjjwebbkabhtxticxmxfujpxlrpzlrozfslkzfdsswlmmsbdgjwmjnummk +dhsxylejzityahtqqzmohrpzjprrsraztpnuagtyzfjdekthvdogfidksrdppr +ybc +fyukknoqfnkllkwflwempjijxgo +dltvlau +rhvrvlwsribfctuzodfqkdczfzxnetqqzflnhiyl +goxmcasmq +wljbhwkpahdotqhhrbhqzijv +lszewkgdmkezvgmbmllhpksdkoiwgkvqjmurshrptlctqsosuurndcuzjfwherotv +dudxxihygxblhgchbgzyzffb +eht +fvwxvqoltdcsd +rkuig +e +axhsacsmnicugul +rubtdlhjqndxdzzwfnkuzy +swxteuyxxsktkjgv +hzwwodlqaq +vxgecev +qnwla +vdxjuzpyoqhpmuunyffptopmeauhycs +dkzo +awrfzatzohslgvqlaezepmli +qgxatixvpkkhvkumbwmwcagtgyfljdok +amdnzstpvcqj +xsrvwvhjirzfgkessve +qezwbfltfbikbmoasvoflozsjhrljnszqiciuqmflrlqowwkoevuumh +babskcvavmtvsxqsewirucwzajjcfcqwsydydqo +ywfurpsl +edacsjjkjjewkxfoh +dcgkfpcjezurnuhiatrczcp +xsatnimwbcciu +grzmbrsvvcyigcbmcqfwiiknrohveubhyijxeyzfm +kqyewccgcqrrrznwxmoztlyseagbpyho +najju +nis +awgzdvfjkzlrsjcqfeacx +oisuflfigrjaex +desbdulyuwqxuxianyypybxwlql +ekmqgspvqpftpwswayh +egbyj +fznzprhvnnwcxgcc +wfdsueieosmugirxbymbpmfrspvrktjzguxm +qkjrufshwnfwwpbhukdjlaqvljlgubmqmhnha +hwqpudgnblhlxppbrmbznotteivuzguuwlhtkytky +w +yofkyzbpg +cenolnfnllkvhikrpttcxgqxmufvorekjruyjxmr + +hyexmpjijgzumawp +cdbevdilgopbzlo +fivelagckslkugdxprjxkylizewcptwxfhomzuituujixchadmnjoktnqa +csojvlinzmmkkfzqueamnuwkanzdzsavgohposbuoamoevehqrmcxdsuyelvvctoejzoertqormhaaxwofvjzekwt +sbkghhnhutrvwtyjaxndzyjamrhx +jjyqy +majwbnrhveuhrsbbbjrwpwuplifeseylqh +wyvutpxnkrnkuxxetjkkifpqb +dyzucmbcvgnjeecm +hz +uhnuipthxrzkqluosvk +lwqqzsdwiwvwaqfwlvubadlyizlo +jbd +oyzjeu +kydjkbsqxnbfiuesc +smeubjqrcxdvhsabzceyglqjzbfmoacmwvwjbhhxbr +uabipgecujfdfxpmdzrscdyvefizabgspqjrrkmgjt +xgvdgzryz +lw +uimob +ifhn +bqph +ole +g +wt +k +yslzrkwkundxfdibwqvucemepqxlmlpyngabbeciuzhptpjdetyngrtxrdtzmvq +ccwapidp + +bwvrgvmtshevrophy +ni +fdkplu +mdykey +i +rhsrenoetdggpjb +djmkplpeabsholx +judxtub +fooakqwvocvpcrvxqhvtmpvhkrecy +uuxscjillynilbkrgt +evtinrmilniguarqritpeipwochmdw +sxaqzjybydyvnmmjtdcgkjnqfcklbfpkdfyewgcukqoiegyfp +kg +ovrwieqhy +jcxqtkerzjwhs +xeonglszbgypafhmqcaseimzjgebkvigbqwsayrnrprtuvhsxyitfqygohgorcdnufbcyvevvgzmjrgjqqquwkszplogx +zdketqqv +yebckucwayckeezfvtnavglpjh +zorkfrwk +pad +xqaquxudybwtgixbfktinctfirjfdayh +rieknj +ebk +qzbcfywfdmhsdruhopovemafijbscagllkmhmof + +asbsnbddlobwoqatfhkbhhsymzqxjuixwreheugvngmgcuqpkjhhfwpbarqaxrwgwnjbanljlds +etevdvlc +lqyjrnmenhn +k +tsf +zczgeavcexh +jlpuxywtsrvnvluruqhecjca +ir +rikrgkmhwaosodkxgcnrexfmdrszhnmutpvwztg +bffjqovvkemctnsgeh +weysbhzixiipfithjfsk +usyzvaiyuhmksfluoirfbnsu +o +cgawpdakaszeafdtbdkqtlzkrpnoqomqvuaqcfmzgvfegovtfaonelpv +izmrcjlk +xmzemniyrzy +knqexaafsdlimdamcrprlshq +qkmqw +dntgjwsibclvposdwjuklvtejjjdjibgpyynqpgprvvaetshhmvfkcpb +otvazkrkklrxfotpopyjte +fghkcnpi +rulyaihsowvcgbzeiblhuhhfbmncqsuuqcxvseorn +exirzfmojnxcoqom +zsgpgtokun +zvamxfocorganbtlafifwdqmqtsnktbwwtewborq + +cxlnaspjqvsitjyzyriqsuorjsrvzqenisprttudxntsbqrpjtdkxnwcwgjyxmgtqljcrmrbrmyvosojzlumcmjcgfjsdehec +mvx +mt +mckr +teulvroifk +laaicc +koufy +bexmwsvyarnznebdfy +ripvviosbqijsxnjilwddaqaqemzsdarnxmfooxghoypizwtbueo +ljycycuqwfnzbambibqdixmkkvwtubepla +cis +kcg +vmbbiuuoamenzepuagpfujevfstqtndjxjchdvycfrrrowochtjdmkklgnhf +pmorrwguxkvdxpluatagaziin + +uwvzbmkmykjkmknzppklx +pnzxuvsrjunqxercsnvayhykcazdeclomdsasgkpqpiufyfqsxhj +yceizkddwojgweegcllaagpvrpo +ek +kuxxgbezqyxvfaxdwnqdgqsmneijunxzlwxkrs +ldldbrxmvtjlqxifngmactzqcygkvuteffcmvphevilabgukatqakamjlridznodcvblvlogulmcixxfimh +iuzjootuywjqklolzzhpeaynydjwtufjavbozxnzckuzdodkvkjfmhinelv +swlfkcufscfcovmghqwcrtxjukwafoeogrkgubbqgwzm +gjcylkwgzroubdssuqeykqjcmguso +fzq +srfvysoxtlylctp + +pbfeiuzwoyixews +ocvvunfsjnrtklmuuzjojw +xdjcnrpqhmpmpcwacpcdtmbsczvhllkqapzjuaf +nfnuvjz +fwnuiyqpn +wshxxxpzzxp +hibrxcfeqca + +wqhlllarl +bukcbojv +plrytapy +xm +vlgfqoyzdczqbbaxjwbjjevjhxgopuqvqcrj +vpjqfbdnsdxlbuuiqocvrhap +mgumjbvnnzgnrdru +gcgzugazxdcamrhczfzhtmdjj +uislwq +vooai +zjuqfmebuzsqngzekyajujkopvayxtdzvugwwucvlsbrnhitfotmhhmgddlzlvqrkcponictrfweuilfjiuoabkfdvpjiqjrrgi +aptjfhmrnxaq +hbs +w +mwmoxqvucwygunplzvxtxpk +fgmqmtlorfzytjdzffsosfccnfwugrsrynuej +rpmpenrhsxoefnblyumjqwvuyszyppnttuyvazjdug +zdzxraxkroknkmqgvuoqeqdtvclsvvuwmdwzfugcpteohlogxubyoebvrzbqzklvehfcqadtdrkpubfhmokzwyosogepwragcpwxo +ax +dz +de + +thvkdmnbdws + +ejmubw +umvwkaubzurf +wyxtxeluaoox +wwbioobtgmkebxo +miglgnafmdarzkeblyjctuayzyoeqnfnbtrcbymdzkzg +loavxq +kzhllgsenxlbgdbfzwbg +yxflogzsohlcycbyzegeubfflouvtuatixhjvicjegltjiy +jigqfjppafdiarc +mcnmwtachgearonfcymvjbrnljjxmlzkudvzqsarnfysmxlfrtlvjxwvpdbhvwysnvcdozfcruhjwnucdzakkilmlfgjiolcatpfusm + +n +pdjunfcz +dc +edxkkxabsbvmvifiinnoccki +bc +gwtwsvorwzfqpz +exidmexstfflkhi +s +s +c +wtcjfywlayhpbqktcepoybowtkrmnumqsg +ozclkgjdmdk +jmegtbunyexurvfexhqptnqzie +tkoenpagzwqfawlxvzaijsjqhmg +swodqfjpdqcbkc +ujokogocyaygdibgpglecis +shlmdmgonvpuaxlhrymkxtiytmv +brhk +jmsyiuomiywxhegilycjprkyfgojdo + +wzdzrgpdiosdsvkcw +odlnmsfnjrcsnflviwvawybpczdkzvdocpwrmavz +p +ubowamlskcqhdxuckrxa +fawhntiwhmdwkddnahmtajqqazpdygttqivhdiodkcpcwv +gmxujmmaufmbipaiulhurzkfdg +eixjhmbaeoybiwk +kumntgrgiofcmujlzbcopuobambsw +mnjkqiyb +iktwnsnv +hfuzcl +tqiyqvagbqgtowpjbedgjot +dfemvamelxadkztogliizdtsddoboafawficudlefo +raecmxiiibljryswntpfed +mbwrtsebkeegw +x +epp +he + +vnztrswhiusokqdkmsnpuswucvfhcthjbtam +baxlwidsgbdpzvnlj +tcbjjoadrzo +aiidahyllzzsg + +igebuubweicbssgddpmqxunrawavuglmpxrtkqsvjjtscibqiejjfgfnovokodmqcqitlteiakooupvzkwucucrfdzjvjbqbkgutoybmpfvhbutigdxhfiqfplyciz +cnrhbjdnjftwfwlwzrdkwhajgsizsi +qfntnt +okqyfnbresp +asyg +mjqdkdyggdxzwuzglays +h +ifaqcazoy +fol +vvsusbnugduxsceozmsarbp +epjwtorx +bwiuxxiyc +cw +bwogruhctwkfvbexjnwircykxyzjmats +kygiochfwlpsvmxcgmtjrgvfdptd +q +qmpqe + +z +jghffhqfoecmszunhxmzmzhlmbrvjabhrkihgjmvckhkfpaygjkg + +kfiyfgounmhlvhupswqdgws +ezzdpyqucqoocsdcjtruqpokldfkmjhqzoynirybsifyaxnaxppthjoqy +nwetlgzwrhkhtuubbkbepuhbllxspvagxrqokwnrhkbwdwtp +hlazomrhqogoaxypqaszwfxxmutvbpuuvpdffuqskcbzlwyzcssnflkwiydoveyxjnzllzhyozbsa +hwnitkwbxcyibbqsluuqywbk + +ozpfjsdrc +yoepefuy +lvmspzepnetra +genbrcrmuqfvkaouvuymoxhcxotjjhk +pcshyqgbmqdubsdajnyfqvxkqvywffzn +ukhcbyzwslqeq +otfrmcbnhbyffxqregqoufdxucjunwdhlqqeiiawbxlpqeyzzopfungrryqdykgizrhqodirvazm +dhpfhzyq +cloz +eduupqifolfekve +qiec +ishnjukvomntmdthlkajxpiwk +y +axl +tmyskjqkjsvumizlal +wvvolwewsfxhhdieuagdcuhwsgqvswpbkdkpxskloalmr +ryfmhe +z +mmbpgsyrfvzdatbjrjhuipwt +llzwizmmuulgwocowwmugtaoewkhnqxparvtynlffffdfcocdbba + +pyczkzbmcgrdnxnmezsx +gsqe +mcocxcolcynhpecstsn +opnpplkccobjuhtbhirpzfxuktmpsiwbvsgiaavvdge +wpaldxzasnrbvtugjwytvtfttrh +zxecurevkjiyxy +wtnovebcmglkktic +fdpwfgvlvovxrwh +bmwgdullzy +uzwhagxinwqifxjbcntqzqoxkmpqxhe +jrfizsnwxwnnhb +inapddlahrp + +ndtvkceobe +buskgghihdjmjlwfc +j +rkvffxwtmzoeruhlsurwtnuh +cbvkhfepkdishfpqvijzrpleuy +jzdpxjhcgqnybssfegvrnpgyehdqpgjwudbwrjbavp +xzzvgqdrdwajmdmj +vfatwsxvwfdbdhnijdujoyotwvwjipuuetichcfmvgrsnjpqaaezjtkvc +lbfoqgfshrtwgdqufwnfuitdrjydqctqixlzufkdbp +zgau +qefdpmtkecvtj +kuphldkvnzdtpd +dti +fpd +gfrliyegxsb +i +qsddsrmkyfgzrjeqnitmnypbcakh +vfbvbrpuogzhzrbmklvhji +nkz +xlufbaoblbmeub +alwuzxzmobwdukvwnkiwmuqhuxfhevogdnqtmxjptqznrk +cngpoty + +ms +qvenfg +dmeaffm +jycfgnanbmoamhmarkmjcagbp +ysqmbhopgx +jczbzgwedsp + +zxzwjrxcwdtleizjlvifjwgxiibezwxhtzywqdi +mtgnlu +xboxirdchurkfnklnpkapnqfxnhrxyseiujrznjm + +zm +atddskbghcahlhql +szshwzmmvu +befdtpouamwhiisyybispkchpjhownatawjfbx + +ennkzbrlygd +zbt +upphzpdwzmlhhhbqvjsfmbnrar +ddcs +ipbxgzyudjyongtcyygncojdufnufqpdppgvq +gc +isu +foa +wf +jdlvqxgfbowhohhyyngbcs +zjuwjyucdwblatsnywaaoftlcamfbcnw +lzrioesuhoeevczuwrnltmkahfwiu +uicggfbddqltnjyxfltbnaekncnyxsit +zkxsqkqrwrzrxgxbsgxatybfr + +ptvmfyxdcglbfipcguqthjygzqnpqssscukzawynidtchjrrxwuxifoe +w +ohu +vg +zagpowezvbniybgold +lhqseqcxteiqtgnpanpvrmvvlltxh +mtfnxn +wyodtg + +rawpbgtpbaktqzmmpzxmrlwpvvmdsl +widcfbirvswraukbmkhf +vplrueuxomjkqrtjgyxjdkexttzyozawyq +hrpbahllznvmjudzxpbbv +tlavfrxygjfipkupwnbacltcfepeg +icu +otxcu +aewazy +hl + +fmrp +qaacthwzohenzjr +xbyebba +rvkph +mkhhmh +swme +zjmdoypaktglcyzobquunvthcdwegtbywpijxd +jvkuhnxqc +gibhqgjojsxt +bodbktzomiqujtbstqiyquwvqgufphqstenxvddkvtdh +bpusrxkfi +zgp +pmxvgamydyakituvvsucsuidrlznupcsinltmrahulhepxmhoqtfvpjkxzhrrinncuh +jzgkjjhjqykzelaszvcwvvwbnzsxdeaerfnaravk +ynanrqyrxo +zsmuxofullob +brklgrcqefdyoczy +qkpls +snhqumae +iqdtzjadzzvnqvdvjfsaf +nfqfdqiramueblxkaqxbbkxwywzgdbndjjiqk +tc +kp +cpuckbjsxhtxmomfesgxdpz +oseif +ybhxbvyxrpkrexrhjzoaxxohrhsniewsrktjnaztn +ggelspdzhzbchruhbjbjidgjwdlhdycetqaswh +jkgivsngygkbqtlmoj +dwpnanfvitxg +ospxbwxp +wgvmvrnjescemdoiralbkvemalifxnyhrbdgodml +hjtsnkzknkplbzsiwmneefdkihnhsamjsrxggclyjqgpqltizi + + +sykgbuypwwhweab +nvdkkkskmtiwpoerkon +sx +sbyflwwiqylbskdlxesmylpaz +dnwcjenaluwesyywfaezznwkdwpoesxpu +kie +dslccwfryol +gfhomgfn +zprjtfqvkotktzidmoyrivall +bunvsqkysdelozemnjoeqfolruulpbipm +ullyzfahpkhkja +hwd +kvyqtprpuulgsk +zotbkcadnxmfvqmtlbxalhughceyfcibtzzj +vvpjbgxygl +hpic +mhrqd +dv +thehuzdbaacoidjoljbysnqwrrxxplrdznmgiukkvjqbopb +moszjt +rmtbunktkywqirveeqfa +kse +wbfflnatgzobjrxghjgvcsyxoruenxhyomutbptswjajawqjpqafpdcstkiyjuilimecgejpqmyciolgcmdpcstzdozbmnza diff --git a/deps/aho-corasick-0.2.1/ctags.rust b/deps/aho-corasick-0.2.1/ctags.rust new file mode 100644 index 000000000..b42edf757 --- /dev/null +++ b/deps/aho-corasick-0.2.1/ctags.rust @@ -0,0 +1,11 @@ +--langdef=Rust +--langmap=Rust:.rs +--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/ +--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ diff --git a/deps/aho-corasick-0.2.1/examples/dict-search.rs b/deps/aho-corasick-0.2.1/examples/dict-search.rs new file mode 100644 index 000000000..2900fd5b1 --- /dev/null +++ b/deps/aho-corasick-0.2.1/examples/dict-search.rs @@ -0,0 +1,87 @@ +// This example demonstrates how to use the Aho-Corasick algorithm to rapidly +// scan text for matches in a large dictionary of keywords. This example by +// default reads your system's dictionary (~120,000 words). +extern crate aho_corasick; +extern crate csv; +extern crate docopt; +extern crate rustc_serialize; + +use std::error::Error; +use std::fs::File; +use std::io::{self, BufRead, Write}; +use std::process; + +use aho_corasick::{Automaton, AcAutomaton, Match}; +use docopt::Docopt; + +static USAGE: &'static str = " +Usage: dict-search [options] + dict-search --help + +Options: + -d , --dict Path to dictionary of keywords to search. + [default: /usr/share/dict/words] + -m , --min-len The minimum length for a keyword in UTF-8 + encoded bytes. [default: 5] + --overlapping Report overlapping matches. + -h, --help Show this usage message. +"; + +#[derive(Clone, Debug, RustcDecodable)] +struct Args { + arg_input: String, + flag_dict: String, + flag_min_len: usize, + flag_overlapping: bool, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(err) => { + writeln!(&mut io::stderr(), "{}", err).unwrap(); + process::exit(1); + } + } +} + +fn run(args: &Args) -> Result<(), Box> { + let aut = try!(build_automaton(&args.flag_dict, args.flag_min_len)); + let rdr = try!(File::open(&args.arg_input)); + if args.flag_overlapping { + try!(write_matches(&aut, aut.stream_find_overlapping(rdr))); + } else { + try!(write_matches(&aut, aut.stream_find(rdr))); + } + Ok(()) +} + +fn write_matches(aut: &A, it: I) -> Result<(), Box> + where A: Automaton, I: Iterator> { + let mut wtr = csv::Writer::from_writer(io::stdout()); + try!(wtr.encode(("pattern", "start", "end"))); + for m in it { + let m = try!(m); + try!(wtr.encode((aut.pattern(m.pati), m.start, m.end))); + } + try!(wtr.flush()); + Ok(()) +} + +fn build_automaton( + dict_path: &str, + min_len: usize, +) -> Result> { + let buf = io::BufReader::new(try!(File::open(dict_path))); + let mut lines = Vec::with_capacity(1 << 10); + for line in buf.lines() { + let line = try!(line); + if line.len() >= min_len { + lines.push(line); + } + } + Ok(AcAutomaton::new(lines)) +} diff --git a/deps/aho-corasick-0.2.1/session.vim b/deps/aho-corasick-0.2.1/session.vim new file mode 100644 index 000000000..213c95660 --- /dev/null +++ b/deps/aho-corasick-0.2.1/session.vim @@ -0,0 +1 @@ +au BufWritePost *.rs silent!make ctags > /dev/null 2>&1 diff --git a/deps/aho-corasick-0.2.1/src/autiter.rs b/deps/aho-corasick-0.2.1/src/autiter.rs new file mode 100644 index 000000000..bf505e812 --- /dev/null +++ b/deps/aho-corasick-0.2.1/src/autiter.rs @@ -0,0 +1,325 @@ +use std::io::{self, BufRead, Read}; + +use super::{ROOT_STATE, PatIdx, StateIdx}; + +/// An abstraction over automatons and their corresponding iterators. +pub trait Automaton: Sized { + /// Return the next state given the current state and next character. + fn next_state(&self, si: StateIdx, b: u8) -> StateIdx; + + /// Return true if and only if the given state and current pattern index + /// indicate a match. + fn has_match(&self, si: StateIdx, outi: PatIdx) -> bool; + + /// Build a match given the current state, pattern index and input index. + fn get_match(&self, si: StateIdx, outi: PatIdx, texti: usize) -> Match; + + /// Attempt to skip through the input. + /// + /// This returns the index into `text` at which the next match attempt + /// should start. (If no skipping occurred, then the return value should + /// be equal to `at`.) + /// + /// Finally, if no match is possible, then return `text.len()`. + fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize; + + /// Returns true if and only if this automaton can skip through the input. + fn is_skippable(&self) -> bool; + + /// Returns all of the patterns matched by this automaton. + /// + /// The order of the patterns is the order in which they were added. + fn patterns(&self) -> &[String]; + + /// Returns the pattern indexed at `i`. + /// + /// The index corresponds to the position at which the pattern was added + /// to the automaton, starting at `0`. + fn pattern(&self, i: usize) -> &str; + + /// Return the number of patterns in the automaton. + #[inline] + fn len(&self) -> usize { + self.patterns().len() + } + + /// Returns true if the automaton has no patterns. + #[inline] + fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns an iterator of non-overlapping matches in `s`. + fn find<'a, 's>( + &'a self, + s: &'s str, + ) -> Matches<'a, 's, Self> { + Matches { + aut: self, + text: s.as_bytes(), + texti: 0, + si: ROOT_STATE, + } + } + + /// Returns an iterator of overlapping matches in `s`. + fn find_overlapping<'a, 's>( + &'a self, + s: &'s str, + ) -> MatchesOverlapping<'a, 's, Self> { + MatchesOverlapping { + aut: self, + text: s.as_bytes(), + texti: 0, + si: ROOT_STATE, + outi: 0, + } + } + + /// Returns an iterator of non-overlapping matches in the given reader. + fn stream_find<'a, R: io::Read>( + &'a self, + rdr: R, + ) -> StreamMatches<'a, R, Self> { + StreamMatches { + aut: self, + buf: io::BufReader::new(rdr), + texti: 0, + si: ROOT_STATE, + } + } + + /// Returns an iterator of overlapping matches in the given reader. + fn stream_find_overlapping<'a, R: io::Read>( + &'a self, + rdr: R, + ) -> StreamMatchesOverlapping<'a, R, Self> { + StreamMatchesOverlapping { + aut: self, + buf: io::BufReader::new(rdr), + texti: 0, + si: ROOT_STATE, + outi: 0, + } + } +} + +/// Records a match in the search text. +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +pub struct Match { + /// The pattern index. + /// + /// This corresponds to the ordering in which the matched pattern was + /// added to the automaton, starting at `0`. + pub pati: usize, + /// The starting byte offset of the match in the search text. + pub start: usize, + /// The ending byte offset of the match in the search text. + /// + /// (This can be re-captiulated with `pati` and adding the pattern's + /// length to `start`, but it is convenient to have it here.) + pub end: usize, +} + +/// An iterator of non-overlapping matches for in-memory text. +/// +/// This iterator yields `Match` values. +/// +/// `'a` is the lifetime of the automaton and `'s` is the lifetime of the +/// search text. +#[derive(Debug)] +pub struct Matches<'a, 's, A: 'a + Automaton> { + aut: &'a A, + text: &'s [u8], + texti: usize, + si: StateIdx, +} + +impl<'a, 's, A: Automaton> Iterator for Matches<'a, 's, A> { + type Item = Match; + + fn next(&mut self) -> Option { + // When there's an initial lone start byte, it is usually worth it + // to use `memchr` to skip along the input. The problem is that + // the skipping function is called in the inner match loop, which + // can be quite costly if the skipping condition is never met. + // Therefore, we lift the case analysis outside of the main loop at + // the cost of repeating code. + if self.aut.is_skippable() { + self.texti = self.aut.skip_to(self.si, self.text, self.texti); + while self.texti < self.text.len() { + self.si = self.aut.next_state(self.si, self.text[self.texti]); + if self.aut.has_match(self.si, 0) { + let m = self.aut.get_match(self.si, 0, self.texti); + self.si = ROOT_STATE; + self.texti += 1; + return Some(m); + } + self.texti = self.aut.skip_to( + self.si, self.text, self.texti + 1); + } + } else { + while self.texti < self.text.len() { + self.si = self.aut.next_state(self.si, self.text[self.texti]); + if self.aut.has_match(self.si, 0) { + let m = self.aut.get_match(self.si, 0, self.texti); + self.si = ROOT_STATE; + self.texti += 1; + return Some(m); + } + self.texti += 1; + } + } + None + } +} + +/// An iterator of non-overlapping matches for streaming text. +/// +/// This iterator yields `io::Result` values. +/// +/// `'a` is the lifetime of the automaton and `R` is the type of the underlying +/// `io::Read`er. +#[derive(Debug)] +pub struct StreamMatches<'a, R, A: 'a + Automaton> { + aut: &'a A, + buf: io::BufReader, + texti: usize, + si: StateIdx, +} + +impl<'a, R: io::Read, A: Automaton> Iterator for StreamMatches<'a, R, A> { + type Item = io::Result; + + fn next(&mut self) -> Option> { + let mut m = None; + let mut consumed = 0; +'LOOP: loop { + self.buf.consume(consumed); + let bs = match self.buf.fill_buf() { + Err(err) => return Some(Err(err)), + Ok(bs) if bs.len() == 0 => break, + Ok(bs) => bs, + }; + consumed = bs.len(); // is shortened if we find a match + for (i, &b) in bs.iter().enumerate() { + self.si = self.aut.next_state(self.si, b); + if self.aut.has_match(self.si, 0) { + m = Some(Ok(self.aut.get_match(self.si, 0, self.texti))); + consumed = i + 1; + self.texti += 1; + self.si = ROOT_STATE; + break 'LOOP; + } + self.texti += 1; + } + } + self.buf.consume(consumed); + m + } +} + +/// An iterator of overlapping matches for in-memory text. +/// +/// This iterator yields `Match` values. +/// +/// `'a` is the lifetime of the automaton and `'s` is the lifetime of the +/// search text. +#[derive(Debug)] +pub struct MatchesOverlapping<'a, 's, A: 'a + Automaton> { + aut: &'a A, + text: &'s [u8], + texti: usize, + si: StateIdx, + outi: usize, +} + +impl<'a, 's, A: Automaton> Iterator for MatchesOverlapping<'a, 's, A> { + type Item = Match; + + fn next(&mut self) -> Option { + if self.aut.has_match(self.si, self.outi) { + let m = self.aut.get_match(self.si, self.outi, self.texti); + self.outi += 1; + if !self.aut.has_match(self.si, self.outi) { + self.texti += 1; + } + return Some(m); + } + + self.outi = 0; + self.texti = self.aut.skip_to(self.si, self.text, self.texti); + while self.texti < self.text.len() { + let b = self.text[self.texti]; + self.si = self.aut.next_state(self.si, b); + if self.aut.has_match(self.si, self.outi) { + return self.next(); + } + self.texti = self.aut.skip_to(self.si, self.text, self.texti + 1); + } + None + } +} + +/// An iterator of overlapping matches for streaming text. +/// +/// This iterator yields `io::Result` values. +/// +/// `'a` is the lifetime of the automaton and `R` is the type of the underlying +/// `io::Read`er. +#[derive(Debug)] +pub struct StreamMatchesOverlapping<'a, R, A: 'a + Automaton> { + aut: &'a A, + buf: io::BufReader, + texti: usize, + si: StateIdx, + outi: usize, +} + +impl< + 'a, + R: io::Read, + A: Automaton, +> Iterator for StreamMatchesOverlapping<'a, R, A> { + type Item = io::Result; + + fn next(&mut self) -> Option> { + if self.aut.has_match(self.si, self.outi) { + let m = self.aut.get_match(self.si, self.outi, self.texti); + self.outi += 1; + if !self.aut.has_match(self.si, self.outi) { + self.texti += 1; + } + return Some(Ok(m)); + } + let mut m = None; + let mut consumed = 0; + self.outi = 0; +'LOOP: loop { + self.buf.consume(consumed); + let bs = match self.buf.fill_buf() { + Err(err) => return Some(Err(err)), + Ok(bs) if bs.len() == 0 => break, + Ok(bs) => bs, + }; + consumed = bs.len(); // is shortened if we find a match + for (i, &b) in bs.iter().enumerate() { + self.si = self.aut.next_state(self.si, b); + if self.aut.has_match(self.si, self.outi) { + m = Some(Ok(self.aut.get_match(self.si, self.outi, + self.texti))); + consumed = i + 1; + self.outi += 1; + if !self.aut.has_match(self.si, self.outi) { + self.texti += 1; + } + break 'LOOP; + } + self.texti += 1; + } + } + self.buf.consume(consumed); + m + } +} + diff --git a/deps/aho-corasick-0.2.1/src/full.rs b/deps/aho-corasick-0.2.1/src/full.rs new file mode 100644 index 000000000..c90c6174e --- /dev/null +++ b/deps/aho-corasick-0.2.1/src/full.rs @@ -0,0 +1,116 @@ +use memchr::memchr; + +use super::{ + FAIL_STATE, ROOT_STATE, + StateIdx, PatIdx, + AcAutomaton, Transitions, Match, +}; +use super::autiter::Automaton; + +/// A complete Aho-Corasick automaton. +/// +/// This uses a single transition matrix that permits each input character +/// to move to the next state with a single lookup in the matrix. +/// +/// This is as fast as it gets, but it is guaranteed to use a lot of memory. +/// Namely, it will use at least `4 * 256 * #states`, where the number of +/// states is capped at length of all patterns concatenated. +#[derive(Clone, Debug)] +pub struct FullAcAutomaton { + pats: Vec, + // i * #states + si + trans: Vec, // row-major, where states are rows + out: Vec>, // indexed by StateIdx + start_bytes: Vec, +} + +impl FullAcAutomaton { + /// Build a new expanded Aho-Corasick automaton from an existing + /// Aho-Corasick automaton. + pub fn new(ac: AcAutomaton) -> FullAcAutomaton { + let mut fac = FullAcAutomaton { + pats: vec![], + trans: vec![FAIL_STATE; 256 * ac.states.len()], + out: vec![vec![]; ac.states.len()], + start_bytes: vec![], + }; + fac.build_matrix(&ac); + fac.pats = ac.pats; + fac.start_bytes = ac.start_bytes; + fac + } + + fn set(&mut self, si: StateIdx, i: u8, goto: StateIdx) { + let ns = self.num_states(); + self.trans[i as usize * ns + si as usize] = goto; + } + + #[inline] + fn num_states(&self) -> usize { + self.out.len() + } +} + +impl Automaton for FullAcAutomaton { + #[inline] + fn next_state(&self, si: StateIdx, i: u8) -> StateIdx { + self.trans[i as usize * self.num_states() + si as usize] + } + + #[inline] + fn get_match(&self, si: StateIdx, outi: usize, texti: usize) -> Match { + let pati = self.out[si as usize][outi]; + let patlen = self.pats[pati].len(); + let start = texti + 1 - patlen; + Match { + pati: pati, + start: start, + end: start + patlen, + } + } + + #[inline] + fn has_match(&self, si: StateIdx, outi: usize) -> bool { + outi < self.out[si as usize].len() + } + + #[inline] + fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize { + if si != ROOT_STATE || !self.is_skippable() { + return at; + } + let b = self.start_bytes[0]; + match memchr(b, &text[at..]) { + None => text.len(), + Some(i) => at + i, + } + } + + #[inline] + fn is_skippable(&self) -> bool { + self.start_bytes.len() == 1 + } + + #[inline] + fn patterns(&self) -> &[String] { + &self.pats + } + + #[inline] + fn pattern(&self, i: usize) -> &str { + &self.pats[i] + } +} + +impl FullAcAutomaton { + fn build_matrix(&mut self, ac: &AcAutomaton) { + for (si, s) in ac.states.iter().enumerate().skip(1) { + for b in (0..256).map(|b| b as u8) { + self.set(si as StateIdx, b, ac.next_state(si as StateIdx, b)); + } + for &pati in &s.out { + self.out[si].push(pati); + } + } + } +} diff --git a/deps/aho-corasick-0.2.1/src/lib.rs b/deps/aho-corasick-0.2.1/src/lib.rs new file mode 100644 index 000000000..9b83d860f --- /dev/null +++ b/deps/aho-corasick-0.2.1/src/lib.rs @@ -0,0 +1,863 @@ +/*! +An implementation of the +[Aho-Corasick string search algorithm](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm). + +The Aho-Corasick algorithm is principally useful when you need to search many +large texts for a fixed (possibly large) set of keywords. In particular, the +Aho-Corasick algorithm preprocesses the set of keywords by constructing a +finite state machine. The search phase is then a quick linear scan through the +text. Each character in the search text causes a state transition in the +automaton. Matches are reported when the automaton enters a match state. + +# Examples + +The main type exposed by this crate is `AcAutomaton`, which can be constructed +from an iterator of pattern strings: + +```rust +use aho_corasick::{Automaton, AcAutomaton}; + +let aut = AcAutomaton::new(vec!["apple", "maple"]); + +// AcAutomaton also implements `FromIterator`: +let aut: AcAutomaton = ["apple", "maple"].iter().cloned().collect(); +``` + +Finding matches can be done with `find`: + +```rust +use aho_corasick::{Automaton, AcAutomaton, Match}; + +let aut = AcAutomaton::new(vec!["apple", "maple"]); +let mut it = aut.find("I like maple apples."); +assert_eq!(it.next(), Some(Match { + pati: 1, + start: 7, + end: 12, +})); +assert_eq!(it.next(), Some(Match { + pati: 0, + start: 13, + end: 18, +})); +assert_eq!(it.next(), None); +``` + +Use `find_overlapping` if you want to report all matches, even if they +overlap with each other. + +```rust +use aho_corasick::{Automaton, AcAutomaton, Match}; + +let aut = AcAutomaton::new(vec!["abc", "a"]); +let matches: Vec<_> = aut.find_overlapping("abc").collect(); +assert_eq!(matches, vec![ + Match { pati: 1, start: 0, end: 1}, Match { pati: 0, start: 0, end: 3 }, +]); + +// Regular `find` will report only one match: +let matches: Vec<_> = aut.find("abc").collect(); +assert_eq!(matches, vec![Match { pati: 1, start: 0, end: 1}]); +``` + +Finally, there are also methods for finding matches on *streams*. Namely, the +search text does not have to live in memory. It's useful to run this on files +that can't fit into memory: + +```no_run +use std::fs::File; + +use aho_corasick::{Automaton, AcAutomaton}; + +let aut = AcAutomaton::new(vec!["foo", "bar", "baz"]); +let rdr = File::open("search.txt").unwrap(); +for m in aut.stream_find(rdr) { + let m = m.unwrap(); // could be an IO error + println!("Pattern '{}' matched at: ({}, {})", + aut.pattern(m.pati), m.start, m.end); +} +``` + +There is also `stream_find_overlapping`, which is just like `find_overlapping`, +but it operates on streams. + +Please see `dict-search.rs` in this crate's `examples` directory for a more +complete example. It creates a large automaton from a dictionary and can do a +streaming match over arbitrarily large data. + +# Memory usage + +A key aspect of an Aho-Corasick implementation is how the state transitions +are represented. The easiest way to make the automaton fast is to store a +sparse 256-slot map in each state. It maps an input byte to a state index. +This makes the matching loop extremely fast, since it translates to a simple +pointer read. + +The problem is that as the automaton accumulates more states, you end up paying +a `256 * 4` (`4` is for the `u32` state index) byte penalty for every state +regardless of how many transitions it has. + +To solve this, only states near the root of the automaton have this sparse +map representation. States near the leaves of the automaton use a dense mapping +that requires a linear scan. + +(The specific limit currently set is `3`, so that states with a depth less than +or equal to `3` are less memory efficient. The result is that the memory usage +of the automaton stops growing rapidly past ~60MB, even for automatons with +thousands of patterns.) + +If you'd like to opt for the less-memory-efficient-but-faster version, then +you can construct an `AcAutomaton` with a `Sparse` transition strategy: + +```rust +use aho_corasick::{Automaton, AcAutomaton, Match, Sparse}; + +let aut = AcAutomaton::::with_transitions(vec!["abc", "a"]); +let matches: Vec<_> = aut.find("abc").collect(); +assert_eq!(matches, vec![Match { pati: 1, start: 0, end: 1}]); +``` +*/ + +#![deny(missing_docs)] + +extern crate memchr; +#[cfg(test)] extern crate quickcheck; +#[cfg(test)] extern crate rand; + +use std::collections::VecDeque; +use std::fmt; +use std::iter::FromIterator; + +use memchr::memchr; + +pub use self::autiter::{ + Automaton, Match, + Matches, MatchesOverlapping, StreamMatches, StreamMatchesOverlapping, +}; +pub use self::full::FullAcAutomaton; + +// We're specifying paths explicitly so that we can use +// these modules simultaneously from `main.rs`. +// Should probably make just make `main.rs` a separate crate. +#[path = "autiter.rs"] +mod autiter; +#[path = "full.rs"] +mod full; + +/// The integer type used for the state index. +/// +/// Limiting this to 32 bit integers can have a big impact on memory usage +/// when using the `Sparse` transition representation. +pub type StateIdx = u32; + +type PatIdx = usize; + +// Constants for special state indexes. +const FAIL_STATE: u32 = 0; +const ROOT_STATE: u32 = 1; + +// Limit the depth at which we use a dense alphabet map. Once the limit is +// reached, a sparse set is used (and lookup becomes O(n)). +// +// This does have a performance hit, but the (straight forward) alternative +// is to have a `256 * 4` byte overhead for every state. +// Given that Aho-Corasick is typically used for dictionary searching, this +// can lead to dramatic memory bloat. +// +// This limit should only be increased at your peril. Namely, in the worst +// case, `256^DENSE_DEPTH_THRESHOLD * 4` corresponds to the memory usage in +// bytes. A value of `3` gives us a solid cap at around 64MB, which works +// well in practice even for dictionary sized automatons. +// +// Why not make this user configurable? Well, it doesn't make much sense +// because we pay for it with case analysis in the matching loop. Increasing it +// doesn't have much impact on performance (outside of pathological cases?). +// +// There is probably room for adding a new automaton type that doesn't have +// this restriction. +// +// N.B. Someone else seems to have discovered an alternative, but I haven't +// grokked it yet: https://github.com/mischasan/aho-corasick +const DENSE_DEPTH_THRESHOLD: u32 = 3; + +/// An Aho-Corasick finite automaton. +#[derive(Clone)] +pub struct AcAutomaton { + pats: Vec, + states: Vec>, + start_bytes: Vec, +} + +#[derive(Clone)] +struct State { + out: Vec, + fail: StateIdx, + goto: T, + depth: u32, +} + +impl AcAutomaton { + /// Create a new automaton from an iterator of patterns. + /// + /// The patterns must be convertible to Unicode `String` values via the + /// `Into` trait. + pub fn new(pats: I) -> AcAutomaton + where S: Into, I: IntoIterator { + AcAutomaton::with_transitions(pats) + } +} + +impl AcAutomaton { + /// Create a new automaton from an iterator of patterns. + /// + /// This constructor allows one to choose the transition representation. + /// + /// The patterns must be convertible to Unicode `String` values via the + /// `Into` trait. + pub fn with_transitions(pats: I) -> AcAutomaton + where S: Into, I: IntoIterator { + AcAutomaton { + pats: vec![], // filled in later, avoid wrath of borrow checker + states: vec![State::new(0), State::new(0)], // empty and root + start_bytes: vec![], // also filled in later + }.build(pats.into_iter().map(Into::into).collect()) + } + + /// Build out the entire automaton into a single matrix. + /// + /// This will make searching as fast as possible at the expense of using + /// at least `4 * 256 * #states` bytes of memory. + pub fn into_full(self) -> FullAcAutomaton { + FullAcAutomaton::new(self) + } +} + +impl Automaton for AcAutomaton { + #[inline] + fn next_state(&self, mut si: StateIdx, b: u8) -> StateIdx { + loop { + let maybe_si = self.states[si as usize].goto(b); + if maybe_si != FAIL_STATE { + si = maybe_si; + break; + } else { + si = self.states[si as usize].fail; + } + } + si + } + + #[inline] + fn get_match(&self, si: StateIdx, outi: usize, texti: usize) -> Match { + let pati = self.states[si as usize].out[outi]; + let patlen = self.pats[pati].len(); + let start = texti + 1 - patlen; + Match { + pati: pati, + start: start, + end: start + patlen, + } + } + + #[inline] + fn has_match(&self, si: StateIdx, outi: usize) -> bool { + outi < self.states[si as usize].out.len() + } + + #[inline] + fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize { + if si != ROOT_STATE || !self.is_skippable() { + return at; + } + let b = self.start_bytes[0]; + match memchr(b, &text[at..]) { + None => text.len(), + Some(i) => at + i, + } + } + + #[inline] + fn is_skippable(&self) -> bool { + self.start_bytes.len() == 1 + } + + #[inline] + fn patterns(&self) -> &[String] { + &self.pats + } + + #[inline] + fn pattern(&self, i: usize) -> &str { + &self.pats[i] + } +} + +// Below contains code for *building* the automaton. It's a reasonably faithful +// translation of the description/psuedo-code from: +// http://www.cs.uku.fi/~kilpelai/BSA05/lectures/slides04.pdf + +impl AcAutomaton { + // This is the first phase and builds the initial keyword tree. + fn build(mut self, pats: Vec) -> AcAutomaton { + for (pati, pat) in pats.iter().enumerate() { + if pat.is_empty() { + continue; + } + let mut previ = ROOT_STATE; + for &b in pat.as_bytes() { + if self.states[previ as usize].goto(b) != FAIL_STATE { + previ = self.states[previ as usize].goto(b); + } else { + let depth = self.states[previ as usize].depth + 1; + let nexti = self.add_state(State::new(depth)); + self.states[previ as usize].set_goto(b, nexti); + previ = nexti; + } + } + self.states[previ as usize].out.push(pati); + } + for c in (0..256).into_iter().map(|c| c as u8) { + if self.states[ROOT_STATE as usize].goto(c) == FAIL_STATE { + self.states[ROOT_STATE as usize].set_goto(c, ROOT_STATE); + } else { + self.start_bytes.push(c); + } + } + self.pats = pats; + self.fill() + } + + // The second phase that fills in the back links. + fn fill(mut self) -> AcAutomaton { + // Fill up the queue with all non-root transitions out of the root + // node. Then proceed by breadth first traversal. + let mut q = VecDeque::new(); + for c in (0..256).into_iter().map(|c| c as u8) { + let si = self.states[ROOT_STATE as usize].goto(c); + if si != ROOT_STATE { + q.push_front(si); + } + } + while let Some(si) = q.pop_back() { + for c in (0..256).into_iter().map(|c| c as u8) { + let u = self.states[si as usize].goto(c); + if u != FAIL_STATE { + q.push_front(u); + let mut v = self.states[si as usize].fail; + while self.states[v as usize].goto(c) == FAIL_STATE { + v = self.states[v as usize].fail; + } + let ufail = self.states[v as usize].goto(c); + self.states[u as usize].fail = ufail; + let ufail_out = self.states[ufail as usize].out.clone(); + self.states[u as usize].out.extend(ufail_out); + } + } + } + self + } + + fn add_state(&mut self, state: State) -> StateIdx { + let i = self.states.len(); + self.states.push(state); + i as StateIdx + } +} + +impl State { + fn new(depth: u32) -> State { + State { + out: vec![], + fail: 1, + goto: Transitions::new(depth), + depth: depth, + } + } + + fn goto(&self, b: u8) -> StateIdx { self.goto.goto(b) } + fn set_goto(&mut self, b: u8, si: StateIdx) { self.goto.set_goto(b, si); } +} + +/// An abstraction over state transition strategies. +/// +/// This is an attempt to let the caller choose the space/time trade offs +/// used for state transitions. +/// +/// (It's possible that this interface is merely good enough for just the two +/// implementations in this crate.) +pub trait Transitions { + /// Return a new state at the given depth. + fn new(depth: u32) -> Self; + /// Return the next state index given the next character. + fn goto(&self, alpha: u8) -> StateIdx; + /// Set the next state index for the character given. + fn set_goto(&mut self, alpha: u8, si: StateIdx); +} + +/// State transitions that can be stored either sparsely or densely. +/// +/// This uses less space but at the expense of slower matching. +#[derive(Clone, Debug)] +pub struct Dense(DenseChoice); + +#[derive(Clone, Debug)] +enum DenseChoice { + Sparse(Vec), // indexed by alphabet + Dense(Vec<(u8, StateIdx)>), +} + +impl Transitions for Dense { + fn new(depth: u32) -> Dense { + if depth <= DENSE_DEPTH_THRESHOLD { + Dense(DenseChoice::Sparse(vec![0; 256])) + } else { + Dense(DenseChoice::Dense(vec![])) + } + } + + fn goto(&self, b1: u8) -> StateIdx { + match self.0 { + DenseChoice::Sparse(ref m) => m[b1 as usize], + DenseChoice::Dense(ref m) => { + for &(b2, si) in m { + if b1 == b2 { + return si; + } + } + FAIL_STATE + } + } + } + + fn set_goto(&mut self, b: u8, si: StateIdx) { + match self.0 { + DenseChoice::Sparse(ref mut m) => m[b as usize] = si, + DenseChoice::Dense(ref mut m) => m.push((b, si)), + } + } +} + +/// State transitions that are always sparse. +/// +/// This can use enormous amounts of memory when there are many patterns, +/// but matching is very fast. +#[derive(Clone, Debug)] +pub struct Sparse(Vec); + +impl Transitions for Sparse { + fn new(_: u32) -> Sparse { + Sparse(vec![0; 256]) + } + + #[inline] + fn goto(&self, b: u8) -> StateIdx { + self.0[b as usize] + } + + fn set_goto(&mut self, b: u8, si: StateIdx) { + self.0[b as usize] = si; + } +} + +impl> FromIterator for AcAutomaton { + /// Create an automaton from an iterator of strings. + fn from_iter(it: T) -> AcAutomaton where T: IntoIterator { + AcAutomaton::new(it) + } +} + +// Provide some question debug impls for viewing automatons. +// The custom impls mostly exist for special showing of sparse maps. + +impl fmt::Debug for AcAutomaton { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use std::iter::repeat; + + try!(writeln!(f, "{}", repeat('-').take(79).collect::())); + try!(writeln!(f, "Patterns: {:?}", self.pats)); + for (i, state) in self.states.iter().enumerate().skip(1) { + try!(writeln!(f, "{:3}: {}", i, state.debug(i == 1))); + } + write!(f, "{}", repeat('-').take(79).collect::()) + } +} + +impl State { + fn debug(&self, root: bool) -> String { + format!("State {{ depth: {:?}, out: {:?}, fail: {:?}, goto: {{{}}} }}", + self.depth, self.out, self.fail, self.goto_string(root)) + } + + fn goto_string(&self, root: bool) -> String { + use std::char::from_u32; + + let mut goto = vec![]; + for b in (0..256).map(|b| b as u8) { + let si = self.goto(b); + if (!root && si == FAIL_STATE) || (root && si == ROOT_STATE) { + continue; + } + goto.push(format!("{} => {}", from_u32(b as u32).unwrap(), si)); + } + goto.connect(", ") + } +} + +impl fmt::Debug for State { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.debug(false)) + } +} + +impl AcAutomaton { + #[doc(hidden)] + pub fn dot(&self) -> String { + use std::fmt::Write; + let mut out = String::new(); + macro_rules! w { + ($w:expr, $($tt:tt)*) => { {write!($w, $($tt)*)}.unwrap() } + } + + w!(out, r#" +digraph automaton {{ + label=<{}>; + labelloc="l"; + labeljust="l"; + rankdir="LR"; +"#, self.pats.connect(", ")); + for (i, s) in self.states.iter().enumerate().skip(1) { + let i = i as u32; + if s.out.len() == 0 { + w!(out, " {};\n", i); + } else { + w!(out, " {} [peripheries=2];\n", i); + } + w!(out, " {} -> {} [style=dashed];\n", i, s.fail); + for b in (0..256).map(|b| b as u8) { + let si = s.goto(b); + if si == FAIL_STATE || (i == ROOT_STATE && si == ROOT_STATE) { + continue; + } + w!(out, " {} -> {} [label={}];\n", i, si, b as char); + } + } + w!(out, "}}"); + out + } +} + +#[cfg(test)] +mod tests { + use std::collections::HashSet; + use std::io; + + use quickcheck::{Arbitrary, Gen, quickcheck}; + use rand::Rng; + + use super::{Automaton, AcAutomaton, Match}; + + fn aut_find(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + AcAutomaton::new(xs.to_vec()).find(&haystack).collect() + } + + fn aut_finds(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + let cur = io::Cursor::new(haystack.as_bytes()); + AcAutomaton::new(xs.to_vec()) + .stream_find(cur).map(|r| r.unwrap()).collect() + } + + fn aut_findf(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + AcAutomaton::new(xs.to_vec()).into_full().find(haystack).collect() + } + + fn aut_findfs(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + let cur = io::Cursor::new(haystack.as_bytes()); + AcAutomaton::new(xs.to_vec()) + .into_full() + .stream_find(cur).map(|r| r.unwrap()).collect() + } + + fn aut_findo(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + AcAutomaton::new(xs.to_vec()).find_overlapping(haystack).collect() + } + + fn aut_findos(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + let cur = io::Cursor::new(haystack.as_bytes()); + AcAutomaton::new(xs.to_vec()) + .stream_find_overlapping(cur).map(|r| r.unwrap()).collect() + } + + fn aut_findfo(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + AcAutomaton::new(xs.to_vec()) + .into_full().find_overlapping(haystack).collect() + } + + fn aut_findfos(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + let cur = io::Cursor::new(haystack.as_bytes()); + AcAutomaton::new(xs.to_vec()) + .into_full() + .stream_find_overlapping(cur).map(|r| r.unwrap()).collect() + } + + #[test] + fn one_pattern_one_match() { + let ns = vec!["a"]; + let hay = "za"; + let matches = vec![ + Match { pati: 0, start: 1, end: 2 }, + ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn one_pattern_many_match() { + let ns = vec!["a"]; + let hay = "zazazzzza"; + let matches = vec![ + Match { pati: 0, start: 1, end: 2 }, + Match { pati: 0, start: 3, end: 4 }, + Match { pati: 0, start: 8, end: 9 }, + ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn one_longer_pattern_one_match() { + let ns = vec!["abc"]; + let hay = "zazabcz"; + let matches = vec![ Match { pati: 0, start: 3, end: 6 } ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn one_longer_pattern_many_match() { + let ns = vec!["abc"]; + let hay = "zazabczzzzazzzabc"; + let matches = vec![ + Match { pati: 0, start: 3, end: 6 }, + Match { pati: 0, start: 14, end: 17 }, + ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn many_pattern_one_match() { + let ns = vec!["a", "b"]; + let hay = "zb"; + let matches = vec![ Match { pati: 1, start: 1, end: 2 } ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn many_pattern_many_match() { + let ns = vec!["a", "b"]; + let hay = "zbzazzzzb"; + let matches = vec![ + Match { pati: 1, start: 1, end: 2 }, + Match { pati: 0, start: 3, end: 4 }, + Match { pati: 1, start: 8, end: 9 }, + ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn many_longer_pattern_one_match() { + let ns = vec!["abc", "xyz"]; + let hay = "zazxyzz"; + let matches = vec![ Match { pati: 1, start: 3, end: 6 } ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn many_longer_pattern_many_match() { + let ns = vec!["abc", "xyz"]; + let hay = "zazxyzzzzzazzzabcxyz"; + let matches = vec![ + Match { pati: 1, start: 3, end: 6 }, + Match { pati: 0, start: 14, end: 17 }, + Match { pati: 1, start: 17, end: 20 }, + ]; + assert_eq!(&aut_find(&ns, hay), &matches); + assert_eq!(&aut_finds(&ns, hay), &matches); + assert_eq!(&aut_findf(&ns, hay), &matches); + assert_eq!(&aut_findfs(&ns, hay), &matches); + } + + #[test] + fn many_longer_pattern_overlap_one_match() { + let ns = vec!["abc", "bc"]; + let hay = "zazabcz"; + let matches = vec![ + Match { pati: 0, start: 3, end: 6 }, + Match { pati: 1, start: 4, end: 6 }, + ]; + assert_eq!(&aut_findo(&ns, hay), &matches); + assert_eq!(&aut_findos(&ns, hay), &matches); + assert_eq!(&aut_findfo(&ns, hay), &matches); + assert_eq!(&aut_findfos(&ns, hay), &matches); + } + + #[test] + fn many_longer_pattern_overlap_one_match_reverse() { + let ns = vec!["abc", "bc"]; + let hay = "xbc"; + let matches = vec![ Match { pati: 1, start: 1, end: 3 } ]; + assert_eq!(&aut_findo(&ns, hay), &matches); + assert_eq!(&aut_findos(&ns, hay), &matches); + assert_eq!(&aut_findfo(&ns, hay), &matches); + assert_eq!(&aut_findfos(&ns, hay), &matches); + } + + #[test] + fn many_longer_pattern_overlap_many_match() { + let ns = vec!["abc", "bc", "c"]; + let hay = "zzzabczzzbczzzc"; + let matches = vec![ + Match { pati: 0, start: 3, end: 6 }, + Match { pati: 1, start: 4, end: 6 }, + Match { pati: 2, start: 5, end: 6 }, + Match { pati: 1, start: 9, end: 11 }, + Match { pati: 2, start: 10, end: 11 }, + Match { pati: 2, start: 14, end: 15 }, + ]; + assert_eq!(&aut_findo(&ns, hay), &matches); + assert_eq!(&aut_findos(&ns, hay), &matches); + assert_eq!(&aut_findfo(&ns, hay), &matches); + assert_eq!(&aut_findfos(&ns, hay), &matches); + } + + #[test] + fn many_longer_pattern_overlap_many_match_reverse() { + let ns = vec!["abc", "bc", "c"]; + let hay = "zzzczzzbczzzabc"; + let matches = vec![ + Match { pati: 2, start: 3, end: 4 }, + Match { pati: 1, start: 7, end: 9 }, + Match { pati: 2, start: 8, end: 9 }, + Match { pati: 0, start: 12, end: 15 }, + Match { pati: 1, start: 13, end: 15 }, + Match { pati: 2, start: 14, end: 15 }, + ]; + assert_eq!(&aut_findo(&ns, hay), &matches); + assert_eq!(&aut_findos(&ns, hay), &matches); + assert_eq!(&aut_findfo(&ns, hay), &matches); + assert_eq!(&aut_findfos(&ns, hay), &matches); + } + + // Quickcheck time. + + // This generates very small ascii strings, which makes them more likely + // to interact in interesting ways with larger haystack strings. + #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] + pub struct SmallAscii(String); + + impl Arbitrary for SmallAscii { + fn arbitrary(g: &mut G) -> SmallAscii { + use std::char::from_u32; + SmallAscii((0..2) + .map(|_| from_u32(g.gen_range(97, 123)).unwrap()) + .collect()) + } + + fn shrink(&self) -> Box> { + Box::new(self.0.shrink().map(SmallAscii)) + } + } + + impl From for String { + fn from(s: SmallAscii) -> String { s.0 } + } + + // This is the same arbitrary impl as `String`, except it has a bias toward + // ASCII characters. + #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] + pub struct BiasAscii(String); + + impl Arbitrary for BiasAscii { + fn arbitrary(g: &mut G) -> BiasAscii { + use std::char::from_u32; + let size = { let s = g.size(); g.gen_range(0, s) }; + let mut s = String::with_capacity(size); + for _ in 0..size { + if g.gen_weighted_bool(3) { + s.push(char::arbitrary(g)); + } else { + for _ in 0..5 { + s.push(from_u32(g.gen_range(97, 123)).unwrap()); + } + } + } + BiasAscii(s) + } + + fn shrink(&self) -> Box> { + Box::new(self.0.shrink().map(BiasAscii)) + } + } + + fn naive_find(xs: &[S], haystack: &str) -> Vec + where S: Clone + Into { + let needles: Vec = + xs.to_vec().into_iter().map(Into::into).collect(); + let mut matches = vec![]; + for hi in 0..haystack.len() { + for (pati, needle) in needles.iter().enumerate() { + let needle = needle.as_bytes(); + if needle.len() == 0 || needle.len() > haystack.len() - hi { + continue; + } + if needle == &haystack.as_bytes()[hi..hi+needle.len()] { + matches.push(Match { + pati: pati, + start: hi, + end: hi + needle.len(), + }); + } + } + } + matches + } + + #[test] + fn qc_ac_equals_naive() { + fn prop(needles: Vec, haystack: BiasAscii) -> bool { + let aut_matches = aut_findo(&needles, &haystack.0); + let naive_matches = naive_find(&needles, &haystack.0); + // Ordering isn't always the same. I don't think we care, so do + // an unordered comparison. + let aset: HashSet = aut_matches.iter().cloned().collect(); + let nset: HashSet = naive_matches.iter().cloned().collect(); + aset == nset + } + quickcheck(prop as fn(Vec, BiasAscii) -> bool); + } +} diff --git a/deps/aho-corasick-0.2.1/src/main.rs b/deps/aho-corasick-0.2.1/src/main.rs new file mode 100644 index 000000000..60562ac6a --- /dev/null +++ b/deps/aho-corasick-0.2.1/src/main.rs @@ -0,0 +1,13 @@ +extern crate memchr; + +use std::env; + +use lib::AcAutomaton; + +#[allow(dead_code)] +mod lib; + +fn main() { + let aut = AcAutomaton::new(env::args().skip(1)); + println!("{}", aut.dot().trim()); +} diff --git a/deps/bitflags-0.1.1/.gitignore b/deps/bitflags-0.1.1/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/bitflags-0.1.1/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/bitflags-0.1.1/.travis.yml b/deps/bitflags-0.1.1/.travis.yml new file mode 100644 index 000000000..161a3fa81 --- /dev/null +++ b/deps/bitflags-0.1.1/.travis.yml @@ -0,0 +1,19 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: d+l63TtlF6cfFVDGauYRexgx4lBww4ORqqK4Vt75nWbiCbjZYsKXbcTUdhAr193nIVGiNW50A8SekM01F3EngHwHwr6u5kFleOggm+HA0kkBVeX+k2A4WCVVfYI+gth+zk99WaF8h46MA0evhx6FYDoqeyl9oqmVifI4kaqhMwc= +notifications: + email: + on_success: never diff --git a/deps/bitflags-0.1.1/Cargo.toml b/deps/bitflags-0.1.1/Cargo.toml new file mode 100644 index 000000000..ea7facd26 --- /dev/null +++ b/deps/bitflags-0.1.1/Cargo.toml @@ -0,0 +1,13 @@ +[package] + +name = "bitflags" +version = "0.1.1" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/bitflags" +homepage = "https://github.com/rust-lang/bitflags" +documentation = "http://doc.rust-lang.org/bitflags" +description = """ +A macro to generate structures which behave like bitflags. +""" diff --git a/deps/bitflags-0.1.1/LICENSE-APACHE b/deps/bitflags-0.1.1/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/bitflags-0.1.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/bitflags-0.1.1/LICENSE-MIT b/deps/bitflags-0.1.1/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/bitflags-0.1.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/bitflags-0.1.1/README.md b/deps/bitflags-0.1.1/README.md new file mode 100644 index 000000000..55bf09fef --- /dev/null +++ b/deps/bitflags-0.1.1/README.md @@ -0,0 +1,25 @@ +bitflags +======== + +A Rust macro to generate structures which behave like a set of bitflags + +[![Build Status](https://travis-ci.org/rust-lang/bitflags.svg?branch=master)](https://travis-ci.org/rust-lang/bitflags) + +[Documentation](http://doc.rust-lang.org/bitflags) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] + +bitflags = "0.1" +``` + +and this to your crate root: + +```rust +#[macro_use] +extern crate bitflags; +``` diff --git a/deps/bitflags-0.1.1/src/lib.rs b/deps/bitflags-0.1.1/src/lib.rs new file mode 100644 index 000000000..4b5a37ea9 --- /dev/null +++ b/deps/bitflags-0.1.1/src/lib.rs @@ -0,0 +1,481 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A typesafe bitmask flag generator. + +#![cfg_attr(test, feature(hash))] + +/// The `bitflags!` macro generates a `struct` that holds a set of C-style +/// bitmask flags. It is useful for creating typesafe wrappers for C APIs. +/// +/// The flags should only be defined for integer types, otherwise unexpected +/// type errors may occur at compile time. +/// +/// # Example +/// +/// ```{.rust} +/// #[macro_use] +/// extern crate bitflags; +/// +/// bitflags! { +/// flags Flags: u32 { +/// const FLAG_A = 0b00000001, +/// const FLAG_B = 0b00000010, +/// const FLAG_C = 0b00000100, +/// const FLAG_ABC = FLAG_A.bits +/// | FLAG_B.bits +/// | FLAG_C.bits, +/// } +/// } +/// +/// fn main() { +/// let e1 = FLAG_A | FLAG_C; +/// let e2 = FLAG_B | FLAG_C; +/// assert!((e1 | e2) == FLAG_ABC); // union +/// assert!((e1 & e2) == FLAG_C); // intersection +/// assert!((e1 - e2) == FLAG_A); // set difference +/// assert!(!e2 == FLAG_A); // set complement +/// } +/// ``` +/// +/// The generated `struct`s can also be extended with type and trait implementations: +/// +/// ```{.rust} +/// #[macro_use] +/// extern crate bitflags; +/// +/// use std::fmt; +/// +/// bitflags! { +/// flags Flags: u32 { +/// const FLAG_A = 0b00000001, +/// const FLAG_B = 0b00000010, +/// } +/// } +/// +/// impl Flags { +/// pub fn clear(&mut self) { +/// self.bits = 0; // The `bits` field can be accessed from within the +/// // same module where the `bitflags!` macro was invoked. +/// } +/// } +/// +/// impl fmt::Show for Flags { +/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// write!(f, "hi!") +/// } +/// } +/// +/// fn main() { +/// let mut flags = FLAG_A | FLAG_B; +/// flags.clear(); +/// assert!(flags.is_empty()); +/// assert_eq!(format!("{:?}", flags).as_slice(), "hi!"); +/// } +/// ``` +/// +/// # Attributes +/// +/// Attributes can be attached to the generated `struct` by placing them +/// before the `flags` keyword. +/// +/// # Derived traits +/// +/// The `PartialEq` and `Clone` traits are automatically derived for the `struct` using +/// the `deriving` attribute. Additional traits can be derived by providing an +/// explicit `deriving` attribute on `flags`. +/// +/// # Operators +/// +/// The following operator traits are implemented for the generated `struct`: +/// +/// - `BitOr`: union +/// - `BitAnd`: intersection +/// - `BitXor`: toggle +/// - `Sub`: set difference +/// - `Not`: set complement +/// +/// # Methods +/// +/// The following methods are defined for the generated `struct`: +/// +/// - `empty`: an empty set of flags +/// - `all`: the set of all flags +/// - `bits`: the raw value of the flags currently stored +/// - `from_bits`: convert from underlying bit representation, unless that +/// representation contains bits that do not correspond to a flag +/// - `from_bits_truncate`: convert from underlying bit representation, dropping +/// any bits that do not correspond to flags +/// - `is_empty`: `true` if no flags are currently stored +/// - `is_all`: `true` if all flags are currently set +/// - `intersects`: `true` if there are flags common to both `self` and `other` +/// - `contains`: `true` all of the flags in `other` are contained within `self` +/// - `insert`: inserts the specified flags in-place +/// - `remove`: removes the specified flags in-place +/// - `toggle`: the specified flags will be inserted if not present, and removed +/// if they are. +#[macro_export] +macro_rules! bitflags { + ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty { + $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+ + }) => { + #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] + $(#[$attr])* + pub struct $BitFlags { + bits: $T, + } + + $($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+ + + impl $BitFlags { + /// Returns an empty set of flags. + #[inline] + pub fn empty() -> $BitFlags { + $BitFlags { bits: 0 } + } + + /// Returns the set containing all flags. + #[inline] + pub fn all() -> $BitFlags { + $BitFlags { bits: $($value)|+ } + } + + /// Returns the raw value of the flags currently stored. + #[inline] + pub fn bits(&self) -> $T { + self.bits + } + + /// Convert from underlying bit representation, unless that + /// representation contains bits that do not correspond to a flag. + #[inline] + pub fn from_bits(bits: $T) -> ::std::option::Option<$BitFlags> { + if (bits & !$BitFlags::all().bits()) != 0 { + ::std::option::Option::None + } else { + ::std::option::Option::Some($BitFlags { bits: bits }) + } + } + + /// Convert from underlying bit representation, dropping any bits + /// that do not correspond to flags. + #[inline] + pub fn from_bits_truncate(bits: $T) -> $BitFlags { + $BitFlags { bits: bits } & $BitFlags::all() + } + + /// Returns `true` if no flags are currently stored. + #[inline] + pub fn is_empty(&self) -> bool { + *self == $BitFlags::empty() + } + + /// Returns `true` if all flags are currently set. + #[inline] + pub fn is_all(&self) -> bool { + *self == $BitFlags::all() + } + + /// Returns `true` if there are flags common to both `self` and `other`. + #[inline] + pub fn intersects(&self, other: $BitFlags) -> bool { + !(*self & other).is_empty() + } + + /// Returns `true` all of the flags in `other` are contained within `self`. + #[inline] + pub fn contains(&self, other: $BitFlags) -> bool { + (*self & other) == other + } + + /// Inserts the specified flags in-place. + #[inline] + pub fn insert(&mut self, other: $BitFlags) { + self.bits |= other.bits; + } + + /// Removes the specified flags in-place. + #[inline] + pub fn remove(&mut self, other: $BitFlags) { + self.bits &= !other.bits; + } + + /// Toggles the specified flags in-place. + #[inline] + pub fn toggle(&mut self, other: $BitFlags) { + self.bits ^= other.bits; + } + } + + impl ::std::ops::BitOr for $BitFlags { + type Output = $BitFlags; + + /// Returns the union of the two sets of flags. + #[inline] + fn bitor(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits | other.bits } + } + } + + impl ::std::ops::BitXor for $BitFlags { + type Output = $BitFlags; + + /// Returns the left flags, but with all the right flags toggled. + #[inline] + fn bitxor(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits ^ other.bits } + } + } + + impl ::std::ops::BitAnd for $BitFlags { + type Output = $BitFlags; + + /// Returns the intersection between the two sets of flags. + #[inline] + fn bitand(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits & other.bits } + } + } + + impl ::std::ops::Sub for $BitFlags { + type Output = $BitFlags; + + /// Returns the set difference of the two sets of flags. + #[inline] + fn sub(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits & !other.bits } + } + } + + impl ::std::ops::Not for $BitFlags { + type Output = $BitFlags; + + /// Returns the complement of this set of flags. + #[inline] + fn not(self) -> $BitFlags { + $BitFlags { bits: !self.bits } & $BitFlags::all() + } + } + }; + ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty { + $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+, + }) => { + bitflags! { + $(#[$attr])* + flags $BitFlags: $T { + $($(#[$Flag_attr])* const $Flag = $value),+ + } + } + }; +} + +#[cfg(test)] +#[allow(non_upper_case_globals)] +mod tests { + use std::prelude::v1::*; + use std::hash::{self, SipHasher}; + + bitflags! { + #[doc = "> The first principle is that you must not fool yourself — and"] + #[doc = "> you are the easiest person to fool."] + #[doc = "> "] + #[doc = "> - Richard Feynman"] + flags Flags: u32 { + const FlagA = 0b00000001, + #[doc = " macros are way better at generating code than trans is"] + const FlagB = 0b00000010, + const FlagC = 0b00000100, + #[doc = "* cmr bed"] + #[doc = "* strcat table"] + #[doc = " wait what?"] + const FlagABC = FlagA.bits + | FlagB.bits + | FlagC.bits, + } + } + + bitflags! { + flags AnotherSetOfFlags: i8 { + const AnotherFlag = -1_i8, + } + } + + #[test] + fn test_bits(){ + assert_eq!(Flags::empty().bits(), 0b00000000); + assert_eq!(FlagA.bits(), 0b00000001); + assert_eq!(FlagABC.bits(), 0b00000111); + + assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00); + assert_eq!(AnotherFlag.bits(), !0_i8); + } + + #[test] + fn test_from_bits() { + assert!(Flags::from_bits(0) == Some(Flags::empty())); + assert!(Flags::from_bits(0b1) == Some(FlagA)); + assert!(Flags::from_bits(0b10) == Some(FlagB)); + assert!(Flags::from_bits(0b11) == Some(FlagA | FlagB)); + assert!(Flags::from_bits(0b1000) == None); + + assert!(AnotherSetOfFlags::from_bits(!0_i8) == Some(AnotherFlag)); + } + + #[test] + fn test_from_bits_truncate() { + assert!(Flags::from_bits_truncate(0) == Flags::empty()); + assert!(Flags::from_bits_truncate(0b1) == FlagA); + assert!(Flags::from_bits_truncate(0b10) == FlagB); + assert!(Flags::from_bits_truncate(0b11) == (FlagA | FlagB)); + assert!(Flags::from_bits_truncate(0b1000) == Flags::empty()); + assert!(Flags::from_bits_truncate(0b1001) == FlagA); + + assert!(AnotherSetOfFlags::from_bits_truncate(0_i8) == AnotherSetOfFlags::empty()); + } + + #[test] + fn test_is_empty(){ + assert!(Flags::empty().is_empty()); + assert!(!FlagA.is_empty()); + assert!(!FlagABC.is_empty()); + + assert!(!AnotherFlag.is_empty()); + } + + #[test] + fn test_is_all() { + assert!(Flags::all().is_all()); + assert!(!FlagA.is_all()); + assert!(FlagABC.is_all()); + + assert!(AnotherFlag.is_all()); + } + + #[test] + fn test_two_empties_do_not_intersect() { + let e1 = Flags::empty(); + let e2 = Flags::empty(); + assert!(!e1.intersects(e2)); + + assert!(AnotherFlag.intersects(AnotherFlag)); + } + + #[test] + fn test_empty_does_not_intersect_with_full() { + let e1 = Flags::empty(); + let e2 = FlagABC; + assert!(!e1.intersects(e2)); + } + + #[test] + fn test_disjoint_intersects() { + let e1 = FlagA; + let e2 = FlagB; + assert!(!e1.intersects(e2)); + } + + #[test] + fn test_overlapping_intersects() { + let e1 = FlagA; + let e2 = FlagA | FlagB; + assert!(e1.intersects(e2)); + } + + #[test] + fn test_contains() { + let e1 = FlagA; + let e2 = FlagA | FlagB; + assert!(!e1.contains(e2)); + assert!(e2.contains(e1)); + assert!(FlagABC.contains(e2)); + + assert!(AnotherFlag.contains(AnotherFlag)); + } + + #[test] + fn test_insert(){ + let mut e1 = FlagA; + let e2 = FlagA | FlagB; + e1.insert(e2); + assert!(e1 == e2); + + let mut e3 = AnotherSetOfFlags::empty(); + e3.insert(AnotherFlag); + assert!(e3 == AnotherFlag); + } + + #[test] + fn test_remove(){ + let mut e1 = FlagA | FlagB; + let e2 = FlagA | FlagC; + e1.remove(e2); + assert!(e1 == FlagB); + + let mut e3 = AnotherFlag; + e3.remove(AnotherFlag); + assert!(e3 == AnotherSetOfFlags::empty()); + } + + #[test] + fn test_operators() { + let e1 = FlagA | FlagC; + let e2 = FlagB | FlagC; + assert!((e1 | e2) == FlagABC); // union + assert!((e1 & e2) == FlagC); // intersection + assert!((e1 - e2) == FlagA); // set difference + assert!(!e2 == FlagA); // set complement + assert!(e1 ^ e2 == FlagA | FlagB); // toggle + let mut e3 = e1; + e3.toggle(e2); + assert!(e3 == FlagA | FlagB); + + let mut m4 = AnotherSetOfFlags::empty(); + m4.toggle(AnotherSetOfFlags::empty()); + assert!(m4 == AnotherSetOfFlags::empty()); + } + + #[test] + fn test_lt() { + let mut a = Flags::empty(); + let mut b = Flags::empty(); + + assert!(!(a < b) && !(b < a)); + b = FlagB; + assert!(a < b); + a = FlagC; + assert!(!(a < b) && b < a); + b = FlagC | FlagB; + assert!(a < b); + } + + #[test] + fn test_ord() { + let mut a = Flags::empty(); + let mut b = Flags::empty(); + + assert!(a <= b && a >= b); + a = FlagA; + assert!(a > b && a >= b); + assert!(b < a && b <= a); + b = FlagB; + assert!(b > a && b >= a); + assert!(a < b && a <= b); + } + + #[test] + fn test_hash() { + let mut x = Flags::empty(); + let mut y = Flags::empty(); + assert!(hash::hash::(&x) == hash::hash::(&y)); + x = Flags::all(); + y = FlagABC; + assert!(hash::hash::(&x) == hash::hash::(&y)); + } +} diff --git a/deps/curl-0.2.10/.gitignore b/deps/curl-0.2.10/.gitignore new file mode 100644 index 000000000..1e7caa9ea --- /dev/null +++ b/deps/curl-0.2.10/.gitignore @@ -0,0 +1,2 @@ +Cargo.lock +target/ diff --git a/deps/curl-0.2.10/.gitmodules b/deps/curl-0.2.10/.gitmodules new file mode 100644 index 000000000..7196785dd --- /dev/null +++ b/deps/curl-0.2.10/.gitmodules @@ -0,0 +1,3 @@ +[submodule "curl-sys/curl"] + path = curl-sys/curl + url = https://github.com/alexcrichton/curl diff --git a/deps/curl-0.2.10/Cargo.toml b/deps/curl-0.2.10/Cargo.toml new file mode 100644 index 000000000..16b72c3fb --- /dev/null +++ b/deps/curl-0.2.10/Cargo.toml @@ -0,0 +1,42 @@ +[package] + +name = "curl" +version = "0.2.10" +authors = ["Carl Lerche "] +license = "MIT" +repository = "https://github.com/carllerche/curl-rust" +description = "Rust bindings to libcurl for making HTTP requests" + +[dependencies] +url = "0.2.0" +log = "0.3.0" +libc = "0.1" +curl-sys = { path = "curl-sys", version = "0.1.0" } + +[dev-dependencies] +env_logger = "0.3.0" + +# Unix platforms use OpenSSL for now to provide SSL functionality +[target.i686-apple-darwin.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-apple-darwin.dependencies] +openssl-sys = "0.6.0" +[target.i686-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +[target.arm-unknown-linux-gnueabihf.dependencies] +openssl-sys = "0.6.0" +[target.aarch64-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +[target.i686-unknown-freebsd.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-freebsd.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-bitrig.dependencies] +openssl-sys = "0.6.0" + +[[test]] + +name = "test" +path = "test/test.rs" diff --git a/deps/curl-0.2.10/LICENSE b/deps/curl-0.2.10/LICENSE new file mode 100644 index 000000000..5f5e4b09d --- /dev/null +++ b/deps/curl-0.2.10/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Carl Lerche + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/curl-0.2.10/README.md b/deps/curl-0.2.10/README.md new file mode 100644 index 000000000..0e771f5f7 --- /dev/null +++ b/deps/curl-0.2.10/README.md @@ -0,0 +1,63 @@ +# Curl-Rust + +libcurl bindings for Rust. **This project is in active development and +could (will probably) break API compatibility at any time**. + +## Quick Start + +```rust +extern crate curl; + +use curl::http; + +pub fn main() { + let resp = http::handle() + .get("http://www.example.com") + .exec().unwrap(); + + println!("code={}; headers={:?}; body={:?}", + resp.get_code(), resp.get_headers(), resp.get_body()); +} +``` + +Response header names are automatically lower cased. + +## Post / Put requests + +Both of these methods expect that a request body is provided. A request +body can be a `&[u8]`, `&str`, or `&Reader`. For example: + +```rust +let resp = http::handle() + .post("http://www.example.com/upload", "this is the body") + .exec().unwrap(); +``` + +## Custom headers + +Custom headers can be specified as part of the request: + +```rust +http::handle() + .get("http://www.example.com") + .header("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==") + .exec(); +``` + +## Keep alive + +The handle can be re-used across multiple requests. Curl will attempt to +keep the connections alive. + +```rust +let handle = http::handle(); + +let resp1 = handle.get("http://www.example.com/foo").exec().unwrap(); +let resp2 = handle.get("http://www.example.com/bar").exec().unwrap(); +``` + +## Version Support + +The bindings have been developed using curl version 7.24.0. They should +work with any newer version of curl and possibly with older versions, +but this has not been tested. diff --git a/deps/curl-0.2.10/src/ffi/consts.rs b/deps/curl-0.2.10/src/ffi/consts.rs new file mode 100644 index 000000000..339ffa08b --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/consts.rs @@ -0,0 +1 @@ +pub use curl_ffi::CURL_READFUNC_ABORT; diff --git a/deps/curl-0.2.10/src/ffi/easy.rs b/deps/curl-0.2.10/src/ffi/easy.rs new file mode 100644 index 000000000..5a9a3609b --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/easy.rs @@ -0,0 +1,241 @@ +#![allow(dead_code)] + +use std::sync::{Once, ONCE_INIT}; +use std::mem; +use std::collections::HashMap; +use std::slice; +use libc::{self, c_int, c_long, c_double, size_t}; +use super::{consts, err, info, opt}; +use super::err::ErrCode; +use http::body::Body; +use http::{header, Response}; + +use curl_ffi as ffi; + +pub type ProgressCb<'a> = FnMut(usize, usize, usize, usize) + 'a; + +pub struct Easy { + curl: *mut ffi::CURL +} + +impl Easy { + pub fn new() -> Easy { + // Ensure that curl is globally initialized + global_init(); + + let handle = unsafe { + let p = ffi::curl_easy_init(); + ffi::curl_easy_setopt(p, opt::NOPROGRESS, 0); + p + }; + + Easy { curl: handle } + } + + #[inline] + pub fn setopt(&mut self, option: opt::Opt, val: T) -> Result<(), err::ErrCode> { + // TODO: Prevent setting callback related options + let mut res = err::ErrCode(err::OK); + + unsafe { + val.with_c_repr(|repr| { + res = err::ErrCode(ffi::curl_easy_setopt(self.curl, option, repr)); + }) + } + + if res.is_success() { Ok(()) } else { Err(res) } + } + + pub fn perform(&mut self, + body: Option<&mut Body>, + progress: Option>) + -> Result { + let mut builder = ResponseBuilder::new(); + + unsafe { + let resp_p: usize = mem::transmute(&builder); + let body_p: usize = match body { + Some(b) => mem::transmute(b), + None => 0 + }; + + let progress_p: usize = match progress.as_ref() { + Some(cb) => mem::transmute(cb), + None => 0 + }; + + // Set callback options + ffi::curl_easy_setopt(self.curl, opt::READFUNCTION, curl_read_fn); + ffi::curl_easy_setopt(self.curl, opt::READDATA, body_p); + + ffi::curl_easy_setopt(self.curl, opt::WRITEFUNCTION, curl_write_fn); + ffi::curl_easy_setopt(self.curl, opt::WRITEDATA, resp_p); + + ffi::curl_easy_setopt(self.curl, opt::HEADERFUNCTION, curl_header_fn); + ffi::curl_easy_setopt(self.curl, opt::HEADERDATA, resp_p); + + ffi::curl_easy_setopt(self.curl, opt::PROGRESSFUNCTION, curl_progress_fn); + ffi::curl_easy_setopt(self.curl, opt::PROGRESSDATA, progress_p); + } + + let err = err::ErrCode(unsafe { ffi::curl_easy_perform(self.curl) }); + + // If the request failed, abort here + if !err.is_success() { + return Err(err); + } + + // Try to get the response code + builder.code = try!(self.get_response_code()); + + Ok(builder.build()) + } + + pub fn get_response_code(&self) -> Result { + Ok(try!(self.get_info_long(info::RESPONSE_CODE)) as u32) + } + + pub fn get_total_time(&self) -> Result { + Ok(try!(self.get_info_long(info::TOTAL_TIME)) as usize) + } + + fn get_info_long(&self, key: info::Key) -> Result { + let v: c_long = 0; + let res = err::ErrCode(unsafe { + ffi::curl_easy_getinfo(self.curl as *const _, key, &v) + }); + + if !res.is_success() { + return Err(res); + } + + Ok(v) + } +} + +#[inline] +fn global_init() { + // Schedule curl to be cleaned up after we're done with this whole process + static INIT: Once = ONCE_INIT; + INIT.call_once(|| unsafe { + assert_eq!(libc::atexit(cleanup), 0); + }); + + extern fn cleanup() { + unsafe { ffi::curl_global_cleanup() } + } +} + +impl Drop for Easy { + fn drop(&mut self) { + unsafe { ffi::curl_easy_cleanup(self.curl) } + } +} + +/* + * + * TODO: Move this into handle + * + */ + +struct ResponseBuilder { + code: u32, + hdrs: HashMap>, + body: Vec +} + +impl ResponseBuilder { + fn new() -> ResponseBuilder { + ResponseBuilder { + code: 0, + hdrs: HashMap::new(), + body: Vec::new() + } + } + + fn add_header(&mut self, name: &str, val: &str) { + // TODO: Reduce allocations + use std::ascii::AsciiExt; + let name = name.to_ascii_lowercase(); + + let inserted = match self.hdrs.get_mut(&name) { + Some(vals) => { + vals.push(val.to_string()); + true + } + None => false + }; + + if !inserted { + self.hdrs.insert(name, vec!(val.to_string())); + } + } + + fn build(self) -> Response { + let ResponseBuilder { code, hdrs, body } = self; + Response::new(code, hdrs, body) + } +} + +/* + * + * ===== Callbacks ===== + */ + +extern fn curl_read_fn(p: *mut u8, size: size_t, nmemb: size_t, + body: *mut Body) -> size_t { + if body.is_null() { + return 0; + } + + let dst = unsafe { slice::from_raw_parts_mut(p, (size * nmemb) as usize) }; + let body = unsafe { &mut *body }; + + match body.read(dst) { + Ok(len) => len as size_t, + Err(_) => consts::CURL_READFUNC_ABORT as size_t, + } +} + +extern fn curl_write_fn(p: *mut u8, size: size_t, nmemb: size_t, + resp: *mut ResponseBuilder) -> size_t { + if !resp.is_null() { + let builder: &mut ResponseBuilder = unsafe { mem::transmute(resp) }; + let chunk = unsafe { slice::from_raw_parts(p as *const u8, + (size * nmemb) as usize) }; + builder.body.extend(chunk.iter().map(|x| *x)); + } + + size * nmemb +} + +extern fn curl_header_fn(p: *mut u8, size: size_t, nmemb: size_t, + resp: &mut ResponseBuilder) -> size_t { + // TODO: Skip the first call (it seems to be the status line) + + let vec = unsafe { slice::from_raw_parts(p as *const u8, + (size * nmemb) as usize) }; + + match header::parse(&vec) { + Some((name, val)) => { + resp.add_header(name, val); + } + None => {} + } + + vec.len() as size_t +} + +pub extern "C" fn curl_progress_fn(cb: *mut Box, dltotal: c_double, dlnow: c_double, ultotal: c_double, ulnow: c_double) -> c_int { + #[inline] + fn to_usize(v: c_double) -> usize { + if v > 0.0 { v as usize } else { 0 } + } + + if !cb.is_null() { + let cb: &mut ProgressCb = unsafe { &mut **cb }; + (*cb)(to_usize(dltotal), to_usize(dlnow), to_usize(ultotal), to_usize(ulnow)); + } + + 0 +} diff --git a/deps/curl-0.2.10/src/ffi/err.rs b/deps/curl-0.2.10/src/ffi/err.rs new file mode 100644 index 000000000..6b4418720 --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/err.rs @@ -0,0 +1,138 @@ +use std::ffi::CStr; +use std::error; +use std::fmt; +use std::str; + +use curl_ffi as ffi; + +pub use curl_ffi::CURLcode::CURLE_OK as OK; +pub use curl_ffi::CURLcode::CURLE_UNSUPPORTED_PROTOCOL as UNSUPPORTED_PROTOCOL; +pub use curl_ffi::CURLcode::CURLE_FAILED_INIT as FAILED_INIT; +pub use curl_ffi::CURLcode::CURLE_URL_MALFORMAT as URL_MALFORMAT; +pub use curl_ffi::CURLcode::CURLE_NOT_BUILT_IN as NOT_BUILT_IN; +pub use curl_ffi::CURLcode::CURLE_COULDNT_RESOLVE_PROXY as COULDNT_RESOLVE_PROXY; +pub use curl_ffi::CURLcode::CURLE_COULDNT_RESOLVE_HOST as COULDNT_RESOLVE_HOST; +pub use curl_ffi::CURLcode::CURLE_COULDNT_CONNECT as COULDNT_CONNECT; +pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_SERVER_REPLY as FTP_WEIRD_SERVER_REPLY; +pub use curl_ffi::CURLcode::CURLE_REMOTE_ACCESS_DENIED as REMOTE_ACCESS_DENIED; +pub use curl_ffi::CURLcode::CURLE_FTP_ACCEPT_FAILED as FTP_ACCEPT_FAILED; +pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_PASS_REPLY as FTP_WEIRD_PASS_REPLY; +pub use curl_ffi::CURLcode::CURLE_FTP_ACCEPT_TIMEOUT as FTP_ACCEPT_TIMEOUT; +pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_PASV_REPLY as FTP_WEIRD_PASV_REPLY; +pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_227_FORMAT as FTP_WEIRD_227_FORMAT; +pub use curl_ffi::CURLcode::CURLE_FTP_CANT_GET_HOST as FTP_CANT_GET_HOST; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE16 as OBSOLETE16; +pub use curl_ffi::CURLcode::CURLE_FTP_COULDNT_SET_TYPE as FTP_COULDNT_SET_TYPE; +pub use curl_ffi::CURLcode::CURLE_PARTIAL_FILE as PARTIAL_FILE; +pub use curl_ffi::CURLcode::CURLE_FTP_COULDNT_RETR_FILE as FTP_COULDNT_RETR_FILE; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE20 as OBSOLETE20; +pub use curl_ffi::CURLcode::CURLE_QUOTE_ERROR as QUOTE_ERROR; +pub use curl_ffi::CURLcode::CURLE_HTTP_RETURNED_ERROR as HTTP_RETURNED_ERROR; +pub use curl_ffi::CURLcode::CURLE_WRITE_ERROR as WRITE_ERROR; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE24 as OBSOLETE24; +pub use curl_ffi::CURLcode::CURLE_UPLOAD_FAILED as UPLOAD_FAILED; +pub use curl_ffi::CURLcode::CURLE_READ_ERROR as READ_ERROR; +pub use curl_ffi::CURLcode::CURLE_OUT_OF_MEMORY as OUT_OF_MEMORY; +pub use curl_ffi::CURLcode::CURLE_OPERATION_TIMEDOUT as OPERATION_TIMEDOUT; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE29 as OBSOLETE29; +pub use curl_ffi::CURLcode::CURLE_FTP_PORT_FAILED as FTP_PORT_FAILED; +pub use curl_ffi::CURLcode::CURLE_FTP_COULDNT_USE_REST as FTP_COULDNT_USE_REST; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE32 as OBSOLETE32; +pub use curl_ffi::CURLcode::CURLE_RANGE_ERROR as RANGE_ERROR; +pub use curl_ffi::CURLcode::CURLE_HTTP_POST_ERROR as HTTP_POST_ERROR; +pub use curl_ffi::CURLcode::CURLE_SSL_CONNECT_ERROR as SSL_CONNECT_ERROR; +pub use curl_ffi::CURLcode::CURLE_BAD_DOWNLOAD_RESUME as BAD_DOWNLOAD_RESUME; +pub use curl_ffi::CURLcode::CURLE_FILE_COULDNT_READ_FILE as FILE_COULDNT_READ_FILE; +pub use curl_ffi::CURLcode::CURLE_LDAP_CANNOT_BIND as LDAP_CANNOT_BIND; +pub use curl_ffi::CURLcode::CURLE_LDAP_SEARCH_FAILED as LDAP_SEARCH_FAILED; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE40 as OBSOLETE40; +pub use curl_ffi::CURLcode::CURLE_FUNCTION_NOT_FOUND as FUNCTION_NOT_FOUND; +pub use curl_ffi::CURLcode::CURLE_ABORTED_BY_CALLBACK as ABORTED_BY_CALLBACK; +pub use curl_ffi::CURLcode::CURLE_BAD_FUNCTION_ARGUMENT as BAD_FUNCTION_ARGUMENT; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE44 as OBSOLETE44; +pub use curl_ffi::CURLcode::CURLE_INTERFACE_FAILED as INTERFACE_FAILED; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE46 as OBSOLETE46; +pub use curl_ffi::CURLcode::CURLE_TOO_MANY_REDIRECTS as TOO_MANY_REDIRECTS ; +pub use curl_ffi::CURLcode::CURLE_UNKNOWN_OPTION as UNKNOWN_OPTION; +pub use curl_ffi::CURLcode::CURLE_TELNET_OPTION_SYNTAX as TELNET_OPTION_SYNTAX ; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE50 as OBSOLETE50; +pub use curl_ffi::CURLcode::CURLE_PEER_FAILED_VERIFICATION as PEER_FAILED_VERIFICATION; +pub use curl_ffi::CURLcode::CURLE_GOT_NOTHING as GOT_NOTHING; +pub use curl_ffi::CURLcode::CURLE_SSL_ENGINE_NOTFOUND as SSL_ENGINE_NOTFOUND; +pub use curl_ffi::CURLcode::CURLE_SSL_ENGINE_SETFAILED as SSL_ENGINE_SETFAILED; +pub use curl_ffi::CURLcode::CURLE_SEND_ERROR as SEND_ERROR; +pub use curl_ffi::CURLcode::CURLE_RECV_ERROR as RECV_ERROR; +pub use curl_ffi::CURLcode::CURLE_OBSOLETE57 as OBSOLETE57; +pub use curl_ffi::CURLcode::CURLE_SSL_CERTPROBLEM as SSL_CERTPROBLEM; +pub use curl_ffi::CURLcode::CURLE_SSL_CIPHER as SSL_CIPHER; +pub use curl_ffi::CURLcode::CURLE_SSL_CACERT as SSL_CACERT; +pub use curl_ffi::CURLcode::CURLE_BAD_CONTENT_ENCODING as BAD_CONTENT_ENCODING; +pub use curl_ffi::CURLcode::CURLE_LDAP_INVALID_URL as LDAP_INVALID_URL; +pub use curl_ffi::CURLcode::CURLE_FILESIZE_EXCEEDED as FILESIZE_EXCEEDED; +pub use curl_ffi::CURLcode::CURLE_USE_SSL_FAILED as USE_SSL_FAILED; +pub use curl_ffi::CURLcode::CURLE_SEND_FAIL_REWIND as SEND_FAIL_REWIND; +pub use curl_ffi::CURLcode::CURLE_SSL_ENGINE_INITFAILED as SSL_ENGINE_INITFAILED; +pub use curl_ffi::CURLcode::CURLE_LOGIN_DENIED as LOGIN_DENIED; +pub use curl_ffi::CURLcode::CURLE_TFTP_NOTFOUND as TFTP_NOTFOUND; +pub use curl_ffi::CURLcode::CURLE_TFTP_PERM as TFTP_PERM; +pub use curl_ffi::CURLcode::CURLE_REMOTE_DISK_FULL as REMOTE_DISK_FULL; +pub use curl_ffi::CURLcode::CURLE_TFTP_ILLEGAL as TFTP_ILLEGAL; +pub use curl_ffi::CURLcode::CURLE_TFTP_UNKNOWNID as TFTP_UNKNOWNID; +pub use curl_ffi::CURLcode::CURLE_REMOTE_FILE_EXISTS as REMOTE_FILE_EXISTS; +pub use curl_ffi::CURLcode::CURLE_TFTP_NOSUCHUSER as TFTP_NOSUCHUSER; +pub use curl_ffi::CURLcode::CURLE_CONV_FAILED as CONV_FAILED; +pub use curl_ffi::CURLcode::CURLE_CONV_REQD as CONV_REQD; +pub use curl_ffi::CURLcode::CURLE_SSL_CACERT_BADFILE as SSL_CACERT_BADFILE; +pub use curl_ffi::CURLcode::CURLE_REMOTE_FILE_NOT_FOUND as REMOTE_FILE_NOT_FOUND; +pub use curl_ffi::CURLcode::CURLE_SSH as SSH; +pub use curl_ffi::CURLcode::CURLE_SSL_SHUTDOWN_FAILED as SSL_SHUTDOWN_FAILED; +pub use curl_ffi::CURLcode::CURLE_AGAIN as AGAIN; +pub use curl_ffi::CURLcode::CURLE_SSL_CRL_BADFILE as SSL_CRL_BADFILE; +pub use curl_ffi::CURLcode::CURLE_SSL_ISSUER_ERROR as SSL_ISSUER_ERROR; +pub use curl_ffi::CURLcode::CURLE_FTP_PRET_FAILED as FTP_PRET_FAILED; +pub use curl_ffi::CURLcode::CURLE_RTSP_CSEQ_ERROR as RTSP_CSEQ_ERROR; +pub use curl_ffi::CURLcode::CURLE_RTSP_SESSION_ERROR as RTSP_SESSION_ERROR; +pub use curl_ffi::CURLcode::CURLE_FTP_BAD_FILE_LIST as FTP_BAD_FILE_LIST; +pub use curl_ffi::CURLcode::CURLE_CHUNK_FAILED as CHUNK_FAILED; +pub use curl_ffi::CURLcode::CURLE_NO_CONNECTION_AVAILABLE as NO_CONNECTION_AVAILABLE; +pub use curl_ffi::CURLcode::CURLE_LAST as LAST; + +#[derive(Copy, Clone)] +pub struct ErrCode(pub ffi::CURLcode); + +impl ErrCode { + pub fn is_success(self) -> bool { + self.code() as i32 == OK as i32 + } + + pub fn code(self) -> ffi::CURLcode { let ErrCode(c) = self; c } +} + +impl fmt::Debug for ErrCode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +impl fmt::Display for ErrCode { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let s = unsafe { + CStr::from_ptr(ffi::curl_easy_strerror(self.code())).to_bytes() + }; + + match str::from_utf8(s) { + Ok(s) => write!(fmt, "{}", s), + Err(err) => write!(fmt, "{}", err) + } + } +} + +impl error::Error for ErrCode { + fn description(&self) -> &str { + let code = self.code(); + let s = unsafe { + CStr::from_ptr(ffi::curl_easy_strerror(code) as *const _).to_bytes() + }; + str::from_utf8(s).unwrap() + } +} diff --git a/deps/curl-0.2.10/src/ffi/info.rs b/deps/curl-0.2.10/src/ffi/info.rs new file mode 100644 index 000000000..a1c509d21 --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/info.rs @@ -0,0 +1,9 @@ +#![allow(dead_code)] + +use curl_ffi as ffi; + +pub use curl_ffi::CURLINFO_EFFECTIVE_URL as EFFECTIVE_URL; +pub use curl_ffi::CURLINFO_RESPONSE_CODE as RESPONSE_CODE; +pub use curl_ffi::CURLINFO_TOTAL_TIME as TOTAL_TIME; + +pub type Key = ffi::CURLINFO; diff --git a/deps/curl-0.2.10/src/ffi/list.rs b/deps/curl-0.2.10/src/ffi/list.rs new file mode 100644 index 000000000..c8afe0568 --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/list.rs @@ -0,0 +1,49 @@ +#![allow(dead_code)] + +use std::ptr; +use libc::c_void; +use super::opt::OptVal; + +use curl_ffi as ffi; + +pub struct List { + len: usize, + head: *mut ffi::curl_slist, +} + +impl List { + pub fn new() -> List { + List { + len: 0, + head: ptr::null_mut() + } + } + + pub fn push_bytes(&mut self, val: &[u8]) { + assert!(val[val.len() - 1] == 0); + self.len += 1; + self.head = unsafe { ffi::curl_slist_append(self.head, val.as_ptr()) }; + } + + pub fn len(&self) -> usize { + self.len + } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } +} + +impl Drop for List { + fn drop(&mut self) { + if !self.is_empty() { + unsafe { ffi::curl_slist_free_all(self.head) } + } + } +} + +impl<'a> OptVal for &'a List { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + f(self.head as *const c_void) + } +} diff --git a/deps/curl-0.2.10/src/ffi/mod.rs b/deps/curl-0.2.10/src/ffi/mod.rs new file mode 100644 index 000000000..cb01dc2a0 --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/mod.rs @@ -0,0 +1,10 @@ +pub use self::list::List; +pub use self::version::version; + +pub mod consts; +pub mod easy; +pub mod err; +pub mod info; +pub mod list; +pub mod opt; +pub mod version; diff --git a/deps/curl-0.2.10/src/ffi/opt.rs b/deps/curl-0.2.10/src/ffi/opt.rs new file mode 100644 index 000000000..ad9a42733 --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/opt.rs @@ -0,0 +1,283 @@ +#![allow(dead_code)] + +use std::ffi::CString; +use std::path::Path; +use libc::{c_void}; + +use curl_ffi as ffi; + +pub use curl_ffi::CURLOPT_FILE as FILE; +pub use curl_ffi::CURLOPT_URL as URL; +pub use curl_ffi::CURLOPT_PORT as PORT; +pub use curl_ffi::CURLOPT_PROXY as PROXY; +pub use curl_ffi::CURLOPT_USERPWD as USERPWD; +pub use curl_ffi::CURLOPT_PROXYUSERPWD as PROXYUSERPWD; +pub use curl_ffi::CURLOPT_RANGE as RANGE; +pub use curl_ffi::CURLOPT_INFILE as INFILE; +pub use curl_ffi::CURLOPT_ERRORBUFFER as ERRORBUFFER; +pub use curl_ffi::CURLOPT_WRITEFUNCTION as WRITEFUNCTION; +pub use curl_ffi::CURLOPT_READFUNCTION as READFUNCTION; +pub use curl_ffi::CURLOPT_TIMEOUT as TIMEOUT; +pub use curl_ffi::CURLOPT_INFILESIZE as INFILESIZE; +pub use curl_ffi::CURLOPT_POSTFIELDS as POSTFIELDS; +pub use curl_ffi::CURLOPT_REFERER as REFERER; +pub use curl_ffi::CURLOPT_FTPPORT as FTPPORT; +pub use curl_ffi::CURLOPT_USERAGENT as USERAGENT; +pub use curl_ffi::CURLOPT_LOW_SPEED_LIMIT as LOW_SPEED_LIMIT; +pub use curl_ffi::CURLOPT_LOW_SPEED_TIME as LOW_SPEED_TIME; +pub use curl_ffi::CURLOPT_RESUME_FROM as RESUME_FROM; +pub use curl_ffi::CURLOPT_COOKIE as COOKIE; +pub use curl_ffi::CURLOPT_HTTPHEADER as HTTPHEADER; +pub use curl_ffi::CURLOPT_HTTPPOST as HTTPPOST; +pub use curl_ffi::CURLOPT_SSLCERT as SSLCERT; +pub use curl_ffi::CURLOPT_KEYPASSWD as KEYPASSWD; +pub use curl_ffi::CURLOPT_CRLF as CRLF; +pub use curl_ffi::CURLOPT_QUOTE as QUOTE; +pub use curl_ffi::CURLOPT_WRITEHEADER as WRITEHEADER; +pub use curl_ffi::CURLOPT_COOKIEFILE as COOKIEFILE; +pub use curl_ffi::CURLOPT_SSLVERSION as SSLVERSION; +pub use curl_ffi::CURLOPT_TIMECONDITION as TIMECONDITION; +pub use curl_ffi::CURLOPT_TIMEVALUE as TIMEVALUE; +pub use curl_ffi::CURLOPT_CUSTOMREQUEST as CUSTOMREQUEST; +pub use curl_ffi::CURLOPT_STDERR as STDERR; +pub use curl_ffi::CURLOPT_POSTQUOTE as POSTQUOTE; +pub use curl_ffi::CURLOPT_WRITEINFO as WRITEINFO; +pub use curl_ffi::CURLOPT_VERBOSE as VERBOSE; +pub use curl_ffi::CURLOPT_HEADER as HEADER; +pub use curl_ffi::CURLOPT_NOPROGRESS as NOPROGRESS; +pub use curl_ffi::CURLOPT_NOBODY as NOBODY; +pub use curl_ffi::CURLOPT_FAILONERROR as FAILONERROR; +pub use curl_ffi::CURLOPT_UPLOAD as UPLOAD; +pub use curl_ffi::CURLOPT_POST as POST; +pub use curl_ffi::CURLOPT_DIRLISTONLY as DIRLISTONLY; +pub use curl_ffi::CURLOPT_APPEND as APPEND; +pub use curl_ffi::CURLOPT_NETRC as NETRC; +pub use curl_ffi::CURLOPT_FOLLOWLOCATION as FOLLOWLOCATION; +pub use curl_ffi::CURLOPT_TRANSFERTEXT as TRANSFERTEXT; +pub use curl_ffi::CURLOPT_PUT as PUT; +pub use curl_ffi::CURLOPT_PROGRESSFUNCTION as PROGRESSFUNCTION; +pub use curl_ffi::CURLOPT_PROGRESSDATA as PROGRESSDATA; +pub use curl_ffi::CURLOPT_AUTOREFERER as AUTOREFERER; +pub use curl_ffi::CURLOPT_PROXYPORT as PROXYPORT; +pub use curl_ffi::CURLOPT_POSTFIELDSIZE as POSTFIELDSIZE; +pub use curl_ffi::CURLOPT_HTTPPROXYTUNNEL as HTTPPROXYTUNNEL; +pub use curl_ffi::CURLOPT_INTERFACE as INTERFACE; +pub use curl_ffi::CURLOPT_KRBLEVEL as KRBLEVEL; +pub use curl_ffi::CURLOPT_SSL_VERIFYPEER as SSL_VERIFYPEER; +pub use curl_ffi::CURLOPT_CAINFO as CAINFO; +pub use curl_ffi::CURLOPT_MAXREDIRS as MAXREDIRS; +pub use curl_ffi::CURLOPT_FILETIME as FILETIME; +pub use curl_ffi::CURLOPT_TELNETOPTIONS as TELNETOPTIONS; +pub use curl_ffi::CURLOPT_MAXCONNECTS as MAXCONNECTS; +pub use curl_ffi::CURLOPT_CLOSEPOLICY as CLOSEPOLICY; +pub use curl_ffi::CURLOPT_FRESH_CONNECT as FRESH_CONNECT; +pub use curl_ffi::CURLOPT_FORBID_REUSE as FORBID_REUSE; +pub use curl_ffi::CURLOPT_RANDOM_FILE as RANDOM_FILE; +pub use curl_ffi::CURLOPT_EGDSOCKET as EGDSOCKET; +pub use curl_ffi::CURLOPT_CONNECTTIMEOUT as CONNECTTIMEOUT; +pub use curl_ffi::CURLOPT_HEADERFUNCTION as HEADERFUNCTION; +pub use curl_ffi::CURLOPT_HTTPGET as HTTPGET; +pub use curl_ffi::CURLOPT_SSL_VERIFYHOST as SSL_VERIFYHOST; +pub use curl_ffi::CURLOPT_COOKIEJAR as COOKIEJAR; +pub use curl_ffi::CURLOPT_SSL_CIPHER_LIST as SSL_CIPHER_LIST; +pub use curl_ffi::CURLOPT_HTTP_VERSION as HTTP_VERSION; +pub use curl_ffi::CURLOPT_FTP_USE_EPSV as FTP_USE_EPSV; +pub use curl_ffi::CURLOPT_SSLCERTTYPE as SSLCERTTYPE; +pub use curl_ffi::CURLOPT_SSLKEY as SSLKEY; +pub use curl_ffi::CURLOPT_SSLKEYTYPE as SSLKEYTYPE; +pub use curl_ffi::CURLOPT_SSLENGINE as SSLENGINE; +pub use curl_ffi::CURLOPT_SSLENGINE_DEFAULT as SSLENGINE_DEFAULT; +pub use curl_ffi::CURLOPT_DNS_USE_GLOBAL_CACHE as DNS_USE_GLOBAL_CACHE; +pub use curl_ffi::CURLOPT_DNS_CACHE_TIMEOUT as DNS_CACHE_TIMEOUT; +pub use curl_ffi::CURLOPT_PREQUOTE as PREQUOTE; +pub use curl_ffi::CURLOPT_DEBUGFUNCTION as DEBUGFUNCTION; +pub use curl_ffi::CURLOPT_DEBUGDATA as DEBUGDATA; +pub use curl_ffi::CURLOPT_COOKIESESSION as COOKIESESSION; +pub use curl_ffi::CURLOPT_CAPATH as CAPATH; +pub use curl_ffi::CURLOPT_BUFFERSIZE as BUFFERSIZE; +pub use curl_ffi::CURLOPT_NOSIGNAL as NOSIGNAL; +pub use curl_ffi::CURLOPT_SHARE as SHARE; +pub use curl_ffi::CURLOPT_PROXYTYPE as PROXYTYPE; +pub use curl_ffi::CURLOPT_ACCEPT_ENCODING as ACCEPT_ENCODING; +pub use curl_ffi::CURLOPT_PRIVATE as PRIVATE; +pub use curl_ffi::CURLOPT_HTTP200ALIASES as HTTP200ALIASES; +pub use curl_ffi::CURLOPT_UNRESTRICTED_AUTH as UNRESTRICTED_AUTH; +pub use curl_ffi::CURLOPT_FTP_USE_EPRT as FTP_USE_EPRT; +pub use curl_ffi::CURLOPT_HTTPAUTH as HTTPAUTH; +pub use curl_ffi::CURLOPT_SSL_CTX_FUNCTION as SSL_CTX_FUNCTION; +pub use curl_ffi::CURLOPT_SSL_CTX_DATA as SSL_CTX_DATA; +pub use curl_ffi::CURLOPT_FTP_CREATE_MISSING_DIRS as FTP_CREATE_MISSING_DIRS; +pub use curl_ffi::CURLOPT_PROXYAUTH as PROXYAUTH; +pub use curl_ffi::CURLOPT_FTP_RESPONSE_TIMEOUT as FTP_RESPONSE_TIMEOUT; +pub use curl_ffi::CURLOPT_IPRESOLVE as IPRESOLVE; +pub use curl_ffi::CURLOPT_MAXFILESIZE as MAXFILESIZE; +pub use curl_ffi::CURLOPT_INFILESIZE_LARGE as INFILESIZE_LARGE; +pub use curl_ffi::CURLOPT_RESUME_FROM_LARGE as RESUME_FROM_LARGE; +pub use curl_ffi::CURLOPT_MAXFILESIZE_LARGE as MAXFILESIZE_LARGE; +pub use curl_ffi::CURLOPT_NETRC_FILE as NETRC_FILE; +pub use curl_ffi::CURLOPT_USE_SSL as USE_SSL; +pub use curl_ffi::CURLOPT_POSTFIELDSIZE_LARGE as POSTFIELDSIZE_LARGE; +pub use curl_ffi::CURLOPT_TCP_NODELAY as TCP_NODELAY; +pub use curl_ffi::CURLOPT_FTPSSLAUTH as FTPSSLAUTH; +pub use curl_ffi::CURLOPT_IOCTLFUNCTION as IOCTLFUNCTION; +pub use curl_ffi::CURLOPT_IOCTLDATA as IOCTLDATA; +pub use curl_ffi::CURLOPT_FTP_ACCOUNT as FTP_ACCOUNT; +pub use curl_ffi::CURLOPT_COOKIELIST as COOKIELIST; +pub use curl_ffi::CURLOPT_IGNORE_CONTENT_LENGTH as IGNORE_CONTENT_LENGTH; +pub use curl_ffi::CURLOPT_FTP_SKIP_PASV_IP as FTP_SKIP_PASV_IP; +pub use curl_ffi::CURLOPT_FTP_FILEMETHOD as FTP_FILEMETHOD; +pub use curl_ffi::CURLOPT_LOCALPORT as LOCALPORT; +pub use curl_ffi::CURLOPT_LOCALPORTRANGE as LOCALPORTRANGE; +pub use curl_ffi::CURLOPT_CONNECT_ONLY as CONNECT_ONLY; +pub use curl_ffi::CURLOPT_CONV_FROM_NETWORK_FUNCTION as CONV_FROM_NETWORK_FUNCTION; +pub use curl_ffi::CURLOPT_CONV_TO_NETWORK_FUNCTION as CONV_TO_NETWORK_FUNCTION; +pub use curl_ffi::CURLOPT_CONV_FROM_UTF8_FUNCTION as CONV_FROM_UTF8_FUNCTION; +pub use curl_ffi::CURLOPT_MAX_SEND_SPEED_LARGE as MAX_SEND_SPEED_LARGE; +pub use curl_ffi::CURLOPT_MAX_RECV_SPEED_LARGE as MAX_RECV_SPEED_LARGE; +pub use curl_ffi::CURLOPT_FTP_ALTERNATIVE_TO_USER as FTP_ALTERNATIVE_TO_USER; +pub use curl_ffi::CURLOPT_SOCKOPTFUNCTION as SOCKOPTFUNCTION; +pub use curl_ffi::CURLOPT_SOCKOPTDATA as SOCKOPTDATA; +pub use curl_ffi::CURLOPT_SSL_SESSIONID_CACHE as SSL_SESSIONID_CACHE; +pub use curl_ffi::CURLOPT_SSH_AUTH_TYPES as SSH_AUTH_TYPES; +pub use curl_ffi::CURLOPT_SSH_PUBLIC_KEYFILE as SSH_PUBLIC_KEYFILE; +pub use curl_ffi::CURLOPT_SSH_PRIVATE_KEYFILE as SSH_PRIVATE_KEYFILE; +pub use curl_ffi::CURLOPT_FTP_SSL_CCC as FTP_SSL_CCC; +pub use curl_ffi::CURLOPT_TIMEOUT_MS as TIMEOUT_MS; +pub use curl_ffi::CURLOPT_CONNECTTIMEOUT_MS as CONNECTTIMEOUT_MS; +pub use curl_ffi::CURLOPT_HTTP_TRANSFER_DECODING as HTTP_TRANSFER_DECODING; +pub use curl_ffi::CURLOPT_HTTP_CONTENT_DECODING as HTTP_CONTENT_DECODING; +pub use curl_ffi::CURLOPT_NEW_FILE_PERMS as NEW_FILE_PERMS; +pub use curl_ffi::CURLOPT_NEW_DIRECTORY_PERMS as NEW_DIRECTORY_PERMS; +pub use curl_ffi::CURLOPT_POSTREDIR as POSTREDIR; +pub use curl_ffi::CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 as SSH_HOST_PUBLIC_KEY_MD5; +pub use curl_ffi::CURLOPT_OPENSOCKETFUNCTION as OPENSOCKETFUNCTION; +pub use curl_ffi::CURLOPT_OPENSOCKETDATA as OPENSOCKETDATA; +pub use curl_ffi::CURLOPT_COPYPOSTFIELDS as COPYPOSTFIELDS; +pub use curl_ffi::CURLOPT_PROXY_TRANSFER_MODE as PROXY_TRANSFER_MODE; +pub use curl_ffi::CURLOPT_SEEKFUNCTION as SEEKFUNCTION; +pub use curl_ffi::CURLOPT_SEEKDATA as SEEKDATA; +pub use curl_ffi::CURLOPT_CRLFILE as CRLFILE; +pub use curl_ffi::CURLOPT_ISSUERCERT as ISSUERCERT; +pub use curl_ffi::CURLOPT_ADDRESS_SCOPE as ADDRESS_SCOPE; +pub use curl_ffi::CURLOPT_CERTINFO as CERTINFO; +pub use curl_ffi::CURLOPT_USERNAME as USERNAME; +pub use curl_ffi::CURLOPT_PASSWORD as PASSWORD; +pub use curl_ffi::CURLOPT_PROXYUSERNAME as PROXYUSERNAME; +pub use curl_ffi::CURLOPT_PROXYPASSWORD as PROXYPASSWORD; +pub use curl_ffi::CURLOPT_NOPROXY as NOPROXY; +pub use curl_ffi::CURLOPT_TFTP_BLKSIZE as TFTP_BLKSIZE; +pub use curl_ffi::CURLOPT_SOCKS5_GSSAPI_SERVICE as SOCKS5_GSSAPI_SERVICE; +pub use curl_ffi::CURLOPT_SOCKS5_GSSAPI_NEC as SOCKS5_GSSAPI_NEC; +pub use curl_ffi::CURLOPT_PROTOCOLS as PROTOCOLS; +pub use curl_ffi::CURLOPT_REDIR_PROTOCOLS as REDIR_PROTOCOLS; +pub use curl_ffi::CURLOPT_SSH_KNOWNHOSTS as SSH_KNOWNHOSTS; +pub use curl_ffi::CURLOPT_SSH_KEYFUNCTION as SSH_KEYFUNCTION; +pub use curl_ffi::CURLOPT_SSH_KEYDATA as SSH_KEYDATA; +pub use curl_ffi::CURLOPT_MAIL_FROM as MAIL_FROM; +pub use curl_ffi::CURLOPT_MAIL_RCPT as MAIL_RCPT; +pub use curl_ffi::CURLOPT_FTP_USE_PRET as FTP_USE_PRET; +pub use curl_ffi::CURLOPT_RTSP_REQUEST as RTSP_REQUEST; +pub use curl_ffi::CURLOPT_RTSP_SESSION_ID as RTSP_SESSION_ID; +pub use curl_ffi::CURLOPT_RTSP_STREAM_URI as RTSP_STREAM_URI; +pub use curl_ffi::CURLOPT_RTSP_TRANSPORT as RTSP_TRANSPORT; +pub use curl_ffi::CURLOPT_RTSP_CLIENT_CSEQ as RTSP_CLIENT_CSEQ; +pub use curl_ffi::CURLOPT_RTSP_SERVER_CSEQ as RTSP_SERVER_CSEQ; +pub use curl_ffi::CURLOPT_INTERLEAVEDATA as INTERLEAVEDATA; +pub use curl_ffi::CURLOPT_INTERLEAVEFUNCTION as INTERLEAVEFUNCTION; +pub use curl_ffi::CURLOPT_WILDCARDMATCH as WILDCARDMATCH; +pub use curl_ffi::CURLOPT_CHUNK_BGN_FUNCTION as CHUNK_BGN_FUNCTION; +pub use curl_ffi::CURLOPT_CHUNK_END_FUNCTION as CHUNK_END_FUNCTION; +pub use curl_ffi::CURLOPT_FNMATCH_FUNCTION as FNMATCH_FUNCTION; +pub use curl_ffi::CURLOPT_CHUNK_DATA as CHUNK_DATA; +pub use curl_ffi::CURLOPT_FNMATCH_DATA as FNMATCH_DATA; +pub use curl_ffi::CURLOPT_RESOLVE as RESOLVE; +pub use curl_ffi::CURLOPT_TLSAUTH_USERNAME as TLSAUTH_USERNAME; +pub use curl_ffi::CURLOPT_TLSAUTH_PASSWORD as TLSAUTH_PASSWORD; +pub use curl_ffi::CURLOPT_TLSAUTH_TYPE as TLSAUTH_TYPE; +pub use curl_ffi::CURLOPT_TRANSFER_ENCODING as TRANSFER_ENCODING; +pub use curl_ffi::CURLOPT_CLOSESOCKETFUNCTION as CLOSESOCKETFUNCTION; +pub use curl_ffi::CURLOPT_CLOSESOCKETDATA as CLOSESOCKETDATA; +pub use curl_ffi::CURLOPT_GSSAPI_DELEGATION as GSSAPI_DELEGATION; +pub use curl_ffi::CURLOPT_DNS_SERVERS as DNS_SERVERS; +pub use curl_ffi::CURLOPT_ACCEPTTIMEOUT_MS as ACCEPTTIMEOUT_MS; +pub use curl_ffi::CURLOPT_TCP_KEEPALIVE as TCP_KEEPALIVE; +pub use curl_ffi::CURLOPT_TCP_KEEPIDLE as TCP_KEEPIDLE; +pub use curl_ffi::CURLOPT_TCP_KEEPINTVL as TCP_KEEPINTVL; +pub use curl_ffi::CURLOPT_SSL_OPTIONS as SSL_OPTIONS; +pub use curl_ffi::CURLOPT_MAIL_AUTH as MAIL_AUTH; +pub use curl_ffi::CURLOPT_SASL_IR as SASL_IR; +pub use curl_ffi::CURLOPT_XFERINFOFUNCTION as XFERINFOFUNCTION; +pub use curl_ffi::CURLOPT_XOAUTH2_BEARER as XOAUTH2_BEARER; +pub use curl_ffi::CURLOPT_DNS_INTERFACE as DNS_INTERFACE; +pub use curl_ffi::CURLOPT_DNS_LOCAL_IP4 as DNS_LOCAL_IP4; +pub use curl_ffi::CURLOPT_DNS_LOCAL_IP6 as DNS_LOCAL_IP6; +pub use curl_ffi::CURLOPT_LOGIN_OPTIONS as LOGIN_OPTIONS; +pub use curl_ffi::CURLOPT_SSL_ENABLE_NPN as SSL_ENABLE_NPN; +pub use curl_ffi::CURLOPT_SSL_ENABLE_ALPN as SSL_ENABLE_ALPN; +pub use curl_ffi::CURLOPT_EXPECT_100_TIMEOUT_MS as EXPECT_100_TIMEOUT_MS; +pub use curl_ffi::CURLOPT_PROXYHEADER as PROXYHEADER; +pub use curl_ffi::CURLOPT_HEADEROPT as HEADEROPT; +pub use curl_ffi::CURLOPT_POST301 as POST301; +pub use curl_ffi::CURLOPT_SSLKEYPASSWD as SSLKEYPASSWD; +pub use curl_ffi::CURLOPT_FTPAPPEND as FTPAPPEND; +pub use curl_ffi::CURLOPT_FTPLISTONLY as FTPLISTONLY; +pub use curl_ffi::CURLOPT_FTP_SSL as FTP_SSL; +pub use curl_ffi::CURLOPT_SSLCERTPASSWD as SSLCERTPASSWD; +pub use curl_ffi::CURLOPT_KRB4LEVEL as KRB4LEVEL; +pub use curl_ffi::CURLOPT_READDATA as READDATA; +pub use curl_ffi::CURLOPT_WRITEDATA as WRITEDATA; +pub use curl_ffi::CURLOPT_HEADERDATA as HEADERDATA; +pub use curl_ffi::CURLOPT_XFERINFODATA as XFERINFODATA; + +pub type Opt = ffi::CURLoption; + +pub trait OptVal { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void); +} + +impl OptVal for isize { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + f(self as *const c_void) + } +} + +impl OptVal for i32 { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + (self as isize).with_c_repr(f) + } +} + +impl OptVal for usize { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + f(self as *const c_void) + } +} + +impl OptVal for bool { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + f(self as usize as *const c_void) + } +} + +impl<'a> OptVal for &'a str { + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + let s = CString::new(self).unwrap(); + f(s.as_ptr() as *const c_void) + } +} + +impl<'a> OptVal for &'a Path { + #[cfg(unix)] + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + use std::ffi::OsStr; + use std::os::unix::prelude::*; + let s: &OsStr = self.as_ref(); + let s = CString::new(s.as_bytes()).unwrap(); + f(s.as_ptr() as *const c_void) + } + #[cfg(windows)] + fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { + let s = CString::new(self.to_str().unwrap()).unwrap(); + f(s.as_ptr() as *const c_void) + } +} diff --git a/deps/curl-0.2.10/src/ffi/version.rs b/deps/curl-0.2.10/src/ffi/version.rs new file mode 100644 index 000000000..a3f698208 --- /dev/null +++ b/deps/curl-0.2.10/src/ffi/version.rs @@ -0,0 +1,217 @@ +#![allow(non_camel_case_types)] +#![allow(dead_code)] + +use std::marker; +use std::ffi::CStr; +use std::{fmt, ptr, str}; +use libc::{c_char, c_int}; + +use curl_ffi as ffi; + +#[allow(missing_copy_implementations)] +pub struct Version { inner: *mut ffi::curl_version_info_data } + +impl Version { + + pub fn version_str<'a>(&'a self) -> &'a str { + as_str(unsafe { (*self.inner).version }).unwrap() + } + + pub fn version_major(&self) -> u32 { + (unsafe { (*self.inner).version_num } as u32 & 0xFF0000) >> 16 + } + + pub fn version_minor(&self) -> u32 { + (unsafe { (*self.inner).version_num } as u32 & 0xFF00) >> 8 + } + + pub fn version_patch(&self) -> u32 { + (unsafe { (*self.inner).version_num } as u32 & 0xFF) + } + + pub fn host<'a>(&'a self) -> &'a str { + as_str(unsafe { (*self.inner).host }).unwrap() + } + + fn features(&self) -> c_int { unsafe { (*self.inner).features } } + + pub fn is_ipv6_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_IPV6) == ffi::CURL_VERSION_IPV6 + } + + pub fn is_kerbos4_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_KERBEROS4) == ffi::CURL_VERSION_KERBEROS4 + } + + pub fn is_ssl_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_SSL) == ffi::CURL_VERSION_SSL + } + + pub fn is_libz_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_LIBZ) == ffi::CURL_VERSION_LIBZ + } + + pub fn is_ntlm_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_NTLM) == ffi::CURL_VERSION_NTLM + } + + pub fn is_gss_negotiate_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_GSSNEGOTIATE) == ffi::CURL_VERSION_GSSNEGOTIATE + } + + pub fn is_debug_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_DEBUG) == ffi::CURL_VERSION_DEBUG + } + + pub fn is_async_dns_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_ASYNCHDNS) == ffi::CURL_VERSION_ASYNCHDNS + } + + pub fn is_spengo_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_SPNEGO) == ffi::CURL_VERSION_SPNEGO + } + + pub fn is_large_file_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_LARGEFILE) == ffi::CURL_VERSION_LARGEFILE + } + + pub fn is_idn_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_IDN) == ffi::CURL_VERSION_IDN + } + + pub fn is_sspi_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_SSPI) == ffi::CURL_VERSION_SSPI + } + + pub fn is_conv_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_CONV) == ffi::CURL_VERSION_CONV + } + + pub fn is_curl_debug_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_CURLDEBUG) == ffi::CURL_VERSION_CURLDEBUG + } + + pub fn is_tls_auth_srp_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_TLSAUTH_SRP) == ffi::CURL_VERSION_TLSAUTH_SRP + } + + pub fn is_ntlm_wb_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_NTLM_WB) == ffi::CURL_VERSION_NTLM_WB + } + + pub fn is_http2_enabled(&self) -> bool { + (self.features() & ffi::CURL_VERSION_HTTP2) == ffi::CURL_VERSION_HTTP2 + } + + pub fn ssl_version<'a>(&'a self) -> Option<&'a str> { + as_str(unsafe { (*self.inner).ssl_version }) + } + + pub fn libz_version<'a>(&'a self) -> Option<&'a str> { + as_str(unsafe { (*self.inner).libz_version }) + } + + pub fn protocols<'a>(&'a self) -> Protocols<'a> { + Protocols { + curr: unsafe { (*self.inner).protocols }, + _marker: marker::PhantomData + } + } + + pub fn ares_version<'a>(&'a self) -> Option<&'a str> { + as_str(unsafe { (*self.inner).ares }) + } + + pub fn ares_version_num(&self) -> Option { + match self.ares_version() { + Some(_) => Some(unsafe { (*self.inner).ares_num } as u32), + None => None + } + } + + pub fn idn_version<'a>(&'a self) -> Option<&'a str> { + if self.is_idn_enabled() { + as_str(unsafe { (*self.inner).libidn }) + } + else { + None + } + } + + pub fn iconv_version(self) -> Option { + if self.is_conv_enabled() { + Some(unsafe { (*self.inner).iconv_ver_num } as u32) + } + else { + None + } + } + + pub fn ssh_version<'a>(&'a self) -> Option<&'a str> { + as_str(unsafe { (*self.inner).libssh_version }) + } +} + +#[derive(Copy, Clone)] +#[allow(raw_pointer_derive)] // TODO: Implement this by hand +pub struct Protocols<'a> { + curr: *const *const c_char, + _marker: marker::PhantomData<&'a str>, +} + +impl<'a> Iterator for Protocols<'a> { + type Item = &'a str; + fn next(&mut self) -> Option<&'a str> { + unsafe { + let proto = *self.curr; + + if proto == ptr::null() { + return None; + } + + self.curr = self.curr.offset(1); + as_str(proto) + } + } +} + +impl<'a> fmt::Display for Protocols<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let mut i = self.clone(); + + try!(write!(fmt, "[")); + + match i.next() { + Some(proto) => try!(write!(fmt, "{}", proto)), + None => return write!(fmt, "]") + } + + for proto in i { + try!(write!(fmt, ", {}", proto)); + } + + write!(fmt, "]") + } +} + +fn as_str<'a>(p: *const c_char) -> Option<&'a str> { + if p == ptr::null() { + return None; + } + + unsafe { + str::from_utf8(CStr::from_ptr(p).to_bytes()).ok() + } +} + +pub fn version_info() -> Version { + Version { + inner: unsafe { ffi::curl_version_info(ffi::CURL_VERSION_NOW) }, + } +} + +pub fn version() -> &'static str { + unsafe { + str::from_utf8(CStr::from_ptr(ffi::curl_version()).to_bytes()).unwrap() + } +} diff --git a/deps/curl-0.2.10/src/http/body.rs b/deps/curl-0.2.10/src/http/body.rs new file mode 100644 index 000000000..b8d8b9067 --- /dev/null +++ b/deps/curl-0.2.10/src/http/body.rs @@ -0,0 +1,53 @@ +use std::io::prelude::*; +use std::io; + +use self::Body::{FixedBody, ChunkedBody}; + +pub enum Body<'a> { + FixedBody(&'a [u8], usize), + ChunkedBody(&'a mut (Read+'a)) +} + +impl<'a> Body<'a> { + pub fn get_size(&self) -> Option { + match self { + &FixedBody(_, len) => Some(len), + _ => None + } + } + + pub fn read(&mut self, buf: &mut [u8]) -> io::Result { + match self { + &mut FixedBody(ref mut r, _) => Read::read(r, buf), + &mut ChunkedBody(ref mut r) => r.read(buf) + } + } +} + +pub trait ToBody<'a> { + fn to_body(self) -> Body<'a>; +} + +impl<'a> ToBody<'a> for &'a str { + fn to_body(self) -> Body<'a> { + self.as_bytes().to_body() + } +} + +impl<'a> ToBody<'a> for &'a [u8] { + fn to_body(self) -> Body<'a> { + FixedBody(self, self.len()) + } +} + +impl<'a> ToBody<'a> for &'a String { + fn to_body(self) -> Body<'a> { + self[..].to_body() + } +} + +impl<'a, R: Read + 'a> ToBody<'a> for &'a mut R { + fn to_body(self) -> Body<'a> { + ChunkedBody(self) + } +} diff --git a/deps/curl-0.2.10/src/http/handle.rs b/deps/curl-0.2.10/src/http/handle.rs new file mode 100644 index 000000000..3a87a57c7 --- /dev/null +++ b/deps/curl-0.2.10/src/http/handle.rs @@ -0,0 +1,406 @@ +use std::collections::hash_map::{HashMap, Entry}; +use std::path::Path; + +use url::Url; + +use ffi; +use ffi::opt; +use ffi::easy::Easy; +use http::Response; +use http::body::{Body,ToBody}; +use {ProgressCb,ErrCode}; + +use self::Method::{Get, Head, Post, Put, Patch, Delete}; +use self::BodyType::{Fixed, Chunked}; + +const DEFAULT_TIMEOUT_MS: usize = 30_000; + +pub struct Handle { + easy: Easy, +} + +impl Handle { + pub fn new() -> Handle { + return configure(Handle { easy: Easy::new() } + .timeout(DEFAULT_TIMEOUT_MS) + .connect_timeout(DEFAULT_TIMEOUT_MS)); + + #[cfg(unix)] + fn configure(handle: Handle) -> Handle { + let probe = ::openssl::probe::probe(); + let handle = match probe.cert_file { + Some(ref path) => handle.ssl_ca_info(path), + None => handle, + }; + match probe.cert_dir { + Some(ref path) => handle.ssl_ca_path(path), + None => handle, + } + } + + #[cfg(not(unix))] + fn configure(handle: Handle) -> Handle { handle } + } + + pub fn timeout(mut self, ms: usize) -> Handle { + self.easy.setopt(opt::TIMEOUT_MS, ms).unwrap(); + self + } + + pub fn connect_timeout(mut self, ms: usize) -> Handle { + self.easy.setopt(opt::CONNECTTIMEOUT_MS, ms).unwrap(); + self + } + + /// Set the time in seconds that the transfer speed should be below + /// the `low_speed_limit` rate of bytes per second for the library to + /// consider it too slow and abort. + /// + /// The default for this option is 0 which means that this option is + /// disabled. + pub fn low_speed_timeout(mut self, seconds: usize) -> Handle { + self.easy.setopt(opt::LOW_SPEED_TIME, seconds).unwrap(); + self + } + + /// Set the average transfer speed in bytes per second that the + /// transfer should be below during `low_speed_timeout` seconds for + /// libcurl to consider it to be too slow and abort. + /// + /// The default for this option is 0 which means that this option is + /// disabled. + pub fn low_speed_limit(mut self, bytes_per_second: usize) -> Handle { + self.easy.setopt(opt::LOW_SPEED_LIMIT, bytes_per_second).unwrap(); + self + } + + pub fn verbose(mut self) -> Handle { + self.easy.setopt(opt::VERBOSE, 1).unwrap(); + self + } + + pub fn proxy(mut self, proxy: U) -> Handle { + proxy.with_url_str(|s| { + self.easy.setopt(opt::PROXY, s).unwrap(); + }); + + self + } + + pub fn ssl_ca_path(mut self, path: &Path) -> Handle { + self.easy.setopt(opt::CAPATH, path).unwrap(); + self + } + + pub fn ssl_ca_info(mut self, path: &Path) -> Handle { + self.easy.setopt(opt::CAINFO, path).unwrap(); + self + } + + pub fn cookie_jar(mut self, path: &Path) -> Handle { + self.easy.setopt(opt::COOKIEJAR, path).unwrap(); + self + } + + pub fn cookie_file(mut self, path: &Path) -> Handle { + self.easy.setopt(opt::COOKIEFILE, path).unwrap(); + self + } + + pub fn cookies(self, path: &Path) -> Handle { + self.cookie_jar(path).cookie_file(path) + } + + pub fn get<'a, 'b, U: ToUrl>(&'a mut self, uri: U) -> Request<'a, 'b> { + Request::new(self, Get).uri(uri) + } + + pub fn head<'a, 'b, U: ToUrl>(&'a mut self, uri: U) -> Request<'a, 'b> { + Request::new(self, Head).uri(uri) + } + + pub fn post<'a, 'b, U: ToUrl, B: ToBody<'b>>(&'a mut self, uri: U, body: B) -> Request<'a, 'b> { + Request::new(self, Post).uri(uri).body(body) + } + + pub fn put<'a, 'b, U: ToUrl, B: ToBody<'b>>(&'a mut self, uri: U, body: B) -> Request<'a, 'b> { + Request::new(self, Put).uri(uri).body(body) + } + + pub fn patch<'a, 'b, U: ToUrl, B: ToBody<'b>>(&'a mut self, uri: U, body: B) -> Request<'a, 'b> { + Request::new(self, Patch).uri(uri).body(body) + } + + pub fn delete<'a, 'b, U: ToUrl>(&'a mut self, uri: U) -> Request<'a, 'b> { + Request::new(self, Delete).uri(uri) + } +} + +#[derive(Copy, Clone)] +pub enum Method { + Options, + Get, + Head, + Post, + Put, + Patch, + Delete, + Trace, + Connect +} + +pub struct Request<'a, 'b> { + err: Option, + handle: &'a mut Handle, + method: Method, + headers: HashMap>, + body: Option>, + body_type: Option, + content_type: bool, // whether or not the content type was set + expect_continue: bool, // whether to expect a 100 continue from the server + progress: Option>>, + follow: bool, +} + +enum BodyType { + Fixed(usize), + Chunked, +} + +impl<'a, 'b> Request<'a, 'b> { + pub fn new(handle: &'a mut Handle, method: Method) -> Request<'a, 'b> { + Request { + err: None, + handle: handle, + method: method, + headers: HashMap::new(), + body: None, + body_type: None, + content_type: false, + expect_continue: false, + progress: None, + follow: false, + } + } + + pub fn uri(mut self, uri: U) -> Request<'a, 'b> { + uri.with_url_str(|s| { + match self.handle.easy.setopt(opt::URL, s) { + Ok(_) => {} + Err(e) => self.err = Some(e) + } + }); + + self + } + + pub fn body>(mut self, body: B) -> Request<'a, 'b> { + self.body = Some(body.to_body()); + self + } + + pub fn content_type(mut self, ty: &str) -> Request<'a, 'b> { + if !self.content_type { + self.content_type = true; + append_header(&mut self.headers, "Content-Type", ty); + } + + self + } + + pub fn content_length(mut self, len: usize) -> Request<'a, 'b> { + self.body_type = Some(Fixed(len)); + self + } + + pub fn chunked(mut self) -> Request<'a, 'b> { + self.body_type = Some(Chunked); + self + } + + pub fn expect_continue(mut self) -> Request<'a, 'b> { + self.expect_continue = true; + self + } + + pub fn header(mut self, name: &str, val: &str) -> Request<'a, 'b> { + append_header(&mut self.headers, name, val); + self + } + + pub fn get_header(&self, name: &str) -> Option<&[String]> { + self.headers.get(name).map(|a| &a[..]) + } + + pub fn headers<'c, 'd, I: Iterator>(mut self, hdrs: I) -> Request<'a, 'b> { + for (name, val) in hdrs { + append_header(&mut self.headers, name, val); + } + + self + } + + pub fn progress(mut self, cb: F) -> Request<'a, 'b> + where F: FnMut(usize, usize, usize, usize) + 'b + { + self.progress = Some(Box::new(cb) as Box>); + self + } + + pub fn follow_redirects(mut self, follow: bool) -> Request<'a, 'b> { + self.follow = follow; + self + } + + pub fn exec(self) -> Result { + // Deconstruct the struct + let Request { + err, + handle, + method, + mut headers, + mut body, + body_type, + content_type, + expect_continue, + progress, + follow, + .. + } = self; + + if follow { + try!(handle.easy.setopt(opt::FOLLOWLOCATION, 1)); + } + + match err { + Some(e) => return Err(e), + None => {} + } + + // Clear custom headers set from the previous request + try!(handle.easy.setopt(opt::HTTPHEADER, 0)); + + match method { + Get => try!(handle.easy.setopt(opt::HTTPGET, 1)), + Head => try!(handle.easy.setopt(opt::NOBODY, 1)), + Post => try!(handle.easy.setopt(opt::POST, 1)), + Put => try!(handle.easy.setopt(opt::UPLOAD, 1)), + Patch => { + try!(handle.easy.setopt(opt::CUSTOMREQUEST, "PATCH")); + try!(handle.easy.setopt(opt::UPLOAD, 1)); + }, + Delete => { + if body.is_some() { + try!(handle.easy.setopt(opt::UPLOAD, 1)); + } + + try!(handle.easy.setopt(opt::CUSTOMREQUEST, "DELETE")); + } + _ => unimplemented!() + } + + match body.as_ref() { + None => {} + Some(body) => { + let body_type = body_type.unwrap_or(match body.get_size() { + Some(len) => Fixed(len), + None => Chunked, + }); + + match body_type { + Fixed(len) => { + match method { + Post => try!(handle.easy.setopt(opt::POSTFIELDSIZE, len)), + Put | Patch | Delete => try!(handle.easy.setopt(opt::INFILESIZE, len)), + _ => {} + } + append_header(&mut headers, "Content-Length", + &len.to_string()); + } + Chunked => { + append_header(&mut headers, "Transfer-Encoding", + "chunked"); + } + + } + + if !content_type { + append_header(&mut headers, "Content-Type", "application/octet-stream"); + } + + if !expect_continue { + append_header(&mut headers, "Expect", ""); + } + } + } + + let mut ffi_headers = ffi::List::new(); + + if !headers.is_empty() { + let mut buf = Vec::new(); + + for (k, v) in headers.iter() { + buf.extend(k.bytes()); + buf.extend(": ".bytes()); + + for v in v.iter() { + buf.extend(v.bytes()); + buf.push(0); + ffi_headers.push_bytes(&buf); + buf.truncate(k.len() + 2); + } + + buf.truncate(0); + } + + try!(handle.easy.setopt(opt::HTTPHEADER, &ffi_headers)); + } + + handle.easy.perform(body.as_mut(), progress) + } +} + +fn append_header(map: &mut HashMap>, key: &str, val: &str) { + match map.entry(key.to_string()) { + Entry::Vacant(entry) => { + let mut values = Vec::new(); + values.push(val.to_string()); + entry.insert(values) + }, + Entry::Occupied(entry) => entry.into_mut() + }; +} + +pub trait ToUrl{ + fn with_url_str(self, f: F) where F: FnOnce(&str); +} + +impl<'a> ToUrl for &'a str { + fn with_url_str(self, f: F) where F: FnOnce(&str) { + f(self); + } +} + +impl<'a> ToUrl for &'a Url { + fn with_url_str(self, f: F) where F: FnOnce(&str) { + self.to_string().with_url_str(f); + } +} + +impl ToUrl for String { + fn with_url_str(self, f: F) where F: FnOnce(&str) { + self[..].with_url_str(f); + } +} + +#[cfg(test)] +mod tests { + use super::Handle; + + #[test] + fn get_header() { + let mut h = Handle::new(); + let r = h.get("/foo").header("foo", "bar"); + assert_eq!(r.get_header("foo"), Some(&["bar".to_string()][..])); + } +} diff --git a/deps/curl-0.2.10/src/http/header.rs b/deps/curl-0.2.10/src/http/header.rs new file mode 100644 index 000000000..d50a9b924 --- /dev/null +++ b/deps/curl-0.2.10/src/http/header.rs @@ -0,0 +1,224 @@ +use std::str; + +use self::State::{HdrNameStart, HdrName, HdrValStart, HdrNameDiscardWs, HdrVal, + HdrValDiscardWs}; + +enum State { + HdrNameStart, + HdrName, + HdrNameDiscardWs, + HdrValStart, + HdrVal, + HdrValDiscardWs +} + +/** + * Simple header parser extracts the header name and value, stripping out + * starting and trailing white space. It does not, however, normalize header + * value whitespace + */ +pub fn parse<'a>(buf: &'a [u8]) -> Option<(&'a str, &'a str)> { + let mut i = 0; + let mut name_begin = 0; + let mut name_end = 0; + let mut val_begin = 0; + let mut val_end = 0; + let mut state = HdrNameStart; + + while i < buf.len() { + let c = buf[i]; + + match state { + HdrNameStart => { + if is_token(c) { + name_begin = i; + name_end = i; + state = HdrName; + } + else if c == COLON { + name_end = i; + state = HdrValStart; + } + else if is_space(c) { + name_end = i; + } + else { + return None; // error + } + } + HdrName => { + if c == COLON { + name_end = i; + state = HdrValStart; + } + else if is_space(c) { + name_end = i; + state = HdrNameDiscardWs; + } + else if !is_token(c) { + return None; // error + } + } + HdrNameDiscardWs => { + if is_token(c) { + state = HdrName; + } + else if c == COLON { + state = HdrValStart; + } + else if !is_space(c) { + return None; // error + } + } + HdrValStart => { + if !is_lws(c) { + val_begin = i; + val_end = i + 1; + state = HdrVal; + } + } + HdrVal => { + if is_lws(c) { + val_end = i; + state = HdrValDiscardWs; + } + else { + val_end = i + 1; + } + } + HdrValDiscardWs => { + if !is_lws(c) { + val_end = i + 1; + state = HdrVal; + } + } + } + + i += 1; + } + + let name = match str::from_utf8(&buf[name_begin..name_end]) { + Ok(v) => v, + Err(..) => return None + }; + + let val = match str::from_utf8(&buf[val_begin..val_end]) { + Ok(v) => v, + Err(..) => return None + }; + + Some((name, val)) +} + +static COLON: u8 = 58; + +static TOKEN: &'static [u8] = &[ +/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ + 0, 0, 0, 0, 0, 0, 0, 0, +/* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ + 0, 33, 0, 35, 36, 37, 38, 39, +/* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ + 0, 0, 42, 43, 44, 45, 46, 47, +/* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ + 48, 49, 50, 51, 52, 53, 54, 55, +/* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ + 56, 57, 0, 0, 0, 0, 0, 0, +/* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ + 0, 97, 98, 99, 100, 101, 102, 103, +/* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ + 104, 105, 106, 107, 108, 109, 110, 111, +/* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ + 112, 113, 114, 115, 116, 117, 118, 119, +/* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ + 120, 121, 122, 0, 0, 0, 94, 95, +/* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ + 96, 97, 98, 99, 100, 101, 102, 103, +/* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ + 104, 105, 106, 107, 108, 109, 110, 111, +/* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ + 112, 113, 114, 115, 116, 117, 118, 119, +/* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ + 120, 121, 122, 123, 124, 0, 126, 0 +]; + +#[inline] +fn is_token(c: u8) -> bool { + c < 128 && TOKEN[c as usize] > 0 +} + +#[inline] +fn is_space(c: u8) -> bool { + c == (' ' as u8) || c == ('\t' as u8) +} + +#[inline] +fn is_lws(c: u8) -> bool { + is_space(c) || c == ('\n' as u8) || c == ('\r' as u8) +} + +#[cfg(test)] +mod test { + use super::parse; + + fn parse_str<'a>(s: &'a str) -> (&'a str, &'a str) { + parse(s.as_bytes()).unwrap() + } + + #[test] + pub fn test_basic_header() { + let (name, val) = parse_str("foo: bar"); + + assert!(name == "foo"); + assert!(val == "bar"); + } + + #[test] + pub fn test_basic_header_with_crlf() { + let (name, val) = parse_str("foo: bar\r\n"); + + assert!(name == "foo"); + assert!(val == "bar"); + } + + #[test] + pub fn test_header_with_extra_spacing() { + let (name, val) = parse_str(" \tfoo :bar \t\r"); + + assert!(name == "foo"); + assert!(val == "bar"); + } + + #[test] + pub fn test_header_without_value() { + let (name, val) = parse_str("foo:"); + + assert!(name == "foo"); + assert!(val == ""); + } + + #[test] + pub fn test_header_value_with_spacing_characters() { + let (name, val) = parse_str("foo: blah@example.com\r\n"); + + assert!(name == "foo"); + assert!(val == "blah@example.com"); + } + + #[test] + pub fn test_parsing_empty_line() { + let res = parse("\r\n\r\n".as_bytes()); + assert!(res.is_none()); + } + + #[test] + pub fn test_parsing_invalid_bytes() { + let res = parse(b"fo\x9co: zomg"); + assert!(res.is_none()); + } +} diff --git a/deps/curl-0.2.10/src/http/mod.rs b/deps/curl-0.2.10/src/http/mod.rs new file mode 100644 index 000000000..10f4d60f8 --- /dev/null +++ b/deps/curl-0.2.10/src/http/mod.rs @@ -0,0 +1,12 @@ +pub use self::handle::{Handle,Request}; +pub use self::response::{Headers,Response}; + +pub mod body; +pub mod handle; +pub mod header; +mod response; + +#[inline] +pub fn handle() -> Handle { + Handle::new() +} diff --git a/deps/curl-0.2.10/src/http/response.rs b/deps/curl-0.2.10/src/http/response.rs new file mode 100644 index 000000000..8a8837a08 --- /dev/null +++ b/deps/curl-0.2.10/src/http/response.rs @@ -0,0 +1,62 @@ +use std::{fmt,str}; +use std::collections::HashMap; + +pub type Headers = HashMap>; + +pub struct Response { + code: u32, + hdrs: Headers, + body: Vec +} + +impl Response { + pub fn new(code: u32, hdrs: Headers, body: Vec) -> Response { + Response { + code: code, + hdrs: hdrs, + body: body + } + } + + pub fn get_code(&self) -> u32 { + self.code + } + + pub fn get_headers<'a>(&'a self) -> &'a Headers { + &self.hdrs + } + + pub fn get_header<'a>(&'a self, name: &str) -> &'a [String] { + self.hdrs + .get(name) + .map(|v| &v[..]) + .unwrap_or(&[]) + } + + pub fn get_body<'a>(&'a self) -> &'a [u8] { + &self.body + } + + pub fn move_body(self) -> Vec { + self.body + } +} + +impl fmt::Display for Response { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + try!(write!(fmt, "Response {{{}, ", self.code)); + + for (name, val) in self.hdrs.iter() { + try!(write!(fmt, "{}: {}, ", name, val.connect(", "))); + } + + match str::from_utf8(&self.body) { + Ok(b) => try!(write!(fmt, "{}", b)), + Err(..) => try!(write!(fmt, "bytes[{}]", self.body.len())) + } + + try!(write!(fmt, "]")); + + Ok(()) + } +} diff --git a/deps/curl-0.2.10/src/lib.rs b/deps/curl-0.2.10/src/lib.rs new file mode 100644 index 000000000..d01ae143f --- /dev/null +++ b/deps/curl-0.2.10/src/lib.rs @@ -0,0 +1,24 @@ +extern crate libc; +extern crate url; + +#[macro_use] +extern crate log; + +extern crate curl_sys as curl_ffi; + +#[cfg(unix)] +extern crate openssl_sys as openssl; + +pub use ffi::easy::ProgressCb; +pub use ffi::err::ErrCode; + +// Version accessors +pub use ffi::version::{ + Version, + version, + version_info, + Protocols +}; + +mod ffi; +pub mod http; diff --git a/deps/curl-0.2.10/test/server.rs b/deps/curl-0.2.10/test/server.rs new file mode 100644 index 000000000..699eaff79 --- /dev/null +++ b/deps/curl-0.2.10/test/server.rs @@ -0,0 +1,258 @@ +use std::collections::HashSet; +use std::io::prelude::*; +use std::iter::repeat; +use std::net::{TcpStream, TcpListener}; +use std::str; +use std::sync::mpsc::{channel, Sender, Receiver}; +use std::thread; + +use self::Op::{SendBytes, ReceiveBytes, Wait, Shutdown}; + +// Global handle to the running test HTTP server +thread_local!(static HANDLE: Handle = start_server()); + +// Setup an op sequence with the test HTTP server +pub fn setup(ops: OpSequence) -> OpSequenceResult { + // Setup a channel to receive the response on + let (tx, rx) = channel(); + + // Send the op sequence to the server task + HANDLE.with(move |h| { + h.send(ops, tx); + }); + + OpSequenceResult::new(rx) +} + +pub fn url(path: &str) -> String { + format!("http://localhost:{}{}", port(), path) +} + +fn port() -> usize { + HANDLE.with(|h| { + h.port() + }) +} + +/* Handle to the running HTTP server task. Communication with the server + * happens over channels. + */ +struct Handle { + port: u16, + tx: Sender<(OpSequence, Sender>)> +} + +/* Operations for the test server to perform: + * - Send some bytes + * - Expect to receive bytes + * - Wait for a certain amount of time + * - Shutdown the server (allows a clean exit at the end of the tests) + */ +#[derive(Clone,PartialEq,Debug)] +pub enum Op { + SendBytes(&'static [u8]), + ReceiveBytes(&'static [u8]), + Wait(usize), + Shutdown +} + +/* An ordered sequence of operations for the HTTP server to perform +*/ +#[derive(Debug)] +pub struct OpSequence { + ops: Vec +} + +/* Represents the completion of the of the op sequence by the HTTP + * server. + */ +pub struct OpSequenceResult { + rx: Receiver> +} + +impl OpSequence { + pub fn new(op: Op) -> OpSequence { + OpSequence { ops: vec!(op) } + } + + pub fn concat(op: Op, seq: OpSequence) -> OpSequence { + let mut ops = vec!(op); + ops.extend(seq.ops.iter().cloned()); + OpSequence { ops: ops } + } + + pub fn is_shutdown(&self) -> bool { + self.ops.len() == 1 && self.ops[0] == Shutdown + } + + pub fn apply(&self, sock: &mut TcpStream, port: usize) + -> Result<(), String> { + for op in self.ops.iter() { + match op { + &SendBytes(b) => { + let b = insert_port(b, port); + match sock.write_all(&b) { + Ok(_) => {} + Err(e) => return Err(e.to_string()) + } + } + &ReceiveBytes(b) => { + let b = insert_port(b, port); + let mut rem = b.len(); + let mut act = repeat(0u8).take(rem).collect::>(); + + while rem > 0 { + match sock.read(&mut act[b.len() - rem..]) { + Ok(i) => rem = rem - i, + Err(e) => { + debug!("aborting due to error; error={}; \ + remaining={}; bytes=\n{}", e, rem, + to_debug_str(&act)); + return Err(e.to_string()) + } + } + } + + debug!("server received bytes; rem={}; bytes=\n{}\n~~~~~~~~~~~~~~", + rem, to_debug_str(&act)); + + let req1 = parse_request(&b); + let req2 = parse_request(&act); + + if req1 != req2 { + return Err(format!( + "received unexpected byte sequence.\n\n\ + Expected:\n{}\n\nReceived:\n{}", + to_debug_str(&b), to_debug_str(&act))); + } + } + &Wait(ms) => thread::sleep_ms(ms as u32), + &Shutdown => { + return Err("Shutdown must be sent on its own".to_string()) + } + } + } + + return Ok(()); + + fn insert_port(bytes: &'static [u8], port: usize) -> Vec { + let s = str::from_utf8(bytes).unwrap(); + let p = port.to_string(); + s.replace("{PORT}", &p).into_bytes() + } + + fn parse_request<'a>(req: &'a [u8]) -> (&'a [u8], + HashSet<&'a [u8]>, + &'a [u8]) { + let mut start = None; + let mut headers = HashSet::new(); + let mut taken = 0; + + for part in req.split(|a| *a == b'\n') { + taken += part.len() + 1; + + if start.is_none() { + start = Some(part); + } else if part.len() == 1 { + break; + } else { + headers.insert(part); + } + } + + if taken > req.len() { + taken = req.len(); + } + + (start.unwrap(), headers, &req[taken..]) + } + } +} + +fn to_debug_str(bytes: &[u8]) -> String { + let mut ret = String::new(); + + for b in bytes.iter() { + let b = *b as char; + + if b >= ' ' && b <= '~' { + ret.push(b); + } + else if b == '\n' { + ret.push_str("\\n\n"); + } + else if b == '\r' { + ret.push_str("\\r"); + } + else { + ret.push('?'); + } + } + + ret +} + +impl Handle { + fn new(tx: Sender<(OpSequence, Sender>)>, port: u16) + -> Handle { + Handle { tx: tx, port: port } + } + + fn send(&self, ops: OpSequence, resp: Sender>) { + self.tx.send((ops, resp)).unwrap(); + } + + fn port(&self) -> usize { + self.port as usize + } +} + +impl Drop for Handle { + fn drop(&mut self) { + let (tx, _) = channel(); + self.send(OpSequence::new(Shutdown), tx); + } +} + +impl OpSequenceResult { + pub fn new(rx: Receiver>) -> OpSequenceResult { + OpSequenceResult { rx: rx } + } + + pub fn assert(&self) { + match self.rx.recv().unwrap() { + Ok(_) => {} + Err(e) => panic!("http exchange did not proceed as expected: {}", e) + } + } +} + +fn start_server() -> Handle { + let (ops_tx, ops_rx) = channel(); + + let srv = TcpListener::bind("127.0.0.1:0").unwrap(); + let port = srv.local_addr().unwrap().port(); + + thread::spawn(move || { + loop { + let (ops, resp_tx): (OpSequence, Sender>) = + ops_rx.recv().unwrap(); + + if ops.is_shutdown() { + return; + } + + let mut sock = match srv.accept() { + Ok(s) => s.0, + Err(e) => { + resp_tx.send(Err(format!("server accept err: {}", e))).unwrap(); + return; + } + }; + + resp_tx.send(ops.apply(&mut sock, port as usize)).unwrap(); + } + }); + + Handle::new(ops_tx, port) +} diff --git a/deps/curl-0.2.10/test/test.rs b/deps/curl-0.2.10/test/test.rs new file mode 100644 index 000000000..adcf66fef --- /dev/null +++ b/deps/curl-0.2.10/test/test.rs @@ -0,0 +1,38 @@ +extern crate curl; +extern crate env_logger; + +#[macro_use] +extern crate log; + +macro_rules! server { + ($($ops:expr),+) => (server::setup(ops!($($ops),+))); +} + +macro_rules! ops { + ($op:expr) => (server::OpSequence::new($op)); + ($op:expr, $($res:expr),+) => ( + server::OpSequence::concat($op, ops!($($res),+)) + ); +} + +macro_rules! send { + ($e:expr) => (server::Op::SendBytes($e)); +} + +macro_rules! recv { + ($e:expr) => (server::Op::ReceiveBytes($e)); +} + +macro_rules! wait { + ($dur:expr) => (server::Op::Wait($dur)); +} + +mod server; +mod test_delete; +mod test_get; +mod test_head; +mod test_keep_alive; +mod test_patch; +mod test_post; +mod test_proxy; +mod test_put; diff --git a/deps/curl-0.2.10/test/test_delete.rs b/deps/curl-0.2.10/test/test_delete.rs new file mode 100644 index 000000000..e233af5e0 --- /dev/null +++ b/deps/curl-0.2.10/test/test_delete.rs @@ -0,0 +1,52 @@ +use curl::http; +use super::server; + +#[test] +pub fn test_delete_with_no_body() { + let srv = server!( + recv!(b"DELETE / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + \r\n"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .delete(server::url("/")) + .exec(); + + srv.assert(); + let res = res.unwrap(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} + +#[test] +pub fn test_delete_binary_with_slice() { + let srv = server!( + recv!(b"DELETE / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .delete(server::url("/")) + .body("Foo Bar Baz") + .exec(); // .unwrap(); + + srv.assert(); + let res = res.unwrap(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} diff --git a/deps/curl-0.2.10/test/test_get.rs b/deps/curl-0.2.10/test/test_get.rs new file mode 100644 index 000000000..6c4ef291c --- /dev/null +++ b/deps/curl-0.2.10/test/test_get.rs @@ -0,0 +1,114 @@ +use curl::http::handle; +use super::server; + +#[test] +pub fn test_simple_get() { + let srv = server!( + recv!( + b"GET / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), // Send the data + send!( + b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n")); // Sends + + let res = handle() + .get(server::url("/")) + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200, "code is {}", res.get_code()); + assert!(res.get_body() == "Hello".as_bytes()); + assert!(res.get_headers().len() == 1); + assert!(res.get_header("content-length") == ["5".to_string()]); +} + +#[test] +pub fn test_get_with_custom_headers() { + let srv = server!( + recv!( + b"GET / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + User-Agent: Zomg Test\r\n\r\n"), + send!( + b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n")); + + let res = handle() + .get(server::url("/")) + .header("User-Agent", "Zomg Test") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); + assert!(res.get_headers().len() == 1); + assert!(res.get_header("content-length") == ["5".to_string()]); +} + +#[test] +pub fn test_get_tracking_progress() { + let srv = server!( + recv!( + b"GET / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), + send!( + b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n")); + + let mut dl = 0; + let mut cnt = 0; + + let res = handle() + .get(server::url("/")) + .progress(|_, dlnow, _, _| { + cnt = cnt + 1; + dl = dlnow + }) + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(dl == 5); + assert!(cnt > 1); +} + +#[test] +pub fn follows_redirects() { + let srv1 = server!( + recv!( + b"GET / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), + send!( + b"HTTP/1.1 301 Moved Permanently\r\n\ + Location: http://localhost:{PORT}/test\r\n\r\n")); + let srv2 = server!( + recv!( + b"GET /test HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), + send!( + b"HTTP/1.1 200 OK\r\n\r\n\ + response!")); + + let res = handle() + .get(server::url("/")) + .follow_redirects(true) + .exec() + .unwrap(); + + srv1.assert(); + srv2.assert(); + + assert!(res.get_code() == 200); + assert_eq!(res.get_body(), b"response!"); +} diff --git a/deps/curl-0.2.10/test/test_head.rs b/deps/curl-0.2.10/test/test_head.rs new file mode 100644 index 000000000..6d5c770c3 --- /dev/null +++ b/deps/curl-0.2.10/test/test_head.rs @@ -0,0 +1,26 @@ +use curl::http::handle; +use super::server; + +#[test] +pub fn test_simple_head() { + let srv = server!( + recv!(b"HEAD / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + \r\n"), // Send the data + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n") + ); + + let res = handle() + .head(server::url("/")) + .exec(); + + srv.assert(); + let res = res.unwrap(); + + assert!(res.get_code() == 200, "code is {}", res.get_code()); + assert!(res.get_body() == []); + assert!(res.get_headers().len() == 1); + assert!(res.get_header("content-length") == ["5".to_string()]); +} diff --git a/deps/curl-0.2.10/test/test_keep_alive.rs b/deps/curl-0.2.10/test/test_keep_alive.rs new file mode 100644 index 000000000..719941cfd --- /dev/null +++ b/deps/curl-0.2.10/test/test_keep_alive.rs @@ -0,0 +1,68 @@ +use curl::http::handle; +use super::server; + +#[test] +pub fn test_get_requests() { + let srv = server!( + recv!(b"GET / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n"), + recv!(b"GET /next HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + World\r\n\r\n") + ); + + let mut handle = handle(); + let res1 = handle.get(server::url("/")).exec().unwrap(); + let res2 = handle.get(server::url("/next")).exec().unwrap(); + + srv.assert(); + + assert!(res1.get_code() == 200); + assert!(res1.get_body() == "Hello".as_bytes()); + + assert!(res2.get_code() == 200); + assert!(res2.get_body() == "World".as_bytes()); +} + +#[test] +pub fn test_post_get_requests() { + let srv = server!( + recv!(b"POST / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 5\r\n\ + \r\n\ + Hello"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + World\r\n\r\n"), + recv!(b"GET /next HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\r\n"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 4\r\n\r\n\ + NEXT\r\n\r\n") + ); + + let mut handle = handle().timeout(1000); + let res1 = handle.post(server::url("/"), "Hello").exec().unwrap(); + let res2 = handle.get(server::url("/next")).exec().unwrap(); + + srv.assert(); + + assert!(res1.get_code() == 200); + assert!(res1.get_body() == "World".as_bytes(), "actual={}", + String::from_utf8_lossy(res1.get_body())); + + assert!(res2.get_code() == 200); + assert!(res2.get_body() == "NEXT".as_bytes(), "actual={}", + String::from_utf8_lossy(res2.get_body())); +} diff --git a/deps/curl-0.2.10/test/test_patch.rs b/deps/curl-0.2.10/test/test_patch.rs new file mode 100644 index 000000000..621c6e4e7 --- /dev/null +++ b/deps/curl-0.2.10/test/test_patch.rs @@ -0,0 +1,53 @@ +use curl::http; +use super::server; + +#[test] +pub fn test_patch_binary_with_slice() { + let srv = server!( + recv!(b"PATCH / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .patch(server::url("/"), "Foo Bar Baz") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} + +#[test] +pub fn test_patch_binary_with_content_type() { + let srv = server!( + recv!(b"PATCH / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/foobar\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .patch(server::url("/"), "Foo Bar Baz") + .content_type("application/foobar") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} diff --git a/deps/curl-0.2.10/test/test_post.rs b/deps/curl-0.2.10/test/test_post.rs new file mode 100644 index 000000000..65c682f97 --- /dev/null +++ b/deps/curl-0.2.10/test/test_post.rs @@ -0,0 +1,107 @@ +use curl::http; +use super::server; + +#[test] +pub fn test_post_binary_with_slice() { + let srv = server!( + recv!(b"POST / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .post(server::url("/"), "Foo Bar Baz") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} + +#[test] +pub fn test_post_binary_with_string() { + let srv = server!( + recv!(b"POST / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let body = "Foo Bar Baz".to_string(); + let res = http::handle() + .post(server::url("/"), &body) + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} + +#[test] +pub fn test_post_binary_with_reader() { + let srv = server!( + recv!(b"POST / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Transfer-Encoding: chunked\r\n\ + Content-Type: application/octet-stream\r\n\ + \r\n\ + b\r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let mut body = "Foo Bar Baz".as_bytes(); + let res = http::handle() + .post(server::url("/"), &mut body) + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} + +#[test] +pub fn test_post_binary_with_reader_and_content_length() { + let srv = server!( + recv!(b"POST / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Length: 11\r\n\ + Content-Type: application/octet-stream\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let mut body = "Foo Bar Baz".as_bytes(); + let res = http::handle() + .post(server::url("/"), &mut body) + .content_length(11) + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} diff --git a/deps/curl-0.2.10/test/test_proxy.rs b/deps/curl-0.2.10/test/test_proxy.rs new file mode 100644 index 000000000..c4a63533e --- /dev/null +++ b/deps/curl-0.2.10/test/test_proxy.rs @@ -0,0 +1,30 @@ +use curl::http; +use super::server; + +#[test] +pub fn test_proxy() { + ::env_logger::init().unwrap(); + + let srv = server!( + recv!(b"POST http://www.google.com/ HTTP/1.1\r\n\ + Host: www.google.com\r\n\ + Accept: */*\r\n\ + Proxy-Connection: Keep-Alive\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n")); + + let res = http::handle() + .proxy(server::url("/")) + .post("http://www.google.com/", "Foo Bar Baz") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} diff --git a/deps/curl-0.2.10/test/test_put.rs b/deps/curl-0.2.10/test/test_put.rs new file mode 100644 index 000000000..5898a125b --- /dev/null +++ b/deps/curl-0.2.10/test/test_put.rs @@ -0,0 +1,53 @@ +use curl::http; +use super::server; + +#[test] +pub fn test_put_binary_with_slice() { + let srv = server!( + recv!(b"PUT / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/octet-stream\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .put(server::url("/"), "Foo Bar Baz") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} + +#[test] +pub fn test_put_binary_with_content_type() { + let srv = server!( + recv!(b"PUT / HTTP/1.1\r\n\ + Host: localhost:{PORT}\r\n\ + Accept: */*\r\n\ + Content-Type: application/foobar\r\n\ + Content-Length: 11\r\n\ + \r\n\ + Foo Bar Baz"), + send!(b"HTTP/1.1 200 OK\r\n\ + Content-Length: 5\r\n\r\n\ + Hello\r\n\r\n") + ); + + let res = http::handle() + .put(server::url("/"), "Foo Bar Baz") + .content_type("application/foobar") + .exec().unwrap(); + + srv.assert(); + + assert!(res.get_code() == 200); + assert!(res.get_body() == "Hello".as_bytes()); +} diff --git a/deps/curl-sys-0.1.24/Cargo.toml b/deps/curl-sys-0.1.24/Cargo.toml new file mode 100644 index 000000000..6e99e169e --- /dev/null +++ b/deps/curl-sys-0.1.24/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "curl-sys" +version = "0.1.24" +authors = ["Carl Lerche (match $e { + Ok(t) => t, + Err(e) => panic!("{} return the error {}", stringify!($e), e), + }) +} + +fn main() { + let target = env::var("TARGET").unwrap(); + let src = env::current_dir().unwrap(); + let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let windows = target.contains("windows"); + + // OSX ships libcurl by default, so we just use that version + // unconditionally. + if target.contains("apple") { + return println!("cargo:rustc-flags=-l curl"); + } + + // Next, fall back and try to use pkg-config if its available. + match pkg_config::find_library("libcurl") { + Ok(..) => return, + Err(..) => {} + } + + println!("cargo:rustc-link-search={}/lib", dst.display()); + println!("cargo:rustc-link-lib=static=curl"); + println!("cargo:root={}", dst.display()); + println!("cargo:include={}/include", dst.display()); + if windows { + println!("cargo:rustc-flags=-l ws2_32"); + } + + // MSVC builds are just totally different + if target.contains("msvc") { + return build_msvc(); + } + + let mut cflags = env::var("CFLAGS").unwrap_or(String::new()); + cflags.push_str(" -ffunction-sections -fdata-sections"); + + if target.contains("i686") { + cflags.push_str(" -m32"); + } else if target.contains("x86_64") { + cflags.push_str(" -m64"); + } + if !target.contains("i686") { + cflags.push_str(" -fPIC"); + } + + let _ = fs::create_dir(&dst.join("build")); + + let mut config_opts = Vec::new(); + if windows { + config_opts.push("--with-winssl".to_string()); + } else { + config_opts.push("--without-ca-bundle".to_string()); + config_opts.push("--without-ca-path".to_string()); + + match env::var("DEP_OPENSSL_ROOT") { + Ok(s) => config_opts.push(format!("--with-ssl={}", s)), + Err(..) => {} + } + } + config_opts.push("--enable-static=yes".to_string()); + config_opts.push("--enable-shared=no".to_string()); + config_opts.push("--enable-optimize".to_string()); + config_opts.push(format!("--prefix={}", dst.display())); + + config_opts.push("--without-librtmp".to_string()); + config_opts.push("--without-libidn".to_string()); + config_opts.push("--without-libssh2".to_string()); + config_opts.push("--without-nghttp2".to_string()); + config_opts.push("--disable-ldap".to_string()); + config_opts.push("--disable-ldaps".to_string()); + config_opts.push("--disable-ftp".to_string()); + config_opts.push("--disable-rtsp".to_string()); + config_opts.push("--disable-dict".to_string()); + config_opts.push("--disable-telnet".to_string()); + config_opts.push("--disable-tftp".to_string()); + config_opts.push("--disable-pop3".to_string()); + config_opts.push("--disable-imap".to_string()); + config_opts.push("--disable-smtp".to_string()); + config_opts.push("--disable-gopher".to_string()); + config_opts.push("--disable-manual".to_string()); + + // Can't run ./configure directly on msys2 b/c we're handing in + // Windows-style paths (those starting with C:\), but it chokes on those. + // For that reason we build up a shell script with paths converted to + // posix versions hopefully... + // + // Also apparently the buildbots choke unless we manually set LD, who knows + // why?! + run(Command::new("sh") + .env("CFLAGS", &cflags) + .env("LD", &which("ld").unwrap()) + .current_dir(&dst.join("build")) + .arg("-c") + .arg(&format!("{} {}", src.join("curl/configure").display(), + config_opts.connect(" ")) + .replace("C:\\", "/c/") + .replace("\\", "/"))); + run(Command::new(make()) + .arg(&format!("-j{}", env::var("NUM_JOBS").unwrap())) + .current_dir(&dst.join("build"))); + + // Don't run `make install` because apparently it's a little buggy on mingw + // for windows. + let _ = fs::create_dir_all(&dst.join("lib/pkgconfig")); + + // Which one does windows generate? Who knows! + let p1 = dst.join("build/lib/.libs/libcurl.a"); + let p2 = dst.join("build/lib/.libs/libcurl.lib"); + if fs::metadata(&p1).is_ok() { + t!(fs::copy(&p1, &dst.join("lib/libcurl.a"))); + } else { + t!(fs::copy(&p2, &dst.join("lib/libcurl.a"))); + } + t!(fs::copy(&dst.join("build/libcurl.pc"), + &dst.join("lib/pkgconfig/libcurl.pc"))); +} + +fn run(cmd: &mut Command) { + println!("running: {:?}", cmd); + assert!(t!(cmd.status()).success()); +} + +fn make() -> &'static str { + if cfg!(target_os = "freebsd") {"gmake"} else {"make"} +} + +fn which(cmd: &str) -> Option { + let cmd = format!("{}{}", cmd, env::consts::EXE_SUFFIX); + let paths = env::var_os("PATH").unwrap(); + env::split_paths(&paths).map(|p| p.join(&cmd)).find(|p| { + fs::metadata(p).is_ok() + }) +} + +fn build_msvc() { + let mut cmd = Command::new("nmake"); + let src = env::current_dir().unwrap(); + let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + + t!(fs::create_dir_all(dst.join("include/curl"))); + t!(fs::create_dir_all(dst.join("lib"))); + + cmd.current_dir(src.join("curl/winbuild")); + cmd.arg("/f").arg("Makefile.vc") + .arg("MODE=static") + .arg("MACHINE=x64") + .arg("ENABLE_IDN=yes") + .arg("DEBUG=no") + .arg("GEN_PDB=no") + .arg("ENABLE_WINSSL=yes") + .arg("ENABLE_SSPI=yes"); + if let Some(inc) = env::var_os("DEP_Z_ROOT") { + let inc = PathBuf::from(inc); + let mut s = OsString::from("WITH_DEVEL="); + s.push(&inc); + cmd.arg("WITH_ZLIB=static").arg(s); + + // the build system for curl expects this library to be called + // zlib_a.lib, so make sure it's named correctly (where libz-sys just + // produces zlib.lib) + let _ = fs::remove_file(&inc.join("lib/zlib_a.lib")); + t!(fs::hard_link(inc.join("lib/zlib.lib"), inc.join("lib/zlib_a.lib"))); + } + run(&mut cmd); + + let libs = src.join("curl/builds/libcurl-vc-x64-release-\ + static-zlib-\ + static-\ + ipv6-sspi-winssl"); + + t!(fs::copy(libs.join("lib/libcurl_a.lib"), dst.join("lib/curl.lib"))); + for f in t!(fs::read_dir(libs.join("include/curl"))) { + let path = t!(f).path(); + let dst = dst.join("include/curl").join(path.file_name().unwrap()); + t!(fs::copy(path, dst)); + } + t!(fs::remove_dir_all(src.join("curl/builds"))); + println!("cargo:rustc-link-lib=wldap32"); + println!("cargo:rustc-link-lib=advapi32"); + println!("cargo:rustc-link-lib=normaliz"); +} diff --git a/deps/curl-sys-0.1.24/lib.rs b/deps/curl-sys-0.1.24/lib.rs new file mode 100644 index 000000000..7cae355ac --- /dev/null +++ b/deps/curl-sys-0.1.24/lib.rs @@ -0,0 +1,483 @@ +#![allow(non_camel_case_types, raw_pointer_derive)] + +extern crate libc; +#[cfg(not(target_env = "msvc"))] extern crate libz_sys; +#[cfg(unix)] extern crate openssl_sys; + +use libc::{c_void, c_int, c_char, c_uint, c_long}; + +pub type CURLINFO = c_int; +pub type CURL = c_void; +pub type curl_slist = c_void; +pub type CURLoption = c_int; + +#[repr(C)] +#[derive(Clone, Copy)] +pub enum CURLversion { + CURL_VERSION_FIRST, + CURL_VERSION_SECOND, + CURL_VERSION_THIRD, + CURL_VERSION_FOURTH, + CURL_VERSION_LAST /* never actually use this */ +} + +#[repr(C)] +#[derive(Copy)] +pub struct curl_version_info_data { + pub age: CURLversion, + + pub version: *const c_char, + pub version_num: c_uint, + pub host: *const c_char, + pub features: c_int, + pub ssl_version: *const c_char, + + pub ssl_version_num: c_long, + + pub libz_version: *const c_char, + + /* protocols is terminated by an entry with a NULL protoname */ + pub protocols: *const *const c_char, + + /* The fields below this were added in CURL_VERSION_SECOND */ + pub ares: *const c_char, + pub ares_num: c_int, + + /* This field was added in CURL_VERSION_THIRD */ + pub libidn: *const c_char, + + /* These field were added in CURL_VERSION_FOURTH */ + pub iconv_ver_num: c_int, + pub libssh_version: *const c_char, +} + +impl Clone for curl_version_info_data { + fn clone(&self) -> Self { *self } +} + +pub const CURL_READFUNC_ABORT: c_int = 0x10000000; + +pub const CURLINFO_STRING: c_int = 0x100000; +pub const CURLINFO_LONG: c_int = 0x200000; +pub const CURLINFO_DOUBLE: c_int = 0x300000; +pub const CURLINFO_SLIST: c_int = 0x400000; +pub const CURLINFO_MASK: c_int = 0x0fffff; +pub const CURLINFO_TYPEMASK: c_int = 0xf00000; + +pub const CURLINFO_EFFECTIVE_URL: CURLINFO = CURLINFO_STRING + 1; +pub const CURLINFO_RESPONSE_CODE: CURLINFO = CURLINFO_LONG + 2; +pub const CURLINFO_TOTAL_TIME: CURLINFO = CURLINFO_DOUBLE + 5; + +pub const CURLOPTTYPE_LONG: c_int = 0; +pub const CURLOPTTYPE_OBJECTPOINT: c_int = 10_000; +pub const CURLOPTTYPE_FUNCTIONPOINT: c_int = 20_000; +pub const CURLOPTTYPE_OFF_T: c_int = 30_000; + +pub const CURL_VERSION_NOW: CURLversion = CURLversion::CURL_VERSION_FOURTH; +pub const CURL_VERSION_IPV6: c_int = (1 << 0); +pub const CURL_VERSION_KERBEROS4: c_int = (1 << 1); +pub const CURL_VERSION_SSL: c_int = (1 << 2); +pub const CURL_VERSION_LIBZ: c_int = (1 << 3); +pub const CURL_VERSION_NTLM: c_int = (1 << 4); +pub const CURL_VERSION_GSSNEGOTIATE: c_int = (1 << 5); +pub const CURL_VERSION_DEBUG: c_int = (1 << 6); +pub const CURL_VERSION_ASYNCHDNS: c_int = (1 << 7); +pub const CURL_VERSION_SPNEGO: c_int = (1 << 8); +pub const CURL_VERSION_LARGEFILE: c_int = (1 << 9); +pub const CURL_VERSION_IDN: c_int = (1 << 10); +pub const CURL_VERSION_SSPI: c_int = (1 << 11); +pub const CURL_VERSION_CONV: c_int = (1 << 12); +pub const CURL_VERSION_CURLDEBUG: c_int = (1 << 13); +pub const CURL_VERSION_TLSAUTH_SRP: c_int = (1 << 14); +pub const CURL_VERSION_NTLM_WB: c_int = (1 << 15); +pub const CURL_VERSION_HTTP2: c_int = (1 << 16); + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub enum CURLcode { + CURLE_OK = 0, + CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ + CURLE_FAILED_INIT, /* 2 */ + CURLE_URL_MALFORMAT, /* 3 */ + CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for + 7.17.0, reused in April 2011 for 7.21.5] */ + CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ + CURLE_COULDNT_RESOLVE_HOST, /* 6 */ + CURLE_COULDNT_CONNECT, /* 7 */ + CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ + CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server + due to lack of access - when login fails + this is not returned. */ + CURLE_FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for + 7.15.4, reused in Dec 2011 for 7.24.0]*/ + CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ + CURLE_FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server + [was obsoleted in August 2007 for 7.17.0, + reused in Dec 2011 for 7.24.0]*/ + CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ + CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ + CURLE_FTP_CANT_GET_HOST, /* 15 */ + CURLE_OBSOLETE16, /* 16 - NOT USED */ + CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ + CURLE_PARTIAL_FILE, /* 18 */ + CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ + CURLE_OBSOLETE20, /* 20 - NOT USED */ + CURLE_QUOTE_ERROR, /* 21 - quote command failure */ + CURLE_HTTP_RETURNED_ERROR, /* 22 */ + CURLE_WRITE_ERROR, /* 23 */ + CURLE_OBSOLETE24, /* 24 - NOT USED */ + CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ + CURLE_READ_ERROR, /* 26 - couldn't open/read from file */ + CURLE_OUT_OF_MEMORY, /* 27 */ + /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error + instead of a memory allocation error if CURL_DOES_CONVERSIONS + is defined + */ + CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ + CURLE_OBSOLETE29, /* 29 - NOT USED */ + CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ + CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ + CURLE_OBSOLETE32, /* 32 - NOT USED */ + CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ + CURLE_HTTP_POST_ERROR, /* 34 */ + CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ + CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ + CURLE_FILE_COULDNT_READ_FILE, /* 37 */ + CURLE_LDAP_CANNOT_BIND, /* 38 */ + CURLE_LDAP_SEARCH_FAILED, /* 39 */ + CURLE_OBSOLETE40, /* 40 - NOT USED */ + CURLE_FUNCTION_NOT_FOUND, /* 41 */ + CURLE_ABORTED_BY_CALLBACK, /* 42 */ + CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ + CURLE_OBSOLETE44, /* 44 - NOT USED */ + CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ + CURLE_OBSOLETE46, /* 46 - NOT USED */ + CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ + CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ + CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ + CURLE_OBSOLETE50, /* 50 - NOT USED */ + CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint + wasn't verified fine */ + CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ + CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ + CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as + default */ + CURLE_SEND_ERROR, /* 55 - failed sending network data */ + CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ + CURLE_OBSOLETE57, /* 57 - NOT IN USE */ + CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ + CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ + CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ + CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ + CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ + CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ + CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ + CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind + that failed */ + CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ + CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not + accepted and we failed to login */ + CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ + CURLE_TFTP_PERM, /* 69 - permission problem on server */ + CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ + CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ + CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ + CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ + CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ + CURLE_CONV_FAILED, /* 75 - conversion failed */ + CURLE_CONV_REQD, /* 76 - caller must register conversion + callbacks using curl_easy_setopt options + CURLOPT_CONV_FROM_NETWORK_FUNCTION, + CURLOPT_CONV_TO_NETWORK_FUNCTION, and + CURLOPT_CONV_FROM_UTF8_FUNCTION */ + CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing + or wrong format */ + CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ + CURLE_SSH, /* 79 - error from the SSH layer, somewhat + generic so the error message will be of + interest when this has happened */ + + CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL + connection */ + CURLE_AGAIN, /* 81 - socket is not ready for send/recv, + wait till it's ready and try again (Added + in 7.18.2) */ + CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or + wrong format (Added in 7.19.0) */ + CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in + 7.19.0) */ + CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ + CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ + CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ + CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ + CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ + CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the + session will be queued */ + CURLE_LAST /* never use! */ +} + +macro_rules! DEFOPT { + ($name:ident, $ty:ident, $num:expr) => ( + #[allow(dead_code)] + pub const $name: CURLoption = $ty + $num; + ) +} + +macro_rules! ALIAS { + ($name:ident, $to:ident) => ( + #[allow(dead_code)] + pub const $name: CURLoption = $to; + ) +} + +DEFOPT!(CURLOPT_FILE, CURLOPTTYPE_OBJECTPOINT, 1); +DEFOPT!(CURLOPT_URL, CURLOPTTYPE_OBJECTPOINT, 2); +DEFOPT!(CURLOPT_PORT, CURLOPTTYPE_LONG, 3); +DEFOPT!(CURLOPT_PROXY, CURLOPTTYPE_OBJECTPOINT, 4); +DEFOPT!(CURLOPT_USERPWD, CURLOPTTYPE_OBJECTPOINT, 5); +DEFOPT!(CURLOPT_PROXYUSERPWD, CURLOPTTYPE_OBJECTPOINT, 6); +DEFOPT!(CURLOPT_RANGE, CURLOPTTYPE_OBJECTPOINT, 7); +/* 8: not used */ +DEFOPT!(CURLOPT_INFILE, CURLOPTTYPE_OBJECTPOINT, 9); +DEFOPT!(CURLOPT_ERRORBUFFER, CURLOPTTYPE_OBJECTPOINT, 10); +DEFOPT!(CURLOPT_WRITEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 11); +DEFOPT!(CURLOPT_READFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 12); +DEFOPT!(CURLOPT_TIMEOUT, CURLOPTTYPE_LONG, 13); +DEFOPT!(CURLOPT_INFILESIZE, CURLOPTTYPE_LONG, 14); +DEFOPT!(CURLOPT_POSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 15); +DEFOPT!(CURLOPT_REFERER, CURLOPTTYPE_OBJECTPOINT, 16); +DEFOPT!(CURLOPT_FTPPORT, CURLOPTTYPE_OBJECTPOINT, 17); +DEFOPT!(CURLOPT_USERAGENT, CURLOPTTYPE_OBJECTPOINT, 18); +DEFOPT!(CURLOPT_LOW_SPEED_LIMIT, CURLOPTTYPE_LONG, 19); +DEFOPT!(CURLOPT_LOW_SPEED_TIME, CURLOPTTYPE_LONG, 20); +DEFOPT!(CURLOPT_RESUME_FROM, CURLOPTTYPE_LONG, 21); +DEFOPT!(CURLOPT_COOKIE, CURLOPTTYPE_OBJECTPOINT, 22); +DEFOPT!(CURLOPT_HTTPHEADER, CURLOPTTYPE_OBJECTPOINT, 23); +DEFOPT!(CURLOPT_HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24); +DEFOPT!(CURLOPT_SSLCERT, CURLOPTTYPE_OBJECTPOINT, 25); +DEFOPT!(CURLOPT_KEYPASSWD, CURLOPTTYPE_OBJECTPOINT, 26); +DEFOPT!(CURLOPT_CRLF, CURLOPTTYPE_LONG, 27); +DEFOPT!(CURLOPT_QUOTE, CURLOPTTYPE_OBJECTPOINT, 28); +DEFOPT!(CURLOPT_WRITEHEADER, CURLOPTTYPE_OBJECTPOINT, 29); +/* 30: not used */ +DEFOPT!(CURLOPT_COOKIEFILE, CURLOPTTYPE_OBJECTPOINT, 31); +DEFOPT!(CURLOPT_SSLVERSION, CURLOPTTYPE_LONG, 32); +DEFOPT!(CURLOPT_TIMECONDITION, CURLOPTTYPE_LONG, 33); +DEFOPT!(CURLOPT_TIMEVALUE, CURLOPTTYPE_LONG, 34); +/* 35: not used */ +DEFOPT!(CURLOPT_CUSTOMREQUEST, CURLOPTTYPE_OBJECTPOINT, 36); +DEFOPT!(CURLOPT_STDERR, CURLOPTTYPE_OBJECTPOINT, 37); +/* 38: not used */ +DEFOPT!(CURLOPT_POSTQUOTE, CURLOPTTYPE_OBJECTPOINT, 39); +DEFOPT!(CURLOPT_WRITEINFO, CURLOPTTYPE_OBJECTPOINT, 40); +DEFOPT!(CURLOPT_VERBOSE, CURLOPTTYPE_LONG, 41); +DEFOPT!(CURLOPT_HEADER, CURLOPTTYPE_LONG, 42); +DEFOPT!(CURLOPT_NOPROGRESS, CURLOPTTYPE_LONG, 43); +DEFOPT!(CURLOPT_NOBODY, CURLOPTTYPE_LONG, 44); +DEFOPT!(CURLOPT_FAILONERROR, CURLOPTTYPE_LONG, 45); +DEFOPT!(CURLOPT_UPLOAD, CURLOPTTYPE_LONG, 46); +DEFOPT!(CURLOPT_POST, CURLOPTTYPE_LONG, 47); +DEFOPT!(CURLOPT_DIRLISTONLY, CURLOPTTYPE_LONG, 48); +DEFOPT!(CURLOPT_APPEND, CURLOPTTYPE_LONG, 50); +DEFOPT!(CURLOPT_NETRC, CURLOPTTYPE_LONG, 51); +DEFOPT!(CURLOPT_FOLLOWLOCATION, CURLOPTTYPE_LONG, 52); +DEFOPT!(CURLOPT_TRANSFERTEXT, CURLOPTTYPE_LONG, 53); +DEFOPT!(CURLOPT_PUT, CURLOPTTYPE_LONG, 54); +/* 55: not used */ +DEFOPT!(CURLOPT_PROGRESSFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 56); +DEFOPT!(CURLOPT_PROGRESSDATA, CURLOPTTYPE_OBJECTPOINT, 57); +DEFOPT!(CURLOPT_AUTOREFERER, CURLOPTTYPE_LONG, 58); +DEFOPT!(CURLOPT_PROXYPORT, CURLOPTTYPE_LONG, 59); +DEFOPT!(CURLOPT_POSTFIELDSIZE, CURLOPTTYPE_LONG, 60); +DEFOPT!(CURLOPT_HTTPPROXYTUNNEL, CURLOPTTYPE_LONG, 61); +DEFOPT!(CURLOPT_INTERFACE, CURLOPTTYPE_OBJECTPOINT, 62); +DEFOPT!(CURLOPT_KRBLEVEL, CURLOPTTYPE_OBJECTPOINT, 63); +DEFOPT!(CURLOPT_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 64); +DEFOPT!(CURLOPT_CAINFO, CURLOPTTYPE_OBJECTPOINT, 65); +/* 66: not used */ +/* 67: not used */ +DEFOPT!(CURLOPT_MAXREDIRS, CURLOPTTYPE_LONG, 68); +DEFOPT!(CURLOPT_FILETIME, CURLOPTTYPE_LONG, 69); +DEFOPT!(CURLOPT_TELNETOPTIONS, CURLOPTTYPE_OBJECTPOINT, 70); +DEFOPT!(CURLOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 71); +DEFOPT!(CURLOPT_CLOSEPOLICY, CURLOPTTYPE_LONG, 72); +/* 73: not used */ +DEFOPT!(CURLOPT_FRESH_CONNECT, CURLOPTTYPE_LONG, 74); +DEFOPT!(CURLOPT_FORBID_REUSE, CURLOPTTYPE_LONG, 75); +DEFOPT!(CURLOPT_RANDOM_FILE, CURLOPTTYPE_OBJECTPOINT, 76); +DEFOPT!(CURLOPT_EGDSOCKET, CURLOPTTYPE_OBJECTPOINT, 77); +DEFOPT!(CURLOPT_CONNECTTIMEOUT, CURLOPTTYPE_LONG, 78); +DEFOPT!(CURLOPT_HEADERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 79); +DEFOPT!(CURLOPT_HTTPGET, CURLOPTTYPE_LONG, 80); +DEFOPT!(CURLOPT_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 81); +DEFOPT!(CURLOPT_COOKIEJAR, CURLOPTTYPE_OBJECTPOINT, 82); +DEFOPT!(CURLOPT_SSL_CIPHER_LIST, CURLOPTTYPE_OBJECTPOINT, 83); +DEFOPT!(CURLOPT_HTTP_VERSION, CURLOPTTYPE_LONG, 84); +DEFOPT!(CURLOPT_FTP_USE_EPSV, CURLOPTTYPE_LONG, 85); +DEFOPT!(CURLOPT_SSLCERTTYPE, CURLOPTTYPE_OBJECTPOINT, 86); +DEFOPT!(CURLOPT_SSLKEY, CURLOPTTYPE_OBJECTPOINT, 87); +DEFOPT!(CURLOPT_SSLKEYTYPE, CURLOPTTYPE_OBJECTPOINT, 88); +DEFOPT!(CURLOPT_SSLENGINE, CURLOPTTYPE_OBJECTPOINT, 89); +DEFOPT!(CURLOPT_SSLENGINE_DEFAULT, CURLOPTTYPE_LONG, 90); +DEFOPT!(CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOPTTYPE_LONG, 91); +DEFOPT!(CURLOPT_DNS_CACHE_TIMEOUT, CURLOPTTYPE_LONG, 92); +DEFOPT!(CURLOPT_PREQUOTE, CURLOPTTYPE_OBJECTPOINT, 93); +DEFOPT!(CURLOPT_DEBUGFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 94); +DEFOPT!(CURLOPT_DEBUGDATA, CURLOPTTYPE_OBJECTPOINT, 95); +DEFOPT!(CURLOPT_COOKIESESSION, CURLOPTTYPE_LONG, 96); +DEFOPT!(CURLOPT_CAPATH, CURLOPTTYPE_OBJECTPOINT, 97); +DEFOPT!(CURLOPT_BUFFERSIZE, CURLOPTTYPE_LONG, 98); +DEFOPT!(CURLOPT_NOSIGNAL, CURLOPTTYPE_LONG, 99); +DEFOPT!(CURLOPT_SHARE, CURLOPTTYPE_OBJECTPOINT, 100); +DEFOPT!(CURLOPT_PROXYTYPE, CURLOPTTYPE_LONG, 101); +DEFOPT!(CURLOPT_ACCEPT_ENCODING, CURLOPTTYPE_OBJECTPOINT, 102); +DEFOPT!(CURLOPT_PRIVATE, CURLOPTTYPE_OBJECTPOINT, 103); +DEFOPT!(CURLOPT_HTTP200ALIASES, CURLOPTTYPE_OBJECTPOINT, 104); +DEFOPT!(CURLOPT_UNRESTRICTED_AUTH, CURLOPTTYPE_LONG, 105); +DEFOPT!(CURLOPT_FTP_USE_EPRT, CURLOPTTYPE_LONG, 106); +DEFOPT!(CURLOPT_HTTPAUTH, CURLOPTTYPE_LONG, 107); +DEFOPT!(CURLOPT_SSL_CTX_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 108); +DEFOPT!(CURLOPT_SSL_CTX_DATA, CURLOPTTYPE_OBJECTPOINT, 109); +DEFOPT!(CURLOPT_FTP_CREATE_MISSING_DIRS, CURLOPTTYPE_LONG, 110); +DEFOPT!(CURLOPT_PROXYAUTH, CURLOPTTYPE_LONG, 111); +DEFOPT!(CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOPTTYPE_LONG, 112); +DEFOPT!(CURLOPT_IPRESOLVE, CURLOPTTYPE_LONG, 113); +DEFOPT!(CURLOPT_MAXFILESIZE, CURLOPTTYPE_LONG, 114); +DEFOPT!(CURLOPT_INFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 115); +DEFOPT!(CURLOPT_RESUME_FROM_LARGE, CURLOPTTYPE_OFF_T, 116); +DEFOPT!(CURLOPT_MAXFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 117); +DEFOPT!(CURLOPT_NETRC_FILE, CURLOPTTYPE_OBJECTPOINT, 118); +DEFOPT!(CURLOPT_USE_SSL, CURLOPTTYPE_LONG, 119); +DEFOPT!(CURLOPT_POSTFIELDSIZE_LARGE, CURLOPTTYPE_OFF_T, 120); +DEFOPT!(CURLOPT_TCP_NODELAY, CURLOPTTYPE_LONG, 121); +/* 122 - 128: not used */ +DEFOPT!(CURLOPT_FTPSSLAUTH, CURLOPTTYPE_LONG, 129); +DEFOPT!(CURLOPT_IOCTLFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 130); +DEFOPT!(CURLOPT_IOCTLDATA, CURLOPTTYPE_OBJECTPOINT, 131); +/* 132, CURLOPTTYPE_133: not used */ +DEFOPT!(CURLOPT_FTP_ACCOUNT, CURLOPTTYPE_OBJECTPOINT, 134); +DEFOPT!(CURLOPT_COOKIELIST, CURLOPTTYPE_OBJECTPOINT, 135); +DEFOPT!(CURLOPT_IGNORE_CONTENT_LENGTH, CURLOPTTYPE_LONG, 136); +DEFOPT!(CURLOPT_FTP_SKIP_PASV_IP, CURLOPTTYPE_LONG, 137); +DEFOPT!(CURLOPT_FTP_FILEMETHOD, CURLOPTTYPE_LONG, 138); +DEFOPT!(CURLOPT_LOCALPORT, CURLOPTTYPE_LONG, 139); +DEFOPT!(CURLOPT_LOCALPORTRANGE, CURLOPTTYPE_LONG, 140); +DEFOPT!(CURLOPT_CONNECT_ONLY, CURLOPTTYPE_LONG, 141); +DEFOPT!(CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 142); +DEFOPT!(CURLOPT_CONV_TO_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 143); +DEFOPT!(CURLOPT_CONV_FROM_UTF8_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 144); +DEFOPT!(CURLOPT_MAX_SEND_SPEED_LARGE, CURLOPTTYPE_OFF_T, 145); +DEFOPT!(CURLOPT_MAX_RECV_SPEED_LARGE, CURLOPTTYPE_OFF_T, 146); +DEFOPT!(CURLOPT_FTP_ALTERNATIVE_TO_USER, CURLOPTTYPE_OBJECTPOINT, 147); +DEFOPT!(CURLOPT_SOCKOPTFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 148); +DEFOPT!(CURLOPT_SOCKOPTDATA, CURLOPTTYPE_OBJECTPOINT, 149); +DEFOPT!(CURLOPT_SSL_SESSIONID_CACHE, CURLOPTTYPE_LONG, 150); +DEFOPT!(CURLOPT_SSH_AUTH_TYPES, CURLOPTTYPE_LONG, 151); +DEFOPT!(CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPTTYPE_OBJECTPOINT, 152); +DEFOPT!(CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPTTYPE_OBJECTPOINT, 153); +DEFOPT!(CURLOPT_FTP_SSL_CCC, CURLOPTTYPE_LONG, 154); +DEFOPT!(CURLOPT_TIMEOUT_MS, CURLOPTTYPE_LONG, 155); +DEFOPT!(CURLOPT_CONNECTTIMEOUT_MS, CURLOPTTYPE_LONG, 156); +DEFOPT!(CURLOPT_HTTP_TRANSFER_DECODING, CURLOPTTYPE_LONG, 157); +DEFOPT!(CURLOPT_HTTP_CONTENT_DECODING, CURLOPTTYPE_LONG, 158); +DEFOPT!(CURLOPT_NEW_FILE_PERMS, CURLOPTTYPE_LONG, 159); +DEFOPT!(CURLOPT_NEW_DIRECTORY_PERMS, CURLOPTTYPE_LONG, 160); +DEFOPT!(CURLOPT_POSTREDIR, CURLOPTTYPE_LONG, 161); +DEFOPT!(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, CURLOPTTYPE_OBJECTPOINT, 162); +DEFOPT!(CURLOPT_OPENSOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 163); +DEFOPT!(CURLOPT_OPENSOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 164); +DEFOPT!(CURLOPT_COPYPOSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 165); +DEFOPT!(CURLOPT_PROXY_TRANSFER_MODE, CURLOPTTYPE_LONG, 166); +DEFOPT!(CURLOPT_SEEKFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 167); +DEFOPT!(CURLOPT_SEEKDATA, CURLOPTTYPE_OBJECTPOINT, 168); +DEFOPT!(CURLOPT_CRLFILE, CURLOPTTYPE_OBJECTPOINT, 169); +DEFOPT!(CURLOPT_ISSUERCERT, CURLOPTTYPE_OBJECTPOINT, 170); +DEFOPT!(CURLOPT_ADDRESS_SCOPE, CURLOPTTYPE_LONG, 171); +DEFOPT!(CURLOPT_CERTINFO, CURLOPTTYPE_LONG, 172); +DEFOPT!(CURLOPT_USERNAME, CURLOPTTYPE_OBJECTPOINT, 173); +DEFOPT!(CURLOPT_PASSWORD, CURLOPTTYPE_OBJECTPOINT, 174); +DEFOPT!(CURLOPT_PROXYUSERNAME, CURLOPTTYPE_OBJECTPOINT, 175); +DEFOPT!(CURLOPT_PROXYPASSWORD, CURLOPTTYPE_OBJECTPOINT, 176); +DEFOPT!(CURLOPT_NOPROXY, CURLOPTTYPE_OBJECTPOINT, 177); +DEFOPT!(CURLOPT_TFTP_BLKSIZE, CURLOPTTYPE_LONG, 178); +DEFOPT!(CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOPTTYPE_OBJECTPOINT, 179); +DEFOPT!(CURLOPT_SOCKS5_GSSAPI_NEC, CURLOPTTYPE_LONG, 180); +DEFOPT!(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181); +DEFOPT!(CURLOPT_REDIR_PROTOCOLS, CURLOPTTYPE_LONG, 182); +DEFOPT!(CURLOPT_SSH_KNOWNHOSTS, CURLOPTTYPE_OBJECTPOINT, 183); +DEFOPT!(CURLOPT_SSH_KEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 184); +DEFOPT!(CURLOPT_SSH_KEYDATA, CURLOPTTYPE_OBJECTPOINT, 185); +DEFOPT!(CURLOPT_MAIL_FROM, CURLOPTTYPE_OBJECTPOINT, 186); +DEFOPT!(CURLOPT_MAIL_RCPT, CURLOPTTYPE_OBJECTPOINT, 187); +DEFOPT!(CURLOPT_FTP_USE_PRET, CURLOPTTYPE_LONG, 188); +DEFOPT!(CURLOPT_RTSP_REQUEST, CURLOPTTYPE_LONG, 189); +DEFOPT!(CURLOPT_RTSP_SESSION_ID, CURLOPTTYPE_OBJECTPOINT, 190); +DEFOPT!(CURLOPT_RTSP_STREAM_URI, CURLOPTTYPE_OBJECTPOINT, 191); +DEFOPT!(CURLOPT_RTSP_TRANSPORT, CURLOPTTYPE_OBJECTPOINT, 192); +DEFOPT!(CURLOPT_RTSP_CLIENT_CSEQ, CURLOPTTYPE_LONG, 193); +DEFOPT!(CURLOPT_RTSP_SERVER_CSEQ, CURLOPTTYPE_LONG, 194); +DEFOPT!(CURLOPT_INTERLEAVEDATA, CURLOPTTYPE_OBJECTPOINT, 195); +DEFOPT!(CURLOPT_INTERLEAVEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 196); +DEFOPT!(CURLOPT_WILDCARDMATCH, CURLOPTTYPE_LONG, 197); +DEFOPT!(CURLOPT_CHUNK_BGN_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 198); +DEFOPT!(CURLOPT_CHUNK_END_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 199); +DEFOPT!(CURLOPT_FNMATCH_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 200); +DEFOPT!(CURLOPT_CHUNK_DATA, CURLOPTTYPE_OBJECTPOINT, 201); +DEFOPT!(CURLOPT_FNMATCH_DATA, CURLOPTTYPE_OBJECTPOINT, 202); +DEFOPT!(CURLOPT_RESOLVE, CURLOPTTYPE_OBJECTPOINT, 203); +DEFOPT!(CURLOPT_TLSAUTH_USERNAME, CURLOPTTYPE_OBJECTPOINT, 204); +DEFOPT!(CURLOPT_TLSAUTH_PASSWORD, CURLOPTTYPE_OBJECTPOINT, 205); +DEFOPT!(CURLOPT_TLSAUTH_TYPE, CURLOPTTYPE_OBJECTPOINT, 206); +DEFOPT!(CURLOPT_TRANSFER_ENCODING, CURLOPTTYPE_LONG, 207); +DEFOPT!(CURLOPT_CLOSESOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 208); +DEFOPT!(CURLOPT_CLOSESOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 209); +DEFOPT!(CURLOPT_GSSAPI_DELEGATION, CURLOPTTYPE_LONG, 210); +DEFOPT!(CURLOPT_DNS_SERVERS, CURLOPTTYPE_OBJECTPOINT, 211); +DEFOPT!(CURLOPT_ACCEPTTIMEOUT_MS, CURLOPTTYPE_LONG, 212); +DEFOPT!(CURLOPT_TCP_KEEPALIVE, CURLOPTTYPE_LONG, 213); +DEFOPT!(CURLOPT_TCP_KEEPIDLE, CURLOPTTYPE_LONG, 214); +DEFOPT!(CURLOPT_TCP_KEEPINTVL, CURLOPTTYPE_LONG, 215); +DEFOPT!(CURLOPT_SSL_OPTIONS, CURLOPTTYPE_LONG, 216); +DEFOPT!(CURLOPT_MAIL_AUTH, CURLOPTTYPE_OBJECTPOINT, 217); +DEFOPT!(CURLOPT_SASL_IR, CURLOPTTYPE_LONG, 218); +DEFOPT!(CURLOPT_XFERINFOFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 219); +DEFOPT!(CURLOPT_XOAUTH2_BEARER, CURLOPTTYPE_OBJECTPOINT, 220); +DEFOPT!(CURLOPT_DNS_INTERFACE, CURLOPTTYPE_OBJECTPOINT, 221); +DEFOPT!(CURLOPT_DNS_LOCAL_IP4, CURLOPTTYPE_OBJECTPOINT, 222); +DEFOPT!(CURLOPT_DNS_LOCAL_IP6, CURLOPTTYPE_OBJECTPOINT, 223); +DEFOPT!(CURLOPT_LOGIN_OPTIONS, CURLOPTTYPE_OBJECTPOINT, 224); +DEFOPT!(CURLOPT_SSL_ENABLE_NPN, CURLOPTTYPE_LONG, 225); +DEFOPT!(CURLOPT_SSL_ENABLE_ALPN, CURLOPTTYPE_LONG, 226); +DEFOPT!(CURLOPT_EXPECT_100_TIMEOUT_MS, CURLOPTTYPE_LONG, 227); +DEFOPT!(CURLOPT_PROXYHEADER, CURLOPTTYPE_OBJECTPOINT, 228); +DEFOPT!(CURLOPT_HEADEROPT, CURLOPTTYPE_LONG, 229); + +// Option aliases +ALIAS!(CURLOPT_POST301, CURLOPT_POSTREDIR); +ALIAS!(CURLOPT_SSLKEYPASSWD, CURLOPT_KEYPASSWD); +ALIAS!(CURLOPT_FTPAPPEND, CURLOPT_APPEND); +ALIAS!(CURLOPT_FTPLISTONLY, CURLOPT_DIRLISTONLY); +ALIAS!(CURLOPT_FTP_SSL, CURLOPT_USE_SSL); +ALIAS!(CURLOPT_SSLCERTPASSWD, CURLOPT_KEYPASSWD); +ALIAS!(CURLOPT_KRB4LEVEL, CURLOPT_KRBLEVEL); +ALIAS!(CURLOPT_READDATA, CURLOPT_INFILE); +ALIAS!(CURLOPT_WRITEDATA, CURLOPT_FILE); +ALIAS!(CURLOPT_HEADERDATA, CURLOPT_WRITEHEADER); +ALIAS!(CURLOPT_XFERINFODATA, CURLOPT_PROGRESSDATA); + +extern { + pub fn curl_easy_strerror(code: CURLcode) -> *const c_char; + pub fn curl_easy_init() -> *mut CURL; + pub fn curl_easy_setopt(curl: *mut CURL, option: CURLoption, ...) -> CURLcode; + pub fn curl_easy_perform(curl: *mut CURL) -> CURLcode; + pub fn curl_easy_cleanup(curl: *mut CURL); + pub fn curl_easy_getinfo(curl: *const CURL, info: CURLINFO, ...) -> CURLcode; + pub fn curl_global_cleanup(); + + pub fn curl_slist_append(list: *mut curl_slist, + val: *const u8) -> *mut curl_slist; + pub fn curl_slist_free_all(list: *mut curl_slist); + + pub fn curl_version() -> *const c_char; + pub fn curl_version_info(t: CURLversion) -> *mut curl_version_info_data; +} diff --git a/deps/docopt-0.6.67/.gitignore b/deps/docopt-0.6.67/.gitignore new file mode 100644 index 000000000..0c6e64e41 --- /dev/null +++ b/deps/docopt-0.6.67/.gitignore @@ -0,0 +1,6 @@ +.*.swp +doc +tags +target +scratch* +Cargo.lock diff --git a/deps/docopt-0.6.67/.travis.yml b/deps/docopt-0.6.67/.travis.yml new file mode 100644 index 000000000..5121b10b9 --- /dev/null +++ b/deps/docopt-0.6.67/.travis.yml @@ -0,0 +1,17 @@ +language: rust + +matrix: + include: + - rust: "nightly" + env: TEST_SUITE=suite_nightly + - rust: "beta" + env: TEST_SUITE=suite_beta + +script: + - cargo build --verbose + - cargo test --verbose + - if [ "$TEST_SUITE" == "suite_nightly" ]; then + cd docopt_macros; + cargo build --verbose; + cargo test --verbose; + fi diff --git a/deps/docopt-0.6.67/COPYING b/deps/docopt-0.6.67/COPYING new file mode 100644 index 000000000..bb9c20a09 --- /dev/null +++ b/deps/docopt-0.6.67/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/deps/docopt-0.6.67/Cargo.toml b/deps/docopt-0.6.67/Cargo.toml new file mode 100644 index 000000000..8c2f8fe58 --- /dev/null +++ b/deps/docopt-0.6.67/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "docopt" +version = "0.6.67" #:version +authors = ["Andrew Gallant "] +description = "Command line argument parsing." +documentation = "http://burntsushi.net/rustdoc/docopt/" +homepage = "https://github.com/docopt/docopt.rs" +repository = "https://github.com/docopt/docopt.rs" +readme = "README.md" +keywords = ["docopt", "argument", "command", "argv"] +license = "Unlicense/MIT" + +[lib] +name = "docopt" + +[[bin]] +name = "docopt-wordlist" +path = "src/wordlist.rs" +doc = false +test = false + +[dependencies] +regex = "*" +rustc-serialize = "0.3" +strsim = "0.3" diff --git a/deps/docopt-0.6.67/LICENSE-MIT b/deps/docopt-0.6.67/LICENSE-MIT new file mode 100644 index 000000000..3b0a5dc09 --- /dev/null +++ b/deps/docopt-0.6.67/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/docopt-0.6.67/Makefile b/deps/docopt-0.6.67/Makefile new file mode 100644 index 000000000..30ededbf0 --- /dev/null +++ b/deps/docopt-0.6.67/Makefile @@ -0,0 +1,18 @@ +all: + @echo Nothing to do + +docs: $(LIB_FILES) + cargo doc + # WTF is rustdoc doing? + in-dir ./target/doc fix-perms + rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/ + +src/test/testcases.rs: src/test/testcases.docopt scripts/mk-testcases + ./scripts/mk-testcases ./src/test/testcases.docopt > ./src/test/testcases.rs + +ctags: + ctags --recurse --options=ctags.rust --languages=Rust + +push: + git push github master + git push origin master diff --git a/deps/docopt-0.6.67/README.md b/deps/docopt-0.6.67/README.md new file mode 100644 index 000000000..0ab548f31 --- /dev/null +++ b/deps/docopt-0.6.67/README.md @@ -0,0 +1,314 @@ +Docopt for Rust with automatic type based decoding (i.e., data validation). +This implementation conforms to the +[official description of Docopt](http://docopt.org/) and +[passes its test suite](https://github.com/docopt/docopt/pull/201). + +[![Build status](https://api.travis-ci.org/docopt/docopt.rs.svg)](https://travis-ci.org/docopt/docopt.rs) +[![](http://meritbadge.herokuapp.com/docopt)](https://crates.io/crates/docopt) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Current status + +Fully functional but the design of the API is up for debate. **I am seeking +feedback**. + + +### Documentation + +[http://burntsushi.net/rustdoc/docopt](http://burntsushi.net/rustdoc/docopt/index.html) + + +### Installation + +This crate is fully compatible with Cargo. Just add it to your `Cargo.toml`: + +```toml +[dependencies] +docopt = "*" +rustc-serialize = "*" # if you're using `derive(RustcDecodable)` +``` + +If you want to use the macro (which won't work when Rust 1.0 stable is +released, but will continue to work on the nightlies), then use `docopt_macros += "*"` instead. + + +### Quick example + +Here is a full working example: + +```rust +extern crate rustc_serialize; +extern crate docopt; + +use docopt::Docopt; + +// Write the Docopt usage string. +static USAGE: &'static str = " +Usage: cp [-a] + cp [-a] ... + +Options: + -a, --archive Copy everything. +"; + +#[derive(RustcDecodable, Debug)] +struct Args { + arg_source: Vec, + arg_dest: String, + arg_dir: String, + flag_archive: bool, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} +``` + +Here is the same example, but with the use of the `docopt!` macro, which will +*generate a struct for you*: + +```rust +#![feature(plugin)] +#![plugin(docopt_macros)] + +extern crate rustc_serialize; + +extern crate docopt; + +docopt!(Args derive Debug, " +Usage: cp [options] + cp [options] ... + cp --help + +Options: + -h, --help Show this message. + -a, --archive Copy everything. +"); + +fn main() { + let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} +``` + +The field names of the struct map like this: + +``` +-g => flag_g +--group => flag_group +--group => flag_group +FILE => arg_FILE + => arg_file +build => cmd_build +``` + +The `Args` struct has one static method defined for it: `docopt`. The method +returns a normal `Docopt` value, which can be used to set configuration +options, `argv` and parse or decode command line arguments. + + +### Data validation example + +Here's another example that shows how to specify the types of your arguments: + +```rust +#![feature(plugin)] +#![plugin(docopt_macros)] + +extern crate rustc_serialize; + +extern crate docopt; + +docopt!(Args, "Usage: add ", arg_x: usize, arg_y: usize); + +fn main() { + let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); + println!("x: {}, y: {}", args.arg_x, args.arg_y); +} +``` + +In this example, specific type annotations were added. They will be +automatically inserted into the generated struct. You can override as many (or +as few) fields as you want. If you don't specify a type, then one of `bool`, +`uint`, `String` or `Vec` will be chosen depending on the type of +argument. In this case, both `arg_x` and `arg_y` would have been `String`. + +If any value cannot be decoded into a value with the right type, then an error +will be shown to the user. + +And of course, you don't need the macro to do this. You can do the same thing +with a manually written struct too. + + +### Modeling `rustc` + +Here's a selected subset for some of `rustc`'s options. This also shows how to +restrict values to a list of choices via an `enum` type and demonstrates more +Docopt features. + +```rust +#![feature(plugin)] +#![plugin(docopt_macros)] + +extern crate rustc_serialize; + +extern crate docopt; + +docopt!(Args derive Debug, " +Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT + rustc (--help | --version) + +Options: + -h, --help Show this message. + --version Show the version of rustc. + --cfg SPEC Configure the compilation environment. + -L PATH Add a directory to the library search path. + --emit TYPE Configure the output that rustc will produce. + Valid values: asm, ir, bc, obj, link. + --opt-level LEVEL Optimize with possible levels 0-3. +", flag_opt_level: Option, flag_emit: Option); + +#[derive(RustcDecodable, Debug)] +enum Emit { Asm, Ir, Bc, Obj, Link } + +#[derive(Debug)] +enum OptLevel { Zero, One, Two, Three } + +impl rustc_serialize::Decodable for OptLevel { + fn decode(d: &mut D) -> Result { + Ok(match try!(d.read_usize()) { + 0 => OptLevel::Zero, 1 => OptLevel::One, + 2 => OptLevel::Two, 3 => OptLevel::Three, + n => { + let err = format!("Could not decode '{}' as opt-level.", n); + return Err(d.error(&*err)); + } + }) + } +} + +fn main() { + let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} +``` + +### Viewing the generated struct + +Generating a struct is pretty magical, but if you want, you can look at it by +expanding all macros. Say you wrote the above example for `Usage: add ` +into a file called `add.rs`. Then running: + +```bash +rustc -L path/containing/docopt/lib -Z unstable-options --pretty=expanded add.rs +``` + +Will show all macros expanded. In the generated code, you should be able to +find the generated struct: + +```rust +struct Args { + pub arg_x: int, + pub arg_y: int, +} +``` + + +### Traditional Docopt API + +The reference implementation of Docopt returns a Python dictionary with names +like `` or `--flag`. If you prefer this access pattern, then you can use +`docopt::ArgvMap`. The disadvantage is that you have to do all of your type +conversion manually. Here's the canonical Docopt example with a hash table: + +```rust +extern crate docopt; + +use docopt::Docopt; + +static USAGE: &'static str = " +Naval Fate. + +Usage: + naval_fate.py ship new ... + naval_fate.py ship move [--speed=] + naval_fate.py ship shoot + naval_fate.py mine (set|remove) [--moored | --drifting] + naval_fate.py (-h | --help) + naval_fate.py --version + +Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Moored (anchored) mine. + --drifting Drifting mine. +"; + +fn main() { + let args = Docopt::new(USAGE) + .and_then(|dopt| dopt.parse()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); + + // You can conveniently access values with `get_{bool,count,str,vec}` + // functions. If the key doesn't exist (or if, e.g., you use `get_str` on + // a switch), then a sensible default value is returned. + println!("\nSome values:"); + println!(" Speed: {}", args.get_str("--speed")); + println!(" Drifting? {}", args.get_bool("--drifting")); + println!(" Names: {:?}", args.get_vec("")); +} +``` + +### Tab completion support + +This particular implementation bundles a command called `docopt-wordlist` that +can be used to automate tab completion. This repository also collects some +basic completion support for various shells (currently only bash) in the +`completions` directory. + +You can use them to setup tab completion on your system. It should work with +any program that uses Docopt (or rather, any program that outputs usage +messages that look like Docopt). For example, to get tab completion support for +Cargo, you'll have to install `docopt-wordlist` and add some voodoo to your +`$HOME/.bash_completion` file (this may vary for other shells). + +Here it is step by step: + +```bash +# Download and build `docopt-wordlist` (as part of the Docopt package) +$ git clone git://github.com/docopt/docopt.rs +$ cd docopt.rs +$ cargo build --release + +# Now setup tab completion (for bash) +$ echo "DOCOPT_WORDLIST_BIN=\"$(pwd)/target/release/docopt-wordlist\"" >> $HOME/.bash_completion +$ echo "source \"$(pwd)/completions/docopt-wordlist.bash\"" >> $HOME/.bash_completion +$ echo "complete -F _docopt_wordlist_commands cargo" >> $HOME/.bash_completion +``` + +My [CSV toolkit](https://github.com/BurntSushi/xsv) is supported too: + +```bash +# shameless plug... +$ echo "complete -F _docopt_wordlist_commands xsv" >> $HOME/.bash_completion +``` + +Note that this is emphatically a first pass. There are several improvements +that I'd like to make: + +1. Take context into account when completing. For example, it should be + possible to only show completions that can lead to a valid Docopt match. + This may be hard. (i.e., It may require restructuring Docopt's internals.) +2. Support more shells. (I'll happily accept pull requests on this one. I doubt + I'll venture outside of bash any time soon.) +3. Make tab completion support more seamless. The way it works right now is + pretty hacky by intermingling file/directory completion. + diff --git a/deps/docopt-0.6.67/UNLICENSE b/deps/docopt-0.6.67/UNLICENSE new file mode 100644 index 000000000..68a49daad --- /dev/null +++ b/deps/docopt-0.6.67/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/deps/docopt-0.6.67/completions/docopt-wordlist.bash b/deps/docopt-0.6.67/completions/docopt-wordlist.bash new file mode 100644 index 000000000..9033a20d3 --- /dev/null +++ b/deps/docopt-0.6.67/completions/docopt-wordlist.bash @@ -0,0 +1,79 @@ +# This is your basic tab completion that will work well with commands that +# have only one usage (i.e., no distinct sub-commands). +# +# Completion works by simply taking the command name and running `$cmd --help` +# to get the usage (which is then parsed for possible completions). +function _docopt_wordlist { + if [ -z "$DOCOPT_WORDLIST_BIN" ]; then + DOCOPT_WORDLIST_BIN=/usr/local/bin/docopt-wordlist + fi + + cword=$(_get_cword) + cmd="${COMP_WORDS[0]}" + wordlist=$("$cmd" --help 2>&1 | "$DOCOPT_WORDLIST_BIN") + gen "$cword" "$wordlist" +} + +# This is a fancier version of the above that supports commands that have +# multiple sub-commands (i.e., distinct usages like Cargo). +# +# This supports sub-command completion only if `$cmd --list` shows a list of +# available sub-commands. +# +# Otherwise, the usage for the command `a b c d` is taken from the first +# command that exits successfully: +# +# a b c d --help +# a b c --help +# a b --help +# a --help +# +# So for example, if you've typed `cargo test --jo`, then the following +# happens: +# +# cargo test --jo --help # error +# cargo test --help # gives 'test' sub-command usage! +# +# As a special case, if only the initial command has been typed, then the +# sub-commands (taken from `$cmd --list`) are added to the wordlist. +function _docopt_wordlist_commands { + if [ -z "$DOCOPT_WORDLIST_BIN" ]; then + DOCOPT_WORDLIST_BIN=/usr/local/bin/docopt-wordlist + fi + + cword=$(_get_cword) + if [ "$COMP_CWORD" = 1 ]; then + cmd="${COMP_WORDS[0]}" + wordlist=$("$cmd" --help 2>&1 | "$DOCOPT_WORDLIST_BIN") + wordlist+=" $("$cmd" --list | egrep '^ +\w' | awk '{print $1}')" + gen "$cword" "$wordlist" + else + for ((i="$COMP_CWORD"; i >= 1; i++)); do + cmd="${COMP_WORDS[@]::$i}" + wordlist=$($cmd --help 2>&1 | "$DOCOPT_WORDLIST_BIN") + if [ $? = 0 ]; then + gen "$cword" "$wordlist" + break + fi + done + fi +} + +# A helper function for running `compgen`, which is responsible for taking +# a prefix and presenting possible completions. +# +# If the current prefix starts with a `.` or a `/`, then file/directory +# completion is done. Otherwise, Docopt completion is done. If Docopt +# completion is empty, then it falls back to file/directory completion. +function gen { + cword="$1" + wordlist="$2" + if [[ "$cword" = .* || "$cword" = /* ]]; then + COMPREPLY=($(compgen -A file -- "$cword")) + else + COMPREPLY=($(compgen -W "$wordlist" -- "$cword")) + if [ -z "$COMPREPLY" ]; then + COMPREPLY=($(compgen -A file -- "$cword")) + fi + fi +} diff --git a/deps/docopt-0.6.67/ctags.rust b/deps/docopt-0.6.67/ctags.rust new file mode 100644 index 000000000..b42edf757 --- /dev/null +++ b/deps/docopt-0.6.67/ctags.rust @@ -0,0 +1,11 @@ +--langdef=Rust +--langmap=Rust:.rs +--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/ +--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ diff --git a/deps/docopt-0.6.67/examples/cargo.rs b/deps/docopt-0.6.67/examples/cargo.rs new file mode 100644 index 000000000..a75aa953c --- /dev/null +++ b/deps/docopt-0.6.67/examples/cargo.rs @@ -0,0 +1,51 @@ +extern crate rustc_serialize; +extern crate docopt; + +use docopt::Docopt; + +// Write the Docopt usage string. +static USAGE: &'static str = " +Rust's package manager + +Usage: + cargo [...] + cargo [options] + +Options: + -h, --help Display this message + -V, --version Print version info and exit + --list List installed commands + -v, --verbose Use verbose output + +Some common cargo commands are: + build Compile the current project + clean Remove the target directory + doc Build this project's and its dependencies' documentation + new Create a new cargo project + run Build and execute src/main.rs + test Run the tests + bench Run the benchmarks + update Update dependencies listed in Cargo.lock + +See 'cargo help ' for more information on a specific command. +"; + +#[derive(Debug, RustcDecodable)] +struct Args { + arg_command: Option, + arg_args: Vec, + flag_list: bool, + flag_verbose: bool, +} + +#[derive(Debug, RustcDecodable)] +enum Command { + Build, Clean, Doc, New, Run, Test, Bench, Update, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} diff --git a/deps/docopt-0.6.67/examples/cp.rs b/deps/docopt-0.6.67/examples/cp.rs new file mode 100644 index 000000000..56f5fbbe8 --- /dev/null +++ b/deps/docopt-0.6.67/examples/cp.rs @@ -0,0 +1,28 @@ +extern crate rustc_serialize; +extern crate docopt; + +use docopt::Docopt; + +// Write the Docopt usage string. +static USAGE: &'static str = " +Usage: cp [-a] + cp [-a] ... + +Options: + -a, --archive Copy everything. +"; + +#[derive(Debug, RustcDecodable)] +struct Args { + arg_source: Vec, + arg_dest: String, + arg_dir: String, + flag_archive: bool, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} diff --git a/deps/docopt-0.6.67/examples/decode.rs b/deps/docopt-0.6.67/examples/decode.rs new file mode 100644 index 000000000..c52d62a04 --- /dev/null +++ b/deps/docopt-0.6.67/examples/decode.rs @@ -0,0 +1,44 @@ +extern crate rustc_serialize; +extern crate docopt; + +use docopt::Docopt; + +static USAGE: &'static str = " +Naval Fate. + +Usage: + naval_fate.py ship new ... + naval_fate.py ship move [--speed=] + naval_fate.py ship shoot + naval_fate.py mine (set|remove) [--moored | --drifting] + naval_fate.py (-h | --help) + naval_fate.py --version + +Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Moored (anchored) mine. + --drifting Drifting mine. +"; + +#[derive(Debug, RustcDecodable)] +struct Args { + flag_speed: isize, + flag_drifting: bool, + arg_name: Vec, + arg_x: Option, + arg_y: Option, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); + + println!("\nSome values:"); + println!(" Speed: {}", args.flag_speed); + println!(" Drifting? {}", args.flag_drifting); + println!(" Names: {:?}", args.arg_name); +} diff --git a/deps/docopt-0.6.67/examples/hashmap.rs b/deps/docopt-0.6.67/examples/hashmap.rs new file mode 100644 index 000000000..afde2ec32 --- /dev/null +++ b/deps/docopt-0.6.67/examples/hashmap.rs @@ -0,0 +1,37 @@ +extern crate docopt; + +use docopt::Docopt; + +static USAGE: &'static str = " +Naval Fate. + +Usage: + naval_fate.py ship new ... + naval_fate.py ship move [--speed=] + naval_fate.py ship shoot + naval_fate.py mine (set|remove) [--moored | --drifting] + naval_fate.py (-h | --help) + naval_fate.py --version + +Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Moored (anchored) mine. + --drifting Drifting mine. +"; + +fn main() { + let args = Docopt::new(USAGE) + .and_then(|dopt| dopt.parse()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); + + // You can conveniently access values with `get_{bool,count,str,vec}` + // functions. If the key doesn't exist (or if, e.g., you use `get_str` on + // a switch), then a sensible default value is returned. + println!("\nSome values:"); + println!(" Speed: {}", args.get_str("--speed")); + println!(" Drifting? {}", args.get_bool("--drifting")); + println!(" Names: {:?}", args.get_vec("")); +} diff --git a/deps/docopt-0.6.67/examples/optional_command.rs b/deps/docopt-0.6.67/examples/optional_command.rs new file mode 100644 index 000000000..8b62d786a --- /dev/null +++ b/deps/docopt-0.6.67/examples/optional_command.rs @@ -0,0 +1,50 @@ +// This example shows how to implement a command with a "catch all." +// +// This requires writing your own impl for `Decodable` because docopt's +// decoder uses `Option` to mean "T may not be present" rather than +// "T may be present but incorrect." + +extern crate rustc_serialize; +extern crate docopt; + +use docopt::Docopt; +use rustc_serialize::{Decodable, Decoder}; + +// Write the Docopt usage string. +static USAGE: &'static str = " +Rust's package manager + +Usage: + mycli [] + +Options: + -h, --help Display this message +"; + +#[derive(Debug, RustcDecodable)] +struct Args { + arg_command: Command, +} + +impl Decodable for Command { + fn decode(d: &mut D) -> Result { + let s = try!(d.read_str()); + Ok(match &*s { + "" => Command::None, + "A" => Command::A, + "B" => Command::B, + "C" => Command::C, + s => Command::Unknown(s.to_string()), + }) + } +} + +#[derive(Debug)] +enum Command { A, B, C, Unknown(String), None } + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} diff --git a/deps/docopt-0.6.67/examples/verbose_multiple.rs b/deps/docopt-0.6.67/examples/verbose_multiple.rs new file mode 100644 index 000000000..a80e4b8fb --- /dev/null +++ b/deps/docopt-0.6.67/examples/verbose_multiple.rs @@ -0,0 +1,36 @@ +extern crate rustc_serialize; +extern crate docopt; + +use docopt::Docopt; + +// This shows how to implement multiple levels of verbosity. +// +// When you have multiple patterns, I think the only way to carry the +// repeated flag through all of them is to specify it for each pattern +// explicitly. +// +// This is unfortunate. +static USAGE: &'static str = " +Usage: cp [options] [-v | -vv | -vvv] + cp [options] [-v | -vv | -vvv] ... + +Options: + -a, --archive Copy everything. + -v, --verbose Show extra log output. +"; + +#[derive(Debug, RustcDecodable)] +struct Args { + arg_source: Vec, + arg_dest: String, + arg_dir: String, + flag_archive: bool, + flag_verbose: usize, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + println!("{:?}", args); +} diff --git a/deps/docopt-0.6.67/scripts/mk-testcases b/deps/docopt-0.6.67/scripts/mk-testcases new file mode 100755 index 000000000..9f4f78347 --- /dev/null +++ b/deps/docopt-0.6.67/scripts/mk-testcases @@ -0,0 +1,80 @@ +#!/usr/bin/env python2 + +from __future__ import absolute_import, division, print_function +import argparse +import json +import re + +retests = re.compile('(.*?)"""(.*?)(r"""|\s*$)', re.DOTALL) +reinvokes = re.compile('(.+?$)(.+?)\s*(\$|\Z)', re.DOTALL | re.MULTILINE) + +p = argparse.ArgumentParser( + description="Outputs src/test/testcases.rs to stdout") +p.add_argument("testcases", metavar="FILE", + help="The testcases.docopt language agnostic test suite.") +args = p.parse_args() + +with open(args.testcases) as f: + alltests = f.read() + +alltests = re.sub('^r"""', '', alltests) +alltests = re.sub('^\s*#.*$', '', alltests, flags=re.MULTILINE) + +tests = [] # [{usage, args, expect}] (expect is None ==> user-error) +for m in retests.finditer(alltests): + usage, invokes = m.group(1).strip(), m.group(2).strip() + assert invokes.startswith('$'), 'Bad test: "%s"' % invokes + invokes = re.sub('^\$', '', invokes) + + for mi in reinvokes.finditer(invokes): + invoke, expect = mi.group(1).strip(), mi.group(2).strip() + err = expect.startswith('"user-error"') + tests.append({ + 'usage': usage, + 'args': invoke.split()[1:], + 'expect': None if err else json.loads(expect), + }) + + +def show_test(i, t): + def show_expect(e): + kvs = [] + for k, v in e.iteritems(): + kvs.append('("%s", %s)' % (k, show_value(v))) + return ', '.join(kvs) + def show_value(v): + if v is None: + return 'Plain(None)' + elif isinstance(v, basestring): + return 'Plain(Some("%s".to_string()))' % v + elif isinstance(v, bool): + return 'Switch(%s)' % ('true' if v else 'false') + elif isinstance(v, int): + return 'Counted(%d)' % v + elif isinstance(v, list): + elms = ', '.join(['"%s".to_string()' % el for el in v]) + return 'List(vec!(%s))' % elms + else: + raise ValueError('Unrecognized value: "%s" (type: %s)' + % (v, type(v))) + + args = ', '.join(['"%s"' % arg for arg in t['args']]) + if t['expect'] is None: + return 'test_user_error!(test_%d_testcases, "%s", &[%s]);' \ + % (i, t['usage'], args) + else: + expect = show_expect(t['expect']) + return 'test_expect!(test_%d_testcases, "%s", &[%s], vec!(%s));' \ + % (i, t['usage'], args, expect) + +print( +"""// !!! ATTENTION !!! +// This file is automatically generated by `scripts/mk-testcases`. +// Please do not edit this file directly! + +use Value::{{Switch, Counted, Plain, List}}; +use test::{{get_args, map_from_alist, same_args}}; + +{tests} +""".format(tests='\n\n'.join([show_test(i, t) for i, t in enumerate(tests)]))) + diff --git a/deps/docopt-0.6.67/session.vim b/deps/docopt-0.6.67/session.vim new file mode 100644 index 000000000..59eea67a1 --- /dev/null +++ b/deps/docopt-0.6.67/session.vim @@ -0,0 +1,3 @@ +au BufWritePost *.rs silent!make ctags > /dev/null 2>&1 +" let g:syntastic_rust_rustc_fname = "src/lib.rs" +" let g:syntastic_rust_rustc_args = "--no-trans" diff --git a/deps/docopt-0.6.67/src/dopt.rs b/deps/docopt-0.6.67/src/dopt.rs new file mode 100644 index 000000000..210ba05b9 --- /dev/null +++ b/deps/docopt-0.6.67/src/dopt.rs @@ -0,0 +1,873 @@ +use std::collections::HashMap; +use std::error::Error as StdError; +use std::fmt; + +use rustc_serialize::Decodable; + +use parse::Parser; +use synonym::SynonymMap; + +use self::Value::{Switch, Counted, Plain, List}; +use self::Error::{Usage, Argv, NoMatch, Decode, WithProgramUsage, Help, Version}; + +/// Represents the different types of Docopt errors. +/// +/// This error type has a lot of variants. In the common case, you probably +/// don't care why Docopt has failed, and would rather just quit the program +/// and show an error message instead. The `exit` method defined on the `Error` +/// type will do just that. It will also set the exit code appropriately +/// (no error for `--help` or `--version`, but an error code for bad usage, +/// bad argv, no match or bad decode). +/// +/// ### Example +/// +/// Generally, you want to parse the usage string, try to match the argv +/// and then quit the program if there was an error reported at any point +/// in that process. This can be achieved like so: +/// +/// ```no_run +/// use docopt::Docopt; +/// +/// static USAGE: &'static str = " +/// Usage: ... +/// "; +/// +/// let args = Docopt::new(USAGE) +/// .and_then(|d| d.parse()) +/// .unwrap_or_else(|e| e.exit()); +/// ``` +#[derive(Debug)] +pub enum Error { + /// Parsing the usage string failed. + /// + /// This error can only be triggered by the programmer, i.e., the writer + /// of the Docopt usage string. This error is usually indicative of a bug + /// in your program. + Usage(String), + + /// Parsing the argv specified failed. + /// + /// The payload is a string describing why the arguments provided could not + /// be parsed. + /// + /// This is distinct from `NoMatch` because it will catch errors like + /// using flags that aren't defined in the usage string. + Argv(String), + + /// The given argv parsed successfully, but it did not match any example + /// usage of the program. + /// + /// Regrettably, there is no descriptive message describing *why* the + /// given argv didn't match any of the usage strings. + NoMatch, + + /// This indicates a problem decoding a successful argv match into a + /// decodable value. + Decode(String), + + /// Parsing failed, and the program usage should be printed next to the + /// failure message. Typically this wraps `Argv` and `NoMatch` errors. + WithProgramUsage(Box, String), + + /// Decoding or parsing failed because the command line specified that the + /// help message should be printed. + Help, + + /// Decoding or parsing failed because the command line specified that the + /// version should be printed + /// + /// The version is included as a payload to this variant. + Version(String), +} + +impl Error { + /// Return whether this was a fatal error or not. + /// + /// Non-fatal errors include requests to print the help or version + /// information of a program, while fatal errors include those such as + /// failing to decode or parse. + pub fn fatal(&self) -> bool { + match *self { + Help | Version(..) => false, + Usage(..) | Argv(..) | NoMatch | Decode(..) => true, + WithProgramUsage(ref b, _) => b.fatal(), + } + } + + /// Print this error and immediately exit the program. + /// + /// If the error is non-fatal (e.g., `Help` or `Version`), then the + /// error is printed to stdout and the exit status will be `0`. Otherwise, + /// when the error is fatal, the error is printed to stderr and the + /// exit status will be `1`. + pub fn exit(&self) -> ! { + if self.fatal() { + werr!("{}\n", self); + ::std::process::exit(1) + } else { + println!("{}", self); + ::std::process::exit(0) + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + WithProgramUsage(ref other, ref usage) => { + let other = other.to_string(); + if other.is_empty() { + write!(f, "{}", usage) + } else { + write!(f, "{}\n\n{}", other, usage) + } + } + Help => write!(f, ""), + NoMatch => write!(f, "Invalid arguments."), + Usage(ref s) | Argv(ref s) | Decode(ref s) | Version(ref s) => { + write!(f, "{}", s) + } + } + } +} + +impl StdError for Error { + fn description(&self) -> &str { + match *self { + Usage(..) => "invalid usage string", + Argv(..) => "failed to parse specified argv", + NoMatch => "could not match specified argv", + Decode(..) => "failed to decode", + WithProgramUsage(..) => "failed to parse specified argv", + Help => "help message requested", + Version(..) => "version message requested", + } + } + + fn cause(&self) -> Option<&StdError> { + match *self { + WithProgramUsage(ref cause, _) => Some(&**cause), + _ => None, + } + } +} + +/// The main Docopt type, which is constructed with a Docopt usage string. +/// +/// This can be used to match command line arguments to produce a `ArgvMap`. +#[derive(Clone, Debug)] +pub struct Docopt { + p: Parser, + argv: Option>, + options_first: bool, + help: bool, + version: Option, +} + +impl Docopt { + /// Parse the Docopt usage string given. + /// + /// The `Docopt` value returned may be used immediately to parse command + /// line arguments with a default configuration. + /// + /// If there was a problem parsing the usage string, a `Usage` error + /// is returned. + pub fn new(usage: S) -> Result + where S: ::std::ops::Deref { + Parser::new(usage.deref()) + .map_err(Usage) + .map(|p| Docopt { + p: p, + argv: None, + options_first: false, + help: true, + version: None, + }) + } + + /// Parse and decode the given argv. + /// + /// This is a convenience method for + /// `parse().and_then(|vals| vals.decode())`. + /// + /// For details on how decoding works, please see the documentation for + /// `ArgvMap`. + pub fn decode(&self) -> Result where D: Decodable { + self.parse().and_then(|vals| vals.decode()) + } + + /// Parse command line arguments and try to match them against a usage + /// pattern specified in the Docopt string. + /// + /// If there is a match, then an `ArgvMap` is returned, which maps + /// flags, commands and arguments to values. + /// + /// If parsing the command line arguments fails, then an `Argv` error is + /// returned. If parsing succeeds but there is no match, then a `NoMatch` + /// error is returned. Both of these errors are always returned inside a + /// `WithProgramUsage` error. + /// + /// If special handling of `help` or `version` is enabled (the former is + /// enabled by default), then `Help` or `Version` errors are returned + /// if `--help` or `--version` is present. + pub fn parse(&self) -> Result { + let argv = self.argv.clone().unwrap_or_else(|| Docopt::get_argv()); + let vals = try!( + self.p.parse_argv(argv, self.options_first) + .map_err(|s| self.err_with_usage(Argv(s))) + .and_then(|argv| + match self.p.matches(&argv) { + Some(m) => Ok(ArgvMap { map: m }), + None => Err(self.err_with_usage(NoMatch)), + })); + if self.help && vals.get_bool("--help") { + return Err(self.err_with_full_doc(Help)); + } + match self.version { + Some(ref v) if vals.get_bool("--version") => { + return Err(Version(v.clone())) + } + _ => {}, + } + Ok(vals) + } + + /// Set the argv to be used for Docopt parsing. + /// + /// By default, when no argv is set, and it is automatically taken from + /// `std::env::args()`. + /// + /// The `argv` given *must* be the full set of `argv` passed to the + /// program. e.g., `["cp", "src", "dest"]` is right while `["src", "dest"]` + /// is wrong. + pub fn argv(mut self, argv: I) -> Docopt + where I: Iterator, S: Into { + self.argv = Some( + argv.skip(1).map(|s| s.into()).collect() + ); + self + } + + /// Enables the "options first" Docopt behavior. + /// + /// The options first behavior means that all flags *must* appear before + /// position arguments. That is, after the first position argument is + /// seen, all proceeding arguments are interpreted as positional + /// arguments unconditionally. + pub fn options_first(mut self, yes: bool) -> Docopt { + self.options_first = yes; + self + } + + /// Enables automatic handling of `--help`. + /// + /// When this is enabled and `--help` appears anywhere in the arguments, + /// then a `Help` error will be returned. You may then use the `exit` + /// method on the error value to conveniently quit the program (which will + /// print the full usage string to stdout). + /// + /// Note that for this to work, `--help` must be a valid pattern. + /// + /// When disabled, there is no special handling of `--help`. + pub fn help(mut self, yes: bool) -> Docopt { + self.help = yes; + self + } + + /// Enables automatic handling of `--version`. + /// + /// When this is enabled and `--version` appears anywhere in the arguments, + /// then a `Version(s)` error will be returned, where `s` is the string + /// given here. You may then use the `exit` method on the error value to + /// convenient quit the program (which will print the version to stdout). + /// + /// When disabled (a `None` value), there is no special handling of + /// `--version`. + pub fn version(mut self, version: Option) -> Docopt { + self.version = version; + self + } + + #[doc(hidden)] + // Exposed for use in `docopt_macros`. + pub fn parser<'a>(&'a self) -> &'a Parser { + &self.p + } + + fn err_with_usage(&self, e: Error) -> Error { + WithProgramUsage( + Box::new(e), self.p.usage.trim().to_string()) + } + + fn err_with_full_doc(&self, e: Error) -> Error { + WithProgramUsage( + Box::new(e), self.p.full_doc.trim().to_string()) + } + + fn get_argv() -> Vec { + // Hmm, we should probably handle a Unicode decode error here... ---AG + ::std::env::args().skip(1).map(|v| v.to_string()).collect() + } +} + +/// A map containing matched values from command line arguments. +/// +/// The keys are just as specified in Docopt: `--flag` for a long flag or +/// `-f` for a short flag. (If `-f` is a synonym for `--flag`, then either +/// key will work.) `ARG` or `` specify a positional argument and `cmd` +/// specifies a command. +#[derive(Clone)] +pub struct ArgvMap { + #[doc(hidden)] + pub map: SynonymMap, +} + +impl ArgvMap { + /// Tries to decode the map of values into a struct. + /// + /// This method should always be called to decode a `ArgvMap` into + /// a struct. All fields of the struct must map to a corresponding key + /// in the `ArgvMap`. To this end, each member must have a special prefix + /// corresponding to the different kinds of patterns in Docopt. There are + /// three prefixes: `flag_`, `arg_` and `cmd_` which respectively + /// correspond to short/long flags, positional arguments and commands. + /// + /// If a Docopt item has a `-` in its name, then it is converted to an `_`. + /// + /// # Example + /// + /// ```rust + /// # extern crate docopt; + /// # extern crate rustc_serialize; + /// # fn main() { + /// use docopt::Docopt; + /// + /// static USAGE: &'static str = " + /// Usage: cargo [options] (build | test) + /// cargo --help + /// + /// Options: -v, --verbose + /// -h, --help + /// "; + /// + /// #[derive(RustcDecodable)] + /// struct Args { + /// cmd_build: bool, + /// cmd_test: bool, + /// flag_verbose: bool, + /// flag_h: bool, + /// } + /// + /// let argv = || vec!["cargo", "build", "-v"].into_iter(); + /// let args: Args = Docopt::new(USAGE) + /// .and_then(|d| d.argv(argv()).decode()) + /// .unwrap_or_else(|e| e.exit()); + /// assert!(args.cmd_build && !args.cmd_test + /// && args.flag_verbose && !args.flag_h); + /// # } + /// ``` + /// + /// Note that in the above example, `flag_h` is used but `flag_help` + /// could also be used. (In fact, both could be used at the same time.) + /// + /// In this example, only the `bool` type was used, but any type satisfying + /// the `Decodable` trait is valid. + pub fn decode(self) -> Result { + Decodable::decode(&mut Decoder { vals: self, stack: vec!() }) + } + + /// Finds the value corresponding to `key` and calls `as_bool()` on it. + /// If the key does not exist, `false` is returned. + pub fn get_bool(&self, key: &str) -> bool { + self.find(key).map(|v| v.as_bool()).unwrap_or(false) + } + + /// Finds the value corresponding to `key` and calls `as_count()` on it. + /// If the key does not exist, `0` is returned. + pub fn get_count(&self, key: &str) -> u64 { + self.find(key).map(|v| v.as_count()).unwrap_or(0) + } + + /// Finds the value corresponding to `key` and calls `as_str()` on it. + /// If the key does not exist, `""` is returned. + pub fn get_str<'a>(&'a self, key: &str) -> &'a str { + self.find(key).map(|v| v.as_str()).unwrap_or("") + } + + /// Finds the value corresponding to `key` and calls `as_vec()` on it. + /// If the key does not exist, `vec!()` is returned. + pub fn get_vec<'a>(&'a self, key: &str) -> Vec<&'a str> { + self.find(key).map(|v| v.as_vec()).unwrap_or(vec!()) + } + + /// Return the raw value corresponding to some `key`. + /// + /// `key` should be a string in the traditional Docopt format. e.g., + /// `` or `--flag`. + pub fn find<'a>(&'a self, key: &str) -> Option<&'a Value> { + self.map.find(&key.to_string()) + } + + /// Return the number of values, not including synonyms. + pub fn len(&self) -> usize { + self.map.len() + } + + /// Converts a Docopt key to a struct field name. + /// This makes a half-hearted attempt at making the key a valid struct + /// field name (like replacing `-` with `_`), but it does not otherwise + /// guarantee that the result is a valid struct field name. + #[doc(hidden)] + pub fn key_to_struct_field(name: &str) -> String { + fn sanitize(name: &str) -> String { + name.replace("-", "_") + } + + let r = regex!(r"^(?:--?(?P\S+)|(?:(?P\p{Lu}+)|<(?P[^>]+)>)|(?P\S+))$"); + r.replace(name, |cap: &::regex::Captures| { + let (flag, cmd) = ( + cap.name("flag").unwrap_or(""), + cap.name("cmd").unwrap_or(""), + ); + let (argu, argb) = ( + cap.name("argu").unwrap_or(""), + cap.name("argb").unwrap_or(""), + ); + let (prefix, name) = + if !flag.is_empty() { + ("flag_", flag) + } else if !argu.is_empty() { + ("arg_", argu) + } else if !argb.is_empty() { + ("arg_", argb) + } else if !cmd.is_empty() { + ("cmd_", cmd) + } else { + panic!("Unknown ArgvMap key: '{}'", name) + }; + let mut prefix = prefix.to_string(); + prefix.push_str(&sanitize(name)); + prefix + }) + } + + /// Converts a struct field name to a Docopt key. + #[doc(hidden)] + pub fn struct_field_to_key(field: &str) -> String { + fn desanitize(name: &str) -> String { + name.replace("_", "-") + } + let name = + if field.starts_with("flag_") { + let name = regex!(r"^flag_").replace(field, ""); + let mut pre_name = (if name.len() == 1 { "-" } else { "--" }) + .to_string(); + pre_name.push_str(&*name); + pre_name + } else if field.starts_with("arg_") { + let name = regex!(r"^arg_").replace(field, ""); + if regex!(r"^\p{Lu}+$").is_match(&name) { + name + } else { + let mut pre_name = "<".to_string(); + pre_name.push_str(&*name); + pre_name.push('>'); + pre_name + } + } else if field.starts_with("cmd_") { + { regex!(r"^cmd_") }.replace(field, "") + } else { + panic!("Unrecognized struct field: '{}'", field) + }; + desanitize(&*name) + } +} + +impl fmt::Debug for ArgvMap { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.len() == 0 { + return write!(f, "{{EMPTY}}"); + } + + // This is a little crazy, but we want to group synonyms with + // their keys and sort them for predictable output. + let reverse: HashMap<&String, &String> = + self.map.synonyms().map(|(from, to)| (to, from)).collect(); + let mut keys: Vec<&String> = self.map.keys().collect(); + keys.sort(); + let mut first = true; + for &k in keys.iter() { + if !first { try!(write!(f, "\n")); } else { first = false; } + match reverse.get(&k) { + None => { + try!(write!(f, "{} => {:?}", k, self.map.get(k))) + } + Some(s) => { + try!(write!(f, "{}, {} => {:?}", s, k, self.map.get(k))) + } + } + } + Ok(()) + } +} + +/// A matched command line value. +/// +/// The value can be a boolean, counted repetition, a plain string or a list +/// of strings. +/// +/// The various `as_{bool,count,str,vec}` methods provide convenient access +/// to values without destructuring manually. +#[derive(Clone, Debug, PartialEq)] +pub enum Value { + /// A boolean value from a flag that has no argument. + /// + /// The presence of a flag means `true` and the absence of a flag + /// means `false`. + Switch(bool), + + /// The number of occurrences of a repeated flag. + Counted(u64), + + /// A positional or flag argument. + /// + /// This is `None` when the positional argument or flag is not present. + /// Note that it is possible to have `Some("")` for a present but empty + /// argument. + Plain(Option), + + /// A List of positional or flag arguments. + /// + /// This list may be empty when no arguments or flags are present. + List(Vec), +} + +impl Value { + /// Returns the value as a bool. + /// + /// Counted repetitions are `false` if `0` and `true` otherwise. + /// Plain strings are `true` if present and `false` otherwise. + /// Lists are `true` if non-empty and `false` otherwise. + pub fn as_bool(&self) -> bool { + match *self { + Switch(b) => b, + Counted(n) => n > 0, + Plain(None) => false, + Plain(Some(_)) => true, + List(ref vs) => !vs.is_empty(), + } + } + + /// Returns the value as a count of the number of times it occurred. + /// + /// Booleans are `1` if `true` and `0` otherwise. + /// Plain strings are `1` if present and `0` otherwise. + /// Lists correspond to its length. + pub fn as_count(&self) -> u64 { + match *self { + Switch(b) => if b { 1 } else { 0 }, + Counted(n) => n, + Plain(None) => 0, + Plain(Some(_)) => 1, + List(ref vs) => vs.len() as u64, + } + } + + /// Returns the value as a string. + /// + /// All values return an empty string except for a non-empty plain string. + pub fn as_str<'a>(&'a self) -> &'a str { + match *self { + Switch(_) | Counted(_) | Plain(None) | List(_) => "", + Plain(Some(ref s)) => &**s, + } + } + + /// Returns the value as a list of strings. + /// + /// Booleans, repetitions and empty strings correspond to an empty list. + /// Plain strings correspond to a list of length `1`. + pub fn as_vec<'a>(&'a self) -> Vec<&'a str> { + match *self { + Switch(_) | Counted(_) | Plain(None) => vec![], + Plain(Some(ref s)) => vec![&**s], + List(ref vs) => vs.iter().map(|s| &**s).collect(), + } + } +} + +/// Decoder for `ArgvMap` into your own `Decodable` types. +/// +/// In general, you shouldn't have to use this type directly. It is exposed +/// in case you want to write a generic function that produces a decodable +/// value. For example, here's a function that takes a usage string, an argv +/// and produces a decodable value: +/// +/// ```rust +/// # extern crate docopt; +/// # extern crate rustc_serialize; +/// # fn main() { +/// use docopt::Docopt; +/// use rustc_serialize::Decodable; +/// +/// fn decode(usage: &str, argv: &[&str]) +/// -> Result { +/// Docopt::new(usage) +/// .and_then(|d| d.argv(argv.iter().cloned()).decode()) +/// } +/// # } +pub struct Decoder { + vals: ArgvMap, + stack: Vec, +} + +#[derive(Debug)] +struct DecoderItem { + key: String, + struct_field: String, + val: Option, +} + +macro_rules! derr( + ($($arg:tt)*) => (return Err(Decode(format!($($arg)*)))) +); + +impl Decoder { + fn push(&mut self, struct_field: &str) { + let key = ArgvMap::struct_field_to_key(struct_field); + self.stack.push(DecoderItem { + key: key.clone(), + struct_field: struct_field.to_string(), + val: self.vals.find(&*key).map(|v| v.clone()), + }); + } + + fn pop(&mut self) -> Result { + match self.stack.pop() { + None => derr!("Could not decode value into unknown key."), + Some(it) => Ok(it), + } + } + + fn pop_key_val(&mut self) -> Result<(String, Value), Error> { + let it = try!(self.pop()); + match it.val { + None => derr!("Could not find argument '{}' (from struct \ + field '{}').", it.key, it.struct_field), + Some(v) => Ok((it.key, v)), + } + } + + fn pop_val(&mut self) -> Result { + let (_, v) = try!(self.pop_key_val()); + Ok(v) + } + + fn to_number(&mut self, expect: &str) -> Result { + let (k, v) = try!(self.pop_key_val()); + match v { + Counted(n) => Ok(n), + _ => { + match v.as_str().parse() { + Err(_) => derr!("Could not decode '{}' to {} for '{}'.", + v.as_str(), expect, k), + Ok(v) => Ok(v), + } + } + } + } + + fn to_float(&mut self, expect: &str) -> Result { + let (k, v) = try!(self.pop_key_val()); + match v { + Counted(n) => Ok(n as f64), + _ => { + match v.as_str().parse() { + Err(_) => derr!("Could not decode '{}' to {} for '{}'.", + v.as_str(), expect, k), + Ok(v) => Ok(v), + } + } + } + } +} + +macro_rules! read_num { + ($name:ident, $ty:ty) => ( + fn $name(&mut self) -> Result<$ty, Error> { + self.to_number(stringify!($ty)).map(|n| n as $ty) + } + ); +} + +impl ::rustc_serialize::Decoder for Decoder { + type Error = Error; + + fn error(&mut self, err: &str) -> Error { + Decode(err.to_string()) + } + + fn read_nil(&mut self) -> Result<(), Error> { + // I don't know what the right thing is here, so just fail for now. + panic!("I don't know how to read into a nil value.") + } + + read_num!(read_usize, usize); + read_num!(read_u64, u64); + read_num!(read_u32, u32); + read_num!(read_u16, u16); + read_num!(read_u8, u8); + read_num!(read_isize, isize); + read_num!(read_i64, i64); + read_num!(read_i32, i32); + read_num!(read_i16, i16); + read_num!(read_i8, i8); + + fn read_bool(&mut self) -> Result { + self.pop_val().map(|v| v.as_bool()) + } + + fn read_f64(&mut self) -> Result { + self.to_float("f64") + } + + fn read_f32(&mut self) -> Result { + self.to_float("f32").map(|n| n as f32) + } + + fn read_char(&mut self) -> Result { + let (k, v) = try!(self.pop_key_val()); + let vstr = v.as_str(); + match vstr.chars().count() { + 1 => Ok(vstr.chars().next().unwrap()), + _ => derr!("Could not decode '{}' into char for '{}'.", vstr, k), + } + } + + fn read_str(&mut self) -> Result { + self.pop_val().map(|v| v.as_str().to_string()) + } + + fn read_enum(&mut self, _: &str, f: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + f(self) + } + + fn read_enum_variant(&mut self, names: &[&str], mut f: F) + -> Result + where F: FnMut(&mut Decoder, usize) -> Result { + let v = to_lowercase(try!(self.pop_val()).as_str()); + let i = + match names.iter().map(|&n| to_lowercase(n)).position(|n| n == v) { + Some(i) => i, + None => { + derr!("Could not match '{}' with any of \ + the allowed variants: {:?}", v, names) + } + }; + f(self, i) + } + + fn read_enum_variant_arg(&mut self, _: usize, _: F) + -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_enum_struct_variant(&mut self, _: &[&str], _: F) + -> Result + where F: FnMut(&mut Decoder, usize) -> Result { + unimplemented!() + } + + fn read_enum_struct_variant_field(&mut self, _: &str, _: usize, _: F) + -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_struct(&mut self, _: &str, _: usize, f: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + f(self) + } + + fn read_struct_field(&mut self, f_name: &str, _: usize, f: F) + -> Result + where F: FnOnce(&mut Decoder) -> Result { + self.push(f_name); + f(self) + } + + fn read_tuple(&mut self, _: usize, _: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_tuple_arg(&mut self, _: usize, _: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_tuple_struct(&mut self, _: &str, _: usize, _: F) + -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_tuple_struct_arg(&mut self, _: usize, _: F) + -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_option(&mut self, mut f: F) -> Result + where F: FnMut(&mut Decoder, bool) -> Result { + let option = + match self.stack.last() { + None => derr!("Could not decode value into unknown key."), + Some(it) => it.val.as_ref() + .map(|v| v.as_bool()) + .unwrap_or(false), + }; + f(self, option) + } + + fn read_seq(&mut self, f: F) -> Result + where F: FnOnce(&mut Decoder, usize) -> Result { + let it = try!(self.pop()); + let list = it.val.unwrap_or(List(vec!())); + let vals = list.as_vec(); + for val in vals.iter().rev() { + self.stack.push(DecoderItem { + key: it.key.clone(), + struct_field: it.struct_field.clone(), + val: Some(Plain(Some(val.to_string()))), + }) + } + f(self, vals.len()) + } + + fn read_seq_elt(&mut self, _: usize, f: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + f(self) + } + + fn read_map(&mut self, _: F) -> Result + where F: FnOnce(&mut Decoder, usize) -> Result { + unimplemented!() + } + + fn read_map_elt_key(&mut self, _: usize, _: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } + + fn read_map_elt_val(&mut self, _: usize, _: F) -> Result + where F: FnOnce(&mut Decoder) -> Result { + unimplemented!() + } +} + +fn to_lowercase>(s: S) -> String { + s.into().chars().map(|c| c.to_lowercase().next().unwrap()).collect() +} diff --git a/deps/docopt-0.6.67/src/lib.rs b/deps/docopt-0.6.67/src/lib.rs new file mode 100644 index 000000000..7c308d48b --- /dev/null +++ b/deps/docopt-0.6.67/src/lib.rs @@ -0,0 +1,241 @@ +//! Docopt for Rust. This implementation conforms to the +//! [official description of Docopt](http://docopt.org/) and +//! [passes its test suite](https://github.com/docopt/docopt/pull/201). +//! +//! This library is [on GitHub](https://github.com/docopt/docopt.rs). +//! +//! Fundamentally, Docopt is a command line argument parser. The detail that +//! distinguishes it from most parsers is that the parser is derived from the +//! usage string. Here's a simple example: +//! +//! ```rust +//! use docopt::Docopt; +//! +//! // Write the Docopt usage string. +//! static USAGE: &'static str = " +//! Usage: cp [-a] +//! cp [-a] ... +//! +//! Options: +//! -a, --archive Copy everything. +//! "; +//! +//! // The argv. Normally you'd just use `parse` which will automatically +//! // use `std::env::args()`. +//! let argv = || vec!["cp", "-a", "file1", "file2", "dest/"]; +//! +//! // Parse argv and exit the program with an error message if it fails. +//! let args = Docopt::new(USAGE) +//! .and_then(|d| d.argv(argv().into_iter()).parse()) +//! .unwrap_or_else(|e| e.exit()); +//! +//! // Now access your argv values. Synonyms work just fine! +//! assert!(args.get_bool("-a") && args.get_bool("--archive")); +//! assert_eq!(args.get_vec(""), vec!["file1", "file2"]); +//! assert_eq!(args.get_str(""), "dest/"); +//! assert_eq!(args.get_str(""), ""); +//! ``` +//! +//! # Type based decoding +//! +//! Often, command line values aren't just strings or booleans---sometimes +//! they are integers, or enums, or something more elaborate. Using the +//! standard Docopt interface can be inconvenient for this purpose, because +//! you'll need to convert all of the values explicitly. Instead, this crate +//! provides a `Decoder` that converts an `ArgvMap` to your custom struct. +//! Here is the same example as above using type based decoding: +//! +//! ```rust +//! # extern crate docopt; +//! # extern crate rustc_serialize; +//! # fn main() { +//! use docopt::Docopt; +//! +//! // Write the Docopt usage string. +//! static USAGE: &'static str = " +//! Usage: cp [-a] +//! cp [-a] ... +//! +//! Options: +//! -a, --archive Copy everything. +//! "; +//! +//! #[derive(RustcDecodable)] +//! struct Args { +//! arg_source: Vec, +//! arg_dest: String, +//! arg_dir: String, +//! flag_archive: bool, +//! } +//! +//! let argv = || vec!["cp", "-a", "file1", "file2", "dest/"]; +//! let args: Args = Docopt::new(USAGE) +//! .and_then(|d| d.argv(argv().into_iter()).decode()) +//! .unwrap_or_else(|e| e.exit()); +//! +//! // Now access your argv values. +//! fn s(x: &str) -> String { x.to_string() } +//! assert!(args.flag_archive); +//! assert_eq!(args.arg_source, vec![s("file1"), s("file2")]); +//! assert_eq!(args.arg_dir, s("dest/")); +//! assert_eq!(args.arg_dest, s("")); +//! # } +//! ``` +//! +//! # Command line arguments for `rustc` +//! +//! Here's an example with a subset of `rustc`'s command line arguments that +//! shows more of Docopt and some of the benefits of type based decoding. +//! +//! ```rust +//! # extern crate docopt; +//! # extern crate rustc_serialize; +//! # fn main() { +//! # #![allow(non_snake_case)] +//! use docopt::Docopt; +//! +//! // Write the Docopt usage string. +//! static USAGE: &'static str = " +//! Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT +//! rustc (--help | --version) +//! +//! Options: +//! -h, --help Show this message. +//! --version Show the version of rustc. +//! --cfg SPEC Configure the compilation environment. +//! -L PATH Add a directory to the library search path. +//! --emit TYPE Configure the output that rustc will produce. +//! Valid values: asm, ir, bc, obj, link. +//! --opt-level LEVEL Optimize with possible levels 0-3. +//! "; +//! +//! #[derive(RustcDecodable)] +//! struct Args { +//! arg_INPUT: String, +//! flag_emit: Option, +//! flag_opt_level: Option, +//! flag_cfg: Vec, +//! flag_L: Vec, +//! flag_help: bool, +//! flag_version: bool, +//! } +//! +//! // This is easy. The decoder will automatically restrict values to +//! // strings that match one of the enum variants. +//! #[derive(RustcDecodable)] +//! # #[derive(Debug, PartialEq)] +//! enum Emit { Asm, Ir, Bc, Obj, Link } +//! +//! // This one is harder because we want the user to specify an integer, +//! // but restrict it to a specific range. So we implement `Decodable` +//! // ourselves. +//! # #[derive(Debug, PartialEq)] +//! enum OptLevel { Zero, One, Two, Three } +//! +//! impl rustc_serialize::Decodable for OptLevel { +//! fn decode(d: &mut D) +//! -> Result { +//! Ok(match try!(d.read_usize()) { +//! 0 => OptLevel::Zero, 1 => OptLevel::One, +//! 2 => OptLevel::Two, 3 => OptLevel::Three, +//! n => { +//! let err = format!( +//! "Could not decode '{}' as opt-level.", n); +//! return Err(d.error(&*err)); +//! } +//! }) +//! } +//! } +//! +//! let argv = || vec!["rustc", "-L", ".", "-L", "..", "--cfg", "a", +//! "--opt-level", "2", "--emit=ir", "docopt.rs"]; +//! let args: Args = Docopt::new(USAGE) +//! .and_then(|d| d.argv(argv().into_iter()).decode()) +//! .unwrap_or_else(|e| e.exit()); +//! +//! // Now access your argv values. +//! fn s(x: &str) -> String { x.to_string() } +//! assert_eq!(args.arg_INPUT, "docopt.rs".to_string()); +//! assert_eq!(args.flag_L, vec![s("."), s("..")]); +//! assert_eq!(args.flag_cfg, vec![s("a")]); +//! assert_eq!(args.flag_opt_level, Some(OptLevel::Two)); +//! assert_eq!(args.flag_emit, Some(Emit::Ir)); +//! # } +//! ``` +//! +//! # The `docopt!` macro +//! +//! This package comes bundled with an additional crate, `docopt_macros`, +//! which provides a `docopt!` syntax extension. Its purpose is to automate +//! the creation of a Rust struct from a Docopt usage string. In particular, +//! this provides a single point of truth about the definition of command line +//! arguments in your program. +//! +//! Another advantage of using the macro is that errors in your Docopt usage +//! string will be caught at compile time. Stated differently, your program +//! will not compile with an invalid Docopt usage string. +//! +//! The example above using type based decoding can be simplified to this: +//! +//! ```ignore +//! #![feature(plugin)] +//! #![plugin(docopt_macros)] +//! +//! extern crate rustc_serialize; +//! +//! extern crate docopt; +//! +//! // Write the Docopt usage string with the `docopt!` macro. +//! docopt!(Args, " +//! Usage: cp [-a] +//! cp [-a] ... +//! +//! Options: +//! -a, --archive Copy everything. +//! ") +//! +//! fn main() { +//! let argv = || vec!["cp", "-a", "file1", "file2", "dest/"]; +//! +//! // Your `Args` struct has a single static method defined on it, +//! // `docopt`, which will return a normal `Docopt` value. +//! let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); +//! +//! // Now access your argv values. +//! fn s(x: &str) -> String { x.to_string() } +//! assert!(args.flag_archive); +//! assert_eq!(args.arg_source, vec![s("file1"), s("file2")]); +//! assert_eq!(args.arg_dir, s("dest/")); +//! assert_eq!(args.arg_dest, s("")); +//! } +//! ``` + +#![crate_name = "docopt"] +#![doc(html_root_url = "http://burntsushi.net/rustdoc/docopt")] + +#![deny(missing_docs)] + +extern crate regex; +extern crate rustc_serialize; +extern crate strsim; + +pub use dopt::{ArgvMap, Decoder, Docopt, Error, Value}; + +macro_rules! werr( + ($($arg:tt)*) => ({ + use std::io::{Write, stderr}; + write!(&mut stderr(), $($arg)*).unwrap(); + }) +); + +// cheat until we get syntax extensions back :-( +macro_rules! regex( + ($s:expr) => (::regex::Regex::new($s).unwrap()); +); + +mod dopt; +#[doc(hidden)] +pub mod parse; +mod synonym; +#[cfg(test)] +mod test; diff --git a/deps/docopt-0.6.67/src/parse.rs b/deps/docopt-0.6.67/src/parse.rs new file mode 100644 index 000000000..1b7ced9a9 --- /dev/null +++ b/deps/docopt-0.6.67/src/parse.rs @@ -0,0 +1,1358 @@ +// I am overall pretty displeased with the quality of code in this module. +// I wrote it while simultaneously trying to build a mental model of Docopt's +// specification (hint: one does not exist in written form). As a result, there +// is a lot of coupling and some duplication. +// +// Some things that I think are good about the following code: +// +// - The representation of a "usage pattern." I think it is a minimal +// representation of a pattern's syntax. (One possible tweak: +// `Optional>` -> `Optional>`.) +// - Some disciplined use of regexes. I use a pretty basic state machine +// for parsing patterns, but for teasing out the patterns and options +// from the Docopt string and for picking out flags with arguments, I +// think regexes aren't too bad. There may be one or two scary ones though. +// - The core matching algorithm is reasonably simple and concise, but I +// think writing down some contracts will help me figure out how to make +// the code clearer. +// +// Some bad things: +// +// - I tried several times to split some of the pieces in this module into +// separate modules. I could find no clear separation. This suggests that +// there is too much coupling between parsing components. I'm not convinced +// that the coupling is necessary. +// - The parsers for patterns and argv share some structure. There may be +// an easy abstraction waiting there. +// - It is not efficient in the slightest. I tried to be conservative with +// copying strings, but I think I failed. (It may not be worthwhile to fix +// this if it makes the code more awkward. Docopt does not need to be +// efficient.) +// +// Some things to do immediately: +// +// - Document representation and invariants. +// - Less important: write contracts for functions. +// +// Long term: +// +// - Write a specification for Docopt. + +pub use self::Argument::{Zero, One}; +pub use self::Atom::{Short, Long, Command, Positional}; +use self::Pattern::{Alternates, Sequence, Optional, Repeat, PatAtom}; + +use std::borrow::ToOwned; +use std::collections::{HashMap, HashSet}; +use std::collections::hash_map::Entry::{Vacant, Occupied}; +use std::cmp::Ordering; +use std::fmt; +use regex; +use regex::Regex; +use strsim::levenshtein; + +use dopt::Value::{self, Switch, Counted, Plain, List}; +use synonym::SynonymMap; + +macro_rules! err( + ($($arg:tt)*) => (return Err(format!($($arg)*))) +); + +#[derive(Clone)] +pub struct Parser { + pub program: String, + pub full_doc: String, + pub usage: String, + pub descs: SynonymMap, + usages: Vec, + last_atom_added: Option, // context for [default: ...] +} + +impl Parser { + pub fn new(doc: &str) -> Result { + let mut d = Parser { + program: "".to_string(), + full_doc: doc.to_string(), + usage: "".to_string(), + usages: vec!(), + descs: SynonymMap::new(), + last_atom_added: None, + }; + try!(d.parse(doc)); + Ok(d) + } + + pub fn matches(&self, argv: &Argv) -> Option> { + for usage in self.usages.iter() { + match Matcher::matches(argv, usage) { + None => continue, + Some(vals) => return Some(vals), + } + } + None + } + + pub fn parse_argv<'a>(&'a self, argv: Vec, options_first: bool) + -> Result, String> { + Argv::new(self, argv, options_first) + } +} + +impl Parser { + fn options_atoms(&self) -> Vec { + let mut atoms = vec!(); + for (atom, _) in self.descs.iter().filter(|&(_, opts)| opts.is_desc) { + atoms.push(atom.clone()); + } + atoms + } + + fn has_arg(&self, atom: &Atom) -> bool { + match self.descs.find(atom) { + None => false, + Some(opts) => opts.arg.has_arg(), + } + } + + fn parse(&mut self, doc: &str) -> Result<(), String> { + let musage = regex!(r"(?s)(?i:usage):\s*(?P\S+)(?P.*?)(?:$|\n\s*\n)"); + let caps = match musage.captures(doc) { + None => err!("Could not find usage patterns in doc string."), + Some(caps) => caps, + }; + if caps.name("prog").unwrap_or("").is_empty() { + err!("Could not find program name in doc string.") + } + self.program = caps.name("prog").unwrap_or("").to_string(); + self.usage = caps.at(0).unwrap_or("").to_string(); + + // Before we parse the usage patterns, we look for option descriptions. + // We do this because the information in option descriptions can be + // used to resolve ambiguities in usage patterns (i.e., whether + // `--flag ARG` is a flag with an argument or not). + // + // From the docopt page, "every" line starting with a `-` or a `--` + // is considered an option description. Instead, we restrict the lines + // to any line *not* in the usage pattern section. + // + // *sigh* Apparently the above is not true. The official test suite + // includes `Options: -a ...`, which means some lines not beginning + // with `-` can actually have options. + let (pstart, pend) = caps.pos(0).unwrap(); + let (before, after) = (&doc[..pstart], &doc[pend..]); + // We process every line here (instead of restricting to lines starting + // with "-") because we need to check every line for a default value. + // The default value always belongs to the most recently defined desc. + for line in before.lines().chain(after.lines()) { + try!(self.parse_desc(line)); + } + + let mprog = format!( + "^(?:{})?\\s*(.*?)\\s*$", regex::quote(caps.name("prog").unwrap_or(""))); + let pats = Regex::new(&*mprog).unwrap(); + + if caps.name("pats").unwrap_or("") == "" { + let pattern = try!( + PatParser::new(self, "").parse()); + self.usages.push(pattern); + } else { + for line in caps.name("pats").unwrap_or("").lines() { + for pat in pats.captures_iter(line.trim()) { + let pattern = try!( + PatParser::new(self, pat.at(1).unwrap_or("")).parse()); + self.usages.push(pattern); + } + } + } + Ok(()) + } + + fn parse_desc(&mut self, full_desc: &str) -> Result<(), String> { + let desc = + regex!(r"^\s*(?i:options:)\s*").replace(full_desc.trim(), ""); + let desc = &*desc; + if !regex!(r"^(-\S|--\S)").is_match(desc) { + try!(self.parse_default(full_desc)); + return Ok(()) + } + + // Get rid of the description, which must be at least two spaces + // after the flag or argument. + let desc = regex!(" .*$").replace(desc, ""); + // Normalize `-x, --xyz` to `-x --xyz`. + let desc = regex!(r"([^-\s]), -").replace(&*desc, "$1 -"); + let desc = desc.trim(); + + let rflags = regex!("(?:(?P--[^ \t=]+)|(?P-[^ \t=]+))\ + (?:(?: |=)(?P[^-]\\S*))?"); + let (mut short, mut long) = ("".to_string(), "".to_string()); + let mut has_arg = false; + let mut last_end = 0; + for flags in rflags.captures_iter(desc) { + last_end = flags.pos(0).unwrap().1; + let (s, l) = ( + flags.name("short").unwrap_or(""), + flags.name("long").unwrap_or(""), + ); + if !s.is_empty() { + if !short.is_empty() { + err!("Only one short flag is allowed in an option \ + description, but found '{}' and '{}'.", short, s) + } + short = s.to_string() + } + if !l.is_empty() { + if !long.is_empty() { + err!("Only one long flag is allowed in an option \ + description, but found '{}' and '{}'.", long, l) + } + long = l.to_string() + } + if !flags.name("arg").unwrap_or("").is_empty() { + let arg = flags.name("arg").unwrap_or(""); + if !Atom::is_arg(arg) { + err!("Argument '{}' is not of the form ARG or .", arg) + } + has_arg = true; // may be changed to default later + } + } + // Make sure that we consumed everything. If there are leftovers, + // then there is some malformed description. Alert the user. + assert!(last_end <= desc.len()); + if last_end < desc.len() { + err!("Extraneous text '{}' in option description '{}'.", + &desc[last_end..], desc) + } + try!(self.add_desc(&*short, &*long, has_arg)); + // Looking for default in this line must come after adding the + // description, otherwise `parse_default` won't know which option + // to assign it to. + self.parse_default(full_desc) + } + + fn parse_default(&mut self, desc: &str) -> Result<(), String> { + let rdefault = regex!(r"\[(?i:default):(?P[^]]*)\]"); + let defval = + match rdefault.captures(desc) { + None => return Ok(()), + Some(c) => c.name("val").unwrap_or("").trim(), + }; + let last_atom = + match self.last_atom_added { + None => err!("Found default value '{}' in '{}' before first \ + option description.", defval, desc), + Some(ref atom) => atom, + }; + let opts = + self.descs + .find_mut(last_atom) + .expect(&*format!("BUG: last opt desc key ('{:?}') is invalid.", + last_atom)); + match opts.arg { + One(None) => {}, // OK + Zero => + err!("Cannot assign default value '{}' to flag '{}' \ + that has no arguments.", defval, last_atom), + One(Some(ref curval)) => + err!("Flag '{}' already has a default value \ + of '{}' (second default value: '{}').", + last_atom, curval, defval), + } + opts.arg = One(Some(defval.to_string())); + Ok(()) + } + + fn add_desc(&mut self, short: &str, long: &str, has_arg: bool) + -> Result<(), String> { + assert!(!short.is_empty() || !long.is_empty()); + if !short.is_empty() && short.chars().count() != 2 { + // It looks like the reference implementation just ignores + // these lines. + return Ok(()); + // err!("Short flag '{}' is not of the form '-x'.", short); + } + let mut opts = Options::new(false, + if has_arg { One(None) } else { Zero }); + opts.is_desc = true; + + if !short.is_empty() && !long.is_empty() { + let (short, long) = (Atom::new(short), Atom::new(long)); + self.descs.insert(long.clone(), opts); + self.descs.insert_synonym(short, long.clone()); + self.last_atom_added = Some(long); + } else if !short.is_empty() { + let short = Atom::new(short); + self.descs.insert(short.clone(), opts); + self.last_atom_added = Some(short); + } else if !long.is_empty() { + let long = Atom::new(long); + self.descs.insert(long.clone(), opts); + self.last_atom_added = Some(long); + } + Ok(()) + } +} + +impl fmt::Debug for Parser { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn sorted(mut xs: Vec) -> Vec { + xs.sort(); xs + } + + try!(writeln!(f, "=====")); + try!(writeln!(f, "Program: {}", self.program)); + + try!(writeln!(f, "Option descriptions:")); + let keys = sorted(self.descs.keys().collect()); + for &k in keys.iter() { + try!(writeln!(f, " '{}' => {:?}", k, self.descs.get(k))); + } + + try!(writeln!(f, "Synonyms:")); + let keys: Vec<(&Atom, &Atom)> = + sorted(self.descs.synonyms().collect()); + for &(from, to) in keys.iter() { + try!(writeln!(f, " {:?} => {:?}", from, to)); + } + + try!(writeln!(f, "Usages:")); + for pat in self.usages.iter() { + try!(writeln!(f, " {:?}", pat)); + } + writeln!(f, "=====") + } +} + +struct PatParser<'a> { + dopt: &'a mut Parser, + tokens: Vec, // used while parsing a single usage pattern + curi: usize, // ^^ index into pattern chars + expecting: Vec, // stack of expected ']' or ')' +} + +impl<'a> PatParser<'a> { + fn new(dopt: &'a mut Parser, pat: &str) -> PatParser<'a> { + PatParser { + dopt: dopt, + tokens: pattern_tokens(pat), + curi: 0, + expecting: vec!(), + } + } + + fn parse(&mut self) -> Result { + // let mut seen = HashSet::new(); + let mut p = try!(self.pattern()); + match self.expecting.pop() { + None => {}, + Some(c) => err!("Unclosed group. Expected '{}'.", c), + } + p.add_options_shortcut(self.dopt); + p.tag_repeats(&mut self.dopt.descs); + Ok(p) + } + + fn pattern(&mut self) -> Result { + let mut alts = vec!(); + let mut seq = vec!(); + while !self.is_eof() { + match self.cur() { + "..." => { + err!("'...' must appear directly after a group, argument, \ + flag or command.") + } + "-" | "--" => { + // As per specification, `-` and `--` by themselves are + // just commands that should be interpreted conventionally. + seq.push(try!(self.command())); + } + "|" => { + if seq.is_empty() { + err!("Unexpected '|'. Not in form 'a | b | c'.") + } + try!(self.next_noeof("pattern")); + alts.push(Sequence(seq)); + seq = vec!(); + } + "]" | ")" => { + if seq.is_empty() { + err!("Unexpected '{}'. Empty groups are not allowed.", + self.cur()) + } + match self.expecting.pop() { + None => err!("Unexpected '{}'. No open bracket found.", + self.cur()), + Some(c) => { + if c != self.cur().chars().next().unwrap() { + err!("Expected '{}' but got '{}'.", + c, self.cur()) + } + } + } + let mk: fn(Vec) -> Pattern = + if self.cur() == "]" { Optional } else { Sequence }; + self.next(); + return + if alts.is_empty() { + Ok(mk(seq)) + } else { + alts.push(Sequence(seq)); + Ok(mk(vec!(Alternates(alts)))) + } + } + "[" => { + // Check for special '[options]' shortcut. + if self.atis(1, "options") && self.atis(2, "]") { + self.next(); // cur == options + self.next(); // cur == ] + self.next(); + seq.push(self.maybe_repeat(Optional(vec!()))); + continue + } + self.expecting.push(']'); + seq.push(try!(self.group())); + } + "(" => { + self.expecting.push(')'); + seq.push(try!(self.group())); + } + _ => { + if Atom::is_short(self.cur()) { + seq.extend(try!(self.flag_short()).into_iter()); + } else if Atom::is_long(self.cur()) { + seq.push(try!(self.flag_long())); + } else if Atom::is_arg(self.cur()) { + // These are always positional. + // Arguments for -s and --short are picked up + // when parsing flags. + seq.push(try!(self.positional())); + } else if Atom::is_cmd(self.cur()) { + seq.push(try!(self.command())); + } else { + err!("Unknown token type '{}'.", self.cur()) + } + } + } + } + if alts.is_empty() { + Ok(Sequence(seq)) + } else { + alts.push(Sequence(seq)); + Ok(Alternates(alts)) + } + } + + fn flag_short(&mut self) -> Result, String> { + let mut seq = vec!(); + let stacked: String = self.cur()[1..].to_string(); + for (i, c) in stacked.chars().enumerate() { + let atom = self.dopt.descs.resolve(&Short(c)); + seq.push(PatAtom(atom.clone())); + + // The only way for a short option to have an argument is if + // it's specified in an option description. + if !self.dopt.has_arg(&atom) { + self.add_atom_ifnotexists(Zero, &atom); + } else { + // At this point, the flag MUST have an argument. Therefore, + // we interpret the "rest" of the characters as the argument. + // If the "rest" is empty, then we peek to find and make sure + // there is an argument. + let rest = &stacked[i+1..]; + if rest.is_empty() { + try!(self.next_flag_arg(&atom)); + } else { + try!(self.errif_invalid_flag_arg(&atom, rest)); + } + // We either error'd or consumed the rest of the short stack as + // an argument. + break + } + } + self.next(); + // This is a little weird. We've got to manually look for a repeat + // operator right after the stack, and then apply it to each short + // flag we generated. + // If "sequences" never altered semantics, then we could just use that + // here to group a short stack. + if self.atis(0, "...") { + self.next(); + seq = seq.into_iter().map(|p| Repeat(Box::new(p))).collect(); + } + Ok(seq) + } + + fn flag_long(&mut self) -> Result { + let (atom, arg) = try!(parse_long_equal(self.cur())); + let atom = self.dopt.descs.resolve(&atom); + if self.dopt.descs.contains_key(&atom) { + // Options already exist for this atom, so we must check to make + // sure things are consistent. + let has_arg = self.dopt.has_arg(&atom); + if arg.has_arg() && !has_arg { + // Found `=` in usage, but previous usage of this flag + // didn't specify an argument. + err!("Flag '{}' does not take any arguments.", atom) + } else if !arg.has_arg() && has_arg { + // Didn't find any `=` in usage for this flag, but previous + // usage of this flag specifies an argument. + // So look for `--flag ARG` + try!(self.next_flag_arg(&atom)); + // We don't care about the value of `arg` since options + // already exist. (In which case, the argument value can never + // change.) + } + } + self.add_atom_ifnotexists(arg, &atom); + self.next(); + Ok(self.maybe_repeat(PatAtom(atom))) + } + + fn next_flag_arg(&mut self, atom: &Atom) -> Result<(), String> { + try!(self.next_noeof(&*format!("argument for flag '{:?}'", atom))); + self.errif_invalid_flag_arg(atom, self.cur()) + } + + fn errif_invalid_flag_arg(&self, atom: &Atom, arg: &str) + -> Result<(), String> { + if !Atom::is_arg(arg) { + err!("Expected argument for flag '{}', but found \ + malformed argument '{}'.", atom, arg) + } + Ok(()) + } + + fn command(&mut self) -> Result { + let atom = Atom::new(self.cur()); + self.add_atom_ifnotexists(Zero, &atom); + self.next(); + Ok(self.maybe_repeat(PatAtom(atom))) + } + + fn positional(&mut self) -> Result { + let atom = Atom::new(self.cur()); + self.add_atom_ifnotexists(Zero, &atom); + self.next(); + Ok(self.maybe_repeat(PatAtom(atom))) + } + + fn add_atom_ifnotexists(&mut self, arg: Argument, atom: &Atom) { + if !self.dopt.descs.contains_key(atom) { + let opts = Options::new(false, arg); + self.dopt.descs.insert(atom.clone(), opts); + } + } + + fn group(&mut self) + -> Result { + try!(self.next_noeof("pattern")); + let pat = try!(self.pattern()); + Ok(self.maybe_repeat(pat)) + } + + fn maybe_repeat(&mut self, pat: Pattern) -> Pattern { + if self.atis(0, "...") { + self.next(); + Repeat(Box::new(pat)) + } else { + pat + } + } + + fn is_eof(&self) -> bool { + self.curi == self.tokens.len() + } + fn next(&mut self) { + if self.curi == self.tokens.len() { + return + } + self.curi += 1; + } + fn next_noeof(&mut self, expected: &str) -> Result<(), String> { + self.next(); + if self.curi == self.tokens.len() { + err!("Expected {} but reached end of usage pattern.", expected) + } + Ok(()) + } + fn cur<'r>(&'r self) -> &'r str { + &*self.tokens[self.curi] + } + fn atis(&self, offset: usize, is: &str) -> bool { + let i = self.curi + offset; + i < self.tokens.len() && self.tokens[i] == is + } +} + +#[derive(Clone, Debug)] +enum Pattern { + Alternates(Vec), + Sequence(Vec), + Optional(Vec), + Repeat(Box), + PatAtom(Atom), +} + +#[derive(PartialEq, Eq, Ord, Hash, Clone, Debug)] +pub enum Atom { + Short(char), + Long(String), + Command(String), + Positional(String), +} + +#[derive(Clone, Debug)] +pub struct Options { + /// Set to true if this atom is ever repeated in any context. + /// For positional arguments, non-argument flags and commands, repetition + /// means that they become countable. + /// For flags with arguments, repetition means multiple distinct values + /// can be specified (and are represented as a Vec). + pub repeats: bool, + + /// This specifies whether this atom has any arguments. + /// For commands and positional arguments, this is always Zero. + /// Flags can have zero or one argument, with an optionally default value. + pub arg: Argument, + + /// Whether it shows up in the "options description" second. + pub is_desc: bool, +} + +#[derive(Clone, Debug, PartialEq)] +pub enum Argument { + Zero, + One(Option), // optional default value +} + +impl Pattern { + fn add_options_shortcut(&mut self, par: &Parser) { + fn add(pat: &mut Pattern, all_atoms: &HashSet, par: &Parser) { + match *pat { + Alternates(ref mut ps) | Sequence(ref mut ps) => { + for p in ps.iter_mut() { add(p, all_atoms, par) } + } + Repeat(ref mut p) => add(&mut **p, all_atoms, par), + PatAtom(_) => {} + Optional(ref mut ps) => { + if !ps.is_empty() { + for p in ps.iter_mut() { add(p, all_atoms, par) } + } else { + for atom in par.options_atoms().into_iter() { + if !all_atoms.contains(&atom) { + ps.push(PatAtom(atom)); + } + } + } + } + } + } + let all_atoms = self.all_atoms(); + add(self, &all_atoms, par); + } + + fn all_atoms(&self) -> HashSet { + fn all_atoms(pat: &Pattern, set: &mut HashSet) { + match *pat { + Alternates(ref ps) | Sequence(ref ps) | Optional(ref ps) => { + for p in ps.iter() { all_atoms(p, set) } + } + Repeat(ref p) => all_atoms(&**p, set), + PatAtom(ref a) => { set.insert(a.clone()); } + } + } + let mut set = HashSet::new(); + all_atoms(self, &mut set); + set + } + + fn tag_repeats(&self, map: &mut SynonymMap) { + fn dotag(p: &Pattern, + rep: bool, + map: &mut SynonymMap, + seen: &mut HashSet) { + match *p { + Alternates(ref ps) => { + // This is a bit tricky. Basically, we don't want the + // existence of an item in mutually exclusive alternations + // to affect whether it repeats or not. + // However, we still need to record seeing each item in + // each alternation. + let fresh = seen.clone(); + for p in ps.iter() { + let mut isolated = fresh.clone(); + dotag(p, rep, map, &mut isolated); + for a in isolated.into_iter() { + seen.insert(a); + } + } + } + Sequence(ref ps) => { + for p in ps.iter() { + dotag(p, rep, map, seen) + } + } + Optional(ref ps) => { + for p in ps.iter() { + dotag(p, rep, map, seen) + } + } + Repeat(ref p) => dotag(&**p, true, map, seen), + PatAtom(ref atom) => { + let opt = map.find_mut(atom).expect("bug: no atom found"); + opt.repeats = opt.repeats || rep || seen.contains(atom); + seen.insert(atom.clone()); + } + } + } + let mut seen = HashSet::new(); + dotag(self, false, map, &mut seen); + } +} + +impl Atom { + pub fn new(s: &str) -> Atom { + if Atom::is_short(s) { + Short(s[1..].chars().next().unwrap()) + } else if Atom::is_long(s) { + Long(s[2..].to_string()) + } else if Atom::is_arg(s) { + if s.starts_with("<") && s.ends_with(">") { + Positional(s[1..s.len()-1].to_string()) + } else { + Positional(s.to_string()) + } + } else if Atom::is_cmd(s) { + Command(s.to_string()) + } else { + panic!("Unknown atom string: '{}'", s) + } + } + + fn is_short(s: &str) -> bool { regex!(r"^-[^-]+$").is_match(s) } + fn is_long(s: &str) -> bool { regex!(r"^--\S+(?:<[^>]+>)?$").is_match(s) } + fn is_long_argv(s: &str) -> bool { regex!(r"^--\S+(=.+)?$").is_match(s) } + fn is_arg(s: &str) -> bool { regex!(r"^(\p{Lu}+|<[^>]+>)$").is_match(s) } + fn is_cmd(s: &str) -> bool { regex!(r"^(-|--|[^-]\S*)$").is_match(s) } + + // Assigns an integer to each variant of Atom. (For easier sorting.) + fn type_as_usize(&self) -> usize { + match *self { + Short(_) => 0, + Long(_) => 1, + Command(_) => 2, + Positional(_) => 3, + } + } +} + +impl PartialOrd for Atom { + fn partial_cmp(&self, other: &Atom) -> Option { + match (self, other) { + (&Short(c1), &Short(c2)) => c1.partial_cmp(&c2), + (&Long(ref s1), &Long(ref s2)) => s1.partial_cmp(s2), + (&Command(ref s1), &Command(ref s2)) => s1.partial_cmp(s2), + (&Positional(ref s1), &Positional(ref s2)) => s1.partial_cmp(s2), + (a1, a2) => a1.type_as_usize().partial_cmp(&a2.type_as_usize()), + } + } +} + +impl fmt::Display for Atom { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Short(c) => write!(f, "-{}", c), + Long(ref s) => write!(f, "--{}", s), + Command(ref s) => write!(f, "{}", s), + Positional(ref s) => { + if s.chars().all(|c| c.is_uppercase()) { + write!(f, "{}", s) + } else { + write!(f, "<{}>", s) + } + } + } + } +} + + +impl Options { + fn new(rep: bool, arg: Argument) -> Options { + Options { repeats: rep, arg: arg, is_desc: false, } + } +} + +impl Argument { + fn has_arg(&self) -> bool { + match *self { + Zero => false, + One(_) => true, + } + } +} + +#[doc(hidden)] +pub struct Argv<'a> { + /// A representation of an argv string as an ordered list of tokens. + /// This contains only positional arguments and commands. + positional: Vec, + /// Same as positional, but contains short and long flags. + /// Each flag may have an argument string. + flags: Vec, + /// Counts the number of times each flag appears. + counts: HashMap, + + // State for parser. + dopt: &'a Parser, + argv: Vec, + curi: usize, + options_first: bool, +} + +#[derive(Clone, Debug)] +struct ArgvToken { + atom: Atom, + arg: Option, +} + +impl<'a> Argv<'a> { + fn new(dopt: &'a Parser, argv: Vec, options_first: bool) + -> Result, String> { + let mut a = Argv { + positional: vec!(), + flags: vec!(), + counts: HashMap::new(), + dopt: dopt, + argv: argv.iter().map(|s| s.to_string()).collect(), + curi: 0, + options_first: options_first, + }; + try!(a.parse()); + for flag in a.flags.iter() { + match a.counts.entry(flag.atom.clone()) { + Vacant(v) => { v.insert(1); } + Occupied(mut v) => { *v.get_mut() += 1; } + } + } + Ok(a) + } + + fn parse(&mut self) -> Result<(), String> { + let mut seen_double_dash = false; + while self.curi < self.argv.len() { + let do_flags = + !seen_double_dash + && (!self.options_first || self.positional.is_empty()); + + if do_flags && Atom::is_short(self.cur()) { + let stacked: String = self.cur()[1..].to_string(); + for (i, c) in stacked.chars().enumerate() { + let mut tok = ArgvToken { + atom: self.dopt.descs.resolve(&Short(c)), + arg: None, + }; + if !self.dopt.descs.contains_key(&tok.atom) { + err!("Unknown flag: '{}'", &tok.atom); + } + if !self.dopt.has_arg(&tok.atom) { + self.flags.push(tok); + } else { + let rest = &stacked[i+1..]; + tok.arg = Some( + if rest.is_empty() { + let arg = try!(self.next_arg(&tok.atom)); + arg.to_string() + } else { + rest.to_string() + } + ); + self.flags.push(tok); + // We've either produced an error or gobbled up the + // rest of these stacked short flags, so stop. + break + } + } + } else if do_flags && Atom::is_long_argv(self.cur()) { + let (atom, mut arg) = parse_long_equal_argv(self.cur()); + let atom = self.dopt.descs.resolve(&atom); + if !self.dopt.descs.contains_key(&atom) { + return self.err_unknown_flag(&atom) + } + if arg.is_some() && !self.dopt.has_arg(&atom) { + err!("Flag '{}' cannot have an argument, but found '{:?}'.", + &atom, &arg) + } else if arg.is_none() && self.dopt.has_arg(&atom) { + try!(self.next_noeof(&*format!("argument for flag '{:?}'", + &atom))); + arg = Some(self.cur().to_string()); + } + self.flags.push(ArgvToken { atom: atom, arg: arg }); + } else { + if self.cur() == "--" { + seen_double_dash = true; + } else { + // Yup, we *always* insert a positional argument, which + // means we completely neglect `Command` here. + // This is because we can't tell whether something is a + // `command` or not until we start pattern matching. + let tok = ArgvToken { + atom: Positional(self.cur().to_string()), + arg: None, + }; + self.positional.push(tok); + } + } + self.next() + } + Ok(()) + } + + fn err_unknown_flag(&self, atom: &Atom) -> Result<(), String> { + use std::usize::MAX; + let mut best: String = "".to_string(); + let flag = atom.to_string(); + let mut min = MAX; + + let mut possibles = Vec::new(); + + for (key, _) in self.dopt.descs.synonyms() { + possibles.push(key); + } + + for key in self.dopt.descs.keys() { + possibles.push(key); + } + + for key in possibles.iter() { + match *key { + &Long(_) | &Command(_) => { + let name = key.to_string(); + let dist = levenshtein(&flag, &name); + if dist < 3 && dist < min { + min = dist; + best = name; + } + } + _ => {} + } + } + if best.is_empty() { + err!("Unknown flag: '{}'", &atom); + } else { + err!("Unknown flag: '{}'. Did you mean '{}'?", &atom, &best) + } + } + + fn cur<'b>(&'b self) -> &'b str { self.at(0) } + fn at<'b>(&'b self, i: usize) -> &'b str { + &*self.argv[self.curi + i] + } + fn next(&mut self) { + if self.curi < self.argv.len() { + self.curi += 1 + } + } + fn next_arg<'b>(&'b mut self, atom: &Atom) -> Result<&'b str, String> { + let expected = format!("argument for flag '{:?}'", atom); + try!(self.next_noeof(&*expected)); + Ok(self.cur()) + } + fn next_noeof(&mut self, expected: &str) -> Result<(), String> { + self.next(); + if self.curi == self.argv.len() { + err!("Expected {} but reached end of arguments.", expected) + } + Ok(()) + } +} + +impl<'a> fmt::Debug for Argv<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + try!(writeln!(f, "Positional: {:?}", self.positional)); + try!(writeln!(f, "Flags: {:?}", self.flags)); + try!(writeln!(f, "Counts: {:?}", self.counts)); + Ok(()) + } +} + +struct Matcher<'a, 'b:'a> { + argv: &'a Argv<'b>, +} + +#[derive(Clone, Debug, PartialEq)] +struct MState { + argvi: usize, // index into Argv.positional + counts: HashMap, // flags remaining for pattern consumption + max_counts: HashMap, // optional flag appearances + vals: HashMap, +} + +impl MState { + fn fill_value(&mut self, key: Atom, rep: bool, arg: Option) + -> bool { + match (arg, rep) { + (None, false) => { + self.vals.insert(key, Switch(true)); + } + (Some(arg), false) => { + self.vals.insert(key, Plain(Some(arg))); + } + (None, true) => { + match self.vals.entry(key) { + Vacant(v) => { v.insert(Counted(1)); } + Occupied(mut v) => { + match *v.get_mut() { + Counted(ref mut c) => { *c += 1; } + _ => return false, + } + } + } + } + (Some(arg), true) => { + match self.vals.entry(key) { + Vacant(v) => { v.insert(List(vec!(arg))); } + Occupied(mut v) => { + match *v.get_mut() { + List(ref mut vs) => vs.push(arg), + _ => return false, + } + } + } + } + } + true + } + + fn add_value(&mut self, opts: &Options, + spec: &Atom, atom: &Atom, arg: &Option) -> bool { + assert!(opts.arg.has_arg() == arg.is_some(), + "'{:?}' should have an argument but doesn't", atom); + match *atom { + Short(_) | Long(_) => { + self.fill_value(spec.clone(), opts.repeats, arg.clone()) + } + Positional(ref v) => { + assert!(!opts.arg.has_arg()); + self.fill_value(spec.clone(), opts.repeats, Some(v.clone())) + } + Command(_) => { + assert!(!opts.arg.has_arg()); + self.fill_value(spec.clone(), opts.repeats, None) + } + } + } + + fn use_flag(&mut self, flag: &Atom) -> bool { + match self.max_counts.entry(flag.clone()) { + Vacant(v) => { v.insert(0); } + Occupied(_) => {} + } + match self.counts.entry(flag.clone()) { + Vacant(_) => { false } + Occupied(mut v) => { + let c = v.get_mut(); + if *c == 0 { + false + } else { + *c -= 1; + true + } + } + } + } + + fn use_optional_flag(&mut self, flag: &Atom) { + match self.max_counts.entry(flag.clone()) { + Vacant(v) => { v.insert(1); } + Occupied(mut v) => { *v.get_mut() += 1; } + } + } + + fn match_cmd_or_posarg(&mut self, spec: &Atom, argv: &ArgvToken) + -> Option { + match (spec, &argv.atom) { + (_, &Command(_)) => { + // This is impossible because the argv parser doesn't know + // how to produce `Command` values. + unreachable!() + } + (&Command(ref n1), &Positional(ref n2)) if n1 == n2 => { + // Coerce a positional to a command because the pattern + // demands it and the positional argument matches it. + self.argvi += 1; + Some(ArgvToken { atom: spec.clone(), arg: None }) + } + (&Positional(_), _) => { + self.argvi += 1; + Some(argv.clone()) + } + _ => None, + } + } +} + +impl<'a, 'b> Matcher<'a, 'b> { + fn matches(argv: &'a Argv, pat: &Pattern) + -> Option> { + let m = Matcher { argv: argv }; + let init = MState { + argvi: 0, + counts: argv.counts.clone(), + max_counts: HashMap::new(), + vals: HashMap::new(), + }; + m.states(pat, &init) + .into_iter() + .filter(|s| m.state_consumed_all_argv(s)) + .filter(|s| m.state_has_valid_flags(s)) + .filter(|s| m.state_valid_num_flags(s)) + .collect::>() + .into_iter() + .next() + .map(|mut s| { + m.add_flag_values(&mut s); + m.add_default_values(&mut s); + + // Build a synonym map so that it's easier to look up values. + let mut synmap: SynonymMap = + s.vals.into_iter() + .map(|(k, v)| (k.to_string(), v)) + .collect(); + for (from, to) in argv.dopt.descs.synonyms() { + let (from, to) = (from.to_string(), to.to_string()); + if synmap.contains_key(&to) { + synmap.insert_synonym(from, to); + } + } + synmap + }) + } + + fn token_from(&'a self, state: &MState) -> Option<&'a ArgvToken> { + self.argv.positional.get(state.argvi) + } + + fn add_value(&self, state: &mut MState, + atom_spec: &Atom, atom: &Atom, arg: &Option) + -> bool { + let opts = self.argv.dopt.descs.get(atom_spec); + state.add_value(opts, atom_spec, atom, arg) + } + + fn add_flag_values(&self, state: &mut MState) { + for tok in self.argv.flags.iter() { + self.add_value(state, &tok.atom, &tok.atom, &tok.arg); + } + } + + fn add_default_values(&self, state: &mut MState) { + let vs = &mut state.vals; + for (a, opts) in self.argv.dopt.descs.iter() { + if vs.contains_key(a) { + continue + } + let atom = a.clone(); + match (opts.repeats, &opts.arg) { + (false, &Zero) => { + match a { + &Positional(_) => vs.insert(atom, Plain(None)), + _ => vs.insert(atom, Switch(false)), + }; + } + (true, &Zero) => { + match a { + &Positional(_) => vs.insert(atom, List(vec!())), + _ => vs.insert(atom, Counted(0)), + }; + } + (false, &One(None)) => { vs.insert(atom, Plain(None)); } + (true, &One(None)) => { vs.insert(atom, List(vec!())); } + (false, &One(Some(ref v))) => { + vs.insert(atom, Plain(Some(v.clone()))); + } + (true, &One(Some(ref v))) => { + let words = regex!(r"\s+") + .split(v) + .map(|s| s.to_owned()) + .collect(); + vs.insert(atom, List(words)); + } + } + } + } + + fn state_consumed_all_argv(&self, state: &MState) -> bool { + self.argv.positional.len() == state.argvi + } + + fn state_has_valid_flags(&self, state: &MState) -> bool { + self.argv.counts.keys().all(|flag| state.max_counts.contains_key(flag)) + } + + fn state_valid_num_flags(&self, state: &MState) -> bool { + state.counts.iter().all( + |(flag, count)| count <= &state.max_counts[flag]) + } + + fn states(&self, pat: &Pattern, init: &MState) -> Vec { + match *pat { + Alternates(ref ps) => { + let mut alt_states = vec!(); + for p in ps.iter() { + alt_states.extend(self.states(p, init).into_iter()); + } + alt_states + } + Sequence(ref ps) => { + let (mut states, mut next) = (vec!(), vec!()); + let mut iter = ps.iter(); + match iter.next() { + None => return vec!(init.clone()), + Some(p) => states.extend(self.states(p, init).into_iter()), + } + for p in iter { + for s in states.into_iter() { + next.extend(self.states(p, &s).into_iter()); + } + states = vec!(); + states.extend(next.into_iter()); + next = vec!(); + } + states + } + Optional(ref ps) => { + let mut base = init.clone(); + let mut noflags = vec!(); + for p in ps.iter() { + match p { + &PatAtom(ref a @ Short(_)) + | &PatAtom(ref a @ Long(_)) => { + let argv_count = self.argv.counts.get(a) + .map(|&x|x).unwrap_or(0); + let max_count = base.max_counts.get(a) + .map(|&x|x).unwrap_or(0); + if argv_count > max_count { + base.use_optional_flag(a); + } + } + other => { + noflags.push(other); + } + } + } + let mut states = vec!(); + self.all_option_states(&base, &mut states, &*noflags); + states + } + Repeat(ref p) => { + let mut grouped_states = vec!(self.states(&**p, init)); + loop { + let mut nextss = vec!(); + for s in grouped_states.last().unwrap().iter() { + nextss.extend( + self.states(&**p, s) + .into_iter() + .filter(|snext| snext != s)); + } + if nextss.is_empty() { + break + } + grouped_states.push(nextss); + } + grouped_states + .into_iter() + .flat_map(|ss| ss.into_iter()) + .collect::>() + } + PatAtom(ref atom) => { + let mut state = init.clone(); + match *atom { + Short(_) | Long(_) => { + if !state.use_flag(atom) { + return vec!() + } + } + Command(_) | Positional(_) => { + let tok = + match self.token_from(init) { + None => return vec!(), + Some(tok) => tok, + }; + let tok = + match state.match_cmd_or_posarg(atom, tok) { + None => return vec!(), + Some(tok) => tok, + }; + if !self.add_value(&mut state, atom, + &tok.atom, &tok.arg) { + return vec!() + } + } + } + vec!(state) + } + } + } + + fn all_option_states(&self, base: &MState, states: &mut Vec, + pats: &[&Pattern]) { + if pats.is_empty() { + states.push(base.clone()); + } else { + let (pat, rest) = (*pats.first().unwrap(), &pats[1..]); + for s in self.states(pat, base).into_iter() { + self.all_option_states(&s, states, rest); + } + // Order is important here! This must come after the loop above + // because we prefer presence over absence. The first state wins. + self.all_option_states(base, states, &pats[1..]); + } + } +} + +// Tries to parse a long flag of the form '--flag[=arg]' and returns a tuple +// with the flag atom and whether there is an argument or not. +// If '=arg' exists and 'arg' isn't a valid argument, an error is returned. +fn parse_long_equal(flag: &str) -> Result<(Atom, Argument), String> { + let long_equal = regex!("^(?P[^=]+)=(?P.+)$"); + match long_equal.captures(flag) { + None => Ok((Atom::new(flag), Zero)), + Some(cap) => { + let arg = cap.name("arg").unwrap_or("").to_string(); + if !Atom::is_arg(&*arg) { + err!("Argument '{}' for flag '{}' is not in the \ + form ARG or .", flag, arg) + } + Ok((Atom::new(cap.name("name").unwrap_or("")), One(None))) + } + } +} + +fn parse_long_equal_argv(flag: &str) -> (Atom, Option) { + let long_equal = regex!("^(?P[^=]+)=(?P.*)$"); + match long_equal.captures(flag) { + None => (Atom::new(flag), None), + Some(cap) => ( + Atom::new(cap.name("name").unwrap_or("")), + Some(cap.name("arg").unwrap_or("").to_string()), + ), + } +} + +// Tokenizes a usage pattern. +// Beware: regex hack ahead. Tokenizes based on whitespace separated words. +// It first normalizes `[xyz]` -> `[ xyz ]` so that delimiters are tokens. +// Similarly for `...`, `(`, `)` and `|`. +// One hitch: `--flag=` is allowed, so we use a regex to pick out +// words. +fn pattern_tokens(pat: &str) -> Vec { + let rpat = regex!(r"\.\.\.|\[|\]|\(|\)|\|"); + let rwords = regex!(r"--\S+?=<[^>]+>|<[^>]+>|\S+"); // alt order matters + + let pat = rpat.replace_all(pat.trim(), " $0 "); + let mut words = vec!(); + for cap in rwords.captures_iter(&*pat) { + words.push(cap.at(0).unwrap_or("").to_string()); + } + words +} diff --git a/deps/docopt-0.6.67/src/synonym.rs b/deps/docopt-0.6.67/src/synonym.rs new file mode 100644 index 000000000..e0b26f5b8 --- /dev/null +++ b/deps/docopt-0.6.67/src/synonym.rs @@ -0,0 +1,107 @@ +use std::collections::HashMap; +use std::collections::hash_map::{Iter, Keys}; +use std::fmt::Debug; +use std::hash::Hash; +use std::iter::{FromIterator, IntoIterator}; +use std::mem; + +#[derive(Clone)] +pub struct SynonymMap { + vals: HashMap, + syns: HashMap, +} + +impl SynonymMap { + pub fn new() -> SynonymMap { + SynonymMap { + vals: HashMap::new(), + syns: HashMap::new(), + } + } + + pub fn insert_synonym(&mut self, from: K, to: K) -> bool { + assert!(self.vals.contains_key(&to)); + self.syns.insert(from, to).is_none() + } + + pub fn keys<'a>(&'a self) -> Keys<'a, K, V> { + self.vals.keys() + } + + pub fn iter<'a>(&'a self) -> Iter<'a, K, V> { + self.vals.iter() + } + + pub fn synonyms<'a>(&'a self) -> Iter<'a, K, K> { + self.syns.iter() + } + + pub fn find<'a>(&'a self, k: &K) -> Option<&'a V> { + self.with_key(k, |k| self.vals.get(k)) + } + + pub fn contains_key(&self, k: &K) -> bool { + self.with_key(k, |k| self.vals.contains_key(k)) + } + + pub fn len(&self) -> usize { + self.vals.len() + } + + fn with_key(&self, k: &K, with: F) -> T where F: FnOnce(&K) -> T { + if self.syns.contains_key(k) { + with(&self.syns[k]) + } else { + with(k) + } + } +} + +impl SynonymMap { + pub fn resolve(&self, k: &K) -> K { + self.with_key(k, |k| k.clone()) + } + + pub fn get<'a>(&'a self, k: &K) -> &'a V { + self.find(k).unwrap() + } + + pub fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { + if self.syns.contains_key(k) { + self.vals.get_mut(&self.syns[k]) + } else { + self.vals.get_mut(k) + } + } + + pub fn swap(&mut self, k: K, mut new: V) -> Option { + if self.syns.contains_key(&k) { + let old = self.vals.get_mut(&k).unwrap(); + mem::swap(old, &mut new); + Some(new) + } else { + self.vals.insert(k, new) + } + } + + pub fn insert(&mut self, k: K, v: V) -> bool { + self.swap(k, v).is_none() + } +} + +impl FromIterator<(K, V)> for SynonymMap { + fn from_iter>(iter: T) -> SynonymMap { + let mut map = SynonymMap::new(); + for (k, v) in iter { + map.insert(k, v); + } + map + } +} + +impl Debug for SynonymMap { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + try!(self.vals.fmt(f)); + write!(f, " (synomyns: {:?})", self.syns) + } +} diff --git a/deps/docopt-0.6.67/src/test/mod.rs b/deps/docopt-0.6.67/src/test/mod.rs new file mode 100644 index 000000000..5c5673ba0 --- /dev/null +++ b/deps/docopt-0.6.67/src/test/mod.rs @@ -0,0 +1,68 @@ +use std::collections::HashMap; +use {Docopt, ArgvMap}; +use Value::{self, Switch, Plain}; + +fn get_args(doc: &str, argv: &[&'static str]) -> ArgvMap { + let dopt = match Docopt::new(doc) { + Err(err) => panic!("Invalid usage: {}", err), + Ok(dopt) => dopt, + }; + match dopt.argv(vec!["cmd"].iter().chain(argv.iter()).cloned()).parse() { + Err(err) => panic!("{}", err), + Ok(vals) => vals, + } +} + +fn map_from_alist(alist: Vec<(&'static str, Value)>) -> HashMap { + alist.into_iter().map(|(k, v)| (k.to_string(), v)).collect() +} + +fn same_args(expected: &HashMap, got: &ArgvMap) { + for (k, ve) in expected.iter() { + match got.map.find(k) { + None => panic!("EXPECTED has '{}' but GOT does not.", k), + Some(vg) => assert!(ve == vg, + "{}: EXPECTED = '{:?}' != '{:?}' = GOT", k, ve, vg), + } + } + for (k, vg) in got.map.iter() { + match got.map.find(k) { + None => panic!("GOT has '{}' but EXPECTED does not.", k), + Some(ve) => assert!(vg == ve, + "{}: GOT = '{:?}' != '{:?}' = EXPECTED", k, vg, ve), + } + } +} + +macro_rules! test_expect( + ($name:ident, $doc:expr, $args:expr, $expected:expr) => ( + #[test] + fn $name() { + let vals = get_args($doc, $args); + let expected = map_from_alist($expected); + same_args(&expected, &vals); + } + ); +); + +macro_rules! test_user_error( + ($name:ident, $doc:expr, $args:expr) => ( + #[test] + #[should_panic] + fn $name() { get_args($doc, $args); } + ); +); + +test_expect!(test_issue_13, "Usage: prog file ", &["file", "file"], + vec![("file", Switch(true)), + ("", Plain(Some("file".to_string())))]); + +test_expect!(test_issue_129, "Usage: prog [options] + +Options: + --foo ARG Foo foo.", + &["--foo=a b"], + vec![("--foo", Plain(Some("a b".into())))]); + +mod testcases; +mod suggestions; diff --git a/deps/docopt-0.6.67/src/test/suggestions.rs b/deps/docopt-0.6.67/src/test/suggestions.rs new file mode 100644 index 000000000..77bf47fbb --- /dev/null +++ b/deps/docopt-0.6.67/src/test/suggestions.rs @@ -0,0 +1,72 @@ +use {Docopt, Error}; + +fn get_suggestion(doc: &str, argv: &[&'static str]) -> Error { + let dopt = + match Docopt::new(doc) { + Err(err) => panic!("Invalid usage: {}", err), + Ok(dopt) => dopt, + }; + let mut argv: Vec<_> = argv.iter().map(|x| x.to_string()).collect(); + argv.insert(0, "prog".to_string()); + match dopt.argv(argv.into_iter()).parse() { + Err(err) => err, + Ok(_) => panic!("Should have been a user error"), + } +} + +macro_rules! test_suggest( + ($name:ident, $doc:expr, $args:expr, $expected:expr) => ( + #[test] + fn $name() { + let sg = get_suggestion($doc, $args); + println!("{}", sg); + match sg { + Error::WithProgramUsage(e, _) => { + match *e { + Error::Argv(msg) => { + println!("{:?}",msg); + assert_eq!(msg, $expected); + } + err => panic!("Error other than argv: {:?}", err) + } + }, + _ => panic!("Error without program usage") + } + } + ); +); + + +test_suggest!(test_suggest_1, "Usage: prog [--release]", &["--releas"], "Unknown flag: '--releas'. Did you mean '--release'?"); + +test_suggest!(test_suggest_2, +"Usage: prog [-a] + prog [-a] ... + prog [-e] + Options: + -a, --archive Copy everything. +", +&["-d"], "Unknown flag: '-d'"); + + +test_suggest!(test_suggest_3, +"Usage: prog [-a] + prog [-a] ... + prog [-e] + Options: + -a, --archive Copy everything. + -e, --export Export all the things. +", +&["--expotr"], "Unknown flag: '--expotr'. Did you mean '--export'?"); + + +test_suggest!(test_suggest_4, +"Usage: prog [--import] [--complete] +", +&["--mport", "--complte"], "Unknown flag: '--mport'. Did you mean '--import'?"); + +test_suggest!(test_suggest_5, +"Usage: prog [--import] [--complete] +", +&["--import", "--complte"], "Unknown flag: '--complte'. Did you mean '--complete'?"); + diff --git a/deps/docopt-0.6.67/src/test/testcases.docopt b/deps/docopt-0.6.67/src/test/testcases.docopt new file mode 100644 index 000000000..480f1a200 --- /dev/null +++ b/deps/docopt-0.6.67/src/test/testcases.docopt @@ -0,0 +1,990 @@ +r"""Usage: prog + +""" +$ prog +{} + +$ prog --xxx +"user-error" + + +r"""Usage: prog [options] + +Options: -a All. + +""" +$ prog +{"-a": false} + +$ prog -a +{"-a": true} + +$ prog -x +"user-error" + + +r"""Usage: prog [options] + +Options: --all All. + +""" +$ prog +{"--all": false} + +$ prog --all +{"--all": true} + +$ prog --xxx +"user-error" + + +r"""Usage: prog [options] + +Options: -v, --verbose Verbose. + +""" +$ prog --verbose +{"--verbose": true} + +$ prog --ver +"user-error" + +$ prog -v +{"--verbose": true} + + +r"""Usage: prog [options] + +Options: -p PATH + +""" +$ prog -p home/ +{"-p": "home/"} + +$ prog -phome/ +{"-p": "home/"} + +$ prog -p +"user-error" + + +r"""Usage: prog [options] + +Options: --path + +""" +$ prog --path home/ +{"--path": "home/"} + +$ prog --path=home/ +{"--path": "home/"} + +$ prog --pa home/ +"user-error" + +$ prog --pa=home/ +"user-error" + +$ prog --path +"user-error" + + +r"""Usage: prog [options] + +Options: -p PATH, --path= Path to files. + +""" +$ prog -proot +{"--path": "root"} + + +r"""Usage: prog [options] + +Options: -p --path PATH Path to files. + +""" +$ prog -p root +{"--path": "root"} + +$ prog --path root +{"--path": "root"} + + +r"""Usage: prog [options] + +Options: + -p PATH Path to files [default: ./] + +""" +$ prog +{"-p": "./"} + +$ prog -phome +{"-p": "home"} + + +r"""UsAgE: prog [options] + +OpTiOnS: --path= Path to files + [dEfAuLt: /root] + +""" +$ prog +{"--path": "/root"} + +$ prog --path=home +{"--path": "home"} + + +r"""usage: prog [options] + +options: + -a Add + -r Remote + -m Message + +""" +$ prog -a -r -m Hello +{"-a": true, + "-r": true, + "-m": "Hello"} + +$ prog -armyourass +{"-a": true, + "-r": true, + "-m": "yourass"} + +$ prog -a -r +{"-a": true, + "-r": true, + "-m": null} + + +r"""Usage: prog [options] + +Options: --version + --verbose + +""" +$ prog --version +{"--version": true, + "--verbose": false} + +$ prog --verbose +{"--version": false, + "--verbose": true} + +$ prog --ver +"user-error" + +$ prog --verb +"user-error" + + +r"""usage: prog [-a -r -m ] + +options: + -a Add + -r Remote + -m Message + +""" +$ prog -armyourass +{"-a": true, + "-r": true, + "-m": "yourass"} + + +r"""usage: prog [-armMSG] + +options: -a Add + -r Remote + -m Message + +""" +$ prog -a -r -m Hello +{"-a": true, + "-r": true, + "-m": "Hello"} + + +r"""usage: prog -a -b + +options: + -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog +"user-error" + + +r"""usage: prog (-a -b) + +options: -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog +"user-error" + + +r"""usage: prog [-a] -b + +options: -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog -b +{"-a": false, "-b": true} + +$ prog +"user-error" + + +r"""usage: prog [(-a -b)] + +options: -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog -b +"user-error" + +$ prog +{"-a": false, "-b": false} + + +r"""usage: prog (-a|-b) + +options: -a + -b + +""" +$ prog -a -b +"user-error" + +$ prog +"user-error" + +$ prog -a +{"-a": true, "-b": false} + +$ prog -b +{"-a": false, "-b": true} + + +r"""usage: prog [ -a | -b ] + +options: -a + -b + +""" +$ prog -a -b +"user-error" + +$ prog +{"-a": false, "-b": false} + +$ prog -a +{"-a": true, "-b": false} + +$ prog -b +{"-a": false, "-b": true} + + +r"""usage: prog """ +$ prog 10 +{"": "10"} + +$ prog 10 20 +"user-error" + +$ prog +"user-error" + + +r"""usage: prog []""" +$ prog 10 +{"": "10"} + +$ prog 10 20 +"user-error" + +$ prog +{"": null} + + +r"""usage: prog """ +$ prog 10 20 40 +{"": "10", "": "20", "": "40"} + +$ prog 10 20 +"user-error" + +$ prog +"user-error" + + +r"""usage: prog [ ]""" +$ prog 10 20 40 +{"": "10", "": "20", "": "40"} + +$ prog 10 20 +{"": "10", "": "20", "": null} + +$ prog +"user-error" + + +r"""usage: prog [ | ]""" +$ prog 10 20 40 +"user-error" + +$ prog 20 40 +{"": null, "": "20", "": "40"} + +$ prog +{"": null, "": null, "": null} + + +r"""usage: prog ( --all | ) + +options: + --all + +""" +$ prog 10 --all +{"": "10", "--all": true, "": null} + +$ prog 10 +{"": null, "--all": false, "": "10"} + +$ prog +"user-error" + + +r"""usage: prog [ ]""" +$ prog 10 20 +{"": ["10", "20"]} + +$ prog 10 +{"": ["10"]} + +$ prog +{"": []} + + +r"""usage: prog [( )]""" +$ prog 10 20 +{"": ["10", "20"]} + +$ prog 10 +"user-error" + +$ prog +{"": []} + + +r"""usage: prog NAME...""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +"user-error" + + +r"""usage: prog [NAME]...""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +{"NAME": []} + + +r"""usage: prog [NAME...]""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +{"NAME": []} + + +r"""usage: prog [NAME [NAME ...]]""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +{"NAME": []} + + +r"""usage: prog (NAME | --foo NAME) + +options: --foo + +""" +$ prog 10 +{"NAME": "10", "--foo": false} + +$ prog --foo 10 +{"NAME": "10", "--foo": true} + +$ prog --foo=10 +"user-error" + + +r"""usage: prog (NAME | --foo) [--bar | NAME] + +options: --foo +options: --bar + +""" +$ prog 10 +{"NAME": ["10"], "--foo": false, "--bar": false} + +$ prog 10 20 +{"NAME": ["10", "20"], "--foo": false, "--bar": false} + +$ prog --foo --bar +{"NAME": [], "--foo": true, "--bar": true} + + +r"""Naval Fate. + +Usage: + prog ship new ... + prog ship [] move [--speed=] + prog ship shoot + prog mine (set|remove) [--moored|--drifting] + prog -h | --help + prog --version + +Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Mored (anchored) mine. + --drifting Drifting mine. + +""" +$ prog ship Guardian move 150 300 --speed=20 +{"--drifting": false, + "--help": false, + "--moored": false, + "--speed": "20", + "--version": false, + "": ["Guardian"], + "": "150", + "": "300", + "mine": false, + "move": true, + "new": false, + "remove": false, + "set": false, + "ship": true, + "shoot": false} + + +r"""usage: prog --hello""" +$ prog --hello +{"--hello": true} + + +r"""usage: prog [--hello=]""" +$ prog +{"--hello": null} + +$ prog --hello wrld +{"--hello": "wrld"} + + +r"""usage: prog [-o]""" +$ prog +{"-o": false} + +$ prog -o +{"-o": true} + + +r"""usage: prog [-opr]""" +$ prog -op +{"-o": true, "-p": true, "-r": false} + + +r"""usage: prog --aabb | --aa""" +$ prog --aa +{"--aabb": false, "--aa": true} + +$ prog --a +"user-error" # not a unique prefix + +# +# Counting number of flags +# + +r"""Usage: prog -v""" +$ prog -v +{"-v": true} + + +r"""Usage: prog [-v -v]""" +$ prog +{"-v": 0} + +$ prog -v +{"-v": 1} + +$ prog -vv +{"-v": 2} + + +r"""Usage: prog -v ...""" +$ prog +"user-error" + +$ prog -v +{"-v": 1} + +$ prog -vv +{"-v": 2} + +$ prog -vvvvvv +{"-v": 6} + + +r"""Usage: prog [-v | -vv | -vvv] + +This one is probably most readable user-friednly variant. + +""" +$ prog +{"-v": 0} + +$ prog -v +{"-v": 1} + +$ prog -vv +{"-v": 2} + +$ prog -vvvv +"user-error" + + +r"""usage: prog [--ver --ver]""" +$ prog --ver --ver +{"--ver": 2} + + +# +# Counting commands +# + +r"""usage: prog [go]""" +$ prog go +{"go": true} + + +r"""usage: prog [go go]""" +$ prog +{"go": 0} + +$ prog go +{"go": 1} + +$ prog go go +{"go": 2} + +$ prog go go go +"user-error" + +r"""usage: prog go...""" +$ prog go go go go go +{"go": 5} + +# +# [options] does not include options from usage-pattern +# +r"""usage: prog [options] [-a] + +options: -a + -b +""" +$ prog -a +{"-a": true, "-b": false} + +$ prog -aa +"user-error" + +# +# Test [options] shourtcut +# + +r"""Usage: prog [options] A + +Options: + -q Be quiet + -v Be verbose. + +""" +$ prog arg +{"A": "arg", "-v": false, "-q": false} + +$ prog -v arg +{"A": "arg", "-v": true, "-q": false} + +$ prog -q arg +{"A": "arg", "-v": false, "-q": true} + +# +# Test single dash +# + +r"""usage: prog [-]""" + +$ prog - +{"-": true} + +$ prog +{"-": false} + +# +# If argument is repeated, its value should always be a list +# + +r"""usage: prog [NAME [NAME ...]]""" + +$ prog a b +{"NAME": ["a", "b"]} + +$ prog +{"NAME": []} + +# +# Option's argument defaults to null/None +# + +r"""usage: prog [options] + +options: + -a Add + -m Message + +""" +$ prog -a +{"-m": null, "-a": true} + +# +# Test options without description +# + +r"""usage: prog --hello""" +$ prog --hello +{"--hello": true} + +r"""usage: prog [--hello=]""" +$ prog +{"--hello": null} + +$ prog --hello wrld +{"--hello": "wrld"} + +r"""usage: prog [-o]""" +$ prog +{"-o": false} + +$ prog -o +{"-o": true} + +r"""usage: prog [-opr]""" +$ prog -op +{"-o": true, "-p": true, "-r": false} + +r"""usage: git [-v | --verbose]""" +$ prog -v +{"-v": true, "--verbose": false} + +r"""usage: git remote [-v | --verbose]""" +$ prog remote -v +{"remote": true, "-v": true, "--verbose": false} + +# +# Test empty usage pattern +# + +r"""usage: prog""" +$ prog +{} + +r"""usage: prog + prog +""" +$ prog 1 2 +{"": "1", "": "2"} + +$ prog +{"": null, "": null} + +r"""usage: prog + prog +""" +$ prog +{"": null, "": null} + +# +# Option's argument should not capture default value from usage pattern +# + +r"""usage: prog [--file=]""" +$ prog +{"--file": null} + +r"""usage: prog [--file=] + +options: --file + +""" +$ prog +{"--file": null} + +r"""Usage: prog [-a ] + +Options: -a, --address TCP address [default: localhost:6283]. + +""" +$ prog +{"--address": "localhost:6283"} + +# +# If option with argument could be repeated, +# its arguments should be accumulated into a list +# + +r"""usage: prog --long= ...""" + +$ prog --long one +{"--long": ["one"]} + +$ prog --long one --long two +{"--long": ["one", "two"]} + +# +# Test multiple elements repeated at once +# + +r"""usage: prog (go --speed=)...""" +$ prog go left --speed=5 go right --speed=9 +{"go": 2, "": ["left", "right"], "--speed": ["5", "9"]} + +# +# Required options should work with option shortcut +# + +r"""usage: prog [options] -a + +options: -a + +""" +$ prog -a +{"-a": true} + +# +# If option could be repeated its defaults should be split into a list +# + +r"""usage: prog [-o ]... + +options: -o [default: x] + +""" +$ prog -o this -o that +{"-o": ["this", "that"]} + +$ prog +{"-o": ["x"]} + +r"""usage: prog [-o ]... + +options: -o [default: x y] + +""" +$ prog -o this +{"-o": ["this"]} + +$ prog +{"-o": ["x", "y"]} + +# +# Test stacked option's argument +# + +r"""usage: prog -pPATH + +options: -p PATH + +""" +$ prog -pHOME +{"-p": "HOME"} + +# +# Issue 56: Repeated mutually exclusive args give nested lists sometimes +# + +r"""Usage: foo (--xx=X|--yy=Y)...""" +$ prog --xx=1 --yy=2 +{"--xx": ["1"], "--yy": ["2"]} + +# +# POSIXly correct tokenization +# + +r"""usage: prog []""" +$ prog f.txt +{"": "f.txt"} + +r"""usage: prog [--input=]...""" +$ prog --input a.txt --input=b.txt +{"--input": ["a.txt", "b.txt"]} + +# +# Issue 85: `[options]` shourtcut with multiple subcommands +# + +r"""usage: prog good [options] + prog fail [options] + +options: --loglevel=N + +""" +$ prog fail --loglevel 5 +{"--loglevel": "5", "fail": true, "good": false} + +# +# Usage-section syntax +# + +r"""usage:prog --foo""" +$ prog --foo +{"--foo": true} + +r"""PROGRAM USAGE: prog --foo""" +$ prog --foo +{"--foo": true} + +r"""Usage: prog --foo + prog --bar +NOT PART OF SECTION""" +$ prog --foo +{"--foo": true, "--bar": false} + +r"""Usage: + prog --foo + prog --bar + +NOT PART OF SECTION""" +$ prog --foo +{"--foo": true, "--bar": false} + +r"""Usage: + prog --foo + prog --bar +NOT PART OF SECTION""" +$ prog --foo +{"--foo": true, "--bar": false} + +# +# Options-section syntax +# + +r"""Usage: prog [options] + +global options: --foo +local options: --baz + --bar +other options: + --egg + --spam +-not-an-option- + +""" +$ prog --bar --egg +{"--bar": true, "--egg": true, "--spam": false} + +r"""Usage: prog [-a] [--] [...]""" +$ program -a +{"-a": true, "": []} + +r"""Usage: prog [-a] [--] [...]""" +$ program -- +{"-a": false, "": []} + +r"""Usage: prog [-a] [--] [...]""" +$ program -a -- -b +{"-a": true, "": ["-b"]} + +r"""Usage: prog [-a] [--] [...]""" +$ program -a -- -a +{"-a": true, "": ["-a"]} + +r"""Usage: prog [-a] [--] [...]""" +$ program -- -a +{"-a": false, "": ["-a"]} + +r"""Usage: prog test [options] [--] [...]""" +$ program test a -- -b +{"": ["a", "-b"]} + +r"""Usage: prog test [options] [--] [...]""" +$ program test -- -b +{"": ["-b"]} + +r"""Usage: prog test [options] [--] [...]""" +$ program test a -b +"user-error" diff --git a/deps/docopt-0.6.67/src/test/testcases.rs b/deps/docopt-0.6.67/src/test/testcases.rs new file mode 100644 index 000000000..60ce56104 --- /dev/null +++ b/deps/docopt-0.6.67/src/test/testcases.rs @@ -0,0 +1,651 @@ +// !!! ATTENTION !!! +// This file is automatically generated by `scripts/mk-testcases`. +// Please do not edit this file directly! + +use Value::{Switch, Counted, Plain, List}; +use test::{get_args, map_from_alist, same_args}; + +test_expect!(test_0_testcases, "Usage: prog", &[], vec!()); + +test_user_error!(test_1_testcases, "Usage: prog", &["--xxx"]); + +test_expect!(test_2_testcases, "Usage: prog [options] + +Options: -a All.", &[], vec!(("-a", Switch(false)))); + +test_expect!(test_3_testcases, "Usage: prog [options] + +Options: -a All.", &["-a"], vec!(("-a", Switch(true)))); + +test_user_error!(test_4_testcases, "Usage: prog [options] + +Options: -a All.", &["-x"]); + +test_expect!(test_5_testcases, "Usage: prog [options] + +Options: --all All.", &[], vec!(("--all", Switch(false)))); + +test_expect!(test_6_testcases, "Usage: prog [options] + +Options: --all All.", &["--all"], vec!(("--all", Switch(true)))); + +test_user_error!(test_7_testcases, "Usage: prog [options] + +Options: --all All.", &["--xxx"]); + +test_expect!(test_8_testcases, "Usage: prog [options] + +Options: -v, --verbose Verbose.", &["--verbose"], vec!(("--verbose", Switch(true)))); + +test_user_error!(test_9_testcases, "Usage: prog [options] + +Options: -v, --verbose Verbose.", &["--ver"]); + +test_expect!(test_10_testcases, "Usage: prog [options] + +Options: -v, --verbose Verbose.", &["-v"], vec!(("--verbose", Switch(true)))); + +test_expect!(test_11_testcases, "Usage: prog [options] + +Options: -p PATH", &["-p", "home/"], vec!(("-p", Plain(Some("home/".to_string()))))); + +test_expect!(test_12_testcases, "Usage: prog [options] + +Options: -p PATH", &["-phome/"], vec!(("-p", Plain(Some("home/".to_string()))))); + +test_user_error!(test_13_testcases, "Usage: prog [options] + +Options: -p PATH", &["-p"]); + +test_expect!(test_14_testcases, "Usage: prog [options] + +Options: --path ", &["--path", "home/"], vec!(("--path", Plain(Some("home/".to_string()))))); + +test_expect!(test_15_testcases, "Usage: prog [options] + +Options: --path ", &["--path=home/"], vec!(("--path", Plain(Some("home/".to_string()))))); + +test_user_error!(test_16_testcases, "Usage: prog [options] + +Options: --path ", &["--pa", "home/"]); + +test_user_error!(test_17_testcases, "Usage: prog [options] + +Options: --path ", &["--pa=home/"]); + +test_user_error!(test_18_testcases, "Usage: prog [options] + +Options: --path ", &["--path"]); + +test_expect!(test_19_testcases, "Usage: prog [options] + +Options: -p PATH, --path= Path to files.", &["-proot"], vec!(("--path", Plain(Some("root".to_string()))))); + +test_expect!(test_20_testcases, "Usage: prog [options] + +Options: -p --path PATH Path to files.", &["-p", "root"], vec!(("--path", Plain(Some("root".to_string()))))); + +test_expect!(test_21_testcases, "Usage: prog [options] + +Options: -p --path PATH Path to files.", &["--path", "root"], vec!(("--path", Plain(Some("root".to_string()))))); + +test_expect!(test_22_testcases, "Usage: prog [options] + +Options: + -p PATH Path to files [default: ./]", &[], vec!(("-p", Plain(Some("./".to_string()))))); + +test_expect!(test_23_testcases, "Usage: prog [options] + +Options: + -p PATH Path to files [default: ./]", &["-phome"], vec!(("-p", Plain(Some("home".to_string()))))); + +test_expect!(test_24_testcases, "UsAgE: prog [options] + +OpTiOnS: --path= Path to files + [dEfAuLt: /root]", &[], vec!(("--path", Plain(Some("/root".to_string()))))); + +test_expect!(test_25_testcases, "UsAgE: prog [options] + +OpTiOnS: --path= Path to files + [dEfAuLt: /root]", &["--path=home"], vec!(("--path", Plain(Some("home".to_string()))))); + +test_expect!(test_26_testcases, "usage: prog [options] + +options: + -a Add + -r Remote + -m Message", &["-a", "-r", "-m", "Hello"], vec!(("-m", Plain(Some("Hello".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); + +test_expect!(test_27_testcases, "usage: prog [options] + +options: + -a Add + -r Remote + -m Message", &["-armyourass"], vec!(("-m", Plain(Some("yourass".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); + +test_expect!(test_28_testcases, "usage: prog [options] + +options: + -a Add + -r Remote + -m Message", &["-a", "-r"], vec!(("-m", Plain(None)), ("-a", Switch(true)), ("-r", Switch(true)))); + +test_expect!(test_29_testcases, "Usage: prog [options] + +Options: --version + --verbose", &["--version"], vec!(("--verbose", Switch(false)), ("--version", Switch(true)))); + +test_expect!(test_30_testcases, "Usage: prog [options] + +Options: --version + --verbose", &["--verbose"], vec!(("--verbose", Switch(true)), ("--version", Switch(false)))); + +test_user_error!(test_31_testcases, "Usage: prog [options] + +Options: --version + --verbose", &["--ver"]); + +test_user_error!(test_32_testcases, "Usage: prog [options] + +Options: --version + --verbose", &["--verb"]); + +test_expect!(test_33_testcases, "usage: prog [-a -r -m ] + +options: + -a Add + -r Remote + -m Message", &["-armyourass"], vec!(("-m", Plain(Some("yourass".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); + +test_expect!(test_34_testcases, "usage: prog [-armMSG] + +options: -a Add + -r Remote + -m Message", &["-a", "-r", "-m", "Hello"], vec!(("-m", Plain(Some("Hello".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); + +test_expect!(test_35_testcases, "usage: prog -a -b + +options: + -a + -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_expect!(test_36_testcases, "usage: prog -a -b + +options: + -a + -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_user_error!(test_37_testcases, "usage: prog -a -b + +options: + -a + -b", &["-a"]); + +test_user_error!(test_38_testcases, "usage: prog -a -b + +options: + -a + -b", &[]); + +test_expect!(test_39_testcases, "usage: prog (-a -b) + +options: -a + -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_expect!(test_40_testcases, "usage: prog (-a -b) + +options: -a + -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_user_error!(test_41_testcases, "usage: prog (-a -b) + +options: -a + -b", &["-a"]); + +test_user_error!(test_42_testcases, "usage: prog (-a -b) + +options: -a + -b", &[]); + +test_expect!(test_43_testcases, "usage: prog [-a] -b + +options: -a + -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_expect!(test_44_testcases, "usage: prog [-a] -b + +options: -a + -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_user_error!(test_45_testcases, "usage: prog [-a] -b + +options: -a + -b", &["-a"]); + +test_expect!(test_46_testcases, "usage: prog [-a] -b + +options: -a + -b", &["-b"], vec!(("-a", Switch(false)), ("-b", Switch(true)))); + +test_user_error!(test_47_testcases, "usage: prog [-a] -b + +options: -a + -b", &[]); + +test_expect!(test_48_testcases, "usage: prog [(-a -b)] + +options: -a + -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_expect!(test_49_testcases, "usage: prog [(-a -b)] + +options: -a + -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); + +test_user_error!(test_50_testcases, "usage: prog [(-a -b)] + +options: -a + -b", &["-a"]); + +test_user_error!(test_51_testcases, "usage: prog [(-a -b)] + +options: -a + -b", &["-b"]); + +test_expect!(test_52_testcases, "usage: prog [(-a -b)] + +options: -a + -b", &[], vec!(("-a", Switch(false)), ("-b", Switch(false)))); + +test_user_error!(test_53_testcases, "usage: prog (-a|-b) + +options: -a + -b", &["-a", "-b"]); + +test_user_error!(test_54_testcases, "usage: prog (-a|-b) + +options: -a + -b", &[]); + +test_expect!(test_55_testcases, "usage: prog (-a|-b) + +options: -a + -b", &["-a"], vec!(("-a", Switch(true)), ("-b", Switch(false)))); + +test_expect!(test_56_testcases, "usage: prog (-a|-b) + +options: -a + -b", &["-b"], vec!(("-a", Switch(false)), ("-b", Switch(true)))); + +test_user_error!(test_57_testcases, "usage: prog [ -a | -b ] + +options: -a + -b", &["-a", "-b"]); + +test_expect!(test_58_testcases, "usage: prog [ -a | -b ] + +options: -a + -b", &[], vec!(("-a", Switch(false)), ("-b", Switch(false)))); + +test_expect!(test_59_testcases, "usage: prog [ -a | -b ] + +options: -a + -b", &["-a"], vec!(("-a", Switch(true)), ("-b", Switch(false)))); + +test_expect!(test_60_testcases, "usage: prog [ -a | -b ] + +options: -a + -b", &["-b"], vec!(("-a", Switch(false)), ("-b", Switch(true)))); + +test_expect!(test_61_testcases, "usage: prog ", &["10"], vec!(("", Plain(Some("10".to_string()))))); + +test_user_error!(test_62_testcases, "usage: prog ", &["10", "20"]); + +test_user_error!(test_63_testcases, "usage: prog ", &[]); + +test_expect!(test_64_testcases, "usage: prog []", &["10"], vec!(("", Plain(Some("10".to_string()))))); + +test_user_error!(test_65_testcases, "usage: prog []", &["10", "20"]); + +test_expect!(test_66_testcases, "usage: prog []", &[], vec!(("", Plain(None)))); + +test_expect!(test_67_testcases, "usage: prog ", &["10", "20", "40"], vec!(("", Plain(Some("40".to_string()))), ("", Plain(Some("10".to_string()))), ("", Plain(Some("20".to_string()))))); + +test_user_error!(test_68_testcases, "usage: prog ", &["10", "20"]); + +test_user_error!(test_69_testcases, "usage: prog ", &[]); + +test_expect!(test_70_testcases, "usage: prog [ ]", &["10", "20", "40"], vec!(("", Plain(Some("40".to_string()))), ("", Plain(Some("10".to_string()))), ("", Plain(Some("20".to_string()))))); + +test_expect!(test_71_testcases, "usage: prog [ ]", &["10", "20"], vec!(("", Plain(None)), ("", Plain(Some("10".to_string()))), ("", Plain(Some("20".to_string()))))); + +test_user_error!(test_72_testcases, "usage: prog [ ]", &[]); + +test_user_error!(test_73_testcases, "usage: prog [ | ]", &["10", "20", "40"]); + +test_expect!(test_74_testcases, "usage: prog [ | ]", &["20", "40"], vec!(("", Plain(Some("40".to_string()))), ("", Plain(None)), ("", Plain(Some("20".to_string()))))); + +test_expect!(test_75_testcases, "usage: prog [ | ]", &[], vec!(("", Plain(None)), ("", Plain(None)), ("", Plain(None)))); + +test_expect!(test_76_testcases, "usage: prog ( --all | ) + +options: + --all", &["10", "--all"], vec!(("--all", Switch(true)), ("", Plain(Some("10".to_string()))), ("", Plain(None)))); + +test_expect!(test_77_testcases, "usage: prog ( --all | ) + +options: + --all", &["10"], vec!(("--all", Switch(false)), ("", Plain(None)), ("", Plain(Some("10".to_string()))))); + +test_user_error!(test_78_testcases, "usage: prog ( --all | ) + +options: + --all", &[]); + +test_expect!(test_79_testcases, "usage: prog [ ]", &["10", "20"], vec!(("", List(vec!("10".to_string(), "20".to_string()))))); + +test_expect!(test_80_testcases, "usage: prog [ ]", &["10"], vec!(("", List(vec!("10".to_string()))))); + +test_expect!(test_81_testcases, "usage: prog [ ]", &[], vec!(("", List(vec!())))); + +test_expect!(test_82_testcases, "usage: prog [( )]", &["10", "20"], vec!(("", List(vec!("10".to_string(), "20".to_string()))))); + +test_user_error!(test_83_testcases, "usage: prog [( )]", &["10"]); + +test_expect!(test_84_testcases, "usage: prog [( )]", &[], vec!(("", List(vec!())))); + +test_expect!(test_85_testcases, "usage: prog NAME...", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); + +test_expect!(test_86_testcases, "usage: prog NAME...", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); + +test_user_error!(test_87_testcases, "usage: prog NAME...", &[]); + +test_expect!(test_88_testcases, "usage: prog [NAME]...", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); + +test_expect!(test_89_testcases, "usage: prog [NAME]...", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); + +test_expect!(test_90_testcases, "usage: prog [NAME]...", &[], vec!(("NAME", List(vec!())))); + +test_expect!(test_91_testcases, "usage: prog [NAME...]", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); + +test_expect!(test_92_testcases, "usage: prog [NAME...]", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); + +test_expect!(test_93_testcases, "usage: prog [NAME...]", &[], vec!(("NAME", List(vec!())))); + +test_expect!(test_94_testcases, "usage: prog [NAME [NAME ...]]", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); + +test_expect!(test_95_testcases, "usage: prog [NAME [NAME ...]]", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); + +test_expect!(test_96_testcases, "usage: prog [NAME [NAME ...]]", &[], vec!(("NAME", List(vec!())))); + +test_expect!(test_97_testcases, "usage: prog (NAME | --foo NAME) + +options: --foo", &["10"], vec!(("NAME", Plain(Some("10".to_string()))), ("--foo", Switch(false)))); + +test_expect!(test_98_testcases, "usage: prog (NAME | --foo NAME) + +options: --foo", &["--foo", "10"], vec!(("NAME", Plain(Some("10".to_string()))), ("--foo", Switch(true)))); + +test_user_error!(test_99_testcases, "usage: prog (NAME | --foo NAME) + +options: --foo", &["--foo=10"]); + +test_expect!(test_100_testcases, "usage: prog (NAME | --foo) [--bar | NAME] + +options: --foo +options: --bar", &["10"], vec!(("--bar", Switch(false)), ("NAME", List(vec!("10".to_string()))), ("--foo", Switch(false)))); + +test_expect!(test_101_testcases, "usage: prog (NAME | --foo) [--bar | NAME] + +options: --foo +options: --bar", &["10", "20"], vec!(("--bar", Switch(false)), ("NAME", List(vec!("10".to_string(), "20".to_string()))), ("--foo", Switch(false)))); + +test_expect!(test_102_testcases, "usage: prog (NAME | --foo) [--bar | NAME] + +options: --foo +options: --bar", &["--foo", "--bar"], vec!(("--bar", Switch(true)), ("NAME", List(vec!())), ("--foo", Switch(true)))); + +test_expect!(test_103_testcases, "Naval Fate. + +Usage: + prog ship new ... + prog ship [] move [--speed=] + prog ship shoot + prog mine (set|remove) [--moored|--drifting] + prog -h | --help + prog --version + +Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Mored (anchored) mine. + --drifting Drifting mine.", &["ship", "Guardian", "move", "150", "300", "--speed=20"], vec!(("shoot", Switch(false)), ("--moored", Switch(false)), ("--drifting", Switch(false)), ("move", Switch(true)), ("--speed", Plain(Some("20".to_string()))), ("mine", Switch(false)), ("new", Switch(false)), ("--version", Switch(false)), ("set", Switch(false)), ("remove", Switch(false)), ("", List(vec!("Guardian".to_string()))), ("ship", Switch(true)), ("", Plain(Some("150".to_string()))), ("", Plain(Some("300".to_string()))), ("--help", Switch(false)))); + +test_expect!(test_104_testcases, "usage: prog --hello", &["--hello"], vec!(("--hello", Switch(true)))); + +test_expect!(test_105_testcases, "usage: prog [--hello=]", &[], vec!(("--hello", Plain(None)))); + +test_expect!(test_106_testcases, "usage: prog [--hello=]", &["--hello", "wrld"], vec!(("--hello", Plain(Some("wrld".to_string()))))); + +test_expect!(test_107_testcases, "usage: prog [-o]", &[], vec!(("-o", Switch(false)))); + +test_expect!(test_108_testcases, "usage: prog [-o]", &["-o"], vec!(("-o", Switch(true)))); + +test_expect!(test_109_testcases, "usage: prog [-opr]", &["-op"], vec!(("-o", Switch(true)), ("-p", Switch(true)), ("-r", Switch(false)))); + +test_expect!(test_110_testcases, "usage: prog --aabb | --aa", &["--aa"], vec!(("--aa", Switch(true)), ("--aabb", Switch(false)))); + +test_user_error!(test_111_testcases, "usage: prog --aabb | --aa", &["--a"]); + +test_expect!(test_112_testcases, "Usage: prog -v", &["-v"], vec!(("-v", Switch(true)))); + +test_expect!(test_113_testcases, "Usage: prog [-v -v]", &[], vec!(("-v", Counted(0)))); + +test_expect!(test_114_testcases, "Usage: prog [-v -v]", &["-v"], vec!(("-v", Counted(1)))); + +test_expect!(test_115_testcases, "Usage: prog [-v -v]", &["-vv"], vec!(("-v", Counted(2)))); + +test_user_error!(test_116_testcases, "Usage: prog -v ...", &[]); + +test_expect!(test_117_testcases, "Usage: prog -v ...", &["-v"], vec!(("-v", Counted(1)))); + +test_expect!(test_118_testcases, "Usage: prog -v ...", &["-vv"], vec!(("-v", Counted(2)))); + +test_expect!(test_119_testcases, "Usage: prog -v ...", &["-vvvvvv"], vec!(("-v", Counted(6)))); + +test_expect!(test_120_testcases, "Usage: prog [-v | -vv | -vvv] + +This one is probably most readable user-friednly variant.", &[], vec!(("-v", Counted(0)))); + +test_expect!(test_121_testcases, "Usage: prog [-v | -vv | -vvv] + +This one is probably most readable user-friednly variant.", &["-v"], vec!(("-v", Counted(1)))); + +test_expect!(test_122_testcases, "Usage: prog [-v | -vv | -vvv] + +This one is probably most readable user-friednly variant.", &["-vv"], vec!(("-v", Counted(2)))); + +test_user_error!(test_123_testcases, "Usage: prog [-v | -vv | -vvv] + +This one is probably most readable user-friednly variant.", &["-vvvv"]); + +test_expect!(test_124_testcases, "usage: prog [--ver --ver]", &["--ver", "--ver"], vec!(("--ver", Counted(2)))); + +test_expect!(test_125_testcases, "usage: prog [go]", &["go"], vec!(("go", Switch(true)))); + +test_expect!(test_126_testcases, "usage: prog [go go]", &[], vec!(("go", Counted(0)))); + +test_expect!(test_127_testcases, "usage: prog [go go]", &["go"], vec!(("go", Counted(1)))); + +test_expect!(test_128_testcases, "usage: prog [go go]", &["go", "go"], vec!(("go", Counted(2)))); + +test_user_error!(test_129_testcases, "usage: prog [go go]", &["go", "go", "go"]); + +test_expect!(test_130_testcases, "usage: prog go...", &["go", "go", "go", "go", "go"], vec!(("go", Counted(5)))); + +test_expect!(test_131_testcases, "usage: prog [options] [-a] + +options: -a + -b", &["-a"], vec!(("-a", Switch(true)), ("-b", Switch(false)))); + +test_user_error!(test_132_testcases, "usage: prog [options] [-a] + +options: -a + -b", &["-aa"]); + +test_expect!(test_133_testcases, "Usage: prog [options] A + +Options: + -q Be quiet + -v Be verbose.", &["arg"], vec!(("A", Plain(Some("arg".to_string()))), ("-v", Switch(false)), ("-q", Switch(false)))); + +test_expect!(test_134_testcases, "Usage: prog [options] A + +Options: + -q Be quiet + -v Be verbose.", &["-v", "arg"], vec!(("A", Plain(Some("arg".to_string()))), ("-v", Switch(true)), ("-q", Switch(false)))); + +test_expect!(test_135_testcases, "Usage: prog [options] A + +Options: + -q Be quiet + -v Be verbose.", &["-q", "arg"], vec!(("A", Plain(Some("arg".to_string()))), ("-v", Switch(false)), ("-q", Switch(true)))); + +test_expect!(test_136_testcases, "usage: prog [-]", &["-"], vec!(("-", Switch(true)))); + +test_expect!(test_137_testcases, "usage: prog [-]", &[], vec!(("-", Switch(false)))); + +test_expect!(test_138_testcases, "usage: prog [NAME [NAME ...]]", &["a", "b"], vec!(("NAME", List(vec!("a".to_string(), "b".to_string()))))); + +test_expect!(test_139_testcases, "usage: prog [NAME [NAME ...]]", &[], vec!(("NAME", List(vec!())))); + +test_expect!(test_140_testcases, "usage: prog [options] + +options: + -a Add + -m Message", &["-a"], vec!(("-m", Plain(None)), ("-a", Switch(true)))); + +test_expect!(test_141_testcases, "usage: prog --hello", &["--hello"], vec!(("--hello", Switch(true)))); + +test_expect!(test_142_testcases, "usage: prog [--hello=]", &[], vec!(("--hello", Plain(None)))); + +test_expect!(test_143_testcases, "usage: prog [--hello=]", &["--hello", "wrld"], vec!(("--hello", Plain(Some("wrld".to_string()))))); + +test_expect!(test_144_testcases, "usage: prog [-o]", &[], vec!(("-o", Switch(false)))); + +test_expect!(test_145_testcases, "usage: prog [-o]", &["-o"], vec!(("-o", Switch(true)))); + +test_expect!(test_146_testcases, "usage: prog [-opr]", &["-op"], vec!(("-o", Switch(true)), ("-p", Switch(true)), ("-r", Switch(false)))); + +test_expect!(test_147_testcases, "usage: git [-v | --verbose]", &["-v"], vec!(("-v", Switch(true)), ("--verbose", Switch(false)))); + +test_expect!(test_148_testcases, "usage: git remote [-v | --verbose]", &["remote", "-v"], vec!(("-v", Switch(true)), ("remote", Switch(true)), ("--verbose", Switch(false)))); + +test_expect!(test_149_testcases, "usage: prog", &[], vec!()); + +test_expect!(test_150_testcases, "usage: prog + prog ", &["1", "2"], vec!(("", Plain(Some("1".to_string()))), ("", Plain(Some("2".to_string()))))); + +test_expect!(test_151_testcases, "usage: prog + prog ", &[], vec!(("", Plain(None)), ("", Plain(None)))); + +test_expect!(test_152_testcases, "usage: prog + prog", &[], vec!(("", Plain(None)), ("", Plain(None)))); + +test_expect!(test_153_testcases, "usage: prog [--file=]", &[], vec!(("--file", Plain(None)))); + +test_expect!(test_154_testcases, "usage: prog [--file=] + +options: --file ", &[], vec!(("--file", Plain(None)))); + +test_expect!(test_155_testcases, "Usage: prog [-a ] + +Options: -a, --address TCP address [default: localhost:6283].", &[], vec!(("--address", Plain(Some("localhost:6283".to_string()))))); + +test_expect!(test_156_testcases, "usage: prog --long= ...", &["--long", "one"], vec!(("--long", List(vec!("one".to_string()))))); + +test_expect!(test_157_testcases, "usage: prog --long= ...", &["--long", "one", "--long", "two"], vec!(("--long", List(vec!("one".to_string(), "two".to_string()))))); + +test_expect!(test_158_testcases, "usage: prog (go --speed=)...", &["go", "left", "--speed=5", "go", "right", "--speed=9"], vec!(("go", Counted(2)), ("", List(vec!("left".to_string(), "right".to_string()))), ("--speed", List(vec!("5".to_string(), "9".to_string()))))); + +test_expect!(test_159_testcases, "usage: prog [options] -a + +options: -a", &["-a"], vec!(("-a", Switch(true)))); + +test_expect!(test_160_testcases, "usage: prog [-o ]... + +options: -o [default: x]", &["-o", "this", "-o", "that"], vec!(("-o", List(vec!("this".to_string(), "that".to_string()))))); + +test_expect!(test_161_testcases, "usage: prog [-o ]... + +options: -o [default: x]", &[], vec!(("-o", List(vec!("x".to_string()))))); + +test_expect!(test_162_testcases, "usage: prog [-o ]... + +options: -o [default: x y]", &["-o", "this"], vec!(("-o", List(vec!("this".to_string()))))); + +test_expect!(test_163_testcases, "usage: prog [-o ]... + +options: -o [default: x y]", &[], vec!(("-o", List(vec!("x".to_string(), "y".to_string()))))); + +test_expect!(test_164_testcases, "usage: prog -pPATH + +options: -p PATH", &["-pHOME"], vec!(("-p", Plain(Some("HOME".to_string()))))); + +test_expect!(test_165_testcases, "Usage: foo (--xx=X|--yy=Y)...", &["--xx=1", "--yy=2"], vec!(("--yy", List(vec!("2".to_string()))), ("--xx", List(vec!("1".to_string()))))); + +test_expect!(test_166_testcases, "usage: prog []", &["f.txt"], vec!(("", Plain(Some("f.txt".to_string()))))); + +test_expect!(test_167_testcases, "usage: prog [--input=]...", &["--input", "a.txt", "--input=b.txt"], vec!(("--input", List(vec!("a.txt".to_string(), "b.txt".to_string()))))); + +test_expect!(test_168_testcases, "usage: prog good [options] + prog fail [options] + +options: --loglevel=N", &["fail", "--loglevel", "5"], vec!(("fail", Switch(true)), ("good", Switch(false)), ("--loglevel", Plain(Some("5".to_string()))))); + +test_expect!(test_169_testcases, "usage:prog --foo", &["--foo"], vec!(("--foo", Switch(true)))); + +test_expect!(test_170_testcases, "PROGRAM USAGE: prog --foo", &["--foo"], vec!(("--foo", Switch(true)))); + +test_expect!(test_171_testcases, "Usage: prog --foo + prog --bar +NOT PART OF SECTION", &["--foo"], vec!(("--bar", Switch(false)), ("--foo", Switch(true)))); + +test_expect!(test_172_testcases, "Usage: + prog --foo + prog --bar + +NOT PART OF SECTION", &["--foo"], vec!(("--bar", Switch(false)), ("--foo", Switch(true)))); + +test_expect!(test_173_testcases, "Usage: + prog --foo + prog --bar +NOT PART OF SECTION", &["--foo"], vec!(("--bar", Switch(false)), ("--foo", Switch(true)))); + +test_expect!(test_174_testcases, "Usage: prog [options] + +global options: --foo +local options: --baz + --bar +other options: + --egg + --spam +-not-an-option-", &["--bar", "--egg"], vec!(("--bar", Switch(true)), ("--egg", Switch(true)), ("--spam", Switch(false)))); + +test_expect!(test_175_testcases, "Usage: prog [-a] [--] [...]", &["-a"], vec!(("", List(vec!())), ("-a", Switch(true)))); + +test_expect!(test_176_testcases, "Usage: prog [-a] [--] [...]", &["--"], vec!(("", List(vec!())), ("-a", Switch(false)))); + +test_expect!(test_177_testcases, "Usage: prog [-a] [--] [...]", &["-a", "--", "-b"], vec!(("", List(vec!("-b".to_string()))), ("-a", Switch(true)))); + +test_expect!(test_178_testcases, "Usage: prog [-a] [--] [...]", &["-a", "--", "-a"], vec!(("", List(vec!("-a".to_string()))), ("-a", Switch(true)))); + +test_expect!(test_179_testcases, "Usage: prog [-a] [--] [...]", &["--", "-a"], vec!(("", List(vec!("-a".to_string()))), ("-a", Switch(false)))); + +test_expect!(test_180_testcases, "Usage: prog test [options] [--] [...]", &["test", "a", "--", "-b"], vec!(("", List(vec!("a".to_string(), "-b".to_string()))))); + +test_expect!(test_181_testcases, "Usage: prog test [options] [--] [...]", &["test", "--", "-b"], vec!(("", List(vec!("-b".to_string()))))); + +test_user_error!(test_182_testcases, "Usage: prog test [options] [--] [...]", &["test", "a", "-b"]); + diff --git a/deps/docopt-0.6.67/src/wordlist.rs b/deps/docopt-0.6.67/src/wordlist.rs new file mode 100644 index 000000000..5edcd9bd6 --- /dev/null +++ b/deps/docopt-0.6.67/src/wordlist.rs @@ -0,0 +1,104 @@ +extern crate regex; +extern crate rustc_serialize; +extern crate strsim; + +use std::collections::HashMap; +use std::io::{self, Read, Write}; + +use dopt::Docopt; +use parse::{Atom, Parser}; + +// cheat until we get syntax extensions back :-( +macro_rules! regex( + ($s:expr) => (::regex::Regex::new($s).unwrap()); +); + +macro_rules! werr( + ($($arg:tt)*) => ({ + use std::io::{Write, stderr}; + write!(&mut stderr(), $($arg)*).unwrap(); + }) +); + +#[allow(dead_code)] +mod dopt; +#[allow(dead_code)] +mod parse; +#[allow(dead_code)] +mod synonym; + +static USAGE: &'static str = " +Usage: docopt-wordlist [( )] ... + +docopt-wordlist prints a list of available flags and commands arguments for the +given usage (provided on stdin). + +Example use: + + your-command --help | docopt-wordlist + +This command also supports completing positional arguments when given a list of +choices. The choices are included in the word list if and only if the argument +name appears in the usage string. For example: + + your-command --help | docopt-wordlist 'arg' 'a b c' + +Which will only include 'a', 'b' and 'c' in the wordlist if +'your-command --help' contains a positional argument named 'arg'. +"; + +#[derive(Debug, RustcDecodable)] +struct Args { + arg_name: Vec, + arg_possibles: Vec, +} + +fn main() { + let args: Args = Docopt::new(USAGE) + .and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(args) { + Ok(_) => {}, + Err(err) => { + write!(&mut io::stderr(), "{}", err).unwrap(); + ::std::process::exit(1) + } + } +} + +fn run(args: Args) -> Result<(), String> { + let mut usage = String::new(); + try!(io::stdin().read_to_string(&mut usage).map_err(|e| e.to_string())); + let parsed = try!(Parser::new(&usage).map_err(|e| e.to_string())); + let arg_possibles: HashMap> = + args.arg_name.iter() + .zip(args.arg_possibles.iter()) + .map(|(name, possibles)| { + let choices = + regex!(r"[ \t]+").split(&**possibles) + .map(|s| s.to_string()) + .collect::>(); + (name.clone(), choices) + }) + .collect(); + + let mut words = vec![]; + for k in parsed.descs.keys() { + if let Atom::Positional(ref arg_name) = *k { + if let Some(choices) = arg_possibles.get(arg_name) { + words.extend(choices.iter().map(|s| s.clone())); + } + // If the user hasn't given choices for this positional argument, + // then there's really nothing to complete here. + } else { + words.push(k.to_string()); + } + } + for (k, _) in parsed.descs.synonyms() { + // We don't need to do anything special here since synonyms can + // only be flags, which we always include in the wordlist. + words.push(k.to_string()); + } + println!("{}", words.connect(" ")); + Ok(()) +} diff --git a/deps/encoding-0.2.32/.gitignore b/deps/encoding-0.2.32/.gitignore new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/deps/encoding-0.2.32/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/deps/encoding-0.2.32/.travis.yml b/deps/encoding-0.2.32/.travis.yml new file mode 100644 index 000000000..6f2097466 --- /dev/null +++ b/deps/encoding-0.2.32/.travis.yml @@ -0,0 +1,13 @@ +language: rust +os: + - linux + - osx +env: + global: + - secure: WtFY+Nu8Erb9JOqX38XHyMH0C4b0y5sDAVw2GSo3pr9o5Re/is8Fa7CBtikoZp1IfB70b7mNK7T5hqvh289M+Ur43OA4EAjWi9rKZYAoK94GXRMNCwhUQR4OiPkQ8s/oJxcNGgb2lKT4Bwtpa2/kT4HA2Md6wo1Db30D4lskrsc= +script: + - cargo build -v + - make test + - cargo doc +after_script: + - cd target && curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh diff --git a/deps/encoding-0.2.32/AUTHORS.txt b/deps/encoding-0.2.32/AUTHORS.txt new file mode 100644 index 000000000..86de7910d --- /dev/null +++ b/deps/encoding-0.2.32/AUTHORS.txt @@ -0,0 +1,34 @@ +Encoding is mainly written by Kang Seonghoon , +and also the following people (in ascending order): + +Aaron Weiss +Alex Crichton +Andrew Cann +Aneesh Agrawal +Björn Steinbrink +Brian Koropoff +Clark Gaebel +D.K +Filipe Gonçalves +Florian Gilcher +Frank Denis +Jack Moffitt +Jason Ozias +Jason Ozias +Joonas Javanainen +Joshua DeSeno +Keegan McAllister +Ken Tossell +Kyle Dewey +Manish Goregaokar +Matt Brubeck +Michael Neumann +Michael Sproul +Peter Atashian +Pierre Baillet +Robert Straw +Simon Sapin +Son +Steve Klabnik +klutzy +Сухарик diff --git a/deps/encoding-0.2.32/Cargo.toml b/deps/encoding-0.2.32/Cargo.toml new file mode 100644 index 000000000..ce04c6e54 --- /dev/null +++ b/deps/encoding-0.2.32/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "encoding" +version = "0.2.32" +authors = ["Kang Seonghoon "] + +description = "Character encoding support for Rust" +homepage = "https://github.com/lifthrasiir/rust-encoding" +documentation = "https://lifthrasiir.github.io/rust-encoding/" +repository = "https://github.com/lifthrasiir/rust-encoding" +keywords = ["encoding", "unicode", "charset"] +readme = "README.md" +license = "MIT" + +[lib] +name = "encoding" + +# version policy for index tables: +# - major: addition or deletion of index tables +# - minor: any content changes to index tables, numbered by the date +# - patch: language changes +# +# we definitely don't want to use the old index table, +# so we should use tilde requirements here. + +[dependencies.encoding-index-singlebyte] +version = "~1.20141219.5" +path = "src/index/singlebyte" + +[dependencies.encoding-index-korean] +version = "~1.20141219.5" +path = "src/index/korean" + +[dependencies.encoding-index-japanese] +version = "~1.20141219.5" +path = "src/index/japanese" + +[dependencies.encoding-index-simpchinese] +version = "~1.20141219.5" +path = "src/index/simpchinese" + +[dependencies.encoding-index-tradchinese] +version = "~1.20141219.5" +path = "src/index/tradchinese" + +[dev-dependencies] +getopts = "*" # for examples + diff --git a/deps/encoding-0.2.32/LICENSE.txt b/deps/encoding-0.2.32/LICENSE.txt new file mode 100644 index 000000000..5d33fd9a2 --- /dev/null +++ b/deps/encoding-0.2.32/LICENSE.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2013, Kang Seonghoon. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/deps/encoding-0.2.32/Makefile b/deps/encoding-0.2.32/Makefile new file mode 100644 index 000000000..40dca12cd --- /dev/null +++ b/deps/encoding-0.2.32/Makefile @@ -0,0 +1,39 @@ +.PHONY: all +all: + @echo 'Try `cargo build` instead.' + +.PHONY: authors +authors: + echo 'Encoding is mainly written by Kang Seonghoon ,' > AUTHORS.txt + echo 'and also the following people (in ascending order):' >> AUTHORS.txt + echo >> AUTHORS.txt + git log --format='%aN <%aE>' | grep -v 'Kang Seonghoon' | sort -u >> AUTHORS.txt + +.PHONY: test +test: + cargo test -v + cargo test -v -p encoding-index-singlebyte + cargo test -v -p encoding-index-korean + cargo test -v -p encoding-index-japanese + cargo test -v -p encoding-index-simpchinese + cargo test -v -p encoding-index-tradchinese + +.PHONY: readme +readme: README.md + +README.md: src/lib.rs + # really, really sorry for this mess. + awk '/^# Encoding /{print "[Encoding][doc]",$$3}' $< > $@ + awk '/^# Encoding /{print "[Encoding][doc]",$$3}' $< | sed 's/./=/g' >> $@ + echo >> $@ + echo '[![Encoding on Travis CI][travis-image]][travis]' >> $@ + echo >> $@ + echo '[travis-image]: https://travis-ci.org/lifthrasiir/rust-encoding.png' >> $@ + echo '[travis]: https://travis-ci.org/lifthrasiir/rust-encoding' >> $@ + awk '/^# Encoding /,/^## /' $< | tail -n +2 | head -n -2 >> $@ + echo >> $@ + echo '[Complete Documentation][doc]' >> $@ + echo >> $@ + echo '[doc]: https://lifthrasiir.github.io/rust-encoding/' >> $@ + echo >> $@ + awk '/^## /,/^\*\/$$/' $< | grep -v '^# ' | head -n -2 >> $@ diff --git a/deps/encoding-0.2.32/README.md b/deps/encoding-0.2.32/README.md new file mode 100644 index 000000000..75af89e5a --- /dev/null +++ b/deps/encoding-0.2.32/README.md @@ -0,0 +1,216 @@ +[Encoding][doc] 0.2.32 +====================== + +[![Encoding on Travis CI][travis-image]][travis] + +[travis-image]: https://travis-ci.org/lifthrasiir/rust-encoding.png +[travis]: https://travis-ci.org/lifthrasiir/rust-encoding + +Character encoding support for Rust. (also known as `rust-encoding`) +It is based on [WHATWG Encoding Standard](http://encoding.spec.whatwg.org/), +and also provides an advanced interface for error detection and recovery. + +[Complete Documentation][doc] + +[doc]: https://lifthrasiir.github.io/rust-encoding/ + +## Usage + +Put this in your `Cargo.toml`: + +```toml +[dependencies] +encoding = "0.2" +``` + +Or in the case you are using Rust 1.0 beta, pin the exact version: + +```toml +[dependencies] +encoding = "=0.2.32" +``` + +Then put this in your crate root: + +```rust +extern crate encoding; +``` + +## Overview + +To encode a string: + +~~~~ {.rust} +use encoding::{Encoding, EncoderTrap}; +use encoding::all::ISO_8859_1; + +assert_eq!(ISO_8859_1.encode("caf\u{e9}", EncoderTrap::Strict), + Ok(vec![99,97,102,233])); +~~~~ + +To encode a string with unrepresentable characters: + +~~~~ {.rust} +use encoding::{Encoding, EncoderTrap}; +use encoding::all::ISO_8859_2; + +assert!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::Strict).is_err()); +assert_eq!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::Replace), + Ok(vec![65,99,109,101,63])); +assert_eq!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::Ignore), + Ok(vec![65,99,109,101])); +assert_eq!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::NcrEscape), + Ok(vec![65,99,109,101,38,35,49,54,57,59])); +~~~~ + +To decode a byte sequence: + +~~~~ {.rust} +use encoding::{Encoding, DecoderTrap}; +use encoding::all::ISO_8859_1; + +assert_eq!(ISO_8859_1.decode(&[99,97,102,233], DecoderTrap::Strict), + Ok("caf\u{e9}".to_string())); +~~~~ + +To decode a byte sequence with invalid sequences: + +~~~~ {.rust} +use encoding::{Encoding, DecoderTrap}; +use encoding::all::ISO_8859_6; + +assert!(ISO_8859_6.decode(&[65,99,109,101,169], DecoderTrap::Strict).is_err()); +assert_eq!(ISO_8859_6.decode(&[65,99,109,101,169], DecoderTrap::Replace), + Ok("Acme\u{fffd}".to_string())); +assert_eq!(ISO_8859_6.decode(&[65,99,109,101,169], DecoderTrap::Ignore), + Ok("Acme".to_string())); +~~~~ + +To encode or decode the input into the already allocated buffer: + +~~~~ {.rust} +use encoding::{Encoding, EncoderTrap, DecoderTrap}; +use encoding::all::{ISO_8859_2, ISO_8859_6}; + +let mut bytes = Vec::new(); +let mut chars = String::new(); + +assert!(ISO_8859_2.encode_to("Acme\u{a9}", EncoderTrap::Ignore, &mut bytes).is_ok()); +assert!(ISO_8859_6.decode_to(&[65,99,109,101,169], DecoderTrap::Replace, &mut chars).is_ok()); + +assert_eq!(bytes, [65,99,109,101]); +assert_eq!(chars, "Acme\u{fffd}"); +~~~~ + +A practical example of custom encoder traps: + +~~~~ {.rust} +use encoding::{Encoding, ByteWriter, EncoderTrap, DecoderTrap}; +use encoding::types::RawEncoder; +use encoding::all::ASCII; + +// hexadecimal numeric character reference replacement +fn hex_ncr_escape(_encoder: &mut RawEncoder, input: &str, output: &mut ByteWriter) -> bool { + let escapes: Vec = + input.chars().map(|ch| format!("&#x{:x};", ch as isize)).collect(); + let escapes = escapes.concat(); + output.write_bytes(escapes.as_bytes()); + true +} +static HEX_NCR_ESCAPE: EncoderTrap = EncoderTrap::Call(hex_ncr_escape); + +let orig = "Hello, 世界!".to_string(); +let encoded = ASCII.encode(&orig, HEX_NCR_ESCAPE).unwrap(); +assert_eq!(ASCII.decode(&encoded, DecoderTrap::Strict), + Ok("Hello, 世界!".to_string())); +~~~~ + +Getting the encoding from the string label, as specified in WHATWG Encoding standard: + +~~~~ {.rust} +use encoding::{Encoding, DecoderTrap}; +use encoding::label::encoding_from_whatwg_label; +use encoding::all::WINDOWS_949; + +let euckr = encoding_from_whatwg_label("euc-kr").unwrap(); +assert_eq!(euckr.name(), "windows-949"); +assert_eq!(euckr.whatwg_name(), Some("euc-kr")); // for the sake of compatibility +let broken = &[0xbf, 0xec, 0xbf, 0xcd, 0xff, 0xbe, 0xd3]; +assert_eq!(euckr.decode(broken, DecoderTrap::Replace), + Ok("\u{c6b0}\u{c640}\u{fffd}\u{c559}".to_string())); + +// corresponding Encoding native API: +assert_eq!(WINDOWS_949.decode(broken, DecoderTrap::Replace), + Ok("\u{c6b0}\u{c640}\u{fffd}\u{c559}".to_string())); +~~~~ + +## Types and Stuffs + +There are three main entry points to Encoding. + +**`Encoding`** is a single character encoding. +It contains `encode` and `decode` methods for converting `String` to `Vec` and vice versa. +For the error handling, they receive **traps** (`EncoderTrap` and `DecoderTrap` respectively) +which replace any error with some string (e.g. `U+FFFD`) or sequence (e.g. `?`). +You can also use `EncoderTrap::Strict` and `DecoderTrap::Strict` traps to stop on an error. + +There are two ways to get `Encoding`: + +* `encoding::all` has static items for every supported encoding. + You should use them when the encoding would not change or only handful of them are required. + Combined with link-time optimization, any unused encoding would be discarded from the binary. +* `encoding::label` has functions to dynamically get an encoding from given string ("label"). + They will return a static reference to the encoding, which type is also known as `EncodingRef`. + It is useful when a list of required encodings is not available in advance, + but it will result in the larger binary and missed optimization opportunities. + +**`RawEncoder`** is an experimental incremental encoder. +At each step of `raw_feed`, it receives a slice of string +and emits any encoded bytes to a generic `ByteWriter` (normally `Vec`). +It will stop at the first error if any, and would return a `CodecError` struct in that case. +The caller is responsible for calling `raw_finish` at the end of encoding process. + +**`RawDecoder`** is an experimental incremental decoder. +At each step of `raw_feed`, it receives a slice of byte sequence +and emits any decoded characters to a generic `StringWriter` (normally `String`). +Otherwise it is identical to `RawEncoder`s. + +One should prefer `Encoding::{encode,decode}` as a primary interface. +`RawEncoder` and `RawDecoder` is experimental and can change substantially. +See the additional documents on `encoding::types` module for more information on them. + +## Supported Encodings + +Encoding covers all encodings specified by WHATWG Encoding Standard and some more: + +* 7-bit strict ASCII (`ascii`) +* UTF-8 (`utf-8`) +* UTF-16 in little endian (`utf-16` or `utf-16le`) and big endian (`utf-16be`) +* All single byte encoding in WHATWG Encoding Standard: + * IBM code page 866 + * ISO 8859-{2,3,4,5,6,7,8,10,13,14,15,16} + * KOI8-R, KOI8-U + * MacRoman (`macintosh`), Macintosh Cyrillic encoding (`x-mac-cyrillic`) + * Windows code pages 874, 1250, 1251, 1252 (instead of ISO 8859-1), 1253, + 1254 (instead of ISO 8859-9), 1255, 1256, 1257, 1258 +* All multi byte encodings in WHATWG Encoding Standard: + * Windows code page 949 (`euc-kr`, since the strict EUC-KR is hardly used) + * EUC-JP and Windows code page 932 (`shift_jis`, + since it's the most widespread extension to Shift_JIS) + * ISO-2022-JP with asymmetric JIS X 0212 support + (Note: this is not yet up to date to the current standard) + * GBK + * GB 18030 + * Big5-2003 with HKSCS-2008 extensions +* Encodings that were originally specified by WHATWG Encoding Standard: + * HZ +* ISO 8859-1 (distinct from Windows code page 1252) + +Parenthesized names refer to the encoding's primary name assigned by WHATWG Encoding Standard. + +Many legacy character encodings lack the proper specification, +and even those that have a specification are highly dependent of the actual implementation. +Consequently one should be careful when picking a desired character encoding. +The only standards reliable in this regard are WHATWG Encoding Standard and +[vendor-provided mappings from the Unicode consortium](http://www.unicode.org/Public/MAPPINGS/). +Whenever in doubt, look at the source code and specifications for detailed explanations. diff --git a/deps/encoding-0.2.32/examples/recode.rs b/deps/encoding-0.2.32/examples/recode.rs new file mode 100644 index 000000000..cb6cbd2fa --- /dev/null +++ b/deps/encoding-0.2.32/examples/recode.rs @@ -0,0 +1,94 @@ +// This is a part of rust-encoding. +// Copyright (c) 2014-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +extern crate encoding; +extern crate getopts; + +use std::{io, env}; +use std::io::{Read, Write}; +use std::fs::File; +use std::path::Path; +use encoding::{EncoderTrap, DecoderTrap}; +use encoding::label::encoding_from_whatwg_label; +use getopts::Options; + +fn main() { + let args: Vec<_> = env::args().collect(); + + let mut opts = Options::new(); + opts.optopt("f", "from-code", "set input encoding", "NAME"); + opts.optopt("t", "to-code", "set output encoding", "NAME"); + opts.optopt("e", "error-policy", + "set error policy (one of strict, ignore, replace, ncr-escape)", "POLICY"); + opts.optflag("c", "", "same as `--error-policy=ignore`"); + opts.optopt("o", "output", "output file", "FILE"); + opts.optflag("h", "help", "print this help menu"); + + let matches = match opts.parse(&args[1..]) { + Ok(m) => m, + Err(e) => panic!(e.to_string()), + }; + if matches.opt_present("h") { + println!("{}", opts.usage("Converts the character encoding using rust-encoding.")); + return; + } + + let inencname = matches.opt_str("f"); + let outencname = matches.opt_str("t"); + let inenc = match inencname.as_ref().map(|s| &s[..]) { + Some(name) => match encoding_from_whatwg_label(name) { + Some(enc) => enc, + None => panic!("invalid input encoding name {}", name), + }, + None => encoding::all::UTF_8 as encoding::EncodingRef, + }; + let outenc = match outencname.as_ref().map(|s| &s[..]) { + Some(name) => match encoding_from_whatwg_label(name) { + Some(enc) => enc, + None => panic!("invalid output encoding name {}", name), + }, + None => encoding::all::UTF_8 as encoding::EncodingRef, + }; + + let mut policy = matches.opt_str("e"); + if matches.opt_present("c") { + policy = Some("ignore".to_string()); + } + let (intrap, outtrap) = match policy.as_ref().map(|s| &s[..]) { + Some("strict") | None => (DecoderTrap::Strict, EncoderTrap::Strict), + Some("ignore") => (DecoderTrap::Ignore, EncoderTrap::Ignore), + Some("replace") => (DecoderTrap::Replace, EncoderTrap::Replace), + Some("ncr-escape") => (DecoderTrap::Replace, EncoderTrap::NcrEscape), + Some(s) => panic!("invalid error policy {}", s), + }; + + let mut input = match matches.free.first().map(|s| &s[..]) { + Some("-") | None => Box::new(io::stdin()) as Box, + Some(f) => match File::open(&Path::new(f)) { + Ok(f) => Box::new(f) as Box, + Err(e) => panic!("cannot open the input {}: {}", f, e), + }, + }; + let mut output = match matches.opt_str("o").as_ref().map(|s| &s[..]) { + Some("-") | None => Box::new(io::stdout()) as Box, + Some(f) => match File::create(&Path::new(f)) { + Ok(f) => Box::new(f) as Box, + Err(e) => panic!("cannot open the output {}: {}", f, e), + }, + }; + + // XXX should really use the incremental interface + let mut ret = Vec::new(); + input.read_to_end(&mut ret).ok().expect("cannot read from the input"); + let decoded = match inenc.decode(&ret, intrap) { + Ok(s) => s, + Err(e) => panic!("decoder error: {}", e), + }; + let encoded = match outenc.encode(&decoded, outtrap) { + Ok(s) => s, + Err(e) => panic!("encoder error: {}", e), + }; + output.write_all(&encoded).unwrap(); +} + diff --git a/deps/encoding-0.2.32/src/all.rs b/deps/encoding-0.2.32/src/all.rs new file mode 100644 index 000000000..f6374d9a0 --- /dev/null +++ b/deps/encoding-0.2.32/src/all.rs @@ -0,0 +1,143 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! A list of all supported encodings. Useful for encodings fixed in the compile time. + +use index_singlebyte as index; +use codec; +use types::EncodingRef; + +macro_rules! unique( + ($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, val=$val:ident) => ( + unique!($(#[$attr])* var=$var, mod=$($module)::+, ty=$val, val=$val); + ); + ($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, ty=$ty:ident, val=$val:ident) => ( + $(#[$attr])* pub const $var: &'static $($module)::+::$ty = &$($module)::+::$val; + ); +); + +macro_rules! singlebyte( + ($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, name=$name:expr) => ( + singlebyte!($(#[$attr])* var=$var, mod=$($module)::+, name=$name, whatwg=None); + ); + ($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, name|whatwg=$name:expr) => ( + singlebyte!($(#[$attr])* var=$var, mod=$($module)::+, name=$name, whatwg=Some($name)); + ); + ($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, + name=$name:expr, whatwg=$whatwg:expr) => ( + $(#[$attr])* pub const $var: &'static codec::singlebyte::SingleByteEncoding = + &codec::singlebyte::SingleByteEncoding { + name: $name, + whatwg_name: $whatwg, + index_forward: $($module)::+::forward, + index_backward: $($module)::+::backward, + }; + ) +); + +unique!(var=ERROR, mod=codec::error, val=ErrorEncoding); +unique!(var=ASCII, mod=codec::ascii, val=ASCIIEncoding); +singlebyte!(var=IBM866, mod=index::ibm866, name|whatwg="ibm866"); +singlebyte!(var=ISO_8859_1, mod=codec::singlebyte::iso_8859_1, name="iso-8859-1"); +singlebyte!(var=ISO_8859_2, mod=index::iso_8859_2, name|whatwg="iso-8859-2"); +singlebyte!(var=ISO_8859_3, mod=index::iso_8859_3, name|whatwg="iso-8859-3"); +singlebyte!(var=ISO_8859_4, mod=index::iso_8859_4, name|whatwg="iso-8859-4"); +singlebyte!(var=ISO_8859_5, mod=index::iso_8859_5, name|whatwg="iso-8859-5"); +singlebyte!(var=ISO_8859_6, mod=index::iso_8859_6, name|whatwg="iso-8859-6"); +singlebyte!(var=ISO_8859_7, mod=index::iso_8859_7, name|whatwg="iso-8859-7"); +singlebyte!(var=ISO_8859_8, mod=index::iso_8859_8, name|whatwg="iso-8859-8"); +singlebyte!(var=ISO_8859_10, mod=index::iso_8859_10, name|whatwg="iso-8859-10"); +singlebyte!(var=ISO_8859_13, mod=index::iso_8859_13, name|whatwg="iso-8859-13"); +singlebyte!(var=ISO_8859_14, mod=index::iso_8859_14, name|whatwg="iso-8859-14"); +singlebyte!(var=ISO_8859_15, mod=index::iso_8859_15, name|whatwg="iso-8859-15"); +singlebyte!(var=ISO_8859_16, mod=index::iso_8859_16, name|whatwg="iso-8859-16"); +singlebyte!(var=KOI8_R, mod=index::koi8_r, name|whatwg="koi8-r"); +singlebyte!(var=KOI8_U, mod=index::koi8_u, name|whatwg="koi8-u"); +singlebyte!(var=MAC_ROMAN, mod=index::macintosh, name="mac-roman", whatwg=Some("macintosh")); +singlebyte!(var=WINDOWS_874, mod=index::windows_874, name|whatwg="windows-874"); +singlebyte!(var=WINDOWS_1250, mod=index::windows_1250, name|whatwg="windows-1250"); +singlebyte!(var=WINDOWS_1251, mod=index::windows_1251, name|whatwg="windows-1251"); +singlebyte!(var=WINDOWS_1252, mod=index::windows_1252, name|whatwg="windows-1252"); +singlebyte!(var=WINDOWS_1253, mod=index::windows_1253, name|whatwg="windows-1253"); +singlebyte!(var=WINDOWS_1254, mod=index::windows_1254, name|whatwg="windows-1254"); +singlebyte!(var=WINDOWS_1255, mod=index::windows_1255, name|whatwg="windows-1255"); +singlebyte!(var=WINDOWS_1256, mod=index::windows_1256, name|whatwg="windows-1256"); +singlebyte!(var=WINDOWS_1257, mod=index::windows_1257, name|whatwg="windows-1257"); +singlebyte!(var=WINDOWS_1258, mod=index::windows_1258, name|whatwg="windows-1258"); +singlebyte!(var=MAC_CYRILLIC, mod=index::x_mac_cyrillic, + name="mac-cyrillic", whatwg=Some("x-mac-cyrillic")); +unique!(var=UTF_8, mod=codec::utf_8, val=UTF8Encoding); +unique!(var=UTF_16LE, mod=codec::utf_16, ty=UTF16LEEncoding, val=UTF_16LE_ENCODING); +unique!(var=UTF_16BE, mod=codec::utf_16, ty=UTF16BEEncoding, val=UTF_16BE_ENCODING); +unique!(var=WINDOWS_949, mod=codec::korean, val=Windows949Encoding); +unique!(var=EUC_JP, mod=codec::japanese, val=EUCJPEncoding); +unique!(var=WINDOWS_31J, mod=codec::japanese, val=Windows31JEncoding); +unique!(var=ISO_2022_JP, mod=codec::japanese, val=ISO2022JPEncoding); +unique!(var=GBK, mod=codec::simpchinese, ty=GBKEncoding, val=GBK_ENCODING); +unique!(var=GB18030, mod=codec::simpchinese, ty=GB18030Encoding, val=GB18030_ENCODING); +unique!(var=HZ, mod=codec::simpchinese, val=HZEncoding); +unique!(var=BIG5_2003, mod=codec::tradchinese, val=BigFive2003Encoding); + +pub mod whatwg { + use index_singlebyte as index; + use codec; + + singlebyte!(var=X_USER_DEFINED, mod=codec::whatwg::x_user_defined, + name="pua-mapped-binary", whatwg=Some("x-user-defined")); + singlebyte!(var=ISO_8859_8_I, mod=index::iso_8859_8, name|whatwg="iso-8859-8-i"); + unique!(var=REPLACEMENT, mod=codec::whatwg, val=EncoderOnlyUTF8Encoding); +} + +/// Returns a list of references to the encodings available. +pub fn encodings() -> &'static [EncodingRef] { + // TODO should be generated automatically + const ENCODINGS: &'static [EncodingRef] = &[ + ERROR, + ASCII, + IBM866, + ISO_8859_1, + ISO_8859_2, + ISO_8859_3, + ISO_8859_4, + ISO_8859_5, + ISO_8859_6, + ISO_8859_7, + ISO_8859_8, + ISO_8859_10, + ISO_8859_13, + ISO_8859_14, + ISO_8859_15, + ISO_8859_16, + KOI8_R, + KOI8_U, + MAC_ROMAN, + WINDOWS_874, + WINDOWS_1250, + WINDOWS_1251, + WINDOWS_1252, + WINDOWS_1253, + WINDOWS_1254, + WINDOWS_1255, + WINDOWS_1256, + WINDOWS_1257, + WINDOWS_1258, + MAC_CYRILLIC, + UTF_8, + UTF_16LE, + UTF_16BE, + WINDOWS_949, + EUC_JP, + WINDOWS_31J, + ISO_2022_JP, + GBK, + GB18030, + HZ, + BIG5_2003, + whatwg::X_USER_DEFINED, + whatwg::ISO_8859_8_I, + whatwg::REPLACEMENT, + ]; + ENCODINGS +} + diff --git a/deps/encoding-0.2.32/src/codec/ascii.rs b/deps/encoding-0.2.32/src/codec/ascii.rs new file mode 100644 index 000000000..d7f3e5825 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/ascii.rs @@ -0,0 +1,163 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! 7-bit ASCII encoding. + +use std::mem; +use std::convert::Into; +use types::*; + +/** + * ASCII, also known as ISO/IEC 646:US. + * + * It is both a basis and a lowest common denominator of many other encodings + * including UTF-8, which Rust internally assumes. + */ +#[derive(Clone, Copy)] +pub struct ASCIIEncoding; + +impl Encoding for ASCIIEncoding { + fn name(&self) -> &'static str { "ascii" } + fn raw_encoder(&self) -> Box { ASCIIEncoder::new() } + fn raw_decoder(&self) -> Box { ASCIIDecoder::new() } +} + +/// An encoder for ASCII. +#[derive(Clone, Copy)] +pub struct ASCIIEncoder; + +impl ASCIIEncoder { + pub fn new() -> Box { Box::new(ASCIIEncoder) } +} + +impl RawEncoder for ASCIIEncoder { + fn from_self(&self) -> Box { ASCIIEncoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + match input.as_bytes().iter().position(|&ch| ch >= 0x80) { + Some(first_error) => { + output.write_bytes(&input.as_bytes()[..first_error]); + let len = input[first_error..].chars().next().unwrap().len_utf8(); + (first_error, Some(CodecError { + upto: (first_error + len) as isize, cause: "unrepresentable character".into() + })) + } + None => { + output.write_bytes(input.as_bytes()); + (input.len(), None) + } + } + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for ASCII. +#[derive(Clone, Copy)] +pub struct ASCIIDecoder; + +impl ASCIIDecoder { + pub fn new() -> Box { Box::new(ASCIIDecoder) } +} + +impl RawDecoder for ASCIIDecoder { + fn from_self(&self) -> Box { ASCIIDecoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + fn write_ascii_bytes(output: &mut StringWriter, buf: &[u8]) { + output.write_str(unsafe {mem::transmute(buf)}); + } + + match input.iter().position(|&ch| ch >= 0x80) { + Some(first_error) => { + write_ascii_bytes(output, &input[..first_error]); + (first_error, Some(CodecError { + upto: first_error as isize + 1, cause: "invalid sequence".into() + })) + } + None => { + write_ascii_bytes(output, input); + (input.len(), None) + } + } + } + + fn raw_finish(&mut self, _output: &mut StringWriter) -> Option { + None + } +} + +#[cfg(test)] +mod tests { + extern crate test; + use super::ASCIIEncoding; + use testutils; + use types::*; + + #[test] + fn test_encoder() { + let mut e = ASCIIEncoding.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_err!(e, "", "\u{a0}", "", []); + assert_feed_err!(e, "X", "\u{a0}", "Z", [0x58]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder() { + let mut d = ASCIIEncoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_err!(d, [], [0xa0], [], ""); + assert_feed_err!(d, [0x58], [0xa0], [0x5a], "X"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + ASCIIEncoding.encode(s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + ASCIIEncoding.decode(s, DecoderTrap::Strict) + })) + } + + #[bench] + fn bench_encode_replace(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + ASCIIEncoding.encode(s, EncoderTrap::Replace) + })) + } + + #[bench] + fn bench_decode_replace(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + ASCIIEncoding.decode(s, DecoderTrap::Replace) + })) + } +} diff --git a/deps/encoding-0.2.32/src/codec/error.rs b/deps/encoding-0.2.32/src/codec/error.rs new file mode 100644 index 000000000..abf41b295 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/error.rs @@ -0,0 +1,94 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! A placeholder encoding that returns encoder/decoder error for every case. + +use std::convert::Into; +use types::*; + +/// An encoding that returns encoder/decoder error for every case. +#[derive(Clone, Copy)] +pub struct ErrorEncoding; + +impl Encoding for ErrorEncoding { + fn name(&self) -> &'static str { "error" } + fn raw_encoder(&self) -> Box { ErrorEncoder::new() } + fn raw_decoder(&self) -> Box { ErrorDecoder::new() } +} + +/// An encoder that always returns error. +#[derive(Clone, Copy)] +pub struct ErrorEncoder; + +impl ErrorEncoder { + pub fn new() -> Box { Box::new(ErrorEncoder) } +} + +impl RawEncoder for ErrorEncoder { + fn from_self(&self) -> Box { ErrorEncoder::new() } + + fn raw_feed(&mut self, input: &str, _output: &mut ByteWriter) -> (usize, Option) { + if let Some(ch) = input.chars().next() { + (0, Some(CodecError { upto: ch.len_utf8() as isize, + cause: "unrepresentable character".into() })) + } else { + (0, None) + } + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder that always returns error. +#[derive(Clone, Copy)] +pub struct ErrorDecoder; + +impl ErrorDecoder { + pub fn new() -> Box { Box::new(ErrorDecoder) } +} + +impl RawDecoder for ErrorDecoder { + fn from_self(&self) -> Box { ErrorDecoder::new() } + + fn raw_feed(&mut self, + input: &[u8], _output: &mut StringWriter) -> (usize, Option) { + if input.len() > 0 { + (0, Some(CodecError { upto: 1, cause: "invalid sequence".into() })) + } else { + (0, None) + } + } + + fn raw_finish(&mut self, _output: &mut StringWriter) -> Option { + None + } +} + +#[cfg(test)] +mod tests { + use super::ErrorEncoding; + use types::*; + + #[test] + fn test_encoder() { + let mut e = ErrorEncoding.raw_encoder(); + assert_feed_err!(e, "", "A", "", []); + assert_feed_err!(e, "", "B", "C", []); + assert_feed_ok!(e, "", "", []); + assert_feed_err!(e, "", "\u{a0}", "", []); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder() { + let mut d = ErrorEncoding.raw_decoder(); + assert_feed_err!(d, [], [0x41], [], ""); + assert_feed_err!(d, [], [0x42], [0x43], ""); + assert_feed_ok!(d, [], [], ""); + assert_feed_err!(d, [], [0xa0], [], ""); + assert_finish_ok!(d, ""); + } +} diff --git a/deps/encoding-0.2.32/src/codec/japanese.rs b/deps/encoding-0.2.32/src/codec/japanese.rs new file mode 100644 index 000000000..50eff7843 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/japanese.rs @@ -0,0 +1,1343 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Legacy Japanese encodings based on JIS X 0208 and JIS X 0212. + +use std::convert::Into; +use std::default::Default; +use util::StrCharIndex; +use index_japanese as index; +use types::*; +use self::ISO2022JPState::{ASCII,Katakana,Lead}; + +/** + * EUC-JP. (XXX with asymmetric JIS X 0212 support) + * + * This is a Japanese encoding created from three JIS character sets: + * + * - JIS X 0201, which lower half is ISO/IEC 646:JP (US-ASCII with yen sign and overline) + * and upper half contains legacy half-width Katakanas. + * - JIS X 0208, a primary graphic character set (94x94). + * - JIS X 0212, a supplementary graphic character set (94x94). + * + * EUC-JP contains the lower half of JIS X 0201 in G0 (`[21-7E]`), + * JIS X 0208 in G1 (`[A1-FE] [A1-FE]`), + * the upper half of JIS X 0212 in G2 (`8E [A1-DF]`), and + * JIS X 0212 in G3 (`8F [A1-FE] [A1-FE]`). + */ +#[derive(Clone, Copy)] +pub struct EUCJPEncoding; + +impl Encoding for EUCJPEncoding { + fn name(&self) -> &'static str { "euc-jp" } + fn whatwg_name(&self) -> Option<&'static str> { Some("euc-jp") } + fn raw_encoder(&self) -> Box { EUCJPEncoder::new() } + fn raw_decoder(&self) -> Box { EUCJP0212Decoder::new() } +} + +/// An encoder for EUC-JP with unused G3 character set. +#[derive(Clone, Copy)] +pub struct EUCJPEncoder; + +impl EUCJPEncoder { + pub fn new() -> Box { Box::new(EUCJPEncoder) } +} + +impl RawEncoder for EUCJPEncoder { + fn from_self(&self) -> Box { EUCJPEncoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + for ((i,j), ch) in input.index_iter() { + match ch { + '\u{0}'...'\u{7f}' => { output.write_byte(ch as u8); } + '\u{a5}' => { output.write_byte(0x5c); } + '\u{203e}' => { output.write_byte(0x7e); } + '\u{ff61}'...'\u{ff9f}' => { + output.write_byte(0x8e); + output.write_byte((ch as usize - 0xff61 + 0xa1) as u8); + } + _ => { + let ptr = index::jis0208::backward(ch as u32); + if ptr == 0xffff { + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } else { + let lead = ptr / 94 + 0xa1; + let trail = ptr % 94 + 0xa1; + output.write_byte(lead as u8); + output.write_byte(trail as u8); + } + } + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for EUC-JP with JIS X 0212 in G3. +#[derive(Clone, Copy)] +struct EUCJP0212Decoder { + st: eucjp::State, +} + +impl EUCJP0212Decoder { + pub fn new() -> Box { + Box::new(EUCJP0212Decoder { st: Default::default() }) + } +} + +impl RawDecoder for EUCJP0212Decoder { + fn from_self(&self) -> Box { EUCJP0212Decoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = eucjp::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = eucjp::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module eucjp; + + internal pub fn map_two_0208_bytes(lead: u8, trail: u8) -> u32 { + use index_japanese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0xa1...0xfe, 0xa1...0xfe) => (lead - 0xa1) * 94 + trail - 0xa1, + _ => 0xffff, + }; + index::jis0208::forward(index) + } + + internal pub fn map_two_0212_bytes(lead: u8, trail: u8) -> u32 { + use index_japanese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0xa1...0xfe, 0xa1...0xfe) => (lead - 0xa1) * 94 + trail - 0xa1, + _ => 0xffff, + }; + index::jis0212::forward(index) + } + +initial: + // euc-jp lead = 0x00 + state S0(ctx: Context) { + case b @ 0x00...0x7f => ctx.emit(b as u32); + case 0x8e => S1(ctx); + case 0x8f => S2(ctx); + case b @ 0xa1...0xfe => S3(ctx, b); + case _ => ctx.err("invalid sequence"); + } + +transient: + // euc-jp lead = 0x8e + state S1(ctx: Context) { + case b @ 0xa1...0xdf => ctx.emit(0xff61 + b as u32 - 0xa1); + case 0xa1...0xfe => ctx.err("invalid sequence"); + case _ => ctx.backup_and_err(1, "invalid sequence"); + } + + // euc-jp lead = 0x8f + // JIS X 0201 half-width katakana + state S2(ctx: Context) { + case b @ 0xa1...0xfe => S4(ctx, b); + case _ => ctx.backup_and_err(1, "invalid sequence"); + } + + // euc-jp lead != 0x00, euc-jp jis0212 flag = unset + // JIS X 0208 two-byte sequence + state S3(ctx: Context, lead: u8) { + case b @ 0xa1...0xfe => match map_two_0208_bytes(lead, b) { + // do NOT backup, we only backup for out-of-range trails. + 0xffff => ctx.err("invalid sequence"), + ch => ctx.emit(ch as u32) + }; + case _ => ctx.backup_and_err(1, "invalid sequence"); + } + + // euc-jp lead != 0x00, euc-jp jis0212 flag = set + // JIS X 0212 three-byte sequence + state S4(ctx: Context, lead: u8) { + case b @ 0xa1...0xfe => match map_two_0212_bytes(lead, b) { + // do NOT backup, we only backup for out-of-range trails. + 0xffff => ctx.err("invalid sequence"), + ch => ctx.emit(ch as u32) + }; + case _ => ctx.backup_and_err(1, "invalid sequence"); + } +} + +#[cfg(test)] +mod eucjp_tests { + extern crate test; + use super::EUCJPEncoding; + use testutils; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = EUCJPEncoding.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{a5}", "", [0x5c]); + assert_feed_ok!(e, "\u{203e}", "", [0x7e]); + assert_feed_ok!(e, "\u{306b}\u{307b}\u{3093}", "", [0xa4, 0xcb, 0xa4, 0xdb, 0xa4, 0xf3]); + assert_feed_ok!(e, "\u{ff86}\u{ff8e}\u{ff9d}", "", [0x8e, 0xc6, 0x8e, 0xce, 0x8e, 0xdd]); + assert_feed_ok!(e, "\u{65e5}\u{672c}", "", [0xc6, 0xfc, 0xcb, 0xdc]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_double_mapped() { + // these characters are double-mapped to both EUDC area and Shift_JIS extension area + // but only the former should be used. (note that U+FFE2 is triple-mapped!) + let mut e = EUCJPEncoding.raw_encoder(); + assert_feed_ok!(e, "\u{9ed1}\u{2170}\u{ffe2}", "", [0xfc, 0xee, 0xfc, 0xf1, 0xa2, 0xcc]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_invalid() { + let mut e = EUCJPEncoding.raw_encoder(); + assert_feed_err!(e, "", "\u{ffff}", "", []); + assert_feed_err!(e, "?", "\u{ffff}", "!", [0x3f]); + // JIS X 0212 is not supported in the encoder + assert_feed_err!(e, "", "\u{736c}", "\u{8c78}", []); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0x5c], [], "\\"); + assert_feed_ok!(d, [0x7e], [], "~"); + assert_feed_ok!(d, [0xa4, 0xcb, 0xa4, 0xdb, 0xa4, 0xf3], [], "\u{306b}\u{307b}\u{3093}"); + assert_feed_ok!(d, [0x8e, 0xc6, 0x8e, 0xce, 0x8e, 0xdd], [], "\u{ff86}\u{ff8e}\u{ff9d}"); + assert_feed_ok!(d, [0xc6, 0xfc, 0xcb, 0xdc], [], "\u{65e5}\u{672c}"); + assert_feed_ok!(d, [0x8f, 0xcb, 0xc6, 0xec, 0xb8], [], "\u{736c}\u{8c78}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_valid_partial() { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0xa4], ""); + assert_feed_ok!(d, [0xcb], [0xa4], "\u{306b}"); + assert_feed_ok!(d, [0xdb], [0xa4], "\u{307b}"); + assert_feed_ok!(d, [0xf3], [], "\u{3093}"); + assert_feed_ok!(d, [], [0x8e], ""); + assert_feed_ok!(d, [0xc6], [0x8e], "\u{ff86}"); + assert_feed_ok!(d, [0xce], [0x8e], "\u{ff8e}"); + assert_feed_ok!(d, [0xdd], [], "\u{ff9d}"); + assert_feed_ok!(d, [], [0xc6], ""); + assert_feed_ok!(d, [0xfc], [0xcb], "\u{65e5}"); + assert_feed_ok!(d, [0xdc], [], "\u{672c}"); + assert_feed_ok!(d, [], [0x8f], ""); + assert_feed_ok!(d, [], [0xcb], ""); + assert_feed_ok!(d, [0xc6], [0xec], "\u{736c}"); + assert_feed_ok!(d, [0xb8], [], "\u{8c78}"); + assert_feed_ok!(d, [], [0x8f, 0xcb], ""); + assert_feed_ok!(d, [0xc6, 0xec, 0xb8], [], "\u{736c}\u{8c78}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_immediate_test_finish() { + for i in 0x8e..0x90 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + + for i in 0xa1..0xff { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + + // immediate failures + let mut d = EUCJPEncoding.raw_decoder(); + for i in 0x80..0x8e { + assert_feed_err!(d, [], [i], [], ""); + } + for i in 0x90..0xa1 { + assert_feed_err!(d, [], [i], [], ""); + } + assert_feed_err!(d, [], [0xff], [], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_followed_by_space() { + for i in 0x80..0x100 { + let i = i as u8; + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lead_followed_by_invalid_trail() { + for i in 0x80..0x100 { + let i = i as u8; + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x80], ""); + assert_feed_err!(d, [], [i], [0xff], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lone_lead_for_0212_immediate_test_finish() { + for i in 0xa1..0xff { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x8f, i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lone_lead_for_0212_immediate_test_finish_partial() { + for i in 0xa1..0xff { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x8f], ""); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_trail_for_0201() { + for i in 0..0xa1 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_err!(d, [], [0x8e], [i], ""); + assert_finish_ok!(d, ""); + } + + for i in 0xe0..0xff { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_err!(d, [], [0x8e, i], [], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_trail_for_0201_partial() { + for i in 0..0xa1 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x8e], ""); + assert_feed_err!(d, [], [], [i], ""); + assert_finish_ok!(d, ""); + } + + for i in 0xe0..0xff { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x8e], ""); + assert_feed_err!(d, [], [i], [], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_middle_for_0212() { + for i in 0..0xa1 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_err!(d, [], [0x8f], [i], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_middle_for_0212_partial() { + for i in 0..0xa1 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x8f], ""); + assert_feed_err!(d, [], [], [i], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_trail_for_0212() { + for i in 0..0xa1 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_err!(d, [], [0x8f, 0xa1], [i], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_trail_for_0212_partial() { + for i in 0..0xa1 { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x8f], ""); + assert_feed_ok!(d, [], [0xa1], ""); + assert_feed_err!(d, [], [], [i], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = EUCJPEncoding.raw_decoder(); + assert_feed_ok!(d, [0xa4, 0xa2], [0xa4], "\u{3042}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xa4, 0xa2], [], "\u{3042}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::JAPANESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + EUCJPEncoding.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = EUCJPEncoding.encode(testutils::JAPANESE_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + EUCJPEncoding.decode(&s, DecoderTrap::Strict) + })) + } +} + +/** + * Windows code page 932, i.e. Shift_JIS with IBM/NEC extensions. + * + * This is a Japanese encoding for JIS X 0208 + * compatible to the original assignments of JIS X 0201 (`[21-7E A1-DF]`). + * The 94 by 94 region of JIS X 0208 is sliced, or rather "shifted" into + * the odd half (odd row number) and even half (even row number), + * and merged into the 188 by 47 region mapped to `[81-9F E0-EF] [40-7E 80-FC]`. + * The remaining area, `[80 A0 F0-FF] [40-7E 80-FC]`, has been subjected to + * numerous extensions incompatible to each other. + * This particular implementation uses IBM/NEC extensions + * which assigns more characters to `[F0-FC 80-FC]` and also to the Private Use Area (PUA). + * It requires some cares to handle + * since the second byte of JIS X 0208 can have its MSB unset. + */ +#[derive(Clone, Copy)] +pub struct Windows31JEncoding; + +impl Encoding for Windows31JEncoding { + fn name(&self) -> &'static str { "windows-31j" } + fn whatwg_name(&self) -> Option<&'static str> { Some("shift_jis") } // WHATWG compatibility + fn raw_encoder(&self) -> Box { Windows31JEncoder::new() } + fn raw_decoder(&self) -> Box { Windows31JDecoder::new() } +} + +/// An encoder for Shift_JIS with IBM/NEC extensions. +#[derive(Clone, Copy)] +pub struct Windows31JEncoder; + +impl Windows31JEncoder { + pub fn new() -> Box { Box::new(Windows31JEncoder) } +} + +impl RawEncoder for Windows31JEncoder { + fn from_self(&self) -> Box { Windows31JEncoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + for ((i,j), ch) in input.index_iter() { + match ch { + '\u{0}'...'\u{80}' => { output.write_byte(ch as u8); } + '\u{a5}' => { output.write_byte(0x5c); } + '\u{203e}' => { output.write_byte(0x7e); } + '\u{ff61}'...'\u{ff9f}' => { + output.write_byte((ch as usize - 0xff61 + 0xa1) as u8); + } + _ => { + // corresponds to the "index shift_jis pointer" in the WHATWG spec + let ptr = index::jis0208::backward_remapped(ch as u32); + if ptr == 0xffff { + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into(), + })); + } else { + let lead = ptr / 188; + let leadoffset = if lead < 0x1f {0x81} else {0xc1}; + let trail = ptr % 188; + let trailoffset = if trail < 0x3f {0x40} else {0x41}; + output.write_byte((lead + leadoffset) as u8); + output.write_byte((trail + trailoffset) as u8); + } + } + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for Shift_JIS with IBM/NEC extensions. +#[derive(Clone, Copy)] +struct Windows31JDecoder { + st: windows31j::State, +} + +impl Windows31JDecoder { + pub fn new() -> Box { + Box::new(Windows31JDecoder { st: Default::default() }) + } +} + +impl RawDecoder for Windows31JDecoder { + fn from_self(&self) -> Box { Windows31JDecoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = windows31j::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = windows31j::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module windows31j; + + internal pub fn map_two_0208_bytes(lead: u8, trail: u8) -> u32 { + use index_japanese as index; + + let lead = lead as u16; + let trail = trail as u16; + let leadoffset = if lead < 0xa0 {0x81} else {0xc1}; + let trailoffset = if trail < 0x7f {0x40} else {0x41}; + let index = match (lead, trail) { + (0xf0...0xf9, 0x40...0x7e) | (0xf0...0xf9, 0x80...0xfc) => + return (0xe000 + (lead - 0xf0) * 188 + trail - trailoffset) as u32, + (0x81...0x9f, 0x40...0x7e) | (0x81...0x9f, 0x80...0xfc) | + (0xe0...0xfc, 0x40...0x7e) | (0xe0...0xfc, 0x80...0xfc) => + (lead - leadoffset) * 188 + trail - trailoffset, + _ => 0xffff, + }; + index::jis0208::forward(index) + } + +initial: + // shift_jis lead = 0x00 + state S0(ctx: Context) { + case b @ 0x00...0x80 => ctx.emit(b as u32); + case b @ 0xa1...0xdf => ctx.emit(0xff61 + b as u32 - 0xa1); + case b @ 0x81...0x9f, b @ 0xe0...0xfc => S1(ctx, b); + case _ => ctx.err("invalid sequence"); + } + +transient: + // shift_jis lead != 0x00 + state S1(ctx: Context, lead: u8) { + case b => match map_two_0208_bytes(lead, b) { + 0xffff => ctx.backup_and_err(1, "invalid sequence"), // unconditional + ch => ctx.emit(ch) + }; + } +} + +#[cfg(test)] +mod windows31j_tests { + extern crate test; + use super::Windows31JEncoding; + use testutils; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = Windows31JEncoding.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{a5}", "", [0x5c]); + assert_feed_ok!(e, "\u{203e}", "", [0x7e]); + assert_feed_ok!(e, "\u{306b}\u{307b}\u{3093}", "", [0x82, 0xc9, 0x82, 0xd9, 0x82, 0xf1]); + assert_feed_ok!(e, "\u{ff86}\u{ff8e}\u{ff9d}", "", [0xc6, 0xce, 0xdd]); + assert_feed_ok!(e, "\u{65e5}\u{672c}", "", [0x93, 0xfa, 0x96, 0x7b]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_no_eudc() { + let mut e = Windows31JEncoding.raw_encoder(); + assert_feed_err!(e, "", "\u{e000}", "", []); + assert_feed_err!(e, "", "\u{e757}", "", []); + assert_feed_err!(e, "", "\u{e758}", "", []); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_double_mapped() { + // these characters are double-mapped to both EUDC area and Shift_JIS extension area + // but only the latter should be used. (note that U+FFE2 is triple-mapped!) + let mut e = Windows31JEncoding.raw_encoder(); + assert_feed_ok!(e, "\u{9ed1}\u{2170}\u{ffe2}", "", [0xfc, 0x4b, 0xfa, 0x40, 0x81, 0xca]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_invalid() { + let mut e = Windows31JEncoding.raw_encoder(); + assert_feed_err!(e, "", "\u{ffff}", "", []); + assert_feed_err!(e, "?", "\u{ffff}", "!", [0x3f]); + assert_feed_err!(e, "", "\u{736c}", "\u{8c78}", []); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0x5c], [], "\\"); + assert_feed_ok!(d, [0x7e], [], "~"); + assert_feed_ok!(d, [0x80], [], "\u{80}"); // compatibility + assert_feed_ok!(d, [0x82, 0xc9, 0x82, 0xd9, 0x82, 0xf1], [], "\u{306b}\u{307b}\u{3093}"); + assert_feed_ok!(d, [0xc6, 0xce, 0xdd], [], "\u{ff86}\u{ff8e}\u{ff9d}"); + assert_feed_ok!(d, [0x93, 0xfa, 0x96, 0x7b], [], "\u{65e5}\u{672c}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_eudc() { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0xf0], ""); + assert_feed_ok!(d, [0x40], [], "\u{e000}"); + assert_feed_ok!(d, [0xf9, 0xfc], [], "\u{e757}"); + assert_feed_err!(d, [], [0xf0], [0x00], ""); + assert_feed_err!(d, [], [0xf0], [0xff], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_immediate_test_finish() { + for i in 0x81..0xa0 { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + + for i in 0xe0..0xfd { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + + // A0/FD/FE/FF: immediate failure + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_err!(d, [], [0xa0], [], ""); + assert_feed_err!(d, [], [0xfd], [], ""); + assert_feed_err!(d, [], [0xfe], [], ""); + assert_feed_err!(d, [], [0xff], [], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_followed_by_space() { + for i in 0x81..0xa0 { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x20], ""); + assert_finish_ok!(d, ""); + } + + for i in 0xe0..0xfd { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lead_followed_by_invalid_trail() { + for i in 0x81..0xa0 { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x3f], ""); + assert_feed_err!(d, [], [i], [0x7f], ""); + assert_feed_err!(d, [], [i], [0xfd], ""); + assert_feed_err!(d, [], [i], [0xfe], ""); + assert_feed_err!(d, [], [i], [0xff], ""); + assert_finish_ok!(d, ""); + } + + for i in 0xe0..0xfd { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x3f], ""); + assert_feed_err!(d, [], [i], [0x7f], ""); + assert_feed_err!(d, [], [i], [0xfd], ""); + assert_feed_err!(d, [], [i], [0xfe], ""); + assert_feed_err!(d, [], [i], [0xff], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lead_followed_by_invalid_trail_partial() { + for i in 0x81..0xa0 { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); + assert_feed_err!(d, [], [], [0xff], ""); + assert_finish_ok!(d, ""); + } + + for i in 0xe0..0xfd { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); + assert_feed_err!(d, [], [], [0xff], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = Windows31JEncoding.raw_decoder(); + assert_feed_ok!(d, [0x82, 0xa0], [0x82], "\u{3042}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0x82, 0xa0], [], "\u{3042}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::JAPANESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + Windows31JEncoding.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = Windows31JEncoding.encode(testutils::JAPANESE_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + Windows31JEncoding.decode(&s, DecoderTrap::Strict) + })) + } +} + +/** + * ISO-2022-JP. + * + * This version of ISO-2022-JP does not correspond to any standardized repertoire of character sets + * due to the widespread implementation differences. The following character sets are supported: + * + * - JIS X 0201-1976 roman (`ESC ( J` or `ESC ( B`; the latter is originally allocated to ASCII + * but willfully violated) + * - JIS X 0201-1976 kana (`ESC ( I`) + * - JIS X 0208-1983 (`ESC $ B` or `ESC $ @`; the latter is originally allocated to JIS X 0208-1978 + * but willfully violated) + * - JIS X 0212-1990 (`ESC $ ( D`, XXX asymmetric support) + */ +#[derive(Clone, Copy)] +pub struct ISO2022JPEncoding; + +impl Encoding for ISO2022JPEncoding { + fn name(&self) -> &'static str { "iso-2022-jp" } + fn whatwg_name(&self) -> Option<&'static str> { Some("iso-2022-jp") } + fn raw_encoder(&self) -> Box { ISO2022JPEncoder::new() } + fn raw_decoder(&self) -> Box { ISO2022JPDecoder::new() } +} + +#[derive(PartialEq,Clone,Copy)] +enum ISO2022JPState { + ASCII, // U+0000..007F, U+00A5, U+203E + Katakana, // JIS X 0201: U+FF61..FF9F + Lead, // JIS X 0208 +} + +/// An encoder for ISO-2022-JP without JIS X 0212/0213 support. +#[derive(Clone, Copy)] +pub struct ISO2022JPEncoder { + st: ISO2022JPState +} + +impl ISO2022JPEncoder { + pub fn new() -> Box { Box::new(ISO2022JPEncoder { st: ASCII }) } +} + +impl RawEncoder for ISO2022JPEncoder { + fn from_self(&self) -> Box { ISO2022JPEncoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + let mut st = self.st; + macro_rules! ensure_ASCII( + () => (if st != ASCII { output.write_bytes(b"\x1b(B"); st = ASCII; }) + ); + macro_rules! ensure_Katakana( + () => (if st != Katakana { output.write_bytes(b"\x1b(I"); st = Katakana; }) + ); + macro_rules! ensure_Lead( + () => (if st != Lead { output.write_bytes(b"\x1b$B"); st = Lead; }) + ); + + for ((i,j), ch) in input.index_iter() { + match ch { + '\u{0}'...'\u{7f}' => { ensure_ASCII!(); output.write_byte(ch as u8); } + '\u{a5}' => { ensure_ASCII!(); output.write_byte(0x5c); } + '\u{203e}' => { ensure_ASCII!(); output.write_byte(0x7e); } + '\u{ff61}'...'\u{ff9f}' => { + ensure_Katakana!(); + output.write_byte((ch as usize - 0xff61 + 0x21) as u8); + } + _ => { + let ptr = index::jis0208::backward(ch as u32); + if ptr == 0xffff { + self.st = st; // do NOT reset the state! + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } else { + ensure_Lead!(); + let lead = ptr / 94 + 0x21; + let trail = ptr % 94 + 0x21; + output.write_byte(lead as u8); + output.write_byte(trail as u8); + } + } + } + } + + self.st = st; + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for ISO-2022-JP with JIS X 0212 support. +#[derive(Clone, Copy)] +struct ISO2022JPDecoder { + st: iso2022jp::State, +} + +impl ISO2022JPDecoder { + pub fn new() -> Box { + Box::new(ISO2022JPDecoder { st: Default::default() }) + } +} + +impl RawDecoder for ISO2022JPDecoder { + fn from_self(&self) -> Box { ISO2022JPDecoder::new() } + fn is_ascii_compatible(&self) -> bool { false } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = iso2022jp::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = iso2022jp::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module iso2022jp; + + internal pub fn map_two_0208_bytes(lead: u8, trail: u8) -> u32 { + use index_japanese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0x21...0x7e, 0x21...0x7e) => (lead - 0x21) * 94 + trail - 0x21, + _ => 0xffff, + }; + index::jis0208::forward(index) + } + + internal pub fn map_two_0212_bytes(lead: u8, trail: u8) -> u32 { + use index_japanese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0x21...0x7e, 0x21...0x7e) => (lead - 0x21) * 94 + trail - 0x21, + _ => 0xffff, + }; + index::jis0212::forward(index) + } + +initial: + // iso-2022-jp state = ASCII, iso-2022-jp jis0212 flag = unset, iso-2022-jp lead = 0x00 + state ASCII(ctx: Context) { + case 0x1b => EscapeStart(ctx); + case b @ 0x00...0x7f => ctx.emit(b as u32), ASCII(ctx); + case _ => ctx.err("invalid sequence"), ASCII(ctx); + final => ctx.reset(); + } + +checkpoint: + // iso-2022-jp state = Lead, iso-2022-jp jis0212 flag = unset + state Lead0208(ctx: Context) { + case 0x0a => ctx.emit(0x000a); // return to ASCII + case 0x1b => EscapeStart(ctx); + case b => Trail0208(ctx, b); + final => ctx.reset(); + } + + // iso-2022-jp state = Lead, iso-2022-jp jis0212 flag = set + state Lead0212(ctx: Context) { + case 0x0a => ctx.emit(0x000a); // return to ASCII + case 0x1b => EscapeStart(ctx); + case b => Trail0212(ctx, b); + final => ctx.reset(); + } + + // iso-2022-jp state = Katakana + state Katakana(ctx: Context) { + case 0x1b => EscapeStart(ctx); + case b @ 0x21...0x5f => ctx.emit(0xff61 + b as u32 - 0x21), Katakana(ctx); + case _ => ctx.err("invalid sequence"), Katakana(ctx); + final => ctx.reset(); + } + +transient: + // iso-2022-jp state = EscapeStart + // ESC + state EscapeStart(ctx: Context) { + case 0x24 => EscapeMiddle24(ctx); // ESC $ + case 0x28 => EscapeMiddle28(ctx); // ESC ( + case _ => ctx.backup_and_err(1, "invalid sequence"); + final => ctx.err("incomplete sequence"); + } + + // iso-2022-jp state = EscapeMiddle, iso-2022-jp lead = 0x24 + // ESC $ + state EscapeMiddle24(ctx: Context) { + case 0x40, 0x42 => Lead0208(ctx); // ESC $ @ (JIS X 0208-1978) or ESC $ B (-1983) + case 0x28 => EscapeFinal(ctx); // ESC $ ( + case _ => ctx.backup_and_err(2, "invalid sequence"); + final => ctx.err("incomplete sequence"); + } + + // iso-2022-jp state = EscapeMiddle, iso-2022-jp lead = 0x28 + // ESC ( + state EscapeMiddle28(ctx: Context) { + case 0x42, 0x4a => ctx.reset(); // ESC ( B (ASCII) or ESC ( J (JIS X 0201-1976 roman) + case 0x49 => Katakana(ctx); // ESC ( I (JIS X 0201-1976 kana) + case _ => ctx.backup_and_err(2, "invalid sequence"); + final => ctx.err("incomplete sequence"); + } + + // iso-2022-jp state = EscapeFinal + // ESC $ ( + state EscapeFinal(ctx: Context) { + case 0x44 => Lead0212(ctx); // ESC $ ( D (JIS X 0212-1990) + case _ => ctx.backup_and_err(3, "invalid sequence"); + final => ctx.backup_and_err(1, "incomplete sequence"); + } + + // iso-2022-jp state = Trail, iso-2022-jp jis0212 flag = unset + state Trail0208(ctx: Context, lead: u8) { + case b => + match map_two_0208_bytes(lead, b) { + 0xffff => ctx.err("invalid sequence"), + ch => ctx.emit(ch as u32) + }, + Lead0208(ctx); + final => ctx.err("incomplete sequence"); + } + + // iso-2022-jp state = Trail, iso-2022-jp jis0212 flag = set + state Trail0212(ctx: Context, lead: u8) { + case b => + match map_two_0212_bytes(lead, b) { + 0xffff => ctx.err("invalid sequence"), + ch => ctx.emit(ch as u32) + }, + Lead0212(ctx); + final => ctx.err("incomplete sequence"); + } +} + +#[cfg(test)] +mod iso2022jp_tests { + extern crate test; + use super::ISO2022JPEncoding; + use testutils; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = ISO2022JPEncoding.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "\x1b\x24\x42", "", [0x1b, 0x24, 0x42]); // no round-trip guarantee + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{a5}", "", [0x5c]); + assert_feed_ok!(e, "\u{203e}", "", [0x7e]); + assert_feed_ok!(e, "\u{306b}\u{307b}\u{3093}", "", [0x1b, 0x24, 0x42, + 0x24, 0x4b, 0x24, 0x5b, 0x24, 0x73]); + assert_feed_ok!(e, "\u{65e5}\u{672c}", "", [0x46, 0x7c, 0x4b, 0x5c]); + assert_feed_ok!(e, "\u{ff86}\u{ff8e}\u{ff9d}", "", [0x1b, 0x28, 0x49, + 0x46, 0x4e, 0x5d]); + assert_feed_ok!(e, "XYZ", "", [0x1b, 0x28, 0x42, + 0x58, 0x59, 0x5a]); + assert_finish_ok!(e, []); + + // one ASCII character and two similarly looking characters: + // - A: U+0020 SPACE (requires ASCII state) + // - B: U+30CD KATAKANA LETTER NE (requires JIS X 0208 Lead state) + // - C: U+FF88 HALFWIDTH KATAKANA LETTER NE (requires Katakana state) + // - D is omitted as the encoder does not support JIS X 0212. + // a (3,2) De Bruijn near-sequence "ABCACBA" is used to test all possible cases. + const AD: &'static str = "\x20"; + const BD: &'static str = "\u{30cd}"; + const CD: &'static str = "\u{ff88}"; + const AE: &'static [u8] = &[0x1b, 0x28, 0x42, 0x20]; + const BE: &'static [u8] = &[0x1b, 0x24, 0x42, 0x25, 0x4d]; + const CE: &'static [u8] = &[0x1b, 0x28, 0x49, 0x48]; + let mut e = ISO2022JPEncoding.raw_encoder(); + let decoded: String = ["\x20", BD, CD, AD, CD, BD, AD].concat(); + let encoded: Vec<_> = [&[0x20][..], BE, CE, AE, CE, BE, AE].concat(); + assert_feed_ok!(e, decoded, "", encoded); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_invalid() { + let mut e = ISO2022JPEncoding.raw_encoder(); + assert_feed_err!(e, "", "\u{ffff}", "", []); + assert_feed_err!(e, "?", "\u{ffff}", "!", [0x3f]); + // JIS X 0212 is not supported in the encoder + assert_feed_err!(e, "", "\u{736c}", "\u{8c78}", []); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [0x1b, 0x28, 0x4a, + 0x44, 0x45, 0x46], [], "DEF"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0x5c], [], "\\"); + assert_feed_ok!(d, [0x7e], [], "~"); + assert_feed_ok!(d, [0x1b, 0x24, 0x42, + 0x24, 0x4b, + 0x1b, 0x24, 0x42, + 0x24, 0x5b, 0x24, 0x73], [], "\u{306b}\u{307b}\u{3093}"); + assert_feed_ok!(d, [0x46, 0x7c, 0x4b, 0x5c], [], "\u{65e5}\u{672c}"); + assert_feed_ok!(d, [0x1b, 0x28, 0x49, + 0x46, 0x4e, 0x5d], [], "\u{ff86}\u{ff8e}\u{ff9d}"); + assert_feed_ok!(d, [0x1b, 0x24, 0x28, 0x44, + 0x4b, 0x46, + 0x1b, 0x24, 0x40, + 0x6c, 0x38], [], "\u{736c}\u{8c78}"); + assert_feed_ok!(d, [0x1b, 0x28, 0x42, + 0x58, 0x59, 0x5a], [], "XYZ"); + assert_finish_ok!(d, ""); + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x1b, 0x24, 0x42, + 0x24, 0x4b, 0x24, 0x5b, 0x24, 0x73], [], "\u{306b}\u{307b}\u{3093}"); + assert_finish_ok!(d, ""); + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x1b, 0x28, 0x49, + 0x46, 0x4e, 0x5d], [], "\u{ff86}\u{ff8e}\u{ff9d}"); + assert_finish_ok!(d, ""); + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x1b, 0x24, 0x28, 0x44, + 0x4b, 0x46], [], "\u{736c}"); + assert_finish_ok!(d, ""); + + // one ASCII character and three similarly looking characters: + // - A: U+0020 SPACE (requires ASCII state) + // - B: U+30CD KATAKANA LETTER NE (requires JIS X 0208 Lead state) + // - C: U+FF88 HALFWIDTH KATAKANA LETTER NE (requires Katakana state) + // - D: U+793B CJK UNIFIED IDEOGRAPH-793B (requires JIS X 0212 Lead state) + // a (4,2) De Bruijn sequence "AABBCCACBADDBDCDA" is used to test all possible cases. + const AD: &'static str = "\x20"; + const BD: &'static str = "\u{30cd}"; + const CD: &'static str = "\u{ff88}"; + const DD: &'static str = "\u{793b}"; + const AE: &'static [u8] = &[0x1b, 0x28, 0x42, 0x20]; + const BE: &'static [u8] = &[0x1b, 0x24, 0x42, 0x25, 0x4d]; + const CE: &'static [u8] = &[0x1b, 0x28, 0x49, 0x48]; + const DE: &'static [u8] = &[0x1b, 0x24, 0x28, 0x44, 0x50, 0x4b]; + let mut d = ISO2022JPEncoding.raw_decoder(); + let dec: String = ["\x20", AD,BD,BD,CD,CD,AD,CD,BD,AD,DD,DD,BD,DD,CD,DD,AD].concat(); + let enc: Vec<_> = [&[0x20][..],AE,BE,BE,CE,CE,AE,CE,BE,AE,DE,DE,BE,DE,CE,DE,AE].concat(); + assert_feed_ok!(d, enc, [], dec); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_valid_partial() { + let mut d = ISO2022JPEncoding.raw_decoder(); + + assert_feed_ok!(d, [], [0x1b], ""); + assert_feed_ok!(d, [], [0x28], ""); + assert_feed_ok!(d, [0x4a, 0x41], [], "A"); + assert_feed_ok!(d, [], [0x1b, 0x28], ""); + assert_feed_ok!(d, [0x4a, 0x42], [0x1b], "B"); + assert_feed_ok!(d, [0x28, 0x4a, 0x43], [], "C"); + + assert_feed_ok!(d, [], [0x1b], ""); + assert_feed_ok!(d, [], [0x24], ""); + assert_feed_ok!(d, [0x42], [0x24], ""); + assert_feed_ok!(d, [0x4b], [0x1b, 0x24], "\u{306b}"); + assert_feed_ok!(d, [0x42, 0x24, 0x5b], [], "\u{307b}"); + assert_feed_ok!(d, [], [0x1b], ""); + assert_feed_ok!(d, [0x24, 0x42, 0x24, 0x73], [], "\u{3093}"); + + assert_feed_ok!(d, [], [0x1b], ""); + assert_feed_ok!(d, [], [0x28], ""); + assert_feed_ok!(d, [0x49, 0x46], [], "\u{ff86}"); + assert_feed_ok!(d, [], [0x1b, 0x28], ""); + assert_feed_ok!(d, [0x49, 0x4e], [0x1b], "\u{ff8e}"); + assert_feed_ok!(d, [0x28, 0x49, 0x5d], [], "\u{ff9d}"); + + assert_feed_ok!(d, [], [0x1b, 0x24], ""); + assert_feed_ok!(d, [], [0x28], ""); + assert_feed_ok!(d, [0x44], [0x4b], ""); + assert_feed_ok!(d, [0x46], [0x1b, 0x24, 0x28], "\u{736c}"); + assert_feed_ok!(d, [0x44, 0x4b, 0x46], [], "\u{736c}"); + + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_carriage_return() { + // CR in Lead state "resets to ASCII" + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x1b, 0x24, 0x42, + 0x25, 0x4d, + 0x0a, + 0x25, 0x4d], [], "\u{30cd}\n\x25\x4d"); + assert_feed_ok!(d, [0x1b, 0x24, 0x28, 0x44, + 0x50, 0x4b, + 0x0a, + 0x50, 0x4b], [], "\u{793b}\n\x50\x4b"); + assert_finish_ok!(d, ""); + + // other states don't allow CR + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_err!(d, [0x1b, 0x28, 0x49, 0x48], [0x0a], [], "\u{ff88}"); // Katakana + assert_feed_err!(d, [0x1b, 0x24, 0x42], [0x25, 0x0a], [], ""); // Trail + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_partial() { + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x1b, 0x24, 0x42, 0x24, 0x4b], [0x24], "\u{306b}"); + assert_finish_err!(d, ""); + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x1b, 0x24, 0x28, 0x44, 0x4b, 0x46], [0x50], "\u{736c}"); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_partial_escape() { + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x1b], ""); + assert_finish_err!(d, ""); + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x1b, 0x24], ""); + assert_finish_err!(d, ""); // no backup + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x1b, 0x24, 0x28], ""); + assert_finish_err!(d, -1, ""); // backup of -1, not -2 + + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [], [0x1b, 0x28], ""); + assert_finish_err!(d, ""); // no backup + + assert_eq!(ISO2022JPEncoding.decode(&[0x1b], DecoderTrap::Replace), + Ok("\u{fffd}".to_string())); + assert_eq!(ISO2022JPEncoding.decode(&[0x1b, 0x24], DecoderTrap::Replace), + Ok("\u{fffd}".to_string())); + assert_eq!(ISO2022JPEncoding.decode(&[0x1b, 0x24, 0x28], DecoderTrap::Replace), + Ok("\u{fffd}\x28".to_string())); + assert_eq!(ISO2022JPEncoding.decode(&[0x1b, 0x28], DecoderTrap::Replace), + Ok("\u{fffd}".to_string())); + } + + #[test] + fn test_decoder_invalid_escape() { + // also tests allowed but never used escape codes in ISO 2022 + let mut d = ISO2022JPEncoding.raw_decoder(); + macro_rules! reset(() => ( + assert_feed_ok!(d, [0x41, 0x42, 0x43, 0x1b, 0x24, 0x42, 0x21, 0x21], [], + "ABC\u{3000}") + )); + + reset!(); + assert_feed_ok!(d, [], [0x1b], ""); + assert_feed_err!(d, [], [], [0x00], ""); + reset!(); + assert_feed_err!(d, [], [0x1b], [0x0a], ""); + reset!(); + assert_feed_err!(d, [], [0x1b], [0x20], ""); + reset!(); + assert_feed_err!(d, [], [0x1b], [0x21, 0x5a], ""); // ESC ! Z (CZD) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x22, 0x5a], ""); // ESC " Z (C1D) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x5a], ""); // ESC $ Z (GZDM4) + reset!(); + assert_feed_ok!(d, [], [0x1b, 0x24], ""); + assert_feed_err!(d, -1, [], [], [0x24, 0x5a], ""); + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x28, 0x5a], ""); // ESC $ ( Z (GZDM4) + reset!(); + assert_feed_ok!(d, [], [0x1b, 0x24, 0x28], ""); + assert_feed_err!(d, -2, [], [], [0x24, 0x28, 0x5a], ""); + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x29, 0x5a], ""); // ESC $ ) Z (G1DM4) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x2a, 0x5a], ""); // ESC $ * Z (G2DM4) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x2b, 0x5a], ""); // ESC $ + Z (G3DM4) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x2d, 0x5a], ""); // ESC $ - Z (G1DM6) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x2e, 0x5a], ""); // ESC $ . Z (G2DM6) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x24, 0x2f, 0x5a], ""); // ESC $ / Z (G3DM6) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x25, 0x5a], ""); // ESC % Z (DOCS) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x25, 0x2f, 0x5a], ""); // ESC % / Z (DOCS) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x28, 0x5a], ""); // ESC ( Z (GZD4) + reset!(); + assert_feed_ok!(d, [], [0x1b, 0x28], ""); + assert_feed_err!(d, -1, [], [], [0x28, 0x5a], ""); + reset!(); + assert_feed_err!(d, [], [0x1b], [0x29, 0x5a], ""); // ESC ) Z (G1D4) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x2a, 0x5a], ""); // ESC * Z (G2D4) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x2b, 0x5a], ""); // ESC + Z (G3D4) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x2d, 0x5a], ""); // ESC - Z (G1D6) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x2e, 0x5a], ""); // ESC . Z (G2D6) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x2f, 0x5a], ""); // ESC / Z (G3D6) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x4e], ""); // ESC N (SS2) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x4f], ""); // ESC O (SS3) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x6e], ""); // ESC n (LS2) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x6f], ""); // ESC o (LS3) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x7c], ""); // ESC | (LS3R) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x7d], ""); // ESC } (LS2R) + reset!(); + assert_feed_err!(d, [], [0x1b], [0x7e], ""); // ESC ~ (LS1R) + reset!(); + assert_feed_err!(d, [], [0x1b], [0xff], ""); + reset!(); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_out_or_range() { + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_err!(d, [], [0x80], [], ""); + assert_feed_err!(d, [], [0xff], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x42], [0x80, 0x21], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x42], [0x21, 0x80], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x42], [0x20, 0x21], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x42], [0x21, 0x20], [], ""); + assert_feed_err!(d, [0x1b, 0x28, 0x49], [0x20], [], ""); + assert_feed_err!(d, [0x1b, 0x28, 0x49], [0x60], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x28, 0x44], [0x80, 0x21], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x28, 0x44], [0x21, 0x80], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x28, 0x44], [0x20, 0x21], [], ""); + assert_feed_err!(d, [0x1b, 0x24, 0x28, 0x44], [0x21, 0x20], [], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = ISO2022JPEncoding.raw_decoder(); + assert_feed_ok!(d, [0x24, 0x22, + 0x1b, 0x24, 0x42, + 0x24, 0x22], [0x24], "\x24\x22\u{3042}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0x24, 0x22, + 0x1b, 0x24, 0x42, + 0x24, 0x22], [], "\x24\x22\u{3042}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::JAPANESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + ISO2022JPEncoding.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = ISO2022JPEncoding.encode(testutils::JAPANESE_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + ISO2022JPEncoding.decode(&s, DecoderTrap::Strict) + })) + } +} diff --git a/deps/encoding-0.2.32/src/codec/korean.rs b/deps/encoding-0.2.32/src/codec/korean.rs new file mode 100644 index 000000000..7fb3b119f --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/korean.rs @@ -0,0 +1,280 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Legacy Korean encodings based on KS X 1001. + +use std::convert::Into; +use std::default::Default; +use util::StrCharIndex; +use index_korean as index; +use types::*; + +/** + * Windows code page 949. + * + * This is a Korean encoding derived from EUC-KR, + * which is so widespread that most occurrences of EUC-KR actually mean this encoding. + * Unlike KS X 1001 (and EUC-KR) which only contains a set of 2,350 common Hangul syllables, + * it assigns remaining 8,822 Hangul syllables to the two-byte sequence + * which second byte have its MSB unset (i.e. `[81-C6] [41-5A 61-7A 81-FE]`). + * Its design strongly resembles that of Shift_JIS but less prone to errors + * since the set of MSB-unset second bytes is much limited compared to Shift_JIS. + */ +#[derive(Clone, Copy)] +pub struct Windows949Encoding; + +impl Encoding for Windows949Encoding { + fn name(&self) -> &'static str { "windows-949" } + fn whatwg_name(&self) -> Option<&'static str> { Some("euc-kr") } // WHATWG compatibility + fn raw_encoder(&self) -> Box { Windows949Encoder::new() } + fn raw_decoder(&self) -> Box { Windows949Decoder::new() } +} + +/// An encoder for Windows code page 949. +#[derive(Clone, Copy)] +pub struct Windows949Encoder; + +impl Windows949Encoder { + pub fn new() -> Box { Box::new(Windows949Encoder) } +} + +impl RawEncoder for Windows949Encoder { + fn from_self(&self) -> Box { Windows949Encoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + for ((i,j), ch) in input.index_iter() { + if ch <= '\u{7f}' { + output.write_byte(ch as u8); + } else { + let ptr = index::euc_kr::backward(ch as u32); + if ptr == 0xffff { + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } else { + output.write_byte((ptr / 190 + 0x81) as u8); + output.write_byte((ptr % 190 + 0x41) as u8); + } + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for Windows code page 949. +#[derive(Clone, Copy)] +struct Windows949Decoder { + st: windows949::State, +} + +impl Windows949Decoder { + pub fn new() -> Box { + Box::new(Windows949Decoder { st: Default::default() }) + } +} + +impl RawDecoder for Windows949Decoder { + fn from_self(&self) -> Box { Windows949Decoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = windows949::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = windows949::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module windows949; + + internal pub fn map_two_bytes(lead: u8, trail: u8) -> u32 { + use index_korean as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0x81...0xfe, 0x41...0xfe) => (lead - 0x81) * 190 + (trail - 0x41), + (_, _) => 0xffff, + }; + index::euc_kr::forward(index) + } + +initial: + // euc-kr lead = 0x00 + state S0(ctx: Context) { + case b @ 0x00...0x7f => ctx.emit(b as u32); + case b @ 0x81...0xfe => S1(ctx, b); + case _ => ctx.err("invalid sequence"); + } + +transient: + // euc-kr lead != 0x00 + state S1(ctx: Context, lead: u8) { + case b => match map_two_bytes(lead, b) { + 0xffff => { + let backup = if b < 0x80 {1} else {0}; + ctx.backup_and_err(backup, "invalid sequence") + }, + ch => ctx.emit(ch as u32) + }; + } +} + +#[cfg(test)] +mod windows949_tests { + extern crate test; + use super::Windows949Encoding; + use testutils; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = Windows949Encoding.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{ac00}", "", [0xb0, 0xa1]); + assert_feed_ok!(e, "\u{b098}\u{b2e4}", "", [0xb3, 0xaa, 0xb4, 0xd9]); + assert_feed_ok!(e, "\u{bdc1}\u{314b}\u{d7a3}", "", [0x94, 0xee, 0xa4, 0xbb, 0xc6, 0x52]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_invalid() { + let mut e = Windows949Encoding.raw_encoder(); + assert_feed_err!(e, "", "\u{ffff}", "", []); + assert_feed_err!(e, "?", "\u{ffff}", "!", [0x3f]); + assert_feed_err!(e, "?", "\u{fffd}", "!", [0x3f]); // for invalid table entries + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0xb0, 0xa1], [], "\u{ac00}"); + assert_feed_ok!(d, [0xb3, 0xaa, 0xb4, 0xd9], [], "\u{b098}\u{b2e4}"); + assert_feed_ok!(d, [0x94, 0xee, 0xa4, 0xbb, 0xc6, 0x52, 0xc1, 0x64], [], + "\u{bdc1}\u{314b}\u{d7a3}\u{d58f}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_valid_partial() { + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xb0], ""); + assert_feed_ok!(d, [0xa1], [], "\u{ac00}"); + assert_feed_ok!(d, [0xb3, 0xaa], [0xb4], "\u{b098}"); + assert_feed_ok!(d, [0xd9], [0x94], "\u{b2e4}"); + assert_feed_ok!(d, [0xee, 0xa4, 0xbb], [0xc6], "\u{bdc1}\u{314b}"); + assert_feed_ok!(d, [0x52, 0xc1, 0x64], [], "\u{d7a3}\u{d58f}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_immediate_test_finish() { + for i in 0x81..0xff { + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + + // 80/FF: immediate failure + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_err!(d, [], [0x80], [], ""); + assert_feed_err!(d, [], [0xff], [], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_followed_by_space() { + for i in 0x80..0x100 { + let i = i as u8; + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lead_followed_by_invalid_trail() { + // should behave similarly to Big5. + // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16691 + for i in 0x81..0xff { + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_err!(d, [], [i, 0x80], [0x20], ""); + assert_feed_err!(d, [], [i, 0xff], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); + assert_feed_err!(d, [], [0x80], [0x20], ""); + assert_feed_ok!(d, [], [i], ""); + assert_feed_err!(d, [], [0xff], [0x20], ""); + assert_finish_ok!(d, ""); + } + + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_err!(d, [], [0x80], [0x80], ""); + assert_feed_err!(d, [], [0x80], [0xff], ""); + assert_feed_err!(d, [], [0xff], [0x80], ""); + assert_feed_err!(d, [], [0xff], [0xff], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_boundary() { + // U+D7A3 (C6 52) is the last Hangul syllable not in KS X 1001, C6 53 is invalid. + // note that since the trail byte may coincide with ASCII, the trail byte 53 is + // not considered to be in the problem. this is compatible to WHATWG Encoding standard. + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xc6], ""); + assert_feed_err!(d, [], [], [0x53], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = Windows949Encoding.raw_decoder(); + assert_feed_ok!(d, [0xb0, 0xa1], [0xb0], "\u{ac00}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xb0, 0xa1], [], "\u{ac00}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + Windows949Encoding.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = Windows949Encoding.encode(testutils::KOREAN_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + Windows949Encoding.decode(&s, DecoderTrap::Strict) + })) + } +} + diff --git a/deps/encoding-0.2.32/src/codec/simpchinese.rs b/deps/encoding-0.2.32/src/codec/simpchinese.rs new file mode 100644 index 000000000..c4181cf89 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/simpchinese.rs @@ -0,0 +1,779 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Legacy simplified Chinese encodings based on GB 2312 and GB 18030. + +use std::convert::Into; +use std::marker::PhantomData; +use std::default::Default; +use util::StrCharIndex; +use index_simpchinese as index; +use types::*; + +/// An implementation type for GBK. +/// +/// Can be used as a type parameter to `GBEncoding` and `GBEncoder`. +/// (GB18030Decoder is shared by both.) +#[derive(Clone, Copy)] +pub struct GBK; + +/// An implementation type for GB18030. +/// +/// Can be used as a type parameter to `GBEncoding` and `GBEncoder.' +/// (GB18030Decoder is shared by both.) +#[derive(Clone, Copy)] +pub struct GB18030; + +/// An internal trait used to customize GBK and GB18030 implementations. +trait GBType: Clone + 'static { + fn name() -> &'static str; + fn whatwg_name() -> Option<&'static str>; + fn initial_gbk_flag() -> bool; +} + +impl GBType for GBK { + fn name() -> &'static str { "gbk" } + fn whatwg_name() -> Option<&'static str> { Some("gbk") } + fn initial_gbk_flag() -> bool { true } +} + +impl GBType for GB18030 { + fn name() -> &'static str { "gb18030" } + fn whatwg_name() -> Option<&'static str> { Some("gb18030") } + fn initial_gbk_flag() -> bool { false } +} + +/** + * GBK and GB 18030-2005. + * + * The original GBK 1.0 region spans `[81-FE] [40-7E 80-FE]`, and is derived from + * several different revisions of a family of encodings named "GBK": + * + * - GBK as specified in the normative annex of GB 13000.1-93, + * the domestic standard equivalent to Unicode 1.1, + * consisted of characters included in Unicode 1.1 and not in GB 2312-80. + * - Windows code page 936 is the widespread extension to GBK. + * - Due to the popularity of Windows code page 936, + * a formal encoding based on Windows code page 936 (while adding new characters) + * was standardized into GBK 1.0. + * - Finally, GB 18030 added four-byte sequences to GBK for becoming a pan-Unicode encoding, + * while adding new characters to the (former) GBK region again. + * + * GB 18030-2005 is a simplified Chinese encoding which extends GBK 1.0 to a pan-Unicode encoding. + * It assigns four-byte sequences to every Unicode codepoint missing from the GBK area, + * lexicographically ordered with occasional "gaps" for codepoints in the GBK area. + * Due to this compatibility decision, + * there is no simple relationship between these four-byte sequences and Unicode codepoints, + * though there *exists* a relatively simple mapping algorithm with a small lookup table. + * + * ## Specialization + * + * This type is specialized with GBType `T`, + * which should be either `GBK` or `GB18030`. + */ +#[derive(Clone, Copy)] +pub struct GBEncoding { + _marker: PhantomData +} + +/// A type for GBK. +pub type GBKEncoding = GBEncoding; +/// A type for GB18030. +pub type GB18030Encoding = GBEncoding; + +/// An instance for GBK. +pub const GBK_ENCODING: GBKEncoding = GBEncoding { _marker: PhantomData }; +/// An instance for GB18030. +pub const GB18030_ENCODING: GB18030Encoding = GBEncoding { _marker: PhantomData }; + +impl Encoding for GBEncoding { + fn name(&self) -> &'static str { ::name() } + fn whatwg_name(&self) -> Option<&'static str> { ::whatwg_name() } + fn raw_encoder(&self) -> Box { GBEncoder::::new() } + fn raw_decoder(&self) -> Box { GB18030Decoder::new() } +} + +/** + * An encoder for GBK and GB18030. + * + * ## Specialization + * + * This type is specialized with GBType `T`, + * which should be either `GBK` or `GB18030`. + */ +#[derive(Clone, Copy)] +pub struct GBEncoder { + _marker: PhantomData +} + +impl GBEncoder { + pub fn new() -> Box { + Box::new(GBEncoder:: { _marker: PhantomData }) + } +} + +impl RawEncoder for GBEncoder { + fn from_self(&self) -> Box { GBEncoder::::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + let gbk_flag = ::initial_gbk_flag(); + for ((i, j), ch) in input.index_iter() { + if ch < '\u{80}' { + output.write_byte(ch as u8); + } else if gbk_flag && ch == '\u{20AC}' { + output.write_byte('\u{80}' as u8) + } else { + let ptr = index::gb18030::backward(ch as u32); + if ptr == 0xffff { + if gbk_flag { + return (i, Some(CodecError { + upto: j as isize, + cause: "gbk doesn't support gb18030 extensions".into() + })); + } + let ptr = index::gb18030_ranges::backward(ch as u32); + assert!(ptr != 0xffffffff); + let (ptr, byte4) = (ptr / 10, ptr % 10); + let (ptr, byte3) = (ptr / 126, ptr % 126); + let (byte1, byte2) = (ptr / 10, ptr % 10); + output.write_byte((byte1 + 0x81) as u8); + output.write_byte((byte2 + 0x30) as u8); + output.write_byte((byte3 + 0x81) as u8); + output.write_byte((byte4 + 0x30) as u8); + } else { + let lead = ptr / 190 + 0x81; + let trail = ptr % 190; + let trailoffset = if trail < 0x3f {0x40} else {0x41}; + output.write_byte(lead as u8); + output.write_byte((trail + trailoffset) as u8); + } + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for GB 18030 (also used by GBK). +#[derive(Clone, Copy)] +struct GB18030Decoder { + st: gb18030::State, +} + +impl GB18030Decoder { + pub fn new() -> Box { + Box::new(GB18030Decoder { st: Default::default() }) + } +} + +impl RawDecoder for GB18030Decoder { + fn from_self(&self) -> Box { GB18030Decoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = gb18030::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = gb18030::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module gb18030; + + internal pub fn map_two_bytes(lead: u8, trail: u8) -> u32 { + use index_simpchinese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0x81...0xfe, 0x40...0x7e) | (0x81...0xfe, 0x80...0xfe) => { + let trailoffset = if trail < 0x7f {0x40} else {0x41}; + (lead - 0x81) * 190 + trail - trailoffset + } + _ => 0xffff, + }; + index::gb18030::forward(index) + } + + internal pub fn map_four_bytes(b1: u8, b2: u8, b3: u8, b4: u8) -> u32 { + use index_simpchinese as index; + + // no range check here, caller should have done all checks + let index = (b1 as u32 - 0x81) * 12600 + (b2 as u32 - 0x30) * 1260 + + (b3 as u32 - 0x81) * 10 + (b4 as u32 - 0x30); + index::gb18030_ranges::forward(index) + } + +initial: + // gb18030 first = 0x00, gb18030 second = 0x00, gb18030 third = 0x00 + state S0(ctx: Context) { + case b @ 0x00...0x7f => ctx.emit(b as u32); + case 0x80 => ctx.emit(0x20ac); + case b @ 0x81...0xfe => S1(ctx, b); + case _ => ctx.err("invalid sequence"); + } + +transient: + // gb18030 first != 0x00, gb18030 second = 0x00, gb18030 third = 0x00 + state S1(ctx: Context, first: u8) { + case b @ 0x30...0x39 => S2(ctx, first, b); + case b => match map_two_bytes(first, b) { + 0xffff => ctx.backup_and_err(1, "invalid sequence"), // unconditional + ch => ctx.emit(ch) + }; + } + + // gb18030 first != 0x00, gb18030 second != 0x00, gb18030 third = 0x00 + state S2(ctx: Context, first: u8, second: u8) { + case b @ 0x81...0xfe => S3(ctx, first, second, b); + case _ => ctx.backup_and_err(2, "invalid sequence"); + } + + // gb18030 first != 0x00, gb18030 second != 0x00, gb18030 third != 0x00 + state S3(ctx: Context, first: u8, second: u8, third: u8) { + case b @ 0x30...0x39 => match map_four_bytes(first, second, third, b) { + 0xffffffff => ctx.backup_and_err(3, "invalid sequence"), // unconditional + ch => ctx.emit(ch) + }; + case _ => ctx.backup_and_err(3, "invalid sequence"); + } +} + +#[cfg(test)] +mod gb18030_tests { + extern crate test; + use super::GB18030_ENCODING; + use testutils; + use types::*; + + #[test] + fn test_encoder() { + let mut e = GB18030_ENCODING.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{4e2d}\u{534e}\u{4eba}\u{6c11}\u{5171}\u{548c}\u{56fd}", "", + [0xd6, 0xd0, 0xbb, 0xaa, 0xc8, 0xcb, 0xc3, 0xf1, + 0xb9, 0xb2, 0xba, 0xcd, 0xb9, 0xfa]); + assert_feed_ok!(e, "1\u{20ac}/m", "", [0x31, 0xa2, 0xe3, 0x2f, 0x6d]); + assert_feed_ok!(e, "\u{ff21}\u{ff22}\u{ff23}", "", [0xa3, 0xc1, 0xa3, 0xc2, 0xa3, 0xc3]); + assert_feed_ok!(e, "\u{80}", "", [0x81, 0x30, 0x81, 0x30]); + assert_feed_ok!(e, "\u{81}", "", [0x81, 0x30, 0x81, 0x31]); + assert_feed_ok!(e, "\u{a3}", "", [0x81, 0x30, 0x84, 0x35]); + assert_feed_ok!(e, "\u{a4}", "", [0xa1, 0xe8]); + assert_feed_ok!(e, "\u{a5}", "", [0x81, 0x30, 0x84, 0x36]); + assert_feed_ok!(e, "\u{10ffff}", "", [0xe3, 0x32, 0x9a, 0x35]); + assert_feed_ok!(e, "\u{2a6a5}\u{3007}", "", [0x98, 0x35, 0xee, 0x37, 0xa9, 0x96]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0xd6, 0xd0, 0xbb, 0xaa, 0xc8, 0xcb, 0xc3, 0xf1, + 0xb9, 0xb2, 0xba, 0xcd, 0xb9, 0xfa], [], + "\u{4e2d}\u{534e}\u{4eba}\u{6c11}\u{5171}\u{548c}\u{56fd}"); + assert_feed_ok!(d, [0x31, 0x80, 0x2f, 0x6d], [], "1\u{20ac}/m"); + assert_feed_ok!(d, [0xa3, 0xc1, 0xa3, 0xc2, 0xa3, 0xc3], [], "\u{ff21}\u{ff22}\u{ff23}"); + assert_feed_ok!(d, [0x81, 0x30, 0x81, 0x30], [], "\u{80}"); + assert_feed_ok!(d, [0x81, 0x30, 0x81, 0x31], [], "\u{81}"); + assert_feed_ok!(d, [0x81, 0x30, 0x84, 0x35], [], "\u{a3}"); + assert_feed_ok!(d, [0xa1, 0xe8], [], "\u{a4}" ); + assert_feed_ok!(d, [0x81, 0x30, 0x84, 0x36], [], "\u{a5}"); + assert_feed_ok!(d, [0xe3, 0x32, 0x9a, 0x35], [], "\u{10ffff}"); + assert_feed_ok!(d, [0x98, 0x35, 0xee, 0x37, 0xa9, 0x96], [], "\u{2a6a5}\u{3007}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_valid_partial() { + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0xa1], ""); + assert_feed_ok!(d, [0xa1], [], "\u{3000}"); + assert_feed_ok!(d, [], [0x81], ""); + assert_feed_ok!(d, [], [0x30], ""); + assert_feed_ok!(d, [], [0x81], ""); + assert_feed_ok!(d, [0x30], [], "\u{80}"); + assert_feed_ok!(d, [], [0x81], ""); + assert_feed_ok!(d, [], [0x30], ""); + assert_feed_ok!(d, [0x81, 0x31], [], "\u{81}"); + assert_feed_ok!(d, [], [0x81], ""); + assert_feed_ok!(d, [0x30, 0x81, 0x32], [], "\u{82}"); + assert_feed_ok!(d, [], [0x81], ""); + assert_feed_ok!(d, [], [0x30, 0x81], ""); + assert_feed_ok!(d, [0x33], [], "\u{83}"); + assert_feed_ok!(d, [], [0x81, 0x30], ""); + assert_feed_ok!(d, [], [0x81], ""); + assert_feed_ok!(d, [0x34], [], "\u{84}"); + assert_feed_ok!(d, [], [0x81, 0x30], ""); + assert_feed_ok!(d, [0x81, 0x35], [], "\u{85}"); + assert_feed_ok!(d, [], [0x81, 0x30, 0x81], ""); + assert_feed_ok!(d, [0x36], [], "\u{86}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_partial() { + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0xa1], ""); + assert_finish_err!(d, ""); + + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0x81], ""); + assert_finish_err!(d, ""); + + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0x81, 0x30], ""); + assert_finish_err!(d, ""); + + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0x81, 0x30, 0x81], ""); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_out_of_range() { + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_err!(d, [], [0xff], [], ""); + assert_feed_err!(d, [], [0x81], [0x00], ""); + assert_feed_err!(d, [], [0x81], [0x7f], ""); + assert_feed_err!(d, [], [0x81], [0xff], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0x00], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0x80], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0xff], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0x81, 0x00], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0x81, 0x2f], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0x81, 0x3a], ""); + assert_feed_err!(d, [], [0x81], [0x31, 0x81, 0xff], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_boundary() { + // U+10FFFF (E3 32 9A 35) is the last Unicode codepoint, E3 32 9A 36 is invalid. + // note that since the 2nd to 4th bytes may coincide with ASCII, bytes 32 9A 36 is + // not considered to be in the problem. this is compatible to WHATWG Encoding standard. + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0xe3], ""); + assert_feed_err!(d, [], [], [0x32, 0x9a, 0x36], ""); + assert_finish_ok!(d, ""); + + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [], [0xe3], ""); + assert_feed_ok!(d, [], [0x32, 0x9a], ""); + assert_feed_err!(d, -2, [], [], [0x32, 0x9a, 0x36], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [0xd2, 0xbb], [0xd2], "\u{4e00}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xd2, 0xbb], [], "\u{4e00}"); + assert_finish_ok!(d, ""); + + let mut d = GB18030_ENCODING.raw_decoder(); + assert_feed_ok!(d, [0x98, 0x35, 0xee, 0x37], [0x98, 0x35, 0xee], "\u{2a6a5}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0x98, 0x35, 0xee, 0x37], [0x98, 0x35], "\u{2a6a5}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0x98, 0x35, 0xee, 0x37], [0x98], "\u{2a6a5}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0x98, 0x35, 0xee, 0x37], [], "\u{2a6a5}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::SIMPLIFIED_CHINESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + GB18030_ENCODING.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = GB18030_ENCODING.encode(testutils::SIMPLIFIED_CHINESE_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + GB18030_ENCODING.decode(&s, DecoderTrap::Strict) + })) + } +} + +#[cfg(test)] +mod gbk_tests { + extern crate test; + use super::GBK_ENCODING; + use testutils; + use types::*; + + // GBK and GB 18030 share the same decoder logic. + + #[test] + fn test_encoder() { + let mut e = GBK_ENCODING.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{4e2d}\u{534e}\u{4eba}\u{6c11}\u{5171}\u{548c}\u{56fd}", "", + [0xd6, 0xd0, 0xbb, 0xaa, 0xc8, 0xcb, 0xc3, 0xf1, + 0xb9, 0xb2, 0xba, 0xcd, 0xb9, 0xfa]); + assert_feed_ok!(e, "1\u{20ac}/m", "", [0x31, 0x80, 0x2f, 0x6d]); + assert_feed_ok!(e, "\u{ff21}\u{ff22}\u{ff23}", "", [0xa3, 0xc1, 0xa3, 0xc2, 0xa3, 0xc3]); + assert_feed_err!(e, "", "\u{80}", "", []); + assert_feed_err!(e, "", "\u{81}", "", []); + assert_feed_err!(e, "", "\u{a3}", "", []); + assert_feed_ok!(e, "\u{a4}", "", [0xa1, 0xe8]); + assert_feed_err!(e, "", "\u{a5}", "", []); + assert_feed_err!(e, "", "\u{10ffff}", "", []); + assert_feed_err!(e, "", "\u{2a6a5}", "\u{3007}", []); + assert_feed_err!(e, "\u{3007}", "\u{2a6a5}", "", [0xa9, 0x96]); + assert_finish_ok!(e, []); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::SIMPLIFIED_CHINESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + GBK_ENCODING.encode(&s, EncoderTrap::Strict) + })) + } +} + +/** + * HZ. (RFC 1843) + * + * This is a simplified Chinese encoding based on GB 2312. + * It bears a resemblance to ISO 2022 encodings in such that the printable escape sequences `~{` + * and `~}` are used to delimit a sequence of 7-bit-safe GB 2312 sequences. For the comparison, + * they are equivalent to ISO-2022-CN escape sequences `ESC $ ) A` and `ESC ( B`. + * Additional escape sequences `~~` (for a literal `~`) and `~\n` (ignored) are also supported. + */ +#[derive(Clone, Copy)] +pub struct HZEncoding; + +impl Encoding for HZEncoding { + fn name(&self) -> &'static str { "hz" } + fn whatwg_name(&self) -> Option<&'static str> { None } + fn raw_encoder(&self) -> Box { HZEncoder::new() } + fn raw_decoder(&self) -> Box { HZDecoder::new() } +} + +/// An encoder for HZ. +#[derive(Clone, Copy)] +pub struct HZEncoder { + escaped: bool, +} + +impl HZEncoder { + pub fn new() -> Box { Box::new(HZEncoder { escaped: false }) } +} + +impl RawEncoder for HZEncoder { + fn from_self(&self) -> Box { HZEncoder::new() } + fn is_ascii_compatible(&self) -> bool { false } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + let mut escaped = self.escaped; + macro_rules! ensure_escaped( + () => (if !escaped { output.write_bytes(b"~{"); escaped = true; }) + ); + macro_rules! ensure_unescaped( + () => (if escaped { output.write_bytes(b"~}"); escaped = false; }) + ); + + for ((i,j), ch) in input.index_iter() { + if ch < '\u{80}' { + ensure_unescaped!(); + output.write_byte(ch as u8); + if ch == '~' { output.write_byte('~' as u8); } + } else { + let ptr = index::gb18030::backward(ch as u32); + if ptr == 0xffff { + self.escaped = escaped; // do NOT reset the state! + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } else { + let lead = ptr / 190; + let trail = ptr % 190; + if lead < 0x21 - 1 || trail < 0x21 + 0x3f { // GBK extension, ignored + self.escaped = escaped; // do NOT reset the state! + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } else { + ensure_escaped!(); + output.write_byte((lead + 1) as u8); + output.write_byte((trail - 0x3f) as u8); + } + } + } + } + + self.escaped = escaped; + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for HZ. +#[derive(Clone, Copy)] +struct HZDecoder { + st: hz::State, +} + +impl HZDecoder { + pub fn new() -> Box { + Box::new(HZDecoder { st: Default::default() }) + } +} + +impl RawDecoder for HZDecoder { + fn from_self(&self) -> Box { HZDecoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = hz::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = hz::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module hz; + + internal pub fn map_two_bytes(lead: u8, trail: u8) -> u32 { + use index_simpchinese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0x20...0x7f, 0x21...0x7e) => (lead - 1) * 190 + (trail + 0x3f), + _ => 0xffff, + }; + index::gb18030::forward(index) + } + +initial: + // hz-gb-2312 flag = unset, hz-gb-2312 lead = 0x00 + state A0(ctx: Context) { + case 0x7e => A1(ctx); + case b @ 0x00...0x7f => ctx.emit(b as u32); + case _ => ctx.err("invalid sequence"); + final => ctx.reset(); + } + +checkpoint: + // hz-gb-2312 flag = set, hz-gb-2312 lead = 0x00 + state B0(ctx: Context) { + case 0x7e => B1(ctx); + case b @ 0x20...0x7f => B2(ctx, b); + case 0x0a => ctx.err("invalid sequence"); // error *and* reset + case _ => ctx.err("invalid sequence"), B0(ctx); + final => ctx.reset(); + } + +transient: + // hz-gb-2312 flag = unset, hz-gb-2312 lead = 0x7e + state A1(ctx: Context) { + case 0x7b => B0(ctx); + case 0x7d => A0(ctx); + case 0x7e => ctx.emit(0x7e), A0(ctx); + case 0x0a => A0(ctx); + case _ => ctx.backup_and_err(1, "invalid sequence"); + final => ctx.err("incomplete sequence"); + } + + // hz-gb-2312 flag = set, hz-gb-2312 lead = 0x7e + state B1(ctx: Context) { + case 0x7b => B0(ctx); + case 0x7d => A0(ctx); + case 0x7e => ctx.emit(0x7e), B0(ctx); + case 0x0a => A0(ctx); + case _ => ctx.backup_and_err(1, "invalid sequence"), B0(ctx); + final => ctx.err("incomplete sequence"); + } + + // hz-gb-2312 flag = set, hz-gb-2312 lead != 0 & != 0x7e + state B2(ctx: Context, lead: u8) { + case 0x0a => ctx.err("invalid sequence"); // should reset the state! + case b => + match map_two_bytes(lead, b) { + 0xffff => ctx.err("invalid sequence"), + ch => ctx.emit(ch) + }, + B0(ctx); + final => ctx.err("incomplete sequence"); + } +} + +#[cfg(test)] +mod hz_tests { + extern crate test; + use super::HZEncoding; + use testutils; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = HZEncoding.raw_encoder(); + assert_feed_ok!(e, "A", "", *b"A"); + assert_feed_ok!(e, "BC", "", *b"BC"); + assert_feed_ok!(e, "", "", *b""); + assert_feed_ok!(e, "\u{4e2d}\u{534e}\u{4eba}\u{6c11}\u{5171}\u{548c}\u{56fd}", "", + *b"~{VP;*HKCq92:M9z"); + assert_feed_ok!(e, "\u{ff21}\u{ff22}\u{ff23}", "", *b"#A#B#C"); + assert_feed_ok!(e, "1\u{20ac}/m", "", *b"~}1~{\"c~}/m"); + assert_feed_ok!(e, "~<\u{a4}~\u{0a4}>~", "", *b"~~<~{!h~}~~~{!h~}>~~"); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_invalid() { + let mut e = HZEncoding.raw_encoder(); + assert_feed_err!(e, "", "\u{ffff}", "", []); + assert_feed_err!(e, "?", "\u{ffff}", "!", [0x3f]); + // no support for GBK extension + assert_feed_err!(e, "", "\u{3007}", "", []); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"A", *b"", "A"); + assert_feed_ok!(d, *b"BC", *b"", "BC"); + assert_feed_ok!(d, *b"D~~E", *b"~", "D~E"); + assert_feed_ok!(d, *b"~F~\nG", *b"~", "~FG"); + assert_feed_ok!(d, *b"", *b"", ""); + assert_feed_ok!(d, *b"\nH", *b"~", "H"); + assert_feed_ok!(d, *b"{VP~}~{;*~{HKCq92:M9z", *b"", + "\u{4e2d}\u{534e}\u{4eba}\u{6c11}\u{5171}\u{548c}\u{56fd}"); + assert_feed_ok!(d, *b"", *b"#", ""); + assert_feed_ok!(d, *b"A", *b"~", "\u{ff21}"); + assert_feed_ok!(d, *b"~#B~~#C", *b"~", "~\u{ff22}~\u{ff23}"); + assert_feed_ok!(d, *b"", *b"", ""); + assert_feed_ok!(d, *b"\n#D~{#E~\n#F~{#G", *b"~", "#D\u{ff25}#F\u{ff27}"); + assert_feed_ok!(d, *b"}X~}YZ", *b"", "XYZ"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_out_or_range() { + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"~{", *b"", ""); + assert_feed_err!(d, *b"", *b"\x20\x20", *b"", ""); + assert_feed_err!(d, *b"", *b"\x20\x7f", *b"", ""); // do not reset the state (except for CR) + assert_feed_err!(d, *b"", *b"\x21\x7f", *b"", ""); + assert_feed_err!(d, *b"", *b"\x7f\x20", *b"", ""); + assert_feed_err!(d, *b"", *b"\x7f\x21", *b"", ""); + assert_feed_err!(d, *b"", *b"\x7f\x7f", *b"", ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_carriage_return() { + // CR in the multibyte mode is invalid but *also* resets the state + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"~{#A", *b"", "\u{ff21}"); + assert_feed_err!(d, *b"", *b"\n", *b"", ""); + assert_feed_ok!(d, *b"#B~{#C", *b"", "#B\u{ff23}"); + assert_feed_err!(d, *b"", *b"#\n", *b"", ""); + assert_feed_ok!(d, *b"#D", *b"", "#D"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_partial() { + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"", *b"~", ""); + assert_finish_err!(d, ""); + + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"~{", *b"#", ""); + assert_finish_err!(d, ""); + + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"~{#A", *b"~", "\u{ff21}"); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_escape() { + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"#A", *b"", "#A"); + assert_feed_err!(d, *b"", *b"~", *b"xy", ""); + assert_feed_ok!(d, *b"#B", *b"", "#B"); + assert_feed_ok!(d, *b"", *b"~", ""); + assert_feed_err!(d, *b"", *b"", *b"xy", ""); + assert_feed_ok!(d, *b"#C~{#D", *b"", "#C\u{ff24}"); + assert_feed_err!(d, *b"", *b"~", *b"xy", ""); + assert_feed_ok!(d, *b"#E", *b"", "\u{ff25}"); // does not reset to ASCII + assert_feed_ok!(d, *b"", *b"~", ""); + assert_feed_err!(d, *b"", *b"", *b"xy", ""); + assert_feed_ok!(d, *b"#F~}#G", *b"", "\u{ff26}#G"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = HZEncoding.raw_decoder(); + assert_feed_ok!(d, *b"R;~{R;", *b"R", "R;\u{4e00}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, *b"R;~{R;", *b"", "R;\u{4e00}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::SIMPLIFIED_CHINESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + HZEncoding.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = HZEncoding.encode(testutils::SIMPLIFIED_CHINESE_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + HZEncoding.decode(&s, DecoderTrap::Strict) + })) + } +} + diff --git a/deps/encoding-0.2.32/src/codec/singlebyte.rs b/deps/encoding-0.2.32/src/codec/singlebyte.rs new file mode 100644 index 000000000..713eee1b4 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/singlebyte.rs @@ -0,0 +1,131 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Common codec implementation for single-byte encodings. + +use std::convert::Into; +use util::{as_char, StrCharIndex}; +use types::*; + +/// A common framework for single-byte encodings based on ASCII. +#[derive(Copy, Clone)] +pub struct SingleByteEncoding { + pub name: &'static str, + pub whatwg_name: Option<&'static str>, + pub index_forward: extern "Rust" fn(u8) -> u16, + pub index_backward: extern "Rust" fn(u32) -> u8, +} + +impl Encoding for SingleByteEncoding { + fn name(&self) -> &'static str { self.name } + fn whatwg_name(&self) -> Option<&'static str> { self.whatwg_name } + fn raw_encoder(&self) -> Box { SingleByteEncoder::new(self.index_backward) } + fn raw_decoder(&self) -> Box { SingleByteDecoder::new(self.index_forward) } +} + +/// An encoder for single-byte encodings based on ASCII. +#[derive(Clone, Copy)] +pub struct SingleByteEncoder { + index_backward: extern "Rust" fn(u32) -> u8, +} + +impl SingleByteEncoder { + pub fn new(index_backward: extern "Rust" fn(u32) -> u8) -> Box { + Box::new(SingleByteEncoder { index_backward: index_backward }) + } +} + +impl RawEncoder for SingleByteEncoder { + fn from_self(&self) -> Box { SingleByteEncoder::new(self.index_backward) } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + for ((i,j), ch) in input.index_iter() { + if ch <= '\u{7f}' { + output.write_byte(ch as u8); + continue; + } else { + let index = (self.index_backward)(ch as u32); + if index != 0 { + output.write_byte(index); + } else { + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for single-byte encodings based on ASCII. +#[derive(Clone, Copy)] +pub struct SingleByteDecoder { + index_forward: extern "Rust" fn(u8) -> u16, +} + +impl SingleByteDecoder { + pub fn new(index_forward: extern "Rust" fn(u8) -> u16) -> Box { + Box::new(SingleByteDecoder { index_forward: index_forward }) + } +} + +impl RawDecoder for SingleByteDecoder { + fn from_self(&self) -> Box { SingleByteDecoder::new(self.index_forward) } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + let mut i = 0; + let len = input.len(); + while i < len { + if input[i] <= 0x7f { + output.write_char(input[i] as char); + } else { + let ch = (self.index_forward)(input[i]); + if ch != 0xffff { + output.write_char(as_char(ch as u32)); + } else { + return (i, Some(CodecError { + upto: i as isize + 1, cause: "invalid sequence".into() + })); + } + } + i += 1; + } + (i, None) + } + + fn raw_finish(&mut self, _output: &mut StringWriter) -> Option { + None + } +} + +/// Algorithmic mapping for ISO 8859-1. +pub mod iso_8859_1 { + #[inline] pub fn forward(code: u8) -> u16 { code as u16 } + #[inline] pub fn backward(code: u32) -> u8 { if (code & !0x7f) == 0x80 {code as u8} else {0} } +} + +#[cfg(test)] +mod tests { + use all::ISO_8859_2; + use types::*; + + #[test] + fn test_encoder_non_bmp() { + let mut e = ISO_8859_2.raw_encoder(); + assert_feed_err!(e, "A", "\u{FFFF}", "B", [0x41]); + assert_feed_err!(e, "A", "\u{10000}", "B", [0x41]); + } +} + diff --git a/deps/encoding-0.2.32/src/codec/tradchinese.rs b/deps/encoding-0.2.32/src/codec/tradchinese.rs new file mode 100644 index 000000000..18a574517 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/tradchinese.rs @@ -0,0 +1,277 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Legacy traditional Chinese encodings. + +use std::convert::Into; +use std::default::Default; +use util::StrCharIndex; +use index_tradchinese as index; +use types::*; + +/** + * Big5-2003 with common extensions. (XXX with asymmetric HKSCS-2008 support) + * + * This is a traditional Chinese encoding spanning the region `[81-FE] [40-7E A1-FE]`. + * Originally a proprietary encoding by the consortium of five companies (hence the name), + * the Republic of China government standardized Big5-2003 in an appendix of CNS 11643 + * so that CNS 11643 plane 1 and plane 2 have + * an almost identical set of characters as Big5 (but with a different mapping). + * The Hong Kong government has an official extension to Big5 + * named Hong Kong Supplementary Character Set (HKSCS). + * + * This particular implementation of Big5 includes the widespread ETEN and HKSCS extensions, + * but excludes less common extensions such as Big5+, Big-5E and Unicode-at-on. + */ +#[derive(Clone, Copy)] +pub struct BigFive2003Encoding; + +impl Encoding for BigFive2003Encoding { + fn name(&self) -> &'static str { "big5-2003" } + fn whatwg_name(&self) -> Option<&'static str> { Some("big5") } // WHATWG compatibility + fn raw_encoder(&self) -> Box { BigFive2003Encoder::new() } + fn raw_decoder(&self) -> Box { BigFive2003HKSCS2008Decoder::new() } +} + +/// An encoder for Big5-2003. +#[derive(Clone, Copy)] +pub struct BigFive2003Encoder; + +impl BigFive2003Encoder { + pub fn new() -> Box { Box::new(BigFive2003Encoder) } +} + +impl RawEncoder for BigFive2003Encoder { + fn from_self(&self) -> Box { BigFive2003Encoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + for ((i,j), ch) in input.index_iter() { + if ch < '\u{80}' { + output.write_byte(ch as u8); + } else { + let ptr = index::big5::backward(ch as u32); + if ptr == 0xffff || ptr < (0xa1 - 0x81) * 157 { + // no HKSCS extension (XXX doesn't HKSCS include 0xFA40..0xFEFE?) + return (i, Some(CodecError { + upto: j as isize, cause: "unrepresentable character".into() + })); + } + let lead = ptr / 157 + 0x81; + let trail = ptr % 157; + let trailoffset = if trail < 0x3f {0x40} else {0x62}; + output.write_byte(lead as u8); + output.write_byte((trail + trailoffset) as u8); + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for Big5-2003 with HKSCS-2008 extension. +#[derive(Clone, Copy)] +struct BigFive2003HKSCS2008Decoder { + st: bigfive2003::State, +} + +impl BigFive2003HKSCS2008Decoder { + pub fn new() -> Box { + Box::new(BigFive2003HKSCS2008Decoder { st: Default::default() }) + } +} + +impl RawDecoder for BigFive2003HKSCS2008Decoder { + fn from_self(&self) -> Box { BigFive2003HKSCS2008Decoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + let (st, processed, err) = bigfive2003::raw_feed(self.st, input, output, &()); + self.st = st; + (processed, err) + } + + fn raw_finish(&mut self, output: &mut StringWriter) -> Option { + let (st, err) = bigfive2003::raw_finish(self.st, output, &()); + self.st = st; + err + } +} + +stateful_decoder! { + module bigfive2003; + + internal pub fn map_two_bytes(lead: u8, trail: u8) -> u32 { + use index_tradchinese as index; + + let lead = lead as u16; + let trail = trail as u16; + let index = match (lead, trail) { + (0x81...0xfe, 0x40...0x7e) | (0x81...0xfe, 0xa1...0xfe) => { + let trailoffset = if trail < 0x7f {0x40} else {0x62}; + (lead - 0x81) * 157 + trail - trailoffset + } + _ => 0xffff, + }; + index::big5::forward(index) // may return two-letter replacements 0..3 + } + +initial: + // big5 lead = 0x00 + state S0(ctx: Context) { + case b @ 0x00...0x7f => ctx.emit(b as u32); + case b @ 0x81...0xfe => S1(ctx, b); + case _ => ctx.err("invalid sequence"); + } + +transient: + // big5 lead != 0x00 + state S1(ctx: Context, lead: u8) { + case b => match map_two_bytes(lead, b) { + 0xffff => { + let backup = if b < 0x80 {1} else {0}; + ctx.backup_and_err(backup, "invalid sequence") + }, + 0 /*index=1133*/ => ctx.emit_str("\u{ca}\u{304}"), + 1 /*index=1135*/ => ctx.emit_str("\u{ca}\u{30c}"), + 2 /*index=1164*/ => ctx.emit_str("\u{ea}\u{304}"), + 3 /*index=1166*/ => ctx.emit_str("\u{ea}\u{30c}"), + ch => ctx.emit(ch), + }; + } +} + +#[cfg(test)] +mod bigfive2003_tests { + extern crate test; + use super::BigFive2003Encoding; + use testutils; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = BigFive2003Encoding.raw_encoder(); + assert_feed_ok!(e, "A", "", [0x41]); + assert_feed_ok!(e, "BC", "", [0x42, 0x43]); + assert_feed_ok!(e, "", "", []); + assert_feed_ok!(e, "\u{4e2d}\u{83ef}\u{6c11}\u{570b}", "", + [0xa4, 0xa4, 0xb5, 0xd8, 0xa5, 0xc1, 0xb0, 0xea]); + assert_feed_ok!(e, "1\u{20ac}/m", "", [0x31, 0xa3, 0xe1, 0x2f, 0x6d]); + assert_feed_ok!(e, "\u{ffed}", "", [0xf9, 0xfe]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_encoder_invalid() { + let mut e = BigFive2003Encoding.raw_encoder(); + assert_feed_err!(e, "", "\u{ffff}", "", []); + assert_feed_err!(e, "?", "\u{ffff}", "!", [0x3f]); + assert_feed_err!(e, "", "\u{3eec}", "\u{4e00}", []); // HKSCS-2008 addition + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0xa4, 0xa4, 0xb5, 0xd8, 0xa5, 0xc1, 0xb0, 0xea], [], + "\u{4e2d}\u{83ef}\u{6c11}\u{570b}"); + assert_feed_ok!(d, [], [0xa4], ""); + assert_feed_ok!(d, [0xa4, 0xb5, 0xd8], [0xa5], "\u{4e2d}\u{83ef}"); + assert_feed_ok!(d, [0xc1, 0xb0, 0xea], [], "\u{6c11}\u{570b}"); + assert_feed_ok!(d, [0x31, 0xa3, 0xe1, 0x2f, 0x6d], [], "1\u{20ac}/m"); + assert_feed_ok!(d, [0xf9, 0xfe], [], "\u{ffed}"); + assert_feed_ok!(d, [0x87, 0x7e], [], "\u{3eec}"); // HKSCS-2008 addition + assert_feed_ok!(d, [0x88, 0x62, 0x88, 0x64, 0x88, 0xa3, 0x88, 0xa5], [], + "\u{ca}\u{304}\u{00ca}\u{30c}\u{ea}\u{304}\u{ea}\u{30c}"); // 2-byte output + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_immediate_test_finish() { + for i in 0x81..0xff { + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); // wait for a trail + assert_finish_err!(d, ""); + } + + // 80/FF: immediate failure + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_err!(d, [], [0x80], [], ""); + assert_feed_err!(d, [], [0xff], [], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lead_followed_by_space() { + for i in 0x80..0x100 { + let i = i as u8; + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_err!(d, [], [i], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_decoder_invalid_lead_followed_by_invalid_trail() { + // unlike most other cases, valid lead + invalid MSB-set trail are entirely consumed. + // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16771 + for i in 0x81..0xff { + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_err!(d, [], [i, 0x80], [0x20], ""); + assert_feed_err!(d, [], [i, 0xff], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_ok!(d, [], [i], ""); + assert_feed_err!(d, [], [0x80], [0x20], ""); + assert_feed_ok!(d, [], [i], ""); + assert_feed_err!(d, [], [0xff], [0x20], ""); + assert_finish_ok!(d, ""); + } + + // 80/FF is not a valid lead and the trail is not consumed + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_err!(d, [], [0x80], [0x80], ""); + assert_feed_err!(d, [], [0x80], [0xff], ""); + assert_feed_err!(d, [], [0xff], [0x80], ""); + assert_feed_err!(d, [], [0xff], [0xff], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = BigFive2003Encoding.raw_decoder(); + assert_feed_ok!(d, [0xa4, 0x40], [0xa4], "\u{4e00}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xa4, 0x40], [], "\u{4e00}"); + assert_finish_ok!(d, ""); + } + + #[bench] + fn bench_encode_short_text(bencher: &mut test::Bencher) { + let s = testutils::TRADITIONAL_CHINESE_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + BigFive2003Encoding.encode(&s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode_short_text(bencher: &mut test::Bencher) { + let s = BigFive2003Encoding.encode(testutils::TRADITIONAL_CHINESE_TEXT, + EncoderTrap::Strict).ok().unwrap(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + BigFive2003Encoding.decode(&s, DecoderTrap::Strict) + })) + } +} diff --git a/deps/encoding-0.2.32/src/codec/utf_16.rs b/deps/encoding-0.2.32/src/codec/utf_16.rs new file mode 100644 index 000000000..82b7df081 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/utf_16.rs @@ -0,0 +1,593 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! UTF-16. + +use std::convert::Into; +use std::marker::PhantomData; +use util::as_char; +use types::*; + +/// An implementation type for little endian. +/// +/// Can be used as a type parameter to `UTF16Encoding`, `UTF16Encoder` and `UTF16Decoder`. +#[derive(Clone, Copy)] +pub struct Little; + +/// An implementation type for big endian. +/// +/// Can be used as a type parameter to `UTF16Encoding`, `UTF16Encoder` and `UTF16Decoder`. +#[derive(Clone, Copy)] +pub struct Big; + +/// An internal trait used to customize UTF-16 implementations. +trait Endian: Clone + 'static { + fn name() -> &'static str; + fn whatwg_name() -> Option<&'static str>; + fn write_two_bytes(output: &mut ByteWriter, msb: u8, lsb: u8); + fn concat_two_bytes(lead: u16, trail: u8) -> u16; +} + +impl Endian for Little { + fn name() -> &'static str { "utf-16le" } + fn whatwg_name() -> Option<&'static str> { Some("utf-16le") } + fn write_two_bytes(output: &mut ByteWriter, msb: u8, lsb: u8) { + output.write_byte(lsb); + output.write_byte(msb); + } + fn concat_two_bytes(lead: u16, trail: u8) -> u16 { + lead | ((trail as u16) << 8) + } +} + +impl Endian for Big { + fn name() -> &'static str { "utf-16be" } + fn whatwg_name() -> Option<&'static str> { Some("utf-16be") } + fn write_two_bytes(output: &mut ByteWriter, msb: u8, lsb: u8) { + output.write_byte(msb); + output.write_byte(lsb); + } + fn concat_two_bytes(lead: u16, trail: u8) -> u16 { + (lead << 8) | trail as u16 + } +} + +/** + * UTF-16 (UCS Transformation Format, 16-bit). + * + * This is a Unicode encoding where one codepoint may use + * 2 (up to U+FFFF) or 4 bytes (up to U+10FFFF) depending on its value. + * It uses a "surrogate" mechanism to encode non-BMP codepoints, + * which are represented as a pair of lower surrogate and upper surrogate characters. + * In this effect, surrogate characters (U+D800..DFFF) cannot appear alone + * and cannot be included in a valid Unicode string. + * + * ## Specialization + * + * This type is specialized with endianness type `E`, + * which should be either `Little` (little endian) or `Big` (big endian). + */ +#[derive(Clone, Copy)] +pub struct UTF16Encoding { + _marker: PhantomData +} + +/// A type for UTF-16 in little endian. +pub type UTF16LEEncoding = UTF16Encoding; +/// A type for UTF-16 in big endian. +pub type UTF16BEEncoding = UTF16Encoding; + +/// An instance for UTF-16 in little endian. +pub const UTF_16LE_ENCODING: UTF16LEEncoding = UTF16Encoding { _marker: PhantomData }; +/// An instance for UTF-16 in big endian. +pub const UTF_16BE_ENCODING: UTF16BEEncoding = UTF16Encoding { _marker: PhantomData }; + +impl Encoding for UTF16Encoding { + fn name(&self) -> &'static str { ::name() } + fn whatwg_name(&self) -> Option<&'static str> { ::whatwg_name() } + fn raw_encoder(&self) -> Box { UTF16Encoder::::new() } + fn raw_decoder(&self) -> Box { UTF16Decoder::::new() } +} + +/** + * An encoder for UTF-16. + * + * ## Specialization + * + * This type is specialized with endianness type `E`, + * which should be either `Little` (little endian) or `Big` (big endian). + */ +#[derive(Clone, Copy)] +pub struct UTF16Encoder { + _marker: PhantomData +} + +impl UTF16Encoder { + fn new() -> Box { + Box::new(UTF16Encoder:: { _marker: PhantomData }) + } +} + +impl RawEncoder for UTF16Encoder { + fn from_self(&self) -> Box { UTF16Encoder::::new() } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + output.writer_hint(input.len() * 2); + + let write_two_bytes = |output: &mut ByteWriter, msb: u8, lsb: u8| + ::write_two_bytes(output, msb, lsb); + + for ch in input.chars() { + match ch { + '\u{0}'...'\u{d7ff}' | '\u{e000}'...'\u{ffff}' => { + let ch = ch as u32; + write_two_bytes(output, (ch >> 8) as u8, (ch & 0xff) as u8); + } + '\u{10000}'...'\u{10ffff}' => { + let ch = ch as u32 - 0x10000; + write_two_bytes(output, (0xd8 | (ch >> 18)) as u8, + ((ch >> 10) & 0xff) as u8); + write_two_bytes(output, (0xdc | ((ch >> 8) & 0x3)) as u8, + (ch & 0xff) as u8); + } + _ => unreachable!() // XXX Rust issue #12483, this is redundant + } + } + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/** + * A decoder for UTF-16. + * + * ## Specialization + * + * This type is specialized with endianness type `E`, + * which should be either `Little` (little endian) or `Big` (big endian). + */ +pub struct UTF16Decoder { + leadbyte: u16, + leadsurrogate: u16, + _marker: PhantomData +} + +impl UTF16Decoder { + pub fn new() -> Box { + Box::new(UTF16Decoder:: { leadbyte: 0xffff, leadsurrogate: 0xffff, + _marker: PhantomData }) + } +} + +impl RawDecoder for UTF16Decoder { + fn from_self(&self) -> Box { UTF16Decoder::::new() } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + output.writer_hint(input.len() / 2); // when every codepoint is U+0000..007F + + let concat_two_bytes = |lead: u16, trail: u8| + ::concat_two_bytes(lead, trail); + + let mut i = 0; + let mut processed = 0; + let len = input.len(); + + if i >= len { return (processed, None); } + + if self.leadbyte != 0xffff { + let ch = concat_two_bytes(self.leadbyte, input[i]); + i += 1; + self.leadbyte = 0xffff; + if self.leadsurrogate != 0xffff { // `ch` is lower surrogate + let upper = self.leadsurrogate; + self.leadsurrogate = 0xffff; + match ch { + 0xdc00...0xdfff => { + let ch = ((upper as u32 - 0xd800) << 10) + (ch as u32 - 0xdc00); + output.write_char(as_char(ch + 0x10000)); + processed = i; + } + _ => { + return (processed, Some(CodecError { + upto: i as isize - 2, cause: "invalid sequence".into() + })); + } + } + } else { + match ch { + 0xd800...0xdbff => { + self.leadsurrogate = ch; + // pass through + } + 0xdc00...0xdfff => { + return (processed, Some(CodecError { + upto: i as isize, cause: "invalid sequence".into() + })); + } + _ => { + output.write_char(as_char(ch as u32)); + processed = i; + } + } + } + if i >= len { return (processed, None); } + } + + if self.leadsurrogate != 0xffff { + i += 1; + if i >= len { + self.leadbyte = input[i-1] as u16; + return (processed, None); + } + let upper = self.leadsurrogate; + let ch = concat_two_bytes(input[i-1] as u16, input[i]); + i += 1; + match ch { + 0xdc00...0xdfff => { + let ch = ((upper as u32 - 0xd800) << 10) + (ch as u32 - 0xdc00); + output.write_char(as_char(ch + 0x10000)); + } + _ => { + self.leadbyte = 0xffff; + self.leadsurrogate = 0xffff; + return (processed, Some(CodecError { + upto: i as isize - 2, cause: "invalid sequence".into() + })); + } + } + } + + self.leadbyte = 0xffff; + self.leadsurrogate = 0xffff; + processed = i; + while i < len { + i += 1; + if i >= len { + self.leadbyte = input[i-1] as u16; + break; + } + let ch = concat_two_bytes(input[i-1] as u16, input[i]); + match ch { + 0xd800...0xdbff => { + i += 2; + if i >= len { + self.leadsurrogate = ch; + if i-1 < len { self.leadbyte = input[i-1] as u16; } + break; + } + let ch2 = concat_two_bytes(input[i-1] as u16, input[i]); + match ch2 { + 0xdc00...0xdfff => { + let ch = ((ch as u32 - 0xd800) << 10) + (ch2 as u32 - 0xdc00); + output.write_char(as_char(ch + 0x10000)); + } + _ => { + return (processed, Some(CodecError { + upto: i as isize - 1, cause: "invalid sequence".into() + })); + } + } + } + 0xdc00...0xdfff => { + return (processed, Some(CodecError { + upto: i as isize + 1, cause: "invalid sequence".into() + })); + } + _ => { + output.write_char(as_char(ch as u32)); + } + } + i += 1; + processed = i; + } + (processed, None) + } + + fn raw_finish(&mut self, _output: &mut StringWriter) -> Option { + let leadbyte = self.leadbyte; + let leadsurrogate = self.leadsurrogate; + self.leadbyte = 0xffff; + self.leadsurrogate = 0xffff; + if leadbyte != 0xffff || leadsurrogate != 0xffff { + Some(CodecError { upto: 0, cause: "incomplete sequence".into() }) + } else { + None + } + } +} + +#[cfg(test)] +mod tests { + // little endian and big endian is symmetric to each other, there's no need to test both. + // since big endian is easier to inspect we test UTF_16BE only. + + use super::UTF_16BE_ENCODING as UTF_16BE; + use types::*; + + #[test] + fn test_encoder_valid() { + let mut e = UTF_16BE.raw_encoder(); + assert_feed_ok!(e, "\u{0}\ + \u{1}\u{02}\u{004}\u{0008}\ + \u{10}\u{020}\u{0040}\u{80}\ + \u{100}\u{0200}\u{400}\u{800}\ + \u{1000}\u{2000}\u{4000}\u{8000}\ + \u{ffff}", "", + [0x00, 0x00, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, + 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, + 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, + 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00, + 0xff, 0xff]); + assert_feed_ok!(e, "\u{10000}\ + \u{10001}\u{010002}\ + \u{10004}\u{010008}\ + \u{10010}\u{010020}\ + \u{10040}\u{010080}\ + \u{10100}\u{010200}\ + \u{10400}\u{010800}\ + \u{11000}\u{012000}\ + \u{14000}\u{018000}\ + \u{20000}\u{030000}\ + \u{50000}\u{090000}\ + \u{10FFFF}", "", + [0xd8, 0x00, 0xdc, 0x00, + 0xd8, 0x00, 0xdc, 0x01, 0xd8, 0x00, 0xdc, 0x02, + 0xd8, 0x00, 0xdc, 0x04, 0xd8, 0x00, 0xdc, 0x08, + 0xd8, 0x00, 0xdc, 0x10, 0xd8, 0x00, 0xdc, 0x20, + 0xd8, 0x00, 0xdc, 0x40, 0xd8, 0x00, 0xdc, 0x80, + 0xd8, 0x00, 0xdd, 0x00, 0xd8, 0x00, 0xde, 0x00, + 0xd8, 0x01, 0xdc, 0x00, 0xd8, 0x02, 0xdc, 0x00, + 0xd8, 0x04, 0xdc, 0x00, 0xd8, 0x08, 0xdc, 0x00, + 0xd8, 0x10, 0xdc, 0x00, 0xd8, 0x20, 0xdc, 0x00, + 0xd8, 0x40, 0xdc, 0x00, 0xd8, 0x80, 0xdc, 0x00, + 0xd9, 0x00, 0xdc, 0x00, 0xda, 0x00, 0xdc, 0x00, + 0xdb, 0xff, 0xdf, 0xff]); + assert_finish_ok!(e, []); + } + + #[test] + fn test_decoder_valid() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0x00, 0x00, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, + 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, + 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, + 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00, + 0xff, 0xff], [], + "\u{0}\ + \u{1}\u{02}\u{004}\u{0008}\ + \u{10}\u{020}\u{0040}\u{80}\ + \u{100}\u{0200}\u{400}\u{800}\ + \u{1000}\u{2000}\u{4000}\u{8000}\ + \u{ffff}"); + assert_feed_ok!(d, [0xd8, 0x00, 0xdc, 0x00, + 0xd8, 0x00, 0xdc, 0x01, 0xd8, 0x00, 0xdc, 0x02, + 0xd8, 0x00, 0xdc, 0x04, 0xd8, 0x00, 0xdc, 0x08, + 0xd8, 0x00, 0xdc, 0x10, 0xd8, 0x00, 0xdc, 0x20, + 0xd8, 0x00, 0xdc, 0x40, 0xd8, 0x00, 0xdc, 0x80, + 0xd8, 0x00, 0xdd, 0x00, 0xd8, 0x00, 0xde, 0x00, + 0xd8, 0x01, 0xdc, 0x00, 0xd8, 0x02, 0xdc, 0x00, + 0xd8, 0x04, 0xdc, 0x00, 0xd8, 0x08, 0xdc, 0x00, + 0xd8, 0x10, 0xdc, 0x00, 0xd8, 0x20, 0xdc, 0x00, + 0xd8, 0x40, 0xdc, 0x00, 0xd8, 0x80, 0xdc, 0x00, + 0xd9, 0x00, 0xdc, 0x00, 0xda, 0x00, 0xdc, 0x00, + 0xdb, 0xff, 0xdf, 0xff], [], + "\u{10000}\ + \u{10001}\u{010002}\ + \u{10004}\u{010008}\ + \u{10010}\u{010020}\ + \u{10040}\u{010080}\ + \u{10100}\u{010200}\ + \u{10400}\u{010800}\ + \u{11000}\u{012000}\ + \u{14000}\u{018000}\ + \u{20000}\u{030000}\ + \u{50000}\u{090000}\ + \u{10FFFF}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_valid_partial_bmp() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0x12], ""); + assert_feed_ok!(d, [0x34], [], "\u{1234}"); + assert_feed_ok!(d, [], [0x56], ""); + assert_feed_ok!(d, [0x78], [], "\u{5678}"); + assert_finish_ok!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0x12], ""); + assert_feed_ok!(d, [0x34], [0x56], "\u{1234}"); + assert_feed_ok!(d, [0x78, 0xab, 0xcd], [], "\u{5678}\u{abcd}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_valid_partial_non_bmp() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8], ""); + assert_feed_ok!(d, [], [0x08], ""); + assert_feed_ok!(d, [], [0xdf], ""); + assert_feed_ok!(d, [0x45], [0xd9], "\u{12345}"); + assert_feed_ok!(d, [], [0x5e], ""); + assert_feed_ok!(d, [], [0xdc], ""); + assert_feed_ok!(d, [0x90], [], "\u{67890}"); + assert_finish_ok!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8], ""); + assert_feed_ok!(d, [], [0x08, 0xdf], ""); + assert_feed_ok!(d, [0x45], [0xd9, 0x5e], "\u{12345}"); + assert_feed_ok!(d, [0xdc, 0x90], [], "\u{67890}"); + assert_finish_ok!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8, 0x08, 0xdf], ""); + assert_feed_ok!(d, [0x45], [0xd9, 0x5e, 0xdc], "\u{12345}"); + assert_feed_ok!(d, [0x90], [], "\u{67890}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_partial() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0x12], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8, 0x08], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8, 0x08, 0xdf], ""); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_upper_surrogate() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8, 0x00], ""); + assert_feed_err!(d, [], [], [0x12, 0x34], ""); + assert_feed_err!(d, [], [0xd8, 0x00], [0x56, 0x78], ""); + assert_feed_ok!(d, [], [0xd8, 0x00], ""); + assert_feed_err!(d, [], [], [0xd8, 0x00], ""); + assert_feed_ok!(d, [], [0xd8, 0x00], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xdb, 0xff], ""); + assert_feed_err!(d, [], [], [0x12, 0x34], ""); + assert_feed_err!(d, [], [0xdb, 0xff], [0x56, 0x78], ""); + assert_feed_ok!(d, [], [0xdb, 0xff], ""); + assert_feed_err!(d, [], [], [0xdb, 0xff], ""); + assert_feed_ok!(d, [], [0xdb, 0xff], ""); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_upper_surrogate_partial() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8], ""); + assert_feed_err!(d, [], [0x00], [0x12, 0x34], ""); + assert_feed_ok!(d, [], [0xd8, 0x00, 0x56], ""); + assert_feed_err!(d, -1, [], [], [0x56, 0x78], ""); + assert_feed_ok!(d, [], [0xd8], ""); + assert_feed_err!(d, [], [0x00], [0xd8, 0x00], ""); + assert_feed_ok!(d, [], [0xd8, 0x00, 0xdb], ""); + assert_feed_err!(d, -1, [], [], [0xdb, 0xff], ""); + assert_feed_ok!(d, [], [0xd8], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xdb], ""); + assert_feed_err!(d, [], [0xff], [0x12, 0x34], ""); + assert_feed_ok!(d, [], [0xdb, 0xff, 0x56], ""); + assert_feed_err!(d, -1, [], [], [0x56, 0x78], ""); + assert_feed_ok!(d, [], [0xdb], ""); + assert_feed_err!(d, [], [0xff], [0xdb, 0xff], ""); + assert_feed_ok!(d, [], [0xdb, 0xff, 0xd8], ""); + assert_feed_err!(d, -1, [], [], [0xd8, 0x00], ""); + assert_feed_ok!(d, [], [0xdb], ""); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lower_surrogate() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_err!(d, [], [0xdc, 0x00], [], ""); + assert_feed_err!(d, [0x12, 0x34], [0xdc, 0x00], [0x56, 0x78], "\u{1234}"); + assert_finish_ok!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_err!(d, [], [0xdf, 0xff], [], ""); + assert_feed_err!(d, [0x12, 0x34], [0xdf, 0xff], [0x56, 0x78], "\u{1234}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_lone_lower_surrogate_partial() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xdc], ""); + assert_feed_err!(d, [], [0x00], [], ""); + assert_feed_ok!(d, [0x12, 0x34], [0xdc], "\u{1234}"); + assert_feed_err!(d, [], [0x00], [0x56, 0x78], ""); + assert_finish_ok!(d, ""); + + assert_feed_ok!(d, [], [0xdf], ""); + assert_feed_err!(d, [], [0xff], [], ""); + assert_feed_ok!(d, [0x12, 0x34], [0xdf], "\u{1234}"); + assert_feed_err!(d, [], [0xff], [0x56, 0x78], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_decoder_invalid_one_byte_before_finish() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0x12], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0x12, 0x34], [0x56], "\u{1234}"); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_three_bytes_before_finish() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8, 0x00, 0xdc], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0x12, 0x34], [0xd8, 0x00, 0xdc], "\u{1234}"); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_invalid_three_bytes_before_finish_partial() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [], [0xd8], ""); + assert_feed_ok!(d, [], [0x00], ""); + assert_feed_ok!(d, [], [0xdc], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0x12, 0x34], [0xd8], "\u{1234}"); + assert_feed_ok!(d, [], [0x00, 0xdc], ""); + assert_finish_err!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0x12, 0x34], [0xd8, 0x00], "\u{1234}"); + assert_feed_ok!(d, [], [0xdc], ""); + assert_finish_err!(d, ""); + } + + #[test] + fn test_decoder_feed_after_finish() { + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0x12, 0x34], [0x12], "\u{1234}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0x12, 0x34], [], "\u{1234}"); + assert_finish_ok!(d, ""); + + let mut d = UTF_16BE.raw_decoder(); + assert_feed_ok!(d, [0xd8, 0x08, 0xdf, 0x45], [0xd8, 0x08, 0xdf], "\u{12345}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xd8, 0x08, 0xdf, 0x45], [0xd8, 0x08], "\u{12345}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xd8, 0x08, 0xdf, 0x45], [0xd8], "\u{12345}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xd8, 0x08, 0xdf, 0x45], [], "\u{12345}"); + assert_finish_ok!(d, ""); + } +} + diff --git a/deps/encoding-0.2.32/src/codec/utf_8.rs b/deps/encoding-0.2.32/src/codec/utf_8.rs new file mode 100644 index 000000000..5b3079880 --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/utf_8.rs @@ -0,0 +1,828 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. +// +// Portions Copyright (c) 2008-2009 Bjoern Hoehrmann +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +//! UTF-8, the universal encoding. + +use std::{str, mem}; +use std::convert::Into; +use types::*; + +/** + * UTF-8 (UCS Transformation Format, 8-bit). + * + * This is a Unicode encoding compatible to ASCII (ISO/IEC 646:US) + * and able to represent all Unicode codepoints uniquely and unambiguously. + * It has a variable-length design, + * where one codepoint may use 1 (up to U+007F), 2 (up to U+07FF), 3 (up to U+FFFF) + * and 4 bytes (up to U+10FFFF) depending on its value. + * The first byte of the sequence is distinct from other "continuation" bytes of the sequence + * making UTF-8 self-synchronizable and easy to handle. + * It has a fixed endianness, and can be lexicographically sorted by codepoints. + * + * The UTF-8 scanner used by this module is heavily based on Bjoern Hoehrmann's + * [Flexible and Economical UTF-8 Decoder](http://bjoern.hoehrmann.de/utf-8/decoder/dfa/). + */ +#[derive(Clone, Copy)] +pub struct UTF8Encoding; + +impl Encoding for UTF8Encoding { + fn name(&self) -> &'static str { "utf-8" } + fn whatwg_name(&self) -> Option<&'static str> { Some("utf-8") } + fn raw_encoder(&self) -> Box { UTF8Encoder::new() } + fn raw_decoder(&self) -> Box { UTF8Decoder::new() } +} + +/// An encoder for UTF-8. +#[derive(Clone, Copy)] +pub struct UTF8Encoder; + +impl UTF8Encoder { + pub fn new() -> Box { Box::new(UTF8Encoder) } +} + +impl RawEncoder for UTF8Encoder { + fn from_self(&self) -> Box { UTF8Encoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option) { + let input: &[u8] = input.as_bytes(); + assert!(str::from_utf8(input).is_ok()); + output.write_bytes(input); + (input.len(), None) + } + + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { + None + } +} + +/// A decoder for UTF-8. +#[derive(Clone, Copy)] +pub struct UTF8Decoder { + queuelen: usize, + queue: [u8; 4], + state: u8, +} + +impl UTF8Decoder { + pub fn new() -> Box { + Box::new(UTF8Decoder { queuelen: 0, queue: [0; 4], state: INITIAL_STATE }) + } +} + +static CHAR_CATEGORY: [u8; 256] = [ + // 0 (00-7F): one byte sequence + // 1 (80-8F): continuation byte + // 2 (C2-DF): start of two byte sequence + // 3 (E1-EC,EE-EF): start of three byte sequence, next byte unrestricted + // 4 (ED): start of three byte sequence, next byte restricted to non-surrogates (80-9F) + // 5 (F4): start of four byte sequence, next byte restricted to 0+10FFFF (80-8F) + // 6 (F1-F3): start of four byte sequence, next byte unrestricted + // 7 (A0-BF): continuation byte + // 8 (C0-C1,F5-FF): invalid (overlong or out-of-range) start of multi byte sequences + // 9 (90-9F): continuation byte + // 10 (E0): start of three byte sequence, next byte restricted to non-overlong (A0-BF) + // 11 (F0): start of four byte sequence, next byte restricted to non-overlong (90-BF) + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, +]; + +static STATE_TRANSITIONS: [u8; 110] = [ + 0,98,12,24,48,84,72,98,98,98,36,60, // 0: '?? + 86, 0,86,86,86,86,86, 0,86, 0,86,86, // 12: .. 'cc + 86,12,86,86,86,86,86,12,86,12,86,86, // 24: .. 'cc cc + 86,86,86,86,86,86,86,12,86,86,86,86, // 36: .. 'cc(A0-BF) cc + 86,12,86,86,86,86,86,86,86,12,86,86, // 48: .. 'cc(80-9F) cc + 86,86,86,86,86,86,86,24,86,24,86,86, // 60: .. 'cc(90-BF) cc cc + 86,24,86,86,86,86,86,24,86,24,86,86, // 72: .. 'cc cc cc + 86,24,86,86,86,86,86,86,86,86,86,86,86,86, // 84: .. 'cc(80-8F) cc cc + // 86,86,86,86,86,86,86,86,86,86,86,86, // 86: .. xx '.. + 98,98,98,98,98,98,98,98,98,98,98,98, // 98: xx '.. +]; + +static INITIAL_STATE: u8 = 0; +static ACCEPT_STATE: u8 = 0; +static REJECT_STATE: u8 = 98; +static REJECT_STATE_WITH_BACKUP: u8 = 86; + +macro_rules! is_reject_state(($state:expr) => ($state >= REJECT_STATE_WITH_BACKUP)); +macro_rules! next_state(($state:expr, $ch:expr) => ( + STATE_TRANSITIONS[($state + CHAR_CATEGORY[$ch as usize]) as usize] +)); + +impl RawDecoder for UTF8Decoder { + fn from_self(&self) -> Box { UTF8Decoder::new() } + fn is_ascii_compatible(&self) -> bool { true } + + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option) { + output.writer_hint(input.len()); + + fn write_bytes(output: &mut StringWriter, bytes: &[u8]) { + output.write_str(unsafe {mem::transmute(bytes)}); + } + + let mut state = self.state; + let mut processed = 0; + let mut offset = 0; + + // optimization: if we are in the initial state, quickly skip to the first non-MSB-set byte. + if state == INITIAL_STATE { + let first_msb = input.iter().position(|&ch| ch >= 0x80).unwrap_or(input.len()); + offset += first_msb; + processed += first_msb; + } + + for (i, &ch) in input[offset..].iter().enumerate() { + state = next_state!(state, ch); + if state == ACCEPT_STATE { + processed = i + offset + 1; + } else if is_reject_state!(state) { + let upto = if state == REJECT_STATE {i + offset + 1} else {i + offset}; + self.state = INITIAL_STATE; + if processed > 0 && self.queuelen > 0 { // flush `queue` outside the problem + write_bytes(output, &self.queue[0..self.queuelen]); + } + self.queuelen = 0; + write_bytes(output, &input[0..processed]); + return (processed, Some(CodecError { + upto: upto as isize, cause: "invalid sequence".into() + })); + } + } + + self.state = state; + if processed > 0 && self.queuelen > 0 { // flush `queue` + write_bytes(output, &self.queue[0..self.queuelen]); + self.queuelen = 0; + } + write_bytes(output, &input[0..processed]); + if processed < input.len() { + let morequeuelen = input.len() - processed; + for i in 0..morequeuelen { + self.queue[self.queuelen + i] = input[processed + i]; + } + self.queuelen += morequeuelen; + } + (processed, None) + } + + fn raw_finish(&mut self, _output: &mut StringWriter) -> Option { + let state = self.state; + let queuelen = self.queuelen; + self.state = INITIAL_STATE; + self.queuelen = 0; + if state != ACCEPT_STATE { + Some(CodecError { upto: 0, cause: "incomplete sequence".into() }) + } else { + assert!(queuelen == 0); + None + } + } +} + +/// Almost equivalent to `std::str::from_utf8`. +/// This function is provided for the fair benchmark against the stdlib's UTF-8 conversion +/// functions, as rust-encoding always allocates a new string. +pub fn from_utf8<'a>(input: &'a [u8]) -> Option<&'a str> { + let mut iter = input.iter(); + let mut state; + + macro_rules! return_as_whole(() => (return Some(unsafe {mem::transmute(input)}))); + + // optimization: if we are in the initial state, quickly skip to the first non-MSB-set byte. + loop { + match iter.next() { + Some(&ch) if ch < 0x80 => {} + Some(&ch) => { + state = next_state!(INITIAL_STATE, ch); + break; + } + None => { return_as_whole!(); } + } + } + + for &ch in iter { + state = next_state!(state, ch); + if is_reject_state!(state) { return None; } + } + if state != ACCEPT_STATE { return None; } + return_as_whole!(); +} + +#[cfg(test)] +mod tests { + // portions of these tests are adopted from Markus Kuhn's UTF-8 decoder capability and + // stress test: . + + use super::{UTF8Encoding, from_utf8}; + use std::str; + use testutils; + use types::*; + + #[test] + fn test_valid() { + // one byte + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0x41], [], "A"); + assert_feed_ok!(d, [0x42, 0x43], [], "BC"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0x44, 0x45, 0x46], [], "DEF"); + assert_finish_ok!(d, ""); + + // two bytes + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xc2, 0xa2], [], "\u{a2}"); + assert_feed_ok!(d, [0xc2, 0xac, 0xc2, 0xa9], [], "\u{ac}\u{0a9}"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0xd5, 0xa1, 0xd5, 0xb5, 0xd5, 0xa2, 0xd5, 0xb8, 0xd6, 0x82, + 0xd5, 0xa2, 0xd5, 0xa5, 0xd5, 0xb6], [], + "\u{561}\u{0575}\u{562}\u{578}\u{582}\u{562}\u{565}\u{576}"); + assert_finish_ok!(d, ""); + + // three bytes + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xed, 0x92, 0x89], [], "\u{d489}"); + assert_feed_ok!(d, [0xe6, 0xbc, 0xa2, 0xe5, 0xad, 0x97], [], "\u{6f22}\u{5b57}"); + assert_feed_ok!(d, [], [], ""); + assert_feed_ok!(d, [0xc9, 0x99, 0xc9, 0x94, 0xc9, 0x90], [], "\u{259}\u{0254}\u{250}"); + assert_finish_ok!(d, ""); + + // four bytes + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xf0, 0x90, 0x82, 0x82], [], "\u{10082}"); + assert_feed_ok!(d, [], [], ""); + assert_finish_ok!(d, ""); + + // we don't test encoders as it is largely a no-op. + } + + #[test] + fn test_valid_boundary() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0x00], [], "\x00"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0x7f], [], "\x7f"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xc2, 0x80], [], "\u{80}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xdf, 0xbf], [], "\u{7ff}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xe0, 0xa0, 0x80], [], "\u{800}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xed, 0x9f, 0xbf], [], "\u{d7ff}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xee, 0x80, 0x80], [], "\u{e000}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xef, 0xbf, 0xbf], [], "\u{ffff}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xf0, 0x90, 0x80, 0x80], [], "\u{10000}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xf4, 0x8f, 0xbf, 0xbf], [], "\u{10ffff}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_valid_partial() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xf0], ""); + assert_feed_ok!(d, [], [0x90], ""); + assert_feed_ok!(d, [], [0x82], ""); + assert_feed_ok!(d, [0x82], [0xed], "\u{10082}"); + assert_feed_ok!(d, [0x92, 0x89], [], "\u{d489}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xc2], ""); + assert_feed_ok!(d, [0xa9, 0x20], [], "\u{a9}\u{020}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_invalid_continuation() { + for c in 0x80..0xc0 { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [c], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [c, c], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_invalid_surrogate() { + // surrogates should fail at the second byte. + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xa0, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xad, 0xbf], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xae, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xaf, 0xbf], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xb0, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xbe, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xed], [0xbf, 0xbf], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_invalid_boundary() { + // as with surrogates, should fail at the second byte. + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xf4], [0x90, 0x90, 0x90], ""); // U+110000 + assert_finish_ok!(d, ""); + } + + #[test] + fn test_invalid_start_immediate_test_finish() { + for c in 0xf5..0x100 { + let c = c as u8; + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_invalid_start_followed_by_space() { + for c in 0xf5..0x100 { + let c = c as u8; + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [], ""); + assert_feed_ok!(d, [0x20], [], "\x20"); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_invalid_lone_start_immediate_test_finish() { + for c in 0xc2..0xf5 { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [c], ""); // wait for cont. bytes + assert_finish_err!(d, ""); + } + } + + #[test] + fn test_invalid_lone_start_followed_by_space() { + for c in 0xc2..0xf5 { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [c], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [c], ""); // wait for cont. bytes + assert_feed_err!(d, [], [], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_invalid_incomplete_three_byte_seq_followed_by_space() { + for b in 0xe0..0xf5 { + let c = if b == 0xe0 || b == 0xf0 {0xa0} else {0x80}; + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [b, c], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [b, c], ""); // wait for cont. bytes + assert_feed_err!(d, [], [], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [b], ""); // wait for cont. bytes + assert_feed_err!(d, [], [c], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [b], ""); // wait for cont. bytes + assert_feed_ok!(d, [], [c], ""); // wait for cont. bytes + assert_feed_err!(d, [], [], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_invalid_incomplete_four_byte_seq_followed_by_space() { + for a in 0xf0..0xf5 { + let b = if a == 0xf0 {0xa0} else {0x80}; + let c = 0x80; + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [a, b, c], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [a], ""); // wait for cont. bytes + assert_feed_ok!(d, [], [b], ""); // wait for cont. bytes + assert_feed_ok!(d, [], [c], ""); // wait for cont. bytes + assert_feed_err!(d, [], [], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [a, b], ""); // wait for cont. bytes + assert_feed_err!(d, [], [c], [0x20], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [a, b, c], ""); // wait for cont. bytes + assert_feed_err!(d, [], [], [0x20], ""); + assert_finish_ok!(d, ""); + } + } + + #[test] + fn test_invalid_too_many_cont_bytes() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [0xc2, 0x80], [0x80], [], "\u{80}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [0xe0, 0xa0, 0x80], [0x80], [], "\u{800}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [0xf0, 0x90, 0x80, 0x80], [0x80], [], "\u{10000}"); + assert_finish_ok!(d, ""); + + // no continuation byte is consumed after 5/6-byte sequence starters and FE/FF + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xf8], [0x88, 0x80, 0x80, 0x80, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xfc], [0x84, 0x80, 0x80, 0x80, 0x80, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xfe], [0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xff], [0x80], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_invalid_too_many_cont_bytes_partial() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xc2], ""); + assert_feed_err!(d, [0x80], [0x80], [], "\u{80}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xe0, 0xa0], ""); + assert_feed_err!(d, [0x80], [0x80], [], "\u{800}"); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [], [0xf0, 0x90, 0x80], ""); + assert_feed_err!(d, [0x80], [0x80], [], "\u{10000}"); + assert_finish_ok!(d, ""); + + // no continuation byte is consumed after 5/6-byte sequence starters and FE/FF + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xf8], [], ""); + assert_feed_err!(d, [], [0x88], [0x80, 0x80, 0x80, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xfc], [], ""); + assert_feed_err!(d, [], [0x84], [0x80, 0x80, 0x80, 0x80, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xfe], [], ""); + assert_feed_err!(d, [], [0x80], [], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xff], [], ""); + assert_feed_err!(d, [], [0x80], [], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_invalid_overlong_minimal() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xc0], [0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xe0], [0x80, 0x80], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xf0], [0x80, 0x80, 0x80], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_invalid_overlong_maximal() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xc1], [0xbf], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xe0], [0x9f, 0xbf], ""); + assert_finish_ok!(d, ""); + + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_err!(d, [], [0xf0], [0x8f, 0xbf, 0xbf], ""); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_feed_after_finish() { + let mut d = UTF8Encoding.raw_decoder(); + assert_feed_ok!(d, [0xc2, 0x80], [0xc2], "\u{80}"); + assert_finish_err!(d, ""); + assert_feed_ok!(d, [0xc2, 0x80], [], "\u{80}"); + assert_finish_ok!(d, ""); + } + + #[test] + fn test_correct_from_utf8() { + let s = testutils::ASCII_TEXT.as_bytes(); + assert_eq!(from_utf8(s), str::from_utf8(s).ok()); + + let s = testutils::KOREAN_TEXT.as_bytes(); + assert_eq!(from_utf8(s), str::from_utf8(s).ok()); + + let s = testutils::INVALID_UTF8_TEXT; + assert_eq!(from_utf8(s), str::from_utf8(s).ok()); + } + + mod bench_ascii { + extern crate test; + use super::super::{UTF8Encoding, from_utf8}; + use std::str; + use testutils; + use types::*; + + #[bench] + fn bench_encode(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + UTF8Encoding.encode(s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + UTF8Encoding.decode(s, DecoderTrap::Strict) + })) + } + + #[bench] + fn bench_from_utf8(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + from_utf8(s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + str::from_utf8(s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8_lossy(bencher: &mut test::Bencher) { + let s = testutils::ASCII_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + String::from_utf8_lossy(s) + })) + } + } + + // why Korean? it has an excellent mix of multibyte sequences and ASCII sequences + // unlike other CJK scripts, so it reflects a practical use case a bit better. + mod bench_korean { + extern crate test; + use super::super::{UTF8Encoding, from_utf8}; + use std::str; + use testutils; + use types::*; + + #[bench] + fn bench_encode(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + UTF8Encoding.encode(s, EncoderTrap::Strict) + })) + } + + #[bench] + fn bench_decode(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + UTF8Encoding.decode(s, DecoderTrap::Strict) + })) + } + + #[bench] + fn bench_from_utf8(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + from_utf8(s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + str::from_utf8(s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8_lossy(bencher: &mut test::Bencher) { + let s = testutils::KOREAN_TEXT.as_bytes(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + String::from_utf8_lossy(s) + })) + } + } + + mod bench_lossy_invalid { + extern crate test; + use super::super::{UTF8Encoding, from_utf8}; + use std::str; + use testutils; + use types::*; + use types::DecoderTrap::Replace as DecodeReplace; + + #[bench] + fn bench_decode_replace(bencher: &mut test::Bencher) { + let s = testutils::INVALID_UTF8_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + UTF8Encoding.decode(s, DecodeReplace) + })) + } + + #[bench] // for the comparison + fn bench_from_utf8_failing(bencher: &mut test::Bencher) { + let s = testutils::INVALID_UTF8_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + from_utf8(s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8_failing(bencher: &mut test::Bencher) { + let s = testutils::INVALID_UTF8_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + str::from_utf8(s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8_lossy(bencher: &mut test::Bencher) { + let s = testutils::INVALID_UTF8_TEXT; + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + String::from_utf8_lossy(s) + })) + } + } + + mod bench_lossy_external { + extern crate test; + use super::super::{UTF8Encoding, from_utf8}; + use std::str; + use testutils; + use types::*; + use types::DecoderTrap::Replace as DecodeReplace; + + #[bench] + fn bench_decode_replace(bencher: &mut test::Bencher) { + let s = testutils::get_external_bench_data(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + UTF8Encoding.decode(&s, DecodeReplace) + })) + } + + #[bench] // for the comparison + fn bench_from_utf8_failing(bencher: &mut test::Bencher) { + let s = testutils::get_external_bench_data(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + from_utf8(&s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8_failing(bencher: &mut test::Bencher) { + let s = testutils::get_external_bench_data(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + str::from_utf8(&s) + })) + } + + #[bench] // for the comparison + fn bench_stdlib_from_utf8_lossy(bencher: &mut test::Bencher) { + let s = testutils::get_external_bench_data(); + bencher.bytes = s.len() as u64; + bencher.iter(|| test::black_box({ + String::from_utf8_lossy(&s) + })) + } + } +} diff --git a/deps/encoding-0.2.32/src/codec/whatwg.rs b/deps/encoding-0.2.32/src/codec/whatwg.rs new file mode 100644 index 000000000..869c0099b --- /dev/null +++ b/deps/encoding-0.2.32/src/codec/whatwg.rs @@ -0,0 +1,34 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Asymmetric or special encoding constructions required by the WHATWG Encoding standard. + +use codec; +use types::*; + +/// Replacement encoding used to solve a particular attack vector due to mismatching server and +/// client supports for encodings. It is rarely useful outside. +#[derive(Clone, Copy)] +pub struct EncoderOnlyUTF8Encoding; + +impl Encoding for EncoderOnlyUTF8Encoding { + fn name(&self) -> &'static str { "encoder-only-utf-8" } + fn whatwg_name(&self) -> Option<&'static str> { Some("replacement") } // WHATWG compatibility + fn raw_encoder(&self) -> Box { codec::utf_8::UTF8Encoding.raw_encoder() } + fn raw_decoder(&self) -> Box { codec::error::ErrorEncoding.raw_decoder() } +} + +/// Algorithmic mapping for `x-user-defined` encoding. +pub mod x_user_defined { + #[inline] + pub fn forward(code: u8) -> u16 { + 0xf700 | (code as u16) + } + + #[inline] + pub fn backward(code: u32) -> u8 { + if (code & !0x7f) == 0xf780 {(code & 0xff) as u8} else {0} + } +} + diff --git a/deps/encoding-0.2.32/src/examples/UTF-8-test.txt b/deps/encoding-0.2.32/src/examples/UTF-8-test.txt new file mode 100644 index 0000000000000000000000000000000000000000..abd16f7253bf7254ad1ae04cb5bee8d8c47e407a GIT binary patch literal 20334 zcmdU1X>%Ocb-l=P@_l?QkaQ+KqMb=kWH&#~HSJo~$&h?IO#*?-m zc%Ubgju-S~81=~ARry~yhNh5G^057n(4B1 z-Jl)CU9Yt)Q7lo~@#2A>c;bht2ToHz+%uR?;yu;(!lswhMM+X>Kw223()HXhl{Auu zCoaH4V!C)(1yz@8sk9={!DoAbZN`2Bgt*~QdTyNh&3@ow^nTimx?SUnX>wt*17rPAz z)GE5+b=(6;DHb=Cgmm-*H)9tx`CZcBhe_(WATM%qC1CJyU)%=BH>6_>9koDo+V zLQs$lfz)-uJLDAvP==4s@nApfCw(`-P`!Q%VP8G$d9hE)gDPo5PL>ZR?SRy7gyGtL zoTMwMPwDl+c&u6;Glm2YL9lou@LaqSg&uTj?4lP(5Cu4-)I2{fgff(VLK{#CQ{{D9 zq|vJcu)PF24`6-G=m6dVA%rbA9?}L{K3PgiHa2NV;wCcif`C6WiwuSWR^fTA%#?Gp zqik-3KEK1mEzjviFjCkwg^)nkK}$j?9(L4hLW|&qrl@wFVP*6`)WpXvfwh*ek+1J39Sl`y({PyUv>iuXYRwo~Fm!U$wRSqC&$svCdeo15fXJl* zDAN*bHU{fXI|Ba=#F8QyxBDb2@b=tbJhqjLR|9PLK+X9_%WELc>HrMiEx+An zd`GTfTxa@1{9y!DbA#~0HbP7kBCx!TkqH*o@tV-ypyR+x5smqBvafgZ2u0L{Bu0Fm~gU2Wn0TThEIHF!8 zzGf+Cnr4)EG$9vi)68YFWHWY?4r34!B#VxQCTZ)OSr~Q$L^vh}r|BX}2=X}f-1K5< z`5{<}$s9@rByf31d8rq$fI*bvyH4BlTIY;;w@jjedU9Y7iedni z+NcJPIc$18vh~)RzPp+g1|5eS9F9dx>?kmdP#0`5x@!@kpZ= zvO3BFgbO!-LxpgI1L)2qDg;pa8|a%JQ1cS1vlvFr{0fW!#_b9mtBur7r)kn4RG~}s zX>g_mU*e~Ib+<$-$WoPf4i5x<9TX(w@kYorUT>iuXt8K(3_&}{D#fha9c^Nrk>zr; zF;T@>4W=6K@x3ANow5%u(~3jH0u7cL&grU|38{rZiq0b}o3)-+qlYmhm*vFQ$T{(= zGhZAzYa&mw%Cbevv?*#tUSS3FcF7H_+Z z_tB%OfFlLm5ZRaj+#VzF_A_%LZi;M+b;O9E6T*>$Ja7J5ctctfCfR-EtP@4TGFv-dnpR^Zv4`)+pq6mU(aO zmhoP`Srt$PSf4g;%=pTHcW=&#IBDK%1S}(d^5(pd6Xw04h-Ju60dh_<$ITl;)T^YK zPZM(v(9;_9`1{ljbn^u2hnXuo<4@oJx3e(s4Vt$JvO5r3Q5pRg-$@VJ$0r3;nqfH4BQZ$HA@D34`z($LRcW=H>)m=)6uy7)-taQ^BX8G(@Zw}*M27&(yPV>4zK^MI6| zJp=mG5|Wf4|$s(|46qmHsjG*=iRngNcV_d9%P^7C!>6 ztZ>=QUZWXPJ=SwRR%D|=Shvqr{keF45gDivQ+rM+Lsk#BS1(JgYV82~GnJht`)TC@ zuh9lx)p&C@{K7}pr)k5yuXa?GuuNfwUqqRWd*M};oB=d=2r--Y#G8vkgNFoq;of-j zP-yVBSZ_|*ijm*Z&3R;K@U}&^j>D@?;n~>BCCtI?1_f6wuz+@PvnXY!B_T`nn-v;+ zQKnGCi>D8uwWBZpil^W4m0$JFcYXEOeC^kL{WrYZ*wRVR0nJ4SU^is?An&s2FC}l@Y|Wt$9T`x<&AZ-A)2LK zSoZpguFTn$2TaUY51X{(RvYX3Gp?LIUEwp!a>#+YHzZ*03>rubnn_9oO<>T@<^0)GL z^7rx&@{jUQ^3U=w@~`r5az{QPcmLn@fqH}b*q&6!<_vYTsgCy6YRsw%Dji*%rH>}{(Rx$s<8}G;0(3#0oP|CRt!%Z6ZA)$s>;Cstl`CBzI~CY-KIU3H zeKZsnDcZTEO)c2G!zLd#6m8j3o}p_`LOw0ewp0s(XU)$|kAZIJTO{smX)_P|WTrYI z3OMK^-wD=@U@j)0uHx1rmK0L7Q0b-oCODBBD+0bUz3ym8M980r?iCSV zo3U|XAQ81D0#rrF*Jo|U7);F6D{IDV!I?dU+RL*AiJ5w3%_tt%Nik)`a_ekBOw}uE zh6}I6Q$TDb%tplIy0T_gR*MaV8g~+AL&D1{Yi6aipHS0{glWv&9T###O~V`?MyC(f z4%x9`dNh1AbWTLFq{@Jcj}eTq3|Ww)jj0-L;p<$c$;f6m78)+fF%mBnohFv{QQq3Y zUMD7ue6h6BoY3OfpNr=g$hBLyj}ScQ?dqN{-@OTorHRe72}?`WpNpqiHzKZe^Zitl z6RXlQ`P|~^yAJy)n*Z2LW++5wqxN<7dLFt>k@oV&P}>2RYTM;Fg^Q;T@?#!sd)!=l zW76lxN5B7X^yv$nceiz4=`)MLLmC8q{MXKa-+1FQC&FI5{1CyOK%1L39Tq|2{*s#g z#Nz22x4(iy+xT6?DYUs2eeMip~*h@CpAcUnBI^x(SXYT-MHE98BRk z4((Le#$`6N2keSR?n3d}79MMuumwuOUL!rzffZ5P4od<3vQm zGmWv@9cl>30HKdalAfNE(K8td4tQX^tdA4rHLB{1+k#3ps(CMnKv%ZCQDm7 zn|hK0^7NZLGlbP%YzXGp$kDcc5ZM^=6b@Dz*q+JuQ8a97=eC(pQ21H5Y(5{T%Pu}0 zyG9O=)bOYfPgrCnqHUvRqbZ^U1iSR;?m0Bx=@}2m1{6Vn+Qbj@D+7+Ss~5?<&jU;u zRs02co`)7z4_9$^fYU5!0ZsPk5H+x9_~!(y#HzxM&;%OM(2aIoZGJU0aVh?6bbJY8aFncccZGiC43nemQ<500s#YGe<=* zr^QJqYC;W)1)6t=lO33(=GWrm^Cq+JRUFL2+}+OQb7Chnl9O@Io5j=jMO^rRXo^^y zN!v8gLr>IkQQ@@NcbzjZNodJlikL!xNlp{2wRB{ucD{yQYI9l(c4w3c-?A6|mxp>v z<@UIOmsPRynbPSus|+vtg|twiQ@^Sd=Cmy7T$Wkave8v2)JGVdfF3I#suK) zqj?cG3dFYUGRi@Lh&ju=keemQ?W|=By-Nlakema}i+Q1h*(@*(EHHIWH4o_gCUV>x z)DDXC$J|4|+wT@`S|o+z-k$z$@#c6%PlxJs8ji-u(80+S9!;@_IZ-k7`3({lYDANV zaR3TO#u%|VkqUD{M@}AzEQ>7C$~jBjpX2NyaG^}ikFsbE%g#huK$IWsYRZqT>X{j4 zkZCVR*5LAihQp$kv#~4#969BnHc^?52eNV&vgAztT)aMDFHBIT9g#QK?V}Q&(x%qf|3aJy!XH#mf)+Rd+TA5jEW-Ht! zXA5Z3eHjygx2Ja_$|&V~gGhI_h?hPs+neOMrq&w%B$Kv(DrQj#c#x7|>;}oXpakPi^i83Q4o{qac6Z%Z}+QES~ zI2c!1bT$BAyYozCN6U$ZhnP0)8xQVW(b|TH=-bmoeCOFpSvW`IjX~7-wR1&-01@>> z2x)xoq%>;y+PR{Y2obepAmZ~UrBQ>|&cjxYja-iJJ1LFWw1pgZE!Xf{69wa!?h1Q=rx^sWU zE6*n1Tg+TJ1!iuWz`Vbr3})sr@WC-U)fLC+eD-E#Iy0X!m<63VW==W9D=MvkIN3 zcEK?K+R;XK`q2I@mD3bGXOX?K;v2HN%Iu{ALzqNFyL=9%@8$v a&2b9W0wR0mw+p!$IoY3(SqK`l>;D0Y6_gYJ literal 0 HcmV?d00001 diff --git a/deps/encoding-0.2.32/src/examples/outer-space-treaty.html b/deps/encoding-0.2.32/src/examples/outer-space-treaty.html new file mode 100644 index 000000000..b835debf0 --- /dev/null +++ b/deps/encoding-0.2.32/src/examples/outer-space-treaty.html @@ -0,0 +1,959 @@ + + + + + +Treaty on Principles Governing the Activities of States +in the Exploration and Use of Outer Space, including +the Moon and Other Celestial Bodies + + + +

معاهدة المبادئ المنظمة لأنشطة الدول في ميدان +
استكشاف واستخدام الفضاء الخارجي، بما في ذلك +
القمر والأجرام السماوية الأخرى

+

  

+

  

+

إن الدول الأطراف في هذه المعاهدة

+

،إذ تستلهم الآفاق الواسعة التي فتحها أمام الانسانية ولوج الانسان الفضاء الخارجي

+

وإذ تدرك المصلحة المشتركة التي تعود على جميع الانسانية من التقد م في ميدان +
،استكشاف الفضاء الخارجي واستخدامه للأغراض السلمية  

+

وإذ تعتقد ان استكشاف الفضاء الخارجي واستخدامه يجب أن يباشرا لتحقيق فائدة +
،جميع الشعوب أيا كانت درجة نمائها الاقتصادي أو العلمي  

+

وإذ تود الاسهام في تعاون دولي واسع يتناول النواحي العلمية إلى جانب النواحي +
،القانونية من استكشاف الفضاء الخارجي واستخدامه للأغراض السلمية  

+

وإذ تعتقد ان هذا التعاون سيسهم في انماء التفاهم المتبادل وفي توثيق العلاقات الودية +
،بين الأمم والشعوب  

+

وإذ تشير إلى القرار ١٩٦٢ (د- ١٨ ) ذي العنوان التالي "اعلان المبادئ القانونية +
المنظمة لأنشطة الدول في ميدان استكشاف الفضاء الخارجي واستخدامه "، وهو القرار الذي +
،اتخذته الجمعية العامة للأمم المتحدة بالاجماع في ١٣ كانون الأول/ديسمبر ١٩٦٣  

+

وإذ تشير إلى القرار ١٨٨٤ (د- ١٨ ) الذي يدعو الدول إلى الامتناع عن وضع أية +
أجسام، تحمل أية أسلحة نووية أو أي نوع آخر من أسلحة التدمير الشامل، في أي مدار حول +
الأرض، أو عن وضع مثل هذه الأسلحة على أية أجرام سماوية، وهو القرار الذي اتخذته +
،الجمعية العامة للأمم المتحدة بالاجماع في ١٧ تشرين الأول/أكتوبر ١٩٦٣

+

وإذ تراعي القرار ١١٠ (د- ٢) الذي اتخذته الجمعية العامة للأ مم المتحدة في ٣ +
تشرين الثاني /نوفمبر ١٩٤٧ ، وشجبت فيه الدعاية الرامية أو المؤدية إلى إثارة أو تشجيع أي +
ﺗﻬديد أو خرق للسلم أو أي عمل عدواني، وإذ ترى ان القرار السالف الذكر يسري على +
،الفضاء الخارجي

+

واقتناعا منها بأن عقد معاهدة تتضمن المبادئ المنظمة لأنشطة الد ول في ميدان +
استكشاف واستخدام الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، من +
،شأنه تعزيز مقاصد ميثاق الأمم المتحدة ومبادئه

+

:قد اتفقت على ما يلي

+
+

المادة الأولى

+

يباشر استكشاف واستخدام الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية +
،الأخرى، لتحقيق فائدة ومصالح جميع البلدان، أيا كانت درجة نمائها الاقتصادي أو العلمي +
.ويكونان ميدانا للبشرية قاطبة

+

وتكون لجميع الدول حرية استكشاف واستخدام الفضاء الخارجي، بما في ذلك القمر +
والأجرام السماوية الأخرى دون تمييز وعلى قدم المساواة وفقا للقانون الدولي، ويكون حرا +
.الوصول إلى جميع مناطق الأجرام السماوية

+

ويكون حرا اجراء الأبحاث العلمية في الفضاء الخارجي، بما في ذلك القمر والأجرام +
.السماوية الأخرى، وتراعي الدول تيسير وتشجيع التعاون الدولي في مثل هذه الأبحاث

+

+ 

+

المادة الثانية

+

لا يجوز التملك القومي للفضاء الخ ارجي، بما في ذلك القمر والأجرام السماوية +
.الأخرى، بدعوى السيادة أو بطريق الاستخدام أو الاحتلال أو بأية وسيلة أخرى

+

+ 

+

المادة الثالثة

+

تلتزم الدول الأطراف في المعاهدة، في مباشرة أنشطتها في ميدان استكشاف +
واستخدام الفضاء الخارجي، بما في ذلك القمر والأجرام السما وية الأخرى، مراعاة القانون +
الدولي، بما في ذلك ميثاق الأمم المتحدة، بغية صيانة السلم والأمن الدوليين وتعزيز التعاون +
.والتفاهم الدوليين

+

+ 

+

المادة الرابعة

+

تتعهد الدول الأطراف في المعاهدة بعدم وضع أية أجسام تحمل أية أسلحة نووية أو +
أي نوع آخر من أسلحة التدمير ا لشامل في أي مدار حول الأرض، أو وضع مثل هذه +
.الأسلحة على أية أجرام سماوية أو في الفضاء الخارجي بأية طريقة أخرى

+

وتراعي جميع الدول الأطراف في المعاهدة قصر استخدامها للقمر والأجرام السماوية +
الأخرى على الأغراض السلمية . ويحظر انشاء أية قواعد أو منشآت أو تحصينات عسكرية +
وتجريب أي نوع من الأسلحة واجراء أية مناورات عسكرية في الأجرام السماوية . ولا يحظر +
استخدام الملاكات العسكرية لأغراض البحث العلمي أو لأية أغراض سلمية أخرى . وكذلك +
لا يحظر استخدام أية معدات أو مرافق تكون لازمة للاستكشاف السلمي للقمر وللأجرام +
.السماوية الأخرى

+

+ 

+

المادة الخامسة

+

تراعي الدول الأطراف في المعاهدة اعتبار الملاحين الفضائيين بمثابة مبعوثي الانسانية +
في الفضاء الخارجي وتزويدهم بكل مساعدة ممكنة عند حصول أي حادث أو محنة أو هبوط +
اضطراري في اقليم أية دولة من الدول الأطراف أو في أعالي البحار . ويبادر، في حالة هبوط +
.الملاحين الفضائيين اضطرارا، إلى اعادﺗﻬم سالمين إلى الدولة المسجلة فيها مركبتهم الفضائية

+

ويراعي الملاحون الفضائيون التابعون لأية دولة من الدول الأطراف تقديم كل +
مساعدة ممكنة، عند مباشرة أية نشاطات في الفضاء الخارجي أو الأجرام السماوية، إلى +
.الملاحين الفضائيين التابعين للدول الأطراف الأخرى

+

وتلتزم الدول المعنية الأطراف في المعاهدة القيام فورا باعلام الدول الأخرى الأطراف +
في المعاهدة أو الأمين العام للأمم المتحدة بأية ظاهرة تكتشفها في الفضاء الخارجي، بما في ذلك +
القمر والأجرام السماوية الأخرى، ويكون من شأﻧﻬا تعريض حياة الملاحين الفضائيين أو +
.صحتهم للخطر

+

+ 

+

المادة السادسة

+

تترتب على الدول الأطراف في المعاهدة مسؤولية دولية عن الأنشطة القومية المباشرة +
في الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، سواء باشرﺗﻬا الهيئات +
الحكومية أو غير الحكوم ية، وعن تأمين مباشرة الأنشطة القومية وفقا للمباد ئ المقررة في هذه +
المعاهدة. وتراعي الدولة المعنية الطرف في المعاهدة فرض الاجازة والإشراف المستمر على +
أنشطة الهيئات غير الحكومية في الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية +
الأخرى، وفي حالة صدور الأنش طة المباشرة في الفضاء الخارجي، بما في ذلك القمر والأجرام +
السماوية الأخرى، عن احدى المنظمات الدولية، تكون هذه المنظمة، مع الدول التي تكون +
.مشتركة فيها وأطرافا في المعاهدة، هي صاحبة المسؤولية عن التزام أحكام المعاهدة

+

+ 

+

المادة السابعة

+

تترتب على كل دولة من الدو ل الأطراف في المعاهدة تطلق أو تتيح اطلاق أي جسم +
في الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، وعلى كل دولة من الدول +
الأطراف يطلق أي جسم من اقليمها أو من منشآﺗﻬا، المسؤولية الدولية عن الأضرار التي تلحق +
أية دولة أخرى من الدول الأطراف في المعا هدة أي شخص من أشخاصها الطبيعيين أو +
،القانونيين بسبب ذلك الجسم أجزائه فوق الأرض أو في الفضاء الجوي أو في الفضاء الخارجي +
.بما في ذلك القمر والأجرام السماوية الأخرى

+

+ 

+

المادة الثامنة

+

تحتفظ الدولة الطرف في المعاهدة والمقيد في سجلها أي جسم مطلق في الفضاء +
الخارجي بالولاية والمراقبة على ذلك الجسم وعلى أي أشخاص يحملهم أثناء وجوده +
ووجودهم في الفضاء الخارجي أو على أي جرم سماوي، ولا تتأثر ملكية الأجسام المطلقة في +
الفضاء الخارجي، بما في ذلك الأجسام الهابطة أو المنشأة على أي جرم سماوي، ولا ملكية +
أجزائها، بوجودها في الفض اء الخارجي أو على جرم سماوي أو بعودﺗﻬا إلى الأرض . وترد إلى +
دولة السجل التي تكون طرفا في المعاهدة أية أجسام مقيدة في سجلها أو أية أجزاء منها يعثر +
عليها خارج حدودها، على أن تقوم تلك الدولة قبل الرد بتقديم البيانات الثبوتية اللازمة عند +
.طلبها

+

+ 

+

المادة التاسعة

+

تلتزم الدول الأطراف في المعاهدة، في استكشاف واستخدام الفضاء الخارجي، بما في +
ذلك القمر والأجرام السماوية الأخرى، الاسترشاد بمبدأ التعاون والتساعد المتبادل، والمراعاة +
،الحقة في مباشرة أنشطتها في الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى +
للمصالح المقابلة التي تكون لجميع الدول الأخرى الأطراف في المعاهدة . وتلتزم الدول الأطراف +
في المعاهدة، في دراسة واستكشاف الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية +
الأخرى، تفادي إحداث أي تلويث ضار لها وكذلك أية تغييرات ضارة في البيئة الأرضية +
.يسببها إدخا ل أية مواد غير أرضية، والقيام عند الاقتضاء باتخاذ التدابير المناسبة لهذا الغرض +
ويجب على كل دولة من الدول الأطراف في المعاهدة، يكون لديها من الأسباب ما يحملها +
على الاعتقاد بأن ثمة نشاطا تجريبيا مزمعا منها أو من مواطنيها في الفضاء الخارجي، بما في +
ذلك القمر والأجرام السماوية الأخرى، قد يتسبب في عرقلة، محتملة الإضرار، لأنشطة الدول +
الأطراف الأخرى في ميدان استكشاف واستخدام الفضاء الخارجي، بما في ذلك القمر +
والأجرام السماوية الأخرى، للأغراض السلمية، اجراء المشاورات الدولية المناسبة قبل الشروع +
في ذلك النشاط أو التج ريب. ويجوز لكل دولة من الدول الأطراف في المعاهدة يكون لديها +
من الأسباب ما يحملها على الاعتقاد بأن ثمة نشاطا أو تجريبا مزمعا من أية دولة أخرى من +
الدول الأطراف في الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، قد +
يتسبب في عرقلة، محتملة الإضرار، ل لأنشطة المباشرة في ميدان استكشاف واستخدام الفضاء +
الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، للأغراض السلمية، طلب اجراء +
.المشاورات اللازمة بشأن ذلك النشاط التجريبي

+

+ 

+

المادة العاشرة

+

تراعي الدول الأطراف في المعاهدة والمطلقة لأية أجسام فضائية، تعزيز ا للتعاون +
الدولي في ميدان استكشاف واستخدام الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية +
الأخرى، ووفقا لمقاصد هذه المعاهدة، النظر على قدم المساواة في أية طلبات من الدول +
الأخرى الأطراف في المعاهدة تطلب اليها فيها توفير التسهيلات اللازمة لها لمراقبة طير ان +
.الأجسام الفضائية المطلقة منها

+

ويجري، بالاتفاق بين الدول المعنية، تحديد طبيعة تلك التسهيلات اللازمة للمراقبة +
.وتعيين الشروط المناسبة لتوفيرها

+

+ 

+

المادة الحادية عشرة

+

توافق الدول الأطراف في المعاهدة والمباشرة لأية أنشطة في الفضاء الخارجي، بما في +
ذلك القم ر والأجرام السماوية الأخرى، تعزيزا للتعاون الدولي في ميدان استكشاف الفضاء +
الخارجي واستخدامه، على القيام، في أوسع نطاق عملي ممكن، بموافاة الأمين العام للأمم +
المتحدة، وكذلك الجمهور واﻟﻤﺠتمع العلمي الدولي، بالمعلومات اللازمة عن طبيعة تلك الأنشطة +
ومباشرﺗﻬا وأم اكنها ونتائجها، ويجب على الأمين العام للأمم المتحدة أن يكون مستعدا، عند +
.تلقي المعلومات المذكورة، لإذاعتها ونشرها فورا بالطريقة الفعالة

+

+ 

+

المادة الثانية عشرة

+

تتاح لممثلي الدول الأخرى الأطراف في المعاهدة، وعلى أساس التبادل، زيارة جميع +
المحطات والمنشآت والم عدات والمركبات الفضائية التي تكون موجودة على القمر أو على +
الأجرام السماوية الأخرى . ويراعي الممثلون المذكورون إرسال اعلان مسبق بزيارﺗﻬم المزمعة +
لاتاحة اجراء المشاورات المناسبة وتيسير اتخاذ الاحتياطات القصوى اللازمة لكفالة السلامة +
.ولتفادي عرقلة السير الطبيعية للعمليات المعتادة في المرفق المزمعة زيارته

+

+ 

+

المادة الثالثة عشرة

+

تسري أحكام هذه المعاهدة على الأنشطة التي تباشرها الدول الأطراف فيها في ميدان +
استكشاف واستخدام الفضاء الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، سواء +
كانت تلك الأنشطة مباشرة من اح دى الدول الأطراف في المعاهدة على سبيل الانفراد أو +
بالاشتراك مع الدول الأخرى، بما في ذلك الحالات التي تكون فيها تلك الأنشطة مباشرة ضمن +
.اطار المنظمات الحكومية الدولية

+

وتتولى الدول الأطراف في المعاهدة، بالنسبة إلى أية مسائل عملية تنشأ بصدد +
الأنشطة المباشرة من المنظمات الحكومية الدولية في ميدان استكشاف واستخدام الفضاء +
الخارجي، بما في ذلك القمر والأجرام السماوية الأخرى، التماس الحلول اللازمة لتلك المسائل +
إما مع المنظمة الدولية المختصة وإما مع واحدة أو أكثر من الدول الأعضاء في تلك المنظمة +
.والتي تكون أطرافا في هذه المعاهدة

+

+ 

+

المادة الرابعة عشرة

+

١- تعرض هذه المعاهدة لتوقيع جميع الدول . ويجوز الانضمام إلى هذه المعاهدة +
في أي وقت لأية دولة لم توقعها قبل بدء نفاذها وفقا للفقرة ٣ من هذه +
.المادة

+

٢- تخضع هذه المعاهدة لتصديق الدول الموقعة لها وتودع وثائق التصديق ووثائق +
الانضمام لدى حكومات اتحاد الجمهوريات الاشتراكية السوفياتية والمملكة +
،المتحدة لبريطانيا العظمى وايرلندا الشمالية والولايات المتحدة الأمريكية +
.المعنية بحكم هذه المعاهدة باعتبارها الحكومات الوديعة

+

٣- يبدأ نفاذ هذه المعاهدة بإيداع وثائق تصديق خمس حكومات تكون من +
.بينها الحكومات المعنية بحكم هذه المعاهدة باعتبارها الحكومات الوديعة

+

٤- يبدأ نفاذ هذه المعاهدة، بالنسبة إلى الدول التي تكون قد أودعت وثائق +
تصديقها عليها أو انضمامها اليها بعد بدء نفاذها، ابتداء من تاريخ ايداع +
.تلك الدول لوثائق تصديقها أو انضمامها

+

٥- تنهي الحكومات الوديعة، على وجه السرعة، إلى جميع الدول الموقعة لهذه +
المعاهدة أو المنضمة اليها، تاريخ كل توقيع لها، وتاريخ ايداع كل وثيقة +
تصديق عليها أو انضمام اليها، وتاريخ بدء نفاذها، وأية اعلانات أخرى +
.تتصل ﺑﻬا

+

٦- تقوم الحكومات الوديعة بتسجيل هذه المعاهدة وفقا للمادة ١٠٢ من ميثاق +
.الأمم المتحدة

+

+ 

+

المادة الخامسة عشرة

+

يجوز لأية دولة من الدول الأطراف في المعاهدة اقتراح ادخال التعديلات عليها +
وتصبح التعديلات نافذة، بالنسبة إلى كل دولة تقبلها من الدول الأطراف في المعاهدة، فور +
نيلها قبول أغلبية الدول الأطراف في المعاهدة، وتنفذ بعد ذلك بالنسبة إلى كل دولة أخرى من +
.الدول الأطراف في المعاهدة، ابتداء من تاريخ قبول هذه الدولة لها

+

+ 

+

المادة السادسة عشرة

+

يجوز لكل دولة من الدول الأطراف في المعاهدة، بعد سنة من نفاذها، تخطر +
بانسحاﺑﻬا منها باعلان كتابي ترسله إلى الحكومات ال وديعة، ويسري الانسحاب بعد سنة من +
.ورود هذا الاعلان

+

+ 

+

المادة السابعة عشرة

+

حررت هذه المعاهدة بخمس لغات رسمية متساوية الحجية هي الاسبانية والانكليزية +
والروسية والصينية والفرنسية، وتودع في محفوظات الحكومات الوديعة . وتقوم الحكومات +
الوديعة بارسال نسخ مصدقة من ه ذه المعاهدة إلى حكومات الدول الموقعة لها أو المنضمة +
.اليها

+

واثباتا لما تقدم ، قام الموقعون أدناه، المفوضون بذلك حسب الأصول، بتوقيع هذه +
.المعاهدة

+

حررت بثلاث نسخ في مدن لندن وموسكو وواشنطن العاصمة في اليوم السابع +
.والعشرين من شهر كانون الثاني/يناير عام ألف وتسعمائة وسبعة وستين

+

 

+
+

关于各国探索和利用外层空间包括月球与其他天体活动所应遵守原则的条约

+

 

+

本条约各缔约国,

+

受到由于人类进入外层空间而在人类面前展现的伟大前景的鼓舞,

+

承认为和平目的而探索和利用外层空间所取得的进展关系到全人类共同的利益,

+

相信外层空间的探索和利用应造福于各国人民,不论他们的经济或科学发展的程度如何,

+

愿意在为和平目的而探索和利用外层空间的科学以及法律方面的广泛国际合作作出贡献,

+

相信这种合作将有助于促进各国和各国人民之间的相互谅解并加强他们之间的友好关系,

+

回顾联合国大会1963 年12 月13 日一致通过的题为"关于各国探索和利用外层空间活动的法律原则宣言"的第1962(XVIII)号决议,

+

回顾联合国大会1963 年10 月17 日一致通过的第1881(XVIII)号决议,要求各国不要将任何载有核武器或任何其他种类大规模毁灭性武器的物体放置在环绕地球的轨道上,也不要在天体上装置这种武器,

+

考虑到联合国大会1947 年11 月3 日第110(II)号决议,谴责旨在或可能煽动或鼓励任何威胁和平、破坏和平或侵略行为的宣传,并认为上述决议也适用于外层空间,

+

深信缔结关于各国探索和利用外层空间包括月球与其他天体活动所应遵守原则的条约,将促进联合国宪章的宗旨和原则,

+

议定条款如下:

+

+    +

+

第一条

+

探索和利用外层空间,包括月球与其他天体在内,应本着为所有国家谋福利与利益的精神,不论其经济或科学发展的程度如何,这种探索和利用应是全人类的事情。

+

外层空间,包括月球与其他天体在内,应由各国在平等基础上并按国际法自由探索和利用,不得有任何歧视,天体的所有地区均得自由进入。

+

对外层空间,包括月球与其他天体在内,应有科学调查的自由,各国应在这类调查方面便利并鼓励国际合作。

+

+    +

+

第二条

+

外层空间,包括月球与其他天体在内,不得由国家通过提出主权主张,通过使用或占领,或以任何其他方法,据为己有。

+

+    +

+

第三条

+

本条约各缔约国探索和利用外层空间,包括月球与其他天体在内的活动,应按照国际法,包括联合国宪章,并为了维护国际和平与安全及增进国际合作与谅解而进行。

+

+    +

+

第四条

+

本条约各缔约国承诺不在环绕地球的轨道上放置任何载有核武器或任何其他种类大规模毁灭性武器的物体,不在天体上装置这种武器,也不以任何其他方式在外层空间设置这种武器。

+

本条约所有缔约国应专为和平目的使用月球和其他天体。禁止在天体上建立军事基地、军事设施和工事,试验任何类型的武器和进行军事演习。不禁止为了科学研究或任何其他和平目的而使用军事人员。为和平探索月球与其他天体所必需的任何装置或设备,也不在禁止之列。

+

+    +

+

第五条

+

本条约各缔约国应把航天员视为人类在外层空间的使者,航天员如遇意外事故、危难或在另一缔约国领土上或公海上紧急降落时,应给予他们一切可能的协助。航天员降落后,应将他们安全和迅速地送回航天器的登记国。

+

在外层空间及天体上进行活动时,任一缔约国的航天员应给予其他缔约国的航天员一切可能的协助。

+

本条约各缔约国如发现在包括月球与其他天体在内的外层空间有对航天员的生命或健康可能构成危险的任何现象,应立即通知本条约其他缔约国或联合国秘书长。

+

+    +

+

第六条

+

本条约各缔约国对本国在外层空间,包括月球与其他天体在内的活动应负国际责任,不论这类活动是由政府机构或是由非政府团体进行的。它并应负国际责任保证本国的活动符合本条约的规定。非政府团体在外层空间,包括月球与其他天体在内的活动,应经本条约有关缔约国批准并受其不断的监督。一个国际组织在外层空间,包括月球与其他天体在内进行活动时,遵守本条约的责任应由该国际组织和参加该国际组织的本条约各缔约国共同承担。

+

+    +

+

第七条

+

凡发射或促使发射物体进入外层空间,包括月球与其他天体在内的缔约国,以及以其领土或设备供发射物体用的缔约国,对于这种物体或其组成部分在地球上、在大气空间或在外层空间,包括月球与其他天体在内,使另一缔约国或其自然人或法人遭受损害时,应负国际责任。

+

+    +

+

第八条

+

凡本条约缔约国为射入外层空间物体的登记国者,对于该物体及其所载人员,当其在外层空间或在某一天体上时,应保有管辖权和控制权。向外层空间发射的物体,包括在某一天体上着陆或建筑的物体及其组成部分的所有权,不因其在外层空间或在某一天体上或因其返回地球而受影响。这类物体或组成部分如果在其所登记的缔约国境外发现,应交还该缔约国,如经请求,该缔约国应在交还前提供认证资料。

+

+    +

+

第九条

+

本条约各缔约国探索和利用外层空间,包括月球与其他天体在内,应以合作和互助的原则为指导,其在外层空间,包括月球与其他天体在内进行的各种活动,应充分注意本条约所有其他缔约国的相应利益。本条约各缔约国对外层空间,包括月球与其他天体在内进行的研究和探索,应避免使它们受到有害污染以及将地球外物质带入而使地球环境发生不利变化,并应在必要时为此目的采取适当措施。如果本条约某一缔约国有理由认为,该国或其国民在外层空间,包括月球与其他天体在内计划进行的活动或实验可能对其他缔约国和平探索和利用外层空间,包括月球与其他天体在内的活动产生有害干扰时,则该缔约国在开始进行任何这种活动或实验之前,应进行适当的国际磋商。如果本条约某一缔约国有理由认为,另一缔约国在外层空间,包括月球与其他天体在内计划进行的活动或实验,可能对和平探索和利用外层空间,包括月球与其他天体在内的活动产生有害干扰时,则该缔约国可请求就该活动或实验进行磋商。

+

+    +

+

第十条

+

为了按照本条约的宗旨促进在探索和利用外层空间,包括月球与其他天体在内的国际合作,本条约各缔约国应在平等基础上,考虑本条约其他缔约国就提供机会对其发射的外层空间物体的飞行进行观察所提出的任何要求。

+

这种观察机会的性质和提供这种机会的条件,应由有关国家议定。

+

+    +

+

第十一条

+

为了促进在和平探索和利用外层空间方面的国际合作,在外层空间,包括月球与其他天体在内进行活动的本条约各缔约国同意,在最大可能和实际可行的范围内,将这类活动的性质、进行情况、地点和结果通知联合国秘书长,并通告公众和国际科学界。联合国秘书长在接到上述情报后,应准备立即作有效传播。

+

+    +

+

第十二条

+

在月球与其他天体上的一切站所、设施、装备和航天器,应在对等的基础上对本条约其他缔约国的代表开放。这些代表应将所计划的参观,在合理的时间内提前通知,以便进行适当的磋商和采取最大限度的预防措施,以保证安全并避免干扰所要参观的设备的正常运行。

+

+    +

+

第十三条

+

本条约的规定应适用于本条约各缔约国探索和利用外层空间,包括月球与其他天体在内的活动,不论这类活动是由某一缔约国单独进行还是与其他国家联合进行,包括在国际政府间组织的范围内进行的活动在内。

+

国际政府间组织在进行探索和利用外层空间,包括月球与其他天体在内的活动时所产生的任何实际问题,应由本条约各缔约国与有关国际组织或与该国际组织内本条约一个或一个以上的缔约国成员解决。

+

+    +

+

第十四条

+

1. 本条约应开放供所有国家签署。未在本条约按照本条第三款生效之前签署的任何国家,得随时加入本条约。

+

2. 本条约须经签署国批准。批准书和加入书应交苏维埃社会主义共和国联盟、大不列颠及北爱尔兰联合王国和美利坚合众国三国政府保存,该三国政府经指定为保存国政府。

+

3. 本条约应自包括经指定为本条约保存国政府的三国政府在内的五国政府交存批准书起生效。

+

4. 对于在本条约生效后交存批准书或加入书的国家,本条约应自其批准书或加入书交存之日起生效。

+

5. 保存国政府应将每一签字的日期、本条约每份批准书和加入书的交存日期和本条约生效日期以及其他通知事项,迅速告知所有签署国和加入国。

+

6. 本条约应由保存国政府遵照联合国宪章第一百零二条办理登记。

+

+    +

+

第十五条

+

本条约任何缔约国得对本条约提出修正案。修正案应自本条约多数缔约国接受之日起,对接受修正案的各缔约国生效,其后,对其余各缔约国则应自其接受之日起生效。

+

+    +

+

第十六条

+

本条约任何缔约国得在条约生效一年后用书面通知保存国政府退出本条约。这种退出应自接到通知一年后生效。

+

+    +

+

第十七条

+

本条约的中文、英文、法文、西班牙文和俄文五种文本具有同等效力;本条约应保存在保存国政府的档案库内。本条约经正式核证的副本应由保存国政府分送签署国和加入国政府。

+

下列签署人,经正式授权,在本条约上签字,以资证明。

+

一九六七年一月二十七日订于伦敦、莫斯科和华盛顿,一式三份。

+
+

RESOLUTION ADOPTED BY THE GENERAL ASSEMBLY

+

+2222 (XXI). Treaty on Principles Governing the Activities of States in the Exploration and Use of Outer Space, including the Moon and Other Celestial Bodies

+

The General Assembly,

+

+Having considered the report of the Committee on the Peaceful Uses of Outer Space covering its work during 1966, + + 1 + and in particular the work accomplished by the Legal Subcommittee during its fifth session, held at Geneva from 12 July to 4 August and at New York from 12 September to 16 September,

+

+Noting further the progress achieved through subsequent consultations among States Members of the United Nations,

+

+Reaffirming the importance of international cooperation in the field of activities in the peaceful exploration and use of outer space, including the Moon and other celestial bodies, and the importance of developing the rule of law in this new area of human endeavour,

+

1.     +Commends the Treaty on Principles Governing the Activities of States in the Exploration and Use of Outer Space, including the Moon and Other Celestial Bodies, the text of which is annexed to the present resolution;

+

2.     +Requests the Depositary Governments to open the Treaty for signature and ratification at the earliest possible date;

+

3.     +Expresses its hope for the widest possible adherence to this Treaty;

+

4.     +Requests the Committee on the Peaceful Uses of Outer Space:

+
+

(a) To continue to work on the elaboration of an agreement on liability for damages caused by the launching of objects into outer space and an agreement on assistance to and return of astronauts and space vehicles, which are on the agenda of the Committee;

+

(b) To begin at the same time the study of questions relative to the definition of outer space and the utilization of outer space and celestial bodies, including the various implications of space communications;

+

(c) To report on the progress of its work to the General Assembly at its twenty-second session.

+
+

 

+

 

+

+ 1499th plenary meeting, +
+ 19 December 1966. +

+  +

ANNEX

+

Treaty on Principles Governing the Activities of States +
in the Exploration and Use of Outer Space, including +
the Moon and Other Celestial Bodies

+

 

+

     +The States Parties to this Treaty,

+

     +Inspired by the great prospects opening up before mankind as a result of man's entry into outer space,

+

     +Recognizing the common interest of all mankind in the progress of the exploration and use of outer space for peaceful purposes,

+

     +Believing that the exploration and use of outer space should be carried on for the benefit of all peoples irrespective of the degree of their economic or scientific development,

+

     +Desiring to contribute to broad international co-operation in the scientific as well as the legal aspects of the exploration and use of outer space for peaceful purposes,

+

     +Believing that such co-operation will contribute to the development of mutual understanding and to the strengthening of friendly relations between States and peoples,

+

     +Recalling resolution 1962 (XVIII), entitled "Declaration of Legal Principles Governing the Activities of States in the Exploration and Use of Outer Space",which was adopted unanimously by the United Nations General Assembly on 13 December 1963,

+

     +Recalling resolution 1884 (XVIII), calling upon States to refrain from placing in orbit around the earth any objects carrying nuclear weapons or any other kinds of weapons of mass destruction or from installing such weapons on celestial bodies, which was adopted unanimously by the United Nations General Assembly on 17 October 1963,

+

     +Taking account of United Nations General Assembly resolution 110 (II) of 3 November 1947, which condemned propaganda designed or likely to provoke or encourage any threat to the peace, breach of the peace or act of aggression, and considering that the aforementioned resolution is applicable to outer space,

+

     +Convinced that a Treaty on Principles Governing the Activities of States in the Exploration and Use of Outer Space, including the Moon and Other Celestial Bodies, will further the purposes and principles of the Charter of the United Nations,

+

     +Have agreed on the following:

+

 

+
+

+ Article I +

+
+

    The exploration and use of outer space, including the moon and other celestial bodies, shall be carried out for the benefit and in the interests of all countries, irrespective of their degree of economic or scientific development, and shall be the province of all mankind.

+

    Outer space, including the moon and other celestial bodies, shall be free for exploration and use by all States without discrimination of any kind, on a basis of equality and in accordance with international law, and there shall be free access to all areas of celestial bodies.

+

    There shall be freedom of scientific investigation in outer space, including the moon and other celestial bodies, and States shall facilitate and encourage international co-operation in such investigation.

+

 

+
+

+ Article II +

+
+

    Outer space, including the moon and other celestial bodies, is not subject to national appropriation by claim of sovereignty, by means of use or occupation, or by any other means.

+

 

+
+

+ Article III +

+
+

    States Parties to the Treaty shall carry on activities in the exploration and use of outer space, including the moon and other celestial bodies, in accordance with international law, including the Charter of the United Nations, in the interest of maintaining international peace and security and promoting international co-operation and understanding.

+

 

+
+

+ Article IV +

+
+

    States Parties to the Treaty undertake not to place in orbit around the earth any objects carrying nuclear weapons or any other kinds of weapons of mass destruction, install such weapons on celestial bodies, or station such weapons in outer space in any other manner.

+

    The moon and other celestial bodies shall be used by all States Parties to the Treaty exclusively for peaceful purposes. The establishment of military bases, installations and fortifications, the testing of any type of weapons and the conduct of military manoeuvres on celestial bodies shall be forbidden. The use of military personnel for scientific research or for any other peaceful purposes shall not be prohibited. The use of any equipment or facility necessary for peaceful exploration of the moon and other celestial bodies shall also not be prohibited.

+
+

+ +

+
+

Article V

+

    States Parties to the Treaty shall regard astronauts as envoys of mankind in outer space and shall render to them all possible assistance in the event of accident, distress, or emergency landing on the territory of another State Party or on the high seas. When astronauts make such a landing, they shall be safely and promptly returned to the State of registry of their space vehicle.

+

    In carrying on activities in outer space and on celestial bodies, the astronauts of one State Party shall render all possible assistance to the astronauts of other States Parties.

+

    States Parties to the Treaty shall immediately inform the other States Parties to the Treaty or the Secretary-General of the United Nations of any phenomena they discover in outer space, including the moon and other celestial bodies, which could constitute a danger to the life or health of astronauts.

+

 

+
+

+ Article VI +

+
+

    States Parties to the Treaty shall bear international responsibility for national activities in outer space, including the moon and other celestial bodies, whether such activities are carried on by governmental agencies or by non-governmental entities, and for assuring that national activities are carried out in conformity with the provisions set forth in the present Treaty. The activities of non-governmental entities in outer space, including the moon and other celestial bodies, shall require authorization and continuing supervision by the appropriate State Party to the Treaty. When activities are carried on in outer space, including the moon and other celestial bodies, by an international organization, responsibility for compliance with this Treaty shall be borne both by the international organization and by the States Parties to the Treaty participating in such organization.

+

 

+
+

+ Article VII +

+
+

    Each State Party to the Treaty that launches or procures the launching of an object into outer space, including the moon and other celestial bodies, and each State Party from whose territory or facility an object is launched, is internationally liable for damage to another State Party to the Treaty or to its natural or juridical persons by such object or its component parts on the Earth, in air or in outer space, including the moon and other celestial bodies.

+
+

+ Article VIII +

+
+

    A State Party to the Treaty on whose registry an object launched into outer space is carried shall retain jurisdiction and control over such object, and over any personnel thereof, while in outer space or on a celestial body. Ownership of objects launched into outer space, including objects landed or constructed on a celestial body, and of their component parts, is not affected by their presence in outer space or on a celestial body or by their return to the Earth. Such objects or component parts found beyond the limits of the State Party to the Treaty on whose registry they are carried shall be returned to that State Party, which shall, upon request, furnish identifying data prior to their return.

+

 

+

Article IX

+

    In the exploration and use of outer space, including the moon and other celestial bodies, States Parties to the Treaty shall be guided by the principle of co-operation and mutual assistance and shall conduct all their activities in outer space, including the moon and other celestial bodies, with due regard to the corresponding interests of all other States Parties to the Treaty. States Parties to the Treaty shall pursue studies of outer space, including the moon and other celestial bodies, and conduct exploration of them so as to avoid their harmful contamination and also adverse changes in the environment of the Earth resulting from the introduction of extraterrestrial matter and, where necessary, shall adopt appropriate measures for this purpose. If a State Party to the Treaty has reason to believe that an activity or experiment planned by it or its nationals in outer space, including the moon and other celestial bodies, would cause potentially harmful interference with activities of other States Parties in the peaceful exploration and use of outer space, including the moon and other celestial bodies, it shall undertake appropriate international consultations before proceeding with any such activity or experiment. A State Party to the Treaty which has reason to believe that an activity or experiment planned by another State Party in outer space, including the moon and other celestial bodies, would cause potentially harmful interference with activities in the peaceful exploration and use of outer space, including the moon and other celestial bodies, may request consultation concerning the activity or experiment.

+

 

+

+ Article X +

+

    In order to promote international co-operation in the exploration and use of outer space, including the moon and other celestial bodies, in conformity with the purposes of this Treaty, the States Parties to the Treaty shall consider on a basis of equality any requests by other States Parties to the Treaty to be afforded an opportunity to observe the flight of space objects launched by those States. The nature of such an opportunity for observation and the conditions under which it could be afforded shall be determined by agreement between the States concerned.

+

  

+

+ Article XI +

+

    In order to promote international co-operation in the peaceful exploration and use of outer space, States Parties to the Treaty conducting activities in outer space, including the moon and other celestial bodies, agree to inform the Secretary-General of the United Nations as well as the public and the international scientific community, to the greatest extent feasible and practicable, of the nature, conduct, locations and results of such activities. On receiving the said information, the Secretary-General of the United Nations should be prepared to disseminate it immediately and effectively.

+

 

+

+ Article XII +

+

    All stations, installations, equipment and space vehicles on the moon and other celestial bodies shall be open to representatives of other States Parties to the Treaty on a basis of reciprocity. Such representatives shall give reasonable advance notice of a projected visit, in order that appropriate consultations may be held and that maximum precautions may betaken to assure safety and to avoid interference with normal operations in the facility to be visited.

+

 

+

+ Article XIII +

+

    The provisions of this Treaty shall apply to the activities of States Parties to the Treaty in the exploration and use of outer space, including the moon and other celestial bodies, whether such activities are carried on by a single State Party to the Treaty or jointly with other States, including cases where they are carried on within the framework of international intergovernmental organizations.

+

    Any practical questions arising in connection with activities carried on by international intergovernmental organizations in the exploration and use of outer space, including the moon and other celestial bodies, shall be resolved by the States Parties to the Treaty either with the appropriate international organization or with one or more States members of that international organization, which are Parties to this Treaty.

+

 

+

+ Article XIV +

+

+ 1.   This Treaty shall be open to all States for signature. Any State which does not sign this Treaty before its entry into force in accordance with paragraph 3 of this article may accede to it at anytime. +

+

+ 2.  This Treaty shall be subject to ratification by signatory States. Instruments of ratification and instruments of accession shall be deposited with the Governments of the United Kingdom of Great Britain and Northern Ireland, the Union of Soviet Socialist Republics and the United States of America, which are hereby designated the Depositary Governments. +

+

+ 3.  This Treaty shall enter into force upon the deposit of instruments of ratification by five Governments including the Governments designated as Depositary Governments under this Treaty. +

+

+ 4.  For States whose instruments of ratification or accession are deposited subsequent to the entry into force of this Treaty, it shall enter into force on the date of the deposit of their instruments of ratification or accession. +

+

+ 5.  The Depositary Governments shall promptly inform all signatory and acceding States of the date of each signature, the date of deposit of each instrument of ratification of and accession to this Treaty, the date of its entry into force and other notices. +

+

+ 6.  This Treaty shall be registered by the Depositary Governments pursuant to Article 102 of the Charter of the United Nations. +

+

  

+

+ Article XV +

+

    Any State Party to the Treaty may propose amendments to this Treaty. Amendments shall enter into force for each State Party to the Treaty accepting the amendments upon their acceptance by a majority of the States Parties to the Treaty and thereafter for each remaining State Party to the Treaty on the date of acceptance by it.

+

 

+

+ Article XVI +

+

    Any State Party to the Treaty may give notice of its withdrawal from the Treaty one year after its entry into force by written notification to the Depositary Governments. Such withdrawal shall take effect one year from the date of receipt of this notification.

+

 

+ +
+

Article XVII

+
+

    This Treaty, of which the English, Russian, French, Spanish and Chinese texts are equally authentic, shall be deposited in the archives of the Depositary Governments. Duly certified copies of this Treaty shall be transmitted by the Depositary Governments to the Governments of the signatory and acceding States.

+

    IN WITNESS WHEREOF the undersigned, duly authorized, have signed this Treaty.

+

DONE in triplicate, at the cities of London, Moscow and Washington, the twenty-seventh day of January, one thousand nine hundred and sixty-seven.

+
+
+

 

+

Note

+
+

+1.    +Official Records of the General Assembly, Twenty-first Session, agenda items 30, 89 and 91, document A/6431.

+

+ Back +

+
+
+

 

+
  +
+

2222 (XXI). Traité sur les principes régissant les activités des États en matière d'exploration et d'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes

+

+ L'Assemblée générale, +

+

+Ayant examiné le rapport du Comité des utilisations pacifiques de l'espace extra-atmosphérique sur ses travaux de l'année + + 1 + , et en particulier l'œuvre accomplie par le Sous-Comité juridique à sa cinquième session, tenue à Genève du 12 juillet au 4 août et à New York du 12 au 16 septembre,

+

+Notant en outre les progrès accomplis grâce à des consultations ultérieures entre les États Membres de l'Organisation des Nations Unies,

+

+Réaffirmant l'importance de la coopération internationale dans le domaine des activités touchant l'exploration et l'utilisation pacifques de l'espace extra-atmopshérique, y compris la Lune et les autres célestes, et l'importance qu'il y a à promouvoir le règne du droit dans ce nouveau domaine de l'effort humain,

+

1.     +Se félicite du Traité sur les principes régissant les activités des États en matière d'exploration et d'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, dont le texte est joint en annexe à la présente résolution;

+

2.     +Prie les gouvernements dépositaires d'ouvrir le Traité aussitôt à la signature et à la ratification;

+

3.     +Exprime l'espoir d'une adhésion aussi large que possible audit Traité;

+

4.     +Prie le Comité des utilisations pacifique de l'espace extra-atmopshérique:

+
+

(a) De poursuivre ses travaux concernant l'élaboration d'un accord sur la responsibilité pour les dommages causés par des objets lancés dans l'espace extra-atmopshérique et d'un accord sur l'assistance aux astronautes et aux vehicules spatiaux, le retour des astronautes et la restitution des véhicules spatiaux, qui sont à l'ordre du jour du Comité;

+

(b) D'entreprendre en même temps l'étude de questions relatives à la définition de l'espace extra-atmopshérique et des corps célestes, y compris les diverses conséquences des communications spatiales;

+

(c) De rendre compte de la marche de ses travaux à l'Assemblée générale lors de la vingt-deuxième session.

+
+

+ 1499 + e séance plénière, +
19 décembre 1966
+

+

  

+

  

+

ANNEXE

+

Traité sur les principes régissant les activités des États +
en matière d'exploration et d'utilisation de l'espace +
extra-atmosphérique, y compris la Lune et les +
autres corps célestes

+

 

+

+Les États parties au présent Traité, 

+

+S'inspirant des vastes perspectives qui s'offrent à l'humanité du fait de la découverte de l'espace extra-atmosphérique par l'homme,

+

+Reconnaissant l'intérêt que présente pour l'humanité tout entière le progrès de l'exploration et de l'utilisation de l'espace extra-atmosphérique à des fins pacifiques,

+

+Estimant que l'exploration et l'utilisation de l'espace extra-atmosphérique devraient s'effectuer pour le bien de tous les peuples, quel que soit le stade de leur +
développement économique ou scientifique,

+

+Désireux de contribuer au développement d'une large coopération internationale en ce qui concerne les aspects scientifiques aussi bien que juridiques de l'exploration et de l'utilisation de l'espace extra-atmosphérique à des fins pacifiques,

+

+Estimant que cette coopération contribuera à développer la compréhension mutuelle et à consolider les relations amicales entre les États et entre les peuples,

+

+Rappelant la résolution 1962 (XVIII), intitulée "Déclaration des principes juridiques régissant les activités des États en matière d'exploration et d'utilisation de l'espace extra-atmosphérique", que l'Assemblée générale des Nations Unies a adoptée à l'unanimité le 13 décembre 1963,

+

+Rappelant la résolution 1884 (XVIII), qui engage les États à s'abstenir de mettre sur orbite autour de la Terre tous objets porteurs d'armes nucléaires ou de tout autre type d'armes de destruction massive et d'installer de telles armes sur des corps célestes, résolution que l'Assemblée générale des Nations Unies a adoptée à l'unanimité le 17 octobre 1963,

+

+Tenant comptede la résolution 110 (II) de l'Assemblée générale des Nations Unies en date du 3 novembre 1947, résolution qui condamne la propagande destinée ou de nature à provoquer ou à encourager toute menace à la paix, toute rupture de la paix ou tout acte d'agression, et considérant que ladite résolution est applicable à l'espace extra-atmosphérique,

+

+Convaincus que le Traité sur les principes régissant les activités des États en matière d'exploration et d'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, contribuera à la réalisation des buts et principes de la Charte des Nations Unies,

+

+Sont convenus de ce qui suit:

+

+    +

+

Article premier

+

L'exploration et l'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, doivent se faire pour le bien et dans l'intérêt de tous les pays, quel que soit le stade de leur développement économique ou scientifique; elles sont l'apanage de l'humanité tout entière.

+

L'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, peut être exploré et utilisé librement par tous les États sans aucune discrimination, dans des conditions d'égalité et conformément au droit international, toutes les régions des corps célestes devant être librement accessibles.

+

Les recherches scientifiques sont libres dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, et les États doivent faciliter et encourager la coopération internationale dans ces recherches.

+

+    +

+

Article II

+

L'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, ne peut faire l'objet d'appropriation nationale par proclamation de souveraineté, ni par voie d'utilisation ou d'occupation, ni par aucun autre moyen.

+

+    +

+

Article III

+

Les activités des États parties au Traité relatives à l'exploration et à l'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, doivent s'effectuer conformément au droit international, y compris la Charte des Nations Unies, en vue de maintenir la paix et la sécurité internationales et de favoriser la coopération et la compréhension internationales.

+

+    +

+

Article IV

+

Les États parties au Traité s'engagent à ne mettre sur orbite autour de la Terre aucun objet porteur d'armes nucléaires ou de tout autre type d'armes de destruction massive, à ne pas installer de telles armes sur des corps célestes et à ne pas placer de telles armes, de toute autre manière, dans l'espace extra-atmosphérique.

+

Tous les États parties au Traité utiliseront la Lune et les autres corps célestes exclusivement à des fins pacifiques. Sont interdits sur les corps célestes l'aménagement de bases et installations militaires et de fortifications, les essais d'armes de tous types et l'exécution de manoeuvres militaires. N'est pas interdite l'utilisation de personnel militaire à des fins de recherche scientifique ou à toute autre fin pacifique. N'est pas interdite non plus l'utilisation de tout équipement ou installation nécessaire à l'exploration pacifique de la Lune et des autres corps célestes.

+

+    +

+

Article V

+

Les États parties au Traité considéreront les astronautes comme des envoyés de l'humanité dans l'espace extra-atmosphérique et leur prêteront toute l'assistance possible en cas d'accident, de détresse ou d'atterrissage forcé sur le territoire d'un autre État partie au Traité ou d'amerrissage en haute mer. En cas d'un tel atterrissage ou amerrissage, le retour des astronautes à l'État d'immatriculation de leur véhicule spatial devra être effectué promptement et en toute sécurité.

+

Lorsqu'ils poursuivront des activités dans l'espace extra-atmosphérique et sur les corps célestes, les astronautes d'un État partie au Traité prêteront toute l'assistance possible aux astronautes des autres États parties au Traité.

+

Les États parties au Traité porteront immédiatement à la connaissance des autres États parties au Traité ou du Secrétaire général de l'Organisation des Nations Unies tout phénomène découvert par eux dans l'espace extra-atmosphérique, y compris la Lune et les corps célestes, qui pourrait présenter un danger pour la vie ou la santé des astronautes.

+

+    +

+

Article VI

+

Les États parties au Traité ont la responsabilité internationale des activités nationales dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, qu'elles soient entreprises par des organismes gouvernementaux ou par des entités non gouvernementales, et de veiller à ce que les activités nationales soient poursuivies conformément aux dispositions énoncées dans le présent Traité. Les activités des entités non gouvernementales dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, doivent faire l'objet d'une autorisation et d'une surveillance continue de la part de l'État approprié partie au Traité. En cas d'activités poursuivies par une organisation internationale dans l'espace extraatmosphérique, y compris la Lune et les autres corps célestes, la responsabilité du respect des dispositions du présent Traité incombera à cette organisation internationale et aux États parties au Traité qui font partie de ladite organisation.

+

+    +

+

Article VII

+

Tout État partie au Traité qui procède ou fait procéder au lancement d'un objet dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, et tout État partie dont le territoire ou les installations servent au lancement d'un objet, est responsable du point de vue international des dommages causés par ledit objet ou par ses éléments constitutifs, sur la Terre, dans l'atmosphère ou dans l'espace extraatmosphérique, y compris la Lune et les autres corps célestes, à un autre État partie au Traité ou aux personnes physiques ou morales qui relèvent de cet autre État.

+

+    +

+

Article VIII

+

L'État partie au Traité sur le registre duquel est inscrit un objet lancé dans l'espace extra-atmosphérique conservera sous sa juridiction et son contrôle ledit objet et tout le personnel dudit objet, alors qu'ils se trouvent dans l'espace extraatmosphérique ou sur un corps céleste. Les droits de propriété sur les objets lancés dans l'espace extra-atmosphérique, y compris les objets amenés ou construits sur un corps céleste, ainsi que sur leurs éléments constitutifs, demeurent entiers lorsque ces objets ou éléments se trouvent dans l'espace extra-atmosphérique ou sur un corps céleste, et lorsqu'ils reviennent sur la Terre. Les objets ou éléments constitutifs d'objets trouvés au-delà des limites de l'État partie au Traité sur le registre duquel ils sont inscrits doivent être restitués à cet État partie au Traité, celui-ci étant tenu de fournir, sur demande, des données d'identification avant la restitution.

+

+    +

+

Article IX

+

En ce qui concerne l'exploration et l'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, les États parties au Traité devront se fonder sur les principes de la coopération et de l'assistance mutuelle et poursuivront toutes leurs activités dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, en tenant dûment compte des intérêts correspondants de tous les autres États parties au Traité. Les États parties au Traité effectueront l'étude de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, et procéderont à leur exploration de manière à éviter les effets préjudiciables de leur contamination ainsi que les modifications nocives du milieu terrestre résultant de l'introduction de substances extraterrestres et, en cas de besoin, ils prendront les mesures appropriées à cette fin. Si un État partie au Traité a lieu de croire qu'une activité ou expérience envisagée par lui-même ou par ses ressortissants dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, causerait une gêne potentiellement nuisible aux activités d'autres États parties au Traité en matière d'exploration et d'utilisation pacifiques de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, il devra engager les consultations internationales appropriées avant d'entreprendre ladite activité ou expérience. Tout État partie au Traité ayant lieu de croire qu'une activité ou expérience envisagée par un autre État partie au Traité dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, causerait une gêne potentiellement nuisible aux activités poursuivies en matière d'exploration et d'utilisation pacifiques de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, peut demander que des consultations soient ouvertes au sujet de ladite activité ou expérience.

+

+    +

+

Article X

+

Pour favoriser la coopération en matière d'exploration et d'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, conformément aux buts du présent Traité, les États parties au Traité examineront dans des conditions d'égalité les demandes des autres États parties au Traité tendant à obtenir des facilités pour l'observation du vol des objets spatiaux lancés par ces États.

+

La nature de telles facilités d'observation et les conditions dans lesquelles elles pourraient être consenties seront déterminées d'un commun accord par les États intéressés.

+

+    +

+

Article XI

+

Pour favoriser la coopération internationale en matière d'exploration et d'utilisation pacifiques de l'espace extra-atmosphérique, les États parties au Traité qui mènent des activités dans l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, conviennent, dans toute la mesure où cela est possible et réalisable, d'informer le Secrétaire général de l'Organisation des Nations Unies, ainsi que le public et la communauté scientifique internationale, de la nature et de la conduite de ces activités, des lieux où elles sont poursuivies et de leurs résultats. Le Secrétaire général de l'Organisation des Nations Unies devra être prêt à assurer, aussitôt après les avoir reçus, la diffusion effective de ces renseignements.

+

+    +

+

Article XII

+

Toutes les stations et installations, tout le matériel et tous les véhicules spatiaux se trouvant sur la Lune ou sur d'autres corps célestes seront accessibles, dans des conditions de réciprocité, aux représentants des autres États au Traité. Ces représentants notifieront au préalable toute visite projetée, de façon que les consultations voulues puissent avoir lieu et que le maximum de précautions puissent être prises pour assurer la sécurité et éviter de gêner les opérations normales sur les lieux de l'installation à visiter.

+

+    +

+

Article XIII

+

Les dispositions du présent Traité s'appliquent aux activités poursuivies par les États parties au Traité en matière d'exploration et d'utilisation de l'espace extraatmosphérique, y compris la Lune et les autres corps célestes, que ces activités soient menées par un État partie au Traité seul ou en commun avec d'autres États, notamment dans le cadre d'organisations intergouvernementales internationales.

+

Toutes questions pratiques se posant à l'occasion des activités poursuivies par des organisations intergouvernementales internationales en matière d'exploration et d'utilisation de l'espace extra-atmosphérique, y compris la Lune et les autres corps célestes, seront réglées par les États parties au Traité soit avec l'organisation internationale compétente, soit avec un ou plusieurs des États membres de ladite organisation qui sont parties au Traité.

+

+    +

+

Article XIV

+

1. Le présent Traité est ouvert à la signature de tous les États. Tout État qui n'aura pas signé le présent Traité avant son entrée en vigueur conformément au paragraphe 3 du présent article pourra y adhérer à tout moment.

+

2. Le présent Traité sera soumis à la ratification des États signataires. Les instruments de ratification et les instruments d'adhésion seront déposés auprès des Gouvernements des États-Unis d'Amérique, du Royaume-Uni de Grande-Bretagne et d'Irlande du Nord et de l'Union des Républiques socialistes soviétiques, qui sont, dans le présent Traité, désignés comme étant les gouvernements dépositaires.

+

3. Le présent Traité entrera en vigueur lorsque cinq gouvernements, y compris ceux qui sont désignés comme étant les gouvernements dépositaires aux termes du présent Traité, auront déposé leurs instruments de ratification.

+

4. Pour les États dont les instruments de ratification ou d'adhésion seront déposés après l'entrée en vigueur du présent Traité, celui-ci entrera en vigueur à la date du dépôt de leurs instruments de ratification ou d'adhésion.

+

5. Les gouvernements dépositaires informeront sans délai tous les États qui auront signé le présent Traité ou y auront adhéré de la date de chaque signature, de la date du dépôt de chaque instrument de ratification du présent Traité ou d'adhésion au présent Traité, de la date d'entrée en vigueur du Traité ainsi que de toute autre communication.

+

6. Le présent Traité sera enregistré par les gouvernements dépositaires conformément à l'Article 102 de la Charte des Nations Unies.

+

+    +

+

Article XV

+

Tout État partie au présent Traité peut proposer des amendements au Traité. Les amendements prendront effet à l'égard de chaque État partie au Traité acceptant les amendements dès qu'ils auront été acceptés par la majorité des États parties au Traité et, par la suite, pour chacun des autres États parties au Traité, à la date de son acceptation desdits amendements.

+

+    +

+

Article XVI

+

Tout État partie au présent Traité peut, un an après l'entrée en vigueur du Traité, communiquer son intention de cesser d'y être partie par voie de notification écrite adressée aux gouvernements dépositaires. Cette notification prendra effet un an après la date à laquelle elle aura été reçue.

+

+    +

+

Article XVII

+

Le présent Traité, dont les textes anglais, chinois, espagnol, français et russe font également foi, sera déposé dans les archives des gouvernements dépositaires. Des copies dûment certifiées du présent Traité seront adressées par les gouvernements dépositaires aux gouvernements des États qui auront signé le Traité ou qui y auront adhéré.

+

EN FOI DE QUOI les soussignés, dûment habilités à cet effet, ont signé le présent Traité.

+

FAIT en trois exemplaires, à Londres, Moscou et Washington, le vingt-sept janvier mil neuf cent soixante-sept.

+
+

2222 (XXI). Договор о принципах деятельности государств по исследованию и использованию космического пространства, включая Луну и другие небесные тела

+

 

+

+Государства - участники настоящего Договора,

+

+воодушевленные великими перспективами, открывающимися перед человечеством в результате проникновения человека в космос,

+

+признавая общую заинтересованность всего человечества в прогрессе исследования и использования космического пространства в мирных целях,

+

+полагая, что исследование и использование космического пространства должны быть направлены на благо всех народов, независимо от степени их экономического или научного развития,

+

+желая содействовать развитию широкого международного сотруд-ничества как в научных, так и в юридических аспектах исследования и использования космического пространства в мирных целях,

+

+полагая, что такое сотрудничество будет содействовать развитию взаимопонимания и укреплению дружественных отношений между госу-дарствами и народами,

+

+напоминая резолюцию 1962 (XVIII), озаглавленную "Декларация правовых принципов в деятельности государств по исследованию и использованию космического пространства", единодушно принятую Гене-ральной Ассамблеей Организации Объединенных Наций 13 декабря 1963 года,

+

+напоминая резолюцию 1884 (XVIII), призывающую государства воз-держиваться от вывода на орбиту вокруг Земли любых объектов с ядерным оружием или любыми другими видами оружия массового уничтожения или от установки такого оружия на небесных телах, едино-душно принятую Генеральной Ассамблеей Организации Объединенных Наций 17 октября 1963 года,

+

+принимая во внимание резолюцию Генеральной Ассамблеи Организации Объединенных Наций 110 (II) от 3 ноября 1947 года, которая осуждает пропаганду, имеющую целью или способную создать или усилить угрозу миру, нарушение мира или акты агрессии, и считая, что указанная резолюция применима к космическому пространству,

+

+будучи убежденными, что Договор о принципах деятельности государств по исследованию и использованию космического пространства, включая Луну и другие небесные тела, будет способствовать осуществлению целей и принципов Устава Организации Объединенных Наций,

+

+согласились о нижеследующем:

+

+    +

+

Статья I

+

Исследование и использование космического пространства, включая Луну и другие небесные тела, осуществляются на благо и в интересах всех стран, независимо от степени их экономического или научного развития, и являются достоянием всего человечества.

+

Космическое пространство, включая Луну и другие небесные тела, открыто для исследования и использования всеми государствами без какой бы то ни было дискриминации на основе равенства и в соответствии с международным правом, при свободном доступе во все районы небесных тел.

+

Космическое пространство, включая Луну и другие небесные тела, свободно для научных исследований, и государства содействуют и поощряют международное сотрудничество в таких исследованиях.

+

+    +

+

Статья II

+

Космическое пространство, включая Луну и другие небесные тела, не подлежит национальному присвоению ни путем провозглашения на них суверенитета, ни путем использования или оккупации, ни любыми другими средствами.

+

+    +

+

Статья III

+

Государства - участники Договора осуществляют деятельность по исследованию и использованию космического пространства, в том числе Луны и других небесных тел, в соответствии с международным правом, включая Устав Организации Объединенных Наций, в интересах поддержания международного мира и безопасности и развития международного сотрудничества и взаимопонимания.

+

+    +

+

Статья IV

+

Государства - участники Договора обязуются не выводить на орбиту вокруг Земли любые объекты с ядерным оружием или любыми другими видами оружия массового уничтожения, не устанавливать такое оружие на небесных телах и не размещать такое оружие в космическом пространстве каким-либо иным образом.

+

Луна и другие небесные тела используются всеми государствами - участниками Договора исключительно в мирных целях. Запрещается создание на небесных телах военных баз, сооружений и укреплений, испытание любых типов оружия и проведение военных маневров. Использование военного персонала для научных исследований или каких- либо иных мирных целей не запрещается. Не запрещается также использование любого оборудования или средств, необходимых для мирного исследования Луны и других небесных тел.

+

+    +

+

Статья V

+

Государства - участники Договора рассматривают космонавтов как посланцев человечества в космос и оказывают им всемерную помощь в случае аварии, бедствия или вынужденной посадки на территории другого государства - участника Договора или в открытом море. Космонавты, которые совершают такую вынужденную посадку, должны быть в безопасности и незамедлительно возвращены государству, в регистр которого занесен их космический корабль.

+

При осуществлении деятельности в космическом пространстве, в том числе и на небесных телах, космонавты одного государства - участника Договора оказывают возможную помощь космонавтам других государств - участников Договора.

+

Государства - участники Договора незамедлительно информируют другие государства - участники Договора или Генерального секретаря Организации Объединенных Наций об установленных ими явлениях в космическом пространстве, включая Луну и другие небесные тела, которые могли бы представить опасность для жизни или здоровья космонавтов.

+

+    +

+

Статья VI

+

Государства - участники Договора несут международную ответствен- ность за национальную деятельность в космическом пространстве, включая Луну и другие небесные тела, независимо от того, осуществляется ли она правительственными органами или неправительственными юридическими лицами, и за обеспечение того, чтобы национальная деятельность проводилась в соответствии с положениями, содержащимися в настоящем Договоре. Деятельность неправительственных юридических лиц в космическом пространстве, включая Луну и другие небесные тела, должна проводиться с разрешения и под постоянным наблюдением соответ- ствующего государства - участника Договора. В случае деятельности в космическом пространстве, включая Луну и другие небесные тела, международной организации, ответственность за выполнение настоящего Договора несут, наряду с международной организацией, также и участвующие в ней государства - участники Договора.

+

+    +

+

Статья VII

+

Каждое государство - участник Договора, которое осуществляет или организует запуск объекта в космическое пространство, включая Луну и другие небесные тела, а также каждое государство - участник Договора, с территории или установок которого производится запуск объекта, несет международную ответственность за ущерб, причиненный такими объектами или их составными частями на Земле, в воздушном или в космическом пространстве, включая Луну и другие небесные тела, другому государству - участнику Договора, его физическим или юридическим лицам.

+

+    +

+

Статья VIII

+

Государство - участник Договора, в регистр которого занесен объект, запущенный в космическое пространство, сохраняет юридисдикцию и контроль над таким объектом и над любым экипажем этого объекта во время их нахождения в космическом пространстве, в том числе и на небесном теле. Права собственности на космические объекты, запущенные в космическое пространство, включая объекты, доставленные или сооруженные на небесном теле, и на их составные части остаются незатронутыми во время их нахождения в космическом пространстве или на небесном теле, или по возвращении на Землю. Такие объекты или их составные части, обнару- женные за пределами государства - участника Договора, в регистр которого они занесены, должны быть возвращены этому государству - участнику Договора; при этом такое государство должно по требованию представить до возвращения опознавательные данные.

+

+    +

+

Статья IX

+

При исследовании и использовании космического пространства, включая Луну и другие небесные тела, государства - участники Договора должны руководствоваться принципом сотрудничества и взаимной помощи и должны осуществлять всю свою деятельность в космическом пространстве, включая Луну и другие небесные тела, с должным учетом соответствующих интересов всех других государства - участников Договора. Государства - участники Договора осуществляют изучение и исследование космического пространства, включая Луну и другие небесные тела, таким образом, чтобы избегать их вредного загрязнения, а также неблагоприятных изменений земной среды вследствие доставки внеземного вещества, и с этой целью, в случае необходимости, принимают соответствующие меры. Если какое-либо государство - участник Договора имеет основания полагать, что деятельность или эксперимент, запланированные этим государством - участником Дого- вора или гражданами этого государства - участника Договора в космическом пространстве, включая Луну и другие небесные тела, создадут потенциально вредные помехи деятельности других государств - участников Договора в деле мирного исследования и использования космического пространства, включая Луну и другие небесные тела, то оно должно провести соот- ветствующие международные консультации, прежде чем приступить к такой деятельности или эксперименту. Государство - участник Договора, имеющее основание полагать, что деятельность или эксперимент, запланированные другим государством - участником Договора в космическом пространстве, включая Луну и другие небесные тела, создадут потенциально вредные помехи деятельности в деле мирного исследования и использования космического пространства, включая Луну и другие небесные тела, может запросить проведения консультаций относительно такой деятельности или эксперимента.

+

+    +

+

Статья X

+

Для содействия международному сотрудничеству в исследовании и использовании космического пространства, включая Луну и другие небесные тела, в соответствии с целями настоящего Договора, государства - участники Договора будут на равных основаниях рассматривать просьбы других государств - участников Договора о предоставлении им возможности для наблюдения за полетом запускаемых этими государствами космических объектов.

+

Характер и условия предоставления упомянутой выше возможности определяются по соглашению между заинтересованными государствами.

+

+    +

+

Статья XI

+

Для содействия международному сотрудничеству в мирном исследовании и использовании космического пространства государства - участники Договора, осуществляющие деятельность в космическом пространстве, включая Луну и другие небесные тела, соглашаются в максимально возможной и практически осуществимой степени инфор- мировать Генерального секретаря Организации Объединенных Наций, а также общественность и международное научное сообщество о характера, ходе, местах и результатах такой деятельности. По получении указанной выше информации Генеральный секретарь Организации Объединенных Наций должен быть готов к ее немедленному и эффективному распространению.

+

+    +

+

Статья XII

+

Все станции, установки, оборудование и космические корабли на Луне и на других небесных телах открыты для представителей других государств - участников настоящего Договора на основе взаимности. Эти представители заблаговременно сообщают о проектируемом посещении, чтобы позволить провести соответствующие консультации и принять меры максимальной предосторожности для обеспечения безопасности и во избежание помех для нормальных операций на установке, подлежащей посещению.

+

+    +

+

Статья XIII

+

Положения настоящего Договора применяются в отношении деятель- ности государств - участников Договора по исследованию и использованию космического пространства, включая Луну и другие небесные тела, независимо от того, осуществляется ли такая деятельность одним госу- дарством - участником Договора или совместно с другими государствами, в том числе в рамках международных межправительственных организаций.

+

Практические вопросы, которые могут возникать в связи с осуществлением международными межправительственными организациями деятельности по исследованию и использованию космического пространства, включая Луну и другие небесные тела, решаются государствами - участниками Договора либо с соответствующей международной организацией, либо с одним или несколькими государствами - членами этой международной организации, являющимися участниками настоящего Договора.

+

+    +

+

Статья XIV

+

1. Настоящий Договор будет открыт для подписания его всеми государствами. Любое государство, которое не подпишет настоящей Договор до вступления его в силу в соответствии с пунктом 3 данной статьи, может присоединиться к нему в любое время.

+

2. Настоящий Договор подлежит ратификации государствами, подписавшими его. Ратификационные грамоты и документы о присоединении должны быть сданы на хранение правительствам Союза Советских Социалистических Республик, Соединенного Королевства Великобритании и Северной Ирландии и Соединенных Штатов Америки, которые настоящим назначаются в качестве правительств- депозитариев.

+

3. Настоящий Договор вступает в силу после сдачи на хранение ратификационных грамот пятью правительствами, включая прави- тельства, назначенные в качестве правительств - депозитариев настоящего Договора.

+

4. Для государств, ратификационные грамоты или документы о присоединении которых будут сданы на хранение после вступления в силу настоящего Договора, он вступит в силу в день сдачи на хранение их ратификационных грамот или документов о присоединении.

+

5. Правительства-депозитарии незамедлительно уведомляют все подписавшие и присоединившиеся к настоящему Договору государства о дате каждого подписания, о дате сдачи на хранение каждой ратификационной грамоты и документа о присоединении, о дате вступления в силу настоящего Договора, а также о других уведомлениях.

+

6. Настоящий Договор будет зарегистрирован правительствами- депозитариями в соответствии со статьей 102 Устава Организации Объединенных Наций.

+

+    +

+

Статья XV

+

Любое государство - участник Договора может предлагать поправки к настоящему Договору. Поправки вступают в силу для каждого государства - участника Договора, принимающего эти поправки, после принятия их большинством государств - участников Договора, а впоследствии для каждого оставшегося государства - участника Договора в день принятия им этих поправок.

+

+    +

+

Статья XVI

+

Любое государство - участник Договора может уведомить о своем выходе из Договора через год после вступления его в силу путем письменного уведомления правительств-депозитариев, Такой выход приобретает силу по истечении одного года со дня получения этого уведомления.

+

+    +

+

Статья XVII

+

+    +

+

Статья XVII

+

Настоящий Договор, английский, испанский, китайский, русский и французский тексты которого являются равно аутентичными, будет сдан на хранение в архивы правительств-депозитариев. Должным образом заве- ренные копии настоящего Договора будут препровождены правительствами- депозитариями правительствам государств, подписавших Договор и присоединившихся к нему.

+

В УДОСТОВЕРЕНИЕ ЧЕГО нижеподписавшиеся, должным образом на то уполномоченные, подписали настоящий Договор.

+

СОВЕРШЕНО в трех экземплярах в городах Вашингтоне, О.К., Лондоне и Москве января месяца двадцать седьмого дня тысяча девятьсот шестьдесят седьмого года.

+
+

2222 (XVI): Tratado sobre los principios que deben regir las actividades de los Estados en la exploración y utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes

+

 

+

+ Los Estados Partes en este Tratado, +

+

+Inspirándose en las grandes perspectivas que se ofrecen a la humanidad como consecuencia de la entrada del hombre en el espacio ultraterrestre,

+

+Reconociendo el interés general de toda la humanidad en el proceso de la exploración y utilización del espacio ultraterrestre con fines pacíficos,

+

+Estimando que la exploración y la utilización del espacio ultraterrestre se debe efectuar en bien de todos los pueblos, sea cual fuere su grado de desarrollo económico y científico,

+

+Deseando contribuir a una amplia cooperación internacional en lo que se refiere a los aspectos científicos y jurídicos de la exploración y utilización del espacio ultraterrestre con fines pacíficos,

+

+Estimando que tal cooperación contribuirá al desarrollo de la comprensión mutua y al afianzamiento de las relaciones amistosas entre los Estados y pueblos,

+

+Recordando la resolución 1962 (XVIII), titulada "Declaración de los principios jurídicos que deben regir las actividades de los Estados en la exploración y utilización del espacio ultraterrestre", que fue aprobada unánimemente por la Asamblea General de las Naciones Unidas el 13 de diciembre de 1963,

+

+Recordando la resolución 1884 (XVIII), en que se insta a los Estados a no poner en órbita alrededor de la Tierra ningún objeto portador de armas nucleares u otras clases de armas de destrucción en masa, ni a emplazar tales armas en los cuerpos celestes, que fue aprobada unánimemente por la Asamblea General de las Naciones Unidas el 17 de octubre de 1963,

+

+Tomando nota de la resolución 110 (II), aprobada por la Asamblea General el 3 de noviembre de 1947, que condena la propaganda destinada a provocar o alentar, o susceptible de provocar o alentar cualquier amenaza de la paz, quebrantamiento de la paz o acto de agresión, y considerando que dicha resolución es aplicable al espacio ultraterrestre,

+

+Convencidos de que un Tratado sobre los principios que deben regir las actividades de los Estados en la exploración y utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, promoverá los propósitos y principios de la Carta de las Naciones Unidas,

+

+Han convenido en lo siguiente:

+

+    +

+

Artículo I

+

La exploración y utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, deberán hacerse en provecho y en interés de todos los países, sea cual fuere su grado de desarrollo económico y científico, e incumben a toda la humanidad.

+

El espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, estará abierto para su exploración y utilización a todos los Estados sin discriminación alguna en condiciones de igualdad y en conformidad con el derecho internacional, y habrá libertad de acceso a todas las regiones de los cuerpos celestes.

+

El espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, estarán abiertos a la investigación científica, y los Estados facilitarán y fomentarán la cooperación internacional en dichas investigaciones.

+

+    +

+

Artículo II

+

El espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, no podrá ser objeto de apropiación nacional por reivindicación de soberanía, uso u ocupación, ni de ninguna otra manera.

+

+    +

+

Artículo III

+

Los Estados Partes en el Tratado deberán realizar sus actividades de exploración y utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, de conformidad con el derecho internacional, incluida la Carta de las Naciones Unidas, en interés del mantenimiento de la paz y la seguridad internacionales y del fomento de la cooperación y la comprensión internacionales.

+

+    +

+

Artículo IV

+

Los Estados Partes en el Tratado se comprometen a no colocar en órbita alrededor de la Tierra ningún objeto portador de armas nucleares ni de ningún otro tipo de armas de destrucción en masa, a no emplazar tales armas en los cuerpos celestes y a no colocar tales armas en el espacio ultraterrestre en ninguna otra forma.

+

La Luna y los demás cuerpos celestes se utilizarán exclusivamente con fines pacíficos por todos los Estados Partes en el Tratado. Queda prohibido establecer en los cuerpos celestes bases, instalaciones y fortificaciones militares, efectuar ensayos con cualquier tipo de armas y realizar maniobras militares. No se prohíbe la utilización de personal militar para investigaciones científicas ni para cualquier otro objetivo pacífico. Tampoco se prohíbe la utilización de cualquier equipo o medios necesarios para la exploración de la Luna y de otros cuerpos celestes con fines pacíficos.

+

+    +

+

Artículo V

+

Los Estados Partes en el Tratado considerarán a todos los astronautas como enviados de la humanidad en el espacio ultraterrestre, y les prestarán toda la ayuda posible en caso de accidente, peligro o aterrizaje forzoso en el territorio de otro Estado Parte o en alta mar. Cuando los astronautas hagan tal aterrizaje serán devueltos con seguridad y sin demora al Estado de registro de su vehículo espacial.

+

Al realizar actividades en el espacio ultraterrestre, así como en los cuerpos celestes, los astronautas de un Estado Parte en el Tratado deberán prestar toda la ayuda posible a los astronautas de los demás Estados Partes en el Tratado.

+

Los Estados Partes en el Tratado tendrán que informar inmediatamente a los demás Estados Partes en el Tratado o al Secretario General de las Naciones Unidas sobre los fenómenos por ellos observados en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, que podrían constituir un peligro para la vida o la salud de los astronautas.

+

+    +

+

Artículo VI

+

Los Estados Partes en el Tratado serán responsables internacionalmente de las actividades nacionales que realicen en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, los organismos gubernamentales o las entidades no gubernamentales, y deberán asegurar que dichas actividades se efectúen en conformidad con las disposiciones del presente Tratado. Las actividades de las entidades no gubernamentales en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, deberán ser autorizadas y fiscalizadas constantemente por el pertinente Estado Parte en el Tratado. Cuando se trate de actividades que realiza en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, una organización internacional, la responsable en cuanto al presente Tratado corresponderá a esa organización internacional y a los Estados Partes en el Tratado que pertenecen a ella.

+

+    +

+

Artículo VII

+

Todo Estado Parte en el Tratado que lance o promueva el lanzamiento de un objeto al espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, y todo Estado Parte en el Tratado, desde cuyo territorio o cuyas instalaciones se lance un objeto, será responsable internacionalmente de los daños causados a otro Estado Parte en el Tratado o a sus personas naturales o jurídicas por dicho objeto o sus partes componentes en la Tierra, en el espacio aéreo o en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes.

+

+    +

+

Artículo VIII

+

El Estado Parte en el Tratado, en cuyo registro figura el objeto lanzado al espacio ultraterrestre, retendrá su jurisdicción y control sobre tal objeto, así como sobre todo el personal que vaya en él, mientras se encuentre en el espacio ultraterrestre o en un cuerpo celeste. El derecho de propiedad de los objetos lanzados al espacio ultraterrestre, incluso de los objetos que hayan descendido o se construyan en un cuerpo celeste, y de sus partes componentes, no sufrirá ninguna alteración mientras estén en el espacio ultraterrestre, incluso en un cuerpo celeste, ni en su retorno a la Tierra. Cuando esos objetos o esas partes componentes sean hallados fuera de los límites del Estado Parte en el Tratado en cuyo registro figuran, deberán ser devueltos a ese Estado Parte, el que deberá proporcionar los datos de identificación que se le soliciten antes de efectuarse la restitución.

+

+    +

+

Artículo IX

+

En la exploración y utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, los Estados Partes en el Tratado deberán guiarse por el principio de la cooperación y la asistencia mutua, y en todas sus actividades en el espacio ultraterrestre, incluso en la Luna y otros cuerpos celestes, deberán tener debidamente en cuenta los intereses correspondientes de los demás Estados Partes en el Tratado. Los Estados Partes en el Tratado harán los estudios e investigaciones del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, y procederán a su exploración de tal forma que no se produzca una contaminación nociva ni cambios desfavorables en el medio ambiente de la Tierra como consecuencia de la introducción en él de materias extraterrestres, y cuando sea necesario adoptarán las medidas pertinentes a tal efecto. Si un Estado Parte en el Tratado tiene motivos para creer que una actividad o un experimento en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, proyectado por él o por sus nacionales, crearía un obstáculo capaz de perjudicar las actividades de otros Estados Partes en el Tratado en la exploración y utilización del espacio ultraterrestre con fines pacíficos, incluso en la Luna y otros cuerpos celestes, deberá celebrar las consultas internacionales oportunas antes de iniciar esa actividad o ese experimento. Si un Estado Parte en el Tratado tiene motivos para creer que una actividad o un experimento en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, proyectado por otro Estado Parte en el Tratado, crearía un obstáculo capaz de perjudicar las actividades de exploración y utilización del espacio ultraterrestre con fines pacíficos, incluso en la Luna y otros cuerpos celestes, podrá pedir que se celebren consultas sobre dicha actividad o experimento.

+

+    +

+

Artículo X

+

A fin de contribuir a la cooperación internacional en la exploración y la utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, conforme a los objetivos del presente Tratado, los Estados Partes en él examinarán, en condiciones de igualdad, las solicitudes formuladas por otros Estados Partes en el Tratado para que se les brinde la oportunidad a fin de observar el vuelo de los objetos espaciales lanzados por dichos Estados.

+

La naturaleza de tal oportunidad y las condiciones en que podría ser concedida se determinarán por acuerdo entre los Estados interesados.

+

+    +

+

Artículo XI

+

A fin de fomentar la cooperación internacional en la exploración y utilización del espacio ultraterrestre con fines pacíficos, los Estados Partes en el Tratado que desarrollan actividades en el espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, convienen en informar, en la mayor medida posible dentro de lo viable y factible, al Secretario General de las Naciones Unidas, así como al público y a la comunidad científica internacional, acerca de la naturaleza, marcha, localización y resultados de dichas actividades. El Secretario General de las Naciones Unidas debe estar en condiciones de difundir eficazmente tal información, inmediatamente después de recibirla.

+

+    +

+

Artículo XII

+

Todas las estaciones, instalaciones, equipo y vehículos espaciales situados en la Luna y otros cuerpos celestes serán accesibles a los representantes de otros Estados Parte en el presente Tratado, sobre la base de reciprocidad. Dichos representantes notificarán con antelación razonable su intención de hacer una visita, a fin de permitir celebrar las consultas que procedan y adoptar un máximo de precauciones para velar por la seguridad y evitar toda perturbación del funcionamiento normal de la instalación visitada.

+

+    +

+

Artículo XIII

+

Las disposiciones del presente Tratado se aplicarán a las actividades de exploración y utilización de espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, que realicen los Estados Partes en el Tratado, tanto en el caso de que esas actividades las lleve a cabo un Estado Parte en el Tratado por sí solo o junto con otros Estados, incluso cuando se efectúen dentro del marco de organizaciones intergubernamentales internacionales.

+

Los Estados Partes en el Tratado resolverán los problemas prácticos que puedan surgir en relación con las actividades que desarrollen las organizaciones intergubernamentales internacionales en la exploración y utilización del espacio ultraterrestre, incluso la Luna y otros cuerpos celestes, con la organización internacional pertinente o con uno o varios Estados miembros de dicha organización internacional que sean Partes en el presente Tratado.

+

+    +

+

Artículo XIV

+

1. Este Tratado estará abierto a la firma de todos los Estados. El Estado que firmare este Tratado antes de su entrada en vigor, de conformidad con párrafo 3 de este artículo, podrá adherirse a él en cualquier momento.

+

2. Este Tratado estará sujeto a ratificación por los Estados signatarios. Los instrumentos de ratificación y los instrumentos de adhesión se depositarán en los archivos de los Gobiernos de los Estados Unidos de América, del Reino Unido de Gran Bretaña e Irlanda del Norte y de la Unión de Repúblicas Socialistas Soviéticas, a los que por el presente se designa como Gobiernos depositarios.

+

3. Este Tratado entrará en vigor cuando hayan depositado los instrumentos de ratificación cinco gobiernos, incluidos los designados como Gobiernos depositarios en virtud del presente Tratado.

+

4. Para los Estados cuyos instrumentos de ratificación o de adhesión se depositaren después de la entrada en vigor de este Tratado, el Tratado entrará en vigor en la fecha del depósito de sus instrumentos de ratificación o adhesión.

+

5. Los Gobiernos depositarios informarán sin tardanza a todos los Estados signatarios y a todos los Estados que se hayan adherido a este Tratado, de la fecha de cada firma, de la fecha de depósito de cada instrumento de ratificación y de adhesión a este Tratado, de la fecha de su entrada en vigor y de cualquier otra notificación.

+

6. Este Tratado será registrado por los Gobiernos depositarios, de conformidad con el Artículo 102 de la Carta de las Naciones Unidas.

+

+    +

+

Artículo XV

+

Cualquier Estado Parte en el Tratado podrá proponer enmiendas al mismo. Las enmiendas entrarán en vigor para cada Estado Parte en el Tratado que las acepte cuando éstas hayan sido aceptadas por la mayoría de los Estados Partes en el Tratado, y en lo sucesivo para cada Estado restante que sea Parte en el Tratado en la fecha en que las acepte.

+

+    +

+

Artículo XVI

+

Todo Estado Parte podrá comunicar su retiro de este Tratado al cabo de un año de su entrada en vigor, mediante notificación por escrito dirigida a los Gobiernos depositarios. Tal retiro surtirá efecto un año después de la fecha en que se reciba la notificación.

+

+    +

+

Artículo XVII

+

Este Tratado, cuyos textos en chino, español, francés, inglés y ruso son igualmente auténticos, se depositará en los archivos de los Gobiernos depositarios. Los Gobiernos depositarios remitirán copias debidamente certificadas de este Tratado a los gobiernos de los Estados signatarios y de los Estados que se adhieran al Tratado.

+

EN TESTIMONIO DE LO CUAL, los infrascritos, debidamente autorizados, firman este Tratado.

+

HECHO en tres ejemplares, en las ciudades de Londres, Moscú y Washington D.C., el día veintisiete de enero de mil novecientos sesenta y siete.

+ + diff --git a/deps/encoding-0.2.32/src/index/gen_index.py b/deps/encoding-0.2.32/src/index/gen_index.py new file mode 100644 index 000000000..7a125a3b1 --- /dev/null +++ b/deps/encoding-0.2.32/src/index/gen_index.py @@ -0,0 +1,386 @@ +# This is a part of rust-encoding. +# Copyright (c) 2013-2015, Kang Seonghoon. +# See README.md and LICENSE.txt for details. + +import urllib +import sys +import os.path + +def whatwg_index(name, comments): + for line in urllib.urlopen('http://encoding.spec.whatwg.org/index-%s.txt' % name): + line = line.strip() + if not line: continue + if line.startswith('#'): + comments.append('//' + line[1:]) + continue + parts = line.split(None, 2) + key = int(parts[0], 0) + value = int(parts[1], 0) + yield key, value + +def mkdir_and_open(crate, name): + dirname = os.path.join(os.path.dirname(__file__), crate) + try: + os.mkdir(dirname) + except Exception: + pass + return open(os.path.join(dirname, '%s.rs' % name.replace('-', '_')), 'wb') + +def write_header(f, name, comments): + print >>f, '// AUTOGENERATED FROM index-%s.txt, ORIGINAL COMMENT FOLLOWS:' % name + print >>f, '//' + for line in comments: + print >>f, line + +def write_comma_separated(f, prefix, l, width=80): + buffered = '' + for i in l: + i = str(i) + if len(prefix) + len(buffered) + len(i) <= width: + buffered += i + else: + print >>f, prefix + buffered.rstrip() + buffered = i + if buffered: + print >>f, prefix + buffered.rstrip() + +def make_minimal_trie(invdata, lowerlimit=0x10000): + maxvalue = max(invdata.keys()) + 1 + best = 0xffffffff + besttrie = None + for triebits in xrange(21): + lower = [None] * (1<= len(lower) + len(upper): + best = len(lower) + len(upper) + besttrie = (triebits, lower, upper) + return besttrie + +def generate_single_byte_index(crate, name): + modname = name.replace('-', '_') + + data = [None] * 128 + invdata = {} + comments = [] + for key, value in whatwg_index(name, comments): + assert 0 <= key < 128 and 0 <= value < 0xffff and data[key] is None and value not in invdata + data[key] = value + invdata[value] = key + + # generate a trie with a minimal amount of data + triebits, lower, upper = make_minimal_trie(invdata, lowerlimit=0x10000) + + with mkdir_and_open(crate, name) as f: + write_header(f, name, comments) + print >>f + print >>f, "static FORWARD_TABLE: &'static [u16] = &[" + write_comma_separated(f, ' ', + ['%d, ' % (0xffff if value is None else value) for value in data]) + print >>f, '];' + print >>f + print >>f, '/// Returns the index code point for pointer `code` in this index.' + print >>f, '#[inline]' + print >>f, 'pub fn forward(code: u8) -> u16 {' + print >>f, ' FORWARD_TABLE[(code - 0x80) as usize]' + print >>f, '}' + print >>f + print >>f, "static BACKWARD_TABLE_LOWER: &'static [u8] = &[" + write_comma_separated(f, ' ', ['%d, ' % (0 if v is None else v+0x80) for v in lower]) + print >>f, '];' + print >>f + print >>f, "static BACKWARD_TABLE_UPPER: &'static [u16] = &[" + write_comma_separated(f, ' ', ['%d, ' % v for v in upper]) + print >>f, '];' + print >>f + print >>f, '/// Returns the index pointer for code point `code` in this index.' + print >>f, '#[inline]' + print >>f, 'pub fn backward(code: u32) -> u8 {' + print >>f, ' let offset = (code >> %d) as usize;' % triebits + print >>f, ' let offset = if offset < %d {BACKWARD_TABLE_UPPER[offset] as usize} else {0};' % len(upper) + print >>f, ' BACKWARD_TABLE_LOWER[offset + ((code & %d) as usize)]' % ((1<>f, '}' + print >>f + print >>f, '#[cfg(test)]' + print >>f, 'single_byte_tests!(' + print >>f, ' mod = %s' % modname + print >>f, ');' + + return 2 * len(data) + len(lower) + 2 * len(upper) + +def generate_multi_byte_index(crate, name): + modname = name.replace('-', '_') + + data = {} + invdata = {} + dups = [] + comments = [] + morebits = False + for key, value in whatwg_index(name, comments): + assert 0 <= key < 0xffff and 0 <= value < 0x110000 and value != 0xffff and key not in data + if value >= 0x10001: + assert (value >> 16) == 2 + morebits = True + data[key] = value + if value not in invdata: + invdata[value] = key + else: + dups.append(key) + + # Big5 has four two-letter forward mappings, we use special entries for them + if name == 'big5': + specialidx = [1133, 1135, 1164, 1166] + assert all(key not in data for key in specialidx) + assert all(value not in invdata for value in xrange(len(specialidx))) + for value, key in enumerate(specialidx): + data[key] = value + dups.append(key) # no consistency testing for them + + # generate a trie with a minimal amount of data + triebits, lower, upper = make_minimal_trie(invdata, lowerlimit=0x10000) + + # JIS X 0208 index has two ranges [8272,8836) and [8836,11280) to support two slightly + # different encodings EUC-JP and Shift_JIS; the default backward function would favor + # the former, so we need a separate mapping for the latter. + # + # fortunately for us, all allocated codes in [8272,8836) have counterparts in others, + # so we only need a smaller remapping from [8272,8836) to other counterparts. + remap = None + if name == 'jis0208': + REMAP_MIN = 8272 + REMAP_MAX = 8835 + + invdataminusremap = {} + for key, value in data.items(): + if value not in invdataminusremap and not REMAP_MIN <= key <= REMAP_MAX: + invdataminusremap[value] = key + + remap = [] + for i in xrange(REMAP_MIN, REMAP_MAX+1): + if i in data: + assert data[i] in invdataminusremap + value = invdataminusremap[data[i]] + assert value < 0x10000 + remap.append(value) + else: + remap.append(0xffff) + + minkey = min(data) + maxkey = max(data) + 1 + with mkdir_and_open(crate, name) as f: + write_header(f, name, comments) + print >>f + print >>f, "static FORWARD_TABLE: &'static [u16] = &[" + write_comma_separated(f, ' ', + ['%d, ' % (data.get(key, 0xffff) & 0xffff) for key in xrange(minkey, maxkey)]) + print >>f, '];' + if morebits: + print >>f + print >>f, "static FORWARD_TABLE_MORE: &'static [u32] = &[" + bits = [] + for i in xrange(minkey, maxkey, 32): + v = 0 + for j in xrange(32): + v |= (data.get(i+j, 0) >= 0x10000) << j + bits.append(v) + write_comma_separated(f, ' ', ['%d, ' % v for v in bits]) + print >>f, '];' + print >>f + print >>f, '/// Returns the index code point for pointer `code` in this index.' + print >>f, '#[inline]' + print >>f, 'pub fn forward(code: u16) -> u32 {' + if minkey != 0: + print >>f, ' let code = (code as usize).wrapping_sub(%d);' % minkey + else: + print >>f, ' let code = code as usize;' + print >>f, ' if code < %d {' % (maxkey - minkey) + if morebits: + print >>f, ' (FORWARD_TABLE[code] as u32) | ' + \ + '(((FORWARD_TABLE_MORE[code >> 5] >> (code & 31)) & 1) << 17)' + else: + print >>f, ' FORWARD_TABLE[code] as u32' + print >>f, ' } else {' + print >>f, ' 0xffff' + print >>f, ' }' + print >>f, '}' + print >>f + print >>f, "static BACKWARD_TABLE_LOWER: &'static [u16] = &[" + write_comma_separated(f, ' ', ['%d, ' % (0xffff if v is None else v) for v in lower]) + print >>f, '];' + print >>f + print >>f, "static BACKWARD_TABLE_UPPER: &'static [u16] = &[" + write_comma_separated(f, ' ', ['%d, ' % v for v in upper]) + print >>f, '];' + if remap: + print >>f + print >>f, "static BACKWARD_TABLE_REMAPPED: &'static [u16] = &[" + write_comma_separated(f, ' ', ['%d, ' % v for v in remap]) + print >>f, '];' + print >>f + print >>f, '/// Returns the index pointer for code point `code` in this index.' + print >>f, '#[inline]' + print >>f, 'pub fn backward(code: u32) -> u16 {' + print >>f, ' let offset = (code >> %d) as usize;' % triebits + print >>f, ' let offset = if offset < %d {BACKWARD_TABLE_UPPER[offset] as usize} else {0};' % len(upper) + print >>f, ' BACKWARD_TABLE_LOWER[offset + ((code & %d) as usize)]' % ((1<>f, '}' + if remap: + print >>f + assert name == 'jis0208' + print >>f, '/// Returns the index shift_jis pointer for code point `code`.' + print >>f, '#[inline]' + print >>f, 'pub fn backward_remapped(code: u32) -> u16 {' + print >>f, ' let value = backward(code);' + print >>f, ' if %d <= value && value <= %d {' % (REMAP_MIN, REMAP_MAX) + print >>f, ' BACKWARD_TABLE_REMAPPED[(value - %d) as usize]' % REMAP_MIN + print >>f, ' } else {' + print >>f, ' value' + print >>f, ' }' + print >>f, '}' + print >>f + print >>f, '#[cfg(test)]' + print >>f, 'multi_byte_tests!(' + print >>f, ' mod = %s,' % modname + if remap: + print >>f, ' remap = [%d, %d],' % (REMAP_MIN, REMAP_MAX) + if dups: + print >>f, ' dups = [' + write_comma_separated(f, ' ', ['%d, ' % v for v in sorted(dups)]) + print >>f, ' ]' + else: + print >>f, ' dups = []' + print >>f, ');' + + tablesz = 2 * (maxkey - minkey) + 2 * len(lower) + 2 * len(upper) + if morebits: tablesz += 4 * ((maxkey - minkey + 31) // 32) + if remap: tablesz += 2 * len(remap) + return tablesz + +def generate_multi_byte_range_lbound_index(crate, name): + modname = name.replace('-', '_') + + data = [] + comments = [] + for key, value in whatwg_index(name, comments): + data.append((key, value)) + assert data and data == sorted(data) + + minkey, minvalue = data[0] + maxkey, maxvalue = data[-1] + if data[0] != (0, 0): + data.insert(0, (0, 0)) + maxlog2 = 0 + while 2**(maxlog2 + 1) <= len(data): + maxlog2 += 1 + + if name == 'gb18030-ranges': + keyubound = 0x110000 + valueubound = 126 * 10 * 126 * 10 + else: + keyubound = maxkey + 1 + valueubound = maxvalue + 1 + + with mkdir_and_open(crate, name) as f: + write_header(f, name, comments) + print >>f + print >>f, "static FORWARD_TABLE: &'static [u32] = &[" + write_comma_separated(f, ' ', ['%d, ' % value for key, value in data]) + print >>f, '];' + print >>f + print >>f, "static BACKWARD_TABLE: &'static [u32] = &[" + write_comma_separated(f, ' ', ['%d, ' % key for key, value in data]) + print >>f, '];' + print >>f + print >>f, '/// Returns the index code point for pointer `code` in this index.' + print >>f, '#[inline]' + print >>f, 'pub fn forward(code: u32) -> u32 {' + if minkey > 0: + print >>f, ' if code < %d { return 0xffffffff; }' % minkey + if name == 'gb18030-ranges': # has "invalid" region inside + print >>f, ' if (code > 39419 && code < 189000) || code > 1237575 { return 0xffffffff; }' + print >>f, ' let mut i = if code >= BACKWARD_TABLE[%d] {%d} else {0};' % \ + (2**maxlog2 - 1, len(data) - 2**maxlog2 + 1) + for i in xrange(maxlog2-1, -1, -1): + print >>f, ' if code >= BACKWARD_TABLE[i%s] { i += %d; }' % \ + ('+%d' % (2**i-1) if i > 0 else '', 2**i) + print >>f, ' (code - BACKWARD_TABLE[i-1]) + FORWARD_TABLE[i-1]' + print >>f, '}' + print >>f + print >>f, '/// Returns the index pointer for code point `code` in this index.' + print >>f, '#[inline]' + print >>f, 'pub fn backward(code: u32) -> u32 {' + if minvalue > 0: + print >>f, ' if code < %d { return 0xffffffff; }' % minvalue + print >>f, ' let mut i = if code >= FORWARD_TABLE[%d] {%d} else {0};' % \ + (2**maxlog2 - 1, len(data) - 2**maxlog2 + 1) + for i in xrange(maxlog2-1, -1, -1): + print >>f, ' if code >= FORWARD_TABLE[i%s] { i += %d; }' % \ + ('+%d' % (2**i-1) if i > 0 else '', 2**i) + print >>f, ' (code - FORWARD_TABLE[i-1]) + BACKWARD_TABLE[i-1]' + print >>f, '}' + print >>f + print >>f, '#[cfg(test)]' + print >>f, 'multi_byte_range_tests!(' + print >>f, ' mod = %s,' % modname + print >>f, ' key = [%d, %d], key < %d,' % (minkey, maxkey, keyubound) + print >>f, ' value = [%d, %d], value < %d' % (minvalue, maxvalue, valueubound) + print >>f, ');' + + return 8 * len(data) + +INDICES = { + 'singlebyte/ibm866': generate_single_byte_index, + 'singlebyte/iso-8859-2': generate_single_byte_index, + 'singlebyte/iso-8859-3': generate_single_byte_index, + 'singlebyte/iso-8859-4': generate_single_byte_index, + 'singlebyte/iso-8859-5': generate_single_byte_index, + 'singlebyte/iso-8859-6': generate_single_byte_index, + 'singlebyte/iso-8859-7': generate_single_byte_index, + 'singlebyte/iso-8859-8': generate_single_byte_index, + 'singlebyte/iso-8859-10': generate_single_byte_index, + 'singlebyte/iso-8859-13': generate_single_byte_index, + 'singlebyte/iso-8859-14': generate_single_byte_index, + 'singlebyte/iso-8859-15': generate_single_byte_index, + 'singlebyte/iso-8859-16': generate_single_byte_index, + 'singlebyte/koi8-r': generate_single_byte_index, + 'singlebyte/koi8-u': generate_single_byte_index, + 'singlebyte/macintosh': generate_single_byte_index, + 'singlebyte/windows-874': generate_single_byte_index, + 'singlebyte/windows-1250': generate_single_byte_index, + 'singlebyte/windows-1251': generate_single_byte_index, + 'singlebyte/windows-1252': generate_single_byte_index, + 'singlebyte/windows-1253': generate_single_byte_index, + 'singlebyte/windows-1254': generate_single_byte_index, + 'singlebyte/windows-1255': generate_single_byte_index, + 'singlebyte/windows-1256': generate_single_byte_index, + 'singlebyte/windows-1257': generate_single_byte_index, + 'singlebyte/windows-1258': generate_single_byte_index, + 'singlebyte/x-mac-cyrillic': generate_single_byte_index, + + 'tradchinese/big5': generate_multi_byte_index, + 'korean/euc-kr': generate_multi_byte_index, + 'simpchinese/gb18030': generate_multi_byte_index, + 'japanese/jis0208': generate_multi_byte_index, + 'japanese/jis0212': generate_multi_byte_index, + + 'simpchinese/gb18030-ranges': generate_multi_byte_range_lbound_index, +} + +if __name__ == '__main__': + import sys + filter = sys.argv[1] if len(sys.argv) > 1 else '' + for index, generate in INDICES.items(): + crate, _, index = index.partition('/') + if filter not in index: continue + print >>sys.stderr, 'generating index %s...' % index, + tablesz = generate(crate, index) + print >>sys.stderr, '%d bytes.' % tablesz + diff --git a/deps/encoding-0.2.32/src/label.rs b/deps/encoding-0.2.32/src/label.rs new file mode 100644 index 000000000..38c2f5373 --- /dev/null +++ b/deps/encoding-0.2.32/src/label.rs @@ -0,0 +1,356 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! An interface for retrieving an encoding (or a set of encodings) from a string/numeric label. + +use all; +use types::EncodingRef; + +/// Returns an encoding from given label, defined in the WHATWG Encoding standard, if any. +/// Implements "get an encoding" algorithm: http://encoding.spec.whatwg.org/#concept-encoding-get +pub fn encoding_from_whatwg_label(label: &str) -> Option { + let label = label.trim_matches(&[' ', '\n', '\r', '\t', '\x0C'][..]); + let label: String = + label.chars().map(|c| match c { 'A'...'Z' => (c as u8 + 32) as char, _ => c }).collect(); + match &label[..] { + "unicode-1-1-utf-8" | + "utf-8" | + "utf8" => + Some(all::UTF_8 as EncodingRef), + "866" | + "cp866" | + "csibm866" | + "ibm866" => + Some(all::IBM866 as EncodingRef), + "csisolatin2" | + "iso-8859-2" | + "iso-ir-101" | + "iso8859-2" | + "iso88592" | + "iso_8859-2" | + "iso_8859-2:1987" | + "l2" | + "latin2" => + Some(all::ISO_8859_2 as EncodingRef), + "csisolatin3" | + "iso-8859-3" | + "iso-ir-109" | + "iso8859-3" | + "iso88593" | + "iso_8859-3" | + "iso_8859-3:1988" | + "l3" | + "latin3" => + Some(all::ISO_8859_3 as EncodingRef), + "csisolatin4" | + "iso-8859-4" | + "iso-ir-110" | + "iso8859-4" | + "iso88594" | + "iso_8859-4" | + "iso_8859-4:1988" | + "l4" | + "latin4" => + Some(all::ISO_8859_4 as EncodingRef), + "csisolatincyrillic" | + "cyrillic" | + "iso-8859-5" | + "iso-ir-144" | + "iso8859-5" | + "iso88595" | + "iso_8859-5" | + "iso_8859-5:1988" => + Some(all::ISO_8859_5 as EncodingRef), + "arabic" | + "asmo-708" | + "csiso88596e" | + "csiso88596i" | + "csisolatinarabic" | + "ecma-114" | + "iso-8859-6" | + "iso-8859-6-e" | + "iso-8859-6-i" | + "iso-ir-127" | + "iso8859-6" | + "iso88596" | + "iso_8859-6" | + "iso_8859-6:1987" => + Some(all::ISO_8859_6 as EncodingRef), + "csisolatingreek" | + "ecma-118" | + "elot_928" | + "greek" | + "greek8" | + "iso-8859-7" | + "iso-ir-126" | + "iso8859-7" | + "iso88597" | + "iso_8859-7" | + "iso_8859-7:1987" | + "sun_eu_greek" => + Some(all::ISO_8859_7 as EncodingRef), + "csiso88598e" | + "csisolatinhebrew" | + "hebrew" | + "iso-8859-8" | + "iso-8859-8-e" | + "iso-ir-138" | + "iso8859-8" | + "iso88598" | + "iso_8859-8" | + "iso_8859-8:1988" | + "visual" => + Some(all::ISO_8859_8 as EncodingRef), + "csiso88598i" | + "iso-8859-8-i" | + "logical" => + Some(all::whatwg::ISO_8859_8_I as EncodingRef), + "csisolatin6" | + "iso-8859-10" | + "iso-ir-157" | + "iso8859-10" | + "iso885910" | + "l6" | + "latin6" => + Some(all::ISO_8859_10 as EncodingRef), + "iso-8859-13" | + "iso8859-13" | + "iso885913" => + Some(all::ISO_8859_13 as EncodingRef), + "iso-8859-14" | + "iso8859-14" | + "iso885914" => + Some(all::ISO_8859_14 as EncodingRef), + "csisolatin9" | + "iso-8859-15" | + "iso8859-15" | + "iso885915" | + "iso_8859-15" | + "l9" => + Some(all::ISO_8859_15 as EncodingRef), + "iso-8859-16" => + Some(all::ISO_8859_16 as EncodingRef), + "cskoi8r" | + "koi" | + "koi8" | + "koi8-r" | + "koi8_r" => + Some(all::KOI8_R as EncodingRef), + "koi8-u" => + Some(all::KOI8_U as EncodingRef), + "csmacintosh" | + "mac" | + "macintosh" | + "x-mac-roman" => + Some(all::MAC_ROMAN as EncodingRef), + "dos-874" | + "iso-8859-11" | + "iso8859-11" | + "iso885911" | + "tis-620" | + "windows-874" => + Some(all::WINDOWS_874 as EncodingRef), + "cp1250" | + "windows-1250" | + "x-cp1250" => + Some(all::WINDOWS_1250 as EncodingRef), + "cp1251" | + "windows-1251" | + "x-cp1251" => + Some(all::WINDOWS_1251 as EncodingRef), + "ansi_x3.4-1968" | + "ascii" | + "cp1252" | + "cp819" | + "csisolatin1" | + "ibm819" | + "iso-8859-1" | + "iso-ir-100" | + "iso8859-1" | + "iso88591" | + "iso_8859-1" | + "iso_8859-1:1987" | + "l1" | + "latin1" | + "us-ascii" | + "windows-1252" | + "x-cp1252" => + Some(all::WINDOWS_1252 as EncodingRef), + "cp1253" | + "windows-1253" | + "x-cp1253" => + Some(all::WINDOWS_1253 as EncodingRef), + "cp1254" | + "csisolatin5" | + "iso-8859-9" | + "iso-ir-148" | + "iso8859-9" | + "iso88599" | + "iso_8859-9" | + "iso_8859-9:1989" | + "l5" | + "latin5" | + "windows-1254" | + "x-cp1254" => + Some(all::WINDOWS_1254 as EncodingRef), + "cp1255" | + "windows-1255" | + "x-cp1255" => + Some(all::WINDOWS_1255 as EncodingRef), + "cp1256" | + "windows-1256" | + "x-cp1256" => + Some(all::WINDOWS_1256 as EncodingRef), + "cp1257" | + "windows-1257" | + "x-cp1257" => + Some(all::WINDOWS_1257 as EncodingRef), + "cp1258" | + "windows-1258" | + "x-cp1258" => + Some(all::WINDOWS_1258 as EncodingRef), + "x-mac-cyrillic" | + "x-mac-ukrainian" => + Some(all::MAC_CYRILLIC as EncodingRef), + "chinese" | + "csgb2312" | + "csiso58gb231280" | + "gb2312" | + "gb_2312" | + "gb_2312-80" | + "gbk" | + "iso-ir-58" | + "x-gbk" => + Some(all::GBK as EncodingRef), + "gb18030" => + Some(all::GB18030 as EncodingRef), + "big5" | + "big5-hkscs" | + "cn-big5" | + "csbig5" | + "x-x-big5" => + Some(all::BIG5_2003 as EncodingRef), + "cseucpkdfmtjapanese" | + "euc-jp" | + "x-euc-jp" => + Some(all::EUC_JP as EncodingRef), + "csiso2022jp" | + "iso-2022-jp" => + Some(all::ISO_2022_JP as EncodingRef), + "csshiftjis" | + "ms_kanji" | + "shift-jis" | + "shift_jis" | + "sjis" | + "windows-31j" | + "x-sjis" => + Some(all::WINDOWS_31J as EncodingRef), + "cseuckr" | + "csksc56011987" | + "euc-kr" | + "iso-ir-149" | + "korean" | + "ks_c_5601-1987" | + "ks_c_5601-1989" | + "ksc5601" | + "ksc_5601" | + "windows-949" => + Some(all::WINDOWS_949 as EncodingRef), + "csiso2022kr" | + "hz-gb-2312" | + "iso-2022-kr" | + "iso-2022-cn" | + "iso-2022-cn-ext" => + Some(all::whatwg::REPLACEMENT as EncodingRef), + "utf-16be" => + Some(all::UTF_16BE as EncodingRef), + "utf-16" | + "utf-16le" => + Some(all::UTF_16LE as EncodingRef), + "x-user-defined" => + Some(all::whatwg::X_USER_DEFINED as EncodingRef), + _ => None + } +} + +/// Returns an encoding from Windows code page number. +/// http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx +/// Sometimes it can return a *superset* of the requested encoding, e.g. for several CJK encodings. +pub fn encoding_from_windows_code_page(cp: usize) -> Option { + match cp { + 65001 => Some(all::UTF_8 as EncodingRef), + 866 => Some(all::IBM866 as EncodingRef), + 28591 => Some(all::ISO_8859_1 as EncodingRef), + 28592 => Some(all::ISO_8859_2 as EncodingRef), + 28593 => Some(all::ISO_8859_3 as EncodingRef), + 28594 => Some(all::ISO_8859_4 as EncodingRef), + 28595 => Some(all::ISO_8859_5 as EncodingRef), + 28596 => Some(all::ISO_8859_6 as EncodingRef), + 28597 => Some(all::ISO_8859_7 as EncodingRef), + 28598 => Some(all::ISO_8859_8 as EncodingRef), + 38598 => Some(all::whatwg::ISO_8859_8_I as EncodingRef), + 28603 => Some(all::ISO_8859_13 as EncodingRef), + 28605 => Some(all::ISO_8859_15 as EncodingRef), + 20866 => Some(all::KOI8_R as EncodingRef), + 21866 => Some(all::KOI8_U as EncodingRef), + 10000 => Some(all::MAC_ROMAN as EncodingRef), + 874 => Some(all::WINDOWS_874 as EncodingRef), + 1250 => Some(all::WINDOWS_1250 as EncodingRef), + 1251 => Some(all::WINDOWS_1251 as EncodingRef), + 1252 => Some(all::WINDOWS_1252 as EncodingRef), + 1253 => Some(all::WINDOWS_1253 as EncodingRef), + 1254 => Some(all::WINDOWS_1254 as EncodingRef), + 1255 => Some(all::WINDOWS_1255 as EncodingRef), + 1256 => Some(all::WINDOWS_1256 as EncodingRef), + 1257 => Some(all::WINDOWS_1257 as EncodingRef), + 1258 => Some(all::WINDOWS_1258 as EncodingRef), + 1259 => Some(all::MAC_CYRILLIC as EncodingRef), + 936 | 54936 => Some(all::GB18030 as EncodingRef), // XXX technically wrong + 52936 => Some(all::HZ as EncodingRef), + 950 => Some(all::BIG5_2003 as EncodingRef), + 20932 => Some(all::EUC_JP as EncodingRef), + 50220 => Some(all::ISO_2022_JP as EncodingRef), + 932 => Some(all::WINDOWS_31J as EncodingRef), + 949 => Some(all::WINDOWS_949 as EncodingRef), + 1201 => Some(all::UTF_16BE as EncodingRef), + 1200 => Some(all::UTF_16LE as EncodingRef), + _ => None + } +} + +#[cfg(test)] +mod tests { + extern crate test; + use all; + use super::encoding_from_whatwg_label; + + #[test] + fn test_encoding_from_whatwg_label() { + assert!(encoding_from_whatwg_label("utf-8").is_some()); + assert!(encoding_from_whatwg_label("UTF-8").is_some()); + assert!(encoding_from_whatwg_label("\t\n\x0C\r utf-8\t\n\x0C\r ").is_some()); + assert!(encoding_from_whatwg_label("\u{A0}utf-8").is_none(), + "Non-ASCII whitespace should not be trimmed"); + assert!(encoding_from_whatwg_label("greek").is_some()); + assert!(encoding_from_whatwg_label("gree\u{212A}").is_none(), + "Case-insensitive matching should be ASCII only. Kelvin sign does not match k."); + + // checks if the `whatwg_name` method returns the label that resolves back to that encoding + for encoding in all::encodings() { + if let Some(whatwg_name) = encoding.whatwg_name() { + if whatwg_name == "replacement" { continue; } + assert_eq!(encoding_from_whatwg_label(whatwg_name).and_then(|e| e.whatwg_name()), + Some(whatwg_name)); + } + } + } + + #[bench] + fn bench_encoding_from_whatwg_label(bencher: &mut test::Bencher) { + bencher.iter(|| test::black_box({ + encoding_from_whatwg_label("iso-8859-bazinga") + })) + } +} + diff --git a/deps/encoding-0.2.32/src/lib.rs b/deps/encoding-0.2.32/src/lib.rs new file mode 100644 index 000000000..0d88ad951 --- /dev/null +++ b/deps/encoding-0.2.32/src/lib.rs @@ -0,0 +1,276 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +/*! + +# Encoding 0.2.32 + +Character encoding support for Rust. (also known as `rust-encoding`) +It is based on [WHATWG Encoding Standard](http://encoding.spec.whatwg.org/), +and also provides an advanced interface for error detection and recovery. + +## Usage + +Put this in your `Cargo.toml`: + +```toml +[dependencies] +encoding = "0.2" +``` + +Or in the case you are using Rust 1.0 beta, pin the exact version: + +```toml +[dependencies] +encoding = "=0.2.32" +``` + +Then put this in your crate root: + +```rust +extern crate encoding; +``` + +## Overview + +To encode a string: + +~~~~ {.rust} +use encoding::{Encoding, EncoderTrap}; +use encoding::all::ISO_8859_1; + +assert_eq!(ISO_8859_1.encode("caf\u{e9}", EncoderTrap::Strict), + Ok(vec![99,97,102,233])); +~~~~ + +To encode a string with unrepresentable characters: + +~~~~ {.rust} +use encoding::{Encoding, EncoderTrap}; +use encoding::all::ISO_8859_2; + +assert!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::Strict).is_err()); +assert_eq!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::Replace), + Ok(vec![65,99,109,101,63])); +assert_eq!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::Ignore), + Ok(vec![65,99,109,101])); +assert_eq!(ISO_8859_2.encode("Acme\u{a9}", EncoderTrap::NcrEscape), + Ok(vec![65,99,109,101,38,35,49,54,57,59])); +~~~~ + +To decode a byte sequence: + +~~~~ {.rust} +use encoding::{Encoding, DecoderTrap}; +use encoding::all::ISO_8859_1; + +assert_eq!(ISO_8859_1.decode(&[99,97,102,233], DecoderTrap::Strict), + Ok("caf\u{e9}".to_string())); +~~~~ + +To decode a byte sequence with invalid sequences: + +~~~~ {.rust} +use encoding::{Encoding, DecoderTrap}; +use encoding::all::ISO_8859_6; + +assert!(ISO_8859_6.decode(&[65,99,109,101,169], DecoderTrap::Strict).is_err()); +assert_eq!(ISO_8859_6.decode(&[65,99,109,101,169], DecoderTrap::Replace), + Ok("Acme\u{fffd}".to_string())); +assert_eq!(ISO_8859_6.decode(&[65,99,109,101,169], DecoderTrap::Ignore), + Ok("Acme".to_string())); +~~~~ + +To encode or decode the input into the already allocated buffer: + +~~~~ {.rust} +use encoding::{Encoding, EncoderTrap, DecoderTrap}; +use encoding::all::{ISO_8859_2, ISO_8859_6}; + +let mut bytes = Vec::new(); +let mut chars = String::new(); + +assert!(ISO_8859_2.encode_to("Acme\u{a9}", EncoderTrap::Ignore, &mut bytes).is_ok()); +assert!(ISO_8859_6.decode_to(&[65,99,109,101,169], DecoderTrap::Replace, &mut chars).is_ok()); + +assert_eq!(bytes, [65,99,109,101]); +assert_eq!(chars, "Acme\u{fffd}"); +~~~~ + +A practical example of custom encoder traps: + +~~~~ {.rust} +use encoding::{Encoding, ByteWriter, EncoderTrap, DecoderTrap}; +use encoding::types::RawEncoder; +use encoding::all::ASCII; + +// hexadecimal numeric character reference replacement +fn hex_ncr_escape(_encoder: &mut RawEncoder, input: &str, output: &mut ByteWriter) -> bool { + let escapes: Vec = + input.chars().map(|ch| format!("&#x{:x};", ch as isize)).collect(); + let escapes = escapes.concat(); + output.write_bytes(escapes.as_bytes()); + true +} +static HEX_NCR_ESCAPE: EncoderTrap = EncoderTrap::Call(hex_ncr_escape); + +let orig = "Hello, 世界!".to_string(); +let encoded = ASCII.encode(&orig, HEX_NCR_ESCAPE).unwrap(); +assert_eq!(ASCII.decode(&encoded, DecoderTrap::Strict), + Ok("Hello, 世界!".to_string())); +~~~~ + +Getting the encoding from the string label, as specified in WHATWG Encoding standard: + +~~~~ {.rust} +use encoding::{Encoding, DecoderTrap}; +use encoding::label::encoding_from_whatwg_label; +use encoding::all::WINDOWS_949; + +let euckr = encoding_from_whatwg_label("euc-kr").unwrap(); +assert_eq!(euckr.name(), "windows-949"); +assert_eq!(euckr.whatwg_name(), Some("euc-kr")); // for the sake of compatibility +let broken = &[0xbf, 0xec, 0xbf, 0xcd, 0xff, 0xbe, 0xd3]; +assert_eq!(euckr.decode(broken, DecoderTrap::Replace), + Ok("\u{c6b0}\u{c640}\u{fffd}\u{c559}".to_string())); + +// corresponding Encoding native API: +assert_eq!(WINDOWS_949.decode(broken, DecoderTrap::Replace), + Ok("\u{c6b0}\u{c640}\u{fffd}\u{c559}".to_string())); +~~~~ + +## Types and Stuffs + +There are three main entry points to Encoding. + +**`Encoding`** is a single character encoding. +It contains `encode` and `decode` methods for converting `String` to `Vec` and vice versa. +For the error handling, they receive **traps** (`EncoderTrap` and `DecoderTrap` respectively) +which replace any error with some string (e.g. `U+FFFD`) or sequence (e.g. `?`). +You can also use `EncoderTrap::Strict` and `DecoderTrap::Strict` traps to stop on an error. + +There are two ways to get `Encoding`: + +* `encoding::all` has static items for every supported encoding. + You should use them when the encoding would not change or only handful of them are required. + Combined with link-time optimization, any unused encoding would be discarded from the binary. +* `encoding::label` has functions to dynamically get an encoding from given string ("label"). + They will return a static reference to the encoding, which type is also known as `EncodingRef`. + It is useful when a list of required encodings is not available in advance, + but it will result in the larger binary and missed optimization opportunities. + +**`RawEncoder`** is an experimental incremental encoder. +At each step of `raw_feed`, it receives a slice of string +and emits any encoded bytes to a generic `ByteWriter` (normally `Vec`). +It will stop at the first error if any, and would return a `CodecError` struct in that case. +The caller is responsible for calling `raw_finish` at the end of encoding process. + +**`RawDecoder`** is an experimental incremental decoder. +At each step of `raw_feed`, it receives a slice of byte sequence +and emits any decoded characters to a generic `StringWriter` (normally `String`). +Otherwise it is identical to `RawEncoder`s. + +One should prefer `Encoding::{encode,decode}` as a primary interface. +`RawEncoder` and `RawDecoder` is experimental and can change substantially. +See the additional documents on `encoding::types` module for more information on them. + +## Supported Encodings + +Encoding covers all encodings specified by WHATWG Encoding Standard and some more: + +* 7-bit strict ASCII (`ascii`) +* UTF-8 (`utf-8`) +* UTF-16 in little endian (`utf-16` or `utf-16le`) and big endian (`utf-16be`) +* All single byte encoding in WHATWG Encoding Standard: + * IBM code page 866 + * ISO 8859-{2,3,4,5,6,7,8,10,13,14,15,16} + * KOI8-R, KOI8-U + * MacRoman (`macintosh`), Macintosh Cyrillic encoding (`x-mac-cyrillic`) + * Windows code pages 874, 1250, 1251, 1252 (instead of ISO 8859-1), 1253, + 1254 (instead of ISO 8859-9), 1255, 1256, 1257, 1258 +* All multi byte encodings in WHATWG Encoding Standard: + * Windows code page 949 (`euc-kr`, since the strict EUC-KR is hardly used) + * EUC-JP and Windows code page 932 (`shift_jis`, + since it's the most widespread extension to Shift_JIS) + * ISO-2022-JP with asymmetric JIS X 0212 support + (Note: this is not yet up to date to the current standard) + * GBK + * GB 18030 + * Big5-2003 with HKSCS-2008 extensions +* Encodings that were originally specified by WHATWG Encoding Standard: + * HZ +* ISO 8859-1 (distinct from Windows code page 1252) + +Parenthesized names refer to the encoding's primary name assigned by WHATWG Encoding Standard. + +Many legacy character encodings lack the proper specification, +and even those that have a specification are highly dependent of the actual implementation. +Consequently one should be careful when picking a desired character encoding. +The only standards reliable in this regard are WHATWG Encoding Standard and +[vendor-provided mappings from the Unicode consortium](http://www.unicode.org/Public/MAPPINGS/). +Whenever in doubt, look at the source code and specifications for detailed explanations. + +*/ + +#![cfg_attr(test, feature(test))] // lib stability features as per RFC #507 + +extern crate encoding_index_singlebyte as index_singlebyte; +extern crate encoding_index_korean as index_korean; +extern crate encoding_index_japanese as index_japanese; +extern crate encoding_index_simpchinese as index_simpchinese; +extern crate encoding_index_tradchinese as index_tradchinese; + +#[cfg(test)] extern crate test; + +pub use self::types::{CodecError, ByteWriter, StringWriter, + RawEncoder, RawDecoder, EncodingRef, Encoding, + EncoderTrapFunc, DecoderTrapFunc, DecoderTrap, + EncoderTrap, decode}; // reexport + +#[macro_use] mod util; +#[cfg(test)] #[macro_use] mod testutils; + +pub mod types; + +/// Codec implementations. +pub mod codec { + pub mod error; + pub mod ascii; + pub mod singlebyte; + pub mod utf_8; + pub mod utf_16; + pub mod korean; + pub mod japanese; + pub mod simpchinese; + pub mod tradchinese; + pub mod whatwg; +} + +pub mod all; +pub mod label; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_decode() { + fn test_one(input: &[u8], expected_result: &str, expected_encoding: &str) { + let (result, used_encoding) = decode( + input, DecoderTrap::Strict, all::ISO_8859_1 as EncodingRef); + let result = result.unwrap(); + assert_eq!(used_encoding.name(), expected_encoding); + assert_eq!(&result[..], expected_result); + } + + test_one(&[0xEF, 0xBB, 0xBF, 0xC3, 0xA9], "é", "utf-8"); + test_one(&[0xC3, 0xA9], "é", "iso-8859-1"); + + test_one(&[0xFE, 0xFF, 0x00, 0xE9], "é", "utf-16be"); + test_one(&[0x00, 0xE9], "\x00é", "iso-8859-1"); + + test_one(&[0xFF, 0xFE, 0xE9, 0x00], "é", "utf-16le"); + test_one(&[0xE9, 0x00], "é\x00", "iso-8859-1"); + } +} diff --git a/deps/encoding-0.2.32/src/testutils.rs b/deps/encoding-0.2.32/src/testutils.rs new file mode 100644 index 000000000..cd48d6961 --- /dev/null +++ b/deps/encoding-0.2.32/src/testutils.rs @@ -0,0 +1,309 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Macros and utilities for testing. + +use std::borrow::ToOwned; +use types::{RawDecoder, RawEncoder}; + +pub struct TestResult<'a, Output: 'a + ?Sized + ToOwned> { + pub expected_return: (usize, Option), + pub expected_push: &'a Output, + pub actual_return: (usize, Option), + pub actual_push: Output::Owned, +} + +pub trait Testable { + type Input: ?Sized; + type Output: ?Sized + ToOwned; + + fn process_feed_ok<'a>(&mut self, processed: &Self::Input, unprocessed: &Self::Input, + output: &'a Self::Output) -> TestResult<'a, Self::Output>; + fn process_feed_err<'a>(&mut self, backup: isize, + processed: &Self::Input, problem: &Self::Input, remaining: &Self::Input, + output: &'a Self::Output) -> TestResult<'a, Self::Output>; + fn process_finish_ok<'a>(&mut self, output: &'a Self::Output) -> TestResult<'a, Self::Output>; + fn process_finish_err<'a>(&mut self, backup: isize, + output: &'a Self::Output) -> TestResult<'a, Self::Output>; +} + +impl Testable for RawDecoder { + type Input = [u8]; + type Output = str; + + fn process_feed_ok<'a>(&mut self, processed: &[u8], unprocessed: &[u8], + output: &'a str) -> TestResult<'a, str> { + let mut input = Vec::with_capacity(processed.len() + unprocessed.len()); + input.extend(processed.iter().cloned()); + input.extend(unprocessed.iter().cloned()); + + let mut buf = String::new(); + let (nprocessed, err) = self.raw_feed(&input, &mut buf); + TestResult { + expected_return: (processed.len(), None), + expected_push: output, + actual_return: (nprocessed, err.map(|e| e.upto)), + actual_push: buf, + } + } + + fn process_feed_err<'a>(&mut self, backup: isize, processed: &[u8], problem: &[u8], + remaining: &[u8], output: &'a str) -> TestResult<'a, str> { + let mut input = Vec::with_capacity(processed.len() + problem.len() + remaining.len()); + input.extend(processed.iter().cloned()); + input.extend(problem.iter().cloned()); + input.extend(remaining.iter().cloned()); + + let mut buf = String::new(); + let (nprocessed, err) = self.raw_feed(&input[-backup as usize..], &mut buf); + TestResult { + expected_return: (processed.len(), Some(processed.len() as isize + + problem.len() as isize + backup)), + expected_push: output, + actual_return: (nprocessed, err.map(|e| e.upto)), + actual_push: buf, + } + } + + fn process_finish_ok<'a>(&mut self, output: &'a str) -> TestResult<'a, str> { + let mut buf = String::new(); + let err = self.raw_finish(&mut buf); + TestResult { + expected_return: (0, None), + expected_push: output, + actual_return: (0, err.map(|e| e.upto)), + actual_push: buf, + } + } + + fn process_finish_err<'a>(&mut self, backup: isize, output: &'a str) -> TestResult<'a, str> { + let mut buf = String::new(); + let err = self.raw_finish(&mut buf); + TestResult { + expected_return: (0, Some(backup)), + expected_push: output, + actual_return: (0, err.map(|e| e.upto)), + actual_push: buf, + } + } +} + +impl Testable for RawEncoder { + type Input = str; + type Output = [u8]; + + fn process_feed_ok<'a>(&mut self, processed: &str, unprocessed: &str, + output: &'a [u8]) -> TestResult<'a, [u8]> { + let mut input = String::with_capacity(processed.len() + unprocessed.len()); + input.push_str(processed); + input.push_str(unprocessed); + + let mut buf = Vec::new(); + let (nprocessed, err) = self.raw_feed(&input, &mut buf); + TestResult { + expected_return: (processed.len(), None), + expected_push: output, + actual_return: (nprocessed, err.map(|e| e.upto)), + actual_push: buf, + } + } + + fn process_feed_err<'a>(&mut self, backup: isize, processed: &str, problem: &str, + remaining: &str, output: &'a [u8]) -> TestResult<'a, [u8]> { + let mut input = String::with_capacity(processed.len() + problem.len() + remaining.len()); + input.push_str(processed); + input.push_str(problem); + input.push_str(remaining); + + let mut buf = Vec::new(); + let (nprocessed, err) = self.raw_feed(&input[-backup as usize..], &mut buf); + TestResult { + expected_return: (processed.len(), Some(processed.len() as isize + + problem.len() as isize + backup)), + expected_push: output, + actual_return: (nprocessed, err.map(|e| e.upto)), + actual_push: buf, + } + } + + fn process_finish_ok<'a>(&mut self, output: &'a [u8]) -> TestResult<'a, [u8]> { + let mut buf = Vec::new(); + let err = self.raw_finish(&mut buf); + TestResult { + expected_return: (0, None), + expected_push: output, + actual_return: (0, err.map(|e| e.upto)), + actual_push: buf, + } + } + + fn process_finish_err<'a>(&mut self, backup: isize, output: &'a [u8]) -> TestResult<'a, [u8]> { + let mut buf = Vec::new(); + let err = self.raw_finish(&mut buf); + TestResult { + expected_return: (0, Some(backup)), + expected_push: output, + actual_return: (0, err.map(|e| e.upto)), + actual_push: buf, + } + } +} + +macro_rules! assert_expected { + ($result:expr, $func:expr, $filter:expr) => ({ + use testutils::Testable; + match $result { + result => { + assert!(result.expected_return == result.actual_return, + "{} should return {:?}, but instead returned {:?}", + $func, $filter(result.expected_return), $filter(result.actual_return)); + assert!(&result.expected_push[..] == &result.actual_push[..], + "{} should push {:?}, but instead pushed {:?}", + $func, result.expected_push, result.actual_push); + } + } + }); +} + +macro_rules! assert_feed_ok { + ($this:expr, $processed:expr, $unprocessed:expr, $output:expr) => ( + assert_expected!($this.process_feed_ok(&$processed, &$unprocessed, &$output), + "raw_feed", |r| r) + ); +} + +macro_rules! assert_feed_err { + ($this:expr, $backup:expr, $processed:expr, $problem:expr, $remaining:expr, $output:expr) => ( + assert_expected!($this.process_feed_err($backup, &$processed, &$problem, &$remaining, + &$output), + "raw_feed", |r| r) + ); + ($this:expr, $processed:expr, $problem:expr, $remaining:expr, $output:expr) => ( + assert_feed_err!($this, 0, $processed, $problem, $remaining, $output) + ); +} + +macro_rules! assert_finish_ok { + ($this:expr, $output:expr) => ( + assert_expected!($this.process_finish_ok(&$output), + "raw_finish", |r: (usize, Option)| r.0) + ); +} + +macro_rules! assert_finish_err { + ($this:expr, $backup:expr, $output:expr) => ( + assert_expected!($this.process_finish_err($backup, &$output), + "raw_finish", |r: (usize, Option)| r.0) + ); + ($this:expr, $output:expr) => ( + assert_finish_err!($this, 0, $output) + ); +} + +/// Some ASCII-only text to test. +// +// the first paragraphs of the article "English Language" from English Wikipedia. +// https://en.wikipedia.org/w/index.php?title=English_language&oldid=608500518 +pub static ASCII_TEXT: &'static str = + "English is a West Germanic language that was first spoken in early medieval England \ + and is now a global lingua franca. It is spoken as a first language by \ + the majority populations of several sovereign states, including the United Kingdom, \ + the United States, Canada, Australia, Ireland, New Zealand and a number of Caribbean nations; \ + and it is an official language of almost 60 sovereign states. It is the third-most-common \ + native language in the world, after Mandarin Chinese and Spanish. It is widely learned as \ + a second language and is an official language of the European Union, many Commonwealth \ + countries and the United Nations, as well as in many world organisations."; + +/// Some Korean text to test. +// +// the first paragraphs of the article "Korean Language" from Korean Wikipedia. +// https://ko.wikipedia.org/w/index.php?title=%ED%95%9C%EA%B5%AD%EC%96%B4&oldid=12331875 +pub static KOREAN_TEXT: &'static str = + "한국어(韓國語)는 주로 한반도(韓半島)와 한민족(韓民族) 거주 지역에서 쓰이는 언어로, \ + 대한민국에서는 한국어, 한국말이라고 부르고, 조선민주주의인민공화국과 중국, 일본에서는 \ + 조선어(朝鮮語), 조선말이라고 불린다. 우즈베키스탄, 러시아 등 구 소련의 고려인들 사이에서는 \ + 고려말(高麗語)로 불린다. 19세기 중반 이후 한반도와 주변 정세의 혼란, 20세기 전반 \ + 일본 제국주의의 침략, 20세기 후반 대한민국의 해외 이민에 의해 중국 동북 지방, 일본, \ + 러시아 연해주와 사할린, 우즈베키스탄, 미국, 캐나다, 오스트레일리아, 필리핀, 베트남, 브라질 등 \ + 세계 곳곳에 한민족이 이주하면서 한국어가 쓰이고 있다. 한국어 쓰는 인구는 전 세계를 통틀어 \ + 약 8천250만 명으로 추산된다."; + +/// Some Japanese text to test. +// +// the first paragraphs of the article "Japanese Language" from Japanese Wikipedia. +// https://ja.wikipedia.org/w/index.php?title=%E6%97%A5%E6%9C%AC%E8%AA%9E&oldid=51443986 +pub static JAPANESE_TEXT: &'static str = + "日本語(にほんご、にっぽんご)とは、主に日本国内や日本人同士の間で使われている言語である。\ + 日本は法令によって「公用語」を規定していないが、法令その他の公用文は日本語で記述され、\ + 各種法令(裁判所法第74条、会社計算規則第57条、特許法施行規則第2条など)において\ + 日本語を用いることが定められるなど事実上の公用語となっており、学校教育の「国語」でも\ + 教えられる。使用人口について正確な統計はないが、日本国内の人口、および日本国外に住む\ + 日本人や日系人、日本がかつて統治した地域の一部の住民など、約1億3千万人以上と考えられる。\ + 統計によって前後する可能性はあるが、この数は世界の母語話者数で上位10位以内に入る人数である。"; + +/// Some simplified Chinese text to test. +// +// the first paragraphs of the article "Chinese Language" from Chinese Wikipedia. +// https://zh.wikipedia.org/w/index.php?title=%E6%B1%89%E8%AF%AD&variant=zh-cn&oldid=31224104 +pub static SIMPLIFIED_CHINESE_TEXT: &'static str = + "汉语,又称中文、华语(东南亚)、国语(中华民国国语)、中国语(日本、韩国等),\ + 其他名称有汉文(通常指文言文)、华文、唐文、唐话、中国话等,是属汉藏语系的分析语,具有声调。\ + 汉语的文字系统——汉字是一种意音文字,表意的同时也具一定的表音功能。\ + 汉语包含书面语以及口语两部分,古代书面汉语称为文言文,现代书面汉语一般指使用现代标准汉语语法,\ + 词汇的中文通行文体。目前全球有六分之一人口使用汉语作为母语。现代汉语书面语高度统一,\ + 口语则有官话、粤语、吴语、湘语、赣语、客家语、闽语等七种主要汉语言\ + (也有人认为晋语和(或)徽语和(或)平话(广西平话)也应为独立汉语言,\ + 也有其他人认为闽语其实是一个语族,下辖闽南语、闽东语、闽中语以及莆仙语,\ + 国际标准化组织即持此观点,部分资料将其中的一至六种也算成单独的汉语言,\ + 这就是八至十三种汉语言的由来)。"; + +/// Some traditional Chinese text to test. +// +// the first paragraphs of the article "Chinese Language" from Chinese Wikipedia. +// https://zh.wikipedia.org/w/index.php?title=%E6%B1%89%E8%AF%AD&variant=zh-tw&oldid=31224104 +pub static TRADITIONAL_CHINESE_TEXT: &'static str = + "漢語,又稱中文、華語(東南亞)、國語(中華民國國語)、中國語(日本、韓國等),\ + 其他名稱有漢文(通常指文言文)、華文、唐文、唐話、中國話等,是屬漢藏語系的分析語,具有聲調。\ + 漢語的文字系統——漢字是一種意音文字,表意的同時也具一定的表音功能。\ + 漢語包含書面語以及口語兩部分,古代書面漢語稱為文言文,現代書面漢語一般指使用現代標準漢語語法,\ + 詞彙的中文通行文體。目前全球有六分之一人口使用漢語作為母語。現代漢語書面語高度統一,\ + 口語則有官話、粵語、吳語、湘語、贛語、客家語、閩語等七種主要漢語言\ + (也有人認為晉語和(或)徽語和(或)平話(廣西平話)也應為獨立漢語言,\ + 也有其他人認為閩語其實是一個語族,下轄閩南語、閩東語、閩中語以及莆仙語,\ + 國際標準化組織即持此觀點,部分資料將其中的一至六種也算成單獨的漢語言,\ + 這就是八至十三種漢語言的由來)。"; + +/// Some text with various invalid UTF-8 sequences. +// +// Markus Kuhn's UTF-8 decoder capability and stress test. +// http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt +pub static INVALID_UTF8_TEXT: &'static [u8] = include_bytes!("examples/UTF-8-test.txt"); + +/// Returns a longer text used for external data benchmarks. +/// This can be overriden with an environment variable `EXTERNAL_BENCH_DATA`, +/// or it will use a built-in sample data (of about 100KB). +pub fn get_external_bench_data() -> Vec { + use std::env; + use std::io::Read; + use std::fs::File; + use std::path::Path; + + // An HTML file derived from the Outer Space Treaty of 1967, in six available languages. + // http://www.unoosa.org/oosa/SpaceLaw/outerspt.html + static LONGER_TEXT: &'static [u8] = include_bytes!("examples/outer-space-treaty.html"); + + match env::var("EXTERNAL_BENCH_DATA") { + Ok(path) => { + let path = Path::new(&path); + let mut file = File::open(&path).ok().expect("cannot read an external bench data"); + let mut ret = Vec::new(); + file.read_to_end(&mut ret).ok().expect("cannot read an external bench data"); + ret + } + Err(..) => { + LONGER_TEXT.to_vec() + } + } +} + diff --git a/deps/encoding-0.2.32/src/types.rs b/deps/encoding-0.2.32/src/types.rs new file mode 100644 index 000000000..3e5b103c1 --- /dev/null +++ b/deps/encoding-0.2.32/src/types.rs @@ -0,0 +1,513 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +/*! + * Interface to the character encoding. + * + * # Raw incremental interface + * + * Methods which name starts with `raw_` constitute the raw incremental interface, + * the lowest-available API for encoders and decoders. + * This interface divides the entire input to four parts: + * + * - **Processed** bytes do not affect the future result. + * - **Unprocessed** bytes may affect the future result + * and can be a part of problematic sequence according to the future input. + * - **Problematic** byte is the first byte that causes an error condition. + * - **Remaining** bytes are not yet processed nor read, + * so the caller should feed any remaining bytes again. + * + * The following figure illustrates an example of successive `raw_feed` calls: + * + * ````notrust + * 1st raw_feed :2nd raw_feed :3rd raw_feed + * ----------+----:---------------:--+--+--------- + * | : : | | + * ----------+----:---------------:--+--+--------- + * processed unprocessed | remaining + * problematic + * ```` + * + * Since these parts can span the multiple input sequences to `raw_feed`, + * `raw_feed` returns two offsets (one optional) + * with that the caller can track the problematic sequence. + * The first offset (the first `usize` in the tuple) points to the first unprocessed bytes, + * or is zero when unprocessed bytes have started before the current call. + * (The first unprocessed byte can also be at offset 0, + * which doesn't make a difference for the caller.) + * The second offset (`upto` field in the `CodecError` struct), if any, + * points to the first remaining bytes. + * + * If the caller needs to recover the error via the problematic sequence, + * then the caller starts to save the unprocessed bytes when the first offset < the input length, + * appends any new unprocessed bytes while the first offset is zero, + * and discards unprocessed bytes when first offset becomes non-zero + * while saving new unprocessed bytes when the first offset < the input length. + * Then the caller checks for the error condition + * and can use the saved unprocessed bytes for error recovery. + * Alternatively, if the caller only wants to replace the problematic sequence + * with a fixed string (like U+FFFD), + * then it can just discard the first sequence and can emit the fixed string on an error. + * It still has to feed the input bytes starting at the second offset again. + */ +use std::borrow::Cow; + +/// Error information from either encoder or decoder. +pub struct CodecError { + /// The byte position of the first remaining byte, with respect to the *current* input. + /// For the `finish` call, this should be no more than zero (since there is no input). + /// It can be negative if the remaining byte is in the prior inputs, + /// as long as the remaining byte is not yet processed. + /// The caller should feed the bytes starting from this point again + /// in order to continue encoding or decoding after an error. + pub upto: isize, + /// A human-readable cause of the error. + pub cause: Cow<'static, str>, +} + +/// Byte writer used by encoders. In most cases this will be an owned vector of `u8`. +pub trait ByteWriter { + /// Hints an expected lower bound on the length (in bytes) of the output + /// until the next call to `writer_hint`, + /// so that the writer can reserve the memory for writing. + /// `RawEncoder`s are recommended but not required to call this method + /// with an appropriate estimate. + /// By default this method does nothing. + fn writer_hint(&mut self, _expectedlen: usize) {} + + /// Writes a single byte. + fn write_byte(&mut self, b: u8); + + /// Writes a number of bytes. + fn write_bytes(&mut self, v: &[u8]); +} + +impl ByteWriter for Vec { + fn writer_hint(&mut self, expectedlen: usize) { + self.reserve(expectedlen); + } + + fn write_byte(&mut self, b: u8) { + self.push(b); + } + + fn write_bytes(&mut self, v: &[u8]) { + self.extend(v.iter().cloned()); + } +} + +/// String writer used by decoders. In most cases this will be an owned string. +pub trait StringWriter { + /// Hints an expected lower bound on the length (in bytes) of the output + /// until the next call to `writer_hint`, + /// so that the writer can reserve the memory for writing. + /// `RawDecoder`s are recommended but not required to call this method + /// with an appropriate estimate. + /// By default this method does nothing. + fn writer_hint(&mut self, _expectedlen: usize) {} + + /// Writes a single character. + fn write_char(&mut self, c: char); + + /// Writes a string. + fn write_str(&mut self, s: &str); +} + +impl StringWriter for String { + fn writer_hint(&mut self, expectedlen: usize) { + let newlen = self.len() + expectedlen; + self.reserve(newlen); + } + + fn write_char(&mut self, c: char) { + self.push(c); + } + + fn write_str(&mut self, s: &str) { + self.push_str(s); + } +} + +/// Encoder converting a Unicode string into a byte sequence. +/// This is a lower level interface, and normally `Encoding::encode` should be used instead. +pub trait RawEncoder: 'static { + /// Creates a fresh `RawEncoder` instance which parameters are same as `self`. + fn from_self(&self) -> Box; + + /// Returns true if this encoding is compatible to ASCII, + /// i.e. U+0000 through U+007F always map to bytes 00 through 7F and nothing else. + fn is_ascii_compatible(&self) -> bool { false } + + /// Feeds given portion of string to the encoder, + /// pushes the an encoded byte sequence at the end of the given output, + /// and returns a byte offset to the first unprocessed character + /// (that can be zero when the first such character appeared in the prior calls to `raw_feed`) + /// and optional error information (None means success). + fn raw_feed(&mut self, input: &str, output: &mut ByteWriter) -> (usize, Option); + + /// Finishes the encoder, + /// pushes the an encoded byte sequence at the end of the given output, + /// and returns optional error information (None means success). + /// `remaining` value of the error information, if any, is always an empty string. + fn raw_finish(&mut self, output: &mut ByteWriter) -> Option; +} + +/// Decoder converting a byte sequence into a Unicode string. +/// This is a lower level interface, and normally `Encoding::decode` should be used instead. +pub trait RawDecoder: 'static { + /// Creates a fresh `RawDecoder` instance which parameters are same as `self`. + fn from_self(&self) -> Box; + + /// Returns true if this encoding is compatible to ASCII, + /// i.e. bytes 00 through 7F always map to U+0000 through U+007F and nothing else. + fn is_ascii_compatible(&self) -> bool { false } + + /// Feeds given portion of byte sequence to the encoder, + /// pushes the a decoded string at the end of the given output, + /// and returns an offset to the first unprocessed byte + /// (that can be zero when the first such byte appeared in the prior calls to `raw_feed`) + /// and optional error information (None means success). + fn raw_feed(&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option); + + /// Finishes the decoder, + /// pushes the a decoded string at the end of the given output, + /// and returns optional error information (None means success). + fn raw_finish(&mut self, output: &mut StringWriter) -> Option; +} + +/// A trait object using dynamic dispatch which is a sendable reference to the encoding, +/// for code where the encoding is not known at compile-time. +pub type EncodingRef = &'static (Encoding + Send + Sync); + +/// Character encoding. +pub trait Encoding { + /// Returns the canonical name of given encoding. + /// This name is guaranteed to be unique across built-in encodings, + /// but it is not normative and would be at most arbitrary. + fn name(&self) -> &'static str; + + /// Returns a name of given encoding defined in the WHATWG Encoding standard, if any. + /// This name often differs from `name` due to the compatibility reason. + fn whatwg_name(&self) -> Option<&'static str> { None } + + /// Creates a new encoder. + fn raw_encoder(&self) -> Box; + + /// Creates a new decoder. + fn raw_decoder(&self) -> Box; + + /// An easy-to-use interface to `RawEncoder`. + /// On the encoder error `trap` is called, + /// which may return a replacement sequence to continue processing, + /// or a failure to return the error. + fn encode(&self, input: &str, trap: EncoderTrap) -> Result, Cow<'static, str>> { + let mut ret = Vec::new(); + self.encode_to(input, trap, &mut ret).map(|_| ret) + } + + /// Encode into a `ByteWriter`. + fn encode_to(&self, input: &str, trap: EncoderTrap, ret: &mut ByteWriter) + -> Result<(), Cow<'static, str>> + { + // we don't need to keep `unprocessed` here; + // `raw_feed` should process as much input as possible. + let mut encoder = self.raw_encoder(); + let mut remaining = 0; + + loop { + let (offset, err) = encoder.raw_feed(&input[remaining..], ret); + let unprocessed = remaining + offset; + match err { + Some(err) => { + remaining = (remaining as isize + err.upto) as usize; + if !trap.trap(&mut *encoder, &input[unprocessed..remaining], ret) { + return Err(err.cause); + } + } + None => { + remaining = input.len(); + match encoder.raw_finish(ret) { + Some(err) => { + remaining = (remaining as isize + err.upto) as usize; + if !trap.trap(&mut *encoder, &input[unprocessed..remaining], ret) { + return Err(err.cause); + } + } + None => {} + } + if remaining >= input.len() { return Ok(()); } + } + } + } + } + + /// An easy-to-use interface to `RawDecoder`. + /// On the decoder error `trap` is called, + /// which may return a replacement string to continue processing, + /// or a failure to return the error. + fn decode(&self, input: &[u8], trap: DecoderTrap) -> Result> { + let mut ret = String::new(); + self.decode_to(input, trap, &mut ret).map(|_| ret) + } + + /// Decode into a `StringWriter`. + /// + /// This does *not* handle partial characters at the beginning or end of `input`! + /// Use `RawDecoder` for incremental decoding. + fn decode_to(&self, input: &[u8], trap: DecoderTrap, ret: &mut StringWriter) + -> Result<(), Cow<'static, str>> + { + // we don't need to keep `unprocessed` here; + // `raw_feed` should process as much input as possible. + let mut decoder = self.raw_decoder(); + let mut remaining = 0; + + loop { + let (offset, err) = decoder.raw_feed(&input[remaining..], ret); + let unprocessed = remaining + offset; + match err { + Some(err) => { + remaining = (remaining as isize + err.upto) as usize; + if !trap.trap(&mut *decoder, &input[unprocessed..remaining], ret) { + return Err(err.cause); + } + } + None => { + remaining = input.len(); + match decoder.raw_finish(ret) { + Some(err) => { + remaining = (remaining as isize + err.upto) as usize; + if !trap.trap(&mut *decoder, &input[unprocessed..remaining], ret) { + return Err(err.cause); + } + } + None => {} + } + if remaining >= input.len() { return Ok(()); } + } + } + } + } +} + +/// A type of the bare function in `EncoderTrap` values. +pub type EncoderTrapFunc = + extern "Rust" fn(encoder: &mut RawEncoder, input: &str, output: &mut ByteWriter) -> bool; + +/// A type of the bare function in `DecoderTrap` values. +pub type DecoderTrapFunc = + extern "Rust" fn(decoder: &mut RawDecoder, input: &[u8], output: &mut StringWriter) -> bool; + +/// Trap, which handles decoder errors. +#[derive(Copy)] +pub enum DecoderTrap { + /// Immediately fails on errors. + /// Corresponds to WHATWG "fatal" error algorithm. + Strict, + /// Replaces an error with a U+FFFD (decoder). + /// Corresponds to WHATWG "replacement" error algorithm. + Replace, + /// Silently ignores an error, effectively replacing it with an empty sequence. + Ignore, + /// Calls given function to handle decoder errors. + /// The function is given the current decoder, input and output writer, + /// and should return true only when it is fine to keep going. + Call(DecoderTrapFunc), +} + +impl DecoderTrap { + /// Handles a decoder error. May write to the output writer. + /// Returns true only when it is fine to keep going. + pub fn trap(&self, decoder: &mut RawDecoder, input: &[u8], output: &mut StringWriter) -> bool { + match *self { + DecoderTrap::Strict => false, + DecoderTrap::Replace => { output.write_char('\u{fffd}'); true }, + DecoderTrap::Ignore => true, + DecoderTrap::Call(func) => func(decoder, input, output), + } + } +} + +impl Clone for DecoderTrap { + fn clone(&self) -> DecoderTrap { + match *self { + DecoderTrap::Strict => DecoderTrap::Strict, + DecoderTrap::Replace => DecoderTrap::Replace, + DecoderTrap::Ignore => DecoderTrap::Ignore, + DecoderTrap::Call(f) => DecoderTrap::Call(f), + } + } +} + +#[derive(Copy)] +pub enum EncoderTrap { + /// Immediately fails on errors. + /// Corresponds to WHATWG "fatal" error algorithm. + Strict, + /// Replaces an error with `?` in given encoding. + /// Note that this fails when `?` cannot be represented in given encoding. + /// Corresponds to WHATWG "URL" error algorithms. + Replace, + /// Silently ignores an error, effectively replacing it with an empty sequence. + Ignore, + /// Replaces an error with XML numeric character references (e.g. `Ӓ`). + /// The encoder trap fails when NCRs cannot be represented in given encoding. + /// Corresponds to WHATWG "
" error algorithms. + NcrEscape, + /// Calls given function to handle encoder errors. + /// The function is given the current encoder, input and output writer, + /// and should return true only when it is fine to keep going. + Call(EncoderTrapFunc), +} + +impl EncoderTrap { + /// Handles an encoder error. May write to the output writer. + /// Returns true only when it is fine to keep going. + pub fn trap(&self, encoder: &mut RawEncoder, input: &str, output: &mut ByteWriter) -> bool { + fn reencode(encoder: &mut RawEncoder, input: &str, output: &mut ByteWriter, + trapname: &str) -> bool { + if encoder.is_ascii_compatible() { // optimization! + output.write_bytes(input.as_bytes()); + } else { + let (_, err) = encoder.raw_feed(input, output); + if err.is_some() { + panic!("{} cannot reencode a replacement string", trapname); + } + } + true + } + + match *self { + EncoderTrap::Strict => false, + EncoderTrap::Replace => reencode(encoder, "?", output, "Replace"), + EncoderTrap::Ignore => true, + EncoderTrap::NcrEscape => { + let mut escapes = String::new(); + for ch in input.chars() { + escapes.push_str(&format!("&#{};", ch as isize)); + } + reencode(encoder, &escapes, output, "NcrEscape") + }, + EncoderTrap::Call(func) => func(encoder, input, output), + } + } +} + +impl Clone for EncoderTrap { + fn clone(&self) -> EncoderTrap { + match *self { + EncoderTrap::Strict => EncoderTrap::Strict, + EncoderTrap::Replace => EncoderTrap::Replace, + EncoderTrap::Ignore => EncoderTrap::Ignore, + EncoderTrap::NcrEscape => EncoderTrap::NcrEscape, + EncoderTrap::Call(f) => EncoderTrap::Call(f), + } + } +} + +/// Determine the encoding by looking for a Byte Order Mark (BOM) +/// and decoded a single string in memory. +/// Return the result and the used encoding. +pub fn decode(input: &[u8], trap: DecoderTrap, fallback_encoding: EncodingRef) + -> (Result>, EncodingRef) { + use all::{UTF_8, UTF_16LE, UTF_16BE}; + if input.starts_with(&[0xEF, 0xBB, 0xBF]) { + (UTF_8.decode(&input[3..], trap), UTF_8 as EncodingRef) + } else if input.starts_with(&[0xFE, 0xFF]) { + (UTF_16BE.decode(&input[2..], trap), UTF_16BE as EncodingRef) + } else if input.starts_with(&[0xFF, 0xFE]) { + (UTF_16LE.decode(&input[2..], trap), UTF_16LE as EncodingRef) + } else { + (fallback_encoding.decode(input, trap), fallback_encoding) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use super::EncoderTrap::NcrEscape; + use util::StrCharIndex; + use std::convert::Into; + + // a contrived encoding example: same as ASCII, but inserts `prepend` between each character + // within two "e"s (so that `widespread` becomes `wide*s*p*r*ead` and `eeeeasel` becomes + // `e*ee*ease*l` where `*` is substituted by `prepend`) and prohibits `prohibit` character. + struct MyEncoder { flag: bool, prohibit: char, prepend: &'static str, toggle: bool } + impl RawEncoder for MyEncoder { + fn from_self(&self) -> Box { + Box::new(MyEncoder { flag: self.flag, + prohibit: self.prohibit, + prepend: self.prepend, + toggle: false }) + } + fn is_ascii_compatible(&self) -> bool { self.flag } + fn raw_feed(&mut self, input: &str, + output: &mut ByteWriter) -> (usize, Option) { + for ((i,j), ch) in input.index_iter() { + if ch <= '\u{7f}' && ch != self.prohibit { + if self.toggle && !self.prepend.is_empty() { + output.write_bytes(self.prepend.as_bytes()); + } + output.write_byte(ch as u8); + if ch == 'e' { + self.toggle = !self.toggle; + } + } else { + return (i, Some(CodecError { upto: j as isize, + cause: "!!!".into() })); + } + } + (input.len(), None) + } + fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option { None } + } + + struct MyEncoding { flag: bool, prohibit: char, prepend: &'static str } + impl Encoding for MyEncoding { + fn name(&self) -> &'static str { "my encoding" } + fn raw_encoder(&self) -> Box { + Box::new(MyEncoder { flag: self.flag, + prohibit: self.prohibit, + prepend: self.prepend, + toggle: false }) + } + fn raw_decoder(&self) -> Box { panic!("not supported") } + } + + #[test] + fn test_reencoding_trap_with_ascii_compatible_encoding() { + static COMPAT: &'static MyEncoding = + &MyEncoding { flag: true, prohibit: '\u{80}', prepend: "" }; + static INCOMPAT: &'static MyEncoding = + &MyEncoding { flag: false, prohibit: '\u{80}', prepend: "" }; + + assert_eq!(COMPAT.encode("Hello\u{203d} I'm fine.", NcrEscape), + Ok(b"Hello‽ I'm fine.".to_vec())); + assert_eq!(INCOMPAT.encode("Hello\u{203d} I'm fine.", NcrEscape), + Ok(b"Hello‽ I'm fine.".to_vec())); + } + + #[test] + fn test_reencoding_trap_with_ascii_incompatible_encoding() { + static COMPAT: &'static MyEncoding = + &MyEncoding { flag: true, prohibit: '\u{80}', prepend: "*" }; + static INCOMPAT: &'static MyEncoding = + &MyEncoding { flag: false, prohibit: '\u{80}', prepend: "*" }; + + // this should behave incorrectly as the encoding broke the assumption. + assert_eq!(COMPAT.encode("Hello\u{203d} I'm fine.", NcrEscape), + Ok(b"He*l*l*o‽* *I*'*m* *f*i*n*e.".to_vec())); + assert_eq!(INCOMPAT.encode("Hello\u{203d} I'm fine.", NcrEscape), + Ok(b"He*l*l*o*&*#*8*2*5*3*;* *I*'*m* *f*i*n*e.".to_vec())); + } + + #[test] + #[should_panic] + fn test_reencoding_trap_can_fail() { + static FAIL: &'static MyEncoding = &MyEncoding { flag: false, prohibit: '&', prepend: "" }; + + // this should fail as this contrived encoding does not support `&` at all + let _ = FAIL.encode("Hello\u{203d} I'm fine.", NcrEscape); + } +} diff --git a/deps/encoding-0.2.32/src/util.rs b/deps/encoding-0.2.32/src/util.rs new file mode 100644 index 000000000..1d313aa7c --- /dev/null +++ b/deps/encoding-0.2.32/src/util.rs @@ -0,0 +1,322 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Internal utilities. + +use std::{str, char, mem}; +use std::marker::PhantomData; +use std::convert::Into; +use std::default::Default; +use types; + +/// Unchecked conversion to `char`. +pub fn as_char(ch: u32) -> char { + debug_assert!(char::from_u32(ch).is_some()); + unsafe { mem::transmute(ch) } +} + +/// External iterator for a string's characters with its corresponding byte offset range. +pub struct StrCharIndexIterator<'r> { + index: usize, + chars: str::Chars<'r>, +} + +impl<'r> Iterator for StrCharIndexIterator<'r> { + type Item = ((usize,usize), char); + + #[inline] + fn next(&mut self) -> Option<((usize,usize), char)> { + if let Some(ch) = self.chars.next() { + let prev = self.index; + let next = prev + ch.len_utf8(); + self.index = next; + Some(((prev, next), ch)) + } else { + None + } + } +} + +/// A trait providing an `index_iter` method. +pub trait StrCharIndex<'r> { + fn index_iter(&self) -> StrCharIndexIterator<'r>; +} + +impl<'r> StrCharIndex<'r> for &'r str { + /// Iterates over each character with corresponding byte offset range. + fn index_iter(&self) -> StrCharIndexIterator<'r> { + StrCharIndexIterator { index: 0, chars: self.chars() } + } +} + +/// A helper struct for the stateful decoder DSL. +pub struct StatefulDecoderHelper<'a, St, Data: 'a> { + /// The current buffer. + pub buf: &'a [u8], + /// The current index to the buffer. + pub pos: usize, + /// The output buffer. + pub output: &'a mut (types::StringWriter + 'a), + /// The last codec error. The caller will later collect this. + pub err: Option, + /// The additional data attached for the use from transition functions. + pub data: &'a Data, + /// A marker for the phantom type parameter `St`. + _marker: PhantomData, +} + +impl<'a, St: Default, Data> StatefulDecoderHelper<'a, St, Data> { + /// Makes a new decoder context out of given buffer and output callback. + #[inline(always)] + pub fn new(buf: &'a [u8], output: &'a mut (types::StringWriter + 'a), + data: &'a Data) -> StatefulDecoderHelper<'a, St, Data> { + StatefulDecoderHelper { buf: buf, pos: 0, output: output, err: None, + data: data, _marker: PhantomData } + } + + /// Reads one byte from the buffer if any. + #[inline(always)] + pub fn read(&mut self) -> Option { + match self.buf.get(self.pos) { + Some(&c) => { self.pos += 1; Some(c) } + None => None + } + } + + /// Resets back to the initial state. + /// This should be the last expr in the rules. + #[inline(always)] + pub fn reset(&self) -> St { + Default::default() + } + + /// Writes one Unicode scalar value to the output. + /// There is intentionally no check for `c`, so the caller should ensure that it's valid. + /// If this is the last expr in the rules, also resets back to the initial state. + #[inline(always)] + pub fn emit(&mut self, c: u32) -> St { + self.output.write_char(unsafe {mem::transmute(c)}); + Default::default() + } + + /// Writes a Unicode string to the output. + /// If this is the last expr in the rules, also resets back to the initial state. + #[inline(always)] + pub fn emit_str(&mut self, s: &str) -> St { + self.output.write_str(s); + Default::default() + } + + /// Issues a codec error with given message at the current position. + /// If this is the last expr in the rules, also resets back to the initial state. + #[inline(always)] + pub fn err(&mut self, msg: &'static str) -> St { + self.err = Some(types::CodecError { upto: self.pos as isize, cause: msg.into() }); + Default::default() + } + + /// Issues a codec error with given message at the current position minus `backup` bytes. + /// If this is the last expr in the rules, also resets back to the initial state. + /// + /// This should be used to implement "prepending byte to the stream" in the Encoding spec, + /// which corresponds to `ctx.backup_and_err(1, ...)`. + #[inline(always)] + pub fn backup_and_err(&mut self, backup: usize, msg: &'static str) -> St { + let upto = self.pos as isize - backup as isize; + self.err = Some(types::CodecError { upto: upto, cause: msg.into() }); + Default::default() + } +} + +/// Defines a stateful decoder from given state machine. +macro_rules! stateful_decoder { + ( + module $stmod:ident; // should be unique from other existing identifiers + $(internal $item:item)* // will only be visible from state functions + initial: + state $inist:ident($inictx:ident: Context) { + $(case $($inilhs:pat),+ => $($inirhs:expr),+;)+ + final => $($inifin:expr),+; + } + checkpoint: + $(state $ckst:ident($ckctx:ident: Context $(, $ckarg:ident: $ckty:ty)*) { + $(case $($cklhs:pat),+ => $($ckrhs:expr),+;)+ + final => $($ckfin:expr),+; + })* + transient: + $(state $st:ident($ctx:ident: Context $(, $arg:ident: $ty:ty)*) { + $(case $($lhs:pat),+ => $($rhs:expr),+;)+ + final => $($fin:expr),+; + })* + ) => ( + #[allow(non_snake_case)] + mod $stmod { + pub use self::State::*; + + #[derive(PartialEq, Clone, Copy)] + pub enum State { + $inist, + $( + $ckst(() $(, $ckty)*), + )* + $( + $st(() $(, $ty)*), + )* + } + + impl ::std::default::Default for State { + #[inline(always)] fn default() -> State { $inist } + } + + pub mod internal { + pub type Context<'a, Data> = ::util::StatefulDecoderHelper<'a, super::State, Data>; + + $($item)* + } + + pub mod start { + use super::internal::*; + + #[inline(always)] + pub fn $inist($inictx: &mut Context) -> super::State { + // prohibits all kind of recursions, including self-recursions + #[allow(unused_imports)] use super::transient::*; + match $inictx.read() { + None => super::$inist, + Some(c) => match c { $($($inilhs)|+ => { $($inirhs);+ })+ }, + } + } + + $( + #[inline(always)] + pub fn $ckst($ckctx: &mut Context $(, $ckarg: $ckty)*) -> super::State { + // prohibits all kind of recursions, including self-recursions + #[allow(unused_imports)] use super::transient::*; + match $ckctx.read() { + None => super::$ckst(() $(, $ckarg)*), + Some(c) => match c { $($($cklhs)|+ => { $($ckrhs);+ })+ }, + } + } + )* + } + + pub mod transient { + use super::internal::*; + + #[inline(always)] + #[allow(dead_code)] + pub fn $inist(_: &mut Context) -> super::State { + super::$inist // do not recurse further + } + + $( + #[inline(always)] + #[allow(dead_code)] + pub fn $ckst(_: &mut Context $(, $ckarg: $ckty)*) -> super::State { + super::$ckst(() $(, $ckarg)*) // do not recurse further + } + )* + + $( + #[inline(always)] + pub fn $st($ctx: &mut Context $(, $arg: $ty)*) -> super::State { + match $inictx.read() { + None => super::$st(() $(, $arg)*), + Some(c) => match c { $($($lhs)|+ => { $($rhs);+ })+ }, + } + } + )* + } + + pub fn raw_feed(mut st: State, input: &[u8], output: &mut ::types::StringWriter, + data: &T) -> (State, usize, Option<::types::CodecError>) { + output.writer_hint(input.len()); + + let mut ctx = ::util::StatefulDecoderHelper::new(input, output, data); + let mut processed = 0; + + let st_ = match st { + $inist => $inist, + $( + $ckst(() $(, $ckarg)*) => start::$ckst(&mut ctx $(, $ckarg)*), + )* + $( + $st(() $(, $arg)*) => transient::$st(&mut ctx $(, $arg)*), + )* + }; + match (ctx.err.take(), st_) { + (None, $inist) $(| (None, $ckst(..)))* => { st = st_; processed = ctx.pos; } + // XXX splitting the match case improves the performance somehow, but why? + (None, _) => { return (st_, processed, None); } + (Some(err), _) => { return (st_, processed, Some(err)); } + } + + while ctx.pos < ctx.buf.len() { + let st_ = match st { + $inist => start::$inist(&mut ctx), + $( + $ckst(() $(, $ckarg)*) => start::$ckst(&mut ctx $(, $ckarg)*), + )* + _ => unreachable!(), + }; + match (ctx.err.take(), st_) { + (None, $inist) $(| (None, $ckst(..)))* => { st = st_; processed = ctx.pos; } + // XXX splitting the match case improves the performance somehow, but why? + (None, _) => { return (st_, processed, None); } + (Some(err), _) => { return (st_, processed, Some(err)); } + } + } + + (st, processed, None) + } + + pub fn raw_finish(mut st: State, output: &mut ::types::StringWriter, + data: &T) -> (State, Option<::types::CodecError>) { + #![allow(unused_mut, unused_variables)] + let mut ctx = ::util::StatefulDecoderHelper::new(&[], output, data); + let st = match ::std::mem::replace(&mut st, $inist) { + $inist => { let $inictx = &mut ctx; $($inifin);+ }, + $( + $ckst(() $(, $ckarg)*) => { let $ckctx = &mut ctx; $($ckfin);+ }, + )* + $( + $st(() $(, $arg)*) => { let $ctx = &mut ctx; $($fin);+ }, + )* + }; + (st, ctx.err.take()) + } + } + ); + + // simplified rules: no checkpoint and default final actions + ( + module $stmod:ident; // should be unique from other existing identifiers + $(internal $item:item)* // will only be visible from state functions + initial: + state $inist:ident($inictx:ident: Context) { + $(case $($inilhs:pat),+ => $($inirhs:expr),+;)+ + } + transient: + $(state $st:ident($ctx:ident: Context $(, $arg:ident: $ty:ty)*) { + $(case $($lhs:pat),+ => $($rhs:expr),+;)+ + })* + ) => ( + stateful_decoder! { + module $stmod; + $(internal $item)* + initial: + state $inist($inictx: Context) { + $(case $($inilhs),+ => $($inirhs),+;)+ + final => $inictx.reset(); + } + checkpoint: + transient: + $(state $st($ctx: Context $(, $arg: $ty)*) { + $(case $($lhs),+ => $($rhs),+;)+ + final => $ctx.err("incomplete sequence"); + })* + } + ); +} + diff --git a/deps/encoding-index-japanese-1.20141219.5/Cargo.toml b/deps/encoding-index-japanese-1.20141219.5/Cargo.toml new file mode 100644 index 000000000..6d638cf38 --- /dev/null +++ b/deps/encoding-index-japanese-1.20141219.5/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "encoding-index-japanese" +version = "1.20141219.5" +authors = ["Kang Seonghoon "] + +description = "Index tables for Japanese character encodings" +homepage = "https://github.com/lifthrasiir/rust-encoding" +readme = "../../../README.md" +license = "CC0-1.0" + +[lib] +name = "encoding_index_japanese" +path = "lib.rs" + +[dependencies.encoding_index_tests] +# TODO consider using dev-dependencies instead (Cargo issue #860) +version = "0.1.4" +path = "../tests" diff --git a/deps/encoding-index-japanese-1.20141219.5/jis0208.rs b/deps/encoding-index-japanese-1.20141219.5/jis0208.rs new file mode 100644 index 000000000..f3511017e --- /dev/null +++ b/deps/encoding-index-japanese-1.20141219.5/jis0208.rs @@ -0,0 +1,3372 @@ +// AUTOGENERATED FROM index-jis0208.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-jis0208.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: cbaa91f3deb7d0841faf5c33041fc15a285da0e87e64ab802c4bf04b7c4da861 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 12288, 12289, 12290, 65292, 65294, 12539, 65306, 65307, 65311, 65281, + 12443, 12444, 180, 65344, 168, 65342, 65507, 65343, 12541, 12542, 12445, + 12446, 12291, 20189, 12293, 12294, 12295, 12540, 8213, 8208, 65295, 65340, + 65374, 8741, 65372, 8230, 8229, 8216, 8217, 8220, 8221, 65288, 65289, + 12308, 12309, 65339, 65341, 65371, 65373, 12296, 12297, 12298, 12299, + 12300, 12301, 12302, 12303, 12304, 12305, 65291, 65293, 177, 215, 247, + 65309, 8800, 65308, 65310, 8806, 8807, 8734, 8756, 9794, 9792, 176, 8242, + 8243, 8451, 65509, 65284, 65504, 65505, 65285, 65283, 65286, 65290, 65312, + 167, 9734, 9733, 9675, 9679, 9678, 9671, 9670, 9633, 9632, 9651, 9650, + 9661, 9660, 8251, 12306, 8594, 8592, 8593, 8595, 12307, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8712, 8715, + 8838, 8839, 8834, 8835, 8746, 8745, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8743, 8744, 65506, 8658, 8660, 8704, 8707, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8736, + 8869, 8978, 8706, 8711, 8801, 8786, 8810, 8811, 8730, 8765, 8733, 8757, + 8747, 8748, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8491, 8240, + 9839, 9837, 9834, 8224, 8225, 182, 65535, 65535, 65535, 65535, 9711, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65296, 65297, 65298, 65299, 65300, 65301, + 65302, 65303, 65304, 65305, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65313, 65314, 65315, 65316, 65317, 65318, 65319, 65320, 65321, + 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, + 65332, 65333, 65334, 65335, 65336, 65337, 65338, 65535, 65535, 65535, + 65535, 65535, 65535, 65345, 65346, 65347, 65348, 65349, 65350, 65351, + 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, 65361, + 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, 65535, + 65535, 65535, 65535, 12353, 12354, 12355, 12356, 12357, 12358, 12359, + 12360, 12361, 12362, 12363, 12364, 12365, 12366, 12367, 12368, 12369, + 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, + 12380, 12381, 12382, 12383, 12384, 12385, 12386, 12387, 12388, 12389, + 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12397, 12398, 12399, + 12400, 12401, 12402, 12403, 12404, 12405, 12406, 12407, 12408, 12409, + 12410, 12411, 12412, 12413, 12414, 12415, 12416, 12417, 12418, 12419, + 12420, 12421, 12422, 12423, 12424, 12425, 12426, 12427, 12428, 12429, + 12430, 12431, 12432, 12433, 12434, 12435, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 12449, 12450, 12451, + 12452, 12453, 12454, 12455, 12456, 12457, 12458, 12459, 12460, 12461, + 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, + 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, + 12482, 12483, 12484, 12485, 12486, 12487, 12488, 12489, 12490, 12491, + 12492, 12493, 12494, 12495, 12496, 12497, 12498, 12499, 12500, 12501, + 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12511, + 12512, 12513, 12514, 12515, 12516, 12517, 12518, 12519, 12520, 12521, + 12522, 12523, 12524, 12525, 12526, 12527, 12528, 12529, 12530, 12531, + 12532, 12533, 12534, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, + 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 945, 946, 947, 948, 949, 950, 951, 952, + 953, 954, 955, 956, 957, 958, 959, 960, 961, 963, 964, 965, 966, 967, 968, + 969, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1040, 1041, 1042, + 1043, 1044, 1045, 1025, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, + 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, + 1066, 1067, 1068, 1069, 1070, 1071, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1072, + 1073, 1074, 1075, 1076, 1077, 1105, 1078, 1079, 1080, 1081, 1082, 1083, + 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, + 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 9472, 9474, + 9484, 9488, 9496, 9492, 9500, 9516, 9508, 9524, 9532, 9473, 9475, 9487, + 9491, 9499, 9495, 9507, 9523, 9515, 9531, 9547, 9504, 9519, 9512, 9527, + 9535, 9501, 9520, 9509, 9528, 9538, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9312, 9313, 9314, 9315, 9316, 9317, 9318, 9319, 9320, + 9321, 9322, 9323, 9324, 9325, 9326, 9327, 9328, 9329, 9330, 9331, 8544, + 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 65535, 13129, 13076, + 13090, 13133, 13080, 13095, 13059, 13110, 13137, 13143, 13069, 13094, + 13091, 13099, 13130, 13115, 13212, 13213, 13214, 13198, 13199, 13252, + 13217, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 13179, + 12317, 12319, 8470, 13261, 8481, 12964, 12965, 12966, 12967, 12968, 12849, + 12850, 12857, 13182, 13181, 13180, 8786, 8801, 8747, 8750, 8721, 8730, + 8869, 8736, 8735, 8895, 8757, 8745, 8746, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 20124, 21782, 23043, 38463, + 21696, 24859, 25384, 23030, 36898, 33909, 33564, 31312, 24746, 25569, + 28197, 26093, 33894, 33446, 39925, 26771, 22311, 26017, 25201, 23451, + 22992, 34427, 39156, 32098, 32190, 39822, 25110, 31903, 34999, 23433, + 24245, 25353, 26263, 26696, 38343, 38797, 26447, 20197, 20234, 20301, + 20381, 20553, 22258, 22839, 22996, 23041, 23561, 24799, 24847, 24944, + 26131, 26885, 28858, 30031, 30064, 31227, 32173, 32239, 32963, 33806, + 34915, 35586, 36949, 36986, 21307, 20117, 20133, 22495, 32946, 37057, + 30959, 19968, 22769, 28322, 36920, 31282, 33576, 33419, 39983, 20801, + 21360, 21693, 21729, 22240, 23035, 24341, 39154, 28139, 32996, 34093, + 38498, 38512, 38560, 38907, 21515, 21491, 23431, 28879, 32701, 36802, + 38632, 21359, 40284, 31418, 19985, 30867, 33276, 28198, 22040, 21764, + 27421, 34074, 39995, 23013, 21417, 28006, 29916, 38287, 22082, 20113, + 36939, 38642, 33615, 39180, 21473, 21942, 23344, 24433, 26144, 26355, + 26628, 27704, 27891, 27945, 29787, 30408, 31310, 38964, 33521, 34907, + 35424, 37613, 28082, 30123, 30410, 39365, 24742, 35585, 36234, 38322, + 27022, 21421, 20870, 22290, 22576, 22852, 23476, 24310, 24616, 25513, + 25588, 27839, 28436, 28814, 28948, 29017, 29141, 29503, 32257, 33398, + 33489, 34199, 36960, 37467, 40219, 22633, 26044, 27738, 29989, 20985, + 22830, 22885, 24448, 24540, 25276, 26106, 27178, 27431, 27572, 29579, + 32705, 35158, 40236, 40206, 40644, 23713, 27798, 33659, 20740, 23627, + 25014, 33222, 26742, 29281, 20057, 20474, 21368, 24681, 28201, 31311, + 38899, 19979, 21270, 20206, 20309, 20285, 20385, 20339, 21152, 21487, + 22025, 22799, 23233, 23478, 23521, 31185, 26247, 26524, 26550, 27468, + 27827, 28779, 29634, 31117, 31166, 31292, 31623, 33457, 33499, 33540, + 33655, 33775, 33747, 34662, 35506, 22057, 36008, 36838, 36942, 38686, + 34442, 20420, 23784, 25105, 29273, 30011, 33253, 33469, 34558, 36032, + 38597, 39187, 39381, 20171, 20250, 35299, 22238, 22602, 22730, 24315, + 24555, 24618, 24724, 24674, 25040, 25106, 25296, 25913, 39745, 26214, + 26800, 28023, 28784, 30028, 30342, 32117, 33445, 34809, 38283, 38542, + 35997, 20977, 21182, 22806, 21683, 23475, 23830, 24936, 27010, 28079, + 30861, 33995, 34903, 35442, 37799, 39608, 28012, 39336, 34521, 22435, + 26623, 34510, 37390, 21123, 22151, 21508, 24275, 25313, 25785, 26684, + 26680, 27579, 29554, 30906, 31339, 35226, 35282, 36203, 36611, 37101, + 38307, 38548, 38761, 23398, 23731, 27005, 38989, 38990, 25499, 31520, + 27179, 27263, 26806, 39949, 28511, 21106, 21917, 24688, 25324, 27963, + 28167, 28369, 33883, 35088, 36676, 19988, 39993, 21494, 26907, 27194, + 38788, 26666, 20828, 31427, 33970, 37340, 37772, 22107, 40232, 26658, + 33541, 33841, 31909, 21000, 33477, 29926, 20094, 20355, 20896, 23506, + 21002, 21208, 21223, 24059, 21914, 22570, 23014, 23436, 23448, 23515, + 24178, 24185, 24739, 24863, 24931, 25022, 25563, 25954, 26577, 26707, + 26874, 27454, 27475, 27735, 28450, 28567, 28485, 29872, 29976, 30435, + 30475, 31487, 31649, 31777, 32233, 32566, 32752, 32925, 33382, 33694, + 35251, 35532, 36011, 36996, 37969, 38291, 38289, 38306, 38501, 38867, + 39208, 33304, 20024, 21547, 23736, 24012, 29609, 30284, 30524, 23721, + 32747, 36107, 38593, 38929, 38996, 39000, 20225, 20238, 21361, 21916, + 22120, 22522, 22855, 23305, 23492, 23696, 24076, 24190, 24524, 25582, + 26426, 26071, 26082, 26399, 26827, 26820, 27231, 24112, 27589, 27671, + 27773, 30079, 31048, 23395, 31232, 32000, 24509, 35215, 35352, 36020, + 36215, 36556, 36637, 39138, 39438, 39740, 20096, 20605, 20736, 22931, + 23452, 25135, 25216, 25836, 27450, 29344, 30097, 31047, 32681, 34811, + 35516, 35696, 25516, 33738, 38816, 21513, 21507, 21931, 26708, 27224, + 35440, 30759, 26485, 40653, 21364, 23458, 33050, 34384, 36870, 19992, + 20037, 20167, 20241, 21450, 21560, 23470, 24339, 24613, 25937, 26429, + 27714, 27762, 27875, 28792, 29699, 31350, 31406, 31496, 32026, 31998, + 32102, 26087, 29275, 21435, 23621, 24040, 25298, 25312, 25369, 28192, + 34394, 35377, 36317, 37624, 28417, 31142, 39770, 20136, 20139, 20140, + 20379, 20384, 20689, 20807, 31478, 20849, 20982, 21332, 21281, 21375, + 21483, 21932, 22659, 23777, 24375, 24394, 24623, 24656, 24685, 25375, + 25945, 27211, 27841, 29378, 29421, 30703, 33016, 33029, 33288, 34126, + 37111, 37857, 38911, 39255, 39514, 20208, 20957, 23597, 26241, 26989, + 23616, 26354, 26997, 29577, 26704, 31873, 20677, 21220, 22343, 24062, + 37670, 26020, 27427, 27453, 29748, 31105, 31165, 31563, 32202, 33465, + 33740, 34943, 35167, 35641, 36817, 37329, 21535, 37504, 20061, 20534, + 21477, 21306, 29399, 29590, 30697, 33510, 36527, 39366, 39368, 39378, + 20855, 24858, 34398, 21936, 31354, 20598, 23507, 36935, 38533, 20018, + 27355, 37351, 23633, 23624, 25496, 31391, 27795, 38772, 36705, 31402, + 29066, 38536, 31874, 26647, 32368, 26705, 37740, 21234, 21531, 34219, + 35347, 32676, 36557, 37089, 21350, 34952, 31041, 20418, 20670, 21009, + 20804, 21843, 22317, 29674, 22411, 22865, 24418, 24452, 24693, 24950, + 24935, 25001, 25522, 25658, 25964, 26223, 26690, 28179, 30054, 31293, + 31995, 32076, 32153, 32331, 32619, 33550, 33610, 34509, 35336, 35427, + 35686, 36605, 38938, 40335, 33464, 36814, 39912, 21127, 25119, 25731, + 28608, 38553, 26689, 20625, 27424, 27770, 28500, 31348, 32080, 34880, + 35363, 26376, 20214, 20537, 20518, 20581, 20860, 21048, 21091, 21927, + 22287, 22533, 23244, 24314, 25010, 25080, 25331, 25458, 26908, 27177, + 29309, 29356, 29486, 30740, 30831, 32121, 30476, 32937, 35211, 35609, + 36066, 36562, 36963, 37749, 38522, 38997, 39443, 40568, 20803, 21407, + 21427, 24187, 24358, 28187, 28304, 29572, 29694, 32067, 33335, 35328, + 35578, 38480, 20046, 20491, 21476, 21628, 22266, 22993, 23396, 24049, + 24235, 24359, 25144, 25925, 26543, 28246, 29392, 31946, 34996, 32929, + 32993, 33776, 34382, 35463, 36328, 37431, 38599, 39015, 40723, 20116, + 20114, 20237, 21320, 21577, 21566, 23087, 24460, 24481, 24735, 26791, + 27278, 29786, 30849, 35486, 35492, 35703, 37264, 20062, 39881, 20132, + 20348, 20399, 20505, 20502, 20809, 20844, 21151, 21177, 21246, 21402, + 21475, 21521, 21518, 21897, 22353, 22434, 22909, 23380, 23389, 23439, + 24037, 24039, 24055, 24184, 24195, 24218, 24247, 24344, 24658, 24908, + 25239, 25304, 25511, 25915, 26114, 26179, 26356, 26477, 26657, 26775, + 27083, 27743, 27946, 28009, 28207, 28317, 30002, 30343, 30828, 31295, + 31968, 32005, 32024, 32094, 32177, 32789, 32771, 32943, 32945, 33108, + 33167, 33322, 33618, 34892, 34913, 35611, 36002, 36092, 37066, 37237, + 37489, 30783, 37628, 38308, 38477, 38917, 39321, 39640, 40251, 21083, + 21163, 21495, 21512, 22741, 25335, 28640, 35946, 36703, 40633, 20811, + 21051, 21578, 22269, 31296, 37239, 40288, 40658, 29508, 28425, 33136, + 29969, 24573, 24794, 39592, 29403, 36796, 27492, 38915, 20170, 22256, + 22372, 22718, 23130, 24680, 25031, 26127, 26118, 26681, 26801, 28151, + 30165, 32058, 33390, 39746, 20123, 20304, 21449, 21766, 23919, 24038, + 24046, 26619, 27801, 29811, 30722, 35408, 37782, 35039, 22352, 24231, + 25387, 20661, 20652, 20877, 26368, 21705, 22622, 22971, 23472, 24425, + 25165, 25505, 26685, 27507, 28168, 28797, 37319, 29312, 30741, 30758, + 31085, 25998, 32048, 33756, 35009, 36617, 38555, 21092, 22312, 26448, + 32618, 36001, 20916, 22338, 38442, 22586, 27018, 32948, 21682, 23822, + 22524, 30869, 40442, 20316, 21066, 21643, 25662, 26152, 26388, 26613, + 31364, 31574, 32034, 37679, 26716, 39853, 31545, 21273, 20874, 21047, + 23519, 25334, 25774, 25830, 26413, 27578, 34217, 38609, 30352, 39894, + 25420, 37638, 39851, 30399, 26194, 19977, 20632, 21442, 23665, 24808, + 25746, 25955, 26719, 29158, 29642, 29987, 31639, 32386, 34453, 35715, + 36059, 37240, 39184, 26028, 26283, 27531, 20181, 20180, 20282, 20351, + 21050, 21496, 21490, 21987, 22235, 22763, 22987, 22985, 23039, 23376, + 23629, 24066, 24107, 24535, 24605, 25351, 25903, 23388, 26031, 26045, + 26088, 26525, 27490, 27515, 27663, 29509, 31049, 31169, 31992, 32025, + 32043, 32930, 33026, 33267, 35222, 35422, 35433, 35430, 35468, 35566, + 36039, 36060, 38604, 39164, 27503, 20107, 20284, 20365, 20816, 23383, + 23546, 24904, 25345, 26178, 27425, 28363, 27835, 29246, 29885, 30164, + 30913, 31034, 32780, 32819, 33258, 33940, 36766, 27728, 40575, 24335, + 35672, 40235, 31482, 36600, 23437, 38635, 19971, 21489, 22519, 22833, + 23241, 23460, 24713, 28287, 28422, 30142, 36074, 23455, 34048, 31712, + 20594, 26612, 33437, 23649, 34122, 32286, 33294, 20889, 23556, 25448, + 36198, 26012, 29038, 31038, 32023, 32773, 35613, 36554, 36974, 34503, + 37034, 20511, 21242, 23610, 26451, 28796, 29237, 37196, 37320, 37675, + 33509, 23490, 24369, 24825, 20027, 21462, 23432, 25163, 26417, 27530, + 29417, 29664, 31278, 33131, 36259, 37202, 39318, 20754, 21463, 21610, + 23551, 25480, 27193, 32172, 38656, 22234, 21454, 21608, 23447, 23601, + 24030, 20462, 24833, 25342, 27954, 31168, 31179, 32066, 32333, 32722, + 33261, 33311, 33936, 34886, 35186, 35728, 36468, 36655, 36913, 37195, + 37228, 38598, 37276, 20160, 20303, 20805, 21313, 24467, 25102, 26580, + 27713, 28171, 29539, 32294, 37325, 37507, 21460, 22809, 23487, 28113, + 31069, 32302, 31899, 22654, 29087, 20986, 34899, 36848, 20426, 23803, + 26149, 30636, 31459, 33308, 39423, 20934, 24490, 26092, 26991, 27529, + 28147, 28310, 28516, 30462, 32020, 24033, 36981, 37255, 38918, 20966, + 21021, 25152, 26257, 26329, 28186, 24246, 32210, 32626, 26360, 34223, + 34295, 35576, 21161, 21465, 22899, 24207, 24464, 24661, 37604, 38500, + 20663, 20767, 21213, 21280, 21319, 21484, 21736, 21830, 21809, 22039, + 22888, 22974, 23100, 23477, 23558, 23567, 23569, 23578, 24196, 24202, + 24288, 24432, 25215, 25220, 25307, 25484, 25463, 26119, 26124, 26157, + 26230, 26494, 26786, 27167, 27189, 27836, 28040, 28169, 28248, 28988, + 28966, 29031, 30151, 30465, 30813, 30977, 31077, 31216, 31456, 31505, + 31911, 32057, 32918, 33750, 33931, 34121, 34909, 35059, 35359, 35388, + 35412, 35443, 35937, 36062, 37284, 37478, 37758, 37912, 38556, 38808, + 19978, 19976, 19998, 20055, 20887, 21104, 22478, 22580, 22732, 23330, + 24120, 24773, 25854, 26465, 26454, 27972, 29366, 30067, 31331, 33976, + 35698, 37304, 37664, 22065, 22516, 39166, 25325, 26893, 27542, 29165, + 32340, 32887, 33394, 35302, 39135, 34645, 36785, 23611, 20280, 20449, + 20405, 21767, 23072, 23517, 23529, 24515, 24910, 25391, 26032, 26187, + 26862, 27035, 28024, 28145, 30003, 30137, 30495, 31070, 31206, 32051, + 33251, 33455, 34218, 35242, 35386, 36523, 36763, 36914, 37341, 38663, + 20154, 20161, 20995, 22645, 22764, 23563, 29978, 23613, 33102, 35338, + 36805, 38499, 38765, 31525, 35535, 38920, 37218, 22259, 21416, 36887, + 21561, 22402, 24101, 25512, 27700, 28810, 30561, 31883, 32736, 34928, + 36930, 37204, 37648, 37656, 38543, 29790, 39620, 23815, 23913, 25968, + 26530, 36264, 38619, 25454, 26441, 26905, 33733, 38935, 38592, 35070, + 28548, 25722, 23544, 19990, 28716, 30045, 26159, 20932, 21046, 21218, + 22995, 24449, 24615, 25104, 25919, 25972, 26143, 26228, 26866, 26646, + 27491, 28165, 29298, 29983, 30427, 31934, 32854, 22768, 35069, 35199, + 35488, 35475, 35531, 36893, 37266, 38738, 38745, 25993, 31246, 33030, + 38587, 24109, 24796, 25114, 26021, 26132, 26512, 30707, 31309, 31821, + 32318, 33034, 36012, 36196, 36321, 36447, 30889, 20999, 25305, 25509, + 25666, 25240, 35373, 31363, 31680, 35500, 38634, 32118, 33292, 34633, + 20185, 20808, 21315, 21344, 23459, 23554, 23574, 24029, 25126, 25159, + 25776, 26643, 26676, 27849, 27973, 27927, 26579, 28508, 29006, 29053, + 26059, 31359, 31661, 32218, 32330, 32680, 33146, 33307, 33337, 34214, + 35438, 36046, 36341, 36984, 36983, 37549, 37521, 38275, 39854, 21069, + 21892, 28472, 28982, 20840, 31109, 32341, 33203, 31950, 22092, 22609, + 23720, 25514, 26366, 26365, 26970, 29401, 30095, 30094, 30990, 31062, + 31199, 31895, 32032, 32068, 34311, 35380, 38459, 36961, 40736, 20711, + 21109, 21452, 21474, 20489, 21930, 22766, 22863, 29245, 23435, 23652, + 21277, 24803, 24819, 25436, 25475, 25407, 25531, 25805, 26089, 26361, + 24035, 27085, 27133, 28437, 29157, 20105, 30185, 30456, 31379, 31967, + 32207, 32156, 32865, 33609, 33624, 33900, 33980, 34299, 35013, 36208, + 36865, 36973, 37783, 38684, 39442, 20687, 22679, 24974, 33235, 34101, + 36104, 36896, 20419, 20596, 21063, 21363, 24687, 25417, 26463, 28204, + 36275, 36895, 20439, 23646, 36042, 26063, 32154, 21330, 34966, 20854, + 25539, 23384, 23403, 23562, 25613, 26449, 36956, 20182, 22810, 22826, + 27760, 35409, 21822, 22549, 22949, 24816, 25171, 26561, 33333, 26965, + 38464, 39364, 39464, 20307, 22534, 23550, 32784, 23729, 24111, 24453, + 24608, 24907, 25140, 26367, 27888, 28382, 32974, 33151, 33492, 34955, + 36024, 36864, 36910, 38538, 40667, 39899, 20195, 21488, 22823, 31532, + 37261, 38988, 40441, 28381, 28711, 21331, 21828, 23429, 25176, 25246, + 25299, 27810, 28655, 29730, 35351, 37944, 28609, 35582, 33592, 20967, + 34552, 21482, 21481, 20294, 36948, 36784, 22890, 33073, 24061, 31466, + 36799, 26842, 35895, 29432, 40008, 27197, 35504, 20025, 21336, 22022, + 22374, 25285, 25506, 26086, 27470, 28129, 28251, 28845, 30701, 31471, + 31658, 32187, 32829, 32966, 34507, 35477, 37723, 22243, 22727, 24382, + 26029, 26262, 27264, 27573, 30007, 35527, 20516, 30693, 22320, 24347, + 24677, 26234, 27744, 30196, 31258, 32622, 33268, 34584, 36933, 39347, + 31689, 30044, 31481, 31569, 33988, 36880, 31209, 31378, 33590, 23265, + 30528, 20013, 20210, 23449, 24544, 25277, 26172, 26609, 27880, 34411, + 34935, 35387, 37198, 37619, 39376, 27159, 28710, 29482, 33511, 33879, + 36015, 19969, 20806, 20939, 21899, 23541, 24086, 24115, 24193, 24340, + 24373, 24427, 24500, 25074, 25361, 26274, 26397, 28526, 29266, 30010, + 30522, 32884, 33081, 33144, 34678, 35519, 35548, 36229, 36339, 37530, + 38263, 38914, 40165, 21189, 25431, 30452, 26389, 27784, 29645, 36035, + 37806, 38515, 27941, 22684, 26894, 27084, 36861, 37786, 30171, 36890, + 22618, 26626, 25524, 27131, 20291, 28460, 26584, 36795, 34086, 32180, + 37716, 26943, 28528, 22378, 22775, 23340, 32044, 29226, 21514, 37347, + 40372, 20141, 20302, 20572, 20597, 21059, 35998, 21576, 22564, 23450, + 24093, 24213, 24237, 24311, 24351, 24716, 25269, 25402, 25552, 26799, + 27712, 30855, 31118, 31243, 32224, 33351, 35330, 35558, 36420, 36883, + 37048, 37165, 37336, 40718, 27877, 25688, 25826, 25973, 28404, 30340, + 31515, 36969, 37841, 28346, 21746, 24505, 25764, 36685, 36845, 37444, + 20856, 22635, 22825, 23637, 24215, 28155, 32399, 29980, 36028, 36578, + 39003, 28857, 20253, 27583, 28593, 30000, 38651, 20814, 21520, 22581, + 22615, 22956, 23648, 24466, 26007, 26460, 28193, 30331, 33759, 36077, + 36884, 37117, 37709, 30757, 30778, 21162, 24230, 22303, 22900, 24594, + 20498, 20826, 20908, 20941, 20992, 21776, 22612, 22616, 22871, 23445, + 23798, 23947, 24764, 25237, 25645, 26481, 26691, 26812, 26847, 30423, + 28120, 28271, 28059, 28783, 29128, 24403, 30168, 31095, 31561, 31572, + 31570, 31958, 32113, 21040, 33891, 34153, 34276, 35342, 35588, 35910, + 36367, 36867, 36879, 37913, 38518, 38957, 39472, 38360, 20685, 21205, + 21516, 22530, 23566, 24999, 25758, 27934, 30643, 31461, 33012, 33796, + 36947, 37509, 23776, 40199, 21311, 24471, 24499, 28060, 29305, 30563, + 31167, 31716, 27602, 29420, 35501, 26627, 27233, 20984, 31361, 26932, + 23626, 40182, 33515, 23493, 37193, 28702, 22136, 23663, 24775, 25958, + 27788, 35930, 36929, 38931, 21585, 26311, 37389, 22856, 37027, 20869, + 20045, 20970, 34201, 35598, 28760, 25466, 37707, 26978, 39348, 32260, + 30071, 21335, 26976, 36575, 38627, 27741, 20108, 23612, 24336, 36841, + 21250, 36049, 32905, 34425, 24319, 26085, 20083, 20837, 22914, 23615, + 38894, 20219, 22922, 24525, 35469, 28641, 31152, 31074, 23527, 33905, + 29483, 29105, 24180, 24565, 25467, 25754, 29123, 31896, 20035, 24316, + 20043, 22492, 22178, 24745, 28611, 32013, 33021, 33075, 33215, 36786, + 35223, 34468, 24052, 25226, 25773, 35207, 26487, 27874, 27966, 29750, + 30772, 23110, 32629, 33453, 39340, 20467, 24259, 25309, 25490, 25943, + 26479, 30403, 29260, 32972, 32954, 36649, 37197, 20493, 22521, 23186, + 26757, 26995, 29028, 29437, 36023, 22770, 36064, 38506, 36889, 34687, + 31204, 30695, 33833, 20271, 21093, 21338, 25293, 26575, 27850, 30333, + 31636, 31893, 33334, 34180, 36843, 26333, 28448, 29190, 32283, 33707, + 39361, 40614, 20989, 31665, 30834, 31672, 32903, 31560, 27368, 24161, + 32908, 30033, 30048, 20843, 37474, 28300, 30330, 37271, 39658, 20240, + 32624, 25244, 31567, 38309, 40169, 22138, 22617, 34532, 38588, 20276, + 21028, 21322, 21453, 21467, 24070, 25644, 26001, 26495, 27710, 27726, + 29256, 29359, 29677, 30036, 32321, 33324, 34281, 36009, 31684, 37318, + 29033, 38930, 39151, 25405, 26217, 30058, 30436, 30928, 34115, 34542, + 21290, 21329, 21542, 22915, 24199, 24444, 24754, 25161, 25209, 25259, + 26000, 27604, 27852, 30130, 30382, 30865, 31192, 32203, 32631, 32933, + 34987, 35513, 36027, 36991, 38750, 39131, 27147, 31800, 20633, 23614, + 24494, 26503, 27608, 29749, 30473, 32654, 40763, 26570, 31255, 21305, + 30091, 39661, 24422, 33181, 33777, 32920, 24380, 24517, 30050, 31558, + 36924, 26727, 23019, 23195, 32016, 30334, 35628, 20469, 24426, 27161, + 27703, 28418, 29922, 31080, 34920, 35413, 35961, 24287, 25551, 30149, + 31186, 33495, 37672, 37618, 33948, 34541, 39981, 21697, 24428, 25996, + 27996, 28693, 36007, 36051, 38971, 25935, 29942, 19981, 20184, 22496, + 22827, 23142, 23500, 20904, 24067, 24220, 24598, 25206, 25975, 26023, + 26222, 28014, 29238, 31526, 33104, 33178, 33433, 35676, 36000, 36070, + 36212, 38428, 38468, 20398, 25771, 27494, 33310, 33889, 34154, 37096, + 23553, 26963, 39080, 33914, 34135, 20239, 21103, 24489, 24133, 26381, + 31119, 33145, 35079, 35206, 28149, 24343, 25173, 27832, 20175, 29289, + 39826, 20998, 21563, 22132, 22707, 24996, 25198, 28954, 22894, 31881, + 31966, 32027, 38640, 25991, 32862, 19993, 20341, 20853, 22592, 24163, + 24179, 24330, 26564, 20006, 34109, 38281, 38491, 31859, 38913, 20731, + 22721, 30294, 30887, 21029, 30629, 34065, 31622, 20559, 22793, 29255, + 31687, 32232, 36794, 36820, 36941, 20415, 21193, 23081, 24321, 38829, + 20445, 33303, 37610, 22275, 25429, 27497, 29995, 35036, 36628, 31298, + 21215, 22675, 24917, 25098, 26286, 27597, 31807, 33769, 20515, 20472, + 21253, 21574, 22577, 22857, 23453, 23792, 23791, 23849, 24214, 25265, + 25447, 25918, 26041, 26379, 27861, 27873, 28921, 30770, 32299, 32990, + 33459, 33804, 34028, 34562, 35090, 35370, 35914, 37030, 37586, 39165, + 40179, 40300, 20047, 20129, 20621, 21078, 22346, 22952, 24125, 24536, + 24537, 25151, 26292, 26395, 26576, 26834, 20882, 32033, 32938, 33192, + 35584, 35980, 36031, 37502, 38450, 21536, 38956, 21271, 20693, 21340, + 22696, 25778, 26420, 29287, 30566, 31302, 37350, 21187, 27809, 27526, + 22528, 24140, 22868, 26412, 32763, 20961, 30406, 25705, 30952, 39764, + 40635, 22475, 22969, 26151, 26522, 27598, 21737, 27097, 24149, 33180, + 26517, 39850, 26622, 40018, 26717, 20134, 20451, 21448, 25273, 26411, + 27819, 36804, 20397, 32365, 40639, 19975, 24930, 28288, 28459, 34067, + 21619, 26410, 39749, 24051, 31637, 23724, 23494, 34588, 28234, 34001, + 31252, 33032, 22937, 31885, 27665, 30496, 21209, 22818, 28961, 29279, + 30683, 38695, 40289, 26891, 23167, 23064, 20901, 21517, 21629, 26126, + 30431, 36855, 37528, 40180, 23018, 29277, 28357, 20813, 26825, 32191, + 32236, 38754, 40634, 25720, 27169, 33538, 22916, 23391, 27611, 29467, + 30450, 32178, 32791, 33945, 20786, 26408, 40665, 30446, 26466, 21247, + 39173, 23588, 25147, 31870, 36016, 21839, 24758, 32011, 38272, 21249, + 20063, 20918, 22812, 29242, 32822, 37326, 24357, 30690, 21380, 24441, + 32004, 34220, 35379, 36493, 38742, 26611, 34222, 37971, 24841, 24840, + 27833, 30290, 35565, 36664, 21807, 20305, 20778, 21191, 21451, 23461, + 24189, 24736, 24962, 25558, 26377, 26586, 28263, 28044, 29494, 29495, + 30001, 31056, 35029, 35480, 36938, 37009, 37109, 38596, 34701, 22805, + 20104, 20313, 19982, 35465, 36671, 38928, 20653, 24188, 22934, 23481, + 24248, 25562, 25594, 25793, 26332, 26954, 27096, 27915, 28342, 29076, + 29992, 31407, 32650, 32768, 33865, 33993, 35201, 35617, 36362, 36965, + 38525, 39178, 24958, 25233, 27442, 27779, 28020, 32716, 32764, 28096, + 32645, 34746, 35064, 26469, 33713, 38972, 38647, 27931, 32097, 33853, + 37226, 20081, 21365, 23888, 27396, 28651, 34253, 34349, 35239, 21033, + 21519, 23653, 26446, 26792, 29702, 29827, 30178, 35023, 35041, 37324, + 38626, 38520, 24459, 29575, 31435, 33870, 25504, 30053, 21129, 27969, + 28316, 29705, 30041, 30827, 31890, 38534, 31452, 40845, 20406, 24942, + 26053, 34396, 20102, 20142, 20698, 20001, 20940, 23534, 26009, 26753, + 28092, 29471, 30274, 30637, 31260, 31975, 33391, 35538, 36988, 37327, + 38517, 38936, 21147, 32209, 20523, 21400, 26519, 28107, 29136, 29747, + 33256, 36650, 38563, 40023, 40607, 29792, 22593, 28057, 32047, 39006, + 20196, 20278, 20363, 20919, 21169, 23994, 24604, 29618, 31036, 33491, + 37428, 38583, 38646, 38666, 40599, 40802, 26278, 27508, 21015, 21155, + 28872, 35010, 24265, 24651, 24976, 28451, 29001, 31806, 32244, 32879, + 34030, 36899, 37676, 21570, 39791, 27347, 28809, 36034, 36335, 38706, + 21172, 23105, 24266, 24324, 26391, 27004, 27028, 28010, 28431, 29282, + 29436, 31725, 32769, 32894, 34635, 37070, 20845, 40595, 31108, 32907, + 37682, 35542, 20525, 21644, 35441, 27498, 36036, 33031, 24785, 26528, + 40434, 20121, 20120, 39952, 35435, 34241, 34152, 26880, 28286, 30871, + 33109, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 24332, 19984, 19989, 20010, 20017, 20022, + 20028, 20031, 20034, 20054, 20056, 20098, 20101, 35947, 20106, 33298, + 24333, 20110, 20126, 20127, 20128, 20130, 20144, 20147, 20150, 20174, + 20173, 20164, 20166, 20162, 20183, 20190, 20205, 20191, 20215, 20233, + 20314, 20272, 20315, 20317, 20311, 20295, 20342, 20360, 20367, 20376, + 20347, 20329, 20336, 20369, 20335, 20358, 20374, 20760, 20436, 20447, + 20430, 20440, 20443, 20433, 20442, 20432, 20452, 20453, 20506, 20520, + 20500, 20522, 20517, 20485, 20252, 20470, 20513, 20521, 20524, 20478, + 20463, 20497, 20486, 20547, 20551, 26371, 20565, 20560, 20552, 20570, + 20566, 20588, 20600, 20608, 20634, 20613, 20660, 20658, 20681, 20682, + 20659, 20674, 20694, 20702, 20709, 20717, 20707, 20718, 20729, 20725, + 20745, 20737, 20738, 20758, 20757, 20756, 20762, 20769, 20794, 20791, + 20796, 20795, 20799, 20800, 20818, 20812, 20820, 20834, 31480, 20841, + 20842, 20846, 20864, 20866, 22232, 20876, 20873, 20879, 20881, 20883, + 20885, 20886, 20900, 20902, 20898, 20905, 20906, 20907, 20915, 20913, + 20914, 20912, 20917, 20925, 20933, 20937, 20955, 20960, 34389, 20969, + 20973, 20976, 20981, 20990, 20996, 21003, 21012, 21006, 21031, 21034, + 21038, 21043, 21049, 21071, 21060, 21067, 21068, 21086, 21076, 21098, + 21108, 21097, 21107, 21119, 21117, 21133, 21140, 21138, 21105, 21128, + 21137, 36776, 36775, 21164, 21165, 21180, 21173, 21185, 21197, 21207, + 21214, 21219, 21222, 39149, 21216, 21235, 21237, 21240, 21241, 21254, + 21256, 30008, 21261, 21264, 21263, 21269, 21274, 21283, 21295, 21297, + 21299, 21304, 21312, 21318, 21317, 19991, 21321, 21325, 20950, 21342, + 21353, 21358, 22808, 21371, 21367, 21378, 21398, 21408, 21414, 21413, + 21422, 21424, 21430, 21443, 31762, 38617, 21471, 26364, 29166, 21486, + 21480, 21485, 21498, 21505, 21565, 21568, 21548, 21549, 21564, 21550, + 21558, 21545, 21533, 21582, 21647, 21621, 21646, 21599, 21617, 21623, + 21616, 21650, 21627, 21632, 21622, 21636, 21648, 21638, 21703, 21666, + 21688, 21669, 21676, 21700, 21704, 21672, 21675, 21698, 21668, 21694, + 21692, 21720, 21733, 21734, 21775, 21780, 21757, 21742, 21741, 21754, + 21730, 21817, 21824, 21859, 21836, 21806, 21852, 21829, 21846, 21847, + 21816, 21811, 21853, 21913, 21888, 21679, 21898, 21919, 21883, 21886, + 21912, 21918, 21934, 21884, 21891, 21929, 21895, 21928, 21978, 21957, + 21983, 21956, 21980, 21988, 21972, 22036, 22007, 22038, 22014, 22013, + 22043, 22009, 22094, 22096, 29151, 22068, 22070, 22066, 22072, 22123, + 22116, 22063, 22124, 22122, 22150, 22144, 22154, 22176, 22164, 22159, + 22181, 22190, 22198, 22196, 22210, 22204, 22209, 22211, 22208, 22216, + 22222, 22225, 22227, 22231, 22254, 22265, 22272, 22271, 22276, 22281, + 22280, 22283, 22285, 22291, 22296, 22294, 21959, 22300, 22310, 22327, + 22328, 22350, 22331, 22336, 22351, 22377, 22464, 22408, 22369, 22399, + 22409, 22419, 22432, 22451, 22436, 22442, 22448, 22467, 22470, 22484, + 22482, 22483, 22538, 22486, 22499, 22539, 22553, 22557, 22642, 22561, + 22626, 22603, 22640, 27584, 22610, 22589, 22649, 22661, 22713, 22687, + 22699, 22714, 22750, 22715, 22712, 22702, 22725, 22739, 22737, 22743, + 22745, 22744, 22757, 22748, 22756, 22751, 22767, 22778, 22777, 22779, + 22780, 22781, 22786, 22794, 22800, 22811, 26790, 22821, 22828, 22829, + 22834, 22840, 22846, 31442, 22869, 22864, 22862, 22874, 22872, 22882, + 22880, 22887, 22892, 22889, 22904, 22913, 22941, 20318, 20395, 22947, + 22962, 22982, 23016, 23004, 22925, 23001, 23002, 23077, 23071, 23057, + 23068, 23049, 23066, 23104, 23148, 23113, 23093, 23094, 23138, 23146, + 23194, 23228, 23230, 23243, 23234, 23229, 23267, 23255, 23270, 23273, + 23254, 23290, 23291, 23308, 23307, 23318, 23346, 23248, 23338, 23350, + 23358, 23363, 23365, 23360, 23377, 23381, 23386, 23387, 23397, 23401, + 23408, 23411, 23413, 23416, 25992, 23418, 23424, 23427, 23462, 23480, + 23491, 23495, 23497, 23508, 23504, 23524, 23526, 23522, 23518, 23525, + 23531, 23536, 23542, 23539, 23557, 23559, 23560, 23565, 23571, 23584, + 23586, 23592, 23608, 23609, 23617, 23622, 23630, 23635, 23632, 23631, + 23409, 23660, 23662, 20066, 23670, 23673, 23692, 23697, 23700, 22939, + 23723, 23739, 23734, 23740, 23735, 23749, 23742, 23751, 23769, 23785, + 23805, 23802, 23789, 23948, 23786, 23819, 23829, 23831, 23900, 23839, + 23835, 23825, 23828, 23842, 23834, 23833, 23832, 23884, 23890, 23886, + 23883, 23916, 23923, 23926, 23943, 23940, 23938, 23970, 23965, 23980, + 23982, 23997, 23952, 23991, 23996, 24009, 24013, 24019, 24018, 24022, + 24027, 24043, 24050, 24053, 24075, 24090, 24089, 24081, 24091, 24118, + 24119, 24132, 24131, 24128, 24142, 24151, 24148, 24159, 24162, 24164, + 24135, 24181, 24182, 24186, 40636, 24191, 24224, 24257, 24258, 24264, + 24272, 24271, 24278, 24291, 24285, 24282, 24283, 24290, 24289, 24296, + 24297, 24300, 24305, 24307, 24304, 24308, 24312, 24318, 24323, 24329, + 24413, 24412, 24331, 24337, 24342, 24361, 24365, 24376, 24385, 24392, + 24396, 24398, 24367, 24401, 24406, 24407, 24409, 24417, 24429, 24435, + 24439, 24451, 24450, 24447, 24458, 24456, 24465, 24455, 24478, 24473, + 24472, 24480, 24488, 24493, 24508, 24534, 24571, 24548, 24568, 24561, + 24541, 24755, 24575, 24609, 24672, 24601, 24592, 24617, 24590, 24625, + 24603, 24597, 24619, 24614, 24591, 24634, 24666, 24641, 24682, 24695, + 24671, 24650, 24646, 24653, 24675, 24643, 24676, 24642, 24684, 24683, + 24665, 24705, 24717, 24807, 24707, 24730, 24708, 24731, 24726, 24727, + 24722, 24743, 24715, 24801, 24760, 24800, 24787, 24756, 24560, 24765, + 24774, 24757, 24792, 24909, 24853, 24838, 24822, 24823, 24832, 24820, + 24826, 24835, 24865, 24827, 24817, 24845, 24846, 24903, 24894, 24872, + 24871, 24906, 24895, 24892, 24876, 24884, 24893, 24898, 24900, 24947, + 24951, 24920, 24921, 24922, 24939, 24948, 24943, 24933, 24945, 24927, + 24925, 24915, 24949, 24985, 24982, 24967, 25004, 24980, 24986, 24970, + 24977, 25003, 25006, 25036, 25034, 25033, 25079, 25032, 25027, 25030, + 25018, 25035, 32633, 25037, 25062, 25059, 25078, 25082, 25076, 25087, + 25085, 25084, 25086, 25088, 25096, 25097, 25101, 25100, 25108, 25115, + 25118, 25121, 25130, 25134, 25136, 25138, 25139, 25153, 25166, 25182, + 25187, 25179, 25184, 25192, 25212, 25218, 25225, 25214, 25234, 25235, + 25238, 25300, 25219, 25236, 25303, 25297, 25275, 25295, 25343, 25286, + 25812, 25288, 25308, 25292, 25290, 25282, 25287, 25243, 25289, 25356, + 25326, 25329, 25383, 25346, 25352, 25327, 25333, 25424, 25406, 25421, + 25628, 25423, 25494, 25486, 25472, 25515, 25462, 25507, 25487, 25481, + 25503, 25525, 25451, 25449, 25534, 25577, 25536, 25542, 25571, 25545, + 25554, 25590, 25540, 25622, 25652, 25606, 25619, 25638, 25654, 25885, + 25623, 25640, 25615, 25703, 25711, 25718, 25678, 25898, 25749, 25747, + 25765, 25769, 25736, 25788, 25818, 25810, 25797, 25799, 25787, 25816, + 25794, 25841, 25831, 33289, 25824, 25825, 25260, 25827, 25839, 25900, + 25846, 25844, 25842, 25850, 25856, 25853, 25880, 25884, 25861, 25892, + 25891, 25899, 25908, 25909, 25911, 25910, 25912, 30027, 25928, 25942, + 25941, 25933, 25944, 25950, 25949, 25970, 25976, 25986, 25987, 35722, + 26011, 26015, 26027, 26039, 26051, 26054, 26049, 26052, 26060, 26066, + 26075, 26073, 26080, 26081, 26097, 26482, 26122, 26115, 26107, 26483, + 26165, 26166, 26164, 26140, 26191, 26180, 26185, 26177, 26206, 26205, + 26212, 26215, 26216, 26207, 26210, 26224, 26243, 26248, 26254, 26249, + 26244, 26264, 26269, 26305, 26297, 26313, 26302, 26300, 26308, 26296, + 26326, 26330, 26336, 26175, 26342, 26345, 26352, 26357, 26359, 26383, + 26390, 26398, 26406, 26407, 38712, 26414, 26431, 26422, 26433, 26424, + 26423, 26438, 26462, 26464, 26457, 26467, 26468, 26505, 26480, 26537, + 26492, 26474, 26508, 26507, 26534, 26529, 26501, 26551, 26607, 26548, + 26604, 26547, 26601, 26552, 26596, 26590, 26589, 26594, 26606, 26553, + 26574, 26566, 26599, 27292, 26654, 26694, 26665, 26688, 26701, 26674, + 26702, 26803, 26667, 26713, 26723, 26743, 26751, 26783, 26767, 26797, + 26772, 26781, 26779, 26755, 27310, 26809, 26740, 26805, 26784, 26810, + 26895, 26765, 26750, 26881, 26826, 26888, 26840, 26914, 26918, 26849, + 26892, 26829, 26836, 26855, 26837, 26934, 26898, 26884, 26839, 26851, + 26917, 26873, 26848, 26863, 26920, 26922, 26906, 26915, 26913, 26822, + 27001, 26999, 26972, 27000, 26987, 26964, 27006, 26990, 26937, 26996, + 26941, 26969, 26928, 26977, 26974, 26973, 27009, 26986, 27058, 27054, + 27088, 27071, 27073, 27091, 27070, 27086, 23528, 27082, 27101, 27067, + 27075, 27047, 27182, 27025, 27040, 27036, 27029, 27060, 27102, 27112, + 27138, 27163, 27135, 27402, 27129, 27122, 27111, 27141, 27057, 27166, + 27117, 27156, 27115, 27146, 27154, 27329, 27171, 27155, 27204, 27148, + 27250, 27190, 27256, 27207, 27234, 27225, 27238, 27208, 27192, 27170, + 27280, 27277, 27296, 27268, 27298, 27299, 27287, 34327, 27323, 27331, + 27330, 27320, 27315, 27308, 27358, 27345, 27359, 27306, 27354, 27370, + 27387, 27397, 34326, 27386, 27410, 27414, 39729, 27423, 27448, 27447, + 30428, 27449, 39150, 27463, 27459, 27465, 27472, 27481, 27476, 27483, + 27487, 27489, 27512, 27513, 27519, 27520, 27524, 27523, 27533, 27544, + 27541, 27550, 27556, 27562, 27563, 27567, 27570, 27569, 27571, 27575, + 27580, 27590, 27595, 27603, 27615, 27628, 27627, 27635, 27631, 40638, + 27656, 27667, 27668, 27675, 27684, 27683, 27742, 27733, 27746, 27754, + 27778, 27789, 27802, 27777, 27803, 27774, 27752, 27763, 27794, 27792, + 27844, 27889, 27859, 27837, 27863, 27845, 27869, 27822, 27825, 27838, + 27834, 27867, 27887, 27865, 27882, 27935, 34893, 27958, 27947, 27965, + 27960, 27929, 27957, 27955, 27922, 27916, 28003, 28051, 28004, 27994, + 28025, 27993, 28046, 28053, 28644, 28037, 28153, 28181, 28170, 28085, + 28103, 28134, 28088, 28102, 28140, 28126, 28108, 28136, 28114, 28101, + 28154, 28121, 28132, 28117, 28138, 28142, 28205, 28270, 28206, 28185, + 28274, 28255, 28222, 28195, 28267, 28203, 28278, 28237, 28191, 28227, + 28218, 28238, 28196, 28415, 28189, 28216, 28290, 28330, 28312, 28361, + 28343, 28371, 28349, 28335, 28356, 28338, 28372, 28373, 28303, 28325, + 28354, 28319, 28481, 28433, 28748, 28396, 28408, 28414, 28479, 28402, + 28465, 28399, 28466, 28364, 28478, 28435, 28407, 28550, 28538, 28536, + 28545, 28544, 28527, 28507, 28659, 28525, 28546, 28540, 28504, 28558, + 28561, 28610, 28518, 28595, 28579, 28577, 28580, 28601, 28614, 28586, + 28639, 28629, 28652, 28628, 28632, 28657, 28654, 28635, 28681, 28683, + 28666, 28689, 28673, 28687, 28670, 28699, 28698, 28532, 28701, 28696, + 28703, 28720, 28734, 28722, 28753, 28771, 28825, 28818, 28847, 28913, + 28844, 28856, 28851, 28846, 28895, 28875, 28893, 28889, 28937, 28925, + 28956, 28953, 29029, 29013, 29064, 29030, 29026, 29004, 29014, 29036, + 29071, 29179, 29060, 29077, 29096, 29100, 29143, 29113, 29118, 29138, + 29129, 29140, 29134, 29152, 29164, 29159, 29173, 29180, 29177, 29183, + 29197, 29200, 29211, 29224, 29229, 29228, 29232, 29234, 29243, 29244, + 29247, 29248, 29254, 29259, 29272, 29300, 29310, 29314, 29313, 29319, + 29330, 29334, 29346, 29351, 29369, 29362, 29379, 29382, 29380, 29390, + 29394, 29410, 29408, 29409, 29433, 29431, 20495, 29463, 29450, 29468, + 29462, 29469, 29492, 29487, 29481, 29477, 29502, 29518, 29519, 40664, + 29527, 29546, 29544, 29552, 29560, 29557, 29563, 29562, 29640, 29619, + 29646, 29627, 29632, 29669, 29678, 29662, 29858, 29701, 29807, 29733, + 29688, 29746, 29754, 29781, 29759, 29791, 29785, 29761, 29788, 29801, + 29808, 29795, 29802, 29814, 29822, 29835, 29854, 29863, 29898, 29903, + 29908, 29681, 29920, 29923, 29927, 29929, 29934, 29938, 29936, 29937, + 29944, 29943, 29956, 29955, 29957, 29964, 29966, 29965, 29973, 29971, + 29982, 29990, 29996, 30012, 30020, 30029, 30026, 30025, 30043, 30022, + 30042, 30057, 30052, 30055, 30059, 30061, 30072, 30070, 30086, 30087, + 30068, 30090, 30089, 30082, 30100, 30106, 30109, 30117, 30115, 30146, + 30131, 30147, 30133, 30141, 30136, 30140, 30129, 30157, 30154, 30162, + 30169, 30179, 30174, 30206, 30207, 30204, 30209, 30192, 30202, 30194, + 30195, 30219, 30221, 30217, 30239, 30247, 30240, 30241, 30242, 30244, + 30260, 30256, 30267, 30279, 30280, 30278, 30300, 30296, 30305, 30306, + 30312, 30313, 30314, 30311, 30316, 30320, 30322, 30326, 30328, 30332, + 30336, 30339, 30344, 30347, 30350, 30358, 30355, 30361, 30362, 30384, + 30388, 30392, 30393, 30394, 30402, 30413, 30422, 30418, 30430, 30433, + 30437, 30439, 30442, 34351, 30459, 30472, 30471, 30468, 30505, 30500, + 30494, 30501, 30502, 30491, 30519, 30520, 30535, 30554, 30568, 30571, + 30555, 30565, 30591, 30590, 30585, 30606, 30603, 30609, 30624, 30622, + 30640, 30646, 30649, 30655, 30652, 30653, 30651, 30663, 30669, 30679, + 30682, 30684, 30691, 30702, 30716, 30732, 30738, 31014, 30752, 31018, + 30789, 30862, 30836, 30854, 30844, 30874, 30860, 30883, 30901, 30890, + 30895, 30929, 30918, 30923, 30932, 30910, 30908, 30917, 30922, 30956, + 30951, 30938, 30973, 30964, 30983, 30994, 30993, 31001, 31020, 31019, + 31040, 31072, 31063, 31071, 31066, 31061, 31059, 31098, 31103, 31114, + 31133, 31143, 40779, 31146, 31150, 31155, 31161, 31162, 31177, 31189, + 31207, 31212, 31201, 31203, 31240, 31245, 31256, 31257, 31264, 31263, + 31104, 31281, 31291, 31294, 31287, 31299, 31319, 31305, 31329, 31330, + 31337, 40861, 31344, 31353, 31357, 31368, 31383, 31381, 31384, 31382, + 31401, 31432, 31408, 31414, 31429, 31428, 31423, 36995, 31431, 31434, + 31437, 31439, 31445, 31443, 31449, 31450, 31453, 31457, 31458, 31462, + 31469, 31472, 31490, 31503, 31498, 31494, 31539, 31512, 31513, 31518, + 31541, 31528, 31542, 31568, 31610, 31492, 31565, 31499, 31564, 31557, + 31605, 31589, 31604, 31591, 31600, 31601, 31596, 31598, 31645, 31640, + 31647, 31629, 31644, 31642, 31627, 31634, 31631, 31581, 31641, 31691, + 31681, 31692, 31695, 31668, 31686, 31709, 31721, 31761, 31764, 31718, + 31717, 31840, 31744, 31751, 31763, 31731, 31735, 31767, 31757, 31734, + 31779, 31783, 31786, 31775, 31799, 31787, 31805, 31820, 31811, 31828, + 31823, 31808, 31824, 31832, 31839, 31844, 31830, 31845, 31852, 31861, + 31875, 31888, 31908, 31917, 31906, 31915, 31905, 31912, 31923, 31922, + 31921, 31918, 31929, 31933, 31936, 31941, 31938, 31960, 31954, 31964, + 31970, 39739, 31983, 31986, 31988, 31990, 31994, 32006, 32002, 32028, + 32021, 32010, 32069, 32075, 32046, 32050, 32063, 32053, 32070, 32115, + 32086, 32078, 32114, 32104, 32110, 32079, 32099, 32147, 32137, 32091, + 32143, 32125, 32155, 32186, 32174, 32163, 32181, 32199, 32189, 32171, + 32317, 32162, 32175, 32220, 32184, 32159, 32176, 32216, 32221, 32228, + 32222, 32251, 32242, 32225, 32261, 32266, 32291, 32289, 32274, 32305, + 32287, 32265, 32267, 32290, 32326, 32358, 32315, 32309, 32313, 32323, + 32311, 32306, 32314, 32359, 32349, 32342, 32350, 32345, 32346, 32377, + 32362, 32361, 32380, 32379, 32387, 32213, 32381, 36782, 32383, 32392, + 32393, 32396, 32402, 32400, 32403, 32404, 32406, 32398, 32411, 32412, + 32568, 32570, 32581, 32588, 32589, 32590, 32592, 32593, 32597, 32596, + 32600, 32607, 32608, 32616, 32617, 32615, 32632, 32642, 32646, 32643, + 32648, 32647, 32652, 32660, 32670, 32669, 32666, 32675, 32687, 32690, + 32697, 32686, 32694, 32696, 35697, 32709, 32710, 32714, 32725, 32724, + 32737, 32742, 32745, 32755, 32761, 39132, 32774, 32772, 32779, 32786, + 32792, 32793, 32796, 32801, 32808, 32831, 32827, 32842, 32838, 32850, + 32856, 32858, 32863, 32866, 32872, 32883, 32882, 32880, 32886, 32889, + 32893, 32895, 32900, 32902, 32901, 32923, 32915, 32922, 32941, 20880, + 32940, 32987, 32997, 32985, 32989, 32964, 32986, 32982, 33033, 33007, + 33009, 33051, 33065, 33059, 33071, 33099, 38539, 33094, 33086, 33107, + 33105, 33020, 33137, 33134, 33125, 33126, 33140, 33155, 33160, 33162, + 33152, 33154, 33184, 33173, 33188, 33187, 33119, 33171, 33193, 33200, + 33205, 33214, 33208, 33213, 33216, 33218, 33210, 33225, 33229, 33233, + 33241, 33240, 33224, 33242, 33247, 33248, 33255, 33274, 33275, 33278, + 33281, 33282, 33285, 33287, 33290, 33293, 33296, 33302, 33321, 33323, + 33336, 33331, 33344, 33369, 33368, 33373, 33370, 33375, 33380, 33378, + 33384, 33386, 33387, 33326, 33393, 33399, 33400, 33406, 33421, 33426, + 33451, 33439, 33467, 33452, 33505, 33507, 33503, 33490, 33524, 33523, + 33530, 33683, 33539, 33531, 33529, 33502, 33542, 33500, 33545, 33497, + 33589, 33588, 33558, 33586, 33585, 33600, 33593, 33616, 33605, 33583, + 33579, 33559, 33560, 33669, 33690, 33706, 33695, 33698, 33686, 33571, + 33678, 33671, 33674, 33660, 33717, 33651, 33653, 33696, 33673, 33704, + 33780, 33811, 33771, 33742, 33789, 33795, 33752, 33803, 33729, 33783, + 33799, 33760, 33778, 33805, 33826, 33824, 33725, 33848, 34054, 33787, + 33901, 33834, 33852, 34138, 33924, 33911, 33899, 33965, 33902, 33922, + 33897, 33862, 33836, 33903, 33913, 33845, 33994, 33890, 33977, 33983, + 33951, 34009, 33997, 33979, 34010, 34000, 33985, 33990, 34006, 33953, + 34081, 34047, 34036, 34071, 34072, 34092, 34079, 34069, 34068, 34044, + 34112, 34147, 34136, 34120, 34113, 34306, 34123, 34133, 34176, 34212, + 34184, 34193, 34186, 34216, 34157, 34196, 34203, 34282, 34183, 34204, + 34167, 34174, 34192, 34249, 34234, 34255, 34233, 34256, 34261, 34269, + 34277, 34268, 34297, 34314, 34323, 34315, 34302, 34298, 34310, 34338, + 34330, 34352, 34367, 34381, 20053, 34388, 34399, 34407, 34417, 34451, + 34467, 34473, 34474, 34443, 34444, 34486, 34479, 34500, 34502, 34480, + 34505, 34851, 34475, 34516, 34526, 34537, 34540, 34527, 34523, 34543, + 34578, 34566, 34568, 34560, 34563, 34555, 34577, 34569, 34573, 34553, + 34570, 34612, 34623, 34615, 34619, 34597, 34601, 34586, 34656, 34655, + 34680, 34636, 34638, 34676, 34647, 34664, 34670, 34649, 34643, 34659, + 34666, 34821, 34722, 34719, 34690, 34735, 34763, 34749, 34752, 34768, + 38614, 34731, 34756, 34739, 34759, 34758, 34747, 34799, 34802, 34784, + 34831, 34829, 34814, 34806, 34807, 34830, 34770, 34833, 34838, 34837, + 34850, 34849, 34865, 34870, 34873, 34855, 34875, 34884, 34882, 34898, + 34905, 34910, 34914, 34923, 34945, 34942, 34974, 34933, 34941, 34997, + 34930, 34946, 34967, 34962, 34990, 34969, 34978, 34957, 34980, 34992, + 35007, 34993, 35011, 35012, 35028, 35032, 35033, 35037, 35065, 35074, + 35068, 35060, 35048, 35058, 35076, 35084, 35082, 35091, 35139, 35102, + 35109, 35114, 35115, 35137, 35140, 35131, 35126, 35128, 35148, 35101, + 35168, 35166, 35174, 35172, 35181, 35178, 35183, 35188, 35191, 35198, + 35203, 35208, 35210, 35219, 35224, 35233, 35241, 35238, 35244, 35247, + 35250, 35258, 35261, 35263, 35264, 35290, 35292, 35293, 35303, 35316, + 35320, 35331, 35350, 35344, 35340, 35355, 35357, 35365, 35382, 35393, + 35419, 35410, 35398, 35400, 35452, 35437, 35436, 35426, 35461, 35458, + 35460, 35496, 35489, 35473, 35493, 35494, 35482, 35491, 35524, 35533, + 35522, 35546, 35563, 35571, 35559, 35556, 35569, 35604, 35552, 35554, + 35575, 35550, 35547, 35596, 35591, 35610, 35553, 35606, 35600, 35607, + 35616, 35635, 38827, 35622, 35627, 35646, 35624, 35649, 35660, 35663, + 35662, 35657, 35670, 35675, 35674, 35691, 35679, 35692, 35695, 35700, + 35709, 35712, 35724, 35726, 35730, 35731, 35734, 35737, 35738, 35898, + 35905, 35903, 35912, 35916, 35918, 35920, 35925, 35938, 35948, 35960, + 35962, 35970, 35977, 35973, 35978, 35981, 35982, 35988, 35964, 35992, + 25117, 36013, 36010, 36029, 36018, 36019, 36014, 36022, 36040, 36033, + 36068, 36067, 36058, 36093, 36090, 36091, 36100, 36101, 36106, 36103, + 36111, 36109, 36112, 40782, 36115, 36045, 36116, 36118, 36199, 36205, + 36209, 36211, 36225, 36249, 36290, 36286, 36282, 36303, 36314, 36310, + 36300, 36315, 36299, 36330, 36331, 36319, 36323, 36348, 36360, 36361, + 36351, 36381, 36382, 36368, 36383, 36418, 36405, 36400, 36404, 36426, + 36423, 36425, 36428, 36432, 36424, 36441, 36452, 36448, 36394, 36451, + 36437, 36470, 36466, 36476, 36481, 36487, 36485, 36484, 36491, 36490, + 36499, 36497, 36500, 36505, 36522, 36513, 36524, 36528, 36550, 36529, + 36542, 36549, 36552, 36555, 36571, 36579, 36604, 36603, 36587, 36606, + 36618, 36613, 36629, 36626, 36633, 36627, 36636, 36639, 36635, 36620, + 36646, 36659, 36667, 36665, 36677, 36674, 36670, 36684, 36681, 36678, + 36686, 36695, 36700, 36706, 36707, 36708, 36764, 36767, 36771, 36781, + 36783, 36791, 36826, 36837, 36834, 36842, 36847, 36999, 36852, 36869, + 36857, 36858, 36881, 36885, 36897, 36877, 36894, 36886, 36875, 36903, + 36918, 36917, 36921, 36856, 36943, 36944, 36945, 36946, 36878, 36937, + 36926, 36950, 36952, 36958, 36968, 36975, 36982, 38568, 36978, 36994, + 36989, 36993, 36992, 37002, 37001, 37007, 37032, 37039, 37041, 37045, + 37090, 37092, 25160, 37083, 37122, 37138, 37145, 37170, 37168, 37194, + 37206, 37208, 37219, 37221, 37225, 37235, 37234, 37259, 37257, 37250, + 37282, 37291, 37295, 37290, 37301, 37300, 37306, 37312, 37313, 37321, + 37323, 37328, 37334, 37343, 37345, 37339, 37372, 37365, 37366, 37406, + 37375, 37396, 37420, 37397, 37393, 37470, 37463, 37445, 37449, 37476, + 37448, 37525, 37439, 37451, 37456, 37532, 37526, 37523, 37531, 37466, + 37583, 37561, 37559, 37609, 37647, 37626, 37700, 37678, 37657, 37666, + 37658, 37667, 37690, 37685, 37691, 37724, 37728, 37756, 37742, 37718, + 37808, 37804, 37805, 37780, 37817, 37846, 37847, 37864, 37861, 37848, + 37827, 37853, 37840, 37832, 37860, 37914, 37908, 37907, 37891, 37895, + 37904, 37942, 37931, 37941, 37921, 37946, 37953, 37970, 37956, 37979, + 37984, 37986, 37982, 37994, 37417, 38000, 38005, 38007, 38013, 37978, + 38012, 38014, 38017, 38015, 38274, 38279, 38282, 38292, 38294, 38296, + 38297, 38304, 38312, 38311, 38317, 38332, 38331, 38329, 38334, 38346, + 28662, 38339, 38349, 38348, 38357, 38356, 38358, 38364, 38369, 38373, + 38370, 38433, 38440, 38446, 38447, 38466, 38476, 38479, 38475, 38519, + 38492, 38494, 38493, 38495, 38502, 38514, 38508, 38541, 38552, 38549, + 38551, 38570, 38567, 38577, 38578, 38576, 38580, 38582, 38584, 38585, + 38606, 38603, 38601, 38605, 35149, 38620, 38669, 38613, 38649, 38660, + 38662, 38664, 38675, 38670, 38673, 38671, 38678, 38681, 38692, 38698, + 38704, 38713, 38717, 38718, 38724, 38726, 38728, 38722, 38729, 38748, + 38752, 38756, 38758, 38760, 21202, 38763, 38769, 38777, 38789, 38780, + 38785, 38778, 38790, 38795, 38799, 38800, 38812, 38824, 38822, 38819, + 38835, 38836, 38851, 38854, 38856, 38859, 38876, 38893, 40783, 38898, + 31455, 38902, 38901, 38927, 38924, 38968, 38948, 38945, 38967, 38973, + 38982, 38991, 38987, 39019, 39023, 39024, 39025, 39028, 39027, 39082, + 39087, 39089, 39094, 39108, 39107, 39110, 39145, 39147, 39171, 39177, + 39186, 39188, 39192, 39201, 39197, 39198, 39204, 39200, 39212, 39214, + 39229, 39230, 39234, 39241, 39237, 39248, 39243, 39249, 39250, 39244, + 39253, 39319, 39320, 39333, 39341, 39342, 39356, 39391, 39387, 39389, + 39384, 39377, 39405, 39406, 39409, 39410, 39419, 39416, 39425, 39439, + 39429, 39394, 39449, 39467, 39479, 39493, 39490, 39488, 39491, 39486, + 39509, 39501, 39515, 39511, 39519, 39522, 39525, 39524, 39529, 39531, + 39530, 39597, 39600, 39612, 39616, 39631, 39633, 39635, 39636, 39646, + 39647, 39650, 39651, 39654, 39663, 39659, 39662, 39668, 39665, 39671, + 39675, 39686, 39704, 39706, 39711, 39714, 39715, 39717, 39719, 39720, + 39721, 39722, 39726, 39727, 39730, 39748, 39747, 39759, 39757, 39758, + 39761, 39768, 39796, 39827, 39811, 39825, 39830, 39831, 39839, 39840, + 39848, 39860, 39872, 39882, 39865, 39878, 39887, 39889, 39890, 39907, + 39906, 39908, 39892, 39905, 39994, 39922, 39921, 39920, 39957, 39956, + 39945, 39955, 39948, 39942, 39944, 39954, 39946, 39940, 39982, 39963, + 39973, 39972, 39969, 39984, 40007, 39986, 40006, 39998, 40026, 40032, + 40039, 40054, 40056, 40167, 40172, 40176, 40201, 40200, 40171, 40195, + 40198, 40234, 40230, 40367, 40227, 40223, 40260, 40213, 40210, 40257, + 40255, 40254, 40262, 40264, 40285, 40286, 40292, 40273, 40272, 40281, + 40306, 40329, 40327, 40363, 40303, 40314, 40346, 40356, 40361, 40370, + 40388, 40385, 40379, 40376, 40378, 40390, 40399, 40386, 40409, 40403, + 40440, 40422, 40429, 40431, 40445, 40474, 40475, 40478, 40565, 40569, + 40573, 40577, 40584, 40587, 40588, 40594, 40597, 40593, 40605, 40613, + 40617, 40632, 40618, 40621, 38753, 40652, 40654, 40655, 40656, 40660, + 40668, 40670, 40669, 40672, 40677, 40680, 40687, 40692, 40694, 40695, + 40697, 40699, 40700, 40701, 40711, 40712, 30391, 40725, 40737, 40748, + 40766, 40778, 40786, 40788, 40803, 40799, 40800, 40801, 40806, 40807, + 40812, 40810, 40823, 40818, 40822, 40853, 40860, 40864, 22575, 27079, + 36953, 29796, 20956, 29081, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 32394, 35100, + 37704, 37512, 34012, 20425, 28859, 26161, 26824, 37625, 26363, 24389, + 20008, 20193, 20220, 20224, 20227, 20281, 20310, 20370, 20362, 20378, + 20372, 20429, 20544, 20514, 20479, 20510, 20550, 20592, 20546, 20628, + 20724, 20696, 20810, 20836, 20893, 20926, 20972, 21013, 21148, 21158, + 21184, 21211, 21248, 21255, 21284, 21362, 21395, 21426, 21469, 64014, + 21660, 21642, 21673, 21759, 21894, 22361, 22373, 22444, 22472, 22471, + 64015, 64016, 22686, 22706, 22795, 22867, 22875, 22877, 22883, 22948, + 22970, 23382, 23488, 29999, 23512, 23532, 23582, 23718, 23738, 23797, + 23847, 23891, 64017, 23874, 23917, 23992, 23993, 24016, 24353, 24372, + 24423, 24503, 24542, 24669, 24709, 24714, 24798, 24789, 24864, 24818, + 24849, 24887, 24880, 24984, 25107, 25254, 25589, 25696, 25757, 25806, + 25934, 26112, 26133, 26171, 26121, 26158, 26142, 26148, 26213, 26199, + 26201, 64018, 26227, 26265, 26272, 26290, 26303, 26362, 26382, 63785, + 26470, 26555, 26706, 26560, 26625, 26692, 26831, 64019, 26984, 64020, + 27032, 27106, 27184, 27243, 27206, 27251, 27262, 27362, 27364, 27606, + 27711, 27740, 27782, 27759, 27866, 27908, 28039, 28015, 28054, 28076, + 28111, 28152, 28146, 28156, 28217, 28252, 28199, 28220, 28351, 28552, + 28597, 28661, 28677, 28679, 28712, 28805, 28843, 28943, 28932, 29020, + 28998, 28999, 64021, 29121, 29182, 29361, 29374, 29476, 64022, 29559, + 29629, 29641, 29654, 29667, 29650, 29703, 29685, 29734, 29738, 29737, + 29742, 29794, 29833, 29855, 29953, 30063, 30338, 30364, 30366, 30363, + 30374, 64023, 30534, 21167, 30753, 30798, 30820, 30842, 31024, 64024, + 64025, 64026, 31124, 64027, 31131, 31441, 31463, 64028, 31467, 31646, + 64029, 32072, 32092, 32183, 32160, 32214, 32338, 32583, 32673, 64030, + 33537, 33634, 33663, 33735, 33782, 33864, 33972, 34131, 34137, 34155, + 64031, 34224, 64032, 64033, 34823, 35061, 35346, 35383, 35449, 35495, + 35518, 35551, 64034, 35574, 35667, 35711, 36080, 36084, 36114, 36214, + 64035, 36559, 64036, 64037, 36967, 37086, 64038, 37141, 37159, 37338, + 37335, 37342, 37357, 37358, 37348, 37349, 37382, 37392, 37386, 37434, + 37440, 37436, 37454, 37465, 37457, 37433, 37479, 37543, 37495, 37496, + 37607, 37591, 37593, 37584, 64039, 37589, 37600, 37587, 37669, 37665, + 37627, 64040, 37662, 37631, 37661, 37634, 37744, 37719, 37796, 37830, + 37854, 37880, 37937, 37957, 37960, 38290, 63964, 64041, 38557, 38575, + 38707, 38715, 38723, 38733, 38735, 38737, 38741, 38999, 39013, 64042, + 64043, 39207, 64044, 39326, 39502, 39641, 39644, 39797, 39794, 39823, + 39857, 39867, 39936, 40304, 40299, 64045, 40473, 40657, 65535, 65535, 8560, + 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 65506, 65508, 65287, + 65282, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8560, 8561, + 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8544, 8545, 8546, 8547, + 8548, 8549, 8550, 8551, 8552, 8553, 65506, 65508, 65287, 65282, 12849, + 8470, 8481, 8757, 32394, 35100, 37704, 37512, 34012, 20425, 28859, 26161, + 26824, 37625, 26363, 24389, 20008, 20193, 20220, 20224, 20227, 20281, + 20310, 20370, 20362, 20378, 20372, 20429, 20544, 20514, 20479, 20510, + 20550, 20592, 20546, 20628, 20724, 20696, 20810, 20836, 20893, 20926, + 20972, 21013, 21148, 21158, 21184, 21211, 21248, 21255, 21284, 21362, + 21395, 21426, 21469, 64014, 21660, 21642, 21673, 21759, 21894, 22361, + 22373, 22444, 22472, 22471, 64015, 64016, 22686, 22706, 22795, 22867, + 22875, 22877, 22883, 22948, 22970, 23382, 23488, 29999, 23512, 23532, + 23582, 23718, 23738, 23797, 23847, 23891, 64017, 23874, 23917, 23992, + 23993, 24016, 24353, 24372, 24423, 24503, 24542, 24669, 24709, 24714, + 24798, 24789, 24864, 24818, 24849, 24887, 24880, 24984, 25107, 25254, + 25589, 25696, 25757, 25806, 25934, 26112, 26133, 26171, 26121, 26158, + 26142, 26148, 26213, 26199, 26201, 64018, 26227, 26265, 26272, 26290, + 26303, 26362, 26382, 63785, 26470, 26555, 26706, 26560, 26625, 26692, + 26831, 64019, 26984, 64020, 27032, 27106, 27184, 27243, 27206, 27251, + 27262, 27362, 27364, 27606, 27711, 27740, 27782, 27759, 27866, 27908, + 28039, 28015, 28054, 28076, 28111, 28152, 28146, 28156, 28217, 28252, + 28199, 28220, 28351, 28552, 28597, 28661, 28677, 28679, 28712, 28805, + 28843, 28943, 28932, 29020, 28998, 28999, 64021, 29121, 29182, 29361, + 29374, 29476, 64022, 29559, 29629, 29641, 29654, 29667, 29650, 29703, + 29685, 29734, 29738, 29737, 29742, 29794, 29833, 29855, 29953, 30063, + 30338, 30364, 30366, 30363, 30374, 64023, 30534, 21167, 30753, 30798, + 30820, 30842, 31024, 64024, 64025, 64026, 31124, 64027, 31131, 31441, + 31463, 64028, 31467, 31646, 64029, 32072, 32092, 32183, 32160, 32214, + 32338, 32583, 32673, 64030, 33537, 33634, 33663, 33735, 33782, 33864, + 33972, 34131, 34137, 34155, 64031, 34224, 64032, 64033, 34823, 35061, + 35346, 35383, 35449, 35495, 35518, 35551, 64034, 35574, 35667, 35711, + 36080, 36084, 36114, 36214, 64035, 36559, 64036, 64037, 36967, 37086, + 64038, 37141, 37159, 37338, 37335, 37342, 37357, 37358, 37348, 37349, + 37382, 37392, 37386, 37434, 37440, 37436, 37454, 37465, 37457, 37433, + 37479, 37543, 37495, 37496, 37607, 37591, 37593, 37584, 64039, 37589, + 37600, 37587, 37669, 37665, 37627, 64040, 37662, 37631, 37661, 37634, + 37744, 37719, 37796, 37830, 37854, 37880, 37937, 37957, 37960, 38290, + 63964, 64041, 38557, 38575, 38707, 38715, 38723, 38733, 38735, 38737, + 38741, 38999, 39013, 64042, 64043, 39207, 64044, 39326, 39502, 39641, + 39644, 39797, 39794, 39823, 39857, 39867, 39936, 40304, 40299, 64045, + 40473, 40657, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u16) -> u32 { + let code = code as usize; + if code < 11104 { + FORWARD_TABLE[code] as u32 + } else { + 0xffff + } +} + +static BACKWARD_TABLE_LOWER: &'static [u16] = &[ + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 87, 14, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 74, 61, 65535, 65535, 12, + 65535, 182, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 62, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 63, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 470, 471, + 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, + 65535, 487, 488, 489, 490, 491, 492, 493, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, + 513, 514, 515, 516, 517, 518, 65535, 519, 520, 521, 522, 523, 524, 525, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 570, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 564, 565, 566, 567, 568, + 569, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, + 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 612, 613, 614, + 615, 616, 617, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, + 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, + 65535, 618, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 29, 65535, 65535, 65535, 65535, 28, 65535, 65535, 37, 38, 65535, + 65535, 39, 40, 65535, 65535, 180, 181, 65535, 65535, 65535, 36, 35, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 176, 65535, 75, 76, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 101, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 77, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1193, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1195, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 175, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 65535, + 65535, 65535, 65535, 65535, 65535, 8634, 8635, 8636, 8637, 8638, 8639, + 8640, 8641, 8642, 8643, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 104, 105, 103, 106, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 138, 65535, 139, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 140, + 65535, 156, 141, 65535, 65535, 65535, 157, 119, 65535, 65535, 120, 65535, + 65535, 65535, 65535, 65535, 1211, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 162, 65535, 65535, 164, 70, 1215, 153, 65535, 65535, 65535, + 65535, 33, 65535, 135, 136, 126, 125, 166, 167, 65535, 1210, 65535, 65535, + 65535, 65535, 65535, 71, 165, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 163, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 159, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65, 158, 65535, 65535, 65535, 65535, 68, 69, + 65535, 65535, 160, 161, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 123, 124, 65535, 65535, 121, 122, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 154, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1216, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 155, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, + 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 658, 669, 659, 670, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 660, 65535, 65535, 671, 661, 65535, 65535, 672, 663, 65535, + 65535, 674, 662, 65535, 65535, 673, 664, 685, 65535, 65535, 680, 65535, + 65535, 675, 666, 687, 65535, 65535, 682, 65535, 65535, 677, 665, 65535, + 65535, 681, 686, 65535, 65535, 676, 667, 65535, 65535, 683, 688, 65535, + 65535, 678, 668, 65535, 65535, 684, 65535, 65535, 689, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 679, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 96, 95, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 98, 97, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 100, 99, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 94, + 93, 65535, 65535, 65535, 90, 65535, 65535, 92, 91, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 187, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 89, 88, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 73, 65535, 72, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 179, 65535, 65535, 178, 65535, + 177, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 0, 1, 2, 22, 65535, 24, 25, 26, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 102, 107, 43, 44, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1191, 65535, 1192, 65535, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, + 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, + 360, 361, 362, 363, 364, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 10, 11, 20, 21, 65535, 65535, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, + 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, + 460, 461, 65535, 65535, 65535, 65535, 5, 27, 18, 19, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1201, 1202, 65535, 65535, 65535, 65535, + 65535, 65535, 1203, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1196, 1197, 1198, 1199, 1200, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1165, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1169, 65535, 65535, 65535, 65535, 65535, 65535, 1160, 65535, 65535, + 65535, 1163, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1161, 1171, 65535, 65535, 1170, 1164, 65535, 65535, 65535, 1172, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1166, 65535, + 65535, 65535, 65535, 1174, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1159, 1173, 65535, 65535, 1162, + 65535, 65535, 65535, 1167, 65535, 65535, 65535, 65535, 65535, 1168, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1190, 1206, 1205, 1204, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1178, 1179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1175, 1176, 1177, 65535, 65535, 1181, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1180, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1194, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1485, + 3285, 65535, 2560, 65535, 65535, 65535, 4039, 2795, 2459, 2794, 1625, + 65535, 3811, 4166, 65535, 4419, 1518, 65535, 65535, 1769, 4420, 2917, 4639, + 1933, 3879, 65535, 65535, 65535, 65535, 2796, 65535, 65535, 4259, 65535, + 65535, 65535, 65535, 3887, 65535, 8284, 65535, 4421, 65535, 65535, 3265, + 65535, 65535, 65535, 4422, 2063, 65535, 65535, 65535, 4423, 65535, 1846, + 3211, 65535, 2608, 4424, 65535, 65535, 4425, 65535, 65535, 4426, 3592, + 65535, 1934, 65535, 65535, 65535, 65535, 65535, 3594, 65535, 3544, 2196, + 3966, 65535, 65535, 65535, 65535, 65535, 6808, 4427, 2797, 4428, 1618, + 65535, 65535, 65535, 2042, 2241, 4114, 65535, 65535, 4987, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4215, 65535, 3570, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1790, 65535, 1900, 65535, 4429, 65535, 65535, + 4430, 4256, 65535, 4164, 3079, 4432, 2529, 3560, 65535, 4435, 65535, 65535, + 1533, 2224, 65535, 2223, 1479, 65535, 65535, 4366, 4365, 65535, 2368, 1410, + 65535, 4436, 4437, 4438, 3967, 4439, 65535, 2243, 1480, 4029, 65535, 1971, + 65535, 65535, 1972, 1973, 3355, 4257, 65535, 4440, 65535, 65535, 4441, + 65535, 65535, 4442, 65535, 65535, 65535, 2864, 65535, 65535, 65535, 65535, + 65535, 2657, 2865, 4447, 65535, 4445, 65535, 4446, 1935, 65535, 65535, + 2352, 1677, 65535, 4444, 4443, 3862, 65535, 65535, 65535, 65535, 2481, + 2480, 3131, 4448, 3812, 2984, 65535, 65535, 65535, 23, 4449, 4451, 65535, + 8285, 65535, 3170, 4294, 1451, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4450, 1627, 65535, 2009, 65535, 3266, 65535, 65535, 65535, 2146, + 4452, 65535, 65535, 65535, 3575, 8286, 65535, 65535, 65535, 8287, 1860, + 65535, 8288, 65535, 65535, 65535, 65535, 65535, 4453, 1452, 65535, 65535, + 2225, 1861, 3849, 3683, 1936, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1678, 65535, 4488, 3416, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3647, 4455, 65535, 65535, 65535, 3693, 65535, 4295, 65535, + 2832, 8289, 2482, 65535, 2530, 1629, 65535, 65535, 65535, 65535, 65535, + 3338, 65535, 65535, 3197, 4459, 65535, 65535, 65535, 65535, 65535, 1453, + 3356, 2658, 2369, 4139, 65535, 3147, 65535, 1628, 8290, 4458, 65535, 4165, + 4454, 4456, 2427, 4457, 4891, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4465, 65535, 65535, 65535, 65535, 65535, 4468, + 4466, 65535, 65535, 1631, 65535, 3880, 4460, 65535, 65535, 65535, 65535, + 4464, 2244, 65535, 65535, 2483, 65535, 65535, 65535, 1791, 65535, 65535, + 4469, 65535, 4461, 65535, 8292, 4296, 65535, 2531, 65535, 4462, 65535, + 4467, 8291, 65535, 8294, 65535, 4470, 65535, 4463, 65535, 8293, 1974, + 65535, 1454, 65535, 65535, 1975, 1630, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4892, 65535, 4036, 3837, 2245, 65535, 65535, + 65535, 65535, 65535, 2834, 4252, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3909, 65535, 65535, 2091, 3106, 1665, 65535, 65535, 65535, + 65535, 8277, 2682, 65535, 65535, 8295, 4474, 65535, 4479, 4477, 65535, + 65535, 4472, 65535, 65535, 3116, 4475, 65535, 4478, 4476, 65535, 3914, + 65535, 4473, 65535, 2833, 65535, 4030, 4480, 4481, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2635, 4494, 65535, 65535, 65535, 3619, + 65535, 3781, 4489, 65535, 3933, 65535, 1619, 65535, 65535, 65535, 4493, + 8298, 65535, 65535, 65535, 65535, 65535, 4487, 4496, 65535, 65535, 3057, + 65535, 2197, 65535, 3631, 65535, 5960, 65535, 4495, 3444, 65535, 4484, + 65535, 2247, 65535, 65535, 2246, 4482, 65535, 65535, 65535, 8299, 2595, + 65535, 4490, 8297, 3932, 3240, 4486, 2148, 65535, 4483, 4491, 4485, 4278, + 4492, 4356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2043, + 65535, 65535, 2147, 65535, 65535, 65535, 65535, 65535, 65535, 8296, 65535, + 8302, 4497, 65535, 65535, 8300, 4498, 4502, 1455, 65535, 65535, 65535, + 65535, 65535, 3901, 4501, 65535, 65535, 65535, 65535, 4500, 4504, 65535, + 65535, 65535, 4503, 65535, 3357, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2149, 65535, 65535, 65535, 65535, 65535, 65535, 4505, 65535, + 65535, 65535, 8301, 65535, 2574, 65535, 3107, 3358, 2059, 65535, 4506, + 65535, 65535, 65535, 65535, 1901, 65535, 65535, 4507, 65535, 65535, 65535, + 65535, 4509, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3968, 65535, + 65535, 65535, 2137, 65535, 65535, 8303, 65535, 65535, 65535, 2460, 3752, + 4508, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2386, 4170, 65535, 65535, + 65535, 65535, 4511, 4514, 4510, 2385, 65535, 2724, 65535, 65535, 65535, + 65535, 65535, 65535, 2092, 65535, 65535, 65535, 4515, 65535, 65535, 2020, + 65535, 65535, 65535, 4512, 4513, 65535, 65535, 3492, 65535, 3099, 65535, + 1976, 65535, 65535, 65535, 3992, 4516, 65535, 8305, 65535, 4258, 65535, + 65535, 65535, 4517, 65535, 65535, 65535, 65535, 4520, 65535, 4518, 65535, + 3053, 65535, 65535, 65535, 65535, 65535, 4519, 4521, 65535, 65535, 65535, + 65535, 65535, 8304, 4523, 65535, 65535, 65535, 4522, 65535, 3893, 65535, + 65535, 65535, 65535, 1902, 4525, 4526, 65535, 1612, 65535, 65535, 65535, + 65535, 4524, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2621, + 65535, 4529, 4528, 4527, 65535, 4471, 65535, 4530, 65535, 65535, 65535, + 65535, 2725, 65535, 4531, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4140, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4098, 65535, + 65535, 65535, 65535, 4533, 65535, 65535, 4532, 4535, 4534, 65535, 65535, + 4536, 4537, 1493, 65535, 2182, 2094, 2659, 3286, 1977, 2985, 2248, 8306, + 2333, 4539, 4081, 3421, 65535, 2532, 65535, 4538, 65535, 4540, 65535, + 65535, 65535, 65535, 65535, 3445, 65535, 1776, 65535, 65535, 65535, 65535, + 65535, 4541, 65535, 8307, 3571, 65535, 65535, 3027, 4543, 4544, 3677, 2249, + 4350, 4545, 65535, 65535, 1979, 65535, 65535, 65535, 3881, 3123, 2054, + 3404, 65535, 65535, 65535, 2150, 65535, 65535, 65535, 4546, 65535, 4547, + 65535, 65535, 3543, 1566, 65535, 65535, 4550, 2442, 65535, 4549, 2387, + 65535, 4551, 6563, 4552, 3980, 4553, 65535, 4554, 4555, 2798, 65535, 2581, + 65535, 65535, 65535, 8308, 65535, 65535, 1792, 65535, 4558, 65535, 4556, + 4070, 4557, 65535, 3817, 4559, 4560, 4561, 3446, 65535, 65535, 65535, 4565, + 4563, 4564, 4562, 2416, 4566, 4115, 4297, 65535, 65535, 65535, 65535, + 65535, 4567, 8309, 65535, 65535, 65535, 65535, 65535, 2921, 4568, 2689, + 65535, 65535, 4569, 65535, 3287, 4260, 3447, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4642, 65535, 65535, 65535, 65535, 4570, 7806, + 2010, 65535, 65535, 4571, 4009, 65535, 65535, 65535, 65535, 2703, 3193, + 65535, 4573, 3545, 65535, 8310, 4574, 65535, 65535, 4575, 1705, 65535, + 65535, 65535, 4576, 1980, 65535, 3521, 1593, 2679, 65535, 65535, 3666, + 4577, 65535, 3448, 65535, 65535, 2866, 4578, 65535, 3865, 2971, 1787, + 65535, 1794, 4579, 65535, 65535, 4581, 65535, 65535, 2093, 65535, 65535, + 4580, 8311, 65535, 4312, 65535, 65535, 65535, 65535, 65535, 2704, 65535, + 65535, 65535, 65535, 65535, 65535, 3694, 3897, 65535, 4582, 65535, 4223, + 4583, 65535, 65535, 65535, 4584, 65535, 3477, 65535, 65535, 4585, 65535, + 65535, 2922, 2443, 2151, 4586, 2484, 2334, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3359, 4588, 65535, 65535, 3108, 65535, 65535, 2428, + 4589, 4590, 3023, 65535, 4587, 65535, 65535, 65535, 65535, 4592, 65535, + 3969, 65535, 65535, 65535, 65535, 2323, 65535, 65535, 4591, 65535, 65535, + 65535, 65535, 2152, 2411, 3648, 65535, 65535, 65535, 4595, 4593, 65535, + 65535, 65535, 65535, 3850, 2799, 4602, 1759, 4596, 4594, 3054, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4598, 65535, 4597, 65535, 65535, + 65535, 1727, 65535, 65535, 65535, 2131, 4603, 4242, 65535, 65535, 65535, + 4599, 65535, 65535, 65535, 4604, 4601, 65535, 4600, 65535, 65535, 65535, + 65535, 65535, 65535, 4276, 8312, 65535, 65535, 2250, 1632, 65535, 65535, + 4313, 65535, 65535, 8313, 65535, 65535, 2716, 3439, 2324, 4607, 4608, + 65535, 8487, 65535, 4298, 65535, 65535, 4334, 4610, 65535, 65535, 65535, + 2251, 65535, 65535, 4609, 65535, 1706, 65535, 8314, 4611, 65535, 4001, + 65535, 3317, 65535, 4141, 65535, 3910, 65535, 65535, 65535, 4612, 65535, + 65535, 65535, 65535, 7478, 65535, 65535, 3493, 65535, 4613, 1795, 4060, + 65535, 8315, 65535, 2726, 4614, 3924, 4618, 65535, 2923, 4615, 2021, 65535, + 4616, 1796, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2081, 4619, 65535, 4620, 65535, 65535, 4621, 4622, 2596, 65535, + 65535, 65535, 2252, 4103, 8316, 4113, 3564, 65535, 65535, 3934, 4623, 8317, + 4624, 65535, 65535, 65535, 65535, 4626, 65535, 4628, 4627, 65535, 65535, + 65535, 65535, 4629, 1626, 3991, 65535, 2441, 4630, 65535, 65535, 3064, + 65535, 65535, 2727, 1982, 65535, 4631, 8318, 65535, 65535, 65535, 65535, + 65535, 3724, 65535, 65535, 65535, 65535, 4632, 65535, 4633, 65535, 4634, + 65535, 65535, 65535, 65535, 4635, 3763, 2045, 1478, 65535, 65535, 65535, + 3508, 4636, 2660, 65535, 2986, 65535, 4638, 4637, 2728, 2226, 4640, 3695, + 65535, 65535, 4641, 65535, 65535, 65535, 3725, 3121, 3179, 1981, 65535, + 65535, 3555, 3212, 65535, 3649, 65535, 3993, 65535, 4643, 65535, 2987, + 65535, 65535, 65535, 65535, 65535, 2088, 65535, 65535, 4644, 65535, 65535, + 65535, 65535, 4645, 1515, 1494, 1862, 8319, 3109, 1928, 4216, 65535, 4648, + 1620, 65535, 65535, 4647, 65535, 65535, 65535, 1983, 65535, 65535, 4649, + 65535, 4122, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 8320, 65535, 65535, 4650, 65535, 4279, + 65535, 2253, 65535, 65535, 65535, 65535, 2183, 4651, 65535, 65535, 65535, + 65535, 4653, 4652, 65535, 2882, 1528, 65535, 65535, 65535, 1565, 4654, + 65535, 4655, 65535, 8321, 2184, 65535, 65535, 4656, 65535, 65535, 65535, + 65535, 1957, 65535, 65535, 65535, 65535, 65535, 65535, 2461, 4657, 65535, + 65535, 65535, 65535, 4031, 2370, 1937, 4142, 3055, 3696, 2630, 65535, + 65535, 65535, 65535, 65535, 2670, 65535, 2609, 2622, 65535, 2717, 65535, + 3697, 65535, 8322, 65535, 4660, 65535, 1538, 3056, 2254, 2198, 2044, 65535, + 65535, 4664, 3196, 3195, 1984, 2729, 4665, 4663, 1633, 3171, 2561, 2486, + 1509, 65535, 65535, 1771, 2325, 2485, 65535, 4666, 65535, 65535, 65535, + 65535, 65535, 65535, 4667, 65535, 1920, 1729, 65535, 65535, 65535, 2326, + 1919, 3352, 1508, 3494, 4071, 2256, 4224, 3422, 2255, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2082, 65535, 4676, 65535, 2040, + 3989, 65535, 65535, 65535, 65535, 65535, 3726, 65535, 65535, 4675, 65535, + 1847, 4670, 4671, 4673, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4674, 65535, 1938, 2884, 65535, 3866, 4672, 4668, 2228, 65535, 4669, 65535, + 4327, 65535, 65535, 65535, 3935, 65535, 3361, 2227, 2335, 65535, 65535, + 65535, 4677, 65535, 65535, 3538, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4681, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2631, 65535, 2623, 65535, 65535, 65535, + 65535, 65535, 4684, 4682, 65535, 4044, 65535, 4679, 4688, 4683, 65535, + 65535, 65535, 4686, 2199, 4072, 65535, 65535, 4687, 65535, 65535, 65535, + 4689, 65535, 4691, 65535, 65535, 65535, 8325, 2429, 4357, 65535, 4680, + 4678, 4690, 65535, 4685, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 8324, 65535, 65535, 65535, 65535, 65535, 4693, 65535, 4702, + 4695, 65535, 65535, 4699, 8326, 65535, 4700, 4696, 65535, 65535, 4729, + 65535, 65535, 2422, 1708, 65535, 65535, 65535, 65535, 4694, 65535, 65535, + 65535, 4704, 1495, 4703, 65535, 1414, 3801, 4701, 65535, 4697, 65535, + 65535, 4692, 4698, 2389, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4705, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1496, 4714, 65535, 65535, 4706, 4707, + 65535, 2730, 4020, 65535, 65535, 65535, 4712, 4711, 65535, 65535, 65535, + 3398, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4713, 65535, 65535, + 4710, 65535, 8327, 65535, 65535, 65535, 65535, 1523, 65535, 2371, 2835, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4708, 3449, 65535, 65535, + 65535, 4709, 65535, 1411, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4719, 4138, 65535, 2732, 65535, + 4725, 65535, 65535, 65535, 65535, 4724, 4715, 65535, 65535, 65535, 65535, + 3136, 65535, 4716, 65535, 65535, 65535, 3180, 4721, 2731, 65535, 65535, + 65535, 65535, 65535, 4718, 65535, 65535, 4109, 65535, 65535, 65535, 2095, + 65535, 65535, 4722, 4723, 65535, 65535, 65535, 65535, 4720, 4726, 65535, + 65535, 65535, 65535, 65535, 4717, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4732, 4737, 65535, 4733, + 65535, 4728, 65535, 65535, 4738, 3024, 65535, 8328, 4740, 65535, 2257, + 4730, 3288, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4734, 4727, 1798, 65535, 1863, 1760, 4735, 4731, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2153, 4741, 4739, 3058, + 1921, 1985, 65535, 4736, 65535, 2057, 65535, 65535, 65535, 65535, 65535, + 1539, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4745, 4743, 65535, 4800, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4748, 65535, 65535, + 65535, 65535, 65535, 4742, 65535, 4746, 65535, 65535, 4744, 65535, 65535, + 65535, 2487, 4747, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4750, + 65535, 4755, 65535, 65535, 65535, 4753, 4752, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3213, 65535, 65535, 1634, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4749, 65535, 4751, 2733, 1522, + 65535, 65535, 4754, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1659, 65535, 65535, 65535, 65535, 65535, + 4765, 65535, 2817, 4761, 65535, 4759, 65535, 4760, 65535, 4762, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1532, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3032, 65535, 4756, 65535, + 4757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1781, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4764, 65535, + 65535, 65535, 1864, 65535, 4767, 4763, 4766, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3867, 65535, 65535, 65535, 3530, 65535, 3689, 65535, + 65535, 65535, 65535, 65535, 4769, 65535, 65535, 65535, 65535, 65535, 4768, + 1728, 65535, 65535, 4770, 65535, 65535, 65535, 65535, 4773, 65535, 65535, + 65535, 65535, 4772, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4771, 65535, 3596, 65535, 65535, 4774, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4775, 65535, 65535, 65535, 65535, + 65535, 4777, 65535, 4776, 65535, 65535, 65535, 65535, 65535, 4779, 65535, + 65535, 65535, 4782, 4780, 4778, 4781, 65535, 65535, 65535, 65535, 4783, + 65535, 65535, 65535, 65535, 65535, 4784, 65535, 65535, 4785, 65535, 4786, + 65535, 65535, 65535, 4787, 4548, 65535, 2629, 2488, 65535, 65535, 1680, + 65535, 1497, 65535, 65535, 3231, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4788, 65535, 2353, 65535, 1456, 2881, 65535, + 65535, 65535, 65535, 65535, 4789, 2200, 65535, 65535, 2336, 65535, 4791, + 4790, 65535, 65535, 3917, 4792, 65535, 65535, 65535, 4794, 4793, 65535, + 4795, 65535, 4796, 65535, 2154, 65535, 65535, 1567, 4797, 65535, 65535, + 4799, 65535, 4798, 65535, 65535, 65535, 4801, 65535, 65535, 3441, 65535, + 65535, 65535, 65535, 65535, 65535, 4802, 1430, 2412, 65535, 65535, 65535, + 65535, 2096, 65535, 65535, 3242, 65535, 65535, 65535, 65535, 65535, 65535, + 4803, 4804, 65535, 65535, 4806, 65535, 65535, 65535, 65535, 4807, 65535, + 2417, 65535, 65535, 65535, 65535, 2022, 65535, 65535, 3970, 65535, 65535, + 65535, 4805, 4808, 2382, 2258, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 8329, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4812, 65535, + 65535, 2354, 8330, 3214, 65535, 65535, 4809, 3347, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4813, 65535, 65535, 2885, + 65535, 65535, 65535, 65535, 65535, 4811, 4814, 65535, 2098, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4815, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4816, 65535, 2259, 1723, + 4818, 65535, 65535, 65535, 65535, 65535, 4819, 65535, 8331, 65535, 65535, + 65535, 4820, 65535, 65535, 4817, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4810, 65535, 65535, 4821, 65535, + 65535, 4822, 8333, 8332, 65535, 65535, 4015, 65535, 65535, 2800, 65535, + 65535, 65535, 4824, 4825, 4823, 65535, 4827, 65535, 65535, 65535, 65535, + 65535, 3595, 65535, 65535, 1481, 3813, 65535, 65535, 4828, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2818, 65535, 65535, 2562, 65535, 3632, 1865, + 65535, 2424, 65535, 65535, 65535, 4004, 65535, 3495, 65535, 65535, 2155, + 3148, 65535, 65535, 65535, 4826, 4829, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3137, 65535, 65535, 65535, 4830, 65535, 65535, + 65535, 4831, 65535, 65535, 65535, 4833, 65535, 65535, 3362, 65535, 65535, + 65535, 65535, 65535, 1799, 65535, 65535, 65535, 65535, 7802, 1568, 3936, + 65535, 65535, 2801, 3423, 65535, 65535, 65535, 65535, 2419, 65535, 65535, + 4839, 65535, 65535, 3882, 4290, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1681, 4835, 65535, 65535, 65535, 65535, 65535, 3033, 4838, + 65535, 3450, 65535, 65535, 3424, 3451, 3690, 3334, 65535, 65535, 65535, + 2390, 65535, 65535, 65535, 4834, 65535, 65535, 65535, 65535, 65535, 65535, + 1589, 65535, 3405, 65535, 65535, 65535, 65535, 4836, 65535, 4832, 65535, + 65535, 2867, 65535, 65535, 65535, 4840, 65535, 65535, 65535, 65535, 2677, + 65535, 65535, 65535, 65535, 1986, 65535, 4841, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3925, 65535, + 65535, 65535, 3100, 65535, 65535, 65535, 65535, 3327, 65535, 8336, 4843, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3994, 65535, 65535, + 4844, 65535, 65535, 4849, 65535, 65535, 65535, 8337, 3868, 65535, 65535, + 65535, 65535, 4848, 4842, 4845, 4847, 65535, 65535, 2355, 65535, 65535, + 3894, 65535, 65535, 65535, 4850, 65535, 3232, 65535, 65535, 1682, 65535, + 2802, 65535, 65535, 65535, 65535, 4852, 65535, 4851, 65535, 2327, 65535, + 4853, 4855, 4854, 65535, 65535, 4857, 65535, 4846, 4859, 65535, 65535, + 65535, 65535, 4858, 4856, 65535, 65535, 65535, 65535, 65535, 2489, 2868, + 65535, 3059, 4860, 2941, 1486, 3639, 65535, 65535, 65535, 65535, 3348, + 65535, 4862, 4861, 4863, 4864, 4865, 65535, 65535, 65535, 65535, 4866, + 65535, 65535, 65535, 65535, 65535, 65535, 3902, 4867, 8338, 65535, 65535, + 65535, 1635, 4868, 65535, 65535, 65535, 65535, 4163, 1707, 65535, 4646, + 2671, 3132, 4869, 4116, 65535, 65535, 65535, 65535, 65535, 4061, 65535, + 65535, 4871, 65535, 3172, 65535, 3406, 3133, 3814, 4872, 4873, 1594, 65535, + 65535, 2563, 4874, 65535, 65535, 65535, 65535, 1457, 4875, 65535, 65535, + 65535, 65535, 65535, 4876, 65535, 65535, 65535, 65535, 65535, 1569, 65535, + 65535, 1866, 3541, 3937, 65535, 65535, 65535, 65535, 4880, 3060, 4879, + 2099, 65535, 8339, 4006, 4878, 65535, 3452, 4882, 65535, 4881, 8340, 65535, + 8341, 65535, 65535, 4884, 65535, 4883, 8342, 65535, 1595, 65535, 4885, + 2734, 4887, 3200, 65535, 4886, 65535, 3872, 65535, 65535, 65535, 65535, + 2718, 3442, 65535, 65535, 65535, 4888, 65535, 65535, 65535, 65535, 2260, + 65535, 65535, 65535, 4889, 3572, 3727, 4090, 65535, 65535, 65535, 65535, + 65535, 3576, 65535, 65535, 4898, 65535, 65535, 65535, 65535, 65535, 1903, + 65535, 65535, 4172, 65535, 65535, 4056, 65535, 4993, 65535, 4890, 65535, + 65535, 65535, 65535, 65535, 4893, 8343, 3138, 65535, 65535, 3971, 65535, + 65535, 65535, 3425, 65535, 65535, 65535, 65535, 65535, 4894, 65535, 65535, + 65535, 65535, 65535, 65535, 4016, 8344, 2391, 65535, 65535, 2735, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4895, 65535, 65535, 2491, 65535, + 2490, 65535, 65535, 65535, 65535, 1434, 2201, 65535, 2924, 1458, 65535, + 65535, 65535, 65535, 4899, 4900, 65535, 4897, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1527, 1800, 65535, 4896, 65535, 4078, 3776, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1417, + 65535, 65535, 65535, 65535, 1498, 65535, 65535, 65535, 2492, 65535, 1459, + 65535, 1412, 65535, 65535, 65535, 65535, 65535, 4905, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4903, 65535, 65535, 65535, 65535, 65535, 65535, + 4069, 65535, 4906, 65535, 4904, 65535, 65535, 4902, 2836, 65535, 65535, + 65535, 65535, 4901, 65535, 65535, 65535, 3911, 65535, 65535, 65535, 65535, + 65535, 2229, 65535, 65535, 65535, 65535, 65535, 4910, 4911, 65535, 65535, + 65535, 65535, 65535, 2736, 65535, 65535, 65535, 4907, 4335, 65535, 65535, + 65535, 65535, 3615, 65535, 65535, 4909, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4912, 65535, + 65535, 65535, 3815, 65535, 65535, 65535, 4913, 65535, 4908, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4068, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3633, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4914, 3777, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4915, 4919, 4916, 65535, 65535, 1636, 4918, + 65535, 65535, 65535, 65535, 65535, 65535, 2564, 65535, 4917, 2156, 65535, + 65535, 65535, 4931, 65535, 65535, 65535, 65535, 65535, 4924, 4921, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3263, 65535, 4920, + 65535, 65535, 4922, 65535, 65535, 4923, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4925, 4926, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1867, 65535, 4928, 4927, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4929, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2803, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4932, 65535, 3349, 65535, 65535, 65535, + 1540, 65535, 4930, 65535, 65535, 65535, 4933, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4934, 65535, 4937, 65535, 65535, 4935, 65535, 4936, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2493, + 4938, 65535, 65535, 2261, 4939, 8345, 2533, 3125, 65535, 4940, 4941, 2501, + 2262, 65535, 4091, 65535, 65535, 65535, 1887, 2202, 4942, 1747, 65535, + 65535, 4943, 65535, 3126, 65535, 65535, 65535, 65535, 4944, 4984, 65535, + 4945, 65535, 4946, 65535, 65535, 4947, 65535, 4949, 65535, 65535, 65535, + 65535, 65535, 4950, 65535, 65535, 4951, 65535, 3181, 65535, 1510, 2610, + 1443, 65535, 3062, 1801, 2558, 65535, 2263, 65535, 65535, 65535, 65535, + 65535, 3453, 65535, 2632, 1802, 3267, 3363, 1433, 1904, 3938, 65535, 2571, + 65535, 65535, 1929, 2988, 2565, 4143, 4952, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1939, 65535, 2392, 65535, 65535, 1709, 1570, 2737, + 1637, 65535, 4953, 4173, 65535, 65535, 65535, 65535, 65535, 2672, 8346, + 65535, 2605, 4954, 1868, 3527, 4050, 4955, 65535, 4956, 65535, 65535, 3816, + 65535, 65535, 65535, 4958, 65535, 1793, 2060, 4957, 65535, 65535, 65535, + 8348, 65535, 65535, 1803, 65535, 2837, 4962, 2444, 65535, 1638, 4961, + 65535, 4959, 4963, 4960, 3582, 5590, 2838, 65535, 4964, 8349, 65535, 4261, + 65535, 4965, 65535, 65535, 4967, 65535, 3289, 4966, 65535, 2916, 65535, + 2534, 65535, 65535, 65535, 3149, 2624, 65535, 3844, 2989, 65535, 2582, + 4968, 2738, 4969, 4970, 1460, 3127, 2869, 65535, 4971, 3496, 2739, 65535, + 2740, 65535, 4972, 65535, 65535, 2990, 65535, 65535, 65535, 2741, 65535, + 65535, 65535, 8350, 65535, 4973, 65535, 4974, 65535, 4105, 65535, 65535, + 65535, 4975, 65535, 65535, 65535, 65535, 2011, 65535, 65535, 65535, 2633, + 65535, 65535, 65535, 65535, 65535, 65535, 4976, 4977, 2597, 2831, 3561, + 2871, 3753, 3573, 2014, 4978, 65535, 65535, 65535, 1958, 4979, 65535, 2067, + 65535, 3524, 1613, 65535, 2494, 4980, 4983, 4982, 2066, 65535, 4981, 65535, + 3407, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3117, 65535, + 3426, 2577, 65535, 65535, 3063, 4225, 65535, 65535, 65535, 65535, 65535, + 65535, 4985, 65535, 4986, 3531, 65535, 2462, 65535, 65535, 65535, 65535, + 4988, 65535, 65535, 4989, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4990, 65535, 65535, 65535, 1869, 4991, 65535, 65535, 4992, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1609, 65535, 65535, 65535, 65535, 8351, 65535, 3034, 1853, 65535, + 4994, 4049, 65535, 65535, 65535, 65535, 3151, 65535, 1748, 65535, 65535, + 4996, 4998, 1848, 65535, 8352, 4995, 4997, 65535, 5000, 65535, 65535, + 65535, 65535, 65535, 65535, 4999, 65535, 5001, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5002, 65535, 65535, 65535, 65535, 65535, 65535, 3506, + 1987, 65535, 65535, 65535, 65535, 65535, 65535, 1666, 5003, 5008, 65535, + 65535, 5006, 65535, 3940, 3939, 65535, 65535, 65535, 65535, 8353, 3454, + 65535, 65535, 65535, 5005, 2683, 65535, 5004, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2901, 65535, 65535, 65535, 5009, 65535, + 65535, 2423, 65535, 65535, 5015, 65535, 65535, 5016, 5010, 1710, 5011, + 5020, 5019, 5018, 5014, 65535, 65535, 65535, 5013, 65535, 65535, 5017, + 65535, 65535, 65535, 65535, 8354, 65535, 3941, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8357, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5024, 5021, 65535, + 5023, 65535, 4217, 65535, 5022, 8355, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5012, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2902, 65535, 65535, 5025, 8358, 65535, + 2372, 65535, 65535, 65535, 5026, 65535, 65535, 5027, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5030, 65535, 5029, + 65535, 65535, 5028, 65535, 65535, 65535, 3455, 5007, 65535, 65535, 65535, + 5036, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5032, 65535, 65535, 65535, 65535, 5031, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5033, 65535, 5034, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5037, 8359, 8360, 4299, 65535, + 5038, 5035, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5039, 65535, 65535, 1849, 5040, 65535, 65535, 8361, 65535, + 5042, 5041, 65535, 65535, 5043, 65535, 65535, 65535, 65535, 5044, 65535, + 2991, 2634, 65535, 65535, 2699, 65535, 3074, 65535, 2264, 2373, 2265, 1959, + 65535, 65535, 5045, 65535, 65535, 2374, 65535, 65535, 2203, 5046, 4047, + 3606, 5047, 65535, 2266, 65535, 65535, 65535, 1797, 65535, 3202, 2023, + 65535, 65535, 65535, 2495, 3818, 65535, 65535, 3698, 65535, 65535, 65535, + 65535, 5048, 1870, 65535, 65535, 65535, 65535, 5051, 65535, 65535, 65535, + 65535, 3290, 65535, 65535, 5050, 5049, 5052, 65535, 3364, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2886, 65535, 65535, 65535, 65535, 65535, + 2496, 65535, 2955, 65535, 3152, 1881, 65535, 65535, 3291, 65535, 65535, + 5053, 5054, 2804, 65535, 65535, 65535, 65535, 3972, 65535, 65535, 5057, + 65535, 65535, 5056, 5055, 3852, 65535, 5064, 65535, 65535, 65535, 65535, + 4005, 65535, 5058, 65535, 65535, 65535, 65535, 65535, 5060, 4022, 65535, + 5059, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5061, 65535, 3673, + 5062, 3883, 5063, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1804, 3884, 3586, 5065, 5066, 65535, + 2267, 1805, 5067, 2185, 4171, 4144, 1871, 5069, 65535, 3292, 65535, 2268, + 2742, 65535, 65535, 3728, 65535, 65535, 2743, 65535, 65535, 65535, 65535, + 2719, 65535, 65535, 65535, 65535, 65535, 3365, 3942, 3408, 65535, 65535, + 2269, 65535, 3819, 65535, 65535, 65535, 5070, 65535, 65535, 65535, 65535, + 65535, 3440, 2383, 65535, 65535, 65535, 2204, 65535, 3366, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1444, 2709, 2270, 4174, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5071, 5072, 3620, 65535, 65535, + 65535, 65535, 5073, 4316, 4336, 65535, 65535, 65535, 65535, 5075, 5074, + 65535, 65535, 1730, 65535, 65535, 5076, 65535, 65535, 65535, 5079, 5080, + 65535, 5078, 65535, 3791, 2744, 5082, 5081, 5077, 65535, 65535, 65535, + 65535, 5083, 5084, 65535, 65535, 5085, 65535, 65535, 65535, 5088, 5086, + 65535, 5087, 5089, 65535, 1571, 3367, 5090, 65535, 2157, 1683, 3593, 65535, + 5091, 3568, 65535, 3912, 65535, 5092, 4337, 65535, 65535, 65535, 65535, + 5093, 3885, 5096, 4418, 4434, 65535, 2553, 3562, 5097, 65535, 1940, 3293, + 1499, 5098, 3859, 2271, 65535, 65535, 3243, 65535, 65535, 65535, 3368, + 65535, 8362, 65535, 65535, 65535, 4120, 2186, 2205, 65535, 5099, 65535, + 65535, 65535, 5100, 65535, 5106, 65535, 2606, 65535, 65535, 8363, 3294, + 65535, 1988, 5101, 65535, 65535, 65535, 3770, 65535, 3233, 65535, 65535, + 5102, 65535, 65535, 65535, 8283, 65535, 65535, 5103, 65535, 1989, 65535, + 5104, 65535, 5105, 65535, 65535, 5107, 65535, 3469, 65535, 65535, 5108, + 5109, 65535, 5110, 65535, 65535, 5095, 5094, 65535, 65535, 65535, 5111, + 2100, 65535, 65535, 65535, 3766, 8364, 65535, 2393, 3782, 3295, 3802, 5112, + 65535, 65535, 2745, 1541, 65535, 5113, 65535, 65535, 65535, 5114, 65535, + 4123, 65535, 65535, 3729, 65535, 65535, 5117, 1596, 2925, 5116, 5115, 2101, + 3153, 65535, 5121, 5119, 65535, 5118, 4236, 2230, 65535, 65535, 65535, + 2720, 5120, 3427, 2661, 65535, 65535, 65535, 3509, 5124, 5123, 65535, + 65535, 65535, 65535, 5122, 65535, 5125, 2231, 65535, 65535, 65535, 65535, + 65535, 65535, 5126, 3851, 2690, 65535, 65535, 5127, 3754, 65535, 65535, + 65535, 65535, 3510, 3296, 65535, 65535, 8365, 65535, 3399, 65535, 65535, + 5128, 1890, 65535, 65535, 65535, 65535, 65535, 2839, 65535, 3771, 65535, + 65535, 65535, 65535, 65535, 65535, 1872, 3577, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5129, 2497, 3973, 3974, 65535, 65535, 1597, + 5134, 8366, 65535, 3268, 65535, 65535, 65535, 5131, 65535, 65535, 65535, + 65535, 65535, 65535, 1684, 65535, 65535, 65535, 65535, 5182, 5133, 65535, + 65535, 65535, 3587, 65535, 65535, 5132, 65535, 65535, 5130, 65535, 2345, + 65535, 5136, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5142, 5148, 5140, 65535, 3443, 65535, + 65535, 5145, 3820, 65535, 65535, 5139, 65535, 5144, 4300, 2498, 65535, + 65535, 3154, 5137, 65535, 65535, 65535, 1941, 5147, 2926, 1572, 5141, 1685, + 5146, 65535, 65535, 65535, 1990, 65535, 5143, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5149, 65535, 65535, 65535, 65535, 65535, 65535, + 5151, 5161, 5159, 65535, 65535, 5156, 65535, 65535, 65535, 5155, 4317, + 65535, 5157, 65535, 65535, 1991, 65535, 2272, 65535, 65535, 2721, 65535, + 65535, 65535, 5164, 5150, 65535, 65535, 8367, 65535, 5154, 5138, 65535, + 1687, 5158, 5160, 3244, 65535, 65535, 2357, 1621, 5152, 5163, 5162, 1992, + 65535, 3110, 1761, 65535, 65535, 65535, 65535, 2102, 65535, 5153, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5165, 65535, 5168, + 5170, 8368, 65535, 65535, 65535, 2566, 8369, 5176, 3369, 5166, 65535, + 65535, 65535, 65535, 5174, 65535, 1686, 65535, 5172, 5173, 65535, 65535, + 5169, 5171, 65535, 65535, 65535, 2232, 4145, 65535, 65535, 1806, 65535, + 65535, 1560, 5175, 65535, 3597, 1422, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3730, 5135, 5181, 5185, 4110, 65535, 5178, 65535, 65535, + 65535, 3456, 5183, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2805, + 5184, 3532, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4362, 65535, 5180, 65535, 8371, 65535, 65535, 5186, 65535, 2346, 65535, + 2956, 65535, 8370, 1461, 5179, 5177, 65535, 3065, 65535, 65535, 65535, + 5167, 2463, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3139, 5198, + 8373, 3066, 5193, 65535, 5190, 5191, 65535, 2607, 5194, 5197, 65535, 65535, + 65535, 65535, 5192, 2636, 65535, 5195, 65535, 65535, 5189, 65535, 4133, + 4132, 65535, 65535, 65535, 5199, 5200, 1462, 65535, 8374, 65535, 65535, + 65535, 5188, 65535, 65535, 65535, 65535, 2055, 1415, 65535, 65535, 65535, + 1807, 8372, 5196, 65535, 65535, 65535, 65535, 65535, 5204, 5203, 65535, + 65535, 65535, 5208, 65535, 65535, 65535, 8376, 65535, 65535, 65535, 5209, + 65535, 65535, 8375, 65535, 65535, 65535, 65535, 5207, 5210, 5202, 5206, + 65535, 65535, 5211, 65535, 5212, 65535, 65535, 5201, 2535, 65535, 5205, + 3155, 2273, 5187, 2840, 65535, 65535, 65535, 65535, 5225, 65535, 3926, + 65535, 65535, 5215, 5216, 5217, 65535, 65535, 5224, 65535, 5223, 65535, + 65535, 4040, 1808, 65535, 5221, 65535, 2104, 1711, 65535, 65535, 5218, + 65535, 65535, 4253, 5220, 1463, 5222, 65535, 5213, 5219, 5226, 2103, 5214, + 65535, 65535, 65535, 65535, 65535, 65535, 4196, 65535, 65535, 65535, 4146, + 65535, 65535, 65535, 65535, 5229, 65535, 65535, 5233, 65535, 65535, 65535, + 3101, 65535, 4318, 5234, 65535, 65535, 5231, 65535, 5228, 65535, 8377, + 5227, 5232, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3869, 65535, 65535, 3497, 65535, 2105, 65535, 5235, 5230, 65535, 5236, + 65535, 65535, 65535, 2158, 65535, 65535, 65535, 1614, 65535, 65535, 65535, + 5244, 65535, 65535, 65535, 1809, 65535, 65535, 65535, 65535, 5242, 65535, + 65535, 5243, 2358, 5241, 5239, 5238, 5245, 5237, 5247, 65535, 65535, 1688, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5249, 65535, 65535, + 5248, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3297, 65535, 5252, 65535, 5250, 5240, 2159, 65535, 5251, 65535, + 5255, 5254, 5256, 5253, 5257, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5258, 5259, 3927, 65535, 5261, 5260, 2662, 65535, 2927, 1667, 1689, + 8378, 5262, 65535, 1440, 65535, 65535, 65535, 2957, 5263, 65535, 7084, + 5264, 2132, 65535, 5265, 65535, 65535, 65535, 65535, 2992, 65535, 65535, + 65535, 5266, 65535, 65535, 65535, 5267, 1905, 5268, 65535, 5269, 5270, + 3156, 65535, 65535, 65535, 2206, 65535, 65535, 4106, 65535, 65535, 65535, + 3975, 2705, 5271, 65535, 65535, 65535, 65535, 65535, 2993, 7266, 3731, + 65535, 2611, 65535, 2394, 5272, 65535, 65535, 65535, 65535, 3140, 65535, + 3860, 65535, 65535, 3182, 65535, 65535, 5275, 65535, 65535, 5273, 65535, + 5276, 65535, 65535, 5274, 65535, 65535, 65535, 65535, 5277, 65535, 65535, + 65535, 65535, 65535, 3870, 65535, 65535, 1432, 65535, 65535, 65535, 65535, + 3821, 65535, 65535, 3732, 65535, 65535, 5278, 65535, 5281, 2746, 1906, + 65535, 5279, 5286, 2747, 65535, 65535, 65535, 65535, 5280, 3607, 65535, + 65535, 65535, 65535, 65535, 65535, 4197, 5282, 5283, 5287, 3457, 5284, + 2274, 2975, 65535, 65535, 5301, 3685, 65535, 3183, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 8379, 65535, 65535, 65535, 65535, 3733, 5370, + 65535, 65535, 65535, 65535, 3943, 65535, 65535, 65535, 3370, 65535, 65535, + 65535, 4032, 65535, 5290, 1598, 3269, 65535, 65535, 65535, 65535, 5299, + 65535, 65535, 3215, 5293, 5300, 5295, 5302, 5298, 65535, 5297, 3650, 65535, + 5291, 1690, 5289, 1960, 3184, 5285, 65535, 65535, 5288, 2275, 2972, 65535, + 2748, 5296, 3621, 65535, 65535, 1961, 1731, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1762, 2820, 5304, 5309, 65535, + 5305, 65535, 2160, 65535, 5310, 2445, 2328, 65535, 65535, 65535, 65535, + 65535, 65535, 2637, 5292, 65535, 2536, 5307, 65535, 65535, 65535, 65535, + 2499, 5308, 1445, 65535, 65535, 5303, 65535, 65535, 65535, 65535, 3298, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1962, 65535, 65535, 65535, + 65535, 65535, 1993, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5306, + 1416, 65535, 65535, 2384, 65535, 65535, 65535, 2841, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3371, 65535, 65535, 3717, + 5312, 3069, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3111, 65535, 65535, 2454, 5313, 65535, 5315, 5311, 65535, 65535, 65535, + 65535, 3918, 65535, 3318, 65535, 65535, 65535, 65535, 3067, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3944, 2583, 5327, + 65535, 5326, 65535, 65535, 2907, 65535, 65535, 65535, 2161, 65535, 65535, + 65535, 5320, 2750, 65535, 65535, 3549, 3588, 65535, 65535, 65535, 65535, + 5318, 65535, 65535, 3068, 65535, 65535, 65535, 65535, 2625, 5323, 65535, + 65535, 2749, 65535, 5317, 5322, 65535, 65535, 3622, 65535, 65535, 65535, + 5316, 65535, 2068, 65535, 65535, 1752, 65535, 65535, 65535, 5324, 4240, + 2395, 3216, 5321, 65535, 2973, 65535, 2276, 2887, 1573, 3035, 5319, 1916, + 65535, 65535, 65535, 65535, 65535, 2106, 65535, 3336, 5325, 65535, 65535, + 65535, 65535, 65535, 3070, 65535, 65535, 5328, 65535, 5330, 65535, 65535, + 3124, 5336, 65535, 5331, 65535, 65535, 5333, 65535, 65535, 65535, 65535, + 65535, 3792, 3372, 65535, 5334, 65535, 65535, 65535, 4147, 65535, 65535, + 65535, 4175, 1810, 65535, 65535, 65535, 65535, 65535, 1423, 65535, 5332, + 65535, 65535, 65535, 65535, 65535, 5329, 65535, 65535, 65535, 65535, 1873, + 65535, 65535, 65535, 65535, 65535, 1574, 8380, 5335, 65535, 65535, 65535, + 4176, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5339, 65535, 65535, 65535, 65535, 65535, 65535, 3128, 65535, 5346, + 65535, 65535, 65535, 5340, 65535, 65535, 5337, 5344, 65535, 65535, 65535, + 65535, 5314, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5341, 65535, 5345, 65535, 65535, 65535, 3699, 3458, 65535, 65535, 65535, + 65535, 65535, 65535, 5338, 65535, 5342, 65535, 65535, 65535, 2107, 65535, + 65535, 65535, 2430, 65535, 65535, 65535, 2974, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5350, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3389, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8381, 65535, 65535, 65535, 65535, 65535, 65535, 5347, + 65535, 4011, 65535, 65535, 65535, 65535, 65535, 5348, 65535, 65535, 65535, + 65535, 65535, 65535, 5349, 65535, 4087, 65535, 2915, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2133, 65535, 65535, 65535, 65535, 5356, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2464, 5353, + 65535, 5352, 65535, 65535, 65535, 65535, 3589, 65535, 65535, 8382, 3498, + 65535, 65535, 65535, 65535, 65535, 3400, 5354, 65535, 65535, 65535, 5355, + 65535, 3838, 65535, 3608, 2446, 65535, 2994, 65535, 3995, 65535, 65535, + 65535, 65535, 65535, 65535, 1732, 65535, 5362, 5357, 65535, 65535, 65535, + 65535, 4177, 5364, 65535, 65535, 5360, 65535, 5361, 65535, 65535, 65535, + 65535, 65535, 3071, 8383, 65535, 65535, 65535, 5359, 65535, 5294, 65535, + 65535, 65535, 5363, 65535, 5358, 65535, 65535, 65535, 65535, 65535, 5368, + 5369, 3390, 5371, 65535, 65535, 2447, 5366, 65535, 65535, 65535, 65535, + 1907, 65535, 65535, 5372, 65535, 5365, 5376, 65535, 5375, 65535, 5374, + 65535, 65535, 65535, 5377, 65535, 65535, 5379, 2806, 65535, 5378, 65535, + 65535, 65535, 65535, 5382, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5380, 65535, 65535, 65535, 5381, 5343, 65535, 65535, 65535, 65535, + 65535, 5384, 5383, 65535, 65535, 65535, 65535, 65535, 5351, 5385, 5373, + 65535, 65535, 2500, 65535, 65535, 65535, 65535, 5386, 5387, 5389, 5388, + 5390, 1691, 65535, 2277, 65535, 65535, 3945, 2928, 65535, 65535, 65535, + 65535, 65535, 2207, 65535, 65535, 5392, 65535, 65535, 65535, 65535, 5395, + 8384, 3809, 65535, 1942, 65535, 65535, 65535, 5394, 5393, 3623, 5396, 1994, + 65535, 65535, 65535, 5398, 5397, 65535, 65535, 65535, 1811, 2465, 65535, + 65535, 3533, 65535, 65535, 65535, 65535, 65535, 2108, 65535, 65535, 65535, + 2903, 65535, 5399, 65535, 2929, 3391, 65535, 3822, 5400, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5401, 5402, 65535, 65535, + 65535, 3877, 4948, 2951, 65535, 65535, 3803, 65535, 2405, 65535, 3734, + 3700, 65535, 65535, 65535, 65535, 65535, 3428, 65535, 4262, 65535, 5404, + 2585, 65535, 65535, 5405, 65535, 1431, 65535, 65535, 2025, 2958, 65535, + 3823, 65535, 65535, 65535, 5406, 2477, 3234, 65535, 2502, 2842, 65535, + 65535, 65535, 65535, 65535, 65535, 5407, 65535, 3946, 65535, 65535, 1590, + 2503, 65535, 65535, 65535, 5410, 65535, 5408, 5411, 4254, 5409, 65535, + 65535, 65535, 65535, 3004, 5412, 65535, 65535, 3119, 65535, 65535, 5413, + 65535, 65535, 65535, 65535, 1875, 65535, 5415, 65535, 5414, 65535, 65535, + 65535, 65535, 5416, 5417, 1876, 65535, 65535, 3569, 3217, 1955, 2504, 3072, + 65535, 65535, 2691, 1425, 65535, 65535, 65535, 5418, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1599, 5422, 65535, 65535, 65535, 65535, + 8385, 65535, 2278, 5421, 65535, 65535, 2360, 2751, 65535, 8388, 5420, + 65535, 2752, 65535, 4073, 2359, 65535, 65535, 65535, 1464, 2959, 8386, + 65535, 65535, 65535, 65535, 65535, 65535, 5427, 65535, 8390, 2930, 1542, + 65535, 65535, 65535, 8391, 2684, 65535, 4017, 2431, 65535, 65535, 65535, + 65535, 2753, 8389, 2920, 65535, 8279, 65535, 65535, 5426, 5424, 5425, + 65535, 65535, 65535, 65535, 8387, 3270, 65535, 65535, 5457, 65535, 5431, + 2537, 2279, 5429, 65535, 65535, 65535, 65535, 5430, 65535, 2843, 65535, + 65535, 65535, 5428, 65535, 65535, 2458, 65535, 65535, 65535, 65535, 8393, + 65535, 8394, 65535, 65535, 65535, 5433, 5432, 5437, 65535, 65535, 5438, + 65535, 5434, 8392, 1693, 5435, 5436, 3718, 65535, 65535, 65535, 65535, + 3824, 2109, 5439, 65535, 65535, 8396, 2931, 65535, 2754, 65535, 65535, + 65535, 3245, 65535, 65535, 65535, 65535, 65535, 65535, 2012, 65535, 5440, + 5444, 65535, 65535, 1640, 5441, 5443, 65535, 65535, 65535, 65535, 5442, + 65535, 65535, 2706, 65535, 65535, 65535, 65535, 3235, 1446, 5445, 8397, + 65535, 65535, 65535, 5446, 65535, 65535, 8398, 65535, 3299, 65535, 65535, + 65535, 4310, 65535, 65535, 65535, 65535, 2478, 65535, 65535, 3928, 65535, + 65535, 65535, 8399, 65535, 3976, 65535, 65535, 65535, 5453, 5448, 65535, + 65535, 5451, 65535, 5450, 8400, 65535, 5447, 65535, 65535, 5452, 65535, + 65535, 3539, 65535, 5449, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5454, 65535, 65535, 2707, 5455, 65535, + 4178, 3659, 65535, 65535, 5456, 65535, 65535, 65535, 65535, 65535, 5458, + 65535, 65535, 5459, 65535, 65535, 65535, 65535, 65535, 65535, 5460, 65535, + 2015, 1543, 2280, 5461, 65535, 5462, 2712, 3073, 8401, 8282, 4661, 3037, + 3036, 3157, 2388, 65535, 65535, 4499, 65535, 65535, 65535, 65535, 2145, + 4148, 65535, 3947, 65535, 3853, 8402, 5463, 65535, 65535, 65535, 65535, + 2432, 3320, 5464, 4338, 65535, 65535, 65535, 3977, 65535, 3300, 5465, 1877, + 65535, 65535, 65535, 65535, 65535, 65535, 5466, 5467, 4099, 65535, 4045, + 4033, 4007, 2448, 5469, 65535, 65535, 2612, 65535, 65535, 3996, 65535, + 5471, 5474, 5473, 65535, 1874, 65535, 65535, 1943, 65535, 5470, 65535, + 5472, 65535, 65535, 65535, 65535, 5475, 65535, 65535, 2908, 65535, 65535, + 65535, 65535, 4226, 1450, 2413, 3129, 65535, 2598, 65535, 65535, 2808, + 65535, 65535, 5478, 65535, 65535, 3429, 65535, 5476, 3112, 5477, 2807, + 4102, 5479, 5480, 4207, 8404, 65535, 65535, 65535, 5485, 65535, 65535, + 2281, 65535, 3624, 5482, 3459, 5419, 5423, 65535, 1926, 65535, 3610, 65535, + 65535, 65535, 65535, 5484, 65535, 2755, 3701, 65535, 65535, 65535, 65535, + 65535, 5490, 65535, 3755, 65535, 5481, 65535, 5487, 5486, 65535, 65535, + 65535, 2960, 65535, 65535, 65535, 65535, 4024, 65535, 4280, 65535, 65535, + 4018, 65535, 1641, 2505, 65535, 65535, 4363, 5489, 2904, 65535, 65535, + 65535, 5488, 65535, 65535, 5483, 65535, 65535, 65535, 65535, 65535, 2208, + 65535, 65535, 65535, 5495, 5493, 65535, 1642, 5491, 5497, 5503, 65535, + 8405, 65535, 65535, 65535, 65535, 8407, 3141, 65535, 65535, 3886, 65535, + 5505, 65535, 65535, 65535, 3761, 65535, 65535, 65535, 5504, 3651, 3978, + 1812, 65535, 3000, 2663, 65535, 65535, 65535, 3340, 65535, 4149, 65535, + 65535, 5500, 5499, 65535, 65535, 65535, 5501, 65535, 5498, 65535, 65535, + 5506, 65535, 5496, 65535, 65535, 5494, 65535, 5502, 5492, 65535, 3271, + 65535, 4129, 2575, 2433, 65535, 65535, 65535, 65535, 65535, 2375, 65535, + 65535, 4026, 1724, 65535, 8408, 3335, 3519, 1544, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2995, 65535, 65535, 2933, 2077, 65535, 65535, 65535, 65535, 65535, + 65535, 5508, 65535, 65535, 2282, 1783, 65535, 65535, 65535, 65535, 65535, + 65535, 5510, 1775, 5516, 65535, 65535, 65535, 65535, 65535, 65535, 5513, + 65535, 2996, 65535, 65535, 65535, 1734, 2361, 65535, 65535, 1733, 2396, + 65535, 65535, 5511, 2136, 2110, 3460, 8409, 65535, 5509, 65535, 1447, + 65535, 65535, 65535, 65535, 5512, 5514, 65535, 2018, 2079, 8406, 1813, + 1922, 65535, 65535, 65535, 65535, 5517, 65535, 65535, 2438, 4028, 65535, + 2466, 65535, 65535, 65535, 5518, 65535, 65535, 65535, 3775, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5530, + 65535, 1616, 5519, 65535, 65535, 65535, 65535, 65535, 65535, 5536, 5520, + 65535, 4263, 65535, 5527, 65535, 3634, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5535, 65535, 5522, 65535, 65535, 65535, 1429, 5524, 65535, + 65535, 2283, 65535, 65535, 65535, 5526, 65535, 5525, 65535, 5521, 5532, + 65535, 2756, 65535, 65535, 65535, 4870, 2233, 4227, 65535, 65535, 65535, + 65535, 5523, 65535, 3373, 1694, 2362, 65535, 5515, 65535, 5531, 1756, + 65535, 65535, 5529, 5533, 65535, 3461, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1879, 65535, 5563, 65535, 8280, 4082, 5538, 1878, 65535, + 5545, 65535, 8410, 65535, 65535, 3979, 65535, 5546, 5548, 65535, 5552, + 5540, 65535, 3205, 65535, 65535, 65535, 65535, 3462, 5556, 5543, 65535, + 5553, 65535, 65535, 65535, 5547, 65535, 65535, 65535, 65535, 65535, 65535, + 2844, 5557, 65535, 65535, 2932, 65535, 65535, 65535, 65535, 65535, 65535, + 5555, 1814, 65535, 65535, 65535, 65535, 65535, 4371, 5537, 65535, 65535, + 5551, 1465, 65535, 65535, 5539, 65535, 65535, 4067, 5544, 2821, 3328, 5534, + 65535, 65535, 5550, 65535, 65535, 65535, 65535, 65535, 65535, 2909, 5560, + 1772, 2162, 65535, 65535, 65535, 65535, 5562, 5541, 5561, 65535, 5554, + 5542, 65535, 5558, 65535, 5559, 65535, 65535, 65535, 65535, 65535, 5576, + 65535, 65535, 65535, 3523, 65535, 5549, 65535, 65535, 5572, 65535, 65535, + 65535, 5574, 65535, 3345, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3845, 5569, 3143, 65535, 65535, 65535, 5575, 3038, 65535, 5566, + 5579, 5578, 65535, 3556, 5577, 3551, 65535, 65535, 65535, 65535, 65535, + 8412, 65535, 5581, 5568, 65535, 2013, 5571, 2692, 65535, 65535, 65535, + 3635, 5573, 2016, 65535, 5565, 5567, 5564, 65535, 65535, 4339, 1749, 5570, + 65535, 65535, 5580, 1712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2420, 65535, 65535, 65535, 1564, 65535, 65535, 5597, 65535, 65535, 4340, + 5600, 65535, 65535, 8414, 65535, 65535, 2845, 5599, 65535, 65535, 65535, + 5598, 65535, 65535, 65535, 65535, 65535, 65535, 5595, 65535, 65535, 65535, + 65535, 65535, 65535, 5583, 65535, 65535, 5612, 5582, 65535, 5601, 65535, + 65535, 65535, 65535, 65535, 65535, 5593, 65535, 65535, 5588, 5585, 65535, + 5586, 65535, 5594, 65535, 65535, 65535, 7803, 65535, 65535, 5591, 2284, + 3329, 3075, 5589, 65535, 5584, 65535, 65535, 5587, 65535, 65535, 65535, + 65535, 4180, 4021, 65535, 65535, 65535, 5592, 5602, 65535, 65535, 65535, + 8415, 65535, 65535, 65535, 65535, 5610, 5603, 65535, 65535, 5616, 65535, + 5614, 65535, 65535, 65535, 65535, 5609, 65535, 65535, 65535, 65535, 65535, + 65535, 5608, 65535, 3337, 65535, 3076, 65535, 5606, 65535, 65535, 5604, + 65535, 65535, 5611, 65535, 65535, 65535, 65535, 5617, 3750, 5623, 65535, + 65535, 65535, 65535, 65535, 5618, 5621, 5615, 65535, 65535, 3279, 65535, + 3783, 65535, 5605, 65535, 65535, 5613, 2757, 65535, 4088, 5633, 5620, + 65535, 65535, 65535, 65535, 65535, 2163, 1600, 1754, 65535, 65535, 5596, + 65535, 8416, 65535, 65535, 65535, 65535, 2758, 5625, 65535, 5632, 2626, + 1773, 65535, 65535, 3209, 65535, 65535, 65535, 65535, 65535, 65535, 5622, + 65535, 8418, 5627, 5631, 65535, 65535, 1995, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1923, 5629, 65535, + 65535, 65535, 65535, 65535, 1880, 65535, 3520, 5628, 65535, 65535, 65535, + 5630, 65535, 65535, 65535, 65535, 8417, 65535, 65535, 65535, 65535, 65535, + 65535, 5624, 8419, 65535, 65535, 65535, 65535, 5626, 65535, 65535, 65535, + 65535, 65535, 8420, 1755, 3236, 65535, 65535, 65535, 5637, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5635, 2234, 65535, 5634, 65535, + 65535, 65535, 65535, 65535, 65535, 5640, 65535, 65535, 65535, 65535, 5507, + 65535, 65535, 65535, 5636, 65535, 5638, 5639, 65535, 65535, 65535, 65535, + 65535, 65535, 5651, 65535, 5647, 65535, 5528, 65535, 65535, 65535, 65535, + 5646, 65535, 65535, 65535, 65535, 5645, 65535, 65535, 5642, 65535, 65535, + 65535, 65535, 65535, 5619, 5644, 5643, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5649, 65535, 4329, + 65535, 65535, 65535, 65535, 65535, 65535, 5652, 2064, 65535, 65535, 5648, + 5650, 65535, 65535, 8421, 65535, 8422, 65535, 65535, 65535, 3672, 65535, + 5653, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5657, 5654, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4218, 5655, 65535, 65535, 65535, 65535, 5607, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5658, 65535, 65535, 65535, + 5659, 65535, 65535, 65535, 65535, 65535, 65535, 1524, 65535, 5661, 2138, + 2538, 65535, 2026, 65535, 65535, 65535, 1601, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4198, 65535, 65535, 65535, 65535, + 5663, 5662, 5665, 1908, 65535, 65535, 2027, 1815, 65535, 65535, 65535, + 65535, 5668, 65535, 65535, 65535, 5667, 65535, 5669, 65535, 65535, 1643, + 65535, 3218, 65535, 5670, 65535, 65535, 1816, 5672, 65535, 65535, 65535, + 65535, 5671, 65535, 5673, 65535, 65535, 65535, 5674, 65535, 5675, 2506, + 2934, 2350, 65535, 3839, 65535, 65535, 3919, 4359, 65535, 65535, 65535, + 65535, 2528, 65535, 65535, 65535, 2397, 4311, 65535, 65535, 65535, 5676, + 5677, 65535, 2507, 65535, 65535, 65535, 5678, 5679, 65535, 65535, 5681, + 5680, 65535, 4003, 65535, 65535, 2693, 2613, 2479, 65535, 5682, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5684, 2822, 65535, 5683, 65535, + 65535, 65535, 65535, 65535, 5685, 65535, 65535, 65535, 65535, 65535, 5686, + 65535, 65535, 65535, 65535, 65535, 5687, 5688, 65535, 65535, 65535, 5689, + 65535, 5691, 5690, 5692, 1602, 3237, 65535, 5693, 65535, 65535, 2449, 1735, + 5694, 65535, 65535, 3417, 4837, 65535, 65535, 65535, 65535, 1882, 5695, + 65535, 65535, 65535, 65535, 5696, 65535, 3929, 4019, 65535, 65535, 65535, + 3516, 5697, 3735, 65535, 8423, 65535, 3756, 65535, 65535, 4092, 65535, + 65535, 65535, 5698, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5700, 5699, 65535, 65535, 5702, 65535, 65535, 65535, + 5701, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5704, + 65535, 65535, 65535, 65535, 65535, 65535, 2508, 65535, 4058, 65535, 5705, + 5706, 65535, 65535, 1883, 65535, 65535, 65535, 5707, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5709, 5708, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2888, + 65535, 65535, 3784, 1545, 65535, 65535, 65535, 65535, 65535, 3702, 8424, + 3374, 2664, 1944, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3703, 65535, 2551, 65535, 65535, 65535, 65535, 5711, + 65535, 1817, 65535, 65535, 1591, 65535, 8425, 3559, 5710, 2285, 3246, + 65535, 5712, 65535, 65535, 65535, 65535, 65535, 5720, 65535, 5713, 65535, + 65535, 65535, 65535, 8427, 3134, 65535, 1945, 5721, 65535, 65535, 65535, + 65535, 65535, 65535, 2139, 65535, 65535, 1884, 5719, 65535, 65535, 5717, + 5714, 4199, 65535, 65535, 8426, 65535, 3321, 65535, 65535, 65535, 3534, + 5715, 65535, 65535, 5723, 65535, 5722, 2070, 65535, 65535, 1610, 65535, + 65535, 2376, 5716, 5718, 65535, 65535, 65535, 65535, 65535, 4002, 3185, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4034, 65535, 65535, + 5731, 65535, 65535, 5732, 65535, 1644, 65535, 65535, 65535, 65535, 3861, + 4134, 5734, 2540, 2759, 5727, 5733, 1575, 65535, 1996, 65535, 65535, 5724, + 5729, 65535, 65535, 65535, 2997, 3652, 65535, 3736, 65535, 65535, 65535, + 65535, 65535, 65535, 5726, 65535, 3948, 65535, 5728, 65535, 5737, 8428, + 5735, 65535, 5730, 65535, 65535, 65535, 3949, 3611, 1946, 65535, 3388, + 65535, 65535, 3272, 65535, 5738, 65535, 65535, 65535, 65535, 5736, 3158, + 5725, 65535, 1546, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8429, 65535, 65535, + 65535, 65535, 65535, 65535, 4181, 5749, 65535, 65535, 65535, 65535, 65535, + 5748, 65535, 65535, 65535, 65535, 2999, 65535, 5745, 65535, 4211, 65535, + 65535, 3499, 5739, 65535, 65535, 65535, 65535, 65535, 3326, 65535, 65535, + 65535, 1547, 2286, 5742, 65535, 65535, 65535, 65535, 65535, 65535, 2638, + 5747, 65535, 5746, 5741, 65535, 5744, 65535, 65535, 1763, 65535, 5743, + 3612, 65535, 65535, 4243, 65535, 65535, 2809, 2998, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5755, 5753, 65535, 3804, 65535, + 65535, 65535, 65535, 65535, 65535, 5750, 5752, 65535, 1529, 65535, 65535, + 2287, 4341, 65535, 1720, 65535, 3825, 8431, 65535, 65535, 65535, 65535, + 4200, 65535, 65535, 1695, 2846, 5754, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5759, 65535, 8430, 2760, 65535, + 65535, 65535, 4151, 65535, 5756, 65535, 65535, 65535, 65535, 5751, 65535, + 5757, 8432, 65535, 65535, 4291, 65535, 3466, 3511, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 8433, 65535, 65535, 1713, 65535, 65535, 1556, 65535, 65535, + 5763, 65535, 65535, 5766, 65535, 65535, 65535, 4264, 65535, 65535, 65535, + 4203, 65535, 65535, 65535, 65535, 5773, 5767, 5764, 65535, 65535, 65535, + 4281, 5770, 65535, 65535, 8434, 65535, 2673, 5772, 65535, 65535, 5777, + 65535, 65535, 3464, 5775, 65535, 65535, 65535, 65535, 5769, 65535, 65535, + 3219, 65535, 65535, 5776, 65535, 5765, 65535, 5771, 65535, 5778, 1501, + 5768, 65535, 5779, 65535, 65535, 2847, 8436, 2694, 65535, 3858, 65535, + 2363, 8435, 5760, 5774, 3409, 8437, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2935, 65535, 1764, 2398, 2761, 5762, 2665, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2111, 65535, 5761, 65535, 65535, + 65535, 5783, 2708, 2187, 65535, 5798, 65535, 5792, 1963, 3430, 65535, 5787, + 5796, 1424, 1521, 8440, 65535, 1622, 65535, 5789, 3113, 5780, 5782, 2288, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5799, 8438, 5794, + 65535, 8441, 65535, 5786, 65535, 65535, 65535, 65535, 5793, 65535, 65535, + 65535, 65535, 65535, 65535, 4052, 65535, 65535, 5791, 5795, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2209, 65535, 2762, 65535, 65535, 3220, + 8439, 65535, 65535, 5785, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4150, 65535, 65535, 65535, 5788, 65535, 65535, 5781, 3465, 65535, 65535, + 5784, 65535, 65535, 65535, 5790, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4372, 2567, 4041, 65535, 5800, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3679, 65535, 65535, 5812, 2188, 65535, 65535, + 65535, 65535, 65535, 2695, 65535, 5802, 65535, 65535, 65535, 4244, 2289, + 65535, 5815, 65535, 65535, 1487, 65535, 65535, 5813, 65535, 65535, 65535, + 65535, 5801, 65535, 65535, 65535, 65535, 5807, 65535, 65535, 5809, 65535, + 65535, 65535, 4182, 5804, 65535, 65535, 3397, 65535, 65535, 5806, 65535, + 8442, 65535, 65535, 5814, 65535, 5808, 4080, 65535, 65535, 65535, 5803, + 65535, 2539, 5827, 65535, 65535, 65535, 65535, 1765, 65535, 5805, 5810, + 5811, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3177, 3159, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5819, 65535, 65535, 5825, 65535, 65535, 5823, 65535, 3392, + 65535, 65535, 5830, 5820, 65535, 65535, 65535, 65535, 65535, 5821, 5797, + 65535, 1968, 3785, 65535, 65535, 65535, 2568, 65535, 65535, 2342, 65535, + 65535, 65535, 65535, 65535, 4342, 65535, 5817, 65535, 5829, 1576, 3077, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3660, + 65535, 1818, 4319, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4042, + 3339, 65535, 65535, 65535, 65535, 5824, 5826, 65535, 65535, 65535, 65535, + 65535, 3025, 65535, 65535, 65535, 65535, 65535, 5828, 5822, 65535, 5816, + 65535, 65535, 65535, 1820, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2140, 65535, 65535, 65535, + 5842, 65535, 65535, 5837, 3001, 65535, 65535, 1758, 65535, 65535, 65535, + 65535, 2696, 65535, 5846, 65535, 65535, 65535, 65535, 65535, 65535, 5839, + 3301, 5836, 3346, 65535, 65535, 65535, 5871, 65535, 65535, 65535, 5833, + 65535, 5832, 65535, 5841, 65535, 65535, 65535, 5835, 5834, 5840, 65535, + 2914, 65535, 5831, 65535, 8443, 65535, 65535, 65535, 65535, 65535, 5843, + 65535, 65535, 5844, 65535, 65535, 65535, 65535, 65535, 1819, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5849, 65535, 5848, 5850, + 65535, 65535, 65535, 65535, 65535, 5853, 65535, 65535, 65535, 65535, 65535, + 65535, 3418, 65535, 5847, 65535, 8444, 65535, 65535, 65535, 5851, 65535, + 65535, 65535, 65535, 65535, 65535, 2134, 3190, 5845, 3598, 65535, 65535, + 5852, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5857, 5855, 65535, 65535, 5858, 65535, 65535, 5861, + 65535, 65535, 65535, 5854, 2329, 3579, 65535, 65535, 5758, 65535, 65535, + 65535, 65535, 65535, 65535, 4219, 5856, 65535, 5860, 3186, 65535, 5859, + 65535, 5838, 65535, 8445, 7404, 65535, 65535, 65535, 5864, 65535, 65535, + 65535, 5868, 65535, 65535, 5866, 65535, 65535, 65535, 8446, 65535, 8447, + 65535, 5862, 65535, 5863, 65535, 65535, 65535, 5867, 65535, 5865, 65535, + 65535, 65535, 3805, 65535, 65535, 5873, 65535, 5870, 5869, 65535, 5872, + 3529, 5874, 65535, 65535, 65535, 65535, 65535, 65535, 3280, 3178, 8448, + 65535, 65535, 65535, 2918, 65535, 65535, 65535, 5875, 65535, 5877, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5876, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5818, 65535, 65535, 65535, 65535, 5878, 65535, 65535, + 65535, 65535, 65535, 65535, 3548, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5879, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1645, 65535, 65535, 65535, 3467, 1696, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1947, 65535, 65535, 65535, 2599, 2399, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 8449, 65535, 65535, 65535, 4330, 2889, + 65535, 65535, 65535, 1577, 65535, 65535, 65535, 5881, 65535, 65535, 65535, + 65535, 65535, 65535, 5880, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8450, + 5884, 3221, 5887, 5882, 65535, 65535, 65535, 5886, 65535, 65535, 65535, + 65535, 5885, 3415, 1466, 8278, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4314, 65535, 65535, 5889, 65535, + 65535, 65535, 1511, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5891, 65535, 65535, 65535, 5890, 65535, 5888, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5883, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3950, 65535, 65535, 65535, 5893, 65535, 65535, 65535, 65535, 65535, + 65535, 8452, 65535, 65535, 65535, 65535, 5892, 65535, 65535, 65535, 65535, + 65535, 8451, 65535, 65535, 65535, 65535, 1578, 65535, 65535, 65535, 65535, + 5895, 3871, 65535, 5894, 65535, 65535, 65535, 65535, 4062, 65535, 65535, + 65535, 65535, 2764, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3026, 65535, 65535, 65535, + 65535, 65535, 2763, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 8454, 8455, 65535, 4320, 65535, 65535, 5901, 65535, 3002, 65535, + 65535, 65535, 65535, 65535, 65535, 5897, 5902, 65535, 65535, 1579, 65535, + 65535, 8453, 65535, 65535, 65535, 65535, 65535, 5900, 65535, 3636, 5896, + 5899, 2765, 65535, 3714, 65535, 65535, 5903, 65535, 2586, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3003, 65535, 65535, 65535, 65535, 65535, 65535, 5906, 65535, + 65535, 65535, 5898, 65535, 2074, 65535, 65535, 65535, 65535, 5904, 65535, + 65535, 65535, 65535, 4183, 5907, 65535, 65535, 65535, 7807, 65535, 65535, + 65535, 65535, 65535, 2678, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5908, 65535, 65535, 65535, 5909, 65535, 65535, 65535, 65535, 3585, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5911, 65535, 65535, 65535, + 65535, 5912, 65535, 65535, 8457, 65535, 3590, 65535, 65535, 65535, 65535, + 3468, 5914, 65535, 65535, 65535, 65535, 5916, 65535, 4282, 65535, 5913, + 65535, 5915, 1580, 65535, 5910, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4758, 5917, 65535, 65535, 65535, 65535, 3078, 2467, 5919, 65535, + 65535, 65535, 65535, 5918, 2823, 4662, 65535, 65535, 65535, 65535, 65535, + 65535, 5920, 65535, 65535, 65535, 5922, 65535, 5905, 5921, 65535, 8458, + 5923, 65535, 65535, 65535, 65535, 65535, 65535, 3661, 65535, 65535, 65535, + 65535, 65535, 65535, 5924, 65535, 65535, 5925, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5926, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5927, 65535, 3351, + 65535, 5929, 5928, 65535, 65535, 5930, 65535, 5931, 65535, 65535, 2600, + 3826, 65535, 65535, 65535, 4117, 5932, 5933, 3061, 2541, 5934, 5935, 65535, + 65535, 65535, 65535, 65535, 5936, 3903, 3704, 65535, 65535, 5937, 3626, + 65535, 65535, 65535, 65535, 65535, 3302, 65535, 65535, 65535, 65535, 65535, + 5938, 1668, 65535, 1956, 65535, 4079, 65535, 4063, 65535, 1617, 4343, + 65535, 65535, 65535, 65535, 3997, 65535, 3863, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2936, 65535, 5939, 65535, 65535, 65535, 65535, + 3512, 65535, 65535, 65535, 2164, 5940, 65535, 2401, 5942, 5941, 65535, + 65535, 65535, 65535, 5943, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5944, 65535, 65535, 65535, 5945, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1909, 65535, 5946, 65535, 65535, + 65535, 65535, 5947, 65535, 65535, 65535, 65535, 2165, 65535, 65535, 3705, + 65535, 8459, 5949, 65535, 65535, 65535, 2810, 65535, 65535, 5948, 65535, + 65535, 65535, 65535, 8460, 65535, 65535, 65535, 1997, 5950, 5952, 65535, + 5951, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5953, 65535, 2210, + 65535, 5954, 65535, 65535, 65535, 65535, 2046, 65535, 3039, 65535, 2348, + 65535, 65535, 65535, 65535, 5956, 5957, 5955, 65535, 65535, 65535, 65535, + 65535, 65535, 2614, 65535, 65535, 3517, 1998, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5959, 3207, 5958, 65535, 65535, 4344, + 3637, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5962, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5964, 5961, 65535, 65535, 65535, 4093, 5963, 5965, + 65535, 4265, 65535, 65535, 65535, 65535, 8461, 5969, 65535, 65535, 65535, + 5968, 3281, 3584, 65535, 65535, 2166, 5967, 65535, 65535, 65535, 65535, + 5966, 65535, 4152, 4153, 65535, 65535, 65535, 65535, 65535, 65535, 5970, + 1581, 65535, 65535, 65535, 65535, 2341, 2509, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5971, 5972, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5974, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2666, 65535, 65535, 65535, 65535, 5976, 65535, 5975, + 65535, 65535, 65535, 65535, 65535, 5977, 65535, 1736, 65535, 65535, 5979, + 65535, 8463, 5978, 65535, 5981, 5980, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2189, 65535, 65535, 4237, 65535, 2017, 65535, 1603, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2047, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1850, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4301, 5983, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5985, 65535, 8464, 65535, 65535, 5986, 65535, + 1646, 65535, 65535, 65535, 65535, 65535, 5982, 8465, 2468, 65535, 65535, + 3322, 5984, 65535, 65535, 65535, 8468, 65535, 65535, 65535, 8466, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5989, 65535, 2615, 65535, 65535, + 8467, 65535, 5987, 65535, 65535, 65535, 65535, 2097, 65535, 65535, 3706, + 5988, 65535, 65535, 6015, 65535, 65535, 65535, 8470, 65535, 65535, 5994, + 65535, 65535, 65535, 65535, 65535, 2190, 65535, 65535, 65535, 65535, 1948, + 65535, 5991, 4228, 8469, 65535, 4245, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3187, 65535, + 65535, 5993, 8471, 65535, 65535, 8473, 8472, 65535, 65535, 65535, 8474, + 65535, 65535, 65535, 5995, 4283, 2028, 3757, 3613, 65535, 65535, 65535, + 5996, 65535, 65535, 65535, 65535, 5998, 65535, 6001, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5997, 65535, 65535, 65535, 6000, + 2235, 1548, 6002, 65535, 2899, 5999, 4289, 65535, 8475, 6005, 7805, 65535, + 65535, 65535, 65535, 6003, 6006, 65535, 65535, 65535, 65535, 5992, 6004, + 65535, 65535, 2377, 65535, 65535, 6007, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6008, 65535, 65535, 65535, 65535, 4229, 65535, 65535, 65535, + 65535, 65535, 8476, 65535, 6009, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6010, 8477, 65535, 65535, 5990, 65535, 65535, 65535, 65535, + 6011, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1821, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2542, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6012, 65535, 65535, 65535, 65535, 6013, 65535, 65535, + 65535, 65535, 6014, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1530, + 65535, 65535, 65535, 6016, 65535, 3786, 6017, 65535, 65535, 1789, 6018, + 65535, 6019, 65535, 65535, 65535, 65535, 6020, 65535, 6022, 6023, 6021, + 65535, 65535, 65535, 3810, 6025, 6024, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8478, 65535, 6027, 6026, 6028, 65535, 65535, 65535, + 65535, 65535, 65535, 6029, 6031, 6030, 65535, 65535, 2344, 65535, 6033, + 65535, 6032, 65535, 65535, 1822, 65535, 2870, 65535, 3411, 65535, 6034, + 2937, 65535, 65535, 65535, 2469, 65535, 1592, 6035, 65535, 4184, 65535, + 65535, 3920, 6036, 65535, 65535, 8347, 3419, 4154, 2290, 2848, 65535, + 65535, 65535, 3238, 4625, 65535, 3303, 1669, 6037, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6038, 65535, 6043, 65535, 65535, 6041, 6040, + 5391, 1697, 6039, 65535, 1467, 65535, 3675, 65535, 65535, 3707, 65535, + 65535, 65535, 65535, 4246, 6044, 6042, 3255, 2919, 65535, 65535, 3676, + 65535, 3772, 65535, 6046, 4241, 2112, 6047, 65535, 6045, 3719, 6048, 65535, + 6049, 65535, 8479, 1468, 65535, 65535, 2811, 6054, 65535, 6051, 3554, 6050, + 65535, 65535, 65535, 65535, 65535, 65535, 1885, 65535, 65535, 6057, 65535, + 65535, 65535, 6052, 6053, 65535, 6056, 6055, 3764, 65535, 65535, 3041, + 3040, 65535, 1910, 65535, 65535, 6058, 65535, 65535, 65535, 65535, 65535, + 6059, 65535, 65535, 6060, 65535, 65535, 65535, 65535, 65535, 6062, 65535, + 6061, 65535, 65535, 65535, 65535, 65535, 1557, 65535, 65535, 65535, 65535, + 65535, 6070, 3737, 6064, 65535, 6066, 65535, 65535, 6068, 2849, 65535, + 65535, 6069, 6067, 2569, 65535, 65535, 65535, 6063, 6065, 65535, 3793, + 65535, 2766, 65535, 65535, 6072, 65535, 65535, 6071, 65535, 65535, 65535, + 65535, 6073, 65535, 2543, 2364, 65535, 65535, 3470, 6074, 65535, 3332, + 65535, 65535, 6076, 65535, 65535, 65535, 4230, 6075, 65535, 65535, 65535, + 65535, 65535, 3080, 65535, 65535, 65535, 65535, 65535, 65535, 6081, 65535, + 6083, 6084, 3247, 65535, 65535, 65535, 65535, 65535, 6082, 65535, 6079, + 65535, 6077, 6078, 65535, 6080, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6087, 65535, 6085, 65535, 6086, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6088, 6090, 6091, 6092, 65535, 6093, 65535, 65535, 6089, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6095, 65535, 65535, + 65535, 6094, 65535, 65535, 65535, 65535, 65535, 65535, 6096, 65535, 65535, + 65535, 65535, 65535, 65535, 4266, 65535, 65535, 65535, 6099, 6097, 6098, + 65535, 65535, 65535, 1851, 65535, 65535, 65535, 65535, 65535, 4135, 65535, + 65535, 65535, 3895, 65535, 6101, 65535, 65535, 65535, 6100, 65535, 65535, + 65535, 65535, 6102, 6103, 65535, 65535, 65535, 65535, 6107, 6104, 6105, + 6106, 65535, 6108, 65535, 65535, 65535, 6109, 65535, 6110, 65535, 65535, + 65535, 6111, 65535, 6112, 65535, 3680, 3431, 6113, 3653, 3779, 65535, 6114, + 65535, 8480, 6115, 3393, 65535, 1698, 2291, 6116, 65535, 65535, 6117, + 65535, 65535, 6118, 65535, 2452, 65535, 65535, 6120, 65535, 65535, 6119, + 65535, 65535, 6121, 6122, 8483, 8481, 65535, 8482, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 8484, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3738, 65535, 6123, 65535, 65535, 65535, 6124, 65535, 65535, 7780, + 6125, 6126, 6127, 65535, 65535, 65535, 65535, 2457, 65535, 65535, 6128, + 3625, 65535, 65535, 4010, 65535, 1549, 65535, 1558, 65535, 65535, 6129, + 65535, 65535, 65535, 65535, 6131, 65535, 65535, 65535, 6130, 3463, 65535, + 65535, 65535, 2938, 5664, 65535, 6132, 4074, 65535, 6133, 65535, 1823, + 3720, 6134, 65535, 6135, 65535, 65535, 6136, 65535, 65535, 65535, 4101, + 65535, 65535, 65535, 4094, 65535, 3319, 65535, 65535, 65535, 3081, 65535, + 65535, 6138, 65535, 65535, 2697, 65535, 65535, 2767, 65535, 65535, 6141, + 65535, 65535, 6140, 6139, 3758, 65535, 1824, 2170, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6147, 65535, 65535, 6144, 2850, 4059, 65535, 65535, 65535, 6143, + 6145, 6146, 65535, 65535, 6142, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6148, 6149, 65535, 3304, + 65535, 1852, 65535, 65535, 65535, 3264, 65535, 65535, 65535, 65535, 65535, + 8486, 6150, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6151, 6154, + 65535, 65535, 65535, 65535, 65535, 2890, 65535, 3513, 65535, 6155, 3998, + 65535, 6152, 65535, 65535, 6153, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6158, 65535, 65535, 65535, + 65535, 6157, 6156, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6160, 65535, 65535, 6159, 65535, 65535, 6161, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6163, 65535, 6162, 65535, 65535, 65535, 65535, 3898, 65535, 65535, + 65535, 65535, 65535, 65535, 2685, 4267, 65535, 65535, 6164, 65535, 65535, + 3500, 65535, 65535, 6165, 65535, 65535, 6166, 65535, 6170, 6168, 6169, + 65535, 6167, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6171, 65535, + 65535, 65535, 65535, 65535, 6172, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6173, 65535, 65535, 6174, 4064, 6175, 65535, 65535, + 65535, 65535, 65535, 4121, 6176, 65535, 3241, 65535, 3645, 65535, 2048, + 65535, 65535, 65535, 3222, 6177, 1999, 65535, 65535, 65535, 2961, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6178, 65535, 65535, 65535, + 65535, 65535, 2378, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6179, 65535, 65535, 65535, 65535, 65535, 6180, 65535, 2167, 2402, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6182, + 8488, 65535, 65535, 65535, 3437, 2403, 1925, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3951, 65535, 3614, 65535, 65535, + 65535, 65535, 65535, 3438, 65535, 65535, 65535, 65535, 2315, 65535, 65535, + 65535, 65535, 65535, 6184, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 8489, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2768, 65535, 65535, 65535, 65535, 65535, + 65535, 8490, 65535, 65535, 65535, 65535, 65535, 65535, 4247, 2292, 65535, + 65535, 2168, 65535, 65535, 3668, 65535, 6186, 65535, 65535, 65535, 65535, + 65535, 8491, 65535, 6188, 65535, 65535, 65535, 65535, 2236, 65535, 65535, + 65535, 65535, 6187, 3375, 65535, 65535, 65535, 65535, 6190, 1714, 6185, + 65535, 65535, 3739, 65535, 1519, 65535, 2425, 65535, 4373, 65535, 65535, + 6189, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6191, 65535, + 65535, 65535, 3896, 65535, 2970, 6193, 65535, 65535, 65535, 65535, 6194, + 65535, 65535, 65535, 65535, 65535, 6192, 65535, 65535, 65535, 65535, 1737, + 65535, 6200, 65535, 6199, 65535, 65535, 2544, 65535, 65535, 65535, 6201, + 6196, 65535, 65535, 65535, 6202, 6197, 65535, 65535, 65535, 65535, 3721, + 6195, 65535, 65535, 6198, 65535, 65535, 65535, 65535, 65535, 6205, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6204, 4012, 65535, 65535, 65535, 6203, 65535, 65535, 1484, 65535, + 65535, 65535, 65535, 6207, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6206, 65535, 65535, 65535, 2769, 65535, 65535, 65535, 65535, 65535, + 6208, 65535, 65535, 65535, 65535, 65535, 65535, 3042, 65535, 65535, 6210, + 6209, 65535, 65535, 65535, 65535, 65535, 65535, 6211, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6181, 65535, + 65535, 65535, 6183, 6213, 6212, 65535, 65535, 65535, 8492, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2545, 65535, 4302, 65535, + 2587, 65535, 6214, 2090, 65535, 65535, 65535, 65535, 65535, 1911, 1886, + 2510, 65535, 65535, 65535, 65535, 65535, 65535, 4155, 65535, 65535, 6220, + 65535, 6219, 3043, 6216, 65535, 65535, 6218, 65535, 65535, 2674, 2851, + 6217, 6215, 65535, 3581, 65535, 65535, 2770, 65535, 65535, 3787, 65535, + 65535, 65535, 65535, 2404, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3471, 65535, 65535, 6221, 65535, 65535, 65535, 65535, 6222, + 6244, 2029, 65535, 65535, 4352, 3028, 65535, 65535, 65535, 65535, 6223, + 65535, 65535, 1647, 3376, 3854, 65535, 65535, 65535, 65535, 8496, 65535, + 65535, 65535, 65535, 65535, 65535, 8498, 65535, 6224, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1969, 6225, 65535, 65535, 6227, 65535, + 65535, 65535, 6228, 65535, 3580, 65535, 65535, 6229, 65535, 65535, 65535, + 65535, 65535, 6230, 6231, 65535, 65535, 2030, 1648, 3514, 2639, 2511, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6232, 65535, 2640, 65535, + 65535, 65535, 65535, 65535, 1639, 3794, 65535, 65535, 6233, 65535, 65535, + 3740, 65535, 65535, 65535, 65535, 65535, 65535, 3044, 65535, 6236, 65535, + 6237, 3644, 65535, 2852, 6234, 65535, 3260, 65535, 65535, 6235, 65535, + 65535, 65535, 2771, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1469, 65535, 65535, 65535, 65535, 1888, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6238, 65535, 65535, 3377, 65535, 6239, 2952, + 65535, 65535, 65535, 65535, 65535, 4054, 65535, 65535, 3762, 6240, 6241, + 3248, 65535, 4268, 65535, 65535, 6243, 6242, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2616, 65535, + 65535, 6245, 1489, 65535, 65535, 65535, 65535, 6248, 65535, 65535, 65535, + 6246, 1649, 2113, 6247, 2293, 2337, 65535, 3923, 6249, 65535, 65535, 3999, + 65535, 65535, 6251, 65535, 65535, 65535, 2962, 1550, 1623, 1421, 65535, + 65535, 65535, 65535, 65535, 65535, 6250, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6252, 6253, 2812, 65535, 65535, 65535, 65535, + 65535, 6254, 65535, 1738, 65535, 65535, 65535, 65535, 6256, 65535, 65535, + 65535, 2141, 65535, 1949, 65535, 65535, 6257, 2058, 65535, 65535, 6258, + 65535, 3005, 65535, 3522, 65535, 2977, 2434, 65535, 65535, 65535, 6259, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3261, 3082, + 65535, 6261, 6263, 6260, 6262, 65535, 65535, 65535, 65535, 65535, 65535, + 2069, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6264, + 2073, 65535, 65535, 65535, 1950, 4185, 6266, 65535, 65535, 65535, 65535, + 65535, 6267, 65535, 65535, 65535, 1517, 65535, 65535, 65535, 65535, 6270, + 65535, 65535, 65535, 1777, 6269, 6268, 65535, 6272, 6265, 65535, 6273, + 4238, 65535, 6274, 65535, 6275, 65535, 8499, 4877, 6277, 65535, 6276, + 65535, 65535, 65535, 6278, 6279, 65535, 4250, 6280, 65535, 7504, 2772, + 6281, 6282, 2686, 65535, 3501, 6283, 8500, 65535, 65535, 3203, 8502, 65535, + 6284, 65535, 3223, 6285, 65535, 65535, 65535, 65535, 65535, 1978, 65535, + 4542, 3256, 2556, 65535, 65535, 65535, 65535, 1825, 65535, 65535, 6286, + 65535, 6299, 65535, 6289, 65535, 1951, 65535, 6288, 6301, 65535, 65535, + 65535, 6287, 65535, 2773, 65535, 65535, 65535, 65535, 65535, 65535, 6291, + 6292, 65535, 3394, 65535, 65535, 6293, 65535, 1753, 65535, 65535, 65535, + 65535, 2877, 3827, 65535, 6295, 65535, 65535, 65535, 3173, 65535, 65535, + 65535, 65535, 65535, 65535, 6290, 65535, 6294, 6296, 65535, 65535, 2440, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6303, 3773, 65535, 3671, 3472, 65535, 2031, 6302, 6300, 65535, 3686, + 6297, 3257, 3474, 65535, 3473, 65535, 2435, 65535, 65535, 65535, 65535, + 65535, 65535, 6321, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6305, + 65535, 6307, 65535, 65535, 65535, 65535, 6310, 65535, 6311, 65535, 6308, + 6309, 65535, 65535, 6306, 6304, 65535, 65535, 65535, 65535, 6298, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3900, + 1650, 65535, 65535, 65535, 6318, 65535, 6315, 65535, 6320, 65535, 65535, + 6319, 65535, 3654, 4048, 65535, 2470, 6313, 6322, 6317, 65535, 6316, 6312, + 8503, 6314, 65535, 1826, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3224, 65535, 65535, 3006, 65535, 65535, 65535, 3667, 65535, 65535, + 6327, 65535, 65535, 65535, 3669, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2978, 6324, 65535, 65535, 3712, 65535, 6328, 3904, 65535, 3254, + 65535, 6323, 6325, 65535, 65535, 6326, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6329, 65535, 65535, + 2573, 65535, 65535, 65535, 3515, 6334, 6333, 65535, 65535, 6330, 65535, + 65535, 65535, 4345, 65535, 65535, 65535, 65535, 65535, 6339, 65535, 65535, + 6343, 6340, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6336, + 65535, 65535, 65535, 65535, 65535, 65535, 6337, 65535, 65535, 65535, 65535, + 65535, 6342, 65535, 65535, 65535, 6331, 4658, 6338, 6332, 65535, 65535, + 6341, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6347, 65535, 1827, + 65535, 6344, 65535, 65535, 65535, 6345, 65535, 65535, 6346, 6349, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6348, + 3751, 65535, 65535, 65535, 65535, 6350, 4321, 3930, 6355, 65535, 65535, + 6352, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6351, 2963, + 65535, 6354, 6356, 65535, 65535, 65535, 6353, 65535, 6360, 65535, 6357, + 65535, 65535, 65535, 65535, 65535, 65535, 6358, 6335, 65535, 65535, 65535, + 6359, 6361, 65535, 65535, 65535, 65535, 65535, 65535, 6362, 65535, 65535, + 65535, 65535, 65535, 65535, 3891, 65535, 6363, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4107, 65535, 65535, 2019, 2076, 6364, 65535, + 65535, 65535, 65535, 65535, 3873, 65535, 2891, 65535, 4057, 65535, 65535, + 6365, 65535, 4248, 65535, 65535, 3655, 65535, 3045, 3591, 65535, 65535, + 2676, 65535, 65535, 65535, 1441, 65535, 6370, 6368, 65535, 6366, 1786, + 65535, 2774, 6371, 65535, 65535, 6369, 65535, 6367, 6375, 65535, 65535, + 6374, 6373, 6372, 65535, 65535, 65535, 65535, 65535, 6376, 65535, 65535, + 65535, 6377, 2939, 65535, 6378, 65535, 6380, 65535, 65535, 6379, 65535, + 65535, 65535, 65535, 2211, 65535, 65535, 65535, 3031, 65535, 65535, 65535, + 6382, 65535, 65535, 65535, 3475, 65535, 6381, 65535, 65535, 65535, 6383, + 65535, 3874, 3083, 2294, 65535, 6384, 65535, 65535, 65535, 65535, 4269, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6386, 65535, 65535, 6387, + 65535, 6388, 65535, 6389, 65535, 2512, 65535, 6390, 2114, 65535, 65535, + 1953, 65535, 1889, 65535, 6392, 65535, 4124, 2295, 6391, 65535, 65535, + 65535, 6395, 4111, 65535, 3599, 65535, 65535, 3778, 65535, 65535, 65535, + 2698, 6394, 65535, 2588, 2296, 2513, 1952, 3875, 6393, 65535, 65535, 65535, + 3046, 3981, 2436, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2514, 3350, 65535, 6398, 4292, 2406, 65535, 6399, 2853, 65535, 6401, 65535, + 65535, 65535, 2775, 2365, 65535, 65535, 65535, 65535, 6400, 65535, 65535, + 2641, 2191, 3047, 6396, 6402, 65535, 8505, 65535, 65535, 6397, 2115, 65535, + 6405, 6409, 2142, 65535, 65535, 65535, 65535, 65535, 6404, 65535, 65535, + 65535, 65535, 6413, 8506, 65535, 2297, 65535, 65535, 4212, 1437, 6410, + 65535, 65535, 1954, 65535, 6407, 65535, 65535, 65535, 65535, 65535, 6408, + 65535, 65535, 3476, 6406, 6403, 65535, 1699, 2981, 65535, 65535, 2169, + 65535, 65535, 65535, 6415, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6412, 65535, 65535, 65535, 65535, 65535, 6414, + 65535, 65535, 65535, 6411, 65535, 65535, 65535, 65535, 65535, 2116, 3120, + 6416, 3085, 65535, 65535, 6429, 8508, 65535, 6425, 6419, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6423, 2627, 1470, 6418, 6426, 6430, + 2298, 4095, 65535, 3343, 6420, 65535, 8507, 6428, 65535, 6417, 3225, 65535, + 6422, 1438, 4083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6421, + 65535, 65535, 2032, 3741, 65535, 65535, 65535, 3084, 65535, 4277, 2710, + 65535, 65535, 6469, 8509, 65535, 6431, 65535, 3007, 65535, 6427, 6432, + 6434, 65535, 3378, 6437, 65535, 65535, 6433, 65535, 65535, 65535, 3905, + 1828, 65535, 65535, 4084, 65535, 65535, 1471, 65535, 65535, 6436, 65535, + 4322, 65535, 65535, 65535, 65535, 65535, 65535, 6435, 65535, 65535, 65535, + 65535, 65535, 1582, 65535, 65535, 3553, 6438, 65535, 65535, 65535, 6445, + 6439, 6446, 65535, 65535, 65535, 65535, 65535, 65535, 6442, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3662, 65535, 65535, 2579, 6444, + 65535, 6441, 6447, 6440, 65535, 65535, 2667, 65535, 65535, 65535, 65535, + 3952, 65535, 65535, 2675, 65535, 65535, 6443, 6455, 65535, 65535, 6451, + 65535, 6454, 65535, 6452, 6456, 6450, 65535, 6424, 2964, 65535, 65535, + 3708, 65535, 6453, 65535, 65535, 6448, 65535, 65535, 65535, 3008, 2117, + 65535, 2642, 65535, 65535, 65535, 65535, 8510, 65535, 2824, 3029, 6459, + 65535, 65535, 6461, 6462, 65535, 65535, 6458, 6460, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6449, 6457, 65535, 6465, 6464, 65535, 65535, + 4037, 65535, 65535, 2078, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6463, 65535, 6467, 6466, 6470, 65535, 6472, 65535, 65535, 2471, + 6468, 65535, 65535, 65535, 65535, 6473, 6474, 8272, 65535, 6475, 65535, + 6481, 3410, 6477, 65535, 6476, 6478, 6479, 65535, 6480, 65535, 65535, + 65535, 65535, 6482, 6483, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1829, 65535, 6484, + 65535, 6485, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6486, 65535, 8511, 65535, 65535, 65535, 65535, 6487, 6488, 6489, + 65535, 6490, 6491, 65535, 65535, 6493, 6492, 65535, 65535, 6494, 65535, + 65535, 65535, 65535, 65535, 65535, 6495, 6496, 65535, 65535, 65535, 65535, + 65535, 65535, 6499, 6497, 6498, 2414, 2118, 65535, 65535, 3249, 65535, + 3684, 65535, 2711, 65535, 65535, 3616, 65535, 3742, 6500, 5246, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6501, 6503, 65535, 4204, + 6502, 6505, 6504, 65535, 4186, 65535, 6506, 65535, 3759, 65535, 65535, + 65535, 65535, 65535, 6507, 65535, 65535, 65535, 65535, 65535, 6510, 65535, + 65535, 6509, 6508, 65535, 65535, 8512, 65535, 6511, 2085, 65535, 65535, + 65535, 3009, 1912, 65535, 65535, 65535, 65535, 6515, 6512, 65535, 65535, + 6513, 65535, 65535, 65535, 6516, 65535, 6517, 6514, 65535, 65535, 65535, + 1512, 65535, 65535, 65535, 1604, 65535, 65535, 65535, 6519, 6520, 65535, + 65535, 65535, 6521, 65535, 4201, 65535, 65535, 65535, 65535, 65535, 2643, + 65535, 6523, 6522, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2892, 6524, 65535, 65535, 65535, 65535, 6525, 65535, 65535, + 6526, 65535, 1854, 65535, 65535, 65535, 65535, 1830, 65535, 65535, 6527, + 65535, 65535, 65535, 65535, 65535, 6528, 65535, 4008, 4202, 65535, 65535, + 65535, 4187, 4346, 65535, 2300, 6531, 2589, 6530, 65535, 65535, 65535, + 65535, 6532, 2546, 65535, 65535, 65535, 3150, 65535, 6533, 65535, 65535, + 2299, 65535, 4096, 6534, 6535, 65535, 65535, 6536, 65535, 65535, 65535, + 65535, 6537, 65535, 65535, 65535, 65535, 65535, 65535, 6538, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2547, 65535, 65535, + 4118, 65535, 65535, 65535, 65535, 6540, 65535, 3226, 65535, 6539, 65535, + 65535, 65535, 65535, 65535, 65535, 6542, 65535, 65535, 65535, 6541, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6543, 65535, 65535, 65535, 2940, + 65535, 6544, 65535, 6545, 65535, 65535, 65535, 3878, 6546, 65535, 3086, + 6547, 65535, 65535, 65535, 65535, 65535, 6548, 65535, 65535, 65535, 65535, + 65535, 65535, 4323, 6551, 65535, 6550, 6549, 3305, 65535, 6552, 2825, + 65535, 6553, 65535, 65535, 65535, 6554, 4347, 6555, 65535, 65535, 65535, + 65535, 6556, 6558, 6557, 3670, 65535, 3566, 65535, 4353, 3674, 65535, + 65535, 65535, 65535, 65535, 65535, 6560, 65535, 65535, 2776, 65535, 3769, + 65535, 6561, 6559, 65535, 1831, 65535, 65535, 65535, 2213, 2515, 65535, + 65535, 3743, 65535, 65535, 65535, 2171, 3982, 65535, 6564, 6562, 65535, + 2301, 65535, 2302, 1482, 65535, 2421, 65535, 65535, 65535, 65535, 65535, + 3628, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1472, 6569, + 65535, 3227, 65535, 65535, 65535, 65535, 65535, 3627, 65535, 3160, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6571, 65535, 65535, 6567, 6570, + 6565, 65535, 6568, 3953, 65535, 65535, 2214, 65535, 65535, 1502, 6566, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6573, 65535, + 6574, 65535, 65535, 3502, 65535, 65535, 65535, 2000, 65535, 65535, 65535, + 6585, 3600, 65535, 65535, 65535, 65535, 2516, 65535, 65535, 2001, 2953, + 4361, 4055, 6572, 2965, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1930, 6575, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6577, 65535, 65535, 65535, 65535, + 65535, 6576, 65535, 65535, 65535, 65535, 65535, 6578, 65535, 3201, 65535, + 3601, 65535, 65535, 65535, 65535, 65535, 3306, 65535, 65535, 65535, 65535, + 6582, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6581, 65535, 65535, + 65535, 65535, 6579, 65535, 65535, 2872, 65535, 3828, 6584, 65535, 6583, + 2303, 4374, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6600, 65535, 65535, 65535, 65535, 65535, 6588, 6589, 65535, 65535, 65535, + 65535, 2617, 65535, 65535, 6587, 65535, 2343, 6586, 65535, 65535, 6590, + 65535, 65535, 65535, 3307, 3855, 3010, 65535, 65535, 65535, 65535, 3161, + 6594, 65535, 6595, 6591, 65535, 65535, 65535, 65535, 6592, 65535, 6593, + 65535, 65535, 65535, 65535, 2304, 65535, 65535, 65535, 6601, 65535, 6597, + 65535, 65535, 65535, 65535, 3829, 65535, 4023, 3767, 65535, 65535, 6596, + 65535, 65535, 6599, 6598, 65535, 65535, 65535, 3983, 6602, 65535, 65535, + 65535, 65535, 65535, 65535, 6603, 65535, 65535, 3030, 65535, 6604, 65535, + 65535, 6606, 65535, 6610, 65535, 65535, 6607, 6605, 3602, 6608, 65535, + 6609, 65535, 65535, 65535, 1615, 65535, 6616, 6611, 65535, 65535, 65535, + 6612, 65535, 65535, 65535, 6613, 65535, 3102, 65535, 65535, 65535, 65535, + 6615, 6614, 6617, 65535, 65535, 65535, 65535, 6618, 6619, 65535, 65535, + 2854, 65535, 1670, 65535, 6620, 4284, 65535, 2548, 65535, 65535, 2644, + 65535, 65535, 65535, 65535, 65535, 2517, 3250, 65535, 65535, 65535, 65535, + 65535, 6621, 6622, 1520, 65535, 6623, 65535, 65535, 6624, 6625, 65535, + 65535, 6626, 65535, 6627, 2002, 5367, 6628, 65535, 2982, 6629, 2580, 65535, + 6630, 65535, 4433, 65535, 65535, 65535, 6631, 3915, 1845, 65535, 65535, + 3011, 2687, 65535, 3840, 2645, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6632, 2305, 6633, 3709, 65535, 6647, 65535, 65535, + 65535, 65535, 6635, 65535, 3142, 3656, 2192, 6634, 3012, 65535, 65535, + 65535, 65535, 65535, 65535, 6636, 65535, 65535, 65535, 65535, 65535, 65535, + 3379, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6638, 6637, 6640, 65535, 65535, + 6639, 65535, 6641, 65535, 65535, 6643, 65535, 6642, 65535, 1832, 65535, + 6644, 65535, 6645, 6646, 65535, 65535, 2366, 4270, 65535, 6648, 2826, + 65535, 65535, 65535, 1583, 6649, 6650, 65535, 65535, 65535, 65535, 65535, + 6651, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1491, 65535, 6652, 65535, 65535, 65535, 65535, 6653, 65535, + 65535, 65535, 65535, 65535, 65535, 3830, 65535, 65535, 65535, 2576, 65535, + 6655, 65535, 65535, 65535, 65535, 65535, 1700, 1427, 65535, 65535, 65535, + 65535, 6654, 6657, 3617, 65535, 2855, 65535, 1651, 65535, 3954, 65535, + 65535, 65535, 65535, 2128, 2033, 65535, 6656, 65535, 1671, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1788, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1584, 6661, 4303, 3162, 65535, + 65535, 3795, 65535, 6673, 65535, 1652, 6671, 65535, 6669, 6660, 65535, + 6658, 65535, 6659, 65535, 2604, 2049, 3282, 65535, 65535, 65535, 3526, + 65535, 65535, 65535, 65535, 65535, 1552, 65535, 6663, 6662, 65535, 65535, + 65535, 65535, 6668, 6664, 6667, 65535, 65535, 65535, 65535, 65535, 8514, + 4089, 6666, 1653, 1784, 6670, 65535, 65535, 6672, 65535, 65535, 65535, + 65535, 2119, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6676, 6685, + 6686, 65535, 65535, 65535, 1420, 65535, 65535, 65535, 65535, 65535, 65535, + 6693, 65535, 65535, 65535, 65535, 1490, 65535, 65535, 6684, 65535, 65535, + 65535, 6683, 65535, 6678, 6677, 65535, 6675, 6674, 3262, 65535, 3192, 6680, + 65535, 65535, 65535, 65535, 65535, 65535, 6679, 65535, 65535, 65535, 65535, + 6682, 65535, 65535, 65535, 3087, 2120, 65535, 65535, 65535, 65535, 1536, + 6681, 65535, 2306, 65535, 65535, 65535, 65535, 65535, 3088, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8515, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6699, 65535, 6700, 65535, 1654, 65535, 65535, 65535, + 1611, 6697, 65535, 65535, 8516, 65535, 65535, 65535, 65535, 65535, 6687, + 65535, 6695, 65535, 6702, 6696, 65535, 65535, 65535, 6694, 65535, 65535, + 65535, 65535, 6665, 65535, 65535, 6692, 65535, 65535, 65535, 6688, 65535, + 65535, 65535, 1833, 6690, 6701, 65535, 6691, 65535, 65535, 65535, 65535, + 65535, 6703, 65535, 6689, 3663, 65535, 65535, 65535, 65535, 65535, 4208, + 65535, 65535, 65535, 6698, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6720, 65535, 65535, 65535, 6712, 65535, 65535, 65535, 2910, 65535, 8517, + 65535, 65535, 1917, 65535, 2034, 65535, 6707, 65535, 65535, 65535, 65535, + 1656, 65535, 65535, 2777, 65535, 6710, 65535, 65535, 65535, 2407, 65535, + 65535, 3432, 6715, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3931, 65535, 6706, 65535, 65535, 65535, 1655, 2215, 3768, 6716, 65535, + 6704, 65535, 8518, 6713, 65535, 65535, 65535, 6723, 65535, 6708, 65535, + 65535, 65535, 65535, 65535, 6709, 3503, 65535, 65535, 6714, 65535, 65535, + 65535, 6711, 3955, 6717, 1473, 65535, 65535, 65535, 65535, 6705, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6719, 65535, 6718, 65535, 65535, 65535, 65535, 65535, 65535, 3646, + 6725, 65535, 6736, 65535, 65535, 65535, 65535, 1785, 65535, 65535, 65535, + 6739, 65535, 65535, 6721, 65535, 65535, 65535, 6726, 4213, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6735, 65535, 8519, 4188, 65535, + 65535, 65535, 65535, 4239, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3283, 65535, 65535, 65535, 1766, 65535, 65535, 65535, 65535, 65535, + 3841, 6741, 3478, 65535, 65535, 1426, 65535, 65535, 6734, 65535, 6730, + 3089, 6724, 6732, 6737, 65535, 3583, 65535, 65535, 65535, 1419, 65535, + 6729, 65535, 6738, 3847, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6733, 65535, 6728, 65535, 65535, 65535, 65535, 65535, 65535, 2778, 65535, + 65535, 65535, 65535, 2646, 65535, 65535, 65535, 2549, 65535, 65535, 65535, + 65535, 4097, 65535, 65535, 3798, 65535, 65535, 6744, 65535, 6753, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6731, + 65535, 65535, 65535, 65535, 1778, 65535, 8520, 65535, 65535, 65535, 2813, + 6742, 65535, 6747, 3090, 65535, 65535, 6743, 65535, 6750, 65535, 65535, + 3258, 65535, 6751, 65535, 65535, 4189, 6740, 1715, 65535, 6746, 65535, + 65535, 6749, 4053, 65535, 65535, 65535, 65535, 6752, 65535, 65535, 6745, + 6748, 65535, 8276, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3956, 65535, 4324, 65535, + 65535, 65535, 65535, 65535, 6756, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6763, 65535, 65535, 6755, 2572, 65535, 65535, 65535, 65535, 65535, + 6722, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3899, 65535, 4043, 6762, 6761, 65535, 6757, 6758, 65535, 1525, 65535, + 65535, 65535, 65535, 6760, 65535, 6754, 65535, 65535, 65535, 65535, 3342, + 65535, 65535, 65535, 65535, 65535, 6759, 1503, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3103, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3888, 65535, 65535, 6764, 6768, 65535, 3722, 65535, 65535, 65535, 65535, + 6767, 2779, 2578, 6770, 65535, 65535, 2003, 65535, 65535, 65535, 65535, + 8521, 65535, 6771, 65535, 3848, 6766, 8522, 6727, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6765, 65535, 65535, 65535, 65535, 4370, + 3479, 3842, 8523, 65535, 6778, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6784, 65535, 65535, 65535, 65535, 65535, 65535, 6785, + 65535, 6772, 65535, 65535, 65535, 3657, 65535, 65535, 6782, 6774, 65535, + 6776, 65535, 65535, 65535, 65535, 65535, 6786, 6775, 65535, 65535, 6779, + 65535, 65535, 1585, 65535, 3546, 65535, 6780, 6783, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6773, 65535, 3013, 65535, 6777, 2450, 2856, + 2083, 4125, 65535, 4130, 2713, 8525, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6790, 6788, 65535, 65535, 65535, 65535, 65535, 65535, + 4369, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6787, 65535, 65535, + 65535, 4220, 65535, 6789, 6791, 65535, 65535, 65535, 65535, 6792, 65535, + 65535, 65535, 65535, 65535, 65535, 6795, 6793, 65535, 65535, 65535, 65535, + 65535, 65535, 3480, 6794, 65535, 65535, 65535, 3710, 6781, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2714, + 65535, 6796, 6801, 3091, 65535, 65535, 6800, 65535, 65535, 65535, 6769, + 65535, 65535, 65535, 6802, 3048, 65535, 65535, 6797, 6799, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6798, 65535, 65535, 5656, 5641, 65535, + 65535, 6804, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6803, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4221, 65535, + 6137, 6805, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6806, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6807, 2216, 65535, + 1931, 65535, 65535, 65535, 6809, 4572, 65535, 65535, 65535, 65535, 1964, + 65535, 4255, 65535, 2056, 6810, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6811, 65535, 65535, 65535, 3273, 65535, 65535, 65535, 65535, 65535, + 6812, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3567, 65535, 1435, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1664, 6817, 6818, 65535, 65535, 65535, 65535, + 65535, 65535, 6813, 65535, 2472, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6814, 3605, 65535, 65535, + 65535, 65535, 6815, 6816, 6826, 65535, 65535, 65535, 6820, 6823, 65535, + 65535, 65535, 65535, 65535, 6819, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6821, 65535, 6822, 2593, + 65535, 6824, 65535, 3228, 65535, 2121, 1725, 65535, 65535, 65535, 65535, + 65535, 6827, 65535, 65535, 65535, 65535, 1722, 65535, 6832, 65535, 65535, + 6828, 6831, 65535, 65535, 65535, 65535, 3691, 65535, 65535, 65535, 65535, + 6829, 65535, 65535, 6830, 3799, 3723, 6833, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3194, 6843, 65535, 6839, 65535, 65535, 1672, + 65535, 6837, 65535, 3957, 6838, 65535, 65535, 6835, 65535, 6836, 6841, + 6844, 65535, 65535, 6842, 65535, 65535, 65535, 6840, 6834, 65535, 65535, + 65535, 65535, 65535, 3251, 65535, 6851, 65535, 4051, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6849, 65535, 65535, 65535, 6850, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6845, 65535, + 65535, 6847, 65535, 65535, 65535, 6848, 65535, 65535, 65535, 6846, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2983, 65535, 4348, + 6855, 65535, 6856, 65535, 65535, 65535, 65535, 6862, 65535, 2829, 65535, + 6858, 65535, 6861, 65535, 65535, 65535, 65535, 65535, 6853, 6852, 65535, + 65535, 6863, 65535, 65535, 1657, 65535, 6859, 65535, 6864, 65535, 65535, + 65535, 6860, 65535, 65535, 65535, 65535, 65535, 6857, 65535, 3308, 65535, + 6854, 65535, 65535, 65535, 65535, 65535, 65535, 3643, 65535, 65535, 6868, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4162, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6867, 65535, 65535, 6866, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6875, 65535, 65535, + 65535, 6869, 65535, 65535, 65535, 6877, 65535, 65535, 65535, 65535, 65535, + 65535, 4205, 6880, 65535, 6871, 65535, 65535, 6872, 65535, 65535, 65535, + 6876, 65535, 6879, 6878, 65535, 65535, 65535, 6870, 65535, 65535, 65535, + 65535, 6873, 65535, 6890, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6883, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6881, + 65535, 65535, 6882, 65535, 65535, 65535, 6887, 6888, 65535, 1701, 65535, + 1913, 65535, 65535, 6886, 65535, 65535, 65535, 65535, 65535, 65535, 6865, + 65535, 8528, 65535, 65535, 65535, 65535, 65535, 6885, 6889, 6884, 65535, + 6891, 65535, 65535, 65535, 6893, 6892, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6895, 6894, 6825, 65535, 65535, 65535, + 6899, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6896, + 65535, 65535, 65535, 65535, 6897, 65535, 65535, 6898, 65535, 6900, 65535, + 65535, 65535, 65535, 2143, 65535, 6902, 65535, 6901, 65535, 2647, 65535, + 65535, 65535, 65535, 65535, 2307, 5740, 65535, 65535, 65535, 65535, 6903, + 2680, 65535, 65535, 65535, 1716, 65535, 6904, 65535, 1553, 65535, 2780, + 6905, 65535, 65535, 2308, 6906, 1474, 65535, 65535, 65535, 65535, 3788, + 65535, 65535, 6907, 65535, 65535, 65535, 65535, 2893, 65535, 6914, 65535, + 65535, 6911, 65535, 3274, 65535, 65535, 65535, 65535, 65535, 6912, 6909, + 2035, 65535, 6908, 6915, 65535, 65535, 65535, 65535, 65535, 2089, 65535, + 65535, 3163, 65535, 6921, 65535, 65535, 65535, 65535, 6917, 65535, 65535, + 65535, 3122, 6916, 65535, 6919, 65535, 65535, 65535, 65535, 6910, 65535, + 65535, 65535, 6920, 65535, 6922, 65535, 65535, 65535, 65535, 65535, 65535, + 3744, 65535, 65535, 6918, 65535, 6923, 6925, 65535, 65535, 2212, 6913, + 65535, 1442, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6924, 65535, + 2408, 4315, 6926, 6927, 3092, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4231, 65535, 65535, 65535, 65535, 6928, 4156, 65535, + 65535, 6929, 6930, 65535, 65535, 3921, 6931, 65535, 2381, 65535, 4232, + 65535, 65535, 65535, 65535, 65535, 65535, 6936, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6937, 2781, 6935, 8529, 65535, 65535, + 4206, 6932, 65535, 65535, 6934, 2942, 2913, 65535, 65535, 65535, 6933, + 65535, 6938, 65535, 65535, 3856, 65535, 65535, 6940, 65535, 6939, 65535, + 65535, 65535, 1767, 65535, 3958, 6941, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8273, 6953, 6943, 65535, 65535, 65535, 65535, 65535, + 65535, 6944, 65535, 65535, 65535, 65535, 6945, 6946, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6950, 65535, 6951, 65535, + 65535, 6949, 65535, 65535, 65535, 65535, 65535, 6947, 65535, 6942, 6948, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6952, 7448, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1605, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6955, 2036, 6954, 65535, 65535, 65535, 6957, 65535, + 6956, 65535, 65535, 65535, 6959, 65535, 65535, 6958, 65535, 6960, 65535, + 65535, 2648, 65535, 6961, 65535, 65535, 6962, 65535, 65535, 65535, 65535, + 65535, 65535, 6963, 2943, 65535, 4190, 65535, 6964, 65535, 65535, 3857, + 3609, 6965, 65535, 6966, 2172, 65535, 65535, 65535, 1891, 65535, 65535, + 65535, 6967, 65535, 65535, 2518, 3604, 6968, 65535, 1739, 65535, 65535, + 65535, 65535, 65535, 65535, 6969, 65535, 65535, 65535, 65535, 6971, 4222, + 65535, 6970, 2857, 65535, 6972, 65535, 65535, 6973, 65535, 65535, 6974, + 1834, 65535, 65535, 65535, 65535, 65535, 65535, 6975, 65535, 65535, 6976, + 65535, 6977, 6978, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1740, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6979, 65535, 6980, 6981, 65535, + 65535, 65535, 65535, 65535, 1679, 65535, 65535, 2827, 6982, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6983, + 65535, 65535, 65535, 6984, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2193, 65535, 3380, 6985, 65535, 65535, 65535, 65535, 2122, 65535, 2873, + 65535, 6988, 65535, 3481, 65535, 6987, 65535, 8530, 2084, 65535, 65535, + 6986, 3188, 1892, 65535, 65535, 6989, 65535, 6990, 65535, 2782, 65535, + 65535, 65535, 2144, 65535, 6991, 65535, 65535, 65535, 65535, 3959, 65535, + 65535, 2976, 65535, 65535, 65535, 1965, 65535, 4126, 3049, 65535, 6992, + 8531, 65535, 65535, 2858, 3275, 2783, 65535, 65535, 65535, 65535, 6993, + 65535, 65535, 65535, 65535, 6996, 65535, 6997, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2379, 3135, 6995, 65535, 2784, 3789, 65535, 65535, + 65535, 65535, 65535, 6994, 65535, 65535, 2519, 65535, 1554, 65535, 7001, + 2123, 65535, 65535, 2521, 65535, 65535, 2520, 65535, 4368, 7000, 6999, + 3014, 65535, 1924, 4358, 1717, 2785, 65535, 65535, 65535, 65535, 65535, + 8532, 65535, 65535, 6998, 65535, 65535, 65535, 65535, 65535, 7003, 65535, + 7004, 7002, 65535, 2217, 65535, 4167, 65535, 65535, 2522, 3578, 65535, + 65535, 65535, 7007, 65535, 2945, 65535, 3229, 65535, 65535, 4157, 65535, + 7010, 65535, 65535, 65535, 2237, 65535, 2944, 7006, 65535, 7011, 2238, + 7008, 7009, 8533, 7005, 65535, 65535, 65535, 2979, 3518, 65535, 65535, + 3210, 65535, 1658, 65535, 65535, 65535, 65535, 65535, 65535, 3745, 65535, + 65535, 1914, 65535, 8534, 3309, 65535, 65535, 7014, 65535, 7012, 65535, + 65535, 3239, 65535, 65535, 65535, 2946, 1835, 7013, 65535, 2878, 65535, + 65535, 4271, 65535, 65535, 65535, 4355, 65535, 65535, 65535, 7015, 7026, + 3310, 65535, 7025, 8535, 7022, 7030, 7023, 65535, 7019, 65535, 3381, 7018, + 65535, 65535, 65535, 7016, 65535, 4136, 2523, 65535, 65535, 7020, 65535, + 7017, 65535, 65535, 8537, 7024, 2715, 65535, 2194, 65535, 65535, 65535, + 3191, 65535, 3984, 1561, 1475, 65535, 3482, 65535, 65535, 7028, 65535, + 65535, 65535, 65535, 7027, 65535, 3547, 65535, 7032, 65535, 65535, 65535, + 7021, 65535, 7031, 7033, 65535, 2173, 7029, 2309, 65535, 2590, 65535, + 65535, 7034, 4191, 65535, 65535, 65535, 65535, 7037, 65535, 7040, 65535, + 65535, 7038, 3780, 65535, 65535, 65535, 65535, 65535, 65535, 7035, 65535, + 65535, 65535, 65535, 65535, 2037, 65535, 65535, 65535, 65535, 7039, 65535, + 65535, 7041, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7045, 65535, + 65535, 7042, 65535, 7044, 7043, 65535, 65535, 65535, 8538, 65535, 65535, + 7046, 65535, 2554, 65535, 7048, 7047, 3831, 65535, 65535, 7050, 65535, + 65535, 65535, 65535, 65535, 65535, 2124, 65535, 65535, 65535, 65535, 7049, + 7051, 65535, 65535, 7052, 1915, 6518, 2814, 65535, 7053, 65535, 65535, + 2239, 65535, 65535, 65535, 65535, 65535, 7054, 65535, 8539, 7055, 65535, + 65535, 2473, 65535, 65535, 65535, 65535, 65535, 65535, 5403, 65535, 7056, + 65535, 7057, 65535, 2649, 65535, 7058, 7059, 65535, 65535, 7060, 65535, + 65535, 7061, 7062, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3206, + 65535, 65535, 7063, 65535, 65535, 65535, 65535, 7065, 65535, 7064, 65535, + 65535, 65535, 65535, 3483, 65535, 7066, 65535, 3960, 65535, 7067, 65535, + 7068, 65535, 7069, 65535, 65535, 65535, 65535, 7070, 65535, 65535, 65535, + 65535, 3535, 65535, 65535, 65535, 65535, 65535, 65535, 2786, 7071, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2330, 4431, 7072, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7073, 3790, + 7074, 65535, 7082, 65535, 65535, 65535, 65535, 65535, 7075, 65535, 65535, + 7077, 65535, 65535, 65535, 7076, 7078, 65535, 3985, 7079, 7080, 65535, + 65535, 65535, 65535, 65535, 7081, 65535, 65535, 65535, 7083, 65535, 65535, + 65535, 65535, 1704, 3360, 65535, 3832, 2415, 2310, 65535, 65535, 65535, + 65535, 3806, 1660, 3711, 7086, 1836, 2966, 7085, 7090, 3284, 4108, 65535, + 7088, 7089, 1893, 65535, 7091, 3638, 3164, 65535, 65535, 3746, 3412, 7087, + 65535, 3986, 1673, 7093, 4331, 3323, 4360, 65535, 65535, 2524, 7092, 65535, + 3118, 65535, 65535, 7109, 3015, 65535, 65535, 3565, 65535, 3807, 65535, + 65535, 65535, 65535, 65535, 65535, 7096, 2474, 2525, 65535, 2787, 65535, + 3640, 65535, 2174, 7095, 7094, 65535, 3833, 65535, 65535, 65535, 2570, + 65535, 65535, 3433, 65535, 65535, 8540, 65535, 65535, 65535, 8541, 65535, + 65535, 65535, 65535, 65535, 7098, 7099, 2311, 7097, 65535, 65535, 65535, + 65535, 65535, 65535, 7100, 7101, 65535, 7103, 3104, 65535, 7102, 1855, + 65535, 7105, 65535, 7104, 7106, 65535, 8542, 7108, 7110, 65535, 7111, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2967, 65535, 2584, 7112, 65535, 65535, 65535, 1741, + 65535, 7113, 65535, 65535, 3093, 7114, 65535, 7115, 3834, 65535, 8543, + 1894, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7116, + 65535, 65535, 65535, 3311, 65535, 65535, 65535, 65535, 1562, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7117, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2618, 65535, 65535, 65535, 65535, 2905, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3114, 65535, 65535, 65535, 65535, + 65535, 65535, 7120, 65535, 65535, 65535, 7119, 65535, 65535, 65535, 7118, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7126, 7124, 65535, + 65535, 7121, 65535, 65535, 65535, 65535, 65535, 65535, 7123, 65535, 65535, + 65535, 7122, 7125, 65535, 1966, 65535, 7129, 65535, 2968, 65535, 7130, + 65535, 65535, 65535, 65535, 2218, 65535, 7127, 7128, 65535, 65535, 65535, + 4332, 65535, 65535, 65535, 3312, 65535, 3016, 65535, 65535, 65535, 65535, + 65535, 65535, 7131, 65535, 65535, 7134, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7132, 7133, 4192, 65535, 65535, 65535, 65535, 3484, + 7137, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7135, 7136, 7138, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7152, 65535, 65535, 65535, 65535, 65535, 7141, + 65535, 65535, 65535, 7142, 7140, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7139, 65535, 3382, 65535, 65535, + 7144, 7148, 7145, 7143, 65535, 7146, 65535, 65535, 65535, 7147, 65535, + 65535, 65535, 65535, 7154, 65535, 65535, 65535, 7149, 65535, 65535, 65535, + 65535, 65535, 2969, 7151, 65535, 65535, 7153, 7150, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7156, + 65535, 2650, 65535, 7155, 65535, 65535, 65535, 65535, 65535, 7157, 65535, + 65535, 65535, 65535, 7158, 65535, 65535, 7161, 7160, 65535, 7159, 65535, + 65535, 7163, 7162, 65535, 4127, 65535, 65535, 65535, 7165, 65535, 7164, + 7166, 65535, 65535, 65535, 65535, 7167, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7169, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 7168, 2859, 7170, 65535, 65535, 2050, 7171, 7173, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7174, 65535, + 65535, 65535, 65535, 65535, 65535, 7175, 7172, 65535, 7176, 65535, 2591, + 7177, 1895, 2086, 65535, 8545, 65535, 65535, 2175, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7178, 65535, 65535, 65535, 3557, 65535, + 65535, 3413, 7179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7182, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2557, 65535, 65535, 7181, 7180, 2125, 7183, 65535, 65535, + 65535, 65535, 1742, 65535, 7185, 65535, 65535, 65535, 2409, 7184, 65535, + 7193, 65535, 65535, 65535, 65535, 65535, 7187, 7189, 3922, 7186, 65535, + 65535, 65535, 7188, 65535, 7192, 7190, 1896, 65535, 7191, 65535, 65535, + 65535, 65535, 65535, 65535, 7194, 65535, 65535, 3629, 4285, 65535, 65535, + 65535, 65535, 2651, 65535, 65535, 65535, 7195, 65535, 65535, 65535, 65535, + 4137, 7197, 65535, 7196, 65535, 65535, 7200, 4168, 65535, 65535, 7199, + 65535, 1768, 7198, 7203, 65535, 65535, 7202, 65535, 65535, 7201, 3401, + 7204, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7205, 65535, + 65535, 65535, 65535, 7206, 65535, 65535, 2331, 65535, 2072, 7207, 7208, + 7209, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2860, 7210, 65535, 2550, 7211, 65535, 65535, + 65535, 7212, 65535, 65535, 65535, 4606, 4605, 65535, 65535, 65535, 65535, + 7213, 6471, 7214, 3199, 2830, 3603, 65535, 65535, 65535, 65535, 7215, + 65535, 65535, 3906, 3341, 2349, 65535, 65535, 3204, 65535, 65535, 1513, + 65535, 4035, 2874, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2129, 65535, 65535, 2038, 65535, 65535, 3907, 65535, 65535, 65535, 65535, + 65535, 7216, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7218, 65535, + 65535, 7217, 1661, 65535, 65535, 3563, 7219, 3658, 65535, 3402, 65535, + 7220, 2681, 65535, 65535, 65535, 7222, 65535, 65535, 4075, 7237, 7224, + 7225, 65535, 65535, 3330, 65535, 65535, 3165, 3094, 65535, 3485, 65535, + 7223, 1932, 65535, 65535, 65535, 65535, 7232, 65535, 7229, 7242, 3486, + 3259, 7226, 65535, 3383, 3434, 7227, 7231, 2883, 65535, 3642, 3333, 65535, + 65535, 2947, 7230, 3115, 3105, 7228, 1418, 4325, 65535, 65535, 65535, 7233, + 65535, 65535, 65535, 65535, 65535, 65535, 3166, 65535, 65535, 2652, 2861, + 65535, 65535, 7235, 7234, 65535, 1488, 7236, 65535, 65535, 3774, 65535, + 7244, 65535, 65535, 3536, 2894, 65535, 65535, 3252, 65535, 2061, 65535, + 7243, 4158, 1534, 65535, 3908, 1662, 7238, 7239, 7240, 7241, 3504, 3198, + 1476, 7245, 65535, 7246, 7804, 65535, 65535, 3130, 65535, 7247, 65535, + 1586, 3051, 65535, 2176, 65535, 4193, 65535, 8548, 7248, 3395, 65535, + 65535, 65535, 3095, 2592, 7249, 65535, 65535, 7252, 65535, 65535, 2700, + 7250, 3018, 3017, 65535, 1477, 65535, 4272, 7254, 65535, 3747, 7256, 7255, + 7253, 6271, 1837, 65535, 65535, 7221, 65535, 7258, 7257, 65535, 65535, + 65535, 65535, 7259, 65535, 4159, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3542, 65535, 65535, 3961, 65535, 7260, 65535, 2594, 65535, 65535, + 65535, 65535, 7261, 65535, 7262, 65535, 65535, 65535, 7263, 65535, 65535, + 3384, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1483, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2312, 65535, 65535, 65535, + 4349, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7267, 65535, 65535, 8549, 65535, 65535, 2087, 7264, 65535, + 7265, 65535, 65535, 65535, 3843, 65535, 65535, 65535, 65535, 1743, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4160, 65535, 2004, 65535, 65535, + 65535, 65535, 65535, 3435, 65535, 65535, 65535, 65535, 7268, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7269, 65535, 65535, 8551, 65535, 65535, 65535, 7270, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8552, 65535, 65535, 65535, 65535, 65535, 3385, 65535, + 65535, 7272, 65535, 7271, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3528, 7273, 2653, 2601, 3630, 3276, + 65535, 65535, 65535, 2619, 65535, 2895, 65535, 7274, 65535, 7275, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2880, 7276, 65535, + 7277, 65535, 65535, 65535, 7278, 4214, 65535, 2654, 65535, 65535, 65535, + 65535, 65535, 7280, 7279, 65535, 2313, 65535, 2338, 2475, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7283, 65535, 65535, 65535, + 65535, 2701, 65535, 7282, 65535, 7281, 65535, 3174, 65535, 65535, 2240, + 65535, 2948, 65535, 65535, 65535, 65535, 3681, 65535, 65535, 65535, 65535, + 2656, 65535, 65535, 65535, 65535, 65535, 7284, 65535, 2788, 65535, 65535, + 65535, 65535, 65535, 7287, 7285, 65535, 65535, 65535, 7286, 65535, 65535, + 65535, 65535, 7289, 7288, 65535, 65535, 2815, 65535, 7290, 65535, 65535, + 65535, 65535, 65535, 7291, 7292, 65535, 65535, 65535, 65535, 3713, 2400, + 2602, 7293, 65535, 7294, 4233, 2668, 4119, 4273, 7295, 2039, 65535, 65535, + 65535, 65535, 7296, 8554, 3386, 65535, 8553, 7299, 1779, 2862, 8555, 7297, + 65535, 7298, 65535, 3353, 8558, 8559, 4000, 2065, 65535, 65535, 65535, + 65535, 65535, 8556, 8557, 65535, 65535, 65535, 65535, 65535, 65535, 7301, + 7302, 65535, 65535, 65535, 65535, 65535, 7300, 65535, 65535, 7304, 65535, + 65535, 65535, 65535, 65535, 65535, 8560, 65535, 65535, 65535, 8562, 65535, + 65535, 3540, 1726, 65535, 8561, 7308, 65535, 65535, 7305, 7307, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7303, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7378, 65535, 65535, 7306, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4304, 65535, 65535, 2219, + 65535, 8569, 8563, 65535, 8565, 65535, 65535, 7316, 8564, 65535, 65535, + 65535, 3403, 7311, 65535, 65535, 7314, 7312, 65535, 7317, 65535, 65535, + 8566, 65535, 7318, 8568, 65535, 65535, 65535, 65535, 65535, 7310, 65535, + 8567, 7323, 1587, 65535, 65535, 7309, 65535, 65535, 65535, 3678, 65535, + 7313, 65535, 2789, 8570, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2314, 65535, 65535, 65535, 65535, 65535, 8572, 8573, 65535, + 65535, 65535, 65535, 65535, 3987, 65535, 2041, 65535, 65535, 2669, 65535, + 3505, 65535, 65535, 8275, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3020, 65535, 7321, 65535, 7315, 7320, 65535, 4076, 65535, 3313, + 7322, 7319, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 8571, 65535, 65535, 65535, 65535, 65535, 3019, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7326, 65535, 7325, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7324, 8577, + 65535, 3962, 8581, 65535, 8579, 65535, 8575, 65535, 8576, 65535, 65535, + 65535, 65535, 65535, 65535, 8580, 65535, 65535, 65535, 2722, 65535, 65535, + 8574, 65535, 7327, 3916, 65535, 65535, 1555, 65535, 65535, 65535, 65535, + 3797, 3277, 65535, 65535, 65535, 65535, 1967, 8281, 7329, 8584, 2316, + 65535, 65535, 8587, 65535, 65535, 8589, 65535, 65535, 65535, 2455, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7328, 2896, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2897, 7332, 7334, 65535, 65535, 8588, + 8586, 65535, 2816, 8583, 7333, 7335, 65535, 8582, 2024, 65535, 3796, 65535, + 65535, 2603, 4326, 65535, 7331, 2437, 65535, 65535, 4354, 65535, 65535, + 7337, 65535, 65535, 65535, 65535, 7336, 7338, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7330, 65535, 65535, 65535, 8274, 65535, 65535, + 3550, 65535, 3436, 65535, 65535, 65535, 65535, 65535, 65535, 3344, 65535, + 7343, 8591, 65535, 65535, 65535, 3230, 7339, 65535, 65535, 65535, 7340, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2080, 65535, 7342, 65535, 8590, 65535, 65535, 65535, 65535, 2177, + 65535, 65535, 65535, 65535, 65535, 65535, 7341, 65535, 2790, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1780, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7347, 65535, + 2380, 3096, 65535, 65535, 3331, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8592, 65535, 65535, 1718, 65535, 65535, 65535, 65535, + 7345, 7346, 3324, 65535, 7344, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7348, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7354, 65535, 65535, 8593, 65535, 7357, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7356, 3396, 65535, 65535, 65535, 65535, 7349, 7350, + 7353, 65535, 65535, 65535, 65535, 7355, 8594, 65535, 65535, 2005, 65535, + 65535, 7358, 7352, 65535, 65535, 7351, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8595, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7362, + 65535, 65535, 65535, 7363, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7364, 65535, 65535, 7361, 7360, 65535, 65535, 65535, 2791, 3487, + 7359, 65535, 65535, 65535, 65535, 65535, 65535, 7368, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7366, 65535, 65535, 65535, 65535, + 65535, 8596, 65535, 65535, 65535, 7367, 7365, 65535, 3189, 65535, 7369, + 65535, 65535, 65535, 65535, 65535, 65535, 7370, 65535, 65535, 7372, 8597, + 65535, 65535, 8598, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1838, 7371, 4131, 65535, 65535, 65535, 65535, 65535, 65535, 7383, 7373, + 65535, 65535, 7376, 65535, 7374, 65535, 7375, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7377, 65535, 65535, 65535, 65535, 65535, 7379, 65535, + 65535, 65535, 65535, 7380, 65535, 7381, 65535, 65535, 65535, 65535, 7384, + 7382, 7385, 7387, 65535, 7386, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3314, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4112, 65535, 7388, 3021, 65535, 65535, + 65535, 7389, 65535, 3889, 7390, 1702, 65535, 65535, 65535, 1531, 65535, + 1840, 8599, 1839, 7391, 65535, 7392, 65535, 7393, 7394, 65535, 65535, + 65535, 65535, 65535, 65535, 7395, 65535, 1841, 1744, 2317, 3687, 65535, + 7397, 7396, 65535, 65535, 65535, 65535, 7398, 65535, 65535, 65535, 65535, + 1563, 65535, 65535, 65535, 65535, 65535, 65535, 7401, 65535, 7400, 7399, + 65535, 7402, 65535, 65535, 65535, 65535, 7405, 65535, 65535, 65535, 1448, + 65535, 65535, 7403, 65535, 7407, 7406, 65535, 65535, 65535, 65535, 65535, + 65535, 7409, 7408, 7410, 65535, 3491, 65535, 65535, 65535, 7411, 65535, + 65535, 65535, 65535, 7412, 7414, 65535, 65535, 7413, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3835, 65535, 65535, 65535, 65535, 7415, 65535, 65535, 65535, 65535, + 65535, 65535, 7416, 65535, 2418, 65535, 65535, 65535, 7417, 7418, 65535, + 65535, 3988, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3050, + 65535, 65535, 65535, 1413, 3144, 65535, 7419, 65535, 3836, 65535, 65535, + 65535, 65535, 65535, 65535, 7422, 7420, 2318, 65535, 7421, 2195, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3890, 7424, + 7426, 7425, 7427, 65535, 65535, 1504, 2875, 2723, 1842, 7428, 65535, 65535, + 65535, 3641, 65535, 7430, 65535, 65535, 65535, 1505, 65535, 7429, 3325, + 65535, 4274, 3488, 7423, 4235, 65535, 2178, 65535, 65535, 4194, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2062, 4249, 65535, 2075, 65535, + 3167, 6580, 65535, 7431, 1703, 2898, 65535, 65535, 65535, 65535, 1745, + 7433, 65535, 7434, 7432, 2135, 65535, 2410, 2792, 8602, 65535, 65535, 1506, + 65535, 65535, 4286, 65535, 65535, 65535, 7436, 7251, 65535, 7435, 65535, + 65535, 65535, 65535, 8603, 7439, 7437, 7438, 65535, 7440, 65535, 7441, + 4305, 7442, 7443, 65535, 2954, 3692, 65535, 65535, 65535, 2912, 1856, + 65535, 65535, 4161, 1674, 2655, 2220, 65535, 7446, 65535, 7445, 2526, 7447, + 7444, 65535, 65535, 2451, 65535, 65535, 65535, 7451, 6874, 65535, 65535, + 4659, 65535, 2906, 7449, 65535, 65535, 65535, 65535, 65535, 4234, 3558, + 65535, 65535, 65535, 65535, 1514, 65535, 2980, 2559, 65535, 65535, 65535, + 65535, 3876, 65535, 1535, 65535, 65535, 65535, 4306, 4210, 65535, 7452, + 65535, 3420, 65535, 65535, 65535, 65535, 2628, 65535, 65535, 65535, 7453, + 65535, 7454, 2863, 7455, 65535, 4307, 65535, 65535, 7450, 7457, 7459, + 65535, 7458, 65535, 7456, 65535, 65535, 7460, 65535, 65535, 7461, 65535, + 65535, 3097, 65535, 1663, 65535, 65535, 65535, 65535, 65535, 7462, 65535, + 65535, 4065, 65535, 65535, 7463, 65535, 65535, 65535, 65535, 65535, 7464, + 65535, 4333, 8604, 65535, 65535, 65535, 65535, 5468, 7465, 65535, 8605, + 65535, 7466, 7467, 65535, 65535, 65535, 7471, 8606, 7468, 65535, 7469, + 65535, 7470, 7472, 65535, 65535, 65535, 8607, 65535, 8608, 65535, 8609, + 2949, 65535, 65535, 8610, 4128, 65535, 65535, 2950, 65535, 65535, 7473, + 65535, 3748, 65535, 7474, 7758, 4085, 65535, 7475, 65535, 7476, 65535, + 7477, 1746, 65535, 7479, 65535, 2876, 65535, 65535, 65535, 7480, 65535, + 65535, 2071, 65535, 65535, 65535, 65535, 7481, 7485, 65535, 7483, 65535, + 65535, 65535, 65535, 7484, 65535, 65535, 1774, 7482, 7486, 65535, 65535, + 65535, 65535, 7487, 65535, 1449, 65535, 7488, 7489, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2793, 65535, 65535, 65535, 7490, 65535, 65535, + 65535, 1918, 65535, 65535, 7493, 65535, 65535, 7492, 65535, 7491, 65535, + 65535, 7036, 65535, 3913, 65535, 65535, 65535, 65535, 65535, 7494, 7495, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7496, 65535, 65535, 7497, 65535, 7498, 65535, + 65535, 7499, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1843, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7500, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7501, 3574, 65535, 65535, 65535, 7503, 1624, 65535, + 7506, 7505, 65535, 65535, 65535, 65535, 1507, 65535, 65535, 65535, 2006, + 65535, 3892, 3315, 2351, 65535, 2319, 2702, 65535, 2879, 65535, 65535, + 65535, 7508, 65535, 65535, 7507, 4169, 1857, 3715, 3537, 65535, 65535, + 65535, 2911, 4275, 65535, 2126, 65535, 65535, 65535, 65535, 65535, 65535, + 7511, 65535, 65535, 7510, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3990, 3489, 65535, 65535, 65535, 65535, 65535, 65535, 1551, 65535, 65535, + 7512, 7509, 65535, 65535, 3808, 4209, 7513, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7514, 65535, 65535, 65535, 65535, 7516, 3175, + 1750, 1751, 7515, 65535, 65535, 65535, 65535, 1858, 2179, 65535, 8611, + 1859, 65535, 65535, 3414, 65535, 65535, 4293, 65535, 65535, 65535, 65535, + 65535, 65535, 8612, 65535, 2221, 65535, 65535, 65535, 7517, 65535, 65535, + 65535, 7518, 7519, 7520, 65535, 7522, 7521, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3846, 65535, 7523, 65535, 65535, 65535, + 65535, 7524, 65535, 7525, 65535, 65535, 65535, 65535, 7526, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7528, + 7527, 65535, 7529, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3749, 6529, 65535, 65535, 2828, 65535, 65535, 1897, 65535, + 65535, 65535, 65535, 65535, 65535, 7530, 65535, 7531, 65535, 4617, 5666, + 3716, 65535, 65535, 1500, 65535, 1436, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2527, 3963, 2819, 65535, 65535, 65535, 65535, 7532, 65535, + 4104, 65535, 65535, 65535, 7533, 4195, 65535, 1537, 65535, 65535, 65535, + 2476, 65535, 7534, 1675, 7535, 65535, 65535, 65535, 7536, 65535, 65535, + 65535, 65535, 7538, 7539, 65535, 7541, 7537, 65535, 65535, 7540, 65535, + 65535, 8615, 1844, 65535, 65535, 65535, 7542, 65535, 7543, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7544, 7545, 65535, 65535, 65535, 7546, 65535, 65535, 7548, + 65535, 65535, 65535, 7547, 65535, 7550, 7553, 65535, 65535, 65535, 7549, + 7551, 7552, 65535, 65535, 7554, 65535, 2007, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2620, 7555, 7556, 2320, 65535, + 65535, 65535, 65535, 8617, 65535, 65535, 65535, 65535, 65535, 65535, 7557, + 65535, 65535, 1721, 65535, 65535, 65535, 3618, 7558, 7559, 65535, 65535, + 65535, 65535, 3253, 3552, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 7560, 65535, 65535, 65535, 65535, 3664, 65535, 65535, 3145, 1559, 2051, + 65535, 2052, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3278, 7565, + 2053, 65535, 65535, 1676, 65535, 65535, 7564, 65535, 65535, 7562, 65535, + 7563, 65535, 7561, 65535, 65535, 7575, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7566, 7567, 65535, 65535, 7568, 7569, + 65535, 65535, 65535, 65535, 65535, 7571, 65535, 65535, 7570, 65535, 65535, + 65535, 2688, 65535, 7572, 65535, 65535, 65535, 7574, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1898, 7573, 65535, 65535, 3098, 2180, + 65535, 65535, 65535, 65535, 65535, 7576, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3146, 65535, + 65535, 7577, 65535, 65535, 65535, 65535, 3490, 65535, 65535, 65535, 65535, + 65535, 65535, 7578, 65535, 65535, 65535, 65535, 65535, 65535, 7583, 65535, + 7581, 65535, 7580, 7582, 65535, 7579, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7585, 8618, 65535, 65535, 65535, 65535, 65535, 65535, 7584, + 65535, 7587, 65535, 65535, 2008, 7586, 65535, 65535, 65535, 7588, 65535, + 65535, 7589, 65535, 7591, 7590, 65535, 65535, 65535, 7592, 7594, 7593, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2347, 65535, 65535, + 65535, 65535, 7595, 65535, 65535, 7596, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1719, 65535, 65535, 65535, 7597, 65535, 65535, 65535, 7598, + 65535, 65535, 65535, 2900, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7599, 65535, 7600, 65535, 7601, 7602, 65535, 65535, + 65535, 2321, 8619, 65535, 65535, 8620, 65535, 7603, 7604, 65535, 65535, + 7605, 7606, 65535, 65535, 7607, 65535, 65535, 65535, 3682, 7609, 65535, + 3765, 7610, 7608, 65535, 7612, 65535, 65535, 7611, 65535, 65535, 7613, + 65535, 65535, 65535, 7614, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7615, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7616, + 65535, 7617, 65535, 65535, 65535, 65535, 7618, 65535, 65535, 7619, 7620, + 65535, 7621, 65535, 7622, 7623, 7624, 7625, 65535, 65535, 65535, 7626, + 7627, 65535, 5660, 7628, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6385, 1899, 65535, 65535, 65535, 65535, 1692, 2367, 7630, 7629, + 4046, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7632, 7633, 7631, + 65535, 7634, 65535, 65535, 4013, 65535, 65535, 65535, 7635, 65535, 1970, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4328, + 65535, 65535, 8622, 65535, 7636, 8621, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7638, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1439, 8623, 65535, + 7639, 3864, 7637, 65535, 65535, 7640, 7641, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7642, 7643, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7644, 65535, 4025, 2456, 65535, 2439, 3022, 65535, 65535, 8624, + 65535, 65535, 7645, 65535, 65535, 65535, 65535, 7648, 65535, 8625, 65535, + 65535, 65535, 65535, 7646, 65535, 65535, 65535, 65535, 65535, 7649, 65535, + 65535, 2242, 7647, 65535, 65535, 65535, 65535, 7650, 65535, 7651, 7652, + 65535, 7656, 65535, 2453, 65535, 65535, 65535, 65535, 3169, 65535, 65535, + 65535, 65535, 65535, 7657, 7654, 7653, 7655, 65535, 65535, 65535, 2130, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7661, 7660, 7659, 65535, + 65535, 1428, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 8626, 65535, 65535, 65535, 7671, 65535, 7667, 65535, 7668, 7664, + 7670, 65535, 7666, 1757, 65535, 65535, 4367, 65535, 7669, 7665, 7663, 7662, + 65535, 65535, 65535, 65535, 65535, 7673, 65535, 65535, 65535, 65535, 65535, + 7676, 65535, 65535, 7675, 7674, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3800, 7672, 1492, 7677, 65535, 7679, 65535, 65535, 65535, 65535, + 65535, 65535, 1770, 7658, 1526, 65535, 65535, 7681, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7680, 7678, 3208, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4027, 65535, 65535, 65535, 65535, 4287, + 65535, 65535, 7682, 65535, 65535, 65535, 65535, 65535, 7683, 65535, 65535, + 65535, 65535, 65535, 65535, 7684, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7685, 65535, 7686, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3316, 65535, 7687, 65535, 3688, 65535, 7692, 7688, 65535, + 65535, 65535, 7689, 65535, 65535, 3964, 4077, 65535, 3525, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7693, + 65535, 65535, 7694, 3507, 7691, 7690, 65535, 65535, 65535, 65535, 1607, + 65535, 65535, 65535, 7702, 65535, 65535, 7701, 65535, 65535, 65535, 65535, + 65535, 1588, 65535, 65535, 65535, 7699, 65535, 65535, 65535, 7698, 65535, + 65535, 7696, 65535, 1782, 65535, 7695, 2555, 1606, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2322, 65535, 65535, 7705, 7704, 65535, 7703, 65535, 65535, 7700, + 65535, 7706, 65535, 7707, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 7712, 7711, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7713, 65535, + 65535, 1516, 7708, 7709, 65535, 2339, 4066, 65535, 65535, 7710, 65535, + 65535, 65535, 65535, 65535, 65535, 8628, 3965, 65535, 65535, 7718, 8627, + 65535, 7714, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7719, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7716, 65535, 7715, 65535, 65535, 65535, 65535, 65535, 2127, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7720, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7721, 65535, 65535, + 65535, 65535, 7722, 65535, 7717, 65535, 65535, 65535, 7697, 65535, 65535, + 7723, 65535, 3354, 65535, 65535, 65535, 7727, 65535, 7728, 7726, 65535, + 65535, 65535, 65535, 65535, 7725, 7731, 65535, 7724, 65535, 7729, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7730, 65535, 65535, 65535, + 7733, 65535, 65535, 65535, 65535, 65535, 7732, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7735, 65535, 65535, + 65535, 65535, 65535, 65535, 7736, 65535, 7737, 65535, 65535, 4364, 65535, + 65535, 65535, 65535, 65535, 7734, 3176, 2426, 65535, 65535, 7738, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 8630, 7739, 7740, 65535, 65535, + 7741, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7742, 65535, 65535, 2181, 7743, 65535, 65535, 65535, 7744, + 65535, 2552, 65535, 7745, 65535, 65535, 65535, 65535, 65535, 65535, 7746, + 65535, 65535, 7747, 7748, 65535, 65535, 65535, 65535, 7751, 7749, 4351, + 65535, 7750, 65535, 4308, 65535, 65535, 65535, 65535, 65535, 7752, 65535, + 4288, 65535, 65535, 65535, 65535, 65535, 7753, 3665, 65535, 65535, 7754, + 7756, 65535, 65535, 7757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7755, 2332, 4086, 4014, 5068, 65535, 5703, 4038, + 65535, 65535, 65535, 65535, 1608, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7759, 1927, 7760, 7761, 7762, 8631, 2340, 65535, 7763, 65535, 65535, + 65535, 5973, 4100, 65535, 3168, 7764, 7766, 7765, 65535, 7767, 65535, + 65535, 65535, 65535, 7768, 65535, 65535, 7769, 65535, 65535, 65535, 65535, + 65535, 65535, 7770, 65535, 65535, 65535, 65535, 7771, 65535, 7772, 7773, + 65535, 7774, 65535, 7775, 7776, 7777, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7778, 7779, 65535, 65535, 65535, 65535, 65535, + 3387, 65535, 65535, 65535, 65535, 2222, 65535, 7781, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3052, 7782, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7783, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3760, 65535, 65535, 7784, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7785, 6226, 65535, 65535, 7107, + 7502, 65535, 65535, 7786, 65535, 7787, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7789, 7790, 7791, 4309, 7788, 65535, + 65535, 7792, 7793, 65535, 65535, 7795, 65535, 7794, 65535, 65535, 65535, + 65535, 65535, 7797, 65535, 65535, 65535, 7798, 7796, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4251, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7799, 65535, 65535, 65535, 65535, 65535, + 65535, 7800, 6255, 65535, 65535, 7801, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 8403, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 8600, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 8323, 8334, 8335, 8356, 8395, 8411, 8413, 8456, 8462, 8485, + 8493, 8494, 8495, 8497, 8501, 8504, 8513, 8524, 8526, 8527, 8536, 8544, + 8546, 8547, 8550, 8578, 8585, 8601, 8613, 8614, 8616, 8629, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 9, 8647, 83, 79, 82, 84, + 8646, 41, 42, 85, 59, 3, 60, 4, 30, 203, 204, 205, 206, 207, 208, 209, 210, + 211, 212, 6, 7, 66, 64, 67, 8, 86, 220, 221, 222, 223, 224, 225, 226, 227, + 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 45, 31, 46, 15, 17, 13, 252, 253, 254, 255, 256, 257, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 274, 275, 276, 277, 47, 34, 48, 32, 65535, 80, 81, 137, 16, 8645, 78, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 64, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 160, 192, 0, 224, 256, 288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 320, 352, 0, 0, 0, 0, 0, 0, 384, 416, 0, + 448, 480, 0, 512, 0, 544, 576, 608, 640, 672, 704, 0, 0, 736, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 768, 0, 0, 0, 0, 800, 832, 864, 0, 0, 896, 928, 960, 992, + 0, 1024, 1056, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1088, 0, 1120, 1152, 1184, 1216, 1248, 1280, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1312, 0, 0, 0, 1344, 0, 0, 1376, 1408, 1440, 1472, 1504, + 1536, 1568, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1600, 1632, 1664, 1696, 1728, 1760, + 1792, 1824, 1856, 1888, 1920, 1952, 1984, 2016, 2048, 2080, 2112, 2144, + 2176, 2208, 2240, 2272, 2304, 2336, 2368, 2400, 2432, 2464, 2496, 2528, + 2560, 2592, 2624, 2656, 2688, 2720, 2752, 2784, 2816, 2848, 2880, 2912, + 2944, 2976, 3008, 3040, 3072, 3104, 3136, 3168, 3200, 3232, 3264, 3296, + 3328, 3360, 3392, 3424, 3456, 3488, 3520, 3552, 3584, 3616, 3648, 3680, + 3712, 3744, 3776, 3808, 3840, 3872, 3904, 3936, 3968, 4000, 4032, 4064, + 4096, 4128, 4160, 4192, 4224, 4256, 4288, 4320, 4352, 4384, 4416, 4448, + 4480, 4512, 4544, 4576, 4608, 4640, 4672, 4704, 4736, 4768, 4800, 4832, + 4864, 4896, 4928, 4960, 4992, 5024, 5056, 5088, 5120, 5152, 5184, 5216, + 5248, 5280, 5312, 5344, 5376, 5408, 5440, 5472, 5504, 5536, 5568, 5600, + 5632, 5664, 5696, 5728, 5760, 5792, 5824, 5856, 5888, 5920, 5952, 5984, + 6016, 6048, 6080, 6112, 6144, 6176, 6208, 6240, 6272, 6304, 6336, 6368, + 6400, 6432, 6464, 6496, 6528, 6560, 6592, 6624, 6656, 6688, 6720, 6752, + 6784, 6816, 6848, 6880, 6912, 6944, 6976, 7008, 7040, 7072, 7104, 7136, + 7168, 7200, 7232, 7264, 7296, 7328, 7360, 7392, 7424, 7456, 7488, 7520, + 7552, 7584, 7616, 7648, 7680, 7712, 7744, 7776, 7808, 7840, 7872, 7904, + 7936, 7968, 8000, 8032, 8064, 8096, 8128, 8160, 8192, 8224, 8256, 8288, + 8320, 8352, 8384, 8416, 8448, 8480, 8512, 8544, 8576, 8608, 8640, 8672, + 8704, 8736, 8768, 8800, 8832, 8864, 8896, 8928, 8960, 8992, 9024, 9056, + 9088, 9120, 9152, 9184, 9216, 9248, 9280, 9312, 9344, 9376, 9408, 9440, + 9472, 9504, 9536, 9568, 9600, 9632, 9664, 9696, 9728, 9760, 9792, 9824, + 9856, 9888, 9920, 9952, 9984, 10016, 10048, 10080, 10112, 10144, 10176, + 10208, 10240, 10272, 10304, 10336, 10368, 10400, 10432, 10464, 10496, + 10528, 10560, 10592, 10624, 10656, 10688, 10720, 10752, 10784, 10816, + 10848, 10880, 10912, 10944, 10976, 11008, 11040, 11072, 11104, 11136, + 11168, 11200, 11232, 11264, 11296, 11328, 11360, 11392, 11424, 11456, + 11488, 11520, 11552, 11584, 11616, 11648, 11680, 11712, 11744, 11776, + 11808, 11840, 11872, 11904, 11936, 11968, 12000, 12032, 12064, 12096, + 12128, 12160, 12192, 12224, 12256, 12288, 12320, 12352, 12384, 12416, + 12448, 12480, 12512, 12544, 12576, 12608, 12640, 12672, 12704, 12736, + 12768, 12800, 12832, 12864, 12896, 12928, 12960, 12992, 13024, 13056, + 13088, 13120, 13152, 13184, 13216, 13248, 13280, 13312, 13344, 13376, + 13408, 13440, 13472, 13504, 13536, 13568, 13600, 13632, 13664, 13696, + 13728, 13760, 13792, 13824, 13856, 13888, 13920, 13952, 13984, 14016, 0, 0, + 0, 0, 14048, 14080, 14112, 14144, 14176, 14208, 14240, 14272, 14304, 14336, + 14368, 14400, 14432, 14464, 14496, 14528, 14560, 14592, 14624, 14656, + 14688, 14720, 14752, 14784, 14816, 14848, 14880, 14912, 14944, 14976, + 15008, 15040, 15072, 15104, 15136, 15168, 15200, 15232, 15264, 15296, + 15328, 15360, 15392, 15424, 15456, 15488, 15520, 15552, 15584, 15616, + 15648, 15680, 15712, 15744, 15776, 15808, 15840, 15872, 15904, 15936, + 15968, 16000, 16032, 16064, 16096, 16128, 16160, 16192, 16224, 16256, + 16288, 16320, 16352, 16384, 16416, 16448, 16480, 16512, 16544, 16576, + 16608, 16640, 16672, 16704, 16736, 16768, 16800, 16832, 16864, 16896, + 16928, 16960, 16992, 17024, 17056, 17088, 17120, 17152, 17184, 17216, 0, 0, + 0, 0, 17248, 17280, 17312, 17344, 17376, 17408, 17440, 17472, 0, 0, 17504, + 17536, 17568, 17600, 17632, 17664, 17696, 17728, 17760, 17792, 17824, + 17856, 17888, 17920, 17952, 17984, 18016, 18048, 18080, 18112, 18144, + 18176, 18208, 18240, 18272, 18304, 18336, 18368, 18400, 18432, 18464, + 18496, 18528, 18560, 18592, 18624, 18656, 18688, 18720, 18752, 18784, + 18816, 18848, 18880, 18912, 18944, 18976, 19008, 19040, 19072, 19104, + 19136, 19168, 19200, 19232, 19264, 19296, 19328, 0, 0, 0, 0, 0, 0, 19360, + 19392, 19424, 19456, 19488, 19520, 19552, 19584, 19616, 19648, 19680, + 19712, 19744, 19776, 19808, 19840, 19872, 19904, 19936, 19968, 20000, + 20032, 20064, 20096, 20128, 0, 20160, 20192, 20224, 20256, 20288, 20320, 0, + 20352, 20384, 20416, 20448, 20480, 20512, 20544, 20576, 0, 20608, 20640, + 20672, 20704, 20736, 20768, 20800, 20832, 20864, 20896, 20928, 20960, + 20992, 21024, 21056, 0, 0, 0, 21088, 21120, 21152, 21184, 21216, 21248, + 21280, 21312, 21344, 21376, 0, 0, 21408, 21440, 21472, 21504, 21536, 21568, + 21600, 21632, 21664, 21696, 21728, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 21760, 0, 0, 0, 0, 21792, 0, 21824, 21856, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 21888, 21920, 21952, 0, 0, 0, 0, 21984, +]; + +static BACKWARD_TABLE_REMAPPED: &'static [u16] = &[ + 10744, 10745, 10746, 10747, 10748, 10749, 10750, 10751, 10752, 10753, + 10754, 10755, 10756, 10757, 10758, 10759, 10760, 10761, 10762, 10763, + 10764, 10765, 10766, 10767, 10768, 10769, 10770, 10771, 10772, 10773, + 10774, 10775, 10776, 10777, 10778, 10779, 10780, 10781, 10782, 10783, + 10784, 10785, 10786, 10787, 10788, 10789, 10790, 10791, 10792, 10793, + 10794, 10795, 10796, 10797, 10798, 10799, 10800, 10801, 10802, 10803, + 10804, 10805, 10806, 10807, 10808, 10809, 10810, 10811, 10812, 10813, + 10814, 10815, 10816, 10817, 10818, 10819, 10820, 10821, 10822, 10823, + 10824, 10825, 10826, 10827, 10828, 10829, 10830, 10831, 10832, 10833, + 10834, 10835, 10836, 10837, 10838, 10839, 10840, 10841, 10842, 10843, + 10844, 10845, 10846, 10847, 10848, 10849, 10850, 10851, 10852, 10853, + 10854, 10855, 10856, 10857, 10858, 10859, 10860, 10861, 10862, 10863, + 10864, 10865, 10866, 10867, 10868, 10869, 10870, 10871, 10872, 10873, + 10874, 10875, 10876, 10877, 10878, 10879, 10880, 10881, 10882, 10883, + 10884, 10885, 10886, 10887, 10888, 10889, 10890, 10891, 10892, 10893, + 10894, 10895, 10896, 10897, 10898, 10899, 10900, 10901, 10902, 10903, + 10904, 10905, 10906, 10907, 10908, 10909, 10910, 10911, 10912, 10913, + 10914, 10915, 10916, 10917, 10918, 10919, 10920, 10921, 10922, 10923, + 10924, 10925, 10926, 10927, 10928, 10929, 10930, 10931, 10932, 10933, + 10934, 10935, 10936, 10937, 10938, 10939, 10940, 10941, 10942, 10943, + 10944, 10945, 10946, 10947, 10948, 10949, 10950, 10951, 10952, 10953, + 10954, 10955, 10956, 10957, 10958, 10959, 10960, 10961, 10962, 10963, + 10964, 10965, 10966, 10967, 10968, 10969, 10970, 10971, 10972, 10973, + 10974, 10975, 10976, 10977, 10978, 10979, 10980, 10981, 10982, 10983, + 10984, 10985, 10986, 10987, 10988, 10989, 10990, 10991, 10992, 10993, + 10994, 10995, 10996, 10997, 10998, 10999, 11000, 11001, 11002, 11003, + 11004, 11005, 11006, 11007, 11008, 11009, 11010, 11011, 11012, 11013, + 11014, 11015, 11016, 11017, 11018, 11019, 11020, 11021, 11022, 11023, + 11024, 11025, 11026, 11027, 11028, 11029, 11030, 11031, 11032, 11033, + 11034, 11035, 11036, 11037, 11038, 11039, 11040, 11041, 11042, 11043, + 11044, 11045, 11046, 11047, 11048, 11049, 11050, 11051, 11052, 11053, + 11054, 11055, 11056, 11057, 11058, 11059, 11060, 11061, 11062, 11063, + 11064, 11065, 11066, 11067, 11068, 11069, 11070, 11071, 11072, 11073, + 11074, 11075, 11076, 11077, 11078, 11079, 11080, 11081, 11082, 11083, + 11084, 11085, 11086, 11087, 11088, 11089, 11090, 11091, 11092, 11093, + 11094, 11095, 11096, 11097, 11098, 11099, 11100, 11101, 11102, 11103, + 65535, 65535, 10716, 10717, 10718, 10719, 10720, 10721, 10722, 10723, + 10724, 10725, 137, 10737, 10738, 10739, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u16 { + let offset = (code >> 5) as usize; + let offset = if offset < 2048 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +/// Returns the index shift_jis pointer for code point `code`. +#[inline] +pub fn backward_remapped(code: u32) -> u16 { + let value = backward(code); + if 8272 <= value && value <= 8835 { + BACKWARD_TABLE_REMAPPED[(value - 8272) as usize] + } else { + value + } +} + +#[cfg(test)] +multi_byte_tests!( + mod = jis0208, + remap = [8272, 8835], + dups = [ + 1207, 1208, 1209, 1212, 1213, 1214, 1217, 1218, 1219, 8644, 10716, + 10717, 10718, 10719, 10720, 10721, 10722, 10723, 10724, 10725, 10726, + 10727, 10728, 10729, 10730, 10731, 10732, 10733, 10734, 10735, 10736, + 10737, 10738, 10739, 10740, 10741, 10742, 10743, 10744, 10745, 10746, + 10747, 10748, 10749, 10750, 10751, 10752, 10753, 10754, 10755, 10756, + 10757, 10758, 10759, 10760, 10761, 10762, 10763, 10764, 10765, 10766, + 10767, 10768, 10769, 10770, 10771, 10772, 10773, 10774, 10775, 10776, + 10777, 10778, 10779, 10780, 10781, 10782, 10783, 10784, 10785, 10786, + 10787, 10788, 10789, 10790, 10791, 10792, 10793, 10794, 10795, 10796, + 10797, 10798, 10799, 10800, 10801, 10802, 10803, 10804, 10805, 10806, + 10807, 10808, 10809, 10810, 10811, 10812, 10813, 10814, 10815, 10816, + 10817, 10818, 10819, 10820, 10821, 10822, 10823, 10824, 10825, 10826, + 10827, 10828, 10829, 10830, 10831, 10832, 10833, 10834, 10835, 10836, + 10837, 10838, 10839, 10840, 10841, 10842, 10843, 10844, 10845, 10846, + 10847, 10848, 10849, 10850, 10851, 10852, 10853, 10854, 10855, 10856, + 10857, 10858, 10859, 10860, 10861, 10862, 10863, 10864, 10865, 10866, + 10867, 10868, 10869, 10870, 10871, 10872, 10873, 10874, 10875, 10876, + 10877, 10878, 10879, 10880, 10881, 10882, 10883, 10884, 10885, 10886, + 10887, 10888, 10889, 10890, 10891, 10892, 10893, 10894, 10895, 10896, + 10897, 10898, 10899, 10900, 10901, 10902, 10903, 10904, 10905, 10906, + 10907, 10908, 10909, 10910, 10911, 10912, 10913, 10914, 10915, 10916, + 10917, 10918, 10919, 10920, 10921, 10922, 10923, 10924, 10925, 10926, + 10927, 10928, 10929, 10930, 10931, 10932, 10933, 10934, 10935, 10936, + 10937, 10938, 10939, 10940, 10941, 10942, 10943, 10944, 10945, 10946, + 10947, 10948, 10949, 10950, 10951, 10952, 10953, 10954, 10955, 10956, + 10957, 10958, 10959, 10960, 10961, 10962, 10963, 10964, 10965, 10966, + 10967, 10968, 10969, 10970, 10971, 10972, 10973, 10974, 10975, 10976, + 10977, 10978, 10979, 10980, 10981, 10982, 10983, 10984, 10985, 10986, + 10987, 10988, 10989, 10990, 10991, 10992, 10993, 10994, 10995, 10996, + 10997, 10998, 10999, 11000, 11001, 11002, 11003, 11004, 11005, 11006, + 11007, 11008, 11009, 11010, 11011, 11012, 11013, 11014, 11015, 11016, + 11017, 11018, 11019, 11020, 11021, 11022, 11023, 11024, 11025, 11026, + 11027, 11028, 11029, 11030, 11031, 11032, 11033, 11034, 11035, 11036, + 11037, 11038, 11039, 11040, 11041, 11042, 11043, 11044, 11045, 11046, + 11047, 11048, 11049, 11050, 11051, 11052, 11053, 11054, 11055, 11056, + 11057, 11058, 11059, 11060, 11061, 11062, 11063, 11064, 11065, 11066, + 11067, 11068, 11069, 11070, 11071, 11072, 11073, 11074, 11075, 11076, + 11077, 11078, 11079, 11080, 11081, 11082, 11083, 11084, 11085, 11086, + 11087, 11088, 11089, 11090, 11091, 11092, 11093, 11094, 11095, 11096, + 11097, 11098, 11099, 11100, 11101, 11102, 11103, + ] +); diff --git a/deps/encoding-index-japanese-1.20141219.5/jis0212.rs b/deps/encoding-index-japanese-1.20141219.5/jis0212.rs new file mode 100644 index 000000000..378c5e147 --- /dev/null +++ b/deps/encoding-index-japanese-1.20141219.5/jis0212.rs @@ -0,0 +1,2764 @@ +// AUTOGENERATED FROM index-jis0212.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-jis0212.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 83bf90dd1c591a4355730d8c4567efc499d74da7490531019ef22a879991cfb7 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 728, 711, 184, 729, 733, 175, 731, 730, 65374, 900, 901, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 161, 166, 191, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 186, 170, 169, 174, 8482, 164, + 8470, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 902, 904, + 905, 906, 938, 65535, 908, 65535, 910, 939, 65535, 911, 65535, 65535, + 65535, 65535, 940, 941, 942, 943, 970, 912, 972, 962, 973, 971, 944, 974, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1026, 1027, 1028, 1029, 1030, 1031, + 1032, 1033, 1034, 1035, 1036, 1038, 1039, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, + 1118, 1119, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 198, 272, 65535, 294, 65535, 306, 65535, + 321, 319, 65535, 330, 216, 338, 65535, 358, 222, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 230, 273, 240, 295, 305, 307, 312, 322, 320, 329, 331, + 248, 339, 223, 359, 254, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 193, 192, + 196, 194, 258, 461, 256, 260, 197, 195, 262, 264, 268, 199, 266, 270, 201, + 200, 203, 202, 282, 278, 274, 280, 65535, 284, 286, 290, 288, 292, 205, + 204, 207, 206, 463, 304, 298, 302, 296, 308, 310, 313, 317, 315, 323, 327, + 325, 209, 211, 210, 214, 212, 465, 336, 332, 213, 340, 344, 342, 346, 348, + 352, 350, 356, 354, 218, 217, 220, 219, 364, 467, 368, 362, 370, 366, 360, + 471, 475, 473, 469, 372, 221, 376, 374, 377, 381, 379, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 225, 224, 228, 226, 259, 462, 257, 261, 229, + 227, 263, 265, 269, 231, 267, 271, 233, 232, 235, 234, 283, 279, 275, 281, + 501, 285, 287, 65535, 289, 293, 237, 236, 239, 238, 464, 65535, 299, 303, + 297, 309, 311, 314, 318, 316, 324, 328, 326, 241, 243, 242, 246, 244, 466, + 337, 333, 245, 341, 345, 343, 347, 349, 353, 351, 357, 355, 250, 249, 252, + 251, 365, 468, 369, 363, 371, 367, 361, 472, 476, 474, 470, 373, 253, 255, + 375, 378, 382, 380, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19970, 19972, 19973, 19980, 19986, + 19999, 20003, 20004, 20008, 20011, 20014, 20015, 20016, 20021, 20032, + 20033, 20036, 20039, 20049, 20058, 20060, 20067, 20072, 20073, 20084, + 20085, 20089, 20095, 20109, 20118, 20119, 20125, 20143, 20153, 20163, + 20176, 20186, 20187, 20192, 20193, 20194, 20200, 20207, 20209, 20211, + 20213, 20221, 20222, 20223, 20224, 20226, 20227, 20232, 20235, 20236, + 20242, 20245, 20246, 20247, 20249, 20270, 20273, 20320, 20275, 20277, + 20279, 20281, 20283, 20286, 20288, 20290, 20296, 20297, 20299, 20300, + 20306, 20308, 20310, 20312, 20319, 20323, 20330, 20332, 20334, 20337, + 20343, 20344, 20345, 20346, 20349, 20350, 20353, 20354, 20356, 20357, + 20361, 20362, 20364, 20366, 20368, 20370, 20371, 20372, 20375, 20377, + 20378, 20382, 20383, 20402, 20407, 20409, 20411, 20412, 20413, 20414, + 20416, 20417, 20421, 20422, 20424, 20425, 20427, 20428, 20429, 20431, + 20434, 20444, 20448, 20450, 20464, 20466, 20476, 20477, 20479, 20480, + 20481, 20484, 20487, 20490, 20492, 20494, 20496, 20499, 20503, 20504, + 20507, 20508, 20509, 20510, 20514, 20519, 20526, 20528, 20530, 20531, + 20533, 20544, 20545, 20546, 20549, 20550, 20554, 20556, 20558, 20561, + 20562, 20563, 20567, 20569, 20575, 20576, 20578, 20579, 20582, 20583, + 20586, 20589, 20592, 20593, 20539, 20609, 20611, 20612, 20614, 20618, + 20622, 20623, 20624, 20626, 20627, 20628, 20630, 20635, 20636, 20638, + 20639, 20640, 20641, 20642, 20650, 20655, 20656, 20665, 20666, 20669, + 20672, 20675, 20676, 20679, 20684, 20686, 20688, 20691, 20692, 20696, + 20700, 20701, 20703, 20706, 20708, 20710, 20712, 20713, 20719, 20721, + 20726, 20730, 20734, 20739, 20742, 20743, 20744, 20747, 20748, 20749, + 20750, 20722, 20752, 20759, 20761, 20763, 20764, 20765, 20766, 20771, + 20775, 20776, 20780, 20781, 20783, 20785, 20787, 20788, 20789, 20792, + 20793, 20802, 20810, 20815, 20819, 20821, 20823, 20824, 20831, 20836, + 20838, 20862, 20867, 20868, 20875, 20878, 20888, 20893, 20897, 20899, + 20909, 20920, 20922, 20924, 20926, 20927, 20930, 20936, 20943, 20945, + 20946, 20947, 20949, 20952, 20958, 20962, 20965, 20974, 20978, 20979, + 20980, 20983, 20993, 20994, 20997, 21010, 21011, 21013, 21014, 21016, + 21026, 21032, 21041, 21042, 21045, 21052, 21061, 21065, 21077, 21079, + 21080, 21082, 21084, 21087, 21088, 21089, 21094, 21102, 21111, 21112, + 21113, 21120, 21122, 21125, 21130, 21132, 21139, 21141, 21142, 21143, + 21144, 21146, 21148, 21156, 21157, 21158, 21159, 21167, 21168, 21174, + 21175, 21176, 21178, 21179, 21181, 21184, 21188, 21190, 21192, 21196, + 21199, 21201, 21204, 21206, 21211, 21212, 21217, 21221, 21224, 21225, + 21226, 21228, 21232, 21233, 21236, 21238, 21239, 21248, 21251, 21258, + 21259, 21260, 21265, 21267, 21272, 21275, 21276, 21278, 21279, 21285, + 21287, 21288, 21289, 21291, 21292, 21293, 21296, 21298, 21301, 21308, + 21309, 21310, 21314, 21324, 21323, 21337, 21339, 21345, 21347, 21349, + 21356, 21357, 21362, 21369, 21374, 21379, 21383, 21384, 21390, 21395, + 21396, 21401, 21405, 21409, 21412, 21418, 21419, 21423, 21426, 21428, + 21429, 21431, 21432, 21434, 21437, 21440, 21445, 21455, 21458, 21459, + 21461, 21466, 21469, 21470, 21472, 21478, 21479, 21493, 21506, 21523, + 21530, 21537, 21543, 21544, 21546, 21551, 21553, 21556, 21557, 21571, + 21572, 21575, 21581, 21583, 21598, 21602, 21604, 21606, 21607, 21609, + 21611, 21613, 21614, 21620, 21631, 21633, 21635, 21637, 21640, 21641, + 21645, 21649, 21653, 21654, 21660, 21663, 21665, 21670, 21671, 21673, + 21674, 21677, 21678, 21681, 21687, 21689, 21690, 21691, 21695, 21702, + 21706, 21709, 21710, 21728, 21738, 21740, 21743, 21750, 21756, 21758, + 21759, 21760, 21761, 21765, 21768, 21769, 21772, 21773, 21774, 21781, + 21802, 21803, 21810, 21813, 21814, 21819, 21820, 21821, 21825, 21831, + 21833, 21834, 21837, 21840, 21841, 21848, 21850, 21851, 21854, 21856, + 21857, 21860, 21862, 21887, 21889, 21890, 21894, 21896, 21902, 21903, + 21905, 21906, 21907, 21908, 21911, 21923, 21924, 21933, 21938, 21951, + 21953, 21955, 21958, 21961, 21963, 21964, 21966, 21969, 21970, 21971, + 21975, 21976, 21979, 21982, 21986, 21993, 22006, 22015, 22021, 22024, + 22026, 22029, 22030, 22031, 22032, 22033, 22034, 22041, 22060, 22064, + 22067, 22069, 22071, 22073, 22075, 22076, 22077, 22079, 22080, 22081, + 22083, 22084, 22086, 22089, 22091, 22093, 22095, 22100, 22110, 22112, + 22113, 22114, 22115, 22118, 22121, 22125, 22127, 22129, 22130, 22133, + 22148, 22149, 22152, 22155, 22156, 22165, 22169, 22170, 22173, 22174, + 22175, 22182, 22183, 22184, 22185, 22187, 22188, 22189, 22193, 22195, + 22199, 22206, 22213, 22217, 22218, 22219, 22223, 22224, 22220, 22221, + 22233, 22236, 22237, 22239, 22241, 22244, 22245, 22246, 22247, 22248, + 22257, 22251, 22253, 22262, 22263, 22273, 22274, 22279, 22282, 22284, + 22289, 22293, 22298, 22299, 22301, 22304, 22306, 22307, 22308, 22309, + 22313, 22314, 22316, 22318, 22319, 22323, 22324, 22333, 22334, 22335, + 22341, 22342, 22348, 22349, 22354, 22370, 22373, 22375, 22376, 22379, + 22381, 22382, 22383, 22384, 22385, 22387, 22388, 22389, 22391, 22393, + 22394, 22395, 22396, 22398, 22401, 22403, 22412, 22420, 22423, 22425, + 22426, 22428, 22429, 22430, 22431, 22433, 22421, 22439, 22440, 22441, + 22444, 22456, 22461, 22471, 22472, 22476, 22479, 22485, 22493, 22494, + 22500, 22502, 22503, 22505, 22509, 22512, 22517, 22518, 22520, 22525, + 22526, 22527, 22531, 22532, 22536, 22537, 22497, 22540, 22541, 22555, + 22558, 22559, 22560, 22566, 22567, 22573, 22578, 22585, 22591, 22601, + 22604, 22605, 22607, 22608, 22613, 22623, 22625, 22628, 22631, 22632, + 22648, 22652, 22655, 22656, 22657, 22663, 22664, 22665, 22666, 22668, + 22669, 22671, 22672, 22676, 22678, 22685, 22688, 22689, 22690, 22694, + 22697, 22705, 22706, 22724, 22716, 22722, 22728, 22733, 22734, 22736, + 22738, 22740, 22742, 22746, 22749, 22753, 22754, 22761, 22771, 22789, + 22790, 22795, 22796, 22802, 22803, 22804, 34369, 22813, 22817, 22819, + 22820, 22824, 22831, 22832, 22835, 22837, 22838, 22847, 22851, 22854, + 22866, 22867, 22873, 22875, 22877, 22878, 22879, 22881, 22883, 22891, + 22893, 22895, 22898, 22901, 22902, 22905, 22907, 22908, 22923, 22924, + 22926, 22930, 22933, 22935, 22943, 22948, 22951, 22957, 22958, 22959, + 22960, 22963, 22967, 22970, 22972, 22977, 22979, 22980, 22984, 22986, + 22989, 22994, 23005, 23006, 23007, 23011, 23012, 23015, 23022, 23023, + 23025, 23026, 23028, 23031, 23040, 23044, 23052, 23053, 23054, 23058, + 23059, 23070, 23075, 23076, 23079, 23080, 23082, 23085, 23088, 23108, + 23109, 23111, 23112, 23116, 23120, 23125, 23134, 23139, 23141, 23143, + 23149, 23159, 23162, 23163, 23166, 23179, 23184, 23187, 23190, 23193, + 23196, 23198, 23199, 23200, 23202, 23207, 23212, 23217, 23218, 23219, + 23221, 23224, 23226, 23227, 23231, 23236, 23238, 23240, 23247, 23258, + 23260, 23264, 23269, 23274, 23278, 23285, 23286, 23293, 23296, 23297, + 23304, 23319, 23348, 23321, 23323, 23325, 23329, 23333, 23341, 23352, + 23361, 23371, 23372, 23378, 23382, 23390, 23400, 23406, 23407, 23420, + 23421, 23422, 23423, 23425, 23428, 23430, 23434, 23438, 23440, 23441, + 23443, 23444, 23446, 23464, 23465, 23468, 23469, 23471, 23473, 23474, + 23479, 23482, 23484, 23488, 23489, 23501, 23503, 23510, 23511, 23512, + 23513, 23514, 23520, 23535, 23537, 23540, 23549, 23564, 23575, 23582, + 23583, 23587, 23590, 23593, 23595, 23596, 23598, 23600, 23602, 23605, + 23606, 23641, 23642, 23644, 23650, 23651, 23655, 23656, 23657, 23661, + 23664, 23668, 23669, 23674, 23675, 23676, 23677, 23687, 23688, 23690, + 23695, 23698, 23709, 23711, 23712, 23714, 23715, 23718, 23722, 23730, + 23732, 23733, 23738, 23753, 23755, 23762, 23773, 23767, 23790, 23793, + 23794, 23796, 23809, 23814, 23821, 23826, 23851, 23843, 23844, 23846, + 23847, 23857, 23860, 23865, 23869, 23871, 23874, 23875, 23878, 23880, + 23893, 23889, 23897, 23882, 23903, 23904, 23905, 23906, 23908, 23914, + 23917, 23920, 23929, 23930, 23934, 23935, 23937, 23939, 23944, 23946, + 23954, 23955, 23956, 23957, 23961, 23963, 23967, 23968, 23975, 23979, + 23984, 23988, 23992, 23993, 24003, 24007, 24011, 24016, 24014, 24024, + 24025, 24032, 24036, 24041, 24056, 24057, 24064, 24071, 24077, 24082, + 24084, 24085, 24088, 24095, 24096, 24110, 24104, 24114, 24117, 24126, + 24139, 24144, 24137, 24145, 24150, 24152, 24155, 24156, 24158, 24168, + 24170, 24171, 24172, 24173, 24174, 24176, 24192, 24203, 24206, 24226, + 24228, 24229, 24232, 24234, 24236, 24241, 24243, 24253, 24254, 24255, + 24262, 24268, 24267, 24270, 24273, 24274, 24276, 24277, 24284, 24286, + 24293, 24299, 24322, 24326, 24327, 24328, 24334, 24345, 24348, 24349, + 24353, 24354, 24355, 24356, 24360, 24363, 24364, 24366, 24368, 24372, + 24374, 24379, 24381, 24383, 24384, 24388, 24389, 24391, 24397, 24400, + 24404, 24408, 24411, 24416, 24419, 24420, 24423, 24431, 24434, 24436, + 24437, 24440, 24442, 24445, 24446, 24457, 24461, 24463, 24470, 24476, + 24477, 24482, 24487, 24491, 24484, 24492, 24495, 24496, 24497, 24504, + 24516, 24519, 24520, 24521, 24523, 24528, 24529, 24530, 24531, 24532, + 24542, 24545, 24546, 24552, 24553, 24554, 24556, 24557, 24558, 24559, + 24562, 24563, 24566, 24570, 24572, 24583, 24586, 24589, 24595, 24596, + 24599, 24600, 24602, 24607, 24612, 24621, 24627, 24629, 24640, 24647, + 24648, 24649, 24652, 24657, 24660, 24662, 24663, 24669, 24673, 24679, + 24689, 24702, 24703, 24706, 24710, 24712, 24714, 24718, 24721, 24723, + 24725, 24728, 24733, 24734, 24738, 24740, 24741, 24744, 24752, 24753, + 24759, 24763, 24766, 24770, 24772, 24776, 24777, 24778, 24779, 24782, + 24783, 24788, 24789, 24793, 24795, 24797, 24798, 24802, 24805, 24818, + 24821, 24824, 24828, 24829, 24834, 24839, 24842, 24844, 24848, 24849, + 24850, 24851, 24852, 24854, 24855, 24857, 24860, 24862, 24866, 24874, + 24875, 24880, 24881, 24885, 24886, 24887, 24889, 24897, 24901, 24902, + 24905, 24926, 24928, 24940, 24946, 24952, 24955, 24956, 24959, 24960, + 24961, 24963, 24964, 24971, 24973, 24978, 24979, 24983, 24984, 24988, + 24989, 24991, 24992, 24997, 25000, 25002, 25005, 25016, 25017, 25020, + 25024, 25025, 25026, 25038, 25039, 25045, 25052, 25053, 25054, 25055, + 25057, 25058, 25063, 25065, 25061, 25068, 25069, 25071, 25089, 25091, + 25092, 25095, 25107, 25109, 25116, 25120, 25122, 25123, 25127, 25129, + 25131, 25145, 25149, 25154, 25155, 25156, 25158, 25164, 25168, 25169, + 25170, 25172, 25174, 25178, 25180, 25188, 25197, 25199, 25203, 25210, + 25213, 25229, 25230, 25231, 25232, 25254, 25256, 25267, 25270, 25271, + 25274, 25278, 25279, 25284, 25294, 25301, 25302, 25306, 25322, 25330, + 25332, 25340, 25341, 25347, 25348, 25354, 25355, 25357, 25360, 25363, + 25366, 25368, 25385, 25386, 25389, 25397, 25398, 25401, 25404, 25409, + 25410, 25411, 25412, 25414, 25418, 25419, 25422, 25426, 25427, 25428, + 25432, 25435, 25445, 25446, 25452, 25453, 25457, 25460, 25461, 25464, + 25468, 25469, 25471, 25474, 25476, 25479, 25482, 25488, 25492, 25493, + 25497, 25498, 25502, 25508, 25510, 25517, 25518, 25519, 25533, 25537, + 25541, 25544, 25550, 25553, 25555, 25556, 25557, 25564, 25568, 25573, + 25578, 25580, 25586, 25587, 25589, 25592, 25593, 25609, 25610, 25616, + 25618, 25620, 25624, 25630, 25632, 25634, 25636, 25637, 25641, 25642, + 25647, 25648, 25653, 25661, 25663, 25675, 25679, 25681, 25682, 25683, + 25684, 25690, 25691, 25692, 25693, 25695, 25696, 25697, 25699, 25709, + 25715, 25716, 25723, 25725, 25733, 25735, 25743, 25744, 25745, 25752, + 25753, 25755, 25757, 25759, 25761, 25763, 25766, 25768, 25772, 25779, + 25789, 25790, 25791, 25796, 25801, 25802, 25803, 25804, 25806, 25808, + 25809, 25813, 25815, 25828, 25829, 25833, 25834, 25837, 25840, 25845, + 25847, 25851, 25855, 25857, 25860, 25864, 25865, 25866, 25871, 25875, + 25876, 25878, 25881, 25883, 25886, 25887, 25890, 25894, 25897, 25902, + 25905, 25914, 25916, 25917, 25923, 25927, 25929, 25936, 25938, 25940, + 25951, 25952, 25959, 25963, 25978, 25981, 25985, 25989, 25994, 26002, + 26005, 26008, 26013, 26016, 26019, 26022, 26030, 26034, 26035, 26036, + 26047, 26050, 26056, 26057, 26062, 26064, 26068, 26070, 26072, 26079, + 26096, 26098, 26100, 26101, 26105, 26110, 26111, 26112, 26116, 26120, + 26121, 26125, 26129, 26130, 26133, 26134, 26141, 26142, 26145, 26146, + 26147, 26148, 26150, 26153, 26154, 26155, 26156, 26158, 26160, 26161, + 26163, 26169, 26167, 26176, 26181, 26182, 26186, 26188, 26193, 26190, + 26199, 26200, 26201, 26203, 26204, 26208, 26209, 26363, 26218, 26219, + 26220, 26238, 26227, 26229, 26239, 26231, 26232, 26233, 26235, 26240, + 26236, 26251, 26252, 26253, 26256, 26258, 26265, 26266, 26267, 26268, + 26271, 26272, 26276, 26285, 26289, 26290, 26293, 26299, 26303, 26304, + 26306, 26307, 26312, 26316, 26318, 26319, 26324, 26331, 26335, 26344, + 26347, 26348, 26350, 26362, 26373, 26375, 26382, 26387, 26393, 26396, + 26400, 26402, 26419, 26430, 26437, 26439, 26440, 26444, 26452, 26453, + 26461, 26470, 26476, 26478, 26484, 26486, 26491, 26497, 26500, 26510, + 26511, 26513, 26515, 26518, 26520, 26521, 26523, 26544, 26545, 26546, + 26549, 26555, 26556, 26557, 26617, 26560, 26562, 26563, 26565, 26568, + 26569, 26578, 26583, 26585, 26588, 26593, 26598, 26608, 26610, 26614, + 26615, 26706, 26644, 26649, 26653, 26655, 26664, 26663, 26668, 26669, + 26671, 26672, 26673, 26675, 26683, 26687, 26692, 26693, 26698, 26700, + 26709, 26711, 26712, 26715, 26731, 26734, 26735, 26736, 26737, 26738, + 26741, 26745, 26746, 26747, 26748, 26754, 26756, 26758, 26760, 26774, + 26776, 26778, 26780, 26785, 26787, 26789, 26793, 26794, 26798, 26802, + 26811, 26821, 26824, 26828, 26831, 26832, 26833, 26835, 26838, 26841, + 26844, 26845, 26853, 26856, 26858, 26859, 26860, 26861, 26864, 26865, + 26869, 26870, 26875, 26876, 26877, 26886, 26889, 26890, 26896, 26897, + 26899, 26902, 26903, 26929, 26931, 26933, 26936, 26939, 26946, 26949, + 26953, 26958, 26967, 26971, 26979, 26980, 26981, 26982, 26984, 26985, + 26988, 26992, 26993, 26994, 27002, 27003, 27007, 27008, 27021, 27026, + 27030, 27032, 27041, 27045, 27046, 27048, 27051, 27053, 27055, 27063, + 27064, 27066, 27068, 27077, 27080, 27089, 27094, 27095, 27106, 27109, + 27118, 27119, 27121, 27123, 27125, 27134, 27136, 27137, 27139, 27151, + 27153, 27157, 27162, 27165, 27168, 27172, 27176, 27184, 27186, 27188, + 27191, 27195, 27198, 27199, 27205, 27206, 27209, 27210, 27214, 27216, + 27217, 27218, 27221, 27222, 27227, 27236, 27239, 27242, 27249, 27251, + 27262, 27265, 27267, 27270, 27271, 27273, 27275, 27281, 27291, 27293, + 27294, 27295, 27301, 27307, 27311, 27312, 27313, 27316, 27325, 27326, + 27327, 27334, 27337, 27336, 27340, 27344, 27348, 27349, 27350, 27356, + 27357, 27364, 27367, 27372, 27376, 27377, 27378, 27388, 27389, 27394, + 27395, 27398, 27399, 27401, 27407, 27408, 27409, 27415, 27419, 27422, + 27428, 27432, 27435, 27436, 27439, 27445, 27446, 27451, 27455, 27462, + 27466, 27469, 27474, 27478, 27480, 27485, 27488, 27495, 27499, 27502, + 27504, 27509, 27517, 27518, 27522, 27525, 27543, 27547, 27551, 27552, + 27554, 27555, 27560, 27561, 27564, 27565, 27566, 27568, 27576, 27577, + 27581, 27582, 27587, 27588, 27593, 27596, 27606, 27610, 27617, 27619, + 27622, 27623, 27630, 27633, 27639, 27641, 27647, 27650, 27652, 27653, + 27657, 27661, 27662, 27664, 27666, 27673, 27679, 27686, 27687, 27688, + 27692, 27694, 27699, 27701, 27702, 27706, 27707, 27711, 27722, 27723, + 27725, 27727, 27730, 27732, 27737, 27739, 27740, 27755, 27757, 27759, + 27764, 27766, 27768, 27769, 27771, 27781, 27782, 27783, 27785, 27796, + 27797, 27799, 27800, 27804, 27807, 27824, 27826, 27828, 27842, 27846, + 27853, 27855, 27856, 27857, 27858, 27860, 27862, 27866, 27868, 27872, + 27879, 27881, 27883, 27884, 27886, 27890, 27892, 27908, 27911, 27914, + 27918, 27919, 27921, 27923, 27930, 27942, 27943, 27944, 27751, 27950, + 27951, 27953, 27961, 27964, 27967, 27991, 27998, 27999, 28001, 28005, + 28007, 28015, 28016, 28028, 28034, 28039, 28049, 28050, 28052, 28054, + 28055, 28056, 28074, 28076, 28084, 28087, 28089, 28093, 28095, 28100, + 28104, 28106, 28110, 28111, 28118, 28123, 28125, 28127, 28128, 28130, + 28133, 28137, 28143, 28144, 28148, 28150, 28156, 28160, 28164, 28190, + 28194, 28199, 28210, 28214, 28217, 28219, 28220, 28228, 28229, 28232, + 28233, 28235, 28239, 28241, 28242, 28243, 28244, 28247, 28252, 28253, + 28254, 28258, 28259, 28264, 28275, 28283, 28285, 28301, 28307, 28313, + 28320, 28327, 28333, 28334, 28337, 28339, 28347, 28351, 28352, 28353, + 28355, 28359, 28360, 28362, 28365, 28366, 28367, 28395, 28397, 28398, + 28409, 28411, 28413, 28420, 28424, 28426, 28428, 28429, 28438, 28440, + 28442, 28443, 28454, 28457, 28458, 28463, 28464, 28467, 28470, 28475, + 28476, 28461, 28495, 28497, 28498, 28499, 28503, 28505, 28506, 28509, + 28510, 28513, 28514, 28520, 28524, 28541, 28542, 28547, 28551, 28552, + 28555, 28556, 28557, 28560, 28562, 28563, 28564, 28566, 28570, 28575, + 28576, 28581, 28582, 28583, 28584, 28590, 28591, 28592, 28597, 28598, + 28604, 28613, 28615, 28616, 28618, 28634, 28638, 28648, 28649, 28656, + 28661, 28665, 28668, 28669, 28672, 28677, 28678, 28679, 28685, 28695, + 28704, 28707, 28719, 28724, 28727, 28729, 28732, 28739, 28740, 28744, + 28745, 28746, 28747, 28756, 28757, 28765, 28766, 28750, 28772, 28773, + 28780, 28782, 28789, 28790, 28798, 28801, 28805, 28806, 28820, 28821, + 28822, 28823, 28824, 28827, 28836, 28843, 28848, 28849, 28852, 28855, + 28874, 28881, 28883, 28884, 28885, 28886, 28888, 28892, 28900, 28922, + 28931, 28932, 28933, 28934, 28935, 28939, 28940, 28943, 28958, 28960, + 28971, 28973, 28975, 28976, 28977, 28984, 28993, 28997, 28998, 28999, + 29002, 29003, 29008, 29010, 29015, 29018, 29020, 29022, 29024, 29032, + 29049, 29056, 29061, 29063, 29068, 29074, 29082, 29083, 29088, 29090, + 29103, 29104, 29106, 29107, 29114, 29119, 29120, 29121, 29124, 29131, + 29132, 29139, 29142, 29145, 29146, 29148, 29176, 29182, 29184, 29191, + 29192, 29193, 29203, 29207, 29210, 29213, 29215, 29220, 29227, 29231, + 29236, 29240, 29241, 29249, 29250, 29251, 29253, 29262, 29263, 29264, + 29267, 29269, 29270, 29274, 29276, 29278, 29280, 29283, 29288, 29291, + 29294, 29295, 29297, 29303, 29304, 29307, 29308, 29311, 29316, 29321, + 29325, 29326, 29331, 29339, 29352, 29357, 29358, 29361, 29364, 29374, + 29377, 29383, 29385, 29388, 29397, 29398, 29400, 29407, 29413, 29427, + 29428, 29434, 29435, 29438, 29442, 29444, 29445, 29447, 29451, 29453, + 29458, 29459, 29464, 29465, 29470, 29474, 29476, 29479, 29480, 29484, + 29489, 29490, 29493, 29498, 29499, 29501, 29507, 29517, 29520, 29522, + 29526, 29528, 29533, 29534, 29535, 29536, 29542, 29543, 29545, 29547, + 29548, 29550, 29551, 29553, 29559, 29561, 29564, 29568, 29569, 29571, + 29573, 29574, 29582, 29584, 29587, 29589, 29591, 29592, 29596, 29598, + 29599, 29600, 29602, 29605, 29606, 29610, 29611, 29613, 29621, 29623, + 29625, 29628, 29629, 29631, 29637, 29638, 29641, 29643, 29644, 29647, + 29650, 29651, 29654, 29657, 29661, 29665, 29667, 29670, 29671, 29673, + 29684, 29685, 29687, 29689, 29690, 29691, 29693, 29695, 29696, 29697, + 29700, 29703, 29706, 29713, 29722, 29723, 29732, 29734, 29736, 29737, + 29738, 29739, 29740, 29741, 29742, 29743, 29744, 29745, 29753, 29760, + 29763, 29764, 29766, 29767, 29771, 29773, 29777, 29778, 29783, 29789, + 29794, 29798, 29799, 29800, 29803, 29805, 29806, 29809, 29810, 29824, + 29825, 29829, 29830, 29831, 29833, 29839, 29840, 29841, 29842, 29848, + 29849, 29850, 29852, 29855, 29856, 29857, 29859, 29862, 29864, 29865, + 29866, 29867, 29870, 29871, 29873, 29874, 29877, 29881, 29883, 29887, + 29896, 29897, 29900, 29904, 29907, 29912, 29914, 29915, 29918, 29919, + 29924, 29928, 29930, 29931, 29935, 29940, 29946, 29947, 29948, 29951, + 29958, 29970, 29974, 29975, 29984, 29985, 29988, 29991, 29993, 29994, + 29999, 30006, 30009, 30013, 30014, 30015, 30016, 30019, 30023, 30024, + 30030, 30032, 30034, 30039, 30046, 30047, 30049, 30063, 30065, 30073, + 30074, 30075, 30076, 30077, 30078, 30081, 30085, 30096, 30098, 30099, + 30101, 30105, 30108, 30114, 30116, 30132, 30138, 30143, 30144, 30145, + 30148, 30150, 30156, 30158, 30159, 30167, 30172, 30175, 30176, 30177, + 30180, 30183, 30188, 30190, 30191, 30193, 30201, 30208, 30210, 30211, + 30212, 30215, 30216, 30218, 30220, 30223, 30226, 30227, 30229, 30230, + 30233, 30235, 30236, 30237, 30238, 30243, 30245, 30246, 30249, 30253, + 30258, 30259, 30261, 30264, 30265, 30266, 30268, 30282, 30272, 30273, + 30275, 30276, 30277, 30281, 30283, 30293, 30297, 30303, 30308, 30309, + 30317, 30318, 30319, 30321, 30324, 30337, 30341, 30348, 30349, 30357, + 30363, 30364, 30365, 30367, 30368, 30370, 30371, 30372, 30373, 30374, + 30375, 30376, 30378, 30381, 30397, 30401, 30405, 30409, 30411, 30412, + 30414, 30420, 30425, 30432, 30438, 30440, 30444, 30448, 30449, 30454, + 30457, 30460, 30464, 30470, 30474, 30478, 30482, 30484, 30485, 30487, + 30489, 30490, 30492, 30498, 30504, 30509, 30510, 30511, 30516, 30517, + 30518, 30521, 30525, 30526, 30530, 30533, 30534, 30538, 30541, 30542, + 30543, 30546, 30550, 30551, 30556, 30558, 30559, 30560, 30562, 30564, + 30567, 30570, 30572, 30576, 30578, 30579, 30580, 30586, 30589, 30592, + 30596, 30604, 30605, 30612, 30613, 30614, 30618, 30623, 30626, 30631, + 30634, 30638, 30639, 30641, 30645, 30654, 30659, 30665, 30673, 30674, + 30677, 30681, 30686, 30687, 30688, 30692, 30694, 30698, 30700, 30704, + 30705, 30708, 30712, 30715, 30725, 30726, 30729, 30733, 30734, 30737, + 30749, 30753, 30754, 30755, 30765, 30766, 30768, 30773, 30775, 30787, + 30788, 30791, 30792, 30796, 30798, 30802, 30812, 30814, 30816, 30817, + 30819, 30820, 30824, 30826, 30830, 30842, 30846, 30858, 30863, 30868, + 30872, 30881, 30877, 30878, 30879, 30884, 30888, 30892, 30893, 30896, + 30897, 30898, 30899, 30907, 30909, 30911, 30919, 30920, 30921, 30924, + 30926, 30930, 30931, 30933, 30934, 30948, 30939, 30943, 30944, 30945, + 30950, 30954, 30962, 30963, 30976, 30966, 30967, 30970, 30971, 30975, + 30982, 30988, 30992, 31002, 31004, 31006, 31007, 31008, 31013, 31015, + 31017, 31021, 31025, 31028, 31029, 31035, 31037, 31039, 31044, 31045, + 31046, 31050, 31051, 31055, 31057, 31060, 31064, 31067, 31068, 31079, + 31081, 31083, 31090, 31097, 31099, 31100, 31102, 31115, 31116, 31121, + 31123, 31124, 31125, 31126, 31128, 31131, 31132, 31137, 31144, 31145, + 31147, 31151, 31153, 31156, 31160, 31163, 31170, 31172, 31175, 31176, + 31178, 31183, 31188, 31190, 31194, 31197, 31198, 31200, 31202, 31205, + 31210, 31211, 31213, 31217, 31224, 31228, 31234, 31235, 31239, 31241, + 31242, 31244, 31249, 31253, 31259, 31262, 31265, 31271, 31275, 31277, + 31279, 31280, 31284, 31285, 31288, 31289, 31290, 31300, 31301, 31303, + 31304, 31308, 31317, 31318, 31321, 31324, 31325, 31327, 31328, 31333, + 31335, 31338, 31341, 31349, 31352, 31358, 31360, 31362, 31365, 31366, + 31370, 31371, 31376, 31377, 31380, 31390, 31392, 31395, 31404, 31411, + 31413, 31417, 31419, 31420, 31430, 31433, 31436, 31438, 31441, 31451, + 31464, 31465, 31467, 31468, 31473, 31476, 31483, 31485, 31486, 31495, + 31508, 31519, 31523, 31527, 31529, 31530, 31531, 31533, 31534, 31535, + 31536, 31537, 31540, 31549, 31551, 31552, 31553, 31559, 31566, 31573, + 31584, 31588, 31590, 31593, 31594, 31597, 31599, 31602, 31603, 31607, + 31620, 31625, 31630, 31632, 31633, 31638, 31643, 31646, 31648, 31653, + 31660, 31663, 31664, 31666, 31669, 31670, 31674, 31675, 31676, 31677, + 31682, 31685, 31688, 31690, 31700, 31702, 31703, 31705, 31706, 31707, + 31720, 31722, 31730, 31732, 31733, 31736, 31737, 31738, 31740, 31742, + 31745, 31746, 31747, 31748, 31750, 31753, 31755, 31756, 31758, 31759, + 31769, 31771, 31776, 31781, 31782, 31784, 31788, 31793, 31795, 31796, + 31798, 31801, 31802, 31814, 31818, 31829, 31825, 31826, 31827, 31833, + 31834, 31835, 31836, 31837, 31838, 31841, 31843, 31847, 31849, 31853, + 31854, 31856, 31858, 31865, 31868, 31869, 31878, 31879, 31887, 31892, + 31902, 31904, 31910, 31920, 31926, 31927, 31930, 31931, 31932, 31935, + 31940, 31943, 31944, 31945, 31949, 31951, 31955, 31956, 31957, 31959, + 31961, 31962, 31965, 31974, 31977, 31979, 31989, 32003, 32007, 32008, + 32009, 32015, 32017, 32018, 32019, 32022, 32029, 32030, 32035, 32038, + 32042, 32045, 32049, 32060, 32061, 32062, 32064, 32065, 32071, 32072, + 32077, 32081, 32083, 32087, 32089, 32090, 32092, 32093, 32101, 32103, + 32106, 32112, 32120, 32122, 32123, 32127, 32129, 32130, 32131, 32133, + 32134, 32136, 32139, 32140, 32141, 32145, 32150, 32151, 32157, 32158, + 32166, 32167, 32170, 32179, 32182, 32183, 32185, 32194, 32195, 32196, + 32197, 32198, 32204, 32205, 32206, 32215, 32217, 32256, 32226, 32229, + 32230, 32234, 32235, 32237, 32241, 32245, 32246, 32249, 32250, 32264, + 32272, 32273, 32277, 32279, 32284, 32285, 32288, 32295, 32296, 32300, + 32301, 32303, 32307, 32310, 32319, 32324, 32325, 32327, 32334, 32336, + 32338, 32344, 32351, 32353, 32354, 32357, 32363, 32366, 32367, 32371, + 32376, 32382, 32385, 32390, 32391, 32394, 32397, 32401, 32405, 32408, + 32410, 32413, 32414, 32572, 32571, 32573, 32574, 32575, 32579, 32580, + 32583, 32591, 32594, 32595, 32603, 32604, 32605, 32609, 32611, 32612, + 32613, 32614, 32621, 32625, 32637, 32638, 32639, 32640, 32651, 32653, + 32655, 32656, 32657, 32662, 32663, 32668, 32673, 32674, 32678, 32682, + 32685, 32692, 32700, 32703, 32704, 32707, 32712, 32718, 32719, 32731, + 32735, 32739, 32741, 32744, 32748, 32750, 32751, 32754, 32762, 32765, + 32766, 32767, 32775, 32776, 32778, 32781, 32782, 32783, 32785, 32787, + 32788, 32790, 32797, 32798, 32799, 32800, 32804, 32806, 32812, 32814, + 32816, 32820, 32821, 32823, 32825, 32826, 32828, 32830, 32832, 32836, + 32864, 32868, 32870, 32877, 32881, 32885, 32897, 32904, 32910, 32924, + 32926, 32934, 32935, 32939, 32952, 32953, 32968, 32973, 32975, 32978, + 32980, 32981, 32983, 32984, 32992, 33005, 33006, 33008, 33010, 33011, + 33014, 33017, 33018, 33022, 33027, 33035, 33046, 33047, 33048, 33052, + 33054, 33056, 33060, 33063, 33068, 33072, 33077, 33082, 33084, 33093, + 33095, 33098, 33100, 33106, 33111, 33120, 33121, 33127, 33128, 33129, + 33133, 33135, 33143, 33153, 33168, 33156, 33157, 33158, 33163, 33166, + 33174, 33176, 33179, 33182, 33186, 33198, 33202, 33204, 33211, 33227, + 33219, 33221, 33226, 33230, 33231, 33237, 33239, 33243, 33245, 33246, + 33249, 33252, 33259, 33260, 33264, 33265, 33266, 33269, 33270, 33272, + 33273, 33277, 33279, 33280, 33283, 33295, 33299, 33300, 33305, 33306, + 33309, 33313, 33314, 33320, 33330, 33332, 33338, 33347, 33348, 33349, + 33350, 33355, 33358, 33359, 33361, 33366, 33372, 33376, 33379, 33383, + 33389, 33396, 33403, 33405, 33407, 33408, 33409, 33411, 33412, 33415, + 33417, 33418, 33422, 33425, 33428, 33430, 33432, 33434, 33435, 33440, + 33441, 33443, 33444, 33447, 33448, 33449, 33450, 33454, 33456, 33458, + 33460, 33463, 33466, 33468, 33470, 33471, 33478, 33488, 33493, 33498, + 33504, 33506, 33508, 33512, 33514, 33517, 33519, 33526, 33527, 33533, + 33534, 33536, 33537, 33543, 33544, 33546, 33547, 33620, 33563, 33565, + 33566, 33567, 33569, 33570, 33580, 33581, 33582, 33584, 33587, 33591, + 33594, 33596, 33597, 33602, 33603, 33604, 33607, 33613, 33614, 33617, + 33621, 33622, 33623, 33648, 33656, 33661, 33663, 33664, 33666, 33668, + 33670, 33677, 33682, 33684, 33685, 33688, 33689, 33691, 33692, 33693, + 33702, 33703, 33705, 33708, 33726, 33727, 33728, 33735, 33737, 33743, + 33744, 33745, 33748, 33757, 33619, 33768, 33770, 33782, 33784, 33785, + 33788, 33793, 33798, 33802, 33807, 33809, 33813, 33817, 33709, 33839, + 33849, 33861, 33863, 33864, 33866, 33869, 33871, 33873, 33874, 33878, + 33880, 33881, 33882, 33884, 33888, 33892, 33893, 33895, 33898, 33904, + 33907, 33908, 33910, 33912, 33916, 33917, 33921, 33925, 33938, 33939, + 33941, 33950, 33958, 33960, 33961, 33962, 33967, 33969, 33972, 33978, + 33981, 33982, 33984, 33986, 33991, 33992, 33996, 33999, 34003, 34012, + 34023, 34026, 34031, 34032, 34033, 34034, 34039, 34098, 34042, 34043, + 34045, 34050, 34051, 34055, 34060, 34062, 34064, 34076, 34078, 34082, + 34083, 34084, 34085, 34087, 34090, 34091, 34095, 34099, 34100, 34102, + 34111, 34118, 34127, 34128, 34129, 34130, 34131, 34134, 34137, 34140, + 34141, 34142, 34143, 34144, 34145, 34146, 34148, 34155, 34159, 34169, + 34170, 34171, 34173, 34175, 34177, 34181, 34182, 34185, 34187, 34188, + 34191, 34195, 34200, 34205, 34207, 34208, 34210, 34213, 34215, 34228, + 34230, 34231, 34232, 34236, 34237, 34238, 34239, 34242, 34247, 34250, + 34251, 34254, 34221, 34264, 34266, 34271, 34272, 34278, 34280, 34285, + 34291, 34294, 34300, 34303, 34304, 34308, 34309, 34317, 34318, 34320, + 34321, 34322, 34328, 34329, 34331, 34334, 34337, 34343, 34345, 34358, + 34360, 34362, 34364, 34365, 34368, 34370, 34374, 34386, 34387, 34390, + 34391, 34392, 34393, 34397, 34400, 34401, 34402, 34403, 34404, 34409, + 34412, 34415, 34421, 34422, 34423, 34426, 34445, 34449, 34454, 34456, + 34458, 34460, 34465, 34470, 34471, 34472, 34477, 34481, 34483, 34484, + 34485, 34487, 34488, 34489, 34495, 34496, 34497, 34499, 34501, 34513, + 34514, 34517, 34519, 34522, 34524, 34528, 34531, 34533, 34535, 34440, + 34554, 34556, 34557, 34564, 34565, 34567, 34571, 34574, 34575, 34576, + 34579, 34580, 34585, 34590, 34591, 34593, 34595, 34600, 34606, 34607, + 34609, 34610, 34617, 34618, 34620, 34621, 34622, 34624, 34627, 34629, + 34637, 34648, 34653, 34657, 34660, 34661, 34671, 34673, 34674, 34683, + 34691, 34692, 34693, 34694, 34695, 34696, 34697, 34699, 34700, 34704, + 34707, 34709, 34711, 34712, 34713, 34718, 34720, 34723, 34727, 34732, + 34733, 34734, 34737, 34741, 34750, 34751, 34753, 34760, 34761, 34762, + 34766, 34773, 34774, 34777, 34778, 34780, 34783, 34786, 34787, 34788, + 34794, 34795, 34797, 34801, 34803, 34808, 34810, 34815, 34817, 34819, + 34822, 34825, 34826, 34827, 34832, 34841, 34834, 34835, 34836, 34840, + 34842, 34843, 34844, 34846, 34847, 34856, 34861, 34862, 34864, 34866, + 34869, 34874, 34876, 34881, 34883, 34885, 34888, 34889, 34890, 34891, + 34894, 34897, 34901, 34902, 34904, 34906, 34908, 34911, 34912, 34916, + 34921, 34929, 34937, 34939, 34944, 34968, 34970, 34971, 34972, 34975, + 34976, 34984, 34986, 35002, 35005, 35006, 35008, 35018, 35019, 35020, + 35021, 35022, 35025, 35026, 35027, 35035, 35038, 35047, 35055, 35056, + 35057, 35061, 35063, 35073, 35078, 35085, 35086, 35087, 35093, 35094, + 35096, 35097, 35098, 35100, 35104, 35110, 35111, 35112, 35120, 35121, + 35122, 35125, 35129, 35130, 35134, 35136, 35138, 35141, 35142, 35145, + 35151, 35154, 35159, 35162, 35163, 35164, 35169, 35170, 35171, 35179, + 35182, 35184, 35187, 35189, 35194, 35195, 35196, 35197, 35209, 35213, + 35216, 35220, 35221, 35227, 35228, 35231, 35232, 35237, 35248, 35252, + 35253, 35254, 35255, 35260, 35284, 35285, 35286, 35287, 35288, 35301, + 35305, 35307, 35309, 35313, 35315, 35318, 35321, 35325, 35327, 35332, + 35333, 35335, 35343, 35345, 35346, 35348, 35349, 35358, 35360, 35362, + 35364, 35366, 35371, 35372, 35375, 35381, 35383, 35389, 35390, 35392, + 35395, 35397, 35399, 35401, 35405, 35406, 35411, 35414, 35415, 35416, + 35420, 35421, 35425, 35429, 35431, 35445, 35446, 35447, 35449, 35450, + 35451, 35454, 35455, 35456, 35459, 35462, 35467, 35471, 35472, 35474, + 35478, 35479, 35481, 35487, 35495, 35497, 35502, 35503, 35507, 35510, + 35511, 35515, 35518, 35523, 35526, 35528, 35529, 35530, 35537, 35539, + 35540, 35541, 35543, 35549, 35551, 35564, 35568, 35572, 35573, 35574, + 35580, 35583, 35589, 35590, 35595, 35601, 35612, 35614, 35615, 35594, + 35629, 35632, 35639, 35644, 35650, 35651, 35652, 35653, 35654, 35656, + 35666, 35667, 35668, 35673, 35661, 35678, 35683, 35693, 35702, 35704, + 35705, 35708, 35710, 35713, 35716, 35717, 35723, 35725, 35727, 35732, + 35733, 35740, 35742, 35743, 35896, 35897, 35901, 35902, 35909, 35911, + 35913, 35915, 35919, 35921, 35923, 35924, 35927, 35928, 35931, 35933, + 35929, 35939, 35940, 35942, 35944, 35945, 35949, 35955, 35957, 35958, + 35963, 35966, 35974, 35975, 35979, 35984, 35986, 35987, 35993, 35995, + 35996, 36004, 36025, 36026, 36037, 36038, 36041, 36043, 36047, 36054, + 36053, 36057, 36061, 36065, 36072, 36076, 36079, 36080, 36082, 36085, + 36087, 36088, 36094, 36095, 36097, 36099, 36105, 36114, 36119, 36123, + 36197, 36201, 36204, 36206, 36223, 36226, 36228, 36232, 36237, 36240, + 36241, 36245, 36254, 36255, 36256, 36262, 36267, 36268, 36271, 36274, + 36277, 36279, 36281, 36283, 36288, 36293, 36294, 36295, 36296, 36298, + 36302, 36305, 36308, 36309, 36311, 36313, 36324, 36325, 36327, 36332, + 36336, 36284, 36337, 36338, 36340, 36349, 36353, 36356, 36357, 36358, + 36363, 36369, 36372, 36374, 36384, 36385, 36386, 36387, 36390, 36391, + 36401, 36403, 36406, 36407, 36408, 36409, 36413, 36416, 36417, 36427, + 36429, 36430, 36431, 36436, 36443, 36444, 36445, 36446, 36449, 36450, + 36457, 36460, 36461, 36463, 36464, 36465, 36473, 36474, 36475, 36482, + 36483, 36489, 36496, 36498, 36501, 36506, 36507, 36509, 36510, 36514, + 36519, 36521, 36525, 36526, 36531, 36533, 36538, 36539, 36544, 36545, + 36547, 36548, 36551, 36559, 36561, 36564, 36572, 36584, 36590, 36592, + 36593, 36599, 36601, 36602, 36589, 36608, 36610, 36615, 36616, 36623, + 36624, 36630, 36631, 36632, 36638, 36640, 36641, 36643, 36645, 36647, + 36648, 36652, 36653, 36654, 36660, 36661, 36662, 36663, 36666, 36672, + 36673, 36675, 36679, 36687, 36689, 36690, 36691, 36692, 36693, 36696, + 36701, 36702, 36709, 36765, 36768, 36769, 36772, 36773, 36774, 36789, + 36790, 36792, 36798, 36800, 36801, 36806, 36810, 36811, 36813, 36816, + 36818, 36819, 36821, 36832, 36835, 36836, 36840, 36846, 36849, 36853, + 36854, 36859, 36862, 36866, 36868, 36872, 36876, 36888, 36891, 36904, + 36905, 36911, 36906, 36908, 36909, 36915, 36916, 36919, 36927, 36931, + 36932, 36940, 36955, 36957, 36962, 36966, 36967, 36972, 36976, 36980, + 36985, 36997, 37000, 37003, 37004, 37006, 37008, 37013, 37015, 37016, + 37017, 37019, 37024, 37025, 37026, 37029, 37040, 37042, 37043, 37044, + 37046, 37053, 37068, 37054, 37059, 37060, 37061, 37063, 37064, 37077, + 37079, 37080, 37081, 37084, 37085, 37087, 37093, 37074, 37110, 37099, + 37103, 37104, 37108, 37118, 37119, 37120, 37124, 37125, 37126, 37128, + 37133, 37136, 37140, 37142, 37143, 37144, 37146, 37148, 37150, 37152, + 37157, 37154, 37155, 37159, 37161, 37166, 37167, 37169, 37172, 37174, + 37175, 37177, 37178, 37180, 37181, 37187, 37191, 37192, 37199, 37203, + 37207, 37209, 37210, 37211, 37217, 37220, 37223, 37229, 37236, 37241, + 37242, 37243, 37249, 37251, 37253, 37254, 37258, 37262, 37265, 37267, + 37268, 37269, 37272, 37278, 37281, 37286, 37288, 37292, 37293, 37294, + 37296, 37297, 37298, 37299, 37302, 37307, 37308, 37309, 37311, 37314, + 37315, 37317, 37331, 37332, 37335, 37337, 37338, 37342, 37348, 37349, + 37353, 37354, 37356, 37357, 37358, 37359, 37360, 37361, 37367, 37369, + 37371, 37373, 37376, 37377, 37380, 37381, 37382, 37383, 37385, 37386, + 37388, 37392, 37394, 37395, 37398, 37400, 37404, 37405, 37411, 37412, + 37413, 37414, 37416, 37422, 37423, 37424, 37427, 37429, 37430, 37432, + 37433, 37434, 37436, 37438, 37440, 37442, 37443, 37446, 37447, 37450, + 37453, 37454, 37455, 37457, 37464, 37465, 37468, 37469, 37472, 37473, + 37477, 37479, 37480, 37481, 37486, 37487, 37488, 37493, 37494, 37495, + 37496, 37497, 37499, 37500, 37501, 37503, 37512, 37513, 37514, 37517, + 37518, 37522, 37527, 37529, 37535, 37536, 37540, 37541, 37543, 37544, + 37547, 37551, 37554, 37558, 37560, 37562, 37563, 37564, 37565, 37567, + 37568, 37569, 37570, 37571, 37573, 37574, 37575, 37576, 37579, 37580, + 37581, 37582, 37584, 37587, 37589, 37591, 37592, 37593, 37596, 37597, + 37599, 37600, 37601, 37603, 37605, 37607, 37608, 37612, 37614, 37616, + 37625, 37627, 37631, 37632, 37634, 37640, 37645, 37649, 37652, 37653, + 37660, 37661, 37662, 37663, 37665, 37668, 37669, 37671, 37673, 37674, + 37683, 37684, 37686, 37687, 37703, 37704, 37705, 37712, 37713, 37714, + 37717, 37719, 37720, 37722, 37726, 37732, 37733, 37735, 37737, 37738, + 37741, 37743, 37744, 37745, 37747, 37748, 37750, 37754, 37757, 37759, + 37760, 37761, 37762, 37768, 37770, 37771, 37773, 37775, 37778, 37781, + 37784, 37787, 37790, 37793, 37795, 37796, 37798, 37800, 37803, 37812, + 37813, 37814, 37818, 37801, 37825, 37828, 37829, 37830, 37831, 37833, + 37834, 37835, 37836, 37837, 37843, 37849, 37852, 37854, 37855, 37858, + 37862, 37863, 37881, 37879, 37880, 37882, 37883, 37885, 37889, 37890, + 37892, 37896, 37897, 37901, 37902, 37903, 37909, 37910, 37911, 37919, + 37934, 37935, 37937, 37938, 37939, 37940, 37947, 37951, 37949, 37955, + 37957, 37960, 37962, 37964, 37973, 37977, 37980, 37983, 37985, 37987, + 37992, 37995, 37997, 37998, 37999, 38001, 38002, 38020, 38019, 38264, + 38265, 38270, 38276, 38280, 38284, 38285, 38286, 38301, 38302, 38303, + 38305, 38310, 38313, 38315, 38316, 38324, 38326, 38330, 38333, 38335, + 38342, 38344, 38345, 38347, 38352, 38353, 38354, 38355, 38361, 38362, + 38365, 38366, 38367, 38368, 38372, 38374, 38429, 38430, 38434, 38436, + 38437, 38438, 38444, 38449, 38451, 38455, 38456, 38457, 38458, 38460, + 38461, 38465, 38482, 38484, 38486, 38487, 38488, 38497, 38510, 38516, + 38523, 38524, 38526, 38527, 38529, 38530, 38531, 38532, 38537, 38545, + 38550, 38554, 38557, 38559, 38564, 38565, 38566, 38569, 38574, 38575, + 38579, 38586, 38602, 38610, 23986, 38616, 38618, 38621, 38622, 38623, + 38633, 38639, 38641, 38650, 38658, 38659, 38661, 38665, 38682, 38683, + 38685, 38689, 38690, 38691, 38696, 38705, 38707, 38721, 38723, 38730, + 38734, 38735, 38741, 38743, 38744, 38746, 38747, 38755, 38759, 38762, + 38766, 38771, 38774, 38775, 38776, 38779, 38781, 38783, 38784, 38793, + 38805, 38806, 38807, 38809, 38810, 38814, 38815, 38818, 38828, 38830, + 38833, 38834, 38837, 38838, 38840, 38841, 38842, 38844, 38846, 38847, + 38849, 38852, 38853, 38855, 38857, 38858, 38860, 38861, 38862, 38864, + 38865, 38868, 38871, 38872, 38873, 38877, 38878, 38880, 38875, 38881, + 38884, 38895, 38897, 38900, 38903, 38904, 38906, 38919, 38922, 38937, + 38925, 38926, 38932, 38934, 38940, 38942, 38944, 38947, 38950, 38955, + 38958, 38959, 38960, 38962, 38963, 38965, 38949, 38974, 38980, 38983, + 38986, 38993, 38994, 38995, 38998, 38999, 39001, 39002, 39010, 39011, + 39013, 39014, 39018, 39020, 39083, 39085, 39086, 39088, 39092, 39095, + 39096, 39098, 39099, 39103, 39106, 39109, 39112, 39116, 39137, 39139, + 39141, 39142, 39143, 39146, 39155, 39158, 39170, 39175, 39176, 39185, + 39189, 39190, 39191, 39194, 39195, 39196, 39199, 39202, 39206, 39207, + 39211, 39217, 39218, 39219, 39220, 39221, 39225, 39226, 39227, 39228, + 39232, 39233, 39238, 39239, 39240, 39245, 39246, 39252, 39256, 39257, + 39259, 39260, 39262, 39263, 39264, 39323, 39325, 39327, 39334, 39344, + 39345, 39346, 39349, 39353, 39354, 39357, 39359, 39363, 39369, 39379, + 39380, 39385, 39386, 39388, 39390, 39399, 39402, 39403, 39404, 39408, + 39412, 39413, 39417, 39421, 39422, 39426, 39427, 39428, 39435, 39436, + 39440, 39441, 39446, 39454, 39456, 39458, 39459, 39460, 39463, 39469, + 39470, 39475, 39477, 39478, 39480, 39495, 39489, 39492, 39498, 39499, + 39500, 39502, 39505, 39508, 39510, 39517, 39594, 39596, 39598, 39599, + 39602, 39604, 39605, 39606, 39609, 39611, 39614, 39615, 39617, 39619, + 39622, 39624, 39630, 39632, 39634, 39637, 39638, 39639, 39643, 39644, + 39648, 39652, 39653, 39655, 39657, 39660, 39666, 39667, 39669, 39673, + 39674, 39677, 39679, 39680, 39681, 39682, 39683, 39684, 39685, 39688, + 39689, 39691, 39692, 39693, 39694, 39696, 39698, 39702, 39705, 39707, + 39708, 39712, 39718, 39723, 39725, 39731, 39732, 39733, 39735, 39737, + 39738, 39741, 39752, 39755, 39756, 39765, 39766, 39767, 39771, 39774, + 39777, 39779, 39781, 39782, 39784, 39786, 39787, 39788, 39789, 39790, + 39795, 39797, 39799, 39800, 39801, 39807, 39808, 39812, 39813, 39814, + 39815, 39817, 39818, 39819, 39821, 39823, 39824, 39828, 39834, 39837, + 39838, 39846, 39847, 39849, 39852, 39856, 39857, 39858, 39863, 39864, + 39867, 39868, 39870, 39871, 39873, 39879, 39880, 39886, 39888, 39895, + 39896, 39901, 39903, 39909, 39911, 39914, 39915, 39919, 39923, 39927, + 39928, 39929, 39930, 39933, 39935, 39936, 39938, 39947, 39951, 39953, + 39958, 39960, 39961, 39962, 39964, 39966, 39970, 39971, 39974, 39975, + 39976, 39977, 39978, 39985, 39989, 39990, 39991, 39997, 40001, 40003, + 40004, 40005, 40009, 40010, 40014, 40015, 40016, 40019, 40020, 40022, + 40024, 40027, 40029, 40030, 40031, 40035, 40041, 40042, 40028, 40043, + 40040, 40046, 40048, 40050, 40053, 40055, 40059, 40166, 40178, 40183, + 40185, 40203, 40194, 40209, 40215, 40216, 40220, 40221, 40222, 40239, + 40240, 40242, 40243, 40244, 40250, 40252, 40261, 40253, 40258, 40259, + 40263, 40266, 40275, 40276, 40287, 40291, 40290, 40293, 40297, 40298, + 40299, 40304, 40310, 40311, 40315, 40316, 40318, 40323, 40324, 40326, + 40330, 40333, 40334, 40338, 40339, 40341, 40342, 40343, 40344, 40353, + 40362, 40364, 40366, 40369, 40373, 40377, 40380, 40383, 40387, 40391, + 40393, 40394, 40404, 40405, 40406, 40407, 40410, 40414, 40415, 40416, + 40421, 40423, 40425, 40427, 40430, 40432, 40435, 40436, 40446, 40458, + 40450, 40455, 40462, 40464, 40465, 40466, 40469, 40470, 40473, 40476, + 40477, 40570, 40571, 40572, 40576, 40578, 40579, 40580, 40581, 40583, + 40590, 40591, 40598, 40600, 40603, 40606, 40612, 40616, 40620, 40622, + 40623, 40624, 40627, 40628, 40629, 40646, 40648, 40651, 40661, 40671, + 40676, 40679, 40684, 40685, 40686, 40688, 40689, 40690, 40693, 40696, + 40703, 40706, 40707, 40713, 40719, 40720, 40721, 40722, 40724, 40726, + 40727, 40729, 40730, 40731, 40735, 40738, 40742, 40746, 40747, 40751, + 40753, 40754, 40756, 40759, 40761, 40762, 40764, 40765, 40767, 40769, + 40771, 40772, 40773, 40774, 40775, 40787, 40789, 40790, 40791, 40792, + 40794, 40797, 40798, 40808, 40809, 40813, 40814, 40815, 40816, 40817, + 40819, 40821, 40826, 40829, 40847, 40848, 40849, 40850, 40852, 40854, + 40855, 40862, 40865, 40866, 40867, 40869, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u16) -> u32 { + let code = (code as usize).wrapping_sub(108); + if code < 7103 { + FORWARD_TABLE[code] as u32 + } else { + 0xffff + } +} + +static BACKWARD_TABLE_LOWER: &'static [u16] = &[ + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 127, 65535, 65535, 173, + 65535, 128, 65535, 65535, 170, 169, 65535, 65535, 65535, 171, 113, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 110, 65535, 168, 65535, + 65535, 65535, 65535, 129, 847, 846, 849, 855, 848, 854, 752, 859, 863, 862, + 865, 864, 877, 876, 879, 878, 65535, 893, 895, 894, 897, 901, 896, 65535, + 763, 912, 911, 914, 913, 927, 767, 797, 941, 940, 943, 949, 942, 948, 784, + 953, 957, 956, 959, 958, 971, 970, 973, 972, 786, 987, 989, 988, 991, 995, + 990, 65535, 795, 1006, 1005, 1008, 1007, 1021, 799, 1022, 852, 946, 850, + 944, 853, 947, 856, 950, 857, 951, 860, 954, 858, 952, 861, 955, 753, 785, + 868, 962, 65535, 65535, 867, 961, 869, 963, 866, 960, 871, 965, 872, 966, + 874, 968, 873, 65535, 875, 969, 755, 787, 884, 978, 882, 976, 65535, 65535, + 883, 977, 881, 788, 757, 789, 885, 979, 886, 980, 790, 887, 981, 889, 983, + 888, 982, 760, 792, 759, 791, 890, 984, 892, 986, 891, 985, 793, 762, 794, + 900, 994, 65535, 65535, 899, 993, 764, 796, 902, 996, 904, 998, 903, 997, + 905, 999, 906, 1000, 908, 1002, 907, 1001, 910, 1004, 909, 1003, 766, 798, + 921, 1015, 918, 1012, 915, 1009, 920, 1014, 917, 1011, 919, 1013, 926, + 1020, 929, 1023, 928, 930, 1024, 932, 1026, 931, 1025, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 851, 945, 880, 974, 898, 992, 916, 1010, 925, 1019, 922, 1016, 924, + 1018, 923, 1017, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 964, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 109, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 108, 111, + 115, 114, 65535, 112, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 117, 118, 534, 65535, 535, 536, 537, 65535, 540, 65535, 542, 545, + 555, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 538, 543, 550, 551, 552, 553, 560, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 557, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 554, 559, 556, 558, 561, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 597, 598, 599, 600, + 601, 602, 603, 604, 605, 606, 607, 65535, 608, 609, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, + 65535, 656, 657, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 174, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 172, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1410, 65535, 1411, + 1412, 65535, 65535, 65535, 65535, 65535, 65535, 1413, 65535, 65535, 65535, + 65535, 65535, 1414, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1415, 65535, 65535, 65535, 1416, 1417, 65535, + 65535, 65535, 1418, 65535, 65535, 1419, 65535, 65535, 1420, 1421, 1422, + 65535, 65535, 65535, 65535, 1423, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1424, 1425, 65535, 65535, 1426, 65535, 65535, + 1427, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1428, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1429, 65535, 1430, + 65535, 65535, 65535, 65535, 65535, 65535, 1431, 65535, 65535, 65535, 65535, + 1432, 1433, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1434, 1435, 65535, 65535, 65535, 1436, 65535, 65535, 65535, 65535, + 65535, 1437, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1438, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1439, 1440, 65535, 65535, 65535, 65535, 65535, 1441, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1442, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1443, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1444, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1445, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1446, 1447, 65535, 65535, 65535, 65535, + 1448, 1449, 1450, 65535, 65535, 65535, 65535, 65535, 1451, 65535, 65535, + 65535, 65535, 65535, 65535, 1452, 65535, 1453, 65535, 1454, 65535, 1455, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1456, 1457, 1458, 1459, + 65535, 1460, 1461, 65535, 65535, 65535, 65535, 1462, 65535, 65535, 1463, + 1464, 65535, 65535, 65535, 65535, 65535, 1465, 65535, 65535, 1466, 1467, + 1468, 65535, 1469, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1470, 65535, 65535, 1471, 65535, 1473, 65535, 1474, 65535, + 1475, 65535, 1476, 65535, 1477, 65535, 65535, 1478, 65535, 1479, 65535, + 1480, 65535, 65535, 65535, 65535, 65535, 1481, 1482, 65535, 1483, 1484, + 65535, 65535, 65535, 65535, 65535, 1485, 65535, 1486, 65535, 1487, 65535, + 1488, 65535, 65535, 65535, 65535, 65535, 65535, 1489, 1472, 65535, 65535, + 1490, 65535, 65535, 65535, 65535, 65535, 65535, 1491, 65535, 1492, 65535, + 1493, 65535, 65535, 1494, 65535, 65535, 65535, 65535, 65535, 1495, 1496, + 1497, 1498, 65535, 65535, 1499, 1500, 65535, 65535, 1501, 1502, 65535, + 1503, 1504, 65535, 65535, 65535, 1505, 1506, 65535, 1507, 65535, 1508, + 65535, 1509, 65535, 1510, 1511, 1512, 65535, 65535, 1513, 65535, 1514, + 1515, 65535, 65535, 65535, 1516, 1517, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1518, 65535, 65535, 65535, 65535, 1519, 65535, 1520, + 65535, 1521, 1522, 1523, 1524, 65535, 1525, 1526, 65535, 65535, 65535, + 1527, 1528, 65535, 1529, 1530, 65535, 1531, 1532, 1533, 65535, 1534, 65535, + 65535, 1535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1536, 65535, 65535, 65535, 1537, 65535, 1538, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1539, 65535, + 1540, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1541, + 1542, 65535, 1543, 1544, 1545, 65535, 65535, 1546, 65535, 65535, 1547, + 65535, 65535, 1548, 65535, 1549, 65535, 1550, 65535, 1551, 65535, 65535, + 1552, 65535, 65535, 65535, 1553, 1554, 65535, 65535, 1555, 1556, 1557, + 1558, 65535, 65535, 65535, 1559, 65535, 65535, 65535, 65535, 1560, 65535, + 65535, 65535, 65535, 65535, 65535, 1561, 65535, 1562, 65535, 1563, 1564, + 65535, 1565, 65535, 65535, 65535, 65535, 65535, 1589, 65535, 65535, 65535, + 65535, 1566, 1567, 1568, 65535, 65535, 1569, 1570, 65535, 65535, 65535, + 1571, 65535, 1572, 65535, 1573, 65535, 65535, 1574, 1575, 1576, 65535, + 65535, 65535, 1577, 65535, 1578, 65535, 65535, 65535, 65535, 65535, 1579, + 1580, 65535, 1581, 1582, 65535, 65535, 1583, 1584, 65535, 65535, 1585, + 65535, 65535, 1586, 65535, 65535, 1587, 1588, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1590, 65535, 1591, 1592, 65535, 1593, 65535, 65535, 65535, 1594, + 65535, 65535, 65535, 1595, 1596, 1597, 65535, 1598, 1599, 1600, 65535, + 1601, 65535, 65535, 65535, 65535, 1602, 1603, 65535, 1604, 1605, 1606, + 1607, 1608, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1609, 65535, + 65535, 65535, 65535, 1610, 1611, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1612, 1613, 65535, 65535, 1614, 65535, 65535, 1615, 65535, + 65535, 1616, 1617, 65535, 65535, 1618, 65535, 65535, 65535, 65535, 1619, + 65535, 1620, 65535, 1621, 65535, 65535, 1622, 1623, 65535, 65535, 65535, + 1624, 65535, 65535, 65535, 1625, 1626, 65535, 1627, 65535, 65535, 1628, + 65535, 1629, 65535, 1630, 65535, 1631, 1632, 65535, 65535, 65535, 65535, + 65535, 1633, 65535, 1634, 1646, 65535, 65535, 65535, 1635, 65535, 65535, + 65535, 1636, 65535, 65535, 65535, 1637, 65535, 65535, 65535, 65535, 1638, + 65535, 65535, 1639, 1640, 1641, 65535, 65535, 1642, 1643, 1644, 1645, + 65535, 1647, 65535, 65535, 65535, 65535, 65535, 65535, 1648, 65535, 1649, + 65535, 1650, 1651, 1652, 1653, 65535, 65535, 65535, 65535, 1654, 65535, + 65535, 65535, 1655, 1656, 65535, 65535, 65535, 1657, 1658, 65535, 1659, + 65535, 1660, 65535, 1661, 1662, 1663, 65535, 65535, 1664, 1665, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1666, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1667, 65535, 65535, 65535, 65535, 1668, 65535, + 65535, 65535, 1669, 65535, 1670, 65535, 1671, 1672, 65535, 65535, 65535, + 65535, 65535, 65535, 1673, 65535, 65535, 65535, 65535, 1674, 65535, 1675, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1676, 65535, 65535, 65535, 65535, 1677, 1678, 65535, + 65535, 65535, 65535, 65535, 65535, 1679, 65535, 65535, 1680, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1681, 65535, 65535, 65535, + 65535, 1682, 65535, 65535, 65535, 1683, 65535, 1684, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1685, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1686, 65535, 1687, 65535, 1688, + 65535, 1689, 1690, 65535, 65535, 1691, 65535, 65535, 65535, 65535, 65535, + 1692, 65535, 65535, 65535, 65535, 65535, 65535, 1693, 65535, 1694, 1695, + 1696, 65535, 1697, 65535, 65535, 1698, 65535, 65535, 65535, 65535, 65535, + 1699, 65535, 65535, 65535, 1700, 65535, 65535, 1701, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1702, 65535, 65535, 65535, 1703, 1704, + 1705, 65535, 65535, 1706, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1707, 1708, 65535, 65535, 1709, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1710, 1711, 65535, + 1712, 1713, 65535, 1714, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1715, 65535, 65535, 65535, 65535, 65535, 1716, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1717, 1718, 65535, 65535, 1719, + 65535, 65535, 65535, 65535, 65535, 65535, 1720, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1721, 65535, 65535, 65535, 1722, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1723, 65535, + 1724, 1725, 65535, 1726, 65535, 1727, 65535, 65535, 1728, 1729, 1730, + 65535, 65535, 65535, 65535, 1731, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1732, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1733, + 1734, 1735, 65535, 65535, 65535, 65535, 65535, 65535, 1736, 65535, 1737, + 65535, 65535, 1738, 65535, 65535, 65535, 65535, 1739, 65535, 1740, 65535, + 65535, 65535, 65535, 65535, 65535, 1741, 65535, 1742, 1743, 1744, 1745, + 65535, 1746, 65535, 1747, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1748, 1749, 1750, 1751, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1752, 1753, 65535, 65535, 65535, 65535, 65535, 1754, 1755, 1756, 65535, + 1757, 1758, 65535, 1759, 65535, 65535, 1760, 65535, 65535, 65535, 1761, + 65535, 1762, 65535, 1763, 65535, 65535, 65535, 1764, 65535, 65535, 1765, + 65535, 1766, 65535, 65535, 1767, 65535, 1768, 65535, 65535, 65535, 65535, + 1769, 1770, 65535, 65535, 65535, 65535, 1771, 65535, 65535, 65535, 1772, + 65535, 65535, 1773, 1774, 1775, 65535, 1776, 65535, 65535, 65535, 1777, + 1778, 65535, 65535, 1779, 65535, 1780, 1781, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1782, 65535, 65535, 1783, 65535, 65535, 65535, + 65535, 65535, 65535, 1784, 1785, 1786, 65535, 65535, 65535, 65535, 1787, + 65535, 1788, 65535, 65535, 65535, 65535, 1789, 65535, 65535, 1790, 1791, + 65535, 1792, 1793, 65535, 65535, 65535, 65535, 65535, 1794, 65535, 1795, + 1796, 1797, 65535, 1798, 1799, 1800, 65535, 65535, 1801, 65535, 1802, + 65535, 65535, 1803, 65535, 65535, 65535, 65535, 65535, 65535, 1804, 1805, + 1806, 65535, 65535, 65535, 1807, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1809, 1808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1810, 65535, 1811, 65535, 65535, 65535, + 65535, 65535, 1812, 65535, 1813, 65535, 1814, 65535, 65535, 65535, 65535, + 65535, 65535, 1815, 1816, 65535, 65535, 65535, 65535, 1817, 65535, 65535, + 65535, 65535, 65535, 65535, 1818, 65535, 65535, 65535, 65535, 1819, 65535, + 65535, 65535, 65535, 1820, 65535, 65535, 65535, 1821, 1822, 65535, 65535, + 65535, 65535, 65535, 1823, 65535, 65535, 65535, 65535, 1824, 1825, 65535, + 65535, 65535, 65535, 1826, 65535, 65535, 65535, 1827, 65535, 65535, 65535, + 1828, 65535, 65535, 1829, 65535, 65535, 65535, 65535, 65535, 1830, 1831, + 65535, 65535, 65535, 1832, 65535, 65535, 1833, 65535, 1834, 1835, 65535, + 1836, 1837, 65535, 1838, 65535, 65535, 1839, 65535, 65535, 1840, 65535, + 65535, 65535, 65535, 1841, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1842, 65535, 65535, 1843, 1844, 65535, 1845, 65535, 65535, + 65535, 65535, 1846, 65535, 65535, 1847, 1848, 65535, 1849, 65535, 65535, + 65535, 65535, 65535, 1850, 1851, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1852, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1853, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1854, 65535, 65535, 65535, 65535, 65535, + 65535, 1855, 65535, 65535, 65535, 65535, 65535, 65535, 1856, 65535, 65535, + 65535, 65535, 65535, 1857, 1858, 65535, 1859, 65535, 65535, 65535, 65535, + 1860, 65535, 1861, 65535, 65535, 1862, 1863, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1864, 1865, + 65535, 65535, 1866, 65535, 65535, 65535, 65535, 65535, 1867, 65535, 1868, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1869, 65535, 65535, 65535, 1870, 65535, 1871, + 65535, 1872, 1873, 65535, 1874, 65535, 1875, 65535, 1876, 1877, 65535, + 65535, 65535, 65535, 65535, 1878, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1879, 65535, 1880, 65535, 1881, 65535, 1882, + 65535, 65535, 1883, 1884, 65535, 65535, 65535, 1885, 65535, 65535, 65535, + 1886, 65535, 65535, 65535, 1887, 1888, 65535, 65535, 65535, 65535, 65535, + 1889, 65535, 65535, 1890, 65535, 1891, 65535, 65535, 65535, 65535, 1892, + 1893, 65535, 1894, 1895, 65535, 65535, 1896, 1897, 65535, 65535, 1898, + 65535, 65535, 65535, 65535, 65535, 1899, 65535, 1900, 1901, 1902, 65535, + 65535, 65535, 1903, 65535, 65535, 65535, 65535, 65535, 65535, 1904, 65535, + 65535, 65535, 1905, 65535, 65535, 1906, 1907, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1908, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1909, 65535, 1910, 65535, 65535, 1911, 65535, 65535, 65535, + 65535, 65535, 65535, 1912, 65535, 65535, 65535, 65535, 65535, 1913, 65535, + 1914, 1915, 1916, 1917, 65535, 65535, 65535, 1918, 65535, 65535, 1919, + 1920, 65535, 65535, 1921, 1922, 1923, 65535, 65535, 65535, 65535, 65535, + 65535, 1924, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1925, 1926, 65535, 65535, 65535, 65535, 65535, 65535, 1927, 65535, + 65535, 1928, 1929, 65535, 65535, 65535, 65535, 1930, 1931, 1932, 65535, + 65535, 65535, 1933, 65535, 65535, 65535, 65535, 65535, 1934, 65535, 1935, + 1936, 65535, 65535, 1937, 65535, 65535, 1938, 1939, 65535, 65535, 65535, + 65535, 65535, 65535, 1940, 65535, 1941, 1942, 65535, 65535, 1943, 65535, + 1944, 1945, 65535, 65535, 1946, 65535, 1947, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1948, + 65535, 1949, 1950, 65535, 65535, 65535, 1951, 65535, 1952, 65535, 65535, + 65535, 65535, 65535, 1953, 1954, 65535, 1955, 1956, 1957, 1958, 65535, + 65535, 1959, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1960, 1961, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1962, 65535, 65535, 65535, 65535, 1963, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1964, 65535, 1965, + 65535, 1966, 65535, 65535, 1967, 65535, 65535, 1968, 65535, 1969, 1970, + 65535, 1971, 65535, 65535, 1972, 1973, 1974, 65535, 65535, 65535, 1975, + 1976, 65535, 65535, 1977, 65535, 65535, 1978, 65535, 65535, 65535, 1979, + 65535, 65535, 65535, 65535, 65535, 65535, 1980, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1981, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1982, 65535, 65535, 65535, 65535, + 65535, 1983, 65535, 65535, 1984, 65535, 1985, 65535, 65535, 1986, 1987, + 1988, 1989, 1990, 1991, 65535, 65535, 65535, 65535, 65535, 65535, 1992, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1993, 65535, 65535, + 65535, 1994, 65535, 65535, 1995, 65535, 1996, 65535, 1997, 65535, 1998, + 65535, 1999, 2000, 2001, 65535, 2002, 2003, 2004, 65535, 2005, 2006, 65535, + 2007, 65535, 65535, 2008, 65535, 2009, 65535, 2010, 65535, 2011, 65535, + 65535, 65535, 65535, 2012, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2013, 65535, 2014, 2015, 2016, 2017, 65535, 65535, 2018, + 65535, 65535, 2019, 65535, 65535, 65535, 2020, 65535, 2021, 65535, 2022, + 2023, 65535, 65535, 2024, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2025, 2026, 65535, 65535, + 2027, 65535, 65535, 2028, 2029, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2030, 65535, 65535, 65535, 2031, 2032, 65535, 65535, 2033, + 2034, 2035, 65535, 65535, 65535, 65535, 65535, 65535, 2036, 2037, 2038, + 2039, 65535, 2040, 2041, 2042, 65535, 65535, 65535, 2043, 65535, 2044, + 65535, 65535, 65535, 2045, 65535, 65535, 65535, 65535, 65535, 65535, 2046, + 65535, 65535, 65535, 65535, 65535, 65535, 2047, 65535, 65535, 65535, 2048, + 2049, 2050, 2053, 2054, 65535, 2051, 2052, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2055, 65535, 65535, 2056, 2057, 65535, 2058, + 65535, 2059, 65535, 65535, 2060, 2061, 2062, 2063, 2064, 65535, 65535, + 2066, 65535, 2067, 65535, 65535, 65535, 2065, 65535, 65535, 65535, 65535, + 2068, 2069, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2070, 2071, 65535, 65535, 65535, 65535, 2072, 65535, 65535, 2073, 65535, + 2074, 65535, 65535, 65535, 65535, 2075, 65535, 65535, 65535, 2076, 65535, + 65535, 65535, 65535, 2077, 2078, 65535, 2079, 65535, 65535, 2080, 65535, + 2081, 2082, 2083, 2084, 65535, 65535, 65535, 2085, 2086, 65535, 2087, + 65535, 2088, 2089, 65535, 65535, 65535, 2090, 2091, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2092, 2093, 2094, 65535, 65535, 65535, + 65535, 65535, 2095, 2096, 65535, 65535, 65535, 65535, 65535, 2097, 2098, + 65535, 65535, 65535, 65535, 2099, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2100, 65535, + 65535, 2101, 65535, 2102, 2103, 65535, 65535, 2104, 65535, 2105, 2106, + 2107, 2108, 2109, 65535, 2110, 2111, 2112, 65535, 2113, 65535, 2114, 2115, + 2116, 2117, 65535, 2118, 65535, 65535, 2119, 65535, 2120, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2121, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2122, 2131, 65535, 2123, 65535, 2124, 2125, 65535, + 2126, 2127, 2128, 2129, 65535, 2130, 65535, 65535, 65535, 65535, 65535, + 2132, 2133, 2134, 65535, 65535, 2135, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2136, 65535, 65535, 65535, 65535, + 2137, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2138, + 2139, 65535, 65535, 65535, 2140, 65535, 65535, 2141, 65535, 65535, 65535, + 65535, 65535, 2142, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2143, + 2144, 65535, 65535, 2161, 65535, 65535, 2145, 65535, 2146, 2147, 65535, + 2148, 65535, 65535, 65535, 2149, 65535, 65535, 2150, 65535, 65535, 65535, + 65535, 2151, 2152, 65535, 2153, 65535, 65535, 65535, 65535, 2154, 2155, + 2156, 65535, 65535, 65535, 2157, 2158, 65535, 65535, 65535, 2159, 2160, + 65535, 65535, 2162, 2163, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2164, 65535, 65535, 2165, 2166, + 2167, 65535, 65535, 65535, 65535, 65535, 2168, 2169, 65535, 65535, 65535, + 65535, 65535, 2170, 65535, 65535, 65535, 65535, 2171, 65535, 65535, 65535, + 65535, 65535, 65535, 2172, 65535, 65535, 65535, 65535, 65535, 2173, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2174, 65535, 65535, + 2175, 2176, 65535, 2177, 2178, 65535, 65535, 65535, 65535, 2179, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2180, 65535, 2181, + 65535, 65535, 2182, 65535, 65535, 2183, 2184, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2185, 65535, 65535, 65535, 2186, 65535, 65535, 2187, 2188, 2189, + 65535, 65535, 65535, 65535, 65535, 2190, 2191, 2192, 2193, 65535, 2194, + 2195, 65535, 2196, 2197, 65535, 65535, 65535, 2198, 65535, 2199, 65535, + 65535, 65535, 65535, 65535, 65535, 2200, 65535, 65535, 2201, 2202, 2203, + 65535, 65535, 65535, 2204, 65535, 65535, 2205, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2206, 2207, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2209, 65535, 65535, 65535, 65535, 65535, 2210, 65535, + 2208, 65535, 65535, 65535, 2211, 65535, 65535, 65535, 65535, 2212, 2213, + 65535, 2214, 65535, 2215, 65535, 2216, 65535, 2217, 65535, 65535, 65535, + 2218, 65535, 65535, 2219, 65535, 65535, 65535, 2220, 2221, 65535, 65535, + 65535, 65535, 65535, 65535, 2222, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2223, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2224, + 2225, 65535, 65535, 65535, 65535, 2226, 2227, 65535, 65535, 65535, 65535, + 65535, 2228, 2229, 2230, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2232, 65535, 65535, 65535, 2233, 65535, 2234, 2235, 65535, 65535, + 65535, 2236, 65535, 65535, 65535, 65535, 65535, 65535, 2237, 2238, 65535, + 65535, 2239, 65535, 2240, 2241, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2242, 65535, 65535, 65535, 2243, 65535, 65535, 2244, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2245, + 2246, 65535, 65535, 65535, 65535, 65535, 2247, 65535, 2248, 65535, 2249, + 2250, 2251, 65535, 2252, 65535, 2253, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2254, 65535, 2255, 65535, 2256, 65535, 65535, 2257, 65535, + 65535, 2258, 2259, 65535, 65535, 2260, 65535, 2261, 2262, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2263, 2264, 65535, 2265, 65535, 65535, 65535, 2266, 65535, + 65535, 2267, 65535, 2268, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2269, 65535, 65535, 65535, 65535, 2270, 65535, 65535, 2271, 65535, 65535, + 65535, 65535, 65535, 2272, 2273, 2274, 2275, 65535, 65535, 2276, 65535, + 65535, 65535, 2277, 65535, 65535, 2278, 65535, 2279, 65535, 65535, 65535, + 65535, 2280, 65535, 2281, 2282, 65535, 65535, 65535, 2283, 65535, 2284, + 65535, 65535, 2285, 65535, 65535, 65535, 65535, 2286, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2287, 2288, 2289, 65535, + 65535, 65535, 2290, 2291, 65535, 65535, 2292, 65535, 65535, 65535, 65535, + 65535, 65535, 2293, 2294, 65535, 2295, 2296, 65535, 2297, 65535, 65535, + 2298, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2299, 65535, + 65535, 65535, 2300, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2301, + 2302, 2303, 65535, 65535, 65535, 2304, 2305, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2306, 65535, 65535, 65535, 65535, + 2307, 2308, 65535, 65535, 2309, 2310, 65535, 2311, 65535, 65535, 2312, + 65535, 65535, 2313, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2314, 2315, 65535, 2316, 2317, 65535, 65535, 65535, 2318, 65535, + 65535, 65535, 2319, 65535, 65535, 65535, 65535, 2320, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2321, 65535, 65535, 65535, 65535, 2322, + 65535, 2323, 65535, 2324, 65535, 65535, 65535, 65535, 65535, 2325, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2326, 65535, 65535, + 2327, 2328, 65535, 65535, 2329, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2330, 65535, 65535, 65535, 65535, + 2331, 65535, 65535, 2332, 65535, 65535, 2333, 65535, 65535, 2334, 65535, + 65535, 2335, 65535, 2336, 2337, 2338, 65535, 2339, 65535, 65535, 65535, + 65535, 2340, 65535, 65535, 65535, 65535, 2341, 65535, 65535, 65535, 65535, + 2342, 2343, 2344, 65535, 2345, 65535, 65535, 2346, 65535, 2347, 2348, + 65535, 65535, 65535, 2349, 65535, 65535, 65535, 65535, 2350, 65535, 2351, + 65535, 2352, 65535, 65535, 65535, 65535, 65535, 65535, 2353, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2354, 65535, 2355, + 65535, 65535, 65535, 2356, 65535, 65535, 65535, 65535, 2357, 65535, 65535, + 65535, 65535, 2358, 65535, 65535, 65535, 2359, 65535, 65535, 65535, 65535, + 65535, 65535, 2360, 2361, 65535, 65535, 65535, 65535, 65535, 65535, 2362, + 65535, 65535, 2363, 2364, 65535, 65535, 65535, 65535, 65535, 65535, 2365, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2366, 65535, 2368, 65535, 2369, 65535, 2370, + 65535, 65535, 65535, 2371, 65535, 65535, 65535, 2372, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2373, 65535, 65535, 65535, 65535, 65535, 65535, + 2367, 65535, 65535, 65535, 2374, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2375, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2376, 2377, 65535, 65535, 65535, 65535, 65535, 2378, 65535, 65535, + 65535, 2379, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2380, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2381, 65535, 65535, + 65535, 65535, 65535, 2382, 2383, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2384, 2385, 2386, 2387, 65535, + 2388, 65535, 65535, 2389, 65535, 2390, 65535, 65535, 65535, 2391, 65535, + 65535, 65535, 2392, 65535, 2393, 2394, 65535, 2395, 2396, 65535, 2397, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2398, 2399, 65535, 65535, + 2400, 2401, 65535, 2402, 65535, 2403, 2404, 65535, 65535, 65535, 65535, + 2405, 65535, 65535, 2406, 65535, 2407, 65535, 65535, 65535, 2408, 2409, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2410, 65535, 2411, 65535, 65535, 65535, 65535, 65535, 65535, 2412, + 2413, 2414, 2415, 2416, 65535, 65535, 65535, 65535, 65535, 2417, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2418, 65535, 2419, 65535, 65535, 2420, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2421, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2422, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2423, + 65535, 65535, 65535, 65535, 65535, 65535, 2424, 2425, 65535, 65535, 65535, + 2426, 65535, 65535, 2427, 65535, 65535, 2428, 65535, 2429, 2430, 65535, + 2431, 65535, 2432, 65535, 2433, 65535, 65535, 2434, 2435, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2436, 2437, 65535, 2438, 65535, 65535, 65535, 65535, 65535, + 2439, 2440, 65535, 65535, 65535, 2441, 2442, 2443, 65535, 65535, 65535, + 2444, 65535, 65535, 2445, 65535, 65535, 65535, 2446, 2447, 65535, 65535, + 65535, 65535, 2448, 2449, 2450, 2451, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2452, 2453, 65535, 2454, 65535, 65535, 65535, + 65535, 2455, 65535, 65535, 2456, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2457, 65535, 2458, 2459, 65535, 2460, 2461, + 65535, 65535, 2462, 65535, 65535, 65535, 2463, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2464, 65535, 2465, 2466, 65535, 65535, 65535, 65535, + 2467, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2468, 65535, 2469, 65535, 65535, 65535, 65535, + 65535, 65535, 2470, 65535, 65535, 65535, 65535, 2472, 65535, 65535, 65535, + 65535, 65535, 2471, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2473, 65535, 65535, + 2474, 2475, 65535, 2476, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2477, 65535, 65535, 65535, 65535, 2478, + 65535, 65535, 65535, 65535, 65535, 65535, 2479, 65535, 65535, 65535, 65535, + 2480, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2482, 2483, 65535, 2484, 2485, + 65535, 65535, 65535, 2481, 65535, 65535, 65535, 65535, 65535, 2486, 65535, + 65535, 2487, 65535, 65535, 65535, 65535, 2488, 65535, 65535, 65535, 2489, + 65535, 2490, 65535, 65535, 2491, 2492, 65535, 65535, 2493, 65535, 2494, + 65535, 2498, 65535, 65535, 65535, 65535, 65535, 65535, 2496, 65535, 65535, + 65535, 2495, 65535, 65535, 65535, 2497, 65535, 65535, 65535, 65535, 65535, + 2499, 2500, 2501, 2502, 65535, 2503, 65535, 65535, 65535, 65535, 65535, + 2504, 65535, 65535, 2505, 65535, 65535, 2506, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2507, 2508, 65535, 65535, 65535, 2509, 2510, + 65535, 2511, 65535, 2512, 65535, 65535, 65535, 65535, 2513, 65535, 2514, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2515, 2516, 2517, 2518, + 65535, 65535, 65535, 2519, 65535, 2520, 65535, 65535, 65535, 2521, 2522, + 65535, 65535, 65535, 65535, 65535, 65535, 2523, 65535, 65535, 65535, 2524, + 65535, 65535, 65535, 65535, 2525, 65535, 6569, 65535, 2526, 65535, 65535, + 65535, 2527, 2528, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2529, 65535, 65535, 65535, 2530, 65535, 65535, 65535, 2531, 65535, + 65535, 2533, 65535, 2532, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2534, 2535, 65535, 65535, 65535, 65535, 65535, 65535, 2536, 65535, 65535, + 65535, 2537, 65535, 65535, 65535, 65535, 2538, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2539, + 2540, 65535, 65535, 65535, 65535, 65535, 65535, 2541, 65535, 65535, 65535, + 65535, 65535, 65535, 2542, 65535, 65535, 65535, 65535, 65535, 2543, 65535, + 65535, 65535, 65535, 2544, 65535, 2545, 2546, 65535, 65535, 2547, 65535, + 65535, 65535, 65535, 65535, 65535, 2548, 2549, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2551, 65535, 65535, 65535, 65535, 65535, 2550, 65535, + 65535, 65535, 2552, 65535, 65535, 2553, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2554, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2557, 65535, 2555, 65535, 65535, 65535, 65535, 2556, + 2558, 65535, 65535, 65535, 65535, 2559, 65535, 2560, 65535, 65535, 2561, + 2562, 65535, 2563, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2564, 65535, 2565, 2566, 2567, 2568, 2569, 65535, 2570, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2571, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2572, 65535, 65535, 2573, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2574, 65535, 2575, 2576, 65535, + 65535, 2577, 65535, 2578, 65535, 2579, 65535, 65535, 65535, 65535, 2580, + 65535, 2581, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2582, 2583, 2584, 65535, 65535, 65535, 65535, 65535, 65535, 2585, 65535, + 65535, 65535, 65535, 2587, 2586, 65535, 2588, 65535, 65535, 2589, 2590, + 65535, 2591, 2592, 65535, 65535, 65535, 65535, 65535, 65535, 2593, 65535, + 2594, 65535, 65535, 65535, 65535, 65535, 65535, 2595, 65535, 65535, 65535, + 65535, 65535, 2596, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2597, 65535, 65535, 65535, 2598, 2599, 2600, + 65535, 65535, 65535, 65535, 65535, 2601, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2602, 65535, 65535, 2603, 2604, 65535, + 65535, 65535, 2605, 2606, 2607, 2608, 65535, 65535, 65535, 2609, 65535, + 65535, 2610, 2611, 65535, 2612, 65535, 2613, 65535, 65535, 65535, 2614, + 65535, 2615, 65535, 65535, 65535, 65535, 2616, 65535, 2617, 65535, 2618, + 2619, 65535, 65535, 65535, 2620, 2621, 65535, 2622, 65535, 65535, 65535, + 65535, 65535, 2623, 65535, 65535, 2624, 65535, 65535, 65535, 2625, 65535, + 65535, 65535, 2626, 65535, 65535, 2627, 65535, 65535, 65535, 65535, 2628, + 65535, 65535, 2629, 2630, 65535, 65535, 2631, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2632, 65535, 65535, 2633, 65535, 2634, 2635, 65535, + 65535, 2636, 65535, 2637, 65535, 65535, 2638, 2639, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2640, 65535, 65535, 65535, + 2641, 65535, 2642, 65535, 65535, 65535, 65535, 65535, 65535, 2643, 65535, + 65535, 65535, 65535, 65535, 2644, 2645, 65535, 65535, 65535, 65535, 2646, + 65535, 2649, 65535, 65535, 2647, 65535, 65535, 65535, 2648, 2650, 65535, + 65535, 2651, 2652, 2653, 65535, 65535, 65535, 65535, 65535, 65535, 2654, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2655, 65535, 65535, 2656, 2657, 2658, 65535, 2659, 65535, 65535, + 65535, 65535, 2660, 2661, 2662, 2663, 2664, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2665, 65535, 65535, 2666, 2667, 65535, + 65535, 65535, 65535, 65535, 2668, 2669, 2670, 65535, 2671, 2672, 2673, + 2674, 65535, 65535, 2675, 2676, 65535, 65535, 2677, 65535, 65535, 65535, + 2678, 65535, 2679, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2680, 65535, 65535, 2681, 65535, 65535, 2682, 65535, 65535, + 65535, 65535, 65535, 2683, 2684, 65535, 65535, 2685, 2686, 65535, 2687, + 65535, 65535, 65535, 65535, 2688, 65535, 65535, 65535, 65535, 2689, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2690, 65535, 65535, 65535, + 65535, 65535, 2691, 65535, 2692, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2693, 65535, 65535, 65535, 65535, 65535, 65535, + 2694, 2695, 2696, 65535, 65535, 2697, 65535, 65535, 65535, 65535, 2698, + 65535, 65535, 2699, 65535, 2700, 2701, 65535, 65535, 65535, 65535, 65535, + 2702, 65535, 65535, 65535, 2703, 65535, 65535, 65535, 65535, 65535, 2704, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2705, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2706, 2707, 65535, 65535, 2708, 65535, 65535, 65535, 2709, 65535, + 2710, 65535, 2711, 65535, 65535, 65535, 2712, 65535, 65535, 2713, 65535, + 2714, 65535, 2715, 65535, 65535, 2716, 65535, 65535, 65535, 65535, 2717, + 2718, 65535, 65535, 65535, 2719, 65535, 2720, 2721, 65535, 65535, 2722, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2723, 2724, 65535, 65535, + 65535, 65535, 65535, 2725, 65535, 65535, 65535, 2726, 65535, 65535, 2727, + 65535, 65535, 65535, 2728, 65535, 2729, 65535, 65535, 65535, 2730, 2731, + 2732, 2733, 65535, 65535, 2734, 2735, 65535, 65535, 65535, 65535, 2736, + 2737, 65535, 65535, 65535, 2738, 65535, 2739, 65535, 2740, 2741, 65535, + 65535, 65535, 2742, 65535, 65535, 2743, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2744, 65535, 65535, 2745, + 65535, 65535, 2746, 65535, 65535, 65535, 2747, 2748, 65535, 65535, 65535, + 65535, 2749, 65535, 65535, 65535, 65535, 2750, 65535, 65535, 2751, 65535, + 2752, 65535, 65535, 65535, 2753, 2754, 2755, 2756, 2757, 65535, 2758, 2759, + 65535, 2760, 65535, 65535, 2761, 65535, 2762, 65535, 65535, 65535, 2763, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2764, 2765, 65535, 65535, + 65535, 65535, 2766, 2767, 65535, 65535, 65535, 2768, 2769, 2770, 65535, + 2771, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2772, 65535, 65535, + 65535, 2773, 2774, 65535, 65535, 2775, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2776, 65535, 2777, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2778, 65535, 65535, + 65535, 65535, 65535, 2779, 65535, 65535, 65535, 65535, 65535, 2780, 65535, + 65535, 2781, 2782, 65535, 65535, 2783, 2784, 2785, 65535, 2786, 2787, + 65535, 65535, 65535, 65535, 65535, 65535, 2788, 65535, 2789, 65535, 65535, + 65535, 65535, 2790, 2791, 65535, 65535, 65535, 2792, 2793, 65535, 65535, + 65535, 2794, 2795, 65535, 2796, 2797, 65535, 65535, 65535, 65535, 2798, + 65535, 65535, 2799, 65535, 2800, 65535, 65535, 2801, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2802, 2803, 65535, 65535, + 2804, 65535, 65535, 65535, 2805, 2806, 2807, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2808, 2809, 65535, 65535, + 65535, 65535, 65535, 2810, 65535, 65535, 65535, 65535, 65535, 65535, 2811, + 2812, 2813, 2814, 65535, 2815, 2816, 65535, 65535, 2819, 65535, 2817, + 65535, 2818, 65535, 65535, 2820, 2821, 65535, 2822, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2823, 65535, 2824, 2825, 65535, 65535, 2826, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2827, 65535, 2828, 65535, 65535, 65535, 65535, 65535, 65535, 2829, + 65535, 65535, 65535, 2830, 65535, 2831, 2832, 65535, 65535, 65535, 2833, + 65535, 2834, 65535, 2835, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2836, 65535, 65535, 65535, 2837, + 65535, 65535, 65535, 65535, 2838, 2839, 2840, 65535, 2841, 65535, 65535, + 65535, 65535, 65535, 2842, 65535, 65535, 65535, 2843, 2844, 2845, 65535, + 2846, 65535, 2847, 65535, 65535, 65535, 2848, 65535, 2849, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2850, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2851, 65535, 2852, 65535, 65535, 65535, 2853, 65535, + 65535, 65535, 65535, 65535, 65535, 2854, 65535, 65535, 2855, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2856, 2857, 2858, 2859, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2860, 65535, 2861, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2862, 65535, + 65535, 2863, 2864, 65535, 65535, 2865, 65535, 65535, 65535, 2866, 2867, + 65535, 65535, 65535, 65535, 2868, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2869, 65535, 65535, 65535, 65535, 65535, 65535, 2870, + 2871, 65535, 65535, 65535, 2872, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2873, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2874, 65535, 2875, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2876, 2877, 65535, 65535, 65535, 65535, + 65535, 2878, 2879, 65535, 65535, 65535, 65535, 65535, 2880, 2881, 65535, + 2882, 65535, 65535, 2883, 65535, 65535, 2884, 65535, 65535, 2885, 65535, + 2886, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2887, 2888, 65535, 65535, 2889, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2890, 2891, 65535, 65535, + 2892, 65535, 65535, 2893, 65535, 65535, 65535, 65535, 2894, 2895, 2896, + 2897, 65535, 2898, 65535, 65535, 65535, 2899, 2900, 65535, 65535, 2901, + 65535, 65535, 65535, 2902, 2903, 2904, 65535, 65535, 65535, 2905, 65535, + 65535, 2906, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2907, 2908, 65535, 65535, 65535, 65535, 65535, 2909, 2910, 65535, 65535, + 65535, 2911, 65535, 65535, 2912, 2913, 65535, 65535, 2914, 65535, 65535, + 65535, 2915, 2916, 65535, 2917, 65535, 65535, 2918, 65535, 2919, 65535, + 65535, 2920, 65535, 65535, 2921, 65535, 65535, 65535, 65535, 65535, 2922, + 65535, 65535, 65535, 2923, 2924, 65535, 65535, 65535, 2925, 2926, 65535, + 65535, 65535, 2927, 65535, 65535, 65535, 65535, 65535, 2928, 65535, 2929, + 65535, 65535, 65535, 65535, 65535, 65535, 2930, 2931, 2932, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2933, 65535, 65535, 65535, 2934, 65535, 65535, 65535, 2935, 65535, + 65535, 2936, 65535, 65535, 65535, 65535, 65535, 2937, 65535, 65535, 2938, + 65535, 2939, 2940, 2941, 65535, 65535, 65535, 65535, 65535, 65535, 2942, + 65535, 65535, 65535, 2943, 65535, 65535, 65535, 65535, 2944, 65535, 65535, + 65535, 65535, 2945, 65535, 2946, 65535, 65535, 65535, 65535, 65535, 2947, + 2948, 65535, 2949, 65535, 65535, 2950, 2951, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2952, 2953, 65535, 65535, 65535, 65535, 65535, 2954, 65535, 2955, + 65535, 2956, 65535, 65535, 65535, 2957, 65535, 65535, 65535, 65535, 65535, + 2958, 65535, 2959, 65535, 2960, 65535, 2961, 2962, 65535, 65535, 65535, + 2963, 2964, 65535, 65535, 65535, 65535, 2965, 2966, 65535, 65535, 65535, + 65535, 2967, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2968, 65535, + 2969, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2970, 65535, 65535, 65535, 2971, 65535, 2972, 2973, 2974, 2975, + 65535, 65535, 65535, 65535, 65535, 2976, 2977, 2978, 2979, 65535, 2980, + 2981, 2982, 65535, 2983, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2984, 65535, 65535, 65535, 65535, 65535, 2985, 2986, 65535, + 65535, 65535, 65535, 65535, 65535, 2987, 65535, 2988, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2989, 65535, 2990, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2991, 2992, 2993, 65535, 65535, 65535, 65535, 65535, + 65535, 2994, 2995, 65535, 2996, 65535, 2997, 65535, 2998, 65535, 2999, + 65535, 3000, 65535, 65535, 3001, 65535, 3002, 65535, 65535, 65535, 3003, + 65535, 65535, 65535, 65535, 65535, 65535, 3004, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3005, 3006, 3007, 65535, 65535, 65535, + 65535, 3008, 65535, 65535, 65535, 65535, 3009, 3010, 3011, 3012, 65535, + 3013, 65535, 3014, 3015, 65535, 65535, 65535, 3016, 65535, 3017, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3018, 3019, 65535, 65535, 65535, 3020, 3021, 65535, 65535, 3022, + 65535, 65535, 3023, 65535, 65535, 65535, 65535, 3024, 65535, 3025, 65535, + 65535, 65535, 3026, 65535, 65535, 65535, 3027, 65535, 3028, 65535, 65535, + 3029, 65535, 65535, 65535, 3030, 3031, 3032, 65535, 65535, 65535, 65535, + 3033, 65535, 65535, 65535, 3034, 3035, 65535, 3036, 65535, 65535, 3037, + 65535, 3038, 65535, 65535, 3039, 3040, 65535, 65535, 3041, 65535, 65535, + 65535, 3042, 65535, 65535, 3043, 65535, 65535, 65535, 65535, 3044, 65535, + 65535, 3045, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3046, + 65535, 3047, 3048, 65535, 65535, 65535, 65535, 65535, 3049, 65535, 65535, + 65535, 3050, 65535, 3051, 65535, 65535, 65535, 65535, 65535, 65535, 3052, + 65535, 3053, 65535, 3054, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3055, 3056, 65535, 65535, 65535, 65535, 65535, 65535, + 3057, 65535, 65535, 65535, 3058, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3059, 65535, 65535, + 3060, 65535, 65535, 65535, 3061, 65535, 65535, 65535, 3062, 65535, 65535, + 65535, 65535, 3063, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3064, + 65535, 65535, 3065, 65535, 65535, 3066, 65535, 65535, 65535, 65535, 3067, + 65535, 65535, 3068, 65535, 65535, 3069, 65535, 65535, 3070, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3071, 65535, 65535, 65535, 3072, 3073, + 3074, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3075, 65535, 65535, 3076, 65535, 65535, 65535, 65535, 65535, 3077, 3078, + 65535, 65535, 65535, 65535, 3079, 65535, 3080, 65535, 65535, 65535, 3081, + 65535, 3082, 65535, 3083, 65535, 65535, 65535, 65535, 65535, 65535, 3084, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3085, 65535, 3086, 65535, 3087, + 3088, 65535, 65535, 65535, 3089, 65535, 65535, 65535, 65535, 3090, 3091, + 3092, 65535, 65535, 65535, 3093, 65535, 65535, 65535, 3094, 3095, 65535, + 65535, 65535, 3096, 65535, 65535, 65535, 3097, 3098, 65535, 65535, 3099, + 3100, 65535, 65535, 65535, 65535, 65535, 65535, 3101, 3102, 65535, 65535, + 3103, 3104, 3105, 3106, 65535, 3107, 65535, 65535, 3108, 3109, 3110, 3111, + 65535, 3112, 65535, 3113, 3114, 65535, 3115, 65535, 65535, 65535, 3117, + 65535, 3116, 65535, 65535, 65535, 65535, 65535, 65535, 3118, 65535, 65535, + 65535, 65535, 3119, 3120, 65535, 65535, 65535, 3121, 65535, 3122, 65535, + 3124, 65535, 65535, 3123, 65535, 65535, 65535, 65535, 65535, 3125, 3126, + 3127, 65535, 3128, 3129, 65535, 65535, 65535, 3130, 3131, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3133, 3134, 3135, 65535, 65535, + 65535, 65535, 65535, 65535, 3137, 65535, 3138, 65535, 3140, 3141, 3142, + 65535, 3143, 3145, 65535, 3136, 3139, 3144, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3146, 3147, 3148, 65535, 65535, + 3149, 65535, 3150, 65535, 65535, 65535, 65535, 65535, 65535, 3151, 3152, + 3153, 3154, 65535, 65535, 3155, 3156, 65535, 65535, 65535, 3157, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3158, 65535, 65535, 65535, + 3159, 3160, 65535, 65535, 3161, 65535, 65535, 65535, 65535, 65535, 3162, + 65535, 65535, 65535, 3163, 3164, 65535, 3165, 3166, 65535, 65535, 65535, + 65535, 3167, 65535, 65535, 65535, 3168, 65535, 3169, 3170, 65535, 65535, + 65535, 65535, 3171, 65535, 65535, 65535, 65535, 65535, 65535, 3172, 65535, + 65535, 65535, 3173, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3174, 65535, 65535, 3175, 3176, 65535, 3177, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3178, 3132, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3179, 65535, 3180, 65535, + 65535, 65535, 65535, 65535, 65535, 3181, 65535, 65535, 65535, 65535, 3182, + 65535, 65535, 65535, 65535, 65535, 3183, 65535, 65535, 3184, 65535, 65535, + 65535, 3185, 65535, 3186, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3187, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3188, 65535, + 65535, 65535, 65535, 65535, 65535, 3189, 65535, 3190, 3191, 65535, 65535, + 65535, 3192, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3193, 3194, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3195, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3196, 65535, 65535, 65535, 65535, 65535, + 3197, 65535, 3198, 65535, 65535, 65535, 65535, 65535, 3199, 65535, 3200, + 65535, 65535, 65535, 65535, 3201, 65535, 65535, 65535, 65535, 65535, 3202, + 65535, 65535, 3203, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3204, 3205, 65535, 3206, 65535, 3207, 65535, 65535, 3208, 65535, + 3209, 3210, 65535, 3211, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3212, 3213, 3214, 65535, 65535, 3215, 65535, 65535, + 65535, 65535, 65535, 3216, 3217, 3218, 65535, 65535, 3220, 65535, 3221, + 3222, 65535, 3223, 65535, 65535, 3224, 3225, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3226, 65535, 65535, 65535, 65535, 3227, 65535, + 3228, 65535, 65535, 3229, 65535, 65535, 65535, 65535, 3230, 65535, 65535, + 65535, 65535, 3231, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3232, 65535, 3233, 65535, 65535, 65535, 3234, 3235, 65535, 3219, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3237, 65535, 65535, 65535, 65535, + 3238, 65535, 65535, 65535, 3239, 65535, 3240, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3242, 3241, 65535, 65535, 65535, 3243, 3244, 65535, + 3245, 3246, 3247, 65535, 3248, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3249, 65535, 65535, 65535, 3250, 65535, 65535, 65535, 65535, 3251, + 3252, 65535, 65535, 65535, 65535, 3253, 65535, 3254, 65535, 65535, 65535, + 65535, 65535, 3236, 65535, 65535, 3255, 65535, 3256, 3257, 65535, 65535, + 3258, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3259, 65535, 65535, 3260, 3261, 3262, + 3263, 3264, 65535, 65535, 3265, 65535, 65535, 65535, 3266, 3267, 3268, + 3269, 65535, 65535, 65535, 65535, 65535, 3270, 65535, 3271, 65535, 3272, + 65535, 3273, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3274, 65535, 3275, 65535, 3276, 65535, 3277, + 65535, 65535, 65535, 65535, 3278, 65535, 3279, 65535, 3280, 65535, 65535, + 65535, 3281, 3282, 65535, 65535, 65535, 3283, 65535, 65535, 65535, 3284, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3285, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3286, 65535, 65535, 3287, + 65535, 65535, 65535, 3288, 65535, 65535, 3289, 3290, 3291, 65535, 3292, + 65535, 65535, 3293, 65535, 65535, 3294, 65535, 65535, 3295, 3296, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3297, 65535, 65535, 3298, 65535, + 3299, 3300, 3301, 3302, 65535, 65535, 3303, 3304, 65535, 65535, 65535, + 3305, 3306, 65535, 65535, 65535, 65535, 3307, 3308, 3309, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3310, 65535, 65535, 3311, 3312, + 65535, 65535, 65535, 65535, 65535, 3313, 3314, 65535, 3315, 65535, 65535, + 3316, 3317, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3318, 65535, 3319, 65535, 3320, + 65535, 65535, 3321, 65535, 65535, 3322, 65535, 65535, 65535, 65535, 65535, + 65535, 3323, 65535, 65535, 3324, 65535, 65535, 65535, 3325, 65535, 65535, + 65535, 65535, 3326, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3327, 65535, 65535, 65535, 3328, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3329, 3330, 3331, 3332, 65535, 3333, 3334, 65535, 65535, 3335, + 65535, 65535, 65535, 3336, 3337, 3338, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3339, 3340, 65535, 65535, 65535, 3341, 3342, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3343, + 65535, 65535, 65535, 65535, 3344, 65535, 65535, 65535, 3345, 65535, 3346, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3347, 65535, 65535, + 65535, 3348, 3349, 65535, 3350, 65535, 65535, 3351, 65535, 3352, 65535, + 3353, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3354, 3355, 65535, + 3356, 65535, 3357, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3358, 65535, 65535, 3359, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3360, 65535, 65535, 65535, 65535, 3361, 3362, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3363, 65535, 65535, 3364, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3365, 3366, 65535, + 3367, 65535, 3368, 65535, 3369, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3370, 65535, 3371, 3372, 65535, 3373, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3374, 65535, 3375, + 65535, 65535, 65535, 3376, 65535, 65535, 65535, 65535, 3377, 65535, 65535, + 3378, 65535, 65535, 3379, 65535, 65535, 65535, 3380, 65535, 65535, 65535, + 3381, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3382, 65535, 3383, + 65535, 3384, 65535, 65535, 3385, 65535, 65535, 65535, 3386, 65535, 65535, + 3387, 3388, 65535, 65535, 65535, 65535, 65535, 3389, 3390, 65535, 65535, + 3391, 3392, 65535, 65535, 65535, 3393, 65535, 3394, 3395, 3396, 65535, + 65535, 3397, 3398, 65535, 65535, 65535, 65535, 3399, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3400, 65535, 65535, 3401, 65535, 65535, + 3402, 65535, 65535, 65535, 65535, 65535, 65535, 3403, 65535, 3404, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3405, 65535, + 65535, 3406, 65535, 3407, 65535, 65535, 3408, 3409, 65535, 3410, 65535, + 3411, 65535, 65535, 65535, 65535, 65535, 3412, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3413, 65535, 3414, 3415, 3416, 65535, + 65535, 65535, 65535, 65535, 3417, 65535, 65535, 65535, 65535, 65535, 3418, + 65535, 65535, 65535, 3419, 3420, 3421, 65535, 65535, 3422, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3423, 3424, 3425, 65535, 65535, + 65535, 65535, 65535, 65535, 3426, 65535, 3428, 3427, 65535, 65535, 3429, + 65535, 65535, 65535, 3430, 65535, 65535, 65535, 3431, 3432, 3433, 65535, + 65535, 65535, 65535, 65535, 3434, 3435, 65535, 65535, 65535, 65535, 65535, + 65535, 3436, 65535, 65535, 3437, 65535, 65535, 65535, 65535, 3438, 65535, + 65535, 65535, 3439, 3440, 3441, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3442, 3443, 65535, 65535, 65535, 65535, 3444, 3445, + 65535, 65535, 3446, 3447, 65535, 3448, 65535, 65535, 65535, 65535, 65535, + 3449, 3450, 3451, 65535, 65535, 65535, 65535, 65535, 3452, 65535, 65535, + 65535, 3453, 65535, 65535, 3454, 65535, 65535, 65535, 65535, 65535, 3455, + 65535, 65535, 65535, 3456, 65535, 65535, 3457, 3458, 65535, 65535, 3459, + 65535, 65535, 65535, 65535, 65535, 3460, 3461, 65535, 65535, 65535, 65535, + 3462, 65535, 65535, 65535, 3463, 65535, 65535, 65535, 65535, 65535, 65535, + 3464, 65535, 65535, 65535, 3465, 65535, 65535, 3466, 65535, 65535, 65535, + 65535, 3467, 65535, 65535, 65535, 3468, 65535, 3469, 65535, 65535, 65535, + 65535, 3470, 65535, 65535, 3471, 65535, 65535, 65535, 65535, 65535, 65535, + 3472, 65535, 65535, 65535, 3473, 65535, 65535, 3474, 65535, 3475, 65535, + 65535, 65535, 65535, 3476, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3477, 3478, 65535, 65535, 65535, 3479, 65535, 65535, 3480, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3481, 65535, 65535, 65535, 3482, 65535, + 65535, 65535, 3483, 3484, 65535, 3485, 3486, 65535, 65535, 65535, 65535, + 3487, 3488, 65535, 65535, 3489, 3490, 3491, 65535, 3492, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3493, 3494, 65535, 65535, 65535, 3495, + 3496, 65535, 65535, 65535, 65535, 3497, 3498, 65535, 65535, 65535, 65535, + 3499, 65535, 65535, 3500, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3501, 65535, 65535, 65535, 3502, 65535, 65535, 65535, 65535, + 65535, 65535, 3503, 65535, 3504, 65535, 65535, 3505, 3506, 65535, 65535, + 65535, 65535, 65535, 65535, 3507, 65535, 65535, 3508, 65535, 65535, 65535, + 65535, 65535, 3509, 65535, 3510, 65535, 65535, 65535, 65535, 65535, 3511, + 65535, 65535, 3512, 65535, 3513, 3514, 65535, 65535, 65535, 3515, 65535, + 65535, 65535, 3516, 3517, 65535, 3518, 65535, 3519, 65535, 65535, 65535, + 65535, 65535, 65535, 3520, 65535, 65535, 65535, 65535, 65535, 3521, 65535, + 65535, 65535, 65535, 65535, 65535, 3522, 3523, 3524, 65535, 65535, 65535, + 3525, 65535, 3526, 65535, 65535, 65535, 65535, 3527, 65535, 3528, 3529, + 65535, 65535, 65535, 3530, 3531, 65535, 65535, 65535, 3532, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3533, 3534, 65535, + 3535, 65535, 3536, 65535, 65535, 3537, 65535, 3538, 65535, 65535, 65535, + 65535, 3539, 65535, 3540, 3541, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3593, 65535, 65535, 65535, 3542, 65535, 3543, + 65535, 3544, 65535, 65535, 65535, 65535, 3545, 65535, 3546, 65535, 3547, + 3548, 65535, 3549, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3550, 3551, 3552, 65535, 3553, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3554, 3555, 65535, 3556, 3557, 65535, + 65535, 65535, 3558, 65535, 65535, 3559, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3560, 65535, 3561, 65535, 3562, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3563, 65535, 65535, + 65535, 3564, 65535, 65535, 65535, 65535, 65535, 65535, 3565, 65535, 3566, + 3567, 3568, 3569, 65535, 3570, 65535, 3571, 65535, 65535, 65535, 3572, + 65535, 3573, 65535, 65535, 65535, 3574, 65535, 65535, 65535, 65535, 65535, + 65535, 3575, 65535, 3576, 65535, 3577, 3578, 65535, 3579, 65535, 65535, + 65535, 3580, 65535, 3581, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3582, 65535, 65535, + 3583, 65535, 65535, 3584, 65535, 65535, 65535, 3585, 3586, 65535, 3587, + 65535, 3588, 65535, 65535, 65535, 65535, 65535, 65535, 3589, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3590, 3591, + 3592, 65535, 65535, 65535, 65535, 65535, 3594, 3595, 65535, 3596, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3597, 65535, 65535, 3598, 65535, + 65535, 3599, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3600, 65535, 65535, 65535, 65535, 65535, 65535, + 3601, 3602, 65535, 3603, 65535, 65535, 65535, 3604, 65535, 3605, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3606, 3607, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3608, 65535, 65535, + 65535, 65535, 65535, 3609, 65535, 65535, 65535, 65535, 3610, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3611, 3612, 65535, 3613, + 65535, 3614, 3615, 3616, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3617, + 65535, 3618, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3619, 65535, + 65535, 3620, 65535, 3621, 65535, 65535, 65535, 3622, 65535, 3623, 65535, + 65535, 65535, 65535, 3624, 65535, 65535, 65535, 3625, 65535, 3626, 65535, + 65535, 65535, 3627, 3628, 65535, 65535, 65535, 65535, 65535, 65535, 3629, + 65535, 65535, 65535, 65535, 3630, 65535, 3631, 65535, 3632, 3633, 65535, + 3634, 65535, 65535, 3635, 65535, 65535, 65535, 3636, 65535, 65535, 65535, + 65535, 65535, 3637, 3638, 65535, 65535, 65535, 3639, 65535, 3640, 65535, + 65535, 65535, 65535, 65535, 3641, 65535, 65535, 65535, 3642, 65535, 65535, + 65535, 3643, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3644, 65535, 65535, 65535, 3645, + 65535, 65535, 65535, 65535, 3646, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3647, 65535, 65535, 65535, 3648, 65535, 65535, + 3649, 65535, 3650, 3651, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3652, 3653, 65535, 65535, 3654, 3655, 65535, 3656, 65535, 65535, 65535, + 3657, 65535, 3658, 3659, 3660, 3661, 65535, 65535, 3662, 65535, 65535, + 65535, 65535, 3663, 3664, 3665, 65535, 65535, 65535, 3666, 3667, 65535, + 65535, 65535, 65535, 3668, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3669, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3670, 65535, 3671, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3672, 65535, 65535, 65535, + 65535, 65535, 3673, 65535, 65535, 65535, 65535, 65535, 3674, 65535, 65535, + 65535, 65535, 65535, 65535, 3675, 65535, 65535, 65535, 65535, 65535, 65535, + 3676, 65535, 65535, 65535, 65535, 65535, 3677, 3678, 65535, 65535, 3679, + 65535, 3680, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3681, 65535, + 65535, 65535, 3682, 3683, 3684, 65535, 3685, 65535, 65535, 65535, 3686, + 3687, 65535, 3688, 65535, 65535, 3689, 3690, 3691, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3692, 65535, 3693, 3694, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3695, 65535, 3696, 65535, + 3697, 65535, 65535, 65535, 65535, 65535, 65535, 3698, 65535, 65535, 65535, + 3699, 65535, 3700, 65535, 3701, 3702, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3703, 65535, 3704, 65535, 3705, 3706, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3707, 65535, 65535, + 3708, 3709, 65535, 65535, 3716, 65535, 3710, 3711, 65535, 65535, 3712, + 65535, 65535, 3713, 65535, 65535, 65535, 65535, 3714, 3715, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3717, 65535, 3718, 3719, 3720, + 65535, 65535, 65535, 3721, 65535, 3722, 3723, 65535, 65535, 3724, 3725, + 65535, 65535, 3726, 3727, 65535, 65535, 65535, 65535, 65535, 3728, 65535, + 65535, 65535, 3729, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3730, 3731, 65535, + 65535, 65535, 65535, 3732, 65535, 65535, 65535, 3733, 3734, 65535, 65535, + 3735, 3736, 3737, 65535, 65535, 3738, 65535, 3739, 3740, 3741, 65535, 3742, + 65535, 65535, 65535, 3743, 65535, 65535, 65535, 65535, 3744, 3745, 65535, + 65535, 65535, 65535, 3746, 3747, 3748, 3749, 65535, 65535, 65535, 65535, + 65535, 3750, 3751, 3752, 65535, 65535, 65535, 65535, 3753, 3754, 65535, + 65535, 65535, 65535, 65535, 3755, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3756, 65535, 3757, 3758, 65535, 3759, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3760, 65535, 65535, 65535, 3761, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3762, 3763, 65535, 65535, 65535, 65535, + 65535, 65535, 3764, 65535, 65535, 65535, 65535, 3765, 65535, 65535, 65535, + 3766, 65535, 65535, 3767, 3768, 65535, 65535, 3769, 65535, 65535, 65535, + 65535, 3770, 3771, 3772, 65535, 65535, 65535, 65535, 65535, 3773, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3774, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3775, 65535, 65535, 3776, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3777, + 65535, 65535, 65535, 65535, 3778, 65535, 65535, 3779, 65535, 3780, 65535, + 65535, 3781, 65535, 65535, 65535, 65535, 65535, 65535, 3782, 3783, 65535, + 65535, 65535, 3784, 3785, 3786, 3787, 65535, 65535, 3792, 65535, 65535, + 65535, 65535, 65535, 3788, 3789, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3790, 3791, 65535, 65535, 65535, 65535, 65535, 3793, 3794, 65535, + 65535, 65535, 65535, 65535, 65535, 3795, 65535, 3796, 65535, 65535, 65535, + 65535, 65535, 65535, 3797, 3798, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3799, 65535, 65535, 3800, 65535, 65535, 65535, 3801, 3802, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3803, 3804, 3805, 3806, 3807, 65535, 65535, 3808, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3809, 65535, 65535, 65535, + 65535, 65535, 65535, 3810, 65535, 65535, 65535, 65535, 3811, 3812, 65535, + 65535, 3813, 65535, 65535, 3814, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3815, 65535, 65535, 65535, 65535, 65535, 65535, 3816, 65535, + 3817, 3818, 3819, 3820, 65535, 3821, 65535, 65535, 65535, 3822, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3823, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3824, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3825, 3826, 3827, 3828, 3829, 65535, + 65535, 65535, 3830, 3831, 65535, 65535, 3832, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3833, + 65535, 3834, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3835, 65535, 3836, 65535, 3837, 3838, 3839, 65535, 65535, 65535, + 65535, 65535, 65535, 3840, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3841, 65535, 65535, 65535, 3842, 3843, 3844, 65535, 65535, 3845, + 3846, 65535, 65535, 65535, 65535, 3847, 65535, 3848, 65535, 65535, 65535, + 65535, 3849, 65535, 65535, 3850, 65535, 3851, 65535, 3852, 65535, 3853, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3854, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3855, 65535, 65535, 65535, 65535, 65535, 65535, 3856, + 65535, 65535, 65535, 65535, 3857, 65535, 3858, 65535, 65535, 65535, 65535, + 3859, 65535, 65535, 65535, 65535, 65535, 3860, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3861, 3862, 65535, 65535, 65535, 65535, 3863, 65535, + 3864, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3865, 3866, 65535, 3867, 3868, 65535, 65535, 65535, 65535, + 65535, 65535, 3869, 65535, 65535, 65535, 65535, 3870, 3871, 3872, 65535, + 65535, 3873, 65535, 65535, 65535, 65535, 65535, 65535, 3874, 3875, 65535, + 65535, 65535, 65535, 65535, 65535, 3876, 65535, 65535, 3877, 65535, 65535, + 3878, 3879, 65535, 3880, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3881, + 65535, 65535, 65535, 65535, 65535, 3882, 65535, 3883, 65535, 65535, 65535, + 65535, 65535, 65535, 3884, 3885, 3886, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3887, 65535, 65535, 65535, 3888, 65535, 65535, + 3889, 65535, 65535, 3890, 65535, 3891, 65535, 65535, 65535, 65535, 3892, + 65535, 65535, 65535, 65535, 65535, 65535, 3893, 65535, 65535, 65535, 3894, + 65535, 65535, 65535, 65535, 3895, 65535, 65535, 65535, 3896, 3897, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3898, 3899, 3900, 65535, 3901, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3902, 3903, 3904, + 65535, 65535, 3905, 65535, 3906, 3907, 65535, 65535, 65535, 3908, 65535, + 3909, 65535, 3910, 65535, 3911, 65535, 65535, 3912, 65535, 65535, 65535, + 65535, 3913, 65535, 65535, 3914, 65535, 65535, 3915, 3916, 65535, 3917, + 65535, 65535, 65535, 65535, 65535, 3918, 3919, 65535, 65535, 3920, 3921, + 65535, 65535, 3922, 65535, 65535, 65535, 65535, 3923, 65535, 65535, 65535, + 65535, 3924, 65535, 65535, 65535, 3925, 3926, 65535, 65535, 65535, 65535, + 3927, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3928, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3929, + 65535, 65535, 65535, 65535, 3930, 3931, 65535, 65535, 3932, 65535, 65535, + 3933, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3934, + 65535, 65535, 3935, 65535, 65535, 65535, 65535, 65535, 3936, 65535, 3937, + 65535, 65535, 3938, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3939, 3940, 65535, 3941, 65535, 65535, 65535, 65535, 65535, 65535, 3942, + 65535, 65535, 65535, 65535, 65535, 3943, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3944, 3945, 65535, + 65535, 65535, 65535, 65535, 3946, 3947, 65535, 65535, 3948, 65535, 65535, + 65535, 3949, 65535, 3950, 3951, 65535, 3952, 65535, 65535, 65535, 3953, + 65535, 3954, 65535, 65535, 65535, 65535, 3955, 3956, 65535, 65535, 65535, + 65535, 3957, 3958, 65535, 65535, 65535, 65535, 3959, 65535, 65535, 65535, + 3960, 65535, 3961, 65535, 65535, 3962, 3963, 65535, 65535, 65535, 3964, + 65535, 65535, 65535, 65535, 3965, 3966, 65535, 65535, 3967, 65535, 65535, + 65535, 65535, 3968, 3969, 65535, 3970, 65535, 65535, 65535, 65535, 65535, + 3971, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3972, + 65535, 65535, 3973, 65535, 3974, 65535, 65535, 65535, 3975, 65535, 3976, + 65535, 65535, 65535, 65535, 3977, 3978, 3979, 3980, 65535, 65535, 65535, + 65535, 65535, 3981, 3982, 65535, 3983, 65535, 3984, 3985, 65535, 3986, + 3987, 65535, 3988, 65535, 65535, 65535, 65535, 65535, 3989, 65535, 3990, + 65535, 65535, 3991, 65535, 65535, 65535, 3992, 3993, 65535, 3994, 65535, + 3995, 3996, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3997, 65535, + 3998, 65535, 65535, 3999, 65535, 4000, 65535, 4001, 4002, 65535, 65535, + 65535, 4003, 65535, 4004, 4005, 4006, 65535, 4007, 65535, 65535, 4008, + 4009, 65535, 65535, 65535, 4010, 4011, 65535, 4012, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4013, 65535, 4014, 65535, 4015, 65535, 65535, + 4016, 4017, 65535, 4018, 65535, 65535, 65535, 65535, 65535, 4019, 4020, + 65535, 65535, 4021, 65535, 4022, 4023, 65535, 65535, 4024, 65535, 65535, + 4025, 4026, 65535, 65535, 4027, 65535, 65535, 4028, 65535, 65535, 65535, + 4029, 65535, 65535, 65535, 4030, 65535, 4031, 65535, 65535, 4032, 4033, + 65535, 4034, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4035, 4036, 65535, 4037, 65535, 4038, 4039, 4040, 65535, 4041, + 65535, 4042, 4043, 4044, 65535, 65535, 4045, 65535, 65535, 4046, 65535, + 65535, 4047, 65535, 65535, 65535, 65535, 65535, 65535, 4048, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4049, 4050, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4051, 65535, 4052, 65535, 4053, 4054, + 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4063, 65535, 65535, 65535, 65535, 65535, 65535, 4064, + 65535, 65535, 4065, 4066, 65535, 4067, 4068, 65535, 65535, 65535, 4069, + 65535, 4070, 65535, 65535, 65535, 4071, 4072, 65535, 65535, 65535, 65535, + 4073, 65535, 65535, 65535, 65535, 65535, 4074, 65535, 65535, 65535, 65535, + 4075, 65535, 65535, 65535, 4076, 4077, 4078, 65535, 65535, 4079, 65535, + 4080, 4081, 65535, 65535, 4082, 4083, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4084, 4085, 65535, + 65535, 65535, 4086, 4087, 4088, 65535, 4089, 65535, 65535, 65535, 65535, + 65535, 4090, 4091, 4092, 4093, 65535, 65535, 65535, 65535, 65535, 4094, + 4095, 4096, 65535, 4097, 65535, 65535, 4098, 4099, 4100, 65535, 4101, + 65535, 65535, 4102, 65535, 4103, 4104, 4105, 4106, 65535, 65535, 4107, + 4108, 65535, 4109, 4110, 65535, 65535, 4111, 65535, 65535, 65535, 4112, + 65535, 4113, 65535, 65535, 65535, 4114, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4115, 4116, 65535, 65535, 4117, 65535, 65535, 65535, + 4118, 65535, 65535, 4119, 65535, 65535, 65535, 65535, 4120, 65535, 4121, + 4122, 65535, 65535, 4123, 4124, 65535, 65535, 65535, 65535, 4125, 65535, + 65535, 65535, 4126, 65535, 4127, 4128, 65535, 65535, 65535, 4129, 65535, + 65535, 65535, 65535, 4130, 65535, 65535, 65535, 65535, 65535, 4131, 4132, + 4133, 65535, 65535, 4134, 65535, 65535, 65535, 65535, 65535, 65535, 4135, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4136, 65535, 65535, 65535, 4137, 4138, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4139, 4140, 65535, 65535, 4141, 65535, 65535, + 4142, 65535, 4143, 4144, 65535, 65535, 65535, 65535, 4145, 65535, 65535, + 65535, 65535, 65535, 65535, 4146, 65535, 65535, 4147, 65535, 65535, 65535, + 4148, 4149, 4150, 4151, 65535, 65535, 4152, 65535, 65535, 65535, 4153, + 4154, 65535, 65535, 65535, 65535, 65535, 4155, 65535, 4156, 65535, 4157, + 65535, 65535, 65535, 65535, 4158, 65535, 65535, 65535, 65535, 65535, 65535, + 4159, 4160, 65535, 4161, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4162, 65535, 4163, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4164, 4165, 4166, 4167, 4168, 4169, + 65535, 65535, 4170, 65535, 65535, 65535, 4171, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4172, 65535, 4173, 4174, 65535, + 4175, 65535, 65535, 65535, 4176, 65535, 65535, 4177, 65535, 65535, 65535, + 65535, 65535, 4178, 65535, 4179, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4180, 65535, + 65535, 65535, 65535, 65535, 4181, 65535, 65535, 65535, 65535, 4182, 4183, + 4184, 65535, 65535, 4185, 65535, 4186, 65535, 65535, 65535, 65535, 65535, + 4187, 65535, 4188, 4189, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4190, 65535, 65535, 65535, 65535, 4191, 65535, 65535, 4192, 4193, 4194, + 65535, 65535, 4195, 65535, 65535, 4196, 65535, 65535, 65535, 65535, 4197, + 65535, 4198, 4199, 65535, 4200, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4201, 65535, 65535, 65535, 65535, 65535, 65535, 4202, 65535, 4203, + 4204, 4205, 65535, 65535, 4206, 4207, 65535, 4208, 65535, 4209, 65535, + 65535, 4210, 65535, 65535, 4211, 4212, 65535, 4213, 4214, 65535, 65535, + 4215, 65535, 4216, 4217, 4218, 4219, 65535, 65535, 65535, 65535, 4220, + 65535, 4221, 4222, 65535, 65535, 4223, 65535, 65535, 65535, 4224, 65535, + 65535, 65535, 65535, 4225, 4226, 65535, 4227, 65535, 65535, 4228, 4229, + 4230, 65535, 4231, 65535, 65535, 65535, 4233, 4234, 65535, 4235, 4236, + 4237, 65535, 65535, 65535, 4238, 4232, 4239, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4240, 65535, 65535, 65535, 4241, 65535, + 65535, 65535, 65535, 65535, 4242, 65535, 65535, 65535, 65535, 4243, 4244, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4245, 4246, 4247, 65535, + 4248, 65535, 65535, 4249, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4250, 65535, 65535, 65535, 4251, 65535, + 65535, 65535, 65535, 65535, 65535, 4252, 4253, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4254, 65535, 65535, 65535, 65535, 65535, 4255, 4256, + 4257, 65535, 4258, 4259, 65535, 4260, 4261, 4262, 4263, 4264, 4265, 4266, + 65535, 4267, 65535, 65535, 4268, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4269, 65535, + 65535, 65535, 4270, 65535, 65535, 65535, 4271, 65535, 65535, 65535, 4272, + 65535, 4273, 4274, 65535, 4275, 65535, 65535, 65535, 65535, 65535, 4276, + 65535, 65535, 65535, 65535, 4277, 65535, 65535, 65535, 65535, 65535, 65535, + 4278, 65535, 65535, 65535, 65535, 65535, 4279, 65535, 4280, 65535, 65535, + 65535, 4281, 65535, 65535, 65535, 4282, 4283, 65535, 65535, 65535, 65535, + 4284, 65535, 65535, 4285, 65535, 65535, 4286, 65535, 65535, 65535, 4287, + 65535, 65535, 65535, 65535, 65535, 4288, 65535, 65535, 65535, 4289, 65535, + 65535, 65535, 4290, 65535, 65535, 65535, 4291, 65535, 4292, 4293, 65535, + 4294, 65535, 4295, 4296, 65535, 4297, 65535, 65535, 65535, 65535, 65535, + 4298, 65535, 65535, 65535, 65535, 65535, 4299, 65535, 65535, 65535, 65535, + 4300, 4301, 4302, 65535, 65535, 65535, 65535, 4303, 4304, 4305, 65535, + 65535, 4306, 65535, 65535, 65535, 4307, 4308, 65535, 65535, 65535, 4309, + 65535, 65535, 4310, 4311, 65535, 65535, 65535, 4312, 65535, 65535, 4313, + 4314, 4315, 65535, 65535, 4316, 65535, 65535, 65535, 4317, 4318, 65535, + 65535, 65535, 65535, 4319, 65535, 4320, 4321, 4322, 65535, 4323, 65535, + 4324, 65535, 65535, 4325, 65535, 65535, 4326, 65535, 4327, 65535, 65535, + 65535, 4328, 65535, 4329, 4330, 4331, 65535, 65535, 65535, 65535, 65535, + 4332, 65535, 65535, 4333, 65535, 65535, 4334, 65535, 65535, 65535, 4335, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4336, 4337, 65535, 65535, + 65535, 65535, 65535, 65535, 4338, 4339, 4340, 65535, 65535, 65535, 4341, + 65535, 65535, 65535, 65535, 4342, 65535, 65535, 4343, 65535, 65535, 65535, + 65535, 4344, 65535, 65535, 4345, 65535, 65535, 65535, 4346, 4347, 65535, + 4348, 65535, 65535, 65535, 4349, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4350, 65535, 65535, 65535, 65535, 4351, 65535, 65535, 65535, + 65535, 65535, 4352, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4353, + 4354, 65535, 65535, 4355, 65535, 65535, 65535, 4356, 65535, 65535, 65535, + 65535, 4357, 4358, 4359, 65535, 65535, 65535, 4360, 65535, 4361, 65535, + 65535, 65535, 4362, 65535, 4363, 65535, 65535, 65535, 4364, 4365, 65535, + 65535, 4366, 65535, 65535, 65535, 4367, 65535, 65535, 4368, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4369, 4370, 65535, 65535, + 4371, 65535, 65535, 65535, 4372, 4373, 65535, 65535, 4374, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4375, 65535, + 65535, 65535, 4376, 4377, 4378, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4379, 4380, 65535, 4381, 65535, 65535, 65535, 65535, + 4382, 65535, 4383, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4384, 4385, 65535, 65535, 4386, 4387, 65535, 65535, + 65535, 4388, 65535, 4389, 65535, 65535, 65535, 4390, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4391, 65535, 4392, 65535, 4393, + 4394, 65535, 4395, 4396, 65535, 65535, 65535, 4397, 65535, 4398, 65535, + 65535, 65535, 4399, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4400, 65535, 65535, 65535, 4401, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4402, 65535, 65535, + 65535, 65535, 4403, 65535, 65535, 65535, 65535, 4404, 65535, 65535, 65535, + 4405, 65535, 65535, 65535, 65535, 4407, 4408, 4409, 65535, 4406, 65535, + 65535, 4410, 65535, 65535, 65535, 4411, 65535, 65535, 65535, 4412, 4413, + 65535, 65535, 4414, 4415, 4416, 4417, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4418, 65535, 4419, 65535, 4420, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4421, 4422, 4423, 65535, 65535, 4424, 65535, 4425, + 65535, 65535, 65535, 4426, 4427, 65535, 4428, 4429, 65535, 65535, 65535, + 65535, 4431, 65535, 65535, 65535, 4432, 4433, 4434, 65535, 65535, 4430, + 65535, 4435, 65535, 65535, 65535, 4436, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4437, 4438, 65535, 65535, 4440, 4441, 65535, 65535, 4442, + 4443, 65535, 65535, 65535, 4444, 4439, 65535, 65535, 65535, 65535, 65535, + 4445, 65535, 65535, 65535, 65535, 65535, 4446, 65535, 65535, 65535, 4447, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4448, 65535, + 4449, 65535, 4450, 4451, 4452, 65535, 65535, 65535, 65535, 4453, 65535, + 4454, 65535, 4455, 65535, 65535, 65535, 4456, 65535, 65535, 65535, 4457, + 65535, 65535, 4458, 4459, 65535, 65535, 65535, 65535, 65535, 4460, 65535, + 4461, 65535, 4462, 65535, 65535, 65535, 65535, 4463, 4464, 4465, 65535, + 65535, 65535, 4466, 4467, 65535, 65535, 65535, 4468, 65535, 4469, 65535, + 65535, 4470, 65535, 65535, 65535, 4471, 65535, 65535, 4472, 4473, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4474, 65535, + 4475, 65535, 4476, 65535, 65535, 65535, 65535, 65535, 65535, 4477, 65535, + 65535, 65535, 65535, 65535, 65535, 4478, 65535, 4479, 4480, 65535, 4481, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4482, 4483, 65535, 65535, 65535, 65535, 4484, 65535, 4485, + 4486, 4487, 4488, 65535, 4489, 65535, 65535, 4490, 4491, 65535, 65535, + 65535, 65535, 4492, 65535, 65535, 65535, 65535, 65535, 65535, 4493, 4494, + 65535, 4495, 65535, 65535, 65535, 4496, 65535, 4497, 65535, 65535, 4498, + 65535, 65535, 65535, 4499, 65535, 65535, 4500, 65535, 65535, 65535, 65535, + 65535, 65535, 4501, 65535, 4502, 65535, 65535, 4503, 4504, 65535, 4505, + 65535, 65535, 65535, 65535, 4506, 65535, 65535, 65535, 65535, 4507, 65535, + 4508, 65535, 65535, 65535, 4509, 65535, 65535, 4510, 4511, 65535, 4512, + 65535, 4513, 65535, 65535, 4514, 65535, 65535, 65535, 65535, 4515, 4516, + 65535, 4517, 65535, 65535, 65535, 4518, 65535, 65535, 65535, 65535, 65535, + 65535, 4519, 65535, 65535, 65535, 4520, 65535, 65535, 65535, 65535, 65535, + 4521, 4522, 65535, 65535, 65535, 4523, 65535, 4524, 4525, 65535, 4526, + 65535, 65535, 65535, 65535, 4527, 65535, 65535, 65535, 4528, 65535, 65535, + 65535, 65535, 65535, 4529, 65535, 65535, 4530, 65535, 65535, 4531, 65535, + 65535, 65535, 65535, 65535, 4532, 65535, 65535, 65535, 4533, 65535, 4534, + 65535, 4535, 4536, 65535, 65535, 65535, 4537, 4538, 65535, 65535, 4539, + 4540, 4541, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4542, 4543, 65535, 4544, 4545, 65535, 65535, 65535, 4546, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4547, 4548, 65535, 65535, 4549, + 65535, 65535, 4550, 4551, 65535, 4552, 4553, 65535, 65535, 65535, 65535, + 4554, 65535, 4555, 65535, 65535, 4556, 65535, 65535, 4557, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4558, 65535, 65535, 4559, 65535, 65535, + 65535, 65535, 65535, 4560, 65535, 4561, 65535, 4562, 65535, 65535, 4563, + 4564, 65535, 65535, 65535, 4565, 4566, 65535, 65535, 65535, 65535, 4567, + 4568, 65535, 65535, 4569, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4570, 65535, 4571, 65535, 65535, 4572, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4573, 65535, 65535, 65535, 65535, 65535, + 65535, 4574, 65535, 4575, 65535, 65535, 65535, 4576, 65535, 4577, 4578, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4579, 65535, + 65535, 4580, 65535, 65535, 4581, 65535, 4582, 65535, 65535, 4583, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4584, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4585, + 4586, 65535, 4587, 4588, 65535, 65535, 65535, 65535, 4589, 65535, 65535, + 4590, 65535, 65535, 65535, 65535, 65535, 65535, 4591, 65535, 4592, 4593, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4594, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4595, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4596, + 65535, 65535, 65535, 4597, 65535, 65535, 65535, 4598, 65535, 4599, 4600, + 4601, 65535, 4602, 4603, 4604, 4605, 4606, 65535, 65535, 4607, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4608, 65535, 4609, 4610, + 4611, 65535, 65535, 65535, 65535, 65535, 4612, 65535, 65535, 65535, 65535, + 65535, 65535, 4613, 65535, 65535, 65535, 65535, 65535, 65535, 4614, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4615, 65535, + 65535, 65535, 4616, 65535, 4617, 65535, 65535, 4618, 4619, 65535, 65535, + 4620, 65535, 4621, 65535, 65535, 4622, 4623, 65535, 65535, 65535, 4624, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4625, 65535, 65535, 65535, 65535, 4626, 65535, 65535, 65535, + 65535, 4627, 65535, 4628, 4629, 65535, 65535, 65535, 65535, 4630, 65535, + 65535, 65535, 65535, 4631, 65535, 65535, 4632, 65535, 4633, 65535, 65535, + 65535, 65535, 4634, 65535, 65535, 65535, 65535, 65535, 65535, 4635, 65535, + 65535, 4636, 4637, 65535, 4638, 65535, 65535, 4639, 4640, 65535, 65535, + 65535, 4641, 4642, 4643, 4644, 65535, 65535, 65535, 65535, 4645, 65535, + 65535, 4646, 65535, 65535, 4647, 65535, 4648, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4649, 65535, 4650, 4651, 65535, 4652, + 4653, 4654, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4655, 65535, 4656, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4657, 65535, 4658, 4659, 65535, 65535, 4660, 4661, 4662, + 65535, 4663, 65535, 4664, 65535, 65535, 4665, 4666, 4667, 4668, 65535, + 4669, 65535, 65535, 4670, 65535, 4671, 4672, 65535, 4673, 4674, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4675, 65535, 4676, + 65535, 65535, 65535, 65535, 4677, 65535, 65535, 65535, 65535, 4678, 4679, + 65535, 4680, 65535, 65535, 65535, 4681, 65535, 65535, 65535, 65535, 4682, + 65535, 4683, 4684, 65535, 4685, 65535, 65535, 4686, 4687, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4688, 65535, + 65535, 65535, 4689, 65535, 65535, 65535, 65535, 65535, 65535, 4691, 4692, + 4693, 65535, 4690, 65535, 65535, 65535, 4694, 4695, 4696, 4697, 4698, 4699, + 65535, 65535, 4700, 65535, 4701, 65535, 65535, 65535, 4702, 65535, 4703, + 65535, 65535, 65535, 4704, 4705, 65535, 4706, 65535, 4707, 65535, 65535, + 65535, 65535, 65535, 65535, 4708, 65535, 65535, 4709, 4710, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4711, 4712, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4713, 65535, 65535, 65535, 65535, 4714, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4715, 65535, 4716, + 65535, 65535, 65535, 65535, 65535, 4717, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4718, 65535, 65535, 65535, 65535, 65535, 4719, + 4720, 65535, 65535, 4721, 4722, 4723, 65535, 65535, 4724, 65535, 65535, + 65535, 65535, 4725, 65535, 65535, 4726, 4727, 4728, 65535, 65535, 65535, + 4729, 65535, 4730, 65535, 65535, 65535, 4731, 4732, 4733, 65535, 4734, + 65535, 4735, 4736, 65535, 65535, 4737, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4738, 65535, 65535, 4739, 65535, 4740, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4741, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4742, + 65535, 65535, 65535, 4743, 4744, 4745, 65535, 65535, 65535, 65535, 65535, + 4746, 65535, 4747, 4748, 4749, 65535, 65535, 4750, 65535, 65535, 65535, + 65535, 65535, 65535, 4751, 4752, 65535, 65535, 65535, 65535, 4753, 65535, + 65535, 4754, 65535, 65535, 65535, 4755, 65535, 65535, 4756, 65535, 65535, + 65535, 4757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4758, 4759, 4760, 65535, 4761, 4762, 65535, 65535, 65535, 65535, + 65535, 4763, 4764, 65535, 65535, 65535, 65535, 4765, 65535, 65535, 65535, + 4766, 65535, 4767, 65535, 65535, 65535, 4768, 65535, 4769, 4770, 65535, + 4771, 4772, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4773, 65535, + 4774, 65535, 65535, 4775, 65535, 65535, 65535, 65535, 65535, 4776, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4777, 65535, 4778, 4779, 65535, + 65535, 65535, 4780, 65535, 4781, 4782, 4783, 65535, 4784, 4785, 65535, + 4786, 65535, 65535, 4787, 4788, 4789, 65535, 65535, 65535, 4790, 65535, + 65535, 65535, 65535, 4791, 4792, 65535, 65535, 65535, 65535, 65535, 4793, + 4794, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4795, 4796, 65535, + 65535, 4797, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4798, + 65535, 65535, 4799, 4800, 65535, 4801, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4802, 4803, 4804, 4805, 4806, 65535, 65535, 65535, + 65535, 65535, 4807, 4808, 4809, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4810, 65535, 4811, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4813, 65535, 65535, 4814, 4815, 65535, 65535, 65535, 4816, + 4817, 65535, 4818, 65535, 65535, 65535, 4819, 65535, 65535, 65535, 4820, + 4821, 65535, 65535, 4822, 4823, 65535, 65535, 65535, 65535, 65535, 4812, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4824, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4825, 4826, 65535, 65535, 65535, 4827, 65535, + 4828, 65535, 65535, 65535, 65535, 4829, 4830, 65535, 65535, 4831, 65535, + 65535, 65535, 65535, 65535, 65535, 4832, 4833, 65535, 65535, 65535, 4834, + 4835, 65535, 4836, 65535, 65535, 65535, 4837, 65535, 65535, 4838, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4839, 65535, 65535, 65535, + 65535, 4840, 4841, 65535, 4842, 65535, 65535, 65535, 65535, 65535, 65535, + 4843, 65535, 4844, 65535, 4845, 65535, 65535, 65535, 65535, 65535, 4846, + 65535, 65535, 65535, 65535, 65535, 65535, 4847, 65535, 4848, 4849, 65535, + 65535, 4850, 65535, 65535, 65535, 65535, 65535, 4851, 65535, 65535, 4852, + 4853, 65535, 65535, 65535, 4854, 65535, 65535, 65535, 65535, 4855, 65535, + 65535, 65535, 65535, 65535, 4856, 65535, 65535, 4857, 65535, 65535, 65535, + 65535, 4858, 4859, 65535, 65535, 4860, 65535, 65535, 4861, 65535, 65535, + 65535, 4862, 65535, 65535, 65535, 4863, 65535, 65535, 4864, 65535, 4865, + 65535, 65535, 4866, 4867, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4869, 4868, 4870, 4871, 4872, 65535, + 65535, 65535, 4873, 4874, 65535, 65535, 4875, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4876, 65535, 65535, 4877, 4878, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4879, 4880, 4881, 65535, 65535, 65535, 4882, + 65535, 4883, 4884, 4885, 4886, 65535, 65535, 65535, 65535, 65535, 65535, + 4887, 65535, 65535, 65535, 4888, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4889, 4890, 4891, 4892, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4893, 65535, 4894, + 65535, 4895, 4896, 4897, 65535, 65535, 65535, 65535, 4898, 4899, 65535, + 65535, 65535, 65535, 4900, 65535, 65535, 65535, 65535, 4901, 4902, 65535, + 65535, 65535, 4903, 65535, 65535, 65535, 4904, 65535, 65535, 4905, 65535, + 65535, 65535, 65535, 65535, 65535, 4906, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4907, 65535, 65535, 4908, 4909, 65535, 65535, 4910, 65535, + 65535, 65535, 65535, 4911, 65535, 65535, 65535, 65535, 65535, 4912, 4913, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4914, 65535, 65535, 65535, 4915, 65535, 65535, 65535, 4916, 65535, + 4917, 65535, 65535, 4918, 65535, 65535, 65535, 4919, 65535, 4920, 4921, + 65535, 65535, 4922, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4923, + 65535, 65535, 4924, 4925, 4926, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4927, 4928, 65535, 4929, 65535, 65535, 4930, 4931, 4932, 65535, + 4933, 65535, 4934, 4935, 65535, 4936, 65535, 65535, 65535, 65535, 65535, + 65535, 4937, 4938, 4939, 4940, 65535, 65535, 65535, 4941, 65535, 4942, + 65535, 65535, 65535, 65535, 65535, 4943, 65535, 4944, 65535, 4945, 65535, + 65535, 65535, 4946, 4947, 65535, 4948, 65535, 4949, 4950, 65535, 4951, + 65535, 4952, 65535, 4953, 65535, 65535, 65535, 4954, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4955, 65535, 65535, 65535, 4956, 65535, 4957, + 65535, 65535, 65535, 65535, 65535, 65535, 4958, 65535, 65535, 65535, 4959, + 65535, 65535, 65535, 4960, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4961, 65535, 65535, 65535, 65535, 65535, 65535, + 4962, 65535, 65535, 65535, 65535, 65535, 4963, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4964, 65535, + 4965, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4966, 4967, 65535, + 65535, 65535, 4968, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4969, 4970, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4971, 65535, + 65535, 65535, 65535, 4972, 65535, 4973, 65535, 65535, 4974, 65535, 4975, + 4976, 65535, 4977, 4978, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4979, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4980, 4981, 65535, 4982, 65535, 4983, 4984, 65535, 65535, + 4985, 65535, 65535, 4986, 4987, 65535, 65535, 65535, 4988, 65535, 65535, + 65535, 65535, 4989, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4990, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4991, + 4992, 4993, 65535, 65535, 65535, 4994, 65535, 4995, 65535, 4996, 65535, + 65535, 65535, 4997, 65535, 65535, 4998, 65535, 65535, 65535, 65535, 4999, + 65535, 65535, 65535, 5000, 65535, 65535, 65535, 65535, 5001, 65535, 65535, + 65535, 65535, 5002, 65535, 5003, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5004, 65535, 5005, 65535, 65535, 5006, 65535, 5007, 65535, + 65535, 65535, 65535, 65535, 5008, 65535, 65535, 65535, 65535, 5009, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5010, 5011, 65535, 65535, + 65535, 65535, 65535, 5012, 5013, 5014, 65535, 65535, 65535, 5015, 65535, + 5016, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5017, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5018, 65535, 65535, 5020, + 5021, 5022, 65535, 65535, 65535, 65535, 5023, 65535, 65535, 5024, 65535, + 5019, 65535, 65535, 65535, 65535, 65535, 5025, 65535, 5026, 65535, 65535, + 5027, 65535, 65535, 5028, 65535, 65535, 65535, 5029, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5030, 65535, 65535, + 65535, 5031, 65535, 5032, 65535, 65535, 65535, 65535, 65535, 65535, 5033, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5035, 65535, 5036, 65535, + 65535, 65535, 65535, 5037, 5034, 65535, 65535, 5038, 5039, 65535, 65535, + 65535, 65535, 65535, 5040, 65535, 5041, 65535, 65535, 65535, 5042, 65535, + 5043, 5044, 65535, 65535, 5045, 65535, 65535, 5046, 65535, 65535, 65535, + 65535, 65535, 65535, 5047, 5048, 65535, 65535, 65535, 5049, 5050, 5051, + 65535, 65535, 5052, 5053, 65535, 5054, 5055, 65535, 65535, 65535, 5056, + 65535, 5057, 5058, 65535, 65535, 5059, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5060, 65535, 65535, 65535, 5061, + 5062, 65535, 65535, 65535, 65535, 5063, 5064, 65535, 65535, 5065, 65535, + 65535, 65535, 5066, 5067, 65535, 65535, 65535, 65535, 65535, 5068, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5069, 65535, 5070, + 65535, 65535, 65535, 65535, 65535, 5071, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5072, 5073, 5074, 5075, 65535, 65535, 65535, 65535, + 5076, 65535, 65535, 5077, 5078, 65535, 5079, 65535, 65535, 65535, 65535, + 5080, 65535, 65535, 65535, 65535, 65535, 5081, 65535, 65535, 65535, 5082, + 65535, 65535, 5083, 65535, 65535, 65535, 5084, 65535, 65535, 65535, 65535, + 65535, 5085, 65535, 65535, 65535, 65535, 65535, 65535, 5086, 65535, 65535, + 65535, 65535, 65535, 65535, 5087, 65535, 5088, 65535, 5089, 5090, 5091, + 65535, 5092, 5093, 65535, 65535, 5094, 65535, 5095, 5096, 65535, 65535, + 65535, 5097, 65535, 65535, 5098, 65535, 65535, 5099, 65535, 5100, 65535, + 5101, 65535, 5102, 5103, 65535, 65535, 65535, 65535, 5104, 5105, 65535, + 5106, 5107, 65535, 65535, 5108, 5109, 5110, 5111, 65535, 65535, 65535, + 5112, 65535, 5113, 65535, 5114, 65535, 5115, 65535, 65535, 5116, 65535, + 65535, 5117, 65535, 5118, 65535, 5119, 5120, 65535, 65535, 65535, 65535, + 65535, 65535, 5121, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5122, 65535, 65535, 65535, 65535, 5123, 65535, 65535, 65535, 65535, + 5124, 65535, 65535, 65535, 65535, 65535, 5125, 65535, 5126, 65535, 5127, + 65535, 65535, 65535, 5128, 65535, 5129, 65535, 65535, 5130, 65535, 5131, + 65535, 65535, 65535, 65535, 65535, 65535, 5132, 5133, 65535, 65535, 65535, + 65535, 65535, 5134, 5135, 65535, 5136, 5137, 65535, 65535, 65535, 65535, + 65535, 5138, 5139, 65535, 5140, 5141, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5143, + 65535, 5144, 5145, 5146, 65535, 5147, 5148, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5149, 5150, 5151, 65535, 5152, 65535, + 65535, 5153, 65535, 65535, 65535, 5154, 65535, 65535, 5155, 65535, 5156, + 5157, 65535, 65535, 65535, 65535, 5158, 5159, 5160, 65535, 65535, 5161, + 65535, 65535, 65535, 65535, 65535, 5162, 5163, 65535, 65535, 5164, 65535, + 5199, 5142, 5165, 5166, 5167, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5168, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5169, 65535, 65535, 65535, 65535, 5170, + 65535, 5171, 5172, 65535, 5173, 65535, 5174, 65535, 5175, 65535, 65535, + 65535, 65535, 65535, 65535, 5176, 65535, 65535, 65535, 65535, 5177, 65535, + 5178, 5179, 65535, 65535, 5180, 5181, 65535, 5182, 5183, 5184, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5185, 5186, 65535, 5187, + 65535, 65535, 5188, 5213, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5189, 5190, + 5191, 65535, 65535, 65535, 65535, 65535, 65535, 5192, 65535, 5193, 65535, + 65535, 65535, 65535, 65535, 5194, 5195, 5196, 65535, 65535, 5197, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5198, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5200, 65535, 5201, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5202, + 65535, 5203, 5204, 65535, 65535, 5205, 65535, 65535, 65535, 65535, 5206, + 65535, 65535, 65535, 65535, 5207, 65535, 65535, 65535, 5208, 65535, 65535, + 65535, 65535, 5209, 65535, 5210, 65535, 65535, 65535, 5211, 65535, 65535, + 65535, 5212, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5214, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5215, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5216, 65535, 5217, 5218, 65535, 5219, 65535, 65535, 5220, + 65535, 5221, 65535, 5222, 5223, 65535, 65535, 65535, 5224, 65535, 5225, + 5226, 5227, 65535, 5228, 65535, 65535, 65535, 5229, 65535, 65535, 65535, + 5230, 5231, 65535, 5232, 65535, 65535, 5233, 65535, 65535, 65535, 65535, + 65535, 5234, 65535, 65535, 5235, 5236, 65535, 5237, 65535, 5238, 65535, + 65535, 65535, 5239, 5240, 65535, 65535, 65535, 5241, 65535, 65535, 65535, + 5242, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5243, 5244, 65535, 5245, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5246, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5247, 65535, 5248, 5249, 5250, 65535, 65535, 65535, 65535, 5251, 65535, + 5252, 65535, 65535, 5253, 65535, 65535, 65535, 65535, 65535, 5254, 65535, + 65535, 5255, 5256, 65535, 5257, 65535, 5258, 65535, 65535, 65535, 65535, + 5259, 5260, 65535, 65535, 65535, 5261, 65535, 65535, 5262, 65535, 65535, + 65535, 5263, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5264, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5265, + 65535, 65535, 5266, 65535, 65535, 65535, 65535, 5267, 5268, 5269, 5270, + 65535, 65535, 65535, 65535, 5271, 65535, 65535, 5273, 5274, 65535, 5275, + 65535, 65535, 65535, 65535, 5276, 5277, 65535, 65535, 65535, 5278, 65535, + 65535, 65535, 65535, 5279, 65535, 5280, 65535, 5281, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5282, 65535, 5283, + 65535, 65535, 65535, 5284, 5285, 5286, 5287, 65535, 5288, 65535, 65535, + 5289, 5290, 65535, 65535, 65535, 5291, 65535, 65535, 5272, 5292, 5293, + 65535, 5294, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5295, + 65535, 65535, 65535, 65535, 65535, 65535, 5296, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5297, 5298, 5299, 5300, 5301, 65535, 65535, + 5302, 65535, 65535, 5303, 65535, 65535, 5304, 5305, 5306, 5307, 5308, 5309, + 5310, 65535, 5311, 65535, 65535, 65535, 65535, 65535, 65535, 5312, 65535, + 65535, 65535, 5313, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5314, 5315, 5316, 65535, 5317, 65535, 5318, 65535, 5319, 65535, + 65535, 65535, 5320, 5321, 65535, 65535, 5322, 65535, 5323, 5324, 65535, + 65535, 5325, 65535, 65535, 65535, 5326, 65535, 65535, 65535, 65535, 5327, + 65535, 65535, 65535, 65535, 5328, 65535, 5329, 5330, 65535, 5331, 65535, + 65535, 5332, 65535, 5333, 65535, 65535, 65535, 65535, 65535, 5347, 65535, + 65535, 65535, 65535, 65535, 65535, 5334, 65535, 5335, 5336, 5337, 65535, + 65535, 65535, 5338, 5339, 5340, 5341, 65535, 65535, 5342, 65535, 65535, + 65535, 65535, 5343, 65535, 65535, 5344, 5345, 65535, 65535, 5346, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5348, 65535, 5349, + 65535, 65535, 65535, 65535, 5350, 5351, 65535, 65535, 65535, 65535, 65535, + 5352, 65535, 5353, 65535, 65535, 65535, 65535, 5354, 65535, 65535, 65535, + 65535, 65535, 5355, 65535, 65535, 5356, 65535, 65535, 65535, 65535, 65535, + 5357, 65535, 65535, 5358, 5359, 65535, 65535, 65535, 5360, 5361, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5362, 5363, 65535, 5364, 5365, + 5366, 65535, 65535, 65535, 65535, 65535, 5367, 5368, 65535, 5369, 65535, + 65535, 5370, 65535, 65535, 5371, 65535, 65535, 65535, 65535, 65535, 5372, + 65535, 5373, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5374, 65535, 5375, 65535, 5376, 65535, 5377, 5378, + 65535, 65535, 5379, 2231, 5380, 65535, 65535, 65535, 5381, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5382, 5383, + 65535, 65535, 5384, 5385, 5386, 5387, 65535, 65535, 65535, 5388, 65535, + 65535, 5389, 5390, 5391, 5392, 5393, 65535, 65535, 65535, 65535, 5394, + 65535, 65535, 5395, 65535, 65535, 5396, 65535, 65535, 65535, 65535, 65535, + 5397, 5398, 5399, 65535, 65535, 5400, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5434, 65535, 65535, + 65535, 65535, 5401, 65535, 65535, 65535, 5402, 65535, 65535, 65535, 65535, + 5403, 65535, 5404, 65535, 5405, 65535, 5406, 65535, 65535, 65535, 65535, + 5407, 65535, 65535, 65535, 65535, 5408, 5409, 5410, 65535, 65535, 65535, + 65535, 5411, 65535, 65535, 65535, 5412, 65535, 5413, 5414, 5415, 65535, + 5416, 5417, 5418, 65535, 65535, 65535, 65535, 65535, 5419, 5420, 5421, + 65535, 5422, 65535, 5423, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5424, 5425, 65535, 65535, 5426, 65535, 5427, + 65535, 65535, 5428, 65535, 5429, 65535, 65535, 65535, 5430, 65535, 65535, + 5431, 65535, 5432, 65535, 5433, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5435, 65535, 5436, 5437, 65535, 65535, 65535, 65535, 65535, + 65535, 5438, 5439, 65535, 5440, 65535, 65535, 65535, 5441, 65535, 65535, + 5442, 5443, 5444, 65535, 65535, 5445, 5446, 65535, 65535, 65535, 65535, + 5447, 65535, 65535, 65535, 65535, 5448, 5449, 65535, 5450, 65535, 5451, + 65535, 65535, 65535, 65535, 5452, 65535, 65535, 65535, 65535, 65535, 5453, + 5454, 65535, 5455, 5456, 65535, 65535, 65535, 65535, 65535, 65535, 5457, + 5458, 65535, 5459, 5460, 5461, 65535, 5462, 65535, 65535, 5463, 65535, + 5464, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5465, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5466, 65535, 65535, + 65535, 65535, 5467, 65535, 65535, 65535, 5468, 65535, 65535, 5469, 5470, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5471, 65535, + 5472, 5473, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5474, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5475, 5476, 5477, 5478, + 5479, 5480, 5481, 65535, 5482, 5483, 65535, 65535, 65535, 5484, 65535, + 65535, 5485, 65535, 5486, 65535, 5487, 5488, 5489, 65535, 65535, 65535, + 65535, 5490, 65535, 5491, 65535, 65535, 5492, 65535, 65535, 65535, 5493, + 65535, 65535, 65535, 65535, 5494, 5495, 5496, 65535, 65535, 5497, 65535, + 65535, 65535, 5498, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5499, 5500, 65535, 5501, 65535, 65535, 65535, 65535, 65535, 65535, 5502, + 5503, 5504, 65535, 65535, 65535, 5505, 65535, 65535, 65535, 65535, 65535, + 65535, 5506, 5507, 65535, 65535, 5508, 5509, 65535, 5510, 65535, 65535, + 5511, 65535, 65535, 5512, 5513, 5514, 65535, 65535, 65535, 65535, 65535, + 5515, 5516, 65535, 5517, 65535, 65535, 65535, 5518, 65535, 5519, 65535, + 65535, 65535, 65535, 5520, 65535, 5521, 65535, 65535, 65535, 65535, 5522, + 65535, 5523, 65535, 5524, 65535, 65535, 5525, 65535, 65535, 5526, 5527, + 5528, 65535, 65535, 65535, 65535, 5529, 65535, 5531, 5532, 5533, 65535, + 65535, 65535, 5534, 5530, 5535, 5536, 5537, 65535, 5538, 5539, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5540, 65535, 65535, 65535, + 65535, 5541, 5542, 65535, 5543, 65535, 5544, 65535, 65535, 5545, 65535, + 65535, 65535, 65535, 5546, 65535, 5547, 65535, 65535, 65535, 65535, 5548, + 65535, 5549, 65535, 5550, 65535, 65535, 5551, 5552, 5553, 5554, 65535, + 65535, 5555, 65535, 65535, 5556, 65535, 65535, 65535, 5557, 5558, 65535, + 5559, 65535, 5560, 65535, 5561, 65535, 65535, 5562, 5563, 65535, 65535, + 65535, 5564, 65535, 65535, 65535, 65535, 5565, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5566, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5567, 65535, 5568, 65535, 65535, 65535, 65535, 5569, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5570, + 65535, 5571, 5572, 5573, 65535, 65535, 5574, 5575, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5576, 65535, 5577, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5578, 65535, 65535, 5579, 5580, 65535, 5581, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5582, 5583, 5584, 5585, 5586, + 65535, 65535, 5587, 5588, 5589, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5590, 65535, 65535, 5591, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5592, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5593, + 5594, 5595, 65535, 65535, 65535, 5596, 65535, 5597, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5598, 65535, 65535, 65535, 65535, + 5599, 65535, 65535, 65535, 65535, 65535, 65535, 5600, 5601, 5602, 65535, + 65535, 65535, 65535, 65535, 5603, 5604, 65535, 5605, 5606, 5607, 65535, + 5608, 65535, 65535, 65535, 5609, 65535, 65535, 65535, 65535, 65535, 5610, + 5611, 5612, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5613, 5614, + 5615, 65535, 65535, 5616, 65535, 65535, 65535, 5617, 5618, 65535, 65535, + 65535, 5619, 65535, 5620, 65535, 5621, 65535, 65535, 5622, 5623, 65535, + 65535, 5624, 65535, 65535, 65535, 65535, 65535, 5625, 65535, 65535, 5626, + 65535, 65535, 65535, 65535, 5627, 65535, 65535, 5628, 5629, 5630, 65535, + 65535, 65535, 65535, 5631, 5632, 5633, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5634, 65535, 65535, 5635, 65535, 5636, 65535, 65535, 5637, + 65535, 5638, 65535, 65535, 65535, 65535, 5639, 5640, 5641, 5642, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5643, + 65535, 65535, 65535, 5644, 65535, 65535, 5645, 65535, 65535, 65535, 5646, + 5647, 65535, 65535, 65535, 65535, 65535, 5648, 5649, 65535, 65535, 5650, + 5651, 65535, 65535, 65535, 65535, 5652, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5653, 65535, 65535, 65535, 5654, 5655, + 5656, 5657, 65535, 65535, 65535, 65535, 5658, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5659, 5660, + 5661, 5662, 5663, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5664, 65535, 65535, 65535, 5665, 65535, 5666, + 65535, 5667, 65535, 65535, 65535, 5668, 65535, 5669, 65535, 65535, 5670, + 65535, 65535, 5671, 65535, 65535, 65535, 5672, 65535, 5673, 65535, 65535, + 65535, 65535, 5674, 5675, 65535, 5676, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5677, 65535, 5678, 5679, 65535, 5680, 5681, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5682, 65535, 5683, 65535, 5684, + 65535, 5685, 65535, 5686, 65535, 65535, 65535, 65535, 5687, 5688, 65535, + 65535, 5689, 65535, 65535, 65535, 65535, 65535, 5690, 65535, 5691, 65535, + 65535, 65535, 65535, 65535, 5692, 5693, 65535, 5694, 65535, 65535, 5695, + 65535, 5696, 65535, 5697, 65535, 5698, 65535, 65535, 65535, 5699, 5700, + 65535, 65535, 65535, 65535, 5701, 65535, 65535, 5702, 5703, 5704, 65535, + 65535, 65535, 5705, 5706, 65535, 65535, 65535, 5707, 65535, 65535, 65535, + 5708, 65535, 5709, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5710, 5711, 5712, 65535, 5713, 5714, + 5715, 65535, 65535, 5716, 5717, 5718, 65535, 65535, 5719, 65535, 65535, + 5720, 65535, 65535, 65535, 65535, 5721, 65535, 65535, 65535, 5722, 5723, + 65535, 5724, 65535, 65535, 65535, 5725, 5726, 65535, 5727, 65535, 65535, + 65535, 65535, 65535, 5728, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5729, 65535, 5730, 65535, 65535, 65535, 65535, 5731, 5732, 65535, 65535, + 65535, 5733, 65535, 65535, 5734, 5735, 65535, 65535, 65535, 5736, 65535, + 65535, 5737, 65535, 65535, 65535, 65535, 5738, 65535, 65535, 5739, 65535, + 5740, 5741, 5742, 65535, 65535, 65535, 65535, 65535, 65535, 5743, 65535, + 5744, 5745, 5746, 65535, 5747, 65535, 65535, 65535, 65535, 65535, 5748, + 65535, 5749, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5750, 65535, 65535, 65535, 5751, 65535, 65535, 65535, + 5752, 5753, 5754, 65535, 65535, 65535, 65535, 65535, 5755, 65535, 65535, + 5756, 65535, 65535, 65535, 65535, 65535, 5757, 5758, 65535, 65535, 65535, + 5764, 5759, 65535, 65535, 65535, 65535, 65535, 5760, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5761, 65535, 5762, 5763, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5765, 65535, 65535, 5766, 65535, 65535, 65535, 65535, + 65535, 65535, 5767, 65535, 65535, 65535, 65535, 5768, 65535, 65535, 65535, + 65535, 65535, 5769, 5770, 5771, 5772, 5773, 65535, 5774, 65535, 65535, + 65535, 65535, 5779, 65535, 65535, 65535, 65535, 5775, 5776, 5777, 65535, + 65535, 65535, 65535, 5778, 65535, 65535, 65535, 65535, 5780, 65535, 65535, + 65535, 65535, 5781, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5782, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5783, + 65535, 5784, 5785, 65535, 65535, 5786, 65535, 5787, 65535, 65535, 5788, + 65535, 65535, 5789, 5790, 65535, 65535, 65535, 65535, 65535, 5791, 65535, + 5792, 65535, 5793, 65535, 65535, 65535, 65535, 5794, 5795, 65535, 65535, + 65535, 65535, 65535, 65535, 5796, 65535, 5797, 5798, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5799, 5800, 65535, 65535, 65535, 5801, + 5802, 65535, 65535, 65535, 65535, 65535, 65535, 5803, 65535, 5804, 65535, + 5805, 65535, 5806, 65535, 65535, 65535, 5807, 65535, 5808, 65535, 5809, + 5810, 65535, 65535, 5811, 5812, 5815, 65535, 5813, 65535, 5814, 65535, + 65535, 65535, 65535, 65535, 5816, 5817, 65535, 5818, 65535, 5819, 5820, + 65535, 65535, 65535, 5821, 65535, 65535, 65535, 65535, 65535, 5822, 65535, + 5823, 5824, 65535, 65535, 65535, 65535, 5825, 65535, 65535, 5826, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5827, 5828, 65535, 65535, 65535, + 5829, 65535, 65535, 65535, 65535, 5830, 65535, 5831, 5832, 65535, 65535, + 65535, 65535, 65535, 5833, 65535, 5834, 5835, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5836, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5837, 5838, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5839, 5840, 65535, 65535, 5841, 65535, 5842, + 65535, 65535, 65535, 5843, 65535, 65535, 65535, 65535, 65535, 5845, 5844, + 65535, 65535, 5846, 65535, 65535, 65535, 5847, 65535, 65535, 65535, 5848, + 65535, 65535, 65535, 65535, 65535, 65535, 5849, 65535, 65535, 65535, 5850, + 65535, 65535, 5851, 5852, 65535, 5853, 65535, 65535, 5854, 65535, 5855, + 5856, 65535, 65535, 65535, 65535, 65535, 5857, 5858, 65535, 5859, 65535, + 5860, 65535, 65535, 65535, 65535, 65535, 5861, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5862, 65535, 65535, 65535, 65535, 5863, 65535, + 65535, 65535, 5864, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5865, 65535, 65535, 65535, 5866, 65535, + 65535, 5867, 65535, 5868, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5869, 65535, + 65535, 5870, 65535, 5871, 65535, 65535, 65535, 5872, 65535, 65535, 65535, + 65535, 5873, 65535, 65535, 5874, 5875, 65535, 65535, 65535, 5876, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5877, 5878, 5879, 65535, + 65535, 65535, 65535, 65535, 5880, 65535, 65535, 65535, 65535, 5881, 5882, + 65535, 65535, 5883, 65535, 65535, 5884, 65535, 65535, 5885, 65535, 5886, + 65535, 5887, 65535, 5888, 5906, 65535, 65535, 65535, 5889, 65535, 65535, + 65535, 65535, 5890, 5891, 5892, 5893, 65535, 5894, 65535, 65535, 65535, + 5895, 65535, 65535, 5896, 65535, 65535, 5897, 5898, 65535, 5899, 65535, + 5900, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5901, 5902, 65535, 5903, 65535, 65535, 65535, 65535, 5904, 65535, 65535, + 65535, 5905, 5907, 5908, 65535, 5909, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5910, 65535, 65535, 65535, 5911, 65535, 65535, 5912, + 5913, 5914, 65535, 65535, 65535, 65535, 5915, 65535, 65535, 65535, 65535, + 65535, 5916, 65535, 65535, 5917, 65535, 5918, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5919, 5920, 5921, 5922, 65535, 65535, + 5923, 5924, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5925, 65535, 5926, 65535, 65535, 5927, 5928, 5929, 5930, 65535, 65535, + 65535, 5931, 65535, 65535, 5932, 5933, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5934, 65535, 5935, 5936, 5937, 65535, 65535, + 65535, 65535, 5938, 65535, 65535, 65535, 65535, 65535, 65535, 5939, 5940, + 5941, 5942, 65535, 65535, 5943, 5944, 65535, 65535, 65535, 65535, 65535, + 65535, 5945, 65535, 65535, 5946, 5947, 65535, 5948, 5949, 5950, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5951, 5952, 5953, 65535, 65535, + 65535, 65535, 65535, 65535, 5954, 5955, 65535, 65535, 65535, 65535, 65535, + 5956, 65535, 65535, 65535, 65535, 65535, 65535, 5957, 65535, 5958, 65535, + 65535, 5959, 65535, 65535, 65535, 65535, 5960, 5961, 65535, 5962, 5963, + 65535, 65535, 65535, 5964, 65535, 65535, 65535, 65535, 5965, 65535, 5966, + 65535, 65535, 65535, 5967, 5968, 65535, 65535, 65535, 65535, 5969, 65535, + 5970, 65535, 65535, 65535, 65535, 5971, 5972, 65535, 65535, 65535, 65535, + 5973, 5974, 65535, 5975, 5976, 65535, 65535, 5977, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5978, 65535, 5979, 65535, 65535, 5980, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5981, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5982, 65535, 65535, 65535, + 65535, 5989, 5983, 65535, 5984, 5985, 65535, 65535, 65535, 65535, 65535, + 5986, 65535, 5987, 5988, 65535, 65535, 65535, 65535, 65535, 5990, 65535, + 5991, 65535, 65535, 65535, 65535, 5992, 5993, 65535, 65535, 65535, 65535, + 65535, 65535, 5994, 5995, 65535, 65535, 65535, 65535, 65535, 5996, 5997, + 5998, 65535, 65535, 65535, 65535, 65535, 5999, 65535, 6000, 6001, 65535, + 6002, 65535, 6003, 65535, 6004, 6005, 65535, 65535, 65535, 6006, 6007, + 6008, 65535, 65535, 65535, 65535, 65535, 6009, 6010, 6011, 6012, 65535, + 65535, 6013, 65535, 65535, 65535, 65535, 65535, 6014, 6015, 65535, 6016, + 65535, 65535, 65535, 6017, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6018, 65535, 6019, 6020, 6021, 6022, 6023, 65535, 65535, 6024, 65535, + 65535, 65535, 65535, 6025, 6026, 65535, 65535, 65535, 65535, 65535, 65535, + 6027, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6028, 65535, 65535, 6029, 6030, 65535, + 65535, 6031, 6032, 6033, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6034, 6035, 65535, 6036, + 65535, 65535, 65535, 65535, 65535, 6037, 65535, 6038, 6039, 65535, 65535, + 65535, 65535, 6040, 65535, 65535, 65535, 6041, 6042, 65535, 6043, 65535, + 65535, 6044, 65535, 6045, 6046, 65535, 6047, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6048, 65535, 65535, 6049, 6050, + 65535, 65535, 65535, 6051, 65535, 65535, 65535, 65535, 65535, 6052, 65535, + 65535, 6053, 65535, 65535, 65535, 6054, 6055, 65535, 65535, 65535, 65535, + 6056, 65535, 65535, 6057, 65535, 65535, 65535, 6058, 65535, 6059, 65535, + 65535, 65535, 6060, 65535, 65535, 65535, 6061, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6062, 65535, 65535, 6063, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6064, 6065, 6067, 65535, 6068, 6069, 65535, 6066, 65535, + 65535, 65535, 6070, 6071, 65535, 65535, 6072, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6073, 65535, 65535, 65535, 6074, 6075, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6076, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6077, 65535, + 6078, 65535, 65535, 65535, 65535, 6079, 65535, 65535, 65535, 6080, 6081, + 65535, 65535, 65535, 65535, 6082, 65535, 65535, 65535, 6083, 65535, 65535, + 65535, 6084, 65535, 65535, 65535, 65535, 6085, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6086, 65535, 65535, 6087, + 65535, 65535, 6088, 6089, 65535, 6090, 65535, 6091, 65535, 65535, 65535, + 65535, 6092, 65535, 6093, 6094, 6095, 65535, 6096, 65535, 65535, 65535, + 65535, 6097, 6098, 6099, 65535, 65535, 6100, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6101, 65535, 6102, 6103, 6104, + 65535, 6105, 65535, 65535, 65535, 65535, 65535, 65535, 6106, 6108, 65535, + 65535, 65535, 65535, 6109, 6110, 6111, 65535, 6112, 6113, 65535, 65535, + 65535, 6107, 65535, 65535, 65535, 65535, 65535, 6122, 65535, 65535, 6114, + 65535, 6115, 6116, 6117, 65535, 65535, 6118, 6119, 65535, 6120, 65535, + 65535, 65535, 65535, 65535, 6121, 65535, 65535, 65535, 65535, 65535, 6124, + 65535, 65535, 65535, 6125, 6126, 65535, 65535, 65535, 6127, 65535, 6123, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6128, 6129, 6130, 65535, + 65535, 65535, 6131, 6132, 6133, 65535, 6134, 65535, 65535, 65535, 65535, + 6135, 65535, 65535, 6136, 65535, 65535, 65535, 6137, 65535, 6138, 6139, + 6140, 65535, 6141, 65535, 6142, 65535, 6143, 65535, 6144, 65535, 6146, + 6147, 65535, 6145, 65535, 6148, 65535, 6149, 65535, 65535, 65535, 65535, + 6150, 6151, 65535, 6152, 65535, 65535, 6153, 65535, 6154, 6155, 65535, + 6156, 6157, 65535, 6158, 6159, 65535, 65535, 65535, 65535, 65535, 6160, + 65535, 65535, 65535, 6161, 6162, 65535, 65535, 65535, 65535, 65535, 65535, + 6163, 65535, 65535, 65535, 6164, 65535, 65535, 65535, 6165, 65535, 6166, + 6167, 6168, 65535, 65535, 65535, 65535, 65535, 6169, 65535, 65535, 6170, + 65535, 65535, 6171, 65535, 65535, 65535, 65535, 65535, 6172, 65535, 65535, + 65535, 65535, 65535, 65535, 6173, 65535, 65535, 65535, 65535, 6174, 6175, + 6176, 65535, 65535, 65535, 65535, 65535, 6177, 65535, 6178, 65535, 6179, + 6180, 65535, 65535, 65535, 6181, 65535, 65535, 65535, 6182, 65535, 65535, + 6183, 65535, 6184, 6185, 6186, 65535, 65535, 6187, 65535, 65535, 65535, + 65535, 65535, 6188, 65535, 65535, 6189, 65535, 65535, 65535, 65535, 6190, + 65535, 6191, 65535, 65535, 65535, 6192, 6193, 6194, 65535, 6195, 6196, + 6197, 6198, 65535, 65535, 6199, 65535, 65535, 65535, 65535, 6200, 6201, + 6202, 65535, 6203, 65535, 65535, 6204, 6205, 65535, 6206, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6207, 6208, 65535, 65535, 6209, 65535, 6210, 6211, 65535, 65535, + 65535, 6212, 65535, 65535, 65535, 65535, 65535, 6213, 6214, 65535, 65535, + 65535, 6215, 6216, 65535, 6217, 6218, 6219, 6220, 6221, 6222, 65535, 65535, + 65535, 65535, 65535, 6223, 65535, 6224, 65535, 6225, 65535, 6226, 65535, + 65535, 6227, 6228, 65535, 65535, 6229, 6230, 6231, 6232, 65535, 6233, 6234, + 65535, 6235, 65535, 65535, 65535, 6236, 65535, 6237, 6238, 65535, 65535, + 6239, 65535, 6240, 65535, 65535, 65535, 6241, 6242, 65535, 65535, 65535, + 65535, 65535, 6243, 6244, 6245, 6246, 65535, 6247, 65535, 65535, 65535, + 65535, 65535, 6248, 6249, 6250, 65535, 65535, 6251, 65535, 6252, 6253, + 65535, 6254, 6255, 6256, 65535, 6257, 65535, 6258, 65535, 6259, 65535, + 6260, 6261, 65535, 65535, 6262, 6263, 65535, 65535, 6264, 65535, 65535, + 6265, 6266, 6267, 65535, 6268, 65535, 65535, 65535, 65535, 65535, 65535, + 6269, 6270, 65535, 65535, 6271, 6272, 65535, 65535, 6273, 6274, 65535, + 65535, 65535, 6275, 65535, 6276, 6277, 6278, 65535, 65535, 65535, 65535, + 6279, 6280, 6281, 65535, 65535, 65535, 65535, 6282, 6283, 6284, 6285, 6286, + 65535, 6287, 6288, 6289, 65535, 6290, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6291, 6292, 6293, 65535, 65535, 6294, 6295, 65535, + 65535, 65535, 6296, 65535, 65535, 65535, 65535, 6297, 65535, 6298, 65535, + 65535, 65535, 65535, 65535, 6299, 6300, 65535, 65535, 65535, 6301, 6302, + 65535, 6303, 6304, 65535, 65535, 6305, 65535, 65535, 65535, 6306, 65535, + 65535, 6307, 65535, 65535, 65535, 6308, 65535, 6309, 65535, 6310, 6311, + 6312, 6313, 65535, 6314, 6315, 6316, 6317, 6318, 65535, 6319, 6320, 6321, + 6322, 65535, 65535, 6323, 6324, 6325, 6326, 65535, 6327, 65535, 65535, + 6328, 65535, 6329, 65535, 6330, 6331, 6332, 65535, 65535, 6333, 6334, + 65535, 6335, 6336, 6337, 65535, 6338, 65535, 6339, 65535, 6340, 6341, + 65535, 65535, 65535, 6342, 65535, 6343, 65535, 6344, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6345, 65535, 6346, 65535, 65535, 65535, + 6347, 6348, 65535, 6349, 65535, 65535, 65535, 65535, 65535, 6350, 65535, + 65535, 65535, 65535, 6351, 65535, 65535, 65535, 6352, 65535, 65535, 6353, + 6354, 65535, 65535, 65535, 65535, 65535, 65535, 6355, 6356, 6357, 6358, + 65535, 6359, 65535, 65535, 6360, 6361, 65535, 6362, 65535, 6363, 6364, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6365, 6366, 65535, + 6367, 6368, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6369, 6370, 6371, 65535, 65535, + 65535, 65535, 65535, 65535, 6372, 6373, 6374, 65535, 65535, 6375, 65535, + 6376, 6377, 65535, 6378, 65535, 65535, 65535, 6379, 65535, 65535, 65535, + 65535, 65535, 6380, 6381, 65535, 6382, 65535, 6383, 6384, 65535, 65535, + 6385, 65535, 6386, 6387, 6388, 65535, 6389, 6390, 65535, 6391, 65535, + 65535, 65535, 6392, 65535, 65535, 6393, 65535, 6394, 6395, 6396, 6397, + 65535, 65535, 65535, 65535, 65535, 6398, 65535, 6399, 6400, 65535, 6401, + 65535, 6402, 65535, 65535, 6403, 65535, 65535, 6404, 65535, 65535, 6405, + 65535, 65535, 6406, 65535, 65535, 6407, 65535, 65535, 6408, 65535, 6409, + 6410, 65535, 6411, 65535, 6412, 6418, 65535, 6413, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6414, 6415, 6416, 65535, 65535, 65535, + 6417, 65535, 65535, 65535, 65535, 65535, 65535, 6419, 65535, 65535, 6420, + 6421, 6422, 6423, 65535, 6424, 6425, 6426, 6427, 6428, 65535, 65535, 65535, + 65535, 65535, 6429, 65535, 65535, 65535, 65535, 65535, 6430, 65535, 65535, + 6431, 65535, 6432, 6433, 65535, 65535, 6434, 65535, 65535, 65535, 6435, + 6436, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6438, 6439, 6437, 6440, 6441, 65535, + 6442, 65535, 65535, 65535, 6443, 6444, 65535, 6445, 65535, 65535, 65535, + 6446, 6447, 65535, 65535, 65535, 6448, 6449, 6450, 65535, 65535, 65535, + 65535, 65535, 6451, 6452, 6453, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6454, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6455, 6456, 65535, 6457, 6458, 6459, + 6460, 65535, 65535, 65535, 65535, 65535, 65535, 6461, 65535, 6463, 65535, + 6462, 65535, 65535, 65535, 6464, 65535, 6465, 65535, 65535, 6466, 65535, + 6467, 65535, 6468, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6469, 65535, 65535, 65535, 6470, 65535, 65535, 6471, 65535, 65535, 6472, + 65535, 6473, 65535, 6474, 65535, 65535, 65535, 65535, 6475, 65535, 65535, + 6476, 65535, 6477, 6478, 6479, 65535, 6480, 6481, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6483, 6482, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6484, 6485, + 65535, 65535, 65535, 65535, 6486, 65535, 65535, 65535, 65535, 65535, 6487, + 65535, 65535, 65535, 6488, 65535, 65535, 65535, 6489, 6490, 6491, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6492, 6493, 6494, 65535, 6495, 65535, 65535, 65535, + 65535, 6496, 65535, 65535, 6497, 65535, 6498, 6499, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6500, 65535, 6501, 65535, 65535, 65535, 6502, + 65535, 65535, 6503, 65535, 6504, 65535, 65535, 65535, 65535, 65535, 65535, + 6505, 65535, 6506, 6507, 65535, 6508, 65535, 65535, 65535, 65535, 6509, + 6510, 6511, 6512, 65535, 65535, 65535, 65535, 65535, 6513, 6514, 65535, + 65535, 6515, 6516, 6517, 6518, 65535, 65535, 65535, 6519, 65535, 6520, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6521, 6522, 65535, 65535, 65535, 6523, 65535, + 6524, 6525, 6526, 65535, 65535, 65535, 65535, 65535, 6527, 65535, 65535, + 65535, 65535, 6528, 65535, 6529, 65535, 65535, 65535, 6530, 6531, 6532, + 6533, 65535, 6534, 6535, 65535, 65535, 65535, 6536, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6537, 65535, 6538, 65535, 6539, 6540, 6541, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6542, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6543, 65535, + 65535, 65535, 65535, 65535, 6544, 65535, 65535, 65535, 65535, 65535, 65535, + 6545, 6546, 65535, 6547, 6548, 65535, 6549, 6550, 6551, 6552, 65535, 65535, + 65535, 65535, 6553, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6554, + 65535, 65535, 65535, 65535, 6555, 65535, 65535, 65535, 6556, 65535, 65535, + 6557, 65535, 6558, 65535, 65535, 65535, 65535, 6559, 6560, 6561, 65535, + 65535, 6562, 65535, 65535, 65535, 65535, 6563, 6564, 65535, 65535, 65535, + 6565, 65535, 65535, 65535, 65535, 65535, 65535, 6566, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6567, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6568, + 65535, 65535, 65535, 65535, 65535, 6570, 65535, 6571, 65535, 65535, 6572, + 6573, 6574, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6575, 65535, 65535, 65535, 65535, 65535, 6576, 65535, 6577, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6578, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6579, 6580, 65535, 6581, 65535, 65535, 65535, 6582, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6583, 6584, 65535, 6585, 65535, + 65535, 65535, 6586, 6587, 6588, 65535, 65535, 65535, 65535, 6589, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6590, 65535, 6591, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6592, 65535, 6593, 65535, 65535, 65535, 65535, 65535, 65535, + 6594, 65535, 65535, 65535, 6595, 6596, 65535, 65535, 65535, 65535, 65535, + 6597, 65535, 6598, 6599, 65535, 6600, 6601, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6602, 65535, 65535, 65535, 6603, 65535, 65535, 6604, + 65535, 65535, 65535, 6605, 65535, 65535, 65535, 65535, 6606, 65535, 65535, + 6607, 6608, 6609, 65535, 65535, 6610, 65535, 6611, 65535, 6612, 6613, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6614, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6615, 6616, + 6617, 65535, 6618, 6619, 65535, 65535, 65535, 6620, 6621, 65535, 65535, + 6622, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6623, + 65535, 6624, 65535, 65535, 6625, 6626, 65535, 65535, 6627, 6628, 65535, + 6629, 6630, 6631, 65535, 6632, 65535, 6633, 6634, 65535, 6635, 65535, + 65535, 6636, 6637, 65535, 6638, 65535, 6639, 6640, 65535, 6641, 6642, 6643, + 65535, 6644, 6645, 65535, 65535, 6646, 65535, 65535, 6647, 6648, 6649, + 65535, 6653, 65535, 6650, 6651, 65535, 6652, 6654, 65535, 65535, 6655, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6656, + 65535, 6657, 65535, 65535, 6658, 65535, 65535, 6659, 6660, 65535, 6661, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6662, 65535, 65535, 6663, 65535, 65535, 6665, 6666, 65535, + 65535, 65535, 65535, 65535, 6667, 65535, 6668, 65535, 65535, 6664, 65535, + 65535, 6669, 65535, 6670, 65535, 6671, 65535, 65535, 6672, 65535, 6681, + 6673, 65535, 65535, 65535, 65535, 6674, 65535, 65535, 6675, 6676, 6677, + 65535, 6678, 6679, 65535, 6680, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6682, 65535, 65535, 65535, 65535, 65535, 6683, 65535, 65535, + 6684, 65535, 65535, 6685, 65535, 65535, 65535, 65535, 65535, 65535, 6686, + 6687, 6688, 65535, 65535, 6689, 6690, 65535, 6691, 6692, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6693, 6694, 65535, 6695, 6696, 65535, + 65535, 65535, 6697, 65535, 6698, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6699, 65535, 6700, 6701, 65535, + 6702, 65535, 65535, 65535, 6703, 65535, 65535, 6704, 6705, 65535, 6706, + 6707, 65535, 65535, 65535, 6708, 65535, 65535, 6709, 65535, 65535, 6710, + 65535, 65535, 6711, 65535, 65535, 65535, 6712, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6713, 65535, 6714, 65535, 6715, + 6716, 6717, 65535, 65535, 6718, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6719, 65535, 65535, 6720, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6721, 65535, 65535, 65535, 65535, + 6722, 6723, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6724, + 65535, 65535, 65535, 6725, 6726, 6727, 65535, 65535, 6728, 6729, 6730, + 65535, 65535, 6731, 65535, 65535, 6732, 65535, 65535, 65535, 6733, 6734, + 65535, 65535, 65535, 6735, 65535, 65535, 65535, 65535, 65535, 6736, 6737, + 6738, 6739, 6740, 65535, 65535, 65535, 6741, 6742, 6743, 6744, 65535, + 65535, 65535, 6745, 6746, 65535, 65535, 65535, 65535, 6747, 6748, 6749, + 65535, 65535, 65535, 65535, 6750, 6751, 65535, 65535, 65535, 65535, 65535, + 6752, 65535, 65535, 65535, 6753, 6754, 65535, 6755, 6756, 65535, 6757, + 6758, 6759, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6760, 65535, + 6761, 65535, 6762, 65535, 65535, 65535, 65535, 65535, 65535, 6763, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6764, 6765, 6766, + 65535, 65535, 6767, 65535, 65535, 65535, 6768, 6769, 65535, 65535, 6770, + 65535, 6771, 65535, 65535, 65535, 6772, 65535, 65535, 65535, 65535, 65535, + 6773, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6774, + 6775, 65535, 65535, 65535, 65535, 6776, 6777, 65535, 6778, 65535, 6779, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6780, 65535, 65535, + 6781, 6782, 6783, 65535, 65535, 65535, 6784, 65535, 65535, 65535, 6785, + 6786, 65535, 65535, 65535, 6787, 65535, 65535, 65535, 6788, 6789, 65535, + 65535, 65535, 6790, 6791, 6792, 65535, 65535, 65535, 65535, 65535, 65535, + 6793, 6794, 65535, 65535, 65535, 6795, 6796, 65535, 65535, 65535, 65535, + 6797, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6798, 65535, 6799, + 65535, 6800, 6801, 6802, 65535, 65535, 6803, 65535, 65535, 65535, 65535, + 65535, 6804, 6805, 65535, 65535, 65535, 65535, 6806, 65535, 6807, 6808, + 65535, 6809, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6811, + 65535, 65535, 6812, 65535, 65535, 6810, 65535, 65535, 6813, 6814, 6815, + 65535, 6816, 65535, 65535, 6817, 65535, 65535, 6818, 65535, 6819, 65535, + 65535, 65535, 65535, 65535, 65535, 6820, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6821, 65535, 6822, 65535, 6823, 6824, 65535, 65535, 6825, 65535, + 6826, 6827, 6828, 65535, 65535, 6829, 65535, 6830, 65535, 65535, 6831, + 6832, 65535, 6833, 65535, 6834, 65535, 65535, 6835, 65535, 6836, 65535, + 65535, 65535, 65535, 65535, 6837, 65535, 6838, 65535, 6839, 65535, 65535, + 6840, 6841, 6842, 65535, 65535, 65535, 6843, 6844, 65535, 65535, 65535, + 6845, 65535, 65535, 65535, 6846, 6847, 65535, 6848, 65535, 6849, 65535, + 65535, 6850, 65535, 65535, 65535, 65535, 65535, 6851, 6852, 65535, 6853, + 65535, 65535, 65535, 6854, 6855, 65535, 65535, 6856, 65535, 6857, 6858, + 6859, 6860, 6861, 6862, 6863, 65535, 65535, 6864, 6865, 65535, 6866, 6867, + 6868, 6869, 65535, 6870, 65535, 6871, 65535, 65535, 65535, 6872, 65535, + 65535, 6873, 65535, 6874, 6875, 65535, 65535, 65535, 6876, 65535, 65535, + 65535, 65535, 65535, 6877, 65535, 65535, 65535, 65535, 6878, 65535, 6879, + 65535, 65535, 65535, 65535, 65535, 6880, 6881, 6882, 65535, 6883, 65535, + 6884, 6885, 65535, 65535, 6886, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6887, 65535, 65535, 6888, 6889, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6890, 6891, 6892, 65535, 65535, + 65535, 6893, 65535, 65535, 6894, 65535, 65535, 6895, 65535, 6896, 65535, + 6897, 6898, 65535, 6899, 65535, 6900, 6901, 6902, 6903, 6904, 65535, 65535, + 65535, 65535, 6905, 65535, 6906, 65535, 6907, 6908, 6909, 65535, 65535, + 65535, 65535, 65535, 6910, 6911, 65535, 65535, 65535, 6912, 6913, 6914, + 6915, 65535, 6916, 6917, 6918, 65535, 6919, 65535, 6920, 6921, 65535, + 65535, 65535, 6922, 65535, 65535, 65535, 65535, 65535, 6923, 65535, 65535, + 6924, 6925, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6926, 6927, + 65535, 6928, 65535, 65535, 6929, 65535, 65535, 65535, 6930, 6931, 6932, + 65535, 65535, 65535, 65535, 6933, 6934, 65535, 65535, 6935, 6936, 65535, + 6937, 6938, 65535, 6939, 65535, 65535, 65535, 65535, 65535, 6940, 6941, + 65535, 65535, 65535, 65535, 65535, 6942, 65535, 6943, 65535, 65535, 65535, + 65535, 65535, 65535, 6944, 6945, 65535, 65535, 65535, 65535, 6946, 65535, + 6947, 65535, 65535, 65535, 65535, 65535, 6948, 65535, 6949, 65535, 65535, + 6950, 6951, 65535, 65535, 65535, 6952, 65535, 65535, 65535, 6953, 65535, + 65535, 65535, 6954, 6955, 6956, 6957, 65535, 65535, 6958, 65535, 6959, + 6960, 65535, 6961, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6962, 65535, 65535, 65535, 6963, 65535, 6964, 65535, 65535, 65535, 65535, + 6965, 65535, 6966, 6967, 6968, 65535, 6969, 65535, 6970, 65535, 65535, + 65535, 6971, 6972, 65535, 65535, 6973, 6974, 6975, 6976, 6977, 65535, + 65535, 65535, 65535, 65535, 65535, 6978, 65535, 65535, 65535, 6979, 6980, + 6981, 65535, 65535, 65535, 65535, 65535, 6982, 65535, 65535, 65535, 6983, + 65535, 6984, 6985, 6986, 65535, 65535, 65535, 6987, 6988, 65535, 65535, + 65535, 6989, 6990, 6991, 65535, 65535, 6992, 6993, 65535, 6994, 65535, + 6995, 65535, 65535, 6996, 7003, 6997, 6998, 6999, 65535, 65535, 65535, + 7000, 65535, 65535, 65535, 65535, 7005, 7001, 7002, 7004, 65535, 65535, + 7006, 65535, 7007, 65535, 7008, 65535, 65535, 7009, 65535, 7010, 65535, + 65535, 65535, 7011, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7012, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7013, 65535, 65535, 65535, 65535, 7014, + 65535, 7015, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7017, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7016, 65535, 65535, + 65535, 65535, 65535, 7018, 65535, 65535, 65535, 65535, 65535, 7019, 7020, + 65535, 65535, 65535, 7021, 7022, 7023, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7024, 7025, 65535, 7026, 7027, 7028, 65535, 65535, 65535, 65535, + 65535, 7029, 65535, 7030, 7032, 65535, 65535, 65535, 65535, 7033, 7034, + 65535, 7031, 65535, 7035, 65535, 65535, 7036, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7037, 7038, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7039, 65535, 65535, 7041, 7040, 65535, + 7042, 65535, 65535, 65535, 7043, 7044, 7045, 65535, 65535, 65535, 65535, + 7046, 65535, 65535, 65535, 65535, 65535, 7047, 7048, 65535, 65535, 65535, + 7049, 7050, 65535, 7051, 65535, 65535, 65535, 65535, 7052, 7053, 65535, + 7054, 65535, 65535, 65535, 7055, 65535, 65535, 7056, 7057, 65535, 65535, + 65535, 7058, 7059, 65535, 7060, 7061, 7062, 7063, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7064, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7065, 65535, 7066, 65535, 7067, 65535, 65535, 7068, + 65535, 65535, 65535, 7069, 65535, 65535, 65535, 7070, 65535, 65535, 7071, + 65535, 65535, 7072, 65535, 65535, 65535, 7073, 65535, 65535, 65535, 7074, + 65535, 7075, 7076, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7077, 7078, 7079, 7080, 65535, 65535, 7081, 65535, 65535, 65535, + 7082, 7083, 7084, 65535, 65535, 65535, 65535, 7085, 65535, 7086, 65535, + 7087, 65535, 7088, 65535, 65535, 7089, 65535, 7090, 65535, 65535, 7091, + 7092, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7093, + 65535, 65535, 65535, 7095, 65535, 65535, 65535, 65535, 7096, 65535, 65535, + 7094, 65535, 65535, 65535, 7097, 65535, 7098, 7099, 7100, 65535, 65535, + 7101, 7102, 65535, 65535, 7103, 65535, 65535, 7104, 7105, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7106, + 7107, 7108, 65535, 65535, 65535, 7109, 65535, 7110, 7111, 7112, 7113, + 65535, 7114, 65535, 65535, 65535, 65535, 65535, 65535, 7115, 7116, 65535, + 65535, 65535, 65535, 65535, 65535, 7117, 65535, 7118, 65535, 65535, 7119, + 65535, 65535, 7120, 65535, 65535, 65535, 65535, 65535, 7121, 65535, 65535, + 65535, 7122, 65535, 65535, 65535, 7123, 65535, 7124, 7125, 7126, 65535, + 65535, 7127, 7128, 7129, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7130, 65535, + 7131, 65535, 65535, 7132, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7133, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7134, 65535, 65535, 65535, 65535, 7135, 65535, 65535, 7136, 65535, + 65535, 65535, 65535, 7137, 7138, 7139, 65535, 7140, 7141, 7142, 65535, + 65535, 7143, 65535, 65535, 7144, 65535, 65535, 65535, 65535, 65535, 65535, + 7145, 65535, 65535, 7146, 7147, 65535, 65535, 65535, 65535, 65535, 7148, + 65535, 65535, 65535, 65535, 65535, 7149, 7150, 7151, 7152, 65535, 7153, + 65535, 7154, 7155, 65535, 7156, 7157, 7158, 65535, 65535, 65535, 7159, + 65535, 65535, 7160, 65535, 65535, 65535, 7161, 65535, 65535, 65535, 7162, + 7163, 65535, 65535, 65535, 7164, 65535, 7165, 7166, 65535, 7167, 65535, + 65535, 7168, 65535, 7169, 7170, 65535, 7171, 7172, 65535, 7173, 65535, + 7174, 65535, 7175, 7176, 7177, 7178, 7179, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7180, 65535, 7181, 7182, + 7183, 7184, 65535, 7185, 65535, 65535, 7186, 7187, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7188, 7189, 65535, 65535, 65535, + 7190, 7191, 7192, 7193, 7194, 65535, 7195, 65535, 7196, 65535, 65535, + 65535, 65535, 7197, 65535, 65535, 7198, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7199, 7200, 7201, 7202, 65535, 7203, 65535, 7204, 7205, + 65535, 65535, 65535, 65535, 65535, 65535, 7206, 65535, 65535, 7207, 7208, + 7209, 65535, 7210, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 116, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 192, 256, 0, 320, 0, 0, 0, 384, 0, 0, 448, 512, 576, 640, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 768, 832, 896, + 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 1664, + 1728, 1792, 1856, 1920, 1984, 2048, 2112, 2176, 2240, 2304, 2368, 2432, + 2496, 2560, 2624, 2688, 2752, 2816, 2880, 2944, 3008, 3072, 3136, 3200, + 3264, 3328, 3392, 3456, 3520, 3584, 3648, 3712, 3776, 3840, 3904, 3968, + 4032, 4096, 4160, 4224, 4288, 4352, 4416, 4480, 4544, 4608, 4672, 4736, + 4800, 4864, 4928, 4992, 5056, 5120, 5184, 5248, 5312, 5376, 5440, 5504, + 5568, 5632, 5696, 5760, 5824, 5888, 5952, 6016, 6080, 6144, 6208, 6272, + 6336, 6400, 6464, 6528, 6592, 6656, 6720, 6784, 6848, 6912, 6976, 7040, + 7104, 7168, 7232, 7296, 7360, 7424, 7488, 7552, 7616, 7680, 7744, 7808, + 7872, 7936, 8000, 8064, 8128, 8192, 8256, 8320, 8384, 8448, 8512, 8576, + 8640, 8704, 8768, 8832, 8896, 8960, 9024, 9088, 9152, 9216, 9280, 9344, + 9408, 9472, 9536, 9600, 9664, 9728, 9792, 9856, 9920, 9984, 10048, 10112, + 10176, 10240, 10304, 10368, 10432, 10496, 10560, 10624, 10688, 10752, + 10816, 10880, 10944, 11008, 11072, 11136, 11200, 11264, 11328, 11392, + 11456, 11520, 11584, 11648, 11712, 11776, 11840, 11904, 11968, 12032, + 12096, 12160, 12224, 12288, 12352, 12416, 12480, 12544, 12608, 12672, + 12736, 12800, 12864, 12928, 12992, 13056, 13120, 13184, 0, 13248, 13312, + 13376, 13440, 13504, 13568, 13632, 13696, 13760, 13824, 13888, 13952, + 14016, 14080, 14144, 14208, 14272, 14336, 14400, 14464, 14528, 14592, + 14656, 14720, 14784, 14848, 14912, 14976, 15040, 15104, 15168, 15232, + 15296, 15360, 15424, 15488, 15552, 15616, 15680, 15744, 15808, 15872, + 15936, 16000, 16064, 16128, 16192, 16256, 16320, 16384, 16448, 0, 16512, + 16576, 16640, 16704, 16768, 16832, 16896, 16960, 17024, 17088, 17152, + 17216, 17280, 17344, 17408, 17472, 17536, 17600, 17664, 17728, 17792, + 17856, 17920, 17984, 18048, 18112, 18176, 18240, 18304, 18368, 18432, + 18496, 18560, 18624, 18688, 0, 0, 18752, 18816, 18880, 18944, 19008, 19072, + 19136, 19200, 19264, 19328, 19392, 19456, 19520, 19584, 19648, 19712, + 19776, 19840, 19904, 19968, 20032, 20096, 20160, 20224, 20288, 20352, + 20416, 20480, 20544, 0, 20608, 20672, 20736, 20800, 20864, 20928, 20992, + 21056, 21120, 21184, 21248, 21312, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21376, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u16 { + let offset = (code >> 6) as usize; + let offset = if offset < 1022 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +multi_byte_tests!( + mod = jis0212, + dups = [] +); diff --git a/deps/encoding-index-japanese-1.20141219.5/lib.rs b/deps/encoding-index-japanese-1.20141219.5/lib.rs new file mode 100644 index 000000000..823effe4d --- /dev/null +++ b/deps/encoding-index-japanese-1.20141219.5/lib.rs @@ -0,0 +1,28 @@ +// This is a part of rust-encoding. +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ + +//! Japanese index tables for [rust-encoding](https://github.com/lifthrasiir/rust-encoding). + +#![cfg_attr(test, feature(test))] + +#[cfg(test)] +#[macro_use] +extern crate encoding_index_tests; + +/// JIS X 0208 with common extensions. +/// +/// From the Encoding Standard: +/// +/// > This is the JIS X 0208 standard including formerly proprietary extensions from IBM and NEC. +pub mod jis0208; + +/// JIS X 0212. +/// +/// From the Encoding Standard: +/// +/// > This is the JIS X 0212 standard. +/// > It is only used by the euc-jp decoder due to lack of widespread support elsewhere. +pub mod jis0212; + diff --git a/deps/encoding-index-korean-1.20141219.5/Cargo.toml b/deps/encoding-index-korean-1.20141219.5/Cargo.toml new file mode 100644 index 000000000..e6e8afde1 --- /dev/null +++ b/deps/encoding-index-korean-1.20141219.5/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "encoding-index-korean" +version = "1.20141219.5" +authors = ["Kang Seonghoon "] + +description = "Index tables for Korean character encodings" +homepage = "https://github.com/lifthrasiir/rust-encoding" +readme = "../../../README.md" +license = "CC0-1.0" + +[lib] +name = "encoding_index_korean" +path = "lib.rs" + +[dependencies.encoding_index_tests] +# TODO consider using dev-dependencies instead (Cargo issue #860) +version = "0.1.4" +path = "../tests" diff --git a/deps/encoding-index-korean-1.20141219.5/euc_kr.rs b/deps/encoding-index-korean-1.20141219.5/euc_kr.rs new file mode 100644 index 000000000..ced607af0 --- /dev/null +++ b/deps/encoding-index-korean-1.20141219.5/euc_kr.rs @@ -0,0 +1,5723 @@ +// AUTOGENERATED FROM index-euc-kr.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-euc-kr.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 1d97134cbf187263585bc8f593ca4196654ed4c7a673f5672eaad4f5d9fdc4ba +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 44034, 44035, 44037, 44038, 44043, 44044, 44045, 44046, 44047, 44056, + 44062, 44063, 44065, 44066, 44067, 44069, 44070, 44071, 44072, 44073, + 44074, 44075, 44078, 44082, 44083, 44084, 65535, 65535, 65535, 65535, + 65535, 65535, 44085, 44086, 44087, 44090, 44091, 44093, 44094, 44095, + 44097, 44098, 44099, 44100, 44101, 44102, 44103, 44104, 44105, 44106, + 44108, 44110, 44111, 44112, 44113, 44114, 44115, 44117, 65535, 65535, + 65535, 65535, 65535, 65535, 44118, 44119, 44121, 44122, 44123, 44125, + 44126, 44127, 44128, 44129, 44130, 44131, 44132, 44133, 44134, 44135, + 44136, 44137, 44138, 44139, 44140, 44141, 44142, 44143, 44146, 44147, + 44149, 44150, 44153, 44155, 44156, 44157, 44158, 44159, 44162, 44167, + 44168, 44173, 44174, 44175, 44177, 44178, 44179, 44181, 44182, 44183, + 44184, 44185, 44186, 44187, 44190, 44194, 44195, 44196, 44197, 44198, + 44199, 44203, 44205, 44206, 44209, 44210, 44211, 44212, 44213, 44214, + 44215, 44218, 44222, 44223, 44224, 44226, 44227, 44229, 44230, 44231, + 44233, 44234, 44235, 44237, 44238, 44239, 44240, 44241, 44242, 44243, + 44244, 44246, 44248, 44249, 44250, 44251, 44252, 44253, 44254, 44255, + 44258, 44259, 44261, 44262, 44265, 44267, 44269, 44270, 44274, 44276, + 44279, 44280, 44281, 44282, 44283, 44286, 44287, 44289, 44290, 44291, + 44293, 44295, 44296, 44297, 44298, 44299, 44302, 44304, 44306, 44307, + 44308, 44309, 44310, 44311, 44313, 44314, 44315, 44317, 44318, 44319, + 44321, 44322, 44323, 44324, 44325, 44326, 44327, 44328, 44330, 44331, + 44334, 44335, 44336, 44337, 44338, 44339, 65535, 65535, 65535, 65535, + 65535, 65535, 44342, 44343, 44345, 44346, 44347, 44349, 44350, 44351, + 44352, 44353, 44354, 44355, 44358, 44360, 44362, 44363, 44364, 44365, + 44366, 44367, 44369, 44370, 44371, 44373, 44374, 44375, 65535, 65535, + 65535, 65535, 65535, 65535, 44377, 44378, 44379, 44380, 44381, 44382, + 44383, 44384, 44386, 44388, 44389, 44390, 44391, 44392, 44393, 44394, + 44395, 44398, 44399, 44401, 44402, 44407, 44408, 44409, 44410, 44414, + 44416, 44419, 44420, 44421, 44422, 44423, 44426, 44427, 44429, 44430, + 44431, 44433, 44434, 44435, 44436, 44437, 44438, 44439, 44440, 44441, + 44442, 44443, 44446, 44447, 44448, 44449, 44450, 44451, 44453, 44454, + 44455, 44456, 44457, 44458, 44459, 44460, 44461, 44462, 44463, 44464, + 44465, 44466, 44467, 44468, 44469, 44470, 44472, 44473, 44474, 44475, + 44476, 44477, 44478, 44479, 44482, 44483, 44485, 44486, 44487, 44489, + 44490, 44491, 44492, 44493, 44494, 44495, 44498, 44500, 44501, 44502, + 44503, 44504, 44505, 44506, 44507, 44509, 44510, 44511, 44513, 44514, + 44515, 44517, 44518, 44519, 44520, 44521, 44522, 44523, 44524, 44525, + 44526, 44527, 44528, 44529, 44530, 44531, 44532, 44533, 44534, 44535, + 44538, 44539, 44541, 44542, 44546, 44547, 44548, 44549, 44550, 44551, + 44554, 44556, 44558, 44559, 44560, 44561, 44562, 44563, 44565, 44566, + 44567, 44568, 44569, 44570, 44571, 44572, 65535, 65535, 65535, 65535, + 65535, 65535, 44573, 44574, 44575, 44576, 44577, 44578, 44579, 44580, + 44581, 44582, 44583, 44584, 44585, 44586, 44587, 44588, 44589, 44590, + 44591, 44594, 44595, 44597, 44598, 44601, 44603, 44604, 65535, 65535, + 65535, 65535, 65535, 65535, 44605, 44606, 44607, 44610, 44612, 44615, + 44616, 44617, 44619, 44623, 44625, 44626, 44627, 44629, 44631, 44632, + 44633, 44634, 44635, 44638, 44642, 44643, 44644, 44646, 44647, 44650, + 44651, 44653, 44654, 44655, 44657, 44658, 44659, 44660, 44661, 44662, + 44663, 44666, 44670, 44671, 44672, 44673, 44674, 44675, 44678, 44679, + 44680, 44681, 44682, 44683, 44685, 44686, 44687, 44688, 44689, 44690, + 44691, 44692, 44693, 44694, 44695, 44696, 44697, 44698, 44699, 44700, + 44701, 44702, 44703, 44704, 44705, 44706, 44707, 44708, 44709, 44710, + 44711, 44712, 44713, 44714, 44715, 44716, 44717, 44718, 44719, 44720, + 44721, 44722, 44723, 44724, 44725, 44726, 44727, 44728, 44729, 44730, + 44731, 44735, 44737, 44738, 44739, 44741, 44742, 44743, 44744, 44745, + 44746, 44747, 44750, 44754, 44755, 44756, 44757, 44758, 44759, 44762, + 44763, 44765, 44766, 44767, 44768, 44769, 44770, 44771, 44772, 44773, + 44774, 44775, 44777, 44778, 44780, 44782, 44783, 44784, 44785, 44786, + 44787, 44789, 44790, 44791, 44793, 44794, 44795, 44797, 44798, 44799, + 44800, 44801, 44802, 44803, 44804, 44805, 65535, 65535, 65535, 65535, + 65535, 65535, 44806, 44809, 44810, 44811, 44812, 44814, 44815, 44817, + 44818, 44819, 44820, 44821, 44822, 44823, 44824, 44825, 44826, 44827, + 44828, 44829, 44830, 44831, 44832, 44833, 44834, 44835, 65535, 65535, + 65535, 65535, 65535, 65535, 44836, 44837, 44838, 44839, 44840, 44841, + 44842, 44843, 44846, 44847, 44849, 44851, 44853, 44854, 44855, 44856, + 44857, 44858, 44859, 44862, 44864, 44868, 44869, 44870, 44871, 44874, + 44875, 44876, 44877, 44878, 44879, 44881, 44882, 44883, 44884, 44885, + 44886, 44887, 44888, 44889, 44890, 44891, 44894, 44895, 44896, 44897, + 44898, 44899, 44902, 44903, 44904, 44905, 44906, 44907, 44908, 44909, + 44910, 44911, 44912, 44913, 44914, 44915, 44916, 44917, 44918, 44919, + 44920, 44922, 44923, 44924, 44925, 44926, 44927, 44929, 44930, 44931, + 44933, 44934, 44935, 44937, 44938, 44939, 44940, 44941, 44942, 44943, + 44946, 44947, 44948, 44950, 44951, 44952, 44953, 44954, 44955, 44957, + 44958, 44959, 44960, 44961, 44962, 44963, 44964, 44965, 44966, 44967, + 44968, 44969, 44970, 44971, 44972, 44973, 44974, 44975, 44976, 44977, + 44978, 44979, 44980, 44981, 44982, 44983, 44986, 44987, 44989, 44990, + 44991, 44993, 44994, 44995, 44996, 44997, 44998, 45002, 45004, 45007, + 45008, 45009, 45010, 45011, 45013, 45014, 45015, 45016, 45017, 45018, + 45019, 45021, 45022, 45023, 45024, 45025, 65535, 65535, 65535, 65535, + 65535, 65535, 45026, 45027, 45028, 45029, 45030, 45031, 45034, 45035, + 45036, 45037, 45038, 45039, 45042, 45043, 45045, 45046, 45047, 45049, + 45050, 45051, 45052, 45053, 45054, 45055, 45058, 45059, 65535, 65535, + 65535, 65535, 65535, 65535, 45061, 45062, 45063, 45064, 45065, 45066, + 45067, 45069, 45070, 45071, 45073, 45074, 45075, 45077, 45078, 45079, + 45080, 45081, 45082, 45083, 45086, 45087, 45088, 45089, 45090, 45091, + 45092, 45093, 45094, 45095, 45097, 45098, 45099, 45100, 45101, 45102, + 45103, 45104, 45105, 45106, 45107, 45108, 45109, 45110, 45111, 45112, + 45113, 45114, 45115, 45116, 45117, 45118, 45119, 45120, 45121, 45122, + 45123, 45126, 45127, 45129, 45131, 45133, 45135, 45136, 45137, 45138, + 45142, 45144, 45146, 45147, 45148, 45150, 45151, 45152, 45153, 45154, + 45155, 45156, 45157, 45158, 45159, 45160, 45161, 45162, 45163, 45164, + 45165, 45166, 45167, 45168, 45169, 45170, 45171, 45172, 45173, 45174, + 45175, 45176, 45177, 45178, 45179, 45182, 45183, 45185, 45186, 45187, + 45189, 45190, 45191, 45192, 45193, 45194, 45195, 45198, 45200, 45202, + 45203, 45204, 45205, 45206, 45207, 45211, 45213, 45214, 45219, 45220, + 45221, 45222, 45223, 45226, 45232, 45234, 45238, 45239, 45241, 45242, + 45243, 45245, 45246, 45247, 45248, 45249, 45250, 45251, 45254, 45258, + 45259, 45260, 45261, 45262, 45263, 45266, 65535, 65535, 65535, 65535, + 65535, 65535, 45267, 45269, 45270, 45271, 45273, 45274, 45275, 45276, + 45277, 45278, 45279, 45281, 45282, 45283, 45284, 45286, 45287, 45288, + 45289, 45290, 45291, 45292, 45293, 45294, 45295, 45296, 65535, 65535, + 65535, 65535, 65535, 65535, 45297, 45298, 45299, 45300, 45301, 45302, + 45303, 45304, 45305, 45306, 45307, 45308, 45309, 45310, 45311, 45312, + 45313, 45314, 45315, 45316, 45317, 45318, 45319, 45322, 45325, 45326, + 45327, 45329, 45332, 45333, 45334, 45335, 45338, 45342, 45343, 45344, + 45345, 45346, 45350, 45351, 45353, 45354, 45355, 45357, 45358, 45359, + 45360, 45361, 45362, 45363, 45366, 45370, 45371, 45372, 45373, 45374, + 45375, 45378, 45379, 45381, 45382, 45383, 45385, 45386, 45387, 45388, + 45389, 45390, 45391, 45394, 45395, 45398, 45399, 45401, 45402, 45403, + 45405, 45406, 45407, 45409, 45410, 45411, 45412, 45413, 45414, 45415, + 45416, 45417, 45418, 45419, 45420, 45421, 45422, 45423, 45424, 45425, + 45426, 45427, 45428, 45429, 45430, 45431, 45434, 45435, 45437, 45438, + 45439, 45441, 45443, 45444, 45445, 45446, 45447, 45450, 45452, 45454, + 45455, 45456, 45457, 45461, 45462, 45463, 45465, 45466, 45467, 45469, + 45470, 45471, 45472, 45473, 45474, 45475, 45476, 45477, 45478, 45479, + 45481, 45482, 45483, 45484, 45485, 45486, 45487, 45488, 45489, 45490, + 45491, 45492, 45493, 45494, 45495, 45496, 65535, 65535, 65535, 65535, + 65535, 65535, 45497, 45498, 45499, 45500, 45501, 45502, 45503, 45504, + 45505, 45506, 45507, 45508, 45509, 45510, 45511, 45512, 45513, 45514, + 45515, 45517, 45518, 45519, 45521, 45522, 45523, 45525, 65535, 65535, + 65535, 65535, 65535, 65535, 45526, 45527, 45528, 45529, 45530, 45531, + 45534, 45536, 45537, 45538, 45539, 45540, 45541, 45542, 45543, 45546, + 45547, 45549, 45550, 45551, 45553, 45554, 45555, 45556, 45557, 45558, + 45559, 45560, 45562, 45564, 45566, 45567, 45568, 45569, 45570, 45571, + 45574, 45575, 45577, 45578, 45581, 45582, 45583, 45584, 45585, 45586, + 45587, 45590, 45592, 45594, 45595, 45596, 45597, 45598, 45599, 45601, + 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, + 45612, 45613, 45614, 45615, 45616, 45617, 45618, 45619, 45621, 45622, + 45623, 45624, 45625, 45626, 45627, 45629, 45630, 45631, 45632, 45633, + 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, + 45644, 45645, 45646, 45647, 45648, 45649, 45650, 45651, 45652, 45653, + 45654, 45655, 45657, 45658, 45659, 45661, 45662, 45663, 45665, 45666, + 45667, 45668, 45669, 45670, 45671, 45674, 45675, 45676, 45677, 45678, + 45679, 45680, 45681, 45682, 45683, 45686, 45687, 45688, 45689, 45690, + 45691, 45693, 45694, 45695, 45696, 45697, 45698, 45699, 45702, 45703, + 45704, 45706, 45707, 45708, 45709, 45710, 65535, 65535, 65535, 65535, + 65535, 65535, 45711, 45714, 45715, 45717, 45718, 45719, 45723, 45724, + 45725, 45726, 45727, 45730, 45732, 45735, 45736, 45737, 45739, 45741, + 45742, 45743, 45745, 45746, 45747, 45749, 45750, 45751, 65535, 65535, + 65535, 65535, 65535, 65535, 45752, 45753, 45754, 45755, 45756, 45757, + 45758, 45759, 45760, 45761, 45762, 45763, 45764, 45765, 45766, 45767, + 45770, 45771, 45773, 45774, 45775, 45777, 45779, 45780, 45781, 45782, + 45783, 45786, 45788, 45790, 45791, 45792, 45793, 45795, 45799, 45801, + 45802, 45808, 45809, 45810, 45814, 45820, 45821, 45822, 45826, 45827, + 45829, 45830, 45831, 45833, 45834, 45835, 45836, 45837, 45838, 45839, + 45842, 45846, 45847, 45848, 45849, 45850, 45851, 45853, 45854, 45855, + 45856, 45857, 45858, 45859, 45860, 45861, 45862, 45863, 45864, 45865, + 45866, 45867, 45868, 45869, 45870, 45871, 45872, 45873, 45874, 45875, + 45876, 45877, 45878, 45879, 45880, 45881, 45882, 45883, 45884, 45885, + 45886, 45887, 45888, 45889, 45890, 45891, 45892, 45893, 45894, 45895, + 45896, 45897, 45898, 45899, 45900, 45901, 45902, 45903, 45904, 45905, + 45906, 45907, 45911, 45913, 45914, 45917, 45920, 45921, 45922, 45923, + 45926, 45928, 45930, 45932, 45933, 45935, 45938, 45939, 45941, 45942, + 45943, 45945, 45946, 45947, 45948, 45949, 45950, 45951, 45954, 45958, + 45959, 45960, 45961, 45962, 45963, 45965, 65535, 65535, 65535, 65535, + 65535, 65535, 45966, 45967, 45969, 45970, 45971, 45973, 45974, 45975, + 45976, 45977, 45978, 45979, 45980, 45981, 45982, 45983, 45986, 45987, + 45988, 45989, 45990, 45991, 45993, 45994, 45995, 45997, 65535, 65535, + 65535, 65535, 65535, 65535, 45998, 45999, 46000, 46001, 46002, 46003, + 46004, 46005, 46006, 46007, 46008, 46009, 46010, 46011, 46012, 46013, + 46014, 46015, 46016, 46017, 46018, 46019, 46022, 46023, 46025, 46026, + 46029, 46031, 46033, 46034, 46035, 46038, 46040, 46042, 46044, 46046, + 46047, 46049, 46050, 46051, 46053, 46054, 46055, 46057, 46058, 46059, + 46060, 46061, 46062, 46063, 46064, 46065, 46066, 46067, 46068, 46069, + 46070, 46071, 46072, 46073, 46074, 46075, 46077, 46078, 46079, 46080, + 46081, 46082, 46083, 46084, 46085, 46086, 46087, 46088, 46089, 46090, + 46091, 46092, 46093, 46094, 46095, 46097, 46098, 46099, 46100, 46101, + 46102, 46103, 46105, 46106, 46107, 46109, 46110, 46111, 46113, 46114, + 46115, 46116, 46117, 46118, 46119, 46122, 46124, 46125, 46126, 46127, + 46128, 46129, 46130, 46131, 46133, 46134, 46135, 46136, 46137, 46138, + 46139, 46140, 46141, 46142, 46143, 46144, 46145, 46146, 46147, 46148, + 46149, 46150, 46151, 46152, 46153, 46154, 46155, 46156, 46157, 46158, + 46159, 46162, 46163, 46165, 46166, 46167, 46169, 46170, 46171, 46172, + 46173, 46174, 46175, 46178, 46180, 46182, 65535, 65535, 65535, 65535, + 65535, 65535, 46183, 46184, 46185, 46186, 46187, 46189, 46190, 46191, + 46192, 46193, 46194, 46195, 46196, 46197, 46198, 46199, 46200, 46201, + 46202, 46203, 46204, 46205, 46206, 46207, 46209, 46210, 65535, 65535, + 65535, 65535, 65535, 65535, 46211, 46212, 46213, 46214, 46215, 46217, + 46218, 46219, 46220, 46221, 46222, 46223, 46224, 46225, 46226, 46227, + 46228, 46229, 46230, 46231, 46232, 46233, 46234, 46235, 46236, 46238, + 46239, 46240, 46241, 46242, 46243, 46245, 46246, 46247, 46249, 46250, + 46251, 46253, 46254, 46255, 46256, 46257, 46258, 46259, 46260, 46262, + 46264, 46266, 46267, 46268, 46269, 46270, 46271, 46273, 46274, 46275, + 46277, 46278, 46279, 46281, 46282, 46283, 46284, 46285, 46286, 46287, + 46289, 46290, 46291, 46292, 46294, 46295, 46296, 46297, 46298, 46299, + 46302, 46303, 46305, 46306, 46309, 46311, 46312, 46313, 46314, 46315, + 46318, 46320, 46322, 46323, 46324, 46325, 46326, 46327, 46329, 46330, + 46331, 46332, 46333, 46334, 46335, 46336, 46337, 46338, 46339, 46340, + 46341, 46342, 46343, 46344, 46345, 46346, 46347, 46348, 46349, 46350, + 46351, 46352, 46353, 46354, 46355, 46358, 46359, 46361, 46362, 46365, + 46366, 46367, 46368, 46369, 46370, 46371, 46374, 46379, 46380, 46381, + 46382, 46383, 46386, 46387, 46389, 46390, 46391, 46393, 46394, 46395, + 46396, 46397, 46398, 46399, 46402, 46406, 65535, 65535, 65535, 65535, + 65535, 65535, 46407, 46408, 46409, 46410, 46414, 46415, 46417, 46418, + 46419, 46421, 46422, 46423, 46424, 46425, 46426, 46427, 46430, 46434, + 46435, 46436, 46437, 46438, 46439, 46440, 46441, 46442, 65535, 65535, + 65535, 65535, 65535, 65535, 46443, 46444, 46445, 46446, 46447, 46448, + 46449, 46450, 46451, 46452, 46453, 46454, 46455, 46456, 46457, 46458, + 46459, 46460, 46461, 46462, 46463, 46464, 46465, 46466, 46467, 46468, + 46469, 46470, 46471, 46472, 46473, 46474, 46475, 46476, 46477, 46478, + 46479, 46480, 46481, 46482, 46483, 46484, 46485, 46486, 46487, 46488, + 46489, 46490, 46491, 46492, 46493, 46494, 46495, 46498, 46499, 46501, + 46502, 46503, 46505, 46508, 46509, 46510, 46511, 46514, 46518, 46519, + 46520, 46521, 46522, 46526, 46527, 46529, 46530, 46531, 46533, 46534, + 46535, 46536, 46537, 46538, 46539, 46542, 46546, 46547, 46548, 46549, + 46550, 46551, 46553, 46554, 46555, 46556, 46557, 46558, 46559, 46560, + 46561, 46562, 46563, 46564, 46565, 46566, 46567, 46568, 46569, 46570, + 46571, 46573, 46574, 46575, 46576, 46577, 46578, 46579, 46580, 46581, + 46582, 46583, 46584, 46585, 46586, 46587, 46588, 46589, 46590, 46591, + 46592, 46593, 46594, 46595, 46596, 46597, 46598, 46599, 46600, 46601, + 46602, 46603, 46604, 46605, 46606, 46607, 46610, 46611, 46613, 46614, + 46615, 46617, 46618, 46619, 46620, 46621, 65535, 65535, 65535, 65535, + 65535, 65535, 46622, 46623, 46624, 46625, 46626, 46627, 46628, 46630, + 46631, 46632, 46633, 46634, 46635, 46637, 46638, 46639, 46640, 46641, + 46642, 46643, 46645, 46646, 46647, 46648, 46649, 46650, 65535, 65535, + 65535, 65535, 65535, 65535, 46651, 46652, 46653, 46654, 46655, 46656, + 46657, 46658, 46659, 46660, 46661, 46662, 46663, 46665, 46666, 46667, + 46668, 46669, 46670, 46671, 46672, 46673, 46674, 46675, 46676, 46677, + 46678, 46679, 46680, 46681, 46682, 46683, 46684, 46685, 46686, 46687, + 46688, 46689, 46690, 46691, 46693, 46694, 46695, 46697, 46698, 46699, + 46700, 46701, 46702, 46703, 46704, 46705, 46706, 46707, 46708, 46709, + 46710, 46711, 46712, 46713, 46714, 46715, 46716, 46717, 46718, 46719, + 46720, 46721, 46722, 46723, 46724, 46725, 46726, 46727, 46728, 46729, + 46730, 46731, 46732, 46733, 46734, 46735, 46736, 46737, 46738, 46739, + 46740, 46741, 46742, 46743, 46744, 46745, 46746, 46747, 46750, 46751, + 46753, 46754, 46755, 46757, 46758, 46759, 46760, 46761, 46762, 46765, + 46766, 46767, 46768, 46770, 46771, 46772, 46773, 46774, 46775, 46776, + 46777, 46778, 46779, 46780, 46781, 46782, 46783, 46784, 46785, 46786, + 46787, 46788, 46789, 46790, 46791, 46792, 46793, 46794, 46795, 46796, + 46797, 46798, 46799, 46800, 46801, 46802, 46803, 46805, 46806, 46807, + 46808, 46809, 46810, 46811, 46812, 46813, 65535, 65535, 65535, 65535, + 65535, 65535, 46814, 46815, 46816, 46817, 46818, 46819, 46820, 46821, + 46822, 46823, 46824, 46825, 46826, 46827, 46828, 46829, 46830, 46831, + 46833, 46834, 46835, 46837, 46838, 46839, 46841, 46842, 65535, 65535, + 65535, 65535, 65535, 65535, 46843, 46844, 46845, 46846, 46847, 46850, + 46851, 46852, 46854, 46855, 46856, 46857, 46858, 46859, 46860, 46861, + 46862, 46863, 46864, 46865, 46866, 46867, 46868, 46869, 46870, 46871, + 46872, 46873, 46874, 46875, 46876, 46877, 46878, 46879, 46880, 46881, + 46882, 46883, 46884, 46885, 46886, 46887, 46890, 46891, 46893, 46894, + 46897, 46898, 46899, 46900, 46901, 46902, 46903, 46906, 46908, 46909, + 46910, 46911, 46912, 46913, 46914, 46915, 46917, 46918, 46919, 46921, + 46922, 46923, 46925, 46926, 46927, 46928, 46929, 46930, 46931, 46934, + 46935, 46936, 46937, 46938, 46939, 46940, 46941, 46942, 46943, 46945, + 46946, 46947, 46949, 46950, 46951, 46953, 46954, 46955, 46956, 46957, + 46958, 46959, 46962, 46964, 46966, 46967, 46968, 46969, 46970, 46971, + 46974, 46975, 46977, 46978, 46979, 46981, 46982, 46983, 46984, 46985, + 46986, 46987, 46990, 46995, 46996, 46997, 47002, 47003, 47005, 47006, + 47007, 47009, 47010, 47011, 47012, 47013, 47014, 47015, 47018, 47022, + 47023, 47024, 47025, 47026, 47027, 47030, 47031, 47033, 47034, 47035, + 47036, 47037, 47038, 47039, 47040, 47041, 65535, 65535, 65535, 65535, + 65535, 65535, 47042, 47043, 47044, 47045, 47046, 47048, 47050, 47051, + 47052, 47053, 47054, 47055, 47056, 47057, 47058, 47059, 47060, 47061, + 47062, 47063, 47064, 47065, 47066, 47067, 47068, 47069, 65535, 65535, + 65535, 65535, 65535, 65535, 47070, 47071, 47072, 47073, 47074, 47075, + 47076, 47077, 47078, 47079, 47080, 47081, 47082, 47083, 47086, 47087, + 47089, 47090, 47091, 47093, 47094, 47095, 47096, 47097, 47098, 47099, + 47102, 47106, 47107, 47108, 47109, 47110, 47114, 47115, 47117, 47118, + 47119, 47121, 47122, 47123, 47124, 47125, 47126, 47127, 47130, 47132, + 47134, 47135, 47136, 47137, 47138, 47139, 47142, 47143, 47145, 47146, + 47147, 47149, 47150, 47151, 47152, 47153, 47154, 47155, 47158, 47162, + 47163, 47164, 47165, 47166, 47167, 47169, 47170, 47171, 47173, 47174, + 47175, 47176, 47177, 47178, 47179, 47180, 47181, 47182, 47183, 47184, + 47186, 47188, 47189, 47190, 47191, 47192, 47193, 47194, 47195, 47198, + 47199, 47201, 47202, 47203, 47205, 47206, 47207, 47208, 47209, 47210, + 47211, 47214, 47216, 47218, 47219, 47220, 47221, 47222, 47223, 47225, + 47226, 47227, 47229, 47230, 47231, 47232, 47233, 47234, 47235, 47236, + 47237, 47238, 47239, 47240, 47241, 47242, 47243, 47244, 47246, 47247, + 47248, 47249, 47250, 47251, 47252, 47253, 47254, 47255, 47256, 47257, + 47258, 47259, 47260, 47261, 47262, 47263, 65535, 65535, 65535, 65535, + 65535, 65535, 47264, 47265, 47266, 47267, 47268, 47269, 47270, 47271, + 47273, 47274, 47275, 47276, 47277, 47278, 47279, 47281, 47282, 47283, + 47285, 47286, 47287, 47289, 47290, 47291, 47292, 47293, 65535, 65535, + 65535, 65535, 65535, 65535, 47294, 47295, 47298, 47300, 47302, 47303, + 47304, 47305, 47306, 47307, 47309, 47310, 47311, 47313, 47314, 47315, + 47317, 47318, 47319, 47320, 47321, 47322, 47323, 47324, 47326, 47328, + 47330, 47331, 47332, 47333, 47334, 47335, 47338, 47339, 47341, 47342, + 47343, 47345, 47346, 47347, 47348, 47349, 47350, 47351, 47354, 47356, + 47358, 47359, 47360, 47361, 47362, 47363, 47365, 47366, 47367, 47368, + 47369, 47370, 47371, 47372, 47373, 47374, 47375, 47376, 47377, 47378, + 47379, 47380, 47381, 47382, 47383, 47385, 47386, 47387, 47388, 47389, + 47390, 47391, 47393, 47394, 47395, 47396, 47397, 47398, 47399, 47400, + 47401, 47402, 47403, 47404, 47405, 47406, 47407, 47408, 47409, 47410, + 47411, 47412, 47413, 47414, 47415, 47416, 47417, 47418, 47419, 47422, + 47423, 47425, 47426, 47427, 47429, 47430, 47431, 47432, 47433, 47434, + 47435, 47437, 47438, 47440, 47442, 47443, 47444, 47445, 47446, 47447, + 47450, 47451, 47453, 47454, 47455, 47457, 47458, 47459, 47460, 47461, + 47462, 47463, 47466, 47468, 47470, 47471, 47472, 47473, 47474, 47475, + 47478, 47479, 47481, 47482, 47483, 47485, 65535, 65535, 65535, 65535, + 65535, 65535, 47486, 47487, 47488, 47489, 47490, 47491, 47494, 47496, + 47499, 47500, 47503, 47504, 47505, 47506, 47507, 47508, 47509, 47510, + 47511, 47512, 47513, 47514, 47515, 47516, 47517, 47518, 65535, 65535, + 65535, 65535, 65535, 65535, 47519, 47520, 47521, 47522, 47523, 47524, + 47525, 47526, 47527, 47528, 47529, 47530, 47531, 47534, 47535, 47537, + 47538, 47539, 47541, 47542, 47543, 47544, 47545, 47546, 47547, 47550, + 47552, 47554, 47555, 47556, 47557, 47558, 47559, 47562, 47563, 47565, + 47571, 47572, 47573, 47574, 47575, 47578, 47580, 47583, 47584, 47586, + 47590, 47591, 47593, 47594, 47595, 47597, 47598, 47599, 47600, 47601, + 47602, 47603, 47606, 47611, 47612, 47613, 47614, 47615, 47618, 47619, + 47620, 47621, 47622, 47623, 47625, 47626, 47627, 47628, 47629, 47630, + 47631, 47632, 47633, 47634, 47635, 47636, 47638, 47639, 47640, 47641, + 47642, 47643, 47644, 47645, 47646, 47647, 47648, 47649, 47650, 47651, + 47652, 47653, 47654, 47655, 47656, 47657, 47658, 47659, 47660, 47661, + 47662, 47663, 47664, 47665, 47666, 47667, 47668, 47669, 47670, 47671, + 47674, 47675, 47677, 47678, 47679, 47681, 47683, 47684, 47685, 47686, + 47687, 47690, 47692, 47695, 47696, 47697, 47698, 47702, 47703, 47705, + 47706, 47707, 47709, 47710, 47711, 47712, 47713, 47714, 47715, 47718, + 47722, 47723, 47724, 47725, 47726, 47727, 65535, 65535, 65535, 65535, + 65535, 65535, 47730, 47731, 47733, 47734, 47735, 47737, 47738, 47739, + 47740, 47741, 47742, 47743, 47744, 47745, 47746, 47750, 47752, 47753, + 47754, 47755, 47757, 47758, 47759, 47760, 47761, 47762, 65535, 65535, + 65535, 65535, 65535, 65535, 47763, 47764, 47765, 47766, 47767, 47768, + 47769, 47770, 47771, 47772, 47773, 47774, 47775, 47776, 47777, 47778, + 47779, 47780, 47781, 47782, 47783, 47786, 47789, 47790, 47791, 47793, + 47795, 47796, 47797, 47798, 47799, 47802, 47804, 47806, 47807, 47808, + 47809, 47810, 47811, 47813, 47814, 47815, 47817, 47818, 47819, 47820, + 47821, 47822, 47823, 47824, 47825, 47826, 47827, 47828, 47829, 47830, + 47831, 47834, 47835, 47836, 47837, 47838, 47839, 47840, 47841, 47842, + 47843, 47844, 47845, 47846, 47847, 47848, 47849, 47850, 47851, 47852, + 47853, 47854, 47855, 47856, 47857, 47858, 47859, 47860, 47861, 47862, + 47863, 47864, 47865, 47866, 47867, 47869, 47870, 47871, 47873, 47874, + 47875, 47877, 47878, 47879, 47880, 47881, 47882, 47883, 47884, 47886, + 47888, 47890, 47891, 47892, 47893, 47894, 47895, 47897, 47898, 47899, + 47901, 47902, 47903, 47905, 47906, 47907, 47908, 47909, 47910, 47911, + 47912, 47914, 47916, 47917, 47918, 47919, 47920, 47921, 47922, 47923, + 47927, 47929, 47930, 47935, 47936, 47937, 47938, 47939, 47942, 47944, + 47946, 47947, 47948, 47950, 47953, 47954, 65535, 65535, 65535, 65535, + 65535, 65535, 47955, 47957, 47958, 47959, 47961, 47962, 47963, 47964, + 47965, 47966, 47967, 47968, 47970, 47972, 47973, 47974, 47975, 47976, + 47977, 47978, 47979, 47981, 47982, 47983, 47984, 47985, 65535, 65535, + 65535, 65535, 65535, 65535, 47986, 47987, 47988, 47989, 47990, 47991, + 47992, 47993, 47994, 47995, 47996, 47997, 47998, 47999, 48000, 48001, + 48002, 48003, 48004, 48005, 48006, 48007, 48009, 48010, 48011, 48013, + 48014, 48015, 48017, 48018, 48019, 48020, 48021, 48022, 48023, 48024, + 48025, 48026, 48027, 48028, 48029, 48030, 48031, 48032, 48033, 48034, + 48035, 48037, 48038, 48039, 48041, 48042, 48043, 48045, 48046, 48047, + 48048, 48049, 48050, 48051, 48053, 48054, 48056, 48057, 48058, 48059, + 48060, 48061, 48062, 48063, 48065, 48066, 48067, 48069, 48070, 48071, + 48073, 48074, 48075, 48076, 48077, 48078, 48079, 48081, 48082, 48084, + 48085, 48086, 48087, 48088, 48089, 48090, 48091, 48092, 48093, 48094, + 48095, 48096, 48097, 48098, 48099, 48100, 48101, 48102, 48103, 48104, + 48105, 48106, 48107, 48108, 48109, 48110, 48111, 48112, 48113, 48114, + 48115, 48116, 48117, 48118, 48119, 48122, 48123, 48125, 48126, 48129, + 48131, 48132, 48133, 48134, 48135, 48138, 48142, 48144, 48146, 48147, + 48153, 48154, 48160, 48161, 48162, 48163, 48166, 48168, 48170, 48171, + 48172, 48174, 48175, 48178, 48179, 48181, 65535, 65535, 65535, 65535, + 65535, 65535, 48182, 48183, 48185, 48186, 48187, 48188, 48189, 48190, + 48191, 48194, 48198, 48199, 48200, 48202, 48203, 48206, 48207, 48209, + 48210, 48211, 48212, 48213, 48214, 48215, 48216, 48217, 65535, 65535, + 65535, 65535, 65535, 65535, 48218, 48219, 48220, 48222, 48223, 48224, + 48225, 48226, 48227, 48228, 48229, 48230, 48231, 48232, 48233, 48234, + 48235, 48236, 48237, 48238, 48239, 48240, 48241, 48242, 48243, 48244, + 48245, 48246, 48247, 48248, 48249, 48250, 48251, 48252, 48253, 48254, + 48255, 48256, 48257, 48258, 48259, 48262, 48263, 48265, 48266, 48269, + 48271, 48272, 48273, 48274, 48275, 48278, 48280, 48283, 48284, 48285, + 48286, 48287, 48290, 48291, 48293, 48294, 48297, 48298, 48299, 48300, + 48301, 48302, 48303, 48306, 48310, 48311, 48312, 48313, 48314, 48315, + 48318, 48319, 48321, 48322, 48323, 48325, 48326, 48327, 48328, 48329, + 48330, 48331, 48332, 48334, 48338, 48339, 48340, 48342, 48343, 48345, + 48346, 48347, 48349, 48350, 48351, 48352, 48353, 48354, 48355, 48356, + 48357, 48358, 48359, 48360, 48361, 48362, 48363, 48364, 48365, 48366, + 48367, 48368, 48369, 48370, 48371, 48375, 48377, 48378, 48379, 48381, + 48382, 48383, 48384, 48385, 48386, 48387, 48390, 48392, 48394, 48395, + 48396, 48397, 48398, 48399, 48401, 48402, 48403, 48405, 48406, 48407, + 48408, 48409, 48410, 48411, 48412, 48413, 65535, 65535, 65535, 65535, + 65535, 65535, 48414, 48415, 48416, 48417, 48418, 48419, 48421, 48422, + 48423, 48424, 48425, 48426, 48427, 48429, 48430, 48431, 48432, 48433, + 48434, 48435, 48436, 48437, 48438, 48439, 48440, 48441, 65535, 65535, + 65535, 65535, 65535, 65535, 48442, 48443, 48444, 48445, 48446, 48447, + 48449, 48450, 48451, 48452, 48453, 48454, 48455, 48458, 48459, 48461, + 48462, 48463, 48465, 48466, 48467, 48468, 48469, 48470, 48471, 48474, + 48475, 48476, 48477, 48478, 48479, 48480, 48481, 48482, 48483, 48485, + 48486, 48487, 48489, 48490, 48491, 48492, 48493, 48494, 48495, 48496, + 48497, 48498, 48499, 48500, 48501, 48502, 48503, 48504, 48505, 48506, + 48507, 48508, 48509, 48510, 48511, 48514, 48515, 48517, 48518, 48523, + 48524, 48525, 48526, 48527, 48530, 48532, 48534, 48535, 48536, 48539, + 48541, 48542, 48543, 48544, 48545, 48546, 48547, 48549, 48550, 48551, + 48552, 48553, 48554, 48555, 48556, 48557, 48558, 48559, 48561, 48562, + 48563, 48564, 48565, 48566, 48567, 48569, 48570, 48571, 48572, 48573, + 48574, 48575, 48576, 48577, 48578, 48579, 48580, 48581, 48582, 48583, + 48584, 48585, 48586, 48587, 48588, 48589, 48590, 48591, 48592, 48593, + 48594, 48595, 48598, 48599, 48601, 48602, 48603, 48605, 48606, 48607, + 48608, 48609, 48610, 48611, 48612, 48613, 48614, 48615, 48616, 48618, + 48619, 48620, 48621, 48622, 48623, 48625, 65535, 65535, 65535, 65535, + 65535, 65535, 48626, 48627, 48629, 48630, 48631, 48633, 48634, 48635, + 48636, 48637, 48638, 48639, 48641, 48642, 48644, 48646, 48647, 48648, + 48649, 48650, 48651, 48654, 48655, 48657, 48658, 48659, 65535, 65535, + 65535, 65535, 65535, 65535, 48661, 48662, 48663, 48664, 48665, 48666, + 48667, 48670, 48672, 48673, 48674, 48675, 48676, 48677, 48678, 48679, + 48680, 48681, 48682, 48683, 48684, 48685, 48686, 48687, 48688, 48689, + 48690, 48691, 48692, 48693, 48694, 48695, 48696, 48697, 48698, 48699, + 48700, 48701, 48702, 48703, 48704, 48705, 48706, 48707, 48710, 48711, + 48713, 48714, 48715, 48717, 48719, 48720, 48721, 48722, 48723, 48726, + 48728, 48732, 48733, 48734, 48735, 48738, 48739, 48741, 48742, 48743, + 48745, 48747, 48748, 48749, 48750, 48751, 48754, 48758, 48759, 48760, + 48761, 48762, 48766, 48767, 48769, 48770, 48771, 48773, 48774, 48775, + 48776, 48777, 48778, 48779, 48782, 48786, 48787, 48788, 48789, 48790, + 48791, 48794, 48795, 48796, 48797, 48798, 48799, 48800, 48801, 48802, + 48803, 48804, 48805, 48806, 48807, 48809, 48810, 48811, 48812, 48813, + 48814, 48815, 48816, 48817, 48818, 48819, 48820, 48821, 48822, 48823, + 48824, 48825, 48826, 48827, 48828, 48829, 48830, 48831, 48832, 48833, + 48834, 48835, 48836, 48837, 48838, 48839, 48840, 48841, 48842, 48843, + 48844, 48845, 48846, 48847, 48850, 48851, 65535, 65535, 65535, 65535, + 65535, 65535, 48853, 48854, 48857, 48858, 48859, 48860, 48861, 48862, + 48863, 48865, 48866, 48870, 48871, 48872, 48873, 48874, 48875, 48877, + 48878, 48879, 48880, 48881, 48882, 48883, 48884, 48885, 65535, 65535, + 65535, 65535, 65535, 65535, 48886, 48887, 48888, 48889, 48890, 48891, + 48892, 48893, 48894, 48895, 48896, 48898, 48899, 48900, 48901, 48902, + 48903, 48906, 48907, 48908, 48909, 48910, 48911, 48912, 48913, 48914, + 48915, 48916, 48917, 48918, 48919, 48922, 48926, 48927, 48928, 48929, + 48930, 48931, 48932, 48933, 48934, 48935, 48936, 48937, 48938, 48939, + 48940, 48941, 48942, 48943, 48944, 48945, 48946, 48947, 48948, 48949, + 48950, 48951, 48952, 48953, 48954, 48955, 48956, 48957, 48958, 48959, + 48962, 48963, 48965, 48966, 48967, 48969, 48970, 48971, 48972, 48973, + 48974, 48975, 48978, 48979, 48980, 48982, 48983, 48984, 48985, 48986, + 48987, 48988, 48989, 48990, 48991, 48992, 48993, 48994, 48995, 48996, + 48997, 48998, 48999, 49000, 49001, 49002, 49003, 49004, 49005, 49006, + 49007, 49008, 49009, 49010, 49011, 49012, 49013, 49014, 49015, 49016, + 49017, 49018, 49019, 49020, 49021, 49022, 49023, 49024, 49025, 49026, + 49027, 49028, 49029, 49030, 49031, 49032, 49033, 49034, 49035, 49036, + 49037, 49038, 49039, 49040, 49041, 49042, 49043, 49045, 49046, 49047, + 49048, 49049, 49050, 49051, 49052, 49053, 65535, 65535, 65535, 65535, + 65535, 65535, 49054, 49055, 49056, 49057, 49058, 49059, 49060, 49061, + 49062, 49063, 49064, 49065, 49066, 49067, 49068, 49069, 49070, 49071, + 49073, 49074, 49075, 49076, 49077, 49078, 49079, 49080, 65535, 65535, + 65535, 65535, 65535, 65535, 49081, 49082, 49083, 49084, 49085, 49086, + 49087, 49088, 49089, 49090, 49091, 49092, 49094, 49095, 49096, 49097, + 49098, 49099, 49102, 49103, 49105, 49106, 49107, 49109, 49110, 49111, + 49112, 49113, 49114, 49115, 49117, 49118, 49120, 49122, 49123, 49124, + 49125, 49126, 49127, 49128, 49129, 49130, 49131, 49132, 49133, 49134, + 49135, 49136, 49137, 49138, 49139, 49140, 49141, 49142, 49143, 49144, + 49145, 49146, 49147, 49148, 49149, 49150, 49151, 49152, 49153, 49154, + 49155, 49156, 49157, 49158, 49159, 49160, 49161, 49162, 49163, 49164, + 49165, 49166, 49167, 49168, 49169, 49170, 49171, 49172, 49173, 49174, + 49175, 49176, 49177, 49178, 49179, 49180, 49181, 49182, 49183, 49184, + 49185, 49186, 49187, 49188, 49189, 49190, 49191, 49192, 49193, 49194, + 49195, 49196, 49197, 49198, 49199, 49200, 49201, 49202, 49203, 49204, + 49205, 49206, 49207, 49208, 49209, 49210, 49211, 49213, 49214, 49215, + 49216, 49217, 49218, 49219, 49220, 49221, 49222, 49223, 49224, 49225, + 49226, 49227, 49228, 49229, 49230, 49231, 49232, 49234, 49235, 49236, + 49237, 49238, 49239, 49241, 49242, 49243, 65535, 65535, 65535, 65535, + 65535, 65535, 49245, 49246, 49247, 49249, 49250, 49251, 49252, 49253, + 49254, 49255, 49258, 49259, 49260, 49261, 49262, 49263, 49264, 49265, + 49266, 49267, 49268, 49269, 49270, 49271, 49272, 49273, 65535, 65535, + 65535, 65535, 65535, 65535, 49274, 49275, 49276, 49277, 49278, 49279, + 49280, 49281, 49282, 49283, 49284, 49285, 49286, 49287, 49288, 49289, + 49290, 49291, 49292, 49293, 49294, 49295, 49298, 49299, 49301, 49302, + 49303, 49305, 49306, 49307, 49308, 49309, 49310, 49311, 49314, 49316, + 49318, 49319, 49320, 49321, 49322, 49323, 49326, 49329, 49330, 49335, + 49336, 49337, 49338, 49339, 49342, 49346, 49347, 49348, 49350, 49351, + 49354, 49355, 49357, 49358, 49359, 49361, 49362, 49363, 49364, 49365, + 49366, 49367, 49370, 49374, 49375, 49376, 49377, 49378, 49379, 49382, + 49383, 49385, 49386, 49387, 49389, 49390, 49391, 49392, 49393, 49394, + 49395, 49398, 49400, 49402, 49403, 49404, 49405, 49406, 49407, 49409, + 49410, 49411, 49413, 49414, 49415, 49417, 49418, 49419, 49420, 49421, + 49422, 49423, 49425, 49426, 49427, 49428, 49430, 49431, 49432, 49433, + 49434, 49435, 49441, 49442, 49445, 49448, 49449, 49450, 49451, 49454, + 49458, 49459, 49460, 49461, 49463, 49466, 49467, 49469, 49470, 49471, + 49473, 49474, 49475, 49476, 49477, 49478, 49479, 49482, 49486, 49487, + 49488, 49489, 49490, 49491, 49494, 49495, 65535, 65535, 65535, 65535, + 65535, 65535, 49497, 49498, 49499, 49501, 49502, 49503, 49504, 49505, + 49506, 49507, 49510, 49514, 49515, 49516, 49517, 49518, 49519, 49521, + 49522, 49523, 49525, 49526, 49527, 49529, 49530, 49531, 65535, 65535, + 65535, 65535, 65535, 65535, 49532, 49533, 49534, 49535, 49536, 49537, + 49538, 49539, 49540, 49542, 49543, 49544, 49545, 49546, 49547, 49551, + 49553, 49554, 49555, 49557, 49559, 49560, 49561, 49562, 49563, 49566, + 49568, 49570, 49571, 49572, 49574, 49575, 49578, 49579, 49581, 49582, + 49583, 49585, 49586, 49587, 49588, 49589, 49590, 49591, 49592, 49593, + 49594, 49595, 49596, 49598, 49599, 49600, 49601, 49602, 49603, 49605, + 49606, 49607, 49609, 49610, 49611, 49613, 49614, 49615, 49616, 49617, + 49618, 49619, 49621, 49622, 49625, 49626, 49627, 49628, 49629, 49630, + 49631, 49633, 49634, 49635, 49637, 49638, 49639, 49641, 49642, 49643, + 49644, 49645, 49646, 49647, 49650, 49652, 49653, 49654, 49655, 49656, + 49657, 49658, 49659, 49662, 49663, 49665, 49666, 49667, 49669, 49670, + 49671, 49672, 49673, 49674, 49675, 49678, 49680, 49682, 49683, 49684, + 49685, 49686, 49687, 49690, 49691, 49693, 49694, 49697, 49698, 49699, + 49700, 49701, 49702, 49703, 49706, 49708, 49710, 49712, 49715, 49717, + 49718, 49719, 49720, 49721, 49722, 49723, 49724, 49725, 49726, 49727, + 49728, 49729, 49730, 49731, 49732, 49733, 65535, 65535, 65535, 65535, + 65535, 65535, 49734, 49735, 49737, 49738, 49739, 49740, 49741, 49742, + 49743, 49746, 49747, 49749, 49750, 49751, 49753, 49754, 49755, 49756, + 49757, 49758, 49759, 49761, 49762, 49763, 49764, 49766, 65535, 65535, + 65535, 65535, 65535, 65535, 49767, 49768, 49769, 49770, 49771, 49774, + 49775, 49777, 49778, 49779, 49781, 49782, 49783, 49784, 49785, 49786, + 49787, 49790, 49792, 49794, 49795, 49796, 49797, 49798, 49799, 49802, + 49803, 49804, 49805, 49806, 49807, 49809, 49810, 49811, 49812, 49813, + 49814, 49815, 49817, 49818, 49820, 49822, 49823, 49824, 49825, 49826, + 49827, 49830, 49831, 49833, 49834, 49835, 49838, 49839, 49840, 49841, + 49842, 49843, 49846, 49848, 49850, 49851, 49852, 49853, 49854, 49855, + 49856, 49857, 49858, 49859, 49860, 49861, 49862, 49863, 49864, 49865, + 49866, 49867, 49868, 49869, 49870, 49871, 49872, 49873, 49874, 49875, + 49876, 49877, 49878, 49879, 49880, 49881, 49882, 49883, 49886, 49887, + 49889, 49890, 49893, 49894, 49895, 49896, 49897, 49898, 49902, 49904, + 49906, 49907, 49908, 49909, 49911, 49914, 49917, 49918, 49919, 49921, + 49922, 49923, 49924, 49925, 49926, 49927, 49930, 49931, 49934, 49935, + 49936, 49937, 49938, 49942, 49943, 49945, 49946, 49947, 49949, 49950, + 49951, 49952, 49953, 49954, 49955, 49958, 49959, 49962, 49963, 49964, + 49965, 49966, 49967, 49968, 49969, 49970, 65535, 65535, 65535, 65535, + 65535, 65535, 49971, 49972, 49973, 49974, 49975, 49976, 49977, 49978, + 49979, 49980, 49981, 49982, 49983, 49984, 49985, 49986, 49987, 49988, + 49990, 49991, 49992, 49993, 49994, 49995, 49996, 49997, 65535, 65535, + 65535, 65535, 65535, 65535, 49998, 49999, 50000, 50001, 50002, 50003, + 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 50012, 50013, + 50014, 50015, 50016, 50017, 50018, 50019, 50020, 50021, 50022, 50023, + 50026, 50027, 50029, 50030, 50031, 50033, 50035, 50036, 50037, 50038, + 50039, 50042, 50043, 50046, 50047, 50048, 50049, 50050, 50051, 50053, + 50054, 50055, 50057, 50058, 50059, 50061, 50062, 50063, 50064, 50065, + 50066, 50067, 50068, 50069, 50070, 50071, 50072, 50073, 50074, 50075, + 50076, 50077, 50078, 50079, 50080, 50081, 50082, 50083, 50084, 50085, + 50086, 50087, 50088, 50089, 50090, 50091, 50092, 50093, 50094, 50095, + 50096, 50097, 50098, 50099, 50100, 50101, 50102, 50103, 50104, 50105, + 50106, 50107, 50108, 50109, 50110, 50111, 50113, 50114, 50115, 50116, + 50117, 50118, 50119, 50120, 50121, 50122, 50123, 50124, 50125, 50126, + 50127, 50128, 50129, 50130, 50131, 50132, 50133, 50134, 50135, 50138, + 50139, 50141, 50142, 50145, 50147, 50148, 50149, 50150, 50151, 50154, + 50155, 50156, 50158, 50159, 50160, 50161, 50162, 50163, 50166, 50167, + 50169, 50170, 50171, 50172, 50173, 50174, 65535, 65535, 65535, 65535, + 65535, 65535, 50175, 50176, 50177, 50178, 50179, 50180, 50181, 50182, + 50183, 50185, 50186, 50187, 50188, 50189, 50190, 50191, 50193, 50194, + 50195, 50196, 50197, 50198, 50199, 50200, 50201, 50202, 65535, 65535, + 65535, 65535, 65535, 65535, 50203, 50204, 50205, 50206, 50207, 50208, + 50209, 50210, 50211, 50213, 50214, 50215, 50216, 50217, 50218, 50219, + 50221, 50222, 50223, 50225, 50226, 50227, 50229, 50230, 50231, 50232, + 50233, 50234, 50235, 50238, 50239, 50240, 50241, 50242, 50243, 50244, + 50245, 50246, 50247, 50249, 50250, 50251, 50252, 50253, 50254, 50255, + 50256, 50257, 50258, 50259, 50260, 50261, 50262, 50263, 50264, 50265, + 50266, 50267, 50268, 50269, 50270, 50271, 50272, 50273, 50274, 50275, + 50278, 50279, 50281, 50282, 50283, 50285, 50286, 50287, 50288, 50289, + 50290, 50291, 50294, 50295, 50296, 50298, 50299, 50300, 50301, 50302, + 50303, 50305, 50306, 50307, 50308, 50309, 50310, 50311, 50312, 50313, + 50314, 50315, 50316, 50317, 50318, 50319, 50320, 50321, 50322, 50323, + 50325, 50326, 50327, 50328, 50329, 50330, 50331, 50333, 50334, 50335, + 50336, 50337, 50338, 50339, 50340, 50341, 50342, 50343, 50344, 50345, + 50346, 50347, 50348, 50349, 50350, 50351, 50352, 50353, 50354, 50355, + 50356, 50357, 50358, 50359, 50361, 50362, 50363, 50365, 50366, 50367, + 50368, 50369, 50370, 50371, 50372, 50373, 65535, 65535, 65535, 65535, + 65535, 65535, 50374, 50375, 50376, 50377, 50378, 50379, 50380, 50381, + 50382, 50383, 50384, 50385, 50386, 50387, 50388, 50389, 50390, 50391, + 50392, 50393, 50394, 50395, 50396, 50397, 50398, 50399, 65535, 65535, + 65535, 65535, 65535, 65535, 50400, 50401, 50402, 50403, 50404, 50405, + 50406, 50407, 50408, 50410, 50411, 50412, 50413, 50414, 50415, 50418, + 50419, 50421, 50422, 50423, 50425, 50427, 50428, 50429, 50430, 50434, + 50435, 50436, 50437, 50438, 50439, 50440, 50441, 50442, 50443, 50445, + 50446, 50447, 50449, 50450, 50451, 50453, 50454, 50455, 50456, 50457, + 50458, 50459, 50461, 50462, 50463, 50464, 50465, 50466, 50467, 50468, + 50469, 50470, 50471, 50474, 50475, 50477, 50478, 50479, 50481, 50482, + 50483, 50484, 50485, 50486, 50487, 50490, 50492, 50494, 50495, 50496, + 50497, 50498, 50499, 50502, 50503, 50507, 50511, 50512, 50513, 50514, + 50518, 50522, 50523, 50524, 50527, 50530, 50531, 50533, 50534, 50535, + 50537, 50538, 50539, 50540, 50541, 50542, 50543, 50546, 50550, 50551, + 50552, 50553, 50554, 50555, 50558, 50559, 50561, 50562, 50563, 50565, + 50566, 50568, 50569, 50570, 50571, 50574, 50576, 50578, 50579, 50580, + 50582, 50585, 50586, 50587, 50589, 50590, 50591, 50593, 50594, 50595, + 50596, 50597, 50598, 50599, 50600, 50602, 50603, 50604, 50605, 50606, + 50607, 50608, 50609, 50610, 50611, 50614, 65535, 65535, 65535, 65535, + 65535, 65535, 50615, 50618, 50623, 50624, 50625, 50626, 50627, 50635, + 50637, 50639, 50642, 50643, 50645, 50646, 50647, 50649, 50650, 50651, + 50652, 50653, 50654, 50655, 50658, 50660, 50662, 50663, 65535, 65535, + 65535, 65535, 65535, 65535, 50664, 50665, 50666, 50667, 50671, 50673, + 50674, 50675, 50677, 50680, 50681, 50682, 50683, 50690, 50691, 50692, + 50697, 50698, 50699, 50701, 50702, 50703, 50705, 50706, 50707, 50708, + 50709, 50710, 50711, 50714, 50717, 50718, 50719, 50720, 50721, 50722, + 50723, 50726, 50727, 50729, 50730, 50731, 50735, 50737, 50738, 50742, + 50744, 50746, 50748, 50749, 50750, 50751, 50754, 50755, 50757, 50758, + 50759, 50761, 50762, 50763, 50764, 50765, 50766, 50767, 50770, 50774, + 50775, 50776, 50777, 50778, 50779, 50782, 50783, 50785, 50786, 50787, + 50788, 50789, 50790, 50791, 50792, 50793, 50794, 50795, 50797, 50798, + 50800, 50802, 50803, 50804, 50805, 50806, 50807, 50810, 50811, 50813, + 50814, 50815, 50817, 50818, 50819, 50820, 50821, 50822, 50823, 50826, + 50828, 50830, 50831, 50832, 50833, 50834, 50835, 50838, 50839, 50841, + 50842, 50843, 50845, 50846, 50847, 50848, 50849, 50850, 50851, 50854, + 50856, 50858, 50859, 50860, 50861, 50862, 50863, 50866, 50867, 50869, + 50870, 50871, 50875, 50876, 50877, 50878, 50879, 50882, 50884, 50886, + 50887, 50888, 50889, 50890, 50891, 50894, 65535, 65535, 65535, 65535, + 65535, 65535, 50895, 50897, 50898, 50899, 50901, 50902, 50903, 50904, + 50905, 50906, 50907, 50910, 50911, 50914, 50915, 50916, 50917, 50918, + 50919, 50922, 50923, 50925, 50926, 50927, 50929, 50930, 65535, 65535, + 65535, 65535, 65535, 65535, 50931, 50932, 50933, 50934, 50935, 50938, + 50939, 50940, 50942, 50943, 50944, 50945, 50946, 50947, 50950, 50951, + 50953, 50954, 50955, 50957, 50958, 50959, 50960, 50961, 50962, 50963, + 50966, 50968, 50970, 50971, 50972, 50973, 50974, 50975, 50978, 50979, + 50981, 50982, 50983, 50985, 50986, 50987, 50988, 50989, 50990, 50991, + 50994, 50996, 50998, 51000, 51001, 51002, 51003, 51006, 51007, 51009, + 51010, 51011, 51013, 51014, 51015, 51016, 51017, 51019, 51022, 51024, + 51033, 51034, 51035, 51037, 51038, 51039, 51041, 51042, 51043, 51044, + 51045, 51046, 51047, 51049, 51050, 51052, 51053, 51054, 51055, 51056, + 51057, 51058, 51059, 51062, 51063, 51065, 51066, 51067, 51071, 51072, + 51073, 51074, 51078, 51083, 51084, 51085, 51087, 51090, 51091, 51093, + 51097, 51099, 51100, 51101, 51102, 51103, 51106, 51111, 51112, 51113, + 51114, 51115, 51118, 51119, 51121, 51122, 51123, 51125, 51126, 51127, + 51128, 51129, 51130, 51131, 51134, 51138, 51139, 51140, 51141, 51142, + 51143, 51146, 51147, 51149, 51151, 51153, 51154, 51155, 51156, 51157, + 51158, 51159, 51161, 51162, 51163, 51164, 65535, 65535, 65535, 65535, + 65535, 65535, 51166, 51167, 51168, 51169, 51170, 51171, 51173, 51174, + 51175, 51177, 51178, 51179, 51181, 51182, 51183, 51184, 51185, 51186, + 51187, 51188, 51189, 51190, 51191, 51192, 51193, 51194, 65535, 65535, + 65535, 65535, 65535, 65535, 51195, 51196, 51197, 51198, 51199, 51202, + 51203, 51205, 51206, 51207, 51209, 51211, 51212, 51213, 51214, 51215, + 51218, 51220, 51223, 51224, 51225, 51226, 51227, 51230, 51231, 51233, + 51234, 51235, 51237, 51238, 51239, 51240, 51241, 51242, 51243, 51246, + 51248, 51250, 51251, 51252, 51253, 51254, 51255, 51257, 51258, 51259, + 51261, 51262, 51263, 51265, 51266, 51267, 51268, 51269, 51270, 51271, + 51274, 51275, 51278, 51279, 51280, 51281, 51282, 51283, 51285, 51286, + 51287, 51288, 51289, 51290, 51291, 51292, 51293, 51294, 51295, 51296, + 51297, 51298, 51299, 51300, 51301, 51302, 51303, 51304, 51305, 51306, + 51307, 51308, 51309, 51310, 51311, 51314, 51315, 51317, 51318, 51319, + 51321, 51323, 51324, 51325, 51326, 51327, 51330, 51332, 51336, 51337, + 51338, 51342, 51343, 51344, 51345, 51346, 51347, 51349, 51350, 51351, + 51352, 51353, 51354, 51355, 51356, 51358, 51360, 51362, 51363, 51364, + 51365, 51366, 51367, 51369, 51370, 51371, 51372, 51373, 51374, 51375, + 51376, 51377, 51378, 51379, 51380, 51381, 51382, 51383, 51384, 51385, + 51386, 51387, 51390, 51391, 51392, 51393, 65535, 65535, 65535, 65535, + 65535, 65535, 51394, 51395, 51397, 51398, 51399, 51401, 51402, 51403, + 51405, 51406, 51407, 51408, 51409, 51410, 51411, 51414, 51416, 51418, + 51419, 51420, 51421, 51422, 51423, 51426, 51427, 51429, 65535, 65535, + 65535, 65535, 65535, 65535, 51430, 51431, 51432, 51433, 51434, 51435, + 51436, 51437, 51438, 51439, 51440, 51441, 51442, 51443, 51444, 51446, + 51447, 51448, 51449, 51450, 51451, 51454, 51455, 51457, 51458, 51459, + 51463, 51464, 51465, 51466, 51467, 51470, 12288, 12289, 12290, 183, 8229, + 8230, 168, 12291, 173, 8213, 8741, 65340, 8764, 8216, 8217, 8220, 8221, + 12308, 12309, 12296, 12297, 12298, 12299, 12300, 12301, 12302, 12303, + 12304, 12305, 177, 215, 247, 8800, 8804, 8805, 8734, 8756, 176, 8242, 8243, + 8451, 8491, 65504, 65505, 65509, 9794, 9792, 8736, 8869, 8978, 8706, 8711, + 8801, 8786, 167, 8251, 9734, 9733, 9675, 9679, 9678, 9671, 9670, 9633, + 9632, 9651, 9650, 9661, 9660, 8594, 8592, 8593, 8595, 8596, 12307, 8810, + 8811, 8730, 8765, 8733, 8757, 8747, 8748, 8712, 8715, 8838, 8839, 8834, + 8835, 8746, 8745, 8743, 8744, 65506, 51472, 51474, 51475, 51476, 51477, + 51478, 51479, 51481, 51482, 51483, 51484, 51485, 51486, 51487, 51488, + 51489, 51490, 51491, 51492, 51493, 51494, 51495, 51496, 51497, 51498, + 51499, 65535, 65535, 65535, 65535, 65535, 65535, 51501, 51502, 51503, + 51504, 51505, 51506, 51507, 51509, 51510, 51511, 51512, 51513, 51514, + 51515, 51516, 51517, 51518, 51519, 51520, 51521, 51522, 51523, 51524, + 51525, 51526, 51527, 65535, 65535, 65535, 65535, 65535, 65535, 51528, + 51529, 51530, 51531, 51532, 51533, 51534, 51535, 51538, 51539, 51541, + 51542, 51543, 51545, 51546, 51547, 51548, 51549, 51550, 51551, 51554, + 51556, 51557, 51558, 51559, 51560, 51561, 51562, 51563, 51565, 51566, + 51567, 8658, 8660, 8704, 8707, 180, 65374, 711, 728, 733, 730, 729, 184, + 731, 161, 191, 720, 8750, 8721, 8719, 164, 8457, 8240, 9665, 9664, 9655, + 9654, 9828, 9824, 9825, 9829, 9831, 9827, 8857, 9672, 9635, 9680, 9681, + 9618, 9636, 9637, 9640, 9639, 9638, 9641, 9832, 9743, 9742, 9756, 9758, + 182, 8224, 8225, 8597, 8599, 8601, 8598, 8600, 9837, 9833, 9834, 9836, + 12927, 12828, 8470, 13255, 8482, 13250, 13272, 8481, 8364, 174, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 51569, 51570, 51571, 51573, 51574, 51575, 51576, 51577, + 51578, 51579, 51581, 51582, 51583, 51584, 51585, 51586, 51587, 51588, + 51589, 51590, 51591, 51594, 51595, 51597, 51598, 51599, 65535, 65535, + 65535, 65535, 65535, 65535, 51601, 51602, 51603, 51604, 51605, 51606, + 51607, 51610, 51612, 51614, 51615, 51616, 51617, 51618, 51619, 51620, + 51621, 51622, 51623, 51624, 51625, 51626, 51627, 51628, 51629, 51630, + 65535, 65535, 65535, 65535, 65535, 65535, 51631, 51632, 51633, 51634, + 51635, 51636, 51637, 51638, 51639, 51640, 51641, 51642, 51643, 51644, + 51645, 51646, 51647, 51650, 51651, 51653, 51654, 51657, 51659, 51660, + 51661, 51662, 51663, 51666, 51668, 51671, 51672, 51675, 65281, 65282, + 65283, 65284, 65285, 65286, 65287, 65288, 65289, 65290, 65291, 65292, + 65293, 65294, 65295, 65296, 65297, 65298, 65299, 65300, 65301, 65302, + 65303, 65304, 65305, 65306, 65307, 65308, 65309, 65310, 65311, 65312, + 65313, 65314, 65315, 65316, 65317, 65318, 65319, 65320, 65321, 65322, + 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, 65332, + 65333, 65334, 65335, 65336, 65337, 65338, 65339, 65510, 65341, 65342, + 65343, 65344, 65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, + 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, 65361, 65362, + 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, 65371, 65372, + 65373, 65507, 51678, 51679, 51681, 51683, 51685, 51686, 51688, 51689, + 51690, 51691, 51694, 51698, 51699, 51700, 51701, 51702, 51703, 51706, + 51707, 51709, 51710, 51711, 51713, 51714, 51715, 51716, 65535, 65535, + 65535, 65535, 65535, 65535, 51717, 51718, 51719, 51722, 51726, 51727, + 51728, 51729, 51730, 51731, 51733, 51734, 51735, 51737, 51738, 51739, + 51740, 51741, 51742, 51743, 51744, 51745, 51746, 51747, 51748, 51749, + 65535, 65535, 65535, 65535, 65535, 65535, 51750, 51751, 51752, 51754, + 51755, 51756, 51757, 51758, 51759, 51760, 51761, 51762, 51763, 51764, + 51765, 51766, 51767, 51768, 51769, 51770, 51771, 51772, 51773, 51774, + 51775, 51776, 51777, 51778, 51779, 51780, 51781, 51782, 12593, 12594, + 12595, 12596, 12597, 12598, 12599, 12600, 12601, 12602, 12603, 12604, + 12605, 12606, 12607, 12608, 12609, 12610, 12611, 12612, 12613, 12614, + 12615, 12616, 12617, 12618, 12619, 12620, 12621, 12622, 12623, 12624, + 12625, 12626, 12627, 12628, 12629, 12630, 12631, 12632, 12633, 12634, + 12635, 12636, 12637, 12638, 12639, 12640, 12641, 12642, 12643, 12644, + 12645, 12646, 12647, 12648, 12649, 12650, 12651, 12652, 12653, 12654, + 12655, 12656, 12657, 12658, 12659, 12660, 12661, 12662, 12663, 12664, + 12665, 12666, 12667, 12668, 12669, 12670, 12671, 12672, 12673, 12674, + 12675, 12676, 12677, 12678, 12679, 12680, 12681, 12682, 12683, 12684, + 12685, 12686, 51783, 51784, 51785, 51786, 51787, 51790, 51791, 51793, + 51794, 51795, 51797, 51798, 51799, 51800, 51801, 51802, 51803, 51806, + 51810, 51811, 51812, 51813, 51814, 51815, 51817, 51818, 65535, 65535, + 65535, 65535, 65535, 65535, 51819, 51820, 51821, 51822, 51823, 51824, + 51825, 51826, 51827, 51828, 51829, 51830, 51831, 51832, 51833, 51834, + 51835, 51836, 51838, 51839, 51840, 51841, 51842, 51843, 51845, 51846, + 65535, 65535, 65535, 65535, 65535, 65535, 51847, 51848, 51849, 51850, + 51851, 51852, 51853, 51854, 51855, 51856, 51857, 51858, 51859, 51860, + 51861, 51862, 51863, 51865, 51866, 51867, 51868, 51869, 51870, 51871, + 51872, 51873, 51874, 51875, 51876, 51877, 51878, 51879, 8560, 8561, 8562, + 8563, 8564, 8565, 8566, 8567, 8568, 8569, 65535, 65535, 65535, 65535, + 65535, 8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 913, 914, 915, 916, 917, 918, + 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, + 935, 936, 937, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 945, + 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, + 961, 963, 964, 965, 966, 967, 968, 969, 65535, 65535, 65535, 65535, 65535, + 65535, 51880, 51881, 51882, 51883, 51884, 51885, 51886, 51887, 51888, + 51889, 51890, 51891, 51892, 51893, 51894, 51895, 51896, 51897, 51898, + 51899, 51902, 51903, 51905, 51906, 51907, 51909, 65535, 65535, 65535, + 65535, 65535, 65535, 51910, 51911, 51912, 51913, 51914, 51915, 51918, + 51920, 51922, 51924, 51925, 51926, 51927, 51930, 51931, 51932, 51933, + 51934, 51935, 51937, 51938, 51939, 51940, 51941, 51942, 51943, 65535, + 65535, 65535, 65535, 65535, 65535, 51944, 51945, 51946, 51947, 51949, + 51950, 51951, 51952, 51953, 51954, 51955, 51957, 51958, 51959, 51960, + 51961, 51962, 51963, 51964, 51965, 51966, 51967, 51968, 51969, 51970, + 51971, 51972, 51973, 51974, 51975, 51977, 51978, 9472, 9474, 9484, 9488, + 9496, 9492, 9500, 9516, 9508, 9524, 9532, 9473, 9475, 9487, 9491, 9499, + 9495, 9507, 9523, 9515, 9531, 9547, 9504, 9519, 9512, 9527, 9535, 9501, + 9520, 9509, 9528, 9538, 9490, 9489, 9498, 9497, 9494, 9493, 9486, 9485, + 9502, 9503, 9505, 9506, 9510, 9511, 9513, 9514, 9517, 9518, 9521, 9522, + 9525, 9526, 9529, 9530, 9533, 9534, 9536, 9537, 9539, 9540, 9541, 9542, + 9543, 9544, 9545, 9546, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 51979, + 51980, 51981, 51982, 51983, 51985, 51986, 51987, 51989, 51990, 51991, + 51993, 51994, 51995, 51996, 51997, 51998, 51999, 52002, 52003, 52004, + 52005, 52006, 52007, 52008, 52009, 65535, 65535, 65535, 65535, 65535, + 65535, 52010, 52011, 52012, 52013, 52014, 52015, 52016, 52017, 52018, + 52019, 52020, 52021, 52022, 52023, 52024, 52025, 52026, 52027, 52028, + 52029, 52030, 52031, 52032, 52034, 52035, 52036, 65535, 65535, 65535, + 65535, 65535, 65535, 52037, 52038, 52039, 52042, 52043, 52045, 52046, + 52047, 52049, 52050, 52051, 52052, 52053, 52054, 52055, 52058, 52059, + 52060, 52062, 52063, 52064, 52065, 52066, 52067, 52069, 52070, 52071, + 52072, 52073, 52074, 52075, 52076, 13205, 13206, 13207, 8467, 13208, 13252, + 13219, 13220, 13221, 13222, 13209, 13210, 13211, 13212, 13213, 13214, + 13215, 13216, 13217, 13218, 13258, 13197, 13198, 13199, 13263, 13192, + 13193, 13256, 13223, 13224, 13232, 13233, 13234, 13235, 13236, 13237, + 13238, 13239, 13240, 13241, 13184, 13185, 13186, 13187, 13188, 13242, + 13243, 13244, 13245, 13246, 13247, 13200, 13201, 13202, 13203, 13204, 8486, + 13248, 13249, 13194, 13195, 13196, 13270, 13253, 13229, 13230, 13231, + 13275, 13225, 13226, 13227, 13228, 13277, 13264, 13267, 13251, 13257, + 13276, 13254, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52077, 52078, 52079, + 52080, 52081, 52082, 52083, 52084, 52085, 52086, 52087, 52090, 52091, + 52092, 52093, 52094, 52095, 52096, 52097, 52098, 52099, 52100, 52101, + 52102, 52103, 52104, 65535, 65535, 65535, 65535, 65535, 65535, 52105, + 52106, 52107, 52108, 52109, 52110, 52111, 52112, 52113, 52114, 52115, + 52116, 52117, 52118, 52119, 52120, 52121, 52122, 52123, 52125, 52126, + 52127, 52128, 52129, 52130, 52131, 65535, 65535, 65535, 65535, 65535, + 65535, 52132, 52133, 52134, 52135, 52136, 52137, 52138, 52139, 52140, + 52141, 52142, 52143, 52144, 52145, 52146, 52147, 52148, 52149, 52150, + 52151, 52153, 52154, 52155, 52156, 52157, 52158, 52159, 52160, 52161, + 52162, 52163, 52164, 198, 208, 170, 294, 65535, 306, 65535, 319, 321, 216, + 338, 186, 222, 358, 330, 65535, 12896, 12897, 12898, 12899, 12900, 12901, + 12902, 12903, 12904, 12905, 12906, 12907, 12908, 12909, 12910, 12911, + 12912, 12913, 12914, 12915, 12916, 12917, 12918, 12919, 12920, 12921, + 12922, 12923, 9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, + 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, 9442, 9443, 9444, 9445, + 9446, 9447, 9448, 9449, 9312, 9313, 9314, 9315, 9316, 9317, 9318, 9319, + 9320, 9321, 9322, 9323, 9324, 9325, 9326, 189, 8531, 8532, 188, 190, 8539, + 8540, 8541, 8542, 52165, 52166, 52167, 52168, 52169, 52170, 52171, 52172, + 52173, 52174, 52175, 52176, 52177, 52178, 52179, 52181, 52182, 52183, + 52184, 52185, 52186, 52187, 52188, 52189, 52190, 52191, 65535, 65535, + 65535, 65535, 65535, 65535, 52192, 52193, 52194, 52195, 52197, 52198, + 52200, 52202, 52203, 52204, 52205, 52206, 52207, 52208, 52209, 52210, + 52211, 52212, 52213, 52214, 52215, 52216, 52217, 52218, 52219, 52220, + 65535, 65535, 65535, 65535, 65535, 65535, 52221, 52222, 52223, 52224, + 52225, 52226, 52227, 52228, 52229, 52230, 52231, 52232, 52233, 52234, + 52235, 52238, 52239, 52241, 52242, 52243, 52245, 52246, 52247, 52248, + 52249, 52250, 52251, 52254, 52255, 52256, 52259, 52260, 230, 273, 240, 295, + 305, 307, 312, 320, 322, 248, 339, 223, 254, 359, 331, 329, 12800, 12801, + 12802, 12803, 12804, 12805, 12806, 12807, 12808, 12809, 12810, 12811, + 12812, 12813, 12814, 12815, 12816, 12817, 12818, 12819, 12820, 12821, + 12822, 12823, 12824, 12825, 12826, 12827, 9372, 9373, 9374, 9375, 9376, + 9377, 9378, 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, + 9389, 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9397, 9332, 9333, 9334, + 9335, 9336, 9337, 9338, 9339, 9340, 9341, 9342, 9343, 9344, 9345, 9346, + 185, 178, 179, 8308, 8319, 8321, 8322, 8323, 8324, 52261, 52262, 52266, + 52267, 52269, 52271, 52273, 52274, 52275, 52276, 52277, 52278, 52279, + 52282, 52287, 52288, 52289, 52290, 52291, 52294, 52295, 52297, 52298, + 52299, 52301, 52302, 65535, 65535, 65535, 65535, 65535, 65535, 52303, + 52304, 52305, 52306, 52307, 52310, 52314, 52315, 52316, 52317, 52318, + 52319, 52321, 52322, 52323, 52325, 52327, 52329, 52330, 52331, 52332, + 52333, 52334, 52335, 52337, 52338, 65535, 65535, 65535, 65535, 65535, + 65535, 52339, 52340, 52342, 52343, 52344, 52345, 52346, 52347, 52348, + 52349, 52350, 52351, 52352, 52353, 52354, 52355, 52356, 52357, 52358, + 52359, 52360, 52361, 52362, 52363, 52364, 52365, 52366, 52367, 52368, + 52369, 52370, 52371, 12353, 12354, 12355, 12356, 12357, 12358, 12359, + 12360, 12361, 12362, 12363, 12364, 12365, 12366, 12367, 12368, 12369, + 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, + 12380, 12381, 12382, 12383, 12384, 12385, 12386, 12387, 12388, 12389, + 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12397, 12398, 12399, + 12400, 12401, 12402, 12403, 12404, 12405, 12406, 12407, 12408, 12409, + 12410, 12411, 12412, 12413, 12414, 12415, 12416, 12417, 12418, 12419, + 12420, 12421, 12422, 12423, 12424, 12425, 12426, 12427, 12428, 12429, + 12430, 12431, 12432, 12433, 12434, 12435, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52372, 52373, 52374, + 52375, 52378, 52379, 52381, 52382, 52383, 52385, 52386, 52387, 52388, + 52389, 52390, 52391, 52394, 52398, 52399, 52400, 52401, 52402, 52403, + 52406, 52407, 52409, 65535, 65535, 65535, 65535, 65535, 65535, 52410, + 52411, 52413, 52414, 52415, 52416, 52417, 52418, 52419, 52422, 52424, + 52426, 52427, 52428, 52429, 52430, 52431, 52433, 52434, 52435, 52437, + 52438, 52439, 52440, 52441, 52442, 65535, 65535, 65535, 65535, 65535, + 65535, 52443, 52444, 52445, 52446, 52447, 52448, 52449, 52450, 52451, + 52453, 52454, 52455, 52456, 52457, 52458, 52459, 52461, 52462, 52463, + 52465, 52466, 52467, 52468, 52469, 52470, 52471, 52472, 52473, 52474, + 52475, 52476, 52477, 12449, 12450, 12451, 12452, 12453, 12454, 12455, + 12456, 12457, 12458, 12459, 12460, 12461, 12462, 12463, 12464, 12465, + 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, + 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12484, 12485, + 12486, 12487, 12488, 12489, 12490, 12491, 12492, 12493, 12494, 12495, + 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, + 12506, 12507, 12508, 12509, 12510, 12511, 12512, 12513, 12514, 12515, + 12516, 12517, 12518, 12519, 12520, 12521, 12522, 12523, 12524, 12525, + 12526, 12527, 12528, 12529, 12530, 12531, 12532, 12533, 12534, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52478, 52479, 52480, + 52482, 52483, 52484, 52485, 52486, 52487, 52490, 52491, 52493, 52494, + 52495, 52497, 52498, 52499, 52500, 52501, 52502, 52503, 52506, 52508, + 52510, 52511, 52512, 65535, 65535, 65535, 65535, 65535, 65535, 52513, + 52514, 52515, 52517, 52518, 52519, 52521, 52522, 52523, 52525, 52526, + 52527, 52528, 52529, 52530, 52531, 52532, 52533, 52534, 52535, 52536, + 52538, 52539, 52540, 52541, 52542, 65535, 65535, 65535, 65535, 65535, + 65535, 52543, 52544, 52545, 52546, 52547, 52548, 52549, 52550, 52551, + 52552, 52553, 52554, 52555, 52556, 52557, 52558, 52559, 52560, 52561, + 52562, 52563, 52564, 52565, 52566, 52567, 52568, 52569, 52570, 52571, + 52573, 52574, 52575, 1040, 1041, 1042, 1043, 1044, 1045, 1025, 1046, 1047, + 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, + 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1072, 1073, 1074, 1075, 1076, 1077, + 1105, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, + 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, + 1101, 1102, 1103, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 52577, 52578, 52579, 52581, 52582, + 52583, 52584, 52585, 52586, 52587, 52590, 52592, 52594, 52595, 52596, + 52597, 52598, 52599, 52601, 52602, 52603, 52604, 52605, 52606, 52607, + 52608, 65535, 65535, 65535, 65535, 65535, 65535, 52609, 52610, 52611, + 52612, 52613, 52614, 52615, 52617, 52618, 52619, 52620, 52621, 52622, + 52623, 52624, 52625, 52626, 52627, 52630, 52631, 52633, 52634, 52635, + 52637, 52638, 52639, 65535, 65535, 65535, 65535, 65535, 65535, 52640, + 52641, 52642, 52643, 52646, 52648, 52650, 52651, 52652, 52653, 52654, + 52655, 52657, 52658, 52659, 52660, 52661, 52662, 52663, 52664, 52665, + 52666, 52667, 52668, 52669, 52670, 52671, 52672, 52673, 52674, 52675, + 52677, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 52678, 52679, 52680, 52681, 52682, + 52683, 52685, 52686, 52687, 52689, 52690, 52691, 52692, 52693, 52694, + 52695, 52696, 52697, 52698, 52699, 52700, 52701, 52702, 52703, 52704, + 52705, 65535, 65535, 65535, 65535, 65535, 65535, 52706, 52707, 52708, + 52709, 52710, 52711, 52713, 52714, 52715, 52717, 52718, 52719, 52721, + 52722, 52723, 52724, 52725, 52726, 52727, 52730, 52732, 52734, 52735, + 52736, 52737, 52738, 65535, 65535, 65535, 65535, 65535, 65535, 52739, + 52741, 52742, 52743, 52745, 52746, 52747, 52749, 52750, 52751, 52752, + 52753, 52754, 52755, 52757, 52758, 52759, 52760, 52762, 52763, 52764, + 52765, 52766, 52767, 52770, 52771, 52773, 52774, 52775, 52777, 52778, + 52779, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 52780, 52781, 52782, 52783, 52786, + 52788, 52790, 52791, 52792, 52793, 52794, 52795, 52796, 52797, 52798, + 52799, 52800, 52801, 52802, 52803, 52804, 52805, 52806, 52807, 52808, + 52809, 65535, 65535, 65535, 65535, 65535, 65535, 52810, 52811, 52812, + 52813, 52814, 52815, 52816, 52817, 52818, 52819, 52820, 52821, 52822, + 52823, 52826, 52827, 52829, 52830, 52834, 52835, 52836, 52837, 52838, + 52839, 52842, 52844, 65535, 65535, 65535, 65535, 65535, 65535, 52846, + 52847, 52848, 52849, 52850, 52851, 52854, 52855, 52857, 52858, 52859, + 52861, 52862, 52863, 52864, 52865, 52866, 52867, 52870, 52872, 52874, + 52875, 52876, 52877, 52878, 52879, 52882, 52883, 52885, 52886, 52887, + 52889, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 52890, 52891, 52892, 52893, 52894, + 52895, 52898, 52902, 52903, 52904, 52905, 52906, 52907, 52910, 52911, + 52912, 52913, 52914, 52915, 52916, 52917, 52918, 52919, 52920, 52921, + 52922, 65535, 65535, 65535, 65535, 65535, 65535, 52923, 52924, 52925, + 52926, 52927, 52928, 52930, 52931, 52932, 52933, 52934, 52935, 52936, + 52937, 52938, 52939, 52940, 52941, 52942, 52943, 52944, 52945, 52946, + 52947, 52948, 52949, 65535, 65535, 65535, 65535, 65535, 65535, 52950, + 52951, 52952, 52953, 52954, 52955, 52956, 52957, 52958, 52959, 52960, + 52961, 52962, 52963, 52966, 52967, 52969, 52970, 52973, 52974, 52975, + 52976, 52977, 52978, 52979, 52982, 52986, 52987, 52988, 52989, 52990, + 52991, 44032, 44033, 44036, 44039, 44040, 44041, 44042, 44048, 44049, + 44050, 44051, 44052, 44053, 44054, 44055, 44057, 44058, 44059, 44060, + 44061, 44064, 44068, 44076, 44077, 44079, 44080, 44081, 44088, 44089, + 44092, 44096, 44107, 44109, 44116, 44120, 44124, 44144, 44145, 44148, + 44151, 44152, 44154, 44160, 44161, 44163, 44164, 44165, 44166, 44169, + 44170, 44171, 44172, 44176, 44180, 44188, 44189, 44191, 44192, 44193, + 44200, 44201, 44202, 44204, 44207, 44208, 44216, 44217, 44219, 44220, + 44221, 44225, 44228, 44232, 44236, 44245, 44247, 44256, 44257, 44260, + 44263, 44264, 44266, 44268, 44271, 44272, 44273, 44275, 44277, 44278, + 44284, 44285, 44288, 44292, 44294, 52994, 52995, 52997, 52998, 52999, + 53001, 53002, 53003, 53004, 53005, 53006, 53007, 53010, 53012, 53014, + 53015, 53016, 53017, 53018, 53019, 53021, 53022, 53023, 53025, 53026, + 53027, 65535, 65535, 65535, 65535, 65535, 65535, 53029, 53030, 53031, + 53032, 53033, 53034, 53035, 53038, 53042, 53043, 53044, 53045, 53046, + 53047, 53049, 53050, 53051, 53052, 53053, 53054, 53055, 53056, 53057, + 53058, 53059, 53060, 65535, 65535, 65535, 65535, 65535, 65535, 53061, + 53062, 53063, 53064, 53065, 53066, 53067, 53068, 53069, 53070, 53071, + 53072, 53073, 53074, 53075, 53078, 53079, 53081, 53082, 53083, 53085, + 53086, 53087, 53088, 53089, 53090, 53091, 53094, 53096, 53098, 53099, + 53100, 44300, 44301, 44303, 44305, 44312, 44316, 44320, 44329, 44332, + 44333, 44340, 44341, 44344, 44348, 44356, 44357, 44359, 44361, 44368, + 44372, 44376, 44385, 44387, 44396, 44397, 44400, 44403, 44404, 44405, + 44406, 44411, 44412, 44413, 44415, 44417, 44418, 44424, 44425, 44428, + 44432, 44444, 44445, 44452, 44471, 44480, 44481, 44484, 44488, 44496, + 44497, 44499, 44508, 44512, 44516, 44536, 44537, 44540, 44543, 44544, + 44545, 44552, 44553, 44555, 44557, 44564, 44592, 44593, 44596, 44599, + 44600, 44602, 44608, 44609, 44611, 44613, 44614, 44618, 44620, 44621, + 44622, 44624, 44628, 44630, 44636, 44637, 44639, 44640, 44641, 44645, + 44648, 44649, 44652, 44656, 44664, 53101, 53102, 53103, 53106, 53107, + 53109, 53110, 53111, 53113, 53114, 53115, 53116, 53117, 53118, 53119, + 53121, 53122, 53123, 53124, 53126, 53127, 53128, 53129, 53130, 53131, + 53133, 65535, 65535, 65535, 65535, 65535, 65535, 53134, 53135, 53136, + 53137, 53138, 53139, 53140, 53141, 53142, 53143, 53144, 53145, 53146, + 53147, 53148, 53149, 53150, 53151, 53152, 53154, 53155, 53156, 53157, + 53158, 53159, 53161, 65535, 65535, 65535, 65535, 65535, 65535, 53162, + 53163, 53164, 53165, 53166, 53167, 53169, 53170, 53171, 53172, 53173, + 53174, 53175, 53176, 53177, 53178, 53179, 53180, 53181, 53182, 53183, + 53184, 53185, 53186, 53187, 53189, 53190, 53191, 53192, 53193, 53194, + 53195, 44665, 44667, 44668, 44669, 44676, 44677, 44684, 44732, 44733, + 44734, 44736, 44740, 44748, 44749, 44751, 44752, 44753, 44760, 44761, + 44764, 44776, 44779, 44781, 44788, 44792, 44796, 44807, 44808, 44813, + 44816, 44844, 44845, 44848, 44850, 44852, 44860, 44861, 44863, 44865, + 44866, 44867, 44872, 44873, 44880, 44892, 44893, 44900, 44901, 44921, + 44928, 44932, 44936, 44944, 44945, 44949, 44956, 44984, 44985, 44988, + 44992, 44999, 45000, 45001, 45003, 45005, 45006, 45012, 45020, 45032, + 45033, 45040, 45041, 45044, 45048, 45056, 45057, 45060, 45068, 45072, + 45076, 45084, 45085, 45096, 45124, 45125, 45128, 45130, 45132, 45134, + 45139, 45140, 45141, 45143, 45145, 53196, 53197, 53198, 53199, 53200, + 53201, 53202, 53203, 53204, 53205, 53206, 53207, 53208, 53209, 53210, + 53211, 53212, 53213, 53214, 53215, 53218, 53219, 53221, 53222, 53223, + 53225, 65535, 65535, 65535, 65535, 65535, 65535, 53226, 53227, 53228, + 53229, 53230, 53231, 53234, 53236, 53238, 53239, 53240, 53241, 53242, + 53243, 53245, 53246, 53247, 53249, 53250, 53251, 53253, 53254, 53255, + 53256, 53257, 53258, 65535, 65535, 65535, 65535, 65535, 65535, 53259, + 53260, 53261, 53262, 53263, 53264, 53266, 53267, 53268, 53269, 53270, + 53271, 53273, 53274, 53275, 53276, 53277, 53278, 53279, 53280, 53281, + 53282, 53283, 53284, 53285, 53286, 53287, 53288, 53289, 53290, 53291, + 53292, 45149, 45180, 45181, 45184, 45188, 45196, 45197, 45199, 45201, + 45208, 45209, 45210, 45212, 45215, 45216, 45217, 45218, 45224, 45225, + 45227, 45228, 45229, 45230, 45231, 45233, 45235, 45236, 45237, 45240, + 45244, 45252, 45253, 45255, 45256, 45257, 45264, 45265, 45268, 45272, + 45280, 45285, 45320, 45321, 45323, 45324, 45328, 45330, 45331, 45336, + 45337, 45339, 45340, 45341, 45347, 45348, 45349, 45352, 45356, 45364, + 45365, 45367, 45368, 45369, 45376, 45377, 45380, 45384, 45392, 45393, + 45396, 45397, 45400, 45404, 45408, 45432, 45433, 45436, 45440, 45442, + 45448, 45449, 45451, 45453, 45458, 45459, 45460, 45464, 45468, 45480, + 45516, 45520, 45524, 45532, 45533, 53294, 53295, 53296, 53297, 53298, + 53299, 53302, 53303, 53305, 53306, 53307, 53309, 53310, 53311, 53312, + 53313, 53314, 53315, 53318, 53320, 53322, 53323, 53324, 53325, 53326, + 53327, 65535, 65535, 65535, 65535, 65535, 65535, 53329, 53330, 53331, + 53333, 53334, 53335, 53337, 53338, 53339, 53340, 53341, 53342, 53343, + 53345, 53346, 53347, 53348, 53349, 53350, 53351, 53352, 53353, 53354, + 53355, 53358, 53359, 65535, 65535, 65535, 65535, 65535, 65535, 53361, + 53362, 53363, 53365, 53366, 53367, 53368, 53369, 53370, 53371, 53374, + 53375, 53376, 53378, 53379, 53380, 53381, 53382, 53383, 53384, 53385, + 53386, 53387, 53388, 53389, 53390, 53391, 53392, 53393, 53394, 53395, + 53396, 45535, 45544, 45545, 45548, 45552, 45561, 45563, 45565, 45572, + 45573, 45576, 45579, 45580, 45588, 45589, 45591, 45593, 45600, 45620, + 45628, 45656, 45660, 45664, 45672, 45673, 45684, 45685, 45692, 45700, + 45701, 45705, 45712, 45713, 45716, 45720, 45721, 45722, 45728, 45729, + 45731, 45733, 45734, 45738, 45740, 45744, 45748, 45768, 45769, 45772, + 45776, 45778, 45784, 45785, 45787, 45789, 45794, 45796, 45797, 45798, + 45800, 45803, 45804, 45805, 45806, 45807, 45811, 45812, 45813, 45815, + 45816, 45817, 45818, 45819, 45823, 45824, 45825, 45828, 45832, 45840, + 45841, 45843, 45844, 45845, 45852, 45908, 45909, 45910, 45912, 45915, + 45916, 45918, 45919, 45924, 45925, 53397, 53398, 53399, 53400, 53401, + 53402, 53403, 53404, 53405, 53406, 53407, 53408, 53409, 53410, 53411, + 53414, 53415, 53417, 53418, 53419, 53421, 53422, 53423, 53424, 53425, + 53426, 65535, 65535, 65535, 65535, 65535, 65535, 53427, 53430, 53432, + 53434, 53435, 53436, 53437, 53438, 53439, 53442, 53443, 53445, 53446, + 53447, 53450, 53451, 53452, 53453, 53454, 53455, 53458, 53462, 53463, + 53464, 53465, 53466, 65535, 65535, 65535, 65535, 65535, 65535, 53467, + 53470, 53471, 53473, 53474, 53475, 53477, 53478, 53479, 53480, 53481, + 53482, 53483, 53486, 53490, 53491, 53492, 53493, 53494, 53495, 53497, + 53498, 53499, 53500, 53501, 53502, 53503, 53504, 53505, 53506, 53507, + 53508, 45927, 45929, 45931, 45934, 45936, 45937, 45940, 45944, 45952, + 45953, 45955, 45956, 45957, 45964, 45968, 45972, 45984, 45985, 45992, + 45996, 46020, 46021, 46024, 46027, 46028, 46030, 46032, 46036, 46037, + 46039, 46041, 46043, 46045, 46048, 46052, 46056, 46076, 46096, 46104, + 46108, 46112, 46120, 46121, 46123, 46132, 46160, 46161, 46164, 46168, + 46176, 46177, 46179, 46181, 46188, 46208, 46216, 46237, 46244, 46248, + 46252, 46261, 46263, 46265, 46272, 46276, 46280, 46288, 46293, 46300, + 46301, 46304, 46307, 46308, 46310, 46316, 46317, 46319, 46321, 46328, + 46356, 46357, 46360, 46363, 46364, 46372, 46373, 46375, 46376, 46377, + 46378, 46384, 46385, 46388, 46392, 53509, 53510, 53511, 53512, 53513, + 53514, 53515, 53516, 53518, 53519, 53520, 53521, 53522, 53523, 53524, + 53525, 53526, 53527, 53528, 53529, 53530, 53531, 53532, 53533, 53534, + 53535, 65535, 65535, 65535, 65535, 65535, 65535, 53536, 53537, 53538, + 53539, 53540, 53541, 53542, 53543, 53544, 53545, 53546, 53547, 53548, + 53549, 53550, 53551, 53554, 53555, 53557, 53558, 53559, 53561, 53563, + 53564, 53565, 53566, 65535, 65535, 65535, 65535, 65535, 65535, 53567, + 53570, 53574, 53575, 53576, 53577, 53578, 53579, 53582, 53583, 53585, + 53586, 53587, 53589, 53590, 53591, 53592, 53593, 53594, 53595, 53598, + 53600, 53602, 53603, 53604, 53605, 53606, 53607, 53609, 53610, 53611, + 53613, 46400, 46401, 46403, 46404, 46405, 46411, 46412, 46413, 46416, + 46420, 46428, 46429, 46431, 46432, 46433, 46496, 46497, 46500, 46504, + 46506, 46507, 46512, 46513, 46515, 46516, 46517, 46523, 46524, 46525, + 46528, 46532, 46540, 46541, 46543, 46544, 46545, 46552, 46572, 46608, + 46609, 46612, 46616, 46629, 46636, 46644, 46664, 46692, 46696, 46748, + 46749, 46752, 46756, 46763, 46764, 46769, 46804, 46832, 46836, 46840, + 46848, 46849, 46853, 46888, 46889, 46892, 46895, 46896, 46904, 46905, + 46907, 46916, 46920, 46924, 46932, 46933, 46944, 46948, 46952, 46960, + 46961, 46963, 46965, 46972, 46973, 46976, 46980, 46988, 46989, 46991, + 46992, 46993, 46994, 46998, 46999, 53614, 53615, 53616, 53617, 53618, + 53619, 53620, 53621, 53622, 53623, 53624, 53625, 53626, 53627, 53629, + 53630, 53631, 53632, 53633, 53634, 53635, 53637, 53638, 53639, 53641, + 53642, 65535, 65535, 65535, 65535, 65535, 65535, 53643, 53644, 53645, + 53646, 53647, 53648, 53649, 53650, 53651, 53652, 53653, 53654, 53655, + 53656, 53657, 53658, 53659, 53660, 53661, 53662, 53663, 53666, 53667, + 53669, 53670, 53671, 65535, 65535, 65535, 65535, 65535, 65535, 53673, + 53674, 53675, 53676, 53677, 53678, 53679, 53682, 53684, 53686, 53687, + 53688, 53689, 53691, 53693, 53694, 53695, 53697, 53698, 53699, 53700, + 53701, 53702, 53703, 53704, 53705, 53706, 53707, 53708, 53709, 53710, + 53711, 47000, 47001, 47004, 47008, 47016, 47017, 47019, 47020, 47021, + 47028, 47029, 47032, 47047, 47049, 47084, 47085, 47088, 47092, 47100, + 47101, 47103, 47104, 47105, 47111, 47112, 47113, 47116, 47120, 47128, + 47129, 47131, 47133, 47140, 47141, 47144, 47148, 47156, 47157, 47159, + 47160, 47161, 47168, 47172, 47185, 47187, 47196, 47197, 47200, 47204, + 47212, 47213, 47215, 47217, 47224, 47228, 47245, 47272, 47280, 47284, + 47288, 47296, 47297, 47299, 47301, 47308, 47312, 47316, 47325, 47327, + 47329, 47336, 47337, 47340, 47344, 47352, 47353, 47355, 47357, 47364, + 47384, 47392, 47420, 47421, 47424, 47428, 47436, 47439, 47441, 47448, + 47449, 47452, 47456, 47464, 47465, 53712, 53713, 53714, 53715, 53716, + 53717, 53718, 53719, 53721, 53722, 53723, 53724, 53725, 53726, 53727, + 53728, 53729, 53730, 53731, 53732, 53733, 53734, 53735, 53736, 53737, + 53738, 65535, 65535, 65535, 65535, 65535, 65535, 53739, 53740, 53741, + 53742, 53743, 53744, 53745, 53746, 53747, 53749, 53750, 53751, 53753, + 53754, 53755, 53756, 53757, 53758, 53759, 53760, 53761, 53762, 53763, + 53764, 53765, 53766, 65535, 65535, 65535, 65535, 65535, 65535, 53768, + 53770, 53771, 53772, 53773, 53774, 53775, 53777, 53778, 53779, 53780, + 53781, 53782, 53783, 53784, 53785, 53786, 53787, 53788, 53789, 53790, + 53791, 53792, 53793, 53794, 53795, 53796, 53797, 53798, 53799, 53800, + 53801, 47467, 47469, 47476, 47477, 47480, 47484, 47492, 47493, 47495, + 47497, 47498, 47501, 47502, 47532, 47533, 47536, 47540, 47548, 47549, + 47551, 47553, 47560, 47561, 47564, 47566, 47567, 47568, 47569, 47570, + 47576, 47577, 47579, 47581, 47582, 47585, 47587, 47588, 47589, 47592, + 47596, 47604, 47605, 47607, 47608, 47609, 47610, 47616, 47617, 47624, + 47637, 47672, 47673, 47676, 47680, 47682, 47688, 47689, 47691, 47693, + 47694, 47699, 47700, 47701, 47704, 47708, 47716, 47717, 47719, 47720, + 47721, 47728, 47729, 47732, 47736, 47747, 47748, 47749, 47751, 47756, + 47784, 47785, 47787, 47788, 47792, 47794, 47800, 47801, 47803, 47805, + 47812, 47816, 47832, 47833, 47868, 53802, 53803, 53806, 53807, 53809, + 53810, 53811, 53813, 53814, 53815, 53816, 53817, 53818, 53819, 53822, + 53824, 53826, 53827, 53828, 53829, 53830, 53831, 53833, 53834, 53835, + 53836, 65535, 65535, 65535, 65535, 65535, 65535, 53837, 53838, 53839, + 53840, 53841, 53842, 53843, 53844, 53845, 53846, 53847, 53848, 53849, + 53850, 53851, 53853, 53854, 53855, 53856, 53857, 53858, 53859, 53861, + 53862, 53863, 53864, 65535, 65535, 65535, 65535, 65535, 65535, 53865, + 53866, 53867, 53868, 53869, 53870, 53871, 53872, 53873, 53874, 53875, + 53876, 53877, 53878, 53879, 53880, 53881, 53882, 53883, 53884, 53885, + 53886, 53887, 53890, 53891, 53893, 53894, 53895, 53897, 53898, 53899, + 53900, 47872, 47876, 47885, 47887, 47889, 47896, 47900, 47904, 47913, + 47915, 47924, 47925, 47926, 47928, 47931, 47932, 47933, 47934, 47940, + 47941, 47943, 47945, 47949, 47951, 47952, 47956, 47960, 47969, 47971, + 47980, 48008, 48012, 48016, 48036, 48040, 48044, 48052, 48055, 48064, + 48068, 48072, 48080, 48083, 48120, 48121, 48124, 48127, 48128, 48130, + 48136, 48137, 48139, 48140, 48141, 48143, 48145, 48148, 48149, 48150, + 48151, 48152, 48155, 48156, 48157, 48158, 48159, 48164, 48165, 48167, + 48169, 48173, 48176, 48177, 48180, 48184, 48192, 48193, 48195, 48196, + 48197, 48201, 48204, 48205, 48208, 48221, 48260, 48261, 48264, 48267, + 48268, 48270, 48276, 48277, 48279, 53901, 53902, 53903, 53906, 53907, + 53908, 53910, 53911, 53912, 53913, 53914, 53915, 53917, 53918, 53919, + 53921, 53922, 53923, 53925, 53926, 53927, 53928, 53929, 53930, 53931, + 53933, 65535, 65535, 65535, 65535, 65535, 65535, 53934, 53935, 53936, + 53938, 53939, 53940, 53941, 53942, 53943, 53946, 53947, 53949, 53950, + 53953, 53955, 53956, 53957, 53958, 53959, 53962, 53964, 53965, 53966, + 53967, 53968, 53969, 65535, 65535, 65535, 65535, 65535, 65535, 53970, + 53971, 53973, 53974, 53975, 53977, 53978, 53979, 53981, 53982, 53983, + 53984, 53985, 53986, 53987, 53990, 53991, 53992, 53993, 53994, 53995, + 53996, 53997, 53998, 53999, 54002, 54003, 54005, 54006, 54007, 54009, + 54010, 48281, 48282, 48288, 48289, 48292, 48295, 48296, 48304, 48305, + 48307, 48308, 48309, 48316, 48317, 48320, 48324, 48333, 48335, 48336, + 48337, 48341, 48344, 48348, 48372, 48373, 48374, 48376, 48380, 48388, + 48389, 48391, 48393, 48400, 48404, 48420, 48428, 48448, 48456, 48457, + 48460, 48464, 48472, 48473, 48484, 48488, 48512, 48513, 48516, 48519, + 48520, 48521, 48522, 48528, 48529, 48531, 48533, 48537, 48538, 48540, + 48548, 48560, 48568, 48596, 48597, 48600, 48604, 48617, 48624, 48628, + 48632, 48640, 48643, 48645, 48652, 48653, 48656, 48660, 48668, 48669, + 48671, 48708, 48709, 48712, 48716, 48718, 48724, 48725, 48727, 48729, + 48730, 48731, 48736, 48737, 48740, 54011, 54012, 54013, 54014, 54015, + 54018, 54020, 54022, 54023, 54024, 54025, 54026, 54027, 54031, 54033, + 54034, 54035, 54037, 54039, 54040, 54041, 54042, 54043, 54046, 54050, + 54051, 65535, 65535, 65535, 65535, 65535, 65535, 54052, 54054, 54055, + 54058, 54059, 54061, 54062, 54063, 54065, 54066, 54067, 54068, 54069, + 54070, 54071, 54074, 54078, 54079, 54080, 54081, 54082, 54083, 54086, + 54087, 54088, 54089, 65535, 65535, 65535, 65535, 65535, 65535, 54090, + 54091, 54092, 54093, 54094, 54095, 54096, 54097, 54098, 54099, 54100, + 54101, 54102, 54103, 54104, 54105, 54106, 54107, 54108, 54109, 54110, + 54111, 54112, 54113, 54114, 54115, 54116, 54117, 54118, 54119, 54120, + 54121, 48744, 48746, 48752, 48753, 48755, 48756, 48757, 48763, 48764, + 48765, 48768, 48772, 48780, 48781, 48783, 48784, 48785, 48792, 48793, + 48808, 48848, 48849, 48852, 48855, 48856, 48864, 48867, 48868, 48869, + 48876, 48897, 48904, 48905, 48920, 48921, 48923, 48924, 48925, 48960, + 48961, 48964, 48968, 48976, 48977, 48981, 49044, 49072, 49093, 49100, + 49101, 49104, 49108, 49116, 49119, 49121, 49212, 49233, 49240, 49244, + 49248, 49256, 49257, 49296, 49297, 49300, 49304, 49312, 49313, 49315, + 49317, 49324, 49325, 49327, 49328, 49331, 49332, 49333, 49334, 49340, + 49341, 49343, 49344, 49345, 49349, 49352, 49353, 49356, 49360, 49368, + 49369, 49371, 49372, 49373, 49380, 54122, 54123, 54124, 54125, 54126, + 54127, 54128, 54129, 54130, 54131, 54132, 54133, 54134, 54135, 54136, + 54137, 54138, 54139, 54142, 54143, 54145, 54146, 54147, 54149, 54150, + 54151, 65535, 65535, 65535, 65535, 65535, 65535, 54152, 54153, 54154, + 54155, 54158, 54162, 54163, 54164, 54165, 54166, 54167, 54170, 54171, + 54173, 54174, 54175, 54177, 54178, 54179, 54180, 54181, 54182, 54183, + 54186, 54188, 54190, 65535, 65535, 65535, 65535, 65535, 65535, 54191, + 54192, 54193, 54194, 54195, 54197, 54198, 54199, 54201, 54202, 54203, + 54205, 54206, 54207, 54208, 54209, 54210, 54211, 54214, 54215, 54218, + 54219, 54220, 54221, 54222, 54223, 54225, 54226, 54227, 54228, 54229, + 54230, 49381, 49384, 49388, 49396, 49397, 49399, 49401, 49408, 49412, + 49416, 49424, 49429, 49436, 49437, 49438, 49439, 49440, 49443, 49444, + 49446, 49447, 49452, 49453, 49455, 49456, 49457, 49462, 49464, 49465, + 49468, 49472, 49480, 49481, 49483, 49484, 49485, 49492, 49493, 49496, + 49500, 49508, 49509, 49511, 49512, 49513, 49520, 49524, 49528, 49541, + 49548, 49549, 49550, 49552, 49556, 49558, 49564, 49565, 49567, 49569, + 49573, 49576, 49577, 49580, 49584, 49597, 49604, 49608, 49612, 49620, + 49623, 49624, 49632, 49636, 49640, 49648, 49649, 49651, 49660, 49661, + 49664, 49668, 49676, 49677, 49679, 49681, 49688, 49689, 49692, 49695, + 49696, 49704, 49705, 49707, 49709, 54231, 54233, 54234, 54235, 54236, + 54237, 54238, 54239, 54240, 54242, 54244, 54245, 54246, 54247, 54248, + 54249, 54250, 54251, 54254, 54255, 54257, 54258, 54259, 54261, 54262, + 54263, 65535, 65535, 65535, 65535, 65535, 65535, 54264, 54265, 54266, + 54267, 54270, 54272, 54274, 54275, 54276, 54277, 54278, 54279, 54281, + 54282, 54283, 54284, 54285, 54286, 54287, 54288, 54289, 54290, 54291, + 54292, 54293, 54294, 65535, 65535, 65535, 65535, 65535, 65535, 54295, + 54296, 54297, 54298, 54299, 54300, 54302, 54303, 54304, 54305, 54306, + 54307, 54308, 54309, 54310, 54311, 54312, 54313, 54314, 54315, 54316, + 54317, 54318, 54319, 54320, 54321, 54322, 54323, 54324, 54325, 54326, + 54327, 49711, 49713, 49714, 49716, 49736, 49744, 49745, 49748, 49752, + 49760, 49765, 49772, 49773, 49776, 49780, 49788, 49789, 49791, 49793, + 49800, 49801, 49808, 49816, 49819, 49821, 49828, 49829, 49832, 49836, + 49837, 49844, 49845, 49847, 49849, 49884, 49885, 49888, 49891, 49892, + 49899, 49900, 49901, 49903, 49905, 49910, 49912, 49913, 49915, 49916, + 49920, 49928, 49929, 49932, 49933, 49939, 49940, 49941, 49944, 49948, + 49956, 49957, 49960, 49961, 49989, 50024, 50025, 50028, 50032, 50034, + 50040, 50041, 50044, 50045, 50052, 50056, 50060, 50112, 50136, 50137, + 50140, 50143, 50144, 50146, 50152, 50153, 50157, 50164, 50165, 50168, + 50184, 50192, 50212, 50220, 50224, 54328, 54329, 54330, 54331, 54332, + 54333, 54334, 54335, 54337, 54338, 54339, 54341, 54342, 54343, 54344, + 54345, 54346, 54347, 54348, 54349, 54350, 54351, 54352, 54353, 54354, + 54355, 65535, 65535, 65535, 65535, 65535, 65535, 54356, 54357, 54358, + 54359, 54360, 54361, 54362, 54363, 54365, 54366, 54367, 54369, 54370, + 54371, 54373, 54374, 54375, 54376, 54377, 54378, 54379, 54380, 54382, + 54384, 54385, 54386, 65535, 65535, 65535, 65535, 65535, 65535, 54387, + 54388, 54389, 54390, 54391, 54394, 54395, 54397, 54398, 54401, 54403, + 54404, 54405, 54406, 54407, 54410, 54412, 54414, 54415, 54416, 54417, + 54418, 54419, 54421, 54422, 54423, 54424, 54425, 54426, 54427, 54428, + 54429, 50228, 50236, 50237, 50248, 50276, 50277, 50280, 50284, 50292, + 50293, 50297, 50304, 50324, 50332, 50360, 50364, 50409, 50416, 50417, + 50420, 50424, 50426, 50431, 50432, 50433, 50444, 50448, 50452, 50460, + 50472, 50473, 50476, 50480, 50488, 50489, 50491, 50493, 50500, 50501, + 50504, 50505, 50506, 50508, 50509, 50510, 50515, 50516, 50517, 50519, + 50520, 50521, 50525, 50526, 50528, 50529, 50532, 50536, 50544, 50545, + 50547, 50548, 50549, 50556, 50557, 50560, 50564, 50567, 50572, 50573, + 50575, 50577, 50581, 50583, 50584, 50588, 50592, 50601, 50612, 50613, + 50616, 50617, 50619, 50620, 50621, 50622, 50628, 50629, 50630, 50631, + 50632, 50633, 50634, 50636, 50638, 54430, 54431, 54432, 54433, 54434, + 54435, 54436, 54437, 54438, 54439, 54440, 54442, 54443, 54444, 54445, + 54446, 54447, 54448, 54449, 54450, 54451, 54452, 54453, 54454, 54455, + 54456, 65535, 65535, 65535, 65535, 65535, 65535, 54457, 54458, 54459, + 54460, 54461, 54462, 54463, 54464, 54465, 54466, 54467, 54468, 54469, + 54470, 54471, 54472, 54473, 54474, 54475, 54477, 54478, 54479, 54481, + 54482, 54483, 54485, 65535, 65535, 65535, 65535, 65535, 65535, 54486, + 54487, 54488, 54489, 54490, 54491, 54493, 54494, 54496, 54497, 54498, + 54499, 54500, 54501, 54502, 54503, 54505, 54506, 54507, 54509, 54510, + 54511, 54513, 54514, 54515, 54516, 54517, 54518, 54519, 54521, 54522, + 54524, 50640, 50641, 50644, 50648, 50656, 50657, 50659, 50661, 50668, + 50669, 50670, 50672, 50676, 50678, 50679, 50684, 50685, 50686, 50687, + 50688, 50689, 50693, 50694, 50695, 50696, 50700, 50704, 50712, 50713, + 50715, 50716, 50724, 50725, 50728, 50732, 50733, 50734, 50736, 50739, + 50740, 50741, 50743, 50745, 50747, 50752, 50753, 50756, 50760, 50768, + 50769, 50771, 50772, 50773, 50780, 50781, 50784, 50796, 50799, 50801, + 50808, 50809, 50812, 50816, 50824, 50825, 50827, 50829, 50836, 50837, + 50840, 50844, 50852, 50853, 50855, 50857, 50864, 50865, 50868, 50872, + 50873, 50874, 50880, 50881, 50883, 50885, 50892, 50893, 50896, 50900, + 50908, 50909, 50912, 50913, 50920, 54526, 54527, 54528, 54529, 54530, + 54531, 54533, 54534, 54535, 54537, 54538, 54539, 54541, 54542, 54543, + 54544, 54545, 54546, 54547, 54550, 54552, 54553, 54554, 54555, 54556, + 54557, 65535, 65535, 65535, 65535, 65535, 65535, 54558, 54559, 54560, + 54561, 54562, 54563, 54564, 54565, 54566, 54567, 54568, 54569, 54570, + 54571, 54572, 54573, 54574, 54575, 54576, 54577, 54578, 54579, 54580, + 54581, 54582, 54583, 65535, 65535, 65535, 65535, 65535, 65535, 54584, + 54585, 54586, 54587, 54590, 54591, 54593, 54594, 54595, 54597, 54598, + 54599, 54600, 54601, 54602, 54603, 54606, 54608, 54610, 54611, 54612, + 54613, 54614, 54615, 54618, 54619, 54621, 54622, 54623, 54625, 54626, + 54627, 50921, 50924, 50928, 50936, 50937, 50941, 50948, 50949, 50952, + 50956, 50964, 50965, 50967, 50969, 50976, 50977, 50980, 50984, 50992, + 50993, 50995, 50997, 50999, 51004, 51005, 51008, 51012, 51018, 51020, + 51021, 51023, 51025, 51026, 51027, 51028, 51029, 51030, 51031, 51032, + 51036, 51040, 51048, 51051, 51060, 51061, 51064, 51068, 51069, 51070, + 51075, 51076, 51077, 51079, 51080, 51081, 51082, 51086, 51088, 51089, + 51092, 51094, 51095, 51096, 51098, 51104, 51105, 51107, 51108, 51109, + 51110, 51116, 51117, 51120, 51124, 51132, 51133, 51135, 51136, 51137, + 51144, 51145, 51148, 51150, 51152, 51160, 51165, 51172, 51176, 51180, + 51200, 51201, 51204, 51208, 51210, 54628, 54630, 54631, 54634, 54636, + 54638, 54639, 54640, 54641, 54642, 54643, 54646, 54647, 54649, 54650, + 54651, 54653, 54654, 54655, 54656, 54657, 54658, 54659, 54662, 54666, + 54667, 65535, 65535, 65535, 65535, 65535, 65535, 54668, 54669, 54670, + 54671, 54673, 54674, 54675, 54676, 54677, 54678, 54679, 54680, 54681, + 54682, 54683, 54684, 54685, 54686, 54687, 54688, 54689, 54690, 54691, + 54692, 54694, 54695, 65535, 65535, 65535, 65535, 65535, 65535, 54696, + 54697, 54698, 54699, 54700, 54701, 54702, 54703, 54704, 54705, 54706, + 54707, 54708, 54709, 54710, 54711, 54712, 54713, 54714, 54715, 54716, + 54717, 54718, 54719, 54720, 54721, 54722, 54723, 54724, 54725, 54726, + 54727, 51216, 51217, 51219, 51221, 51222, 51228, 51229, 51232, 51236, + 51244, 51245, 51247, 51249, 51256, 51260, 51264, 51272, 51273, 51276, + 51277, 51284, 51312, 51313, 51316, 51320, 51322, 51328, 51329, 51331, + 51333, 51334, 51335, 51339, 51340, 51341, 51348, 51357, 51359, 51361, + 51368, 51388, 51389, 51396, 51400, 51404, 51412, 51413, 51415, 51417, + 51424, 51425, 51428, 51445, 51452, 51453, 51456, 51460, 51461, 51462, + 51468, 51469, 51471, 51473, 51480, 51500, 51508, 51536, 51537, 51540, + 51544, 51552, 51553, 51555, 51564, 51568, 51572, 51580, 51592, 51593, + 51596, 51600, 51608, 51609, 51611, 51613, 51648, 51649, 51652, 51655, + 51656, 51658, 51664, 51665, 51667, 54730, 54731, 54733, 54734, 54735, + 54737, 54739, 54740, 54741, 54742, 54743, 54746, 54748, 54750, 54751, + 54752, 54753, 54754, 54755, 54758, 54759, 54761, 54762, 54763, 54765, + 54766, 65535, 65535, 65535, 65535, 65535, 65535, 54767, 54768, 54769, + 54770, 54771, 54774, 54776, 54778, 54779, 54780, 54781, 54782, 54783, + 54786, 54787, 54789, 54790, 54791, 54793, 54794, 54795, 54796, 54797, + 54798, 54799, 54802, 65535, 65535, 65535, 65535, 65535, 65535, 54806, + 54807, 54808, 54809, 54810, 54811, 54813, 54814, 54815, 54817, 54818, + 54819, 54821, 54822, 54823, 54824, 54825, 54826, 54827, 54828, 54830, + 54831, 54832, 54833, 54834, 54835, 54836, 54837, 54838, 54839, 54842, + 54843, 51669, 51670, 51673, 51674, 51676, 51677, 51680, 51682, 51684, + 51687, 51692, 51693, 51695, 51696, 51697, 51704, 51705, 51708, 51712, + 51720, 51721, 51723, 51724, 51725, 51732, 51736, 51753, 51788, 51789, + 51792, 51796, 51804, 51805, 51807, 51808, 51809, 51816, 51837, 51844, + 51864, 51900, 51901, 51904, 51908, 51916, 51917, 51919, 51921, 51923, + 51928, 51929, 51936, 51948, 51956, 51976, 51984, 51988, 51992, 52000, + 52001, 52033, 52040, 52041, 52044, 52048, 52056, 52057, 52061, 52068, + 52088, 52089, 52124, 52152, 52180, 52196, 52199, 52201, 52236, 52237, + 52240, 52244, 52252, 52253, 52257, 52258, 52263, 52264, 52265, 52268, + 52270, 52272, 52280, 52281, 52283, 54845, 54846, 54847, 54849, 54850, + 54851, 54852, 54854, 54855, 54858, 54860, 54862, 54863, 54864, 54866, + 54867, 54870, 54871, 54873, 54874, 54875, 54877, 54878, 54879, 54880, + 54881, 65535, 65535, 65535, 65535, 65535, 65535, 54882, 54883, 54884, + 54885, 54886, 54888, 54890, 54891, 54892, 54893, 54894, 54895, 54898, + 54899, 54901, 54902, 54903, 54904, 54905, 54906, 54907, 54908, 54909, + 54910, 54911, 54912, 65535, 65535, 65535, 65535, 65535, 65535, 54913, + 54914, 54916, 54918, 54919, 54920, 54921, 54922, 54923, 54926, 54927, + 54929, 54930, 54931, 54933, 54934, 54935, 54936, 54937, 54938, 54939, + 54940, 54942, 54944, 54946, 54947, 54948, 54949, 54950, 54951, 54953, + 54954, 52284, 52285, 52286, 52292, 52293, 52296, 52300, 52308, 52309, + 52311, 52312, 52313, 52320, 52324, 52326, 52328, 52336, 52341, 52376, + 52377, 52380, 52384, 52392, 52393, 52395, 52396, 52397, 52404, 52405, + 52408, 52412, 52420, 52421, 52423, 52425, 52432, 52436, 52452, 52460, + 52464, 52481, 52488, 52489, 52492, 52496, 52504, 52505, 52507, 52509, + 52516, 52520, 52524, 52537, 52572, 52576, 52580, 52588, 52589, 52591, + 52593, 52600, 52616, 52628, 52629, 52632, 52636, 52644, 52645, 52647, + 52649, 52656, 52676, 52684, 52688, 52712, 52716, 52720, 52728, 52729, + 52731, 52733, 52740, 52744, 52748, 52756, 52761, 52768, 52769, 52772, + 52776, 52784, 52785, 52787, 52789, 54955, 54957, 54958, 54959, 54961, + 54962, 54963, 54964, 54965, 54966, 54967, 54968, 54970, 54972, 54973, + 54974, 54975, 54976, 54977, 54978, 54979, 54982, 54983, 54985, 54986, + 54987, 65535, 65535, 65535, 65535, 65535, 65535, 54989, 54990, 54991, + 54992, 54994, 54995, 54997, 54998, 55000, 55002, 55003, 55004, 55005, + 55006, 55007, 55009, 55010, 55011, 55013, 55014, 55015, 55017, 55018, + 55019, 55020, 55021, 65535, 65535, 65535, 65535, 65535, 65535, 55022, + 55023, 55025, 55026, 55027, 55028, 55030, 55031, 55032, 55033, 55034, + 55035, 55038, 55039, 55041, 55042, 55043, 55045, 55046, 55047, 55048, + 55049, 55050, 55051, 55052, 55053, 55054, 55055, 55056, 55058, 55059, + 55060, 52824, 52825, 52828, 52831, 52832, 52833, 52840, 52841, 52843, + 52845, 52852, 52853, 52856, 52860, 52868, 52869, 52871, 52873, 52880, + 52881, 52884, 52888, 52896, 52897, 52899, 52900, 52901, 52908, 52909, + 52929, 52964, 52965, 52968, 52971, 52972, 52980, 52981, 52983, 52984, + 52985, 52992, 52993, 52996, 53000, 53008, 53009, 53011, 53013, 53020, + 53024, 53028, 53036, 53037, 53039, 53040, 53041, 53048, 53076, 53077, + 53080, 53084, 53092, 53093, 53095, 53097, 53104, 53105, 53108, 53112, + 53120, 53125, 53132, 53153, 53160, 53168, 53188, 53216, 53217, 53220, + 53224, 53232, 53233, 53235, 53237, 53244, 53248, 53252, 53265, 53272, + 53293, 53300, 53301, 53304, 53308, 55061, 55062, 55063, 55066, 55067, + 55069, 55070, 55071, 55073, 55074, 55075, 55076, 55077, 55078, 55079, + 55082, 55084, 55086, 55087, 55088, 55089, 55090, 55091, 55094, 55095, + 55097, 65535, 65535, 65535, 65535, 65535, 65535, 55098, 55099, 55101, + 55102, 55103, 55104, 55105, 55106, 55107, 55109, 55110, 55112, 55114, + 55115, 55116, 55117, 55118, 55119, 55122, 55123, 55125, 55130, 55131, + 55132, 55133, 55134, 65535, 65535, 65535, 65535, 65535, 65535, 55135, + 55138, 55140, 55142, 55143, 55144, 55146, 55147, 55149, 55150, 55151, + 55153, 55154, 55155, 55157, 55158, 55159, 55160, 55161, 55162, 55163, + 55166, 55167, 55168, 55170, 55171, 55172, 55173, 55174, 55175, 55178, + 55179, 53316, 53317, 53319, 53321, 53328, 53332, 53336, 53344, 53356, + 53357, 53360, 53364, 53372, 53373, 53377, 53412, 53413, 53416, 53420, + 53428, 53429, 53431, 53433, 53440, 53441, 53444, 53448, 53449, 53456, + 53457, 53459, 53460, 53461, 53468, 53469, 53472, 53476, 53484, 53485, + 53487, 53488, 53489, 53496, 53517, 53552, 53553, 53556, 53560, 53562, + 53568, 53569, 53571, 53572, 53573, 53580, 53581, 53584, 53588, 53596, + 53597, 53599, 53601, 53608, 53612, 53628, 53636, 53640, 53664, 53665, + 53668, 53672, 53680, 53681, 53683, 53685, 53690, 53692, 53696, 53720, + 53748, 53752, 53767, 53769, 53776, 53804, 53805, 53808, 53812, 53820, + 53821, 53823, 53825, 53832, 53852, 55181, 55182, 55183, 55185, 55186, + 55187, 55188, 55189, 55190, 55191, 55194, 55196, 55198, 55199, 55200, + 55201, 55202, 55203, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 53860, 53888, 53889, 53892, 53896, 53904, 53905, 53909, 53916, + 53920, 53924, 53932, 53937, 53944, 53945, 53948, 53951, 53952, 53954, + 53960, 53961, 53963, 53972, 53976, 53980, 53988, 53989, 54000, 54001, + 54004, 54008, 54016, 54017, 54019, 54021, 54028, 54029, 54030, 54032, + 54036, 54038, 54044, 54045, 54047, 54048, 54049, 54053, 54056, 54057, + 54060, 54064, 54072, 54073, 54075, 54076, 54077, 54084, 54085, 54140, + 54141, 54144, 54148, 54156, 54157, 54159, 54160, 54161, 54168, 54169, + 54172, 54176, 54184, 54185, 54187, 54189, 54196, 54200, 54204, 54212, + 54213, 54216, 54217, 54224, 54232, 54241, 54243, 54252, 54253, 54256, + 54260, 54268, 54269, 54271, 54273, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 54280, 54301, 54336, 54340, 54364, 54368, 54372, 54381, 54383, + 54392, 54393, 54396, 54399, 54400, 54402, 54408, 54409, 54411, 54413, + 54420, 54441, 54476, 54480, 54484, 54492, 54495, 54504, 54508, 54512, + 54520, 54523, 54525, 54532, 54536, 54540, 54548, 54549, 54551, 54588, + 54589, 54592, 54596, 54604, 54605, 54607, 54609, 54616, 54617, 54620, + 54624, 54629, 54632, 54633, 54635, 54637, 54644, 54645, 54648, 54652, + 54660, 54661, 54663, 54664, 54665, 54672, 54693, 54728, 54729, 54732, + 54736, 54738, 54744, 54745, 54747, 54749, 54756, 54757, 54760, 54764, + 54772, 54773, 54775, 54777, 54784, 54785, 54788, 54792, 54800, 54801, + 54803, 54804, 54805, 54812, 54816, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 54820, 54829, 54840, 54841, 54844, 54848, 54853, 54856, 54857, + 54859, 54861, 54865, 54868, 54869, 54872, 54876, 54887, 54889, 54896, + 54897, 54900, 54915, 54917, 54924, 54925, 54928, 54932, 54941, 54943, + 54945, 54952, 54956, 54960, 54969, 54971, 54980, 54981, 54984, 54988, + 54993, 54996, 54999, 55001, 55008, 55012, 55016, 55024, 55029, 55036, + 55037, 55040, 55044, 55057, 55064, 55065, 55068, 55072, 55080, 55081, + 55083, 55085, 55092, 55093, 55096, 55100, 55108, 55111, 55113, 55120, + 55121, 55124, 55126, 55127, 55128, 55129, 55136, 55137, 55139, 55141, + 55145, 55148, 55152, 55156, 55164, 55165, 55169, 55176, 55177, 55180, + 55184, 55192, 55193, 55195, 55197, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20285, 20339, 20551, 20729, 21152, 21487, 21621, 21733, 22025, + 23233, 23478, 26247, 26550, 26551, 26607, 27468, 29634, 30146, 31292, + 33499, 33540, 34903, 34952, 35382, 36040, 36303, 36603, 36838, 39381, + 21051, 21364, 21508, 24682, 24932, 27580, 29647, 33050, 35258, 35282, + 38307, 20355, 21002, 22718, 22904, 23014, 24178, 24185, 25031, 25536, + 26438, 26604, 26751, 28567, 30286, 30475, 30965, 31240, 31487, 31777, + 32925, 33390, 33393, 35563, 38291, 20075, 21917, 26359, 28212, 30883, + 31469, 33883, 35088, 34638, 38824, 21208, 22350, 22570, 23884, 24863, + 25022, 25121, 25954, 26577, 27204, 28187, 29976, 30131, 30435, 30640, + 32058, 37039, 37969, 37970, 40853, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21283, 23724, 30002, 32987, 37440, 38296, 21083, 22536, 23004, + 23713, 23831, 24247, 24378, 24394, 24951, 27743, 30074, 30086, 31968, + 32115, 32177, 32652, 33108, 33313, 34193, 35137, 35611, 37628, 38477, + 40007, 20171, 20215, 20491, 20977, 22607, 24887, 24894, 24936, 25913, + 27114, 28433, 30117, 30342, 30422, 31623, 33445, 33995, 63744, 37799, + 38283, 21888, 23458, 22353, 63745, 31923, 32697, 37301, 20520, 21435, + 23621, 24040, 25298, 25454, 25818, 25831, 28192, 28844, 31067, 36317, + 36382, 63746, 36989, 37445, 37624, 20094, 20214, 20581, 24062, 24314, + 24838, 26967, 33137, 34388, 36423, 37749, 39467, 20062, 20625, 26480, + 26688, 20745, 21133, 21138, 27298, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 30652, 37392, 40660, 21163, 24623, 36850, 20552, 25001, 25581, + 25802, 26684, 27268, 28608, 33160, 35233, 38548, 22533, 29309, 29356, + 29956, 32121, 32365, 32937, 35211, 35700, 36963, 40273, 25225, 27770, + 28500, 32080, 32570, 35363, 20860, 24906, 31645, 35609, 37463, 37772, + 20140, 20435, 20510, 20670, 20742, 21185, 21197, 21375, 22384, 22659, + 24218, 24465, 24950, 25004, 25806, 25964, 26223, 26299, 26356, 26775, + 28039, 28805, 28913, 29855, 29861, 29898, 30169, 30828, 30956, 31455, + 31478, 32069, 32147, 32789, 32831, 33051, 33686, 35686, 36629, 36885, + 37857, 38915, 38968, 39514, 39912, 20418, 21843, 22586, 22865, 23395, + 23622, 24760, 25106, 26690, 26800, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 26856, 28330, 30028, 30328, 30926, 31293, 31995, 32363, 32380, + 35336, 35489, 35903, 38542, 40388, 21476, 21481, 21578, 21617, 22266, + 22993, 23396, 23611, 24235, 25335, 25911, 25925, 25970, 26272, 26543, + 27073, 27837, 30204, 30352, 30590, 31295, 32660, 32771, 32929, 33167, + 33510, 33533, 33776, 34241, 34865, 34996, 35493, 63747, 36764, 37678, + 38599, 39015, 39640, 40723, 21741, 26011, 26354, 26767, 31296, 35895, + 40288, 22256, 22372, 23825, 26118, 26801, 26829, 28414, 29736, 34974, + 39908, 27752, 63748, 39592, 20379, 20844, 20849, 21151, 23380, 24037, + 24656, 24685, 25329, 25511, 25915, 29657, 31354, 34467, 36002, 38799, + 20018, 23521, 25096, 26524, 29916, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 31185, 33747, 35463, 35506, 36328, 36942, 37707, 38982, 24275, + 27112, 34303, 37101, 63749, 20896, 23448, 23532, 24931, 26874, 27454, + 28748, 29743, 29912, 31649, 32592, 33733, 35264, 36011, 38364, 39208, + 21038, 24669, 25324, 36866, 20362, 20809, 21281, 22745, 24291, 26336, + 27960, 28826, 29378, 29654, 31568, 33009, 37979, 21350, 25499, 32619, + 20054, 20608, 22602, 22750, 24618, 24871, 25296, 27088, 39745, 23439, + 32024, 32945, 36703, 20132, 20689, 21676, 21932, 23308, 23968, 24039, + 25898, 25934, 26657, 27211, 29409, 30350, 30703, 32094, 32761, 33184, + 34126, 34527, 36611, 36686, 37066, 39171, 39509, 39851, 19992, 20037, + 20061, 20167, 20465, 20855, 21246, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21312, 21475, 21477, 21646, 22036, 22389, 22434, 23495, 23943, + 24272, 25084, 25304, 25937, 26552, 26601, 27083, 27472, 27590, 27628, + 27714, 28317, 28792, 29399, 29590, 29699, 30655, 30697, 31350, 32127, + 32777, 33276, 33285, 33290, 33503, 34914, 35635, 36092, 36544, 36881, + 37041, 37476, 37558, 39378, 39493, 40169, 40407, 40860, 22283, 23616, + 33738, 38816, 38827, 40628, 21531, 31384, 32676, 35033, 36557, 37089, + 22528, 23624, 25496, 31391, 23470, 24339, 31353, 31406, 33422, 36524, + 20518, 21048, 21240, 21367, 22280, 25331, 25458, 27402, 28099, 30519, + 21413, 29527, 34152, 36470, 38357, 26426, 27331, 28528, 35437, 36556, + 39243, 63750, 26231, 27512, 36020, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 39740, 63751, 21483, 22317, 22862, 25542, 27131, 29674, 30789, + 31418, 31429, 31998, 33909, 35215, 36211, 36917, 38312, 21243, 22343, + 30023, 31584, 33740, 37406, 63752, 27224, 20811, 21067, 21127, 25119, + 26840, 26997, 38553, 20677, 21156, 21220, 25027, 26020, 26681, 27135, + 29822, 31563, 33465, 33771, 35250, 35641, 36817, 39241, 63753, 20170, + 22935, 25810, 26129, 27278, 29748, 31105, 31165, 33449, 34942, 34943, + 35167, 63754, 37670, 20235, 21450, 24613, 25201, 27762, 32026, 32102, + 20120, 20834, 30684, 32943, 20225, 20238, 20854, 20864, 21980, 22120, + 22331, 22522, 22524, 22804, 22855, 22931, 23492, 23696, 23822, 24049, + 24190, 24524, 25216, 26071, 26083, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 26398, 26399, 26462, 26827, 26820, 27231, 27450, 27683, 27773, + 27778, 28103, 29592, 29734, 29738, 29826, 29859, 30072, 30079, 30849, + 30959, 31041, 31047, 31048, 31098, 31637, 32000, 32186, 32648, 32774, + 32813, 32908, 35352, 35663, 35912, 36215, 37665, 37668, 39138, 39249, + 39438, 39439, 39525, 40594, 32202, 20342, 21513, 25326, 26708, 37329, + 21931, 20794, 63755, 63756, 23068, 25062, 63757, 25295, 25343, 63758, + 63759, 63760, 63761, 63762, 63763, 37027, 63764, 63765, 63766, 63767, + 63768, 35582, 63769, 63770, 63771, 63772, 26262, 63773, 29014, 63774, + 63775, 38627, 63776, 25423, 25466, 21335, 63777, 26511, 26976, 28275, + 63778, 30007, 63779, 63780, 63781, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 32013, 63782, 63783, 34930, 22218, 23064, 63784, 63785, 63786, + 63787, 63788, 20035, 63789, 20839, 22856, 26608, 32784, 63790, 22899, + 24180, 25754, 31178, 24565, 24684, 25288, 25467, 23527, 23511, 21162, + 63791, 22900, 24361, 24594, 63792, 63793, 63794, 29785, 63795, 63796, + 63797, 63798, 63799, 63800, 39377, 63801, 63802, 63803, 63804, 63805, + 63806, 63807, 63808, 63809, 63810, 63811, 28611, 63812, 63813, 33215, + 36786, 24817, 63814, 63815, 33126, 63816, 63817, 23615, 63818, 63819, + 63820, 63821, 63822, 63823, 63824, 63825, 23273, 35365, 26491, 32016, + 63826, 63827, 63828, 63829, 63830, 63831, 33021, 63832, 63833, 23612, + 27877, 21311, 28346, 22810, 33590, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20025, 20150, 20294, 21934, 22296, 22727, 24406, 26039, 26086, + 27264, 27573, 28237, 30701, 31471, 31774, 32222, 34507, 34962, 37170, + 37723, 25787, 28606, 29562, 30136, 36948, 21846, 22349, 25018, 25812, + 26311, 28129, 28251, 28525, 28601, 30192, 32835, 33213, 34113, 35203, + 35527, 35674, 37663, 27795, 30035, 31572, 36367, 36957, 21776, 22530, + 22616, 24162, 25095, 25758, 26848, 30070, 31958, 34739, 40680, 20195, + 22408, 22382, 22823, 23565, 23729, 24118, 24453, 25140, 25825, 29619, + 33274, 34955, 36024, 38538, 40667, 23429, 24503, 24755, 20498, 20992, + 21040, 22294, 22581, 22615, 23566, 23648, 23798, 23947, 24230, 24466, + 24764, 25361, 25481, 25623, 26691, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 26873, 27330, 28120, 28193, 28372, 28644, 29182, 30428, 30585, + 31153, 31291, 33796, 35241, 36077, 36339, 36424, 36867, 36884, 36947, + 37117, 37709, 38518, 38876, 27602, 28678, 29272, 29346, 29544, 30563, + 31167, 31716, 32411, 35712, 22697, 24775, 25958, 26109, 26302, 27788, + 28958, 29129, 35930, 38931, 20077, 31361, 20189, 20908, 20941, 21205, + 21516, 24999, 26481, 26704, 26847, 27934, 28540, 30140, 30643, 31461, + 33012, 33891, 37509, 20828, 26007, 26460, 26515, 30168, 31431, 33651, + 63834, 35910, 36887, 38957, 23663, 33216, 33434, 36929, 36975, 37389, + 24471, 23965, 27225, 29128, 30331, 31561, 34276, 35588, 37159, 39472, + 21895, 25078, 63835, 30313, 32645, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 34367, 34746, 35064, 37007, 63836, 27931, 28889, 29662, 32097, + 33853, 63837, 37226, 39409, 63838, 20098, 21365, 27396, 27410, 28734, + 29211, 34349, 40478, 21068, 36771, 23888, 25829, 25900, 27414, 28651, + 31811, 32412, 34253, 35172, 35261, 25289, 33240, 34847, 24266, 26391, + 28010, 29436, 29701, 29807, 34690, 37086, 20358, 23821, 24480, 33802, + 20919, 25504, 30053, 20142, 20486, 20841, 20937, 26753, 27153, 31918, + 31921, 31975, 33391, 35538, 36635, 37327, 20406, 20791, 21237, 21570, + 24300, 24942, 25150, 26053, 27354, 28670, 31018, 34268, 34851, 38317, + 39522, 39530, 40599, 40654, 21147, 26310, 27511, 28701, 31019, 36706, + 38722, 24976, 25088, 25891, 28451, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 29001, 29833, 32244, 32879, 34030, 36646, 36899, 37706, 20925, + 21015, 21155, 27916, 28872, 35010, 24265, 25986, 27566, 28610, 31806, + 29557, 20196, 20278, 22265, 63839, 23738, 23994, 24604, 29618, 31533, + 32666, 32718, 32838, 36894, 37428, 38646, 38728, 38936, 40801, 20363, + 28583, 31150, 37300, 38583, 21214, 63840, 25736, 25796, 27347, 28510, + 28696, 29200, 30439, 32769, 34310, 34396, 36335, 36613, 38706, 39791, + 40442, 40565, 30860, 31103, 32160, 33737, 37636, 40575, 40595, 35542, + 22751, 24324, 26407, 28711, 29903, 31840, 32894, 20769, 28712, 29282, + 30922, 36034, 36058, 36084, 38647, 20102, 20698, 23534, 24278, 26009, + 29134, 30274, 30637, 32842, 34044, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 36988, 39719, 40845, 22744, 23105, 23650, 27155, 28122, 28431, + 30267, 32047, 32311, 34078, 35128, 37860, 38475, 21129, 26066, 26611, + 27060, 27969, 28316, 28687, 29705, 29792, 30041, 30244, 30827, 35628, + 39006, 20845, 25134, 38520, 20374, 20523, 23833, 28138, 32184, 36650, + 24459, 24900, 26647, 63841, 38534, 21202, 32907, 20956, 20940, 26974, + 31260, 32190, 33777, 38517, 20442, 21033, 21400, 21519, 21774, 23653, + 24743, 26446, 26792, 28012, 29313, 29432, 29702, 29827, 63842, 30178, + 31852, 32633, 32696, 33673, 35023, 35041, 37324, 37328, 38626, 39881, + 21533, 28542, 29136, 29848, 34298, 36522, 38563, 40023, 40607, 26519, + 28107, 29747, 33256, 38678, 30764, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 31435, 31520, 31890, 25705, 29802, 30194, 30908, 30952, 39340, + 39764, 40635, 23518, 24149, 28448, 33180, 33707, 37000, 19975, 21325, + 23081, 24018, 24398, 24930, 25405, 26217, 26364, 28415, 28459, 28771, + 30622, 33836, 34067, 34875, 36627, 39237, 39995, 21788, 25273, 26411, + 27819, 33545, 35178, 38778, 20129, 22916, 24536, 24537, 26395, 32178, + 32596, 33426, 33579, 33725, 36638, 37017, 22475, 22969, 23186, 23504, + 26151, 26522, 26757, 27599, 29028, 32629, 36023, 36067, 36993, 39749, + 33032, 35978, 38476, 39488, 40613, 23391, 27667, 29467, 30450, 30431, + 33804, 20906, 35219, 20813, 20885, 21193, 26825, 27796, 30468, 30496, + 32191, 32236, 38754, 40629, 28357, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 34065, 20901, 21517, 21629, 26126, 26269, 26919, 28319, 30399, + 30609, 33559, 33986, 34719, 37225, 37528, 40180, 34946, 20398, 20882, + 21215, 22982, 24125, 24917, 25720, 25721, 26286, 26576, 27169, 27597, + 27611, 29279, 29281, 29761, 30520, 30683, 32791, 33468, 33541, 35584, + 35624, 35980, 26408, 27792, 29287, 30446, 30566, 31302, 40361, 27519, + 27794, 22818, 26406, 33945, 21359, 22675, 22937, 24287, 25551, 26164, + 26483, 28218, 29483, 31447, 33495, 37672, 21209, 24043, 25006, 25035, + 25098, 25287, 25771, 26080, 26969, 27494, 27595, 28961, 29687, 30045, + 32326, 33310, 33538, 34154, 35491, 36031, 38695, 40289, 22696, 40664, + 20497, 21006, 21563, 21839, 25991, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 27766, 32010, 32011, 32862, 34442, 38272, 38639, 21247, 27797, + 29289, 21619, 23194, 23614, 23883, 24396, 24494, 26410, 26806, 26979, + 28220, 28228, 30473, 31859, 32654, 34183, 35598, 36855, 38753, 40692, + 23735, 24758, 24845, 25003, 25935, 26107, 26108, 27665, 27887, 29599, + 29641, 32225, 38292, 23494, 34588, 35600, 21085, 21338, 25293, 25615, + 25778, 26420, 27192, 27850, 29632, 29854, 31636, 31893, 32283, 33162, + 33334, 34180, 36843, 38649, 39361, 20276, 21322, 21453, 21467, 25292, + 25644, 25856, 26001, 27075, 27886, 28504, 29677, 30036, 30242, 30436, + 30460, 30928, 30971, 31020, 32070, 33324, 34784, 36820, 38930, 39151, + 21187, 25300, 25765, 28196, 28497, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 30332, 36299, 37297, 37474, 39662, 39747, 20515, 20621, 22346, + 22952, 23592, 24135, 24439, 25151, 25918, 26041, 26049, 26121, 26507, + 27036, 28354, 30917, 32033, 32938, 33152, 33323, 33459, 33953, 34444, + 35370, 35607, 37030, 38450, 40848, 20493, 20467, 63843, 22521, 24472, + 25308, 25490, 26479, 28227, 28953, 30403, 32972, 32986, 35060, 35061, + 35097, 36064, 36649, 37197, 38506, 20271, 20336, 24091, 26575, 26658, + 30333, 30334, 39748, 24161, 27146, 29033, 29140, 30058, 63844, 32321, + 34115, 34281, 39132, 20240, 31567, 32624, 38309, 20961, 24070, 26805, + 27710, 27726, 27867, 29359, 31684, 33539, 27861, 29754, 20731, 21128, + 22721, 25816, 27287, 29863, 30294, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 30887, 34327, 38370, 38713, 63845, 21342, 24321, 35722, 36776, + 36783, 37002, 21029, 30629, 40009, 40712, 19993, 20482, 20853, 23643, + 24183, 26142, 26170, 26564, 26821, 28851, 29953, 30149, 31177, 31453, + 36647, 39200, 39432, 20445, 22561, 22577, 23542, 26222, 27493, 27921, + 28282, 28541, 29668, 29995, 33769, 35036, 35091, 35676, 36628, 20239, + 20693, 21264, 21340, 23443, 24489, 26381, 31119, 33145, 33583, 34068, + 35079, 35206, 36665, 36667, 39333, 39954, 26412, 20086, 20472, 22857, + 23553, 23791, 23792, 25447, 26834, 28925, 29090, 29739, 32299, 34028, + 34562, 36898, 37586, 40179, 19981, 20184, 20463, 20613, 21078, 21103, + 21542, 21648, 22496, 22827, 23142, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23386, 23413, 23500, 24220, 63846, 25206, 25975, 26023, 28014, + 28325, 29238, 31526, 31807, 32566, 33104, 33105, 33178, 33344, 33433, + 33705, 35331, 36000, 36070, 36091, 36212, 36282, 37096, 37340, 38428, + 38468, 39385, 40167, 21271, 20998, 21545, 22132, 22707, 22868, 22894, + 24575, 24996, 25198, 26128, 27774, 28954, 30406, 31881, 31966, 32027, + 33452, 36033, 38640, 63847, 20315, 24343, 24447, 25282, 23849, 26379, + 26842, 30844, 32323, 40300, 19989, 20633, 21269, 21290, 21329, 22915, + 23138, 24199, 24754, 24970, 25161, 25209, 26000, 26503, 27047, 27604, + 27606, 27607, 27608, 27832, 63848, 29749, 30202, 30738, 30865, 31189, + 31192, 31875, 32203, 32737, 32933, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 33086, 33218, 33778, 34586, 35048, 35513, 35692, 36027, 37145, + 38750, 39131, 40763, 22188, 23338, 24428, 25996, 27315, 27567, 27996, + 28657, 28693, 29277, 29613, 36007, 36051, 38971, 24977, 27703, 32856, + 39425, 20045, 20107, 20123, 20181, 20282, 20284, 20351, 20447, 20735, + 21490, 21496, 21766, 21987, 22235, 22763, 22882, 23057, 23531, 23546, + 23556, 24051, 24107, 24473, 24605, 25448, 26012, 26031, 26614, 26619, + 26797, 27515, 27801, 27863, 28195, 28681, 29509, 30722, 31038, 31040, + 31072, 31169, 31721, 32023, 32114, 32902, 33293, 33678, 34001, 34503, + 35039, 35408, 35422, 35613, 36060, 36198, 36781, 37034, 39164, 39391, + 40605, 21066, 63849, 26388, 63850, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20632, 21034, 23665, 25955, 27733, 29642, 29987, 30109, 31639, + 33948, 37240, 38704, 20087, 25746, 27578, 29022, 34217, 19977, 63851, + 26441, 26862, 28183, 33439, 34072, 34923, 25591, 28545, 37394, 39087, + 19978, 20663, 20687, 20767, 21830, 21930, 22039, 23360, 23577, 23776, + 24120, 24202, 24224, 24258, 24819, 26705, 27233, 28248, 29245, 29248, + 29376, 30456, 31077, 31665, 32724, 35059, 35316, 35443, 35937, 36062, + 38684, 22622, 29885, 36093, 21959, 63852, 31329, 32034, 33394, 29298, + 29983, 29989, 63853, 31513, 22661, 22779, 23996, 24207, 24246, 24464, + 24661, 25234, 25471, 25933, 26257, 26329, 26360, 26646, 26866, 29312, + 29790, 31598, 32110, 32214, 32626, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 32997, 33298, 34223, 35199, 35475, 36893, 37604, 40653, 40736, + 22805, 22893, 24109, 24796, 26132, 26227, 26512, 27728, 28101, 28511, + 30707, 30889, 33990, 37323, 37675, 20185, 20682, 20808, 21892, 23307, + 23459, 25159, 25982, 26059, 28210, 29053, 29697, 29764, 29831, 29887, + 30316, 31146, 32218, 32341, 32680, 33146, 33203, 33337, 34330, 34796, + 35445, 36323, 36984, 37521, 37925, 39245, 39854, 21352, 23633, 26964, + 27844, 27945, 28203, 33292, 34203, 35131, 35373, 35498, 38634, 40807, + 21089, 26297, 27570, 32406, 34814, 36109, 38275, 38493, 25885, 28041, + 29166, 63854, 22478, 22995, 23468, 24615, 24826, 25104, 26143, 26207, + 29481, 29689, 30427, 30465, 31596, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 32854, 32882, 33125, 35488, 37266, 19990, 21218, 27506, 27927, + 31237, 31545, 32048, 63855, 36016, 21484, 22063, 22609, 23477, 23567, + 23569, 24034, 25152, 25475, 25620, 26157, 26803, 27836, 28040, 28335, + 28703, 28836, 29138, 29990, 30095, 30094, 30233, 31505, 31712, 31787, + 32032, 32057, 34092, 34157, 34311, 35380, 36877, 36961, 37045, 37559, + 38902, 39479, 20439, 23660, 26463, 28049, 31903, 32396, 35606, 36118, + 36895, 23403, 24061, 25613, 33984, 36956, 39137, 29575, 23435, 24730, + 26494, 28126, 35359, 35494, 36865, 38924, 21047, 63856, 28753, 30862, + 37782, 34928, 37335, 20462, 21463, 22013, 22234, 22402, 22781, 23234, + 23432, 23723, 23744, 24101, 24833, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 25101, 25163, 25480, 25628, 25910, 25976, 27193, 27530, 27700, + 27929, 28465, 29159, 29417, 29560, 29703, 29874, 30246, 30561, 31168, + 31319, 31466, 31929, 32143, 32172, 32353, 32670, 33065, 33585, 33936, + 34010, 34282, 34966, 35504, 35728, 36664, 36930, 36995, 37228, 37526, + 37561, 38539, 38567, 38568, 38614, 38656, 38920, 39318, 39635, 39706, + 21460, 22654, 22809, 23408, 23487, 28113, 28506, 29087, 29729, 29881, + 32901, 33789, 24033, 24455, 24490, 24642, 26092, 26642, 26991, 27219, + 27529, 27957, 28147, 29667, 30462, 30636, 31565, 32020, 33059, 33308, + 33600, 34036, 34147, 35426, 35524, 37255, 37662, 38918, 39348, 25100, + 34899, 36848, 37477, 23815, 23847, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23913, 29791, 33181, 34664, 28629, 25342, 32722, 35126, 35186, + 19998, 20056, 20711, 21213, 21319, 25215, 26119, 32361, 34821, 38494, + 20365, 21273, 22070, 22987, 23204, 23608, 23630, 23629, 24066, 24337, + 24643, 26045, 26159, 26178, 26558, 26612, 29468, 30690, 31034, 32709, + 33940, 33997, 35222, 35430, 35433, 35553, 35925, 35962, 22516, 23508, + 24335, 24687, 25325, 26893, 27542, 28252, 29060, 31698, 34645, 35672, + 36606, 39135, 39166, 20280, 20353, 20449, 21627, 23072, 23480, 24892, + 26032, 26216, 29180, 30003, 31070, 32051, 33102, 33251, 33688, 34218, + 34254, 34563, 35338, 36523, 36763, 63857, 36805, 22833, 23460, 23526, + 24713, 23529, 23563, 24515, 27777, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 63858, 28145, 28683, 29978, 33455, 35574, 20160, 21313, 63859, + 38617, 27663, 20126, 20420, 20818, 21854, 23077, 23784, 25105, 29273, + 33469, 33706, 34558, 34905, 35357, 38463, 38597, 39187, 40201, 40285, + 22538, 23731, 23997, 24132, 24801, 24853, 25569, 27138, 28197, 37122, + 37716, 38990, 39952, 40823, 23433, 23736, 25353, 26191, 26696, 30524, + 38593, 38797, 38996, 39839, 26017, 35585, 36555, 38332, 21813, 23721, + 24022, 24245, 26263, 30284, 33780, 38343, 22739, 25276, 29390, 40232, + 20208, 22830, 24591, 26171, 27523, 31207, 40230, 21395, 21696, 22467, + 23830, 24859, 26326, 28079, 30861, 33406, 38552, 38724, 21380, 25212, + 25494, 28082, 32266, 33099, 38989, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 27387, 32588, 40367, 40474, 20063, 20539, 20918, 22812, 24825, + 25590, 26928, 29242, 32822, 63860, 37326, 24369, 63861, 63862, 32004, + 33509, 33903, 33979, 34277, 36493, 63863, 20335, 63864, 63865, 22756, + 23363, 24665, 25562, 25880, 25965, 26264, 63866, 26954, 27171, 27915, + 28673, 29036, 30162, 30221, 31155, 31344, 63867, 32650, 63868, 35140, + 63869, 35731, 37312, 38525, 63870, 39178, 22276, 24481, 26044, 28417, + 30208, 31142, 35486, 39341, 39770, 40812, 20740, 25014, 25233, 27277, + 33222, 20547, 22576, 24422, 28937, 35328, 35578, 23420, 34326, 20474, + 20796, 22196, 22852, 25513, 28153, 23978, 26989, 20870, 20104, 20313, + 63871, 63872, 63873, 22914, 63874, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 63875, 27487, 27741, 63876, 29877, 30998, 63877, 33287, 33349, + 33593, 36671, 36701, 63878, 39192, 63879, 63880, 63881, 20134, 63882, + 22495, 24441, 26131, 63883, 63884, 30123, 32377, 35695, 63885, 36870, + 39515, 22181, 22567, 23032, 23071, 23476, 63886, 24310, 63887, 63888, + 25424, 25403, 63889, 26941, 27783, 27839, 28046, 28051, 28149, 28436, + 63890, 28895, 28982, 29017, 63891, 29123, 29141, 63892, 30799, 30831, + 63893, 31605, 32227, 63894, 32303, 63895, 34893, 36575, 63896, 63897, + 63898, 37467, 63899, 40182, 63900, 63901, 63902, 24709, 28037, 63903, + 29105, 63904, 63905, 38321, 21421, 63906, 63907, 63908, 26579, 63909, + 28814, 28976, 29744, 33398, 33490, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 63910, 38331, 39653, 40573, 26308, 63911, 29121, 33865, 63912, + 63913, 22603, 63914, 63915, 23992, 24433, 63916, 26144, 26254, 27001, + 27054, 27704, 27891, 28214, 28481, 28634, 28699, 28719, 29008, 29151, + 29552, 63917, 29787, 63918, 29908, 30408, 31310, 32403, 63919, 63920, + 33521, 35424, 36814, 63921, 37704, 63922, 38681, 63923, 63924, 20034, + 20522, 63925, 21000, 21473, 26355, 27757, 28618, 29450, 30591, 31330, + 33454, 34269, 34306, 63926, 35028, 35427, 35709, 35947, 63927, 37555, + 63928, 38675, 38928, 20116, 20237, 20425, 20658, 21320, 21566, 21555, + 21978, 22626, 22714, 22887, 23067, 23524, 24735, 63929, 25034, 25942, + 26111, 26212, 26791, 27738, 28595, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 28879, 29100, 29522, 31613, 34568, 35492, 39986, 40711, 23627, + 27779, 29508, 29577, 37434, 28331, 29797, 30239, 31337, 32277, 34314, + 20800, 22725, 25793, 29934, 29973, 30320, 32705, 37013, 38605, 39252, + 28198, 29926, 31401, 31402, 33253, 34521, 34680, 35355, 23113, 23436, + 23451, 26785, 26880, 28003, 29609, 29715, 29740, 30871, 32233, 32747, + 33048, 33109, 33694, 35916, 38446, 38929, 26352, 24448, 26106, 26505, + 27754, 29579, 20525, 23043, 27498, 30702, 22806, 23916, 24013, 29477, + 30031, 63930, 63931, 20709, 20985, 22575, 22829, 22934, 23002, 23525, + 63932, 63933, 23970, 25303, 25622, 25747, 25854, 63934, 26332, 63935, + 27208, 63936, 29183, 29796, 63937, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 31368, 31407, 32327, 32350, 32768, 33136, 63938, 34799, 35201, + 35616, 36953, 63939, 36992, 39250, 24958, 27442, 28020, 32287, 35109, + 36785, 20433, 20653, 20887, 21191, 22471, 22665, 23481, 24248, 24898, + 27029, 28044, 28263, 28342, 29076, 29794, 29992, 29996, 32883, 33592, + 33993, 36362, 37780, 37854, 63940, 20110, 20305, 20598, 20778, 21448, + 21451, 21491, 23431, 23507, 23588, 24858, 24962, 26100, 29275, 29591, + 29760, 30402, 31056, 31121, 31161, 32006, 32701, 33419, 34261, 34398, + 36802, 36935, 37109, 37354, 38533, 38632, 38633, 21206, 24423, 26093, + 26161, 26671, 29020, 31286, 37057, 38922, 20113, 63941, 27218, 27550, + 28560, 29065, 32792, 33464, 34131, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 36939, 38549, 38642, 38907, 34074, 39729, 20112, 29066, 38596, + 20803, 21407, 21729, 22291, 22290, 22435, 23195, 23236, 23491, 24616, + 24895, 25588, 27781, 27961, 28274, 28304, 29232, 29503, 29783, 33489, + 34945, 36677, 36960, 63942, 38498, 39000, 40219, 26376, 36234, 37470, + 20301, 20553, 20702, 21361, 22285, 22996, 23041, 23561, 24944, 26256, + 28205, 29234, 29771, 32239, 32963, 33806, 33894, 34111, 34655, 34907, + 35096, 35586, 36949, 38859, 39759, 20083, 20369, 20754, 20842, 63943, + 21807, 21929, 23418, 23461, 24188, 24189, 24254, 24736, 24799, 24840, + 24841, 25540, 25912, 26377, 63944, 26580, 26586, 63945, 26977, 26978, + 27833, 27943, 63946, 28216, 63947, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 28641, 29494, 29495, 63948, 29788, 30001, 63949, 30290, 63950, + 63951, 32173, 33278, 33848, 35029, 35480, 35547, 35565, 36400, 36418, + 36938, 36926, 36986, 37193, 37321, 37742, 63952, 63953, 22537, 63954, + 27603, 32905, 32946, 63955, 63956, 20801, 22891, 23609, 63957, 63958, + 28516, 29607, 32996, 36103, 63959, 37399, 38287, 63960, 63961, 63962, + 63963, 32895, 25102, 28700, 32104, 34701, 63964, 22432, 24681, 24903, + 27575, 35518, 37504, 38577, 20057, 21535, 28139, 34093, 38512, 38899, + 39150, 25558, 27875, 37009, 20957, 25033, 33210, 40441, 20381, 20506, + 20736, 23452, 24847, 25087, 25836, 26885, 27589, 30097, 30691, 32681, + 33380, 34191, 34811, 34915, 35516, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 35696, 37291, 20108, 20197, 20234, 63965, 63966, 22839, 23016, + 63967, 24050, 24347, 24411, 24609, 63968, 63969, 63970, 63971, 29246, + 29669, 63972, 30064, 30157, 63973, 31227, 63974, 32780, 32819, 32900, + 33505, 33617, 63975, 63976, 36029, 36019, 36999, 63977, 63978, 39156, + 39180, 63979, 63980, 28727, 30410, 32714, 32716, 32764, 35610, 20154, + 20161, 20995, 21360, 63981, 21693, 22240, 23035, 23493, 24341, 24525, + 28270, 63982, 63983, 32106, 33589, 63984, 34451, 35469, 63985, 38765, + 38775, 63986, 63987, 19968, 20314, 20350, 22777, 26085, 28322, 36920, + 37808, 39353, 20219, 22764, 22922, 23001, 24641, 63988, 63989, 31252, + 63990, 33615, 36035, 20837, 21316, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 63991, 63992, 63993, 20173, 21097, 23381, 33471, 20180, 21050, + 21672, 22985, 23039, 23376, 23383, 23388, 24675, 24904, 28363, 28825, + 29038, 29574, 29943, 30133, 30913, 32043, 32773, 33258, 33576, 34071, + 34249, 35566, 36039, 38604, 20316, 21242, 22204, 26027, 26152, 28796, + 28856, 29237, 32189, 33421, 37196, 38592, 40306, 23409, 26855, 27544, + 28538, 30430, 23697, 26283, 28507, 31668, 31786, 34870, 38620, 19976, + 20183, 21280, 22580, 22715, 22767, 22892, 23559, 24115, 24196, 24373, + 25484, 26290, 26454, 27167, 27299, 27404, 28479, 29254, 63994, 29520, + 29835, 31456, 31911, 33144, 33247, 33255, 33674, 33900, 34083, 34196, + 34255, 35037, 36115, 37292, 38263, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 38556, 20877, 21705, 22312, 23472, 25165, 26448, 26685, 26771, + 28221, 28371, 28797, 32289, 35009, 36001, 36617, 40779, 40782, 29229, + 31631, 35533, 37658, 20295, 20302, 20786, 21632, 22992, 24213, 25269, + 26485, 26990, 27159, 27822, 28186, 29401, 29482, 30141, 31672, 32053, + 33511, 33785, 33879, 34295, 35419, 36015, 36487, 36889, 37048, 38606, + 40799, 21219, 21514, 23265, 23490, 25688, 25973, 28404, 29380, 63995, + 30340, 31309, 31515, 31821, 32318, 32735, 33659, 35627, 36042, 36196, + 36321, 36447, 36842, 36857, 36969, 37841, 20291, 20346, 20659, 20840, + 20856, 21069, 21098, 22625, 22652, 22880, 23560, 23637, 24283, 24731, + 25136, 26643, 27583, 27656, 28593, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 29006, 29728, 30000, 30008, 30033, 30322, 31564, 31627, 31661, + 31686, 32399, 35438, 36670, 36681, 37439, 37523, 37666, 37931, 38651, + 39002, 39019, 39198, 20999, 25130, 25240, 27993, 30308, 31434, 31680, + 32118, 21344, 23742, 24215, 28472, 28857, 31896, 38673, 39822, 40670, + 25509, 25722, 34678, 19969, 20117, 20141, 20572, 20597, 21576, 22979, + 23450, 24128, 24237, 24311, 24449, 24773, 25402, 25919, 25972, 26060, + 26230, 26232, 26622, 26984, 27273, 27491, 27712, 28096, 28136, 28191, + 28254, 28702, 28833, 29582, 29693, 30010, 30555, 30855, 31118, 31243, + 31357, 31934, 32142, 33351, 35330, 35562, 35998, 37165, 37194, 37336, + 37478, 37580, 37664, 38662, 38742, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 38748, 38914, 40718, 21046, 21137, 21884, 22564, 24093, 24351, + 24716, 25552, 26799, 28639, 31085, 31532, 33229, 34234, 35069, 35576, + 36420, 37261, 38500, 38555, 38717, 38988, 40778, 20430, 20806, 20939, + 21161, 22066, 24340, 24427, 25514, 25805, 26089, 26177, 26362, 26361, + 26397, 26781, 26839, 27133, 28437, 28526, 29031, 29157, 29226, 29866, + 30522, 31062, 31066, 31199, 31264, 31381, 31895, 31967, 32068, 32368, + 32903, 34299, 34468, 35412, 35519, 36249, 36481, 36896, 36973, 37347, + 38459, 38613, 40165, 26063, 31751, 36275, 37827, 23384, 23562, 21330, + 25305, 29469, 20519, 23447, 24478, 24752, 24939, 26837, 28121, 29742, + 31278, 32066, 32156, 32305, 33131, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 36394, 36405, 37758, 37912, 20304, 22352, 24038, 24231, 25387, + 32618, 20027, 20303, 20367, 20570, 23005, 32964, 21610, 21608, 22014, + 22863, 23449, 24030, 24282, 26205, 26417, 26609, 26666, 27880, 27954, + 28234, 28557, 28855, 29664, 30087, 31820, 32002, 32044, 32162, 33311, + 34523, 35387, 35461, 36208, 36490, 36659, 36913, 37198, 37202, 37956, + 39376, 31481, 31909, 20426, 20737, 20934, 22472, 23535, 23803, 26201, + 27197, 27994, 28310, 28652, 28940, 30063, 31459, 34850, 36897, 36981, + 38603, 39423, 33537, 20013, 20210, 34886, 37325, 21373, 27355, 26987, + 27713, 33914, 22686, 24974, 26366, 25327, 28893, 29969, 30151, 32338, + 33976, 35657, 36104, 20043, 21482, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21675, 22320, 22336, 24535, 25345, 25351, 25711, 25903, 26088, + 26234, 26525, 26547, 27490, 27744, 27802, 28460, 30693, 30757, 31049, + 31063, 32025, 32930, 33026, 33267, 33437, 33463, 34584, 35468, 63996, + 36100, 36286, 36978, 30452, 31257, 31287, 32340, 32887, 21767, 21972, + 22645, 25391, 25634, 26185, 26187, 26733, 27035, 27524, 27941, 28337, + 29645, 29800, 29857, 30043, 30137, 30433, 30494, 30603, 31206, 32265, + 32285, 33275, 34095, 34967, 35386, 36049, 36587, 36784, 36914, 37805, + 38499, 38515, 38663, 20356, 21489, 23018, 23241, 24089, 26702, 29894, + 30142, 31209, 31378, 33187, 34541, 36074, 36300, 36845, 26015, 26389, + 63997, 22519, 28503, 32221, 36655, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 37878, 38598, 24501, 25074, 28548, 19988, 20376, 20511, 21449, + 21983, 23919, 24046, 27425, 27492, 30923, 31642, 63998, 36425, 36554, + 36974, 25417, 25662, 30528, 31364, 37679, 38015, 40810, 25776, 28591, + 29158, 29864, 29914, 31428, 31762, 32386, 31922, 32408, 35738, 36106, + 38013, 39184, 39244, 21049, 23519, 25830, 26413, 32046, 20717, 21443, + 22649, 24920, 24921, 25082, 26028, 31449, 35730, 35734, 20489, 20513, + 21109, 21809, 23100, 24288, 24432, 24884, 25950, 26124, 26166, 26274, + 27085, 28356, 28466, 29462, 30241, 31379, 33081, 33369, 33750, 33980, + 20661, 22512, 23488, 23528, 24425, 25505, 30758, 32181, 33756, 34081, + 37319, 37365, 20874, 26613, 31574, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 36012, 20932, 22971, 24765, 34389, 20508, 63999, 21076, 23610, + 24957, 25114, 25299, 25842, 26021, 28364, 30240, 33034, 36448, 38495, + 38587, 20191, 21315, 21912, 22825, 24029, 25797, 27849, 28154, 29588, + 31359, 33307, 34214, 36068, 36368, 36983, 37351, 38369, 38433, 38854, + 20984, 21746, 21894, 24505, 25764, 28552, 32180, 36639, 36685, 37941, + 20681, 23574, 27838, 28155, 29979, 30651, 31805, 31844, 35449, 35522, + 22558, 22974, 24086, 25463, 29266, 30090, 30571, 35548, 36028, 36626, + 24307, 26228, 28152, 32893, 33729, 35531, 38737, 39894, 64000, 21059, + 26367, 28053, 28399, 32224, 35558, 36910, 36958, 39636, 21021, 21119, + 21736, 24980, 25220, 25307, 26786, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 26898, 26970, 27189, 28818, 28966, 30813, 30977, 30990, 31186, + 31245, 32918, 33400, 33493, 33609, 34121, 35970, 36229, 37218, 37259, + 37294, 20419, 22225, 29165, 30679, 34560, 35320, 23544, 24534, 26449, + 37032, 21474, 22618, 23541, 24740, 24961, 25696, 32317, 32880, 34085, + 37507, 25774, 20652, 23828, 26368, 22684, 25277, 25512, 26894, 27000, + 27166, 28267, 30394, 31179, 33467, 33833, 35535, 36264, 36861, 37138, + 37195, 37276, 37648, 37656, 37786, 38619, 39478, 39949, 19985, 30044, + 31069, 31482, 31569, 31689, 32302, 33988, 36441, 36468, 36600, 36880, + 26149, 26943, 29763, 20986, 26414, 40668, 20805, 24544, 27798, 34802, + 34909, 34935, 24756, 33205, 33795, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 36101, 21462, 21561, 22068, 23094, 23601, 28810, 32736, 32858, + 33030, 33261, 36259, 37257, 39519, 40434, 20596, 20164, 21408, 24827, + 28204, 23652, 20360, 20516, 21988, 23769, 24159, 24677, 26772, 27835, + 28100, 29118, 30164, 30196, 30305, 31258, 31305, 32199, 32251, 32622, + 33268, 34473, 36636, 38601, 39347, 40786, 21063, 21189, 39149, 35242, + 19971, 26578, 28422, 20405, 23522, 26517, 27784, 28024, 29723, 30759, + 37341, 37756, 34756, 31204, 31281, 24555, 20182, 21668, 21822, 22702, + 22949, 24816, 25171, 25302, 26422, 26965, 33333, 38464, 39345, 39389, + 20524, 21331, 21828, 22396, 64001, 25176, 64002, 25826, 26219, 26589, + 28609, 28655, 29730, 29752, 35351, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 37944, 21585, 22022, 22374, 24392, 24986, 27470, 28760, 28845, + 32187, 35477, 22890, 33067, 25506, 30472, 32829, 36010, 22612, 25645, + 27067, 23445, 24081, 28271, 64003, 34153, 20812, 21488, 22826, 24608, + 24907, 27526, 27760, 27888, 31518, 32974, 33492, 36294, 37040, 39089, + 64004, 25799, 28580, 25745, 25860, 20814, 21520, 22303, 35342, 24927, + 26742, 64005, 30171, 31570, 32113, 36890, 22534, 27084, 33151, 35114, + 36864, 38969, 20600, 22871, 22956, 25237, 36879, 39722, 24925, 29305, + 38358, 22369, 23110, 24052, 25226, 25773, 25850, 26487, 27874, 27966, + 29228, 29750, 30772, 32631, 33453, 36315, 38935, 21028, 22338, 26495, + 29256, 29923, 36009, 36774, 37393, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 38442, 20843, 21485, 25420, 20329, 21764, 24726, 25943, 27803, + 28031, 29260, 29437, 31255, 35207, 35997, 24429, 28558, 28921, 33192, + 24846, 20415, 20559, 25153, 29255, 31687, 32232, 32745, 36941, 38829, + 39449, 36022, 22378, 24179, 26544, 33805, 35413, 21536, 23318, 24163, + 24290, 24330, 25987, 32954, 34109, 38281, 38491, 20296, 21253, 21261, + 21263, 21638, 21754, 22275, 24067, 24598, 25243, 25265, 25429, 64006, + 27873, 28006, 30129, 30770, 32990, 33071, 33502, 33889, 33970, 34957, + 35090, 36875, 37610, 39165, 39825, 24133, 26292, 26333, 28689, 29190, + 64007, 20469, 21117, 24426, 24915, 26451, 27161, 28418, 29922, 31080, + 34920, 35961, 39111, 39108, 39491, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21697, 31263, 26963, 35575, 35914, 39080, 39342, 24444, 25259, + 30130, 30382, 34987, 36991, 38466, 21305, 24380, 24517, 27852, 29644, + 30050, 30091, 31558, 33534, 39325, 20047, 36924, 19979, 20309, 21414, + 22799, 24264, 26160, 27827, 29781, 33655, 34662, 36032, 36944, 38686, + 39957, 22737, 23416, 34384, 35604, 40372, 23506, 24680, 24717, 26097, + 27735, 28450, 28579, 28698, 32597, 32752, 38289, 38290, 38480, 38867, + 21106, 36676, 20989, 21547, 21688, 21859, 21898, 27323, 28085, 32216, + 33382, 37532, 38519, 40569, 21512, 21704, 30418, 34532, 38308, 38356, + 38492, 20130, 20233, 23022, 23270, 24055, 24658, 25239, 26477, 26689, + 27782, 28207, 32568, 32923, 33322, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 64008, 64009, 38917, 20133, 20565, 21683, 22419, 22874, 23401, + 23475, 25032, 26999, 28023, 28707, 34809, 35299, 35442, 35559, 36994, + 39405, 39608, 21182, 26680, 20502, 24184, 26447, 33607, 34892, 20139, + 21521, 22190, 29670, 37141, 38911, 39177, 39255, 39321, 22099, 22687, + 34395, 35377, 25010, 27382, 29563, 36562, 27463, 38570, 39511, 22869, + 29184, 36203, 38761, 20436, 23796, 24358, 25080, 26203, 27883, 28843, + 29572, 29625, 29694, 30505, 30541, 32067, 32098, 32291, 33335, 34898, + 64010, 36066, 37449, 39023, 23377, 31348, 34880, 38913, 23244, 20448, + 21332, 22846, 23805, 25406, 28025, 29433, 33029, 33031, 33698, 37583, + 38960, 20136, 20804, 21009, 22411, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 24418, 27842, 28366, 28677, 28752, 28847, 29074, 29673, 29801, + 33610, 34722, 34913, 36872, 37026, 37795, 39336, 20846, 24407, 24800, + 24935, 26291, 34137, 36426, 37295, 38795, 20046, 20114, 21628, 22741, + 22778, 22909, 23733, 24359, 25142, 25160, 26122, 26215, 27627, 28009, + 28111, 28246, 28408, 28564, 28640, 28649, 28765, 29392, 29733, 29786, + 29920, 30355, 31068, 31946, 32286, 32993, 33446, 33899, 33983, 34382, + 34399, 34676, 35703, 35946, 37804, 38912, 39013, 24785, 25110, 37239, + 23130, 26127, 28151, 28222, 29759, 39746, 24573, 24794, 31503, 21700, + 24344, 27742, 27859, 27946, 28888, 32005, 34425, 35340, 40251, 21270, + 21644, 23301, 27194, 28779, 30069, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 31117, 31166, 33457, 33775, 35441, 35649, 36008, 38772, 64011, + 25844, 25899, 30906, 30907, 31339, 20024, 21914, 22864, 23462, 24187, + 24739, 25563, 27489, 26213, 26707, 28185, 29029, 29872, 32008, 36996, + 39529, 39973, 27963, 28369, 29502, 35905, 38346, 20976, 24140, 24488, + 24653, 24822, 24880, 24908, 26179, 26180, 27045, 27841, 28255, 28361, + 28514, 29004, 29852, 30343, 31681, 31783, 33618, 34647, 36945, 38541, + 40643, 21295, 22238, 24315, 24458, 24674, 24724, 25079, 26214, 26371, + 27292, 28142, 28590, 28784, 29546, 32362, 33214, 33588, 34516, 35496, + 36036, 21123, 29554, 23446, 27243, 37892, 21742, 22150, 23389, 25928, + 25989, 26313, 26783, 28045, 28102, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 29243, 32948, 37237, 39501, 20399, 20505, 21402, 21518, 21564, + 21897, 21957, 24127, 24460, 26429, 29030, 29661, 36869, 21211, 21235, + 22628, 22734, 28932, 29071, 29179, 34224, 35347, 26248, 34216, 21927, + 26244, 29002, 33841, 21321, 21913, 27585, 24409, 24509, 25582, 26249, + 28999, 35569, 36637, 40638, 20241, 25658, 28875, 30054, 34407, 24676, + 35662, 40440, 20807, 20982, 21256, 27958, 33016, 40657, 26133, 27427, + 28824, 30165, 21507, 23673, 32007, 35350, 27424, 27453, 27462, 21560, + 24688, 27965, 32725, 33288, 20694, 20958, 21916, 22123, 22221, 23020, + 23305, 24076, 24985, 24984, 25137, 26206, 26342, 29081, 29113, 29114, + 29351, 31143, 31232, 32690, 35440, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u16) -> u32 { + let code = code as usize; + if code < 23750 { + FORWARD_TABLE[code] as u32 + } else { + 0xffff + } +} + +static BACKWARD_TABLE_LOWER: &'static [u16] = &[ + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6379, 65535, 65535, 6385, 65535, 65535, 6230, 6182, + 65535, 7508, 65535, 65535, 6184, 6436, 65535, 6213, 6205, 7782, 7783, 6370, + 65535, 6415, 6179, 6377, 7781, 7517, 65535, 7594, 7591, 7595, 6380, 65535, + 65535, 65535, 65535, 65535, 65535, 7506, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7507, 65535, 65535, 65535, 65535, 65535, 65535, + 6206, 7515, 65535, 65535, 65535, 65535, 65535, 7518, 7707, 65535, 65535, + 65535, 65535, 65535, 65535, 7696, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7698, 65535, 65535, 65535, 65535, 65535, 65535, 6207, + 7705, 65535, 65535, 65535, 65535, 65535, 7708, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7697, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7509, 7699, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7700, 7511, 7701, 65535, 65535, 65535, 65535, + 7702, 65535, 65535, 65535, 65535, 65535, 65535, 7513, 7703, 7514, 7704, + 65535, 65535, 65535, 65535, 65535, 65535, 7711, 7520, 7710, 65535, 65535, + 65535, 65535, 65535, 65535, 7516, 7706, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7519, 7709, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6372, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6381, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6373, 6376, 6375, 6378, 65535, 6374, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6968, 6969, 6970, 6971, 6972, 6973, 6974, 6975, + 6976, 6977, 6978, 6979, 6980, 6981, 6982, 6983, 6984, 65535, 6985, 6986, + 6987, 6988, 6989, 6990, 6991, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007, 7008, 7009, 7010, + 7011, 7012, 7013, 7014, 7015, 7016, 65535, 7017, 7018, 7019, 7020, 7021, + 7022, 7023, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 8272, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8266, 8267, 8268, + 8269, 8270, 8271, 8273, 8274, 8275, 8276, 8277, 8278, 8279, 8280, 8281, + 8282, 8283, 8284, 8285, 8286, 8287, 8288, 8289, 8290, 8291, 8292, 8293, + 8294, 8295, 8296, 8297, 8298, 8314, 8315, 8316, 8317, 8318, 8319, 8321, + 8322, 8323, 8324, 8325, 8326, 8327, 8328, 8329, 8330, 8331, 8332, 8333, + 8334, 8335, 8336, 8337, 8338, 8339, 8340, 8341, 8342, 8343, 8344, 8345, + 8346, 65535, 8320, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6185, 65535, 65535, 6189, + 6190, 65535, 65535, 6191, 6192, 65535, 65535, 6416, 6417, 65535, 65535, + 65535, 6180, 6181, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6387, 65535, 6214, 6215, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6231, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7784, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7785, 65535, 7786, 7787, 7788, 7789, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6435, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6216, 65535, 65535, 65535, 65535, 65535, 6386, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7319, 65535, 65535, 6429, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6434, 6431, + 65535, 65535, 65535, 7372, 65535, 65535, 65535, 65535, 6217, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7592, 7593, 65535, 65535, + 65535, 65535, 65535, 65535, 7596, 7597, 7598, 7599, 65535, 6951, 6952, + 6953, 6954, 6955, 6956, 6957, 6958, 6959, 6960, 65535, 65535, 65535, 65535, + 65535, 65535, 6936, 6937, 6938, 6939, 6940, 6941, 6942, 6943, 6944, 6945, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6246, 6247, 6245, 6248, 6249, 6418, 6421, 6419, 6422, 6420, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6366, 65535, 6367, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6368, 65535, 6226, 6369, + 65535, 65535, 65535, 6227, 6259, 65535, 65535, 6260, 65535, 65535, 65535, + 6384, 65535, 6383, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6253, 65535, 65535, 6255, 6211, 65535, 6223, 65535, 65535, 65535, 65535, + 6186, 65535, 6267, 6268, 6266, 6265, 6257, 6258, 65535, 6382, 65535, 65535, + 65535, 65535, 65535, 6212, 6256, 65535, 65535, 65535, 65535, 65535, 65535, + 6188, 6254, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6229, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6208, 6228, 65535, 65535, 6209, 6210, 65535, + 65535, 65535, 65535, 6251, 6252, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6263, 6264, 65535, 65535, 6261, + 6262, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6398, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6224, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6225, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7576, 7577, 7578, 7579, 7580, 7581, + 7582, 7583, 7584, 7585, 7586, 7587, 7588, 7589, 7590, 65535, 65535, 65535, + 65535, 65535, 7766, 7767, 7768, 7769, 7770, 7771, 7772, 7773, 7774, 7775, + 7776, 7777, 7778, 7779, 7780, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7740, 7741, + 7742, 7743, 7744, 7745, 7746, 7747, 7748, 7749, 7750, 7751, 7752, 7753, + 7754, 7755, 7756, 7757, 7758, 7759, 7760, 7761, 7762, 7763, 7764, 7765, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7550, 7551, 7552, 7553, 7554, + 7555, 7556, 7557, 7558, 7559, 7560, 7561, 7562, 7563, 7564, 7565, 7566, + 7567, 7568, 7569, 7570, 7571, 7572, 7573, 7574, 7575, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7126, 7137, + 7127, 7138, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7128, + 7165, 7164, 7139, 7129, 7159, 7158, 7140, 7131, 7163, 7162, 7142, 7130, + 7161, 7160, 7141, 7132, 7153, 7166, 7167, 7148, 7168, 7169, 7143, 7134, + 7155, 7170, 7171, 7150, 7172, 7173, 7145, 7133, 7174, 7175, 7149, 7154, + 7176, 7177, 7144, 7135, 7178, 7179, 7151, 7156, 7180, 7181, 7146, 7136, + 7182, 7183, 7152, 7184, 7185, 7157, 7186, 7187, 7188, 7189, 7190, 7191, + 7192, 7193, 7147, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6403, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6240, 6239, 65535, 6400, 6404, 6405, 6408, 6407, 6406, + 6409, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6242, 6241, + 65535, 65535, 6391, 6390, 65535, 65535, 65535, 65535, 6244, 6243, 65535, + 65535, 6389, 6388, 65535, 65535, 65535, 65535, 6238, 6237, 6399, 65535, + 65535, 6234, 65535, 65535, 6236, 6235, 6401, 6402, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6233, 6232, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6412, 6411, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6413, 65535, 6414, 65535, + 6222, 65535, 6221, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6393, 6394, 65535, 6397, 6392, 6395, 65535, 6396, 6410, 6424, 6425, + 65535, 6426, 6423, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6176, + 6177, 6178, 6183, 65535, 65535, 65535, 65535, 6195, 6196, 6197, 6198, 6199, + 6200, 6201, 6202, 6203, 6204, 65535, 6250, 6193, 6194, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7886, 7887, 7888, + 7889, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7897, 7898, 7899, 7900, + 7901, 7902, 7903, 7904, 7905, 7906, 7907, 7908, 7909, 7910, 7911, 7912, + 7913, 7914, 7915, 7916, 7917, 7918, 7919, 7920, 7921, 7922, 7923, 7924, + 7925, 7926, 7927, 7928, 7929, 7930, 7931, 7932, 7933, 7934, 7935, 7936, + 7937, 7938, 7939, 7940, 7941, 7942, 7943, 7944, 7945, 7946, 7947, 7948, + 7949, 7950, 7951, 7952, 7953, 7954, 7955, 7956, 7957, 7958, 7959, 7960, + 7961, 7962, 7963, 7964, 7965, 7966, 7967, 7968, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8076, 8077, + 8078, 8079, 8080, 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, + 8090, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8098, 8099, 8100, 8101, + 8102, 8103, 8104, 8105, 8106, 8107, 8108, 8109, 8110, 8111, 8112, 8113, + 8114, 8115, 8116, 8117, 8118, 8119, 8120, 8121, 8122, 8123, 8124, 8125, + 8126, 8127, 8128, 8129, 8130, 8131, 8132, 8133, 8134, 8135, 8136, 8137, + 8138, 8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, + 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 8158, 8159, 8160, 8161, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6746, 6747, 6748, 6749, 6750, + 6751, 6752, 6753, 6754, 6755, 6756, 6757, 6758, 6759, 6760, 6761, 6762, + 6763, 6764, 6765, 6766, 6767, 6768, 6769, 6770, 6771, 6772, 6773, 6774, + 6775, 6776, 6777, 6778, 6779, 6780, 6781, 6782, 6783, 6784, 6785, 6786, + 6787, 6788, 6789, 6790, 6791, 6792, 6793, 6794, 6795, 6796, 6797, 6798, + 6799, 6800, 6801, 6802, 6803, 6804, 6805, 6806, 6807, 6808, 6809, 6810, + 6811, 6812, 6813, 6814, 6815, 6816, 6817, 6818, 6819, 6820, 6821, 6822, + 6823, 6824, 6825, 6826, 6827, 6828, 6829, 6830, 6831, 6832, 6833, 6834, + 6835, 6836, 6837, 6838, 6839, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7712, 7713, 7714, 7715, 7716, 7717, 7718, 7719, 7720, 7721, 7722, + 7723, 7724, 7725, 7726, 7727, 7728, 7729, 7730, 7731, 7732, 7733, 7734, + 7735, 7736, 7737, 7738, 7739, 6428, 65535, 65535, 65535, 7522, 7523, 7524, + 7525, 7526, 7527, 7528, 7529, 7530, 7531, 7532, 7533, 7534, 7535, 7536, + 7537, 7538, 7539, 7540, 7541, 7542, 7543, 7544, 7545, 7546, 7547, 7548, + 7549, 65535, 65535, 65535, 6427, 7356, 7357, 7358, 7359, 7360, 65535, + 65535, 65535, 7341, 7342, 7375, 7376, 7377, 7337, 7338, 7339, 7367, 7368, + 7369, 7370, 7371, 7316, 7317, 7318, 7320, 7326, 7327, 7328, 7329, 7330, + 7331, 7332, 7333, 7334, 7335, 7322, 7323, 7324, 7325, 7344, 7345, 7384, + 7385, 7386, 7387, 7380, 7381, 7382, 7346, 7347, 7348, 7349, 7350, 7351, + 7352, 7353, 7354, 7355, 7361, 7362, 7363, 7364, 7365, 7366, 7373, 7374, + 6432, 7391, 7321, 7379, 7394, 6430, 7343, 7392, 7336, 65535, 65535, 65535, + 65535, 7340, 7389, 65535, 65535, 7390, 65535, 65535, 7378, 65535, 6433, + 65535, 65535, 7383, 7393, 7388, 65535, 65535, 20498, 21038, 65535, 22375, + 65535, 65535, 65535, 16643, 20674, 17973, 17985, 22922, 65535, 17469, + 65535, 65535, 65535, 22203, 65535, 65535, 21761, 17639, 18341, 65535, + 14813, 17401, 65535, 65535, 65535, 65535, 18725, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21448, 65535, 65535, 65535, 65535, 14625, 65535, 65535, 65535, + 65535, 65535, 23480, 15676, 65535, 21386, 65535, 65535, 65535, 65535, + 65535, 65535, 19524, 15497, 65535, 14814, 65535, 65535, 65535, 65535, + 65535, 21468, 65535, 17796, 23301, 22920, 65535, 65535, 65535, 65535, + 65535, 65535, 14775, 65535, 18726, 20299, 65535, 65535, 65535, 14815, + 14242, 19100, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14030, 65535, 15909, 65535, 65535, 65535, 65535, + 65535, 20110, 65535, 65535, 17452, 17968, 65535, 65535, 65535, 65535, + 65535, 65535, 14230, 65535, 65535, 65535, 16070, 65535, 65535, 65535, + 16330, 65535, 19183, 65535, 65535, 17797, 20428, 65535, 19900, 65535, + 20052, 19941, 23302, 65535, 19548, 21039, 65535, 65535, 15175, 65535, + 65535, 17798, 65535, 65535, 18917, 65535, 65535, 16669, 22976, 65535, + 14788, 23089, 19303, 65535, 23176, 65535, 65535, 23114, 14385, 21040, + 16108, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15677, 65535, + 65535, 65535, 20474, 65535, 65535, 65535, 65535, 65535, 18912, 20475, + 65535, 65535, 22342, 65535, 65535, 14816, 65535, 65535, 15154, 14186, + 65535, 20619, 65535, 65535, 65535, 65535, 65535, 65535, 20623, 17799, + 22391, 20675, 17470, 18170, 65535, 65535, 65535, 15911, 65535, 21966, + 65535, 65535, 65535, 15734, 16266, 20429, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 18975, 65535, 21449, 65535, + 65535, 65535, 14231, 14187, 65535, 65535, 65535, 20507, 65535, 65535, + 65535, 65535, 65535, 15179, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22977, 20430, 15168, 65535, 19549, 15180, 17434, 17268, 23699, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17250, + 65535, 65535, 65535, 65535, 17070, 65535, 16267, 65535, 18778, 65535, + 17800, 65535, 17801, 13966, 65535, 65535, 65535, 65535, 65535, 20881, + 65535, 65535, 15678, 20828, 22752, 65535, 65535, 65535, 65535, 20085, + 20829, 21387, 21380, 19901, 65535, 65535, 65535, 22923, 65535, 65535, + 65535, 19184, 20499, 17629, 20649, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22710, 65535, 65535, + 65535, 65535, 65535, 19121, 17251, 65535, 65535, 13967, 65535, 65535, + 15340, 65535, 65535, 65535, 20882, 65535, 65535, 65535, 20500, 17802, + 65535, 18779, 65535, 14006, 21638, 65535, 16101, 65535, 22347, 65535, + 14759, 16284, 65535, 18735, 65535, 21388, 65535, 20111, 65535, 65535, + 65535, 65535, 16469, 65535, 21762, 65535, 65535, 14609, 65535, 20313, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 16833, 23660, 65535, 65535, + 65535, 65535, 65535, 22378, 16121, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22726, 65535, 65535, 14430, 22156, 18918, 65535, + 65535, 65535, 65535, 19550, 21428, 65535, 65535, 65535, 21212, 65535, + 65535, 19876, 65535, 14386, 23138, 65535, 65535, 18387, 65535, 65535, + 16489, 65535, 65535, 17418, 65535, 17803, 23164, 18780, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18418, 17471, 65535, 14817, 65535, 17231, 65535, 22786, 65535, 65535, + 17453, 65535, 19174, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17402, 65535, 65535, 65535, 16109, 65535, 65535, 21813, 65535, 14188, + 65535, 17230, 65535, 65535, 65535, 16905, 15753, 65535, 65535, 65535, + 23109, 65535, 65535, 23661, 20314, 65535, 21951, 65535, 14387, 21763, + 65535, 21814, 65535, 17202, 22348, 65535, 14985, 21267, 14213, 65535, + 19525, 16470, 22405, 19727, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19101, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19166, 65535, 65535, 65535, 13968, + 14352, 20086, 65535, 65535, 65535, 65535, 65535, 22727, 65535, 65535, + 65535, 65535, 65535, 23090, 65535, 65535, 65535, 65535, 21389, 65535, + 21041, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14232, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22341, 21042, 19902, 65535, 22577, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14776, 65535, 65535, 65535, + 65535, 17472, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17203, + 65535, 65535, 65535, 14243, 65535, 65535, 65535, 65535, 65535, 65535, + 17956, 17640, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22177, 19877, 65535, 65535, 65535, 65535, 19551, 20883, 65535, 21835, + 65535, 17986, 65535, 65535, 65535, 65535, 65535, 65535, 14388, 65535, + 65535, 65535, 65535, 65535, 65535, 15138, 65535, 65535, 65535, 21995, + 18171, 65535, 65535, 65535, 65535, 17987, 65535, 14789, 65535, 65535, + 65535, 17435, 23729, 65535, 65535, 65535, 16331, 65535, 65535, 65535, + 20087, 65535, 65535, 65535, 65535, 65535, 65535, 19738, 65535, 18727, + 65535, 65535, 65535, 65535, 65535, 21803, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 13969, 65535, 17283, + 65535, 65535, 65535, 17804, 20315, 21429, 65535, 65535, 19161, 65535, + 14389, 65535, 65535, 14246, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 20112, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17988, 65535, 16322, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19903, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 20830, 65535, 65535, 65535, 65535, 16122, + 65535, 65535, 15346, 65535, 19175, 65535, 65535, 65535, 19685, 20270, + 65535, 20055, 23177, 22221, 21213, 23707, 18172, 14760, 65535, 15131, + 22541, 16708, 22560, 65535, 65535, 65535, 18919, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15928, 65535, 65535, 65535, + 65535, 65535, 15176, 65535, 65535, 20518, 65535, 15499, 20884, 16110, + 20113, 22707, 14610, 16466, 23292, 65535, 65535, 14611, 65535, 65535, + 65535, 17403, 15181, 14818, 20885, 65535, 65535, 65535, 14379, 65535, + 65535, 65535, 15182, 65535, 65535, 65535, 65535, 65535, 19182, 65535, + 65535, 65535, 21847, 65535, 65535, 20807, 65535, 65535, 65535, 65535, + 16834, 65535, 65535, 16709, 65535, 19878, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14739, 65535, 65535, 65535, 65535, 16817, + 65535, 65535, 65535, 65535, 16706, 65535, 15912, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19102, 16105, 65535, 65535, + 65535, 65535, 65535, 16254, 65535, 65535, 65535, 65535, 65535, 65535, + 21947, 65535, 21430, 65535, 65535, 16111, 65535, 21214, 16483, 15913, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16482, 20309, 23730, 65535, 65535, 17272, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23502, 14189, 65535, 65535, 65535, 65535, + 23708, 65535, 21985, 19739, 22218, 65535, 65535, 22957, 65535, 65535, + 15754, 65535, 65535, 20476, 65535, 65535, 17609, 21018, 19527, 65535, + 14007, 65535, 65535, 65535, 16906, 65535, 65535, 23178, 65535, 65535, + 65535, 65535, 65535, 16255, 65535, 65535, 65535, 65535, 65535, 22033, + 65535, 65535, 65535, 65535, 65535, 65535, 22602, 17397, 65535, 65535, + 65535, 16490, 17957, 65535, 65535, 65535, 14755, 65535, 15755, 65535, + 65535, 65535, 65535, 65535, 21189, 18411, 14986, 21798, 20624, 13995, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22024, 65535, 65535, + 65535, 22371, 65535, 65535, 17856, 15132, 16078, 20886, 65535, 65535, + 65535, 65535, 65535, 65535, 21953, 65535, 17473, 65535, 65535, 65535, + 65535, 14162, 65535, 17051, 65535, 65535, 65535, 18215, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20620, 20887, 65535, 65535, 65535, + 65535, 17474, 65535, 65535, 22955, 65535, 65535, 21815, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22787, 65535, 22034, 65535, 65535, + 65535, 23546, 65535, 65535, 65535, 15133, 17284, 16452, 65535, 65535, + 65535, 14247, 65535, 65535, 65535, 21190, 14248, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16139, 65535, 65535, 65535, 14612, + 13970, 65535, 65535, 16256, 15139, 65535, 65535, 65535, 65535, 21215, + 15514, 14349, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23107, 65535, 65535, 14390, 65535, 17095, 65535, 22372, 65535, 19879, + 65535, 16710, 65535, 65535, 65535, 14391, 65535, 65535, 65535, 65535, + 16480, 65535, 65535, 15914, 19932, 65535, 14040, 16881, 65535, 23673, + 65535, 18728, 16289, 16835, 65535, 65535, 18342, 20856, 15140, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23674, 65535, 16123, 65535, 65535, 14987, 65535, + 20650, 15123, 65535, 65535, 14819, 17013, 65535, 65535, 65535, 65535, + 65535, 22753, 65535, 65535, 23709, 65535, 65535, 65535, 65535, 22754, + 65535, 22755, 17436, 65535, 65535, 65535, 65535, 17641, 23364, 17608, + 65535, 18736, 65535, 65535, 65535, 65535, 65535, 65535, 20676, 14761, + 65535, 14156, 65535, 65535, 65535, 65535, 65535, 65535, 17642, 65535, + 65535, 65535, 65535, 23526, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22910, 65535, 65535, 65535, 65535, 65535, 15576, + 14916, 18913, 65535, 21967, 20519, 65535, 65535, 18729, 19552, 23688, + 17071, 65535, 65535, 16644, 65535, 65535, 65535, 17643, 21264, 22406, + 23165, 65535, 65535, 15380, 65535, 65535, 17052, 65535, 17437, 65535, + 17391, 65535, 21026, 65535, 65535, 65535, 65535, 65535, 14772, 65535, + 18202, 65535, 65535, 65535, 65535, 65535, 65535, 16869, 20477, 20088, + 65535, 65535, 13996, 16071, 65535, 14988, 65535, 65535, 65535, 65535, + 65535, 21452, 65535, 14392, 65535, 65535, 65535, 65535, 18993, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18982, 65535, 65535, 65535, 65535, 16491, 65535, + 23662, 65535, 65535, 65535, 65535, 20056, 22343, 65535, 65535, 65535, + 65535, 14995, 22924, 65535, 65535, 65535, 65535, 65535, 65535, 19369, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14214, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21804, 65535, 65535, 65535, 65535, 19904, 21764, 15169, 19905, + 65535, 17072, 65535, 65535, 65535, 65535, 65535, 65535, 18575, 65535, + 22327, 18419, 65535, 65535, 65535, 17073, 65535, 65535, 65535, 65535, + 65535, 19528, 22166, 14917, 14550, 14918, 65535, 65535, 65535, 14551, + 21469, 15108, 18350, 22708, 65535, 13971, 22542, 21639, 17805, 19906, + 65535, 65535, 65535, 65535, 17806, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23717, 13997, 65535, 65535, 65535, + 22969, 15341, 20857, 65535, 15915, 16818, 23663, 16492, 22561, 23115, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14969, + 65535, 16515, 65535, 20300, 22742, 65535, 65535, 65535, 65535, 65535, + 17475, 65535, 65535, 17610, 65535, 22958, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19554, 65535, 65535, 65535, 65535, 23724, 22328, + 65535, 16907, 23664, 65535, 19553, 65535, 65535, 65535, 16124, 65535, + 65535, 65535, 65535, 65535, 21043, 65535, 14552, 65535, 65535, 65535, + 65535, 65535, 65535, 22517, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21393, 65535, 21392, 65535, + 65535, 65535, 65535, 65535, 65535, 14553, 65535, 17016, 65535, 13972, + 65535, 65535, 65535, 65535, 65535, 18781, 23303, 16819, 65535, 65535, + 20831, 65535, 65535, 65535, 65535, 65535, 22756, 65535, 65535, 65535, + 65535, 65535, 23365, 65535, 14919, 65535, 17476, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22392, 65535, 65535, 65535, + 20625, 65535, 65535, 21566, 14790, 65535, 65535, 65535, 65535, 65535, + 65535, 23091, 65535, 65535, 65535, 65535, 22959, 65535, 65535, 65535, + 65535, 20479, 65535, 65535, 18983, 22896, 65535, 65535, 23354, 65535, + 65535, 65535, 22970, 20808, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20057, 65535, 65535, + 65535, 13973, 65535, 65535, 22035, 65535, 65535, 65535, 65535, 14589, + 23551, 65535, 65535, 65535, 21986, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22711, 65535, 17807, 21603, 65535, 65535, 65535, 65535, + 65535, 65535, 16493, 65535, 15723, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 16662, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20115, 65535, 21816, 65535, 65535, + 65535, 18963, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22393, 65535, 65535, 65535, 65535, 65535, 22407, 65535, 17989, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16908, 65535, 65535, + 65535, 14431, 65535, 65535, 15701, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18920, 65535, 65535, 65535, 65535, 22960, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 21191, 65535, 65535, 65535, 14206, 65535, 65535, 65535, + 18173, 65535, 21987, 15955, 65535, 23665, 22961, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21968, 23689, 23481, 65535, 23731, 14031, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23684, 65535, 20116, 17990, 15345, + 14791, 65535, 15679, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23666, 65535, 18019, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21604, 65535, 65535, 65535, 65535, 65535, 19555, 65535, 15183, 65535, + 65535, 21765, 65535, 65535, 65535, 17808, 22349, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18420, 21394, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22518, 65535, 65535, 13974, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14920, 65535, 65535, 17991, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18351, 65535, 65535, 21216, 65535, 22329, 65535, 18737, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23123, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15184, 65535, + 65535, 23732, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17611, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23552, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19316, + 65535, 65535, 65535, 65535, 65535, 65535, 17778, 65535, 23116, 65535, + 65535, 65535, 65535, 65535, 19176, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 20651, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15490, 65535, 65535, 23733, + 65535, 65535, 65535, 22157, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18421, 17809, 65535, 65535, 23527, 65535, 20480, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14596, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 16268, 14554, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22758, 19151, 65535, 65535, 65535, 14989, 65535, + 65535, 14963, 65535, 20089, 65535, 65535, 65535, 65535, 20059, 20058, + 65535, 65535, 15756, 65535, 15680, 65535, 65535, 65535, 65535, 65535, + 65535, 22562, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 20809, 65535, 65535, 65535, 65535, 15109, 65535, 65535, 21567, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15185, + 65535, 65535, 65535, 65535, 21568, 65535, 22603, 65535, 65535, 65535, + 65535, 15124, 65535, 65535, 17204, 65535, 65535, 15702, 14041, 65535, + 21381, 14208, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22586, 65535, 65535, + 14597, 65535, 22519, 65535, 65535, 65535, 22737, 65535, 65535, 65535, + 15736, 65535, 14393, 65535, 65535, 65535, 65535, 14921, 65535, 65535, + 65535, 65535, 65535, 65535, 22408, 65535, 65535, 65535, 65535, 65535, + 18422, 65535, 65535, 65535, 65535, 65535, 15735, 65535, 65535, 23179, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23092, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 20292, 65535, 14922, 20060, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18984, 65535, 65535, 65535, 19880, + 21431, 65535, 65535, 16681, 65535, 65535, 18227, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19305, 17477, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21836, 65535, 65535, 65535, 18763, 65535, 65535, 21656, 65535, 17233, + 15186, 65535, 15187, 65535, 65535, 65535, 14975, 65535, 15724, 65535, + 65535, 14362, 22571, 65535, 14163, 20263, 18935, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22005, 65535, 65535, 17419, + 65535, 65535, 21192, 65535, 65535, 19317, 65535, 65535, 14042, 65535, + 65535, 65535, 65535, 19740, 19167, 17420, 65535, 65535, 20677, 15757, + 65535, 65535, 65535, 65535, 14432, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14777, 19486, 65535, 65535, 65535, 14190, 65535, 18352, 65535, 65535, + 22533, 65535, 65535, 15758, 15725, 65535, 22167, 65535, 65535, 65535, + 18016, 65535, 65535, 20888, 19556, 65535, 23675, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 21605, 65535, 65535, 65535, 21805, 65535, 65535, + 20889, 65535, 18576, 65535, 65535, 65535, 65535, 14394, 65535, 18029, + 65535, 65535, 65535, 19881, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 16870, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22180, 65535, 21457, 23124, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16903, 15899, 65535, 65535, 65535, 65535, + 22394, 65535, 65535, 65535, 65535, 17612, 65535, 65535, 65535, 65535, + 65535, 65535, 19557, 20678, 65535, 65535, 14008, 65535, 65535, 17285, + 65535, 65535, 65535, 19686, 65535, 15681, 65535, 65535, 65535, 65535, + 65535, 65535, 23676, 65535, 65535, 22936, 65535, 18971, 65535, 23304, + 65535, 65535, 16439, 14762, 65535, 65535, 65535, 65535, 14778, 16315, + 65535, 65535, 65535, 65535, 19124, 65535, 65535, 65535, 65535, 65535, + 65535, 17810, 20508, 65535, 65535, 20679, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20501, 23305, 18030, 65535, 18423, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22925, 65535, 65535, + 65535, 65535, 15188, 18155, 19731, 65535, 65535, 18577, 15578, 65535, + 19103, 65535, 65535, 65535, 65535, 65535, 16866, 65535, 65535, 65535, + 65535, 15737, 65535, 21969, 22543, 17478, 65535, 19741, 18976, 65535, + 65535, 18802, 65535, 65535, 65535, 65535, 65535, 20433, 65535, 65535, + 65535, 65535, 65535, 65535, 23166, 65535, 65535, 65535, 65535, 65535, + 19177, 65535, 65535, 15189, 15500, 17454, 65535, 65535, 65535, 65535, + 15110, 21395, 23482, 14433, 65535, 65535, 17613, 23134, 65535, 22578, + 65535, 65535, 23093, 65535, 65535, 65535, 65535, 65535, 20890, 65535, + 17811, 65535, 65535, 65535, 65535, 19558, 65535, 65535, 22527, 20271, + 20680, 18156, 17614, 65535, 65535, 65535, 65535, 15504, 15516, 65535, + 65535, 65535, 14009, 65535, 65535, 65535, 65535, 23306, 65535, 65535, + 65535, 65535, 19188, 17644, 16670, 65535, 65535, 65535, 65535, 65535, + 20509, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15190, + 65535, 65535, 19742, 15155, 65535, 16871, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22395, 65535, 65535, + 17205, 65535, 65535, 65535, 22579, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16682, 65535, 21948, + 65535, 65535, 22006, 65535, 65535, 65535, 65535, 21044, 65535, 65535, + 16836, 65535, 65535, 20626, 65535, 18738, 65535, 65535, 65535, 65535, + 20832, 14555, 65535, 18228, 20090, 65535, 65535, 65535, 65535, 20510, + 19743, 65535, 14164, 21390, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 14010, 65535, 20434, 65535, 21640, 65535, 23734, 65535, + 22978, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19318, 65535, 65535, 20481, 65535, 65535, 65535, 20627, 65535, 20091, + 65535, 19728, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17812, 65535, 65535, 65535, 65535, + 65535, 65535, 15491, 65535, 65535, 19559, 15349, 65535, 65535, 19319, + 18782, 65535, 65535, 65535, 65535, 18921, 65535, 65535, 65535, 16645, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22330, 65535, 65535, 65535, 65535, 65535, 21817, 65535, + 65535, 65535, 65535, 16440, 65535, 65535, 65535, 65535, 22587, 65535, + 65535, 19703, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23345, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17645, 65535, 65535, 65535, + 17479, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16683, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17017, 20061, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18739, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 13975, 18424, 65535, 20062, 65535, 65535, 65535, 65535, 21641, + 65535, 65535, 23163, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 20858, 65535, 65535, 65535, 65535, 22979, 65535, + 65535, 15561, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23366, + 65535, 65535, 65535, 23735, 65535, 18174, 14792, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22743, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17779, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17992, 65535, + 65535, 19125, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 20628, 23159, 65535, 65535, 14613, 20621, + 65535, 20629, 21262, 65535, 17576, 65535, 20630, 23553, 65535, 16700, + 65535, 65535, 65535, 14434, 14556, 65535, 65535, 65535, 65535, 23094, + 65535, 18396, 65535, 65535, 65535, 65535, 18578, 20662, 65535, 65535, + 65535, 17577, 65535, 65535, 22937, 65535, 20117, 65535, 19172, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15750, 65535, 19907, + 18425, 18949, 65535, 18403, 19704, 65535, 65535, 14784, 65535, 65535, + 65535, 17438, 65535, 22536, 23548, 21268, 14740, 21396, 21045, 19705, + 20316, 65535, 65535, 65535, 65535, 65535, 14207, 18175, 18803, 20118, + 23483, 65535, 65535, 65535, 65535, 65535, 18229, 65535, 14979, 65535, + 20810, 65535, 65535, 23095, 19320, 18353, 13976, 65535, 18783, 19882, + 65535, 65535, 65535, 65535, 65535, 18579, 21837, 65535, 20859, 20063, + 15191, 20482, 17048, 14923, 65535, 65535, 65535, 65535, 17578, 65535, + 65535, 65535, 16684, 65535, 22941, 19908, 18764, 65535, 65535, 15513, + 65535, 65535, 65535, 65535, 65535, 65535, 16637, 21799, 65535, 14626, + 22379, 65535, 19560, 19744, 18804, 15512, 21838, 18806, 65535, 17813, + 14741, 65535, 16332, 21432, 65535, 65535, 65535, 65535, 65535, 22168, + 17421, 65535, 22162, 65535, 17814, 65535, 65535, 65535, 65535, 65535, + 65535, 17455, 65535, 65535, 17815, 65535, 65535, 20681, 20891, 20092, + 21263, 18807, 65535, 15738, 15759, 18354, 65535, 18355, 65535, 65535, + 65535, 65535, 21996, 65535, 65535, 17993, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19909, 65535, 65535, 65535, + 17206, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22331, + 65535, 65535, 65535, 65535, 65535, 65535, 18740, 20272, 21954, 14557, + 15574, 65535, 17018, 15552, 14964, 65535, 65535, 65535, 65535, 14215, + 14435, 65535, 14976, 65535, 65535, 19674, 65535, 18742, 18741, 65535, + 65535, 18203, 65535, 65535, 65535, 20892, 65535, 65535, 65535, 65535, + 65535, 17404, 65535, 65535, 65535, 65535, 15760, 65535, 16441, 65535, + 22346, 16494, 65535, 65535, 65535, 65535, 65535, 65535, 18388, 65535, + 65535, 15939, 65535, 17958, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23718, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 15192, 20667, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14165, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18964, + 65535, 18426, 14157, 65535, 65535, 65535, 65535, 15739, 65535, 18936, + 65535, 23307, 65535, 17035, 18950, 65535, 16270, 65535, 65535, 65535, + 21027, 65535, 18427, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22350, 65535, 65535, + 65535, 65535, 65535, 65535, 17994, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18922, 65535, 65535, 65535, 65535, 65535, 65535, 17456, + 17457, 65535, 65535, 65535, 23139, 65535, 15761, 65535, 65535, 65535, + 65535, 21433, 65535, 23167, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18618, 65535, 65535, 65535, 65535, 65535, 16102, + 15193, 65535, 65535, 14598, 65535, 65535, 22178, 65535, 18985, 14166, + 65535, 16471, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18619, 65535, 17633, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17019, 14043, 65535, 65535, 65535, 16080, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18716, 65535, 65535, 19732, 65535, 65535, 21766, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14924, 65535, 65535, 65535, 15762, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 15946, 65535, 65535, 14793, 65535, 19747, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19180, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19489, 65535, 16271, 65535, 18031, 18937, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19733, 65535, 65535, 65535, 65535, 16646, 65535, 65535, 65535, + 18965, 65535, 65535, 65535, 65535, 65535, 65535, 21970, 21397, 65535, + 65535, 18587, 18356, 65535, 65535, 14614, 21382, 14794, 14216, 65535, + 65535, 16882, 65535, 65535, 21767, 65535, 65535, 15194, 20436, 17816, + 22588, 65535, 65535, 22980, 65535, 65535, 65535, 65535, 65535, 18397, + 14233, 65535, 65535, 65535, 18743, 22759, 65535, 65535, 17273, 65535, + 65535, 65535, 65535, 65535, 23736, 65535, 65535, 65535, 65535, 22537, + 65535, 65535, 65535, 65535, 22007, 65535, 65535, 21642, 65535, 17252, + 65535, 21193, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18428, + 65535, 65535, 65535, 65535, 65535, 17817, 65535, 18157, 65535, 65535, + 65535, 65535, 65535, 20682, 65535, 65535, 15740, 65535, 17995, 65535, + 65535, 65535, 65535, 16837, 65535, 23667, 21046, 65535, 65535, 65535, + 18938, 22780, 65535, 17207, 65535, 65535, 65535, 65535, 23503, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16638, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22351, 65535, 17258, + 15726, 22744, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14011, 22738, 15505, 65535, + 65535, 17405, 23110, 14012, 65535, 23484, 20119, 20120, 15195, 65535, + 65535, 65535, 65535, 65535, 20683, 65535, 65535, 17646, 65535, 65535, + 17996, 65535, 65535, 65535, 65535, 18032, 65535, 65535, 65535, 65535, + 65535, 20833, 65535, 21028, 65535, 65535, 14395, 65535, 17579, 65535, + 65535, 65535, 17997, 65535, 65535, 65535, 65535, 65535, 15763, 21383, + 65535, 65535, 65535, 14558, 65535, 21047, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18966, 18033, 14167, 19883, 65535, 65535, 65535, + 65535, 65535, 20121, 65535, 65535, 65535, 17998, 65535, 65535, 65535, + 65535, 65535, 22926, 16260, 16093, 65535, 65535, 65535, 65535, 65535, + 14925, 65535, 65535, 14734, 65535, 65535, 16333, 65535, 65535, 65535, + 21398, 20893, 65535, 65535, 65535, 16872, 21818, 65535, 22745, 14763, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16125, 65535, + 65535, 65535, 65535, 65535, 65535, 22015, 65535, 65535, 19322, 21048, + 65535, 65535, 14234, 23528, 65535, 65535, 65535, 65535, 65535, 17392, + 65535, 65535, 16316, 65535, 65535, 65535, 65535, 65535, 22746, 65535, + 65535, 65535, 65535, 18765, 65535, 18744, 65535, 14980, 21217, 20483, + 65535, 17630, 23355, 65535, 65535, 20437, 65535, 65535, 65535, 21194, + 65535, 65535, 65535, 65535, 65535, 65535, 23140, 23308, 65535, 15517, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19111, 65535, 65535, + 65535, 20684, 65535, 65535, 65535, 65535, 14168, 65535, 22911, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22520, 65535, 14169, 65535, 17020, 65535, 16647, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 15682, 23293, 65535, 23691, 65535, 20438, + 65535, 65535, 65535, 65535, 65535, 65535, 23276, 65535, 65535, 65535, + 19168, 19933, 65535, 21839, 22788, 21218, 17780, 22721, 65535, 65535, + 21819, 19490, 65535, 65535, 65535, 65535, 65535, 17208, 65535, 19306, + 65535, 65535, 22903, 65535, 65535, 17631, 19722, 21049, 65535, 65535, + 65535, 15741, 65535, 18588, 65535, 65535, 23529, 16475, 23668, 65535, + 65535, 65535, 18034, 14396, 15764, 65535, 65535, 65535, 65535, 15945, + 17234, 17818, 65535, 65535, 65535, 65535, 21269, 65535, 16103, 19152, + 65535, 65535, 65535, 65535, 65535, 65535, 23504, 17439, 18589, 65535, + 65535, 65535, 17021, 65535, 65535, 65535, 65535, 65535, 65535, 21758, + 65535, 15751, 65535, 21988, 65535, 65535, 65535, 23692, 65535, 65535, + 65535, 65535, 65535, 18808, 65535, 22912, 65535, 65535, 65535, 65535, + 65535, 65535, 15196, 20484, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22163, 21569, 16671, 16672, 65535, 65535, 65535, 65535, + 65535, 65535, 22222, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22390, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 15508, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23351, 65535, 17615, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18977, + 65535, 65535, 15518, 65535, 65535, 65535, 22760, 65535, 65535, 65535, + 65535, 65535, 16272, 17819, 65535, 65535, 22544, 20439, 65535, 65535, + 65535, 15170, 65535, 18230, 20064, 65535, 14779, 65535, 65535, 65535, + 65535, 14350, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20511, + 18590, 18745, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23505, 65535, 65535, 14615, 65535, 22981, 65535, 65535, 18035, + 65535, 65535, 65535, 19126, 65535, 65535, 65535, 14756, 65535, 65535, + 65535, 65535, 23530, 20631, 23704, 22352, 65535, 65535, 22942, 20293, + 13998, 65535, 15509, 14616, 65535, 18766, 23725, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19362, 65535, 65535, + 65535, 18805, 65535, 65535, 21195, 22943, 65535, 65535, 65535, 65535, + 65535, 65535, 23531, 65535, 22712, 65535, 65535, 65535, 18404, 20894, + 65535, 65535, 65535, 19561, 20122, 65535, 65535, 23485, 22169, 65535, + 65535, 16495, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21270, 65535, 17647, 15752, 22227, 65535, 17036, 65535, 14436, 65535, + 65535, 65535, 15765, 21949, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21050, 65535, 15900, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23342, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23352, 65535, 18158, 65535, 65535, 20123, 23294, 18939, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22396, 15546, 65535, 17999, 65535, 65535, + 23506, 65535, 65535, 19104, 18231, 22344, 65535, 65535, 65535, 65535, + 65535, 18429, 65535, 65535, 65535, 65535, 14235, 65535, 20124, 20125, + 65535, 65535, 65535, 17037, 22725, 20317, 65535, 65535, 65535, 65535, + 65535, 18940, 65535, 65535, 65535, 65535, 19910, 18986, 65535, 65535, + 65535, 14044, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14780, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23507, 65535, + 65535, 65535, 21820, 65535, 65535, 14191, 65535, 65535, 65535, 65535, + 18784, 65535, 14192, 20065, 65535, 65535, 19884, 65535, 16476, 65535, + 65535, 20294, 20632, 65535, 14380, 22545, 23508, 65535, 65535, 65535, + 65535, 65535, 65535, 22789, 65535, 16838, 65535, 65535, 21806, 21807, + 65535, 65535, 65535, 22583, 65535, 22564, 65535, 65535, 16648, 14742, + 13999, 65535, 65535, 23295, 14193, 65535, 65535, 21271, 65535, 65535, + 16126, 65535, 20093, 65535, 65535, 65535, 65535, 65535, 14397, 14170, + 65535, 65535, 65535, 65535, 65535, 21955, 19870, 65535, 65535, 22170, + 19911, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17648, 65535, + 65535, 65535, 21458, 65535, 16146, 17792, 65535, 65535, 22036, 65535, + 65535, 65535, 23738, 23737, 22521, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17616, 65535, 65535, 15916, 65535, 14353, + 65535, 17038, 14398, 65535, 16883, 65535, 65535, 65535, 23127, 65535, + 65535, 65535, 19162, 65535, 65535, 65535, 15703, 65535, 65535, 65535, + 14045, 65535, 65535, 65535, 65535, 15141, 65535, 65535, 65535, 14013, + 23096, 20310, 19563, 16884, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 15350, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 21759, 65535, 65535, 65535, 15956, 23532, 23141, 65535, + 21808, 65535, 14926, 65535, 65535, 20318, 16147, 65535, 65535, 65535, + 65535, 65535, 65535, 15727, 14627, 65535, 16885, 65535, 18614, 18526, + 20287, 65535, 18232, 18923, 14437, 65535, 65535, 65535, 23343, 65535, + 65535, 65535, 21956, 65535, 65535, 65535, 65535, 15134, 65535, 14046, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21019, 65535, + 65535, 65535, 16467, 65535, 20895, 23739, 65535, 65535, 15742, 65535, + 23309, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16127, 17209, + 18357, 22728, 65535, 65535, 65535, 65535, 65535, 18176, 23310, 17649, + 65535, 18527, 65535, 20811, 65535, 65535, 65535, 65535, 65535, 22397, + 65535, 65535, 65535, 65535, 22410, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17617, 65535, 65535, 15171, + 65535, 65535, 65535, 65535, 17581, 65535, 65535, 17650, 65535, 65535, + 18994, 65535, 65535, 18730, 15197, 65535, 65535, 65535, 22037, 65535, + 65535, 65535, 65535, 14373, 22589, 65535, 65535, 65535, 65535, 65535, + 65535, 19163, 18036, 65535, 65535, 22580, 65535, 22982, 21020, 65535, + 65535, 22761, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22904, 65535, 65535, + 65535, 65535, 65535, 22762, 65535, 65535, 65535, 20834, 65535, 65535, + 65535, 16663, 65535, 65535, 18972, 22181, 65535, 65535, 65535, 65535, + 17632, 65535, 65535, 65535, 65535, 16886, 15510, 16090, 65535, 65535, + 17074, 17053, 65535, 15352, 14781, 65535, 14217, 21957, 17096, 65535, + 22398, 19748, 14927, 21265, 65535, 22038, 17235, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 14757, 18767, 15342, 21460, 65535, 14617, 65535, 14990, + 65535, 65535, 65535, 14559, 65535, 65535, 65535, 65535, 65535, 65535, + 18721, 15353, 65535, 21570, 65535, 65535, 65535, 65535, 65535, 21571, + 65535, 18951, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15766, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 21384, 65535, 65535, 65535, 21606, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21051, 19326, 65535, 16649, 23168, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 21776, 65535, 65535, 22709, 65535, + 65535, 15378, 19325, 65535, 65535, 65535, 65535, 22763, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17458, 17820, 65535, 65535, 65535, + 65535, 65535, 14218, 65535, 65535, 65535, 14991, 65535, 65535, 65535, + 65535, 22008, 65535, 65535, 15379, 15511, 65535, 65535, 65535, 18037, + 65535, 65535, 65535, 18358, 65535, 65535, 65535, 65535, 18528, 15767, + 65535, 65535, 20685, 65535, 65535, 65535, 65535, 65535, 17236, 65535, + 65535, 65535, 18995, 65535, 14977, 65535, 65535, 14773, 65535, 65535, + 65535, 65535, 16106, 21840, 22529, 65535, 65535, 21035, 65535, 14618, + 22182, 19178, 21219, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14014, 65535, 65535, 65535, 20126, 65535, + 15111, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16873, + 21196, 65535, 65535, 65535, 65535, 65535, 20306, 65535, 65535, 65535, + 19127, 23486, 65535, 65535, 65535, 65535, 65535, 18941, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14354, + 23693, 65535, 65535, 65535, 65535, 65535, 20066, 65535, 19105, 17981, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18398, 65535, 17054, 65535, 65535, 65535, 65535, 18359, 65535, + 19749, 15768, 65535, 65535, 65535, 65535, 18529, 65535, 65535, 65535, + 65535, 65535, 21607, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17075, 22534, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 23700, 65535, 65535, 65535, + 21777, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 20860, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22171, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 16629, 65535, 65535, 65535, 65535, 65535, 21572, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16839, 16840, + 21036, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16291, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22558, 17969, 19750, 65535, 65535, 65535, 65535, + 65535, 65535, 15506, 65535, 65535, 65535, 15728, 65535, 65535, 65535, + 65535, 65535, 21989, 17097, 65535, 65535, 65535, 65535, 65535, 16887, + 65535, 22590, 22176, 65535, 21783, 65535, 17055, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 15696, 65535, 65535, 65535, 65535, + 65535, 19687, 65535, 65535, 16292, 21971, 65535, 22556, 65535, 65535, + 14355, 65535, 65535, 21220, 14399, 65535, 65535, 65535, 15156, 65535, + 15704, 65535, 65535, 65535, 17286, 65535, 14219, 65535, 65535, 65535, + 65535, 65535, 65535, 15743, 22412, 65535, 65535, 16081, 21800, 14220, + 65535, 65535, 65535, 65535, 20319, 65535, 65535, 65535, 65535, 65535, + 21958, 65535, 23475, 65535, 65535, 65535, 65535, 65535, 22591, 65535, + 65535, 65535, 19751, 65535, 17076, 65535, 65535, 65535, 22559, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19128, 65535, + 65535, 65535, 65535, 18223, 65535, 65535, 65535, 65535, 65535, 16148, + 65535, 65535, 65535, 65535, 65535, 65535, 14795, 23476, 16082, 65535, + 65535, 21573, 65535, 65535, 65535, 65535, 65535, 65535, 18530, 14560, + 20127, 14194, 65535, 14619, 65535, 65535, 17210, 21052, 65535, 65535, + 65535, 65535, 65535, 14561, 65535, 65535, 23554, 65535, 65535, 65535, + 65535, 18038, 14796, 17039, 65535, 14928, 65535, 65535, 65535, 65535, + 19564, 22713, 65535, 65535, 65535, 65535, 65535, 65535, 21821, 65535, + 65535, 65535, 14047, 17959, 65535, 65535, 15901, 65535, 65535, 65535, + 65535, 65535, 14400, 19129, 65535, 65535, 65535, 65535, 14562, 65535, + 21053, 20861, 65535, 17582, 18531, 65535, 65535, 65535, 65535, 65535, + 18177, 65535, 65535, 65535, 16261, 22747, 65535, 23555, 65535, 16909, + 65535, 65535, 65535, 65535, 17781, 65535, 65535, 65535, 17651, 17077, + 65535, 65535, 65535, 65535, 65535, 15929, 65535, 16334, 65535, 14590, + 17821, 65535, 65535, 21653, 65535, 18959, 65535, 65535, 15142, 21959, + 65535, 17583, 65535, 65535, 65535, 20652, 21809, 65535, 65535, 17822, + 18785, 65535, 65535, 65535, 65535, 65535, 65535, 15683, 65535, 17211, + 65535, 65535, 19153, 18746, 65535, 65535, 65535, 17212, 65535, 65535, + 65535, 16128, 65535, 65535, 65535, 65535, 65535, 18178, 21054, 65535, + 65535, 21258, 65535, 65535, 16453, 65535, 65535, 65535, 65535, 15198, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16888, 65535, + 65535, 15199, 65535, 20502, 15684, 65535, 21574, 21221, 65535, 65535, + 18591, 19934, 65535, 65535, 65535, 22944, 65535, 65535, 19912, 65535, + 65535, 65535, 65535, 65535, 19723, 17040, 17041, 15902, 65535, 19565, + 65535, 65535, 65535, 65535, 65535, 65535, 14599, 18731, 65535, 17213, + 23311, 65535, 21822, 65535, 16820, 23346, 17618, 15157, 65535, 19307, + 18159, 23713, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17406, 18233, 19492, 65535, 65535, 65535, 65535, 22215, 65535, 16685, + 20653, 65535, 65535, 65535, 65535, 18360, 65535, 18747, 22927, 19935, + 65535, 65535, 16874, 65535, 21823, 65535, 65535, 65535, 17407, 18978, + 65535, 65535, 65535, 65535, 65535, 21222, 18748, 23509, 23510, 65535, + 65535, 65535, 65535, 21608, 65535, 21609, 65535, 65535, 65535, 18952, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21434, + 65535, 23142, 65535, 21399, 23740, 18234, 65535, 65535, 65535, 65535, + 19566, 23488, 23533, 23312, 18786, 16650, 65535, 22413, 65535, 65535, + 17422, 14401, 65535, 65535, 65535, 18160, 22016, 65535, 21055, 15007, + 21056, 65535, 21575, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23685, 65535, 65535, 13977, 23682, 23694, 65535, 65535, + 65535, 65535, 19493, 65535, 20094, 18039, 65535, 65535, 65535, 65535, + 15371, 18967, 19130, 65535, 65535, 65535, 65535, 16821, 65535, 65535, + 14563, 65535, 21824, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20668, 65535, 65535, 16841, 65535, 65535, 65535, 20686, 23296, + 22781, 65535, 65535, 65535, 65535, 18216, 65535, 14402, 65535, 65535, + 15903, 65535, 65535, 65535, 65535, 65535, 19480, 65535, 16140, 15705, + 65535, 23556, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18987, 65535, 65535, 18040, 65535, 65535, + 19753, 22782, 65535, 65535, 14764, 65535, 65535, 65535, 65535, 65535, + 23741, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19721, 65535, 14591, 19529, 14403, 65535, 65535, 14032, 18041, 21224, + 21223, 65535, 16651, 65535, 21459, 22025, 22179, 65535, 65535, 23534, + 65535, 65535, 65535, 65535, 20082, 20128, 65535, 17634, 65535, 17440, + 65535, 65535, 65535, 65535, 65535, 65535, 17858, 21654, 65535, 16094, + 65535, 65535, 65535, 16673, 65535, 21225, 15296, 15297, 65535, 65535, + 65535, 65535, 65535, 65535, 16867, 16317, 16857, 65535, 17022, 16664, + 17451, 21801, 22219, 65535, 65535, 21400, 65535, 65535, 17056, 65535, + 22399, 65535, 65535, 65535, 15000, 65535, 65535, 23669, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14015, 65535, 65535, 17975, + 65535, 65535, 65535, 65535, 16496, 23111, 20812, 22164, 65535, 22790, + 65535, 65535, 20687, 65535, 65535, 65535, 65535, 65535, 15930, 65535, + 15298, 18389, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22983, 65535, 17237, 14244, 15917, + 65535, 16875, 65535, 20835, 65535, 22592, 65535, 65535, 65535, 15563, + 65535, 65535, 18405, 22604, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17652, 65535, 19724, 65535, 17214, 65535, 65535, 65535, 15382, + 18161, 65535, 65535, 15931, 65535, 22380, 65535, 16524, 65535, 65535, + 16686, 65535, 14628, 21576, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14564, 22739, 65535, 65535, 21577, 65535, 65535, 13978, 13979, + 14929, 65535, 65535, 65535, 65535, 65535, 18749, 65535, 65535, 65535, + 65535, 65535, 17408, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 17253, 16842, 14048, 22376, 19373, 20130, 65535, + 65535, 65535, 65535, 65535, 20131, 65535, 65535, 22414, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14930, + 65535, 65535, 14016, 65535, 65535, 13980, 15501, 21401, 65535, 16454, + 18750, 21848, 17823, 65535, 65535, 65535, 65535, 17824, 65535, 65535, + 21057, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18592, 20896, 65535, 65535, 18042, 16477, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14797, 17254, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21402, 65535, 65535, 65535, 65535, 19936, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23108, 15143, + 65535, 65535, 14356, 20813, 65535, 65535, 14245, 22984, 14438, 15769, + 65535, 65535, 65535, 65535, 18953, 65535, 65535, 65535, 65535, 65535, + 21643, 65535, 15918, 18000, 65535, 23489, 15343, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21610, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22565, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14017, + 65535, 16112, 65535, 65535, 65535, 16687, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14592, 65535, 65535, 65535, 20814, + 22353, 65535, 65535, 14404, 65535, 65535, 65535, 65535, 65535, 21226, + 65535, 23557, 65535, 19706, 22039, 65535, 65535, 65535, 65535, 19567, + 16497, 65535, 65535, 65535, 65535, 17825, 65535, 21197, 14439, 14600, + 65535, 18361, 65535, 17274, 17023, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15300, 17409, + 65535, 65535, 65535, 16711, 65535, 15299, 65535, 14601, 65535, 65535, + 65535, 65535, 17459, 65535, 65535, 21272, 65535, 21227, 15135, 65535, + 17635, 65535, 65535, 65535, 65535, 15919, 15729, 65535, 65535, 65535, + 65535, 65535, 65535, 20663, 14536, 65535, 65535, 65535, 65535, 65535, + 17976, 65535, 65535, 65535, 18043, 65535, 65535, 65535, 65535, 65535, + 65535, 15866, 14743, 65535, 65535, 65535, 65535, 65535, 19707, 65535, + 65535, 65535, 65535, 20320, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18768, 22183, 65535, 65535, 65535, 22136, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16822, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19106, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19328, + 65535, 22216, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19132, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22898, 18204, 22400, 65535, 14236, 65535, 16889, 22137, 65535, + 65535, 65535, 16484, 65535, 15383, 20133, 20134, 17024, 65535, 65535, + 65535, 65535, 21058, 65535, 65535, 21454, 65535, 19181, 20836, 18593, + 65535, 65535, 65535, 65535, 65535, 15136, 65535, 23097, 22184, 19494, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19885, 65535, 65535, + 65535, 65535, 65535, 21611, 17215, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23511, 65535, 17653, 65535, 65535, 65535, 65535, + 65535, 65535, 19495, 65535, 65535, 65535, 65535, 65535, 16455, 65535, + 65535, 65535, 65535, 65535, 65535, 22535, 65535, 65535, 65535, 65535, + 65535, 14565, 65535, 17078, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14931, 22572, 21825, 65535, 65535, 14782, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14735, 65535, 14195, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15112, + 65535, 21228, 65535, 15144, 65535, 65535, 18942, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17259, 65535, 65535, 65535, 65535, 65535, + 65535, 16113, 65535, 16442, 65535, 65535, 65535, 20837, 65535, 22791, + 65535, 65535, 65535, 65535, 22185, 20688, 65535, 16843, 65535, 19133, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22138, 65535, 65535, + 17057, 18532, 23367, 65535, 65535, 21435, 65535, 65535, 65535, 65535, + 65535, 65535, 14049, 65535, 65535, 65535, 19755, 65535, 65535, 14798, + 65535, 65535, 65535, 65535, 65535, 65535, 19943, 18594, 65535, 65535, + 65535, 65535, 15130, 15947, 65535, 65535, 65535, 65535, 65535, 15301, + 65535, 18001, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23549, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15685, 65535, 65535, 65535, 14357, 65535, 65535, 65535, + 65535, 21059, 65535, 65535, 65535, 19164, 15158, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17287, 65535, 65535, 65535, 65535, + 23535, 65535, 65535, 65535, 65535, 65535, 14249, 20689, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 17782, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22962, 65535, 65535, 65535, 65535, 65535, 65535, 15867, 15001, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16293, 65535, 65535, 65535, 65535, + 65535, 65535, 16129, 21453, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23128, 65535, 65535, 65535, 65535, 19096, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16072, 65535, 65535, 65535, 65535, 65535, + 14992, 65535, 20690, 65535, 65535, 65535, 65535, 65535, 16073, 65535, + 65535, 65535, 16083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23721, 21768, 65535, 23714, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19871, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15302, 65535, + 65535, 23722, 14744, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23723, 23131, 65535, 65535, 65535, 65535, 13981, 65535, 22522, 65535, + 14932, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19287, 65535, 23487, 21578, 21060, + 21769, 17423, 16890, 65535, 65535, 65535, 19729, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18343, 65535, 65535, 65535, 65535, 16141, + 15008, 65535, 65535, 17826, 65535, 65535, 65535, 16864, 65535, 65535, + 65535, 18979, 21612, 65535, 22546, 65535, 65535, 18595, 18533, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18769, 65535, 20664, 65535, 65535, 65535, 65535, 65535, 19944, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16262, 17783, 65535, 65535, 18217, 65535, + 65535, 15686, 65535, 20295, 65535, 65535, 17970, 65535, 14000, 65535, + 65535, 20897, 65535, 23690, 65535, 65535, 65535, 20321, 14933, 65535, + 65535, 65535, 65535, 16891, 65535, 16844, 65535, 16688, 65535, 65535, + 15889, 20265, 17654, 65535, 17655, 17656, 17657, 65535, 65535, 16845, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23313, 14934, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 20898, 65535, 65535, 65535, 65535, 65535, + 65535, 18916, 65535, 17042, 65535, 16701, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 15303, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18534, 65535, + 65535, 17793, 19496, 65535, 65535, 65535, 65535, 65535, 17275, 65535, + 21061, 21455, 14935, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17276, 65535, 18162, 65535, 65535, 65535, + 65535, 17960, 65535, 22945, 65535, 65535, 19568, 65535, 65535, 19288, + 23356, 14171, 21579, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14606, 65535, 19725, 65535, 65535, 19530, 65535, 65535, 22547, 65535, + 15172, 65535, 65535, 65535, 17006, 65535, 65535, 65535, 14374, 65535, + 65535, 15304, 17619, 65535, 65535, 18809, 15305, 19675, 65535, 20067, + 22985, 19329, 22381, 65535, 65535, 65535, 15904, 65535, 65535, 65535, + 16858, 65535, 16865, 15718, 16712, 17014, 22223, 65535, 65535, 17827, + 21580, 22714, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16665, 65535, 65535, + 20838, 65535, 65535, 65535, 65535, 22928, 65535, 65535, 65535, 65535, + 17658, 20135, 65535, 22354, 18362, 14566, 21997, 19330, 65535, 23512, + 23277, 65535, 18205, 65535, 65535, 65535, 65535, 21972, 17058, 65535, + 22913, 65535, 65535, 65535, 65535, 65535, 65535, 23357, 65535, 17281, + 65535, 17828, 65535, 65535, 65535, 17277, 65535, 65535, 65535, 65535, + 65535, 22765, 22593, 20307, 65535, 15575, 65535, 65535, 21403, 65535, + 65535, 23143, 65535, 65535, 17079, 17043, 22548, 65535, 65535, 19497, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19134, 16257, 65535, 65535, 65535, 65535, 17424, + 65535, 65535, 65535, 65535, 65535, 18344, 65535, 18535, 65535, 16061, + 65535, 65535, 15920, 65535, 65535, 65535, 65535, 65535, 65535, 21613, + 65535, 20136, 65535, 18206, 23358, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 21404, 65535, 65535, 18596, 23710, 65535, 14765, 20068, + 65535, 23497, 65535, 23726, 22594, 65535, 65535, 16456, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21021, 21436, 65535, 17784, 65535, 65535, 65535, 65535, 65535, + 65535, 19708, 65535, 65535, 22766, 65535, 65535, 23314, 16095, 65535, + 16498, 65535, 17584, 65535, 65535, 65535, 65535, 65535, 19872, 65535, + 65535, 23098, 22382, 23169, 65535, 65535, 65535, 65535, 65535, 22715, + 65535, 65535, 65535, 65535, 65535, 19363, 65535, 14405, 18363, 18224, + 65535, 65535, 19886, 23558, 19331, 65535, 65535, 18390, 65535, 19332, + 65535, 22026, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18988, 65535, 65535, + 18996, 65535, 65535, 22963, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21062, 65535, 65535, 14993, 22355, 18163, + 23559, 15306, 65535, 65535, 65535, 16525, 65535, 65535, 65535, 23315, + 65535, 18580, 65535, 65535, 65535, 65535, 65535, 65535, 15868, 21273, + 16443, 65535, 65535, 65535, 18406, 65535, 65535, 15706, 65535, 65535, + 65535, 65535, 65535, 65535, 21063, 65535, 16472, 20301, 65535, 65535, + 23536, 65535, 65535, 18907, 65535, 18597, 65535, 19333, 65535, 23347, + 22017, 19179, 21973, 21998, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17977, 65535, 23490, 20839, 14050, 65535, 65535, 65535, 21064, + 14221, 15869, 65535, 17829, 17098, 18943, 19695, 65535, 65535, 65535, + 65535, 18207, 22345, 20095, 65535, 22986, 65535, 65535, 18179, 65535, + 14033, 65535, 19498, 65535, 20138, 65535, 16876, 65535, 17025, 20815, + 23348, 65535, 65535, 65535, 65535, 17238, 17026, 65535, 65535, 65535, + 65535, 65535, 21405, 65535, 65535, 15687, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23316, 65535, 18002, 65535, 65535, 15707, + 18770, 65535, 21065, 23513, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19887, 65535, 65535, 65535, 22186, 65535, 65535, 20485, 22538, + 65535, 65535, 20069, 15384, 65535, 65535, 65535, 65535, 65535, 65535, + 17425, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 20070, 65535, 65535, 65535, 65535, 65535, 21437, 65535, + 65535, 65535, 65535, 65535, 16457, 14936, 65535, 16823, 65535, 65535, + 20503, 65535, 65535, 17585, 65535, 65535, 65535, 65535, 14537, 19679, + 65535, 65535, 65535, 18364, 65535, 21614, 65535, 65535, 65535, 65535, + 19888, 65535, 65535, 65535, 15577, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17216, 65535, 21826, 16719, 65535, 65535, 65535, 23514, + 65535, 20633, 21960, 65535, 23278, 65535, 65535, 23498, 65535, 20816, + 15870, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22027, 65535, 65535, + 65535, 65535, 20862, 65535, 65535, 65535, 23317, 65535, 65535, 65535, + 65535, 65535, 14602, 16652, 65535, 19154, 22792, 65535, 65535, 65535, + 22377, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16444, + 65535, 14196, 65535, 65535, 19334, 21229, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 16639, 65535, 22946, 16149, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16653, 21581, 65535, + 65535, 65535, 65535, 18536, 21827, 65535, 65535, 65535, 65535, 65535, + 21029, 65535, 65535, 65535, 65535, 65535, 65535, 20691, 65535, 19499, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17099, 65535, 65535, 14375, 65535, + 65535, 21657, 17080, 65535, 18581, 20669, 65535, 65535, 16294, 18164, + 65535, 65535, 23515, 65535, 20275, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 15708, 21230, 65535, 15002, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 20665, 65535, 15921, 17426, + 16516, 65535, 65535, 17982, 65535, 65535, 21760, 65535, 65535, 65535, + 21990, 65535, 65535, 65535, 65535, 21406, 22722, 65535, 19945, 65535, + 65535, 65535, 23318, 65535, 65535, 14018, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22947, 22557, 65535, + 65535, 16285, 65535, 65535, 65535, 65535, 65535, 65535, 23537, 21784, + 65535, 20899, 65535, 19569, 65535, 65535, 65535, 65535, 65535, 15709, + 65535, 65535, 65535, 65535, 15697, 65535, 14358, 22415, 16263, 15541, + 65535, 65535, 65535, 65535, 65535, 65535, 19531, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18720, 65535, 65535, + 65535, 65535, 19500, 65535, 65535, 65535, 65535, 21198, 23319, 20236, + 65535, 65535, 15871, 65535, 65535, 65535, 65535, 23320, 65535, 16084, + 21438, 65535, 65535, 22416, 65535, 17785, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16130, 65535, + 65535, 19135, 65535, 65535, 65535, 23279, 15890, 65535, 65535, 17830, + 65535, 18908, 65535, 65535, 65535, 16458, 65535, 22783, 65535, 65535, + 65535, 17786, 65535, 65535, 16295, 65535, 22948, 19501, 20288, 16142, + 21066, 18365, 65535, 65535, 65535, 23099, 65535, 65535, 65535, 16318, + 16323, 65535, 65535, 65535, 65535, 65535, 65535, 19502, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20468, 65535, 65535, 65535, 65535, + 65535, 65535, 16074, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14745, 65535, 65535, 65535, + 23280, 18413, 65535, 65535, 65535, 65535, 65535, 65535, 22523, 65535, + 65535, 65535, 65535, 23321, 65535, 65535, 65535, 65535, 65535, 16654, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23368, 65535, 65535, + 65535, 65535, 23538, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14937, 65535, 65535, 65535, 20654, 20817, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14406, 65535, 65535, 65535, 65535, 22332, 65535, + 65535, 65535, 19375, 65535, 65535, 65535, 22139, 65535, 65535, 65535, + 65535, 65535, 23715, 20634, 14766, 65535, 65535, 65535, 65535, 65535, + 65535, 21067, 65535, 65535, 18366, 65535, 65535, 65535, 65535, 65535, + 65535, 23144, 14222, 22524, 65535, 23281, 65535, 65535, 65535, 17410, + 65535, 65535, 65535, 21407, 20655, 21030, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 16258, 65535, 65535, 23701, 65535, 65535, 65535, 19666, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 23359, 16062, 65535, 65535, + 65535, 21461, 65535, 19336, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14407, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22723, + 65535, 65535, 65535, 17460, 65535, 65535, 65535, 65535, 65535, 65535, + 23677, 65535, 65535, 65535, 65535, 19169, 65535, 65535, 21439, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17239, 17620, 65535, 65535, 65535, 15905, 65535, 65535, 16892, + 65535, 65535, 65535, 65535, 22140, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19376, 65535, 65535, 65535, 65535, 65535, + 19337, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23695, 65535, 16246, + 23686, 65535, 23516, 65535, 20996, 65535, 19503, 65535, 65535, 65535, + 65535, 65535, 15373, 65535, 65535, 19338, 65535, 65535, 19937, 65535, + 17971, 65535, 65535, 65535, 65535, 65535, 16689, 23491, 23670, 21231, + 65535, 17260, 65535, 65535, 19136, 65535, 20635, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18180, 65535, 65535, 65535, 65535, 65535, 65535, 18771, 65535, + 65535, 65535, 65535, 19946, 20053, 65535, 65535, 65535, 65535, 23678, + 65535, 65535, 23282, 65535, 19889, 65535, 65535, 65535, 65535, 23742, + 65535, 65535, 65535, 65535, 65535, 18582, 65535, 65535, 17461, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19667, 65535, + 65535, 65535, 65535, 19365, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23743, 23744, 65535, 65535, 65535, 22356, 65535, 65535, 19482, + 65535, 19340, 65535, 65535, 65535, 65535, 15948, 15906, 65535, 65535, + 65535, 65535, 16335, 65535, 16517, 65535, 18367, 65535, 17261, 19341, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19504, + 65535, 65535, 65535, 65535, 65535, 21232, 21785, 18537, 65535, 65535, + 65535, 65535, 65535, 22158, 18225, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23679, 18787, 65535, + 15872, 19757, 23135, 65535, 65535, 65535, 65535, 65535, 22784, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16296, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16075, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21233, 65535, 22595, 20824, 65535, 65535, + 20071, 65535, 20096, 65535, 65535, 20656, 17586, 65535, 65535, 65535, + 19107, 23656, 65535, 18003, 20444, 65535, 18004, 65535, 65535, 65535, + 65535, 65535, 20692, 22729, 22605, 65535, 65535, 65535, 22716, 65535, + 65535, 65535, 65535, 65535, 22009, 65535, 65535, 65535, 65535, 65535, + 15891, 18924, 65535, 19913, 65535, 17787, 65535, 16846, 65535, 16847, + 16324, 65535, 65535, 65535, 65535, 16859, 65535, 17015, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 18024, 65535, 65535, 65535, + 65535, 65535, 65535, 22584, 65535, 65535, 65535, 14363, 65535, 65535, + 18044, 16499, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 15892, 65535, 65535, 65535, 65535, 23745, + 65535, 65535, 65535, 65535, 14364, 65535, 65535, 17278, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18005, 65535, 14767, 65535, 20863, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18973, 65535, + 23322, 65535, 65535, 65535, 65535, 65535, 65535, 14938, 65535, 20840, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14799, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18538, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 16500, 23170, 65535, 65535, 16096, 22717, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19532, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21828, 65535, 65535, 65535, 65535, 16702, 18751, 21266, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19734, 65535, 65535, 65535, 18235, + 20841, 16877, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 20237, 20238, 65535, 65535, 65535, 65535, 65535, 65535, + 23499, 20072, 65535, 65535, 65535, 65535, 19676, 17831, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20694, 65535, + 19668, 65535, 65535, 65535, 65535, 14996, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15893, 65535, 23539, 65535, 65535, 65535, 65535, 65535, + 19505, 65535, 23547, 65535, 65535, 16265, 65535, 65535, 18539, 65535, + 15698, 23129, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23145, 65535, 20636, 18402, 65535, 19677, 65535, 19726, 65535, 65535, + 21068, 65535, 65535, 65535, 65535, 65535, 21974, 65535, 14939, 19914, + 15307, 65535, 65535, 65535, 65535, 65535, 65535, 17044, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20276, 65535, 19709, 65535, 65535, + 65535, 17788, 65535, 65535, 65535, 65535, 16273, 15744, 65535, 65535, + 65535, 65535, 65535, 23146, 65535, 65535, 65535, 65535, 65535, 65535, + 17059, 65535, 13982, 65535, 65535, 65535, 65535, 65535, 65535, 17045, + 17961, 65535, 22914, 21615, 65535, 14001, 65535, 65535, 65535, 65535, + 65535, 65535, 14768, 65535, 65535, 14620, 65535, 65535, 65535, 23671, + 16063, 65535, 21408, 65535, 65535, 18598, 17427, 20445, 23117, 65535, + 65535, 23283, 15113, 65535, 65535, 17081, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16893, 65535, 18236, 65535, 65535, + 65535, 21069, 23147, 65535, 65535, 18181, 65535, 14940, 65535, 16097, + 16501, 18540, 65535, 16459, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19710, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22383, 65535, 65535, 65535, 65535, 20997, 18583, 22417, 65535, + 65535, 23323, 15308, 65535, 14603, 65535, 15309, 17462, 19711, 65535, + 21274, 14746, 19377, 65535, 65535, 16526, 15159, 17660, 22596, 65535, + 22418, 65535, 17282, 65535, 65535, 65535, 65535, 23349, 19915, 16848, + 65535, 22217, 18182, 65535, 65535, 65535, 65535, 65535, 65535, 20097, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22929, + 65535, 20073, 65535, 15522, 23324, 19507, 20240, 65535, 18045, 18717, + 16460, 65535, 19890, 65535, 19758, 19680, 65535, 65535, 21616, 23284, + 16630, 65535, 65535, 65535, 65535, 16098, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 15145, 65535, 65535, 65535, 15310, 16502, 65535, 65535, 65535, 18183, + 65535, 16247, 65535, 20695, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 16518, 65535, 65535, 65535, + 23517, 65535, 17060, 14408, 65535, 21617, 65535, 15311, 65535, 14409, + 65535, 17288, 21786, 65535, 21234, 65535, 65535, 65535, 65535, 65535, + 23492, 65535, 18541, 65535, 65535, 19290, 65535, 65535, 65535, 18584, + 65535, 65535, 65535, 18017, 65535, 18184, 65535, 65535, 65535, 65535, + 65535, 65535, 21644, 65535, 65535, 65535, 14410, 65535, 65535, 65535, + 65535, 16319, 65535, 65535, 65535, 65535, 19509, 65535, 65535, 65535, + 14747, 65535, 21787, 65535, 14629, 65535, 65535, 65535, 23325, 65535, + 22793, 22606, 65535, 65535, 19696, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19688, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20637, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17411, 65535, 65535, 14365, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21462, 65535, 65535, + 65535, 19689, 65535, 65535, 14051, 65535, 18909, 21999, 65535, 65535, + 65535, 18025, 65535, 65535, 65535, 17962, 65535, 18026, 18368, 65535, + 19891, 65535, 65535, 17428, 19892, 65535, 65535, 65535, 20998, 20241, + 14158, 18788, 65535, 65535, 65535, 15386, 20999, 65535, 21070, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 15125, 65535, 65535, 65535, 65535, 14538, 65535, 65535, 19735, + 65535, 21000, 65535, 15719, 17082, 65535, 65535, 65535, 65535, 16461, + 65535, 21618, 22204, 16894, 65535, 65535, 65535, 65535, 22915, 65535, + 65535, 16107, 23702, 65535, 65535, 65535, 17262, 65535, 65535, 65535, + 65535, 21440, 20447, 65535, 65535, 65535, 65535, 23369, 15730, 65535, + 15312, 65535, 14172, 65535, 65535, 65535, 65535, 15313, 65535, 65535, + 65535, 65535, 65535, 65535, 14173, 21409, 65535, 65535, 22010, 22916, + 65535, 65535, 18370, 18369, 65535, 20322, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17963, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14197, 65535, 65535, 65535, 65535, + 65535, 19310, 65535, 65535, 65535, 65535, 65535, 22767, 22905, 14052, + 65535, 20638, 65535, 65535, 15699, 21619, 65535, 65535, 15922, 20842, + 21645, 65535, 65535, 65535, 13983, 65535, 65535, 17412, 65535, 21463, + 65535, 65535, 65535, 65535, 65535, 20448, 65535, 65535, 65535, 65535, + 19137, 65535, 22357, 23716, 65535, 65535, 15932, 14411, 65535, 22567, + 65535, 65535, 65535, 65535, 65535, 65535, 16504, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 15710, 65535, 16631, 65535, 22358, 65535, 65535, 65535, 65535, 65535, + 17661, 65535, 14567, 65535, 65535, 65535, 19155, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19138, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18371, 65535, 65535, 65535, 65535, 65535, 19681, 21961, 21829, + 17083, 65535, 16462, 65535, 18542, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16445, 65535, 65535, 65535, 65535, + 65535, 65535, 16336, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18968, 65535, 14019, 65535, 65535, 65535, 20243, 65535, + 65535, 65535, 17289, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22359, 65535, 65535, 21022, 65535, 65535, 65535, + 65535, 15958, 65535, 65535, 18185, 65535, 65535, 65535, 19690, 65535, + 21001, 65535, 65535, 65535, 65535, 65535, 14539, 65535, 65535, 15949, + 17196, 17255, 17256, 65535, 65535, 65535, 65535, 65535, 20865, 65535, + 14198, 23518, 65535, 65535, 65535, 65535, 65535, 65535, 14800, 65535, + 14568, 65535, 65535, 23326, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22906, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22187, 65535, 65535, 65535, 65535, 16824, 65535, 65535, + 19916, 17240, 65535, 65535, 17621, 65535, 19510, 65535, 20469, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22971, 65535, 65535, 65535, + 14199, 65535, 65535, 65535, 65535, 18237, 15873, 65535, 20666, 16704, + 65535, 21620, 65535, 14053, 17084, 65535, 65535, 16297, 65535, 65535, + 65535, 65535, 65535, 65535, 16860, 65535, 65535, 65535, 16703, 65535, + 21598, 65535, 65535, 65535, 18006, 65535, 65535, 65535, 17085, 65535, + 18599, 65535, 65535, 18238, 65535, 65535, 16713, 65535, 65535, 65535, + 22530, 17027, 65535, 14020, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 21621, 65535, 16714, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23148, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14994, 16849, 65535, + 21235, 65535, 18954, 65535, 65535, 65535, 21778, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23149, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 21071, 65535, 65535, 65535, 65535, 65535, 18543, + 65535, 15894, 65535, 65535, 16861, 65535, 65535, 65535, 65535, 22011, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 15874, 65535, 65535, 65535, 65535, 14569, 19533, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21622, 65535, 65535, 65535, 65535, 65535, 16825, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 16655, 65535, 65535, 65535, 65535, 65535, 65535, 17398, 65535, 65535, + 65535, 65535, 65535, 65535, 18600, 16337, 65535, 65535, 14054, 65535, + 65535, 15923, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22000, + 14346, 65535, 65535, 14941, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22159, 65535, 65535, + 65535, 16850, 15177, 65535, 65535, 65535, 65535, 65535, 18752, 20323, + 65535, 21582, 65535, 65535, 65535, 14942, 65535, 65535, 65535, 15688, + 19730, 14801, 65535, 65535, 65535, 18165, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17832, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17662, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 21583, 21841, 22384, 65535, 65535, + 65535, 65535, 16529, 65535, 65535, 65535, 65535, 65535, 22768, 65535, + 22597, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15114, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19343, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22141, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16463, 14412, 65535, 65535, 19344, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17636, 65535, 65535, 65535, 65535, 15314, 65535, 65535, + 65535, 65535, 65535, 21072, 65535, 65535, 65535, 65535, 16307, 18989, + 18414, 65535, 65535, 17663, 65535, 65535, 65535, 65535, 65535, 19712, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14034, 65535, 65535, 65535, 17386, 65535, 18166, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23477, 23478, 16632, 65535, 65535, 65535, + 65535, 20639, 65535, 65535, 65535, 17217, 65535, 65535, 65535, 65535, + 16325, 21770, 65535, 65535, 14540, 65535, 17086, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 16633, 65535, 65535, 65535, 14413, 65535, 65535, 15315, 65535, 65535, + 65535, 65535, 65535, 14021, 65535, 65535, 65535, 65535, 65535, 17087, + 65535, 65535, 65535, 65535, 65535, 22142, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22143, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19291, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 16131, 16143, 17088, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18753, 65535, 65535, 65535, 17833, 65535, 17834, 15316, + 65535, 65535, 65535, 65535, 65535, 15317, 15318, 21584, 65535, 65535, + 65535, 65535, 65535, 65535, 19917, 65535, 65535, 65535, 65535, 65535, + 21236, 21585, 65535, 65535, 21237, 14223, 23327, 22205, 18789, 65535, + 17835, 65535, 65535, 65535, 65535, 18007, 65535, 65535, 22794, 65535, + 65535, 65535, 65535, 21199, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15319, 65535, 65535, 65535, + 65535, 16308, 65535, 15160, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23466, 21073, 17441, 65535, 19918, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19156, 23746, 65535, 65535, 18186, 65535, 65535, 65535, 16286, 65535, + 65535, 15875, 65535, 19139, 65535, 65535, 65535, 65535, 65535, 19919, + 65535, 65535, 65535, 15161, 23467, 15895, 18544, 17836, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17413, 15507, 22188, 65535, 65535, + 65535, 65535, 65535, 14726, 22144, 65535, 65535, 17664, 65535, 65535, + 17665, 65535, 65535, 65535, 65535, 65535, 65535, 21238, 65535, 65535, + 65535, 65535, 22388, 65535, 21623, 18980, 65535, 21646, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20450, 65535, 65535, 65535, 65535, + 23747, 65535, 65535, 65535, 65535, 18345, 65535, 65535, 14022, 65535, + 65535, 21074, 65535, 22145, 65535, 65535, 65535, 65535, 65535, 65535, + 20514, 65535, 65535, 22718, 65535, 21599, 22360, 65535, 16485, 65535, + 65535, 22897, 21239, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21275, 65535, 65535, 22389, + 65535, 65535, 65535, 65535, 19938, 21600, 65535, 65535, 65535, 15876, + 13984, 14541, 65535, 14570, 14593, 65535, 65535, 65535, 65535, 65535, + 16862, 65535, 65535, 22361, 65535, 65535, 65535, 20866, 19511, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18545, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18021, 19534, 65535, + 65535, 65535, 65535, 65535, 65535, 19682, 65535, 23479, 65535, 65535, + 65535, 65535, 19140, 65535, 65535, 65535, 23160, 65535, 14943, 65535, + 65535, 14981, 14621, 65535, 65535, 21075, 65535, 21975, 65535, 15910, + 65535, 65535, 21779, 65535, 65535, 65535, 19856, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21647, 21830, 65535, 21240, + 65535, 65535, 14970, 65535, 65535, 65535, 65535, 65535, 65535, 14978, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19697, + 19698, 65535, 65535, 65535, 14982, 19857, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15115, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21788, 15116, 65535, 15933, + 65535, 65535, 21023, 16626, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16878, 65535, 21810, 65535, 65535, + 65535, 17414, 65535, 14414, 20696, 65535, 65535, 21441, 65535, 15924, + 65535, 65535, 65535, 65535, 18546, 65535, 65535, 14035, 65535, 15689, + 65535, 65535, 65535, 65535, 65535, 65535, 14415, 65535, 65535, 21426, + 22206, 65535, 65535, 65535, 65535, 14023, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23353, 65535, 18372, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18028, 65535, 20867, 65535, 65535, 22549, 65535, 16627, 65535, + 65535, 65535, 65535, 65535, 17587, 65535, 65535, 65535, 65535, 65535, + 21200, 16274, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18346, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22917, 65535, 65535, 15950, + 65535, 15146, 21002, 18601, 65535, 17269, 14769, 22207, 22568, 65535, + 15720, 65535, 21849, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15126, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18239, 65535, 18046, 65535, 65535, 65535, + 65535, 65535, 65535, 19346, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19669, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14200, 65535, 65535, 65535, 21003, 65535, 65535, 65535, 20825, + 65535, 65535, 65535, 65535, 17061, 15320, 65535, 17964, 65535, 65535, + 21771, 65535, 65535, 14381, 65535, 65535, 65535, 14748, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21004, + 65535, 65535, 65535, 18008, 65535, 65535, 20670, 65535, 65535, 65535, + 20843, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21024, 23519, + 65535, 65535, 17279, 65535, 21005, 22730, 65535, 22208, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 18772, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18373, 65535, 65535, 65535, 15896, 65535, 65535, 65535, 65535, 17837, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21259, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21789, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15690, 65535, 65535, 14024, 65535, 65535, 65535, 65535, + 65535, 23520, 65535, 65535, 20671, 18374, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22001, 16264, 17588, 65535, 65535, 65535, 16085, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21410, 20868, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16320, 65535, + 65535, 65535, 22002, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 16505, 65535, 65535, 65535, 65535, 65535, 65535, 17028, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 17666, 65535, 65535, 65535, 65535, 65535, 17622, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16628, 65535, + 65535, 17062, 65535, 21241, 21031, 65535, 65535, 65535, 65535, 65535, + 65535, 18391, 65535, 65535, 65535, 65535, 65535, 21427, 65535, 20697, + 65535, 65535, 65535, 65535, 65535, 65535, 16114, 65535, 65535, 16115, + 21791, 14210, 65535, 65535, 65535, 65535, 65535, 18547, 65535, 65535, + 65535, 65535, 21076, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23328, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15731, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17623, 21242, 14174, 65535, 65535, 65535, + 65535, 65535, 65535, 16116, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14542, 65535, 65535, 15117, 65535, 15321, 65535, + 21411, 65535, 19114, 23360, 19920, 23719, 23493, 65535, 17007, 17008, + 65535, 15486, 65535, 65535, 15564, 65535, 65535, 65535, 18602, 65535, + 65535, 17838, 14785, 21586, 15173, 17624, 65535, 65535, 65535, 65535, + 18375, 17218, 18022, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20640, 21412, 65535, 21802, 16446, 18347, 65535, 65535, 18790, + 65535, 20844, 65535, 65535, 65535, 18376, 14055, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21276, 23150, 21243, 14416, 17089, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14376, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 14802, 65535, 65535, 16064, 23151, 65535, 65535, 65535, + 15174, 65535, 20289, 65535, 20488, 65535, 65535, 65535, 18047, 65535, + 65535, 22569, 17839, 14175, 65535, 65535, 21025, 65535, 65535, 14366, + 65535, 65535, 65535, 65535, 65535, 14944, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21077, 18548, 65535, 65535, 65535, 14417, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21277, 65535, 65535, 65535, 16309, 65535, + 21413, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18549, 20246, 65535, 65535, 65535, 14176, 16674, 65535, 21991, 21842, + 65535, 65535, 16473, 65535, 15322, 22525, 65535, 20657, 16486, 16715, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22362, 65535, 65535, + 15339, 17667, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18048, 65535, 22964, 65535, 18187, 65535, 65535, 21658, + 15691, 65535, 22028, 17046, 65535, 19347, 65535, 65535, 65535, 65535, + 22731, 19713, 65535, 65535, 16716, 65535, 65535, 20098, 65535, 65535, + 65535, 65535, 16248, 65535, 65535, 65535, 65535, 65535, 65535, 22363, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 21624, 18997, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19683, 65535, 65535, 65535, 65535, + 65535, 17063, 65535, 21625, 23329, 19873, 65535, 20818, 65535, 23152, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17463, 65535, 65535, + 22209, 19349, 65535, 21278, 65535, 65535, 65535, 65535, 65535, 16447, + 65535, 65535, 65535, 65535, 65535, 22172, 20869, 65535, 65535, 17264, + 65535, 17637, 65535, 65535, 16895, 19858, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21464, 65535, 21601, 18188, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19859, 65535, + 65535, 18550, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18732, + 23540, 14543, 65535, 14367, 65535, 65535, 21244, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19311, 65535, 65535, 14544, 65535, + 65535, 65535, 65535, 65535, 21790, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18392, 65535, 65535, 21006, 65535, 65535, + 65535, 19512, 65535, 65535, 18218, 65535, 21792, 65535, 65535, 15897, + 16086, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17589, 65535, 22987, 65535, + 14377, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19097, 65535, + 65535, 65535, 14749, 65535, 65535, 65535, 16675, 22949, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21385, 14774, + 65535, 65535, 22364, 65535, 17270, 65535, 18049, 65535, 65535, 16690, + 65535, 22598, 65535, 16506, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 15959, 65535, 65535, 15323, 65535, + 19142, 65535, 14177, 65535, 17029, 65535, 65535, 65535, 65535, 65535, + 14571, 65535, 65535, 65535, 65535, 65535, 16275, 65535, 65535, 65535, + 18551, 65535, 65535, 65535, 65535, 65535, 14971, 65535, 65535, 65535, + 18189, 20324, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23748, 65535, 65535, 65535, 65535, 65535, 16507, 14211, 65535, 65535, + 65535, 19921, 65535, 65535, 65535, 19691, 65535, 65535, 65535, 18754, + 65535, 65535, 65535, 65535, 20470, 65535, 20471, 65535, 16276, 65535, + 65535, 65535, 18722, 65535, 18009, 23727, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20870, 22333, 17668, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22732, 65535, 19714, 65535, 65535, + 65535, 65535, 22950, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14803, 65535, 65535, 20472, 65535, 65535, 65535, 19860, 16298, + 65535, 14572, 65535, 20641, 15324, 65535, 65535, 14945, 65535, 65535, + 20452, 65535, 65535, 65535, 15502, 65535, 65535, 65535, 65535, 14418, + 65535, 16851, 19947, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 15325, 65535, 65535, 65535, 65535, 65535, 20453, + 65535, 65535, 19108, 65535, 65535, 65535, 65535, 65535, 65535, 22531, + 65535, 14419, 65535, 65535, 65535, 15711, 65535, 65535, 16277, 65535, + 65535, 65535, 16338, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18336, 65535, 17794, 65535, 22334, 65535, + 65535, 65535, 17009, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16249, + 22173, 65535, 18337, 19893, 65535, 65535, 65535, 21602, 65535, 65535, + 65535, 65535, 65535, 22018, 16321, 20286, 65535, 65535, 65535, 65535, + 20454, 18585, 17840, 21245, 65535, 20266, 65535, 16481, 15326, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22146, 65535, + 65535, 65535, 65535, 22988, 65535, 14025, 65535, 65535, 65535, 14573, + 21587, 65535, 65535, 17669, 65535, 65535, 65535, 14368, 17219, 65535, + 65535, 65535, 65535, 15178, 65535, 14786, 20267, 65535, 23657, 65535, + 65535, 65535, 65535, 65535, 22748, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 20099, 21391, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17241, 65535, 22550, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17242, 14159, 65535, 65535, + 22769, 65535, 65535, 23330, 65535, 65535, 20277, 18146, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14770, + 65535, 65535, 15925, 65535, 65535, 65535, 23711, 65535, 65535, 65535, + 65535, 15571, 65535, 65535, 65535, 65535, 21588, 65535, 65535, 23171, + 22335, 23172, 16695, 65535, 21962, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19715, 65535, + 14002, 14420, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18603, + 65535, 65535, 65535, 65535, 65535, 18552, 65535, 22528, 65535, 65535, + 65535, 22770, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21831, 65535, 65535, 65535, 65535, 17766, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18998, + 65535, 65535, 18791, 65535, 17590, 17591, 65535, 65535, 14178, 19716, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18338, 15549, 65535, 65535, 65535, + 65535, 21279, 65535, 65535, 65535, 65535, 19861, 14237, 65535, 65535, + 65535, 65535, 65535, 65535, 20698, 17442, 18190, 65535, 65535, 65535, + 65535, 22573, 17220, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14359, 65535, 17064, 65535, 65535, 65535, 65535, 14574, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17592, 65535, + 16640, 18718, 65535, 65535, 14804, 65535, 65535, 21648, 65535, 65535, + 65535, 65535, 22724, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18191, 65535, 22228, 65535, 65535, 65535, 65535, + 20311, 65535, 65535, 15712, 23541, 15544, 15940, 65535, 17767, 65535, + 65535, 65535, 19165, 65535, 65535, 65535, 65535, 65535, 65535, 21201, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 16091, 65535, 65535, 65535, 65535, 65535, 65535, 20699, 65535, 65535, + 65535, 18792, 65535, 19699, 65535, 20700, 16527, 65535, 20642, 65535, + 65535, 22336, 65535, 65535, 65535, 65535, 65535, 21589, 22365, 65535, + 65535, 65535, 65535, 65535, 15745, 21626, 14946, 65535, 20247, 65535, + 65535, 65535, 65535, 65535, 65535, 14947, 65535, 19293, 23728, 65535, + 14948, 65535, 18208, 17841, 65535, 65535, 65535, 65535, 18147, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21976, 18604, 65535, + 16896, 21414, 65535, 14179, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22989, 17221, 17090, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22401, 17065, 23153, 65535, 18192, 65535, 65535, + 65535, 65535, 65535, 65535, 17593, 65535, 65535, 65535, 65535, 19294, + 65535, 21078, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21832, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 20325, 65535, 22965, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14026, 16117, 65535, 14027, 18023, 65535, 65535, 65535, 19378, 65535, + 22147, 65535, 65535, 65535, 65535, 65535, 18990, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19922, + 65535, 20658, 14983, 65535, 65535, 65535, 16676, 65535, 65535, 65535, + 65535, 65535, 65535, 17594, 15941, 65535, 65535, 21590, 65535, 17978, + 65535, 65535, 65535, 65535, 65535, 14201, 23331, 65535, 65535, 15162, + 65535, 65535, 17625, 22599, 19535, 18910, 65535, 23468, 65535, 17222, + 65535, 65535, 65535, 21591, 19948, 15147, 65535, 22189, 16852, 18925, + 65535, 20622, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20074, + 19379, 65535, 22551, 22148, 65535, 16879, 65535, 65535, 65535, 13985, + 65535, 65535, 22771, 14949, 65535, 20455, 65535, 65535, 65535, 19115, + 14575, 20845, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19515, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14576, 22918, 65535, 65535, 21447, 16897, 17280, + 13986, 16853, 65535, 65535, 65535, 16666, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16826, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 20643, 65535, 65535, 16677, + 65535, 65535, 65535, 17443, 65535, 18553, 65535, 65535, 23542, 20489, + 15579, 65535, 19894, 19295, 65535, 65535, 65535, 65535, 65535, 65535, + 18605, 65535, 65535, 65535, 65535, 65535, 65535, 23112, 65535, 22149, + 23285, 65535, 65535, 65535, 65535, 20516, 65535, 20456, 23521, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 15934, 65535, 65535, 65535, 22930, 65535, 65535, 65535, 20871, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 16508, 20701, 65535, 65535, 65535, 17842, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14421, 65535, 18793, 65535, + 65535, 65535, 65535, 65535, 19717, 65535, 65535, 65535, 23173, 65535, + 65535, 65535, 65535, 65535, 65535, 17595, 18926, 16641, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16678, 65535, 65535, 65535, 22019, + 65535, 65535, 65535, 14750, 65535, 65535, 65535, 16310, 14965, 65535, + 15127, 65535, 65535, 65535, 65535, 65535, 65535, 14727, 65535, 65535, + 21833, 65535, 65535, 65535, 65535, 65535, 21843, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17429, + 65535, 15148, 65535, 65535, 65535, 23469, 14577, 16487, 17768, 65535, + 18969, 65535, 65535, 65535, 65535, 20846, 65535, 65535, 65535, 18586, + 65535, 65535, 65535, 65535, 65535, 22229, 15877, 65535, 65535, 65535, + 65535, 65535, 16104, 65535, 16705, 22740, 20100, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22190, 65535, 65535, 16656, 65535, 65535, 65535, + 65535, 23687, 65535, 65535, 65535, 65535, 65535, 65535, 20248, 65535, + 65535, 65535, 65535, 16065, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19483, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20847, + 65535, 65535, 65535, 14036, 65535, 65535, 65535, 65535, 65535, 22772, + 65535, 15926, 65535, 65535, 20101, 65535, 65535, 65535, 65535, 23332, + 20702, 65535, 65535, 19116, 65535, 65535, 65535, 65535, 65535, 15118, + 65535, 65535, 65535, 65535, 21456, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 18554, 65535, 65535, 65535, + 18755, 65535, 65535, 65535, 65535, 16868, 65535, 65535, 17965, 65535, + 65535, 65535, 65535, 17223, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22773, 65535, 65535, 65535, 65535, 65535, 21465, 65535, 65535, 19117, + 21834, 65535, 65535, 23333, 18399, 65535, 16827, 65535, 22210, 65535, + 18167, 65535, 65535, 19895, 65535, 14202, 65535, 18756, 65535, 65535, + 65535, 17843, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18555, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17464, 65535, + 16250, 65535, 65535, 65535, 65535, 65535, 18606, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16339, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16816, 65535, 16657, 17444, 65535, + 65535, 20644, 17979, 65535, 20050, 65535, 65535, 65535, 16448, 65535, + 65535, 21844, 65535, 20703, 65535, 22174, 65535, 65535, 65535, 65535, + 65535, 65535, 18377, 20302, 65535, 21627, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22749, + 65535, 20102, 65535, 15713, 65535, 17265, 65535, 65535, 65535, 65535, + 65535, 22150, 65535, 65535, 65535, 65535, 14805, 65535, 65535, 65535, + 65535, 19949, 65535, 65535, 65535, 65535, 65535, 23297, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18607, 65535, 65535, + 65535, 65535, 14997, 22540, 16898, 65535, 65535, 18378, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17066, 65535, 65535, 17030, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20326, 65535, 14180, 65535, 65535, 20704, 65535, 65535, 65535, + 65535, 65535, 65535, 18209, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21977, 65535, 23683, 17972, 18794, 65535, + 65535, 65535, 65535, 18148, 23680, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21202, 65535, 65535, 65535, 65535, 65535, + 65535, 14578, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20645, + 65535, 65535, 65535, 16087, 18795, 20705, 65535, 65535, 65535, 65535, + 65535, 19923, 65535, 65535, 65535, 65535, 65535, 65535, 16132, 19536, + 65535, 65535, 65535, 65535, 65535, 65535, 15951, 19118, 65535, 65535, + 65535, 17266, 18556, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20848, 65535, 65535, 16519, 21246, + 65535, 65535, 65535, 14736, 65535, 65535, 19537, 65535, 65535, 65535, + 16299, 18379, 65535, 65535, 19684, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19173, 17387, 65535, 65535, + 18193, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16076, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16056, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23334, 65535, 22938, 65535, 65535, 65535, 14238, 21950, + 65535, 65535, 65535, 65535, 65535, 23125, 16300, 65535, 19924, 23335, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23703, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23361, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17010, 65535, 17224, 65535, 65535, 65535, 65535, 65535, + 65535, 20491, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14622, 21247, 65535, + 65535, 65535, 65535, 22366, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 17844, 65535, 65535, 65535, 15692, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 23543, 65535, 65535, 65535, + 65535, 19700, 65535, 21415, 65535, 65535, 65535, 14806, 65535, 65535, + 65535, 65535, 22972, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21649, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18927, 65535, + 22160, 65535, 17465, 18796, 65535, 65535, 65535, 65535, 19670, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21592, 65535, 17769, 65535, 17049, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14038, 65535, 65535, 65535, + 65535, 65535, 65535, 18773, 65535, 23522, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 20103, 65535, 65535, 65535, 65535, 65535, 65535, + 22931, 65535, 18719, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23336, 65535, 21037, 65535, 19701, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16099, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20290, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16828, 65535, 65535, + 23286, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15732, 65535, 65535, + 65535, 65535, 65535, 65535, 16057, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22387, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 17091, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18194, 65535, 65535, 19863, 65535, 65535, + 22224, 65535, 65535, 65535, 65535, 65535, 65535, 23100, 65535, 20327, + 65535, 65535, 18219, 65535, 65535, 65535, 65535, 65535, 65535, 18733, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16092, 65535, 65535, 21442, 16133, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14579, 65535, 65535, 65535, 65535, 20672, 65535, + 65535, 65535, 65535, 16658, 65535, 65535, 65535, 65535, 23161, 65535, + 65535, 65535, 65535, 65535, 21450, 65535, 65535, 65535, 65535, 65535, + 23113, 19351, 65535, 65535, 65535, 65535, 23154, 18615, 65535, 65535, + 65535, 13987, 65535, 18928, 65535, 20104, 65535, 22225, 65535, 65535, + 65535, 23287, 14950, 20328, 65535, 65535, 65535, 65535, 22795, 65535, + 65535, 17980, 65535, 65535, 65535, 65535, 18416, 65535, 15489, 65535, + 65535, 65535, 65535, 22226, 65535, 65535, 65535, 65535, 65535, 65535, + 15163, 15164, 65535, 20075, 16832, 65535, 65535, 65535, 65535, 65535, + 13988, 65535, 65535, 15746, 65535, 22774, 65535, 65535, 65535, 65535, + 15693, 65535, 65535, 65535, 18557, 21628, 65535, 65535, 65535, 65535, + 65535, 65535, 14604, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22907, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14580, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20819, 16259, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 16509, 65535, 65535, 65535, 65535, 19539, 20249, 65535, 65535, + 65535, 14972, 65535, 65535, 17430, 20706, 65535, 17845, 65535, 16510, + 65535, 65535, 65535, 65535, 65535, 65535, 17770, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18010, 17243, 17244, + 65535, 65535, 16058, 65535, 65535, 65535, 65535, 21203, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17445, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14037, 65535, 22775, 17431, + 65535, 65535, 65535, 65535, 20105, 17245, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19874, 65535, 65535, + 65535, 65535, 22574, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18723, 65535, 16449, 65535, 65535, 18210, + 65535, 65535, 65535, 65535, 65535, 14181, 65535, 65535, 19144, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 15165, 65535, 65535, 65535, 65535, + 16088, 65535, 65535, 65535, 65535, 65535, 16667, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18724, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18149, 65535, 19864, + 65535, 15714, 65535, 65535, 17446, 22719, 65535, 65535, 65535, 14369, + 65535, 65535, 65535, 15119, 65535, 65535, 65535, 16707, 65535, 65535, + 18757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14360, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15878, + 22374, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15149, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14003, 65535, 65535, 16089, + 65535, 65535, 14751, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14004, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23101, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 18011, 65535, 65535, 65535, 22161, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19170, 65535, 21079, 17596, + 65535, 65535, 65535, 65535, 14545, 65535, 18797, 65535, 23362, 65535, + 22563, 65535, 65535, 65535, 65535, 23681, 65535, 65535, 23720, 22419, + 15327, 65535, 65535, 19702, 65535, 18929, 65535, 18407, 65535, 65535, + 65535, 14378, 65535, 15562, 65535, 65535, 65535, 65535, 17225, 65535, + 65535, 18211, 65535, 65535, 65535, 23126, 65535, 65535, 18380, 65535, + 13989, 65535, 65535, 65535, 21629, 21416, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17846, 65535, 65535, 65535, + 21248, 22741, 65535, 65535, 65535, 65535, 65535, 20849, 65535, 65535, + 17847, 65535, 19516, 65535, 18608, 19540, 65535, 65535, 18758, 65535, + 65535, 18759, 65535, 65535, 65535, 15003, 21007, 65535, 23749, 23470, + 23102, 18012, 65535, 18195, 65535, 65535, 65535, 22003, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21417, + 65535, 14728, 65535, 65535, 65535, 65535, 21593, 20492, 65535, 65535, + 65535, 65535, 65535, 18150, 65535, 22526, 65535, 65535, 20250, 65535, + 65535, 65535, 65535, 65535, 19157, 65535, 18339, 14546, 65535, 16899, + 19671, 14581, 18408, 65535, 23544, 65535, 18212, 65535, 65535, 65535, + 65535, 65535, 18558, 65535, 14729, 65535, 65535, 65535, 65535, 65535, + 65535, 17771, 65535, 65535, 20329, 65535, 20296, 21249, 65535, 65535, + 22004, 65535, 18609, 65535, 65535, 15715, 65535, 65535, 65535, 22020, + 65535, 20826, 65535, 22191, 65535, 65535, 16118, 65535, 65535, 65535, + 16314, 65535, 65535, 65535, 65535, 20251, 22012, 65535, 65535, 65535, + 65535, 18760, 65535, 65535, 65535, 65535, 22029, 23103, 65535, 65535, + 21080, 14028, 65535, 20252, 20646, 65535, 65535, 23696, 65535, 65535, + 65535, 65535, 18911, 22899, 21204, 65535, 19171, 65535, 65535, 65535, + 15366, 65535, 16854, 18960, 20106, 65535, 15952, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17031, 65535, 17050, 65535, + 65535, 65535, 22939, 65535, 18393, 17226, 65535, 14382, 20473, 14182, + 65535, 17848, 65535, 65535, 19865, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 16855, 65535, 65535, 20872, 16464, 65535, 65535, 65535, + 65535, 65535, 65535, 14951, 65535, 65535, 65535, 65535, 65535, 15150, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23471, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 21466, 65535, 65535, 65535, 65535, + 23705, 15328, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18774, 65535, 15716, 65535, 17432, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14422, 65535, 65535, 65535, 65535, 65535, + 17772, 65535, 65535, 19312, 20426, 65535, 65535, 65535, 14370, 65535, + 65535, 23337, 65535, 65535, 65535, 65535, 65535, 19541, 65535, 65535, + 15898, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17393, 65535, 65535, 65535, 65535, 65535, 18559, 65535, 21811, 19146, + 65535, 65535, 21812, 65535, 65535, 65535, 21793, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14594, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14547, 65535, 23500, 65535, 65535, 65535, 65535, + 15936, 65535, 15329, 65535, 22900, 65535, 19718, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18761, 65535, 65535, 65535, 65535, + 15907, 65535, 65535, 65535, 65535, 65535, 65535, 18013, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 23338, 19542, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22796, 18762, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22151, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16696, 65535, + 16856, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22720, 21081, 65535, + 17597, 20820, 14623, 65535, 65535, 65535, 65535, 17789, 23472, 22607, + 22532, 14752, 21946, 65535, 65535, 20850, 18349, 65535, 65535, 20460, + 15009, 65535, 22736, 16691, 15747, 65535, 65535, 17773, 22013, 20459, + 65535, 16900, 22932, 17626, 16326, 20517, 23545, 65535, 65535, 20647, + 13990, 65535, 20873, 65535, 65535, 65535, 65535, 65535, 65535, 21630, + 65535, 17790, 65535, 65535, 65535, 65535, 65535, 65535, 16327, 65535, + 17849, 65535, 18014, 65535, 17246, 65535, 23156, 16692, 21978, 65535, + 17598, 65535, 65535, 65535, 21650, 65535, 65535, 15879, 65535, 65535, + 65535, 65535, 65535, 65535, 16328, 65535, 65535, 65535, 65535, 65535, + 65535, 17599, 14952, 18018, 65535, 65535, 65535, 65535, 65535, 65535, + 21595, 22326, 65535, 20278, 21467, 65535, 21794, 65535, 65535, 18220, + 65535, 65535, 65535, 65535, 65535, 20707, 65535, 65535, 18394, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 20874, 65535, 17850, 65535, 65535, 65535, 65535, 23136, + 65535, 65535, 65535, 65535, 21418, 65535, 65535, 15120, 17600, 65535, + 65535, 15330, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22152, 65535, 65535, 65535, 65535, + 20083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 21250, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22337, 65535, 65535, 65535, 65535, + 22192, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21260, 65535, 65535, 65535, 65535, 65535, 65535, 17601, 65535, + 65535, 65535, 21596, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22552, 65535, 65535, 65535, 65535, 17197, 21651, 65535, 65535, 13991, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 22600, 65535, 14224, 65535, 65535, 65535, 20875, 65535, 18196, + 65535, 65535, 65535, 65535, 14730, 65535, 65535, 65535, 65535, 65535, + 65535, 16301, 65535, 65535, 65535, 15880, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19896, 65535, + 65535, 65535, 65535, 15721, 21979, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14225, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21376, 65535, 65535, 65535, 65535, 65535, 20253, 65535, 65535, 65535, + 65535, 21377, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 20254, 65535, 21205, 65535, 65535, 14239, + 15881, 21773, 23298, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22211, 65535, 65535, + 65535, 65535, 65535, 20876, 21963, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22212, 65535, 14998, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21251, 65535, 65535, + 65535, 65535, 65535, 20851, 65535, 65535, 21419, 65535, 65535, 19119, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16520, 18798, + 14984, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14953, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21774, 18961, 15004, 14973, 65535, 65535, 65535, 65535, 23130, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19352, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 21631, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22213, 65535, 65535, 13992, + 65535, 65535, 18775, 65535, 65535, 65535, 65535, 14807, 65535, 16302, + 65535, 65535, 65535, 20821, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22014, 16659, 17433, 14423, 65535, 65535, 65535, 65535, + 65535, 16119, 22367, 23697, 16679, 21992, 65535, 65535, 65535, 65535, + 65535, 65535, 16251, 17415, 65535, 17247, 16474, 65535, 65535, 65535, + 65535, 21659, 65535, 65535, 65535, 21420, 65535, 65535, 65535, 65535, + 18560, 17447, 65535, 17448, 65535, 65535, 21008, 19296, 65535, 65535, + 65535, 65535, 22956, 20076, 65535, 65535, 65535, 21009, 65535, 65535, + 65535, 21993, 14808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19297, 65535, 14787, + 65535, 65535, 16144, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18799, + 14583, 65535, 65535, 65535, 65535, 65535, 65535, 16079, 65535, 65535, + 22608, 65535, 17394, 65535, 65535, 65535, 65535, 17851, 65535, 17395, + 21632, 19875, 15545, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19925, 65535, + 65535, 18801, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19517, 65535, 65535, 15151, 65535, 65535, 17092, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 13993, 65535, 65535, 65535, 20877, 17067, + 65535, 21652, 65535, 65535, 18616, 65535, 14351, 65535, 65535, 65535, + 65535, 17032, 65535, 20878, 65535, 65535, 65535, 22193, 65535, 65535, + 22575, 18409, 14758, 15882, 65535, 23672, 19314, 65535, 23288, 65535, + 65535, 22776, 65535, 18381, 65535, 22581, 22214, 14954, 65535, 65535, + 15883, 14424, 65535, 15937, 65535, 20852, 22570, 65535, 65535, 18151, + 16278, 18395, 21252, 21443, 17466, 16252, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 22030, 65535, 65535, 21421, + 21633, 65535, 65535, 15121, 65535, 65535, 20504, 65535, 65535, 65535, + 22921, 65535, 20256, 65535, 65535, 15942, 18561, 65535, 65535, 65535, + 65535, 19926, 65535, 65535, 20255, 20046, 65535, 22733, 14731, 65535, + 22933, 23523, 65535, 15884, 15700, 20107, 65535, 65535, 65535, 19866, + 65535, 65535, 18400, 15722, 22031, 65535, 20077, 18382, 65535, 14371, + 65535, 65535, 65535, 65535, 65535, 20879, 65535, 65535, 65535, 21253, + 21775, 15943, 65535, 65535, 21597, 65535, 65535, 21444, 65535, 21980, + 18197, 65535, 20257, 65535, 16436, 14227, 65535, 22908, 19868, 16693, + 23104, 18562, 23494, 65535, 65535, 20461, 16642, 65535, 17396, 65535, + 65535, 65535, 65535, 16059, 65535, 20308, 65535, 65535, 65535, 19692, + 65535, 65535, 65535, 16680, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23289, 15360, 65535, 65535, 17227, 65535, 22165, 65535, + 17852, 65535, 65535, 65535, 65535, 14056, 22553, 14955, 65535, 65535, + 65535, 18383, 65535, 65535, 20853, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19939, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 14809, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 16100, 65535, 65535, 14974, 65535, 65535, 65535, 65535, + 65535, 65535, 17602, 65535, 65535, 65535, 65535, 14737, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19927, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 15885, 65535, 65535, 65535, 65535, 18944, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22194, 65535, 65535, 23118, 65535, 65535, + 65535, 17774, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 15953, 65535, 65535, 65535, 65535, + 65535, 21082, 65535, 65535, 65535, 65535, 15694, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20258, + 21083, 22195, 20659, 17248, 21422, 65535, 65535, 65535, 21423, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22153, 65535, 65535, 65535, 65535, 65535, + 65535, 16829, 16067, 65535, 18563, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23658, 65535, 23344, 17966, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18610, 65535, 22338, 65535, 22154, 65535, 21206, 65535, 65535, + 65535, 65535, 18340, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22196, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20427, 20708, 65535, + 22155, 23299, 65535, 17198, 65535, 65535, 16287, 14212, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19147, 65535, + 65535, 65535, 65535, 65535, 65535, 21845, 65535, 20259, 65535, 18168, + 16511, 21451, 19110, 16120, 16512, 15344, 65535, 65535, 65535, 65535, + 65535, 18417, 21084, 65535, 65535, 65535, 17603, 22385, 65535, 65535, + 65535, 65535, 65535, 21254, 65535, 65535, 65535, 21981, 65535, 65535, + 19928, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21846, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 15944, 65535, 65535, 14347, 22609, + 17983, 65535, 65535, 65535, 65535, 20280, 65535, 65535, 65535, 65535, + 65535, 65535, 15128, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 16279, 65535, 65535, 65535, 65535, 65535, + 19678, 65535, 65535, 65535, 65535, 21010, 14160, 65535, 65535, 65535, + 65535, 14228, 65535, 65535, 65535, 23157, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14383, + 65535, 65535, 65535, 19356, 65535, 65535, 20084, 65535, 65535, 65535, + 17199, 65535, 14956, 18617, 21085, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 20297, 65535, 65535, 22175, 65535, 15927, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18198, 65535, 21011, + 65535, 65535, 18564, 65535, 16830, 65535, 65535, 65535, 22966, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19544, 65535, 65535, 14957, 18384, 65535, 18565, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21086, 65535, 65535, 23174, + 65535, 65535, 17467, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 18152, 65535, 65535, 65535, 65535, 65535, 22777, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14229, 65535, 65535, 65535, 14183, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 16311, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22197, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 22198, 65535, 20827, 65535, 65535, 65535, 18611, 15717, + 21087, 15331, 21012, 65535, 15332, 65535, 15167, 65535, 16880, 65535, + 65535, 18169, 65535, 65535, 14584, 21780, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19519, 65535, 16253, 14732, 65535, 15886, 65535, 65535, 65535, 65535, + 65535, 65535, 18945, 65535, 65535, 65535, 65535, 65535, 65535, 15695, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20260, 65535, + 65535, 65535, 65535, 65535, 65535, 14240, 65535, 65535, 65535, 65535, + 65535, 65535, 22386, 65535, 21378, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14384, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19897, 65535, 18415, 65535, + 65535, 65535, 22199, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23290, 65535, 65535, 65535, 14204, 65535, 65535, 65535, 65535, + 23339, 21634, 65535, 65535, 20505, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 21261, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20880, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19898, 65535, 65535, 14425, 65535, 65535, 16450, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21756, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23550, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21379, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18199, 65535, 65535, 65535, 65535, 65535, 21013, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21994, 65535, 65535, + 22516, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 21424, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14057, 14058, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14771, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21795, + 65535, 21781, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20709, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17011, 65535, 65535, 18221, 65535, 65535, + 65535, 65535, 65535, 22750, 65535, 14205, 65535, 65535, 65535, 20281, + 65535, 22951, 22952, 14029, 17047, 65535, 65535, 65535, 14161, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14005, + 22973, 17271, 65535, 65535, 15122, 65535, 65535, 65535, 65535, 16134, + 65535, 65535, 65535, 19368, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19477, 18962, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18970, 65535, 65535, 23501, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22974, 14999, + 22585, 65535, 65535, 65535, 65535, 65535, 14753, 65535, 65535, 65535, + 65535, 21982, 17388, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 17604, 65535, 65535, 65535, 65535, 21983, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 22706, 65535, 65535, 65535, 19719, 65535, + 65535, 65535, 17228, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21255, 65535, 65535, 65535, 18930, 22402, 65535, 22909, 65535, + 17605, 65535, 65535, 65535, 65535, 65535, 65535, 16451, 16697, 14184, + 65535, 65535, 22953, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 22751, 22975, 18222, 18734, 21964, 65535, 65535, + 20079, 21635, 21207, 65535, 65535, 65535, 65535, 65535, 17249, 65535, + 65535, 65535, 65535, 65535, 20303, 65535, 65535, 21636, 65535, 16488, + 15887, 22967, 16468, 65535, 65535, 65535, 65535, 19148, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19929, 16479, 65535, 65535, 65535, + 15748, 18566, 65535, 23524, 14548, 65535, 65535, 65535, 65535, 65535, + 14361, 20047, 65535, 65535, 18991, 15137, 65535, 21208, 20806, 65535, + 65535, 65535, 65535, 65535, 65535, 16521, 65535, 65535, 65535, 18567, + 18568, 65535, 23132, 65535, 65535, 65535, 65535, 65535, 65535, 20298, + 65535, 65535, 65535, 65535, 65535, 16288, 65535, 65535, 65535, 21965, + 65535, 65535, 65535, 65535, 20660, 18955, 65535, 65535, 20054, 18931, + 21757, 14585, 65535, 22368, 65535, 21445, 20648, 19693, 20854, 65535, + 65535, 65535, 65535, 65535, 65535, 21256, 18569, 65535, 65535, 18915, + 65535, 22200, 20673, 65535, 65535, 65535, 65535, 65535, 16513, 15376, + 65535, 65535, 65535, 65535, 19930, 19931, 18213, 65535, 65535, 65535, + 65535, 17012, 17627, 65535, 20048, 65535, 65535, 65535, 16280, 16329, + 65535, 17068, 65535, 21014, 65535, 65535, 65535, 65535, 18570, 65535, + 65535, 65535, 65535, 65535, 21088, 21637, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 21032, 65535, 19546, 65535, 65535, + 16528, 65535, 65535, 19521, 65535, 65535, 18015, 65535, 22934, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16901, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 17967, 65535, 16303, 65535, + 65535, 65535, 65535, 65535, 65535, 17389, 65535, 65535, 65535, 21209, + 65535, 65535, 65535, 65535, 16145, 65535, 18992, 65535, 65535, 65535, + 16281, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22021, + 65535, 65535, 65535, 65535, 21089, 65535, 65535, 65535, 65535, 65535, + 21186, 65535, 17775, 65535, 65535, 17033, 16717, 65535, 65535, 65535, + 65535, 65535, 65535, 23137, 65535, 65535, 65535, 20494, 65535, 65535, + 65535, 65535, 65535, 65535, 23473, 65535, 65535, 20495, 65535, 65535, + 16668, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23300, 65535, 18956, + 65535, 14624, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14966, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 14039, 65535, 65535, 14967, + 65535, 22734, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 21984, 65535, 65535, 65535, + 65535, 20108, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22954, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15888, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20304, 65535, 65535, 18385, 65535, 65535, 65535, 65535, 20049, + 65535, 65535, 65535, 23119, 23340, 23162, 21187, 14426, 65535, 23088, + 18612, 65535, 18571, 65535, 19940, 65535, 18410, 65535, 65535, 65535, + 19547, 19720, 17093, 15908, 65535, 65535, 65535, 22601, 16282, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15938, + 65535, 65535, 23175, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14427, 22576, 65535, 17791, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14733, 65535, 65535, 65535, 65535, 65535, + 21210, 18999, 18946, 65535, 65535, 65535, 65535, 65535, 18957, 65535, + 65535, 65535, 20080, 65535, 21015, 65535, 65535, 65535, 16465, 65535, + 65535, 65535, 65535, 65535, 65535, 23341, 65535, 14586, 65535, 65535, + 65535, 21016, 65535, 65535, 65535, 23158, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22901, 65535, 65535, 65535, 65535, 65535, 65535, 17984, 65535, 22554, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22798, 65535, + 65535, 22797, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17776, 17267, 65535, 65535, 18776, 65535, 18401, 15333, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22373, + 20305, 17094, 65535, 65535, 65535, 65535, 20464, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17853, 22778, 18777, 65535, 65535, 65535, + 65535, 14810, 65535, 65535, 65535, 65535, 65535, 23120, 19150, 65535, + 20465, 65535, 65535, 65535, 21796, 65535, 65535, 18932, 65535, 65535, + 65535, 65535, 19299, 65535, 65535, 65535, 65535, 65535, 21017, 65535, + 17416, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14754, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16660, 65535, 65535, + 65535, 15152, 65535, 15005, 21797, 18200, 65535, 65535, 65535, 15334, + 19869, 65535, 19694, 65535, 65535, 23121, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 18572, 65535, 65535, 23122, + 65535, 65535, 65535, 22919, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 17449, 65535, 65535, 23291, 65535, 65535, 65535, 16634, 19158, + 22902, 65535, 65535, 22403, 65535, 22369, 18613, 65535, 65535, 65535, + 65535, 20506, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17069, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 21425, 15529, 14958, 65535, 65535, 13994, + 65535, 65535, 65535, 17606, 65535, 65535, 65535, 22404, 65535, 17854, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23105, 65535, 65535, 65535, 16068, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 21446, 65535, 17795, 65535, 65535, 65535, 65535, 65535, 65535, + 17417, 65535, 65535, 65535, 65535, 65535, 15335, 15336, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 22735, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 14241, 65535, 65535, 65535, 65535, + 15954, 65535, 65535, 65535, 65535, 65535, 22201, 18386, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 16698, 65535, 65535, 22799, + 65535, 14959, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23659, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14811, 65535, 23133, + 65535, 65535, 14428, 19315, 65535, 65535, 65535, 22339, 65535, 65535, + 16135, 65535, 65535, 15337, 65535, 65535, 65535, 23495, 16136, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14608, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23106, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 18573, 22032, 65535, 65535, 65535, 14587, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19478, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17200, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18574, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 16437, 65535, 65535, 22582, 65535, + 65535, 65535, 65535, 65535, 65535, 20051, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15106, 65535, 65535, 65535, + 65535, 14783, 23350, 17201, 17257, 16694, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 20109, 65535, 65535, 65535, 65535, + 16635, 65535, 65535, 65535, 65535, 65535, 19159, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16304, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21033, 65535, + 65535, 22779, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18958, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14812, 65535, 65535, + 18201, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16514, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22022, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14605, 65535, 65535, 65535, 14429, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 22202, 65535, 65535, 18947, 65535, + 17450, 65535, 65535, 22935, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23496, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19672, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 16661, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14185, 65535, 17399, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16522, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 21257, 65535, 17607, 65535, 14960, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17468, 16831, 65535, + 19358, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18933, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 20081, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18981, 65535, + 18974, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23363, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 14372, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18934, 65535, 65535, 14595, 16902, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 17638, 65535, + 65535, 65535, 65535, 65535, 20661, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16863, 65535, 65535, + 65535, 65535, 65535, 19098, 65535, 65535, 65535, 65535, 22940, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 14549, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14961, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 22340, 65535, 65535, 65535, 65535, 65535, 23706, 20312, 16305, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19099, 65535, 65535, 65535, 16077, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16306, 65535, 65535, + 65535, 22968, 65535, 65535, 65535, 19479, 65535, 16312, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 15338, 16313, 65535, 65535, + 65535, 16137, 65535, 65535, 65535, 65535, 65535, 17855, 65535, 16523, + 65535, 65535, 65535, 65535, 65535, 16699, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14968, 16718, 65535, 65535, 65535, 65535, 65535, 16636, 65535, 65535, + 23698, 65535, 65535, 65535, 65535, 23525, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18153, 16138, 65535, 65535, 23712, + 65535, 65535, 14348, 65535, 65535, 65535, 16904, 65535, 65535, 15749, + 22220, 65535, 21034, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15733, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 17034, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19673, 17400, 65535, 65535, 65535, 65535, 65535, + 21188, 65535, 65535, 65535, 65535, 14588, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18154, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 17777, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 21211, 20822, 65535, 65535, 20823, 65535, 65535, 65535, 22370, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 20855, 65535, 16283, 65535, 65535, 65535, 65535, 65535, 18214, + 65535, 65535, 21782, 65535, 19160, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 18948, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 16438, 65535, 65535, + 17229, 65535, 65535, 65535, 65535, 14059, 65535, 65535, 65535, 65535, + 65535, 65535, 14962, 65535, 65535, 65535, 9026, 9027, 0, 1, 9028, 2, 3, + 9029, 9030, 9031, 9032, 4, 5, 6, 7, 8, 9033, 9034, 9035, 9036, 9037, 9038, + 9039, 9040, 9, 9041, 9042, 9043, 9044, 9045, 10, 11, 9046, 12, 13, 14, + 9047, 15, 16, 17, 18, 19, 20, 21, 9048, 9049, 22, 9050, 9051, 9052, 23, 24, + 25, 32, 33, 34, 9053, 9054, 35, 36, 9055, 37, 38, 39, 9056, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 9057, 50, 9058, 51, 52, 53, 54, 55, 56, 9059, 57, + 64, 65, 9060, 66, 67, 68, 9061, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 9062, 9063, 88, 89, 9064, 90, 91, 9065, + 9066, 92, 9067, 93, 94, 95, 96, 97, 9068, 9069, 98, 9070, 9071, 9072, 9073, + 99, 100, 9074, 9075, 9076, 9077, 101, 102, 103, 9078, 104, 105, 106, 9079, + 107, 108, 109, 110, 111, 112, 113, 9080, 9081, 114, 9082, 9083, 9084, 115, + 116, 117, 118, 119, 120, 9085, 9086, 9087, 121, 9088, 122, 123, 9089, 9090, + 124, 125, 126, 127, 128, 129, 130, 9091, 9092, 131, 9093, 9094, 9095, 132, + 133, 134, 9096, 135, 136, 9097, 137, 138, 139, 9098, 140, 141, 142, 9099, + 143, 144, 145, 146, 147, 148, 149, 150, 9100, 151, 9101, 152, 153, 154, + 155, 156, 157, 158, 159, 9102, 9103, 160, 161, 9104, 162, 163, 9105, 9106, + 164, 9107, 165, 9108, 166, 167, 9109, 9110, 9111, 168, 9112, 169, 9113, + 9114, 170, 171, 172, 173, 174, 9115, 9116, 175, 176, 9117, 177, 178, 179, + 9118, 180, 9119, 181, 182, 183, 184, 185, 9216, 9217, 186, 9218, 187, 9219, + 188, 189, 190, 191, 192, 193, 9220, 194, 195, 196, 9221, 197, 198, 199, + 9222, 200, 201, 202, 203, 204, 205, 206, 207, 9223, 208, 209, 9224, 9225, + 210, 211, 212, 213, 214, 215, 9226, 9227, 222, 223, 9228, 224, 225, 226, + 9229, 227, 228, 229, 230, 231, 232, 233, 9230, 9231, 234, 9232, 235, 9233, + 236, 237, 238, 239, 240, 241, 9234, 242, 243, 244, 9235, 245, 246, 247, + 9236, 254, 255, 256, 257, 258, 259, 260, 261, 9237, 262, 9238, 263, 264, + 265, 266, 267, 268, 269, 270, 9239, 9240, 271, 272, 9241, 273, 274, 9242, + 9243, 9244, 9245, 275, 276, 277, 278, 9246, 9247, 9248, 279, 9249, 280, + 9250, 9251, 281, 282, 283, 284, 285, 9252, 9253, 286, 287, 9254, 288, 289, + 290, 9255, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 9256, + 9257, 302, 303, 304, 305, 306, 307, 9258, 308, 309, 310, 311, 312, 313, + 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 9259, 326, 327, + 328, 329, 330, 331, 332, 333, 9260, 9261, 334, 335, 9262, 336, 337, 338, + 9263, 339, 340, 341, 342, 343, 344, 345, 9264, 9265, 346, 9266, 347, 348, + 349, 350, 351, 352, 353, 354, 9267, 355, 356, 357, 9268, 358, 359, 360, + 9269, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 9270, 9271, 380, 381, 9272, 382, 383, 9273, 9274, + 9275, 384, 385, 386, 387, 388, 389, 9276, 9277, 390, 9278, 391, 9279, 392, + 393, 394, 395, 396, 397, 9280, 398, 399, 400, 401, 402, 403, 404, 405, 412, + 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, + 428, 429, 430, 9281, 9282, 431, 432, 9283, 433, 434, 9284, 9285, 435, 9286, + 436, 437, 444, 445, 446, 9287, 9288, 447, 9289, 448, 9290, 9291, 449, 450, + 451, 9292, 452, 9293, 9294, 9295, 453, 9296, 454, 455, 456, 9297, 457, + 9298, 458, 459, 460, 461, 462, 9299, 9300, 463, 9301, 9302, 9303, 464, 465, + 466, 9304, 467, 468, 9305, 9306, 469, 470, 9307, 471, 472, 473, 9308, 474, + 475, 476, 477, 478, 479, 480, 9309, 9406, 481, 9407, 9408, 9409, 482, 483, + 484, 485, 486, 487, 9410, 9411, 488, 489, 490, 491, 492, 493, 9412, 494, + 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, + 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, + 540, 9413, 9414, 9415, 541, 9416, 542, 543, 544, 9417, 545, 546, 547, 548, + 549, 550, 551, 9418, 9419, 552, 9420, 9421, 9422, 553, 554, 555, 556, 557, + 558, 9423, 9424, 559, 560, 9425, 561, 562, 563, 564, 565, 566, 567, 568, + 569, 570, 571, 9426, 572, 573, 9427, 574, 9428, 575, 576, 577, 578, 579, + 580, 9429, 581, 582, 583, 9430, 584, 585, 586, 9431, 587, 588, 589, 590, + 591, 592, 593, 594, 595, 602, 9432, 9433, 603, 604, 605, 606, 9434, 607, + 608, 9435, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, + 622, 623, 624, 625, 626, 627, 634, 635, 636, 637, 638, 639, 640, 641, 9436, + 9437, 642, 643, 9438, 644, 9439, 645, 9440, 646, 647, 648, 649, 650, 651, + 652, 9441, 9442, 653, 9443, 654, 9444, 9445, 9446, 655, 656, 657, 658, + 9447, 9448, 659, 660, 661, 662, 663, 664, 9449, 665, 666, 667, 668, 669, + 670, 671, 672, 673, 674, 675, 9450, 9451, 676, 677, 678, 679, 680, 681, + 9452, 9453, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, + 694, 695, 696, 697, 698, 699, 700, 9454, 701, 702, 703, 704, 705, 706, + 9455, 707, 708, 709, 9456, 710, 711, 712, 9457, 713, 714, 715, 716, 717, + 718, 719, 9458, 9459, 720, 721, 722, 9460, 723, 724, 725, 726, 727, 728, + 9461, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, + 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 9462, + 9463, 756, 757, 9464, 758, 759, 760, 9465, 761, 762, 763, 764, 765, 766, + 9466, 9467, 9468, 767, 9469, 768, 9470, 9471, 769, 770, 771, 772, 773, + 9472, 774, 775, 776, 777, 778, 779, 780, 9473, 781, 782, 783, 784, 785, + 792, 793, 794, 795, 796, 797, 9474, 9475, 798, 799, 800, 801, 802, 803, + 9476, 9477, 804, 805, 9478, 806, 807, 808, 9479, 809, 810, 811, 812, 813, + 814, 815, 9480, 9481, 816, 817, 9482, 824, 825, 826, 827, 828, 829, 830, + 9483, 831, 832, 833, 9484, 834, 835, 836, 9485, 837, 838, 839, 840, 841, + 842, 843, 9486, 9487, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, + 9488, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, + 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 9489, + 9490, 881, 882, 9491, 883, 9492, 884, 9493, 885, 9494, 886, 887, 888, 889, + 9495, 9496, 9497, 890, 9498, 891, 9499, 892, 893, 894, 9596, 895, 896, 897, + 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, + 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 9597, 9598, + 925, 926, 9599, 927, 928, 929, 9600, 930, 931, 932, 933, 934, 935, 936, + 9601, 9602, 937, 9603, 938, 9604, 939, 940, 941, 942, 943, 944, 9605, 9606, + 9607, 945, 9608, 946, 947, 9609, 9610, 9611, 9612, 948, 949, 950, 951, 952, + 9613, 9614, 953, 9615, 9616, 9617, 9618, 9619, 954, 9620, 955, 9621, 9622, + 9623, 956, 957, 9624, 958, 959, 960, 9625, 961, 962, 963, 964, 965, 966, + 967, 9626, 9627, 968, 9628, 9629, 9630, 969, 970, 971, 972, 973, 974, 9631, + 9632, 975, 982, 9633, 983, 984, 985, 9634, 986, 987, 988, 989, 990, 991, + 992, 9635, 993, 994, 995, 996, 9636, 997, 998, 999, 1000, 1001, 1002, 1003, + 1004, 1005, 1006, 1007, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, + 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, + 1034, 1035, 1036, 9637, 9638, 1037, 9639, 9640, 1038, 1039, 1040, 9641, + 1041, 9642, 9643, 1042, 1043, 1044, 1045, 9644, 9645, 1046, 9646, 9647, + 9648, 1047, 1048, 1049, 1050, 1051, 9649, 9650, 9651, 1052, 1053, 9652, + 1054, 1055, 1056, 9653, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 9654, + 9655, 1064, 9656, 9657, 9658, 1065, 1066, 1067, 1068, 1069, 1070, 9659, + 9660, 1071, 1072, 9661, 1073, 1074, 1075, 9662, 1076, 1077, 1078, 1079, + 1080, 1081, 1082, 9663, 9664, 1083, 1084, 9665, 9666, 1085, 1086, 9667, + 1087, 1088, 1089, 9668, 1090, 1091, 1092, 9669, 1093, 1094, 1095, 1096, + 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, + 1109, 1110, 1111, 1112, 1113, 1114, 1115, 9670, 9671, 1116, 1117, 9672, + 1118, 1119, 1120, 9673, 1121, 9674, 1122, 1123, 1124, 1125, 1126, 9675, + 9676, 1127, 9677, 1128, 9678, 1129, 1130, 1131, 1132, 9679, 9680, 9681, + 1133, 1134, 1135, 9682, 1136, 1137, 1138, 9683, 1139, 1140, 1141, 1142, + 1143, 1144, 1145, 1146, 1147, 1148, 1149, 9684, 1150, 1151, 1152, 1153, + 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, + 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, + 1184, 1185, 1186, 1187, 1188, 1189, 1190, 9685, 1191, 1192, 1193, 9686, + 1194, 1195, 1196, 9687, 1197, 1204, 1205, 1206, 1207, 1208, 1209, 9688, + 9689, 1210, 9786, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 9787, + 9788, 1219, 1220, 9789, 1221, 1222, 1223, 9790, 1224, 1225, 1226, 1227, + 1228, 1229, 1230, 1231, 9791, 1232, 9792, 1233, 9793, 1234, 1235, 1236, + 1237, 1238, 1239, 9794, 9795, 1240, 1241, 9796, 1242, 1243, 9797, 9798, + 1244, 1245, 1246, 1247, 1248, 1249, 1250, 9799, 9800, 1251, 9801, 1252, + 9802, 1253, 1254, 1255, 1256, 1257, 1258, 9803, 1259, 1260, 1261, 1262, + 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, + 1275, 1276, 1277, 9804, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 9805, + 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, + 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, + 1309, 1310, 1311, 9806, 1312, 1313, 1314, 9807, 1315, 1316, 1317, 9808, + 1318, 1319, 1320, 1321, 1322, 1323, 1324, 9809, 9810, 1325, 1326, 1327, + 1328, 1329, 1330, 1331, 1332, 1333, 1334, 9811, 9812, 1335, 1336, 1337, + 1338, 1339, 1340, 9813, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 9814, + 9815, 1348, 1349, 1350, 9816, 1351, 1352, 1353, 1354, 1355, 1362, 9817, + 9818, 1363, 1364, 9819, 1365, 1366, 1367, 9820, 9821, 9822, 1368, 1369, + 1370, 1371, 1372, 9823, 9824, 1373, 9825, 1374, 9826, 9827, 1375, 1376, + 1377, 9828, 1378, 9829, 1379, 1380, 1381, 9830, 1382, 1383, 1384, 9831, + 1385, 1386, 1387, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, + 1403, 1404, 1405, 1406, 1407, 1408, 1409, 9832, 9833, 1410, 1411, 9834, + 1412, 1413, 1414, 9835, 1415, 9836, 1416, 1417, 1418, 1419, 1420, 9837, + 9838, 1421, 9839, 1422, 9840, 1423, 1424, 1425, 1426, 9841, 1427, 9842, + 9843, 9844, 1428, 9845, 1429, 1430, 9846, 9847, 9848, 9849, 9850, 1431, + 1432, 1433, 9851, 9852, 9853, 1434, 9854, 9855, 9856, 9857, 9858, 1435, + 1436, 1437, 9859, 9860, 9861, 1438, 1439, 9862, 1440, 1441, 1442, 9863, + 1443, 1444, 1445, 1446, 1447, 1448, 1449, 9864, 9865, 1450, 9866, 9867, + 9868, 1451, 1452, 1453, 1454, 1455, 1456, 9869, 1457, 1458, 1459, 1460, + 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, + 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, + 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, + 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, + 1509, 1510, 1511, 9870, 9871, 9872, 1512, 9873, 1513, 1514, 9874, 9875, + 1515, 9876, 9877, 1516, 1517, 1518, 1519, 9878, 9879, 1520, 9976, 1521, + 9977, 1522, 9978, 1523, 1524, 9979, 1525, 9980, 9981, 1526, 1527, 9982, + 1528, 1529, 1530, 9983, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 9984, + 9985, 1538, 9986, 9987, 9988, 1539, 1540, 1541, 1542, 1543, 1544, 9989, + 1545, 1552, 1553, 9990, 1554, 1555, 1556, 9991, 1557, 1558, 1559, 1560, + 1561, 1562, 1563, 1564, 1565, 1566, 1567, 9992, 9993, 1568, 1569, 1570, + 1571, 1572, 1573, 9994, 1574, 1575, 1576, 9995, 1577, 1584, 1585, 1586, + 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, + 1599, 1600, 1601, 1602, 1603, 1604, 1605, 9996, 9997, 1606, 1607, 9998, + 1608, 1609, 9999, 10000, 1610, 10001, 1611, 10002, 1612, 1613, 1614, 10003, + 10004, 1615, 10005, 1616, 10006, 1617, 10007, 1618, 10008, 1619, 1620, + 10009, 1621, 1622, 1623, 10010, 1624, 1625, 1626, 10011, 1627, 1628, 1629, + 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, + 1642, 1643, 1644, 1645, 10012, 1646, 1647, 1648, 1649, 1650, 1651, 1652, + 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, + 10013, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 10014, 1672, 1673, 1674, + 10015, 1675, 1676, 1677, 10016, 1678, 1679, 1680, 1681, 1682, 1683, 1684, + 10017, 10018, 1685, 10019, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, + 10020, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, + 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, + 1717, 1718, 1719, 1720, 10021, 10022, 1721, 1722, 10023, 1723, 1724, 1725, + 10024, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 10025, 10026, 1733, 10027, + 1734, 10028, 1735, 1742, 1743, 1744, 1745, 1746, 10029, 1747, 1748, 1749, + 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, + 1762, 1763, 1764, 1765, 10030, 1766, 1767, 1774, 1775, 1776, 1777, 1778, + 10031, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, + 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 10032, 1799, 1800, + 1801, 1802, 1803, 1804, 10033, 1805, 1806, 1807, 10034, 1808, 1809, 1810, + 10035, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 10036, 1819, 10037, + 1820, 10038, 1821, 1822, 1823, 1824, 1825, 1826, 10039, 1827, 1828, 1829, + 10040, 1830, 1831, 1832, 10041, 1833, 1834, 1835, 1836, 1837, 1838, 1839, + 10042, 1840, 1841, 1842, 1843, 10043, 1844, 1845, 1846, 1847, 1848, 1849, + 10044, 10045, 1850, 1851, 10046, 1852, 1853, 10047, 10048, 1854, 10049, + 1855, 1856, 1857, 1858, 1859, 10050, 10051, 1860, 10052, 1861, 10053, 1862, + 1863, 1864, 1865, 1866, 1867, 10054, 1868, 1869, 1870, 1871, 1872, 1873, + 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, + 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 10055, 10056, 1895, + 1896, 10057, 1897, 1898, 10058, 10059, 1899, 1900, 1901, 1902, 1903, 1904, + 1905, 10060, 10061, 1906, 10062, 10063, 10064, 10065, 1907, 1908, 1909, + 1910, 1911, 10066, 10067, 1912, 1913, 10068, 1914, 1915, 1916, 10069, 1917, + 1918, 1919, 1920, 1921, 1922, 1923, 10166, 10167, 1924, 10168, 10169, + 10170, 1925, 1932, 1933, 1934, 1935, 10171, 10172, 10173, 1936, 1937, + 10174, 1938, 1939, 1940, 10175, 1941, 1942, 1943, 1944, 1945, 1946, 1947, + 10176, 10177, 1948, 10178, 10179, 10180, 1949, 1950, 1951, 1952, 1953, + 1954, 1955, 1956, 1957, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, + 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, + 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 10181, 10182, 2017, + 2018, 10183, 2019, 2020, 2021, 10184, 2022, 10185, 10186, 2023, 2024, 2025, + 2026, 10187, 10188, 2027, 10189, 10190, 10191, 2028, 2029, 2030, 2031, + 2032, 10192, 10193, 10194, 2033, 2034, 10195, 2035, 2036, 2037, 10196, + 2038, 2039, 2040, 2041, 2042, 2043, 2044, 10197, 10198, 2045, 10199, 10200, + 10201, 2046, 2047, 2048, 2049, 2050, 2051, 10202, 2052, 2053, 2054, 2055, + 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, + 2068, 2069, 2070, 10203, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, + 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, + 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, + 2103, 2104, 2105, 10204, 10205, 2106, 2107, 10206, 2108, 2109, 2110, 10207, + 2111, 2112, 2113, 2114, 2115, 2122, 2123, 2124, 2125, 2126, 2127, 2128, + 10208, 2129, 2130, 2131, 2132, 2133, 2134, 10209, 2135, 2136, 2137, 2138, + 2139, 2140, 2141, 10210, 2142, 2143, 2144, 2145, 2146, 2147, 2154, 2155, + 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166, 10211, + 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, + 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, + 2191, 2192, 2193, 10212, 2194, 2195, 2196, 10213, 2197, 2198, 2199, 2200, + 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, + 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, + 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, + 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 10214, + 10215, 2248, 2249, 10216, 2250, 2251, 2252, 10217, 2253, 2254, 2255, 2256, + 2257, 2258, 10218, 10219, 2259, 2260, 2261, 2262, 10220, 2263, 2264, 2265, + 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, + 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, + 2290, 2291, 2292, 2293, 2294, 2295, 2296, 10221, 2297, 2298, 2299, 2300, + 2301, 2302, 2303, 2304, 2305, 2312, 2313, 2314, 2315, 2316, 2317, 2318, + 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 10222, + 2330, 2331, 2332, 10223, 2333, 2334, 2335, 10224, 2336, 2337, 2344, 2345, + 2346, 2347, 2348, 10225, 10226, 2349, 2350, 2351, 10227, 2352, 2353, 2354, + 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, + 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, + 2379, 2380, 2381, 2382, 2383, 2384, 2385, 10228, 10229, 2386, 2387, 10230, + 2388, 2389, 10231, 10232, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 10233, + 10234, 2397, 10235, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 10236, + 2406, 2407, 2408, 10237, 2409, 2410, 2411, 10238, 2412, 2413, 2414, 2415, + 2416, 2417, 2418, 10239, 10240, 2419, 2420, 2421, 2422, 2423, 2424, 2425, + 2426, 2427, 2428, 10241, 2429, 2430, 2431, 10242, 2432, 2433, 2434, 10243, + 2435, 2436, 2437, 2438, 2439, 2440, 2441, 10244, 10245, 2442, 10246, 2443, + 10247, 2444, 2445, 2446, 2447, 2448, 2449, 10248, 10249, 2450, 2451, 10250, + 2452, 2453, 2454, 10251, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 10252, + 10253, 2462, 10254, 10255, 10256, 10257, 2463, 2464, 2465, 10258, 10259, + 10356, 10357, 2466, 2467, 10358, 2468, 2469, 2470, 10359, 2471, 2472, 2473, + 2474, 2475, 2476, 2477, 10360, 10361, 2478, 10362, 10363, 10364, 2479, + 2480, 2481, 2482, 2483, 2484, 10365, 10366, 2485, 2486, 10367, 2487, 2488, + 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2502, 2503, 2504, 2505, 2506, + 10368, 2507, 10369, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, + 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2534, + 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, + 2547, 10370, 10371, 2548, 2549, 10372, 2550, 2551, 2552, 10373, 2553, 2554, + 2555, 2556, 2557, 2558, 2559, 10374, 10375, 2560, 10376, 10377, 10378, + 2561, 2562, 2563, 2564, 2565, 10379, 10380, 10381, 2566, 2567, 10382, 2568, + 2569, 2570, 10383, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 10384, 10385, + 2578, 10386, 2579, 10387, 2580, 2581, 2582, 2583, 2584, 2585, 10388, 10389, + 2586, 2587, 10390, 2588, 2589, 2590, 10391, 2591, 2592, 2593, 2594, 2595, + 2596, 2597, 10392, 10393, 2598, 10394, 10395, 10396, 2599, 2600, 2601, + 2602, 2603, 2604, 10397, 2605, 2606, 2607, 10398, 2608, 2609, 2610, 2611, + 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 10399, 2620, 10400, 2621, + 2622, 2623, 2624, 2625, 2626, 2627, 2628, 10401, 10402, 2629, 2630, 10403, + 2631, 2632, 2633, 10404, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 10405, + 10406, 2641, 10407, 2642, 10408, 2643, 2644, 2645, 2646, 2647, 2648, 10409, + 2649, 2650, 2651, 10410, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, + 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 10411, 2668, 2669, 2670, + 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, + 2683, 2684, 2685, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 10412, + 2700, 2701, 2702, 2703, 2704, 2705, 2706, 10413, 2707, 2708, 2709, 10414, + 2710, 2711, 2712, 10415, 2713, 2714, 2715, 2716, 2717, 2724, 2725, 10416, + 10417, 2726, 10418, 2727, 10419, 2728, 2729, 2730, 2731, 2732, 2733, 10420, + 2734, 2735, 2736, 10421, 2737, 2738, 2739, 10422, 2740, 2741, 2742, 2743, + 2744, 2745, 2746, 2747, 10423, 2748, 10424, 2749, 10425, 2750, 2751, 2752, + 2753, 2754, 2755, 10426, 10427, 2756, 2757, 10428, 2758, 2759, 2760, 10429, + 2761, 2762, 2763, 2764, 2765, 2766, 2767, 10430, 10431, 2768, 10432, 2769, + 10433, 2770, 2771, 2772, 2773, 2774, 2775, 10434, 2776, 2777, 2778, 2779, + 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, + 2792, 2793, 2794, 10435, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 10436, + 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, + 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, + 2826, 2827, 2828, 10437, 10438, 2829, 2830, 10439, 2831, 2832, 2833, 10440, + 2834, 2835, 2836, 2837, 2838, 2839, 2840, 10441, 2841, 2842, 10442, 2843, + 10443, 2844, 2845, 2846, 2847, 2848, 2849, 10444, 10445, 2850, 2851, 10446, + 2852, 2853, 2854, 10447, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 10448, + 10449, 2862, 10546, 2863, 10547, 2864, 2865, 2866, 2867, 2868, 2869, 10548, + 10549, 2870, 2871, 10550, 2872, 2873, 2874, 10551, 2875, 2882, 2883, 2884, + 2885, 2886, 2887, 10552, 10553, 2888, 10554, 2889, 10555, 10556, 2890, + 2891, 10557, 10558, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, + 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2914, 2915, 2916, 2917, 2918, + 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 10559, 10560, 2927, 2928, + 10561, 2929, 2930, 2931, 10562, 2932, 2933, 2934, 2935, 2936, 2937, 2938, + 10563, 10564, 2939, 10565, 2940, 10566, 2941, 2942, 2943, 2944, 2945, 2946, + 10567, 10568, 2947, 2948, 10569, 2949, 10570, 10571, 10572, 10573, 10574, + 2950, 2951, 2952, 2953, 2954, 10575, 10576, 2955, 10577, 2956, 10578, + 10579, 2957, 2958, 10580, 2959, 10581, 10582, 10583, 2960, 2961, 10584, + 2962, 2963, 2964, 10585, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 10586, + 10587, 2972, 10588, 10589, 10590, 10591, 2973, 2974, 2975, 2976, 2977, + 10592, 10593, 2978, 2979, 2980, 2981, 2982, 2983, 10594, 2984, 2985, 2986, + 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 10595, 2996, 2997, + 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, + 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, + 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 10596, 10597, 3030, 3031, + 10598, 3032, 3033, 3034, 10599, 3035, 10600, 3036, 3037, 3038, 3039, 3040, + 10601, 10602, 3041, 10603, 3042, 10604, 10605, 3043, 3044, 3045, 3046, + 10606, 10607, 10608, 3047, 3048, 10609, 3049, 3050, 3051, 10610, 3052, + 3053, 3054, 3055, 3056, 3057, 3058, 10611, 10612, 3059, 10613, 10614, + 10615, 3060, 3061, 3062, 3063, 3064, 3065, 10616, 10617, 3072, 3073, 10618, + 3074, 3075, 3076, 10619, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, + 3085, 3086, 10620, 10621, 10622, 3087, 10623, 3088, 3089, 3090, 3091, + 10624, 3092, 3093, 3094, 3095, 3096, 3097, 3104, 3105, 3106, 3107, 3108, + 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, + 3121, 3122, 3123, 3124, 10625, 10626, 3125, 10627, 10628, 3126, 3127, 3128, + 10629, 3129, 10630, 3130, 3131, 3132, 3133, 3134, 10631, 10632, 3135, + 10633, 3136, 10634, 3137, 3138, 3139, 3140, 3141, 3142, 10635, 3143, 3144, + 3145, 10636, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, + 3156, 3157, 3158, 3159, 3160, 10637, 10638, 3161, 3162, 3163, 3164, 3165, + 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, + 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, + 3190, 3191, 3192, 3193, 3194, 10639, 3195, 3196, 3197, 10736, 3198, 3199, + 3200, 10737, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 10738, 3209, + 10739, 3210, 10740, 3211, 3212, 3213, 3214, 3215, 3216, 10741, 3217, 3218, + 3219, 10742, 3220, 3221, 3222, 10743, 3223, 3224, 3225, 3226, 3227, 3228, + 3229, 3230, 10744, 3231, 10745, 3232, 3233, 3234, 3235, 3236, 3237, 3238, + 3239, 10746, 10747, 10748, 3240, 10749, 3241, 3242, 10750, 10751, 10752, + 10753, 3243, 3244, 3245, 3246, 3247, 10754, 10755, 3248, 10756, 3249, + 10757, 3250, 3251, 3252, 10758, 3253, 10759, 10760, 3254, 3255, 3262, + 10761, 3263, 3264, 3265, 10762, 3266, 3267, 3268, 3269, 3270, 3271, 3272, + 3273, 10763, 3274, 10764, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, + 10765, 3283, 3284, 3285, 3286, 3287, 3294, 3295, 3296, 3297, 3298, 3299, + 3300, 3301, 3302, 3303, 3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, + 3312, 3313, 3314, 3315, 10766, 3316, 3317, 3318, 10767, 3319, 3320, 3321, + 10768, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, + 3333, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 10769, 3341, 3342, 3343, + 10770, 3344, 3345, 3346, 10771, 3347, 3348, 3349, 3350, 3351, 3352, 3353, + 10772, 3354, 3355, 10773, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, + 10774, 3364, 3365, 3366, 10775, 3367, 3368, 3369, 10776, 3370, 3371, 3372, + 3373, 3374, 3375, 3376, 10777, 3377, 3378, 10778, 3379, 3380, 3381, 3382, + 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, + 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, + 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3414, 10779, 10780, 3415, 3416, + 10781, 3417, 3418, 10782, 10783, 3419, 10784, 3420, 3421, 3422, 3423, 3424, + 10785, 10786, 3425, 10787, 10788, 10789, 3426, 10790, 3427, 10791, 3428, + 3429, 10792, 10793, 10794, 10795, 10796, 3430, 3431, 10797, 10798, 10799, + 10800, 10801, 3432, 3433, 3434, 3435, 10802, 10803, 3436, 10804, 3437, + 10805, 3438, 3439, 3440, 10806, 3441, 3442, 10807, 10808, 3443, 3444, + 10809, 3445, 3452, 3453, 10810, 3454, 3455, 3456, 3457, 3458, 3459, 3460, + 10811, 10812, 3461, 10813, 10814, 10815, 3462, 3463, 3464, 10816, 3465, + 3466, 10817, 10818, 3467, 3468, 10819, 3469, 3470, 3471, 3472, 3473, 3474, + 3475, 3476, 3477, 3484, 3485, 3486, 10820, 3487, 3488, 3489, 3490, 3491, + 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, + 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, + 3516, 3517, 3518, 3519, 3520, 3521, 3522, 3523, 3524, 10821, 10822, 3525, + 3526, 10823, 3527, 3528, 10824, 10825, 3529, 10826, 3530, 3531, 3532, 3533, + 3534, 10827, 10828, 3535, 10829, 3536, 10926, 10927, 3537, 3538, 3539, + 3540, 3541, 10928, 10929, 3542, 3543, 10930, 3544, 3545, 10931, 10932, + 3546, 3547, 3548, 3549, 3550, 3551, 3552, 10933, 10934, 3553, 10935, 10936, + 10937, 3554, 3555, 3556, 3557, 3558, 3559, 10938, 10939, 3560, 3561, 10940, + 3562, 3563, 3564, 10941, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, + 10942, 3573, 10943, 10944, 10945, 3574, 3575, 3576, 10946, 3577, 3578, + 10947, 3579, 3580, 3581, 10948, 3582, 3583, 3584, 3585, 3586, 3587, 3588, + 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, + 3601, 3602, 3603, 3604, 10949, 10950, 10951, 3605, 10952, 3606, 3607, 3608, + 10953, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 10954, 10955, 3616, 10956, + 3617, 10957, 3618, 3619, 3620, 3621, 3622, 3623, 10958, 3624, 3625, 3626, + 10959, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3642, 3643, + 3644, 3645, 3646, 3647, 10960, 3648, 3649, 3650, 3651, 3652, 3653, 3654, + 10961, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, + 3666, 3667, 3674, 3675, 3676, 3677, 3678, 3679, 10962, 3680, 3681, 3682, + 3683, 3684, 3685, 3686, 10963, 10964, 3687, 3688, 10965, 3689, 3690, 3691, + 10966, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 10967, 10968, 3699, 3700, + 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 10969, 3709, 3710, 3711, + 10970, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, + 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, + 10971, 10972, 3735, 3736, 10973, 3737, 3738, 10974, 10975, 10976, 10977, + 3739, 3740, 3741, 3742, 3743, 10978, 10979, 3744, 10980, 3745, 10981, 3746, + 3747, 3748, 10982, 10983, 3749, 10984, 3750, 3751, 3752, 3753, 3754, 3755, + 3756, 10985, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3766, + 3767, 10986, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 10987, 3775, 3776, + 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, + 3789, 3790, 3791, 3792, 3793, 3794, 3795, 3796, 3797, 3798, 3799, 3800, + 3801, 10988, 10989, 3802, 3803, 10990, 3804, 3805, 3806, 10991, 3807, 3808, + 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817, 3818, 10992, 3819, + 3820, 3821, 3822, 3823, 3824, 10993, 3825, 3832, 3833, 10994, 3834, 3835, + 3836, 10995, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 10996, 3844, 3845, + 10997, 3846, 10998, 3847, 3848, 3849, 3850, 3851, 3852, 10999, 11000, 3853, + 3854, 11001, 3855, 3856, 3857, 11002, 3864, 3865, 3866, 3867, 3868, 3869, + 3870, 11003, 11004, 3871, 11005, 3872, 3873, 3874, 3875, 3876, 3877, 3878, + 3879, 3880, 3881, 3882, 3883, 3884, 3885, 3886, 3887, 3888, 3889, 3890, + 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, + 3903, 3904, 3905, 3906, 3907, 11006, 11007, 3908, 3909, 11008, 3910, 3911, + 3912, 11009, 3913, 11010, 3914, 3915, 3916, 3917, 3918, 11011, 11012, 3919, + 11013, 3920, 11014, 11015, 11016, 3921, 3922, 3923, 3924, 11017, 11018, + 3925, 3926, 11019, 3927, 3928, 3929, 11116, 3930, 11117, 3931, 3932, 3933, + 3934, 3935, 11118, 11119, 3936, 11120, 11121, 11122, 3937, 3938, 3939, + 3940, 3941, 11123, 11124, 11125, 3942, 3943, 11126, 3944, 3945, 3946, + 11127, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 11128, 11129, 3954, 11130, + 11131, 11132, 3955, 3956, 3957, 3958, 3959, 3960, 11133, 11134, 3961, 3962, + 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, + 11135, 3975, 3976, 3977, 3978, 3979, 3980, 3981, 3982, 3983, 3984, 3985, + 3986, 3987, 3988, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, + 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, + 4010, 4011, 4012, 4013, 11136, 11137, 4014, 4015, 11138, 4022, 4023, 11139, + 11140, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 11141, 4031, 4032, 11142, + 11143, 11144, 4033, 4034, 4035, 4036, 4037, 4038, 11145, 4039, 4040, 4041, + 4042, 4043, 4044, 4045, 4046, 4047, 4054, 4055, 4056, 4057, 4058, 4059, + 4060, 4061, 4062, 4063, 4064, 11146, 4065, 4066, 4067, 4068, 4069, 4070, + 11147, 11148, 4071, 4072, 4073, 4074, 4075, 4076, 4077, 4078, 4079, 4080, + 4081, 4082, 4083, 4084, 11149, 11150, 4085, 11151, 11152, 11153, 4086, + 4087, 4088, 4089, 4090, 4091, 4092, 4093, 4094, 4095, 4096, 4097, 4098, + 4099, 4100, 4101, 4102, 4103, 4104, 4105, 4106, 4107, 4108, 4109, 4110, + 4111, 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, 11154, 11155, 4120, + 4121, 11156, 4122, 4123, 4124, 11157, 4125, 4126, 4127, 4128, 4129, 4130, + 4131, 11158, 11159, 4132, 4133, 4134, 11160, 4135, 4136, 4137, 4138, 4139, + 4140, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, + 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, 4161, 4162, 4163, + 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4172, 4173, 4174, 4175, + 4176, 4177, 4178, 4179, 4180, 4181, 4182, 4183, 4184, 4185, 4186, 4187, + 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 11161, 4197, 4198, + 4199, 4200, 4201, 4202, 4203, 4204, 4205, 4212, 4213, 4214, 4215, 4216, + 4217, 4218, 4219, 4220, 4221, 4222, 4223, 4224, 4225, 4226, 4227, 4228, + 4229, 11162, 4230, 4231, 4232, 4233, 4234, 4235, 4236, 4237, 4244, 4245, + 4246, 4247, 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 11163, 4256, + 4257, 4258, 4259, 4260, 4261, 11164, 11165, 4262, 4263, 11166, 4264, 4265, + 4266, 11167, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 11168, 4274, 4275, + 11169, 4276, 11170, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, + 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293, 4294, 4295, 4296, 4297, + 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4305, 4306, 4307, 4308, 4309, + 4310, 4311, 4312, 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4320, 4321, + 4322, 4323, 4324, 4325, 4326, 4327, 4328, 4329, 4330, 4331, 4332, 4333, + 4334, 4335, 4336, 4337, 4338, 4339, 4340, 4341, 4342, 4343, 4344, 4345, + 4346, 4347, 4348, 4349, 4350, 4351, 4352, 4353, 4354, 4355, 4356, 4357, + 4358, 4359, 4360, 4361, 4362, 4363, 4364, 4365, 4366, 11171, 4367, 4368, + 4369, 4370, 4371, 4372, 4373, 4374, 4375, 4376, 4377, 4378, 4379, 4380, + 4381, 4382, 4383, 4384, 4385, 4386, 11172, 4387, 4388, 4389, 4390, 4391, + 4392, 11173, 4393, 4394, 4395, 11174, 4402, 4403, 4404, 11175, 4405, 4406, + 4407, 4408, 4409, 4410, 4411, 11176, 11177, 4412, 4413, 4414, 4415, 4416, + 4417, 4418, 4419, 4420, 4421, 4422, 4423, 4424, 4425, 4426, 4427, 4434, + 4435, 4436, 4437, 4438, 4439, 4440, 4441, 4442, 4443, 4444, 4445, 4446, + 4447, 4448, 4449, 4450, 4451, 4452, 4453, 4454, 4455, 11178, 11179, 4456, + 4457, 11180, 4458, 4459, 4460, 11181, 4461, 4462, 4463, 4464, 4465, 4466, + 4467, 11182, 11183, 4468, 11184, 4469, 11185, 4470, 4471, 4472, 4473, 4474, + 4475, 11186, 11187, 4476, 11188, 11189, 4477, 4478, 11190, 11191, 11192, + 11193, 4479, 4480, 4481, 4482, 4483, 11194, 11195, 4484, 11196, 11197, + 11198, 4485, 4486, 4487, 11199, 4488, 4489, 11200, 11201, 4490, 4491, + 11202, 4492, 4493, 4494, 11203, 4495, 4496, 4497, 4498, 4499, 4500, 4501, + 11204, 11205, 4502, 11206, 11207, 11208, 4503, 4504, 4505, 4506, 4507, + 4508, 11209, 11306, 4509, 4510, 11307, 4511, 4512, 4513, 11308, 4514, 4515, + 4516, 4517, 4518, 4519, 4520, 11309, 11310, 4521, 11311, 4522, 11312, 4523, + 4524, 4525, 4526, 4527, 4528, 11313, 4529, 4530, 4531, 11314, 4532, 4533, + 4534, 11315, 4535, 4536, 4537, 4538, 4539, 4540, 4541, 11316, 4542, 4543, + 4544, 4545, 11317, 4546, 4547, 4548, 4549, 4550, 4551, 11318, 11319, 11320, + 11321, 11322, 4552, 4553, 11323, 11324, 4554, 11325, 11326, 4555, 4556, + 4557, 4558, 11327, 11328, 4559, 11329, 11330, 11331, 4560, 4561, 4562, + 4563, 11332, 4564, 11333, 11334, 4565, 4566, 11335, 4567, 4568, 4569, + 11336, 4570, 4571, 4572, 4573, 4574, 4575, 4576, 11337, 11338, 4577, 11339, + 11340, 11341, 4578, 4579, 4580, 4581, 4582, 4583, 11342, 11343, 4584, 4585, + 11344, 4592, 4593, 4594, 11345, 4595, 4596, 4597, 4598, 4599, 4600, 4601, + 11346, 11347, 4602, 11348, 11349, 11350, 4603, 4604, 4605, 4606, 4607, + 4608, 11351, 4609, 4610, 4611, 11352, 4612, 4613, 4614, 11353, 4615, 4616, + 4617, 4624, 4625, 4626, 4627, 4628, 4629, 4630, 4631, 4632, 11354, 4633, + 4634, 4635, 4636, 4637, 4638, 11355, 11356, 11357, 4639, 11358, 4640, 4641, + 4642, 11359, 4643, 11360, 4644, 4645, 4646, 4647, 4648, 11361, 11362, 4649, + 11363, 4650, 11364, 4651, 4652, 4653, 11365, 4654, 4655, 11366, 11367, + 4656, 4657, 11368, 4658, 4659, 4660, 11369, 4661, 4662, 4663, 4664, 4665, + 4666, 4667, 4668, 4669, 4670, 4671, 4672, 11370, 4673, 4674, 4675, 4676, + 4677, 4678, 11371, 4679, 4680, 4681, 11372, 4682, 4683, 4684, 11373, 4685, + 4686, 4687, 4688, 4689, 4690, 4691, 11374, 4692, 4693, 11375, 11376, 4694, + 4695, 4696, 4697, 4698, 4699, 4700, 11377, 4701, 4702, 4703, 11378, 4704, + 4705, 4706, 11379, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 11380, 11381, + 4714, 11382, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 11383, 11384, + 4723, 4724, 11385, 4725, 4726, 4727, 11386, 4728, 4729, 4730, 4731, 4732, + 4733, 4734, 11387, 11388, 4735, 11389, 4736, 11390, 4737, 4738, 4739, 4740, + 4741, 4742, 11391, 11392, 4743, 4744, 11393, 4745, 4746, 11394, 11395, + 4747, 4748, 4749, 4750, 4751, 4752, 4753, 11396, 11397, 4754, 11398, 4755, + 11399, 4756, 11496, 4757, 11497, 11498, 4758, 11499, 4759, 4760, 4761, + 4762, 4763, 4764, 4765, 4766, 4767, 4768, 4769, 4770, 4771, 4772, 4773, + 4774, 4775, 4782, 4783, 11500, 4784, 4785, 4786, 4787, 4788, 4789, 4790, + 11501, 11502, 4791, 4792, 11503, 4793, 4794, 4795, 11504, 4796, 4797, 4798, + 4799, 4800, 4801, 4802, 11505, 4803, 4804, 4805, 4806, 11506, 4807, 4814, + 4815, 4816, 4817, 4818, 11507, 11508, 4819, 4820, 11509, 4821, 4822, 4823, + 11510, 4824, 4825, 4826, 4827, 4828, 4829, 4830, 11511, 11512, 4831, 11513, + 4832, 11514, 4833, 4834, 4835, 4836, 4837, 4838, 11515, 11516, 4839, 4840, + 4841, 4842, 4843, 4844, 11517, 4845, 4846, 4847, 4848, 4849, 4850, 4851, + 11518, 4852, 4853, 11519, 4854, 11520, 4855, 4856, 4857, 4858, 4859, 4860, + 11521, 11522, 4861, 4862, 11523, 4863, 4864, 4865, 11524, 11525, 4866, + 4867, 4868, 4869, 4870, 4871, 11526, 11527, 4872, 11528, 4873, 11529, 4874, + 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, + 4887, 4888, 4889, 4890, 4891, 4892, 4893, 4894, 4895, 4896, 4897, 4898, + 4899, 4900, 4901, 4902, 4903, 4904, 4905, 4906, 4907, 11530, 11531, 4908, + 4909, 11532, 4910, 4911, 11533, 11534, 4912, 4913, 4914, 4915, 4916, 4917, + 11535, 11536, 11537, 4918, 11538, 4919, 11539, 4920, 4921, 4922, 4923, + 11540, 4924, 11541, 11542, 4925, 11543, 11544, 4926, 4927, 4928, 11545, + 4929, 4930, 4931, 4932, 4933, 4934, 4935, 11546, 11547, 4936, 4937, 11548, + 11549, 4938, 4939, 4940, 4941, 4942, 11550, 11551, 11552, 4943, 4944, + 11553, 4945, 4946, 4947, 11554, 4948, 4949, 4950, 4951, 4952, 4953, 4954, + 11555, 11556, 4955, 4956, 11557, 11558, 4957, 4958, 4959, 4960, 4961, 4962, + 4963, 4964, 4965, 4972, 4973, 4974, 4975, 4976, 4977, 4978, 4979, 4980, + 4981, 4982, 4983, 4984, 4985, 4986, 4987, 4988, 4989, 11559, 4990, 4991, + 4992, 4993, 4994, 4995, 4996, 4997, 5004, 5005, 5006, 5007, 5008, 5009, + 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020, 5021, + 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 11560, 11561, 5030, 5031, + 11562, 5032, 5033, 5034, 11563, 5035, 11564, 5036, 5037, 5038, 5039, 5040, + 11565, 11566, 5041, 5042, 11567, 11568, 5043, 5044, 5045, 5046, 5047, 5048, + 11569, 5049, 5050, 5051, 11570, 5052, 5053, 5054, 11571, 5055, 5056, 5057, + 5058, 5059, 5060, 5061, 5062, 5063, 5064, 5065, 5066, 5067, 5068, 5069, + 5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 5079, 5080, 5081, + 5082, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 5091, 5092, 5093, + 5094, 5095, 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, + 11572, 5106, 5107, 5108, 5109, 5110, 5111, 5112, 5113, 5114, 5115, 5116, + 5117, 5118, 5119, 5120, 5121, 5122, 5123, 5124, 5125, 5126, 5127, 5128, + 11573, 11574, 5129, 5130, 11575, 5131, 5132, 11576, 11577, 5133, 11578, + 5134, 5135, 5136, 5137, 5138, 11579, 11580, 5139, 5140, 5141, 11581, 5142, + 5143, 5144, 5145, 5146, 5147, 11582, 11583, 5148, 5149, 11584, 5150, 5151, + 5152, 5153, 5154, 5155, 5162, 5163, 5164, 5165, 5166, 5167, 5168, 5169, + 5170, 11585, 5171, 5172, 5173, 5174, 5175, 5176, 5177, 11586, 5178, 5179, + 5180, 5181, 5182, 5183, 5184, 5185, 5186, 5187, 5194, 5195, 5196, 5197, + 5198, 5199, 5200, 5201, 5202, 11587, 5203, 5204, 5205, 5206, 5207, 5208, + 5209, 11588, 5210, 5211, 5212, 11589, 5213, 5214, 5215, 11686, 5216, 5217, + 5218, 5219, 5220, 5221, 5222, 11687, 11688, 5223, 5224, 5225, 5226, 5227, + 5228, 5229, 5230, 5231, 5232, 11689, 5233, 5234, 5235, 5236, 5237, 5238, + 5239, 5240, 5241, 5242, 5243, 5244, 5245, 5246, 5247, 5248, 5249, 5250, + 5251, 5252, 5253, 5254, 5255, 5256, 5257, 5258, 5259, 11690, 11691, 5260, + 5261, 11692, 5262, 5263, 5264, 11693, 5265, 5266, 5267, 5268, 5269, 5270, + 5271, 11694, 11695, 5272, 5273, 5274, 11696, 5275, 5276, 5277, 5278, 5279, + 5280, 11697, 5281, 5282, 5283, 5284, 5285, 5286, 5287, 5288, 5289, 5290, + 5291, 5292, 5293, 5294, 5295, 5296, 5297, 5298, 5299, 11698, 5300, 5301, + 5302, 5303, 5304, 5305, 5306, 11699, 5307, 5308, 5309, 5310, 5311, 5312, + 5313, 5314, 5315, 5316, 5317, 5318, 5319, 5320, 5321, 5322, 5323, 5324, + 5325, 5326, 5327, 5328, 5329, 5330, 5331, 5332, 5333, 11700, 5334, 5335, + 5336, 11701, 5337, 5338, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5352, + 5353, 5354, 5355, 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5363, 5364, + 5365, 5366, 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, 5375, 5376, + 5377, 5384, 5385, 5386, 5387, 5388, 5389, 5390, 5391, 5392, 11702, 5393, + 5394, 5395, 5396, 5397, 5398, 11703, 11704, 5399, 5400, 11705, 5401, 5402, + 5403, 11706, 5404, 11707, 5405, 5406, 5407, 5408, 11708, 11709, 11710, + 5409, 5410, 5411, 5412, 5413, 5414, 5415, 5416, 5417, 5418, 11711, 5419, + 5420, 5421, 11712, 5422, 5423, 5424, 11713, 5425, 5426, 5427, 5428, 5429, + 5430, 5431, 11714, 5432, 5433, 5434, 5435, 5436, 5437, 5438, 5439, 5440, + 5441, 5442, 11715, 11716, 5443, 5444, 11717, 5445, 5446, 5447, 11718, 5448, + 5449, 5450, 5451, 5452, 5453, 5454, 11719, 11720, 5455, 11721, 5456, 11722, + 5457, 5458, 5459, 5460, 5461, 5462, 11723, 11724, 5463, 5464, 11725, 11726, + 11727, 5465, 11728, 11729, 11730, 5466, 5467, 5468, 5469, 11731, 11732, + 11733, 5470, 11734, 11735, 11736, 5471, 5472, 5473, 11737, 11738, 5474, + 11739, 11740, 5475, 5476, 11741, 5477, 5478, 5479, 11742, 5480, 5481, 5482, + 5483, 5484, 5485, 5486, 11743, 11744, 5487, 11745, 11746, 11747, 5488, + 5489, 5490, 5491, 5492, 5493, 11748, 11749, 5494, 5495, 11750, 5496, 5497, + 5498, 11751, 5499, 5500, 11752, 5501, 5502, 5503, 5504, 11753, 11754, 5505, + 11755, 5506, 11756, 5507, 5508, 5509, 11757, 5510, 11758, 11759, 5511, + 5512, 5513, 11760, 5514, 5515, 5516, 11761, 5517, 5518, 5519, 5520, 5521, + 5522, 5523, 5524, 11762, 5525, 5526, 5527, 5528, 5529, 5530, 5531, 5532, + 5533, 5534, 11763, 11764, 5535, 5542, 11765, 11766, 5543, 11767, 11768, + 11769, 11770, 5544, 5545, 5546, 5547, 5548, 11771, 11772, 11773, 11774, + 11775, 11776, 11777, 5549, 11778, 5550, 11779, 5551, 11876, 11877, 5552, + 5553, 11878, 5554, 5555, 5556, 11879, 5557, 5558, 5559, 5560, 5561, 5562, + 5563, 11880, 11881, 5564, 11882, 5565, 11883, 5566, 5567, 5574, 5575, 5576, + 5577, 11884, 11885, 11886, 5578, 11887, 5579, 5580, 5581, 11888, 5582, + 11889, 11890, 5583, 5584, 5585, 5586, 11891, 11892, 11893, 11894, 11895, + 11896, 5587, 5588, 5589, 11897, 11898, 11899, 11900, 5590, 5591, 5592, + 11901, 5593, 5594, 5595, 11902, 5596, 5597, 5598, 5599, 5600, 5601, 5602, + 11903, 11904, 5603, 11905, 11906, 5604, 5605, 5606, 5607, 5608, 5609, 5610, + 11907, 11908, 5611, 5612, 11909, 5613, 5614, 5615, 11910, 11911, 11912, + 5616, 11913, 5617, 5618, 11914, 11915, 11916, 5619, 11917, 5620, 11918, + 5621, 11919, 5622, 5623, 5624, 5625, 11920, 11921, 5626, 5627, 11922, 5628, + 5629, 5630, 11923, 5631, 5632, 5633, 5634, 5635, 5636, 5637, 11924, 11925, + 5638, 11926, 11927, 11928, 5639, 5640, 5641, 5642, 5643, 5644, 11929, + 11930, 5645, 5646, 11931, 5647, 5648, 5649, 5650, 5651, 5652, 5653, 5654, + 5655, 5656, 5657, 11932, 5658, 5659, 11933, 5660, 11934, 5661, 5662, 5663, + 5664, 5665, 5666, 11935, 11936, 5667, 5668, 11937, 5669, 5670, 5671, 11938, + 5672, 5673, 5674, 5675, 5676, 5677, 5678, 11939, 11940, 5679, 11941, 5680, + 11942, 5681, 5682, 5683, 5684, 5685, 5686, 11943, 11944, 5687, 5688, 11945, + 5689, 5690, 5691, 11946, 5692, 5693, 5694, 5695, 5696, 5697, 5698, 11947, + 11948, 5699, 11949, 5700, 11950, 5701, 5702, 5703, 5704, 5705, 5706, 11951, + 11952, 5707, 5708, 11953, 5709, 5710, 5711, 11954, 11955, 11956, 5712, + 5713, 5714, 5715, 5716, 11957, 11958, 5717, 11959, 5718, 11960, 5719, 5720, + 5721, 5722, 5723, 5724, 11961, 11962, 5725, 5732, 11963, 5733, 5734, 5735, + 11964, 5736, 5737, 5738, 5739, 5740, 5741, 5742, 11965, 11966, 5743, 5744, + 11967, 11968, 5745, 5746, 5747, 5748, 5749, 5750, 11969, 12066, 5751, 5752, + 12067, 5753, 5754, 5755, 12068, 5756, 5757, 5764, 5765, 5766, 5767, 5768, + 12069, 12070, 5769, 5770, 5771, 12071, 5772, 5773, 5774, 5775, 5776, 5777, + 12072, 12073, 5778, 5779, 12074, 5780, 5781, 5782, 12075, 5783, 5784, 5785, + 5786, 5787, 5788, 5789, 12076, 12077, 5790, 12078, 5791, 12079, 5792, 5793, + 5794, 5795, 5796, 5797, 12080, 12081, 5798, 5799, 12082, 5800, 5801, 5802, + 12083, 5803, 5804, 5805, 5806, 5807, 5808, 5809, 12084, 12085, 5810, 12086, + 5811, 12087, 5812, 12088, 5813, 5814, 5815, 5816, 12089, 12090, 5817, 5818, + 12091, 5819, 5820, 5821, 12092, 5822, 5823, 5824, 5825, 5826, 12093, 5827, + 12094, 12095, 5828, 12096, 5829, 12097, 12098, 12099, 12100, 12101, 12102, + 12103, 12104, 5830, 5831, 5832, 12105, 5833, 5834, 5835, 12106, 5836, 5837, + 5838, 5839, 5840, 5841, 5842, 12107, 5843, 5844, 12108, 5845, 5846, 5847, + 5848, 5849, 5850, 5851, 5852, 12109, 12110, 5853, 5854, 12111, 5855, 5856, + 5857, 12112, 12113, 12114, 5858, 5859, 5860, 5861, 12115, 12116, 12117, + 5862, 12118, 12119, 12120, 12121, 5863, 5864, 5865, 12122, 5866, 12123, + 12124, 5867, 5868, 12125, 5869, 12126, 12127, 12128, 5870, 12129, 5871, + 5872, 5873, 5874, 5875, 12130, 12131, 5876, 12132, 12133, 12134, 12135, + 5877, 5878, 5879, 5880, 5881, 12136, 12137, 5882, 5883, 12138, 5884, 5885, + 5886, 12139, 5887, 5888, 5889, 5890, 5891, 5892, 5893, 12140, 12141, 5894, + 12142, 12143, 12144, 5895, 5896, 5897, 5898, 5899, 5900, 12145, 12146, + 5901, 5902, 12147, 5903, 12148, 5904, 12149, 5905, 5906, 5907, 5908, 5909, + 5910, 5911, 12150, 5912, 5913, 5914, 5915, 12151, 5922, 5923, 5924, 5925, + 5926, 5927, 12152, 5928, 5929, 5930, 12153, 5931, 5932, 5933, 12154, 5934, + 5935, 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, + 5947, 5954, 5955, 5956, 5957, 5958, 12155, 12156, 5959, 5960, 12157, 5961, + 5962, 5963, 12158, 5964, 12159, 5965, 5966, 5967, 5968, 5969, 12256, 12257, + 5970, 12258, 5971, 12259, 12260, 5972, 5973, 5974, 5975, 5976, 12261, + 12262, 5977, 5978, 12263, 5979, 5980, 5981, 12264, 5982, 5983, 5984, 5985, + 5986, 5987, 5988, 12265, 12266, 5989, 12267, 5990, 12268, 5991, 5992, 5993, + 5994, 5995, 5996, 12269, 5997, 5998, 5999, 12270, 6000, 6001, 6002, 12271, + 6003, 6004, 6005, 6006, 6007, 6008, 6009, 12272, 12273, 6010, 6011, 12274, + 12275, 6012, 6013, 6014, 6015, 6016, 6017, 12276, 6018, 6019, 6020, 6021, + 6022, 6023, 6024, 6025, 6026, 6027, 6028, 6029, 6030, 6031, 6032, 6033, + 6034, 6035, 6036, 6037, 6038, 6039, 6040, 6041, 6042, 6043, 6044, 12277, + 12278, 6045, 6046, 12279, 6047, 6048, 6049, 12280, 6050, 12281, 6051, 6052, + 6053, 6054, 6055, 12282, 12283, 6056, 12284, 6057, 12285, 12286, 12287, + 6058, 6059, 6060, 12288, 12289, 12290, 6061, 6062, 6063, 6064, 6065, 6066, + 12291, 6067, 6068, 6069, 6070, 6071, 6072, 6073, 6074, 12292, 6075, 12293, + 6076, 12294, 6077, 6078, 6079, 6080, 6081, 6082, 12295, 6083, 6084, 6085, + 6086, 6087, 6088, 6089, 6090, 6091, 6092, 6093, 6094, 6095, 6096, 6097, + 6098, 6099, 6100, 6101, 12296, 12297, 6102, 6103, 6104, 6105, 6112, 6113, + 12298, 6114, 6115, 6116, 12299, 6117, 6118, 6119, 12300, 6120, 6121, 6122, + 6123, 6124, 6125, 6126, 12301, 12302, 6127, 12303, 6128, 12304, 6129, 6130, + 6131, 6132, 6133, 6134, 12305, 12306, 6135, 6136, 12307, 6137, 6144, 6145, + 6146, 6147, 6148, 6149, 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, + 6158, 12308, 6159, 6160, 6161, 6162, 6163, 6164, 12309, 12310, 6165, 6166, + 12311, 6167, 6168, 6169, 12312, 12313, 12314, 6170, 6171, 6172, 6173, 6174, + 12315, 12316, 6175, 12317, 6270, 12318, 6271, 6272, 6273, 6274, 6275, 6276, + 12319, 6277, 6278, 6279, 6280, 6281, 6282, 6283, 6284, 6285, 6286, 6287, + 6288, 6289, 6290, 6291, 6292, 6293, 6294, 6295, 12320, 6302, 6303, 6304, + 6305, 6306, 6307, 6308, 12321, 6309, 6310, 6311, 6312, 6313, 6314, 6315, + 6316, 6317, 6318, 6319, 6320, 6321, 6322, 6323, 6324, 6325, 6326, 6327, + 6334, 6335, 6336, 6337, 6338, 6339, 6340, 6341, 12322, 12323, 6342, 6343, + 12324, 6344, 6345, 6346, 12325, 6347, 6348, 6349, 6350, 6351, 6352, 6353, + 12326, 12327, 6354, 12328, 6355, 6356, 6357, 6358, 6359, 6360, 6361, 6362, + 12329, 6363, 6364, 6365, 12330, 6460, 6461, 6462, 12331, 6463, 6464, 6465, + 6466, 6467, 6468, 6469, 12332, 6470, 6471, 6472, 6473, 6474, 6475, 6476, + 6477, 6478, 6479, 6480, 12333, 12334, 6481, 6482, 12335, 6483, 6484, 6485, + 12336, 6492, 6493, 6494, 6495, 6496, 6497, 6498, 12337, 12338, 6499, 12339, + 6500, 12340, 6501, 6502, 6503, 6504, 6505, 6506, 6507, 6508, 6509, 6510, + 6511, 6512, 6513, 6514, 6515, 6516, 6517, 6524, 6525, 6526, 6527, 6528, + 6529, 6530, 6531, 6532, 6533, 6534, 6535, 6536, 6537, 6538, 6539, 6540, + 12341, 12342, 6541, 6542, 12343, 6543, 6544, 12344, 12345, 6545, 12346, + 6546, 6547, 6548, 6549, 6550, 12347, 12348, 6551, 12349, 6552, 12446, + 12447, 6553, 6554, 12448, 12449, 6555, 12450, 12451, 6650, 6651, 12452, + 6652, 12453, 6653, 12454, 6654, 6655, 12455, 6656, 6657, 6658, 6659, 12456, + 12457, 6660, 12458, 12459, 12460, 6661, 6662, 6663, 6664, 6665, 6666, + 12461, 12462, 6667, 6668, 12463, 6669, 6670, 6671, 12464, 6672, 6673, 6674, + 6675, 6682, 6683, 6684, 12465, 12466, 6685, 12467, 12468, 12469, 6686, + 6687, 6688, 6689, 6690, 6691, 12470, 6692, 6693, 6694, 12471, 6695, 6696, + 6697, 6698, 6699, 6700, 6701, 6702, 6703, 6704, 6705, 6706, 6707, 6714, + 6715, 6716, 12472, 6717, 6718, 6719, 6720, 6721, 6722, 6723, 6724, 6725, + 6726, 6727, 6728, 6729, 6730, 6731, 6732, 6733, 6734, 6735, 6736, 6737, + 6738, 6739, 6740, 6741, 6742, 6743, 6744, 6745, 6840, 6841, 6842, 6843, + 6844, 12473, 12474, 6845, 6846, 12475, 6847, 6848, 6849, 12476, 6850, 6851, + 6852, 6853, 6854, 6855, 6856, 12477, 12478, 6857, 12479, 12480, 12481, + 6858, 6859, 6860, 6861, 6862, 6863, 12482, 6864, 6865, 6872, 6873, 6874, + 6875, 6876, 6877, 6878, 6879, 6880, 6881, 6882, 6883, 6884, 6885, 6886, + 6887, 6888, 6889, 12483, 6890, 6891, 6892, 6893, 6894, 6895, 12484, 6896, + 6897, 6904, 6905, 6906, 6907, 6908, 6909, 6910, 6911, 6912, 6913, 6914, + 6915, 6916, 6917, 6918, 6919, 6920, 12485, 6921, 6922, 6923, 6924, 6925, + 6926, 6927, 6928, 6929, 6930, 6931, 6932, 6933, 6934, 6935, 7030, 7031, + 7032, 7033, 7034, 7035, 7036, 7037, 7038, 7039, 7040, 7041, 7042, 7043, + 7044, 7045, 7046, 7047, 7048, 7049, 12486, 12487, 7050, 7051, 12488, 7052, + 7053, 7054, 12489, 7055, 7062, 7063, 7064, 7065, 7066, 7067, 12490, 12491, + 7068, 12492, 7069, 12493, 7070, 12494, 7071, 7072, 7073, 7074, 12495, + 12496, 7075, 7076, 7077, 7078, 7079, 7080, 12497, 7081, 7082, 7083, 7084, + 7085, 7086, 7087, 7094, 7095, 7096, 7097, 12498, 7098, 7099, 7100, 7101, + 7102, 7103, 7104, 12499, 7105, 7106, 7107, 7108, 7109, 7110, 7111, 7112, + 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7122, 7123, 12500, + 7124, 7125, 7220, 7221, 7222, 7223, 7224, 12501, 7225, 7226, 7227, 12502, + 7228, 7229, 7230, 12503, 7231, 7232, 7233, 7234, 7235, 7236, 7237, 12504, + 12505, 7238, 7239, 7240, 7241, 7242, 7243, 7244, 7245, 7252, 7253, 7254, + 7255, 7256, 7257, 7258, 7259, 7260, 7261, 7262, 7263, 7264, 7265, 7266, + 7267, 7268, 7269, 7270, 7271, 7272, 7273, 7274, 12506, 7275, 7276, 7277, + 7284, 7285, 7286, 12507, 12508, 7287, 7288, 12509, 7289, 7290, 7291, 12510, + 7292, 7293, 7294, 7295, 7296, 7297, 7298, 12511, 12512, 7299, 7300, 7301, + 12513, 7302, 7303, 7304, 7305, 7306, 7307, 12514, 7308, 7309, 7310, 7311, + 7312, 7313, 7314, 7315, 7410, 7411, 7412, 7413, 7414, 7415, 7416, 7417, + 7418, 7419, 7420, 12515, 12516, 7421, 7422, 7423, 7424, 7425, 7426, 7427, + 7428, 7429, 7430, 7431, 7432, 7433, 7434, 7435, 7442, 7443, 7444, 7445, + 7446, 7447, 7448, 7449, 7450, 7451, 7452, 7453, 7454, 7455, 7456, 7457, + 7458, 7459, 7460, 12517, 7461, 7462, 7463, 7464, 7465, 7466, 7467, 7474, + 7475, 7476, 7477, 7478, 7479, 7480, 7481, 7482, 7483, 7484, 7485, 7486, + 7487, 7488, 7489, 7490, 7491, 7492, 7493, 12518, 7494, 7495, 7496, 7497, + 7498, 7499, 7500, 7501, 7502, 7503, 7504, 7505, 7600, 7601, 7602, 7603, + 7604, 7605, 7606, 7607, 7608, 7609, 7610, 7611, 7612, 7613, 7614, 12519, + 7615, 7616, 7617, 7618, 7619, 7620, 7621, 7622, 7623, 7624, 7625, 7632, + 7633, 7634, 7635, 12520, 7636, 7637, 12521, 7638, 12522, 7639, 7640, 7641, + 7642, 7643, 7644, 7645, 7646, 7647, 7648, 7649, 7650, 7651, 7652, 7653, + 7654, 7655, 7656, 7657, 7664, 7665, 7666, 7667, 7668, 7669, 7670, 7671, + 7672, 7673, 7674, 7675, 7676, 7677, 7678, 12523, 12524, 7679, 7680, 12525, + 7681, 7682, 7683, 12526, 7684, 7685, 7686, 7687, 7688, 7689, 7690, 12527, + 12528, 7691, 7692, 7693, 12529, 12530, 7694, 7695, 7790, 7791, 12531, + 12532, 12533, 7792, 7793, 12534, 7794, 12535, 7795, 12536, 7796, 7797, + 7798, 7799, 7800, 7801, 7802, 12537, 12538, 7803, 12539, 12636, 12637, + 12638, 7804, 7805, 7806, 7807, 7808, 12639, 12640, 7809, 7810, 12641, 7811, + 7812, 7813, 12642, 7814, 7815, 7822, 7823, 7824, 7825, 7826, 12643, 12644, + 7827, 12645, 12646, 12647, 7828, 7829, 7830, 7831, 7832, 7833, 12648, 7834, + 7835, 7836, 12649, 7837, 12650, 7838, 12651, 7839, 7840, 7841, 7842, 7843, + 7844, 7845, 12652, 7846, 7847, 7854, 7855, 12653, 7856, 7857, 7858, 7859, + 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867, 7868, 7869, 7870, 7871, + 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, + 7884, 7885, 7980, 7981, 7982, 7983, 12654, 12655, 7984, 7985, 12656, 7986, + 7987, 7988, 12657, 7989, 7990, 7991, 7992, 7993, 7994, 7995, 12658, 12659, + 7996, 12660, 12661, 12662, 7997, 7998, 7999, 8000, 8001, 8002, 12663, + 12664, 8003, 8004, 12665, 8005, 8012, 8013, 12666, 8014, 8015, 8016, 8017, + 8018, 8019, 8020, 12667, 12668, 8021, 12669, 8022, 12670, 8023, 8024, 8025, + 8026, 8027, 8028, 12671, 8029, 8030, 8031, 12672, 8032, 8033, 8034, 8035, + 8036, 8037, 8044, 8045, 8046, 8047, 8048, 8049, 8050, 8051, 8052, 12673, + 8053, 8054, 8055, 8056, 8057, 8058, 8059, 12674, 8060, 8061, 8062, 12675, + 8063, 8064, 8065, 8066, 8067, 8068, 8069, 8070, 8071, 8072, 8073, 8074, + 8075, 8170, 8171, 8172, 12676, 8173, 8174, 8175, 8176, 8177, 8178, 12677, + 12678, 8179, 8180, 12679, 8181, 8182, 8183, 12680, 8184, 8185, 8186, 8187, + 8188, 8189, 8190, 12681, 12682, 8191, 12683, 8192, 12684, 8193, 8194, 8195, + 8202, 8203, 8204, 12685, 8205, 8206, 8207, 12686, 8208, 8209, 8210, 12687, + 8211, 8212, 8213, 8214, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, + 12688, 8223, 8224, 8225, 8226, 8227, 8234, 8235, 8236, 8237, 8238, 8239, + 8240, 8241, 8242, 8243, 8244, 8245, 8246, 8247, 8248, 8249, 8250, 8251, + 8252, 8253, 8254, 8255, 8256, 8257, 8258, 8259, 8260, 8261, 8262, 12689, + 8263, 8264, 8265, 12690, 8360, 8361, 8362, 12691, 8363, 8364, 8365, 8366, + 8367, 8368, 8369, 12692, 12693, 8370, 12694, 8371, 12695, 8372, 8373, 8374, + 8375, 8376, 8377, 12696, 8378, 8379, 8380, 8381, 8382, 8383, 8384, 8385, + 8392, 8393, 8394, 8395, 8396, 8397, 8398, 12697, 8399, 8400, 8401, 8402, + 8403, 8404, 8405, 8406, 8407, 8408, 8409, 12698, 12699, 8410, 8411, 12700, + 8412, 8413, 8414, 12701, 8415, 8416, 8417, 8424, 8425, 8426, 8427, 12702, + 12703, 8428, 12704, 8429, 12705, 8430, 8431, 8432, 8433, 8434, 8435, 12706, + 8436, 8437, 8438, 8439, 8440, 8441, 8442, 8443, 8444, 8445, 8446, 8447, + 8448, 8449, 8450, 8451, 8452, 8453, 8454, 12707, 8455, 8550, 8551, 8552, + 8553, 8554, 8555, 12708, 8556, 8557, 8558, 12709, 8559, 8560, 8561, 8562, + 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, + 8575, 8582, 8583, 8584, 8585, 8586, 8587, 12710, 8588, 8589, 8590, 12711, + 8591, 8592, 8593, 12712, 8594, 8595, 8596, 8597, 8598, 8599, 8600, 12713, + 12714, 8601, 12715, 8602, 12716, 8603, 8604, 8605, 8606, 8607, 8614, 12717, + 8615, 8616, 8617, 12718, 8618, 8619, 8620, 12719, 8621, 8622, 8623, 8624, + 8625, 8626, 8627, 12720, 8628, 8629, 8630, 8631, 12721, 8632, 8633, 8634, + 8635, 8636, 8637, 12722, 12723, 8638, 8639, 12724, 8640, 8641, 8642, 12725, + 8643, 8644, 8645, 8740, 8741, 8742, 8743, 12726, 12727, 8744, 12728, 8745, + 12729, 8746, 8747, 8748, 8749, 8750, 8751, 8752, 8753, 8754, 8755, 8756, + 8757, 8758, 8759, 8760, 8761, 8762, 8763, 8764, 8765, 8772, 8773, 8774, + 8775, 8776, 8777, 8778, 8779, 8780, 8781, 8782, 8783, 8784, 8785, 12826, + 12827, 8786, 8787, 12828, 8788, 8789, 12829, 12830, 12831, 8790, 8791, + 8792, 8793, 8794, 8795, 12832, 12833, 8796, 12834, 8797, 12835, 8804, 8805, + 8806, 8807, 8808, 8809, 12836, 12837, 8810, 8811, 12838, 8812, 8813, 8814, + 12839, 8815, 8816, 8817, 8818, 8819, 8820, 8821, 12840, 12841, 8822, 12842, + 8823, 12843, 8824, 8825, 8826, 8827, 8828, 8829, 12844, 12845, 8830, 8831, + 12846, 8832, 8833, 8834, 12847, 8835, 8930, 8931, 8932, 8933, 8934, 8935, + 12848, 12849, 8936, 12850, 12851, 12852, 8937, 8938, 8939, 8940, 8941, + 8942, 12853, 12854, 8943, 8944, 8945, 8946, 8947, 8948, 8949, 8950, 8951, + 8952, 8953, 8954, 8955, 8962, 8963, 8964, 8965, 8966, 8967, 12855, 8968, + 8969, 8970, 8971, 8972, 8973, 8974, 8975, 8976, 8977, 8978, 8979, 8980, + 8981, 8982, 8983, 8984, 8985, 8986, 8987, 8994, 8995, 8996, 8997, 8998, + 8999, 9000, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 12856, 12857, 9008, + 9009, 12858, 9010, 9011, 12859, 12860, 9012, 9013, 9014, 9015, 9016, 9017, + 9018, 12861, 12862, 9019, 12863, 12864, 12865, 9020, 9021, 9022, 9023, + 9024, 9025, 12866, 12867, 9120, 9121, 12868, 9122, 9123, 9124, 12869, 9125, + 9126, 9127, 9128, 9129, 9130, 9131, 12870, 12871, 9132, 12872, 9133, 12873, + 9134, 9135, 9136, 9137, 9138, 9139, 12874, 9140, 9141, 9142, 12875, 9143, + 9144, 9145, 12876, 9152, 9153, 9154, 9155, 9156, 9157, 9158, 12877, 12878, + 9159, 12879, 12880, 12881, 9160, 9161, 9162, 9163, 9164, 9165, 12882, 9166, + 9167, 9168, 9169, 9170, 9171, 9172, 9173, 9174, 9175, 9176, 9177, 9184, + 9185, 9186, 9187, 9188, 9189, 9190, 9191, 9192, 9193, 9194, 9195, 9196, + 9197, 9198, 12883, 12884, 9199, 9200, 12885, 9201, 9202, 9203, 12886, 9204, + 9205, 9206, 9207, 9208, 9209, 9210, 12887, 12888, 9211, 12889, 9212, 12890, + 9213, 9214, 9215, 9310, 9311, 9312, 12891, 12892, 9313, 9314, 12893, 9315, + 9316, 9317, 12894, 9318, 9319, 9320, 9321, 9322, 9323, 9324, 12895, 9325, + 9326, 9327, 9328, 12896, 9329, 9330, 9331, 9332, 9333, 9334, 12897, 9335, + 9342, 9343, 9344, 9345, 9346, 9347, 9348, 9349, 9350, 9351, 9352, 9353, + 9354, 9355, 9356, 9357, 9358, 9359, 9360, 12898, 9361, 9362, 9363, 9364, + 9365, 9366, 12899, 9367, 9374, 9375, 9376, 9377, 9378, 9379, 12900, 9380, + 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, 9391, 9392, + 9393, 9394, 9395, 9396, 9397, 9398, 12901, 9399, 9400, 9401, 9402, 9403, + 9404, 9405, 9500, 9501, 9502, 9503, 9504, 9505, 9506, 9507, 9508, 9509, + 9510, 9511, 9512, 9513, 9514, 9515, 9516, 9517, 9518, 9519, 12902, 12903, + 9520, 9521, 12904, 9522, 9523, 9524, 12905, 9525, 9532, 9533, 9534, 9535, + 9536, 9537, 12906, 12907, 9538, 12908, 9539, 12909, 9540, 9541, 9542, 9543, + 9544, 9545, 12910, 9546, 9547, 9548, 12911, 9549, 9550, 9551, 12912, 9552, + 9553, 9554, 9555, 9556, 9557, 9564, 9565, 9566, 9567, 9568, 9569, 12913, + 9570, 9571, 9572, 9573, 9574, 9575, 12914, 9576, 9577, 9578, 9579, 9580, + 9581, 9582, 9583, 9584, 9585, 9586, 9587, 9588, 9589, 9590, 9591, 9592, + 9593, 9594, 9595, 12915, 9690, 9691, 9692, 9693, 9694, 9695, 12916, 12917, + 9696, 9697, 12918, 9698, 9699, 9700, 12919, 9701, 9702, 9703, 9704, 9705, + 9706, 9707, 13016, 13017, 9708, 13018, 9709, 13019, 9710, 9711, 9712, 9713, + 9714, 9715, 13020, 9722, 9723, 9724, 13021, 9725, 9726, 9727, 13022, 9728, + 9729, 9730, 9731, 9732, 9733, 9734, 13023, 9735, 9736, 9737, 9738, 9739, + 9740, 9741, 9742, 9743, 9744, 9745, 13024, 13025, 9746, 9747, 13026, 9754, + 9755, 9756, 13027, 9757, 9758, 9759, 9760, 9761, 9762, 9763, 13028, 13029, + 9764, 9765, 9766, 13030, 9767, 9768, 9769, 9770, 9771, 9772, 9773, 9774, + 9775, 9776, 9777, 9778, 9779, 9780, 9781, 9782, 9783, 9784, 9785, 9880, + 9881, 9882, 9883, 9884, 9885, 9886, 9887, 9888, 9889, 9890, 9891, 9892, + 9893, 9894, 13031, 13032, 9895, 9896, 13033, 9897, 9898, 9899, 13034, 9900, + 9901, 9902, 9903, 9904, 9905, 9912, 13035, 13036, 9913, 13037, 9914, 13038, + 9915, 9916, 9917, 9918, 9919, 9920, 13039, 13040, 9921, 9922, 13041, 9923, + 9924, 9925, 13042, 13043, 9926, 9927, 9928, 9929, 9930, 9931, 13044, 13045, + 9932, 13046, 13047, 13048, 9933, 9934, 9935, 9936, 9937, 9944, 13049, + 13050, 9945, 9946, 13051, 9947, 9948, 9949, 13052, 9950, 9951, 9952, 9953, + 9954, 9955, 9956, 13053, 13054, 9957, 13055, 13056, 13057, 9958, 9959, + 9960, 9961, 9962, 9963, 13058, 9964, 9965, 9966, 9967, 9968, 9969, 9970, + 9971, 9972, 9973, 9974, 9975, 10070, 10071, 10072, 10073, 10074, 10075, + 10076, 10077, 13059, 10078, 10079, 10080, 10081, 10082, 10083, 10084, + 10085, 10086, 10087, 10088, 10089, 10090, 10091, 10092, 10093, 10094, + 10095, 10102, 10103, 10104, 10105, 10106, 10107, 10108, 10109, 10110, + 10111, 10112, 10113, 10114, 10115, 10116, 10117, 13060, 13061, 10118, + 10119, 13062, 10120, 10121, 10122, 13063, 10123, 13064, 10124, 10125, + 10126, 10127, 10134, 13065, 13066, 10135, 13067, 13068, 13069, 10136, + 10137, 10138, 10139, 10140, 10141, 13070, 13071, 10142, 10143, 13072, + 10144, 10145, 10146, 13073, 10147, 10148, 10149, 10150, 10151, 10152, + 10153, 13074, 13075, 10154, 13076, 10155, 13077, 10156, 10157, 10158, + 10159, 10160, 10161, 13078, 10162, 10163, 10164, 13079, 10165, 10260, + 10261, 10262, 10263, 10264, 10265, 10266, 10267, 10268, 10269, 10270, + 10271, 10272, 10273, 13080, 10274, 10275, 10276, 10277, 10278, 10279, + 10280, 13081, 10281, 10282, 10283, 13082, 10284, 10285, 10292, 10293, + 10294, 10295, 10296, 10297, 10298, 10299, 10300, 10301, 10302, 10303, + 10304, 10305, 10306, 10307, 10308, 10309, 10310, 10311, 10312, 13083, + 13084, 10313, 10314, 13085, 10315, 10316, 10317, 13086, 10324, 10325, + 10326, 10327, 10328, 10329, 10330, 13087, 13088, 10331, 13089, 10332, + 13090, 10333, 10334, 10335, 10336, 13091, 10337, 13092, 10338, 10339, + 10340, 13093, 10341, 10342, 10343, 10344, 10345, 10346, 10347, 10348, + 10349, 10350, 10351, 10352, 10353, 10354, 10355, 10450, 10451, 10452, + 10453, 10454, 10455, 10456, 10457, 13094, 10458, 10459, 10460, 10461, + 10462, 10463, 10464, 10465, 10466, 10467, 10468, 10469, 10470, 10471, + 10472, 10473, 10474, 10475, 10482, 10483, 10484, 10485, 10486, 10487, + 10488, 10489, 10490, 13095, 10491, 10492, 10493, 13096, 10494, 10495, + 10496, 10497, 10498, 10499, 10500, 10501, 10502, 10503, 10504, 10505, + 10506, 10507, 13097, 10514, 13098, 10515, 10516, 10517, 10518, 10519, + 10520, 13099, 10521, 10522, 10523, 10524, 10525, 10526, 10527, 10528, + 10529, 10530, 10531, 10532, 10533, 10534, 10535, 10536, 10537, 10538, + 10539, 10540, 10541, 10542, 10543, 10544, 10545, 10640, 10641, 13100, + 13101, 10642, 10643, 13102, 10644, 10645, 10646, 13103, 10647, 10648, + 10649, 10650, 10651, 10652, 10653, 13104, 13105, 10654, 13106, 10655, + 13107, 10656, 10657, 10658, 10659, 10660, 10661, 13108, 10662, 10663, + 10664, 10665, 10672, 10673, 10674, 10675, 10676, 10677, 10678, 10679, + 10680, 10681, 10682, 10683, 10684, 10685, 10686, 13109, 10687, 10688, + 10689, 10690, 10691, 10692, 10693, 13206, 10694, 10695, 10696, 10697, + 10704, 10705, 10706, 10707, 10708, 10709, 10710, 10711, 10712, 10713, + 10714, 10715, 10716, 10717, 10718, 10719, 10720, 10721, 10722, 10723, + 10724, 10725, 10726, 13207, 13208, 10727, 10728, 13209, 10729, 10730, + 10731, 13210, 10732, 10733, 10734, 10735, 10830, 10831, 10832, 13211, + 13212, 10833, 10834, 10835, 13213, 10836, 10837, 10838, 10839, 10840, + 10841, 13214, 10842, 10843, 10844, 13215, 10845, 10846, 10847, 13216, + 10848, 10849, 10850, 10851, 10852, 10853, 10854, 13217, 10855, 10862, + 10863, 10864, 13218, 10865, 10866, 10867, 10868, 10869, 10870, 13219, + 13220, 10871, 10872, 13221, 10873, 10874, 13222, 13223, 10875, 13224, + 10876, 10877, 10878, 10879, 10880, 13225, 13226, 10881, 13227, 10882, + 10883, 10884, 10885, 10886, 10887, 10894, 10895, 13228, 10896, 10897, + 10898, 13229, 10899, 10900, 10901, 13230, 10902, 10903, 10904, 10905, + 10906, 10907, 10908, 13231, 13232, 10909, 10910, 10911, 10912, 10913, + 10914, 10915, 10916, 10917, 10918, 13233, 13234, 10919, 10920, 13235, + 10921, 10922, 10923, 13236, 10924, 10925, 11020, 11021, 11022, 11023, + 11024, 13237, 13238, 11025, 13239, 11026, 13240, 11027, 11028, 11029, + 11030, 11031, 11032, 13241, 13242, 13243, 11033, 13244, 11034, 11035, + 11036, 13245, 11037, 13246, 11038, 11039, 11040, 11041, 11042, 13247, + 13248, 11043, 13249, 13250, 13251, 11044, 11045, 11052, 13252, 11053, + 11054, 13253, 13254, 11055, 11056, 13255, 11057, 11058, 11059, 13256, + 11060, 11061, 11062, 11063, 11064, 11065, 11066, 13257, 13258, 11067, + 13259, 13260, 13261, 11068, 11069, 11070, 11071, 11072, 11073, 13262, + 13263, 11074, 11075, 11076, 11077, 11084, 11085, 11086, 11087, 11088, + 11089, 11090, 11091, 11092, 11093, 11094, 11095, 11096, 11097, 11098, + 11099, 11100, 11101, 11102, 11103, 11104, 11105, 11106, 11107, 11108, + 11109, 11110, 11111, 11112, 11113, 11114, 11115, 11210, 11211, 11212, + 11213, 11214, 11215, 11216, 11217, 11218, 11219, 11220, 11221, 11222, + 11223, 11224, 11225, 11226, 11227, 13264, 13265, 11228, 11229, 13266, + 11230, 11231, 11232, 13267, 11233, 11234, 11235, 11242, 11243, 11244, + 11245, 13268, 13269, 11246, 13270, 13271, 13272, 11247, 11248, 11249, + 11250, 11251, 11252, 13273, 13274, 11253, 11254, 13275, 11255, 11256, + 11257, 13276, 11258, 11259, 11260, 11261, 11262, 11263, 11264, 13277, + 13278, 11265, 13279, 11266, 13280, 11267, 11274, 11275, 11276, 11277, + 11278, 13281, 11279, 11280, 11281, 13282, 11282, 11283, 11284, 13283, + 11285, 11286, 11287, 11288, 11289, 11290, 11291, 13284, 13285, 11292, + 11293, 13286, 13287, 11294, 11295, 11296, 11297, 11298, 11299, 13288, + 11300, 11301, 11302, 11303, 11304, 11305, 11400, 13289, 11401, 11402, + 11403, 11404, 11405, 11406, 11407, 11408, 13290, 11409, 13291, 11410, + 11411, 11412, 11413, 11414, 11415, 11416, 11417, 13292, 13293, 11418, + 11419, 13294, 11420, 11421, 11422, 13295, 11423, 11424, 11425, 11432, + 11433, 11434, 11435, 13296, 13297, 11436, 13298, 11437, 13299, 11438, + 11439, 11440, 11441, 11442, 11443, 13396, 11444, 11445, 11446, 11447, + 11448, 11449, 11450, 11451, 11452, 11453, 11454, 11455, 11456, 11457, + 11464, 11465, 11466, 11467, 11468, 11469, 13397, 11470, 11471, 11472, + 11473, 11474, 11475, 11476, 11477, 11478, 11479, 11480, 11481, 11482, + 11483, 11484, 11485, 11486, 11487, 11488, 11489, 11490, 11491, 11492, + 11493, 11494, 11495, 11590, 11591, 11592, 11593, 11594, 11595, 11596, + 11597, 13398, 11598, 11599, 11600, 13399, 11601, 11602, 11603, 11604, + 11605, 11606, 11607, 11608, 11609, 11610, 11611, 11612, 11613, 11614, + 11615, 11622, 11623, 11624, 11625, 11626, 11627, 11628, 11629, 13400, + 11630, 11631, 11632, 13401, 11633, 11634, 11635, 13402, 11636, 11637, + 11638, 11639, 11640, 11641, 11642, 11643, 13403, 11644, 13404, 11645, + 11646, 11647, 11654, 11655, 11656, 11657, 11658, 13405, 13406, 11659, + 11660, 13407, 11661, 11662, 13408, 13409, 11663, 13410, 11664, 11665, + 11666, 11667, 11668, 13411, 13412, 11669, 13413, 11670, 13414, 11671, + 11672, 11673, 11674, 11675, 11676, 13415, 11677, 11678, 11679, 11680, + 11681, 11682, 11683, 11684, 11685, 11780, 11781, 11782, 11783, 11784, + 11785, 11786, 11787, 11788, 11789, 11790, 13416, 11791, 11792, 11793, + 11794, 11795, 11796, 11797, 11798, 11799, 11800, 11801, 11802, 11803, + 11804, 11805, 11812, 11813, 11814, 11815, 11816, 11817, 11818, 11819, + 11820, 11821, 11822, 11823, 11824, 11825, 11826, 11827, 11828, 11829, + 11830, 13417, 11831, 11832, 11833, 13418, 11834, 11835, 11836, 13419, + 11837, 11844, 11845, 11846, 11847, 11848, 11849, 13420, 11850, 11851, + 13421, 11852, 11853, 11854, 11855, 11856, 11857, 11858, 11859, 13422, + 11860, 11861, 11862, 13423, 11863, 11864, 11865, 13424, 11866, 11867, + 11868, 11869, 11870, 11871, 11872, 13425, 11873, 11874, 13426, 11875, + 13427, 11970, 11971, 11972, 11973, 11974, 11975, 13428, 11976, 11977, + 11978, 13429, 11979, 11980, 11981, 13430, 11982, 11983, 11984, 11985, + 11986, 11987, 11988, 13431, 13432, 11989, 13433, 11990, 11991, 11992, + 11993, 11994, 11995, 12002, 12003, 12004, 12005, 12006, 12007, 12008, + 12009, 12010, 12011, 12012, 12013, 12014, 12015, 12016, 12017, 12018, + 12019, 12020, 12021, 12022, 12023, 12024, 12025, 12026, 12027, 12034, + 12035, 12036, 12037, 13434, 13435, 12038, 12039, 13436, 12040, 12041, + 12042, 13437, 12043, 12044, 12045, 12046, 12047, 12048, 12049, 13438, + 13439, 12050, 13440, 12051, 13441, 12052, 12053, 12054, 12055, 12056, + 12057, 13442, 13443, 12058, 12059, 13444, 12060, 12061, 12062, 13445, + 12063, 12064, 12065, 12160, 13446, 12161, 12162, 13447, 13448, 12163, + 13449, 12164, 13450, 12165, 12166, 12167, 12168, 12169, 12170, 13451, + 13452, 12171, 12172, 13453, 12173, 12174, 12175, 13454, 12176, 12177, + 12178, 12179, 12180, 12181, 12182, 13455, 13456, 12183, 13457, 13458, + 13459, 12184, 12185, 12192, 12193, 12194, 12195, 13460, 12196, 12197, + 12198, 12199, 12200, 12201, 12202, 12203, 12204, 12205, 12206, 12207, + 12208, 12209, 12210, 12211, 12212, 12213, 12214, 12215, 13461, 12216, + 12217, 12224, 12225, 12226, 12227, 12228, 12229, 12230, 12231, 12232, + 12233, 12234, 12235, 12236, 12237, 12238, 12239, 12240, 12241, 12242, + 12243, 12244, 12245, 12246, 12247, 12248, 12249, 12250, 12251, 12252, + 12253, 12254, 12255, 13462, 13463, 12350, 12351, 13464, 12352, 12353, + 12354, 13465, 12355, 13466, 12356, 12357, 12358, 12359, 12360, 13467, + 13468, 12361, 13469, 12362, 13470, 12363, 12364, 12365, 12366, 12367, + 12368, 13471, 13472, 12369, 12370, 13473, 12371, 12372, 12373, 13474, + 12374, 12375, 12382, 12383, 12384, 12385, 12386, 13475, 13476, 12387, + 13477, 12388, 13478, 12389, 12390, 12391, 12392, 12393, 12394, 13479, + 13480, 12395, 12396, 13481, 12397, 12398, 12399, 13482, 12400, 12401, + 12402, 12403, 12404, 12405, 12406, 13483, 13484, 12407, 13485, 13486, + 13487, 12414, 12415, 12416, 12417, 12418, 12419, 13488, 12420, 12421, + 12422, 13489, 12423, 12424, 12425, 13586, 12426, 12427, 12428, 12429, + 12430, 12431, 12432, 12433, 13587, 12434, 12435, 12436, 12437, 12438, + 12439, 12440, 12441, 12442, 12443, 13588, 13589, 12444, 12445, 13590, + 12540, 12541, 12542, 13591, 12543, 12544, 12545, 12546, 13592, 12547, + 12548, 13593, 13594, 12549, 13595, 12550, 13596, 12551, 12552, 12553, + 13597, 12554, 12555, 13598, 13599, 12556, 12557, 13600, 12558, 12559, + 12560, 13601, 12561, 12562, 12563, 12564, 12565, 12572, 12573, 12574, + 12575, 12576, 13602, 12577, 13603, 12578, 12579, 12580, 12581, 12582, + 12583, 13604, 13605, 12584, 12585, 13606, 12586, 12587, 12588, 12589, + 12590, 12591, 12592, 12593, 12594, 12595, 12596, 12597, 12604, 12605, + 13607, 12606, 13608, 12607, 12608, 12609, 12610, 12611, 12612, 13609, + 13610, 12613, 12614, 13611, 12615, 12616, 12617, 13612, 12618, 12619, + 12620, 12621, 12622, 12623, 12624, 12625, 13613, 12626, 13614, 12627, + 13615, 12628, 12629, 12630, 12631, 12632, 12633, 13616, 12634, 12635, + 12730, 13617, 12731, 12732, 12733, 13618, 12734, 12735, 12736, 12737, + 12738, 12739, 12740, 12741, 13619, 12742, 13620, 12743, 12744, 12745, + 12746, 12747, 12748, 12749, 12750, 13621, 13622, 12751, 12752, 13623, + 12753, 12754, 12755, 13624, 12762, 12763, 12764, 12765, 13625, 12766, + 12767, 13626, 12768, 12769, 13627, 12770, 13628, 12771, 12772, 12773, + 12774, 12775, 12776, 13629, 12777, 12778, 12779, 13630, 12780, 12781, + 12782, 13631, 12783, 12784, 12785, 12786, 12787, 12794, 12795, 13632, + 12796, 12797, 12798, 12799, 13633, 12800, 12801, 12802, 12803, 12804, + 12805, 13634, 13635, 12806, 12807, 13636, 12808, 12809, 12810, 13637, + 12811, 12812, 12813, 12814, 12815, 12816, 12817, 12818, 12819, 12820, + 12821, 12822, 13638, 12823, 12824, 12825, 12920, 12921, 12922, 13639, + 13640, 12923, 12924, 13641, 12925, 12926, 12927, 13642, 12928, 12929, + 12930, 12931, 12932, 12933, 12934, 13643, 13644, 12935, 13645, 12936, + 13646, 12937, 12938, 12939, 12940, 12941, 12942, 13647, 13648, 12943, + 12944, 13649, 12945, 12952, 12953, 13650, 12954, 12955, 12956, 12957, + 12958, 12959, 12960, 13651, 12961, 12962, 13652, 12963, 13653, 12964, + 12965, 12966, 12967, 12968, 12969, 13654, 13655, 12970, 12971, 13656, + 12972, 13657, 13658, 13659, 13660, 12973, 12974, 12975, 12976, 12977, + 12984, 13661, 13662, 12985, 13663, 12986, 13664, 12987, 12988, 12989, + 13665, 12990, 12991, 13666, 12992, 12993, 12994, 13667, 12995, 12996, + 12997, 13668, 12998, 12999, 13000, 13001, 13002, 13003, 13004, 13669, + 13670, 13005, 13006, 13007, 13671, 13008, 13009, 13010, 13011, 13012, + 13013, 13672, 13673, 13014, 13015, 13674, 13110, 13111, 13112, 13675, + 13113, 13114, 13115, 13116, 13117, 13118, 13119, 13676, 13677, 13120, + 13678, 13121, 13679, 13122, 13123, 13124, 13125, 13126, 13127, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14203, 14209, 14226, + 14582, 14607, 14738, 15006, 15107, 15129, 15153, 15166, 15347, 15348, + 15351, 15354, 15355, 15356, 15357, 15358, 15359, 15361, 15362, 15363, + 15364, 15365, 15367, 15368, 15369, 15370, 15372, 15374, 15375, 15377, + 15381, 15385, 15387, 15388, 15389, 15487, 15488, 15492, 15493, 15494, + 15495, 15496, 15498, 15503, 15515, 15519, 15520, 15521, 15523, 15524, + 15525, 15526, 15527, 15528, 15530, 15531, 15532, 15533, 15534, 15535, + 15536, 15537, 15538, 15539, 15540, 15542, 15543, 15547, 15548, 15550, + 15551, 15553, 15554, 15555, 15556, 15557, 15558, 15559, 15560, 15565, + 15566, 15567, 15568, 15569, 15570, 15572, 15573, 15935, 15957, 16060, + 16066, 16069, 16269, 16290, 16478, 16503, 17232, 17263, 17390, 17580, + 17628, 17659, 17857, 17859, 17974, 18020, 18027, 18226, 18348, 18412, + 18800, 18906, 18914, 19109, 19112, 19113, 19120, 19122, 19123, 19131, + 19141, 19143, 19145, 19149, 19185, 19186, 19187, 19189, 19286, 19289, + 19292, 19298, 19300, 19301, 19302, 19304, 19308, 19309, 19313, 19321, + 19323, 19324, 19327, 19335, 19339, 19342, 19345, 19348, 19350, 19353, + 19354, 19355, 19357, 19359, 19360, 19361, 19364, 19366, 19367, 19370, + 19371, 19372, 19374, 19476, 19481, 19484, 19485, 19487, 19488, 19491, + 19506, 19508, 19513, 19514, 19518, 19520, 19522, 19523, 19526, 19538, + 19543, 19545, 19562, 19736, 19737, 19745, 19746, 19752, 19754, 19756, + 19759, 19862, 19867, 19899, 19942, 20078, 20114, 20129, 20132, 20137, + 20139, 20239, 20242, 20244, 20245, 20261, 20262, 20264, 20268, 20269, + 20273, 20274, 20279, 20282, 20283, 20284, 20285, 20291, 20431, 20432, + 20435, 20440, 20441, 20442, 20443, 20446, 20449, 20451, 20457, 20458, + 20462, 20463, 20466, 20467, 20478, 20486, 20487, 20490, 20493, 20496, + 20497, 20512, 20513, 20515, 20616, 20617, 20618, 20693, 20864, 21594, + 21655, 21772, 21952, 22023, 22409, 22411, 22539, 22555, 22566, 22764, + 22785, 23086, 23087, 23155, 23474, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6556, 6557, 6558, 6559, 6560, + 6561, 6562, 6563, 6564, 6565, 6566, 6567, 6568, 6569, 6570, 6571, 6572, + 6573, 6574, 6575, 6576, 6577, 6578, 6579, 6580, 6581, 6582, 6583, 6584, + 6585, 6586, 6587, 6588, 6589, 6590, 6591, 6592, 6593, 6594, 6595, 6596, + 6597, 6598, 6599, 6600, 6601, 6602, 6603, 6604, 6605, 6606, 6607, 6608, + 6609, 6610, 6611, 6612, 6613, 6614, 6187, 6616, 6617, 6618, 6619, 6620, + 6621, 6622, 6623, 6624, 6625, 6626, 6627, 6628, 6629, 6630, 6631, 6632, + 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, + 6645, 6646, 6647, 6648, 6371, 65535, 6218, 6219, 6269, 6649, 65535, 6220, + 6615, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 64, 96, 128, 160, 192, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 256, 0, 0, 0, 0, 0, 288, 320, 352, 0, 384, 416, 448, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 512, 0, 544, 576, 608, 0, + 0, 640, 672, 704, 736, 768, 0, 800, 0, 832, 864, 896, 928, 960, 992, 0, 0, + 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1056, 1088, 1120, 1152, 1184, 1216, + 1248, 1280, 0, 1312, 1344, 1376, 0, 1408, 0, 1440, 1472, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1504, 0, 1536, + 1568, 1600, 1632, 1664, 1696, 0, 1728, 1760, 1792, 1824, 0, 0, 0, 1856, 0, + 0, 1888, 0, 0, 0, 0, 0, 0, 0, 0, 1920, 1952, 1984, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2016, 2048, 2080, 2112, 2144, 2176, 2208, 2240, 2272, 2304, 2336, 2368, + 2400, 2432, 2464, 2496, 2528, 2560, 2592, 2624, 2656, 2688, 2720, 2752, + 2784, 2816, 2848, 2880, 2912, 2944, 2976, 3008, 3040, 3072, 3104, 3136, + 3168, 3200, 3232, 3264, 3296, 3328, 3360, 3392, 3424, 3456, 3488, 3520, + 3552, 3584, 3616, 3648, 3680, 3712, 3744, 3776, 3808, 3840, 3872, 3904, + 3936, 3968, 4000, 4032, 4064, 4096, 4128, 4160, 4192, 4224, 4256, 4288, + 4320, 4352, 4384, 4416, 4448, 4480, 4512, 4544, 4576, 4608, 4640, 4672, + 4704, 4736, 4768, 4800, 4832, 4864, 4896, 4928, 4960, 4992, 5024, 5056, + 5088, 5120, 5152, 5184, 5216, 5248, 5280, 5312, 5344, 5376, 5408, 5440, + 5472, 5504, 5536, 5568, 5600, 5632, 5664, 5696, 5728, 5760, 5792, 5824, + 5856, 5888, 5920, 5952, 5984, 6016, 6048, 6080, 6112, 6144, 6176, 6208, + 6240, 6272, 6304, 6336, 6368, 6400, 6432, 6464, 6496, 6528, 6560, 6592, + 6624, 6656, 6688, 6720, 6752, 6784, 6816, 6848, 6880, 6912, 6944, 6976, + 7008, 7040, 7072, 7104, 7136, 7168, 7200, 7232, 7264, 7296, 7328, 7360, + 7392, 7424, 7456, 7488, 7520, 7552, 7584, 7616, 7648, 7680, 7712, 7744, + 7776, 7808, 7840, 7872, 7904, 7936, 7968, 8000, 8032, 8064, 8096, 8128, + 8160, 8192, 8224, 8256, 8288, 8320, 8352, 8384, 8416, 8448, 8480, 8512, + 8544, 8576, 8608, 8640, 8672, 8704, 8736, 8768, 8800, 8832, 8864, 8896, + 8928, 8960, 8992, 9024, 9056, 9088, 9120, 9152, 9184, 9216, 9248, 9280, + 9312, 9344, 9376, 9408, 9440, 9472, 9504, 9536, 9568, 9600, 9632, 9664, + 9696, 9728, 9760, 9792, 9824, 9856, 9888, 9920, 9952, 9984, 10016, 10048, + 10080, 10112, 10144, 10176, 10208, 10240, 10272, 10304, 10336, 10368, + 10400, 10432, 10464, 10496, 10528, 10560, 10592, 10624, 10656, 10688, + 10720, 10752, 10784, 10816, 10848, 10880, 10912, 10944, 10976, 11008, + 11040, 11072, 11104, 11136, 11168, 11200, 11232, 11264, 11296, 11328, + 11360, 11392, 11424, 11456, 11488, 11520, 11552, 11584, 11616, 11648, + 11680, 11712, 11744, 11776, 11808, 11840, 11872, 11904, 11936, 11968, + 12000, 12032, 12064, 12096, 12128, 12160, 12192, 12224, 12256, 12288, + 12320, 12352, 12384, 12416, 12448, 12480, 12512, 12544, 12576, 12608, + 12640, 12672, 12704, 12736, 12768, 12800, 12832, 12864, 12896, 12928, + 12960, 12992, 13024, 13056, 13088, 13120, 13152, 13184, 13216, 13248, + 13280, 13312, 13344, 13376, 13408, 13440, 13472, 13504, 13536, 13568, + 13600, 13632, 13664, 13696, 13728, 13760, 13792, 13824, 13856, 13888, + 13920, 13952, 13984, 14016, 14048, 14080, 14112, 14144, 14176, 14208, + 14240, 14272, 14304, 14336, 14368, 14400, 14432, 0, 0, 0, 0, 14464, 14496, + 14528, 14560, 14592, 14624, 14656, 14688, 14720, 14752, 14784, 14816, + 14848, 14880, 14912, 14944, 14976, 15008, 15040, 15072, 15104, 15136, + 15168, 15200, 15232, 15264, 15296, 15328, 15360, 15392, 15424, 15456, + 15488, 15520, 15552, 15584, 15616, 15648, 15680, 15712, 15744, 15776, + 15808, 15840, 15872, 15904, 15936, 15968, 16000, 16032, 16064, 16096, + 16128, 16160, 16192, 16224, 16256, 16288, 16320, 16352, 16384, 16416, + 16448, 16480, 0, 16512, 16544, 16576, 16608, 16640, 16672, 16704, 16736, + 16768, 16800, 16832, 16864, 16896, 16928, 16960, 16992, 17024, 17056, + 17088, 17120, 17152, 17184, 17216, 17248, 17280, 17312, 17344, 17376, + 17408, 17440, 17472, 17504, 17536, 17568, 17600, 0, 0, 0, 0, 17632, 17664, + 17696, 17728, 17760, 17792, 17824, 17856, 0, 0, 17888, 17920, 17952, 17984, + 18016, 18048, 18080, 18112, 18144, 18176, 18208, 18240, 18272, 18304, + 18336, 18368, 18400, 18432, 18464, 18496, 18528, 18560, 18592, 18624, + 18656, 18688, 18720, 18752, 18784, 18816, 18848, 18880, 18912, 18944, + 18976, 19008, 19040, 19072, 19104, 19136, 19168, 19200, 19232, 19264, + 19296, 19328, 19360, 19392, 19424, 19456, 19488, 19520, 19552, 19584, + 19616, 19648, 19680, 0, 0, 0, 0, 0, 0, 0, 19712, 19744, 19776, 19808, + 19840, 19872, 19904, 19936, 19968, 20000, 20032, 20064, 20096, 20128, + 20160, 20192, 20224, 20256, 20288, 20320, 20352, 20384, 20416, 20448, + 20480, 0, 20512, 20544, 20576, 20608, 20640, 20672, 0, 20704, 20736, 20768, + 20800, 20832, 20864, 20896, 20928, 0, 20960, 20992, 21024, 21056, 21088, + 21120, 21152, 21184, 21216, 21248, 21280, 21312, 21344, 21376, 0, 0, 0, 0, + 21408, 21440, 21472, 21504, 21536, 0, 21568, 21600, 21632, 21664, 0, 0, + 21696, 21728, 21760, 21792, 21824, 21856, 21888, 21920, 21952, 21984, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22016, + 22048, 22080, 22112, 22144, 22176, 22208, 22240, 22272, 22304, 22336, + 22368, 22400, 22432, 22464, 22496, 22528, 22560, 22592, 22624, 22656, + 22688, 22720, 22752, 22784, 22816, 22848, 22880, 22912, 22944, 22976, + 23008, 23040, 23072, 23104, 23136, 23168, 23200, 23232, 23264, 23296, + 23328, 23360, 23392, 23424, 23456, 23488, 23520, 23552, 23584, 23616, + 23648, 23680, 23712, 23744, 23776, 23808, 23840, 23872, 23904, 23936, + 23968, 24000, 24032, 24064, 24096, 24128, 24160, 24192, 24224, 24256, + 24288, 24320, 24352, 24384, 24416, 24448, 24480, 24512, 24544, 24576, + 24608, 24640, 24672, 24704, 24736, 24768, 24800, 24832, 24864, 24896, + 24928, 24960, 24992, 25024, 25056, 25088, 25120, 25152, 25184, 25216, + 25248, 25280, 25312, 25344, 25376, 25408, 25440, 25472, 25504, 25536, + 25568, 25600, 25632, 25664, 25696, 25728, 25760, 25792, 25824, 25856, + 25888, 25920, 25952, 25984, 26016, 26048, 26080, 26112, 26144, 26176, + 26208, 26240, 26272, 26304, 26336, 26368, 26400, 26432, 26464, 26496, + 26528, 26560, 26592, 26624, 26656, 26688, 26720, 26752, 26784, 26816, + 26848, 26880, 26912, 26944, 26976, 27008, 27040, 27072, 27104, 27136, + 27168, 27200, 27232, 27264, 27296, 27328, 27360, 27392, 27424, 27456, + 27488, 27520, 27552, 27584, 27616, 27648, 27680, 27712, 27744, 27776, + 27808, 27840, 27872, 27904, 27936, 27968, 28000, 28032, 28064, 28096, + 28128, 28160, 28192, 28224, 28256, 28288, 28320, 28352, 28384, 28416, + 28448, 28480, 28512, 28544, 28576, 28608, 28640, 28672, 28704, 28736, + 28768, 28800, 28832, 28864, 28896, 28928, 28960, 28992, 29024, 29056, + 29088, 29120, 29152, 29184, 29216, 29248, 29280, 29312, 29344, 29376, + 29408, 29440, 29472, 29504, 29536, 29568, 29600, 29632, 29664, 29696, + 29728, 29760, 29792, 29824, 29856, 29888, 29920, 29952, 29984, 30016, + 30048, 30080, 30112, 30144, 30176, 30208, 30240, 30272, 30304, 30336, + 30368, 30400, 30432, 30464, 30496, 30528, 30560, 30592, 30624, 30656, + 30688, 30720, 30752, 30784, 30816, 30848, 30880, 30912, 30944, 30976, + 31008, 31040, 31072, 31104, 31136, 31168, 31200, 31232, 31264, 31296, + 31328, 31360, 31392, 31424, 31456, 31488, 31520, 31552, 31584, 31616, + 31648, 31680, 31712, 31744, 31776, 31808, 31840, 31872, 31904, 31936, + 31968, 32000, 32032, 32064, 32096, 32128, 32160, 32192, 32224, 32256, + 32288, 32320, 32352, 32384, 32416, 32448, 32480, 32512, 32544, 32576, + 32608, 32640, 32672, 32704, 32736, 32768, 32800, 32832, 32864, 32896, + 32928, 32960, 32992, 33024, 33056, 33088, 33120, 33152, 33184, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33216, 33248, 33280, 33312, 33344, + 33376, 33408, 33440, 33472, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33504, + 33536, 33568, 0, 0, 0, 0, 33600, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u16 { + let offset = (code >> 5) as usize; + let offset = if offset < 2048 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +multi_byte_tests!( + mod = euc_kr, + dups = [] +); diff --git a/deps/encoding-index-korean-1.20141219.5/lib.rs b/deps/encoding-index-korean-1.20141219.5/lib.rs new file mode 100644 index 000000000..857e40341 --- /dev/null +++ b/deps/encoding-index-korean-1.20141219.5/lib.rs @@ -0,0 +1,21 @@ +// This is a part of rust-encoding. +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ + +//! Korean index tables for [rust-encoding](https://github.com/lifthrasiir/rust-encoding). + +#![cfg_attr(test, feature(test))] + +#[cfg(test)] +#[macro_use] +extern crate encoding_index_tests; + +/// KS X 1001 plus Unified Hangul Code. +/// +/// From the Encoding Standard: +/// +/// > This matches the KS X 1001 standard and the Unified Hangul Code, +/// > more commonly known together as Windows Codepage 949. +pub mod euc_kr; + diff --git a/deps/encoding-index-simpchinese-1.20141219.5/Cargo.toml b/deps/encoding-index-simpchinese-1.20141219.5/Cargo.toml new file mode 100644 index 000000000..cf08d2425 --- /dev/null +++ b/deps/encoding-index-simpchinese-1.20141219.5/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "encoding-index-simpchinese" +version = "1.20141219.5" +authors = ["Kang Seonghoon "] + +description = "Index tables for simplified Chinese character encodings" +homepage = "https://github.com/lifthrasiir/rust-encoding" +readme = "../../../README.md" +license = "CC0-1.0" + +[lib] +name = "encoding_index_simpchinese" +path = "lib.rs" + +[dependencies.encoding_index_tests] +# TODO consider using dev-dependencies instead (Cargo issue #860) +version = "0.1.4" +path = "../tests" diff --git a/deps/encoding-index-simpchinese-1.20141219.5/gb18030.rs b/deps/encoding-index-simpchinese-1.20141219.5/gb18030.rs new file mode 100644 index 000000000..fdee2033a --- /dev/null +++ b/deps/encoding-index-simpchinese-1.20141219.5/gb18030.rs @@ -0,0 +1,4983 @@ +// AUTOGENERATED FROM index-gb18030.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-gb18030.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 7cc86532fd6516482e5b36c2aab29dcce5d67ebdef05b291f0ff52736172934b +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 19970, 19972, 19973, 19974, 19983, 19986, 19991, 19999, 20000, 20001, + 20003, 20006, 20009, 20014, 20015, 20017, 20019, 20021, 20023, 20028, + 20032, 20033, 20034, 20036, 20038, 20042, 20049, 20053, 20055, 20058, + 20059, 20066, 20067, 20068, 20069, 20071, 20072, 20074, 20075, 20076, + 20077, 20078, 20079, 20082, 20084, 20085, 20086, 20087, 20088, 20089, + 20090, 20091, 20092, 20093, 20095, 20096, 20097, 20098, 20099, 20100, + 20101, 20103, 20106, 20112, 20118, 20119, 20121, 20124, 20125, 20126, + 20131, 20138, 20143, 20144, 20145, 20148, 20150, 20151, 20152, 20153, + 20156, 20157, 20158, 20168, 20172, 20175, 20176, 20178, 20186, 20187, + 20188, 20192, 20194, 20198, 20199, 20201, 20205, 20206, 20207, 20209, + 20212, 20216, 20217, 20218, 20220, 20222, 20224, 20226, 20227, 20228, + 20229, 20230, 20231, 20232, 20235, 20236, 20242, 20243, 20244, 20245, + 20246, 20252, 20253, 20257, 20259, 20264, 20265, 20268, 20269, 20270, + 20273, 20275, 20277, 20279, 20281, 20283, 20286, 20287, 20288, 20289, + 20290, 20292, 20293, 20295, 20296, 20297, 20298, 20299, 20300, 20306, + 20308, 20310, 20321, 20322, 20326, 20328, 20330, 20331, 20333, 20334, + 20337, 20338, 20341, 20343, 20344, 20345, 20346, 20349, 20352, 20353, + 20354, 20357, 20358, 20359, 20362, 20364, 20366, 20368, 20370, 20371, + 20373, 20374, 20376, 20377, 20378, 20380, 20382, 20383, 20385, 20386, + 20388, 20395, 20397, 20400, 20401, 20402, 20403, 20404, 20406, 20407, + 20408, 20409, 20410, 20411, 20412, 20413, 20414, 20416, 20417, 20418, + 20422, 20423, 20424, 20425, 20427, 20428, 20429, 20434, 20435, 20436, + 20437, 20438, 20441, 20443, 20448, 20450, 20452, 20453, 20455, 20459, + 20460, 20464, 20466, 20468, 20469, 20470, 20471, 20473, 20475, 20476, + 20477, 20479, 20480, 20481, 20482, 20483, 20484, 20485, 20486, 20487, + 20488, 20489, 20490, 20491, 20494, 20496, 20497, 20499, 20501, 20502, + 20503, 20507, 20509, 20510, 20512, 20514, 20515, 20516, 20519, 20523, + 20527, 20528, 20529, 20530, 20531, 20532, 20533, 20534, 20535, 20536, + 20537, 20539, 20541, 20543, 20544, 20545, 20546, 20548, 20549, 20550, + 20553, 20554, 20555, 20557, 20560, 20561, 20562, 20563, 20564, 20566, + 20567, 20568, 20569, 20571, 20573, 20574, 20575, 20576, 20577, 20578, + 20579, 20580, 20582, 20583, 20584, 20585, 20586, 20587, 20589, 20590, + 20591, 20592, 20593, 20594, 20595, 20596, 20597, 20600, 20601, 20602, + 20604, 20605, 20609, 20610, 20611, 20612, 20614, 20615, 20617, 20618, + 20619, 20620, 20622, 20623, 20624, 20625, 20626, 20627, 20628, 20629, + 20630, 20631, 20632, 20633, 20634, 20635, 20636, 20637, 20638, 20639, + 20640, 20641, 20642, 20644, 20646, 20650, 20651, 20653, 20654, 20655, + 20656, 20657, 20659, 20660, 20661, 20662, 20663, 20664, 20665, 20668, + 20669, 20670, 20671, 20672, 20673, 20674, 20675, 20676, 20677, 20678, + 20679, 20680, 20681, 20682, 20683, 20684, 20685, 20686, 20688, 20689, + 20690, 20691, 20692, 20693, 20695, 20696, 20697, 20699, 20700, 20701, + 20702, 20703, 20704, 20705, 20706, 20707, 20708, 20709, 20712, 20713, + 20714, 20715, 20719, 20720, 20721, 20722, 20724, 20726, 20727, 20728, + 20729, 20730, 20732, 20733, 20734, 20735, 20736, 20737, 20738, 20739, + 20740, 20741, 20744, 20745, 20746, 20748, 20749, 20750, 20751, 20752, + 20753, 20755, 20756, 20757, 20758, 20759, 20760, 20761, 20762, 20763, + 20764, 20765, 20766, 20767, 20768, 20770, 20771, 20772, 20773, 20774, + 20775, 20776, 20777, 20778, 20779, 20780, 20781, 20782, 20783, 20784, + 20785, 20786, 20787, 20788, 20789, 20790, 20791, 20792, 20793, 20794, + 20795, 20796, 20797, 20798, 20802, 20807, 20810, 20812, 20814, 20815, + 20816, 20818, 20819, 20823, 20824, 20825, 20827, 20829, 20830, 20831, + 20832, 20833, 20835, 20836, 20838, 20839, 20841, 20842, 20847, 20850, + 20858, 20862, 20863, 20867, 20868, 20870, 20871, 20874, 20875, 20878, + 20879, 20880, 20881, 20883, 20884, 20888, 20890, 20893, 20894, 20895, + 20897, 20899, 20902, 20903, 20904, 20905, 20906, 20909, 20910, 20916, + 20920, 20921, 20922, 20926, 20927, 20929, 20930, 20931, 20933, 20936, + 20938, 20941, 20942, 20944, 20946, 20947, 20948, 20949, 20950, 20951, + 20952, 20953, 20954, 20956, 20958, 20959, 20962, 20963, 20965, 20966, + 20967, 20968, 20969, 20970, 20972, 20974, 20977, 20978, 20980, 20983, + 20990, 20996, 20997, 21001, 21003, 21004, 21007, 21008, 21011, 21012, + 21013, 21020, 21022, 21023, 21025, 21026, 21027, 21029, 21030, 21031, + 21034, 21036, 21039, 21041, 21042, 21044, 21045, 21052, 21054, 21060, + 21061, 21062, 21063, 21064, 21065, 21067, 21070, 21071, 21074, 21075, + 21077, 21079, 21080, 21081, 21082, 21083, 21085, 21087, 21088, 21090, + 21091, 21092, 21094, 21096, 21099, 21100, 21101, 21102, 21104, 21105, + 21107, 21108, 21109, 21110, 21111, 21112, 21113, 21114, 21115, 21116, + 21118, 21120, 21123, 21124, 21125, 21126, 21127, 21129, 21130, 21131, + 21132, 21133, 21134, 21135, 21137, 21138, 21140, 21141, 21142, 21143, + 21144, 21145, 21146, 21148, 21156, 21157, 21158, 21159, 21166, 21167, + 21168, 21172, 21173, 21174, 21175, 21176, 21177, 21178, 21179, 21180, + 21181, 21184, 21185, 21186, 21188, 21189, 21190, 21192, 21194, 21196, + 21197, 21198, 21199, 21201, 21203, 21204, 21205, 21207, 21209, 21210, + 21211, 21212, 21213, 21214, 21216, 21217, 21218, 21219, 21221, 21222, + 21223, 21224, 21225, 21226, 21227, 21228, 21229, 21230, 21231, 21233, + 21234, 21235, 21236, 21237, 21238, 21239, 21240, 21243, 21244, 21245, + 21249, 21250, 21251, 21252, 21255, 21257, 21258, 21259, 21260, 21262, + 21265, 21266, 21267, 21268, 21272, 21275, 21276, 21278, 21279, 21282, + 21284, 21285, 21287, 21288, 21289, 21291, 21292, 21293, 21295, 21296, + 21297, 21298, 21299, 21300, 21301, 21302, 21303, 21304, 21308, 21309, + 21312, 21314, 21316, 21318, 21323, 21324, 21325, 21328, 21332, 21336, + 21337, 21339, 21341, 21349, 21352, 21354, 21356, 21357, 21362, 21366, + 21369, 21371, 21372, 21373, 21374, 21376, 21377, 21379, 21383, 21384, + 21386, 21390, 21391, 21392, 21393, 21394, 21395, 21396, 21398, 21399, + 21401, 21403, 21404, 21406, 21408, 21409, 21412, 21415, 21418, 21419, + 21420, 21421, 21423, 21424, 21425, 21426, 21427, 21428, 21429, 21431, + 21432, 21433, 21434, 21436, 21437, 21438, 21440, 21443, 21444, 21445, + 21446, 21447, 21454, 21455, 21456, 21458, 21459, 21461, 21466, 21468, + 21469, 21470, 21473, 21474, 21479, 21492, 21498, 21502, 21503, 21504, + 21506, 21509, 21511, 21515, 21524, 21528, 21529, 21530, 21532, 21538, + 21540, 21541, 21546, 21552, 21555, 21558, 21559, 21562, 21565, 21567, + 21569, 21570, 21572, 21573, 21575, 21577, 21580, 21581, 21582, 21583, + 21585, 21594, 21597, 21598, 21599, 21600, 21601, 21603, 21605, 21607, + 21609, 21610, 21611, 21612, 21613, 21614, 21615, 21616, 21620, 21625, + 21626, 21630, 21631, 21633, 21635, 21637, 21639, 21640, 21641, 21642, + 21645, 21649, 21651, 21655, 21656, 21660, 21662, 21663, 21664, 21665, + 21666, 21669, 21678, 21680, 21682, 21685, 21686, 21687, 21689, 21690, + 21692, 21694, 21699, 21701, 21706, 21707, 21718, 21720, 21723, 21728, + 21729, 21730, 21731, 21732, 21739, 21740, 21743, 21744, 21745, 21748, + 21749, 21750, 21751, 21752, 21753, 21755, 21758, 21760, 21762, 21763, + 21764, 21765, 21768, 21770, 21771, 21772, 21773, 21774, 21778, 21779, + 21781, 21782, 21783, 21784, 21785, 21786, 21788, 21789, 21790, 21791, + 21793, 21797, 21798, 21800, 21801, 21803, 21805, 21810, 21812, 21813, + 21814, 21816, 21817, 21818, 21819, 21821, 21824, 21826, 21829, 21831, + 21832, 21835, 21836, 21837, 21838, 21839, 21841, 21842, 21843, 21844, + 21847, 21848, 21849, 21850, 21851, 21853, 21854, 21855, 21856, 21858, + 21859, 21864, 21865, 21867, 21871, 21872, 21873, 21874, 21875, 21876, + 21881, 21882, 21885, 21887, 21893, 21894, 21900, 21901, 21902, 21904, + 21906, 21907, 21909, 21910, 21911, 21914, 21915, 21918, 21920, 21921, + 21922, 21923, 21924, 21925, 21926, 21928, 21929, 21930, 21931, 21932, + 21933, 21934, 21935, 21936, 21938, 21940, 21942, 21944, 21946, 21948, + 21951, 21952, 21953, 21954, 21955, 21958, 21959, 21960, 21962, 21963, + 21966, 21967, 21968, 21973, 21975, 21976, 21977, 21978, 21979, 21982, + 21984, 21986, 21991, 21993, 21997, 21998, 22000, 22001, 22004, 22006, + 22008, 22009, 22010, 22011, 22012, 22015, 22018, 22019, 22020, 22021, + 22022, 22023, 22026, 22027, 22029, 22032, 22033, 22034, 22035, 22036, + 22037, 22038, 22039, 22041, 22042, 22044, 22045, 22048, 22049, 22050, + 22053, 22054, 22056, 22057, 22058, 22059, 22062, 22063, 22064, 22067, + 22069, 22071, 22072, 22074, 22076, 22077, 22078, 22080, 22081, 22082, + 22083, 22084, 22085, 22086, 22087, 22088, 22089, 22090, 22091, 22095, + 22096, 22097, 22098, 22099, 22101, 22102, 22106, 22107, 22109, 22110, + 22111, 22112, 22113, 22115, 22117, 22118, 22119, 22125, 22126, 22127, + 22128, 22130, 22131, 22132, 22133, 22135, 22136, 22137, 22138, 22141, + 22142, 22143, 22144, 22145, 22146, 22147, 22148, 22151, 22152, 22153, + 22154, 22155, 22156, 22157, 22160, 22161, 22162, 22164, 22165, 22166, + 22167, 22168, 22169, 22170, 22171, 22172, 22173, 22174, 22175, 22176, + 22177, 22178, 22180, 22181, 22182, 22183, 22184, 22185, 22186, 22187, + 22188, 22189, 22190, 22192, 22193, 22194, 22195, 22196, 22197, 22198, + 22200, 22201, 22202, 22203, 22205, 22206, 22207, 22208, 22209, 22210, + 22211, 22212, 22213, 22214, 22215, 22216, 22217, 22219, 22220, 22221, + 22222, 22223, 22224, 22225, 22226, 22227, 22229, 22230, 22232, 22233, + 22236, 22243, 22245, 22246, 22247, 22248, 22249, 22250, 22252, 22254, + 22255, 22258, 22259, 22262, 22263, 22264, 22267, 22268, 22272, 22273, + 22274, 22277, 22279, 22283, 22284, 22285, 22286, 22287, 22288, 22289, + 22290, 22291, 22292, 22293, 22294, 22295, 22296, 22297, 22298, 22299, + 22301, 22302, 22304, 22305, 22306, 22308, 22309, 22310, 22311, 22315, + 22321, 22322, 22324, 22325, 22326, 22327, 22328, 22332, 22333, 22335, + 22337, 22339, 22340, 22341, 22342, 22344, 22345, 22347, 22354, 22355, + 22356, 22357, 22358, 22360, 22361, 22370, 22371, 22373, 22375, 22380, + 22382, 22384, 22385, 22386, 22388, 22389, 22392, 22393, 22394, 22397, + 22398, 22399, 22400, 22401, 22407, 22408, 22409, 22410, 22413, 22414, + 22415, 22416, 22417, 22420, 22421, 22422, 22423, 22424, 22425, 22426, + 22428, 22429, 22430, 22431, 22437, 22440, 22442, 22444, 22447, 22448, + 22449, 22451, 22453, 22454, 22455, 22457, 22458, 22459, 22460, 22461, + 22462, 22463, 22464, 22465, 22468, 22469, 22470, 22471, 22472, 22473, + 22474, 22476, 22477, 22480, 22481, 22483, 22486, 22487, 22491, 22492, + 22494, 22497, 22498, 22499, 22501, 22502, 22503, 22504, 22505, 22506, + 22507, 22508, 22510, 22512, 22513, 22514, 22515, 22517, 22518, 22519, + 22523, 22524, 22526, 22527, 22529, 22531, 22532, 22533, 22536, 22537, + 22538, 22540, 22542, 22543, 22544, 22546, 22547, 22548, 22550, 22551, + 22552, 22554, 22555, 22556, 22557, 22559, 22562, 22563, 22565, 22566, + 22567, 22568, 22569, 22571, 22572, 22573, 22574, 22575, 22577, 22578, + 22579, 22580, 22582, 22583, 22584, 22585, 22586, 22587, 22588, 22589, + 22590, 22591, 22592, 22593, 22594, 22595, 22597, 22598, 22599, 22600, + 22601, 22602, 22603, 22606, 22607, 22608, 22610, 22611, 22613, 22614, + 22615, 22617, 22618, 22619, 22620, 22621, 22623, 22624, 22625, 22626, + 22627, 22628, 22630, 22631, 22632, 22633, 22634, 22637, 22638, 22639, + 22640, 22641, 22642, 22643, 22644, 22645, 22646, 22647, 22648, 22649, + 22650, 22651, 22652, 22653, 22655, 22658, 22660, 22662, 22663, 22664, + 22666, 22667, 22668, 22669, 22670, 22671, 22672, 22673, 22676, 22677, + 22678, 22679, 22680, 22683, 22684, 22685, 22688, 22689, 22690, 22691, + 22692, 22693, 22694, 22695, 22698, 22699, 22700, 22701, 22702, 22703, + 22704, 22705, 22706, 22707, 22708, 22709, 22710, 22711, 22712, 22713, + 22714, 22715, 22717, 22718, 22719, 22720, 22722, 22723, 22724, 22726, + 22727, 22728, 22729, 22730, 22731, 22732, 22733, 22734, 22735, 22736, + 22738, 22739, 22740, 22742, 22743, 22744, 22745, 22746, 22747, 22748, + 22749, 22750, 22751, 22752, 22753, 22754, 22755, 22757, 22758, 22759, + 22760, 22761, 22762, 22765, 22767, 22769, 22770, 22772, 22773, 22775, + 22776, 22778, 22779, 22780, 22781, 22782, 22783, 22784, 22785, 22787, + 22789, 22790, 22792, 22793, 22794, 22795, 22796, 22798, 22800, 22801, + 22802, 22803, 22807, 22808, 22811, 22813, 22814, 22816, 22817, 22818, + 22819, 22822, 22824, 22828, 22832, 22834, 22835, 22837, 22838, 22843, + 22845, 22846, 22847, 22848, 22851, 22853, 22854, 22858, 22860, 22861, + 22864, 22866, 22867, 22873, 22875, 22876, 22877, 22878, 22879, 22881, + 22883, 22884, 22886, 22887, 22888, 22889, 22890, 22891, 22892, 22893, + 22894, 22895, 22896, 22897, 22898, 22901, 22903, 22906, 22907, 22908, + 22910, 22911, 22912, 22917, 22921, 22923, 22924, 22926, 22927, 22928, + 22929, 22932, 22933, 22936, 22938, 22939, 22940, 22941, 22943, 22944, + 22945, 22946, 22950, 22951, 22956, 22957, 22960, 22961, 22963, 22964, + 22965, 22966, 22967, 22968, 22970, 22972, 22973, 22975, 22976, 22977, + 22978, 22979, 22980, 22981, 22983, 22984, 22985, 22988, 22989, 22990, + 22991, 22997, 22998, 23001, 23003, 23006, 23007, 23008, 23009, 23010, + 23012, 23014, 23015, 23017, 23018, 23019, 23021, 23022, 23023, 23024, + 23025, 23026, 23027, 23028, 23029, 23030, 23031, 23032, 23034, 23036, + 23037, 23038, 23040, 23042, 23050, 23051, 23053, 23054, 23055, 23056, + 23058, 23060, 23061, 23062, 23063, 23065, 23066, 23067, 23069, 23070, + 23073, 23074, 23076, 23078, 23079, 23080, 23082, 23083, 23084, 23085, + 23086, 23087, 23088, 23091, 23093, 23095, 23096, 23097, 23098, 23099, + 23101, 23102, 23103, 23105, 23106, 23107, 23108, 23109, 23111, 23112, + 23115, 23116, 23117, 23118, 23119, 23120, 23121, 23122, 23123, 23124, + 23126, 23127, 23128, 23129, 23131, 23132, 23133, 23134, 23135, 23136, + 23137, 23139, 23140, 23141, 23142, 23144, 23145, 23147, 23148, 23149, + 23150, 23151, 23152, 23153, 23154, 23155, 23160, 23161, 23163, 23164, + 23165, 23166, 23168, 23169, 23170, 23171, 23172, 23173, 23174, 23175, + 23176, 23177, 23178, 23179, 23180, 23181, 23182, 23183, 23184, 23185, + 23187, 23188, 23189, 23190, 23191, 23192, 23193, 23196, 23197, 23198, + 23199, 23200, 23201, 23202, 23203, 23204, 23205, 23206, 23207, 23208, + 23209, 23211, 23212, 23213, 23214, 23215, 23216, 23217, 23220, 23222, + 23223, 23225, 23226, 23227, 23228, 23229, 23231, 23232, 23235, 23236, + 23237, 23238, 23239, 23240, 23242, 23243, 23245, 23246, 23247, 23248, + 23249, 23251, 23253, 23255, 23257, 23258, 23259, 23261, 23262, 23263, + 23266, 23268, 23269, 23271, 23272, 23274, 23276, 23277, 23278, 23279, + 23280, 23282, 23283, 23284, 23285, 23286, 23287, 23288, 23289, 23290, + 23291, 23292, 23293, 23294, 23295, 23296, 23297, 23298, 23299, 23300, + 23301, 23302, 23303, 23304, 23306, 23307, 23308, 23309, 23310, 23311, + 23312, 23313, 23314, 23315, 23316, 23317, 23320, 23321, 23322, 23323, + 23324, 23325, 23326, 23327, 23328, 23329, 23330, 23331, 23332, 23333, + 23334, 23335, 23336, 23337, 23338, 23339, 23340, 23341, 23342, 23343, + 23344, 23345, 23347, 23349, 23350, 23352, 23353, 23354, 23355, 23356, + 23357, 23358, 23359, 23361, 23362, 23363, 23364, 23365, 23366, 23367, + 23368, 23369, 23370, 23371, 23372, 23373, 23374, 23375, 23378, 23382, + 23390, 23392, 23393, 23399, 23400, 23403, 23405, 23406, 23407, 23410, + 23412, 23414, 23415, 23416, 23417, 23419, 23420, 23422, 23423, 23426, + 23430, 23434, 23437, 23438, 23440, 23441, 23442, 23444, 23446, 23455, + 23463, 23464, 23465, 23468, 23469, 23470, 23471, 23473, 23474, 23479, + 23482, 23483, 23484, 23488, 23489, 23491, 23496, 23497, 23498, 23499, + 23501, 23502, 23503, 23505, 23508, 23509, 23510, 23511, 23512, 23513, + 23514, 23515, 23516, 23520, 23522, 23523, 23526, 23527, 23529, 23530, + 23531, 23532, 23533, 23535, 23537, 23538, 23539, 23540, 23541, 23542, + 23543, 23549, 23550, 23552, 23554, 23555, 23557, 23559, 23560, 23563, + 23564, 23565, 23566, 23568, 23570, 23571, 23575, 23577, 23579, 23582, + 23583, 23584, 23585, 23587, 23590, 23592, 23593, 23594, 23595, 23597, + 23598, 23599, 23600, 23602, 23603, 23605, 23606, 23607, 23619, 23620, + 23622, 23623, 23628, 23629, 23634, 23635, 23636, 23638, 23639, 23640, + 23642, 23643, 23644, 23645, 23647, 23650, 23652, 23655, 23656, 23657, + 23658, 23659, 23660, 23661, 23664, 23666, 23667, 23668, 23669, 23670, + 23671, 23672, 23675, 23676, 23677, 23678, 23680, 23683, 23684, 23685, + 23686, 23687, 23689, 23690, 23691, 23694, 23695, 23698, 23699, 23701, + 23709, 23710, 23711, 23712, 23713, 23716, 23717, 23718, 23719, 23720, + 23722, 23726, 23727, 23728, 23730, 23732, 23734, 23737, 23738, 23739, + 23740, 23742, 23744, 23746, 23747, 23749, 23750, 23751, 23752, 23753, + 23754, 23756, 23757, 23758, 23759, 23760, 23761, 23763, 23764, 23765, + 23766, 23767, 23768, 23770, 23771, 23772, 23773, 23774, 23775, 23776, + 23778, 23779, 23783, 23785, 23787, 23788, 23790, 23791, 23793, 23794, + 23795, 23796, 23797, 23798, 23799, 23800, 23801, 23802, 23804, 23805, + 23806, 23807, 23808, 23809, 23812, 23813, 23816, 23817, 23818, 23819, + 23820, 23821, 23823, 23824, 23825, 23826, 23827, 23829, 23831, 23832, + 23833, 23834, 23836, 23837, 23839, 23840, 23841, 23842, 23843, 23845, + 23848, 23850, 23851, 23852, 23855, 23856, 23857, 23858, 23859, 23861, + 23862, 23863, 23864, 23865, 23866, 23867, 23868, 23871, 23872, 23873, + 23874, 23875, 23876, 23877, 23878, 23880, 23881, 23885, 23886, 23887, + 23888, 23889, 23890, 23891, 23892, 23893, 23894, 23895, 23897, 23898, + 23900, 23902, 23903, 23904, 23905, 23906, 23907, 23908, 23909, 23910, + 23911, 23912, 23914, 23917, 23918, 23920, 23921, 23922, 23923, 23925, + 23926, 23927, 23928, 23929, 23930, 23931, 23932, 23933, 23934, 23935, + 23936, 23937, 23939, 23940, 23941, 23942, 23943, 23944, 23945, 23946, + 23947, 23948, 23949, 23950, 23951, 23952, 23953, 23954, 23955, 23956, + 23957, 23958, 23959, 23960, 23962, 23963, 23964, 23966, 23967, 23968, + 23969, 23970, 23971, 23972, 23973, 23974, 23975, 23976, 23977, 23978, + 23979, 23980, 23981, 23982, 23983, 23984, 23985, 23986, 23987, 23988, + 23989, 23990, 23992, 23993, 23994, 23995, 23996, 23997, 23998, 23999, + 24000, 24001, 24002, 24003, 24004, 24006, 24007, 24008, 24009, 24010, + 24011, 24012, 24014, 24015, 24016, 24017, 24018, 24019, 24020, 24021, + 24022, 24023, 24024, 24025, 24026, 24028, 24031, 24032, 24035, 24036, + 24042, 24044, 24045, 24048, 24053, 24054, 24056, 24057, 24058, 24059, + 24060, 24063, 24064, 24068, 24071, 24073, 24074, 24075, 24077, 24078, + 24082, 24083, 24087, 24094, 24095, 24096, 24097, 24098, 24099, 24100, + 24101, 24104, 24105, 24106, 24107, 24108, 24111, 24112, 24114, 24115, + 24116, 24117, 24118, 24121, 24122, 24126, 24127, 24128, 24129, 24131, + 24134, 24135, 24136, 24137, 24138, 24139, 24141, 24142, 24143, 24144, + 24145, 24146, 24147, 24150, 24151, 24152, 24153, 24154, 24156, 24157, + 24159, 24160, 24163, 24164, 24165, 24166, 24167, 24168, 24169, 24170, + 24171, 24172, 24173, 24174, 24175, 24176, 24177, 24181, 24183, 24185, + 24190, 24193, 24194, 24195, 24197, 24200, 24201, 24204, 24205, 24206, + 24210, 24216, 24219, 24221, 24225, 24226, 24227, 24228, 24232, 24233, + 24234, 24235, 24236, 24238, 24239, 24240, 24241, 24242, 24244, 24250, + 24251, 24252, 24253, 24255, 24256, 24257, 24258, 24259, 24260, 24261, + 24262, 24263, 24264, 24267, 24268, 24269, 24270, 24271, 24272, 24276, + 24277, 24279, 24280, 24281, 24282, 24284, 24285, 24286, 24287, 24288, + 24289, 24290, 24291, 24292, 24293, 24294, 24295, 24297, 24299, 24300, + 24301, 24302, 24303, 24304, 24305, 24306, 24307, 24309, 24312, 24313, + 24315, 24316, 24317, 24325, 24326, 24327, 24329, 24332, 24333, 24334, + 24336, 24338, 24340, 24342, 24345, 24346, 24348, 24349, 24350, 24353, + 24354, 24355, 24356, 24360, 24363, 24364, 24366, 24368, 24370, 24371, + 24372, 24373, 24374, 24375, 24376, 24379, 24381, 24382, 24383, 24385, + 24386, 24387, 24388, 24389, 24390, 24391, 24392, 24393, 24394, 24395, + 24396, 24397, 24398, 24399, 24401, 24404, 24409, 24410, 24411, 24412, + 24414, 24415, 24416, 24419, 24421, 24423, 24424, 24427, 24430, 24431, + 24434, 24436, 24437, 24438, 24440, 24442, 24445, 24446, 24447, 24451, + 24454, 24461, 24462, 24463, 24465, 24467, 24468, 24470, 24474, 24475, + 24477, 24478, 24479, 24480, 24482, 24483, 24484, 24485, 24486, 24487, + 24489, 24491, 24492, 24495, 24496, 24497, 24498, 24499, 24500, 24502, + 24504, 24505, 24506, 24507, 24510, 24511, 24512, 24513, 24514, 24519, + 24520, 24522, 24523, 24526, 24531, 24532, 24533, 24538, 24539, 24540, + 24542, 24543, 24546, 24547, 24549, 24550, 24552, 24553, 24556, 24559, + 24560, 24562, 24563, 24564, 24566, 24567, 24569, 24570, 24572, 24583, + 24584, 24585, 24587, 24588, 24592, 24593, 24595, 24599, 24600, 24602, + 24606, 24607, 24610, 24611, 24612, 24620, 24621, 24622, 24624, 24625, + 24626, 24627, 24628, 24630, 24631, 24632, 24633, 24634, 24637, 24638, + 24640, 24644, 24645, 24646, 24647, 24648, 24649, 24650, 24652, 24654, + 24655, 24657, 24659, 24660, 24662, 24663, 24664, 24667, 24668, 24670, + 24671, 24672, 24673, 24677, 24678, 24686, 24689, 24690, 24692, 24693, + 24695, 24702, 24704, 24705, 24706, 24709, 24710, 24711, 24712, 24714, + 24715, 24718, 24719, 24720, 24721, 24723, 24725, 24727, 24728, 24729, + 24732, 24734, 24737, 24738, 24740, 24741, 24743, 24745, 24746, 24750, + 24752, 24755, 24757, 24758, 24759, 24761, 24762, 24765, 24766, 24767, + 24768, 24769, 24770, 24771, 24772, 24775, 24776, 24777, 24780, 24781, + 24782, 24783, 24784, 24786, 24787, 24788, 24790, 24791, 24793, 24795, + 24798, 24801, 24802, 24803, 24804, 24805, 24810, 24817, 24818, 24821, + 24823, 24824, 24827, 24828, 24829, 24830, 24831, 24834, 24835, 24836, + 24837, 24839, 24842, 24843, 24844, 24848, 24849, 24850, 24851, 24852, + 24854, 24855, 24856, 24857, 24859, 24860, 24861, 24862, 24865, 24866, + 24869, 24872, 24873, 24874, 24876, 24877, 24878, 24879, 24880, 24881, + 24882, 24883, 24884, 24885, 24886, 24887, 24888, 24889, 24890, 24891, + 24892, 24893, 24894, 24896, 24897, 24898, 24899, 24900, 24901, 24902, + 24903, 24905, 24907, 24909, 24911, 24912, 24914, 24915, 24916, 24918, + 24919, 24920, 24921, 24922, 24923, 24924, 24926, 24927, 24928, 24929, + 24931, 24932, 24933, 24934, 24937, 24938, 24939, 24940, 24941, 24942, + 24943, 24945, 24946, 24947, 24948, 24950, 24952, 24953, 24954, 24955, + 24956, 24957, 24958, 24959, 24960, 24961, 24962, 24963, 24964, 24965, + 24966, 24967, 24968, 24969, 24970, 24972, 24973, 24975, 24976, 24977, + 24978, 24979, 24981, 24982, 24983, 24984, 24985, 24986, 24987, 24988, + 24990, 24991, 24992, 24993, 24994, 24995, 24996, 24997, 24998, 25002, + 25003, 25005, 25006, 25007, 25008, 25009, 25010, 25011, 25012, 25013, + 25014, 25016, 25017, 25018, 25019, 25020, 25021, 25023, 25024, 25025, + 25027, 25028, 25029, 25030, 25031, 25033, 25036, 25037, 25038, 25039, + 25040, 25043, 25045, 25046, 25047, 25048, 25049, 25050, 25051, 25052, + 25053, 25054, 25055, 25056, 25057, 25058, 25059, 25060, 25061, 25063, + 25064, 25065, 25066, 25067, 25068, 25069, 25070, 25071, 25072, 25073, + 25074, 25075, 25076, 25078, 25079, 25080, 25081, 25082, 25083, 25084, + 25085, 25086, 25088, 25089, 25090, 25091, 25092, 25093, 25095, 25097, + 25107, 25108, 25113, 25116, 25117, 25118, 25120, 25123, 25126, 25127, + 25128, 25129, 25131, 25133, 25135, 25136, 25137, 25138, 25141, 25142, + 25144, 25145, 25146, 25147, 25148, 25154, 25156, 25157, 25158, 25162, + 25167, 25168, 25173, 25174, 25175, 25177, 25178, 25180, 25181, 25182, + 25183, 25184, 25185, 25186, 25188, 25189, 25192, 25201, 25202, 25204, + 25205, 25207, 25208, 25210, 25211, 25213, 25217, 25218, 25219, 25221, + 25222, 25223, 25224, 25227, 25228, 25229, 25230, 25231, 25232, 25236, + 25241, 25244, 25245, 25246, 25251, 25254, 25255, 25257, 25258, 25261, + 25262, 25263, 25264, 25266, 25267, 25268, 25270, 25271, 25272, 25274, + 25278, 25280, 25281, 25283, 25291, 25295, 25297, 25301, 25309, 25310, + 25312, 25313, 25316, 25322, 25323, 25328, 25330, 25333, 25336, 25337, + 25338, 25339, 25344, 25347, 25348, 25349, 25350, 25354, 25355, 25356, + 25357, 25359, 25360, 25362, 25363, 25364, 25365, 25367, 25368, 25369, + 25372, 25382, 25383, 25385, 25388, 25389, 25390, 25392, 25393, 25395, + 25396, 25397, 25398, 25399, 25400, 25403, 25404, 25406, 25407, 25408, + 25409, 25412, 25415, 25416, 25418, 25425, 25426, 25427, 25428, 25430, + 25431, 25432, 25433, 25434, 25435, 25436, 25437, 25440, 25444, 25445, + 25446, 25448, 25450, 25451, 25452, 25455, 25456, 25458, 25459, 25460, + 25461, 25464, 25465, 25468, 25469, 25470, 25471, 25473, 25475, 25476, + 25477, 25478, 25483, 25485, 25489, 25491, 25492, 25493, 25495, 25497, + 25498, 25499, 25500, 25501, 25502, 25503, 25505, 25508, 25510, 25515, + 25519, 25521, 25522, 25525, 25526, 25529, 25531, 25533, 25535, 25536, + 25537, 25538, 25539, 25541, 25543, 25544, 25546, 25547, 25548, 25553, + 25555, 25556, 25557, 25559, 25560, 25561, 25562, 25563, 25564, 25565, + 25567, 25570, 25572, 25573, 25574, 25575, 25576, 25579, 25580, 25582, + 25583, 25584, 25585, 25587, 25589, 25591, 25593, 25594, 25595, 25596, + 25598, 25603, 25604, 25606, 25607, 25608, 25609, 25610, 25613, 25614, + 25617, 25618, 25621, 25622, 25623, 25624, 25625, 25626, 25629, 25631, + 25634, 25635, 25636, 25637, 25639, 25640, 25641, 25643, 25646, 25647, + 25648, 25649, 25650, 25651, 25653, 25654, 25655, 25656, 25657, 25659, + 25660, 25662, 25664, 25666, 25667, 25673, 25675, 25676, 25677, 25678, + 25679, 25680, 25681, 25683, 25685, 25686, 25687, 25689, 25690, 25691, + 25692, 25693, 25695, 25696, 25697, 25698, 25699, 25700, 25701, 25702, + 25704, 25706, 25707, 25708, 25710, 25711, 25712, 25713, 25714, 25715, + 25716, 25717, 25718, 25719, 25723, 25724, 25725, 25726, 25727, 25728, + 25729, 25731, 25734, 25736, 25737, 25738, 25739, 25740, 25741, 25742, + 25743, 25744, 25747, 25748, 25751, 25752, 25754, 25755, 25756, 25757, + 25759, 25760, 25761, 25762, 25763, 25765, 25766, 25767, 25768, 25770, + 25771, 25775, 25777, 25778, 25779, 25780, 25782, 25785, 25787, 25789, + 25790, 25791, 25793, 25795, 25796, 25798, 25799, 25800, 25801, 25802, + 25803, 25804, 25807, 25809, 25811, 25812, 25813, 25814, 25817, 25818, + 25819, 25820, 25821, 25823, 25824, 25825, 25827, 25829, 25831, 25832, + 25833, 25834, 25835, 25836, 25837, 25838, 25839, 25840, 25841, 25842, + 25843, 25844, 25845, 25846, 25847, 25848, 25849, 25850, 25851, 25852, + 25853, 25854, 25855, 25857, 25858, 25859, 25860, 25861, 25862, 25863, + 25864, 25866, 25867, 25868, 25869, 25870, 25871, 25872, 25873, 25875, + 25876, 25877, 25878, 25879, 25881, 25882, 25883, 25884, 25885, 25886, + 25887, 25888, 25889, 25890, 25891, 25892, 25894, 25895, 25896, 25897, + 25898, 25900, 25901, 25904, 25905, 25906, 25907, 25911, 25914, 25916, + 25917, 25920, 25921, 25922, 25923, 25924, 25926, 25927, 25930, 25931, + 25933, 25934, 25936, 25938, 25939, 25940, 25943, 25944, 25946, 25948, + 25951, 25952, 25953, 25956, 25957, 25959, 25960, 25961, 25962, 25965, + 25966, 25967, 25969, 25971, 25973, 25974, 25976, 25977, 25978, 25979, + 25980, 25981, 25982, 25983, 25984, 25985, 25986, 25987, 25988, 25989, + 25990, 25992, 25993, 25994, 25997, 25998, 25999, 26002, 26004, 26005, + 26006, 26008, 26010, 26013, 26014, 26016, 26018, 26019, 26022, 26024, + 26026, 26028, 26030, 26033, 26034, 26035, 26036, 26037, 26038, 26039, + 26040, 26042, 26043, 26046, 26047, 26048, 26050, 26055, 26056, 26057, + 26058, 26061, 26064, 26065, 26067, 26068, 26069, 26072, 26073, 26074, + 26075, 26076, 26077, 26078, 26079, 26081, 26083, 26084, 26090, 26091, + 26098, 26099, 26100, 26101, 26104, 26105, 26107, 26108, 26109, 26110, + 26111, 26113, 26116, 26117, 26119, 26120, 26121, 26123, 26125, 26128, + 26129, 26130, 26134, 26135, 26136, 26138, 26139, 26140, 26142, 26145, + 26146, 26147, 26148, 26150, 26153, 26154, 26155, 26156, 26158, 26160, + 26162, 26163, 26167, 26168, 26169, 26170, 26171, 26173, 26175, 26176, + 26178, 26180, 26181, 26182, 26183, 26184, 26185, 26186, 26189, 26190, + 26192, 26193, 26200, 26201, 26203, 26204, 26205, 26206, 26208, 26210, + 26211, 26213, 26215, 26217, 26218, 26219, 26220, 26221, 26225, 26226, + 26227, 26229, 26232, 26233, 26235, 26236, 26237, 26239, 26240, 26241, + 26243, 26245, 26246, 26248, 26249, 26250, 26251, 26253, 26254, 26255, + 26256, 26258, 26259, 26260, 26261, 26264, 26265, 26266, 26267, 26268, + 26270, 26271, 26272, 26273, 26274, 26275, 26276, 26277, 26278, 26281, + 26282, 26283, 26284, 26285, 26287, 26288, 26289, 26290, 26291, 26293, + 26294, 26295, 26296, 26298, 26299, 26300, 26301, 26303, 26304, 26305, + 26306, 26307, 26308, 26309, 26310, 26311, 26312, 26313, 26314, 26315, + 26316, 26317, 26318, 26319, 26320, 26321, 26322, 26323, 26324, 26325, + 26326, 26327, 26328, 26330, 26334, 26335, 26336, 26337, 26338, 26339, + 26340, 26341, 26343, 26344, 26346, 26347, 26348, 26349, 26350, 26351, + 26353, 26357, 26358, 26360, 26362, 26363, 26365, 26369, 26370, 26371, + 26372, 26373, 26374, 26375, 26380, 26382, 26383, 26385, 26386, 26387, + 26390, 26392, 26393, 26394, 26396, 26398, 26400, 26401, 26402, 26403, + 26404, 26405, 26407, 26409, 26414, 26416, 26418, 26419, 26422, 26423, + 26424, 26425, 26427, 26428, 26430, 26431, 26433, 26436, 26437, 26439, + 26442, 26443, 26445, 26450, 26452, 26453, 26455, 26456, 26457, 26458, + 26459, 26461, 26466, 26467, 26468, 26470, 26471, 26475, 26476, 26478, + 26481, 26484, 26486, 26488, 26489, 26490, 26491, 26493, 26496, 26498, + 26499, 26501, 26502, 26504, 26506, 26508, 26509, 26510, 26511, 26513, + 26514, 26515, 26516, 26518, 26521, 26523, 26527, 26528, 26529, 26532, + 26534, 26537, 26540, 26542, 26545, 26546, 26548, 26553, 26554, 26555, + 26556, 26557, 26558, 26559, 26560, 26562, 26565, 26566, 26567, 26568, + 26569, 26570, 26571, 26572, 26573, 26574, 26581, 26582, 26583, 26587, + 26591, 26593, 26595, 26596, 26598, 26599, 26600, 26602, 26603, 26605, + 26606, 26610, 26613, 26614, 26615, 26616, 26617, 26618, 26619, 26620, + 26622, 26625, 26626, 26627, 26628, 26630, 26637, 26640, 26642, 26644, + 26645, 26648, 26649, 26650, 26651, 26652, 26654, 26655, 26656, 26658, + 26659, 26660, 26661, 26662, 26663, 26664, 26667, 26668, 26669, 26670, + 26671, 26672, 26673, 26676, 26677, 26678, 26682, 26683, 26687, 26695, + 26699, 26701, 26703, 26706, 26710, 26711, 26712, 26713, 26714, 26715, + 26716, 26717, 26718, 26719, 26730, 26732, 26733, 26734, 26735, 26736, + 26737, 26738, 26739, 26741, 26744, 26745, 26746, 26747, 26748, 26749, + 26750, 26751, 26752, 26754, 26756, 26759, 26760, 26761, 26762, 26763, + 26764, 26765, 26766, 26768, 26769, 26770, 26772, 26773, 26774, 26776, + 26777, 26778, 26779, 26780, 26781, 26782, 26783, 26784, 26785, 26787, + 26788, 26789, 26793, 26794, 26795, 26796, 26798, 26801, 26802, 26804, + 26806, 26807, 26808, 26809, 26810, 26811, 26812, 26813, 26814, 26815, + 26817, 26819, 26820, 26821, 26822, 26823, 26824, 26826, 26828, 26830, + 26831, 26832, 26833, 26835, 26836, 26838, 26839, 26841, 26843, 26844, + 26845, 26846, 26847, 26849, 26850, 26852, 26853, 26854, 26855, 26856, + 26857, 26858, 26859, 26860, 26861, 26863, 26866, 26867, 26868, 26870, + 26871, 26872, 26875, 26877, 26878, 26879, 26880, 26882, 26883, 26884, + 26886, 26887, 26888, 26889, 26890, 26892, 26895, 26897, 26899, 26900, + 26901, 26902, 26903, 26904, 26905, 26906, 26907, 26908, 26909, 26910, + 26913, 26914, 26915, 26917, 26918, 26919, 26920, 26921, 26922, 26923, + 26924, 26926, 26927, 26929, 26930, 26931, 26933, 26934, 26935, 26936, + 26938, 26939, 26940, 26942, 26944, 26945, 26947, 26948, 26949, 26950, + 26951, 26952, 26953, 26954, 26955, 26956, 26957, 26958, 26959, 26960, + 26961, 26962, 26963, 26965, 26966, 26968, 26969, 26971, 26972, 26975, + 26977, 26978, 26980, 26981, 26983, 26984, 26985, 26986, 26988, 26989, + 26991, 26992, 26994, 26995, 26996, 26997, 26998, 27002, 27003, 27005, + 27006, 27007, 27009, 27011, 27013, 27018, 27019, 27020, 27022, 27023, + 27024, 27025, 27026, 27027, 27030, 27031, 27033, 27034, 27037, 27038, + 27039, 27040, 27041, 27042, 27043, 27044, 27045, 27046, 27049, 27050, + 27052, 27054, 27055, 27056, 27058, 27059, 27061, 27062, 27064, 27065, + 27066, 27068, 27069, 27070, 27071, 27072, 27074, 27075, 27076, 27077, + 27078, 27079, 27080, 27081, 27083, 27085, 27087, 27089, 27090, 27091, + 27093, 27094, 27095, 27096, 27097, 27098, 27100, 27101, 27102, 27105, + 27106, 27107, 27108, 27109, 27110, 27111, 27112, 27113, 27114, 27115, + 27116, 27118, 27119, 27120, 27121, 27123, 27124, 27125, 27126, 27127, + 27128, 27129, 27130, 27131, 27132, 27134, 27136, 27137, 27138, 27139, + 27140, 27141, 27142, 27143, 27144, 27145, 27147, 27148, 27149, 27150, + 27151, 27152, 27153, 27154, 27155, 27156, 27157, 27158, 27161, 27162, + 27163, 27164, 27165, 27166, 27168, 27170, 27171, 27172, 27173, 27174, + 27175, 27177, 27179, 27180, 27181, 27182, 27184, 27186, 27187, 27188, + 27190, 27191, 27192, 27193, 27194, 27195, 27196, 27199, 27200, 27201, + 27202, 27203, 27205, 27206, 27208, 27209, 27210, 27211, 27212, 27213, + 27214, 27215, 27217, 27218, 27219, 27220, 27221, 27222, 27223, 27226, + 27228, 27229, 27230, 27231, 27232, 27234, 27235, 27236, 27238, 27239, + 27240, 27241, 27242, 27243, 27244, 27245, 27246, 27247, 27248, 27250, + 27251, 27252, 27253, 27254, 27255, 27256, 27258, 27259, 27261, 27262, + 27263, 27265, 27266, 27267, 27269, 27270, 27271, 27272, 27273, 27274, + 27275, 27276, 27277, 27279, 27282, 27283, 27284, 27285, 27286, 27288, + 27289, 27290, 27291, 27292, 27293, 27294, 27295, 27297, 27298, 27299, + 27300, 27301, 27302, 27303, 27304, 27306, 27309, 27310, 27311, 27312, + 27313, 27314, 27315, 27316, 27317, 27318, 27319, 27320, 27321, 27322, + 27323, 27324, 27325, 27326, 27327, 27328, 27329, 27330, 27331, 27332, + 27333, 27334, 27335, 27336, 27337, 27338, 27339, 27340, 27341, 27342, + 27343, 27344, 27345, 27346, 27347, 27348, 27349, 27350, 27351, 27352, + 27353, 27354, 27355, 27356, 27357, 27358, 27359, 27360, 27361, 27362, + 27363, 27364, 27365, 27366, 27367, 27368, 27369, 27370, 27371, 27372, + 27373, 27374, 27375, 27376, 27377, 27378, 27379, 27380, 27381, 27382, + 27383, 27384, 27385, 27386, 27387, 27388, 27389, 27390, 27391, 27392, + 27393, 27394, 27395, 27396, 27397, 27398, 27399, 27400, 27401, 27402, + 27403, 27404, 27405, 27406, 27407, 27408, 27409, 27410, 27411, 27412, + 27413, 27414, 27415, 27416, 27417, 27418, 27419, 27420, 27421, 27422, + 27423, 27429, 27430, 27432, 27433, 27434, 27435, 27436, 27437, 27438, + 27439, 27440, 27441, 27443, 27444, 27445, 27446, 27448, 27451, 27452, + 27453, 27455, 27456, 27457, 27458, 27460, 27461, 27464, 27466, 27467, + 27469, 27470, 27471, 27472, 27473, 27474, 27475, 27476, 27477, 27478, + 27479, 27480, 27482, 27483, 27484, 27485, 27486, 27487, 27488, 27489, + 27496, 27497, 27499, 27500, 27501, 27502, 27503, 27504, 27505, 27506, + 27507, 27508, 27509, 27510, 27511, 27512, 27514, 27517, 27518, 27519, + 27520, 27525, 27528, 27532, 27534, 27535, 27536, 27537, 27540, 27541, + 27543, 27544, 27545, 27548, 27549, 27550, 27551, 27552, 27554, 27555, + 27556, 27557, 27558, 27559, 27560, 27561, 27563, 27564, 27565, 27566, + 27567, 27568, 27569, 27570, 27574, 27576, 27577, 27578, 27579, 27580, + 27581, 27582, 27584, 27587, 27588, 27590, 27591, 27592, 27593, 27594, + 27596, 27598, 27600, 27601, 27608, 27610, 27612, 27613, 27614, 27615, + 27616, 27618, 27619, 27620, 27621, 27622, 27623, 27624, 27625, 27628, + 27629, 27630, 27632, 27633, 27634, 27636, 27638, 27639, 27640, 27642, + 27643, 27644, 27646, 27647, 27648, 27649, 27650, 27651, 27652, 27656, + 27657, 27658, 27659, 27660, 27662, 27666, 27671, 27676, 27677, 27678, + 27680, 27683, 27685, 27691, 27692, 27693, 27697, 27699, 27702, 27703, + 27705, 27706, 27707, 27708, 27710, 27711, 27715, 27716, 27717, 27720, + 27723, 27724, 27725, 27726, 27727, 27729, 27730, 27731, 27734, 27736, + 27737, 27738, 27746, 27747, 27749, 27750, 27751, 27755, 27756, 27757, + 27758, 27759, 27761, 27763, 27765, 27767, 27768, 27770, 27771, 27772, + 27775, 27776, 27780, 27783, 27786, 27787, 27789, 27790, 27793, 27794, + 27797, 27798, 27799, 27800, 27802, 27804, 27805, 27806, 27808, 27810, + 27816, 27820, 27823, 27824, 27828, 27829, 27830, 27831, 27834, 27840, + 27841, 27842, 27843, 27846, 27847, 27848, 27851, 27853, 27854, 27855, + 27857, 27858, 27864, 27865, 27866, 27868, 27869, 27871, 27876, 27878, + 27879, 27881, 27884, 27885, 27890, 27892, 27897, 27903, 27904, 27906, + 27907, 27909, 27910, 27912, 27913, 27914, 27917, 27919, 27920, 27921, + 27923, 27924, 27925, 27926, 27928, 27932, 27933, 27935, 27936, 27937, + 27938, 27939, 27940, 27942, 27944, 27945, 27948, 27949, 27951, 27952, + 27956, 27958, 27959, 27960, 27962, 27967, 27968, 27970, 27972, 27977, + 27980, 27984, 27989, 27990, 27991, 27992, 27995, 27997, 27999, 28001, + 28002, 28004, 28005, 28007, 28008, 28011, 28012, 28013, 28016, 28017, + 28018, 28019, 28021, 28022, 28025, 28026, 28027, 28029, 28030, 28031, + 28032, 28033, 28035, 28036, 28038, 28039, 28042, 28043, 28045, 28047, + 28048, 28050, 28054, 28055, 28056, 28057, 28058, 28060, 28066, 28069, + 28076, 28077, 28080, 28081, 28083, 28084, 28086, 28087, 28089, 28090, + 28091, 28092, 28093, 28094, 28097, 28098, 28099, 28104, 28105, 28106, + 28109, 28110, 28111, 28112, 28114, 28115, 28116, 28117, 28119, 28122, + 28123, 28124, 28127, 28130, 28131, 28133, 28135, 28136, 28137, 28138, + 28141, 28143, 28144, 28146, 28148, 28149, 28150, 28152, 28154, 28157, + 28158, 28159, 28160, 28161, 28162, 28163, 28164, 28166, 28167, 28168, + 28169, 28171, 28175, 28178, 28179, 28181, 28184, 28185, 28187, 28188, + 28190, 28191, 28194, 28198, 28199, 28200, 28202, 28204, 28206, 28208, + 28209, 28211, 28213, 28214, 28215, 28217, 28219, 28220, 28221, 28222, + 28223, 28224, 28225, 28226, 28229, 28230, 28231, 28232, 28233, 28234, + 28235, 28236, 28239, 28240, 28241, 28242, 28245, 28247, 28249, 28250, + 28252, 28253, 28254, 28256, 28257, 28258, 28259, 28260, 28261, 28262, + 28263, 28264, 28265, 28266, 28268, 28269, 28271, 28272, 28273, 28274, + 28275, 28276, 28277, 28278, 28279, 28280, 28281, 28282, 28283, 28284, + 28285, 28288, 28289, 28290, 28292, 28295, 28296, 28298, 28299, 28300, + 28301, 28302, 28305, 28306, 28307, 28308, 28309, 28310, 28311, 28313, + 28314, 28315, 28317, 28318, 28320, 28321, 28323, 28324, 28326, 28328, + 28329, 28331, 28332, 28333, 28334, 28336, 28339, 28341, 28344, 28345, + 28348, 28350, 28351, 28352, 28355, 28356, 28357, 28358, 28360, 28361, + 28362, 28364, 28365, 28366, 28368, 28370, 28374, 28376, 28377, 28379, + 28380, 28381, 28387, 28391, 28394, 28395, 28396, 28397, 28398, 28399, + 28400, 28401, 28402, 28403, 28405, 28406, 28407, 28408, 28410, 28411, + 28412, 28413, 28414, 28415, 28416, 28417, 28419, 28420, 28421, 28423, + 28424, 28426, 28427, 28428, 28429, 28430, 28432, 28433, 28434, 28438, + 28439, 28440, 28441, 28442, 28443, 28444, 28445, 28446, 28447, 28449, + 28450, 28451, 28453, 28454, 28455, 28456, 28460, 28462, 28464, 28466, + 28468, 28469, 28471, 28472, 28473, 28474, 28475, 28476, 28477, 28479, + 28480, 28481, 28482, 28483, 28484, 28485, 28488, 28489, 28490, 28492, + 28494, 28495, 28496, 28497, 28498, 28499, 28500, 28501, 28502, 28503, + 28505, 28506, 28507, 28509, 28511, 28512, 28513, 28515, 28516, 28517, + 28519, 28520, 28521, 28522, 28523, 28524, 28527, 28528, 28529, 28531, + 28533, 28534, 28535, 28537, 28539, 28541, 28542, 28543, 28544, 28545, + 28546, 28547, 28549, 28550, 28551, 28554, 28555, 28559, 28560, 28561, + 28562, 28563, 28564, 28565, 28566, 28567, 28568, 28569, 28570, 28571, + 28573, 28574, 28575, 28576, 28578, 28579, 28580, 28581, 28582, 28584, + 28585, 28586, 28587, 28588, 28589, 28590, 28591, 28592, 28593, 28594, + 28596, 28597, 28599, 28600, 28602, 28603, 28604, 28605, 28606, 28607, + 28609, 28611, 28612, 28613, 28614, 28615, 28616, 28618, 28619, 28620, + 28621, 28622, 28623, 28624, 28627, 28628, 28629, 28630, 28631, 28632, + 28633, 28634, 28635, 28636, 28637, 28639, 28642, 28643, 28644, 28645, + 28646, 28647, 28648, 28649, 28650, 28651, 28652, 28653, 28656, 28657, + 28658, 28659, 28660, 28661, 28662, 28663, 28664, 28665, 28666, 28667, + 28668, 28669, 28670, 28671, 28672, 28673, 28674, 28675, 28676, 28677, + 28678, 28679, 28680, 28681, 28682, 28683, 28684, 28685, 28686, 28687, + 28688, 28690, 28691, 28692, 28693, 28694, 28695, 28696, 28697, 28700, + 28701, 28702, 28703, 28704, 28705, 28706, 28708, 28709, 28710, 28711, + 28712, 28713, 28714, 28715, 28716, 28717, 28718, 28719, 28720, 28721, + 28722, 28723, 28724, 28726, 28727, 28728, 28730, 28731, 28732, 28733, + 28734, 28735, 28736, 28737, 28738, 28739, 28740, 28741, 28742, 28743, + 28744, 28745, 28746, 28747, 28749, 28750, 28752, 28753, 28754, 28755, + 28756, 28757, 28758, 28759, 28760, 28761, 28762, 28763, 28764, 28765, + 28767, 28768, 28769, 28770, 28771, 28772, 28773, 28774, 28775, 28776, + 28777, 28778, 28782, 28785, 28786, 28787, 28788, 28791, 28793, 28794, + 28795, 28797, 28801, 28802, 28803, 28804, 28806, 28807, 28808, 28811, + 28812, 28813, 28815, 28816, 28817, 28819, 28823, 28824, 28826, 28827, + 28830, 28831, 28832, 28833, 28834, 28835, 28836, 28837, 28838, 28839, + 28840, 28841, 28842, 28848, 28850, 28852, 28853, 28854, 28858, 28862, + 28863, 28868, 28869, 28870, 28871, 28873, 28875, 28876, 28877, 28878, + 28879, 28880, 28881, 28882, 28883, 28884, 28885, 28886, 28887, 28890, + 28892, 28893, 28894, 28896, 28897, 28898, 28899, 28901, 28906, 28910, + 28912, 28913, 28914, 28915, 28916, 28917, 28918, 28920, 28922, 28923, + 28924, 28926, 28927, 28928, 28929, 28930, 28931, 28932, 28933, 28934, + 28935, 28936, 28939, 28940, 28941, 28942, 28943, 28945, 28946, 28948, + 28951, 28955, 28956, 28957, 28958, 28959, 28960, 28961, 28962, 28963, + 28964, 28965, 28967, 28968, 28969, 28970, 28971, 28972, 28973, 28974, + 28978, 28979, 28980, 28981, 28983, 28984, 28985, 28986, 28987, 28988, + 28989, 28990, 28991, 28992, 28993, 28994, 28995, 28996, 28998, 28999, + 29000, 29001, 29003, 29005, 29007, 29008, 29009, 29010, 29011, 29012, + 29013, 29014, 29015, 29016, 29017, 29018, 29019, 29021, 29023, 29024, + 29025, 29026, 29027, 29029, 29033, 29034, 29035, 29036, 29037, 29039, + 29040, 29041, 29044, 29045, 29046, 29047, 29049, 29051, 29052, 29054, + 29055, 29056, 29057, 29058, 29059, 29061, 29062, 29063, 29064, 29065, + 29067, 29068, 29069, 29070, 29072, 29073, 29074, 29075, 29077, 29078, + 29079, 29082, 29083, 29084, 29085, 29086, 29089, 29090, 29091, 29092, + 29093, 29094, 29095, 29097, 29098, 29099, 29101, 29102, 29103, 29104, + 29105, 29106, 29108, 29110, 29111, 29112, 29114, 29115, 29116, 29117, + 29118, 29119, 29120, 29121, 29122, 29124, 29125, 29126, 29127, 29128, + 29129, 29130, 29131, 29132, 29133, 29135, 29136, 29137, 29138, 29139, + 29142, 29143, 29144, 29145, 29146, 29147, 29148, 29149, 29150, 29151, + 29153, 29154, 29155, 29156, 29158, 29160, 29161, 29162, 29163, 29164, + 29165, 29167, 29168, 29169, 29170, 29171, 29172, 29173, 29174, 29175, + 29176, 29178, 29179, 29180, 29181, 29182, 29183, 29184, 29185, 29186, + 29187, 29188, 29189, 29191, 29192, 29193, 29194, 29195, 29196, 29197, + 29198, 29199, 29200, 29201, 29202, 29203, 29204, 29205, 29206, 29207, + 29208, 29209, 29210, 29211, 29212, 29214, 29215, 29216, 29217, 29218, + 29219, 29220, 29221, 29222, 29223, 29225, 29227, 29229, 29230, 29231, + 29234, 29235, 29236, 29242, 29244, 29246, 29248, 29249, 29250, 29251, + 29252, 29253, 29254, 29257, 29258, 29259, 29262, 29263, 29264, 29265, + 29267, 29268, 29269, 29271, 29272, 29274, 29276, 29278, 29280, 29283, + 29284, 29285, 29288, 29290, 29291, 29292, 29293, 29296, 29297, 29299, + 29300, 29302, 29303, 29304, 29307, 29308, 29309, 29314, 29315, 29317, + 29318, 29319, 29320, 29321, 29324, 29326, 29328, 29329, 29331, 29332, + 29333, 29334, 29335, 29336, 29337, 29338, 29339, 29340, 29341, 29342, + 29344, 29345, 29346, 29347, 29348, 29349, 29350, 29351, 29352, 29353, + 29354, 29355, 29358, 29361, 29362, 29363, 29365, 29370, 29371, 29372, + 29373, 29374, 29375, 29376, 29381, 29382, 29383, 29385, 29386, 29387, + 29388, 29391, 29393, 29395, 29396, 29397, 29398, 29400, 29402, 29403, + 58566, 58567, 58568, 58569, 58570, 58571, 58572, 58573, 58574, 58575, + 58576, 58577, 58578, 58579, 58580, 58581, 58582, 58583, 58584, 58585, + 58586, 58587, 58588, 58589, 58590, 58591, 58592, 58593, 58594, 58595, + 58596, 58597, 58598, 58599, 58600, 58601, 58602, 58603, 58604, 58605, + 58606, 58607, 58608, 58609, 58610, 58611, 58612, 58613, 58614, 58615, + 58616, 58617, 58618, 58619, 58620, 58621, 58622, 58623, 58624, 58625, + 58626, 58627, 58628, 58629, 58630, 58631, 58632, 58633, 58634, 58635, + 58636, 58637, 58638, 58639, 58640, 58641, 58642, 58643, 58644, 58645, + 58646, 58647, 58648, 58649, 58650, 58651, 58652, 58653, 58654, 58655, + 58656, 58657, 58658, 58659, 58660, 58661, 12288, 12289, 12290, 183, 713, + 711, 168, 12291, 12293, 8212, 65374, 8214, 8230, 8216, 8217, 8220, 8221, + 12308, 12309, 12296, 12297, 12298, 12299, 12300, 12301, 12302, 12303, + 12310, 12311, 12304, 12305, 177, 215, 247, 8758, 8743, 8744, 8721, 8719, + 8746, 8745, 8712, 8759, 8730, 8869, 8741, 8736, 8978, 8857, 8747, 8750, + 8801, 8780, 8776, 8765, 8733, 8800, 8814, 8815, 8804, 8805, 8734, 8757, + 8756, 9794, 9792, 176, 8242, 8243, 8451, 65284, 164, 65504, 65505, 8240, + 167, 8470, 9734, 9733, 9675, 9679, 9678, 9671, 9670, 9633, 9632, 9651, + 9650, 8251, 8594, 8592, 8593, 8595, 12307, 58662, 58663, 58664, 58665, + 58666, 58667, 58668, 58669, 58670, 58671, 58672, 58673, 58674, 58675, + 58676, 58677, 58678, 58679, 58680, 58681, 58682, 58683, 58684, 58685, + 58686, 58687, 58688, 58689, 58690, 58691, 58692, 58693, 58694, 58695, + 58696, 58697, 58698, 58699, 58700, 58701, 58702, 58703, 58704, 58705, + 58706, 58707, 58708, 58709, 58710, 58711, 58712, 58713, 58714, 58715, + 58716, 58717, 58718, 58719, 58720, 58721, 58722, 58723, 58724, 58725, + 58726, 58727, 58728, 58729, 58730, 58731, 58732, 58733, 58734, 58735, + 58736, 58737, 58738, 58739, 58740, 58741, 58742, 58743, 58744, 58745, + 58746, 58747, 58748, 58749, 58750, 58751, 58752, 58753, 58754, 58755, + 58756, 58757, 8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, + 59238, 59239, 59240, 59241, 59242, 59243, 9352, 9353, 9354, 9355, 9356, + 9357, 9358, 9359, 9360, 9361, 9362, 9363, 9364, 9365, 9366, 9367, 9368, + 9369, 9370, 9371, 9332, 9333, 9334, 9335, 9336, 9337, 9338, 9339, 9340, + 9341, 9342, 9343, 9344, 9345, 9346, 9347, 9348, 9349, 9350, 9351, 9312, + 9313, 9314, 9315, 9316, 9317, 9318, 9319, 9320, 9321, 8364, 59245, 12832, + 12833, 12834, 12835, 12836, 12837, 12838, 12839, 12840, 12841, 59246, + 59247, 8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, + 8555, 59248, 59249, 58758, 58759, 58760, 58761, 58762, 58763, 58764, 58765, + 58766, 58767, 58768, 58769, 58770, 58771, 58772, 58773, 58774, 58775, + 58776, 58777, 58778, 58779, 58780, 58781, 58782, 58783, 58784, 58785, + 58786, 58787, 58788, 58789, 58790, 58791, 58792, 58793, 58794, 58795, + 58796, 58797, 58798, 58799, 58800, 58801, 58802, 58803, 58804, 58805, + 58806, 58807, 58808, 58809, 58810, 58811, 58812, 58813, 58814, 58815, + 58816, 58817, 58818, 58819, 58820, 58821, 58822, 58823, 58824, 58825, + 58826, 58827, 58828, 58829, 58830, 58831, 58832, 58833, 58834, 58835, + 58836, 58837, 58838, 58839, 58840, 58841, 58842, 58843, 58844, 58845, + 58846, 58847, 58848, 58849, 58850, 58851, 58852, 12288, 65281, 65282, + 65283, 65509, 65285, 65286, 65287, 65288, 65289, 65290, 65291, 65292, + 65293, 65294, 65295, 65296, 65297, 65298, 65299, 65300, 65301, 65302, + 65303, 65304, 65305, 65306, 65307, 65308, 65309, 65310, 65311, 65312, + 65313, 65314, 65315, 65316, 65317, 65318, 65319, 65320, 65321, 65322, + 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, 65332, + 65333, 65334, 65335, 65336, 65337, 65338, 65339, 65340, 65341, 65342, + 65343, 65344, 65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, + 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, 65361, 65362, + 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, 65371, 65372, + 65373, 65507, 58854, 58855, 58856, 58857, 58858, 58859, 58860, 58861, + 58862, 58863, 58864, 58865, 58866, 58867, 58868, 58869, 58870, 58871, + 58872, 58873, 58874, 58875, 58876, 58877, 58878, 58879, 58880, 58881, + 58882, 58883, 58884, 58885, 58886, 58887, 58888, 58889, 58890, 58891, + 58892, 58893, 58894, 58895, 58896, 58897, 58898, 58899, 58900, 58901, + 58902, 58903, 58904, 58905, 58906, 58907, 58908, 58909, 58910, 58911, + 58912, 58913, 58914, 58915, 58916, 58917, 58918, 58919, 58920, 58921, + 58922, 58923, 58924, 58925, 58926, 58927, 58928, 58929, 58930, 58931, + 58932, 58933, 58934, 58935, 58936, 58937, 58938, 58939, 58940, 58941, + 58942, 58943, 58944, 58945, 58946, 58947, 58948, 58949, 12353, 12354, + 12355, 12356, 12357, 12358, 12359, 12360, 12361, 12362, 12363, 12364, + 12365, 12366, 12367, 12368, 12369, 12370, 12371, 12372, 12373, 12374, + 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, 12384, + 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, + 12395, 12396, 12397, 12398, 12399, 12400, 12401, 12402, 12403, 12404, + 12405, 12406, 12407, 12408, 12409, 12410, 12411, 12412, 12413, 12414, + 12415, 12416, 12417, 12418, 12419, 12420, 12421, 12422, 12423, 12424, + 12425, 12426, 12427, 12428, 12429, 12430, 12431, 12432, 12433, 12434, + 12435, 59250, 59251, 59252, 59253, 59254, 59255, 59256, 59257, 59258, + 59259, 59260, 58950, 58951, 58952, 58953, 58954, 58955, 58956, 58957, + 58958, 58959, 58960, 58961, 58962, 58963, 58964, 58965, 58966, 58967, + 58968, 58969, 58970, 58971, 58972, 58973, 58974, 58975, 58976, 58977, + 58978, 58979, 58980, 58981, 58982, 58983, 58984, 58985, 58986, 58987, + 58988, 58989, 58990, 58991, 58992, 58993, 58994, 58995, 58996, 58997, + 58998, 58999, 59000, 59001, 59002, 59003, 59004, 59005, 59006, 59007, + 59008, 59009, 59010, 59011, 59012, 59013, 59014, 59015, 59016, 59017, + 59018, 59019, 59020, 59021, 59022, 59023, 59024, 59025, 59026, 59027, + 59028, 59029, 59030, 59031, 59032, 59033, 59034, 59035, 59036, 59037, + 59038, 59039, 59040, 59041, 59042, 59043, 59044, 59045, 12449, 12450, + 12451, 12452, 12453, 12454, 12455, 12456, 12457, 12458, 12459, 12460, + 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, + 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, + 12481, 12482, 12483, 12484, 12485, 12486, 12487, 12488, 12489, 12490, + 12491, 12492, 12493, 12494, 12495, 12496, 12497, 12498, 12499, 12500, + 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, + 12511, 12512, 12513, 12514, 12515, 12516, 12517, 12518, 12519, 12520, + 12521, 12522, 12523, 12524, 12525, 12526, 12527, 12528, 12529, 12530, + 12531, 12532, 12533, 12534, 59261, 59262, 59263, 59264, 59265, 59266, + 59267, 59268, 59046, 59047, 59048, 59049, 59050, 59051, 59052, 59053, + 59054, 59055, 59056, 59057, 59058, 59059, 59060, 59061, 59062, 59063, + 59064, 59065, 59066, 59067, 59068, 59069, 59070, 59071, 59072, 59073, + 59074, 59075, 59076, 59077, 59078, 59079, 59080, 59081, 59082, 59083, + 59084, 59085, 59086, 59087, 59088, 59089, 59090, 59091, 59092, 59093, + 59094, 59095, 59096, 59097, 59098, 59099, 59100, 59101, 59102, 59103, + 59104, 59105, 59106, 59107, 59108, 59109, 59110, 59111, 59112, 59113, + 59114, 59115, 59116, 59117, 59118, 59119, 59120, 59121, 59122, 59123, + 59124, 59125, 59126, 59127, 59128, 59129, 59130, 59131, 59132, 59133, + 59134, 59135, 59136, 59137, 59138, 59139, 59140, 59141, 913, 914, 915, 916, + 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, + 933, 934, 935, 936, 937, 59269, 59270, 59271, 59272, 59273, 59274, 59275, + 59276, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, + 958, 959, 960, 961, 963, 964, 965, 966, 967, 968, 969, 59277, 59278, 59279, + 59280, 59281, 59282, 59283, 65077, 65078, 65081, 65082, 65087, 65088, + 65085, 65086, 65089, 65090, 65091, 65092, 59284, 59285, 65083, 65084, + 65079, 65080, 65073, 59286, 65075, 65076, 59287, 59288, 59289, 59290, + 59291, 59292, 59293, 59294, 59295, 59142, 59143, 59144, 59145, 59146, + 59147, 59148, 59149, 59150, 59151, 59152, 59153, 59154, 59155, 59156, + 59157, 59158, 59159, 59160, 59161, 59162, 59163, 59164, 59165, 59166, + 59167, 59168, 59169, 59170, 59171, 59172, 59173, 59174, 59175, 59176, + 59177, 59178, 59179, 59180, 59181, 59182, 59183, 59184, 59185, 59186, + 59187, 59188, 59189, 59190, 59191, 59192, 59193, 59194, 59195, 59196, + 59197, 59198, 59199, 59200, 59201, 59202, 59203, 59204, 59205, 59206, + 59207, 59208, 59209, 59210, 59211, 59212, 59213, 59214, 59215, 59216, + 59217, 59218, 59219, 59220, 59221, 59222, 59223, 59224, 59225, 59226, + 59227, 59228, 59229, 59230, 59231, 59232, 59233, 59234, 59235, 59236, + 59237, 1040, 1041, 1042, 1043, 1044, 1045, 1025, 1046, 1047, 1048, 1049, + 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, + 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 59296, 59297, + 59298, 59299, 59300, 59301, 59302, 59303, 59304, 59305, 59306, 59307, + 59308, 59309, 59310, 1072, 1073, 1074, 1075, 1076, 1077, 1105, 1078, 1079, + 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, + 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, + 59311, 59312, 59313, 59314, 59315, 59316, 59317, 59318, 59319, 59320, + 59321, 59322, 59323, 714, 715, 729, 8211, 8213, 8229, 8245, 8453, 8457, + 8598, 8599, 8600, 8601, 8725, 8735, 8739, 8786, 8806, 8807, 8895, 9552, + 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, + 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, + 9577, 9578, 9579, 9580, 9581, 9582, 9583, 9584, 9585, 9586, 9587, 9601, + 9602, 9603, 9604, 9605, 9606, 9607, 9608, 9609, 9610, 9611, 9612, 9613, + 9614, 9615, 9619, 9620, 9621, 9660, 9661, 9698, 9699, 9700, 9701, 9737, + 8853, 12306, 12317, 12318, 59324, 59325, 59326, 59327, 59328, 59329, 59330, + 59331, 59332, 59333, 59334, 257, 225, 462, 224, 275, 233, 283, 232, 299, + 237, 464, 236, 333, 243, 466, 242, 363, 250, 468, 249, 470, 472, 474, 476, + 252, 234, 593, 59335, 324, 328, 505, 609, 59337, 59338, 59339, 59340, + 12549, 12550, 12551, 12552, 12553, 12554, 12555, 12556, 12557, 12558, + 12559, 12560, 12561, 12562, 12563, 12564, 12565, 12566, 12567, 12568, + 12569, 12570, 12571, 12572, 12573, 12574, 12575, 12576, 12577, 12578, + 12579, 12580, 12581, 12582, 12583, 12584, 12585, 59341, 59342, 59343, + 59344, 59345, 59346, 59347, 59348, 59349, 59350, 59351, 59352, 59353, + 59354, 59355, 59356, 59357, 59358, 59359, 59360, 59361, 12321, 12322, + 12323, 12324, 12325, 12326, 12327, 12328, 12329, 12963, 13198, 13199, + 13212, 13213, 13214, 13217, 13252, 13262, 13265, 13266, 13269, 65072, + 65506, 65508, 59362, 8481, 12849, 59363, 8208, 59364, 59365, 59366, 12540, + 12443, 12444, 12541, 12542, 12294, 12445, 12446, 65097, 65098, 65099, + 65100, 65101, 65102, 65103, 65104, 65105, 65106, 65108, 65109, 65110, + 65111, 65113, 65114, 65115, 65116, 65117, 65118, 65119, 65120, 65121, + 65122, 65123, 65124, 65125, 65126, 65128, 65129, 65130, 65131, 12350, + 12272, 12273, 12274, 12275, 12276, 12277, 12278, 12279, 12280, 12281, + 12282, 12283, 12295, 59380, 59381, 59382, 59383, 59384, 59385, 59386, + 59387, 59388, 59389, 59390, 59391, 59392, 9472, 9473, 9474, 9475, 9476, + 9477, 9478, 9479, 9480, 9481, 9482, 9483, 9484, 9485, 9486, 9487, 9488, + 9489, 9490, 9491, 9492, 9493, 9494, 9495, 9496, 9497, 9498, 9499, 9500, + 9501, 9502, 9503, 9504, 9505, 9506, 9507, 9508, 9509, 9510, 9511, 9512, + 9513, 9514, 9515, 9516, 9517, 9518, 9519, 9520, 9521, 9522, 9523, 9524, + 9525, 9526, 9527, 9528, 9529, 9530, 9531, 9532, 9533, 9534, 9535, 9536, + 9537, 9538, 9539, 9540, 9541, 9542, 9543, 9544, 9545, 9546, 9547, 59393, + 59394, 59395, 59396, 59397, 59398, 59399, 59400, 59401, 59402, 59403, + 59404, 59405, 59406, 59407, 29404, 29405, 29407, 29410, 29411, 29412, + 29413, 29414, 29415, 29418, 29419, 29429, 29430, 29433, 29437, 29438, + 29439, 29440, 29442, 29444, 29445, 29446, 29447, 29448, 29449, 29451, + 29452, 29453, 29455, 29456, 29457, 29458, 29460, 29464, 29465, 29466, + 29471, 29472, 29475, 29476, 29478, 29479, 29480, 29485, 29487, 29488, + 29490, 29491, 29493, 29494, 29498, 29499, 29500, 29501, 29504, 29505, + 29506, 29507, 29508, 29509, 29510, 29511, 29512, 29513, 29514, 29515, + 29516, 29518, 29519, 29521, 29523, 29524, 29525, 29526, 29528, 29529, + 29530, 29531, 29532, 29533, 29534, 29535, 29537, 29538, 29539, 29540, + 29541, 29542, 29543, 29544, 29545, 29546, 29547, 29550, 29552, 29553, + 57344, 57345, 57346, 57347, 57348, 57349, 57350, 57351, 57352, 57353, + 57354, 57355, 57356, 57357, 57358, 57359, 57360, 57361, 57362, 57363, + 57364, 57365, 57366, 57367, 57368, 57369, 57370, 57371, 57372, 57373, + 57374, 57375, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57383, + 57384, 57385, 57386, 57387, 57388, 57389, 57390, 57391, 57392, 57393, + 57394, 57395, 57396, 57397, 57398, 57399, 57400, 57401, 57402, 57403, + 57404, 57405, 57406, 57407, 57408, 57409, 57410, 57411, 57412, 57413, + 57414, 57415, 57416, 57417, 57418, 57419, 57420, 57421, 57422, 57423, + 57424, 57425, 57426, 57427, 57428, 57429, 57430, 57431, 57432, 57433, + 57434, 57435, 57436, 57437, 29554, 29555, 29556, 29557, 29558, 29559, + 29560, 29561, 29562, 29563, 29564, 29565, 29567, 29568, 29569, 29570, + 29571, 29573, 29574, 29576, 29578, 29580, 29581, 29583, 29584, 29586, + 29587, 29588, 29589, 29591, 29592, 29593, 29594, 29596, 29597, 29598, + 29600, 29601, 29603, 29604, 29605, 29606, 29607, 29608, 29610, 29612, + 29613, 29617, 29620, 29621, 29622, 29624, 29625, 29628, 29629, 29630, + 29631, 29633, 29635, 29636, 29637, 29638, 29639, 29643, 29644, 29646, + 29650, 29651, 29652, 29653, 29654, 29655, 29656, 29658, 29659, 29660, + 29661, 29663, 29665, 29666, 29667, 29668, 29670, 29672, 29674, 29675, + 29676, 29678, 29679, 29680, 29681, 29683, 29684, 29685, 29686, 29687, + 57438, 57439, 57440, 57441, 57442, 57443, 57444, 57445, 57446, 57447, + 57448, 57449, 57450, 57451, 57452, 57453, 57454, 57455, 57456, 57457, + 57458, 57459, 57460, 57461, 57462, 57463, 57464, 57465, 57466, 57467, + 57468, 57469, 57470, 57471, 57472, 57473, 57474, 57475, 57476, 57477, + 57478, 57479, 57480, 57481, 57482, 57483, 57484, 57485, 57486, 57487, + 57488, 57489, 57490, 57491, 57492, 57493, 57494, 57495, 57496, 57497, + 57498, 57499, 57500, 57501, 57502, 57503, 57504, 57505, 57506, 57507, + 57508, 57509, 57510, 57511, 57512, 57513, 57514, 57515, 57516, 57517, + 57518, 57519, 57520, 57521, 57522, 57523, 57524, 57525, 57526, 57527, + 57528, 57529, 57530, 57531, 29688, 29689, 29690, 29691, 29692, 29693, + 29694, 29695, 29696, 29697, 29698, 29700, 29703, 29704, 29707, 29708, + 29709, 29710, 29713, 29714, 29715, 29716, 29717, 29718, 29719, 29720, + 29721, 29724, 29725, 29726, 29727, 29728, 29729, 29731, 29732, 29735, + 29737, 29739, 29741, 29743, 29745, 29746, 29751, 29752, 29753, 29754, + 29755, 29757, 29758, 29759, 29760, 29762, 29763, 29764, 29765, 29766, + 29767, 29768, 29769, 29770, 29771, 29772, 29773, 29774, 29775, 29776, + 29777, 29778, 29779, 29780, 29782, 29784, 29789, 29792, 29793, 29794, + 29795, 29796, 29797, 29798, 29799, 29800, 29801, 29802, 29803, 29804, + 29806, 29807, 29809, 29810, 29811, 29812, 29813, 29816, 29817, 29818, + 57532, 57533, 57534, 57535, 57536, 57537, 57538, 57539, 57540, 57541, + 57542, 57543, 57544, 57545, 57546, 57547, 57548, 57549, 57550, 57551, + 57552, 57553, 57554, 57555, 57556, 57557, 57558, 57559, 57560, 57561, + 57562, 57563, 57564, 57565, 57566, 57567, 57568, 57569, 57570, 57571, + 57572, 57573, 57574, 57575, 57576, 57577, 57578, 57579, 57580, 57581, + 57582, 57583, 57584, 57585, 57586, 57587, 57588, 57589, 57590, 57591, + 57592, 57593, 57594, 57595, 57596, 57597, 57598, 57599, 57600, 57601, + 57602, 57603, 57604, 57605, 57606, 57607, 57608, 57609, 57610, 57611, + 57612, 57613, 57614, 57615, 57616, 57617, 57618, 57619, 57620, 57621, + 57622, 57623, 57624, 57625, 29819, 29820, 29821, 29823, 29826, 29828, + 29829, 29830, 29832, 29833, 29834, 29836, 29837, 29839, 29841, 29842, + 29843, 29844, 29845, 29846, 29847, 29848, 29849, 29850, 29851, 29853, + 29855, 29856, 29857, 29858, 29859, 29860, 29861, 29862, 29866, 29867, + 29868, 29869, 29870, 29871, 29872, 29873, 29874, 29875, 29876, 29877, + 29878, 29879, 29880, 29881, 29883, 29884, 29885, 29886, 29887, 29888, + 29889, 29890, 29891, 29892, 29893, 29894, 29895, 29896, 29897, 29898, + 29899, 29900, 29901, 29902, 29903, 29904, 29905, 29907, 29908, 29909, + 29910, 29911, 29912, 29913, 29914, 29915, 29917, 29919, 29921, 29925, + 29927, 29928, 29929, 29930, 29931, 29932, 29933, 29936, 29937, 29938, + 57626, 57627, 57628, 57629, 57630, 57631, 57632, 57633, 57634, 57635, + 57636, 57637, 57638, 57639, 57640, 57641, 57642, 57643, 57644, 57645, + 57646, 57647, 57648, 57649, 57650, 57651, 57652, 57653, 57654, 57655, + 57656, 57657, 57658, 57659, 57660, 57661, 57662, 57663, 57664, 57665, + 57666, 57667, 57668, 57669, 57670, 57671, 57672, 57673, 57674, 57675, + 57676, 57677, 57678, 57679, 57680, 57681, 57682, 57683, 57684, 57685, + 57686, 57687, 57688, 57689, 57690, 57691, 57692, 57693, 57694, 57695, + 57696, 57697, 57698, 57699, 57700, 57701, 57702, 57703, 57704, 57705, + 57706, 57707, 57708, 57709, 57710, 57711, 57712, 57713, 57714, 57715, + 57716, 57717, 57718, 57719, 29939, 29941, 29944, 29945, 29946, 29947, + 29948, 29949, 29950, 29952, 29953, 29954, 29955, 29957, 29958, 29959, + 29960, 29961, 29962, 29963, 29964, 29966, 29968, 29970, 29972, 29973, + 29974, 29975, 29979, 29981, 29982, 29984, 29985, 29986, 29987, 29988, + 29990, 29991, 29994, 29998, 30004, 30006, 30009, 30012, 30013, 30015, + 30017, 30018, 30019, 30020, 30022, 30023, 30025, 30026, 30029, 30032, + 30033, 30034, 30035, 30037, 30038, 30039, 30040, 30045, 30046, 30047, + 30048, 30049, 30050, 30051, 30052, 30055, 30056, 30057, 30059, 30060, + 30061, 30062, 30063, 30064, 30065, 30067, 30069, 30070, 30071, 30074, + 30075, 30076, 30077, 30078, 30080, 30081, 30082, 30084, 30085, 30087, + 57720, 57721, 57722, 57723, 57724, 57725, 57726, 57727, 57728, 57729, + 57730, 57731, 57732, 57733, 57734, 57735, 57736, 57737, 57738, 57739, + 57740, 57741, 57742, 57743, 57744, 57745, 57746, 57747, 57748, 57749, + 57750, 57751, 57752, 57753, 57754, 57755, 57756, 57757, 57758, 57759, + 57760, 57761, 57762, 57763, 57764, 57765, 57766, 57767, 57768, 57769, + 57770, 57771, 57772, 57773, 57774, 57775, 57776, 57777, 57778, 57779, + 57780, 57781, 57782, 57783, 57784, 57785, 57786, 57787, 57788, 57789, + 57790, 57791, 57792, 57793, 57794, 57795, 57796, 57797, 57798, 57799, + 57800, 57801, 57802, 57803, 57804, 57805, 57806, 57807, 57808, 57809, + 57810, 57811, 57812, 57813, 30088, 30089, 30090, 30092, 30093, 30094, + 30096, 30099, 30101, 30104, 30107, 30108, 30110, 30114, 30118, 30119, + 30120, 30121, 30122, 30125, 30134, 30135, 30138, 30139, 30143, 30144, + 30145, 30150, 30155, 30156, 30158, 30159, 30160, 30161, 30163, 30167, + 30169, 30170, 30172, 30173, 30175, 30176, 30177, 30181, 30185, 30188, + 30189, 30190, 30191, 30194, 30195, 30197, 30198, 30199, 30200, 30202, + 30203, 30205, 30206, 30210, 30212, 30214, 30215, 30216, 30217, 30219, + 30221, 30222, 30223, 30225, 30226, 30227, 30228, 30230, 30234, 30236, + 30237, 30238, 30241, 30243, 30247, 30248, 30252, 30254, 30255, 30257, + 30258, 30262, 30263, 30265, 30266, 30267, 30269, 30273, 30274, 30276, + 57814, 57815, 57816, 57817, 57818, 57819, 57820, 57821, 57822, 57823, + 57824, 57825, 57826, 57827, 57828, 57829, 57830, 57831, 57832, 57833, + 57834, 57835, 57836, 57837, 57838, 57839, 57840, 57841, 57842, 57843, + 57844, 57845, 57846, 57847, 57848, 57849, 57850, 57851, 57852, 57853, + 57854, 57855, 57856, 57857, 57858, 57859, 57860, 57861, 57862, 57863, + 57864, 57865, 57866, 57867, 57868, 57869, 57870, 57871, 57872, 57873, + 57874, 57875, 57876, 57877, 57878, 57879, 57880, 57881, 57882, 57883, + 57884, 57885, 57886, 57887, 57888, 57889, 57890, 57891, 57892, 57893, + 57894, 57895, 57896, 57897, 57898, 57899, 57900, 57901, 57902, 57903, + 57904, 57905, 57906, 57907, 30277, 30278, 30279, 30280, 30281, 30282, + 30283, 30286, 30287, 30288, 30289, 30290, 30291, 30293, 30295, 30296, + 30297, 30298, 30299, 30301, 30303, 30304, 30305, 30306, 30308, 30309, + 30310, 30311, 30312, 30313, 30314, 30316, 30317, 30318, 30320, 30321, + 30322, 30323, 30324, 30325, 30326, 30327, 30329, 30330, 30332, 30335, + 30336, 30337, 30339, 30341, 30345, 30346, 30348, 30349, 30351, 30352, + 30354, 30356, 30357, 30359, 30360, 30362, 30363, 30364, 30365, 30366, + 30367, 30368, 30369, 30370, 30371, 30373, 30374, 30375, 30376, 30377, + 30378, 30379, 30380, 30381, 30383, 30384, 30387, 30389, 30390, 30391, + 30392, 30393, 30394, 30395, 30396, 30397, 30398, 30400, 30401, 30403, + 21834, 38463, 22467, 25384, 21710, 21769, 21696, 30353, 30284, 34108, + 30702, 33406, 30861, 29233, 38552, 38797, 27688, 23433, 20474, 25353, + 26263, 23736, 33018, 26696, 32942, 26114, 30414, 20985, 25942, 29100, + 32753, 34948, 20658, 22885, 25034, 28595, 33453, 25420, 25170, 21485, + 21543, 31494, 20843, 30116, 24052, 25300, 36299, 38774, 25226, 32793, + 22365, 38712, 32610, 29240, 30333, 26575, 30334, 25670, 20336, 36133, + 25308, 31255, 26001, 29677, 25644, 25203, 33324, 39041, 26495, 29256, + 25198, 25292, 20276, 29923, 21322, 21150, 32458, 37030, 24110, 26758, + 27036, 33152, 32465, 26834, 30917, 34444, 38225, 20621, 35876, 33502, + 32990, 21253, 35090, 21093, 30404, 30407, 30409, 30411, 30412, 30419, + 30421, 30425, 30426, 30428, 30429, 30430, 30432, 30433, 30434, 30435, + 30436, 30438, 30439, 30440, 30441, 30442, 30443, 30444, 30445, 30448, + 30451, 30453, 30454, 30455, 30458, 30459, 30461, 30463, 30464, 30466, + 30467, 30469, 30470, 30474, 30476, 30478, 30479, 30480, 30481, 30482, + 30483, 30484, 30485, 30486, 30487, 30488, 30491, 30492, 30493, 30494, + 30497, 30499, 30500, 30501, 30503, 30506, 30507, 30508, 30510, 30512, + 30513, 30514, 30515, 30516, 30521, 30523, 30525, 30526, 30527, 30530, + 30532, 30533, 30534, 30536, 30537, 30538, 30539, 30540, 30541, 30542, + 30543, 30546, 30547, 30548, 30549, 30550, 30551, 30552, 30553, 30556, + 34180, 38649, 20445, 22561, 39281, 23453, 25265, 25253, 26292, 35961, + 40077, 29190, 26479, 30865, 24754, 21329, 21271, 36744, 32972, 36125, + 38049, 20493, 29384, 22791, 24811, 28953, 34987, 22868, 33519, 26412, + 31528, 23849, 32503, 29997, 27893, 36454, 36856, 36924, 40763, 27604, + 37145, 31508, 24444, 30887, 34006, 34109, 27605, 27609, 27606, 24065, + 24199, 30201, 38381, 25949, 24330, 24517, 36767, 22721, 33218, 36991, + 38491, 38829, 36793, 32534, 36140, 25153, 20415, 21464, 21342, 36776, + 36777, 36779, 36941, 26631, 24426, 33176, 34920, 40150, 24971, 21035, + 30250, 24428, 25996, 28626, 28392, 23486, 25672, 20853, 20912, 26564, + 19993, 31177, 39292, 28851, 30557, 30558, 30559, 30560, 30564, 30567, + 30569, 30570, 30573, 30574, 30575, 30576, 30577, 30578, 30579, 30580, + 30581, 30582, 30583, 30584, 30586, 30587, 30588, 30593, 30594, 30595, + 30598, 30599, 30600, 30601, 30602, 30603, 30607, 30608, 30611, 30612, + 30613, 30614, 30615, 30616, 30617, 30618, 30619, 30620, 30621, 30622, + 30625, 30627, 30628, 30630, 30632, 30635, 30637, 30638, 30639, 30641, + 30642, 30644, 30646, 30647, 30648, 30649, 30650, 30652, 30654, 30656, + 30657, 30658, 30659, 30660, 30661, 30662, 30663, 30664, 30665, 30666, + 30667, 30668, 30670, 30671, 30672, 30673, 30674, 30675, 30676, 30677, + 30678, 30680, 30681, 30682, 30685, 30686, 30687, 30688, 30689, 30692, + 30149, 24182, 29627, 33760, 25773, 25320, 38069, 27874, 21338, 21187, + 25615, 38082, 31636, 20271, 24091, 33334, 33046, 33162, 28196, 27850, + 39539, 25429, 21340, 21754, 34917, 22496, 19981, 24067, 27493, 31807, + 37096, 24598, 25830, 29468, 35009, 26448, 25165, 36130, 30572, 36393, + 37319, 24425, 33756, 34081, 39184, 21442, 34453, 27531, 24813, 24808, + 28799, 33485, 33329, 20179, 27815, 34255, 25805, 31961, 27133, 26361, + 33609, 21397, 31574, 20391, 20876, 27979, 23618, 36461, 25554, 21449, + 33580, 33590, 26597, 30900, 25661, 23519, 23700, 24046, 35815, 25286, + 26612, 35962, 25600, 25530, 34633, 39307, 35863, 32544, 38130, 20135, + 38416, 39076, 26124, 29462, 30694, 30696, 30698, 30703, 30704, 30705, + 30706, 30708, 30709, 30711, 30713, 30714, 30715, 30716, 30723, 30724, + 30725, 30726, 30727, 30728, 30730, 30731, 30734, 30735, 30736, 30739, + 30741, 30745, 30747, 30750, 30752, 30753, 30754, 30756, 30760, 30762, + 30763, 30766, 30767, 30769, 30770, 30771, 30773, 30774, 30781, 30783, + 30785, 30786, 30787, 30788, 30790, 30792, 30793, 30794, 30795, 30797, + 30799, 30801, 30803, 30804, 30808, 30809, 30810, 30811, 30812, 30814, + 30815, 30816, 30817, 30818, 30819, 30820, 30821, 30822, 30823, 30824, + 30825, 30831, 30832, 30833, 30834, 30835, 30836, 30837, 30838, 30840, + 30841, 30842, 30843, 30845, 30846, 30847, 30848, 30849, 30850, 30851, + 22330, 23581, 24120, 38271, 20607, 32928, 21378, 25950, 30021, 21809, + 20513, 36229, 25220, 38046, 26397, 22066, 28526, 24034, 21557, 28818, + 36710, 25199, 25764, 25507, 24443, 28552, 37108, 33251, 36784, 23576, + 26216, 24561, 27785, 38472, 36225, 34924, 25745, 31216, 22478, 27225, + 25104, 21576, 20056, 31243, 24809, 28548, 35802, 25215, 36894, 39563, + 31204, 21507, 30196, 25345, 21273, 27744, 36831, 24347, 39536, 32827, + 40831, 20360, 23610, 36196, 32709, 26021, 28861, 20805, 20914, 34411, + 23815, 23456, 25277, 37228, 30068, 36364, 31264, 24833, 31609, 20167, + 32504, 30597, 19985, 33261, 21021, 20986, 27249, 21416, 36487, 38148, + 38607, 28353, 38500, 26970, 30852, 30853, 30854, 30856, 30858, 30859, + 30863, 30864, 30866, 30868, 30869, 30870, 30873, 30877, 30878, 30880, + 30882, 30884, 30886, 30888, 30889, 30890, 30891, 30892, 30893, 30894, + 30895, 30901, 30902, 30903, 30904, 30906, 30907, 30908, 30909, 30911, + 30912, 30914, 30915, 30916, 30918, 30919, 30920, 30924, 30925, 30926, + 30927, 30929, 30930, 30931, 30934, 30935, 30936, 30938, 30939, 30940, + 30941, 30942, 30943, 30944, 30945, 30946, 30947, 30948, 30949, 30950, + 30951, 30953, 30954, 30955, 30957, 30958, 30959, 30960, 30961, 30963, + 30965, 30966, 30968, 30969, 30971, 30972, 30973, 30974, 30975, 30976, + 30978, 30979, 30980, 30982, 30983, 30984, 30985, 30986, 30987, 30988, + 30784, 20648, 30679, 25616, 35302, 22788, 25571, 24029, 31359, 26941, + 20256, 33337, 21912, 20018, 30126, 31383, 24162, 24202, 38383, 21019, + 21561, 28810, 25462, 38180, 22402, 26149, 26943, 37255, 21767, 28147, + 32431, 34850, 25139, 32496, 30133, 33576, 30913, 38604, 36766, 24904, + 29943, 35789, 27492, 21050, 36176, 27425, 32874, 33905, 22257, 21254, + 20174, 19995, 20945, 31895, 37259, 31751, 20419, 36479, 31713, 31388, + 25703, 23828, 20652, 33030, 30209, 31929, 28140, 32736, 26449, 23384, + 23544, 30923, 25774, 25619, 25514, 25387, 38169, 25645, 36798, 31572, + 30249, 25171, 22823, 21574, 27513, 20643, 25140, 24102, 27526, 20195, + 36151, 34955, 24453, 36910, 30989, 30990, 30991, 30992, 30993, 30994, + 30996, 30997, 30998, 30999, 31000, 31001, 31002, 31003, 31004, 31005, + 31007, 31008, 31009, 31010, 31011, 31013, 31014, 31015, 31016, 31017, + 31018, 31019, 31020, 31021, 31022, 31023, 31024, 31025, 31026, 31027, + 31029, 31030, 31031, 31032, 31033, 31037, 31039, 31042, 31043, 31044, + 31045, 31047, 31050, 31051, 31052, 31053, 31054, 31055, 31056, 31057, + 31058, 31060, 31061, 31064, 31065, 31073, 31075, 31076, 31078, 31081, + 31082, 31083, 31084, 31086, 31088, 31089, 31090, 31091, 31092, 31093, + 31094, 31097, 31099, 31100, 31101, 31102, 31103, 31106, 31107, 31110, + 31111, 31112, 31113, 31115, 31116, 31117, 31118, 31120, 31121, 31122, + 24608, 32829, 25285, 20025, 21333, 37112, 25528, 32966, 26086, 27694, + 20294, 24814, 28129, 35806, 24377, 34507, 24403, 25377, 20826, 33633, + 26723, 20992, 25443, 36424, 20498, 23707, 31095, 23548, 21040, 31291, + 24764, 36947, 30423, 24503, 24471, 30340, 36460, 28783, 30331, 31561, + 30634, 20979, 37011, 22564, 20302, 28404, 36842, 25932, 31515, 29380, + 28068, 32735, 23265, 25269, 24213, 22320, 33922, 31532, 24093, 24351, + 36882, 32532, 39072, 25474, 28359, 30872, 28857, 20856, 38747, 22443, + 30005, 20291, 30008, 24215, 24806, 22880, 28096, 27583, 30857, 21500, + 38613, 20939, 20993, 25481, 21514, 38035, 35843, 36300, 29241, 30879, + 34678, 36845, 35853, 21472, 31123, 31124, 31125, 31126, 31127, 31128, + 31129, 31131, 31132, 31133, 31134, 31135, 31136, 31137, 31138, 31139, + 31140, 31141, 31142, 31144, 31145, 31146, 31147, 31148, 31149, 31150, + 31151, 31152, 31153, 31154, 31156, 31157, 31158, 31159, 31160, 31164, + 31167, 31170, 31172, 31173, 31175, 31176, 31178, 31180, 31182, 31183, + 31184, 31187, 31188, 31190, 31191, 31193, 31194, 31195, 31196, 31197, + 31198, 31200, 31201, 31202, 31205, 31208, 31210, 31212, 31214, 31217, + 31218, 31219, 31220, 31221, 31222, 31223, 31225, 31226, 31228, 31230, + 31231, 31233, 31236, 31237, 31239, 31240, 31241, 31242, 31244, 31247, + 31248, 31249, 31250, 31251, 31253, 31254, 31256, 31257, 31259, 31260, + 19969, 30447, 21486, 38025, 39030, 40718, 38189, 23450, 35746, 20002, + 19996, 20908, 33891, 25026, 21160, 26635, 20375, 24683, 20923, 27934, + 20828, 25238, 26007, 38497, 35910, 36887, 30168, 37117, 30563, 27602, + 29322, 29420, 35835, 22581, 30585, 36172, 26460, 38208, 32922, 24230, + 28193, 22930, 31471, 30701, 38203, 27573, 26029, 32526, 22534, 20817, + 38431, 23545, 22697, 21544, 36466, 25958, 39039, 22244, 38045, 30462, + 36929, 25479, 21702, 22810, 22842, 22427, 36530, 26421, 36346, 33333, + 21057, 24816, 22549, 34558, 23784, 40517, 20420, 39069, 35769, 23077, + 24694, 21380, 25212, 36943, 37122, 39295, 24681, 32780, 20799, 32819, + 23572, 39285, 27953, 20108, 31261, 31263, 31265, 31266, 31268, 31269, + 31270, 31271, 31272, 31273, 31274, 31275, 31276, 31277, 31278, 31279, + 31280, 31281, 31282, 31284, 31285, 31286, 31288, 31290, 31294, 31296, + 31297, 31298, 31299, 31300, 31301, 31303, 31304, 31305, 31306, 31307, + 31308, 31309, 31310, 31311, 31312, 31314, 31315, 31316, 31317, 31318, + 31320, 31321, 31322, 31323, 31324, 31325, 31326, 31327, 31328, 31329, + 31330, 31331, 31332, 31333, 31334, 31335, 31336, 31337, 31338, 31339, + 31340, 31341, 31342, 31343, 31345, 31346, 31347, 31349, 31355, 31356, + 31357, 31358, 31362, 31365, 31367, 31369, 31370, 31371, 31372, 31374, + 31375, 31376, 31379, 31380, 31385, 31386, 31387, 31390, 31393, 31394, + 36144, 21457, 32602, 31567, 20240, 20047, 38400, 27861, 29648, 34281, + 24070, 30058, 32763, 27146, 30718, 38034, 32321, 20961, 28902, 21453, + 36820, 33539, 36137, 29359, 39277, 27867, 22346, 33459, 26041, 32938, + 25151, 38450, 22952, 20223, 35775, 32442, 25918, 33778, 38750, 21857, + 39134, 32933, 21290, 35837, 21536, 32954, 24223, 27832, 36153, 33452, + 37210, 21545, 27675, 20998, 32439, 22367, 28954, 27774, 31881, 22859, + 20221, 24575, 24868, 31914, 20016, 23553, 26539, 34562, 23792, 38155, + 39118, 30127, 28925, 36898, 20911, 32541, 35773, 22857, 20964, 20315, + 21542, 22827, 25975, 32932, 23413, 25206, 25282, 36752, 24133, 27679, + 31526, 20239, 20440, 26381, 31395, 31396, 31399, 31401, 31402, 31403, + 31406, 31407, 31408, 31409, 31410, 31412, 31413, 31414, 31415, 31416, + 31417, 31418, 31419, 31420, 31421, 31422, 31424, 31425, 31426, 31427, + 31428, 31429, 31430, 31431, 31432, 31433, 31434, 31436, 31437, 31438, + 31439, 31440, 31441, 31442, 31443, 31444, 31445, 31447, 31448, 31450, + 31451, 31452, 31453, 31457, 31458, 31460, 31463, 31464, 31465, 31466, + 31467, 31468, 31470, 31472, 31473, 31474, 31475, 31476, 31477, 31478, + 31479, 31480, 31483, 31484, 31486, 31488, 31489, 31490, 31493, 31495, + 31497, 31500, 31501, 31502, 31504, 31506, 31507, 31510, 31511, 31512, + 31514, 31516, 31517, 31519, 31521, 31522, 31523, 31527, 31529, 31533, + 28014, 28074, 31119, 34993, 24343, 29995, 25242, 36741, 20463, 37340, + 26023, 33071, 33105, 24220, 33104, 36212, 21103, 35206, 36171, 22797, + 20613, 20184, 38428, 29238, 33145, 36127, 23500, 35747, 38468, 22919, + 32538, 21648, 22134, 22030, 35813, 25913, 27010, 38041, 30422, 28297, + 24178, 29976, 26438, 26577, 31487, 32925, 36214, 24863, 31174, 25954, + 36195, 20872, 21018, 38050, 32568, 32923, 32434, 23703, 28207, 26464, + 31705, 30347, 39640, 33167, 32660, 31957, 25630, 38224, 31295, 21578, + 21733, 27468, 25601, 25096, 40509, 33011, 30105, 21106, 38761, 33883, + 26684, 34532, 38401, 38548, 38124, 20010, 21508, 32473, 26681, 36319, + 32789, 26356, 24218, 32697, 31535, 31536, 31538, 31540, 31541, 31542, + 31543, 31545, 31547, 31549, 31551, 31552, 31553, 31554, 31555, 31556, + 31558, 31560, 31562, 31565, 31566, 31571, 31573, 31575, 31577, 31580, + 31582, 31583, 31585, 31587, 31588, 31589, 31590, 31591, 31592, 31593, + 31594, 31595, 31596, 31597, 31599, 31600, 31603, 31604, 31606, 31608, + 31610, 31612, 31613, 31615, 31617, 31618, 31619, 31620, 31622, 31623, + 31624, 31625, 31626, 31627, 31628, 31630, 31631, 31633, 31634, 31635, + 31638, 31640, 31641, 31642, 31643, 31646, 31647, 31648, 31651, 31652, + 31653, 31662, 31663, 31664, 31666, 31667, 31669, 31670, 31671, 31673, + 31674, 31675, 31676, 31677, 31678, 31679, 31680, 31682, 31683, 31684, + 22466, 32831, 26775, 24037, 25915, 21151, 24685, 40858, 20379, 36524, + 20844, 23467, 24339, 24041, 27742, 25329, 36129, 20849, 38057, 21246, + 27807, 33503, 29399, 22434, 26500, 36141, 22815, 36764, 33735, 21653, + 31629, 20272, 27837, 23396, 22993, 40723, 21476, 34506, 39592, 35895, + 32929, 25925, 39038, 22266, 38599, 21038, 29916, 21072, 23521, 25346, + 35074, 20054, 25296, 24618, 26874, 20851, 23448, 20896, 35266, 31649, + 39302, 32592, 24815, 28748, 36143, 20809, 24191, 36891, 29808, 35268, + 22317, 30789, 24402, 40863, 38394, 36712, 39740, 35809, 30328, 26690, + 26588, 36330, 36149, 21053, 36746, 28378, 26829, 38149, 37101, 22269, + 26524, 35065, 36807, 21704, 31685, 31688, 31689, 31690, 31691, 31693, + 31694, 31695, 31696, 31698, 31700, 31701, 31702, 31703, 31704, 31707, + 31708, 31710, 31711, 31712, 31714, 31715, 31716, 31719, 31720, 31721, + 31723, 31724, 31725, 31727, 31728, 31730, 31731, 31732, 31733, 31734, + 31736, 31737, 31738, 31739, 31741, 31743, 31744, 31745, 31746, 31747, + 31748, 31749, 31750, 31752, 31753, 31754, 31757, 31758, 31760, 31761, + 31762, 31763, 31764, 31765, 31767, 31768, 31769, 31770, 31771, 31772, + 31773, 31774, 31776, 31777, 31778, 31779, 31780, 31781, 31784, 31785, + 31787, 31788, 31789, 31790, 31791, 31792, 31793, 31794, 31795, 31796, + 31797, 31798, 31799, 31801, 31802, 31803, 31804, 31805, 31806, 31810, + 39608, 23401, 28023, 27686, 20133, 23475, 39559, 37219, 25000, 37039, + 38889, 21547, 28085, 23506, 20989, 21898, 32597, 32752, 25788, 25421, + 26097, 25022, 24717, 28938, 27735, 27721, 22831, 26477, 33322, 22741, + 22158, 35946, 27627, 37085, 22909, 32791, 21495, 28009, 21621, 21917, + 33655, 33743, 26680, 31166, 21644, 20309, 21512, 30418, 35977, 38402, + 27827, 28088, 36203, 35088, 40548, 36154, 22079, 40657, 30165, 24456, + 29408, 24680, 21756, 20136, 27178, 34913, 24658, 36720, 21700, 28888, + 34425, 40511, 27946, 23439, 24344, 32418, 21897, 20399, 29492, 21564, + 21402, 20505, 21518, 21628, 20046, 24573, 29786, 22774, 33899, 32993, + 34676, 29392, 31946, 28246, 31811, 31812, 31813, 31814, 31815, 31816, + 31817, 31818, 31819, 31820, 31822, 31823, 31824, 31825, 31826, 31827, + 31828, 31829, 31830, 31831, 31832, 31833, 31834, 31835, 31836, 31837, + 31838, 31839, 31840, 31841, 31842, 31843, 31844, 31845, 31846, 31847, + 31848, 31849, 31850, 31851, 31852, 31853, 31854, 31855, 31856, 31857, + 31858, 31861, 31862, 31863, 31864, 31865, 31866, 31870, 31871, 31872, + 31873, 31874, 31875, 31876, 31877, 31878, 31879, 31880, 31882, 31883, + 31884, 31885, 31886, 31887, 31888, 31891, 31892, 31894, 31897, 31898, + 31899, 31904, 31905, 31907, 31910, 31911, 31912, 31913, 31915, 31916, + 31917, 31919, 31920, 31924, 31925, 31926, 31927, 31928, 31930, 31931, + 24359, 34382, 21804, 25252, 20114, 27818, 25143, 33457, 21719, 21326, + 29502, 28369, 30011, 21010, 21270, 35805, 27088, 24458, 24576, 28142, + 22351, 27426, 29615, 26707, 36824, 32531, 25442, 24739, 21796, 30186, + 35938, 28949, 28067, 23462, 24187, 33618, 24908, 40644, 30970, 34647, + 31783, 30343, 20976, 24822, 29004, 26179, 24140, 24653, 35854, 28784, + 25381, 36745, 24509, 24674, 34516, 22238, 27585, 24724, 24935, 21321, + 24800, 26214, 36159, 31229, 20250, 28905, 27719, 35763, 35826, 32472, + 33636, 26127, 23130, 39746, 27985, 28151, 35905, 27963, 20249, 28779, + 33719, 25110, 24785, 38669, 36135, 31096, 20987, 22334, 22522, 26426, + 30072, 31293, 31215, 31637, 31935, 31936, 31938, 31939, 31940, 31942, + 31945, 31947, 31950, 31951, 31952, 31953, 31954, 31955, 31956, 31960, + 31962, 31963, 31965, 31966, 31969, 31970, 31971, 31972, 31973, 31974, + 31975, 31977, 31978, 31979, 31980, 31981, 31982, 31984, 31985, 31986, + 31987, 31988, 31989, 31990, 31991, 31993, 31994, 31996, 31997, 31998, + 31999, 32000, 32001, 32002, 32003, 32004, 32005, 32006, 32007, 32008, + 32009, 32011, 32012, 32013, 32014, 32015, 32016, 32017, 32018, 32019, + 32020, 32021, 32022, 32023, 32024, 32025, 32026, 32027, 32028, 32029, + 32030, 32031, 32033, 32035, 32036, 32037, 32038, 32040, 32041, 32042, + 32044, 32045, 32046, 32048, 32049, 32050, 32051, 32052, 32053, 32054, + 32908, 39269, 36857, 28608, 35749, 40481, 23020, 32489, 32521, 21513, + 26497, 26840, 36753, 31821, 38598, 21450, 24613, 30142, 27762, 21363, + 23241, 32423, 25380, 20960, 33034, 24049, 34015, 25216, 20864, 23395, + 20238, 31085, 21058, 24760, 27982, 23492, 23490, 35745, 35760, 26082, + 24524, 38469, 22931, 32487, 32426, 22025, 26551, 22841, 20339, 23478, + 21152, 33626, 39050, 36158, 30002, 38078, 20551, 31292, 20215, 26550, + 39550, 23233, 27516, 30417, 22362, 23574, 31546, 38388, 29006, 20860, + 32937, 33392, 22904, 32516, 33575, 26816, 26604, 30897, 30839, 25315, + 25441, 31616, 20461, 21098, 20943, 33616, 27099, 37492, 36341, 36145, + 35265, 38190, 31661, 20214, 32055, 32056, 32057, 32058, 32059, 32060, + 32061, 32062, 32063, 32064, 32065, 32066, 32067, 32068, 32069, 32070, + 32071, 32072, 32073, 32074, 32075, 32076, 32077, 32078, 32079, 32080, + 32081, 32082, 32083, 32084, 32085, 32086, 32087, 32088, 32089, 32090, + 32091, 32092, 32093, 32094, 32095, 32096, 32097, 32098, 32099, 32100, + 32101, 32102, 32103, 32104, 32105, 32106, 32107, 32108, 32109, 32111, + 32112, 32113, 32114, 32115, 32116, 32117, 32118, 32120, 32121, 32122, + 32123, 32124, 32125, 32126, 32127, 32128, 32129, 32130, 32131, 32132, + 32133, 32134, 32135, 32136, 32137, 32138, 32139, 32140, 32141, 32142, + 32143, 32144, 32145, 32146, 32147, 32148, 32149, 32150, 32151, 32152, + 20581, 33328, 21073, 39279, 28176, 28293, 28071, 24314, 20725, 23004, + 23558, 27974, 27743, 30086, 33931, 26728, 22870, 35762, 21280, 37233, + 38477, 34121, 26898, 30977, 28966, 33014, 20132, 37066, 27975, 39556, + 23047, 22204, 25605, 38128, 30699, 20389, 33050, 29409, 35282, 39290, + 32564, 32478, 21119, 25945, 37237, 36735, 36739, 21483, 31382, 25581, + 25509, 30342, 31224, 34903, 38454, 25130, 21163, 33410, 26708, 26480, + 25463, 30571, 31469, 27905, 32467, 35299, 22992, 25106, 34249, 33445, + 30028, 20511, 20171, 30117, 35819, 23626, 24062, 31563, 26020, 37329, + 20170, 27941, 35167, 32039, 38182, 20165, 35880, 36827, 38771, 26187, + 31105, 36817, 28908, 28024, 32153, 32154, 32155, 32156, 32157, 32158, + 32159, 32160, 32161, 32162, 32163, 32164, 32165, 32167, 32168, 32169, + 32170, 32171, 32172, 32173, 32175, 32176, 32177, 32178, 32179, 32180, + 32181, 32182, 32183, 32184, 32185, 32186, 32187, 32188, 32189, 32190, + 32191, 32192, 32193, 32194, 32195, 32196, 32197, 32198, 32199, 32200, + 32201, 32202, 32203, 32204, 32205, 32206, 32207, 32208, 32209, 32210, + 32211, 32212, 32213, 32214, 32215, 32216, 32217, 32218, 32219, 32220, + 32221, 32222, 32223, 32224, 32225, 32226, 32227, 32228, 32229, 32230, + 32231, 32232, 32233, 32234, 32235, 32236, 32237, 32238, 32239, 32240, + 32241, 32242, 32243, 32244, 32245, 32246, 32247, 32248, 32249, 32250, + 23613, 21170, 33606, 20834, 33550, 30555, 26230, 40120, 20140, 24778, + 31934, 31923, 32463, 20117, 35686, 26223, 39048, 38745, 22659, 25964, + 38236, 24452, 30153, 38742, 31455, 31454, 20928, 28847, 31384, 25578, + 31350, 32416, 29590, 38893, 20037, 28792, 20061, 37202, 21417, 25937, + 26087, 33276, 33285, 21646, 23601, 30106, 38816, 25304, 29401, 30141, + 23621, 39545, 33738, 23616, 21632, 30697, 20030, 27822, 32858, 25298, + 25454, 24040, 20855, 36317, 36382, 38191, 20465, 21477, 24807, 28844, + 21095, 25424, 40515, 23071, 20518, 30519, 21367, 32482, 25733, 25899, + 25225, 25496, 20500, 29237, 35273, 20915, 35776, 32477, 22343, 33740, + 38055, 20891, 21531, 23803, 32251, 32252, 32253, 32254, 32255, 32256, + 32257, 32258, 32259, 32260, 32261, 32262, 32263, 32264, 32265, 32266, + 32267, 32268, 32269, 32270, 32271, 32272, 32273, 32274, 32275, 32276, + 32277, 32278, 32279, 32280, 32281, 32282, 32283, 32284, 32285, 32286, + 32287, 32288, 32289, 32290, 32291, 32292, 32293, 32294, 32295, 32296, + 32297, 32298, 32299, 32300, 32301, 32302, 32303, 32304, 32305, 32306, + 32307, 32308, 32309, 32310, 32311, 32312, 32313, 32314, 32316, 32317, + 32318, 32319, 32320, 32322, 32323, 32324, 32325, 32326, 32328, 32329, + 32330, 32331, 32332, 32333, 32334, 32335, 32336, 32337, 32338, 32339, + 32340, 32341, 32342, 32343, 32344, 32345, 32346, 32347, 32348, 32349, + 20426, 31459, 27994, 37089, 39567, 21888, 21654, 21345, 21679, 24320, + 25577, 26999, 20975, 24936, 21002, 22570, 21208, 22350, 30733, 30475, + 24247, 24951, 31968, 25179, 25239, 20130, 28821, 32771, 25335, 28900, + 38752, 22391, 33499, 26607, 26869, 30933, 39063, 31185, 22771, 21683, + 21487, 28212, 20811, 21051, 23458, 35838, 32943, 21827, 22438, 24691, + 22353, 21549, 31354, 24656, 23380, 25511, 25248, 21475, 25187, 23495, + 26543, 21741, 31391, 33510, 37239, 24211, 35044, 22840, 22446, 25358, + 36328, 33007, 22359, 31607, 20393, 24555, 23485, 27454, 21281, 31568, + 29378, 26694, 30719, 30518, 26103, 20917, 20111, 30420, 23743, 31397, + 33909, 22862, 39745, 20608, 32350, 32351, 32352, 32353, 32354, 32355, + 32356, 32357, 32358, 32359, 32360, 32361, 32362, 32363, 32364, 32365, + 32366, 32367, 32368, 32369, 32370, 32371, 32372, 32373, 32374, 32375, + 32376, 32377, 32378, 32379, 32380, 32381, 32382, 32383, 32384, 32385, + 32387, 32388, 32389, 32390, 32391, 32392, 32393, 32394, 32395, 32396, + 32397, 32398, 32399, 32400, 32401, 32402, 32403, 32404, 32405, 32406, + 32407, 32408, 32409, 32410, 32412, 32413, 32414, 32430, 32436, 32443, + 32444, 32470, 32484, 32492, 32505, 32522, 32528, 32542, 32567, 32569, + 32571, 32572, 32573, 32574, 32575, 32576, 32577, 32579, 32582, 32583, + 32584, 32585, 32586, 32587, 32588, 32589, 32590, 32591, 32594, 32595, + 39304, 24871, 28291, 22372, 26118, 25414, 22256, 25324, 25193, 24275, + 38420, 22403, 25289, 21895, 34593, 33098, 36771, 21862, 33713, 26469, + 36182, 34013, 23146, 26639, 25318, 31726, 38417, 20848, 28572, 35888, + 25597, 35272, 25042, 32518, 28866, 28389, 29701, 27028, 29436, 24266, + 37070, 26391, 28010, 25438, 21171, 29282, 32769, 20332, 23013, 37226, + 28889, 28061, 21202, 20048, 38647, 38253, 34174, 30922, 32047, 20769, + 22418, 25794, 32907, 31867, 27882, 26865, 26974, 20919, 21400, 26792, + 29313, 40654, 31729, 29432, 31163, 28435, 29702, 26446, 37324, 40100, + 31036, 33673, 33620, 21519, 26647, 20029, 21385, 21169, 30782, 21382, + 21033, 20616, 20363, 20432, 32598, 32601, 32603, 32604, 32605, 32606, + 32608, 32611, 32612, 32613, 32614, 32615, 32619, 32620, 32621, 32623, + 32624, 32627, 32629, 32630, 32631, 32632, 32634, 32635, 32636, 32637, + 32639, 32640, 32642, 32643, 32644, 32645, 32646, 32647, 32648, 32649, + 32651, 32653, 32655, 32656, 32657, 32658, 32659, 32661, 32662, 32663, + 32664, 32665, 32667, 32668, 32672, 32674, 32675, 32677, 32678, 32680, + 32681, 32682, 32683, 32684, 32685, 32686, 32689, 32691, 32692, 32693, + 32694, 32695, 32698, 32699, 32702, 32704, 32706, 32707, 32708, 32710, + 32711, 32712, 32713, 32715, 32717, 32719, 32720, 32721, 32722, 32723, + 32726, 32727, 32729, 32730, 32731, 32732, 32733, 32734, 32738, 32739, + 30178, 31435, 31890, 27813, 38582, 21147, 29827, 21737, 20457, 32852, + 33714, 36830, 38256, 24265, 24604, 28063, 24088, 25947, 33080, 38142, + 24651, 28860, 32451, 31918, 20937, 26753, 31921, 33391, 20004, 36742, + 37327, 26238, 20142, 35845, 25769, 32842, 20698, 30103, 29134, 23525, + 36797, 28518, 20102, 25730, 38243, 24278, 26009, 21015, 35010, 28872, + 21155, 29454, 29747, 26519, 30967, 38678, 20020, 37051, 40158, 28107, + 20955, 36161, 21533, 25294, 29618, 33777, 38646, 40836, 38083, 20278, + 32666, 20940, 28789, 38517, 23725, 39046, 21478, 20196, 28316, 29705, + 27060, 30827, 39311, 30041, 21016, 30244, 27969, 26611, 20845, 40857, + 32843, 21657, 31548, 31423, 32740, 32743, 32744, 32746, 32747, 32748, + 32749, 32751, 32754, 32756, 32757, 32758, 32759, 32760, 32761, 32762, + 32765, 32766, 32767, 32770, 32775, 32776, 32777, 32778, 32782, 32783, + 32785, 32787, 32794, 32795, 32797, 32798, 32799, 32801, 32803, 32804, + 32811, 32812, 32813, 32814, 32815, 32816, 32818, 32820, 32825, 32826, + 32828, 32830, 32832, 32833, 32836, 32837, 32839, 32840, 32841, 32846, + 32847, 32848, 32849, 32851, 32853, 32854, 32855, 32857, 32859, 32860, + 32861, 32862, 32863, 32864, 32865, 32866, 32867, 32868, 32869, 32870, + 32871, 32872, 32875, 32876, 32877, 32878, 32879, 32880, 32882, 32883, + 32884, 32885, 32886, 32887, 32888, 32889, 32890, 32891, 32892, 32893, + 38534, 22404, 25314, 38471, 27004, 23044, 25602, 31699, 28431, 38475, + 33446, 21346, 39045, 24208, 28809, 25523, 21348, 34383, 40065, 40595, + 30860, 38706, 36335, 36162, 40575, 28510, 31108, 24405, 38470, 25134, + 39540, 21525, 38109, 20387, 26053, 23653, 23649, 32533, 34385, 27695, + 24459, 29575, 28388, 32511, 23782, 25371, 23402, 28390, 21365, 20081, + 25504, 30053, 25249, 36718, 20262, 20177, 27814, 32438, 35770, 33821, + 34746, 32599, 36923, 38179, 31657, 39585, 35064, 33853, 27931, 39558, + 32476, 22920, 40635, 29595, 30721, 34434, 39532, 39554, 22043, 21527, + 22475, 20080, 40614, 21334, 36808, 33033, 30610, 39314, 34542, 28385, + 34067, 26364, 24930, 28459, 32894, 32897, 32898, 32901, 32904, 32906, + 32909, 32910, 32911, 32912, 32913, 32914, 32916, 32917, 32919, 32921, + 32926, 32931, 32934, 32935, 32936, 32940, 32944, 32947, 32949, 32950, + 32952, 32953, 32955, 32965, 32967, 32968, 32969, 32970, 32971, 32975, + 32976, 32977, 32978, 32979, 32980, 32981, 32984, 32991, 32992, 32994, + 32995, 32998, 33006, 33013, 33015, 33017, 33019, 33022, 33023, 33024, + 33025, 33027, 33028, 33029, 33031, 33032, 33035, 33036, 33045, 33047, + 33049, 33051, 33052, 33053, 33055, 33056, 33057, 33058, 33059, 33060, + 33061, 33062, 33063, 33064, 33065, 33066, 33067, 33069, 33070, 33072, + 33075, 33076, 33077, 33079, 33081, 33082, 33083, 33084, 33085, 33087, + 35881, 33426, 33579, 30450, 27667, 24537, 33725, 29483, 33541, 38170, + 27611, 30683, 38086, 21359, 33538, 20882, 24125, 35980, 36152, 20040, + 29611, 26522, 26757, 37238, 38665, 29028, 27809, 30473, 23186, 38209, + 27599, 32654, 26151, 23504, 22969, 23194, 38376, 38391, 20204, 33804, + 33945, 27308, 30431, 38192, 29467, 26790, 23391, 30511, 37274, 38753, + 31964, 36855, 35868, 24357, 31859, 31192, 35269, 27852, 34588, 23494, + 24130, 26825, 30496, 32501, 20885, 20813, 21193, 23081, 32517, 38754, + 33495, 25551, 30596, 34256, 31186, 28218, 24217, 22937, 34065, 28781, + 27665, 25279, 30399, 25935, 24751, 38397, 26126, 34719, 40483, 38125, + 21517, 21629, 35884, 25720, 33088, 33089, 33090, 33091, 33092, 33093, + 33095, 33097, 33101, 33102, 33103, 33106, 33110, 33111, 33112, 33115, + 33116, 33117, 33118, 33119, 33121, 33122, 33123, 33124, 33126, 33128, + 33130, 33131, 33132, 33135, 33138, 33139, 33141, 33142, 33143, 33144, + 33153, 33155, 33156, 33157, 33158, 33159, 33161, 33163, 33164, 33165, + 33166, 33168, 33170, 33171, 33172, 33173, 33174, 33175, 33177, 33178, + 33182, 33183, 33184, 33185, 33186, 33188, 33189, 33191, 33193, 33195, + 33196, 33197, 33198, 33199, 33200, 33201, 33202, 33204, 33205, 33206, + 33207, 33208, 33209, 33212, 33213, 33214, 33215, 33220, 33221, 33223, + 33224, 33225, 33227, 33229, 33230, 33231, 33232, 33233, 33234, 33235, + 25721, 34321, 27169, 33180, 30952, 25705, 39764, 25273, 26411, 33707, + 22696, 40664, 27819, 28448, 23518, 38476, 35851, 29279, 26576, 25287, + 29281, 20137, 22982, 27597, 22675, 26286, 24149, 21215, 24917, 26408, + 30446, 30566, 29287, 31302, 25343, 21738, 21584, 38048, 37027, 23068, + 32435, 27670, 20035, 22902, 32784, 22856, 21335, 30007, 38590, 22218, + 25376, 33041, 24700, 38393, 28118, 21602, 39297, 20869, 23273, 33021, + 22958, 38675, 20522, 27877, 23612, 25311, 20320, 21311, 33147, 36870, + 28346, 34091, 25288, 24180, 30910, 25781, 25467, 24565, 23064, 37247, + 40479, 23615, 25423, 32834, 23421, 21870, 38218, 38221, 28037, 24744, + 26592, 29406, 20957, 23425, 33236, 33237, 33238, 33239, 33240, 33241, + 33242, 33243, 33244, 33245, 33246, 33247, 33248, 33249, 33250, 33252, + 33253, 33254, 33256, 33257, 33259, 33262, 33263, 33264, 33265, 33266, + 33269, 33270, 33271, 33272, 33273, 33274, 33277, 33279, 33283, 33287, + 33288, 33289, 33290, 33291, 33294, 33295, 33297, 33299, 33301, 33302, + 33303, 33304, 33305, 33306, 33309, 33312, 33316, 33317, 33318, 33319, + 33321, 33326, 33330, 33338, 33340, 33341, 33343, 33344, 33345, 33346, + 33347, 33349, 33350, 33352, 33354, 33356, 33357, 33358, 33360, 33361, + 33362, 33363, 33364, 33365, 33366, 33367, 33369, 33371, 33372, 33373, + 33374, 33376, 33377, 33378, 33379, 33380, 33381, 33382, 33383, 33385, + 25319, 27870, 29275, 25197, 38062, 32445, 33043, 27987, 20892, 24324, + 22900, 21162, 24594, 22899, 26262, 34384, 30111, 25386, 25062, 31983, + 35834, 21734, 27431, 40485, 27572, 34261, 21589, 20598, 27812, 21866, + 36276, 29228, 24085, 24597, 29750, 25293, 25490, 29260, 24472, 28227, + 27966, 25856, 28504, 30424, 30928, 30460, 30036, 21028, 21467, 20051, + 24222, 26049, 32810, 32982, 25243, 21638, 21032, 28846, 34957, 36305, + 27873, 21624, 32986, 22521, 35060, 36180, 38506, 37197, 20329, 27803, + 21943, 30406, 30768, 25256, 28921, 28558, 24429, 34028, 26842, 30844, + 31735, 33192, 26379, 40527, 25447, 30896, 22383, 30738, 38713, 25209, + 25259, 21128, 29749, 27607, 33386, 33387, 33388, 33389, 33393, 33397, + 33398, 33399, 33400, 33403, 33404, 33408, 33409, 33411, 33413, 33414, + 33415, 33417, 33420, 33424, 33427, 33428, 33429, 33430, 33434, 33435, + 33438, 33440, 33442, 33443, 33447, 33458, 33461, 33462, 33466, 33467, + 33468, 33471, 33472, 33474, 33475, 33477, 33478, 33481, 33488, 33494, + 33497, 33498, 33501, 33506, 33511, 33512, 33513, 33514, 33516, 33517, + 33518, 33520, 33522, 33523, 33525, 33526, 33528, 33530, 33532, 33533, + 33534, 33535, 33536, 33546, 33547, 33549, 33552, 33554, 33555, 33558, + 33560, 33561, 33565, 33566, 33567, 33568, 33569, 33570, 33571, 33572, + 33573, 33574, 33577, 33578, 33582, 33584, 33586, 33591, 33595, 33597, + 21860, 33086, 30130, 30382, 21305, 30174, 20731, 23617, 35692, 31687, + 20559, 29255, 39575, 39128, 28418, 29922, 31080, 25735, 30629, 25340, + 39057, 36139, 21697, 32856, 20050, 22378, 33529, 33805, 24179, 20973, + 29942, 35780, 23631, 22369, 27900, 39047, 23110, 30772, 39748, 36843, + 31893, 21078, 25169, 38138, 20166, 33670, 33889, 33769, 33970, 22484, + 26420, 22275, 26222, 28006, 35889, 26333, 28689, 26399, 27450, 26646, + 25114, 22971, 19971, 20932, 28422, 26578, 27791, 20854, 26827, 22855, + 27495, 30054, 23822, 33040, 40784, 26071, 31048, 31041, 39569, 36215, + 23682, 20062, 20225, 21551, 22865, 30732, 22120, 27668, 36804, 24323, + 27773, 27875, 35755, 25488, 33598, 33599, 33601, 33602, 33604, 33605, + 33608, 33610, 33611, 33612, 33613, 33614, 33619, 33621, 33622, 33623, + 33624, 33625, 33629, 33634, 33648, 33649, 33650, 33651, 33652, 33653, + 33654, 33657, 33658, 33662, 33663, 33664, 33665, 33666, 33667, 33668, + 33671, 33672, 33674, 33675, 33676, 33677, 33679, 33680, 33681, 33684, + 33685, 33686, 33687, 33689, 33690, 33693, 33695, 33697, 33698, 33699, + 33700, 33701, 33702, 33703, 33708, 33709, 33710, 33711, 33717, 33723, + 33726, 33727, 33730, 33731, 33732, 33734, 33736, 33737, 33739, 33741, + 33742, 33744, 33745, 33746, 33747, 33749, 33751, 33753, 33754, 33755, + 33758, 33762, 33763, 33764, 33766, 33767, 33768, 33771, 33772, 33773, + 24688, 27965, 29301, 25190, 38030, 38085, 21315, 36801, 31614, 20191, + 35878, 20094, 40660, 38065, 38067, 21069, 28508, 36963, 27973, 35892, + 22545, 23884, 27424, 27465, 26538, 21595, 33108, 32652, 22681, 34103, + 24378, 25250, 27207, 38201, 25970, 24708, 26725, 30631, 20052, 20392, + 24039, 38808, 25772, 32728, 23789, 20431, 31373, 20999, 33540, 19988, + 24623, 31363, 38054, 20405, 20146, 31206, 29748, 21220, 33465, 25810, + 31165, 23517, 27777, 38738, 36731, 27682, 20542, 21375, 28165, 25806, + 26228, 27696, 24773, 39031, 35831, 24198, 29756, 31351, 31179, 19992, + 37041, 29699, 27714, 22234, 37195, 27845, 36235, 21306, 34502, 26354, + 36527, 23624, 39537, 28192, 33774, 33775, 33779, 33780, 33781, 33782, + 33783, 33786, 33787, 33788, 33790, 33791, 33792, 33794, 33797, 33799, + 33800, 33801, 33802, 33808, 33810, 33811, 33812, 33813, 33814, 33815, + 33817, 33818, 33819, 33822, 33823, 33824, 33825, 33826, 33827, 33833, + 33834, 33835, 33836, 33837, 33838, 33839, 33840, 33842, 33843, 33844, + 33845, 33846, 33847, 33849, 33850, 33851, 33854, 33855, 33856, 33857, + 33858, 33859, 33860, 33861, 33863, 33864, 33865, 33866, 33867, 33868, + 33869, 33870, 33871, 33872, 33874, 33875, 33876, 33877, 33878, 33880, + 33885, 33886, 33887, 33888, 33890, 33892, 33893, 33894, 33895, 33896, + 33898, 33902, 33903, 33904, 33906, 33908, 33911, 33913, 33915, 33916, + 21462, 23094, 40843, 36259, 21435, 22280, 39079, 26435, 37275, 27849, + 20840, 30154, 25331, 29356, 21048, 21149, 32570, 28820, 30264, 21364, + 40522, 27063, 30830, 38592, 35033, 32676, 28982, 29123, 20873, 26579, + 29924, 22756, 25880, 22199, 35753, 39286, 25200, 32469, 24825, 28909, + 22764, 20161, 20154, 24525, 38887, 20219, 35748, 20995, 22922, 32427, + 25172, 20173, 26085, 25102, 33592, 33993, 33635, 34701, 29076, 28342, + 23481, 32466, 20887, 25545, 26580, 32905, 33593, 34837, 20754, 23418, + 22914, 36785, 20083, 27741, 20837, 35109, 36719, 38446, 34122, 29790, + 38160, 38384, 28070, 33509, 24369, 25746, 27922, 33832, 33134, 40131, + 22622, 36187, 19977, 21441, 33917, 33918, 33919, 33920, 33921, 33923, + 33924, 33925, 33926, 33930, 33933, 33935, 33936, 33937, 33938, 33939, + 33940, 33941, 33942, 33944, 33946, 33947, 33949, 33950, 33951, 33952, + 33954, 33955, 33956, 33957, 33958, 33959, 33960, 33961, 33962, 33963, + 33964, 33965, 33966, 33968, 33969, 33971, 33973, 33974, 33975, 33979, + 33980, 33982, 33984, 33986, 33987, 33989, 33990, 33991, 33992, 33995, + 33996, 33998, 33999, 34002, 34004, 34005, 34007, 34008, 34009, 34010, + 34011, 34012, 34014, 34017, 34018, 34020, 34023, 34024, 34025, 34026, + 34027, 34029, 34030, 34031, 34033, 34034, 34035, 34036, 34037, 34038, + 34039, 34040, 34041, 34042, 34043, 34045, 34046, 34048, 34049, 34050, + 20254, 25955, 26705, 21971, 20007, 25620, 39578, 25195, 23234, 29791, + 33394, 28073, 26862, 20711, 33678, 30722, 26432, 21049, 27801, 32433, + 20667, 21861, 29022, 31579, 26194, 29642, 33515, 26441, 23665, 21024, + 29053, 34923, 38378, 38485, 25797, 36193, 33203, 21892, 27733, 25159, + 32558, 22674, 20260, 21830, 36175, 26188, 19978, 23578, 35059, 26786, + 25422, 31245, 28903, 33421, 21242, 38902, 23569, 21736, 37045, 32461, + 22882, 36170, 34503, 33292, 33293, 36198, 25668, 23556, 24913, 28041, + 31038, 35774, 30775, 30003, 21627, 20280, 36523, 28145, 23072, 32453, + 31070, 27784, 23457, 23158, 29978, 32958, 24910, 28183, 22768, 29983, + 29989, 29298, 21319, 32499, 34051, 34052, 34053, 34054, 34055, 34056, + 34057, 34058, 34059, 34061, 34062, 34063, 34064, 34066, 34068, 34069, + 34070, 34072, 34073, 34075, 34076, 34077, 34078, 34080, 34082, 34083, + 34084, 34085, 34086, 34087, 34088, 34089, 34090, 34093, 34094, 34095, + 34096, 34097, 34098, 34099, 34100, 34101, 34102, 34110, 34111, 34112, + 34113, 34114, 34116, 34117, 34118, 34119, 34123, 34124, 34125, 34126, + 34127, 34128, 34129, 34130, 34131, 34132, 34133, 34135, 34136, 34138, + 34139, 34140, 34141, 34143, 34144, 34145, 34146, 34147, 34149, 34150, + 34151, 34153, 34154, 34155, 34156, 34157, 34158, 34159, 34160, 34161, + 34163, 34165, 34166, 34167, 34168, 34172, 34173, 34175, 34176, 34177, + 30465, 30427, 21097, 32988, 22307, 24072, 22833, 29422, 26045, 28287, + 35799, 23608, 34417, 21313, 30707, 25342, 26102, 20160, 39135, 34432, + 23454, 35782, 21490, 30690, 20351, 23630, 39542, 22987, 24335, 31034, + 22763, 19990, 26623, 20107, 25325, 35475, 36893, 21183, 26159, 21980, + 22124, 36866, 20181, 20365, 37322, 39280, 27663, 24066, 24643, 23460, + 35270, 35797, 25910, 25163, 39318, 23432, 23551, 25480, 21806, 21463, + 30246, 20861, 34092, 26530, 26803, 27530, 25234, 36755, 21460, 33298, + 28113, 30095, 20070, 36174, 23408, 29087, 34223, 26257, 26329, 32626, + 34560, 40653, 40736, 23646, 26415, 36848, 26641, 26463, 25101, 31446, + 22661, 24246, 25968, 28465, 34178, 34179, 34182, 34184, 34185, 34186, + 34187, 34188, 34189, 34190, 34192, 34193, 34194, 34195, 34196, 34197, + 34198, 34199, 34200, 34201, 34202, 34205, 34206, 34207, 34208, 34209, + 34210, 34211, 34213, 34214, 34215, 34217, 34219, 34220, 34221, 34225, + 34226, 34227, 34228, 34229, 34230, 34232, 34234, 34235, 34236, 34237, + 34238, 34239, 34240, 34242, 34243, 34244, 34245, 34246, 34247, 34248, + 34250, 34251, 34252, 34253, 34254, 34257, 34258, 34260, 34262, 34263, + 34264, 34265, 34266, 34267, 34269, 34270, 34271, 34272, 34273, 34274, + 34275, 34277, 34278, 34279, 34280, 34282, 34283, 34284, 34285, 34286, + 34287, 34288, 34289, 34290, 34291, 34292, 34293, 34294, 34295, 34296, + 24661, 21047, 32781, 25684, 34928, 29993, 24069, 26643, 25332, 38684, + 21452, 29245, 35841, 27700, 30561, 31246, 21550, 30636, 39034, 33308, + 35828, 30805, 26388, 28865, 26031, 25749, 22070, 24605, 31169, 21496, + 19997, 27515, 32902, 23546, 21987, 22235, 20282, 20284, 39282, 24051, + 26494, 32824, 24578, 39042, 36865, 23435, 35772, 35829, 25628, 33368, + 25822, 22013, 33487, 37221, 20439, 32032, 36895, 31903, 20723, 22609, + 28335, 23487, 35785, 32899, 37240, 33948, 31639, 34429, 38539, 38543, + 32485, 39635, 30862, 23681, 31319, 36930, 38567, 31071, 23385, 25439, + 31499, 34001, 26797, 21766, 32553, 29712, 32034, 38145, 25152, 22604, + 20182, 23427, 22905, 22612, 34297, 34298, 34300, 34301, 34302, 34304, + 34305, 34306, 34307, 34308, 34310, 34311, 34312, 34313, 34314, 34315, + 34316, 34317, 34318, 34319, 34320, 34322, 34323, 34324, 34325, 34327, + 34328, 34329, 34330, 34331, 34332, 34333, 34334, 34335, 34336, 34337, + 34338, 34339, 34340, 34341, 34342, 34344, 34346, 34347, 34348, 34349, + 34350, 34351, 34352, 34353, 34354, 34355, 34356, 34357, 34358, 34359, + 34361, 34362, 34363, 34365, 34366, 34367, 34368, 34369, 34370, 34371, + 34372, 34373, 34374, 34375, 34376, 34377, 34378, 34379, 34380, 34386, + 34387, 34389, 34390, 34391, 34392, 34393, 34395, 34396, 34397, 34399, + 34400, 34401, 34403, 34404, 34405, 34406, 34407, 34408, 34409, 34410, + 29549, 25374, 36427, 36367, 32974, 33492, 25260, 21488, 27888, 37214, + 22826, 24577, 27760, 22349, 25674, 36138, 30251, 28393, 22363, 27264, + 30192, 28525, 35885, 35848, 22374, 27631, 34962, 30899, 25506, 21497, + 28845, 27748, 22616, 25642, 22530, 26848, 33179, 21776, 31958, 20504, + 36538, 28108, 36255, 28907, 25487, 28059, 28372, 32486, 33796, 26691, + 36867, 28120, 38518, 35752, 22871, 29305, 34276, 33150, 30140, 35466, + 26799, 21076, 36386, 38161, 25552, 39064, 36420, 21884, 20307, 26367, + 22159, 24789, 28053, 21059, 23625, 22825, 28155, 22635, 30000, 29980, + 24684, 33300, 33094, 25361, 26465, 36834, 30522, 36339, 36148, 38081, + 24086, 21381, 21548, 28867, 34413, 34415, 34416, 34418, 34419, 34420, + 34421, 34422, 34423, 34424, 34435, 34436, 34437, 34438, 34439, 34440, + 34441, 34446, 34447, 34448, 34449, 34450, 34452, 34454, 34455, 34456, + 34457, 34458, 34459, 34462, 34463, 34464, 34465, 34466, 34469, 34470, + 34475, 34477, 34478, 34482, 34483, 34487, 34488, 34489, 34491, 34492, + 34493, 34494, 34495, 34497, 34498, 34499, 34501, 34504, 34508, 34509, + 34514, 34515, 34517, 34518, 34519, 34522, 34524, 34525, 34528, 34529, + 34530, 34531, 34533, 34534, 34535, 34536, 34538, 34539, 34540, 34543, + 34549, 34550, 34551, 34554, 34555, 34556, 34557, 34559, 34561, 34564, + 34565, 34566, 34571, 34572, 34574, 34575, 34576, 34577, 34580, 34582, + 27712, 24311, 20572, 20141, 24237, 25402, 33351, 36890, 26704, 37230, + 30643, 21516, 38108, 24420, 31461, 26742, 25413, 31570, 32479, 30171, + 20599, 25237, 22836, 36879, 20984, 31171, 31361, 22270, 24466, 36884, + 28034, 23648, 22303, 21520, 20820, 28237, 22242, 25512, 39059, 33151, + 34581, 35114, 36864, 21534, 23663, 33216, 25302, 25176, 33073, 40501, + 38464, 39534, 39548, 26925, 22949, 25299, 21822, 25366, 21703, 34521, + 27964, 23043, 29926, 34972, 27498, 22806, 35916, 24367, 28286, 29609, + 39037, 20024, 28919, 23436, 30871, 25405, 26202, 30358, 24779, 23451, + 23113, 19975, 33109, 27754, 29579, 20129, 26505, 32593, 24448, 26106, + 26395, 24536, 22916, 23041, 34585, 34587, 34589, 34591, 34592, 34596, + 34598, 34599, 34600, 34602, 34603, 34604, 34605, 34607, 34608, 34610, + 34611, 34613, 34614, 34616, 34617, 34618, 34620, 34621, 34624, 34625, + 34626, 34627, 34628, 34629, 34630, 34634, 34635, 34637, 34639, 34640, + 34641, 34642, 34644, 34645, 34646, 34648, 34650, 34651, 34652, 34653, + 34654, 34655, 34657, 34658, 34662, 34663, 34664, 34665, 34666, 34667, + 34668, 34669, 34671, 34673, 34674, 34675, 34677, 34679, 34680, 34681, + 34682, 34687, 34688, 34689, 34692, 34694, 34695, 34697, 34698, 34700, + 34702, 34703, 34704, 34705, 34706, 34708, 34709, 34710, 34712, 34713, + 34714, 34715, 34716, 34717, 34718, 34720, 34721, 34722, 34723, 34724, + 24013, 24494, 21361, 38886, 36829, 26693, 22260, 21807, 24799, 20026, + 28493, 32500, 33479, 33806, 22996, 20255, 20266, 23614, 32428, 26410, + 34074, 21619, 30031, 32963, 21890, 39759, 20301, 28205, 35859, 23561, + 24944, 21355, 30239, 28201, 34442, 25991, 38395, 32441, 21563, 31283, + 32010, 38382, 21985, 32705, 29934, 25373, 34583, 28065, 31389, 25105, + 26017, 21351, 25569, 27779, 24043, 21596, 38056, 20044, 27745, 35820, + 23627, 26080, 33436, 26791, 21566, 21556, 27595, 27494, 20116, 25410, + 21320, 33310, 20237, 20398, 22366, 25098, 38654, 26212, 29289, 21247, + 21153, 24735, 35823, 26132, 29081, 26512, 35199, 30802, 30717, 26224, + 22075, 21560, 38177, 29306, 34725, 34726, 34727, 34729, 34730, 34734, + 34736, 34737, 34738, 34740, 34742, 34743, 34744, 34745, 34747, 34748, + 34750, 34751, 34753, 34754, 34755, 34756, 34757, 34759, 34760, 34761, + 34764, 34765, 34766, 34767, 34768, 34772, 34773, 34774, 34775, 34776, + 34777, 34778, 34780, 34781, 34782, 34783, 34785, 34786, 34787, 34788, + 34790, 34791, 34792, 34793, 34795, 34796, 34797, 34799, 34800, 34801, + 34802, 34803, 34804, 34805, 34806, 34807, 34808, 34810, 34811, 34812, + 34813, 34815, 34816, 34817, 34818, 34820, 34821, 34822, 34823, 34824, + 34825, 34827, 34828, 34829, 34830, 34831, 34832, 34833, 34834, 34836, + 34839, 34840, 34841, 34842, 34844, 34845, 34846, 34847, 34848, 34851, + 31232, 24687, 24076, 24713, 33181, 22805, 24796, 29060, 28911, 28330, + 27728, 29312, 27268, 34989, 24109, 20064, 23219, 21916, 38115, 27927, + 31995, 38553, 25103, 32454, 30606, 34430, 21283, 38686, 36758, 26247, + 23777, 20384, 29421, 19979, 21414, 22799, 21523, 25472, 38184, 20808, + 20185, 40092, 32420, 21688, 36132, 34900, 33335, 38386, 28046, 24358, + 23244, 26174, 38505, 29616, 29486, 21439, 33146, 39301, 32673, 23466, + 38519, 38480, 32447, 30456, 21410, 38262, 39321, 31665, 35140, 28248, + 20065, 32724, 31077, 35814, 24819, 21709, 20139, 39033, 24055, 27233, + 20687, 21521, 35937, 33831, 30813, 38660, 21066, 21742, 22179, 38144, + 28040, 23477, 28102, 26195, 34852, 34853, 34854, 34855, 34856, 34857, + 34858, 34859, 34860, 34861, 34862, 34863, 34864, 34865, 34867, 34868, + 34869, 34870, 34871, 34872, 34874, 34875, 34877, 34878, 34879, 34881, + 34882, 34883, 34886, 34887, 34888, 34889, 34890, 34891, 34894, 34895, + 34896, 34897, 34898, 34899, 34901, 34902, 34904, 34906, 34907, 34908, + 34909, 34910, 34911, 34912, 34918, 34919, 34922, 34925, 34927, 34929, + 34931, 34932, 34933, 34934, 34936, 34937, 34938, 34939, 34940, 34944, + 34947, 34950, 34951, 34953, 34954, 34956, 34958, 34959, 34960, 34961, + 34963, 34964, 34965, 34967, 34968, 34969, 34970, 34971, 34973, 34974, + 34975, 34976, 34977, 34979, 34981, 34982, 34983, 34984, 34985, 34986, + 23567, 23389, 26657, 32918, 21880, 31505, 25928, 26964, 20123, 27463, + 34638, 38795, 21327, 25375, 25658, 37034, 26012, 32961, 35856, 20889, + 26800, 21368, 34809, 25032, 27844, 27899, 35874, 23633, 34218, 33455, + 38156, 27427, 36763, 26032, 24571, 24515, 20449, 34885, 26143, 33125, + 29481, 24826, 20852, 21009, 22411, 24418, 37026, 34892, 37266, 24184, + 26447, 24615, 22995, 20804, 20982, 33016, 21256, 27769, 38596, 29066, + 20241, 20462, 32670, 26429, 21957, 38152, 31168, 34966, 32483, 22687, + 25100, 38656, 34394, 22040, 39035, 24464, 35768, 33988, 37207, 21465, + 26093, 24207, 30044, 24676, 32110, 23167, 32490, 32493, 36713, 21927, + 23459, 24748, 26059, 29572, 34988, 34990, 34991, 34992, 34994, 34995, + 34996, 34997, 34998, 35000, 35001, 35002, 35003, 35005, 35006, 35007, + 35008, 35011, 35012, 35015, 35016, 35018, 35019, 35020, 35021, 35023, + 35024, 35025, 35027, 35030, 35031, 35034, 35035, 35036, 35037, 35038, + 35040, 35041, 35046, 35047, 35049, 35050, 35051, 35052, 35053, 35054, + 35055, 35058, 35061, 35062, 35063, 35066, 35067, 35069, 35071, 35072, + 35073, 35075, 35076, 35077, 35078, 35079, 35080, 35081, 35083, 35084, + 35085, 35086, 35087, 35089, 35092, 35093, 35094, 35095, 35096, 35100, + 35101, 35102, 35103, 35104, 35106, 35107, 35108, 35110, 35111, 35112, + 35113, 35116, 35117, 35118, 35119, 35121, 35122, 35123, 35125, 35127, + 36873, 30307, 30505, 32474, 38772, 34203, 23398, 31348, 38634, 34880, + 21195, 29071, 24490, 26092, 35810, 23547, 39535, 24033, 27529, 27739, + 35757, 35759, 36874, 36805, 21387, 25276, 40486, 40493, 21568, 20011, + 33469, 29273, 34460, 23830, 34905, 28079, 38597, 21713, 20122, 35766, + 28937, 21693, 38409, 28895, 28153, 30416, 20005, 30740, 34578, 23721, + 24310, 35328, 39068, 38414, 28814, 27839, 22852, 25513, 30524, 34893, + 28436, 33395, 22576, 29141, 21388, 30746, 38593, 21761, 24422, 28976, + 23476, 35866, 39564, 27523, 22830, 40495, 31207, 26472, 25196, 20335, + 30113, 32650, 27915, 38451, 27687, 20208, 30162, 20859, 26679, 28478, + 36992, 33136, 22934, 29814, 35128, 35129, 35130, 35131, 35132, 35133, + 35134, 35135, 35136, 35138, 35139, 35141, 35142, 35143, 35144, 35145, + 35146, 35147, 35148, 35149, 35150, 35151, 35152, 35153, 35154, 35155, + 35156, 35157, 35158, 35159, 35160, 35161, 35162, 35163, 35164, 35165, + 35168, 35169, 35170, 35171, 35172, 35173, 35175, 35176, 35177, 35178, + 35179, 35180, 35181, 35182, 35183, 35184, 35185, 35186, 35187, 35188, + 35189, 35190, 35191, 35192, 35193, 35194, 35196, 35197, 35198, 35200, + 35202, 35204, 35205, 35207, 35208, 35209, 35210, 35211, 35212, 35213, + 35214, 35215, 35216, 35217, 35218, 35219, 35220, 35221, 35222, 35223, + 35224, 35225, 35226, 35227, 35228, 35229, 35230, 35231, 35232, 35233, + 25671, 23591, 36965, 31377, 35875, 23002, 21676, 33280, 33647, 35201, + 32768, 26928, 22094, 32822, 29239, 37326, 20918, 20063, 39029, 25494, + 19994, 21494, 26355, 33099, 22812, 28082, 19968, 22777, 21307, 25558, + 38129, 20381, 20234, 34915, 39056, 22839, 36951, 31227, 20202, 33008, + 30097, 27778, 23452, 23016, 24413, 26885, 34433, 20506, 24050, 20057, + 30691, 20197, 33402, 25233, 26131, 37009, 23673, 20159, 24441, 33222, + 36920, 32900, 30123, 20134, 35028, 24847, 27589, 24518, 20041, 30410, + 28322, 35811, 35758, 35850, 35793, 24322, 32764, 32716, 32462, 33589, + 33643, 22240, 27575, 38899, 38452, 23035, 21535, 38134, 28139, 23493, + 39278, 23609, 24341, 38544, 35234, 35235, 35236, 35237, 35238, 35239, + 35240, 35241, 35242, 35243, 35244, 35245, 35246, 35247, 35248, 35249, + 35250, 35251, 35252, 35253, 35254, 35255, 35256, 35257, 35258, 35259, + 35260, 35261, 35262, 35263, 35264, 35267, 35277, 35283, 35284, 35285, + 35287, 35288, 35289, 35291, 35293, 35295, 35296, 35297, 35298, 35300, + 35303, 35304, 35305, 35306, 35308, 35309, 35310, 35312, 35313, 35314, + 35316, 35317, 35318, 35319, 35320, 35321, 35322, 35323, 35324, 35325, + 35326, 35327, 35329, 35330, 35331, 35332, 35333, 35334, 35336, 35337, + 35338, 35339, 35340, 35341, 35342, 35343, 35344, 35345, 35346, 35347, + 35348, 35349, 35350, 35351, 35352, 35353, 35354, 35355, 35356, 35357, + 21360, 33521, 27185, 23156, 40560, 24212, 32552, 33721, 33828, 33829, + 33639, 34631, 36814, 36194, 30408, 24433, 39062, 30828, 26144, 21727, + 25317, 20323, 33219, 30152, 24248, 38605, 36362, 34553, 21647, 27891, + 28044, 27704, 24703, 21191, 29992, 24189, 20248, 24736, 24551, 23588, + 30001, 37038, 38080, 29369, 27833, 28216, 37193, 26377, 21451, 21491, + 20305, 37321, 35825, 21448, 24188, 36802, 28132, 20110, 30402, 27014, + 34398, 24858, 33286, 20313, 20446, 36926, 40060, 24841, 28189, 28180, + 38533, 20104, 23089, 38632, 19982, 23679, 31161, 23431, 35821, 32701, + 29577, 22495, 33419, 37057, 21505, 36935, 21947, 23786, 24481, 24840, + 27442, 29425, 32946, 35465, 35358, 35359, 35360, 35361, 35362, 35363, + 35364, 35365, 35366, 35367, 35368, 35369, 35370, 35371, 35372, 35373, + 35374, 35375, 35376, 35377, 35378, 35379, 35380, 35381, 35382, 35383, + 35384, 35385, 35386, 35387, 35388, 35389, 35391, 35392, 35393, 35394, + 35395, 35396, 35397, 35398, 35399, 35401, 35402, 35403, 35404, 35405, + 35406, 35407, 35408, 35409, 35410, 35411, 35412, 35413, 35414, 35415, + 35416, 35417, 35418, 35419, 35420, 35421, 35422, 35423, 35424, 35425, + 35426, 35427, 35428, 35429, 35430, 35431, 35432, 35433, 35434, 35435, + 35436, 35437, 35438, 35439, 35440, 35441, 35442, 35443, 35444, 35445, + 35446, 35447, 35448, 35450, 35451, 35452, 35453, 35454, 35455, 35456, + 28020, 23507, 35029, 39044, 35947, 39533, 40499, 28170, 20900, 20803, + 22435, 34945, 21407, 25588, 36757, 22253, 21592, 22278, 29503, 28304, + 32536, 36828, 33489, 24895, 24616, 38498, 26352, 32422, 36234, 36291, + 38053, 23731, 31908, 26376, 24742, 38405, 32792, 20113, 37095, 21248, + 38504, 20801, 36816, 34164, 37213, 26197, 38901, 23381, 21277, 30776, + 26434, 26685, 21705, 28798, 23472, 36733, 20877, 22312, 21681, 25874, + 26242, 36190, 36163, 33039, 33900, 36973, 31967, 20991, 34299, 26531, + 26089, 28577, 34468, 36481, 22122, 36896, 30338, 28790, 29157, 36131, + 25321, 21017, 27901, 36156, 24590, 22686, 24974, 26366, 36192, 25166, + 21939, 28195, 26413, 36711, 35457, 35458, 35459, 35460, 35461, 35462, + 35463, 35464, 35467, 35468, 35469, 35470, 35471, 35472, 35473, 35474, + 35476, 35477, 35478, 35479, 35480, 35481, 35482, 35483, 35484, 35485, + 35486, 35487, 35488, 35489, 35490, 35491, 35492, 35493, 35494, 35495, + 35496, 35497, 35498, 35499, 35500, 35501, 35502, 35503, 35504, 35505, + 35506, 35507, 35508, 35509, 35510, 35511, 35512, 35513, 35514, 35515, + 35516, 35517, 35518, 35519, 35520, 35521, 35522, 35523, 35524, 35525, + 35526, 35527, 35528, 35529, 35530, 35531, 35532, 35533, 35534, 35535, + 35536, 35537, 35538, 35539, 35540, 35541, 35542, 35543, 35544, 35545, + 35546, 35547, 35548, 35549, 35550, 35551, 35552, 35553, 35554, 35555, + 38113, 38392, 30504, 26629, 27048, 21643, 20045, 28856, 35784, 25688, + 25995, 23429, 31364, 20538, 23528, 30651, 27617, 35449, 31896, 27838, + 30415, 26025, 36759, 23853, 23637, 34360, 26632, 21344, 25112, 31449, + 28251, 32509, 27167, 31456, 24432, 28467, 24352, 25484, 28072, 26454, + 19976, 24080, 36134, 20183, 32960, 30260, 38556, 25307, 26157, 25214, + 27836, 36213, 29031, 32617, 20806, 32903, 21484, 36974, 25240, 21746, + 34544, 36761, 32773, 38167, 34071, 36825, 27993, 29645, 26015, 30495, + 29956, 30759, 33275, 36126, 38024, 20390, 26517, 30137, 35786, 38663, + 25391, 38215, 38453, 33976, 25379, 30529, 24449, 29424, 20105, 24596, + 25972, 25327, 27491, 25919, 35556, 35557, 35558, 35559, 35560, 35561, + 35562, 35563, 35564, 35565, 35566, 35567, 35568, 35569, 35570, 35571, + 35572, 35573, 35574, 35575, 35576, 35577, 35578, 35579, 35580, 35581, + 35582, 35583, 35584, 35585, 35586, 35587, 35588, 35589, 35590, 35592, + 35593, 35594, 35595, 35596, 35597, 35598, 35599, 35600, 35601, 35602, + 35603, 35604, 35605, 35606, 35607, 35608, 35609, 35610, 35611, 35612, + 35613, 35614, 35615, 35616, 35617, 35618, 35619, 35620, 35621, 35623, + 35624, 35625, 35626, 35627, 35628, 35629, 35630, 35631, 35632, 35633, + 35634, 35635, 35636, 35637, 35638, 35639, 35640, 35641, 35642, 35643, + 35644, 35645, 35646, 35647, 35648, 35649, 35650, 35651, 35652, 35653, + 24103, 30151, 37073, 35777, 33437, 26525, 25903, 21553, 34584, 30693, + 32930, 33026, 27713, 20043, 32455, 32844, 30452, 26893, 27542, 25191, + 20540, 20356, 22336, 25351, 27490, 36286, 21482, 26088, 32440, 24535, + 25370, 25527, 33267, 33268, 32622, 24092, 23769, 21046, 26234, 31209, + 31258, 36136, 28825, 30164, 28382, 27835, 31378, 20013, 30405, 24544, + 38047, 34935, 32456, 31181, 32959, 37325, 20210, 20247, 33311, 21608, + 24030, 27954, 35788, 31909, 36724, 32920, 24090, 21650, 30385, 23449, + 26172, 39588, 29664, 26666, 34523, 26417, 29482, 35832, 35803, 36880, + 31481, 28891, 29038, 25284, 30633, 22065, 20027, 33879, 26609, 21161, + 34496, 36142, 38136, 31569, 35654, 35655, 35656, 35657, 35658, 35659, + 35660, 35661, 35662, 35663, 35664, 35665, 35666, 35667, 35668, 35669, + 35670, 35671, 35672, 35673, 35674, 35675, 35676, 35677, 35678, 35679, + 35680, 35681, 35682, 35683, 35684, 35685, 35687, 35688, 35689, 35690, + 35691, 35693, 35694, 35695, 35696, 35697, 35698, 35699, 35700, 35701, + 35702, 35703, 35704, 35705, 35706, 35707, 35708, 35709, 35710, 35711, + 35712, 35713, 35714, 35715, 35716, 35717, 35718, 35719, 35720, 35721, + 35722, 35723, 35724, 35725, 35726, 35727, 35728, 35729, 35730, 35731, + 35732, 35733, 35734, 35735, 35736, 35737, 35738, 35739, 35740, 35741, + 35742, 35743, 35756, 35761, 35771, 35783, 35792, 35818, 35849, 35870, + 20303, 27880, 31069, 39547, 25235, 29226, 25341, 19987, 30742, 36716, + 25776, 36186, 31686, 26729, 24196, 35013, 22918, 25758, 22766, 29366, + 26894, 38181, 36861, 36184, 22368, 32512, 35846, 20934, 25417, 25305, + 21331, 26700, 29730, 33537, 37196, 21828, 30528, 28796, 27978, 20857, + 21672, 36164, 23039, 28363, 28100, 23388, 32043, 20180, 31869, 28371, + 23376, 33258, 28173, 23383, 39683, 26837, 36394, 23447, 32508, 24635, + 32437, 37049, 36208, 22863, 25549, 31199, 36275, 21330, 26063, 31062, + 35781, 38459, 32452, 38075, 32386, 22068, 37257, 26368, 32618, 23562, + 36981, 26152, 24038, 20304, 26590, 20570, 20316, 22352, 24231, 59408, + 59409, 59410, 59411, 59412, 35896, 35897, 35898, 35899, 35900, 35901, + 35902, 35903, 35904, 35906, 35907, 35908, 35909, 35912, 35914, 35915, + 35917, 35918, 35919, 35920, 35921, 35922, 35923, 35924, 35926, 35927, + 35928, 35929, 35931, 35932, 35933, 35934, 35935, 35936, 35939, 35940, + 35941, 35942, 35943, 35944, 35945, 35948, 35949, 35950, 35951, 35952, + 35953, 35954, 35956, 35957, 35958, 35959, 35963, 35964, 35965, 35966, + 35967, 35968, 35969, 35971, 35972, 35974, 35975, 35976, 35979, 35981, + 35982, 35983, 35984, 35985, 35986, 35987, 35989, 35990, 35991, 35993, + 35994, 35995, 35996, 35997, 35998, 35999, 36000, 36001, 36002, 36003, + 36004, 36005, 36006, 36007, 36008, 36009, 36010, 36011, 36012, 36013, + 20109, 19980, 20800, 19984, 24319, 21317, 19989, 20120, 19998, 39730, + 23404, 22121, 20008, 31162, 20031, 21269, 20039, 22829, 29243, 21358, + 27664, 22239, 32996, 39319, 27603, 30590, 40727, 20022, 20127, 40720, + 20060, 20073, 20115, 33416, 23387, 21868, 22031, 20164, 21389, 21405, + 21411, 21413, 21422, 38757, 36189, 21274, 21493, 21286, 21294, 21310, + 36188, 21350, 21347, 20994, 21000, 21006, 21037, 21043, 21055, 21056, + 21068, 21086, 21089, 21084, 33967, 21117, 21122, 21121, 21136, 21139, + 20866, 32596, 20155, 20163, 20169, 20162, 20200, 20193, 20203, 20190, + 20251, 20211, 20258, 20324, 20213, 20261, 20263, 20233, 20267, 20318, + 20327, 25912, 20314, 20317, 36014, 36015, 36016, 36017, 36018, 36019, + 36020, 36021, 36022, 36023, 36024, 36025, 36026, 36027, 36028, 36029, + 36030, 36031, 36032, 36033, 36034, 36035, 36036, 36037, 36038, 36039, + 36040, 36041, 36042, 36043, 36044, 36045, 36046, 36047, 36048, 36049, + 36050, 36051, 36052, 36053, 36054, 36055, 36056, 36057, 36058, 36059, + 36060, 36061, 36062, 36063, 36064, 36065, 36066, 36067, 36068, 36069, + 36070, 36071, 36072, 36073, 36074, 36075, 36076, 36077, 36078, 36079, + 36080, 36081, 36082, 36083, 36084, 36085, 36086, 36087, 36088, 36089, + 36090, 36091, 36092, 36093, 36094, 36095, 36096, 36097, 36098, 36099, + 36100, 36101, 36102, 36103, 36104, 36105, 36106, 36107, 36108, 36109, + 20319, 20311, 20274, 20285, 20342, 20340, 20369, 20361, 20355, 20367, + 20350, 20347, 20394, 20348, 20396, 20372, 20454, 20456, 20458, 20421, + 20442, 20451, 20444, 20433, 20447, 20472, 20521, 20556, 20467, 20524, + 20495, 20526, 20525, 20478, 20508, 20492, 20517, 20520, 20606, 20547, + 20565, 20552, 20558, 20588, 20603, 20645, 20647, 20649, 20666, 20694, + 20742, 20717, 20716, 20710, 20718, 20743, 20747, 20189, 27709, 20312, + 20325, 20430, 40864, 27718, 31860, 20846, 24061, 40649, 39320, 20865, + 22804, 21241, 21261, 35335, 21264, 20971, 22809, 20821, 20128, 20822, + 20147, 34926, 34980, 20149, 33044, 35026, 31104, 23348, 34819, 32696, + 20907, 20913, 20925, 20924, 36110, 36111, 36112, 36113, 36114, 36115, + 36116, 36117, 36118, 36119, 36120, 36121, 36122, 36123, 36124, 36128, + 36177, 36178, 36183, 36191, 36197, 36200, 36201, 36202, 36204, 36206, + 36207, 36209, 36210, 36216, 36217, 36218, 36219, 36220, 36221, 36222, + 36223, 36224, 36226, 36227, 36230, 36231, 36232, 36233, 36236, 36237, + 36238, 36239, 36240, 36242, 36243, 36245, 36246, 36247, 36248, 36249, + 36250, 36251, 36252, 36253, 36254, 36256, 36257, 36258, 36260, 36261, + 36262, 36263, 36264, 36265, 36266, 36267, 36268, 36269, 36270, 36271, + 36272, 36274, 36278, 36279, 36281, 36283, 36285, 36288, 36289, 36290, + 36293, 36295, 36296, 36297, 36298, 36301, 36304, 36306, 36307, 36308, + 20935, 20886, 20898, 20901, 35744, 35750, 35751, 35754, 35764, 35765, + 35767, 35778, 35779, 35787, 35791, 35790, 35794, 35795, 35796, 35798, + 35800, 35801, 35804, 35807, 35808, 35812, 35816, 35817, 35822, 35824, + 35827, 35830, 35833, 35836, 35839, 35840, 35842, 35844, 35847, 35852, + 35855, 35857, 35858, 35860, 35861, 35862, 35865, 35867, 35864, 35869, + 35871, 35872, 35873, 35877, 35879, 35882, 35883, 35886, 35887, 35890, + 35891, 35893, 35894, 21353, 21370, 38429, 38434, 38433, 38449, 38442, + 38461, 38460, 38466, 38473, 38484, 38495, 38503, 38508, 38514, 38516, + 38536, 38541, 38551, 38576, 37015, 37019, 37021, 37017, 37036, 37025, + 37044, 37043, 37046, 37050, 36309, 36312, 36313, 36316, 36320, 36321, + 36322, 36325, 36326, 36327, 36329, 36333, 36334, 36336, 36337, 36338, + 36340, 36342, 36348, 36350, 36351, 36352, 36353, 36354, 36355, 36356, + 36358, 36359, 36360, 36363, 36365, 36366, 36368, 36369, 36370, 36371, + 36373, 36374, 36375, 36376, 36377, 36378, 36379, 36380, 36384, 36385, + 36388, 36389, 36390, 36391, 36392, 36395, 36397, 36400, 36402, 36403, + 36404, 36406, 36407, 36408, 36411, 36412, 36414, 36415, 36419, 36421, + 36422, 36428, 36429, 36430, 36431, 36432, 36435, 36436, 36437, 36438, + 36439, 36440, 36442, 36443, 36444, 36445, 36446, 36447, 36448, 36449, + 36450, 36451, 36452, 36453, 36455, 36456, 36458, 36459, 36462, 36465, + 37048, 37040, 37071, 37061, 37054, 37072, 37060, 37063, 37075, 37094, + 37090, 37084, 37079, 37083, 37099, 37103, 37118, 37124, 37154, 37150, + 37155, 37169, 37167, 37177, 37187, 37190, 21005, 22850, 21154, 21164, + 21165, 21182, 21759, 21200, 21206, 21232, 21471, 29166, 30669, 24308, + 20981, 20988, 39727, 21430, 24321, 30042, 24047, 22348, 22441, 22433, + 22654, 22716, 22725, 22737, 22313, 22316, 22314, 22323, 22329, 22318, + 22319, 22364, 22331, 22338, 22377, 22405, 22379, 22406, 22396, 22395, + 22376, 22381, 22390, 22387, 22445, 22436, 22412, 22450, 22479, 22439, + 22452, 22419, 22432, 22485, 22488, 22490, 22489, 22482, 22456, 22516, + 22511, 22520, 22500, 22493, 36467, 36469, 36471, 36472, 36473, 36474, + 36475, 36477, 36478, 36480, 36482, 36483, 36484, 36486, 36488, 36489, + 36490, 36491, 36492, 36493, 36494, 36497, 36498, 36499, 36501, 36502, + 36503, 36504, 36505, 36506, 36507, 36509, 36511, 36512, 36513, 36514, + 36515, 36516, 36517, 36518, 36519, 36520, 36521, 36522, 36525, 36526, + 36528, 36529, 36531, 36532, 36533, 36534, 36535, 36536, 36537, 36539, + 36540, 36541, 36542, 36543, 36544, 36545, 36546, 36547, 36548, 36549, + 36550, 36551, 36552, 36553, 36554, 36555, 36556, 36557, 36559, 36560, + 36561, 36562, 36563, 36564, 36565, 36566, 36567, 36568, 36569, 36570, + 36571, 36572, 36573, 36574, 36575, 36576, 36577, 36578, 36579, 36580, + 22539, 22541, 22525, 22509, 22528, 22558, 22553, 22596, 22560, 22629, + 22636, 22657, 22665, 22682, 22656, 39336, 40729, 25087, 33401, 33405, + 33407, 33423, 33418, 33448, 33412, 33422, 33425, 33431, 33433, 33451, + 33464, 33470, 33456, 33480, 33482, 33507, 33432, 33463, 33454, 33483, + 33484, 33473, 33449, 33460, 33441, 33450, 33439, 33476, 33486, 33444, + 33505, 33545, 33527, 33508, 33551, 33543, 33500, 33524, 33490, 33496, + 33548, 33531, 33491, 33553, 33562, 33542, 33556, 33557, 33504, 33493, + 33564, 33617, 33627, 33628, 33544, 33682, 33596, 33588, 33585, 33691, + 33630, 33583, 33615, 33607, 33603, 33631, 33600, 33559, 33632, 33581, + 33594, 33587, 33638, 33637, 36581, 36582, 36583, 36584, 36585, 36586, + 36587, 36588, 36589, 36590, 36591, 36592, 36593, 36594, 36595, 36596, + 36597, 36598, 36599, 36600, 36601, 36602, 36603, 36604, 36605, 36606, + 36607, 36608, 36609, 36610, 36611, 36612, 36613, 36614, 36615, 36616, + 36617, 36618, 36619, 36620, 36621, 36622, 36623, 36624, 36625, 36626, + 36627, 36628, 36629, 36630, 36631, 36632, 36633, 36634, 36635, 36636, + 36637, 36638, 36639, 36640, 36641, 36642, 36643, 36644, 36645, 36646, + 36647, 36648, 36649, 36650, 36651, 36652, 36653, 36654, 36655, 36656, + 36657, 36658, 36659, 36660, 36661, 36662, 36663, 36664, 36665, 36666, + 36667, 36668, 36669, 36670, 36671, 36672, 36673, 36674, 36675, 36676, + 33640, 33563, 33641, 33644, 33642, 33645, 33646, 33712, 33656, 33715, + 33716, 33696, 33706, 33683, 33692, 33669, 33660, 33718, 33705, 33661, + 33720, 33659, 33688, 33694, 33704, 33722, 33724, 33729, 33793, 33765, + 33752, 22535, 33816, 33803, 33757, 33789, 33750, 33820, 33848, 33809, + 33798, 33748, 33759, 33807, 33795, 33784, 33785, 33770, 33733, 33728, + 33830, 33776, 33761, 33884, 33873, 33882, 33881, 33907, 33927, 33928, + 33914, 33929, 33912, 33852, 33862, 33897, 33910, 33932, 33934, 33841, + 33901, 33985, 33997, 34000, 34022, 33981, 34003, 33994, 33983, 33978, + 34016, 33953, 33977, 33972, 33943, 34021, 34019, 34060, 29965, 34104, + 34032, 34105, 34079, 34106, 36677, 36678, 36679, 36680, 36681, 36682, + 36683, 36684, 36685, 36686, 36687, 36688, 36689, 36690, 36691, 36692, + 36693, 36694, 36695, 36696, 36697, 36698, 36699, 36700, 36701, 36702, + 36703, 36704, 36705, 36706, 36707, 36708, 36709, 36714, 36736, 36748, + 36754, 36765, 36768, 36769, 36770, 36772, 36773, 36774, 36775, 36778, + 36780, 36781, 36782, 36783, 36786, 36787, 36788, 36789, 36791, 36792, + 36794, 36795, 36796, 36799, 36800, 36803, 36806, 36809, 36810, 36811, + 36812, 36813, 36815, 36818, 36822, 36823, 36826, 36832, 36833, 36835, + 36839, 36844, 36847, 36849, 36850, 36852, 36853, 36854, 36858, 36859, + 36860, 36862, 36863, 36871, 36872, 36876, 36878, 36883, 36885, 36888, + 34134, 34107, 34047, 34044, 34137, 34120, 34152, 34148, 34142, 34170, + 30626, 34115, 34162, 34171, 34212, 34216, 34183, 34191, 34169, 34222, + 34204, 34181, 34233, 34231, 34224, 34259, 34241, 34268, 34303, 34343, + 34309, 34345, 34326, 34364, 24318, 24328, 22844, 22849, 32823, 22869, + 22874, 22872, 21263, 23586, 23589, 23596, 23604, 25164, 25194, 25247, + 25275, 25290, 25306, 25303, 25326, 25378, 25334, 25401, 25419, 25411, + 25517, 25590, 25457, 25466, 25486, 25524, 25453, 25516, 25482, 25449, + 25518, 25532, 25586, 25592, 25568, 25599, 25540, 25566, 25550, 25682, + 25542, 25534, 25669, 25665, 25611, 25627, 25632, 25612, 25638, 25633, + 25694, 25732, 25709, 25750, 36889, 36892, 36899, 36900, 36901, 36903, + 36904, 36905, 36906, 36907, 36908, 36912, 36913, 36914, 36915, 36916, + 36919, 36921, 36922, 36925, 36927, 36928, 36931, 36933, 36934, 36936, + 36937, 36938, 36939, 36940, 36942, 36948, 36949, 36950, 36953, 36954, + 36956, 36957, 36958, 36959, 36960, 36961, 36964, 36966, 36967, 36969, + 36970, 36971, 36972, 36975, 36976, 36977, 36978, 36979, 36982, 36983, + 36984, 36985, 36986, 36987, 36988, 36990, 36993, 36996, 36997, 36998, + 36999, 37001, 37002, 37004, 37005, 37006, 37007, 37008, 37010, 37012, + 37014, 37016, 37018, 37020, 37022, 37023, 37024, 37028, 37029, 37031, + 37032, 37033, 37035, 37037, 37042, 37047, 37052, 37053, 37055, 37056, + 25722, 25783, 25784, 25753, 25786, 25792, 25808, 25815, 25828, 25826, + 25865, 25893, 25902, 24331, 24530, 29977, 24337, 21343, 21489, 21501, + 21481, 21480, 21499, 21522, 21526, 21510, 21579, 21586, 21587, 21588, + 21590, 21571, 21537, 21591, 21593, 21539, 21554, 21634, 21652, 21623, + 21617, 21604, 21658, 21659, 21636, 21622, 21606, 21661, 21712, 21677, + 21698, 21684, 21714, 21671, 21670, 21715, 21716, 21618, 21667, 21717, + 21691, 21695, 21708, 21721, 21722, 21724, 21673, 21674, 21668, 21725, + 21711, 21726, 21787, 21735, 21792, 21757, 21780, 21747, 21794, 21795, + 21775, 21777, 21799, 21802, 21863, 21903, 21941, 21833, 21869, 21825, + 21845, 21823, 21840, 21820, 37058, 37059, 37062, 37064, 37065, 37067, + 37068, 37069, 37074, 37076, 37077, 37078, 37080, 37081, 37082, 37086, + 37087, 37088, 37091, 37092, 37093, 37097, 37098, 37100, 37102, 37104, + 37105, 37106, 37107, 37109, 37110, 37111, 37113, 37114, 37115, 37116, + 37119, 37120, 37121, 37123, 37125, 37126, 37127, 37128, 37129, 37130, + 37131, 37132, 37133, 37134, 37135, 37136, 37137, 37138, 37139, 37140, + 37141, 37142, 37143, 37144, 37146, 37147, 37148, 37149, 37151, 37152, + 37153, 37156, 37157, 37158, 37159, 37160, 37161, 37162, 37163, 37164, + 37165, 37166, 37168, 37170, 37171, 37172, 37173, 37174, 37175, 37176, + 37178, 37179, 37180, 37181, 37182, 37183, 37184, 37185, 37186, 37188, + 21815, 21846, 21877, 21878, 21879, 21811, 21808, 21852, 21899, 21970, + 21891, 21937, 21945, 21896, 21889, 21919, 21886, 21974, 21905, 21883, + 21983, 21949, 21950, 21908, 21913, 21994, 22007, 21961, 22047, 21969, + 21995, 21996, 21972, 21990, 21981, 21956, 21999, 21989, 22002, 22003, + 21964, 21965, 21992, 22005, 21988, 36756, 22046, 22024, 22028, 22017, + 22052, 22051, 22014, 22016, 22055, 22061, 22104, 22073, 22103, 22060, + 22093, 22114, 22105, 22108, 22092, 22100, 22150, 22116, 22129, 22123, + 22139, 22140, 22149, 22163, 22191, 22228, 22231, 22237, 22241, 22261, + 22251, 22265, 22271, 22276, 22282, 22281, 22300, 24079, 24089, 24084, + 24081, 24113, 24123, 24124, 37189, 37191, 37192, 37201, 37203, 37204, + 37205, 37206, 37208, 37209, 37211, 37212, 37215, 37216, 37222, 37223, + 37224, 37227, 37229, 37235, 37242, 37243, 37244, 37248, 37249, 37250, + 37251, 37252, 37254, 37256, 37258, 37262, 37263, 37267, 37268, 37269, + 37270, 37271, 37272, 37273, 37276, 37277, 37278, 37279, 37280, 37281, + 37284, 37285, 37286, 37287, 37288, 37289, 37291, 37292, 37296, 37297, + 37298, 37299, 37302, 37303, 37304, 37305, 37307, 37308, 37309, 37310, + 37311, 37312, 37313, 37314, 37315, 37316, 37317, 37318, 37320, 37323, + 37328, 37330, 37331, 37332, 37333, 37334, 37335, 37336, 37337, 37338, + 37339, 37341, 37342, 37343, 37344, 37345, 37346, 37347, 37348, 37349, + 24119, 24132, 24148, 24155, 24158, 24161, 23692, 23674, 23693, 23696, + 23702, 23688, 23704, 23705, 23697, 23706, 23708, 23733, 23714, 23741, + 23724, 23723, 23729, 23715, 23745, 23735, 23748, 23762, 23780, 23755, + 23781, 23810, 23811, 23847, 23846, 23854, 23844, 23838, 23814, 23835, + 23896, 23870, 23860, 23869, 23916, 23899, 23919, 23901, 23915, 23883, + 23882, 23913, 23924, 23938, 23961, 23965, 35955, 23991, 24005, 24435, + 24439, 24450, 24455, 24457, 24460, 24469, 24473, 24476, 24488, 24493, + 24501, 24508, 34914, 24417, 29357, 29360, 29364, 29367, 29368, 29379, + 29377, 29390, 29389, 29394, 29416, 29423, 29417, 29426, 29428, 29431, + 29441, 29427, 29443, 29434, 37350, 37351, 37352, 37353, 37354, 37355, + 37356, 37357, 37358, 37359, 37360, 37361, 37362, 37363, 37364, 37365, + 37366, 37367, 37368, 37369, 37370, 37371, 37372, 37373, 37374, 37375, + 37376, 37377, 37378, 37379, 37380, 37381, 37382, 37383, 37384, 37385, + 37386, 37387, 37388, 37389, 37390, 37391, 37392, 37393, 37394, 37395, + 37396, 37397, 37398, 37399, 37400, 37401, 37402, 37403, 37404, 37405, + 37406, 37407, 37408, 37409, 37410, 37411, 37412, 37413, 37414, 37415, + 37416, 37417, 37418, 37419, 37420, 37421, 37422, 37423, 37424, 37425, + 37426, 37427, 37428, 37429, 37430, 37431, 37432, 37433, 37434, 37435, + 37436, 37437, 37438, 37439, 37440, 37441, 37442, 37443, 37444, 37445, + 29435, 29463, 29459, 29473, 29450, 29470, 29469, 29461, 29474, 29497, + 29477, 29484, 29496, 29489, 29520, 29517, 29527, 29536, 29548, 29551, + 29566, 33307, 22821, 39143, 22820, 22786, 39267, 39271, 39272, 39273, + 39274, 39275, 39276, 39284, 39287, 39293, 39296, 39300, 39303, 39306, + 39309, 39312, 39313, 39315, 39316, 39317, 24192, 24209, 24203, 24214, + 24229, 24224, 24249, 24245, 24254, 24243, 36179, 24274, 24273, 24283, + 24296, 24298, 33210, 24516, 24521, 24534, 24527, 24579, 24558, 24580, + 24545, 24548, 24574, 24581, 24582, 24554, 24557, 24568, 24601, 24629, + 24614, 24603, 24591, 24589, 24617, 24619, 24586, 24639, 24609, 24696, + 24697, 24699, 24698, 24642, 37446, 37447, 37448, 37449, 37450, 37451, + 37452, 37453, 37454, 37455, 37456, 37457, 37458, 37459, 37460, 37461, + 37462, 37463, 37464, 37465, 37466, 37467, 37468, 37469, 37470, 37471, + 37472, 37473, 37474, 37475, 37476, 37477, 37478, 37479, 37480, 37481, + 37482, 37483, 37484, 37485, 37486, 37487, 37488, 37489, 37490, 37491, + 37493, 37494, 37495, 37496, 37497, 37498, 37499, 37500, 37501, 37502, + 37503, 37504, 37505, 37506, 37507, 37508, 37509, 37510, 37511, 37512, + 37513, 37514, 37515, 37516, 37517, 37519, 37520, 37521, 37522, 37523, + 37524, 37525, 37526, 37527, 37528, 37529, 37530, 37531, 37532, 37533, + 37534, 37535, 37536, 37537, 37538, 37539, 37540, 37541, 37542, 37543, + 24682, 24701, 24726, 24730, 24749, 24733, 24707, 24722, 24716, 24731, + 24812, 24763, 24753, 24797, 24792, 24774, 24794, 24756, 24864, 24870, + 24853, 24867, 24820, 24832, 24846, 24875, 24906, 24949, 25004, 24980, + 24999, 25015, 25044, 25077, 24541, 38579, 38377, 38379, 38385, 38387, + 38389, 38390, 38396, 38398, 38403, 38404, 38406, 38408, 38410, 38411, + 38412, 38413, 38415, 38418, 38421, 38422, 38423, 38425, 38426, 20012, + 29247, 25109, 27701, 27732, 27740, 27722, 27811, 27781, 27792, 27796, + 27788, 27752, 27753, 27764, 27766, 27782, 27817, 27856, 27860, 27821, + 27895, 27896, 27889, 27863, 27826, 27872, 27862, 27898, 27883, 27886, + 27825, 27859, 27887, 27902, 37544, 37545, 37546, 37547, 37548, 37549, + 37551, 37552, 37553, 37554, 37555, 37556, 37557, 37558, 37559, 37560, + 37561, 37562, 37563, 37564, 37565, 37566, 37567, 37568, 37569, 37570, + 37571, 37572, 37573, 37574, 37575, 37577, 37578, 37579, 37580, 37581, + 37582, 37583, 37584, 37585, 37586, 37587, 37588, 37589, 37590, 37591, + 37592, 37593, 37594, 37595, 37596, 37597, 37598, 37599, 37600, 37601, + 37602, 37603, 37604, 37605, 37606, 37607, 37608, 37609, 37610, 37611, + 37612, 37613, 37614, 37615, 37616, 37617, 37618, 37619, 37620, 37621, + 37622, 37623, 37624, 37625, 37626, 37627, 37628, 37629, 37630, 37631, + 37632, 37633, 37634, 37635, 37636, 37637, 37638, 37639, 37640, 37641, + 27961, 27943, 27916, 27971, 27976, 27911, 27908, 27929, 27918, 27947, + 27981, 27950, 27957, 27930, 27983, 27986, 27988, 27955, 28049, 28015, + 28062, 28064, 27998, 28051, 28052, 27996, 28000, 28028, 28003, 28186, + 28103, 28101, 28126, 28174, 28095, 28128, 28177, 28134, 28125, 28121, + 28182, 28075, 28172, 28078, 28203, 28270, 28238, 28267, 28338, 28255, + 28294, 28243, 28244, 28210, 28197, 28228, 28383, 28337, 28312, 28384, + 28461, 28386, 28325, 28327, 28349, 28347, 28343, 28375, 28340, 28367, + 28303, 28354, 28319, 28514, 28486, 28487, 28452, 28437, 28409, 28463, + 28470, 28491, 28532, 28458, 28425, 28457, 28553, 28557, 28556, 28536, + 28530, 28540, 28538, 28625, 37642, 37643, 37644, 37645, 37646, 37647, + 37648, 37649, 37650, 37651, 37652, 37653, 37654, 37655, 37656, 37657, + 37658, 37659, 37660, 37661, 37662, 37663, 37664, 37665, 37666, 37667, + 37668, 37669, 37670, 37671, 37672, 37673, 37674, 37675, 37676, 37677, + 37678, 37679, 37680, 37681, 37682, 37683, 37684, 37685, 37686, 37687, + 37688, 37689, 37690, 37691, 37692, 37693, 37695, 37696, 37697, 37698, + 37699, 37700, 37701, 37702, 37703, 37704, 37705, 37706, 37707, 37708, + 37709, 37710, 37711, 37712, 37713, 37714, 37715, 37716, 37717, 37718, + 37719, 37720, 37721, 37722, 37723, 37724, 37725, 37726, 37727, 37728, + 37729, 37730, 37731, 37732, 37733, 37734, 37735, 37736, 37737, 37739, + 28617, 28583, 28601, 28598, 28610, 28641, 28654, 28638, 28640, 28655, + 28698, 28707, 28699, 28729, 28725, 28751, 28766, 23424, 23428, 23445, + 23443, 23461, 23480, 29999, 39582, 25652, 23524, 23534, 35120, 23536, + 36423, 35591, 36790, 36819, 36821, 36837, 36846, 36836, 36841, 36838, + 36851, 36840, 36869, 36868, 36875, 36902, 36881, 36877, 36886, 36897, + 36917, 36918, 36909, 36911, 36932, 36945, 36946, 36944, 36968, 36952, + 36962, 36955, 26297, 36980, 36989, 36994, 37000, 36995, 37003, 24400, + 24407, 24406, 24408, 23611, 21675, 23632, 23641, 23409, 23651, 23654, + 32700, 24362, 24361, 24365, 33396, 24380, 39739, 23662, 22913, 22915, + 22925, 22953, 22954, 22947, 37740, 37741, 37742, 37743, 37744, 37745, + 37746, 37747, 37748, 37749, 37750, 37751, 37752, 37753, 37754, 37755, + 37756, 37757, 37758, 37759, 37760, 37761, 37762, 37763, 37764, 37765, + 37766, 37767, 37768, 37769, 37770, 37771, 37772, 37773, 37774, 37776, + 37777, 37778, 37779, 37780, 37781, 37782, 37783, 37784, 37785, 37786, + 37787, 37788, 37789, 37790, 37791, 37792, 37793, 37794, 37795, 37796, + 37797, 37798, 37799, 37800, 37801, 37802, 37803, 37804, 37805, 37806, + 37807, 37808, 37809, 37810, 37811, 37812, 37813, 37814, 37815, 37816, + 37817, 37818, 37819, 37820, 37821, 37822, 37823, 37824, 37825, 37826, + 37827, 37828, 37829, 37830, 37831, 37832, 37833, 37835, 37836, 37837, + 22935, 22986, 22955, 22942, 22948, 22994, 22962, 22959, 22999, 22974, + 23045, 23046, 23005, 23048, 23011, 23000, 23033, 23052, 23049, 23090, + 23092, 23057, 23075, 23059, 23104, 23143, 23114, 23125, 23100, 23138, + 23157, 33004, 23210, 23195, 23159, 23162, 23230, 23275, 23218, 23250, + 23252, 23224, 23264, 23267, 23281, 23254, 23270, 23256, 23260, 23305, + 23319, 23318, 23346, 23351, 23360, 23573, 23580, 23386, 23397, 23411, + 23377, 23379, 23394, 39541, 39543, 39544, 39546, 39551, 39549, 39552, + 39553, 39557, 39560, 39562, 39568, 39570, 39571, 39574, 39576, 39579, + 39580, 39581, 39583, 39584, 39586, 39587, 39589, 39591, 32415, 32417, + 32419, 32421, 32424, 32425, 37838, 37839, 37840, 37841, 37842, 37843, + 37844, 37845, 37847, 37848, 37849, 37850, 37851, 37852, 37853, 37854, + 37855, 37856, 37857, 37858, 37859, 37860, 37861, 37862, 37863, 37864, + 37865, 37866, 37867, 37868, 37869, 37870, 37871, 37872, 37873, 37874, + 37875, 37876, 37877, 37878, 37879, 37880, 37881, 37882, 37883, 37884, + 37885, 37886, 37887, 37888, 37889, 37890, 37891, 37892, 37893, 37894, + 37895, 37896, 37897, 37898, 37899, 37900, 37901, 37902, 37903, 37904, + 37905, 37906, 37907, 37908, 37909, 37910, 37911, 37912, 37913, 37914, + 37915, 37916, 37917, 37918, 37919, 37920, 37921, 37922, 37923, 37924, + 37925, 37926, 37927, 37928, 37929, 37930, 37931, 37932, 37933, 37934, + 32429, 32432, 32446, 32448, 32449, 32450, 32457, 32459, 32460, 32464, + 32468, 32471, 32475, 32480, 32481, 32488, 32491, 32494, 32495, 32497, + 32498, 32525, 32502, 32506, 32507, 32510, 32513, 32514, 32515, 32519, + 32520, 32523, 32524, 32527, 32529, 32530, 32535, 32537, 32540, 32539, + 32543, 32545, 32546, 32547, 32548, 32549, 32550, 32551, 32554, 32555, + 32556, 32557, 32559, 32560, 32561, 32562, 32563, 32565, 24186, 30079, + 24027, 30014, 37013, 29582, 29585, 29614, 29602, 29599, 29647, 29634, + 29649, 29623, 29619, 29632, 29641, 29640, 29669, 29657, 39036, 29706, + 29673, 29671, 29662, 29626, 29682, 29711, 29738, 29787, 29734, 29733, + 29736, 29744, 29742, 29740, 37935, 37936, 37937, 37938, 37939, 37940, + 37941, 37942, 37943, 37944, 37945, 37946, 37947, 37948, 37949, 37951, + 37952, 37953, 37954, 37955, 37956, 37957, 37958, 37959, 37960, 37961, + 37962, 37963, 37964, 37965, 37966, 37967, 37968, 37969, 37970, 37971, + 37972, 37973, 37974, 37975, 37976, 37977, 37978, 37979, 37980, 37981, + 37982, 37983, 37984, 37985, 37986, 37987, 37988, 37989, 37990, 37991, + 37992, 37993, 37994, 37996, 37997, 37998, 37999, 38000, 38001, 38002, + 38003, 38004, 38005, 38006, 38007, 38008, 38009, 38010, 38011, 38012, + 38013, 38014, 38015, 38016, 38017, 38018, 38019, 38020, 38033, 38038, + 38040, 38087, 38095, 38099, 38100, 38106, 38118, 38139, 38172, 38176, + 29723, 29722, 29761, 29788, 29783, 29781, 29785, 29815, 29805, 29822, + 29852, 29838, 29824, 29825, 29831, 29835, 29854, 29864, 29865, 29840, + 29863, 29906, 29882, 38890, 38891, 38892, 26444, 26451, 26462, 26440, + 26473, 26533, 26503, 26474, 26483, 26520, 26535, 26485, 26536, 26526, + 26541, 26507, 26487, 26492, 26608, 26633, 26584, 26634, 26601, 26544, + 26636, 26585, 26549, 26586, 26547, 26589, 26624, 26563, 26552, 26594, + 26638, 26561, 26621, 26674, 26675, 26720, 26721, 26702, 26722, 26692, + 26724, 26755, 26653, 26709, 26726, 26689, 26727, 26688, 26686, 26698, + 26697, 26665, 26805, 26767, 26740, 26743, 26771, 26731, 26818, 26990, + 26876, 26911, 26912, 26873, 38183, 38195, 38205, 38211, 38216, 38219, + 38229, 38234, 38240, 38254, 38260, 38261, 38263, 38264, 38265, 38266, + 38267, 38268, 38269, 38270, 38272, 38273, 38274, 38275, 38276, 38277, + 38278, 38279, 38280, 38281, 38282, 38283, 38284, 38285, 38286, 38287, + 38288, 38289, 38290, 38291, 38292, 38293, 38294, 38295, 38296, 38297, + 38298, 38299, 38300, 38301, 38302, 38303, 38304, 38305, 38306, 38307, + 38308, 38309, 38310, 38311, 38312, 38313, 38314, 38315, 38316, 38317, + 38318, 38319, 38320, 38321, 38322, 38323, 38324, 38325, 38326, 38327, + 38328, 38329, 38330, 38331, 38332, 38333, 38334, 38335, 38336, 38337, + 38338, 38339, 38340, 38341, 38342, 38343, 38344, 38345, 38346, 38347, + 26916, 26864, 26891, 26881, 26967, 26851, 26896, 26993, 26937, 26976, + 26946, 26973, 27012, 26987, 27008, 27032, 27000, 26932, 27084, 27015, + 27016, 27086, 27017, 26982, 26979, 27001, 27035, 27047, 27067, 27051, + 27053, 27092, 27057, 27073, 27082, 27103, 27029, 27104, 27021, 27135, + 27183, 27117, 27159, 27160, 27237, 27122, 27204, 27198, 27296, 27216, + 27227, 27189, 27278, 27257, 27197, 27176, 27224, 27260, 27281, 27280, + 27305, 27287, 27307, 29495, 29522, 27521, 27522, 27527, 27524, 27538, + 27539, 27533, 27546, 27547, 27553, 27562, 36715, 36717, 36721, 36722, + 36723, 36725, 36726, 36728, 36727, 36729, 36730, 36732, 36734, 36737, + 36738, 36740, 36743, 36747, 38348, 38349, 38350, 38351, 38352, 38353, + 38354, 38355, 38356, 38357, 38358, 38359, 38360, 38361, 38362, 38363, + 38364, 38365, 38366, 38367, 38368, 38369, 38370, 38371, 38372, 38373, + 38374, 38375, 38380, 38399, 38407, 38419, 38424, 38427, 38430, 38432, + 38435, 38436, 38437, 38438, 38439, 38440, 38441, 38443, 38444, 38445, + 38447, 38448, 38455, 38456, 38457, 38458, 38462, 38465, 38467, 38474, + 38478, 38479, 38481, 38482, 38483, 38486, 38487, 38488, 38489, 38490, + 38492, 38493, 38494, 38496, 38499, 38501, 38502, 38507, 38509, 38510, + 38511, 38512, 38513, 38515, 38520, 38521, 38522, 38523, 38524, 38525, + 38526, 38527, 38528, 38529, 38530, 38531, 38532, 38535, 38537, 38538, + 36749, 36750, 36751, 36760, 36762, 36558, 25099, 25111, 25115, 25119, + 25122, 25121, 25125, 25124, 25132, 33255, 29935, 29940, 29951, 29967, + 29969, 29971, 25908, 26094, 26095, 26096, 26122, 26137, 26482, 26115, + 26133, 26112, 28805, 26359, 26141, 26164, 26161, 26166, 26165, 32774, + 26207, 26196, 26177, 26191, 26198, 26209, 26199, 26231, 26244, 26252, + 26279, 26269, 26302, 26331, 26332, 26342, 26345, 36146, 36147, 36150, + 36155, 36157, 36160, 36165, 36166, 36168, 36169, 36167, 36173, 36181, + 36185, 35271, 35274, 35275, 35276, 35278, 35279, 35280, 35281, 29294, + 29343, 29277, 29286, 29295, 29310, 29311, 29316, 29323, 29325, 29327, + 29330, 25352, 25394, 25520, 38540, 38542, 38545, 38546, 38547, 38549, + 38550, 38554, 38555, 38557, 38558, 38559, 38560, 38561, 38562, 38563, + 38564, 38565, 38566, 38568, 38569, 38570, 38571, 38572, 38573, 38574, + 38575, 38577, 38578, 38580, 38581, 38583, 38584, 38586, 38587, 38591, + 38594, 38595, 38600, 38602, 38603, 38608, 38609, 38611, 38612, 38614, + 38615, 38616, 38617, 38618, 38619, 38620, 38621, 38622, 38623, 38625, + 38626, 38627, 38628, 38629, 38630, 38631, 38635, 38636, 38637, 38638, + 38640, 38641, 38642, 38644, 38645, 38648, 38650, 38651, 38652, 38653, + 38655, 38658, 38659, 38661, 38666, 38667, 38668, 38672, 38673, 38674, + 38676, 38677, 38679, 38680, 38681, 38682, 38683, 38685, 38687, 38688, + 25663, 25816, 32772, 27626, 27635, 27645, 27637, 27641, 27653, 27655, + 27654, 27661, 27669, 27672, 27673, 27674, 27681, 27689, 27684, 27690, + 27698, 25909, 25941, 25963, 29261, 29266, 29270, 29232, 34402, 21014, + 32927, 32924, 32915, 32956, 26378, 32957, 32945, 32939, 32941, 32948, + 32951, 32999, 33000, 33001, 33002, 32987, 32962, 32964, 32985, 32973, + 32983, 26384, 32989, 33003, 33009, 33012, 33005, 33037, 33038, 33010, + 33020, 26389, 33042, 35930, 33078, 33054, 33068, 33048, 33074, 33096, + 33100, 33107, 33140, 33113, 33114, 33137, 33120, 33129, 33148, 33149, + 33133, 33127, 22605, 23221, 33160, 33154, 33169, 28373, 33187, 33194, + 33228, 26406, 33226, 33211, 38689, 38690, 38691, 38692, 38693, 38694, + 38695, 38696, 38697, 38699, 38700, 38702, 38703, 38705, 38707, 38708, + 38709, 38710, 38711, 38714, 38715, 38716, 38717, 38719, 38720, 38721, + 38722, 38723, 38724, 38725, 38726, 38727, 38728, 38729, 38730, 38731, + 38732, 38733, 38734, 38735, 38736, 38737, 38740, 38741, 38743, 38744, + 38746, 38748, 38749, 38751, 38755, 38756, 38758, 38759, 38760, 38762, + 38763, 38764, 38765, 38766, 38767, 38768, 38769, 38770, 38773, 38775, + 38776, 38777, 38778, 38779, 38781, 38782, 38783, 38784, 38785, 38786, + 38787, 38788, 38790, 38791, 38792, 38793, 38794, 38796, 38798, 38799, + 38800, 38803, 38805, 38806, 38807, 38809, 38810, 38811, 38812, 38813, + 33217, 33190, 27428, 27447, 27449, 27459, 27462, 27481, 39121, 39122, + 39123, 39125, 39129, 39130, 27571, 24384, 27586, 35315, 26000, 40785, + 26003, 26044, 26054, 26052, 26051, 26060, 26062, 26066, 26070, 28800, + 28828, 28822, 28829, 28859, 28864, 28855, 28843, 28849, 28904, 28874, + 28944, 28947, 28950, 28975, 28977, 29043, 29020, 29032, 28997, 29042, + 29002, 29048, 29050, 29080, 29107, 29109, 29096, 29088, 29152, 29140, + 29159, 29177, 29213, 29224, 28780, 28952, 29030, 29113, 25150, 25149, + 25155, 25160, 25161, 31035, 31040, 31046, 31049, 31067, 31068, 31059, + 31066, 31074, 31063, 31072, 31087, 31079, 31098, 31109, 31114, 31130, + 31143, 31155, 24529, 24528, 38814, 38815, 38817, 38818, 38820, 38821, + 38822, 38823, 38824, 38825, 38826, 38828, 38830, 38832, 38833, 38835, + 38837, 38838, 38839, 38840, 38841, 38842, 38843, 38844, 38845, 38846, + 38847, 38848, 38849, 38850, 38851, 38852, 38853, 38854, 38855, 38856, + 38857, 38858, 38859, 38860, 38861, 38862, 38863, 38864, 38865, 38866, + 38867, 38868, 38869, 38870, 38871, 38872, 38873, 38874, 38875, 38876, + 38877, 38878, 38879, 38880, 38881, 38882, 38883, 38884, 38885, 38888, + 38894, 38895, 38896, 38897, 38898, 38900, 38903, 38904, 38905, 38906, + 38907, 38908, 38909, 38910, 38911, 38912, 38913, 38914, 38915, 38916, + 38917, 38918, 38919, 38920, 38921, 38922, 38923, 38924, 38925, 38926, + 24636, 24669, 24666, 24679, 24641, 24665, 24675, 24747, 24838, 24845, + 24925, 25001, 24989, 25035, 25041, 25094, 32896, 32895, 27795, 27894, + 28156, 30710, 30712, 30720, 30729, 30743, 30744, 30737, 26027, 30765, + 30748, 30749, 30777, 30778, 30779, 30751, 30780, 30757, 30764, 30755, + 30761, 30798, 30829, 30806, 30807, 30758, 30800, 30791, 30796, 30826, + 30875, 30867, 30874, 30855, 30876, 30881, 30883, 30898, 30905, 30885, + 30932, 30937, 30921, 30956, 30962, 30981, 30964, 30995, 31012, 31006, + 31028, 40859, 40697, 40699, 40700, 30449, 30468, 30477, 30457, 30471, + 30472, 30490, 30498, 30489, 30509, 30502, 30517, 30520, 30544, 30545, + 30535, 30531, 30554, 30568, 38927, 38928, 38929, 38930, 38931, 38932, + 38933, 38934, 38935, 38936, 38937, 38938, 38939, 38940, 38941, 38942, + 38943, 38944, 38945, 38946, 38947, 38948, 38949, 38950, 38951, 38952, + 38953, 38954, 38955, 38956, 38957, 38958, 38959, 38960, 38961, 38962, + 38963, 38964, 38965, 38966, 38967, 38968, 38969, 38970, 38971, 38972, + 38973, 38974, 38975, 38976, 38977, 38978, 38979, 38980, 38981, 38982, + 38983, 38984, 38985, 38986, 38987, 38988, 38989, 38990, 38991, 38992, + 38993, 38994, 38995, 38996, 38997, 38998, 38999, 39000, 39001, 39002, + 39003, 39004, 39005, 39006, 39007, 39008, 39009, 39010, 39011, 39012, + 39013, 39014, 39015, 39016, 39017, 39018, 39019, 39020, 39021, 39022, + 30562, 30565, 30591, 30605, 30589, 30592, 30604, 30609, 30623, 30624, + 30640, 30645, 30653, 30010, 30016, 30030, 30027, 30024, 30043, 30066, + 30073, 30083, 32600, 32609, 32607, 35400, 32616, 32628, 32625, 32633, + 32641, 32638, 30413, 30437, 34866, 38021, 38022, 38023, 38027, 38026, + 38028, 38029, 38031, 38032, 38036, 38039, 38037, 38042, 38043, 38044, + 38051, 38052, 38059, 38058, 38061, 38060, 38063, 38064, 38066, 38068, + 38070, 38071, 38072, 38073, 38074, 38076, 38077, 38079, 38084, 38088, + 38089, 38090, 38091, 38092, 38093, 38094, 38096, 38097, 38098, 38101, + 38102, 38103, 38105, 38104, 38107, 38110, 38111, 38112, 38114, 38116, + 38117, 38119, 38120, 38122, 39023, 39024, 39025, 39026, 39027, 39028, + 39051, 39054, 39058, 39061, 39065, 39075, 39080, 39081, 39082, 39083, + 39084, 39085, 39086, 39087, 39088, 39089, 39090, 39091, 39092, 39093, + 39094, 39095, 39096, 39097, 39098, 39099, 39100, 39101, 39102, 39103, + 39104, 39105, 39106, 39107, 39108, 39109, 39110, 39111, 39112, 39113, + 39114, 39115, 39116, 39117, 39119, 39120, 39124, 39126, 39127, 39131, + 39132, 39133, 39136, 39137, 39138, 39139, 39140, 39141, 39142, 39145, + 39146, 39147, 39148, 39149, 39150, 39151, 39152, 39153, 39154, 39155, + 39156, 39157, 39158, 39159, 39160, 39161, 39162, 39163, 39164, 39165, + 39166, 39167, 39168, 39169, 39170, 39171, 39172, 39173, 39174, 39175, + 38121, 38123, 38126, 38127, 38131, 38132, 38133, 38135, 38137, 38140, + 38141, 38143, 38147, 38146, 38150, 38151, 38153, 38154, 38157, 38158, + 38159, 38162, 38163, 38164, 38165, 38166, 38168, 38171, 38173, 38174, + 38175, 38178, 38186, 38187, 38185, 38188, 38193, 38194, 38196, 38198, + 38199, 38200, 38204, 38206, 38207, 38210, 38197, 38212, 38213, 38214, + 38217, 38220, 38222, 38223, 38226, 38227, 38228, 38230, 38231, 38232, + 38233, 38235, 38238, 38239, 38237, 38241, 38242, 38244, 38245, 38246, + 38247, 38248, 38249, 38250, 38251, 38252, 38255, 38257, 38258, 38259, + 38202, 30695, 30700, 38601, 31189, 31213, 31203, 31211, 31238, 23879, + 31235, 31234, 31262, 31252, 39176, 39177, 39178, 39179, 39180, 39182, + 39183, 39185, 39186, 39187, 39188, 39189, 39190, 39191, 39192, 39193, + 39194, 39195, 39196, 39197, 39198, 39199, 39200, 39201, 39202, 39203, + 39204, 39205, 39206, 39207, 39208, 39209, 39210, 39211, 39212, 39213, + 39215, 39216, 39217, 39218, 39219, 39220, 39221, 39222, 39223, 39224, + 39225, 39226, 39227, 39228, 39229, 39230, 39231, 39232, 39233, 39234, + 39235, 39236, 39237, 39238, 39239, 39240, 39241, 39242, 39243, 39244, + 39245, 39246, 39247, 39248, 39249, 39250, 39251, 39254, 39255, 39256, + 39257, 39258, 39259, 39260, 39261, 39262, 39263, 39264, 39265, 39266, + 39268, 39270, 39283, 39288, 39289, 39291, 39294, 39298, 39299, 39305, + 31289, 31287, 31313, 40655, 39333, 31344, 30344, 30350, 30355, 30361, + 30372, 29918, 29920, 29996, 40480, 40482, 40488, 40489, 40490, 40491, + 40492, 40498, 40497, 40502, 40504, 40503, 40505, 40506, 40510, 40513, + 40514, 40516, 40518, 40519, 40520, 40521, 40523, 40524, 40526, 40529, + 40533, 40535, 40538, 40539, 40540, 40542, 40547, 40550, 40551, 40552, + 40553, 40554, 40555, 40556, 40561, 40557, 40563, 30098, 30100, 30102, + 30112, 30109, 30124, 30115, 30131, 30132, 30136, 30148, 30129, 30128, + 30147, 30146, 30166, 30157, 30179, 30184, 30182, 30180, 30187, 30183, + 30211, 30193, 30204, 30207, 30224, 30208, 30213, 30220, 30231, 30218, + 30245, 30232, 30229, 30233, 39308, 39310, 39322, 39323, 39324, 39325, + 39326, 39327, 39328, 39329, 39330, 39331, 39332, 39334, 39335, 39337, + 39338, 39339, 39340, 39341, 39342, 39343, 39344, 39345, 39346, 39347, + 39348, 39349, 39350, 39351, 39352, 39353, 39354, 39355, 39356, 39357, + 39358, 39359, 39360, 39361, 39362, 39363, 39364, 39365, 39366, 39367, + 39368, 39369, 39370, 39371, 39372, 39373, 39374, 39375, 39376, 39377, + 39378, 39379, 39380, 39381, 39382, 39383, 39384, 39385, 39386, 39387, + 39388, 39389, 39390, 39391, 39392, 39393, 39394, 39395, 39396, 39397, + 39398, 39399, 39400, 39401, 39402, 39403, 39404, 39405, 39406, 39407, + 39408, 39409, 39410, 39411, 39412, 39413, 39414, 39415, 39416, 39417, + 30235, 30268, 30242, 30240, 30272, 30253, 30256, 30271, 30261, 30275, + 30270, 30259, 30285, 30302, 30292, 30300, 30294, 30315, 30319, 32714, + 31462, 31352, 31353, 31360, 31366, 31368, 31381, 31398, 31392, 31404, + 31400, 31405, 31411, 34916, 34921, 34930, 34941, 34943, 34946, 34978, + 35014, 34999, 35004, 35017, 35042, 35022, 35043, 35045, 35057, 35098, + 35068, 35048, 35070, 35056, 35105, 35097, 35091, 35099, 35082, 35124, + 35115, 35126, 35137, 35174, 35195, 30091, 32997, 30386, 30388, 30684, + 32786, 32788, 32790, 32796, 32800, 32802, 32805, 32806, 32807, 32809, + 32808, 32817, 32779, 32821, 32835, 32838, 32845, 32850, 32873, 32881, + 35203, 39032, 39040, 39043, 39418, 39419, 39420, 39421, 39422, 39423, + 39424, 39425, 39426, 39427, 39428, 39429, 39430, 39431, 39432, 39433, + 39434, 39435, 39436, 39437, 39438, 39439, 39440, 39441, 39442, 39443, + 39444, 39445, 39446, 39447, 39448, 39449, 39450, 39451, 39452, 39453, + 39454, 39455, 39456, 39457, 39458, 39459, 39460, 39461, 39462, 39463, + 39464, 39465, 39466, 39467, 39468, 39469, 39470, 39471, 39472, 39473, + 39474, 39475, 39476, 39477, 39478, 39479, 39480, 39481, 39482, 39483, + 39484, 39485, 39486, 39487, 39488, 39489, 39490, 39491, 39492, 39493, + 39494, 39495, 39496, 39497, 39498, 39499, 39500, 39501, 39502, 39503, + 39504, 39505, 39506, 39507, 39508, 39509, 39510, 39511, 39512, 39513, + 39049, 39052, 39053, 39055, 39060, 39066, 39067, 39070, 39071, 39073, + 39074, 39077, 39078, 34381, 34388, 34412, 34414, 34431, 34426, 34428, + 34427, 34472, 34445, 34443, 34476, 34461, 34471, 34467, 34474, 34451, + 34473, 34486, 34500, 34485, 34510, 34480, 34490, 34481, 34479, 34505, + 34511, 34484, 34537, 34545, 34546, 34541, 34547, 34512, 34579, 34526, + 34548, 34527, 34520, 34513, 34563, 34567, 34552, 34568, 34570, 34573, + 34569, 34595, 34619, 34590, 34597, 34606, 34586, 34622, 34632, 34612, + 34609, 34601, 34615, 34623, 34690, 34594, 34685, 34686, 34683, 34656, + 34672, 34636, 34670, 34699, 34643, 34659, 34684, 34660, 34649, 34661, + 34707, 34735, 34728, 34770, 39514, 39515, 39516, 39517, 39518, 39519, + 39520, 39521, 39522, 39523, 39524, 39525, 39526, 39527, 39528, 39529, + 39530, 39531, 39538, 39555, 39561, 39565, 39566, 39572, 39573, 39577, + 39590, 39593, 39594, 39595, 39596, 39597, 39598, 39599, 39602, 39603, + 39604, 39605, 39609, 39611, 39613, 39614, 39615, 39619, 39620, 39622, + 39623, 39624, 39625, 39626, 39629, 39630, 39631, 39632, 39634, 39636, + 39637, 39638, 39639, 39641, 39642, 39643, 39644, 39645, 39646, 39648, + 39650, 39651, 39652, 39653, 39655, 39656, 39657, 39658, 39660, 39662, + 39664, 39665, 39666, 39667, 39668, 39669, 39670, 39671, 39672, 39674, + 39676, 39677, 39678, 39679, 39680, 39681, 39682, 39684, 39685, 39686, + 34758, 34696, 34693, 34733, 34711, 34691, 34731, 34789, 34732, 34741, + 34739, 34763, 34771, 34749, 34769, 34752, 34762, 34779, 34794, 34784, + 34798, 34838, 34835, 34814, 34826, 34843, 34849, 34873, 34876, 32566, + 32578, 32580, 32581, 33296, 31482, 31485, 31496, 31491, 31492, 31509, + 31498, 31531, 31503, 31559, 31544, 31530, 31513, 31534, 31537, 31520, + 31525, 31524, 31539, 31550, 31518, 31576, 31578, 31557, 31605, 31564, + 31581, 31584, 31598, 31611, 31586, 31602, 31601, 31632, 31654, 31655, + 31672, 31660, 31645, 31656, 31621, 31658, 31644, 31650, 31659, 31668, + 31697, 31681, 31692, 31709, 31706, 31717, 31718, 31722, 31756, 31742, + 31740, 31759, 31766, 31755, 39687, 39689, 39690, 39691, 39692, 39693, + 39694, 39696, 39697, 39698, 39700, 39701, 39702, 39703, 39704, 39705, + 39706, 39707, 39708, 39709, 39710, 39712, 39713, 39714, 39716, 39717, + 39718, 39719, 39720, 39721, 39722, 39723, 39724, 39725, 39726, 39728, + 39729, 39731, 39732, 39733, 39734, 39735, 39736, 39737, 39738, 39741, + 39742, 39743, 39744, 39750, 39754, 39755, 39756, 39758, 39760, 39762, + 39763, 39765, 39766, 39767, 39768, 39769, 39770, 39771, 39772, 39773, + 39774, 39775, 39776, 39777, 39778, 39779, 39780, 39781, 39782, 39783, + 39784, 39785, 39786, 39787, 39788, 39789, 39790, 39791, 39792, 39793, + 39794, 39795, 39796, 39797, 39798, 39799, 39800, 39801, 39802, 39803, + 31775, 31786, 31782, 31800, 31809, 31808, 33278, 33281, 33282, 33284, + 33260, 34884, 33313, 33314, 33315, 33325, 33327, 33320, 33323, 33336, + 33339, 33331, 33332, 33342, 33348, 33353, 33355, 33359, 33370, 33375, + 33384, 34942, 34949, 34952, 35032, 35039, 35166, 32669, 32671, 32679, + 32687, 32688, 32690, 31868, 25929, 31889, 31901, 31900, 31902, 31906, + 31922, 31932, 31933, 31937, 31943, 31948, 31949, 31944, 31941, 31959, + 31976, 33390, 26280, 32703, 32718, 32725, 32741, 32737, 32742, 32745, + 32750, 32755, 31992, 32119, 32166, 32174, 32327, 32411, 40632, 40628, + 36211, 36228, 36244, 36241, 36273, 36199, 36205, 35911, 35913, 37194, + 37200, 37198, 37199, 37220, 39804, 39805, 39806, 39807, 39808, 39809, + 39810, 39811, 39812, 39813, 39814, 39815, 39816, 39817, 39818, 39819, + 39820, 39821, 39822, 39823, 39824, 39825, 39826, 39827, 39828, 39829, + 39830, 39831, 39832, 39833, 39834, 39835, 39836, 39837, 39838, 39839, + 39840, 39841, 39842, 39843, 39844, 39845, 39846, 39847, 39848, 39849, + 39850, 39851, 39852, 39853, 39854, 39855, 39856, 39857, 39858, 39859, + 39860, 39861, 39862, 39863, 39864, 39865, 39866, 39867, 39868, 39869, + 39870, 39871, 39872, 39873, 39874, 39875, 39876, 39877, 39878, 39879, + 39880, 39881, 39882, 39883, 39884, 39885, 39886, 39887, 39888, 39889, + 39890, 39891, 39892, 39893, 39894, 39895, 39896, 39897, 39898, 39899, + 37218, 37217, 37232, 37225, 37231, 37245, 37246, 37234, 37236, 37241, + 37260, 37253, 37264, 37261, 37265, 37282, 37283, 37290, 37293, 37294, + 37295, 37301, 37300, 37306, 35925, 40574, 36280, 36331, 36357, 36441, + 36457, 36277, 36287, 36284, 36282, 36292, 36310, 36311, 36314, 36318, + 36302, 36303, 36315, 36294, 36332, 36343, 36344, 36323, 36345, 36347, + 36324, 36361, 36349, 36372, 36381, 36383, 36396, 36398, 36387, 36399, + 36410, 36416, 36409, 36405, 36413, 36401, 36425, 36417, 36418, 36433, + 36434, 36426, 36464, 36470, 36476, 36463, 36468, 36485, 36495, 36500, + 36496, 36508, 36510, 35960, 35970, 35978, 35973, 35992, 35988, 26011, + 35286, 35294, 35290, 35292, 39900, 39901, 39902, 39903, 39904, 39905, + 39906, 39907, 39908, 39909, 39910, 39911, 39912, 39913, 39914, 39915, + 39916, 39917, 39918, 39919, 39920, 39921, 39922, 39923, 39924, 39925, + 39926, 39927, 39928, 39929, 39930, 39931, 39932, 39933, 39934, 39935, + 39936, 39937, 39938, 39939, 39940, 39941, 39942, 39943, 39944, 39945, + 39946, 39947, 39948, 39949, 39950, 39951, 39952, 39953, 39954, 39955, + 39956, 39957, 39958, 39959, 39960, 39961, 39962, 39963, 39964, 39965, + 39966, 39967, 39968, 39969, 39970, 39971, 39972, 39973, 39974, 39975, + 39976, 39977, 39978, 39979, 39980, 39981, 39982, 39983, 39984, 39985, + 39986, 39987, 39988, 39989, 39990, 39991, 39992, 39993, 39994, 39995, + 35301, 35307, 35311, 35390, 35622, 38739, 38633, 38643, 38639, 38662, + 38657, 38664, 38671, 38670, 38698, 38701, 38704, 38718, 40832, 40835, + 40837, 40838, 40839, 40840, 40841, 40842, 40844, 40702, 40715, 40717, + 38585, 38588, 38589, 38606, 38610, 30655, 38624, 37518, 37550, 37576, + 37694, 37738, 37834, 37775, 37950, 37995, 40063, 40066, 40069, 40070, + 40071, 40072, 31267, 40075, 40078, 40080, 40081, 40082, 40084, 40085, + 40090, 40091, 40094, 40095, 40096, 40097, 40098, 40099, 40101, 40102, + 40103, 40104, 40105, 40107, 40109, 40110, 40112, 40113, 40114, 40115, + 40116, 40117, 40118, 40119, 40122, 40123, 40124, 40125, 40132, 40133, + 40134, 40135, 40138, 40139, 39996, 39997, 39998, 39999, 40000, 40001, + 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, + 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, + 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, + 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, 40040, 40041, + 40042, 40043, 40044, 40045, 40046, 40047, 40048, 40049, 40050, 40051, + 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40061, 40062, + 40064, 40067, 40068, 40073, 40074, 40076, 40079, 40083, 40086, 40087, + 40088, 40089, 40093, 40106, 40108, 40111, 40121, 40126, 40127, 40128, + 40129, 40130, 40136, 40137, 40145, 40146, 40154, 40155, 40160, 40161, + 40140, 40141, 40142, 40143, 40144, 40147, 40148, 40149, 40151, 40152, + 40153, 40156, 40157, 40159, 40162, 38780, 38789, 38801, 38802, 38804, + 38831, 38827, 38819, 38834, 38836, 39601, 39600, 39607, 40536, 39606, + 39610, 39612, 39617, 39616, 39621, 39618, 39627, 39628, 39633, 39749, + 39747, 39751, 39753, 39752, 39757, 39761, 39144, 39181, 39214, 39253, + 39252, 39647, 39649, 39654, 39663, 39659, 39675, 39661, 39673, 39688, + 39695, 39699, 39711, 39715, 40637, 40638, 32315, 40578, 40583, 40584, + 40587, 40594, 37846, 40605, 40607, 40667, 40668, 40669, 40672, 40671, + 40674, 40681, 40679, 40677, 40682, 40687, 40738, 40748, 40751, 40761, + 40759, 40765, 40766, 40772, 40163, 40164, 40165, 40166, 40167, 40168, + 40169, 40170, 40171, 40172, 40173, 40174, 40175, 40176, 40177, 40178, + 40179, 40180, 40181, 40182, 40183, 40184, 40185, 40186, 40187, 40188, + 40189, 40190, 40191, 40192, 40193, 40194, 40195, 40196, 40197, 40198, + 40199, 40200, 40201, 40202, 40203, 40204, 40205, 40206, 40207, 40208, + 40209, 40210, 40211, 40212, 40213, 40214, 40215, 40216, 40217, 40218, + 40219, 40220, 40221, 40222, 40223, 40224, 40225, 40226, 40227, 40228, + 40229, 40230, 40231, 40232, 40233, 40234, 40235, 40236, 40237, 40238, + 40239, 40240, 40241, 40242, 40243, 40244, 40245, 40246, 40247, 40248, + 40249, 40250, 40251, 40252, 40253, 40254, 40255, 40256, 40257, 40258, + 57908, 57909, 57910, 57911, 57912, 57913, 57914, 57915, 57916, 57917, + 57918, 57919, 57920, 57921, 57922, 57923, 57924, 57925, 57926, 57927, + 57928, 57929, 57930, 57931, 57932, 57933, 57934, 57935, 57936, 57937, + 57938, 57939, 57940, 57941, 57942, 57943, 57944, 57945, 57946, 57947, + 57948, 57949, 57950, 57951, 57952, 57953, 57954, 57955, 57956, 57957, + 57958, 57959, 57960, 57961, 57962, 57963, 57964, 57965, 57966, 57967, + 57968, 57969, 57970, 57971, 57972, 57973, 57974, 57975, 57976, 57977, + 57978, 57979, 57980, 57981, 57982, 57983, 57984, 57985, 57986, 57987, + 57988, 57989, 57990, 57991, 57992, 57993, 57994, 57995, 57996, 57997, + 57998, 57999, 58000, 58001, 40259, 40260, 40261, 40262, 40263, 40264, + 40265, 40266, 40267, 40268, 40269, 40270, 40271, 40272, 40273, 40274, + 40275, 40276, 40277, 40278, 40279, 40280, 40281, 40282, 40283, 40284, + 40285, 40286, 40287, 40288, 40289, 40290, 40291, 40292, 40293, 40294, + 40295, 40296, 40297, 40298, 40299, 40300, 40301, 40302, 40303, 40304, + 40305, 40306, 40307, 40308, 40309, 40310, 40311, 40312, 40313, 40314, + 40315, 40316, 40317, 40318, 40319, 40320, 40321, 40322, 40323, 40324, + 40325, 40326, 40327, 40328, 40329, 40330, 40331, 40332, 40333, 40334, + 40335, 40336, 40337, 40338, 40339, 40340, 40341, 40342, 40343, 40344, + 40345, 40346, 40347, 40348, 40349, 40350, 40351, 40352, 40353, 40354, + 58002, 58003, 58004, 58005, 58006, 58007, 58008, 58009, 58010, 58011, + 58012, 58013, 58014, 58015, 58016, 58017, 58018, 58019, 58020, 58021, + 58022, 58023, 58024, 58025, 58026, 58027, 58028, 58029, 58030, 58031, + 58032, 58033, 58034, 58035, 58036, 58037, 58038, 58039, 58040, 58041, + 58042, 58043, 58044, 58045, 58046, 58047, 58048, 58049, 58050, 58051, + 58052, 58053, 58054, 58055, 58056, 58057, 58058, 58059, 58060, 58061, + 58062, 58063, 58064, 58065, 58066, 58067, 58068, 58069, 58070, 58071, + 58072, 58073, 58074, 58075, 58076, 58077, 58078, 58079, 58080, 58081, + 58082, 58083, 58084, 58085, 58086, 58087, 58088, 58089, 58090, 58091, + 58092, 58093, 58094, 58095, 40355, 40356, 40357, 40358, 40359, 40360, + 40361, 40362, 40363, 40364, 40365, 40366, 40367, 40368, 40369, 40370, + 40371, 40372, 40373, 40374, 40375, 40376, 40377, 40378, 40379, 40380, + 40381, 40382, 40383, 40384, 40385, 40386, 40387, 40388, 40389, 40390, + 40391, 40392, 40393, 40394, 40395, 40396, 40397, 40398, 40399, 40400, + 40401, 40402, 40403, 40404, 40405, 40406, 40407, 40408, 40409, 40410, + 40411, 40412, 40413, 40414, 40415, 40416, 40417, 40418, 40419, 40420, + 40421, 40422, 40423, 40424, 40425, 40426, 40427, 40428, 40429, 40430, + 40431, 40432, 40433, 40434, 40435, 40436, 40437, 40438, 40439, 40440, + 40441, 40442, 40443, 40444, 40445, 40446, 40447, 40448, 40449, 40450, + 58096, 58097, 58098, 58099, 58100, 58101, 58102, 58103, 58104, 58105, + 58106, 58107, 58108, 58109, 58110, 58111, 58112, 58113, 58114, 58115, + 58116, 58117, 58118, 58119, 58120, 58121, 58122, 58123, 58124, 58125, + 58126, 58127, 58128, 58129, 58130, 58131, 58132, 58133, 58134, 58135, + 58136, 58137, 58138, 58139, 58140, 58141, 58142, 58143, 58144, 58145, + 58146, 58147, 58148, 58149, 58150, 58151, 58152, 58153, 58154, 58155, + 58156, 58157, 58158, 58159, 58160, 58161, 58162, 58163, 58164, 58165, + 58166, 58167, 58168, 58169, 58170, 58171, 58172, 58173, 58174, 58175, + 58176, 58177, 58178, 58179, 58180, 58181, 58182, 58183, 58184, 58185, + 58186, 58187, 58188, 58189, 40451, 40452, 40453, 40454, 40455, 40456, + 40457, 40458, 40459, 40460, 40461, 40462, 40463, 40464, 40465, 40466, + 40467, 40468, 40469, 40470, 40471, 40472, 40473, 40474, 40475, 40476, + 40477, 40478, 40484, 40487, 40494, 40496, 40500, 40507, 40508, 40512, + 40525, 40528, 40530, 40531, 40532, 40534, 40537, 40541, 40543, 40544, + 40545, 40546, 40549, 40558, 40559, 40562, 40564, 40565, 40566, 40567, + 40568, 40569, 40570, 40571, 40572, 40573, 40576, 40577, 40579, 40580, + 40581, 40582, 40585, 40586, 40588, 40589, 40590, 40591, 40592, 40593, + 40596, 40597, 40598, 40599, 40600, 40601, 40602, 40603, 40604, 40606, + 40608, 40609, 40610, 40611, 40612, 40613, 40615, 40616, 40617, 40618, + 58190, 58191, 58192, 58193, 58194, 58195, 58196, 58197, 58198, 58199, + 58200, 58201, 58202, 58203, 58204, 58205, 58206, 58207, 58208, 58209, + 58210, 58211, 58212, 58213, 58214, 58215, 58216, 58217, 58218, 58219, + 58220, 58221, 58222, 58223, 58224, 58225, 58226, 58227, 58228, 58229, + 58230, 58231, 58232, 58233, 58234, 58235, 58236, 58237, 58238, 58239, + 58240, 58241, 58242, 58243, 58244, 58245, 58246, 58247, 58248, 58249, + 58250, 58251, 58252, 58253, 58254, 58255, 58256, 58257, 58258, 58259, + 58260, 58261, 58262, 58263, 58264, 58265, 58266, 58267, 58268, 58269, + 58270, 58271, 58272, 58273, 58274, 58275, 58276, 58277, 58278, 58279, + 58280, 58281, 58282, 58283, 40619, 40620, 40621, 40622, 40623, 40624, + 40625, 40626, 40627, 40629, 40630, 40631, 40633, 40634, 40636, 40639, + 40640, 40641, 40642, 40643, 40645, 40646, 40647, 40648, 40650, 40651, + 40652, 40656, 40658, 40659, 40661, 40662, 40663, 40665, 40666, 40670, + 40673, 40675, 40676, 40678, 40680, 40683, 40684, 40685, 40686, 40688, + 40689, 40690, 40691, 40692, 40693, 40694, 40695, 40696, 40698, 40701, + 40703, 40704, 40705, 40706, 40707, 40708, 40709, 40710, 40711, 40712, + 40713, 40714, 40716, 40719, 40721, 40722, 40724, 40725, 40726, 40728, + 40730, 40731, 40732, 40733, 40734, 40735, 40737, 40739, 40740, 40741, + 40742, 40743, 40744, 40745, 40746, 40747, 40749, 40750, 40752, 40753, + 58284, 58285, 58286, 58287, 58288, 58289, 58290, 58291, 58292, 58293, + 58294, 58295, 58296, 58297, 58298, 58299, 58300, 58301, 58302, 58303, + 58304, 58305, 58306, 58307, 58308, 58309, 58310, 58311, 58312, 58313, + 58314, 58315, 58316, 58317, 58318, 58319, 58320, 58321, 58322, 58323, + 58324, 58325, 58326, 58327, 58328, 58329, 58330, 58331, 58332, 58333, + 58334, 58335, 58336, 58337, 58338, 58339, 58340, 58341, 58342, 58343, + 58344, 58345, 58346, 58347, 58348, 58349, 58350, 58351, 58352, 58353, + 58354, 58355, 58356, 58357, 58358, 58359, 58360, 58361, 58362, 58363, + 58364, 58365, 58366, 58367, 58368, 58369, 58370, 58371, 58372, 58373, + 58374, 58375, 58376, 58377, 40754, 40755, 40756, 40757, 40758, 40760, + 40762, 40764, 40767, 40768, 40769, 40770, 40771, 40773, 40774, 40775, + 40776, 40777, 40778, 40779, 40780, 40781, 40782, 40783, 40786, 40787, + 40788, 40789, 40790, 40791, 40792, 40793, 40794, 40795, 40796, 40797, + 40798, 40799, 40800, 40801, 40802, 40803, 40804, 40805, 40806, 40807, + 40808, 40809, 40810, 40811, 40812, 40813, 40814, 40815, 40816, 40817, + 40818, 40819, 40820, 40821, 40822, 40823, 40824, 40825, 40826, 40827, + 40828, 40829, 40830, 40833, 40834, 40845, 40846, 40847, 40848, 40849, + 40850, 40851, 40852, 40853, 40854, 40855, 40856, 40860, 40861, 40862, + 40865, 40866, 40867, 40868, 40869, 63788, 63865, 63893, 63975, 63985, + 58378, 58379, 58380, 58381, 58382, 58383, 58384, 58385, 58386, 58387, + 58388, 58389, 58390, 58391, 58392, 58393, 58394, 58395, 58396, 58397, + 58398, 58399, 58400, 58401, 58402, 58403, 58404, 58405, 58406, 58407, + 58408, 58409, 58410, 58411, 58412, 58413, 58414, 58415, 58416, 58417, + 58418, 58419, 58420, 58421, 58422, 58423, 58424, 58425, 58426, 58427, + 58428, 58429, 58430, 58431, 58432, 58433, 58434, 58435, 58436, 58437, + 58438, 58439, 58440, 58441, 58442, 58443, 58444, 58445, 58446, 58447, + 58448, 58449, 58450, 58451, 58452, 58453, 58454, 58455, 58456, 58457, + 58458, 58459, 58460, 58461, 58462, 58463, 58464, 58465, 58466, 58467, + 58468, 58469, 58470, 58471, 64012, 64013, 64014, 64015, 64017, 64019, + 64020, 64024, 64031, 64032, 64033, 64035, 64036, 64039, 64040, 64041, + 11905, 59414, 59415, 59416, 11908, 13427, 13383, 11912, 11915, 59422, + 13726, 13850, 13838, 11916, 11927, 14702, 14616, 59430, 14799, 14815, + 14963, 14800, 59435, 59436, 15182, 15470, 15584, 11943, 59441, 59442, + 11946, 16470, 16735, 11950, 17207, 11955, 11958, 11959, 59451, 17329, + 17324, 11963, 17373, 17622, 18017, 17996, 59459, 18211, 18217, 18300, + 18317, 11978, 18759, 18810, 18813, 18818, 18819, 18821, 18822, 18847, + 18843, 18871, 18870, 59476, 59477, 19619, 19615, 19616, 19617, 19575, + 19618, 19731, 19732, 19733, 19734, 19735, 19736, 19737, 19886, 59492, + 58472, 58473, 58474, 58475, 58476, 58477, 58478, 58479, 58480, 58481, + 58482, 58483, 58484, 58485, 58486, 58487, 58488, 58489, 58490, 58491, + 58492, 58493, 58494, 58495, 58496, 58497, 58498, 58499, 58500, 58501, + 58502, 58503, 58504, 58505, 58506, 58507, 58508, 58509, 58510, 58511, + 58512, 58513, 58514, 58515, 58516, 58517, 58518, 58519, 58520, 58521, + 58522, 58523, 58524, 58525, 58526, 58527, 58528, 58529, 58530, 58531, + 58532, 58533, 58534, 58535, 58536, 58537, 58538, 58539, 58540, 58541, + 58542, 58543, 58544, 58545, 58546, 58547, 58548, 58549, 58550, 58551, + 58552, 58553, 58554, 58555, 58556, 58557, 58558, 58559, 58560, 58561, + 58562, 58563, 58564, 58565, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u16) -> u32 { + let code = code as usize; + if code < 23940 { + FORWARD_TABLE[code] as u32 + } else { + 0xffff + } +} + +static BACKWARD_TABLE_LOWER: &'static [u16] = &[ + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6247, 65535, 65535, 6251, 6182, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6242, 6207, 65535, 65535, + 65535, 65535, 65535, 6179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6208, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7509, 7507, 65535, 65535, 65535, 65535, 65535, 65535, 7513, + 7511, 7531, 65535, 7517, 7515, 65535, 65535, 65535, 65535, 7521, 7519, + 65535, 65535, 65535, 6209, 65535, 7525, 7523, 65535, 7530, 65535, 65535, + 65535, 65535, 7506, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7510, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7512, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7514, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7534, 65535, 65535, 65535, 7535, 65535, + 65535, 65535, 65535, 7518, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7522, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7508, 65535, 7516, 65535, 7520, + 65535, 7524, 65535, 7526, 65535, 7527, 65535, 7528, 65535, 7529, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7536, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7532, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7537, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 6181, 65535, 6180, 7410, 7411, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7412, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7126, 7127, 7128, 7129, 7130, 7131, 7132, 7133, 7134, 7135, + 7136, 7137, 7138, 7139, 7140, 7141, 7142, 65535, 7143, 7144, 7145, 7146, + 7147, 7148, 7149, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7158, + 7159, 7160, 7161, 7162, 7163, 7164, 7165, 7166, 7167, 7168, 7169, 7170, + 7171, 7172, 7173, 7174, 65535, 7175, 7176, 7177, 7178, 7179, 7180, 7181, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7322, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7316, 7317, 7318, 7319, + 7320, 7321, 7323, 7324, 7325, 7326, 7327, 7328, 7329, 7330, 7331, 7332, + 7333, 7334, 7335, 7336, 7337, 7338, 7339, 7340, 7341, 7342, 7343, 7344, + 7345, 7346, 7347, 7348, 7364, 7365, 7366, 7367, 7368, 7369, 7371, 7372, + 7373, 7374, 7375, 7376, 7377, 7378, 7379, 7380, 7381, 7382, 7383, 7384, + 7385, 7386, 7387, 7388, 7389, 7390, 7391, 7392, 7393, 7394, 7395, 7396, + 65535, 7370, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7628, 65535, 65535, 7413, 6185, 7414, 6187, 65535, 6189, 6190, + 65535, 65535, 6191, 6192, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 7415, 6188, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 6250, 65535, 6243, 6244, 65535, 7416, 65535, 65535, 65535, 65535, 65535, + 6264, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6432, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6245, 65535, 7417, + 65535, 65535, 65535, 7418, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6252, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7625, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6446, 6447, 6448, 6449, 6450, 6451, + 6452, 6453, 6454, 6455, 6456, 6457, 65535, 65535, 65535, 65535, 6366, 6367, + 6368, 6369, 6370, 6371, 6372, 6373, 6374, 6375, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6266, 6267, 6265, + 6268, 65535, 65535, 7419, 7420, 7421, 7422, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6217, + 65535, 65535, 65535, 65535, 65535, 65535, 6214, 65535, 6213, 65535, 65535, + 65535, 7423, 65535, 65535, 65535, 65535, 6219, 65535, 65535, 6231, 6237, + 7424, 6222, 65535, 65535, 7425, 65535, 6221, 65535, 6211, 6212, 6216, 6215, + 6225, 65535, 65535, 6226, 65535, 65535, 65535, 65535, 65535, 6239, 6238, + 6210, 6218, 65535, 65535, 65535, 65535, 65535, 6230, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6229, 65535, 65535, 65535, + 6228, 65535, 65535, 65535, 65535, 65535, 7426, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6232, 6227, + 65535, 65535, 6235, 6236, 7427, 7428, 65535, 65535, 65535, 65535, 65535, + 65535, 6233, 6234, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7491, 65535, + 65535, 65535, 6224, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6220, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7429, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6223, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6422, 6423, + 6424, 6425, 6426, 6427, 6428, 6429, 6430, 6431, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6402, 6403, 6404, 6405, 6406, + 6407, 6408, 6409, 6410, 6411, 6412, 6413, 6414, 6415, 6416, 6417, 6418, + 6419, 6420, 6421, 6382, 6383, 6384, 6385, 6386, 6387, 6388, 6389, 6390, + 6391, 6392, 6393, 6394, 6395, 6396, 6397, 6398, 6399, 6400, 6401, 65535, + 65535, 65535, 65535, 7699, 7700, 7701, 7702, 7703, 7704, 7705, 7706, 7707, + 7708, 7709, 7710, 7711, 7712, 7713, 7714, 7715, 7716, 7717, 7718, 7719, + 7720, 7721, 7722, 7723, 7724, 7725, 7726, 7727, 7728, 7729, 7730, 7731, + 7732, 7733, 7734, 7735, 7736, 7737, 7738, 7739, 7740, 7741, 7742, 7743, + 7744, 7745, 7746, 7747, 7748, 7749, 7750, 7751, 7752, 7753, 7754, 7755, + 7756, 7757, 7758, 7759, 7760, 7761, 7762, 7763, 7764, 7765, 7766, 7767, + 7768, 7769, 7770, 7771, 7772, 7773, 7774, 65535, 65535, 65535, 65535, 7430, + 7431, 7432, 7433, 7434, 7435, 7436, 7437, 7438, 7439, 7440, 7441, 7442, + 7443, 7444, 7445, 7446, 7447, 7448, 7449, 7450, 7451, 7452, 7453, 7454, + 7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 7463, 7464, 7465, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 7466, 7467, 7468, 7469, 7470, 7471, 7472, 7473, 7474, 7475, + 7476, 7477, 7478, 7479, 7480, 65535, 65535, 65535, 7481, 7482, 7483, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6261, 6260, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 6263, 6262, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7484, 7485, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6259, 6258, 65535, 65535, 65535, 6255, 65535, + 65535, 6257, 6256, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7486, + 7487, 7488, 7489, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6254, 6253, 65535, 65535, 7490, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6241, 65535, + 6240, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23766, 65535, 65535, 23770, 65535, 65535, 65535, 23773, 65535, 65535, + 23774, 23779, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23780, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23793, 65535, + 65535, 23796, 65535, 65535, 65535, 23799, 65535, 65535, 65535, 65535, + 23801, 65535, 65535, 23802, 23803, 65535, 65535, 65535, 23807, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23817, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7673, 7674, 7675, 7676, 7677, 7678, 7679, 7680, 7681, 7682, 7683, + 7684, 65535, 65535, 65535, 65535, 6176, 6177, 6178, 6183, 65535, 6184, + 7637, 7685, 6195, 6196, 6197, 6198, 6199, 6200, 6201, 6202, 6205, 6206, + 7492, 6269, 6193, 6194, 6203, 6204, 65535, 65535, 65535, 65535, 65535, + 7493, 7494, 65535, 65535, 7600, 7601, 7602, 7603, 7604, 7605, 7606, 7607, + 7608, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7672, + 65535, 65535, 6746, 6747, 6748, 6749, 6750, 6751, 6752, 6753, 6754, 6755, + 6756, 6757, 6758, 6759, 6760, 6761, 6762, 6763, 6764, 6765, 6766, 6767, + 6768, 6769, 6770, 6771, 6772, 6773, 6774, 6775, 6776, 6777, 6778, 6779, + 6780, 6781, 6782, 6783, 6784, 6785, 6786, 6787, 6788, 6789, 6790, 6791, + 6792, 6793, 6794, 6795, 6796, 6797, 6798, 6799, 6800, 6801, 6802, 6803, + 6804, 6805, 6806, 6807, 6808, 6809, 6810, 6811, 6812, 6813, 6814, 6815, + 6816, 6817, 6818, 6819, 6820, 6821, 6822, 6823, 6824, 6825, 6826, 6827, + 6828, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7633, 7634, 7638, + 7639, 65535, 65535, 6936, 6937, 6938, 6939, 6940, 6941, 6942, 6943, 6944, + 6945, 6946, 6947, 6948, 6949, 6950, 6951, 6952, 6953, 6954, 6955, 6956, + 6957, 6958, 6959, 6960, 6961, 6962, 6963, 6964, 6965, 6966, 6967, 6968, + 6969, 6970, 6971, 6972, 6973, 6974, 6975, 6976, 6977, 6978, 6979, 6980, + 6981, 6982, 6983, 6984, 6985, 6986, 6987, 6988, 6989, 6990, 6991, 6992, + 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7002, 7003, 7004, + 7005, 7006, 7007, 7008, 7009, 7010, 7011, 7012, 7013, 7014, 7015, 7016, + 7017, 7018, 7019, 7020, 7021, 65535, 65535, 65535, 65535, 65535, 7632, + 7635, 7636, 65535, 65535, 65535, 65535, 65535, 65535, 7542, 7543, 7544, + 7545, 7546, 7547, 7548, 7549, 7550, 7551, 7552, 7553, 7554, 7555, 7556, + 7557, 7558, 7559, 7560, 7561, 7562, 7563, 7564, 7565, 7566, 7567, 7568, + 7569, 7570, 7571, 7572, 7573, 7574, 7575, 7576, 7577, 7578, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6434, + 6435, 6436, 6437, 6438, 6439, 6440, 6441, 6442, 6443, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7626, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7609, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7610, 7611, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 7612, 7613, 7614, 65535, 65535, + 7615, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 7616, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 7617, 65535, 65535, 7618, 7619, 65535, 65535, 7620, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23772, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23771, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23776, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23778, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23777, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23782, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23781, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23784, 23787, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23785, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23786, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23790, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23791, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23792, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23797, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23798, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23800, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23806, 65535, 65535, 65535, 65535, 23805, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23808, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23809, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 23811, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23810, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23813, 65535, 65535, 65535, 65535, 65535, 23814, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23815, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23816, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23818, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23819, 65535, 65535, 23820, 65535, 65535, 65535, 65535, + 23821, 23822, 65535, 23823, 23824, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23826, 65535, 65535, 65535, 23825, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23828, 23827, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23835, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23832, 23833, 23834, 23836, 23831, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23837, 23838, 23839, + 23840, 23841, 23842, 23843, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 23844, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15512, 10166, 0, 13268, 1, 2, 3, 14617, 16096, 13678, 13822, + 14949, 16627, 9432, 15750, 4, 16629, 9678, 5, 16443, 13445, 16632, 13997, + 6, 13475, 9306, 15506, 9837, 10176, 14186, 16634, 7, 8, 9, 10175, 10, + 12284, 15342, 11, 13780, 16638, 12, 10631, 15325, 18775, 16293, 13, 14, + 10420, 15, 9799, 16, 12312, 17, 16653, 18, 14607, 9979, 14735, 16332, 19, + 12151, 11742, 16640, 20, 21, 22, 12868, 23, 11720, 24, 16642, 12655, 15554, + 25, 16259, 14783, 16062, 11010, 10361, 12119, 26, 13230, 13065, 13434, 27, + 10787, 28, 9638, 15535, 29, 30, 16656, 11722, 13287, 15503, 14931, 14986, + 31, 32, 33, 34, 14038, 35, 36, 16657, 37, 38, 39, 40, 41, 42, 12527, 12495, + 43, 13658, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 13407, 54, 55, 56, 57, + 58, 59, 60, 12298, 61, 15747, 16144, 62, 13999, 10259, 16626, 15733, 11962, + 63, 15903, 11120, 16658, 14794, 11699, 64, 65, 16633, 66, 15334, 15114, 67, + 68, 69, 16654, 16894, 14621, 11901, 70, 11522, 10930, 15549, 9495, 10989, + 12847, 71, 14992, 11694, 14539, 12288, 72, 73, 74, 13450, 16896, 75, 16899, + 76, 77, 78, 79, 13628, 16698, 80, 81, 82, 15543, 13983, 13627, 16701, + 16699, 16663, 11581, 13250, 9675, 83, 16700, 11576, 11568, 84, 13637, 9836, + 85, 86, 12501, 87, 9459, 16483, 14008, 14246, 16099, 10567, 14956, 88, 89, + 90, 16873, 16705, 13405, 91, 16703, 92, 9875, 12333, 15537, 93, 94, 16702, + 95, 15524, 16704, 12674, 96, 97, 98, 15381, 99, 16302, 16707, 100, 16710, + 11399, 11364, 101, 102, 103, 13631, 104, 10416, 105, 10389, 106, 13288, + 107, 108, 109, 110, 111, 112, 113, 16713, 15518, 114, 115, 14798, 11336, + 10447, 10360, 15166, 116, 117, 118, 119, 120, 16303, 15712, 11194, 11180, + 16706, 121, 122, 13776, 14741, 9796, 123, 16708, 124, 13818, 16711, 12500, + 16712, 125, 126, 14742, 16714, 127, 128, 129, 9419, 10767, 130, 16818, 131, + 9098, 132, 12325, 133, 13851, 134, 14192, 135, 14193, 16819, 136, 137, 138, + 139, 140, 10047, 141, 142, 9986, 143, 144, 145, 146, 147, 148, 14752, + 10020, 16436, 16519, 15726, 149, 14414, 150, 10971, 151, 16817, 16875, + 15739, 16718, 10435, 16522, 16719, 16715, 16816, 12892, 152, 153, 15697, + 16709, 16876, 154, 16716, 155, 13084, 156, 157, 12113, 158, 159, 15375, + 9084, 160, 161, 11354, 16821, 162, 16820, 163, 164, 165, 166, 16827, 16829, + 167, 16826, 13990, 168, 169, 170, 16824, 16267, 171, 172, 173, 9657, 16823, + 174, 12158, 175, 14009, 176, 16825, 177, 16822, 178, 179, 16831, 180, 181, + 10182, 182, 183, 184, 10744, 185, 15517, 186, 187, 14947, 188, 189, 12479, + 190, 11531, 16131, 9469, 13435, 11950, 16828, 191, 16830, 192, 14799, + 11003, 193, 194, 195, 196, 197, 13449, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 9282, 207, 208, 209, 9842, 10242, 16835, 210, 211, 212, 213, + 11876, 214, 215, 216, 16877, 13441, 12159, 16839, 217, 218, 219, 220, 221, + 14210, 10448, 222, 16836, 223, 16838, 9218, 15740, 16840, 224, 15142, 225, + 16837, 226, 227, 16832, 228, 16833, 12264, 16834, 229, 230, 11388, 15167, + 10554, 231, 11752, 232, 16844, 233, 234, 235, 236, 16841, 237, 9044, 238, + 239, 240, 16849, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, + 252, 253, 16851, 9237, 254, 16846, 255, 256, 10000, 257, 11768, 258, 259, + 260, 14385, 11007, 15533, 261, 16850, 262, 263, 11567, 264, 9606, 265, 266, + 267, 16852, 11760, 268, 16853, 16842, 12888, 269, 16845, 16848, 16847, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 16069, 281, 16266, 282, + 13462, 283, 284, 285, 286, 16855, 287, 288, 289, 11362, 16857, 290, 291, + 292, 16843, 293, 16858, 13216, 294, 295, 296, 297, 298, 16856, 299, 300, + 301, 302, 16521, 303, 14538, 304, 305, 306, 307, 308, 309, 310, 311, 11496, + 312, 313, 314, 315, 316, 317, 16859, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 13043, 14556, 327, 328, 329, 16860, 330, 331, 16854, 9600, 11969, + 332, 333, 334, 335, 10566, 336, 337, 12157, 338, 339, 340, 341, 9113, 342, + 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 360, 361, 362, 9871, 363, 16861, 364, 16862, 9787, 16863, 365, + 366, 9848, 367, 368, 369, 370, 371, 9058, 372, 373, 374, 375, 376, 377, + 378, 16864, 13796, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 14996, 398, 399, 400, 401, 402, + 403, 16865, 404, 405, 406, 12292, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 16869, 13789, 418, 419, 420, 421, 16868, 16867, 16870, 422, + 423, 424, 425, 14214, 426, 11504, 427, 428, 429, 430, 431, 13212, 432, 433, + 434, 435, 436, 437, 438, 439, 440, 441, 16866, 16871, 442, 443, 444, 16872, + 445, 446, 447, 448, 449, 450, 13654, 451, 452, 453, 454, 455, 456, 457, + 458, 459, 460, 461, 462, 463, 464, 12125, 465, 466, 467, 468, 469, 470, + 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, + 486, 487, 488, 489, 490, 491, 492, 493, 10254, 16628, 15907, 494, 15875, + 15159, 9663, 16110, 495, 14955, 10801, 496, 11918, 497, 12701, 498, 499, + 500, 10215, 501, 502, 14570, 16893, 16895, 503, 504, 505, 9994, 506, 10186, + 507, 508, 509, 510, 511, 11689, 512, 513, 13660, 514, 515, 13596, 516, 517, + 9068, 10746, 12344, 16881, 518, 12093, 10753, 519, 10791, 15148, 9303, + 13273, 11748, 10043, 16475, 520, 15383, 11375, 14027, 521, 522, 11334, + 16885, 16696, 523, 524, 12883, 525, 526, 10597, 13614, 527, 528, 9470, + 15922, 529, 530, 531, 532, 12651, 533, 534, 12700, 17007, 13648, 535, + 15125, 536, 11777, 13024, 537, 538, 539, 10793, 540, 17008, 541, 15874, + 17009, 542, 543, 544, 545, 546, 16906, 10177, 547, 548, 10430, 9304, 16907, + 9664, 11771, 549, 11961, 15502, 12133, 550, 551, 552, 10184, 16909, 16908, + 553, 554, 11712, 555, 556, 557, 13269, 558, 16463, 17006, 559, 12280, 560, + 10057, 12327, 561, 562, 11390, 563, 9838, 564, 565, 566, 567, 568, 569, + 570, 571, 572, 12316, 573, 12918, 574, 575, 11329, 10373, 576, 577, 10434, + 578, 579, 580, 581, 582, 583, 16891, 584, 13235, 585, 11888, 11158, 586, + 587, 10017, 588, 17236, 15160, 589, 14560, 9053, 9681, 11202, 17237, 10940, + 590, 15933, 9997, 10058, 16679, 13633, 591, 592, 10409, 13443, 16680, 593, + 11890, 594, 595, 17222, 16681, 596, 597, 15149, 11129, 598, 599, 600, + 20265, 12303, 12340, 15947, 10598, 9805, 601, 9680, 602, 603, 13805, 604, + 605, 606, 13063, 607, 608, 609, 13072, 12156, 610, 9295, 611, 16682, 10781, + 612, 10004, 613, 614, 16683, 615, 616, 16283, 14157, 13600, 13793, 9829, + 11919, 617, 10819, 618, 16684, 16685, 10236, 11338, 14419, 619, 620, 621, + 622, 623, 624, 15002, 625, 16686, 13411, 626, 627, 10783, 11498, 628, 629, + 14407, 630, 13247, 631, 632, 633, 634, 635, 16689, 636, 16687, 637, 638, + 16688, 639, 640, 641, 9119, 642, 11756, 643, 13968, 11389, 644, 645, 646, + 647, 10562, 648, 649, 10623, 650, 651, 652, 653, 654, 655, 656, 657, 658, + 659, 16691, 660, 11538, 661, 16693, 16692, 662, 663, 664, 665, 666, 13107, + 667, 668, 669, 670, 671, 672, 673, 16694, 674, 675, 16695, 676, 677, 678, + 679, 680, 681, 682, 12261, 683, 13601, 9101, 10741, 11356, 14806, 17224, + 12306, 684, 685, 686, 687, 10180, 16335, 13027, 11552, 17225, 17226, 688, + 689, 690, 12153, 11687, 12110, 691, 692, 693, 694, 695, 696, 697, 698, 699, + 700, 17227, 14003, 701, 702, 703, 9415, 704, 705, 706, 15709, 707, 12702, + 708, 15306, 709, 710, 711, 712, 17229, 713, 12118, 714, 715, 716, 17230, + 717, 11892, 718, 719, 720, 721, 722, 723, 12853, 724, 725, 726, 727, 13453, + 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 17231, 739, 740, + 741, 742, 743, 744, 745, 746, 16887, 13830, 747, 748, 749, 10755, 14805, + 15905, 750, 751, 752, 753, 9117, 9835, 754, 15162, 755, 756, 757, 758, + 16888, 759, 17808, 16890, 760, 761, 762, 763, 16641, 11130, 9232, 764, + 9650, 16671, 765, 766, 15914, 767, 768, 11514, 11954, 769, 14942, 770, 771, + 16673, 772, 773, 774, 10398, 775, 776, 777, 16674, 778, 779, 780, 781, 782, + 783, 784, 785, 786, 787, 13210, 13483, 15514, 788, 789, 16675, 12893, 790, + 13979, 791, 13402, 792, 16631, 793, 13868, 14796, 11175, 9100, 794, 795, + 796, 11125, 15118, 797, 9231, 16503, 16466, 798, 9980, 12529, 12872, 799, + 800, 9414, 801, 9428, 802, 9284, 17973, 16083, 11883, 12457, 16678, 12462, + 803, 16677, 14777, 804, 17069, 805, 14757, 806, 807, 16645, 12649, 15676, + 14728, 808, 11325, 13605, 12494, 809, 11762, 15127, 810, 17070, 811, 812, + 813, 814, 13463, 815, 816, 9602, 817, 10247, 14437, 12155, 818, 819, 12152, + 820, 15320, 15360, 16664, 821, 822, 823, 824, 825, 826, 827, 9467, 828, + 829, 12134, 830, 11006, 831, 832, 16665, 833, 15878, 834, 835, 14980, + 16666, 836, 16667, 14950, 837, 9683, 11724, 838, 839, 840, 841, 16668, 842, + 843, 844, 845, 846, 847, 848, 17239, 849, 850, 851, 852, 13590, 853, 854, + 855, 14971, 856, 13679, 9451, 857, 858, 859, 860, 861, 15729, 9475, 11321, + 15724, 14166, 10375, 862, 863, 864, 10357, 865, 866, 14034, 867, 13586, + 14025, 9283, 15185, 868, 13064, 869, 870, 871, 17232, 10069, 872, 873, + 11933, 10772, 11753, 12332, 874, 17977, 17976, 16272, 11543, 16112, 9065, + 10168, 11916, 14353, 17974, 13988, 15725, 875, 16672, 15507, 10962, 14185, + 14375, 876, 17978, 10055, 17975, 877, 878, 879, 15760, 880, 9647, 10632, + 881, 17981, 882, 10972, 11315, 10060, 883, 14547, 12726, 11008, 12149, + 14569, 14997, 17979, 14952, 884, 12477, 17980, 12525, 885, 886, 887, 11778, + 888, 12318, 14579, 15572, 10400, 17988, 889, 17991, 890, 891, 10436, 9066, + 10219, 10407, 892, 10937, 14438, 11927, 14172, 13289, 893, 16253, 17992, + 894, 14791, 9614, 895, 896, 14817, 9806, 897, 14764, 11005, 898, 14790, + 899, 15324, 900, 901, 17987, 902, 903, 9869, 904, 9637, 905, 10615, 17982, + 906, 907, 908, 909, 12862, 910, 17983, 17984, 17985, 13042, 17986, 17989, + 15882, 17990, 911, 13421, 14781, 912, 913, 914, 915, 916, 12881, 917, + 17997, 918, 18002, 919, 16305, 920, 921, 922, 923, 924, 925, 926, 927, + 17996, 18013, 14747, 928, 10964, 18001, 17995, 13077, 929, 930, 13850, + 11009, 12727, 931, 932, 11740, 933, 17993, 934, 18000, 935, 13071, 936, + 937, 938, 939, 16061, 10970, 940, 11729, 15704, 10577, 941, 16313, 942, + 17994, 10765, 11882, 943, 944, 12347, 17998, 17999, 945, 18003, 946, 947, + 948, 949, 950, 18014, 18024, 951, 18010, 18009, 16476, 18022, 18023, 19170, + 15492, 18005, 952, 11884, 953, 15924, 954, 11915, 18007, 955, 956, 957, + 14959, 958, 959, 18016, 960, 15337, 961, 18017, 9032, 13228, 18006, 962, + 10994, 963, 10228, 14594, 10829, 15918, 964, 965, 18018, 14991, 9030, + 18026, 18004, 15333, 18008, 18011, 18012, 18015, 966, 11124, 967, 18019, + 18020, 968, 18021, 18025, 18027, 15695, 969, 970, 971, 972, 973, 10616, + 13037, 18029, 13833, 12263, 12861, 974, 975, 11937, 15003, 976, 977, 978, + 16115, 18033, 979, 980, 981, 982, 983, 984, 9429, 985, 10988, 18031, 986, + 17228, 987, 15363, 988, 989, 990, 991, 14239, 9814, 992, 9031, 993, 994, + 995, 996, 997, 18036, 14383, 18037, 998, 999, 18032, 1000, 1001, 1002, + 1003, 1004, 1005, 18028, 1006, 1007, 1008, 1009, 18030, 1010, 18034, 18035, + 11144, 1011, 1012, 18038, 1013, 1014, 18039, 1015, 11118, 1016, 14024, + 14733, 18152, 9605, 1017, 18151, 1018, 1019, 1020, 18146, 1021, 1022, 1023, + 1024, 18049, 1025, 14592, 18047, 1026, 18045, 1027, 11923, 16471, 1028, + 13819, 1029, 1030, 18043, 9026, 1031, 1032, 1033, 1034, 1035, 18048, 1036, + 1037, 1038, 1039, 18046, 18147, 1040, 1041, 1042, 1043, 1044, 18153, 1045, + 1046, 1047, 1048, 10395, 1049, 1050, 13206, 13797, 12083, 18040, 1051, + 1052, 13045, 1053, 16661, 18044, 12911, 1054, 1055, 1056, 1057, 1058, 1059, + 18148, 18149, 18150, 15110, 1060, 1061, 18165, 14413, 1062, 18162, 1063, + 11881, 18160, 14750, 18156, 13813, 1064, 1065, 12079, 18159, 11002, 10941, + 18154, 1066, 1067, 1068, 18041, 1069, 18164, 1070, 1071, 18169, 1072, 1073, + 1074, 9798, 18170, 1075, 1076, 14933, 10965, 1077, 18161, 1078, 1079, 1080, + 1081, 1082, 1083, 1084, 15195, 1085, 1086, 1087, 1088, 1089, 1090, 1091, + 1092, 1093, 18157, 1094, 15956, 1095, 18042, 1096, 13086, 1097, 18158, + 1098, 15762, 1099, 18167, 18168, 1100, 1101, 1102, 1103, 1104, 18181, + 15170, 1105, 1106, 1107, 18173, 1108, 1109, 18186, 18187, 1110, 1111, 1112, + 18175, 18155, 13779, 18178, 1113, 18163, 1114, 1115, 1116, 1117, 1118, + 14005, 18180, 1119, 18166, 1120, 14768, 1121, 14190, 18190, 18183, 18179, + 1122, 18188, 1123, 18171, 18176, 18177, 1124, 1125, 18182, 1126, 1127, + 18184, 18185, 1128, 18189, 1129, 18172, 1130, 1131, 1132, 1133, 1134, + 14207, 18198, 1135, 18199, 18195, 1136, 1137, 1138, 1139, 1140, 1141, + 18193, 11351, 1142, 1143, 18194, 1144, 10579, 16662, 1145, 1146, 1147, + 1148, 1149, 1150, 1151, 1152, 15179, 1153, 1154, 12524, 1155, 1156, 18192, + 18174, 1157, 1158, 1159, 18197, 18196, 1160, 1161, 18200, 1162, 1163, 1164, + 1165, 18205, 18201, 1166, 1167, 1168, 16331, 9611, 1169, 16511, 1170, + 14182, 1171, 1172, 18203, 1173, 14816, 1174, 1175, 1176, 10982, 1177, 1178, + 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 18210, 18206, + 15498, 1189, 1190, 1191, 1192, 1193, 18211, 1194, 1195, 18204, 18202, + 18208, 1196, 1197, 18209, 1198, 1199, 1200, 1201, 1202, 18207, 1203, 18213, + 1204, 1205, 1206, 13292, 16637, 15940, 18215, 14006, 1207, 1208, 1209, + 1210, 18214, 1211, 1212, 1213, 1214, 10578, 1215, 1216, 1217, 1218, 18216, + 18217, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 18218, 18212, 1227, + 1228, 1229, 1230, 1231, 1232, 1233, 10956, 14416, 1234, 1235, 1236, 18219, + 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, + 1249, 1250, 1251, 15004, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, + 1260, 1261, 1262, 18220, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 13619, + 1270, 1271, 1272, 1273, 11527, 1274, 1275, 1276, 1277, 1278, 1279, 1280, + 1281, 1282, 1283, 1284, 1285, 1286, 12875, 1287, 1288, 1289, 1290, 1291, + 1292, 1293, 1294, 1295, 18221, 1296, 1297, 18222, 1298, 1299, 13479, 14191, + 1300, 18223, 11171, 16647, 15567, 18224, 14572, 1301, 10223, 1302, 1303, + 1304, 1305, 1306, 1307, 18226, 1308, 15881, 1309, 1310, 12072, 9834, 1311, + 1312, 14732, 18225, 1313, 1314, 1315, 18227, 10779, 1316, 1317, 10825, + 14563, 18228, 1318, 1319, 1320, 13257, 18229, 1321, 15883, 1322, 13591, + 18231, 18230, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, + 1333, 1334, 1335, 1336, 1337, 1338, 1339, 18232, 1340, 1341, 14568, 1342, + 1343, 1344, 13970, 1345, 1346, 1347, 1348, 15923, 17250, 17252, 1349, + 17251, 10806, 17255, 17256, 10031, 1350, 1351, 17253, 1352, 1353, 1354, + 1355, 1356, 17254, 9596, 17258, 1357, 1358, 11203, 1359, 16268, 1360, + 17259, 1361, 1362, 1363, 1364, 11774, 1365, 1366, 10382, 1367, 17243, + 14359, 11893, 11136, 16523, 11926, 1368, 1369, 1370, 1371, 1372, 11948, + 1373, 1374, 11370, 14364, 17257, 9076, 14800, 10411, 16460, 13239, 1375, + 1376, 12069, 1377, 14370, 1378, 17266, 17260, 13231, 17262, 1379, 17267, + 1380, 13102, 1381, 1382, 1383, 17269, 1384, 1385, 17268, 11907, 1386, 1387, + 1388, 17265, 17264, 1389, 1390, 1391, 1392, 1393, 9810, 12077, 12447, + 17261, 17263, 1394, 1395, 1396, 1397, 15150, 17272, 1398, 1399, 1400, 1401, + 1402, 12126, 17277, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 10231, 1410, + 1411, 1412, 1413, 17278, 17245, 10759, 15876, 17271, 1414, 11924, 17275, + 1415, 17244, 1416, 10045, 1417, 17270, 11944, 1418, 1419, 1420, 17273, + 1421, 17276, 1422, 1423, 1424, 17284, 1425, 1426, 1427, 1428, 1429, 1430, + 1431, 1432, 1433, 10736, 9028, 1434, 1435, 1436, 1437, 1438, 1439, 1440, + 12526, 1441, 1442, 9634, 17274, 1443, 1444, 17283, 1445, 13255, 17279, + 1446, 1447, 17280, 17282, 17281, 1448, 1449, 17289, 1450, 15757, 9431, + 1451, 1452, 1453, 17288, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, + 17389, 1462, 17286, 1463, 1464, 1465, 1466, 17285, 1467, 1468, 1469, 17287, + 13079, 11204, 1470, 1471, 17388, 1472, 1473, 17390, 1474, 14380, 1475, + 1476, 1477, 10214, 17607, 1478, 1479, 1480, 17386, 1481, 17387, 1482, 1483, + 1484, 13416, 1485, 1486, 1487, 10238, 1488, 1489, 1490, 17392, 1491, 1492, + 1493, 1494, 17391, 1495, 17394, 9219, 1496, 1497, 10019, 1498, 1499, 1500, + 1501, 1502, 11891, 1503, 1504, 1505, 1506, 1507, 15358, 1508, 1509, 1510, + 1511, 10199, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, + 1522, 1523, 1524, 1525, 17393, 1526, 1527, 1528, 1529, 1530, 1531, 1532, + 14245, 20318, 1533, 1534, 1535, 14215, 1536, 1537, 14249, 1538, 1539, 1540, + 14378, 1541, 1542, 1543, 1544, 1545, 13676, 1546, 1547, 1548, 1549, 1550, + 1551, 17395, 1552, 1553, 1554, 1555, 1556, 14423, 17396, 1557, 1558, 1559, + 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, + 1572, 1573, 17246, 1574, 17400, 17397, 1575, 11704, 1576, 14056, 1577, + 1578, 1579, 17398, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 13817, + 12850, 1588, 1589, 1590, 1591, 1592, 13424, 17399, 1593, 1594, 1595, 15951, + 15175, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 12836, 10218, 1604, + 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, + 1617, 1618, 1619, 1620, 1621, 17247, 1622, 1623, 1624, 1625, 9273, 1626, + 1627, 1628, 17248, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, + 1638, 1639, 17249, 1640, 1641, 1642, 10955, 1643, 1644, 1645, 1646, 1647, + 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 13617, 1657, 1658, + 1659, 1660, 1661, 1662, 13996, 13626, 1663, 16454, 1664, 13864, 1665, 1666, + 11914, 1667, 1668, 11013, 1669, 1670, 15513, 1671, 1672, 1673, 1674, 1675, + 1676, 1677, 1678, 18551, 1679, 9791, 1680, 1681, 9239, 1682, 1683, 1684, + 1685, 1686, 10565, 1687, 14951, 1688, 1689, 1690, 1691, 16886, 14921, + 14601, 1692, 1693, 16892, 10229, 1694, 15510, 1695, 1696, 10762, 1697, + 1698, 1699, 1700, 18550, 18548, 1701, 9868, 1702, 14421, 14356, 10437, + 1703, 16643, 15370, 10952, 1704, 13972, 1705, 1706, 14558, 1707, 1708, + 15521, 11943, 11353, 10230, 1709, 17802, 1710, 1711, 1712, 1713, 17803, + 17223, 1714, 15352, 1715, 1716, 13275, 12871, 10433, 1717, 10415, 1718, + 1719, 11967, 16499, 1720, 13290, 1721, 1722, 9243, 17805, 11512, 14400, + 17807, 1723, 17806, 1724, 1725, 1726, 1727, 1728, 10051, 1729, 13836, 1730, + 1731, 9059, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, + 1742, 1743, 1744, 13029, 13026, 1745, 12869, 1746, 11378, 14248, 1747, + 1748, 1749, 10960, 1750, 1751, 1752, 19184, 13656, 19185, 14628, 1753, + 16452, 10575, 12517, 1754, 13634, 1755, 1756, 19186, 1757, 1758, 1759, + 1760, 10207, 11348, 1761, 1762, 15388, 19286, 1763, 12713, 1764, 1765, + 1766, 1767, 19289, 1768, 1769, 1770, 1771, 19189, 19290, 14590, 1772, 1773, + 10388, 19187, 19188, 19288, 1774, 1775, 12886, 19293, 1776, 1777, 19292, + 1778, 1779, 1780, 1781, 1782, 1783, 12670, 1784, 13267, 1785, 1786, 19295, + 1787, 1788, 1789, 1790, 1791, 1792, 1793, 12848, 1794, 1795, 1796, 19287, + 13993, 1797, 1798, 1799, 1800, 11562, 10770, 19291, 15158, 14740, 1801, + 1802, 19294, 19301, 1803, 15491, 1804, 11505, 19298, 1805, 1806, 1807, + 1808, 1809, 19300, 1810, 12114, 1811, 1812, 15529, 1813, 1814, 1815, 11312, + 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, + 19302, 1828, 15571, 1829, 1830, 1831, 16478, 1832, 14629, 1833, 14597, + 12451, 19296, 19297, 11526, 19299, 19304, 1834, 1835, 19303, 1836, 1837, + 1838, 1839, 19307, 1840, 19309, 1841, 1842, 1843, 1844, 12904, 1845, 1846, + 1847, 12865, 1848, 1849, 11759, 13854, 1850, 1851, 19308, 1852, 10245, + 1853, 1854, 1855, 12703, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 15748, + 19305, 1863, 19306, 1864, 13587, 1865, 1866, 1867, 1868, 1869, 19314, 1870, + 1871, 1872, 19310, 1873, 1874, 1875, 1876, 1877, 13242, 1878, 1879, 14616, + 19312, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 19313, + 1890, 1891, 1892, 1893, 11188, 1894, 1895, 1896, 1897, 1898, 1899, 1900, + 19315, 1901, 1902, 1903, 1904, 19311, 1905, 1906, 12088, 1907, 1908, 1909, + 1910, 1911, 1912, 1913, 1914, 1915, 15679, 19316, 13859, 19320, 1916, 1917, + 19321, 1918, 1919, 1920, 1921, 15191, 1922, 1923, 1924, 1925, 1926, 1927, + 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, + 12664, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 12671, 19319, 1947, 1948, + 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, + 19318, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 19324, 14932, 1968, 20319, + 1969, 1970, 19327, 1971, 1972, 1973, 1974, 1975, 19322, 1976, 1977, 11367, + 13784, 1978, 1979, 1980, 1981, 1982, 1983, 11326, 1984, 1985, 14966, 1986, + 1987, 1988, 1989, 1990, 19325, 1991, 19326, 1992, 19331, 1993, 19333, 1994, + 1995, 1996, 19334, 1997, 1998, 1999, 19328, 10028, 2000, 19329, 2001, 2002, + 19332, 2003, 2004, 12884, 2005, 19323, 2006, 2007, 2008, 2009, 2010, 19330, + 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, + 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 19335, + 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, + 19337, 19336, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, + 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, + 2068, 2069, 2070, 2071, 19338, 2072, 16903, 2073, 2074, 19339, 2075, 2076, + 2077, 2078, 2079, 2080, 2081, 2082, 19340, 2083, 2084, 2085, 2086, 2087, + 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 16486, 19346, + 2098, 19347, 11930, 15913, 2099, 16489, 9855, 14234, 19343, 16660, 16481, + 15107, 2100, 12682, 2101, 2102, 19348, 11335, 10769, 19344, 15302, 2103, + 2104, 10927, 12492, 2105, 16636, 2106, 2107, 2108, 14040, 19173, 2109, + 19345, 2110, 10440, 2111, 2112, 2113, 2114, 13655, 2115, 2116, 12910, 2117, + 2118, 19113, 12919, 2119, 14247, 19114, 16067, 2120, 15753, 14021, 9043, + 2121, 14201, 14609, 2122, 2123, 10999, 2124, 2125, 2126, 19116, 2127, + 19115, 2128, 16493, 10792, 16315, 10173, 14615, 15528, 9221, 13986, 2129, + 9667, 13858, 11920, 15196, 14015, 19117, 11149, 2130, 2131, 2132, 14975, + 10747, 2133, 2134, 2135, 2136, 15920, 2137, 2138, 10931, 15366, 15007, + 11355, 2139, 19118, 13646, 2140, 2141, 2142, 11952, 9301, 14217, 2143, + 2144, 11342, 2145, 11341, 15575, 12695, 11935, 2146, 2147, 2148, 2149, + 10572, 2150, 2151, 2152, 12669, 2153, 10939, 15867, 2154, 2155, 2156, 2157, + 2158, 2159, 2160, 2161, 2162, 13457, 12840, 9481, 2163, 10784, 2164, 2165, + 19122, 12295, 2166, 2167, 16070, 2168, 2169, 2170, 2171, 2172, 19123, 2173, + 19125, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 9856, 10217, 14189, 15311, + 10003, 2181, 2182, 14022, 2183, 10421, 2184, 2185, 13843, 2186, 11506, + 2187, 2188, 14755, 16515, 2189, 2190, 2191, 2192, 15106, 2193, 13832, 2194, + 2195, 10256, 19341, 11371, 2196, 9625, 2197, 13823, 2198, 19342, 9597, + 2199, 2200, 2201, 2202, 17809, 2203, 15715, 17810, 2204, 15487, 2205, 2206, + 2207, 2208, 17811, 2209, 2210, 2211, 2212, 11730, 2213, 2214, 17812, 2215, + 2216, 2217, 13977, 15577, 9658, 19169, 12890, 11686, 14743, 12907, 11739, + 13213, 9472, 2218, 2219, 11736, 2220, 2221, 13487, 14420, 11571, 14786, + 2222, 2223, 13991, 13238, 19171, 15133, 2224, 2225, 2226, 16080, 2227, + 2228, 2229, 19172, 2230, 2231, 2232, 2233, 14049, 2234, 14567, 12482, 2235, + 19174, 2236, 12481, 19175, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 19183, + 14580, 2244, 13804, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 15542, 18343, + 2252, 2253, 2254, 2255, 15751, 2256, 14229, 13286, 2257, 2258, 2259, 2260, + 2261, 18347, 2262, 2263, 2264, 18342, 18344, 2265, 2266, 18345, 18350, + 2267, 2268, 9482, 2269, 18346, 10603, 18348, 18349, 18351, 10001, 18352, + 2270, 2271, 2272, 2273, 2274, 18354, 18359, 2275, 2276, 2277, 2278, 2279, + 15345, 2280, 18357, 18356, 12330, 2281, 2282, 2283, 18358, 2284, 15897, + 2285, 18353, 2286, 18361, 9047, 2287, 2288, 2289, 2290, 18355, 2291, 11964, + 2292, 18360, 2293, 2294, 18362, 2295, 2296, 2297, 2298, 2299, 2300, 18365, + 2301, 2302, 2303, 2304, 2305, 2306, 18363, 2307, 2308, 2309, 2310, 2311, + 2312, 16282, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 14946, 2320, 2321, + 18364, 18366, 12490, 2322, 10240, 2323, 15763, 2324, 2325, 13440, 2326, + 2327, 10424, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, + 11779, 2338, 2339, 2340, 2341, 2342, 2343, 18367, 18368, 2344, 2345, 18374, + 9666, 2346, 2347, 2348, 2349, 2350, 2351, 13278, 2352, 2353, 2354, 2355, + 2356, 9847, 2357, 15329, 2358, 2359, 2360, 2361, 18375, 2362, 2363, 18373, + 2364, 2365, 2366, 2367, 2368, 18372, 2369, 18370, 18369, 2370, 9247, 2371, + 2372, 2373, 16079, 18371, 2374, 2375, 2376, 2377, 2378, 18378, 2379, 2380, + 2381, 2382, 2383, 2384, 2385, 2386, 18379, 18377, 2387, 2388, 2389, 2390, + 2391, 2392, 2393, 2394, 21085, 2395, 2396, 18386, 18385, 13417, 2397, 2398, + 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 18376, 2408, 2409, + 18381, 2410, 18383, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, + 2420, 2421, 18387, 2422, 18384, 18380, 2423, 2424, 18382, 2425, 2426, 2427, + 2428, 18388, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, + 2439, 2440, 2441, 18389, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, + 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, + 2462, 2463, 18390, 2464, 2465, 2466, 18391, 2467, 2468, 2469, 2470, 2471, + 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, + 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 18393, 2492, 2493, 2494, + 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 18394, 2505, + 2506, 2507, 2508, 2509, 2510, 2511, 14726, 2512, 2513, 2514, 2515, 2516, + 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 19536, 2525, 9793, 16306, + 2526, 2527, 15313, 9613, 2528, 2529, 10739, 16518, 13436, 11747, 10749, + 2530, 14780, 2531, 2532, 9483, 17242, 2533, 11331, 15534, 14195, 9070, + 2534, 2535, 14994, 2536, 2537, 2538, 2539, 2540, 16882, 11572, 2541, 2542, + 9265, 14013, 9433, 2543, 14162, 10366, 2544, 13971, 2545, 2546, 2547, + 14918, 2548, 2549, 18233, 16097, 18236, 2550, 2551, 18235, 13048, 14436, + 2552, 12272, 18234, 16312, 9420, 16281, 10034, 2553, 2554, 2555, 2556, + 2557, 2558, 2559, 2560, 9873, 16246, 2561, 2562, 2563, 2564, 2565, 14930, + 9104, 2566, 2567, 18237, 2568, 2569, 2570, 2571, 2572, 18336, 9598, 2573, + 2574, 18238, 18239, 12652, 2575, 2576, 2577, 2578, 12696, 2579, 18337, + 10444, 2580, 2581, 2582, 2583, 2584, 2585, 11162, 2586, 2587, 2588, 2589, + 2590, 2591, 2592, 18338, 12852, 2593, 2594, 2595, 2596, 2597, 18339, 2598, + 2599, 18340, 2600, 2601, 18341, 9802, 2602, 2603, 2604, 2605, 2606, 2607, + 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 10586, 13234, 12899, + 2617, 9407, 2618, 15155, 2619, 19534, 11150, 15730, 15711, 2620, 10802, + 18572, 2621, 2622, 2623, 16450, 2624, 13471, 9266, 2625, 2626, 9803, 18574, + 2627, 2628, 2629, 15187, 12459, 18573, 2630, 11941, 15681, 10030, 18575, + 10049, 2631, 12712, 10638, 2632, 10559, 2633, 13066, 10402, 18577, 2634, + 2635, 2636, 2637, 18576, 10205, 16524, 2638, 2639, 2640, 2641, 2642, 14540, + 2643, 2644, 2645, 2646, 2647, 18581, 2648, 18579, 14057, 11896, 15700, + 18578, 2649, 2650, 2651, 2652, 18580, 2653, 2654, 2655, 2656, 2657, 2658, + 2659, 2660, 2661, 2662, 12269, 12105, 2663, 2664, 2665, 2666, 2667, 2668, + 18584, 18583, 12075, 2669, 2670, 12301, 2671, 2672, 2673, 2674, 18585, + 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, + 18586, 2687, 18587, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, + 17235, 2697, 15346, 14537, 2698, 2699, 11503, 2700, 2701, 2702, 17800, + 16630, 11885, 17240, 15561, 13295, 13025, 2703, 2704, 2705, 17801, 2706, + 9270, 17969, 2707, 2708, 2709, 13994, 2710, 17972, 2711, 10748, 2712, + 15578, 2713, 10550, 11000, 2714, 2715, 9653, 2716, 2717, 2718, 10035, + 16092, 2719, 2720, 2721, 2722, 12689, 14965, 11116, 2723, 19178, 19177, + 2724, 2725, 19179, 2726, 14603, 2727, 13670, 2728, 2729, 2730, 2731, 2732, + 2733, 2734, 9990, 13426, 2735, 19181, 2736, 2737, 2738, 20441, 2739, 2740, + 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, + 2753, 19165, 2754, 10808, 9992, 2755, 12473, 19167, 19166, 19168, 2756, + 2757, 2758, 2759, 15530, 2760, 2761, 2762, 18409, 15151, 2763, 14549, 2764, + 15364, 2765, 2766, 9447, 9290, 2767, 9297, 13092, 2768, 2769, 16090, 15691, + 2770, 18395, 2771, 2772, 2773, 18396, 2774, 15544, 2775, 9620, 9258, 2776, + 2777, 2778, 14624, 16142, 18397, 2779, 11707, 9878, 2780, 18398, 10985, + 18399, 11133, 12486, 18400, 2781, 2782, 2783, 15181, 2784, 14564, 2785, + 2786, 18401, 2787, 10010, 13054, 18402, 2788, 2789, 18403, 2790, 2791, + 2792, 2793, 15764, 2794, 2795, 2796, 2797, 2798, 2799, 18404, 2800, 15308, + 2801, 2802, 18405, 14727, 2803, 2804, 2805, 2806, 2807, 2808, 18406, 2809, + 10009, 2810, 2811, 2812, 2813, 18407, 11168, 2814, 2815, 2816, 2817, 2818, + 15141, 18589, 9271, 15553, 2819, 2820, 18590, 2821, 2822, 11346, 13629, + 2823, 18592, 20519, 20518, 17970, 2824, 2825, 2826, 18591, 16275, 14627, + 12641, 2827, 2828, 2829, 18750, 2830, 2831, 16295, 18596, 2832, 2833, + 18597, 2834, 2835, 15714, 2836, 2837, 18601, 11951, 2838, 18602, 18594, + 2839, 2840, 9627, 2841, 2842, 2843, 12903, 2844, 2845, 18603, 2846, 2847, + 15140, 2848, 11011, 18598, 10417, 11134, 14357, 14198, 18593, 18595, 18599, + 18600, 2849, 2850, 2851, 18612, 2852, 2853, 18609, 15950, 18608, 2854, + 2855, 13028, 2856, 16145, 13049, 9437, 2857, 2858, 18604, 2859, 18607, + 12270, 14183, 2860, 2861, 9976, 18614, 2862, 2863, 2864, 11322, 18606, + 15157, 15890, 18610, 10789, 18611, 2865, 2866, 2867, 13446, 2868, 2869, + 2870, 2871, 2872, 18605, 2873, 2874, 2875, 2876, 2877, 16495, 20616, 2878, + 2879, 18613, 2880, 20620, 18619, 14014, 2881, 2882, 2883, 2884, 2885, 2886, + 2887, 12276, 2888, 11163, 2889, 2890, 11929, 2891, 10992, 2892, 2893, + 14156, 2894, 2895, 2896, 20621, 20618, 2897, 2898, 20617, 2899, 2900, 2901, + 2902, 11169, 20622, 15189, 2903, 2904, 20619, 10987, 10252, 18716, 10183, + 14426, 10742, 2905, 14917, 13396, 2906, 2907, 11925, 2908, 2909, 10246, + 2910, 18615, 18616, 18618, 18617, 12878, 18717, 2911, 15708, 2912, 2913, + 2914, 18722, 13431, 2915, 2916, 2917, 2918, 14919, 2919, 2920, 18724, + 10948, 2921, 2922, 2923, 2924, 18723, 2925, 11173, 2926, 18718, 2927, 2928, + 2929, 18719, 18725, 2930, 18721, 2931, 14807, 15713, 2932, 2933, 11143, + 2934, 2935, 15900, 2936, 12915, 2937, 2938, 20623, 15197, 18720, 2939, + 12720, 2940, 18728, 9230, 2941, 18733, 2942, 2943, 2944, 11339, 2945, 2946, + 18727, 10006, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 13468, 18731, + 2955, 2956, 2957, 11695, 14614, 2958, 2959, 2960, 2961, 2962, 11198, 2963, + 2964, 2965, 14417, 2966, 2967, 18730, 2968, 18732, 2969, 14922, 18729, + 2970, 14734, 11176, 2971, 2972, 2973, 2974, 2975, 10050, 11754, 9455, 9640, + 2976, 9240, 18726, 9454, 9987, 10798, 10237, 2977, 2978, 14990, 18738, + 2979, 11159, 2980, 2981, 13624, 15147, 2982, 2983, 2984, 2985, 2986, 18739, + 9673, 2987, 2988, 2989, 2990, 20624, 2991, 15765, 15743, 2992, 2993, 2994, + 20625, 18740, 15551, 2995, 2996, 2997, 2998, 2999, 18736, 3000, 3001, 3002, + 3003, 15737, 3004, 3005, 3006, 3007, 10593, 18734, 3008, 3009, 18737, + 10418, 3010, 18735, 12067, 3011, 3012, 3013, 18741, 3014, 3015, 3016, 3017, + 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, + 3030, 3031, 3032, 15889, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, + 9825, 3041, 18742, 3042, 11152, 3043, 13862, 3044, 3045, 13844, 3046, 3047, + 3048, 12854, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 20626, 3056, 3057, + 3058, 3059, 12538, 3060, 3061, 3062, 3063, 11174, 11889, 3064, 3065, 3066, + 3067, 3068, 3069, 3070, 14756, 3071, 3072, 3073, 3074, 18743, 3075, 11897, + 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, + 3088, 3089, 3090, 3091, 3092, 3093, 3094, 9294, 3095, 3096, 15952, 3097, + 3098, 3099, 3100, 3101, 18745, 3102, 3103, 3104, 3105, 3106, 3107, 3108, + 3109, 20628, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 18746, + 10934, 20627, 3119, 3120, 18744, 3121, 3122, 3123, 3124, 3125, 3126, 3127, + 3128, 3129, 3130, 18747, 3131, 3132, 3133, 3134, 3135, 3136, 10947, 3137, + 3138, 3139, 10179, 3140, 3141, 3142, 3143, 3144, 15129, 3145, 9060, 20629, + 3146, 3147, 3148, 3149, 3150, 20630, 12098, 3151, 18748, 3152, 3153, 3154, + 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, + 3167, 3168, 13034, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, + 3178, 3179, 3180, 3181, 3182, 18749, 3183, 3184, 3185, 3186, 3187, 3188, + 3189, 3190, 3191, 17403, 3192, 3193, 3194, 3195, 3196, 3197, 20631, 3198, + 10619, 3199, 14801, 20052, 15176, 14054, 13639, 14938, 9636, 14775, 11563, + 3200, 3201, 18777, 11197, 20053, 16084, 3202, 13266, 20054, 3203, 3204, + 3205, 20055, 3206, 20057, 20056, 3207, 20059, 20058, 3208, 3209, 3210, + 3211, 11551, 3212, 20060, 3213, 12475, 3214, 3215, 3216, 3217, 9818, 9872, + 3218, 3219, 11122, 3220, 3221, 3222, 3223, 3224, 20495, 20494, 10386, + 14244, 9281, 3225, 20496, 3226, 3227, 3228, 13815, 20497, 20498, 3229, + 14019, 17813, 9442, 15955, 3230, 3231, 13248, 9064, 9867, 13636, 3232, + 3233, 3234, 14583, 3235, 3236, 11899, 3237, 3238, 3239, 3240, 3241, 3242, + 3243, 11934, 3244, 3245, 13399, 16265, 3246, 12074, 17814, 13783, 15374, + 13019, 9096, 9617, 13622, 3247, 3248, 9091, 3249, 3250, 10441, 3251, 3252, + 13105, 3253, 3254, 10248, 3255, 16105, 9643, 11333, 3256, 3257, 3258, 9608, + 3259, 3260, 3261, 3262, 11766, 9074, 3263, 3264, 3265, 3266, 3267, 3268, + 15539, 14032, 16440, 3269, 14557, 10187, 11900, 16114, 3270, 10552, 13070, + 3271, 3272, 3273, 17815, 11932, 12498, 13427, 3274, 11119, 9223, 3275, + 3276, 13089, 3277, 3278, 13106, 14352, 3279, 3280, 3281, 3282, 9222, 3283, + 3284, 3285, 10029, 3286, 3287, 3288, 12833, 3289, 17816, 15321, 9668, 3290, + 12717, 3291, 3292, 10442, 3293, 16329, 9978, 9485, 12845, 12898, 12078, + 17817, 3294, 9097, 13051, 12319, 3295, 10788, 3296, 11745, 14591, 9071, + 3297, 14582, 17819, 11733, 16465, 17818, 16103, 9086, 3298, 3299, 12891, + 3300, 3301, 12448, 11385, 3302, 15696, 12090, 13016, 9411, 15946, 3303, + 3304, 12073, 14000, 17820, 16147, 3305, 10751, 3306, 13598, 14164, 3307, + 17822, 11904, 3308, 3309, 3310, 3311, 13225, 16442, 13981, 12860, 3312, + 9649, 10785, 3313, 3314, 3315, 3316, 16269, 20137, 9045, 3317, 3318, 3319, + 3320, 11945, 3321, 3322, 14429, 3323, 3324, 3325, 3326, 14593, 3327, 3328, + 3329, 16276, 12491, 3330, 14771, 14347, 15119, 12876, 9993, 17821, 16140, + 11328, 11166, 3331, 3332, 9029, 3333, 13033, 9861, 3334, 3335, 3336, 16136, + 3337, 3338, 20138, 3339, 3340, 3341, 3342, 3343, 3344, 17823, 14541, 3345, + 3346, 14611, 3347, 3348, 3349, 3350, 14795, 17825, 3351, 14552, 12071, + 3352, 3353, 16464, 3354, 17824, 9063, 10945, 13826, 12908, 11757, 3355, + 3356, 3357, 3358, 9427, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, + 12109, 14235, 3367, 11386, 11142, 9998, 3368, 3369, 3370, 13100, 3371, + 17835, 3372, 3373, 3374, 17832, 11746, 3375, 3376, 17828, 3377, 3378, 3379, + 3380, 9808, 11556, 3381, 3382, 17829, 12902, 3383, 3384, 3385, 3386, 14953, + 3387, 10039, 3388, 3389, 3390, 3391, 10227, 14023, 10059, 17834, 3392, + 16093, 3393, 17830, 14390, 13299, 3394, 13052, 3395, 3396, 3397, 15505, + 3398, 11767, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 12496, 3406, 14374, + 9619, 3407, 11546, 3408, 11931, 14573, 15353, 9860, 3409, 17833, 17826, + 17836, 3410, 20139, 3411, 3412, 12461, 17831, 3413, 3414, 16277, 9982, + 3415, 9489, 3416, 17837, 3417, 17847, 3418, 3419, 3420, 3421, 3422, 17842, + 3423, 17846, 3424, 3425, 13649, 3426, 3427, 3428, 16500, 17844, 12707, + 14410, 3429, 9474, 3430, 3431, 3432, 15515, 3433, 3434, 3435, 3436, 3437, + 3438, 3439, 17843, 3440, 17840, 14778, 3441, 9792, 3442, 3443, 3444, 3445, + 3446, 11886, 11715, 3447, 3448, 11545, 3449, 3450, 3451, 3452, 17838, 3453, + 15879, 3454, 17827, 3455, 17839, 3456, 3457, 3458, 3459, 12096, 3460, + 17841, 9488, 10618, 12452, 3461, 3462, 11528, 3463, 3464, 3465, 3466, 3467, + 17850, 17853, 3468, 3469, 9416, 9789, 3470, 3471, 9859, 13781, 3472, 3473, + 3474, 3475, 3476, 3477, 17851, 14204, 3478, 10612, 3479, 17852, 17855, + 3480, 3481, 3482, 3483, 17854, 3484, 3485, 3486, 14379, 3487, 9090, 9863, + 3488, 3489, 3490, 3491, 3492, 3493, 19121, 3494, 3495, 3496, 3497, 3498, + 15120, 3499, 3500, 9480, 3501, 20236, 3502, 17849, 3503, 3504, 13842, + 17848, 9083, 15486, 9302, 3505, 14360, 3506, 3507, 3508, 3509, 3510, 3511, + 3512, 17845, 3513, 14159, 3514, 3515, 3516, 16065, 3517, 3518, 3519, 3520, + 3521, 17856, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 9846, 3530, + 12831, 3531, 3532, 3533, 17858, 3534, 3535, 3536, 3537, 3538, 3539, 3540, + 3541, 3542, 3543, 12729, 12826, 17956, 3544, 3545, 3546, 3547, 3548, 3549, + 3550, 12299, 3551, 17857, 11764, 3552, 13223, 3553, 3554, 3555, 3556, 3557, + 3558, 3559, 3560, 3561, 9632, 13671, 3562, 3563, 14181, 17859, 3564, 3565, + 17959, 3566, 3567, 3568, 3569, 16453, 3570, 3571, 3572, 3573, 3574, 9618, + 3575, 3576, 3577, 3578, 12290, 3579, 3580, 13438, 9410, 9858, 3581, 16446, + 3582, 3583, 3584, 3585, 12901, 3586, 17957, 17958, 3587, 17960, 3588, + 10944, 3589, 3590, 3591, 17961, 3592, 12127, 3593, 3594, 13810, 3595, 3596, + 3597, 3598, 3599, 3600, 3601, 9462, 13465, 3602, 17962, 3603, 13455, 3604, + 3605, 3606, 3607, 17963, 20237, 3608, 3609, 3610, 3611, 3612, 14206, 3613, + 3614, 3615, 17965, 3616, 17964, 3617, 9438, 3618, 3619, 3620, 3621, 3622, + 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, + 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 13057, 3643, 3644, 3645, + 3646, 3647, 3648, 3649, 3650, 17966, 3651, 3652, 3653, 3654, 3655, 3656, + 3657, 3658, 15925, 3659, 3660, 3661, 3662, 3663, 13618, 3664, 3665, 3666, + 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 17967, 3676, 3677, + 3678, 3679, 3680, 11765, 3681, 3682, 17968, 16252, 3683, 3684, 3685, 3686, + 20068, 20257, 14018, 3687, 16717, 10581, 3688, 10740, 3689, 3690, 10392, + 16149, 3691, 3692, 3693, 3694, 3695, 10777, 3696, 3697, 15112, 21990, 3698, + 3699, 10023, 3700, 3701, 12719, 3702, 11725, 3703, 3704, 3705, 20258, 9054, + 3706, 3707, 11539, 3708, 12273, 3709, 9269, 9603, 3710, 3711, 3712, 10595, + 13777, 3713, 3714, 10221, 3715, 3716, 3717, 3718, 20259, 11705, 3719, 3720, + 3721, 14058, 3722, 13430, 3723, 16146, 3724, 3725, 10438, 3726, 3727, 3728, + 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, + 14761, 3741, 3742, 3743, 16066, 9298, 3744, 3745, 3746, 20444, 9088, 3747, + 20446, 3748, 3749, 3750, 10188, 3751, 12302, 3752, 22225, 15122, 3753, + 3754, 16124, 3755, 14776, 3756, 3757, 11574, 9661, 3758, 10556, 3759, + 16077, 3760, 20644, 3761, 10212, 3762, 14180, 15139, 3763, 3764, 3765, + 3766, 3767, 3768, 3769, 3770, 10384, 3771, 3772, 20447, 13974, 3773, 3774, + 3775, 13067, 3776, 20450, 20449, 12480, 20448, 3777, 3778, 3779, 3780, + 15198, 20451, 3781, 20452, 16504, 3782, 3783, 20453, 3784, 3785, 3786, + 20454, 13281, 3787, 3788, 3789, 3790, 3791, 3792, 3793, 3794, 14787, 3795, + 11345, 3796, 3797, 13638, 9984, 11726, 16273, 15936, 3798, 3799, 15309, + 15186, 20069, 20070, 20071, 10946, 3800, 3801, 3802, 3803, 13982, 11960, + 3804, 3805, 14625, 3806, 3807, 3808, 3809, 3810, 20077, 3811, 9051, 20075, + 3812, 3813, 12070, 3814, 3815, 3816, 20072, 3817, 9498, 3818, 12722, 11187, + 3819, 3820, 3821, 15540, 14809, 20076, 3822, 3823, 3824, 20073, 3825, 3826, + 3827, 20080, 3828, 15144, 15694, 3829, 3830, 3831, 3832, 9811, 3833, 12668, + 16517, 3834, 3835, 3836, 3837, 16104, 3838, 14004, 3839, 20082, 3840, 3841, + 20081, 20084, 20083, 3842, 3843, 3844, 3845, 3846, 16316, 3847, 14967, + 3848, 3849, 20088, 3850, 11161, 3851, 3852, 3853, 3854, 3855, 3856, 3857, + 11585, 13821, 3858, 3859, 20089, 3860, 3861, 13800, 15009, 20087, 15911, + 20090, 20092, 3862, 3863, 14612, 3864, 3865, 3866, 3867, 20086, 3868, + 20091, 3869, 3870, 14803, 3871, 11177, 3872, 9626, 3873, 3874, 3875, 3876, + 3877, 13258, 11701, 14815, 3878, 3879, 3880, 13466, 3881, 11692, 20093, + 3882, 3883, 16284, 3884, 3885, 3886, 12287, 3887, 3888, 3889, 15926, 3890, + 20094, 3891, 3892, 14945, 3893, 3894, 3895, 3896, 20095, 3897, 3898, 3899, + 3900, 14043, 3901, 3902, 3903, 3904, 13030, 9046, 3905, 3906, 3907, 3908, + 3909, 20097, 3910, 3911, 3912, 3913, 3914, 3915, 3916, 3917, 3918, 20096, + 22008, 3919, 3920, 3921, 3922, 3923, 12851, 3924, 3925, 3926, 3927, 3928, + 9224, 3929, 3930, 3931, 3932, 19158, 3933, 3934, 3935, 3936, 20098, 3937, + 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3946, 3947, 3948, 3949, + 3950, 3951, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, + 3962, 14044, 3963, 20099, 20100, 13261, 3964, 3965, 3966, 3967, 3968, 3969, + 3970, 3971, 20101, 3972, 3973, 20102, 3974, 3975, 3976, 3977, 3978, 3979, + 15892, 3980, 13485, 15508, 10637, 3981, 3982, 20079, 3983, 9465, 3984, + 3985, 12537, 3986, 15953, 14415, 16513, 3987, 3988, 3989, 3990, 3991, 3992, + 3993, 15899, 15723, 20270, 13098, 3994, 10449, 3995, 3996, 20287, 3997, + 3998, 3999, 14178, 20297, 4000, 12107, 4001, 4002, 4003, 14626, 4004, 9610, + 4005, 13263, 4006, 4007, 4008, 4009, 4010, 4011, 20327, 4012, 12855, 4013, + 14745, 12834, 9245, 15958, 4014, 14050, 4015, 16321, 4016, 4017, 13256, + 10233, 4018, 4019, 4020, 4021, 11205, 4022, 4023, 15169, 4024, 4025, 13792, + 4026, 15916, 13593, 4027, 4028, 10588, 4029, 19695, 13803, 4030, 4031, + 19692, 4032, 12143, 15156, 9441, 9854, 4033, 19693, 4034, 4035, 16095, + 4036, 4037, 4038, 4039, 4040, 10202, 4041, 19694, 14053, 10605, 14430, + 4042, 4043, 4044, 12085, 4045, 4046, 15373, 19696, 19699, 4047, 4048, + 10953, 4049, 9228, 11555, 4050, 20074, 19700, 4051, 19703, 4052, 19708, + 4053, 4054, 4055, 4056, 19709, 4057, 14196, 9094, 4058, 11316, 4059, 4060, + 10760, 4061, 4062, 19698, 4063, 14622, 4064, 19707, 4065, 4066, 4067, 4068, + 14811, 4069, 4070, 4071, 4072, 16132, 4073, 12309, 19701, 4074, 12657, + 4075, 10826, 16251, 19705, 4076, 4077, 4078, 14029, 15935, 4079, 19697, + 4080, 19702, 19704, 4081, 13420, 10422, 4082, 19706, 4083, 11936, 19715, + 4084, 4085, 19720, 4086, 19718, 11365, 11352, 19724, 4087, 4088, 4089, + 4090, 4091, 4092, 4093, 4094, 19727, 4095, 19723, 9305, 4096, 4097, 4098, + 4099, 4100, 4101, 4102, 4103, 4104, 4105, 9081, 12844, 10589, 13271, 13615, + 13650, 4106, 4107, 4108, 19712, 19717, 19719, 4109, 10816, 19721, 16520, + 4110, 12916, 4111, 19725, 4112, 4113, 9478, 4114, 4115, 4116, 19714, 4117, + 4118, 11382, 4119, 4120, 11909, 19710, 16334, 4121, 12343, 9486, 4122, + 4123, 4124, 4125, 4126, 4127, 4128, 4129, 19728, 4130, 13998, 19722, 4131, + 4132, 4133, 4134, 16059, 4135, 9289, 16082, 19711, 19713, 10181, 19716, + 4136, 19726, 12089, 4137, 14052, 4138, 14163, 4139, 4140, 13265, 12150, + 4141, 4142, 4143, 4144, 4145, 19738, 4146, 4147, 4148, 15108, 4149, 4150, + 4151, 4152, 4153, 4154, 4155, 19747, 16319, 4156, 4157, 4158, 4159, 4160, + 4161, 4162, 19729, 19730, 4163, 4164, 4165, 15384, 10968, 10634, 4166, + 4167, 10626, 15917, 19744, 4168, 19743, 19741, 10815, 14395, 19735, 14731, + 11957, 4169, 9049, 19746, 19745, 4170, 16467, 4171, 19733, 4172, 14544, + 13778, 4173, 11139, 11554, 19739, 4174, 4175, 4176, 4177, 4178, 4179, 4180, + 4181, 4182, 4183, 19731, 19732, 19734, 9996, 19736, 13432, 19740, 19742, + 11511, 16449, 4184, 19753, 4185, 4186, 4187, 4188, 4189, 4190, 4191, 4192, + 19750, 4193, 14551, 19751, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, + 4202, 12281, 4203, 19737, 4204, 12658, 9105, 4205, 4206, 4207, 4208, 4209, + 4210, 4211, 4212, 19749, 4213, 4214, 4215, 19752, 4216, 4217, 4218, 10738, + 4219, 4220, 4221, 4222, 4223, 4224, 4225, 4226, 4227, 4228, 13825, 4229, + 4230, 4231, 12681, 14789, 12135, 4232, 4233, 4234, 4235, 14238, 4236, + 14406, 15126, 4237, 4238, 14030, 4239, 19748, 4240, 4241, 4242, 4243, 4244, + 4245, 4246, 4247, 4248, 4249, 11381, 4250, 19754, 4251, 4252, 4253, 4254, + 4255, 4256, 12697, 4257, 13274, 4258, 10822, 4259, 4260, 4261, 4262, 9109, + 4263, 4264, 16491, 4265, 4266, 11317, 4267, 13094, 4268, 4269, 4270, 4271, + 4272, 14381, 4273, 4274, 19861, 4275, 4276, 4277, 4278, 4279, 4280, 4281, + 4282, 4283, 4284, 13788, 4285, 19857, 12131, 4286, 4287, 4288, 11910, 4289, + 4290, 4291, 19759, 10790, 4292, 19756, 4293, 4294, 4295, 4296, 19859, 4297, + 4298, 4299, 15531, 4300, 4301, 4302, 4303, 4304, 19858, 4305, 16263, 16456, + 4306, 19862, 4307, 11518, 4308, 4309, 4310, 4311, 4312, 4313, 4314, 4315, + 4316, 4317, 4318, 4319, 19757, 19758, 4320, 4321, 4322, 19856, 4323, 4324, + 4325, 4326, 4327, 4328, 4329, 4330, 14589, 4331, 4332, 15497, 4333, 4334, + 4335, 19873, 4336, 4337, 4338, 4339, 19864, 4340, 4341, 4342, 9795, 4343, + 9812, 4344, 4345, 19866, 4346, 4347, 4348, 4349, 4350, 4351, 4352, 4353, + 4354, 4355, 4356, 4357, 4358, 4359, 4360, 4361, 4362, 15113, 4363, 4364, + 19860, 4365, 4366, 9689, 4367, 4368, 19867, 12132, 4369, 19865, 4370, 4371, + 19880, 4372, 4373, 19879, 4374, 4375, 4376, 4377, 19869, 4378, 4379, 19755, + 4380, 4381, 19863, 4382, 4383, 4384, 4385, 4386, 11887, 19872, 19881, 4387, + 4388, 12450, 4389, 4390, 4391, 19870, 4392, 10582, 4393, 19868, 4394, + 15735, 19875, 19876, 19878, 4395, 4396, 4397, 19894, 4398, 4399, 4400, + 4401, 4402, 4403, 12103, 19892, 4404, 4405, 19871, 4406, 4407, 19882, 9106, + 4408, 4409, 4410, 4411, 4412, 4413, 4414, 4415, 4416, 4417, 19883, 16060, + 4418, 4419, 19885, 4420, 19886, 4421, 4422, 4423, 19888, 4424, 4425, 12336, + 4426, 4427, 13607, 4428, 4429, 4430, 19884, 4431, 4432, 4433, 4434, 4435, + 19889, 4436, 4437, 4438, 4439, 4440, 4441, 4442, 4443, 19890, 4444, 19874, + 4445, 19877, 4446, 11132, 4447, 4448, 4449, 19887, 4450, 4451, 4452, 4453, + 4454, 4455, 11392, 4456, 4457, 4458, 19891, 19893, 4459, 4460, 4461, 4462, + 4463, 4464, 4465, 4466, 4467, 4468, 4469, 4470, 19897, 4471, 4472, 4473, + 4474, 19901, 4475, 4476, 4477, 4478, 4479, 4480, 4481, 4482, 4483, 4484, + 9464, 4485, 19895, 4486, 4487, 4488, 4489, 4490, 4491, 4492, 4493, 4494, + 4495, 10369, 4496, 4497, 4498, 4499, 4500, 4501, 4502, 4503, 4504, 4505, + 4506, 4507, 19898, 19899, 4508, 4509, 4510, 4511, 4512, 4513, 16088, 4514, + 12828, 4515, 4516, 4517, 4518, 4519, 4520, 19911, 4521, 10990, 4522, 4523, + 4524, 4525, 19896, 4526, 15678, 4527, 4528, 4529, 19907, 4530, 4531, 4532, + 4533, 4534, 4535, 4536, 19910, 19903, 4537, 4538, 4539, 4540, 4541, 19902, + 4542, 4543, 13428, 4544, 4545, 4546, 4547, 4548, 4549, 4550, 4551, 19905, + 4552, 4553, 4554, 4555, 4556, 4557, 4558, 19912, 9635, 4559, 19906, 4560, + 4561, 4562, 4563, 4564, 14995, 4565, 4566, 4567, 19900, 4568, 4569, 4570, + 4571, 4572, 4573, 4574, 4575, 4576, 4577, 4578, 9682, 4579, 4580, 4581, + 4582, 4583, 4584, 4585, 19909, 4586, 4587, 19913, 4588, 4589, 4590, 14365, + 4591, 4592, 4593, 14928, 4594, 4595, 4596, 4597, 4598, 4599, 4600, 4601, + 4602, 19908, 4603, 19915, 19914, 4604, 4605, 4606, 4607, 4608, 19917, 4609, + 4610, 4611, 4612, 4613, 4614, 4615, 4616, 19904, 4617, 4618, 4619, 4620, + 4621, 4622, 4623, 4624, 19916, 4625, 19918, 12677, 4626, 4627, 4628, 4629, + 4630, 4631, 4632, 4633, 4634, 4635, 4636, 4637, 4638, 4639, 4640, 4641, + 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649, 4650, 4651, 4652, 4653, + 4654, 4655, 4656, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, + 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, + 4678, 4679, 4680, 4681, 4682, 4683, 4684, 4685, 4686, 4687, 4688, 4689, + 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, + 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, + 4714, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4724, 4725, + 4726, 4727, 4728, 4729, 4730, 4731, 4732, 4733, 4734, 4735, 4736, 4737, + 4738, 4739, 4740, 13418, 9831, 11137, 15137, 20428, 4741, 4742, 13038, + 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 15766, 4753, + 4754, 4755, 4756, 20429, 4757, 20430, 13264, 4758, 4759, 4760, 11953, 4761, + 4762, 4763, 4764, 20431, 4765, 4766, 20432, 15115, 4767, 13419, 4768, 4769, + 10617, 4770, 4771, 4772, 4773, 4774, 4775, 4776, 4777, 4778, 4779, 4780, + 4781, 20433, 4782, 4783, 4784, 4785, 4786, 4787, 4788, 4789, 16270, 16148, + 9828, 9434, 14793, 13276, 4790, 4791, 14600, 4792, 4793, 4794, 4795, 4796, + 4797, 4798, 4799, 4800, 4801, 4802, 4803, 4804, 4805, 9870, 4806, 14187, + 11368, 4807, 4808, 4809, 4810, 19921, 19922, 15369, 19924, 4811, 9874, + 19923, 4812, 15314, 14031, 9453, 4813, 19927, 4814, 4815, 4816, 4817, + 19925, 19926, 4818, 4819, 16264, 4820, 4821, 4822, 19928, 19929, 4823, + 4824, 4825, 4826, 4827, 19930, 4828, 4829, 4830, 4831, 4832, 4833, 4834, + 4835, 19931, 4836, 4837, 4838, 4839, 4840, 4841, 4842, 4843, 20440, 13040, + 10211, 4844, 15568, 4845, 4846, 4847, 4848, 4849, 4850, 4851, 10053, 4852, + 11172, 20442, 4853, 4854, 15552, 4855, 4856, 4857, 4858, 4859, 14792, 4860, + 12849, 4861, 12666, 4862, 4863, 10195, 16650, 9255, 9262, 9264, 13109, + 4864, 9263, 4865, 12646, 4866, 4867, 4868, 4869, 4870, 16072, 4871, 4872, + 4873, 4874, 4875, 4876, 4877, 4878, 20239, 10958, 4879, 4880, 4881, 14371, + 4882, 4883, 4884, 20240, 4885, 20242, 4886, 4887, 4888, 20243, 4889, 4890, + 4891, 20241, 4892, 4893, 4894, 4895, 4896, 4897, 4898, 20244, 20246, 20245, + 4899, 4900, 4901, 4902, 4903, 20247, 4904, 14012, 16646, 12716, 4905, + 12640, 13293, 20248, 12867, 4906, 20249, 20250, 20251, 10408, 4907, 4908, + 4909, 10445, 4910, 20252, 13461, 4911, 20254, 4912, 10929, 15380, 9042, + 20253, 20255, 4913, 4914, 4915, 9985, 12485, 13467, 4916, 20256, 4917, + 14169, 18778, 4918, 4919, 15707, 4920, 4921, 4922, 4923, 16874, 4924, 4925, + 14536, 16258, 13478, 4926, 4927, 4928, 16879, 11182, 4929, 10951, 18781, + 4930, 4931, 4932, 4933, 4934, 14926, 4935, 4936, 4937, 18779, 13814, 4938, + 10950, 4939, 4940, 4941, 15315, 18780, 13659, 10750, 11508, 9651, 14784, + 4942, 4943, 14377, 4944, 4945, 4946, 18787, 18788, 14619, 4947, 4948, 4949, + 4950, 4951, 14358, 4952, 11324, 4953, 18789, 4954, 18790, 4955, 4956, + 15163, 4957, 4958, 4959, 13296, 10413, 4960, 4961, 13458, 15527, 14779, + 4962, 18783, 18791, 4963, 13857, 9628, 4964, 4965, 18786, 4966, 4967, + 13272, 18784, 4968, 4969, 20634, 18785, 4970, 4971, 4972, 4973, 13794, + 4974, 13085, 4975, 4976, 4977, 10756, 4978, 12662, 4979, 18782, 13044, + 12259, 12502, 9460, 4980, 18792, 11121, 12838, 4981, 18795, 11743, 4982, + 4983, 18806, 18800, 10976, 4984, 4985, 4986, 4987, 10403, 15720, 4988, + 16291, 16106, 10768, 16075, 15351, 4989, 4990, 4991, 4992, 15130, 13481, + 4993, 4994, 4995, 13595, 9425, 4996, 12693, 4997, 4998, 4999, 18793, 5000, + 5001, 18807, 18794, 10363, 18802, 18799, 5002, 5003, 5004, 10381, 5005, + 5006, 13017, 5007, 18801, 13076, 9413, 13297, 5008, 12889, 5009, 5010, + 16437, 5011, 12130, 18804, 5012, 5013, 18805, 18808, 14354, 18798, 5014, + 15705, 5015, 9250, 20635, 18796, 18797, 5016, 18803, 15131, 13240, 15948, + 18809, 5017, 5018, 11559, 5019, 5020, 18912, 5021, 5022, 18911, 5023, 5024, + 5025, 15378, 18908, 5026, 18914, 5027, 5028, 5029, 13672, 5030, 5031, 5032, + 5033, 14935, 5034, 18913, 18919, 12514, 5035, 5036, 10185, 5037, 5038, + 5039, 5040, 5041, 5042, 11577, 5043, 18907, 5044, 5045, 10998, 18915, 5046, + 5047, 18917, 5048, 5049, 10258, 16307, 18923, 5050, 18918, 5051, 5052, + 5053, 18906, 5054, 11193, 14596, 13397, 13056, 5055, 5056, 12342, 5057, + 18909, 5058, 13414, 11507, 11524, 18910, 5059, 16474, 9471, 5060, 18916, + 11340, 18920, 5061, 11190, 18921, 13023, 18922, 5062, 5063, 5064, 5065, + 16122, 11878, 5066, 18931, 5067, 18928, 5068, 18932, 5069, 5070, 18934, + 5071, 5072, 13259, 5073, 5074, 10963, 12108, 5075, 5076, 5077, 10546, + 18925, 5078, 5079, 5080, 5081, 15866, 5082, 5083, 10928, 11589, 5084, 5085, + 5086, 18933, 5087, 5088, 5089, 5090, 5091, 14566, 5092, 5093, 12914, 5094, + 5095, 15006, 13845, 5096, 5097, 15706, 5098, 14964, 5099, 5100, 18924, + 5101, 18929, 18930, 14418, 5102, 5103, 5104, 5105, 5106, 14391, 5107, + 12117, 18926, 12271, 18927, 14773, 5108, 11148, 10026, 5109, 13668, 11502, + 16094, 13787, 10547, 18947, 5110, 5111, 18949, 15331, 5112, 5113, 15511, + 5114, 5115, 10938, 5116, 5117, 10977, 5118, 5119, 5120, 5121, 5122, 5123, + 18940, 10052, 5124, 5125, 5126, 16480, 18937, 15008, 18936, 5127, 5128, + 5129, 12315, 14387, 5130, 5131, 5132, 5133, 14036, 5134, 5135, 5136, 5137, + 12880, 5138, 14397, 18945, 5139, 5140, 5141, 18944, 18938, 5142, 18941, + 9988, 5143, 5144, 15732, 5145, 18943, 5146, 5147, 5148, 5149, 15574, 9852, + 5150, 11135, 5151, 5152, 13853, 5153, 9815, 5154, 5155, 5156, 11191, 5157, + 15340, 5158, 14422, 20636, 5159, 5160, 5161, 5162, 5163, 5164, 5165, 5166, + 13464, 5167, 5168, 5169, 5170, 15873, 5171, 18948, 16488, 18939, 5172, + 11500, 18942, 5173, 5174, 15745, 5175, 18946, 13863, 5176, 5177, 18935, + 5178, 5179, 15744, 5180, 5181, 13489, 10206, 5182, 15957, 9424, 18960, + 5183, 5184, 5185, 14759, 5186, 18950, 5187, 14753, 5188, 10604, 5189, 5190, + 18959, 5191, 11917, 5192, 5193, 5194, 15721, 5195, 12711, 5196, 5197, 5198, + 5199, 5200, 5201, 5202, 5203, 13055, 18961, 5204, 5205, 5206, 5207, 5208, + 5209, 5210, 5211, 14571, 18952, 5212, 5213, 5214, 5215, 18957, 18958, 5216, + 11019, 5217, 14985, 5218, 5219, 16086, 5220, 5221, 5222, 18955, 5223, 5224, + 5225, 5226, 5227, 5228, 5229, 5230, 5231, 5232, 5233, 18953, 5234, 5235, + 18951, 5236, 5237, 5238, 5239, 5240, 5241, 5242, 5243, 5244, 5245, 5246, + 5247, 5248, 5249, 5250, 14604, 13975, 5251, 5252, 5253, 12068, 5254, 11501, + 18956, 5255, 5256, 10585, 5257, 5258, 5259, 5260, 5261, 18976, 15885, 5262, + 5263, 5264, 5265, 5266, 5267, 5268, 18964, 5269, 5270, 5271, 12334, 5272, + 5273, 18978, 5274, 5275, 15556, 5276, 5277, 18968, 5278, 18969, 5279, 5280, + 14925, 5281, 5282, 5283, 5284, 14216, 5285, 18963, 18954, 5286, 18974, + 5287, 13645, 18972, 5288, 5289, 12896, 18971, 5290, 18970, 5291, 5292, + 5293, 9687, 18977, 5294, 5295, 5296, 5297, 10040, 5298, 5299, 5300, 16479, + 5301, 5302, 5303, 18975, 5304, 11127, 5305, 16485, 14392, 20323, 5306, + 18973, 5307, 5308, 10821, 5309, 5310, 5311, 16290, 18962, 18965, 12535, + 18967, 5312, 12488, 12101, 12493, 5313, 9300, 14363, 5314, 5315, 5316, + 5317, 5318, 5319, 5320, 5321, 5322, 5323, 10021, 5324, 5325, 5326, 5327, + 18984, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 13220, 5336, 5337, + 5338, 13270, 5339, 5340, 18990, 5341, 5342, 5343, 5344, 5345, 12454, 5346, + 5347, 5348, 12141, 15356, 18983, 5349, 5350, 5351, 5352, 5353, 5354, 5355, + 5356, 5357, 5358, 12839, 5359, 5360, 5361, 18982, 5362, 5363, 5364, 5365, + 18991, 18989, 12539, 5366, 18966, 5367, 18985, 5368, 14059, 5369, 16091, + 5370, 5371, 18986, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 15385, 5379, + 5380, 5381, 5382, 5383, 5384, 5385, 18980, 18981, 5386, 5387, 5388, 18987, + 5389, 14736, 5390, 5391, 5392, 5393, 5394, 5395, 5396, 5397, 5398, 5399, + 13058, 5400, 5401, 5402, 13412, 5403, 12471, 5404, 5405, 5406, 18979, 5407, + 5408, 5409, 12297, 5410, 5411, 5412, 5413, 5414, 5415, 14367, 9612, 5416, + 5417, 5418, 18996, 5419, 18988, 5420, 5421, 5422, 18995, 5423, 18998, 5424, + 18997, 5425, 5426, 5427, 5428, 5429, 5430, 5431, 9641, 5432, 5433, 5434, + 9621, 18992, 5435, 5436, 18994, 18993, 13091, 5437, 5438, 5439, 5440, 5441, + 5442, 5443, 5444, 5445, 5446, 5447, 5448, 5449, 12094, 5450, 5451, 5452, + 5453, 15937, 5454, 5455, 5456, 5457, 5458, 19097, 5459, 5460, 5461, 5462, + 5463, 5464, 5465, 5466, 5467, 5468, 5469, 9061, 5470, 5471, 19099, 5472, + 5473, 19098, 5474, 5475, 5476, 5477, 5478, 5479, 11309, 5480, 19100, 5481, + 5482, 5483, 5484, 5485, 5486, 19096, 5487, 5488, 5489, 5490, 5491, 5492, + 5493, 18999, 9299, 5494, 5495, 5496, 5497, 5498, 5499, 5500, 5501, 5502, + 5503, 5504, 19103, 5505, 19104, 19101, 5506, 5507, 5508, 5509, 5510, 5511, + 5512, 5513, 5514, 5515, 5516, 5517, 19102, 19105, 5518, 5519, 5520, 5521, + 5522, 5523, 5524, 5525, 5526, 5527, 5528, 5529, 5530, 5531, 5532, 5533, + 5534, 5535, 5536, 5537, 5538, 5539, 5540, 5541, 5542, 5543, 5544, 5545, + 5546, 5547, 5548, 5549, 5550, 13262, 5551, 5552, 5553, 5554, 5555, 5556, + 5557, 5558, 19106, 19108, 5559, 5560, 5561, 5562, 5563, 5564, 5565, 19107, + 5566, 5567, 5568, 5569, 5570, 5571, 5572, 5573, 5574, 5575, 5576, 5577, + 5578, 5579, 5580, 5581, 5582, 19110, 5583, 5584, 5585, 19109, 5586, 5587, + 5588, 5589, 5590, 5591, 5592, 5593, 5594, 5595, 5596, 5597, 5598, 5599, + 5600, 5601, 5602, 5603, 10799, 5604, 5605, 19111, 5606, 5607, 5608, 5609, + 5610, 5611, 5612, 5613, 5614, 5615, 5616, 5617, 5618, 5619, 19112, 5620, + 5621, 5622, 5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 11195, + 20490, 12715, 5632, 10013, 11165, 5633, 5634, 5635, 5636, 12328, 15943, + 5637, 11721, 5638, 5639, 5640, 16473, 5641, 15919, 9456, 20455, 5642, 5643, + 5644, 5645, 20078, 5646, 5647, 5648, 12460, 9807, 5649, 5650, 5651, 15350, + 5652, 5653, 5654, 9615, 5655, 13603, 11902, 20457, 5656, 5657, 16288, 5658, + 5659, 20456, 20458, 5660, 5661, 5662, 5663, 5664, 5665, 5666, 5667, 5668, + 5669, 5670, 5671, 5672, 20462, 11755, 14376, 13073, 11713, 5673, 20463, + 5674, 9309, 5675, 5676, 5677, 20461, 16063, 10042, 5678, 20459, 12277, + 9662, 5679, 5680, 20460, 14179, 12100, 14439, 5681, 5682, 5683, 5684, + 12305, 5685, 20465, 5686, 5687, 5688, 5689, 5690, 5691, 5692, 5693, 5694, + 5695, 5696, 5697, 5698, 10995, 12116, 5699, 16327, 5700, 5701, 5702, 15339, + 5703, 5704, 5705, 5706, 11905, 5707, 10374, 13828, 20464, 11181, 5708, + 14389, 11588, 13625, 5709, 14924, 5710, 5711, 5712, 5713, 5714, 5715, 5716, + 14608, 5717, 13090, 5718, 5719, 5720, 10428, 5721, 5722, 5723, 5724, 5725, + 5726, 5727, 5728, 5729, 5730, 5731, 15336, 10949, 5732, 5733, 5734, 5735, + 5736, 20466, 5737, 5738, 20467, 5739, 11147, 20468, 5740, 20491, 9241, + 10412, 5741, 5742, 5743, 5744, 5745, 5746, 5747, 5748, 5749, 5750, 5751, + 11520, 5752, 5753, 5754, 5755, 5756, 5757, 5758, 5759, 20469, 15365, 20470, + 5760, 5761, 5762, 5763, 13612, 5764, 5765, 5766, 5767, 5768, 5769, 5770, + 5771, 5772, 5773, 5774, 5775, 5776, 5777, 20474, 5778, 5779, 5780, 5781, + 20476, 5782, 11160, 5783, 11374, 5784, 5785, 5786, 5787, 5788, 5789, 5790, + 5791, 5792, 5793, 5794, 5795, 5796, 20472, 5797, 13798, 5798, 5799, 5800, + 5801, 5802, 12661, 5803, 20492, 16108, 20473, 5804, 5805, 5806, 5807, 5808, + 16328, 5809, 5810, 5811, 20475, 20471, 5812, 5813, 5814, 5815, 20477, 5816, + 20478, 5817, 5818, 13806, 5819, 5820, 5821, 5822, 5823, 5824, 14923, 5825, + 5826, 5827, 5828, 5829, 15165, 5830, 5831, 5832, 5833, 15307, 5834, 5835, + 5836, 5837, 13644, 5838, 5839, 5840, 20479, 14810, 5841, 5842, 5843, 5844, + 5845, 14041, 20483, 5846, 5847, 5848, 5849, 5850, 5851, 5852, 20482, 5853, + 5854, 5855, 9055, 5856, 5857, 5858, 5859, 5860, 5861, 20480, 5862, 20481, + 5863, 5864, 5865, 20493, 5866, 5867, 5868, 5869, 5870, 5871, 5872, 5873, + 5874, 13613, 5875, 5876, 5877, 5878, 5879, 5880, 5881, 5882, 5883, 5884, + 12294, 5885, 5886, 5887, 5888, 5889, 20485, 15359, 5890, 5891, 5892, 5893, + 5894, 5895, 5896, 5897, 5898, 5899, 20484, 5900, 5901, 5902, 5903, 15944, + 5904, 20486, 5905, 5906, 5907, 5908, 5909, 5910, 17233, 5911, 5912, 5913, + 5914, 5915, 5916, 5917, 5918, 5919, 5920, 20487, 5921, 5922, 5923, 5924, + 5925, 5926, 5927, 5928, 5929, 5930, 5931, 5932, 9227, 5933, 5934, 5935, + 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, 5947, + 5948, 5949, 5950, 5951, 5952, 5953, 5954, 20488, 5955, 5956, 5957, 5958, + 5959, 5960, 5961, 5962, 5963, 5964, 20489, 5965, 16441, 5966, 13047, 5967, + 5968, 5969, 20263, 9039, 5970, 5971, 5972, 11769, 10569, 15500, 9079, + 10064, 5973, 16644, 5974, 14167, 5975, 18776, 5976, 5977, 5978, 5979, 5980, + 5981, 5982, 13217, 9095, 5983, 5984, 5985, 13053, 20260, 5986, 5987, 5988, + 5989, 20261, 5990, 5991, 5992, 20262, 5993, 5994, 15327, 5995, 13018, 5996, + 20127, 5997, 12843, 5998, 12846, 12111, 5999, 6000, 6001, 20128, 12858, + 6002, 14804, 6003, 6004, 6005, 6006, 20125, 20129, 6007, 6008, 13867, 6009, + 6010, 13398, 6011, 6012, 6013, 14401, 14819, 6014, 6015, 6016, 20130, + 20131, 14927, 12136, 6017, 6018, 20132, 6019, 6020, 6021, 6022, 6023, + 10196, 20133, 6024, 20134, 6025, 20135, 6026, 6027, 20136, 6028, 6029, + 6030, 6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039, 20126, 6040, + 6041, 6042, 6043, 6044, 6045, 6046, 6047, 6048, 6049, 6050, 6051, 13599, + 18410, 6052, 10379, 18411, 6053, 6054, 6055, 18412, 6056, 16455, 18413, + 18414, 15719, 6057, 6058, 6059, 6060, 6061, 6062, 6063, 18416, 11956, + 18415, 10025, 6064, 6065, 6066, 9238, 6067, 6068, 6069, 6070, 18418, 18417, + 6071, 11017, 6072, 18419, 6073, 6074, 6075, 6076, 10758, 6077, 11734, 6078, + 6079, 7790, 7791, 12917, 7792, 10986, 11533, 7793, 7794, 7795, 7796, 7797, + 7798, 18420, 18422, 7799, 7800, 10197, 14948, 13973, 18421, 16143, 15767, + 18423, 18427, 18424, 7801, 7802, 18425, 12139, 7803, 18429, 18526, 12104, + 7804, 7805, 7806, 7807, 18426, 7808, 18428, 7809, 7810, 7811, 7812, 7813, + 7814, 18530, 7815, 7816, 7817, 12307, 7818, 7819, 7820, 7821, 18528, 7822, + 18533, 9499, 18527, 7823, 7824, 7825, 12680, 9439, 18532, 18531, 7826, + 7827, 18529, 18534, 7828, 7829, 18536, 7830, 7831, 7832, 15146, 16322, + 12643, 18537, 7833, 14970, 7834, 7835, 18539, 7836, 7837, 11004, 7838, + 7839, 19919, 18538, 18535, 7840, 7841, 7842, 7843, 11126, 15884, 7844, + 7845, 7846, 7847, 7848, 7849, 7850, 7851, 7852, 7853, 7854, 7855, 7856, + 18541, 7857, 7858, 18540, 7859, 19920, 7860, 7861, 7862, 7863, 18542, 7864, + 7865, 7866, 7867, 7868, 7869, 7870, 7871, 18543, 7872, 7873, 7874, 7875, + 7876, 7877, 7878, 7879, 7880, 7881, 7882, 18544, 14346, 7883, 18545, 7884, + 7885, 7980, 7981, 7982, 7983, 7984, 7985, 7986, 7987, 7988, 7989, 7990, + 7991, 18546, 7992, 7993, 7994, 7995, 7996, 15199, 7997, 7998, 12487, 7999, + 15756, 8000, 14620, 8001, 8002, 19539, 8003, 8004, 19540, 8005, 8006, 8007, + 8008, 11718, 8009, 8010, 8011, 8012, 12519, 8013, 8014, 8015, 19543, 8016, + 8017, 19542, 8018, 8019, 8020, 8021, 8022, 8023, 14605, 8024, 12656, 8025, + 8026, 19541, 11138, 14969, 8027, 12320, 19548, 8028, 8029, 8030, 19547, + 8031, 8032, 19559, 9408, 8033, 8034, 8035, 8036, 19549, 8037, 19545, 8038, + 8039, 8040, 8041, 8042, 19551, 19550, 13801, 8043, 8044, 16123, 8045, + 19544, 10364, 19546, 8046, 8047, 8048, 8049, 8050, 8051, 8052, 19553, 8053, + 8054, 8055, 8056, 19558, 8057, 16318, 8058, 8059, 8060, 8061, 19552, 8062, + 19557, 8063, 19556, 8064, 8065, 8066, 9089, 8067, 8068, 8069, 8070, 19560, + 8071, 8072, 8073, 8074, 8075, 8170, 8171, 8172, 8173, 8174, 8175, 8176, + 8177, 8178, 8179, 8180, 13477, 8181, 12102, 12142, 8182, 8183, 12335, + 19555, 8184, 8185, 8186, 8187, 19561, 14241, 8188, 8189, 8190, 8191, 8192, + 8193, 8194, 8195, 8196, 19667, 19666, 8197, 8198, 8199, 8200, 8201, 8202, + 16468, 8203, 8204, 19565, 19564, 8205, 19566, 8206, 19562, 8207, 19569, + 8208, 19568, 8209, 19567, 8210, 8211, 12308, 13452, 13108, 13050, 8212, + 8213, 8214, 8215, 8216, 13472, 8217, 8218, 8219, 8220, 19668, 8221, 8222, + 8223, 8224, 8225, 8226, 8227, 8228, 8229, 8230, 8231, 8232, 8233, 8234, + 8235, 8236, 8237, 8238, 8239, 19671, 8240, 19670, 8241, 19672, 11012, + 19563, 19669, 8242, 13665, 13785, 8243, 8244, 8245, 8246, 8247, 8248, 8249, + 8250, 8251, 8252, 8253, 8254, 8255, 19674, 8256, 8257, 10804, 8258, 8259, + 8260, 8261, 8262, 15389, 19673, 8263, 8264, 8265, 8360, 8361, 8362, 19675, + 8363, 19678, 19679, 8364, 12262, 8365, 8366, 8367, 19680, 8368, 8369, 8370, + 19681, 8371, 8372, 19677, 8373, 19685, 8374, 8375, 8376, 8377, 8378, 8379, + 8380, 8381, 8382, 8383, 8384, 19676, 8385, 19682, 8386, 8387, 8388, 8389, + 8390, 8391, 8392, 8393, 19686, 19683, 19684, 8394, 8395, 8396, 8397, 8398, + 8399, 8400, 8401, 8402, 8403, 8404, 8405, 8406, 8407, 8408, 8409, 19688, + 8410, 8411, 8412, 8413, 8414, 8415, 8416, 8417, 8418, 8419, 8420, 8421, + 8422, 8423, 8424, 8425, 8426, 8427, 8428, 8429, 8430, 8431, 8432, 19687, + 8433, 8434, 8435, 8436, 8437, 8438, 8439, 8440, 8441, 10782, 8442, 21197, + 8443, 21198, 8444, 13221, 9099, 13616, 8445, 14598, 8446, 8447, 8448, 8449, + 8450, 8451, 8452, 14770, 20062, 8453, 8454, 8455, 8550, 20063, 8551, 13236, + 9826, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 20064, 8559, 8560, 8561, + 8562, 16126, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 17664, 8571, + 20065, 8572, 20066, 8573, 20067, 8574, 8575, 8576, 8577, 10587, 17971, + 13860, 8578, 14425, 8579, 8580, 13865, 8581, 8582, 8583, 8584, 8585, 13866, + 8586, 8587, 15710, 14161, 8588, 10551, 21199, 9249, 8589, 19119, 14424, + 15716, 11360, 13849, 8590, 10046, 8591, 12873, 10048, 8592, 20819, 11128, + 8593, 8594, 19537, 8595, 20820, 8596, 8597, 8598, 8599, 9604, 8600, 8601, + 20823, 8602, 8603, 20822, 11566, 8604, 20821, 14748, 8605, 8606, 8607, + 8608, 13062, 8609, 8610, 8611, 8612, 12339, 17241, 20824, 15188, 8613, + 8614, 8615, 8616, 8617, 8618, 8619, 8620, 12497, 13277, 8621, 8622, 8623, + 10367, 8624, 8625, 8626, 8627, 8628, 8629, 8630, 20825, 8631, 9670, 8632, + 8633, 8634, 11206, 20826, 8635, 8636, 8637, 8638, 8639, 19535, 8640, 8641, + 8642, 20827, 8643, 8644, 11509, 8645, 8740, 8741, 8742, 21441, 8743, 8744, + 8745, 14037, 8746, 15526, 21243, 8747, 21244, 8748, 21245, 12293, 8749, + 10622, 11731, 8750, 8751, 21247, 8752, 13032, 21246, 15376, 8753, 21249, + 9069, 11569, 8754, 8755, 8756, 8757, 8758, 15548, 21248, 8759, 9800, 10427, + 21255, 21254, 13208, 21250, 21251, 9820, 8760, 8761, 21252, 16133, 8762, + 8763, 14404, 11735, 11323, 8764, 8765, 8766, 21257, 21256, 21253, 9406, + 8767, 16247, 15699, 11708, 13597, 8768, 8769, 21259, 8770, 8771, 8772, + 8773, 15382, 8774, 16289, 10984, 21258, 8775, 10192, 8776, 8777, 14555, + 8778, 8779, 13211, 8780, 8781, 8782, 12256, 21260, 21263, 8783, 21262, + 21265, 21261, 8784, 11145, 21264, 8785, 8786, 8787, 8788, 14366, 21267, + 8789, 8790, 9648, 8791, 8792, 8793, 8794, 9267, 8795, 8796, 21268, 8797, + 8798, 21269, 21271, 9850, 8799, 21266, 8800, 21272, 8801, 8802, 8803, 8804, + 21275, 8805, 21273, 8806, 8807, 8808, 21270, 8809, 8810, 8811, 8812, 21278, + 8813, 21274, 21277, 21279, 8814, 21376, 8815, 8816, 8817, 14758, 21379, + 8818, 21378, 8819, 12341, 21276, 14026, 8820, 8821, 9866, 9296, 14362, + 8822, 21381, 8823, 8824, 21382, 8825, 8826, 21387, 16101, 21384, 8827, + 8828, 13604, 8829, 8830, 8831, 21377, 8832, 21386, 21383, 21380, 8833, + 8834, 21385, 8835, 8930, 8931, 8932, 8933, 8934, 8935, 8936, 9034, 21388, + 8937, 8938, 8939, 8940, 8941, 8942, 21390, 8943, 21392, 8944, 8945, 8946, + 8947, 8948, 21391, 8949, 21389, 8950, 8951, 8952, 8953, 15297, 8954, 8955, + 8956, 8957, 8958, 8959, 8960, 21393, 8961, 8962, 8963, 21394, 8964, 8965, + 8966, 8967, 8968, 8969, 8970, 8971, 10814, 8972, 8973, 10014, 8974, 9080, + 9082, 8975, 8976, 8977, 15942, 8978, 10011, 8979, 11547, 11157, 21192, + 8980, 8981, 10607, 8982, 8983, 21193, 8984, 8985, 9033, 8986, 21194, 8987, + 8988, 14613, 8989, 8990, 21195, 8991, 8992, 8993, 8994, 8995, 8996, 8997, + 8998, 8999, 9000, 21196, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 9008, + 9009, 13209, 9010, 9011, 16314, 21443, 9012, 21444, 9013, 9014, 9015, 9016, + 9017, 9018, 9019, 9020, 9021, 9022, 12718, 9023, 9024, 15734, 9025, 9120, + 16294, 13087, 9121, 15690, 9122, 15555, 9123, 9124, 20838, 9052, 16076, + 15341, 11369, 10973, 9125, 11963, 9126, 10584, 10008, 13059, 9127, 9128, + 13967, 9129, 9130, 9131, 12678, 9132, 9133, 9134, 9135, 9136, 20839, 9137, + 9138, 9139, 9140, 9141, 9142, 9143, 9144, 12856, 10167, 9145, 20691, 12639, + 9146, 16262, 9147, 9148, 9149, 14979, 20694, 9150, 9151, 13061, 9152, + 10225, 9153, 9154, 13966, 9155, 9156, 20692, 9157, 9158, 20695, 20696, + 12663, 9159, 11895, 9160, 20693, 9161, 9162, 9163, 9164, 9165, 9166, 9167, + 9168, 9169, 9170, 9171, 20699, 20697, 9172, 9173, 9174, 9175, 16125, 12698, + 9176, 20698, 9177, 9178, 9179, 20701, 9180, 16058, 15298, 9181, 9182, 9183, + 20700, 9184, 12683, 9185, 9186, 9187, 9188, 9189, 20702, 11959, 11761, + 20703, 9190, 14432, 9191, 15354, 9192, 9193, 9194, 16472, 16141, 9195, + 20707, 9196, 9197, 9198, 20706, 9199, 9200, 9201, 9202, 9203, 9204, 9205, + 9206, 20704, 20705, 9207, 9208, 9209, 9210, 9211, 9212, 9213, 9214, 20708, + 11691, 9215, 9310, 9311, 9312, 9313, 14170, 20806, 10194, 9314, 20807, + 12857, 9315, 20709, 9316, 9317, 11557, 9444, 9318, 9319, 9320, 9321, 9322, + 9323, 9324, 9325, 9326, 9327, 9328, 9329, 10200, 9330, 9331, 9332, 20810, + 16651, 20808, 20811, 9333, 9334, 9335, 12708, 9677, 9336, 9337, 9338, 9339, + 9340, 9341, 20812, 20809, 14940, 9342, 9343, 20813, 12532, 9344, 9345, + 9346, 9347, 9348, 9349, 9350, 9351, 9352, 9353, 9354, 9355, 20814, 20815, + 9356, 17776, 9357, 9358, 13224, 9359, 13433, 9360, 16330, 10016, 9361, + 14173, 9362, 9363, 9364, 20816, 9365, 9366, 14546, 9367, 20817, 9368, 9369, + 9370, 9371, 9372, 16071, 9373, 20818, 9374, 22361, 9375, 9376, 9377, 9378, + 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 17234, 9388, 9389, + 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9788, 9397, 9398, 9399, 12647, + 21445, 9400, 9401, 9402, 9403, 9404, 13989, 15536, 9405, 16255, 9500, + 21077, 9501, 11741, 9502, 11530, 21078, 10209, 9036, 9503, 9504, 9505, + 9506, 13980, 9507, 9508, 20637, 9509, 20638, 9510, 9511, 9512, 9513, 14814, + 10370, 11958, 20639, 12520, 13791, 9514, 9515, 9516, 9517, 9518, 9519, + 20640, 9520, 9521, 13291, 11894, 9522, 9523, 9524, 20643, 13103, 9525, + 15343, 9526, 16444, 20641, 20642, 9527, 15361, 9528, 20646, 20647, 9529, + 20651, 9530, 9531, 9532, 20655, 9533, 20653, 20661, 16127, 9534, 20656, + 9535, 9536, 20654, 20645, 9537, 9538, 13088, 9539, 9540, 9541, 13243, 9542, + 9543, 13848, 15915, 20648, 20649, 20650, 20652, 9544, 12154, 9545, 9786, + 9546, 9547, 9548, 9549, 10807, 9550, 20663, 9551, 9552, 9553, 9554, 20664, + 9555, 20657, 9556, 20662, 9557, 14813, 9558, 9559, 14177, 20659, 20660, + 9560, 9561, 9562, 9563, 9564, 15000, 9565, 9566, 9567, 9568, 9569, 9570, + 9571, 9572, 9573, 9574, 9575, 9576, 20665, 12337, 15693, 20658, 13608, + 9577, 9578, 9579, 9580, 9581, 9582, 9583, 9584, 11384, 9585, 9586, 9587, + 9588, 13095, 9589, 9590, 9591, 9592, 9593, 9594, 9595, 9690, 9691, 9692, + 20669, 9693, 10054, 9694, 9695, 12466, 9038, 14228, 9696, 9697, 9229, 9698, + 20667, 9699, 9700, 9701, 14610, 10041, 9702, 20668, 20666, 20670, 9703, + 9704, 10065, 9705, 20671, 9706, 20672, 9707, 20675, 9708, 9259, 9709, 9710, + 9711, 9712, 9713, 9714, 9715, 9716, 13101, 11383, 20673, 14373, 9479, 9717, + 9718, 9719, 9720, 20674, 9721, 9722, 9723, 9724, 12900, 9725, 9726, 9822, + 9727, 9728, 9729, 9110, 9730, 9731, 9732, 20678, 12123, 9857, 9733, 9734, + 9735, 9736, 13060, 9737, 9738, 9739, 20676, 11911, 9740, 9741, 9742, 20677, + 9743, 9744, 9745, 9746, 9747, 9748, 9749, 9750, 9751, 9752, 9753, 9754, + 9755, 9756, 12830, 9757, 9758, 9759, 20679, 9760, 9761, 9762, 9763, 9764, + 20680, 9765, 20682, 9766, 9767, 12310, 9768, 9769, 11154, 9770, 9771, 9772, + 9773, 9774, 9775, 11519, 9776, 9777, 9778, 20681, 9779, 9780, 9781, 9782, + 9783, 9784, 9785, 9880, 9881, 9882, 9883, 9884, 9885, 20683, 9886, 9887, + 9888, 9889, 9890, 9891, 9892, 9893, 9894, 9895, 20685, 9896, 9897, 9898, + 9899, 9900, 20684, 9901, 9902, 9903, 9904, 9905, 9906, 9907, 9908, 9909, + 9910, 9911, 9912, 9913, 9914, 9915, 20686, 9916, 9917, 9918, 9919, 9920, + 13995, 20499, 12146, 9921, 13846, 9922, 20500, 13283, 9923, 9924, 9925, + 9926, 20501, 9927, 13282, 20502, 9928, 9929, 9930, 9931, 9932, 9933, 9934, + 9935, 9936, 20505, 9937, 9938, 16505, 20508, 9939, 9940, 20506, 20503, + 20504, 16438, 13856, 14233, 20509, 9941, 20507, 9942, 9943, 14988, 9944, + 20511, 13222, 9945, 9946, 9947, 9948, 11337, 9949, 20510, 9950, 9951, 9952, + 9953, 9954, 9955, 9956, 10002, 11201, 9957, 20512, 9958, 9959, 9960, 9961, + 9962, 16902, 11586, 9963, 9964, 12472, 20513, 9965, 9966, 9967, 9968, + 20514, 9969, 9970, 9971, 9972, 10548, 9973, 9974, 9975, 10070, 10071, + 10072, 10073, 10074, 10075, 10076, 20515, 10077, 10078, 10079, 10080, + 10081, 10082, 10083, 10084, 10085, 10086, 10087, 10088, 20516, 10089, + 10090, 10091, 10092, 10093, 10094, 10095, 10096, 10097, 10098, 10099, + 20517, 10100, 10101, 10102, 10103, 10104, 15752, 16639, 12140, 10105, + 13456, 10969, 10106, 15172, 14184, 10107, 14561, 10108, 10109, 10594, + 10110, 10111, 9307, 10112, 13474, 10113, 16299, 10114, 10115, 10116, 11913, + 12710, 10117, 10118, 21080, 10119, 10120, 12691, 10121, 10122, 10123, + 10124, 10125, 10126, 16501, 10127, 10128, 10129, 21082, 9646, 10130, 13451, + 15372, 10131, 16285, 10132, 21083, 10133, 21081, 10134, 11208, 9633, 10135, + 10136, 10137, 10138, 10139, 10140, 10141, 11548, 10142, 10143, 15523, + 10144, 11179, 10145, 10146, 14916, 10147, 21087, 21086, 10148, 10149, + 21084, 10150, 10151, 10152, 10153, 9639, 10154, 13827, 14171, 10155, 10156, + 10157, 10158, 10159, 21089, 10160, 10161, 9087, 10162, 10163, 16286, 10164, + 10165, 10260, 21088, 10261, 9672, 10262, 10263, 22378, 10264, 10265, 10266, + 10267, 10268, 10269, 10270, 10271, 10272, 10273, 10274, 10275, 10276, + 10277, 10278, 14765, 10279, 10280, 10281, 21187, 10282, 21186, 10283, + 10005, 11363, 11207, 10284, 10614, 10285, 10286, 10287, 10288, 10289, + 10290, 12859, 10291, 10292, 10293, 10294, 10295, 10296, 10297, 10298, + 10299, 10300, 21188, 10301, 10302, 10303, 10304, 10305, 14230, 10306, + 10307, 10308, 10309, 10310, 10311, 10312, 10313, 10314, 10315, 10316, + 10317, 10318, 10319, 10320, 10321, 10322, 10323, 10324, 10325, 10326, + 10327, 10328, 10329, 21191, 10330, 10331, 10332, 15303, 10333, 11716, + 13473, 21397, 21398, 11928, 10334, 10335, 10336, 10337, 9794, 21399, 14562, + 10338, 13447, 16068, 10339, 21400, 10340, 21401, 10341, 10342, 10343, + 10344, 13442, 10345, 10346, 10347, 15489, 16292, 10348, 10349, 21402, + 11544, 9801, 11714, 10350, 10351, 10352, 9845, 14774, 10353, 11938, 21404, + 10354, 10355, 10450, 10451, 11965, 21403, 10452, 21406, 10453, 10454, + 10455, 21405, 21407, 10456, 10457, 10458, 10459, 10460, 21408, 10461, + 10462, 10463, 10464, 10465, 10466, 10467, 10468, 10469, 10470, 10471, + 12349, 10472, 10473, 10474, 10475, 10476, 10477, 10478, 10479, 10480, + 10481, 10482, 12257, 10483, 10484, 10485, 10486, 10487, 10488, 10489, + 10490, 10491, 10492, 14055, 10493, 10494, 16085, 10495, 10496, 10497, + 10498, 11711, 11710, 16089, 10499, 10500, 11877, 10501, 14550, 21396, + 10502, 10503, 10504, 10505, 10506, 10507, 11558, 10508, 10208, 10509, + 10510, 10511, 10512, 10513, 10514, 10515, 10516, 10517, 16326, 21790, + 10518, 10519, 21791, 10520, 10590, 10521, 10522, 10523, 21793, 21794, + 10524, 9067, 10525, 21792, 10526, 21796, 14236, 10527, 10528, 10529, 21798, + 10530, 15111, 10531, 10532, 9257, 21795, 10533, 10534, 10535, 21802, 10536, + 10024, 10537, 10538, 21810, 10539, 21805, 10540, 10541, 10542, 21807, + 21806, 10446, 10543, 9246, 10544, 21801, 21797, 10033, 10545, 21803, 10640, + 10641, 21804, 10642, 21808, 10643, 10644, 10645, 10646, 21800, 10647, + 11372, 10648, 12348, 10649, 21809, 10650, 10651, 10652, 10653, 10654, + 10655, 21813, 10656, 21799, 10657, 10015, 10658, 11573, 21815, 10659, + 10660, 10359, 11955, 16339, 14553, 10661, 9865, 10662, 9468, 10663, 21811, + 10664, 21812, 13799, 10665, 21816, 10666, 10667, 21817, 10668, 21820, + 10669, 10670, 10671, 10672, 10673, 10674, 10675, 10676, 10677, 10678, + 10679, 21818, 10680, 10681, 21822, 21821, 10682, 10683, 21814, 10684, + 11949, 10685, 9674, 10686, 21819, 10687, 10688, 13404, 10689, 11387, 10690, + 10691, 10692, 10693, 21830, 10694, 10695, 10696, 10697, 10698, 10699, + 10700, 10766, 10701, 10702, 21823, 10703, 10704, 10705, 9418, 11209, 10706, + 14222, 10707, 10708, 10709, 10710, 21832, 21828, 10711, 10712, 10713, + 10795, 21833, 10714, 10715, 10716, 21824, 21825, 21829, 12510, 21831, + 21834, 21827, 11398, 10717, 10718, 10719, 14983, 10720, 10721, 21835, + 10722, 10723, 10724, 21826, 10725, 10726, 10727, 10728, 10729, 10730, + 10731, 10732, 21837, 10733, 10734, 10735, 10830, 16448, 13215, 10831, + 10832, 10833, 10834, 21838, 10835, 10836, 10837, 10838, 21836, 10839, + 12453, 10840, 10841, 10842, 10843, 10844, 10606, 21840, 10845, 10846, + 21839, 10847, 10848, 10849, 9844, 10850, 10851, 10852, 21841, 21842, 10853, + 10854, 10855, 21843, 10856, 10857, 10858, 12091, 10859, 10860, 12138, + 10861, 10862, 10863, 10864, 10865, 13096, 10866, 10867, 10868, 10869, + 21846, 10870, 21845, 10871, 10872, 10873, 10874, 10875, 10876, 10877, + 10878, 9841, 10879, 10880, 10881, 21849, 21844, 10882, 10883, 21847, 10884, + 10885, 10886, 10887, 10888, 10889, 21848, 10890, 10891, 10892, 10893, + 10894, 10895, 10896, 10897, 21946, 10898, 10899, 10900, 10901, 10902, + 10903, 21948, 11156, 10904, 10905, 21947, 10906, 10907, 10908, 10909, + 10910, 10911, 10912, 10913, 10914, 10915, 10916, 10917, 10918, 21949, + 10919, 10920, 10921, 10922, 10923, 10924, 9435, 21951, 21950, 10925, 11020, + 11021, 11022, 11023, 11024, 11025, 11026, 11027, 11028, 11029, 11319, + 11030, 11031, 11032, 11033, 11034, 11035, 11036, 11037, 11038, 11039, + 11040, 11041, 11042, 11043, 11044, 11045, 11046, 11047, 11048, 11049, + 11050, 11051, 11052, 11053, 11054, 11055, 11056, 11057, 11058, 11059, + 11060, 11061, 11062, 11063, 11064, 11065, 11066, 12690, 16880, 11067, + 11068, 11069, 11070, 11071, 11072, 12129, 21989, 16484, 11073, 11074, + 11075, 11076, 11077, 11078, 11079, 11080, 11081, 11082, 11083, 10414, + 11084, 11085, 11086, 11087, 11088, 11089, 11090, 21991, 12258, 11091, + 11092, 13246, 11093, 9839, 16074, 11094, 11095, 11096, 21993, 21992, 21994, + 14213, 11097, 11098, 21995, 11099, 15898, 16309, 11100, 11101, 11102, + 11103, 10419, 11104, 11105, 11106, 12279, 11107, 11108, 12282, 21996, + 11697, 11109, 11110, 11111, 11112, 11113, 9851, 11114, 11115, 21997, 21998, + 11696, 11210, 11211, 21999, 11212, 11213, 11214, 22004, 11215, 22000, + 22003, 11216, 11018, 11217, 22001, 22002, 11218, 11219, 11220, 11221, + 11222, 11223, 11224, 10611, 14384, 22005, 11225, 9463, 11226, 11227, 12686, + 11228, 11229, 15932, 11898, 11230, 11231, 11232, 11233, 11234, 11235, + 11236, 22006, 11237, 11238, 11239, 11240, 11241, 11242, 13035, 11243, + 11244, 11245, 11246, 11247, 11248, 11249, 11250, 22018, 11251, 11252, + 14936, 11253, 11254, 11255, 11256, 11257, 11258, 11259, 11260, 11261, + 11262, 11263, 11264, 11265, 11266, 14766, 11267, 11268, 11269, 11270, + 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278, 11279, 11280, + 11281, 11282, 11283, 11284, 11285, 11286, 11287, 14211, 11288, 14242, + 11289, 11290, 11291, 11292, 11579, 11293, 11294, 11295, 16482, 11296, + 11297, 11298, 12124, 11299, 11300, 11301, 11302, 11303, 11304, 11305, + 11400, 11401, 11402, 11403, 11404, 11405, 11406, 11407, 11408, 11409, + 11410, 11411, 11412, 11413, 11414, 11415, 11416, 11417, 11418, 11419, + 11420, 11421, 11422, 11423, 11424, 11425, 11426, 11427, 11428, 11429, + 11430, 11431, 11432, 11433, 11434, 11435, 11436, 11437, 11438, 11439, + 11440, 11441, 11442, 11443, 11444, 11445, 11446, 11447, 11448, 11449, + 11450, 11451, 11452, 11453, 11454, 15190, 11455, 11456, 11457, 11458, + 11459, 11460, 11461, 11462, 22019, 11463, 11464, 11465, 11466, 11467, + 11468, 11469, 11470, 11471, 11472, 11473, 11474, 11475, 11476, 11477, + 11478, 11479, 11480, 11481, 11482, 11483, 11484, 11485, 11486, 11487, + 11488, 11489, 11490, 11491, 11492, 11493, 11494, 11495, 11590, 11591, + 11592, 11593, 11594, 11595, 11596, 11597, 11598, 11599, 11600, 11601, + 11602, 22020, 11603, 11604, 11605, 11606, 11607, 11608, 11609, 22021, + 11610, 11611, 11612, 11613, 11614, 11615, 11616, 11617, 11618, 11619, + 11620, 11621, 11622, 11623, 11624, 11625, 11626, 11627, 11628, 11629, + 11630, 11631, 11632, 11633, 11634, 11635, 11636, 11637, 11638, 11639, + 11640, 11641, 11642, 11643, 11644, 11645, 11646, 11647, 11648, 11649, + 11650, 11651, 11652, 11653, 11654, 11655, 11656, 11657, 11658, 11659, + 11660, 11661, 11662, 11663, 11664, 11665, 11666, 11667, 11668, 11669, + 11670, 11671, 11672, 11673, 11674, 11675, 11676, 11677, 11678, 11679, + 11680, 11681, 11682, 11683, 11684, 11685, 11780, 11781, 11782, 11783, + 11784, 11785, 11786, 11787, 11788, 11789, 11790, 11791, 11792, 11793, + 11794, 11795, 11796, 11797, 11798, 11799, 11800, 11801, 11802, 11803, + 11804, 11805, 11806, 11807, 11808, 11809, 11810, 11811, 11812, 11813, + 11814, 11815, 11816, 11817, 11818, 11819, 11820, 11821, 11822, 11823, + 11824, 11825, 11826, 11827, 11828, 11829, 11830, 11831, 11832, 11833, + 11834, 11835, 11836, 11837, 11838, 11839, 11840, 11841, 11842, 11843, + 22582, 11844, 11845, 11846, 11847, 11848, 10372, 11849, 11850, 11851, + 11852, 11853, 22022, 11854, 11855, 11856, 11857, 11858, 11859, 11860, + 11861, 11862, 11863, 11864, 11865, 11866, 11867, 11868, 11869, 11870, + 11871, 11872, 11873, 11874, 11875, 11970, 11971, 11972, 11973, 11974, + 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984, + 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, + 11995, 11996, 11997, 11998, 11999, 12000, 12001, 12002, 12003, 12004, + 12005, 16510, 12006, 12007, 12008, 12009, 12010, 12011, 12012, 12013, + 12014, 12015, 12016, 12017, 12018, 12019, 12020, 12021, 12022, 12023, + 12024, 12025, 12026, 12027, 12028, 12029, 22023, 12030, 12031, 12032, + 19374, 11717, 19375, 11001, 19376, 14958, 19377, 15893, 11327, 19378, + 19379, 11350, 13635, 14744, 19476, 12033, 9816, 19477, 13795, 10602, 12866, + 12034, 16496, 12503, 10410, 16274, 14763, 10391, 12035, 12036, 13021, + 19478, 14978, 19479, 19480, 19481, 12278, 16508, 13855, 14939, 16260, + 16298, 19482, 9102, 19483, 19484, 13835, 15564, 11698, 19485, 9108, 13647, + 11560, 19486, 13623, 12037, 19487, 11185, 10633, 15299, 19488, 12516, + 11773, 11537, 14554, 19489, 19490, 11763, 15174, 12038, 14226, 14393, + 11349, 19491, 11313, 15192, 19492, 12039, 15193, 19493, 19494, 9819, 19495, + 19496, 13869, 14737, 12699, 19498, 9248, 9676, 12040, 19499, 19500, 16494, + 16087, 19501, 12489, 16461, 19502, 19503, 19504, 11379, 12704, 12099, + 19505, 19506, 11314, 12041, 19507, 19508, 19497, 10213, 19509, 12042, + 19510, 19511, 11141, 10037, 12483, 9279, 19512, 15886, 19513, 10576, 19515, + 19514, 10431, 12043, 19516, 9493, 19517, 19518, 19519, 19520, 19521, 19522, + 19523, 15682, 14240, 19524, 19525, 19526, 19527, 13816, 19528, 19529, + 19530, 19531, 19532, 11536, 19533, 21785, 12044, 10600, 12045, 13602, + 12046, 12047, 12048, 12049, 12050, 12051, 12052, 21786, 12053, 21787, + 21788, 12054, 12055, 12056, 12057, 12058, 12059, 12060, 12061, 12062, + 12063, 10797, 14623, 12064, 12065, 16697, 10942, 12160, 12507, 20828, + 12161, 10358, 12162, 12163, 12164, 12165, 20830, 12166, 20829, 9078, 12167, + 12168, 12169, 12170, 12171, 20832, 16109, 16514, 12172, 12173, 12174, + 16280, 12175, 12176, 20834, 14045, 12177, 20833, 12178, 12179, 12180, + 12181, 20835, 12182, 12183, 12184, 12185, 20837, 12186, 12187, 20836, + 12188, 12189, 12190, 12191, 12192, 12193, 12194, 12195, 15377, 12196, + 13423, 12197, 12667, 12198, 12199, 12200, 12201, 12202, 10610, 12203, + 12204, 12205, 12206, 12207, 12326, 12208, 12209, 21983, 15168, 21984, + 12210, 14974, 12211, 12212, 13611, 12213, 12214, 21985, 12215, 12216, + 12217, 12218, 12219, 12220, 12221, 21986, 21987, 12222, 21988, 12223, + 12224, 12225, 12226, 12227, 16905, 10639, 12228, 12229, 19176, 15755, + 12230, 22009, 12231, 14769, 12232, 12233, 12234, 9660, 12235, 12236, 12237, + 12238, 21395, 12239, 15563, 12240, 22010, 12241, 12242, 12243, 12244, + 12245, 14987, 22011, 12246, 12247, 13439, 12248, 12249, 12250, 12251, + 12252, 12253, 10027, 9853, 22013, 12254, 12255, 12350, 22012, 22014, 12351, + 12352, 22015, 12353, 12354, 12355, 12356, 22016, 12357, 10943, 9056, 12358, + 22017, 12359, 12360, 12361, 12362, 12363, 12364, 12365, 10368, 15562, + 12366, 12367, 12368, 15496, 12112, 12369, 11903, 20238, 16118, 20085, + 12370, 12371, 12372, 12373, 21458, 10253, 14158, 12374, 12375, 12870, + 12376, 21446, 12377, 21447, 10636, 21448, 10961, 15902, 9075, 12378, 12379, + 21449, 12380, 12381, 12382, 21450, 12383, 21451, 12384, 12385, 21452, + 21453, 21454, 21456, 21455, 13068, 12386, 12387, 12388, 12389, 12390, + 12391, 21457, 12392, 10255, 12393, 21459, 15499, 17804, 14197, 12394, + 12395, 9655, 12396, 9977, 12397, 10737, 12398, 12399, 12909, 21460, 12400, + 12401, 21461, 12402, 12403, 12404, 12291, 12346, 16261, 21462, 12405, + 12406, 12407, 12408, 21463, 12409, 12265, 12410, 12411, 12412, 13229, + 12413, 11744, 12414, 12415, 12416, 12417, 12418, 12419, 12420, 12421, + 12422, 12423, 12424, 12425, 12426, 12427, 21464, 9832, 12428, 12429, 12430, + 12431, 12432, 12433, 21465, 12434, 12435, 12436, 12437, 12438, 12439, + 12440, 12441, 12442, 12443, 12444, 12445, 12540, 20633, 20632, 12541, + 12542, 14219, 15547, 12543, 14188, 16111, 12544, 13651, 12545, 12128, + 11306, 12546, 12547, 12548, 12549, 12550, 12551, 20268, 12552, 12553, + 15109, 12554, 16311, 12555, 10204, 10601, 20267, 10591, 12556, 20266, 9601, + 10776, 16256, 12557, 10439, 10397, 12558, 12559, 12560, 11376, 10385, + 20273, 12561, 20274, 9050, 11922, 12562, 20272, 15768, 12563, 20275, 12564, + 12565, 20276, 12566, 12567, 10401, 12568, 20269, 20271, 13861, 16300, + 16100, 15123, 20282, 14749, 20283, 12569, 9983, 12570, 12571, 12572, 12573, + 12574, 9234, 20285, 14350, 12575, 12576, 12577, 12578, 12579, 12580, 12581, + 13069, 20286, 12582, 20284, 13078, 20281, 13969, 20288, 9116, 12583, 12584, + 11015, 12585, 12586, 16648, 21442, 12587, 20277, 20278, 20279, 20280, + 20289, 19317, 20292, 12588, 11947, 15525, 20290, 20295, 10621, 20291, + 12589, 11521, 12590, 15161, 12591, 9048, 12592, 20296, 12885, 12593, 12594, + 12595, 12596, 16257, 12597, 12598, 12599, 9849, 12600, 12601, 12531, 11330, + 12602, 12603, 20293, 20294, 15929, 13279, 12877, 20298, 13022, 16900, + 12604, 9422, 12605, 20303, 12606, 11532, 12607, 12608, 12609, 20301, 12610, + 12611, 12612, 12613, 12614, 12615, 12616, 12617, 12618, 12619, 12620, + 12621, 12622, 20302, 12623, 12624, 10557, 12625, 14584, 20304, 12626, + 12627, 12628, 20300, 12629, 12274, 12630, 12631, 12632, 12633, 12634, + 13207, 12635, 12730, 12731, 12732, 12733, 12734, 12735, 14428, 12736, + 20305, 12737, 12081, 15509, 20306, 12738, 12739, 12740, 10560, 10558, + 12741, 20307, 13422, 14618, 12742, 12743, 12744, 20309, 20310, 12745, + 12746, 12747, 12748, 12749, 20312, 12750, 12751, 12752, 12753, 15145, + 12754, 20317, 12755, 20313, 12756, 12757, 12758, 20316, 13674, 12759, + 15387, 20311, 12760, 12761, 20308, 12762, 12763, 12764, 12765, 10570, + 14972, 12894, 20314, 20315, 14403, 14575, 9107, 12766, 20321, 12767, 12768, + 12769, 12770, 12771, 20320, 12772, 9423, 12773, 12774, 12775, 12776, 10609, + 12777, 20322, 12778, 12779, 12780, 12781, 12782, 12783, 9291, 12784, 12785, + 14382, 12829, 14920, 12786, 12787, 12788, 12789, 12790, 20324, 12791, + 12792, 20427, 12793, 13097, 12794, 20325, 12795, 12796, 12797, 12798, + 12799, 12800, 12801, 12802, 13812, 12803, 12804, 12805, 12806, 12807, + 12808, 18588, 20329, 12809, 12810, 12811, 12812, 14581, 20426, 9274, 15698, + 12813, 12814, 15545, 12815, 12816, 12817, 20328, 12818, 20326, 12819, + 12820, 12821, 12822, 12823, 12824, 12825, 12920, 12921, 12922, 12923, + 12924, 12925, 12926, 12927, 12928, 12929, 12930, 12931, 12932, 12933, + 12934, 9623, 12935, 12936, 12937, 20061, 12938, 12939, 16487, 12940, 21956, + 9679, 12941, 12942, 12943, 12944, 12945, 16278, 16279, 12946, 12947, 12948, + 12949, 12950, 12951, 16128, 11727, 12952, 21952, 12953, 15493, 21953, + 21954, 12954, 21955, 11728, 15738, 12955, 12956, 12957, 12958, 12959, + 13839, 13840, 12960, 12961, 21789, 12962, 14035, 12963, 14427, 12964, + 12965, 12966, 12967, 12968, 12969, 18547, 14175, 12970, 14797, 16304, + 12971, 21958, 21959, 21960, 12972, 12973, 12974, 12975, 21963, 12976, + 10954, 21964, 9092, 21961, 12977, 21962, 11497, 9458, 12978, 21967, 21968, + 10235, 9421, 14962, 21965, 9797, 12979, 21966, 12980, 12981, 21969, 12982, + 12983, 12984, 12985, 12986, 21970, 12987, 12988, 14542, 12989, 21971, + 12990, 21972, 12991, 12992, 12993, 21973, 12994, 12995, 12996, 12997, + 12998, 12999, 13000, 13001, 14205, 13002, 21974, 13003, 13004, 13005, + 13006, 21975, 13007, 13008, 13009, 13010, 13011, 13012, 13013, 13014, + 21976, 13015, 13110, 13111, 13112, 13113, 22007, 12283, 11377, 13114, + 13786, 15357, 19180, 13115, 13116, 13117, 13118, 17404, 15538, 13119, + 13120, 17405, 9037, 17406, 13121, 13122, 11553, 13123, 17410, 13124, 13125, + 13126, 16659, 13127, 17408, 15758, 13128, 13829, 17411, 17407, 13129, + 17412, 12637, 13130, 13131, 13132, 13133, 17413, 17422, 17414, 13134, + 13135, 14788, 16250, 13136, 17432, 13137, 17430, 13138, 13139, 17435, + 11565, 12456, 13140, 17409, 17428, 17431, 17415, 10405, 9062, 17424, 15135, + 17418, 11123, 13141, 10383, 17429, 13142, 13143, 17423, 17416, 13454, + 13144, 13145, 13146, 15326, 17417, 13147, 13148, 17427, 13149, 13150, + 17433, 13151, 13152, 14738, 17419, 13153, 17420, 17425, 17426, 9457, 17434, + 14208, 13154, 15888, 17444, 17448, 14351, 17455, 13155, 12706, 17445, + 13156, 13157, 11908, 17442, 13158, 9115, 10757, 17454, 17436, 13159, 17421, + 17439, 13669, 11939, 13160, 13161, 13162, 13163, 13802, 13164, 13165, + 13166, 9244, 13167, 15677, 13168, 13169, 17443, 13170, 13171, 17438, 13172, + 13232, 13173, 17447, 13174, 13175, 13176, 13177, 13178, 16469, 12650, + 10377, 13444, 12644, 17451, 17441, 17460, 17437, 13179, 13180, 17446, + 13181, 11690, 17440, 13182, 17449, 13183, 13184, 17452, 17453, 13185, + 17473, 13186, 13187, 17450, 17577, 17456, 13188, 13189, 13190, 13191, + 13192, 13193, 13194, 13195, 13196, 13197, 11380, 9821, 13198, 13199, 12638, + 9476, 17475, 13200, 17467, 13201, 17464, 13202, 17477, 17463, 15565, 9477, + 13203, 13640, 13652, 17476, 13204, 17462, 13205, 13300, 13301, 17472, + 13302, 13303, 17470, 13304, 13305, 11688, 17469, 13306, 9466, 13307, 13308, + 13309, 13310, 13311, 17468, 11391, 17457, 11151, 13312, 12148, 13313, + 13314, 13315, 13316, 13317, 11357, 17458, 17459, 13318, 17466, 17471, + 17474, 9995, 13319, 13642, 11186, 17479, 17478, 15686, 17576, 17578, 17580, + 15566, 17579, 17581, 17582, 15494, 13320, 13321, 13322, 13323, 13324, + 13325, 13326, 10966, 17584, 13327, 13328, 17597, 17592, 17595, 13329, + 13330, 13331, 13332, 13333, 13334, 13335, 17591, 13251, 13336, 13337, + 12147, 13338, 13339, 13340, 13341, 13790, 13342, 13343, 13344, 17461, + 17589, 13345, 13346, 13347, 13348, 17598, 13349, 13350, 17465, 17590, + 13351, 17599, 13352, 17587, 13353, 13354, 13355, 13356, 13357, 13358, + 13359, 17600, 17594, 17588, 12835, 13360, 13361, 13362, 13363, 17583, + 12084, 12266, 17585, 17586, 13364, 17593, 11196, 17596, 15683, 17601, + 13365, 17602, 12642, 13366, 13367, 17625, 17603, 13368, 13369, 13370, + 17624, 13371, 10764, 13372, 13373, 11738, 13374, 11775, 13375, 13376, + 10967, 13377, 13378, 13379, 13380, 17617, 13381, 17612, 13382, 17606, + 13383, 13384, 13385, 9448, 17610, 13386, 17618, 9409, 17628, 13387, 13388, + 13389, 17605, 13390, 13391, 13392, 13253, 17623, 13393, 13394, 13395, + 13490, 13491, 17627, 12321, 10393, 13492, 13493, 13494, 13495, 13496, + 17621, 17622, 13497, 13498, 13499, 17611, 13500, 13501, 13502, 17604, + 13503, 17620, 14394, 13504, 17616, 13505, 13506, 13507, 13508, 17609, + 12675, 13233, 14739, 17619, 13509, 17615, 13510, 13511, 13512, 13513, + 13514, 13515, 17608, 13516, 13517, 13518, 17613, 12505, 13519, 13520, + 13521, 13522, 13523, 13524, 15684, 15685, 17626, 14999, 13673, 13525, + 13526, 13527, 13528, 13529, 13530, 13531, 13532, 17645, 13533, 13534, + 13535, 13536, 13537, 13538, 17614, 13539, 13540, 13541, 17639, 12513, + 13542, 13543, 13544, 13545, 13546, 13547, 13548, 13549, 17640, 13550, + 13551, 13552, 13553, 13554, 13555, 13556, 13557, 13558, 13559, 17630, + 13560, 13561, 13562, 13563, 13564, 16333, 13565, 17632, 17631, 10625, + 17629, 13566, 13567, 13568, 13569, 13252, 13570, 10178, 13571, 13572, + 13573, 13574, 13575, 17641, 13576, 11014, 15930, 17646, 13577, 13578, + 13579, 9833, 13580, 17633, 13581, 11966, 17642, 13582, 17638, 13583, 17636, + 13584, 13585, 13680, 13681, 13682, 13683, 13684, 10032, 13685, 13686, + 13687, 13688, 17634, 17635, 17637, 13689, 11510, 17643, 13690, 17644, + 13691, 13692, 13693, 13694, 13695, 13696, 13697, 13698, 17660, 13699, + 12676, 13700, 13701, 14221, 13702, 13703, 13704, 13705, 17657, 13706, + 13707, 13708, 13709, 13710, 13711, 13712, 13713, 13714, 13715, 13716, + 13717, 13718, 16690, 13719, 13720, 13254, 13721, 17659, 13722, 13723, + 13724, 16139, 17658, 17655, 13725, 13726, 17651, 13727, 17654, 13728, + 17647, 13729, 13730, 15183, 13731, 13732, 13733, 13734, 13641, 17653, + 13735, 13736, 17648, 13737, 13738, 17649, 14237, 13739, 17652, 13740, + 13741, 9260, 13742, 13743, 13744, 13745, 13746, 13747, 12087, 13748, 11332, + 17656, 13749, 13750, 17662, 13751, 17661, 17650, 13752, 13753, 13754, + 13755, 13756, 13093, 13757, 13758, 13759, 17666, 13760, 13761, 13762, + 13763, 13764, 13765, 13766, 13767, 13768, 13769, 13770, 17769, 13771, + 13772, 17768, 13773, 13774, 13775, 13870, 13871, 13872, 13873, 13874, + 13875, 13876, 13877, 13878, 17663, 13879, 13880, 13881, 13882, 12714, + 13883, 12536, 13884, 13885, 13886, 16120, 13887, 13888, 14746, 13889, + 13890, 13891, 13892, 17668, 13893, 9449, 13894, 13895, 13896, 13897, 13898, + 13899, 13900, 13901, 13902, 12897, 14028, 13903, 13904, 13905, 13906, + 13907, 13908, 13909, 13910, 13911, 13912, 13425, 17665, 17667, 17669, + 17767, 9035, 9261, 13913, 13914, 13915, 13916, 13917, 17777, 13918, 13919, + 13920, 13921, 17771, 11517, 13664, 13922, 13923, 13924, 13925, 13926, + 13927, 13928, 13929, 13930, 13931, 13932, 17766, 13933, 13934, 17770, + 13935, 13936, 13937, 13938, 17774, 13939, 13940, 13941, 13942, 13943, + 17773, 13944, 13945, 13946, 17772, 13947, 13948, 13949, 13950, 13951, + 13952, 13953, 13954, 13955, 17778, 13956, 15909, 13957, 13958, 13959, + 13960, 17784, 17775, 17779, 13961, 13962, 12122, 13963, 13964, 13965, + 14060, 14061, 9216, 17787, 14062, 17782, 14063, 14064, 14065, 14066, 14067, + 14068, 14069, 17783, 14070, 14071, 14072, 14073, 14074, 14075, 14076, + 14077, 14078, 14079, 14080, 15301, 17786, 14081, 14082, 14083, 14084, + 14085, 14086, 14087, 17780, 14088, 14089, 14090, 17781, 14091, 15134, + 14092, 14093, 14094, 17785, 14042, 17790, 14095, 14096, 14097, 14098, + 14099, 14100, 17789, 14101, 17788, 14102, 14103, 14104, 14105, 14106, + 14107, 14108, 17792, 14109, 14110, 14111, 14112, 14113, 14114, 14115, + 11564, 14116, 14117, 14118, 14119, 14120, 9461, 12709, 14121, 14122, 17791, + 14123, 13041, 14124, 14125, 14126, 14127, 14128, 14129, 17793, 14130, + 14131, 14132, 14133, 14134, 14135, 14136, 14402, 14137, 14138, 14139, + 14140, 10365, 14141, 14142, 14143, 14144, 14145, 14146, 14147, 14148, + 14149, 14150, 14151, 14152, 14153, 14154, 14155, 14250, 14251, 15934, + 14252, 14253, 14254, 17794, 14255, 14256, 14257, 14258, 14259, 17796, + 14260, 14261, 14262, 14263, 14264, 14265, 14266, 14267, 14268, 14269, + 14270, 12827, 14271, 14272, 14273, 14274, 17798, 14275, 14276, 14277, + 14278, 14279, 14280, 14281, 14282, 14283, 14284, 14285, 14286, 14287, + 14288, 14289, 14290, 17795, 14291, 17797, 14292, 14293, 14294, 14295, + 14296, 14297, 14298, 14299, 14300, 14301, 14302, 14303, 14304, 14305, + 16081, 14306, 14307, 14308, 17799, 14309, 14310, 14311, 14312, 14313, + 14314, 14315, 14316, 14317, 14318, 14319, 14320, 14321, 14322, 14323, + 14324, 21579, 11117, 12463, 13031, 12484, 14325, 14326, 21580, 14327, + 14328, 14329, 14330, 14331, 15178, 14332, 14333, 14334, 15736, 14335, + 14336, 14337, 20264, 14338, 14339, 14340, 14341, 14342, 14343, 14344, + 14345, 9665, 21581, 14440, 21582, 14441, 14442, 13978, 14443, 14444, 14445, + 14446, 14447, 14448, 14449, 10996, 21584, 21586, 21585, 14223, 14941, + 21583, 13985, 15532, 12521, 14450, 14451, 14452, 14453, 14454, 14455, + 14456, 14760, 21589, 9111, 21588, 14457, 14458, 14459, 14460, 14461, 21595, + 14462, 9452, 14463, 14464, 14465, 14466, 14467, 14468, 15328, 21591, 14469, + 14470, 14471, 14472, 14473, 21593, 15938, 14474, 14475, 21592, 21587, + 21596, 21594, 14476, 21590, 14477, 14478, 21604, 21601, 21603, 14479, + 14480, 21607, 21599, 21597, 14481, 14482, 14483, 21602, 14484, 14485, + 14486, 14487, 14488, 16336, 14489, 14490, 14491, 21598, 14492, 13484, + 13838, 14493, 21605, 10773, 9991, 14494, 14495, 21600, 21606, 21613, 21619, + 14496, 14497, 11170, 14498, 14499, 14500, 21618, 14595, 14501, 16320, + 14502, 14503, 21615, 21617, 14504, 14505, 14506, 14507, 10627, 14508, + 14509, 14510, 14511, 21608, 14512, 14513, 14514, 21611, 12534, 14515, + 16116, 21609, 21610, 21612, 21616, 14516, 14517, 14518, 21622, 15703, + 14519, 14520, 14521, 14522, 10239, 14523, 14046, 14524, 10423, 21620, + 14525, 14526, 14527, 21621, 21623, 21626, 21624, 14528, 14529, 21625, + 14530, 14531, 14532, 14533, 15344, 21614, 14534, 14576, 14535, 14772, + 16254, 14630, 21632, 14631, 12694, 14632, 21629, 14633, 14634, 12080, + 21641, 21627, 14635, 21630, 14636, 14637, 14638, 21637, 14639, 14640, + 14641, 14642, 21631, 14643, 14644, 21636, 14645, 14646, 21635, 14647, + 14648, 21638, 14649, 14650, 14651, 21628, 14652, 14653, 21633, 21639, + 14654, 14655, 14656, 14657, 14658, 14659, 14660, 15687, 21634, 9490, 14661, + 14662, 21647, 14663, 15116, 14664, 14665, 14666, 14667, 21650, 14668, + 14669, 14670, 11155, 14671, 21654, 14672, 14673, 14674, 14675, 14676, + 14677, 21645, 14678, 14679, 21651, 21653, 21655, 14680, 14681, 14682, + 14683, 14684, 14685, 14686, 14687, 21648, 14688, 21646, 14689, 14690, + 14691, 11016, 14692, 10066, 14693, 14694, 14695, 14696, 21644, 21652, + 21642, 21643, 14697, 14698, 14699, 21640, 21761, 14700, 21758, 14701, + 14702, 21757, 14703, 14704, 21649, 14705, 13643, 14706, 14707, 14708, + 14709, 14710, 21656, 14711, 14712, 14713, 21760, 14714, 14715, 14716, + 14717, 14718, 14719, 14720, 12723, 14721, 14722, 14723, 14724, 14725, + 14820, 14821, 14822, 21658, 14823, 14824, 21762, 21764, 21759, 14825, + 21657, 14826, 14827, 14828, 21766, 14829, 21765, 14830, 14831, 14832, + 14833, 12506, 14834, 14835, 21769, 14836, 14837, 21771, 14838, 14839, + 14840, 14841, 14842, 21756, 14843, 14844, 14845, 21772, 21767, 14846, + 14847, 14848, 14849, 14850, 21770, 21659, 21768, 14851, 14852, 14853, + 14854, 14855, 14856, 14857, 21773, 14858, 14859, 14860, 14861, 21775, + 14862, 14863, 14864, 14865, 21763, 14866, 14867, 14868, 14869, 21774, + 14870, 14871, 14872, 21776, 14873, 14874, 14875, 14876, 14877, 14878, + 14879, 14880, 14881, 14882, 15128, 14883, 14884, 14885, 14886, 21779, + 14887, 14888, 14889, 14890, 16904, 14891, 14892, 14893, 14894, 14895, + 14896, 21780, 14897, 14898, 14899, 14900, 14901, 14902, 14903, 14904, + 21778, 14905, 13653, 21777, 14906, 14907, 14908, 14909, 21781, 14910, + 14911, 14912, 14913, 14914, 21782, 9817, 14915, 15010, 15011, 15012, 15013, + 15014, 15015, 15016, 15017, 15018, 15019, 15020, 15021, 15022, 15023, + 20840, 15024, 15025, 15026, 15027, 15028, 15029, 21783, 15030, 15031, + 21784, 15032, 15033, 15034, 15305, 15035, 15036, 15037, 21957, 15143, + 15038, 15039, 15040, 15041, 15042, 15043, 15153, 15355, 15044, 15045, + 15046, 15047, 15048, 15049, 14961, 15050, 15051, 11549, 15052, 15330, + 15053, 15054, 15055, 15056, 15057, 15058, 15059, 10991, 18408, 15519, + 21409, 9430, 15060, 15061, 9292, 21410, 15062, 13807, 9631, 15063, 16897, + 15064, 14160, 15065, 21411, 15066, 15067, 15068, 15069, 16297, 15070, + 15071, 15072, 15073, 15074, 21412, 21977, 21413, 15075, 15877, 21414, + 15076, 9057, 21978, 15077, 15078, 21979, 15079, 15080, 9877, 15081, 13074, + 15082, 15083, 15084, 15085, 14372, 15086, 15087, 15088, 15173, 15089, + 15090, 15091, 15092, 15093, 14599, 15094, 15095, 15096, 15097, 15098, + 21415, 15099, 16898, 15100, 15101, 15102, 15103, 15104, 15105, 9242, 15200, + 14929, 15201, 15202, 15203, 10549, 15204, 15205, 15206, 15207, 15208, + 21417, 15209, 15210, 15211, 15212, 21418, 15213, 15214, 15215, 15216, 9440, + 12304, 15217, 15218, 16451, 21416, 15219, 15220, 21419, 15221, 15222, + 15223, 15224, 21421, 15225, 15226, 15227, 16901, 15228, 15550, 15868, + 15229, 15230, 21980, 13610, 15231, 15232, 15233, 15234, 15235, 21981, + 15236, 15237, 21420, 21422, 11942, 21423, 15238, 15239, 21427, 15240, + 15241, 15242, 15243, 15244, 15245, 15246, 21429, 21424, 15247, 13824, + 13080, 15248, 15249, 15250, 12512, 10827, 15251, 15252, 21426, 15253, + 21428, 15254, 15255, 15256, 10786, 15257, 15258, 15259, 15260, 15261, + 15262, 15263, 21434, 15264, 15265, 15266, 15267, 15268, 10979, 15269, 9118, + 21432, 15270, 15271, 15272, 15273, 15274, 21431, 21425, 21433, 15275, + 15276, 15277, 15278, 15279, 21430, 15280, 15281, 15282, 13661, 15283, + 15284, 15285, 15286, 14577, 21436, 15287, 15288, 15289, 15290, 19124, + 15291, 15292, 15293, 21435, 15294, 21437, 15295, 15390, 15391, 15392, + 15393, 15394, 15395, 15396, 15397, 15398, 21438, 15399, 15400, 14984, + 15401, 15402, 15403, 15404, 15405, 15406, 15407, 15408, 15409, 15410, + 15411, 15412, 15413, 15414, 15415, 15416, 15417, 15418, 15419, 15420, + 15421, 15422, 15423, 15424, 15425, 21982, 11578, 15426, 15427, 15428, + 15429, 15430, 15431, 21439, 15432, 15433, 15434, 15435, 15436, 15437, + 15438, 15439, 15440, 15441, 15442, 15443, 15444, 15445, 15446, 15447, + 15448, 15449, 15450, 15451, 21440, 15452, 15453, 15454, 14812, 15455, + 15495, 15456, 21466, 15457, 15458, 10563, 15459, 15460, 15461, 15462, + 15463, 15464, 15465, 15466, 15467, 15468, 15469, 15470, 15471, 15472, + 15473, 15474, 15475, 15476, 15477, 15478, 15479, 15480, 15481, 15482, + 15483, 15484, 15485, 15580, 15581, 15582, 15583, 15584, 15585, 15586, + 15587, 15588, 15589, 15590, 15591, 15592, 15593, 15594, 15595, 15596, + 15597, 15598, 15599, 15600, 15601, 15602, 15603, 15604, 15605, 15606, + 15607, 15608, 15609, 15610, 11396, 10794, 15611, 10805, 12692, 14016, + 20117, 12097, 11770, 20118, 20119, 20120, 15612, 20121, 20122, 20123, + 20124, 11534, 15613, 15614, 15615, 22226, 15616, 15617, 15618, 22228, + 15619, 22229, 15620, 22227, 15621, 15622, 15623, 15624, 11561, 15625, + 22326, 9790, 15626, 15627, 15628, 15629, 22327, 15630, 15631, 15632, 22328, + 15633, 15634, 15635, 20443, 15636, 15637, 15638, 15639, 15640, 15641, + 15642, 15643, 15644, 15645, 15646, 15647, 15347, 15648, 15649, 15650, + 15651, 15652, 15653, 16889, 15654, 15655, 15656, 15657, 15658, 15659, + 15660, 15661, 15662, 15663, 15664, 15665, 15666, 15667, 15668, 15669, + 15670, 15671, 15672, 15673, 15674, 15675, 15770, 15771, 15772, 15773, + 15774, 15775, 15776, 15777, 15778, 15779, 15780, 15781, 15782, 15783, + 15784, 15785, 15786, 15787, 15788, 15789, 15790, 15791, 15792, 15793, + 15794, 15795, 15796, 15797, 15798, 15799, 15800, 15801, 22329, 15802, + 15803, 15804, 15805, 15806, 15807, 15808, 15809, 15810, 20831, 15811, + 15812, 15813, 15814, 15815, 15816, 15817, 15818, 15819, 15820, 15821, + 15822, 15823, 15824, 15825, 15826, 15827, 15828, 15829, 15830, 15831, + 15832, 15833, 15834, 15835, 15836, 15837, 15838, 15839, 15840, 15841, + 15842, 15843, 15844, 15845, 15846, 15847, 15848, 15849, 15850, 15851, + 15852, 15853, 15854, 15855, 15856, 15857, 15858, 16073, 15859, 15860, + 15861, 15862, 15863, 15864, 15865, 15960, 15961, 15962, 15963, 15964, + 15965, 15966, 15967, 15769, 14405, 15968, 15969, 15970, 15971, 15972, + 15973, 15974, 15975, 14001, 15976, 15977, 15978, 15979, 15980, 15981, + 15982, 15983, 15984, 15985, 15986, 15987, 15988, 15989, 15990, 15991, + 15992, 15993, 15994, 15995, 15996, 15997, 15998, 15999, 16000, 16001, + 16002, 16003, 16004, 16005, 16006, 16007, 16008, 16009, 16010, 16011, + 16012, 16013, 16014, 16015, 16016, 16017, 16018, 16019, 16020, 16021, + 16022, 16023, 16024, 16025, 16026, 16027, 16028, 16029, 16030, 16031, + 16032, 16033, 16034, 16035, 16036, 16037, 16038, 16039, 16040, 16041, + 16042, 16043, 16044, 16045, 16046, 16047, 16048, 16049, 16050, 16051, + 16052, 16053, 16054, 16055, 16150, 16151, 16152, 16153, 16154, 16155, + 16156, 16157, 16158, 16159, 16160, 16161, 16162, 16163, 16164, 16165, + 16166, 16167, 16168, 16169, 16170, 16171, 16172, 16173, 16174, 16175, + 16176, 16177, 16178, 16179, 16180, 16181, 16182, 16183, 16184, 19127, + 16185, 16186, 16187, 16188, 16189, 16190, 16191, 16192, 16193, 16194, + 16195, 16196, 16197, 16198, 16199, 16200, 16201, 16202, 16203, 16204, + 16205, 16206, 16207, 16208, 16209, 16210, 16211, 16212, 16213, 16214, + 22330, 16215, 16216, 16217, 16218, 16219, 16220, 16221, 16222, 16223, + 16224, 16225, 16226, 16227, 16228, 16229, 16230, 16231, 16232, 16233, + 16234, 16235, 16236, 16237, 16238, 16239, 16240, 16241, 16242, 16243, + 16244, 16245, 16340, 16341, 16342, 16343, 16344, 16345, 16346, 16347, + 16348, 16349, 16350, 16351, 16352, 16353, 16354, 16355, 16356, 16357, + 16358, 16359, 16360, 16361, 16362, 16363, 16364, 16365, 16366, 16367, + 16368, 16369, 16370, 16371, 11700, 16372, 16373, 16374, 16375, 16376, + 13214, 16377, 16378, 16379, 16380, 16381, 16382, 16383, 16384, 16385, + 16386, 16387, 16388, 16389, 16390, 16391, 16392, 16393, 16394, 16395, + 16396, 16397, 16398, 16399, 16400, 16401, 16402, 16403, 16404, 16405, + 16406, 16407, 16408, 16409, 16410, 16411, 16412, 16413, 16414, 16415, + 16416, 16417, 16418, 16419, 16420, 16421, 16422, 16423, 16424, 16425, + 16426, 16427, 17010, 11343, 10174, 10573, 13632, 11310, 17011, 17012, + 14399, 13620, 17013, 13298, 16428, 15316, 15558, 15317, 11344, 16429, + 11513, 11183, 17014, 17015, 15335, 17016, 15182, 10244, 12504, 16430, + 14202, 10432, 13847, 10390, 11772, 16249, 17017, 17018, 13237, 16506, + 13987, 16431, 16064, 14218, 16134, 17019, 16308, 9827, 17021, 17020, 16432, + 15560, 17022, 17023, 17024, 14017, 17025, 13976, 17026, 17027, 9642, 16324, + 17028, 11131, 9989, 17029, 17030, 10813, 15310, 15557, 17031, 10580, 14989, + 9484, 17032, 17033, 16433, 11570, 14785, 15754, 17034, 14808, 17035, 15728, + 11184, 17036, 14176, 14203, 17037, 13470, 16323, 17038, 13036, 10198, + 17039, 10399, 11921, 17040, 17041, 14168, 17042, 10062, 17043, 12289, + 16462, 17044, 14369, 16434, 15559, 12842, 17045, 10068, 11164, 17046, + 15124, 17047, 17048, 14754, 17049, 17050, 17051, 9492, 17054, 17052, 15367, + 17053, 12688, 17055, 16435, 17056, 17057, 17058, 15132, 15490, 9114, 17059, + 13406, 17060, 11582, 12636, 17061, 17062, 12728, 14368, 17063, 17064, + 12095, 13260, 17065, 17066, 13415, 17067, 17068, 10775, 16530, 16531, + 16532, 16533, 16534, 16535, 16536, 16537, 16538, 11192, 16539, 16540, + 16541, 16542, 10190, 22033, 16543, 22034, 16544, 16545, 14602, 16546, + 16547, 16548, 16549, 16550, 16551, 16552, 16553, 22160, 16554, 16555, + 16556, 16557, 20299, 16558, 16559, 16560, 16561, 16562, 16563, 14998, + 11146, 16564, 16565, 16566, 16567, 16568, 16569, 16570, 10957, 15870, + 16571, 16572, 16573, 16574, 16575, 16576, 16577, 18392, 16578, 16579, + 16580, 16581, 22219, 9225, 9487, 16582, 16583, 16584, 16585, 16586, 16587, + 16588, 22220, 16589, 16590, 22222, 16591, 16592, 16593, 10974, 22221, + 16594, 12653, 16595, 16596, 16597, 16598, 16599, 16600, 16601, 22224, + 16602, 16603, 16604, 22223, 16605, 16606, 16607, 16608, 16609, 16610, + 16611, 16612, 16613, 16614, 16615, 16616, 16617, 16618, 16619, 16620, + 16621, 16622, 16623, 16624, 16625, 16720, 16721, 16722, 16723, 16724, + 16725, 16726, 16727, 16728, 16729, 16730, 16731, 16732, 16733, 16734, + 16735, 16736, 16737, 16738, 16739, 16740, 16741, 16742, 16743, 16744, + 16745, 16746, 16747, 16748, 16749, 16750, 16751, 16752, 16753, 16754, + 16755, 16756, 16757, 16758, 16759, 16760, 16761, 16762, 16763, 16764, + 16765, 16766, 16767, 16768, 16769, 16770, 16771, 16772, 16773, 16774, + 16775, 16776, 16777, 16778, 16779, 16780, 16781, 16782, 16783, 16784, + 16785, 16786, 16787, 16788, 16789, 16790, 16791, 16792, 16793, 16794, + 16795, 16796, 16797, 16798, 16799, 16800, 16801, 16802, 16803, 16804, + 16805, 16806, 16807, 16808, 16809, 16810, 16811, 16812, 16813, 16814, + 16815, 16910, 16911, 16912, 16913, 16914, 16915, 16916, 16917, 16918, + 16919, 16920, 16921, 16922, 16923, 16924, 9235, 16129, 10571, 16925, 10752, + 9443, 15945, 14960, 9085, 16098, 11200, 16287, 10378, 14361, 13227, 9280, + 10761, 16337, 10800, 10356, 11395, 20103, 20104, 14434, 10818, 20105, 9876, + 12654, 10404, 10981, 20106, 15949, 20107, 11359, 11178, 20108, 12317, + 12469, 15928, 16477, 20109, 20110, 20113, 20111, 20112, 13837, 10564, + 10201, 20114, 14039, 13820, 9830, 16926, 16927, 18582, 13081, 20115, 12086, + 16928, 16459, 20116, 16447, 13677, 16676, 16670, 15927, 16929, 15954, + 13811, 15689, 10596, 9659, 16930, 13841, 22031, 16931, 16932, 16933, 10978, + 16934, 22032, 16935, 16936, 16498, 16937, 16938, 22026, 10561, 16107, + 10592, 13285, 16939, 16940, 16941, 16942, 16943, 16944, 16945, 16946, + 16947, 9630, 16948, 16949, 22027, 9607, 16950, 16951, 16952, 16953, 15894, + 13482, 16954, 16955, 16956, 16957, 16958, 22029, 16959, 16960, 22028, + 16961, 16962, 16963, 16964, 16965, 16966, 16967, 16968, 16969, 16970, + 14388, 16971, 16972, 16973, 13589, 16974, 16975, 16976, 16977, 16978, + 16979, 16980, 16981, 16982, 16983, 16984, 16985, 16986, 22030, 16987, + 16502, 13046, 22167, 16988, 16989, 22162, 16990, 22170, 16991, 22169, + 16992, 16271, 22168, 16993, 16994, 16995, 15895, 22171, 16996, 22179, + 16997, 16998, 16999, 17000, 9072, 10063, 17001, 22176, 22177, 17002, 13075, + 17003, 17004, 17005, 17100, 22172, 22173, 17101, 17102, 22174, 22178, + 17103, 11749, 22175, 10635, 17104, 17105, 17106, 22183, 22186, 17107, + 17108, 17109, 11946, 17110, 10817, 22163, 22180, 17111, 17112, 12468, + 17113, 17114, 17115, 14433, 17116, 11394, 17117, 22181, 22182, 22184, + 10234, 22185, 17118, 22188, 17119, 17120, 17121, 17122, 17123, 17124, + 17125, 22164, 17126, 17127, 17128, 22187, 15702, 17129, 9671, 17130, 17131, + 14349, 17132, 17133, 17134, 17135, 22189, 17136, 17137, 17138, 17139, + 17140, 17141, 17142, 17143, 22190, 11750, 22191, 17144, 17145, 14408, + 22194, 17146, 17147, 17148, 17149, 17150, 9445, 16492, 17151, 22192, 17152, + 22193, 22195, 17153, 22201, 17154, 17155, 17156, 22199, 17157, 17158, + 17159, 22198, 22196, 17160, 17161, 22200, 17162, 17163, 22197, 22203, + 22204, 17164, 14412, 17165, 17166, 19126, 9999, 22202, 22207, 14348, 17167, + 17168, 17169, 17170, 17171, 22205, 22206, 17172, 17173, 17174, 17175, + 17176, 17177, 22165, 17178, 17179, 17180, 17181, 17182, 17183, 17184, + 17185, 17186, 17187, 17188, 17189, 9251, 17190, 17191, 22166, 17192, 17193, + 10012, 9473, 17194, 22211, 22208, 17195, 10220, 17290, 22212, 17291, 22209, + 17292, 17293, 17294, 17295, 17296, 22210, 17297, 17298, 9843, 17299, 15939, + 17300, 17301, 17302, 22213, 17303, 9684, 17304, 17305, 17306, 17307, 17308, + 17309, 17310, 22214, 22216, 17311, 17312, 17313, 22215, 17314, 17315, + 17316, 17317, 17318, 17319, 17320, 22217, 17321, 22218, 17322, 17323, + 17324, 17325, 17326, 17327, 17328, 17329, 17330, 17331, 17332, 17333, + 13852, 10745, 17334, 17335, 13486, 17336, 17337, 10232, 17338, 17339, + 17340, 17341, 17342, 17343, 17344, 14386, 17345, 17346, 17347, 17348, + 17349, 17350, 17351, 17352, 17353, 17354, 17355, 17356, 17357, 17358, + 17359, 17360, 17361, 17362, 17363, 20051, 17364, 17365, 17366, 17367, + 17368, 17369, 17370, 17371, 17372, 17373, 17374, 17375, 17376, 17377, + 17378, 17379, 17380, 17381, 17382, 17383, 17384, 17385, 17480, 17481, + 17482, 17483, 17484, 17485, 17486, 17487, 17488, 17489, 17490, 17491, + 17492, 17493, 17494, 17495, 17496, 17497, 17498, 17499, 17500, 17501, + 17502, 17503, 17504, 17505, 17506, 17507, 17508, 17509, 17510, 17511, + 17512, 17513, 17514, 17515, 17516, 17517, 17518, 17519, 17520, 17521, + 17522, 17523, 17524, 17525, 17526, 17527, 17528, 17529, 17530, 17531, + 17532, 17533, 17534, 17535, 17536, 17537, 17538, 17539, 17540, 17541, + 17542, 17543, 17544, 17545, 17546, 17547, 17548, 17549, 17550, 17551, + 17552, 17553, 17554, 17555, 17556, 17557, 17558, 17559, 17560, 17561, + 17562, 17563, 17564, 17565, 17566, 17567, 17568, 17569, 17570, 17571, + 17572, 17573, 17574, 17575, 17670, 17671, 17672, 17673, 17674, 17675, + 17676, 17677, 17678, 17679, 17680, 17681, 17682, 17683, 17684, 17685, + 17686, 17687, 17688, 17689, 17690, 17691, 17692, 17693, 17694, 17695, + 17696, 17697, 17698, 17699, 17700, 17701, 17702, 9616, 15959, 10811, 15194, + 17703, 19932, 16445, 19933, 12499, 13662, 10993, 19934, 19935, 19936, + 16310, 19937, 19938, 19940, 19939, 19941, 19942, 13460, 19943, 15921, + 19944, 11541, 17704, 19945, 19946, 11542, 19947, 10553, 12285, 19948, 9233, + 11167, 10820, 19949, 17705, 20046, 20047, 20048, 10443, 11318, 17706, + 14033, 18191, 15880, 14944, 16078, 20049, 16117, 20050, 15138, 10763, + 17707, 9824, 9272, 17708, 17709, 17710, 12082, 17711, 17712, 17713, 17714, + 9285, 9286, 17715, 9287, 17716, 17717, 17718, 17719, 9624, 13657, 17720, + 17721, 17722, 17723, 19128, 17724, 17725, 9278, 17726, 17727, 17728, 12296, + 9864, 17729, 17730, 13403, 15731, 17731, 13294, 15319, 17732, 10828, 12530, + 17733, 17734, 17735, 17736, 17737, 15688, 17738, 15908, 11587, 17739, + 19129, 10376, 19130, 17740, 17741, 11140, 16121, 17742, 11583, 15887, + 14730, 12267, 9652, 17743, 17744, 14431, 17745, 19133, 19131, 19135, 17746, + 19137, 19134, 10022, 13245, 17747, 10067, 19132, 17748, 14051, 17749, + 17750, 19136, 17751, 17752, 17753, 12687, 9252, 11308, 17754, 17755, 17756, + 16458, 17757, 17758, 14578, 14200, 14007, 14396, 19139, 19138, 12895, + 17759, 17760, 15296, 15318, 19140, 17761, 19143, 17762, 14559, 16325, + 19142, 10036, 17763, 14565, 17764, 19144, 10191, 17765, 17860, 14543, + 10803, 17861, 14002, 9644, 14212, 15941, 19145, 10429, 17862, 17863, 17864, + 19141, 17865, 17866, 17867, 17868, 17869, 17870, 19148, 9879, 19149, 17871, + 17872, 17873, 17874, 17875, 19146, 19147, 17876, 15546, 17877, 17878, + 12508, 9253, 17879, 15741, 17880, 17881, 10226, 14231, 17882, 19150, 17883, + 17884, 15761, 17885, 17886, 17887, 17888, 17889, 9288, 17890, 10249, 19153, + 19151, 19152, 10007, 17891, 17892, 17893, 15522, 19155, 17894, 17895, + 19157, 17896, 17897, 17898, 17899, 17900, 17901, 19156, 13413, 17902, + 15488, 17903, 17904, 19154, 17905, 17906, 17907, 17908, 15931, 16113, + 17909, 17910, 17911, 17912, 17913, 19159, 16516, 17914, 17915, 17916, + 17917, 17918, 17919, 17920, 19160, 17921, 9275, 15386, 17922, 19161, 19163, + 17923, 17924, 17925, 17926, 19162, 17927, 17928, 19164, 17929, 17930, + 17931, 17932, 17933, 15541, 17934, 10018, 17935, 19538, 17936, 17090, + 17937, 17093, 17938, 17091, 17939, 17092, 17940, 17941, 17942, 17095, + 15152, 12864, 17943, 17944, 9103, 17945, 17946, 17947, 15121, 17948, 17094, + 17949, 15717, 10935, 17197, 13476, 17950, 17097, 17096, 13834, 17098, + 17951, 17196, 16497, 17099, 12313, 17952, 17953, 17200, 17954, 17955, + 15759, 18050, 18051, 17202, 17199, 18052, 17203, 18053, 18054, 11523, + 18055, 18056, 18057, 12106, 17198, 17201, 16248, 18058, 17204, 18059, + 18060, 18061, 17208, 18062, 18063, 18064, 17209, 17207, 10959, 18065, + 18066, 18067, 11879, 17206, 18068, 18069, 18070, 17205, 15904, 9436, 18071, + 18072, 17210, 18073, 10824, 18074, 17211, 18075, 18076, 18077, 18078, 9622, + 18079, 18080, 18081, 9981, 18082, 18083, 18084, 18085, 10193, 17212, 18086, + 18087, 18088, 10250, 18089, 17213, 18090, 18091, 18092, 18093, 18094, + 18095, 18096, 18097, 18098, 18099, 18100, 18101, 18102, 18103, 18104, + 18105, 18106, 18107, 18108, 18109, 9256, 18110, 18111, 18112, 18113, 17215, + 18114, 18115, 18116, 17214, 17216, 18117, 18118, 18119, 18120, 18121, + 18122, 18123, 18124, 18125, 18126, 18127, 17218, 18128, 17217, 18129, + 18130, 18131, 18132, 18133, 18134, 18135, 17219, 18136, 18137, 18138, + 18139, 18140, 18141, 18142, 18143, 18144, 17220, 18145, 18240, 17221, + 18241, 18242, 15722, 22035, 13480, 16470, 13083, 22037, 22038, 22036, + 18243, 11723, 18244, 18245, 18246, 18247, 15184, 18248, 18249, 10406, + 18250, 18251, 15910, 14355, 18252, 18253, 22137, 22136, 10933, 22039, + 14209, 18254, 18255, 18256, 22139, 12115, 18257, 9669, 18258, 14545, 22140, + 22138, 11515, 22143, 18259, 22144, 11540, 12659, 11940, 14220, 22145, + 18260, 18261, 18262, 22141, 22142, 12905, 18263, 18264, 18265, 18266, + 18267, 22147, 18268, 9813, 18269, 16512, 18270, 9840, 22146, 22149, 18271, + 18272, 22148, 22150, 15154, 18273, 18274, 18275, 18276, 18277, 18278, + 18279, 12684, 13594, 18280, 18281, 18282, 18283, 18284, 18285, 22151, + 22152, 18286, 18287, 18288, 18289, 18290, 18291, 22153, 18292, 18293, + 22154, 22155, 22156, 18294, 18295, 18296, 18297, 22158, 22157, 18298, + 18299, 18300, 18301, 22159, 18302, 18303, 18304, 18305, 18306, 18307, + 18308, 18309, 18310, 18311, 18312, 18313, 9446, 18314, 15727, 14010, 18315, + 12144, 16301, 15501, 12286, 18316, 11575, 18317, 18318, 18319, 18320, + 18321, 18322, 18323, 18324, 18325, 18326, 10555, 18327, 18328, 18329, + 18330, 18331, 18332, 18333, 18334, 18335, 18430, 18431, 18432, 18433, + 18434, 18435, 18436, 18437, 18438, 18439, 18440, 18441, 18442, 18443, + 18444, 18445, 18446, 18447, 18448, 18449, 18450, 18451, 18452, 18453, + 18454, 18455, 18456, 18457, 18458, 18459, 18460, 18461, 18462, 18463, + 18464, 18465, 18466, 18467, 18468, 18469, 18470, 18471, 18472, 18473, + 18474, 18475, 18476, 18477, 18478, 18479, 18480, 18481, 18482, 18483, + 18484, 18485, 18486, 18487, 18488, 18489, 18490, 18491, 18492, 18493, + 18494, 18495, 18496, 18497, 18498, 18499, 18500, 18501, 18502, 18503, + 18504, 18505, 18506, 18507, 18508, 18509, 18510, 18511, 18512, 18513, + 18514, 18515, 18516, 18517, 18518, 18519, 18520, 18521, 18522, 18523, + 18524, 18525, 18620, 18621, 18622, 18623, 18624, 18625, 18626, 18627, + 18628, 18629, 18630, 18631, 18632, 18633, 18634, 18635, 18636, 18637, + 18638, 18639, 18640, 18641, 18642, 18643, 18644, 18645, 18646, 18647, + 18648, 18649, 18650, 18651, 18652, 18653, 18654, 18655, 18656, 18657, + 18658, 18659, 18660, 18661, 18662, 18663, 18664, 18665, 11393, 18666, + 18667, 18668, 18669, 18670, 18671, 18672, 18673, 18674, 18675, 18676, + 18677, 18678, 18679, 18680, 18681, 18682, 18683, 18684, 18685, 18686, + 18687, 18688, 18689, 18690, 22363, 18691, 18692, 18693, 18694, 18695, + 18696, 18697, 18698, 18699, 18700, 18701, 18702, 18703, 18704, 18705, + 18706, 18707, 18708, 18709, 18710, 18711, 18712, 18713, 18714, 18715, + 18810, 18811, 18812, 18813, 18814, 18815, 22364, 18816, 18817, 18818, + 18819, 18820, 18821, 18822, 18823, 18824, 18825, 18826, 18827, 18828, + 18829, 18830, 18831, 18832, 18833, 18834, 18835, 18836, 18837, 18838, + 18839, 18840, 22365, 18841, 18842, 18843, 18844, 18845, 18846, 18847, + 18848, 18849, 18850, 18851, 18852, 18853, 18854, 18855, 18856, 18857, + 18858, 18859, 18860, 18861, 18862, 18863, 18864, 18865, 18866, 18867, + 18868, 18869, 18870, 18871, 18872, 18873, 18874, 18875, 18876, 18877, + 18878, 18879, 18880, 18881, 18882, 18883, 18884, 18885, 18886, 18887, + 18888, 18889, 18890, 18891, 18892, 18893, 18894, 18895, 18896, 18897, + 18898, 18899, 18900, 18901, 18902, 18903, 18904, 18905, 19000, 19001, + 19002, 19003, 19004, 19005, 19006, 19007, 19008, 19009, 19010, 19011, + 19012, 19013, 19014, 19015, 19016, 19017, 19018, 19019, 19020, 19021, + 19022, 19023, 19024, 19025, 19026, 19027, 19028, 19029, 19030, 19031, + 19032, 19033, 19034, 19035, 19036, 19037, 19038, 19039, 19040, 19041, + 19042, 19043, 19044, 19045, 19046, 19047, 19048, 19049, 19050, 19051, + 22366, 19052, 19053, 19054, 19055, 19056, 19057, 19058, 19059, 19060, + 19061, 19062, 19063, 19064, 19065, 19066, 19067, 19068, 19069, 19070, + 19071, 19072, 19073, 19074, 19075, 19076, 19077, 19078, 19079, 19080, + 19081, 19082, 19083, 19084, 19085, 19086, 19087, 19088, 19089, 19090, + 19091, 19092, 19093, 19094, 22367, 19095, 19190, 19191, 19192, 19193, + 19194, 19195, 19196, 19197, 19198, 19199, 19200, 19201, 19202, 19203, + 19204, 19205, 19206, 19207, 19208, 19209, 19210, 19211, 19212, 19213, + 19214, 19215, 19216, 19217, 19218, 19219, 19220, 19221, 19222, 19223, + 19224, 22369, 19225, 19226, 19227, 19228, 19229, 19230, 19231, 19232, + 19233, 19234, 19235, 19236, 19237, 19238, 19239, 19240, 19241, 19242, + 19243, 19244, 19245, 19246, 19247, 19248, 19249, 19250, 19251, 19252, + 19253, 19254, 19255, 19256, 19257, 19258, 19259, 19260, 19261, 19262, + 19263, 19264, 19265, 19266, 19267, 19268, 19269, 19270, 19271, 19272, + 19273, 19274, 19275, 19276, 19277, 19278, 19279, 19280, 19281, 19282, + 22368, 19283, 19284, 19285, 19380, 19381, 19382, 19383, 19384, 19385, + 19386, 19387, 22588, 19388, 19389, 19390, 19391, 19392, 19393, 19394, + 19395, 19396, 19397, 19398, 19399, 19400, 19401, 19402, 19403, 19404, + 19405, 19406, 19407, 19408, 19409, 19410, 19411, 19412, 19413, 19414, + 19415, 19416, 19417, 19418, 19419, 19420, 19421, 19422, 19423, 19424, + 19425, 19426, 19427, 19428, 19429, 19430, 19431, 19432, 19433, 19434, + 19435, 19436, 19437, 19438, 19439, 19440, 19441, 19442, 19443, 19444, + 19445, 19446, 19447, 19448, 19449, 19450, 19451, 19452, 19453, 19454, + 19455, 19456, 19457, 19458, 19459, 19460, 19461, 19462, 19463, 19464, + 19465, 19466, 19467, 19468, 19469, 19470, 19471, 19472, 19473, 19474, + 19475, 19570, 19571, 19572, 19573, 19574, 19575, 19576, 19577, 19578, + 19579, 19580, 19581, 19582, 19583, 19584, 22370, 19585, 19586, 19587, + 19588, 19589, 19590, 19591, 19592, 19593, 19594, 19595, 19596, 19597, + 19598, 19599, 19600, 19601, 19602, 19603, 19604, 19605, 19606, 19607, + 19608, 19609, 19610, 19611, 19612, 19613, 19614, 19615, 19616, 19617, + 19618, 19619, 19620, 19621, 19622, 19623, 19624, 19625, 19626, 19627, + 19628, 22371, 19629, 19630, 19631, 19632, 19633, 19634, 19635, 19636, + 19637, 19638, 19639, 19640, 19641, 19642, 19643, 19644, 19645, 19646, + 19647, 19648, 19649, 19650, 19651, 19652, 19653, 20841, 20842, 20843, + 16130, 10169, 20845, 20844, 20846, 20847, 13400, 20848, 20849, 19654, + 10371, 10061, 20850, 20852, 19655, 20851, 19656, 10583, 20853, 20854, + 20855, 10224, 9609, 16296, 12863, 9236, 10599, 20856, 20857, 15896, 13448, + 11776, 14782, 10754, 20859, 20858, 20861, 20860, 13020, 20862, 20863, + 13409, 20864, 13410, 20865, 9412, 20866, 20867, 20868, 20869, 20870, 16509, + 20871, 20872, 11361, 20873, 15718, 14435, 9417, 12324, 20874, 13401, 12648, + 19657, 20875, 20876, 20877, 20878, 20879, 20880, 20881, 19658, 20882, + 20883, 20884, 19659, 19660, 20885, 20886, 20887, 20889, 20888, 19661, + 20890, 14548, 12478, 20891, 20892, 20893, 16056, 20894, 14934, 20895, + 20896, 19662, 20897, 20898, 20996, 20899, 20997, 10630, 12725, 20998, + 20999, 11529, 15516, 9494, 21000, 21001, 21002, 15573, 21003, 16338, 21004, + 13249, 19663, 21005, 21006, 12275, 21007, 15005, 14243, 21009, 21008, 9685, + 10823, 21010, 21011, 15171, 21012, 21013, 10425, 15136, 21014, 21015, + 21016, 13666, 14409, 21017, 21018, 21019, 21020, 21021, 16119, 21022, 9862, + 12645, 21023, 19664, 21024, 21025, 21026, 19665, 14818, 21027, 12509, 9809, + 16457, 11580, 19760, 14954, 21030, 21028, 21029, 21031, 10172, 11397, + 11751, 12679, 21032, 21033, 19761, 21034, 21042, 21035, 21036, 21037, + 13429, 21076, 10210, 21038, 19762, 21039, 21040, 10203, 12665, 21041, + 19763, 21043, 21044, 21045, 16137, 19764, 21046, 12912, 19765, 21047, + 12913, 21048, 21049, 10613, 9112, 21050, 21051, 21052, 19766, 21053, 21054, + 21055, 21056, 19767, 21057, 11706, 21060, 21058, 21059, 19768, 21061, + 21062, 12300, 21063, 21064, 21065, 21066, 21067, 21068, 21069, 21070, + 21071, 12121, 19769, 21072, 12268, 21073, 21074, 21075, 19770, 19771, + 14981, 19772, 19773, 19774, 19775, 19776, 19777, 19778, 19779, 9599, 19780, + 19781, 19782, 19783, 19784, 19785, 19786, 19787, 19788, 19789, 19790, + 19791, 19792, 19793, 19794, 19795, 19796, 19797, 19798, 19799, 19800, + 19801, 19802, 19803, 19804, 19805, 19806, 19807, 19808, 19809, 19810, + 19811, 19812, 19813, 19814, 19815, 19816, 19817, 19818, 19819, 19820, + 19821, 19822, 19823, 19824, 19825, 19826, 19827, 19828, 19829, 19830, + 19831, 19832, 19833, 19834, 19835, 19836, 19837, 19838, 19839, 19840, + 19841, 19842, 19843, 19844, 19845, 19846, 19847, 19848, 19849, 19850, + 19851, 19852, 19853, 19854, 19855, 19950, 19951, 19952, 19953, 19954, + 19955, 19956, 19957, 19958, 19959, 19960, 19961, 19962, 19963, 19964, + 19965, 19966, 19967, 19968, 19969, 19970, 19971, 19972, 19973, 19974, + 19975, 19976, 19977, 12672, 18752, 13808, 18753, 19978, 9268, 14767, 9804, + 13667, 18754, 14963, 18755, 11373, 18756, 18757, 12673, 16057, 12879, + 10810, 14762, 18758, 12721, 18759, 19979, 10362, 10628, 10975, 18760, + 18761, 15901, 18762, 19980, 18763, 15338, 18764, 18765, 18766, 18767, + 15349, 18768, 9496, 12092, 18769, 19981, 12076, 18770, 18771, 18772, 19982, + 18773, 18774, 19983, 10568, 17071, 19984, 10216, 19985, 17073, 17072, + 19986, 19987, 19988, 19989, 19990, 19991, 19992, 17075, 19993, 19994, + 19995, 13663, 19996, 19997, 17074, 10387, 15379, 15570, 16138, 11550, + 19998, 19999, 20000, 20001, 16507, 17077, 17076, 20002, 9027, 14586, 20003, + 17078, 20004, 10574, 11347, 12474, 12449, 9629, 17079, 20005, 12455, 12841, + 11516, 20006, 20007, 14977, 20008, 20009, 20010, 17080, 13809, 20011, + 20012, 20013, 20014, 20015, 9276, 20016, 20017, 20018, 17081, 20019, 10189, + 15891, 20020, 9688, 20021, 20022, 17082, 15906, 14968, 13082, 20023, 17083, + 20024, 20025, 20026, 20027, 20028, 17084, 20029, 17085, 12329, 14398, + 14976, 20030, 20031, 20032, 20033, 20034, 20035, 20036, 20037, 20038, + 20039, 20040, 20041, 20042, 15746, 12446, 20043, 17086, 20044, 20045, + 14224, 20140, 17087, 20141, 14225, 15579, 20142, 20143, 20144, 10629, + 20145, 20146, 17088, 9040, 14937, 20147, 20148, 16102, 20149, 20150, 20151, + 20152, 20153, 20154, 20155, 20156, 20157, 20158, 14232, 20159, 20160, + 20161, 20162, 20163, 20164, 20165, 20166, 17089, 20167, 20168, 18751, + 20169, 20170, 12260, 20171, 20172, 22356, 20173, 20174, 22357, 22358, + 12874, 20175, 13609, 15362, 20176, 20177, 15164, 15332, 11320, 10780, + 20178, 21079, 20179, 20180, 9823, 15701, 22359, 9686, 20181, 20182, 22360, + 20183, 20184, 10056, 20185, 20186, 20187, 20188, 20189, 20190, 20191, + 20192, 20193, 20194, 22362, 20195, 20196, 20197, 20198, 20199, 20200, + 20201, 15749, 22332, 15304, 20202, 20203, 20204, 20205, 22334, 20206, + 20207, 20208, 22333, 20209, 20210, 12322, 12120, 20211, 9217, 20212, 20213, + 20214, 20215, 14802, 20216, 15177, 22336, 20217, 20218, 15001, 20219, + 22335, 16135, 22337, 12660, 20220, 20221, 20222, 11199, 22339, 22338, + 20223, 20224, 20225, 12887, 20226, 20227, 12311, 20228, 20229, 20230, + 20231, 20232, 14165, 20233, 14943, 20234, 20235, 20330, 20331, 20332, + 20333, 20334, 20335, 20336, 20337, 20338, 22340, 20339, 20340, 22341, + 20341, 20342, 22342, 20343, 12467, 20344, 20345, 20346, 20347, 20348, 9077, + 13104, 20349, 20350, 20351, 20352, 22343, 20353, 20354, 20355, 20356, + 20357, 20358, 20359, 20360, 20361, 20362, 20363, 20364, 20365, 20366, + 20367, 20368, 20369, 20370, 20371, 13459, 22331, 20372, 20373, 11709, + 20374, 20375, 11703, 20376, 10044, 20377, 20378, 10394, 20379, 11906, + 12685, 12705, 20380, 20381, 16669, 20382, 20383, 20384, 10624, 20385, + 20386, 20387, 20388, 20389, 20390, 20391, 20392, 20393, 11584, 15300, + 20394, 9073, 20395, 20396, 20397, 20398, 20399, 22531, 20400, 20401, 20402, + 20403, 20404, 20405, 20406, 20407, 22532, 20408, 20409, 20410, 20411, + 20412, 15117, 20413, 9041, 20414, 20415, 20416, 22533, 22534, 20417, 22535, + 20418, 20419, 20420, 13437, 20421, 20422, 20423, 20424, 20425, 20520, + 20521, 11732, 20522, 20523, 22538, 20524, 20525, 20526, 20527, 20528, + 20529, 20530, 22537, 20531, 9277, 20532, 22536, 20533, 20534, 22539, 20535, + 22540, 20536, 20537, 20538, 20539, 20540, 20541, 20542, 20543, 20544, + 20545, 20546, 20547, 20548, 20549, 20550, 20551, 20552, 20553, 20554, + 20555, 20556, 20557, 20558, 20559, 20560, 20561, 20562, 20563, 20564, + 20565, 20566, 20567, 20568, 20569, 20570, 20571, 20572, 20573, 20574, + 20575, 20576, 20577, 20578, 20579, 20580, 20581, 20582, 20583, 20584, + 14729, 13630, 20585, 10936, 19689, 19690, 19691, 11719, 20586, 20587, + 20588, 20589, 20590, 15569, 20591, 15912, 13831, 20592, 20593, 20594, + 20595, 20596, 20597, 20598, 20599, 20600, 20601, 20602, 20603, 20604, + 20605, 20606, 20607, 20608, 20609, 20610, 20611, 20612, 20613, 20614, + 20615, 20710, 20711, 20712, 20713, 20714, 20715, 20716, 20717, 20718, + 20719, 20720, 20721, 20722, 20723, 20724, 20725, 20726, 20727, 20728, + 20729, 20730, 20731, 20732, 20733, 20734, 20735, 20736, 20737, 20738, + 20739, 20740, 20741, 20742, 20743, 20744, 20745, 20746, 20747, 20748, + 20749, 20750, 20751, 20752, 20753, 20754, 20755, 20756, 20757, 20758, + 20759, 20760, 20761, 20762, 20763, 20764, 20765, 20766, 20767, 20768, + 20769, 20770, 20771, 20772, 20773, 20774, 20775, 20776, 20777, 20778, + 20779, 20780, 20781, 20782, 20783, 20784, 20785, 20786, 20787, 20788, + 20789, 20790, 20791, 20792, 20793, 20794, 20795, 20796, 20797, 20798, + 20799, 20800, 20801, 20802, 20803, 20804, 20805, 20900, 20901, 20902, + 20903, 20904, 20905, 15504, 10170, 13469, 21467, 14993, 14174, 15180, + 19554, 14606, 10778, 10222, 21468, 9093, 14199, 21469, 15869, 12458, 12331, + 13241, 11702, 21566, 11358, 20906, 21567, 21568, 20907, 21569, 15520, + 13226, 20908, 14574, 21570, 20909, 15692, 11912, 14411, 20910, 21571, + 21572, 15348, 10243, 21573, 21574, 10038, 21575, 21576, 20911, 9497, 21577, + 21578, 13592, 20912, 20913, 20914, 20915, 20916, 20917, 20918, 20919, + 20920, 20921, 20922, 20923, 20924, 20925, 20926, 20927, 20928, 20929, + 20930, 20931, 20932, 20933, 20934, 20935, 20936, 20937, 20938, 20939, + 20940, 20941, 20942, 20943, 20944, 20945, 20946, 20947, 20948, 20949, + 10426, 20950, 20951, 20434, 20435, 20436, 20952, 20437, 20953, 20954, + 13219, 20438, 20439, 20955, 20956, 20957, 10396, 13984, 20958, 20959, + 20960, 20961, 20962, 20963, 20964, 18549, 22562, 20965, 20966, 20967, + 20968, 20969, 20970, 20971, 20972, 20973, 20974, 20975, 20976, 20977, + 20978, 20979, 20980, 20981, 20982, 20983, 20984, 20985, 20986, 20987, + 20988, 20989, 20990, 20991, 20992, 20993, 20994, 20995, 21090, 21091, + 21092, 21093, 21094, 22563, 21095, 21096, 9450, 21097, 21098, 21099, 21100, + 21101, 21102, 21103, 21104, 21105, 21106, 21107, 21108, 21109, 21110, + 21111, 21112, 21113, 21114, 21115, 21116, 21117, 21118, 21119, 21120, + 21121, 21122, 21123, 21124, 21125, 22564, 21126, 21127, 21128, 21129, + 21130, 21131, 21132, 21133, 21134, 21135, 21136, 21137, 21138, 21139, + 21140, 21141, 21142, 21143, 21144, 21145, 21146, 21147, 21148, 21149, + 21150, 21151, 21152, 21153, 21154, 21155, 21156, 21157, 21158, 21159, + 21160, 21161, 21162, 22566, 22565, 21163, 21164, 21165, 21166, 21167, + 21168, 21169, 21170, 21171, 21172, 21173, 21174, 21175, 18552, 21176, + 11307, 21177, 18553, 18554, 18555, 18556, 18557, 18558, 10380, 15576, + 11499, 14011, 9220, 14194, 21178, 18559, 10257, 13621, 18560, 21179, 21180, + 11535, 21181, 9308, 18561, 21182, 10251, 18562, 12882, 21183, 21184, 18563, + 14973, 10796, 18564, 12066, 21185, 18565, 9491, 21280, 18566, 21281, 12338, + 18567, 18568, 12533, 18569, 18570, 18571, 14020, 16649, 16884, 14982, + 21282, 21283, 21284, 21285, 21286, 21287, 21288, 21289, 21290, 21291, + 21292, 21190, 21293, 21294, 17401, 21295, 21296, 21297, 21298, 21299, + 21300, 21301, 21302, 21303, 21304, 21305, 21306, 21307, 21308, 21309, + 21310, 21311, 21312, 21313, 21314, 21315, 21316, 21317, 21318, 21319, + 21320, 21321, 21322, 21323, 21324, 21325, 21326, 21327, 21328, 21329, + 21330, 21331, 21332, 21333, 21334, 21335, 21336, 21337, 21338, 21339, + 21340, 21341, 21342, 21343, 21344, 21345, 21346, 21347, 21348, 21349, + 21350, 21351, 21352, 21353, 21354, 21355, 21356, 21357, 21358, 21359, + 21360, 21361, 21362, 21363, 21364, 21365, 21366, 21367, 21368, 21369, + 21370, 21371, 21372, 21373, 21374, 21375, 21470, 21471, 21472, 21473, + 21474, 21475, 21476, 21477, 21478, 21479, 21480, 21481, 21482, 21483, + 21484, 21485, 21486, 21487, 21488, 21489, 21490, 21491, 21492, 21493, + 21494, 21495, 21496, 21497, 21498, 21499, 21500, 21501, 21502, 21503, + 21504, 21505, 21506, 21507, 21508, 21509, 21510, 21511, 21512, 21513, + 21514, 21515, 21516, 21517, 21518, 21519, 21520, 21521, 21522, 21523, + 21524, 21525, 21526, 21527, 21528, 21529, 21530, 21531, 21532, 21533, + 21534, 21535, 21536, 21537, 21538, 21539, 21540, 21541, 21542, 21543, + 21544, 21545, 21546, 21547, 21548, 21549, 21550, 21551, 21552, 21553, + 21554, 21555, 21556, 21557, 21558, 21559, 21560, 21561, 21562, 21563, + 21564, 21565, 21660, 21661, 21662, 21663, 21664, 21665, 21666, 21667, + 21668, 21669, 21670, 21671, 21672, 21673, 21674, 21675, 21676, 21677, + 12522, 15871, 14587, 15312, 9654, 13488, 21678, 9426, 12476, 19349, 13992, + 19350, 19351, 11737, 19352, 16439, 14588, 19354, 11366, 19353, 19355, + 19356, 12523, 21679, 11525, 19357, 12515, 10932, 19358, 21680, 19359, 9645, + 15368, 21681, 21682, 11880, 19360, 13284, 19361, 19362, 21683, 21684, + 19363, 13218, 19364, 21685, 13782, 19365, 19366, 19367, 19120, 19368, + 19369, 12511, 19370, 19371, 16317, 19372, 21686, 19373, 10774, 21687, + 21688, 21689, 21690, 21691, 21692, 21693, 22542, 22541, 21694, 21695, + 21696, 21697, 22545, 22543, 10926, 21698, 22546, 21699, 22547, 21700, + 21701, 21702, 22549, 22548, 22551, 21703, 21704, 22550, 21705, 21706, + 21707, 21708, 21709, 22552, 22553, 21710, 21711, 21712, 21713, 22554, + 21714, 14227, 21715, 21716, 21717, 21718, 10608, 21719, 21720, 21721, + 21722, 21723, 21724, 22567, 21725, 22568, 21726, 21727, 21728, 21729, + 22569, 21730, 21731, 21732, 21733, 22571, 21734, 22573, 21735, 22570, + 21736, 21737, 21738, 21739, 21740, 21741, 21742, 21743, 21744, 22574, + 21745, 22572, 21746, 21747, 21748, 21749, 21750, 21751, 21752, 16490, + 21753, 21754, 21755, 21850, 22575, 21851, 21852, 21853, 21854, 21855, + 21856, 22576, 21857, 21858, 21859, 22577, 21860, 21861, 21862, 21863, + 21864, 21865, 21866, 21867, 21868, 21869, 21870, 22578, 21871, 21872, + 21873, 22579, 21874, 21875, 21876, 21877, 21878, 21879, 21880, 21881, + 21882, 21883, 21884, 17238, 21885, 21886, 16635, 21887, 21888, 21889, + 21890, 21891, 21892, 21893, 21894, 19182, 10812, 21895, 21896, 21897, + 21898, 11968, 11189, 22556, 13244, 22555, 21899, 22557, 22559, 22558, + 21900, 21901, 21902, 22560, 21903, 14751, 21904, 22561, 21905, 21906, + 12832, 21907, 21908, 21909, 21910, 21911, 21912, 21913, 21914, 21915, + 21916, 21917, 21918, 21919, 21920, 21921, 21922, 21923, 21924, 21925, + 21926, 21927, 21928, 21929, 21930, 21931, 21932, 21933, 21934, 21935, + 21936, 21937, 21938, 21939, 21940, 21941, 21942, 21943, 21944, 21945, + 22040, 22041, 22042, 22043, 22044, 22045, 22046, 22047, 22048, 22049, + 22050, 22051, 22052, 22053, 22054, 22055, 22056, 22057, 22058, 22059, + 22060, 22061, 22062, 22063, 22064, 22065, 22066, 22067, 22068, 22069, + 22070, 22071, 22072, 22073, 22074, 22075, 22076, 22077, 22078, 22079, + 22080, 22081, 22082, 22083, 22084, 22085, 22086, 22087, 22088, 22089, + 22090, 22091, 22092, 22093, 22094, 22095, 22096, 22097, 22098, 22099, + 22100, 22101, 22102, 22103, 22104, 22105, 22106, 22107, 22108, 22109, + 22110, 22111, 22112, 22113, 22114, 22115, 22116, 22117, 22118, 22119, + 22120, 22121, 22122, 22123, 22124, 22125, 22126, 22127, 22128, 22129, + 22130, 22131, 22132, 22133, 22134, 22135, 22230, 22231, 22232, 22233, + 22234, 22235, 22236, 22237, 22238, 22239, 22240, 22241, 22242, 22243, + 22244, 22245, 22246, 22247, 22248, 22249, 22250, 22251, 22252, 22253, + 22254, 22255, 22256, 22257, 22258, 22259, 22260, 22261, 22262, 22263, + 22264, 22265, 22266, 22267, 22268, 22269, 22270, 22271, 22272, 22273, + 22274, 22275, 22276, 22277, 22278, 22279, 22280, 22281, 22282, 22283, + 22284, 22285, 22286, 22287, 22288, 22289, 22290, 22291, 22292, 22293, + 22294, 22295, 22296, 22297, 22298, 22299, 22300, 22301, 22302, 22303, + 22304, 22305, 22306, 22307, 22308, 22309, 22310, 22311, 22312, 22313, + 22314, 22315, 22316, 22317, 22318, 22319, 22320, 22321, 22322, 22323, + 22324, 22325, 22420, 22421, 22422, 22423, 22424, 22425, 22426, 22427, + 22428, 22429, 22430, 22431, 22432, 22433, 22434, 22435, 22436, 22437, + 22438, 22439, 22440, 22441, 22442, 22443, 22444, 22445, 22446, 22447, + 22448, 22449, 22450, 22451, 22452, 22453, 22454, 22455, 22456, 22457, + 22458, 22459, 22460, 22461, 22462, 22463, 22464, 22465, 22466, 22467, + 22468, 22469, 22470, 22471, 22472, 22473, 22474, 22475, 22476, 22477, + 22478, 22479, 22480, 22481, 22482, 22483, 15742, 22484, 22485, 22372, + 22486, 12464, 22373, 22487, 22488, 22374, 22375, 22376, 22377, 22489, + 22490, 22379, 22491, 9226, 22380, 22492, 22381, 22382, 22383, 22493, 22384, + 22385, 22494, 22495, 22496, 22497, 22386, 22387, 14957, 22498, 22388, + 22389, 22390, 22391, 22392, 22393, 12145, 22394, 22395, 22396, 22397, + 22398, 22499, 22399, 22500, 22400, 22401, 22501, 22402, 22403, 22404, + 22405, 22406, 22407, 22408, 22409, 11693, 22502, 22410, 22411, 22412, + 22413, 22503, 22504, 22505, 22506, 22507, 13675, 22414, 22415, 22416, + 22417, 22508, 22509, 22418, 22419, 22516, 22517, 22518, 22519, 22520, + 22510, 22511, 22521, 22522, 22523, 9293, 22524, 22525, 22526, 22512, 22513, + 22527, 22528, 12314, 22529, 22514, 22515, 22530, 22610, 22611, 22612, + 22613, 22614, 22615, 22616, 22617, 22618, 22619, 22620, 22621, 22622, + 22623, 22624, 22625, 22626, 22627, 22628, 22629, 22630, 22631, 22632, + 22633, 22634, 22635, 22636, 22637, 22638, 22639, 22640, 22641, 22642, + 22643, 22644, 22645, 22646, 22647, 22648, 22649, 22650, 22651, 22652, + 22653, 22654, 22655, 22656, 22657, 22658, 22659, 22660, 22661, 22662, + 22663, 22664, 22665, 22666, 22667, 22668, 22669, 22670, 22671, 22672, + 22673, 22674, 22675, 22676, 22677, 22678, 22679, 22680, 22681, 22682, + 22683, 22684, 22685, 22686, 22687, 22688, 22689, 22690, 22691, 22692, + 22693, 22694, 22695, 22696, 22697, 22698, 22699, 22700, 22701, 22702, + 22703, 22704, 22705, 22800, 22801, 22802, 22803, 22804, 22805, 22806, + 22807, 22808, 22809, 22810, 22811, 22812, 22813, 22814, 22815, 22816, + 22817, 22818, 22819, 22820, 22821, 22822, 22823, 22824, 22825, 22826, + 22827, 22828, 22829, 22830, 22831, 22832, 22833, 22834, 22835, 22836, + 22837, 22838, 22839, 22840, 22841, 22842, 22843, 22844, 22845, 22846, + 22847, 22848, 22849, 22850, 22851, 22852, 22853, 22854, 22855, 22856, + 22857, 22858, 22859, 22860, 22861, 22862, 22863, 22864, 22865, 22866, + 22867, 22868, 22869, 22870, 22871, 22872, 22873, 22874, 22875, 22876, + 22877, 22878, 22879, 22880, 22881, 22882, 22883, 22884, 22885, 22886, + 22887, 22888, 22889, 22890, 22891, 22892, 22893, 22894, 22895, 22990, + 22991, 22992, 22993, 22994, 22995, 22996, 22997, 22998, 22999, 23000, + 23001, 23002, 23003, 23004, 23005, 23006, 23007, 23008, 23009, 23010, + 23011, 23012, 23013, 23014, 23015, 23016, 23017, 23018, 23019, 23020, + 23021, 23022, 23023, 23024, 23025, 23026, 23027, 23028, 23029, 23030, + 23031, 23032, 23033, 23034, 23035, 23036, 23037, 23038, 23039, 23040, + 23041, 23042, 23043, 23044, 23045, 23046, 23047, 23048, 23049, 23050, + 23051, 23052, 23053, 23054, 23055, 23056, 23057, 23058, 23059, 23060, + 23061, 23062, 23063, 23064, 23065, 23066, 23067, 23068, 23069, 23070, + 23071, 23072, 23073, 23074, 23075, 23076, 23077, 23078, 23079, 23080, + 23081, 23082, 23083, 23084, 23085, 23180, 23181, 23182, 23183, 23184, + 23185, 23186, 23187, 23188, 23189, 23190, 23191, 23192, 23193, 23194, + 23195, 23196, 23197, 23198, 23199, 23200, 23201, 23202, 23203, 23204, + 23205, 23206, 23207, 12906, 21200, 11311, 21201, 12724, 23208, 13039, + 15322, 23209, 21202, 21203, 21204, 21205, 21206, 15323, 23210, 15371, + 23211, 21208, 21207, 15872, 23212, 14585, 21209, 21211, 21210, 21212, + 21213, 23213, 23214, 10620, 21214, 10997, 23215, 21215, 21216, 11758, + 21217, 10241, 21218, 21219, 21220, 21221, 13606, 21222, 21223, 23216, + 21224, 13099, 23217, 21225, 23218, 23219, 23220, 21226, 23221, 21227, + 22544, 23222, 21228, 21229, 21230, 23223, 21231, 23224, 23225, 23226, + 23227, 21232, 10980, 23228, 21233, 21234, 21235, 21236, 21237, 21238, + 21239, 21241, 23229, 23230, 15680, 21240, 23231, 21242, 23232, 23233, + 23234, 23235, 23236, 23237, 23238, 23239, 23240, 23241, 22161, 12470, + 23242, 23243, 22583, 23244, 23245, 23246, 23247, 22584, 22585, 23248, + 23249, 22586, 23250, 23251, 23252, 23253, 23254, 23255, 22587, 12465, + 23256, 23257, 23258, 23259, 23260, 23261, 23262, 23263, 23264, 22589, + 23265, 22590, 23266, 23267, 23268, 23269, 23270, 23271, 12528, 23272, + 23273, 23274, 23275, 23370, 23371, 23372, 23373, 23374, 23375, 23376, + 23377, 23378, 22025, 23379, 23380, 23381, 22024, 23382, 23383, 12518, + 23384, 22580, 22581, 23385, 23386, 23387, 23388, 23389, 11153, 23390, + 23391, 23392, 23393, 16883, 23394, 23395, 23396, 14047, 12137, 21189, + 23397, 10983, 23398, 23399, 13408, 23400, 23401, 23402, 12837, 23403, + 23404, 22591, 22592, 22593, 23405, 22595, 22594, 23406, 22596, 23407, + 23408, 22599, 23409, 22598, 23410, 22597, 22600, 23411, 23412, 23413, + 23414, 22601, 23415, 23416, 23417, 23418, 23419, 23420, 23421, 23422, + 23423, 20688, 23424, 20689, 20690, 23425, 22353, 23426, 23427, 23428, + 23429, 23430, 23431, 23432, 23433, 23434, 23435, 23436, 23437, 22354, + 23438, 22355, 10171, 23439, 16655, 23440, 23441, 10771, 23442, 23443, + 23444, 16652, 23445, 17402, 23446, 23447, 23448, 23449, 23450, 23451, + 14048, 23452, 22602, 23453, 23454, 23455, 23456, 23457, 23458, 23459, + 23460, 23461, 22603, 23462, 23463, 22604, 23464, 23465, 23560, 23561, + 23562, 23563, 23564, 22606, 23565, 22605, 23566, 9254, 23567, 22607, 22608, + 23568, 23569, 23570, 23571, 23572, 22609, 23573, 23574, 23575, 23576, + 23577, 23578, 23579, 23580, 23581, 23582, 23583, 13280, 20445, 23584, + 23585, 23586, 23587, 23588, 23589, 23590, 23591, 23592, 23593, 23594, + 23595, 23596, 23597, 23598, 23599, 23600, 23601, 23602, 23603, 23604, + 23605, 23606, 23607, 23608, 23609, 23610, 23611, 23612, 23613, 23614, + 23615, 23616, 23617, 23618, 23619, 23620, 23621, 23622, 23623, 23624, + 23625, 23626, 23627, 23628, 9656, 22344, 23629, 23630, 22345, 12323, 22346, + 22347, 22348, 22349, 22350, 22351, 13588, 22352, 23631, 23632, 23633, + 23634, 23635, 23636, 23637, 23638, 23639, 23640, 23641, 23642, 12345, + 10743, 20687, 23643, 23644, 23645, 10809, 16878, 23646, 23647, 23648, + 23649, 23650, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7886, 7887, 7888, + 7889, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7897, 7898, 7899, 7900, + 7901, 7902, 7903, 7904, 7905, 7906, 7907, 7908, 7909, 7910, 7911, 7912, + 7913, 7914, 7915, 7916, 7917, 7918, 7919, 7920, 7921, 7922, 7923, 7924, + 7925, 7926, 7927, 7928, 7929, 7930, 7931, 7932, 7933, 7934, 7935, 7936, + 7937, 7938, 7939, 7940, 7941, 7942, 7943, 7944, 7945, 7946, 7947, 7948, + 7949, 7950, 7951, 7952, 7953, 7954, 7955, 7956, 7957, 7958, 7959, 7960, + 7961, 7962, 7963, 7964, 7965, 7966, 7967, 7968, 7969, 7970, 7971, 7972, + 7973, 7974, 7975, 7976, 7977, 7978, 7979, 8076, 8077, 8078, 8079, 8080, + 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 8091, 8092, + 8093, 8094, 8095, 8096, 8097, 8098, 8099, 8100, 8101, 8102, 8103, 8104, + 8105, 8106, 8107, 8108, 8109, 8110, 8111, 8112, 8113, 8114, 8115, 8116, + 8117, 8118, 8119, 8120, 8121, 8122, 8123, 8124, 8125, 8126, 8127, 8128, + 8129, 8130, 8131, 8132, 8133, 8134, 8135, 8136, 8137, 8138, 8139, 8140, + 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, + 8153, 8154, 8155, 8156, 8157, 8158, 8159, 8160, 8161, 8162, 8163, 8164, + 8165, 8166, 8167, 8168, 8169, 8266, 8267, 8268, 8269, 8270, 8271, 8272, + 8273, 8274, 8275, 8276, 8277, 8278, 8279, 8280, 8281, 8282, 8283, 8284, + 8285, 8286, 8287, 8288, 8289, 8290, 8291, 8292, 8293, 8294, 8295, 8296, + 8297, 8298, 8299, 8300, 8301, 8302, 8303, 8304, 8305, 8306, 8307, 8308, + 8309, 8310, 8311, 8312, 8313, 8314, 8315, 8316, 8317, 8318, 8319, 8320, + 8321, 8322, 8323, 8324, 8325, 8326, 8327, 8328, 8329, 8330, 8331, 8332, + 8333, 8334, 8335, 8336, 8337, 8338, 8339, 8340, 8341, 8342, 8343, 8344, + 8345, 8346, 8347, 8348, 8349, 8350, 8351, 8352, 8353, 8354, 8355, 8356, + 8357, 8358, 8359, 8456, 8457, 8458, 8459, 8460, 8461, 8462, 8463, 8464, + 8465, 8466, 8467, 8468, 8469, 8470, 8471, 8472, 8473, 8474, 8475, 8476, + 8477, 8478, 8479, 8480, 8481, 8482, 8483, 8484, 8485, 8486, 8487, 8488, + 8489, 8490, 8491, 8492, 8493, 8494, 8495, 8496, 8497, 8498, 8499, 8500, + 8501, 8502, 8503, 8504, 8505, 8506, 8507, 8508, 8509, 8510, 8511, 8512, + 8513, 8514, 8515, 8516, 8517, 8518, 8519, 8520, 8521, 8522, 8523, 8524, + 8525, 8526, 8527, 8528, 8529, 8530, 8531, 8532, 8533, 8534, 8535, 8536, + 8537, 8538, 8539, 8540, 8541, 8542, 8543, 8544, 8545, 8546, 8547, 8548, + 8549, 8646, 8647, 8648, 8649, 8650, 8651, 8652, 8653, 8654, 8655, 8656, + 8657, 8658, 8659, 8660, 8661, 8662, 8663, 8664, 8665, 8666, 8667, 8668, + 8669, 8670, 8671, 8672, 8673, 8674, 8675, 8676, 8677, 8678, 8679, 8680, + 8681, 8682, 8683, 8684, 8685, 8686, 8687, 8688, 8689, 8690, 8691, 8692, + 8693, 8694, 8695, 8696, 8697, 8698, 8699, 8700, 8701, 8702, 8703, 8704, + 8705, 8706, 8707, 8708, 8709, 8710, 8711, 8712, 8713, 8714, 8715, 8716, + 8717, 8718, 8719, 8720, 8721, 8722, 8723, 8724, 8725, 8726, 8727, 8728, + 8729, 8730, 8731, 8732, 8733, 8734, 8735, 8736, 8737, 8738, 8739, 8836, + 8837, 8838, 8839, 8840, 8841, 8842, 8843, 8844, 8845, 8846, 8847, 8848, + 8849, 8850, 8851, 8852, 8853, 8854, 8855, 8856, 8857, 8858, 8859, 8860, + 8861, 8862, 8863, 8864, 8865, 8866, 8867, 8868, 8869, 8870, 8871, 8872, + 8873, 8874, 8875, 8876, 8877, 8878, 8879, 8880, 8881, 8882, 8883, 8884, + 8885, 8886, 8887, 8888, 8889, 8890, 8891, 8892, 8893, 8894, 8895, 8896, + 8897, 8898, 8899, 8900, 8901, 8902, 8903, 8904, 8905, 8906, 8907, 8908, + 8909, 8910, 8911, 8912, 8913, 8914, 8915, 8916, 8917, 8918, 8919, 8920, + 8921, 8922, 8923, 8924, 8925, 8926, 8927, 8928, 8929, 22706, 22707, 22708, + 22709, 22710, 22711, 22712, 22713, 22714, 22715, 22716, 22717, 22718, + 22719, 22720, 22721, 22722, 22723, 22724, 22725, 22726, 22727, 22728, + 22729, 22730, 22731, 22732, 22733, 22734, 22735, 22736, 22737, 22738, + 22739, 22740, 22741, 22742, 22743, 22744, 22745, 22746, 22747, 22748, + 22749, 22750, 22751, 22752, 22753, 22754, 22755, 22756, 22757, 22758, + 22759, 22760, 22761, 22762, 22763, 22764, 22765, 22766, 22767, 22768, + 22769, 22770, 22771, 22772, 22773, 22774, 22775, 22776, 22777, 22778, + 22779, 22780, 22781, 22782, 22783, 22784, 22785, 22786, 22787, 22788, + 22789, 22790, 22791, 22792, 22793, 22794, 22795, 22796, 22797, 22798, + 22799, 22896, 22897, 22898, 22899, 22900, 22901, 22902, 22903, 22904, + 22905, 22906, 22907, 22908, 22909, 22910, 22911, 22912, 22913, 22914, + 22915, 22916, 22917, 22918, 22919, 22920, 22921, 22922, 22923, 22924, + 22925, 22926, 22927, 22928, 22929, 22930, 22931, 22932, 22933, 22934, + 22935, 22936, 22937, 22938, 22939, 22940, 22941, 22942, 22943, 22944, + 22945, 22946, 22947, 22948, 22949, 22950, 22951, 22952, 22953, 22954, + 22955, 22956, 22957, 22958, 22959, 22960, 22961, 22962, 22963, 22964, + 22965, 22966, 22967, 22968, 22969, 22970, 22971, 22972, 22973, 22974, + 22975, 22976, 22977, 22978, 22979, 22980, 22981, 22982, 22983, 22984, + 22985, 22986, 22987, 22988, 22989, 23086, 23087, 23088, 23089, 23090, + 23091, 23092, 23093, 23094, 23095, 23096, 23097, 23098, 23099, 23100, + 23101, 23102, 23103, 23104, 23105, 23106, 23107, 23108, 23109, 23110, + 23111, 23112, 23113, 23114, 23115, 23116, 23117, 23118, 23119, 23120, + 23121, 23122, 23123, 23124, 23125, 23126, 23127, 23128, 23129, 23130, + 23131, 23132, 23133, 23134, 23135, 23136, 23137, 23138, 23139, 23140, + 23141, 23142, 23143, 23144, 23145, 23146, 23147, 23148, 23149, 23150, + 23151, 23152, 23153, 23154, 23155, 23156, 23157, 23158, 23159, 23160, + 23161, 23162, 23163, 23164, 23165, 23166, 23167, 23168, 23169, 23170, + 23171, 23172, 23173, 23174, 23175, 23176, 23177, 23178, 23179, 23276, + 23277, 23278, 23279, 23280, 23281, 23282, 23283, 23284, 23285, 23286, + 23287, 23288, 23289, 23290, 23291, 23292, 23293, 23294, 23295, 23296, + 23297, 23298, 23299, 23300, 23301, 23302, 23303, 23304, 23305, 23306, + 23307, 23308, 23309, 23310, 23311, 23312, 23313, 23314, 23315, 23316, + 23317, 23318, 23319, 23320, 23321, 23322, 23323, 23324, 23325, 23326, + 23327, 23328, 23329, 23330, 23331, 23332, 23333, 23334, 23335, 23336, + 23337, 23338, 23339, 23340, 23341, 23342, 23343, 23344, 23345, 23346, + 23347, 23348, 23349, 23350, 23351, 23352, 23353, 23354, 23355, 23356, + 23357, 23358, 23359, 23360, 23361, 23362, 23363, 23364, 23365, 23366, + 23367, 23368, 23369, 23466, 23467, 23468, 23469, 23470, 23471, 23472, + 23473, 23474, 23475, 23476, 23477, 23478, 23479, 23480, 23481, 23482, + 23483, 23484, 23485, 23486, 23487, 23488, 23489, 23490, 23491, 23492, + 23493, 23494, 23495, 23496, 23497, 23498, 23499, 23500, 23501, 23502, + 23503, 23504, 23505, 23506, 23507, 23508, 23509, 23510, 23511, 23512, + 23513, 23514, 23515, 23516, 23517, 23518, 23519, 23520, 23521, 23522, + 23523, 23524, 23525, 23526, 23527, 23528, 23529, 23530, 23531, 23532, + 23533, 23534, 23535, 23536, 23537, 23538, 23539, 23540, 23541, 23542, + 23543, 23544, 23545, 23546, 23547, 23548, 23549, 23550, 23551, 23552, + 23553, 23554, 23555, 23556, 23557, 23558, 23559, 23656, 23657, 23658, + 23659, 23660, 23661, 23662, 23663, 23664, 23665, 23666, 23667, 23668, + 23669, 23670, 23671, 23672, 23673, 23674, 23675, 23676, 23677, 23678, + 23679, 23680, 23681, 23682, 23683, 23684, 23685, 23686, 23687, 23688, + 23689, 23690, 23691, 23692, 23693, 23694, 23695, 23696, 23697, 23698, + 23699, 23700, 23701, 23702, 23703, 23704, 23705, 23706, 23707, 23708, + 23709, 23710, 23711, 23712, 23713, 23714, 23715, 23716, 23717, 23718, + 23719, 23720, 23721, 23722, 23723, 23724, 23725, 23726, 23727, 23728, + 23729, 23730, 23731, 23732, 23733, 23734, 23735, 23736, 23737, 23738, + 23739, 23740, 23741, 23742, 23743, 23744, 23745, 23746, 23747, 23748, + 23749, 23846, 23847, 23848, 23849, 23850, 23851, 23852, 23853, 23854, + 23855, 23856, 23857, 23858, 23859, 23860, 23861, 23862, 23863, 23864, + 23865, 23866, 23867, 23868, 23869, 23870, 23871, 23872, 23873, 23874, + 23875, 23876, 23877, 23878, 23879, 23880, 23881, 23882, 23883, 23884, + 23885, 23886, 23887, 23888, 23889, 23890, 23891, 23892, 23893, 23894, + 23895, 23896, 23897, 23898, 23899, 23900, 23901, 23902, 23903, 23904, + 23905, 23906, 23907, 23908, 23909, 23910, 23911, 23912, 23913, 23914, + 23915, 23916, 23917, 23918, 23919, 23920, 23921, 23922, 23923, 23924, + 23925, 23926, 23927, 23928, 23929, 23930, 23931, 23932, 23933, 23934, + 23935, 23936, 23937, 23938, 23939, 6080, 6081, 6082, 6083, 6084, 6085, + 6086, 6087, 6088, 6089, 6090, 6091, 6092, 6093, 6094, 6095, 6096, 6097, + 6098, 6099, 6100, 6101, 6102, 6103, 6104, 6105, 6106, 6107, 6108, 6109, + 6110, 6111, 6112, 6113, 6114, 6115, 6116, 6117, 6118, 6119, 6120, 6121, + 6122, 6123, 6124, 6125, 6126, 6127, 6128, 6129, 6130, 6131, 6132, 6133, + 6134, 6135, 6136, 6137, 6138, 6139, 6140, 6141, 6142, 6143, 6144, 6145, + 6146, 6147, 6148, 6149, 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, + 6158, 6159, 6160, 6161, 6162, 6163, 6164, 6165, 6166, 6167, 6168, 6169, + 6170, 6171, 6172, 6173, 6174, 6175, 6270, 6271, 6272, 6273, 6274, 6275, + 6276, 6277, 6278, 6279, 6280, 6281, 6282, 6283, 6284, 6285, 6286, 6287, + 6288, 6289, 6290, 6291, 6292, 6293, 6294, 6295, 6296, 6297, 6298, 6299, + 6300, 6301, 6302, 6303, 6304, 6305, 6306, 6307, 6308, 6309, 6310, 6311, + 6312, 6313, 6314, 6315, 6316, 6317, 6318, 6319, 6320, 6321, 6322, 6323, + 6324, 6325, 6326, 6327, 6328, 6329, 6330, 6331, 6332, 6333, 6334, 6335, + 6336, 6337, 6338, 6339, 6340, 6341, 6342, 6343, 6344, 6345, 6346, 6347, + 6348, 6349, 6350, 6351, 6352, 6353, 6354, 6355, 6356, 6357, 6358, 6359, + 6360, 6361, 6362, 6363, 6364, 6365, 6460, 6461, 6462, 6463, 6464, 6465, + 6466, 6467, 6468, 6469, 6470, 6471, 6472, 6473, 6474, 6475, 6476, 6477, + 6478, 6479, 6480, 6481, 6482, 6483, 6484, 6485, 6486, 6487, 6488, 6489, + 6490, 6491, 6492, 6493, 6494, 6495, 6496, 6497, 6498, 6499, 6500, 6501, + 6502, 6503, 6504, 6505, 6506, 6507, 6508, 6509, 6510, 6511, 6512, 6513, + 6514, 6515, 6516, 6517, 6518, 6519, 6520, 6521, 6522, 6523, 6524, 6525, + 6526, 6527, 6528, 6529, 6530, 6531, 6532, 6533, 6534, 6535, 6536, 6537, + 6538, 6539, 6540, 6541, 6542, 6543, 6544, 6545, 6546, 6547, 6548, 6549, + 6550, 6551, 6552, 6553, 6554, 65535, 6650, 6651, 6652, 6653, 6654, 6655, + 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, + 6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, + 6680, 6681, 6682, 6683, 6684, 6685, 6686, 6687, 6688, 6689, 6690, 6691, + 6692, 6693, 6694, 6695, 6696, 6697, 6698, 6699, 6700, 6701, 6702, 6703, + 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6714, 6715, + 6716, 6717, 6718, 6719, 6720, 6721, 6722, 6723, 6724, 6725, 6726, 6727, + 6728, 6729, 6730, 6731, 6732, 6733, 6734, 6735, 6736, 6737, 6738, 6739, + 6740, 6741, 6742, 6743, 6744, 6745, 6840, 6841, 6842, 6843, 6844, 6845, + 6846, 6847, 6848, 6849, 6850, 6851, 6852, 6853, 6854, 6855, 6856, 6857, + 6858, 6859, 6860, 6861, 6862, 6863, 6864, 6865, 6866, 6867, 6868, 6869, + 6870, 6871, 6872, 6873, 6874, 6875, 6876, 6877, 6878, 6879, 6880, 6881, + 6882, 6883, 6884, 6885, 6886, 6887, 6888, 6889, 6890, 6891, 6892, 6893, + 6894, 6895, 6896, 6897, 6898, 6899, 6900, 6901, 6902, 6903, 6904, 6905, + 6906, 6907, 6908, 6909, 6910, 6911, 6912, 6913, 6914, 6915, 6916, 6917, + 6918, 6919, 6920, 6921, 6922, 6923, 6924, 6925, 6926, 6927, 6928, 6929, + 6930, 6931, 6932, 6933, 6934, 6935, 7030, 7031, 7032, 7033, 7034, 7035, + 7036, 7037, 7038, 7039, 7040, 7041, 7042, 7043, 7044, 7045, 7046, 7047, + 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, + 7060, 7061, 7062, 7063, 7064, 7065, 7066, 7067, 7068, 7069, 7070, 7071, + 7072, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, + 7084, 7085, 7086, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, + 7096, 7097, 7098, 7099, 7100, 7101, 7102, 7103, 7104, 7105, 7106, 7107, + 7108, 7109, 7110, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, + 7120, 7121, 7122, 7123, 7124, 7125, 7220, 7221, 7222, 7223, 7224, 7225, + 7226, 7227, 7228, 7229, 7230, 7231, 7232, 7233, 7234, 7235, 7236, 7237, + 7238, 7239, 7240, 7241, 7242, 7243, 7244, 7245, 7246, 7247, 7248, 7249, + 7250, 7251, 7252, 7253, 7254, 7255, 7256, 7257, 7258, 7259, 7260, 7261, + 7262, 7263, 7264, 7265, 7266, 7267, 7268, 7269, 7270, 7271, 7272, 7273, + 7274, 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7282, 7283, 7284, 7285, + 7286, 7287, 7288, 7289, 7290, 7291, 7292, 7293, 7294, 7295, 7296, 7297, + 7298, 7299, 7300, 7301, 7302, 7303, 7304, 7305, 7306, 7307, 7308, 7309, + 7310, 7311, 7312, 7313, 7314, 7315, 6376, 6377, 6378, 6379, 6380, 6381, + 65535, 6433, 6444, 6445, 6458, 6459, 6829, 6830, 6831, 6832, 6833, 6834, + 6835, 6836, 6837, 6838, 6839, 7022, 7023, 7024, 7025, 7026, 7027, 7028, + 7029, 7150, 7151, 7152, 7153, 7154, 7155, 7156, 7157, 7182, 7183, 7184, + 7185, 7186, 7187, 7188, 7201, 7202, 7208, 7211, 7212, 7213, 7214, 7215, + 7216, 7217, 7218, 7219, 7349, 7350, 7351, 7352, 7353, 7354, 7355, 7356, + 7357, 7358, 7359, 7360, 7361, 7362, 7363, 7397, 7398, 7399, 7400, 7401, + 7402, 7403, 7404, 7405, 7406, 7407, 7408, 7409, 7495, 7496, 7497, 7498, + 7499, 7500, 7501, 7502, 7503, 7504, 7505, 7533, 65535, 7538, 7539, 7540, + 7541, 7579, 7580, 7581, 7582, 7583, 7584, 7585, 7586, 7587, 7588, 7589, + 7590, 7591, 7592, 7593, 7594, 7595, 7596, 7597, 7598, 7599, 7624, 7627, + 7629, 7630, 7631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7686, 7687, 7688, 7689, 7690, 7691, + 7692, 7693, 7694, 7695, 7696, 7697, 7698, 7775, 7776, 7777, 7778, 7779, + 7780, 7781, 7782, 7783, 7784, 7785, 7786, 7787, 7788, 7789, 16525, 16526, + 16527, 16528, 16529, 65535, 23767, 23768, 23769, 65535, 65535, 65535, + 65535, 65535, 23775, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23783, 65535, 65535, 65535, 65535, 23788, 23789, 65535, 65535, 65535, + 65535, 23794, 23795, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 23804, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23812, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 23829, 23830, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23845, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 23651, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23652, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 23653, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23654, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 23655, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 23750, 23751, 23752, 23753, 65535, 23754, 65535, 23755, 23756, 65535, + 65535, 65535, 23757, 65535, 65535, 65535, 65535, 65535, 65535, 23758, + 23759, 23760, 65535, 23761, 23762, 65535, 65535, 23763, 23764, 23765, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7621, 7207, 65535, + 7209, 7210, 7189, 7190, 7205, 7206, 7191, 7192, 7203, 7204, 7195, 7196, + 7193, 7194, 7197, 7198, 7199, 7200, 65535, 65535, 65535, 65535, 7640, 7641, + 7642, 7643, 7644, 7645, 7646, 7647, 7648, 7649, 65535, 7650, 7651, 7652, + 7653, 65535, 7654, 7655, 7656, 7657, 7658, 7659, 7660, 7661, 7662, 7663, + 7664, 7665, 7666, 7667, 65535, 7668, 7669, 7670, 7671, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6556, 6557, 6558, + 6246, 6560, 6561, 6562, 6563, 6564, 6565, 6566, 6567, 6568, 6569, 6570, + 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578, 6579, 6580, 6581, 6582, + 6583, 6584, 6585, 6586, 6587, 6588, 6589, 6590, 6591, 6592, 6593, 6594, + 6595, 6596, 6597, 6598, 6599, 6600, 6601, 6602, 6603, 6604, 6605, 6606, + 6607, 6608, 6609, 6610, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, + 6619, 6620, 6621, 6622, 6623, 6624, 6625, 6626, 6627, 6628, 6629, 6630, + 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, + 6643, 6644, 6645, 6646, 6647, 6648, 6186, 65535, 6248, 6249, 7622, 6649, + 7623, 6559, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 64, 96, 128, 160, 192, 224, 0, 0, 256, 288, 0, 0, 320, + 352, 0, 0, 384, 0, 0, 0, 0, 0, 416, 448, 480, 0, 512, 544, 576, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 608, 640, 0, 0, 0, 672, + 0, 0, 704, 736, 0, 768, 800, 0, 0, 0, 832, 864, 896, 928, 960, 992, 0, 0, + 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1056, 1088, 0, 0, 0, 1120, 1152, 1184, + 1216, 1248, 1280, 1312, 1344, 1376, 0, 1408, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1440, 1472, 1504, 0, 0, 0, 0, 0, 0, 0, 0, 1536, 1568, 1600, + 1632, 1664, 1696, 1728, 1760, 1792, 1824, 1856, 0, 0, 0, 0, 0, 0, 0, 1888, + 0, 0, 0, 1920, 0, 0, 0, 0, 0, 0, 1952, 1984, 2016, 0, 0, 0, 2048, 2080, 0, + 0, 0, 0, 0, 0, 0, 0, 2112, 0, 0, 0, 2144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2176, 0, 0, 2208, 0, 0, 2240, 0, 0, 0, + 0, 2272, 0, 0, 0, 0, 0, 0, 2304, 0, 0, 0, 0, 0, 0, 0, 0, 2336, 0, 0, 0, + 2368, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2400, 0, 0, 0, 0, 0, 0, 0, 2432, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2464, 0, 0, 0, 2496, 2528, 0, 0, 0, 0, 0, 0, 0, 2560, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2592, 2624, 0, 0, 0, 0, 0, 2656, 0, 2688, 2720, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2752, 2784, 2816, 2848, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2880, 2912, 2944, 0, 0, 2976, + 0, 0, 0, 0, 3008, 0, 0, 3040, 3072, 3104, 3136, 3168, 3200, 3232, 3264, + 3296, 3328, 3360, 3392, 3424, 3456, 3488, 3520, 3552, 3584, 3616, 3648, + 3680, 3712, 3744, 3776, 3808, 3840, 3872, 3904, 3936, 3968, 4000, 4032, + 4064, 4096, 4128, 4160, 4192, 4224, 4256, 4288, 4320, 4352, 4384, 4416, + 4448, 4480, 4512, 4544, 4576, 4608, 4640, 4672, 4704, 4736, 4768, 4800, + 4832, 4864, 4896, 4928, 4960, 4992, 5024, 5056, 5088, 5120, 5152, 5184, + 5216, 5248, 5280, 5312, 5344, 5376, 5408, 5440, 5472, 5504, 5536, 5568, + 5600, 5632, 5664, 5696, 5728, 5760, 5792, 5824, 5856, 5888, 5920, 5952, + 5984, 6016, 6048, 6080, 6112, 6144, 6176, 6208, 6240, 6272, 6304, 6336, + 6368, 6400, 6432, 6464, 6496, 6528, 6560, 6592, 6624, 6656, 6688, 6720, + 6752, 6784, 6816, 6848, 6880, 6912, 6944, 6976, 7008, 7040, 7072, 7104, + 7136, 7168, 7200, 7232, 7264, 7296, 7328, 7360, 7392, 7424, 7456, 7488, + 7520, 7552, 7584, 7616, 7648, 7680, 7712, 7744, 7776, 7808, 7840, 7872, + 7904, 7936, 7968, 8000, 8032, 8064, 8096, 8128, 8160, 8192, 8224, 8256, + 8288, 8320, 8352, 8384, 8416, 8448, 8480, 8512, 8544, 8576, 8608, 8640, + 8672, 8704, 8736, 8768, 8800, 8832, 8864, 8896, 8928, 8960, 8992, 9024, + 9056, 9088, 9120, 9152, 9184, 9216, 9248, 9280, 9312, 9344, 9376, 9408, + 9440, 9472, 9504, 9536, 9568, 9600, 9632, 9664, 9696, 9728, 9760, 9792, + 9824, 9856, 9888, 9920, 9952, 9984, 10016, 10048, 10080, 10112, 10144, + 10176, 10208, 10240, 10272, 10304, 10336, 10368, 10400, 10432, 10464, + 10496, 10528, 10560, 10592, 10624, 10656, 10688, 10720, 10752, 10784, + 10816, 10848, 10880, 10912, 10944, 10976, 11008, 11040, 11072, 11104, + 11136, 11168, 11200, 11232, 11264, 11296, 11328, 11360, 11392, 11424, + 11456, 11488, 11520, 11552, 11584, 11616, 11648, 11680, 11712, 11744, + 11776, 11808, 11840, 11872, 11904, 11936, 11968, 12000, 12032, 12064, + 12096, 12128, 12160, 12192, 12224, 12256, 12288, 12320, 12352, 12384, + 12416, 12448, 12480, 12512, 12544, 12576, 12608, 12640, 12672, 12704, + 12736, 12768, 12800, 12832, 12864, 12896, 12928, 12960, 12992, 13024, + 13056, 13088, 13120, 13152, 13184, 13216, 13248, 13280, 13312, 13344, + 13376, 13408, 13440, 13472, 13504, 13536, 13568, 13600, 13632, 13664, + 13696, 13728, 13760, 13792, 13824, 13856, 13888, 13920, 13952, 13984, + 14016, 14048, 14080, 14112, 14144, 14176, 14208, 14240, 14272, 14304, + 14336, 14368, 14400, 14432, 14464, 14496, 14528, 14560, 14592, 14624, + 14656, 14688, 14720, 14752, 14784, 14816, 14848, 14880, 14912, 14944, + 14976, 15008, 15040, 15072, 15104, 15136, 15168, 15200, 15232, 15264, + 15296, 15328, 15360, 15392, 15424, 15456, 15488, 15520, 15552, 15584, + 15616, 15648, 15680, 15712, 15744, 15776, 15808, 15840, 15872, 15904, + 15936, 15968, 16000, 16032, 16064, 16096, 16128, 16160, 16192, 16224, + 16256, 16288, 16320, 16352, 16384, 16416, 16448, 16480, 16512, 16544, + 16576, 16608, 16640, 16672, 16704, 16736, 16768, 16800, 16832, 16864, + 16896, 16928, 16960, 16992, 17024, 17056, 17088, 17120, 17152, 17184, + 17216, 17248, 17280, 17312, 17344, 17376, 17408, 17440, 17472, 17504, + 17536, 17568, 17600, 17632, 17664, 17696, 17728, 17760, 17792, 17824, + 17856, 17888, 17920, 17952, 17984, 18016, 18048, 18080, 18112, 18144, + 18176, 18208, 18240, 18272, 18304, 18336, 18368, 18400, 18432, 18464, + 18496, 18528, 18560, 18592, 18624, 18656, 18688, 18720, 18752, 18784, + 18816, 18848, 18880, 18912, 18944, 18976, 19008, 19040, 19072, 19104, + 19136, 19168, 19200, 19232, 19264, 19296, 19328, 19360, 19392, 19424, + 19456, 19488, 19520, 19552, 19584, 19616, 19648, 19680, 19712, 19744, + 19776, 19808, 19840, 19872, 19904, 19936, 19968, 20000, 20032, 20064, + 20096, 20128, 20160, 20192, 20224, 20256, 20288, 20320, 20352, 20384, + 20416, 20448, 20480, 20512, 20544, 20576, 20608, 20640, 20672, 20704, + 20736, 20768, 20800, 20832, 20864, 20896, 20928, 20960, 20992, 21024, + 21056, 21088, 21120, 21152, 21184, 21216, 21248, 21280, 21312, 21344, + 21376, 21408, 21440, 21472, 21504, 21536, 21568, 21600, 21632, 21664, + 21696, 21728, 21760, 21792, 21824, 21856, 21888, 21920, 21952, 21984, + 22016, 22048, 22080, 22112, 22144, 22176, 22208, 22240, 22272, 22304, + 22336, 22368, 22400, 22432, 22464, 22496, 22528, 22560, 22592, 22624, + 22656, 22688, 22720, 22752, 22784, 22816, 22848, 22880, 22912, 22944, + 22976, 23008, 23040, 23072, 23104, 23136, 23168, 23200, 23232, 23264, + 23296, 23328, 23360, 23392, 23424, 23456, 23488, 23520, 23552, 23584, + 23616, 23648, 23680, 23712, 23744, 23776, 23808, 23840, 23872, 23904, + 23936, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23968, 24000, 24032, 24064, + 24096, 24128, 24160, 24192, 24224, 24256, 24288, 24320, 24352, 24384, + 24416, 24448, 24480, 24512, 24544, 24576, 24608, 24640, 24672, 24704, + 24736, 24768, 24800, 24832, 24864, 24896, 24928, 24960, 24992, 25024, + 25056, 25088, 25120, 25152, 25184, 25216, 25248, 25280, 25312, 25344, + 25376, 25408, 25440, 25472, 25504, 25536, 25568, 25600, 25632, 25664, + 25696, 25728, 25760, 25792, 25824, 25856, 25888, 25920, 25952, 25984, + 26016, 26048, 26080, 26112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26144, 0, 26176, 26208, + 0, 0, 26240, 26272, 26304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26336, 26368, 26400, 0, 0, 0, + 0, 26432, 26464, 26496, 0, 0, 0, 0, 26528, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u16 { + let offset = (code >> 5) as usize; + let offset = if offset < 2048 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +multi_byte_tests!( + mod = gb18030, + dups = [ + 6555, + ] +); diff --git a/deps/encoding-index-simpchinese-1.20141219.5/gb18030_ranges.rs b/deps/encoding-index-simpchinese-1.20141219.5/gb18030_ranges.rs new file mode 100644 index 000000000..490f3105a --- /dev/null +++ b/deps/encoding-index-simpchinese-1.20141219.5/gb18030_ranges.rs @@ -0,0 +1,91 @@ +// AUTOGENERATED FROM index-gb18030-ranges.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-gb18030-ranges.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: f963aaa1653f630c523e7b04729fb4e4458f35806c45eb5c179445623138f0c0 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u32] = &[ + 0, 128, 165, 169, 178, 184, 216, 226, 235, 238, 244, 248, 251, 253, 258, + 276, 284, 300, 325, 329, 334, 364, 463, 465, 467, 469, 471, 473, 475, 477, + 506, 594, 610, 712, 716, 730, 930, 938, 962, 970, 1026, 1104, 1106, 8209, + 8215, 8218, 8222, 8231, 8241, 8244, 8246, 8252, 8365, 8452, 8454, 8458, + 8471, 8482, 8556, 8570, 8596, 8602, 8713, 8720, 8722, 8726, 8731, 8737, + 8740, 8742, 8748, 8751, 8760, 8766, 8777, 8781, 8787, 8802, 8808, 8816, + 8854, 8858, 8870, 8896, 8979, 9322, 9372, 9548, 9588, 9616, 9622, 9634, + 9652, 9662, 9672, 9676, 9680, 9702, 9735, 9738, 9793, 9795, 11906, 11909, + 11913, 11917, 11928, 11944, 11947, 11951, 11956, 11960, 11964, 11979, + 12284, 12292, 12312, 12319, 12330, 12351, 12436, 12447, 12535, 12543, + 12586, 12842, 12850, 12964, 13200, 13215, 13218, 13253, 13263, 13267, + 13270, 13384, 13428, 13727, 13839, 13851, 14617, 14703, 14801, 14816, + 14964, 15183, 15471, 15585, 16471, 16736, 17208, 17325, 17330, 17374, + 17623, 17997, 18018, 18212, 18218, 18301, 18318, 18760, 18811, 18814, + 18820, 18823, 18844, 18848, 18872, 19576, 19620, 19738, 19887, 40870, + 59244, 59336, 59367, 59413, 59417, 59423, 59431, 59437, 59443, 59452, + 59460, 59478, 59493, 63789, 63866, 63894, 63976, 63986, 64016, 64018, + 64021, 64025, 64034, 64037, 64042, 65074, 65093, 65107, 65112, 65127, + 65132, 65375, 65510, 65536, +]; + +static BACKWARD_TABLE: &'static [u32] = &[ + 0, 0, 36, 38, 45, 50, 81, 89, 95, 96, 100, 103, 104, 105, 109, 126, 133, + 148, 172, 175, 179, 208, 306, 307, 308, 309, 310, 311, 312, 313, 341, 428, + 443, 544, 545, 558, 741, 742, 749, 750, 805, 819, 820, 7922, 7924, 7925, + 7927, 7934, 7943, 7944, 7945, 7950, 8062, 8148, 8149, 8152, 8164, 8174, + 8236, 8240, 8262, 8264, 8374, 8380, 8381, 8384, 8388, 8390, 8392, 8393, + 8394, 8396, 8401, 8406, 8416, 8419, 8424, 8437, 8439, 8445, 8482, 8485, + 8496, 8521, 8603, 8936, 8946, 9046, 9050, 9063, 9066, 9076, 9092, 9100, + 9108, 9111, 9113, 9131, 9162, 9164, 9218, 9219, 11329, 11331, 11334, 11336, + 11346, 11361, 11363, 11366, 11370, 11372, 11375, 11389, 11682, 11686, + 11687, 11692, 11694, 11714, 11716, 11723, 11725, 11730, 11736, 11982, + 11989, 12102, 12336, 12348, 12350, 12384, 12393, 12395, 12397, 12510, + 12553, 12851, 12962, 12973, 13738, 13823, 13919, 13933, 14080, 14298, + 14585, 14698, 15583, 15847, 16318, 16434, 16438, 16481, 16729, 17102, + 17122, 17315, 17320, 17402, 17418, 17859, 17909, 17911, 17915, 17916, + 17936, 17939, 17961, 18664, 18703, 18814, 18962, 19043, 33469, 33470, + 33471, 33484, 33485, 33490, 33497, 33501, 33505, 33513, 33520, 33536, + 33550, 37845, 37921, 37948, 38029, 38038, 38064, 38065, 38066, 38069, + 38075, 38076, 38078, 39108, 39109, 39113, 39114, 39115, 39116, 39265, + 39394, 189000, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u32) -> u32 { + if (code > 39419 && code < 189000) || code > 1237575 { return 0xffffffff; } + let mut i = if code >= BACKWARD_TABLE[127] {81} else {0}; + if code >= BACKWARD_TABLE[i+63] { i += 64; } + if code >= BACKWARD_TABLE[i+31] { i += 32; } + if code >= BACKWARD_TABLE[i+15] { i += 16; } + if code >= BACKWARD_TABLE[i+7] { i += 8; } + if code >= BACKWARD_TABLE[i+3] { i += 4; } + if code >= BACKWARD_TABLE[i+1] { i += 2; } + if code >= BACKWARD_TABLE[i] { i += 1; } + (code - BACKWARD_TABLE[i-1]) + FORWARD_TABLE[i-1] +} + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u32 { + if code < 128 { return 0xffffffff; } + let mut i = if code >= FORWARD_TABLE[127] {81} else {0}; + if code >= FORWARD_TABLE[i+63] { i += 64; } + if code >= FORWARD_TABLE[i+31] { i += 32; } + if code >= FORWARD_TABLE[i+15] { i += 16; } + if code >= FORWARD_TABLE[i+7] { i += 8; } + if code >= FORWARD_TABLE[i+3] { i += 4; } + if code >= FORWARD_TABLE[i+1] { i += 2; } + if code >= FORWARD_TABLE[i] { i += 1; } + (code - FORWARD_TABLE[i-1]) + BACKWARD_TABLE[i-1] +} + +#[cfg(test)] +multi_byte_range_tests!( + mod = gb18030_ranges, + key = [0, 189000], key < 1114112, + value = [128, 65536], value < 1587600 +); diff --git a/deps/encoding-index-simpchinese-1.20141219.5/lib.rs b/deps/encoding-index-simpchinese-1.20141219.5/lib.rs new file mode 100644 index 000000000..ad04ecc1f --- /dev/null +++ b/deps/encoding-index-simpchinese-1.20141219.5/lib.rs @@ -0,0 +1,33 @@ +// This is a part of rust-encoding. +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ + +//! Simplified Chinese index tables for +//! [rust-encoding](https://github.com/lifthrasiir/rust-encoding). + +#![cfg_attr(test, feature(test))] + +#[cfg(test)] +#[macro_use] +extern crate encoding_index_tests; + +/// GB 18030 two-byte area. +/// +/// From the Encoding Standard: +/// +/// > This matches the GB18030 standard for code points encoded as two bytes, +/// > except `0xA3 0xA0` maps to U+3000 to be compatible with deployed content. +pub mod gb18030; + +/// GB 18030 four-byte area. +/// +/// From the Encoding Standard: +/// +/// > This index works different from all others. +/// > Listing all code points would result in over a million items +/// > whereas they can be represented neatly in 207 ranges combined with trivial limit checks. +/// > It therefore only superficially matches the GB18030 standard +/// > for code points encoded as four bytes. +pub mod gb18030_ranges; + diff --git a/deps/encoding-index-singlebyte-1.20141219.5/Cargo.toml b/deps/encoding-index-singlebyte-1.20141219.5/Cargo.toml new file mode 100644 index 000000000..4521ca049 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "encoding-index-singlebyte" +version = "1.20141219.5" +authors = ["Kang Seonghoon "] + +description = "Index tables for various single-byte character encodings" +homepage = "https://github.com/lifthrasiir/rust-encoding" +readme = "../../../README.md" +license = "CC0-1.0" + +[lib] +name = "encoding_index_singlebyte" +path = "lib.rs" + +[dependencies.encoding_index_tests] +# TODO consider using dev-dependencies instead (Cargo issue #860) +version = "0.1.4" +path = "../tests" diff --git a/deps/encoding-index-singlebyte-1.20141219.5/ibm866.rs b/deps/encoding-index-singlebyte-1.20141219.5/ibm866.rs new file mode 100644 index 000000000..2cd4e78c4 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/ibm866.rs @@ -0,0 +1,83 @@ +// AUTOGENERATED FROM index-ibm866.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-ibm866.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: db6fe14a559d1601a7667338d83704773d5708dbc641e1ad3c5e21405770f05e +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, + 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, + 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, + 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, + 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, + 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, + 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, + 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, + 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, + 1100, 1101, 1102, 1103, 1025, 1105, 1028, 1108, 1031, 1111, 1038, 1118, + 176, 8729, 183, 8730, 8470, 164, 9632, 160, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 248, 0, 0, 0, 0, 0, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 0, 242, 0, + 0, 244, 0, 0, 0, 0, 0, 0, 246, 0, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 0, 241, 0, 0, 243, + 0, 0, 245, 0, 0, 0, 0, 0, 0, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 249, 251, 0, 0, + 0, 0, 0, 196, 0, 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 218, 0, 0, 0, 191, 0, 0, + 0, 192, 0, 0, 0, 217, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, 0, 0, + 0, 0, 0, 194, 0, 0, 0, 0, 0, 0, 0, 193, 0, 0, 0, 0, 0, 0, 0, 197, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 205, 186, 213, 214, 201, + 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, + 209, 210, 203, 207, 208, 202, 216, 215, 206, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, 0, 220, 0, 0, 0, 219, 0, 0, 0, 221, + 0, 0, 0, 222, 176, 177, 178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 64, 96, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0, 0, 0, 0, 0, 0, 192, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, + 256, 288, 320, 352, 384, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 302 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = ibm866 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_10.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_10.rs new file mode 100644 index 000000000..70ad7f19d --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_10.rs @@ -0,0 +1,72 @@ +// AUTOGENERATED FROM index-iso-8859-10.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-10.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 02c2b5590d8ccda9931008c471f6ee2c590b2c8fe5e6ccb3b08638115d778507 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 260, 274, 290, 298, 296, 310, 167, 315, 272, 352, 358, 381, + 173, 362, 330, 176, 261, 275, 291, 299, 297, 311, 183, 316, 273, 353, 359, + 382, 8213, 363, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, + 203, 278, 205, 206, 207, 208, 325, 332, 211, 212, 213, 214, 360, 216, 370, + 218, 219, 220, 221, 222, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, + 233, 281, 235, 279, 237, 238, 239, 240, 326, 333, 243, 244, 245, 246, 361, + 248, 371, 250, 251, 252, 253, 254, 312, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 0, 0, + 0, 167, 0, 0, 0, 0, 0, 173, 0, 0, 176, 0, 0, 0, 0, 0, 0, 183, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 193, 194, 195, 196, 197, 198, 0, 0, 201, 0, 203, 0, 205, + 206, 207, 208, 0, 0, 211, 212, 213, 214, 0, 216, 0, 218, 219, 220, 221, + 222, 223, 0, 225, 226, 227, 228, 229, 230, 0, 0, 233, 0, 235, 0, 237, 238, + 239, 240, 0, 0, 243, 244, 245, 246, 0, 248, 0, 250, 251, 252, 253, 254, 0, + 192, 224, 0, 0, 161, 177, 0, 0, 0, 0, 0, 0, 200, 232, 0, 0, 169, 185, 162, + 178, 0, 0, 204, 236, 202, 234, 0, 0, 0, 0, 0, 0, 0, 0, 163, 179, 0, 0, 0, + 0, 165, 181, 164, 180, 0, 0, 199, 231, 0, 0, 0, 0, 0, 0, 166, 182, 255, 0, + 0, 168, 184, 0, 0, 0, 0, 0, 0, 0, 0, 209, 241, 0, 0, 0, 175, 191, 210, 242, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 186, 0, 0, 0, 0, + 171, 187, 215, 247, 174, 190, 0, 0, 0, 0, 0, 0, 217, 249, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 172, 188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 192, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 320, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 129 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_10 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_13.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_13.rs new file mode 100644 index 000000000..5a68c50eb --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_13.rs @@ -0,0 +1,72 @@ +// AUTOGENERATED FROM index-iso-8859-13.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-13.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 40736338e964ab520407cebcb01329f8d450abf6ce12bf88b74b655b60e43300 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 8221, 162, 163, 164, 8222, 166, 167, 216, 169, 342, 171, + 172, 173, 174, 198, 176, 177, 178, 179, 8220, 181, 182, 183, 248, 185, 343, + 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, + 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, + 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, + 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, + 247, 371, 322, 347, 363, 252, 380, 382, 8217, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, 162, 163, + 164, 0, 166, 167, 0, 169, 0, 171, 172, 173, 174, 0, 176, 177, 178, 179, 0, + 181, 182, 183, 0, 185, 0, 187, 188, 189, 190, 0, 0, 0, 0, 0, 196, 197, 175, + 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 211, 0, 213, 214, 215, 168, 0, 0, 0, + 220, 0, 0, 223, 0, 0, 0, 0, 228, 229, 191, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 243, 0, 245, 246, 247, 184, 0, 0, 0, 252, 0, 0, 0, 194, 226, 0, 0, + 192, 224, 195, 227, 0, 0, 0, 0, 200, 232, 0, 0, 0, 0, 199, 231, 0, 0, 203, + 235, 198, 230, 0, 0, 0, 0, 0, 0, 0, 0, 204, 236, 0, 0, 0, 0, 0, 0, 206, + 238, 0, 0, 193, 225, 0, 0, 0, 0, 0, 0, 205, 237, 0, 0, 0, 207, 239, 0, 0, + 0, 0, 217, 249, 209, 241, 210, 242, 0, 0, 0, 0, 0, 212, 244, 0, 0, 0, 0, 0, + 0, 0, 0, 170, 186, 0, 0, 218, 250, 0, 0, 0, 0, 208, 240, 0, 0, 0, 0, 0, 0, + 0, 0, 219, 251, 0, 0, 0, 0, 0, 0, 216, 248, 0, 0, 0, 0, 0, 202, 234, 221, + 253, 222, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 255, 0, 0, 180, 161, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 192, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 320, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 129 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_13 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_14.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_14.rs new file mode 100644 index 000000000..078d6afdf --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_14.rs @@ -0,0 +1,79 @@ +// AUTOGENERATED FROM index-iso-8859-14.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-14.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 2c8651cfc08b1f35b17919ee5379f2fa006af3ec809f11b3b7f470785580542b +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, + 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, + 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, + 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, + 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, + 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 0, 163, 0, 0, 0, 167, 0, 169, 0, 0, + 0, 173, 174, 0, 0, 0, 0, 0, 0, 0, 182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 0, + 209, 210, 211, 212, 213, 214, 0, 216, 217, 218, 219, 220, 221, 0, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 0, 241, 242, 243, 244, 245, 246, 0, 248, 249, 250, 251, 252, 253, 0, 255, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 178, 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 240, 222, 254, 175, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 161, 162, 0, 0, 0, 0, 0, 0, 166, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 176, 177, 180, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 185, 0, 0, 0, 0, 0, 0, 0, 0, 187, + 191, 0, 0, 0, 0, 0, 0, 0, 0, 215, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 168, 184, 170, 186, 189, 190, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 172, 188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 160, 192, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0, 288, 320, + 352, 0, 0, 384, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 248 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_14 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_15.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_15.rs new file mode 100644 index 000000000..3c7ca351c --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_15.rs @@ -0,0 +1,70 @@ +// AUTOGENERATED FROM index-iso-8859-15.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-15.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: a560aba47bccd7510a6ac77f671fe75dca3800f05cf6d676910c311a8f8ff079 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, + 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, + 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, + 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, + 248, 249, 250, 251, 252, 253, 254, 255, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, + 0, 165, 0, 167, 0, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 0, 181, 182, 183, 0, 185, 186, 187, 0, 0, 0, 191, 192, 193, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, + 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 188, 189, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 166, 168, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 190, 0, 0, 0, 0, 180, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 256, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 131 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_15 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_16.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_16.rs new file mode 100644 index 000000000..aa9a95869 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_16.rs @@ -0,0 +1,76 @@ +// AUTOGENERATED FROM index-iso-8859-16.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-16.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 55676320d2d1b6e6909f5b3d741a7cf0cefc84e920aa4474afc091459111c2e3 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, + 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, + 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, + 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, + 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, + 347, 369, 249, 250, 251, 252, 281, 539, 255, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 0, 0, 0, 167, 0, 169, 0, 171, + 0, 173, 0, 0, 176, 177, 0, 0, 0, 0, 182, 183, 0, 0, 0, 187, 0, 0, 0, 0, + 192, 193, 194, 0, 196, 0, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + 0, 0, 210, 211, 212, 0, 214, 0, 0, 217, 218, 219, 220, 0, 0, 223, 224, 225, + 226, 0, 228, 0, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 0, 0, + 242, 243, 244, 0, 246, 0, 0, 249, 250, 251, 252, 0, 0, 255, 0, 0, 195, 227, + 161, 162, 197, 229, 0, 0, 0, 0, 178, 185, 0, 0, 208, 240, 0, 0, 0, 0, 0, 0, + 221, 253, 0, 0, 0, 0, 0, 0, 0, 163, 179, 209, 241, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 213, 245, 188, 189, 0, 0, 0, 0, 0, 0, 215, 247, 0, 0, 0, 0, 166, + 168, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 248, 0, 0, 0, 0, 0, 0, + 190, 172, 174, 175, 191, 180, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 186, 222, 254, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 181, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 160, 0, 192, 224, 0, 0, 0, 0, 256, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 288, 0, 0, 0, 0, 320, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 262 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_16 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_2.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_2.rs new file mode 100644 index 000000000..0c9a03659 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_2.rs @@ -0,0 +1,66 @@ +// AUTOGENERATED FROM index-iso-8859-2.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-2.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 9569c67f22d0b57790e1c407c6eecf227e4562322dc296de43cdab7a0152ec73 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, + 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, + 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, + 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, + 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, + 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, + 345, 367, 250, 369, 252, 253, 355, 729, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, + 164, 0, 0, 167, 168, 0, 0, 0, 0, 173, 0, 0, 176, 0, 0, 0, 180, 0, 0, 0, + 184, 0, 0, 0, 0, 0, 0, 0, 0, 193, 194, 0, 196, 0, 0, 199, 0, 201, 0, 203, + 0, 205, 206, 0, 0, 0, 0, 211, 212, 0, 214, 215, 0, 0, 218, 0, 220, 221, 0, + 223, 0, 225, 226, 0, 228, 0, 0, 231, 0, 233, 0, 235, 0, 237, 238, 0, 0, 0, + 0, 243, 244, 0, 246, 247, 0, 0, 250, 0, 252, 253, 0, 0, 0, 0, 195, 227, + 161, 177, 198, 230, 0, 0, 0, 0, 200, 232, 207, 239, 208, 240, 0, 0, 0, 0, + 0, 0, 202, 234, 204, 236, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197, 229, + 0, 0, 165, 181, 0, 0, 163, 179, 209, 241, 0, 0, 210, 242, 0, 0, 0, 0, 0, 0, + 0, 213, 245, 0, 0, 192, 224, 0, 0, 216, 248, 166, 182, 0, 0, 170, 186, 169, + 185, 222, 254, 171, 187, 0, 0, 0, 0, 0, 0, 0, 0, 217, 249, 219, 251, 0, 0, + 0, 0, 0, 0, 0, 172, 188, 175, 191, 174, 190, 0, 0, 0, 0, 0, 0, 0, 0, 183, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 255, 0, 178, 0, 189, + 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 0, 176, + 192, 208, 224, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 256, 272, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 4) as usize; + let offset = if offset < 46 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 15) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_2 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_3.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_3.rs new file mode 100644 index 000000000..faec941b5 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_3.rs @@ -0,0 +1,64 @@ +// AUTOGENERATED FROM index-iso-8859-3.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-3.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: af8f1e12df79b768322b5e83613698cdc619438270a2fc359554331c805054a3 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 294, 728, 163, 164, 65535, 292, 167, 168, 304, 350, 286, + 308, 173, 65535, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, + 351, 287, 309, 189, 65535, 380, 192, 193, 194, 65535, 196, 266, 264, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 65535, 209, 210, 211, 212, 288, + 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, 65535, + 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, 65535, 241, + 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 0, 0, 163, 164, 0, 0, 167, 168, 0, + 0, 0, 0, 173, 0, 0, 176, 0, 178, 179, 180, 181, 0, 183, 184, 0, 0, 0, 0, + 189, 0, 0, 192, 193, 194, 0, 196, 0, 0, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 0, 209, 210, 211, 212, 0, 214, 215, 0, 217, 218, 219, 220, 0, 0, + 223, 224, 225, 226, 0, 228, 0, 0, 231, 232, 233, 234, 235, 236, 237, 238, + 239, 0, 241, 242, 243, 244, 0, 246, 247, 0, 249, 250, 251, 252, 0, 0, 0, + 198, 230, 197, 229, 0, 0, 0, 0, 0, 0, 0, 0, 216, 248, 171, 187, 213, 245, + 0, 0, 166, 182, 161, 177, 169, 185, 0, 0, 172, 188, 0, 0, 0, 0, 0, 0, 222, + 254, 170, 186, 0, 0, 0, 0, 221, 253, 0, 0, 0, 0, 0, 175, 191, 0, 0, 0, 162, + 255, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 16, 24, 32, 40, 48, 56, + 64, 72, 80, 88, 96, 104, 112, 120, 128, 0, 136, 0, 144, 152, 0, 160, 0, 0, + 0, 0, 168, 0, 176, 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 192, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 3) as usize; + let offset = if offset < 92 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 7) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_3 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_4.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_4.rs new file mode 100644 index 000000000..0015f542f --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_4.rs @@ -0,0 +1,66 @@ +// AUTOGENERATED FROM index-iso-8859-4.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-4.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 72f29c92344d351fe9e74a946e7e0468d76d542c6894ff82982cb652ebe0feb7 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 260, 312, 342, 164, 296, 315, 167, 168, 352, 274, 290, 358, + 173, 381, 175, 176, 261, 731, 343, 180, 297, 316, 711, 184, 353, 275, 291, + 359, 330, 382, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, + 203, 278, 205, 206, 298, 272, 325, 332, 310, 212, 213, 214, 215, 216, 370, + 218, 219, 220, 360, 362, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, + 233, 281, 235, 279, 237, 238, 299, 273, 326, 333, 311, 244, 245, 246, 247, + 248, 371, 250, 251, 252, 361, 363, 729, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 164, 0, 0, 167, 168, 0, 0, 0, + 0, 173, 0, 175, 176, 0, 0, 0, 180, 0, 0, 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, + 193, 194, 195, 196, 197, 198, 0, 0, 201, 0, 203, 0, 205, 206, 0, 0, 0, 0, + 0, 212, 213, 214, 215, 216, 0, 218, 219, 220, 0, 0, 223, 0, 225, 226, 227, + 228, 229, 230, 0, 0, 233, 0, 235, 0, 237, 238, 0, 0, 0, 0, 0, 244, 245, + 246, 247, 248, 0, 250, 251, 252, 0, 0, 0, 192, 224, 0, 0, 161, 177, 0, 0, + 0, 0, 0, 0, 200, 232, 0, 0, 208, 240, 170, 186, 0, 0, 204, 236, 202, 234, + 0, 0, 0, 0, 0, 0, 0, 0, 171, 187, 0, 0, 0, 0, 165, 181, 207, 239, 0, 0, + 199, 231, 0, 0, 0, 0, 0, 0, 211, 243, 162, 0, 0, 166, 182, 0, 0, 0, 0, 0, + 0, 0, 0, 209, 241, 0, 0, 0, 189, 191, 210, 242, 0, 0, 0, 0, 0, 0, 0, 0, + 163, 179, 0, 0, 0, 0, 0, 0, 0, 0, 169, 185, 0, 0, 0, 0, 172, 188, 221, 253, + 222, 254, 0, 0, 0, 0, 0, 0, 217, 249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 174, 190, + 0, 0, 0, 0, 0, 0, 0, 0, 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 255, 0, 178, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 160, 192, 224, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 288, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 23 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_4 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_5.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_5.rs new file mode 100644 index 000000000..191c0c2f6 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_5.rs @@ -0,0 +1,72 @@ +// AUTOGENERATED FROM index-iso-8859-5.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-5.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: fa9b1f3f5242df43e2e7bca80e9b6997c67944f20a4af91ee06bacc4e132d9c9 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, + 1035, 1036, 173, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, + 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, + 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, + 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, + 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, + 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 8470, 1105, 1106, + 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 167, 1118, + 1119, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 0, 0, + 0, 253, 0, 0, 0, 0, 0, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 0, + 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, + 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, + 234, 235, 236, 237, 238, 239, 0, 241, 242, 243, 244, 245, 246, 247, 248, + 249, 250, 251, 252, 0, 254, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_5 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_6.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_6.rs new file mode 100644 index 000000000..acdca54dc --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_6.rs @@ -0,0 +1,62 @@ +// AUTOGENERATED FROM index-iso-8859-6.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-6.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 85bb7b5c2dc75975afebe5743935ba4ed5a09c1e9e34e9bfb2ff80293f5d8bbc +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 65535, 65535, 65535, 164, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1548, 173, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1563, 65535, 65535, 65535, 1567, + 65535, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, + 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, + 1592, 1593, 1594, 65535, 65535, 65535, 65535, 65535, 1600, 1601, 1602, + 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, + 1615, 1616, 1617, 1618, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, + 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 0, + 0, 0, 191, 0, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, 0, + 0, 0, 0, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, + 237, 238, 239, 240, 241, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, + 128, 160, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 51 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_6 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_7.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_7.rs new file mode 100644 index 000000000..013a6743b --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_7.rs @@ -0,0 +1,73 @@ +// AUTOGENERATED FROM index-iso-8859-7.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-7.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: f53d8aeba36314ef950eef02ffcf11dff540638ce27dfe7a86b6ccc6875afb24 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 8216, 8217, 163, 8364, 8367, 166, 167, 168, 169, 890, 171, + 172, 173, 65535, 8213, 176, 177, 178, 179, 900, 901, 902, 183, 904, 905, + 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, + 921, 922, 923, 924, 925, 926, 927, 928, 929, 65535, 931, 932, 933, 934, + 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, + 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, + 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 65535, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 0, 163, 0, 0, 166, 167, 168, 169, 0, + 171, 172, 173, 0, 0, 176, 177, 178, 179, 0, 0, 0, 183, 0, 0, 0, 187, 0, + 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 181, 182, 0, 184, 185, + 186, 0, 188, 0, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 0, 211, 212, 213, 214, 215, 216, + 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, + 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, + 247, 248, 249, 250, 251, 252, 253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 175, 0, 0, 161, 162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 164, 0, 0, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 96, 128, 160, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 0, 256, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 262 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_7 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_8.rs b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_8.rs new file mode 100644 index 000000000..82f99fd83 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/iso_8859_8.rs @@ -0,0 +1,71 @@ +// AUTOGENERATED FROM index-iso-8859-8.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-iso-8859-8.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 7657a9ca3fa875990da960d3f812eea28dcd0ae6ed55a18d5394303c86f5484b +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 160, 65535, 162, 163, 164, 165, 166, 167, 168, 169, 215, 171, + 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, + 187, 188, 189, 190, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 8215, 1488, 1489, 1490, 1491, 1492, 1493, 1494, + 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, + 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 65535, 65535, 8206, 8207, + 65535, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, 162, 163, + 164, 165, 166, 167, 168, 169, 0, 171, 172, 173, 174, 175, 176, 177, 178, + 179, 180, 181, 182, 183, 184, 185, 0, 187, 188, 189, 190, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, + 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 256, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 129 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = iso_8859_8 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/koi8_r.rs b/deps/encoding-index-singlebyte-1.20141219.5/koi8_r.rs new file mode 100644 index 000000000..05c535cc9 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/koi8_r.rs @@ -0,0 +1,87 @@ +// AUTOGENERATED FROM index-koi8-r.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-koi8-r.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: c5497cd9071cb352c0e56b219154e539badf63de40b71578f09e2e11fe7d50ae +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, + 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, + 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 9555, + 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, + 9568, 9569, 1025, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, + 9579, 9580, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, + 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, + 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, + 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, + 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, + 1067, 1047, 1064, 1069, 1065, 1063, 1066, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 154, 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, 0, 0, 0, 0, 0, + 156, 0, 157, 0, 0, 0, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 225, 226, 247, 231, + 228, 229, 246, 250, 233, 234, 235, 236, 237, 238, 239, 240, 242, 243, 244, + 245, 230, 232, 227, 254, 251, 253, 255, 249, 248, 252, 224, 241, 193, 194, + 215, 199, 196, 197, 214, 218, 201, 202, 203, 204, 205, 206, 207, 208, 210, + 211, 212, 213, 198, 200, 195, 222, 219, 221, 223, 217, 216, 220, 192, 209, + 0, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 149, 150, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 147, 155, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 128, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130, 0, 0, 0, 131, 0, 0, 0, 132, 0, + 0, 0, 133, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, + 136, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 138, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 161, 162, 164, 165, 166, 167, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, + 184, 185, 186, 187, 188, 189, 190, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 139, 0, 0, 0, 140, 0, 0, 0, 141, 0, 0, 0, 142, 0, 0, 0, + 143, 144, 145, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 96, 128, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 224, 256, 0, 0, 0, 0, 0, 288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 320, 352, 384, 416, 448, 480, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 302 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = koi8_r +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/koi8_u.rs b/deps/encoding-index-singlebyte-1.20141219.5/koi8_u.rs new file mode 100644 index 000000000..d49db8a1e --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/koi8_u.rs @@ -0,0 +1,88 @@ +// AUTOGENERATED FROM index-koi8-u.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-koi8-u.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: f9609f62c683e8f4ee8e9c68c6a6e18b6043b381e6f7d512c53fcaf9894e3a94 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, + 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, + 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 1108, + 9556, 1110, 1111, 9559, 9560, 9561, 9562, 9563, 1169, 9565, 9566, 9567, + 9568, 9569, 1025, 1028, 9571, 1030, 1031, 9574, 9575, 9576, 9577, 9578, + 1168, 9580, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, + 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, + 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, + 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, + 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, + 1067, 1047, 1064, 1069, 1065, 1063, 1066, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 154, 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, 0, 0, 0, 0, 0, + 156, 0, 157, 0, 0, 0, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 179, 0, 0, 180, 0, 182, 183, 0, 0, 0, 0, 0, 0, 0, 0, 225, 226, 247, + 231, 228, 229, 246, 250, 233, 234, 235, 236, 237, 238, 239, 240, 242, 243, + 244, 245, 230, 232, 227, 254, 251, 253, 255, 249, 248, 252, 224, 241, 193, + 194, 215, 199, 196, 197, 214, 218, 201, 202, 203, 204, 205, 206, 207, 208, + 210, 211, 212, 213, 198, 200, 195, 222, 219, 221, 223, 217, 216, 220, 192, + 209, 0, 163, 0, 0, 164, 0, 166, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 189, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 149, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, + 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 147, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 130, 0, 0, 0, 131, 0, 0, 0, 132, 0, 0, 0, 133, 0, 0, 0, 134, 0, 0, 0, 0, 0, + 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, + 0, 0, 0, 138, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, + 161, 162, 0, 165, 0, 0, 168, 169, 170, 171, 172, 0, 174, 175, 176, 177, + 178, 0, 181, 0, 0, 184, 185, 186, 187, 188, 0, 190, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 0, 140, 0, 0, 0, 141, 0, 0, 0, + 142, 0, 0, 0, 143, 144, 145, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 96, 128, 160, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 224, 0, 256, 288, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 352, 384, 416, 448, 480, 512, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 302 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = koi8_u +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/lib.rs b/deps/encoding-index-singlebyte-1.20141219.5/lib.rs new file mode 100644 index 000000000..6daba7a8f --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/lib.rs @@ -0,0 +1,95 @@ +// This is a part of rust-encoding. +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ + +//! Single-byte index tables for +//! [rust-encoding](https://github.com/lifthrasiir/rust-encoding). + +#![cfg_attr(test, feature(test))] + +#[cfg(test)] +#[macro_use] +extern crate encoding_index_tests; + +/// IBM code page 866. +pub mod ibm866; + +/// ISO 8859-2. +pub mod iso_8859_2; + +/// ISO 8859-3. +pub mod iso_8859_3; + +/// ISO 8859-4. +pub mod iso_8859_4; + +/// ISO 8859-5. +pub mod iso_8859_5; + +/// ISO 8859-6. +pub mod iso_8859_6; + +/// ISO 8859-7. +pub mod iso_8859_7; + +/// ISO 8859-8 (either visual or logical). +pub mod iso_8859_8; + +/// ISO 8859-10. +pub mod iso_8859_10; + +/// ISO 8859-13. +pub mod iso_8859_13; + +/// ISO 8859-14. +pub mod iso_8859_14; + +/// ISO 8859-15. +pub mod iso_8859_15; + +/// ISO 8859-16. +pub mod iso_8859_16; + +/// KOI8-R. +pub mod koi8_r; + +/// KOI8-U. +pub mod koi8_u; + +/// MacRoman. +pub mod macintosh; + +/// Windows code page 874. +pub mod windows_874; + +/// Windows code page 1250. +pub mod windows_1250; + +/// Windows code page 1251. +pub mod windows_1251; + +/// Windows code page 1252. +pub mod windows_1252; + +/// Windows code page 1253. +pub mod windows_1253; + +/// Windows code page 1254. +pub mod windows_1254; + +/// Windows code page 1254. +pub mod windows_1255; + +/// Windows code page 1256. +pub mod windows_1256; + +/// Windows code page 1257. +pub mod windows_1257; + +/// Windows code page 1258. +pub mod windows_1258; + +/// MacCyrillic. +pub mod x_mac_cyrillic; + diff --git a/deps/encoding-index-singlebyte-1.20141219.5/macintosh.rs b/deps/encoding-index-singlebyte-1.20141219.5/macintosh.rs new file mode 100644 index 000000000..d7035dd56 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/macintosh.rs @@ -0,0 +1,139 @@ +// AUTOGENERATED FROM index-macintosh.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-macintosh.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: f2c6a4f6406b3e86a50a5dba4d2b7dd48e2e33c0d82aefe764535c934ec11764 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 228, 227, 229, 231, 233, + 232, 234, 235, 237, 236, 238, 239, 241, 243, 242, 244, 246, 245, 250, 249, + 251, 252, 8224, 176, 162, 163, 167, 8226, 182, 223, 174, 169, 8482, 180, + 168, 8800, 198, 216, 8734, 177, 8804, 8805, 165, 181, 8706, 8721, 8719, + 960, 8747, 170, 186, 937, 230, 248, 191, 161, 172, 8730, 402, 8776, 8710, + 171, 187, 8230, 160, 192, 195, 213, 338, 339, 8211, 8212, 8220, 8221, 8216, + 8217, 247, 9674, 255, 376, 8260, 8364, 8249, 8250, 64257, 64258, 8225, 183, + 8218, 8222, 8240, 194, 202, 193, 203, 200, 205, 206, 207, 204, 211, 212, + 63743, 210, 218, 219, 217, 305, 710, 732, 175, 728, 729, 730, 184, 733, + 731, 711, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 193, + 162, 163, 0, 180, 0, 164, 172, 169, 187, 199, 194, 0, 168, 248, 161, 177, + 0, 0, 171, 181, 166, 225, 252, 0, 188, 200, 0, 0, 0, 192, 203, 231, 229, + 204, 128, 129, 174, 130, 233, 131, 230, 232, 237, 234, 235, 236, 0, 132, + 241, 238, 239, 205, 133, 0, 175, 244, 242, 243, 134, 0, 0, 167, 136, 135, + 137, 139, 138, 140, 190, 141, 143, 142, 144, 145, 147, 146, 148, 149, 0, + 150, 152, 151, 153, 155, 154, 214, 191, 157, 156, 158, 159, 0, 0, 216, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 206, 207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 217, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 246, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 249, 250, 251, + 254, 247, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 209, 0, 0, 0, 212, 213, 226, 0, + 210, 211, 227, 0, 160, 224, 165, 0, 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 228, 0, 0, 0, 0, 0, 0, 0, 0, 220, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 218, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 182, 0, 0, 0, 198, 0, 0, 0, 0, + 0, 0, 0, 0, 184, 0, 183, 0, 0, 0, 0, 0, 0, 0, 0, 195, 0, 0, 0, 176, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 0, 0, 0, 178, 179, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 240, 0, 222, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 192, 256, 320, 0, 0, 0, 0, 384, 0, 0, 448, 512, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 576, 640, 704, 0, 768, 0, 0, 0, 832, 896, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 960, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 1088, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 1005 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = macintosh +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1250.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1250.rs new file mode 100644 index 000000000..e25ff3910 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1250.rs @@ -0,0 +1,80 @@ +// AUTOGENERATED FROM index-windows-1250.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1250.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 0669455a7a1c70ba6003ea737991e8ee9adc455125c13cfe6705a361358de5fa +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 352, 8249, 346, + 356, 381, 377, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, + 353, 8250, 347, 357, 382, 378, 160, 711, 728, 321, 164, 260, 166, 167, 168, + 169, 350, 171, 172, 173, 174, 379, 176, 177, 731, 322, 180, 181, 182, 183, + 184, 261, 351, 187, 317, 733, 318, 380, 340, 193, 194, 258, 196, 313, 262, + 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, + 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, + 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, + 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 131, 0, 0, 0, 0, 136, + 0, 0, 0, 0, 0, 0, 0, 144, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, + 160, 0, 0, 0, 164, 0, 166, 167, 168, 169, 0, 171, 172, 173, 174, 0, 176, + 177, 0, 0, 180, 181, 182, 183, 184, 0, 0, 187, 0, 0, 0, 0, 0, 193, 194, 0, + 196, 0, 0, 199, 0, 201, 0, 203, 0, 205, 206, 0, 0, 0, 0, 211, 212, 0, 214, + 215, 0, 0, 218, 0, 220, 221, 0, 223, 0, 225, 226, 0, 228, 0, 0, 231, 0, + 233, 0, 235, 0, 237, 238, 0, 0, 0, 0, 243, 244, 0, 246, 247, 0, 0, 250, 0, + 252, 253, 0, 0, 0, 0, 195, 227, 165, 185, 198, 230, 0, 0, 0, 0, 200, 232, + 207, 239, 208, 240, 0, 0, 0, 0, 0, 0, 202, 234, 204, 236, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197, + 229, 0, 0, 188, 190, 0, 0, 163, 179, 209, 241, 0, 0, 210, 242, 0, 0, 0, 0, + 0, 0, 0, 213, 245, 0, 0, 192, 224, 0, 0, 216, 248, 140, 156, 0, 0, 170, + 186, 138, 154, 222, 254, 141, 157, 0, 0, 0, 0, 0, 0, 0, 0, 217, 249, 219, + 251, 0, 0, 0, 0, 0, 0, 0, 143, 159, 175, 191, 142, 158, 0, 0, 0, 0, 0, 0, + 0, 0, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 255, 0, + 178, 0, 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, + 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, + 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 192, 256, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 384, 0, 448, 0, 512, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1250 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1251.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1251.rs new file mode 100644 index 000000000..0c453b6b4 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1251.rs @@ -0,0 +1,79 @@ +// AUTOGENERATED FROM index-windows-1251.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1251.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 7592ef921679ba168b00a9e9afa3b4eebd67bf13dc7e84c4b6e120de856826e0 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240, 1033, 8249, + 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220, 8221, 8226, 8211, 8212, + 152, 8482, 1113, 8250, 1114, 1116, 1115, 1119, 160, 1038, 1118, 1032, 164, + 1168, 166, 167, 1025, 169, 1028, 171, 172, 173, 174, 1031, 176, 177, 1030, + 1110, 1169, 181, 182, 183, 1105, 8470, 1108, 187, 1112, 1029, 1109, 1111, + 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, + 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, + 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, + 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, + 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, + 1100, 1101, 1102, 1103, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0, + 0, 164, 0, 166, 167, 0, 169, 0, 171, 172, 173, 174, 0, 176, 177, 0, 0, 0, + 181, 182, 183, 0, 0, 0, 187, 0, 0, 0, 0, 0, 168, 128, 129, 170, 189, 178, + 175, 163, 138, 140, 142, 141, 0, 161, 143, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 0, 184, + 144, 131, 186, 190, 179, 191, 188, 154, 156, 158, 157, 0, 162, 159, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 180, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, + 0, 147, 148, 132, 0, 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 137, 0, 0, 0, 0, 0, 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 256, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 320, 0, 384, 0, 448, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1251 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1252.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1252.rs new file mode 100644 index 000000000..8efcdd0c6 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1252.rs @@ -0,0 +1,79 @@ +// AUTOGENERATED FROM index-windows-1252.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1252.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: e56d49d9176e9a412283cf29ac9bd613f5620462f2a080a84eceaf974cfa18b7 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, + 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, + 353, 8250, 339, 157, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 0, 143, + 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157, 0, 0, 160, 161, 162, 163, + 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, + 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, + 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, + 254, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 156, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 0, 0, 0, 0, 142, 158, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, + 0, 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, + 0, 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 0, 0, 160, 192, 224, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 288, 320, 0, 0, 0, 352, 0, 0, 0, 384, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 266 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1252 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1253.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1253.rs new file mode 100644 index 000000000..f0d7a025f --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1253.rs @@ -0,0 +1,76 @@ +// AUTOGENERATED FROM index-windows-1253.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1253.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 49fdc881a3488904dd1e8dfba9aef3258454249958b611bcded1d4c981ab5561 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, + 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, + 154, 8250, 156, 157, 158, 159, 160, 901, 902, 163, 164, 165, 166, 167, 168, + 169, 65535, 171, 172, 173, 174, 8213, 176, 177, 178, 179, 900, 181, 182, + 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, + 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 65535, 931, + 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, + 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, + 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 65535, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 136, 0, 138, 0, 140, 141, + 142, 143, 144, 0, 0, 0, 0, 0, 0, 0, 152, 0, 154, 0, 156, 157, 158, 159, + 160, 0, 0, 163, 164, 165, 166, 167, 168, 169, 0, 171, 172, 173, 174, 0, + 176, 177, 178, 179, 0, 181, 182, 183, 0, 0, 0, 187, 0, 189, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 161, 162, 0, 184, 185, 186, 0, 188, 0, 190, + 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 0, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, + 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, + 251, 252, 253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 151, 175, 0, 0, + 145, 146, 130, 0, 147, 148, 132, 0, 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 160, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 256, 0, 0, 0, 288, 0, 0, 0, 320, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 266 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1253 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1254.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1254.rs new file mode 100644 index 000000000..b92dd6757 --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1254.rs @@ -0,0 +1,81 @@ +// AUTOGENERATED FROM index-windows-1254.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1254.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: e80a27adf377438be8ba5bd223875ea56d6a4d47f958cce1c957a2c446825caa +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, + 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, + 353, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 205, 206, 207, 286, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 304, 350, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 287, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 250, 251, 252, 305, 351, 255, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 142, + 143, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157, 158, 0, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + 0, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 0, 0, 223, + 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, + 239, 0, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 0, 0, + 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 208, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 221, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 222, 254, 138, 154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, + 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, 134, 135, 149, 0, 0, 0, + 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0, 139, 155, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 320, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 352, 384, 0, 0, 0, 416, 0, 0, 0, 448, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 266 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1254 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1255.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1255.rs new file mode 100644 index 000000000..c93a0933e --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1255.rs @@ -0,0 +1,81 @@ +// AUTOGENERATED FROM index-windows-1255.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1255.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 3b3ec872752f43c348a39b3fd2040202ccd95b935e56b2f92bb9e03e220ca02a +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 140, + 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, + 154, 8250, 156, 157, 158, 159, 160, 161, 162, 163, 8362, 165, 166, 167, + 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, + 183, 184, 185, 247, 187, 188, 189, 190, 191, 1456, 1457, 1458, 1459, 1460, + 1461, 1462, 1463, 1464, 1465, 65535, 1467, 1468, 1469, 1470, 1471, 1472, + 1473, 1474, 1475, 1520, 1521, 1522, 1523, 1524, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, + 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, + 1509, 1510, 1511, 1512, 1513, 1514, 65535, 65535, 8206, 8207, 65535, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 140, 141, 142, + 143, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 0, 156, 157, 158, 159, 160, 161, + 162, 163, 0, 165, 166, 167, 168, 169, 0, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 184, 185, 0, 187, 188, 189, 190, 191, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 0, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 250, 0, 0, 0, 0, 0, 212, 213, 214, 215, 216, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 253, 254, 0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, + 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, + 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 0, 0, 0, 0, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, + 256, 288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 320, 352, 0, 0, 0, 384, 0, 0, 0, 416, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 266 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1255 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1256.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1256.rs new file mode 100644 index 000000000..a4e63043d --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1256.rs @@ -0,0 +1,87 @@ +// AUTOGENERATED FROM index-windows-1256.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1256.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 161bdb381f16408e8bebcc8f5310c4190af0e359de8d9bbaa3628ce2f0875509 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, + 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, + 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, + 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, + 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, + 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, + 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, + 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, + 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, + 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 160, 0, 162, 163, 164, 165, 166, 167, 168, 169, 0, + 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, + 0, 187, 188, 189, 190, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 226, 0, 0, 0, 0, + 231, 232, 233, 234, 235, 0, 0, 238, 239, 0, 0, 0, 0, 244, 0, 0, 247, 0, + 249, 0, 251, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 140, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 161, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, 191, 0, 193, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, 216, 217, 218, 219, 0, 0, 0, 0, 0, 220, 221, 222, 223, 225, + 227, 228, 229, 230, 236, 237, 240, 241, 242, 243, 245, 246, 248, 250, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, + 141, 0, 143, 0, 0, 0, 0, 0, 0, 0, 0, 154, 0, 0, 0, 0, 0, 0, 142, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 144, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 159, 0, 0, 0, 170, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 157, 158, 253, 254, 0, 0, 0, 150, 151, 0, 0, 0, + 145, 146, 130, 0, 147, 148, 132, 0, 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 64, 96, 0, 0, 128, 0, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 224, 256, 288, 320, 352, 384, 416, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 448, 480, 0, 0, 0, 512, 0, 0, + 0, 544, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 266 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1256 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1257.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1257.rs new file mode 100644 index 000000000..f7156ec9d --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1257.rs @@ -0,0 +1,80 @@ +// AUTOGENERATED FROM index-windows-1257.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1257.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: cc7256bdd10a5b8dc7fb6f994659f307dfcae60def9aa6c29d811f85e2842c47 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, + 168, 711, 184, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, + 154, 8250, 156, 175, 731, 159, 160, 65535, 162, 163, 164, 65535, 166, 167, + 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 180, 181, 182, + 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, + 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, + 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, + 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, + 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 729, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 131, 0, 0, 0, 0, 136, + 0, 138, 0, 140, 0, 0, 0, 144, 0, 0, 0, 0, 0, 0, 0, 152, 0, 154, 0, 156, 0, + 0, 159, 160, 0, 162, 163, 164, 0, 166, 167, 141, 169, 0, 171, 172, 173, + 174, 157, 176, 177, 178, 179, 180, 181, 182, 183, 143, 185, 0, 187, 188, + 189, 190, 0, 0, 0, 0, 0, 196, 197, 175, 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 211, 0, 213, 214, 215, 168, 0, 0, 0, 220, 0, 0, 223, 0, 0, 0, 0, 228, + 229, 191, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243, 0, 245, 246, 247, 184, + 0, 0, 0, 252, 0, 0, 0, 194, 226, 0, 0, 192, 224, 195, 227, 0, 0, 0, 0, 200, + 232, 0, 0, 0, 0, 199, 231, 0, 0, 203, 235, 198, 230, 0, 0, 0, 0, 0, 0, 0, + 0, 204, 236, 0, 0, 0, 0, 0, 0, 206, 238, 0, 0, 193, 225, 0, 0, 0, 0, 0, 0, + 205, 237, 0, 0, 0, 207, 239, 0, 0, 0, 0, 217, 249, 209, 241, 210, 242, 0, + 0, 0, 0, 0, 212, 244, 0, 0, 0, 0, 0, 0, 0, 0, 170, 186, 0, 0, 218, 250, 0, + 0, 0, 0, 208, 240, 0, 0, 0, 0, 0, 0, 0, 0, 219, 251, 0, 0, 0, 0, 0, 0, 216, + 248, 0, 0, 0, 0, 0, 202, 234, 221, 253, 222, 254, 0, 0, 0, 0, 0, 0, 0, 0, + 142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 158, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, 134, 135, + 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0, + 139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 128, 192, 256, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 384, 0, 448, 0, 512, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1257 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_1258.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_1258.rs new file mode 100644 index 000000000..d4587f81a --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_1258.rs @@ -0,0 +1,85 @@ +// AUTOGENERATED FROM index-windows-1258.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-1258.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 198bacedfcf24390e219240a7b776b6cec34cff070330b08a601a69c67f7eb24 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 338, + 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, + 154, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 258, 196, 197, 198, + 199, 200, 201, 202, 203, 768, 205, 206, 207, 272, 209, 777, 211, 212, 416, + 214, 215, 216, 217, 218, 219, 220, 431, 771, 223, 224, 225, 226, 259, 228, + 229, 230, 231, 232, 233, 234, 235, 769, 237, 238, 239, 273, 241, 803, 243, + 244, 417, 246, 247, 248, 249, 250, 251, 252, 432, 8363, 255, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 0, 141, 142, + 143, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 0, 0, 157, 158, 0, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 0, 196, 197, 198, 199, 200, 201, 202, 203, 0, 205, 206, 207, 0, + 209, 0, 211, 212, 0, 214, 215, 216, 217, 218, 219, 220, 0, 0, 223, 224, + 225, 226, 0, 228, 229, 230, 231, 232, 233, 234, 235, 0, 237, 238, 239, 0, + 241, 0, 243, 244, 0, 246, 247, 248, 249, 250, 251, 252, 0, 0, 255, 0, 0, + 195, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 240, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 140, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 213, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221, + 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, + 204, 236, 0, 222, 0, 0, 0, 0, 0, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, + 147, 148, 132, 0, 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 137, 0, 0, 0, 0, 0, 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 32, 64, 96, 128, 160, 0, 192, 224, 256, 288, 0, 0, 0, 0, 0, 0, + 0, 0, 320, 0, 352, 384, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 416, 448, 0, 0, 0, 480, 0, 0, 0, + 512, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 266 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_1258 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/windows_874.rs b/deps/encoding-index-singlebyte-1.20141219.5/windows_874.rs new file mode 100644 index 000000000..0c2ef2b4c --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/windows_874.rs @@ -0,0 +1,74 @@ +// AUTOGENERATED FROM index-windows-874.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-windows-874.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: b416583ce125e38474381b31b401a98b19ecf2e57e0998e78a1e18b14894905d +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, + 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, + 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, + 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, + 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, + 3640, 3641, 3642, 65535, 65535, 65535, 65535, 3647, 3648, 3649, 3650, 3651, + 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, + 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, + 65535, 65535, 65535, 65535, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 130, 131, 132, 0, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 0, 0, 0, 0, 0, 0, 0, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 161, 162, 163, + 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, + 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, 0, 0, 0, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 150, 151, 0, 0, 0, 145, 146, 0, 0, 147, 148, 0, 0, 0, 0, 149, 0, 0, 0, 133, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 128, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 256, 0, 320, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 6) as usize; + let offset = if offset < 131 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = windows_874 +); diff --git a/deps/encoding-index-singlebyte-1.20141219.5/x_mac_cyrillic.rs b/deps/encoding-index-singlebyte-1.20141219.5/x_mac_cyrillic.rs new file mode 100644 index 000000000..98865c2cb --- /dev/null +++ b/deps/encoding-index-singlebyte-1.20141219.5/x_mac_cyrillic.rs @@ -0,0 +1,86 @@ +// AUTOGENERATED FROM index-x-mac-cyrillic.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-x-mac-cyrillic.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 73e8e7642c6fa9de29d42819b47fba55b58666fb1e339faeb4a89a0bd7c24d43 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, + 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, + 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 8224, 176, 1168, 163, 167, + 8226, 182, 1030, 174, 169, 8482, 1026, 1106, 8800, 1027, 1107, 8734, 177, + 8804, 8805, 1110, 181, 1169, 1032, 1028, 1108, 1031, 1111, 1033, 1113, + 1034, 1114, 1112, 1029, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, + 1035, 1115, 1036, 1116, 1109, 8211, 8212, 8220, 8221, 8216, 8217, 247, + 8222, 1038, 1118, 1039, 1119, 8470, 1025, 1105, 1103, 1072, 1073, 1074, + 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, + 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, + 1099, 1100, 1101, 1102, 8364, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u8) -> u16 { + FORWARD_TABLE[(code - 0x80) as usize] +} + +static BACKWARD_TABLE_LOWER: &'static [u8] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 202, 0, 0, 163, 0, 0, 0, 164, 0, 169, 0, 199, 194, 0, + 168, 0, 161, 177, 0, 0, 0, 181, 166, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221, 171, 174, 184, 193, 167, + 186, 183, 188, 190, 203, 205, 0, 216, 218, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 224, 225, 226, 227, + 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 223, 0, 222, + 172, 175, 185, 207, 180, 187, 192, 189, 191, 204, 206, 0, 217, 219, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 182, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 208, 209, 0, 0, 0, 212, 213, 0, 0, 210, 211, 215, 0, 160, 0, 165, 0, 0, 0, + 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 195, 0, 0, 0, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 0, 0, 0, 178, 179, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 32, 0, 64, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 128, 160, 192, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 288, 0, 0, 0, 320, 0, 0, 352, 384, 0, 0, + 0, 0, 0, 0, 416, 0, 448, 480, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u8 { + let offset = (code >> 5) as usize; + let offset = if offset < 276 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] +} + +#[cfg(test)] +single_byte_tests!( + mod = x_mac_cyrillic +); diff --git a/deps/encoding-index-tradchinese-1.20141219.5/Cargo.toml b/deps/encoding-index-tradchinese-1.20141219.5/Cargo.toml new file mode 100644 index 000000000..818befb40 --- /dev/null +++ b/deps/encoding-index-tradchinese-1.20141219.5/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "encoding-index-tradchinese" +version = "1.20141219.5" +authors = ["Kang Seonghoon "] + +description = "Index tables for traditional Chinese character encodings" +homepage = "https://github.com/lifthrasiir/rust-encoding" +readme = "../../../README.md" +license = "CC0-1.0" + +[lib] +name = "encoding_index_tradchinese" +path = "lib.rs" + +[dependencies.encoding_index_tests] +# TODO consider using dev-dependencies instead (Cargo issue #860) +version = "0.1.4" +path = "../tests" diff --git a/deps/encoding-index-tradchinese-1.20141219.5/big5.rs b/deps/encoding-index-tradchinese-1.20141219.5/big5.rs new file mode 100644 index 000000000..2ffe8c7a3 --- /dev/null +++ b/deps/encoding-index-tradchinese-1.20141219.5/big5.rs @@ -0,0 +1,6602 @@ +// AUTOGENERATED FROM index-big5.txt, ORIGINAL COMMENT FOLLOWS: +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ +// +// For details on index index-big5.txt see the Encoding Standard +// https://encoding.spec.whatwg.org/ +// +// Identifier: 8dfc771062e7be0810919082c2c06baa2236147909e0ecc235b1cb9ad782ac82 +// Date: 2014-12-19 + +static FORWARD_TABLE: &'static [u16] = &[ + 17392, 19506, 17923, 17830, 17784, 29287, 19831, 17843, 31921, 19682, + 31941, 15253, 18230, 18244, 19527, 19520, 17087, 13847, 29522, 28299, + 28882, 19543, 41809, 18255, 17882, 19589, 31852, 19719, 19108, 18081, + 27427, 29221, 23124, 6755, 15878, 16225, 26189, 22267, 65535, 32149, 22813, + 35769, 15860, 38708, 31727, 23515, 7518, 23204, 13861, 40624, 23249, 23479, + 23804, 26478, 34195, 39237, 29793, 29853, 14453, 7507, 13982, 24609, 16108, + 22750, 15093, 31484, 40855, 16737, 35085, 12778, 2698, 12894, 17162, 33924, + 40854, 37935, 18736, 34323, 22678, 38730, 37400, 31184, 31282, 26208, + 27177, 34973, 29772, 31685, 26498, 31276, 21071, 36934, 13542, 29636, + 23993, 29894, 40903, 22451, 18735, 21580, 16689, 13966, 22552, 31346, + 31589, 35727, 18094, 28296, 16769, 23961, 31662, 9404, 40904, 9409, 9417, + 9420, 40905, 34052, 13755, 16564, 40906, 17633, 44543, 25281, 28782, 40907, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 12736, 12737, 12738, 12739, 12740, 268, 12741, 209, 205, 12742, + 12743, 203, 8168, 12744, 202, 12745, 12746, 12747, 12748, 270, 12749, + 12750, 256, 193, 461, 192, 274, 201, 282, 200, 332, 211, 465, 210, 0, 7870, + 1, 7872, 202, 257, 225, 462, 224, 593, 275, 233, 283, 232, 299, 237, 464, + 236, 333, 243, 466, 242, 363, 250, 468, 249, 470, 472, 474, 476, 252, 2, + 7871, 3, 7873, 234, 609, 9178, 9179, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 41897, 4421, + 65535, 25866, 65535, 65535, 20029, 28381, 40270, 37343, 65535, 65535, + 30517, 25745, 20250, 20264, 20392, 20822, 20852, 20892, 20964, 21153, + 21160, 21307, 21326, 21457, 21464, 22242, 22768, 22788, 22791, 22834, + 22836, 23398, 23454, 23455, 23706, 24198, 24635, 25993, 26622, 26628, + 26725, 27982, 28860, 30005, 32420, 32428, 32442, 32455, 32463, 32479, + 32518, 32567, 33402, 33487, 33647, 35270, 35774, 35810, 36710, 36711, + 36718, 29713, 31996, 32205, 26950, 31433, 21031, 65535, 65535, 65535, + 65535, 37260, 30904, 37214, 32956, 65535, 36107, 33014, 2535, 65535, 65535, + 32927, 40647, 19661, 40393, 40460, 19518, 40438, 28686, 40458, 41267, + 13761, 65535, 28314, 33342, 29977, 65535, 18705, 39532, 39567, 40857, + 31111, 33900, 7626, 1488, 10982, 20004, 20097, 20096, 20103, 20159, 20203, + 20279, 13388, 20413, 15944, 20483, 20616, 13437, 13459, 13477, 20870, + 22789, 20955, 20988, 20997, 20105, 21113, 21136, 21287, 13767, 21417, + 13649, 21424, 13651, 21442, 21539, 13677, 13682, 13953, 21651, 21667, + 21684, 21689, 21712, 21743, 21784, 21795, 21800, 13720, 21823, 13733, + 13759, 21975, 13765, 32132, 21797, 65535, 3138, 3349, 20779, 21904, 11462, + 14828, 833, 36422, 19896, 38117, 16467, 32958, 30586, 11320, 14900, 18389, + 33117, 27122, 19946, 25821, 3452, 4020, 3285, 4340, 25741, 36478, 3734, + 3083, 3940, 11433, 33366, 17619, 65535, 3398, 39501, 33001, 18420, 20135, + 11458, 39602, 14951, 38388, 16365, 13574, 21191, 38868, 30920, 11588, + 40302, 38933, 65535, 17369, 24741, 25780, 21731, 11596, 11210, 4215, 14843, + 4207, 26330, 26390, 31136, 25834, 20562, 3139, 36456, 8609, 35660, 1841, + 65535, 18443, 425, 16378, 22643, 11661, 65535, 17864, 1276, 24727, 3916, + 3478, 21881, 16571, 17338, 65535, 19124, 10854, 4253, 33194, 39157, 3484, + 25465, 14846, 10101, 36288, 22177, 25724, 15939, 65535, 42497, 3593, 10959, + 11465, 65535, 4296, 14786, 14738, 14854, 33435, 13688, 24137, 8391, 22098, + 3889, 11442, 38688, 13500, 27709, 20027, 65535, 65535, 30068, 11915, 8712, + 42587, 36045, 3706, 3124, 26652, 32659, 4303, 10243, 10553, 13819, 20963, + 3724, 3981, 3754, 16275, 3888, 3399, 4431, 3660, 65535, 3755, 2985, 3400, + 4288, 4413, 16377, 9878, 25650, 4013, 13300, 30265, 11214, 3454, 3455, + 11345, 11349, 14872, 3736, 4295, 3886, 42546, 27472, 36050, 36249, 36042, + 38314, 21708, 33476, 21945, 65535, 40643, 39974, 39606, 30558, 11758, + 28992, 33133, 33004, 23580, 25970, 33076, 14231, 21343, 32957, 37302, 3834, + 3599, 3703, 3835, 13789, 19947, 13833, 3286, 22191, 10165, 4297, 3600, + 3704, 4216, 4424, 33287, 5205, 3705, 20048, 11684, 23124, 4125, 4126, 4341, + 4342, 22428, 3601, 30356, 33485, 4021, 3707, 20862, 14083, 4022, 4480, + 21208, 41661, 18906, 6202, 16759, 33404, 22681, 21096, 13850, 22333, 31666, + 23400, 18432, 19244, 40743, 18919, 39967, 39821, 23412, 12605, 22011, + 13810, 22153, 20008, 22786, 7105, 63608, 38737, 134, 20059, 20155, 13630, + 23587, 24401, 24516, 14586, 25164, 25909, 27514, 27701, 27706, 28780, + 29227, 20012, 29357, 18665, 32594, 31035, 31993, 32595, 25194, 13505, + 65535, 25419, 32770, 32896, 26130, 26961, 21341, 34916, 35265, 30898, + 35744, 36125, 38021, 38264, 38271, 38376, 36367, 38886, 39029, 39118, + 39134, 39267, 38928, 40060, 40479, 40644, 27503, 63751, 20023, 135, 38429, + 25143, 38050, 65535, 20539, 28158, 40051, 40870, 15817, 34959, 16718, + 28791, 23797, 19232, 20941, 13657, 23856, 24866, 35378, 36775, 37366, + 29073, 26393, 29626, 12929, 41223, 15499, 6528, 19216, 30948, 29698, 20910, + 34575, 16393, 27235, 41658, 16931, 34319, 2671, 31274, 39239, 35562, 38741, + 28749, 21284, 8318, 37876, 30425, 35299, 40871, 30685, 20131, 20464, 20668, + 20015, 20247, 40872, 21556, 32139, 22674, 22736, 7606, 24210, 24217, 24514, + 10002, 25995, 13305, 26905, 27203, 15459, 27903, 65535, 29184, 17669, + 29580, 16091, 18963, 23317, 29881, 35715, 23716, 22165, 31379, 31724, + 31939, 32364, 33528, 34199, 40873, 34960, 40874, 36537, 40875, 36815, + 34143, 39392, 37409, 40876, 36281, 5183, 16497, 17058, 23066, 65535, 65535, + 65535, 39016, 26475, 17014, 22333, 65535, 34262, 18811, 33471, 28941, + 19585, 28020, 23931, 27413, 28606, 40877, 40878, 23446, 40879, 26343, + 32347, 28247, 31178, 15752, 17603, 12886, 10134, 17306, 17718, 65535, + 23765, 15130, 35577, 23672, 15634, 13649, 23928, 40882, 29015, 17752, + 16620, 7715, 19575, 14712, 13386, 420, 27713, 35532, 20404, 569, 22975, + 33132, 38998, 39162, 24379, 2975, 65535, 8641, 35181, 16642, 18107, 36985, + 16135, 40883, 41397, 16632, 14294, 18167, 27718, 16764, 34482, 29695, + 17773, 14548, 21658, 17761, 17691, 19849, 19579, 19830, 17898, 16328, + 19215, 13921, 17630, 17597, 16877, 23870, 23880, 23894, 15868, 14351, + 23972, 23993, 14368, 14392, 24130, 24253, 24357, 24451, 14600, 14612, + 14655, 14669, 24791, 24893, 23781, 14729, 25015, 25017, 25039, 14776, + 25132, 25232, 25317, 25368, 14840, 22193, 14851, 25570, 25595, 25607, + 25690, 14923, 25792, 23829, 22049, 40863, 14999, 25990, 15037, 26111, + 26195, 15090, 26258, 15138, 26390, 15170, 26532, 26624, 15192, 26698, + 26756, 15218, 15217, 15227, 26889, 26947, 29276, 26980, 27039, 27013, + 15292, 27094, 15325, 27237, 27252, 27249, 27266, 15340, 27289, 15346, + 27307, 27317, 27348, 27382, 27521, 27585, 27626, 27765, 27818, 15563, + 27906, 27910, 27942, 28033, 15599, 28068, 28081, 28181, 28184, 28201, + 28294, 35264, 28347, 28386, 28378, 40831, 28392, 28393, 28452, 28468, + 15686, 16193, 28545, 28606, 15722, 15733, 29111, 23705, 15754, 28716, + 15761, 28752, 28756, 28783, 28799, 28809, 805, 17345, 13809, 3800, 16087, + 22462, 28371, 28990, 22496, 13902, 27042, 35817, 23412, 31305, 22753, + 38105, 31333, 31357, 22956, 31419, 31408, 31426, 31427, 29137, 25741, + 16842, 31450, 31453, 31466, 16879, 21682, 23553, 31499, 31573, 31529, + 21262, 23806, 31650, 31599, 33692, 23476, 27775, 31696, 33825, 31634, + 31672, 23840, 15789, 23653, 33938, 31738, 31750, 31797, 23745, 31812, + 31875, 18562, 31910, 26237, 17784, 31945, 31943, 31974, 31860, 31987, + 31989, 31950, 32359, 17693, 28228, 32093, 28374, 29837, 32137, 32171, + 28981, 32179, 32210, 16471, 24617, 32228, 15635, 32245, 6137, 32229, 33645, + 32285, 24865, 24922, 32366, 32402, 17195, 37996, 32295, 32576, 32577, + 32583, 31030, 25296, 39393, 32663, 25425, 32675, 5729, 104, 17756, 14182, + 17667, 33594, 32762, 25737, 32773, 32776, 32797, 32808, 32815, 41095, + 27843, 32827, 32828, 32865, 10004, 18825, 26150, 15843, 26344, 26405, + 32935, 35400, 33031, 33050, 22704, 9974, 27775, 25752, 20408, 25831, 5258, + 33304, 6238, 27219, 19045, 19093, 17530, 33321, 2829, 27218, 15742, 20473, + 5373, 34018, 33634, 27402, 18855, 13616, 6003, 15864, 33450, 26907, 63892, + 16859, 34123, 33488, 33562, 3606, 6068, 14017, 12669, 13658, 33403, 33506, + 33560, 16011, 28067, 27397, 27543, 13774, 15807, 33565, 21996, 33669, + 17675, 28069, 33708, 33729, 33747, 13438, 28372, 27223, 34138, 13462, + 28226, 12015, 33880, 23524, 33905, 15827, 17636, 27303, 33866, 15541, + 31064, 33960, 27542, 28279, 28227, 34014, 33807, 33681, 17568, 33939, + 34020, 23697, 16960, 23744, 17731, 34100, 23282, 28313, 17703, 34163, + 17686, 26559, 34326, 34341, 34363, 34241, 28808, 34306, 5506, 28877, 63922, + 17770, 34344, 13896, 6306, 21495, 29594, 34430, 34673, 41208, 34798, 11303, + 34737, 34778, 34831, 22113, 34412, 26710, 17935, 34885, 34886, 30176, + 15801, 30180, 34910, 34972, 18011, 34996, 34997, 25537, 35013, 30583, + 30479, 35207, 35210, 35238, 35241, 35239, 35260, 35365, 35303, 31012, + 31421, 35484, 30611, 37374, 35472, 31321, 31465, 31546, 16271, 18195, + 31544, 29052, 35596, 35615, 21552, 21861, 35647, 35660, 35661, 35497, + 19066, 35728, 35739, 35503, 5855, 17941, 34895, 35995, 32084, 32143, 63956, + 14117, 32083, 36054, 32152, 32189, 36114, 36099, 6416, 36059, 28764, 36113, + 19657, 16080, 36215, 36265, 32770, 4116, 18826, 15228, 33212, 28940, 31463, + 36525, 36534, 36547, 37588, 36633, 36653, 33637, 33810, 36773, 37635, + 41631, 2640, 36787, 18730, 35294, 34109, 15803, 24312, 12898, 36857, 40980, + 34492, 34049, 8997, 14720, 28375, 36919, 34108, 31422, 36961, 34156, 34315, + 37032, 34579, 37060, 34534, 37038, 37117, 37223, 15088, 37289, 37316, + 31916, 35123, 7817, 37390, 27807, 37441, 37474, 21945, 37561, 35526, 15515, + 35596, 21979, 3377, 37676, 37739, 35553, 35819, 28815, 23235, 35554, 35557, + 18789, 37444, 35820, 35897, 35839, 37747, 37979, 36540, 38277, 38310, + 37926, 38304, 28662, 17081, 9850, 34520, 4732, 15918, 18911, 27676, 38523, + 38550, 16748, 38563, 28373, 25050, 38582, 30965, 35552, 38589, 21452, + 18849, 27832, 628, 25616, 37039, 37093, 19153, 6421, 13066, 38705, 34370, + 38710, 18959, 17725, 17797, 19177, 28789, 23361, 38683, 38748, 37333, + 38743, 23370, 37355, 38751, 37925, 20688, 12471, 12476, 38793, 38815, + 38833, 38846, 38848, 38866, 38880, 21612, 38894, 29724, 37939, 38911, + 38901, 37917, 31098, 19153, 38964, 38963, 38987, 39014, 15118, 29045, + 15697, 1584, 16732, 22278, 39114, 39095, 39112, 39111, 19199, 27943, 5843, + 21936, 39137, 39142, 39148, 37752, 39225, 18985, 19314, 38999, 39173, + 39413, 39436, 39483, 39440, 39512, 22309, 14020, 37041, 39893, 39648, + 39650, 39685, 39668, 19470, 39700, 39725, 34304, 20532, 39732, 27048, + 14531, 12413, 39760, 39744, 40254, 23109, 6243, 39822, 16971, 39938, 39935, + 39948, 40552, 40404, 40887, 41362, 41387, 41185, 41251, 41439, 40318, + 40323, 41268, 40462, 26760, 40388, 8539, 41363, 41504, 6459, 41523, 40249, + 41145, 41652, 40592, 40597, 40606, 40610, 19764, 40618, 40623, 17252, + 40641, 15200, 14821, 15645, 20274, 14270, 35883, 40706, 40712, 19350, + 37924, 28066, 40727, 40726, 40761, 22175, 22154, 40773, 39352, 37003, + 38898, 33919, 40802, 40809, 31452, 40846, 29206, 19390, 18805, 18875, + 29047, 18936, 17224, 19025, 29598, 35802, 6394, 31135, 35198, 36406, 37737, + 37875, 35396, 37612, 37761, 37835, 35180, 17593, 29207, 16107, 30578, + 31299, 28880, 17523, 17400, 29054, 6127, 28835, 6334, 13721, 16071, 6277, + 21551, 6136, 14114, 5883, 6201, 14049, 6004, 6353, 24395, 14115, 5824, + 22363, 18981, 5118, 4776, 5062, 5302, 34051, 13990, 34051, 33877, 18836, + 29029, 15921, 21852, 16123, 28754, 17652, 14062, 39325, 28454, 26617, + 14131, 15381, 15847, 22636, 6434, 26640, 16471, 14143, 16609, 16523, 16655, + 27681, 21707, 22174, 26289, 22162, 4063, 2984, 3597, 37830, 35603, 37788, + 20216, 20779, 14361, 17462, 20156, 1125, 895, 20299, 20362, 22097, 23144, + 427, 971, 14745, 778, 1044, 13365, 20265, 704, 36531, 629, 35546, 524, + 20120, 20685, 20749, 20386, 20227, 18958, 16010, 20290, 20526, 20588, + 20609, 20428, 20453, 20568, 20732, 20825, 20827, 20829, 20830, 28278, + 13717, 15929, 16063, 28018, 6276, 16009, 20904, 20931, 1504, 17629, 1187, + 1170, 1169, 36218, 35484, 1806, 21081, 21156, 2163, 21217, 37742, 18042, + 29068, 17292, 3104, 18860, 4324, 27089, 3613, 29817, 16094, 29849, 29716, + 29782, 29592, 19342, 19132, 16525, 21456, 13700, 29199, 16585, 21940, 837, + 21709, 3014, 22301, 37469, 38644, 37734, 22493, 22413, 22399, 13886, 22731, + 23193, 35398, 5882, 5999, 5904, 23084, 22968, 37519, 23166, 23247, 23058, + 22854, 6643, 6241, 17045, 14069, 27909, 29763, 23073, 24195, 23169, 35799, + 1043, 37856, 29836, 4867, 28933, 18802, 37896, 35323, 37821, 14240, 23582, + 23710, 24158, 24136, 6550, 6524, 15086, 24269, 23375, 6403, 6404, 14081, + 6304, 14045, 5886, 14035, 33066, 35399, 7610, 13426, 35240, 24332, 24334, + 6439, 6059, 23147, 5947, 23364, 34324, 30205, 34912, 24702, 10336, 9771, + 24539, 16056, 9647, 9662, 37000, 28531, 25024, 62, 70, 9755, 24985, 24984, + 24693, 11419, 11527, 18132, 37197, 25713, 18021, 11114, 14889, 11042, + 13392, 39146, 11896, 25399, 42075, 25782, 25393, 25553, 18915, 11623, + 25252, 11425, 25659, 25963, 26994, 15348, 12430, 12973, 18825, 12971, + 21773, 13024, 6361, 37951, 26318, 12937, 12723, 15072, 16784, 21892, 35618, + 21903, 5884, 21851, 21541, 30958, 12547, 6186, 12852, 13412, 12815, 12674, + 17097, 26254, 27940, 26219, 19347, 26160, 30832, 7659, 26211, 13010, 13025, + 26142, 22642, 14545, 14394, 14268, 15257, 14242, 13310, 29904, 15254, + 26511, 17962, 26806, 26654, 15300, 27326, 14435, 14293, 17543, 27187, + 27218, 27337, 27397, 6418, 25873, 26776, 27212, 15319, 27258, 27479, 16320, + 15514, 37792, 37618, 35818, 35531, 37513, 32798, 35292, 37991, 28069, + 28427, 18924, 28007, 16255, 15759, 28164, 16444, 23101, 28170, 22599, + 27940, 30786, 28987, 17178, 17014, 28913, 29264, 29319, 29332, 18319, + 18213, 20857, 19108, 1515, 29818, 16120, 13919, 19018, 18711, 24545, 16134, + 16049, 19167, 35875, 16181, 24743, 16115, 29900, 29756, 37767, 29751, + 17567, 28138, 17745, 30083, 16227, 19673, 19718, 16216, 30037, 30323, + 42438, 15129, 29800, 35532, 18859, 18830, 15099, 15821, 19022, 16127, + 18885, 18675, 37370, 22322, 37698, 35555, 6244, 20703, 21025, 20967, 30584, + 12850, 30478, 30479, 30587, 18071, 14209, 14942, 18672, 29752, 29851, + 16063, 19130, 19143, 16584, 19094, 25006, 37639, 21889, 30750, 30861, + 30856, 30930, 29648, 31065, 30529, 22243, 16654, 31131, 33942, 31141, + 27181, 16122, 31290, 31220, 16750, 5862, 16690, 37429, 31217, 3404, 18828, + 665, 15802, 5998, 13719, 21867, 13680, 13994, 468, 3085, 31458, 23129, + 9973, 23215, 23196, 23053, 603, 30960, 23082, 23494, 31486, 16889, 31837, + 31853, 16913, 23475, 24252, 24230, 31949, 18937, 6064, 31886, 31868, 31918, + 27314, 32220, 32263, 32211, 32590, 25185, 24924, 31560, 32151, 24194, + 17002, 27509, 2326, 26582, 78, 13775, 22468, 25618, 25592, 18786, 32733, + 31527, 2092, 23273, 23875, 31500, 24078, 39398, 34373, 39523, 27164, 13375, + 14818, 18935, 26029, 39455, 26016, 33920, 28967, 27857, 17642, 33079, + 17410, 32966, 33033, 33090, 26548, 39107, 27202, 33378, 33381, 27217, + 33875, 28071, 34320, 29211, 23174, 16767, 6208, 23339, 6305, 23268, 6360, + 34464, 63932, 15759, 34861, 29730, 23042, 34926, 20293, 34951, 35007, + 35046, 35173, 35149, 22147, 35156, 30597, 30596, 35829, 35801, 35740, + 35321, 16045, 33955, 18165, 18127, 14322, 35389, 35356, 37960, 24397, + 37419, 17028, 26068, 28969, 28868, 6213, 40301, 35999, 36073, 32220, 22938, + 30659, 23024, 17262, 14036, 36394, 36519, 19465, 36656, 36682, 17140, + 27736, 28603, 8993, 18587, 28537, 28299, 6106, 39913, 14005, 18735, 37051, + 37015, 21873, 18694, 37307, 37892, 35403, 16482, 35580, 37927, 35869, + 35899, 34021, 35371, 38297, 38311, 38295, 38294, 36148, 29765, 16066, + 18687, 19010, 17386, 16103, 12837, 38543, 36583, 36454, 36453, 16076, + 18925, 19064, 16366, 29714, 29803, 16124, 38721, 37040, 26695, 18973, + 37011, 22495, 38749, 37736, 35209, 35878, 35631, 25534, 37562, 23313, + 35689, 18748, 29689, 16923, 38811, 38769, 39224, 3878, 24001, 35781, 19122, + 38943, 38106, 37622, 38359, 37349, 17600, 35664, 19047, 35684, 39132, + 35397, 16128, 37418, 18725, 33812, 39227, 39245, 31494, 15869, 39323, + 19311, 39338, 39516, 35685, 22728, 27279, 39457, 23294, 39471, 39153, + 19344, 39240, 39356, 19389, 19351, 37757, 22642, 4866, 22562, 18872, 5352, + 30788, 10015, 15800, 26821, 15741, 37976, 14631, 24912, 10113, 10603, + 24839, 40015, 40019, 40059, 39989, 39952, 39807, 39887, 40493, 39839, + 41461, 41214, 40225, 19630, 16644, 40472, 19632, 40204, 41396, 41197, + 41203, 39215, 40357, 33981, 28178, 28639, 27522, 34300, 17715, 28068, + 28292, 28144, 33824, 34286, 28160, 14295, 24676, 31202, 13724, 13888, + 18733, 18910, 15714, 37851, 37566, 37704, 703, 30905, 37495, 37965, 20452, + 13376, 36964, 21853, 30781, 30804, 30902, 30795, 5975, 12745, 18753, 13978, + 20338, 28634, 28633, 28702, 28702, 21524, 16821, 22459, 22771, 22410, + 40214, 22487, 28980, 13487, 16812, 29163, 27712, 20375, 23336, 6069, 35401, + 24844, 23246, 23051, 17084, 17544, 14124, 19323, 35324, 37819, 37816, 6358, + 3869, 33906, 27840, 5139, 17146, 11302, 17345, 22932, 15799, 26433, 32168, + 24923, 24740, 18873, 18827, 35322, 37605, 29666, 16105, 29876, 35683, 6303, + 16097, 19123, 27352, 29683, 29691, 16086, 19006, 19092, 6105, 19046, 935, + 5156, 18917, 29768, 18710, 28837, 18806, 37508, 29670, 37727, 1278, 37681, + 35534, 35350, 37766, 35815, 21973, 18741, 35458, 29035, 18755, 3327, 22180, + 1562, 3051, 3256, 21762, 31172, 6138, 32254, 5826, 19024, 6226, 17710, + 37889, 14090, 35520, 18861, 22960, 6335, 6275, 29828, 23201, 14050, 15707, + 14000, 37471, 23161, 35457, 6242, 37748, 15565, 2740, 19094, 14730, 20724, + 15721, 15692, 5020, 29045, 17147, 33304, 28175, 37092, 17643, 27991, 32335, + 28775, 27823, 15574, 16365, 15917, 28162, 28428, 15727, 1013, 30033, 14012, + 13512, 18048, 16090, 18545, 22980, 37486, 18750, 36673, 35868, 27584, + 22546, 22472, 14038, 5202, 28926, 17250, 19057, 12259, 4784, 9149, 26809, + 26983, 5016, 13541, 31732, 14047, 35459, 14294, 13306, 19615, 27162, 13997, + 27831, 33854, 17631, 17614, 27942, 27985, 27778, 28638, 28439, 28937, + 33597, 5946, 33773, 27776, 28755, 6107, 22921, 23170, 6067, 23137, 23153, + 6405, 16892, 14125, 23023, 5948, 14023, 29070, 37776, 26266, 17061, 23150, + 23083, 17043, 27179, 16121, 30518, 17499, 17098, 28957, 16985, 35297, + 20400, 27944, 23746, 17614, 32333, 17341, 27148, 16982, 4868, 28838, 28979, + 17385, 15781, 27871, 63525, 19023, 32357, 23019, 23855, 15859, 24412, + 19037, 6111, 32164, 33830, 21637, 15098, 13056, 532, 22398, 2261, 1561, + 16357, 8094, 41654, 28675, 37211, 23920, 29583, 31955, 35417, 37920, 20424, + 32743, 29389, 29456, 31476, 29496, 29497, 22262, 29505, 29512, 16041, + 31512, 36972, 29173, 18674, 29665, 33270, 16074, 30476, 16081, 27810, + 22269, 29721, 29726, 29727, 16098, 16112, 16116, 16122, 29907, 16142, + 16211, 30018, 30061, 30066, 30093, 16252, 30152, 30172, 16320, 30285, + 16343, 30324, 16348, 30330, 20316, 29064, 22051, 35200, 22633, 16413, + 30531, 16441, 26465, 16453, 13787, 30616, 16490, 16495, 23646, 30654, + 30667, 22770, 30744, 28857, 30748, 16552, 30777, 30791, 30801, 30822, + 33864, 21813, 31027, 26627, 31026, 16643, 16649, 31121, 31129, 36795, + 31238, 36796, 16743, 31377, 16818, 31420, 33401, 16836, 31439, 31451, + 16847, 20001, 31586, 31596, 31611, 31762, 31771, 16992, 17018, 31867, + 31900, 17036, 31928, 17044, 31981, 36755, 28864, 3279, 32207, 32212, 32208, + 32253, 32686, 32692, 29343, 17303, 32800, 32805, 31545, 32814, 32817, + 32852, 15820, 22452, 28832, 32951, 33001, 17389, 33036, 29482, 33038, + 33042, 30048, 33044, 17409, 15161, 33110, 33113, 33114, 17427, 22586, + 33148, 33156, 17445, 33171, 17453, 33189, 22511, 33217, 33252, 33364, + 17551, 33446, 33398, 33482, 33496, 33535, 17584, 33623, 38505, 27018, + 33797, 28917, 33892, 24803, 33928, 17668, 33982, 34017, 34040, 34064, + 34104, 34130, 17723, 34159, 34160, 34272, 17783, 34418, 34450, 34482, + 34543, 38469, 34699, 17926, 17943, 34990, 35071, 35108, 35143, 35217, + 31079, 35369, 35384, 35476, 35508, 35921, 36052, 36082, 36124, 18328, + 22623, 36291, 18413, 20206, 36410, 21976, 22356, 36465, 22005, 36528, + 18487, 36558, 36578, 36580, 36589, 36594, 36791, 36801, 36810, 36812, + 36915, 39364, 18605, 39136, 37395, 18718, 37416, 37464, 37483, 37553, + 37550, 37567, 37603, 37611, 37619, 37620, 37629, 37699, 37764, 37805, + 18757, 18769, 40639, 37911, 21249, 37917, 37933, 37950, 18794, 37972, + 38009, 38189, 38306, 18855, 38388, 38451, 18917, 26528, 18980, 38720, + 18997, 38834, 38850, 22100, 19172, 24808, 39097, 19225, 39153, 22596, + 39182, 39193, 20916, 39196, 39223, 39234, 39261, 39266, 19312, 39365, + 19357, 39484, 39695, 31363, 39785, 39809, 39901, 39921, 39924, 19565, + 39968, 14191, 7106, 40265, 39994, 40702, 22096, 40339, 40381, 40384, 40444, + 38134, 36790, 40571, 40620, 40625, 40637, 40646, 38108, 40674, 40689, + 40696, 31432, 40772, 148, 695, 928, 26906, 38083, 22956, 1239, 22592, + 38081, 14265, 1493, 1557, 1654, 5818, 22359, 29043, 2754, 2765, 3007, + 21610, 63547, 3019, 21662, 3067, 3131, 3155, 3173, 3196, 24807, 3213, + 22138, 3253, 3293, 3309, 3439, 3506, 3528, 26965, 39983, 34725, 3588, 3598, + 3799, 3984, 3885, 3699, 23584, 4028, 24075, 4188, 4175, 4214, 26398, 4219, + 4232, 4246, 13895, 4287, 4307, 4399, 4411, 21348, 33965, 4835, 4981, 4918, + 35713, 5495, 5657, 6083, 6087, 20088, 28859, 6189, 6506, 6701, 6725, 7210, + 7280, 7340, 7880, 25283, 7893, 7957, 29080, 26709, 8261, 27113, 14024, + 8828, 9175, 9210, 10026, 10353, 10575, 33533, 10599, 10643, 10965, 35237, + 10984, 36768, 11022, 38840, 11071, 38983, 39613, 11340, 65535, 11400, + 11447, 23528, 11528, 11538, 11703, 11669, 11842, 12148, 12236, 12339, + 12390, 13087, 13278, 24497, 26184, 26303, 31353, 13671, 13811, 29185, + 18874, 30679, 13850, 14102, 32391, 838, 22709, 26382, 26904, 15015, 30295, + 24546, 15889, 16057, 30206, 8346, 18640, 19128, 16665, 35482, 17134, 17165, + 16443, 17204, 17302, 19013, 1482, 20946, 1553, 22943, 7848, 15294, 15615, + 17412, 17622, 22408, 18036, 14747, 18223, 34280, 39369, 14178, 8643, 35678, + 35662, 39382, 18450, 18683, 18965, 29193, 19136, 3192, 22885, 20133, 20358, + 1913, 36570, 20524, 21135, 22335, 29041, 21145, 21529, 16202, 19111, 21948, + 21574, 21614, 27474, 37332, 13427, 21823, 30258, 21854, 18200, 21858, + 21862, 22471, 18751, 22621, 20582, 13563, 13260, 24798, 22787, 18300, + 35144, 23214, 23433, 23558, 7568, 22433, 29009, 28598, 24834, 31762, 36950, + 25010, 20378, 35682, 25602, 25674, 23899, 27639, 36662, 25732, 6428, 35562, + 18934, 25736, 16367, 25874, 19392, 26047, 26293, 10011, 37989, 22497, + 24981, 23079, 63693, 20411, 22201, 17697, 26364, 20074, 18740, 38486, + 28047, 27837, 13848, 35191, 26521, 26734, 25617, 26718, 29151, 26823, + 31554, 37056, 2577, 26918, 37124, 26937, 31301, 40432, 27130, 39462, 27181, + 13919, 25705, 33, 31107, 27188, 27483, 23852, 13593, 33743, 27549, 18128, + 27812, 30011, 34917, 28078, 22710, 14108, 9613, 28747, 29133, 15444, 29312, + 29317, 37505, 8570, 29323, 37680, 29414, 18896, 27705, 38047, 29776, 3832, + 34855, 35061, 10534, 33907, 6065, 28344, 18986, 6176, 14756, 14009, 23568, + 31203, 17727, 26294, 40109, 39076, 35139, 30668, 30808, 22230, 16607, 5642, + 14753, 14127, 33000, 5061, 29101, 33638, 31197, 37288, 23143, 19639, 28847, + 35243, 31229, 31242, 31499, 32102, 16762, 31555, 31102, 32777, 28597, + 41695, 27139, 33560, 21410, 28167, 37823, 26678, 38749, 33135, 32803, + 27061, 5101, 12847, 32840, 23941, 35888, 32899, 22293, 38947, 35145, 23979, + 18824, 26046, 27093, 21458, 19109, 16257, 15377, 26422, 32912, 33012, + 33070, 8097, 33103, 33161, 33199, 33306, 33542, 33583, 33674, 13770, 33896, + 34474, 18682, 25574, 35158, 30728, 37461, 35256, 17394, 35303, 17375, + 35304, 35654, 35796, 23032, 35849, 36619, 36805, 37100, 31569, 37136, + 37180, 15863, 37214, 19146, 36816, 29327, 22155, 38119, 38377, 38320, + 38328, 38706, 39121, 39241, 39274, 39363, 39464, 39694, 40282, 40347, + 32415, 40696, 40739, 19620, 38215, 41619, 29090, 41727, 19857, 36882, + 42443, 19868, 3228, 36798, 21953, 36794, 9392, 36793, 19091, 17673, 32383, + 28502, 27313, 20202, 13540, 35628, 30877, 14138, 36480, 6133, 32804, 35692, + 35737, 31294, 26287, 15851, 30293, 15543, 22069, 22870, 20122, 24193, + 25176, 22207, 3693, 36366, 23405, 16008, 19614, 25566, 25296, 6134, 6267, + 25904, 22061, 23626, 21530, 21265, 15814, 40344, 19581, 22050, 22046, + 32585, 24280, 22901, 15680, 34672, 19996, 4074, 3401, 14010, 33047, 40286, + 36120, 30267, 40005, 30286, 30649, 37701, 21554, 33096, 33527, 22053, + 33074, 33816, 32957, 21994, 31074, 22083, 21526, 3741, 13774, 22021, 22001, + 26353, 33506, 13869, 30004, 22000, 21946, 21655, 21874, 3137, 3222, 24272, + 20808, 3702, 11362, 3746, 40619, 32090, 21982, 4213, 25245, 38765, 21652, + 36045, 29174, 37238, 25596, 25529, 25598, 21865, 11075, 40050, 11955, + 20890, 13535, 3495, 20903, 21581, 21790, 21779, 30310, 36397, 26762, 30129, + 32950, 34820, 34694, 35015, 33206, 33820, 4289, 17644, 29444, 18182, 23440, + 33547, 26771, 22139, 9972, 32047, 16803, 32115, 28368, 29366, 37232, 4569, + 37384, 15612, 42665, 3756, 3833, 29286, 7330, 18254, 20418, 32761, 4075, + 16634, 40029, 25887, 11680, 18675, 18400, 40316, 4076, 3594, 24674, 30115, + 4077, 65535, 24648, 4487, 29091, 32398, 40272, 19994, 19972, 13687, 23309, + 27826, 21351, 13996, 14812, 21373, 13989, 17944, 22682, 19310, 33325, + 21579, 22442, 23189, 2425, 65535, 14930, 9317, 29556, 40620, 19721, 39917, + 15614, 40752, 19547, 20393, 38302, 40926, 33884, 15798, 29362, 26547, + 14112, 25390, 32037, 16119, 15916, 14890, 36872, 21196, 15988, 13946, + 17897, 1166, 30272, 23280, 3766, 30842, 32558, 22695, 16575, 22140, 39819, + 23924, 30292, 42036, 40581, 19681, 30201, 14331, 24857, 12506, 17394, + 65535, 22109, 4777, 22439, 18787, 40454, 21044, 28846, 13741, 27722, 40316, + 31830, 39737, 22494, 5996, 23635, 25811, 38096, 25397, 29028, 34477, 3368, + 27938, 19170, 3441, 65535, 20990, 7951, 23950, 38659, 7633, 40577, 36940, + 31519, 39682, 23761, 31651, 25192, 25397, 39679, 31695, 39722, 31870, + 39726, 31810, 31878, 39957, 31740, 39689, 40727, 39963, 18750, 40794, + 21875, 23491, 20477, 40600, 20466, 21088, 15878, 21201, 22375, 20566, + 22967, 24082, 38856, 40363, 36700, 21609, 38836, 39232, 38842, 21292, + 24880, 26924, 21466, 39946, 40194, 19515, 38465, 27008, 20646, 30022, 5997, + 39386, 21107, 65535, 37209, 38529, 37212, 65535, 37201, 36503, 25471, + 27939, 27338, 22033, 37262, 30074, 25221, 1020, 29519, 31856, 23585, 15613, + 65535, 18713, 30422, 39837, 20010, 3284, 33726, 34882, 65535, 23626, 27072, + 20717, 22394, 21023, 24053, 20174, 27697, 498, 20281, 21660, 21722, 21146, + 36226, 13822, 24332, 13811, 65535, 27474, 37244, 40869, 39831, 38958, + 39092, 39610, 40616, 40580, 29050, 31508, 65535, 27642, 34840, 32632, + 65535, 22048, 42570, 36471, 40787, 65535, 36308, 36431, 40476, 36353, + 25218, 33661, 36392, 36469, 31443, 19063, 31294, 30936, 27882, 35431, + 30215, 35418, 40742, 27854, 34774, 30147, 41650, 30803, 63552, 36108, + 29410, 29553, 35629, 29442, 29937, 36075, 19131, 34351, 24506, 34976, + 17591, 65535, 6203, 28165, 65535, 35454, 9499, 65535, 24829, 30311, 39639, + 40260, 37742, 39823, 34805, 65535, 34831, 36087, 29484, 38689, 39856, + 13782, 29362, 19463, 31825, 39242, 24921, 24921, 19460, 40598, 24957, + 65535, 22367, 24943, 25254, 25145, 25294, 14940, 25058, 21418, 13301, + 25444, 26626, 13778, 23895, 35778, 36826, 36409, 65535, 20697, 7494, 30982, + 21298, 38456, 3899, 16485, 65535, 30718, 65535, 31938, 24346, 31962, 31277, + 32870, 32867, 32077, 29957, 29938, 35220, 33306, 26380, 32866, 29830, + 32859, 29936, 33027, 30500, 35209, 26572, 30035, 28369, 34729, 34766, + 33224, 34700, 35401, 36013, 35651, 30507, 29944, 34010, 13877, 27058, + 36262, 65535, 35241, 29800, 28089, 34753, 16401, 29927, 15835, 29046, + 24740, 24988, 15569, 29026, 24695, 65535, 32625, 35629, 29264, 24809, + 19326, 21024, 15384, 15559, 24279, 30294, 21809, 6468, 4862, 39171, 28124, + 28845, 23745, 25005, 35343, 13943, 238, 26694, 20238, 17762, 23327, 25420, + 40784, 40614, 25195, 12288, 65292, 12289, 12290, 65294, 8231, 65307, 65306, + 65311, 65281, 65072, 8230, 8229, 65104, 65105, 65106, 183, 65108, 65109, + 65110, 65111, 65372, 8211, 65073, 8212, 65075, 9588, 65076, 65103, 65288, + 65289, 65077, 65078, 65371, 65373, 65079, 65080, 12308, 12309, 65081, + 65082, 12304, 12305, 65083, 65084, 12298, 12299, 65085, 65086, 12296, + 12297, 65087, 65088, 12300, 12301, 65089, 65090, 12302, 12303, 65091, + 65092, 65113, 65114, 65115, 65116, 65117, 65118, 8216, 8217, 8220, 8221, + 12317, 12318, 8245, 8242, 65283, 65286, 65290, 8251, 167, 12291, 9675, + 9679, 9651, 9650, 9678, 9734, 9733, 9671, 9670, 9633, 9632, 9661, 9660, + 12963, 8453, 175, 65507, 65343, 717, 65097, 65098, 65101, 65102, 65099, + 65100, 65119, 65120, 65121, 65291, 65293, 215, 247, 177, 8730, 65308, + 65310, 65309, 8806, 8807, 8800, 8734, 8786, 8801, 65122, 65123, 65124, + 65125, 65126, 65374, 8745, 8746, 8869, 8736, 8735, 8895, 13266, 13265, + 8747, 8750, 8757, 8756, 9792, 9794, 8853, 8857, 8593, 8595, 8592, 8594, + 8598, 8599, 8601, 8600, 8741, 8739, 65295, 65340, 8725, 65128, 65284, + 65509, 12306, 65504, 65505, 65285, 65312, 8451, 8457, 65129, 65130, 65131, + 13269, 13212, 13213, 13214, 13262, 13217, 13198, 13199, 13252, 176, 20825, + 20827, 20830, 20829, 20833, 20835, 21991, 29929, 31950, 9601, 9602, 9603, + 9604, 9605, 9606, 9607, 9608, 9615, 9614, 9613, 9612, 9611, 9610, 9609, + 9532, 9524, 9516, 9508, 9500, 9620, 9472, 9474, 9621, 9484, 9488, 9492, + 9496, 9581, 9582, 9584, 9583, 9552, 9566, 9578, 9569, 9698, 9699, 9701, + 9700, 9585, 9586, 9587, 65296, 65297, 65298, 65299, 65300, 65301, 65302, + 65303, 65304, 65305, 8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, + 8553, 12321, 12322, 12323, 12324, 12325, 12326, 12327, 12328, 12329, 21313, + 21316, 21317, 65313, 65314, 65315, 65316, 65317, 65318, 65319, 65320, + 65321, 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, + 65331, 65332, 65333, 65334, 65335, 65336, 65337, 65338, 65345, 65346, + 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, + 65357, 65358, 65359, 65360, 65361, 65362, 65363, 65364, 65365, 65366, + 65367, 65368, 65369, 65370, 913, 914, 915, 916, 917, 918, 919, 920, 921, + 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, + 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, + 960, 961, 963, 964, 965, 966, 967, 968, 969, 12549, 12550, 12551, 12552, + 12553, 12554, 12555, 12556, 12557, 12558, 12559, 12560, 12561, 12562, + 12563, 12564, 12565, 12566, 12567, 12568, 12569, 12570, 12571, 12572, + 12573, 12574, 12575, 12576, 12577, 12578, 12579, 12580, 12581, 12582, + 12583, 12584, 12585, 729, 713, 714, 711, 715, 9216, 9217, 9218, 9219, 9220, + 9221, 9222, 9223, 9224, 9225, 9226, 9227, 9228, 9229, 9230, 9231, 9232, + 9233, 9234, 9235, 9236, 9237, 9238, 9239, 9240, 9241, 9242, 9243, 9244, + 9245, 9246, 9247, 9249, 8364, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19968, 20057, 19969, 19971, 20035, 20061, 20102, + 20108, 20154, 20799, 20837, 20843, 20960, 20992, 20993, 21147, 21269, + 21313, 21340, 21448, 19977, 19979, 19976, 19978, 20011, 20024, 20961, + 20037, 20040, 20063, 20062, 20110, 20129, 20800, 20995, 21242, 21315, + 21449, 21475, 22303, 22763, 22805, 22823, 22899, 23376, 23377, 23379, + 23544, 23567, 23586, 23608, 23665, 24029, 24037, 24049, 24050, 24051, + 24062, 24178, 24318, 24331, 24339, 25165, 19985, 19984, 19981, 20013, + 20016, 20025, 20043, 23609, 20104, 20113, 20117, 20114, 20116, 20130, + 20161, 20160, 20163, 20166, 20167, 20173, 20170, 20171, 20164, 20803, + 20801, 20839, 20845, 20846, 20844, 20887, 20982, 20998, 20999, 21000, + 21243, 21246, 21247, 21270, 21305, 21320, 21319, 21317, 21342, 21380, + 21451, 21450, 21453, 22764, 22825, 22827, 22826, 22829, 23380, 23569, + 23588, 23610, 23663, 24052, 24187, 24319, 24340, 24341, 24515, 25096, + 25142, 25163, 25166, 25903, 25991, 26007, 26020, 26041, 26085, 26352, + 26376, 26408, 27424, 27490, 27513, 27595, 27604, 27611, 27663, 27700, + 28779, 29226, 29238, 29243, 29255, 29273, 29275, 29356, 29579, 19993, + 19990, 19989, 19988, 19992, 20027, 20045, 20047, 20046, 20197, 20184, + 20180, 20181, 20182, 20183, 20195, 20196, 20185, 20190, 20805, 20804, + 20873, 20874, 20908, 20985, 20986, 20984, 21002, 21152, 21151, 21253, + 21254, 21271, 21277, 20191, 21322, 21321, 21345, 21344, 21359, 21358, + 21435, 21487, 21476, 21491, 21484, 21486, 21481, 21480, 21500, 21496, + 21493, 21483, 21478, 21482, 21490, 21489, 21488, 21477, 21485, 21499, + 22235, 22234, 22806, 22830, 22833, 22900, 22902, 23381, 23427, 23612, + 24040, 24039, 24038, 24066, 24067, 24179, 24188, 24321, 24344, 24343, + 24517, 25098, 25171, 25172, 25170, 25169, 26021, 26086, 26414, 26412, + 26410, 26411, 26413, 27491, 27597, 27665, 27664, 27704, 27713, 27712, + 27710, 29359, 29572, 29577, 29916, 29926, 29976, 29983, 29992, 29993, + 30000, 30001, 30002, 30003, 30091, 30333, 30382, 30399, 30446, 30683, + 30690, 30707, 31034, 31166, 31348, 31435, 19998, 19999, 20050, 20051, + 20073, 20121, 20132, 20134, 20133, 20223, 20233, 20249, 20234, 20245, + 20237, 20240, 20241, 20239, 20210, 20214, 20219, 20208, 20211, 20221, + 20225, 20235, 20809, 20807, 20806, 20808, 20840, 20849, 20877, 20912, + 21015, 21009, 21010, 21006, 21014, 21155, 21256, 21281, 21280, 21360, + 21361, 21513, 21519, 21516, 21514, 21520, 21505, 21515, 21508, 21521, + 21517, 21512, 21507, 21518, 21510, 21522, 22240, 22238, 22237, 22323, + 22320, 22312, 22317, 22316, 22319, 22313, 22809, 22810, 22839, 22840, + 22916, 22904, 22915, 22909, 22905, 22914, 22913, 23383, 23384, 23431, + 23432, 23429, 23433, 23546, 23574, 23673, 24030, 24070, 24182, 24180, + 24335, 24347, 24537, 24534, 25102, 25100, 25101, 25104, 25187, 25179, + 25176, 25910, 26089, 26088, 26092, 26093, 26354, 26355, 26377, 26429, + 26420, 26417, 26421, 27425, 27492, 27515, 27670, 27741, 27735, 27737, + 27743, 27744, 27728, 27733, 27745, 27739, 27725, 27726, 28784, 29279, + 29277, 30334, 31481, 31859, 31992, 32566, 32650, 32701, 32769, 32771, + 32780, 32786, 32819, 32895, 32905, 32907, 32908, 33251, 33258, 33267, + 33276, 33292, 33307, 33311, 33390, 33394, 33406, 34411, 34880, 34892, + 34915, 35199, 38433, 20018, 20136, 20301, 20303, 20295, 20311, 20318, + 20276, 20315, 20309, 20272, 20304, 20305, 20285, 20282, 20280, 20291, + 20308, 20284, 20294, 20323, 20316, 20320, 20271, 20302, 20278, 20313, + 20317, 20296, 20314, 20812, 20811, 20813, 20853, 20918, 20919, 21029, + 21028, 21033, 21034, 21032, 21163, 21161, 21162, 21164, 21283, 21363, + 21365, 21533, 21549, 21534, 21566, 21542, 21582, 21543, 21574, 21571, + 21555, 21576, 21570, 21531, 21545, 21578, 21561, 21563, 21560, 21550, + 21557, 21558, 21536, 21564, 21568, 21553, 21547, 21535, 21548, 22250, + 22256, 22244, 22251, 22346, 22353, 22336, 22349, 22343, 22350, 22334, + 22352, 22351, 22331, 22767, 22846, 22941, 22930, 22952, 22942, 22947, + 22937, 22934, 22925, 22948, 22931, 22922, 22949, 23389, 23388, 23386, + 23387, 23436, 23435, 23439, 23596, 23616, 23617, 23615, 23614, 23696, + 23697, 23700, 23692, 24043, 24076, 24207, 24199, 24202, 24311, 24324, + 24351, 24420, 24418, 24439, 24441, 24536, 24524, 24535, 24525, 24561, + 24555, 24568, 24554, 25106, 25105, 25220, 25239, 25238, 25216, 25206, + 25225, 25197, 25226, 25212, 25214, 25209, 25203, 25234, 25199, 25240, + 25198, 25237, 25235, 25233, 25222, 25913, 25915, 25912, 26097, 26356, + 26463, 26446, 26447, 26448, 26449, 26460, 26454, 26462, 26441, 26438, + 26464, 26451, 26455, 27493, 27599, 27714, 27742, 27801, 27777, 27784, + 27785, 27781, 27803, 27754, 27770, 27792, 27760, 27788, 27752, 27798, + 27794, 27773, 27779, 27762, 27774, 27764, 27782, 27766, 27789, 27796, + 27800, 27778, 28790, 28796, 28797, 28792, 29282, 29281, 29280, 29380, + 29378, 29590, 29996, 29995, 30007, 30008, 30338, 30447, 30691, 31169, + 31168, 31167, 31350, 31995, 32597, 32918, 32915, 32925, 32920, 32923, + 32922, 32946, 33391, 33426, 33419, 33421, 35211, 35282, 35328, 35895, + 35910, 35925, 35997, 36196, 36208, 36275, 36523, 36554, 36763, 36784, + 36802, 36806, 36805, 36804, 24033, 37009, 37026, 37034, 37030, 37027, + 37193, 37318, 37324, 38450, 38446, 38449, 38442, 38444, 20006, 20054, + 20083, 20107, 20123, 20126, 20139, 20140, 20335, 20381, 20365, 20339, + 20351, 20332, 20379, 20363, 20358, 20355, 20336, 20341, 20360, 20329, + 20347, 20374, 20350, 20367, 20369, 20346, 20820, 20818, 20821, 20841, + 20855, 20854, 20856, 20925, 20989, 21051, 21048, 21047, 21050, 21040, + 21038, 21046, 21057, 21182, 21179, 21330, 21332, 21331, 21329, 21350, + 21367, 21368, 21369, 21462, 21460, 21463, 21619, 21621, 21654, 21624, + 21653, 21632, 21627, 21623, 21636, 21650, 21638, 21628, 21648, 21617, + 21622, 21644, 21658, 21602, 21608, 21643, 21629, 21646, 22266, 22403, + 22391, 22378, 22377, 22369, 22374, 22372, 22396, 22812, 22857, 22855, + 22856, 22852, 22868, 22974, 22971, 22996, 22969, 22958, 22993, 22982, + 22992, 22989, 22987, 22995, 22986, 22959, 22963, 22994, 22981, 23391, + 23396, 23395, 23447, 23450, 23448, 23452, 23449, 23451, 23578, 23624, + 23621, 23622, 23735, 23713, 23736, 23721, 23723, 23729, 23731, 24088, + 24090, 24086, 24085, 24091, 24081, 24184, 24218, 24215, 24220, 24213, + 24214, 24310, 24358, 24359, 24361, 24448, 24449, 24447, 24444, 24541, + 24544, 24573, 24565, 24575, 24591, 24596, 24623, 24629, 24598, 24618, + 24597, 24609, 24615, 24617, 24619, 24603, 25110, 25109, 25151, 25150, + 25152, 25215, 25289, 25292, 25284, 25279, 25282, 25273, 25298, 25307, + 25259, 25299, 25300, 25291, 25288, 25256, 25277, 25276, 25296, 25305, + 25287, 25293, 25269, 25306, 25265, 25304, 25302, 25303, 25286, 25260, + 25294, 25918, 26023, 26044, 26106, 26132, 26131, 26124, 26118, 26114, + 26126, 26112, 26127, 26133, 26122, 26119, 26381, 26379, 26477, 26507, + 26517, 26481, 26524, 26483, 26487, 26503, 26525, 26519, 26479, 26480, + 26495, 26505, 26494, 26512, 26485, 26522, 26515, 26492, 26474, 26482, + 27427, 27494, 27495, 27519, 27667, 27675, 27875, 27880, 27891, 27825, + 27852, 27877, 27827, 27837, 27838, 27836, 27874, 27819, 27861, 27859, + 27832, 27844, 27833, 27841, 27822, 27863, 27845, 27889, 27839, 27835, + 27873, 27867, 27850, 27820, 27887, 27868, 27862, 27872, 28821, 28814, + 28818, 28810, 28825, 29228, 29229, 29240, 29256, 29287, 29289, 29376, + 29390, 29401, 29399, 29392, 29609, 29608, 29599, 29611, 29605, 30013, + 30109, 30105, 30106, 30340, 30402, 30450, 30452, 30693, 30717, 31038, + 31040, 31041, 31177, 31176, 31354, 31353, 31482, 31998, 32596, 32652, + 32651, 32773, 32954, 32933, 32930, 32945, 32929, 32939, 32937, 32948, + 32938, 32943, 33253, 33278, 33293, 33459, 33437, 33433, 33453, 33469, + 33439, 33465, 33457, 33452, 33445, 33455, 33464, 33443, 33456, 33470, + 33463, 34382, 34417, 21021, 34920, 36555, 36814, 36820, 36817, 37045, + 37048, 37041, 37046, 37319, 37329, 38263, 38272, 38428, 38464, 38463, + 38459, 38468, 38466, 38585, 38632, 38738, 38750, 20127, 20141, 20142, + 20449, 20405, 20399, 20415, 20448, 20433, 20431, 20445, 20419, 20406, + 20440, 20447, 20426, 20439, 20398, 20432, 20420, 20418, 20442, 20430, + 20446, 20407, 20823, 20882, 20881, 20896, 21070, 21059, 21066, 21069, + 21068, 21067, 21063, 21191, 21193, 21187, 21185, 21261, 21335, 21371, + 21402, 21467, 21676, 21696, 21672, 21710, 21705, 21688, 21670, 21683, + 21703, 21698, 21693, 21674, 21697, 21700, 21704, 21679, 21675, 21681, + 21691, 21673, 21671, 21695, 22271, 22402, 22411, 22432, 22435, 22434, + 22478, 22446, 22419, 22869, 22865, 22863, 22862, 22864, 23004, 23000, + 23039, 23011, 23016, 23043, 23013, 23018, 23002, 23014, 23041, 23035, + 23401, 23459, 23462, 23460, 23458, 23461, 23553, 23630, 23631, 23629, + 23627, 23769, 23762, 24055, 24093, 24101, 24095, 24189, 24224, 24230, + 24314, 24328, 24365, 24421, 24456, 24453, 24458, 24459, 24455, 24460, + 24457, 24594, 24605, 24608, 24613, 24590, 24616, 24653, 24688, 24680, + 24674, 24646, 24643, 24684, 24683, 24682, 24676, 25153, 25308, 25366, + 25353, 25340, 25325, 25345, 25326, 25341, 25351, 25329, 25335, 25327, + 25324, 25342, 25332, 25361, 25346, 25919, 25925, 26027, 26045, 26082, + 26149, 26157, 26144, 26151, 26159, 26143, 26152, 26161, 26148, 26359, + 26623, 26579, 26609, 26580, 26576, 26604, 26550, 26543, 26613, 26601, + 26607, 26564, 26577, 26548, 26586, 26597, 26552, 26575, 26590, 26611, + 26544, 26585, 26594, 26589, 26578, 27498, 27523, 27526, 27573, 27602, + 27607, 27679, 27849, 27915, 27954, 27946, 27969, 27941, 27916, 27953, + 27934, 27927, 27963, 27965, 27966, 27958, 27931, 27893, 27961, 27943, + 27960, 27945, 27950, 27957, 27918, 27947, 28843, 28858, 28851, 28844, + 28847, 28845, 28856, 28846, 28836, 29232, 29298, 29295, 29300, 29417, + 29408, 29409, 29623, 29642, 29627, 29618, 29645, 29632, 29619, 29978, + 29997, 30031, 30028, 30030, 30027, 30123, 30116, 30117, 30114, 30115, + 30328, 30342, 30343, 30344, 30408, 30406, 30403, 30405, 30465, 30457, + 30456, 30473, 30475, 30462, 30460, 30471, 30684, 30722, 30740, 30732, + 30733, 31046, 31049, 31048, 31047, 31161, 31162, 31185, 31186, 31179, + 31359, 31361, 31487, 31485, 31869, 32002, 32005, 32000, 32009, 32007, + 32004, 32006, 32568, 32654, 32703, 32772, 32784, 32781, 32785, 32822, + 32982, 32997, 32986, 32963, 32964, 32972, 32993, 32987, 32974, 32990, + 32996, 32989, 33268, 33314, 33511, 33539, 33541, 33507, 33499, 33510, + 33540, 33509, 33538, 33545, 33490, 33495, 33521, 33537, 33500, 33492, + 33489, 33502, 33491, 33503, 33519, 33542, 34384, 34425, 34427, 34426, + 34893, 34923, 35201, 35284, 35336, 35330, 35331, 35998, 36000, 36212, + 36211, 36276, 36557, 36556, 36848, 36838, 36834, 36842, 36837, 36845, + 36843, 36836, 36840, 37066, 37070, 37057, 37059, 37195, 37194, 37325, + 38274, 38480, 38475, 38476, 38477, 38754, 38761, 38859, 38893, 38899, + 38913, 39080, 39131, 39135, 39318, 39321, 20056, 20147, 20492, 20493, + 20515, 20463, 20518, 20517, 20472, 20521, 20502, 20486, 20540, 20511, + 20506, 20498, 20497, 20474, 20480, 20500, 20520, 20465, 20513, 20491, + 20505, 20504, 20467, 20462, 20525, 20522, 20478, 20523, 20489, 20860, + 20900, 20901, 20898, 20941, 20940, 20934, 20939, 21078, 21084, 21076, + 21083, 21085, 21290, 21375, 21407, 21405, 21471, 21736, 21776, 21761, + 21815, 21756, 21733, 21746, 21766, 21754, 21780, 21737, 21741, 21729, + 21769, 21742, 21738, 21734, 21799, 21767, 21757, 21775, 22275, 22276, + 22466, 22484, 22475, 22467, 22537, 22799, 22871, 22872, 22874, 23057, + 23064, 23068, 23071, 23067, 23059, 23020, 23072, 23075, 23081, 23077, + 23052, 23049, 23403, 23640, 23472, 23475, 23478, 23476, 23470, 23477, + 23481, 23480, 23556, 23633, 23637, 23632, 23789, 23805, 23803, 23786, + 23784, 23792, 23798, 23809, 23796, 24046, 24109, 24107, 24235, 24237, + 24231, 24369, 24466, 24465, 24464, 24665, 24675, 24677, 24656, 24661, + 24685, 24681, 24687, 24708, 24735, 24730, 24717, 24724, 24716, 24709, + 24726, 25159, 25331, 25352, 25343, 25422, 25406, 25391, 25429, 25410, + 25414, 25423, 25417, 25402, 25424, 25405, 25386, 25387, 25384, 25421, + 25420, 25928, 25929, 26009, 26049, 26053, 26178, 26185, 26191, 26179, + 26194, 26188, 26181, 26177, 26360, 26388, 26389, 26391, 26657, 26680, + 26696, 26694, 26707, 26681, 26690, 26708, 26665, 26803, 26647, 26700, + 26705, 26685, 26612, 26704, 26688, 26684, 26691, 26666, 26693, 26643, + 26648, 26689, 27530, 27529, 27575, 27683, 27687, 27688, 27686, 27684, + 27888, 28010, 28053, 28040, 28039, 28006, 28024, 28023, 27993, 28051, + 28012, 28041, 28014, 27994, 28020, 28009, 28044, 28042, 28025, 28037, + 28005, 28052, 28874, 28888, 28900, 28889, 28872, 28879, 29241, 29305, + 29436, 29433, 29437, 29432, 29431, 29574, 29677, 29705, 29678, 29664, + 29674, 29662, 30036, 30045, 30044, 30042, 30041, 30142, 30149, 30151, + 30130, 30131, 30141, 30140, 30137, 30146, 30136, 30347, 30384, 30410, + 30413, 30414, 30505, 30495, 30496, 30504, 30697, 30768, 30759, 30776, + 30749, 30772, 30775, 30757, 30765, 30752, 30751, 30770, 31061, 31056, + 31072, 31071, 31062, 31070, 31069, 31063, 31066, 31204, 31203, 31207, + 31199, 31206, 31209, 31192, 31364, 31368, 31449, 31494, 31505, 31881, + 32033, 32023, 32011, 32010, 32032, 32034, 32020, 32016, 32021, 32026, + 32028, 32013, 32025, 32027, 32570, 32607, 32660, 32709, 32705, 32774, + 32792, 32789, 32793, 32791, 32829, 32831, 33009, 33026, 33008, 33029, + 33005, 33012, 33030, 33016, 33011, 33032, 33021, 33034, 33020, 33007, + 33261, 33260, 33280, 33296, 33322, 33323, 33320, 33324, 33467, 33579, + 33618, 33620, 33610, 33592, 33616, 33609, 33589, 33588, 33615, 33586, + 33593, 33590, 33559, 33600, 33585, 33576, 33603, 34388, 34442, 34474, + 34451, 34468, 34473, 34444, 34467, 34460, 34928, 34935, 34945, 34946, + 34941, 34937, 35352, 35344, 35342, 35340, 35349, 35338, 35351, 35347, + 35350, 35343, 35345, 35912, 35962, 35961, 36001, 36002, 36215, 36524, + 36562, 36564, 36559, 36785, 36865, 36870, 36855, 36864, 36858, 36852, + 36867, 36861, 36869, 36856, 37013, 37089, 37085, 37090, 37202, 37197, + 37196, 37336, 37341, 37335, 37340, 37337, 38275, 38498, 38499, 38497, + 38491, 38493, 38500, 38488, 38494, 38587, 39138, 39340, 39592, 39640, + 39717, 39730, 39740, 20094, 20602, 20605, 20572, 20551, 20547, 20556, + 20570, 20553, 20581, 20598, 20558, 20565, 20597, 20596, 20599, 20559, + 20495, 20591, 20589, 20828, 20885, 20976, 21098, 21103, 21202, 21209, + 21208, 21205, 21264, 21263, 21273, 21311, 21312, 21310, 21443, 26364, + 21830, 21866, 21862, 21828, 21854, 21857, 21827, 21834, 21809, 21846, + 21839, 21845, 21807, 21860, 21816, 21806, 21852, 21804, 21859, 21811, + 21825, 21847, 22280, 22283, 22281, 22495, 22533, 22538, 22534, 22496, + 22500, 22522, 22530, 22581, 22519, 22521, 22816, 22882, 23094, 23105, + 23113, 23142, 23146, 23104, 23100, 23138, 23130, 23110, 23114, 23408, + 23495, 23493, 23492, 23490, 23487, 23494, 23561, 23560, 23559, 23648, + 23644, 23645, 23815, 23814, 23822, 23835, 23830, 23842, 23825, 23849, + 23828, 23833, 23844, 23847, 23831, 24034, 24120, 24118, 24115, 24119, + 24247, 24248, 24246, 24245, 24254, 24373, 24375, 24407, 24428, 24425, + 24427, 24471, 24473, 24478, 24472, 24481, 24480, 24476, 24703, 24739, + 24713, 24736, 24744, 24779, 24756, 24806, 24765, 24773, 24763, 24757, + 24796, 24764, 24792, 24789, 24774, 24799, 24760, 24794, 24775, 25114, + 25115, 25160, 25504, 25511, 25458, 25494, 25506, 25509, 25463, 25447, + 25496, 25514, 25457, 25513, 25481, 25475, 25499, 25451, 25512, 25476, + 25480, 25497, 25505, 25516, 25490, 25487, 25472, 25467, 25449, 25448, + 25466, 25949, 25942, 25937, 25945, 25943, 21855, 25935, 25944, 25941, + 25940, 26012, 26011, 26028, 26063, 26059, 26060, 26062, 26205, 26202, + 26212, 26216, 26214, 26206, 26361, 21207, 26395, 26753, 26799, 26786, + 26771, 26805, 26751, 26742, 26801, 26791, 26775, 26800, 26755, 26820, + 26797, 26758, 26757, 26772, 26781, 26792, 26783, 26785, 26754, 27442, + 27578, 27627, 27628, 27691, 28046, 28092, 28147, 28121, 28082, 28129, + 28108, 28132, 28155, 28154, 28165, 28103, 28107, 28079, 28113, 28078, + 28126, 28153, 28088, 28151, 28149, 28101, 28114, 28186, 28085, 28122, + 28139, 28120, 28138, 28145, 28142, 28136, 28102, 28100, 28074, 28140, + 28095, 28134, 28921, 28937, 28938, 28925, 28911, 29245, 29309, 29313, + 29468, 29467, 29462, 29459, 29465, 29575, 29701, 29706, 29699, 29702, + 29694, 29709, 29920, 29942, 29943, 29980, 29986, 30053, 30054, 30050, + 30064, 30095, 30164, 30165, 30133, 30154, 30157, 30350, 30420, 30418, + 30427, 30519, 30526, 30524, 30518, 30520, 30522, 30827, 30787, 30798, + 31077, 31080, 31085, 31227, 31378, 31381, 31520, 31528, 31515, 31532, + 31526, 31513, 31518, 31534, 31890, 31895, 31893, 32070, 32067, 32113, + 32046, 32057, 32060, 32064, 32048, 32051, 32068, 32047, 32066, 32050, + 32049, 32573, 32670, 32666, 32716, 32718, 32722, 32796, 32842, 32838, + 33071, 33046, 33059, 33067, 33065, 33072, 33060, 33282, 33333, 33335, + 33334, 33337, 33678, 33694, 33688, 33656, 33698, 33686, 33725, 33707, + 33682, 33674, 33683, 33673, 33696, 33655, 33659, 33660, 33670, 33703, + 34389, 24426, 34503, 34496, 34486, 34500, 34485, 34502, 34507, 34481, + 34479, 34505, 34899, 34974, 34952, 34987, 34962, 34966, 34957, 34955, + 35219, 35215, 35370, 35357, 35363, 35365, 35377, 35373, 35359, 35355, + 35362, 35913, 35930, 36009, 36012, 36011, 36008, 36010, 36007, 36199, + 36198, 36286, 36282, 36571, 36575, 36889, 36877, 36890, 36887, 36899, + 36895, 36893, 36880, 36885, 36894, 36896, 36879, 36898, 36886, 36891, + 36884, 37096, 37101, 37117, 37207, 37326, 37365, 37350, 37347, 37351, + 37357, 37353, 38281, 38506, 38517, 38515, 38520, 38512, 38516, 38518, + 38519, 38508, 38592, 38634, 38633, 31456, 31455, 38914, 38915, 39770, + 40165, 40565, 40575, 40613, 40635, 20642, 20621, 20613, 20633, 20625, + 20608, 20630, 20632, 20634, 26368, 20977, 21106, 21108, 21109, 21097, + 21214, 21213, 21211, 21338, 21413, 21883, 21888, 21927, 21884, 21898, + 21917, 21912, 21890, 21916, 21930, 21908, 21895, 21899, 21891, 21939, + 21934, 21919, 21822, 21938, 21914, 21947, 21932, 21937, 21886, 21897, + 21931, 21913, 22285, 22575, 22570, 22580, 22564, 22576, 22577, 22561, + 22557, 22560, 22777, 22778, 22880, 23159, 23194, 23167, 23186, 23195, + 23207, 23411, 23409, 23506, 23500, 23507, 23504, 23562, 23563, 23601, + 23884, 23888, 23860, 23879, 24061, 24133, 24125, 24128, 24131, 24190, + 24266, 24257, 24258, 24260, 24380, 24429, 24489, 24490, 24488, 24785, + 24801, 24754, 24758, 24800, 24860, 24867, 24826, 24853, 24816, 24827, + 24820, 24936, 24817, 24846, 24822, 24841, 24832, 24850, 25119, 25161, + 25507, 25484, 25551, 25536, 25577, 25545, 25542, 25549, 25554, 25571, + 25552, 25569, 25558, 25581, 25582, 25462, 25588, 25578, 25563, 25682, + 25562, 25593, 25950, 25958, 25954, 25955, 26001, 26000, 26031, 26222, + 26224, 26228, 26230, 26223, 26257, 26234, 26238, 26231, 26366, 26367, + 26399, 26397, 26874, 26837, 26848, 26840, 26839, 26885, 26847, 26869, + 26862, 26855, 26873, 26834, 26866, 26851, 26827, 26829, 26893, 26898, + 26894, 26825, 26842, 26990, 26875, 27454, 27450, 27453, 27544, 27542, + 27580, 27631, 27694, 27695, 27692, 28207, 28216, 28244, 28193, 28210, + 28263, 28234, 28192, 28197, 28195, 28187, 28251, 28248, 28196, 28246, + 28270, 28205, 28198, 28271, 28212, 28237, 28218, 28204, 28227, 28189, + 28222, 28363, 28297, 28185, 28238, 28259, 28228, 28274, 28265, 28255, + 28953, 28954, 28966, 28976, 28961, 28982, 29038, 28956, 29260, 29316, + 29312, 29494, 29477, 29492, 29481, 29754, 29738, 29747, 29730, 29733, + 29749, 29750, 29748, 29743, 29723, 29734, 29736, 29989, 29990, 30059, + 30058, 30178, 30171, 30179, 30169, 30168, 30174, 30176, 30331, 30332, + 30358, 30355, 30388, 30428, 30543, 30701, 30813, 30828, 30831, 31245, + 31240, 31243, 31237, 31232, 31384, 31383, 31382, 31461, 31459, 31561, + 31574, 31558, 31568, 31570, 31572, 31565, 31563, 31567, 31569, 31903, + 31909, 32094, 32080, 32104, 32085, 32043, 32110, 32114, 32097, 32102, + 32098, 32112, 32115, 21892, 32724, 32725, 32779, 32850, 32901, 33109, + 33108, 33099, 33105, 33102, 33081, 33094, 33086, 33100, 33107, 33140, + 33298, 33308, 33769, 33795, 33784, 33805, 33760, 33733, 33803, 33729, + 33775, 33777, 33780, 33879, 33802, 33776, 33804, 33740, 33789, 33778, + 33738, 33848, 33806, 33796, 33756, 33799, 33748, 33759, 34395, 34527, + 34521, 34541, 34516, 34523, 34532, 34512, 34526, 34903, 35009, 35010, + 34993, 35203, 35222, 35387, 35424, 35413, 35422, 35388, 35393, 35412, + 35419, 35408, 35398, 35380, 35386, 35382, 35414, 35937, 35970, 36015, + 36028, 36019, 36029, 36033, 36027, 36032, 36020, 36023, 36022, 36031, + 36024, 36234, 36229, 36225, 36302, 36317, 36299, 36314, 36305, 36300, + 36315, 36294, 36603, 36600, 36604, 36764, 36910, 36917, 36913, 36920, + 36914, 36918, 37122, 37109, 37129, 37118, 37219, 37221, 37327, 37396, + 37397, 37411, 37385, 37406, 37389, 37392, 37383, 37393, 38292, 38287, + 38283, 38289, 38291, 38290, 38286, 38538, 38542, 38539, 38525, 38533, + 38534, 38541, 38514, 38532, 38593, 38597, 38596, 38598, 38599, 38639, + 38642, 38860, 38917, 38918, 38920, 39143, 39146, 39151, 39145, 39154, + 39149, 39342, 39341, 40643, 40653, 40657, 20098, 20653, 20661, 20658, + 20659, 20677, 20670, 20652, 20663, 20667, 20655, 20679, 21119, 21111, + 21117, 21215, 21222, 21220, 21218, 21219, 21295, 21983, 21992, 21971, + 21990, 21966, 21980, 21959, 21969, 21987, 21988, 21999, 21978, 21985, + 21957, 21958, 21989, 21961, 22290, 22291, 22622, 22609, 22616, 22615, + 22618, 22612, 22635, 22604, 22637, 22602, 22626, 22610, 22603, 22887, + 23233, 23241, 23244, 23230, 23229, 23228, 23219, 23234, 23218, 23913, + 23919, 24140, 24185, 24265, 24264, 24338, 24409, 24492, 24494, 24858, + 24847, 24904, 24863, 24819, 24859, 24825, 24833, 24840, 24910, 24908, + 24900, 24909, 24894, 24884, 24871, 24845, 24838, 24887, 25121, 25122, + 25619, 25662, 25630, 25642, 25645, 25661, 25644, 25615, 25628, 25620, + 25613, 25654, 25622, 25623, 25606, 25964, 26015, 26032, 26263, 26249, + 26247, 26248, 26262, 26244, 26264, 26253, 26371, 27028, 26989, 26970, + 26999, 26976, 26964, 26997, 26928, 27010, 26954, 26984, 26987, 26974, + 26963, 27001, 27014, 26973, 26979, 26971, 27463, 27506, 27584, 27583, + 27603, 27645, 28322, 28335, 28371, 28342, 28354, 28304, 28317, 28359, + 28357, 28325, 28312, 28348, 28346, 28331, 28369, 28310, 28316, 28356, + 28372, 28330, 28327, 28340, 29006, 29017, 29033, 29028, 29001, 29031, + 29020, 29036, 29030, 29004, 29029, 29022, 28998, 29032, 29014, 29242, + 29266, 29495, 29509, 29503, 29502, 29807, 29786, 29781, 29791, 29790, + 29761, 29759, 29785, 29787, 29788, 30070, 30072, 30208, 30192, 30209, + 30194, 30193, 30202, 30207, 30196, 30195, 30430, 30431, 30555, 30571, + 30566, 30558, 30563, 30585, 30570, 30572, 30556, 30565, 30568, 30562, + 30702, 30862, 30896, 30871, 30872, 30860, 30857, 30844, 30865, 30867, + 30847, 31098, 31103, 31105, 33836, 31165, 31260, 31258, 31264, 31252, + 31263, 31262, 31391, 31392, 31607, 31680, 31584, 31598, 31591, 31921, + 31923, 31925, 32147, 32121, 32145, 32129, 32143, 32091, 32622, 32617, + 32618, 32626, 32681, 32680, 32676, 32854, 32856, 32902, 32900, 33137, + 33136, 33144, 33125, 33134, 33139, 33131, 33145, 33146, 33126, 33285, + 33351, 33922, 33911, 33853, 33841, 33909, 33894, 33899, 33865, 33900, + 33883, 33852, 33845, 33889, 33891, 33897, 33901, 33862, 34398, 34396, + 34399, 34553, 34579, 34568, 34567, 34560, 34558, 34555, 34562, 34563, + 34566, 34570, 34905, 35039, 35028, 35033, 35036, 35032, 35037, 35041, + 35018, 35029, 35026, 35228, 35299, 35435, 35442, 35443, 35430, 35433, + 35440, 35463, 35452, 35427, 35488, 35441, 35461, 35437, 35426, 35438, + 35436, 35449, 35451, 35390, 35432, 35938, 35978, 35977, 36042, 36039, + 36040, 36036, 36018, 36035, 36034, 36037, 36321, 36319, 36328, 36335, + 36339, 36346, 36330, 36324, 36326, 36530, 36611, 36617, 36606, 36618, + 36767, 36786, 36939, 36938, 36947, 36930, 36948, 36924, 36949, 36944, + 36935, 36943, 36942, 36941, 36945, 36926, 36929, 37138, 37143, 37228, + 37226, 37225, 37321, 37431, 37463, 37432, 37437, 37440, 37438, 37467, + 37451, 37476, 37457, 37428, 37449, 37453, 37445, 37433, 37439, 37466, + 38296, 38552, 38548, 38549, 38605, 38603, 38601, 38602, 38647, 38651, + 38649, 38646, 38742, 38772, 38774, 38928, 38929, 38931, 38922, 38930, + 38924, 39164, 39156, 39165, 39166, 39347, 39345, 39348, 39649, 40169, + 40578, 40718, 40723, 40736, 20711, 20718, 20709, 20694, 20717, 20698, + 20693, 20687, 20689, 20721, 20686, 20713, 20834, 20979, 21123, 21122, + 21297, 21421, 22014, 22016, 22043, 22039, 22013, 22036, 22022, 22025, + 22029, 22030, 22007, 22038, 22047, 22024, 22032, 22006, 22296, 22294, + 22645, 22654, 22659, 22675, 22666, 22649, 22661, 22653, 22781, 22821, + 22818, 22820, 22890, 22889, 23265, 23270, 23273, 23255, 23254, 23256, + 23267, 23413, 23518, 23527, 23521, 23525, 23526, 23528, 23522, 23524, + 23519, 23565, 23650, 23940, 23943, 24155, 24163, 24149, 24151, 24148, + 24275, 24278, 24330, 24390, 24432, 24505, 24903, 24895, 24907, 24951, + 24930, 24931, 24927, 24922, 24920, 24949, 25130, 25735, 25688, 25684, + 25764, 25720, 25695, 25722, 25681, 25703, 25652, 25709, 25723, 25970, + 26017, 26071, 26070, 26274, 26280, 26269, 27036, 27048, 27029, 27073, + 27054, 27091, 27083, 27035, 27063, 27067, 27051, 27060, 27088, 27085, + 27053, 27084, 27046, 27075, 27043, 27465, 27468, 27699, 28467, 28436, + 28414, 28435, 28404, 28457, 28478, 28448, 28460, 28431, 28418, 28450, + 28415, 28399, 28422, 28465, 28472, 28466, 28451, 28437, 28459, 28463, + 28552, 28458, 28396, 28417, 28402, 28364, 28407, 29076, 29081, 29053, + 29066, 29060, 29074, 29246, 29330, 29334, 29508, 29520, 29796, 29795, + 29802, 29808, 29805, 29956, 30097, 30247, 30221, 30219, 30217, 30227, + 30433, 30435, 30596, 30589, 30591, 30561, 30913, 30879, 30887, 30899, + 30889, 30883, 31118, 31119, 31117, 31278, 31281, 31402, 31401, 31469, + 31471, 31649, 31637, 31627, 31605, 31639, 31645, 31636, 31631, 31672, + 31623, 31620, 31929, 31933, 31934, 32187, 32176, 32156, 32189, 32190, + 32160, 32202, 32180, 32178, 32177, 32186, 32162, 32191, 32181, 32184, + 32173, 32210, 32199, 32172, 32624, 32736, 32737, 32735, 32862, 32858, + 32903, 33104, 33152, 33167, 33160, 33162, 33151, 33154, 33255, 33274, + 33287, 33300, 33310, 33355, 33993, 33983, 33990, 33988, 33945, 33950, + 33970, 33948, 33995, 33976, 33984, 34003, 33936, 33980, 34001, 33994, + 34623, 34588, 34619, 34594, 34597, 34612, 34584, 34645, 34615, 34601, + 35059, 35074, 35060, 35065, 35064, 35069, 35048, 35098, 35055, 35494, + 35468, 35486, 35491, 35469, 35489, 35475, 35492, 35498, 35493, 35496, + 35480, 35473, 35482, 35495, 35946, 35981, 35980, 36051, 36049, 36050, + 36203, 36249, 36245, 36348, 36628, 36626, 36629, 36627, 36771, 36960, + 36952, 36956, 36963, 36953, 36958, 36962, 36957, 36955, 37145, 37144, + 37150, 37237, 37240, 37239, 37236, 37496, 37504, 37509, 37528, 37526, + 37499, 37523, 37532, 37544, 37500, 37521, 38305, 38312, 38313, 38307, + 38309, 38308, 38553, 38556, 38555, 38604, 38610, 38656, 38780, 38789, + 38902, 38935, 38936, 39087, 39089, 39171, 39173, 39180, 39177, 39361, + 39599, 39600, 39654, 39745, 39746, 40180, 40182, 40179, 40636, 40763, + 40778, 20740, 20736, 20731, 20725, 20729, 20738, 20744, 20745, 20741, + 20956, 21127, 21128, 21129, 21133, 21130, 21232, 21426, 22062, 22075, + 22073, 22066, 22079, 22068, 22057, 22099, 22094, 22103, 22132, 22070, + 22063, 22064, 22656, 22687, 22686, 22707, 22684, 22702, 22697, 22694, + 22893, 23305, 23291, 23307, 23285, 23308, 23304, 23534, 23532, 23529, + 23531, 23652, 23653, 23965, 23956, 24162, 24159, 24161, 24290, 24282, + 24287, 24285, 24291, 24288, 24392, 24433, 24503, 24501, 24950, 24935, + 24942, 24925, 24917, 24962, 24956, 24944, 24939, 24958, 24999, 24976, + 25003, 24974, 25004, 24986, 24996, 24980, 25006, 25134, 25705, 25711, + 25721, 25758, 25778, 25736, 25744, 25776, 25765, 25747, 25749, 25769, + 25746, 25774, 25773, 25771, 25754, 25772, 25753, 25762, 25779, 25973, + 25975, 25976, 26286, 26283, 26292, 26289, 27171, 27167, 27112, 27137, + 27166, 27161, 27133, 27169, 27155, 27146, 27123, 27138, 27141, 27117, + 27153, 27472, 27470, 27556, 27589, 27590, 28479, 28540, 28548, 28497, + 28518, 28500, 28550, 28525, 28507, 28536, 28526, 28558, 28538, 28528, + 28516, 28567, 28504, 28373, 28527, 28512, 28511, 29087, 29100, 29105, + 29096, 29270, 29339, 29518, 29527, 29801, 29835, 29827, 29822, 29824, + 30079, 30240, 30249, 30239, 30244, 30246, 30241, 30242, 30362, 30394, + 30436, 30606, 30599, 30604, 30609, 30603, 30923, 30917, 30906, 30922, + 30910, 30933, 30908, 30928, 31295, 31292, 31296, 31293, 31287, 31291, + 31407, 31406, 31661, 31665, 31684, 31668, 31686, 31687, 31681, 31648, + 31692, 31946, 32224, 32244, 32239, 32251, 32216, 32236, 32221, 32232, + 32227, 32218, 32222, 32233, 32158, 32217, 32242, 32249, 32629, 32631, + 32687, 32745, 32806, 33179, 33180, 33181, 33184, 33178, 33176, 34071, + 34109, 34074, 34030, 34092, 34093, 34067, 34065, 34083, 34081, 34068, + 34028, 34085, 34047, 34054, 34690, 34676, 34678, 34656, 34662, 34680, + 34664, 34649, 34647, 34636, 34643, 34907, 34909, 35088, 35079, 35090, + 35091, 35093, 35082, 35516, 35538, 35527, 35524, 35477, 35531, 35576, + 35506, 35529, 35522, 35519, 35504, 35542, 35533, 35510, 35513, 35547, + 35916, 35918, 35948, 36064, 36062, 36070, 36068, 36076, 36077, 36066, + 36067, 36060, 36074, 36065, 36205, 36255, 36259, 36395, 36368, 36381, + 36386, 36367, 36393, 36383, 36385, 36382, 36538, 36637, 36635, 36639, + 36649, 36646, 36650, 36636, 36638, 36645, 36969, 36974, 36968, 36973, + 36983, 37168, 37165, 37159, 37169, 37255, 37257, 37259, 37251, 37573, + 37563, 37559, 37610, 37548, 37604, 37569, 37555, 37564, 37586, 37575, + 37616, 37554, 38317, 38321, 38660, 38662, 38663, 38665, 38752, 38797, + 38795, 38799, 38945, 38955, 38940, 39091, 39178, 39187, 39186, 39192, + 39389, 39376, 39391, 39387, 39377, 39381, 39378, 39385, 39607, 39662, + 39663, 39719, 39749, 39748, 39799, 39791, 40198, 40201, 40195, 40617, + 40638, 40654, 22696, 40786, 20754, 20760, 20756, 20752, 20757, 20864, + 20906, 20957, 21137, 21139, 21235, 22105, 22123, 22137, 22121, 22116, + 22136, 22122, 22120, 22117, 22129, 22127, 22124, 22114, 22134, 22721, + 22718, 22727, 22725, 22894, 23325, 23348, 23416, 23536, 23566, 24394, + 25010, 24977, 25001, 24970, 25037, 25014, 25022, 25034, 25032, 25136, + 25797, 25793, 25803, 25787, 25788, 25818, 25796, 25799, 25794, 25805, + 25791, 25810, 25812, 25790, 25972, 26310, 26313, 26297, 26308, 26311, + 26296, 27197, 27192, 27194, 27225, 27243, 27224, 27193, 27204, 27234, + 27233, 27211, 27207, 27189, 27231, 27208, 27481, 27511, 27653, 28610, + 28593, 28577, 28611, 28580, 28609, 28583, 28595, 28608, 28601, 28598, + 28582, 28576, 28596, 29118, 29129, 29136, 29138, 29128, 29141, 29113, + 29134, 29145, 29148, 29123, 29124, 29544, 29852, 29859, 29848, 29855, + 29854, 29922, 29964, 29965, 30260, 30264, 30266, 30439, 30437, 30624, + 30622, 30623, 30629, 30952, 30938, 30956, 30951, 31142, 31309, 31310, + 31302, 31308, 31307, 31418, 31705, 31761, 31689, 31716, 31707, 31713, + 31721, 31718, 31957, 31958, 32266, 32273, 32264, 32283, 32291, 32286, + 32285, 32265, 32272, 32633, 32690, 32752, 32753, 32750, 32808, 33203, + 33193, 33192, 33275, 33288, 33368, 33369, 34122, 34137, 34120, 34152, + 34153, 34115, 34121, 34157, 34154, 34142, 34691, 34719, 34718, 34722, + 34701, 34913, 35114, 35122, 35109, 35115, 35105, 35242, 35238, 35558, + 35578, 35563, 35569, 35584, 35548, 35559, 35566, 35582, 35585, 35586, + 35575, 35565, 35571, 35574, 35580, 35947, 35949, 35987, 36084, 36420, + 36401, 36404, 36418, 36409, 36405, 36667, 36655, 36664, 36659, 36776, + 36774, 36981, 36980, 36984, 36978, 36988, 36986, 37172, 37266, 37664, + 37686, 37624, 37683, 37679, 37666, 37628, 37675, 37636, 37658, 37648, + 37670, 37665, 37653, 37678, 37657, 38331, 38567, 38568, 38570, 38613, + 38670, 38673, 38678, 38669, 38675, 38671, 38747, 38748, 38758, 38808, + 38960, 38968, 38971, 38967, 38957, 38969, 38948, 39184, 39208, 39198, + 39195, 39201, 39194, 39405, 39394, 39409, 39608, 39612, 39675, 39661, + 39720, 39825, 40213, 40227, 40230, 40232, 40210, 40219, 40664, 40660, + 40845, 40860, 20778, 20767, 20769, 20786, 21237, 22158, 22144, 22160, + 22149, 22151, 22159, 22741, 22739, 22737, 22734, 23344, 23338, 23332, + 23418, 23607, 23656, 23996, 23994, 23997, 23992, 24171, 24396, 24509, + 25033, 25026, 25031, 25062, 25035, 25138, 25140, 25806, 25802, 25816, + 25824, 25840, 25830, 25836, 25841, 25826, 25837, 25986, 25987, 26329, + 26326, 27264, 27284, 27268, 27298, 27292, 27355, 27299, 27262, 27287, + 27280, 27296, 27484, 27566, 27610, 27656, 28632, 28657, 28639, 28640, + 28635, 28644, 28651, 28655, 28544, 28652, 28641, 28649, 28629, 28654, + 28656, 29159, 29151, 29166, 29158, 29157, 29165, 29164, 29172, 29152, + 29237, 29254, 29552, 29554, 29865, 29872, 29862, 29864, 30278, 30274, + 30284, 30442, 30643, 30634, 30640, 30636, 30631, 30637, 30703, 30967, + 30970, 30964, 30959, 30977, 31143, 31146, 31319, 31423, 31751, 31757, + 31742, 31735, 31756, 31712, 31968, 31964, 31966, 31970, 31967, 31961, + 31965, 32302, 32318, 32326, 32311, 32306, 32323, 32299, 32317, 32305, + 32325, 32321, 32308, 32313, 32328, 32309, 32319, 32303, 32580, 32755, + 32764, 32881, 32882, 32880, 32879, 32883, 33222, 33219, 33210, 33218, + 33216, 33215, 33213, 33225, 33214, 33256, 33289, 33393, 34218, 34180, + 34174, 34204, 34193, 34196, 34223, 34203, 34183, 34216, 34186, 34407, + 34752, 34769, 34739, 34770, 34758, 34731, 34747, 34746, 34760, 34763, + 35131, 35126, 35140, 35128, 35133, 35244, 35598, 35607, 35609, 35611, + 35594, 35616, 35613, 35588, 35600, 35905, 35903, 35955, 36090, 36093, + 36092, 36088, 36091, 36264, 36425, 36427, 36424, 36426, 36676, 36670, + 36674, 36677, 36671, 36991, 36989, 36996, 36993, 36994, 36992, 37177, + 37283, 37278, 37276, 37709, 37762, 37672, 37749, 37706, 37733, 37707, + 37656, 37758, 37740, 37723, 37744, 37722, 37716, 38346, 38347, 38348, + 38344, 38342, 38577, 38584, 38614, 38684, 38686, 38816, 38867, 38982, + 39094, 39221, 39425, 39423, 39854, 39851, 39850, 39853, 40251, 40255, + 40587, 40655, 40670, 40668, 40669, 40667, 40766, 40779, 21474, 22165, + 22190, 22745, 22744, 23352, 24413, 25059, 25139, 25844, 25842, 25854, + 25862, 25850, 25851, 25847, 26039, 26332, 26406, 27315, 27308, 27331, + 27323, 27320, 27330, 27310, 27311, 27487, 27512, 27567, 28681, 28683, + 28670, 28678, 28666, 28689, 28687, 29179, 29180, 29182, 29176, 29559, + 29557, 29863, 29887, 29973, 30294, 30296, 30290, 30653, 30655, 30651, + 30652, 30990, 31150, 31329, 31330, 31328, 31428, 31429, 31787, 31783, + 31786, 31774, 31779, 31777, 31975, 32340, 32341, 32350, 32346, 32353, + 32338, 32345, 32584, 32761, 32763, 32887, 32886, 33229, 33231, 33290, + 34255, 34217, 34253, 34256, 34249, 34224, 34234, 34233, 34214, 34799, + 34796, 34802, 34784, 35206, 35250, 35316, 35624, 35641, 35628, 35627, + 35920, 36101, 36441, 36451, 36454, 36452, 36447, 36437, 36544, 36681, + 36685, 36999, 36995, 37000, 37291, 37292, 37328, 37780, 37770, 37782, + 37794, 37811, 37806, 37804, 37808, 37784, 37786, 37783, 38356, 38358, + 38352, 38357, 38626, 38620, 38617, 38619, 38622, 38692, 38819, 38822, + 38829, 38905, 38989, 38991, 38988, 38990, 38995, 39098, 39230, 39231, + 39229, 39214, 39333, 39438, 39617, 39683, 39686, 39759, 39758, 39757, + 39882, 39881, 39933, 39880, 39872, 40273, 40285, 40288, 40672, 40725, + 40748, 20787, 22181, 22750, 22751, 22754, 23541, 40848, 24300, 25074, + 25079, 25078, 25077, 25856, 25871, 26336, 26333, 27365, 27357, 27354, + 27347, 28699, 28703, 28712, 28698, 28701, 28693, 28696, 29190, 29197, + 29272, 29346, 29560, 29562, 29885, 29898, 29923, 30087, 30086, 30303, + 30305, 30663, 31001, 31153, 31339, 31337, 31806, 31807, 31800, 31805, + 31799, 31808, 32363, 32365, 32377, 32361, 32362, 32645, 32371, 32694, + 32697, 32696, 33240, 34281, 34269, 34282, 34261, 34276, 34277, 34295, + 34811, 34821, 34829, 34809, 34814, 35168, 35167, 35158, 35166, 35649, + 35676, 35672, 35657, 35674, 35662, 35663, 35654, 35673, 36104, 36106, + 36476, 36466, 36487, 36470, 36460, 36474, 36468, 36692, 36686, 36781, + 37002, 37003, 37297, 37294, 37857, 37841, 37855, 37827, 37832, 37852, + 37853, 37846, 37858, 37837, 37848, 37860, 37847, 37864, 38364, 38580, + 38627, 38698, 38695, 38753, 38876, 38907, 39006, 39000, 39003, 39100, + 39237, 39241, 39446, 39449, 39693, 39912, 39911, 39894, 39899, 40329, + 40289, 40306, 40298, 40300, 40594, 40599, 40595, 40628, 21240, 22184, + 22199, 22198, 22196, 22204, 22756, 23360, 23363, 23421, 23542, 24009, + 25080, 25082, 25880, 25876, 25881, 26342, 26407, 27372, 28734, 28720, + 28722, 29200, 29563, 29903, 30306, 30309, 31014, 31018, 31020, 31019, + 31431, 31478, 31820, 31811, 31821, 31983, 31984, 36782, 32381, 32380, + 32386, 32588, 32768, 33242, 33382, 34299, 34297, 34321, 34298, 34310, + 34315, 34311, 34314, 34836, 34837, 35172, 35258, 35320, 35696, 35692, + 35686, 35695, 35679, 35691, 36111, 36109, 36489, 36481, 36485, 36482, + 37300, 37323, 37912, 37891, 37885, 38369, 38704, 39108, 39250, 39249, + 39336, 39467, 39472, 39479, 39477, 39955, 39949, 40569, 40629, 40680, + 40751, 40799, 40803, 40801, 20791, 20792, 22209, 22208, 22210, 22804, + 23660, 24013, 25084, 25086, 25885, 25884, 26005, 26345, 27387, 27396, + 27386, 27570, 28748, 29211, 29351, 29910, 29908, 30313, 30675, 31824, + 32399, 32396, 32700, 34327, 34349, 34330, 34851, 34850, 34849, 34847, + 35178, 35180, 35261, 35700, 35703, 35709, 36115, 36490, 36493, 36491, + 36703, 36783, 37306, 37934, 37939, 37941, 37946, 37944, 37938, 37931, + 38370, 38712, 38713, 38706, 38911, 39015, 39013, 39255, 39493, 39491, + 39488, 39486, 39631, 39764, 39761, 39981, 39973, 40367, 40372, 40386, + 40376, 40605, 40687, 40729, 40796, 40806, 40807, 20796, 20795, 22216, + 22218, 22217, 23423, 24020, 24018, 24398, 25087, 25892, 27402, 27489, + 28753, 28760, 29568, 29924, 30090, 30318, 30316, 31155, 31840, 31839, + 32894, 32893, 33247, 35186, 35183, 35324, 35712, 36118, 36119, 36497, + 36499, 36705, 37192, 37956, 37969, 37970, 38717, 38718, 38851, 38849, + 39019, 39253, 39509, 39501, 39634, 39706, 40009, 39985, 39998, 39995, + 40403, 40407, 40756, 40812, 40810, 40852, 22220, 24022, 25088, 25891, + 25899, 25898, 26348, 27408, 29914, 31434, 31844, 31843, 31845, 32403, + 32406, 32404, 33250, 34360, 34367, 34865, 35722, 37008, 37007, 37987, + 37984, 37988, 38760, 39023, 39260, 39514, 39515, 39511, 39635, 39636, + 39633, 40020, 40023, 40022, 40421, 40607, 40692, 22225, 22761, 25900, + 28766, 30321, 30322, 30679, 32592, 32648, 34870, 34873, 34914, 35731, + 35730, 35734, 33399, 36123, 37312, 37994, 38722, 38728, 38724, 38854, + 39024, 39519, 39714, 39768, 40031, 40441, 40442, 40572, 40573, 40711, + 40823, 40818, 24307, 27414, 28771, 31852, 31854, 34875, 35264, 36513, + 37313, 38002, 38000, 39025, 39262, 39638, 39715, 40652, 28772, 30682, + 35738, 38007, 38857, 39522, 39525, 32412, 35740, 36522, 37317, 38013, + 38014, 38012, 40055, 40056, 40695, 35924, 38015, 40474, 29224, 39530, + 39729, 40475, 40478, 31858, 9312, 9313, 9314, 9315, 9316, 9317, 9318, 9319, + 9320, 9321, 9332, 9333, 9334, 9335, 9336, 9337, 9338, 9339, 9340, 9341, + 8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 20022, 20031, + 20101, 20128, 20866, 20886, 20907, 21241, 21304, 21353, 21430, 22794, + 23424, 24027, 12083, 24191, 24308, 24400, 24417, 25908, 26080, 30098, + 30326, 36789, 38582, 168, 710, 12541, 12542, 12445, 12446, 12291, 20189, + 12293, 12294, 12295, 12540, 65339, 65341, 10045, 12353, 12354, 12355, + 12356, 12357, 12358, 12359, 12360, 12361, 12362, 12363, 12364, 12365, + 12366, 12367, 12368, 12369, 12370, 12371, 12372, 12373, 12374, 12375, + 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, 12384, 12385, + 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, + 12396, 12397, 12398, 12399, 12400, 12401, 12402, 12403, 12404, 12405, + 12406, 12407, 12408, 12409, 12410, 12411, 12412, 12413, 12414, 12415, + 12416, 12417, 12418, 12419, 12420, 12421, 12422, 12423, 12424, 12425, + 12426, 12427, 12428, 12429, 12430, 12431, 12432, 12433, 12434, 12435, + 12449, 12450, 12451, 12452, 12453, 12454, 12455, 12456, 12457, 12458, + 12459, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, + 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, + 12479, 12480, 12481, 12482, 12483, 12484, 12485, 12486, 12487, 12488, + 12489, 12490, 12491, 12492, 12493, 12494, 12495, 12496, 12497, 12498, + 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, + 12509, 12510, 12511, 12512, 12513, 12514, 12515, 12516, 12517, 12518, + 12519, 12520, 12521, 12522, 12523, 12524, 12525, 12526, 12527, 12528, + 12529, 12530, 12531, 12532, 12533, 12534, 1040, 1041, 1042, 1043, 1044, + 1045, 1025, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, + 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, + 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1105, 1078, + 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, + 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, + 1103, 8679, 8632, 8633, 12751, 204, 20058, 138, 20994, 17553, 40880, 20872, + 40881, 30215, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65506, 65508, 65287, 65282, 12849, 8470, 8481, 12443, 12444, + 11904, 11908, 11910, 11911, 11912, 11914, 11916, 11917, 11925, 11932, + 11933, 11941, 11943, 11946, 11948, 11950, 11958, 11964, 11966, 11974, + 11978, 11980, 11981, 11983, 11990, 11991, 11998, 12003, 65535, 65535, + 65535, 643, 592, 603, 596, 629, 339, 248, 331, 650, 618, 20034, 20060, + 20981, 21274, 21378, 19975, 19980, 20039, 20109, 22231, 64012, 23662, + 24435, 19983, 20871, 19982, 20014, 20115, 20162, 20169, 20168, 20888, + 21244, 21356, 21433, 22304, 22787, 22828, 23568, 24063, 26081, 27571, + 27596, 27668, 29247, 20017, 20028, 20200, 20188, 20201, 20193, 20189, + 20186, 21004, 21276, 21324, 22306, 22307, 22807, 22831, 23425, 23428, + 23570, 23611, 23668, 23667, 24068, 24192, 24194, 24521, 25097, 25168, + 27669, 27702, 27715, 27711, 27707, 29358, 29360, 29578, 31160, 32906, + 38430, 20238, 20248, 20268, 20213, 20244, 20209, 20224, 20215, 20232, + 20253, 20226, 20229, 20258, 20243, 20228, 20212, 20242, 20913, 21011, + 21001, 21008, 21158, 21282, 21279, 21325, 21386, 21511, 22241, 22239, + 22318, 22314, 22324, 22844, 22912, 22908, 22917, 22907, 22910, 22903, + 22911, 23382, 23573, 23589, 23676, 23674, 23675, 23678, 24031, 24181, + 24196, 24322, 24346, 24436, 24533, 24532, 24527, 25180, 25182, 25188, + 25185, 25190, 25186, 25177, 25184, 25178, 25189, 26095, 26094, 26430, + 26425, 26424, 26427, 26426, 26431, 26428, 26419, 27672, 27718, 27730, + 27740, 27727, 27722, 27732, 27723, 27724, 28785, 29278, 29364, 29365, + 29582, 29994, 30335, 31349, 32593, 33400, 33404, 33408, 33405, 33407, + 34381, 35198, 37017, 37015, 37016, 37019, 37012, 38434, 38436, 38432, + 38435, 20310, 20283, 20322, 20297, 20307, 20324, 20286, 20327, 20306, + 20319, 20289, 20312, 20269, 20275, 20287, 20321, 20879, 20921, 21020, + 21022, 21025, 21165, 21166, 21257, 21347, 21362, 21390, 21391, 21552, + 21559, 21546, 21588, 21573, 21529, 21532, 21541, 21528, 21565, 21583, + 21569, 21544, 21540, 21575, 22254, 22247, 22245, 22337, 22341, 22348, + 22345, 22347, 22354, 22790, 22848, 22950, 22936, 22944, 22935, 22926, + 22946, 22928, 22927, 22951, 22945, 23438, 23442, 23592, 23594, 23693, + 23695, 23688, 23691, 23689, 23698, 23690, 23686, 23699, 23701, 24032, + 24074, 24078, 24203, 24201, 24204, 24200, 24205, 24325, 24349, 24440, + 24438, 24530, 24529, 24528, 24557, 24552, 24558, 24563, 24545, 24548, + 24547, 24570, 24559, 24567, 24571, 24576, 24564, 25146, 25219, 25228, + 25230, 25231, 25236, 25223, 25201, 25211, 25210, 25200, 25217, 25224, + 25207, 25213, 25202, 25204, 25911, 26096, 26100, 26099, 26098, 26101, + 26437, 26439, 26457, 26453, 26444, 26440, 26461, 26445, 26458, 26443, + 27600, 27673, 27674, 27768, 27751, 27755, 27780, 27787, 27791, 27761, + 27759, 27753, 27802, 27757, 27783, 27797, 27804, 27750, 27763, 27749, + 27771, 27790, 28788, 28794, 29283, 29375, 29373, 29379, 29382, 29377, + 29370, 29381, 29589, 29591, 29587, 29588, 29586, 30010, 30009, 30100, + 30101, 30337, 31037, 32820, 32917, 32921, 32912, 32914, 32924, 33424, + 33423, 33413, 33422, 33425, 33427, 33418, 33411, 33412, 35960, 36809, + 36799, 37023, 37025, 37029, 37022, 37031, 37024, 38448, 38440, 38447, + 38445, 20019, 20376, 20348, 20357, 20349, 20352, 20359, 20342, 20340, + 20361, 20356, 20343, 20300, 20375, 20330, 20378, 20345, 20353, 20344, + 20368, 20380, 20372, 20382, 20370, 20354, 20373, 20331, 20334, 20894, + 20924, 20926, 21045, 21042, 21043, 21062, 21041, 21180, 21258, 21259, + 21308, 21394, 21396, 21639, 21631, 21633, 21649, 21634, 21640, 21611, + 21626, 21630, 21605, 21612, 21620, 21606, 21645, 21615, 21601, 21600, + 21656, 21603, 21607, 21604, 22263, 22265, 22383, 22386, 22381, 22379, + 22385, 22384, 22390, 22400, 22389, 22395, 22387, 22388, 22370, 22376, + 22397, 22796, 22853, 22965, 22970, 22991, 22990, 22962, 22988, 22977, + 22966, 22972, 22979, 22998, 22961, 22973, 22976, 22984, 22964, 22983, + 23394, 23397, 23443, 23445, 23620, 23623, 23726, 23716, 23712, 23733, + 23727, 23720, 23724, 23711, 23715, 23725, 23714, 23722, 23719, 23709, + 23717, 23734, 23728, 23718, 24087, 24084, 24089, 24360, 24354, 24355, + 24356, 24404, 24450, 24446, 24445, 24542, 24549, 24621, 24614, 24601, + 24626, 24587, 24628, 24586, 24599, 24627, 24602, 24606, 24620, 24610, + 24589, 24592, 24622, 24595, 24593, 24588, 24585, 24604, 25108, 25149, + 25261, 25268, 25297, 25278, 25258, 25270, 25290, 25262, 25267, 25263, + 25275, 25257, 25264, 25272, 25917, 26024, 26043, 26121, 26108, 26116, + 26130, 26120, 26107, 26115, 26123, 26125, 26117, 26109, 26129, 26128, + 26358, 26378, 26501, 26476, 26510, 26514, 26486, 26491, 26520, 26502, + 26500, 26484, 26509, 26508, 26490, 26527, 26513, 26521, 26499, 26493, + 26497, 26488, 26489, 26516, 27429, 27520, 27518, 27614, 27677, 27795, + 27884, 27883, 27886, 27865, 27830, 27860, 27821, 27879, 27831, 27856, + 27842, 27834, 27843, 27846, 27885, 27890, 27858, 27869, 27828, 27786, + 27805, 27776, 27870, 27840, 27952, 27853, 27847, 27824, 27897, 27855, + 27881, 27857, 28820, 28824, 28805, 28819, 28806, 28804, 28817, 28822, + 28802, 28826, 28803, 29290, 29398, 29387, 29400, 29385, 29404, 29394, + 29396, 29402, 29388, 29393, 29604, 29601, 29613, 29606, 29602, 29600, + 29612, 29597, 29917, 29928, 30015, 30016, 30014, 30092, 30104, 30383, + 30451, 30449, 30448, 30453, 30712, 30716, 30713, 30715, 30714, 30711, + 31042, 31039, 31173, 31352, 31355, 31483, 31861, 31997, 32821, 32911, + 32942, 32931, 32952, 32949, 32941, 33312, 33440, 33472, 33451, 33434, + 33432, 33435, 33461, 33447, 33454, 33468, 33438, 33466, 33460, 33448, + 33441, 33449, 33474, 33444, 33475, 33462, 33442, 34416, 34415, 34413, + 34414, 35926, 36818, 36811, 36819, 36813, 36822, 36821, 36823, 37042, + 37044, 37039, 37043, 37040, 38457, 38461, 38460, 38458, 38467, 20429, + 20421, 20435, 20402, 20425, 20427, 20417, 20436, 20444, 20441, 20411, + 20403, 20443, 20423, 20438, 20410, 20416, 20409, 20460, 21060, 21065, + 21184, 21186, 21309, 21372, 21399, 21398, 21401, 21400, 21690, 21665, + 21677, 21669, 21711, 21699, 33549, 21687, 21678, 21718, 21686, 21701, + 21702, 21664, 21616, 21692, 21666, 21694, 21618, 21726, 21680, 22453, + 22430, 22431, 22436, 22412, 22423, 22429, 22427, 22420, 22424, 22415, + 22425, 22437, 22426, 22421, 22772, 22797, 22867, 23009, 23006, 23022, + 23040, 23025, 23005, 23034, 23037, 23036, 23030, 23012, 23026, 23031, + 23003, 23017, 23027, 23029, 23008, 23038, 23028, 23021, 23464, 23628, + 23760, 23768, 23756, 23767, 23755, 23771, 23774, 23770, 23753, 23751, + 23754, 23766, 23763, 23764, 23759, 23752, 23750, 23758, 23775, 23800, + 24057, 24097, 24098, 24099, 24096, 24100, 24240, 24228, 24226, 24219, + 24227, 24229, 24327, 24366, 24406, 24454, 24631, 24633, 24660, 24690, + 24670, 24645, 24659, 24647, 24649, 24667, 24652, 24640, 24642, 24671, + 24612, 24644, 24664, 24678, 24686, 25154, 25155, 25295, 25357, 25355, + 25333, 25358, 25347, 25323, 25337, 25359, 25356, 25336, 25334, 25344, + 25363, 25364, 25338, 25365, 25339, 25328, 25921, 25923, 26026, 26047, + 26166, 26145, 26162, 26165, 26140, 26150, 26146, 26163, 26155, 26170, + 26141, 26164, 26169, 26158, 26383, 26384, 26561, 26610, 26568, 26554, + 26588, 26555, 26616, 26584, 26560, 26551, 26565, 26603, 26596, 26591, + 26549, 26573, 26547, 26615, 26614, 26606, 26595, 26562, 26553, 26574, + 26599, 26608, 26546, 26620, 26566, 26605, 26572, 26542, 26598, 26587, + 26618, 26569, 26570, 26563, 26602, 26571, 27432, 27522, 27524, 27574, + 27606, 27608, 27616, 27680, 27681, 27944, 27956, 27949, 27935, 27964, + 27967, 27922, 27914, 27866, 27955, 27908, 27929, 27962, 27930, 27921, + 27904, 27933, 27970, 27905, 27928, 27959, 27907, 27919, 27968, 27911, + 27936, 27948, 27912, 27938, 27913, 27920, 28855, 28831, 28862, 28849, + 28848, 28833, 28852, 28853, 28841, 29249, 29257, 29258, 29292, 29296, + 29299, 29294, 29386, 29412, 29416, 29419, 29407, 29418, 29414, 29411, + 29573, 29644, 29634, 29640, 29637, 29625, 29622, 29621, 29620, 29675, + 29631, 29639, 29630, 29635, 29638, 29624, 29643, 29932, 29934, 29998, + 30023, 30024, 30119, 30122, 30329, 30404, 30472, 30467, 30468, 30469, + 30474, 30455, 30459, 30458, 30695, 30696, 30726, 30737, 30738, 30725, + 30736, 30735, 30734, 30729, 30723, 30739, 31050, 31052, 31051, 31045, + 31044, 31189, 31181, 31183, 31190, 31182, 31360, 31358, 31441, 31488, + 31489, 31866, 31864, 31865, 31871, 31872, 31873, 32003, 32008, 32001, + 32600, 32657, 32653, 32702, 32775, 32782, 32783, 32788, 32823, 32984, + 32967, 32992, 32977, 32968, 32962, 32976, 32965, 32995, 32985, 32988, + 32970, 32981, 32969, 32975, 32983, 32998, 32973, 33279, 33313, 33428, + 33497, 33534, 33529, 33543, 33512, 33536, 33493, 33594, 33515, 33494, + 33524, 33516, 33505, 33522, 33525, 33548, 33531, 33526, 33520, 33514, + 33508, 33504, 33530, 33523, 33517, 34423, 34420, 34428, 34419, 34881, + 34894, 34919, 34922, 34921, 35283, 35332, 35335, 36210, 36835, 36833, + 36846, 36832, 37105, 37053, 37055, 37077, 37061, 37054, 37063, 37067, + 37064, 37332, 37331, 38484, 38479, 38481, 38483, 38474, 38478, 20510, + 20485, 20487, 20499, 20514, 20528, 20507, 20469, 20468, 20531, 20535, + 20524, 20470, 20471, 20503, 20508, 20512, 20519, 20533, 20527, 20529, + 20494, 20826, 20884, 20883, 20938, 20932, 20933, 20936, 20942, 21089, + 21082, 21074, 21086, 21087, 21077, 21090, 21197, 21262, 21406, 21798, + 21730, 21783, 21778, 21735, 21747, 21732, 21786, 21759, 21764, 21768, + 21739, 21777, 21765, 21745, 21770, 21755, 21751, 21752, 21728, 21774, + 21763, 21771, 22273, 22274, 22476, 22578, 22485, 22482, 22458, 22470, + 22461, 22460, 22456, 22454, 22463, 22471, 22480, 22457, 22465, 22798, + 22858, 23065, 23062, 23085, 23086, 23061, 23055, 23063, 23050, 23070, + 23091, 23404, 23463, 23469, 23468, 23555, 23638, 23636, 23788, 23807, + 23790, 23793, 23799, 23808, 23801, 24105, 24104, 24232, 24238, 24234, + 24236, 24371, 24368, 24423, 24669, 24666, 24679, 24641, 24738, 24712, + 24704, 24722, 24705, 24733, 24707, 24725, 24731, 24727, 24711, 24732, + 24718, 25113, 25158, 25330, 25360, 25430, 25388, 25412, 25413, 25398, + 25411, 25572, 25401, 25419, 25418, 25404, 25385, 25409, 25396, 25432, + 25428, 25433, 25389, 25415, 25395, 25434, 25425, 25400, 25431, 25408, + 25416, 25930, 25926, 26054, 26051, 26052, 26050, 26186, 26207, 26183, + 26193, 26386, 26387, 26655, 26650, 26697, 26674, 26675, 26683, 26699, + 26703, 26646, 26673, 26652, 26677, 26667, 26669, 26671, 26702, 26692, + 26676, 26653, 26642, 26644, 26662, 26664, 26670, 26701, 26682, 26661, + 26656, 27436, 27439, 27437, 27441, 27444, 27501, 32898, 27528, 27622, + 27620, 27624, 27619, 27618, 27623, 27685, 28026, 28003, 28004, 28022, + 27917, 28001, 28050, 27992, 28002, 28013, 28015, 28049, 28045, 28143, + 28031, 28038, 27998, 28007, 28000, 28055, 28016, 28028, 27999, 28034, + 28056, 27951, 28008, 28043, 28030, 28032, 28036, 27926, 28035, 28027, + 28029, 28021, 28048, 28892, 28883, 28881, 28893, 28875, 32569, 28898, + 28887, 28882, 28894, 28896, 28884, 28877, 28869, 28870, 28871, 28890, + 28878, 28897, 29250, 29304, 29303, 29302, 29440, 29434, 29428, 29438, + 29430, 29427, 29435, 29441, 29651, 29657, 29669, 29654, 29628, 29671, + 29667, 29673, 29660, 29650, 29659, 29652, 29661, 29658, 29655, 29656, + 29672, 29918, 29919, 29940, 29941, 29985, 30043, 30047, 30128, 30145, + 30139, 30148, 30144, 30143, 30134, 30138, 30346, 30409, 30493, 30491, + 30480, 30483, 30482, 30499, 30481, 30485, 30489, 30490, 30498, 30503, + 30755, 30764, 30754, 30773, 30767, 30760, 30766, 30763, 30753, 30761, + 30771, 30762, 30769, 31060, 31067, 31055, 31068, 31059, 31058, 31057, + 31211, 31212, 31200, 31214, 31213, 31210, 31196, 31198, 31197, 31366, + 31369, 31365, 31371, 31372, 31370, 31367, 31448, 31504, 31492, 31507, + 31493, 31503, 31496, 31498, 31502, 31497, 31506, 31876, 31889, 31882, + 31884, 31880, 31885, 31877, 32030, 32029, 32017, 32014, 32024, 32022, + 32019, 32031, 32018, 32015, 32012, 32604, 32609, 32606, 32608, 32605, + 32603, 32662, 32658, 32707, 32706, 32704, 32790, 32830, 32825, 33018, + 33010, 33017, 33013, 33025, 33019, 33024, 33281, 33327, 33317, 33587, + 33581, 33604, 33561, 33617, 33573, 33622, 33599, 33601, 33574, 33564, + 33570, 33602, 33614, 33563, 33578, 33544, 33596, 33613, 33558, 33572, + 33568, 33591, 33583, 33577, 33607, 33605, 33612, 33619, 33566, 33580, + 33611, 33575, 33608, 34387, 34386, 34466, 34472, 34454, 34445, 34449, + 34462, 34439, 34455, 34438, 34443, 34458, 34437, 34469, 34457, 34465, + 34471, 34453, 34456, 34446, 34461, 34448, 34452, 34883, 34884, 34925, + 34933, 34934, 34930, 34944, 34929, 34943, 34927, 34947, 34942, 34932, + 34940, 35346, 35911, 35927, 35963, 36004, 36003, 36214, 36216, 36277, + 36279, 36278, 36561, 36563, 36862, 36853, 36866, 36863, 36859, 36868, + 36860, 36854, 37078, 37088, 37081, 37082, 37091, 37087, 37093, 37080, + 37083, 37079, 37084, 37092, 37200, 37198, 37199, 37333, 37346, 37338, + 38492, 38495, 38588, 39139, 39647, 39727, 20095, 20592, 20586, 20577, + 20574, 20576, 20563, 20555, 20573, 20594, 20552, 20557, 20545, 20571, + 20554, 20578, 20501, 20549, 20575, 20585, 20587, 20579, 20580, 20550, + 20544, 20590, 20595, 20567, 20561, 20944, 21099, 21101, 21100, 21102, + 21206, 21203, 21293, 21404, 21877, 21878, 21820, 21837, 21840, 21812, + 21802, 21841, 21858, 21814, 21813, 21808, 21842, 21829, 21772, 21810, + 21861, 21838, 21817, 21832, 21805, 21819, 21824, 21835, 22282, 22279, + 22523, 22548, 22498, 22518, 22492, 22516, 22528, 22509, 22525, 22536, + 22520, 22539, 22515, 22479, 22535, 22510, 22499, 22514, 22501, 22508, + 22497, 22542, 22524, 22544, 22503, 22529, 22540, 22513, 22505, 22512, + 22541, 22532, 22876, 23136, 23128, 23125, 23143, 23134, 23096, 23093, + 23149, 23120, 23135, 23141, 23148, 23123, 23140, 23127, 23107, 23133, + 23122, 23108, 23131, 23112, 23182, 23102, 23117, 23097, 23116, 23152, + 23145, 23111, 23121, 23126, 23106, 23132, 23410, 23406, 23489, 23488, + 23641, 23838, 23819, 23837, 23834, 23840, 23820, 23848, 23821, 23846, + 23845, 23823, 23856, 23826, 23843, 23839, 23854, 24126, 24116, 24241, + 24244, 24249, 24242, 24243, 24374, 24376, 24475, 24470, 24479, 24714, + 24720, 24710, 24766, 24752, 24762, 24787, 24788, 24783, 24804, 24793, + 24797, 24776, 24753, 24795, 24759, 24778, 24767, 24771, 24781, 24768, + 25394, 25445, 25482, 25474, 25469, 25533, 25502, 25517, 25501, 25495, + 25515, 25486, 25455, 25479, 25488, 25454, 25519, 25461, 25500, 25453, + 25518, 25468, 25508, 25403, 25503, 25464, 25477, 25473, 25489, 25485, + 25456, 25939, 26061, 26213, 26209, 26203, 26201, 26204, 26210, 26392, + 26745, 26759, 26768, 26780, 26733, 26734, 26798, 26795, 26966, 26735, + 26787, 26796, 26793, 26741, 26740, 26802, 26767, 26743, 26770, 26748, + 26731, 26738, 26794, 26752, 26737, 26750, 26779, 26774, 26763, 26784, + 26761, 26788, 26744, 26747, 26769, 26764, 26762, 26749, 27446, 27443, + 27447, 27448, 27537, 27535, 27533, 27534, 27532, 27690, 28096, 28075, + 28084, 28083, 28276, 28076, 28137, 28130, 28087, 28150, 28116, 28160, + 28104, 28128, 28127, 28118, 28094, 28133, 28124, 28125, 28123, 28148, + 28106, 28093, 28141, 28144, 28090, 28117, 28098, 28111, 28105, 28112, + 28146, 28115, 28157, 28119, 28109, 28131, 28091, 28922, 28941, 28919, + 28951, 28916, 28940, 28912, 28932, 28915, 28944, 28924, 28927, 28934, + 28947, 28928, 28920, 28918, 28939, 28930, 28942, 29310, 29307, 29308, + 29311, 29469, 29463, 29447, 29457, 29464, 29450, 29448, 29439, 29455, + 29470, 29576, 29686, 29688, 29685, 29700, 29697, 29693, 29703, 29696, + 29690, 29692, 29695, 29708, 29707, 29684, 29704, 30052, 30051, 30158, + 30162, 30159, 30155, 30156, 30161, 30160, 30351, 30345, 30419, 30521, + 30511, 30509, 30513, 30514, 30516, 30515, 30525, 30501, 30523, 30517, + 30792, 30802, 30793, 30797, 30794, 30796, 30758, 30789, 30800, 31076, + 31079, 31081, 31082, 31075, 31083, 31073, 31163, 31226, 31224, 31222, + 31223, 31375, 31380, 31376, 31541, 31559, 31540, 31525, 31536, 31522, + 31524, 31539, 31512, 31530, 31517, 31537, 31531, 31533, 31535, 31538, + 31544, 31514, 31523, 31892, 31896, 31894, 31907, 32053, 32061, 32056, + 32054, 32058, 32069, 32044, 32041, 32065, 32071, 32062, 32063, 32074, + 32059, 32040, 32611, 32661, 32668, 32669, 32667, 32714, 32715, 32717, + 32720, 32721, 32711, 32719, 32713, 32799, 32798, 32795, 32839, 32835, + 32840, 33048, 33061, 33049, 33051, 33069, 33055, 33068, 33054, 33057, + 33045, 33063, 33053, 33058, 33297, 33336, 33331, 33338, 33332, 33330, + 33396, 33680, 33699, 33704, 33677, 33658, 33651, 33700, 33652, 33679, + 33665, 33685, 33689, 33653, 33684, 33705, 33661, 33667, 33676, 33693, + 33691, 33706, 33675, 33662, 33701, 33711, 33672, 33687, 33712, 33663, + 33702, 33671, 33710, 33654, 33690, 34393, 34390, 34495, 34487, 34498, + 34497, 34501, 34490, 34480, 34504, 34489, 34483, 34488, 34508, 34484, + 34491, 34492, 34499, 34493, 34494, 34898, 34953, 34965, 34984, 34978, + 34986, 34970, 34961, 34977, 34975, 34968, 34983, 34969, 34971, 34967, + 34980, 34988, 34956, 34963, 34958, 35202, 35286, 35289, 35285, 35376, + 35367, 35372, 35358, 35897, 35899, 35932, 35933, 35965, 36005, 36221, + 36219, 36217, 36284, 36290, 36281, 36287, 36289, 36568, 36574, 36573, + 36572, 36567, 36576, 36577, 36900, 36875, 36881, 36892, 36876, 36897, + 37103, 37098, 37104, 37108, 37106, 37107, 37076, 37099, 37100, 37097, + 37206, 37208, 37210, 37203, 37205, 37356, 37364, 37361, 37363, 37368, + 37348, 37369, 37354, 37355, 37367, 37352, 37358, 38266, 38278, 38280, + 38524, 38509, 38507, 38513, 38511, 38591, 38762, 38916, 39141, 39319, + 20635, 20629, 20628, 20638, 20619, 20643, 20611, 20620, 20622, 20637, + 20584, 20636, 20626, 20610, 20615, 20831, 20948, 21266, 21265, 21412, + 21415, 21905, 21928, 21925, 21933, 21879, 22085, 21922, 21907, 21896, + 21903, 21941, 21889, 21923, 21906, 21924, 21885, 21900, 21926, 21887, + 21909, 21921, 21902, 22284, 22569, 22583, 22553, 22558, 22567, 22563, + 22568, 22517, 22600, 22565, 22556, 22555, 22579, 22591, 22582, 22574, + 22585, 22584, 22573, 22572, 22587, 22881, 23215, 23188, 23199, 23162, + 23202, 23198, 23160, 23206, 23164, 23205, 23212, 23189, 23214, 23095, + 23172, 23178, 23191, 23171, 23179, 23209, 23163, 23165, 23180, 23196, + 23183, 23187, 23197, 23530, 23501, 23499, 23508, 23505, 23498, 23502, + 23564, 23600, 23863, 23875, 23915, 23873, 23883, 23871, 23861, 23889, + 23886, 23893, 23859, 23866, 23890, 23869, 23857, 23897, 23874, 23865, + 23881, 23864, 23868, 23858, 23862, 23872, 23877, 24132, 24129, 24408, + 24486, 24485, 24491, 24777, 24761, 24780, 24802, 24782, 24772, 24852, + 24818, 24842, 24854, 24837, 24821, 24851, 24824, 24828, 24830, 24769, + 24835, 24856, 24861, 24848, 24831, 24836, 24843, 25162, 25492, 25521, + 25520, 25550, 25573, 25576, 25583, 25539, 25757, 25587, 25546, 25568, + 25590, 25557, 25586, 25589, 25697, 25567, 25534, 25565, 25564, 25540, + 25560, 25555, 25538, 25543, 25548, 25547, 25544, 25584, 25559, 25561, + 25906, 25959, 25962, 25956, 25948, 25960, 25957, 25996, 26013, 26014, + 26030, 26064, 26066, 26236, 26220, 26235, 26240, 26225, 26233, 26218, + 26226, 26369, 26892, 26835, 26884, 26844, 26922, 26860, 26858, 26865, + 26895, 26838, 26871, 26859, 26852, 26870, 26899, 26896, 26867, 26849, + 26887, 26828, 26888, 26992, 26804, 26897, 26863, 26822, 26900, 26872, + 26832, 26877, 26876, 26856, 26891, 26890, 26903, 26830, 26824, 26845, + 26846, 26854, 26868, 26833, 26886, 26836, 26857, 26901, 26917, 26823, + 27449, 27451, 27455, 27452, 27540, 27543, 27545, 27541, 27581, 27632, + 27634, 27635, 27696, 28156, 28230, 28231, 28191, 28233, 28296, 28220, + 28221, 28229, 28258, 28203, 28223, 28225, 28253, 28275, 28188, 28211, + 28235, 28224, 28241, 28219, 28163, 28206, 28254, 28264, 28252, 28257, + 28209, 28200, 28256, 28273, 28267, 28217, 28194, 28208, 28243, 28261, + 28199, 28280, 28260, 28279, 28245, 28281, 28242, 28262, 28213, 28214, + 28250, 28960, 28958, 28975, 28923, 28974, 28977, 28963, 28965, 28962, + 28978, 28959, 28968, 28986, 28955, 29259, 29274, 29320, 29321, 29318, + 29317, 29323, 29458, 29451, 29488, 29474, 29489, 29491, 29479, 29490, + 29485, 29478, 29475, 29493, 29452, 29742, 29740, 29744, 29739, 29718, + 29722, 29729, 29741, 29745, 29732, 29731, 29725, 29737, 29728, 29746, + 29947, 29999, 30063, 30060, 30183, 30170, 30177, 30182, 30173, 30175, + 30180, 30167, 30357, 30354, 30426, 30534, 30535, 30532, 30541, 30533, + 30538, 30542, 30539, 30540, 30686, 30700, 30816, 30820, 30821, 30812, + 30829, 30833, 30826, 30830, 30832, 30825, 30824, 30814, 30818, 31092, + 31091, 31090, 31088, 31234, 31242, 31235, 31244, 31236, 31385, 31462, + 31460, 31562, 31547, 31556, 31560, 31564, 31566, 31552, 31576, 31557, + 31906, 31902, 31912, 31905, 32088, 32111, 32099, 32083, 32086, 32103, + 32106, 32079, 32109, 32092, 32107, 32082, 32084, 32105, 32081, 32095, + 32078, 32574, 32575, 32613, 32614, 32674, 32672, 32673, 32727, 32849, + 32847, 32848, 33022, 32980, 33091, 33098, 33106, 33103, 33095, 33085, + 33101, 33082, 33254, 33262, 33271, 33272, 33273, 33284, 33340, 33341, + 33343, 33397, 33595, 33743, 33785, 33827, 33728, 33768, 33810, 33767, + 33764, 33788, 33782, 33808, 33734, 33736, 33771, 33763, 33727, 33793, + 33757, 33765, 33752, 33791, 33761, 33739, 33742, 33750, 33781, 33737, + 33801, 33807, 33758, 33809, 33798, 33730, 33779, 33749, 33786, 33735, + 33745, 33770, 33811, 33731, 33772, 33774, 33732, 33787, 33751, 33762, + 33819, 33755, 33790, 34520, 34530, 34534, 34515, 34531, 34522, 34538, + 34525, 34539, 34524, 34540, 34537, 34519, 34536, 34513, 34888, 34902, + 34901, 35002, 35031, 35001, 35000, 35008, 35006, 34998, 35004, 34999, + 35005, 34994, 35073, 35017, 35221, 35224, 35223, 35293, 35290, 35291, + 35406, 35405, 35385, 35417, 35392, 35415, 35416, 35396, 35397, 35410, + 35400, 35409, 35402, 35404, 35407, 35935, 35969, 35968, 36026, 36030, + 36016, 36025, 36021, 36228, 36224, 36233, 36312, 36307, 36301, 36295, + 36310, 36316, 36303, 36309, 36313, 36296, 36311, 36293, 36591, 36599, + 36602, 36601, 36582, 36590, 36581, 36597, 36583, 36584, 36598, 36587, + 36593, 36588, 36596, 36585, 36909, 36916, 36911, 37126, 37164, 37124, + 37119, 37116, 37128, 37113, 37115, 37121, 37120, 37127, 37125, 37123, + 37217, 37220, 37215, 37218, 37216, 37377, 37386, 37413, 37379, 37402, + 37414, 37391, 37388, 37376, 37394, 37375, 37373, 37382, 37380, 37415, + 37378, 37404, 37412, 37401, 37399, 37381, 37398, 38267, 38285, 38284, + 38288, 38535, 38526, 38536, 38537, 38531, 38528, 38594, 38600, 38595, + 38641, 38640, 38764, 38768, 38766, 38919, 39081, 39147, 40166, 40697, + 20099, 20100, 20150, 20669, 20671, 20678, 20654, 20676, 20682, 20660, + 20680, 20674, 20656, 20673, 20666, 20657, 20683, 20681, 20662, 20664, + 20951, 21114, 21112, 21115, 21116, 21955, 21979, 21964, 21968, 21963, + 21962, 21981, 21952, 21972, 21956, 21993, 21951, 21970, 21901, 21967, + 21973, 21986, 21974, 21960, 22002, 21965, 21977, 21954, 22292, 22611, + 22632, 22628, 22607, 22605, 22601, 22639, 22613, 22606, 22621, 22617, + 22629, 22619, 22589, 22627, 22641, 22780, 23239, 23236, 23243, 23226, + 23224, 23217, 23221, 23216, 23231, 23240, 23227, 23238, 23223, 23232, + 23242, 23220, 23222, 23245, 23225, 23184, 23510, 23512, 23513, 23583, + 23603, 23921, 23907, 23882, 23909, 23922, 23916, 23902, 23912, 23911, + 23906, 24048, 24143, 24142, 24138, 24141, 24139, 24261, 24268, 24262, + 24267, 24263, 24384, 24495, 24493, 24823, 24905, 24906, 24875, 24901, + 24886, 24882, 24878, 24902, 24879, 24911, 24873, 24896, 25120, 37224, + 25123, 25125, 25124, 25541, 25585, 25579, 25616, 25618, 25609, 25632, + 25636, 25651, 25667, 25631, 25621, 25624, 25657, 25655, 25634, 25635, + 25612, 25638, 25648, 25640, 25665, 25653, 25647, 25610, 25626, 25664, + 25637, 25639, 25611, 25575, 25627, 25646, 25633, 25614, 25967, 26002, + 26067, 26246, 26252, 26261, 26256, 26251, 26250, 26265, 26260, 26232, + 26400, 26982, 26975, 26936, 26958, 26978, 26993, 26943, 26949, 26986, + 26937, 26946, 26967, 26969, 27002, 26952, 26953, 26933, 26988, 26931, + 26941, 26981, 26864, 27000, 26932, 26985, 26944, 26991, 26948, 26998, + 26968, 26945, 26996, 26956, 26939, 26955, 26935, 26972, 26959, 26961, + 26930, 26962, 26927, 27003, 26940, 27462, 27461, 27459, 27458, 27464, + 27457, 27547, 64013, 27643, 27644, 27641, 27639, 27640, 28315, 28374, + 28360, 28303, 28352, 28319, 28307, 28308, 28320, 28337, 28345, 28358, + 28370, 28349, 28353, 28318, 28361, 28343, 28336, 28365, 28326, 28367, + 28338, 28350, 28355, 28380, 28376, 28313, 28306, 28302, 28301, 28324, + 28321, 28351, 28339, 28368, 28362, 28311, 28334, 28323, 28999, 29012, + 29010, 29027, 29024, 28993, 29021, 29026, 29042, 29048, 29034, 29025, + 28994, 29016, 28995, 29003, 29040, 29023, 29008, 29011, 28996, 29005, + 29018, 29263, 29325, 29324, 29329, 29328, 29326, 29500, 29506, 29499, + 29498, 29504, 29514, 29513, 29764, 29770, 29771, 29778, 29777, 29783, + 29760, 29775, 29776, 29774, 29762, 29766, 29773, 29780, 29921, 29951, + 29950, 29949, 29981, 30073, 30071, 27011, 30191, 30223, 30211, 30199, + 30206, 30204, 30201, 30200, 30224, 30203, 30198, 30189, 30197, 30205, + 30361, 30389, 30429, 30549, 30559, 30560, 30546, 30550, 30554, 30569, + 30567, 30548, 30553, 30573, 30688, 30855, 30874, 30868, 30863, 30852, + 30869, 30853, 30854, 30881, 30851, 30841, 30873, 30848, 30870, 30843, + 31100, 31106, 31101, 31097, 31249, 31256, 31257, 31250, 31255, 31253, + 31266, 31251, 31259, 31248, 31395, 31394, 31390, 31467, 31590, 31588, + 31597, 31604, 31593, 31602, 31589, 31603, 31601, 31600, 31585, 31608, + 31606, 31587, 31922, 31924, 31919, 32136, 32134, 32128, 32141, 32127, + 32133, 32122, 32142, 32123, 32131, 32124, 32140, 32148, 32132, 32125, + 32146, 32621, 32619, 32615, 32616, 32620, 32678, 32677, 32679, 32731, + 32732, 32801, 33124, 33120, 33143, 33116, 33129, 33115, 33122, 33138, + 26401, 33118, 33142, 33127, 33135, 33092, 33121, 33309, 33353, 33348, + 33344, 33346, 33349, 34033, 33855, 33878, 33910, 33913, 33935, 33933, + 33893, 33873, 33856, 33926, 33895, 33840, 33869, 33917, 33882, 33881, + 33908, 33907, 33885, 34055, 33886, 33847, 33850, 33844, 33914, 33859, + 33912, 33842, 33861, 33833, 33753, 33867, 33839, 33858, 33837, 33887, + 33904, 33849, 33870, 33868, 33874, 33903, 33989, 33934, 33851, 33863, + 33846, 33843, 33896, 33918, 33860, 33835, 33888, 33876, 33902, 33872, + 34571, 34564, 34551, 34572, 34554, 34518, 34549, 34637, 34552, 34574, + 34569, 34561, 34550, 34573, 34565, 35030, 35019, 35021, 35022, 35038, + 35035, 35034, 35020, 35024, 35205, 35227, 35295, 35301, 35300, 35297, + 35296, 35298, 35292, 35302, 35446, 35462, 35455, 35425, 35391, 35447, + 35458, 35460, 35445, 35459, 35457, 35444, 35450, 35900, 35915, 35914, + 35941, 35940, 35942, 35974, 35972, 35973, 36044, 36200, 36201, 36241, + 36236, 36238, 36239, 36237, 36243, 36244, 36240, 36242, 36336, 36320, + 36332, 36337, 36334, 36304, 36329, 36323, 36322, 36327, 36338, 36331, + 36340, 36614, 36607, 36609, 36608, 36613, 36615, 36616, 36610, 36619, + 36946, 36927, 36932, 36937, 36925, 37136, 37133, 37135, 37137, 37142, + 37140, 37131, 37134, 37230, 37231, 37448, 37458, 37424, 37434, 37478, + 37427, 37477, 37470, 37507, 37422, 37450, 37446, 37485, 37484, 37455, + 37472, 37479, 37487, 37430, 37473, 37488, 37425, 37460, 37475, 37456, + 37490, 37454, 37459, 37452, 37462, 37426, 38303, 38300, 38302, 38299, + 38546, 38547, 38545, 38551, 38606, 38650, 38653, 38648, 38645, 38771, + 38775, 38776, 38770, 38927, 38925, 38926, 39084, 39158, 39161, 39343, + 39346, 39344, 39349, 39597, 39595, 39771, 40170, 40173, 40167, 40576, + 40701, 20710, 20692, 20695, 20712, 20723, 20699, 20714, 20701, 20708, + 20691, 20716, 20720, 20719, 20707, 20704, 20952, 21120, 21121, 21225, + 21227, 21296, 21420, 22055, 22037, 22028, 22034, 22012, 22031, 22044, + 22017, 22035, 22018, 22010, 22045, 22020, 22015, 22009, 22665, 22652, + 22672, 22680, 22662, 22657, 22655, 22644, 22667, 22650, 22663, 22673, + 22670, 22646, 22658, 22664, 22651, 22676, 22671, 22782, 22891, 23260, + 23278, 23269, 23253, 23274, 23258, 23277, 23275, 23283, 23266, 23264, + 23259, 23276, 23262, 23261, 23257, 23272, 23263, 23415, 23520, 23523, + 23651, 23938, 23936, 23933, 23942, 23930, 23937, 23927, 23946, 23945, + 23944, 23934, 23932, 23949, 23929, 23935, 24152, 24153, 24147, 24280, + 24273, 24279, 24270, 24284, 24277, 24281, 24274, 24276, 24388, 24387, + 24431, 24502, 24876, 24872, 24897, 24926, 24945, 24947, 24914, 24915, + 24946, 24940, 24960, 24948, 24916, 24954, 24923, 24933, 24891, 24938, + 24929, 24918, 25129, 25127, 25131, 25643, 25677, 25691, 25693, 25716, + 25718, 25714, 25715, 25725, 25717, 25702, 25766, 25678, 25730, 25694, + 25692, 25675, 25683, 25696, 25680, 25727, 25663, 25708, 25707, 25689, + 25701, 25719, 25971, 26016, 26273, 26272, 26271, 26373, 26372, 26402, + 27057, 27062, 27081, 27040, 27086, 27030, 27056, 27052, 27068, 27025, + 27033, 27022, 27047, 27021, 27049, 27070, 27055, 27071, 27076, 27069, + 27044, 27092, 27065, 27082, 27034, 27087, 27059, 27027, 27050, 27041, + 27038, 27097, 27031, 27024, 27074, 27061, 27045, 27078, 27466, 27469, + 27467, 27550, 27551, 27552, 27587, 27588, 27646, 28366, 28405, 28401, + 28419, 28453, 28408, 28471, 28411, 28462, 28425, 28494, 28441, 28442, + 28455, 28440, 28475, 28434, 28397, 28426, 28470, 28531, 28409, 28398, + 28461, 28480, 28464, 28476, 28469, 28395, 28423, 28430, 28483, 28421, + 28413, 28406, 28473, 28444, 28412, 28474, 28447, 28429, 28446, 28424, + 28449, 29063, 29072, 29065, 29056, 29061, 29058, 29071, 29051, 29062, + 29057, 29079, 29252, 29267, 29335, 29333, 29331, 29507, 29517, 29521, + 29516, 29794, 29811, 29809, 29813, 29810, 29799, 29806, 29952, 29954, + 29955, 30077, 30096, 30230, 30216, 30220, 30229, 30225, 30218, 30228, + 30392, 30593, 30588, 30597, 30594, 30574, 30592, 30575, 30590, 30595, + 30898, 30890, 30900, 30893, 30888, 30846, 30891, 30878, 30885, 30880, + 30892, 30882, 30884, 31128, 31114, 31115, 31126, 31125, 31124, 31123, + 31127, 31112, 31122, 31120, 31275, 31306, 31280, 31279, 31272, 31270, + 31400, 31403, 31404, 31470, 31624, 31644, 31626, 31633, 31632, 31638, + 31629, 31628, 31643, 31630, 31621, 31640, 21124, 31641, 31652, 31618, + 31931, 31935, 31932, 31930, 32167, 32183, 32194, 32163, 32170, 32193, + 32192, 32197, 32157, 32206, 32196, 32198, 32203, 32204, 32175, 32185, + 32150, 32188, 32159, 32166, 32174, 32169, 32161, 32201, 32627, 32738, + 32739, 32741, 32734, 32804, 32861, 32860, 33161, 33158, 33155, 33159, + 33165, 33164, 33163, 33301, 33943, 33956, 33953, 33951, 33978, 33998, + 33986, 33964, 33966, 33963, 33977, 33972, 33985, 33997, 33962, 33946, + 33969, 34000, 33949, 33959, 33979, 33954, 33940, 33991, 33996, 33947, + 33961, 33967, 33960, 34006, 33944, 33974, 33999, 33952, 34007, 34004, + 34002, 34011, 33968, 33937, 34401, 34611, 34595, 34600, 34667, 34624, + 34606, 34590, 34593, 34585, 34587, 34627, 34604, 34625, 34622, 34630, + 34592, 34610, 34602, 34605, 34620, 34578, 34618, 34609, 34613, 34626, + 34598, 34599, 34616, 34596, 34586, 34608, 34577, 35063, 35047, 35057, + 35058, 35066, 35070, 35054, 35068, 35062, 35067, 35056, 35052, 35051, + 35229, 35233, 35231, 35230, 35305, 35307, 35304, 35499, 35481, 35467, + 35474, 35471, 35478, 35901, 35944, 35945, 36053, 36047, 36055, 36246, + 36361, 36354, 36351, 36365, 36349, 36362, 36355, 36359, 36358, 36357, + 36350, 36352, 36356, 36624, 36625, 36622, 36621, 37155, 37148, 37152, + 37154, 37151, 37149, 37146, 37156, 37153, 37147, 37242, 37234, 37241, + 37235, 37541, 37540, 37494, 37531, 37498, 37536, 37524, 37546, 37517, + 37542, 37530, 37547, 37497, 37527, 37503, 37539, 37614, 37518, 37506, + 37525, 37538, 37501, 37512, 37537, 37514, 37510, 37516, 37529, 37543, + 37502, 37511, 37545, 37533, 37515, 37421, 38558, 38561, 38655, 38744, + 38781, 38778, 38782, 38787, 38784, 38786, 38779, 38788, 38785, 38783, + 38862, 38861, 38934, 39085, 39086, 39170, 39168, 39175, 39325, 39324, + 39363, 39353, 39355, 39354, 39362, 39357, 39367, 39601, 39651, 39655, + 39742, 39743, 39776, 39777, 39775, 40177, 40178, 40181, 40615, 20735, + 20739, 20784, 20728, 20742, 20743, 20726, 20734, 20747, 20748, 20733, + 20746, 21131, 21132, 21233, 21231, 22088, 22082, 22092, 22069, 22081, + 22090, 22089, 22086, 22104, 22106, 22080, 22067, 22077, 22060, 22078, + 22072, 22058, 22074, 22298, 22699, 22685, 22705, 22688, 22691, 22703, + 22700, 22693, 22689, 22783, 23295, 23284, 23293, 23287, 23286, 23299, + 23288, 23298, 23289, 23297, 23303, 23301, 23311, 23655, 23961, 23959, + 23967, 23954, 23970, 23955, 23957, 23968, 23964, 23969, 23962, 23966, + 24169, 24157, 24160, 24156, 32243, 24283, 24286, 24289, 24393, 24498, + 24971, 24963, 24953, 25009, 25008, 24994, 24969, 24987, 24979, 25007, + 25005, 24991, 24978, 25002, 24993, 24973, 24934, 25011, 25133, 25710, + 25712, 25750, 25760, 25733, 25751, 25756, 25743, 25739, 25738, 25740, + 25763, 25759, 25704, 25777, 25752, 25974, 25978, 25977, 25979, 26034, + 26035, 26293, 26288, 26281, 26290, 26295, 26282, 26287, 27136, 27142, + 27159, 27109, 27128, 27157, 27121, 27108, 27168, 27135, 27116, 27106, + 27163, 27165, 27134, 27175, 27122, 27118, 27156, 27127, 27111, 27200, + 27144, 27110, 27131, 27149, 27132, 27115, 27145, 27140, 27160, 27173, + 27151, 27126, 27174, 27143, 27124, 27158, 27473, 27557, 27555, 27554, + 27558, 27649, 27648, 27647, 27650, 28481, 28454, 28542, 28551, 28614, + 28562, 28557, 28553, 28556, 28514, 28495, 28549, 28506, 28566, 28534, + 28524, 28546, 28501, 28530, 28498, 28496, 28503, 28564, 28563, 28509, + 28416, 28513, 28523, 28541, 28519, 28560, 28499, 28555, 28521, 28543, + 28565, 28515, 28535, 28522, 28539, 29106, 29103, 29083, 29104, 29088, + 29082, 29097, 29109, 29085, 29093, 29086, 29092, 29089, 29098, 29084, + 29095, 29107, 29336, 29338, 29528, 29522, 29534, 29535, 29536, 29533, + 29531, 29537, 29530, 29529, 29538, 29831, 29833, 29834, 29830, 29825, + 29821, 29829, 29832, 29820, 29817, 29960, 29959, 30078, 30245, 30238, + 30233, 30237, 30236, 30243, 30234, 30248, 30235, 30364, 30365, 30366, + 30363, 30605, 30607, 30601, 30600, 30925, 30907, 30927, 30924, 30929, + 30926, 30932, 30920, 30915, 30916, 30921, 31130, 31137, 31136, 31132, + 31138, 31131, 27510, 31289, 31410, 31412, 31411, 31671, 31691, 31678, + 31660, 31694, 31663, 31673, 31690, 31669, 31941, 31944, 31948, 31947, + 32247, 32219, 32234, 32231, 32215, 32225, 32259, 32250, 32230, 32246, + 32241, 32240, 32238, 32223, 32630, 32684, 32688, 32685, 32749, 32747, + 32746, 32748, 32742, 32744, 32868, 32871, 33187, 33183, 33182, 33173, + 33186, 33177, 33175, 33302, 33359, 33363, 33362, 33360, 33358, 33361, + 34084, 34107, 34063, 34048, 34089, 34062, 34057, 34061, 34079, 34058, + 34087, 34076, 34043, 34091, 34042, 34056, 34060, 34036, 34090, 34034, + 34069, 34039, 34027, 34035, 34044, 34066, 34026, 34025, 34070, 34046, + 34088, 34077, 34094, 34050, 34045, 34078, 34038, 34097, 34086, 34023, + 34024, 34032, 34031, 34041, 34072, 34080, 34096, 34059, 34073, 34095, + 34402, 34646, 34659, 34660, 34679, 34785, 34675, 34648, 34644, 34651, + 34642, 34657, 34650, 34641, 34654, 34669, 34666, 34640, 34638, 34655, + 34653, 34671, 34668, 34682, 34670, 34652, 34661, 34639, 34683, 34677, + 34658, 34663, 34665, 34906, 35077, 35084, 35092, 35083, 35095, 35096, + 35097, 35078, 35094, 35089, 35086, 35081, 35234, 35236, 35235, 35309, + 35312, 35308, 35535, 35526, 35512, 35539, 35537, 35540, 35541, 35515, + 35543, 35518, 35520, 35525, 35544, 35523, 35514, 35517, 35545, 35902, + 35917, 35983, 36069, 36063, 36057, 36072, 36058, 36061, 36071, 36256, + 36252, 36257, 36251, 36384, 36387, 36389, 36388, 36398, 36373, 36379, + 36374, 36369, 36377, 36390, 36391, 36372, 36370, 36376, 36371, 36380, + 36375, 36378, 36652, 36644, 36632, 36634, 36640, 36643, 36630, 36631, + 36979, 36976, 36975, 36967, 36971, 37167, 37163, 37161, 37162, 37170, + 37158, 37166, 37253, 37254, 37258, 37249, 37250, 37252, 37248, 37584, + 37571, 37572, 37568, 37593, 37558, 37583, 37617, 37599, 37592, 37609, + 37591, 37597, 37580, 37615, 37570, 37608, 37578, 37576, 37582, 37606, + 37581, 37589, 37577, 37600, 37598, 37607, 37585, 37587, 37557, 37601, + 37574, 37556, 38268, 38316, 38315, 38318, 38320, 38564, 38562, 38611, + 38661, 38664, 38658, 38746, 38794, 38798, 38792, 38864, 38863, 38942, + 38941, 38950, 38953, 38952, 38944, 38939, 38951, 39090, 39176, 39162, + 39185, 39188, 39190, 39191, 39189, 39388, 39373, 39375, 39379, 39380, + 39374, 39369, 39382, 39384, 39371, 39383, 39372, 39603, 39660, 39659, + 39667, 39666, 39665, 39750, 39747, 39783, 39796, 39793, 39782, 39798, + 39797, 39792, 39784, 39780, 39788, 40188, 40186, 40189, 40191, 40183, + 40199, 40192, 40185, 40187, 40200, 40197, 40196, 40579, 40659, 40719, + 40720, 20764, 20755, 20759, 20762, 20753, 20958, 21300, 21473, 22128, + 22112, 22126, 22131, 22118, 22115, 22125, 22130, 22110, 22135, 22300, + 22299, 22728, 22717, 22729, 22719, 22714, 22722, 22716, 22726, 23319, + 23321, 23323, 23329, 23316, 23315, 23312, 23318, 23336, 23322, 23328, + 23326, 23535, 23980, 23985, 23977, 23975, 23989, 23984, 23982, 23978, + 23976, 23986, 23981, 23983, 23988, 24167, 24168, 24166, 24175, 24297, + 24295, 24294, 24296, 24293, 24395, 24508, 24989, 25000, 24982, 25029, + 25012, 25030, 25025, 25036, 25018, 25023, 25016, 24972, 25815, 25814, + 25808, 25807, 25801, 25789, 25737, 25795, 25819, 25843, 25817, 25907, + 25983, 25980, 26018, 26312, 26302, 26304, 26314, 26315, 26319, 26301, + 26299, 26298, 26316, 26403, 27188, 27238, 27209, 27239, 27186, 27240, + 27198, 27229, 27245, 27254, 27227, 27217, 27176, 27226, 27195, 27199, + 27201, 27242, 27236, 27216, 27215, 27220, 27247, 27241, 27232, 27196, + 27230, 27222, 27221, 27213, 27214, 27206, 27477, 27476, 27478, 27559, + 27562, 27563, 27592, 27591, 27652, 27651, 27654, 28589, 28619, 28579, + 28615, 28604, 28622, 28616, 28510, 28612, 28605, 28574, 28618, 28584, + 28676, 28581, 28590, 28602, 28588, 28586, 28623, 28607, 28600, 28578, + 28617, 28587, 28621, 28591, 28594, 28592, 29125, 29122, 29119, 29112, + 29142, 29120, 29121, 29131, 29140, 29130, 29127, 29135, 29117, 29144, + 29116, 29126, 29146, 29147, 29341, 29342, 29545, 29542, 29543, 29548, + 29541, 29547, 29546, 29823, 29850, 29856, 29844, 29842, 29845, 29857, + 29963, 30080, 30255, 30253, 30257, 30269, 30259, 30268, 30261, 30258, + 30256, 30395, 30438, 30618, 30621, 30625, 30620, 30619, 30626, 30627, + 30613, 30617, 30615, 30941, 30953, 30949, 30954, 30942, 30947, 30939, + 30945, 30946, 30957, 30943, 30944, 31140, 31300, 31304, 31303, 31414, + 31416, 31413, 31409, 31415, 31710, 31715, 31719, 31709, 31701, 31717, + 31706, 31720, 31737, 31700, 31722, 31714, 31708, 31723, 31704, 31711, + 31954, 31956, 31959, 31952, 31953, 32274, 32289, 32279, 32268, 32287, + 32288, 32275, 32270, 32284, 32277, 32282, 32290, 32267, 32271, 32278, + 32269, 32276, 32293, 32292, 32579, 32635, 32636, 32634, 32689, 32751, + 32810, 32809, 32876, 33201, 33190, 33198, 33209, 33205, 33195, 33200, + 33196, 33204, 33202, 33207, 33191, 33266, 33365, 33366, 33367, 34134, + 34117, 34155, 34125, 34131, 34145, 34136, 34112, 34118, 34148, 34113, + 34146, 34116, 34129, 34119, 34147, 34110, 34139, 34161, 34126, 34158, + 34165, 34133, 34151, 34144, 34188, 34150, 34141, 34132, 34149, 34156, + 34403, 34405, 34404, 34715, 34703, 34711, 34707, 34706, 34696, 34689, + 34710, 34712, 34681, 34695, 34723, 34693, 34704, 34705, 34717, 34692, + 34708, 34716, 34714, 34697, 35102, 35110, 35120, 35117, 35118, 35111, + 35121, 35106, 35113, 35107, 35119, 35116, 35103, 35313, 35552, 35554, + 35570, 35572, 35573, 35549, 35604, 35556, 35551, 35568, 35528, 35550, + 35553, 35560, 35583, 35567, 35579, 35985, 35986, 35984, 36085, 36078, + 36081, 36080, 36083, 36204, 36206, 36261, 36263, 36403, 36414, 36408, + 36416, 36421, 36406, 36412, 36413, 36417, 36400, 36415, 36541, 36662, + 36654, 36661, 36658, 36665, 36663, 36660, 36982, 36985, 36987, 36998, + 37114, 37171, 37173, 37174, 37267, 37264, 37265, 37261, 37263, 37671, + 37662, 37640, 37663, 37638, 37647, 37754, 37688, 37692, 37659, 37667, + 37650, 37633, 37702, 37677, 37646, 37645, 37579, 37661, 37626, 37669, + 37651, 37625, 37623, 37684, 37634, 37668, 37631, 37673, 37689, 37685, + 37674, 37652, 37644, 37643, 37630, 37641, 37632, 37627, 37654, 38332, + 38349, 38334, 38329, 38330, 38326, 38335, 38325, 38333, 38569, 38612, + 38667, 38674, 38672, 38809, 38807, 38804, 38896, 38904, 38965, 38959, + 38962, 39204, 39199, 39207, 39209, 39326, 39406, 39404, 39397, 39396, + 39408, 39395, 39402, 39401, 39399, 39609, 39615, 39604, 39611, 39670, + 39674, 39673, 39671, 39731, 39808, 39813, 39815, 39804, 39806, 39803, + 39810, 39827, 39826, 39824, 39802, 39829, 39805, 39816, 40229, 40215, + 40224, 40222, 40212, 40233, 40221, 40216, 40226, 40208, 40217, 40223, + 40584, 40582, 40583, 40622, 40621, 40661, 40662, 40698, 40722, 40765, + 20774, 20773, 20770, 20772, 20768, 20777, 21236, 22163, 22156, 22157, + 22150, 22148, 22147, 22142, 22146, 22143, 22145, 22742, 22740, 22735, + 22738, 23341, 23333, 23346, 23331, 23340, 23335, 23334, 23343, 23342, + 23419, 23537, 23538, 23991, 24172, 24170, 24510, 24507, 25027, 25013, + 25020, 25063, 25056, 25061, 25060, 25064, 25054, 25839, 25833, 25827, + 25835, 25828, 25832, 25985, 25984, 26038, 26074, 26322, 27277, 27286, + 27265, 27301, 27273, 27295, 27291, 27297, 27294, 27271, 27283, 27278, + 27285, 27267, 27304, 27300, 27281, 27263, 27302, 27290, 27269, 27276, + 27282, 27483, 27565, 27657, 28620, 28585, 28660, 28628, 28643, 28636, + 28653, 28647, 28646, 28638, 28658, 28637, 28642, 28648, 29153, 29169, + 29160, 29170, 29156, 29168, 29154, 29555, 29550, 29551, 29847, 29874, + 29867, 29840, 29866, 29869, 29873, 29861, 29871, 29968, 29969, 29970, + 29967, 30084, 30275, 30280, 30281, 30279, 30372, 30441, 30645, 30635, + 30642, 30647, 30646, 30644, 30641, 30632, 30704, 30963, 30973, 30978, + 30971, 30972, 30962, 30981, 30969, 30974, 30980, 31147, 31144, 31324, + 31323, 31318, 31320, 31316, 31322, 31422, 31424, 31425, 31749, 31759, + 31730, 31744, 31743, 31739, 31758, 31732, 31755, 31731, 31746, 31753, + 31747, 31745, 31736, 31741, 31750, 31728, 31729, 31760, 31754, 31976, + 32301, 32316, 32322, 32307, 38984, 32312, 32298, 32329, 32320, 32327, + 32297, 32332, 32304, 32315, 32310, 32324, 32314, 32581, 32639, 32638, + 32637, 32756, 32754, 32812, 33211, 33220, 33228, 33226, 33221, 33223, + 33212, 33257, 33371, 33370, 33372, 34179, 34176, 34191, 34215, 34197, + 34208, 34187, 34211, 34171, 34212, 34202, 34206, 34167, 34172, 34185, + 34209, 34170, 34168, 34135, 34190, 34198, 34182, 34189, 34201, 34205, + 34177, 34210, 34178, 34184, 34181, 34169, 34166, 34200, 34192, 34207, + 34408, 34750, 34730, 34733, 34757, 34736, 34732, 34745, 34741, 34748, + 34734, 34761, 34755, 34754, 34764, 34743, 34735, 34756, 34762, 34740, + 34742, 34751, 34744, 34749, 34782, 34738, 35125, 35123, 35132, 35134, + 35137, 35154, 35127, 35138, 35245, 35247, 35246, 35314, 35315, 35614, + 35608, 35606, 35601, 35589, 35595, 35618, 35599, 35602, 35605, 35591, + 35597, 35592, 35590, 35612, 35603, 35610, 35919, 35952, 35954, 35953, + 35951, 35989, 35988, 36089, 36207, 36430, 36429, 36435, 36432, 36428, + 36423, 36675, 36672, 36997, 36990, 37176, 37274, 37282, 37275, 37273, + 37279, 37281, 37277, 37280, 37793, 37763, 37807, 37732, 37718, 37703, + 37756, 37720, 37724, 37750, 37705, 37712, 37713, 37728, 37741, 37775, + 37708, 37738, 37753, 37719, 37717, 37714, 37711, 37745, 37751, 37755, + 37729, 37726, 37731, 37735, 37760, 37710, 37721, 38343, 38336, 38345, + 38339, 38341, 38327, 38574, 38576, 38572, 38688, 38687, 38680, 38685, + 38681, 38810, 38817, 38812, 38814, 38813, 38869, 38868, 38897, 38977, + 38980, 38986, 38985, 38981, 38979, 39205, 39211, 39212, 39210, 39219, + 39218, 39215, 39213, 39217, 39216, 39320, 39331, 39329, 39426, 39418, + 39412, 39415, 39417, 39416, 39414, 39419, 39421, 39422, 39420, 39427, + 39614, 39678, 39677, 39681, 39676, 39752, 39834, 39848, 39838, 39835, + 39846, 39841, 39845, 39844, 39814, 39842, 39840, 39855, 40243, 40257, + 40295, 40246, 40238, 40239, 40241, 40248, 40240, 40261, 40258, 40259, + 40254, 40247, 40256, 40253, 32757, 40237, 40586, 40585, 40589, 40624, + 40648, 40666, 40699, 40703, 40740, 40739, 40738, 40788, 40864, 20785, + 20781, 20782, 22168, 22172, 22167, 22170, 22173, 22169, 22896, 23356, + 23657, 23658, 24000, 24173, 24174, 25048, 25055, 25069, 25070, 25073, + 25066, 25072, 25067, 25046, 25065, 25855, 25860, 25853, 25848, 25857, + 25859, 25852, 26004, 26075, 26330, 26331, 26328, 27333, 27321, 27325, + 27361, 27334, 27322, 27318, 27319, 27335, 27316, 27309, 27486, 27593, + 27659, 28679, 28684, 28685, 28673, 28677, 28692, 28686, 28671, 28672, + 28667, 28710, 28668, 28663, 28682, 29185, 29183, 29177, 29187, 29181, + 29558, 29880, 29888, 29877, 29889, 29886, 29878, 29883, 29890, 29972, + 29971, 30300, 30308, 30297, 30288, 30291, 30295, 30298, 30374, 30397, + 30444, 30658, 30650, 30975, 30988, 30995, 30996, 30985, 30992, 30994, + 30993, 31149, 31148, 31327, 31772, 31785, 31769, 31776, 31775, 31789, + 31773, 31782, 31784, 31778, 31781, 31792, 32348, 32336, 32342, 32355, + 32344, 32354, 32351, 32337, 32352, 32343, 32339, 32693, 32691, 32759, + 32760, 32885, 33233, 33234, 33232, 33375, 33374, 34228, 34246, 34240, + 34243, 34242, 34227, 34229, 34237, 34247, 34244, 34239, 34251, 34254, + 34248, 34245, 34225, 34230, 34258, 34340, 34232, 34231, 34238, 34409, + 34791, 34790, 34786, 34779, 34795, 34794, 34789, 34783, 34803, 34788, + 34772, 34780, 34771, 34797, 34776, 34787, 34724, 34775, 34777, 34817, + 34804, 34792, 34781, 35155, 35147, 35151, 35148, 35142, 35152, 35153, + 35145, 35626, 35623, 35619, 35635, 35632, 35637, 35655, 35631, 35644, + 35646, 35633, 35621, 35639, 35622, 35638, 35630, 35620, 35643, 35645, + 35642, 35906, 35957, 35993, 35992, 35991, 36094, 36100, 36098, 36096, + 36444, 36450, 36448, 36439, 36438, 36446, 36453, 36455, 36443, 36442, + 36449, 36445, 36457, 36436, 36678, 36679, 36680, 36683, 37160, 37178, + 37179, 37182, 37288, 37285, 37287, 37295, 37290, 37813, 37772, 37778, + 37815, 37787, 37789, 37769, 37799, 37774, 37802, 37790, 37798, 37781, + 37768, 37785, 37791, 37773, 37809, 37777, 37810, 37796, 37800, 37812, + 37795, 37797, 38354, 38355, 38353, 38579, 38615, 38618, 24002, 38623, + 38616, 38621, 38691, 38690, 38693, 38828, 38830, 38824, 38827, 38820, + 38826, 38818, 38821, 38871, 38873, 38870, 38872, 38906, 38992, 38993, + 38994, 39096, 39233, 39228, 39226, 39439, 39435, 39433, 39437, 39428, + 39441, 39434, 39429, 39431, 39430, 39616, 39644, 39688, 39684, 39685, + 39721, 39733, 39754, 39756, 39755, 39879, 39878, 39875, 39871, 39873, + 39861, 39864, 39891, 39862, 39876, 39865, 39869, 40284, 40275, 40271, + 40266, 40283, 40267, 40281, 40278, 40268, 40279, 40274, 40276, 40287, + 40280, 40282, 40590, 40588, 40671, 40705, 40704, 40726, 40741, 40747, + 40746, 40745, 40744, 40780, 40789, 20788, 20789, 21142, 21239, 21428, + 22187, 22189, 22182, 22183, 22186, 22188, 22746, 22749, 22747, 22802, + 23357, 23358, 23359, 24003, 24176, 24511, 25083, 25863, 25872, 25869, + 25865, 25868, 25870, 25988, 26078, 26077, 26334, 27367, 27360, 27340, + 27345, 27353, 27339, 27359, 27356, 27344, 27371, 27343, 27341, 27358, + 27488, 27568, 27660, 28697, 28711, 28704, 28694, 28715, 28705, 28706, + 28707, 28713, 28695, 28708, 28700, 28714, 29196, 29194, 29191, 29186, + 29189, 29349, 29350, 29348, 29347, 29345, 29899, 29893, 29879, 29891, + 29974, 30304, 30665, 30666, 30660, 30705, 31005, 31003, 31009, 31004, + 30999, 31006, 31152, 31335, 31336, 31795, 31804, 31801, 31788, 31803, + 31980, 31978, 32374, 32373, 32376, 32368, 32375, 32367, 32378, 32370, + 32372, 32360, 32587, 32586, 32643, 32646, 32695, 32765, 32766, 32888, + 33239, 33237, 33380, 33377, 33379, 34283, 34289, 34285, 34265, 34273, + 34280, 34266, 34263, 34284, 34290, 34296, 34264, 34271, 34275, 34268, + 34257, 34288, 34278, 34287, 34270, 34274, 34816, 34810, 34819, 34806, + 34807, 34825, 34828, 34827, 34822, 34812, 34824, 34815, 34826, 34818, + 35170, 35162, 35163, 35159, 35169, 35164, 35160, 35165, 35161, 35208, + 35255, 35254, 35318, 35664, 35656, 35658, 35648, 35667, 35670, 35668, + 35659, 35669, 35665, 35650, 35666, 35671, 35907, 35959, 35958, 35994, + 36102, 36103, 36105, 36268, 36266, 36269, 36267, 36461, 36472, 36467, + 36458, 36463, 36475, 36546, 36690, 36689, 36687, 36688, 36691, 36788, + 37184, 37183, 37296, 37293, 37854, 37831, 37839, 37826, 37850, 37840, + 37881, 37868, 37836, 37849, 37801, 37862, 37834, 37844, 37870, 37859, + 37845, 37828, 37838, 37824, 37842, 37863, 38269, 38362, 38363, 38625, + 38697, 38699, 38700, 38696, 38694, 38835, 38839, 38838, 38877, 38878, + 38879, 39004, 39001, 39005, 38999, 39103, 39101, 39099, 39102, 39240, + 39239, 39235, 39334, 39335, 39450, 39445, 39461, 39453, 39460, 39451, + 39458, 39456, 39463, 39459, 39454, 39452, 39444, 39618, 39691, 39690, + 39694, 39692, 39735, 39914, 39915, 39904, 39902, 39908, 39910, 39906, + 39920, 39892, 39895, 39916, 39900, 39897, 39909, 39893, 39905, 39898, + 40311, 40321, 40330, 40324, 40328, 40305, 40320, 40312, 40326, 40331, + 40332, 40317, 40299, 40308, 40309, 40304, 40297, 40325, 40307, 40315, + 40322, 40303, 40313, 40319, 40327, 40296, 40596, 40593, 40640, 40700, + 40749, 40768, 40769, 40781, 40790, 40791, 40792, 21303, 22194, 22197, + 22195, 22755, 23365, 24006, 24007, 24302, 24303, 24512, 24513, 25081, + 25879, 25878, 25877, 25875, 26079, 26344, 26339, 26340, 27379, 27376, + 27370, 27368, 27385, 27377, 27374, 27375, 28732, 28725, 28719, 28727, + 28724, 28721, 28738, 28728, 28735, 28730, 28729, 28736, 28731, 28723, + 28737, 29203, 29204, 29352, 29565, 29564, 29882, 30379, 30378, 30398, + 30445, 30668, 30670, 30671, 30669, 30706, 31013, 31011, 31015, 31016, + 31012, 31017, 31154, 31342, 31340, 31341, 31479, 31817, 31816, 31818, + 31815, 31813, 31982, 32379, 32382, 32385, 32384, 32698, 32767, 32889, + 33243, 33241, 33291, 33384, 33385, 34338, 34303, 34305, 34302, 34331, + 34304, 34294, 34308, 34313, 34309, 34316, 34301, 34841, 34832, 34833, + 34839, 34835, 34838, 35171, 35174, 35257, 35319, 35680, 35690, 35677, + 35688, 35683, 35685, 35687, 35693, 36270, 36486, 36488, 36484, 36697, + 36694, 36695, 36693, 36696, 36698, 37005, 37187, 37185, 37303, 37301, + 37298, 37299, 37899, 37907, 37883, 37920, 37903, 37908, 37886, 37909, + 37904, 37928, 37913, 37901, 37877, 37888, 37879, 37895, 37902, 37910, + 37906, 37882, 37897, 37880, 37898, 37887, 37884, 37900, 37878, 37905, + 37894, 38366, 38368, 38367, 38702, 38703, 38841, 38843, 38909, 38910, + 39008, 39010, 39011, 39007, 39105, 39106, 39248, 39246, 39257, 39244, + 39243, 39251, 39474, 39476, 39473, 39468, 39466, 39478, 39465, 39470, + 39480, 39469, 39623, 39626, 39622, 39696, 39698, 39697, 39947, 39944, + 39927, 39941, 39954, 39928, 40000, 39943, 39950, 39942, 39959, 39956, + 39945, 40351, 40345, 40356, 40349, 40338, 40344, 40336, 40347, 40352, + 40340, 40348, 40362, 40343, 40353, 40346, 40354, 40360, 40350, 40355, + 40383, 40361, 40342, 40358, 40359, 40601, 40603, 40602, 40677, 40676, + 40679, 40678, 40752, 40750, 40795, 40800, 40798, 40797, 40793, 40849, + 20794, 20793, 21144, 21143, 22211, 22205, 22206, 23368, 23367, 24011, + 24015, 24305, 25085, 25883, 27394, 27388, 27395, 27384, 27392, 28739, + 28740, 28746, 28744, 28745, 28741, 28742, 29213, 29210, 29209, 29566, + 29975, 30314, 30672, 31021, 31025, 31023, 31828, 31827, 31986, 32394, + 32391, 32392, 32395, 32390, 32397, 32589, 32699, 32816, 33245, 34328, + 34346, 34342, 34335, 34339, 34332, 34329, 34343, 34350, 34337, 34336, + 34345, 34334, 34341, 34857, 34845, 34843, 34848, 34852, 34844, 34859, + 34890, 35181, 35177, 35182, 35179, 35322, 35705, 35704, 35653, 35706, + 35707, 36112, 36116, 36271, 36494, 36492, 36702, 36699, 36701, 37190, + 37188, 37189, 37305, 37951, 37947, 37942, 37929, 37949, 37948, 37936, + 37945, 37930, 37943, 37932, 37952, 37937, 38373, 38372, 38371, 38709, + 38714, 38847, 38881, 39012, 39113, 39110, 39104, 39256, 39254, 39481, + 39485, 39494, 39492, 39490, 39489, 39482, 39487, 39629, 39701, 39703, + 39704, 39702, 39738, 39762, 39979, 39965, 39964, 39980, 39971, 39976, + 39977, 39972, 39969, 40375, 40374, 40380, 40385, 40391, 40394, 40399, + 40382, 40389, 40387, 40379, 40373, 40398, 40377, 40378, 40364, 40392, + 40369, 40365, 40396, 40371, 40397, 40370, 40570, 40604, 40683, 40686, + 40685, 40731, 40728, 40730, 40753, 40782, 40805, 40804, 40850, 20153, + 22214, 22213, 22219, 22897, 23371, 23372, 24021, 24017, 24306, 25889, + 25888, 25894, 25890, 27403, 27400, 27401, 27661, 28757, 28758, 28759, + 28754, 29214, 29215, 29353, 29567, 29912, 29909, 29913, 29911, 30317, + 30381, 31029, 31156, 31344, 31345, 31831, 31836, 31833, 31835, 31834, + 31988, 31985, 32401, 32591, 32647, 33246, 33387, 34356, 34357, 34355, + 34348, 34354, 34358, 34860, 34856, 34854, 34858, 34853, 35185, 35263, + 35262, 35323, 35710, 35716, 35714, 35718, 35717, 35711, 36117, 36501, + 36500, 36506, 36498, 36496, 36502, 36503, 36704, 36706, 37191, 37964, + 37968, 37962, 37963, 37967, 37959, 37957, 37960, 37961, 37958, 38719, + 38883, 39018, 39017, 39115, 39252, 39259, 39502, 39507, 39508, 39500, + 39503, 39496, 39498, 39497, 39506, 39504, 39632, 39705, 39723, 39739, + 39766, 39765, 40006, 40008, 39999, 40004, 39993, 39987, 40001, 39996, + 39991, 39988, 39986, 39997, 39990, 40411, 40402, 40414, 40410, 40395, + 40400, 40412, 40401, 40415, 40425, 40409, 40408, 40406, 40437, 40405, + 40413, 40630, 40688, 40757, 40755, 40754, 40770, 40811, 40853, 40866, + 20797, 21145, 22760, 22759, 22898, 23373, 24024, 34863, 24399, 25089, + 25091, 25092, 25897, 25893, 26006, 26347, 27409, 27410, 27407, 27594, + 28763, 28762, 29218, 29570, 29569, 29571, 30320, 30676, 31847, 31846, + 32405, 33388, 34362, 34368, 34361, 34364, 34353, 34363, 34366, 34864, + 34866, 34862, 34867, 35190, 35188, 35187, 35326, 35724, 35726, 35723, + 35720, 35909, 36121, 36504, 36708, 36707, 37308, 37986, 37973, 37981, + 37975, 37982, 38852, 38853, 38912, 39510, 39513, 39710, 39711, 39712, + 40018, 40024, 40016, 40010, 40013, 40011, 40021, 40025, 40012, 40014, + 40443, 40439, 40431, 40419, 40427, 40440, 40420, 40438, 40417, 40430, + 40422, 40434, 40432, 40418, 40428, 40436, 40435, 40424, 40429, 40642, + 40656, 40690, 40691, 40710, 40732, 40760, 40759, 40758, 40771, 40783, + 40817, 40816, 40814, 40815, 22227, 22221, 23374, 23661, 25901, 26349, + 26350, 27411, 28767, 28769, 28765, 28768, 29219, 29915, 29925, 30677, + 31032, 31159, 31158, 31850, 32407, 32649, 33389, 34371, 34872, 34871, + 34869, 34891, 35732, 35733, 36510, 36511, 36512, 36509, 37310, 37309, + 37314, 37995, 37992, 37993, 38629, 38726, 38723, 38727, 38855, 38885, + 39518, 39637, 39769, 40035, 40039, 40038, 40034, 40030, 40032, 40450, + 40446, 40455, 40451, 40454, 40453, 40448, 40449, 40457, 40447, 40445, + 40452, 40608, 40734, 40774, 40820, 40821, 40822, 22228, 25902, 26040, + 27416, 27417, 27415, 27418, 28770, 29222, 29354, 30680, 30681, 31033, + 31849, 31851, 31990, 32410, 32408, 32411, 32409, 33248, 33249, 34374, + 34375, 34376, 35193, 35194, 35196, 35195, 35327, 35736, 35737, 36517, + 36516, 36515, 37998, 37997, 37999, 38001, 38003, 38729, 39026, 39263, + 40040, 40046, 40045, 40459, 40461, 40464, 40463, 40466, 40465, 40609, + 40693, 40713, 40775, 40824, 40827, 40826, 40825, 22302, 28774, 31855, + 34876, 36274, 36518, 37315, 38004, 38008, 38006, 38005, 39520, 40052, + 40051, 40049, 40053, 40468, 40467, 40694, 40714, 40868, 28776, 28773, + 31991, 34410, 34878, 34877, 34879, 35742, 35996, 36521, 36553, 38731, + 39027, 39028, 39116, 39265, 39339, 39524, 39526, 39527, 39716, 40469, + 40471, 40776, 25095, 27422, 29223, 34380, 36520, 38018, 38016, 38017, + 39529, 39528, 39726, 40473, 29225, 34379, 35743, 38019, 40057, 40631, + 30325, 39531, 40058, 40477, 28777, 28778, 40612, 40830, 40777, 40856, + 30849, 37561, 35023, 22715, 24658, 31911, 23290, 9556, 9574, 9559, 9568, + 9580, 9571, 9562, 9577, 9565, 9554, 9572, 9557, 9566, 9578, 9569, 9560, + 9575, 9563, 9555, 9573, 9558, 9567, 9579, 9570, 9561, 9576, 9564, 9553, + 9552, 9581, 9582, 9584, 9583, 65517, 1351, 37595, 1503, 16325, 34124, + 17077, 29679, 20917, 13897, 18754, 35300, 37700, 6619, 33518, 15560, 30780, + 26436, 25311, 18739, 35242, 672, 27571, 4869, 20395, 9453, 20488, 27945, + 31364, 13824, 19121, 9491, 20521, 894, 24484, 896, 839, 28379, 1055, 20605, + 20737, 13434, 20750, 39020, 14147, 33814, 18852, 1159, 20832, 13236, 20842, + 3071, 8444, 741, 9520, 1422, 12851, 6531, 23426, 34685, 1459, 15513, 20914, + 20920, 40244, 20937, 20943, 20945, 15580, 20947, 19110, 20915, 20962, + 21314, 20973, 33741, 26942, 14125, 24443, 21003, 21030, 21052, 21173, + 21079, 21140, 21177, 21189, 31765, 34114, 21216, 34317, 27411, 21253, + 35550, 21833, 28377, 16256, 2388, 16364, 21299, 21316, 3042, 27851, 5926, + 26651, 29653, 24650, 16042, 14540, 5864, 29149, 17570, 21357, 21364, 34475, + 21374, 21375, 5526, 5651, 30694, 21395, 35483, 21408, 21419, 21422, 29607, + 22386, 16217, 29596, 21441, 21445, 27721, 20041, 22526, 21465, 15019, 2959, + 21472, 16363, 11683, 21494, 3191, 21523, 28793, 21803, 26199, 27995, 21613, + 27475, 3444, 21853, 21647, 21668, 18342, 5901, 3805, 15796, 3405, 35260, + 9880, 21831, 19693, 21551, 29719, 21894, 21929, 22021, 6359, 16442, 17746, + 17461, 26291, 4276, 22071, 26317, 12938, 26276, 26285, 22093, 22095, 30961, + 22257, 38791, 21502, 22272, 22255, 22253, 35686, 13859, 4687, 22342, 16805, + 27758, 28811, 22338, 14001, 27774, 22502, 5142, 22531, 5204, 17251, 22566, + 19445, 22620, 22698, 13665, 22752, 22748, 4668, 22779, 23551, 22339, 41296, + 17016, 37843, 13729, 22815, 26790, 14019, 28249, 5694, 23076, 21843, 5778, + 34053, 22985, 3406, 27777, 27946, 6108, 23001, 6139, 6066, 28070, 28017, + 6184, 5845, 23033, 28229, 23211, 23139, 14054, 18857, 23159, 14088, 23190, + 29797, 23251, 28577, 9556, 15749, 6417, 14130, 5816, 24195, 21200, 23414, + 25992, 23420, 31246, 16388, 18525, 516, 23509, 24928, 6708, 22988, 1445, + 23539, 23453, 19728, 23557, 6980, 23571, 29646, 23572, 7333, 27432, 23625, + 18653, 23685, 23785, 23791, 23947, 7673, 7735, 23824, 23832, 23878, 7844, + 23738, 24023, 33532, 14381, 18689, 8265, 8563, 33415, 14390, 15298, 24110, + 27274, 24181, 24186, 17596, 3283, 21414, 20151, 24272, 21416, 6001, 24073, + 24308, 33922, 24313, 24315, 14496, 24316, 26686, 37915, 24333, 449, 63636, + 15070, 18606, 4922, 24378, 26760, 9168, 24408, 9329, 24419, 38845, 28270, + 24434, 37696, 35382, 24487, 23990, 15711, 21072, 8042, 28920, 9832, 37334, + 670, 35369, 24625, 26245, 6263, 14691, 15815, 13881, 22416, 10164, 31089, + 15936, 24734, 24740, 24755, 18818, 18831, 31315, 29860, 20705, 23200, + 24932, 33828, 24898, 63654, 28370, 24961, 20980, 1622, 24967, 23466, 16311, + 10335, 25043, 35741, 39261, 25040, 14642, 10624, 10433, 24611, 24924, + 25886, 25483, 280, 25285, 6000, 25301, 11789, 25452, 18911, 14871, 25656, + 25592, 5006, 6140, 25744, 28554, 11830, 38932, 16524, 22301, 25825, 25829, + 38011, 14950, 25658, 14935, 25933, 28438, 18984, 18979, 25989, 25965, + 25951, 12414, 26037, 18752, 19255, 26065, 16600, 6185, 26080, 26083, 24543, + 13312, 26136, 12791, 12792, 26180, 12708, 12709, 26187, 3701, 26215, 20966, + 26227, 26228, 7741, 12849, 34292, 12744, 21267, 30661, 10487, 39332, 26370, + 17308, 18977, 15147, 27130, 14274, 26462, 26471, 26466, 16845, 37101, + 26583, 17641, 26658, 28240, 37436, 26625, 13286, 28064, 26717, 13423, + 27105, 27147, 35551, 26995, 26819, 13773, 26881, 26880, 15666, 14849, + 13884, 15232, 26540, 26977, 35402, 17148, 26934, 27032, 15265, 969, 33635, + 20624, 27129, 13913, 8490, 27205, 14083, 27293, 15347, 26545, 27336, 37276, + 15373, 27421, 2339, 24798, 27445, 27508, 10189, 28341, 15067, 949, 6488, + 14144, 21537, 15194, 27617, 16124, 27612, 27703, 9355, 18673, 27473, 27738, + 33318, 27769, 15804, 17605, 15805, 16804, 18700, 18688, 15561, 14053, + 15595, 3378, 39811, 12793, 9361, 32655, 26679, 27941, 28065, 28139, 28054, + 27996, 28284, 28420, 18815, 16517, 28274, 34099, 28532, 20935, 27804, + 28189, 33838, 35617, 28207, 15919, 29779, 16258, 31180, 28239, 23185, + 12363, 28664, 14093, 28573, 15920, 28410, 5271, 16445, 17749, 37872, 28484, + 28508, 15694, 28532, 37232, 15675, 28575, 16708, 28627, 16529, 16725, + 16441, 16368, 16308, 16703, 20959, 16726, 16727, 16704, 25053, 28747, + 28798, 28839, 28801, 28876, 28885, 28886, 28895, 16644, 15848, 29108, + 29078, 17015, 28971, 28997, 23176, 29002, 29038, 23708, 17253, 29007, + 37730, 17089, 28972, 17498, 18983, 18978, 29114, 35816, 28861, 29198, + 37954, 29205, 22801, 37955, 29220, 37697, 22021, 29230, 29248, 18804, + 26813, 29269, 29271, 15957, 12356, 26637, 28477, 29314, 29482, 29483, + 18467, 34859, 18669, 34820, 29480, 29486, 29647, 29610, 3130, 27182, 29641, + 29769, 16866, 5863, 18980, 26147, 14021, 18871, 18829, 18939, 29687, 29717, + 26883, 18982, 29753, 1475, 16087, 29788, 10413, 29792, 36530, 29767, 29668, + 29814, 33721, 29804, 14128, 29812, 37873, 27180, 29826, 18771, 19084, + 16735, 19065, 35727, 23366, 35843, 6302, 29896, 6536, 29966, 29929, 29982, + 36569, 6731, 23511, 36524, 37765, 30029, 30026, 30055, 30062, 20354, 16132, + 19731, 30094, 29789, 30110, 30132, 30210, 30252, 30289, 30287, 30319, + 30326, 25589, 30352, 33263, 14328, 26897, 26894, 30369, 30373, 30391, + 30412, 28575, 33890, 20637, 20861, 7708, 30494, 30502, 30528, 25775, 21024, + 30552, 12972, 30639, 35172, 35176, 5825, 30708, 30729, 4982, 18962, 26826, + 30895, 30919, 30931, 38565, 31022, 21984, 30935, 31028, 30897, 30220, + 36792, 34948, 35627, 24707, 9756, 31110, 35072, 26882, 31104, 22615, 31133, + 31545, 31036, 31145, 28202, 28966, 16040, 31174, 37133, 31188, +]; + +static FORWARD_TABLE_MORE: &'static [u32] = &[ + 1147077920, 3095548431, 1073742072, 72263968, 0, 68404, 0, 0, 0, 201326592, + 64, 0, 5768192, 60, 1551892480, 3153321133, 3991815113, 3240497060, + 4025644699, 4160420830, 2940482063, 4278054910, 11558929, 2165907712, + 2827489312, 610869600, 3297330176, 1073938432, 2218983477, 1754485041, 514, + 0, 0, 16793600, 2187635840, 2426506304, 3563081732, 405459456, 2536859805, + 553179215, 672957124, 43283842, 2711633976, 1299255493, 3113749956, + 1124162398, 2013501855, 136307232, 1086914953, 2584544007, 1339118224, + 553780092, 326025248, 4124816771, 1334867941, 389454359, 3127771148, + 1415589641, 1752702464, 2656464930, 3079598885, 3874425623, 458954615, + 2375553217, 3484817426, 443691265, 3233164379, 1556341280, 3672120194, + 1087800782, 3490403497, 1078216719, 1087637776, 509885358, 135736132, + 406225542, 2632419744, 58984539, 3968915970, 3213199323, 2392698274, + 622893213, 2672164934, 3386237823, 1305932932, 414638854, 2322, 1024, 32, + 512, 0, 536870912, 0, 0, 0, 2382364680, 1063218808, 4148026750, 2935790588, + 1804599250, 3133138929, 4011290286, 3057559516, 2462676917, 1253483991, + 2176424814, 1425958733, 4267875313, 920081007, 1160364030, 1706948993, + 3752614, 2405450240, 1077974016, 3520573394, 2560622811, 1376156594, + 3356923936, 2365, 1, 145885697, 128, 337676292, 19472, 1151401988, + 21037072, 4030728192, 151519, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2189426688, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3190490752, 4272953022, 528396, 2567449034, 202063888, 2449467, 411227178, + 2184044104, 411509781, 562094360, 2022888193, 2466480659, 885346509, + 2913085632, 1478007164, 1120150034, 1049514914, 1162011085, 259952692, + 24412416, 965050898, 3724552519, 2281783650, 2174567329, 4760008, +]; + +/// Returns the index code point for pointer `code` in this index. +#[inline] +pub fn forward(code: u16) -> u32 { + let code = (code as usize).wrapping_sub(942); + if code < 18840 { + (FORWARD_TABLE[code] as u32) | (((FORWARD_TABLE_MORE[code >> 5] >> (code & 31)) & 1) << 17) + } else { + 0xffff + } +} + +static BACKWARD_TABLE_LOWER: &'static [u16] = &[ + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5103, 10951, 65535, 65535, 65535, 65535, 65535, 65535, + 5120, 5205, 5137, 65535, 65535, 65535, 65535, 65535, 5040, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1124, 1122, 65535, 65535, 65535, + 65535, 65535, 65535, 1128, 1126, 1137, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1132, 1130, 65535, 65535, 65535, 5135, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1141, 1139, 65535, 65535, 65535, 65535, + 65535, 65535, 1146, 1144, 1168, 65535, 1150, 1148, 65535, 65535, 65535, + 65535, 1154, 1152, 65535, 65535, 65535, 5136, 11300, 1158, 1156, 65535, + 1163, 65535, 65535, 65535, 1121, 1138, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1125, 1143, 65535, 65535, 65535, 65535, 65535, 65535, 1127, 1145, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1147, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 11301, 1129, 1151, 65535, 65535, 65535, 65535, 65535, 11299, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1155, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1123, 1140, 65535, + 1149, 1131, 1153, 65535, 1157, 65535, 1159, 65535, 1160, 65535, 1161, + 65535, 1162, 65535, 65535, 65535, 11295, 1142, 65535, 65535, 11297, 65535, + 65535, 65535, 65535, 65535, 65535, 11296, 65535, 65535, 65535, 65535, + 65535, 1169, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 11303, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 11298, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 11294, 65535, 65535, 65535, 65535, 65535, + 65535, 11302, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 10952, 5430, 65535, 5428, 5429, 5431, 65535, 5123, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5427, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5342, 5343, + 5344, 5345, 5346, 5347, 5348, 5349, 5350, 5351, 5352, 5353, 5354, 5355, + 5356, 5357, 5358, 65535, 5359, 5360, 5361, 5362, 5363, 5364, 5365, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5366, 5367, 5368, 5369, 5370, + 5371, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, + 65535, 5383, 5384, 5385, 5386, 5387, 5388, 5389, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 11141, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 11135, + 11136, 11137, 11138, 11139, 11140, 11142, 11143, 11144, 11145, 11146, + 11147, 11148, 11149, 11150, 11151, 11152, 11153, 11154, 11155, 11156, + 11157, 11158, 11159, 11160, 11161, 11162, 11163, 11164, 11165, 11166, + 11167, 11168, 11169, 11170, 11171, 11172, 11173, 11175, 11176, 11177, + 11178, 11179, 11180, 11181, 11182, 11183, 11184, 11185, 11186, 11187, + 11188, 11189, 11190, 11191, 11192, 11193, 11194, 11195, 11196, 11197, + 11198, 11199, 11200, 65535, 11174, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1134, 1165, 1136, 1167, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5046, 5048, 65535, 65535, 65535, 5091, 5092, 65535, + 65535, 5093, 5094, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5036, + 5035, 5029, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5098, 65535, 65535, 5097, 65535, 65535, 65535, 65535, 65535, 5102, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5465, 65535, 65535, 65535, 65535, + 65535, 65535, 5191, 65535, 5119, 65535, 65535, 65535, 5192, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 11259, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 11260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5268, 5269, 5270, 5271, 5272, + 5273, 5274, 5275, 5276, 5277, 65535, 65535, 65535, 65535, 65535, 65535, + 10916, 10917, 10918, 10919, 10920, 10921, 10922, 10923, 10924, 10925, + 65535, 65535, 65535, 65535, 65535, 65535, 5172, 5170, 5173, 5171, 65535, + 65535, 5174, 5175, 5177, 5176, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 11202, 11203, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 11201, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5182, 65535, 65535, 65535, + 65535, 5138, 65535, 65535, 65535, 5145, 5158, 5157, 65535, 65535, 5179, + 65535, 5178, 65535, 65535, 65535, 5154, 5155, 5162, 65535, 65535, 5163, + 65535, 65535, 65535, 65535, 65535, 5165, 5164, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5146, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5144, 5147, 65535, 65535, 65535, 65535, 5142, 5143, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5168, 65535, 65535, 65535, 5169, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5156, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5159, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1170, 1171, 65535, 65535, 65535, 65535, 5432, 5433, 5434, 5435, + 5436, 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5446, 5447, + 5448, 5449, 5450, 5451, 5452, 5453, 5454, 5455, 5456, 5457, 5458, 5459, + 5460, 5461, 5462, 5463, 65535, 5464, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 10896, + 10897, 10898, 10899, 10900, 10901, 10902, 10903, 10904, 10905, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 10906, + 10907, 10908, 10909, 10910, 10911, 10912, 10913, 10914, 10915, 65535, + 65535, 5236, 65535, 5237, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5239, 65535, 65535, 65535, 5240, 65535, 65535, 65535, 5241, + 65535, 65535, 65535, 5242, 65535, 65535, 65535, 5234, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5233, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5232, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5231, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5230, 65535, 65535, 65535, 5247, + 18990, 18972, 18981, 18963, 18974, 18983, 18965, 18978, 18987, 18969, + 18980, 18989, 18971, 5248, 18984, 18966, 5250, 18986, 18968, 18973, 18982, + 18964, 18979, 18988, 18970, 5249, 18985, 18967, 5243, 5244, 5246, 5245, + 5255, 5256, 5257, 5050, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5215, 5216, 5217, 5218, 5219, 5220, + 5221, 5222, 5229, 5228, 5227, 5226, 5225, 5224, 5223, 65535, 65535, 65535, + 65535, 5235, 5238, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5115, 5114, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5108, 5107, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5117, 5116, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5113, 5112, 65535, 65535, + 65535, 5105, 65535, 65535, 5109, 5106, 65535, 65535, 5251, 5252, 5254, + 5253, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5111, 5110, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5166, 65535, 5167, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 10965, 65535, 65535, 11263, 65535, 65535, 65535, + 11264, 65535, 11265, 11266, 11267, 65535, 11268, 65535, 11269, 11270, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 11271, 65535, 65535, + 65535, 65535, 65535, 65535, 11272, 11273, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 11274, 65535, 11275, 65535, 65535, 11276, 65535, + 11277, 65535, 11278, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 11279, 65535, 65535, 65535, 65535, 65535, 11280, 65535, 11281, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 11282, 65535, 65535, 65535, + 11283, 65535, 11284, 11285, 65535, 11286, 65535, 65535, 65535, 65535, + 65535, 65535, 11287, 11288, 65535, 65535, 65535, 65535, 65535, 65535, + 11289, 65535, 65535, 65535, 65535, 11290, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 10940, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5024, 5026, 5027, 5104, 65535, 10959, 10960, + 10961, 5073, 5074, 5069, 5070, 5077, 5078, 5081, 5082, 5065, 5066, 5186, + 65535, 5061, 5062, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5095, + 5096, 65535, 65535, 5278, 5279, 5280, 5281, 5282, 5283, 5284, 5285, 5286, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 10966, 10967, 10968, + 10969, 10970, 10971, 10972, 10973, 10974, 10975, 10976, 10977, 10978, + 10979, 10980, 10981, 10982, 10983, 10984, 10985, 10986, 10987, 10988, + 10989, 10990, 10991, 10992, 10993, 10994, 10995, 10996, 10997, 10998, + 10999, 11000, 11001, 11002, 11003, 11004, 11005, 11006, 11007, 11008, + 11009, 11010, 11011, 11012, 11013, 11014, 11015, 11016, 11017, 11018, + 11019, 11020, 11021, 11022, 11023, 11024, 11025, 11026, 11027, 11028, + 11029, 11030, 11031, 11032, 11033, 11034, 11035, 11036, 11037, 11038, + 11039, 11040, 11041, 11042, 11043, 11044, 11045, 11046, 11047, 11048, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 11261, 11262, 10955, + 10956, 65535, 65535, 11049, 11050, 11051, 11052, 11053, 11054, 11055, + 11056, 11057, 11058, 11059, 11060, 11061, 11062, 11063, 11064, 11065, + 11066, 11067, 11068, 11069, 11070, 11071, 11072, 11073, 11074, 11075, + 11076, 11077, 11078, 11079, 11080, 11081, 11082, 11083, 11084, 11085, + 11086, 11087, 11088, 11089, 11090, 11091, 11092, 11093, 11094, 11095, + 11096, 11097, 11098, 11099, 11100, 11101, 11102, 11103, 11104, 11105, + 11106, 11107, 11108, 11109, 11110, 11111, 11112, 11113, 11114, 11115, + 11116, 11117, 11118, 11119, 11120, 11121, 11122, 11123, 11124, 11125, + 11126, 11127, 11128, 11129, 11130, 11131, 11132, 11133, 11134, 65535, + 65535, 65535, 65535, 65535, 10962, 10953, 10954, 65535, 65535, 65535, + 65535, 65535, 65535, 5390, 5391, 5392, 5393, 5394, 5395, 5396, 5397, 5398, + 5399, 5400, 5401, 5402, 5403, 5404, 5405, 5406, 5407, 5408, 5409, 5410, + 5411, 5412, 5413, 5414, 5415, 5416, 5417, 5418, 5419, 5420, 5421, 5422, + 5423, 5424, 5425, 5426, 65535, 65535, 65535, 65535, 65535, 65535, 1099, + 1100, 1101, 1102, 1103, 1105, 1108, 1109, 1112, 1114, 1115, 1116, 1117, + 1119, 1120, 11204, 65535, 11258, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5118, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5202, 5203, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5197, + 5198, 5199, 65535, 65535, 5201, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5204, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5200, 65535, 65535, 5161, 5160, 65535, 65535, 5196, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2724, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3422, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1873, 65535, 1371, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2933, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4207, 65535, 65535, 65535, 65535, 65535, + 65535, 19037, 65535, 65535, 1376, 2223, 65535, 65535, 65535, 65535, 1377, + 65535, 65535, 2227, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1378, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3446, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1533, 65535, 65535, 65535, + 65535, 1692, 65535, 65535, 65535, 65535, 65535, 65535, 3575, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4572, + 65535, 65535, 65535, 65535, 4468, 65535, 1034, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4218, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1459, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1672, 65535, + 65535, 1390, 65535, 1392, 65535, 65535, 65535, 65535, 65535, 1738, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19202, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1395, 65535, 65535, + 3106, 65535, 1396, 65535, 65535, 65535, 65535, 4635, 1526, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2790, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3104, 1407, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19212, 65535, 65535, 65535, 1409, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4707, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1410, 65535, 1349, 65535, 65535, 65535, 1412, + 65535, 1388, 65535, 65535, 4402, 65535, 65535, 65535, 4536, 65535, 65535, + 65535, 4929, 65535, 65535, 65535, 4907, 65535, 65535, 65535, 65535, 3746, + 65535, 1610, 65535, 65535, 65535, 2039, 1662, 4829, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1550, 65535, 65535, 4827, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1612, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4267, 65535, 1649, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19184, 65535, 990, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4541, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4977, 65535, 65535, + 65535, 19349, 65535, 65535, 65535, 65535, 2804, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4063, 2271, 19005, 65535, 65535, 65535, 65535, + 2046, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4286, 65535, 1912, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4677, 65535, 65535, 65535, 65535, 65535, 65535, 1397, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3432, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4642, 65535, 65535, 65535, 65535, 3107, 65535, 4639, + 65535, 65535, 65535, 3542, 19191, 65535, 65535, 65535, 3256, 65535, 65535, + 65535, 4328, 65535, 65535, 3574, 65535, 65535, 65535, 65535, 2203, 65535, + 19215, 2536, 19661, 65535, 3633, 4095, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2853, 3241, 65535, 3587, 65535, 65535, + 65535, 65535, 65535, 65535, 2851, 65535, 65535, 65535, 2659, 3540, 65535, + 65535, 19532, 19238, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2821, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2849, 65535, 1638, + 65535, 65535, 65535, 65535, 19241, 65535, 3532, 65535, 65535, 19566, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4302, 65535, 65535, 65535, 65535, 65535, 2656, 2663, + 65535, 2341, 65535, 65535, 65535, 65535, 65535, 65535, 3459, 3630, 65535, + 65535, 19681, 65535, 19249, 2686, 65535, 65535, 65535, 65535, 65535, 65535, + 4471, 65535, 65535, 65535, 65535, 65535, 19512, 65535, 65535, 19040, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4178, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3984, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1602, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2837, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4016, 65535, 65535, 65535, 65535, 2597, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1895, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3222, 65535, 65535, 65535, + 65535, 65535, 19724, 65535, 65535, 4695, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1920, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2710, 65535, 65535, 65535, 65535, 65535, 65535, 1923, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19290, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19295, 65535, 1924, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2963, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1000, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19313, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2550, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19104, 65535, 65535, + 65535, 65535, 2949, 65535, 65535, 1902, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1676, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1929, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1930, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3367, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19379, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1931, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1932, 65535, 65535, 65535, 65535, 65535, 19347, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1872, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2387, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1936, 3551, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1523, 65535, 65535, 65535, 65535, 65535, 65535, 2721, + 65535, 4174, 65535, 65535, 65535, 65535, 65535, 4341, 65535, 65535, 4327, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1940, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4640, 65535, 65535, + 65535, 65535, 65535, 3166, 65535, 65535, 2594, 65535, 65535, 65535, 65535, + 65535, 65535, 1421, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1945, 65535, 65535, 1474, 65535, 65535, 1509, 65535, + 65535, 19478, 65535, 1947, 65535, 65535, 1524, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19393, 1577, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2892, 4673, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1430, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1952, 65535, 65535, 65535, 65535, 65535, 65535, 4652, 65535, 65535, + 65535, 65535, 19409, 65535, 65535, 65535, 65535, 4923, 65535, 3066, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19407, 1456, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1957, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19131, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1959, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19320, 65535, 2921, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2402, 65535, 1962, 65535, 65535, 1006, 65535, 65535, 65535, + 65535, 65535, 3045, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2507, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3040, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1964, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19451, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3827, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1966, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1969, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2593, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1973, 1972, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1974, 2359, 65535, 65535, 65535, 19480, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 953, 2956, 65535, 65535, 2952, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19487, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1981, 65535, 4168, 65535, 65535, 65535, 19296, + 65535, 2961, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2974, 65535, + 65535, 65535, 65535, 65535, 1983, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1988, 65535, 65535, + 65535, 65535, 65535, 1990, 19497, 2909, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19501, + 65535, 65535, 65535, 4389, 65535, 65535, 65535, 2687, 65535, 65535, 5001, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4306, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1749, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2000, 65535, 3548, + 65535, 65535, 65535, 4991, 65535, 65535, 65535, 65535, 3566, 65535, 65535, + 65535, 65535, 65535, 19064, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19533, 65535, + 65535, 65535, 2005, 65535, 65535, 1863, 2118, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2595, 65535, 65535, 65535, 65535, 19477, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19579, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2021, 65535, + 65535, 65535, 65535, 65535, 3554, 65535, 19576, 65535, 65535, 2509, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19336, 65535, 65535, 3413, 65535, 65535, 65535, 65535, 65535, + 65535, 3553, 2025, 65535, 65535, 65535, 65535, 3571, 65535, 65535, 65535, + 65535, 65535, 2026, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3365, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19247, 65535, 65535, 1852, + 65535, 2029, 65535, 65535, 65535, 65535, 2992, 65535, 2031, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3661, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2084, 65535, 65535, 65535, 65535, 65535, 65535, + 19152, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2214, 65535, 65535, 65535, 65535, 65535, 65535, 4502, 19348, 65535, + 1731, 65535, 65535, 3814, 3046, 65535, 65535, 65535, 65535, 65535, 2233, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4987, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2688, 19603, 65535, + 65535, 4479, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3668, 984, + 65535, 65535, 4425, 65535, 65535, 65535, 65535, 1919, 3338, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4758, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19353, 65535, 65535, 1514, 65535, 65535, + 65535, 65535, 1373, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19638, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4676, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19778, 3701, 19103, + 65535, 65535, 3218, 65535, 65535, 65535, 3019, 65535, 65535, 65535, 65535, + 65535, 65535, 2873, 65535, 65535, 65535, 65535, 65535, 65535, 3070, 65535, + 65535, 3278, 65535, 65535, 65535, 65535, 2652, 65535, 65535, 3708, 65535, + 3288, 65535, 65535, 65535, 2353, 3710, 65535, 65535, 65535, 65535, 3492, + 19671, 65535, 65535, 3577, 1799, 65535, 65535, 2781, 65535, 65535, 3487, + 3716, 65535, 65535, 65535, 65535, 3282, 65535, 3483, 65535, 2641, 1004, + 65535, 65535, 65535, 3717, 65535, 65535, 3024, 3718, 65535, 65535, 65535, + 65535, 65535, 3719, 65535, 3294, 65535, 65535, 3048, 3331, 65535, 65535, + 65535, 19709, 65535, 3018, 1891, 65535, 65535, 65535, 65535, 65535, 65535, + 3721, 65535, 65535, 65535, 65535, 3722, 65535, 65535, 65535, 65535, 3036, + 19123, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3033, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3727, 65535, 65535, 65535, 65535, 65535, 65535, + 1555, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3730, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1910, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3732, 65535, 65535, 65535, 65535, 3734, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3681, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1458, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1566, 1489, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19257, 65535, 65535, 65535, 65535, 1756, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3741, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3743, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3745, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1426, 65535, 65535, 65535, 2692, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3265, 65535, 65535, + 4941, 65535, 65535, 65535, 65535, 3748, 65535, 65535, 65535, 65535, 3749, + 65535, 1824, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1061, 65535, 65535, 65535, 65535, 65535, 65535, + 1499, 65535, 65535, 65535, 4686, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3073, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19422, 65535, 65535, + 65535, 65535, 65535, 65535, 4339, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1894, 65535, 4615, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1888, 3767, 19602, 65535, 65535, 65535, 65535, 3768, 65535, 65535, + 65535, 65535, 3086, 65535, 65535, 1042, 3096, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3774, 65535, 65535, 65535, 65535, + 2449, 65535, 3094, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1898, 65535, 65535, 3191, 65535, 1050, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2922, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3776, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3779, 65535, 65535, + 65535, 65535, 65535, 2062, 65535, 65535, 65535, 65535, 3782, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2197, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1915, 65535, 2066, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3121, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3124, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1759, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2250, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3789, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3144, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1832, 65535, 65535, + 65535, 3790, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3793, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3795, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1825, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19002, 65535, 65535, 65535, 2440, + 65535, 65535, 3457, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3247, + 65535, 65535, 65535, 65535, 65535, 65535, 3557, 19484, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1014, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2128, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3240, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3807, 65535, 65535, 1856, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1500, + 65535, 65535, 65535, 65535, 65535, 65535, 2038, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1467, 65535, + 65535, 65535, 65535, 65535, 4413, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3819, 65535, 65535, 942, + 65535, 4411, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3826, 3176, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3831, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3835, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3837, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2180, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3843, 65535, 11209, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3029, 2246, 65535, 19107, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3849, 65535, + 65535, 65535, 65535, 65535, 65535, 4886, 65535, 65535, 65535, 65535, 65535, + 1914, 65535, 65535, 3325, 65535, 65535, 1853, 65535, 19526, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3610, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2760, + 1913, 3609, 65535, 1063, 65535, 65535, 2234, 65535, 65535, 65535, 65535, + 19460, 3174, 3561, 4589, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2681, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2144, 3858, 65535, 65535, 65535, 65535, 4463, + 65535, 2218, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2258, 65535, 65535, 65535, 65535, 1905, 65535, 2105, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2256, 65535, 65535, 65535, + 65535, 65535, 65535, 3530, 65535, 65535, 65535, 65535, 3399, 65535, 65535, + 1857, 65535, 65535, 65535, 65535, 3865, 65535, 2471, 65535, 4331, 65535, + 65535, 65535, 2252, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3031, 19165, 65535, 65535, 19572, 65535, + 65535, 1868, 65535, 65535, 65535, 2142, 65535, 65535, 65535, 65535, 1904, + 5018, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2269, 65535, 65535, + 1901, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3869, + 946, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2472, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 945, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 949, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 966, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4678, 1909, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 944, 65535, 65535, 3876, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2286, 65535, 65535, 65535, 65535, + 65535, 2335, 65535, 3877, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2294, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2772, 65535, 65535, 65535, 65535, + 65535, 3576, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 971, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1048, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1889, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3221, + 4296, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3220, + 65535, 1896, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2319, 65535, 65535, 65535, 65535, 4211, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 954, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 955, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4611, 965, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4222, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3892, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19149, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1431, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3895, 65535, 65535, 65535, + 65535, 65535, 65535, 1452, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1653, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1487, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3903, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19258, 65535, 65535, 65535, 3578, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3251, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3915, 19321, 65535, 4153, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19276, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19647, 65535, 65535, 65535, 65535, 65535, 4619, 65535, + 65535, 65535, 65535, 65535, 65535, 4405, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3261, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1355, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3918, 65535, 65535, + 65535, 65535, 65535, 65535, 3333, 65535, 65535, 65535, 65535, 2376, 65535, + 65535, 3411, 65535, 1040, 1018, 65535, 65535, 65535, 65535, 3514, 65535, + 65535, 65535, 65535, 65535, 65535, 3310, 65535, 3581, 65535, 65535, 65535, + 65535, 65535, 65535, 3933, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3934, 65535, 19686, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2427, 65535, 65535, 65535, 65535, 3941, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2833, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2159, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2458, 65535, 65535, 65535, 65535, 65535, 3946, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2445, 65535, 65535, 65535, 65535, 65535, 3949, 65535, + 1656, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2470, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3298, 65535, 65535, 65535, 65535, + 65535, 65535, 3951, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3953, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3550, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 970, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1502, 65535, 65535, 65535, 4154, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2502, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3957, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2517, 1751, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3960, 65535, 65535, 65535, + 65535, 65535, 65535, 1736, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1654, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19420, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3340, 3971, 65535, + 2527, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3460, 65535, + 65535, 4999, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2786, 65535, 3350, 65535, 65535, + 2940, 65535, 65535, 2601, 3354, 65535, 65535, 65535, 65535, 65535, 3973, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3353, 2619, 65535, 4249, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4914, 65535, 65535, 4909, + 65535, 65535, 65535, 65535, 65535, 65535, 2543, 65535, 65535, 65535, 943, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4777, 65535, 65535, + 1344, 65535, 957, 65535, 65535, 65535, 65535, 65535, 65535, 956, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 963, 65535, 65535, 65535, 4660, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3982, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1871, 65535, 65535, 65535, 1907, 65535, 4504, + 65535, 65535, 65535, 1839, 65535, 65535, 65535, 967, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4447, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3384, 65535, 3387, 65535, 65535, 65535, 65535, 65535, 65535, 4350, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1341, + 65535, 65535, 65535, 4693, 951, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19157, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 969, 65535, 4656, 65535, 65535, 65535, 65535, + 65535, 65535, 19267, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2588, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1908, 948, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1906, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4452, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4455, 65535, 65535, 65535, 5495, 5497, 65535, + 5498, 4634, 65535, 65535, 11309, 5517, 5515, 5518, 5516, 11310, 5560, + 11319, 11317, 5559, 5558, 65535, 65535, 5654, 5653, 5652, 65535, 5655, + 5651, 4633, 65535, 4512, 65535, 5778, 5779, 65535, 3783, 65535, 65535, + 1364, 65535, 6220, 65535, 1664, 65535, 4808, 5519, 1684, 5561, 11320, 1777, + 5562, 11339, 5945, 11697, 65535, 65535, 10926, 1721, 5520, 5563, 65535, + 5656, 11340, 1262, 65535, 10927, 65535, 65535, 11304, 5499, 65535, 5522, + 65535, 11311, 5523, 19128, 65535, 5564, 65535, 5657, 5659, 5658, 65535, + 65535, 5780, 5781, 65535, 65535, 6221, 65535, 6998, 5496, 11206, 1670, + 11305, 5500, 5525, 5524, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5782, 4262, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 6222, 65535, 65535, 65535, 65535, 4078, 65535, 65535, 65535, 65535, + 65535, 7455, 13042, 1366, 1365, 8418, 14366, 14367, 10928, 5501, 1367, + 5566, 1384, 65535, 6223, 5502, 11312, 5526, 65535, 65535, 5567, 5569, + 11321, 5570, 5568, 65535, 65535, 2731, 5783, 4484, 6224, 65535, 65535, + 6225, 6599, 10929, 5527, 5571, 1774, 5784, 5786, 5785, 65535, 5946, 65535, + 65535, 6226, 6227, 6600, 6601, 65535, 65535, 65535, 65535, 6999, 65535, + 65535, 14368, 19304, 65535, 18485, 5503, 1671, 2712, 65535, 65535, 1368, + 5573, 5572, 11322, 5574, 5580, 65535, 5575, 5576, 11324, 11323, 5578, 5579, + 65535, 5577, 4819, 65535, 65535, 65535, 65535, 65535, 5662, 5663, 5664, + 5665, 5661, 5668, 11346, 65535, 11342, 10958, 5669, 5685, 65535, 11344, + 65535, 5666, 5667, 5660, 65535, 65535, 11341, 11343, 4467, 1369, 65535, + 65535, 3896, 65535, 5799, 11382, 5796, 5800, 11392, 11380, 5797, 11384, + 2708, 65535, 65535, 5798, 65535, 5801, 65535, 5787, 11383, 5802, 11387, + 2735, 11391, 11388, 65535, 65535, 11385, 5788, 5790, 5803, 65535, 5792, + 11377, 5795, 5793, 5794, 11393, 11390, 11381, 5791, 65535, 1778, 11378, + 5789, 1270, 65535, 65535, 11386, 65535, 65535, 65535, 65535, 11389, 65535, + 65535, 65535, 65535, 65535, 1271, 2725, 65535, 65535, 11379, 11499, 65535, + 5968, 5955, 65535, 2596, 11500, 5952, 65535, 5970, 1370, 5960, 4822, 5959, + 11488, 5963, 5958, 11493, 11501, 65535, 11497, 2738, 5961, 65535, 3204, + 5964, 5949, 5973, 11490, 65535, 2715, 11709, 5947, 5969, 5948, 5956, 5957, + 11495, 11491, 5962, 5954, 11487, 5950, 11498, 5971, 5974, 5953, 5966, 5972, + 5951, 11496, 5967, 11502, 11489, 5965, 11492, 65535, 65535, 11494, 65535, + 6241, 11711, 11723, 6233, 65535, 11724, 6228, 6238, 65535, 3433, 6231, + 11705, 6239, 11704, 11708, 11715, 11713, 6247, 6242, 11699, 11701, 6244, + 6232, 11702, 11714, 11721, 6237, 11707, 11700, 6236, 11703, 6240, 11706, + 2716, 6235, 65535, 6230, 65535, 6245, 11716, 6246, 11720, 65535, 11718, + 11722, 6243, 11710, 11698, 65535, 11712, 6234, 11717, 6229, 11719, 65535, + 65535, 65535, 2734, 65535, 65535, 65535, 65535, 65535, 1272, 65535, 65535, + 19020, 65535, 65535, 6616, 6604, 3649, 65535, 12058, 12066, 1877, 6603, + 6611, 6623, 65535, 12072, 12070, 4258, 65535, 1372, 65535, 6605, 12071, + 12061, 6619, 6610, 6618, 12056, 65535, 12068, 3691, 12059, 6614, 12060, + 2742, 12055, 6621, 6608, 6617, 6607, 65535, 12057, 12062, 65535, 12069, + 6615, 6612, 12064, 6620, 12067, 12063, 6609, 6622, 6613, 6606, 6602, 65535, + 65535, 3421, 2743, 65535, 65535, 65535, 65535, 65535, 65535, 12073, 65535, + 7025, 7003, 1775, 7019, 4756, 7024, 12513, 12512, 12517, 12518, 7006, 2185, + 7015, 65535, 65535, 4754, 7028, 65535, 7016, 65535, 65535, 1374, 65535, + 12506, 7009, 12507, 19022, 7030, 65535, 7021, 7000, 7001, 12526, 7472, + 65535, 7014, 7013, 12508, 7017, 13058, 7008, 12519, 7023, 7022, 7012, + 12511, 12520, 65535, 12505, 7011, 12521, 7020, 12509, 7002, 65535, 7005, + 7004, 12522, 7018, 7007, 7027, 7029, 12516, 7026, 2739, 12524, 12510, + 12525, 65535, 12514, 2547, 12523, 65535, 12515, 65535, 65535, 65535, 1727, + 7010, 65535, 65535, 65535, 13066, 13054, 65535, 7460, 65535, 13059, 13065, + 7459, 13052, 7463, 13056, 13049, 7461, 13053, 7466, 7471, 65535, 13070, + 65535, 13048, 65535, 7467, 4761, 13069, 2744, 65535, 7462, 13055, 7458, + 13050, 13046, 13060, 13047, 13045, 13057, 13063, 13064, 7464, 4217, 65535, + 13686, 13061, 13044, 13062, 2740, 7474, 13067, 7473, 13043, 65535, 13051, + 13068, 7469, 7468, 7465, 7470, 65535, 65535, 7456, 65535, 65535, 7457, + 65535, 65535, 7952, 2741, 13689, 13682, 65535, 7949, 65535, 13690, 1375, + 65535, 65535, 13680, 13683, 7948, 13684, 65535, 19490, 7951, 13688, 65535, + 13678, 13677, 7953, 65535, 7954, 7950, 7955, 13676, 13687, 13685, 13679, + 65535, 65535, 65535, 7947, 13681, 65535, 65535, 4780, 65535, 65535, 65535, + 65535, 65535, 8425, 8419, 14372, 8428, 14378, 14381, 8421, 8422, 14375, + 8420, 14384, 8426, 14385, 65535, 14380, 8427, 1776, 14369, 8424, 14370, + 65535, 14379, 14377, 65535, 14373, 8423, 14371, 8429, 14376, 14383, 14374, + 14382, 65535, 2732, 8876, 8873, 2484, 8874, 65535, 15066, 15058, 8872, + 8869, 15059, 65535, 4935, 8871, 15062, 65535, 15064, 65535, 3056, 15071, + 19361, 65535, 15070, 15065, 8868, 15057, 8866, 15060, 8877, 15063, 65535, + 15067, 4815, 8867, 15069, 15068, 8875, 65535, 15061, 3552, 9256, 15681, + 65535, 15678, 9257, 65535, 9255, 2745, 15685, 15682, 15675, 9254, 19036, + 9258, 15676, 9253, 9261, 15679, 15680, 9259, 9260, 15686, 15683, 15684, + 2733, 19038, 65535, 9649, 16321, 9646, 16318, 9648, 9650, 65535, 16319, + 9647, 65535, 16320, 65535, 16317, 65535, 65535, 9945, 16890, 9946, 16888, + 65535, 16889, 16887, 16886, 65535, 65535, 16891, 9944, 2709, 65535, 17356, + 17357, 65535, 15677, 17355, 9947, 10393, 17721, 17722, 65535, 10636, 10637, + 18307, 18306, 10720, 10719, 18636, 65535, 5504, 5528, 5582, 65535, 5581, + 5671, 5670, 5806, 5805, 5807, 5804, 65535, 5976, 5975, 5977, 65535, 65535, + 65535, 65535, 6249, 65535, 6248, 6250, 1273, 6624, 65535, 2746, 12527, + 2747, 7475, 2748, 2749, 13691, 19044, 5210, 8878, 5211, 65535, 5505, 65535, + 5583, 5808, 6251, 19046, 5506, 5586, 5584, 5585, 65535, 65535, 5809, 65535, + 65535, 1274, 5978, 6253, 6252, 6254, 3009, 65535, 65535, 7031, 65535, + 65535, 65535, 9651, 65535, 10930, 65535, 65535, 65535, 1379, 11318, 11211, + 5672, 5673, 65535, 65535, 5810, 65535, 11503, 65535, 6626, 6625, 12529, + 12528, 7476, 10931, 5587, 11325, 65535, 4571, 65535, 1275, 65535, 11725, + 65535, 6627, 65535, 7034, 65535, 7032, 7033, 65535, 4574, 2757, 65535, + 9652, 10932, 5674, 65535, 1754, 65535, 5811, 11394, 19058, 19067, 3965, + 19004, 5979, 5980, 19059, 11504, 65535, 65535, 11726, 6255, 11727, 65535, + 65535, 65535, 65535, 2758, 12531, 12532, 7037, 19552, 12533, 19061, 12530, + 7038, 7036, 7035, 12534, 19062, 13071, 19063, 4164, 19065, 13692, 65535, + 65535, 14386, 15072, 65535, 65535, 1381, 9262, 9653, 16322, 19589, 5507, + 5521, 19068, 65535, 1276, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19070, 65535, 65535, 7477, 7957, 65535, 8879, 19369, 11306, 5588, + 65535, 5677, 5675, 5676, 65535, 1382, 6256, 4725, 65535, 5508, 5509, 11208, + 5529, 65535, 1383, 5589, 5590, 5591, 11396, 5678, 19075, 11347, 65535, + 5815, 65535, 11397, 5813, 5814, 11395, 65535, 65535, 5816, 5812, 65535, + 65535, 65535, 65535, 11505, 6575, 11506, 4817, 5000, 11507, 65535, 65535, + 5982, 5981, 19076, 1324, 5985, 5983, 5984, 65535, 65535, 65535, 6262, + 65535, 6261, 11732, 11729, 11730, 4705, 11728, 6263, 6259, 6258, 65535, + 6260, 6257, 19077, 65535, 65535, 65535, 65535, 6264, 65535, 6629, 12074, + 65535, 11731, 6634, 65535, 12075, 6630, 6633, 6632, 6631, 6628, 1032, + 65535, 65535, 12537, 65535, 7041, 12540, 7039, 19079, 65535, 2767, 12536, + 7042, 7040, 7043, 12538, 12539, 4757, 12535, 12541, 65535, 65535, 65535, + 65535, 65535, 1648, 7961, 7478, 13072, 13074, 13073, 13075, 7479, 65535, + 65535, 7958, 4784, 7959, 7960, 65535, 8431, 14388, 1385, 14387, 14389, + 14390, 8432, 65535, 8430, 15073, 15074, 8881, 8880, 15412, 65535, 65535, + 9263, 9264, 9265, 9267, 15687, 15688, 9266, 65535, 4195, 1386, 9654, 65535, + 9655, 19080, 65535, 17723, 18309, 18308, 18637, 4825, 5510, 65535, 65535, + 65535, 5680, 5679, 1277, 65535, 5817, 2768, 65535, 11398, 65535, 1278, + 5987, 5988, 5986, 5989, 11508, 11509, 65535, 65535, 65535, 65535, 65535, + 65535, 19078, 65535, 65535, 65535, 19081, 65535, 6266, 11733, 65535, 6265, + 65535, 12076, 6638, 12077, 6637, 65535, 19082, 65535, 6635, 65535, 6636, + 65535, 65535, 4675, 12542, 65535, 65535, 19252, 4759, 7480, 13077, 65535, + 7483, 13076, 7667, 7482, 7481, 65535, 7964, 65535, 7963, 7962, 8433, 19085, + 2770, 8436, 8437, 8435, 65535, 8434, 65535, 65535, 15075, 65535, 15076, + 65535, 65535, 65535, 15690, 9268, 15689, 65535, 9656, 16892, 9948, 65535, + 17724, 10540, 10933, 5530, 5592, 11326, 65535, 5593, 5594, 65535, 3937, + 65535, 65535, 65535, 5681, 5682, 65535, 5818, 11510, 11734, 11735, 65535, + 6639, 12543, 7485, 7484, 13694, 13693, 65535, 65535, 5511, 5595, 5683, + 65535, 7486, 11307, 65535, 11348, 5684, 65535, 11400, 5820, 5819, 11399, + 5990, 1767, 65535, 65535, 1387, 65535, 65535, 7044, 65535, 4771, 13078, + 65535, 8438, 15077, 8882, 4938, 19095, 16323, 65535, 65535, 18053, 10934, + 5596, 65535, 1279, 11736, 12078, 7489, 7487, 7488, 5287, 19069, 5531, 5288, + 5289, 65535, 5598, 5597, 5687, 5686, 65535, 11349, 11401, 1280, 65535, + 65535, 6270, 6267, 6269, 6268, 65535, 65535, 6640, 65535, 65535, 7965, + 65535, 5513, 1699, 5600, 1603, 5689, 5688, 65535, 11511, 4068, 65535, 6271, + 4638, 65535, 10935, 65535, 65535, 11327, 19108, 5691, 5690, 5821, 5822, + 11512, 5991, 19109, 5992, 65535, 6272, 6273, 6274, 65535, 6641, 12079, + 4641, 19111, 7045, 65535, 65535, 11308, 65535, 5601, 65535, 65535, 65535, + 65535, 65535, 11402, 65535, 65535, 65535, 11513, 11514, 65535, 65535, + 11737, 19116, 11738, 65535, 12081, 12080, 12083, 12082, 6642, 65535, 13079, + 7047, 12544, 7046, 19118, 65535, 4365, 65535, 13695, 7966, 19303, 13696, + 19306, 1389, 4925, 19119, 15078, 8883, 19120, 65535, 1391, 65535, 9269, + 65535, 17725, 65535, 10936, 65535, 65535, 11328, 65535, 5692, 65535, 65535, + 65535, 65535, 65535, 19125, 1393, 7490, 65535, 19126, 65535, 65535, 5514, + 5532, 5603, 5602, 2457, 5604, 65535, 65535, 2789, 1281, 4386, 65535, 6276, + 65535, 6275, 6277, 1282, 19130, 4774, 6643, 65535, 65535, 65535, 7048, + 19133, 16324, 10220, 5533, 5694, 5709, 5704, 65535, 5699, 5698, 5705, 5703, + 5696, 5710, 5697, 5693, 5708, 5707, 5706, 5695, 65535, 5702, 19136, 2273, + 5701, 65535, 65535, 5711, 5700, 65535, 19179, 65535, 65535, 5828, 65535, + 5834, 5830, 65535, 5836, 11403, 5833, 5823, 5826, 5829, 5825, 5832, 5835, + 5824, 5827, 5831, 5837, 19138, 3438, 65535, 4534, 65535, 11523, 11520, + 4500, 6005, 11521, 5993, 5995, 6019, 6014, 19513, 65535, 1394, 11528, + 11522, 5997, 5999, 11527, 6006, 11517, 6018, 6020, 5994, 6011, 19158, + 11515, 6017, 4524, 6002, 1780, 6012, 6013, 11516, 6010, 6008, 65535, 6009, + 6015, 11524, 5996, 65535, 6016, 11526, 6004, 6001, 65535, 11519, 6000, + 11529, 6003, 65535, 6007, 4647, 1041, 4575, 5998, 11525, 65535, 65535, + 65535, 65535, 11518, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 11755, 11754, 6295, 11757, 11759, 11748, 11751, + 11758, 6296, 4767, 4026, 11745, 11749, 19143, 65535, 11753, 12098, 6291, + 12102, 6278, 11750, 6279, 6292, 6285, 6281, 65535, 11746, 6284, 6289, 6298, + 11747, 11740, 6283, 11741, 11743, 65535, 6286, 3674, 6288, 11739, 11744, + 65535, 65535, 6297, 6293, 11752, 6299, 19147, 6290, 11742, 6287, 1398, + 4560, 6282, 6280, 4545, 11756, 65535, 6294, 65535, 4823, 65535, 4029, + 65535, 12097, 12085, 12100, 1399, 19148, 12087, 6650, 6664, 6646, 6663, + 6655, 6660, 6644, 12086, 12092, 6659, 12104, 6661, 2067, 6651, 1400, 65535, + 12094, 12091, 6649, 1401, 12084, 6662, 12099, 6654, 12101, 6665, 6645, + 6656, 6653, 12089, 6657, 12095, 12096, 6652, 6658, 6648, 65535, 2698, 1587, + 2795, 6647, 12088, 1402, 65535, 65535, 65535, 65535, 65535, 12093, 65535, + 65535, 65535, 4824, 65535, 65535, 65535, 12103, 65535, 12564, 7061, 12546, + 1470, 12551, 7054, 7065, 12549, 7049, 7059, 7064, 12556, 65535, 7060, 7063, + 1403, 65535, 12559, 7055, 12550, 65535, 65535, 65535, 12562, 12563, 65535, + 7057, 12561, 7053, 7068, 65535, 12553, 65535, 7051, 3523, 12566, 12554, + 12558, 7056, 7067, 12555, 7062, 12560, 12567, 13094, 2914, 12565, 7069, + 7050, 12557, 12548, 4577, 7058, 65535, 65535, 12547, 1404, 65535, 12552, + 65535, 65535, 65535, 4576, 65535, 65535, 65535, 65535, 1405, 65535, 1414, + 12545, 7066, 1406, 65535, 13086, 19140, 7509, 13100, 7507, 7504, 13091, + 7500, 13095, 7511, 13085, 13090, 13089, 7052, 7506, 13098, 65535, 13101, + 13082, 65535, 7984, 1408, 13102, 7512, 65535, 7498, 7495, 13093, 7492, + 19156, 13099, 19090, 7499, 13103, 65535, 13083, 13097, 7502, 13084, 13087, + 13092, 19219, 65535, 7503, 7501, 7513, 65535, 65535, 65535, 65535, 7508, + 19146, 7496, 7648, 65535, 7497, 13088, 7510, 7505, 13096, 7494, 65535, + 65535, 4567, 7493, 3105, 65535, 65535, 65535, 65535, 65535, 3260, 4546, + 4752, 65535, 13080, 13081, 13701, 65535, 1498, 65535, 7967, 7970, 13712, + 7990, 13715, 7968, 13708, 7974, 7980, 8255, 65535, 19160, 7978, 13705, + 7991, 7971, 7979, 13713, 14404, 13718, 13706, 1419, 13697, 13710, 13704, + 7977, 13716, 65535, 65535, 7973, 7993, 7986, 65535, 7975, 7972, 65535, + 7983, 65535, 13717, 13703, 13709, 13711, 13699, 13714, 7969, 13698, 19161, + 7976, 7992, 7988, 13700, 7982, 65535, 2520, 7989, 7985, 7981, 2793, 13707, + 65535, 65535, 65535, 1589, 4544, 7987, 4202, 65535, 65535, 14402, 14398, + 4458, 14413, 14391, 14400, 8452, 8453, 8445, 14409, 8455, 14396, 14395, + 14393, 14411, 8443, 14405, 14394, 8446, 14403, 8441, 14399, 14406, 14408, + 1411, 3898, 14412, 8450, 14392, 8444, 14397, 4556, 8439, 65535, 8451, + 14407, 8447, 8448, 8454, 8442, 5212, 8440, 14401, 4531, 65535, 2216, 65535, + 65535, 8449, 4543, 4538, 14410, 65535, 65535, 3901, 8899, 8894, 65535, + 15093, 15089, 1661, 15083, 8888, 8884, 15092, 8885, 15086, 15088, 65535, + 15091, 4537, 8890, 65535, 8897, 8891, 65535, 65535, 15081, 8892, 8893, + 15084, 8898, 4795, 15082, 15087, 8889, 15080, 8895, 8887, 65535, 65535, + 65535, 8886, 15085, 15090, 4506, 8896, 4847, 1955, 4505, 3738, 65535, 4527, + 65535, 15079, 65535, 9276, 15707, 65535, 15704, 4498, 9270, 9282, 9283, + 65535, 9273, 15702, 9275, 15694, 9281, 19169, 15706, 9272, 15708, 9271, + 65535, 15703, 15705, 9274, 15701, 15695, 15692, 4533, 65535, 13702, 15698, + 65535, 15691, 15697, 15696, 65535, 15693, 19174, 9278, 19175, 3989, 65535, + 1529, 9277, 3956, 65535, 65535, 9279, 15699, 9657, 15700, 65535, 65535, + 4700, 16333, 65535, 16326, 2283, 9669, 16330, 9661, 9665, 16329, 65535, + 9664, 9660, 9663, 9658, 9668, 16331, 16327, 9667, 16325, 9666, 16332, + 16328, 9280, 65535, 9670, 16334, 9662, 9659, 4037, 4595, 4687, 65535, + 16899, 16901, 9950, 16902, 16900, 16898, 16897, 9952, 16896, 9953, 65535, + 1663, 2608, 4430, 16894, 16895, 9949, 9954, 9951, 65535, 2701, 16893, + 65535, 10221, 65535, 17360, 17358, 17363, 17361, 65535, 17359, 17362, 2699, + 2607, 65535, 1512, 65535, 65535, 3519, 10394, 17728, 17729, 10541, 65535, + 17730, 17726, 17731, 17727, 10222, 1614, 65535, 1946, 18054, 18056, 10544, + 18055, 10543, 10542, 65535, 4259, 65535, 65535, 10545, 18311, 18312, 4487, + 10639, 10638, 10640, 18310, 65535, 18487, 18486, 65535, 10721, 10723, + 10722, 18488, 10778, 18751, 65535, 65535, 65535, 10819, 65535, 18750, + 18823, 65535, 4338, 11313, 65535, 65535, 5713, 5712, 65535, 5840, 5839, + 11405, 5838, 11404, 1283, 65535, 6023, 11532, 65535, 11531, 65535, 65535, + 6021, 6024, 65535, 19182, 11530, 19181, 6022, 19177, 65535, 65535, 65535, + 65535, 65535, 11760, 65535, 11761, 6300, 979, 65535, 3712, 65535, 6666, + 19180, 12568, 12569, 7070, 7071, 65535, 65535, 13105, 7514, 7516, 13104, + 7515, 13719, 7994, 65535, 65535, 65535, 65535, 8456, 8457, 14414, 4379, + 8901, 65535, 8900, 65535, 15709, 16336, 16335, 2797, 18883, 5534, 11329, + 65535, 11350, 11351, 65535, 65535, 65535, 65535, 5843, 5847, 11407, 65535, + 5845, 5844, 11406, 5846, 5842, 65535, 3052, 5841, 11408, 65535, 65535, + 65535, 65535, 65535, 65535, 6034, 65535, 1833, 6031, 4196, 6027, 11533, + 19190, 19208, 65535, 11534, 19186, 6029, 65535, 11536, 6025, 11537, 11535, + 6028, 6030, 6033, 6032, 6026, 11538, 65535, 3899, 65535, 65535, 4021, + 65535, 65535, 65535, 2665, 65535, 65535, 65535, 4918, 65535, 6305, 11774, + 65535, 6307, 65535, 6306, 4760, 11775, 6304, 6303, 11765, 65535, 11764, + 65535, 11762, 11767, 11766, 11763, 11772, 11773, 11770, 11768, 6302, 65535, + 65535, 4816, 11771, 6308, 11776, 3678, 2803, 11769, 65535, 6667, 6301, + 65535, 65535, 65535, 65535, 4172, 65535, 3442, 6668, 12109, 2802, 65535, + 12115, 19350, 65535, 65535, 6674, 12113, 12119, 65535, 12110, 12114, 12116, + 12118, 12112, 1631, 12111, 12106, 12107, 6669, 4228, 6671, 6670, 12108, + 12117, 65535, 4702, 65535, 65535, 4648, 65535, 65535, 65535, 6673, 65535, + 65535, 65535, 65535, 1039, 3815, 12105, 12579, 65535, 12578, 12583, 12574, + 3440, 12577, 12576, 2042, 12580, 65535, 12584, 7072, 7075, 3150, 65535, + 12575, 12581, 3586, 65535, 65535, 7074, 12570, 65535, 6672, 13119, 12582, + 65535, 12573, 65535, 7073, 12572, 65535, 3444, 65535, 65535, 65535, 65535, + 13110, 2801, 4712, 7517, 7521, 13126, 13108, 13122, 7522, 13124, 19193, + 13130, 65535, 13134, 65535, 65535, 13125, 13113, 13121, 3839, 13135, 13133, + 13123, 13118, 13111, 13727, 13109, 7526, 13116, 7527, 7523, 13106, 13128, + 13114, 19129, 65535, 13112, 13131, 7524, 19195, 13137, 7518, 7520, 13120, + 13115, 7076, 7519, 13117, 13132, 13136, 13127, 65535, 13129, 65535, 3585, + 65535, 13107, 65535, 65535, 65535, 1044, 13722, 65535, 13731, 13730, 8002, + 13723, 65535, 8003, 8001, 3358, 13725, 7998, 13729, 19198, 13724, 13726, + 13720, 7996, 65535, 13739, 13738, 13735, 7995, 7999, 8000, 12571, 13732, + 7997, 7525, 13734, 13721, 13737, 13736, 3832, 13740, 65535, 14428, 65535, + 13733, 4014, 65535, 65535, 65535, 3962, 65535, 65535, 2997, 13728, 14420, + 8467, 8470, 8465, 14419, 14423, 14418, 65535, 8459, 8469, 14415, 8463, + 14422, 65535, 8461, 8460, 14425, 8462, 14427, 19200, 14424, 8458, 3893, + 65535, 65535, 8468, 14429, 14417, 14426, 65535, 65535, 14416, 3740, 65535, + 8464, 2689, 8466, 65535, 14421, 65535, 14430, 3356, 1490, 15101, 8902, + 15107, 65535, 65535, 8907, 15103, 15110, 15095, 8909, 8903, 15100, 9284, + 15099, 15108, 8904, 65535, 8908, 15098, 15104, 15109, 15094, 8906, 15102, + 65535, 65535, 15106, 15112, 15096, 15105, 1782, 8905, 15111, 65535, 1020, + 65535, 15097, 1647, 4644, 65535, 9288, 15711, 9286, 9285, 15713, 15718, + 65535, 15714, 65535, 15717, 9291, 4685, 9644, 9290, 19201, 15710, 15716, + 65535, 9289, 15715, 2168, 15712, 65535, 9287, 65535, 4143, 4301, 65535, + 65535, 65535, 16341, 18959, 16343, 16338, 9672, 16340, 65535, 9671, 16342, + 65535, 65535, 9674, 16344, 9673, 16337, 16339, 65535, 2805, 65535, 65535, + 9958, 16905, 1783, 9957, 16906, 9956, 16904, 9955, 16903, 65535, 10224, + 10223, 17732, 17734, 19204, 17733, 10395, 10396, 19203, 65535, 10397, + 18057, 10546, 65535, 65535, 18639, 18638, 10820, 65535, 5535, 5605, 65535, + 65535, 6035, 1284, 65535, 3753, 3441, 12120, 65535, 65535, 65535, 65535, + 8004, 8005, 19206, 14431, 8910, 15113, 15719, 65535, 65535, 1665, 11330, + 1285, 1380, 11539, 1286, 65535, 65535, 10937, 65535, 11777, 12121, 12585, + 7077, 65535, 19627, 17735, 65535, 10641, 5536, 5714, 11352, 65535, 5848, + 5849, 65535, 6309, 982, 65535, 19213, 7528, 65535, 8912, 65535, 8913, 8911, + 65535, 5537, 65535, 5606, 5608, 5607, 11331, 5609, 5715, 11353, 65535, + 5716, 1287, 65535, 1288, 65535, 65535, 5850, 5851, 65535, 65535, 65535, + 11409, 65535, 6036, 65535, 11540, 65535, 65535, 65535, 6313, 11778, 65535, + 6311, 6312, 6310, 12586, 65535, 65535, 65535, 6678, 6677, 6679, 6676, + 65535, 12122, 6314, 6675, 65535, 7078, 7079, 65535, 7080, 65535, 13138, + 65535, 65535, 65535, 8006, 13741, 7529, 65535, 65535, 4189, 65535, 8471, + 65535, 8915, 8914, 15114, 65535, 9292, 9675, 65535, 17364, 18489, 18640, + 5538, 5717, 4509, 5718, 11415, 5853, 5856, 65535, 11413, 11411, 5855, + 11414, 11416, 11410, 5858, 5857, 5854, 5852, 11412, 65535, 65535, 65535, + 3623, 6047, 65535, 65535, 6044, 11545, 11548, 11547, 65535, 6038, 6046, + 3472, 65535, 6043, 11544, 11542, 6042, 3237, 65535, 65535, 6037, 6040, + 4166, 11543, 11550, 11546, 6041, 6045, 6048, 11541, 11549, 6039, 65535, + 65535, 65535, 4012, 65535, 6319, 6327, 3535, 11790, 11783, 6328, 11794, + 11779, 11786, 4762, 2812, 6318, 11780, 6316, 11787, 11791, 6315, 1879, + 11792, 11785, 65535, 11788, 3579, 6330, 6321, 11795, 11793, 19222, 6326, + 6324, 11784, 6323, 11782, 11781, 6322, 6320, 6329, 6325, 6317, 65535, + 11789, 65535, 6681, 19227, 6688, 12136, 6680, 12128, 12124, 65535, 12140, + 12123, 65535, 6683, 12133, 6686, 6689, 65535, 6684, 12137, 6687, 3666, + 7087, 12143, 12125, 3631, 3239, 12127, 12134, 12138, 12142, 12139, 12132, + 12135, 4417, 19234, 12129, 6691, 12131, 12130, 12141, 6682, 12126, 6690, + 3202, 6685, 65535, 65535, 65535, 65535, 65535, 7093, 12594, 3456, 7092, + 3115, 65535, 12592, 65535, 7081, 2816, 7086, 65535, 12591, 12588, 12593, + 7082, 12587, 1826, 7085, 7083, 65535, 12595, 7084, 7088, 2824, 65535, 7089, + 19218, 7091, 65535, 4256, 65535, 7090, 3118, 3639, 2811, 12589, 12590, + 65535, 65535, 65535, 65535, 12596, 65535, 13145, 7530, 13755, 13144, 13163, + 65535, 65535, 7536, 2995, 13161, 65535, 7535, 7531, 13170, 13154, 13157, + 2555, 7539, 13167, 13159, 7532, 7540, 65535, 13164, 13162, 65535, 65535, + 13147, 13168, 13156, 13151, 1626, 13141, 13169, 13153, 13140, 3111, 7538, + 13158, 13171, 13155, 13143, 13148, 13139, 3626, 7537, 19237, 13152, 13149, + 7533, 4349, 2718, 13166, 7534, 2863, 13150, 13146, 3638, 65535, 13165, + 3627, 65535, 65535, 65535, 65535, 65535, 8007, 13748, 3544, 13745, 13762, + 13750, 13763, 2814, 8009, 65535, 2826, 3624, 13759, 13756, 65535, 3190, + 65535, 19609, 65535, 13757, 13760, 13764, 65535, 13160, 13766, 14451, + 19563, 8010, 13767, 13743, 13753, 19242, 13758, 65535, 2806, 8008, 8011, + 13765, 13768, 13747, 13744, 19362, 3539, 13746, 65535, 989, 13751, 13749, + 8012, 65535, 13761, 65535, 19236, 13752, 65535, 13754, 13742, 14439, 14437, + 8480, 8478, 14447, 14438, 14448, 14444, 14436, 14450, 14435, 14442, 8477, + 8476, 8475, 14440, 14445, 8472, 8479, 2424, 14433, 65535, 14443, 14432, + 14441, 8473, 14446, 14434, 8474, 14449, 3455, 2815, 65535, 992, 65535, + 19244, 65535, 15118, 8920, 8919, 8921, 15130, 15120, 15126, 15115, 15129, + 15128, 15132, 15125, 8916, 15124, 8922, 3195, 15117, 8917, 65535, 15131, + 8918, 15119, 15122, 15127, 15121, 15116, 65535, 4681, 65535, 2254, 15123, + 15721, 9296, 15724, 15723, 15726, 15728, 18962, 9294, 65535, 15722, 3347, + 15720, 65535, 15729, 15727, 15725, 65535, 15731, 65535, 15730, 9298, 9293, + 65535, 9295, 9297, 4636, 65535, 15732, 16351, 3308, 65535, 16350, 16349, + 1801, 16352, 16345, 65535, 16346, 16354, 16347, 65535, 9676, 16356, 5019, + 16355, 16348, 65535, 16910, 9961, 16908, 16913, 16912, 3451, 65535, 9960, + 3193, 16911, 16907, 16915, 16914, 9959, 65535, 16909, 65535, 9677, 65535, + 65535, 65535, 10225, 65535, 65535, 65535, 17365, 17736, 17737, 17738, + 10547, 2475, 65535, 10548, 2865, 18058, 19691, 18314, 18313, 65535, 2480, + 18490, 18491, 18641, 18752, 2846, 5539, 5540, 65535, 5541, 5610, 5719, + 11417, 5859, 5860, 65535, 6051, 6052, 6050, 6049, 65535, 6331, 65535, + 65535, 11796, 6333, 6332, 11797, 1289, 65535, 1652, 6692, 65535, 7094, + 12597, 4490, 13173, 65535, 7541, 8014, 13172, 8013, 2049, 8923, 19253, + 15133, 9678, 65535, 9962, 16916, 19255, 10549, 65535, 10724, 10938, 11354, + 19054, 5720, 11355, 5863, 65535, 5861, 5862, 5864, 65535, 6054, 6053, + 65535, 11551, 6055, 4592, 65535, 11552, 11798, 65535, 11799, 1846, 6334, + 6336, 6338, 6335, 6339, 6337, 19266, 1290, 1291, 65535, 65535, 6696, 6693, + 6695, 6697, 6694, 12598, 12144, 65535, 19372, 65535, 12600, 12599, 7100, + 65535, 7096, 65535, 65535, 7097, 7099, 7101, 7098, 993, 7103, 7102, 65535, + 65535, 65535, 65535, 65535, 7546, 13175, 13174, 7545, 4753, 7544, 7543, + 7547, 7542, 65535, 65535, 13774, 13771, 8016, 13770, 13775, 65535, 8018, + 13773, 8015, 8017, 13772, 19260, 14452, 19701, 14453, 14454, 65535, 987, + 65535, 65535, 8924, 8932, 15134, 8926, 8930, 15135, 8931, 8927, 8928, 8925, + 8929, 9301, 13769, 9302, 9300, 65535, 9299, 16357, 9679, 16917, 16918, + 19265, 65535, 10398, 10550, 65535, 5542, 65535, 5865, 65535, 65535, 65535, + 65535, 19207, 65535, 6698, 65535, 12601, 7104, 19268, 65535, 7550, 7549, + 7548, 8019, 8020, 13776, 8933, 9680, 5543, 4329, 5611, 11356, 19270, 19272, + 11418, 5866, 65535, 65535, 65535, 6340, 65535, 1599, 65535, 2838, 14455, + 4053, 65535, 5544, 1673, 5612, 11419, 65535, 65535, 11553, 65535, 11554, + 65535, 6056, 65535, 65535, 65535, 13777, 8021, 65535, 14456, 65535, 65535, + 65535, 9963, 5545, 5565, 5613, 11357, 5721, 65535, 6060, 6059, 6057, 6058, + 65535, 65535, 11800, 6342, 6343, 11801, 6341, 19275, 4813, 6702, 12145, + 6701, 6699, 6700, 7107, 7105, 65535, 4714, 12603, 7106, 12602, 65535, 7095, + 13176, 65535, 65535, 7552, 7553, 3750, 65535, 7551, 65535, 8934, 15136, + 9303, 9304, 65535, 15733, 9964, 17366, 17367, 65535, 10642, 18753, 11315, + 5614, 65535, 5546, 65535, 11359, 11358, 65535, 65535, 65535, 1862, 5867, + 11421, 11422, 11420, 65535, 11423, 65535, 65535, 65535, 65535, 65535, + 65535, 19277, 11562, 65535, 11557, 11559, 11561, 11558, 6064, 11555, 65535, + 11556, 6061, 6062, 11560, 11563, 6063, 11564, 65535, 65535, 65535, 2028, + 1292, 65535, 19612, 11815, 2839, 11809, 11804, 6345, 11812, 11810, 11803, + 11816, 11819, 11814, 11807, 6347, 11813, 6348, 11808, 11811, 11802, 11806, + 11818, 6349, 65535, 6350, 65535, 11805, 11817, 6344, 6346, 65535, 19287, + 65535, 65535, 65535, 65535, 65535, 65535, 5011, 3651, 65535, 65535, 65535, + 12162, 12155, 12161, 12154, 12156, 12150, 12148, 65535, 12163, 12160, + 12146, 4734, 6704, 12158, 12159, 1859, 12157, 12149, 12147, 6703, 12153, + 12151, 65535, 65535, 12152, 12164, 65535, 65535, 65535, 65535, 65535, 1935, + 65535, 65535, 7112, 19278, 7111, 65535, 12604, 7108, 12606, 19279, 7113, + 12607, 65535, 65535, 7116, 1735, 7114, 12608, 12165, 12610, 65535, 7110, + 994, 7109, 65535, 12605, 12609, 7115, 65535, 65535, 65535, 65535, 7555, + 7554, 65535, 65535, 65535, 13178, 13182, 13184, 7556, 13187, 19283, 7560, + 13189, 65535, 7562, 1954, 7558, 7566, 19284, 7563, 13180, 7557, 65535, + 13179, 13177, 13191, 13181, 65535, 7559, 13190, 7564, 13186, 13185, 7565, + 13183, 7561, 65535, 65535, 4292, 65535, 13192, 3667, 13188, 13792, 13799, + 13788, 8024, 13784, 13800, 13778, 13797, 13795, 13789, 65535, 13798, 13791, + 1916, 13783, 13801, 13781, 13794, 13779, 65535, 13802, 19285, 8025, 1917, + 13796, 14459, 13782, 8022, 65535, 13786, 65535, 8023, 13785, 13790, 65535, + 65535, 13787, 1918, 4930, 65535, 13793, 65535, 4239, 65535, 65535, 14463, + 65535, 65535, 65535, 14466, 14458, 65535, 14460, 65535, 14465, 14464, 8481, + 65535, 13780, 14462, 65535, 65535, 8482, 3686, 14457, 14461, 65535, 4689, + 65535, 65535, 15143, 1865, 15150, 15141, 1841, 15148, 15139, 15147, 15151, + 15138, 15142, 15137, 65535, 8935, 4376, 15140, 8936, 15146, 15145, 15144, + 19280, 65535, 15149, 4727, 65535, 65535, 65535, 15737, 15739, 9306, 15740, + 65535, 15735, 65535, 15734, 15744, 65535, 15742, 9305, 15745, 15736, 15741, + 15743, 15738, 65535, 1921, 65535, 65535, 16361, 16366, 16360, 16365, 4382, + 16358, 16368, 16364, 16369, 16363, 16359, 16367, 65535, 16370, 16362, + 19335, 16919, 9968, 1922, 9966, 65535, 9965, 9967, 65535, 65535, 17368, + 3317, 17634, 17739, 65535, 65535, 18059, 18060, 65535, 10551, 65535, 18315, + 65535, 10643, 65535, 18316, 65535, 18493, 10726, 65535, 10725, 18492, + 10779, 19288, 18642, 65535, 65535, 10939, 65535, 5547, 5868, 11424, 11565, + 6206, 7567, 65535, 65535, 5548, 5724, 5723, 5722, 65535, 65535, 6065, + 65535, 65535, 7117, 65535, 14467, 5549, 5550, 5551, 5615, 4818, 65535, + 6705, 65535, 12166, 65535, 65535, 65535, 8026, 5552, 11333, 65535, 65535, + 5725, 5726, 11360, 65535, 5869, 65535, 65535, 19308, 11566, 4055, 6066, + 65535, 11567, 65535, 65535, 6356, 4763, 65535, 11821, 6354, 6353, 11820, + 6351, 11822, 6352, 6355, 65535, 6706, 65535, 6708, 12170, 12167, 12168, + 12169, 12171, 6707, 65535, 65535, 12612, 12611, 65535, 7119, 65535, 7118, + 19297, 65535, 65535, 65535, 65535, 7570, 13194, 65535, 7569, 7571, 7568, + 65535, 65535, 65535, 65535, 8028, 13193, 65535, 8029, 13804, 1925, 8030, + 13803, 8027, 65535, 65535, 2841, 65535, 14470, 14472, 8483, 14471, 14469, + 14468, 65535, 65535, 65535, 15154, 8941, 8939, 65535, 8940, 15152, 15153, + 65535, 8937, 15749, 15747, 2840, 9308, 15748, 9309, 9307, 8938, 65535, + 65535, 16373, 16371, 16372, 15746, 16921, 9969, 16920, 17369, 17370, 16374, + 17740, 65535, 5553, 5727, 5871, 11425, 5870, 65535, 6357, 8484, 19300, + 5616, 5728, 6709, 8031, 10941, 11361, 65535, 11362, 19251, 11426, 65535, + 1293, 6068, 11571, 11569, 6069, 11568, 11570, 11572, 65535, 6067, 65535, + 65535, 1785, 65535, 65535, 6361, 6362, 6359, 65535, 1786, 6358, 12175, + 6360, 65535, 65535, 65535, 6710, 65535, 12174, 12176, 12173, 12177, 6711, + 7122, 12613, 65535, 12615, 7120, 12616, 7121, 12614, 65535, 12172, 13195, + 13198, 13199, 13196, 7575, 7574, 7572, 7573, 13197, 65535, 65535, 65535, + 1926, 7576, 65535, 65535, 8033, 8034, 65535, 8035, 14473, 14475, 14477, + 8486, 8485, 8032, 14476, 14474, 2845, 15158, 65535, 4549, 15156, 15162, + 8942, 15163, 15160, 8943, 15157, 15155, 15161, 9311, 15751, 15159, 9313, + 15752, 9312, 9315, 15753, 9310, 9314, 65535, 16379, 16377, 16376, 16378, + 16375, 65535, 65535, 10400, 65535, 18061, 18062, 65535, 18317, 18494, + 10854, 10942, 65535, 6363, 6070, 2380, 19311, 6712, 19312, 19314, 65535, + 5554, 5617, 65535, 5729, 11427, 65535, 6071, 11573, 65535, 12178, 6713, + 65535, 8944, 5555, 2859, 19317, 2860, 5872, 65535, 65535, 8487, 5556, 5618, + 5619, 65535, 5731, 5730, 65535, 11428, 5873, 65535, 11574, 65535, 6072, + 65535, 65535, 11824, 11825, 11826, 1927, 6364, 6365, 11823, 6366, 65535, + 65535, 65535, 6714, 12179, 65535, 12618, 7123, 65535, 12617, 65535, 7577, + 13200, 7578, 13201, 65535, 19323, 1883, 8036, 65535, 65535, 65535, 14478, + 65535, 65535, 15165, 15164, 65535, 8945, 65535, 9316, 15754, 9681, 16380, + 9970, 3226, 10727, 18644, 10943, 1674, 65535, 65535, 11827, 65535, 12180, + 7579, 13805, 8488, 65535, 65535, 3669, 10226, 65535, 65535, 65535, 10944, + 6074, 19328, 6073, 6715, 65535, 12619, 65535, 7581, 7853, 7582, 7580, 8037, + 65535, 15166, 8946, 9317, 19331, 11316, 11429, 65535, 11576, 6075, 11575, + 6076, 65535, 19074, 6370, 11830, 11829, 6369, 6367, 6368, 11828, 1928, + 65535, 6717, 12181, 6720, 6716, 6722, 6718, 6719, 6721, 65535, 65535, + 65535, 7126, 7125, 7124, 65535, 65535, 65535, 13203, 7583, 7586, 7584, + 65535, 13202, 7589, 65535, 7585, 13204, 7588, 7587, 65535, 65535, 19030, + 13807, 13806, 19334, 8040, 8038, 8039, 13808, 8489, 14480, 8490, 14479, + 65535, 4130, 15755, 65535, 65535, 9319, 15167, 9318, 65535, 8947, 4884, + 16923, 16381, 9971, 16922, 17741, 18063, 18064, 1787, 5620, 1675, 5732, + 65535, 65535, 65535, 11363, 65535, 65535, 6078, 6080, 65535, 11432, 11579, + 11578, 11577, 65535, 11431, 11430, 5875, 6079, 6077, 5874, 65535, 2872, + 65535, 6371, 11831, 19426, 6372, 11584, 65535, 11586, 11585, 11832, 65535, + 65535, 11581, 65535, 6084, 6082, 65535, 11580, 11582, 11588, 65535, 6081, + 65535, 11583, 11592, 6374, 65535, 11589, 6083, 65535, 11587, 11590, 65535, + 6373, 65535, 6375, 11591, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 11852, 11839, 11837, 11851, 11846, 6727, 6376, 11847, 11850, 6723, + 11849, 6377, 6382, 6380, 11840, 65535, 11835, 11842, 6387, 11853, 6724, + 11843, 65535, 6725, 6383, 11845, 19382, 12196, 6726, 11834, 6384, 6728, + 6385, 6381, 6386, 11844, 11833, 11848, 6378, 65535, 19344, 11836, 11841, + 11838, 6379, 65535, 12182, 65535, 12183, 65535, 1294, 65535, 65535, 65535, + 65535, 12193, 12623, 12194, 6734, 12197, 12187, 6733, 12189, 65535, 12190, + 19102, 65535, 12192, 6729, 65535, 65535, 7130, 65535, 18960, 12188, 12184, + 7131, 65535, 65535, 12198, 7127, 12621, 12191, 65535, 12620, 12186, 12195, + 65535, 65535, 4624, 7128, 6738, 7129, 12199, 12622, 6731, 7133, 6737, 6736, + 6735, 7132, 12200, 7134, 6730, 65535, 12185, 65535, 65535, 2884, 65535, + 4993, 65535, 65535, 65535, 65535, 65535, 65535, 2869, 7590, 12626, 12628, + 65535, 12630, 7135, 7141, 13207, 12634, 12625, 7592, 13205, 65535, 7140, + 7138, 12636, 65535, 13206, 65535, 12627, 65535, 7139, 12631, 7142, 12633, + 65535, 65535, 7137, 12632, 12635, 12629, 19354, 7136, 7593, 65535, 12624, + 7591, 4989, 65535, 65535, 3023, 7594, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 13209, 13218, 8043, 19356, 7596, 7601, 8044, 13220, 7608, + 13810, 13210, 7600, 7603, 7598, 13208, 13222, 13225, 13825, 65535, 13223, + 13814, 7599, 7606, 7610, 13217, 13809, 13221, 7595, 13811, 13224, 13813, + 13213, 65535, 8041, 65535, 13211, 13212, 7605, 65535, 1933, 7604, 13215, + 7609, 13219, 7602, 13216, 4220, 7607, 8045, 8042, 13812, 3856, 13214, + 65535, 7597, 4035, 3958, 4998, 65535, 65535, 65535, 65535, 65535, 65535, + 8050, 8054, 13816, 8495, 8052, 13820, 8056, 14481, 13822, 8497, 8048, 8051, + 13823, 4894, 13824, 13830, 8058, 8498, 65535, 13826, 13831, 13819, 8508, + 3371, 8499, 8057, 13817, 13832, 3454, 8507, 8055, 8492, 13829, 65535, 8059, + 13821, 13815, 8049, 13818, 65535, 13827, 4696, 8491, 8496, 8046, 13828, + 65535, 8494, 65535, 65535, 1740, 8047, 65535, 65535, 65535, 8506, 15169, + 14492, 65535, 14484, 15168, 65535, 14488, 14490, 4772, 65535, 14487, 65535, + 8505, 65535, 14486, 8509, 65535, 65535, 65535, 15184, 65535, 1934, 8504, + 8949, 14493, 15170, 19365, 65535, 8502, 14485, 14489, 8948, 8493, 14482, + 14483, 8950, 8501, 8503, 8500, 14491, 3368, 65535, 15174, 15175, 15180, + 9324, 15187, 65535, 8956, 4913, 8955, 15182, 19383, 9323, 15171, 8954, + 19261, 15186, 8952, 8953, 19363, 15183, 15772, 9321, 8053, 65535, 15185, + 9328, 15177, 65535, 9322, 4919, 9327, 15172, 15176, 15173, 15179, 8957, + 9320, 8951, 65535, 15758, 15181, 65535, 9326, 4916, 9329, 65535, 15178, + 19368, 9325, 15757, 65535, 65535, 65535, 19371, 65535, 15762, 9685, 15756, + 16393, 15771, 9333, 65535, 9331, 9683, 15768, 15764, 9337, 4255, 16384, + 65535, 2883, 2882, 9335, 15763, 4990, 16382, 65535, 15767, 65535, 15770, + 15761, 65535, 9336, 65535, 65535, 9330, 16383, 9684, 15769, 9332, 9334, + 15766, 9338, 15765, 15760, 15759, 9682, 15773, 16386, 16925, 9687, 1937, + 16392, 1938, 16390, 65535, 16926, 65535, 9688, 16391, 2878, 16388, 9973, + 16924, 65535, 16385, 16387, 9974, 9690, 9972, 9689, 9976, 16389, 9686, + 65535, 1939, 19378, 65535, 65535, 19375, 65535, 65535, 17379, 65535, 17371, + 65535, 2452, 65535, 65535, 65535, 16932, 17372, 16928, 65535, 4924, 10227, + 16930, 16929, 9975, 16927, 16931, 17380, 17376, 17378, 65535, 17373, 17374, + 65535, 17377, 17375, 10401, 65535, 65535, 10404, 10403, 10402, 10552, + 18065, 10553, 17742, 10644, 18318, 10645, 10728, 10780, 18645, 65535, + 18646, 18647, 65535, 65535, 18928, 5621, 11364, 5733, 65535, 5877, 5878, + 5876, 65535, 5879, 6086, 6085, 65535, 11854, 6389, 6388, 65535, 65535, + 12637, 7611, 7612, 65535, 65535, 65535, 8060, 14494, 8510, 8511, 14496, + 14498, 14497, 65535, 15189, 65535, 15188, 8958, 15190, 1941, 15774, 9339, + 65535, 9691, 65535, 9977, 10228, 9978, 65535, 5622, 1724, 65535, 4921, + 11593, 65535, 65535, 11855, 6391, 6390, 6392, 6739, 12201, 12202, 65535, + 65535, 12638, 7143, 7613, 8061, 13833, 5623, 1677, 5557, 5624, 65535, + 11365, 5737, 5736, 5734, 5735, 65535, 65535, 65535, 5882, 11439, 11441, + 5881, 11433, 65535, 11434, 65535, 11440, 11436, 11438, 5880, 11435, 11442, + 11437, 65535, 4736, 65535, 65535, 65535, 65535, 6093, 6102, 6100, 11603, + 11600, 11608, 6098, 11609, 65535, 6091, 11606, 65535, 6097, 11602, 11601, + 6095, 11607, 6096, 6393, 6090, 11604, 4856, 11594, 6087, 4798, 6106, 11599, + 11605, 6092, 6094, 65535, 11595, 65535, 11596, 11597, 1942, 6105, 6099, + 6104, 11598, 6103, 6089, 6088, 6101, 65535, 65535, 65535, 65535, 4558, + 65535, 65535, 65535, 65535, 65535, 65535, 2904, 65535, 4920, 65535, 6407, + 11867, 11860, 6402, 6421, 11856, 11863, 11865, 11868, 6416, 65535, 11864, + 11857, 6414, 11861, 65535, 11869, 6399, 65535, 11866, 6409, 6408, 11859, + 6397, 65535, 1065, 6398, 4088, 6396, 19387, 6420, 6412, 6406, 6394, 11862, + 6405, 6395, 6413, 4922, 12203, 4494, 11858, 6400, 6403, 6404, 19389, 6418, + 6419, 6417, 6411, 6415, 6401, 6740, 65535, 65535, 19014, 65535, 65535, + 65535, 65535, 65535, 1943, 65535, 65535, 65535, 65535, 65535, 12209, 6752, + 6744, 6746, 6751, 12221, 6749, 12639, 7144, 6754, 12206, 12214, 6750, + 12213, 12210, 12218, 12220, 6743, 6747, 6753, 7146, 12215, 6745, 6756, + 12208, 65535, 65535, 65535, 6748, 7145, 6742, 65535, 12205, 12212, 12204, + 12207, 12211, 12640, 6755, 65535, 12216, 12217, 12219, 6741, 65535, 1944, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7160, 12652, 7158, 7159, 12642, 12658, + 4669, 7149, 65535, 2900, 13226, 12660, 12654, 4737, 12645, 2897, 12663, + 12648, 7155, 13249, 12651, 7157, 7148, 65535, 12665, 12653, 7151, 12646, + 12643, 12644, 7152, 12659, 12666, 7154, 12650, 12649, 7162, 7161, 7147, + 7153, 7156, 12662, 65535, 65535, 12656, 7150, 12641, 12664, 12655, 12657, + 12661, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4927, + 13227, 65535, 7621, 7641, 7640, 65535, 7629, 19391, 13245, 13241, 13238, + 13256, 7624, 7616, 65535, 65535, 13243, 8077, 7620, 13251, 1508, 7642, + 7639, 13247, 13230, 65535, 4792, 7638, 13253, 13229, 7627, 7631, 13252, + 65535, 13239, 7632, 7626, 13228, 19385, 8063, 13255, 13237, 7637, 13240, + 13254, 7636, 65535, 13834, 65535, 7617, 13235, 7622, 7633, 65535, 7628, + 13244, 13234, 13232, 13250, 7614, 7634, 7618, 8062, 13248, 7619, 65535, + 7615, 7630, 7625, 7623, 13236, 7635, 13233, 13246, 13242, 13836, 13835, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4565, 65535, 65535, 65535, + 13231, 13852, 65535, 8065, 2297, 13858, 13841, 13855, 14499, 8068, 13859, + 13862, 8067, 13844, 13861, 13860, 8069, 13837, 8064, 8072, 2901, 8070, + 13857, 65535, 13847, 8074, 13864, 13856, 13865, 8082, 8080, 13854, 13853, + 4493, 13851, 13845, 8073, 1948, 8071, 12647, 13838, 4406, 14529, 13839, + 8066, 8079, 14501, 65535, 8075, 8076, 13840, 13863, 14500, 13848, 13843, + 8078, 13849, 13846, 65535, 19395, 8083, 65535, 1949, 4564, 65535, 4566, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8526, 1950, 65535, 14504, + 14523, 14528, 14516, 8522, 14533, 8519, 14502, 65535, 14503, 8512, 8521, + 14510, 8524, 8525, 14511, 65535, 14524, 14530, 8520, 65535, 8514, 14509, + 14505, 14532, 14514, 14515, 14506, 14526, 14517, 14527, 14519, 65535, 8515, + 15191, 8518, 8516, 14531, 14522, 14518, 65535, 1568, 14507, 8968, 14521, + 8523, 14513, 19394, 14512, 19408, 2906, 65535, 8517, 8513, 15212, 14525, + 14520, 65535, 14508, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 15207, 65535, 15192, 15203, 65535, 15210, 8966, 8081, 15208, 8961, 65535, + 65535, 65535, 8960, 15215, 1951, 15193, 15206, 15194, 15205, 8964, 15209, + 13850, 65535, 65535, 65535, 15216, 15201, 8967, 15788, 9340, 65535, 15214, + 15213, 8969, 15775, 9341, 15776, 2889, 15197, 15198, 15195, 15200, 15196, + 15217, 8963, 9342, 8965, 8970, 1513, 15199, 65535, 15211, 65535, 65535, + 15204, 65535, 65535, 15779, 65535, 8959, 9345, 16400, 15784, 15783, 15785, + 1440, 65535, 15782, 9346, 1269, 9352, 9349, 65535, 9350, 15777, 15780, + 15790, 9358, 9356, 65535, 15781, 13842, 9343, 15787, 15778, 65535, 9359, + 15786, 8962, 9348, 15202, 65535, 65535, 9351, 65535, 9355, 9357, 9354, + 9353, 19739, 9347, 15789, 9344, 9360, 1469, 65535, 2899, 65535, 65535, + 65535, 65535, 9695, 9696, 16399, 9705, 9702, 1953, 9693, 9700, 16401, 9698, + 9692, 65535, 9699, 65535, 16398, 9980, 9694, 65535, 9701, 9979, 16397, + 16396, 65535, 9703, 4715, 9704, 65535, 16395, 16394, 9981, 16404, 9697, + 16402, 65535, 1435, 65535, 65535, 9982, 19404, 9987, 16935, 16937, 19405, + 9984, 2173, 16938, 16934, 1479, 16936, 9985, 9988, 65535, 16933, 9983, + 9986, 10230, 16403, 10229, 65535, 65535, 10235, 17384, 65535, 10233, 10234, + 17387, 17383, 10231, 17381, 10405, 17385, 65535, 17386, 17382, 65535, + 10232, 17743, 65535, 17746, 1259, 65535, 17747, 17745, 17748, 10406, 17744, + 2971, 65535, 18069, 10555, 18068, 18067, 18066, 10554, 10556, 65535, 18319, + 10647, 10646, 19384, 4617, 18496, 18495, 18498, 10781, 10729, 18649, 18497, + 65535, 65535, 18648, 10783, 10782, 10821, 18754, 18824, 5625, 4497, 65535, + 13866, 16405, 10945, 1678, 5883, 11610, 6109, 6107, 65535, 6108, 65535, + 11870, 6423, 6757, 65535, 12222, 65535, 12223, 65535, 6758, 12668, 65535, + 7163, 7164, 12667, 65535, 65535, 19410, 65535, 7649, 65535, 7645, 65535, + 13257, 7652, 7651, 7644, 7647, 7650, 7646, 65535, 65535, 13870, 7643, 8084, + 19416, 65535, 65535, 8086, 8087, 13869, 13872, 8085, 13867, 13871, 65535, + 13868, 2907, 8527, 19415, 65535, 14534, 65535, 65535, 8971, 15218, 9706, + 9361, 15791, 9362, 9363, 15793, 15792, 15794, 16407, 65535, 65535, 16406, + 16940, 16939, 9989, 9990, 17749, 19414, 1958, 5626, 19254, 1295, 65535, + 1789, 13873, 65535, 65535, 65535, 8089, 8088, 14535, 65535, 17388, 10648, + 18650, 5627, 65535, 7165, 65535, 7654, 7653, 13874, 13875, 8528, 15219, + 8972, 16408, 65535, 5628, 5738, 65535, 6424, 11871, 65535, 12224, 6759, + 7655, 65535, 13876, 8090, 8529, 65535, 15795, 15796, 65535, 19418, 16941, + 10236, 18825, 5629, 65535, 11872, 6425, 6760, 4384, 12225, 65535, 7166, + 12672, 12670, 12671, 7167, 12669, 65535, 65535, 65535, 65535, 7657, 7658, + 13258, 7659, 7656, 13877, 19421, 13878, 14536, 3229, 65535, 8974, 8973, + 65535, 65535, 16942, 17389, 65535, 17751, 17750, 18070, 10946, 11334, 6761, + 19425, 65535, 5630, 5739, 65535, 5885, 5884, 65535, 65535, 5886, 5887, + 11444, 11443, 11611, 6110, 11614, 11613, 11612, 11615, 65535, 65535, 65535, + 65535, 6426, 11878, 11874, 11883, 65535, 1960, 6433, 65535, 6431, 11879, + 11875, 11882, 6430, 6437, 11877, 11873, 6436, 11880, 6429, 11881, 6432, + 6434, 11885, 11884, 11876, 6428, 6427, 6435, 65535, 65535, 19428, 65535, + 65535, 65535, 12230, 12236, 2947, 6767, 6764, 12227, 12232, 19660, 6770, + 6762, 12231, 6765, 6768, 65535, 65535, 12234, 65535, 6763, 12239, 6766, + 2941, 6769, 12228, 12233, 12237, 12229, 12226, 65535, 65535, 12238, 12235, + 65535, 65535, 65535, 65535, 65535, 65535, 7175, 7168, 7171, 19431, 7174, + 65535, 12675, 4131, 7169, 12673, 19434, 7173, 978, 65535, 7170, 65535, + 12676, 7172, 1961, 65535, 65535, 65535, 19141, 65535, 13262, 7661, 13261, + 13263, 7660, 7665, 12674, 1025, 13260, 13264, 2944, 7662, 13259, 7664, + 19436, 7663, 65535, 13885, 2939, 13880, 65535, 8091, 8095, 8092, 13883, + 13886, 19438, 8093, 65535, 8094, 8099, 14545, 13884, 8097, 13881, 13879, + 2095, 8098, 65535, 13882, 65535, 65535, 65535, 8535, 19345, 14537, 8532, + 8533, 8531, 14542, 14541, 14538, 8537, 2937, 65535, 14540, 8096, 1963, + 65535, 14544, 14539, 8534, 8530, 8536, 14543, 3636, 65535, 65535, 8977, + 65535, 15222, 15221, 15220, 8975, 65535, 19172, 65535, 65535, 65535, 8976, + 15799, 15802, 9365, 65535, 19173, 9364, 15803, 15798, 9367, 15800, 19167, + 9366, 15797, 4332, 15801, 9712, 9709, 16417, 16416, 65535, 16415, 16410, + 4132, 16411, 65535, 65535, 65535, 9710, 65535, 9707, 9711, 16409, 9708, + 16412, 16413, 16418, 19170, 2918, 16414, 65535, 65535, 16943, 65535, 65535, + 65535, 9992, 65535, 17392, 9991, 17390, 17391, 10237, 10408, 17752, 65535, + 10407, 65535, 65535, 18072, 18073, 65535, 10557, 1848, 18071, 10649, 65535, + 18651, 10784, 18755, 18756, 65535, 5631, 4539, 5888, 5889, 6111, 65535, + 11886, 6771, 7176, 7666, 65535, 65535, 7491, 65535, 8100, 8101, 7956, + 13887, 19448, 8538, 15224, 15223, 65535, 65535, 5632, 5890, 11887, 6439, + 4956, 6438, 4144, 12240, 12241, 65535, 12677, 12678, 7177, 7178, 1965, + 7179, 13265, 1745, 65535, 7668, 65535, 8103, 4059, 8102, 14546, 14816, + 15225, 16419, 65535, 2163, 10238, 10558, 5633, 65535, 5742, 5743, 5741, + 5744, 5740, 65535, 65535, 5893, 65535, 11452, 5892, 5894, 4390, 65535, + 11447, 11446, 11449, 11448, 11451, 5891, 11445, 11450, 65535, 65535, 65535, + 65535, 19013, 11616, 6121, 11617, 11621, 6120, 65535, 11625, 11620, 11623, + 6113, 6114, 6115, 6116, 65535, 6123, 65535, 11619, 6118, 6124, 65535, + 11618, 11624, 65535, 6117, 11622, 6119, 6112, 6122, 3744, 19456, 65535, + 65535, 65535, 65535, 19455, 65535, 65535, 6460, 1831, 11889, 6440, 995, + 6450, 6451, 6443, 6461, 6445, 11897, 6456, 11892, 6446, 11907, 11908, + 11900, 11893, 6459, 11905, 6454, 6452, 65535, 11906, 1030, 11904, 11896, + 11888, 11895, 6447, 65535, 6453, 65535, 6441, 11899, 11898, 11890, 2957, + 6455, 11902, 11891, 6458, 11909, 6442, 65535, 6449, 11894, 11903, 6457, + 65535, 6444, 6448, 65535, 11901, 3950, 65535, 65535, 65535, 1967, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19481, 65535, 12273, 6779, 6792, + 19498, 12268, 12258, 6785, 12256, 6778, 12251, 6788, 12264, 12245, 12247, + 65535, 65535, 65535, 2259, 12250, 12242, 12263, 12279, 6783, 12252, 12270, + 65535, 12244, 12277, 12278, 12281, 12272, 12257, 12265, 6789, 6776, 6784, + 6796, 6773, 6775, 65535, 3147, 19459, 12249, 6793, 6786, 12275, 12246, + 6795, 6790, 12255, 65535, 65535, 6794, 12262, 12254, 6787, 12274, 12266, + 65535, 6781, 12280, 12253, 6777, 12271, 12261, 6782, 12267, 6774, 12243, + 6791, 7194, 6780, 12260, 12259, 12248, 2685, 12276, 65535, 12269, 65535, + 1296, 6772, 1968, 19464, 4928, 3765, 1297, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19640, 65535, 65535, 2691, 65535, 12698, 7201, + 12699, 65535, 12687, 7190, 7202, 65535, 12680, 19100, 12689, 12697, 2960, + 12679, 12706, 7180, 19461, 65535, 65535, 12705, 12700, 65535, 12701, 7188, + 7199, 12691, 65535, 12692, 12702, 12693, 65535, 12688, 12682, 12683, 12696, + 12690, 4368, 19539, 7181, 7185, 12704, 12684, 7197, 7193, 19315, 65535, + 7196, 7203, 7186, 7198, 12695, 7200, 7183, 3297, 7182, 12681, 1970, 12685, + 7191, 12703, 12694, 12686, 7195, 7192, 65535, 7184, 7187, 4092, 2285, + 65535, 65535, 65535, 65535, 65535, 65535, 19467, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1298, 65535, 65535, 65535, 65535, 65535, 13286, + 65535, 13270, 13271, 13275, 65535, 13290, 13287, 65535, 13280, 13279, 7675, + 13283, 13298, 13266, 65535, 13299, 13285, 13303, 13291, 7674, 13289, 7669, + 7690, 7680, 1971, 7684, 7683, 13267, 2574, 13296, 13302, 13294, 13301, + 65535, 65535, 13282, 13268, 13300, 13284, 7672, 7685, 65535, 13293, 7678, + 2972, 65535, 65535, 13292, 13269, 7686, 65535, 7688, 13295, 7689, 7671, + 13276, 13297, 65535, 19214, 7677, 7687, 13278, 13288, 13273, 13277, 7682, + 13272, 7670, 7679, 7676, 13281, 7189, 13910, 7673, 2959, 65535, 65535, + 3595, 65535, 65535, 65535, 19635, 65535, 65535, 65535, 65535, 65535, 19473, + 7681, 3364, 13913, 13935, 13924, 8123, 19751, 8118, 13907, 8119, 13923, + 65535, 13916, 13929, 8115, 13889, 13931, 8105, 13897, 8108, 8107, 65535, + 8124, 65535, 13891, 13925, 13926, 8110, 8106, 13905, 65535, 8117, 13900, + 65535, 13927, 8113, 13919, 13932, 13894, 13899, 13893, 65535, 8112, 13912, + 14568, 13895, 8116, 13904, 13928, 8111, 13901, 13898, 13915, 8114, 8104, + 8126, 13918, 13917, 65535, 65535, 19476, 19475, 19769, 19667, 13890, 8109, + 13930, 13906, 13908, 1975, 13921, 13920, 13888, 8120, 8122, 13896, 13903, + 13911, 8121, 13902, 13914, 13933, 65535, 13922, 4145, 1791, 4010, 2195, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 13934, + 65535, 65535, 65535, 65535, 13892, 65535, 4773, 65535, 65535, 14588, 8546, + 65535, 14586, 14565, 14570, 14563, 19485, 14582, 14549, 14556, 65535, + 14580, 14590, 14566, 19072, 14553, 14572, 14577, 14557, 1976, 14574, 14554, + 1322, 65535, 14561, 14562, 8548, 14581, 14579, 65535, 14550, 14584, 65535, + 14585, 14587, 8552, 8544, 4044, 13274, 14558, 14576, 14559, 8541, 8557, + 14583, 8555, 8551, 14548, 8543, 19482, 14551, 8556, 1978, 14567, 14547, + 3596, 8549, 14571, 14555, 8550, 14564, 8540, 8125, 14573, 13909, 14552, + 2908, 19472, 14578, 8545, 14575, 8542, 14569, 8553, 14560, 14589, 65535, + 65535, 65535, 65535, 4779, 65535, 8547, 14701, 65535, 1980, 8554, 65535, + 65535, 65535, 3852, 65535, 65535, 15239, 15237, 65535, 15259, 15235, 65535, + 15253, 8539, 8980, 15231, 15258, 19486, 15236, 15250, 8985, 8978, 65535, + 15256, 1979, 15229, 15255, 2047, 8996, 15246, 15262, 8994, 15238, 8979, + 15240, 15254, 8988, 15233, 8992, 8982, 15242, 15232, 15226, 4978, 15252, + 8989, 15261, 15227, 8986, 65535, 15248, 65535, 8987, 15234, 15245, 15241, + 15243, 4814, 8981, 15260, 8995, 15244, 65535, 15263, 65535, 65535, 15228, + 15249, 8984, 8993, 8991, 15230, 15251, 8990, 2778, 65535, 8983, 15247, + 4385, 1982, 65535, 65535, 15257, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19469, 15815, 65535, 15811, 15807, 15827, 15824, 9370, 4094, 65535, + 15831, 15814, 9381, 15821, 65535, 65535, 15810, 15820, 9378, 15840, 65535, + 15837, 15823, 15808, 19491, 19452, 15828, 15830, 9374, 15818, 15813, 15804, + 9371, 9379, 4363, 15833, 9380, 15805, 15839, 15826, 15832, 9377, 19470, + 3655, 15829, 65535, 15836, 65535, 9382, 65535, 9376, 15822, 15809, 15841, + 15806, 15834, 9373, 3605, 15816, 3164, 15817, 9372, 9369, 15812, 9375, + 65535, 9368, 65535, 15835, 15838, 15819, 16432, 1026, 65535, 3641, 19684, + 3090, 65535, 65535, 65535, 65535, 16424, 2966, 16420, 9725, 65535, 65535, + 9714, 9719, 9715, 16434, 16445, 9713, 16426, 16435, 15825, 16436, 65535, + 1792, 9720, 19494, 16451, 9724, 9727, 16422, 65535, 9723, 2973, 16449, + 16450, 16440, 16439, 16431, 2967, 2177, 16441, 16448, 16447, 2225, 9718, + 9716, 16433, 16430, 65535, 16427, 16446, 9726, 16444, 9722, 9721, 1757, + 16438, 1984, 16421, 16423, 16425, 16443, 16437, 9717, 65535, 16428, 65535, + 16442, 65535, 1986, 65535, 65535, 1985, 65535, 16429, 65535, 65535, 65535, + 2975, 65535, 65535, 65535, 10000, 16961, 9993, 16946, 1987, 16957, 9995, + 16964, 65535, 16953, 65535, 16948, 19298, 65535, 16965, 16944, 16955, 3345, + 10002, 16960, 16966, 16954, 9994, 16956, 16945, 10001, 65535, 1989, 16963, + 16950, 9997, 19496, 16952, 16949, 10003, 16951, 9996, 9999, 16959, 16947, + 16962, 2235, 16958, 65535, 65535, 1991, 10240, 17403, 10245, 10246, 65535, + 4466, 3134, 10239, 17402, 1992, 17399, 17400, 10243, 17394, 17398, 10242, + 65535, 17395, 2962, 65535, 65535, 65535, 10244, 10241, 65535, 17393, 17397, + 17401, 19499, 2968, 4794, 17758, 17755, 17764, 65535, 17763, 17761, 17756, + 65535, 10412, 1993, 65535, 65535, 65535, 3489, 17757, 10411, 9998, 17760, + 10410, 17765, 17759, 17754, 17396, 65535, 65535, 65535, 10409, 65535, + 17753, 18077, 65535, 18076, 17762, 10559, 65535, 18080, 18081, 18075, + 18079, 65535, 18074, 65535, 65535, 1994, 65535, 18323, 18078, 10652, 10650, + 18321, 65535, 65535, 65535, 18324, 65535, 18320, 18322, 10651, 2969, 65535, + 65535, 18500, 18501, 10730, 18499, 65535, 65535, 65535, 18654, 10785, + 18652, 18653, 18757, 65535, 65535, 10855, 18828, 18826, 18827, 18829, + 65535, 65535, 19502, 18929, 65535, 5634, 5895, 65535, 6462, 65535, 11910, + 65535, 65535, 12282, 65535, 65535, 65535, 12707, 12709, 65535, 12708, + 65535, 12710, 7691, 13305, 12711, 19505, 13304, 13306, 13307, 13936, 8128, + 13937, 13939, 8129, 8127, 13938, 65535, 14596, 14594, 14593, 65535, 14592, + 14591, 8558, 14595, 8997, 15264, 15266, 8998, 15265, 9384, 65535, 9383, + 15842, 4831, 65535, 16453, 16452, 16454, 2976, 65535, 9728, 65535, 16967, + 10004, 65535, 17404, 10247, 17766, 10731, 5635, 5745, 5896, 6125, 6463, + 6464, 65535, 65535, 6797, 65535, 65535, 12712, 65535, 1719, 65535, 65535, + 8559, 65535, 19506, 65535, 15968, 9729, 10248, 5636, 1679, 5897, 65535, + 65535, 11912, 6465, 11911, 1995, 12283, 6798, 12284, 65535, 6799, 65535, + 12714, 7205, 7204, 65535, 13312, 13310, 13311, 13309, 65535, 13308, 65535, + 65535, 13940, 13943, 8131, 13941, 8130, 13942, 65535, 14597, 65535, 65535, + 15267, 15268, 15269, 65535, 15845, 15844, 9385, 15843, 15846, 16455, 65535, + 65535, 16456, 16457, 65535, 16968, 10005, 10249, 17767, 65535, 10653, + 11335, 65535, 6800, 12285, 7206, 65535, 65535, 7692, 65535, 8132, 13944, + 65535, 8561, 8560, 1996, 65535, 15270, 15271, 9386, 9387, 16459, 16458, + 17405, 18655, 5637, 11336, 5746, 65535, 6126, 11626, 65535, 6801, 8562, + 5638, 65535, 12286, 6802, 12287, 65535, 10006, 5639, 19517, 65535, 11913, + 65535, 12288, 19515, 12719, 12718, 12716, 65535, 12715, 12720, 12717, + 65535, 1997, 7693, 7694, 65535, 65535, 8133, 13945, 65535, 13946, 13947, + 65535, 65535, 65535, 14602, 14603, 14601, 4843, 14599, 14600, 8563, 15272, + 15849, 15848, 15847, 15850, 16461, 16460, 9730, 16462, 65535, 10007, 16969, + 65535, 17406, 17768, 18502, 65535, 5640, 5748, 5747, 65535, 6466, 11337, + 11366, 5898, 65535, 11453, 11627, 11628, 6467, 2446, 11914, 65535, 6803, + 12289, 12290, 65535, 7207, 7211, 12721, 7210, 7208, 7209, 65535, 13313, + 7695, 8136, 65535, 8134, 8135, 13948, 4820, 65535, 8999, 5641, 1680, 11367, + 19518, 5749, 4315, 1681, 11370, 65535, 1534, 5752, 11369, 5751, 5750, 6127, + 11368, 65535, 65535, 11454, 65535, 65535, 19127, 4708, 11460, 11461, 5908, + 5909, 11457, 5904, 65535, 11455, 65535, 11459, 5905, 65535, 5900, 3248, + 5901, 19522, 5907, 11456, 5899, 6128, 5902, 5903, 5906, 65535, 65535, + 65535, 11645, 11643, 11630, 6140, 11637, 6135, 11631, 65535, 11639, 19188, + 11636, 6138, 11635, 6145, 11644, 6147, 1998, 6149, 65535, 11629, 19524, + 6136, 11646, 65535, 6143, 6146, 2170, 11937, 6130, 6153, 6144, 11632, 6133, + 6148, 11640, 6131, 6132, 11935, 11633, 6139, 6150, 11647, 11634, 6137, + 65535, 6142, 11915, 6151, 11641, 6141, 65535, 6152, 6129, 11638, 6134, + 11642, 11936, 65535, 2409, 65535, 65535, 3711, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1999, 6479, 6495, 11922, 6486, 3565, 11943, 6471, + 4637, 6474, 11934, 65535, 11920, 11924, 6482, 6484, 11927, 6491, 6477, + 6475, 6476, 6490, 11939, 6485, 11926, 11928, 6483, 6488, 11929, 11942, + 65535, 6804, 6494, 19098, 6472, 11941, 4869, 11945, 11925, 11947, 11932, + 6481, 11921, 6480, 6498, 6487, 65535, 11919, 12299, 6493, 6497, 11933, + 11938, 3662, 6499, 6492, 6478, 6468, 65535, 6473, 65535, 11923, 6469, + 11946, 4864, 11917, 11916, 11930, 11918, 6496, 7212, 6489, 11931, 6470, + 65535, 6819, 65535, 65535, 65535, 11944, 65535, 65535, 65535, 65535, 65535, + 1794, 12306, 12309, 2001, 12312, 12301, 2822, 2002, 12315, 12318, 12320, + 12298, 6805, 6810, 12726, 6826, 12313, 12321, 12305, 12297, 65535, 65535, + 65535, 12753, 6813, 12310, 12302, 12304, 6818, 65535, 12307, 6812, 12294, + 12316, 65535, 12319, 65535, 2998, 6809, 2003, 6821, 12291, 6823, 6807, + 6827, 12317, 12293, 6824, 12747, 11940, 6811, 6806, 12300, 12292, 6825, + 6817, 12311, 6822, 6820, 12303, 6814, 12295, 6815, 6816, 12296, 12314, + 6808, 12308, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1299, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3562, 12729, 7220, 7225, 19142, 19544, 65535, 12738, 12744, 12740, 12727, + 12730, 12723, 12724, 7232, 7217, 2990, 12748, 7227, 7213, 65535, 7222, + 12731, 7224, 12732, 12742, 19231, 2754, 65535, 7226, 12757, 12725, 7219, + 7218, 7230, 12722, 12755, 12743, 12756, 12750, 12736, 12751, 2004, 12745, + 12754, 12752, 7231, 12737, 7216, 7215, 7223, 7229, 12749, 7228, 12734, + 7696, 4265, 12758, 12733, 12728, 7221, 7233, 7214, 19543, 12741, 12746, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2006, 2987, 65535, 65535, 65535, 65535, 7730, 13315, 13319, 65535, + 7711, 7709, 65535, 2007, 7700, 13317, 13316, 7720, 65535, 13322, 7714, + 4983, 13340, 13352, 7697, 13337, 13330, 7732, 13314, 65535, 13342, 65535, + 7729, 7717, 7728, 7707, 13326, 13344, 13336, 7708, 7702, 13350, 65535, + 13343, 13345, 7710, 7718, 13347, 13324, 13341, 13329, 13349, 7723, 7699, + 7721, 13334, 13332, 13333, 7712, 13328, 13327, 7701, 13321, 13351, 7703, + 13331, 7733, 65535, 7727, 13320, 7724, 7722, 7731, 13338, 7726, 12735, + 13339, 7725, 13346, 7698, 13335, 7716, 13323, 7715, 65535, 7713, 7705, + 7704, 13949, 13348, 1728, 65535, 13325, 65535, 3569, 13970, 2993, 7706, + 65535, 65535, 65535, 65535, 2996, 65535, 65535, 65535, 65535, 3559, 65535, + 65535, 65535, 65535, 65535, 2008, 65535, 65535, 2009, 8165, 7719, 8147, + 13964, 8161, 65535, 13952, 8144, 8140, 13982, 8146, 8150, 8145, 8154, + 13986, 13977, 2010, 19776, 13959, 8159, 8153, 13971, 8137, 13983, 13976, + 8141, 13965, 8156, 13994, 13995, 65535, 8138, 13981, 8158, 13969, 13955, + 13956, 8162, 13960, 13967, 13961, 65535, 8160, 8168, 13957, 13950, 13951, + 65535, 13953, 8143, 13966, 65535, 8157, 8166, 19562, 19462, 13968, 13992, + 13984, 8139, 13990, 8151, 1850, 8149, 19216, 13996, 8148, 13974, 13962, + 13972, 8171, 13978, 13975, 13958, 8167, 13988, 13985, 13993, 8142, 13973, + 8170, 65535, 13980, 65535, 65535, 8152, 8155, 65535, 13979, 8169, 13963, + 13318, 65535, 2750, 13989, 13987, 13991, 65535, 65535, 19545, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2011, 65535, 13954, 8164, + 65535, 3253, 65535, 14634, 14633, 14607, 8569, 65535, 14632, 14610, 14611, + 65535, 8579, 14641, 8574, 14631, 1351, 14604, 8580, 8570, 14619, 14609, + 14612, 14636, 8564, 14643, 14635, 8573, 14624, 8584, 65535, 65535, 8583, + 8577, 65535, 65535, 14642, 8565, 14622, 14613, 14626, 14638, 8585, 19508, + 8567, 14621, 4324, 14614, 8576, 2013, 8575, 14617, 14627, 14637, 14608, + 14618, 8568, 14628, 8581, 8572, 14615, 8571, 14606, 14620, 14640, 8163, + 9027, 14623, 15273, 14625, 14639, 8578, 14616, 8566, 8582, 9405, 14605, + 65535, 14630, 19091, 2015, 19033, 14629, 1263, 65535, 65535, 65535, 65535, + 2014, 65535, 65535, 65535, 65535, 65535, 2017, 2018, 65535, 15301, 9024, + 15290, 15295, 9013, 65535, 15275, 9026, 65535, 9004, 15274, 15307, 9028, + 15278, 15294, 19569, 15280, 15310, 15306, 9002, 9012, 15876, 9025, 9010, + 15276, 19546, 15305, 9014, 15302, 15315, 15282, 15291, 2988, 3570, 15313, + 15303, 9009, 65535, 65535, 15289, 9003, 9001, 9019, 19411, 3615, 15287, + 15284, 15285, 65535, 15309, 65535, 15314, 15312, 9007, 15316, 9011, 9018, + 2019, 15277, 15852, 15286, 65535, 9005, 9023, 9020, 9008, 15296, 15281, + 9021, 15298, 9015, 9017, 9000, 2020, 15300, 15292, 15279, 9016, 15308, + 15311, 15288, 15299, 19641, 9006, 9388, 15297, 15851, 65535, 15304, 19574, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 15283, + 15861, 15871, 9391, 15870, 15882, 9393, 15868, 4465, 15872, 9404, 65535, + 15863, 9396, 19575, 15875, 16470, 9408, 9407, 15877, 15860, 15887, 9402, + 65535, 9392, 15880, 65535, 15884, 15889, 15878, 15866, 9395, 9398, 9406, + 9401, 65535, 15869, 15293, 19577, 65535, 15865, 15888, 9397, 3252, 9400, + 15890, 9389, 15879, 15853, 15885, 10016, 2023, 15867, 65535, 9390, 15862, + 9394, 15854, 9022, 15858, 19399, 15883, 15859, 15857, 9399, 65535, 15881, + 65535, 15856, 15874, 15873, 15886, 15864, 9403, 65535, 65535, 65535, 65535, + 65535, 19567, 16473, 19580, 9743, 9733, 16485, 16465, 9735, 16477, 9742, + 9737, 16475, 16971, 16481, 16487, 16480, 16463, 16478, 16489, 16491, 9732, + 16490, 9738, 9744, 4361, 4230, 65535, 16484, 9740, 16479, 3249, 16467, + 16472, 2024, 16483, 9739, 9736, 9731, 9734, 16471, 65535, 15855, 16466, + 16469, 16486, 16474, 16464, 16970, 16488, 16468, 16482, 65535, 65535, + 65535, 19582, 16973, 10020, 65535, 65535, 10008, 3435, 3434, 10012, 16975, + 16981, 16979, 10010, 10011, 10018, 16982, 16974, 10013, 65535, 16978, + 16977, 16983, 10019, 65535, 10014, 10017, 16976, 10021, 10015, 10022, + 10009, 16980, 65535, 16972, 65535, 2439, 17419, 19565, 65535, 10254, 17416, + 17418, 65535, 10252, 17414, 17415, 17410, 65535, 3684, 16476, 17411, 10253, + 17407, 65535, 10250, 17420, 10251, 17408, 17409, 17413, 10256, 65535, + 10255, 65535, 65535, 17412, 10418, 17772, 17778, 10419, 17769, 10416, + 10413, 17780, 10417, 3436, 10414, 17771, 17774, 17775, 17776, 17779, 65535, + 17417, 17770, 10415, 17777, 17781, 17773, 2030, 65535, 65535, 18084, 10561, + 18087, 10562, 18095, 18086, 18083, 65535, 18085, 18089, 18092, 18091, + 18094, 18082, 65535, 10560, 18090, 18093, 18096, 18088, 18325, 18326, + 18330, 18331, 65535, 18328, 18329, 18327, 19594, 10654, 1766, 65535, 65535, + 2032, 10732, 18506, 65535, 2033, 18503, 18504, 18505, 10733, 65535, 18657, + 18656, 2350, 18760, 10822, 18758, 18761, 18759, 18830, 10856, 10870, 18905, + 18884, 3564, 18904, 18950, 18951, 5642, 1682, 65535, 1066, 2034, 5910, + 11462, 65535, 65535, 11648, 2474, 6154, 1734, 6157, 19139, 11649, 65535, + 6155, 6156, 19595, 2035, 65535, 19597, 11956, 11958, 11953, 11950, 11952, + 65535, 65535, 2036, 6503, 19189, 65535, 65535, 6501, 2423, 65535, 11954, + 6502, 11951, 11948, 6500, 11955, 65535, 11949, 6504, 11957, 65535, 65535, + 65535, 65535, 12323, 3816, 12327, 65535, 2649, 6836, 3502, 3658, 19596, + 65535, 12330, 65535, 6828, 6831, 6833, 6835, 6832, 12326, 12325, 65535, + 6830, 12328, 12329, 65535, 12322, 6834, 3755, 6829, 4079, 1300, 19623, + 12324, 65535, 3798, 65535, 65535, 65535, 3231, 12772, 12773, 12774, 7238, + 65535, 7234, 12763, 19598, 12771, 12776, 7239, 2644, 12761, 12767, 12760, + 12770, 19599, 19600, 12766, 7235, 7237, 12775, 65535, 12759, 12762, 12768, + 19601, 12769, 12777, 12765, 65535, 7236, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 7738, 13359, 3003, 65535, 13361, 13357, + 3854, 13369, 13355, 13368, 7734, 13353, 14000, 13363, 7737, 3589, 13364, + 13367, 65535, 13371, 65535, 13360, 2832, 13365, 65535, 65535, 7735, 7736, + 13370, 13358, 13354, 13372, 65535, 13362, 65535, 65535, 13366, 65535, + 65535, 65535, 13356, 65535, 8172, 8173, 14010, 8179, 3646, 13998, 14007, + 13997, 8176, 14005, 14003, 65535, 14004, 8174, 65535, 14008, 3230, 65535, + 19607, 19617, 65535, 14001, 13999, 8175, 14002, 14006, 3659, 3445, 2112, + 8177, 65535, 65535, 65535, 14009, 3000, 65535, 65535, 2044, 65535, 1596, + 14649, 14656, 14658, 14664, 19608, 8598, 14644, 65535, 8590, 19610, 14659, + 8595, 14665, 8586, 19614, 14662, 4229, 14646, 14663, 14645, 65535, 8600, + 1867, 14657, 8587, 14666, 65535, 8592, 14650, 8597, 14661, 14648, 14655, + 4992, 14647, 8589, 8596, 8594, 8591, 8599, 8588, 14654, 3516, 8593, 65535, + 8178, 65535, 14660, 4197, 14652, 4022, 65535, 3556, 4988, 2622, 14653, + 65535, 4840, 15324, 2321, 9031, 2647, 65535, 15320, 15326, 15322, 65535, + 9033, 15321, 15325, 15317, 3737, 15319, 9032, 65535, 2773, 65535, 3634, + 15323, 15318, 1744, 9034, 65535, 9029, 65535, 19605, 15327, 4091, 9030, + 15896, 15893, 15905, 15899, 15901, 9409, 15895, 15903, 4450, 4630, 15902, + 15900, 65535, 15906, 9412, 15897, 15904, 65535, 9410, 4345, 65535, 15892, + 15894, 9411, 15891, 15907, 19604, 15898, 65535, 2027, 16495, 9751, 19621, + 65535, 16506, 16504, 9745, 16494, 16497, 16498, 16493, 9755, 9756, 16492, + 16507, 16502, 9749, 9746, 16501, 16499, 65535, 65535, 9752, 16503, 9747, + 2060, 9748, 65535, 16500, 9750, 16496, 65535, 16505, 9753, 16508, 16509, + 9754, 19106, 65535, 4273, 10031, 16984, 16990, 65535, 16988, 10027, 10026, + 10023, 16986, 65535, 65535, 3448, 10029, 10028, 10025, 65535, 16989, 16985, + 16987, 65535, 10030, 3704, 4562, 65535, 10260, 17423, 65535, 10257, 10258, + 17425, 10259, 17422, 1796, 4136, 17785, 17424, 65535, 17786, 10420, 17784, + 65535, 4186, 17783, 65535, 17782, 10421, 19624, 2791, 10563, 65535, 65535, + 18097, 18098, 19626, 2618, 2640, 65535, 18334, 18333, 10655, 65535, 18332, + 18507, 18508, 65535, 65535, 18658, 18762, 19629, 973, 18831, 18930, 10890, + 18940, 5643, 1683, 6505, 6506, 19632, 65535, 6837, 65535, 65535, 65535, + 65535, 10032, 5644, 65535, 6507, 7240, 8601, 5645, 65535, 7739, 9035, + 11338, 19633, 12331, 12778, 65535, 15328, 65535, 10033, 5646, 6508, 12332, + 12333, 14011, 8180, 65535, 65535, 14667, 3004, 65535, 8602, 15329, 65535, + 19636, 9413, 19637, 10422, 5647, 14012, 5648, 1977, 5912, 11463, 5911, + 6160, 6159, 6158, 11650, 65535, 65535, 4609, 6509, 65535, 6510, 11959, + 65535, 12334, 65535, 12337, 6839, 12335, 65535, 6838, 12336, 6840, 65535, + 12781, 12780, 12779, 7241, 65535, 13374, 13375, 7740, 13373, 13376, 8182, + 7741, 19642, 65535, 8181, 14016, 14015, 3005, 14013, 14014, 65535, 14017, + 14669, 14668, 14672, 4429, 14671, 14670, 9036, 15332, 3006, 15331, 9037, + 15330, 15908, 65535, 15909, 9414, 65535, 16510, 16511, 3806, 65535, 17791, + 10423, 17790, 17789, 17787, 17788, 10656, 18099, 18509, 18832, 65535, 5649, + 1685, 11371, 5753, 11372, 65535, 4908, 65535, 11464, 11465, 65535, 65535, + 65535, 65535, 11656, 65535, 65535, 11652, 65535, 11651, 6511, 11655, 6162, + 11653, 6161, 11657, 11654, 65535, 65535, 11963, 12338, 11961, 11968, 3693, + 6512, 65535, 6515, 11969, 11965, 65535, 11966, 65535, 11960, 6514, 11962, + 6513, 11967, 65535, 11964, 65535, 65535, 12342, 6842, 6843, 4876, 12345, + 12339, 65535, 12344, 65535, 12340, 6841, 12343, 12341, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 12787, 12784, 65535, 12786, 7246, 7245, 7243, + 12783, 12788, 7242, 7244, 12785, 13384, 12782, 12789, 4879, 65535, 4590, + 65535, 65535, 13379, 13383, 65535, 13382, 14019, 14030, 65535, 65535, + 13385, 3694, 13380, 14018, 7745, 65535, 65535, 7744, 13378, 13381, 7746, + 65535, 7743, 7742, 13377, 13386, 65535, 65535, 65535, 14021, 14028, 65535, + 8184, 14027, 14024, 19649, 8186, 3821, 19644, 4904, 14026, 19650, 65535, + 14020, 14022, 14025, 14023, 8185, 14029, 8183, 8603, 3696, 3697, 14676, + 14675, 14673, 65535, 8606, 8605, 14677, 3699, 14674, 15333, 9038, 8604, + 65535, 65535, 3700, 14679, 14678, 65535, 15336, 15334, 9415, 4800, 9039, + 15335, 15911, 65535, 65535, 65535, 65535, 9416, 15910, 15919, 15918, 15916, + 65535, 15915, 15912, 15913, 15914, 15917, 15920, 65535, 65535, 16516, + 16513, 16514, 9757, 16512, 16518, 16517, 16515, 65535, 16992, 16993, 10034, + 4877, 10035, 16991, 4654, 10262, 17426, 10261, 10424, 65535, 10425, 10564, + 18101, 18100, 18335, 18510, 10734, 18660, 18659, 18661, 5754, 12346, 7247, + 7747, 13387, 5755, 11373, 5650, 1798, 65535, 11466, 3687, 65535, 65535, + 11662, 11660, 11661, 11658, 6163, 11659, 2785, 65535, 65535, 65535, 19124, + 11977, 2626, 6518, 11975, 11971, 11974, 65535, 11970, 6520, 11973, 19121, + 6517, 6516, 19652, 6519, 11976, 11972, 65535, 65535, 65535, 65535, 6847, + 6850, 12354, 12353, 12352, 6844, 12361, 12351, 1746, 6846, 12794, 65535, + 12358, 12356, 6849, 65535, 12348, 12359, 1035, 12350, 12360, 12357, 12349, + 19655, 6845, 12362, 12347, 6848, 19271, 19651, 3082, 65535, 12799, 12790, + 12801, 19101, 12793, 12804, 12805, 12791, 12803, 12800, 12798, 12802, 7253, + 65535, 7251, 3706, 3482, 12796, 19677, 12792, 3505, 12795, 12806, 12797, + 7252, 12355, 65535, 7248, 7250, 19003, 65535, 65535, 65535, 3490, 13401, + 13390, 13388, 19665, 13389, 3311, 13396, 3491, 13397, 13393, 7752, 13398, + 13395, 13392, 1753, 7750, 13391, 7748, 7751, 13394, 13402, 7249, 7749, + 13400, 13399, 7753, 65535, 65535, 65535, 1319, 3292, 65535, 2783, 19666, + 14035, 19159, 65535, 3713, 14036, 8196, 2496, 14042, 3714, 3715, 14044, + 14037, 8190, 14041, 14040, 8191, 8197, 65535, 8198, 14043, 8188, 14034, + 14032, 14038, 14031, 8195, 14033, 14039, 14045, 8189, 8194, 8192, 8193, + 3028, 3068, 19669, 8187, 65535, 3026, 65535, 65535, 8613, 14686, 8612, + 14690, 2823, 14680, 3277, 14691, 19676, 3500, 19656, 14681, 14682, 1028, + 14692, 14689, 14687, 14688, 14684, 14683, 19559, 14693, 8609, 2784, 14685, + 65535, 8614, 8608, 8615, 8616, 19712, 8611, 8610, 19674, 998, 15337, 9041, + 9040, 19243, 65535, 15342, 3041, 9417, 9042, 3293, 19680, 9044, 15343, + 8607, 9043, 15339, 15341, 15338, 19682, 15340, 19678, 65535, 65535, 2780, + 3012, 65535, 15929, 15926, 9420, 16519, 9421, 15925, 19685, 9419, 65535, + 15927, 15924, 15921, 15928, 15922, 15923, 9418, 2830, 2109, 65535, 65535, + 16997, 65535, 16523, 65535, 16522, 16524, 65535, 16994, 9760, 2782, 16520, + 3069, 9758, 999, 9762, 9761, 16521, 16525, 65535, 9759, 19360, 17001, + 10038, 10263, 10039, 10036, 16998, 16996, 65535, 16999, 65535, 17002, + 10037, 17000, 16995, 65535, 3484, 17429, 17432, 17794, 17427, 1802, 18102, + 17433, 65535, 10426, 17431, 10264, 17428, 17430, 17434, 17795, 65535, + 17793, 1037, 65535, 19694, 65535, 10427, 17792, 3025, 65535, 65535, 10565, + 2955, 65535, 65535, 3720, 10658, 18512, 10657, 18514, 18511, 18513, 10786, + 18763, 5756, 11978, 12807, 12808, 7754, 14694, 9763, 10428, 10735, 18764, + 5757, 4986, 11979, 5213, 65535, 65535, 12363, 65535, 12364, 65535, 4960, + 4880, 4953, 65535, 12809, 12810, 7755, 7756, 4975, 65535, 65535, 14046, + 65535, 14697, 14696, 14695, 15344, 65535, 15345, 15346, 9045, 4952, 65535, + 15932, 15931, 65535, 65535, 16526, 9764, 9765, 19696, 17006, 17003, 17004, + 17005, 17436, 17435, 10265, 17796, 18336, 5758, 1353, 6851, 65535, 7757, + 14698, 19698, 5759, 65535, 12811, 7758, 65535, 65535, 8199, 8200, 65535, + 5760, 5761, 11467, 6165, 6164, 6852, 12365, 14047, 5762, 5763, 5764, 5765, + 4542, 1301, 65535, 6166, 6167, 11664, 11663, 4298, 65535, 6521, 11982, + 11980, 11981, 65535, 3723, 65535, 65535, 65535, 4781, 12366, 12367, 65535, + 19705, 6856, 6854, 19704, 6855, 6853, 65535, 3573, 65535, 4965, 7254, 3037, + 65535, 65535, 65535, 7258, 7257, 12812, 7256, 7255, 65535, 12813, 3824, + 65535, 7761, 13404, 13403, 7759, 7760, 19706, 65535, 65535, 8202, 8201, + 14049, 3724, 19707, 14048, 7762, 65535, 3725, 65535, 65535, 65535, 8617, + 14700, 8618, 14699, 4797, 65535, 65535, 15347, 15933, 9422, 16527, 65535, + 65535, 3032, 17007, 65535, 10430, 10429, 65535, 65535, 10736, 5766, 11983, + 3726, 19711, 7763, 15348, 9046, 10947, 65535, 11665, 11666, 65535, 65535, + 11984, 6523, 6524, 65535, 65535, 6522, 19713, 65535, 65535, 65535, 6860, + 6861, 6858, 6859, 65535, 12368, 65535, 65535, 12369, 6857, 65535, 65535, + 65535, 65535, 12814, 4581, 7262, 7263, 19714, 7766, 12820, 65535, 7268, + 7266, 12821, 12816, 7265, 7264, 7259, 12819, 12818, 12815, 7267, 4871, + 12817, 7260, 65535, 7261, 3728, 65535, 7767, 13408, 13409, 7768, 13405, + 13407, 13411, 13410, 13406, 65535, 7764, 7765, 65535, 14057, 8207, 8206, + 14051, 8204, 3729, 14054, 8208, 14055, 8209, 14052, 8203, 8205, 14056, + 65535, 14053, 14050, 65535, 65535, 65535, 65535, 65535, 14713, 65535, + 14702, 8620, 8623, 8622, 8627, 8626, 14714, 14712, 14705, 14709, 4694, + 8624, 14711, 14707, 14715, 14706, 8625, 8619, 8621, 19715, 14704, 65535, + 65535, 65535, 4866, 15350, 9050, 15354, 9049, 15351, 9048, 65535, 14703, + 14710, 15353, 65535, 9051, 15355, 15352, 15349, 65535, 65535, 15936, 15940, + 15942, 15938, 15937, 15935, 9425, 9423, 9428, 9429, 15939, 9426, 15934, + 9427, 9047, 15941, 9424, 65535, 65535, 19716, 16529, 65535, 16528, 16536, + 16530, 16535, 16532, 9766, 16534, 65535, 65535, 9767, 65535, 9768, 4519, + 16533, 16531, 65535, 65535, 4680, 65535, 10041, 17008, 65535, 65535, 10040, + 17011, 17009, 17010, 65535, 65535, 10042, 3731, 4521, 19718, 17440, 19717, + 10268, 17441, 4690, 65535, 10266, 17442, 10267, 17439, 17443, 65535, 17437, + 65535, 65535, 10431, 17797, 10432, 10566, 65535, 17438, 10567, 4578, 4895, + 65535, 10659, 18337, 65535, 10738, 18515, 10737, 19719, 18662, 10823, + 10824, 3038, 3733, 18946, 10948, 65535, 6862, 12370, 3735, 8210, 8211, + 5767, 5913, 11468, 65535, 11667, 6168, 65535, 6525, 65535, 6863, 6864, + 6865, 13413, 12822, 7269, 65535, 65535, 7769, 13412, 19722, 65535, 14059, + 8213, 65535, 14058, 8212, 65535, 65535, 14716, 9430, 15946, 15943, 15944, + 15945, 65535, 65535, 19727, 65535, 65535, 17012, 19728, 17444, 65535, + 65535, 65535, 18104, 18103, 65535, 18516, 5768, 11985, 7270, 65535, 65535, + 65535, 8214, 14717, 65535, 19729, 15356, 65535, 9431, 16537, 65535, 17445, + 18105, 5769, 65535, 65535, 6526, 6868, 12371, 6869, 6867, 65535, 6866, + 12823, 7271, 65535, 19730, 7272, 7273, 65535, 65535, 65535, 7771, 13414, + 7770, 65535, 4806, 65535, 65535, 1770, 14060, 7772, 8215, 14718, 8628, + 8629, 65535, 9052, 65535, 9053, 9432, 9770, 16538, 9769, 65535, 17013, + 10043, 65535, 17446, 18106, 5770, 6169, 11988, 11987, 6527, 11986, 6528, + 11989, 65535, 12377, 6872, 6871, 12379, 12378, 6876, 65535, 6875, 65535, + 65535, 6870, 65535, 12373, 12374, 12375, 65535, 6877, 12372, 6873, 12376, + 6874, 3709, 65535, 3061, 3062, 12826, 12830, 12828, 12827, 65535, 12831, + 65535, 65535, 65535, 12832, 12833, 12825, 65535, 12824, 19736, 7275, 7276, + 65535, 12834, 12829, 4962, 13423, 19737, 12835, 7277, 7274, 65535, 4974, + 65535, 13417, 65535, 13416, 65535, 13418, 13419, 13421, 13420, 13425, 7776, + 7773, 7777, 13415, 7778, 13424, 7775, 13422, 7774, 65535, 19738, 65535, + 65535, 3742, 14063, 14065, 14061, 14062, 65535, 65535, 14066, 14068, 14069, + 14064, 14067, 8216, 65535, 65535, 14722, 65535, 14727, 14719, 14723, 65535, + 19741, 14728, 14724, 8630, 8638, 65535, 8633, 14720, 14721, 9057, 8641, + 8634, 65535, 8639, 8632, 14726, 8640, 14725, 8636, 8631, 8637, 14729, + 15361, 15363, 65535, 65535, 2642, 65535, 65535, 65535, 65535, 2299, 3059, + 8635, 1428, 3063, 15358, 9055, 15364, 9056, 15362, 15357, 15360, 15365, + 9054, 15359, 65535, 9434, 15950, 15949, 65535, 9437, 9435, 15947, 9433, + 15948, 65535, 9436, 65535, 2312, 65535, 16546, 65535, 16548, 3747, 16547, + 16539, 16543, 16542, 16540, 9772, 9773, 9771, 16541, 16544, 16545, 65535, + 9774, 65535, 10048, 17021, 65535, 10045, 17015, 10047, 10049, 65535, 19743, + 10046, 17020, 17016, 10044, 17019, 17014, 17018, 17017, 65535, 4522, 17448, + 10271, 10272, 10269, 3751, 10270, 65535, 65535, 17447, 3238, 17800, 19445, + 65535, 10433, 65535, 17798, 17799, 3752, 18107, 18110, 18108, 18109, 18338, + 65535, 65535, 10660, 18663, 18765, 65535, 4138, 18833, 18834, 10871, 5771, + 6878, 1773, 14070, 65535, 14730, 65535, 5772, 6170, 65535, 6529, 19115, + 12380, 12381, 7278, 65535, 65535, 14071, 8217, 8642, 10050, 17022, 17801, + 18111, 5773, 19747, 65535, 65535, 11995, 11990, 11992, 11994, 11993, 11991, + 6530, 4943, 65535, 65535, 65535, 6879, 12390, 65535, 12385, 12382, 65535, + 4408, 12389, 65535, 65535, 6881, 6882, 12388, 12387, 12386, 12383, 12384, + 12391, 6880, 65535, 65535, 65535, 3754, 65535, 65535, 65535, 3756, 7282, + 3078, 7288, 7287, 12844, 12838, 12836, 65535, 7285, 13432, 7280, 12841, + 12845, 12847, 12843, 12837, 7286, 12842, 12840, 7279, 12848, 7289, 12846, + 7283, 12839, 65535, 7284, 7281, 3758, 65535, 65535, 19012, 3425, 65535, + 65535, 65535, 65535, 2999, 7780, 3361, 13433, 65535, 3759, 13426, 13428, + 13430, 3428, 13431, 13429, 7781, 65535, 13434, 3760, 13427, 4873, 3426, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 14075, 8218, 14083, 65535, + 14072, 65535, 14084, 65535, 14073, 14074, 3761, 65535, 14082, 14081, 14078, + 7779, 8219, 14076, 14079, 8220, 14080, 14077, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 14741, 4683, 14745, 8649, 65535, 15371, 8652, 14743, + 18956, 65535, 14740, 14735, 14737, 14738, 14731, 3080, 8648, 65535, 65535, + 8647, 3079, 8643, 14734, 65535, 8650, 65535, 8651, 14733, 14736, 14744, + 8645, 8646, 14742, 14732, 65535, 65535, 65535, 15373, 9059, 15375, 14739, + 15377, 9063, 15378, 15374, 65535, 9060, 15370, 9062, 15367, 15372, 15376, + 15369, 65535, 19752, 8644, 19760, 15366, 9061, 15368, 65535, 3427, 65535, + 1330, 3418, 9440, 15952, 9444, 65535, 9442, 65535, 65535, 9058, 65535, + 15959, 15960, 9439, 65535, 19753, 15958, 15961, 9441, 9438, 15954, 15951, + 15956, 15953, 9445, 15955, 3081, 19754, 15957, 9443, 65535, 19758, 4863, + 65535, 9776, 16555, 65535, 16549, 16553, 16559, 16560, 16556, 16557, 16554, + 1752, 16551, 65535, 9778, 9775, 16550, 16552, 65535, 9777, 16558, 2929, + 10054, 3117, 19176, 17028, 17023, 10053, 2454, 65535, 10051, 65535, 17030, + 10052, 17026, 17027, 17024, 17031, 17449, 65535, 10055, 17025, 65535, + 17032, 17029, 4937, 65535, 65535, 17453, 65535, 65535, 17450, 65535, 10273, + 65535, 17454, 17456, 17455, 17451, 17452, 65535, 65535, 17806, 65535, + 10434, 65535, 17803, 17805, 17802, 17807, 65535, 65535, 17804, 65535, + 18113, 18116, 18112, 10568, 18114, 18115, 18117, 10569, 10571, 10570, + 18339, 19756, 18341, 65535, 18340, 3766, 3764, 19759, 18517, 2134, 65535, + 18766, 18835, 5774, 1688, 19774, 11668, 6531, 11997, 6532, 6533, 11996, + 65535, 12396, 12395, 6883, 6886, 6885, 6884, 12392, 12394, 12393, 65535, + 65535, 12851, 7291, 12855, 12854, 12853, 12849, 7290, 7294, 7297, 2238, + 3083, 7298, 12850, 12852, 7296, 7295, 7293, 7292, 13441, 4532, 13439, + 13435, 7782, 65535, 13436, 7783, 13437, 13438, 13440, 65535, 7784, 65535, + 65535, 14088, 19352, 14087, 14086, 14085, 65535, 65535, 65535, 65535, + 14749, 8653, 65535, 14746, 14748, 4359, 8654, 19770, 8655, 14747, 4289, + 65535, 65535, 19767, 1359, 15387, 65535, 15380, 15381, 65535, 9066, 9064, + 9065, 15389, 3769, 15388, 15385, 15384, 15383, 15382, 15386, 15379, 3770, + 15962, 3087, 15965, 19772, 65535, 2629, 15964, 15963, 15966, 65535, 16561, + 3089, 9779, 10056, 17034, 19775, 10057, 17033, 17458, 17457, 10274, 65535, + 17808, 10435, 18118, 10739, 18518, 65535, 18768, 18767, 11374, 6887, 6888, + 13442, 65535, 8657, 5775, 6173, 6172, 6171, 65535, 65535, 3524, 11998, + 19779, 65535, 6535, 6534, 1851, 6891, 19561, 12398, 12401, 12399, 1023, + 6889, 6890, 65535, 19781, 12397, 12400, 65535, 7305, 65535, 65535, 65535, + 12862, 12864, 12863, 7302, 12858, 65535, 3408, 4330, 7299, 65535, 7303, + 7301, 65535, 7304, 12861, 12856, 12857, 12860, 12859, 65535, 65535, 3098, + 65535, 65535, 3093, 65535, 13445, 13446, 13444, 65535, 13443, 7785, 65535, + 65535, 65535, 65535, 8225, 65535, 14089, 14091, 14093, 8224, 3772, 65535, + 8222, 65535, 14090, 8223, 14092, 8221, 65535, 65535, 14759, 14750, 14753, + 14757, 8661, 14755, 65535, 14754, 14751, 14752, 8659, 14758, 8658, 65535, + 8663, 8662, 8660, 65535, 14756, 65535, 65535, 65535, 15395, 65535, 15394, + 65535, 1762, 15390, 1031, 4948, 9067, 15393, 15392, 9068, 1024, 65535, + 65535, 65535, 65535, 9450, 65535, 15969, 3092, 9451, 9447, 9449, 4862, + 9446, 9448, 65535, 65535, 2643, 16562, 4281, 9782, 16564, 16563, 2050, + 15391, 9784, 9783, 9780, 9781, 65535, 65535, 65535, 65535, 65535, 17039, + 65535, 17037, 10058, 17038, 65535, 17040, 17036, 17035, 65535, 65535, + 17459, 10277, 10275, 10276, 65535, 65535, 2053, 65535, 17809, 17810, 10437, + 65535, 10436, 18120, 18121, 18119, 65535, 18519, 18520, 1045, 65535, 5776, + 11469, 6174, 65535, 11999, 6537, 6536, 12000, 65535, 2054, 12403, 6892, + 12402, 6893, 65535, 3976, 7306, 12867, 12865, 12871, 7307, 12866, 12870, + 12868, 12869, 65535, 65535, 13447, 13449, 3775, 7786, 1806, 13448, 7787, + 8228, 8227, 8226, 14094, 65535, 65535, 65535, 65535, 14762, 8664, 8665, + 65535, 14761, 14760, 65535, 65535, 65535, 65535, 15396, 9070, 9069, 15397, + 15398, 65535, 9453, 9452, 2057, 16568, 15970, 15972, 15971, 16567, 16565, + 16569, 16566, 65535, 9785, 2056, 3777, 65535, 17041, 10059, 17042, 17043, + 2058, 2059, 10278, 10279, 65535, 10572, 4005, 1323, 10787, 5777, 65535, + 65535, 65535, 3780, 65535, 12404, 65535, 4860, 65535, 65535, 65535, 65535, + 12872, 7308, 2063, 3781, 2616, 2064, 65535, 7938, 7937, 65535, 3110, 8230, + 14096, 8229, 14095, 2362, 65535, 2316, 2065, 14763, 65535, 9071, 15399, + 9072, 65535, 65535, 65535, 65535, 65535, 65535, 10573, 18122, 65535, 5914, + 6538, 12001, 1007, 6895, 3120, 6894, 12405, 12406, 65535, 65535, 12874, + 12876, 7309, 65535, 12878, 12881, 12879, 2069, 3159, 65535, 12880, 12877, + 12873, 7310, 12882, 12875, 4841, 65535, 65535, 65535, 13458, 7793, 13467, + 7790, 65535, 13460, 7794, 4732, 7788, 65535, 13455, 13468, 13456, 13453, + 7792, 3155, 7789, 2071, 13459, 13462, 7791, 13463, 7795, 13464, 13454, + 13461, 13465, 13457, 13452, 13450, 65535, 65535, 13466, 3810, 65535, 14098, + 65535, 65535, 65535, 65535, 14103, 65535, 4275, 4358, 14099, 14105, 8233, + 13451, 14100, 8231, 14097, 8238, 14101, 8237, 14102, 8239, 8234, 4422, + 8235, 65535, 8236, 2070, 8232, 65535, 14104, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 8668, 14774, 3784, 14777, 14765, 14770, 14764, 8670, + 65535, 14768, 65535, 65535, 3785, 14766, 8669, 2075, 14773, 14772, 14769, + 14771, 14767, 9076, 14776, 8666, 14775, 65535, 65535, 3786, 65535, 65535, + 65535, 65535, 65535, 65535, 15415, 65535, 9083, 15410, 65535, 9082, 15400, + 65535, 15402, 9075, 15407, 15406, 15409, 9080, 15404, 15403, 2081, 65535, + 9079, 9074, 15405, 9077, 15411, 15413, 65535, 15408, 15401, 9078, 65535, + 65535, 9461, 9073, 2074, 4735, 15414, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 15976, 9454, 1052, 15978, 65535, 9455, 1651, 65535, 9457, + 15981, 65535, 15973, 2082, 15979, 65535, 65535, 65535, 65535, 15975, 65535, + 8667, 9460, 65535, 65535, 9456, 1029, 9458, 9459, 65535, 9788, 15980, + 15974, 9462, 65535, 15977, 4739, 2079, 65535, 65535, 65535, 16579, 16574, + 65535, 65535, 16584, 9786, 16576, 9790, 16582, 16573, 16570, 16585, 10065, + 9791, 16581, 16571, 9789, 16575, 9793, 16572, 16577, 9792, 16580, 16583, + 1807, 65535, 65535, 65535, 17061, 17062, 17046, 17053, 17051, 65535, 65535, + 10063, 17058, 16578, 2087, 17049, 4746, 17059, 10062, 17048, 17047, 17057, + 17054, 17056, 65535, 17044, 2088, 10060, 65535, 17055, 17064, 17052, 10064, + 10061, 17050, 17045, 17063, 9787, 3787, 65535, 65535, 19083, 65535, 65535, + 65535, 17462, 65535, 3788, 17460, 17466, 10283, 17464, 17463, 10285, 17469, + 10284, 65535, 17470, 17467, 10281, 17468, 17461, 10282, 10280, 17814, + 17465, 65535, 65535, 17471, 65535, 65535, 17811, 65535, 2089, 65535, 10442, + 10440, 17813, 65535, 17815, 17812, 10441, 10438, 10439, 10443, 65535, 4743, + 10575, 2091, 18127, 65535, 18126, 18124, 18123, 18125, 65535, 10574, 10576, + 65535, 65535, 10661, 4910, 65535, 18343, 18342, 65535, 4710, 18521, 65535, + 18523, 18525, 18524, 18522, 3122, 65535, 10741, 10740, 65535, 65535, 10789, + 10788, 10790, 18665, 18664, 65535, 18836, 18769, 18837, 10857, 3123, 10858, + 18885, 4801, 65535, 10895, 5915, 2100, 12002, 65535, 65535, 12408, 12409, + 12407, 3791, 3132, 6896, 4741, 12410, 12411, 12412, 65535, 2092, 12883, + 12889, 4744, 65535, 12887, 7311, 12885, 65535, 12886, 12888, 3131, 65535, + 65535, 12884, 7796, 65535, 13469, 7798, 13471, 7797, 13470, 65535, 65535, + 65535, 3792, 65535, 14107, 8241, 65535, 14109, 14106, 13472, 65535, 8242, + 2094, 18961, 14108, 65535, 65535, 65535, 2405, 65535, 3133, 14780, 65535, + 8671, 14778, 8672, 14779, 8673, 65535, 65535, 3794, 9084, 15419, 15416, + 15418, 9085, 9086, 15417, 65535, 65535, 4945, 1808, 65535, 15982, 65535, + 2098, 15983, 2097, 9463, 15985, 15984, 3128, 2103, 65535, 16589, 16590, + 16586, 3688, 16587, 9794, 9795, 16588, 65535, 10071, 4947, 65535, 10067, + 10072, 10068, 10070, 10066, 65535, 10069, 65535, 65535, 65535, 2099, 10286, + 17065, 65535, 17817, 65535, 17816, 3796, 18128, 10577, 10578, 18527, 18344, + 2101, 18526, 2102, 18838, 18906, 5916, 1689, 65535, 6175, 1320, 12003, + 6539, 65535, 6899, 12415, 6897, 12413, 6902, 6898, 6903, 6901, 12414, 6900, + 7315, 7314, 12900, 7323, 12893, 12899, 7319, 12892, 12898, 12896, 7318, + 7320, 12895, 7313, 12894, 7324, 7321, 7325, 7322, 12891, 12890, 12897, + 7316, 7312, 7317, 65535, 65535, 4670, 65535, 65535, 13487, 13480, 65535, + 8247, 13479, 65535, 7802, 7809, 7806, 7812, 7811, 7807, 65535, 13473, + 13476, 65535, 13475, 7803, 13477, 13486, 7804, 13474, 13483, 13484, 7805, + 13481, 7810, 7800, 7808, 13478, 7799, 13482, 65535, 65535, 13485, 65535, + 65535, 4951, 14126, 14117, 8244, 14124, 14121, 14113, 14122, 8246, 14114, + 65535, 14110, 65535, 4555, 8679, 14119, 2107, 8243, 14125, 65535, 8250, + 8252, 14112, 65535, 65535, 8251, 14115, 8245, 14123, 14116, 14120, 65535, + 14118, 8248, 14111, 8253, 7801, 8249, 8254, 65535, 65535, 65535, 65535, + 65535, 8675, 14787, 14789, 14791, 14795, 65535, 14785, 14783, 8677, 65535, + 14790, 14794, 14786, 14782, 65535, 14781, 2110, 65535, 1781, 14792, 14784, + 14788, 8678, 65535, 8676, 14796, 8674, 14793, 981, 15436, 3142, 65535, + 65535, 65535, 65535, 9089, 15428, 9476, 15438, 9092, 15442, 9098, 15423, + 3672, 65535, 15439, 15420, 3475, 15441, 15424, 2111, 9105, 9102, 15440, + 15434, 9088, 9096, 9095, 2113, 9094, 9100, 65535, 15421, 9101, 15435, 9097, + 9087, 15437, 9090, 9091, 9099, 15426, 15425, 15422, 65535, 15430, 15427, + 15431, 9104, 65535, 15443, 9093, 15432, 15433, 1321, 15429, 3800, 3802, + 65535, 2114, 3137, 3801, 65535, 65535, 15990, 9468, 9477, 9473, 15987, + 3135, 9470, 9474, 15999, 9464, 15991, 65535, 9472, 2117, 2121, 15994, + 15989, 9471, 9475, 15988, 65535, 9469, 65535, 15998, 9466, 15997, 15996, + 9478, 15750, 9465, 2119, 15995, 15986, 65535, 9479, 15993, 9467, 65535, + 3803, 3526, 65535, 65535, 65535, 65535, 15992, 65535, 65535, 65535, 3136, + 9798, 9803, 9796, 16603, 16594, 16606, 16598, 16604, 9804, 9797, 16591, + 16597, 16607, 16600, 16605, 16593, 65535, 65535, 16601, 9799, 16599, 2123, + 9801, 16595, 16596, 16592, 16602, 9800, 16609, 16608, 65535, 2130, 65535, + 17076, 17072, 10079, 65535, 17066, 10073, 10089, 17078, 10081, 10077, + 17069, 10084, 10087, 17080, 10076, 17071, 10085, 17082, 17079, 17067, + 10080, 10074, 10088, 17074, 10083, 17068, 10078, 17081, 10082, 10075, + 17075, 10086, 17073, 65535, 65535, 17077, 65535, 65535, 65535, 17473, + 17479, 10292, 17482, 10287, 10288, 17474, 17481, 17476, 10293, 10290, 1849, + 17472, 65535, 10289, 17478, 17480, 10291, 17477, 17475, 65535, 3665, 65535, + 2104, 17827, 10447, 10448, 10444, 1809, 10445, 2126, 17823, 17821, 65535, + 17825, 10450, 17826, 17819, 17818, 17822, 17820, 10446, 17824, 18129, + 10581, 10580, 18130, 4464, 18132, 18131, 10582, 65535, 65535, 65535, 18349, + 4141, 18347, 65535, 18345, 18348, 10663, 18350, 4631, 10662, 65535, 18528, + 2127, 10791, 10793, 18666, 10792, 18770, 18840, 18842, 18839, 18841, 10877, + 65535, 65535, 4444, 65535, 65535, 65535, 65535, 1302, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1303, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1304, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1305, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1306, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1307, 65535, 65535, 65535, 65535, 65535, 65535, 1308, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 5917, 1309, 6904, 12764, 7326, 65535, 65535, 7813, + 14127, 14128, 2131, 2132, 65535, 16610, 10090, 17083, 65535, 2133, 10294, + 4507, 17829, 17828, 10583, 18351, 3138, 18529, 10826, 11470, 1687, 1690, + 6540, 6176, 65535, 65535, 12416, 65535, 65535, 12906, 12901, 12905, 12903, + 7327, 12904, 12902, 65535, 13488, 65535, 14129, 14130, 14799, 14800, 8681, + 8682, 14798, 14801, 14797, 8680, 65535, 9106, 4995, 8683, 15444, 65535, + 9480, 16000, 9481, 4845, 9805, 16613, 16611, 16612, 17086, 17085, 17084, + 65535, 65535, 65535, 17830, 65535, 10449, 17831, 18530, 10827, 18771, 5918, + 6542, 6541, 12418, 6905, 19538, 65535, 12417, 12908, 1546, 7328, 13489, + 12907, 2137, 65535, 65535, 7815, 13492, 13490, 13491, 7814, 65535, 14132, + 14133, 14131, 2139, 8686, 14803, 14802, 14804, 8685, 8684, 65535, 65535, + 16001, 16003, 3804, 9482, 16002, 16614, 9806, 17484, 3805, 17483, 10451, + 17832, 10453, 10452, 18133, 18352, 10664, 5919, 12419, 6906, 12911, 7330, + 12910, 12909, 65535, 7329, 65535, 13498, 65535, 13500, 13493, 13494, 7816, + 13495, 7817, 13499, 13496, 13497, 7818, 65535, 8256, 8257, 65535, 14134, + 65535, 65535, 65535, 14805, 14806, 3154, 15448, 9109, 9107, 9108, 15445, + 15446, 65535, 15447, 16008, 3692, 16009, 9483, 16006, 16005, 16007, 16004, + 9809, 16615, 9807, 9808, 17088, 10091, 17087, 17340, 65535, 17485, 17486, + 10295, 2146, 10296, 10092, 17833, 17834, 18134, 10584, 5920, 1695, 5921, + 6907, 2148, 7331, 12420, 2149, 65535, 65535, 8258, 5922, 6909, 12421, + 12422, 6908, 6910, 5923, 65535, 12423, 7333, 12912, 7335, 7332, 7334, + 65535, 13503, 7819, 2150, 13502, 13501, 3808, 14807, 65535, 65535, 15449, + 3809, 9484, 65535, 2151, 16617, 16616, 65535, 17089, 65535, 3811, 2152, + 18353, 3812, 65535, 5924, 11669, 12004, 6911, 12424, 65535, 12914, 65535, + 2155, 2156, 7336, 12913, 7337, 65535, 65535, 65535, 13505, 65535, 65535, + 7821, 13504, 13506, 65535, 7820, 65535, 65535, 65535, 65535, 14136, 14137, + 14135, 8259, 65535, 3813, 65535, 8687, 65535, 8688, 65535, 9111, 4959, + 15451, 15450, 9110, 65535, 65535, 2157, 4957, 4950, 16010, 65535, 4949, + 16011, 65535, 65535, 65535, 65535, 16618, 65535, 65535, 10096, 10095, + 10093, 10094, 10097, 65535, 17487, 10298, 10297, 17835, 18135, 65535, + 65535, 65535, 10743, 10742, 5925, 1696, 65535, 12713, 65535, 8690, 8260, + 8689, 9112, 65535, 5926, 11375, 5927, 5928, 65535, 65535, 12005, 11672, + 65535, 11673, 6178, 65535, 11670, 6177, 65535, 6180, 11671, 6182, 6181, + 11674, 6179, 65535, 1339, 65535, 6548, 6546, 12007, 65535, 6545, 65535, + 2164, 65535, 6550, 6552, 6549, 65535, 12010, 12006, 6553, 65535, 6547, + 6183, 65535, 6551, 12009, 4582, 3817, 12008, 65535, 6544, 65535, 1332, + 4530, 65535, 65535, 65535, 65535, 12430, 6915, 6916, 12432, 3177, 12426, + 12429, 12438, 12436, 65535, 6917, 12442, 6920, 12439, 12431, 12428, 65535, + 65535, 14139, 12437, 6912, 12440, 12425, 12434, 6914, 6919, 12435, 6923, + 6921, 65535, 12427, 6918, 65535, 12433, 6922, 6913, 12441, 65535, 65535, + 3818, 65535, 65535, 1598, 7342, 65535, 7351, 7340, 7338, 12916, 7346, 7343, + 12918, 1335, 65535, 7345, 12917, 12915, 12920, 7350, 7348, 14138, 65535, + 12921, 12919, 7339, 4961, 65535, 7341, 7344, 2166, 7347, 3178, 7349, 65535, + 3820, 65535, 3822, 65535, 65535, 65535, 3823, 65535, 3825, 13516, 7823, + 4516, 13507, 13509, 2167, 13510, 65535, 13518, 13514, 13512, 65535, 13515, + 13519, 7824, 7828, 13508, 65535, 13517, 65535, 7826, 2854, 7825, 13513, + 13511, 65535, 7822, 7827, 65535, 4528, 65535, 1601, 65535, 65535, 3175, + 65535, 8266, 14147, 65535, 65535, 14145, 8268, 65535, 65535, 65535, 3179, + 14140, 14821, 65535, 8267, 14144, 4525, 65535, 14141, 8263, 8269, 14146, + 8265, 14143, 9113, 8264, 14142, 8270, 8262, 8261, 3828, 65535, 65535, 3829, + 3830, 14813, 14811, 65535, 14817, 65535, 14809, 14822, 14814, 65535, 14808, + 8694, 8700, 14819, 65535, 14812, 65535, 8697, 1880, 1597, 8695, 14820, + 8692, 8691, 14815, 8696, 8271, 65535, 14818, 14810, 8693, 8698, 8699, + 65535, 3833, 65535, 65535, 9118, 9114, 65535, 9119, 15454, 3834, 65535, + 15453, 15455, 9116, 15452, 9117, 15458, 15457, 15456, 65535, 9115, 65535, + 65535, 65535, 3836, 65535, 16015, 65535, 16018, 9490, 16017, 9489, 9485, + 9486, 9487, 16014, 16013, 9488, 65535, 16016, 16012, 65535, 3838, 16620, + 16630, 9813, 9812, 1505, 16624, 16626, 65535, 16621, 65535, 16625, 16619, + 16628, 9811, 16627, 16623, 4586, 16629, 65535, 16622, 10100, 17090, 17096, + 10104, 10106, 10103, 10102, 3840, 10101, 10099, 17091, 17094, 10098, 17095, + 4969, 10105, 17093, 65535, 17092, 10299, 65535, 10300, 17490, 17488, 17489, + 65535, 65535, 17837, 65535, 17836, 10454, 18137, 10585, 18136, 65535, + 18354, 18531, 10744, 18843, 18844, 10794, 5929, 3841, 6554, 14148, 9120, + 10107, 17097, 5930, 65535, 7353, 7352, 14149, 19723, 65535, 65535, 16631, + 5931, 6924, 65535, 3707, 14150, 14151, 14152, 9121, 9814, 5932, 65535, + 6555, 12443, 7354, 12922, 7829, 65535, 14153, 8701, 65535, 9122, 9815, + 10108, 10301, 18138, 5933, 6556, 65535, 65535, 7355, 13520, 8272, 65535, + 9123, 15459, 16019, 65535, 2175, 65535, 4955, 5934, 8273, 14823, 9124, + 5935, 12011, 12444, 6925, 65535, 65535, 12924, 19523, 65535, 7358, 2181, + 7356, 7357, 7359, 4646, 65535, 12923, 65535, 65535, 13525, 13522, 13524, + 7830, 7832, 7831, 13521, 7833, 13523, 65535, 14154, 14155, 1352, 14156, + 14826, 65535, 14827, 65535, 14825, 14828, 65535, 8702, 65535, 14824, 65535, + 9125, 65535, 65535, 16024, 16020, 16023, 16025, 16022, 16021, 3842, 16632, + 16633, 16634, 9816, 9817, 17099, 17098, 17100, 65535, 17492, 17491, 65535, + 17839, 3183, 17840, 17838, 3184, 10586, 65535, 18139, 18140, 65535, 18532, + 18667, 18772, 5936, 6184, 65535, 10109, 5937, 65535, 13526, 14157, 3845, + 10834, 11471, 3778, 1310, 2206, 11472, 11474, 5938, 11475, 11473, 65535, + 65535, 11682, 11683, 11677, 65535, 19294, 65535, 65535, 11681, 6186, 65535, + 6187, 11678, 11676, 11675, 11679, 6185, 11680, 12445, 65535, 65535, 65535, + 12016, 6559, 12015, 12017, 65535, 6558, 12022, 6562, 12012, 12026, 12032, + 6569, 12029, 6566, 3844, 12019, 12025, 12027, 2194, 12014, 6565, 6560, + 12020, 6567, 6570, 6564, 65535, 6557, 12024, 12018, 12031, 6572, 6568, + 6563, 12023, 7360, 12021, 6561, 6571, 1837, 12013, 65535, 12028, 12030, + 1588, 65535, 65535, 65535, 65535, 65535, 3846, 65535, 65535, 65535, 65535, + 1311, 2199, 6942, 6936, 6944, 6941, 12452, 12455, 6937, 3847, 12446, 65535, + 6930, 6940, 65535, 6943, 6945, 12467, 12458, 2207, 6929, 12466, 6933, 6931, + 6926, 12450, 65535, 12465, 12454, 12457, 12470, 19010, 6946, 12464, 6938, + 12459, 12469, 12456, 12460, 12463, 4526, 1810, 12448, 12468, 12462, 19289, + 4102, 12447, 3848, 12451, 6939, 6934, 6927, 6932, 6928, 6947, 12449, 12941, + 6935, 65535, 4593, 12461, 12090, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 12944, 7374, 2208, 12928, 2200, 12939, 12935, 2215, 12954, + 65535, 12946, 65535, 12936, 65535, 12945, 12930, 12934, 12957, 7377, 12949, + 12940, 7361, 12955, 12926, 65535, 12948, 65535, 7376, 7371, 12925, 7369, + 7368, 7373, 12947, 7365, 7372, 12453, 14158, 12942, 3617, 65535, 12932, + 7375, 12933, 12937, 7378, 12927, 12951, 65535, 12950, 12958, 7367, 7364, + 12956, 12952, 12943, 12938, 7370, 7366, 12929, 7362, 12953, 7363, 65535, + 12931, 3850, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2188, 19489, 65535, 65535, 4346, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1312, 65535, 65535, 65535, 13532, 13534, 13539, 13559, + 7847, 7837, 65535, 13531, 7848, 7849, 13542, 13549, 13555, 65535, 13536, + 65535, 13543, 65535, 2217, 7850, 13557, 13552, 7845, 7843, 13548, 13544, + 13530, 7834, 13535, 13527, 2245, 7842, 7844, 13540, 13537, 7839, 13553, + 7836, 13538, 13560, 13546, 2076, 13545, 7835, 65535, 7846, 65535, 7838, + 13528, 13533, 13550, 13556, 7851, 13529, 13541, 13547, 7841, 2220, 65535, + 13558, 13551, 13554, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19679, 65535, 65535, 65535, 7840, 4810, 14174, 14162, 2221, 14191, + 14199, 14202, 8279, 14170, 14195, 14171, 14185, 8292, 14181, 8289, 19071, + 14182, 4294, 65535, 14196, 65535, 2222, 8298, 14193, 14183, 14204, 14178, + 14860, 65535, 14207, 8296, 14176, 14188, 8299, 8278, 14180, 14205, 14173, + 14166, 14177, 65535, 14165, 14163, 8274, 14197, 14172, 14200, 3619, 14201, + 8282, 8287, 8283, 8291, 14192, 8284, 14184, 14168, 65535, 8276, 14160, + 14194, 14203, 14167, 8290, 14208, 14179, 65535, 14175, 65535, 8275, 8295, + 3853, 14190, 8297, 65535, 14186, 8286, 8280, 8288, 8277, 8294, 2244, 14169, + 14189, 14164, 14198, 3334, 65535, 19041, 65535, 4529, 65535, 65535, 14206, + 4587, 65535, 65535, 65535, 3403, 2080, 65535, 14161, 19364, 65535, 3673, + 65535, 65535, 14859, 65535, 14881, 8656, 14864, 19555, 14862, 14841, 8706, + 14857, 14877, 14853, 8714, 14876, 14851, 8293, 14867, 14852, 14874, 8713, + 8705, 3608, 14830, 14838, 65535, 14863, 14855, 14880, 14858, 8719, 14875, + 3762, 8710, 2236, 14861, 14869, 14842, 14868, 65535, 14885, 14837, 14870, + 3186, 14883, 2674, 14831, 8285, 2230, 14845, 14844, 8712, 4664, 14848, + 14850, 14865, 14882, 8715, 19732, 8716, 3855, 14836, 8708, 14840, 14878, + 8717, 65535, 8709, 8711, 8718, 14884, 14871, 14866, 2232, 3466, 14847, + 14846, 8707, 14832, 8704, 14856, 14833, 14854, 65535, 65535, 14843, 14879, + 2613, 3171, 65535, 8703, 65535, 1015, 65535, 14839, 65535, 3857, 65535, + 65535, 65535, 65535, 14835, 14873, 14834, 9138, 15499, 2086, 2247, 15482, + 65535, 3088, 15460, 15490, 9130, 15475, 15485, 9133, 15478, 9131, 15463, + 15493, 15462, 15481, 3219, 15461, 65535, 65535, 15479, 2239, 15486, 15474, + 15469, 15467, 4069, 15468, 15487, 15498, 15476, 9132, 65535, 15471, 65535, + 15491, 65535, 9135, 15470, 15464, 15480, 9139, 3394, 3859, 9127, 9136, + 15472, 15466, 65535, 9129, 14872, 9128, 15483, 65535, 9126, 9141, 9134, + 15484, 15473, 15465, 15492, 15477, 9140, 15496, 9137, 15495, 65535, 15489, + 15494, 65535, 65535, 4976, 15497, 65535, 65535, 2243, 65535, 65535, 3860, + 2187, 65535, 2248, 3270, 65535, 16065, 16066, 16053, 16052, 16048, 9502, + 65535, 9494, 16068, 16067, 14829, 16045, 16049, 16043, 65535, 16062, 16047, + 3861, 16069, 16040, 16038, 16050, 16060, 16055, 9504, 16029, 65535, 16059, + 2671, 1059, 19221, 9505, 14849, 16041, 16032, 16035, 16073, 16042, 16033, + 16031, 16028, 3862, 9498, 16051, 9497, 9501, 16046, 16054, 9491, 16070, + 16074, 9493, 65535, 16037, 16057, 16061, 16034, 16071, 9500, 65535, 9499, + 16026, 9503, 16064, 16036, 16056, 16030, 16044, 16039, 9495, 9496, 16058, + 16075, 16072, 16063, 65535, 19550, 2253, 65535, 65535, 65535, 3863, 65535, + 65535, 16027, 65535, 9492, 16651, 65535, 16642, 16645, 19084, 9823, 16647, + 16636, 16643, 16649, 9820, 9824, 9818, 2198, 19001, 16638, 16654, 65535, + 65535, 16648, 3864, 16639, 16663, 16657, 16635, 17119, 16641, 9819, 2226, + 16652, 65535, 16662, 9827, 1818, 16659, 16640, 16646, 16650, 16644, 16664, + 16661, 16658, 9821, 9822, 9826, 16637, 16665, 9825, 16655, 3866, 3867, + 16653, 65535, 2257, 65535, 16656, 17132, 17113, 17118, 17131, 17117, 17109, + 17114, 65535, 10112, 65535, 17102, 17126, 17128, 17101, 10111, 17130, + 17122, 10118, 17129, 17115, 10120, 17107, 16660, 17123, 17120, 17103, + 17134, 10114, 65535, 996, 10115, 17105, 17121, 1811, 17133, 17124, 17111, + 10117, 10113, 17125, 17112, 17135, 17106, 17116, 17127, 17108, 17110, + 65535, 10310, 17104, 10119, 10303, 10110, 65535, 65535, 65535, 65535, + 10116, 10307, 17508, 65535, 17498, 17493, 17499, 17509, 17513, 17512, + 10309, 10308, 65535, 65535, 17500, 17514, 17503, 17495, 2263, 17497, 17496, + 17502, 17507, 17494, 17501, 17506, 10306, 65535, 17504, 65535, 10304, + 17505, 10302, 10305, 17856, 17510, 65535, 65535, 10458, 1835, 17848, 17852, + 17844, 17847, 65535, 17855, 10456, 17860, 17853, 3868, 17845, 17861, 17854, + 10459, 10460, 17858, 65535, 17846, 10455, 10457, 17841, 17849, 17843, 3404, + 17859, 17857, 17842, 17850, 65535, 65535, 65535, 18147, 10461, 17851, + 10588, 10590, 10587, 3398, 18152, 18144, 18142, 18146, 18143, 2265, 65535, + 18148, 18150, 10591, 10593, 65535, 18149, 10594, 10592, 18151, 19086, + 65535, 1760, 3188, 10589, 65535, 1019, 2866, 65535, 2260, 10665, 18355, + 18361, 10667, 18145, 18360, 65535, 18367, 18358, 18365, 18364, 18141, + 18359, 17511, 18368, 18357, 18362, 2270, 18366, 18356, 65535, 18536, 10666, + 18363, 4883, 65535, 18672, 18537, 18535, 18533, 18534, 18538, 65535, 10795, + 18670, 18668, 18673, 18671, 65535, 18674, 10796, 18669, 65535, 2468, 18773, + 65535, 3162, 18845, 18846, 18847, 65535, 65535, 18941, 18931, 11476, 6573, + 65535, 6948, 65535, 12960, 12959, 7379, 7852, 13562, 65535, 65535, 13561, + 65535, 8300, 8721, 65535, 8720, 8722, 65535, 15500, 16076, 16666, 16668, + 16667, 65535, 10121, 17136, 17515, 18907, 5939, 2284, 12035, 12036, 12034, + 12033, 6574, 3870, 12474, 12472, 65535, 65535, 12471, 65535, 6949, 6951, + 6950, 12473, 65535, 2275, 65535, 65535, 65535, 65535, 65535, 65535, 12972, + 12969, 12967, 65535, 65535, 7380, 12970, 7385, 12964, 12979, 65535, 12981, + 12965, 3871, 7382, 12982, 12977, 12963, 12968, 12978, 12974, 12971, 65535, + 7387, 12980, 12966, 65535, 3197, 12975, 12961, 7386, 7383, 12973, 65535, + 12976, 12962, 7384, 7381, 65535, 65535, 4719, 65535, 7862, 13569, 7861, + 3872, 13572, 13575, 7858, 7856, 13564, 13573, 13571, 13568, 13576, 13577, + 13579, 13580, 13563, 7855, 13566, 13565, 13578, 7857, 13567, 7859, 7854, + 13570, 7863, 65535, 7860, 13574, 65535, 65535, 65535, 8307, 14223, 65535, + 14212, 8304, 65535, 14891, 14221, 14209, 8302, 14214, 8305, 14218, 14216, + 8308, 8301, 65535, 65535, 14210, 14213, 8306, 65535, 14211, 65535, 14222, + 14220, 14215, 14217, 14219, 8303, 65535, 3873, 65535, 65535, 65535, 65535, + 65535, 14892, 14898, 14888, 14894, 8723, 14890, 8729, 65535, 65535, 8728, + 65535, 8727, 14897, 8730, 8731, 14887, 14900, 8732, 8726, 8725, 14896, + 8733, 14886, 14889, 14899, 14895, 65535, 65535, 15532, 15521, 8724, 65535, + 65535, 65535, 65535, 9148, 15509, 15530, 15510, 9143, 65535, 15507, 65535, + 15516, 15508, 9145, 15502, 15529, 9146, 15526, 15527, 15503, 9151, 15518, + 65535, 15512, 15519, 15506, 65535, 15531, 15523, 15517, 15501, 9147, 15524, + 65535, 9150, 15528, 65535, 15522, 9144, 15520, 65535, 15514, 9142, 15505, + 15513, 15525, 15511, 65535, 65535, 15515, 65535, 65535, 65535, 65535, + 65535, 9515, 14893, 16094, 16103, 16093, 16089, 16086, 9516, 16084, 9149, + 16077, 9514, 16083, 9513, 16088, 16085, 16101, 16096, 16090, 16095, 9509, + 16087, 16106, 16078, 16079, 16102, 9510, 16107, 9512, 16108, 16092, 15504, + 16098, 16091, 16100, 16097, 4511, 2276, 65535, 16082, 9507, 16105, 9508, + 16080, 9511, 16678, 16099, 16104, 65535, 19055, 65535, 65535, 65535, 16675, + 9506, 9828, 16685, 16681, 4584, 16679, 16674, 16689, 65535, 3875, 4970, + 9832, 65535, 16670, 16682, 16683, 16673, 16672, 16686, 65535, 16676, 16671, + 16677, 65535, 16688, 16669, 16687, 16684, 9830, 9829, 65535, 65535, 9831, + 16680, 17532, 4046, 65535, 65535, 65535, 4967, 17138, 10127, 17142, 17139, + 17146, 17152, 17141, 2280, 17161, 10124, 17155, 17144, 17156, 17151, 17158, + 17143, 10129, 10128, 17145, 17159, 17137, 17157, 10122, 4984, 17149, 17148, + 17153, 17140, 10126, 65535, 10130, 17147, 17154, 10131, 17150, 65535, 4968, + 65535, 65535, 10123, 10125, 17528, 17526, 65535, 4870, 17533, 17530, 17534, + 2281, 17519, 17527, 17538, 17160, 17523, 10314, 16081, 17518, 17531, 17525, + 17522, 17517, 17516, 17537, 65535, 17521, 17520, 10312, 17529, 2278, 10311, + 65535, 65535, 10313, 17524, 17536, 4900, 17865, 17866, 65535, 10465, 17863, + 10462, 17871, 65535, 10466, 17873, 17862, 17535, 17875, 17864, 4583, 10463, + 17870, 65535, 17872, 17867, 17874, 17869, 17868, 10464, 65535, 2282, 18154, + 18155, 65535, 18157, 10595, 10596, 18158, 18156, 4844, 18153, 65535, 18371, + 18374, 18370, 65535, 10671, 18372, 10670, 10669, 10668, 18373, 18543, + 18541, 4319, 18540, 18369, 18542, 18375, 18539, 3200, 18677, 18643, 18675, + 10797, 18676, 18678, 65535, 18776, 10828, 18775, 18774, 10829, 65535, + 10859, 18886, 18909, 18908, 18910, 5940, 12475, 4811, 12983, 12984, 2287, + 2288, 65535, 14224, 65535, 18376, 18777, 5941, 6952, 12476, 2336, 65535, + 65535, 13581, 7864, 65535, 14226, 14225, 8309, 65535, 8734, 16109, 9517, + 65535, 9518, 2292, 65535, 2868, 9833, 10830, 5942, 1700, 4299, 65535, + 12477, 6576, 12479, 12478, 6953, 65535, 12985, 3203, 12992, 7388, 12990, + 12988, 65535, 12995, 12986, 12987, 7389, 65535, 7393, 65535, 65535, 12996, + 7392, 12994, 12991, 12989, 7390, 7391, 12993, 19763, 65535, 65535, 3205, + 7866, 13582, 65535, 7871, 13598, 7870, 13600, 1732, 1813, 13588, 7868, + 13599, 65535, 13583, 7869, 13595, 13591, 13593, 13587, 13594, 2293, 1027, + 7865, 13590, 4885, 13589, 13585, 65535, 13596, 65535, 65535, 13592, 13584, + 65535, 13586, 7867, 13597, 65535, 3878, 65535, 65535, 8312, 14237, 65535, + 2295, 2296, 14233, 14235, 14230, 14229, 14227, 65535, 14234, 14236, 14232, + 3206, 14231, 8310, 8311, 65535, 65535, 2298, 65535, 4585, 65535, 14239, + 8742, 14902, 14908, 14903, 14904, 18958, 14909, 65535, 8744, 65535, 8736, + 8743, 14901, 14228, 8739, 8737, 14907, 14906, 8738, 8740, 14905, 8735, + 65535, 8741, 65535, 65535, 65535, 65535, 3207, 15534, 9158, 65535, 65535, + 15545, 15544, 65535, 15539, 9160, 15543, 15535, 15536, 9152, 9154, 4320, + 15541, 15533, 9156, 9155, 15537, 15542, 15540, 9157, 15538, 3879, 19768, + 14238, 9153, 65535, 65535, 16110, 16117, 9520, 65535, 16121, 9524, 16113, + 16111, 65535, 16120, 65535, 9519, 16119, 9521, 9522, 16112, 9523, 16118, + 16114, 16115, 16116, 9159, 65535, 65535, 65535, 16690, 16702, 65535, 9838, + 16697, 16699, 3880, 9836, 16691, 16695, 65535, 16698, 9834, 9837, 16701, + 16693, 16694, 16700, 16692, 16696, 9835, 17163, 65535, 17162, 10133, 17168, + 10135, 65535, 65535, 10132, 17164, 10136, 17165, 65535, 65535, 17166, + 17169, 4335, 10134, 65535, 17543, 3881, 65535, 17546, 65535, 17540, 17542, + 3209, 65535, 17541, 17544, 17545, 17167, 17539, 3211, 65535, 10469, 17879, + 17882, 17884, 17877, 17878, 17881, 17883, 10470, 10468, 10467, 17880, + 17876, 18159, 10597, 3208, 18160, 65535, 65535, 18378, 10672, 18380, 10673, + 18377, 18379, 10746, 65535, 18544, 10745, 18681, 18680, 65535, 18679, 4268, + 65535, 18848, 18849, 18851, 18850, 65535, 11477, 5943, 3739, 6954, 13601, + 8313, 65535, 14910, 10315, 2301, 17885, 4963, 2302, 6188, 65535, 65535, + 65535, 7873, 65535, 3882, 65535, 7872, 4954, 14240, 8314, 14242, 14241, + 65535, 65535, 14911, 8745, 15546, 15549, 15548, 65535, 15547, 16122, 16124, + 16123, 4106, 2303, 2305, 65535, 2304, 9839, 65535, 10137, 17170, 17172, + 17171, 65535, 65535, 10316, 65535, 65535, 65535, 17887, 17886, 65535, + 18161, 10598, 65535, 2306, 10674, 18546, 18545, 10860, 1701, 65535, 65535, + 65535, 65535, 1313, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 6189, 12480, 6955, 13604, 13602, 65535, 65535, 13603, + 14244, 14245, 14918, 14243, 65535, 14912, 14916, 14915, 14917, 8746, 14914, + 14913, 14919, 2308, 15552, 15550, 65535, 15551, 16127, 16125, 65535, 65535, + 16126, 16703, 17173, 17174, 10317, 65535, 17888, 18162, 10599, 65535, + 18381, 18547, 10747, 65535, 18682, 18852, 6190, 65535, 6957, 6958, 12481, + 65535, 65535, 12482, 6956, 65535, 7399, 65535, 7397, 65535, 7396, 7403, + 7395, 7404, 12997, 7401, 65535, 7398, 7402, 7400, 7394, 65535, 65535, 7881, + 3224, 7875, 13608, 7880, 65535, 65535, 7882, 7876, 65535, 7877, 65535, + 13606, 65535, 3884, 7874, 3271, 13607, 7879, 65535, 65535, 13605, 7878, + 65535, 65535, 8325, 65535, 8327, 65535, 3885, 14248, 8326, 8315, 8319, + 3223, 8765, 14924, 14250, 8320, 65535, 65535, 14253, 14254, 8324, 65535, + 14256, 4971, 14258, 65535, 14259, 14247, 14246, 14260, 8323, 14257, 14255, + 65535, 8321, 8317, 8328, 14251, 14252, 14249, 65535, 8322, 65535, 65535, + 8318, 65535, 8316, 14923, 8760, 8755, 65535, 65535, 8750, 4865, 8766, 8751, + 65535, 8747, 8762, 8759, 8761, 65535, 8752, 8757, 8748, 8749, 14931, 14928, + 14920, 14925, 65535, 8763, 14932, 8764, 8754, 65535, 4891, 14922, 65535, + 14930, 14926, 14929, 14927, 8758, 14921, 8753, 65535, 65535, 65535, 15555, + 9162, 9165, 65535, 15557, 2314, 9173, 15556, 9167, 3886, 9529, 15558, + 65535, 9172, 15554, 9174, 65535, 2311, 65535, 9163, 65535, 8756, 9166, + 65535, 9164, 9168, 9170, 9161, 9175, 9171, 2329, 9169, 15553, 65535, 65535, + 65535, 2333, 9536, 65535, 9532, 65535, 3887, 65535, 9539, 65535, 16130, + 9540, 16142, 16135, 9525, 16143, 16137, 9535, 16138, 65535, 9534, 16141, + 9528, 16139, 16129, 9527, 16714, 9533, 65535, 9530, 1876, 9538, 65535, + 16128, 65535, 16132, 9526, 16131, 16133, 16134, 9537, 16136, 16140, 16144, + 2729, 9541, 9846, 16709, 16715, 16712, 16704, 16716, 16705, 65535, 16711, + 65535, 9841, 9847, 16717, 65535, 4244, 9843, 65535, 9853, 9848, 16719, + 16713, 9844, 16706, 9854, 16707, 16708, 9855, 9852, 9531, 1861, 9842, + 16720, 9856, 65535, 9849, 16718, 9845, 9850, 9851, 65535, 10145, 17179, + 17188, 17185, 17187, 65535, 10142, 17180, 2322, 17186, 10138, 17182, 10146, + 17178, 17183, 17190, 16710, 17184, 17177, 10139, 17176, 10140, 17191, + 10141, 17189, 10144, 17175, 2323, 10143, 65535, 17181, 17549, 17563, 17558, + 17560, 17548, 10318, 65535, 17547, 10321, 10320, 4878, 17562, 17554, 17551, + 17557, 65535, 17550, 65535, 17552, 17561, 17559, 65535, 10319, 17566, + 17564, 17555, 17565, 17556, 2326, 17892, 10471, 17899, 4973, 65535, 18384, + 10478, 17553, 17890, 10474, 17891, 17896, 2327, 2328, 10476, 10477, 17889, + 17898, 17900, 17893, 17895, 17897, 17894, 17901, 10473, 10479, 10475, + 65535, 10472, 18165, 4180, 10604, 18163, 65535, 4236, 18167, 65535, 18168, + 10602, 18169, 18166, 3309, 18164, 10605, 10601, 18170, 65535, 10603, 10600, + 65535, 65535, 65535, 10675, 65535, 65535, 10676, 18383, 18382, 18385, + 18386, 65535, 10677, 18548, 18553, 10748, 4073, 18550, 1803, 18549, 18552, + 18551, 65535, 18686, 65535, 10798, 18685, 18683, 65535, 18684, 1047, 2331, + 65535, 10832, 10831, 18778, 18779, 10833, 65535, 18853, 18854, 10872, 2332, + 10878, 65535, 18911, 18942, 1703, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1314, 65535, 65535, 65535, 1315, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6191, 65535, 13609, 65535, + 13610, 14933, 15559, 16145, 10148, 65535, 10147, 17567, 17902, 65535, + 18687, 6192, 12998, 7405, 7883, 14935, 14934, 9542, 16146, 9543, 17192, + 10322, 3888, 65535, 65535, 10887, 6193, 12037, 12999, 65535, 65535, 7884, + 65535, 13611, 13612, 65535, 14261, 65535, 8329, 8767, 65535, 14937, 14936, + 14938, 65535, 15560, 15561, 9176, 9857, 9544, 9858, 65535, 17196, 17193, + 17195, 17194, 10149, 65535, 17568, 17904, 17903, 11684, 7407, 7406, 13000, + 65535, 13613, 65535, 65535, 14263, 14262, 8330, 65535, 14940, 14941, 14939, + 65535, 65535, 8769, 8768, 65535, 9178, 9177, 65535, 16147, 16723, 16721, + 16722, 9859, 17198, 17197, 65535, 17571, 17570, 17569, 17905, 2337, 18912, + 6194, 6959, 3234, 6960, 7408, 7409, 13002, 13001, 13614, 65535, 7890, 7888, + 7885, 7889, 7887, 7886, 4972, 65535, 8331, 14266, 65535, 8774, 8333, 8338, + 14268, 8340, 8339, 8342, 14267, 14264, 8336, 8332, 8334, 14265, 8341, 8337, + 8335, 8776, 8775, 8773, 8777, 65535, 8771, 8772, 65535, 8770, 65535, 14942, + 4561, 65535, 15563, 65535, 9180, 9181, 9179, 3889, 15562, 2343, 15564, + 65535, 16150, 16152, 2349, 9553, 16153, 9546, 16149, 9545, 9555, 9551, + 9552, 9548, 16148, 9547, 16154, 16151, 3235, 9554, 4881, 9549, 9550, 16725, + 65535, 16727, 16726, 3890, 16728, 9860, 16724, 65535, 4903, 10153, 17199, + 10150, 10154, 10152, 10151, 17572, 65535, 17575, 65535, 17574, 2347, 17573, + 10323, 17906, 17907, 10480, 17908, 10481, 1334, 4875, 10607, 65535, 10606, + 18387, 2351, 2346, 10678, 18388, 18554, 10749, 10750, 4518, 18688, 65535, + 10835, 3891, 1704, 65535, 65535, 65535, 65535, 65535, 65535, 6195, 65535, + 7892, 7891, 14943, 14944, 65535, 9182, 16729, 9556, 16730, 17200, 6196, + 65535, 12483, 6962, 6961, 65535, 13003, 2354, 13004, 13617, 2764, 13616, + 65535, 13615, 65535, 65535, 14270, 8345, 4826, 65535, 14269, 8344, 65535, + 65535, 65535, 14271, 8343, 65535, 14946, 14949, 14947, 14948, 14952, 14945, + 14953, 14950, 14951, 9184, 15565, 65535, 65535, 9183, 65535, 16158, 16156, + 65535, 65535, 9557, 16155, 16157, 65535, 9558, 65535, 16731, 4979, 16732, + 10155, 2355, 17910, 17912, 17909, 17911, 18171, 18389, 65535, 65535, 18887, + 6197, 6963, 13005, 13007, 13006, 65535, 13620, 7894, 65535, 13618, 65535, + 7893, 13621, 1511, 13622, 13619, 3894, 65535, 14283, 8353, 14275, 14281, + 65535, 65535, 8348, 8351, 14274, 8346, 14278, 14959, 8350, 65535, 14273, + 4852, 14279, 14276, 14282, 14272, 14280, 8349, 8352, 14277, 8347, 65535, + 8779, 14955, 8778, 14962, 14961, 8785, 65535, 8786, 14963, 8780, 14960, + 8784, 14965, 14956, 65535, 14958, 8781, 14954, 14957, 14964, 8782, 14966, + 65535, 65535, 65535, 65535, 65535, 8783, 65535, 9185, 15570, 15576, 15568, + 15577, 4855, 15567, 15572, 15578, 15575, 15574, 15573, 65535, 15566, 15571, + 65535, 65535, 15569, 4489, 9563, 9560, 16167, 16172, 16174, 16171, 16164, + 16166, 16176, 16173, 16168, 16177, 16165, 16175, 9561, 9567, 9565, 16159, + 9566, 9562, 16160, 16162, 16161, 16169, 16170, 4858, 9564, 3242, 9559, + 65535, 4579, 16163, 65535, 16742, 9862, 65535, 16733, 9863, 9866, 16738, + 65535, 16735, 9865, 3897, 65535, 16739, 16740, 16734, 16743, 16736, 16741, + 9864, 65535, 9861, 16737, 1423, 17206, 10158, 10156, 10159, 10157, 17205, + 17202, 17201, 4853, 17204, 65535, 65535, 17203, 17589, 10329, 17580, 17579, + 65535, 10324, 17585, 17584, 17576, 17587, 17581, 10328, 17578, 17586, + 17577, 10325, 10327, 17582, 10326, 17583, 1482, 17588, 17916, 65535, 10486, + 17913, 65535, 17917, 65535, 3900, 10483, 17915, 10488, 4859, 10485, 4849, + 17914, 65535, 10487, 17918, 10482, 65535, 1441, 65535, 4472, 10609, 10611, + 65535, 18174, 10610, 18172, 10484, 18173, 10608, 10679, 10681, 18391, + 10680, 18390, 65535, 18559, 10751, 18558, 10752, 18556, 18555, 18560, + 18561, 18689, 65535, 18557, 65535, 65535, 18783, 18780, 18781, 18782, + 10861, 65535, 18857, 18856, 18855, 18888, 3243, 18932, 18913, 10879, 6198, + 7411, 2363, 65535, 65535, 3902, 65535, 8787, 65535, 65535, 65535, 2364, + 65535, 65535, 1815, 9568, 65535, 2434, 16744, 65535, 65535, 10330, 65535, + 17919, 2365, 65535, 65535, 65535, 65535, 65535, 18914, 6199, 6577, 6965, + 6964, 3904, 7414, 65535, 13008, 7412, 13009, 7413, 65535, 65535, 13627, + 13623, 65535, 4193, 7895, 13626, 13625, 13624, 7896, 13628, 13629, 3905, + 65535, 3906, 14290, 14288, 14292, 14293, 14299, 65535, 14295, 14297, 3907, + 14289, 14284, 65535, 14296, 3908, 65535, 14298, 14291, 14294, 14285, 8355, + 14287, 14286, 8354, 8356, 65535, 8790, 14968, 14970, 14969, 14974, 8788, + 65535, 14971, 14967, 14972, 14973, 8789, 8791, 4419, 65535, 15582, 15581, + 65535, 15579, 15580, 9187, 9189, 9186, 9188, 16184, 16185, 16180, 2367, + 16181, 9570, 9575, 9569, 9576, 9571, 16182, 65535, 65535, 16183, 16179, + 9577, 9573, 65535, 65535, 9572, 9574, 65535, 16178, 2368, 16746, 9868, + 3245, 65535, 16748, 9870, 16751, 16747, 4241, 16750, 9869, 16749, 65535, + 9867, 65535, 65535, 10161, 10164, 17208, 3582, 10162, 17207, 10160, 10163, + 17590, 17591, 17592, 10331, 3246, 17593, 65535, 10332, 10490, 17922, 17923, + 17921, 17920, 17924, 10489, 18178, 18176, 18177, 18179, 18175, 18180, + 18393, 4766, 18394, 18392, 10682, 18562, 10753, 18563, 18691, 18690, 65535, + 1316, 1317, 65535, 65535, 65535, 65535, 65535, 65535, 1318, 65535, 65535, + 65535, 65535, 3797, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6200, + 8357, 65535, 65535, 8792, 4108, 65535, 65535, 9190, 65535, 2371, 9872, + 1742, 9871, 65535, 65535, 65535, 65535, 10491, 10579, 10683, 6201, 7415, + 8793, 2375, 17925, 10949, 3995, 3909, 19762, 4461, 4459, 3771, 3773, 65535, + 4457, 11686, 65535, 3910, 6202, 65535, 6205, 6204, 6203, 65535, 65535, + 11685, 3911, 12039, 3912, 12041, 6578, 1817, 4428, 6580, 12038, 12040, + 6579, 12043, 12042, 12044, 65535, 65535, 4932, 65535, 65535, 65535, 65535, + 65535, 12487, 12485, 6968, 12484, 6973, 6970, 6967, 65535, 6974, 65535, + 6969, 6972, 65535, 6971, 12486, 65535, 6966, 65535, 65535, 65535, 7421, + 13011, 13017, 7418, 7425, 2382, 7420, 13014, 13016, 7423, 13010, 13013, + 7419, 7416, 13012, 7422, 13015, 7424, 7417, 65535, 4674, 65535, 65535, + 13631, 13634, 7898, 65535, 7908, 7904, 13632, 4453, 65535, 7912, 7905, + 7910, 7900, 65535, 7897, 7899, 7911, 13633, 7903, 7906, 7902, 7907, 13635, + 7909, 7901, 13630, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 14300, 8358, 14302, 65535, 8360, 8362, 3913, 14301, 8359, 8363, 2389, 8361, + 65535, 65535, 65535, 8799, 14980, 8807, 14977, 65535, 8808, 8797, 65535, + 14978, 65535, 1033, 8802, 65535, 14979, 8795, 8794, 4731, 8805, 8804, 8803, + 8801, 8806, 14976, 8796, 8798, 8800, 4233, 65535, 9192, 9195, 65535, 9199, + 9193, 9198, 9196, 65535, 9191, 2392, 9197, 9194, 3423, 65535, 65535, 16189, + 9580, 9578, 65535, 16190, 3703, 9581, 9579, 16188, 16187, 65535, 9876, + 16186, 9874, 9873, 16752, 9582, 9875, 16753, 9878, 16754, 9877, 10166, + 17210, 10165, 10170, 10168, 10169, 10334, 10167, 17209, 16755, 10333, + 10335, 65535, 10492, 10493, 65535, 18181, 65535, 10800, 10799, 6207, 65535, + 65535, 11482, 7426, 65535, 3259, 11480, 11478, 65535, 11481, 65535, 65535, + 11690, 11687, 11692, 11688, 6208, 6211, 65535, 11689, 6210, 11691, 2395, + 65535, 6209, 65535, 65535, 65535, 2399, 12047, 12049, 6583, 12045, 12048, + 12046, 6581, 6584, 65535, 6582, 65535, 65535, 3258, 65535, 12489, 12493, + 12490, 65535, 6977, 65535, 6978, 2397, 12492, 65535, 12494, 12496, 65535, + 6975, 12495, 65535, 65535, 6976, 65535, 65535, 65535, 65535, 65535, 13642, + 12491, 13018, 13027, 13025, 13020, 13021, 13026, 13028, 7428, 65535, 13023, + 13019, 7427, 7429, 13022, 13029, 13024, 65535, 65535, 7913, 13645, 13637, + 13643, 13644, 7914, 65535, 13636, 13638, 12488, 13640, 13641, 13639, 8365, + 65535, 65535, 65535, 14309, 16756, 14310, 14307, 2400, 8367, 14306, 14312, + 14311, 8364, 14315, 4279, 14314, 14303, 14313, 14308, 8366, 65535, 14987, + 65535, 14982, 14988, 14983, 14981, 14984, 8809, 65535, 14986, 65535, 14985, + 8810, 9201, 9200, 15589, 15592, 15584, 15588, 9202, 15587, 15585, 15591, + 15586, 15583, 15590, 65535, 16196, 9585, 17594, 16193, 16194, 16192, 14304, + 9584, 16197, 16191, 9583, 9586, 16195, 16757, 9879, 16758, 16759, 65535, + 17211, 10171, 17595, 17596, 65535, 65535, 17597, 17927, 17926, 18183, + 65535, 18182, 18396, 18397, 18395, 18564, 10754, 6212, 6980, 6979, 7432, + 7431, 13031, 13032, 13030, 4790, 7430, 13649, 65535, 13650, 13646, 7916, + 13647, 4786, 13648, 65535, 4788, 65535, 1331, 14318, 14320, 14316, 14319, + 8368, 14317, 8369, 65535, 2401, 14495, 8813, 8812, 65535, 8811, 65535, + 14989, 14990, 4602, 65535, 15594, 15596, 9206, 9203, 4563, 9205, 9204, + 15595, 15593, 65535, 4832, 65535, 65535, 65535, 16204, 16201, 16202, 9590, + 16203, 16198, 16199, 9587, 65535, 9588, 16200, 9589, 1329, 16763, 4796, + 16764, 16761, 16762, 9880, 16760, 65535, 65535, 65535, 65535, 65535, 17215, + 17212, 17214, 10174, 17218, 10173, 17216, 17219, 17217, 17213, 10172, + 65535, 17599, 65535, 17600, 17598, 2403, 17602, 10336, 10337, 17929, 10495, + 17601, 17928, 10494, 18186, 18187, 10612, 18185, 1605, 18184, 65535, 18398, + 10684, 3262, 18692, 18785, 18784, 65535, 10836, 10862, 18786, 18889, 2404, + 10880, 6213, 6585, 65535, 8814, 65535, 10613, 6214, 6981, 7917, 8370, + 10338, 6586, 65535, 12498, 4206, 13033, 19341, 7435, 7433, 7437, 13035, + 65535, 7436, 7434, 65535, 1265, 65535, 65535, 13034, 7920, 13656, 3324, + 7919, 7921, 13661, 7923, 13658, 13659, 13651, 7922, 13662, 65535, 65535, + 13653, 65535, 13654, 13652, 7918, 1743, 13660, 13655, 13657, 3051, 65535, + 65535, 14332, 2313, 14331, 14329, 14321, 14336, 14324, 14334, 14341, 14333, + 8378, 4604, 8374, 14322, 65535, 14328, 8376, 2408, 14327, 8377, 8379, + 14330, 3917, 8371, 8372, 14342, 14340, 1022, 14339, 14325, 65535, 14337, + 65535, 8375, 65535, 65535, 1820, 65535, 8373, 14338, 14323, 14326, 14335, + 3919, 65535, 3332, 3227, 65535, 15631, 15000, 65535, 14993, 15012, 15021, + 14996, 8825, 3097, 15009, 8815, 8817, 8829, 14994, 65535, 19463, 8818, + 8820, 8830, 8819, 2410, 65535, 65535, 2428, 8828, 15002, 65535, 14991, + 8826, 15001, 8822, 15019, 8827, 15017, 15005, 15015, 8824, 14992, 15018, + 15013, 4409, 15020, 8816, 3920, 65535, 8831, 8821, 65535, 2798, 14998, + 3543, 15006, 15010, 2411, 15014, 8823, 14997, 14995, 15007, 65535, 65535, + 65535, 3921, 15004, 15003, 3580, 15008, 15011, 65535, 15016, 65535, 65535, + 65535, 15599, 3419, 9207, 15609, 15601, 9212, 9216, 15618, 15626, 15611, + 9208, 4309, 15615, 14999, 3504, 9209, 15622, 15627, 15619, 2983, 15621, + 15630, 15623, 15605, 15614, 2813, 65535, 9217, 65535, 9213, 15603, 15616, + 9211, 15610, 9210, 15624, 15607, 15600, 9214, 15629, 65535, 65535, 15602, + 15620, 15617, 15612, 15598, 15597, 15606, 15625, 9215, 15628, 15604, 15608, + 9595, 65535, 3923, 65535, 65535, 3922, 9603, 9598, 16237, 16234, 16210, + 9593, 65535, 2413, 3307, 9592, 9599, 65535, 3415, 3924, 16208, 9597, 16220, + 16206, 16207, 9591, 16236, 9601, 16223, 16228, 16222, 16782, 16218, 16226, + 16224, 16211, 16205, 16232, 9600, 16233, 2366, 16227, 65535, 16216, 16214, + 16209, 65535, 18998, 65535, 16217, 16230, 16213, 16229, 16235, 65535, 3925, + 9596, 3481, 16225, 16231, 16221, 16215, 9594, 3926, 2635, 65535, 15613, + 16219, 9602, 16212, 2980, 3927, 3928, 65535, 3322, 16788, 9883, 16787, + 16784, 16803, 9887, 3929, 16800, 16792, 16802, 16777, 16790, 2372, 9889, + 65535, 16769, 3076, 16767, 16801, 65535, 16799, 16798, 16781, 16780, 16770, + 9891, 65535, 16776, 16786, 16797, 9894, 16804, 65535, 10182, 9896, 9890, + 16774, 65535, 16783, 16766, 16768, 9881, 9893, 9886, 16775, 16791, 16785, + 9892, 16765, 10177, 16793, 16796, 9888, 2419, 16779, 9895, 9885, 4312, + 3508, 65535, 9884, 16789, 16795, 9882, 65535, 16772, 16794, 65535, 65535, + 16773, 65535, 65535, 65535, 19332, 19630, 3053, 3930, 19008, 4523, 16778, + 17225, 3416, 17230, 10179, 10181, 17236, 10175, 17251, 17242, 17231, 17232, + 17241, 65535, 10188, 17240, 17224, 17239, 17227, 17252, 10187, 10185, + 17228, 65535, 17247, 3506, 17233, 17246, 19615, 17248, 17223, 10180, 2800, + 17249, 3302, 2632, 17237, 2420, 10184, 17234, 2771, 65535, 10186, 17243, + 65535, 2432, 3547, 10178, 17229, 17244, 2524, 17238, 16771, 17245, 17226, + 3355, 10183, 65535, 17250, 2636, 10176, 17221, 3931, 19703, 3511, 3027, + 17616, 17609, 10340, 65535, 17604, 17619, 17611, 17235, 3635, 17621, 17605, + 65535, 10339, 17615, 10341, 10349, 10347, 17617, 10348, 17607, 2707, 17608, + 17613, 17618, 2979, 17220, 10342, 17626, 17623, 17627, 17614, 17610, 17624, + 17940, 17612, 65535, 10345, 3932, 10344, 17222, 10346, 17620, 17622, 10343, + 17625, 17603, 65535, 17606, 3463, 65535, 65535, 3462, 65535, 2836, 65535, + 4367, 17949, 65535, 17933, 10499, 17947, 65535, 2705, 17931, 10500, 65535, + 17942, 2637, 17938, 10505, 17948, 17932, 17935, 10497, 17950, 19211, 17943, + 17946, 10503, 10508, 10506, 17939, 17934, 3414, 10501, 10502, 17930, 10498, + 2829, 10496, 10504, 17945, 10507, 65535, 17941, 17951, 10509, 65535, 65535, + 65535, 17937, 65535, 17944, 65535, 19573, 19683, 65535, 2633, 1769, 18200, + 18214, 18202, 18209, 17936, 18207, 18190, 18212, 10616, 18194, 18211, + 18201, 3531, 65535, 10615, 3263, 65535, 18216, 18203, 2834, 18208, 18210, + 18188, 18213, 18199, 18204, 18192, 18196, 18215, 18206, 18189, 18193, + 18195, 18205, 3936, 10614, 18198, 65535, 19316, 65535, 3938, 65535, 65535, + 18191, 65535, 65535, 65535, 2602, 2483, 2437, 3267, 18197, 18402, 18407, + 10691, 18409, 3939, 10685, 1017, 18405, 18411, 10690, 10686, 65535, 10687, + 18401, 18408, 10689, 18406, 10688, 18400, 18404, 18403, 3940, 18399, 18410, + 65535, 19625, 19628, 10755, 18571, 18574, 18570, 18572, 18573, 18567, + 18568, 18565, 3420, 65535, 18569, 18566, 10756, 10757, 65535, 3942, 18694, + 65535, 18696, 3366, 65535, 65535, 2433, 65535, 18695, 18697, 65535, 10802, + 65535, 18693, 10801, 10803, 4253, 65535, 2986, 18788, 18789, 10837, 18787, + 2129, 18859, 18858, 18860, 10864, 18861, 10863, 18862, 18890, 18893, 18892, + 10873, 18891, 3943, 65535, 19406, 10883, 10881, 10882, 10888, 18934, 18935, + 18933, 18943, 65535, 1705, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4316, 65535, 65535, + 1725, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4015, 65535, 4011, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4001, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3994, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3944, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4448, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6587, 1706, 65535, 13663, 14343, 16238, + 17952, 65535, 1707, 6588, 65535, 6982, 7438, 65535, 2435, 13664, 65535, + 13665, 7924, 65535, 8382, 14345, 14344, 8386, 8381, 14346, 8383, 8385, + 8384, 8380, 65535, 3275, 3274, 8832, 3272, 65535, 15025, 15023, 65535, + 15024, 15022, 2438, 9218, 3945, 9221, 9223, 9222, 2436, 3273, 9219, 9220, + 1586, 16240, 16239, 9604, 16241, 65535, 16242, 9605, 65535, 65535, 65535, + 16812, 16810, 17258, 65535, 16808, 16809, 9897, 16805, 16813, 16807, 16811, + 17254, 65535, 65535, 17256, 65535, 17257, 10193, 17253, 10192, 17255, + 10189, 10190, 10191, 16806, 65535, 65535, 10352, 17630, 17628, 17629, + 10350, 10353, 10351, 65535, 65535, 65535, 17953, 17954, 10510, 65535, + 18217, 18219, 18218, 10617, 10692, 18414, 18413, 18412, 65535, 65535, 1708, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3947, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 6589, 1723, 11376, 65535, 11485, 5944, 11483, + 11486, 11484, 65535, 65535, 65535, 11694, 65535, 6218, 65535, 6219, 11696, + 6216, 11695, 11693, 6217, 6215, 3948, 65535, 65535, 65535, 65535, 4939, + 12050, 12053, 6592, 12052, 12051, 65535, 6591, 6590, 4778, 6594, 12054, + 6593, 3874, 65535, 65535, 65535, 65535, 12503, 6984, 6985, 6986, 12504, + 12500, 6983, 12501, 65535, 12502, 12499, 65535, 4264, 65535, 7445, 65535, + 65535, 7442, 13036, 7443, 7446, 13037, 65535, 7441, 7439, 7440, 7444, + 65535, 65535, 65535, 65535, 3851, 7925, 13668, 7933, 13667, 65535, 13670, + 7929, 13669, 8394, 7927, 7930, 7926, 7931, 7932, 7928, 65535, 65535, 2447, + 13666, 8390, 14348, 65535, 14352, 4787, 65535, 14351, 8395, 8391, 8392, + 14347, 14349, 14350, 8387, 8389, 65535, 8393, 8388, 3284, 65535, 15028, + 15026, 15027, 8834, 8835, 2448, 15029, 8833, 9224, 65535, 9226, 9225, + 65535, 15632, 65535, 65535, 15633, 16244, 2450, 16243, 19755, 65535, 9898, + 9899, 16814, 9900, 65535, 17261, 65535, 17259, 65535, 17260, 10194, 65535, + 17631, 10511, 65535, 2453, 65535, 10195, 6595, 65535, 7447, 13038, 2456, + 65535, 13671, 7934, 8396, 14353, 14355, 8398, 8397, 8399, 8400, 14354, + 8838, 8839, 8837, 9227, 8836, 15030, 65535, 65535, 65535, 9228, 16245, + 16815, 9901, 10196, 17632, 17636, 10356, 17633, 10357, 10355, 17637, 10358, + 17635, 65535, 17955, 10354, 10512, 65535, 18790, 65535, 65535, 6596, 7936, + 7935, 65535, 65535, 65535, 65535, 8401, 14357, 14356, 8402, 65535, 2799, + 15034, 8843, 8840, 15033, 8842, 15031, 8841, 65535, 15032, 65535, 15634, + 9229, 65535, 16248, 4728, 9606, 16246, 9607, 9608, 16247, 9609, 65535, + 16816, 65535, 9905, 9902, 9907, 16818, 9903, 16817, 9906, 65535, 65535, + 9904, 65535, 17264, 17266, 65535, 2476, 10197, 17265, 10198, 17263, 17262, + 4905, 17639, 17638, 10359, 17640, 17960, 10514, 17959, 17956, 10513, 17957, + 17958, 65535, 18220, 18221, 10618, 2467, 10695, 65535, 985, 18415, 2469, + 65535, 10693, 10694, 18416, 65535, 65535, 10758, 10759, 18575, 3952, 3295, + 10838, 18792, 10840, 65535, 18791, 18793, 10839, 18863, 1021, 18915, 65535, + 65535, 65535, 65535, 65535, 1668, 6597, 65535, 65535, 1765, 8844, 2479, + 15635, 65535, 16249, 9908, 2477, 3301, 6598, 2482, 9610, 10515, 6987, + 65535, 65535, 65535, 9910, 65535, 10804, 6988, 13672, 65535, 14358, 4559, + 14360, 65535, 14359, 3314, 15038, 15035, 8845, 65535, 8846, 15036, 15037, + 65535, 15637, 15642, 9230, 15636, 15638, 15645, 15640, 15644, 15641, 15639, + 15643, 9231, 65535, 19178, 16252, 2487, 16250, 9612, 65535, 9611, 16251, + 9613, 65535, 65535, 65535, 65535, 16821, 65535, 65535, 16820, 9911, 16819, + 17267, 3313, 17269, 17271, 17270, 2488, 10199, 17268, 17647, 10360, 17645, + 17648, 10361, 65535, 17643, 65535, 17646, 17644, 17641, 10362, 17642, + 65535, 65535, 2489, 3954, 17961, 4768, 65535, 17963, 17962, 4110, 18222, + 4770, 18223, 65535, 19329, 2490, 18417, 2491, 10761, 3955, 10760, 18698, + 18699, 10841, 18794, 4764, 10874, 65535, 6989, 8403, 15647, 15646, 16254, + 16253, 65535, 2492, 10200, 17273, 17272, 17651, 17649, 17652, 17650, 65535, + 65535, 10516, 17964, 17965, 17966, 2493, 18418, 65535, 18576, 65535, 18795, + 1710, 65535, 65535, 65535, 65535, 65535, 65535, 6990, 2495, 65535, 16822, + 17274, 2612, 6991, 65535, 2499, 9232, 65535, 16823, 10363, 17653, 10517, + 65535, 18224, 18225, 2498, 18700, 6992, 7939, 7940, 13673, 8404, 8405, + 14361, 8406, 65535, 8850, 65535, 8852, 15040, 15041, 15039, 8847, 8848, + 8851, 8849, 19401, 1465, 15648, 9233, 9234, 65535, 65535, 16261, 9616, + 16256, 16255, 3320, 16260, 9614, 65535, 4380, 9918, 65535, 16257, 16262, + 16259, 16258, 65535, 9615, 65535, 9916, 4835, 16825, 9912, 65535, 16826, + 2504, 2503, 16824, 65535, 9915, 9913, 9917, 65535, 9914, 65535, 65535, + 65535, 65535, 65535, 17275, 65535, 17280, 17276, 17279, 10201, 4112, 17070, + 17278, 17277, 2505, 10366, 10364, 10367, 10365, 17654, 17655, 17656, 10368, + 65535, 65535, 1881, 17970, 10519, 17968, 65535, 10520, 17967, 17969, 10518, + 18229, 18226, 65535, 18227, 18228, 18419, 10698, 2506, 10697, 1830, 18578, + 18577, 10762, 19039, 65535, 65535, 10805, 10842, 10865, 18864, 18916, + 18917, 1711, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6993, 14362, + 65535, 65535, 15042, 15649, 15650, 9235, 65535, 9236, 16263, 9617, 4836, + 65535, 10202, 2514, 17657, 3959, 10369, 17973, 10521, 17972, 17974, 17971, + 18422, 18230, 18231, 3181, 10619, 65535, 18421, 2516, 2515, 18420, 2513, + 18579, 18918, 65535, 1712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 6994, 3329, 65535, 1713, 6995, 3916, + 2521, 7448, 13039, 65535, 13674, 2522, 8407, 65535, 8410, 8408, 14363, + 2523, 8412, 65535, 8409, 65535, 3961, 8411, 65535, 8854, 1506, 15043, + 65535, 65535, 15044, 16265, 65535, 8853, 8855, 8856, 65535, 15652, 65535, + 15651, 9237, 65535, 9238, 65535, 15653, 16264, 9240, 9618, 65535, 9239, + 65535, 3963, 65535, 9919, 16266, 9620, 9619, 16267, 16270, 16268, 16269, + 9621, 3964, 9924, 9922, 3966, 65535, 9921, 16828, 65535, 9923, 65535, + 65535, 16827, 17281, 65535, 16829, 9920, 16830, 17284, 17282, 17283, 17288, + 10373, 17287, 17290, 17289, 17286, 17285, 65535, 10203, 65535, 3967, 3315, + 2525, 17660, 3335, 17659, 10372, 10370, 10371, 4769, 17658, 3968, 17977, + 65535, 10522, 65535, 17976, 17975, 10523, 4911, 18236, 18235, 3336, 18233, + 65535, 18232, 10621, 10620, 18237, 18580, 10763, 18424, 10699, 18423, + 18234, 65535, 18581, 10806, 3969, 10866, 18865, 65535, 18919, 3970, 1714, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 6996, 13675, 17291, + 6997, 65535, 3339, 15655, 15654, 16831, 65535, 65535, 17293, 65535, 17292, + 19447, 10374, 17978, 17979, 10622, 65535, 3341, 18920, 7449, 8414, 8413, + 15045, 15047, 8858, 15046, 8857, 8859, 15048, 65535, 65535, 2610, 15657, + 15659, 15658, 3352, 15661, 65535, 65535, 65535, 9241, 15660, 15656, 3914, + 3972, 65535, 15662, 65535, 16277, 65535, 16280, 16282, 16272, 16276, 16273, + 9623, 9626, 9628, 16274, 16275, 9627, 4182, 16281, 16279, 9629, 4783, 9625, + 16271, 9622, 65535, 9624, 1819, 2136, 9926, 16837, 16835, 16834, 3161, + 16840, 65535, 16839, 16838, 65535, 16833, 9925, 16832, 65535, 16836, 9927, + 65535, 65535, 17296, 2530, 17300, 17297, 17299, 17298, 17295, 17301, 17304, + 17302, 17303, 10205, 65535, 10204, 17294, 17305, 17665, 17668, 17670, + 17669, 65535, 17663, 17667, 17662, 2531, 17664, 10375, 17661, 2533, 17666, + 65535, 65535, 17992, 17981, 10524, 65535, 65535, 10525, 17980, 17985, + 17991, 17983, 17990, 3169, 17987, 3346, 17986, 17989, 17984, 17982, 4284, + 17988, 65535, 18244, 18242, 10623, 18241, 18247, 18245, 3348, 10624, 18240, + 18238, 65535, 18239, 10626, 18243, 10625, 18246, 18425, 18431, 2532, 3974, + 18426, 10703, 18432, 10702, 18430, 18429, 10701, 18428, 10700, 18427, + 65535, 18587, 18589, 18588, 65535, 18585, 10765, 18582, 18586, 18591, + 65535, 18590, 18583, 18584, 10764, 18701, 10809, 2534, 18702, 10807, 10808, + 3342, 65535, 18796, 10843, 18894, 65535, 10875, 3163, 18921, 10876, 18922, + 18923, 18937, 18936, 10891, 18947, 1356, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1357, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 7450, 65535, 65535, 15050, 65535, 15049, 65535, 9242, 9243, 15663, + 1455, 16283, 16843, 65535, 1593, 9630, 9928, 16841, 4837, 16844, 9929, + 4113, 17306, 16842, 17671, 10376, 17993, 65535, 65535, 65535, 18250, 18248, + 65535, 65535, 18249, 65535, 65535, 18433, 65535, 10704, 18592, 10812, + 10766, 10810, 10811, 18797, 10867, 4896, 7451, 65535, 65535, 65535, 17672, + 65535, 65535, 13040, 2539, 8860, 2540, 15664, 65535, 65535, 9244, 15665, + 65535, 65535, 65535, 16285, 16284, 9931, 9631, 9632, 65535, 16288, 16287, + 16286, 2542, 65535, 16845, 16848, 65535, 16847, 16846, 9930, 17310, 17308, + 17307, 4738, 65535, 17309, 4733, 10377, 17674, 17675, 10378, 65535, 17673, + 4747, 17995, 17994, 17997, 10526, 17996, 3975, 18251, 18253, 18252, 65535, + 2544, 18434, 18437, 18435, 18436, 18593, 10767, 65535, 65535, 65535, 18703, + 18704, 18705, 65535, 10844, 10868, 18924, 7452, 65535, 9633, 9932, 17676, + 4740, 18594, 65535, 2545, 4742, 13041, 65535, 10892, 7453, 16849, 2548, + 17677, 65535, 17998, 65535, 4711, 18438, 18595, 7454, 65535, 15666, 15667, + 2553, 9245, 9246, 16290, 9635, 9634, 16289, 65535, 17311, 65535, 17678, + 17680, 17679, 10381, 10380, 10379, 2552, 10706, 18439, 65535, 10705, 18597, + 18596, 65535, 10845, 18798, 7941, 15051, 65535, 65535, 65535, 15670, 15668, + 15669, 65535, 65535, 16299, 65535, 16294, 16291, 16298, 3977, 65535, 65535, + 16300, 65535, 65535, 9637, 16297, 16293, 65535, 65535, 16292, 16296, 16295, + 9636, 65535, 65535, 16860, 16855, 16853, 16862, 16854, 3377, 16850, 3978, + 16856, 19535, 65535, 16851, 17320, 16852, 16863, 65535, 65535, 4688, 65535, + 1658, 2557, 4899, 16859, 9933, 16858, 16857, 65535, 16861, 65535, 4834, + 65535, 65535, 17312, 17315, 65535, 4807, 17314, 3380, 17322, 17317, 17321, + 65535, 17319, 17318, 17316, 65535, 17313, 65535, 10208, 10207, 65535, + 10209, 10206, 17323, 4906, 65535, 65535, 65535, 65535, 17686, 17689, 65535, + 17687, 17691, 65535, 65535, 65535, 17692, 65535, 17684, 10386, 17685, + 65535, 17683, 17690, 65535, 17682, 17681, 10385, 10383, 10382, 65535, + 65535, 65535, 65535, 3378, 65535, 65535, 65535, 17688, 18007, 18013, 10529, + 18008, 65535, 18011, 18015, 10530, 18010, 3979, 18002, 65535, 18001, 18014, + 18005, 65535, 18003, 18012, 18004, 10528, 10527, 3255, 17999, 18000, 18009, + 4657, 65535, 65535, 18006, 3980, 65535, 65535, 3981, 65535, 65535, 18256, + 18259, 65535, 65535, 65535, 65535, 10384, 65535, 2560, 65535, 65535, 2559, + 65535, 65535, 18257, 18263, 18261, 18255, 18266, 4775, 18254, 2561, 10628, + 18262, 65535, 3376, 65535, 18258, 10627, 18265, 4745, 65535, 18264, 65535, + 65535, 65535, 4749, 18442, 18441, 65535, 1657, 3983, 18448, 65535, 18444, + 18447, 10708, 1592, 65535, 18445, 18446, 65535, 18440, 18443, 10707, 65535, + 4045, 65535, 10769, 18608, 18603, 18607, 3375, 18610, 18606, 65535, 18602, + 3987, 10771, 18605, 18609, 10770, 18600, 18260, 18604, 65535, 65535, 18601, + 4520, 18598, 65535, 18599, 10768, 18709, 18711, 18714, 18710, 18715, 3372, + 18708, 65535, 18706, 3373, 10813, 18712, 10815, 10814, 18707, 18713, 65535, + 65535, 65535, 4616, 18803, 10846, 18804, 65535, 18802, 18799, 65535, 65535, + 18801, 18800, 18866, 65535, 65535, 65535, 65535, 18868, 18867, 65535, + 65535, 18897, 4569, 18896, 18895, 18898, 65535, 10884, 10885, 18944, 18948, + 3374, 1716, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 7942, + 14364, 15054, 65535, 8861, 15052, 65535, 65535, 15053, 65535, 65535, 65535, + 15671, 15672, 9249, 9247, 15673, 9248, 16305, 65535, 16308, 16302, 16309, + 16301, 16303, 65535, 16304, 16307, 65535, 4776, 9640, 16312, 16311, 9638, + 16306, 16310, 9639, 65535, 65535, 3388, 65535, 65535, 65535, 16873, 65535, + 9938, 65535, 16868, 9934, 3443, 16865, 16871, 16874, 65535, 9939, 65535, + 16870, 16867, 16875, 16866, 3383, 16872, 9935, 65535, 16864, 9936, 65535, + 9937, 16869, 65535, 65535, 65535, 17341, 17328, 17329, 17332, 17330, 65535, + 17324, 19060, 65535, 17327, 17337, 17331, 2581, 65535, 10210, 65535, 17339, + 17336, 10211, 17338, 17325, 17334, 17335, 4897, 17333, 65535, 65535, 65535, + 3986, 17696, 17698, 17701, 65535, 1264, 17695, 4632, 10387, 17703, 17694, + 17704, 65535, 17700, 17702, 17706, 17699, 17707, 17697, 17693, 10388, 4517, + 17705, 10389, 10532, 65535, 65535, 65535, 65535, 65535, 17326, 18041, + 18032, 10534, 18028, 10535, 3233, 1464, 18037, 18031, 18021, 10533, 18034, + 18029, 18030, 65535, 18016, 18023, 18038, 65535, 18035, 4709, 18027, 2570, + 18039, 18022, 18017, 18036, 2571, 18019, 18033, 18024, 18040, 18020, 10531, + 18018, 18025, 18026, 65535, 65535, 65535, 18273, 65535, 18271, 3990, 18276, + 65535, 18288, 18279, 18272, 18268, 18281, 18274, 18277, 18270, 18284, + 18267, 18275, 18280, 18282, 18285, 18269, 3393, 18289, 18290, 18283, 18287, + 18278, 4765, 18464, 18467, 65535, 10709, 65535, 18466, 18471, 18469, 10710, + 18460, 18450, 18449, 10712, 18462, 18463, 18459, 18451, 3991, 18456, 18286, + 3992, 18452, 10711, 18458, 2575, 18457, 65535, 18453, 18465, 1342, 18454, + 18615, 18468, 18470, 18461, 18455, 18616, 18618, 18612, 10772, 2563, 18625, + 18623, 10773, 18622, 18621, 18614, 18611, 18617, 18626, 18613, 18619, + 65535, 18724, 18729, 18719, 18722, 10816, 18726, 65535, 18733, 18620, + 65535, 18720, 18730, 18734, 18725, 18718, 4282, 65535, 18727, 18732, 18731, + 18624, 18723, 18717, 18721, 10847, 10848, 18716, 3993, 18815, 18806, 18814, + 18811, 18812, 18805, 18808, 18816, 18810, 18809, 18807, 65535, 18813, 1347, + 18869, 1343, 18870, 2573, 18872, 18871, 18874, 18873, 18900, 18899, 18925, + 65535, 18926, 3386, 18939, 10889, 10893, 4854, 18949, 10894, 1717, 65535, + 65535, 65535, 65535, 65535, 7943, 65535, 65535, 65535, 10629, 18472, 3996, + 10849, 10850, 65535, 7944, 15055, 4730, 8862, 16313, 4839, 4692, 16877, + 16878, 16876, 17343, 17342, 10212, 17709, 17344, 17708, 65535, 2584, 18043, + 10536, 10538, 18042, 2585, 4915, 10537, 4755, 18291, 18293, 18292, 18473, + 10713, 2586, 10817, 18817, 18875, 2587, 65535, 18952, 7945, 5022, 15674, + 4838, 9641, 2589, 4554, 3997, 16880, 16879, 2590, 17345, 3998, 65535, + 65535, 10539, 10630, 18627, 18945, 65535, 65535, 65535, 7946, 9250, 3999, + 9642, 3935, 18044, 2592, 18735, 8415, 1718, 65535, 4000, 1340, 17346, + 65535, 65535, 65535, 10869, 8416, 9643, 10213, 18736, 8417, 65535, 16314, + 9941, 16881, 16882, 65535, 9940, 65535, 17347, 10217, 10215, 10216, 10214, + 17710, 10390, 65535, 4002, 65535, 18295, 18294, 18297, 18296, 10631, 65535, + 65535, 18474, 65535, 18476, 18475, 10714, 18628, 4003, 18737, 18738, 10818, + 18876, 18901, 10886, 4004, 14365, 16883, 17348, 18045, 15056, 3988, 17349, + 17712, 17711, 2599, 65535, 65535, 65535, 18739, 10851, 2600, 18877, 18902, + 65535, 65535, 65535, 8863, 16315, 16316, 65535, 16884, 8864, 65535, 10391, + 2605, 2604, 18478, 10715, 18479, 18477, 18740, 65535, 18818, 65535, 8865, + 65535, 17352, 17351, 17350, 17714, 4868, 1655, 17718, 17717, 17716, 17715, + 10392, 18046, 18299, 10632, 18298, 18480, 18631, 18630, 10774, 18629, + 18743, 18742, 18741, 2606, 65535, 9251, 65535, 16885, 10218, 65535, 18047, + 18048, 18632, 18744, 4006, 2609, 18819, 18878, 18927, 18954, 9252, 10219, + 17719, 18049, 18481, 18745, 5021, 65535, 9645, 4850, 17353, 17720, 18050, + 18051, 18052, 18304, 4751, 18300, 10716, 18303, 18302, 10633, 18301, 10635, + 2614, 10634, 18483, 18482, 10717, 10718, 65535, 2615, 10776, 18633, 10775, + 65535, 18748, 18749, 18747, 18746, 10853, 65535, 18820, 18821, 18822, + 10852, 18879, 18882, 18881, 18880, 65535, 65535, 18953, 2016, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 9942, 2617, 65535, 10399, 18305, 18484, 65535, 10777, 18634, 1016, + 1008, 18955, 1358, 65535, 65535, 9943, 65535, 65535, 1956, 17354, 65535, + 18635, 65535, 18903, 4833, 1730, 1772, 1779, 1812, 1814, 1816, 1821, 1844, + 1845, 1847, 11210, 11212, 1866, 1892, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1038, 1054, 1058, 1062, 1067, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1720, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 11314, + 14598, 65535, 65535, 5034, 5047, 65535, 5049, 5051, 5055, 5056, 5059, 5060, + 5063, 5064, 5067, 5068, 5071, 5072, 5075, 5076, 5079, 5080, 5083, 5084, + 65535, 65535, 65535, 65535, 5124, 5125, 5128, 5129, 5126, 5127, 5052, 5037, + 5038, 5039, 65535, 5041, 5042, 5043, 5044, 65535, 5085, 5086, 5087, 5088, + 5089, 5090, 5130, 5131, 5132, 5148, 5149, 5150, 5151, 5152, 65535, 5183, + 5193, 5194, 5195, 65535, 65535, 65535, 65535, 65535, 5033, 11257, 5099, + 5184, 5189, 5100, 11256, 5053, 5054, 5101, 5133, 5025, 5134, 5028, 5180, + 5258, 5259, 5260, 5261, 5262, 5263, 5264, 5265, 5266, 5267, 5031, 5030, + 5139, 5141, 5140, 5032, 5190, 5290, 5291, 5292, 5293, 5294, 5295, 5296, + 5297, 5298, 5299, 5300, 5301, 5302, 5303, 5304, 5305, 5306, 5307, 5308, + 5309, 5310, 5311, 5312, 5313, 5314, 5315, 10963, 5181, 10964, 65535, 5122, + 65535, 5316, 5317, 5318, 5319, 5320, 5321, 5322, 5323, 5324, 5325, 5326, + 5327, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336, 5337, 5338, + 5339, 5340, 5341, 5057, 5045, 5058, 5153, 65535, 5187, 5188, 11254, 5121, + 11255, 5185, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 18996, 65535, + 65535, 65535, 4288, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2879, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2880, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3148, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2141, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1669, 1722, 65535, 65535, 11207, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4007, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1113, + 1110, 11205, 1107, 65535, 65535, 65535, 1106, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 5015, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1104, 65535, 1118, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19386, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1874, + 65535, 65535, 65535, 65535, 1488, 65535, 2719, 65535, 65535, 65535, 65535, + 65535, 19318, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3108, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4821, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19259, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2730, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3677, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1878, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3116, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2460, 2728, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3101, + 65535, 65535, 65535, 65535, 19342, 65535, 19017, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4008, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3417, 2726, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19049, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2722, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2037, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1422, 65535, + 65535, 65535, 2794, 4142, 19032, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19029, 2714, 19031, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4009, 65535, 65535, 65535, 65535, 65535, 65535, 3497, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19510, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19488, 65535, 2720, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3572, 65535, 65535, 65535, 65535, 65535, 65535, + 4799, 65535, 65535, 65535, 65535, 65535, 65535, 2828, 2723, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19034, 65535, + 65535, 65535, 65535, 65535, 2713, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19043, 65535, 65535, 65535, 65535, 65535, 65535, 4679, 65535, 65535, + 2763, 2762, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2761, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4013, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1494, 65535, 3507, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 18997, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19051, + 65535, 65535, 65535, 65535, 65535, 65535, 19264, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19056, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19670, 65535, 65535, 65535, + 65535, 65535, 65535, 4163, 65535, 65535, 65535, 65535, 65535, 1362, 65535, + 65535, 65535, 65535, 4017, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 18999, 2759, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3011, 65535, 65535, 65535, 65535, 65535, 4165, 65535, + 65535, 65535, 4018, 65535, 65535, 65535, 3680, 3520, 65535, 65535, 65535, + 65535, 65535, 2510, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19370, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4019, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2766, 65535, 65535, 1485, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4192, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3156, 65535, 65535, 65535, 65535, + 65535, 65535, 2769, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3679, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3146, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19503, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19093, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4650, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1336, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4277, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2374, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1761, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1012, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3549, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4023, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4024, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2182, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19132, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1884, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2703, + 1562, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4025, 65535, 65535, 65535, 65535, 65535, 65535, 2796, 65535, 65535, + 65535, 65535, 4028, 65535, 65535, 65535, 65535, 65535, 65535, 19097, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3521, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4030, 65535, 65535, 65535, 19047, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1443, 65535, 3109, 65535, + 65535, 2775, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1544, + 65535, 65535, 65535, 65535, 65535, 19653, 4031, 65535, 65535, 65535, 65535, + 65535, 4547, 1416, 1481, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4032, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4033, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19137, 4188, 65535, 65535, 65535, 4034, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4036, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4548, 65535, 65535, 65535, 65535, 65535, 4456, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4038, 65535, 65535, 3522, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3799, + 65535, 65535, 65535, 19302, 4809, 1438, 1613, 65535, 65535, 65535, 65535, + 65535, 65535, 4039, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4040, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3518, 65535, 65535, 65535, 65535, 65535, 1417, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4720, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2418, 19534, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1449, 1557, 1563, 4514, 65535, + 65535, 3099, 19153, 19223, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4041, 65535, + 4723, 65535, 65535, 19145, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1436, 65535, 1573, 1574, 65535, 65535, 65535, 65535, 65535, 65535, 1497, + 65535, 65535, 65535, 65535, 65535, 1507, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4573, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4042, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4043, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4047, 65535, 65535, 65535, + 65535, 1517, 4623, 65535, 65535, 2704, 4048, 1607, 1617, 1632, 65535, + 65535, 65535, 65535, 2201, 65535, 65535, 65535, 65535, 65535, 65535, 2779, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1559, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4488, + 65535, 65535, 65535, 65535, 65535, 4052, 65535, 19435, 4551, 1608, 1618, + 1623, 1543, 1636, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1552, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1442, 65535, 1578, 65535, + 65535, 65535, 65535, 4535, 65535, 65535, 65535, 65535, 4553, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1554, 1561, 4607, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4682, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4049, 2040, 65535, 65535, 65535, 65535, 19151, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4318, 4608, 1606, + 1609, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3465, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3316, 65535, 65535, 65535, 65535, 65535, + 65535, 4051, 1580, 65535, 1556, 1530, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4940, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1496, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1444, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1553, 65535, 65535, 4050, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1569, 65535, 65535, 65535, 65535, 65535, 65535, 1437, 1635, + 1639, 65535, 65535, 65535, 65535, 65535, 4054, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2702, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4513, 4614, 4622, 4626, 65535, 65535, 65535, + 65535, 65535, 65535, 2357, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1627, 1628, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4057, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4056, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1475, 65535, 65535, + 65535, 65535, 65535, 4557, 4058, 1473, 1619, 65535, 65535, 4060, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4061, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4062, 65535, 65535, 65535, 65535, 65535, 65535, + 1504, 65535, 65535, 65535, 65535, 65535, 65535, 19168, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4064, 1564, 4588, 65535, + 65535, 65535, 65535, 65535, 1579, 1521, 1616, 65535, 65535, 65535, 65535, + 65535, 1547, 65535, 65535, 65535, 4065, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2777, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1439, 1629, 1630, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4066, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4067, 65535, 1565, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1257, 65535, 65535, 1620, 65535, 65535, 65535, 65535, 65535, + 65535, 1558, 1640, 65535, 65535, 65535, 65535, 65535, 65535, 4629, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4603, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19205, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19185, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2443, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2668, 4701, 65535, 65535, + 65535, 65535, 65535, 65535, 3593, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4070, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5007, 65535, 65535, + 65535, 3357, 2831, 3657, 19019, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4072, + 65535, 65535, 65535, 19322, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4071, 19749, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19396, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3597, 65535, 65535, + 65535, 3555, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4344, + 2669, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4373, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2667, 65535, 65535, + 65535, 65535, 3468, 65535, 65535, 19194, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3498, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1823, 65535, 65535, 3588, 65535, 19196, 1622, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2174, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19570, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2670, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3360, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2186, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4074, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2266, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19113, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4340, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19114, 65535, 65535, 65535, 65535, 65535, 4075, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19217, 65535, 65535, 2140, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19220, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19250, 65535, 4020, 65535, + 65535, 65535, 65535, 65535, 2664, 19746, 3527, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2519, 65535, 19233, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2334, 65535, 65535, 65535, 65535, 65535, 65535, 3095, + 19658, 19105, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2808, 2657, + 2926, 65535, 2852, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19150, 65535, 65535, 2810, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19099, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3618, + 2864, 3632, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3429, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4713, 4782, 3103, 2809, 19388, 19307, 65535, 2192, 2660, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2862, 65535, 65535, 65535, 65535, 3130, 4323, 19229, 3625, 2202, + 3452, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4076, 65535, 65535, 65535, 4077, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3495, 3254, 3622, 19226, 65535, 65535, 3671, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2648, 65535, 65535, 65535, 65535, 65535, + 4473, 4495, 65535, 2655, 2120, 3525, 19228, 19397, 65535, 65535, 65535, + 4326, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19232, 19423, 2931, + 65535, 65535, 4080, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2658, 1644, 4888, 65535, 65535, 65535, 65535, 3192, + 65535, 65535, 65535, 65535, 3232, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3529, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2176, 65535, 65535, 2819, + 3546, 2556, 3055, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19346, 65535, 65535, 65535, 4496, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3537, 2755, 2653, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19693, 3486, 2850, 3194, + 2272, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2650, 3536, 65535, 2661, + 65535, 65535, 65535, 65535, 3464, 19163, 3196, 2916, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2628, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2847, 2848, 3628, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2348, 19248, 2970, 65535, 65535, 2465, 65535, 65535, + 65535, 65535, 65535, 65535, 4243, 65535, 65535, 65535, 65535, 65535, 2690, + 65535, 65535, 65535, 65535, 2861, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2579, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5006, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19511, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4081, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2843, 65535, 65535, 65535, 1750, 65535, + 65535, 19053, 65535, 65535, 65535, 65535, 19695, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2842, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19009, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2818, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4082, 65535, 65535, 65535, 65535, 65535, 65535, 19262, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4083, 65535, 65535, 65535, 65535, + 65535, 19700, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 975, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19269, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1666, 3985, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4084, 65535, 65535, 65535, 65535, 65535, 4085, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4610, 65535, 65535, 19273, 65535, 65535, + 65535, 65535, 65535, 65535, 4086, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4936, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1001, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 988, 65535, 4227, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1784, 65535, 65535, + 65535, 2856, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1361, 65535, 65535, 65535, 65535, + 65535, 65535, 4729, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2943, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19281, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19735, + 65535, 65535, 65535, 65535, 65535, 65535, 1870, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19282, 65535, 65535, 65535, 65535, + 65535, 19440, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2407, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19286, 65535, 65535, 65535, 4167, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4087, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4089, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4726, 65535, + 65535, 65535, 65535, 65535, 4090, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19338, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3682, 65535, 65535, 4394, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1111, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4093, 65535, 65535, 65535, 19292, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1768, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4152, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1528, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19048, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19493, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2576, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19293, 65535, 65535, 65535, + 65535, 65535, 65535, 4310, 65535, 65535, 65535, 65535, 65535, 65535, 1483, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1886, 65535, 4179, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1540, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4096, 65535, 65535, 65535, 65535, + 3250, 65535, 65535, 65535, 2386, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3594, 65535, 65535, 19325, + 65535, 65535, 65535, 65535, 65535, 65535, 4097, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4098, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4653, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19327, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19519, 65535, 65535, 65535, 65535, 65535, 19537, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4460, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1053, 65535, 65535, 65535, 65535, 1055, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1056, 65535, 65535, 1057, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19021, 65535, 65535, 65535, 65535, 65535, + 19027, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4892, 65535, 65535, + 65535, 65535, 19050, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19246, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4303, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2874, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2875, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2881, + 19766, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2871, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19340, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2441, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1567, 65535, 19155, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4596, 3112, + 2169, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1788, 65535, 2158, 65535, 65535, 65535, 65535, 65535, 65535, 4252, + 65535, 65535, 65535, 3362, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4099, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1510, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3369, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1855, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19351, 1615, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19507, 65535, 65535, 65535, 65535, 65535, 1548, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19374, 2870, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4100, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19673, 65535, + 65535, 65535, 19381, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19446, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4321, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1549, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4101, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4103, 65535, 65535, 65535, 3370, 65535, + 65535, 65535, 65535, 19380, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4104, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1503, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1518, 65535, 65535, 65535, 65535, 65535, 4105, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1363, 65535, 4107, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4109, 65535, + 65535, 65535, 2893, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4111, + 65535, 65535, 65535, 4568, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2891, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1472, + 65535, 65535, 65535, 1572, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 3470, 2279, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1429, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4114, 65535, 65535, 65535, 65535, + 1575, 65535, 65535, 65535, 1576, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4552, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4116, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2885, 65535, 65535, 65535, 65535, 65535, + 2905, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1445, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1531, 65535, 65535, 65535, 65535, + 4117, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1454, 65535, 65535, 65535, 1420, 65535, 65535, 1519, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2886, + 4119, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4120, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1463, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1471, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2903, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1491, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4122, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4618, 65535, 65535, 19135, 1625, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4121, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1595, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19390, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19400, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4123, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2896, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1539, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4570, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2229, 65535, 65535, 65535, 65535, 4124, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4125, 65535, 65535, 65535, 65535, 65535, 65535, 3592, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4126, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19639, 65535, 65535, 65535, 65535, 65535, 65535, 19564, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4127, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2551, + 19417, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2910, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2485, 65535, 65535, 65535, 65535, 2486, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4697, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2930, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1660, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2204, + 65535, 65535, 65535, 65535, 2935, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19432, 19433, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2920, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19443, 3430, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1011, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19429, 19430, 19536, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2934, 65535, + 65535, 65535, 65535, 65535, 3283, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4374, 65535, 19441, 3060, 19052, 2932, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1854, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1013, 65535, 65535, 65535, 2381, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1747, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2919, 19171, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2913, 19742, 2911, 65535, 65535, 65535, 65535, + 2945, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2915, 2946, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3676, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2466, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4128, 65535, 65535, 65535, + 65535, 19045, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4219, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4129, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19465, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1570, 4926, 65535, 65535, 65535, 1790, 3603, 65535, + 65535, 65535, 2954, 65535, 19427, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3165, 2894, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19468, 65535, 65535, 2857, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3598, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4293, 65535, 65535, 65535, 65535, 65535, + 65535, 2191, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1864, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2205, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4134, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2751, + 65535, 65535, 65535, 2651, 65535, 65535, 3409, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1060, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19474, 2213, 3149, 65535, + 65535, 65535, 4135, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19025, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 959, 65535, 65535, 4139, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19479, 65535, 65535, + 65535, 3410, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19492, 65535, 65535, 65535, 65535, + 65535, 3014, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5014, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1043, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1002, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2672, 65535, 65535, 65535, 65535, 65535, 65535, 3606, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4515, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3600, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2682, 65535, 65535, 65535, 65535, + 19495, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4140, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4668, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19073, 65535, 4342, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2693, 65535, 65535, 65535, + 65535, 65535, 65535, 2143, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3065, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2953, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2951, 65535, 65535, 65535, 65535, 65535, 19453, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2964, 3602, 3406, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2950, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1522, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4146, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19509, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2844, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3675, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1860, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19514, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1793, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19057, 2978, 2415, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2237, 65535, 4481, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5002, 19011, 19531, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4605, 4803, 4658, 4169, 4510, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3541, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2184, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3199, 65535, 65535, 65535, 65535, + 65535, 65535, 4665, 3473, 3363, 2290, 3102, 2379, 19525, 19527, 65535, + 65535, 65535, 65535, 65535, 2161, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2193, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 976, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4149, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4672, 3568, 2444, 19558, 19568, 2677, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2752, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4491, 2756, + 2737, 2209, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4150, 65535, 65535, 65535, 65535, 65535, 2753, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2041, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4671, 3013, 3642, 3091, 2679, 19516, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3022, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2022, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4200, 65535, 65535, 65535, 65535, 65535, 65535, + 977, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2991, 19092, + 4388, 19560, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2318, 65535, 65535, 65535, 65535, 19587, 65535, 65535, + 19373, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2977, 65535, + 65535, 65535, 65535, 19000, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19134, 19094, 3567, 3291, 4247, 19586, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4985, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19585, + 19164, 4159, 2994, 19571, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2115, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19548, 65535, 65535, 65535, 65535, + 65535, 2695, 19402, 2788, 65535, 65535, 65535, 19583, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2792, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2694, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1869, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3385, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2696, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4155, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19588, 19592, 65535, 65535, 65535, 19581, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1733, 65535, + 65535, 65535, 65535, 65535, 65535, 19584, 19590, 19591, 65535, 65535, + 65535, 65535, 2511, 65535, 65535, 19688, 65535, 1009, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1645, 65535, 65535, + 4357, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4598, 19528, + 19187, 65535, 65535, 65535, 65535, 65535, 65535, 3447, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3439, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19457, 65535, + 65535, 65535, 65535, 19657, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3629, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3312, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2558, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3656, 65535, 65535, + 3647, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3002, 19606, 19210, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3228, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3640, 65535, + 2820, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3637, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 958, + 65535, 19616, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2936, 3645, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4157, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3469, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4158, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3001, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4160, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2624, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3590, 19197, 2591, 19613, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2774, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4161, 65535, 65535, 65535, 65535, 65535, 19449, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3654, 65535, 65535, 65535, 3471, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3660, + 3281, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4698, 65535, 65535, + 65535, 65535, 65535, 2646, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4170, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19166, 2711, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19618, 3644, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2645, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2965, 3458, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2639, 65535, 65535, 19301, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3652, 65535, 65535, 65535, 65535, 1447, + 65535, 65535, 4171, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1797, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4260, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2096, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1493, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4643, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2958, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2890, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4173, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3064, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2887, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4591, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3008, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4175, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3007, 4620, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4183, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19645, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2093, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1686, 65535, 65535, 65535, 65535, + 65535, 65535, 3067, 19520, 3705, 3050, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4184, 65535, 65535, 65535, 3279, 19530, 19291, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19529, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3501, 3016, 65535, + 4805, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3257, 65535, 65535, 65535, 19015, 4263, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4750, 4215, 19419, 3431, 19006, 3517, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3153, 4703, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19634, 2620, 3503, 65535, 65535, 65535, 65535, 1836, 65535, 65535, + 65535, 19547, 65535, 65535, 19357, 65535, 65535, 65535, 65535, 65535, 4383, + 2912, 2358, 3479, 3100, 19663, 3044, 19358, 65535, 65535, 65535, 65535, + 2675, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19042, 65535, 65535, 2190, 65535, 19239, + 65535, 3043, 2776, 3534, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19662, 3359, 3478, 4137, 2621, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3049, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4314, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1643, 65535, 65535, 65535, 3412, 19392, 65535, + 65535, 65535, 2902, 65535, 3499, 65535, 65535, 65535, 65535, 65535, 65535, + 2989, 3289, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4245, + 3167, 2623, 3129, 65535, 19664, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2736, 65535, 65535, 65535, 19750, 1800, 65535, 4185, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19450, 19620, 19413, 19659, 2666, 19668, 19619, 19412, 2526, 4325, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3493, 65535, 65535, + 65535, 3280, 65535, 65535, 4162, 65535, 65535, 65535, 65535, 3015, 65535, + 65535, 65535, 3047, 3664, 3528, 2625, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3670, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2178, 3496, 3327, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3591, 65535, 65535, 65535, 65535, 65535, 4861, + 3290, 19689, 2330, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19687, + 65535, 65535, 65535, 65535, 65535, 65535, 4462, 3494, 2179, 3074, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3010, 4387, 19066, 4201, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19026, 3319, 3488, 65535, 65535, 65535, 65535, + 65535, 65535, 3071, 4882, 2787, 65535, 65535, 65535, 4187, 65535, 65535, + 65535, 65535, 65535, 65535, 3072, 65535, 65535, 4427, 65535, 65535, 65535, + 65535, 65535, 65535, 2464, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3020, 65535, 65535, 4722, 65535, + 65535, 65535, 65535, 65535, 65535, 2473, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1911, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4645, + 65535, 65535, 65535, 65535, 65535, 65535, 19199, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3244, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4492, 3604, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2352, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3034, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3035, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19710, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1424, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1434, 1611, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1535, 65535, + 65535, 65535, 65535, 1624, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4190, 65535, 1453, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5017, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3736, + 65535, 65535, 65535, 65535, 65535, 19708, 65535, 65535, 65535, 4191, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3450, 65535, 65535, 4235, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4661, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2172, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4612, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4194, + 65535, 65535, 65535, 65535, 65535, 1480, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19733, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1418, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4550, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19734, 1637, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1737, 65535, 65535, 65535, 65535, 65535, 1551, 65535, 65535, + 19437, 3058, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19740, + 3057, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19337, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4198, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1460, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1641, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2072, 65535, + 65535, 4501, 65535, 19444, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4199, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2928, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2654, 2324, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4203, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2494, 65535, 4204, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1903, + 65535, 65535, 65535, 65535, 65535, 65535, 5005, 65535, 65535, 65535, 3763, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4208, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2927, + 2678, 3424, 4210, 65535, 65535, 65535, 4212, 65535, 65535, 2325, 4213, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3077, + 65535, 65535, 2923, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2925, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2412, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3513, 65535, 65535, 65535, 65535, 65535, 2417, 65535, 65535, + 65535, 65535, 19757, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19631, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4482, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2717, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3210, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1805, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3085, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3698, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2512, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19403, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1650, 65535, 65535, 65535, 65535, 19122, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4214, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3300, 2045, 4254, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19771, 65535, 65535, 65535, 65535, 65535, 4216, + 65535, 65535, 65535, 65535, 2948, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3344, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1005, 65535, 65535, 2051, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4221, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2817, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4483, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2055, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19263, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 974, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4649, 65535, + 65535, 65535, 65535, 65535, 65535, 3114, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4224, 3113, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3157, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1659, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4225, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3125, 2077, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3119, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2231, 65535, 65535, 65535, 4118, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2068, 65535, 65535, 65535, 65535, 4226, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4802, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4499, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2085, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2249, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1804, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2251, 2090, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2073, 65535, 2083, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1739, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3158, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1051, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1036, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3160, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1527, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 4485, 3143, 2825, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3127, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3126, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5003, 4508, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4946, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2662, 65535, 65535, 65535, 65535, 65535, + 3017, 4148, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1003, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2116, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4628, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3407, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19765, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1495, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3477, 1468, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4231, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2124, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4912, 2125, 3476, 3140, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 5012, 3075, 65535, 65535, 65535, 4234, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19593, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4486, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3139, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 1691, 5023, 65535, 65535, 65535, 65535, 2135, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4717, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1694, 5020, 65535, 65535, + 65535, 65535, 2138, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3306, + 65535, 65535, 65535, 65535, 65535, 65535, 19721, 65535, 65535, 3152, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4237, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2461, 4271, 3151, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4238, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4287, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4242, + 65535, 65535, 65535, 4246, 2147, 65535, 65535, 65535, 2061, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2171, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4248, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1600, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3170, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3168, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4250, 65535, 65535, 1697, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2160, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4478, + 65535, 2700, 65535, 65535, 65535, 4251, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1476, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2162, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4261, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1477, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3474, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4269, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4667, 3180, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4964, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1545, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 5016, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4272, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4270, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19324, 65535, 4580, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4594, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4274, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19726, 65535, 65535, 19725, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4278, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4280, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1698, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2549, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4372, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1433, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4283, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4285, 19654, 65535, 65535, 65535, 65535, 65535, + 4290, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3182, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3185, 2183, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2211, 65535, 65535, 65535, 65535, + 2189, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19087, 65535, + 1842, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 972, 65535, 65535, 65535, 65535, 19274, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1582, 19521, 4205, 19144, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4291, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3145, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3397, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2240, 2212, 65535, 65535, 65535, 65535, + 65535, 4295, 65535, 65535, 65535, 65535, 65535, 19018, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3584, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4240, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2697, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3449, 1875, 65535, 65535, 65535, 65535, 1897, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19192, 2078, 3620, 19224, 3613, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4297, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3607, 2459, 65535, 65535, 65535, 65535, 4266, 65535, 65535, + 3467, 65535, 65535, 2154, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3173, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4721, 4793, 2938, 19540, 3611, 2518, 3650, 19023, 19225, + 65535, 65535, 65535, 65535, 65535, 65535, 3612, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1840, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19466, 19541, 2603, 2210, 3400, 2219, + 19230, 3187, 65535, 65535, 65535, 65535, 65535, 65535, 4300, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 5009, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3030, 19542, 65535, 65535, 65535, 65535, 3402, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3405, 65535, 65535, 65535, 65535, 4889, + 65535, 4366, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3395, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2228, 2242, 2106, 19235, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 19330, 65535, 65535, 65535, 19549, 65535, 65535, + 65535, 65535, 2241, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3401, 65535, 65535, 65535, 1049, 65535, 65535, + 961, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2255, 65535, 65535, 65535, 65535, 65535, 65535, 4600, + 4966, 19367, 2043, 2224, 2451, 2108, 2388, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2684, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2877, 19551, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19731, + 65535, 19245, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1843, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3614, 3396, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1346, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4304, 65535, 65535, 65535, 65535, 65535, 65535, 2680, 3621, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2264, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 5010, + 4706, 4351, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2267, 65535, 65535, 65535, 65535, 962, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 19339, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3616, 65535, 65535, 2361, + 1838, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19777, 3172, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4718, 2676, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2508, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4305, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3189, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 947, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4307, 65535, 65535, 65535, 65535, 4308, 65535, 65535, + 65535, 65535, 65535, 4311, 65535, 65535, 65535, 65535, 65535, 65535, 4666, + 65535, 65535, 65535, 4601, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4313, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 960, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2274, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1900, 65535, 65535, 3201, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4317, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3538, 65535, 4958, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1538, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4625, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2289, 65535, 65535, + 65535, 2291, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2867, 4151, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 11213, 65535, 65535, 65535, 65535, 19761, + 65535, 65535, 65535, 65535, 65535, 4209, 65535, 65535, 65535, 65535, 65535, + 65535, 1571, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4480, 5004, 4147, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1633, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2300, 65535, 65535, 65535, 65535, 65535, 1268, 3643, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3084, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1594, 65535, 65535, 65535, + 65535, 65535, 3213, 3212, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4336, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4337, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2942, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4470, 65535, 65535, 65535, 65535, 1702, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1462, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2309, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3883, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2501, 65535, 65535, 65535, 65535, 65535, 1478, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4347, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4353, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4354, 65535, 65535, 65535, 19256, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4477, 65535, 65535, 65535, 65535, 19359, 65535, + 65535, 65535, 65535, 65535, 2315, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4133, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19024, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2310, 2391, 65535, 65535, 65535, 65535, 65535, + 3695, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3337, 65535, 65535, 65535, + 65535, 4355, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3702, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2320, 19773, 2317, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3141, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1046, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 986, + 65535, 65535, 65535, 65535, 3599, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4232, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 968, 65535, 65535, 65535, 65535, 950, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 952, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4597, 65535, 65535, 65535, 2342, 2338, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4599, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1413, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2339, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2344, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2345, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3236, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3653, + 65535, 3563, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4684, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4613, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2356, 65535, 65535, 65535, 65535, 65535, 65535, 4360, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2984, + 65535, 65535, 65535, 65535, 4371, 4474, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4375, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4378, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4391, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1604, 1427, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4343, 1451, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4392, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4393, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4395, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1432, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4370, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4396, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4397, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2360, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1621, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3558, 65535, 4398, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1446, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1646, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1525, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1634, 65535, + 65535, 65535, 65535, 4540, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4399, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4364, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4400, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2145, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2369, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2122, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4857, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4401, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2370, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4403, 65535, 65535, 65535, 1360, 65535, 65535, + 65535, 65535, 65535, 65535, 4322, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19310, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2385, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2390, 2378, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2393, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4176, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19442, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2546, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2394, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2261, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2262, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4404, 19110, 65535, 65535, 65535, 65535, 65535, 65535, 1899, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2384, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2442, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2398, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1755, 65535, 65535, 65535, + 2396, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19648, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19646, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1010, 65535, 65535, 65535, + 65535, 65535, 2406, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4223, 4381, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4407, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19744, 65535, + 65535, 65535, 19745, 65535, 65535, 65535, 2638, 1887, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2630, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3303, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2858, 65535, 19016, 4352, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4410, 65535, 65535, 65535, 19154, 65535, 65535, 65535, 2012, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2985, 65535, 2377, 65535, + 65535, 3648, 65535, 1771, 19007, 65535, 65535, 4412, 4414, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3217, 3480, 2835, 3461, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 5013, 65535, 65535, 65535, 65535, 65535, + 65535, 3510, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2307, 65535, 65535, 65535, 19343, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1741, 65535, 65535, 65535, + 19333, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2634, 3330, 2807, 2855, 2165, 3453, 19483, + 3264, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3689, 4867, 65535, 65535, 65535, 65535, 65535, 65535, + 3545, 3515, 3601, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4156, 19117, 2765, 65535, 65535, 65535, 3533, + 65535, 65535, 65535, 65535, 65535, 2414, 65535, 65535, 65535, 65535, 2982, + 3042, 65535, 3509, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19089, 19471, 2455, 2421, + 2425, 3054, 65535, 2426, 65535, 65535, 65535, 65535, 1764, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3266, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2416, + 65535, 65535, 65535, 65535, 65535, 65535, 2706, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19556, 2924, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19764, 4469, 4996, + 65535, 3305, 65535, 65535, 65535, 65535, 65535, 65535, 4415, 65535, 65535, + 65535, 65535, 65535, 1484, 65535, 4181, 65535, 3326, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3485, 3328, 3343, 19183, 65535, 65535, + 65535, 65535, 65535, 4475, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 19690, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4476, 65535, 65535, 3216, 19376, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 983, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4931, 65535, 65535, 3318, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4416, 65535, 65535, 2827, 65535, 3215, 2627, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3512, 19622, + 2048, 2981, 2422, 2429, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3214, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2431, 65535, 65535, 65535, 19692, 65535, 65535, 65535, 65535, 65535, 4418, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3583, 3268, 65535, + 65535, 65535, 65535, 65535, 3021, 65535, 65535, 3304, 65535, 65535, 65535, + 65535, 2598, 65535, 65535, 65535, 65535, 4377, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2430, 65535, 3269, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1585, + 65535, 65535, 1542, 65535, 65535, 65535, 65535, 1583, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3276, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 1584, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1822, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1709, + 65535, 65535, 65535, 65535, 65535, 65535, 2631, 65535, 65535, 4933, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3287, + 3286, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4791, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 19702, 65535, 65535, 65535, + 65535, 65535, 19675, 2727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19699, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3285, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4420, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1890, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2876, 65535, 65535, 2611, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3299, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2462, 3296, 2537, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4276, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3560, 2463, 65535, 65535, 65535, + 65535, 65535, 65535, 4421, 19458, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19780, + 65535, 65535, 4423, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4424, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2888, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3685, 65535, 65535, + 4426, 65535, 19578, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 19500, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4348, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2478, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2481, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2500, 65535, 65535, 3690, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2497, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2917, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 3225, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4716, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2052, 3321, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1425, 65535, 4431, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4662, 65535, 4433, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4434, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 3323, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4432, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1457, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1532, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4435, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1461, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1715, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2528, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 4334, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4436, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2895, 65535, 65535, + 65535, 65535, 65535, 65535, 3349, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1882, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 5008, 65535, 2529, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3392, 65535, 65535, 65535, + 65535, 65535, 997, 65535, 1763, 3351, 4437, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 19377, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4438, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2683, 65535, 65535, 65535, 65535, + 65535, 4439, 65535, 65535, 65535, 65535, 65535, 4177, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4440, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 1450, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2541, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4441, 65535, 65535, 65535, + 65535, 65535, 65535, 2538, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1729, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 4333, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2554, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4442, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4621, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 4503, 65535, 65535, 4443, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1345, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 4704, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 3379, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2562, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4655, 65535, 65535, 65535, 991, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1591, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4445, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4446, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4659, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2564, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4663, 65535, 65535, 65535, 65535, 65535, 2383, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2153, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2582, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 2567, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 3390, 65535, 65535, 65535, 65535, 65535, 3391, 65535, 65535, + 65535, 65535, 2277, 65535, 65535, 65535, 65535, 65535, 3382, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1748, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2568, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 1348, 2572, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19209, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 2565, 2577, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 2566, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 3389, 1893, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2569, + 65535, 65535, 65535, 65535, 65535, 3381, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 2578, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 2580, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4449, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2373, 65535, + 65535, 4872, 65535, 2583, 65535, 3683, 65535, 65535, 65535, 1758, 65535, + 65535, 1642, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4362, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 4451, 65535, 964, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1256, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4691, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 2898, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 3039, + 65535, 65535, 65535, 65535, 4454, 65535, 65535, 65535, 65535, 65535, 1516, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 1581, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4848, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 1541, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4606, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1064, 65535, + 65535, 65535, 65535, 65535, 3663, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4027, 65535, 65535, 65535, 65535, 4874, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 1667, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 19319, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 19366, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 4257, 65535, 65535, 65535, 65535, 65535, + 65535, 2196, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 2268, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 3198, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 2340, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, +]; + +static BACKWARD_TABLE_UPPER: &'static [u16] = &[ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 0, + 160, 176, 192, 0, 0, 0, 0, 0, 208, 224, 0, 0, 0, 0, 0, 0, 0, 240, 256, 272, + 288, 0, 0, 0, 304, 320, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 336, 352, 368, + 384, 0, 0, 0, 400, 416, 432, 448, 464, 480, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 496, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 528, 544, 560, 0, 0, 0, 0, 0, 0, 576, 0, 0, 0, + 0, 0, 592, 608, 624, 0, 0, 0, 640, 656, 0, 672, 0, 688, 0, 0, 704, 0, 0, + 720, 736, 752, 0, 768, 784, 0, 0, 800, 816, 832, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 848, 0, 0, 864, 880, 896, 0, 0, 0, 912, 928, 0, 0, + 0, 0, 0, 0, 0, 0, 944, 960, 976, 992, 0, 1008, 1024, 1040, 1056, 1072, + 1088, 1104, 1120, 0, 1136, 0, 1152, 0, 0, 0, 1168, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1200, 1216, 1232, 1248, 1264, 1280, 1296, 0, 0, 0, 0, 1312, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1328, 1344, 1360, 0, 1376, 1392, 1408, 1424, 1440, + 1456, 1472, 1488, 1504, 1520, 1536, 1552, 1568, 1584, 1600, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1616, 0, 0, 0, 0, 0, 0, 1632, 0, 0, 0, 0, 0, 0, 1648, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1664, 1680, 1696, 0, 1712, 1728, 0, 0, 0, 0, + 0, 1744, 1760, 0, 1776, 1792, 0, 1808, 1824, 1840, 1856, 1872, 1888, 1904, + 1920, 0, 0, 1936, 0, 1952, 1968, 1984, 2000, 2016, 2032, 2048, 2064, 2080, + 0, 2096, 2112, 2128, 2144, 2160, 2176, 2192, 2208, 2224, 2240, 2256, 2272, + 2288, 2304, 2320, 2336, 2352, 2368, 2384, 2400, 2416, 2432, 0, 2448, 0, 0, + 2464, 2480, 2496, 0, 2512, 0, 2528, 2544, 2560, 2576, 2592, 0, 0, 2608, + 2624, 0, 0, 2640, 0, 2656, 2672, 0, 2688, 2704, 2720, 2736, 2752, 2768, 0, + 2784, 2800, 2816, 2832, 2848, 2864, 0, 2880, 2896, 2912, 2928, 2944, 2960, + 2976, 2992, 3008, 3024, 0, 0, 3040, 3056, 3072, 0, 3088, 3104, 3120, 3136, + 3152, 3168, 3184, 3200, 3216, 3232, 3248, 3264, 3280, 3296, 3312, 3328, + 3344, 3360, 3376, 3392, 3408, 0, 0, 0, 3424, 0, 0, 3440, 0, 0, 0, 3456, + 3472, 3488, 0, 0, 3504, 0, 3520, 3536, 3552, 3568, 3584, 3600, 3616, 3632, + 3648, 3664, 3680, 3696, 3712, 3728, 0, 0, 0, 3744, 3760, 0, 3776, 0, 0, + 3792, 3808, 3824, 3840, 3856, 3872, 3888, 0, 0, 0, 0, 3904, 3920, 3936, 0, + 3952, 0, 0, 3968, 3984, 4000, 4016, 4032, 4048, 0, 4064, 4080, 4096, 4112, + 4128, 0, 0, 4144, 4160, 4176, 4192, 0, 4208, 4224, 0, 0, 4240, 0, 0, 4256, + 4272, 4288, 4304, 0, 4320, 4336, 4352, 4368, 4384, 0, 4400, 4416, 0, 4432, + 0, 4448, 4464, 4480, 4496, 4512, 4528, 0, 0, 0, 4544, 4560, 0, 4576, 0, 0, + 0, 4592, 0, 0, 4608, 0, 4624, 4640, 4656, 4672, 4688, 4704, 4720, 4736, 0, + 0, 0, 0, 4752, 4768, 4784, 4800, 4816, 4832, 4848, 4864, 4880, 4896, 4912, + 4928, 4944, 4960, 4976, 4992, 5008, 5024, 0, 5040, 5056, 0, 5072, 5088, 0, + 5104, 5120, 0, 0, 0, 5136, 0, 5152, 5168, 0, 5184, 5200, 5216, 5232, 0, + 5248, 0, 5264, 0, 5280, 5296, 0, 0, 5312, 0, 5328, 5344, 0, 0, 5360, 5376, + 5392, 5408, 0, 0, 5424, 0, 5440, 0, 5456, 0, 5472, 5488, 0, 0, 5504, 5520, + 5536, 5552, 5568, 5584, 5600, 5616, 5632, 5648, 5664, 5680, 0, 5696, 0, 0, + 5712, 5728, 0, 5744, 5760, 5776, 5792, 0, 0, 0, 0, 0, 5808, 5824, 5840, 0, + 5856, 5872, 5888, 0, 5904, 5920, 5936, 0, 0, 5952, 5968, 5984, 6000, 0, + 6016, 6032, 0, 0, 0, 6048, 0, 0, 6064, 6080, 6096, 6112, 6128, 6144, 0, + 6160, 6176, 6192, 0, 6208, 0, 6224, 6240, 0, 6256, 0, 0, 0, 6272, 6288, + 6304, 0, 0, 0, 0, 0, 0, 6320, 6336, 6352, 6368, 6384, 6400, 6416, 6432, + 6448, 6464, 6480, 6496, 6512, 6528, 6544, 6560, 6576, 6592, 6608, 6624, + 6640, 6656, 6672, 6688, 6704, 6720, 6736, 6752, 6768, 6784, 6800, 6816, + 6832, 6848, 6864, 6880, 6896, 6912, 6928, 6944, 6960, 6976, 6992, 7008, + 7024, 7040, 7056, 7072, 7088, 7104, 7120, 7136, 7152, 7168, 7184, 7200, + 7216, 7232, 7248, 7264, 7280, 7296, 7312, 7328, 7344, 7360, 7376, 7392, + 7408, 7424, 7440, 7456, 7472, 7488, 7504, 7520, 7536, 7552, 7568, 7584, + 7600, 7616, 7632, 7648, 7664, 7680, 7696, 7712, 7728, 7744, 7760, 7776, + 7792, 7808, 7824, 7840, 7856, 7872, 7888, 7904, 7920, 7936, 7952, 7968, + 7984, 8000, 8016, 8032, 8048, 8064, 8080, 8096, 8112, 8128, 8144, 8160, + 8176, 8192, 8208, 8224, 8240, 8256, 8272, 8288, 8304, 8320, 8336, 8352, + 8368, 8384, 8400, 8416, 8432, 8448, 8464, 8480, 8496, 8512, 8528, 8544, + 8560, 8576, 8592, 8608, 8624, 8640, 8656, 8672, 8688, 8704, 8720, 8736, + 8752, 8768, 8784, 8800, 8816, 8832, 8848, 8864, 8880, 8896, 8912, 8928, + 8944, 8960, 8976, 8992, 9008, 9024, 9040, 9056, 9072, 9088, 9104, 9120, + 9136, 9152, 9168, 9184, 9200, 9216, 9232, 9248, 9264, 9280, 9296, 9312, + 9328, 9344, 9360, 9376, 9392, 9408, 9424, 9440, 9456, 9472, 9488, 9504, + 9520, 9536, 9552, 9568, 9584, 9600, 9616, 9632, 9648, 9664, 9680, 9696, + 9712, 9728, 9744, 9760, 9776, 9792, 9808, 9824, 9840, 9856, 9872, 9888, + 9904, 9920, 9936, 9952, 9968, 9984, 10000, 10016, 10032, 10048, 10064, + 10080, 10096, 10112, 10128, 10144, 10160, 10176, 10192, 10208, 10224, + 10240, 10256, 10272, 10288, 10304, 10320, 10336, 10352, 10368, 10384, + 10400, 10416, 10432, 10448, 10464, 10480, 10496, 10512, 10528, 10544, + 10560, 10576, 10592, 10608, 10624, 10640, 10656, 10672, 10688, 10704, + 10720, 10736, 10752, 10768, 10784, 10800, 10816, 10832, 10848, 10864, + 10880, 10896, 10912, 10928, 10944, 10960, 10976, 10992, 11008, 11024, + 11040, 11056, 11072, 11088, 11104, 11120, 11136, 11152, 11168, 11184, + 11200, 11216, 11232, 11248, 11264, 11280, 11296, 11312, 11328, 11344, + 11360, 11376, 11392, 11408, 11424, 11440, 11456, 11472, 11488, 11504, + 11520, 11536, 11552, 11568, 11584, 11600, 11616, 11632, 11648, 11664, + 11680, 11696, 11712, 11728, 11744, 11760, 11776, 11792, 11808, 11824, + 11840, 11856, 11872, 11888, 11904, 11920, 11936, 11952, 11968, 11984, + 12000, 12016, 12032, 12048, 12064, 12080, 12096, 12112, 12128, 12144, + 12160, 12176, 12192, 12208, 12224, 12240, 12256, 12272, 12288, 12304, + 12320, 12336, 12352, 12368, 12384, 12400, 12416, 12432, 12448, 12464, + 12480, 12496, 12512, 12528, 12544, 12560, 12576, 12592, 12608, 12624, + 12640, 12656, 12672, 12688, 12704, 12720, 12736, 12752, 12768, 12784, + 12800, 12816, 12832, 12848, 12864, 12880, 12896, 12912, 12928, 12944, + 12960, 12976, 12992, 13008, 13024, 13040, 13056, 13072, 13088, 13104, + 13120, 13136, 13152, 13168, 13184, 13200, 13216, 13232, 13248, 13264, + 13280, 13296, 13312, 13328, 13344, 13360, 13376, 13392, 13408, 13424, + 13440, 13456, 13472, 13488, 13504, 13520, 13536, 13552, 13568, 13584, + 13600, 13616, 13632, 13648, 13664, 13680, 13696, 13712, 13728, 13744, + 13760, 13776, 13792, 13808, 13824, 13840, 13856, 13872, 13888, 13904, + 13920, 13936, 13952, 13968, 13984, 14000, 14016, 14032, 14048, 14064, + 14080, 14096, 14112, 14128, 14144, 14160, 14176, 14192, 14208, 14224, + 14240, 14256, 14272, 14288, 14304, 14320, 14336, 14352, 14368, 14384, + 14400, 14416, 14432, 14448, 14464, 14480, 14496, 14512, 14528, 14544, + 14560, 14576, 14592, 14608, 14624, 14640, 14656, 14672, 14688, 14704, + 14720, 14736, 14752, 14768, 14784, 14800, 14816, 14832, 14848, 14864, + 14880, 14896, 14912, 14928, 14944, 14960, 14976, 14992, 15008, 15024, + 15040, 15056, 15072, 15088, 15104, 15120, 15136, 15152, 15168, 15184, + 15200, 15216, 15232, 15248, 15264, 15280, 15296, 15312, 15328, 15344, + 15360, 15376, 15392, 15408, 15424, 15440, 15456, 15472, 15488, 15504, + 15520, 15536, 15552, 15568, 15584, 15600, 15616, 15632, 15648, 15664, + 15680, 15696, 15712, 15728, 15744, 15760, 15776, 15792, 15808, 15824, + 15840, 15856, 15872, 15888, 15904, 15920, 15936, 15952, 15968, 15984, + 16000, 16016, 16032, 16048, 16064, 16080, 16096, 16112, 16128, 16144, + 16160, 16176, 16192, 16208, 16224, 16240, 16256, 16272, 16288, 16304, + 16320, 16336, 16352, 16368, 16384, 16400, 16416, 16432, 16448, 16464, + 16480, 16496, 16512, 16528, 16544, 16560, 16576, 16592, 16608, 16624, + 16640, 16656, 16672, 16688, 16704, 16720, 16736, 16752, 16768, 16784, + 16800, 16816, 16832, 16848, 16864, 16880, 16896, 16912, 16928, 16944, + 16960, 16976, 16992, 17008, 17024, 17040, 17056, 17072, 17088, 17104, + 17120, 17136, 17152, 17168, 17184, 17200, 17216, 17232, 17248, 17264, + 17280, 17296, 17312, 17328, 17344, 17360, 17376, 17392, 17408, 17424, + 17440, 17456, 17472, 17488, 17504, 17520, 17536, 17552, 17568, 17584, + 17600, 17616, 17632, 17648, 17664, 17680, 17696, 17712, 17728, 17744, + 17760, 17776, 17792, 17808, 17824, 17840, 17856, 17872, 17888, 17904, + 17920, 17936, 17952, 17968, 17984, 18000, 18016, 18032, 18048, 18064, + 18080, 18096, 18112, 18128, 18144, 18160, 18176, 18192, 18208, 18224, + 18240, 18256, 18272, 18288, 18304, 18320, 18336, 18352, 18368, 18384, + 18400, 18416, 18432, 18448, 18464, 18480, 18496, 18512, 18528, 18544, + 18560, 18576, 18592, 18608, 18624, 18640, 18656, 18672, 18688, 18704, + 18720, 18736, 18752, 18768, 18784, 18800, 18816, 0, 0, 18832, 0, 0, 18848, + 18864, 18880, 18896, 18912, 18928, 18944, 18960, 18976, 18992, 19008, + 19024, 19040, 19056, 19072, 19088, 19104, 19120, 19136, 19152, 19168, + 19184, 19200, 19216, 19232, 19248, 19264, 19280, 19296, 19312, 19328, + 19344, 19360, 19376, 19392, 19408, 19424, 19440, 19456, 19472, 19488, + 19504, 19520, 19536, 19552, 19568, 19584, 19600, 19616, 19632, 19648, + 19664, 19680, 19696, 19712, 19728, 19744, 19760, 19776, 19792, 19808, + 19824, 19840, 19856, 19872, 19888, 19904, 19920, 19936, 19952, 19968, + 19984, 20000, 20016, 20032, 20048, 20064, 20080, 20096, 20112, 20128, + 20144, 20160, 20176, 20192, 20208, 20224, 20240, 20256, 20272, 20288, + 20304, 20320, 20336, 20352, 20368, 20384, 20400, 20416, 20432, 20448, + 20464, 20480, 20496, 20512, 20528, 20544, 20560, 20576, 20592, 20608, + 20624, 20640, 20656, 20672, 20688, 20704, 20720, 20736, 20752, 20768, + 20784, 20800, 20816, 20832, 20848, 20864, 20880, 20896, 20912, 20928, + 20944, 20960, 20976, 20992, 21008, 21024, 21040, 21056, 21072, 21088, + 21104, 21120, 21136, 21152, 21168, 21184, 21200, 21216, 21232, 21248, + 21264, 21280, 21296, 21312, 21328, 21344, 21360, 21376, 21392, 21408, + 21424, 21440, 21456, 21472, 21488, 21504, 21520, 21536, 21552, 21568, + 21584, 21600, 21616, 21632, 21648, 21664, 21680, 21696, 21712, 21728, + 21744, 21760, 21776, 21792, 21808, 21824, 21840, 21856, 21872, 21888, + 21904, 21920, 21936, 21952, 21968, 21984, 22000, 22016, 22032, 22048, 0, 0, + 22064, 0, 0, 0, 0, 22080, 22096, 22112, 22128, 22144, 22160, 22176, 22192, + 22208, 22224, 22240, 22256, 22272, 22288, 22304, 0, 0, 0, 0, 22320, 22336, + 22352, 22368, 22384, 22400, 22416, 22432, 22448, 22464, 22480, 22496, + 22512, 22528, 22544, 22560, 22576, 22592, 22608, 22624, 22640, 22656, + 22672, 22688, 22704, 22720, 22736, 22752, 22768, 22784, 22800, 22816, + 22832, 0, 0, 22848, 22864, 22880, 22896, 22912, 22928, 22944, 22960, 22976, + 22992, 23008, 23024, 23040, 23056, 23072, 23088, 23104, 23120, 23136, + 23152, 23168, 23184, 23200, 23216, 23232, 23248, 23264, 23280, 23296, + 23312, 23328, 23344, 23360, 23376, 23392, 23408, 23424, 23440, 23456, + 23472, 23488, 23504, 23520, 23536, 23552, 23568, 23584, 23600, 23616, + 23632, 23648, 23664, 23680, 23696, 23712, 23728, 23744, 23760, 23776, + 23792, 23808, 23824, 23840, 23856, 23872, 23888, 23904, 23920, 23936, + 23952, 23968, 23984, 24000, 24016, 24032, 24048, 24064, 24080, 24096, + 24112, 24128, 24144, 0, 24160, 24176, 0, 24192, 0, 0, 24208, 0, 24224, 0, + 0, 24240, 24256, 24272, 24288, 24304, 24320, 24336, 24352, 24368, 0, 24384, + 24400, 24416, 24432, 24448, 24464, 24480, 24496, 24512, 24528, 24544, + 24560, 24576, 24592, 24608, 24624, 24640, 24656, 24672, 24688, 24704, + 24720, 24736, 24752, 24768, 24784, 24800, 24816, 24832, 24848, 24864, + 24880, 24896, 24912, 24928, 24944, 24960, 24976, 24992, 0, 0, 25008, 25024, + 25040, 25056, 25072, 25088, 25104, 25120, 25136, 25152, 25168, 25184, + 25200, 0, 0, 25216, 25232, 25248, 25264, 25280, 25296, 25312, 25328, 25344, + 25360, 25376, 25392, 25408, 25424, 0, 25440, 0, 25456, 25472, 25488, 25504, + 25520, 25536, 25552, 25568, 25584, 25600, 25616, 25632, 25648, 25664, + 25680, 25696, 25712, 25728, 25744, 25760, 25776, 25792, 25808, 25824, + 25840, 25856, 25872, 25888, 25904, 25920, 0, 0, 0, 0, 0, 0, 25936, 25952, + 25968, 25984, 26000, 26016, 26032, 26048, 26064, 26080, 26096, 26112, + 26128, 26144, 26160, 26176, 26192, 26208, 26224, 26240, 0, 0, 0, 0, 0, + 26256, 26272, 26288, 26304, 26320, 26336, 26352, 26368, 26384, 26400, + 26416, 26432, 26448, 26464, 26480, 26496, 26512, 26528, 26544, 26560, + 26576, 26592, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 26608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 26624, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26640, 26656, 26672, + 26688, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26704, 26720, 26736, 26752, 26768, 26784, + 0, 0, 0, 0, 0, 0, 0, 0, 26800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 26816, 26832, 26848, 0, 26864, 0, 26880, 26896, + 0, 0, 26912, 26928, 26944, 0, 26960, 26976, 0, 0, 0, 0, 0, 0, 0, 0, 26992, + 0, 27008, 27024, 0, 27040, 27056, 27072, 0, 27088, 0, 27104, 0, 27120, 0, + 27136, 27152, 27168, 27184, 0, 27200, 0, 27216, 0, 27232, 0, 27248, 0, 0, + 27264, 27280, 0, 27296, 27312, 27328, 0, 0, 27344, 0, 27360, 0, 0, 0, 0, + 27376, 0, 27392, 27408, 27424, 0, 0, 27440, 0, 27456, 0, 0, 0, 0, 27472, 0, + 0, 0, 27488, 0, 27504, 27520, 27536, 27552, 27568, 0, 0, 27584, 0, 27600, + 0, 27616, 0, 27632, 0, 0, 0, 0, 0, 0, 0, 0, 27648, 0, 0, 27664, 0, 0, 0, + 27680, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27696, 0, 0, 0, 0, 27712, 0, 0, 0, 0, + 0, 27728, 0, 0, 0, 27744, 27760, 0, 0, 27776, 0, 27792, 0, 0, 0, 0, 0, 0, + 27808, 0, 0, 27824, 0, 0, 0, 27840, 27856, 0, 27872, 0, 0, 27888, 27904, 0, + 0, 0, 27920, 0, 0, 0, 0, 0, 0, 0, 27936, 27952, 27968, 27984, 28000, 0, + 28016, 28032, 28048, 0, 28064, 28080, 28096, 28112, 28128, 28144, 28160, + 28176, 0, 28192, 28208, 28224, 28240, 28256, 0, 28272, 28288, 28304, 28320, + 0, 28336, 28352, 0, 28368, 28384, 28400, 28416, 0, 0, 0, 28432, 28448, 0, + 0, 28464, 0, 28480, 28496, 28512, 28528, 28544, 28560, 0, 28576, 0, 28592, + 0, 28608, 28624, 28640, 28656, 0, 28672, 0, 28688, 28704, 28720, 28736, 0, + 28752, 28768, 0, 0, 28784, 0, 0, 28800, 28816, 28832, 28848, 28864, 28880, + 0, 28896, 28912, 28928, 28944, 28960, 0, 0, 28976, 28992, 29008, 0, 0, 0, + 29024, 0, 0, 0, 0, 29040, 0, 0, 0, 0, 0, 29056, 29072, 0, 0, 29088, 0, 0, + 29104, 29120, 0, 0, 29136, 29152, 29168, 0, 0, 29184, 0, 0, 0, 29200, + 29216, 29232, 0, 0, 29248, 0, 29264, 29280, 0, 29296, 29312, 29328, 0, + 29344, 0, 0, 29360, 29376, 0, 29392, 0, 0, 29408, 29424, 0, 0, 0, 0, 0, 0, + 0, 29440, 29456, 29472, 0, 0, 0, 0, 0, 0, 29488, 29504, 0, 29520, 0, 0, + 29536, 0, 0, 29552, 0, 29568, 29584, 29600, 29616, 29632, 29648, 29664, + 29680, 29696, 0, 29712, 29728, 29744, 0, 0, 29760, 29776, 29792, 29808, + 29824, 29840, 0, 0, 29856, 29872, 29888, 29904, 29920, 29936, 29952, 29968, + 29984, 30000, 0, 30016, 0, 30032, 30048, 30064, 30080, 30096, 30112, 30128, + 30144, 30160, 30176, 30192, 0, 0, 0, 30208, 0, 30224, 0, 0, 30240, 30256, + 30272, 0, 30288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30304, 0, 0, 0, 0, + 0, 0, 0, 30320, 0, 0, 0, 0, 0, 30336, 0, 0, 0, 0, 30352, 0, 0, 30368, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 30384, 30400, 0, 0, 0, 30416, 0, 30432, 30448, 30464, + 30480, 30496, 0, 30512, 30528, 30544, 0, 0, 0, 0, 30560, 0, 30576, 0, + 30592, 30608, 0, 0, 30624, 30640, 0, 0, 0, 0, 30656, 0, 0, 30672, 30688, 0, + 0, 0, 30704, 0, 0, 0, 0, 0, 30720, 0, 0, 30736, 0, 30752, 0, 0, 30768, 0, + 0, 30784, 0, 0, 30800, 0, 0, 30816, 0, 30832, 0, 0, 30848, 0, 30864, 0, 0, + 0, 30880, 0, 0, 0, 0, 0, 0, 30896, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30912, 0, + 0, 0, 0, 0, 0, 0, 0, 30928, 0, 30944, 0, 30960, 0, 0, 0, 0, 0, 0, 30976, + 30992, 31008, 31024, 0, 31040, 31056, 0, 31072, 0, 0, 31088, 0, 31104, 0, + 31120, 0, 0, 31136, 0, 31152, 31168, 0, 0, 0, 0, 0, 31184, 31200, 0, 0, 0, + 31216, 31232, 0, 31248, 0, 0, 0, 0, 0, 31264, 0, 31280, 31296, 0, 0, 0, 0, + 31312, 31328, 31344, 0, 31360, 31376, 0, 0, 0, 31392, 0, 0, 0, 0, 31408, + 31424, 31440, 0, 0, 31456, 0, 31472, 0, 0, 31488, 0, 0, 31504, 31520, + 31536, 0, 31552, 0, 31568, 31584, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 31600, 0, 0, 0, 0, 0, 31616, 31632, 31648, 0, 31664, 0, 31680, 31696, + 31712, 0, 31728, 0, 0, 0, 0, 0, 31744, 0, 0, 0, 0, 0, 31760, 31776, 31792, + 31808, 31824, 0, 31840, 31856, 31872, 31888, 31904, 0, 0, 0, 31920, 31936, + 0, 0, 31952, 0, 31968, 0, 31984, 32000, 32016, 32032, 0, 0, 32048, 0, + 32064, 0, 0, 32080, 32096, 0, 0, 32112, 32128, 0, 0, 32144, 0, 0, 32160, 0, + 0, 0, 0, 0, 0, 0, 0, 32176, 0, 0, 0, 0, 32192, 0, 32208, 0, 0, 0, 0, 32224, + 32240, 0, 32256, 32272, 32288, 0, 0, 32304, 0, 32320, 0, 0, 32336, 0, 0, + 32352, 0, 0, 0, 32368, 32384, 0, 32400, 32416, 32432, 0, 32448, 32464, + 32480, 0, 32496, 32512, 0, 32528, 32544, 0, 32560, 0, 32576, 0, 0, 32592, + 32608, 0, 32624, 32640, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32656, 32672, 32688, + 32704, 32720, 32736, 0, 0, 32752, 0, 32768, 32784, 32800, 0, 0, 0, 0, 0, 0, + 32816, 0, 0, 32832, 0, 32848, 0, 32864, 32880, 0, 0, 32896, 0, 32912, + 32928, 0, 0, 32944, 32960, 32976, 0, 32992, 33008, 33024, 0, 33040, 33056, + 33072, 33088, 33104, 0, 33120, 33136, 0, 33152, 33168, 33184, 33200, 0, 0, + 33216, 0, 33232, 0, 33248, 33264, 33280, 33296, 0, 0, 0, 0, 0, 33312, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33328, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33344, 0, 0, 33360, 33376, 33392, 0, + 33408, 0, 0, 0, 33424, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 33440, 0, 0, 33456, 0, 33472, 33488, 0, 0, 33504, 0, 0, 0, 0, 33520, 33536, + 0, 33552, 33568, 0, 0, 33584, 0, 0, 33600, 33616, 33632, 33648, 33664, + 33680, 0, 0, 0, 0, 33696, 0, 0, 33712, 0, 33728, 0, 33744, 0, 0, 0, 33760, + 33776, 0, 33792, 33808, 33824, 0, 0, 33840, 33856, 0, 33872, 33888, 0, + 33904, 0, 33920, 0, 33936, 0, 0, 33952, 33968, 0, 0, 33984, 0, 34000, 0, + 34016, 34032, 0, 34048, 34064, 34080, 34096, 34112, 0, 0, 34128, 34144, + 34160, 0, 34176, 34192, 0, 34208, 0, 0, 34224, 34240, 0, 34256, 34272, + 34288, 34304, 34320, 34336, 0, 34352, 34368, 34384, 34400, 0, 34416, 34432, + 0, 34448, 0, 34464, 34480, 0, 34496, 34512, 0, 34528, 34544, 34560, 0, 0, + 34576, 0, 34592, 0, 34608, 34624, 0, 0, 34640, 34656, 34672, 0, 0, 34688, + 0, 34704, 0, 0, 0, 0, 34720, 0, 0, 0, 0, 34736, 0, 0, 0, 0, 34752, 34768, + 0, 0, 0, 34784, 34800, 0, 34816, 0, 0, 0, 34832, 0, 0, 34848, 0, 34864, 0, + 0, 0, 0, 0, 34880, 0, 0, 0, 0, 0, 34896, 0, 0, 34912, 34928, 0, 0, 0, 0, 0, + 34944, 0, 0, 0, 0, 0, 34960, 34976, 34992, 35008, 35024, 35040, 35056, 0, + 35072, 35088, 35104, 35120, 35136, 35152, 35168, 35184, 35200, 35216, + 35232, 35248, 35264, 35280, 35296, 35312, 35328, 35344, 35360, 35376, + 35392, 35408, 35424, 35440, 35456, 0, 35472, 0, 0, 0, 0, 0, 35488, 0, 0, 0, + 0, 0, 0, 0, 0, 35504, 35520, 0, 0, 0, 0, 0, 0, 0, 0, 35536, 0, 0, 35552, + 35568, 0, 0, 35584, 35600, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35616, 0, 0, 35632, + 0, 0, 0, 0, 35648, 0, 35664, 0, 0, 0, 0, 35680, 0, 0, 0, 0, 0, 35696, 0, 0, + 0, 0, 35712, 0, 0, 35728, 35744, 35760, 35776, 35792, 0, 0, 0, 0, 0, 35808, + 0, 0, 35824, 0, 0, 0, 35840, 0, 0, 0, 0, 0, 0, 0, 0, 35856, 0, 35872, 0, 0, + 35888, 0, 0, 0, 0, 35904, 0, 35920, 0, 0, 0, 35936, 0, 0, 35952, 0, 0, 0, + 35968, 0, 0, 35984, 36000, 0, 0, 36016, 36032, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 36048, 36064, 36080, 36096, 0, 36112, 0, 0, 36128, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 36144, 0, 36160, 36176, 0, 36192, 0, 0, 36208, 0, + 36224, 36240, 0, 36256, 0, 0, 36272, 0, 36288, 0, 0, 36304, 36320, 0, 0, 0, + 0, 36336, 36352, 36368, 36384, 36400, 36416, 0, 0, 0, 36432, 0, 0, 0, 0, + 36448, 36464, 36480, 0, 0, 0, 0, 0, 0, 36496, 0, 36512, 0, 0, 0, 0, 36528, + 36544, 36560, 0, 36576, 0, 0, 0, 36592, 36608, 0, 0, 0, 0, 36624, 0, 36640, + 0, 0, 0, 0, 0, 0, 0, 0, 36656, 0, 0, 0, 36672, 36688, 0, 0, 0, 36704, 0, 0, + 0, 0, 0, 0, 0, 0, 36720, 36736, 0, 0, 36752, 36768, 0, 36784, 0, 36800, 0, + 36816, 0, 36832, 0, 36848, 0, 0, 36864, 36880, 0, 36896, 0, 0, 36912, 0, 0, + 36928, 36944, 36960, 0, 0, 0, 0, 36976, 0, 36992, 0, 0, 0, 0, 37008, 0, 0, + 0, 37024, 0, 0, 0, 37040, 0, 37056, 37072, 0, 37088, 0, 0, 0, 37104, 0, 0, + 37120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37136, 0, 0, 0, 37152, 0, 37168, 0, + 37184, 0, 37200, 37216, 37232, 0, 0, 0, 0, 0, 37248, 0, 37264, 0, 0, 37280, + 0, 0, 0, 0, 37296, 37312, 0, 37328, 0, 0, 0, 0, 0, 0, 0, 37344, 37360, 0, + 0, 0, 0, 0, 0, 37376, 0, 0, 0, 0, 0, 37392, 37408, 37424, 0, 0, 0, 0, 0, + 37440, 0, 0, 0, 37456, 37472, 37488, 0, 0, 37504, 0, 37520, 0, 37536, + 37552, 0, 0, 0, 0, 0, 0, 0, 37568, 0, 0, 0, 0, 0, 37584, 0, 0, 37600, + 37616, 0, 0, 0, 0, 0, 37632, 37648, 0, 0, 0, 0, 0, 0, 0, 37664, 37680, 0, + 37696, 37712, 37728, 0, 37744, 0, 0, 37760, 0, 0, 0, 0, 37776, 0, 37792, + 37808, 0, 0, 0, 0, 37824, 0, 0, 37840, 37856, 37872, 0, 37888, 37904, 0, 0, + 37920, 0, 0, 0, 37936, 37952, 37968, 37984, 0, 38000, 0, 0, 0, 0, 38016, + 38032, 0, 0, 0, 38048, 0, 0, 38064, 38080, 38096, 38112, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 38128, 38144, 38160, 0, 0, 38176, 0, 38192, 38208, 38224, 0, + 38240, 38256, 0, 0, 38272, 0, 0, 38288, 0, 38304, 0, 0, 38320, 38336, 0, + 38352, 38368, 38384, 38400, 0, 0, 0, 0, 38416, 0, 0, 38432, 0, 38448, 0, 0, + 38464, 0, 0, 38480, 38496, 38512, 38528, 38544, 0, 0, 38560, 0, 38576, + 38592, 38608, 38624, 0, 0, 0, 38640, 0, 0, 0, 0, 38656, 0, 0, 0, 0, 38672, + 0, 38688, 38704, 38720, 0, 38736, 0, 0, 38752, 0, 0, 0, 38768, 38784, 0, 0, + 38800, 0, 38816, 0, 38832, 38848, 0, 38864, 38880, 0, 38896, 0, 0, 0, + 38912, 38928, 0, 0, 0, 0, 38944, 0, 0, 0, 0, 38960, 0, 0, 0, 0, 38976, 0, + 38992, 0, 0, 39008, 0, 0, 39024, 0, 0, 0, 0, 0, 0, 39040, 0, 0, 0, 39056, + 0, 0, 0, 0, 0, 39072, 0, 0, 39088, 0, 0, 39104, 0, 0, 39120, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 39136, 0, 0, 39152, 0, 0, 0, 39168, 39184, + 39200, 0, 0, 39216, 0, 39232, 0, 0, 0, 39248, 0, 0, 0, 0, 0, 0, 39264, 0, + 0, 39280, 39296, 39312, 0, 0, 39328, 0, 0, 0, 39344, 0, 0, 0, 0, 0, 0, 0, + 0, 39360, 0, 39376, 0, 39392, 0, 39408, 39424, 0, 0, 0, 0, 0, 39440, 0, 0, + 0, 39456, 39472, 0, 0, 39488, 0, 0, 39504, 0, 39520, 39536, 0, 0, 39552, 0, + 39568, 0, 39584, 39600, 0, 0, 39616, 0, 0, 0, 39632, 39648, 39664, 0, + 39680, 39696, 0, 39712, 0, 0, 0, 0, 0, 0, 0, 39728, 39744, 0, 39760, 0, 0, + 0, 0, 39776, 0, 0, 0, 0, 39792, 39808, 0, 0, 0, 0, 0, 39824, 0, 0, 39840, + 39856, 39872, 39888, 39904, 0, 39920, 0, 39936, 0, 0, 0, 0, 0, 0, 39952, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39968, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39984, 40000, 40016, 40032, 0, 40048, 0, 0, 0, 40064, 40080, 0, 40096, + 0, 0, 40112, 40128, 0, 0, 40144, 0, 40160, 40176, 40192, 0, 40208, 0, + 40224, 40240, 0, 0, 0, 0, 40256, 40272, 0, 0, 0, 40288, 0, 40304, 0, 40320, + 0, 0, 40336, 0, 40352, 0, 40368, 40384, 40400, 40416, 0, 0, 40432, 40448, + 40464, 0, 0, 0, 0, 0, 0, 0, 0, 40480, 0, 0, 0, 0, 40496, 40512, 40528, 0, + 0, 0, 0, 0, 0, 0, 40544, 0, 0, 40560, 0, 0, 40576, 0, 0, 0, 0, 0, 0, 0, + 40592, 40608, 40624, 0, 40640, 40656, 0, 0, 0, 0, 0, 0, 40672, 40688, 0, + 40704, 40720, 0, 40736, 40752, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 40768, 0, 40784, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40800, 0, 0, 40816, + 40832, 40848, 40864, 40880, 40896, 0, 40912, 40928, 40944, 40960, 40976, + 40992, 41008, 41024, 41040, 41056, 41072, 41088, 0, 0, 41104, 41120, 0, 0, + 41136, 41152, 41168, 41184, 41200, 41216, 41232, 0, 41248, 41264, 41280, 0, + 41296, 41312, 0, 41328, 41344, 41360, 41376, 41392, 41408, 41424, 41440, + 41456, 0, 0, 0, 0, 0, 0, 0, 0, 41472, 41488, 0, 0, 0, 0, 0, 41504, 0, 0, 0, + 0, 0, 41520, 0, 41536, 0, 0, 0, 0, 41552, 0, 0, 41568, 0, 0, 41584, 0, 0, + 41600, 41616, 41632, 0, 41648, 41664, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 41680, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41696, 41712, 41728, 41744, 41760, + 41776, 0, 41792, 0, 41808, 41824, 0, 41840, 41856, 41872, 0, 41888, 0, + 41904, 41920, 0, 0, 41936, 41952, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41968, 41984, + 42000, 42016, 0, 0, 0, 0, 0, 0, 0, 0, 42032, 42048, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 42064, 0, 42080, 0, 42096, 42112, 42128, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 42144, 42160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42176, + 0, 0, 0, 42192, 0, 0, 0, 42208, 0, 0, 0, 0, 42224, 0, 0, 42240, 42256, + 42272, 42288, 0, 42304, 0, 42320, 42336, 42352, 0, 0, 42368, 0, 0, 42384, + 0, 0, 0, 0, 0, 42400, 0, 42416, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42432, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42448, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42464, + 0, 0, 42480, 0, 0, 0, 0, 0, 0, 0, 0, 42496, 0, 42512, 0, 42528, 0, 42544, + 0, 0, 0, 0, 0, 42560, 42576, 0, 42592, 0, 0, 0, 42608, 0, 0, 0, 42624, + 42640, 42656, 0, 0, 42672, 0, 0, 42688, 42704, 0, 0, 0, 0, 0, 0, 0, 42720, + 0, 42736, 0, 0, 0, 42752, 0, 0, 0, 0, 0, 0, 42768, 0, 0, 42784, 0, 0, + 42800, 42816, 42832, 0, 42848, 42864, 0, 42880, 0, 0, 0, 42896, 42912, + 42928, 0, 42944, 0, 42960, 0, 0, 42976, 42992, 0, 0, 0, 0, 0, 43008, 0, + 43024, 0, 43040, 0, 43056, 0, 0, 0, 0, 0, 43072, 0, 0, 0, 0, 43088, 0, 0, + 0, 0, 0, 0, 0, 0, 43104, 0, 43120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 43136, 0, 0, 0, 43152, 0, 0, 43168, 43184, + 43200, 0, 0, 0, 0, 43216, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 43232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43248, 43264, 43280, 0, 0, 43296, 0, + 43312, 43328, 0, 43344, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43360, 0, + 43376, 0, 43392, +]; + +/// Returns the index pointer for code point `code` in this index. +#[inline] +pub fn backward(code: u32) -> u16 { + let offset = (code >> 4) as usize; + let offset = if offset < 12190 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; + BACKWARD_TABLE_LOWER[offset + ((code & 15) as usize)] +} + +#[cfg(test)] +multi_byte_tests!( + mod = big5, + dups = [ + 1133, 1135, 1164, 1166, 2673, 3437, 4369, 4748, 4828, 4898, 4902, 4981, + 4982, 4997, 5206, 5207, 5208, 5209, 5214, 5512, 5599, 6410, 6422, 6543, + 6732, 7300, 7410, 7915, 8240, 8281, 8870, 9081, 9103, 9741, 9802, 9810, + 9840, 9909, 10024, 10696, 10825, 10950, 10957, 11332, 11345, 11458, + 11479, 12065, 12497, 12739, 13142, 14159, 14187, 14305, 14651, 14708, + 14975, 15488, 15930, 15967, 16278, 16353, 16745, 17060, 17421, 17713, + 18346, 18728, 18938, 18957, 18975, 18976, 18977, 18991, 18992, 18993, + 18994, 18995, 19028, 19035, 19088, 19096, 19112, 19162, 19240, 19299, + 19305, 19309, 19326, 19355, 19398, 19424, 19439, 19454, 19504, 19553, + 19554, 19557, 19611, 19643, 19672, 19697, 19720, 19748, + ] +); diff --git a/deps/encoding-index-tradchinese-1.20141219.5/lib.rs b/deps/encoding-index-tradchinese-1.20141219.5/lib.rs new file mode 100644 index 000000000..a5451ef39 --- /dev/null +++ b/deps/encoding-index-tradchinese-1.20141219.5/lib.rs @@ -0,0 +1,22 @@ +// This is a part of rust-encoding. +// +// Any copyright is dedicated to the Public Domain. +// https://creativecommons.org/publicdomain/zero/1.0/ + +//! Traditional Chinese index tables for +//! [rust-encoding](https://github.com/lifthrasiir/rust-encoding). + +#![cfg_attr(test, feature(test))] + +#[cfg(test)] +#[macro_use] +extern crate encoding_index_tests; + +/// Big5 and HKSCS. +/// +/// From the Encoding Standard: +/// +/// > This matches the Big5 standard +/// > in combination with the Hong Kong Supplementary Character Set and other common extensions. +pub mod big5; + diff --git a/deps/encoding_index_tests-0.1.4/Cargo.toml b/deps/encoding_index_tests-0.1.4/Cargo.toml new file mode 100644 index 000000000..b6f5dbaec --- /dev/null +++ b/deps/encoding_index_tests-0.1.4/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "encoding_index_tests" +version = "0.1.4" +authors = ["Kang Seonghoon "] + +description = "Helper macros used to test index tables for character encodings" +homepage = "https://github.com/lifthrasiir/rust-encoding" +readme = "../../../README.md" +license = "CC0-1.0" + +[lib] +name = "encoding_index_tests" +path = "index_tests.rs" diff --git a/deps/encoding_index_tests-0.1.4/index_tests.rs b/deps/encoding_index_tests-0.1.4/index_tests.rs new file mode 100644 index 000000000..aba1dcb8c --- /dev/null +++ b/deps/encoding_index_tests-0.1.4/index_tests.rs @@ -0,0 +1,210 @@ +// This is a part of rust-encoding. +// Copyright (c) 2013-2015, Kang Seonghoon. +// See README.md and LICENSE.txt for details. + +//! Macros and utilities for testing indices. + +/// Makes a common test suite for single-byte indices. +#[macro_export] +macro_rules! single_byte_tests { + ( + mod = $parentmod:ident // XXX Rust issue #20701 prevents the use of `super` + ) => ( + mod tests { + extern crate test; + use $parentmod::{forward, backward}; + + #[test] + fn test_correct_table() { + for i in 0x80..0x100 { + let i = i as u8; + let j = forward(i); + if j != 0xffff { assert_eq!(backward(j as u32), i); } + } + } + + #[bench] + fn bench_forward_sequential_128(bencher: &mut test::Bencher) { + bencher.iter(|| { + for i in 0x80..0x100 { + test::black_box(forward(i as u8)); + } + }) + } + + #[bench] + fn bench_backward_sequential_128(bencher: &mut test::Bencher) { + let mut start: u32 = 0; + bencher.iter(|| { + for i in start..(start + 0x80) { + test::black_box(backward(i)); + } + start += 0x80; + }) + } + } + ); +} + +/// Makes a common test suite for multi-byte indices. +#[macro_export] +macro_rules! multi_byte_tests { + (make shared tests and benches with dups = $dups:expr) => ( // internal macro + #[test] + fn test_correct_table() { + static DUPS: &'static [u16] = &$dups; + for i in 0..0x10000 { + let i = i as u16; + if DUPS.contains(&i) { continue; } + let j = forward(i); + if j != 0xffff { assert_eq!(backward(j), i); } + } + } + + #[bench] + fn bench_forward_sequential_128(bencher: &mut test::Bencher) { + let mut start: u32 = 0; + bencher.iter(|| { + for i in start..(start + 0x80) { + test::black_box(forward(i as u16)); + } + start += 0x80; + }) + } + + #[bench] + fn bench_backward_sequential_128(bencher: &mut test::Bencher) { + let mut start: u32 = 0; + bencher.iter(|| { + for i in start..(start + 0x80) { + test::black_box(backward(i)); + } + start += 0x80; + if start >= 0x110000 { start = 0; } + }) + } + ); + + ( + mod = $parentmod:ident, // XXX Rust issue #20701 + dups = $dups:expr + ) => ( + mod tests { + extern crate test; + use $parentmod::{forward, backward}; + + multi_byte_tests!(make shared tests and benches with dups = $dups); + } + ); + + ( + mod = $parentmod:ident, // XXX Rust issue #20701 + remap = [$remap_min:expr, $remap_max:expr], + dups = $dups:expr + ) => ( + mod tests { + extern crate test; + use $parentmod::{forward, backward, backward_remapped}; + + multi_byte_tests!(make shared tests and benches with dups = $dups); + + static REMAP_MIN: u16 = $remap_min; + static REMAP_MAX: u16 = $remap_max; + + #[test] + fn test_correct_remapping() { + for i in REMAP_MIN..(REMAP_MAX+1) { + let j = forward(i); + if j != 0xffff { + let ii = backward_remapped(j); + assert!(ii != i && ii != 0xffff); + let jj = forward(ii); + assert_eq!(j, jj); + } + } + } + + #[bench] + fn bench_backward_remapped_sequential_128(bencher: &mut test::Bencher) { + let mut start: u32 = 0; + bencher.iter(|| { + for i in start..(start + 0x80) { + test::black_box(backward_remapped(i)); + } + start += 0x80; + if start >= 0x110000 { start = 0; } + }) + } + } + ); +} + +/// Makes a common test suite for multi-byte range indices. +#[macro_export] +macro_rules! multi_byte_range_tests { + ( + mod = $parentmod:ident, + key = [$minkey:expr, $maxkey:expr], key < $keyubound:expr, + value = [$minvalue:expr, $maxvalue:expr], value < $valueubound:expr + ) => ( + mod tests { + extern crate test; + use $parentmod::{forward, backward}; + + static MIN_KEY: u32 = $minkey; + static MAX_KEY: u32 = $maxkey; + static KEY_UBOUND: u32 = $keyubound; + static MIN_VALUE: u32 = $minvalue; + static MAX_VALUE: u32 = $maxvalue; + static VALUE_UBOUND: u32 = $valueubound; + + #[test] + #[allow(unused_comparisons)] + fn test_no_failure() { + for i in (if MIN_KEY>0 {MIN_KEY-1} else {0})..(MAX_KEY+2) { + forward(i); + } + for j in (if MIN_VALUE>0 {MIN_VALUE-1} else {0})..(MAX_VALUE+2) { + backward(j); + } + } + + #[test] + fn test_correct_table() { + for i in MIN_KEY..(MAX_KEY+2) { + let j = forward(i); + if j == 0xffffffff { continue; } + let i_ = backward(j); + if i_ == 0xffffffff { continue; } + assert!(i_ == i, + "backward(forward({})) = backward({}) = {} != {}", i, j, i_, i); + } + } + + #[bench] + fn bench_forward_sequential_128(bencher: &mut test::Bencher) { + let mut start: u32 = 0; + bencher.iter(|| { + for i in start..(start + 0x80) { + test::black_box(forward(i)); + } + start += 0x80; + if start >= KEY_UBOUND { start = 0; } + }) + } + + #[bench] + fn bench_backward_sequential_128(bencher: &mut test::Bencher) { + let mut start: u32 = 0; + bencher.iter(|| { + for i in start..(start + 0x80) { + test::black_box(backward(i)); + } + start += 0x80; + if start >= VALUE_UBOUND { start = 0; } + }) + } + } + ); +} + diff --git a/deps/env_logger-0.3.1/Cargo.toml b/deps/env_logger-0.3.1/Cargo.toml new file mode 100644 index 000000000..57f46e551 --- /dev/null +++ b/deps/env_logger-0.3.1/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "env_logger" +version = "0.3.1" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang/log" +documentation = "http://doc.rust-lang.org/log/env_logger" +homepage = "https://github.com/rust-lang/log" +description = """ +An logging implementation for `log` which is configured via an environment +variable. +""" + +[dependencies.log] +version = "0.3" +path = ".." + +[dependencies] +regex = "0.1" diff --git a/deps/env_logger-0.3.1/src/lib.rs b/deps/env_logger-0.3.1/src/lib.rs new file mode 100644 index 000000000..d71262551 --- /dev/null +++ b/deps/env_logger-0.3.1/src/lib.rs @@ -0,0 +1,464 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A logger configured via an environment variable. +//! +//! ## Example +//! +//! ``` +//! #[macro_use] extern crate log; +//! extern crate env_logger; +//! +//! use log::LogLevel; +//! +//! fn main() { +//! env_logger::init().unwrap(); +//! +//! debug!("this is a debug {}", "message"); +//! error!("this is printed by default"); +//! +//! if log_enabled!(LogLevel::Info) { +//! let x = 3 * 4; // expensive computation +//! info!("the answer was: {}", x); +//! } +//! } +//! ``` +//! +//! Assumes the binary is `main`: +//! +//! ```{.bash} +//! $ RUST_LOG=error ./main +//! ERROR:main: this is printed by default +//! ``` +//! +//! ```{.bash} +//! $ RUST_LOG=info ./main +//! ERROR:main: this is printed by default +//! INFO:main: the answer was: 12 +//! ``` +//! +//! ```{.bash} +//! $ RUST_LOG=debug ./main +//! DEBUG:main: this is a debug message +//! ERROR:main: this is printed by default +//! INFO:main: the answer was: 12 +//! ``` +//! +//! You can also set the log level on a per module basis: +//! +//! ```{.bash} +//! $ RUST_LOG=main=info ./main +//! ERROR:main: this is printed by default +//! INFO:main: the answer was: 12 +//! ``` +//! +//! And enable all logging: +//! +//! ```{.bash} +//! $ RUST_LOG=main ./main +//! DEBUG:main: this is a debug message +//! ERROR:main: this is printed by default +//! INFO:main: the answer was: 12 +//! ``` +//! +//! See the documentation for the log crate for more information about its API. +//! +//! ## Enabling logging +//! +//! Log levels are controlled on a per-module basis, and by default all logging +//! is disabled except for `error!`. Logging is controlled via the `RUST_LOG` +//! environment variable. The value of this environment variable is a +//! comma-separated list of logging directives. A logging directive is of the +//! form: +//! +//! ```text +//! path::to::module=log_level +//! ``` +//! +//! The path to the module is rooted in the name of the crate it was compiled +//! for, so if your program is contained in a file `hello.rs`, for example, to +//! turn on logging for this file you would use a value of `RUST_LOG=hello`. +//! Furthermore, this path is a prefix-search, so all modules nested in the +//! specified module will also have logging enabled. +//! +//! The actual `log_level` is optional to specify. If omitted, all logging will +//! be enabled. If specified, it must be one of the strings `debug`, `error`, +//! `info`, `warn`, or `trace`. +//! +//! As the log level for a module is optional, the module to enable logging for +//! is also optional. If only a `log_level` is provided, then the global log +//! level for all modules is set to this value. +//! +//! Some examples of valid values of `RUST_LOG` are: +//! +//! * `hello` turns on all logging for the 'hello' module +//! * `info` turns on all info logging +//! * `hello=debug` turns on debug logging for 'hello' +//! * `hello,std::option` turns on hello, and std's option logging +//! * `error,hello=warn` turn on global error logging and also warn for hello +//! +//! ## Filtering results +//! +//! A RUST_LOG directive may include a regex filter. The syntax is to append `/` +//! followed by a regex. Each message is checked against the regex, and is only +//! logged if it matches. Note that the matching is done after formatting the +//! log string but before adding any logging meta-data. There is a single filter +//! for all modules. +//! +//! Some examples: +//! +//! * `hello/foo` turns on all logging for the 'hello' module where the log +//! message includes 'foo'. +//! * `info/f.o` turns on all info logging where the log message includes 'foo', +//! 'f1o', 'fao', etc. +//! * `hello=debug/foo*foo` turns on debug logging for 'hello' where the log +//! message includes 'foofoo' or 'fofoo' or 'fooooooofoo', etc. +//! * `error,hello=warn/[0-9] scopes` turn on global error logging and also +//! warn for hello. In both cases the log message must include a single digit +//! number followed by 'scopes'. + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/env_logger/")] +#![cfg_attr(test, deny(warnings))] + +extern crate regex; +extern crate log; + +use regex::Regex; +use std::io::prelude::*; +use std::io; +use std::env; + +use log::{Log, LogLevel, LogLevelFilter, LogRecord, SetLoggerError, LogMetadata}; + +struct Logger { + directives: Vec, + filter: Option, +} + +impl Logger { + fn enabled(&self, level: LogLevel, target: &str) -> bool { + // Search for the longest match, the vector is assumed to be pre-sorted. + for directive in self.directives.iter().rev() { + match directive.name { + Some(ref name) if !target.starts_with(&**name) => {}, + Some(..) | None => { + return level <= directive.level + } + } + } + false + } +} + +impl Log for Logger { + fn enabled(&self, metadata: &LogMetadata) -> bool { + self.enabled(metadata.level(), metadata.target()) + } + + fn log(&self, record: &LogRecord) { + if !Log::enabled(self, record.metadata()) { + return; + } + + if let Some(filter) = self.filter.as_ref() { + if filter.is_match(&*record.args().to_string()) { + return; + } + } + + let _ = writeln!(&mut io::stderr(), + "{}:{}: {}", + record.level(), + record.location().module_path(), + record.args()); + } +} + +struct LogDirective { + name: Option, + level: LogLevelFilter, +} + +/// Initializes the global logger with an env logger. +/// +/// This should be called early in the execution of a Rust program, and the +/// global logger may only be initialized once. Future initialization attempts +/// will return an error. +pub fn init() -> Result<(), SetLoggerError> { + log::set_logger(|max_level| { + let (mut directives, filter) = match env::var("RUST_LOG") { + Ok(spec) => parse_logging_spec(&spec), + Err(..) => (vec![LogDirective { name: None, level: LogLevelFilter::Error }], None), + }; + + // Sort the provided directives by length of their name, this allows a + // little more efficient lookup at runtime. + directives.sort_by(|a, b| { + let alen = a.name.as_ref().map(|a| a.len()).unwrap_or(0); + let blen = b.name.as_ref().map(|b| b.len()).unwrap_or(0); + alen.cmp(&blen) + }); + + let level = { + let max = directives.iter().map(|d| d.level).max(); + max.unwrap_or(LogLevelFilter::Off) + }; + max_level.set(level); + + Box::new(Logger { + directives: directives, + filter: filter, + }) + }) +} + +/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=error/foo") +/// and return a vector with log directives. +fn parse_logging_spec(spec: &str) -> (Vec, Option) { + let mut dirs = Vec::new(); + + let mut parts = spec.split('/'); + let mods = parts.next(); + let filter = parts.next(); + if parts.next().is_some() { + println!("warning: invalid logging spec '{}', \ + ignoring it (too many '/'s)", spec); + return (dirs, None); + } + mods.map(|m| { for s in m.split(',') { + if s.len() == 0 { continue } + let mut parts = s.split('='); + let (log_level, name) = match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) { + (Some(part0), None, None) => { + // if the single argument is a log-level string or number, + // treat that as a global fallback + match part0.parse() { + Ok(num) => (num, None), + Err(_) => (LogLevelFilter::max(), Some(part0)), + } + } + (Some(part0), Some(""), None) => (LogLevelFilter::max(), Some(part0)), + (Some(part0), Some(part1), None) => { + match part1.parse() { + Ok(num) => (num, Some(part0)), + _ => { + println!("warning: invalid logging spec '{}', \ + ignoring it", part1); + continue + } + } + }, + _ => { + println!("warning: invalid logging spec '{}', \ + ignoring it", s); + continue + } + }; + dirs.push(LogDirective { + name: name.map(|s| s.to_string()), + level: log_level, + }); + }}); + + let filter = filter.map_or(None, |filter| { + match Regex::new(filter) { + Ok(re) => Some(re), + Err(e) => { + println!("warning: invalid regex filter - {}", e); + None + } + } + }); + + return (dirs, filter); +} + +#[cfg(test)] +mod tests { + use log::{Log, LogLevel, LogLevelFilter}; + + use super::{Logger, LogDirective, parse_logging_spec}; + + fn make_logger(dirs: Vec) -> Logger { + Logger { + directives: dirs, + filter: None, + } + } + + #[test] + fn match_full_path() { + let logger = make_logger(vec![ + LogDirective { + name: Some("crate2".to_string()), + level: LogLevelFilter::Info + }, + LogDirective { + name: Some("crate1::mod1".to_string()), + level: LogLevelFilter::Warn + } + ]); + assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); + assert!(!logger.enabled(LogLevel::Info, "crate1::mod1")); + assert!(logger.enabled(LogLevel::Info, "crate2")); + assert!(!logger.enabled(LogLevel::Debug, "crate2")); + } + + #[test] + fn no_match() { + let logger = make_logger(vec![ + LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, + LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } + ]); + assert!(!logger.enabled(LogLevel::Warn, "crate3")); + } + + #[test] + fn match_beginning() { + let logger = make_logger(vec![ + LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, + LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } + ]); + assert!(logger.enabled(LogLevel::Info, "crate2::mod1")); + } + + #[test] + fn match_beginning_longest_match() { + let logger = make_logger(vec![ + LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, + LogDirective { name: Some("crate2::mod".to_string()), level: LogLevelFilter::Debug }, + LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } + ]); + assert!(logger.enabled(LogLevel::Debug, "crate2::mod1")); + assert!(!logger.enabled(LogLevel::Debug, "crate2")); + } + + #[test] + fn match_default() { + let logger = make_logger(vec![ + LogDirective { name: None, level: LogLevelFilter::Info }, + LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } + ]); + assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); + assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); + } + + #[test] + fn zero_level() { + let logger = make_logger(vec![ + LogDirective { name: None, level: LogLevelFilter::Info }, + LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Off } + ]); + assert!(!logger.enabled(LogLevel::Error, "crate1::mod1")); + assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); + } + + #[test] + fn parse_logging_spec_valid() { + let (dirs, filter) = parse_logging_spec("crate1::mod1=error,crate1::mod2,crate2=debug"); + assert_eq!(dirs.len(), 3); + assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::Error); + + assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); + assert_eq!(dirs[1].level, LogLevelFilter::max()); + + assert_eq!(dirs[2].name, Some("crate2".to_string())); + assert_eq!(dirs[2].level, LogLevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_logging_spec_invalid_crate() { + // test parse_logging_spec with multiple = in specification + let (dirs, filter) = parse_logging_spec("crate1::mod1=warn=info,crate2=debug"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_logging_spec_invalid_log_level() { + // test parse_logging_spec with 'noNumber' as log level + let (dirs, filter) = parse_logging_spec("crate1::mod1=noNumber,crate2=debug"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_logging_spec_string_log_level() { + // test parse_logging_spec with 'warn' as log level + let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2=warn"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::Warn); + assert!(filter.is_none()); + } + + #[test] + fn parse_logging_spec_empty_log_level() { + // test parse_logging_spec with '' as log level + let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2="); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::max()); + assert!(filter.is_none()); + } + + #[test] + fn parse_logging_spec_global() { + // test parse_logging_spec with no crate + let (dirs, filter) = parse_logging_spec("warn,crate2=debug"); + assert_eq!(dirs.len(), 2); + assert_eq!(dirs[0].name, None); + assert_eq!(dirs[0].level, LogLevelFilter::Warn); + assert_eq!(dirs[1].name, Some("crate2".to_string())); + assert_eq!(dirs[1].level, LogLevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_logging_spec_valid_filter() { + let (dirs, filter) = parse_logging_spec("crate1::mod1=error,crate1::mod2,crate2=debug/abc"); + assert_eq!(dirs.len(), 3); + assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::Error); + + assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); + assert_eq!(dirs[1].level, LogLevelFilter::max()); + + assert_eq!(dirs[2].name, Some("crate2".to_string())); + assert_eq!(dirs[2].level, LogLevelFilter::Debug); + assert!(filter.is_some() && filter.unwrap().to_string() == "abc"); + } + + #[test] + fn parse_logging_spec_invalid_crate_filter() { + let (dirs, filter) = parse_logging_spec("crate1::mod1=error=warn,crate2=debug/a.c"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::Debug); + assert!(filter.is_some() && filter.unwrap().to_string() == "a.c"); + } + + #[test] + fn parse_logging_spec_empty_with_filter() { + let (dirs, filter) = parse_logging_spec("crate1/a*c"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate1".to_string())); + assert_eq!(dirs[0].level, LogLevelFilter::max()); + assert!(filter.is_some() && filter.unwrap().to_string() == "a*c"); + } +} diff --git a/deps/filetime-0.1.4/.gitignore b/deps/filetime-0.1.4/.gitignore new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/deps/filetime-0.1.4/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/deps/filetime-0.1.4/.travis.yml b/deps/filetime-0.1.4/.travis.yml new file mode 100644 index 000000000..5fab63857 --- /dev/null +++ b/deps/filetime-0.1.4/.travis.yml @@ -0,0 +1,23 @@ +language: rust +rust: + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +notifications: + email: + on_success: never +env: + global: +env: + global: + secure: dsIj09BQvGF872zKmqzG+WwCl7gfqwsnxcm3GZlAMgyLYm4juvHOwCRhIERCN3BCxPvdlSRKhe9Rwmp1RkiKuqTK3ITUTAy29Maf2vuL1T+zcdpZE0t6JSCU1gbEwzCA2foB1jzgy7Q47EzeJusmGNwibscjYmXKlH6JCFwTobM= diff --git a/deps/filetime-0.1.4/Cargo.toml b/deps/filetime-0.1.4/Cargo.toml new file mode 100644 index 000000000..096a412f0 --- /dev/null +++ b/deps/filetime-0.1.4/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "filetime" +authors = ["Alex Crichton "] +version = "0.1.4" +license = "MIT/Apache-2.0" +readme = "README.md" +keywords = ["timestamp", "mtime"] +repository = "https://github.com/alexcrichton/filetime" +homepage = "https://github.com/alexcrichton/filetime" +documentation = "http://alexcrichton.com/filetime" +description = """ +Platform-agnostic accessors of timestamps in File metadata +""" diff --git a/deps/filetime-0.1.4/LICENSE-APACHE b/deps/filetime-0.1.4/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/filetime-0.1.4/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/filetime-0.1.4/LICENSE-MIT b/deps/filetime-0.1.4/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/filetime-0.1.4/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/filetime-0.1.4/README.md b/deps/filetime-0.1.4/README.md new file mode 100644 index 000000000..0422084e7 --- /dev/null +++ b/deps/filetime-0.1.4/README.md @@ -0,0 +1,25 @@ +# filetime + +[![Build Status](https://travis-ci.org/alexcrichton/filetime.svg?branch=master)](https://travis-ci.org/alexcrichton/filetime) +[![Build status](https://ci.appveyor.com/api/projects/status/9tatexq47i3ee13k?svg=true)](https://ci.appveyor.com/project/alexcrichton/filetime) + +[Documentation](http://alexcrichton.com/filetime/filetime/index.html) + +A helper library for inspecting the various timestamps of files in Rust. This +library takes into account cross-platform differences in terms of where the +timestamps are located, what they are called, and how to convert them into a +platform-independent representation. + +```toml +# Cargo.toml +[dependencies] +filetime = "0.1" +``` + +# License + +`filetime` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/filetime-0.1.4/appveyor.yml b/deps/filetime-0.1.4/appveyor.yml new file mode 100644 index 000000000..f74c851ad --- /dev/null +++ b/deps/filetime-0.1.4/appveyor.yml @@ -0,0 +1,11 @@ +install: + - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' + - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/filetime-0.1.4/src/lib.rs b/deps/filetime-0.1.4/src/lib.rs new file mode 100644 index 000000000..7d11dac3c --- /dev/null +++ b/deps/filetime-0.1.4/src/lib.rs @@ -0,0 +1,183 @@ +//! Timestamps for files in Rust +//! +//! This library provides platform-agnostic inspection of the various timestamps +//! present in the standard `fs::Metadata` structure. +//! +//! # Installation +//! +//! Add this to you `Cargo.toml`: +//! +//! ```toml +//! [dependencies] +//! filetime = "0.1" +//! ``` +//! +//! # Usage +//! +//! ```no_run +//! use std::fs; +//! use filetime::FileTime; +//! +//! let metadata = fs::metadata("foo.txt").unwrap(); +//! +//! let mtime = FileTime::from_last_modification_time(&metadata); +//! println!("{}", mtime); +//! +//! let atime = FileTime::from_last_access_time(&metadata); +//! assert!(mtime < atime); +//! +//! // Inspect values that can be interpreted across platforms +//! println!("{}", mtime.seconds_relative_to_1970()); +//! println!("{}", mtime.nanoseconds()); +//! +//! // Print the platform-specific value of seconds +//! println!("{}", mtime.seconds()); +//! ``` + +#[cfg(unix)] use std::os::unix::prelude::*; +#[cfg(windows)] use std::os::windows::prelude::*; + +use std::fmt; +use std::fs; + +/// A helper structure to represent a timestamp for a file. +/// +/// The actual value contined within is platform-specific and does not have the +/// same meaning across platforms, but comparisons and stringification can be +/// significant among the same platform. +#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Copy, Clone)] +pub struct FileTime { + seconds: u64, + nanos: u32, +} + +impl FileTime { + /// Creates a new timestamp representing a 0 time. + /// + /// Useful for creating the base of a cmp::max chain of times. + pub fn zero() -> FileTime { + FileTime { seconds: 0, nanos: 0 } + } + + /// Creates a new timestamp from the last modification time listed in the + /// specified metadata. + /// + /// The returned value corresponds to the `mtime` field of `stat` on Unix + /// platforms and the `ftLastWriteTime` field on Windows platforms. + pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime { + #[cfg(unix)] + fn imp(meta: &fs::Metadata) -> FileTime { + FileTime::from_os_repr(meta.mtime() as u64, meta.mtime_nsec() as u32) + } + #[cfg(windows)] + fn imp(meta: &fs::Metadata) -> FileTime { + FileTime::from_os_repr(meta.last_write_time()) + } + imp(meta) + } + + /// Creates a new timestamp from the last access time listed in the + /// specified metadata. + /// + /// The returned value corresponds to the `atime` field of `stat` on Unix + /// platforms and the `ftLastAccessTime` field on Windows platforms. + pub fn from_last_access_time(meta: &fs::Metadata) -> FileTime { + #[cfg(unix)] + fn imp(meta: &fs::Metadata) -> FileTime { + FileTime::from_os_repr(meta.atime() as u64, meta.atime_nsec() as u32) + } + #[cfg(windows)] + fn imp(meta: &fs::Metadata) -> FileTime { + FileTime::from_os_repr(meta.last_access_time()) + } + imp(meta) + } + + /// Creates a new timestamp from the creation time listed in the specified + /// metadata. + /// + /// The returned value corresponds to the `birthtime` field of `stat` on + /// Unix platforms and the `ftCreationTime` field on Windows platforms. Note + /// that not all Unix platforms have this field available and may return + /// `None` in some circumstances. + pub fn from_creation_time(meta: &fs::Metadata) -> Option { + macro_rules! birthtim { + ($(($e:expr, $i:ident)),*) => { + #[cfg(any($(target_os = $e),*))] + fn imp(meta: &fs::Metadata) -> Option { + $( + #[cfg(target_os = $e)] + use std::os::$i::fs::MetadataExt; + )* + let raw = meta.as_raw_stat(); + Some(FileTime::from_os_repr(raw.st_birthtime as u64, + raw.st_birthtime_nsec as u32)) + } + + #[cfg(all(not(windows), + $(not(target_os = $e)),*))] + fn imp(_meta: &fs::Metadata) -> Option { + None + } + } + } + + birthtim! { + ("bitrig", bitrig), + ("freebsd", freebsd), + ("ios", ios), + ("macos", macos), + ("openbsd", openbsd) + } + + #[cfg(windows)] + fn imp(meta: &fs::Metadata) -> Option { + Some(FileTime::from_os_repr(meta.last_access_time())) + } + imp(meta) + } + + #[cfg(windows)] + fn from_os_repr(time: u64) -> FileTime { + // Windows write times are in 100ns intervals, so do a little math to + // get it into the right representation. + FileTime { + seconds: time / (1_000_000_000 / 100), + nanos: ((time % (1_000_000_000 / 100)) * 100) as u32, + } + } + + #[cfg(unix)] + fn from_os_repr(seconds: u64, nanos: u32) -> FileTime { + FileTime { seconds: seconds, nanos: nanos } + } + + /// Returns the whole number of seconds represented by this timestamp. + /// + /// Note that this value's meaning is **platform specific**. On Unix + /// platform time stamps are typically relative to January 1, 1970, but on + /// Windows platforms time stamps are relative to January 1, 1601. + pub fn seconds(&self) -> u64 { self.seconds } + + /// Returns the whole number of seconds represented by this timestamp, + /// relative to the Unix epoch start of January 1, 1970. + /// + /// Note that this does not return the same value as `seconds` for Windows + /// platforms as seconds are relative to a different date there. + pub fn seconds_relative_to_1970(&self) -> u64 { + self.seconds - if cfg!(windows) {11644473600} else {0} + } + + /// Returns the nanosecond precision of this timestamp. + /// + /// The returned value is always less than one billion and represents a + /// portion of a second forward from the seconds returned by the `seconds` + /// method. + pub fn nanoseconds(&self) -> u32 { self.nanos } +} + +impl fmt::Display for FileTime { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}.{:09}s", self.seconds, self.nanos) + } +} diff --git a/deps/flate2-0.2.7/.gitignore b/deps/flate2-0.2.7/.gitignore new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/deps/flate2-0.2.7/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/deps/flate2-0.2.7/.travis.yml b/deps/flate2-0.2.7/.travis.yml new file mode 100644 index 000000000..52dad2139 --- /dev/null +++ b/deps/flate2-0.2.7/.travis.yml @@ -0,0 +1,21 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - rustdoc --test README.md -L target/debug -L target/debug/deps + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + - secure: xHKXragwOcBcqJ8mjNGQO8RZijmhCYhpKrt2Z3M0125D60Zc544GJXyhfKxJ2fNrnCjBPQ5pg/s6bassfOKsxOGnZLFoc8pqFyW2CApWzaVrF6tSwDYe83epXFKxYyYp7+f0d6NJ4yqs9DpA23gTNL5tqpQc1P4zSkg7l1pXCtI= + - secure: VYL5QxBYlf+KW94L0X/Nl2ymkOfOEIvHy6CMPXT8aPFIA8EI3SYqTM+PPWsMrZ7hsPESzvfPmTheeT28rjTyE4d9sORxJJUMrLYyZUB7DmVZYnc3GjtZkD74sb+SfdTGUMloeJSNcs5uLfyBHrOb6++pK0bz/XQ07zvptyypQQU= +notifications: + email: + on_success: never diff --git a/deps/flate2-0.2.7/Cargo.toml b/deps/flate2-0.2.7/Cargo.toml new file mode 100644 index 000000000..608608df5 --- /dev/null +++ b/deps/flate2-0.2.7/Cargo.toml @@ -0,0 +1,23 @@ +[package] + +name = "flate2" +authors = ["Alex Crichton "] +version = "0.2.7" +license = "MIT/Apache-2.0" +readme = "README.md" +keywords = ["gzip", "flate", "zlib", "encoding"] +repository = "https://github.com/alexcrichton/flate2-rs" +homepage = "https://github.com/alexcrichton/flate2-rs" +documentation = "http://alexcrichton.com/flate2-rs" +description = """ +Bindings to miniz.c for DEFLATE compression and decompression exposed as +Reader/Writer streams. Contains bindings for zlib, deflate, and gzip-based +streams. +""" + +[dependencies] +libc = "0.1" +miniz-sys = { path = "miniz-sys", version = "0.1" } + +[dev-dependencies] +rand = "0.3" diff --git a/deps/flate2-0.2.7/LICENSE-APACHE b/deps/flate2-0.2.7/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/flate2-0.2.7/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/flate2-0.2.7/LICENSE-MIT b/deps/flate2-0.2.7/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/flate2-0.2.7/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/flate2-0.2.7/README.md b/deps/flate2-0.2.7/README.md new file mode 100644 index 000000000..01b8a4baf --- /dev/null +++ b/deps/flate2-0.2.7/README.md @@ -0,0 +1,61 @@ +# flate2 + +[![Build Status](https://travis-ci.org/alexcrichton/flate2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/flate2-rs) + +[Documentation](http://alexcrichton.com/flate2-rs/flate2/index.html) + +A streaming compression/decompression library for rust with bindings to +[`miniz`](https://code.google.com/p/miniz/) + +Supported formats: + +* deflate +* zlib +* gzip + +```toml +# Cargo.toml +[dependencies] +flate2 = "0.2" +``` + +## Compression + +```rust +extern crate flate2; + +use std::io::prelude::*; +use flate2::Compression; +use flate2::write::ZlibEncoder; + +fn main() { + let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); + e.write(b"foo"); + e.write(b"bar"); + let compressed_bytes = e.finish(); +} +``` + +## Decompression + +```rust,no_run +extern crate flate2; + +use std::io::prelude::*; +use flate2::read::GzDecoder; + +fn main() { + let mut d = GzDecoder::new("...".as_bytes()).unwrap(); + let mut s = String::new(); + d.read_to_string(&mut s).unwrap(); + println!("{}", s); +} +``` + +# License + +`flate2-rs` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/flate2-0.2.7/src/crc.rs b/deps/flate2-0.2.7/src/crc.rs new file mode 100644 index 000000000..7ed24ee20 --- /dev/null +++ b/deps/flate2-0.2.7/src/crc.rs @@ -0,0 +1,50 @@ +//! Simple CRC bindings backed by miniz.c + +use std::io::prelude::*; +use std::io; +use libc; + +use ffi; + +pub struct Crc { + crc: libc::c_ulong, + amt: u32, +} + +pub struct CrcReader { + inner: R, + crc: Crc, +} + +impl Crc { + pub fn new() -> Crc { + Crc { crc: 0, amt: 0 } + } + + pub fn sum(&self) -> libc::c_ulong { self.crc } + pub fn amt(&self) -> u32 { self.amt } + + pub fn update(&mut self, data: &[u8]) { + self.amt += data.len() as u32; + self.crc = unsafe { + ffi::mz_crc32(self.crc, data.as_ptr(), data.len() as libc::size_t) + }; + } +} + +impl CrcReader { + pub fn new(r: R) -> CrcReader { + CrcReader { inner: r, crc: Crc::new() } + } + pub fn crc(&self) -> &Crc { &self.crc } + pub fn into_inner(self) -> R { self.inner } + pub fn inner(&mut self) -> &mut R { &mut self.inner } +} + +impl Read for CrcReader { + fn read(&mut self, into: &mut [u8]) -> io::Result { + let amt = try!(self.inner.read(into)); + self.crc.update(&into[..amt]); + Ok(amt) + } +} diff --git a/deps/flate2-0.2.7/src/deflate.rs b/deps/flate2-0.2.7/src/deflate.rs new file mode 100644 index 000000000..ed21bdc4b --- /dev/null +++ b/deps/flate2-0.2.7/src/deflate.rs @@ -0,0 +1,190 @@ +//! DEFLATE compression and decompression of streams + +use std::io::prelude::*; +use std::io; +use std::iter::repeat; + +use raw; + +/// A DEFLATE encoder, or compressor. +/// +/// This structure implements a `Write` interface and takes a stream of +/// uncompressed data, writing the compressed data to the wrapped writer. +pub struct EncoderWriter { + inner: raw::EncoderWriter, +} + +/// A DEFLATE encoder, or compressor. +/// +/// This structure implements a `Read` interface and will read uncompressed +/// data from an underlying stream and emit a stream of compressed data. +pub struct EncoderReader { + inner: raw::EncoderReader, +} + +/// A DEFLATE decoder, or decompressor. +/// +/// This structure implements a `Read` interface and takes a stream of +/// compressed data as input, providing the decompressed data when read from. +pub struct DecoderReader { + inner: raw::DecoderReader, +} + +/// A DEFLATE decoder, or decompressor. +/// +/// This structure implements a `Write` and will emit a stream of decompressed +/// data when fed a stream of compressed data. +pub struct DecoderWriter { + inner: raw::DecoderWriter, +} + +impl EncoderWriter { + /// Creates a new encoder which will write compressed data to the stream + /// given at the given compression level. + /// + /// When this encoder is dropped or unwrapped the final pieces of data will + /// be flushed. + pub fn new(w: W, level: ::Compression) -> EncoderWriter { + EncoderWriter { + inner: raw::EncoderWriter::new(w, level, true, + Vec::with_capacity(32 * 1024)), + } + } + + /// Consumes this encoder, flushing the output stream. + /// + /// This will flush the underlying data stream and then return the contained + /// writer if the flush succeeded. + pub fn finish(mut self) -> io::Result { + try!(self.inner.finish()); + Ok(self.inner.into_inner()) + } +} + +impl Write for EncoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } +} + +impl EncoderReader { + /// Creates a new encoder which will read uncompressed data from the given + /// stream and emit the compressed stream. + pub fn new(r: R, level: ::Compression) -> EncoderReader { + EncoderReader { + inner: raw::EncoderReader::new(r, level, true, + repeat(0).take(32 * 1024).collect()), + } + } + + /// Consumes this encoder, returning the underlying reader. + pub fn into_inner(self) -> R { + self.inner.into_inner() + } +} + +impl Read for EncoderReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.inner.read(buf) + } +} + +impl DecoderReader { + /// Creates a new decoder which will decompress data read from the given + /// stream. + pub fn new(r: R) -> DecoderReader { + DecoderReader::new_with_buf(r, repeat(0).take(32 * 1024).collect()) + } + + /// Same as `new`, but the intermediate buffer for data is specified. + /// + /// Note that the capacity of the intermediate buffer is never increased, + /// and it is recommended for it to be large. + pub fn new_with_buf(r: R, buf: Vec) -> DecoderReader { + DecoderReader { inner: raw::DecoderReader::new(r, true, buf) } + } + + /// Consumes this decoder, returning the underlying reader. + pub fn into_inner(self) -> R { + self.inner.into_inner() + } +} + +impl Read for DecoderReader { + fn read(&mut self, into: &mut [u8]) -> io::Result { + self.inner.read(into) + } +} + +impl DecoderWriter { + /// Creates a new decoder which will write uncompressed data to the stream. + /// + /// When this encoder is dropped or unwrapped the final pieces of data will + /// be flushed. + pub fn new(w: W) -> DecoderWriter { + DecoderWriter { + inner: raw::DecoderWriter::new(w, true, + Vec::with_capacity(32 * 1024)), + } + } + + /// Consumes this encoder, flushing the output stream. + /// + /// This will flush the underlying data stream and then return the contained + /// writer if the flush succeeded. + pub fn finish(mut self) -> io::Result { + try!(self.inner.finish()); + Ok(self.inner.into_inner()) + } +} + +impl Write for DecoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } +} + +#[cfg(test)] +mod tests { + use std::io::prelude::*; + + use rand::{thread_rng, Rng}; + + use deflate::{EncoderWriter, EncoderReader, DecoderReader, DecoderWriter}; + use Compression::Default; + + #[test] + fn roundtrip() { + let mut real = Vec::new(); + let mut w = EncoderWriter::new(Vec::new(), Default); + let v = thread_rng().gen_iter::().take(1024).collect::>(); + for _ in 0..200 { + let to_write = &v[..thread_rng().gen_range(0, v.len())]; + real.extend(to_write.iter().map(|x| *x)); + w.write_all(to_write).unwrap(); + } + let result = w.finish().unwrap(); + let mut r = DecoderReader::new(&result[..]); + let mut ret = Vec::new(); + r.read_to_end(&mut ret).unwrap(); + assert!(ret == real); + } + + #[test] + fn roundtrip2() { + let v = thread_rng().gen_iter::().take(1024 * 1024).collect::>(); + let mut r = DecoderReader::new(EncoderReader::new(&v[..], Default)); + let mut ret = Vec::new(); + r.read_to_end(&mut ret).unwrap(); + assert_eq!(ret, v); + } + + #[test] + fn roundtrip3() { + let v = thread_rng().gen_iter::().take(1024 * 1024).collect::>(); + let mut w = EncoderWriter::new(DecoderWriter::new(Vec::new()), Default); + w.write_all(&v).unwrap(); + let w = w.finish().unwrap().finish().unwrap(); + assert!(w == v); + } +} + + diff --git a/deps/flate2-0.2.7/src/gz.rs b/deps/flate2-0.2.7/src/gz.rs new file mode 100644 index 000000000..f73e10a4b --- /dev/null +++ b/deps/flate2-0.2.7/src/gz.rs @@ -0,0 +1,542 @@ +//! gzip compression/decompression +//! +//! [1]: http://www.gzip.org/zlib/rfc-gzip.html + +use std::cmp; +use std::env; +use std::ffi::CString; +use std::io::prelude::*; +use std::io; +use std::iter::repeat; +use std::mem; + +use Compression; +use crc::{CrcReader, Crc}; +use raw; + +static FHCRC: u8 = 1 << 1; +static FEXTRA: u8 = 1 << 2; +static FNAME: u8 = 1 << 3; +static FCOMMENT: u8 = 1 << 4; + +/// A gzip streaming encoder +/// +/// This structure exposes a `Write` interface that will emit compressed data +/// to the underlying writer `W`. +pub struct EncoderWriter { + inner: raw::EncoderWriter, + crc: Crc, + header: Vec, +} + +/// A gzip streaming encoder +/// +/// This structure exposes a `Read` interface that will read uncompressed data +/// from the underlying reader and expose the compressed version as a `Read` +/// interface. +pub struct EncoderReader { + inner: raw::EncoderReader>, + header: Vec, + pos: usize, + eof: bool, +} + +/// A builder structure to create a new gzip Encoder. +/// +/// This structure controls header configuration options such as the filename. +pub struct Builder { + extra: Option>, + filename: Option, + comment: Option, + mtime: u32, +} + +/// A gzip streaming decoder +/// +/// This structure exposes a `Read` interface that will consume compressed +/// data from the underlying reader and emit uncompressed data. +pub struct DecoderReader { + inner: CrcReader>, + header: Header, +} + +/// A structure representing the header of a gzip stream. +/// +/// The header can contain metadata about the file that was compressed, if +/// present. +pub struct Header { + extra: Option>, + filename: Option>, + comment: Option>, + mtime: u32, +} + +impl Builder { + /// Create a new blank builder with no header by default. + pub fn new() -> Builder { + Builder { + extra: None, + filename: None, + comment: None, + mtime: 0, + } + } + + /// Configure the `mtime` field in the gzip header. + pub fn mtime(mut self, mtime: u32) -> Builder { + self.mtime = mtime; + self + } + + /// Configure the `extra` field in the gzip header. + pub fn extra(mut self, extra: Vec) -> Builder { + self.extra = Some(extra); + self + } + + /// Configure the `filename` field in the gzip header. + pub fn filename(mut self, filename: &[u8]) -> Builder { + self.filename = Some(CString::new(filename).unwrap()); + self + } + + /// Configure the `comment` field in the gzip header. + pub fn comment(mut self, comment: &[u8]) -> Builder { + self.comment = Some(CString::new(comment).unwrap()); + self + } + + /// Consume this builder, creating a writer encoder in the process. + /// + /// The data written to the returned encoder will be compressed and then + /// written out to the supplied parameter `w`. + pub fn write(self, w: W, lvl: Compression) -> EncoderWriter { + EncoderWriter { + inner: raw::EncoderWriter::new(w, lvl, true, + Vec::with_capacity(32 * 1024)), + crc: Crc::new(), + header: self.into_header(lvl), + } + } + + /// Consume this builder, creating a reader encoder in the process. + /// + /// Data read from the returned encoder will be the compressed version of + /// the data read from the given reader. + pub fn read(self, r: R, lvl: Compression) -> EncoderReader { + let crc = CrcReader::new(r); + EncoderReader { + inner: raw::EncoderReader::new(crc, lvl, true, + repeat(0).take(32 * 1024).collect()), + header: self.into_header(lvl), + pos: 0, + eof: false, + } + } + + fn into_header(self, lvl: Compression) -> Vec { + let Builder { extra, filename, comment, mtime } = self; + let mut flg = 0; + let mut header = repeat(0u8).take(10).collect::>(); + match extra { + Some(v) => { + flg |= FEXTRA; + header.push((v.len() >> 0) as u8); + header.push((v.len() >> 8) as u8); + header.extend(v); + } + None => {} + } + match filename { + Some(filename) => { + flg |= FNAME; + header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); + } + None => {} + } + match comment { + Some(comment) => { + flg |= FCOMMENT; + header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); + } + None => {} + } + header[0] = 0x1f; + header[1] = 0x8b; + header[2] = 8; + header[3] = flg; + header[4] = (mtime >> 0) as u8; + header[5] = (mtime >> 8) as u8; + header[6] = (mtime >> 16) as u8; + header[7] = (mtime >> 24) as u8; + header[8] = match lvl { + Compression::Best => 2, + Compression::Fast => 4, + _ => 0, + }; + header[9] = match env::consts::OS { + "linux" => 3, + "macos" => 7, + "win32" => 0, + _ => 255, + }; + return header; + } +} + +impl EncoderWriter { + /// Creates a new encoder which will use the given compression level. + /// + /// The encoder is not configured specially for the emitted header. For + /// header configuration, see the `Builder` type. + /// + /// The data written to the returned encoder will be compressed and then + /// written to the stream `w`. + pub fn new(w: W, level: Compression) -> EncoderWriter { + Builder::new().write(w, level) + } + + /// Finish encoding this stream, returning the underlying writer once the + /// encoding is done. + pub fn finish(mut self) -> io::Result { + self.do_finish() + } + + fn do_finish(&mut self) -> io::Result { + if self.header.len() != 0 { + try!(self.inner.write_all_raw(&self.header)); + } + try!(self.inner.finish()); + let mut inner = self.inner.take_inner(); + let (sum, amt) = (self.crc.sum() as u32, self.crc.amt()); + let buf = [ + (sum >> 0) as u8, + (sum >> 8) as u8, + (sum >> 16) as u8, + (sum >> 24) as u8, + (amt >> 0) as u8, + (amt >> 8) as u8, + (amt >> 16) as u8, + (amt >> 24) as u8, + ]; + try!(inner.write_all(&buf)); + Ok(inner) + } +} + +impl Write for EncoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.header.len() != 0 { + try!(self.inner.write_all_raw(&self.header)); + self.header.truncate(0); + } + let n = try!(self.inner.write(buf)); + self.crc.update(&buf[..n]); + Ok(n) + } + + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } +} + +impl Drop for EncoderWriter { + fn drop(&mut self) { + if !self.inner.unwrapped() { + let _ = self.do_finish(); + } + } +} + +impl EncoderReader { + /// Creates a new encoder which will use the given compression level. + /// + /// The encoder is not configured specially for the emitted header. For + /// header configuration, see the `Builder` type. + /// + /// The data read from the stream `r` will be compressed and available + /// through the returned reader. + pub fn new(r: R, level: Compression) -> EncoderReader { + Builder::new().read(r, level) + } + + /// Returns the underlying stream, consuming this encoder + pub fn into_inner(self) -> R { + self.inner.into_inner().into_inner() + } + + fn read_footer(&mut self, into: &mut [u8]) -> io::Result { + if self.pos == 8 { return Ok(0) } + let crc = self.inner.get_ref().crc(); + let ref arr = [ + (crc.sum() >> 0) as u8, + (crc.sum() >> 8) as u8, + (crc.sum() >> 16) as u8, + (crc.sum() >> 24) as u8, + (crc.amt() >> 0) as u8, + (crc.amt() >> 8) as u8, + (crc.amt() >> 16) as u8, + (crc.amt() >> 24) as u8, + ]; + Ok(copy(into, arr, &mut self.pos)) + } +} + +fn copy(into: &mut [u8], from: &[u8], pos: &mut usize) -> usize { + let min = cmp::min(into.len(), from.len() - *pos); + for (slot, val) in into.iter_mut().zip(from[*pos..*pos + min].iter()) { + *slot = *val; + } + *pos += min; + return min +} + +impl Read for EncoderReader { + fn read(&mut self, mut into: &mut [u8]) -> io::Result { + let mut amt = 0; + if self.eof { + return self.read_footer(into) + } else if self.pos < self.header.len() { + amt += copy(into, &self.header, &mut self.pos); + if amt == into.len() { return Ok(amt) } + let tmp = into; into = &mut tmp[amt..]; + } + match try!(self.inner.read(into)) { + 0 => { + self.eof = true; + self.pos = 0; + self.read_footer(into) + } + n => Ok(amt + n), + } + } +} + +impl DecoderReader { + /// Creates a new decoder from the given reader, immediately parsing the + /// gzip header. + /// + /// If an error is encountered when parsing the gzip header, an error is + /// returned. + pub fn new(r: R) -> io::Result> { + let mut crc_reader = CrcReader::new(r); + let mut header = [0; 10]; + try!(fill(&mut crc_reader, &mut header)); + + let id1 = header[0]; + let id2 = header[1]; + if id1 != 0x1f || id2 != 0x8b { return Err(bad_header()) } + let cm = header[2]; + if cm != 8 { return Err(bad_header()) } + + let flg = header[3]; + let mtime = ((header[4] as u32) << 0) | + ((header[5] as u32) << 8) | + ((header[6] as u32) << 16) | + ((header[7] as u32) << 24); + let _xfl = header[8]; + let _os = header[9]; + + let extra = if flg & FEXTRA != 0 { + let xlen = try!(read_le_u16(&mut crc_reader)); + let mut extra = repeat(0).take(xlen as usize).collect::>(); + try!(fill(&mut crc_reader, &mut extra)); + Some(extra) + } else { + None + }; + let filename = if flg & FNAME != 0 { + // wow this is slow + let mut b = Vec::new(); + for byte in crc_reader.by_ref().bytes() { + let byte = try!(byte); + if byte == 0 { break } + b.push(byte); + } + Some(b) + } else { + None + }; + let comment = if flg & FCOMMENT != 0 { + // wow this is slow + let mut b = Vec::new(); + for byte in crc_reader.by_ref().bytes() { + let byte = try!(byte); + if byte == 0 { break } + b.push(byte); + } + Some(b) + } else { + None + }; + + if flg & FHCRC != 0 { + let calced_crc = crc_reader.crc().sum() as u16; + let stored_crc = try!(read_le_u16(&mut crc_reader)); + if calced_crc != stored_crc { return Err(corrupt()) } + } + + let flate = raw::DecoderReader::new(crc_reader.into_inner(), true, + repeat(0).take(32 * 1024).collect()); + return Ok(DecoderReader { + inner: CrcReader::new(flate), + header: Header { + extra: extra, + filename: filename, + comment: comment, + mtime: mtime, + } + }); + + fn bad_header() -> io::Error { + io::Error::new(io::ErrorKind::InvalidInput, "invalid gzip header") + } + + fn fill(r: &mut R, mut buf: &mut [u8]) -> io::Result<()> { + while buf.len() > 0 { + match try!(r.read(buf)) { + 0 => return Err(corrupt()), + n => buf = &mut mem::replace(&mut buf, &mut [])[n..], + } + } + Ok(()) + } + + fn read_le_u16(r: &mut R) -> io::Result { + let mut b = [0; 2]; + try!(fill(r, &mut b)); + Ok((b[0] as u16) | ((b[1] as u16) << 8)) + } + } + + /// Returns the header associated with this stream. + pub fn header(&self) -> &Header { &self.header } + + fn finish(&mut self) -> io::Result<()> { + let ref mut buf = [0u8; 8]; + { + let mut len = 0; + + while len < buf.len() { + match try!(self.inner.inner().read_raw(&mut buf[len..])) { + 0 => return Err(corrupt()), + n => len += n, + } + } + } + + let crc = ((buf[0] as u32) << 0) | + ((buf[1] as u32) << 8) | + ((buf[2] as u32) << 16) | + ((buf[3] as u32) << 24); + let amt = ((buf[4] as u32) << 0) | + ((buf[5] as u32) << 8) | + ((buf[6] as u32) << 16) | + ((buf[7] as u32) << 24); + if crc != self.inner.crc().sum() as u32 { return Err(corrupt()) } + if amt != self.inner.crc().amt() { return Err(corrupt()) } + Ok(()) + } +} + +impl Read for DecoderReader { + fn read(&mut self, into: &mut [u8]) -> io::Result { + match try!(self.inner.read(into)) { + 0 => { try!(self.finish()); Ok(0) } + n => Ok(n), + } + } +} + +impl Header { + /// Returns the `filename` field of this gzip stream's header, if present. + pub fn filename(&self) -> Option<&[u8]> { + self.filename.as_ref().map(|s| &s[..]) + } + /// Returns the `extra` field of this gzip stream's header, if present. + pub fn extra(&self) -> Option<&[u8]> { + self.extra.as_ref().map(|s| &s[..]) + } + /// Returns the `comment` field of this gzip stream's header, if present. + pub fn comment(&self) -> Option<&[u8]> { + self.comment.as_ref().map(|s| &s[..]) + } + /// Returns the `mtime` field of this gzip stream's header, if present. + pub fn mtime(&self) -> u32 { self.mtime } +} + +fn corrupt() -> io::Error { + io::Error::new(io::ErrorKind::InvalidInput, + "corrupt gzip stream does not have a matching checksum") +} + +#[cfg(test)] +mod tests { + use std::io::prelude::*; + + use super::{EncoderWriter, EncoderReader, DecoderReader, Builder}; + use Compression::Default; + use rand::{thread_rng, Rng}; + + #[test] + fn roundtrip() { + let mut e = EncoderWriter::new(Vec::new(), Default); + e.write_all(b"foo bar baz").unwrap(); + let inner = e.finish().unwrap(); + let mut d = DecoderReader::new(&inner[..]).unwrap(); + let mut s = String::new(); + d.read_to_string(&mut s).unwrap(); + assert_eq!(s, "foo bar baz"); + } + + #[test] + fn roundtrip_zero() { + let e = EncoderWriter::new(Vec::new(), Default); + let inner = e.finish().unwrap(); + let mut d = DecoderReader::new(&inner[..]).unwrap(); + let mut s = String::new(); + d.read_to_string(&mut s).unwrap(); + assert_eq!(s, ""); + } + + #[test] + fn roundtrip_big() { + let mut real = Vec::new(); + let mut w = EncoderWriter::new(Vec::new(), Default); + let v = thread_rng().gen_iter::().take(1024).collect::>(); + for _ in 0..200 { + let to_write = &v[..thread_rng().gen_range(0, v.len())]; + real.extend(to_write.iter().map(|x| *x)); + w.write_all(to_write).unwrap(); + } + let result = w.finish().unwrap(); + let mut r = DecoderReader::new(&result[..]).unwrap(); + let mut v = Vec::new(); + r.read_to_end(&mut v).unwrap(); + assert!(v == real); + } + + #[test] + fn roundtrip_big2() { + let v = thread_rng().gen_iter::().take(1024 * 1024).collect::>(); + let mut r = DecoderReader::new(EncoderReader::new(&v[..], Default)).unwrap(); + let mut res = Vec::new(); + r.read_to_end(&mut res).unwrap(); + assert!(res == v); + } + + #[test] + fn fields() { + let r = vec![0, 2, 4, 6]; + let e = Builder::new().filename(b"foo.rs") + .comment(b"bar") + .extra(vec![0, 1, 2, 3]) + .read(&r[..], Default); + let mut d = DecoderReader::new(e).unwrap(); + assert_eq!(d.header().filename(), Some(&b"foo.rs"[..])); + assert_eq!(d.header().comment(), Some(&b"bar"[..])); + assert_eq!(d.header().extra(), Some(&b"\x00\x01\x02\x03"[..])); + let mut res = Vec::new(); + d.read_to_end(&mut res).unwrap(); + assert_eq!(res, vec![0, 2, 4, 6]); + + } +} diff --git a/deps/flate2-0.2.7/src/lib.rs b/deps/flate2-0.2.7/src/lib.rs new file mode 100644 index 000000000..4777d5915 --- /dev/null +++ b/deps/flate2-0.2.7/src/lib.rs @@ -0,0 +1,179 @@ +//! A DEFLATE-based stream compression/decompression library +//! +//! This library is meant to supplement/replace the standard distributon's +//! libflate library by providing a streaming encoder/decoder rather than purely +//! in in-memory encoder/decoder. +//! +//! Like with libflate, flate2 is based on [`miniz.c`][1] +//! +//! [1]: https://code.google.com/p/miniz/ +//! +//! # Organization +//! +//! This crate contains mainly of two modules, `reader` and `writer`. Each +//! module contains a number of types used to encode and decode various streams +//! of data. All types in the `writer` module work on instances of `Writer`, +//! whereas all types in the `reader` module work on instances of `Reader`. +//! +//! Other various types are provided at the top-level of the crate for +//! mangement and dealing with encoders/decoders. +//! +//! # Helper traits +//! +//! There are two helper traits, provided, `FlateReader` and `FlateWriter`. +//! These provide convenience methods for creating a decoder/encoder out of an +//! already existing stream to chain construction. + +#![doc(html_root_url = "http://alexcrichton.com/flate2-rs")] +#![deny(missing_docs)] +#![allow(trivial_numeric_casts)] +#![cfg_attr(test, deny(warnings))] + +extern crate libc; +extern crate miniz_sys as ffi; +#[cfg(test)] extern crate rand; + +use std::io::prelude::*; +use std::io; + +pub use gz::Builder as GzBuilder; +pub use gz::Header as GzHeader; + +mod crc; +mod deflate; +mod gz; +mod raw; +mod zlib; +mod stream; + +/// Types which operate over `Reader` streams, both encoders and decoders for +/// various formats. +pub mod read { + pub use deflate::EncoderReader as DeflateEncoder; + pub use deflate::DecoderReader as DeflateDecoder; + pub use zlib::EncoderReader as ZlibEncoder; + pub use zlib::DecoderReader as ZlibDecoder; + pub use gz::EncoderReader as GzEncoder; + pub use gz::DecoderReader as GzDecoder; +} + +/// Types which operate over `Writer` streams, both encoders and decoders for +/// various formats. +pub mod write { + pub use deflate::EncoderWriter as DeflateEncoder; + pub use deflate::DecoderWriter as DeflateDecoder; + pub use zlib::EncoderWriter as ZlibEncoder; + pub use zlib::DecoderWriter as ZlibDecoder; + pub use gz::EncoderWriter as GzEncoder; +} + +/// When compressing data, the compression level can be specified by a value in +/// this enum. +#[derive(Copy, Clone)] +pub enum Compression { + /// No compression is to be performed, this may actually inflate data + /// slightly when encoding. + None = 0, + /// Optimize for the best speed of encoding. + Fast = 1, + /// Optimize for the size of data being encoded. + Best = 9, + /// Choose the default compression, a balance between speed and size. + Default = 6, +} + +/// A helper trait to create encoder/decoders with method syntax. +pub trait FlateReadExt: Read + Sized { + /// Consume this reader to create a compression stream at the specified + /// compression level. + fn gz_encode(self, lvl: Compression) -> read::GzEncoder { + read::GzEncoder::new(self, lvl) + } + + /// Consume this reader to create a decompression stream of this stream. + fn gz_decode(self) -> io::Result> { + read::GzDecoder::new(self) + } + + /// Consume this reader to create a compression stream at the specified + /// compression level. + fn zlib_encode(self, lvl: Compression) -> read::ZlibEncoder { + read::ZlibEncoder::new(self, lvl) + } + + /// Consume this reader to create a decompression stream of this stream. + fn zlib_decode(self) -> read::ZlibDecoder { + read::ZlibDecoder::new(self) + } + + /// Consume this reader to create a compression stream at the specified + /// compression level. + fn deflate_encode(self, lvl: Compression) -> read::DeflateEncoder { + read::DeflateEncoder::new(self, lvl) + } + + /// Consume this reader to create a decompression stream of this stream. + fn deflate_decode(self) -> read::DeflateDecoder { + read::DeflateDecoder::new(self) + } +} + +/// A helper trait to create encoder/decoders with method syntax. +pub trait FlateWriteExt: Write + Sized { + /// Consume this writer to create a compression stream at the specified + /// compression level. + fn gz_encode(self, lvl: Compression) -> write::GzEncoder { + write::GzEncoder::new(self, lvl) + } + + // TODO: coming soon to a theater near you! + // /// Consume this writer to create a decompression stream of this stream. + // fn gz_decode(self) -> IoResult> { + // write::GzDecoder::new(self) + // } + + /// Consume this writer to create a compression stream at the specified + /// compression level. + fn zlib_encode(self, lvl: Compression) -> write::ZlibEncoder { + write::ZlibEncoder::new(self, lvl) + } + + /// Consume this writer to create a decompression stream of this stream. + fn zlib_decode(self) -> write::ZlibDecoder { + write::ZlibDecoder::new(self) + } + + /// Consume this writer to create a compression stream at the specified + /// compression level. + fn deflate_encode(self, lvl: Compression) -> write::DeflateEncoder { + write::DeflateEncoder::new(self, lvl) + } + + /// Consume this writer to create a decompression stream of this stream. + fn deflate_decode(self) -> write::DeflateDecoder { + write::DeflateDecoder::new(self) + } +} + +impl FlateReadExt for T {} +impl FlateWriteExt for T {} + +#[cfg(test)] +mod test { + use std::io::prelude::*; + use {FlateReadExt, Compression}; + + #[test] + fn crazy() { + let rdr = &mut b"foobar"; + let mut res = Vec::new(); + rdr.gz_encode(Compression::Default) + .deflate_encode(Compression::Default) + .zlib_encode(Compression::Default) + .zlib_decode() + .deflate_decode() + .gz_decode().unwrap() + .read_to_end(&mut res).unwrap(); + assert_eq!(res, b"foobar"); + } +} diff --git a/deps/flate2-0.2.7/src/raw.rs b/deps/flate2-0.2.7/src/raw.rs new file mode 100644 index 000000000..d10fe1da1 --- /dev/null +++ b/deps/flate2-0.2.7/src/raw.rs @@ -0,0 +1,259 @@ +//! Raw un-exported bindings to miniz for encoding/decoding + +use std::io::prelude::*; +use std::io; +use libc; + +use Compression; +use ffi; +use stream::{Stream, Compress, Decompress, Direction, Flush}; + +pub struct EncoderWriter(InnerWrite); +pub struct DecoderWriter(InnerWrite); + +struct InnerWrite { + inner: Option, + stream: Stream, + buf: Vec, +} + +pub struct EncoderReader(InnerRead); +pub struct DecoderReader(InnerRead); + +struct InnerRead { + inner: R, + stream: Stream, + buf: Vec, // TODO: this should be Box<[u8]> + pos: usize, + cap: usize, +} + +impl EncoderWriter { + pub fn new(w: W, level: Compression, raw: bool, buf: Vec) + -> EncoderWriter { + EncoderWriter(InnerWrite { + inner: Some(w), + stream: Stream::new_compress(level, raw), + buf: buf, + }) + } + + pub fn finish(&mut self) -> io::Result<()> { + self.0.finish(&mut |stream, inner| { + stream.compress_vec(&[], inner, Flush::Finish) + }) + } + + pub fn into_inner(mut self) -> W { self.0.inner.take().unwrap() } + + pub fn take_inner(&mut self) -> W { self.0.inner.take().unwrap() } + + pub fn write_all_raw(&mut self, buf: &[u8]) -> io::Result<()> { + self.0.inner.as_mut().unwrap().write_all(buf) + } + + pub fn unwrapped(&self) -> bool { + self.0.inner.is_none() + } +} + +impl Write for EncoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + // miniz isn't guaranteed to actually write any of the buffer provided, + // it may be in a flushing mode where it's just giving us data before + // we're actually giving it any data. We don't want to spuriously return + // `Ok(0)` when possible as it will cause calls to write_all() to fail. + // As a result we execute this in a loop to ensure that we try our + // darndest to write the data. + loop { + let n = try!(self.0.write(&mut |stream, inner| { + stream.compress_vec(buf, inner, Flush::None) + })); + if buf.len() == 0 || n != 0 { + return Ok(n) + } + } + } + + fn flush(&mut self) -> io::Result<()> { + self.0.finish(&mut |stream, inner| { + stream.compress_vec(&[], inner, Flush::Sync) + }).and_then(|()| self.0.inner.as_mut().unwrap().flush()) + } +} + +impl Drop for EncoderWriter { + fn drop(&mut self) { + if self.0.inner.is_some() { + let _ = self.finish(); + } + } +} + +impl DecoderWriter { + pub fn new(w: W, raw: bool, buf: Vec) -> DecoderWriter { + DecoderWriter(InnerWrite { + inner: Some(w), + stream: Stream::new_decompress(raw), + buf: buf, + }) + } + + pub fn finish(&mut self) -> io::Result<()> { + self.0.finish(&mut |stream, inner| { + stream.decompress_vec(&[], inner, Flush::Finish) + }) + } + + pub fn into_inner(mut self) -> W { self.0.inner.take().unwrap() } +} + +impl Write for DecoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + // See EncoderWriter::write for why this is in a loop + loop { + let n = try!(self.0.write(&mut |stream, inner| { + stream.decompress_vec(buf, inner, Flush::None) + })); + if buf.len() == 0 || n != 0 { + return Ok(n) + } + } + } + + fn flush(&mut self) -> io::Result<()> { + self.0.finish(&mut |stream, inner| { + stream.decompress_vec(&[], inner, Flush::Sync) + }).and_then(|()| self.0.inner.as_mut().unwrap().flush()) + } +} + +impl InnerWrite { + fn write(&mut self, f: &mut F) -> io::Result + where F: FnMut(&mut Stream, &mut Vec) -> libc::c_int + { + let writer = self.inner.as_mut().unwrap(); + if self.buf.len() > 0 { + try!(writer.write_all(&self.buf)); + self.buf.truncate(0); + } + + let before_in = self.stream.total_in(); + let ret = f(&mut self.stream, &mut self.buf); + let written = (self.stream.total_in() - before_in) as usize; + match ret { + ffi::MZ_OK | ffi::MZ_BUF_ERROR | ffi::MZ_STREAM_END => Ok(written), + n => panic!("unexpected return {}", n), + } + } + + fn finish(&mut self, f: &mut F) -> io::Result<()> + where F: FnMut(&mut Stream, &mut Vec) -> libc::c_int + { + // Unfortunately miniz doesn't actually tell us when we're done with + // pulling out all the data from the internal stream. To remedy this we + // have to continually ask the stream for more memory until it doesn't + // give us a chunk of memory the same size as our own internal buffer, + // at which point we assume it's reached the end. + let mut cont = true; + while cont { + try!(self.write(f)); + let inner = self.inner.as_mut().unwrap(); + if self.buf.len() > 0 { + try!(inner.write_all(&self.buf)); + } + cont = self.buf.len() == self.buf.capacity(); + self.buf.truncate(0); + } + Ok(()) + } +} + +impl EncoderReader { + pub fn new(w: R, level: Compression, raw: bool, buf: Vec) + -> EncoderReader { + EncoderReader(InnerRead { + inner: w, + stream: Stream::new_compress(level, raw), + buf: buf, + cap: 0, + pos: 0, + }) + } + pub fn get_ref(&self) -> &R { &self.0.inner } + pub fn into_inner(self) -> R { self.0.inner } +} + +impl Read for EncoderReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.0.read(|stream, inner, flush| stream.compress(inner, buf, flush)) + } +} + +impl DecoderReader { + pub fn new(r: R, raw: bool, buf: Vec) -> DecoderReader { + DecoderReader(InnerRead { + inner: r, + stream: Stream::new_decompress(raw), + buf: buf, + pos: 0, + cap: 0, + }) + } + + pub fn into_inner(self) -> R { self.0.inner } + + pub fn read_raw(&mut self, buf: &mut [u8]) -> io::Result { + let mut from = &self.0.buf[self.0.pos..self.0.cap]; + match try!(Read::read(&mut from, buf)) { + 0 => {} + n => { self.0.pos += n; return Ok(n) } + } + self.0.inner.read(buf) + } +} + +impl Read for DecoderReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.0.read(|stream, inner, flush| stream.decompress(inner, buf, flush)) + } +} + +impl InnerRead { + fn read(&mut self, mut f: F) -> io::Result + where F: FnMut(&mut Stream, &[u8], Flush) -> libc::c_int + { + loop { + let mut eof = false; + if self.pos == self.cap { + self.cap = try!(self.inner.read(&mut self.buf)); + self.pos = 0; + eof = self.cap == 0; + } + + let before_out = self.stream.total_out(); + let before_in = self.stream.total_in(); + let ret = f(&mut self.stream, &self.buf[self.pos..self.cap], + if eof {Flush::Finish} else {Flush::None}); + let read = (self.stream.total_out() - before_out) as usize; + self.pos += (self.stream.total_in() - before_in) as usize; + + return match ret { + ffi::MZ_OK | ffi::MZ_BUF_ERROR => { + // If we haven't ready any data and we haven't hit EOF yet, + // then we need to keep asking for more data because if we + // return that 0 bytes of data have been read then it will + // be interpreted as EOF. + if read == 0 && !eof { continue } + Ok(read) + } + ffi::MZ_STREAM_END => return Ok(read), + ffi::MZ_DATA_ERROR => { + Err(io::Error::new(io::ErrorKind::InvalidInput, + "corrupt deflate stream")) + } + n => panic!("unexpected return {}", n), + } + } + } +} diff --git a/deps/flate2-0.2.7/src/stream.rs b/deps/flate2-0.2.7/src/stream.rs new file mode 100644 index 000000000..885b372e6 --- /dev/null +++ b/deps/flate2-0.2.7/src/stream.rs @@ -0,0 +1,145 @@ +//! Raw un-exported bindings to miniz for encoding/decoding + +use std::marker; +use std::mem; +use libc::{c_int, c_uint}; + +use Compression; +use ffi; + +pub struct Stream { + raw: ffi::mz_stream, + _marker: marker::PhantomData, +} + +pub enum Compress {} +pub enum Decompress {} + +pub enum Flush { + None = ffi::MZ_NO_FLUSH as isize, + Sync = ffi::MZ_SYNC_FLUSH as isize, + Finish = ffi::MZ_FINISH as isize, +} + +#[doc(hidden)] +pub trait Direction { + unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int; + fn foo(&self) {} +} + +impl Stream { + pub fn new_compress(lvl: Compression, raw: bool) -> Stream { + unsafe { + let mut state: ffi::mz_stream = mem::zeroed(); + let ret = ffi::mz_deflateInit2(&mut state, + lvl as c_int, + ffi::MZ_DEFLATED, + if raw { + -ffi::MZ_DEFAULT_WINDOW_BITS + } else { + ffi::MZ_DEFAULT_WINDOW_BITS + }, + 9, + ffi::MZ_DEFAULT_STRATEGY); + debug_assert_eq!(ret, 0); + Stream { raw: state, _marker: marker::PhantomData } + } + } + + pub fn new_decompress(raw: bool) -> Stream { + unsafe { + let mut state: ffi::mz_stream = mem::zeroed(); + let ret = ffi::mz_inflateInit2(&mut state, + if raw { + -ffi::MZ_DEFAULT_WINDOW_BITS + } else { + ffi::MZ_DEFAULT_WINDOW_BITS + }); + debug_assert_eq!(ret, 0); + Stream { raw: state, _marker: marker::PhantomData } + } + } +} + +impl Stream { + pub fn total_in(&self) -> u64 { self.raw.total_in as u64 } + pub fn total_out(&self) -> u64 { self.raw.total_out as u64 } +} + +impl Stream { + pub fn decompress(&mut self, input: &[u8], output: &mut [u8], + flush: Flush) -> c_int { + self.raw.next_in = input.as_ptr(); + self.raw.avail_in = input.len() as c_uint; + self.raw.next_out = output.as_mut_ptr(); + self.raw.avail_out = output.len() as c_uint; + unsafe { ffi::mz_inflate(&mut self.raw, flush as c_int) } + } + + pub fn decompress_vec(&mut self, input: &[u8], output: &mut Vec, + flush: Flush) -> c_int { + let cap = output.capacity(); + let len = output.len(); + self.raw.avail_in = input.len() as c_uint; + self.raw.next_in = input.as_ptr() as *mut _; + self.raw.avail_out = (cap - len) as c_uint; + + unsafe { + self.raw.next_out = output.as_mut_ptr().offset(len as isize); + let before = self.total_out(); + let rc = ffi::mz_inflate(&mut self.raw, flush as c_int); + let diff = (self.total_out() - before) as usize; + output.set_len(len + diff); + return rc; + } + } +} + +impl Stream { + pub fn compress(&mut self, input: &[u8], output: &mut [u8], + flush: Flush) -> c_int { + self.raw.next_in = input.as_ptr() as *mut _; + self.raw.avail_in = input.len() as c_uint; + self.raw.next_out = output.as_mut_ptr(); + self.raw.avail_out = output.len() as c_uint; + unsafe { ffi::mz_deflate(&mut self.raw, flush as c_int) } + } + + pub fn compress_vec(&mut self, input: &[u8], output: &mut Vec, + flush: Flush) -> c_int { + let cap = output.capacity(); + let len = output.len(); + self.raw.avail_in = input.len() as c_uint; + self.raw.next_in = input.as_ptr() as *mut _; + self.raw.avail_out = (cap - len) as c_uint; + + unsafe { + self.raw.next_out = output.as_mut_ptr().offset(len as isize); + + let before = self.total_out(); + let rc = ffi::mz_deflate(&mut self.raw, flush as c_int); + let diff = (self.total_out() - before) as usize; + output.set_len(len + diff); + return rc; + } + } +} + +impl Direction for Compress { + unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int { + ffi::mz_deflateEnd(stream) + } +} +impl Direction for Decompress { + unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int { + ffi::mz_inflateEnd(stream) + } +} + +impl Drop for Stream { + fn drop(&mut self) { + unsafe { + let _ = ::destroy(&mut self.raw); + } + } +} diff --git a/deps/flate2-0.2.7/src/zlib.rs b/deps/flate2-0.2.7/src/zlib.rs new file mode 100644 index 000000000..93ab75cd7 --- /dev/null +++ b/deps/flate2-0.2.7/src/zlib.rs @@ -0,0 +1,190 @@ +//! ZLIB compression and decompression of streams + +use std::io::prelude::*; +use std::io; +use std::iter::repeat; + +use raw; + +/// A ZLIB encoder, or compressor. +/// +/// This structure implements a `Write` interface and takes a stream of +/// uncompressed data, writing the compressed data to the wrapped writer. +pub struct EncoderWriter { + inner: raw::EncoderWriter, +} + +/// A ZLIB encoder, or compressor. +/// +/// This structure implements a `Read` interface and will read uncompressed +/// data from an underlying stream and emit a stream of compressed data. +pub struct EncoderReader { + inner: raw::EncoderReader, +} + +/// A ZLIB decoder, or decompressor. +/// +/// This structure implements a `Read` interface and takes a stream of +/// compressed data as input, providing the decompressed data when read from. +pub struct DecoderReader { + inner: raw::DecoderReader, +} + +/// A ZLIB decoder, or decompressor. +/// +/// This structure implements a `Write` and will emit a stream of decompressed +/// data when fed a stream of compressed data. +pub struct DecoderWriter { + inner: raw::DecoderWriter, +} + +impl EncoderWriter { + /// Creates a new encoder which will write compressed data to the stream + /// given at the given compression level. + /// + /// When this encoder is dropped or unwrapped the final pieces of data will + /// be flushed. + pub fn new(w: W, level: ::Compression) -> EncoderWriter { + EncoderWriter { + inner: raw::EncoderWriter::new(w, level, false, + Vec::with_capacity(32 * 1024)), + } + } + + /// Consumes this encoder, flushing the output stream. + /// + /// This will flush the underlying data stream and then return the contained + /// writer if the flush succeeded. + pub fn finish(mut self) -> io::Result { + try!(self.inner.finish()); + Ok(self.inner.into_inner()) + } +} + +impl Write for EncoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } +} + +impl EncoderReader { + /// Creates a new encoder which will read uncompressed data from the given + /// stream and emit the compressed stream. + pub fn new(r: R, level: ::Compression) -> EncoderReader { + EncoderReader { + inner: raw::EncoderReader::new(r, level, false, + repeat(0).take(32 * 1024).collect()) + } + } + + /// Consumes this encoder, returning the underlying reader. + pub fn into_inner(self) -> R { + self.inner.into_inner() + } +} + +impl Read for EncoderReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.inner.read(buf) + } +} + +impl DecoderReader { + /// Creates a new decoder which will decompress data read from the given + /// stream. + pub fn new(r: R) -> DecoderReader { + DecoderReader::new_with_buf(r, repeat(0).take(32 * 1024).collect()) + } + + /// Same as `new`, but the intermediate buffer for data is specified. + /// + /// Note that the specified buffer will only be used up to its current + /// length. The buffer's capacity will also not grow over time. + pub fn new_with_buf(r: R, buf: Vec) -> DecoderReader { + DecoderReader { inner: raw::DecoderReader::new(r, false, buf) } + } + + /// Consumes this decoder, returning the underlying reader. + pub fn into_inner(self) -> R { + self.inner.into_inner() + } +} + +impl Read for DecoderReader { + fn read(&mut self, into: &mut [u8]) -> io::Result { + self.inner.read(into) + } +} + +impl DecoderWriter { + /// Creates a new decoder which will write uncompressed data to the stream. + /// + /// When this encoder is dropped or unwrapped the final pieces of data will + /// be flushed. + pub fn new(w: W) -> DecoderWriter { + DecoderWriter { + inner: raw::DecoderWriter::new(w, false, + Vec::with_capacity(32 * 1024)), + } + } + + /// Consumes this encoder, flushing the output stream. + /// + /// This will flush the underlying data stream and then return the contained + /// writer if the flush succeeded. + pub fn finish(mut self) -> io::Result { + try!(self.inner.finish()); + Ok(self.inner.into_inner()) + } +} + +impl Write for DecoderWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } +} + +#[cfg(test)] +mod tests { + use std::io::prelude::*; + + use rand::{thread_rng, Rng}; + + use zlib::{EncoderWriter, EncoderReader, DecoderReader, DecoderWriter}; + use Compression::Default; + + #[test] + fn roundtrip() { + let mut real = Vec::new(); + let mut w = EncoderWriter::new(Vec::new(), Default); + let v = thread_rng().gen_iter::().take(1024).collect::>(); + for _ in 0..200 { + let to_write = &v[..thread_rng().gen_range(0, v.len())]; + real.extend(to_write.iter().map(|x| *x)); + w.write_all(to_write).unwrap(); + } + let result = w.finish().unwrap(); + let mut r = DecoderReader::new(&result[..]); + let mut ret = Vec::new(); + r.read_to_end(&mut ret).unwrap(); + assert!(ret == real); + } + + #[test] + fn roundtrip2() { + let v = thread_rng().gen_iter::().take(1024 * 1024).collect::>(); + let mut r = DecoderReader::new(EncoderReader::new(&v[..], Default)); + let mut ret = Vec::new(); + r.read_to_end(&mut ret).unwrap(); + assert_eq!(ret, v); + } + + #[test] + fn roundtrip3() { + let v = thread_rng().gen_iter::().take(1024 * 1024).collect::>(); + let mut w = EncoderWriter::new(DecoderWriter::new(Vec::new()), Default); + w.write_all(&v).unwrap(); + let w = w.finish().unwrap().finish().unwrap(); + assert!(w == v); + } +} + + diff --git a/deps/flate2-0.2.7/tests/corrupt-file.gz b/deps/flate2-0.2.7/tests/corrupt-file.gz new file mode 100644 index 0000000000000000000000000000000000000000..159333b032751969263eeb152e7e94782ab2cd39 GIT binary patch literal 7128 zcmeH}3`T8Bd^E~*{sR93UWTs`tIH^whgwc1l%>Czl5mp~aWyj6i8WXLt$movJ+e~8!|2g5T~UafXuTIJu# zoS~3m6PA$4Q;uFDI8m7>q+XZ&N^Gjzdn>6v%OFv?Go}67YjH_mY)Uz#0=%;*6Dqa? z?t{I-75TdNvQ}L~-ONn8cU`PXs{TyB{yv!8>iJf!Mw89_!sc@KR`fbp5@X0!>iZ}E zYU7oHq?2~Nqnbz5>o@hi;+AB%A0ZXE_WY~7dEqw&4lqG@d->r>wd4=; z_frA~ie+z1GGz$%NHbFmqzZ;Zze*!6^g;4%q)jqg+Pi9@i+61o#ucZn*BT|$yF=?n zI(#41LL^L85hEST#S{Ul8y5^~C_dtxGu%Vf%`QdZ1+nISvfpcr5x%!uN!98-In?; z3fFx^x(n8gMKWrpOZArTc=w&9$UJ!Y0p|Nj7B<3J2=mswps}|MMm&;^SQEYYn5xD!=rxs7sS`MxHsb6xrd7*UOdwC zan!!BbV|cCVea9d$fT_s^Zg&A|HtV6az^bG`rbnOYI*L7wz+)T)WX#YfJ93Jj5fl& zS0bt*EfBpC7)nF13u-+2opxJ zmoG1tJWIpk1HB&#KMXZrn329jVpn`EB~2e|6Nc?ymZ-pjzQU6Fx|7jFWYleZ@8s)! z7K$HI5y>px!wb)u6~hrYar4SjhrDM^;^t4#2QygOu~w2a zJR7mAb!$X;S_vCs!AwmB+|5PvS(igNfgT(oYb~V4E0S0xf7U9UjrMt0 z%+}w!%GY%tt?CUA&@(&Y+TPCMW5Z2DglRF}sgkg0cI@edoUkuPmzIy=_Xvv_qvKi`y5Us;0F?Br zGFciYoHX26hX2)0;V}h&W4f@hyo8>z()gpJtp^|RMn|m|@fnH9ZGgnACk%3N=>_J) z6nZx|pL4>qEeRgKmO+(Yh-~TeJ*4%1gogF|u7EoJJ5k z9abxxtAP}LUe`ddQGx_NJ7suR@}1HdsW{B=i$RRXBZ`&Prw(iegqQbUy6?ZyD%)x$ zQax!hmr0f|W=FafQP{Pz0>E3X-!kk`BlEx86iHDSWk_nAiHpRH&DEC;cGR&h>-Tcf z?VYuDYYCbkt>kt-Hd@hNYB%b}-`L)ljeetz(ZRb& zvVUcpY(xMGf6@G%mQ|E^B@}A33uh}r>8%cmyDcY&3`MiCN`o z*nz~wRPFAf9NVoa` zMUCVE$tLl!(Py!({W$r}&{IdAEI-1I1Duqrs<$SZ(=L?_(%VNrU0%Hu;if+CU|_VD z&4`;IZ|3v~36GK2Ze|^6TXcEYtTGBP2zebNKO~v_0+;=%U*-7%>GA}4CLmZ^1Dj>R zcDGz2d3g)}Y84ubi-8gLTDt$Fp-GojwmHuLlGHC4Z=uar6jHlNzW|V`hGqLSA8&yK zj}{>ZRBZbXU;eEUN@k#5ESk3=9-T(ZRk_^U@9CCa6QegMF+kI`3MX@z36@39ET(8| zaCntuc*d3l+T6G#RyM%HI2~$QoBh-rl~v}=g&gXOv+qvDaZFfcqT>MfkRK`z?N#2c zPnXN(&0K05QDOAk97_rWL@}&`$bXV+rl?ZHw@{x0P$F4rMImDlV!Mc2fk#8SfzSwD0G;ShnlK?Ei-PTybHhVDw=-qP&3!7Jcd1*ws`YANBfnu$!J@G)) z%l;wHSObFhxB(hSlN*Aq#U)p_>TLtPtbUN8(`Q3|)t@=Pf|>d&SK;dVc4KW`z%>lh z1D6f`dNgWW|O1iRD_&F;;S|n_|+d$TH3pxmfwsY7*fG)I_&$#jK72o)^3$V z<%X5(^fw$Wm58T5<4U(8-=smD3Y6D5(QL&@g&P3SpOYq}>Cu5ystYC6zciA1W6`U0 zqaR38UH1q6DCN`GX$BgE!}x(HM-ry*i(k#Tg}h$eH`0`k<qq${E>m!BjEW zTl=KdJ&a`eI&Ds3^&UpYe`GnAd@FF7vU8c^!~_->k-#;9@9kZ zbhBxQ#s3d0ACFaE$t~pu7bn29;^L7?#6iB{J65VS*7@>#HS(Oq1S=Qr!HjC)vrU3s zdADdKB(}#TVl~C(g(~uxcrKC{7o0xOdvGK8{YOs|8=x&D`m+#ulC5&DU(+PqRqS-} z!ByF14mlMEbds>!glW4Q6$lb9i&s(fK$~Ax-C0v9&&KjhaMBSPnz71IAnl0>XRFPt z)zx4?q3)2_b8d?28haZ54wLg70B;TJ^xWN;-KEd76#&|vB?8kS4K6-cDO+!tYmTbl z_B=_GW{tX;$+*Ln#{BL-1NjBT0=Q(F6~>O$&K!nGCCV@tG_NoNzrb^PK%MBZv@}PS zvrZJPcXhVx6f2!DEfuH^R8IqlsPohoC%unUFMQ!GR85Ax?#cseqDNy}6-L3>KwcS* ze57)@uOhaH0&n@>=SrYombbDxSWGBz^UoP*Vp?4S1`6UZ_8mmYyc@}76j@^vo$pm0 zb*bZI^ogAE+v5NTJHMoBD#-iJ5yhA`Yw^>bx)`PU>Lf%v`+f`dAoN-FC+-!`ysW~t z`^c?gB{N_BDd6Vy&vvS*U3Zgg4;hgT+!2)%Hip6SX7BydSJ%}E$^G5u=yX!Gji;H| zir)rN)h++kVmlvpAON;tdoS)Myur}@gFv2vOz7y{q~%QbL+VIype{pkAsG$rL6@nv zUGvT9a>qYuAMSe}y?hs|!LKnO(zfF`EPXS*7NJNJ1rAK?kjgSvN&{`0I7x1f^@KN& zVT}ez)@)!?ZucD1gYpaBG;=oNmjJGJ&X764I>u+iEesH-zW#0r)EzrBlYrqIo3|dD z_?(E5SQ@Y%!<%A zTw67eF_U;Ye5iWun6BtXDi-3Aw-fO@2F&TS_Rpl9_Y*Ciikp9Vs~&UYHHbPz0;#Iy zK?=Wh!l}FySFiSaKVP{MuYt3fWY{pSxru!2Pf~1GZq(6g!=3B4p&6%kdTS^- z)(?Na{IMI(QOze5IW;#?`W_?qQ!L5$Ijik*`_uAC%x=a`0Wld11rt#b^2~ zhrY-ycsx*m4!vM4!=fU-Y%o9)KY>W*=t9*oOL4JZcP;7IPN zv+_PYO>Z7|7ew}4SdjXd?=+iM;WdkKjXYDbsKLIugwQT-&X&h%mS8uPE@r4XOK@O& zYZJlIdPzXcS-to0=ury*F+n~4RY$$hG96B?Y?{q$#O)$61Sl-U7^!inPi>o`Uh8Qm zy{}Kb2@VP$EKc2{D;~jKxFYt3FcrH**2dXiCY7WxfiL56#CW_ zfDjntb2K%%(Hcmj!|h<%L3G~NGXHbi&3~&c&*lYu^KCgYaYQgwJ77$f9+OW5*h)-x ziUknR!aIHf#4j8kbB=|?8WkRdw$AuwS`IKImREzK-w6z_qR71rQP@4i8r*x@3eN#E1?i7+pm1^ud3V*FKH**wPf8@W}cz z)~~Wk=M6n<(Wex?6MX+!f__J&A^IsWWa7(|%^2q*U8(A52|B7LP;=LBbtY)$K2<;R zj#USgu~n+t<_n6EKbdRIr7O2e?X=*zyf;HO#nb06JBQCAXcN%1t%(@eO~z z*;cm$Q5FIe3>~(cL=}=VFM_|E%M5qH3E~eqIH)41%{KBJS&1J+$#6*EDC%tEl8=_@ zvWzM;r@|qWw@8TF+8cT!1qGYsKB);p@>}0Bf^PWBUo}sjJyJFbL=fQikll@tYWX~Q z@rAE*X3RFRuAGjv4SBMb{QbQL3W0kl`Z7Rsv4SwdBoRfs6rCjEb+@T%kE_;yV%WU< zo#P#vSv`y8Aq z8*X>ztqX);Ffmt z1o*B~%hjB%bU!?lGB1HH$CN*84aM~6c_p<6s9k0OQr{OGd zNxyZQ;+_QjCnb)vrVH`~K78Is3|rG!ph)gStC>K;Ovn=<8y*llPUG$f*eVgv(v$Bt z7IM4M@(MEf0dyN#r14C)Bj_QC2wrE@Jsq;Mu3Nl+(cUD4W|YJ6T>O*DxP?9OWF^(#!Ob+-EC%bHeisX2K`|~;B>p^I`r`OuxmZ975&80 zCceZo?YLoWvISWZxi+?-Z9t0yOE>XWCQiv&rS~+B{m`bnh+lf0QX-A;G9fM}7azE` zE?ZG4+h6uqY~+@UtVX6&gH2Ijjni`{7M*X6_Nl3~5=&YSbR6 zzvmcFD6N56{3LOdxg^7~LgRg>l;*9)xAX)$eF|?QXs-*Zf#yBBOWLOS8z;vR+shu9 zB<_qLG-h~9$SJ>06J63(zL$o~A z>zAX+)N;!t6r>WV1>9VUI!kd}O}aRC{_&u8-6x?gQ9Byw>+ajtvEr_w8>_g_G>0P> zvZVUggA}WZ-vxU0Z3dTlywC>OYIGU52PTQW6Ose!BvVvZ#;ND;tKI$XtK~!TA zm71(3{tX|x(k-M;7Fvx|$7pnXABLlO+~u3EbNrvTb1Ur1iE^7!l;2R3*5bFl#Ta^| zDF*$OifQakLq7ilRUJ$F%q=J+>MtQLw0~i&6FD#sT+!uo>)lELS>@!ypZd{t(wK$R zJPrI-*wVk$NZ3x+w%Jx9!os{o`zLxHj+m2)kJ>yODHD|71ifL%i1+_N)!d>_wYgnr z5DSbfK%m6t0w1!qZ+q_sslBpIlrK3PunDEhPaVDkR@)$%Lc`!M$Su}6Qql`Trp*C(~rdCId~1;;f?28aCcFVxBT|gpd(4CR{1^lVJ_WQ{|8`uM_fH)`BKH)i18)lVjMZnVD?|)u`HlQ2u z?zne}#@nT0El~fAqS=k)omrtV6OP;i-!qAjk%i(7rIW4N*RY8 zv+xu4N?D*qbsf!;Xwm4M+B`Lm^a;m5sWmk3_%-fny>M0>_XBHsWFV@=DE03P#J@dd zwSL^YEsSYfdm4ZsG32i~xf|45QD+Ux;unIol(f_clHUyj_?mwW;yZ@#H4 zXz$K1RyzXfoN%mvSxnP~5&Un)(iEb0$=-51EI@PXxj_vzflSsEv0ht#qA@VZ_sy!# zdsY734fuyd-f}zGudC7xMIh< zKhwwdw7E%xNskh~(&rw7t9Cx=jm)bLWa-#h>l?qz>SOWM?A#_+SsAbOx>TQ{Fm;BH zlN$10+O(#c9J2e0Y&`bcmKVP)?N+w}WE)0rJTWB3`Og1*P+g&%b$83cWWK;mOq|5E z_WtaiPks#ille$Zx!BBe`$TnqebIq@;n4Ej1lcY&=iQ0$EZ|k-81`{+l~7BQP(@qQ#Bg-$mdb)J>nF% zUOVO}tdb1;#3-iVIp-209%K|l@ugP=n~cE^OFTlrTOa0KqWa4`d&as3Vrtha{xDjW LalHo10|5UIqgUPt literal 0 HcmV?d00001 diff --git a/deps/flate2-0.2.7/tests/good-file.gz b/deps/flate2-0.2.7/tests/good-file.gz new file mode 100644 index 0000000000000000000000000000000000000000..f968689cce01efba445a1d33eb4a21aabf551981 GIT binary patch literal 6766 zcmV-!8j4BrBZ80f#~(j`{PFzy`#=8t>(`(E{Q2we|MR%S-so-X+CFp76$KCKQf!GXY>F2 zD7LX!-%n+!rR~wD@zCr~WwE8M?%wpBUG!87Q!T|XS<_Q2xD>Z;T}vLL+EaVj%xht?Phd?WN4ohCb7(_4d@2#?goIcInlhx?iJLZM1G5 z^J(Qi8ArT|KdpW?9dlhe?WeVCTzmc0ID}^RlT)9sKDKVCzs6}gVO@#tpp9$X+G8E2 z18aVbUi_!(AA0g^NS~TI+S*%fPdgjhzN^bzID8*cO6xo zx;mTTqqCLC8rph{<+tiuDI4I%L_VhS*YimrGY07zf z9D4QbT^7aD)APhvuS0j&w$<{CJn>#O5xB}&&&VUMdlO-prgYke6?>XI%H`4K&cNJ>&HrnOxD##XsYQLme(Z+gAEB zZaCD{aDBPk<2M|1DY|rhV?2K2q3)&YnhMLu&xZ6wBOcszhn^b}J}rSk9XgH2b3by? zBJhx7O}(7k(PApL&Mmp8Pmb2Z>lKJT6Hs&m`1j-&Vk`1ti!kWIDo=3Qx<;NdZDYnZ zsQM9n5<0s9Q3xHJ zQs2A*QKn8?S6r58?v04G46hLMiAu`Z(;h<5aKsHIwgbo>A831Gw1ddjbe^>hNUQV{ z0JFm|I@l@Wxge2g14;$KwRpmE34)L-v!sM7mk$EDf?3&;vBh@aGL)^0P6q?_6bZVr z8l)`@Sc~O(t1{I9P#qwf(@DsbDBHs45f(C8K=BZG>aMhKnR=M|273h9I+fsTy%=zW z3XsVY`8&Qe%VH5p52M22iduxjItaZ1+Q~z48S+7efoyy0Tgla?YghpJmb2F6YGI0) z35?cJ9Hw4Eb^TYx2Qum~wGga78gIj*(0PKnSIE6e)&mPAG+EShPR zm#ar*#X7OVv#)mvQ~0qaVwd%GuVE{MN=4CFxz^cHDvcwuH)MeJMRYWtePd>f5{Nyv zuEy+IxAv>};6&|>8euH4Fso!yhM;lZww_On)0usr&*i|JqWYd1N&R}x|K@Fj0(j&6Pjs~=g39k)8moqNBR&VN> zg3)!|-Pm7`7)Vanae?N-3oR~4UF+t41c8gE!qr3)x&|Ep4iltaB{)PWz%k-;C&r_E zz%iM|5#kPt@kyCNic5$Nw8w5bqagJPV8G~;XirLCgT14r7jO2TqoxHA3J(EqO+p6{ zwd^(r5tV!{hvh~jfY7YtP@qAm2psJy>0I&MU;qb<>tS=LYUu@>mOwsiE~JpiMpxtX zhs~ST&E7g5aL8P{^UWFbg4nhf%y&o@T{PC~SPCJ~yyFA@;<5Z>01*Ki$Li`n6fVHJ~#^16Xg+NO9pl zi|@{}H|H4fDXFA7`>WAJua4lr(`If>KWe&W1tHEb{X_>*q^lwi$!(1(-qdpqVy^SO zDq=_;C=UtV7v^YrpuFR{$^7!OAqW++O0U#I{UVm?A;`7Dl@2H2ifl(1*5H1mJv7ud zkrv!9)B&F4)=TSHiOh~D<`8+2Ef_q_eT{f=h6$NMc2!u#$`?aS3jSF{NOwI`@KWQV zck;>xX0--s(;BP~`^ewK5}l{wDjXpv{1#y7V@df6DlMPIU`pvS#g}0E0KO03FX_c# z4d*lt-wV@I>o-W^@I9DbP*KXZWK8F(xH!=_^s%#~w*92Q2Fi8)0nczzaWi!$wHDfvC>2H*7pmTF14XR&Ll#goYe@ zVLf3pcd4OyTru9tei3~Jhm!=f`lg09z)?|)R!~oNxH@|T7nOmYti33>KzSwovROj9 z5^*wB{a4vCLFD8jTnyVtNS|Ccd8!U7^LDw4^gf^-w%E>AG_q_QU$zvK_8}6_q_7MZ|JB)0iel1T;&GZ zXv=JIy5l~$cT4hD=BBI=5bpeBtlx16l#OUwww0j1_`!${$)IBQYXpphRAA%>>FB~TFDU6wZrw=T$YB0(6Ak< z*Y1`>fE%}F88E1VmE4repX<>Ci@K(Z`AY_&bYX@?k}V(iwR8UX!?9Hy+zzv zKD%B_A0beLNHXTmjLH}QzNM?%$?nI3-(~Cs=y>l6ttqq=cD79L<$R6h*NBA_16s~9 zV12~9DF#N1_#iZ8OP6z^NLW>$7E(a}aSc+2O{9hrkPpXiipu%T1m{hGLfi#V?lPN1g z0;ysl)U}`FeIZ3xU~-;3mqJDW*AefIHy+N{m8?+e@-rFti|PUOx;MGUVf+Tz1gaCf zhwv+Qve!;|^yB-4YArz@ou5di3Z~fNa_0xiVpatY!8xyYDMJC&ji0)ZoKR8Zu(IB` z8D3MS^X!cq=g1Z2Mpf^|jfWVRsO+|G;LI8!A}W=&UQj0#264CA3+ZEoNEcPM_2!mx zZYqt4@3#62=_4vB%Kx7BCjXKkL=4G#%j{o%xT#%Q_|H0JFl$jb!8cNXyqdPs1@ zZSS}4GPx?lRrXQ*2G1J#U<>+Jmy0kT9+h)T>X#bbP`ob09!uiaVN-yV z7f3c)(taNj&}bd<087@_;}cJuLr7=I`C7Y<7eJ?Ynv9Q_3Y8A_+2MQPzLn4+g%2Jr zDS=6(31M8uBV&Y3;jc({J7f=EdC2t2Z|@h8o#E9aTph?y*uQZTeXRp=PPsfBbl?dSrU(keh*MZCUaZL{y!sXg6 z*pJCBVfQ8Lej#1p2Iv*7_O00O9k~;{s&$>3eG~%lTxDr8wu9(O83RY-eLLYX`61y0 z51zX!QBi3qQ_DI4m6;iZ?M~S|fo+N=0r|l>y+XiI=dvw+BVA7ZLY<}1r3oFN7^ifk zm9V^!0rX{}B1uAQmcYC>gyF)^$3g}e)hG~s;2a?Ww5x$vHrU=m0_a731w@}tR+%g_GsW1++%_cEeT= zqytn4b#aRw%I^@8JakdvvBUU+(vd+(d*LPgy|Z?zQ|0|z?b|FwA) z(0=_(AXOuc;k#dUIVZY@GK=+#$+!WzY}2oeFLWrF)Ezf7zU)%61DqOii1B5Yi-L5N z|80Ds(=B^NSkK<3_%5#3I-1<7XKYUL5*-HZ}DHNTp+V9 zL`yi;f9liW%nf2W)d1=REDN%h(NB0#InfYR>oB4>I>mAQu)Z>2r=7kjTJ=NvVsUD_LiNtC_(An< ziRyHA59e2Iydito?nn89dbb31eDq5%bsXZI)`{HJX#Mxo}iZUP;N}Uh9(+6vn)an!K(P>%%#z76L zpZdS_BTBv?vl5`B6#%3CI#Pbv!qufL>`akg^F3%WC-w4#Y|OsmIJ{?!^K0 zGqw_adMd&)rR>kHrLbFH3I!lYpJ4icIeRwm%h=JPM2Gbxe+9*&GBO!(IqmzN<01j+ zJ$b)JKQZbotSn<)%f^)^a;+!lD}GSWqA8h@@GBDzf#^iRp?lX>=x&A%>4)t_Pf#Ys z7oM~i(Kq>~s8NePTrYV^{ZsBb7(;lwFG^oYSZPo`{dVz3u@23=CG%A781#X;DfKo9s zn+ilceV*IOCan%#o6Smqa{3Zo((ta-0ytO9vn)(01q2tQ1C=UU&j!B^eMKn;q|6S# z*Jw9uCE7^{0cn%Sd33v&0-HsjG!R@@_w!j^BtX;oGYT*& z5g!78`a{+Yl^pae^^X;Jw~+}wOa0=!l-n#dnco?sX@I(88wu+2_l<39mnYR1_HU+J zv^Ux23+kI>bRz)!p?s>rDB>m2^Yp{`R9}d3U##X3KGheCIWC;}H@=VIm6#sr`?r!G z^~nmf?5`vfwHG{jfAv1Pj>Ht!3&`eCd@(%ccKa399x}Z!pmXC!{@w$kwAK9^*D$~m zK=#%Do$?QOFF)K2gK^Wb6yqJ?PBS5N25YUmdfE;N6DAqkA%K??~rxi7I zY&~I}`bdEKNHL%jjc!#mMaNMC68k%<>;k8ejsGGzL*#GnDI5Q^GH8_MlB1KUTiCfb z=Ij!jm1Nh`niwO;5T~QwH$9>eLO`Y!@&>OA6~L_HUNM=-d!hOzq@$z`zKtyOOH4%l zMVoy_R{BenFqnPO`6Ty8Yr4jqi&me^Z$`ZgP;aa?rOc$GZc;M(+F|{rnygh1>-mu=dkun`I`J&a{27punmq@o% z)_0g;#z2iTP%}>bUv3mmCryO$3?A0O2t8WHARPmpVWc5uO@C162db>BmyeJvD}sDwJ;s?8fJJ#RCuEF)B1HnUwo>zppkqG7Y<2Upfbk;goepGC#RdjcPeQpUkgRXE8#+tg>v$ zkfM^2vovz0eWpZbj5>M@%pT5nvO0GE599oJ&PwzxZ7{X zU-(M7LA=bf^ICfp4&?M+ZrGG;s!Uy@m;G5ADJP{WzfFK%f>@M+=*MmoV2vorNc%qi z_5c`=?J>{DlV_aQM*y`nCm%ht`f-d*5lU!yeFu7_qEPDcR2k1*Idgs5kpjuH6hMWF z)|i3@TVflN%`1i%wV|U1Zn>J4KDfgi*!i{51ZfX4RM$^^gLMaEUR6$wPt7 zO6G$aX?=MJ0VRel`yHYT4;dg+l=bQiQ>cFT9pj9Hq300&G3z&#V?Umi{!ycEuJGX7 zM~E$_Nvd??@#K9uz7GrOu3g)ihnqE!U+P}A)G`nr~JGKvJcIDQ-c)@e95=As|J z9e=D9jmURz$KU#hF)%7(emnlCs2TI4SZ~yL3#Hz;tK0Dx{6*R-7?<@%jmLL= zKq+>i)9Dl%{4@Y)A(1!_rd<8h|D_|Nw#dYxj3>Qh3X#PKH>f|vJ9N&xmOkGusz9`OQi`~$iCmD%JQcoG6z$Yx?k3)Q% zA##`!RVDuzSt{>6I;G019v}N)dUQ$|{B_TQOt_>V9ZQP-PP|CVnvOL1pE&{UpT9JD zJRAOk6#!4{rmrXUuMV~%qJgl}@u%O~qlCijz9*zd$toe;ll7%R(D;+dSogz@7JtN` zJd$61$46(>>`}RX_}=*gk(g#At`6PXh}2N2IDa7Usu&NSxA@`1^#b?eQA*|S2Hsx3 z6bvNY5@v3*U%$YFJ=HW>uZk&@l_f$pzjcFVEs#$M2wzyAwMMZ}$8nqeO4>q$H1Pa3 z`(^c^s*Vf%QW+IJJKDKc%eT154YHuFCSG3S8Y}?{D<^lD^c&TK1;mK1 io::Result>{ + let mut v = Vec::new(); + let f = try!(File::open(path_compressed)); + try!(try!(GzDecoder::new(f)).read_to_end(&mut v)); + Ok(v) +} diff --git a/deps/gcc-0.3.8/.gitignore b/deps/gcc-0.3.8/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/gcc-0.3.8/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/gcc-0.3.8/.travis.yml b/deps/gcc-0.3.8/.travis.yml new file mode 100644 index 000000000..53eaf558c --- /dev/null +++ b/deps/gcc-0.3.8/.travis.yml @@ -0,0 +1,25 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc + - rustdoc --test README.md -L target/debug +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: bnPRXhVawJwerfEWYNzEfzK8Y4GOme0RqyLqQ6E5GU6B1EdCGaPgz8d4q8S2nXCq8IrzbEGo7nJaWptO3iNTnG/NIQ4qcLsQaDCz8ICAZTbS1dTbNByX2S9GyXUxCkaIfRNCSTuRSD276tdgj69VOW3bp0rgUpkpYhoGupmc3VY= +notifications: + email: + on_success: never diff --git a/deps/gcc-0.3.8/Cargo.toml b/deps/gcc-0.3.8/Cargo.toml new file mode 100644 index 000000000..a325082c7 --- /dev/null +++ b/deps/gcc-0.3.8/Cargo.toml @@ -0,0 +1,14 @@ +[package] + +name = "gcc" +version = "0.3.8" +authors = ["Alex Crichton "] +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/gcc-rs" +documentation = "http://alexcrichton.com/gcc-rs" +description = """ +A build-time dependency for Cargo build scripts to assist in invoking the native +C compiler to compile native C code into a static archive to be linked into Rust +code. +""" +keywords = ["build-dependencies"] diff --git a/deps/gcc-0.3.8/LICENSE-APACHE b/deps/gcc-0.3.8/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/gcc-0.3.8/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/gcc-0.3.8/LICENSE-MIT b/deps/gcc-0.3.8/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/gcc-0.3.8/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/gcc-0.3.8/README.md b/deps/gcc-0.3.8/README.md new file mode 100644 index 000000000..63cabe59c --- /dev/null +++ b/deps/gcc-0.3.8/README.md @@ -0,0 +1,82 @@ +# gcc-rs + +[![Build Status](https://travis-ci.org/alexcrichton/gcc-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/gcc-rs) +[![Build status](https://ci.appveyor.com/api/projects/status/onu270iw98h81nwv?svg=true)](https://ci.appveyor.com/project/alexcrichton/gcc-rs) + +[Documentation](http://alexcrichton.com/gcc-rs/gcc/index.html) + +A simple library meant to be used as a build dependency with Cargo packages in +order to build a set of C files into a static archive. + +```rust,no_run +extern crate gcc; + +fn main() { + gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]); +} +``` + +# External configuration via environment variables + +To control the programs and flags used for building, the builder can set a number of different environment variables. +* `CFLAGS` - a series of space seperated flags passed to "gcc". Note that + individual flags cannot currently contain spaces, so doing + something like: "-L=foo\ bar" is not possible. +* `CC` - the actual C compiler used. Note that this is used as an exact + executable name, so (for example) no extra flags can be passed inside + this variable, and the builder must ensure that there aren't any + trailing spaces. This compiler must understand the `-c` flag. For + certain `TARGET`s, it also is assumed to know about other flags (most + common is `-fPIC`). +* `AR` - the `ar` (archiver) executable to use to build the static library. + +Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order: + +1. `_` - for example, `CC_x86_64-unknown-linux-gnu` +1. `_` - for example, `CC_x86_64_unknown_linux_gnu` +1. `_` - for example, `HOST_CC` or `TARGET_CFLAGS` +1. `` - a plain `CC`, `AR` as above. + +If none of these varaibles exist, gcc-rs uses built-in defaults + +In addition to the the above optional environment variables, `gcc-rs` has some functions with hard requirements on some variables supplied by [cargo's build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, and `HOST` variables + +[cargo]: http://doc.crates.io/build-script.html#inputs-to-the-build-script + +# Windows notes + +Currently use of this crate means that Windows users will require gcc to be installed at compile-time. +We recommend the [MinGW-w64](http://mingw-w64.sourceforge.net) distribution +([direct link to the installer][mingw-installer]). +You may also acquite it via [MSYS2](http://msys2.github.io), as explained [here][msys2-help]. +Make sure to install the appropriate architecture corresponding to your installation of rustc. + +Once gcc is installed, it also requires that the directory containing gcc is in the PATH environment variable. + +[mingw-installer]: http://sourceforge.net/projects/mingw-w64/files/latest/download +[msys2-help]: http://github.com/rust-lang/rust#building-on-windows + +# C++ support + +`gcc-rs` supports C++ libraries compilation by using the `cpp` method on `Config`: + +```rust,no_run +extern crate gcc; + +fn main() { + gcc::Config::new() + .cpp(true) // Switch to C++ library compilation. + .file("foo.cpp") + .compile("libfoo.a"); +} +``` + +When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env variables are used instead of `CC` and `CFLAGS` and the C++ standard library is linked to the crate target. + +# License + +`gcc-rs` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/gcc-0.3.8/appveyor.yml b/deps/gcc-0.3.8/appveyor.yml new file mode 100644 index 000000000..f74c851ad --- /dev/null +++ b/deps/gcc-0.3.8/appveyor.yml @@ -0,0 +1,11 @@ +install: + - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' + - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/gcc-0.3.8/src/lib.rs b/deps/gcc-0.3.8/src/lib.rs new file mode 100644 index 000000000..41421c6ee --- /dev/null +++ b/deps/gcc-0.3.8/src/lib.rs @@ -0,0 +1,498 @@ +//! A library for build scripts to compile custom C code +//! +//! This library is intended to be used as a `build-dependencies` entry in +//! `Cargo.toml`: +//! +//! ```toml +//! [build-dependencies] +//! gcc = "0.2" +//! ``` +//! +//! The purpose of this crate is to provide the utility functions necessary to +//! compile C code into a static archive which is then linked into a Rust crate. +//! The top-level `compile_library` function serves as a convenience and more +//! advanced configuration is available through the `Config` builder. +//! +//! This crate will automatically detect situations such as cross compilation or +//! other environment variables set by Cargo and will build code appropriately. +//! +//! # Examples +//! +//! Use the default configuration: +//! +//! ```no_run +//! extern crate gcc; +//! +//! fn main() { +//! gcc::compile_library("libfoo.a", &["src/foo.c"]); +//! } +//! ``` +//! +//! Use more advanced configuration: +//! +//! ```no_run +//! extern crate gcc; +//! +//! fn main() { +//! gcc::Config::new() +//! .file("src/foo.c") +//! .define("FOO", Some("bar")) +//! .include("src") +//! .compile("libfoo.a"); +//! } +//! ``` + +#![doc(html_root_url = "http://alexcrichton.com/gcc-rs")] +#![cfg_attr(test, deny(warnings))] + +use std::env; +use std::ffi::OsString; +use std::fs; +use std::io; +use std::path::{PathBuf, Path}; +use std::process::{Command, Stdio}; + +/// Extra configuration to pass to gcc. +pub struct Config { + include_directories: Vec, + definitions: Vec<(String, Option)>, + objects: Vec, + flags: Vec, + files: Vec, + cpp: bool, + cpp_link_stdlib: Option, + cpp_set_stdlib: Option, +} + +/// Returns the default C++ standard library for the current target: `libc++` +/// for OS X and `libstdc++` for anything else. +fn target_default_cpp_stdlib() -> Option<&'static str> { + let target = getenv_unwrap("TARGET"); + if target.contains("msvc") { + None + } else if target.contains("darwin") { + Some("c++") + } else { + Some("stdc++") + } +} + +fn getenv(v: &str) -> Option { + let r = env::var(v).ok(); + println!("{} = {:?}", v, r); + r +} + +fn getenv_unwrap(v: &str) -> String { + match getenv(v) { + Some(s) => s, + None => fail(&format!("environment variable `{}` not defined", v)), + } +} + +/// Compile a library from the given set of input C files. +/// +/// This will simply compile all files into object files and then assemble them +/// into the output. This will read the standard environment variables to detect +/// cross compilations and such. +/// +/// This function will also print all metadata on standard output for Cargo. +/// +/// # Example +/// +/// ```no_run +/// gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]); +/// ``` +pub fn compile_library(output: &str, files: &[&str]) { + let mut c = Config::new(); + for f in files.iter() { + c.file(*f); + } + c.compile(output) +} + +impl Config { + /// Construct a new instance of a blank set of configuration. + /// + /// This builder is finished with the `compile` function. + pub fn new() -> Config { + Config { + include_directories: Vec::new(), + definitions: Vec::new(), + objects: Vec::new(), + flags: Vec::new(), + files: Vec::new(), + cpp: false, + cpp_link_stdlib: target_default_cpp_stdlib().map(|s| s.into()), + cpp_set_stdlib: None, + } + } + + /// Add a directory to the `-I` or include path for headers + pub fn include>(&mut self, dir: P) -> &mut Config { + self.include_directories.push(dir.as_ref().to_path_buf()); + self + } + + /// Specify a `-D` variable with an optional value. + pub fn define(&mut self, var: &str, val: Option<&str>) -> &mut Config { + self.definitions.push((var.to_string(), val.map(|s| s.to_string()))); + self + } + + /// Add an arbitrary object file to link in + pub fn object>(&mut self, obj: P) -> &mut Config { + self.objects.push(obj.as_ref().to_path_buf()); + self + } + + /// Add an arbitrary flag to the invocation of the compiler + pub fn flag(&mut self, flag: &str) -> &mut Config { + self.flags.push(flag.to_string()); + self + } + + /// Add a file which will be compiled + pub fn file>(&mut self, p: P) -> &mut Config { + self.files.push(p.as_ref().to_path_buf()); + self + } + + /// Set C++ support. + /// + /// The other `cpp_*` options will only become active if this is set to + /// `true`. + pub fn cpp(&mut self, cpp: bool) -> &mut Config { + self.cpp = cpp; + self + } + + /// Set the standard library to link against when compiling with C++ + /// support. + /// + /// The default value of this property depends on the current target: On + /// OS X `Some("c++")` is used, when compiling for a Visual Studio based + /// target `None` is used and for other targets `Some("stdc++")` is used. + /// + /// A value of `None` indicates that no automatic linking should happen, + /// otherwise cargo will link against the specified library. + /// + /// The given library name must not contain the `lib` prefix. + pub fn cpp_link_stdlib(&mut self, cpp_link_stdlib: Option<&str>) -> &mut Config { + self.cpp_link_stdlib = cpp_link_stdlib.map(|s| s.into()); + self + } + + /// Force the C++ compiler to use the specified standard library. + /// + /// Setting this option will automatically set `cpp_link_stdlib` to the same + /// value. + /// + /// The default value of this option is always `None`. + /// + /// This option has no effect when compiling for a Visual Studio based + /// target. + /// + /// This option sets the `-stdlib` flag, which is only supported by some + /// compilers (clang, icc) but not by others (gcc). The library will not + /// detect which compiler is used, as such it is the responsibility of the + /// caller to ensure that this option is only used in conjuction with a + /// compiler which supports the `-stdlib` flag. + /// + /// A value of `None` indicates that no specific C++ standard library should + /// be used, otherwise `-stdlib` is added to the compile invocation. + /// + /// The given library name must not contain the `lib` prefix. + pub fn cpp_set_stdlib(&mut self, cpp_set_stdlib: Option<&str>) -> &mut Config { + self.cpp_set_stdlib = cpp_set_stdlib.map(|s| s.into()); + + self.cpp_link_stdlib(cpp_set_stdlib); + + self + } + + /// Run the compiler, generating the file `output` + /// + /// The name `output` must begin with `lib` and end with `.a` + pub fn compile(&self, output: &str) { + assert!(output.starts_with("lib")); + assert!(output.ends_with(".a")); + let lib_name = &output[3..output.len() - 2]; + + let target = getenv_unwrap("TARGET"); + let src = PathBuf::from(getenv_unwrap("CARGO_MANIFEST_DIR")); + let dst = PathBuf::from(getenv_unwrap("OUT_DIR")); + let mut objects = Vec::new(); + for file in self.files.iter() { + let mut cmd = self.compile_cmd(&target); + cmd.arg(src.join(file)); + + let obj = dst.join(file).with_extension("o"); + fs::create_dir_all(&obj.parent().unwrap()).unwrap(); + if target.contains("msvc") { + let mut s = OsString::from("/Fo:"); + s.push(&obj); + cmd.arg(s); + } else { + cmd.arg("-o").arg(&obj); + } + run(&mut cmd, &self.compiler(&target)); + objects.push(obj); + } + + if target.contains("msvc") { + let mut out = OsString::from("/OUT:"); + out.push(dst.join(output)); + run(Command::new("lib").arg(out).args(&objects).args(&self.objects), + "lib"); + + // The Rust compiler will look for libfoo.a and foo.lib, but the + // MSVC linker will also be passed foo.lib, so be sure that both + // exist for now. + let lib_dst = dst.join(format!("{}.lib", lib_name)); + let _ = fs::remove_file(&lib_dst); + fs::hard_link(dst.join(output), lib_dst).unwrap(); + } else { + run(Command::new(&ar(&target)).arg("crus") + .arg(&dst.join(output)) + .args(&objects) + .args(&self.objects), + &ar(&target)); + } + println!("cargo:rustc-link-search=native={}", dst.display()); + println!("cargo:rustc-link-lib=static={}", + &output[3..output.len() - 2]); + + // Add specific C++ libraries, if enabled. + if self.cpp { + if let Some(ref stdlib) = self.cpp_link_stdlib { + println!("cargo:rustc-link-lib={}", stdlib); + } + } + } + + fn compiler(&self, target: &str) -> String { + if self.cpp { + gxx(target) + } else { + gcc(target) + } + } + + fn compile_flags(&self) -> Vec { + if self.cpp { + cxxflags() + } else { + cflags() + } + } + + fn compile_cmd(&self, target: &str) -> Command { + let opt_level = getenv_unwrap("OPT_LEVEL"); + let profile = getenv_unwrap("PROFILE"); + println!("{} {}", profile, opt_level); + + let mut cmd = Command::new(self.compiler(&target)); + + if target.contains("msvc") { + cmd.arg("/c"); + cmd.arg("/MD"); // link against msvcrt.dll for now + cmd.arg(format!("/O{}", opt_level)); + } else { + cmd.arg(format!("-O{}", opt_level)); + cmd.arg("-c"); + cmd.arg("-ffunction-sections").arg("-fdata-sections"); + } + cmd.args(&self.compile_flags()); + + if target.contains("-ios") { + cmd.args(&ios_flags(&target)); + } else if !target.contains("msvc") { + if target.contains("windows") { + cmd.arg("-mwin32"); + } + + if target.contains("i686") { + cmd.arg("-m32"); + } else if target.contains("x86_64") { + cmd.arg("-m64"); + } + + if !target.contains("i686") { + cmd.arg("-fPIC"); + } + } + + if self.cpp && !target.contains("msvc") { + if let Some(ref stdlib) = self.cpp_set_stdlib { + cmd.arg(&format!("-stdlib=lib{}", stdlib)); + } + } + + for directory in self.include_directories.iter() { + cmd.arg(if target.contains("msvc") {"/I"} else {"-I"}); + cmd.arg(directory); + } + + for flag in self.flags.iter() { + cmd.arg(flag); + } + + for &(ref key, ref value) in self.definitions.iter() { + let lead = if target.contains("msvc") {"/"} else {"-"}; + if let &Some(ref value) = value { + cmd.arg(&format!("{}D{}={}", lead, key, value)); + } else { + cmd.arg(&format!("{}D{}", lead, key)); + } + } + return cmd; + } +} + +fn run(cmd: &mut Command, program: &str) { + println!("running: {:?}", cmd); + let status = match cmd.status() { + Ok(status) => status, + Err(ref e) if e.kind() == io::ErrorKind::NotFound => { + let extra = if cfg!(windows) { + " (see https://github.com/alexcrichton/gcc-rs#windows-notes \ + for help)" + } else { + "" + }; + fail(&format!("failed to execute command: {}\nIs `{}` \ + not installed?{}", e, program, extra)); + } + Err(e) => fail(&format!("failed to execute command: {}", e)), + }; + if !status.success() { + fail(&format!("command did not execute successfully, got: {}", status)); + } +} + +fn get_var(var_base: &str) -> Result { + let target = getenv_unwrap("TARGET"); + let host = getenv_unwrap("HOST"); + let kind = if host == target {"HOST"} else {"TARGET"}; + let target_u = target.replace("-", "_"); + let res = getenv(&format!("{}_{}", var_base, target)) + .or_else(|| getenv(&format!("{}_{}", var_base, target_u))) + .or_else(|| getenv(&format!("{}_{}", kind, var_base))) + .or_else(|| getenv(var_base)); + + match res { + Some(res) => Ok(res), + None => Err("Could not get environment variable".to_string()), + } +} + +fn gcc(target: &str) -> String { + let is_android = target.find("android").is_some(); + + get_var("CC").unwrap_or(if cfg!(windows) { + if target.contains("msvc") { + "cl".to_string() + } else { + "gcc".to_string() + } + } else if is_android { + format!("{}-gcc", target) + } else { + "cc".to_string() + }) +} + +fn gxx(target: &str) -> String { + let is_android = target.find("android").is_some(); + + get_var("CXX").unwrap_or(if cfg!(windows) { + if target.contains("msvc") { + "cl".to_string() + } else { + "g++".to_string() + } + } else if is_android { + format!("{}-g++", target) + } else { + "c++".to_string() + }) +} + +fn ar(target: &str) -> String { + let is_android = target.find("android").is_some(); + + get_var("AR").unwrap_or(if is_android { + format!("{}-ar", target) + } else { + "ar".to_string() + }) +} + +fn envflags(name: &str) -> Vec { + get_var(name).unwrap_or(String::new()) + .split(|c: char| c.is_whitespace()).filter(|s| !s.is_empty()) + .map(|s| s.to_string()) + .collect() +} + +fn cflags() -> Vec { + envflags("CFLAGS") +} + +fn cxxflags() -> Vec { + envflags("CXXFLAGS") +} + +fn ios_flags(target: &str) -> Vec { + enum ArchSpec { + Device(&'static str), + Simulator(&'static str), + } + + let mut res = Vec::new(); + + let arch = target.split('-').nth(0).expect("expected target in format `arch-vendor-os`"); + let arch = match arch { + "arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"), + "armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"), + "arm64" | "aarch64" => ArchSpec::Device("arm64"), + "i386" | "i686" => ArchSpec::Simulator("-m32"), + "x86_64" => ArchSpec::Simulator("-m64"), + _ => unreachable!("Unknown arch for iOS target") + }; + + let sdk = match arch { + ArchSpec::Device(arch) => { + res.push("-arch".to_string()); + res.push(arch.to_string()); + "iphoneos" + }, + ArchSpec::Simulator(arch) => { + res.push(arch.to_string()); + "iphonesimulator" + } + }; + + println!("Detecting iOS SDK path for {}", sdk); + let sdk_path = Command::new("xcrun") + .arg("--show-sdk-path") + .arg("--sdk") + .arg(sdk) + .stderr(Stdio::inherit()) + .output() + .unwrap() + .stdout; + + let sdk_path = String::from_utf8(sdk_path).unwrap(); + + res.push("-isysroot".to_string()); + res.push(sdk_path.trim().to_string()); + + res +} + +fn fail(s: &str) -> ! { + println!("\n\n{}\n\n", s); + panic!() +} diff --git a/deps/git2-0.2.12/.gitignore b/deps/git2-0.2.12/.gitignore new file mode 100644 index 000000000..2a729c83f --- /dev/null +++ b/deps/git2-0.2.12/.gitignore @@ -0,0 +1,3 @@ +target +Cargo.lock +src/main.rs diff --git a/deps/git2-0.2.12/.gitmodules b/deps/git2-0.2.12/.gitmodules new file mode 100644 index 000000000..95c45cce4 --- /dev/null +++ b/deps/git2-0.2.12/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libgit2-sys/libgit2"] + path = libgit2-sys/libgit2 + url = https://github.com/libgit2/libgit2 diff --git a/deps/git2-0.2.12/.travis.yml b/deps/git2-0.2.12/.travis.yml new file mode 100644 index 000000000..9578d3bc3 --- /dev/null +++ b/deps/git2-0.2.12/.travis.yml @@ -0,0 +1,30 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - | + [ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --manifest-path=git2-curl/Cargo.toml + - cargo doc --manifest-path=git2-curl/Cargo.toml +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '' > git2-curl/target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n git2-curl/target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + - secure: OUEJN91dVSqpWtn8uDgGQJVGr6k9PuHrtOfpIgztIHWHiEXQVvdiuobm5iPqcpiXl+LDUIpRnwrH6WLIiWQodTRvdfDx/mJ14uKTXS354V7zV9yNd4mc7AhHvV8tNl+3zJQlPir9s1FrFu+6YEMuxilFgeLRqSXoeSVprVB+Fwo= + - secure: KgyhQ5rVcuSUxgsABVd85KDajPjLlEUDll2+z+TTZB5zdowoGgqDH/Iqp1eXqsjerh3wgR36k3E9Dhb0mLJA51pZkfX9rxXNWU+gWr3l99TIHSuVsqlYtSMTR2Fjfz3W00jL6BQTZb8PMJMRzc3HotJ2qY+nCXDeik4ifVwwW3A= +notifications: + email: + on_success: never +os: + - linux + - osx diff --git a/deps/git2-0.2.12/Cargo.toml b/deps/git2-0.2.12/Cargo.toml new file mode 100644 index 000000000..023e2cfcd --- /dev/null +++ b/deps/git2-0.2.12/Cargo.toml @@ -0,0 +1,31 @@ +[package] + +name = "git2" +version = "0.2.12" +authors = ["Alex Crichton "] +license = "MIT/Apache-2.0" +readme = "README.md" +keywords = ["git"] +repository = "https://github.com/alexcrichton/git2-rs" +homepage = "https://github.com/alexcrichton/git2-rs" +documentation = "http://alexcrichton.com/git2-rs" +description = """ +Bindings to libgit2 for interoperating with git repositories. This library is +both threadsafe and memory safe and allows both reading and writing git +repositories. +""" + +[dependencies] +url = "0.2" +bitflags = "0.1" +libc = "0.1" +libgit2-sys = { path = "libgit2-sys", version = "0.2.3" } + +[dev-dependencies] +docopt = "0.6" +rustc-serialize = "0.3" +time = "0.1" +tempdir = "0.3" + +[features] +unstable = [] diff --git a/deps/git2-0.2.12/LICENSE-APACHE b/deps/git2-0.2.12/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/git2-0.2.12/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/git2-0.2.12/LICENSE-MIT b/deps/git2-0.2.12/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/git2-0.2.12/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/git2-0.2.12/README.md b/deps/git2-0.2.12/README.md new file mode 100644 index 000000000..3b2816158 --- /dev/null +++ b/deps/git2-0.2.12/README.md @@ -0,0 +1,31 @@ +# git2-rs + +[![Build Status](https://travis-ci.org/alexcrichton/git2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/git2-rs) + +[Documentation](http://alexcrichton.com/git2-rs/git2/index.html) + +libgit2 bindings for Rust + +```toml +[dependencies] +git2 = "0.2" +``` + +## Building git2-rs + +First, you'll need to install _CMake_ and _pkg-config_ if you don't already +have libgit2 installed elsewhere on the system. Afterwards, just run: + +```sh +$ git clone --recursive https://github.com/alexcrichton/git2-rs +$ cd git2-rs +$ cargo build +``` + +# License + +`git2-rs` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/git2-0.2.12/examples/add.rs b/deps/git2-0.2.12/examples/add.rs new file mode 100644 index 000000000..d4cb718f4 --- /dev/null +++ b/deps/git2-0.2.12/examples/add.rs @@ -0,0 +1,84 @@ +/* + * libgit2 "add" example - shows how to modify the index + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] +#![allow(trivial_casts)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use std::path::Path; +use docopt::Docopt; +use git2::Repository; + +#[derive(RustcDecodable)] +struct Args { + arg_spec: Vec, + flag_dry_run: bool, + flag_verbose: bool, + flag_update: bool, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let repo = try!(Repository::open(&Path::new("."))); + let mut index = try!(repo.index()); + + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { + let status = repo.status_file(path).unwrap(); + + let ret = if status.contains(git2::STATUS_WT_MODIFIED) || + status.contains(git2::STATUS_WT_NEW) { + println!("add '{}'", path.display()); + 0 + } else { + 1 + }; + + if args.flag_dry_run {1} else {ret} + }; + let cb = if args.flag_verbose || args.flag_update { + Some(cb as &mut git2::IndexMatchedPath) + } else { + None + }; + + if args.flag_update { + try!(index.update_all(args.arg_spec.iter(), cb)); + } else { + try!(index.add_all(args.arg_spec.iter(), git2::ADD_DEFAULT, cb)); + } + + try!(index.write()); + Ok(()) +} + +fn main() { + const USAGE: &'static str = " +usage: add [options] [--] [..] + +Options: + -n, --dry-run dry run + -v, --verbose be verbose + -u, --update update tracked files + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/blame.rs b/deps/git2-0.2.12/examples/blame.rs new file mode 100644 index 000000000..b51e223d9 --- /dev/null +++ b/deps/git2-0.2.12/examples/blame.rs @@ -0,0 +1,105 @@ +/* + * libgit2 "blame" example - shows how to use the blame API + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::{Repository, BlameOptions}; +use std::path::Path; +use std::io::{BufReader, BufRead}; + +#[derive(RustcDecodable)] #[allow(non_snake_case)] +struct Args { + arg_path: String, + arg_spec: Option, + flag_M: bool, + flag_C: bool, + flag_F: bool, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let repo = try!(Repository::open(".")); + let path = Path::new(&args.arg_path[..]); + + // Prepare our blame options + let mut opts = BlameOptions::new(); + opts.track_copies_same_commit_moves(args.flag_M) + .track_copies_same_commit_copies(args.flag_C) + .first_parent(args.flag_F); + + let mut commit_id = "HEAD".to_string(); + + // Parse spec + if let Some(spec) = args.arg_spec.as_ref() { + + let revspec = try!(repo.revparse(spec)); + + let (oldest, newest) = if revspec.mode().contains(git2::REVPARSE_SINGLE) { + (None, revspec.from()) + } else if revspec.mode().contains(git2::REVPARSE_RANGE) { + (revspec.from(), revspec.to()) + } else { + (None, None) + }; + + if let Some(commit) = oldest { + opts.oldest_commit(commit.id()); + } + + if let Some(commit) = newest { + opts.newest_commit(commit.id()); + if !commit.id().is_zero() { + commit_id = format!("{}", commit.id()) + } + } + + } + + let spec = format!("{}:{}", commit_id, path.display()); + let blame = try!(repo.blame_file(path, Some(&mut opts))); + let object = try!(repo.revparse_single(&spec[..])); + let blob = try!(repo.find_blob(object.id())); + let reader = BufReader::new(blob.content()); + + for (i, line) in reader.lines().enumerate() { + if let (Ok(line), Some(hunk)) = (line, blame.get_line(i+1)) { + let sig = hunk.final_signature(); + println!("{} {} <{}> {}", hunk.final_commit_id(), + String::from_utf8_lossy(sig.name_bytes()), + String::from_utf8_lossy(sig.email_bytes()), line); + } + } + + Ok(()) +} + +fn main() { + const USAGE: &'static str = " +usage: blame [options] [] + +Options: + -M find line moves within and across files + -C find line copies within and across files + -F follow only the first parent commits +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/cat-file.rs b/deps/git2-0.2.12/examples/cat-file.rs new file mode 100644 index 000000000..d9be6c068 --- /dev/null +++ b/deps/git2-0.2.12/examples/cat-file.rs @@ -0,0 +1,143 @@ +/* + * libgit2 "cat-file" example - shows how to print data from the ODB + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use std::io::{self, Write}; + +use docopt::Docopt; +use git2::{Repository, ObjectType, Blob, Commit, Signature, Tag, Tree}; + +#[derive(RustcDecodable)] +struct Args { + arg_object: String, + flag_t: bool, + flag_s: bool, + flag_e: bool, + flag_p: bool, + flag_q: bool, + flag_v: bool, + flag_git_dir: Option, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); + let repo = try!(Repository::open(path)); + + let obj = try!(repo.revparse_single(&args.arg_object)); + if args.flag_v && !args.flag_q { + println!("{} {}\n--", obj.kind().unwrap().str(), obj.id()); + } + + if args.flag_t { + println!("{}", obj.kind().unwrap().str()); + } else if args.flag_s { + /* ... */ + } else if args.flag_e { + /* ... */ + } else if args.flag_p { + match obj.kind() { + Some(ObjectType::Blob) => { + show_blob(obj.as_blob().unwrap()); + } + Some(ObjectType::Commit) => { + show_commit(obj.as_commit().unwrap()); + } + Some(ObjectType::Tag) => { + show_tag(obj.as_tag().unwrap()); + } + Some(ObjectType::Tree) => { + show_tree(obj.as_tree().unwrap()); + } + Some(ObjectType::Any) | None => { + println!("unknown {}", obj.id()) + } + } + } + Ok(()) +} + +fn show_blob(blob: &Blob) { + io::stdout().write_all(blob.content()).unwrap(); +} + +fn show_commit(commit: &Commit) { + println!("tree {}", commit.tree_id()); + for parent in commit.parent_ids() { + println!("parent {}", parent); + } + show_sig("author", Some(commit.author())); + show_sig("committer", Some(commit.committer())); + if let Some(msg) = commit.message() { + println!("\n{}", msg); + } +} + +fn show_tag(tag: &Tag) { + println!("object {}", tag.target_id()); + println!("type {}", tag.target_type().unwrap().str()); + println!("tag {}", tag.name().unwrap()); + show_sig("tagger", tag.tagger()); + + if let Some(msg) = tag.message() { + println!("\n{}", msg); + } +} + +fn show_tree(tree: &Tree) { + for entry in tree.iter() { + println!("{:06o} {} {}\t{}", + entry.filemode(), + entry.kind().unwrap().str(), + entry.id(), + entry.name().unwrap()); + } +} + +fn show_sig(header: &str, sig: Option) { + let sig = match sig { Some(s) => s, None => return }; + let offset = sig.when().offset_minutes(); + let (sign, offset) = if offset < 0 {('-', -offset)} else {('+', offset)}; + let (hours, minutes) = (offset / 60, offset % 60); + println!("{} {} {} {}{:02}{:02}", + header, sig, sig.when().seconds(), sign, hours, minutes); + +} + +fn main() { + const USAGE: &'static str = " +usage: cat-file (-t | -s | -e | -p) [options] + +Options: + -t show the object type + -s show the object size + -e suppress all output + -p pretty print the contents of the object + -q suppress output + -v use verbose output + --git-dir use the specified directory as the base directory + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/clone.rs b/deps/git2-0.2.12/examples/clone.rs new file mode 100644 index 000000000..a2fde4bf8 --- /dev/null +++ b/deps/git2-0.2.12/examples/clone.rs @@ -0,0 +1,117 @@ +/* + * libgit2 "clone" example + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::build::{RepoBuilder, CheckoutBuilder}; +use git2::{RemoteCallbacks, Progress}; +use std::cell::RefCell; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; + +#[derive(RustcDecodable)] +struct Args { + arg_url: String, + arg_path: String, +} + +struct State { + progress: Option>, + total: usize, + current: usize, + path: PathBuf, + newline: bool, +} + +fn print(state: &mut State) { + let stats = state.progress.as_ref().unwrap(); + let network_pct = (100 * stats.received_objects()) / stats.total_objects(); + let index_pct = (100 * stats.indexed_objects()) / stats.total_objects(); + let co_pct = if state.total > 0 { + (100 * state.current) / state.total + } else { + 0 + }; + let kbytes = stats.received_bytes() / 1024; + if stats.received_objects() == stats.total_objects() && false { + if !state.newline { + println!(""); + state.newline = true; + } + print!("Resolving deltas {}/{}\r", stats.indexed_deltas(), + stats.total_deltas()); + } else { + print!("net {:3}% ({:4} kb, {:5}/{:5}) / idx {:3}% ({:5}/{:5}) \ + / chk {:3}% ({:4}/{:4}) {}\r", + network_pct, kbytes, stats.received_objects(), + stats.total_objects(), + index_pct, stats.indexed_objects(), stats.total_objects(), + co_pct, state.current, state.total, state.path.display()); + } + io::stdout().flush().unwrap(); +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let state = RefCell::new(State { + progress: None, + total: 0, + current: 0, + path: PathBuf::from("."), + newline: false, + }); + let mut cb = RemoteCallbacks::new(); + cb.transfer_progress(|stats| { + let mut state = state.borrow_mut(); + state.progress = Some(stats.to_owned()); + print(&mut *state); + true + }); + + let mut co = CheckoutBuilder::new(); + co.progress(|path, cur, total| { + let mut state = state.borrow_mut(); + state.path = path.to_path_buf(); + state.current = cur; + state.total = total; + print(&mut *state); + }); + + try!(RepoBuilder::new().remote_callbacks(cb).with_checkout(co) + .clone(&args.arg_url, Path::new(&args.arg_path))); + println!(""); + + Ok(()) +} + +fn main() { + const USAGE: &'static str = " +usage: add [options] + +Options: + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} + diff --git a/deps/git2-0.2.12/examples/diff.rs b/deps/git2-0.2.12/examples/diff.rs new file mode 100644 index 000000000..b9a356d4a --- /dev/null +++ b/deps/git2-0.2.12/examples/diff.rs @@ -0,0 +1,283 @@ +/* + * libgit2 "diff" example - shows how to use the diff API + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use std::str; + +use docopt::Docopt; +use git2::{Repository, Error, Object, ObjectType, DiffOptions, Diff}; +use git2::{DiffFindOptions, DiffFormat}; + +#[derive(RustcDecodable)] #[allow(non_snake_case)] +struct Args { + arg_from_oid: Option, + arg_to_oid: Option, + flag_patch: bool, + flag_cached: bool, + flag_nocached: bool, + flag_name_only: bool, + flag_name_status: bool, + flag_raw: bool, + flag_format: Option, + flag_color: bool, + flag_no_color: bool, + flag_R: bool, + flag_text: bool, + flag_ignore_space_at_eol: bool, + flag_ignore_space_change: bool, + flag_ignore_all_space: bool, + flag_ignored: bool, + flag_untracked: bool, + flag_patience: bool, + flag_minimal: bool, + flag_stat: bool, + flag_numstat: bool, + flag_shortstat: bool, + flag_summary: bool, + flag_find_renames: Option, + flag_find_copies: Option, + flag_find_copies_harder: bool, + flag_break_rewrites: bool, + flag_unified: Option, + flag_inter_hunk_context: Option, + flag_abbrev: Option, + flag_src_prefix: Option, + flag_dst_prefix: Option, + flag_git_dir: Option, +} + +const RESET: &'static str = "\u{1b}[m"; +const BOLD: &'static str = "\u{1b}[1m"; +const RED: &'static str = "\u{1b}[31m"; +const GREEN: &'static str = "\u{1b}[32m"; +const CYAN: &'static str = "\u{1b}[36m"; + +#[derive(PartialEq, Eq, Copy, Clone)] +enum Cache { Normal, Only, None } + +fn run(args: &Args) -> Result<(), Error> { + let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); + let repo = try!(Repository::open(path)); + + // Prepare our diff options based on the arguments given + let mut opts = DiffOptions::new(); + opts.reverse(args.flag_R) + .force_text(args.flag_text) + .ignore_whitespace_eol(args.flag_ignore_space_at_eol) + .ignore_whitespace_change(args.flag_ignore_space_change) + .ignore_whitespace(args.flag_ignore_all_space) + .include_ignored(args.flag_ignored) + .include_untracked(args.flag_untracked) + .patience(args.flag_patience) + .minimal(args.flag_minimal); + if let Some(amt) = args.flag_unified { opts.context_lines(amt); } + if let Some(amt) = args.flag_inter_hunk_context { opts.interhunk_lines(amt); } + if let Some(amt) = args.flag_abbrev { opts.id_abbrev(amt); } + if let Some(ref s) = args.flag_src_prefix { opts.old_prefix(&s); } + if let Some(ref s) = args.flag_dst_prefix { opts.new_prefix(&s); } + if let Some("diff-index") = args.flag_format.as_ref().map(|s| &s[..]) { + opts.id_abbrev(40); + } + + // Prepare the diff to inspect + let t1 = try!(tree_to_treeish(&repo, args.arg_from_oid.as_ref())); + let t2 = try!(tree_to_treeish(&repo, args.arg_to_oid.as_ref())); + let head = try!(tree_to_treeish(&repo, Some(&"HEAD".to_string()))).unwrap(); + let mut diff = match (t1, t2, args.cache()) { + (Some(t1), Some(t2), _) => { + try!(Diff::tree_to_tree(&repo, t1.as_tree(), t2.as_tree(), + Some(&mut opts))) + } + (t1, None, Cache::None) => { + let t1 = t1.unwrap_or(head); + try!(Diff::tree_to_workdir(&repo, t1.as_tree(), Some(&mut opts))) + } + (t1, None, Cache::Only) => { + let t1 = t1.unwrap_or(head); + try!(Diff::tree_to_index(&repo, t1.as_tree(), None, Some(&mut opts))) + } + (Some(t1), None, _) => { + try!(Diff::tree_to_workdir_with_index(&repo, t1.as_tree(), + Some(&mut opts))) + } + (None, None, _) => { + try!(Diff::index_to_workdir(&repo, None, Some(&mut opts))) + } + (None, Some(_), _) => unreachable!(), + }; + + // Apply rename and copy detection if requested + if args.flag_break_rewrites || args.flag_find_copies_harder || + args.flag_find_renames.is_some() || args.flag_find_copies.is_some() + { + let mut opts = DiffFindOptions::new(); + if let Some(t) = args.flag_find_renames { + opts.rename_threshold(t); + opts.renames(true); + } + if let Some(t) = args.flag_find_copies { + opts.copy_threshold(t); + opts.copies(true); + } + opts.copies_from_unmodified(args.flag_find_copies_harder) + .rewrites(args.flag_break_rewrites); + try!(diff.find_similar(Some(&mut opts))); + } + + // Generate simple output + let stats = args.flag_stat | args.flag_numstat | args.flag_shortstat | + args.flag_summary; + if stats { + try!(print_stats(&diff, args)); + } + if args.flag_patch || !stats { + if args.color() { print!("{}", RESET); } + let mut last_color = None; + try!(diff.print(args.diff_format(), |_delta, _hunk, line| { + if args.color() { + let next = match line.origin() { + '+' => Some(GREEN), + '-' => Some(RED), + '>' => Some(GREEN), + '<' => Some(RED), + 'F' => Some(BOLD), + 'H' => Some(CYAN), + _ => None + }; + if args.color() && next != last_color { + if last_color == Some(BOLD) || next == Some(BOLD) { + print!("{}", RESET); + } + print!("{}", next.unwrap_or(RESET)); + last_color = next; + } + } + + match line.origin() { + '+' | '-' | ' ' => print!("{}", line.origin()), + _ => {} + } + print!("{}", str::from_utf8(line.content()).unwrap()); + true + })); + if args.color() { print!("{}", RESET); } + } + + Ok(()) +} + +fn print_stats(diff: &Diff, args: &Args) -> Result<(), Error> { + let stats = try!(diff.stats()); + let mut format = git2::DIFF_STATS_NONE; + if args.flag_stat { + format = format | git2::DIFF_STATS_FULL; + } + if args.flag_shortstat { + format = format | git2::DIFF_STATS_SHORT; + } + if args.flag_numstat { + format = format | git2::DIFF_STATS_NUMBER; + } + if args.flag_summary { + format = format | git2::DIFF_STATS_INCLUDE_SUMMARY; + } + let buf = try!(stats.to_buf(format, 80)); + print!("{}", str::from_utf8(&*buf).unwrap()); + Ok(()) +} + +fn tree_to_treeish<'a>(repo: &'a Repository, arg: Option<&String>) + -> Result>, Error> { + let arg = match arg { Some(s) => s, None => return Ok(None) }; + let obj = try!(repo.revparse_single(arg)); + let tree = try!(obj.peel(ObjectType::Tree)); + Ok(Some(tree)) +} + +impl Args { + fn cache(&self) -> Cache { + if self.flag_cached {Cache::Only} + else if self.flag_nocached {Cache::None} + else {Cache::Normal} + } + fn color(&self) -> bool { self.flag_color && !self.flag_no_color } + fn diff_format(&self) -> DiffFormat { + if self.flag_patch {DiffFormat::Patch} + else if self.flag_name_only {DiffFormat::NameOnly} + else if self.flag_name_status {DiffFormat::NameStatus} + else if self.flag_raw {DiffFormat::Raw} + else { + match self.flag_format.as_ref().map(|s| &s[..]) { + Some("name") => DiffFormat::NameOnly, + Some("name-status") => DiffFormat::NameStatus, + Some("raw") => DiffFormat::Raw, + Some("diff-index") => DiffFormat::Raw, + _ => DiffFormat::Patch, + } + } + } +} + +fn main() { + const USAGE: &'static str = " +usage: diff [options] [ []] + +Options: + -p, --patch show output in patch format + --cached use staged changes as diff + --nocached do not use staged changes + --name-only show only names of changed files + --name-status show only names and status changes + --raw generate the raw format + --format= specify format for stat summary + --color use color output + --no-color never use color output + -R swap two inputs + -a, --text treat all files as text + --ignore-space-at-eol ignore changes in whitespace at EOL + -b, --ignore-space-change ignore changes in amount of whitespace + -w, --ignore-all-space ignore whitespace when comparing lines + --ignored show ignored files as well + --untracked show untracked files + --patience generate diff using the patience algorithm + --minimal spend extra time to find smallest diff + --stat generate a diffstat + --numstat similar to --stat, but more machine friendly + --shortstat only output last line of --stat + --summary output condensed summary of header info + -M, --find-renames set threshold for findind renames (default 50) + -C, --find-copies set threshold for finding copies (default 50) + --find-copies-harder inspect unmodified files for sources of copies + -B, --break-rewrites break complete rewrite changes into pairs + -U, --unified lints of context to show + --inter-hunk-context maximum lines of change between hunks + --abbrev length to abbreviate commits to + --src-prefix show given source prefix instead of 'a/' + --dst-prefix show given destinction prefix instead of 'b/' + --git-dir path to git repository to use + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/fetch.rs b/deps/git2-0.2.12/examples/fetch.rs new file mode 100644 index 000000000..def7f0519 --- /dev/null +++ b/deps/git2-0.2.12/examples/fetch.rs @@ -0,0 +1,130 @@ +/* + * libgit2 "fetch" example - shows how to fetch remote data + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::{Repository, RemoteCallbacks, Direction}; +use std::io::{self, Write}; +use std::str; + +#[derive(RustcDecodable)] +struct Args { + arg_remote: Option, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let repo = try!(Repository::open(".")); + let remote = args.arg_remote.as_ref().map(|s| &s[..]).unwrap_or("origin"); + + // Figure out whether it's a named remote or a URL + println!("Fetcing {} for repo", remote); + let mut cb = RemoteCallbacks::new(); + let mut remote = try!(repo.find_remote(remote).or_else(|_| { + repo.remote_anonymous(remote, None) + })); + cb.sideband_progress(|data| { + print!("remote: {}", str::from_utf8(data).unwrap()); + io::stdout().flush().unwrap(); + true + }); + + // This callback gets called for each remote-tracking branch that gets + // updated. The message we output depends on whether it's a new one or an + // update. + cb.update_tips(|refname, a, b| { + if a.is_zero() { + println!("[new] {:20} {}", b, refname); + } else { + println!("[updated] {:10}..{:10} {}", a, b, refname); + } + true + }); + + // Here we show processed and total objects in the pack and the amount of + // received data. Most frontends will probably want to show a percentage and + // the download rate. + cb.transfer_progress(|stats| { + if stats.received_objects() == stats.total_objects() { + print!("Resolving deltas {}/{}\r", stats.indexed_deltas(), + stats.total_deltas()); + } else if stats.total_objects() > 0 { + print!("Received {}/{} objects ({}) in {} bytes\r", + stats.received_objects(), + stats.total_objects(), + stats.indexed_objects(), + stats.received_bytes()); + } + io::stdout().flush().unwrap(); + true + }); + + remote.set_callbacks(cb); + + // Connect to the remote end specifying that we want to fetch information + // from it. + try!(remote.connect(Direction::Fetch)); + + // Download the packfile and index it. This function updates the amount of + // received data and the indexer stats which lets you inform the user about + // progress. + try!(remote.download(&[])); + + { + // If there are local objects (we got a thin pack), then tell the user + // how many objects we saved from having to cross the network. + let stats = remote.stats(); + if stats.local_objects() > 0 { + println!("\rReceived {}/{} objects in {} bytes (used {} local \ + objects)", stats.indexed_objects(), + stats.total_objects(), stats.received_bytes(), + stats.local_objects()); + } else { + println!("\rReceived {}/{} objects in {} bytes", + stats.indexed_objects(), stats.total_objects(), + stats.received_bytes()); + } + } + + // Disconnect the underlying connection to prevent from idling. + remote.disconnect(); + + // Update the references in the remote's namespace to point to the right + // commits. This may be needed even if there was no packfile to download, + // which can happen e.g. when the branches have been changed but all the + // needed objects are available locally. + try!(remote.update_tips(None)); + + Ok(()) +} + +fn main() { + const USAGE: &'static str = " +usage: fetch [options] [] + +Options: + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/init.rs b/deps/git2-0.2.12/examples/init.rs new file mode 100644 index 000000000..2af3e9657 --- /dev/null +++ b/deps/git2-0.2.12/examples/init.rs @@ -0,0 +1,151 @@ +/* + * libgit2 "init" example - shows how to initialize a new repo + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::{Repository, RepositoryInitOptions, RepositoryInitMode, Error}; +use std::path::{PathBuf, Path}; + +#[derive(RustcDecodable)] +struct Args { + arg_directory: String, + flag_quiet: bool, + flag_bare: bool, + flag_template: Option, + flag_separate_git_dir: Option, + flag_initial_commit: bool, + flag_shared: Option, +} + +fn run(args: &Args) -> Result<(), Error> { + let mut path = PathBuf::from(&args.arg_directory); + let repo = if !args.flag_bare && args.flag_template.is_none() && + args.flag_shared.is_none() && + args.flag_separate_git_dir.is_none() { + try!(Repository::init(&path)) + } else { + let mut opts = RepositoryInitOptions::new(); + opts.bare(args.flag_bare); + if let Some(ref s) = args.flag_template { + opts.template_path(Path::new(s)); + } + + // If you specified a separate git directory, then initialize + // the repository at that path and use the second path as the + // working directory of the repository (with a git-link file) + if let Some(ref s) = args.flag_separate_git_dir { + opts.workdir_path(&path); + path = PathBuf::from(s); + } + + if let Some(ref s) = args.flag_shared { + opts.mode(try!(parse_shared(&s))); + } + try!(Repository::init_opts(&path, &opts)) + }; + + // Print a message to stdout like "git init" does + if !args.flag_quiet { + if args.flag_bare || args.flag_separate_git_dir.is_some() { + path = repo.path().to_path_buf(); + } else { + path = repo.workdir().unwrap().to_path_buf(); + } + println!("Initialized empty Git repository in {}", path.display()); + } + + if args.flag_initial_commit { + try!(create_initial_commit(&repo)); + println!("Created empty initial commit"); + } + + Ok(()) +} + +/// Unlike regular "git init", this example shows how to create an initial empty +/// commit in the repository. This is the helper function that does that. +fn create_initial_commit(repo: &Repository) -> Result<(), Error> { + // First use the config to initialize a commit signature for the user. + let sig = try!(repo.signature()); + + // Now let's create an empty tree for this commit + let tree_id = { + let mut index = try!(repo.index()); + + // Outside of this example, you could call index.add_path() + // here to put actual files into the index. For our purposes, we'll + // leave it empty for now. + + try!(index.write_tree()) + }; + + let tree = try!(repo.find_tree(tree_id)); + + // Ready to create the initial commit. + // + // Normally creating a commit would involve looking up the current HEAD + // commit and making that be the parent of the initial commit, but here this + // is the first commit so there will be no parent. + try!(repo.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[])); + + Ok(()) +} + +fn parse_shared(shared: &str) -> Result { + match shared { + "false" | "umask" => Ok(git2::REPOSITORY_INIT_SHARED_UMASK), + "true" | "group" => Ok(git2::REPOSITORY_INIT_SHARED_GROUP), + "all" | "world" => Ok(git2::REPOSITORY_INIT_SHARED_ALL), + _ => { + if shared.starts_with("0") { + match u32::from_str_radix(&shared[1..], 8).ok() { + Some(n) => { + return Ok(RepositoryInitMode::from_bits_truncate(n)) + } + None => { + Err(Error::from_str("invalid octal value for --shared")) + } + } + } else { + Err(Error::from_str("unknown value for --shared")) + } + } + } +} + +fn main() { + const USAGE: &'static str = " +usage: init [options] + +Options: + -q, --quiet don't print information to stdout + --bare initialize a new bare repository + --template use as an initialization template + --separate-git-dir use as the .git directory + --initial-commit create an initial empty commit + --shared permissions to create the repository with +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/log.rs b/deps/git2-0.2.12/examples/log.rs new file mode 100644 index 000000000..dea8febb1 --- /dev/null +++ b/deps/git2-0.2.12/examples/log.rs @@ -0,0 +1,261 @@ +/* + * libgit2 "log" example - shows how to walk history and get commit info + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate rustc_serialize; +extern crate docopt; +extern crate git2; +extern crate time; + +use std::str; +use docopt::Docopt; +use git2::{Repository, Signature, Commit, ObjectType, Time, DiffOptions}; +use git2::{Pathspec, Diff, Error, DiffFormat}; + +#[derive(RustcDecodable)] +struct Args { + arg_commit: Vec, + arg_spec: Vec, + flag_topo_order: bool, + flag_date_order: bool, + flag_reverse: bool, + flag_author: Option, + flag_committer: Option, + flag_grep: Option, + flag_git_dir: Option, + flag_skip: Option, + flag_max_count: Option, + flag_merges: bool, + flag_no_merges: bool, + flag_no_min_parents: bool, + flag_no_max_parents: bool, + flag_max_parents: Option, + flag_min_parents: Option, + flag_patch: bool, +} + +fn run(args: &Args) -> Result<(), Error> { + let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); + let repo = try!(Repository::open(path)); + let mut revwalk = try!(repo.revwalk()); + + // Prepare the revwalk based on CLI parameters + let base = if args.flag_reverse {git2::SORT_REVERSE} else {git2::SORT_NONE}; + revwalk.set_sorting(base | if args.flag_topo_order { + git2::SORT_TOPOLOGICAL + } else if args.flag_date_order { + git2::SORT_TIME + } else { + git2::SORT_NONE + }); + for commit in args.arg_commit.iter() { + if commit.starts_with("^") { + let obj = try!(repo.revparse_single(&commit[1..])); + try!(revwalk.hide(obj.id())); + continue + } + let revspec = try!(repo.revparse(&commit)); + if revspec.mode().contains(git2::REVPARSE_SINGLE) { + try!(revwalk.push(revspec.from().unwrap().id())); + } else { + let from = revspec.from().unwrap().id(); + let to = revspec.to().unwrap().id(); + try!(revwalk.push(to)); + if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { + let base = try!(repo.merge_base(from, to)); + let o = try!(repo.find_object(base, Some(ObjectType::Commit))); + try!(revwalk.push(o.id())); + } + try!(revwalk.hide(from)); + } + } + if args.arg_commit.len() == 0 { + try!(revwalk.push_head()); + } + + // Prepare our diff options and pathspec matcher + let (mut diffopts, mut diffopts2) = (DiffOptions::new(), DiffOptions::new()); + for spec in args.arg_spec.iter() { + diffopts.pathspec(spec); + diffopts2.pathspec(spec); + } + let ps = try!(Pathspec::new(args.arg_spec.iter())); + + // Filter our revwalk based on the CLI parameters + macro_rules! filter_try { + ($e:expr) => (match $e { Ok(t) => t, Err(e) => return Some(Err(e)) }) + } + let revwalk = revwalk.filter_map(|id| { + let commit = filter_try!(repo.find_commit(id)); + let parents = commit.parents().len(); + if parents < args.min_parents() { return None } + if let Some(n) = args.max_parents() { + if parents >= n { return None } + } + if args.arg_spec.len() > 0 { + match commit.parents().len() { + 0 => { + let tree = filter_try!(commit.tree()); + let flags = git2::PATHSPEC_NO_MATCH_ERROR; + if ps.match_tree(&tree, flags).is_err() { return None } + } + _ => { + let m = commit.parents().all(|parent| { + match_with_parent(&repo, &commit, &parent, &mut diffopts) + .unwrap_or(false) + }); + if !m { return None } + } + } + } + if !sig_matches(commit.author(), &args.flag_author) { return None } + if !sig_matches(commit.committer(), &args.flag_committer) { return None } + if !log_message_matches(commit.message(), &args.flag_grep) { return None } + Some(Ok(commit)) + }).skip(args.flag_skip.unwrap_or(0)).take(args.flag_max_count.unwrap_or(!0)); + + // print! + for commit in revwalk { + let commit = try!(commit); + print_commit(&commit); + if !args.flag_patch || commit.parents().len() > 1 { continue } + let a = if commit.parents().len() == 1 { + let parent = try!(commit.parent(0)); + Some(try!(parent.tree())) + } else { + None + }; + let b = try!(commit.tree()); + let diff = try!(Diff::tree_to_tree(&repo, a.as_ref(), Some(&b), + Some(&mut diffopts2))); + try!(diff.print(DiffFormat::Patch, |_delta, _hunk, line| { + match line.origin() { + ' ' | '+' | '-' => print!("{}", line.origin()), + _ => {} + } + print!("{}", str::from_utf8(line.content()).unwrap()); + true + })); + } + + Ok(()) +} + +fn sig_matches(sig: Signature, arg: &Option) -> bool { + match *arg { + Some(ref s) => { + sig.name().map(|n| n.contains(s)).unwrap_or(false) || + sig.email().map(|n| n.contains(s)).unwrap_or(false) + } + None => true + } +} + +fn log_message_matches(msg: Option<&str>, grep: &Option) -> bool { + match (grep, msg) { + (&None, _) => true, + (&Some(_), None) => false, + (&Some(ref s), Some(msg)) => msg.contains(s), + } +} + +fn print_commit(commit: &Commit) { + println!("commit {}", commit.id()); + + if commit.parents().len() > 1 { + print!("Merge:"); + for id in commit.parent_ids() { + print!(" {:.8}", id); + } + println!(""); + } + + let author = commit.author(); + println!("Author: {}", author); + print_time(&author.when(), "Date: "); + println!(""); + + for line in String::from_utf8_lossy(commit.message_bytes()).lines() { + println!(" {}", line); + } + println!(""); +} + +fn print_time(time: &Time, prefix: &str) { + let (offset, sign) = match time.offset_minutes() { + n if n < 0 => (-n, '-'), + n => (n, '+'), + }; + let (hours, minutes) = (offset / 60, offset % 60); + let ts = time::Timespec::new(time.seconds() + + (time.offset_minutes() as i64) * 60, 0); + let time = time::at(ts); + + println!("{}{} {}{:02}{:02}", prefix, + time.strftime("%a %b %e %T %Y").unwrap(), sign, hours, minutes); + +} + +fn match_with_parent(repo: &Repository, commit: &Commit, parent: &Commit, + opts: &mut DiffOptions) -> Result { + let a = try!(parent.tree()); + let b = try!(commit.tree()); + let diff = try!(Diff::tree_to_tree(repo, Some(&a), Some(&b), Some(opts))); + Ok(diff.deltas().len() > 0) +} + +impl Args { + fn min_parents(&self) -> usize { + if self.flag_no_min_parents { return 0 } + self.flag_min_parents.unwrap_or(if self.flag_merges {2} else {0}) + } + + fn max_parents(&self) -> Option { + if self.flag_no_max_parents { return None } + self.flag_max_parents.or(if self.flag_no_merges {Some(1)} else {None}) + } +} + +fn main() { + const USAGE: &'static str = " +usage: log [options] [..] [--] [..] + +Options: + --topo-order sort commits in topological order + --date-order sort commits in date order + --reverse sort commits in reverse + --author author to sort by + --committer committer to sort by + --grep pattern to filter commit messages by + --git-dir alternative git directory to use + --skip number of commits to skip + -n, --max-count maximum number of commits to show + --merges only show merge commits + --no-merges don't show merge commits + --no-min-parents don't require a minimum number of parents + --no-max-parents don't require a maximum number of parents + --max-parents specify a maximum number of parents for a commit + --min-parents specify a minimum number of parents for a commit + -p, --patch show commit diff + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/ls-remote.rs b/deps/git2-0.2.12/examples/ls-remote.rs new file mode 100644 index 000000000..523ca7a18 --- /dev/null +++ b/deps/git2-0.2.12/examples/ls-remote.rs @@ -0,0 +1,63 @@ +/* + * libgit2 "ls-remote" example + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::{Repository, Direction}; + +#[derive(RustcDecodable)] +struct Args { + arg_remote: String, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let repo = try!(Repository::open(".")); + let remote = &args.arg_remote; + let mut remote = try!(repo.find_remote(remote).or_else(|_| { + repo.remote_anonymous(remote, None) + })); + + // Connect to the remote and call the printing function for each of the + // remote references. + try!(remote.connect(Direction::Fetch)); + + // Get the list of references on the remote and print out their name next to + // what they point to. + for head in try!(remote.list()).iter() { + println!("{}\t{}", head.oid(), head.name()); + } + + Ok(()) +} + +fn main() { + const USAGE: &'static str = " +usage: ls-remote [option] + +Options: + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/rev-list.rs b/deps/git2-0.2.12/examples/rev-list.rs new file mode 100644 index 000000000..c1c8eca25 --- /dev/null +++ b/deps/git2-0.2.12/examples/rev-list.rs @@ -0,0 +1,95 @@ +/* + * libgit2 "rev-list" example - shows how to transform a rev-spec into a list + * of commit ids + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::{Repository, Error, Revwalk, Oid}; + +#[derive(RustcDecodable)] +struct Args { + arg_spec: Vec, + flag_topo_order: bool, + flag_date_order: bool, + flag_reverse: bool, + flag_not: Vec, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let repo = try!(Repository::open(".")); + let mut revwalk = try!(repo.revwalk()); + + let base = if args.flag_reverse {git2::SORT_REVERSE} else {git2::SORT_NONE}; + revwalk.set_sorting(base | if args.flag_topo_order { + git2::SORT_TOPOLOGICAL + } else if args.flag_date_order { + git2::SORT_TIME + } else { + git2::SORT_NONE + }); + + let specs = args.flag_not.iter().map(|s| (s, true)) + .chain(args.arg_spec.iter().map(|s| (s, false))) + .map(|(spec, hide)| { + if spec.starts_with("^") {(&spec[1..], !hide)} else {(&spec[..], hide)} + }); + for (spec, hide) in specs { + let id = if spec.contains("..") { + let revspec = try!(repo.revparse(spec)); + if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { + return Err(Error::from_str("merge bases not implemented")) + } + try!(push(&mut revwalk, revspec.from().unwrap().id(), !hide)); + revspec.to().unwrap().id() + } else { + try!(repo.revparse_single(spec)).id() + }; + try!(push(&mut revwalk, id, hide)); + } + + for id in revwalk { + println!("{}", id); + } + Ok(()) +} + +fn push(revwalk: &mut Revwalk, id: Oid, hide: bool) -> Result<(), Error> { + if hide {revwalk.hide(id)} else {revwalk.push(id)} +} + +fn main() { + const USAGE: &'static str = " +usage: rev-list [options] [--] ... + +Options: + --topo-order sort commits in topological order + --date-order sort commits in date order + --reverse sort commits in reverse + --not don't show + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} + diff --git a/deps/git2-0.2.12/examples/rev-parse.rs b/deps/git2-0.2.12/examples/rev-parse.rs new file mode 100644 index 000000000..370509913 --- /dev/null +++ b/deps/git2-0.2.12/examples/rev-parse.rs @@ -0,0 +1,69 @@ +/* + * libgit2 "rev-parse" example - shows how to parse revspecs + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use docopt::Docopt; +use git2::Repository; + +#[derive(RustcDecodable)] +struct Args { + arg_spec: String, + flag_git_dir: Option, +} + +fn run(args: &Args) -> Result<(), git2::Error> { + let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); + let repo = try!(Repository::open(path)); + + let revspec = try!(repo.revparse(&args.arg_spec)); + + if revspec.mode().contains(git2::REVPARSE_SINGLE) { + println!("{}", revspec.from().unwrap().id()); + } else if revspec.mode().contains(git2::REVPARSE_RANGE) { + let to = revspec.to().unwrap(); + let from = revspec.from().unwrap(); + println!("{}", to.id()); + + if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { + let base = try!(repo.merge_base(from.id(), to.id())); + println!("{}", base); + } + + println!("^{}", from.id()); + } else { + return Err(git2::Error::from_str("invalid results from revparse")) + } + Ok(()) +} + +fn main() { + const USAGE: &'static str = " +usage: rev-parse [options] + +Options: + --git-dir directory for the git repository to check +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/status.rs b/deps/git2-0.2.12/examples/status.rs new file mode 100644 index 000000000..e67a484aa --- /dev/null +++ b/deps/git2-0.2.12/examples/status.rs @@ -0,0 +1,373 @@ +/* + * libgit2 "status" example - shows how to use the status APIs + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use std::str; +use docopt::Docopt; +use git2::{Repository, Error, StatusOptions, ErrorCode}; + +#[derive(RustcDecodable)] +struct Args { + arg_spec: Vec, + flag_short: bool, + flag_long: bool, + flag_porcelain: bool, + flag_branch: bool, + flag_z: bool, + flag_ignored: bool, + flag_untracked_files: Option, + flag_ignore_submodules: Option, + flag_git_dir: Option, + flag_repeat: bool, + flag_list_submodules: bool, +} + +#[derive(Eq, PartialEq)] +enum Format { Long, Short, Porcelain } + +fn run(args: &Args) -> Result<(), Error> { + let path = args.flag_git_dir.clone().unwrap_or(".".to_string()); + let repo = try!(Repository::open(&path)); + if repo.is_bare() { + return Err(Error::from_str("cannot report status on bare repository")) + } + + let mut opts = StatusOptions::new(); + opts.include_ignored(args.flag_ignored); + match args.flag_untracked_files.as_ref().map(|s| &s[..]) { + Some("no") => { opts.include_untracked(false); } + Some("normal") => { opts.include_untracked(true); } + Some("all") => { + opts.include_untracked(true).recurse_untracked_dirs(true); + } + Some(_) => return Err(Error::from_str("invalid untracked-files value")), + None => {} + } + match args.flag_ignore_submodules.as_ref().map(|s| &s[..]) { + Some("all") => { opts.exclude_submodules(true); } + Some(_) => return Err(Error::from_str("invalid ignore-submodules value")), + None => {} + } + opts.include_untracked(!args.flag_ignored); + for spec in args.arg_spec.iter() { + opts.pathspec(spec); + } + + loop { + if args.flag_repeat { + println!("\u{1b}[H\u{1b}[2J"); + } + + let statuses = try!(repo.statuses(Some(&mut opts))); + + if args.flag_branch { + try!(show_branch(&repo, args.format())); + } + if args.flag_list_submodules { + try!(print_submodules(&repo)); + } + + if args.format() == Format::Long { + print_long(statuses); + } else { + print_short(&repo, statuses); + } + + if args.flag_repeat { + std::thread::sleep_ms(10000); + } else { + return Ok(()) + } + } +} + +fn show_branch(repo: &Repository, format: Format) -> Result<(), Error> { + let head = match repo.head() { + Ok(head) => Some(head), + Err(ref e) if e.code() == ErrorCode::UnbornBranch || + e.code() == ErrorCode::NotFound => None, + Err(e) => return Err(e), + }; + let head = head.as_ref().and_then(|h| h.shorthand()); + + if format == Format::Long { + println!("# On branch {}", + head.unwrap_or("Not currently on any branch")); + } else { + println!("## {}", head.unwrap_or("HEAD (no branch)")); + } + Ok(()) +} + +fn print_submodules(repo: &Repository) -> Result<(), Error> { + let modules = try!(repo.submodules()); + println!("# Submodules"); + for sm in modules.iter() { + println!("# - submodule '{}' at {}", sm.name().unwrap(), + sm.path().display()); + } + Ok(()) +} + +// This function print out an output similar to git's status command in long +// form, including the command-line hints. +fn print_long(statuses: git2::Statuses) { + let mut header = false; + let mut rm_in_workdir = false; + let mut changes_in_index = false; + let mut changed_in_workdir = false; + + // Print index changes + for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { + if entry.status().contains(git2::STATUS_WT_DELETED) { + rm_in_workdir = true; + } + let istatus = match entry.status() { + s if s.contains(git2::STATUS_INDEX_NEW) => "new file: ", + s if s.contains(git2::STATUS_INDEX_MODIFIED) => "modified: ", + s if s.contains(git2::STATUS_INDEX_DELETED) => "deleted: ", + s if s.contains(git2::STATUS_INDEX_RENAMED) => "renamed: ", + s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => "typechange:", + _ => continue, + }; + if !header { + println!("\ +# Changes to be committed: +# (use \"git reset HEAD ...\" to unstage) +#"); + header = true; + } + + let old_path = entry.head_to_index().unwrap().old_file().path(); + let new_path = entry.head_to_index().unwrap().new_file().path(); + match (old_path, new_path) { + (Some(ref old), Some(ref new)) if old != new => { + println!("#\t{} {} -> {}", istatus, old.display(), + new.display()); + } + (old, new) => { + println!("#\t{} {}", istatus, old.or(new).unwrap().display()); + } + } + } + + if header { + changes_in_index = true; + println!("#"); + } + header = false; + + // Print workdir changes to tracked files + for entry in statuses.iter() { + // With `STATUS_OPT_INCLUDE_UNMODIFIED` (not used in this example) + // `index_to_workdir` may not be `None` even if there are no differences, + // in which case it will be a `Delta::Unmodified`. + if entry.status() == git2::STATUS_CURRENT || + entry.index_to_workdir().is_none() { + continue + } + + let istatus = match entry.status() { + s if s.contains(git2::STATUS_WT_MODIFIED) => "modified: ", + s if s.contains(git2::STATUS_WT_DELETED) => "deleted: ", + s if s.contains(git2::STATUS_WT_RENAMED) => "renamed: ", + s if s.contains(git2::STATUS_WT_TYPECHANGE) => "typechange:", + _ => continue, + }; + + if !header { + println!("\ +# Changes not staged for commit: +# (use \"git add{} ...\" to update what will be committed) +# (use \"git checkout -- ...\" to discard changes in working directory) +#\ + ", if rm_in_workdir {"/rm"} else {""}); + header = true; + } + + let old_path = entry.index_to_workdir().unwrap().old_file().path(); + let new_path = entry.index_to_workdir().unwrap().new_file().path(); + match (old_path, new_path) { + (Some(ref old), Some(ref new)) if old != new => { + println!("#\t{} {} -> {}", istatus, old.display(), + new.display()); + } + (old, new) => { + println!("#\t{} {}", istatus, old.or(new).unwrap().display()); + } + } + } + + if header { + changed_in_workdir = true; + println!("#"); + } + header = false; + + // Print untracked files + for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { + if !header { + println!("\ +# Untracked files +# (use \"git add ...\" to include in what will be committed) +#"); + header = true; + } + let file = entry.index_to_workdir().unwrap().old_file().path().unwrap(); + println!("#\t{}", file.display()); + } + header = false; + + // Print ignored files + for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_IGNORED) { + if !header { + println!("\ +# Ignored files +# (use \"git add -f ...\" to include in what will be committed) +#"); + header = true; + } + let file = entry.index_to_workdir().unwrap().old_file().path().unwrap(); + println!("#\t{}", file.display()); + } + + if !changes_in_index && changed_in_workdir { + println!("no changes added to commit (use \"git add\" and/or \ + \"git commit -a\")"); + } +} + +// This version of the output prefixes each path with two status columns and +// shows submodule status information. +fn print_short(repo: &Repository, statuses: git2::Statuses) { + for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { + let mut istatus = match entry.status() { + s if s.contains(git2::STATUS_INDEX_NEW) => 'A', + s if s.contains(git2::STATUS_INDEX_MODIFIED) => 'M', + s if s.contains(git2::STATUS_INDEX_DELETED) => 'D', + s if s.contains(git2::STATUS_INDEX_RENAMED) => 'R', + s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => 'T', + _ => ' ', + }; + let mut wstatus = match entry.status() { + s if s.contains(git2::STATUS_WT_NEW) => { + if istatus == ' ' { istatus = '?'; } '?' + } + s if s.contains(git2::STATUS_WT_MODIFIED) => 'M', + s if s.contains(git2::STATUS_WT_DELETED) => 'D', + s if s.contains(git2::STATUS_WT_RENAMED) => 'R', + s if s.contains(git2::STATUS_WT_TYPECHANGE) => 'T', + _ => ' ', + }; + + if entry.status().contains(git2::STATUS_IGNORED) { + istatus = '!'; + wstatus = '!'; + } + if istatus == '?' && wstatus == '?' { continue } + let mut extra = ""; + + // A commit in a tree is how submodules are stored, so let's go take a + // look at its status. + // + // TODO: check for GIT_FILEMODE_COMMIT + let status = entry.index_to_workdir().and_then(|diff| { + diff.new_file().path_bytes() + .and_then(|s| str::from_utf8(s).ok()) + .and_then(|name| repo.find_submodule(name).ok()) + }).and_then(|module| { + module.status().ok() + }); + if let Some(status) = status { + if status.contains(git2::SUBMODULE_STATUS_WD_MODIFIED) { + extra = " (new commits)"; + } else if status.contains(git2::SUBMODULE_STATUS_WD_INDEX_MODIFIED) { + extra = " (modified content)"; + } else if status.contains(git2::SUBMODULE_STATUS_WD_WD_MODIFIED) { + extra = " (modified content)"; + } else if status.contains(git2::SUBMODULE_STATUS_WD_UNTRACKED) { + extra = " (untracked content)"; + } + } + + let (mut a, mut b, mut c) = (None, None, None); + if let Some(diff) = entry.head_to_index() { + a = diff.old_file().path(); + b = diff.new_file().path(); + } + if let Some(diff) = entry.index_to_workdir() { + a = a.or(diff.old_file().path()); + b = b.or(diff.old_file().path()); + c = diff.new_file().path(); + } + + match (istatus, wstatus) { + ('R', 'R') => println!("RR {} {} {}{}", a.unwrap().display(), + b.unwrap().display(), c.unwrap().display(), + extra), + ('R', w) => println!("R{} {} {}{}", w, a.unwrap().display(), + b.unwrap().display(), extra), + (i, 'R') => println!("{}R {} {}{}", i, a.unwrap().display(), + c.unwrap().display(), extra), + (i, w) => println!("{}{} {}{}", i, w, a.unwrap().display(), extra), + } + } + + for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { + println!("?? {}", entry.index_to_workdir().unwrap().old_file() + .path().unwrap().display()); + } +} + +impl Args { + fn format(&self) -> Format { + if self.flag_short { Format::Short } + else if self.flag_long { Format::Long } + else if self.flag_porcelain { Format::Porcelain } + else if self.flag_z { Format::Porcelain } + else { Format::Long } + } +} + +fn main() { + const USAGE: &'static str = " +usage: status [options] [--] [..] + +Options: + -s, --short show short statuses + --long show longer statuses (default) + --porcelain ?? + -b, --branch show branch information + -z ?? + --ignored show ignored files as well + --untracked-files setting for showing untracked files [no|normal|all] + --ignore-submodules setting for ignoring submodules [all] + --git-dir git directory to analyze + --repeat repeatedly show status, sleeping inbetween + --list-submodules show submodules + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/examples/tag.rs b/deps/git2-0.2.12/examples/tag.rs new file mode 100644 index 000000000..a584908d0 --- /dev/null +++ b/deps/git2-0.2.12/examples/tag.rs @@ -0,0 +1,133 @@ +/* + * libgit2 "tag" example - shows how to list, create and delete tags + * + * Written by the libgit2 contributors + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +#![deny(warnings)] + +extern crate git2; +extern crate docopt; +extern crate rustc_serialize; + +use std::str; +use docopt::Docopt; +use git2::{Repository, Error, Tag, Commit}; + +#[derive(RustcDecodable)] +struct Args { + arg_tagname: Option, + arg_object: Option, + arg_pattern: Option, + flag_n: Option, + flag_force: bool, + flag_list: bool, + flag_delete: Option, + flag_message: Option, +} + +fn run(args: &Args) -> Result<(), Error> { + let repo = try!(Repository::open(".")); + + if let Some(ref name) = args.arg_tagname { + let target = args.arg_object.as_ref().map(|s| &s[..]).unwrap_or("HEAD"); + let obj = try!(repo.revparse_single(target)); + + if let Some(ref message) = args.flag_message { + let sig = try!(repo.signature()); + try!(repo.tag(&name, &obj, &sig, &message, args.flag_force)); + } else { + try!(repo.tag_lightweight(&name, &obj, args.flag_force)); + } + + } else if let Some(ref name) = args.flag_delete { + let obj = try!(repo.revparse_single(name)); + let id = try!(obj.short_id()); + try!(repo.tag_delete(name)); + println!("Deleted tag '{}' (was {})", name, + str::from_utf8(&*id).unwrap()); + + } else if args.flag_list { + let pattern = args.arg_pattern.as_ref().map(|s| &s[..]).unwrap_or("*"); + for name in try!(repo.tag_names(Some(pattern))).iter() { + let name = name.unwrap(); + let obj = try!(repo.revparse_single(name)); + + if let Some(tag) = obj.as_tag() { + print_tag(tag, args); + } else if let Some(commit) = obj.as_commit() { + print_commit(commit, name, args); + } else { + print_name(name); + } + } + } + Ok(()) +} + +fn print_tag(tag: &Tag, args: &Args) { + print!("{:<16}", tag.name().unwrap()); + if args.flag_n.is_some() { + print_list_lines(tag.message(), args); + } else { + println!(""); + } +} + +fn print_commit(commit: &Commit, name: &str, args: &Args) { + print!("{:<16}", name); + if args.flag_n.is_some() { + print_list_lines(commit.message(), args); + } else { + println!(""); + } +} + +fn print_name(name: &str) { + println!("{}", name); +} + +fn print_list_lines(message: Option<&str>, args: &Args) { + let message = match message { Some(s) => s, None => return }; + let mut lines = message.lines().filter(|l| !l.trim().is_empty()); + if let Some(first) = lines.next() { + print!("{}", first); + } + println!(""); + + for line in lines.take(args.flag_n.unwrap_or(0) as usize) { + print!(" {}", line); + } +} + +fn main() { + const USAGE: &'static str = " +usage: + tag [-a] [-f] [-m ] [] + tag -d + tag [-n ] -l [] + +Options: + -n specify number of lines from teh annotation to print + -f, --force replace an existing tag with the given name + -l, --list list tags with names matching the pattern given + -d, --delete delete the tag specified + -m, --message message for a new tag + -h, --help show this message +"; + + let args = Docopt::new(USAGE).and_then(|d| d.decode()) + .unwrap_or_else(|e| e.exit()); + match run(&args) { + Ok(()) => {} + Err(e) => println!("error: {}", e), + } +} diff --git a/deps/git2-0.2.12/src/blame.rs b/deps/git2-0.2.12/src/blame.rs new file mode 100644 index 000000000..6de64a554 --- /dev/null +++ b/deps/git2-0.2.12/src/blame.rs @@ -0,0 +1,303 @@ +use std::marker; +use {raw, Repository, Oid, signature, Signature}; +use util::{self, Binding}; +use std::path::Path; +use std::ops::Range; +use std::mem; + +/// Opaque structure to hold blame results. +pub struct Blame<'repo> { + raw: *mut raw::git_blame, + _marker: marker::PhantomData<&'repo Repository>, +} + +/// Structure that represents a blame hunk. +pub struct BlameHunk<'blame> { + raw: *mut raw::git_blame_hunk, + _marker: marker::PhantomData<&'blame raw::git_blame>, +} + +/// Blame options +pub struct BlameOptions { + raw: raw::git_blame_options, +} + +/// An iterator over the hunks in a blame. +pub struct BlameIter<'blame> { + range: Range, + blame: &'blame Blame<'blame>, +} + +impl<'repo> Blame<'repo> { + + /// Gets the number of hunks that exist in the blame structure. + pub fn len(&self) -> usize { + unsafe { raw::git_blame_get_hunk_count(self.raw) as usize } + } + + /// Gets the blame hunk at the given index. + pub fn get_index(&self, index: usize) -> Option { + unsafe { + let ptr = raw::git_blame_get_hunk_byindex(self.raw(), index as u32); + if ptr.is_null() { + None + } else { + Some(BlameHunk::from_raw_const(ptr)) + } + } + } + + /// Gets the hunk that relates to the given line number in the newest + /// commit. + pub fn get_line(&self, lineno: usize) -> Option { + unsafe { + let ptr = raw::git_blame_get_hunk_byline(self.raw(), lineno as u32); + if ptr.is_null() { + None + } else { + Some(BlameHunk::from_raw_const(ptr)) + } + } + } + + /// Returns an iterator over the hunks in this blame. + pub fn iter(&self) -> BlameIter { + BlameIter { range: 0..self.len(), blame: self } + } + +} + +impl<'blame> BlameHunk<'blame> { + + unsafe fn from_raw_const(raw: *const raw::git_blame_hunk) + -> BlameHunk<'blame> { + BlameHunk { + raw: raw as *mut raw::git_blame_hunk, + _marker: marker::PhantomData, + } + } + + /// Returns OID of the commit where this line was last changed + pub fn final_commit_id(&self) -> Oid { + unsafe { Oid::from_raw(&(*self.raw).final_commit_id) } + } + + /// Returns signature of the commit. + pub fn final_signature(&self) -> Signature { + unsafe { signature::from_raw_const(self, (*self.raw).final_signature) } + } + + /// Returns line number where this hunk begins. + /// + /// Note that the start line is counting from 1. + pub fn final_start_line(&self) -> usize { + unsafe { (*self.raw).final_start_line_number as usize } + } + + /// Returns the OID of the commit where this hunk was found. + /// + /// This will usually be the same as `final_commit_id`, + /// except when `BlameOptions::track_copies_any_commit_copies` has been + /// turned on + pub fn orig_commit_id(&self) -> Oid { + unsafe { Oid::from_raw(&(*self.raw).orig_commit_id) } + } + + /// Returns signature of the commit. + pub fn orig_signature(&self) -> Signature { + unsafe { signature::from_raw_const(self, (*self.raw).orig_signature) } + } + + /// Returns line number where this hunk begins. + /// + /// Note that the start line is counting from 1. + pub fn orig_start_line(&self) -> usize { + unsafe { (*self.raw).orig_start_line_number as usize } + } + + /// Returns path to the file where this hunk originated. + /// + /// Note: `None` could be returned for non-unicode paths on Widnows. + pub fn path(&self) -> Option<&Path> { + unsafe { + if let Some(bytes) = ::opt_bytes(self, (*self.raw).orig_path) { + Some(util::bytes2path(bytes)) + } else { + None + } + } + } + + /// Tests whether this hunk has been tracked to a boundary commit + /// (the root, or the commit specified in git_blame_options.oldest_commit). + pub fn is_boundary(&self) -> bool { + unsafe { (*self.raw).boundary == 1 } + } + + /// Returns number of lines in this hunk. + pub fn lines_in_hunk(&self) -> usize { + unsafe { (*self.raw).lines_in_hunk as usize } + } +} + +impl BlameOptions { + + /// Initialize options + pub fn new() -> BlameOptions { + unsafe { + let mut raw: raw::git_blame_options = mem::zeroed(); + assert_eq!( + raw::git_blame_init_options(&mut raw, + raw::GIT_BLAME_OPTIONS_VERSION) + , 0); + + Binding::from_raw(&raw as *const _ as *mut _) + } + } + + fn flag(&mut self, opt: u32, val: bool) -> &mut BlameOptions { + if val { + self.raw.flags |= opt; + } else { + self.raw.flags &= !opt; + } + self + } + + /// Track lines that have moved within a file. + pub fn track_copies_same_file(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_FILE, opt) + } + + /// Track lines that have moved across files in the same commit. + pub fn track_copies_same_commit_moves(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES, opt) + } + + /// Track lines that have been copied from another file that exists + /// in the same commit. + pub fn track_copies_same_commit_copies(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES, opt) + } + + /// Track lines that have been copied from another file that exists + /// in any commit. + pub fn track_copies_any_commit_copies(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES, opt) + } + + /// Restrict the search of commits to those reachable following only + /// the first parents. + pub fn first_parent(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_FIRST_PARENT, opt) + } + + /// Setter for the id of the newest commit to consider. + pub fn newest_commit(&mut self, id: Oid) -> &mut BlameOptions { + unsafe { self.raw.newest_commit = *id.raw(); } + self + } + + /// Setter for the id of the oldest commit to consider. + pub fn oldest_commit(&mut self, id: Oid) -> &mut BlameOptions { + unsafe { self.raw.oldest_commit = *id.raw(); } + self + } + +} + +impl<'repo> Binding for Blame<'repo> { + type Raw = *mut raw::git_blame; + + unsafe fn from_raw(raw: *mut raw::git_blame) -> Blame<'repo> { + Blame { raw: raw, _marker: marker::PhantomData } + } + + fn raw(&self) -> *mut raw::git_blame { self.raw } +} + +impl<'repo> Drop for Blame<'repo> { + fn drop(&mut self) { + unsafe { raw::git_blame_free(self.raw) } + } +} + +impl<'blame> Binding for BlameHunk<'blame> { + type Raw = *mut raw::git_blame_hunk; + + unsafe fn from_raw(raw: *mut raw::git_blame_hunk) -> BlameHunk<'blame> { + BlameHunk { raw: raw, _marker: marker::PhantomData } + } + + fn raw(&self) -> *mut raw::git_blame_hunk { self.raw } +} + +impl Binding for BlameOptions { + type Raw = *mut raw::git_blame_options; + + unsafe fn from_raw(opts: *mut raw::git_blame_options) -> BlameOptions { + BlameOptions { raw: *opts } + } + + fn raw(&self) -> *mut raw::git_blame_options { + &self.raw as *const _ as *mut _ + } +} + +impl<'blame> Iterator for BlameIter<'blame> { + type Item = BlameHunk<'blame>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.blame.get_index(i)) + } + + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} + +impl<'blame> DoubleEndedIterator for BlameIter<'blame> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.blame.get_index(i)) + } +} + +impl<'blame> ExactSizeIterator for BlameIter<'blame> {} + +#[cfg(test)] +mod tests { + use std::fs::{self, File}; + use std::path::Path; + + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let mut index = repo.index().unwrap(); + + let root = repo.path().parent().unwrap(); + fs::create_dir(&root.join("foo")).unwrap(); + File::create(&root.join("foo/bar")).unwrap(); + index.add_path(Path::new("foo/bar")).unwrap(); + + let id = index.write_tree().unwrap(); + let tree = repo.find_tree(id).unwrap(); + let sig = repo.signature().unwrap(); + let id = repo.refname_to_id("HEAD").unwrap(); + let parent = repo.find_commit(id).unwrap(); + let commit = repo.commit(Some("HEAD"), &sig, &sig, "commit", + &tree, &[&parent]).unwrap(); + + let blame = repo.blame_file(Path::new("foo/bar"), None).unwrap(); + + assert_eq!(blame.len(), 1); + assert_eq!(blame.iter().count(), 1); + + let hunk = blame.get_index(0).unwrap(); + assert_eq!(hunk.final_commit_id(), commit); + assert_eq!(hunk.final_signature().name(), sig.name()); + assert_eq!(hunk.final_signature().email(), sig.email()); + assert_eq!(hunk.final_start_line(), 1); + assert_eq!(hunk.path(), Some(Path::new("foo/bar"))); + assert_eq!(hunk.lines_in_hunk(), 0); + assert!(!hunk.is_boundary()) + } + +} + diff --git a/deps/git2-0.2.12/src/blob.rs b/deps/git2-0.2.12/src/blob.rs new file mode 100644 index 000000000..cfc4cf86c --- /dev/null +++ b/deps/git2-0.2.12/src/blob.rs @@ -0,0 +1,86 @@ +use std::marker; +use std::slice; + +use {raw, Oid, Object}; +use util::Binding; + +/// A structure to represent a git [blob][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects +pub struct Blob<'repo> { + raw: *mut raw::git_blob, + _marker: marker::PhantomData>, +} + +impl<'repo> Blob<'repo> { + /// Get the id (SHA1) of a repository blob + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_blob_id(&*self.raw)) } + } + + /// Determine if the blob content is most certainly binary or not. + pub fn is_binary(&self) -> bool { + unsafe { raw::git_blob_is_binary(&*self.raw) == 1 } + } + + /// Get the content of this blob. + pub fn content(&self) -> &[u8] { + unsafe { + let data = raw::git_blob_rawcontent(&*self.raw) as *const u8; + let len = raw::git_blob_rawsize(&*self.raw) as usize; + slice::from_raw_parts(data, len) + } + } +} + +impl<'repo> Binding for Blob<'repo> { + type Raw = *mut raw::git_blob; + + unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> { + Blob { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *mut raw::git_blob { self.raw } +} + + +impl<'repo> Drop for Blob<'repo> { + fn drop(&mut self) { + unsafe { raw::git_blob_free(self.raw) } + } +} + +#[cfg(test)] +mod tests { + use std::io::prelude::*; + use std::fs::File; + use tempdir::TempDir; + use Repository; + + #[test] + fn buffer() { + let td = TempDir::new("test").unwrap(); + let repo = Repository::init(td.path()).unwrap(); + let id = repo.blob(&[5, 4, 6]).unwrap(); + let blob = repo.find_blob(id).unwrap(); + + assert_eq!(blob.id(), id); + assert_eq!(blob.content(), [5, 4, 6]); + assert!(blob.is_binary()); + + repo.find_object(id, None).unwrap().as_blob().unwrap(); + } + + #[test] + fn path() { + let td = TempDir::new("test").unwrap(); + let path = td.path().join("foo"); + File::create(&path).unwrap().write_all(&[7, 8, 9]).unwrap(); + let repo = Repository::init(td.path()).unwrap(); + let id = repo.blob_path(&path).unwrap(); + let blob = repo.find_blob(id).unwrap(); + assert_eq!(blob.content(), [7, 8, 9]); + } +} diff --git a/deps/git2-0.2.12/src/branch.rs b/deps/git2-0.2.12/src/branch.rs new file mode 100644 index 000000000..52398fa4f --- /dev/null +++ b/deps/git2-0.2.12/src/branch.rs @@ -0,0 +1,166 @@ +use std::ffi::CString; +use std::marker; +use std::str; +use libc; + +use {raw, Error, Reference, BranchType, References}; +use util::Binding; + +/// A structure to represent a git [branch][1] +/// +/// A branch is currently just a wrapper to an underlying `Reference`. The +/// reference can be accessed through the `get` and `unwrap` methods. +/// +/// [1]: http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is +pub struct Branch<'repo> { + inner: Reference<'repo>, +} + +/// An iterator over the branches inside of a repository. +pub struct Branches<'repo> { + raw: *mut raw::git_branch_iterator, + _marker: marker::PhantomData>, +} + +impl<'repo> Branch<'repo> { + /// Creates a new branch from a reference + pub fn wrap(reference: Reference) -> Branch { Branch { inner: reference } } + + /// Gain access to the reference that is this branch + pub fn get(&self) -> &Reference<'repo> { &self.inner } + + /// Take ownership of the underlying reference. + pub fn into_reference(self) -> Reference<'repo> { self.inner } + + /// Delete an existing branch reference. + pub fn delete(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_branch_delete(self.get().raw())); } + Ok(()) + } + + /// Determine if the current local branch is pointed at by HEAD. + pub fn is_head(&self) -> bool { + unsafe { raw::git_branch_is_head(&*self.get().raw()) == 1 } + } + + /// Move/rename an existing local branch reference. + pub fn rename(&mut self, new_branch_name: &str, force: bool) + -> Result, Error> { + let mut ret = 0 as *mut raw::git_reference; + let new_branch_name = try!(CString::new(new_branch_name)); + unsafe { + try_call!(raw::git_branch_move(&mut ret, self.get().raw(), + new_branch_name, force)); + Ok(Branch::wrap(Binding::from_raw(ret))) + } + } + + /// Return the name of the given local or remote branch. + /// + /// May return `Ok(None)` if the name is not valid utf-8. + pub fn name(&self) -> Result, Error> { + self.name_bytes().map(|s| str::from_utf8(s).ok()) + } + + /// Return the name of the given local or remote branch. + pub fn name_bytes(&self) -> Result<&[u8], Error> { + let mut ret = 0 as *const libc::c_char; + unsafe { + try_call!(raw::git_branch_name(&mut ret, &*self.get().raw())); + Ok(::opt_bytes(self, ret).unwrap()) + } + } + + /// Return the reference supporting the remote tracking branch, given a + /// local branch reference. + pub fn upstream<'a>(&'a self) -> Result, Error> { + let mut ret = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_branch_upstream(&mut ret, &*self.get().raw())); + Ok(Branch::wrap(Binding::from_raw(ret))) + } + } + + /// Set the upstream configuration for a given local branch. + /// + /// If `None` is specified, then the upstream branch is unset. The name + /// provided is the name of the branch to set as upstream. + pub fn set_upstream(&mut self, + upstream_name: Option<&str>) -> Result<(), Error> { + let upstream_name = try!(::opt_cstr(upstream_name)); + unsafe { + try_call!(raw::git_branch_set_upstream(self.get().raw(), + upstream_name)); + Ok(()) + } + } +} + +impl<'repo> Branches<'repo> { + /// Creates a new iterator from the raw pointer given. + /// + /// This function is unsafe as it is not guaranteed that `raw` is a valid + /// pointer. + pub unsafe fn from_raw(raw: *mut raw::git_branch_iterator) + -> Branches<'repo> { + Branches { + raw: raw, + _marker: marker::PhantomData, + } + } +} + +impl<'repo> Iterator for Branches<'repo> { + type Item = (Branch<'repo>, BranchType); + fn next(&mut self) -> Option<(Branch<'repo>, BranchType)> { + let mut ret = 0 as *mut raw::git_reference; + let mut typ = raw::GIT_BRANCH_LOCAL; + unsafe { + let rc = raw::git_branch_next(&mut ret, &mut typ, self.raw); + if rc == raw::GIT_ITEROVER as libc::c_int { + return None + } + assert_eq!(rc, 0); + let typ = match typ { + raw::GIT_BRANCH_LOCAL => BranchType::Local, + raw::GIT_BRANCH_REMOTE => BranchType::Remote, + raw::GIT_BRANCH_ALL => panic!("unexected branch type"), + }; + Some((Branch::wrap(Binding::from_raw(ret)), typ)) + } + } +} + +impl<'repo> Drop for Branches<'repo> { + fn drop(&mut self) { + unsafe { raw::git_branch_iterator_free(self.raw) } + } +} + +#[cfg(test)] +mod tests { + use BranchType; + + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let head = repo.head().unwrap(); + let target = head.target().unwrap(); + let commit = repo.find_commit(target).unwrap(); + + let mut b1 = repo.branch("foo", &commit, false).unwrap(); + assert!(!b1.is_head()); + repo.branch("foo2", &commit, false).unwrap(); + + assert_eq!(repo.branches(None).unwrap().count(), 3); + repo.find_branch("foo", BranchType::Local).unwrap(); + let mut b1 = b1.rename("bar", false).unwrap(); + assert_eq!(b1.name().unwrap(), Some("bar")); + assert!(b1.upstream().is_err()); + b1.set_upstream(Some("master")).unwrap(); + b1.upstream().unwrap(); + b1.set_upstream(None).unwrap(); + + b1.delete().unwrap(); + } +} diff --git a/deps/git2-0.2.12/src/buf.rs b/deps/git2-0.2.12/src/buf.rs new file mode 100644 index 000000000..330f948bc --- /dev/null +++ b/deps/git2-0.2.12/src/buf.rs @@ -0,0 +1,67 @@ +use std::slice; +use std::str; +use std::ops::{Deref, DerefMut}; +use libc; + +use raw; +use util::Binding; + +/// A structure to wrap an intermediate buffer used by libgit2. +/// +/// A buffer can be thought of a `Vec`, but the `Vec` type is not used to +/// avoid copying data back and forth. +pub struct Buf { + raw: raw::git_buf, +} + +impl Buf { + /// Creates a new empty buffer. + pub fn new() -> Buf { + ::init(); + unsafe { + Binding::from_raw(&mut raw::git_buf { + ptr: 0 as *mut libc::c_char, + size: 0, + asize: 0, + } as *mut _) + } + } + + /// Attempt to view this buffer as a string slice. + /// + /// Returns `None` if the buffer is not valid utf-8. + pub fn as_str(&self) -> Option<&str> { str::from_utf8(&**self).ok() } +} + +impl Deref for Buf { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self.raw.ptr as *const u8, + self.raw.size as usize) + } + } +} + +impl DerefMut for Buf { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self.raw.ptr as *mut u8, + self.raw.size as usize) + } + } +} + +impl Binding for Buf { + type Raw = *mut raw::git_buf; + unsafe fn from_raw(raw: *mut raw::git_buf) -> Buf { + Buf { raw: *raw } + } + fn raw(&self) -> *mut raw::git_buf { &self.raw as *const _ as *mut _ } +} + +impl Drop for Buf { + fn drop(&mut self) { + unsafe { raw::git_buf_free(&mut self.raw) } + } +} diff --git a/deps/git2-0.2.12/src/build.rs b/deps/git2-0.2.12/src/build.rs new file mode 100644 index 000000000..2c917ed5d --- /dev/null +++ b/deps/git2-0.2.12/src/build.rs @@ -0,0 +1,465 @@ +//! Builder-pattern objects for configuration various git operations. + +use std::ffi::{CStr, CString}; +use std::mem; +use std::path::Path; +use libc::{c_char, size_t, c_void, c_uint, c_int}; + +use {raw, Error, Repository, RemoteCallbacks, IntoCString}; +use util::{self, Binding}; + +/// A builder struct which is used to build configuration for cloning a new git +/// repository. +pub struct RepoBuilder<'cb> { + bare: bool, + branch: Option, + local: bool, + hardlinks: bool, + checkout: Option>, + callbacks: Option>, +} + +/// A builder struct for configuring checkouts of a repository. +pub struct CheckoutBuilder<'cb> { + their_label: Option, + our_label: Option, + ancestor_label: Option, + target_dir: Option, + paths: Vec, + path_ptrs: Vec<*const c_char>, + file_perm: Option, + dir_perm: Option, + disable_filters: bool, + checkout_opts: u32, + progress: Option>>, +} + +/// Checkout progress notification callback. +/// +/// The first argument is the path for the notification, the next is the numver +/// of completed steps so far, and the final is the total number of steps. +pub type Progress<'a> = FnMut(&Path, usize, usize) + 'a; + +impl<'cb> RepoBuilder<'cb> { + /// Creates a new repository builder with all of the default configuration. + /// + /// When ready, the `clone()` method can be used to clone a new repository + /// using this configuration. + pub fn new() -> RepoBuilder<'cb> { + ::init(); + RepoBuilder { + bare: false, + branch: None, + local: true, + hardlinks: true, + checkout: None, + callbacks: None, + } + } + + /// Indicate whether the repository will be cloned as a bare repository or + /// not. + pub fn bare(&mut self, bare: bool) -> &mut RepoBuilder<'cb> { + self.bare = bare; + self + } + + /// Specify the name of the branch to check out after the clone. + /// + /// If not specified, the remote's default branch will be used. + pub fn branch(&mut self, branch: &str) -> &mut RepoBuilder<'cb> { + self.branch = Some(CString::new(branch).unwrap()); + self + } + + /// Set the flag for bypassing the git aware transport mechanism for local + /// paths. + /// + /// If `true`, the git-aware transport will be bypassed for local paths. If + /// `false`, the git-aware transport will not be bypassed. + pub fn local(&mut self, local: bool) -> &mut RepoBuilder<'cb> { + self.local = local; + self + } + + /// Set the flag for whether hardlinks are used when using a local git-aware + /// transport mechanism. + pub fn hardlinks(&mut self, links: bool) -> &mut RepoBuilder<'cb> { + self.hardlinks = links; + self + } + + /// Configure the checkout which will be performed by consuming a checkout + /// builder. + pub fn with_checkout(&mut self, checkout: CheckoutBuilder<'cb>) + -> &mut RepoBuilder<'cb> { + self.checkout = Some(checkout); + self + } + + /// Set the callbacks which will be used to monitor the download progress. + pub fn remote_callbacks(&mut self, callbacks: RemoteCallbacks<'cb>) + -> &mut RepoBuilder<'cb> { + self.callbacks = Some(callbacks); + self + } + + /// Clone a remote repository. + /// + /// This will use the options configured so far to clone the specified url + /// into the specified local path. + pub fn clone(&mut self, url: &str, into: &Path) -> Result { + let mut opts: raw::git_clone_options = unsafe { mem::zeroed() }; + unsafe { + try_call!(raw::git_clone_init_options(&mut opts, + raw::GIT_CLONE_OPTIONS_VERSION)); + } + opts.bare = self.bare as c_int; + opts.checkout_branch = self.branch.as_ref().map(|s| { + s.as_ptr() + }).unwrap_or(0 as *const _); + + opts.local = match (self.local, self.hardlinks) { + (true, false) => raw::GIT_CLONE_LOCAL_NO_LINKS, + (false, _) => raw::GIT_CLONE_NO_LOCAL, + (true, _) => raw::GIT_CLONE_LOCAL_AUTO, + }; + opts.checkout_opts.checkout_strategy = + raw::GIT_CHECKOUT_SAFE as c_uint; + + match self.callbacks { + Some(ref mut cbs) => { + opts.remote_callbacks = cbs.raw(); + }, + None => {} + } + + match self.checkout { + Some(ref mut c) => unsafe { c.configure(&mut opts.checkout_opts) }, + None => {} + } + + let url = try!(CString::new(url)); + let into = try!(into.into_c_string()); + let mut raw = 0 as *mut raw::git_repository; + unsafe { + try_call!(raw::git_clone(&mut raw, url, into, &opts)); + Ok(Binding::from_raw(raw)) + } + } +} + +impl<'cb> CheckoutBuilder<'cb> { + /// Creates a new builder for checkouts with all of its default + /// configuration. + pub fn new() -> CheckoutBuilder<'cb> { + ::init(); + CheckoutBuilder { + disable_filters: false, + dir_perm: None, + file_perm: None, + path_ptrs: Vec::new(), + paths: Vec::new(), + target_dir: None, + ancestor_label: None, + our_label: None, + their_label: None, + checkout_opts: raw::GIT_CHECKOUT_SAFE as u32, + progress: None, + } + } + + /// Indicate that this checkout should perform a dry run by checking for + /// conflicts but not make any actual changes. + pub fn dry_run(&mut self) -> &mut CheckoutBuilder<'cb> { + self.checkout_opts &= !((1 << 4) - 1); + self.checkout_opts |= raw::GIT_CHECKOUT_NONE as u32; + self + } + + /// Take any action necessary to get the working directory to match the + /// target including potentially discarding modified files. + pub fn force(&mut self) -> &mut CheckoutBuilder<'cb> { + self.checkout_opts &= !((1 << 4) - 1); + self.checkout_opts |= raw::GIT_CHECKOUT_FORCE as u32; + self + } + + /// Indicate that the checkout should be performed safely, allowing new + /// files to be created but not overwriting extisting files or changes. + /// + /// This is the default. + pub fn safe(&mut self) -> &mut CheckoutBuilder<'cb> { + self.checkout_opts &= !((1 << 4) - 1); + self.checkout_opts |= raw::GIT_CHECKOUT_SAFE as u32; + self + } + + fn flag(&mut self, bit: raw::git_checkout_strategy_t, + on: bool) -> &mut CheckoutBuilder<'cb> { + if on { + self.checkout_opts |= bit as u32; + } else { + self.checkout_opts &= !(bit as u32); + } + self + } + + /// In safe mode, apply safe file updates even when there are conflicts + /// instead of canceling the checkout. + /// + /// Defaults to false. + pub fn allow_conflicts(&mut self, allow: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_ALLOW_CONFLICTS, allow) + } + + /// Remove untracked files from the working dir. + /// + /// Defaults to false. + pub fn remove_untracked(&mut self, remove: bool) + -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_REMOVE_UNTRACKED, remove) + } + + /// Remove ignored files from the working dir. + /// + /// Defaults to false. + pub fn remove_ignored(&mut self, remove: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_REMOVE_IGNORED, remove) + } + + /// Only update the contents of files that already exist. + /// + /// If set, files will not be created or deleted. + /// + /// Defaults to false. + pub fn update_only(&mut self, update: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_UPDATE_ONLY, update) + } + + /// Prevents checkout from writing the updated files' information to the + /// index. + /// + /// Defaults to true. + pub fn update_index(&mut self, update: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_DONT_UPDATE_INDEX, !update) + } + + /// Indicate whether the index and git attributes should be refreshed from + /// disk before any operations. + /// + /// Defaults to true, + pub fn refresh(&mut self, refresh: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_NO_REFRESH, !refresh) + } + + /// Skip files with unmerged index entries. + /// + /// Defaults to false. + pub fn skip_unmerged(&mut self, skip: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_SKIP_UNMERGED, skip) + } + + /// Indicate whether the checkout should proceed on conflicts by using the + /// stage 2 version of the file ("ours"). + /// + /// Defaults to false. + pub fn use_ours(&mut self, ours: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_USE_OURS, ours) + } + + /// Indicate whether the checkout should proceed on conflicts by using the + /// stage 3 version of the file ("theirs"). + /// + /// Defaults to false. + pub fn use_theirs(&mut self, theirs: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_USE_THEIRS, theirs) + } + + /// Indicate whether ignored files should be overwritten during the checkout. + /// + /// Defaults to true. + pub fn overwrite_ignored(&mut self, overwrite: bool) + -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_DONT_OVERWRITE_IGNORED, !overwrite) + } + + /// Indicate whether a normal merge file should be written for conflicts. + /// + /// Defaults to false. + pub fn conflict_style_merge(&mut self, on: bool) + -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_MERGE, on) + } + + /// Indicates whether to include common ancestor data in diff3 format files + /// for conflicts. + /// + /// Defaults to false. + pub fn conflict_style_diff3(&mut self, on: bool) + -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_DIFF3, on) + } + + /// Indicate whether to apply filters like CRLF conversion. + pub fn disable_filters(&mut self, disable: bool) + -> &mut CheckoutBuilder<'cb> { + self.disable_filters = disable; + self + } + + /// Set the mode with which new directories are created. + /// + /// Default is 0755 + pub fn dir_perm(&mut self, perm: i32) -> &mut CheckoutBuilder<'cb> { + self.dir_perm = Some(perm); + self + } + + /// Set the mode with which new files are created. + /// + /// The default is 0644 or 0755 as dictated by the blob. + pub fn file_perm(&mut self, perm: i32) -> &mut CheckoutBuilder<'cb> { + self.file_perm = Some(perm); + self + } + + /// Add a path to be checked out. + /// + /// If no paths are specified, then all files are checked out. Otherwise + /// only these specified paths are checked out. + pub fn path(&mut self, path: T) + -> &mut CheckoutBuilder<'cb> { + let path = path.into_c_string().unwrap(); + self.path_ptrs.push(path.as_ptr()); + self.paths.push(path); + self + } + + /// Set the directory to check out to + pub fn target_dir(&mut self, dst: &Path) -> &mut CheckoutBuilder<'cb> { + self.target_dir = Some(dst.into_c_string().unwrap()); + self + } + + /// The name of the common ancestor side of conflicts + pub fn ancestor_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { + self.ancestor_label = Some(CString::new(label).unwrap()); + self + } + + /// The name of the common our side of conflicts + pub fn our_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { + self.our_label = Some(CString::new(label).unwrap()); + self + } + + /// The name of the common their side of conflicts + pub fn their_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { + self.their_label = Some(CString::new(label).unwrap()); + self + } + + /// Set a callback to receive notifications of checkout progress. + pub fn progress(&mut self, cb: F) -> &mut CheckoutBuilder<'cb> + where F: FnMut(&Path, usize, usize) + 'cb { + self.progress = Some(Box::new(cb) as Box>); + self + } + + /// Configure a raw checkout options based on this configuration. + /// + /// This method is unsafe as there is no guarantee that this structure will + /// outlive the provided checkout options. + pub unsafe fn configure(&mut self, opts: &mut raw::git_checkout_options) { + opts.version = raw::GIT_CHECKOUT_OPTIONS_VERSION; + opts.disable_filters = self.disable_filters as c_int; + opts.dir_mode = self.dir_perm.unwrap_or(0) as c_uint; + opts.file_mode = self.file_perm.unwrap_or(0) as c_uint; + + if self.path_ptrs.len() > 0 { + opts.paths.strings = self.path_ptrs.as_ptr() as *mut _; + opts.paths.count = self.path_ptrs.len() as size_t; + } + + match self.target_dir { + Some(ref c) => opts.target_directory = c.as_ptr(), + None => {} + } + match self.ancestor_label { + Some(ref c) => opts.ancestor_label = c.as_ptr(), + None => {} + } + match self.our_label { + Some(ref c) => opts.our_label = c.as_ptr(), + None => {} + } + match self.their_label { + Some(ref c) => opts.their_label = c.as_ptr(), + None => {} + } + if self.progress.is_some() { + let f: raw::git_checkout_progress_cb = progress_cb; + opts.progress_cb = Some(f); + opts.progress_payload = self as *mut _ as *mut _; + } + opts.checkout_strategy = self.checkout_opts as c_uint; + } +} + +wrap_env! { + fn progress_cb(path: *const c_char, + completed: size_t, + total: size_t, + data: *mut c_void) -> () { + unsafe { + let payload = &mut *(data as *mut CheckoutBuilder); + let callback = match payload.progress { + Some(ref mut c) => c, + None => return, + }; + let path = CStr::from_ptr(path).to_bytes(); + callback(util::bytes2path(path), completed as usize, total as usize) + } + } + returning _ok as () +} + +#[cfg(test)] +mod tests { + use std::fs; + use std::path::Path; + use tempdir::TempDir; + use super::RepoBuilder; + use Repository; + + #[test] + fn smoke() { + let r = RepoBuilder::new().clone("/path/to/nowhere", Path::new("foo")); + assert!(r.is_err()); + } + + #[test] + fn smoke2() { + let td = TempDir::new("test").unwrap(); + Repository::init_bare(&td.path().join("bare")).unwrap(); + let url = if cfg!(unix) { + format!("file://{}/bare", td.path().display()) + } else { + format!("file:///{}/bare", td.path().display().to_string() + .replace("\\", "/")) + }; + + let dst = td.path().join("foo"); + RepoBuilder::new().clone(&url, &dst).unwrap(); + fs::remove_dir_all(&dst).unwrap(); + RepoBuilder::new().local(false).clone(&url, &dst).unwrap(); + fs::remove_dir_all(&dst).unwrap(); + RepoBuilder::new().local(false).hardlinks(false).bare(true) + .clone(&url, &dst).unwrap(); + fs::remove_dir_all(&dst).unwrap(); + assert!(RepoBuilder::new().branch("foo") + .clone(&url, &dst).is_err()); + } + +} diff --git a/deps/git2-0.2.12/src/call.rs b/deps/git2-0.2.12/src/call.rs new file mode 100644 index 000000000..e64dafdbe --- /dev/null +++ b/deps/git2-0.2.12/src/call.rs @@ -0,0 +1,160 @@ +#![macro_use] +use libc; + +use Error; + +macro_rules! call { + (raw::$p:ident ($($e:expr),*)) => ( + raw::$p($(::call::convert(&$e)),*) + ) +} + +macro_rules! try_call { + (raw::$p:ident ($($e:expr),*)) => ({ + match ::call::try(raw::$p($(::call::convert(&$e)),*)) { + Ok(o) => o, + Err(e) => { ::panic::check(); return Err(e) } + } + }) +} + +#[doc(hidden)] +pub trait Convert { + fn convert(&self) -> T; +} + +pub fn convert>(u: &U) -> T { u.convert() } + +pub fn try(ret: libc::c_int) -> Result { + match ret { + n if n < 0 => Err(last_error()), + n => Ok(n), + } +} + +fn last_error() -> Error { + // Apparently libgit2 isn't necessarily guaranteed to set the last error + // whenever a function returns a negative value! + Error::last_error().unwrap_or_else(|| { + Error::from_str("an unknown error occurred") + }) +} + +mod impls { + use std::ffi::CString; + use libc; + + use {raw, ConfigLevel, ResetType, ObjectType, BranchType, Direction}; + use {DiffFormat}; + use call::Convert; + + impl Convert for T { + fn convert(&self) -> T { *self } + } + + impl Convert for bool { + fn convert(&self) -> libc::c_int { *self as libc::c_int } + } + impl<'a, T> Convert<*const T> for &'a T { + fn convert(&self) -> *const T { *self as *const T } + } + impl<'a, T> Convert<*mut T> for &'a mut T { + fn convert(&self) -> *mut T { &**self as *const T as *mut T } + } + impl Convert<*const T> for *mut T { + fn convert(&self) -> *const T { *self as *const T } + } + + impl Convert<*const libc::c_char> for CString { + fn convert(&self) -> *const libc::c_char { self.as_ptr() } + } + + impl> Convert<*const T> for Option { + fn convert(&self) -> *const T { + self.as_ref().map(|s| s.convert()).unwrap_or(0 as *const _) + } + } + + impl> Convert<*mut T> for Option { + fn convert(&self) -> *mut T { + self.as_ref().map(|s| s.convert()).unwrap_or(0 as *mut _) + } + } + + impl Convert for ResetType { + fn convert(&self) -> raw::git_reset_t { + match *self { + ResetType::Soft => raw::GIT_RESET_SOFT, + ResetType::Hard => raw::GIT_RESET_HARD, + ResetType::Mixed => raw::GIT_RESET_MIXED, + } + } + } + + impl Convert for Direction { + fn convert(&self) -> raw::git_direction { + match *self { + Direction::Push => raw::GIT_DIRECTION_PUSH, + Direction::Fetch => raw::GIT_DIRECTION_FETCH, + } + } + } + + impl Convert for ObjectType { + fn convert(&self) -> raw::git_otype { + match *self { + ObjectType::Any => raw::GIT_OBJ_ANY, + ObjectType::Commit => raw::GIT_OBJ_COMMIT, + ObjectType::Tree => raw::GIT_OBJ_TREE, + ObjectType::Blob => raw::GIT_OBJ_BLOB, + ObjectType::Tag => raw::GIT_OBJ_TAG, + } + } + } + + impl Convert for Option { + fn convert(&self) -> raw::git_otype { + self.unwrap_or(ObjectType::Any).convert() + } + } + + impl Convert for BranchType { + fn convert(&self) -> raw::git_branch_t { + match *self { + BranchType::Remote => raw::GIT_BRANCH_REMOTE, + BranchType::Local => raw::GIT_BRANCH_LOCAL, + } + } + } + + impl Convert for Option { + fn convert(&self) -> raw::git_branch_t { + self.map(|s| s.convert()).unwrap_or(raw::GIT_BRANCH_ALL) + } + } + + impl Convert for ConfigLevel { + fn convert(&self) -> raw::git_config_level_t { + match *self { + ConfigLevel::System => raw::GIT_CONFIG_LEVEL_SYSTEM, + ConfigLevel::XDG => raw::GIT_CONFIG_LEVEL_XDG, + ConfigLevel::Global => raw::GIT_CONFIG_LEVEL_GLOBAL, + ConfigLevel::Local => raw::GIT_CONFIG_LEVEL_LOCAL, + ConfigLevel::App => raw::GIT_CONFIG_LEVEL_APP, + ConfigLevel::Highest => raw::GIT_CONFIG_HIGHEST_LEVEL, + } + } + } + + impl Convert for DiffFormat { + fn convert(&self) -> raw::git_diff_format_t { + match *self { + DiffFormat::Patch => raw::GIT_DIFF_FORMAT_PATCH, + DiffFormat::PatchHeader => raw::GIT_DIFF_FORMAT_PATCH_HEADER, + DiffFormat::Raw => raw::GIT_DIFF_FORMAT_RAW, + DiffFormat::NameOnly => raw::GIT_DIFF_FORMAT_NAME_ONLY, + DiffFormat::NameStatus => raw::GIT_DIFF_FORMAT_NAME_STATUS, + } + } + } +} diff --git a/deps/git2-0.2.12/src/cert.rs b/deps/git2-0.2.12/src/cert.rs new file mode 100644 index 000000000..70ab9498f --- /dev/null +++ b/deps/git2-0.2.12/src/cert.rs @@ -0,0 +1,97 @@ +//! Certificate types which are passed to `CertificateCheck` in +//! `RemoteCallbacks`. + +use std::marker; +use std::mem; +use std::slice; + +use raw; +use util::Binding; + +/// A certificate for a remote connection, viewable as one of `CertHostkey` or +/// `CertX509` currently. +pub struct Cert<'a> { + raw: *mut raw::git_cert, + _marker: marker::PhantomData<&'a raw::git_cert>, +} + +/// Hostkey information taken from libssh2 +pub struct CertHostkey<'a> { + raw: *mut raw::git_cert_hostkey, + _marker: marker::PhantomData<&'a raw::git_cert>, +} + +/// X.509 certificate information +pub struct CertX509<'a> { + raw: *mut raw::git_cert_x509, + _marker: marker::PhantomData<&'a raw::git_cert>, +} + +impl<'a> Cert<'a> { + /// Attempt to view this certificate as an SSH hostkey. + /// + /// Returns `None` if this is not actually an SSH hostkey. + pub fn as_hostkey(&self) -> Option<&CertHostkey<'a>> { + self.cast(raw::GIT_CERT_HOSTKEY_LIBSSH2) + } + + /// Attempt to view this certificate as an X.509 certificate. + /// + /// Returns `None` if this is not actually an X.509 certificate. + pub fn as_x509(&self) -> Option<&CertX509<'a>> { + self.cast(raw::GIT_CERT_X509) + } + + fn cast(&self, kind: raw::git_cert_t) -> Option<&T> { + assert_eq!(mem::size_of::>(), mem::size_of::()); + unsafe { + if kind == (*self.raw).cert_type { + Some(&*(self as *const Cert<'a> as *const T)) + } else { + None + } + } + } +} + +impl<'a> CertHostkey<'a> { + /// Returns the md5 hash of the hostkey, if available. + pub fn hash_md5(&self) -> Option<&[u8; 16]> { + unsafe { + if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_MD5 as u32 == 0 { + None + } else { + Some(&(*self.raw).hash_md5) + } + } + } + + /// Returns the SHA-1 hash of the hostkey, if available. + pub fn hash_sha1(&self) -> Option<&[u8; 20]> { + unsafe { + if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_SHA1 as u32 == 0 { + None + } else { + Some(&(*self.raw).hash_sha1) + } + } + } +} + +impl<'a> CertX509<'a> { + /// Return the X.509 certificate data as a byte slice + pub fn data(&self) -> &[u8] { + unsafe { + slice::from_raw_parts((*self.raw).data as *const u8, + (*self.raw).len as usize) + } + } +} + +impl<'a> Binding for Cert<'a> { + type Raw = *mut raw::git_cert; + unsafe fn from_raw(raw: *mut raw::git_cert) -> Cert<'a> { + Cert { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_cert { self.raw } +} diff --git a/deps/git2-0.2.12/src/commit.rs b/deps/git2-0.2.12/src/commit.rs new file mode 100644 index 000000000..3d940179f --- /dev/null +++ b/deps/git2-0.2.12/src/commit.rs @@ -0,0 +1,322 @@ +use std::marker; +use std::ops::Range; +use std::str; +use libc; + +use {raw, signature, Oid, Error, Signature, Tree, Time, Object}; +use util::Binding; + +/// A structure to represent a git [commit][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects +pub struct Commit<'repo> { + raw: *mut raw::git_commit, + _marker: marker::PhantomData>, +} + +/// An iterator over the parent commits of a commit. +pub struct Parents<'commit, 'repo: 'commit> { + range: Range, + commit: &'commit Commit<'repo>, +} + +/// An iterator over the parent commits' ids of a commit. +pub struct ParentIds<'commit> { + range: Range, + commit: &'commit Commit<'commit>, +} + +impl<'repo> Commit<'repo> { + /// Get the id (SHA1) of a repository commit + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_commit_id(&*self.raw)) } + } + + /// Get the id of the tree pointed to by this commit. + /// + /// No attempts are made to fetch an object from the ODB. + pub fn tree_id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_commit_tree_id(&*self.raw)) } + } + + /// Get the tree pointed to by a commit. + pub fn tree(&self) -> Result, Error> { + let mut ret = 0 as *mut raw::git_tree; + unsafe { + try_call!(raw::git_commit_tree(&mut ret, &*self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Get access to the underlying raw pointer. + pub fn raw(&self) -> *mut raw::git_commit { self.raw } + + /// Get the full message of a commit. + /// + /// The returned message will be slightly prettified by removing any + /// potential leading newlines. + /// + /// `None` will be returned if the message is not valid utf-8 + pub fn message(&self) -> Option<&str> { + str::from_utf8(self.message_bytes()).ok() + } + + /// Get the full message of a commit as a byte slice. + /// + /// The returned message will be slightly prettified by removing any + /// potential leading newlines. + pub fn message_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_commit_message(&*self.raw)).unwrap() + } + } + + /// Get the encoding for the message of a commit, as a string representing a + /// standard encoding name. + /// + /// `None` will be returned if the encoding is not known + pub fn message_encoding(&self) -> Option<&str> { + let bytes = unsafe { + ::opt_bytes(self, raw::git_commit_message(&*self.raw)) + }; + bytes.map(|b| str::from_utf8(b).unwrap()) + } + + /// Get the full raw message of a commit. + /// + /// `None` will be returned if the message is not valid utf-8 + pub fn message_raw(&self) -> Option<&str> { + str::from_utf8(self.message_raw_bytes()).ok() + } + + /// Get the full raw message of a commit. + pub fn message_raw_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_commit_message_raw(&*self.raw)).unwrap() + } + } + + /// Get the full raw text of the commit header. + /// + /// `None` will be returned if the message is not valid utf-8 + pub fn raw_header(&self) -> Option<&str> { + str::from_utf8(self.raw_header_bytes()).ok() + } + + /// Get the full raw text of the commit header. + pub fn raw_header_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_commit_raw_header(&*self.raw)).unwrap() + } + } + + /// Get the short "summary" of the git commit message. + /// + /// The returned message is the summary of the commit, comprising the first + /// paragraph of the message with whitespace trimmed and squashed. + /// + /// `None` may be returned if an error occurs or if the summary is not valid + /// utf-8. + pub fn summary(&mut self) -> Option<&str> { + self.summary_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the short "summary" of the git commit message. + /// + /// The returned message is the summary of the commit, comprising the first + /// paragraph of the message with whitespace trimmed and squashed. + /// + /// `None` may be returned if an error occurs + pub fn summary_bytes(&mut self) -> Option<&[u8]> { + unsafe { ::opt_bytes(self, raw::git_commit_summary(self.raw)) } + } + + /// Get the commit time (i.e. committer time) of a commit. + /// + /// The first element of the tuple is the time, in seconds, since the epoch. + /// The second element is the offset, in minutes, of the time zone of the + /// committer's preferred time zone. + pub fn time(&self) -> Time { + unsafe { + Time::new(raw::git_commit_time(&*self.raw) as i64, + raw::git_commit_time_offset(&*self.raw) as i32) + } + } + + /// Creates a new iterator over the parents of this commit. + pub fn parents<'a>(&'a self) -> Parents<'a, 'repo> { + let max = unsafe { raw::git_commit_parentcount(&*self.raw) as usize }; + Parents { range: 0..max, commit: self } + } + + /// Creates a new iterator over the parents of this commit. + pub fn parent_ids(&self) -> ParentIds { + let max = unsafe { raw::git_commit_parentcount(&*self.raw) as usize }; + ParentIds { range: 0..max, commit: self } + } + + /// Get the author of this commit. + pub fn author(&self) -> Signature { + unsafe { + let ptr = raw::git_commit_author(&*self.raw); + signature::from_raw_const(self, ptr) + } + } + + /// Get the committer of this commit. + pub fn committer(&self) -> Signature { + unsafe { + let ptr = raw::git_commit_committer(&*self.raw); + signature::from_raw_const(self, ptr) + } + } + + /// Amend this existing commit with all non-`None` values + /// + /// This creates a new commit that is exactly the same as the old commit, + /// except that any non-`None` values will be updated. The new commit has + /// the same parents as the old commit. + /// + /// For information about `update_ref`, see `new`. + pub fn amend(&self, + update_ref: Option<&str>, + author: Option<&Signature>, + committer: Option<&Signature>, + message_encoding: Option<&str>, + message: Option<&str>, + tree: Option<&Tree<'repo>>) -> Result { + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + let update_ref = try!(::opt_cstr(update_ref)); + let encoding = try!(::opt_cstr(message_encoding)); + let message = try!(::opt_cstr(message)); + unsafe { + try_call!(raw::git_commit_amend(&mut raw, + self.raw(), + update_ref, + author.map(|s| s.raw()), + committer.map(|s| s.raw()), + encoding, + message, + tree.map(|t| t.raw()))); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Get the specified parent of the commit. + /// + /// Use the `parents` iterator to return an iterator over all parents. + pub fn parent(&self, i: usize) -> Result, Error> { + unsafe { + let mut raw = 0 as *mut raw::git_commit; + try_call!(raw::git_commit_parent(&mut raw, &*self.raw, + i as libc::c_uint)); + Ok(Binding::from_raw(raw)) + } + } + + /// Get the specified parent id of the commit. + /// + /// This is different from `parent`, which will attemptstempt to load the + /// parent commit from the ODB. + /// + /// Use the `parent_ids` iterator to return an iterator over all parents. + pub fn parent_id(&self, i: usize) -> Result { + unsafe { + let id = raw::git_commit_parent_id(self.raw, i as libc::c_uint); + if id.is_null() { + Err(Error::from_str("parent index out of bounds")) + } else { + Ok(Binding::from_raw(id)) + } + } + } +} + +impl<'repo> Binding for Commit<'repo> { + type Raw = *mut raw::git_commit; + unsafe fn from_raw(raw: *mut raw::git_commit) -> Commit<'repo> { + Commit { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *mut raw::git_commit { self.raw } +} + + +impl<'repo, 'commit> Iterator for Parents<'commit, 'repo> { + type Item = Commit<'repo>; + fn next(&mut self) -> Option> { + self.range.next().map(|i| self.commit.parent(i).unwrap()) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} + +impl<'repo, 'commit> DoubleEndedIterator for Parents<'commit, 'repo> { + fn next_back(&mut self) -> Option> { + self.range.next_back().map(|i| self.commit.parent(i).unwrap()) + } +} + +impl<'repo, 'commit> ExactSizeIterator for Parents<'commit, 'repo> {} + +impl<'commit> Iterator for ParentIds<'commit> { + type Item = Oid; + fn next(&mut self) -> Option { + self.range.next().map(|i| self.commit.parent_id(i).unwrap()) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} + +impl<'commit> DoubleEndedIterator for ParentIds<'commit> { + fn next_back(&mut self) -> Option { + self.range.next_back().map(|i| self.commit.parent_id(i).unwrap()) + } +} + +impl<'commit> ExactSizeIterator for ParentIds<'commit> {} + +impl<'repo> Drop for Commit<'repo> { + fn drop(&mut self) { + unsafe { raw::git_commit_free(self.raw) } + } +} + +#[cfg(test)] +mod tests { + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let head = repo.head().unwrap(); + let target = head.target().unwrap(); + let mut commit = repo.find_commit(target).unwrap(); + assert_eq!(commit.message(), Some("initial")); + assert_eq!(commit.id(), target); + commit.message_raw().unwrap(); + commit.raw_header().unwrap(); + commit.message_encoding(); + commit.summary().unwrap(); + commit.tree_id(); + commit.tree().unwrap(); + assert_eq!(commit.parents().count(), 0); + + assert_eq!(commit.author().name(), Some("name")); + assert_eq!(commit.author().email(), Some("email")); + assert_eq!(commit.committer().name(), Some("name")); + assert_eq!(commit.committer().email(), Some("email")); + + let sig = repo.signature().unwrap(); + let tree = repo.find_tree(commit.tree_id()).unwrap(); + let id = repo.commit(Some("HEAD"), &sig, &sig, "bar", &tree, + &[&commit]).unwrap(); + let head = repo.find_commit(id).unwrap(); + + let new_head = head.amend(Some("HEAD"), None, None, None, + Some("new message"), None).unwrap(); + let new_head = repo.find_commit(new_head).unwrap(); + assert_eq!(new_head.message(), Some("new message")); + + repo.find_object(target, None).unwrap().as_commit().unwrap(); + } +} + diff --git a/deps/git2-0.2.12/src/config.rs b/deps/git2-0.2.12/src/config.rs new file mode 100644 index 000000000..d02a305c6 --- /dev/null +++ b/deps/git2-0.2.12/src/config.rs @@ -0,0 +1,500 @@ +use std::ffi::CString; +use std::marker; +use std::path::{Path, PathBuf}; +use std::str; +use libc; + +use {raw, Error, ConfigLevel, Buf, IntoCString}; +use util::{self, Binding}; + +/// A structure representing a git configuration key/value store +pub struct Config { + raw: *mut raw::git_config, +} + +/// A struct representing a certain entry owned by a `Config` instance. +/// +/// An entry has a name, a value, and a level it applies to. +pub struct ConfigEntry<'cfg> { + raw: *mut raw::git_config_entry, + _marker: marker::PhantomData<&'cfg Config>, + owned: bool, +} + +/// An iterator over the `ConfigEntry` values of a `Config` structure. +pub struct ConfigEntries<'cfg> { + raw: *mut raw::git_config_iterator, + _marker: marker::PhantomData<&'cfg Config>, +} + +impl Config { + /// Allocate a new configuration object + /// + /// This object is empty, so you have to add a file to it before you can do + /// anything with it. + pub fn new() -> Result { + ::init(); + let mut raw = 0 as *mut raw::git_config; + unsafe { + try_call!(raw::git_config_new(&mut raw)); + Ok(Binding::from_raw(raw)) + } + } + + /// Create a new config instance containing a single on-disk file + pub fn open(path: &Path) -> Result { + ::init(); + let mut raw = 0 as *mut raw::git_config; + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_config_open_ondisk(&mut raw, path)); + Ok(Binding::from_raw(raw)) + } + } + + /// Open the global, XDG and system configuration files + /// + /// Utility wrapper that finds the global, XDG and system configuration + /// files and opens them into a single prioritized config object that can + /// be used when accessing default config data outside a repository. + pub fn open_default() -> Result { + ::init(); + let mut raw = 0 as *mut raw::git_config; + unsafe { + try_call!(raw::git_config_open_default(&mut raw)); + Ok(Binding::from_raw(raw)) + } + } + + /// Locate the path to the global configuration file + /// + /// The user or global configuration file is usually located in + /// `$HOME/.gitconfig`. + /// + /// This method will try to guess the full path to that file, if the file + /// exists. The returned path may be used on any method call to load + /// the global configuration file. + /// + /// This method will not guess the path to the xdg compatible config file + /// (`.config/git/config`). + pub fn find_global() -> Result { + ::init(); + let buf = Buf::new(); + unsafe { try_call!(raw::git_config_find_global(buf.raw())); } + Ok(util::bytes2path(&buf).to_path_buf()) + } + + /// Locate the path to the system configuration file + /// + /// If /etc/gitconfig doesn't exist, it will look for %PROGRAMFILES% + pub fn find_system() -> Result { + ::init(); + let buf = Buf::new(); + unsafe { try_call!(raw::git_config_find_system(buf.raw())); } + Ok(util::bytes2path(&buf).to_path_buf()) + } + + /// Locate the path to the global xdg compatible configuration file + /// + /// The xdg compatible configuration file is usually located in + /// `$HOME/.config/git/config`. + pub fn find_xdg() -> Result { + ::init(); + let buf = Buf::new(); + unsafe { try_call!(raw::git_config_find_xdg(buf.raw())); } + Ok(util::bytes2path(&buf).to_path_buf()) + } + + /// Add an on-disk config file instance to an existing config + /// + /// The on-disk file pointed at by path will be opened and parsed; it's + /// expected to be a native Git config file following the default Git config + /// syntax (see man git-config). + /// + /// Further queries on this config object will access each of the config + /// file instances in order (instances with a higher priority level will be + /// accessed first). + pub fn add_file(&mut self, path: &Path, level: ConfigLevel, + force: bool) -> Result<(), Error> { + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_config_add_file_ondisk(self.raw, path, level, + force)); + Ok(()) + } + } + + /// Delete a config variable from the config file with the highest level + /// (usually the local one). + pub fn remove(&mut self, name: &str) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_delete_entry(self.raw, name)); + Ok(()) + } + } + + /// Get the value of a boolean config variable. + /// + /// All config files will be looked into, in the order of their defined + /// level. A higher level means a higher priority. The first occurrence of + /// the variable will be returned here. + pub fn get_bool(&self, name: &str) -> Result { + let mut out = 0 as libc::c_int; + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_bool(&mut out, &*self.raw, name)); + + } + Ok(if out == 0 {false} else {true}) + } + + /// Get the value of an integer config variable. + /// + /// All config files will be looked into, in the order of their defined + /// level. A higher level means a higher priority. The first occurrence of + /// the variable will be returned here. + pub fn get_i32(&self, name: &str) -> Result { + let mut out = 0i32; + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_int32(&mut out, &*self.raw, name)); + + } + Ok(out) + } + + /// Get the value of an integer config variable. + /// + /// All config files will be looked into, in the order of their defined + /// level. A higher level means a higher priority. The first occurrence of + /// the variable will be returned here. + pub fn get_i64(&self, name: &str) -> Result { + let mut out = 0i64; + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_int64(&mut out, &*self.raw, name)); + } + Ok(out) + } + + /// Get the value of a string config variable. + /// + /// This is the same as `get_bytes` except that it may return `Err` if + /// the bytes are not valid utf-8. + pub fn get_str(&self, name: &str) -> Result<&str, Error> { + str::from_utf8(try!(self.get_bytes(name))).map_err(|_| { + Error::from_str("configuration value is not valid utf8") + }) + } + + /// Get the value of a string config variable as a byte slice. + /// + /// This method will return an error if this `Config` is not a snapshot. + pub fn get_bytes(&self, name: &str) -> Result<&[u8], Error> { + let mut ret = 0 as *const libc::c_char; + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_string(&mut ret, &*self.raw, name)); + Ok(::opt_bytes(self, ret).unwrap()) + } + } + + /// Get the value of a string config variable as an owned string. + /// + /// An error will be returned if the config value is not valid utf-8. + pub fn get_string(&self, name: &str) -> Result { + let ret = Buf::new(); + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_string_buf(ret.raw(), self.raw, name)); + } + str::from_utf8(&ret).map(|s| s.to_string()).map_err(|_| { + Error::from_str("configuration value is not valid utf8") + }) + } + + /// Get the value of a path config variable as an owned . + pub fn get_path(&self, name: &str) -> Result { + let ret = Buf::new(); + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_path(ret.raw(), self.raw, name)); + } + Ok(::util::bytes2path(&ret).to_path_buf()) + } + + /// Get the ConfigEntry for a config variable. + pub fn get_entry(&self, name: &str) -> Result { + let mut ret = 0 as *mut raw::git_config_entry; + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_get_entry(&mut ret, self.raw, name)); + Ok(Binding::from_raw(ret)) + } + } + + /// Iterate over all the config variables + /// + /// If `glob` is `Some`, then the iterator will only iterate over all + /// variables whose name matches the pattern. + /// + /// # Example + /// + /// ``` + /// # #![allow(unstable)] + /// use git2::Config; + /// + /// let cfg = Config::new().unwrap(); + /// + /// for entry in &cfg.entries(None).unwrap() { + /// println!("{} => {}", entry.name().unwrap(), entry.value().unwrap()); + /// } + /// ``` + pub fn entries(&self, glob: Option<&str>) -> Result { + let mut ret = 0 as *mut raw::git_config_iterator; + unsafe { + match glob { + Some(s) => { + let s = try!(CString::new(s)); + try_call!(raw::git_config_iterator_glob_new(&mut ret, + &*self.raw, + s)); + } + None => { + try_call!(raw::git_config_iterator_new(&mut ret, &*self.raw)); + } + } + Ok(Binding::from_raw(ret)) + } + } + + /// Open the global/XDG configuration file according to git's rules + /// + /// Git allows you to store your global configuration at `$HOME/.config` or + /// `$XDG_CONFIG_HOME/git/config`. For backwards compatability, the XDG file + /// shouldn't be used unless the use has created it explicitly. With this + /// function you'll open the correct one to write to. + pub fn open_global(&mut self) -> Result { + let mut raw = 0 as *mut raw::git_config; + unsafe { + try_call!(raw::git_config_open_global(&mut raw, self.raw)); + Ok(Binding::from_raw(raw)) + } + } + + /// Build a single-level focused config object from a multi-level one. + /// + /// The returned config object can be used to perform get/set/delete + /// operations on a single specific level. + pub fn open_level(&self, level: ConfigLevel) -> Result { + let mut raw = 0 as *mut raw::git_config; + unsafe { + try_call!(raw::git_config_open_level(&mut raw, &*self.raw, level)); + Ok(Binding::from_raw(raw)) + } + } + + /// Set the value of a boolean config variable in the config file with the + /// highest level (usually the local one). + pub fn set_bool(&mut self, name: &str, value: bool) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_set_bool(self.raw, name, value)); + } + Ok(()) + } + + /// Set the value of an integer config variable in the config file with the + /// highest level (usually the local one). + pub fn set_i32(&mut self, name: &str, value: i32) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_set_int32(self.raw, name, value)); + } + Ok(()) + } + + /// Set the value of an integer config variable in the config file with the + /// highest level (usually the local one). + pub fn set_i64(&mut self, name: &str, value: i64) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_config_set_int64(self.raw, name, value)); + } + Ok(()) + } + + /// Set the value of a string config variable in the config file with the + /// highest level (usually the local one). + pub fn set_str(&mut self, name: &str, value: &str) -> Result<(), Error> { + let name = try!(CString::new(name)); + let value = try!(CString::new(value)); + unsafe { + try_call!(raw::git_config_set_string(self.raw, name, value)); + } + Ok(()) + } + + /// Create a snapshot of the configuration + /// + /// Create a snapshot of the current state of a configuration, which allows + /// you to look into a consistent view of the configuration for looking up + /// complex values (e.g. a remote, submodule). + pub fn snapshot(&mut self) -> Result { + let mut ret = 0 as *mut raw::git_config; + unsafe { + try_call!(raw::git_config_snapshot(&mut ret, self.raw)); + Ok(Binding::from_raw(ret)) + } + } +} + +impl Binding for Config { + type Raw = *mut raw::git_config; + unsafe fn from_raw(raw: *mut raw::git_config) -> Config { + Config { raw: raw } + } + fn raw(&self) -> *mut raw::git_config { self.raw } +} + +impl Drop for Config { + fn drop(&mut self) { + unsafe { raw::git_config_free(self.raw) } + } +} + +impl<'cfg> ConfigEntry<'cfg> { + /// Gets the name of this entry. + /// + /// May return `None` if the name is not valid utf-8 + pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } + + /// Gets the name of this entry as a byte slice. + pub fn name_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } + } + + /// Gets the value of this entry. + /// + /// May return `None` if the value is not valid utf-8 + pub fn value(&self) -> Option<&str> { str::from_utf8(self.value_bytes()).ok() } + + /// Gets the value of this entry as a byte slice. + pub fn value_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, (*self.raw).value).unwrap() } + } + + /// Gets the configuration level of this entry. + pub fn level(&self) -> ConfigLevel { + unsafe { ConfigLevel::from_raw((*self.raw).level) } + } +} + +impl<'cfg> Binding for ConfigEntry<'cfg> { + type Raw = *mut raw::git_config_entry; + + unsafe fn from_raw(raw: *mut raw::git_config_entry) + -> ConfigEntry<'cfg> { + ConfigEntry { + raw: raw, + _marker: marker::PhantomData, + owned: true, + } + } + fn raw(&self) -> *mut raw::git_config_entry { self.raw } +} + +impl<'cfg> Binding for ConfigEntries<'cfg> { + type Raw = *mut raw::git_config_iterator; + + unsafe fn from_raw(raw: *mut raw::git_config_iterator) + -> ConfigEntries<'cfg> { + ConfigEntries { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *mut raw::git_config_iterator { self.raw } +} + +// entries are only valid until the iterator is freed, so this impl is for +// `&'b T` instead of `T` to have a lifetime to tie them to. +// +// It's also not implemented for `&'b mut T` so we can have multiple entries +// (ok). +impl<'cfg, 'b> Iterator for &'b ConfigEntries<'cfg> { + type Item = ConfigEntry<'b>; + fn next(&mut self) -> Option> { + let mut raw = 0 as *mut raw::git_config_entry; + unsafe { + if raw::git_config_next(&mut raw, self.raw) == 0 { + Some(ConfigEntry { + owned: false, + raw: raw, + _marker: marker::PhantomData, + }) + } else { + None + } + } + } +} + +impl<'cfg> Drop for ConfigEntries<'cfg> { + fn drop(&mut self) { + unsafe { raw::git_config_iterator_free(self.raw) } + } +} + +impl<'cfg> Drop for ConfigEntry<'cfg> { + fn drop(&mut self) { + if self.owned { + unsafe { raw::git_config_entry_free(self.raw) } + } + } +} + +#[cfg(test)] +mod tests { + use std::fs::File; + use tempdir::TempDir; + + use Config; + + #[test] + fn smoke() { + let _cfg = Config::new().unwrap(); + let _ = Config::find_global(); + let _ = Config::find_system(); + let _ = Config::find_xdg(); + } + + #[test] + fn persisted() { + let td = TempDir::new("test").unwrap(); + let path = td.path().join("foo"); + File::create(&path).unwrap(); + + let mut cfg = Config::open(&path).unwrap(); + assert!(cfg.get_bool("foo.bar").is_err()); + cfg.set_bool("foo.k1", true).unwrap(); + cfg.set_i32("foo.k2", 1).unwrap(); + cfg.set_i64("foo.k3", 2).unwrap(); + cfg.set_str("foo.k4", "bar").unwrap(); + cfg.snapshot().unwrap(); + drop(cfg); + + let cfg = Config::open(&path).unwrap().snapshot().unwrap(); + assert_eq!(cfg.get_bool("foo.k1").unwrap(), true); + assert_eq!(cfg.get_i32("foo.k2").unwrap(), 1); + assert_eq!(cfg.get_i64("foo.k3").unwrap(), 2); + assert_eq!(cfg.get_str("foo.k4").unwrap(), "bar"); + + for entry in &cfg.entries(None).unwrap() { + entry.name(); + entry.value(); + entry.level(); + } + } +} diff --git a/deps/git2-0.2.12/src/cred.rs b/deps/git2-0.2.12/src/cred.rs new file mode 100644 index 000000000..cb20407d4 --- /dev/null +++ b/deps/git2-0.2.12/src/cred.rs @@ -0,0 +1,469 @@ +use std::ffi::CString; +use std::io::Write; +use std::mem; +use std::path::Path; +use std::process::{Command, Stdio}; +use url::{self, UrlParser}; + +use {raw, Error, Config, IntoCString}; +use util::Binding; + +/// A structure to represent git credentials in libgit2. +pub struct Cred { + raw: *mut raw::git_cred, +} + +/// Management of the gitcredentials(7) interface. +pub struct CredentialHelper { + /// A public field representing the currently discovered username from + /// configuration. + pub username: Option, + protocol: Option, + host: Option, + url: String, + commands: Vec, +} + +impl Cred { + /// Create a "default" credential usable for Negotiate mechanisms like NTLM + /// or Kerberos authentication. + pub fn default() -> Result { + ::init(); + let mut out = 0 as *mut raw::git_cred; + unsafe { + try_call!(raw::git_cred_default_new(&mut out)); + Ok(Binding::from_raw(out)) + } + } + + /// Create a new ssh key credential object used for querying an ssh-agent. + /// + /// The username specified is the username to authenticate. + pub fn ssh_key_from_agent(username: &str) -> Result { + ::init(); + let mut out = 0 as *mut raw::git_cred; + let username = try!(CString::new(username)); + unsafe { + try_call!(raw::git_cred_ssh_key_from_agent(&mut out, username)); + Ok(Binding::from_raw(out)) + } + } + + /// Create a new passphrase-protected ssh key credential object. + pub fn ssh_key(username: &str, + publickey: Option<&Path>, + privatekey: &Path, + passphrase: Option<&str>) -> Result { + ::init(); + let username = try!(CString::new(username)); + let publickey = try!(::opt_cstr(publickey)); + let privatekey = try!(privatekey.into_c_string()); + let passphrase = try!(::opt_cstr(passphrase)); + let mut out = 0 as *mut raw::git_cred; + unsafe { + try_call!(raw::git_cred_ssh_key_new(&mut out, username, publickey, + privatekey, passphrase)); + Ok(Binding::from_raw(out)) + } + } + + /// Create a new plain-text username and password credential object. + pub fn userpass_plaintext(username: &str, + password: &str) -> Result { + ::init(); + let username = try!(CString::new(username)); + let password = try!(CString::new(password)); + let mut out = 0 as *mut raw::git_cred; + unsafe { + try_call!(raw::git_cred_userpass_plaintext_new(&mut out, username, + password)); + Ok(Binding::from_raw(out)) + } + } + + /// Attempt to read `credential.helper` according to gitcredentials(7) [1] + /// + /// This function will attempt to parse the user's `credential.helper` + /// configuration, invoke the necessary processes, and read off what the + /// username/password should be for a particular url. + /// + /// The returned credential type will be a username/password credential if + /// successful. + /// + /// [1]: https://www.kernel.org/pub/software/scm/git/docs/gitcredentials.html + pub fn credential_helper(config: &Config, + url: &str, + username: Option<&str>) + -> Result { + match CredentialHelper::new(url).config(config).username(username) + .execute() { + Some((username, password)) => { + Cred::userpass_plaintext(&username, &password) + } + None => Err(Error::from_str("failed to acquire username/password \ + from local configuration")) + } + } + + /// Create a credential to specify a username. + /// + /// THis is used with ssh authentication to query for the username if non is + /// specified in the url. + pub fn username(username: &str) -> Result { + ::init(); + let username = try!(CString::new(username)); + let mut out = 0 as *mut raw::git_cred; + unsafe { + try_call!(raw::git_cred_username_new(&mut out, username)); + Ok(Binding::from_raw(out)) + } + } + + /// Check whether a credential object contains username information. + pub fn has_username(&self) -> bool { + unsafe { raw::git_cred_has_username(self.raw) == 1 } + } + + /// Return the type of credentials that this object represents. + pub fn credtype(&self) -> raw::git_credtype_t { + unsafe { (*self.raw).credtype } + } + + /// Unwrap access to the underlying raw pointer, canceling the destructor + pub unsafe fn unwrap(mut self) -> *mut raw::git_cred { + mem::replace(&mut self.raw, 0 as *mut raw::git_cred) + } +} + +impl Binding for Cred { + type Raw = *mut raw::git_cred; + + unsafe fn from_raw(raw: *mut raw::git_cred) -> Cred { + Cred { raw: raw } + } + fn raw(&self) -> *mut raw::git_cred { self.raw } +} + +impl Drop for Cred { + fn drop(&mut self) { + if !self.raw.is_null() { + unsafe { ((*self.raw).free)(self.raw) } + } + } +} + +impl CredentialHelper { + /// Create a new credential helper object which will be used to probe git's + /// local credential configuration. + /// + /// The url specified is the namespace on which this will query credentials. + /// Invalid urls are currently ignored. + pub fn new(url: &str) -> CredentialHelper { + let mut ret = CredentialHelper { + protocol: None, + host: None, + username: None, + url: url.to_string(), + commands: Vec::new(), + }; + + // Parse out the (protocol, host) if one is available + let parsed_url = UrlParser::new().scheme_type_mapper(mapper).parse(url); + match parsed_url { + Ok(url) => { + match url.host() { + Some(&url::Host::Domain(ref s)) => ret.host = Some(s.clone()), + _ => {} + } + ret.protocol = Some(url.scheme) + } + Err(..) => {} + }; + return ret; + + fn mapper(s: &str) -> url::SchemeType { + match s { + "git" => url::SchemeType::Relative(9418), + "ssh" => url::SchemeType::Relative(22), + s => url::whatwg_scheme_type_mapper(s), + } + } + } + + /// Set the username that this credential helper will query with. + /// + /// By default the username is `None`. + pub fn username(&mut self, username: Option<&str>) -> &mut CredentialHelper { + self.username = username.map(|s| s.to_string()); + self + } + + /// Query the specified configuration object to discover commands to + /// execute, usernames to query, etc. + pub fn config(&mut self, config: &Config) -> &mut CredentialHelper { + // Figure out the configured username/helper program. + // + // see http://git-scm.com/docs/gitcredentials.html#_configuration_options + // + // TODO: implement useHttpPath + if self.username.is_none() { + self.config_username(config); + } + self.config_helper(config); + self + } + + // Configure the queried username from `config` + fn config_username(&mut self, config: &Config) { + let key = self.exact_key("username"); + self.username = config.get_string(&key).ok().or_else(|| { + self.url_key("username").and_then(|s| { + config.get_string(&s).ok() + }) + }).or_else(|| { + config.get_string("credential.username").ok() + }) + } + + // Discover all `helper` directives from `config` + fn config_helper(&mut self, config: &Config) { + let exact = config.get_string(&self.exact_key("helper")); + self.add_command(exact.as_ref().ok().map(|s| &s[..])); + match self.url_key("helper") { + Some(key) => { + let url = config.get_string(&key); + self.add_command(url.as_ref().ok().map(|s| &s[..])); + } + None => {} + } + let global = config.get_string("credential.helper"); + self.add_command(global.as_ref().ok().map(|s| &s[..])); + } + + // Add a `helper` configured command to the list of commands to execute. + // + // see https://www.kernel.org/pub/software/scm/git/docs/technical + // /api-credentials.html#_credential_helpers + fn add_command(&mut self, cmd: Option<&str>) { + let cmd = match cmd { Some(s) => s, None => return }; + if cmd.starts_with("!") { + self.commands.push(cmd[1..].to_string()); + } else if cmd.starts_with("/") || cmd.starts_with("\\") || + cmd[1..].starts_with(":\\") { + self.commands.push(format!("\"{}\"", cmd)); + } else { + self.commands.push(format!("git credential-{}", cmd)); + } + } + + fn exact_key(&self, name: &str) -> String { + format!("credential.{}.{}", self.url, name) + } + + fn url_key(&self, name: &str) -> Option { + match (&self.host, &self.protocol) { + (&Some(ref host), &Some(ref protocol)) => { + Some(format!("credential.{}://{}.{}", protocol, host, name)) + } + _ => None + } + } + + /// Execute this helper, attempting to discover a username/password pair. + /// + /// All I/O errors are ignored, (to match git behavior), and this function + /// only succeeds if both a username and a password were found + pub fn execute(&self) -> Option<(String, String)> { + let mut username = self.username.clone(); + let mut password = None; + for cmd in self.commands.iter() { + let (u, p) = self.execute_cmd(&cmd, &username); + if u.is_some() && username.is_none() { + username = u; + } + if p.is_some() && password.is_none() { + password = p; + } + if username.is_some() && password.is_some() { break } + } + + match (username, password) { + (Some(u), Some(p)) => Some((u, p)), + _ => None, + } + } + + // Execute the given `cmd`, providing the appropriate variables on stdin and + // then afterwards parsing the output into the username/password on stdout. + fn execute_cmd(&self, cmd: &str, username: &Option) + -> (Option, Option) { + macro_rules! my_try( ($e:expr) => ( + match $e { Ok(e) => e, Err(..) => return (None, None) } + ) ); + + let mut p = my_try!(Command::new("sh").arg("-c") + .arg(&format!("{} get", cmd)) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn()); + // Ignore write errors as the command may not actually be listening for + // stdin + { + let stdin = p.stdin.as_mut().unwrap(); + match self.protocol { + Some(ref p) => { let _ = writeln!(stdin, "protocol={}", p); } + None => {} + } + match self.host { + Some(ref p) => { let _ = writeln!(stdin, "host={}", p); } + None => {} + } + match *username { + Some(ref p) => { let _ = writeln!(stdin, "username={}", p); } + None => {} + } + } + let output = my_try!(p.wait_with_output()); + if !output.status.success() { return (None, None) } + return self.parse_output(output.stdout) + } + + // Parse the output of a command into the username/password found + fn parse_output(&self, output: Vec) -> (Option, Option) { + // Parse the output of the command, looking for username/password + let mut username = None; + let mut password = None; + for line in output.split(|t| *t == b'\n') { + let mut parts = line.splitn(2, |t| *t == b'='); + let key = parts.next().unwrap(); + let value = match parts.next() { Some(s) => s, None => continue }; + let value = match String::from_utf8(value.to_vec()) { + Ok(s) => s, + Err(..) => continue, + }; + match key { + b"username" => username = Some(value), + b"password" => password = Some(value), + _ => {} + } + } + (username, password) + } +} + +#[cfg(all(test, feature = "unstable"))] +mod test { + use std::env; + use std::fs::File; + use std::io::prelude::*; + use std::path::Path; + use tempdir::TempDir; + + use {Cred, Config, CredentialHelper, ConfigLevel}; + + macro_rules! cfg( ($($k:expr => $v:expr),*) => ({ + let td = TempDir::new("git2-rs").unwrap(); + let mut cfg = Config::new().unwrap(); + cfg.add_file(&td.path().join("cfg"), ConfigLevel::Highest, false).unwrap(); + $(cfg.set_str($k, $v).unwrap();)* + cfg + }) ); + + #[test] + fn smoke() { + Cred::default().unwrap(); + } + + #[test] + fn credential_helper1() { + let cfg = cfg! { + "credential.helper" => "!f() { echo username=a; echo password=b; }; f" + }; + let (u, p) = CredentialHelper::new("https://example.com/foo/bar") + .config(&cfg) + .execute().unwrap(); + assert_eq!(u, "a"); + assert_eq!(p, "b"); + } + + #[test] + fn credential_helper2() { + let cfg = cfg! {}; + assert!(CredentialHelper::new("https://example.com/foo/bar") + .config(&cfg) + .execute().is_none()); + } + + #[test] + fn credential_helper3() { + let cfg = cfg! { + "credential.https://example.com.helper" => + "!f() { echo username=c; }; f", + "credential.helper" => "!f() { echo username=a; echo password=b; }; f" + }; + let (u, p) = CredentialHelper::new("https://example.com/foo/bar") + .config(&cfg) + .execute().unwrap(); + assert_eq!(u, "c"); + assert_eq!(p, "b"); + } + + #[test] + fn credential_helper4() { + let td = TempDir::new("git2-rs").unwrap(); + let path = td.path().join("script"); + File::create(&path).unwrap().write(br"\ +#!/bin/sh +echo username=c +").unwrap(); + chmod(&path); + let cfg = cfg! { + "credential.https://example.com.helper" => + &path.display().to_string()[..], + "credential.helper" => "!f() { echo username=a; echo password=b; }; f" + }; + let (u, p) = CredentialHelper::new("https://example.com/foo/bar") + .config(&cfg) + .execute().unwrap(); + assert_eq!(u, "c"); + assert_eq!(p, "b"); + } + + #[test] + fn credential_helper5() { + let td = TempDir::new("git2-rs").unwrap(); + let path = td.path().join("git-credential-script"); + File::create(&path).unwrap().write(br"\ +#!/bin/sh +echo username=c +").unwrap(); + chmod(&path); + + let paths = env::var("PATH").unwrap(); + let paths = env::split_paths(&paths) + .chain(path.parent().map(|p| p.to_path_buf()).into_iter()); + env::set_var("PATH", &env::join_paths(paths).unwrap()); + + let cfg = cfg! { + "credential.https://example.com.helper" => "script", + "credential.helper" => "!f() { echo username=a; echo password=b; }; f" + }; + let (u, p) = CredentialHelper::new("https://example.com/foo/bar") + .config(&cfg) + .execute().unwrap(); + assert_eq!(u, "c"); + assert_eq!(p, "b"); + } + + #[cfg(unix)] + fn chmod(path: &Path) { + use std::os::unix::prelude::*; + use std::fs; + let mut perms = fs::metadata(path).unwrap().permissions(); + perms.set_mode(0o755); + fs::set_permissions(path, perms).unwrap(); + } + #[cfg(windows)] + fn chmod(_path: &Path) {} +} diff --git a/deps/git2-0.2.12/src/diff.rs b/deps/git2-0.2.12/src/diff.rs new file mode 100644 index 000000000..7344d535f --- /dev/null +++ b/deps/git2-0.2.12/src/diff.rs @@ -0,0 +1,1020 @@ +use std::ffi::CString; +use std::marker; +use std::mem; +use std::ops::Range; +use std::path::Path; +use std::slice; +use libc::{c_char, size_t, c_void, c_int}; + +use {raw, Buf, Delta, Oid, Repository, Tree, Error, Index, DiffFormat}; +use {DiffStatsFormat, IntoCString}; +use util::{self, Binding}; + +/// The diff object that contains all individual file deltas. +/// +/// This is an opaque structure which will be allocated by one of the diff +/// generator functions below (such as `Diff::tree_to_tree`). +pub struct Diff { + raw: *mut raw::git_diff, +} + +unsafe impl Send for Diff {} + +/// Description of changes to one entry. +pub struct DiffDelta<'a> { + raw: *mut raw::git_diff_delta, + _marker: marker::PhantomData<&'a raw::git_diff_delta>, +} + +/// Description of one side of a delta. +/// +/// Although this is called a "file" it could represent a file, a symbolic +/// link, a submodule commit id, or even a tree (although that only happens if +/// you are tracking type changes or ignored/untracked directories). +pub struct DiffFile<'a> { + raw: *const raw::git_diff_file, + _marker: marker::PhantomData<&'a raw::git_diff_file>, +} + +/// Structure describing options about how the diff should be executed. +pub struct DiffOptions { + pathspec: Vec, + pathspec_ptrs: Vec<*const c_char>, + old_prefix: Option, + new_prefix: Option, + raw: raw::git_diff_options, +} + +/// Control behavior of rename and copy detection +pub struct DiffFindOptions { + raw: raw::git_diff_find_options, +} + +/// An iterator over the diffs in a delta +pub struct Deltas<'diff> { + range: Range, + diff: &'diff Diff, +} + +/// Structure describing a line (or data span) of a diff. +pub struct DiffLine<'a> { + raw: *const raw::git_diff_line, + _marker: marker::PhantomData<&'a raw::git_diff_line>, +} + +/// Structure describing a hunk of a diff. +pub struct DiffHunk<'a> { + raw: *const raw::git_diff_hunk, + _marker: marker::PhantomData<&'a raw::git_diff_hunk>, +} + +/// Structure describing a hunk of a diff. +pub struct DiffStats { + raw: *mut raw::git_diff_stats, +} + +type PrintCb<'a> = FnMut(DiffDelta, Option, DiffLine) -> bool + 'a; + +impl Diff { + /// Create a diff with the difference between two tree objects. + /// + /// This is equivalent to `git diff ` + /// + /// The first tree will be used for the "old_file" side of the delta and the + /// second tree will be used for the "new_file" side of the delta. You can + /// pass `None` to indicate an empty tree, although it is an error to pass + /// `None` for both the `old_tree` and `new_tree`. + pub fn tree_to_tree(repo: &Repository, + old_tree: Option<&Tree>, + new_tree: Option<&Tree>, + opts: Option<&mut DiffOptions>) -> Result { + let mut ret = 0 as *mut raw::git_diff; + unsafe { + try_call!(raw::git_diff_tree_to_tree(&mut ret, + repo.raw(), + old_tree.map(|s| s.raw()), + new_tree.map(|s| s.raw()), + opts.map(|s| s.raw()))); + Ok(Binding::from_raw(ret)) + } + } + + /// Create a diff between a tree and repository index. + /// + /// This is equivalent to `git diff --cached ` or if you pass + /// the HEAD tree, then like `git diff --cached`. + /// + /// The tree you pass will be used for the "old_file" side of the delta, and + /// the index will be used for the "new_file" side of the delta. + /// + /// If you pass `None` for the index, then the existing index of the `repo` + /// will be used. In this case, the index will be refreshed from disk + /// (if it has changed) before the diff is generated. + /// + /// If the tree is `None`, then it is considered an empty tree. + pub fn tree_to_index(repo: &Repository, + old_tree: Option<&Tree>, + index: Option<&Index>, + opts: Option<&mut DiffOptions>) -> Result { + let mut ret = 0 as *mut raw::git_diff; + unsafe { + try_call!(raw::git_diff_tree_to_index(&mut ret, + repo.raw(), + old_tree.map(|s| s.raw()), + index.map(|s| s.raw()), + opts.map(|s| s.raw()))); + Ok(Binding::from_raw(ret)) + } + } + + /// Create a diff between the repository index and the workdir directory. + /// + /// This matches the `git diff` command. See the note below on + /// `tree_to_workdir` for a discussion of the difference between + /// `git diff` and `git diff HEAD` and how to emulate a `git diff ` + /// using libgit2. + /// + /// The index will be used for the "old_file" side of the delta, and the + /// working directory will be used for the "new_file" side of the delta. + /// + /// If you pass `None` for the index, then the existing index of the `repo` + /// will be used. In this case, the index will be refreshed from disk + /// (if it has changed) before the diff is generated. + pub fn index_to_workdir(repo: &Repository, + index: Option<&Index>, + opts: Option<&mut DiffOptions>) + -> Result { + let mut ret = 0 as *mut raw::git_diff; + unsafe { + try_call!(raw::git_diff_index_to_workdir(&mut ret, + repo.raw(), + index.map(|s| s.raw()), + opts.map(|s| s.raw()))); + Ok(Binding::from_raw(ret)) + } + } + + /// Create a diff between a tree and the working directory. + /// + /// The tree you provide will be used for the "old_file" side of the delta, + /// and the working directory will be used for the "new_file" side. + /// + /// This is not the same as `git diff ` or `git diff-index + /// `. Those commands use information from the index, whereas this + /// function strictly returns the differences between the tree and the files + /// in the working directory, regardless of the state of the index. Use + /// `tree_to_workdir_with_index` to emulate those commands. + /// + /// To see difference between this and `tree_to_workdir_with_index`, + /// consider the example of a staged file deletion where the file has then + /// been put back into the working dir and further modified. The + /// tree-to-workdir diff for that file is 'modified', but `git diff` would + /// show status 'deleted' since there is a staged delete. + /// + /// If `None` is passed for `tree`, then an empty tree is used. + pub fn tree_to_workdir(repo: &Repository, + old_tree: Option<&Tree>, + opts: Option<&mut DiffOptions>) + -> Result { + let mut ret = 0 as *mut raw::git_diff; + unsafe { + try_call!(raw::git_diff_tree_to_workdir(&mut ret, + repo.raw(), + old_tree.map(|s| s.raw()), + opts.map(|s| s.raw()))); + Ok(Binding::from_raw(ret)) + } + } + + /// Create a diff between a tree and the working directory using index data + /// to account for staged deletes, tracked files, etc. + /// + /// This emulates `git diff ` by diffing the tree to the index and + /// the index to the working directory and blending the results into a + /// single diff that includes staged deleted, etc. + pub fn tree_to_workdir_with_index(repo: &Repository, + old_tree: Option<&Tree>, + opts: Option<&mut DiffOptions>) + -> Result { + let mut ret = 0 as *mut raw::git_diff; + unsafe { + try_call!(raw::git_diff_tree_to_workdir_with_index(&mut ret, + repo.raw(), old_tree.map(|s| s.raw()), opts.map(|s| s.raw()))); + Ok(Binding::from_raw(ret)) + } + } + + /// Merge one diff into another. + /// + /// This merges items from the "from" list into the "self" list. The + /// resulting diff will have all items that appear in either list. + /// If an item appears in both lists, then it will be "merged" to appear + /// as if the old version was from the "onto" list and the new version + /// is from the "from" list (with the exception that if the item has a + /// pending DELETE in the middle, then it will show as deleted). + pub fn merge(&mut self, from: &Diff) -> Result<(), Error> { + unsafe { try_call!(raw::git_diff_merge(self.raw, &*from.raw)); } + Ok(()) + } + + /// Returns an iterator over the deltas in this diff. + pub fn deltas(&self) -> Deltas { + let num_deltas = unsafe { raw::git_diff_num_deltas(&*self.raw) }; + Deltas { range: 0..(num_deltas as usize), diff: self } + } + + /// Return the diff delta for an entry in the diff list. + pub fn get_delta(&self, i: usize) -> Option { + unsafe { + let ptr = raw::git_diff_get_delta(&*self.raw, i as size_t); + Binding::from_raw_opt(ptr as *mut _) + } + } + + /// Check if deltas are sorted case sensitively or insensitively. + pub fn is_sorted_icase(&self) -> bool { + unsafe { raw::git_diff_is_sorted_icase(&*self.raw) == 1 } + } + + /// Iterate over a diff generating formatted text output. + /// + /// Returning `false` from the callback will terminate the iteration and + /// return an error from this function. + pub fn print(&self, format: DiffFormat, mut cb: F) -> Result<(), Error> + where F: FnMut(DiffDelta, + Option, + DiffLine) -> bool { + let mut cb: &mut PrintCb = &mut cb; + let ptr = &mut cb as *mut _; + unsafe { + try_call!(raw::git_diff_print(self.raw, format, print_cb, + ptr as *mut _)); + return Ok(()) + } + } + + /// Accumulate diff statistics for all patches. + pub fn stats(&self) -> Result { + let mut ret = 0 as *mut raw::git_diff_stats; + unsafe { + try_call!(raw::git_diff_get_stats(&mut ret, self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Transform a diff marking file renames, copies, etc. + /// + /// This modifies a diff in place, replacing old entries that look like + /// renames or copies with new entries reflecting those changes. This also + /// will, if requested, break modified files into add/remove pairs if the + /// amount of change is above a threshold. + pub fn find_similar(&mut self, opts: Option<&mut DiffFindOptions>) + -> Result<(), Error> { + let opts = opts.map(|opts| &opts.raw); + unsafe { try_call!(raw::git_diff_find_similar(self.raw, opts)); } + Ok(()) + } + + // TODO: num_deltas_of_type, foreach, format_email, find_similar +} + +wrap_env! { + fn print_cb(delta: *const raw::git_diff_delta, + hunk: *const raw::git_diff_hunk, + line: *const raw::git_diff_line, + data: *mut c_void) -> c_int { + unsafe { + let delta = Binding::from_raw(delta as *mut _); + let hunk = Binding::from_raw_opt(hunk); + let line = Binding::from_raw(line); + let data = data as *mut &mut PrintCb; + (*data)(delta, hunk, line) + } + } + returning ok as if ok == Some(true) {0} else {-1} +} + +impl Binding for Diff { + type Raw = *mut raw::git_diff; + unsafe fn from_raw(raw: *mut raw::git_diff) -> Diff { + Diff { raw: raw } + } + fn raw(&self) -> *mut raw::git_diff { self.raw } +} + +impl Drop for Diff { + fn drop(&mut self) { + unsafe { raw::git_diff_free(self.raw) } + } +} + +impl<'a> DiffDelta<'a> { + // TODO: expose when diffs are more exposed + // pub fn similarity(&self) -> u16 { + // unsafe { (*self.raw).similarity } + // } + + /// Returns the number of files in this delta. + pub fn nfiles(&self) -> u16 { + unsafe { (*self.raw).nfiles } + } + + /// Returns the status of this entry + /// + /// For more information, see `Delta`'s documentation + pub fn status(&self) -> Delta { + match unsafe { (*self.raw).status } { + raw::GIT_DELTA_UNMODIFIED => Delta::Unmodified, + raw::GIT_DELTA_ADDED => Delta::Added, + raw::GIT_DELTA_DELETED => Delta::Deleted, + raw::GIT_DELTA_MODIFIED => Delta::Modified, + raw::GIT_DELTA_RENAMED => Delta::Renamed, + raw::GIT_DELTA_COPIED => Delta::Copied, + raw::GIT_DELTA_IGNORED => Delta::Ignored, + raw::GIT_DELTA_UNTRACKED => Delta::Untracked, + raw::GIT_DELTA_TYPECHANGE => Delta::Typechange, + raw::GIT_DELTA_UNREADABLE => Delta::Unreadable, + } + } + + /// Return the file which represents the "from" side of the diff. + /// + /// What side this means depends on the function that was used to generate + /// the diff and will be documented on the function itself. + pub fn old_file(&self) -> DiffFile<'a> { + unsafe { Binding::from_raw(&(*self.raw).old_file as *const _) } + } + + /// Return the file which represents the "to" side of the diff. + /// + /// What side this means depends on the function that was used to generate + /// the diff and will be documented on the function itself. + pub fn new_file(&self) -> DiffFile<'a> { + unsafe { Binding::from_raw(&(*self.raw).new_file as *const _) } + } +} + +impl<'a> Binding for DiffDelta<'a> { + type Raw = *mut raw::git_diff_delta; + unsafe fn from_raw(raw: *mut raw::git_diff_delta) -> DiffDelta<'a> { + DiffDelta { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *mut raw::git_diff_delta { self.raw } +} + +impl<'a> DiffFile<'a> { + /// Returns the Oid of this item. + /// + /// If this entry represents an absent side of a diff (e.g. the `old_file` + /// of a `Added` delta), then the oid returned will be zeroes. + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(&(*self.raw).id as *const _) } + } + + /// Returns the path, in bytes, of the entry relative to the working + /// directory of the repository. + pub fn path_bytes(&self) -> Option<&'a [u8]> { + static FOO: () = (); + unsafe { ::opt_bytes(&FOO, (*self.raw).path) } + } + + /// Returns the path of the entry relative to the working directory of the + /// repository. + pub fn path(&self) -> Option<&'a Path> { + self.path_bytes().map(util::bytes2path) + } + + /// Returns the size of this entry, in bytes + pub fn size(&self) -> u64 { unsafe { (*self.raw).size as u64 } } + + // TODO: expose flags/mode +} + +impl<'a> Binding for DiffFile<'a> { + type Raw = *const raw::git_diff_file; + unsafe fn from_raw(raw: *const raw::git_diff_file) -> DiffFile<'a> { + DiffFile { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *const raw::git_diff_file { self.raw } +} + +impl DiffOptions { + /// Creates a new set of empty diff options. + /// + /// All flags and other options are defaulted to false or their otherwise + /// zero equivalents. + pub fn new() -> DiffOptions { + let mut opts = DiffOptions { + pathspec: Vec::new(), + pathspec_ptrs: Vec::new(), + raw: unsafe { mem::zeroed() }, + old_prefix: None, + new_prefix: None, + }; + assert_eq!(unsafe { + raw::git_diff_init_options(&mut opts.raw, 1) + }, 0); + opts + } + + fn flag(&mut self, opt: u32, val: bool) -> &mut DiffOptions { + if val { + self.raw.flags |= opt; + } else { + self.raw.flags &= !opt; + } + self + } + + /// Flag indicating whether the sides of the diff will be reversed. + pub fn reverse(&mut self, reverse: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_REVERSE, reverse) + } + + /// Flag indicating whether ignored files are included. + pub fn include_ignored(&mut self, include: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_IGNORED, include) + } + + /// Flag indicating whether ignored directories are traversed deeply or not. + pub fn recurse_ignored_dirs(&mut self, recurse: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_RECURSE_IGNORED_DIRS, recurse) + } + + /// Flag indicating whether untracked files are in the diff + pub fn include_untracked(&mut self, include: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_UNTRACKED, include) + } + + /// Flag indicating whether untracked directories are deeply traversed or + /// not. + pub fn recurse_untracked_dirs(&mut self, recurse: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_RECURSE_UNTRACKED_DIRS, recurse) + } + + /// Flag indicating whether unmodified files are in the diff. + pub fn include_unmodified(&mut self, include: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_UNMODIFIED, include) + } + + /// If entrabled, then Typechange delta records are generated. + pub fn include_typechange(&mut self, include: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_TYPECHANGE, include) + } + + /// Event with `include_typechange`, the tree treturned generally shows a + /// deleted blow. This flag correctly labels the tree transitions as a + /// typechange record with the `new_file`'s mode set to tree. + /// + /// Note that the tree SHA will not be available. + pub fn include_typechange_trees(&mut self, include: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_TYPECHANGE_TREES, include) + } + + /// Flag indicating whether file mode changes are ignored. + pub fn ignore_filemode(&mut self, ignore: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_IGNORE_FILEMODE, ignore) + } + + /// Flag indicating whether all submodules should be treated as unmodified. + pub fn ignore_submodules(&mut self, ignore: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_IGNORE_SUBMODULES, ignore) + } + + /// Flag indicating whether case insensitive filenames should be used. + pub fn ignore_case(&mut self, ignore: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_IGNORE_CASE, ignore) + } + + /// If pathspecs are specified, this flag means that they should be applied + /// as an exact match instead of a fnmatch pattern. + pub fn disable_pathspec_match(&mut self, disable: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_DISABLE_PATHSPEC_MATCH, disable) + } + + /// Disable updating the `binary` flag in delta records. This is useful when + /// iterating over a diff if you don't need hunk and data callbacks and want + /// to avoid having to load a file completely. + pub fn skip_binary_check(&mut self, skip: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_SKIP_BINARY_CHECK, skip) + } + + /// When diff finds an untracked directory, to match the behavior of core + /// Git, it scans the contents for ignored and untracked files. If all + /// contents are ignored, then the directory is ignored; if any contents are + /// not ignored, then the directory is untracked. This is extra work that + /// may not matter in many cases. + /// + /// This flag turns off that scan and immediately labels an untracked + /// directory as untracked (changing the behavior to not match core git). + pub fn enable_fast_untracked_dirs(&mut self, enable: bool) + -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS, enable) + } + + /// When diff finds a file in the working directory with stat information + /// different from the index, but the OID ends up being the same, write the + /// correct stat information into the index. Note: without this flag, diff + /// will always leave the index untouched. + pub fn update_index(&mut self, update: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_UPDATE_INDEX, update) + } + + /// Include unreadable files in the diff + pub fn include_unreadable(&mut self, include: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_UNREADABLE, include) + } + + /// Include unreadable files in the diff + pub fn include_unreadable_as_untracked(&mut self, include: bool) + -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED, include) + } + + /// Treat all files as text, disabling binary attributes and detection. + pub fn force_text(&mut self, force: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_FORCE_TEXT, force) + } + + /// Treat all files as binary, disabling text diffs + pub fn force_binary(&mut self, force: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_FORCE_TEXT, force) + } + + /// Ignore all whitespace + pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE, ignore) + } + + /// Ignore changes in the amount of whitespace + pub fn ignore_whitespace_change(&mut self, ignore: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_CHANGE, ignore) + } + + /// Ignore whitespace at tend of line + pub fn ignore_whitespace_eol(&mut self, ignore: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_EOL, ignore) + } + + /// When generating patch text, include the content of untracked files. + /// + /// This automatically turns on `include_untracked` but it does not turn on + /// `recurse_untracked_dirs`. Add that flag if you want the content of every + /// single untracked file. + pub fn show_untracked_content(&mut self, show: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_SHOW_UNTRACKED_CONTENT, show) + } + + /// When generating output, include the names of unmodified files if they + /// are included in the `Diff`. Normally these are skipped in the formats + /// that list files (e.g. name-only, name-status, raw). Even with this these + /// will not be included in the patch format. + pub fn show_unmodified(&mut self, show: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_SHOW_UNMODIFIED, show) + } + + /// Use the "patience diff" algorithm + pub fn patience(&mut self, patience: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_PATIENCE, patience) + } + + /// Take extra time to find the minimal diff + pub fn minimal(&mut self, minimal: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_MINIMAL, minimal) + } + + /// Include the necessary deflate/delta information so that `git-apply` can + /// apply given diff information to binary files. + pub fn show_binary(&mut self, show: bool) -> &mut DiffOptions { + self.flag(raw::GIT_DIFF_SHOW_BINARY, show) + } + + /// Set the number of unchanged lines that define the boundary of a hunk + /// (and to display before and after). + /// + /// The default value for this is 3. + pub fn context_lines(&mut self, lines: u32) -> &mut DiffOptions { + self.raw.context_lines = lines; + self + } + + /// Set the maximum number of unchanged lines between hunk boundaries before + /// the hunks will be merged into one. + /// + /// The default value for this is 0. + pub fn interhunk_lines(&mut self, lines: u32) -> &mut DiffOptions { + self.raw.interhunk_lines = lines; + self + } + + /// The default value for this is `core.abbrev` or 7 if unset. + pub fn id_abbrev(&mut self, abbrev: u16) -> &mut DiffOptions { + self.raw.id_abbrev = abbrev; + self + } + + /// Maximum size (in bytes) above which a blob will be marked as binary + /// automatically. + /// + /// A negative value will disable this entirely. + /// + /// The default value for this is 512MB. + pub fn max_size(&mut self, size: i64) -> &mut DiffOptions { + self.raw.max_size = size as raw::git_off_t; + self + } + + /// The virtual "directory" to prefix old file names with in hunk headers. + /// + /// The default value for this is "a". + pub fn old_prefix(&mut self, t: T) -> &mut DiffOptions { + self.old_prefix = Some(t.into_c_string().unwrap()); + self + } + + /// The virtual "directory" to prefix new file names with in hunk headers. + /// + /// The default value for this is "b". + pub fn new_prefix(&mut self, t: T) -> &mut DiffOptions { + self.new_prefix = Some(t.into_c_string().unwrap()); + self + } + + /// Add to the array of paths/fnmatch patterns to constrain the diff. + pub fn pathspec(&mut self, pathspec: T) + -> &mut DiffOptions { + let s = pathspec.into_c_string().unwrap(); + self.pathspec_ptrs.push(s.as_ptr()); + self.pathspec.push(s); + self + } + + /// Acquire a pointer to the underlying raw options. + /// + /// This function is unsafe as the pointer is only valid so long as this + /// structure is not moved, modified, or used elsewhere. + pub unsafe fn raw(&mut self) -> *const raw::git_diff_options { + self.raw.old_prefix = self.old_prefix.as_ref().map(|s| s.as_ptr()) + .unwrap_or(0 as *const _); + self.raw.new_prefix = self.new_prefix.as_ref().map(|s| s.as_ptr()) + .unwrap_or(0 as *const _); + self.raw.pathspec.count = self.pathspec_ptrs.len() as size_t; + self.raw.pathspec.strings = self.pathspec_ptrs.as_ptr() as *mut _; + &self.raw as *const _ + } + + // TODO: expose ignore_submodules, notify_cb/notify_payload +} + +impl<'diff> Iterator for Deltas<'diff> { + type Item = DiffDelta<'diff>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.diff.get_delta(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'diff> DoubleEndedIterator for Deltas<'diff> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.diff.get_delta(i)) + } +} +impl<'diff> ExactSizeIterator for Deltas<'diff> {} + +impl<'a> DiffLine<'a> { + /// Line number in old file or `None` for added line + pub fn old_lineno(&self) -> Option { + match unsafe { (*self.raw).old_lineno } { + n if n < 0 => None, + n => Some(n as u32), + } + } + + /// Line number in new file or `None` for deleted line + pub fn new_lineno(&self) -> Option { + match unsafe { (*self.raw).new_lineno } { + n if n < 0 => None, + n => Some(n as u32), + } + } + + /// Number of newline characters in content + pub fn num_lines(&self) -> u32 { + unsafe { (*self.raw).num_lines as u32 } + } + + /// Offset in the original file to the content + pub fn content_offset(&self) -> i64 { + unsafe { (*self.raw).content_offset as i64 } + } + + /// Content of this line as bytes. + pub fn content(&self) -> &[u8] { + unsafe { + slice::from_raw_parts((*self.raw).content, + (*self.raw).content_len as usize) + } + } + + /// Sigil showing the origin of this `DiffLine`. + /// + /// * ` ` - Line context + /// * `+` - Line addition + /// * `-` - Line deletion + /// * `=` - Context (End of file) + /// * `>` - Add (End of file) + /// * `<` - Remove (End of file) + /// * `F` - File header + /// * `H` - Hunk header + /// * `B` - Line binary + pub fn origin(&self) -> char { + match unsafe { (*self.raw).origin } { + raw::GIT_DIFF_LINE_CONTEXT => ' ', + raw::GIT_DIFF_LINE_ADDITION => '+', + raw::GIT_DIFF_LINE_DELETION => '-', + raw::GIT_DIFF_LINE_CONTEXT_EOFNL => '=', + raw::GIT_DIFF_LINE_ADD_EOFNL => '>', + raw::GIT_DIFF_LINE_DEL_EOFNL => '<', + raw::GIT_DIFF_LINE_FILE_HDR => 'F', + raw::GIT_DIFF_LINE_HUNK_HDR => 'H', + raw::GIT_DIFF_LINE_LINE_BINARY => 'B', + _ => ' ', + } + } +} + +impl<'a> Binding for DiffLine<'a> { + type Raw = *const raw::git_diff_line; + unsafe fn from_raw(raw: *const raw::git_diff_line) -> DiffLine<'a> { + DiffLine { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *const raw::git_diff_line { self.raw } +} + +impl<'a> DiffHunk<'a> { + /// Starting line number in old_file + pub fn old_start(&self) -> u32 { + unsafe { (*self.raw).old_start as u32 } + } + + /// Number of lines in old_file + pub fn old_lines(&self) -> u32 { + unsafe { (*self.raw).old_lines as u32 } + } + + /// Starting line number in new_file + pub fn new_start(&self) -> u32 { + unsafe { (*self.raw).new_start as u32 } + } + + /// Number of lines in new_file + pub fn new_lines(&self) -> u32 { + unsafe { (*self.raw).new_lines as u32 } + } + + /// Header text + pub fn header(&self) -> &[u8] { + unsafe { &(*self.raw).header[..(*self.raw).header_len as usize] } + } +} + +impl<'a> Binding for DiffHunk<'a> { + type Raw = *const raw::git_diff_hunk; + unsafe fn from_raw(raw: *const raw::git_diff_hunk) -> DiffHunk<'a> { + DiffHunk { + raw: raw, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *const raw::git_diff_hunk { self.raw } +} + +impl DiffStats { + /// Get the total number of files chaned in a diff. + pub fn files_changed(&self) -> usize { + unsafe { raw::git_diff_stats_files_changed(&*self.raw) as usize } + } + + /// Get the total number of insertions in a diff + pub fn insertions(&self) -> usize { + unsafe { raw::git_diff_stats_insertions(&*self.raw) as usize } + } + + /// Get the total number of deletions in a diff + pub fn deletions(&self) -> usize { + unsafe { raw::git_diff_stats_deletions(&*self.raw) as usize } + } + + /// Print diff statistics to a Buf + pub fn to_buf(&self, format: DiffStatsFormat, width: usize) + -> Result { + let buf = Buf::new(); + unsafe { + try_call!(raw::git_diff_stats_to_buf(buf.raw(), self.raw, + format.bits(), + width as size_t)); + } + Ok(buf) + } +} + +impl Binding for DiffStats { + type Raw = *mut raw::git_diff_stats; + + unsafe fn from_raw(raw: *mut raw::git_diff_stats) -> DiffStats { + DiffStats { raw: raw } + } + fn raw(&self) -> *mut raw::git_diff_stats { self.raw } +} + +impl Drop for DiffStats { + fn drop(&mut self) { + unsafe { raw::git_diff_stats_free(self.raw) } + } +} + +impl DiffFindOptions { + /// Creates a new set of empty diff find options. + /// + /// All flags and other options are defaulted to false or their otherwise + /// zero equivalents. + pub fn new() -> DiffFindOptions { + let mut opts = DiffFindOptions { + raw: unsafe { mem::zeroed() }, + }; + assert_eq!(unsafe { + raw::git_diff_find_init_options(&mut opts.raw, 1) + }, 0); + opts + } + + fn flag(&mut self, opt: u32, val: bool) -> &mut DiffFindOptions { + if val { + self.raw.flags |= opt; + } else { + self.raw.flags &= !opt; + } + self + } + + /// Reset all flags back to their unset state, indicating that + /// `diff.renames` should be used instead. This is overridden once any flag + /// is set. + pub fn by_config(&mut self) -> &mut DiffFindOptions { + self.flag(0xffffffff, false) + } + + /// Look for renames? + pub fn renames(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_RENAMES, find) + } + + /// Consider old side of modified for renames? + pub fn renames_from_rewrites(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_RENAMES_FROM_REWRITES, find) + } + + /// Look for copies? + pub fn copies(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_COPIES, find) + } + + /// Consider unmodified as copy sources? + /// + /// For this to work correctly, use `include_unmodified` when the initial + /// diff is being generated. + pub fn copies_from_unmodified(&mut self, find: bool) + -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED, find) + } + + /// Mark significant rewrites for split. + pub fn rewrites(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_REWRITES, find) + } + + /// Actually split large rewrites into delete/add pairs + pub fn break_rewries(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_BREAK_REWRITES, find) + } + + /// Find renames/copies for untracked items in working directory. + /// + /// For this to work correctly use the `include_untracked` option when the + /// initial diff is being generated. + pub fn for_untracked(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_FOR_UNTRACKED, find) + } + + /// Turn on all finding features. + pub fn all(&mut self, find: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_ALL, find) + } + + /// Measure similarity ignoring leading whitespace (default) + pub fn ignore_leading_whitespace(&mut self, ignore: bool) + -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE, ignore) + } + + /// Measure similarity ignoring all whitespace + pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_IGNORE_WHITESPACE, ignore) + } + + /// Measure similarity including all data + pub fn dont_ignore_whitespace(&mut self, dont: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE, dont) + } + + /// Measure similarity only by comparing SHAs (fast and cheap) + pub fn exact_match_only(&mut self, exact: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_EXACT_MATCH_ONLY, exact) + } + + /// Do not break rewrites unless they contribute to a rename. + /// + /// Normally, `break_rewrites` and `rewrites` will measure the + /// self-similarity of modified files and split the ones that have changed a + /// lot into a delete/add pair. Then the sides of that pair will be + /// considered candidates for rename and copy detection + /// + /// If you add this flag in and the split pair is not used for an actual + /// rename or copy, then the modified record will be restored to a regular + /// modified record instead of being split. + pub fn break_rewrites_for_renames_only(&mut self, b: bool) + -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY, b) + } + + /// Remove any unmodified deltas after find_similar is done. + /// + /// Using `copies_from_unmodified` to emulate the `--find-copies-harder` + /// behavior requires building a diff with the `include_unmodified` flag. If + /// you do not want unmodified records in the final result, pas this flag to + /// have them removed. + pub fn remove_unmodified(&mut self, remove: bool) -> &mut DiffFindOptions { + self.flag(raw::GIT_DIFF_FIND_REMOVE_UNMODIFIED, remove) + } + + /// Similarity to consider a file renamed (default 50) + pub fn rename_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { + self.raw.rename_threshold = thresh; + self + } + + /// Similarity of modified to be glegible rename source (default 50) + pub fn rename_from_rewrite_threshold(&mut self, thresh: u16) + -> &mut DiffFindOptions { + self.raw.rename_from_rewrite_threshold = thresh; + self + } + + /// Similarity to consider a file copy (default 50) + pub fn copy_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { + self.raw.copy_threshold = thresh; + self + } + + /// Similarity to split modify into delete/add pair (default 60) + pub fn break_rewrite_threshold(&mut self, thresh: u16) + -> &mut DiffFindOptions { + self.raw.break_rewrite_threshold = thresh; + self + } + + /// Maximum similarity sources to examine for a file (somewhat like + /// git-diff's `-l` option or `diff.renameLimit` config) + /// + /// Defaults to 200 + pub fn rename_limit(&mut self, limit: usize) -> &mut DiffFindOptions { + self.raw.rename_limit = limit as size_t; + self + } + + // TODO: expose git_diff_similarity_metric +} + +#[cfg(test)] +mod tests { + use super::Diff; + + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let diff = Diff::tree_to_workdir(&repo, None, None).unwrap(); + assert_eq!(diff.deltas().len(), 0); + let stats = diff.stats().unwrap(); + assert_eq!(stats.insertions(), 0); + assert_eq!(stats.deletions(), 0); + assert_eq!(stats.files_changed(), 0); + } +} diff --git a/deps/git2-0.2.12/src/error.rs b/deps/git2-0.2.12/src/error.rs new file mode 100644 index 000000000..dbbf35be6 --- /dev/null +++ b/deps/git2-0.2.12/src/error.rs @@ -0,0 +1,113 @@ +use std::ffi::{CStr, NulError}; +use std::error; +use std::fmt; +use std::str; +use libc::c_int; + +use {raw, ErrorCode}; + +/// A structure to represent errors coming out of libgit2. +#[derive(Debug)] +pub struct Error { + klass: c_int, + message: String, +} + +impl Error { + /// Returns the last error, or `None` if one is not available. + pub fn last_error() -> Option { + ::init(); + unsafe { + let ptr = raw::giterr_last(); + if ptr.is_null() { + None + } else { + Some(Error::from_raw(ptr)) + } + } + } + + unsafe fn from_raw(ptr: *const raw::git_error) -> Error { + let msg = CStr::from_ptr((*ptr).message as *const _).to_bytes(); + let msg = str::from_utf8(msg).unwrap(); + Error { klass: (*ptr).klass, message: msg.to_string() } + } + + /// Creates a new error from the given string as the error. + pub fn from_str(s: &str) -> Error { + Error { klass: raw::GIT_ERROR as c_int, message: s.to_string() } + } + + /// Return the error code associated with this error. + pub fn code(&self) -> ErrorCode { + match self.raw_code() { + raw::GIT_OK => super::ErrorCode::GenericError, + raw::GIT_ERROR => super::ErrorCode::GenericError, + raw::GIT_ENOTFOUND => super::ErrorCode::NotFound, + raw::GIT_EEXISTS => super::ErrorCode::Exists, + raw::GIT_EAMBIGUOUS => super::ErrorCode::Ambiguous, + raw::GIT_EBUFS => super::ErrorCode::BufSize, + raw::GIT_EUSER => super::ErrorCode::User, + raw::GIT_EBAREREPO => super::ErrorCode::BareRepo, + raw::GIT_EUNBORNBRANCH => super::ErrorCode::UnbornBranch, + raw::GIT_EUNMERGED => super::ErrorCode::Unmerged, + raw::GIT_ENONFASTFORWARD => super::ErrorCode::NotFastForward, + raw::GIT_EINVALIDSPEC => super::ErrorCode::InvalidSpec, + raw::GIT_EMERGECONFLICT => super::ErrorCode::MergeConflict, + raw::GIT_ELOCKED => super::ErrorCode::Locked, + raw::GIT_EMODIFIED => super::ErrorCode::Modified, + raw::GIT_PASSTHROUGH => super::ErrorCode::GenericError, + raw::GIT_ITEROVER => super::ErrorCode::GenericError, + } + } + + /// Return the raw error code associated with this error. + pub fn raw_code(&self) -> raw::git_error_code { + macro_rules! check( ($($e:ident),*) => ( + $(if self.klass == raw::$e as c_int { raw::$e }) else * + else { + raw::GIT_ERROR + } + ) ); + check!( + GIT_OK, + GIT_ERROR, + GIT_ENOTFOUND, + GIT_EEXISTS, + GIT_EAMBIGUOUS, + GIT_EBUFS, + GIT_EUSER, + GIT_EBAREREPO, + GIT_EUNBORNBRANCH, + GIT_EUNMERGED, + GIT_ENONFASTFORWARD, + GIT_EINVALIDSPEC, + GIT_EMERGECONFLICT, + GIT_ELOCKED, + GIT_EMODIFIED, + GIT_PASSTHROUGH, + GIT_ITEROVER + ) + } + + /// Return the message associated with this error + pub fn message(&self) -> &str { &self.message } +} + +impl error::Error for Error { + fn description(&self) -> &str { &self.message } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "[{}] ", self.klass)); + f.write_str(&self.message) + } +} + +impl From for Error { + fn from(_: NulError) -> Error { + Error::from_str("data contained a nul byte that could not be \ + represented as a string") + } +} diff --git a/deps/git2-0.2.12/src/index.rs b/deps/git2-0.2.12/src/index.rs new file mode 100644 index 000000000..a0d708b1b --- /dev/null +++ b/deps/git2-0.2.12/src/index.rs @@ -0,0 +1,565 @@ +use std::ffi::{CStr, OsString}; +use std::iter::IntoIterator; +use std::ops::Range; +use std::path::Path; + +use libc::{c_int, c_uint, size_t, c_void, c_char, c_ushort}; + +use {raw, Repository, Error, Tree, Oid, IndexAddOption, IndexTime}; +use IntoCString; +use util::{self, Binding}; + +/// A structure to represent a git [index][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects +pub struct Index { + raw: *mut raw::git_index, +} + +/// An iterator over the entries in an index +pub struct IndexEntries<'index> { + range: Range, + index: &'index Index, +} + +/// A callback function to filter index matches. +/// +/// Used by `Index::{add_all,remove_all,update_all}`. The first argument is the +/// path, and the second is the patchspec that matched it. Return 0 to confirm +/// the operation on the item, > 0 to skip the item, and < 0 to abort the scan. +pub type IndexMatchedPath<'a> = FnMut(&Path, &[u8]) -> i32 + 'a; + +/// A structure to represent an entry or a file inside of an index. +/// +/// All fields of an entry are public for modification and inspection. This is +/// also how a new index entry is created. +#[allow(missing_docs)] +pub struct IndexEntry { + pub ctime: IndexTime, + pub mtime: IndexTime, + pub dev: u32, + pub ino: u32, + pub mode: u32, + pub uid: u32, + pub gid: u32, + pub file_size: u64, + pub id: Oid, + pub flags: u16, + pub flags_extended: u16, + pub path: Vec, +} + +impl Index { + /// Creates a new in-memory index. + /// + /// This index object cannot be read/written to the filesystem, but may be + /// used to perform in-memory index operations. + pub fn new() -> Result { + ::init(); + let mut raw = 0 as *mut raw::git_index; + unsafe { + try_call!(raw::git_index_new(&mut raw)); + Ok(Binding::from_raw(raw)) + } + } + + /// Create a new bare Git index object as a memory representation of the Git + /// index file in 'index_path', without a repository to back it. + /// + /// Since there is no ODB or working directory behind this index, any Index + /// methods which rely on these (e.g. add_path) will fail. + /// + /// If you need an index attached to a repository, use the `index()` method + /// on `Repository`. + pub fn open(index_path: &Path) -> Result { + ::init(); + let mut raw = 0 as *mut raw::git_index; + let index_path = try!(index_path.into_c_string()); + unsafe { + try_call!(raw::git_index_open(&mut raw, index_path)); + Ok(Binding::from_raw(raw)) + } + } + + /// Add or update an index entry from an in-memory struct + /// + /// If a previous index entry exists that has the same path and stage as the + /// given 'source_entry', it will be replaced. Otherwise, the 'source_entry' + /// will be added. + pub fn add(&mut self, source_entry: &IndexEntry) -> Result<(), Error> { + let entry = source_entry.raw(); + unsafe { + try_call!(raw::git_index_add(self.raw, &entry)); + Ok(()) + } + } + + /// Add or update an index entry from a file on disk + /// + /// The file path must be relative to the repository's working folder and + /// must be readable. + /// + /// This method will fail in bare index instances. + /// + /// This forces the file to be added to the index, not looking at gitignore + /// rules. + /// + /// If this file currently is the result of a merge conflict, this file will + /// no longer be marked as conflicting. The data about the conflict will be + /// moved to the "resolve undo" (REUC) section. + pub fn add_path(&mut self, path: &Path) -> Result<(), Error> { + // Git apparently expects '/' to be separators for paths + let mut posix_path = OsString::new(); + for (i, comp) in path.components().enumerate() { + if i != 0 { posix_path.push("/"); } + posix_path.push(comp.as_os_str()); + } + let posix_path = try!(posix_path.into_c_string()); + unsafe { + try_call!(raw::git_index_add_bypath(self.raw, posix_path)); + Ok(()) + } + } + + /// Add or update index entries matching files in the working directory. + /// + /// This method will fail in bare index instances. + /// + /// The `pathspecs` are a list of file names or shell glob patterns that + /// will matched against files in the repository's working directory. Each + /// file that matches will be added to the index (either updating an + /// existing entry or adding a new entry). You can disable glob expansion + /// and force exact matching with the `AddDisablePathspecMatch` flag. + /// + /// Files that are ignored will be skipped (unlike `add_path`). If a file is + /// already tracked in the index, then it will be updated even if it is + /// ignored. Pass the `AddForce` flag to skip the checking of ignore rules. + /// + /// To emulate `git add -A` and generate an error if the pathspec contains + /// the exact path of an ignored file (when not using `AddForce`), add the + /// `AddCheckPathspec` flag. This checks that each entry in `pathspecs` + /// that is an exact match to a filename on disk is either not ignored or + /// already in the index. If this check fails, the function will return + /// an error. + /// + /// To emulate `git add -A` with the "dry-run" option, just use a callback + /// function that always returns a positive value. See below for details. + /// + /// If any files are currently the result of a merge conflict, those files + /// will no longer be marked as conflicting. The data about the conflicts + /// will be moved to the "resolve undo" (REUC) section. + /// + /// If you provide a callback function, it will be invoked on each matching + /// item in the working directory immediately before it is added to / + /// updated in the index. Returning zero will add the item to the index, + /// greater than zero will skip the item, and less than zero will abort the + /// scan an return an error to the caller. + pub fn add_all(&mut self, + pathspecs: I, + flag: IndexAddOption, + mut cb: Option<&mut IndexMatchedPath>) + -> Result<(), Error> + where T: IntoCString, I: IntoIterator, + { + let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); + let ptr = cb.as_mut(); + let callback = ptr.as_ref().map(|_| { + index_matched_path_cb as raw::git_index_matched_path_cb + }); + unsafe { + try_call!(raw::git_index_add_all(self.raw, + &raw_strarray, + flag.bits() as c_uint, + callback, + ptr.map(|p| p as *mut _) + .unwrap_or(0 as *mut _) + as *mut c_void)); + } + return Ok(()); + } + + /// Clear the contents (all the entries) of an index object. + /// + /// This clears the index object in memory; changes must be explicitly + /// written to disk for them to take effect persistently via `write_*`. + pub fn clear(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_index_clear(self.raw)); } + Ok(()) + } + + /// Get the count of entries currently in the index + pub fn len(&self) -> usize { + unsafe { raw::git_index_entrycount(&*self.raw) as usize } + } + + /// Get one of the entries in the index by its position. + pub fn get(&self, n: usize) -> Option { + unsafe { + let ptr = raw::git_index_get_byindex(self.raw, n as size_t); + if ptr.is_null() {None} else {Some(Binding::from_raw(*ptr))} + } + } + + /// Get an iterator over the entries in this index. + pub fn iter(&self) -> IndexEntries { + IndexEntries { range: 0..self.len(), index: self } + } + + /// Get one of the entries in the index by its path. + pub fn get_path(&self, path: &Path, stage: i32) -> Option { + let path = path.into_c_string().unwrap(); + unsafe { + let ptr = call!(raw::git_index_get_bypath(self.raw, path, + stage as c_int)); + if ptr.is_null() {None} else {Some(Binding::from_raw(*ptr))} + } + } + + /// Get the full path to the index file on disk. + /// + /// Returns `None` if this is an in-memory index. + pub fn path(&self) -> Option<&Path> { + unsafe { + ::opt_bytes(self, raw::git_index_path(&*self.raw)).map(util::bytes2path) + } + } + + /// Update the contents of an existing index object in memory by reading + /// from the hard disk. + /// + /// If force is true, this performs a "hard" read that discards in-memory + /// changes and always reloads the on-disk index data. If there is no + /// on-disk version, the index will be cleared. + /// + /// If force is false, this does a "soft" read that reloads the index data + /// from disk only if it has changed since the last time it was loaded. + /// Purely in-memory index data will be untouched. Be aware: if there are + /// changes on disk, unwritten in-memory changes are discarded. + pub fn read(&mut self, force: bool) -> Result<(), Error> { + unsafe { try_call!(raw::git_index_read(self.raw, force)); } + Ok(()) + } + + /// Read a tree into the index file with stats + /// + /// The current index contents will be replaced by the specified tree. + pub fn read_tree(&mut self, tree: &Tree) -> Result<(), Error> { + unsafe { try_call!(raw::git_index_read_tree(self.raw, &*tree.raw())); } + Ok(()) + } + + /// Remove an entry from the index + pub fn remove(&mut self, path: &Path, stage: i32) -> Result<(), Error> { + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_index_remove(self.raw, path, stage as c_int)); + } + Ok(()) + } + + /// Remove an index entry corresponding to a file on disk. + /// + /// The file path must be relative to the repository's working folder. It + /// may exist. + /// + /// If this file currently is the result of a merge conflict, this file will + /// no longer be marked as conflicting. The data about the conflict will be + /// moved to the "resolve undo" (REUC) section. + pub fn remove_path(&mut self, path: &Path) -> Result<(), Error> { + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_index_remove_bypath(self.raw, path)); + } + Ok(()) + } + + /// Remove all entries from the index under a given directory. + pub fn remove_dir(&mut self, path: &Path, stage: i32) -> Result<(), Error> { + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_index_remove_directory(self.raw, path, + stage as c_int)); + } + Ok(()) + } + + /// Remove all matching index entries. + /// + /// If you provide a callback function, it will be invoked on each matching + /// item in the index immediately before it is removed. Return 0 to remove + /// the item, > 0 to skip the item, and < 0 to abort the scan. + pub fn remove_all(&mut self, + pathspecs: I, + mut cb: Option<&mut IndexMatchedPath>) + -> Result<(), Error> + where T: IntoCString, I: IntoIterator, + { + let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); + let ptr = cb.as_mut(); + let callback = ptr.as_ref().map(|_| { + index_matched_path_cb as raw::git_index_matched_path_cb + }); + unsafe { + try_call!(raw::git_index_remove_all(self.raw, + &raw_strarray, + callback, + ptr.map(|p| p as *mut _) + .unwrap_or(0 as *mut _) + as *mut c_void)); + } + return Ok(()); + } + + /// Update all index entries to match the working directory + /// + /// This method will fail in bare index instances. + /// + /// This scans the existing index entries and synchronizes them with the + /// working directory, deleting them if the corresponding working directory + /// file no longer exists otherwise updating the information (including + /// adding the latest version of file to the ODB if needed). + /// + /// If you provide a callback function, it will be invoked on each matching + /// item in the index immediately before it is updated (either refreshed or + /// removed depending on working directory state). Return 0 to proceed with + /// updating the item, > 0 to skip the item, and < 0 to abort the scan. + pub fn update_all(&mut self, + pathspecs: I, + mut cb: Option<&mut IndexMatchedPath>) + -> Result<(), Error> + where T: IntoCString, I: IntoIterator, + { + let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); + let ptr = cb.as_mut(); + let callback = ptr.as_ref().map(|_| { + index_matched_path_cb as raw::git_index_matched_path_cb + }); + unsafe { + try_call!(raw::git_index_update_all(self.raw, + &raw_strarray, + callback, + ptr.map(|p| p as *mut _) + .unwrap_or(0 as *mut _) + as *mut c_void)); + } + return Ok(()); + } + + /// Write an existing index object from memory back to disk using an atomic + /// file lock. + pub fn write(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_index_write(self.raw)); } + Ok(()) + } + + /// Write the index as a tree. + /// + /// This method will scan the index and write a representation of its + /// current state back to disk; it recursively creates tree objects for each + /// of the subtrees stored in the index, but only returns the OID of the + /// root tree. This is the OID that can be used e.g. to create a commit. + /// + /// The index instance cannot be bare, and needs to be associated to an + /// existing repository. + /// + /// The index must not contain any file in conflict. + pub fn write_tree(&mut self) -> Result { + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_index_write_tree(&mut raw, self.raw)); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Write the index as a tree to the given repository + /// + /// This is the same as `write_tree` except that the destination repository + /// can be chosen. + pub fn write_tree_to(&mut self, repo: &Repository) -> Result { + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_index_write_tree_to(&mut raw, self.raw, + repo.raw())); + Ok(Binding::from_raw(&raw as *const _)) + } + } +} + +impl Binding for Index { + type Raw = *mut raw::git_index; + unsafe fn from_raw(raw: *mut raw::git_index) -> Index { + Index { raw: raw } + } + fn raw(&self) -> *mut raw::git_index { self.raw } +} + +wrap_env! { + fn index_matched_path_cb(path: *const c_char, + matched_pathspec: *const c_char, + payload: *mut c_void) -> c_int { + unsafe { + let path = CStr::from_ptr(path).to_bytes(); + let matched_pathspec = CStr::from_ptr(matched_pathspec).to_bytes(); + let payload = payload as *mut &mut IndexMatchedPath; + (*payload)(util::bytes2path(path), matched_pathspec) as c_int + } + } + returning code as code.unwrap_or(-1) +} + +impl Drop for Index { + fn drop(&mut self) { + unsafe { raw::git_index_free(self.raw) } + } +} + +impl<'index> Iterator for IndexEntries<'index> { + type Item = IndexEntry; + fn next(&mut self) -> Option { + self.range.next().map(|i| self.index.get(i).unwrap()) + } +} + +impl Binding for IndexEntry { + type Raw = raw::git_index_entry; + + unsafe fn from_raw(raw: raw::git_index_entry) -> IndexEntry { + let raw::git_index_entry { + ctime, mtime, dev, ino, mode, uid, gid, file_size, id, flags, + flags_extended, path + } = raw; + IndexEntry { + dev: dev as u32, + ino: ino as u32, + mode: mode as u32, + uid: uid as u32, + gid: gid as u32, + file_size: file_size as u64, + id: Binding::from_raw(&id as *const _), + flags: flags as u16, + flags_extended: flags_extended as u16, + path: CStr::from_ptr(path).to_bytes().to_vec(), + mtime: Binding::from_raw(mtime), + ctime: Binding::from_raw(ctime), + } + } + + fn raw(&self) -> raw::git_index_entry { + raw::git_index_entry { + dev: self.dev as c_uint, + ino: self.ino as c_uint, + mode: self.mode as c_uint, + uid: self.uid as c_uint, + gid: self.gid as c_uint, + file_size: self.file_size as raw::git_off_t, + id: unsafe { *self.id.raw() }, + flags: self.flags as c_ushort, + flags_extended: self.flags_extended as c_ushort, + path: self.path.as_ptr() as *const _, + mtime: raw::git_index_time { + seconds: self.mtime.seconds() as raw::git_time_t, + nanoseconds: self.mtime.nanoseconds() as c_uint, + }, + ctime: raw::git_index_time { + seconds: self.ctime.seconds() as raw::git_time_t, + nanoseconds: self.ctime.nanoseconds() as c_uint, + }, + } + } +} + +#[cfg(test)] +mod tests { + use std::fs::{self, File}; + use std::path::Path; + use tempdir::TempDir; + + use {Index, Repository, ResetType}; + + #[test] + fn smoke() { + let mut index = Index::new().unwrap(); + assert!(index.add_path(&Path::new(".")).is_err()); + index.clear().unwrap(); + assert_eq!(index.len(), 0); + assert!(index.get(0).is_none()); + assert!(index.path().is_none()); + assert!(index.read(true).is_err()); + } + + #[test] + fn smoke_from_repo() { + let (_td, repo) = ::test::repo_init(); + let mut index = repo.index().unwrap(); + assert_eq!(index.path().map(|s| s.to_path_buf()), + Some(repo.path().join("index"))); + Index::open(&repo.path().join("index")).unwrap(); + + index.clear().unwrap(); + index.read(true).unwrap(); + index.write().unwrap(); + index.write_tree().unwrap(); + index.write_tree_to(&repo).unwrap(); + } + + #[test] + fn add_all() { + let (_td, repo) = ::test::repo_init(); + let mut index = repo.index().unwrap(); + + let root = repo.path().parent().unwrap(); + fs::create_dir(&root.join("foo")).unwrap(); + File::create(&root.join("foo/bar")).unwrap(); + let mut called = false; + index.add_all(["foo"].iter(), ::ADD_DEFAULT, + Some(&mut |a: &Path, b: &[u8]| { + assert!(!called); + called = true; + assert_eq!(b, b"foo"); + assert_eq!(a, Path::new("foo/bar")); + 0 + })).unwrap(); + assert!(called); + + called = false; + index.remove_all(["."].iter(), Some(&mut |a: &Path, b: &[u8]| { + assert!(!called); + called = true; + assert_eq!(b, b"."); + assert_eq!(a, Path::new("foo/bar")); + 0 + })).unwrap(); + assert!(called); + } + + #[test] + fn smoke_add() { + let (_td, repo) = ::test::repo_init(); + let mut index = repo.index().unwrap(); + + let root = repo.path().parent().unwrap(); + fs::create_dir(&root.join("foo")).unwrap(); + File::create(&root.join("foo/bar")).unwrap(); + index.add_path(Path::new("foo/bar")).unwrap(); + index.write().unwrap(); + assert_eq!(index.iter().count(), 1); + + // Make sure we can use this repo somewhere else now. + let id = index.write_tree().unwrap(); + let tree = repo.find_tree(id).unwrap(); + let sig = repo.signature().unwrap(); + let id = repo.refname_to_id("HEAD").unwrap(); + let parent = repo.find_commit(id).unwrap(); + let commit = repo.commit(Some("HEAD"), &sig, &sig, "commit", + &tree, &[&parent]).unwrap(); + let obj = repo.find_object(commit, None).unwrap(); + repo.reset(&obj, ResetType::Hard, None).unwrap(); + + let td2 = TempDir::new("git").unwrap(); + let url = ::test::path2url(&root); + let repo = Repository::clone(&url, td2.path()).unwrap(); + let obj = repo.find_object(commit, None).unwrap(); + repo.reset(&obj, ResetType::Hard, None).unwrap(); + } +} + diff --git a/deps/git2-0.2.12/src/lib.rs b/deps/git2-0.2.12/src/lib.rs new file mode 100644 index 000000000..f8828c5a9 --- /dev/null +++ b/deps/git2-0.2.12/src/lib.rs @@ -0,0 +1,608 @@ +//! # libgit2 bindings for Rust +//! +//! This library contains bindings to the [libgit2][1] C library which is used +//! to manage git repositories. The library itself is a work in progress and is +//! likely lacking some bindings here and there, so be warned. +//! +//! [1]: https://libgit2.github.com/ +//! +//! The git2-rs library strives to be as close to libgit2 as possible, but also +//! strives to make using libgit2 as safe as possible. All resource management +//! is automatic as well as adding strong types to all interfaces (including +//! `Result`) +//! +//! ## Creating a `Repository` +//! +//! The `Repository` is the source from which almost all other objects in git-rs +//! are spawned. A repository can be created through opening, initializing, or +//! cloning. +//! +//! ### Initializing a new repository +//! +//! The `init` method will create a new repository, assuming one does not +//! already exist. +//! +//! ```no_run +//! # #![allow(unstable)] +//! use git2::Repository; +//! +//! let repo = match Repository::init("/path/to/a/repo") { +//! Ok(repo) => repo, +//! Err(e) => panic!("failed to init: {}", e), +//! }; +//! ``` +//! +//! ### Opening an existing repository +//! +//! ```no_run +//! # #![allow(unstable)] +//! use git2::Repository; +//! +//! let repo = match Repository::open("/path/to/a/repo") { +//! Ok(repo) => repo, +//! Err(e) => panic!("failed to open: {}", e), +//! }; +//! ``` +//! +//! ### Cloning an existing repository +//! +//! ```no_run +//! # #![allow(unstable)] +//! use git2::Repository; +//! +//! let url = "https://github.com/alexcrichton/git2-rs"; +//! let repo = match Repository::clone(url, "/path/to/a/repo") { +//! Ok(repo) => repo, +//! Err(e) => panic!("failed to clone: {}", e), +//! }; +//! ``` +//! +//! ## Working with a `Repository` +//! +//! All deriviative objects, references, etc are attached to the lifetime of the +//! source `Repository`, to ensure that they do not outlive the repository +//! itself. + +#![doc(html_root_url = "http://alexcrichton.com/git2-rs")] +#![allow(trivial_numeric_casts, trivial_casts)] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] +#![cfg_attr(all(feature = "unstable", test, unix), feature(fs, fs_ext))] +#![cfg_attr(feature = "unstable", feature(catch_panic))] + +extern crate libc; +extern crate url; +extern crate libgit2_sys as raw; +#[macro_use] extern crate bitflags; +#[cfg(test)] extern crate tempdir; + +use std::ffi::{CStr, CString}; +use std::fmt; +use std::str; +use std::sync::{Once, ONCE_INIT}; + +pub use blame::{Blame, BlameHunk, BlameIter, BlameOptions}; +pub use blob::Blob; +pub use branch::{Branch, Branches}; +pub use buf::Buf; +pub use commit::{Commit, Parents}; +pub use config::{Config, ConfigEntry, ConfigEntries}; +pub use cred::{Cred, CredentialHelper}; +pub use diff::{Diff, DiffDelta, DiffFile, DiffOptions, Deltas}; +pub use diff::{DiffLine, DiffHunk, DiffStats, DiffFindOptions}; +pub use error::Error; +pub use index::{Index, IndexEntry, IndexEntries, IndexMatchedPath}; +pub use note::{Note, Notes}; +pub use object::Object; +pub use oid::Oid; +pub use pathspec::{Pathspec, PathspecMatchList, PathspecFailedEntries}; +pub use pathspec::{PathspecDiffEntries, PathspecEntries}; +pub use push::{Push, PushStatus}; +pub use reference::{Reference, References, ReferenceNames}; +pub use reflog::{Reflog, ReflogEntry, ReflogIter}; +pub use refspec::Refspec; +pub use remote::{Remote, Refspecs, RemoteHead}; +pub use remote_callbacks::{RemoteCallbacks, Credentials, TransferProgress}; +pub use remote_callbacks::{TransportMessage, Progress, UpdateTips}; +pub use repo::{Repository, RepositoryInitOptions}; +pub use revspec::Revspec; +pub use revwalk::Revwalk; +pub use signature::Signature; +pub use status::{StatusOptions, Statuses, StatusIter, StatusEntry, StatusShow}; +pub use submodule::Submodule; +pub use tag::Tag; +pub use time::{Time, IndexTime}; +pub use tree::{Tree, TreeEntry, TreeIter}; +pub use util::IntoCString; + +/// An enumeration of possible errors that can happen when working with a git +/// repository. +#[derive(PartialEq, Eq, Clone, Debug, Copy)] +pub enum ErrorCode { + /// Generic error + GenericError, + /// Requested object could not be found + NotFound, + /// Object exists preventing operation + Exists, + /// More than one object matches + Ambiguous, + /// Output buffer too short to hold data + BufSize, + /// Operation not allowed on bare repository + User, + /// Operation not allowed on bare repository + BareRepo, + /// HEAD refers to branch with no commits + UnbornBranch, + /// Merge in progress prevented operation + Unmerged, + /// Reference was not fast-forwardable + NotFastForward, + /// Name/ref spec was not in a valid format + InvalidSpec, + /// Merge conflicts prevented operation + MergeConflict, + /// Lock file prevented operation + Locked, + /// Reference value does not match expected + Modified, +} + +/// A listing of the possible states that a repository can be in. +#[derive(PartialEq, Eq, Clone, Debug, Copy)] +#[allow(missing_docs)] +pub enum RepositoryState { + Clean, + Merge, + Revert, + CherryPick, + Bisect, + Rebase, + RebaseInteractive, + RebaseMerge, + ApplyMailbox, + ApplyMailboxOrRebase, +} + +/// An enumeration of the possible directions for a remote. +#[derive(Copy, Clone)] +pub enum Direction { + /// Data will be fetched (read) from this remote. + Fetch, + /// Data will be pushed (written) to this remote. + Push, +} + +/// An enumeration of the operations that can be performed for the `reset` +/// method on a `Repository`. +#[derive(Copy, Clone)] +pub enum ResetType { + /// Move the head to the given commit. + Soft, + /// Soft plus reset the index to the commit. + Mixed, + /// Mixed plus changes in the working tree are discarded. + Hard, +} + +/// An enumeration all possible kinds objects may have. +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +pub enum ObjectType { + /// An object which corresponds to a any git object + Any, + /// An object which corresponds to a git commit + Commit, + /// An object which corresponds to a git tree + Tree, + /// An object which corresponds to a git blob + Blob, + /// An object which corresponds to a git tag + Tag, +} + +/// An enumeration for the possible types of branches +#[derive(PartialEq, Eq, Debug, Copy, Clone)] +pub enum BranchType { + /// A local branch not on a remote. + Local, + /// A branch for a remote. + Remote, +} + +/// An enumeration of the possible priority levels of a config file. +/// +/// The levels corresponding to the escalation logic (higher to lower) when +/// searching for config entries. +#[derive(PartialEq, Eq, Debug, Copy, Clone)] +pub enum ConfigLevel { + /// System-wide configuration file, e.g. /etc/gitconfig + System, + /// XDG-compatible configuration file, e.g. ~/.config/git/config + XDG, + /// User-specific configuration, e.g. ~/.gitconfig + Global, + /// Reopsitory specific config, e.g. $PWD/.git/config + Local, + /// Application specific configuration file + App, + /// Highest level available + Highest, +} + +bitflags! { + #[doc = " +Orderings that may be specified for Revwalk iteration. +"] + flags Sort: u32 { + const SORT_NONE = raw::GIT_SORT_NONE as u32, + const SORT_TOPOLOGICAL = raw::GIT_SORT_TOPOLOGICAL as u32, + const SORT_TIME = raw::GIT_SORT_TIME as u32, + const SORT_REVERSE = raw::GIT_SORT_REVERSE as u32, + } +} + +bitflags! { + #[doc = " +Types of credentials that can be requested by a credential callback. +"] + flags CredentialType: u32 { + const USER_PASS_PLAINTEXT = raw::GIT_CREDTYPE_USERPASS_PLAINTEXT as u32, + const SSH_KEY = raw::GIT_CREDTYPE_SSH_KEY as u32, + const SSH_CUSTOM = raw::GIT_CREDTYPE_SSH_CUSTOM as u32, + const DEFAULT = raw::GIT_CREDTYPE_DEFAULT as u32, + const SSH_INTERACTIVE = raw::GIT_CREDTYPE_SSH_INTERACTIVE as u32, + const USERNAME = raw::GIT_CREDTYPE_USERNAME as u32, + } +} + +bitflags! { + #[doc = " +Flags for APIs that add files matching pathspec +"] + flags IndexAddOption: u32 { + const ADD_DEFAULT = raw::GIT_INDEX_ADD_DEFAULT as u32, + const ADD_FORCE = raw::GIT_INDEX_ADD_FORCE as u32, + const ADD_DISABLE_PATHSPEC_MATCH = + raw::GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH as u32, + const ADD_CHECK_PATHSPEC = raw::GIT_INDEX_ADD_CHECK_PATHSPEC as u32, + } +} + +bitflags! { + #[doc = " +Flags for the return value of `Repository::revparse` +"] + flags RevparseMode: u32 { + const REVPARSE_SINGLE = raw::GIT_REVPARSE_SINGLE as u32, + const REVPARSE_RANGE = raw::GIT_REVPARSE_RANGE as u32, + const REVPARSE_MERGE_BASE = raw::GIT_REVPARSE_MERGE_BASE as u32, + } +} + +#[cfg(test)] #[macro_use] mod test; +#[macro_use] mod panic; +mod call; +mod util; + +pub mod build; +pub mod cert; +pub mod string_array; +pub mod transport; + +mod blame; +mod blob; +mod branch; +mod buf; +mod commit; +mod config; +mod cred; +mod diff; +mod error; +mod index; +mod note; +mod object; +mod oid; +mod pathspec; +mod push; +mod reference; +mod reflog; +mod refspec; +mod remote; +mod remote_callbacks; +mod repo; +mod revspec; +mod revwalk; +mod signature; +mod status; +mod submodule; +mod tag; +mod time; +mod tree; + +fn init() { + static INIT: Once = ONCE_INIT; + INIT.call_once(|| unsafe { + raw::openssl_init(); + let r = raw::git_libgit2_init(); + assert!(r >= 0, + "couldn't initialize the libgit2 library: {}", r); + assert_eq!(libc::atexit(shutdown), 0); + }); + extern fn shutdown() { unsafe { raw::git_libgit2_shutdown() } } +} + +unsafe fn opt_bytes<'a, T>(_anchor: &'a T, + c: *const libc::c_char) -> Option<&'a [u8]> { + if c.is_null() { + None + } else { + Some(CStr::from_ptr(c).to_bytes()) + } +} + +fn opt_cstr(o: Option) -> Result, Error> { + match o { + Some(s) => s.into_c_string().map(Some), + None => Ok(None) + } +} + +impl ObjectType { + /// Convert an object type to its string representation. + pub fn str(&self) -> &'static str { + unsafe { + let ptr = call!(raw::git_object_type2string(*self)) as *const _; + let data = CStr::from_ptr(ptr).to_bytes(); + str::from_utf8(data).unwrap() + } + } + + /// Determine if the given git_otype is a valid loose object type. + pub fn is_loose(&self) -> bool { + unsafe { (call!(raw::git_object_typeisloose(*self)) == 1) } + } + + /// Convert a raw git_otype to an ObjectType + pub fn from_raw(raw: raw::git_otype) -> Option { + match raw { + raw::GIT_OBJ_ANY => Some(ObjectType::Any), + raw::GIT_OBJ_BAD => None, + raw::GIT_OBJ__EXT1 => None, + raw::GIT_OBJ_COMMIT => Some(ObjectType::Commit), + raw::GIT_OBJ_TREE => Some(ObjectType::Tree), + raw::GIT_OBJ_BLOB => Some(ObjectType::Blob), + raw::GIT_OBJ_TAG => Some(ObjectType::Tag), + raw::GIT_OBJ__EXT2 => None, + raw::GIT_OBJ_OFS_DELTA => None, + raw::GIT_OBJ_REF_DELTA => None, + } + } + + /// Convert this kind into its raw representation + pub fn raw(&self) -> raw::git_otype { + call::convert(self) + } + + /// Convert a string object type representation to its object type. + pub fn from_str(s: &str) -> Option { + let raw = unsafe { call!(raw::git_object_string2type(CString::new(s).unwrap())) }; + ObjectType::from_raw(raw) + } +} + +impl fmt::Display for ObjectType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.str().fmt(f) + } +} + +impl ConfigLevel { + /// Converts a raw configuration level to a ConfigLevel + pub fn from_raw(raw: raw::git_config_level_t) -> ConfigLevel { + match raw { + raw::GIT_CONFIG_LEVEL_SYSTEM => ConfigLevel::System, + raw::GIT_CONFIG_LEVEL_XDG => ConfigLevel::XDG, + raw::GIT_CONFIG_LEVEL_GLOBAL => ConfigLevel::Global, + raw::GIT_CONFIG_LEVEL_LOCAL => ConfigLevel::Local, + raw::GIT_CONFIG_LEVEL_APP => ConfigLevel::App, + raw::GIT_CONFIG_HIGHEST_LEVEL => ConfigLevel::Highest, + } + } +} + +bitflags! { + #[doc = " +Flags for repository status +"] + flags Status: u32 { + const STATUS_CURRENT = raw::GIT_STATUS_CURRENT as u32, + + const STATUS_INDEX_NEW = raw::GIT_STATUS_INDEX_NEW as u32, + const STATUS_INDEX_MODIFIED = raw::GIT_STATUS_INDEX_MODIFIED as u32, + const STATUS_INDEX_DELETED = raw::GIT_STATUS_INDEX_DELETED as u32, + const STATUS_INDEX_RENAMED = raw::GIT_STATUS_INDEX_RENAMED as u32, + const STATUS_INDEX_TYPECHANGE = raw::GIT_STATUS_INDEX_TYPECHANGE as u32, + + const STATUS_WT_NEW = raw::GIT_STATUS_WT_NEW as u32, + const STATUS_WT_MODIFIED = raw::GIT_STATUS_WT_MODIFIED as u32, + const STATUS_WT_DELETED = raw::GIT_STATUS_WT_DELETED as u32, + const STATUS_WT_TYPECHANGE = raw::GIT_STATUS_WT_TYPECHANGE as u32, + const STATUS_WT_RENAMED = raw::GIT_STATUS_WT_RENAMED as u32, + + const STATUS_IGNORED = raw::GIT_STATUS_IGNORED as u32, + } +} + +bitflags! { + #[doc = " +Mode options for RepositoryInitOptions +"] + flags RepositoryInitMode: u32 { + #[doc = "Use permissions configured by umask - the default"] + const REPOSITORY_INIT_SHARED_UMASK = + raw::GIT_REPOSITORY_INIT_SHARED_UMASK as u32, + #[doc = "Use `--shared=group` behavior, chmod'ing the new repo to be \ + group writable and \"g+sx\" for sticky group assignment"] + const REPOSITORY_INIT_SHARED_GROUP = + raw::GIT_REPOSITORY_INIT_SHARED_GROUP as u32, + #[doc = "Use `--shared=all` behavior, adding world readability."] + const REPOSITORY_INIT_SHARED_ALL = + raw::GIT_REPOSITORY_INIT_SHARED_ALL as u32, + } +} + +/// What type of change is described by a `DiffDelta`? +#[derive(Copy, Clone, Debug)] +pub enum Delta { + /// No changes + Unmodified, + /// Entry does not exist in old version + Added, + /// Entry does not exist in new version + Deleted, + /// Entry content changed between old and new + Modified, + /// Entry was renamed wbetween old and new + Renamed, + /// Entry was copied from another old entry + Copied, + /// Entry is ignored item in workdir + Ignored, + /// Entry is untracked item in workdir + Untracked, + /// Type of entry changed between old and new + Typechange, + /// Entry is unreadable + Unreadable, +} + +bitflags! { + #[doc = r#" +Return codes for submodule status. + +A combination of these flags will be returned to describe the status of a +submodule. Depending on the "ignore" property of the submodule, some of +the flags may never be returned because they indicate changes that are +supposed to be ignored. + +Submodule info is contained in 4 places: the HEAD tree, the index, config +files (both .git/config and .gitmodules), and the working directory. Any +or all of those places might be missing information about the submodule +depending on what state the repo is in. We consider all four places to +build the combination of status flags. + +There are four values that are not really status, but give basic info +about what sources of submodule data are available. These will be +returned even if ignore is set to "ALL". + +* IN_HEAD - superproject head contains submodule +* IN_INDEX - superproject index contains submodule +* IN_CONFIG - superproject gitmodules has submodule +* IN_WD - superproject workdir has submodule + +The following values will be returned so long as ignore is not "ALL". + +* INDEX_ADDED - in index, not in head +* INDEX_DELETED - in head, not in index +* INDEX_MODIFIED - index and head don't match +* WD_UNINITIALIZED - workdir contains empty directory +* WD_ADDED - in workdir, not index +* WD_DELETED - in index, not workdir +* WD_MODIFIED - index and workdir head don't match + +The following can only be returned if ignore is "NONE" or "UNTRACKED". + +* WD_INDEX_MODIFIED - submodule workdir index is dirty +* WD_WD_MODIFIED - submodule workdir has modified files + +Lastly, the following will only be returned for ignore "NONE". + +* WD_UNTRACKED - wd contains untracked files +"#] + flags SubmoduleStatus: u32 { + const SUBMODULE_STATUS_IN_HEAD = + raw::GIT_SUBMODULE_STATUS_IN_HEAD as u32, + const SUBMODULE_STATUS_IN_INDEX = + raw::GIT_SUBMODULE_STATUS_IN_INDEX as u32, + const SUBMODULE_STATUS_IN_CONFIG = + raw::GIT_SUBMODULE_STATUS_IN_CONFIG as u32, + const SUBMODULE_STATUS_IN_WD = + raw::GIT_SUBMODULE_STATUS_IN_WD as u32, + const SUBMODULE_STATUS_INDEX_ADDED = + raw::GIT_SUBMODULE_STATUS_INDEX_ADDED as u32, + const SUBMODULE_STATUS_INDEX_DELETED = + raw::GIT_SUBMODULE_STATUS_INDEX_DELETED as u32, + const SUBMODULE_STATUS_INDEX_MODIFIED = + raw::GIT_SUBMODULE_STATUS_INDEX_MODIFIED as u32, + const SUBMODULE_STATUS_WD_UNINITIALIZED = + raw::GIT_SUBMODULE_STATUS_WD_UNINITIALIZED as u32, + const SUBMODULE_STATUS_WD_ADDED = + raw::GIT_SUBMODULE_STATUS_WD_ADDED as u32, + const SUBMODULE_STATUS_WD_DELETED = + raw::GIT_SUBMODULE_STATUS_WD_DELETED as u32, + const SUBMODULE_STATUS_WD_MODIFIED = + raw::GIT_SUBMODULE_STATUS_WD_MODIFIED as u32, + const SUBMODULE_STATUS_WD_INDEX_MODIFIED = + raw::GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED as u32, + const SUBMODULE_STATUS_WD_WD_MODIFIED = + raw::GIT_SUBMODULE_STATUS_WD_WD_MODIFIED as u32, + const SUBMODULE_STATUS_WD_UNTRACKED = + raw::GIT_SUBMODULE_STATUS_WD_UNTRACKED as u32, + } + +} + +bitflags! { + #[doc = r#" +"#] + flags PathspecFlags: u32 { + const PATHSPEC_DEFAULT = raw::GIT_PATHSPEC_DEFAULT as u32, + const PATHSPEC_IGNORE_CASE = raw::GIT_PATHSPEC_IGNORE_CASE as u32, + const PATHSPEC_USE_CASE = raw::GIT_PATHSPEC_USE_CASE as u32, + const PATHSPEC_NO_GLOB = raw::GIT_PATHSPEC_NO_GLOB as u32, + const PATHSPEC_NO_MATCH_ERROR = raw::GIT_PATHSPEC_NO_MATCH_ERROR as u32, + const PATHSPEC_FIND_FAILURES = raw::GIT_PATHSPEC_FIND_FAILURES as u32, + const PATHSPEC_FAILURES_ONLY = raw::GIT_PATHSPEC_FAILURES_ONLY as u32, + } +} + +/// Possible output formats for diff data +#[derive(Copy, Clone)] +pub enum DiffFormat { + /// full git diff + Patch, + /// just the headers of the patch + PatchHeader, + /// like git diff --raw + Raw, + /// like git diff --name-only + NameOnly, + /// like git diff --name-status + NameStatus, +} + +bitflags! { + /// Formatting options for diff stats + flags DiffStatsFormat: u32 { + const DIFF_STATS_NONE = raw::GIT_DIFF_STATS_NONE as u32, + const DIFF_STATS_FULL = raw::GIT_DIFF_STATS_FULL as u32, + const DIFF_STATS_SHORT = raw::GIT_DIFF_STATS_SHORT as u32, + const DIFF_STATS_NUMBER = raw::GIT_DIFF_STATS_NUMBER as u32, + const DIFF_STATS_INCLUDE_SUMMARY = + raw::GIT_DIFF_STATS_INCLUDE_SUMMARY as u32, + } +} + +#[cfg(test)] +mod tests { + use super::ObjectType; + + #[test] + fn convert() { + assert_eq!(ObjectType::Blob.str(), "blob"); + assert_eq!(ObjectType::from_str("blob"), Some(ObjectType::Blob)); + assert!(ObjectType::Blob.is_loose()); + } + +} diff --git a/deps/git2-0.2.12/src/note.rs b/deps/git2-0.2.12/src/note.rs new file mode 100644 index 000000000..79b6c6880 --- /dev/null +++ b/deps/git2-0.2.12/src/note.rs @@ -0,0 +1,126 @@ +use std::marker; +use std::str; + +use {raw, signature, Signature, Oid, Repository}; +use util::Binding; + +/// A structure representing a [note][note] in git. +/// +/// [note]: http://git-scm.com/blog/2010/08/25/notes.html +pub struct Note<'repo> { + raw: *mut raw::git_note, + + // Hmm, the current libgit2 version does not have this inside of it, but + // perhaps it's a good idea to keep it around? Can always remove it later I + // suppose... + _marker: marker::PhantomData<&'repo Repository>, +} + +/// An iterator over all of the notes within a repository. +pub struct Notes<'repo> { + raw: *mut raw::git_note_iterator, + _marker: marker::PhantomData<&'repo Repository>, +} + +impl<'repo> Note<'repo> { + /// Get the note author + pub fn author(&self) -> Signature { + unsafe { + signature::from_raw_const(self, raw::git_note_author(&*self.raw)) + } + } + + /// Get the note committer + pub fn committer(&self) -> Signature { + unsafe { + signature::from_raw_const(self, raw::git_note_committer(&*self.raw)) + } + } + + /// Get the note message, in bytes. + pub fn message_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_note_message(&*self.raw)).unwrap() } + } + + /// Get the note message as a string, returning `None` if it is not UTF-8. + pub fn message(&self) -> Option<&str> { + str::from_utf8(self.message_bytes()).ok() + } + + /// Get the note object's id + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_note_id(&*self.raw)) } + } +} + +impl<'repo> Binding for Note<'repo> { + type Raw = *mut raw::git_note; + unsafe fn from_raw(raw: *mut raw::git_note) -> Note<'repo> { + Note { raw: raw, _marker: marker::PhantomData, } + } + fn raw(&self) -> *mut raw::git_note { self.raw } +} + + +impl<'repo> Drop for Note<'repo> { + fn drop(&mut self) { + unsafe { raw::git_note_free(self.raw); } + } +} + +impl<'repo> Binding for Notes<'repo> { + type Raw = *mut raw::git_note_iterator; + unsafe fn from_raw(raw: *mut raw::git_note_iterator) -> Notes<'repo> { + Notes { raw: raw, _marker: marker::PhantomData, } + } + fn raw(&self) -> *mut raw::git_note_iterator { self.raw } +} + +impl<'repo> Iterator for Notes<'repo> { + type Item = (Oid, Oid); + fn next(&mut self) -> Option<(Oid, Oid)> { + let mut note_id = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + let mut annotated_id = note_id; + unsafe { + match raw::git_note_next(&mut note_id, &mut annotated_id, self.raw) { + 0 => Some((Binding::from_raw(¬e_id as *const _), + Binding::from_raw(&annotated_id as *const _))), + _ => None, + } + } + } +} + +impl<'repo> Drop for Notes<'repo> { + fn drop(&mut self) { + unsafe { raw::git_note_iterator_free(self.raw); } + } +} + +#[cfg(test)] +mod tests { + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + assert!(repo.notes(None).is_err()); + + let sig = repo.signature().unwrap(); + let head = repo.head().unwrap().target().unwrap(); + let note = repo.note(&sig, &sig, None, head, "foo", false).unwrap(); + assert_eq!(repo.notes(None).unwrap().count(), 1); + + let note_obj = repo.find_note(None, head).unwrap(); + assert_eq!(note_obj.id(), note); + assert_eq!(note_obj.message(), Some("foo")); + + let (a, b) = repo.notes(None).unwrap().next().unwrap(); + assert_eq!(a, note); + assert_eq!(b, head); + + assert_eq!(repo.note_default_ref().unwrap(), "refs/notes/commits"); + + assert_eq!(sig.name(), note_obj.author().name()); + assert_eq!(sig.name(), note_obj.committer().name()); + assert!(sig.when() == note_obj.committer().when()); + } +} diff --git a/deps/git2-0.2.12/src/object.rs b/deps/git2-0.2.12/src/object.rs new file mode 100644 index 000000000..e0148e636 --- /dev/null +++ b/deps/git2-0.2.12/src/object.rs @@ -0,0 +1,119 @@ +use std::marker; +use std::mem; + +use {raw, Oid, ObjectType, Error, Buf, Commit, Tag, Blob, Tree, Repository}; +use util::Binding; + +/// A structure to represent a git [object][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects +pub struct Object<'repo> { + raw: *mut raw::git_object, + _marker: marker::PhantomData<&'repo Repository>, +} + +impl<'repo> Object<'repo> { + /// Get the id (SHA1) of a repository object + pub fn id(&self) -> Oid { + unsafe { + Binding::from_raw(raw::git_object_id(&*self.raw)) + } + } + + /// Get the object type of an object. + /// + /// If the type is unknown, then `None` is returned. + pub fn kind(&self) -> Option { + ObjectType::from_raw(unsafe { raw::git_object_type(&*self.raw) }) + } + + /// Recursively peel an object until an object of the specified type is met. + /// + /// If you pass `Any` as the target type, then the object will be + /// peeled until the type changes (e.g. a tag will be chased until the + /// referenced object is no longer a tag). + pub fn peel(&self, kind: ObjectType) -> Result, Error> { + let mut raw = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_object_peel(&mut raw, &*self.raw(), kind)); + Ok(Binding::from_raw(raw)) + } + } + + /// Get a short abbreviated OID string for the object + /// + /// This starts at the "core.abbrev" length (default 7 characters) and + /// iteratively extends to a longer string if that length is ambiguous. The + /// result will be unambiguous (at least until new objects are added to the + /// repository). + pub fn short_id(&self) -> Result { + unsafe { + let buf = Buf::new(); + try_call!(raw::git_object_short_id(buf.raw(), &*self.raw())); + Ok(buf) + } + } + + /// Attempt to view this object as a commit. + /// + /// Returns `None` if the object is not actually a commit. + pub fn as_commit(&self) -> Option<&Commit<'repo>> { + self.cast(ObjectType::Commit) + } + + /// Attempt to view this object as a tag. + /// + /// Returns `None` if the object is not actually a tag. + pub fn as_tag(&self) -> Option<&Tag<'repo>> { + self.cast(ObjectType::Tag) + } + + /// Attempt to view this object as a tree. + /// + /// Returns `None` if the object is not actually a tree. + pub fn as_tree(&self) -> Option<&Tree<'repo>> { + self.cast(ObjectType::Tree) + } + + /// Attempt to view this object as a blob. + /// + /// Returns `None` if the object is not actually a blob. + pub fn as_blob(&self) -> Option<&Blob<'repo>> { + self.cast(ObjectType::Blob) + } + + fn cast(&self, kind: ObjectType) -> Option<&T> { + assert_eq!(mem::size_of::(), mem::size_of::()); + if self.kind() == Some(kind) { + unsafe { Some(&*(self as *const _ as *const T)) } + } else { + None + } + } +} + +impl<'repo> Clone for Object<'repo> { + fn clone(&self) -> Object<'repo> { + let mut raw = 0 as *mut raw::git_object; + unsafe { + let rc = raw::git_object_dup(&mut raw, self.raw); + assert_eq!(rc, 0); + Binding::from_raw(raw) + } + } +} + +impl<'repo> Binding for Object<'repo> { + type Raw = *mut raw::git_object; + + unsafe fn from_raw(raw: *mut raw::git_object) -> Object<'repo> { + Object { raw: raw, _marker: marker::PhantomData, } + } + fn raw(&self) -> *mut raw::git_object { self.raw } +} + +impl<'repo> Drop for Object<'repo> { + fn drop(&mut self) { + unsafe { raw::git_object_free(self.raw) } + } +} diff --git a/deps/git2-0.2.12/src/oid.rs b/deps/git2-0.2.12/src/oid.rs new file mode 100644 index 000000000..ce3cf85bd --- /dev/null +++ b/deps/git2-0.2.12/src/oid.rs @@ -0,0 +1,128 @@ +use std::fmt; +use std::cmp::Ordering; +use std::hash::{Hasher, Hash}; +use std::str; +use libc; + +use {raw, Error}; +use util::Binding; + +/// Unique identity of any object (commit, tree, blob, tag). +#[derive(Copy)] +pub struct Oid { + raw: raw::git_oid, +} + +impl Oid { + /// Parse a hex-formatted object id into an Oid structure. + /// + /// If the string is not a valid 40-character hex string, an error is + /// returned. + pub fn from_str(s: &str) -> Result { + ::init(); + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_oid_fromstrn(&mut raw, + s.as_bytes().as_ptr() + as *const libc::c_char, + s.len() as libc::size_t)); + } + Ok(Oid { raw: raw }) + } + + /// Parse a raw object id into an Oid structure. + /// + /// If the array given is not 20 bytes in length, an error is returned. + pub fn from_bytes(bytes: &[u8]) -> Result { + ::init(); + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + if bytes.len() != raw::GIT_OID_RAWSZ { + Err(Error::from_str("raw byte array must be 20 bytes")) + } else { + unsafe { raw::git_oid_fromraw(&mut raw, bytes.as_ptr()) } + Ok(Oid { raw: raw }) + } + } + + /// View this OID as a byte-slice 20 bytes in length. + pub fn as_bytes(&self) -> &[u8] { &self.raw.id } + + /// Test if this OID is all zeros. + pub fn is_zero(&self) -> bool { + unsafe { raw::git_oid_iszero(&self.raw) == 1 } + } +} + +impl Binding for Oid { + type Raw = *const raw::git_oid; + + unsafe fn from_raw(oid: *const raw::git_oid) -> Oid { + Oid { raw: *oid } + } + fn raw(&self) -> *const raw::git_oid { &self.raw as *const _ } +} + +impl fmt::Debug for Oid { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +impl fmt::Display for Oid { + /// Hex-encode this Oid into a formatter. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut dst = [0u8; raw::GIT_OID_HEXSZ + 1]; + unsafe { + raw::git_oid_tostr(dst.as_mut_ptr() as *mut libc::c_char, + dst.len() as libc::size_t, &self.raw); + } + let s = &dst[..dst.iter().position(|&a| a == 0).unwrap()]; + str::from_utf8(s).unwrap().fmt(f) + } +} + +impl PartialEq for Oid { + fn eq(&self, other: &Oid) -> bool { + unsafe { raw::git_oid_equal(&self.raw, &other.raw) != 0 } + } +} +impl Eq for Oid {} + +impl PartialOrd for Oid { + fn partial_cmp(&self, other: &Oid) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Oid { + fn cmp(&self, other: &Oid) -> Ordering { + match unsafe { raw::git_oid_cmp(&self.raw, &other.raw) } { + 0 => Ordering::Equal, + n if n < 0 => Ordering::Less, + _ => Ordering::Greater, + } + } +} + +impl Clone for Oid { + fn clone(&self) -> Oid { *self } +} + +impl Hash for Oid { + fn hash(&self, into: &mut H) { + self.raw.id.hash(into) + } +} + +#[cfg(test)] +mod tests { + use super::Oid; + + #[test] + fn conversions() { + assert!(Oid::from_str("foo").is_err()); + assert!(Oid::from_str("decbf2be529ab6557d5429922251e5ee36519817").is_ok()); + assert!(Oid::from_bytes(b"foo").is_err()); + assert!(Oid::from_bytes(b"00000000000000000000").is_ok()); + } +} diff --git a/deps/git2-0.2.12/src/panic.rs b/deps/git2-0.2.12/src/panic.rs new file mode 100644 index 000000000..e55e22408 --- /dev/null +++ b/deps/git2-0.2.12/src/panic.rs @@ -0,0 +1,76 @@ +use std::any::Any; +use std::cell::RefCell; + +// This is technically super unsafe, allowing capturing an arbitrary environment +// and then declaring it Send to cross the boundary into a safe call to `wrap`. +// +// One of the main reasons for the `Send` bound, however, is for exception +// safety mitigation. We do not want to impose exception safety concerns on +// consumers, so at the end of all calls to libgit2 we check if there was an +// error while calling a callback and then re-raise as a panic if necessary. +// Along these lines we simply catch an exception to be re-raised on the Rust +// side after passing back through C. +// +// As a result we're generally keeping the equivalent semantics for Rust, so +// this `unsafe impl Send` should be ok. +macro_rules! wrap_env { + (fn $fn_name:ident($($arg:ident: $arg_t:ty),*) -> $ret:ty { $body:expr } + returning $name:ident as $ret_expr:expr ) => { + extern fn $fn_name($($arg: $arg_t),*) -> $ret { + struct Env { $($arg: $arg_t),* } + unsafe impl Send for Env {} + let env = Env { $($arg: $arg),* }; + let $name = ::panic::wrap(move || { + $(let $arg = env.$arg;)* + $body + }); + $ret_expr + } + } +} + +thread_local!(static LAST_ERROR: RefCell>> = { + RefCell::new(None) +}); + +#[cfg(feature = "unstable")] +pub fn wrap T + Send + 'static>(f: F) -> Option { + use std::thread; + if LAST_ERROR.with(|slot| slot.borrow().is_some()) { + return None + } + match thread::catch_panic(f) { + Ok(ret) => Some(ret), + Err(e) => { + LAST_ERROR.with(move |slot| { + *slot.borrow_mut() = Some(e); + }); + None + } + } +} + +#[cfg(not(feature = "unstable"))] +pub fn wrap T + Send + 'static>(f: F) -> Option { + struct Bomb { enabled: bool } + impl Drop for Bomb { + fn drop(&mut self) { + if !self.enabled { return } + panic!("callback has panicked, and continuing to unwind into C \ + is not safe, so aborting the process"); + + } + } + let mut bomb = Bomb { enabled: true }; + let ret = Some(f()); + bomb.enabled = false; + return ret; +} + +pub fn check() { + let err = LAST_ERROR.with(|slot| slot.borrow_mut().take()); + match err { + Some(err) => panic!(err), + None => {} + } +} diff --git a/deps/git2-0.2.12/src/pathspec.rs b/deps/git2-0.2.12/src/pathspec.rs new file mode 100644 index 000000000..05590ff64 --- /dev/null +++ b/deps/git2-0.2.12/src/pathspec.rs @@ -0,0 +1,284 @@ +use std::iter::IntoIterator; +use std::marker; +use std::ops::Range; +use std::path::Path; +use libc::size_t; + +use {raw, Error, Tree, PathspecFlags, Index, Repository, DiffDelta, IntoCString}; +use util::Binding; + +/// Structure representing a compiled pathspec used for matching against various +/// structures. +pub struct Pathspec { + raw: *mut raw::git_pathspec, +} + +/// List of filenames matching a pathspec. +pub struct PathspecMatchList<'ps> { + raw: *mut raw::git_pathspec_match_list, + _marker: marker::PhantomData<&'ps Pathspec>, +} + +/// Iterator over the matched paths in a pathspec. +pub struct PathspecEntries<'list> { + range: Range, + list: &'list PathspecMatchList<'list>, +} + +/// Iterator over the matching diff deltas. +pub struct PathspecDiffEntries<'list> { + range: Range, + list: &'list PathspecMatchList<'list>, +} + +/// Iterator over the failed list of pathspec items that did not match. +pub struct PathspecFailedEntries<'list> { + range: Range, + list: &'list PathspecMatchList<'list>, +} + +impl Pathspec { + /// Creates a new pathspec from a list of specs to match against. + pub fn new(specs: I) -> Result + where T: IntoCString, I: IntoIterator { + let (_a, _b, arr) = try!(::util::iter2cstrs(specs)); + unsafe { + let mut ret = 0 as *mut raw::git_pathspec; + try_call!(raw::git_pathspec_new(&mut ret, &arr)); + Ok(Binding::from_raw(ret)) + } + } + + /// Match a pathspec against files in a tree. + /// + /// The list returned contains the list of all matched filenames (unless you + /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the + /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is + /// specified. + pub fn match_tree(&self, tree: &Tree, flags: PathspecFlags) + -> Result { + let mut ret = 0 as *mut raw::git_pathspec_match_list; + unsafe { + try_call!(raw::git_pathspec_match_tree(&mut ret, tree.raw(), + flags.bits(), self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// This matches the pathspec against the files in the repository index. + /// + /// The list returned contains the list of all matched filenames (unless you + /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the + /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is + /// specified. + pub fn match_index(&self, index: &Index, flags: PathspecFlags) + -> Result { + let mut ret = 0 as *mut raw::git_pathspec_match_list; + unsafe { + try_call!(raw::git_pathspec_match_index(&mut ret, index.raw(), + flags.bits(), self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Match a pathspec against the working directory of a repository. + /// + /// This matches the pathspec against the current files in the working + /// directory of the repository. It is an error to invoke this on a bare + /// repo. This handles git ignores (i.e. ignored files will not be + /// considered to match the pathspec unless the file is tracked in the + /// index). + /// + /// The list returned contains the list of all matched filenames (unless you + /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the + /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is + /// specified. + pub fn match_workdir(&self, repo: &Repository, flags: PathspecFlags) + -> Result { + let mut ret = 0 as *mut raw::git_pathspec_match_list; + unsafe { + try_call!(raw::git_pathspec_match_workdir(&mut ret, repo.raw(), + flags.bits(), self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Try to match a path against a pathspec + /// + /// Unlike most of the other pathspec matching functions, this will not fall + /// back on the native case-sensitivity for your platform. You must + /// explicitly pass flags to control case sensitivity or else this will fall + /// back on being case sensitive. + pub fn matches_path(&self, path: &Path, flags: PathspecFlags) -> bool { + let path = path.into_c_string().unwrap(); + unsafe { + raw::git_pathspec_matches_path(&*self.raw, flags.bits(), + path.as_ptr()) == 1 + } + } +} + +impl Binding for Pathspec { + type Raw = *mut raw::git_pathspec; + + unsafe fn from_raw(raw: *mut raw::git_pathspec) -> Pathspec { + Pathspec { raw: raw } + } + fn raw(&self) -> *mut raw::git_pathspec { self.raw } +} + +impl Drop for Pathspec { + fn drop(&mut self) { + unsafe { raw::git_pathspec_free(self.raw) } + } +} + +impl<'ps> PathspecMatchList<'ps> { + fn entrycount(&self) -> usize { + unsafe { raw::git_pathspec_match_list_entrycount(&*self.raw) as usize } + } + + fn failed_entrycount(&self) -> usize { + unsafe { raw::git_pathspec_match_list_failed_entrycount(&*self.raw) as usize } + } + + /// Returns an iterator over the matching filenames in this list. + pub fn entries(&self) -> PathspecEntries { + let n = self.entrycount(); + let n = if n > 0 && self.entry(0).is_none() {0} else {n}; + PathspecEntries { range: 0..n, list: self } + } + + /// Get a matching filename by position. + /// + /// If this list was generated from a diff, then the return value will + /// always be `None. + pub fn entry(&self, i: usize) -> Option<&[u8]> { + unsafe { + let ptr = raw::git_pathspec_match_list_entry(&*self.raw, i as size_t); + ::opt_bytes(self, ptr) + } + } + + /// Returns an iterator over the matching diff entries in this list. + pub fn diff_entries(&self) -> PathspecDiffEntries { + let n = self.entrycount(); + let n = if n > 0 && self.diff_entry(0).is_none() {0} else {n}; + PathspecDiffEntries { range: 0..n, list: self } + } + + /// Get a matching diff delta by position. + /// + /// If the list was not generated from a diff, then the return value will + /// always be `None`. + pub fn diff_entry(&self, i: usize) -> Option { + unsafe { + let ptr = raw::git_pathspec_match_list_diff_entry(&*self.raw, + i as size_t); + Binding::from_raw_opt(ptr as *mut _) + } + } + + /// Returns an iterator over the non-matching entries in this list. + pub fn failed_entries(&self) -> PathspecFailedEntries { + let n = self.failed_entrycount(); + let n = if n > 0 && self.failed_entry(0).is_none() {0} else {n}; + PathspecFailedEntries { range: 0..n, list: self } + } + + /// Get an original pathspec string that had no matches. + pub fn failed_entry(&self, i: usize) -> Option<&[u8]> { + unsafe { + let ptr = raw::git_pathspec_match_list_failed_entry(&*self.raw, + i as size_t); + ::opt_bytes(self, ptr) + } + } +} + +impl<'ps> Binding for PathspecMatchList<'ps> { + type Raw = *mut raw::git_pathspec_match_list; + + unsafe fn from_raw(raw: *mut raw::git_pathspec_match_list) + -> PathspecMatchList<'ps> { + PathspecMatchList { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_pathspec_match_list { self.raw } +} + +impl<'ps> Drop for PathspecMatchList<'ps> { + fn drop(&mut self) { + unsafe { raw::git_pathspec_match_list_free(self.raw) } + } +} + +impl<'list> Iterator for PathspecEntries<'list> { + type Item = &'list [u8]; + fn next(&mut self) -> Option<&'list [u8]> { + self.range.next().and_then(|i| self.list.entry(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'list> DoubleEndedIterator for PathspecEntries<'list> { + fn next_back(&mut self) -> Option<&'list [u8]> { + self.range.next_back().and_then(|i| self.list.entry(i)) + } +} +impl<'list> ExactSizeIterator for PathspecEntries<'list> {} + +impl<'list> Iterator for PathspecDiffEntries<'list> { + type Item = DiffDelta<'list>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.list.diff_entry(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'list> DoubleEndedIterator for PathspecDiffEntries<'list> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.list.diff_entry(i)) + } +} +impl<'list> ExactSizeIterator for PathspecDiffEntries<'list> {} + +impl<'list> Iterator for PathspecFailedEntries<'list> { + type Item = &'list [u8]; + fn next(&mut self) -> Option<&'list [u8]> { + self.range.next().and_then(|i| self.list.failed_entry(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'list> DoubleEndedIterator for PathspecFailedEntries<'list> { + fn next_back(&mut self) -> Option<&'list [u8]> { + self.range.next_back().and_then(|i| self.list.failed_entry(i)) + } +} +impl<'list> ExactSizeIterator for PathspecFailedEntries<'list> {} + +#[cfg(test)] +mod tests { + use PATHSPEC_DEFAULT; + use super::Pathspec; + use std::fs::File; + use std::path::Path; + + #[test] + fn smoke() { + let ps = Pathspec::new(["a"].iter()).unwrap(); + assert!(ps.matches_path(Path::new("a"), PATHSPEC_DEFAULT)); + assert!(ps.matches_path(Path::new("a/b"), PATHSPEC_DEFAULT)); + assert!(!ps.matches_path(Path::new("b"), PATHSPEC_DEFAULT)); + assert!(!ps.matches_path(Path::new("ab/c"), PATHSPEC_DEFAULT)); + + let (td, repo) = ::test::repo_init(); + let list = ps.match_workdir(&repo, PATHSPEC_DEFAULT).unwrap(); + assert_eq!(list.entries().len(), 0); + assert_eq!(list.diff_entries().len(), 0); + assert_eq!(list.failed_entries().len(), 0); + + File::create(&td.path().join("a")).unwrap(); + + let list = ps.match_workdir(&repo, ::PATHSPEC_FIND_FAILURES).unwrap(); + assert_eq!(list.entries().len(), 1); + assert_eq!(list.entries().next(), Some("a".as_bytes())); + } +} diff --git a/deps/git2-0.2.12/src/push.rs b/deps/git2-0.2.12/src/push.rs new file mode 100644 index 000000000..72aeffefc --- /dev/null +++ b/deps/git2-0.2.12/src/push.rs @@ -0,0 +1,135 @@ +use std::ffi::{CStr, CString}; +use std::marker; +use std::str; +use libc; + +use {raw, Error, Signature}; +use util::Binding; + +/// A structure to represent a pending push operation to a remote. +/// +/// Remotes can create a `Push` which is then used to push data to the upstream +/// repository. +pub struct Push<'remote> { + raw: *mut raw::git_push, + _marker: marker::PhantomData<&'remote raw::git_remote>, +} + +/// A status representing the result of updating a remote reference. +pub struct PushStatus { + /// The reference that was updated as part of a push. + pub reference: String, + /// If `None`, the reference was updated successfully, otherwise a message + /// explaining why it could not be updated is provided. + pub message: Option, +} + +impl<'remote> Push<'remote> { + /// Add a refspec to be pushed + pub fn add_refspec(&mut self, refspec: &str) -> Result<(), Error> { + let refspec = try!(CString::new(refspec)); + unsafe { + try_call!(raw::git_push_add_refspec(self.raw, refspec)); + Ok(()) + } + } + + /// Actually push all given refspecs + /// + /// To check if the push was successful (i.e. all remote references have + /// been updated as requested), you need to call + /// `statuses`. The remote repository might have refused to + /// update some or all of the references. + pub fn finish(&mut self) -> Result<(), Error> { + unsafe { + try_call!(raw::git_push_finish(self.raw)); + Ok(()) + } + } + + /// Update remote tips after a push + pub fn update_tips(&mut self, signature: Option<&Signature>, + reflog_message: Option<&str>) -> Result<(), Error> { + let msg = try!(::opt_cstr(reflog_message)); + unsafe { + try_call!(raw::git_push_update_tips(self.raw, + signature.map(|s| s.raw()), + msg)); + Ok(()) + } + } + + /// Return each status entry + pub fn statuses(&mut self) -> Result, Error> { + let mut ret: Vec = Vec::new(); + unsafe { + try_call!(raw::git_push_status_foreach(self.raw, cb, + &mut ret as *mut _ + as *mut libc::c_void)); + } + return Ok(ret); + + extern fn cb(git_ref: *const libc::c_char, + msg: *const libc::c_char, + data: *mut libc::c_void) -> libc::c_int { + unsafe { + let git_ref = match str::from_utf8(CStr::from_ptr(git_ref).to_bytes()) { + Ok(s) => s.to_string(), + Err(_) => return 0, + }; + let msg = if !msg.is_null() { + match str::from_utf8(CStr::from_ptr(msg).to_bytes()) { + Ok(s) => Some(s.to_string()), + Err(_) => return 0, + } + } else { + None + }; + + let data = &mut *(data as *mut Vec); + data.push(PushStatus { reference: git_ref, message: msg }); + return 0; + } + } + } +} + +impl<'remote> Binding for Push<'remote> { + type Raw = *mut raw::git_push; + unsafe fn from_raw(raw: *mut raw::git_push) -> Push<'remote> { + Push { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_push { self.raw } +} + +impl<'a> Drop for Push<'a> { + fn drop(&mut self) { + unsafe { raw::git_push_free(self.raw) } + } +} + +#[cfg(test)] +mod tests { + use tempdir::TempDir; + use Repository; + + #[test] + fn smoke() { + let td = TempDir::new("test").unwrap(); + let remote = td.path().join("remote"); + Repository::init_bare(&remote).unwrap(); + + let (_td, repo) = ::test::repo_init(); + let url = ::test::path2url(&remote); + let mut remote = repo.remote("origin", &url).unwrap(); + + let mut push = remote.push().unwrap(); + push.add_refspec("refs/heads/master").unwrap(); + push.finish().unwrap(); + push.update_tips(None, None).unwrap(); + let v = push.statuses().unwrap(); + assert!(v.len() > 0); + assert_eq!(v[0].reference, "refs/heads/master"); + assert!(v[0].message.is_none()); + } +} diff --git a/deps/git2-0.2.12/src/reference.rs b/deps/git2-0.2.12/src/reference.rs new file mode 100644 index 000000000..c4fc17742 --- /dev/null +++ b/deps/git2-0.2.12/src/reference.rs @@ -0,0 +1,340 @@ +use std::cmp::Ordering; +use std::ffi::CString; +use std::marker; +use std::mem; +use std::str; +use libc; + +use {raw, Error, Oid, Repository, Object, ObjectType}; +use util::Binding; + +struct Refdb<'repo>(&'repo Repository); + +/// A structure to represent a git [reference][1]. +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-Git-References +pub struct Reference<'repo> { + raw: *mut raw::git_reference, + _marker: marker::PhantomData>, +} + +/// An iterator over the references in a repository. +pub struct References<'repo> { + raw: *mut raw::git_reference_iterator, + _marker: marker::PhantomData>, +} + +/// An iterator over the names of references in a repository. +pub struct ReferenceNames<'repo> { + inner: References<'repo>, +} + +impl<'repo> Reference<'repo> { + /// Ensure the reference name is well-formed. + pub fn is_valid_name(refname: &str) -> bool { + ::init(); + let refname = CString::new(refname).unwrap(); + unsafe { raw::git_reference_is_valid_name(refname.as_ptr()) == 1 } + } + + /// Get access to the underlying raw pointer. + pub fn raw(&self) -> *mut raw::git_reference { self.raw } + + /// Delete an existing reference. + /// + /// This method works for both direct and symbolic references. The reference + /// will be immediately removed on disk. + /// + /// This function will return an error if the reference has changed from the + /// time it was looked up. + pub fn delete(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_reference_delete(self.raw)); } + Ok(()) + } + + /// Check if a reference is a local branch. + pub fn is_branch(&self) -> bool { + unsafe { raw::git_reference_is_branch(&*self.raw) == 1 } + } + + /// Check if a reference is a note. + pub fn is_note(&self) -> bool { + unsafe { raw::git_reference_is_note(&*self.raw) == 1 } + } + + /// Check if a reference is a remote tracking branch + pub fn is_remote(&self) -> bool { + unsafe { raw::git_reference_is_remote(&*self.raw) == 1 } + } + + /// Check if a reference is a tag + pub fn is_tag(&self) -> bool { + unsafe { raw::git_reference_is_tag(&*self.raw) == 1 } + } + + /// Get the full name of a reference. + /// + /// Returns `None` if the name is not valid utf-8. + pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } + + /// Get the full name of a reference. + pub fn name_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_reference_name(&*self.raw)).unwrap() } + } + + /// Get the full shorthand of a reference. + /// + /// This will transform the reference name into a name "human-readable" + /// version. If no shortname is appropriate, it will return the full name. + /// + /// Returns `None` if the shorthand is not valid utf-8. + pub fn shorthand(&self) -> Option<&str> { + str::from_utf8(self.shorthand_bytes()).ok() + } + + /// Get the full shorthand of a reference. + pub fn shorthand_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_reference_shorthand(&*self.raw)).unwrap() + } + } + + /// Get the OID pointed to by a direct reference. + /// + /// Only available if the reference is direct (i.e. an object id reference, + /// not a symbolic one). + pub fn target(&self) -> Option { + unsafe { + Binding::from_raw_opt(raw::git_reference_target(&*self.raw)) + } + } + + /// Return the peeled OID target of this reference. + /// + /// This peeled OID only applies to direct references that point to a hard + /// Tag object: it is the result of peeling such Tag. + pub fn target_peel(&self) -> Option { + unsafe { + Binding::from_raw_opt(raw::git_reference_target_peel(&*self.raw)) + } + } + + /// Get full name to the reference pointed to by a symbolic reference. + /// + /// May return `None` if the reference is either not symbolic or not a + /// valid utf-8 string. + pub fn symbolic_target(&self) -> Option<&str> { + self.symbolic_target_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get full name to the reference pointed to by a symbolic reference. + /// + /// Only available if the reference is symbolic. + pub fn symbolic_target_bytes(&self) -> Option<&[u8]> { + unsafe { ::opt_bytes(self, raw::git_reference_symbolic_target(&*self.raw)) } + } + + /// Resolve a symbolic reference to a direct reference. + /// + /// This method iteratively peels a symbolic reference until it resolves to + /// a direct reference to an OID. + /// + /// If a direct reference is passed as an argument, a copy of that + /// reference is returned. + pub fn resolve(&self) -> Result, Error> { + let mut raw = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_reference_resolve(&mut raw, &*self.raw)); + Ok(Binding::from_raw(raw)) + } + } + + /// Peel a reference to an object + /// + /// This method recursively peels the reference until it reaches + /// an object of the specified type. + pub fn peel(&self, kind: ObjectType) -> Result, Error> { + let mut raw = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_reference_peel(&mut raw, &*self.raw, kind)); + Ok(Binding::from_raw(raw)) + } + } + + /// Rename an existing reference. + /// + /// This method works for both direct and symbolic references. + /// + /// If the force flag is not enabled, and there's already a reference with + /// the given name, the renaming will fail. + pub fn rename(&mut self, new_name: &str, force: bool, + msg: &str) -> Result, Error> { + let mut raw = 0 as *mut raw::git_reference; + let new_name = try!(CString::new(new_name)); + let msg = try!(CString::new(msg)); + unsafe { + try_call!(raw::git_reference_rename(&mut raw, self.raw, new_name, + force, msg)); + Ok(Binding::from_raw(raw)) + } + } + +} + +impl<'repo> PartialOrd for Reference<'repo> { + fn partial_cmp(&self, other: &Reference<'repo>) -> Option { + Some(self.cmp(other)) + } +} + +impl<'repo> Ord for Reference<'repo> { + fn cmp(&self, other: &Reference<'repo>) -> Ordering { + match unsafe { raw::git_reference_cmp(&*self.raw, &*other.raw) } { + 0 => Ordering::Equal, + n if n < 0 => Ordering::Less, + _ => Ordering::Greater, + } + } +} + +impl<'repo> PartialEq for Reference<'repo> { + fn eq(&self, other: &Reference<'repo>) -> bool { + self.cmp(other) == Ordering::Equal + } +} + +impl<'repo> Eq for Reference<'repo> {} + +impl<'repo> Binding for Reference<'repo> { + type Raw = *mut raw::git_reference; + unsafe fn from_raw(raw: *mut raw::git_reference) -> Reference<'repo> { + Reference { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_reference { self.raw } +} + +impl<'repo> Drop for Reference<'repo> { + fn drop(&mut self) { + unsafe { raw::git_reference_free(self.raw) } + } +} + +impl<'repo> References<'repo> { + /// Consumes a `References` iterator to create an iterator over just the + /// name of some references. + /// + /// This is more efficient if only the names are desired of references as + /// the references themselves don't have to be allocated and deallocated. + /// + /// The returned iterator will yield strings as opposed to a `Reference`. + pub fn names(self) -> ReferenceNames<'repo> { + ReferenceNames { inner: self } + } +} + +impl<'repo> Binding for References<'repo> { + type Raw = *mut raw::git_reference_iterator; + unsafe fn from_raw(raw: *mut raw::git_reference_iterator) + -> References<'repo> { + References { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_reference_iterator { self.raw } +} + +impl<'repo> Iterator for References<'repo> { + type Item = Reference<'repo>; + fn next(&mut self) -> Option> { + let mut out = 0 as *mut raw::git_reference; + if unsafe { raw::git_reference_next(&mut out, self.raw) == 0 } { + Some(unsafe { Binding::from_raw(out) }) + } else { + None + } + } +} + +impl<'repo> Drop for References<'repo> { + fn drop(&mut self) { + unsafe { raw::git_reference_iterator_free(self.raw) } + } +} + +impl<'repo> Iterator for ReferenceNames<'repo> { + type Item = &'repo str; + fn next(&mut self) -> Option<&'repo str> { + let mut out = 0 as *const libc::c_char; + if unsafe { raw::git_reference_next_name(&mut out, self.inner.raw) == 0 } { + Some(unsafe { + let bytes = ::opt_bytes(self, out).unwrap(); + let s = str::from_utf8(bytes).unwrap(); + mem::transmute::<&str, &'repo str>(s) + }) + } else { + None + } + } +} + +#[cfg(test)] +mod tests { + use {Reference, ObjectType}; + + #[test] + fn smoke() { + assert!(Reference::is_valid_name("refs/foo")); + assert!(!Reference::is_valid_name("foo")); + } + + #[test] + fn smoke2() { + let (_td, repo) = ::test::repo_init(); + let mut head = repo.head().unwrap(); + assert!(head.is_branch()); + assert!(!head.is_remote()); + assert!(!head.is_tag()); + assert!(!head.is_note()); + + assert!(head == repo.head().unwrap()); + assert_eq!(head.name(), Some("refs/heads/master")); + + assert!(head == repo.find_reference("refs/heads/master").unwrap()); + assert_eq!(repo.refname_to_id("refs/heads/master").unwrap(), + head.target().unwrap()); + + assert!(head.symbolic_target().is_none()); + assert!(head.target_peel().is_none()); + + assert_eq!(head.shorthand(), Some("master")); + assert!(head.resolve().unwrap() == head); + + let mut tag1 = repo.reference("refs/tags/tag1", + head.target().unwrap(), + false, "test").unwrap(); + assert!(tag1.is_tag()); + + let peeled_commit = tag1.peel(ObjectType::Commit).unwrap(); + assert_eq!(ObjectType::Commit, peeled_commit.kind().unwrap()); + assert_eq!(tag1.target().unwrap(), peeled_commit.id()); + + tag1.delete().unwrap(); + + let mut sym1 = repo.reference_symbolic("refs/tags/tag1", + "refs/heads/master", false, + "test").unwrap(); + sym1.delete().unwrap(); + + { + assert!(repo.references().unwrap().count() == 1); + assert!(repo.references().unwrap().next().unwrap() == head); + let mut names = repo.references().unwrap().names(); + assert_eq!(names.next(), Some("refs/heads/master")); + assert_eq!(names.next(), None); + assert!(repo.references_glob("foo").unwrap().count() == 0); + assert!(repo.references_glob("refs/heads/*").unwrap().count() == 1); + } + + let mut head = head.rename("refs/foo", true, "test").unwrap(); + head.delete().unwrap(); + + } +} diff --git a/deps/git2-0.2.12/src/reflog.rs b/deps/git2-0.2.12/src/reflog.rs new file mode 100644 index 000000000..69e40f8e3 --- /dev/null +++ b/deps/git2-0.2.12/src/reflog.rs @@ -0,0 +1,167 @@ +use std::ops::Range; +use std::marker; +use std::str; +use libc::size_t; + +use {raw, signature, Oid, Error, Signature}; +use util::Binding; + +/// A reference log of a git repository. +pub struct Reflog { + raw: *mut raw::git_reflog, +} + +/// An entry inside the reflog of a repository +pub struct ReflogEntry<'reflog> { + raw: *const raw::git_reflog_entry, + _marker: marker::PhantomData<&'reflog Reflog>, +} + +/// An iterator over the entries inside of a reflog. +pub struct ReflogIter<'reflog> { + range: Range, + reflog: &'reflog Reflog, +} + +impl Reflog { + /// Add a new entry to the in-memory reflog. + pub fn append(&mut self, new_oid: Oid, committer: &Signature, + msg: Option<&str>) -> Result<(), Error> { + let msg = try!(::opt_cstr(msg)); + unsafe { + try_call!(raw::git_reflog_append(self.raw, new_oid.raw(), + committer.raw(), msg)); + } + Ok(()) + } + + /// Remove an entry from the reflog by its index + /// + /// To ensure there's no gap in the log history, set rewrite_previous_entry + /// param value to `true`. When deleting entry n, member old_oid of entry + /// n-1 (if any) will be updated with the value of member new_oid of entry + /// n+1. + pub fn remove(&mut self, i: usize, rewrite_previous_entry: bool) + -> Result<(), Error> { + unsafe { + try_call!(raw::git_reflog_drop(self.raw, i as size_t, + rewrite_previous_entry)); + } + Ok(()) + } + + /// Lookup an entry by its index + /// + /// Requesting the reflog entry with an index of 0 (zero) will return the + /// most recently created entry. + pub fn get(&self, i: usize) -> Option { + unsafe { + let ptr = raw::git_reflog_entry_byindex(self.raw, i as size_t); + Binding::from_raw_opt(ptr) + } + } + + /// Get the number of log entries in a reflog + pub fn len(&self) -> usize { + unsafe { raw::git_reflog_entrycount(self.raw) as usize } + } + + /// Get an iterator to all entries inside of this reflog + pub fn iter(&self) -> ReflogIter { + ReflogIter { range: 0..self.len(), reflog: self } + } + + /// Write an existing in-memory reflog object back to disk using an atomic + /// file lock. + pub fn write(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_reflog_write(self.raw)); } + Ok(()) + } +} + +impl Binding for Reflog { + type Raw = *mut raw::git_reflog; + + unsafe fn from_raw(raw: *mut raw::git_reflog) -> Reflog { + Reflog { raw: raw } + } + fn raw(&self) -> *mut raw::git_reflog { self.raw } +} + +impl Drop for Reflog { + fn drop(&mut self) { + unsafe { raw::git_reflog_free(self.raw) } + } +} + +impl<'reflog> ReflogEntry<'reflog> { + /// Get the committer of this entry + pub fn committer(&self) -> Signature { + unsafe { + let ptr = raw::git_reflog_entry_committer(self.raw); + signature::from_raw_const(self, ptr) + } + } + + /// Get the new oid + pub fn id_new(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_reflog_entry_id_new(self.raw)) } + } + + /// Get the old oid + pub fn id_old(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_reflog_entry_id_new(self.raw)) } + } + + /// Get the log message, returning `None` on invalid UTF-8. + pub fn message(&self) -> Option<&str> { + self.message_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the log message as a byte array. + pub fn message_bytes(&self) -> Option<&[u8]> { + unsafe { + ::opt_bytes(self, raw::git_reflog_entry_message(self.raw)) + } + } +} + +impl<'reflog> Binding for ReflogEntry<'reflog> { + type Raw = *const raw::git_reflog_entry; + + unsafe fn from_raw(raw: *const raw::git_reflog_entry) -> ReflogEntry<'reflog> { + ReflogEntry { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *const raw::git_reflog_entry { self.raw } +} + +impl<'reflog> Iterator for ReflogIter<'reflog> { + type Item = ReflogEntry<'reflog>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.reflog.get(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'reflog> DoubleEndedIterator for ReflogIter<'reflog> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.reflog.get(i)) + } +} +impl<'reflog> ExactSizeIterator for ReflogIter<'reflog> {} + +#[cfg(test)] +mod tests { + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let mut reflog = repo.reflog("HEAD").unwrap(); + assert_eq!(reflog.iter().len(), 1); + reflog.write().unwrap(); + + let entry = reflog.iter().next().unwrap(); + assert!(entry.message().is_some()); + + repo.reflog_rename("HEAD", "refs/heads/foo").unwrap(); + repo.reflog_delete("refs/heads/foo").unwrap(); + } +} diff --git a/deps/git2-0.2.12/src/refspec.rs b/deps/git2-0.2.12/src/refspec.rs new file mode 100644 index 000000000..ea82f103e --- /dev/null +++ b/deps/git2-0.2.12/src/refspec.rs @@ -0,0 +1,88 @@ +use std::ffi::CString; +use std::marker; +use std::str; + +use {raw, Direction}; +use util::Binding; + +/// A structure to represent a git [refspec][1]. +/// +/// Refspecs are currently mainly accessed/created through a `Remote`. +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-The-Refspec +pub struct Refspec<'remote> { + raw: *const raw::git_refspec, + _marker: marker::PhantomData<&'remote raw::git_remote>, +} + +impl<'remote> Refspec<'remote> { + /// Get the refspec's direction. + pub fn direction(&self) -> Direction { + match unsafe { raw::git_refspec_direction(self.raw) } { + raw::GIT_DIRECTION_FETCH => Direction::Fetch, + raw::GIT_DIRECTION_PUSH => Direction::Push, + } + } + + /// Get the destination specifier. + /// + /// If the destination is not utf-8, None is returned. + pub fn dst(&self) -> Option<&str> { + str::from_utf8(self.dst_bytes()).ok() + } + + /// Get the destination specifier, in bytes. + pub fn dst_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_refspec_dst(self.raw)).unwrap() } + } + + /// Check if a refspec's destination descriptor matches a reference + pub fn dst_matches(&self, refname: &str) -> bool { + let refname = CString::new(refname).unwrap(); + unsafe { raw::git_refspec_dst_matches(self.raw, refname.as_ptr()) == 1 } + } + + /// Get the source specifier. + /// + /// If the source is not utf-8, None is returned. + pub fn src(&self) -> Option<&str> { + str::from_utf8(self.src_bytes()).ok() + } + + /// Get the source specifier, in bytes. + pub fn src_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_refspec_src(self.raw)).unwrap() } + } + + /// Check if a refspec's source descriptor matches a reference + pub fn src_matches(&self, refname: &str) -> bool { + let refname = CString::new(refname).unwrap(); + unsafe { raw::git_refspec_src_matches(self.raw, refname.as_ptr()) == 1 } + } + + /// Get the force update setting. + pub fn is_force(&self) -> bool { + unsafe { raw::git_refspec_force(self.raw) == 1 } + } + + /// Get the refspec's string. + /// + /// Returns None if the string is not valid utf8. + pub fn str(&self) -> Option<&str> { + str::from_utf8(self.bytes()).ok() + } + + /// Get the refspec's string as a byte array + pub fn bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_refspec_string(self.raw)).unwrap() } + } +} + +impl<'remote> Binding for Refspec<'remote> { + type Raw = *const raw::git_refspec; + + unsafe fn from_raw(raw: *const raw::git_refspec) -> Refspec<'remote> { + Refspec { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *const raw::git_refspec { self.raw } +} diff --git a/deps/git2-0.2.12/src/remote.rs b/deps/git2-0.2.12/src/remote.rs new file mode 100644 index 000000000..9aa390eec --- /dev/null +++ b/deps/git2-0.2.12/src/remote.rs @@ -0,0 +1,526 @@ +use std::ffi::CString; +use std::ops::Range; +use std::marker; +use std::mem; +use std::slice; +use std::str; +use libc; + +use {raw, Direction, Error, Refspec, Oid, IntoCString}; +use {Push, RemoteCallbacks, Progress, Repository}; +use util::Binding; + +/// A structure representing a [remote][1] of a git repository. +/// +/// [1]: http://git-scm.com/book/en/Git-Basics-Working-with-Remotes +/// +/// The lifetime is the lifetime of the repository that it is attached to. The +/// remote is used to manage fetches and pushes as well as refspecs. +pub struct Remote<'repo, 'cb> { + raw: *mut raw::git_remote, + _marker: marker::PhantomData<&'repo Repository>, + callbacks: Option>>, +} + +/// An iterator over the refspecs that a remote contains. +pub struct Refspecs<'remote, 'cb: 'remote> { + range: Range, + remote: &'remote Remote<'remote, 'cb>, +} + +/// Description of a reference advertised bya remote server, given out on calls +/// to `list`. +pub struct RemoteHead<'remote> { + raw: *const raw::git_remote_head, + _marker: marker::PhantomData<&'remote str>, +} + +impl<'repo, 'cb> Remote<'repo, 'cb> { + /// Ensure the remote name is well-formed. + pub fn is_valid_name(remote_name: &str) -> bool { + ::init(); + let remote_name = CString::new(remote_name).unwrap(); + unsafe { raw::git_remote_is_valid_name(remote_name.as_ptr()) == 1 } + } + + /// Get the remote's name. + /// + /// Returns `None` if this remote has not yet been named or if the name is + /// not valid utf-8 + pub fn name(&self) -> Option<&str> { + self.name_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the remote's name, in bytes. + /// + /// Returns `None` if this remote has not yet been named + pub fn name_bytes(&self) -> Option<&[u8]> { + unsafe { ::opt_bytes(self, raw::git_remote_name(&*self.raw)) } + } + + /// Get the remote's url. + /// + /// Returns `None` if the url is not valid utf-8 + pub fn url(&self) -> Option<&str> { + str::from_utf8(self.url_bytes()).ok() + } + + /// Get the remote's url as a byte array. + pub fn url_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_remote_url(&*self.raw)).unwrap() } + } + + /// Get the remote's pushurl. + /// + /// Returns `None` if the pushurl is not valid utf-8 + pub fn pushurl(&self) -> Option<&str> { + self.pushurl_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the remote's pushurl as a byte array. + pub fn pushurl_bytes(&self) -> Option<&[u8]> { + unsafe { ::opt_bytes(self, raw::git_remote_pushurl(&*self.raw)) } + } + + /// Open a connection to a remote. + pub fn connect(&mut self, dir: Direction) -> Result<(), Error> { + unsafe { + try!(self.set_raw_callbacks()); + try_call!(raw::git_remote_connect(self.raw, dir)); + } + Ok(()) + } + + /// Check whether the remote is connected + pub fn connected(&mut self) -> bool { + unsafe { raw::git_remote_connected(self.raw) == 1 } + } + + /// Disconnect from the remote + pub fn disconnect(&mut self) { + unsafe { raw::git_remote_disconnect(self.raw) } + } + + /// Save a remote to its repository's configuration + /// + /// Anonymous remotes cannot be saved + pub fn save(&self) -> Result<(), Error> { + unsafe { try_call!(raw::git_remote_save(&*self.raw)); } + Ok(()) + } + + /// Add a fetch refspec to the remote + pub fn add_fetch(&mut self, spec: &str) -> Result<(), Error> { + let spec = try!(CString::new(spec)); + unsafe { + try_call!(raw::git_remote_add_fetch(self.raw, spec)); + } + Ok(()) + } + + /// Add a push refspec to the remote + pub fn add_push(&mut self, spec: &str) -> Result<(), Error> { + let spec = try!(CString::new(spec)); + unsafe { + try_call!(raw::git_remote_add_push(self.raw, spec)); + } + Ok(()) + } + + /// Set the remote's url + /// + /// Existing connections will not be updated. + pub fn set_url(&mut self, url: &str) -> Result<(), Error> { + let url = try!(CString::new(url)); + unsafe { try_call!(raw::git_remote_set_url(self.raw, url)); } + Ok(()) + } + + /// Set the remote's pushurl. + /// + /// `None` indicates that it should be cleared. + /// + /// Existing connections will not be updated. + pub fn set_pushurl(&mut self, pushurl: Option<&str>) -> Result<(), Error> { + let pushurl = try!(::opt_cstr(pushurl)); + unsafe { + try_call!(raw::git_remote_set_pushurl(self.raw, pushurl)); + } + Ok(()) + } + + /// Sets the update FETCH_HEAD setting. By default, FETCH_HEAD will be + /// updated on every fetch. + pub fn set_update_fetchhead(&mut self, update: bool) { + unsafe { + raw::git_remote_set_update_fetchhead(self.raw, update as libc::c_int) + } + } + + /// Set the remote's list of fetch refspecs + pub fn set_fetch_refspecs(&mut self, i: I) -> Result<(), Error> + where T: IntoCString, I: Iterator + { + let (_a, _b, mut arr) = try!(::util::iter2cstrs(i)); + unsafe { + try_call!(raw::git_remote_set_fetch_refspecs(self.raw, &mut arr)); + } + Ok(()) + } + + /// Set the remote's list of push refspecs + pub fn set_push_refspecs(&mut self, i: I) -> Result<(), Error> + where T: IntoCString, I: Iterator + { + let (_a, _b, mut arr) = try!(::util::iter2cstrs(i)); + unsafe { + try_call!(raw::git_remote_set_push_refspecs(self.raw, &mut arr)); + } + Ok(()) + } + + /// Clear the refspecs + /// + /// Remove all configured fetch and push refspecs from the remote. + pub fn clear_refspecs(&mut self) { + unsafe { raw::git_remote_clear_refspecs(self.raw) } + } + + /// Download and index the packfile + /// + /// Connect to the remote if it hasn't been done yet, negotiate with the + /// remote git which objects are missing, download and index the packfile. + /// + /// The .idx file will be created and both it and the packfile with be + /// renamed to their final name. + /// + /// The `specs` argument is a list of refspecs to use for this negotiation + /// and download. Use an empty array to use the base refspecs. + pub fn download(&mut self, specs: &[&str]) -> Result<(), Error> { + let (_a, _b, arr) = try!(::util::iter2cstrs(specs.iter())); + unsafe { + try!(self.set_raw_callbacks()); + try_call!(raw::git_remote_download(self.raw, &arr)); + } + Ok(()) + } + + /// Get the number of refspecs for a remote + pub fn refspecs<'a>(&'a self) -> Refspecs<'a, 'cb> { + let cnt = unsafe { raw::git_remote_refspec_count(&*self.raw) as usize }; + Refspecs { range: 0..cnt, remote: self } + } + + /// Get the `nth` refspec from this remote. + /// + /// The `refspecs` iterator can be used to iterate over all refspecs. + pub fn get_refspec(&self, i: usize) -> Option> { + unsafe { + let ptr = raw::git_remote_get_refspec(&*self.raw, + i as libc::size_t); + Binding::from_raw_opt(ptr) + } + } + + /// Download new data and update tips + /// + /// Convenience function to connect to a remote, download the data, + /// disconnect and update the remote-tracking branches. + pub fn fetch(&mut self, + refspecs: &[&str], + msg: Option<&str>) -> Result<(), Error> { + let (_a, _b, arr) = try!(::util::iter2cstrs(refspecs.iter())); + let msg = try!(::opt_cstr(msg)); + unsafe { + try!(self.set_raw_callbacks()); + try_call!(raw::git_remote_fetch(self.raw, &arr, msg)); + } + Ok(()) + } + + /// Update the tips to the new state + pub fn update_tips(&mut self, msg: Option<&str>) -> Result<(), Error> { + let msg = try!(::opt_cstr(msg)); + unsafe { + try_call!(raw::git_remote_update_tips(self.raw, msg)); + } + Ok(()) + } + + /// Retrieve the update FETCH_HEAD setting. + pub fn update_fetchhead(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_remote_update_fetchhead(self.raw)); } + Ok(()) + } + + /// Create a new push object + pub fn push(&mut self) -> Result { + let mut ret = 0 as *mut raw::git_push; + try!(self.set_raw_callbacks()); + unsafe { + try_call!(raw::git_push_new(&mut ret, self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Set the callbacks to be invoked when the transfer is in-progress. + /// + /// This will overwrite the previously set callbacks. + pub fn set_callbacks(&mut self, callbacks: RemoteCallbacks<'cb>) { + self.callbacks = Some(Box::new(callbacks)); + } + + fn set_raw_callbacks(&mut self) -> Result<(), Error> { + match self.callbacks { + Some(ref mut cbs) => unsafe { + let raw = cbs.raw(); + try_call!(raw::git_remote_set_callbacks(self.raw, &raw)); + }, + None => {} + } + Ok(()) + } + + /// Get the statistics structure that is filled in by the fetch operation. + pub fn stats(&self) -> Progress { + unsafe { + Binding::from_raw(raw::git_remote_stats(self.raw)) + } + } + + /// Get the remote repository's reference advertisement list. + /// + /// Get the list of references with which the server responds to a new + /// connection. + /// + /// The remote (or more exactly its transport) must have connected to the + /// remote repository. This list is available as soon as the connection to + /// the remote is initiated and it remains available after disconnecting. + pub fn list(&self) -> Result<&[RemoteHead], Error> { + let mut size = 0; + let mut base = 0 as *mut _; + unsafe { + try_call!(raw::git_remote_ls(&mut base, &mut size, self.raw)); + assert_eq!(mem::size_of::(), + mem::size_of::<*const raw::git_remote_head>()); + let slice = slice::from_raw_parts(base as *const _, size as usize); + Ok(mem::transmute::<&[*const raw::git_remote_head], + &[RemoteHead]>(slice)) + } + } +} + +impl<'a, 'b> Clone for Remote<'a, 'b> { + fn clone(&self) -> Remote<'a, 'b> { + let mut ret = 0 as *mut raw::git_remote; + let rc = unsafe { call!(raw::git_remote_dup(&mut ret, self.raw)) }; + assert_eq!(rc, 0); + Remote { + raw: ret, + _marker: marker::PhantomData, + callbacks: None, + } + } +} + +impl<'repo, 'cb> Binding for Remote<'repo, 'cb> { + type Raw = *mut raw::git_remote; + + unsafe fn from_raw(raw: *mut raw::git_remote) -> Remote<'repo, 'cb> { + Remote { + raw: raw, + _marker: marker::PhantomData, + callbacks: None, + } + } + fn raw(&self) -> *mut raw::git_remote { self.raw } +} + +impl<'a, 'b> Drop for Remote<'a, 'b> { + fn drop(&mut self) { + unsafe { raw::git_remote_free(self.raw) } + } +} + +impl<'repo, 'cb> Iterator for Refspecs<'repo, 'cb> { + type Item = Refspec<'repo>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.remote.get_refspec(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'repo, 'cb> DoubleEndedIterator for Refspecs<'repo, 'cb> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.remote.get_refspec(i)) + } +} +impl<'repo, 'cb> ExactSizeIterator for Refspecs<'repo, 'cb> {} + +#[allow(missing_docs)] // not documented in libgit2 :( +impl<'remote> RemoteHead<'remote> { + /// Flag if this is available locally. + pub fn is_local(&self) -> bool { + unsafe { (*self.raw).local != 0 } + } + + pub fn oid(&self) -> Oid { + unsafe { Binding::from_raw(&(*self.raw).oid as *const _) } + } + pub fn loid(&self) -> Oid { + unsafe { Binding::from_raw(&(*self.raw).loid as *const _) } + } + + pub fn name(&self) -> &str { + let b = unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() }; + str::from_utf8(b).unwrap() + } + + pub fn symref_target(&self) -> Option<&str> { + let b = unsafe { ::opt_bytes(self, (*self.raw).symref_target) }; + b.map(|b| str::from_utf8(b).unwrap()) + } +} + +#[cfg(test)] +mod tests { + use std::cell::Cell; + use tempdir::TempDir; + use {Repository, Remote, RemoteCallbacks, Direction}; + + #[test] + fn smoke() { + let (td, repo) = ::test::repo_init(); + t!(repo.remote("origin", "/path/to/nowhere")); + drop(repo); + + let repo = t!(Repository::init(td.path())); + let mut origin = t!(repo.find_remote("origin")); + assert_eq!(origin.name(), Some("origin")); + assert_eq!(origin.url(), Some("/path/to/nowhere")); + assert_eq!(origin.pushurl(), None); + + t!(origin.set_url("/path/to/elsewhere")); + assert_eq!(origin.url(), Some("/path/to/elsewhere")); + t!(origin.set_pushurl(Some("/path/to/elsewhere"))); + assert_eq!(origin.pushurl(), Some("/path/to/elsewhere")); + + origin.set_update_fetchhead(true); + let stats = origin.stats(); + assert_eq!(stats.total_objects(), 0); + } + + #[test] + fn create_remote() { + let td = TempDir::new("test").unwrap(); + let remote = td.path().join("remote"); + Repository::init_bare(&remote).unwrap(); + + let (_td, repo) = ::test::repo_init(); + let url = if cfg!(unix) { + format!("file://{}", remote.display()) + } else { + format!("file:///{}", remote.display().to_string() + .replace("\\", "/")) + }; + let mut origin = repo.remote("origin", &url).unwrap(); + assert_eq!(origin.name(), Some("origin")); + assert_eq!(origin.url(), Some(&url[..])); + assert_eq!(origin.pushurl(), None); + + { + let mut specs = origin.refspecs(); + let spec = specs.next().unwrap(); + assert!(specs.next().is_none()); + assert_eq!(spec.str(), Some("+refs/heads/*:refs/remotes/origin/*")); + assert_eq!(spec.dst(), Some("refs/remotes/origin/*")); + assert_eq!(spec.src(), Some("refs/heads/*")); + assert!(spec.is_force()); + } + assert!(origin.refspecs().next_back().is_some()); + { + let remotes = repo.remotes().unwrap(); + assert_eq!(remotes.len(), 1); + assert_eq!(remotes.get(0), Some("origin")); + assert_eq!(remotes.iter().count(), 1); + assert_eq!(remotes.iter().next().unwrap(), Some("origin")); + } + + origin.connect(Direction::Push).unwrap(); + assert!(origin.connected()); + origin.disconnect(); + + origin.connect(Direction::Fetch).unwrap(); + assert!(origin.connected()); + origin.download(&[]).unwrap(); + origin.disconnect(); + + t!(origin.save()); + + t!(origin.add_fetch("foo")); + t!(origin.add_fetch("bar")); + origin.clear_refspecs(); + t!(origin.update_fetchhead()); + + origin.set_fetch_refspecs(["foo"].iter().map(|a| *a)).unwrap(); + origin.set_push_refspecs(["foo"].iter().map(|a| *a)).unwrap(); + + origin.fetch(&[], None).unwrap(); + origin.fetch(&[], Some("foo")).unwrap(); + origin.update_tips(None).unwrap(); + origin.update_tips(Some("foo")).unwrap(); + } + + #[test] + fn rename_remote() { + let (_td, repo) = ::test::repo_init(); + repo.remote("origin", "foo").unwrap(); + repo.remote_rename("origin", "foo").unwrap(); + repo.remote_delete("foo").unwrap(); + } + + #[test] + fn create_remote_anonymous() { + let td = TempDir::new("test").unwrap(); + let repo = Repository::init(td.path()).unwrap(); + + let origin = repo.remote_anonymous("/path/to/nowhere", + Some("master")).unwrap(); + assert_eq!(origin.name(), None); + drop(origin.clone()); + } + + #[test] + fn is_valid() { + assert!(Remote::is_valid_name("foobar")); + assert!(!Remote::is_valid_name("\x01")); + } + + #[test] + fn transfer_cb() { + let (td, _repo) = ::test::repo_init(); + let td2 = TempDir::new("git").unwrap(); + let url = ::test::path2url(&td.path()); + + let repo = Repository::init(td2.path()).unwrap(); + let progress_hit = Cell::new(false); + { + let mut callbacks = RemoteCallbacks::new(); + let mut origin = repo.remote("origin", &url).unwrap(); + + callbacks.transfer_progress(|_progress| { + progress_hit.set(true); + true + }); + origin.set_callbacks(callbacks); + origin.fetch(&[], None).unwrap(); + + let list = t!(origin.list()); + assert_eq!(list.len(), 2); + assert_eq!(list[0].name(), "HEAD"); + assert!(!list[0].is_local()); + assert_eq!(list[1].name(), "refs/heads/master"); + assert!(!list[1].is_local()); + } + assert!(progress_hit.get()); + } +} diff --git a/deps/git2-0.2.12/src/remote_callbacks.rs b/deps/git2-0.2.12/src/remote_callbacks.rs new file mode 100644 index 000000000..a40c18084 --- /dev/null +++ b/deps/git2-0.2.12/src/remote_callbacks.rs @@ -0,0 +1,343 @@ +use std::ffi::CStr; +use std::marker; +use std::mem; +use std::slice; +use std::str; +use libc::{c_void, c_int, c_char, c_uint}; + +use {raw, Error, Cred, CredentialType, Oid}; +use cert::Cert; +use util::Binding; + +/// A structure to contain the callbacks which are invoked when a repository is +/// being updated or downloaded. +/// +/// These callbacks are used to manage facilities such as authentication, +/// transfer progress, etc. +pub struct RemoteCallbacks<'a> { + progress: Option>>, + credentials: Option>>, + sideband_progress: Option>>, + update_tips: Option>>, + certificate_check: Option>>, +} + +/// Struct representing the progress by an in-flight transfer. +pub struct Progress<'a> { + raw: ProgressState, + _marker: marker::PhantomData<&'a raw::git_transfer_progress>, +} + +enum ProgressState { + Borrowed(*const raw::git_transfer_progress), + Owned(raw::git_transfer_progress), +} + +/// Callback used to acquire credentials for when a remote is fetched. +/// +/// * `url` - the resource for which the credentials are required. +/// * `username_from_url` - the username that was embedded in the url, or `None` +/// if it was not included. +/// * `allowed_types` - a bitmask stating which cred types are ok to return. +pub type Credentials<'a> = FnMut(&str, Option<&str>, CredentialType) + -> Result + 'a; + +/// Callback to be invoked while a transfer is in progress. +/// +/// This callback will be periodically called with updates to the progress of +/// the transfer so far. The return value indicates whether the transfer should +/// continue. A return value of `false` will cancel the transfer. +/// +/// * `progress` - the progress being made so far. +pub type TransferProgress<'a> = FnMut(Progress) -> bool + 'a; + +/// Callback for receiving messages delivered by the transport. +/// +/// The return value indicates whether the network operation should continue. +pub type TransportMessage<'a> = FnMut(&[u8]) -> bool + 'a; + +/// Callback for whenever a reference is updated locally. +pub type UpdateTips<'a> = FnMut(&str, Oid, Oid) -> bool + 'a; + +/// Callback for a custom certificate check. +/// +/// The first argument is the certificate receved on the connection. +/// Certificates are typically either an SSH or X509 certificate. +/// +/// The second argument is the hostname for the connection is passed as the last +/// argument. +pub type CertificateCheck<'a> = FnMut(&Cert, &str) -> bool + 'a; + +impl<'a> RemoteCallbacks<'a> { + /// Creates a new set of empty callbacks + pub fn new() -> RemoteCallbacks<'a> { + RemoteCallbacks { + credentials: None, + progress: None, + sideband_progress: None, + update_tips: None, + certificate_check: None, + } + } + + /// The callback through which to fetch credentials if required. + pub fn credentials(&mut self, cb: F) -> &mut RemoteCallbacks<'a> + where F: FnMut(&str, Option<&str>, CredentialType) + -> Result + 'a + { + self.credentials = Some(Box::new(cb) as Box>); + self + } + + /// The callback through which progress is monitored. + pub fn transfer_progress(&mut self, cb: F) -> &mut RemoteCallbacks<'a> + where F: FnMut(Progress) -> bool + 'a { + self.progress = Some(Box::new(cb) as Box>); + self + } + + /// Textual progress from the remote. + /// + /// Text sent over the progress side-band will be passed to this function + /// (this is the 'counting objects' output. + pub fn sideband_progress(&mut self, cb: F) -> &mut RemoteCallbacks<'a> + where F: FnMut(&[u8]) -> bool + 'a { + self.sideband_progress = Some(Box::new(cb) as Box>); + self + } + + /// Each time a reference is updated locally, the callback will be called + /// with information about it. + pub fn update_tips(&mut self, cb: F) -> &mut RemoteCallbacks<'a> + where F: FnMut(&str, Oid, Oid) -> bool + 'a { + self.update_tips = Some(Box::new(cb) as Box>); + self + } + + /// If certificate verification fails, then this callback will be invoked to + /// let the caller make the final decision of whether to allow the + /// connection to proceed. + pub fn certificate_check(&mut self, cb: F) -> &mut RemoteCallbacks<'a> + where F: FnMut(&Cert, &str) -> bool + 'a + { + self.certificate_check = Some(Box::new(cb) as Box>); + self + } +} + +impl<'a> Binding for RemoteCallbacks<'a> { + type Raw = raw::git_remote_callbacks; + unsafe fn from_raw(_raw: raw::git_remote_callbacks) -> RemoteCallbacks<'a> { + panic!("unimplemented"); + } + + fn raw(&self) -> raw::git_remote_callbacks { + unsafe { + let mut callbacks: raw::git_remote_callbacks = mem::zeroed(); + assert_eq!(raw::git_remote_init_callbacks(&mut callbacks, + raw::GIT_REMOTE_CALLBACKS_VERSION), 0); + if self.progress.is_some() { + let f: raw::git_transfer_progress_cb = transfer_progress_cb; + callbacks.transfer_progress = Some(f); + } + if self.credentials.is_some() { + let f: raw::git_cred_acquire_cb = credentials_cb; + callbacks.credentials = Some(f); + } + if self.sideband_progress.is_some() { + let f: raw::git_transport_message_cb = sideband_progress_cb; + callbacks.sideband_progress = Some(f); + } + if self.certificate_check.is_some() { + let f: raw::git_transport_certificate_check_cb = + certificate_check_cb; + callbacks.certificate_check = Some(f); + } + if self.update_tips.is_some() { + let f: extern fn(*const c_char, *const raw::git_oid, + *const raw::git_oid, *mut c_void) -> c_int + = update_tips_cb; + callbacks.update_tips = Some(f); + } + callbacks.payload = self as *const _ as *mut _; + return callbacks; + } + } +} + +impl<'a> Progress<'a> { + /// Number of objects in the packfile being downloaded + pub fn total_objects(&self) -> usize { + unsafe { (*self.raw()).total_objects as usize } + } + /// Received objects that have been hashed + pub fn indexed_objects(&self) -> usize { + unsafe { (*self.raw()).indexed_objects as usize } + } + /// Objects which have been downloaded + pub fn received_objects(&self) -> usize { + unsafe { (*self.raw()).received_objects as usize } + } + /// Locally-available objects that have been injected in order to fix a thin + /// pack. + pub fn local_objects(&self) -> usize { + unsafe { (*self.raw()).local_objects as usize } + } + /// Number of deltas in the packfile being downloaded + pub fn total_deltas(&self) -> usize { + unsafe { (*self.raw()).total_deltas as usize } + } + /// Received deltas that have been hashed. + pub fn indexed_deltas(&self) -> usize { + unsafe { (*self.raw()).indexed_deltas as usize } + } + /// Size of the packfile received up to now + pub fn received_bytes(&self) -> usize { + unsafe { (*self.raw()).received_bytes as usize } + } + + /// Convert this to an owned version of `Progress`. + pub fn to_owned(&self) -> Progress<'static> { + Progress { + raw: ProgressState::Owned(unsafe { *self.raw() }), + _marker: marker::PhantomData, + } + } +} + +impl<'a> Binding for Progress<'a> { + type Raw = *const raw::git_transfer_progress; + unsafe fn from_raw(raw: *const raw::git_transfer_progress) + -> Progress<'a> { + Progress { + raw: ProgressState::Borrowed(raw), + _marker: marker::PhantomData, + } + } + + fn raw(&self) -> *const raw::git_transfer_progress { + match self.raw { + ProgressState::Borrowed(raw) => raw, + ProgressState::Owned(ref raw) => raw as *const _, + } + } +} + +wrap_env! { + fn credentials_cb(ret: *mut *mut raw::git_cred, + url: *const c_char, + username_from_url: *const c_char, + allowed_types: c_uint, + payload: *mut c_void) -> c_int { + unsafe { + let payload = &mut *(payload as *mut RemoteCallbacks); + let callback = try!(payload.credentials.as_mut() + .ok_or(raw::GIT_PASSTHROUGH as c_int)); + *ret = 0 as *mut raw::git_cred; + let url = try!(str::from_utf8(CStr::from_ptr(url).to_bytes()) + .map_err(|_| raw::GIT_PASSTHROUGH as c_int)); + let username_from_url = match ::opt_bytes(&url, username_from_url) { + Some(username) => { + Some(try!(str::from_utf8(username) + .map_err(|_| raw::GIT_PASSTHROUGH as c_int))) + } + None => None, + }; + + let cred_type = CredentialType::from_bits_truncate(allowed_types as u32); + callback(url, username_from_url, cred_type).map_err(|e| { + e.raw_code() as c_int + }) + } + } + returning ok as unsafe { + match ok { + Some(Ok(cred)) => { + // Turns out it's a memory safety issue if we pass through any + // and all credentials into libgit2 + if allowed_types & (cred.credtype() as c_uint) != 0 { + *ret = cred.unwrap(); + 0 + } else { + raw::GIT_PASSTHROUGH as c_int + } + } + Some(Err(e)) => e, + None => -1, + } + } +} + +wrap_env! { + fn transfer_progress_cb(stats: *const raw::git_transfer_progress, + payload: *mut c_void) -> c_int { + unsafe { + let payload = &mut *(payload as *mut RemoteCallbacks); + let callback = match payload.progress { + Some(ref mut c) => c, + None => return true, + }; + let progress = Binding::from_raw(stats); + callback(progress) + } + } + returning ok as (if ok == Some(true) {0} else {-1}) +} + +wrap_env! { + fn sideband_progress_cb(str: *const c_char, + len: c_int, + payload: *mut c_void) -> c_int { + unsafe { + let payload = &mut *(payload as *mut RemoteCallbacks); + let callback = match payload.sideband_progress { + Some(ref mut c) => c, + None => return true, + }; + let buf = slice::from_raw_parts(str as *const u8, len as usize); + callback(buf) + } + } + returning ok as (if ok == Some(true) {0} else {-1}) +} + +wrap_env! { + fn update_tips_cb(refname: *const c_char, + a: *const raw::git_oid, + b: *const raw::git_oid, + data: *mut c_void) -> c_int { + unsafe { + let payload = &mut *(data as *mut RemoteCallbacks); + let callback = match payload.update_tips { + Some(ref mut c) => c, + None => return true, + }; + let refname = str::from_utf8(CStr::from_ptr(refname).to_bytes()) + .unwrap(); + let a = Binding::from_raw(a); + let b = Binding::from_raw(b); + callback(refname, a, b) + } + } + returning ok as (if ok == Some(true) {0} else {-1}) +} + +wrap_env! { + fn certificate_check_cb(cert: *mut raw::git_cert, + _valid: c_int, + hostname: *const c_char, + data: *mut c_void) -> c_int { + unsafe { + let payload = &mut *(data as *mut RemoteCallbacks); + let callback = match payload.certificate_check { + Some(ref mut c) => c, + None => return true, + }; + let cert = Binding::from_raw(cert); + let hostname = str::from_utf8(CStr::from_ptr(hostname).to_bytes()) + .unwrap(); + callback(&cert, hostname) + } + } + returning ok as (if ok == Some(true) {0} else {-1}) +} diff --git a/deps/git2-0.2.12/src/repo.rs b/deps/git2-0.2.12/src/repo.rs new file mode 100644 index 000000000..2728d4d6a --- /dev/null +++ b/deps/git2-0.2.12/src/repo.rs @@ -0,0 +1,1528 @@ +use std::ffi::{CStr, CString}; +use std::iter::IntoIterator; +use std::mem; +use std::path::Path; +use std::str; +use libc::{c_int, c_char, size_t, c_void, c_uint}; + +use {raw, Revspec, Error, init, Object, RepositoryState, Remote, Buf}; +use {ResetType, Signature, Reference, References, Submodule, Blame, BlameOptions}; +use {Branches, BranchType, Index, Config, Oid, Blob, Branch, Commit, Tree}; +use {ObjectType, Tag, Note, Notes, StatusOptions, Statuses, Status, Revwalk}; +use {RevparseMode, RepositoryInitMode, Reflog, IntoCString}; +use build::{RepoBuilder, CheckoutBuilder}; +use string_array::StringArray; +use util::{self, Binding}; + +/// An owned git repository, representing all state associated with the +/// underlying filesystem. +/// +/// This structure corresponds to a `git_repository` in libgit2. Many other +/// types in git2-rs are derivative from this structure and are attached to its +/// lifetime. +/// +/// When a repository goes out of scope it is freed in memory but not deleted +/// from the filesystem. +pub struct Repository { + raw: *mut raw::git_repository, +} + +// It is the current belief that a `Repository` can be sent among threads, or +// even shared among threads in a mutex. +unsafe impl Send for Repository {} + +/// Options which can be used to configure how a repository is initialized +pub struct RepositoryInitOptions { + flags: u32, + mode: u32, + workdir_path: Option, + description: Option, + template_path: Option, + initial_head: Option, + origin_url: Option, +} + +impl Repository { + /// Attempt to open an already-existing repository at `path`. + /// + /// The path can point to either a normal or bare repository. + pub fn open>(path: P) -> Result { + init(); + let path = try!(path.as_ref().into_c_string()); + let mut ret = 0 as *mut raw::git_repository; + unsafe { + try_call!(raw::git_repository_open(&mut ret, path)); + Ok(Binding::from_raw(ret)) + } + } + + /// Attempt to open an already-existing repository at or above `path` + /// + /// This starts at `path` and looks up the filesystem hierarchy + /// until it finds a repository. + pub fn discover>(path: P) -> Result { + // TODO: this diverges significantly from the libgit2 API + init(); + let buf = Buf::new(); + let path = try!(path.as_ref().into_c_string()); + unsafe { + try_call!(raw::git_repository_discover(buf.raw(), path, 1, + 0 as *const _)); + } + Repository::open(util::bytes2path(&*buf)) + } + + /// Creates a new repository in the specified folder. + /// + /// This by default will create any necessary directories to create the + /// repository, and it will read any user-specified templates when creating + /// the repository. This behavior can be configured through `init_opts`. + pub fn init>(path: P) -> Result { + Repository::init_opts(path, &RepositoryInitOptions::new()) + } + + /// Creates a new `--bare` repository in the specified folder. + /// + /// The folder must exist prior to invoking this function. + pub fn init_bare>(path: P) -> Result { + Repository::init_opts(path, RepositoryInitOptions::new().bare(true)) + } + + /// Creates a new `--bare` repository in the specified folder. + /// + /// The folder must exist prior to invoking this function. + pub fn init_opts>(path: P, opts: &RepositoryInitOptions) + -> Result { + init(); + let path = try!(path.as_ref().into_c_string()); + let mut ret = 0 as *mut raw::git_repository; + unsafe { + let mut opts = opts.raw(); + try_call!(raw::git_repository_init_ext(&mut ret, path, &mut opts)); + Ok(Binding::from_raw(ret)) + } + } + + /// Clone a remote repository. + /// + /// See the `RepoBuilder` struct for more information. This function will + /// delegate to a fresh `RepoBuilder` + pub fn clone>(url: &str, into: P) + -> Result { + ::init(); + RepoBuilder::new().clone(url, into.as_ref()) + } + + /// Execute a rev-parse operation against the `spec` listed. + /// + /// The resulting revision specification is returned, or an error is + /// returned if one occurs. + pub fn revparse(&self, spec: &str) -> Result { + let mut raw = raw::git_revspec { + from: 0 as *mut _, + to: 0 as *mut _, + flags: 0, + }; + let spec = try!(CString::new(spec)); + unsafe { + try_call!(raw::git_revparse(&mut raw, self.raw, spec)); + let to = Binding::from_raw_opt(raw.to); + let from = Binding::from_raw_opt(raw.from); + let mode = RevparseMode::from_bits_truncate(raw.flags as u32); + Ok(Revspec::from_objects(from, to, mode)) + } + } + + /// Find a single object, as specified by a revision string. + pub fn revparse_single(&self, spec: &str) -> Result { + let spec = try!(CString::new(spec)); + let mut obj = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_revparse_single(&mut obj, self.raw, spec)); + assert!(!obj.is_null()); + Ok(Binding::from_raw(obj)) + } + } + + /// Find a single object and intermediate reference by a revision string. + /// + /// See `man gitrevisions`, or + /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + /// information on the syntax accepted. + /// + /// In some cases (`@{<-n>}` or `@{upstream}`), the expression + /// may point to an intermediate reference. When such expressions are being + /// passed in, this intermediate reference is returned. + pub fn revparse_ext(&self, spec: &str) + -> Result<(Object, Option), Error> { + let spec = try!(CString::new(spec)); + let mut git_obj = 0 as *mut raw::git_object; + let mut git_ref = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_revparse_ext(&mut git_obj, &mut git_ref, + self.raw, spec)); + assert!(!git_obj.is_null()); + Ok((Binding::from_raw(git_obj), Binding::from_raw_opt(git_ref))) + } + } + + /// Tests whether this repository is a bare repository or not. + pub fn is_bare(&self) -> bool { + unsafe { raw::git_repository_is_bare(self.raw) == 1 } + } + + /// Tests whether this repository is a shallow clone. + pub fn is_shallow(&self) -> bool { + unsafe { raw::git_repository_is_shallow(self.raw) == 1 } + } + + /// Tests whether this repository is empty. + pub fn is_empty(&self) -> Result { + let empty = unsafe { + try_call!(raw::git_repository_is_empty(self.raw)) + }; + Ok(empty == 1) + } + + /// Returns the path to the `.git` folder for normal repositories or the + /// repository itself for bare repositories. + pub fn path(&self) -> &Path { + unsafe { + let ptr = raw::git_repository_path(self.raw); + util::bytes2path(::opt_bytes(self, ptr).unwrap()) + } + } + + /// Returns the current state of this repository + pub fn state(&self) -> RepositoryState { + let state = unsafe { raw::git_repository_state(self.raw) }; + macro_rules! check( ($($raw:ident => $real:ident),*) => ( + $(if state == raw::$raw as c_int { + super::RepositoryState::$real + }) else * + else { + panic!("unknown repository state: {}", state) + } + ) ); + + check!( + GIT_REPOSITORY_STATE_NONE => Clean, + GIT_REPOSITORY_STATE_MERGE => Merge, + GIT_REPOSITORY_STATE_REVERT => Revert, + GIT_REPOSITORY_STATE_CHERRYPICK => CherryPick, + GIT_REPOSITORY_STATE_BISECT => Bisect, + GIT_REPOSITORY_STATE_REBASE => Rebase, + GIT_REPOSITORY_STATE_REBASE_INTERACTIVE => RebaseInteractive, + GIT_REPOSITORY_STATE_REBASE_MERGE => RebaseMerge, + GIT_REPOSITORY_STATE_APPLY_MAILBOX => ApplyMailbox, + GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE => ApplyMailboxOrRebase + ) + } + + /// Get the path of the working directory for this repository. + /// + /// If this repository is bare, then `None` is returned. + pub fn workdir(&self) -> Option<&Path> { + unsafe { + let ptr = raw::git_repository_workdir(self.raw); + if ptr.is_null() { + None + } else { + Some(util::bytes2path(CStr::from_ptr(ptr).to_bytes())) + } + } + } + + /// Get the currently active namespace for this repository. + /// + /// If there is no namespace, or the namespace is not a valid utf8 string, + /// `None` is returned. + pub fn namespace(&self) -> Option<&str> { + self.namespace_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the currently active namespace for this repository as a byte array. + /// + /// If there is no namespace, `None` is returned. + pub fn namespace_bytes(&self) -> Option<&[u8]> { + unsafe { ::opt_bytes(self, raw::git_repository_get_namespace(self.raw)) } + } + + /// List all remotes for a given repository + pub fn remotes(&self) -> Result { + let mut arr = raw::git_strarray { + strings: 0 as *mut *mut c_char, + count: 0, + }; + unsafe { + try_call!(raw::git_remote_list(&mut arr, self.raw)); + Ok(Binding::from_raw(arr)) + } + } + + /// Get the information for a particular remote + pub fn find_remote(&self, name: &str) -> Result { + let mut ret = 0 as *mut raw::git_remote; + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_remote_lookup(&mut ret, self.raw, name)); + Ok(Binding::from_raw(ret)) + } + } + + /// Add a remote with the default fetch refspec to the repository's + /// configuration. + pub fn remote(&self, name: &str, url: &str) -> Result { + let mut ret = 0 as *mut raw::git_remote; + let name = try!(CString::new(name)); + let url = try!(CString::new(url)); + unsafe { + try_call!(raw::git_remote_create(&mut ret, self.raw, name, url)); + Ok(Binding::from_raw(ret)) + } + } + + /// Create an anonymous remote + /// + /// Create a remote with the given url and refspec in memory. You can use + /// this when you have a URL instead of a remote's name. Note that anonymous + /// remotes cannot be converted to persisted remotes. + pub fn remote_anonymous(&self, + url: &str, + fetch: Option<&str>) -> Result { + let mut ret = 0 as *mut raw::git_remote; + let url = try!(CString::new(url)); + let fetch = match fetch { + Some(t) => Some(try!(CString::new(t))), + None => None, + }; + unsafe { + try_call!(raw::git_remote_create_anonymous(&mut ret, self.raw, url, + fetch)); + Ok(Binding::from_raw(ret)) + } + } + + /// Give a remote a new name + /// + /// All remote-tracking branches and configuration settings for the remote + /// are updated. + /// + /// A temporary in-memory remote cannot be given a name with this method. + /// + /// No loaded instances of the remote with the old name will change their + /// name or their list of refspecs. + /// + /// The returned array of strings is a list of the non-default refspecs + /// which cannot be renamed and are returned for further processing by the + /// caller. + pub fn remote_rename(&self, name: &str, + new_name: &str) -> Result { + let name = try!(CString::new(name)); + let new_name = try!(CString::new(new_name)); + let mut problems = raw::git_strarray { + count: 0, + strings: 0 as *mut *mut c_char, + }; + unsafe { + try_call!(raw::git_remote_rename(&mut problems, self.raw, name, + new_name)); + Ok(Binding::from_raw(problems)) + } + } + + /// Delete an existing persisted remote. + /// + /// All remote-tracking branches and configuration settings for the remote + /// will be removed. + pub fn remote_delete(&self, name: &str) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { try_call!(raw::git_remote_delete(self.raw, name)); } + Ok(()) + } + + /// Sets the current head to the specified object and optionally resets + /// the index and working tree to match. + /// + /// A soft reset means the head will be moved to the commit. + /// + /// A mixed reset will trigger a soft reset, plus the index will be + /// replaced with the content of the commit tree. + /// + /// A hard reset will trigger a mixed reset and the working directory will + /// be replaced with the content of the index. (Untracked and ignored files + /// will be left alone, however.) + /// + /// The `target` is a commit-ish to which the head should be moved to. The + /// object can either be a commit or a tag, but tags must be derefernceable + /// to a commit. + /// + /// The `checkout` options will only be used for a hard reset. + pub fn reset(&self, + target: &Object, + kind: ResetType, + checkout: Option<&mut CheckoutBuilder>) + -> Result<(), Error> { + unsafe { + let mut opts: raw::git_checkout_options = mem::zeroed(); + let opts = checkout.map(|c| { + c.configure(&mut opts); &mut opts + }); + try_call!(raw::git_reset(self.raw, target.raw(), kind, opts)); + } + Ok(()) + } + + /// Updates some entries in the index from the target commit tree. + /// + /// The scope of the updated entries is determined by the paths being + /// in the iterator provided. + /// + /// Passing a `None` target will result in removing entries in the index + /// matching the provided pathspecs. + pub fn reset_default(&self, + target: Option<&Object>, + paths: I) -> Result<(), Error> + where T: IntoCString, I: IntoIterator, + { + let (_a, _b, mut arr) = try!(::util::iter2cstrs(paths)); + let target = target.map(|t| t.raw()); + unsafe { + try_call!(raw::git_reset_default(self.raw, target, &mut arr)); + } + Ok(()) + } + + /// Retrieve and resolve the reference pointed at by HEAD. + pub fn head(&self) -> Result { + let mut ret = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_repository_head(&mut ret, self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Make the repository HEAD point to the specified reference. + /// + /// If the provided reference points to a tree or a blob, the HEAD is + /// unaltered and an error is returned. + /// + /// If the provided reference points to a branch, the HEAD will point to + /// that branch, staying attached, or become attached if it isn't yet. If + /// the branch doesn't exist yet, no error will be returned. The HEAD will + /// then be attached to an unborn branch. + /// + /// Otherwise, the HEAD will be detached and will directly point to the + /// commit. + pub fn set_head(&self, refname: &str) -> Result<(), Error> { + let refname = try!(CString::new(refname)); + unsafe { + try_call!(raw::git_repository_set_head(self.raw, refname)); + } + Ok(()) + } + + /// Make the repository HEAD directly point to the commit. + /// + /// If the provided committish cannot be found in the repository, the HEAD + /// is unaltered and an error is returned. + /// + /// If the provided commitish cannot be peeled into a commit, the HEAD is + /// unaltered and an error is returned. + /// + /// Otherwise, the HEAD will eventually be detached and will directly point + /// to the peeled commit. + pub fn set_head_detached(&self, commitish: Oid) -> Result<(), Error> { + unsafe { + try_call!(raw::git_repository_set_head_detached(self.raw, + commitish.raw())); + } + Ok(()) + } + + /// Create an iterator for the repo's references + pub fn references(&self) -> Result { + let mut ret = 0 as *mut raw::git_reference_iterator; + unsafe { + try_call!(raw::git_reference_iterator_new(&mut ret, self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Create an iterator for the repo's references that match the specified + /// glob + pub fn references_glob(&self, glob: &str) -> Result { + let mut ret = 0 as *mut raw::git_reference_iterator; + let glob = try!(CString::new(glob)); + unsafe { + try_call!(raw::git_reference_iterator_glob_new(&mut ret, self.raw, + glob)); + + Ok(Binding::from_raw(ret)) + } + } + + /// Load all submodules for this repository and return them. + pub fn submodules(&self) -> Result, Error> { + struct Data<'a, 'b:'a> { + repo: &'b Repository, + ret: &'a mut Vec>, + } + let mut ret = Vec::new(); + + unsafe { + let mut data = Data { + repo: self, + ret: &mut ret, + }; + try_call!(raw::git_submodule_foreach(self.raw, append, + &mut data as *mut _ + as *mut c_void)); + } + + return Ok(ret); + + extern fn append(_repo: *mut raw::git_submodule, + name: *const c_char, + data: *mut c_void) -> c_int { + unsafe { + let data = &mut *(data as *mut Data); + let mut raw = 0 as *mut raw::git_submodule; + let rc = raw::git_submodule_lookup(&mut raw, data.repo.raw(), + name); + assert_eq!(rc, 0); + data.ret.push(Binding::from_raw(raw)); + } + 0 + } + } + + /// Gather file status information and populate the returned structure. + /// + /// Note that if a pathspec is given in the options to filter the + /// status, then the results from rename detection (if you enable it) may + /// not be accurate. To do rename detection properly, this must be called + /// with no pathspec so that all files can be considered. + pub fn statuses(&self, options: Option<&mut StatusOptions>) + -> Result { + let mut ret = 0 as *mut raw::git_status_list; + unsafe { + try_call!(raw::git_status_list_new(&mut ret, self.raw, + options.map(|s| s.raw()) + .unwrap_or(0 as *const _))); + Ok(Binding::from_raw(ret)) + } + } + + /// Test if the ignore rules apply to a given file. + /// + /// This function checks the ignore rules to see if they would apply to the + /// given file. This indicates if the file would be ignored regardless of + /// whether the file is already in the index or committed to the repository. + /// + /// One way to think of this is if you were to do "git add ." on the + /// directory containing the file, would it be added or not? + pub fn status_should_ignore(&self, path: &Path) -> Result { + let mut ret = 0 as c_int; + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_status_should_ignore(&mut ret, self.raw, + path)); + } + Ok(ret != 0) + } + + /// Get file status for a single file. + /// + /// This tries to get status for the filename that you give. If no files + /// match that name (in either the HEAD, index, or working directory), this + /// returns NotFound. + /// + /// If the name matches multiple files (for example, if the path names a + /// directory or if running on a case- insensitive filesystem and yet the + /// HEAD has two entries that both match the path), then this returns + /// Ambiguous because it cannot give correct results. + /// + /// This does not do any sort of rename detection. Renames require a set of + /// targets and because of the path filtering, there is not enough + /// information to check renames correctly. To check file status with rename + /// detection, there is no choice but to do a full `statuses` and scan + /// through looking for the path that you are interested in. + pub fn status_file(&self, path: &Path) -> Result { + let mut ret = 0 as c_uint; + let path = try!(path.into_c_string()); + unsafe { + try_call!(raw::git_status_file(&mut ret, self.raw, + path)); + } + Ok(Status::from_bits_truncate(ret as u32)) + } + + /// Create an iterator which loops over the requested branches. + pub fn branches(&self, filter: Option) + -> Result { + let mut raw = 0 as *mut raw::git_branch_iterator; + unsafe { + try_call!(raw::git_branch_iterator_new(&mut raw, self.raw(), filter)); + Ok(Branches::from_raw(raw)) + } + } + + /// Get the Index file for this repository. + /// + /// If a custom index has not been set, the default index for the repository + /// will be returned (the one located in .git/index). + pub fn index(&self) -> Result { + let mut raw = 0 as *mut raw::git_index; + unsafe { + try_call!(raw::git_repository_index(&mut raw, self.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Get the configuration file for this repository. + /// + /// If a configuration file has not been set, the default config set for the + /// repository will be returned, including global and system configurations + /// (if they are available). + pub fn config(&self) -> Result { + let mut raw = 0 as *mut raw::git_config; + unsafe { + try_call!(raw::git_repository_config(&mut raw, self.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Write an in-memory buffer to the ODB as a blob. + /// + /// The Oid returned can in turn be passed to `find_blob` to get a handle to + /// the blob. + pub fn blob(&self, data: &[u8]) -> Result { + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + let ptr = data.as_ptr() as *const c_void; + let len = data.len() as size_t; + try_call!(raw::git_blob_create_frombuffer(&mut raw, self.raw(), + ptr, len)); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Read a file from the filesystem and write its content to the Object + /// Database as a loose blob + /// + /// The Oid returned can in turn be passed to `find_blob` to get a handle to + /// the blob. + pub fn blob_path(&self, path: &Path) -> Result { + let path = try!(path.into_c_string()); + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_blob_create_fromdisk(&mut raw, self.raw(), + path)); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Lookup a reference to one of the objects in a repository. + pub fn find_blob(&self, oid: Oid) -> Result { + let mut raw = 0 as *mut raw::git_blob; + unsafe { + try_call!(raw::git_blob_lookup(&mut raw, self.raw(), oid.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Create a new branch pointing at a target commit + /// + /// A new direct reference will be created pointing to this target commit. + /// If `force` is true and a reference already exists with the given name, + /// it'll be replaced. + pub fn branch(&self, + branch_name: &str, + target: &Commit, + force: bool) -> Result { + let branch_name = try!(CString::new(branch_name)); + let mut raw = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_branch_create(&mut raw, + self.raw(), + branch_name, + target.raw(), + force)); + Ok(Branch::wrap(Binding::from_raw(raw))) + } + } + + /// Lookup a branch by its name in a repository. + pub fn find_branch(&self, name: &str, branch_type: BranchType) + -> Result { + let name = try!(CString::new(name)); + let mut ret = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_branch_lookup(&mut ret, self.raw(), name, + branch_type)); + Ok(Branch::wrap(Binding::from_raw(ret))) + } + } + + /// Create new commit in the repository + /// + /// If the `update_ref` is not `None`, name of the reference that will be + /// updated to point to this commit. If the reference is not direct, it will + /// be resolved to a direct reference. Use "HEAD" to update the HEAD of the + /// current branch and make it point to this commit. If the reference + /// doesn't exist yet, it will be created. If it does exist, the first + /// parent must be the tip of this branch. + pub fn commit(&self, + update_ref: Option<&str>, + author: &Signature, + committer: &Signature, + message: &str, + tree: &Tree, + parents: &[&Commit]) -> Result { + let update_ref = try!(::opt_cstr(update_ref)); + let parent_ptrs: Vec<*const raw::git_commit> = parents.iter().map(|p| { + p.raw() as *const raw::git_commit + }).collect(); + let message = try!(CString::new(message)); + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_commit_create(&mut raw, + self.raw(), + update_ref, + author.raw(), + committer.raw(), + 0 as *const c_char, + message, + tree.raw(), + parents.len() as size_t, + parent_ptrs.as_ptr())); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + + /// Lookup a reference to one of the commits in a repository. + pub fn find_commit(&self, oid: Oid) -> Result { + let mut raw = 0 as *mut raw::git_commit; + unsafe { + try_call!(raw::git_commit_lookup(&mut raw, self.raw(), oid.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Lookup a reference to one of the objects in a repository. + pub fn find_object(&self, oid: Oid, + kind: Option) -> Result { + let mut raw = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_object_lookup(&mut raw, self.raw(), oid.raw(), + kind)); + Ok(Binding::from_raw(raw)) + } + } + + /// Create a new direct reference. + /// + /// This function will return an error if a reference already exists with + /// the given name unless force is true, in which case it will be + /// overwritten. + pub fn reference(&self, name: &str, id: Oid, force: bool, + log_message: &str) -> Result { + let name = try!(CString::new(name)); + let log_message = try!(CString::new(log_message)); + let mut raw = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_reference_create(&mut raw, self.raw(), name, + id.raw(), force, + log_message)); + Ok(Binding::from_raw(raw)) + } + } + + /// Create a new symbolic reference. + /// + /// This function will return an error if a reference already exists with + /// the given name unless force is true, in which case it will be + /// overwritten. + pub fn reference_symbolic(&self, name: &str, target: &str, + force: bool, + log_message: &str) + -> Result { + let name = try!(CString::new(name)); + let target = try!(CString::new(target)); + let log_message = try!(CString::new(log_message)); + let mut raw = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_reference_symbolic_create(&mut raw, self.raw(), + name, target, force, + log_message)); + Ok(Binding::from_raw(raw)) + } + } + + /// Lookup a reference to one of the objects in a repository. + pub fn find_reference(&self, name: &str) -> Result { + let name = try!(CString::new(name)); + let mut raw = 0 as *mut raw::git_reference; + unsafe { + try_call!(raw::git_reference_lookup(&mut raw, self.raw(), name)); + Ok(Binding::from_raw(raw)) + } + } + + /// Lookup a reference by name and resolve immediately to OID. + /// + /// This function provides a quick way to resolve a reference name straight + /// through to the object id that it refers to. This avoids having to + /// allocate or free any `Reference` objects for simple situations. + pub fn refname_to_id(&self, name: &str) -> Result { + let name = try!(CString::new(name)); + let mut ret = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_reference_name_to_id(&mut ret, self.raw(), name)); + Ok(Binding::from_raw(&ret as *const _)) + } + } + + /// Create a new action signature with default user and now timestamp. + /// + /// This looks up the user.name and user.email from the configuration and + /// uses the current time as the timestamp, and creates a new signature + /// based on that information. It will return `NotFound` if either the + /// user.name or user.email are not set. + pub fn signature(&self) -> Result, Error> { + let mut ret = 0 as *mut raw::git_signature; + unsafe { + try_call!(raw::git_signature_default(&mut ret, self.raw())); + Ok(Binding::from_raw(ret)) + } + } + + /// Set up a new git submodule for checkout. + /// + /// This does "git submodule add" up to the fetch and checkout of the + /// submodule contents. It preps a new submodule, creates an entry in + /// `.gitmodules` and creates an empty initialized repository either at the + /// given path in the working directory or in `.git/modules` with a gitlink + /// from the working directory to the new repo. + /// + /// To fully emulate "git submodule add" call this function, then `open()` + /// the submodule repo and perform the clone step as needed. Lastly, call + /// `finalize()` to wrap up adding the new submodule and `.gitmodules` to + /// the index to be ready to commit. + pub fn submodule(&self, url: &str, path: &Path, + use_gitlink: bool) -> Result { + let url = try!(CString::new(url)); + let path = try!(path.into_c_string()); + let mut raw = 0 as *mut raw::git_submodule; + unsafe { + try_call!(raw::git_submodule_add_setup(&mut raw, self.raw(), + url, path, use_gitlink)); + Ok(Binding::from_raw(raw)) + } + } + + /// Lookup submodule information by name or path. + /// + /// Given either the submodule name or path (they are usually the same), + /// this returns a structure describing the submodule. + pub fn find_submodule(&self, name: &str) -> Result { + let name = try!(CString::new(name)); + let mut raw = 0 as *mut raw::git_submodule; + unsafe { + try_call!(raw::git_submodule_lookup(&mut raw, self.raw(), name)); + Ok(Binding::from_raw(raw)) + } + } + + /// Lookup a reference to one of the objects in a repository. + pub fn find_tree(&self, oid: Oid) -> Result { + let mut raw = 0 as *mut raw::git_tree; + unsafe { + try_call!(raw::git_tree_lookup(&mut raw, self.raw(), oid.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Create a new tag in the repository from an object + /// + /// A new reference will also be created pointing to this tag object. If + /// `force` is true and a reference already exists with the given name, + /// it'll be replaced. + /// + /// The message will not be cleaned up. + /// + /// The tag name will be checked for validity. You must avoid the characters + /// '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @ + /// {" which have special meaning to revparse. + pub fn tag(&self, name: &str, target: &Object, + tagger: &Signature, message: &str, + force: bool) -> Result { + let name = try!(CString::new(name)); + let message = try!(CString::new(message)); + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_tag_create(&mut raw, self.raw, name, + target.raw(), tagger.raw(), + message, force)); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Create a new lightweight tag pointing at a target object + /// + /// A new direct reference will be created pointing to this target object. + /// If force is true and a reference already exists with the given name, + /// it'll be replaced. + pub fn tag_lightweight(&self, + name: &str, + target: &Object, + force: bool) -> Result { + let name = try!(CString::new(name)); + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_tag_create_lightweight(&mut raw, self.raw, name, + target.raw(), force)); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Lookup a tag object from the repository. + pub fn find_tag(&self, id: Oid) -> Result { + let mut raw = 0 as *mut raw::git_tag; + unsafe { + try_call!(raw::git_tag_lookup(&mut raw, self.raw, id.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Delete an existing tag reference. + /// + /// The tag name will be checked for validity, see `tag` for some rules + /// about valid names. + pub fn tag_delete(&self, name: &str) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { + try_call!(raw::git_tag_delete(self.raw, name)); + Ok(()) + } + } + + /// Get a list with all the tags in the repository. + /// + /// An optional fnmatch pattern can also be specified. + pub fn tag_names(&self, pattern: Option<&str>) -> Result { + let mut arr = raw::git_strarray { + strings: 0 as *mut *mut c_char, + count: 0, + }; + unsafe { + match pattern { + Some(s) => { + let s = try!(CString::new(s)); + try_call!(raw::git_tag_list_match(&mut arr, s, self.raw)); + } + None => { try_call!(raw::git_tag_list(&mut arr, self.raw)); } + } + Ok(Binding::from_raw(arr)) + } + } + + /// Updates files in the index and the working tree to match the content of + /// the commit pointed at by HEAD. + pub fn checkout_head(&self, opts: Option<&mut CheckoutBuilder>) + -> Result<(), Error> { + unsafe { + let mut raw_opts = mem::zeroed(); + try_call!(raw::git_checkout_init_options(&mut raw_opts, + raw::GIT_CHECKOUT_OPTIONS_VERSION)); + match opts { + Some(c) => c.configure(&mut raw_opts), + None => {} + } + + try_call!(raw::git_checkout_head(self.raw, &raw_opts)); + } + Ok(()) + } + + /// Updates files in the working tree to match the content of the index. + /// + /// If the index is `None`, the repository's index will be used. + pub fn checkout_index(&self, + index: Option<&mut Index>, + opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { + unsafe { + let mut raw_opts = mem::zeroed(); + try_call!(raw::git_checkout_init_options(&mut raw_opts, + raw::GIT_CHECKOUT_OPTIONS_VERSION)); + match opts { + Some(c) => c.configure(&mut raw_opts), + None => {} + } + + try_call!(raw::git_checkout_index(self.raw, + index.map(|i| &mut *i.raw()), + &raw_opts)); + } + Ok(()) + } + + /// Updates files in the index and working tree to match the content of the + /// tree pointed at by the treeish. + pub fn checkout_tree(&self, + treeish: &Object, + opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { + unsafe { + let mut raw_opts = mem::zeroed(); + try_call!(raw::git_checkout_init_options(&mut raw_opts, + raw::GIT_CHECKOUT_OPTIONS_VERSION)); + match opts { + Some(c) => c.configure(&mut raw_opts), + None => {} + } + + try_call!(raw::git_checkout_tree(self.raw, &*treeish.raw(), + &raw_opts)); + } + Ok(()) + } + + /// Add a note for an object + /// + /// The `notes_ref` argument is the canonical name of the reference to use, + /// defaulting to "refs/notes/commits". If `force` is specified then + /// previous notes are overwritten. + pub fn note(&self, + author: &Signature, + committer: &Signature, + notes_ref: Option<&str>, + oid: Oid, + note: &str, + force: bool) -> Result { + let notes_ref = try!(::opt_cstr(notes_ref)); + let note = try!(CString::new(note)); + let mut ret = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_note_create(&mut ret, + self.raw, + notes_ref, + author.raw(), + committer.raw(), + oid.raw(), + note, + force)); + Ok(Binding::from_raw(&ret as *const _)) + } + } + + /// Get the default notes reference for this repository + pub fn note_default_ref(&self) -> Result { + let ret = Buf::new(); + unsafe { + try_call!(raw::git_note_default_ref(ret.raw(), self.raw)); + } + Ok(str::from_utf8(&ret).unwrap().to_string()) + } + + /// Creates a new iterator for notes in this repository. + /// + /// The `notes_ref` argument is the canonical name of the reference to use, + /// defaulting to "refs/notes/commits". + /// + /// The iterator returned yields pairs of (Oid, Oid) where the first element + /// is the id of the note and the second id is the id the note is + /// annotating. + pub fn notes(&self, notes_ref: Option<&str>) -> Result { + let notes_ref = try!(::opt_cstr(notes_ref)); + let mut ret = 0 as *mut raw::git_note_iterator; + unsafe { + try_call!(raw::git_note_iterator_new(&mut ret, self.raw, notes_ref)); + Ok(Binding::from_raw(ret)) + } + } + + /// Read the note for an object. + /// + /// The `notes_ref` argument is the canonical name of the reference to use, + /// defaulting to "refs/notes/commits". + /// + /// The id specified is the Oid of the git object to read the note from. + pub fn find_note(&self, notes_ref: Option<&str>, id: Oid) + -> Result { + let notes_ref = try!(::opt_cstr(notes_ref)); + let mut ret = 0 as *mut raw::git_note; + unsafe { + try_call!(raw::git_note_read(&mut ret, self.raw, notes_ref, + id.raw())); + Ok(Binding::from_raw(ret)) + } + } + + /// Remove the note for an object. + /// + /// The `notes_ref` argument is the canonical name of the reference to use, + /// defaulting to "refs/notes/commits". + /// + /// The id specified is the Oid of the git object to remove the note from. + pub fn note_delete(&self, + id: Oid, + notes_ref: Option<&str>, + author: &Signature, + committer: &Signature) -> Result<(), Error> { + let notes_ref = try!(::opt_cstr(notes_ref)); + unsafe { + try_call!(raw::git_note_remove(self.raw, notes_ref, author.raw(), + committer.raw(), id.raw())); + Ok(()) + } + } + + /// Create a revwalk that can be used to traverse the commit graph. + pub fn revwalk(&self) -> Result { + let mut raw = 0 as *mut raw::git_revwalk; + unsafe { + try_call!(raw::git_revwalk_new(&mut raw, self.raw())); + Ok(Binding::from_raw(raw)) + } + } + + /// Get the blame for a single file. + pub fn blame_file(&self, path: &Path, opts: Option<&mut BlameOptions>) + -> Result { + let path = try!(path.into_c_string()); + let mut raw = 0 as *mut raw::git_blame; + + unsafe { + try_call!(raw::git_blame_file(&mut raw, + self.raw(), + path, + opts.map(|s| s.raw()))); + Ok(Binding::from_raw(raw)) + } + } + + /// Find a merge base between two commits + pub fn merge_base(&self, one: Oid, two: Oid) -> Result { + let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + try_call!(raw::git_merge_base(&mut raw, self.raw, + one.raw(), two.raw())); + Ok(Binding::from_raw(&raw as *const _)) + } + } + + /// Count the number of unique commits between two commit objects + /// + /// There is no need for branches containing the commits to have any + /// upstream relationship, but it helps to think of one as a branch and the + /// other as its upstream, the ahead and behind values will be what git + /// would report for the branches. + pub fn graph_ahead_behind(&self, local: Oid, upstream: Oid) + -> Result<(usize, usize), Error> { + unsafe { + let mut ahead: size_t = 0; + let mut behind: size_t = 0; + try_call!(raw::git_graph_ahead_behind(&mut ahead, &mut behind, + self.raw(), local.raw(), + upstream.raw())); + Ok((ahead as usize, behind as usize)) + } + } + + /// Determine if a commit is the descendant of another commit + pub fn graph_descendant_of(&self, commit: Oid, ancestor: Oid) + -> Result { + unsafe { + let rv = try_call!(raw::git_graph_descendant_of(self.raw(), + commit.raw(), + ancestor.raw())); + Ok(rv != 0) + } + } + + /// Read the reflog for the given reference + /// + /// If there is no reflog file for the given reference yet, an empty reflog + /// object will be returned. + pub fn reflog(&self, name: &str) -> Result { + let name = try!(CString::new(name)); + let mut ret = 0 as *mut raw::git_reflog; + unsafe { + try_call!(raw::git_reflog_read(&mut ret, self.raw, name)); + Ok(Binding::from_raw(ret)) + } + } + + /// Delete the reflog for the given reference + pub fn reflog_delete(&self, name: &str) -> Result<(), Error> { + let name = try!(CString::new(name)); + unsafe { try_call!(raw::git_reflog_delete(self.raw, name)); } + Ok(()) + } + + /// Rename a reflog + /// + /// The reflog to be renamed is expected to already exist. + pub fn reflog_rename(&self, old_name: &str, new_name: &str) + -> Result<(), Error> { + let old_name = try!(CString::new(old_name)); + let new_name = try!(CString::new(new_name)); + unsafe { + try_call!(raw::git_reflog_rename(self.raw, old_name, new_name)); + } + Ok(()) + } +} + +impl Binding for Repository { + type Raw = *mut raw::git_repository; + unsafe fn from_raw(ptr: *mut raw::git_repository) -> Repository { + Repository { raw: ptr } + } + fn raw(&self) -> *mut raw::git_repository { self.raw } +} + +impl Drop for Repository { + fn drop(&mut self) { + unsafe { raw::git_repository_free(self.raw) } + } +} + +impl RepositoryInitOptions { + /// Creates a default set of initialization options. + /// + /// By default this will set flags for creating all necessary directories + /// and initializing a directory from the user-configured templates path. + pub fn new() -> RepositoryInitOptions { + RepositoryInitOptions { + flags: raw::GIT_REPOSITORY_INIT_MKDIR as u32 | + raw::GIT_REPOSITORY_INIT_MKPATH as u32 | + raw::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE as u32, + mode: 0, + workdir_path: None, + description: None, + template_path: None, + initial_head: None, + origin_url: None, + } + } + + /// Create a bare repository with no working directory. + /// + /// Defaults to false. + pub fn bare(&mut self, bare: bool) -> &mut RepositoryInitOptions { + self.flag(raw::GIT_REPOSITORY_INIT_BARE, bare) + } + + /// Return an error if the repository path appears to already be a git + /// repository. + /// + /// Defaults to false. + pub fn no_reinit(&mut self, enabled: bool) -> &mut RepositoryInitOptions { + self.flag(raw::GIT_REPOSITORY_INIT_NO_REINIT, enabled) + } + + /// Normally a '/.git/' will be appended to the repo apth for non-bare repos + /// (if it is not already there), but passing this flag prevents that + /// behavior. + /// + /// Defaults to false. + pub fn no_dotgit_dir(&mut self, enabled: bool) -> &mut RepositoryInitOptions { + self.flag(raw::GIT_REPOSITORY_INIT_NO_DOTGIT_DIR, enabled) + } + + /// Make the repo path (and workdir path) as needed. The ".git" directory + /// will always be created regardless of this flag. + /// + /// Defaults to true. + pub fn mkdir(&mut self, enabled: bool) -> &mut RepositoryInitOptions { + self.flag(raw::GIT_REPOSITORY_INIT_MKDIR, enabled) + } + + /// Recursively make all components of the repo and workdir path sas + /// necessary. + /// + /// Defaults to true. + pub fn mkpath(&mut self, enabled: bool) -> &mut RepositoryInitOptions { + self.flag(raw::GIT_REPOSITORY_INIT_MKPATH, enabled) + } + + /// Set to one of the `RepositoryInit` constants, or a custom value. + pub fn mode(&mut self, mode: RepositoryInitMode) + -> &mut RepositoryInitOptions { + self.mode = mode.bits(); + self + } + + /// Enable or disable using external templates. + /// + /// If enabled, then the `template_path` option will be queried first, then + /// `init.templatedir` from the global config, and finally + /// `/usr/share/git-core-templates` will be used (if it exists). + /// + /// Defaults to true. + pub fn external_template(&mut self, enabled: bool) + -> &mut RepositoryInitOptions { + self.flag(raw::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE, enabled) + } + + fn flag(&mut self, flag: raw::git_repository_init_flag_t, on: bool) + -> &mut RepositoryInitOptions { + if on { + self.flags |= flag as u32; + } else { + self.flags &= !(flag as u32); + } + self + } + + /// The path do the working directory. + /// + /// If this is a relative path it will be evaulated relative to the repo + /// path. If this is not the "natural" working directory, a .git gitlink + /// file will be created here linking to the repo path. + pub fn workdir_path(&mut self, path: &Path) -> &mut RepositoryInitOptions { + self.workdir_path = Some(path.into_c_string().unwrap()); + self + } + + /// If set, this will be used to initialize the "description" file in the + /// repository instead of using the template content. + pub fn description(&mut self, desc: &str) -> &mut RepositoryInitOptions { + self.description = Some(CString::new(desc).unwrap()); + self + } + + /// When the `external_template` option is set, this is the first location + /// to check for the template directory. + /// + /// If this is not configured, then the default locations will be searched + /// instead. + pub fn template_path(&mut self, path: &Path) -> &mut RepositoryInitOptions { + self.template_path = Some(path.into_c_string().unwrap()); + self + } + + /// The name of the head to point HEAD at. + /// + /// If not configured, this will be treated as `master` and the HEAD ref + /// will be set to `refs/heads/master`. If this begins with `refs/` it will + /// be used verbatim; otherwise `refs/heads/` will be prefixed + pub fn initial_head(&mut self, head: &str) -> &mut RepositoryInitOptions { + self.initial_head = Some(CString::new(head).unwrap()); + self + } + + /// If set, then after the rest of the repository initialization is + /// completed an `origin` remote will be added pointing to this URL. + pub fn origin_url(&mut self, url: &str) -> &mut RepositoryInitOptions { + self.origin_url = Some(CString::new(url).unwrap()); + self + } + + /// Creates a set of raw init options to be used with + /// `git_repository_init_ext`. + /// + /// This method is unsafe as the returned value may have pointers to the + /// interior of this structure. + pub unsafe fn raw(&self) -> raw::git_repository_init_options { + let mut opts = mem::zeroed(); + assert_eq!(raw::git_repository_init_init_options(&mut opts, + raw::GIT_REPOSITORY_INIT_OPTIONS_VERSION), 0); + opts.flags = self.flags; + opts.mode = self.mode; + opts.workdir_path = ::call::convert(&self.workdir_path); + opts.description = ::call::convert(&self.description); + opts.template_path = ::call::convert(&self.template_path); + opts.initial_head = ::call::convert(&self.initial_head); + opts.origin_url = ::call::convert(&self.origin_url); + return opts; + } +} + +#[cfg(test)] +mod tests { + use std::fs; + use tempdir::TempDir; + use {Repository, Oid, ObjectType, ResetType}; + use build::CheckoutBuilder; + + #[test] + fn smoke_init() { + let td = TempDir::new("test").unwrap(); + let path = td.path(); + + let repo = Repository::init(path).unwrap(); + assert!(!repo.is_bare()); + } + + #[test] + fn smoke_init_bare() { + let td = TempDir::new("test").unwrap(); + let path = td.path(); + + let repo = Repository::init_bare(path).unwrap(); + assert!(repo.is_bare()); + assert!(repo.namespace().is_none()); + } + + #[test] + fn smoke_open() { + let td = TempDir::new("test").unwrap(); + let path = td.path(); + Repository::init(td.path()).unwrap(); + let repo = Repository::open(path).unwrap(); + assert!(!repo.is_bare()); + assert!(!repo.is_shallow()); + assert!(repo.is_empty().unwrap()); + assert_eq!(::test::realpath(&repo.path()).unwrap(), + ::test::realpath(&td.path().join(".git/")).unwrap()); + assert_eq!(repo.state(), ::RepositoryState::Clean); + } + + #[test] + fn smoke_open_bare() { + let td = TempDir::new("test").unwrap(); + let path = td.path(); + Repository::init_bare(td.path()).unwrap(); + + let repo = Repository::open(path).unwrap(); + assert!(repo.is_bare()); + assert_eq!(::test::realpath(&repo.path()).unwrap(), + ::test::realpath(&td.path().join("")).unwrap()); + } + + #[test] + fn smoke_checkout() { + let (_td, repo) = ::test::repo_init(); + repo.checkout_head(None).unwrap(); + } + + #[test] + fn smoke_revparse() { + let (_td, repo) = ::test::repo_init(); + let rev = repo.revparse("HEAD").unwrap(); + assert!(rev.to().is_none()); + let from = rev.from().unwrap(); + assert!(rev.from().is_some()); + + assert_eq!(repo.revparse_single("HEAD").unwrap().id(), from.id()); + let obj = repo.find_object(from.id(), None).unwrap().clone(); + obj.peel(ObjectType::Any).unwrap(); + obj.short_id().unwrap(); + repo.reset(&obj, ResetType::Hard, None).unwrap(); + let mut opts = CheckoutBuilder::new(); + t!(repo.reset(&obj, ResetType::Soft, Some(&mut opts))); + } + + #[test] + fn makes_dirs() { + let td = TempDir::new("foo").unwrap(); + Repository::init(&td.path().join("a/b/c/d")).unwrap(); + } + + #[test] + fn smoke_discover() { + let td = TempDir::new("test").unwrap(); + let subdir = td.path().join("subdi"); + fs::create_dir(&subdir).unwrap(); + Repository::init_bare(td.path()).unwrap(); + let repo = Repository::discover(&subdir).unwrap(); + assert_eq!(::test::realpath(&repo.path()).unwrap(), + ::test::realpath(&td.path().join("")).unwrap()); + } + + fn graph_repo_init() -> (TempDir, Repository) { + let (_td, repo) = ::test::repo_init(); + { + let head = repo.head().unwrap().target().unwrap(); + let head = repo.find_commit(head).unwrap(); + + let mut index = repo.index().unwrap(); + let id = index.write_tree().unwrap(); + + let tree = repo.find_tree(id).unwrap(); + let sig = repo.signature().unwrap(); + repo.commit(Some("HEAD"), &sig, &sig, "second", + &tree, &[&head]).unwrap(); + } + (_td, repo) + } + + #[test] + fn smoke_graph_ahead_behind() { + let (_td, repo) = graph_repo_init(); + let head = repo.head().unwrap().target().unwrap(); + let head = repo.find_commit(head).unwrap(); + let head_id = head.id(); + let head_parent_id = head.parent(0).unwrap().id(); + let (ahead, behind) = repo.graph_ahead_behind(head_id, + head_parent_id).unwrap(); + assert_eq!(ahead, 1); + assert_eq!(behind, 0); + let (ahead, behind) = repo.graph_ahead_behind(head_parent_id, + head_id).unwrap(); + assert_eq!(ahead, 0); + assert_eq!(behind, 1); + } + + #[test] + fn smoke_graph_descendant_of() { + let (_td, repo) = graph_repo_init(); + let head = repo.head().unwrap().target().unwrap(); + let head = repo.find_commit(head).unwrap(); + let head_id = head.id(); + let head_parent_id = head.parent(0).unwrap().id(); + assert!(repo.graph_descendant_of(head_id, head_parent_id).unwrap()); + assert!(!repo.graph_descendant_of(head_parent_id, head_id).unwrap()); + } + + #[test] + fn smoke_set_head() { + let (_td, repo) = ::test::repo_init(); + + assert!(repo.set_head("refs/heads/does-not-exist").is_ok()); + assert!(repo.head().is_err()); + + assert!(repo.set_head("refs/heads/master").is_ok()); + assert!(repo.head().is_ok()); + + assert!(repo.set_head("*").is_err()); + } + + #[test] + fn smoke_set_head_detached() { + let (_td, repo) = ::test::repo_init(); + + let void_oid = Oid::from_bytes(b"00000000000000000000").unwrap(); + assert!(repo.set_head_detached(void_oid).is_err()); + + let master_oid = repo.revparse_single("master").unwrap().id(); + assert!(repo.set_head_detached(master_oid).is_ok()); + assert_eq!(repo.head().unwrap().target().unwrap(), master_oid); + } + + #[test] + fn smoke_revparse_ext() { + let (_td, repo) = graph_repo_init(); + + { + let short_refname = "master"; + let expected_refname = "refs/heads/master"; + let (obj, reference) = repo.revparse_ext(short_refname).unwrap(); + let expected_obj = repo.revparse_single(expected_refname).unwrap(); + assert_eq!(obj.id(), expected_obj.id()); + assert_eq!(reference.unwrap().name().unwrap(), expected_refname); + } + { + let missing_refname = "refs/heads/does-not-exist"; + assert!(repo.revparse_ext(missing_refname).is_err()); + } + { + let (_obj, reference) = repo.revparse_ext("HEAD^").unwrap(); + assert!(reference.is_none()); + } + } +} diff --git a/deps/git2-0.2.12/src/revspec.rs b/deps/git2-0.2.12/src/revspec.rs new file mode 100644 index 000000000..eb18492ef --- /dev/null +++ b/deps/git2-0.2.12/src/revspec.rs @@ -0,0 +1,26 @@ +use {Object, RevparseMode}; + +/// A revspec represents a range of revisions within a repository. +pub struct Revspec<'repo> { + from: Option>, + to: Option>, + mode: RevparseMode, +} + +impl<'repo> Revspec<'repo> { + /// Assembles a new revspec from the from/to components. + pub fn from_objects(from: Option>, + to: Option>, + mode: RevparseMode) -> Revspec<'repo> { + Revspec { from: from, to: to, mode: mode } + } + + /// Access the `from` range of this revspec. + pub fn from(&self) -> Option<&Object<'repo>> { self.from.as_ref() } + + /// Access the `to` range of this revspec. + pub fn to(&self) -> Option<&Object<'repo>> { self.to.as_ref() } + + /// Returns the intent of the revspec. + pub fn mode(&self) -> RevparseMode { self.mode } +} diff --git a/deps/git2-0.2.12/src/revwalk.rs b/deps/git2-0.2.12/src/revwalk.rs new file mode 100644 index 000000000..e628ef0c5 --- /dev/null +++ b/deps/git2-0.2.12/src/revwalk.rs @@ -0,0 +1,209 @@ +use std::marker; +use std::ffi::CString; +use libc::c_uint; + +use {raw, Error, Sort, Oid, Repository}; +use util::Binding; + +/// A revwalk allows traversal of the commit graph defined by including one or +/// more leaves and excluding one or more roots. +pub struct Revwalk<'repo> { + raw: *mut raw::git_revwalk, + _marker: marker::PhantomData<&'repo Repository>, +} + +impl<'repo> Revwalk<'repo> { + /// Reset a revwalk to allow re-configuring it. + /// + /// The revwalk is automatically reset when iteration of its commits + /// completes. + pub fn reset(&mut self) { + unsafe { raw::git_revwalk_reset(self.raw()) } + } + + /// Set the order in which commits are visited. + pub fn set_sorting(&mut self, sort_mode: Sort) { + unsafe { + raw::git_revwalk_sorting(self.raw(), sort_mode.bits() as c_uint) + } + } + + /// Simplify the history by first-parent + /// + /// No parents other than the first for each commit will be enqueued. + pub fn simplify_first_parent(&mut self) { + unsafe { raw::git_revwalk_simplify_first_parent(self.raw) } + } + + /// Mark a commit to start traversal from. + /// + /// The given OID must belong to a committish on the walked repository. + /// + /// The given commit will be used as one of the roots when starting the + /// revision walk. At least one commit must be pushed onto the walker before + /// a walk can be started. + pub fn push(&mut self, oid: Oid) -> Result<(), Error> { + unsafe { + try_call!(raw::git_revwalk_push(self.raw(), oid.raw())); + } + Ok(()) + } + + /// Push the repository's HEAD + /// + /// For more information, see `push`. + pub fn push_head(&mut self) -> Result<(), Error> { + unsafe { + try_call!(raw::git_revwalk_push_head(self.raw())); + } + Ok(()) + } + + /// Push matching references + /// + /// The OIDs pointed to by the references that match the given glob pattern + /// will be pushed to the revision walker. + /// + /// A leading 'refs/' is implied if not present as well as a trailing `/ \ + /// *` if the glob lacks '?', ' \ *' or '['. + /// + /// Any references matching this glob which do not point to a committish + /// will be ignored. + pub fn push_glob(&mut self, glob: &str) -> Result<(), Error> { + let glob = try!(CString::new(glob)); + unsafe { + try_call!(raw::git_revwalk_push_glob(self.raw, glob)); + } + Ok(()) + } + + /// Push and hide the respective endpoints of the given range. + /// + /// The range should be of the form `..` where each + /// `` is in the form accepted by `revparse_single`. The left-hand + /// commit will be hidden and the right-hand commit pushed. + pub fn push_range(&mut self, range: &str) -> Result<(), Error> { + let range = try!(CString::new(range)); + unsafe { + try_call!(raw::git_revwalk_push_range(self.raw, range)); + } + Ok(()) + } + + /// Push the OID pointed to by a reference + /// + /// The reference must point to a committish. + pub fn push_ref(&mut self, reference: &str) -> Result<(), Error> { + let reference = try!(CString::new(reference)); + unsafe { + try_call!(raw::git_revwalk_push_ref(self.raw, reference)); + } + Ok(()) + } + + /// Mark a commit as not of interest to this revwalk. + pub fn hide(&mut self, oid: Oid) -> Result<(), Error> { + unsafe { + try_call!(raw::git_revwalk_hide(self.raw(), oid.raw())); + } + Ok(()) + } + + /// Hide the repository's HEAD + /// + /// For more information, see `hide`. + pub fn hide_head(&mut self) -> Result<(), Error> { + unsafe { + try_call!(raw::git_revwalk_hide_head(self.raw())); + } + Ok(()) + } + + /// Hide matching references. + /// + /// The OIDs pointed to by the references that match the given glob pattern + /// and their ancestors will be hidden from the output on the revision walk. + /// + /// A leading 'refs/' is implied if not present as well as a trailing `/ \ + /// *` if the glob lacks '?', ' \ *' or '['. + /// + /// Any references matching this glob which do not point to a committish + /// will be ignored. + pub fn hide_glob(&mut self, glob: &str) -> Result<(), Error> { + let glob = try!(CString::new(glob)); + unsafe { + try_call!(raw::git_revwalk_hide_glob(self.raw, glob)); + } + Ok(()) + } + + /// Hide the OID pointed to by a reference. + /// + /// The reference must point to a committish. + pub fn hide_ref(&mut self, reference: &str) -> Result<(), Error> { + let reference = try!(CString::new(reference)); + unsafe { + try_call!(raw::git_revwalk_hide_ref(self.raw, reference)); + } + Ok(()) + } +} + +impl<'repo> Binding for Revwalk<'repo> { + type Raw = *mut raw::git_revwalk; + unsafe fn from_raw(raw: *mut raw::git_revwalk) -> Revwalk<'repo> { + Revwalk { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_revwalk { self.raw } +} + +impl<'repo> Drop for Revwalk<'repo> { + fn drop(&mut self) { + unsafe { raw::git_revwalk_free(self.raw) } + } +} + +impl<'repo> Iterator for Revwalk<'repo> { + type Item = Oid; + fn next(&mut self) -> Option { + let mut out: raw::git_oid = raw::git_oid{ id: [0; raw::GIT_OID_RAWSZ] }; + unsafe { + match raw::git_revwalk_next(&mut out, self.raw()) { + 0 => (), + _ => return None, + } + + Some(Binding::from_raw(&out as *const _)) + } + } +} + +#[cfg(test)] +mod tests { + extern crate std; + use std::vec::{Vec}; + + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let head = repo.head().unwrap(); + let target = head.target().unwrap(); + + let mut walk = repo.revwalk().unwrap(); + walk.push(target).unwrap(); + + let oids: Vec<::Oid> = walk.by_ref().collect(); + + assert_eq!(oids.len(), 1); + assert_eq!(oids[0], target); + + walk.reset(); + walk.push_head().unwrap(); + assert_eq!(walk.by_ref().count(), 1); + + walk.reset(); + walk.push_head().unwrap(); + walk.hide_head().unwrap(); + assert_eq!(walk.by_ref().count(), 0); + } +} diff --git a/deps/git2-0.2.12/src/signature.rs b/deps/git2-0.2.12/src/signature.rs new file mode 100644 index 000000000..b06b85617 --- /dev/null +++ b/deps/git2-0.2.12/src/signature.rs @@ -0,0 +1,171 @@ +use std::ffi::CString; +use std::marker; +use std::mem; +use std::str; +use std::fmt; +use libc; + +use {raw, Error, Time}; +use util::Binding; + +/// A Signature is used to indicate authorship of various actions throughout the +/// library. +/// +/// Signatures contain a name, email, and timestamp. All fields can be specified +/// with `new`, the `now` constructor omits the timestamp, and the `default` +/// constructor reads configuration from the given repository. +pub struct Signature<'a> { + raw: *mut raw::git_signature, + _marker: marker::PhantomData<&'a str>, + owned: bool, +} + +impl<'a> Signature<'a> { + /// Create a new action signature with a timestamp of 'now'. + /// + /// See `new` for more information + pub fn now(name: &str, email: &str) -> Result, Error> { + ::init(); + let mut ret = 0 as *mut raw::git_signature; + let name = try!(CString::new(name)); + let email = try!(CString::new(email)); + unsafe { + try_call!(raw::git_signature_now(&mut ret, name, email)); + Ok(Binding::from_raw(ret)) + } + } + + /// Create a new action signature. + /// + /// The `time` specified is in seconds since the epoch, and the `offset` is + /// the time zone offset in minutes. + /// + /// Returns error if either `name` or `email` contain angle brackets. + pub fn new(name: &str, email: &str, time: &Time) + -> Result, Error> { + ::init(); + let mut ret = 0 as *mut raw::git_signature; + let name = try!(CString::new(name)); + let email = try!(CString::new(email)); + unsafe { + try_call!(raw::git_signature_new(&mut ret, name, email, + time.seconds() as raw::git_time_t, + time.offset_minutes() as libc::c_int)); + Ok(Binding::from_raw(ret)) + } + } + + /// Gets the name on the signature. + /// + /// Returns `None` if the name is not valid utf-8 + pub fn name(&self) -> Option<&str> { + str::from_utf8(self.name_bytes()).ok() + } + + /// Gets the name on the signature as a byte slice. + pub fn name_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } + } + + /// Gets the email on the signature. + /// + /// Returns `None` if the email is not valid utf-8 + pub fn email(&self) -> Option<&str> { + str::from_utf8(self.email_bytes()).ok() + } + + /// Gets the email on the signature as a byte slice. + pub fn email_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, (*self.raw).email).unwrap() } + } + + /// Get the `when` of this signature. + pub fn when(&self) -> Time { + unsafe { Binding::from_raw((*self.raw).when) } + } + + /// Convert a signature of any lifetime into an owned signature with a + /// static lifetime. + pub fn to_owned(&self) -> Signature<'static> { + unsafe { + let me = mem::transmute::<&Signature<'a>, &Signature<'static>>(self); + me.clone() + } + } +} + +impl<'a> Binding for Signature<'a> { + type Raw = *mut raw::git_signature; + unsafe fn from_raw(raw: *mut raw::git_signature) -> Signature<'a> { + Signature { + raw: raw, + _marker: marker::PhantomData, + owned: true, + } + } + fn raw(&self) -> *mut raw::git_signature { self.raw } +} + +/// Creates a new signature from the give raw pointer, tied to the lifetime +/// of the given object. +/// +/// This function is unsafe as there is no guarantee that `raw` is valid for +/// `'a` nor if it's a valid pointer. +pub unsafe fn from_raw_const<'b, T>(_lt: &'b T, + raw: *const raw::git_signature) + -> Signature<'b> { + Signature { + raw: raw as *mut raw::git_signature, + _marker: marker::PhantomData, + owned: false, + } +} + +impl Clone for Signature<'static> { + fn clone(&self) -> Signature<'static> { + // TODO: can this be defined for 'a and just do a plain old copy if the + // lifetime isn't static? + let mut raw = 0 as *mut raw::git_signature; + let rc = unsafe { raw::git_signature_dup(&mut raw, &*self.raw) }; + assert_eq!(rc, 0); + unsafe { Binding::from_raw(raw) } + } +} + +impl<'a> Drop for Signature<'a> { + fn drop(&mut self) { + if self.owned { + unsafe { raw::git_signature_free(self.raw) } + } + } +} + +impl<'a> fmt::Display for Signature<'a> { + + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} <{}>", + String::from_utf8_lossy(self.name_bytes()), + String::from_utf8_lossy(self.email_bytes())) + } + +} + +#[cfg(test)] +mod tests { + use {Signature, Time}; + + #[test] + fn smoke() { + Signature::new("foo", "bar", &Time::new(89, 0)).unwrap(); + Signature::now("foo", "bar").unwrap(); + assert!(Signature::new("", "bar", &Time::new(89, 0)).is_err()); + assert!(Signature::now("", "bar").is_err()); + + let s = Signature::now("foo", "bar").unwrap(); + assert_eq!(s.name(), Some("foo")); + assert_eq!(s.email(), Some("bar")); + + drop(s.clone()); + drop(s.to_owned()); + } +} diff --git a/deps/git2-0.2.12/src/status.rs b/deps/git2-0.2.12/src/status.rs new file mode 100644 index 000000000..40e47b72d --- /dev/null +++ b/deps/git2-0.2.12/src/status.rs @@ -0,0 +1,396 @@ +use std::ffi::CString; +use std::ops::Range; +use std::marker; +use std::mem; +use std::str; +use libc::{c_char, size_t, c_uint}; + +use {raw, Status, DiffDelta, IntoCString, Repository}; +use util::Binding; + +/// Options that can be provided to `repo.statuses()` to control how the status +/// information is gathered. +pub struct StatusOptions { + raw: raw::git_status_options, + pathspec: Vec, + ptrs: Vec<*const c_char>, +} + +/// Enumeration of possible methods of what can be shown through a status +/// operation. +#[derive(Copy, Clone)] +pub enum StatusShow { + /// Only gives status based on HEAD to index comparison, not looking at + /// working directory changes. + Index, + + /// Only gives status based on index to working directory comparison, not + /// comparing the index to the HEAD. + Workdir, + + /// The default, this roughly matches `git status --porcelain` regarding + /// which files are included and in what order. + IndexAndWorkdir, +} + +/// A container for a list of status information about a repository. +/// +/// Each instances appears as a if it were a collection, having a length and +/// allowing indexing as well as provding an iterator. +pub struct Statuses<'repo> { + raw: *mut raw::git_status_list, + + // Hm, not currently present, but can't hurt? + _marker: marker::PhantomData<&'repo Repository>, +} + +/// An iterator over the statuses in a `Statuses` instance. +pub struct StatusIter<'statuses> { + statuses: &'statuses Statuses<'statuses>, + range: Range, +} + +/// A structure representing an entry in the `Statuses` structure. +/// +/// Instances are created through the `.iter()` method or the `.get()` method. +pub struct StatusEntry<'statuses> { + raw: *const raw::git_status_entry, + _marker: marker::PhantomData<&'statuses DiffDelta<'statuses>>, +} + +impl StatusOptions { + /// Creates a new blank set of status options. + pub fn new() -> StatusOptions { + unsafe { + let mut raw = mem::zeroed(); + let r = raw::git_status_init_options(&mut raw, + raw::GIT_STATUS_OPTIONS_VERSION); + assert_eq!(r, 0); + StatusOptions { + raw: raw, + pathspec: Vec::new(), + ptrs: Vec::new(), + } + } + } + + /// Select the files on which to report status. + /// + /// The default, if unspecified, is to show the index and the working + /// directory. + pub fn show(&mut self, show: StatusShow) -> &mut StatusOptions { + self.raw.show = match show { + StatusShow::Index => raw::GIT_STATUS_SHOW_INDEX_ONLY, + StatusShow::Workdir => raw::GIT_STATUS_SHOW_WORKDIR_ONLY, + StatusShow::IndexAndWorkdir => raw::GIT_STATUS_SHOW_INDEX_AND_WORKDIR, + }; + self + } + + /// Add a path pattern to match (using fnmatch-style matching). + /// + /// If the `disable_pathspec_match` option is given, then this is a literal + /// path to match. If this is not called, then there will be no patterns to + /// match and the entire directory will be used. + pub fn pathspec(&mut self, pathspec: T) + -> &mut StatusOptions { + let s = pathspec.into_c_string().unwrap(); + self.ptrs.push(s.as_ptr()); + self.pathspec.push(s); + self + } + + fn flag(&mut self, flag: raw::git_status_opt_t, val: bool) + -> &mut StatusOptions { + if val { + self.raw.flags |= flag as c_uint; + } else { + self.raw.flags &= !(flag as c_uint); + } + self + } + + /// Flag whether untracked files will be included. + /// + /// Untracked files will only be included if the workdir files are included + /// in the status "show" option. + pub fn include_untracked(&mut self, include: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNTRACKED, include) + } + + /// Flag whether ignored files will be included. + /// + /// The files will only be included if the workdir files are included + /// in the status "show" option. + pub fn include_ignored(&mut self, include: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_INCLUDE_IGNORED, include) + } + + /// Flag to include unmodified files. + pub fn include_unmodified(&mut self, include: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNMODIFIED, include) + } + + /// Flag that submodules should be skipped. + /// + /// This only applies if there are no pending typechanges to the submodule + /// (either from or to another type). + pub fn exclude_submodules(&mut self, exclude: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_EXCLUDE_SUBMODULES, exclude) + } + + /// Flag that all files in untracked directories should be included. + /// + /// Normally if an entire directory is new then just the top-level directory + /// is included (with a trailing slash on the entry name). + pub fn recurse_untracked_dirs(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS, include) + } + + /// Indicates that the given paths should be treated as literals paths, note + /// patterns. + pub fn disable_pathspec_match(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH, include) + } + + /// Indicates that the contents of ignored directories should be included in + /// the status. + pub fn recurse_ignored_dirs(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_RECURSE_IGNORED_DIRS, include) + } + + /// Indicates that rename detection should be processed between the head. + pub fn renames_head_to_index(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX, include) + } + + /// Indicates that rename detection should be run between the index and the + /// working directory. + pub fn renames_index_to_workdir(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR, include) + } + + /// Override the native case sensitivity for the file system and force the + /// output to be in case sensitive order. + pub fn sort_case_sensitively(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_SORT_CASE_SENSITIVELY, include) + } + + /// Override the native case sensitivity for the file system and force the + /// output to be in case-insensitive order. + pub fn sort_case_insensitively(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY, include) + } + + /// Indicates that rename detection should include rewritten files. + pub fn renames_from_rewrites(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_RENAMES_FROM_REWRITES, include) + } + + /// Bypasses the default status behavior of doing a "soft" index reload. + pub fn no_refresh(&mut self, include: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_NO_REFRESH, include) + } + + /// Refresh the stat cache in the index for files are unchanged but have + /// out of date stat information in the index. + /// + /// This will result in less work being done on subsequent calls to fetching + /// the status. + pub fn update_index(&mut self, include: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_UPDATE_INDEX, include) + } + + // erm... + #[allow(missing_docs)] + pub fn include_unreadable(&mut self, include: bool) -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNREADABLE, include) + } + + // erm... + #[allow(missing_docs)] + pub fn include_unreadable_as_untracked(&mut self, include: bool) + -> &mut StatusOptions { + self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED, include) + } + + /// Get a pointer to the inner list of status options. + /// + /// This function is unsafe as the returned structure has interior pointers + /// and may no longer be valid if these options continue to be mutated. + pub unsafe fn raw(&mut self) -> *const raw::git_status_options { + self.raw.pathspec.strings = self.ptrs.as_ptr() as *mut _; + self.raw.pathspec.count = self.ptrs.len() as size_t; + &self.raw + } +} + +impl<'repo> Statuses<'repo> { + /// Gets a status entry from this list at the specified index. + /// + /// Returns `None` if the index is out of bounds. + pub fn get(&self, index: usize) -> Option { + unsafe { + let p = raw::git_status_byindex(self.raw, index as size_t); + Binding::from_raw_opt(p) + } + } + + /// Gets the count of status entries in this list. + /// + /// If there are no changes in status (at least according the options given + /// when the status list was created), this can return 0. + pub fn len(&self) -> usize { + unsafe { raw::git_status_list_entrycount(self.raw) as usize } + } + + /// Returns an iterator over the statuses in this list. + pub fn iter(&self) -> StatusIter { + StatusIter { + statuses: self, + range: 0..self.len(), + } + } +} + +impl<'repo> Binding for Statuses<'repo> { + type Raw = *mut raw::git_status_list; + unsafe fn from_raw(raw: *mut raw::git_status_list) -> Statuses<'repo> { + Statuses { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_status_list { self.raw } +} + +impl<'repo> Drop for Statuses<'repo> { + fn drop(&mut self) { + unsafe { raw::git_status_list_free(self.raw); } + } +} + +impl<'a> Iterator for StatusIter<'a> { + type Item = StatusEntry<'a>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.statuses.get(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'a> DoubleEndedIterator for StatusIter<'a> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.statuses.get(i)) + } +} +impl<'a> ExactSizeIterator for StatusIter<'a> {} + +impl<'statuses> StatusEntry<'statuses> { + /// Access the bytes for this entry's corresponding pathname + pub fn path_bytes(&self) -> &[u8] { + unsafe { + if (*self.raw).head_to_index.is_null() { + ::opt_bytes(self, (*(*self.raw).index_to_workdir).old_file.path) + } else { + ::opt_bytes(self, (*(*self.raw).head_to_index).old_file.path) + }.unwrap() + } + } + + /// Access this entry's path name as a string. + /// + /// Returns `None` if the path is not valid utf-8. + pub fn path(&self) -> Option<&str> { str::from_utf8(self.path_bytes()).ok() } + + /// Access the status flags for this file + pub fn status(&self) -> Status { + Status::from_bits_truncate(unsafe { (*self.raw).status as u32 }) + } + + /// Access detailed information about the differences between the file in + /// HEAD and the file in the index. + pub fn head_to_index(&self) -> Option> { + unsafe { + Binding::from_raw_opt((*self.raw).head_to_index) + } + } + + /// Access detailed information about the differences between the file in + /// the index and the file in the working directory. + pub fn index_to_workdir(&self) -> Option> { + unsafe { + Binding::from_raw_opt((*self.raw).index_to_workdir) + } + } +} + +impl<'statuses> Binding for StatusEntry<'statuses> { + type Raw = *const raw::git_status_entry; + + unsafe fn from_raw(raw: *const raw::git_status_entry) + -> StatusEntry<'statuses> { + StatusEntry { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *const raw::git_status_entry { self.raw } +} + +#[cfg(test)] +mod tests { + use std::fs::File; + use std::path::Path; + use std::io::prelude::*; + use super::StatusOptions; + + #[test] + fn smoke() { + let (td, repo) = ::test::repo_init(); + assert_eq!(repo.statuses(None).unwrap().len(), 0); + File::create(&td.path().join("foo")).unwrap(); + let statuses = repo.statuses(None).unwrap(); + assert_eq!(statuses.iter().count(), 1); + let status = statuses.iter().next().unwrap(); + assert_eq!(status.path(), Some("foo")); + assert!(status.status().contains(::STATUS_WT_NEW)); + assert!(!status.status().contains(::STATUS_INDEX_NEW)); + assert!(status.head_to_index().is_none()); + let diff = status.index_to_workdir().unwrap(); + assert_eq!(diff.old_file().path_bytes().unwrap(), b"foo"); + assert_eq!(diff.new_file().path_bytes().unwrap(), b"foo"); + } + + #[test] + fn filter() { + let (td, repo) = ::test::repo_init(); + t!(File::create(&td.path().join("foo"))); + t!(File::create(&td.path().join("bar"))); + let mut opts = StatusOptions::new(); + opts.include_untracked(true) + .pathspec("foo"); + + let statuses = t!(repo.statuses(Some(&mut opts))); + assert_eq!(statuses.iter().count(), 1); + let status = statuses.iter().next().unwrap(); + assert_eq!(status.path(), Some("foo")); + } + + #[test] + fn gitignore() { + let (td, repo) = ::test::repo_init(); + t!(t!(File::create(td.path().join(".gitignore"))).write_all(b"foo\n")); + assert!(!t!(repo.status_should_ignore(Path::new("bar")))); + assert!(t!(repo.status_should_ignore(Path::new("foo")))); + } + + #[test] + fn status_file() { + let (td, repo) = ::test::repo_init(); + assert!(repo.status_file(Path::new("foo")).is_err()); + t!(File::create(td.path().join("foo"))); + let status = t!(repo.status_file(Path::new("foo"))); + assert!(status.contains(::STATUS_WT_NEW)); + } +} diff --git a/deps/git2-0.2.12/src/string_array.rs b/deps/git2-0.2.12/src/string_array.rs new file mode 100644 index 000000000..60a209a0c --- /dev/null +++ b/deps/git2-0.2.12/src/string_array.rs @@ -0,0 +1,106 @@ +//! Bindings to libgit2's raw git_strarray type + +use std::str; +use std::ops::Range; + +use raw; +use util::Binding; + +/// A string array structure used by libgit2 +/// +/// Some apis return arrays of strings which originate from libgit2. This +/// wrapper type behaves a little like `Vec<&str>` but does so without copying +/// the underlying strings until necessary. +pub struct StringArray { + raw: raw::git_strarray, +} + +/// A forward iterator over the strings of an array, casted to `&str`. +pub struct Iter<'a> { + range: Range, + arr: &'a StringArray, +} + +/// A forward iterator over the strings of an array, casted to `&[u8]`. +pub struct IterBytes<'a> { + range: Range, + arr: &'a StringArray, +} + +impl StringArray { + /// Returns None if the i'th string is not utf8 or if i is out of bounds. + pub fn get(&self, i: usize) -> Option<&str> { + self.get_bytes(i).and_then(|s| str::from_utf8(s).ok()) + } + + /// Returns None if `i` is out of bounds. + pub fn get_bytes(&self, i: usize) -> Option<&[u8]> { + if i < self.raw.count as usize { + unsafe { + let ptr = *self.raw.strings.offset(i as isize) as *const _; + Some(::opt_bytes(self, ptr).unwrap()) + } + } else { + None + } + } + + /// Returns an iterator over the strings contained within this array. + /// + /// The iterator yields `Option<&str>` as it is unknown whether the contents + /// are utf-8 or not. + pub fn iter(&self) -> Iter { + Iter { range: 0..self.len(), arr: self } + } + + /// Returns an iterator over the strings contained within this array, + /// yielding byte slices. + pub fn iter_bytes(&self) -> IterBytes { + IterBytes { range: 0..self.len(), arr: self } + } + + /// Returns the number of strings in this array. + pub fn len(&self) -> usize { self.raw.count as usize } +} + +impl Binding for StringArray { + type Raw = raw::git_strarray; + unsafe fn from_raw(raw: raw::git_strarray) -> StringArray { + StringArray { raw: raw } + } + fn raw(&self) -> raw::git_strarray { self.raw } +} + +impl<'a> Iterator for Iter<'a> { + type Item = Option<&'a str>; + fn next(&mut self) -> Option> { + self.range.next().map(|i| self.arr.get(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'a> DoubleEndedIterator for Iter<'a> { + fn next_back(&mut self) -> Option> { + self.range.next_back().map(|i| self.arr.get(i)) + } +} +impl<'a> ExactSizeIterator for Iter<'a> {} + +impl<'a> Iterator for IterBytes<'a> { + type Item = &'a [u8]; + fn next(&mut self) -> Option<&'a [u8]> { + self.range.next().and_then(|i| self.arr.get_bytes(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'a> DoubleEndedIterator for IterBytes<'a> { + fn next_back(&mut self) -> Option<&'a [u8]> { + self.range.next_back().and_then(|i| self.arr.get_bytes(i)) + } +} +impl<'a> ExactSizeIterator for IterBytes<'a> {} + +impl Drop for StringArray { + fn drop(&mut self) { + unsafe { raw::git_strarray_free(&mut self.raw) } + } +} diff --git a/deps/git2-0.2.12/src/submodule.rs b/deps/git2-0.2.12/src/submodule.rs new file mode 100644 index 000000000..48b531f55 --- /dev/null +++ b/deps/git2-0.2.12/src/submodule.rs @@ -0,0 +1,255 @@ +use std::marker; +use std::str; +use std::path::Path; + +use {raw, Oid, Repository, Error, SubmoduleStatus}; +use util::{self, Binding}; + +/// A structure to represent a git [submodule][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Tools-Submodules +pub struct Submodule<'repo> { + raw: *mut raw::git_submodule, + _marker: marker::PhantomData<&'repo Repository>, +} + +impl<'repo> Submodule<'repo> { + /// Get the submodule's branch. + /// + /// Returns `None` if the branch is not valid utf-8 or if the branch is not + /// yet available. + pub fn branch(&self) -> Option<&str> { + self.branch_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the branch for the submodule. + /// + /// Returns `None` if the branch is not yet available. + pub fn branch_bytes(&self) -> Option<&[u8]> { + unsafe { + ::opt_bytes(self, raw::git_submodule_branch(self.raw)) + } + } + + /// Get the submodule's url. + /// + /// Returns `None` if the url is not valid utf-8 + pub fn url(&self) -> Option<&str> { str::from_utf8(self.url_bytes()).ok() } + + /// Get the url for the submodule. + pub fn url_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_submodule_url(self.raw)).unwrap() + } + } + + /// Get the submodule's name. + /// + /// Returns `None` if the name is not valid utf-8 + pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } + + /// Get the name for the submodule. + pub fn name_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_submodule_name(self.raw)).unwrap() + } + } + + /// Get the path for the submodule. + pub fn path(&self) -> &Path { + util::bytes2path(unsafe { + ::opt_bytes(self, raw::git_submodule_path(self.raw)).unwrap() + }) + } + + /// Get the OID for the submodule in the current HEAD tree. + pub fn head_id(&self) -> Option { + unsafe { + Binding::from_raw_opt(raw::git_submodule_head_id(self.raw)) + } + } + + /// Get the OID for the submodule in the index. + pub fn index_id(&self) -> Option { + unsafe { + Binding::from_raw_opt(raw::git_submodule_index_id(self.raw)) + } + } + + /// Get the OID for the submodule in the current working directory. + /// + /// This returns the OID that corresponds to looking up 'HEAD' in the + /// checked out submodule. If there are pending changes in the index or + /// anything else, this won't notice that. + pub fn workdir_id(&self) -> Option { + unsafe { + Binding::from_raw_opt(raw::git_submodule_wd_id(self.raw)) + } + } + + /// Copy submodule info into ".git/config" file. + /// + /// Just like "git submodule init", this copies information about the + /// submodule into ".git/config". You can use the accessor functions above + /// to alter the in-memory git_submodule object and control what is written + /// to the config, overriding what is in .gitmodules. + /// + /// By default, existing entries will not be overwritten, but passing `true` + /// for `overwrite` forces them to be updated. + pub fn init(&mut self, overwrite: bool) -> Result<(), Error> { + unsafe { + try_call!(raw::git_submodule_init(self.raw, overwrite)); + } + Ok(()) + } + + /// Open the repository for a submodule. + /// + /// This will only work if the submodule is checked out into the working + /// directory. + pub fn open(&self) -> Result { + let mut raw = 0 as *mut raw::git_repository; + unsafe { + try_call!(raw::git_submodule_open(&mut raw, self.raw)); + Ok(Binding::from_raw(raw)) + } + } + + /// Reread submodule info from config, index, and HEAD. + /// + /// Call this to reread cached submodule information for this submodule if + /// you have reason to believe that it has changed. + /// + /// If `force` is `true`, then data will be reloaded even if it doesn't seem + /// out of date + pub fn reload(&mut self, force: bool) -> Result<(), Error> { + unsafe { + try_call!(raw::git_submodule_reload(self.raw, force)); + } + Ok(()) + } + + /// Write submodule settings to .gitmodules file. + /// + /// This commits any in-memory changes to the submodule to the gitmodules + /// file on disk. You may also be interested in `init()` which + /// writes submodule info to ".git/config" (which is better for local + /// changes to submodule settings) and/or `sync()` which writes + /// settings about remotes to the actual submodule repository. + pub fn save(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_submodule_save(self.raw)); } + Ok(()) + } + + /// Copy submodule remote info into submodule repo. + /// + /// This copies the information about the submodules URL into the checked + /// out submodule config, acting like "git submodule sync". This is useful + /// if you have altered the URL for the submodule (or it has been altered + /// by a fetch of upstream changes) and you need to update your local repo. + pub fn sync(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_submodule_sync(self.raw)); } + Ok(()) + } + + /// Add current submodule HEAD commit to index of superproject. + /// + /// If `write_index` is true, then the index file will be immediately + /// written. Otherwise you must explicitly call `write()` on an `Index` + /// later on. + pub fn add_to_index(&mut self, write_index: bool) -> Result<(), Error> { + unsafe { + try_call!(raw::git_submodule_add_to_index(self.raw, write_index)); + } + Ok(()) + } + + /// Resolve the setup of a new git submodule. + /// + /// This should be called on a submodule once you have called add setup and + /// done the clone of the submodule. This adds the .gitmodules file and the + /// newly cloned submodule to the index to be ready to be committed (but + /// doesn't actually do the commit). + pub fn add_finalize(&mut self) -> Result<(), Error> { + unsafe { try_call!(raw::git_submodule_add_finalize(self.raw)); } + Ok(()) + } + + /// Get the status for a submodule. + /// + /// This looks at a submodule and tries to determine the status. It + /// will return a combination of the `SubmoduleStatus` values. + pub fn status(&self) -> Result { + let mut ret = 0; + unsafe { try_call!(raw::git_submodule_status(&mut ret, self.raw)); } + Ok(SubmoduleStatus::from_bits_truncate(ret as u32)) + } +} + +impl<'repo> Binding for Submodule<'repo> { + type Raw = *mut raw::git_submodule; + unsafe fn from_raw(raw: *mut raw::git_submodule) -> Submodule<'repo> { + Submodule { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_submodule { self.raw } +} + +impl<'repo> Drop for Submodule<'repo> { + fn drop(&mut self) { + unsafe { raw::git_submodule_free(self.raw) } + } +} + +#[cfg(test)] +mod tests { + use std::path::Path; + use std::fs; + use tempdir::TempDir; + use url::Url; + + use Repository; + + #[test] + fn smoke() { + let td = TempDir::new("test").unwrap(); + let repo = Repository::init(td.path()).unwrap(); + let mut s1 = repo.submodule("/path/to/nowhere", + Path::new("foo"), true).unwrap(); + s1.init(false).unwrap(); + s1.sync().unwrap(); + + let s2 = repo.submodule("/path/to/nowhere", + Path::new("bar"), true).unwrap(); + drop((s1, s2)); + + let mut submodules = repo.submodules().unwrap(); + assert_eq!(submodules.len(), 2); + let mut s = submodules.remove(0); + assert_eq!(s.name(), Some("bar")); + assert_eq!(s.url(), Some("/path/to/nowhere")); + assert_eq!(s.branch(), None); + assert!(s.head_id().is_none()); + assert!(s.index_id().is_none()); + assert!(s.workdir_id().is_none()); + + repo.find_submodule("bar").unwrap(); + s.open().unwrap(); + assert!(s.path() == Path::new("bar")); + s.reload(true).unwrap(); + } + + #[test] + fn add_a_submodule() { + let (_td, repo1) = ::test::repo_init(); + let (td, repo2) = ::test::repo_init(); + + let url = Url::from_file_path(&repo1.workdir().unwrap()).unwrap(); + let mut s = repo2.submodule(&url.to_string(), Path::new("bar"), + true).unwrap(); + t!(fs::remove_dir_all(td.path().join("bar"))); + t!(Repository::clone(&url.to_string(), + td.path().join("bar"))); + t!(s.add_to_index(false)); + t!(s.add_finalize()); + } +} diff --git a/deps/git2-0.2.12/src/tag.rs b/deps/git2-0.2.12/src/tag.rs new file mode 100644 index 000000000..482451c0e --- /dev/null +++ b/deps/git2-0.2.12/src/tag.rs @@ -0,0 +1,155 @@ +use std::marker; +use std::str; + +use {raw, signature, Error, Oid, Object, Signature, ObjectType}; +use util::Binding; + +/// A structure to represent a git [tag][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Basics-Tagging +pub struct Tag<'repo> { + raw: *mut raw::git_tag, + _marker: marker::PhantomData>, +} + +impl<'repo> Tag<'repo> { + /// Get the id (SHA1) of a repository tag + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_tag_id(&*self.raw)) } + } + + /// Get the message of a tag + /// + /// Returns None if there is no message or if it is not valid utf8 + pub fn message(&self) -> Option<&str> { + self.message_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Get the message of a tag + /// + /// Returns None if there is no message + pub fn message_bytes(&self) -> Option<&[u8]> { + unsafe { ::opt_bytes(self, raw::git_tag_message(&*self.raw)) } + } + + /// Get the name of a tag + /// + /// Returns None if it is not valid utf8 + pub fn name(&self) -> Option<&str> { + str::from_utf8(self.name_bytes()).ok() + } + + /// Get the name of a tag + pub fn name_bytes(&self) -> &[u8] { + unsafe { ::opt_bytes(self, raw::git_tag_name(&*self.raw)).unwrap() } + } + + /// Recursively peel a tag until a non tag git_object is found + pub fn peel(&self) -> Result, Error> { + let mut ret = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_tag_peel(&mut ret, &*self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Get the tagger (author) of a tag + /// + /// If the author is unspecified, then `None` is returned. + pub fn tagger(&self) -> Option { + unsafe { + let ptr = raw::git_tag_tagger(&*self.raw); + if ptr.is_null() { + None + } else { + Some(signature::from_raw_const(self, ptr)) + } + } + } + + /// Get the tagged object of a tag + /// + /// This method performs a repository lookup for the given object and + /// returns it + pub fn target(&self) -> Result, Error> { + let mut ret = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_tag_target(&mut ret, &*self.raw)); + Ok(Binding::from_raw(ret)) + } + } + + /// Get the OID of the tagged object of a tag + pub fn target_id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_tag_target_id(&*self.raw)) } + } + + /// Get the OID of the tagged object of a tag + pub fn target_type(&self) -> Option { + unsafe { ObjectType::from_raw(raw::git_tag_target_type(&*self.raw)) } + } +} + +impl<'repo> Binding for Tag<'repo> { + type Raw = *mut raw::git_tag; + unsafe fn from_raw(raw: *mut raw::git_tag) -> Tag<'repo> { + Tag { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_tag { self.raw } +} + +impl<'repo> Drop for Tag<'repo> { + fn drop(&mut self) { + unsafe { raw::git_tag_free(self.raw) } + } +} + +#[cfg(test)] +mod tests { + #[test] + fn smoke() { + let (_td, repo) = ::test::repo_init(); + let head = repo.head().unwrap(); + let id = head.target().unwrap(); + assert!(repo.find_tag(id).is_err()); + + let obj = repo.find_object(id, None).unwrap(); + let sig = repo.signature().unwrap(); + let tag_id = repo.tag("foo", &obj, &sig, "msg", false).unwrap(); + let tag = repo.find_tag(tag_id).unwrap(); + assert_eq!(tag.id(), tag_id); + + let tags = repo.tag_names(None).unwrap(); + assert_eq!(tags.len(), 1); + assert_eq!(tags.get(0), Some("foo")); + + assert_eq!(tag.name(), Some("foo")); + assert_eq!(tag.message(), Some("msg")); + assert_eq!(tag.peel().unwrap().id(), obj.id()); + assert_eq!(tag.target_id(), obj.id()); + assert_eq!(tag.target_type(), Some(::ObjectType::Commit)); + + assert_eq!(tag.tagger().unwrap().name(), sig.name()); + tag.target().unwrap(); + + repo.find_object(tag_id, None).unwrap().as_tag().unwrap(); + + repo.tag_delete("foo").unwrap(); + } + + #[test] + fn lite() { + let (_td, repo) = ::test::repo_init(); + let head = t!(repo.head()); + let id = head.target().unwrap(); + let obj = t!(repo.find_object(id, None)); + let tag_id = t!(repo.tag_lightweight("foo", &obj, false)); + assert!(repo.find_tag(tag_id).is_err()); + assert_eq!(t!(repo.refname_to_id("refs/tags/foo")), id); + + let tags = t!(repo.tag_names(Some("f*"))); + assert_eq!(tags.len(), 1); + let tags = t!(repo.tag_names(Some("b*"))); + assert_eq!(tags.len(), 0); + } +} diff --git a/deps/git2-0.2.12/src/test.rs b/deps/git2-0.2.12/src/test.rs new file mode 100644 index 000000000..1f88f980e --- /dev/null +++ b/deps/git2-0.2.12/src/test.rs @@ -0,0 +1,40 @@ +use std::path::{Path, PathBuf}; +use std::io; +use tempdir::TempDir; +use url::Url; + +use Repository; + +macro_rules! t { + ($e:expr) => (match $e { + Ok(e) => e, + Err(e) => panic!("{} failed with {}", stringify!($e), e), + }) +} + +pub fn repo_init() -> (TempDir, Repository) { + let td = TempDir::new("test").unwrap(); + let repo = Repository::init(td.path()).unwrap(); + { + let mut config = repo.config().unwrap(); + config.set_str("user.name", "name").unwrap(); + config.set_str("user.email", "email").unwrap(); + let mut index = repo.index().unwrap(); + let id = index.write_tree().unwrap(); + + let tree = repo.find_tree(id).unwrap(); + let sig = repo.signature().unwrap(); + repo.commit(Some("HEAD"), &sig, &sig, "initial", + &tree, &[]).unwrap(); + } + (td, repo) +} + +pub fn path2url(path: &Path) -> String { + Url::from_file_path(path).unwrap().to_string() +} + +pub fn realpath(original: &Path) -> io::Result { + // TODO: implement this + Ok(original.to_path_buf()) +} diff --git a/deps/git2-0.2.12/src/time.rs b/deps/git2-0.2.12/src/time.rs new file mode 100644 index 000000000..419b23a2c --- /dev/null +++ b/deps/git2-0.2.12/src/time.rs @@ -0,0 +1,67 @@ +use libc::{c_int, c_uint}; + +use raw; +use util::Binding; + +/// Time in a signature +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct Time { + raw: raw::git_time, +} + +/// Time structure used in a git index entry. +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct IndexTime { + raw: raw::git_index_time, +} + +impl Time { + /// Creates a new time structure from its components. + pub fn new(time: i64, offset: i32) -> Time { + unsafe { + Binding::from_raw(raw::git_time { + time: time as raw::git_time_t, + offset: offset as c_int, + }) + } + } + + /// Return the time, in seconds, from epoch + pub fn seconds(&self) -> i64 { self.raw.time as i64 } + + /// Return the timezone offset, in minutes + pub fn offset_minutes(&self) -> i32 { self.raw.offset as i32 } +} + +impl Binding for Time { + type Raw = raw::git_time; + unsafe fn from_raw(raw: raw::git_time) -> Time { + Time { raw: raw } + } + fn raw(&self) -> raw::git_time { self.raw } +} + +impl IndexTime { + /// Creates a new time structure from its components. + pub fn new(seconds: i64, nanoseconds: u32) -> IndexTime { + unsafe { + Binding::from_raw(raw::git_index_time { + seconds: seconds as raw::git_time_t, + nanoseconds: nanoseconds as c_uint, + }) + } + } + + /// Returns the number of seconds in the second component of this time. + pub fn seconds(&self) -> i64 { self.raw.seconds as i64 } + /// Returns the nanosecond component of this time. + pub fn nanoseconds(&self) -> u32 { self.raw.nanoseconds as u32 } +} + +impl Binding for IndexTime { + type Raw = raw::git_index_time; + unsafe fn from_raw(raw: raw::git_index_time) -> IndexTime { + IndexTime { raw: raw } + } + fn raw(&self) -> raw::git_index_time { self.raw } +} diff --git a/deps/git2-0.2.12/src/transport.rs b/deps/git2-0.2.12/src/transport.rs new file mode 100644 index 000000000..115e71e2e --- /dev/null +++ b/deps/git2-0.2.12/src/transport.rs @@ -0,0 +1,341 @@ +//! Interfaces for adding custom transports to libgit2 + +use std::ffi::{CStr, CString}; +use std::io::prelude::*; +use std::io; +use std::mem; +use std::slice; +use std::str; +use libc::{c_int, c_void, c_uint, c_char, size_t}; + +use {raw, Error, Remote}; +use util::Binding; + +/// A transport is a structure which knows how to transfer data to and from a +/// remote. +/// +/// This transport is a representation of the raw transport underneath it, which +/// is similar to a trait object in Rust. +#[allow(missing_copy_implementations)] +pub struct Transport { + raw: *mut raw::git_transport, + owned: bool, +} + +/// Interfaced used by smart transports. +/// +/// The full-fledged definiton of transports has to deal with lots of +/// nitty-gritty details of the git protocol, but "smart transports" largely +/// only need to deal with read() and write() of data over a channel. +/// +/// A smart subtransport is contained within an instance of a smart transport +/// and is delegated to in order to actually conduct network activity to push or +/// pull data from a remote. +pub trait SmartSubtransport: Send + 'static { + /// Indicates that this subtransport will be performing the specified action + /// on the specified URL. + /// + /// This function is responsible for making any network connections and + /// returns a stream which can be read and written from in order to + /// negotiate the git protocol. + fn action(&self, url: &str, action: Service) + -> Result, Error>; + + /// Terminates a connection with the remote. + /// + /// Each subtransport is guaranteed a call to close() between calls to + /// action(), except for the following tow natural progressions of actions + /// against a constant URL. + /// + /// 1. UploadPackLs -> UploadPack + /// 2. ReceivePackLs -> ReceivePack + fn close(&self) -> Result<(), Error>; +} + +/// Actions that a smart transport can ask a subtransport to perform +#[derive(Copy, Clone)] +#[allow(missing_docs)] +pub enum Service { + UploadPackLs, + UploadPack, + ReceivePackLs, + ReceivePack, +} + +/// An instance of a stream over which a smart transport will communicate with a +/// remote. +/// +/// Currently this only requires the standard `Read` and `Write` traits. This +/// trait also does not need to be implemented manually as long as the `Read` +/// and `Write` traits are implemented. +pub trait SmartSubtransportStream: Read + Write + Send + 'static {} + +impl SmartSubtransportStream for T {} + +type TransportFactory = Fn(&Remote) -> Result + Send + Sync + + 'static; + +/// Boxed data payload used for registering new transports. +/// +/// Currently only contains a field which knows how to create transports. +struct TransportData { + factory: Box, +} + +/// Instance of a `git_smart_subtransport`, must use `#[repr(C)]` to ensure that +/// the C fields come first. +#[repr(C)] +struct RawSmartSubtransport { + raw: raw::git_smart_subtransport, + obj: Box, +} + +/// Instance of a `git_smart_subtransport_stream`, must use `#[repr(C)]` to +/// ensure that the C fields come first. +#[repr(C)] +struct RawSmartSubtransportStream { + raw: raw::git_smart_subtransport_stream, + obj: Box, +} + +/// Add a custom transport definition, to be used in addition to the built-in +/// set of transports that come with libgit2. +/// +/// This function is unsafe as it needs to be externally synchronized with calls +/// to creation of other transports. +pub unsafe fn register(prefix: &str, factory: F) -> Result<(), Error> + where F: Fn(&Remote) -> Result + Send + Sync + 'static +{ + let mut data = Box::new(TransportData { + factory: Box::new(factory), + }); + let prefix = try!(CString::new(prefix)); + let datap = (&mut *data) as *mut TransportData as *mut c_void; + try_call!(raw::git_transport_register(prefix, + transport_factory, + datap)); + mem::forget(data); + Ok(()) +} + +impl Transport { + /// Creates a new transport which will use the "smart" transport protocol + /// for transferring data. + /// + /// A smart transport requires a *subtransport* over which data is actually + /// communicated, but this subtransport largely just needs to be able to + /// read() and write(). The subtransport provided will be used to make + /// connections which can then be read/written from. + /// + /// The `rpc` argument is `true` if the protocol is stateless, false + /// otherwise. For example `http://` is stateless but `git://` is not. + pub fn smart(remote: &Remote, + rpc: bool, + subtransport: S) -> Result + where S: SmartSubtransport + { + let mut ret = 0 as *mut _; + + let mut raw = Box::new(RawSmartSubtransport { + raw: raw::git_smart_subtransport { + action: subtransport_action, + close: subtransport_close, + free: subtransport_free, + }, + obj: Box::new(subtransport), + }); + let mut defn = raw::git_smart_subtransport_definition { + callback: smart_factory, + rpc: rpc as c_uint, + param: &mut *raw as *mut _ as *mut _, + }; + + // Currently there's no way to pass a paload via the + // git_smart_subtransport_definition structure, but it's only used as a + // configuration for the initial creation of the smart transport (verified + // by reading the current code, hopefully it doesn't change!). + // + // We, however, need some state (gotta pass in our + // `RawSmartSubtransport`). This also means that this block must be + // entirely synchronized with a lock (boo!) + unsafe { + try_call!(raw::git_transport_smart(&mut ret, remote.raw(), + &mut defn as *mut _ as *mut _)); + mem::forget(raw); // ownership transport to `ret` + } + return Ok(Transport { raw: ret, owned: true }); + + extern fn smart_factory(out: *mut *mut raw::git_smart_subtransport, + _owner: *mut raw::git_transport, + ptr: *mut c_void) -> c_int { + unsafe { + *out = ptr as *mut raw::git_smart_subtransport; + 0 + } + } + } +} + +impl Drop for Transport { + fn drop(&mut self) { + if self.owned { + unsafe { + ((*self.raw).free)(self.raw) + } + } + } +} + +// callback used by register() to create new transports +wrap_env! { + fn transport_factory(out: *mut *mut raw::git_transport, + owner: *mut raw::git_remote, + param: *mut c_void) -> c_int {{ + struct Bomb<'a, 'b> { remote: Option> } + impl<'a, 'b> Drop for Bomb<'a, 'b> { + fn drop(&mut self) { + // TODO: maybe a method instead? + mem::forget(self.remote.take()); + } + } + + unsafe { + let remote = Bomb { remote: Some(Binding::from_raw(owner)) }; + let data = &mut *(param as *mut TransportData); + match (data.factory)(remote.remote.as_ref().unwrap()) { + Ok(mut transport) => { + *out = transport.raw; + transport.owned = false; + 0 + } + Err(e) => e.raw_code() as c_int, + } + } + }} + returning ret as ret.unwrap_or(-1) +} + +// callback used by smart transports to delegate an action to a +// `SmartSubtransport` trait object. +wrap_env! { + fn subtransport_action(stream: *mut *mut raw::git_smart_subtransport_stream, + raw_transport: *mut raw::git_smart_subtransport, + url: *const c_char, + action: raw::git_smart_service_t) -> c_int { + unsafe { + let url = CStr::from_ptr(url).to_bytes(); + let url = match str::from_utf8(url).ok() { + Some(s) => s, + None => return -1, + }; + let action = match action { + raw::GIT_SERVICE_UPLOADPACK_LS => Service::UploadPackLs, + raw::GIT_SERVICE_UPLOADPACK => Service::UploadPack, + raw::GIT_SERVICE_RECEIVEPACK_LS => Service::ReceivePackLs, + raw::GIT_SERVICE_RECEIVEPACK => Service::ReceivePack, + }; + let transport = &mut *(raw_transport as *mut RawSmartSubtransport); + let obj = match transport.obj.action(url, action) { + Ok(s) => s, + Err(e) => return e.raw_code() as c_int, + }; + *stream = mem::transmute(Box::new(RawSmartSubtransportStream { + raw: raw::git_smart_subtransport_stream { + subtransport: raw_transport, + read: stream_read, + write: stream_write, + free: stream_free, + }, + obj: obj, + })); + 0 + } + } + returning ret as ret.unwrap_or(-1) +} + +// callback used by smart transports to close a `SmartSubtransport` trait +// object. +wrap_env! { + fn subtransport_close(transport: *mut raw::git_smart_subtransport) -> c_int { + unsafe { + let transport = &mut *(transport as *mut RawSmartSubtransport); + transport.obj.close() + } + } + returning ret as { + match ret { + Some(Ok(())) => 0, + Some(Err(e)) => e.raw_code() as c_int, + None => -1, + } + } +} + +// callback used by smart transports to free a `SmartSubtransport` trait +// object. +extern fn subtransport_free(transport: *mut raw::git_smart_subtransport) { + unsafe { + mem::transmute::<_, Box>(transport); + } +} + +// callback used by smart transports to read from a `SmartSubtransportStream` +// object. +wrap_env! { + fn stream_read(stream: *mut raw::git_smart_subtransport_stream, + buffer: *mut c_char, + buf_size: size_t, + bytes_read: *mut size_t) -> c_int { + unsafe { + let transport = &mut *(stream as *mut RawSmartSubtransportStream); + let buf = slice::from_raw_parts_mut(buffer as *mut u8, + buf_size as usize); + match transport.obj.read(buf) { + Ok(n) => { *bytes_read = n as size_t; Ok(n) } + e => e, + } + } + } + returning ret as unsafe { + match ret { + Some(Ok(_)) => 0, + Some(Err(e)) => { set_err(e); -2 } + None => -1, + } + } +} + +// callback used by smart transports to write to a `SmartSubtransportStream` +// object. +wrap_env! { + fn stream_write(stream: *mut raw::git_smart_subtransport_stream, + buffer: *const c_char, + len: size_t) -> c_int { + unsafe { + let transport = &mut *(stream as *mut RawSmartSubtransportStream); + let buf = slice::from_raw_parts(buffer as *const u8, len as usize); + transport.obj.write_all(buf) + } + } + returning ret as unsafe { + match ret { + Some(Ok(())) => 0, + Some(Err(e)) => { set_err(e); -2 } + None => -1, + } + } +} + +unsafe fn set_err(e: io::Error) { + let s = CString::new(e.to_string()).unwrap(); + raw::giterr_set_str(raw::GITERR_NET as c_int, s.as_ptr()) +} + +// callback used by smart transports to free a `SmartSubtransportStream` +// object. +extern fn stream_free(stream: *mut raw::git_smart_subtransport_stream) { + unsafe { + mem::transmute::<_, Box>(stream); + } +} diff --git a/deps/git2-0.2.12/src/tree.rs b/deps/git2-0.2.12/src/tree.rs new file mode 100644 index 000000000..ae4edf800 --- /dev/null +++ b/deps/git2-0.2.12/src/tree.rs @@ -0,0 +1,278 @@ +use std::cmp::Ordering; +use std::ffi::CString; +use std::ops::Range; +use std::marker; +use std::path::Path; +use std::str; +use libc; + +use {raw, Oid, Repository, Error, Object, ObjectType}; +use util::{Binding, IntoCString}; + +/// A structure to represent a git [tree][1] +/// +/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects +pub struct Tree<'repo> { + raw: *mut raw::git_tree, + _marker: marker::PhantomData>, +} + +/// A structure representing an entry inside of a tree. An entry is borrowed +/// from a tree. +pub struct TreeEntry<'tree> { + raw: *mut raw::git_tree_entry, + owned: bool, + _marker: marker::PhantomData<&'tree raw::git_tree_entry>, +} + +/// An iterator over the entries in a tree. +pub struct TreeIter<'tree> { + range: Range, + tree: &'tree Tree<'tree>, +} + +impl<'repo> Tree<'repo> { + /// Get the id (SHA1) of a repository object + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_tree_id(&*self.raw)) } + } + + /// Get the number of entries listed in this tree. + pub fn len(&self) -> usize { + unsafe { raw::git_tree_entrycount(&*self.raw) as usize } + } + + /// Returns an iterator over the entries in this tree. + pub fn iter(&self) -> TreeIter { + TreeIter { range: 0..self.len(), tree: self } + } + + /// Lookup a tree entry by SHA value. + pub fn get_id(&self, id: Oid) -> Option { + unsafe { + let ptr = raw::git_tree_entry_byid(&*self.raw(), &*id.raw()); + if ptr.is_null() { + None + } else { + Some(TreeEntry::from_raw_const(ptr)) + } + } + } + + /// Lookup a tree entry by its position in the tree + pub fn get(&self, n: usize) -> Option { + unsafe { + let ptr = raw::git_tree_entry_byindex(&*self.raw(), + n as libc::size_t); + if ptr.is_null() { + None + } else { + Some(TreeEntry::from_raw_const(ptr)) + } + } + } + + /// Lookup a tree entry by its filename + pub fn get_name(&self, filename: &str) -> Option { + let filename = CString::new(filename).unwrap(); + unsafe { + let ptr = call!(raw::git_tree_entry_byname(&*self.raw(), filename)); + if ptr.is_null() { + None + } else { + Some(TreeEntry::from_raw_const(ptr)) + } + } + } + + /// Retrieve a tree entry contained in a tree or in any of its subtrees, + /// given its relative path. + pub fn get_path(&self, path: &Path) -> Result, Error> { + let path = try!(path.into_c_string()); + let mut ret = 0 as *mut raw::git_tree_entry; + unsafe { + try_call!(raw::git_tree_entry_bypath(&mut ret, &*self.raw(), path)); + Ok(Binding::from_raw(ret)) + } + } +} + +impl<'repo> Binding for Tree<'repo> { + type Raw = *mut raw::git_tree; + + unsafe fn from_raw(raw: *mut raw::git_tree) -> Tree<'repo> { + Tree { raw: raw, _marker: marker::PhantomData } + } + fn raw(&self) -> *mut raw::git_tree { self.raw } +} + +impl<'repo> Drop for Tree<'repo> { + fn drop(&mut self) { + unsafe { raw::git_tree_free(self.raw) } + } +} + +impl<'tree> TreeEntry<'tree> { + /// Create a new tree entry from the raw pointer provided. + /// + /// The lifetime of the entry is tied to the tree provided and the function + /// is unsafe because the validity of the pointer cannot be guaranteed. + unsafe fn from_raw_const(raw: *const raw::git_tree_entry) + -> TreeEntry<'tree> { + TreeEntry { + raw: raw as *mut raw::git_tree_entry, + owned: false, + _marker: marker::PhantomData, + } + } + + /// Get the id of the object pointed by the entry + pub fn id(&self) -> Oid { + unsafe { Binding::from_raw(raw::git_tree_entry_id(&*self.raw)) } + } + + /// Get the filename of a tree entry + /// + /// Returns `None` if the name is not valid utf-8 + pub fn name(&self) -> Option<&str> { + str::from_utf8(self.name_bytes()).ok() + } + + /// Get the filename of a tree entry + pub fn name_bytes(&self) -> &[u8] { + unsafe { + ::opt_bytes(self, raw::git_tree_entry_name(&*self.raw())).unwrap() + } + } + + /// Convert a tree entry to the object it points to. + pub fn to_object<'a>(&self, repo: &'a Repository) + -> Result, Error> { + let mut ret = 0 as *mut raw::git_object; + unsafe { + try_call!(raw::git_tree_entry_to_object(&mut ret, repo.raw(), + &*self.raw())); + Ok(Binding::from_raw(ret)) + } + } + + /// Get the type of the object pointed by the entry + pub fn kind(&self) -> Option { + ObjectType::from_raw(unsafe { raw::git_tree_entry_type(&*self.raw) }) + } + + /// Get the UNIX file attributes of a tree entry + pub fn filemode(&self) -> i32 { + unsafe { raw::git_tree_entry_filemode(&*self.raw) as i32 } + } + + /// Get the raw UNIX file attributes of a tree entry + pub fn filemode_raw(&self) -> i32 { + unsafe { raw::git_tree_entry_filemode_raw(&*self.raw) as i32 } + } +} + +impl<'a> Binding for TreeEntry<'a> { + type Raw = *mut raw::git_tree_entry; + unsafe fn from_raw(raw: *mut raw::git_tree_entry) -> TreeEntry<'a> { + TreeEntry { + raw: raw, + owned: true, + _marker: marker::PhantomData, + } + } + fn raw(&self) -> *mut raw::git_tree_entry { self.raw } +} + +impl<'a> Clone for TreeEntry<'a> { + fn clone(&self) -> TreeEntry<'a> { + let mut ret = 0 as *mut raw::git_tree_entry; + unsafe { + assert_eq!(raw::git_tree_entry_dup(&mut ret, &*self.raw()), 0); + Binding::from_raw(ret) + } + } +} + +impl<'a> PartialOrd for TreeEntry<'a> { + fn partial_cmp(&self, other: &TreeEntry<'a>) -> Option { + Some(self.cmp(other)) + } +} +impl<'a> Ord for TreeEntry<'a> { + fn cmp(&self, other: &TreeEntry<'a>) -> Ordering { + match unsafe { raw::git_tree_entry_cmp(&*self.raw(), &*other.raw()) } { + 0 => Ordering::Equal, + n if n < 0 => Ordering::Less, + _ => Ordering::Greater, + } + } +} + +impl<'a> PartialEq for TreeEntry<'a> { + fn eq(&self, other: &TreeEntry<'a>) -> bool { + self.cmp(other) == Ordering::Equal + } +} +impl<'a> Eq for TreeEntry<'a> {} + +impl<'a> Drop for TreeEntry<'a> { + fn drop(&mut self) { + if self.owned { + unsafe { raw::git_tree_entry_free(self.raw) } + } + } +} + +impl<'tree> Iterator for TreeIter<'tree> { + type Item = TreeEntry<'tree>; + fn next(&mut self) -> Option> { + self.range.next().and_then(|i| self.tree.get(i)) + } + fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } +} +impl<'tree> DoubleEndedIterator for TreeIter<'tree> { + fn next_back(&mut self) -> Option> { + self.range.next_back().and_then(|i| self.tree.get(i)) + } +} +impl<'tree> ExactSizeIterator for TreeIter<'tree> {} + +#[cfg(test)] +mod tests { + use std::fs::File; + use std::io::prelude::*; + use std::path::Path; + + #[test] + fn smoke() { + let (td, repo) = ::test::repo_init(); + { + let mut index = repo.index().unwrap(); + File::create(&td.path().join("foo")).unwrap().write_all(b"foo").unwrap(); + index.add_path(Path::new("foo")).unwrap(); + let id = index.write_tree().unwrap(); + let sig = repo.signature().unwrap(); + let tree = repo.find_tree(id).unwrap(); + let parent = repo.find_commit(repo.head().unwrap().target() + .unwrap()).unwrap(); + repo.commit(Some("HEAD"), &sig, &sig, "another commit", + &tree, &[&parent]).unwrap(); + } + let head = repo.head().unwrap(); + let target = head.target().unwrap(); + let commit = repo.find_commit(target).unwrap(); + + let tree = repo.find_tree(commit.tree_id()).unwrap(); + assert_eq!(tree.id(), commit.tree_id()); + assert_eq!(tree.len(), 1); + let e1 = tree.get(0).unwrap(); + assert!(e1 == tree.get_id(e1.id()).unwrap()); + assert!(e1 == tree.get_name("foo").unwrap()); + assert!(e1 == tree.get_path(Path::new("foo")).unwrap()); + assert_eq!(e1.name(), Some("foo")); + e1.to_object(&repo).unwrap(); + + repo.find_object(commit.tree_id(), None).unwrap().as_tree().unwrap(); + } +} diff --git a/deps/git2-0.2.12/src/util.rs b/deps/git2-0.2.12/src/util.rs new file mode 100644 index 000000000..31a367a38 --- /dev/null +++ b/deps/git2-0.2.12/src/util.rs @@ -0,0 +1,143 @@ +use std::ffi::{CString, OsStr, OsString}; +use std::iter::IntoIterator; +use std::path::{Path, PathBuf}; +use libc::{c_char, size_t}; + +use {raw, Error}; + +#[doc(hidden)] +trait IsNull { + fn is_ptr_null(&self) -> bool; +} +impl IsNull for *const T { + fn is_ptr_null(&self) -> bool { + self.is_null() + } +} +impl IsNull for *mut T { + fn is_ptr_null(&self) -> bool { + self.is_null() + } +} + +#[doc(hidden)] +pub trait Binding: Sized { + type Raw; + + unsafe fn from_raw(raw: Self::Raw) -> Self; + fn raw(&self) -> Self::Raw; + + unsafe fn from_raw_opt(raw: T) -> Option + where T: Copy + IsNull, Self: Binding + { + if raw.is_ptr_null() { + None + } else { + Some(Binding::from_raw(raw)) + } + } +} + +pub fn iter2cstrs(iter: I) -> Result<(Vec, Vec<*const c_char>, + raw::git_strarray), Error> + where T: IntoCString, I: IntoIterator +{ + let cstrs: Vec<_> = try!(iter.into_iter().map(|i| i.into_c_string()).collect()); + let ptrs = cstrs.iter().map(|i| i.as_ptr()).collect::>(); + let raw = raw::git_strarray { + strings: ptrs.as_ptr() as *mut _, + count: ptrs.len() as size_t, + }; + Ok((cstrs, ptrs, raw)) +} + +#[cfg(unix)] +pub fn bytes2path(b: &[u8]) -> &Path { + use std::os::unix::prelude::*; + Path::new(OsStr::from_bytes(b)) +} +#[cfg(windows)] +pub fn bytes2path(b: &[u8]) -> &Path { + use std::str; + Path::new(str::from_utf8(b).unwrap()) +} + +/// A class of types that can be converted to C strings. +/// +/// These types are represented internally as byte slices and it is quite rare +/// for them to contain an interior 0 byte. +pub trait IntoCString { + /// Consume this container, converting it into a CString + fn into_c_string(self) -> Result; +} + +impl<'a, T: IntoCString + Clone> IntoCString for &'a T { + fn into_c_string(self) -> Result { + self.clone().into_c_string() + } +} + +impl<'a> IntoCString for &'a str { + fn into_c_string(self) -> Result { + Ok(try!(CString::new(self))) + } +} + +impl IntoCString for String { + fn into_c_string(self) -> Result { + Ok(try!(CString::new(self.into_bytes()))) + } +} + +impl IntoCString for CString { + fn into_c_string(self) -> Result { Ok(self) } +} + +impl<'a> IntoCString for &'a Path { + fn into_c_string(self) -> Result { + let s: &OsStr = self.as_ref(); + s.into_c_string() + } +} + +impl IntoCString for PathBuf { + fn into_c_string(self) -> Result { + let s: OsString = self.into(); + s.into_c_string() + } +} + +impl<'a> IntoCString for &'a OsStr { + fn into_c_string(self) -> Result { + self.to_os_string().into_c_string() + } +} + +impl IntoCString for OsString { + #[cfg(unix)] + fn into_c_string(self) -> Result { + use std::os::unix::prelude::*; + let s: &OsStr = self.as_ref(); + Ok(try!(CString::new(s.as_bytes()))) + } + #[cfg(windows)] + fn into_c_string(self) -> Result { + match self.to_str() { + Some(s) => s.into_c_string(), + None => Err(Error::from_str("only valid unicode paths are accepted \ + on windows")), + } + } +} + +impl<'a> IntoCString for &'a [u8] { + fn into_c_string(self) -> Result { + Ok(try!(CString::new(self))) + } +} + +impl IntoCString for Vec { + fn into_c_string(self) -> Result { + Ok(try!(CString::new(self))) + } +} diff --git a/deps/git2-curl-0.2.4/Cargo.toml b/deps/git2-curl-0.2.4/Cargo.toml new file mode 100644 index 000000000..9f1c71e4d --- /dev/null +++ b/deps/git2-curl-0.2.4/Cargo.toml @@ -0,0 +1,33 @@ +[package] + +name = "git2-curl" +version = "0.2.4" +authors = ["Alex Crichton "] +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/git2-rs" +homepage = "https://github.com/alexcrichton/git2-rs" +documentation = "http://alexcrichton.com/git2-rs/git2-curl" +description = """ +Backend for an HTTP transport in libgit2 powered by libcurl. + +Intended to be used with the git2 crate. +""" + +[dependencies] +curl = "0.2" +url = "0.2" +log = "0.3" + +[dependencies.git2] +path = ".." +version = "0.2" + +[dev-dependencies] +civet = "0.7" +conduit = "0.7" +conduit-git-http-backend = "0.7" +tempdir = "0.3" + +[[test]] +name = "all" +harness = false diff --git a/deps/git2-curl-0.2.4/src/lib.rs b/deps/git2-curl-0.2.4/src/lib.rs new file mode 100644 index 000000000..cfa50632a --- /dev/null +++ b/deps/git2-curl-0.2.4/src/lib.rs @@ -0,0 +1,211 @@ +//! A crate for using libcurl as a backend for HTTP git requests with git2-rs. +//! +//! This crate provides one public function, `register`, which will register +//! a custom HTTP transport with libcurl for any HTTP requests made by libgit2. +//! At this time the `register` function is unsafe for the same reasons that +//! `git2::transport::register` is also unsafe. +//! +//! It is not recommended to use this crate wherever possible. The current +//! libcurl backend used, `curl-rust`, only supports executing a request in one +//! method call implying no streaming support. This consequently means that +//! when a repository is cloned the entire contents of the repo are downloaded +//! into memory, and *then* written off to disk by libgit2 afterwards. It +//! should be possible to alleviate this problem in the future. +//! +//! > **NOTE**: At this time this crate likely does not support a `git push` +//! > operation, only clones. + +#![doc(html_root_url = "http://alexcrichton.com/git2-rs")] + +extern crate git2; +extern crate curl; +extern crate url; +#[macro_use] extern crate log; + +use std::io::prelude::*; +use std::io::{self, Cursor}; +use std::sync::{Once, ONCE_INIT, Arc, Mutex}; +use std::error; + +use curl::http::handle::Method; +use curl::http::{Handle, Request}; +use git2::Error; +use git2::transport::{SmartSubtransportStream}; +use git2::transport::{Transport, SmartSubtransport, Service}; +use url::Url; + +struct CurlTransport { + handle: Arc>, +} + +struct CurlSubtransport { + handle: Arc>, + service: &'static str, + url_path: &'static str, + base_url: String, + method: Method, + reader: Option>>, + sent_request: bool, +} + +struct MyHandle(Handle); +unsafe impl Send for MyHandle {} // Handle is not send... + +/// Register the libcurl backend for HTTP requests made by libgit2. +/// +/// This function takes one parameter, a `handle`, which is used to perform all +/// future HTTP requests. The handle can be previously configured with +/// information such as proxies, SSL information, etc. +/// +/// This function is unsafe largely for the same reasons as +/// `git2::transport::register`: +/// +/// * The function needs to be synchronized against all other creations of +/// transport (any API calls to libgit2). +/// * The function will leak `handle` as once registered it is not currently +/// possible to unregister the backend. +/// +/// This function may be called concurrently, but only the first `handle` will +/// be used. All others will be discarded. +pub unsafe fn register(handle: Handle) { + static INIT: Once = ONCE_INIT; + + let handle = Arc::new(Mutex::new(MyHandle(handle))); + let handle2 = handle.clone(); + INIT.call_once(move || { + git2::transport::register("http", move |remote| { + factory(remote, handle.clone()) + }).unwrap(); + git2::transport::register("https", move |remote| { + factory(remote, handle2.clone()) + }).unwrap(); + }); +} + +fn factory(remote: &git2::Remote, handle: Arc>) + -> Result { + Transport::smart(remote, true, CurlTransport { handle: handle }) +} + +impl SmartSubtransport for CurlTransport { + fn action(&self, url: &str, action: Service) + -> Result, Error> { + let (service, path, method) = match action { + Service::UploadPackLs => { + ("upload-pack", "/info/refs?service=git-upload-pack", Method::Get) + } + Service::UploadPack => { + ("upload-pack", "/git-upload-pack", Method::Post) + } + Service::ReceivePackLs => { + ("receive-pack", "/info/refs?service=git-receive-pack", + Method::Get) + } + Service::ReceivePack => { + ("receive-pack", "/git-receive-pack", Method::Post) + } + }; + info!("action {} {}", service, path); + Ok(Box::new(CurlSubtransport { + handle: self.handle.clone(), + service: service, + url_path: path, + base_url: url.to_string(), + method: method, + reader: None, + sent_request: false, + })) + } + + fn close(&self) -> Result<(), Error> { + Ok(()) // ... + } +} + +impl CurlSubtransport { + fn err>>(&self, err: E) -> io::Error { + io::Error::new(io::ErrorKind::Other, err) + } + + fn execute(&mut self, mut data: &[u8]) -> io::Result<()> { + if self.sent_request { + return Err(self.err("already sent HTTP request")) + } + let agent = format!("git/1.0 (git2-curl {})", env!("CARGO_PKG_VERSION")); + + // Parse our input URL to figure out the host + let url = format!("{}{}", self.base_url, self.url_path); + let parsed = try!(Url::parse(&url).map_err(|_| { + self.err("invalid url, failed to parse") + })); + let host = match parsed.host() { + Some(host) => host.to_string(), + None => return Err(self.err("invalid url, did not have a host")), + }; + + // Prep the request + debug!("request to {}", url); + let mut h = self.handle.lock().unwrap(); + let mut req = Request::new(&mut h.0, self.method) + .uri(url) + .header("User-Agent", &agent) + .header("Host", &host) + .follow_redirects(true); + if data.len() > 0 { + req = req.body(&mut data) + .content_length(data.len()) + .header("Accept", &format!("application/x-git-{}-result", + self.service)) + .header("Content-Type", + &format!("application/x-git-{}-request", + self.service)); + } else { + req = req.header("Accept", "*/*"); + } + + // Send the request + let resp = try!(req.exec().map_err(|e| self.err(e))); + debug!("response: {}", resp); + if resp.get_code() != 200 { + return Err(self.err(&format!("failed to receive HTTP 200 response: \ + got {}", resp.get_code())[..])) + } + + // Check returned headers + let expected = match self.method { + Method::Get => format!("application/x-git-{}-advertisement", + self.service), + _ => format!("application/x-git-{}-result", self.service), + }; + if &resp.get_header("content-type") != &[expected.clone()] { + return Err(self.err(&format!("invalid Content-Type header: \ + found `{:?}` expected `{}`", + resp.get_header("Content-Type"), + expected)[..])) + } + + // Ok, time to read off some data. + let rdr = Cursor::new(resp.move_body()); + self.reader = Some(rdr); + Ok(()) + } +} + +impl Read for CurlSubtransport { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + if self.reader.is_none() { + try!(self.execute(&[])); + } + self.reader.as_mut().unwrap().read(buf) + } +} + +impl Write for CurlSubtransport { + fn write(&mut self, data: &[u8]) -> io::Result { + if self.reader.is_none() { + try!(self.execute(data)); + } + Ok(data.len()) + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } +} diff --git a/deps/git2-curl-0.2.4/tests/all.rs b/deps/git2-curl-0.2.4/tests/all.rs new file mode 100644 index 000000000..609617222 --- /dev/null +++ b/deps/git2-curl-0.2.4/tests/all.rs @@ -0,0 +1,68 @@ +extern crate conduit_git_http_backend as git_backend; +extern crate git2_curl; +extern crate civet; +extern crate conduit; +extern crate curl; +extern crate git2; +extern crate tempdir; + +use civet::{Server, Config}; +use std::fs::File; +use std::path::Path; +use tempdir::TempDir; + +const PORT: u16 = 7848; + +fn main() { + unsafe { + let h = curl::http::handle::Handle::new(); + git2_curl::register(h.timeout(1000)); + } + + // Spin up a server for git-http-backend + let td = TempDir::new("wut").unwrap(); + let _a = Server::start(Config { port: PORT, threads: 1 }, + git_backend::Serve(td.path().to_path_buf())); + + // Prep a repo with one file called `foo` + let sig = git2::Signature::now("foo", "bar").unwrap(); + let r1 = git2::Repository::init(td.path()).unwrap(); + File::create(&td.path().join(".git").join("git-daemon-export-ok")).unwrap(); + { + let mut index = r1.index().unwrap(); + File::create(&td.path().join("foo")).unwrap(); + index.add_path(Path::new("foo")).unwrap(); + index.write().unwrap(); + let tree_id = index.write_tree().unwrap(); + r1.commit(Some("HEAD"), &sig, &sig, "test", + &r1.find_tree(tree_id).unwrap(), + &[]).unwrap(); + } + + // Clone through the git-http-backend + let td2 = TempDir::new("wut2").unwrap(); + let r = git2::Repository::clone(&format!("http://localhost:{}", PORT), + td2.path()).unwrap(); + assert!(File::open(&td2.path().join("foo")).is_ok()); + { + File::create(&td.path().join("bar")).unwrap(); + let mut index = r1.index().unwrap(); + index.add_path(&Path::new("bar")).unwrap(); + index.write().unwrap(); + let tree_id = index.write_tree().unwrap(); + let parent = r1.head().ok().and_then(|h| h.target()).unwrap(); + let parent = r1.find_commit(parent).unwrap(); + r1.commit(Some("HEAD"), &sig, &sig, "test", + &r1.find_tree(tree_id).unwrap(), + &[&parent]).unwrap(); + } + + let mut remote = r.find_remote("origin").unwrap(); + remote.fetch(&["refs/heads/*:refs/heads/*"], None).unwrap(); + let b = r.find_branch("master", git2::BranchType::Local).unwrap(); + let id = b.get().target().unwrap(); + let obj = r.find_object(id, None).unwrap(); + r.reset(&obj, git2::ResetType::Hard, None).unwrap();; + + assert!(File::open(&td2.path().join("bar")).is_ok()); +} diff --git a/deps/git2-curl-0.2.4/tests/tempdir.rs b/deps/git2-curl-0.2.4/tests/tempdir.rs new file mode 100644 index 000000000..cd5f459e4 --- /dev/null +++ b/deps/git2-curl-0.2.4/tests/tempdir.rs @@ -0,0 +1,18 @@ +use std::old_io; +use std::io; +use std::path; + +pub struct TempDir { + inner: old_io::TempDir, +} + +impl TempDir { + pub fn new(prefix: &str) -> io::Result { + Ok(TempDir { inner: old_io::TempDir::new(prefix).unwrap() }) + } + + pub fn path(&self) -> &path::Path { + path::Path::new(self.inner.path().as_str().unwrap()) + } +} + diff --git a/deps/glob-0.2.10/.gitignore b/deps/glob-0.2.10/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/glob-0.2.10/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/glob-0.2.10/.travis.yml b/deps/glob-0.2.10/.travis.yml new file mode 100644 index 000000000..bc5f3ba5e --- /dev/null +++ b/deps/glob-0.2.10/.travis.yml @@ -0,0 +1,19 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: I3a1njiqfFW9TpMKB715bpq3qHmsSmue/ahYbXhYbRoskWDWk+ruSKHS/X3nvSXY2Vv9oBCFaWldQvKdPtbpLYlfnIfquvUSzGzT3BW8bOAU6EY6+MQiToDln+xlcfjlSqBF4RGyrZtmuXzC1xXPKotG6jfUT1+7iOgaXLxyaRU= +notifications: + email: + on_success: never diff --git a/deps/glob-0.2.10/Cargo.toml b/deps/glob-0.2.10/Cargo.toml new file mode 100644 index 000000000..504499a3c --- /dev/null +++ b/deps/glob-0.2.10/Cargo.toml @@ -0,0 +1,15 @@ +[package] + +name = "glob" +version = "0.2.10" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +homepage = "https://github.com/rust-lang/glob" +repository = "https://github.com/rust-lang/glob" +documentation = "http://doc.rust-lang.org/glob" +description = """ +Support for matching file paths against Unix shell style patterns. +""" + +[dev-dependencies] +tempdir = "0.3" diff --git a/deps/glob-0.2.10/LICENSE-APACHE b/deps/glob-0.2.10/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/glob-0.2.10/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/glob-0.2.10/LICENSE-MIT b/deps/glob-0.2.10/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/glob-0.2.10/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/glob-0.2.10/README.md b/deps/glob-0.2.10/README.md new file mode 100644 index 000000000..5da388821 --- /dev/null +++ b/deps/glob-0.2.10/README.md @@ -0,0 +1,24 @@ +glob +==== + +Support for matching file paths against Unix shell style patterns. + +[![Build Status](https://travis-ci.org/rust-lang/glob.svg?branch=master)](https://travis-ci.org/rust-lang/glob) + +[Documentation](http://doc.rust-lang.org/glob) + +## Usage + +To use `glob`, add this to your `Cargo.toml`: + +```toml +[dependencies] +glob = "*" +``` + +And add this to your crate root: + +```rust +extern crate glob; +``` + diff --git a/deps/glob-0.2.10/src/lib.rs b/deps/glob-0.2.10/src/lib.rs new file mode 100644 index 000000000..8102f0d1e --- /dev/null +++ b/deps/glob-0.2.10/src/lib.rs @@ -0,0 +1,1245 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Support for matching file paths against Unix shell style patterns. +//! +//! The `glob` and `glob_with` functions, in concert with the `Paths` +//! type, allow querying the filesystem for all files that match a particular +//! pattern - just like the libc `glob` function (for an example see the `glob` +//! documentation). The methods on the `Pattern` type provide functionality +//! for checking if individual paths match a particular pattern - in a similar +//! manner to the libc `fnmatch` function +//! For consistency across platforms, and for Windows support, this module +//! is implemented entirely in Rust rather than deferring to the libc +//! `glob`/`fnmatch` functions. + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/glob/")] +#![cfg_attr(all(test, windows), feature(std_misc))] + +use std::ascii::AsciiExt; +use std::cell::Cell; +use std::cmp; +use std::fmt; +use std::fs; +use std::io::prelude::*; +use std::io; +use std::path::{self, Path, PathBuf, Component}; +use std::str::FromStr; + +use PatternToken::{Char, AnyChar, AnySequence, AnyRecursiveSequence, AnyWithin}; +use PatternToken::AnyExcept; +use CharSpecifier::{SingleChar, CharRange}; +use MatchResult::{Match, SubPatternDoesntMatch, EntirePatternDoesntMatch}; + +/// An iterator that yields `Path`s from the filesystem that match a particular +/// pattern. +/// +/// Note that it yields `GlobResult` in order to report any `IoErrors` that may +/// arise during iteration. If a directory matches but is unreadable, +/// thereby preventing its contents from being checked for matches, a +/// `GlobError` is returned to express this. +/// +/// See the `glob` function for more details. +pub struct Paths { + dir_patterns: Vec, + require_dir: bool, + options: MatchOptions, + todo: Vec>, + scope: Option, +} + +/// Return an iterator that produces all the Paths that match the given pattern, +/// which may be absolute or relative to the current working directory. +/// +/// This may return an error if the pattern is invalid. +/// +/// This method uses the default match options and is equivalent to calling +/// `glob_with(pattern, MatchOptions::new())`. Use `glob_with` directly if you +/// want to use non-default match options. +/// +/// When iterating, each result is a `GlobResult` which expresses the +/// possibility that there was an `IoError` when attempting to read the contents +/// of the matched path. In other words, each item returned by the iterator +/// will either be an `Ok(Path)` if the path matched, or an `Err(GlobError)` if +/// the path (partially) matched _but_ its contents could not be read in order +/// to determine if its contents matched. +/// +/// See the `Paths` documentation for more information. +/// +/// # Example +/// +/// Consider a directory `/media/pictures` containing only the files +/// `kittens.jpg`, `puppies.jpg` and `hamsters.gif`: +/// +/// ```rust +/// use glob::glob; +/// +/// for entry in glob("/media/pictures/*.jpg").unwrap() { +/// match entry { +/// Ok(path) => println!("{:?}", path.display()), +/// +/// // if the path matched but was unreadable, +/// // thereby preventing its contents from matching +/// Err(e) => println!("{:?}", e), +/// } +/// } +/// ``` +/// +/// The above code will print: +/// +/// ```ignore +/// /media/pictures/kittens.jpg +/// /media/pictures/puppies.jpg +/// ``` +/// +/// If you want to ignore unreadable paths, you can use something like +/// `filter_map`: +/// +/// ```rust +/// use glob::glob; +/// use std::result::Result; +/// +/// for path in glob("/media/pictures/*.jpg").unwrap().filter_map(Result::ok) { +/// println!("{}", path.display()); +/// } +/// ``` +/// +pub fn glob(pattern: &str) -> Result { + glob_with(pattern, &MatchOptions::new()) +} + +/// Return an iterator that produces all the Paths that match the given pattern, +/// which may be absolute or relative to the current working directory. +/// +/// This may return an error if the pattern is invalid. +/// +/// This function accepts Unix shell style patterns as described by +/// `Pattern::new(..)`. The options given are passed through unchanged to +/// `Pattern::matches_with(..)` with the exception that +/// `require_literal_separator` is always set to `true` regardless of the value +/// passed to this function. +/// +/// Paths are yielded in alphabetical order. +pub fn glob_with(pattern: &str, options: &MatchOptions) + -> Result { + // make sure that the pattern is valid first, else early return with error + let _compiled = try!(Pattern::new(pattern)); + + #[cfg(windows)] + fn check_windows_verbatim(p: &Path) -> bool { + use std::path::Prefix; + match p.components().next() { + Some(Component::Prefix(ref p)) => p.kind().is_verbatim(), + _ => false + } + } + #[cfg(not(windows))] + fn check_windows_verbatim(_: &Path) -> bool { false } + + #[cfg(windows)] + fn to_scope(p: &Path) -> PathBuf { + // FIXME handle volume relative paths here + p.to_path_buf() + } + #[cfg(not(windows))] + fn to_scope(p: &Path) -> PathBuf { p.to_path_buf() } + + let mut components = Path::new(pattern).components().peekable(); + loop { + match components.peek() { + Some(&Component::Prefix(..)) | + Some(&Component::RootDir) => { components.next(); } + _ => break, + } + } + let rest = components.map(|s| s.as_os_str()).collect::(); + let normalized_pattern = Path::new(pattern).iter().collect::(); + let root_len = normalized_pattern.to_str().unwrap().len() - + rest.to_str().unwrap().len(); + let root = if root_len > 0 {Some(Path::new(&pattern[..root_len]))} + else {None}; + + if root_len > 0 && check_windows_verbatim(root.unwrap()) { + // FIXME: How do we want to handle verbatim paths? I'm inclined to + // return nothing, since we can't very well find all UNC shares with a + // 1-letter server name. + return Ok(Paths { + dir_patterns: Vec::new(), + require_dir: false, + options: options.clone(), + todo: Vec::new(), + scope: None, + }); + } + + let scope = root.map(to_scope).unwrap_or_else(|| PathBuf::from(".")); + + let mut dir_patterns = Vec::new(); + let components = pattern[cmp::min(root_len, pattern.len())..] + .split_terminator(path::is_separator); + + for component in components { + let compiled = try!(Pattern::new(component)); + dir_patterns.push(compiled); + } + + if root_len == pattern.len() { + dir_patterns.push(Pattern { + original: "".to_string(), + tokens: Vec::new(), + is_recursive: false, + }); + } + + let require_dir = pattern.chars().next_back().map(path::is_separator) == Some(true); + let todo = Vec::new(); + + Ok(Paths { + dir_patterns: dir_patterns, + require_dir: require_dir, + options: options.clone(), + todo: todo, + scope: Some(scope), + }) +} + +/// A glob iteration error. +/// +/// This is typically returned when a particular path cannot be read +/// to determine if its contents match the glob pattern. This is possible +/// if the program lacks the permissions, for example. +#[derive(Debug)] +pub struct GlobError { + path: PathBuf, + error: io::Error, +} + +impl GlobError { + /// The Path that the error corresponds to. + pub fn path(&self) -> &Path { &self.path } + + /// The error in question. + pub fn error(&self) -> &io::Error { &self.error } +} + +impl fmt::Display for GlobError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "attempting to read `{}` resulted in an error: {}", + self.path.display(), self.error) + } +} + +fn is_dir(p: &Path) -> bool { + fs::metadata(p).map(|m| m.is_dir()).unwrap_or(false) +} + +/// An alias for a glob iteration result. +/// +/// This represents either a matched path or a glob iteration error, +/// such as failing to read a particular directory's contents. +pub type GlobResult = Result; + +impl Iterator for Paths { + type Item = GlobResult; + + fn next(&mut self) -> Option { + // the todo buffer hasn't been initialized yet, so it's done at this + // point rather than in glob() so that the errors are unified that is, + // failing to fill the buffer is an iteration error construction of the + // iterator (i.e. glob()) only fails if it fails to compile the Pattern + if let Some(scope) = self.scope.take() { + if self.dir_patterns.len() > 0 { + // Shouldn't happen, but we're using -1 as a special index. + assert!(self.dir_patterns.len() < !0 as usize); + + fill_todo(&mut self.todo, &self.dir_patterns, + 0, &scope, &self.options); + } + } + + loop { + if self.dir_patterns.is_empty() || self.todo.is_empty() { + return None; + } + + let (path, mut idx) = match self.todo.pop().unwrap() { + Ok(pair) => pair, + Err(e) => return Some(Err(e)), + }; + + // idx -1: was already checked by fill_todo, maybe path was '.' or + // '..' that we can't match here because of normalization. + if idx == !0 as usize { + if self.require_dir && !is_dir(&path) { continue; } + return Some(Ok(path)); + } + + if self.dir_patterns[idx].is_recursive { + let mut next = idx; + + // collapse consecutive recursive patterns + while (next + 1) < self.dir_patterns.len() && + self.dir_patterns[next + 1].is_recursive { + next += 1; + } + + // the path is a directory, so it's a match + if is_dir(&path) { + // push this directory's contents + fill_todo(&mut self.todo, &self.dir_patterns, + next, &path, &self.options); + + // pattern ends in recursive pattern, so return this + // directory as a result + if next == self.dir_patterns.len() - 1 { + return Some(Ok(path)); + // advanced to the next pattern for this path + } else { + idx = next + 1; + } + // advanced to the next pattern for this path + } else if next != self.dir_patterns.len() - 1 { + idx = next + 1; + // not a directory and it's the last pattern, meaning no match + } else { + continue; + } + } + + // not recursive, so match normally + if self.dir_patterns[idx].matches_with({ + match path.file_name().and_then(|s| s.to_str()) { + // FIXME (#9639): How do we handle non-utf8 filenames? + // Ignore them for now Ideally we'd still match them + // against a * + None => continue, + Some(x) => x + } + }, &self.options) { + if idx == self.dir_patterns.len() - 1 { + // it is not possible for a pattern to match a directory + // *AND* its children so we don't need to check the + // children + + if !self.require_dir || is_dir(&path) { + return Some(Ok(path)); + } + } else { + fill_todo(&mut self.todo, &self.dir_patterns, + idx + 1, &path, &self.options); + } + } + } + } + +} + +/// A pattern parsing error. +#[derive(Debug)] +#[allow(missing_copy_implementations)] +pub struct PatternError { + /// The approximate character index of where the error occurred. + pub pos: usize, + + /// A message describing the error. + pub msg: &'static str, +} + +impl fmt::Display for PatternError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Pattern syntax error near position {}: {}", + self.pos, self.msg) + } +} + +/// A compiled Unix shell style pattern. +/// +/// `?` matches any single character +/// +/// `*` matches any (possibly empty) sequence of characters +/// +/// `**` matches the current directory and arbitrary subdirectories. This +/// sequence **must** form a single path component, so both `**a` and `b**` are +/// invalid and will result in an error. A sequence of more than two +/// consecutive `*` characters is also invalid. +/// +/// `[...]` matches any character inside the brackets. +/// Character sequences can also specify ranges +/// of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any +/// character between 0 and 9 inclusive. An unclosed bracket is invalid. +/// +/// `[!...]` is the negation of `[...]`, i.e. it matches any characters **not** +/// in the brackets. +/// +/// The metacharacters `?`, `*`, `[`, `]` can be matched by using brackets +/// (e.g. `[?]`). When a `]` occurs immediately following `[` or `[!` then +/// it is interpreted as being part of, rather then ending, the character +/// set, so `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively. +/// The `-` character can be specified inside a character sequence pattern by +/// placing it at the start or the end, e.g. `[abc-]`. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)] +pub struct Pattern { + original: String, + tokens: Vec, + is_recursive: bool, +} + +/// Show the original glob pattern. +impl fmt::Display for Pattern { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.original.fmt(f) + } +} + +impl FromStr for Pattern { + type Err = PatternError; + + fn from_str(s: &str) -> Result { + Pattern::new(s) + } +} + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +enum PatternToken { + Char(char), + AnyChar, + AnySequence, + AnyRecursiveSequence, + AnyWithin(Vec ), + AnyExcept(Vec ) +} + +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +enum CharSpecifier { + SingleChar(char), + CharRange(char, char) +} + +#[derive(Copy, Clone, PartialEq)] +enum MatchResult { + Match, + SubPatternDoesntMatch, + EntirePatternDoesntMatch +} + +const ERROR_WILDCARDS: &'static str = + "wildcards are either regular `*` or recursive `**`"; +const ERROR_RECURSIVE_WILDCARDS: &'static str = + "recursive wildcards must form a single path component"; +const ERROR_INVALID_RANGE: &'static str = + "invalid range pattern"; + +impl Pattern { + /// This function compiles Unix shell style patterns. + /// + /// An invalid glob pattern will yield an error. + pub fn new(pattern: &str) -> Result { + + let chars = pattern.chars().collect::>(); + let mut tokens = Vec::new(); + let mut is_recursive = false; + let mut i = 0; + + while i < chars.len() { + match chars[i] { + '?' => { + tokens.push(AnyChar); + i += 1; + } + '*' => { + let old = i; + + while i < chars.len() && chars[i] == '*' { + i += 1; + } + + let count = i - old; + + if count > 2 { + return Err( + PatternError { + pos: old + 2, + msg: ERROR_WILDCARDS, + }); + } else if count == 2 { + // ** can only be an entire path component + // i.e. a/**/b is valid, but a**/b or a/**b is not + // invalid matches are treated literally + let is_valid = + // is the beginning of the pattern or begins with '/' + if i == 2 || chars[i - count - 1] == '/' { + // it ends in a '/' + if i < chars.len() && chars[i] == '/' { + i += 1; + true + // or the pattern ends here + // this enables the existing globbing mechanism + } else if i == chars.len() { + true + // `**` ends in non-separator + } else { + return Err( + PatternError { + pos: i, + msg: ERROR_RECURSIVE_WILDCARDS, + }); + } + // `**` begins with non-separator + } else { + return Err( + PatternError { + pos: old - 1, + msg: ERROR_RECURSIVE_WILDCARDS, + }); + }; + + let tokens_len = tokens.len(); + + if is_valid { + // collapse consecutive AnyRecursiveSequence to a + // single one + if !(tokens_len > 1 && + tokens[tokens_len - 1] == AnyRecursiveSequence) { + is_recursive = true; + tokens.push(AnyRecursiveSequence); + } + } + } else { + tokens.push(AnySequence); + } + } + '[' => { + + if i + 4 <= chars.len() && chars[i + 1] == '!' { + match chars[i + 3..].iter().position(|x| *x == ']') { + None => (), + Some(j) => { + let chars = &chars[i + 2 .. i + 3 + j]; + let cs = parse_char_specifiers(chars); + tokens.push(AnyExcept(cs)); + i += j + 4; + continue; + } + } + } else if i + 3 <= chars.len() && chars[i + 1] != '!' { + match chars[i + 2..].iter().position(|x| *x == ']') { + None => (), + Some(j) => { + let cs = parse_char_specifiers(&chars[i + 1 .. + i + 2 + j]); + tokens.push(AnyWithin(cs)); + i += j + 3; + continue; + } + } + } + + // if we get here then this is not a valid range pattern + return Err( + PatternError { + pos: i, + msg: ERROR_INVALID_RANGE, + }); + } + c => { + tokens.push(Char(c)); + i += 1; + } + } + } + + Ok(Pattern { + tokens: tokens, + original: pattern.to_string(), + is_recursive: is_recursive, + }) + } + + /// Escape metacharacters within the given string by surrounding them in + /// brackets. The resulting string will, when compiled into a `Pattern`, + /// match the input string and nothing else. + pub fn escape(s: &str) -> String { + let mut escaped = String::new(); + for c in s.chars() { + match c { + // note that ! does not need escaping because it is only special + // inside brackets + '?' | '*' | '[' | ']' => { + escaped.push('['); + escaped.push(c); + escaped.push(']'); + } + c => { + escaped.push(c); + } + } + } + escaped + } + + /// Return if the given `str` matches this `Pattern` using the default + /// match options (i.e. `MatchOptions::new()`). + /// + /// # Example + /// + /// ```rust + /// use glob::Pattern; + /// + /// assert!(Pattern::new("c?t").unwrap().matches("cat")); + /// assert!(Pattern::new("k[!e]tteh").unwrap().matches("kitteh")); + /// assert!(Pattern::new("d*g").unwrap().matches("doog")); + /// ``` + pub fn matches(&self, str: &str) -> bool { + self.matches_with(str, &MatchOptions::new()) + } + + /// Return if the given `Path`, when converted to a `str`, matches this + /// `Pattern` using the default match options (i.e. `MatchOptions::new()`). + pub fn matches_path(&self, path: &Path) -> bool { + // FIXME (#9639): This needs to handle non-utf8 paths + path.to_str().map_or(false, |s| { + self.matches(s) + }) + } + + /// Return if the given `str` matches this `Pattern` using the specified + /// match options. + pub fn matches_with(&self, str: &str, options: &MatchOptions) -> bool { + self.matches_from(None, str, 0, options) == Match + } + + /// Return if the given `Path`, when converted to a `str`, matches this + /// `Pattern` using the specified match options. + pub fn matches_path_with(&self, path: &Path, options: &MatchOptions) -> bool { + // FIXME (#9639): This needs to handle non-utf8 paths + path.to_str().map_or(false, |s| { + self.matches_with(s, options) + }) + } + + /// Access the original glob pattern. + pub fn as_str<'a>(&'a self) -> &'a str { &self.original } + + fn matches_from(&self, + prev_char: Option, + mut file: &str, + i: usize, + options: &MatchOptions) -> MatchResult { + + let prev_char = Cell::new(prev_char); + + let require_literal = |c| { + (options.require_literal_separator && path::is_separator(c)) || + (options.require_literal_leading_dot && c == '.' + && path::is_separator(prev_char.get().unwrap_or('/'))) + }; + + for (ti, token) in self.tokens[i..].iter().enumerate() { + match *token { + AnySequence | AnyRecursiveSequence => { + loop { + match self.matches_from(prev_char.get(), file, + i + ti + 1, options) { + SubPatternDoesntMatch => (), // keep trying + m => return m, + } + + if file.len() == 0 { return EntirePatternDoesntMatch } + let c = file.chars().next().unwrap(); + let next = &file[c.len_utf8()..]; + + if let AnySequence = *token { + if require_literal(c) { + return SubPatternDoesntMatch; + } + } + + prev_char.set(Some(c)); + file = next; + } + } + _ => { + if file.len() == 0 { return EntirePatternDoesntMatch } + let c = file.chars().next().unwrap(); + let next = &file[c.len_utf8()..]; + + let matches = match *token { + AnyChar => { + !require_literal(c) + } + AnyWithin(ref specifiers) => { + !require_literal(c) && + in_char_specifiers(&specifiers, + c, + options) + } + AnyExcept(ref specifiers) => { + !require_literal(c) && + !in_char_specifiers(&specifiers, + c, + options) + } + Char(c2) => { + chars_eq(c, c2, options.case_sensitive) + } + AnySequence | AnyRecursiveSequence => { + unreachable!() + } + }; + if !matches { + return SubPatternDoesntMatch; + } + prev_char.set(Some(c)); + file = next; + } + } + } + + if file.is_empty() { + Match + } else { + SubPatternDoesntMatch + } + } + +} + +// Fills `todo` with paths under `path` to be matched by `patterns[idx]`, +// special-casing patterns to match `.` and `..`, and avoiding `readdir()` +// calls when there are no metacharacters in the pattern. +fn fill_todo(todo: &mut Vec>, + patterns: &[Pattern], + idx: usize, + path: &Path, + options: &MatchOptions) { + // convert a pattern that's just many Char(_) to a string + fn pattern_as_str(pattern: &Pattern) -> Option { + let mut s = String::new(); + for token in pattern.tokens.iter() { + match *token { + Char(c) => s.push(c), + _ => return None + } + } + return Some(s); + } + + let add = |todo: &mut Vec<_>, next_path: PathBuf| { + if idx + 1 == patterns.len() { + // We know it's good, so don't make the iterator match this path + // against the pattern again. In particular, it can't match + // . or .. globs since these never show up as path components. + todo.push(Ok((next_path, !0 as usize))); + } else { + fill_todo(todo, patterns, idx + 1, &next_path, options); + } + }; + + let pattern = &patterns[idx]; + let is_dir = is_dir(path); + let curdir = path == Path::new("."); + match pattern_as_str(pattern) { + Some(s) => { + // This pattern component doesn't have any metacharacters, so we + // don't need to read the current directory to know where to + // continue. So instead of passing control back to the iterator, + // we can just check for that one entry and potentially recurse + // right away. + let special = "." == s || ".." == s; + let next_path = if curdir {PathBuf::from(s)} else {path.join(&s)}; + if (special && is_dir) || (!special && fs::metadata(&next_path).is_ok()) { + add(todo, next_path); + } + }, + None if is_dir => { + let dirs = fs::read_dir(path).and_then(|d| { + d.map(|e| e.map(|e| { + if curdir { + PathBuf::from(e.path().file_name().unwrap()) + } else { + e.path() + } + })).collect::, _>>() + }); + match dirs { + Ok(mut children) => { + children.sort_by(|p1, p2| p2.file_name().cmp(&p1.file_name())); + todo.extend(children.into_iter().map(|x| Ok((x, idx)))); + + // Matching the special directory entries . and .. that + // refer to the current and parent directory respectively + // requires that the pattern has a leading dot, even if the + // `MatchOptions` field `require_literal_leading_dot` is not + // set. + if pattern.tokens.len() > 0 && pattern.tokens[0] == Char('.') { + for &special in [".", ".."].iter() { + if pattern.matches_with(special, options) { + add(todo, path.join(special)); + } + } + } + }, + Err(e) => { + todo.push(Err(GlobError { + path: path.to_path_buf(), + error: e, + })); + } + } + } + None => {/* not a directory, nothing more to find */} + } +} + +fn parse_char_specifiers(s: &[char]) -> Vec { + let mut cs = Vec::new(); + let mut i = 0; + while i < s.len() { + if i + 3 <= s.len() && s[i + 1] == '-' { + cs.push(CharRange(s[i], s[i + 2])); + i += 3; + } else { + cs.push(SingleChar(s[i])); + i += 1; + } + } + cs +} + +fn in_char_specifiers(specifiers: &[CharSpecifier], c: char, options: &MatchOptions) -> bool { + + for &specifier in specifiers.iter() { + match specifier { + SingleChar(sc) => { + if chars_eq(c, sc, options.case_sensitive) { + return true; + } + } + CharRange(start, end) => { + + // FIXME: work with non-ascii chars properly (issue #1347) + if !options.case_sensitive && c.is_ascii() && + start.is_ascii() && end.is_ascii() { + + let start = start.to_ascii_lowercase(); + let end = end.to_ascii_lowercase(); + + let start_up = start.to_uppercase().next().unwrap(); + let end_up = end.to_uppercase().next().unwrap(); + + // only allow case insensitive matching when + // both start and end are within a-z or A-Z + if start != start_up && end != end_up { + let c = c.to_ascii_lowercase(); + if c >= start && c <= end { + return true; + } + } + } + + if c >= start && c <= end { + return true; + } + } + } + } + + false +} + +/// A helper function to determine if two chars are (possibly case-insensitively) equal. +fn chars_eq(a: char, b: char, case_sensitive: bool) -> bool { + if cfg!(windows) && path::is_separator(a) && path::is_separator(b) { + true + } else if !case_sensitive && a.is_ascii() && b.is_ascii() { + // FIXME: work with non-ascii chars properly (issue #9084) + a.to_ascii_lowercase() == b.to_ascii_lowercase() + } else { + a == b + } +} + + +/// Configuration options to modify the behaviour of `Pattern::matches_with(..)` +#[allow(missing_copy_implementations)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +pub struct MatchOptions { + /// Whether or not patterns should be matched in a case-sensitive manner. + /// This currently only considers upper/lower case relationships between + /// ASCII characters, but in future this might be extended to work with + /// Unicode. + pub case_sensitive: bool, + + /// If this is true then path-component separator characters (e.g. `/` on + /// Posix) must be matched by a literal `/`, rather than by `*` or `?` or + /// `[...]` + pub require_literal_separator: bool, + + /// If this is true then paths that contain components that start with a `.` + /// will not match unless the `.` appears literally in the pattern: `*`, `?` + /// or `[...]` will not match. This is useful because such files are + /// conventionally considered hidden on Unix systems and it might be + /// desirable to skip them when listing files. + pub require_literal_leading_dot: bool +} + +impl MatchOptions { + + /// Constructs a new `MatchOptions` with default field values. This is used + /// when calling functions that do not take an explicit `MatchOptions` + /// parameter. + /// + /// This function always returns this value: + /// + /// ```rust,ignore + /// MatchOptions { + /// case_sensitive: true, + /// require_literal_separator: false. + /// require_literal_leading_dot: false + /// } + /// ``` + pub fn new() -> MatchOptions { + MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: false + } + } + +} + +#[cfg(test)] +mod test { + use std::path::Path; + use super::{glob, Pattern, MatchOptions}; + + #[test] + fn test_pattern_from_str() { + assert!("a*b".parse::().unwrap().matches("a_b")); + assert!("a/**b".parse::().unwrap_err().pos == 4); + } + + #[test] + fn test_wildcard_errors() { + assert!(Pattern::new("a/**b").unwrap_err().pos == 4); + assert!(Pattern::new("a/bc**").unwrap_err().pos == 3); + assert!(Pattern::new("a/*****").unwrap_err().pos == 4); + assert!(Pattern::new("a/b**c**d").unwrap_err().pos == 2); + assert!(Pattern::new("a**b").unwrap_err().pos == 0); + } + + #[test] + fn test_unclosed_bracket_errors() { + assert!(Pattern::new("abc[def").unwrap_err().pos == 3); + assert!(Pattern::new("abc[!def").unwrap_err().pos == 3 ); + assert!(Pattern::new("abc[").unwrap_err().pos == 3); + assert!(Pattern::new("abc[!").unwrap_err().pos == 3); + assert!(Pattern::new("abc[d").unwrap_err().pos == 3); + assert!(Pattern::new("abc[!d").unwrap_err().pos == 3); + assert!(Pattern::new("abc[]").unwrap_err().pos == 3); + assert!(Pattern::new("abc[!]").unwrap_err().pos == 3); + } + + #[test] + fn test_glob_errors() { + assert!(glob("a/**b").err().unwrap().pos == 4); + assert!(glob("abc[def").err().unwrap().pos == 3); + } + + // this test assumes that there is a /root directory and that + // the user running this test is not root or otherwise doesn't + // have permission to read its contents + #[cfg(unix)] + #[test] + fn test_iteration_errors() { + use std::io; + let mut iter = glob("/root/*").unwrap(); + + // GlobErrors shouldn't halt iteration + let next = iter.next(); + assert!(next.is_some()); + + let err = next.unwrap(); + assert!(err.is_err()); + + let err = err.err().unwrap(); + assert!(err.path() == Path::new("/root")); + assert!(err.error().kind() == io::ErrorKind::PermissionDenied); + } + + #[test] + fn test_absolute_pattern() { + assert!(glob("/").unwrap().next().is_some()); + assert!(glob("//").unwrap().next().is_some()); + + // assume that the filesystem is not empty! + assert!(glob("/*").unwrap().next().is_some()); + + #[cfg(not(windows))] fn win() {} + + #[cfg(windows)] fn win() { + use std::env::current_dir; + use std::ffi::AsOsStr; + + // check windows absolute paths with host/device components + let root_with_device = + current_dir().ok().and_then(|p| p.prefix().map(|p| p.join("*"))).unwrap(); + // FIXME (#9639): This needs to handle non-utf8 paths + assert!(glob(root_with_device.as_os_str().to_str().unwrap()).unwrap().next().is_some()); + } + win() + } + + #[test] + fn test_wildcards() { + assert!(Pattern::new("a*b").unwrap().matches("a_b")); + assert!(Pattern::new("a*b*c").unwrap().matches("abc")); + assert!(!Pattern::new("a*b*c").unwrap().matches("abcd")); + assert!(Pattern::new("a*b*c").unwrap().matches("a_b_c")); + assert!(Pattern::new("a*b*c").unwrap().matches("a___b___c")); + assert!(Pattern::new("abc*abc*abc").unwrap().matches("abcabcabcabcabcabcabc")); + assert!(!Pattern::new("abc*abc*abc").unwrap().matches("abcabcabcabcabcabcabca")); + assert!(Pattern::new("a*a*a*a*a*a*a*a*a").unwrap().matches("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); + assert!(Pattern::new("a*b[xyz]c*d").unwrap().matches("abxcdbxcddd")); + } + + #[test] + fn test_recursive_wildcards() { + let pat = Pattern::new("some/**/needle.txt").unwrap(); + assert!(pat.matches("some/needle.txt")); + assert!(pat.matches("some/one/needle.txt")); + assert!(pat.matches("some/one/two/needle.txt")); + assert!(pat.matches("some/other/needle.txt")); + assert!(!pat.matches("some/other/notthis.txt")); + + // a single ** should be valid, for globs + assert!(Pattern::new("**").unwrap().is_recursive); + + // collapse consecutive wildcards + let pat = Pattern::new("some/**/**/needle.txt").unwrap(); + assert!(pat.matches("some/needle.txt")); + assert!(pat.matches("some/one/needle.txt")); + assert!(pat.matches("some/one/two/needle.txt")); + assert!(pat.matches("some/other/needle.txt")); + assert!(!pat.matches("some/other/notthis.txt")); + + // ** can begin the pattern + let pat = Pattern::new("**/test").unwrap(); + assert!(pat.matches("one/two/test")); + assert!(pat.matches("one/test")); + assert!(pat.matches("test")); + + // /** can begin the pattern + let pat = Pattern::new("/**/test").unwrap(); + assert!(pat.matches("/one/two/test")); + assert!(pat.matches("/one/test")); + assert!(pat.matches("/test")); + assert!(!pat.matches("/one/notthis")); + assert!(!pat.matches("/notthis")); + } + + #[test] + fn test_lots_of_files() { + // this is a good test because it touches lots of differently named files + glob("/*/*/*/*").unwrap().skip(10000).next(); + } + + #[test] + fn test_range_pattern() { + + let pat = Pattern::new("a[0-9]b").unwrap(); + for i in 0..10 { + assert!(pat.matches(&format!("a{}b", i))); + } + assert!(!pat.matches("a_b")); + + let pat = Pattern::new("a[!0-9]b").unwrap(); + for i in 0..10 { + assert!(!pat.matches(&format!("a{}b", i))); + } + assert!(pat.matches("a_b")); + + let pats = ["[a-z123]", "[1a-z23]", "[123a-z]"]; + for &p in pats.iter() { + let pat = Pattern::new(p).unwrap(); + for c in "abcdefghijklmnopqrstuvwxyz".chars() { + assert!(pat.matches(&c.to_string())); + } + for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() { + let options = MatchOptions {case_sensitive: false, .. MatchOptions::new()}; + assert!(pat.matches_with(&c.to_string(), &options)); + } + assert!(pat.matches("1")); + assert!(pat.matches("2")); + assert!(pat.matches("3")); + } + + let pats = ["[abc-]", "[-abc]", "[a-c-]"]; + for &p in pats.iter() { + let pat = Pattern::new(p).unwrap(); + assert!(pat.matches("a")); + assert!(pat.matches("b")); + assert!(pat.matches("c")); + assert!(pat.matches("-")); + assert!(!pat.matches("d")); + } + + let pat = Pattern::new("[2-1]").unwrap(); + assert!(!pat.matches("1")); + assert!(!pat.matches("2")); + + assert!(Pattern::new("[-]").unwrap().matches("-")); + assert!(!Pattern::new("[!-]").unwrap().matches("-")); + } + + #[test] + fn test_pattern_matches() { + let txt_pat = Pattern::new("*hello.txt").unwrap(); + assert!(txt_pat.matches("hello.txt")); + assert!(txt_pat.matches("gareth_says_hello.txt")); + assert!(txt_pat.matches("some/path/to/hello.txt")); + assert!(txt_pat.matches("some\\path\\to\\hello.txt")); + assert!(txt_pat.matches("/an/absolute/path/to/hello.txt")); + assert!(!txt_pat.matches("hello.txt-and-then-some")); + assert!(!txt_pat.matches("goodbye.txt")); + + let dir_pat = Pattern::new("*some/path/to/hello.txt").unwrap(); + assert!(dir_pat.matches("some/path/to/hello.txt")); + assert!(dir_pat.matches("a/bigger/some/path/to/hello.txt")); + assert!(!dir_pat.matches("some/path/to/hello.txt-and-then-some")); + assert!(!dir_pat.matches("some/other/path/to/hello.txt")); + } + + #[test] + fn test_pattern_escape() { + let s = "_[_]_?_*_!_"; + assert_eq!(Pattern::escape(s), "_[[]_[]]_[?]_[*]_!_".to_string()); + assert!(Pattern::new(&Pattern::escape(s)).unwrap().matches(s)); + } + + #[test] + fn test_pattern_matches_case_insensitive() { + + let pat = Pattern::new("aBcDeFg").unwrap(); + let options = MatchOptions { + case_sensitive: false, + require_literal_separator: false, + require_literal_leading_dot: false + }; + + assert!(pat.matches_with("aBcDeFg", &options)); + assert!(pat.matches_with("abcdefg", &options)); + assert!(pat.matches_with("ABCDEFG", &options)); + assert!(pat.matches_with("AbCdEfG", &options)); + } + + #[test] + fn test_pattern_matches_case_insensitive_range() { + + let pat_within = Pattern::new("[a]").unwrap(); + let pat_except = Pattern::new("[!a]").unwrap(); + + let options_case_insensitive = MatchOptions { + case_sensitive: false, + require_literal_separator: false, + require_literal_leading_dot: false + }; + let options_case_sensitive = MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: false + }; + + assert!(pat_within.matches_with("a", &options_case_insensitive)); + assert!(pat_within.matches_with("A", &options_case_insensitive)); + assert!(!pat_within.matches_with("A", &options_case_sensitive)); + + assert!(!pat_except.matches_with("a", &options_case_insensitive)); + assert!(!pat_except.matches_with("A", &options_case_insensitive)); + assert!(pat_except.matches_with("A", &options_case_sensitive)); + } + + #[test] + fn test_pattern_matches_require_literal_separator() { + + let options_require_literal = MatchOptions { + case_sensitive: true, + require_literal_separator: true, + require_literal_leading_dot: false + }; + let options_not_require_literal = MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: false + }; + + assert!(Pattern::new("abc/def").unwrap().matches_with("abc/def", &options_require_literal)); + assert!(!Pattern::new("abc?def").unwrap().matches_with("abc/def", &options_require_literal)); + assert!(!Pattern::new("abc*def").unwrap().matches_with("abc/def", &options_require_literal)); + assert!(!Pattern::new("abc[/]def").unwrap().matches_with("abc/def", &options_require_literal)); + + assert!(Pattern::new("abc/def").unwrap().matches_with("abc/def", &options_not_require_literal)); + assert!(Pattern::new("abc?def").unwrap().matches_with("abc/def", &options_not_require_literal)); + assert!(Pattern::new("abc*def").unwrap().matches_with("abc/def", &options_not_require_literal)); + assert!(Pattern::new("abc[/]def").unwrap().matches_with("abc/def", &options_not_require_literal)); + } + + #[test] + fn test_pattern_matches_require_literal_leading_dot() { + + let options_require_literal_leading_dot = MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: true + }; + let options_not_require_literal_leading_dot = MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: false + }; + + let f = |options| Pattern::new("*.txt").unwrap().matches_with(".hello.txt", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(!f(&options_require_literal_leading_dot)); + + let f = |options| Pattern::new(".*.*").unwrap().matches_with(".hello.txt", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(f(&options_require_literal_leading_dot)); + + let f = |options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/.ccc", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(!f(&options_require_literal_leading_dot)); + + let f = |options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/c.c.c.", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(f(&options_require_literal_leading_dot)); + + let f = |options| Pattern::new("aaa/bbb/.*").unwrap().matches_with("aaa/bbb/.ccc", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(f(&options_require_literal_leading_dot)); + + let f = |options| Pattern::new("aaa/?bbb").unwrap().matches_with("aaa/.bbb", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(!f(&options_require_literal_leading_dot)); + + let f = |options| Pattern::new("aaa/[.]bbb").unwrap().matches_with("aaa/.bbb", options); + assert!(f(&options_not_require_literal_leading_dot)); + assert!(!f(&options_require_literal_leading_dot)); + } + + #[test] + fn test_matches_path() { + // on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this + // tests that / and \ are considered equivalent on windows + assert!(Pattern::new("a/b").unwrap().matches_path(&Path::new("a/b"))); + } +} diff --git a/deps/glob-0.2.10/tests/glob-std.rs b/deps/glob-0.2.10/tests/glob-std.rs new file mode 100644 index 000000000..e347858d3 --- /dev/null +++ b/deps/glob-0.2.10/tests/glob-std.rs @@ -0,0 +1,278 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-windows TempDir may cause IoError on windows: #10462 + +#![cfg_attr(test, deny(warnings))] + +extern crate glob; +extern crate tempdir; + +use glob::glob; +use std::env; +use std::path::PathBuf; +use std::fs; +use tempdir::TempDir; + +#[test] +fn main() { + fn mk_file(path: &str, directory: bool) { + if directory { + fs::create_dir(path).unwrap(); + } else { + fs::File::create(path).unwrap(); + } + } + + fn glob_vec(pattern: &str) -> Vec { + glob(pattern).unwrap().map(|r| r.unwrap()).collect() + } + + let root = TempDir::new("glob-tests"); + let root = root.ok().expect("Should have created a temp directory"); + assert!(env::set_current_dir(root.path()).is_ok()); + + mk_file("aaa", true); + mk_file("aaa/apple", true); + mk_file("aaa/orange", true); + mk_file("aaa/tomato", true); + mk_file("aaa/tomato/tomato.txt", false); + mk_file("aaa/tomato/tomoto.txt", false); + mk_file("bbb", true); + mk_file("bbb/specials", true); + mk_file("bbb/specials/!", false); + + // windows does not allow `*` or `?` characters to exist in filenames + if env::consts::FAMILY != "windows" { + mk_file("bbb/specials/*", false); + mk_file("bbb/specials/?", false); + } + + mk_file("bbb/specials/[", false); + mk_file("bbb/specials/]", false); + mk_file("ccc", true); + mk_file("xyz", true); + mk_file("xyz/x", false); + mk_file("xyz/y", false); + mk_file("xyz/z", false); + + mk_file("r", true); + mk_file("r/current_dir.md", false); + mk_file("r/one", true); + mk_file("r/one/a.md", false); + mk_file("r/one/another", true); + mk_file("r/one/another/a.md", false); + mk_file("r/one/another/deep", true); + mk_file("r/one/another/deep/spelunking.md", false); + mk_file("r/another", true); + mk_file("r/another/a.md", false); + mk_file("r/two", true); + mk_file("r/two/b.md", false); + mk_file("r/three", true); + mk_file("r/three/c.md", false); + + // all recursive entities + assert_eq!(glob_vec("r/**"), vec!( + PathBuf::from("r/another"), + PathBuf::from("r/one"), + PathBuf::from("r/one/another"), + PathBuf::from("r/one/another/deep"), + PathBuf::from("r/three"), + PathBuf::from("r/two"))); + + // collapse consecutive recursive patterns + assert_eq!(glob_vec("r/**/**"), vec!( + PathBuf::from("r/another"), + PathBuf::from("r/one"), + PathBuf::from("r/one/another"), + PathBuf::from("r/one/another/deep"), + PathBuf::from("r/three"), + PathBuf::from("r/two"))); + + assert_eq!(glob_vec("r/**/*"), vec!( + PathBuf::from("r/another"), + PathBuf::from("r/another/a.md"), + PathBuf::from("r/current_dir.md"), + PathBuf::from("r/one"), + PathBuf::from("r/one/a.md"), + PathBuf::from("r/one/another"), + PathBuf::from("r/one/another/a.md"), + PathBuf::from("r/one/another/deep"), + PathBuf::from("r/one/another/deep/spelunking.md"), + PathBuf::from("r/three"), + PathBuf::from("r/three/c.md"), + PathBuf::from("r/two"), + PathBuf::from("r/two/b.md"))); + + // followed by a wildcard + assert_eq!(glob_vec("r/**/*.md"), vec!( + PathBuf::from("r/another/a.md"), + PathBuf::from("r/current_dir.md"), + PathBuf::from("r/one/a.md"), + PathBuf::from("r/one/another/a.md"), + PathBuf::from("r/one/another/deep/spelunking.md"), + PathBuf::from("r/three/c.md"), + PathBuf::from("r/two/b.md"))); + + // followed by a precise pattern + assert_eq!(glob_vec("r/one/**/a.md"), vec!( + PathBuf::from("r/one/a.md"), + PathBuf::from("r/one/another/a.md"))); + + // followed by another recursive pattern + // collapses consecutive recursives into one + assert_eq!(glob_vec("r/one/**/**/a.md"), vec!( + PathBuf::from("r/one/a.md"), + PathBuf::from("r/one/another/a.md"))); + + // followed by two precise patterns + assert_eq!(glob_vec("r/**/another/a.md"), vec!( + PathBuf::from("r/another/a.md"), + PathBuf::from("r/one/another/a.md"))); + + assert_eq!(glob_vec(""), Vec::new()); + assert_eq!(glob_vec("."), vec!(PathBuf::from("."))); + assert_eq!(glob_vec(".."), vec!(PathBuf::from(".."))); + + assert_eq!(glob_vec("aaa"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aaa/"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("a"), Vec::new()); + assert_eq!(glob_vec("aa"), Vec::new()); + assert_eq!(glob_vec("aaaa"), Vec::new()); + + assert_eq!(glob_vec("aaa/apple"), vec!(PathBuf::from("aaa/apple"))); + assert_eq!(glob_vec("aaa/apple/nope"), Vec::new()); + + // windows should support both / and \ as directory separators + if env::consts::FAMILY == "windows" { + assert_eq!(glob_vec("aaa\\apple"), vec!(PathBuf::from("aaa/apple"))); + } + + assert_eq!(glob_vec("???/"), vec!( + PathBuf::from("aaa"), + PathBuf::from("bbb"), + PathBuf::from("ccc"), + PathBuf::from("xyz"))); + + assert_eq!(glob_vec("aaa/tomato/tom?to.txt"), vec!( + PathBuf::from("aaa/tomato/tomato.txt"), + PathBuf::from("aaa/tomato/tomoto.txt"))); + + assert_eq!(glob_vec("xyz/?"), vec!( + PathBuf::from("xyz/x"), + PathBuf::from("xyz/y"), + PathBuf::from("xyz/z"))); + + assert_eq!(glob_vec("a*"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("*a*"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("a*a"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aaa*"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("*aaa"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("*aaa*"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("*a*a*a*"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aaa*/"), vec!(PathBuf::from("aaa"))); + + assert_eq!(glob_vec("aaa/*"), vec!( + PathBuf::from("aaa/apple"), + PathBuf::from("aaa/orange"), + PathBuf::from("aaa/tomato"))); + + assert_eq!(glob_vec("aaa/*a*"), vec!( + PathBuf::from("aaa/apple"), + PathBuf::from("aaa/orange"), + PathBuf::from("aaa/tomato"))); + + assert_eq!(glob_vec("*/*/*.txt"), vec!( + PathBuf::from("aaa/tomato/tomato.txt"), + PathBuf::from("aaa/tomato/tomoto.txt"))); + + assert_eq!(glob_vec("*/*/t[aob]m?to[.]t[!y]t"), vec!( + PathBuf::from("aaa/tomato/tomato.txt"), + PathBuf::from("aaa/tomato/tomoto.txt"))); + + assert_eq!(glob_vec("./aaa"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("./*"), glob_vec("*")); + assert_eq!(glob_vec("*/..").pop().unwrap(), PathBuf::from("xyz/..")); + assert_eq!(glob_vec("aaa/../bbb"), vec!(PathBuf::from("aaa/../bbb"))); + assert_eq!(glob_vec("nonexistent/../bbb"), Vec::new()); + assert_eq!(glob_vec("aaa/tomato/tomato.txt/.."), Vec::new()); + + assert_eq!(glob_vec("aaa/tomato/tomato.txt/"), Vec::new()); + + assert_eq!(glob_vec("aa[a]"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aa[abc]"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("a[bca]a"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aa[b]"), Vec::new()); + assert_eq!(glob_vec("aa[xyz]"), Vec::new()); + assert_eq!(glob_vec("aa[]]"), Vec::new()); + + assert_eq!(glob_vec("aa[!b]"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aa[!bcd]"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("a[!bcd]a"), vec!(PathBuf::from("aaa"))); + assert_eq!(glob_vec("aa[!a]"), Vec::new()); + assert_eq!(glob_vec("aa[!abc]"), Vec::new()); + + assert_eq!(glob_vec("bbb/specials/[[]"), vec!(PathBuf::from("bbb/specials/["))); + assert_eq!(glob_vec("bbb/specials/!"), vec!(PathBuf::from("bbb/specials/!"))); + assert_eq!(glob_vec("bbb/specials/[]]"), vec!(PathBuf::from("bbb/specials/]"))); + + if env::consts::FAMILY != "windows" { + assert_eq!(glob_vec("bbb/specials/[*]"), vec!(PathBuf::from("bbb/specials/*"))); + assert_eq!(glob_vec("bbb/specials/[?]"), vec!(PathBuf::from("bbb/specials/?"))); + } + + if env::consts::FAMILY == "windows" { + + assert_eq!(glob_vec("bbb/specials/[![]"), vec!( + PathBuf::from("bbb/specials/!"), + PathBuf::from("bbb/specials/]"))); + + assert_eq!(glob_vec("bbb/specials/[!]]"), vec!( + PathBuf::from("bbb/specials/!"), + PathBuf::from("bbb/specials/["))); + + assert_eq!(glob_vec("bbb/specials/[!!]"), vec!( + PathBuf::from("bbb/specials/["), + PathBuf::from("bbb/specials/]"))); + + } else { + + assert_eq!(glob_vec("bbb/specials/[![]"), vec!( + PathBuf::from("bbb/specials/!"), + PathBuf::from("bbb/specials/*"), + PathBuf::from("bbb/specials/?"), + PathBuf::from("bbb/specials/]"))); + + assert_eq!(glob_vec("bbb/specials/[!]]"), vec!( + PathBuf::from("bbb/specials/!"), + PathBuf::from("bbb/specials/*"), + PathBuf::from("bbb/specials/?"), + PathBuf::from("bbb/specials/["))); + + assert_eq!(glob_vec("bbb/specials/[!!]"), vec!( + PathBuf::from("bbb/specials/*"), + PathBuf::from("bbb/specials/?"), + PathBuf::from("bbb/specials/["), + PathBuf::from("bbb/specials/]"))); + + assert_eq!(glob_vec("bbb/specials/[!*]"), vec!( + PathBuf::from("bbb/specials/!"), + PathBuf::from("bbb/specials/?"), + PathBuf::from("bbb/specials/["), + PathBuf::from("bbb/specials/]"))); + + assert_eq!(glob_vec("bbb/specials/[!?]"), vec!( + PathBuf::from("bbb/specials/!"), + PathBuf::from("bbb/specials/*"), + PathBuf::from("bbb/specials/["), + PathBuf::from("bbb/specials/]"))); + + } +} diff --git a/deps/kernel32-sys-0.1.2/Cargo.toml b/deps/kernel32-sys-0.1.2/Cargo.toml new file mode 100644 index 000000000..ebfd92ab9 --- /dev/null +++ b/deps/kernel32-sys-0.1.2/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "kernel32-sys" +version = "0.1.2" +authors = ["Peter Atashian "] +description = "FFI bindings to kernel32." +documentation = "https://retep998.github.io/doc/kernel32-sys/" +repository = "https://github.com/retep998/winapi-rs" +readme = "README.md" +keywords = ["Windows", "FFI", "WinSDK"] +license = "MIT" +build = "build.rs" +links = "kernel32" + +[lib] +name = "kernel32" + +[dependencies] +winapi = { version = "*", path = "../.." } +[build-dependencies] +winapi-build = { version = "*", path = "../../build" } diff --git a/deps/kernel32-sys-0.1.2/README.md b/deps/kernel32-sys-0.1.2/README.md new file mode 100644 index 000000000..4d48b1567 --- /dev/null +++ b/deps/kernel32-sys-0.1.2/README.md @@ -0,0 +1,4 @@ +# kernel32-sys # +FFI bindings to kernel32. + +[Documentation](https://retep998.github.io/doc/kernel32-sys/) diff --git a/deps/kernel32-sys-0.1.2/build.rs b/deps/kernel32-sys-0.1.2/build.rs new file mode 100644 index 000000000..cf323fc2e --- /dev/null +++ b/deps/kernel32-sys-0.1.2/build.rs @@ -0,0 +1,6 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License +extern crate build; +fn main() { + build::link("kernel32", false) +} diff --git a/deps/kernel32-sys-0.1.2/src/lib.rs b/deps/kernel32-sys-0.1.2/src/lib.rs new file mode 100644 index 000000000..686b48810 --- /dev/null +++ b/deps/kernel32-sys-0.1.2/src/lib.rs @@ -0,0 +1,1768 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License +//! FFI bindings to kernel32. +#![cfg(windows)] +extern crate winapi; +use winapi::*; +extern "system" { + pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK); + pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK); + pub fn ActivateActCtx(hActCtx: HANDLE, lpCookie: *mut ULONG_PTR) -> BOOL; + pub fn AddAtomA(lpString: LPCSTR) -> ATOM; + pub fn AddAtomW(lpString: LPCWSTR) -> ATOM; + pub fn AddConsoleAliasA(Source: LPSTR, Target: LPSTR, ExeName: LPSTR) -> BOOL; + pub fn AddConsoleAliasW(Source: LPWSTR, Target: LPWSTR, ExeName: LPWSTR) -> BOOL; + pub fn AddDllDirectory(NewDirectory: PCWSTR) -> DLL_DIRECTORY_COOKIE; + pub fn AddIntegrityLabelToBoundaryDescriptor( + BoundaryDescriptor: *mut HANDLE, IntegrityLabel: PSID, + ) -> BOOL; + // pub fn AddLocalAlternateComputerNameA(); + // pub fn AddLocalAlternateComputerNameW(); + pub fn AddRefActCtx(hActCtx: HANDLE); + pub fn AddResourceAttributeAce( + pAcl: PACL, dwAceRevision: DWORD, AceFlags: DWORD, AccessMask: DWORD, pSid: PSID, + pAttributeInfo: PCLAIM_SECURITY_ATTRIBUTES_INFORMATION, pReturnLength: PDWORD, + ) -> BOOL; + pub fn AddSIDToBoundaryDescriptor(BoundaryDescriptor: *mut HANDLE, RequiredSid: PSID) -> BOOL; + pub fn AddScopedPolicyIDAce( + pAcl: PACL, dwAceRevision: DWORD, AceFlags: DWORD, AccessMask: DWORD, pSid: PSID, + ) -> BOOL; + pub fn AddSecureMemoryCacheCallback(pfnCallBack: PSECURE_MEMORY_CACHE_CALLBACK) -> BOOL; + pub fn AddVectoredContinueHandler(First: ULONG, Handler: PVECTORED_EXCEPTION_HANDLER) -> PVOID; + pub fn AddVectoredExceptionHandler( + First: ULONG, Handler: PVECTORED_EXCEPTION_HANDLER, + ) -> PVOID; + pub fn AllocConsole() -> BOOL; + // pub fn AllocateUserPhysicalPages(); + // pub fn AllocateUserPhysicalPagesNuma(); + // pub fn AppXGetOSMaxVersionTested(); + // pub fn ApplicationRecoveryFinished(); + // pub fn ApplicationRecoveryInProgress(); + // pub fn AreFileApisANSI(); + pub fn AssignProcessToJobObject(hJob: HANDLE, hProcess: HANDLE) -> BOOL; + pub fn AttachConsole(dwProcessId: DWORD) -> BOOL; + // pub fn BackupRead(); + // pub fn BackupSeek(); + // pub fn BackupWrite(); + // pub fn BaseSetLastNTError(); + // pub fn Beep(); + // pub fn BeginUpdateResourceA(); + // pub fn BeginUpdateResourceW(); + // pub fn BindIoCompletionCallback(); + // pub fn BuildCommDCBA(); + // pub fn BuildCommDCBAndTimeoutsA(); + // pub fn BuildCommDCBAndTimeoutsW(); + // pub fn BuildCommDCBW(); + // pub fn CallNamedPipeA(); + // pub fn CallNamedPipeW(); + // pub fn CallbackMayRunLong(); + // pub fn CalloutOnFiberStack(); + // pub fn CancelDeviceWakeupRequest(); + pub fn CancelIo(hFile: HANDLE) -> BOOL; + pub fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL; + // pub fn CancelSynchronousIo(); + // pub fn CancelThreadpoolIo(); + // pub fn CancelTimerQueueTimer(); + // pub fn CancelWaitableTimer(); + // pub fn CeipIsOptedIn(); + // pub fn ChangeTimerQueueTimer(); + // pub fn CheckElevation(); + // pub fn CheckElevationEnabled(); + // pub fn CheckNameLegalDOS8Dot3A(); + // pub fn CheckNameLegalDOS8Dot3W(); + // pub fn CheckRemoteDebuggerPresent(); + // pub fn CheckTokenCapability(); + // pub fn CheckTokenMembershipEx(); + // pub fn ClearCommBreak(); + // pub fn ClearCommError(); + pub fn CloseHandle(hObject: HANDLE) -> BOOL; + // pub fn ClosePackageInfo(); + // pub fn ClosePrivateNamespace(); + // pub fn CloseState(); + // pub fn CloseThreadpool(); + // pub fn CloseThreadpoolCleanupGroup(); + // pub fn CloseThreadpoolCleanupGroupMembers(); + // pub fn CloseThreadpoolIo(); + // pub fn CloseThreadpoolTimer(); + // pub fn CloseThreadpoolWait(); + // pub fn CloseThreadpoolWork(); + // pub fn CommConfigDialogA(); + // pub fn CommConfigDialogW(); + pub fn CompareFileTime(lpFileTime1: *const FILETIME, lpFileTime2: *const FILETIME) -> LONG; + // pub fn CompareStringA(); + // pub fn CompareStringEx(); + // pub fn CompareStringOrdinal(); + // pub fn CompareStringW(); + pub fn ConnectNamedPipe(hNamedPipe: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL; + // pub fn ContinueDebugEvent(); + // pub fn ConvertDefaultLocale(); + // pub fn ConvertFiberToThread(); + // pub fn ConvertThreadToFiber(); + // pub fn ConvertThreadToFiberEx(); + // pub fn CopyContext(); + // pub fn CopyFile2(); + // pub fn CopyFileA(); + // pub fn CopyFileExA(); + // pub fn CopyFileExW(); + // pub fn CopyFileTransactedA(); + // pub fn CopyFileTransactedW(); + // pub fn CopyFileW(); + // pub fn CreateActCtxA(); + // pub fn CreateActCtxW(); + // pub fn CreateBoundaryDescriptorA(); + // pub fn CreateBoundaryDescriptorW(); + pub fn CreateConsoleScreenBuffer( + dwDesiredAccess: DWORD, dwShareMode: DWORD, + lpSecurityAttributes: *const SECURITY_ATTRIBUTES, dwFlags: DWORD, + lpScreenBufferData: LPVOID, + ) -> HANDLE; + pub fn CreateDirectoryA( + lpPathName: LPCSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateDirectoryExA( + lpTemplateDirectory: LPCSTR, lpNewDirectory: LPCSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateDirectoryExW( + lpTemplateDirectory: LPCWSTR, lpNewDirectory: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + // pub fn CreateDirectoryTransactedA(); + // pub fn CreateDirectoryTransactedW(); + pub fn CreateDirectoryW( + lpPathName: LPCWSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateEventA( + lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, bInitialState: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateEventW( + lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, bInitialState: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn CreateEventExA( + lpEventAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCSTR, dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateEventExW( + lpEventAttributes: LPSECURITY_ATTRIBUTES, lpName: LPWSTR, dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + // pub fn CreateFiber(); + // pub fn CreateFiberEx(); + pub fn CreateFile2( + lpFileName: LPCWSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, + dwCreationDisposition: DWORD, pCreateExParams: LPCREATEFILE2_EXTENDED_PARAMETERS, + ) -> HANDLE; + pub fn CreateFileA( + lpFileName: LPCSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE, + ) -> HANDLE; + pub fn CreateFileMappingA( + hFile: HANDLE, lpAttributes: LPSECURITY_ATTRIBUTES, flProtect: DWORD, + dwMaximumSizeHigh: DWORD, dwMaximumSizeLow: DWORD, lpName: LPCSTR, + ) -> HANDLE; + // pub fn CreateFileMappingFromApp(); + // pub fn CreateFileMappingNumaA(); + // pub fn CreateFileMappingNumaW(); + pub fn CreateFileMappingW( + hFile: HANDLE, lpAttributes: LPSECURITY_ATTRIBUTES, flProtect: DWORD, + dwMaximumSizeHigh: DWORD, dwMaximumSizeLow: DWORD, lpName: LPCWSTR, + ) -> HANDLE; + // pub fn CreateFileTransactedA(); + // pub fn CreateFileTransactedW(); + pub fn CreateFileW( + lpFileName: LPCWSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE, + ) -> HANDLE; + // pub fn CreateHardLinkA(); + // pub fn CreateHardLinkTransactedA(); + // pub fn CreateHardLinkTransactedW(); + // pub fn CreateHardLinkW(); + pub fn CreateIoCompletionPort( + FileHandle: HANDLE, ExistingCompletionPort: HANDLE, CompletionKey: ULONG_PTR, + NumberOfConcurrentThreads: DWORD, + ) -> HANDLE; + // pub fn CreateJobObjectA(); + pub fn CreateJobObjectW(lpJobAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCWSTR) -> HANDLE; + // pub fn CreateJobSet(); + // pub fn CreateMailslotA(); + // pub fn CreateMailslotW(); + // pub fn CreateMemoryResourceNotification(); + // pub fn CreateMutexA(); + // pub fn CreateMutexExA(); + // pub fn CreateMutexExW(); + // pub fn CreateMutexW(); + pub fn CreateNamedPipeA( + lpName: LPCSTR, dwOpenMode: DWORD, dwPipeMode: DWORD, nMaxInstances: DWORD, + nOutBufferSize: DWORD, nInBufferSize: DWORD, nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> HANDLE; + pub fn CreateNamedPipeW( + lpName: LPCWSTR, dwOpenMode: DWORD, dwPipeMode: DWORD, nMaxInstances: DWORD, + nOutBufferSize: DWORD, nInBufferSize: DWORD, nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> HANDLE; + pub fn CreatePipe( + hReadPipe: PHANDLE, hWritePipe: PHANDLE, lpPipeAttributes: LPSECURITY_ATTRIBUTES, + nSize: DWORD, + ) -> BOOL; + // pub fn CreatePrivateNamespaceA(); + // pub fn CreatePrivateNamespaceW(); + // pub fn CreateProcessA(); + // pub fn CreateProcessW(); + // pub fn CreateRemoteThread(); + // pub fn CreateRemoteThreadEx(); + pub fn CreateSemaphoreA( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateSemaphoreExA( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, + lpName: LPCSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateSemaphoreExW( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, + lpName: LPCWSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateSemaphoreW( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, + lpName: LPCWSTR, + ) -> HANDLE; + // pub fn CreateSymbolicLinkA(); + // pub fn CreateSymbolicLinkTransactedA(); + // pub fn CreateSymbolicLinkTransactedW(); + // pub fn CreateSymbolicLinkW(); + // pub fn CreateTapePartition(); + // pub fn CreateThread(); + // pub fn CreateThreadpool(); + // pub fn CreateThreadpoolCleanupGroup(); + // pub fn CreateThreadpoolIo(); + // pub fn CreateThreadpoolTimer(); + // pub fn CreateThreadpoolWait(); + // pub fn CreateThreadpoolWork(); + // pub fn CreateTimerQueue(); + // pub fn CreateTimerQueueTimer(); + // pub fn CreateToolhelp32Snapshot(); + // #[cfg(target_arch = "x86_64")] + // pub fn CreateUmsCompletionList(); + // #[cfg(target_arch = "x86_64")] + // pub fn CreateUmsThreadContext(); + // pub fn CreateWaitableTimerA(); + // pub fn CreateWaitableTimerExA(); + // pub fn CreateWaitableTimerExW(); + // pub fn CreateWaitableTimerW(); + // pub fn CtrlRoutine(); + // pub fn DeactivateActCtx(); + // pub fn DebugActiveProcess(); + // pub fn DebugActiveProcessStop(); + // pub fn DebugBreak(); + // pub fn DebugBreakProcess(); + // pub fn DebugSetProcessKillOnExit(); + // pub fn DecodePointer(); + // pub fn DecodeSystemPointer(); + // pub fn DefineDosDeviceA(); + pub fn DefineDosDeviceW(dwFlags: DWORD, lpDeviceName: LPCWSTR, lpTargetPath: LPCWSTR) -> BOOL; + // pub fn DelayLoadFailureHook(); + // pub fn DeleteAtom(); + // pub fn DeleteBoundaryDescriptor(); + pub fn DeleteCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); + // pub fn DeleteFiber(); + pub fn DeleteFileA(lpFileName: LPCSTR) -> BOOL; + // pub fn DeleteFileTransactedA(); + // pub fn DeleteFileTransactedW(); + pub fn DeleteFileW(lpFileName: LPCWSTR) -> BOOL; + // pub fn DeleteProcThreadAttributeList(); + // pub fn DeleteSynchronizationBarrier(); + // pub fn DeleteTimerQueue(); + // pub fn DeleteTimerQueueEx(); + // pub fn DeleteTimerQueueTimer(); + // #[cfg(target_arch = "x86_64")] + // pub fn DeleteUmsCompletionList(); + // #[cfg(target_arch = "x86_64")] + // pub fn DeleteUmsThreadContext(); + // pub fn DeleteVolumeMountPointA(); + pub fn DeleteVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR) -> BOOL; + // #[cfg(target_arch = "x86_64")] + // pub fn DequeueUmsCompletionListItems(); + pub fn DeviceIoControl( + hDevice: HANDLE, dwIoControlCode: DWORD, lpInBuffer: LPVOID, nInBufferSize: DWORD, + lpOutBuffer: LPVOID, nOutBufferSize: DWORD, lpBytesReturned: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + // pub fn DisableThreadLibraryCalls(); + // pub fn DisableThreadProfiling(); + // pub fn DisassociateCurrentThreadFromCallback(); + // pub fn DisconnectNamedPipe(); + // pub fn DnsHostnameToComputerNameA(); + // pub fn DnsHostnameToComputerNameExW(); + // pub fn DnsHostnameToComputerNameW(); + pub fn DosDateTimeToFileTime(wFatDate: WORD, wFatTime: WORD, lpFileTime: LPFILETIME) -> BOOL; + // pub fn DosPathToSessionPathW(); + // pub fn DuplicateHandle(); + // pub fn EnableThreadProfiling(); + // pub fn EncodePointer(); + // pub fn EncodeSystemPointer(); + // pub fn EndUpdateResourceA(); + // pub fn EndUpdateResourceW(); + pub fn EnterCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); + // pub fn EnterSynchronizationBarrier(); + // #[cfg(target_arch = "x86_64")] + // pub fn EnterUmsSchedulingMode(); + // pub fn EnumCalendarInfoA(); + // pub fn EnumCalendarInfoExA(); + // pub fn EnumCalendarInfoExEx(); + // pub fn EnumCalendarInfoExW(); + // pub fn EnumCalendarInfoW(); + // pub fn EnumDateFormatsA(); + // pub fn EnumDateFormatsExA(); + // pub fn EnumDateFormatsExEx(); + // pub fn EnumDateFormatsExW(); + // pub fn EnumDateFormatsW(); + // pub fn EnumLanguageGroupLocalesA(); + // pub fn EnumLanguageGroupLocalesW(); + // pub fn EnumResourceLanguagesA(); + // pub fn EnumResourceLanguagesExA(); + // pub fn EnumResourceLanguagesExW(); + // pub fn EnumResourceLanguagesW(); + // pub fn EnumResourceNamesA(); + // pub fn EnumResourceNamesExA(); + // pub fn EnumResourceNamesExW(); + // pub fn EnumResourceNamesW(); + // pub fn EnumResourceTypesA(); + // pub fn EnumResourceTypesExA(); + // pub fn EnumResourceTypesExW(); + // pub fn EnumResourceTypesW(); + // pub fn EnumSystemCodePagesA(); + // pub fn EnumSystemCodePagesW(); + // pub fn EnumSystemFirmwareTables(); + // pub fn EnumSystemGeoID(); + // pub fn EnumSystemLanguageGroupsA(); + // pub fn EnumSystemLanguageGroupsW(); + // pub fn EnumSystemLocalesA(); + // pub fn EnumSystemLocalesEx(); + // pub fn EnumSystemLocalesW(); + // pub fn EnumTimeFormatsA(); + // pub fn EnumTimeFormatsEx(); + // pub fn EnumTimeFormatsW(); + // pub fn EnumUILanguagesA(); + // pub fn EnumUILanguagesW(); + // pub fn EnumerateLocalComputerNamesA(); + // pub fn EnumerateLocalComputerNamesW(); + // pub fn EraseTape(); + // pub fn EscapeCommFunction(); + // #[cfg(target_arch = "x86_64")] + // pub fn ExecuteUmsThread(); + // pub fn ExitProcess(); + // pub fn ExitThread(); + // pub fn ExpandEnvironmentStringsA(); + // pub fn ExpandEnvironmentStringsW(); + // pub fn FatalAppExitA(); + // pub fn FatalAppExitW(); + // pub fn FatalExit(); + pub fn FileTimeToDosDateTime( + lpFileTime: *const FILETIME, lpFatDate: LPWORD, lpFatTime: LPWORD, + ) -> BOOL; + pub fn FileTimeToLocalFileTime( + lpFileTime: *const FILETIME, lpLocalFileTime: LPFILETIME, + ) -> BOOL; + pub fn FileTimeToSystemTime( + lpFileTime: *const FILETIME, lpSystemTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn FillConsoleOutputAttribute( + hConsoleOutput: HANDLE, wAttribute: WORD, nLength: DWORD, dwWriteCoord: COORD, + lpNumberOfAttrsWritten: LPDWORD, + ) -> BOOL; + pub fn FillConsoleOutputCharacterA( + hConsoleOutput: HANDLE, cCharacter: CHAR, nLength: DWORD, dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn FillConsoleOutputCharacterW( + hConsoleOutput: HANDLE, cCharacter: WCHAR, nLength: DWORD, dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + // pub fn FindActCtxSectionGuid(); + // pub fn FindActCtxSectionStringA(); + // pub fn FindActCtxSectionStringW(); + // pub fn FindAtomA(); + // pub fn FindAtomW(); + pub fn FindClose(hFindFile: HANDLE) -> BOOL; + pub fn FindCloseChangeNotification(hChangeHandle: HANDLE) -> BOOL; + pub fn FindFirstChangeNotificationA( + lpPathName: LPCSTR, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, + ) -> HANDLE; + pub fn FindFirstChangeNotificationW( + lpPathName: LPCWSTR, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, + ) -> HANDLE; + pub fn FindFirstFileA(lpFileName: LPCSTR, lpFindFileData: LPWIN32_FIND_DATAA) -> HANDLE; + pub fn FindFirstFileExA( + lpFileName: LPCSTR, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: LPVOID, + fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: LPVOID, dwAdditionalFlags: DWORD, + ) -> HANDLE; + pub fn FindFirstFileExW( + lpFileName: LPCWSTR, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: LPVOID, + fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: LPVOID, dwAdditionalFlags: DWORD, + ) -> HANDLE; + // pub fn FindFirstFileNameTransactedW(); + // pub fn FindFirstFileNameW(); + // pub fn FindFirstFileTransactedA(); + // pub fn FindFirstFileTransactedW(); + pub fn FindFirstFileW(lpFileName: LPCWSTR, lpFindFileData: LPWIN32_FIND_DATAW) -> HANDLE; + // pub fn FindFirstStreamTransactedW(); + // pub fn FindFirstStreamW(); + // pub fn FindFirstVolumeA(); + // pub fn FindFirstVolumeMountPointA(); + // pub fn FindFirstVolumeMountPointW(); + pub fn FindFirstVolumeW(lpszVolumeName: LPWSTR, cchBufferLength: DWORD) -> HANDLE; + // pub fn FindNLSString(); + // pub fn FindNLSStringEx(); + pub fn FindNextChangeNotification(hChangeHandle: HANDLE) -> BOOL; + pub fn FindNextFileA(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATAA) -> BOOL; + // pub fn FindNextFileNameW(); + pub fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATAW) -> BOOL; + // pub fn FindNextStreamW(); + // pub fn FindNextVolumeA(); + // pub fn FindNextVolumeMountPointA(); + // pub fn FindNextVolumeMountPointW(); + pub fn FindNextVolumeW( + hFindVolume: HANDLE, lpszVolumeName: LPWSTR, cchBufferLength: DWORD, + ) -> BOOL; + // pub fn FindPackagesByPackageFamily(); + // pub fn FindResourceA(); + // pub fn FindResourceExA(); + // pub fn FindResourceExW(); + // pub fn FindResourceW(); + // pub fn FindStringOrdinal(); + pub fn FindVolumeClose(hFindVolume: HANDLE) -> BOOL; + // pub fn FindVolumeMountPointClose(); + // pub fn FlsAlloc(); + // pub fn FlsFree(); + // pub fn FlsGetValue(); + // pub fn FlsSetValue(); + pub fn FlushConsoleInputBuffer(hConsoleInput: HANDLE) -> BOOL; + pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; + // pub fn FlushInstructionCache(); + // pub fn FlushProcessWriteBuffers(); + pub fn FlushViewOfFile(lpBaseAddress: LPCVOID, dwNumberOfBytesToFlush: SIZE_T) -> BOOL; + // pub fn FoldStringA(); + // pub fn FoldStringW(); + // pub fn FormatApplicationUserModelId(); + pub fn FormatMessageA( + dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD, dwLanguageId: DWORD, + lpBuffer: LPSTR, nSize: DWORD, Arguments: *mut va_list, + ) -> DWORD; + pub fn FormatMessageW( + dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD, dwLanguageId: DWORD, + lpBuffer: LPWSTR, nSize: DWORD, Arguments: *mut va_list, + ) -> DWORD; + pub fn FreeConsole() -> BOOL; + // pub fn FreeEnvironmentStringsA(); + // pub fn FreeEnvironmentStringsW(); + pub fn FreeLibrary(hLibModule: HMODULE) -> BOOL; + // pub fn FreeLibraryAndExitThread(); + // pub fn FreeLibraryWhenCallbackReturns(); + // pub fn FreeResource(); + // pub fn FreeUserPhysicalPages(); + pub fn GenerateConsoleCtrlEvent(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL; + // pub fn GetACP(); + // pub fn GetActiveProcessorCount(); + // pub fn GetActiveProcessorGroupCount(); + // pub fn GetAppContainerAce(); + // pub fn GetAppContainerNamedObjectPath(); + // pub fn GetApplicationRecoveryCallback(); + // pub fn GetApplicationRestartSettings(); + // pub fn GetApplicationUserModelId(); + // pub fn GetAtomNameA(); + // pub fn GetAtomNameW(); + // pub fn GetBinaryType(); + // pub fn GetBinaryTypeA(); + // pub fn GetBinaryTypeW(); + // pub fn GetCPInfo(); + // pub fn GetCPInfoExA(); + // pub fn GetCPInfoExW(); + // pub fn GetCachedSigningLevel(); + // pub fn GetCalendarInfoA(); + // pub fn GetCalendarInfoEx(); + // pub fn GetCalendarInfoW(); + // pub fn GetCommConfig(); + // pub fn GetCommMask(); + // pub fn GetCommModemStatus(); + // pub fn GetCommProperties(); + // pub fn GetCommState(); + // pub fn GetCommTimeouts(); + // pub fn GetCommandLineA(); + // pub fn GetCommandLineW(); + pub fn GetCompressedFileSizeA(lpFileName: LPCSTR, lpFileSizeHigh: LPDWORD) -> DWORD; + // pub fn GetCompressedFileSizeTransactedA(); + // pub fn GetCompressedFileSizeTransactedW(); + pub fn GetCompressedFileSizeW(lpFileName: LPCWSTR, lpFileSizeHigh: LPDWORD) -> DWORD; + // pub fn GetComputerNameA(); + // pub fn GetComputerNameExA(); + // pub fn GetComputerNameExW(); + // pub fn GetComputerNameW(); + pub fn GetConsoleAliasA( + Source: LPSTR, TargetBuffer: LPSTR, TargetBufferLength: DWORD, ExeName: LPSTR, + ) -> DWORD; + pub fn GetConsoleAliasExesA(ExeNameBuffer: LPSTR, ExeNameBufferLength: DWORD) -> DWORD; + pub fn GetConsoleAliasExesLengthA() -> DWORD; + pub fn GetConsoleAliasExesLengthW() -> DWORD; + pub fn GetConsoleAliasExesW(ExeNameBuffer: LPWSTR, ExeNameBufferLength: DWORD) -> DWORD; + pub fn GetConsoleAliasW( + Source: LPWSTR, TargetBuffer: LPWSTR, TargetBufferLength: DWORD, ExeName: LPWSTR, + ) -> DWORD; + pub fn GetConsoleAliasesA( + AliasBuffer: LPSTR, AliasBufferLength: DWORD, ExeName: LPSTR, + ) -> DWORD; + pub fn GetConsoleAliasesLengthA(ExeName: LPSTR) -> DWORD; + pub fn GetConsoleAliasesLengthW(ExeName: LPWSTR) -> DWORD; + pub fn GetConsoleAliasesW( + AliasBuffer: LPWSTR, AliasBufferLength: DWORD, ExeName: LPWSTR, + ) -> DWORD; + pub fn GetConsoleCP() -> UINT; + pub fn GetConsoleCursorInfo( + hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO, + ) -> BOOL; + pub fn GetConsoleDisplayMode(lpModeFlags: LPDWORD) -> BOOL; + pub fn GetConsoleFontSize(hConsoleOutput: HANDLE, nFont: DWORD) -> COORD; + pub fn GetConsoleHistoryInfo(lpConsoleHistoryInfo: PCONSOLE_HISTORY_INFO) -> BOOL; + pub fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: LPDWORD) -> BOOL; + pub fn GetConsoleOriginalTitleA(lpConsoleTitle: LPSTR, nSize: DWORD) -> DWORD; + pub fn GetConsoleOriginalTitleW(lpConsoleTitle: LPWSTR, nSize: DWORD) -> DWORD; + pub fn GetConsoleOutputCP() -> UINT; + pub fn GetConsoleProcessList(lpdwProcessList: LPDWORD, dwProcessCount: DWORD) -> DWORD; + pub fn GetConsoleScreenBufferInfo( + hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO, + ) -> BOOL; + pub fn GetConsoleScreenBufferInfoEx( + hConsoleOutput: HANDLE, lpConsoleScreenBufferInfoEx: PCONSOLE_SCREEN_BUFFER_INFOEX, + ) -> BOOL; + pub fn GetConsoleSelectionInfo(lpConsoleSelectionInfo: PCONSOLE_SELECTION_INFO) -> BOOL; + pub fn GetConsoleTitleA(lpConsoleTitle: LPSTR, nSize: DWORD) -> DWORD; + pub fn GetConsoleTitleW(lpConsoleTitle: LPWSTR, nSize: DWORD) -> DWORD; + pub fn GetConsoleWindow() -> HWND; + // pub fn GetCurrencyFormatA(); + // pub fn GetCurrencyFormatEx(); + // pub fn GetCurrencyFormatW(); + // pub fn GetCurrentActCtx(); + // pub fn GetCurrentApplicationUserModelId(); + pub fn GetCurrentConsoleFont( + hConsoleOutput: HANDLE, bMaximumWindow: BOOL, lpConsoleCurrentFont: PCONSOLE_FONT_INFO, + ) -> BOOL; + pub fn GetCurrentConsoleFontEx( + hConsoleOutput: HANDLE, bMaximumWindow: BOOL, lpConsoleCurrentFontEx: PCONSOLE_FONT_INFOEX, + ) -> BOOL; + pub fn GetCurrentDirectoryA(nBufferLength: DWORD, lpBuffer: LPSTR) -> DWORD; + pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; + // pub fn GetCurrentPackageFamilyName(); + // pub fn GetCurrentPackageFullName(); + // pub fn GetCurrentPackageId(); + // pub fn GetCurrentPackageInfo(); + // pub fn GetCurrentPackagePath(); + pub fn GetCurrentProcess() -> HANDLE; + pub fn GetCurrentProcessId() -> DWORD; + // pub fn GetCurrentProcessorNumber(); + // pub fn GetCurrentProcessorNumberEx(); + pub fn GetCurrentThread() -> HANDLE; + pub fn GetCurrentThreadId() -> DWORD; + // pub fn GetCurrentThreadStackLimits(); + // #[cfg(target_arch = "x86_64")] + // pub fn GetCurrentUmsThread(); + // pub fn GetDateFormatA(); + // pub fn GetDateFormatEx(); + // pub fn GetDateFormatW(); + // pub fn GetDefaultCommConfigA(); + // pub fn GetDefaultCommConfigW(); + // pub fn GetDevicePowerState(); + pub fn GetDiskFreeSpaceA( + lpRootPathName: LPCSTR, lpSectorsPerCluster: LPDWORD, lpBytesPerSector: LPDWORD, + lpNumberOfFreeClusters: LPDWORD, lpTotalNumberOfClusters: LPDWORD, + ) -> BOOL; + pub fn GetDiskFreeSpaceExA( + lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller: PULARGE_INTEGER, + lpTotalNumberOfBytes: PULARGE_INTEGER, lpTotalNumberOfFreeBytes: PULARGE_INTEGER, + ) -> BOOL; + pub fn GetDiskFreeSpaceExW( + lpDirectoryName: LPCWSTR, lpFreeBytesAvailableToCaller: PULARGE_INTEGER, + lpTotalNumberOfBytes: PULARGE_INTEGER, lpTotalNumberOfFreeBytes: PULARGE_INTEGER, + ) -> BOOL; + pub fn GetDiskFreeSpaceW( + lpRootPathName: LPCWSTR, lpSectorsPerCluster: LPDWORD, lpBytesPerSector: LPDWORD, + lpNumberOfFreeClusters: LPDWORD, lpTotalNumberOfClusters: LPDWORD, + ) -> BOOL; + // pub fn GetDllDirectoryA(); + // pub fn GetDllDirectoryW(); + pub fn GetDriveTypeA(lpRootPathName: LPCSTR) -> UINT; + pub fn GetDriveTypeW(lpRootPathName: LPCWSTR) -> UINT; + // pub fn GetDurationFormat(); + // pub fn GetDurationFormatEx(); + pub fn GetDynamicTimeZoneInformation( + pTimeZoneInformation: PDYNAMIC_TIME_ZONE_INFORMATION, + ) -> DWORD; + // #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + // pub fn GetEnabledXStateFeatures(); + // pub fn GetEnvironmentStrings(); + // pub fn GetEnvironmentStringsA(); + // pub fn GetEnvironmentStringsW(); + // pub fn GetEnvironmentVariableA(); + // pub fn GetEnvironmentVariableW(); + // pub fn GetEraNameCountedString(); + // pub fn GetErrorMode(); + // pub fn GetExitCodeProcess(); + // pub fn GetExitCodeThread(); + pub fn GetFileAttributesA(lpFileName: LPCSTR) -> DWORD; + pub fn GetFileAttributesExA( + lpFileName: LPCSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID, + ) -> BOOL; + pub fn GetFileAttributesExW( + lpFileName: LPCWSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID, + ) -> BOOL; + // pub fn GetFileAttributesTransactedA(); + // pub fn GetFileAttributesTransactedW(); + pub fn GetFileAttributesW(lpFileName: LPCWSTR) -> DWORD; + // pub fn GetFileBandwidthReservation(); + pub fn GetFileInformationByHandle(hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION) -> BOOL; + // pub fn GetFileInformationByHandleEx(); + // pub fn GetFileMUIInfo(); + // pub fn GetFileMUIPath(); + pub fn GetFileSize(hFile: HANDLE, lpFileSizeHigh: LPDWORD) -> DWORD; + pub fn GetFileSizeEx(hFile: HANDLE, lpFileSize: PLARGE_INTEGER) -> BOOL; + pub fn GetFileTime( + hFile: HANDLE, lpCreationTime: LPFILETIME, lpLastAccessTime: LPFILETIME, + lpLastWriteTime: LPFILETIME, + ) -> BOOL; + pub fn GetFileType(hFile: HANDLE) -> DWORD; + pub fn GetFinalPathNameByHandleA( + hFile: HANDLE, lpszFilePath: LPSTR, cchFilePath: DWORD, dwFlags: DWORD, + ) -> DWORD; + pub fn GetFinalPathNameByHandleW( + hFile: HANDLE, lpszFilePath: LPWSTR, cchFilePath: DWORD, dwFlags: DWORD, + ) -> DWORD; + // pub fn GetFirmwareEnvironmentVariableA(); + // pub fn GetFirmwareEnvironmentVariableExA(); + // pub fn GetFirmwareEnvironmentVariableExW(); + // pub fn GetFirmwareEnvironmentVariableW(); + // pub fn GetFirmwareType(); + pub fn GetFullPathNameA( + lpFileName: LPCSTR, nBufferLength: DWORD, lpBuffer: LPSTR, lpFilePart: *mut LPSTR, + ) -> DWORD; + // pub fn GetFullPathNameTransactedA(); + // pub fn GetFullPathNameTransactedW(); + pub fn GetFullPathNameW( + lpFileName: LPCWSTR, nBufferLength: DWORD, lpBuffer: LPWSTR, lpFilePart: *mut LPWSTR, + ) -> DWORD; + // pub fn GetGeoInfoA(); + // pub fn GetGeoInfoW(); + // pub fn GetHandleInformation(); + // pub fn GetLargePageMinimum(); + pub fn GetLargestConsoleWindowSize(hConsoleOutput: HANDLE) -> COORD; + pub fn GetLastError() -> DWORD; + pub fn GetLocalTime(lpSystemTime: LPSYSTEMTIME); + // pub fn GetLocaleInfoA(); + // pub fn GetLocaleInfoEx(); + // pub fn GetLocaleInfoW(); + // pub fn GetLogicalDriveStringsA(); + pub fn GetLogicalDriveStringsW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; + pub fn GetLogicalDrives() -> DWORD; + // pub fn GetLogicalProcessorInformation(); + // pub fn GetLogicalProcessorInformationEx(); + pub fn GetLongPathNameA(lpszShortPath: LPCSTR, lpszLongPath: LPSTR, cchBuffer: DWORD) -> DWORD; + // pub fn GetLongPathNameTransactedA(); + // pub fn GetLongPathNameTransactedW(); + pub fn GetLongPathNameW( + lpszShortPath: LPCWSTR, lpszLongPath: LPWSTR, cchBuffer: DWORD, + ) -> DWORD; + // pub fn GetMailslotInfo(); + // pub fn GetMaximumProcessorCount(); + // pub fn GetMaximumProcessorGroupCount(); + // pub fn GetMemoryErrorHandlingCapabilities(); + // pub fn GetModuleFileNameA(); + // pub fn GetModuleFileNameW(); + pub fn GetModuleHandleA(lpModuleName: LPCSTR) -> HMODULE; + pub fn GetModuleHandleExA( + dwFlags: DWORD, lpModuleName: LPCSTR, phModule: *mut HMODULE, + ) -> BOOL; + pub fn GetModuleHandleExW( + dwFlags: DWORD, lpModuleName: LPCWSTR, phModule: *mut HMODULE, + ) -> BOOL; + pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE; + // pub fn GetNLSVersion(); + // pub fn GetNLSVersionEx(); + // pub fn GetNamedPipeAttribute(); + // pub fn GetNamedPipeClientComputerNameA(); + // pub fn GetNamedPipeClientComputerNameW(); + // pub fn GetNamedPipeClientProcessId(); + // pub fn GetNamedPipeClientSessionId(); + // pub fn GetNamedPipeHandleStateA(); + // pub fn GetNamedPipeHandleStateW(); + // pub fn GetNamedPipeInfo(); + // pub fn GetNamedPipeServerProcessId(); + // pub fn GetNamedPipeServerSessionId(); + // pub fn GetNativeSystemInfo(); + // #[cfg(target_arch = "x86_64")] + // pub fn GetNextUmsListItem(); + // pub fn GetNumaAvailableMemoryNode(); + // pub fn GetNumaAvailableMemoryNodeEx(); + // pub fn GetNumaHighestNodeNumber(); + // pub fn GetNumaNodeNumberFromHandle(); + // pub fn GetNumaNodeProcessorMask(); + // pub fn GetNumaNodeProcessorMaskEx(); + // pub fn GetNumaProcessorNode(); + // pub fn GetNumaProcessorNodeEx(); + // pub fn GetNumaProximityNode(); + // pub fn GetNumaProximityNodeEx(); + // pub fn GetNumberFormatA(); + // pub fn GetNumberFormatEx(); + // pub fn GetNumberFormatW(); + pub fn GetNumberOfConsoleInputEvents(hConsoleInput: HANDLE, lpNumberOfEvents: LPDWORD) -> BOOL; + pub fn GetNumberOfConsoleMouseButtons(lpNumberOfMouseButtons: LPDWORD) -> BOOL; + // pub fn GetOEMCP(); + // pub fn GetOverlappedResult(); + // pub fn GetOverlappedResultEx(); + // pub fn GetPackageApplicationIds(); + // pub fn GetPackageFamilyName(); + // pub fn GetPackageFullName(); + // pub fn GetPackageId(); + // pub fn GetPackageInfo(); + // pub fn GetPackagePath(); + // pub fn GetPackagePathByFullName(); + // pub fn GetPackagesByPackageFamily(); + // pub fn GetPhysicallyInstalledSystemMemory(); + // pub fn GetPriorityClass(); + // pub fn GetPrivateProfileIntA(); + // pub fn GetPrivateProfileIntW(); + // pub fn GetPrivateProfileSectionA(); + // pub fn GetPrivateProfileSectionNamesA(); + // pub fn GetPrivateProfileSectionNamesW(); + // pub fn GetPrivateProfileSectionW(); + // pub fn GetPrivateProfileStringA(); + // pub fn GetPrivateProfileStringW(); + // pub fn GetPrivateProfileStructA(); + // pub fn GetPrivateProfileStructW(); + pub fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> FARPROC; + // pub fn GetProcessAffinityMask(); + // pub fn GetProcessDEPPolicy(); + // pub fn GetProcessGroupAffinity(); + // pub fn GetProcessHandleCount(); + pub fn GetProcessHeap() -> HANDLE; + pub fn GetProcessHeaps(NumberOfHeaps: DWORD, ProcessHeaps: PHANDLE) -> DWORD; + // pub fn GetProcessId(); + // pub fn GetProcessIdOfThread(); + // pub fn GetProcessInformation(); + // pub fn GetProcessIoCounters(); + // pub fn GetProcessMitigationPolicy(); + // pub fn GetProcessPreferredUILanguages(); + // pub fn GetProcessPriorityBoost(); + // pub fn GetProcessShutdownParameters(); + pub fn GetProcessTimes( + hProcess: HANDLE, lpCreationTime: LPFILETIME, lpExitTime: LPFILETIME, + lpKernelTime: LPFILETIME, lpUserTime: LPFILETIME, + ) -> BOOL; + // pub fn GetProcessVersion(); + // pub fn GetProcessWorkingSetSize(); + // pub fn GetProcessWorkingSetSizeEx(); + // pub fn GetProcessorSystemCycleTime(); + // pub fn GetProductInfo(); + // pub fn GetProfileIntA(); + // pub fn GetProfileIntW(); + // pub fn GetProfileSectionA(); + // pub fn GetProfileSectionW(); + // pub fn GetProfileStringA(); + // pub fn GetProfileStringW(); + pub fn GetQueuedCompletionStatus( + CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: PULONG_PTR, + lpOverlapped: *mut LPOVERLAPPED, dwMilliseconds: DWORD, + ) -> BOOL; + pub fn GetQueuedCompletionStatusEx( + CompletionPort: HANDLE, lpCompletionPortEntries: LPOVERLAPPED_ENTRY, ulCount: ULONG, + ulNumEntriesRemoved: PULONG, dwMilliseconds: DWORD, fAlertable: BOOL, + ) -> BOOL; + // pub fn GetShortPathNameA(); + pub fn GetShortPathNameW( + lpszLongPath: LPCWSTR, lpszShortPath: LPWSTR, cchBuffer: DWORD, + ) -> DWORD; + // pub fn GetStagedPackagePathByFullName(); + pub fn GetStartupInfoA(lpStartupInfo: LPSTARTUPINFOA); + pub fn GetStartupInfoW(lpStartupInfo: LPSTARTUPINFOW); + // pub fn GetStateFolder(); + pub fn GetStdHandle(nStdHandle: DWORD) -> HANDLE; + // pub fn GetStringScripts(); + // pub fn GetStringTypeA(); + // pub fn GetStringTypeExA(); + // pub fn GetStringTypeExW(); + // pub fn GetStringTypeW(); + // pub fn GetSystemAppDataKey(); + // pub fn GetSystemDEPPolicy(); + // pub fn GetSystemDefaultLCID(); + // pub fn GetSystemDefaultLangID(); + // pub fn GetSystemDefaultLocaleName(); + // pub fn GetSystemDefaultUILanguage(); + // pub fn GetSystemDirectoryA(); + // pub fn GetSystemDirectoryW(); + // pub fn GetSystemFileCacheSize(); + // pub fn GetSystemFirmwareTable(); + // pub fn GetSystemInfo(); + // pub fn GetSystemPowerStatus(); + // pub fn GetSystemPreferredUILanguages(); + pub fn GetSystemRegistryQuota(pdwQuotaAllowed: PDWORD, pdwQuotaUsed: PDWORD) -> BOOL; + pub fn GetSystemTime(lpSystemTime: LPSYSTEMTIME); + pub fn GetSystemTimeAdjustment( + lpTimeAdjustment: PDWORD, lpTimeIncrement: PDWORD, lpTimeAdjustmentDisabled: PBOOL, + ) -> BOOL; + pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME); + pub fn GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime: LPFILETIME); + pub fn GetSystemTimes( + lpIdleTime: PFILETIME, lpKernelTime: PFILETIME, lpUserTime: PFILETIME, + ) -> BOOL; + // pub fn GetSystemWindowsDirectoryA(); + // pub fn GetSystemWindowsDirectoryW(); + // pub fn GetSystemWow64DirectoryA(); + // pub fn GetSystemWow64DirectoryW(); + // pub fn GetTapeParameters(); + // pub fn GetTapePosition(); + // pub fn GetTapeStatus(); + // pub fn GetTempFileNameA(); + pub fn GetTempFileNameW( + lpPathName: LPCWSTR, lpPrefixString: LPCWSTR, uUnique: UINT, lpTempFileName: LPWSTR, + ) -> UINT; + // pub fn GetTempPathA(); + pub fn GetTempPathW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; + // pub fn GetThreadContext(); + // pub fn GetThreadErrorMode(); + // pub fn GetThreadGroupAffinity(); + // pub fn GetThreadIOPendingFlag(); + // pub fn GetThreadId(); + // pub fn GetThreadIdealProcessorEx(); + // pub fn GetThreadInformation(); + // pub fn GetThreadLocale(); + // pub fn GetThreadPreferredUILanguages(); + // pub fn GetThreadPriority(); + // pub fn GetThreadPriorityBoost(); + // pub fn GetThreadSelectorEntry(); + pub fn GetThreadTimes( + hThread: HANDLE, lpCreationTime: LPFILETIME, lpExitTime: LPFILETIME, + lpKernelTime: LPFILETIME, lpUserTime: LPFILETIME, + ) -> BOOL; + // pub fn GetThreadUILanguage(); + // pub fn GetTickCount(); + // pub fn GetTickCount64(); + pub fn GetTimeFormatA( + Locale: LCID, dwFlags: DWORD, lpTime: *const SYSTEMTIME, lpFormat: LPCSTR, + lpTimeStr: LPSTR, cchTime: c_int, + ) -> c_int; + pub fn GetTimeFormatEx( + lpLocaleName: LPCWSTR, dwFlags: DWORD, lpTime: *const SYSTEMTIME, lpFormat: LPCWSTR, + lpTimeStr: LPWSTR, cchTime: c_int, + ) -> c_int; + pub fn GetTimeFormatW( + Locale: LCID, dwFlags: DWORD, lpTime: *const SYSTEMTIME, lpFormat: LPCWSTR, + lpTimeStr: LPWSTR, cchTime: c_int, + ) -> c_int; + pub fn GetTimeZoneInformation(lpTimeZoneInformation: LPTIME_ZONE_INFORMATION) -> DWORD; + pub fn GetTimeZoneInformationForYear( + wYear: USHORT, pdtzi: PDYNAMIC_TIME_ZONE_INFORMATION, ptzi: LPTIME_ZONE_INFORMATION, + ) -> BOOL; + // pub fn GetUILanguageInfo(); + // #[cfg(target_arch = "x86_64")] + // pub fn GetUmsCompletionListEvent(); + // #[cfg(target_arch = "x86_64")] + // pub fn GetUmsSystemThreadInformation(); + // pub fn GetUserDefaultLCID(); + // pub fn GetUserDefaultLangID(); + // pub fn GetUserDefaultLocaleName(); + // pub fn GetUserDefaultUILanguage(); + // pub fn GetUserGeoID(); + // pub fn GetUserPreferredUILanguages(); + // pub fn GetVersion(); + // pub fn GetVersionExA(); + // pub fn GetVersionExW(); + // pub fn GetVolumeInformationA(); + pub fn GetVolumeInformationByHandleW( + hFile: HANDLE, lpVolumeNameBuffer: LPWSTR, nVolumeNameSize: DWORD, + lpVolumeSerialNumber: LPDWORD, lpMaximumComponentLength: LPDWORD, + lpFileSystemFlags: LPDWORD, lpFileSystemNameBuffer: LPWSTR, nFileSystemNameSize: DWORD, + ) -> BOOL; + pub fn GetVolumeInformationW( + lpRootPathName: LPCWSTR, lpVolumeNameBuffer: LPWSTR, nVolumeNameSize: DWORD, + lpVolumeSerialNumber: LPDWORD, lpMaximumComponentLength: LPDWORD, + lpFileSystemFlags: LPDWORD, lpFileSystemNameBuffer: LPWSTR, nFileSystemNameSize: DWORD, + ) -> BOOL; + // pub fn GetVolumeNameForVolumeMountPointA(); + pub fn GetVolumeNameForVolumeMountPointW( + lpszVolumeMountPoint: LPCWSTR, lpszVolumeName: LPWSTR, cchBufferLength: DWORD, + ) -> BOOL; + // pub fn GetVolumePathNameA(); + pub fn GetVolumePathNameW( + lpszFileName: LPCWSTR, lpszVolumePathName: LPWSTR, cchBufferLength: DWORD, + ) -> BOOL; + // pub fn GetVolumePathNamesForVolumeNameA(); + pub fn GetVolumePathNamesForVolumeNameW( + lpszVolumeName: LPCWSTR, lpszVolumePathNames: LPWCH, cchBufferLength: DWORD, + lpcchReturnLength: PDWORD, + ) -> BOOL; + // pub fn GetWindowsDirectoryA(); + // pub fn GetWindowsDirectoryW(); + // pub fn GetWriteWatch(); + // #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + // pub fn GetXStateFeaturesMask(); + // pub fn GlobalAddAtomA(); + // pub fn GlobalAddAtomExA(); + // pub fn GlobalAddAtomExW(); + // pub fn GlobalAddAtomW(); + pub fn GlobalAlloc(uFlags: UINT, dwBytes: SIZE_T) -> HGLOBAL; + // pub fn GlobalCompact(); + // pub fn GlobalDeleteAtom(); + // pub fn GlobalFindAtomA(); + // pub fn GlobalFindAtomW(); + // pub fn GlobalFix(); + // pub fn GlobalFlags(); + // pub fn GlobalFree(); + // pub fn GlobalGetAtomNameA(); + // pub fn GlobalGetAtomNameW(); + // pub fn GlobalHandle(); + pub fn GlobalLock(hMem: HGLOBAL) -> LPVOID; + // pub fn GlobalMemoryStatus(); + // pub fn GlobalMemoryStatusEx(); + // pub fn GlobalReAlloc(); + // pub fn GlobalSize(); + // pub fn GlobalUnWire(); + // pub fn GlobalUnfix(); + pub fn GlobalUnlock(hMem: HGLOBAL) -> BOOL; + // pub fn GlobalWire(); + // pub fn Heap32First(); + // pub fn Heap32ListFirst(); + // pub fn Heap32ListNext(); + // pub fn Heap32Next(); + pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID; + pub fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) -> SIZE_T; + pub fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) -> HANDLE; + pub fn HeapDestroy(hHeap: HANDLE) -> BOOL; + pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL; + pub fn HeapLock(hHeap: HANDLE) -> BOOL; + pub fn HeapQueryInformation( + HeapHandle: HANDLE, HeapInformationClass: HEAP_INFORMATION_CLASS, HeapInformation: PVOID, + HeapInformationLength: SIZE_T, ReturnLength: PSIZE_T, + ) -> BOOL; + pub fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID; + pub fn HeapSetInformation( + HeapHandle: HANDLE, HeapInformationClass: HEAP_INFORMATION_CLASS, HeapInformation: PVOID, + HeapInformationLength: SIZE_T, + ) -> BOOL; + pub fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID) -> SIZE_T; + pub fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) -> BOOL; + pub fn HeapUnlock(hHeap: HANDLE) -> BOOL; + pub fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID) -> BOOL; + pub fn HeapWalk(hHeap: HANDLE, lpEntry: LPPROCESS_HEAP_ENTRY) -> BOOL; + // pub fn InitAtomTable(); + // pub fn InitOnceBeginInitialize(); + // pub fn InitOnceComplete(); + // pub fn InitOnceExecuteOnce(); + // pub fn InitOnceInitialize(); + // pub fn InitializeConditionVariable(); + // pub fn InitializeContext(); + pub fn InitializeCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); + pub fn InitializeCriticalSectionAndSpinCount( + lpCriticalSection: LPCRITICAL_SECTION, dwSpinCount: DWORD, + ) -> BOOL; + pub fn InitializeCriticalSectionEx( + lpCriticalSection: LPCRITICAL_SECTION, dwSpinCount: DWORD, Flags: DWORD, + ) -> BOOL; + // pub fn InitializeProcThreadAttributeList(); + // pub fn InitializeSListHead(); + pub fn InitializeSRWLock(SRWLock: PSRWLOCK); + // pub fn InitializeSynchronizationBarrier(); + // pub fn InstallELAMCertificateInfo(); + // #[cfg(target_arch = "x86")] + // pub fn InterlockedCompareExchange(); + // #[cfg(target_arch = "x86")] + // pub fn InterlockedCompareExchange64(); + // #[cfg(target_arch = "x86")] + // pub fn InterlockedDecrement(); + // #[cfg(target_arch = "x86")] + // pub fn InterlockedExchange(); + // #[cfg(target_arch = "x86")] + // pub fn InterlockedExchangeAdd(); + // pub fn InterlockedFlushSList(); + // #[cfg(target_arch = "x86")] + // pub fn InterlockedIncrement(); + // pub fn InterlockedPopEntrySList(); + // pub fn InterlockedPushEntrySList(); + // pub fn InterlockedPushListSList(); + // pub fn InterlockedPushListSListEx(); + // pub fn IsBadCodePtr(); + // pub fn IsBadHugeReadPtr(); + // pub fn IsBadHugeWritePtr(); + // pub fn IsBadReadPtr(); + // pub fn IsBadStringPtrA(); + // pub fn IsBadStringPtrW(); + // pub fn IsBadWritePtr(); + // pub fn IsDBCSLeadByte(); + // pub fn IsDBCSLeadByteEx(); + // pub fn IsDebuggerPresent(); + // pub fn IsNLSDefinedString(); + // pub fn IsNativeVhdBoot(); + // pub fn IsNormalizedString(); + // pub fn IsProcessCritical(); + // pub fn IsProcessInJob(); + // pub fn IsProcessorFeaturePresent(); + // pub fn IsSystemResumeAutomatic(); + // pub fn IsThreadAFiber(); + // pub fn IsThreadpoolTimerSet(); + // pub fn IsValidCodePage(); + // pub fn IsValidLanguageGroup(); + // pub fn IsValidLocale(); + // pub fn IsValidLocaleName(); + // pub fn IsValidNLSVersion(); + // pub fn IsWow64Process(); + // pub fn K32EmptyWorkingSet(); + // pub fn K32EnumDeviceDrivers(); + // pub fn K32EnumPageFilesA(); + // pub fn K32EnumPageFilesW(); + // pub fn K32EnumProcessModules(); + // pub fn K32EnumProcessModulesEx(); + pub fn K32EnumProcesses( + lpidProcess: *mut DWORD, cb: DWORD, lpcbNeeded: LPDWORD, + ) -> BOOL; + // pub fn K32GetDeviceDriverBaseNameA(); + // pub fn K32GetDeviceDriverBaseNameW(); + // pub fn K32GetDeviceDriverFileNameA(); + // pub fn K32GetDeviceDriverFileNameW(); + // pub fn K32GetMappedFileNameA(); + // pub fn K32GetMappedFileNameW(); + // pub fn K32GetModuleBaseNameA(); + // pub fn K32GetModuleBaseNameW(); + // pub fn K32GetModuleFileNameExA(); + pub fn K32GetModuleFileNameExW( + hProcess: HANDLE, hModule: HMODULE, lpFilename: LPWSTR, nSize: DWORD, + ) -> DWORD; + // pub fn K32GetModuleInformation(); + // pub fn K32GetPerformanceInfo(); + pub fn K32GetProcessImageFileNameA( + hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD, + ) -> DWORD; + pub fn K32GetProcessImageFileNameW( + hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD, + ) -> DWORD; + pub fn K32GetProcessMemoryInfo( + Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD, + ) -> BOOL; + // pub fn K32GetWsChanges(); + // pub fn K32GetWsChangesEx(); + // pub fn K32InitializeProcessForWsWatch(); + // pub fn K32QueryWorkingSet(); + // pub fn K32QueryWorkingSetEx(); + // pub fn LCIDToLocaleName(); + // pub fn LCMapStringA(); + // pub fn LCMapStringEx(); + // pub fn LCMapStringW(); + pub fn LeaveCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); + // pub fn LeaveCriticalSectionWhenCallbackReturns(); + // pub fn LoadAppInitDlls(); + pub fn LoadLibraryA(lpFileName: LPCSTR) -> HMODULE; + // pub fn LoadLibraryExA(); + // pub fn LoadLibraryExW(); + pub fn LoadLibraryW(lpFileName: LPCWSTR) -> HMODULE; + // pub fn LoadModule(); + // pub fn LoadPackagedLibrary(); + // pub fn LoadResource(); + // pub fn LoadStringBaseExW(); + // pub fn LoadStringBaseW(); + // pub fn LocalAlloc(); + // pub fn LocalCompact(); + pub fn LocalFileTimeToFileTime( + lpLocalFileTime: *const FILETIME, lpFileTime: LPFILETIME, + ) -> BOOL; + // pub fn LocalFlags(); + pub fn LocalFree(hMem: HLOCAL) -> HLOCAL; + // pub fn LocalHandle(); + // pub fn LocalLock(); + // pub fn LocalReAlloc(); + // pub fn LocalShrink(); + // pub fn LocalSize(); + // pub fn LocalUnlock(); + // pub fn LocaleNameToLCID(); + // #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + // pub fn LocateXStateFeature(); + pub fn LockFile( + hFile: HANDLE, dwFileOffsetLow: DWORD, dwFileOffsetHigh: DWORD, + nNumberOfBytesToLockLow: DWORD, nNumberOfBytesToLockHigh: DWORD, + ) -> BOOL; + pub fn LockFileEx( + hFile: HANDLE, dwFlags: DWORD, dwReserved: DWORD, nNumberOfBytesToLockLow: DWORD, + nNumberOfBytesToLockHigh: DWORD, lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + // pub fn LockResource(); + // pub fn MapUserPhysicalPages(); + // pub fn MapUserPhysicalPagesScatter(); + pub fn MapViewOfFile( + hFileMappingObject: HANDLE, dwDesiredAccess: DWORD, dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, + ) -> LPVOID; + pub fn MapViewOfFileEx( + hFileMappingObject: HANDLE, dwDesiredAccess: DWORD, dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, lpBaseAddress: LPVOID, + ) -> LPVOID; + // pub fn MapViewOfFileExNuma(); + // pub fn MapViewOfFileFromApp(); + // pub fn Module32First(); + // pub fn Module32FirstW(); + // pub fn Module32Next(); + // pub fn Module32NextW(); + // pub fn MoveFileA(); + pub fn MoveFileExA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, dwFlags: DWORD) -> BOOL; + pub fn MoveFileExW( + lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, dwFlags: DWORD, + ) -> BOOL; + // pub fn MoveFileTransactedA(); + // pub fn MoveFileTransactedW(); + // pub fn MoveFileW(); + // pub fn MoveFileWithProgressA(); + // pub fn MoveFileWithProgressW(); + // pub fn MulDiv(); + pub fn MultiByteToWideChar( + CodePage: UINT, dwFlags: DWORD, lpMultiByteStr: LPCCH, cbMultiByte: c_int, + lpWideCharStr: LPWSTR, cchWideChar: c_int, + ) -> c_int; + // pub fn NeedCurrentDirectoryForExePathA(); + // pub fn NeedCurrentDirectoryForExePathW(); + // pub fn NormalizeString(); + // pub fn NotifyMountMgr(); + // pub fn NotifyUILanguageChange(); + // pub fn OOBEComplete(); + // pub fn OpenEventA(); + // pub fn OpenEventW(); + // pub fn OpenFile(); + // pub fn OpenFileById(); + pub fn OpenFileMappingA( + dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR, + ) -> HANDLE; + pub fn OpenFileMappingW( + dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR, + ) -> HANDLE; + // pub fn OpenJobObjectA(); + // pub fn OpenJobObjectW(); + // pub fn OpenMutexA(); + // pub fn OpenMutexW(); + // pub fn OpenPackageInfoByFullName(); + // pub fn OpenPrivateNamespaceA(); + // pub fn OpenPrivateNamespaceW(); + pub fn OpenProcess(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwProcessId: DWORD) -> HANDLE; + pub fn OpenSemaphoreA(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE; + pub fn OpenSemaphoreW(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE; + // pub fn OpenState(); + // pub fn OpenStateExplicit(); + // pub fn OpenThread(); + // pub fn OpenWaitableTimerA(); + // pub fn OpenWaitableTimerW(); + // pub fn OutputDebugStringA(); + // pub fn OutputDebugStringW(); + // pub fn PackageFamilyNameFromFullName(); + // pub fn PackageFamilyNameFromId(); + // pub fn PackageFullNameFromId(); + // pub fn PackageIdFromFullName(); + // pub fn PackageNameAndPublisherIdFromFamilyName(); + // pub fn ParseApplicationUserModelId(); + pub fn PeekConsoleInputA( + hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn PeekConsoleInputW( + hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + // pub fn PeekNamedPipe(); + pub fn PostQueuedCompletionStatus( + CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + // pub fn PowerClearRequest(); + // pub fn PowerCreateRequest(); + // pub fn PowerSetRequest(); + // pub fn PrefetchVirtualMemory(); + // pub fn PrepareTape(); + // pub fn Process32First(); + // pub fn Process32FirstW(); + // pub fn Process32Next(); + // pub fn Process32NextW(); + // pub fn ProcessIdToSessionId(); + // pub fn PssCaptureSnapshot(); + // pub fn PssDuplicateSnapshot(); + // pub fn PssFreeSnapshot(); + // pub fn PssQuerySnapshot(); + // pub fn PssWalkMarkerCreate(); + // pub fn PssWalkMarkerFree(); + // pub fn PssWalkMarkerGetPosition(); + // pub fn PssWalkMarkerRewind(); + // pub fn PssWalkMarkerSeek(); + // pub fn PssWalkMarkerSeekToBeginning(); + // pub fn PssWalkMarkerSetPosition(); + // pub fn PssWalkMarkerTell(); + // pub fn PssWalkSnapshot(); + // pub fn PulseEvent(); + // pub fn PurgeComm(); + // pub fn QueryActCtxSettingsW(); + // pub fn QueryActCtxW(); + // pub fn QueryDepthSList(); + // pub fn QueryDosDeviceA(); + pub fn QueryDosDeviceW(lpDeviceName: LPCWSTR, lpTargetPath: LPWSTR, ucchMax: DWORD) -> DWORD; + // pub fn QueryFullProcessImageNameA(); + // pub fn QueryFullProcessImageNameW(); + // pub fn QueryIdleProcessorCycleTime(); + // pub fn QueryIdleProcessorCycleTimeEx(); + pub fn QueryInformationJobObject( + hJob: HANDLE, JobObjectInformationClass: JOBOBJECTINFOCLASS, + lpJobObjectInformation: LPVOID, cbJobObjectInformationLength: DWORD, + lpReturnLength: LPDWORD, + ) -> BOOL; + // pub fn QueryMemoryResourceNotification(); + pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; + pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL; + // pub fn QueryProcessAffinityUpdateMode(); + // pub fn QueryProcessCycleTime(); + // pub fn QueryProtectedPolicy(); + // pub fn QueryThreadCycleTime(); + // pub fn QueryThreadProfiling(); + // pub fn QueryThreadpoolStackInformation(); + // #[cfg(target_arch = "x86_64")] + // pub fn QueryUmsThreadInformation(); + // pub fn QueryUnbiasedInterruptTime(); + pub fn QueueUserAPC(pfnAPC: PAPCFUNC, hThread: HANDLE, dwData: ULONG_PTR) -> DWORD; + // pub fn QueueUserWorkItem(); + // pub fn RaiseException(); + // pub fn RaiseFailFastException(); + pub fn ReOpenFile( + hOriginalFile: HANDLE, dwDesiredAccess: DWORD, dwShareMode: DWORD, dwFlags: DWORD, + ) -> HANDLE; + pub fn ReadConsoleA( + hConsoleInput: HANDLE, lpBuffer: LPVOID, nNumberOfCharsToRead: DWORD, + lpNumberOfCharsRead: LPDWORD, pInputControl: PCONSOLE_READCONSOLE_CONTROL, + ) -> BOOL; + pub fn ReadConsoleInputA( + hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleInputW( + hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputA( + hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO, dwBufferSize: COORD, dwBufferCoord: COORD, + lpReadRegion: PSMALL_RECT, + ) -> BOOL; + pub fn ReadConsoleOutputAttribute( + hConsoleOutput: HANDLE, lpAttribute: LPWORD, nLength: DWORD, dwReadCoord: COORD, + lpNumberOfAttrsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputCharacterA( + hConsoleOutput: HANDLE, lpCharacter: LPSTR, nLength: DWORD, dwReadCoord: COORD, + lpNumberOfCharsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputCharacterW( + hConsoleOutput: HANDLE, lpCharacter: LPWSTR, nLength: DWORD, dwReadCoord: COORD, + lpNumberOfCharsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputW( + hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO, dwBufferSize: COORD, dwBufferCoord: COORD, + lpReadRegion: PSMALL_RECT, + ) -> BOOL; + pub fn ReadConsoleW( + hConsoleInput: HANDLE, lpBuffer: LPVOID, nNumberOfCharsToRead: DWORD, + lpNumberOfCharsRead: LPDWORD, pInputControl: PCONSOLE_READCONSOLE_CONTROL, + ) -> BOOL; + pub fn ReadDirectoryChangesW( + hDirectory: HANDLE, lpBuffer: LPVOID, nBufferLength: DWORD, bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, lpBytesReturned: LPDWORD, lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ) -> BOOL; + pub fn ReadFile( + hFile: HANDLE, lpBuffer: LPVOID, nNumberOfBytesToRead: DWORD, lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn ReadFileEx( + hFile: HANDLE, lpBuffer: LPVOID, nNumberOfBytesToRead: DWORD, lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ) -> BOOL; + pub fn ReadFileScatter( + hFile: HANDLE, aSegmentArray: *mut FILE_SEGMENT_ELEMENT, nNumberOfBytesToRead: DWORD, + lpReserved: LPDWORD, lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn ReadProcessMemory( + hProcess: HANDLE, lpBaseAddress: LPCVOID, lpBuffer: LPVOID, nSize: SIZE_T, + lpNumberOfBytesRead: *mut SIZE_T, + ) -> BOOL; + // pub fn ReadThreadProfilingData(); + // pub fn RegisterApplicationRecoveryCallback(); + // pub fn RegisterApplicationRestart(); + // pub fn RegisterBadMemoryNotification(); + // pub fn RegisterWaitForInputIdle(); + pub fn RegisterWaitForSingleObject( + phNewWaitObject: PHANDLE, hObject: HANDLE, Callback: WAITORTIMERCALLBACK, Context: PVOID, + dwMilliseconds: ULONG, dwFlags: ULONG, + ) -> BOOL; + // pub fn RegisterWaitForSingleObjectEx(); + // pub fn RegisterWaitUntilOOBECompleted(); + // pub fn ReleaseActCtx(); + // pub fn ReleaseMutex(); + // pub fn ReleaseMutexWhenCallbackReturns(); + pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK); + pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK); + pub fn ReleaseSemaphore( + hSemaphore: HANDLE, lReleaseCount: LONG, lpPreviousCount: LPLONG, + ) -> BOOL; + // pub fn ReleaseSemaphoreWhenCallbackReturns(); + pub fn RemoveDirectoryA(lpPathName: LPCSTR) -> BOOL; + // pub fn RemoveDirectoryTransactedA(); + // pub fn RemoveDirectoryTransactedW(); + pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; + // pub fn RemoveDllDirectory(); + // pub fn RemoveLocalAlternateComputerNameA(); + // pub fn RemoveLocalAlternateComputerNameW(); + // pub fn RemoveSecureMemoryCacheCallback(); + // pub fn RemoveVectoredContinueHandler(); + // pub fn RemoveVectoredExceptionHandler(); + // pub fn ReplaceFile(); + // pub fn ReplaceFileA(); + // pub fn ReplaceFileW(); + // pub fn ReplacePartitionUnit(); + // pub fn RequestDeviceWakeup(); + // pub fn RequestWakeupLatency(); + // pub fn ResetEvent(); + // pub fn ResetWriteWatch(); + // pub fn ResolveDelayLoadedAPI(); + // pub fn ResolveDelayLoadsFromDll(); + // pub fn ResolveLocaleName(); + // pub fn RestoreLastError(); + // pub fn ResumeThread(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlAddFunctionTable(); + pub fn RtlCaptureContext(ContextRecord: PCONTEXT); + // pub fn RtlCaptureStackBackTrace(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlCompareMemory(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlCopyMemory(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlDeleteFunctionTable(); + // pub fn RtlFillMemory(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlInstallFunctionTableCallback(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlLookupFunctionEntry(); + // pub fn RtlMoveMemory(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlPcToFileHeader(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlRaiseException(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlRestoreContext(); + // pub fn RtlUnwind(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlUnwindEx(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn RtlVirtualUnwind(); + // pub fn RtlZeroMemory(); + pub fn ScrollConsoleScreenBufferA( + hConsoleOutput: HANDLE, lpScrollRectangle: *const SMALL_RECT, + lpClipRectangle: *const SMALL_RECT, dwDestinationOrigin: COORD, lpFill: *const CHAR_INFO, + ) -> BOOL; + pub fn ScrollConsoleScreenBufferW( + hConsoleOutput: HANDLE, lpScrollRectangle: *const SMALL_RECT, + lpClipRectangle: *const SMALL_RECT, dwDestinationOrigin: COORD, lpFill: *const CHAR_INFO, + ) -> BOOL; + // pub fn SearchPathA(); + // pub fn SearchPathW(); + // pub fn SetCachedSigningLevel(); + // pub fn SetCalendarInfoA(); + // pub fn SetCalendarInfoW(); + // pub fn SetCommBreak(); + // pub fn SetCommConfig(); + // pub fn SetCommMask(); + // pub fn SetCommState(); + // pub fn SetCommTimeouts(); + // pub fn SetComputerNameA(); + // pub fn SetComputerNameEx2W(); + // pub fn SetComputerNameExA(); + // pub fn SetComputerNameExW(); + // pub fn SetComputerNameW(); + pub fn SetConsoleActiveScreenBuffer(hConsoleOutput: HANDLE) -> BOOL; + pub fn SetConsoleCP(wCodePageID: UINT) -> BOOL; + pub fn SetConsoleCtrlHandler(HandlerRoutine: PHANDLER_ROUTINE, Add: BOOL) -> BOOL; + // pub fn SetConsoleCursor(); + pub fn SetConsoleCursorInfo( + hConsoleOutput: HANDLE, lpConsoleCursorInfo: *const CONSOLE_CURSOR_INFO, + ) -> BOOL; + pub fn SetConsoleCursorPosition(hConsoleOutput: HANDLE, dwCursorPosition: COORD) -> BOOL; + pub fn SetConsoleDisplayMode( + hConsoleOutput: HANDLE, dwFlags: DWORD, lpNewScreenBufferDimensions: PCOORD, + ) -> BOOL; + pub fn SetConsoleHistoryInfo(lpConsoleHistoryInfo: PCONSOLE_HISTORY_INFO) -> BOOL; + pub fn SetConsoleMode(hConsoleHandle: HANDLE, dwMode: DWORD) -> BOOL; + pub fn SetConsoleOutputCP(wCodePageID: UINT) -> BOOL; + pub fn SetConsoleScreenBufferInfoEx( + hConsoleOutput: HANDLE, lpConsoleScreenBufferInfoEx: PCONSOLE_SCREEN_BUFFER_INFOEX, + ) -> BOOL; + pub fn SetConsoleScreenBufferSize(hConsoleOutput: HANDLE, dwSize: COORD) -> BOOL; + pub fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) -> BOOL; + pub fn SetConsoleTitleA(lpConsoleTitle: LPCSTR) -> BOOL; + pub fn SetConsoleTitleW(lpConsoleTitle: LPCWSTR) -> BOOL; + pub fn SetConsoleWindowInfo( + hConsoleOutput: HANDLE, bAbsolute: BOOL, lpConsoleWindow: *const SMALL_RECT, + ) -> BOOL; + pub fn SetCriticalSectionSpinCount( + lpCriticalSection: LPCRITICAL_SECTION, dwSpinCount: DWORD, + ) -> DWORD; + // pub fn SetCurrentConsoleFontEx(); + pub fn SetCurrentDirectoryA(lpPathName: LPCSTR) -> BOOL; + pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; + // pub fn SetDefaultCommConfigA(); + // pub fn SetDefaultCommConfigW(); + // pub fn SetDefaultDllDirectories(); + // pub fn SetDllDirectoryA(); + // pub fn SetDllDirectoryW(); + pub fn SetDynamicTimeZoneInformation( + lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, + ) -> BOOL; + pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; + // pub fn SetEnvironmentStringsA(); + // pub fn SetEnvironmentStringsW(); + // pub fn SetEnvironmentVariableA(); + // pub fn SetEnvironmentVariableW(); + // pub fn SetErrorMode(); + // pub fn SetEvent(); + // pub fn SetEventWhenCallbackReturns(); + // pub fn SetFileApisToANSI(); + // pub fn SetFileApisToOEM(); + pub fn SetFileAttributesA(lpFileName: LPCSTR, dwFileAttributes: DWORD) -> BOOL; + // pub fn SetFileAttributesTransactedA(); + // pub fn SetFileAttributesTransactedW(); + pub fn SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL; + // pub fn SetFileBandwidthReservation(); + // pub fn SetFileCompletionNotificationModes(); + pub fn SetFileInformationByHandle( + hFile: HANDLE, FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, lpFileInformation: LPVOID, + dwBufferSize: DWORD, + ) -> BOOL; + pub fn SetFileIoOverlappedRange( + FileHandle: HANDLE, OverlappedRangeStart: PUCHAR, Length: ULONG, + ) -> BOOL; + pub fn SetFilePointer( + hFile: HANDLE, lDistanceToMove: LONG, lpDistanceToMoveHigh: PLONG, dwMoveMethod: DWORD, + ) -> DWORD; + pub fn SetFilePointerEx( + hFile: HANDLE, liDistanceToMove: LARGE_INTEGER, lpNewFilePointer: PLARGE_INTEGER, + dwMoveMethod: DWORD, + ) -> BOOL; + // pub fn SetFileShortNameA(); + // pub fn SetFileShortNameW(); + pub fn SetFileTime( + hFile: HANDLE, lpCreationTime: *const FILETIME, lpLastAccessTime: *const FILETIME, + lpLastWriteTime: *const FILETIME, + ) -> BOOL; + pub fn SetFileValidData(hFile: HANDLE, ValidDataLength: LONGLONG) -> BOOL; + // pub fn SetFirmwareEnvironmentVariableA(); + // pub fn SetFirmwareEnvironmentVariableExA(); + // pub fn SetFirmwareEnvironmentVariableExW(); + // pub fn SetFirmwareEnvironmentVariableW(); + // pub fn SetHandleCount(); + // pub fn SetHandleInformation(); + pub fn SetInformationJobObject( + hJob: HANDLE, JobObjectInformationClass: JOBOBJECTINFOCLASS, + lpJobObjectInformation: LPVOID, cbJobObjectInformationLength: DWORD, + ) -> BOOL; + pub fn SetLastError(dwErrCode: DWORD); + // pub fn SetLocalPrimaryComputerNameA(); + // pub fn SetLocalPrimaryComputerNameW(); + pub fn SetLocalTime(lpSystemTime: *const SYSTEMTIME) -> BOOL; + // pub fn SetLocaleInfoA(); + // pub fn SetLocaleInfoW(); + // pub fn SetMailslotInfo(); + // pub fn SetMessageWaitingIndicator(); + // pub fn SetNamedPipeAttribute(); + // pub fn SetNamedPipeHandleState(); + pub fn SetPriorityClass(hProcess: HANDLE, dwPriorityClass: DWORD); + // pub fn SetProcessAffinityMask(); + // pub fn SetProcessAffinityUpdateMode(); + // pub fn SetProcessDEPPolicy(); + // pub fn SetProcessInformation(); + // pub fn SetProcessMitigationPolicy(); + // pub fn SetProcessPreferredUILanguages(); + // pub fn SetProcessPriorityBoost(); + // pub fn SetProcessShutdownParameters(); + // pub fn SetProcessWorkingSetSize(); + // pub fn SetProcessWorkingSetSizeEx(); + // pub fn SetProtectedPolicy(); + // pub fn SetSearchPathMode(); + // pub fn SetStdHandle(); + // pub fn SetStdHandleEx(); + // pub fn SetSystemFileCacheSize(); + // pub fn SetSystemPowerState(); + pub fn SetSystemTime(lpSystemTime: *const SYSTEMTIME) -> BOOL; + pub fn SetSystemTimeAdjustment(dwTimeAdjustment: DWORD, bTimeAdjustmentDisabled: BOOL) -> BOOL; + // pub fn SetTapeParameters(); + // pub fn SetTapePosition(); + // pub fn SetThreadAffinityMask(); + // pub fn SetThreadContext(); + // pub fn SetThreadErrorMode(); + // pub fn SetThreadExecutionState(); + // pub fn SetThreadGroupAffinity(); + // pub fn SetThreadIdealProcessor(); + // pub fn SetThreadIdealProcessorEx(); + // pub fn SetThreadInformation(); + // pub fn SetThreadLocale(); + // pub fn SetThreadPreferredUILanguages(); + // pub fn SetThreadPriority(); + // pub fn SetThreadPriorityBoost(); + // pub fn SetThreadStackGuarantee(); + // pub fn SetThreadUILanguage(); + // pub fn SetThreadpoolStackInformation(); + // pub fn SetThreadpoolThreadMaximum(); + // pub fn SetThreadpoolThreadMinimum(); + // pub fn SetThreadpoolTimer(); + // pub fn SetThreadpoolTimerEx(); + // pub fn SetThreadpoolWait(); + // pub fn SetThreadpoolWaitEx(); + pub fn SetTimeZoneInformation(lpTimeZoneInformation: *const TIME_ZONE_INFORMATION) -> BOOL; + // pub fn SetTimerQueueTimer(); + // #[cfg(target_arch = "x86_64")] + // pub fn SetUmsThreadInformation(); + // pub fn SetUnhandledExceptionFilter(); + // pub fn SetUserGeoID(); + // pub fn SetVolumeLabelA(); + // pub fn SetVolumeLabelW(); + // pub fn SetVolumeMountPointA(); + // pub fn SetVolumeMountPointW(); + // pub fn SetWaitableTimer(); + // pub fn SetWaitableTimerEx(); + // #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + // pub fn SetXStateFeaturesMask(); + // pub fn SetupComm(); + // pub fn SignalObjectAndWait(); + // pub fn SizeofResource(); + pub fn Sleep(dwMilliseconds: DWORD); + // pub fn SleepConditionVariableCS(); + // pub fn SleepConditionVariableSRW(); + pub fn SleepEx(dwMilliseconds: DWORD, bAlertable: BOOL) -> DWORD; + // pub fn StartThreadpoolIo(); + // pub fn SubmitThreadpoolWork(); + // pub fn SuspendThread(); + // pub fn SwitchToFiber(); + // pub fn SwitchToThread(); + pub fn SystemTimeToFileTime( + lpSystemTime: *const SYSTEMTIME, lpFileTime: LPFILETIME, + ) -> BOOL; + pub fn SystemTimeToTzSpecificLocalTime( + lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, lpUniversalTime: *const SYSTEMTIME, + lpLocalTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn SystemTimeToTzSpecificLocalTimeEx( + lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, + lpUniversalTime: *const SYSTEMTIME, lpLocalTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn TerminateJobObject(hJob: HANDLE, uExitCode: UINT) -> BOOL; + pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL; + // pub fn TerminateThread(); + // pub fn Thread32First(); + // pub fn Thread32Next(); + // pub fn TlsAlloc(); + // pub fn TlsFree(); + // pub fn TlsGetValue(); + // pub fn TlsSetValue(); + // pub fn Toolhelp32ReadProcessMemory(); + // pub fn TransactNamedPipe(); + // pub fn TransmitCommChar(); + pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN; + pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN; + pub fn TryEnterCriticalSection(lpCriticalSection: LPCRITICAL_SECTION) -> BOOL; + // pub fn TrySubmitThreadpoolCallback(); + pub fn TzSpecificLocalTimeToSystemTime( + lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, lpLocalTime: *const SYSTEMTIME, + lpUniversalTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn TzSpecificLocalTimeToSystemTimeEx( + lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, + lpLocalTime: *const SYSTEMTIME, lpUniversalTime: LPSYSTEMTIME, + ) -> BOOL; + // #[cfg(target_arch = "x86_64")] + // pub fn UmsThreadYield(); + // pub fn UnhandledExceptionFilter(); + pub fn UnlockFile( + hFile: HANDLE, dwFileOffsetLow: DWORD, dwFileOffsetHigh: DWORD, + nNumberOfBytesToUnlockLow: DWORD, nNumberOfBytesToUnlockHigh: DWORD, + ) -> BOOL; + pub fn UnlockFileEx( + hFile: HANDLE, dwReserved: DWORD, nNumberOfBytesToUnlockLow: DWORD, + nNumberOfBytesToUnlockHigh: DWORD, lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; + // pub fn UnregisterApplicationRecoveryCallback(); + // pub fn UnregisterApplicationRestart(); + // pub fn UnregisterBadMemoryNotification(); + pub fn UnregisterWait(WaitHandle: HANDLE) -> BOOL; + pub fn UnregisterWaitEx(WaitHandle: HANDLE, CompletionEvent: HANDLE) -> BOOL; + // pub fn UnregisterWaitUntilOOBECompleted(); + // pub fn UpdateProcThreadAttribute(); + // pub fn UpdateResourceA(); + // pub fn UpdateResourceW(); + // pub fn VerLanguageNameA(); + // pub fn VerLanguageNameW(); + // pub fn VerSetConditionMask(); + // pub fn VerifyScripts(); + // pub fn VerifyVersionInfoA(); + // pub fn VerifyVersionInfoW(); + pub fn VirtualAlloc( + lpAddress: LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD + ) -> LPVOID; + // pub fn VirtualAllocEx(); + // pub fn VirtualAllocExNuma(); + pub fn VirtualFree(lpAddress: LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) -> BOOL; + // pub fn VirtualFreeEx(); + // pub fn VirtualLock(); + // pub fn VirtualProtect(); + // pub fn VirtualProtectEx(); + // pub fn VirtualQuery(); + // pub fn VirtualQueryEx(); + // pub fn VirtualUnlock(); + // pub fn WTSGetActiveConsoleSessionId(); + // pub fn WaitCommEvent(); + // pub fn WaitForDebugEvent(); + // pub fn WaitForMultipleObjects(); + // pub fn WaitForMultipleObjectsEx(); + // pub fn WaitForSingleObject(); + // pub fn WaitForSingleObjectEx(); + // pub fn WaitForThreadpoolIoCallbacks(); + // pub fn WaitForThreadpoolTimerCallbacks(); + // pub fn WaitForThreadpoolWaitCallbacks(); + // pub fn WaitForThreadpoolWorkCallbacks(); + // pub fn WaitNamedPipeA(); + // pub fn WaitNamedPipeW(); + // pub fn WakeAllConditionVariable(); + // pub fn WakeConditionVariable(); + // pub fn WerGetFlags(); + // pub fn WerRegisterFile(); + // pub fn WerRegisterMemoryBlock(); + // pub fn WerRegisterRuntimeExceptionModule(); + // pub fn WerSetFlags(); + // pub fn WerUnregisterFile(); + // pub fn WerUnregisterMemoryBlock(); + // pub fn WerUnregisterRuntimeExceptionModule(); + // pub fn WerpInitiateRemoteRecovery(); + pub fn WideCharToMultiByte( + CodePage: UINT, dwFlags: DWORD, lpWideCharStr: LPCWCH, cchWideChar: c_int, + lpMultiByteStr: LPSTR, cbMultiByte: c_int, lpDefaultChar: LPCCH, lpUsedDefaultChar: LPBOOL, + ) -> c_int; + pub fn WinExec(lpCmdLine: LPCSTR, uCmdShow: UINT) -> UINT; + // pub fn Wow64DisableWow64FsRedirection(); + // pub fn Wow64EnableWow64FsRedirection(); + // pub fn Wow64GetThreadContext(); + // pub fn Wow64GetThreadSelectorEntry(); + // pub fn Wow64RevertWow64FsRedirection(); + // pub fn Wow64SetThreadContext(); + // pub fn Wow64SuspendThread(); + pub fn WriteConsoleA( + hConsoleOutput: HANDLE, lpBuffer: *const VOID, nNumberOfCharsToWrite: DWORD, + lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID, + ) -> BOOL; + pub fn WriteConsoleInputA( + hConsoleInput: HANDLE, lpBuffer: *const INPUT_RECORD, nLength: DWORD, + lpNumberOfEventsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleInputW( + hConsoleInput: HANDLE, lpBuffer: *const INPUT_RECORD, nLength: DWORD, + lpNumberOfEventsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputA( + hConsoleOutput: HANDLE, lpBuffer: *const CHAR_INFO, dwBufferSize: COORD, + dwBufferCoord: COORD, lpWriteRegion: PSMALL_RECT, + ) -> BOOL; + pub fn WriteConsoleOutputAttribute( + hConsoleOutput: HANDLE, lpAttribute: *const WORD, nLength: DWORD, dwWriteCoord: COORD, + lpNumberOfAttrsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputCharacterA( + hConsoleOutput: HANDLE, lpCharacter: LPCSTR, nLength: DWORD, dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputCharacterW( + hConsoleOutput: HANDLE, lpCharacter: LPCWSTR, nLength: DWORD, dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputW( + hConsoleOutput: HANDLE, lpBuffer: *const CHAR_INFO, dwBufferSize: COORD, + dwBufferCoord: COORD, lpWriteRegion: PSMALL_RECT, + ) -> BOOL; + pub fn WriteConsoleW( + hConsoleOutput: HANDLE, lpBuffer: *const VOID, nNumberOfCharsToWrite: DWORD, + lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID, + ) -> BOOL; + pub fn WriteFile( + hFile: HANDLE, lpBuffer: LPCVOID, nNumberOfBytesToWrite: DWORD, + lpNumberOfBytesWritten: LPDWORD, lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WriteFileEx( + hFile: HANDLE, lpBuffer: LPCVOID, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ) -> BOOL; + pub fn WriteFileGather( + hFile: HANDLE, aSegmentArray: *mut FILE_SEGMENT_ELEMENT, nNumberOfBytesToWrite: DWORD, + lpReserved: LPDWORD, lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + // pub fn WritePrivateProfileSectionA(); + // pub fn WritePrivateProfileSectionW(); + // pub fn WritePrivateProfileStringA(); + // pub fn WritePrivateProfileStringW(); + // pub fn WritePrivateProfileStructA(); + // pub fn WritePrivateProfileStructW(); + pub fn WriteProcessMemory( + hProcess: HANDLE, lpBaseAddress: LPVOID, lpBuffer: LPCVOID, nSize: SIZE_T, + lpNumberOfBytesWritten: *mut SIZE_T, + ) -> BOOL; + // pub fn WriteProfileSectionA(); + // pub fn WriteProfileSectionW(); + // pub fn WriteProfileStringA(); + // pub fn WriteProfileStringW(); + // pub fn WriteTapemark(); + // pub fn ZombifyActCtx(); + // pub fn _hread(); + // pub fn _hwrite(); + // pub fn _lclose(); + // pub fn _lcreat(); + // pub fn _llseek(); + // pub fn _lopen(); + // pub fn _lread(); + // pub fn _lwrite(); + // pub fn lstrcat(); + // pub fn lstrcatA(); + // pub fn lstrcatW(); + // pub fn lstrcmp(); + // pub fn lstrcmpA(); + // pub fn lstrcmpW(); + // pub fn lstrcmpi(); + // pub fn lstrcmpiA(); + // pub fn lstrcmpiW(); + // pub fn lstrcpy(); + // pub fn lstrcpyA(); + // pub fn lstrcpyW(); + // pub fn lstrcpyn(); + // pub fn lstrcpynA(); + // pub fn lstrcpynW(); + // pub fn lstrlen(); + // pub fn lstrlenA(); + // pub fn lstrlenW(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_lstrcmpW(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_lstrcmpiW(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_lstrlenW(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_wcschr(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_wcscpy(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_wcsicmp(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_wcslen(); + // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] + // pub fn uaw_wcsrchr(); +} diff --git a/deps/libc-0.1.8/Cargo.toml b/deps/libc-0.1.8/Cargo.toml new file mode 100644 index 000000000..996beac60 --- /dev/null +++ b/deps/libc-0.1.8/Cargo.toml @@ -0,0 +1,23 @@ +[package] + +name = "libc" +version = "0.1.8" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/libc" +homepage = "https://github.com/rust-lang/libc" +documentation = "http://doc.rust-lang.org/libc" +description = """ +A library for types and bindings to native C functions often found in libc or +other common platform libraries. +""" +include = ["Cargo.toml", "rust/src/liblibc/*"] + +[features] +default = ["cargo-build"] +cargo-build = [] + +[lib] +name = "libc" +path = "rust/src/liblibc/lib.rs" diff --git a/deps/libc-0.1.8/rust/src/liblibc/lib.rs b/deps/libc-0.1.8/rust/src/liblibc/lib.rs new file mode 100644 index 000000000..6e6d16f4e --- /dev/null +++ b/deps/libc-0.1.8/rust/src/liblibc/lib.rs @@ -0,0 +1,6386 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) +#![cfg_attr(stage0, feature(custom_attribute))] +#![crate_name = "libc"] +#![crate_type = "rlib"] +#![cfg_attr(not(feature = "cargo-build"), unstable(feature = "libc", + reason = "use `libc` from crates.io"))] +#![cfg_attr(not(feature = "cargo-build"), feature(staged_api, core, no_std))] +#![cfg_attr(not(feature = "cargo-build"), staged_api)] +#![cfg_attr(not(feature = "cargo-build"), no_std)] +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/nightly/", + html_playground_url = "http://play.rust-lang.org/")] +#![cfg_attr(test, feature(test))] + +//! Bindings for the C standard library and other platform libraries +//! +//! **NOTE:** These are *architecture and libc* specific. On Linux, these +//! bindings are only correct for glibc. +//! +//! This module contains bindings to the C standard library, organized into +//! modules by their defining standard. Additionally, it contains some assorted +//! platform-specific definitions. For convenience, most functions and types +//! are reexported, so `use libc::*` will import the available C bindings as +//! appropriate for the target platform. The exact set of functions available +//! are platform specific. +//! +//! *Note:* Because these definitions are platform-specific, some may not appear +//! in the generated documentation. +//! +//! We consider the following specs reasonably normative with respect to +//! interoperating with the C standard library (libc/msvcrt): +//! +//! * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995. +//! * ISO 9899:1999 ('C99' or 'C9x'). +//! * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1'). +//! * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3'). +//! * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4'). +//! +//! Note that any reference to the 1996 revision of POSIX, or any revs between +//! 1990 (when '88 was approved at ISO) and 2001 (when the next actual +//! revision-revision happened), are merely additions of other chapters (1b and +//! 1c) outside the core interfaces. +//! +//! Despite having several names each, these are *reasonably* coherent +//! point-in-time, list-of-definition sorts of specs. You can get each under a +//! variety of names but will wind up with the same definition in each case. +//! +//! See standards(7) in linux-manpages for more details. +//! +//! Our interface to these libraries is complicated by the non-universality of +//! conformance to any of them. About the only thing universally supported is +//! the first (C95), beyond that definitions quickly become absent on various +//! platforms. +//! +//! We therefore wind up dividing our module-space up (mostly for the sake of +//! sanity while editing, filling-in-details and eliminating duplication) into +//! definitions common-to-all (held in modules named c95, c99, posix88, posix01 +//! and posix08) and definitions that appear only on *some* platforms (named +//! 'extra'). This would be things like significant OSX foundation kit, or Windows +//! library kernel32.dll, or various fancy glibc, Linux or BSD extensions. +//! +//! In addition to the per-platform 'extra' modules, we define a module of +//! 'common BSD' libc routines that never quite made it into POSIX but show up +//! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final +//! one from Berkeley after the lawsuits died down and the CSRG dissolved. + +#![allow(bad_style, raw_pointer_derive)] +#![cfg_attr(target_os = "nacl", allow(unused_imports))] +#[cfg(feature = "cargo-build")] extern crate std as core; +#[cfg(not(feature = "cargo-build"))] extern crate core; + +#[cfg(test)] extern crate std; +#[cfg(test)] extern crate test; + +// Explicit export lists for the intersection (provided here) mean that +// you can write more-platform-agnostic code if you stick to just these +// symbols. + +pub use types::common::c95::*; +pub use types::common::c99::*; +pub use types::common::posix88::*; +pub use types::os::common::posix01::*; +pub use types::os::common::bsd44::*; +pub use types::os::arch::c95::*; +pub use types::os::arch::c99::*; +pub use types::os::arch::posix88::*; +pub use types::os::arch::posix01::*; +pub use types::os::arch::extra::*; + +pub use consts::os::c95::*; +pub use consts::os::posix88::*; +pub use consts::os::posix01::*; +pub use consts::os::bsd44::*; +pub use consts::os::extra::*; + +pub use funcs::c95::ctype::*; +pub use funcs::c95::stdio::*; +pub use funcs::c95::stdlib::*; +pub use funcs::c95::string::*; +pub use funcs::posix88::fcntl::*; +pub use funcs::posix88::stat_::*; +pub use funcs::posix88::stdio::*; +pub use funcs::posix88::unistd::*; + +pub use funcs::bsd43::*; + +// But we also reexport most everything +// if you're interested in writing platform-specific code. + +// FIXME: This is a mess, but the design of this entire module needs to be +// reconsidered, so I'm not inclined to do better right now. As part of +// #11870 I removed all the pub globs here, leaving explicit reexports +// of everything that is actually used in-tree. +// +// So the following exports don't follow any particular plan. + +#[cfg(unix)] pub use consts::os::sysconf::*; + +#[cfg(unix)] pub use funcs::posix88::mman::*; +#[cfg(unix)] pub use funcs::posix88::dirent::*; +#[cfg(unix)] pub use funcs::posix88::net::*; +#[cfg(unix)] pub use funcs::posix01::stat_::*; +#[cfg(unix)] pub use funcs::posix01::unistd::*; +#[cfg(unix)] pub use funcs::posix01::resource::*; + + +#[cfg(windows)] pub use funcs::extra::kernel32::*; +#[cfg(windows)] pub use funcs::extra::winsock::*; +#[cfg(windows)] pub use funcs::extra::msvcrt::*; + +// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them +// in when creating a test crate. +#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))] +#[link(name = "c")] +#[link(name = "m")] +extern {} + +#[cfg(all(target_env = "musl", not(test)))] +#[link(name = "c", kind = "static")] +extern {} + +// libnacl provides functions that require a trip through the IRT to work. +// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip +// to the kernel. +#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] +#[link(name = "nacl", kind = "static")] +extern {} + +// pnaclmm provides a number of functions that the toolchain's Clang emits calls +// to when codegening atomic ops. All the functions within wrap various atomic +// operations. +// Yes, it could be linked by rustc explicitly, however by linking it here +// instead we save a bit of time where bins are involved (by not running the +// optimizations on the whole pnaclmm foreach binary built). +#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] +#[link(name = "pnaclmm", kind = "static")] +extern {} + +pub mod types { + + // Types tend to vary *per architecture* so we pull their definitions out + // into this module. + + // Standard types that are opaque or common, so are not per-target. + pub mod common { + pub mod c95 { + /// Type used to construct void pointers for use with C. + /// + /// This type is only useful as a pointer target. Do not use it as a + /// return type for FFI functions which have the `void` return type in + /// C. Use the unit type `()` or omit the return type instead. + /// + /// For LLVM to recognize the void pointer type and by extension + /// functions like malloc(), we need to have it represented as i8* in + /// LLVM bitcode. The enum used here ensures this and prevents misuse + /// of the "raw" type by only having private variants.. We need two + /// variants, because the compiler complains about the repr attribute + /// otherwise. + #[repr(u8)] + pub enum c_void { + __variant1, + __variant2, + } + + pub enum FILE {} + pub enum fpos_t {} + } + pub mod c99 { + pub type int8_t = i8; + pub type int16_t = i16; + pub type int32_t = i32; + pub type int64_t = i64; + pub type uint8_t = u8; + pub type uint16_t = u16; + pub type uint32_t = u32; + pub type uint64_t = u64; + } + pub mod posix88 { + pub enum DIR {} + pub enum dirent_t {} + } + pub mod posix01 {} + pub mod posix08 {} + pub mod bsd44 {} + } + + // Standard types that are scalar but vary by OS and arch. + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_ulong, size_t, + time_t, suseconds_t, c_long}; + + #[cfg(not(target_os = "nacl"))] + pub type pthread_t = c_ulong; + #[cfg(target_os = "nacl")] + pub type pthread_t = *mut c_void; + pub type rlim_t = u64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + + pub __unused1: *mut c_void, + pub __unused2: *mut c_void, + pub __unused3: *mut c_void, + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + // This is also specified in POSIX 2001, but only has two fields. All implementors + // implement BSD 4.3 version. + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u16; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_align: isize, + #[cfg(target_pointer_width = "32")] + pub __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + pub __ss_pad2: [u8; 128 - 2 * 8], + } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + + #[cfg(target_os = "linux")] + pub ai_addr: *mut sockaddr, + + #[cfg(target_os = "linux")] + pub ai_canonname: *mut c_char, + + #[cfg(any(target_os = "android", target_os = "nacl"))] + pub ai_canonname: *mut c_char, + + #[cfg(any(target_os = "android", target_os = "nacl"))] + pub ai_addr: *mut sockaddr, + + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_ifu: *mut sockaddr, // FIXME This should be a union + pub ifa_data: *mut c_void + } + + } + } + + #[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc", + target_arch = "le32"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = i32; + pub type time_t = i32; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + #[cfg(any(target_arch = "x86", + target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc", + target_arch = "le32", + all(target_arch = "arm", not(target_os = "android"))))] + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u64; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = i32; + } + #[cfg(all(target_arch = "arm", target_os = "android"))] + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i32; + } + #[cfg(any(target_arch = "x86", + target_arch = "le32", + target_arch = "powerpc", + all(target_arch = "arm", not(target_os = "android"))))] + pub mod posix01 { + use types::os::arch::c95::{c_short, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub __pad1: c_short, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad2: c_short, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub __unused4: c_long, + pub __unused5: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u32; 9] + } + } + #[cfg(all(target_arch = "arm", target_os = "android"))] + pub mod posix01 { + use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t}; + use types::os::arch::c99::{c_longlong, c_ulonglong}; + use types::os::arch::posix88::{uid_t, gid_t, ino_t}; + + pub type nlink_t = u16; + pub type blksize_t = u32; + pub type blkcnt_t = u32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: c_ulonglong, + pub __pad0: [c_uchar; 4], + pub __st_ino: ino_t, + pub st_mode: c_uint, + pub st_nlink: c_uint, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: c_ulonglong, + pub __pad3: [c_uchar; 4], + pub st_size: c_longlong, + pub st_blksize: blksize_t, + pub st_blocks: c_ulonglong, + pub st_atime: time_t, + pub st_atime_nsec: c_ulong, + pub st_mtime: time_t, + pub st_mtime_nsec: c_ulong, + pub st_ctime: time_t, + pub st_ctime_nsec: c_ulong, + pub st_ino: c_ulonglong, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u32; 9] + } + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod posix01 { + use types::os::arch::c95::{c_long, c_ulong, time_t}; + use types::os::arch::posix88::{gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: c_ulong, + pub st_pad1: [c_long; 3], + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: c_ulong, + pub st_pad2: [c_long; 2], + pub st_size: off_t, + pub st_pad3: c_long, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_pad5: [c_long; 14], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u32; 9] + } + } + pub mod posix08 {} + pub mod bsd44 {} + pub mod extra { + use types::os::arch::c95::{c_ushort, c_int, c_uchar}; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8] + } + } + + } + + #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64"))] + pub mod arch { + pub mod c95 { + #[cfg(not(target_arch = "aarch64"))] + pub type c_char = i8; + #[cfg(target_arch = "aarch64")] + pub type c_char = u8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i64; + pub type time_t = i64; + pub type suseconds_t = i64; + #[cfg(not(target_arch = "aarch64"))] + pub type wchar_t = i32; + #[cfg(target_arch = "aarch64")] + pub type wchar_t = u32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u64; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = i64; + } + #[cfg(not(target_arch = "aarch64"))] + pub mod posix01 { + use types::os::arch::c95::{c_int, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u64; + pub type blksize_t = i64; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_mode: mode_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub __pad0: c_int, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub __unused: [c_long; 3], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u64; 7] + } + } + #[cfg(target_arch = "aarch64")] + pub mod posix01 { + use types::os::arch::c95::{c_int, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad1: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub __pad2: c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub __unused: [c_int; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u64; 8] + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + use types::os::arch::c95::{c_ushort, c_int, c_uchar}; + #[derive(Copy, Clone)] pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8] + } + + } + } + } + + #[cfg(target_os = "freebsd")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub __unused1: size_t, + pub gl_offs: size_t, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + + + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i32; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i64; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint8_t, uint32_t, int32_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i64; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub __unused: [uint8_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(target_os = "dragonfly")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub __unused1: size_t, + pub gl_offs: size_t, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i32; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i64; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint16_t, uint32_t, int32_t, uint64_t, int64_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = uint32_t; + pub type ino_t = uint64_t; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_padding1: uint16_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare1: int64_t, + pub st_qspare2: int64_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(any(target_os = "bitrig", target_os = "openbsd"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = u64; + + #[cfg(target_os = "bitrig")] + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: c_int, + pub gl_matchc: c_int, + pub gl_offs: c_int, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + pub __unused1: *mut c_void, + pub __unused2: *mut c_void, + pub __unused3: *mut c_void, + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + } + + #[cfg(target_os = "openbsd")] + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: c_int, + pub __unused1: c_int, + pub gl_offs: c_int, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + pub __unused9: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_pad2: i64, + pub __ss_pad3: [u8; 240], + } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i64; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::{c_long}; + pub type off_t = i64; + pub type dev_t = i32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, uint64_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = uint32_t; + pub type blksize_t = uint32_t; + pub type ino_t = uint64_t; + pub type blkcnt_t = i64; + pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_mode: mode_t, + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(target_os = "windows")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::os::arch::c95::{c_short, time_t, c_long}; + use types::os::arch::extra::{int64, time64_t}; + use types::os::arch::posix88::{dev_t, ino_t}; + + // pub Note: this is the struct called stat64 in Windows. Not stat, + // nor stati64. + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: u16, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: int64, + pub st_atime: time64_t, + pub st_mtime: time64_t, + pub st_ctime: time64_t, + } + + // note that this is called utimbuf64 in Windows + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time64_t, + pub modtime: time64_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + } + + pub mod bsd44 { + use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; + use types::os::arch::c99::uintptr_t; + + pub type SOCKET = uintptr_t; + pub type socklen_t = c_int; + pub type sa_family_t = u16; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: size_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + } + } + + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + + #[cfg(target_arch = "x86")] + pub type size_t = u32; + #[cfg(target_arch = "x86_64")] + pub type size_t = u64; + + #[cfg(target_arch = "x86")] + pub type ptrdiff_t = i32; + #[cfg(target_arch = "x86_64")] + pub type ptrdiff_t = i64; + + pub type clock_t = i32; + + #[cfg(target_arch = "x86")] + pub type time_t = i32; + #[cfg(target_arch = "x86_64")] + pub type time_t = i64; + + #[cfg(target_arch = "x86")] + pub type suseconds_t = i32; + #[cfg(target_arch = "x86_64")] + pub type suseconds_t = i64; + + pub type wchar_t = u16; + } + + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + + #[cfg(target_arch = "x86")] + pub type intptr_t = i32; + #[cfg(target_arch = "x86_64")] + pub type intptr_t = i64; + + #[cfg(target_arch = "x86")] + pub type uintptr_t = u32; + #[cfg(target_arch = "x86_64")] + pub type uintptr_t = u64; + + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u32; + pub type ino_t = u16; + + pub type pid_t = u32; + + pub type useconds_t = u32; + pub type mode_t = u16; + + #[cfg(target_arch = "x86")] + pub type ssize_t = i32; + #[cfg(target_arch = "x86_64")] + pub type ssize_t = i64; + } + + pub mod posix01 { + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + use consts::os::extra::{MAX_PROTOCOL_CHAIN, + WSAPROTOCOL_LEN}; + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; + use types::os::arch::c95::{c_long, c_ulong}; + use types::os::arch::c95::{wchar_t}; + use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t}; + + pub type BOOL = c_int; + pub type BYTE = u8; + pub type BOOLEAN = BYTE; + pub type CCHAR = c_char; + pub type CHAR = c_char; + + pub type DWORD = c_ulong; + pub type DWORDLONG = c_ulonglong; + + pub type HANDLE = LPVOID; + pub type HINSTANCE = HANDLE; + pub type HMODULE = HINSTANCE; + + pub type LONG = c_long; + pub type PLONG = *mut c_long; + + #[cfg(target_arch = "x86")] + pub type LONG_PTR = c_long; + #[cfg(target_arch = "x86_64")] + pub type LONG_PTR = i64; + + pub type LARGE_INTEGER = c_longlong; + pub type PLARGE_INTEGER = *mut c_longlong; + + pub type LPCWSTR = *const WCHAR; + pub type LPCSTR = *const CHAR; + + pub type LPWSTR = *mut WCHAR; + pub type LPSTR = *mut CHAR; + + pub type LPWCH = *mut WCHAR; + pub type LPCH = *mut CHAR; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES { + pub nLength: DWORD, + pub lpSecurityDescriptor: LPVOID, + pub bInheritHandle: BOOL, + } + pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; + + pub type LPVOID = *mut c_void; + pub type LPCVOID = *const c_void; + pub type LPBYTE = *mut BYTE; + pub type LPWORD = *mut WORD; + pub type LPDWORD = *mut DWORD; + pub type LPHANDLE = *mut HANDLE; + + pub type LRESULT = LONG_PTR; + pub type PBOOL = *mut BOOL; + pub type WCHAR = wchar_t; + pub type WORD = u16; + pub type SIZE_T = size_t; + + pub type time64_t = i64; + pub type int64 = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct STARTUPINFO { + pub cb: DWORD, + pub lpReserved: LPWSTR, + pub lpDesktop: LPWSTR, + pub lpTitle: LPWSTR, + pub dwX: DWORD, + pub dwY: DWORD, + pub dwXSize: DWORD, + pub dwYSize: DWORD, + pub dwXCountChars: DWORD, + pub dwYCountCharts: DWORD, + pub dwFillAttribute: DWORD, + pub dwFlags: DWORD, + pub wShowWindow: WORD, + pub cbReserved2: WORD, + pub lpReserved2: LPBYTE, + pub hStdInput: HANDLE, + pub hStdOutput: HANDLE, + pub hStdError: HANDLE, + } + pub type LPSTARTUPINFO = *mut STARTUPINFO; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { + pub hProcess: HANDLE, + pub hThread: HANDLE, + pub dwProcessId: DWORD, + pub dwThreadId: DWORD, + } + pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct SYSTEM_INFO { + pub wProcessorArchitecture: WORD, + pub wReserved: WORD, + pub dwPageSize: DWORD, + pub lpMinimumApplicationAddress: LPVOID, + pub lpMaximumApplicationAddress: LPVOID, + pub dwActiveProcessorMask: uintptr_t, + pub dwNumberOfProcessors: DWORD, + pub dwProcessorType: DWORD, + pub dwAllocationGranularity: DWORD, + pub wProcessorLevel: WORD, + pub wProcessorRevision: WORD, + } + pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION { + pub BaseAddress: LPVOID, + pub AllocationBase: LPVOID, + pub AllocationProtect: DWORD, + pub RegionSize: SIZE_T, + pub State: DWORD, + pub Protect: DWORD, + pub Type: DWORD, + } + pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct OVERLAPPED { + pub Internal: *mut c_ulong, + pub InternalHigh: *mut c_ulong, + pub Offset: DWORD, + pub OffsetHigh: DWORD, + pub hEvent: HANDLE, + } + + pub type LPOVERLAPPED = *mut OVERLAPPED; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, + } + + pub type LPFILETIME = *mut FILETIME; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct GUID { + pub Data1: DWORD, + pub Data2: WORD, + pub Data3: WORD, + pub Data4: [BYTE; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN { + pub ChainLen: c_int, + pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], + } + + pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; + + #[repr(C)] + #[derive(Copy)] pub struct WSAPROTOCOL_INFO { + pub dwServiceFlags1: DWORD, + pub dwServiceFlags2: DWORD, + pub dwServiceFlags3: DWORD, + pub dwServiceFlags4: DWORD, + pub dwProviderFlags: DWORD, + pub ProviderId: GUID, + pub dwCatalogEntryId: DWORD, + pub ProtocolChain: WSAPROTOCOLCHAIN, + pub iVersion: c_int, + pub iAddressFamily: c_int, + pub iMaxSockAddr: c_int, + pub iMinSockAddr: c_int, + pub iSocketType: c_int, + pub iProtocol: c_int, + pub iProtocolMaxOffset: c_int, + pub iNetworkByteOrder: c_int, + pub iSecurityScheme: c_int, + pub dwMessageSize: DWORD, + pub dwProviderReserved: DWORD, + pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], + } + impl ::core::clone::Clone for WSAPROTOCOL_INFO { + fn clone(&self) -> WSAPROTOCOL_INFO { *self } + } + + pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; + + pub type GROUP = c_uint; + + #[repr(C)] + #[derive(Copy)] pub struct WIN32_FIND_DATAW { + pub dwFileAttributes: DWORD, + pub ftCreationTime: FILETIME, + pub ftLastAccessTime: FILETIME, + pub ftLastWriteTime: FILETIME, + pub nFileSizeHigh: DWORD, + pub nFileSizeLow: DWORD, + pub dwReserved0: DWORD, + pub dwReserved1: DWORD, + pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 + pub cAlternateFileName: [wchar_t; 14], + } + impl ::core::clone::Clone for WIN32_FIND_DATAW { + fn clone(&self) -> WIN32_FIND_DATAW { *self } + } + + pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; + } + } + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, size_t, time_t}; + use types::os::arch::c95::{suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = u64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub __unused1: c_int, + pub gl_offs: size_t, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + } + } + + #[cfg(any(target_arch = "arm", target_arch = "x86"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = c_ulong; + pub type time_t = c_long; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::c_long; + + pub type off_t = i64; + pub type dev_t = i32; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c99::{int32_t, int64_t, uint32_t}; + use types::os::arch::c95::{c_char, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t, + mode_t, off_t, uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: uint32_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare: [int64_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy)] pub struct pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 36] + } + impl ::core::clone::Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + #[repr(C)] + #[derive(Copy, Clone)] pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub type mach_timebase_info_data_t = mach_timebase_info; + } + } + + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = c_ulong; + pub type time_t = c_long; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::c_long; + + pub type off_t = i64; + pub type dev_t = i32; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c99::{int32_t, int64_t}; + use types::common::c99::{uint32_t}; + use types::os::arch::c95::{c_char, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t, uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: uint32_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare: [int64_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy)] pub struct pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 56] + } + impl ::core::clone::Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + #[repr(C)] + #[derive(Copy, Clone)] pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub type mach_timebase_info_data_t = mach_timebase_info; + } + } + } +} + +pub mod consts { + // Consts tend to vary per OS so we pull their definitions out + // into this module. + + #[cfg(target_os = "windows")] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 32767; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 4; + pub const _IOLBF : c_int = 64; + pub const BUFSIZ : c_uint = 512; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 260; + pub const L_tmpnam : c_uint = 16; + pub const TMP_MAX : c_uint = 32767; + + pub const WSAEINTR: c_int = 10004; + pub const WSAEBADF: c_int = 10009; + pub const WSAEACCES: c_int = 10013; + pub const WSAEFAULT: c_int = 10014; + pub const WSAEINVAL: c_int = 10022; + pub const WSAEMFILE: c_int = 10024; + pub const WSAEWOULDBLOCK: c_int = 10035; + pub const WSAEINPROGRESS: c_int = 10036; + pub const WSAEALREADY: c_int = 10037; + pub const WSAENOTSOCK: c_int = 10038; + pub const WSAEDESTADDRREQ: c_int = 10039; + pub const WSAEMSGSIZE: c_int = 10040; + pub const WSAEPROTOTYPE: c_int = 10041; + pub const WSAENOPROTOOPT: c_int = 10042; + pub const WSAEPROTONOSUPPORT: c_int = 10043; + pub const WSAESOCKTNOSUPPORT: c_int = 10044; + pub const WSAEOPNOTSUPP: c_int = 10045; + pub const WSAEPFNOSUPPORT: c_int = 10046; + pub const WSAEAFNOSUPPORT: c_int = 10047; + pub const WSAEADDRINUSE: c_int = 10048; + pub const WSAEADDRNOTAVAIL: c_int = 10049; + pub const WSAENETDOWN: c_int = 10050; + pub const WSAENETUNREACH: c_int = 10051; + pub const WSAENETRESET: c_int = 10052; + pub const WSAECONNABORTED: c_int = 10053; + pub const WSAECONNRESET: c_int = 10054; + pub const WSAENOBUFS: c_int = 10055; + pub const WSAEISCONN: c_int = 10056; + pub const WSAENOTCONN: c_int = 10057; + pub const WSAESHUTDOWN: c_int = 10058; + pub const WSAETOOMANYREFS: c_int = 10059; + pub const WSAETIMEDOUT: c_int = 10060; + pub const WSAECONNREFUSED: c_int = 10061; + pub const WSAELOOP: c_int = 10062; + pub const WSAENAMETOOLONG: c_int = 10063; + pub const WSAEHOSTDOWN: c_int = 10064; + pub const WSAEHOSTUNREACH: c_int = 10065; + pub const WSAENOTEMPTY: c_int = 10066; + pub const WSAEPROCLIM: c_int = 10067; + pub const WSAEUSERS: c_int = 10068; + pub const WSAEDQUOT: c_int = 10069; + pub const WSAESTALE: c_int = 10070; + pub const WSAEREMOTE: c_int = 10071; + pub const WSASYSNOTREADY: c_int = 10091; + pub const WSAVERNOTSUPPORTED: c_int = 10092; + pub const WSANOTINITIALISED: c_int = 10093; + pub const WSAEDISCON: c_int = 10101; + pub const WSAENOMORE: c_int = 10102; + pub const WSAECANCELLED: c_int = 10103; + pub const WSAEINVALIDPROCTABLE: c_int = 10104; + pub const WSAEINVALIDPROVIDER: c_int = 10105; + pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; + } + pub mod c99 { + } + pub mod posix88 { + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 256; + pub const O_EXCL : c_int = 1024; + pub const O_TRUNC : c_int = 512; + pub const S_IFIFO : c_int = 4096; + pub const S_IFCHR : c_int = 8192; + pub const S_IFBLK : c_int = 12288; + pub const S_IFDIR : c_int = 16384; + pub const S_IFREG : c_int = 32768; + pub const S_IFLNK : c_int = 40960; + pub const S_IFMT : c_int = 61440; + pub const S_IEXEC : c_int = 64; + pub const S_IWRITE : c_int = 128; + pub const S_IREAD : c_int = 256; + pub const S_IRWXU : c_int = 448; + pub const S_IXUSR : c_int = 64; + pub const S_IWUSR : c_int = 128; + pub const S_IRUSR : c_int = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + } + pub mod posix01 { + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 23; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 5; + pub const IPV6_DROP_MEMBERSHIP: c_int = 6; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + + pub const TCP_NODELAY: c_int = 0x0001; + pub const SOL_SOCKET: c_int = 0xffff; + + pub const SO_DEBUG: c_int = 0x0001; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 4; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + pub mod extra { + use types::os::common::bsd44::SOCKET; + use types::os::arch::c95::{c_int, c_long}; + use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE}; + + pub const TRUE : BOOL = 1; + pub const FALSE : BOOL = 0; + + pub const O_TEXT : c_int = 16384; + pub const O_BINARY : c_int = 32768; + pub const O_NOINHERIT: c_int = 128; + + pub const ERROR_SUCCESS : c_int = 0; + pub const ERROR_INVALID_FUNCTION: c_int = 1; + pub const ERROR_FILE_NOT_FOUND: c_int = 2; + pub const ERROR_ACCESS_DENIED: c_int = 5; + pub const ERROR_INVALID_HANDLE : c_int = 6; + pub const ERROR_BROKEN_PIPE: c_int = 109; + pub const ERROR_DISK_FULL : c_int = 112; + pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120; + pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122; + pub const ERROR_INVALID_NAME : c_int = 123; + pub const ERROR_ALREADY_EXISTS : c_int = 183; + pub const ERROR_PIPE_BUSY: c_int = 231; + pub const ERROR_NO_DATA: c_int = 232; + pub const ERROR_INVALID_ADDRESS : c_int = 487; + pub const ERROR_PIPE_CONNECTED: c_int = 535; + pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; + pub const ERROR_OPERATION_ABORTED: c_int = 995; + pub const ERROR_IO_PENDING: c_int = 997; + pub const ERROR_FILE_INVALID : c_int = 1006; + pub const ERROR_NOT_FOUND: c_int = 1168; + pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; + + pub const DELETE : DWORD = 0x00010000; + pub const READ_CONTROL : DWORD = 0x00020000; + pub const SYNCHRONIZE : DWORD = 0x00100000; + pub const WRITE_DAC : DWORD = 0x00040000; + pub const WRITE_OWNER : DWORD = 0x00080000; + + pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080; + pub const PROCESS_CREATE_THREAD : DWORD = 0x0002; + pub const PROCESS_DUP_HANDLE : DWORD = 0x0040; + pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400; + pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000; + pub const PROCESS_SET_INFORMATION : DWORD = 0x0200; + pub const PROCESS_SET_QUOTA : DWORD = 0x0100; + pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800; + pub const PROCESS_TERMINATE : DWORD = 0x0001; + pub const PROCESS_VM_OPERATION : DWORD = 0x0008; + pub const PROCESS_VM_READ : DWORD = 0x0010; + pub const PROCESS_VM_WRITE : DWORD = 0x0020; + + pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040; + pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080; + pub const STARTF_PREVENTPINNING : DWORD = 0x00002000; + pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020; + pub const STARTF_TITLEISAPPID : DWORD = 0x00001000; + pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800; + pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008; + pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010; + pub const STARTF_USEHOTKEY : DWORD = 0x00000200; + pub const STARTF_USEPOSITION : DWORD = 0x00000004; + pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001; + pub const STARTF_USESIZE : DWORD = 0x00000002; + pub const STARTF_USESTDHANDLES : DWORD = 0x00000100; + + pub const WAIT_ABANDONED : DWORD = 0x00000080; + pub const WAIT_OBJECT_0 : DWORD = 0x00000000; + pub const WAIT_TIMEOUT : DWORD = 0x00000102; + pub const WAIT_FAILED : DWORD = !0; + + pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001; + pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002; + + pub const INFINITE : DWORD = !0; + pub const STILL_ACTIVE : DWORD = 259; + + pub const MEM_COMMIT : DWORD = 0x00001000; + pub const MEM_RESERVE : DWORD = 0x00002000; + pub const MEM_DECOMMIT : DWORD = 0x00004000; + pub const MEM_RELEASE : DWORD = 0x00008000; + pub const MEM_RESET : DWORD = 0x00080000; + pub const MEM_RESET_UNDO : DWORD = 0x1000000; + pub const MEM_LARGE_PAGES : DWORD = 0x20000000; + pub const MEM_PHYSICAL : DWORD = 0x00400000; + pub const MEM_TOP_DOWN : DWORD = 0x00100000; + pub const MEM_WRITE_WATCH : DWORD = 0x00200000; + + pub const PAGE_EXECUTE : DWORD = 0x10; + pub const PAGE_EXECUTE_READ : DWORD = 0x20; + pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40; + pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80; + pub const PAGE_NOACCESS : DWORD = 0x01; + pub const PAGE_READONLY : DWORD = 0x02; + pub const PAGE_READWRITE : DWORD = 0x04; + pub const PAGE_WRITECOPY : DWORD = 0x08; + pub const PAGE_GUARD : DWORD = 0x100; + pub const PAGE_NOCACHE : DWORD = 0x200; + pub const PAGE_WRITECOMBINE : DWORD = 0x400; + + pub const SEC_COMMIT : DWORD = 0x8000000; + pub const SEC_IMAGE : DWORD = 0x1000000; + pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000; + pub const SEC_LARGE_PAGES : DWORD = 0x80000000; + pub const SEC_NOCACHE : DWORD = 0x10000000; + pub const SEC_RESERVE : DWORD = 0x4000000; + pub const SEC_WRITECOMBINE : DWORD = 0x40000000; + + pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f; + pub const FILE_MAP_READ : DWORD = 0x4; + pub const FILE_MAP_WRITE : DWORD = 0x2; + pub const FILE_MAP_COPY : DWORD = 0x1; + pub const FILE_MAP_EXECUTE : DWORD = 0x20; + + pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0; + pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5; + pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6; + pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9; + pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff; + + pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; + pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; + pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; + pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; + pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; + pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; + + pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; + + pub const FILE_SHARE_DELETE: DWORD = 0x4; + pub const FILE_SHARE_READ: DWORD = 0x1; + pub const FILE_SHARE_WRITE: DWORD = 0x2; + + pub const CREATE_ALWAYS: DWORD = 2; + pub const CREATE_NEW: DWORD = 1; + pub const OPEN_ALWAYS: DWORD = 4; + pub const OPEN_EXISTING: DWORD = 3; + pub const TRUNCATE_EXISTING: DWORD = 5; + + pub const FILE_APPEND_DATA: DWORD = 0x00000004; + pub const FILE_READ_DATA: DWORD = 0x00000001; + pub const FILE_WRITE_DATA: DWORD = 0x00000002; + + pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; + pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; + pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; + pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; + pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; + pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; + pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; + pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; + pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; + pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; + pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; + pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; + pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; + pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; + pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; + pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; + pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; + + pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; + pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; + pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; + pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; + pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; + pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; + pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x0100000; + pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; + pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; + pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; + pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; + pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; + + pub const FILE_NAME_NORMALIZED: DWORD = 0x0; + pub const FILE_NAME_OPENED: DWORD = 0x8; + + pub const VOLUME_NAME_DOS: DWORD = 0x0; + pub const VOLUME_NAME_GUID: DWORD = 0x1; + pub const VOLUME_NAME_NONE: DWORD = 0x4; + pub const VOLUME_NAME_NT: DWORD = 0x2; + + pub const GENERIC_READ: DWORD = 0x80000000; + pub const GENERIC_WRITE: DWORD = 0x40000000; + pub const GENERIC_EXECUTE: DWORD = 0x20000000; + pub const GENERIC_ALL: DWORD = 0x10000000; + pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; + pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; + + pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; + pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; + pub const FILE_WRITE_EA: DWORD = 0x00000010; + pub const FILE_READ_EA: DWORD = 0x00000008; + pub const FILE_GENERIC_READ: DWORD = + STANDARD_RIGHTS_READ | FILE_READ_DATA | + FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; + pub const FILE_GENERIC_WRITE: DWORD = + STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | + FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | + SYNCHRONIZE; + + pub const FILE_BEGIN: DWORD = 0; + pub const FILE_CURRENT: DWORD = 1; + pub const FILE_END: DWORD = 2; + + pub const MAX_PROTOCOL_CHAIN: DWORD = 7; + pub const WSAPROTOCOL_LEN: DWORD = 255; + pub const INVALID_SOCKET: SOCKET = !0; + + pub const DETACHED_PROCESS: DWORD = 0x00000008; + pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; + pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; + + pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; + pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; + pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; + pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; + pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; + pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; + pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; + pub const PIPE_WAIT: DWORD = 0x00000000; + pub const PIPE_NOWAIT: DWORD = 0x00000001; + pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; + pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; + pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; + + pub const IPPROTO_RAW: c_int = 255; + + pub const FIONBIO: c_long = -0x7FFB9982; + } + pub mod sysconf { + } + } + + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 8192; + pub const FOPEN_MAX : c_uint = 16; + pub const FILENAME_MAX : c_uint = 4096; + pub const L_tmpnam : c_uint = 20; + pub const TMP_MAX : c_uint = 238328; + } + pub mod c99 { + } + #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "le32", + target_arch = "powerpc"))] + pub mod posix88 { + use types::os::arch::c95::c_int; + use types::common::c95::c_void; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 1024; + pub const O_CREAT : c_int = 64; + pub const O_EXCL : c_int = 128; + pub const O_NOCTTY : c_int = 256; + pub const O_TRUNC : c_int = 512; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x0020; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EAGAIN : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + + pub const EDEADLK: c_int = 35; + pub const ENAMETOOLONG: c_int = 36; + pub const ENOLCK: c_int = 37; + pub const ENOSYS: c_int = 38; + pub const ENOTEMPTY: c_int = 39; + pub const ELOOP: c_int = 40; + pub const EWOULDBLOCK: c_int = EAGAIN; + pub const ENOMSG: c_int = 42; + pub const EIDRM: c_int = 43; + pub const ECHRNG: c_int = 44; + pub const EL2NSYNC: c_int = 45; + pub const EL3HLT: c_int = 46; + pub const EL3RST: c_int = 47; + pub const ELNRNG: c_int = 48; + pub const EUNATCH: c_int = 49; + pub const ENOCSI: c_int = 50; + pub const EL2HLT: c_int = 51; + pub const EBADE: c_int = 52; + pub const EBADR: c_int = 53; + pub const EXFULL: c_int = 54; + pub const ENOANO: c_int = 55; + pub const EBADRQC: c_int = 56; + pub const EBADSLT: c_int = 57; + + pub const EDEADLOCK: c_int = EDEADLK; + + pub const EBFONT: c_int = 59; + pub const ENOSTR: c_int = 60; + pub const ENODATA: c_int = 61; + pub const ETIME: c_int = 62; + pub const ENOSR: c_int = 63; + pub const ENONET: c_int = 64; + pub const ENOPKG: c_int = 65; + pub const EREMOTE: c_int = 66; + pub const ENOLINK: c_int = 67; + pub const EADV: c_int = 68; + pub const ESRMNT: c_int = 69; + pub const ECOMM: c_int = 70; + pub const EPROTO: c_int = 71; + pub const EMULTIHOP: c_int = 72; + pub const EDOTDOT: c_int = 73; + pub const EBADMSG: c_int = 74; + pub const EOVERFLOW: c_int = 75; + pub const ENOTUNIQ: c_int = 76; + pub const EBADFD: c_int = 77; + pub const EREMCHG: c_int = 78; + pub const ELIBACC: c_int = 79; + pub const ELIBBAD: c_int = 80; + pub const ELIBSCN: c_int = 81; + pub const ELIBMAX: c_int = 82; + pub const ELIBEXEC: c_int = 83; + pub const EILSEQ: c_int = 84; + pub const ERESTART: c_int = 85; + pub const ESTRPIPE: c_int = 86; + pub const EUSERS: c_int = 87; + pub const ENOTSOCK: c_int = 88; + pub const EDESTADDRREQ: c_int = 89; + pub const EMSGSIZE: c_int = 90; + pub const EPROTOTYPE: c_int = 91; + pub const ENOPROTOOPT: c_int = 92; + pub const EPROTONOSUPPORT: c_int = 93; + pub const ESOCKTNOSUPPORT: c_int = 94; + pub const EOPNOTSUPP: c_int = 95; + pub const EPFNOSUPPORT: c_int = 96; + pub const EAFNOSUPPORT: c_int = 97; + pub const EADDRINUSE: c_int = 98; + pub const EADDRNOTAVAIL: c_int = 99; + pub const ENETDOWN: c_int = 100; + pub const ENETUNREACH: c_int = 101; + pub const ENETRESET: c_int = 102; + pub const ECONNABORTED: c_int = 103; + pub const ECONNRESET: c_int = 104; + pub const ENOBUFS: c_int = 105; + pub const EISCONN: c_int = 106; + pub const ENOTCONN: c_int = 107; + pub const ESHUTDOWN: c_int = 108; + pub const ETOOMANYREFS: c_int = 109; + pub const ETIMEDOUT: c_int = 110; + pub const ECONNREFUSED: c_int = 111; + pub const EHOSTDOWN: c_int = 112; + pub const EHOSTUNREACH: c_int = 113; + pub const EALREADY: c_int = 114; + pub const EINPROGRESS: c_int = 115; + pub const ESTALE: c_int = 116; + pub const EUCLEAN: c_int = 117; + pub const ENOTNAM: c_int = 118; + pub const ENAVAIL: c_int = 119; + pub const EISNAM: c_int = 120; + pub const EREMOTEIO: c_int = 121; + pub const EDQUOT: c_int = 122; + + pub const ENOMEDIUM: c_int = 123; + pub const EMEDIUMTYPE: c_int = 124; + pub const ECANCELED: c_int = 125; + pub const ENOKEY: c_int = 126; + pub const EKEYEXPIRED: c_int = 127; + pub const EKEYREVOKED: c_int = 128; + pub const EKEYREJECTED: c_int = 129; + + pub const EOWNERDEAD: c_int = 130; + pub const ENOTRECOVERABLE: c_int = 131; + + pub const ERFKILL: c_int = 132; + + pub const EHWPOISON: c_int = 133; + } + + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod posix88 { + use types::os::arch::c95::c_int; + use types::common::c95::c_void; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 256; + pub const O_EXCL : c_int = 1024; + pub const O_NOCTTY : c_int = 2048; + pub const O_TRUNC : c_int = 512; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x0800; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EAGAIN : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + + pub const ENOMSG: c_int = 35; + pub const EIDRM: c_int = 36; + pub const ECHRNG: c_int = 37; + pub const EL2NSYNC: c_int = 38; + pub const EL3HLT: c_int = 39; + pub const EL3RST: c_int = 40; + pub const ELNRNG: c_int = 41; + pub const EUNATCH: c_int = 42; + pub const ENOCSI: c_int = 43; + pub const EL2HLT: c_int = 44; + pub const EDEADLK: c_int = 45; + pub const ENOLCK: c_int = 46; + pub const EBADE: c_int = 50; + pub const EBADR: c_int = 51; + pub const EXFULL: c_int = 52; + pub const ENOANO: c_int = 53; + pub const EBADRQC: c_int = 54; + pub const EBADSLT: c_int = 55; + pub const EDEADLOCK: c_int = 56; + pub const EBFONT: c_int = 59; + pub const ENOSTR: c_int = 60; + pub const ENODATA: c_int = 61; + pub const ETIME: c_int = 62; + pub const ENOSR: c_int = 63; + pub const ENONET: c_int = 64; + pub const ENOPKG: c_int = 65; + pub const EREMOTE: c_int = 66; + pub const ENOLINK: c_int = 67; + pub const EADV: c_int = 68; + pub const ESRMNT: c_int = 69; + pub const ECOMM: c_int = 70; + pub const EPROTO: c_int = 71; + pub const EDOTDOT: c_int = 73; + pub const EMULTIHOP: c_int = 74; + pub const EBADMSG: c_int = 77; + pub const ENAMETOOLONG: c_int = 78; + pub const EOVERFLOW: c_int = 79; + pub const ENOTUNIQ: c_int = 80; + pub const EBADFD: c_int = 81; + pub const EREMCHG: c_int = 82; + pub const ELIBACC: c_int = 83; + pub const ELIBBAD: c_int = 84; + pub const ELIBSCN: c_int = 95; + pub const ELIBMAX: c_int = 86; + pub const ELIBEXEC: c_int = 87; + pub const EILSEQ: c_int = 88; + pub const ENOSYS: c_int = 89; + pub const ELOOP: c_int = 90; + pub const ERESTART: c_int = 91; + pub const ESTRPIPE: c_int = 92; + pub const ENOTEMPTY: c_int = 93; + pub const EUSERS: c_int = 94; + pub const ENOTSOCK: c_int = 95; + pub const EDESTADDRREQ: c_int = 96; + pub const EMSGSIZE: c_int = 97; + pub const EPROTOTYPE: c_int = 98; + pub const ENOPROTOOPT: c_int = 99; + pub const EPROTONOSUPPORT: c_int = 120; + pub const ESOCKTNOSUPPORT: c_int = 121; + pub const EOPNOTSUPP: c_int = 122; + pub const EPFNOSUPPORT: c_int = 123; + pub const EAFNOSUPPORT: c_int = 124; + pub const EADDRINUSE: c_int = 125; + pub const EADDRNOTAVAIL: c_int = 126; + pub const ENETDOWN: c_int = 127; + pub const ENETUNREACH: c_int = 128; + pub const ENETRESET: c_int = 129; + pub const ECONNABORTED: c_int = 130; + pub const ECONNRESET: c_int = 131; + pub const ENOBUFS: c_int = 132; + pub const EISCONN: c_int = 133; + pub const ENOTCONN: c_int = 134; + pub const EUCLEAN: c_int = 135; + pub const ENOTNAM: c_int = 137; + pub const ENAVAIL: c_int = 138; + pub const EISNAM: c_int = 139; + pub const EREMOTEIO: c_int = 140; + pub const ESHUTDOWN: c_int = 143; + pub const ETOOMANYREFS: c_int = 144; + pub const ETIMEDOUT: c_int = 145; + pub const ECONNREFUSED: c_int = 146; + pub const EHOSTDOWN: c_int = 147; + pub const EHOSTUNREACH: c_int = 148; + pub const EWOULDBLOCK: c_int = EAGAIN; + pub const EALREADY: c_int = 149; + pub const EINPROGRESS: c_int = 150; + pub const ESTALE: c_int = 151; + pub const ECANCELED: c_int = 158; + + pub const ENOMEDIUM: c_int = 159; + pub const EMEDIUMTYPE: c_int = 160; + pub const ENOKEY: c_int = 161; + pub const EKEYEXPIRED: c_int = 162; + pub const EKEYREVOKED: c_int = 163; + pub const EKEYREJECTED: c_int = 164; + + pub const EOWNERDEAD: c_int = 165; + pub const ENOTRECOVERABLE: c_int = 166; + + pub const ERFKILL: c_int = 167; + + pub const EHWPOISON: c_int = 168; + + pub const EDQUOT: c_int = 1133; + } + #[cfg(not(target_os = "nacl"))] + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const O_ACCMODE : c_int = 3; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_ERR : c_int = 1 << 0; + pub const GLOB_MARK : c_int = 1 << 1; + pub const GLOB_NOSORT : c_int = 1 << 2; + pub const GLOB_DOOFFS : c_int = 1 << 3; + pub const GLOB_NOCHECK : c_int = 1 << 4; + pub const GLOB_APPEND : c_int = 1 << 5; + pub const GLOB_NOESCAPE : c_int = 1 << 6; + + pub const GLOB_NOSPACE : c_int = 1; + pub const GLOB_ABORTED : c_int = 2; + pub const GLOB_NOMATCH : c_int = 3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_MQ_PRIO_MAX : c_int = 28; + pub const _SC_IOV_MAX : c_int = 60; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 69; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 70; + pub const _SC_LOGIN_NAME_MAX : c_int = 71; + pub const _SC_TTY_NAME_MAX : c_int = 72; + pub const _SC_THREADS : c_int = 67; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73; + pub const _SC_THREAD_KEYS_MAX : c_int = 74; + pub const _SC_THREAD_STACK_MIN : c_int = 75; + pub const _SC_THREAD_THREADS_MAX : c_int = 76; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 80; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 81; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 82; + pub const _SC_ATEXIT_MAX : c_int = 87; + pub const _SC_XOPEN_VERSION : c_int = 89; + pub const _SC_XOPEN_XCU_VERSION : c_int = 90; + pub const _SC_XOPEN_UNIX : c_int = 91; + pub const _SC_XOPEN_CRYPT : c_int = 92; + pub const _SC_XOPEN_ENH_I18N : c_int = 93; + pub const _SC_XOPEN_SHM : c_int = 94; + pub const _SC_XOPEN_LEGACY : c_int = 129; + pub const _SC_XOPEN_REALTIME : c_int = 130; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131; + + + + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; + pub const PTHREAD_CREATE_DETACHED: c_int = 1; + + #[cfg(target_os = "android")] + pub const PTHREAD_STACK_MIN: size_t = 8192; + + #[cfg(all(target_os = "linux", + any(target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64")))] + pub const PTHREAD_STACK_MIN: size_t = 16384; + + #[cfg(all(target_os = "linux", + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "aarch64", + target_arch = "powerpc")))] + pub const PTHREAD_STACK_MIN: size_t = 131072; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 1; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_NOFILE: c_int = 7; + pub const RLIMIT_AS: c_int = 9; + pub const RLIMIT_NPROC: c_int = 6; + pub const RLIMIT_MEMLOCK: c_int = 8; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + pub const RLIMIT_NLIMITS: c_int = 16; + pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + #[cfg(target_os = "nacl")] + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_ERR : c_int = 1 << 0; + pub const GLOB_MARK : c_int = 1 << 1; + pub const GLOB_NOSORT : c_int = 1 << 2; + pub const GLOB_DOOFFS : c_int = 1 << 3; + pub const GLOB_NOCHECK : c_int = 1 << 4; + pub const GLOB_APPEND : c_int = 1 << 5; + pub const GLOB_NOESCAPE : c_int = 1 << 6; + + pub const GLOB_NOSPACE : c_int = 1; + pub const GLOB_ABORTED : c_int = 2; + pub const GLOB_NOMATCH : c_int = 3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_MQ_PRIO_MAX : c_int = 28; + pub const _SC_IOV_MAX : c_int = 60; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 69; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 70; + pub const _SC_LOGIN_NAME_MAX : c_int = 71; + pub const _SC_TTY_NAME_MAX : c_int = 72; + pub const _SC_THREADS : c_int = 67; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73; + pub const _SC_THREAD_KEYS_MAX : c_int = 74; + pub const _SC_THREAD_STACK_MIN : c_int = 75; + pub const _SC_THREAD_THREADS_MAX : c_int = 76; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 80; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 81; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 82; + pub const _SC_ATEXIT_MAX : c_int = 87; + pub const _SC_XOPEN_VERSION : c_int = 89; + pub const _SC_XOPEN_XCU_VERSION : c_int = 90; + pub const _SC_XOPEN_UNIX : c_int = 91; + pub const _SC_XOPEN_CRYPT : c_int = 92; + pub const _SC_XOPEN_ENH_I18N : c_int = 93; + pub const _SC_XOPEN_SHM : c_int = 94; + pub const _SC_XOPEN_LEGACY : c_int = 129; + pub const _SC_XOPEN_REALTIME : c_int = 130; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 1; + pub const PTHREAD_CREATE_DETACHED: c_int = 0; + + pub const PTHREAD_STACK_MIN: size_t = 1024; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 1; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_NOFILE: c_int = 7; + pub const RLIMIT_AS: c_int = 9; + pub const RLIMIT_NPROC: c_int = 6; + pub const RLIMIT_MEMLOCK: c_int = 8; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + pub const RLIMIT_NLIMITS: c_int = 16; + + pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + #[cfg(any(target_arch = "arm", + target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "le32", + target_arch = "powerpc"))] + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_REMOVE : c_int = 9; + pub const MADV_DONTFORK : c_int = 10; + pub const MADV_DOFORK : c_int = 11; + pub const MADV_MERGEABLE : c_int = 12; + pub const MADV_UNMERGEABLE : c_int = 13; + pub const MADV_HWPOISON : c_int = 100; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 10; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 33; + pub const IP_MULTICAST_LOOP: c_int = 34; + pub const IP_TTL: c_int = 2; + pub const IP_HDRINCL: c_int = 3; + pub const IP_ADD_MEMBERSHIP: c_int = 35; + pub const IP_DROP_MEMBERSHIP: c_int = 36; + pub const IPV6_ADD_MEMBERSHIP: c_int = 20; + pub const IPV6_DROP_MEMBERSHIP: c_int = 21; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_MAXSEG: c_int = 2; + pub const TCP_CORK: c_int = 3; + pub const TCP_KEEPIDLE: c_int = 4; + pub const TCP_KEEPINTVL: c_int = 5; + pub const TCP_KEEPCNT: c_int = 6; + pub const TCP_SYNCNT: c_int = 7; + pub const TCP_LINGER2: c_int = 8; + pub const TCP_DEFER_ACCEPT: c_int = 9; + pub const TCP_WINDOW_CLAMP: c_int = 10; + pub const TCP_INFO: c_int = 11; + pub const TCP_QUICKACK: c_int = 12; + pub const TCP_CONGESTION: c_int = 13; + pub const TCP_MD5SIG: c_int = 14; + pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; + pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; + pub const TCP_THIN_DUPACK: c_int = 17; + pub const TCP_USER_TIMEOUT: c_int = 18; + pub const TCP_REPAIR: c_int = 19; + pub const TCP_REPAIR_QUEUE: c_int = 20; + pub const TCP_QUEUE_SEQ: c_int = 21; + pub const TCP_REPAIR_OPTIONS: c_int = 22; + pub const TCP_FASTOPEN: c_int = 23; + pub const TCP_TIMESTAMP: c_int = 24; + + pub const SOL_SOCKET: c_int = 1; + + pub const SO_DEBUG: c_int = 1; + pub const SO_REUSEADDR: c_int = 2; + pub const SO_TYPE: c_int = 3; + pub const SO_ERROR: c_int = 4; + pub const SO_DONTROUTE: c_int = 5; + pub const SO_BROADCAST: c_int = 6; + pub const SO_SNDBUF: c_int = 7; + pub const SO_RCVBUF: c_int = 8; + pub const SO_KEEPALIVE: c_int = 9; + pub const SO_OOBINLINE: c_int = 10; + pub const SO_LINGER: c_int = 13; + pub const SO_REUSEPORT: c_int = 15; + pub const SO_RCVLOWAT: c_int = 18; + pub const SO_SNDLOWAT: c_int = 19; + pub const SO_RCVTIMEO: c_int = 20; + pub const SO_SNDTIMEO: c_int = 21; + pub const SO_ACCEPTCONN: c_int = 30; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_REMOVE : c_int = 9; + pub const MADV_DONTFORK : c_int = 10; + pub const MADV_DOFORK : c_int = 11; + pub const MADV_MERGEABLE : c_int = 12; + pub const MADV_UNMERGEABLE : c_int = 13; + pub const MADV_HWPOISON : c_int = 100; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 10; + pub const SOCK_STREAM: c_int = 2; + pub const SOCK_DGRAM: c_int = 1; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 33; + pub const IP_MULTICAST_LOOP: c_int = 34; + pub const IP_TTL: c_int = 2; + pub const IP_HDRINCL: c_int = 3; + pub const IP_ADD_MEMBERSHIP: c_int = 35; + pub const IP_DROP_MEMBERSHIP: c_int = 36; + pub const IPV6_ADD_MEMBERSHIP: c_int = 20; + pub const IPV6_DROP_MEMBERSHIP: c_int = 21; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_MAXSEG: c_int = 2; + pub const TCP_CORK: c_int = 3; + pub const TCP_KEEPIDLE: c_int = 4; + pub const TCP_KEEPINTVL: c_int = 5; + pub const TCP_KEEPCNT: c_int = 6; + pub const TCP_SYNCNT: c_int = 7; + pub const TCP_LINGER2: c_int = 8; + pub const TCP_DEFER_ACCEPT: c_int = 9; + pub const TCP_WINDOW_CLAMP: c_int = 10; + pub const TCP_INFO: c_int = 11; + pub const TCP_QUICKACK: c_int = 12; + pub const TCP_CONGESTION: c_int = 13; + pub const TCP_MD5SIG: c_int = 14; + pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; + pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; + pub const TCP_THIN_DUPACK: c_int = 17; + pub const TCP_USER_TIMEOUT: c_int = 18; + pub const TCP_REPAIR: c_int = 19; + pub const TCP_REPAIR_QUEUE: c_int = 20; + pub const TCP_QUEUE_SEQ: c_int = 21; + pub const TCP_REPAIR_OPTIONS: c_int = 22; + pub const TCP_FASTOPEN: c_int = 23; + pub const TCP_TIMESTAMP: c_int = 24; + + pub const SOL_SOCKET: c_int = 65535; + + pub const SO_DEBUG: c_int = 0x0001; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + pub const SO_ACCEPTCONN: c_int = 0x1009; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "le32", + target_arch = "powerpc"))] + pub mod extra { + use types::os::arch::c95::c_int; + + pub const AF_PACKET : c_int = 17; + pub const IPPROTO_RAW : c_int = 255; + + pub const O_RSYNC : c_int = 1052672; + pub const O_DSYNC : c_int = 4096; + pub const O_NONBLOCK : c_int = 2048; + pub const O_SYNC : c_int = 1052672; + + pub const PROT_GROWSDOWN : c_int = 0x010000000; + pub const PROT_GROWSUP : c_int = 0x020000000; + + pub const MAP_TYPE : c_int = 0x000f; + pub const MAP_ANONYMOUS : c_int = 0x0020; + pub const MAP_32BIT : c_int = 0x0040; + pub const MAP_GROWSDOWN : c_int = 0x0100; + pub const MAP_DENYWRITE : c_int = 0x0800; + pub const MAP_EXECUTABLE : c_int = 0x01000; + pub const MAP_LOCKED : c_int = 0x02000; + pub const MAP_NORESERVE : c_int = 0x04000; + pub const MAP_POPULATE : c_int = 0x08000; + pub const MAP_NONBLOCK : c_int = 0x010000; + pub const MAP_STACK : c_int = 0x020000; + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod extra { + use types::os::arch::c95::c_int; + + pub const AF_PACKET : c_int = 17; + pub const IPPROTO_RAW : c_int = 255; + + pub const O_RSYNC : c_int = 16400; + pub const O_DSYNC : c_int = 16; + pub const O_NONBLOCK : c_int = 128; + pub const O_SYNC : c_int = 16400; + + pub const PROT_GROWSDOWN : c_int = 0x01000000; + pub const PROT_GROWSUP : c_int = 0x02000000; + + pub const MAP_TYPE : c_int = 0x000f; + pub const MAP_ANONYMOUS : c_int = 0x0800; + pub const MAP_GROWSDOWN : c_int = 0x01000; + pub const MAP_DENYWRITE : c_int = 0x02000; + pub const MAP_EXECUTABLE : c_int = 0x04000; + pub const MAP_LOCKED : c_int = 0x08000; + pub const MAP_NORESERVE : c_int = 0x0400; + pub const MAP_POPULATE : c_int = 0x010000; + pub const MAP_NONBLOCK : c_int = 0x020000; + pub const MAP_STACK : c_int = 0x040000; + } + #[cfg(target_os = "linux")] + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 0; + pub const _SC_CHILD_MAX : c_int = 1; + pub const _SC_CLK_TCK : c_int = 2; + pub const _SC_NGROUPS_MAX : c_int = 3; + pub const _SC_OPEN_MAX : c_int = 4; + pub const _SC_STREAM_MAX : c_int = 5; + pub const _SC_TZNAME_MAX : c_int = 6; + pub const _SC_JOB_CONTROL : c_int = 7; + pub const _SC_SAVED_IDS : c_int = 8; + pub const _SC_REALTIME_SIGNALS : c_int = 9; + pub const _SC_PRIORITY_SCHEDULING : c_int = 10; + pub const _SC_TIMERS : c_int = 11; + pub const _SC_ASYNCHRONOUS_IO : c_int = 12; + pub const _SC_PRIORITIZED_IO : c_int = 13; + pub const _SC_SYNCHRONIZED_IO : c_int = 14; + pub const _SC_FSYNC : c_int = 15; + pub const _SC_MAPPED_FILES : c_int = 16; + pub const _SC_MEMLOCK : c_int = 17; + pub const _SC_MEMLOCK_RANGE : c_int = 18; + pub const _SC_MEMORY_PROTECTION : c_int = 19; + pub const _SC_MESSAGE_PASSING : c_int = 20; + pub const _SC_SEMAPHORES : c_int = 21; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 22; + pub const _SC_AIO_LISTIO_MAX : c_int = 23; + pub const _SC_AIO_MAX : c_int = 24; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 25; + pub const _SC_DELAYTIMER_MAX : c_int = 26; + pub const _SC_MQ_OPEN_MAX : c_int = 27; + pub const _SC_VERSION : c_int = 29; + pub const _SC_PAGESIZE : c_int = 30; + pub const _SC_RTSIG_MAX : c_int = 31; + pub const _SC_SEM_NSEMS_MAX : c_int = 32; + pub const _SC_SEM_VALUE_MAX : c_int = 33; + pub const _SC_SIGQUEUE_MAX : c_int = 34; + pub const _SC_TIMER_MAX : c_int = 35; + pub const _SC_BC_BASE_MAX : c_int = 36; + pub const _SC_BC_DIM_MAX : c_int = 37; + pub const _SC_BC_SCALE_MAX : c_int = 38; + pub const _SC_BC_STRING_MAX : c_int = 39; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 40; + pub const _SC_EXPR_NEST_MAX : c_int = 42; + pub const _SC_LINE_MAX : c_int = 43; + pub const _SC_RE_DUP_MAX : c_int = 44; + pub const _SC_2_VERSION : c_int = 46; + pub const _SC_2_C_BIND : c_int = 47; + pub const _SC_2_C_DEV : c_int = 48; + pub const _SC_2_FORT_DEV : c_int = 49; + pub const _SC_2_FORT_RUN : c_int = 50; + pub const _SC_2_SW_DEV : c_int = 51; + pub const _SC_2_LOCALEDEF : c_int = 52; + pub const _SC_NPROCESSORS_ONLN : c_int = 84; + pub const _SC_2_CHAR_TERM : c_int = 95; + pub const _SC_2_C_VERSION : c_int = 96; + pub const _SC_2_UPE : c_int = 97; + pub const _SC_XBS5_ILP32_OFF32 : c_int = 125; + pub const _SC_XBS5_ILP32_OFFBIG : c_int = 126; + pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 128; + + } + #[cfg(target_os = "nacl")] + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub static _SC_SENDMSG_MAX_SIZE : c_int = 0; + pub static _SC_NPROCESSORS_ONLN : c_int = 1; + pub static _SC_PAGESIZE : c_int = 2; + } + + #[cfg(target_os = "android")] + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 0; + pub const _SC_BC_BASE_MAX : c_int = 1; + pub const _SC_BC_DIM_MAX : c_int = 2; + pub const _SC_BC_SCALE_MAX : c_int = 3; + pub const _SC_BC_STRING_MAX : c_int = 4; + pub const _SC_CHILD_MAX : c_int = 5; + pub const _SC_CLK_TCK : c_int = 6; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 7; + pub const _SC_EXPR_NEST_MAX : c_int = 8; + pub const _SC_LINE_MAX : c_int = 9; + pub const _SC_NGROUPS_MAX : c_int = 10; + pub const _SC_OPEN_MAX : c_int = 11; + pub const _SC_2_C_BIND : c_int = 13; + pub const _SC_2_C_DEV : c_int = 14; + pub const _SC_2_C_VERSION : c_int = 15; + pub const _SC_2_CHAR_TERM : c_int = 16; + pub const _SC_2_FORT_DEV : c_int = 17; + pub const _SC_2_FORT_RUN : c_int = 18; + pub const _SC_2_LOCALEDEF : c_int = 19; + pub const _SC_2_SW_DEV : c_int = 20; + pub const _SC_2_UPE : c_int = 21; + pub const _SC_2_VERSION : c_int = 22; + pub const _SC_JOB_CONTROL : c_int = 23; + pub const _SC_SAVED_IDS : c_int = 24; + pub const _SC_VERSION : c_int = 25; + pub const _SC_RE_DUP_MAX : c_int = 26; + pub const _SC_STREAM_MAX : c_int = 27; + pub const _SC_TZNAME_MAX : c_int = 28; + pub const _SC_PAGESIZE : c_int = 39; + } + } + + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 32768; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_SYNC : c_int = 0x0000; + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = 35; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const EOPNOTSUPP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EIDRM : c_int = 82; + pub const ENOMSG : c_int = 83; + pub const EOVERFLOW : c_int = 84; + pub const ECANCELED : c_int = 85; + pub const EILSEQ : c_int = 86; + pub const ENOATTR : c_int = 87; + pub const EDOOFUS : c_int = 88; + pub const EBADMSG : c_int = 89; + pub const EMULTIHOP : c_int = 90; + pub const ENOLINK : c_int = 91; + pub const EPROTO : c_int = 92; + pub const ENOMEDIUM : c_int = 93; + pub const EUNUSED94 : c_int = 94; + pub const EUNUSED95 : c_int = 95; + pub const EUNUSED96 : c_int = 96; + pub const EUNUSED97 : c_int = 97; + pub const EUNUSED98 : c_int = 98; + pub const EASYNC : c_int = 99; + pub const ELAST : c_int = 99; + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x2000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 56; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; + pub const _SC_LOGIN_NAME_MAX : c_int = 73; + pub const _SC_MQ_PRIO_MAX : c_int = 75; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; + pub const _SC_THREAD_KEYS_MAX : c_int = 86; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; + pub const _SC_THREAD_STACK_MIN : c_int = 93; + pub const _SC_THREAD_THREADS_MAX : c_int = 94; + pub const _SC_THREADS : c_int = 96; + pub const _SC_TTY_NAME_MAX : c_int = 101; + pub const _SC_ATEXIT_MAX : c_int = 107; + pub const _SC_XOPEN_CRYPT : c_int = 108; + pub const _SC_XOPEN_ENH_I18N : c_int = 109; + pub const _SC_XOPEN_LEGACY : c_int = 110; + pub const _SC_XOPEN_REALTIME : c_int = 111; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; + pub const _SC_XOPEN_SHM : c_int = 113; + pub const _SC_XOPEN_UNIX : c_int = 115; + pub const _SC_XOPEN_VERSION : c_int = 116; + pub const _SC_XOPEN_XCU_VERSION : c_int = 117; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; + pub const PTHREAD_CREATE_DETACHED: c_int = 1; + + #[cfg(target_arch = "arm")] + pub const PTHREAD_STACK_MIN: size_t = 4096; + + #[cfg(all(target_os = "freebsd", + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "x86", + target_arch = "x86_64")))] + pub const PTHREAD_STACK_MIN: size_t = 2048; + + #[cfg(target_os = "dragonfly")] + pub const PTHREAD_STACK_MIN: size_t = 1024; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 4; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIMIT_SBSIZE: c_int = 9; + pub const RLIMIT_VMEM: c_int = 10; + pub const RLIMIT_AS: c_int = RLIMIT_VMEM; + pub const RLIMIT_NPTS: c_int = 11; + pub const RLIMIT_SWAP: c_int = 12; + pub const RLIMIT_KQUEUES: c_int = 13; + + pub const RLIM_NLIMITS: rlim_t = 14; + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 5; + pub const MADV_NOSYNC : c_int = 6; + pub const MADV_AUTOSYNC : c_int = 7; + pub const MADV_NOCORE : c_int = 8; + pub const MADV_CORE : c_int = 9; + pub const MADV_PROTECT : c_int = 10; + + pub const MINCORE_INCORE : c_int = 0x1; + pub const MINCORE_REFERENCED : c_int = 0x2; + pub const MINCORE_MODIFIED : c_int = 0x4; + pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; + pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; + pub const MINCORE_SUPER : c_int = 0x20; + + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 28; + pub const AF_UNIX: c_int = 1; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_KEEPIDLE: c_int = 256; + pub const SOL_SOCKET: c_int = 0xffff; + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const CTL_KERN: c_int = 1; + pub const KERN_PROC: c_int = 14; + #[cfg(target_os = "freebsd")] + pub const KERN_PROC_PATHNAME: c_int = 12; + #[cfg(target_os = "dragonfly")] + pub const KERN_PROC_PATHNAME: c_int = 9; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0020; + pub const MAP_NORESERVE : c_int = 0x0040; + pub const MAP_HASSEMAPHORE : c_int = 0x0200; + pub const MAP_STACK : c_int = 0x0400; + pub const MAP_NOSYNC : c_int = 0x0800; + pub const MAP_NOCORE : c_int = 0x020000; + + pub const IPPROTO_RAW : c_int = 255; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_ASYNCHRONOUS_IO : c_int = 28; + pub const _SC_MAPPED_FILES : c_int = 29; + pub const _SC_MEMLOCK : c_int = 30; + pub const _SC_MEMLOCK_RANGE : c_int = 31; + pub const _SC_MEMORY_PROTECTION : c_int = 32; + pub const _SC_MESSAGE_PASSING : c_int = 33; + pub const _SC_PRIORITIZED_IO : c_int = 34; + pub const _SC_PRIORITY_SCHEDULING : c_int = 35; + pub const _SC_REALTIME_SIGNALS : c_int = 36; + pub const _SC_SEMAPHORES : c_int = 37; + pub const _SC_FSYNC : c_int = 38; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; + pub const _SC_SYNCHRONIZED_IO : c_int = 40; + pub const _SC_TIMERS : c_int = 41; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_DELAYTIMER_MAX : c_int = 45; + pub const _SC_MQ_OPEN_MAX : c_int = 46; + pub const _SC_PAGESIZE : c_int = 47; + pub const _SC_RTSIG_MAX : c_int = 48; + pub const _SC_SEM_NSEMS_MAX : c_int = 49; + pub const _SC_SEM_VALUE_MAX : c_int = 50; + pub const _SC_SIGQUEUE_MAX : c_int = 51; + pub const _SC_TIMER_MAX : c_int = 52; + } + } + + #[cfg(any(target_os = "bitrig", target_os = "openbsd"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 32768; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_SYNC : c_int = 0x0002; + pub const MS_INVALIDATE : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = 35; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const EOPNOTSUPP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EIPSEC : c_int = 82; + pub const ENOATTR : c_int = 83; + pub const EILSEQ : c_int = 84; + pub const ENOMEDIUM : c_int = 85; + pub const EMEDIUMTYPE : c_int = 86; + pub const EOVERFLOW : c_int = 87; + pub const ECANCELED : c_int = 88; + pub const EIDRM : c_int = 89; + pub const ENOMSG : c_int = 90; + pub const ENOTSUP : c_int = 91; + pub const ELAST : c_int = 91; // must be equal to largest errno + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + pub const F_GETOWN : c_int = 5; + pub const F_SETOWN : c_int = 6; + pub const F_GETLK : c_int = 7; + pub const F_SETLK : c_int = 8; + pub const F_SETLKW : c_int = 9; + pub const F_DUPFD_CLOEXEC : c_int = 10; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x1000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + pub const GLOB_NOSYS : c_int = -4; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 51; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 100; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 101; + pub const _SC_LOGIN_NAME_MAX : c_int = 102; + pub const _SC_MQ_PRIO_MAX : c_int = 59; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80; + pub const _SC_THREAD_KEYS_MAX : c_int = 81; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 82; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 83; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 85; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103; + pub const _SC_THREAD_STACK_MIN : c_int = 89; + pub const _SC_THREAD_THREADS_MAX : c_int = 90; + pub const _SC_THREADS : c_int = 91; + pub const _SC_TTY_NAME_MAX : c_int = 107; + pub const _SC_ATEXIT_MAX : c_int = 46; + pub const _SC_XOPEN_CRYPT : c_int = 117; + pub const _SC_XOPEN_ENH_I18N : c_int = 118; + pub const _SC_XOPEN_LEGACY : c_int = 119; + pub const _SC_XOPEN_REALTIME : c_int = 120; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121; + pub const _SC_XOPEN_SHM : c_int = 30; + pub const _SC_XOPEN_UNIX : c_int = 123; + pub const _SC_XOPEN_VERSION : c_int = 125; + + pub const PTHREAD_CREATE_JOINABLE : c_int = 0; + pub const PTHREAD_CREATE_DETACHED : c_int = 1; + pub const PTHREAD_STACK_MIN : size_t = 2048; + + pub const CLOCK_REALTIME : c_int = 0; + pub const CLOCK_MONOTONIC : c_int = 3; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIM_NLIMITS: c_int = 9; + + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 6; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 24; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist + + pub const TCP_NODELAY: c_int = 0x01; + pub const SOL_SOCKET: c_int = 0xffff; + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_DSYNC : c_int = 128; // same as SYNC + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const CTL_KERN : c_int = 1; + pub const KERN_PROC : c_int = 66; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0000; + pub const MAP_NORESERVE : c_int = 0x0000; + pub const MAP_NOEXTEND : c_int = 0x0000; + pub const MAP_HASSEMAPHORE : c_int = 0x0000; + + pub const IPPROTO_RAW : c_int = 255; + + pub const PATH_MAX: c_int = 1024; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_PAGESIZE : c_int = 28; + pub const _SC_FSYNC : c_int = 29; + pub const _SC_SEM_NSEMS_MAX : c_int = 31; + pub const _SC_SEM_VALUE_MAX : c_int = 32; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_ASYNCHRONOUS_IO : c_int = 45; + pub const _SC_DELAYTIMER_MAX : c_int = 50; + pub const _SC_MAPPED_FILES : c_int = 53; + pub const _SC_MEMLOCK : c_int = 54; + pub const _SC_MEMLOCK_RANGE : c_int = 55; + pub const _SC_MEMORY_PROTECTION : c_int = 56; + pub const _SC_MESSAGE_PASSING : c_int = 57; + pub const _SC_MQ_OPEN_MAX : c_int = 58; + pub const _SC_PRIORITIZED_IO : c_int = 60; + pub const _SC_PRIORITY_SCHEDULING : c_int = 61; + pub const _SC_REALTIME_SIGNALS : c_int = 64; + pub const _SC_RTSIG_MAX : c_int = 66; + pub const _SC_SEMAPHORES : c_int = 67; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68; + pub const _SC_SIGQUEUE_MAX : c_int = 70; + pub const _SC_SYNCHRONIZED_IO : c_int = 75; + pub const _SC_TIMER_MAX : c_int = 93; + pub const _SC_TIMERS : c_int = 94; + } + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 131072; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0010; + + pub const MS_KILLPAGES : c_int = 0x0004; + pub const MS_DEACTIVATE : c_int = 0x0008; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = EAGAIN; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const ENOTSUP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EPWROFF : c_int = 82; + pub const EDEVERR : c_int = 83; + pub const EOVERFLOW : c_int = 84; + pub const EBADEXEC : c_int = 85; + pub const EBADARCH : c_int = 86; + pub const ESHLIBVERS : c_int = 87; + pub const EBADMACHO : c_int = 88; + pub const ECANCELED : c_int = 89; + pub const EIDRM : c_int = 90; + pub const ENOMSG : c_int = 91; + pub const EILSEQ : c_int = 92; + pub const ENOATTR : c_int = 93; + pub const EBADMSG : c_int = 94; + pub const EMULTIHOP : c_int = 95; + pub const ENODATA : c_int = 96; + pub const ENOLINK : c_int = 97; + pub const ENOSR : c_int = 98; + pub const ENOSTR : c_int = 99; + pub const EPROTO : c_int = 100; + pub const ETIME : c_int = 101; + pub const EOPNOTSUPP : c_int = 102; + pub const ENOPOLICY : c_int = 103; + pub const ENOTRECOVERABLE : c_int = 104; + pub const EOWNERDEAD : c_int = 105; + pub const EQFULL : c_int = 106; + pub const ELAST : c_int = 106; + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x2000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 56; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; + pub const _SC_LOGIN_NAME_MAX : c_int = 73; + pub const _SC_MQ_PRIO_MAX : c_int = 75; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; + pub const _SC_THREAD_KEYS_MAX : c_int = 86; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; + pub const _SC_THREAD_STACK_MIN : c_int = 93; + pub const _SC_THREAD_THREADS_MAX : c_int = 94; + pub const _SC_THREADS : c_int = 96; + pub const _SC_TTY_NAME_MAX : c_int = 101; + pub const _SC_ATEXIT_MAX : c_int = 107; + pub const _SC_XOPEN_CRYPT : c_int = 108; + pub const _SC_XOPEN_ENH_I18N : c_int = 109; + pub const _SC_XOPEN_LEGACY : c_int = 110; + pub const _SC_XOPEN_REALTIME : c_int = 111; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; + pub const _SC_XOPEN_SHM : c_int = 113; + pub const _SC_XOPEN_UNIX : c_int = 115; + pub const _SC_XOPEN_VERSION : c_int = 116; + pub const _SC_XOPEN_XCU_VERSION : c_int = 121; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 1; + pub const PTHREAD_CREATE_DETACHED: c_int = 2; + pub const PTHREAD_STACK_MIN: size_t = 8192; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_AS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIM_NLIMITS: c_int = 9; + pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; + + pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 5; + pub const MADV_ZERO_WIRED_PAGES : c_int = 6; + pub const MADV_FREE_REUSABLE : c_int = 7; + pub const MADV_FREE_REUSE : c_int = 8; + pub const MADV_CAN_REUSE : c_int = 9; + + pub const MINCORE_INCORE : c_int = 0x1; + pub const MINCORE_REFERENCED : c_int = 0x2; + pub const MINCORE_MODIFIED : c_int = 0x4; + pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; + pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 30; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + + pub const TCP_NODELAY: c_int = 0x01; + pub const TCP_KEEPALIVE: c_int = 0x10; + pub const SOL_SOCKET: c_int = 0xffff; + + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_DSYNC : c_int = 4194304; + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const F_FULLFSYNC : c_int = 51; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0020; + pub const MAP_NORESERVE : c_int = 0x0040; + pub const MAP_NOEXTEND : c_int = 0x0100; + pub const MAP_HASSEMAPHORE : c_int = 0x0200; + pub const MAP_NOCACHE : c_int = 0x0400; + pub const MAP_JIT : c_int = 0x0800; + pub const MAP_STACK : c_int = 0; + + pub const IPPROTO_RAW : c_int = 255; + + pub const SO_NREAD: c_int = 0x1020; + pub const SO_NKE: c_int = 0x1021; + pub const SO_NOSIGPIPE: c_int = 0x1022; + pub const SO_NOADDRERR: c_int = 0x1023; + pub const SO_NWRITE: c_int = 0x1024; + pub const SO_DONTTRUNC: c_int = 0x2000; + pub const SO_WANTMORE: c_int = 0x4000; + pub const SO_WANTOOBFLAG: c_int = 0x8000; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_ASYNCHRONOUS_IO : c_int = 28; + pub const _SC_PAGESIZE : c_int = 29; + pub const _SC_MEMLOCK : c_int = 30; + pub const _SC_MEMLOCK_RANGE : c_int = 31; + pub const _SC_MEMORY_PROTECTION : c_int = 32; + pub const _SC_MESSAGE_PASSING : c_int = 33; + pub const _SC_PRIORITIZED_IO : c_int = 34; + pub const _SC_PRIORITY_SCHEDULING : c_int = 35; + pub const _SC_REALTIME_SIGNALS : c_int = 36; + pub const _SC_SEMAPHORES : c_int = 37; + pub const _SC_FSYNC : c_int = 38; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; + pub const _SC_SYNCHRONIZED_IO : c_int = 40; + pub const _SC_TIMERS : c_int = 41; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_DELAYTIMER_MAX : c_int = 45; + pub const _SC_MQ_OPEN_MAX : c_int = 46; + pub const _SC_MAPPED_FILES : c_int = 47; + pub const _SC_RTSIG_MAX : c_int = 48; + pub const _SC_SEM_NSEMS_MAX : c_int = 49; + pub const _SC_SEM_VALUE_MAX : c_int = 50; + pub const _SC_SIGQUEUE_MAX : c_int = 51; + pub const _SC_TIMER_MAX : c_int = 52; + pub const _SC_NPROCESSORS_CONF : c_int = 57; + pub const _SC_NPROCESSORS_ONLN : c_int = 58; + pub const _SC_2_PBS : c_int = 59; + pub const _SC_2_PBS_ACCOUNTING : c_int = 60; + pub const _SC_2_PBS_CHECKPOINT : c_int = 61; + pub const _SC_2_PBS_LOCATE : c_int = 62; + pub const _SC_2_PBS_MESSAGE : c_int = 63; + pub const _SC_2_PBS_TRACK : c_int = 64; + pub const _SC_ADVISORY_INFO : c_int = 65; + pub const _SC_BARRIERS : c_int = 66; + pub const _SC_CLOCK_SELECTION : c_int = 67; + pub const _SC_CPUTIME : c_int = 68; + pub const _SC_FILE_LOCKING : c_int = 69; + pub const _SC_HOST_NAME_MAX : c_int = 72; + pub const _SC_MONOTONIC_CLOCK : c_int = 74; + pub const _SC_READER_WRITER_LOCKS : c_int = 76; + pub const _SC_REGEXP : c_int = 77; + pub const _SC_SHELL : c_int = 78; + pub const _SC_SPAWN : c_int = 79; + pub const _SC_SPIN_LOCKS : c_int = 80; + pub const _SC_SPORADIC_SERVER : c_int = 81; + pub const _SC_THREAD_CPUTIME : c_int = 84; + pub const _SC_THREAD_SPORADIC_SERVER : c_int = 92; + pub const _SC_TIMEOUTS : c_int = 95; + pub const _SC_TRACE : c_int = 97; + pub const _SC_TRACE_EVENT_FILTER : c_int = 98; + pub const _SC_TRACE_INHERIT : c_int = 99; + pub const _SC_TRACE_LOG : c_int = 100; + pub const _SC_TYPED_MEMORY_OBJECTS : c_int = 102; + pub const _SC_V6_ILP32_OFF32 : c_int = 103; + pub const _SC_V6_ILP32_OFFBIG : c_int = 104; + pub const _SC_V6_LP64_OFF64 : c_int = 105; + pub const _SC_V6_LPBIG_OFFBIG : c_int = 106; + pub const _SC_IPV6 : c_int = 118; + pub const _SC_RAW_SOCKETS : c_int = 119; + pub const _SC_SYMLOOP_MAX : c_int = 120; + pub const _SC_PAGE_SIZE : c_int = _SC_PAGESIZE; + pub const _SC_XOPEN_STREAMS : c_int = 114; + pub const _SC_XBS5_ILP32_OFF32 : c_int = 122; + pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123; + pub const _SC_XBS5_LP64_OFF64 : c_int = 124; + pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125; + pub const _SC_SS_REPL_MAX : c_int = 126; + pub const _SC_TRACE_EVENT_NAME_MAX : c_int = 127; + pub const _SC_TRACE_NAME_MAX : c_int = 128; + pub const _SC_TRACE_SYS_MAX : c_int = 129; + pub const _SC_TRACE_USER_EVENT_MAX : c_int = 130; + pub const _SC_PASS_MAX : c_int = 131; + } + } +} + + +pub mod funcs { + // Thankfully most of c95 is universally available and does not vary by OS + // or anything. The same is not true of POSIX. + + pub mod c95 { + pub mod ctype { + use types::os::arch::c95::{c_char, c_int}; + + extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_char) -> c_char; + pub fn toupper(c: c_char) -> c_char; + } + } + + pub mod stdio { + use types::common::c95::{FILE, c_void, fpos_t}; + use types::os::arch::c95::{c_char, c_int, c_long, size_t}; + + extern { + pub fn fopen(filename: *const c_char, + mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) + -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, + newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t) + -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + // Omitted: printf and scanf variants. + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; + // Omitted: getc, getchar (might be macros). + + // Omitted: gets, so ridiculously unsafe that it should not + // survive. + + // Omitted: putc, putchar (might be macros). + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE) + -> size_t; + pub fn fwrite(ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE) + -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) + -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + } + } + + pub mod stdlib { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_double, c_int}; + use types::os::arch::c95::{c_long, c_uint, c_ulong}; + use types::os::arch::c95::{size_t}; + + extern { + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + // Omitted: div, ldiv (return pub type incomplete). + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, + endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, + endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + + /// Exits the running program in a possibly dangerous manner. + /// + /// # Unsafety + /// + /// While this forces your program to exit, it does so in a way that has + /// consequences. This will skip all unwinding code, which means that anything + /// relying on unwinding for cleanup (such as flushing and closing a buffer to a + /// file) may act in an unexpected way. + /// + /// # Examples + /// + /// ```no_run,ignore + /// extern crate libc; + /// + /// fn main() { + /// unsafe { + /// libc::exit(1); + /// } + /// } + /// ``` + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + // Omitted: bsearch, qsort + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + } + } + + pub mod string { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, size_t}; + use types::os::arch::c95::{wchar_t}; + + extern { + pub fn strcpy(dst: *mut c_char, + src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) + -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, + n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strpbrk(cs: *const c_char, + ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, + ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, + n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + + // Omitted: memcpy, memmove, memset (provided by LLVM) + + // These are fine to execute on the Rust stack. They must be, + // in fact, because LLVM generates calls to them! + pub fn memcmp(cx: *const c_void, ct: *const c_void, + n: size_t) -> c_int; + pub fn memchr(cx: *const c_void, c: c_int, + n: size_t) -> *mut c_void; + } + } + } + + // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols + // to make sure you don't use them accidentally. It also randomly deviates + // from the exact signatures you might otherwise expect, and omits much, + // so be careful when trying to write portable code; it won't always work + // with the same POSIX functions and types as other platforms. + + #[cfg(target_os = "windows")] + pub mod posix88 { + pub mod stat_ { + use types::os::common::posix01::{stat, utimbuf}; + use types::os::arch::c95::{c_int, c_char, wchar_t}; + + extern { + #[link_name = "_chmod"] + pub fn chmod(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_wchmod"] + pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; + #[link_name = "_mkdir"] + pub fn mkdir(path: *const c_char) -> c_int; + #[link_name = "_wrmdir"] + pub fn wrmdir(path: *const wchar_t) -> c_int; + #[link_name = "_fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + #[link_name = "_stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + #[link_name = "_wstat64"] + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; + #[link_name = "_wutime64"] + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; + } + } + + pub mod stdio { + use types::common::c95::FILE; + use types::os::arch::c95::{c_int, c_char}; + + extern { + #[link_name = "_popen"] + pub fn popen(command: *const c_char, + mode: *const c_char) -> *mut FILE; + #[link_name = "_pclose"] + pub fn pclose(stream: *mut FILE) -> c_int; + #[link_name = "_fdopen"] + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; + #[link_name = "_fileno"] + pub fn fileno(stream: *mut FILE) -> c_int; + } + } + + pub mod fcntl { + use types::os::arch::c95::{c_int, c_char, wchar_t}; + extern { + #[link_name = "_open"] + pub fn open(path: *const c_char, oflag: c_int, mode: c_int) + -> c_int; + #[link_name = "_wopen"] + pub fn wopen(path: *const wchar_t, oflag: c_int, mode: c_int) + -> c_int; + #[link_name = "_creat"] + pub fn creat(path: *const c_char, mode: c_int) -> c_int; + } + } + + pub mod dirent { + // Not supplied at all. + } + + pub mod unistd { + use types::common::c95::c_void; + use types::os::arch::c95::{c_int, c_uint, c_char, + c_long, size_t}; + use types::os::arch::c99::intptr_t; + + extern { + #[link_name = "_access"] + pub fn access(path: *const c_char, amode: c_int) -> c_int; + #[link_name = "_chdir"] + pub fn chdir(dir: *const c_char) -> c_int; + #[link_name = "_close"] + pub fn close(fd: c_int) -> c_int; + #[link_name = "_dup"] + pub fn dup(fd: c_int) -> c_int; + #[link_name = "_dup2"] + pub fn dup2(src: c_int, dst: c_int) -> c_int; + #[link_name = "_execv"] + pub fn execv(prog: *const c_char, + argv: *mut *const c_char) -> intptr_t; + #[link_name = "_execve"] + pub fn execve(prog: *const c_char, argv: *mut *const c_char, + envp: *mut *const c_char) + -> c_int; + #[link_name = "_execvp"] + pub fn execvp(c: *const c_char, + argv: *mut *const c_char) -> c_int; + #[link_name = "_execvpe"] + pub fn execvpe(c: *const c_char, argv: *mut *const c_char, + envp: *mut *const c_char) -> c_int; + #[link_name = "_getcwd"] + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + #[link_name = "_getpid"] + pub fn getpid() -> c_int; + #[link_name = "_isatty"] + pub fn isatty(fd: c_int) -> c_int; + #[link_name = "_lseek"] + pub fn lseek(fd: c_int, offset: c_long, origin: c_int) + -> c_long; + #[link_name = "_pipe"] + pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) + -> c_int; + #[link_name = "_read"] + pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) + -> c_int; + #[link_name = "_rmdir"] + pub fn rmdir(path: *const c_char) -> c_int; + #[link_name = "_unlink"] + pub fn unlink(c: *const c_char) -> c_int; + #[link_name = "_write"] + pub fn write(fd: c_int, buf: *const c_void, + count: c_uint) -> c_int; + } + } + + pub mod mman { + } + } + + #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "nacl"))] + pub mod posix88 { + pub mod stat_ { + use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::posix01::stat; + use types::os::arch::posix88::mode_t; + + extern { + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "android", + target_os = "ios", + target_os = "nacl"))] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + #[cfg(target_os = "macos")] + #[link_name = "fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; + #[cfg(not(target_os = "nacl"))] + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "android", + target_os = "ios", + target_os = "nacl"))] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + + #[cfg(target_os = "macos")] + #[link_name = "stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + } + } + + pub mod stdio { + use types::common::c95::FILE; + use types::os::arch::c95::{c_char, c_int}; + + extern { + pub fn popen(command: *const c_char, + mode: *const c_char) -> *mut FILE; + pub fn pclose(stream: *mut FILE) -> c_int; + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; + pub fn fileno(stream: *mut FILE) -> c_int; + } + } + + pub mod fcntl { + use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::posix88::mode_t; + + mod open_shim { + extern { + #[cfg(any(target_os = "macos", + target_os = "ios"))] + pub fn open(path: *const ::c_char, oflag: ::c_int, ...) + -> ::c_int; + + #[cfg(not(any(target_os = "macos", + target_os = "ios")))] + pub fn open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t) + -> ::c_int; + } + } + + #[cfg(any(target_os = "macos", + target_os = "ios"))] + #[inline] + pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { + use types::os::arch::c95::c_uint; + open_shim::open(path, oflag, mode as c_uint) + } + + #[cfg(not(any(target_os = "macos", + target_os = "ios")))] + #[inline] + pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { + open_shim::open(path, oflag, mode) + } + + extern { + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + } + } + + pub mod dirent { + use types::common::posix88::{DIR, dirent_t}; + use types::os::arch::c95::{c_char, c_int, c_long}; + + // NB: On OS X opendir and readdir have two versions, + // one for 32-bit kernelspace and one for 64. + // We should be linking to the 64-bit ones, called + // opendir$INODE64, etc. but for some reason rustc + // doesn't link it correctly on i686, so we're going + // through a C function that mysteriously does work. + + extern { + #[link_name="rust_opendir"] + pub fn opendir(dirname: *const c_char) -> *mut DIR; + #[link_name="rust_readdir_r"] + pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent_t, + result: *mut *mut dirent_t) -> c_int; + } + + extern { + pub fn closedir(dirp: *mut DIR) -> c_int; + pub fn rewinddir(dirp: *mut DIR); + pub fn seekdir(dirp: *mut DIR, loc: c_long); + pub fn telldir(dirp: *mut DIR) -> c_long; + } + } + + pub mod unistd { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, c_long, c_uint}; + use types::os::arch::c95::{size_t}; + use types::os::common::posix01::timespec; + use types::os::arch::posix01::utimbuf; + use types::os::arch::posix88::{gid_t, off_t, pid_t}; + use types::os::arch::posix88::{ssize_t, uid_t}; + + pub const _PC_NAME_MAX: c_int = 4; + + #[cfg(not(target_os = "nacl"))] + extern { + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, + gid: gid_t) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn execv(prog: *const c_char, + argv: *mut *const c_char) -> c_int; + pub fn execve(prog: *const c_char, argv: *mut *const c_char, + envp: *mut *const c_char) + -> c_int; + pub fn execvp(c: *const c_char, + argv: *mut *const c_char) -> c_int; + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) + -> c_int; + pub fn getlogin() -> *mut c_char; + pub fn getopt(argc: c_int, argv: *mut *const c_char, + optstr: *const c_char) -> c_int; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn getsid(pid: pid_t) -> pid_t; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) + -> off_t; + pub fn pathconf(path: *mut c_char, name: c_int) -> c_long; + pub fn pause() -> c_int; + pub fn pipe(fds: *mut c_int) -> c_int; + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) + -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn usleep(secs: c_uint) -> c_int; + pub fn nanosleep(rqtp: *const timespec, + rmtp: *mut timespec) -> c_int; + pub fn sysconf(name: c_int) -> c_long; + pub fn tcgetpgrp(fd: c_int) -> pid_t; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> c_int; + pub fn wait(status: *const c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *const c_int, options: c_int) + -> pid_t; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) + -> ssize_t; + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + } + #[cfg(target_os = "nacl")] + extern { + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, + gid: gid_t) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn execv(prog: *const c_char, + argv: *mut *const c_char) -> c_int; + pub fn execve(prog: *const c_char, argv: *mut *const c_char, + envp: *mut *const c_char) + -> c_int; + pub fn execvp(c: *const c_char, + argv: *mut *const c_char) -> c_int; + pub fn fork() -> pid_t; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getlogin() -> *mut c_char; + pub fn getopt(argc: c_int, argv: *mut *const c_char, + optstr: *const c_char) -> c_int; + pub fn getuid() -> uid_t; + pub fn getsid(pid: pid_t) -> pid_t; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) + -> off_t; + pub fn pipe(fds: *mut c_int) -> c_int; + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) + -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setuid(uid: uid_t) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn usleep(secs: c_uint) -> c_int; + pub fn nanosleep(rqtp: *const timespec, + rmtp: *mut timespec) -> c_int; + pub fn sysconf(name: c_int) -> c_long; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> c_int; + pub fn wait(status: *const c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *const c_int, options: c_int) + -> pid_t; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) + -> ssize_t; + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + } + } + + pub mod signal { + use types::os::arch::c95::{c_int}; + use types::os::arch::posix88::{pid_t}; + + extern { + pub fn kill(pid: pid_t, sig: c_int) -> c_int; + } + } + + pub mod mman { + use types::common::c95::{c_void}; + use types::os::arch::c95::{size_t, c_int, c_char}; + use types::os::arch::posix88::{mode_t, off_t}; + + #[cfg(not(target_os = "nacl"))] + extern { + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) + -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) + -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) + -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + } + + extern { + pub fn mmap(addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t) + -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + } + } + + pub mod net { + use types::os::arch::c95::{c_char, c_uint}; + + extern { + pub fn if_nametoindex(ifname: *const c_char) -> c_uint; + } + } + + } + + #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "nacl"))] + pub mod posix01 { + pub mod stat_ { + use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::posix01::stat; + + extern { + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "android", + target_os = "ios", + target_os = "nacl"))] + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + + #[cfg(target_os = "macos")] + #[link_name = "lstat64"] + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + } + } + + pub mod unistd { + use types::os::arch::c95::{c_char, c_int, size_t}; + use types::os::arch::posix88::{ssize_t, off_t}; + + extern { + pub fn readlink(path: *const c_char, + buf: *mut c_char, + bufsz: size_t) + -> ssize_t; + + pub fn fsync(fd: c_int) -> c_int; + + #[cfg(any(target_os = "linux", target_os = "android"))] + pub fn fdatasync(fd: c_int) -> c_int; + + pub fn setenv(name: *const c_char, val: *const c_char, + overwrite: c_int) -> c_int; + pub fn unsetenv(name: *const c_char) -> c_int; + pub fn putenv(string: *mut c_char) -> c_int; + + pub fn symlink(path1: *const c_char, + path2: *const c_char) -> c_int; + + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + } + } + + pub mod signal { + use types::os::arch::c95::c_int; + use types::os::common::posix01::sighandler_t; + + #[cfg(not(all(target_os = "android", target_arch = "arm")))] + extern { + pub fn signal(signum: c_int, + handler: sighandler_t) -> sighandler_t; + } + + #[cfg(all(target_os = "android", target_arch = "arm"))] + extern { + #[link_name = "bsd_signal"] + pub fn signal(signum: c_int, + handler: sighandler_t) -> sighandler_t; + } + } + + pub mod glob { + use types::os::arch::c95::{c_char, c_int}; + use types::os::common::posix01::{glob_t}; + + extern { + pub fn glob(pattern: *const c_char, + flags: c_int, + errfunc: ::core::option::Option c_int>, + pglob: *mut glob_t); + pub fn globfree(pglob: *mut glob_t); + } + } + + pub mod mman { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_int, size_t}; + + #[cfg(not(target_os = "nacl"))] + extern { + pub fn posix_madvise(addr: *mut c_void, + len: size_t, + advice: c_int) + -> c_int; + } + } + + pub mod resource { + use types::os::arch::c95::c_int; + use types::os::common::posix01::rlimit; + use types::os::common::bsd43::rusage; + extern { + pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; + pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; + + } + } + } + + #[cfg(target_os = "windows")] + pub mod posix01 { + pub mod stat_ { + } + + pub mod unistd { + } + + pub mod glob { + } + + pub mod mman { + } + + pub mod net { + } + } + + + #[cfg(any(target_os = "windows", + target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "nacl"))] + pub mod posix08 { + pub mod unistd { + } + } + + #[cfg(not(windows))] + pub mod bsd43 { + use types::common::c95::{c_void}; + use types::os::common::bsd44::{socklen_t, sockaddr, ifaddrs}; + use types::os::arch::c95::{c_int, size_t}; + use types::os::arch::posix88::ssize_t; + + extern "system" { + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; + pub fn connect(socket: c_int, address: *const sockaddr, + len: socklen_t) -> c_int; + pub fn bind(socket: c_int, address: *const sockaddr, + address_len: socklen_t) -> c_int; + pub fn listen(socket: c_int, backlog: c_int) -> c_int; + pub fn accept(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn getpeername(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn getsockname(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn setsockopt(socket: c_int, level: c_int, name: c_int, + value: *const c_void, + option_len: socklen_t) -> c_int; + pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, + flags: c_int) -> ssize_t; + pub fn send(socket: c_int, buf: *const c_void, len: size_t, + flags: c_int) -> ssize_t; + pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ssize_t; + pub fn sendto(socket: c_int, buf: *const c_void, len: size_t, + flags: c_int, addr: *const sockaddr, + addrlen: socklen_t) -> ssize_t; + pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut ifaddrs); + pub fn shutdown(socket: c_int, how: c_int) -> c_int; + } + } + + #[cfg(windows)] + pub mod bsd43 { + use types::common::c95::{c_void}; + use types::os::common::bsd44::{socklen_t, sockaddr, SOCKET}; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::ssize_t; + + extern "system" { + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; + pub fn connect(socket: SOCKET, address: *const sockaddr, + len: socklen_t) -> c_int; + pub fn bind(socket: SOCKET, address: *const sockaddr, + address_len: socklen_t) -> c_int; + pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; + pub fn accept(socket: SOCKET, address: *mut sockaddr, + address_len: *mut socklen_t) -> SOCKET; + pub fn getpeername(socket: SOCKET, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn getsockname(socket: SOCKET, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, + value: *const c_void, + option_len: socklen_t) -> c_int; + pub fn closesocket(socket: SOCKET) -> c_int; + pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, + flags: c_int) -> c_int; + pub fn send(socket: SOCKET, buf: *const c_void, len: c_int, + flags: c_int) -> c_int; + pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut c_int) -> ssize_t; + pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int, + flags: c_int, addr: *const sockaddr, + addrlen: c_int) -> c_int; + pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; + } + } + + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd"))] + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t}; + + extern { + pub fn ioctl(d: c_int, request: c_ulong, ...) -> c_int; + pub fn sysctl(name: *mut c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn sysctlnametomib(name: *const c_char, + mibp: *mut c_int, + sizep: *mut size_t) + -> c_int; + pub fn getdtablesize() -> c_int; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) + -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + -> c_int; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) + -> *mut c_char; + } + } + + #[cfg(any(target_os = "linux", target_os = "android"))] + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_uchar, c_int, size_t}; + + extern { + #[cfg(not(all(target_os = "android", target_arch = "aarch64")))] + pub fn getdtablesize() -> c_int; + pub fn ioctl(d: c_int, request: c_int, ...) -> c_int; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) + -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + -> c_int; + } + } + + #[cfg(target_os = "nacl")] + pub mod bsd44 { + use types::os::arch::c95::c_int; + extern { + pub fn getdtablesize() -> c_int; + } + } + + #[cfg(target_os = "windows")] + pub mod bsd44 { + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod extra { + use types::os::arch::c95::{c_char, c_int}; + + extern { + pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32) + -> c_int; + } + } + + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd"))] + pub mod extra { + } + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] + pub mod extra { + } + + + #[cfg(target_os = "windows")] + pub mod extra { + + pub mod kernel32 { + use types::os::arch::c95::{c_uint}; + use types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE, + LPCWSTR, LPWSTR, + LPWCH, LPDWORD, LPVOID, + LPCVOID, LPOVERLAPPED, + LPSECURITY_ATTRIBUTES, + LPSTARTUPINFO, + LPPROCESS_INFORMATION, + LPMEMORY_BASIC_INFORMATION, + LPSYSTEM_INFO, HANDLE, LPHANDLE, + LARGE_INTEGER, PLARGE_INTEGER, + LPFILETIME, LPWIN32_FIND_DATAW}; + + extern "system" { + pub fn GetEnvironmentVariableW(n: LPCWSTR, + v: LPWSTR, + nsize: DWORD) + -> DWORD; + pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) + -> BOOL; + pub fn GetEnvironmentStringsW() -> LPWCH; + pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; + pub fn GetModuleFileNameW(hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD) + -> DWORD; + pub fn CreateDirectoryW(lpPathName: LPCWSTR, + lpSecurityAttributes: + LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn CopyFileW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + bFailIfExists: BOOL) + -> BOOL; + pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; + pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetCurrentDirectoryW(nBufferLength: DWORD, + lpBuffer: LPWSTR) + -> DWORD; + pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetLastError() -> DWORD; + pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) + -> HANDLE; + pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) + -> BOOL; + pub fn FindClose(findFile: HANDLE) -> BOOL; + pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, + hSourceHandle: HANDLE, + hTargetProcessHandle: HANDLE, + lpTargetHandle: LPHANDLE, + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwOptions: DWORD) + -> BOOL; + pub fn CloseHandle(hObject: HANDLE) -> BOOL; + pub fn OpenProcess(dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwProcessId: DWORD) + -> HANDLE; + pub fn GetCurrentProcess() -> HANDLE; + pub fn CreateProcessW(lpApplicationName: LPCWSTR, + lpCommandLine: LPWSTR, + lpProcessAttributes: + LPSECURITY_ATTRIBUTES, + lpThreadAttributes: + LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCWSTR, + lpStartupInfo: LPSTARTUPINFO, + lpProcessInformation: + LPPROCESS_INFORMATION) + -> BOOL; + pub fn WaitForSingleObject(hHandle: HANDLE, + dwMilliseconds: DWORD) + -> DWORD; + pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) + -> BOOL; + pub fn GetExitCodeProcess(hProcess: HANDLE, + lpExitCode: LPDWORD) + -> BOOL; + pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); + pub fn VirtualAlloc(lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD) + -> LPVOID; + pub fn VirtualFree(lpAddress: LPVOID, + dwSize: SIZE_T, + dwFreeType: DWORD) + -> BOOL; + pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; + pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) + -> BOOL; + pub fn VirtualProtect(lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, + lpflOldProtect: LPDWORD) + -> BOOL; + pub fn VirtualQuery(lpAddress: LPCVOID, + lpBuffer: LPMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T) + -> SIZE_T; + pub fn CreateFileMappingW(hFile: HANDLE, + lpAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR) + -> HANDLE; + pub fn MapViewOfFile(hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T) + -> LPVOID; + pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; + pub fn MoveFileExW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + dwFlags: DWORD) -> BOOL; + pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, + lpTargetFileName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; + pub fn CreateFileW(lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE) -> HANDLE; + pub fn ReadFile(hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WriteFile(hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn SetFilePointerEx(hFile: HANDLE, + liDistanceToMove: LARGE_INTEGER, + lpNewFilePointer: PLARGE_INTEGER, + dwMoveMethod: DWORD) -> BOOL; + pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; + + pub fn GetSystemTimeAsFileTime( + lpSystemTimeAsFileTime: LPFILETIME); + + pub fn QueryPerformanceFrequency( + lpFrequency: *mut LARGE_INTEGER) -> BOOL; + pub fn QueryPerformanceCounter( + lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; + + pub fn GetCurrentProcessId() -> DWORD; + pub fn CreateNamedPipeW( + lpName: LPCWSTR, + dwOpenMode: DWORD, + dwPipeMode: DWORD, + nMaxInstances: DWORD, + nOutBufferSize: DWORD, + nInBufferSize: DWORD, + nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES + ) -> HANDLE; + pub fn ConnectNamedPipe(hNamedPipe: HANDLE, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, + nTimeOut: DWORD) -> BOOL; + pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, + lpMode: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD) + -> BOOL; + pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + bInitialState: BOOL, + lpName: LPCWSTR) -> HANDLE; + pub fn GetOverlappedResult(hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + bWait: BOOL) -> BOOL; + pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; + } + } + + pub mod msvcrt { + use types::os::arch::c95::{c_int, c_long}; + use types::os::arch::c99::intptr_t; + + extern { + #[link_name = "_commit"] + pub fn commit(fd: c_int) -> c_int; + + #[link_name = "_get_osfhandle"] + pub fn get_osfhandle(fd: c_int) -> c_long; + + #[link_name = "_open_osfhandle"] + pub fn open_osfhandle(osfhandle: intptr_t, + flags: c_int) -> c_int; + } + } + + pub mod winsock { + use types::os::arch::c95::{c_int, c_long, c_ulong}; + use types::os::common::bsd44::SOCKET; + + extern "system" { + pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; + } + } + } +} + +#[doc(hidden)] +pub fn issue_14344_workaround() {} // FIXME #14344 force linkage to happen correctly + +#[test] fn work_on_windows() { } // FIXME #10872 needed for a happy windows diff --git a/deps/libgit2-sys-0.2.17/Cargo.toml b/deps/libgit2-sys-0.2.17/Cargo.toml new file mode 100644 index 000000000..9c0aa6c06 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/Cargo.toml @@ -0,0 +1,55 @@ +[package] + +name = "libgit2-sys" +version = "0.2.17" +authors = ["Alex Crichton "] +links = "git2" +build = "build.rs" +repository = "https://github.com/alexcrichton/git2-rs" +license = "MIT/Apache-2.0" +description = "Native bindings to the libgit2 library" + +[lib] + name = "libgit2_sys" + path = "lib.rs" + +[dependencies] +libssh2-sys = "0.1.0" +libc = "0.1" + +[build-dependencies] +pkg-config = "0.3" + +[target.i686-apple-darwin.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.x86_64-apple-darwin.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.i686-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.x86_64-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.aarch64-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.arm-unknown-linux-gnueabihf.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.i686-unknown-freebsd.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.x86_64-unknown-freebsd.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.x86_64-unknown-bitrig.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.x86_64-unknown-openbsd.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" +[target.x86_64-unknown-dragonfly.dependencies] +openssl-sys = "0.6.0" +libz-sys = "0.1.0" diff --git a/deps/libgit2-sys-0.2.17/build.rs b/deps/libgit2-sys-0.2.17/build.rs new file mode 100644 index 000000000..d624a63dd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/build.rs @@ -0,0 +1,167 @@ +extern crate pkg_config; + +use std::env; +use std::fs::{self, File}; +use std::io::ErrorKind; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; +use std::process::Command; + +macro_rules! t { + ($e:expr) => (match $e { + Ok(n) => n, + Err(e) => fail(&format!("\n{} failed with {}\n", stringify!($e), e)), + }) +} + +fn main() { + register_dep("SSH2"); + register_dep("OPENSSL"); + + if env::var("LIBSSH2_SYS_USE_PKG_CONFIG").is_ok() { + if pkg_config::find_library("libgit2").is_ok() { + return + } + } + + let mut cflags = env::var("CFLAGS").unwrap_or(String::new()); + let target = env::var("TARGET").unwrap(); + let mingw = target.contains("windows-gnu"); + let msvc = target.contains("msvc"); + + if msvc { + // libgit2 passes the /GL flag to enable whole program optimization, but + // this requires that the /LTCG flag is passed to the linker later on, + // and currently the compiler does not do that, so we disable whole + // program optimization entirely. + cflags.push_str(" /GL-"); + } else { + cflags.push_str(" -ffunction-sections -fdata-sections"); + + if target.contains("i686") { + cflags.push_str(" -m32"); + } else if target.contains("x86_64") { + cflags.push_str(" -m64"); + } + if !target.contains("i686") { + cflags.push_str(" -fPIC"); + } + } + + // libgit2 uses pkg-config to discover libssh2, but this doesn't work on + // windows as libssh2 doesn't come with a libssh2.pc file in that install. + // As a result we just manually turn on SSH support in libgit2 (a little + // jankily) here... + if mingw { + cflags.push_str(" -DGIT_SSH"); + let libssh2_root = env::var("DEP_SSH2_ROOT").unwrap(); + cflags.push_str(&format!(" -I{}/include", libssh2_root)); + } else if msvc { + cflags.push_str(" /DGIT_SSH"); + let libssh2_root = env::var("DEP_SSH2_ROOT").unwrap(); + cflags.push_str(&format!(" /I{}\\include", libssh2_root)); + } + + let src = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap()); + let dst = PathBuf::from(&env::var("OUT_DIR").unwrap()); + let _ = fs::create_dir(&dst.join("build")); + + let mut cmd = Command::new("cmake"); + cmd.arg(&src.join("libgit2")) + .current_dir(&dst.join("build")); + if mingw { + cmd.arg("-G").arg("Unix Makefiles"); + } else if msvc { + // If we don't pass this unfortunately cmake produces 32-bit builds + cmd.arg("-G").arg("Visual Studio 12 2013 Win64"); + + // Currently liblibc links to msvcrt which apparently is a dynamic CRT, + // so we need to turn this off to get it to link right. + cmd.arg("-DSTATIC_CRT=OFF"); + } + let profile = match &env::var("PROFILE").unwrap()[..] { + "bench" | "release" => "Release", + _ if msvc => "Release", // currently we need to always use the same CRT + _ => "Debug", + }; + run(cmd.arg("-DBUILD_SHARED_LIBS=OFF") + .arg("-DBUILD_CLAR=OFF") + .arg(&format!("-DCMAKE_BUILD_TYPE={}", profile)) + .arg(&format!("-DCMAKE_INSTALL_PREFIX={}", dst.display())) + .arg(&format!("-DCMAKE_C_FLAGS={}", cflags)), "cmake"); + + let flags = dst.join("build/CMakeFiles/git2.dir/flags.make"); + let mut contents = String::new(); + + // Make sure libssh2 was detected on unix systems, because it definitely + // should have been! + if !msvc { + t!(t!(File::open(flags)).read_to_string(&mut contents)); + if !contents.contains("-DGIT_SSH") { + fail("libgit2 failed to find libssh2, and SSH support is required"); + } + } + + run(Command::new("cmake") + .arg("--build").arg(".") + .arg("--target").arg("install") + .arg("--config").arg(profile) + .current_dir(&dst.join("build")), "cmake"); + + println!("cargo:root={}", dst.display()); + if mingw || target.contains("windows") { + println!("cargo:rustc-flags=-l winhttp -l rpcrt4 -l ole32 \ + -l static=git2"); + println!("cargo:rustc-link-search=native={}/lib", dst.display()); + return + } + + if env::var("HOST") == env::var("TARGET") { + prepend("PKG_CONFIG_PATH", dst.join("lib/pkgconfig")); + if pkg_config::Config::new().statik(true).find("libgit2").is_ok() { + return + } + } + + println!("cargo:rustc-flags=-l static=git2"); + println!("cargo:rustc-flags=-L {}", dst.join("lib").display()); + if target.contains("apple") { + println!("cargo:rustc-flags=-l iconv"); + } +} + +fn run(cmd: &mut Command, program: &str) { + println!("running: {:?}", cmd); + let status = match cmd.status() { + Ok(status) => status, + Err(ref e) if e.kind() == ErrorKind::NotFound => { + fail(&format!("failed to execute command: {}\nis `{}` not installed?", + e, program)); + } + Err(e) => fail(&format!("failed to execute command: {}", e)), + }; + if !status.success() { + fail(&format!("command did not execute successfully, got: {}", status)); + } +} + +fn register_dep(dep: &str) { + match env::var(&format!("DEP_{}_ROOT", dep)) { + Ok(s) => { + prepend("CMAKE_PREFIX_PATH", PathBuf::from(&s)); + prepend("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig")); + } + Err(..) => {} + } +} + +fn prepend(var: &str, val: PathBuf) { + let prefix = env::var(var).unwrap_or(String::new()); + let mut v = vec![val]; + v.extend(env::split_paths(&prefix)); + env::set_var(var, &env::join_paths(v).unwrap()); +} + +fn fail(s: &str) -> ! { + panic!("\n{}\n\nbuild script failed, must exit now", s) +} diff --git a/deps/libgit2-sys-0.2.17/lib.rs b/deps/libgit2-sys-0.2.17/lib.rs new file mode 100644 index 000000000..bb5ed193f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/lib.rs @@ -0,0 +1,2168 @@ +#![doc(html_root_url = "http://alexcrichton.com/git2-rs")] +#![allow(non_camel_case_types)] +#![allow(raw_pointer_derive)] + +extern crate libc; +extern crate libssh2_sys as libssh2; +#[cfg(unix)] extern crate openssl_sys as openssl; +#[cfg(unix)] extern crate libz_sys as libz; + +pub use git_ref_t::*; +pub use git_branch_t::*; +pub use git_error_code::*; +pub use git_repository_state_t::*; +pub use git_direction::*; +pub use git_clone_local_t::*; +pub use git_remote_completion_type::*; +pub use git_checkout_notify_t::*; +pub use git_checkout_strategy_t::*; +pub use git_reset_t::*; +pub use git_otype::*; +pub use git_filemode_t::*; +pub use git_treewalk_mode::*; +pub use git_config_level_t::*; +pub use git_submodule_update_t::*; +pub use git_submodule_ignore_t::*; +pub use git_credtype_t::*; +pub use git_repository_init_flag_t::*; +pub use git_repository_init_mode_t::*; +pub use git_index_add_option_t::*; +pub use git_cert_t::*; +pub use git_status_t::*; +pub use git_status_opt_t::*; +pub use git_status_show_t::*; +pub use git_delta_t::*; +pub use git_sort::*; +pub use git_diff_format_t::*; +pub use git_diff_stats_format_t::*; +pub use git_smart_service_t::*; +pub use git_cert_ssh_t::*; + +use libc::{c_int, c_char, c_uint, size_t, c_uchar, c_void, c_ushort}; + +pub const GIT_OID_RAWSZ: usize = 20; +pub const GIT_OID_HEXSZ: usize = GIT_OID_RAWSZ * 2; +pub const GIT_CLONE_OPTIONS_VERSION: c_uint = 1; +pub const GIT_CHECKOUT_OPTIONS_VERSION: c_uint = 1; +pub const GIT_REMOTE_CALLBACKS_VERSION: c_uint = 1; +pub const GIT_STATUS_OPTIONS_VERSION: c_uint = 1; +pub const GIT_BLAME_OPTIONS_VERSION: c_uint = 1; + +pub enum git_blob {} +pub enum git_branch_iterator {} +pub enum git_blame {} +pub enum git_commit {} +pub enum git_config {} +pub enum git_config_iterator {} +pub enum git_index {} +pub enum git_object {} +pub enum git_reference {} +pub enum git_reference_iterator {} +pub enum git_refspec {} +pub enum git_remote {} +pub enum git_repository {} +pub enum git_revwalk {} +pub enum git_submodule {} +pub enum git_tag {} +pub enum git_tree {} +pub enum git_tree_entry {} +pub enum git_push {} +pub enum git_note {} +pub enum git_note_iterator {} +pub enum git_status_list {} +pub enum git_pathspec {} +pub enum git_pathspec_match_list {} +pub enum git_diff {} +pub enum git_diff_stats {} +pub enum git_reflog {} +pub enum git_reflog_entry {} + +#[repr(C)] +pub struct git_revspec { + pub from: *mut git_object, + pub to: *mut git_object, + pub flags: git_revparse_mode_t, +} + +#[repr(C)] +pub struct git_error { + pub message: *mut c_char, + pub klass: c_int, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_oid { + pub id: [u8; GIT_OID_RAWSZ], +} + +#[repr(C)] +#[derive(Copy)] +pub struct git_strarray { + pub strings: *mut *mut c_char, + pub count: size_t, +} +impl Clone for git_strarray { + fn clone(&self) -> git_strarray { *self } +} + +#[repr(C)] +pub struct git_signature { + pub name: *mut c_char, + pub email: *mut c_char, + pub when: git_time, +} + +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct git_time { + pub time: git_time_t, + pub offset: c_int, +} + +pub type git_off_t = i64; +pub type git_time_t = i64; + +pub type git_revparse_mode_t = c_int; +pub const GIT_REVPARSE_SINGLE: c_int = 1 << 0; +pub const GIT_REVPARSE_RANGE: c_int = 1 << 1; +pub const GIT_REVPARSE_MERGE_BASE: c_int = 1 << 2; + +#[repr(C)] +#[derive(PartialEq, Eq, Clone, Copy)] +pub enum git_error_code { + GIT_OK = 0, + + GIT_ERROR = -1, + GIT_ENOTFOUND = -3, + GIT_EEXISTS = -4, + GIT_EAMBIGUOUS = -5, + GIT_EBUFS = -6, + GIT_EUSER = -7, + GIT_EBAREREPO = -8, + GIT_EUNBORNBRANCH = -9, + GIT_EUNMERGED = -10, + GIT_ENONFASTFORWARD = -11, + GIT_EINVALIDSPEC = -12, + GIT_EMERGECONFLICT = -13, + GIT_ELOCKED = -14, + GIT_EMODIFIED = -15, + GIT_PASSTHROUGH = -30, + GIT_ITEROVER = -31, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_error_t { + GITERR_NONE = 0, + GITERR_NOMEMORY, + GITERR_OS, + GITERR_INVALID, + GITERR_REFERENCE, + GITERR_ZLIB, + GITERR_REPOSITORY, + GITERR_CONFIG, + GITERR_REGEX, + GITERR_ODB, + GITERR_INDEX, + GITERR_OBJECT, + GITERR_NET, + GITERR_TAG, + GITERR_TREE, + GITERR_INDEXER, + GITERR_SSL, + GITERR_SUBMODULE, + GITERR_THREAD, + GITERR_STASH, + GITERR_CHECKOUT, + GITERR_FETCHHEAD, + GITERR_MERGE, + GITERR_SSH, + GITERR_FILTER, + GITERR_REVERT, + GITERR_CALLBACK, + GITERR_CHERRYPICK, + GITERR_DESCRIBE, + GITERR_REBASE, +} +pub use git_error_t::*; + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_repository_state_t { + GIT_REPOSITORY_STATE_NONE, + GIT_REPOSITORY_STATE_MERGE, + GIT_REPOSITORY_STATE_REVERT, + GIT_REPOSITORY_STATE_CHERRYPICK, + GIT_REPOSITORY_STATE_BISECT, + GIT_REPOSITORY_STATE_REBASE, + GIT_REPOSITORY_STATE_REBASE_INTERACTIVE, + GIT_REPOSITORY_STATE_REBASE_MERGE, + GIT_REPOSITORY_STATE_APPLY_MAILBOX, + GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_direction { + GIT_DIRECTION_FETCH = 0, + GIT_DIRECTION_PUSH = 1, +} + +#[repr(C)] +pub struct git_clone_options { + pub version: c_uint, + pub checkout_opts: git_checkout_options, + pub remote_callbacks: git_remote_callbacks, + pub bare: c_int, + pub local: git_clone_local_t, + pub checkout_branch: *const c_char, + pub repository_cb: Option, + pub repository_cb_payload: *mut c_void, + pub remote_cb: Option, + pub remote_cb_payload: *mut c_void, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_clone_local_t { + GIT_CLONE_LOCAL_AUTO, + GIT_CLONE_LOCAL, + GIT_CLONE_NO_LOCAL, + GIT_CLONE_LOCAL_NO_LINKS, +} + +#[repr(C)] +pub struct git_checkout_options { + pub version: c_uint, + pub checkout_strategy: c_uint, + pub disable_filters: c_int, + pub dir_mode: c_uint, + pub file_mode: c_uint, + pub file_open_flags: c_int, + pub notify_flags: c_uint, + pub notify_cb: Option, + pub notify_payload: *mut c_void, + pub progress_cb: Option, + pub progress_payload: *mut c_void, + pub paths: git_strarray, + pub baseline: *mut git_tree, + pub target_directory: *const c_char, + pub ancestor_label: *const c_char, + pub our_label: *const c_char, + pub their_label: *const c_char, + pub perfdata_cb: Option, + pub perdata_payload: *mut c_void, +} + +pub type git_checkout_notify_cb = extern fn(git_checkout_notify_t, + *const c_char, + *const git_diff_file, + *const git_diff_file, + *const git_diff_file, + *mut c_void) -> c_int; +pub type git_checkout_progress_cb = extern fn(*const c_char, + size_t, + size_t, + *mut c_void); + +pub type git_checkout_perfdata_cb = extern fn(*const git_checkout_perfdata, + *mut c_void); + +#[repr(C)] +pub struct git_checkout_perfdata { + pub mkdir_calls: size_t, + pub stat_calls: size_t, + pub chmod_calls: size_t, +} + +#[repr(C)] +pub struct git_remote_callbacks { + pub version: c_uint, + pub sideband_progress: Option, + pub completion: Option c_int>, + pub credentials: Option, + pub certificate_check: Option, + pub transfer_progress: Option, + pub update_tips: Option c_int>, + pub pack_progress: Option, + pub push_transfer_progress: Option, + pub push_update_reference: Option c_int>, + pub payload: *mut c_void, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_remote_completion_type { + GIT_REMOTE_COMPLETION_DOWNLOAD, + GIT_REMOTE_COMPLETION_INDEXING, + GIT_REMOTE_COMPLETION_ERROR, +} + +pub type git_transport_message_cb = extern fn(*const c_char, c_int, + *mut c_void) -> c_int; +pub type git_cred_acquire_cb = extern fn(*mut *mut git_cred, + *const c_char, *const c_char, + c_uint, *mut c_void) -> c_int; +pub type git_transfer_progress_cb = extern fn(*const git_transfer_progress, + *mut c_void) -> c_int; +pub type git_packbuilder_progress = extern fn(c_int, c_uint, c_uint, + *mut c_void) -> c_int; +pub type git_push_transfer_progress = extern fn(c_uint, c_uint, size_t, + *mut c_void) -> c_int; +pub type git_transport_certificate_check_cb = extern fn(*mut git_cert, + c_int, + *const c_char, + *mut c_void) -> c_int; + +#[repr(C)] +#[derive(Copy, Clone, PartialEq)] +pub enum git_cert_t { + GIT_CERT_X509, + GIT_CERT_HOSTKEY_LIBSSH2, +} + +#[repr(C)] +pub struct git_cert { + pub cert_type: git_cert_t, +} + +#[repr(C)] +pub struct git_cert_hostkey { + pub cert_type: git_cert_t, + pub kind: git_cert_ssh_t, + pub hash_md5: [u8; 16], + pub hash_sha1: [u8; 20], +} + +#[repr(C)] +pub struct git_cert_x509 { + pub cert_type: git_cert_t, + pub data: *mut c_void, + pub len: size_t, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_cert_ssh_t { + GIT_CERT_SSH_MD5 = 1 << 0, + GIT_CERT_SSH_SHA1 = 1 << 1, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_transfer_progress { + pub total_objects: c_uint, + pub indexed_objects: c_uint, + pub received_objects: c_uint, + pub local_objects: c_uint, + pub total_deltas: c_uint, + pub indexed_deltas: c_uint, + pub received_bytes: size_t, +} + +#[repr(C)] +pub struct git_diff_file { + pub id: git_oid, + pub path: *const c_char, + pub size: git_off_t, + pub flags: u32, + pub mode: u16, +} + +pub type git_repository_create_cb = extern fn(*mut *mut git_repository, + *const c_char, + c_int, *mut c_void) -> c_int; +pub type git_remote_create_cb = extern fn(*mut *mut git_remote, + *mut git_repository, + *const c_char, + *const c_char, + *mut c_void) -> c_int; + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_checkout_notify_t { + GIT_CHECKOUT_NOTIFY_NONE = 0, + GIT_CHECKOUT_NOTIFY_CONFLICT = (1 << 0), + GIT_CHECKOUT_NOTIFY_DIRTY = (1 << 1), + GIT_CHECKOUT_NOTIFY_UPDATED = (1 << 2), + GIT_CHECKOUT_NOTIFY_UNTRACKED = (1 << 3), + GIT_CHECKOUT_NOTIFY_IGNORED = (1 << 4), + + GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFF, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_status_t { + GIT_STATUS_CURRENT = 0, + + GIT_STATUS_INDEX_NEW = (1 << 0), + GIT_STATUS_INDEX_MODIFIED = (1 << 1), + GIT_STATUS_INDEX_DELETED = (1 << 2), + GIT_STATUS_INDEX_RENAMED = (1 << 3), + GIT_STATUS_INDEX_TYPECHANGE = (1 << 4), + + GIT_STATUS_WT_NEW = (1 << 7), + GIT_STATUS_WT_MODIFIED = (1 << 8), + GIT_STATUS_WT_DELETED = (1 << 9), + GIT_STATUS_WT_TYPECHANGE = (1 << 10), + GIT_STATUS_WT_RENAMED = (1 << 11), + GIT_STATUS_WT_UNREADABLE = (1 << 12), + + GIT_STATUS_IGNORED = (1 << 14), +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_status_opt_t { + GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1 << 0), + GIT_STATUS_OPT_INCLUDE_IGNORED = (1 << 1), + GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1 << 2), + GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1 << 3), + GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1 << 4), + GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1 << 5), + GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1 << 6), + GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1 << 7), + GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1 << 8), + GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1 << 9), + GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1 << 10), + + GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1 << 11), + GIT_STATUS_OPT_NO_REFRESH = (1 << 12), + GIT_STATUS_OPT_UPDATE_INDEX = (1 << 13), + GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1 << 14), + GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1 << 15), +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_status_show_t { + GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0, + GIT_STATUS_SHOW_INDEX_ONLY = 1, + GIT_STATUS_SHOW_WORKDIR_ONLY = 2 +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_delta_t { + GIT_DELTA_UNMODIFIED = 0, + GIT_DELTA_ADDED = 1, + GIT_DELTA_DELETED = 2, + GIT_DELTA_MODIFIED = 3, + GIT_DELTA_RENAMED = 4, + GIT_DELTA_COPIED = 5, + GIT_DELTA_IGNORED = 6, + GIT_DELTA_UNTRACKED = 7, + GIT_DELTA_TYPECHANGE = 8, + GIT_DELTA_UNREADABLE = 9, +} + +#[repr(C)] +pub struct git_status_options { + pub version: c_uint, + pub show: git_status_show_t, + pub flags: c_uint, + pub pathspec: git_strarray, +} + +#[repr(C)] +pub struct git_diff_delta { + pub status: git_delta_t, + pub flags: u32, + pub similarity: u16, + pub nfiles: u16, + pub old_file: git_diff_file, + pub new_file: git_diff_file, +} + +#[repr(C)] +pub struct git_status_entry { + pub status: git_status_t, + pub head_to_index: *mut git_diff_delta, + pub index_to_workdir: *mut git_diff_delta +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_checkout_strategy_t { + GIT_CHECKOUT_NONE = 0, + GIT_CHECKOUT_SAFE = (1 << 0), + GIT_CHECKOUT_FORCE = (1 << 1), + GIT_CHECKOUT_ALLOW_CONFLICTS = (1 << 4), + GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 5), + GIT_CHECKOUT_REMOVE_IGNORED = (1 << 6), + GIT_CHECKOUT_UPDATE_ONLY = (1 << 7), + GIT_CHECKOUT_DONT_UPDATE_INDEX = (1 << 8), + GIT_CHECKOUT_NO_REFRESH = (1 << 9), + GIT_CHECKOUT_SKIP_UNMERGED = (1 << 10), + GIT_CHECKOUT_USE_OURS = (1 << 11), + GIT_CHECKOUT_USE_THEIRS = (1 << 12), + GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1 << 13), + GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = (1 << 18), + GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = (1 << 19), + GIT_CHECKOUT_CONFLICT_STYLE_MERGE = (1 << 20), + GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1 << 21), + + GIT_CHECKOUT_UPDATE_SUBMODULES = (1 << 16), + GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1 << 17), + +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_reset_t { + GIT_RESET_SOFT = 1, + GIT_RESET_MIXED = 2, + GIT_RESET_HARD = 3, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_otype { + GIT_OBJ_ANY = -2, + GIT_OBJ_BAD = -1, + GIT_OBJ__EXT1 = 0, + GIT_OBJ_COMMIT = 1, + GIT_OBJ_TREE = 2, + GIT_OBJ_BLOB = 3, + GIT_OBJ_TAG = 4, + GIT_OBJ__EXT2 = 5, + GIT_OBJ_OFS_DELTA = 6, + GIT_OBJ_REF_DELTA = 7, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_ref_t { + GIT_REF_INVALID = 0, + GIT_REF_OID = 1, + GIT_REF_SYMBOLIC = 2, + GIT_REF_LISTALL = GIT_REF_OID as isize | GIT_REF_SYMBOLIC as isize, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_filemode_t { + GIT_FILEMODE_UNREADABLE = 0o000000, + GIT_FILEMODE_TREE = 0o040000, + GIT_FILEMODE_BLOB = 0o100644, + GIT_FILEMODE_BLOB_EXECUTABLE = 0o100755, + GIT_FILEMODE_LINK = 0o120000, + GIT_FILEMODE_COMMIT = 0o160000, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_treewalk_mode { + GIT_TREEWALK_PRE = 0, + GIT_TREEWALK_POST = 1, +} + +pub type git_treewalk_cb = extern fn(*const c_char, *const git_tree_entry, + *mut c_void) -> c_int; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_buf { + pub ptr: *mut c_char, + pub asize: size_t, + pub size: size_t, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_branch_t { + GIT_BRANCH_LOCAL = 1, + GIT_BRANCH_REMOTE = 2, + GIT_BRANCH_ALL = GIT_BRANCH_LOCAL as isize | GIT_BRANCH_REMOTE as isize, +} + +pub const GIT_BLAME_NORMAL: u32 = 0; +pub const GIT_BLAME_TRACK_COPIES_SAME_FILE: u32 = 1<<0; +pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES: u32 = 1<<1; +pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES: u32 = 1<<2; +pub const GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES: u32 = 1<<3; +pub const GIT_BLAME_FIRST_PARENT: u32 = 1<<4; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_blame_options { + pub version: c_uint, + + pub flags: u32, + pub min_match_characters: u16, + pub newest_commit: git_oid, + pub oldest_commit: git_oid, + pub min_line: u32, + pub max_line: u32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_blame_hunk { + pub lines_in_hunk: u16, + pub final_commit_id: git_oid, + pub final_start_line_number: u16, + pub final_signature: *mut git_signature, + pub orig_commit_id: git_oid, + pub orig_path: *const c_char, + pub orig_start_line_number: u16, + pub orig_signature: *mut git_signature, + pub boundary: c_char, +} + +pub type git_index_matched_path_cb = extern fn(*const c_char, *const c_char, + *mut c_void) -> c_int; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_index_entry { + pub ctime: git_index_time, + pub mtime: git_index_time, + pub dev: c_uint, + pub ino: c_uint, + pub mode: c_uint, + pub uid: c_uint, + pub gid: c_uint, + pub file_size: git_off_t, + pub id: git_oid, + pub flags: c_ushort, + pub flags_extended: c_ushort, + pub path: *const c_char, +} + +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct git_index_time { + pub seconds: git_time_t, + pub nanoseconds: c_uint, +} + +#[repr(C)] +pub struct git_config_entry { + pub name: *const c_char, + pub value: *const c_char, + pub level: git_config_level_t, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_config_level_t { + GIT_CONFIG_LEVEL_SYSTEM = 1, + GIT_CONFIG_LEVEL_XDG = 2, + GIT_CONFIG_LEVEL_GLOBAL = 3, + GIT_CONFIG_LEVEL_LOCAL = 4, + GIT_CONFIG_LEVEL_APP = 5, + GIT_CONFIG_HIGHEST_LEVEL = -1, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_submodule_update_t { + GIT_SUBMODULE_UPDATE_RESET = -1, + GIT_SUBMODULE_UPDATE_CHECKOUT = 1, + GIT_SUBMODULE_UPDATE_REBASE = 2, + GIT_SUBMODULE_UPDATE_MERGE = 3, + GIT_SUBMODULE_UPDATE_NONE = 4, + GIT_SUBMODULE_UPDATE_DEFAULT = 0 +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_submodule_ignore_t { + GIT_SUBMODULE_IGNORE_RESET = -1, + + GIT_SUBMODULE_IGNORE_NONE = 1, + GIT_SUBMODULE_IGNORE_UNTRACKED = 2, + GIT_SUBMODULE_IGNORE_DIRTY = 3, + GIT_SUBMODULE_IGNORE_ALL = 4, + + GIT_SUBMODULE_IGNORE_DEFAULT = 0 +} + +#[repr(C)] +pub struct git_cred { + pub credtype: git_credtype_t, + pub free: extern fn(*mut git_cred), +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_credtype_t { + GIT_CREDTYPE_USERPASS_PLAINTEXT = 1 << 0, + GIT_CREDTYPE_SSH_KEY = 1 << 1, + GIT_CREDTYPE_SSH_CUSTOM = 1 << 2, + GIT_CREDTYPE_DEFAULT = 1 << 3, + GIT_CREDTYPE_SSH_INTERACTIVE = 1 << 4, + GIT_CREDTYPE_USERNAME = 1 << 5, +} + +pub type git_cred_ssh_interactive_callback = extern fn( + name: *const c_char, + name_len: c_int, + instruction: *const c_char, + instruction_len: c_int, + num_prompts: c_int, + prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT, + responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE, + abstrakt: *mut *mut c_void +); + +pub type git_cred_sign_callback = extern fn( + session: *mut LIBSSH2_SESSION, + sig: *mut *mut c_uchar, + sig_len: *mut size_t, + data: *const c_uchar, + data_len: size_t, + abstrakt: *mut *mut c_void, +); + +pub enum LIBSSH2_SESSION {} +pub enum LIBSSH2_USERAUTH_KBDINT_PROMPT {} +pub enum LIBSSH2_USERAUTH_KBDINT_RESPONSE {} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_push_options { + pub version: c_uint, + pub pb_parallelism: c_uint, +} + +pub type git_tag_foreach_cb = extern fn(name: *const c_char, + oid: *mut git_oid, + payload: *mut c_void) -> c_int; + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_index_add_option_t { + GIT_INDEX_ADD_DEFAULT = 0, + GIT_INDEX_ADD_FORCE = 1 << 0, + GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = 1 << 1, + GIT_INDEX_ADD_CHECK_PATHSPEC = 1 << 2, +} + +#[repr(C)] +pub struct git_repository_init_options { + pub version: c_uint, + pub flags: u32, + pub mode: u32, + pub workdir_path: *const c_char, + pub description: *const c_char, + pub template_path: *const c_char, + pub initial_head: *const c_char, + pub origin_url: *const c_char, +} + +pub const GIT_REPOSITORY_INIT_OPTIONS_VERSION: c_uint = 1; + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_repository_init_flag_t { + GIT_REPOSITORY_INIT_BARE = (1 << 0), + GIT_REPOSITORY_INIT_NO_REINIT = (1 << 1), + GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1 << 2), + GIT_REPOSITORY_INIT_MKDIR = (1 << 3), + GIT_REPOSITORY_INIT_MKPATH = (1 << 4), + GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1 << 5), +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum git_repository_init_mode_t { + GIT_REPOSITORY_INIT_SHARED_UMASK = 0, + GIT_REPOSITORY_INIT_SHARED_GROUP = 0o002775, + GIT_REPOSITORY_INIT_SHARED_ALL = 0o002777, +} + +#[repr(C)] +pub enum git_sort { + GIT_SORT_NONE = 0, + GIT_SORT_TOPOLOGICAL = (1 << 0), + GIT_SORT_TIME = (1 << 1), + GIT_SORT_REVERSE = (1 << 2), +} + +pub type git_submodule_status_t = c_uint; +pub const GIT_SUBMODULE_STATUS_IN_HEAD: c_uint = 1 << 0; +pub const GIT_SUBMODULE_STATUS_IN_INDEX: c_uint = 1 << 1; +pub const GIT_SUBMODULE_STATUS_IN_CONFIG: c_uint = 1 << 2; +pub const GIT_SUBMODULE_STATUS_IN_WD: c_uint = 1 << 3; +pub const GIT_SUBMODULE_STATUS_INDEX_ADDED: c_uint = 1 << 4; +pub const GIT_SUBMODULE_STATUS_INDEX_DELETED: c_uint = 1 << 5; +pub const GIT_SUBMODULE_STATUS_INDEX_MODIFIED: c_uint = 1 << 6; +pub const GIT_SUBMODULE_STATUS_WD_UNINITIALIZED: c_uint = 1 << 7; +pub const GIT_SUBMODULE_STATUS_WD_ADDED: c_uint = 1 << 8; +pub const GIT_SUBMODULE_STATUS_WD_DELETED: c_uint = 1 << 9; +pub const GIT_SUBMODULE_STATUS_WD_MODIFIED: c_uint = 1 << 10; +pub const GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED: c_uint = 1 << 11; +pub const GIT_SUBMODULE_STATUS_WD_WD_MODIFIED: c_uint = 1 << 12; +pub const GIT_SUBMODULE_STATUS_WD_UNTRACKED: c_uint = 1 << 13; + +#[repr(C)] +pub struct git_remote_head { + pub local: c_int, + pub oid: git_oid, + pub loid: git_oid, + pub name: *mut c_char, + pub symref_target: *mut c_char, +} + +pub type git_pathspec_flag_t = u32; +pub const GIT_PATHSPEC_DEFAULT: u32 = 0; +pub const GIT_PATHSPEC_IGNORE_CASE: u32 = 1 << 0; +pub const GIT_PATHSPEC_USE_CASE: u32 = 1 << 1; +pub const GIT_PATHSPEC_NO_GLOB: u32 = 1 << 2; +pub const GIT_PATHSPEC_NO_MATCH_ERROR: u32 = 1 << 3; +pub const GIT_PATHSPEC_FIND_FAILURES: u32 = 1 << 4; +pub const GIT_PATHSPEC_FAILURES_ONLY: u32 = 1 << 5; + +pub type git_diff_file_cb = extern fn(*const git_diff_delta, f32, *mut c_void) + -> c_int; +pub type git_diff_hunk_cb = extern fn(*const git_diff_delta, + *const git_diff_hunk, + *mut c_void) -> c_int; +pub type git_diff_line_cb = extern fn(*const git_diff_delta, + *const git_diff_hunk, + *const git_diff_line, + *mut c_void) -> c_int; + +#[repr(C)] +pub struct git_diff_hunk { + pub old_start: c_int, + pub old_lines: c_int, + pub new_start: c_int, + pub new_lines: c_int, + pub header_len: size_t, + pub header: [u8; 128], +} + +pub type git_diff_line_t = u8; +pub const GIT_DIFF_LINE_CONTEXT: u8 = ' ' as u8; +pub const GIT_DIFF_LINE_ADDITION: u8 = '+' as u8; +pub const GIT_DIFF_LINE_DELETION: u8 = '-' as u8; +pub const GIT_DIFF_LINE_CONTEXT_EOFNL: u8 = '=' as u8; +pub const GIT_DIFF_LINE_ADD_EOFNL: u8 = '>' as u8; +pub const GIT_DIFF_LINE_DEL_EOFNL: u8 = '<' as u8; +pub const GIT_DIFF_LINE_FILE_HDR: u8 = 'F' as u8; +pub const GIT_DIFF_LINE_HUNK_HDR: u8 = 'H' as u8; +pub const GIT_DIFF_LINE_LINE_BINARY: u8 = 'B' as u8; + +#[repr(C)] +pub struct git_diff_line { + pub origin: u8, + pub old_lineno: c_int, + pub new_lineno: c_int, + pub num_lines: c_int, + pub content_len: size_t, + pub content_offset: git_off_t, + pub content: *const u8, +} + +#[repr(C)] +pub struct git_diff_options { + pub version: c_uint, + pub flags: u32, + pub ignore_submodules: git_submodule_ignore_t, + pub pathspec: git_strarray, + pub notify_cb: git_diff_notify_cb, + pub notify_payload: *mut c_void, + pub context_lines: u32, + pub interhunk_lines: u32, + pub id_abbrev: u16, + pub max_size: git_off_t, + pub old_prefix: *const c_char, + pub new_prefix: *const c_char, +} + +#[repr(C)] +pub enum git_diff_format_t { + GIT_DIFF_FORMAT_PATCH = 1, + GIT_DIFF_FORMAT_PATCH_HEADER = 2, + GIT_DIFF_FORMAT_RAW = 3, + GIT_DIFF_FORMAT_NAME_ONLY = 4, + GIT_DIFF_FORMAT_NAME_STATUS = 5, +} + +#[repr(C)] +pub enum git_diff_stats_format_t { + GIT_DIFF_STATS_NONE = 0, + GIT_DIFF_STATS_FULL = 1 << 0, + GIT_DIFF_STATS_SHORT = 1 << 1, + GIT_DIFF_STATS_NUMBER = 1 << 2, + GIT_DIFF_STATS_INCLUDE_SUMMARY = 1 << 3, +} + +pub type git_diff_notify_cb = extern fn(*const git_diff, + *const git_diff_delta, + *const c_char, + *mut c_void) -> c_int; + +pub type git_diff_options_t = u32; +pub const GIT_DIFF_NORMAL: u32 = 0; +pub const GIT_DIFF_REVERSE: u32 = 1 << 0; +pub const GIT_DIFF_INCLUDE_IGNORED: u32 = 1 << 1; +pub const GIT_DIFF_RECURSE_IGNORED_DIRS: u32 = 1 << 2; +pub const GIT_DIFF_INCLUDE_UNTRACKED: u32 = 1 << 3; +pub const GIT_DIFF_RECURSE_UNTRACKED_DIRS: u32 = 1 << 4; +pub const GIT_DIFF_INCLUDE_UNMODIFIED: u32 = 1 << 5; +pub const GIT_DIFF_INCLUDE_TYPECHANGE: u32 = 1 << 6; +pub const GIT_DIFF_INCLUDE_TYPECHANGE_TREES: u32 = 1 << 7; +pub const GIT_DIFF_IGNORE_FILEMODE: u32 = 1 << 8; +pub const GIT_DIFF_IGNORE_SUBMODULES: u32 = 1 << 9; +pub const GIT_DIFF_IGNORE_CASE: u32 = 1 << 10; +pub const GIT_DIFF_DISABLE_PATHSPEC_MATCH: u32 = 1 << 12; +pub const GIT_DIFF_SKIP_BINARY_CHECK: u32 = 1 << 13; +pub const GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS: u32 = 1 << 14; +pub const GIT_DIFF_UPDATE_INDEX: u32 = 1 << 15; +pub const GIT_DIFF_INCLUDE_UNREADABLE: u32 = 1 << 16; +pub const GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED: u32 = 1 << 17; +pub const GIT_DIFF_FORCE_TEXT: u32 = 1 << 20; +pub const GIT_DIFF_FORCE_BINARY: u32 = 1 << 21; +pub const GIT_DIFF_IGNORE_WHITESPACE: u32 = 1 << 22; +pub const GIT_DIFF_IGNORE_WHITESPACE_CHANGE: u32 = 1 << 23; +pub const GIT_DIFF_IGNORE_WHITESPACE_EOL: u32 = 1 << 24; +pub const GIT_DIFF_SHOW_UNTRACKED_CONTENT: u32 = 1 << 25; +pub const GIT_DIFF_SHOW_UNMODIFIED: u32 = 1 << 26; +pub const GIT_DIFF_PATIENCE: u32 = 1 << 28; +pub const GIT_DIFF_MINIMAL: u32 = 1 << 29; +pub const GIT_DIFF_SHOW_BINARY: u32 = 1 << 30; + +#[repr(C)] +pub struct git_diff_find_options { + pub version: c_uint, + pub flags: u32, + pub rename_threshold: u16, + pub rename_from_rewrite_threshold: u16, + pub copy_threshold: u16, + pub break_rewrite_threshold: u16, + pub rename_limit: size_t, + pub metric: *mut git_diff_similarity_metric, +} + +#[repr(C)] +pub struct git_diff_similarity_metric { + pub file_signature: extern fn(*mut *mut c_void, + *const git_diff_file, + *const c_char, + *mut c_void) -> c_int, + pub buffer_signature: extern fn(*mut *mut c_void, + *const git_diff_file, + *const c_char, + size_t, + *mut c_void) -> c_int, + pub free_signature: extern fn(*mut c_void, *mut c_void), + pub similarity: extern fn(*mut c_int, *mut c_void, *mut c_void, + *mut c_void) -> c_int, + pub payload: *mut c_void, +} + +pub const GIT_DIFF_FIND_OPTIONS_VERSION: c_uint = 1; + +pub const GIT_DIFF_FIND_BY_CONFIG: u32 = 0; +pub const GIT_DIFF_FIND_RENAMES: u32 = 1 << 0; +pub const GIT_DIFF_FIND_RENAMES_FROM_REWRITES: u32 = 1 << 1; +pub const GIT_DIFF_FIND_COPIES: u32 = 1 << 2; +pub const GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED: u32 = 1 << 3; +pub const GIT_DIFF_FIND_REWRITES: u32 = 1 << 4; +pub const GIT_DIFF_BREAK_REWRITES: u32 = 1 << 5; +pub const GIT_DIFF_FIND_AND_BREAK_REWRITES: u32 = + GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES; +pub const GIT_DIFF_FIND_FOR_UNTRACKED: u32 = 1 << 6; +pub const GIT_DIFF_FIND_ALL: u32 = 0x0ff; +pub const GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE: u32 = 0; +pub const GIT_DIFF_FIND_IGNORE_WHITESPACE: u32 = 1 << 12; +pub const GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE: u32 = 1 << 13; +pub const GIT_DIFF_FIND_EXACT_MATCH_ONLY: u32 = 1 << 14; +pub const GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY : u32 = 1 << 15; +pub const GIT_DIFF_FIND_REMOVE_UNMODIFIED: u32 = 1 << 16; + +pub type git_transport_cb = extern fn(out: *mut *mut git_transport, + owner: *mut git_remote, + param: *mut c_void) -> c_int; + +#[repr(C)] +pub struct git_transport { + pub version: c_uint, + pub set_callbacks: extern fn(*mut git_transport, + git_transport_message_cb, + git_transport_message_cb, + git_transport_certificate_check_cb, + *mut c_void) -> c_int, + pub connect: extern fn(*mut git_transport, + *const c_char, + git_cred_acquire_cb, + *mut c_void, + c_int, c_int) -> c_int, + pub ls: extern fn(*mut *mut *const git_remote_head, + *mut size_t, + *mut git_transport) -> c_int, + pub push: extern fn(*mut git_transport, *mut git_push) -> c_int, + pub negotiate_fetch: extern fn(*mut git_transport, + *mut git_repository, + *const *const git_remote_head, + size_t) -> c_int, + pub download_pack: extern fn(*mut git_transport, + *mut git_repository, + *mut git_transfer_progress, + git_transfer_progress_cb, + *mut c_void) -> c_int, + pub is_connected: extern fn(*mut git_transport) -> c_int, + pub read_flags: extern fn(*mut git_transport, *mut c_int) -> c_int, + pub cancel: extern fn(*mut git_transport) -> c_int, + pub close: extern fn(*mut git_transport) -> c_int, + pub free: extern fn(*mut git_transport), +} + +#[repr(C)] +pub enum git_smart_service_t { + GIT_SERVICE_UPLOADPACK_LS = 1, + GIT_SERVICE_UPLOADPACK = 2, + GIT_SERVICE_RECEIVEPACK_LS = 3, + GIT_SERVICE_RECEIVEPACK = 4, +} + +#[repr(C)] +pub struct git_smart_subtransport_stream { + pub subtransport: *mut git_smart_subtransport, + pub read: extern fn(*mut git_smart_subtransport_stream, + *mut c_char, + size_t, + *mut size_t) -> c_int, + pub write: extern fn(*mut git_smart_subtransport_stream, + *const c_char, + size_t) -> c_int, + pub free: extern fn(*mut git_smart_subtransport_stream), +} + +#[repr(C)] +pub struct git_smart_subtransport { + pub action: extern fn(*mut *mut git_smart_subtransport_stream, + *mut git_smart_subtransport, + *const c_char, + git_smart_service_t) -> c_int, + pub close: extern fn(*mut git_smart_subtransport) -> c_int, + pub free: extern fn(*mut git_smart_subtransport), +} + +pub type git_smart_subtransport_cb = extern fn(*mut *mut git_smart_subtransport, + *mut git_transport, + *mut c_void) -> c_int; + +#[repr(C)] +pub struct git_smart_subtransport_definition { + pub callback: git_smart_subtransport_cb, + pub rpc: c_uint, + pub param: *mut c_void, +} + +/// Initialize openssl for the libgit2 library +#[cfg(unix)] +pub fn openssl_init() { + if !cfg!(target_os = "linux") && !cfg!(target_os = "freebsd") { return } + + // Currently, libgit2 leverages OpenSSL for SSL support when cloning + // repositories over HTTPS. This means that we're picking up an OpenSSL + // dependency on non-Windows platforms (where it has its own HTTPS + // subsystem). As a result, we need to link to OpenSSL. + // + // Now actually *linking* to OpenSSL isn't so hard. We just need to make + // sure to use pkg-config to discover any relevant system dependencies for + // differences between distributions like CentOS and Ubuntu. The actual + // trickiness comes about when we start *distributing* the resulting + // binaries. Currently Cargo is distributed in binary form as nightlies, + // which means we're distributing a binary with OpenSSL linked in. + // + // For historical reasons, the Linux nightly builder is running a CentOS + // distribution in order to have as much ABI compatibility with other + // distributions as possible. Sadly, however, this compatibility does not + // extend to OpenSSL. Currently OpenSSL has two major versions, 0.9 and 1.0, + // which are incompatible (many ABI differences). The CentOS builder we + // build on has version 1.0, as do most distributions today. Some still have + // 0.9, however. This means that if we are to distribute the binaries built + // by the CentOS machine, we would only be compatible with OpenSSL 1.0 and + // we would fail to run (a dynamic linker error at runtime) on systems with + // only 9.8 installed (hopefully). + // + // But wait, the plot thickens! Apparently CentOS has dubbed their OpenSSL + // library as `libssl.so.10`, notably the `10` is included at the end. On + // the other hand Ubuntu, for example, only distributes `libssl.so`. This + // means that the binaries created at CentOS are hard-wired to probe for a + // file called `libssl.so.10` at runtime (using the LD_LIBRARY_PATH), which + // will not be found on ubuntu. The conclusion of this is that binaries + // built on CentOS cannot be distributed to Ubuntu and run successfully. + // + // There are a number of sneaky things we could do, including, but not + // limited to: + // + // 1. Create a shim program which runs "just before" cargo runs. The + // responsibility of this shim program would be to locate `libssl.so`, + // whatever it's called, on the current system, make sure there's a + // symlink *somewhere* called `libssl.so.10`, and then set up + // LD_LIBRARY_PATH and run the actual cargo. + // + // This approach definitely seems unconventional, and is borderline + // overkill for this problem. It's also dubious if we can find a + // libssl.so reliably on the target system. + // + // 2. Somehow re-work the CentOS installation so that the linked-against + // library is called libssl.so instead of libssl.so.10 + // + // The problem with this approach is that systems with 0.9 installed will + // start to silently fail, due to also having libraries called libssl.so + // (probably symlinked under a more appropriate version). + // + // 3. Compile Cargo against both OpenSSL 1.0 *and* OpenSSL 0.9, and + // distribute both. Also make sure that the linked-against name of the + // library is `libssl.so`. At runtime we determine which version is + // installed, and we then the appropriate binary. + // + // This approach clearly has drawbacks in terms of infrastructure and + // feasibility. + // + // 4. Build a nightly of Cargo for each distribution we'd like to support. + // You would then pick the appropriate Cargo nightly to install locally. + // + // So, with all this in mind, the decision was made to *statically* link + // OpenSSL. This solves any problem of relying on a downstream OpenSSL + // version being available. This does, however, open a can of worms related + // to security issues. It's generally a good idea to dynamically link + // OpenSSL as you'll get security updates over time without having to do + // anything (the system administrator will update the local openssl + // package). By statically linking, we're forfeiting this feature. + // + // The conclusion was made it is likely appropriate for the Cargo nightlies + // to statically link OpenSSL, but highly encourage distributions and + // packagers of Cargo to dynamically link OpenSSL. Packagers are targeting + // one system and are distributing to only that system, so none of the + // problems mentioned above would arise. + // + // In order to support this, a new package was made: openssl-static-sys. + // This package currently performs a fairly simple task: + // + // 1. Run pkg-config to discover where openssl is installed. + // 2. If openssl is installed in a nonstandard location, *and* static copies + // of the libraries are available, copy them to $OUT_DIR. + // + // This library will bring in libssl.a and libcrypto.a into the local build, + // allowing them to be picked up by this crate. This allows us to configure + // our own buildbots to have pkg-config point to these local pre-built + // copies of a static OpenSSL (with very few dependencies) while allowing + // most other builds of Cargo to naturally dynamically link OpenSSL. + // + // So in summary, if you're with me so far, we've statically linked OpenSSL + // to the Cargo binary (or any binary, for that matter) and we're ready to + // distribute it to *all* linux distributions. Remember that our original + // intent for openssl was for HTTPS support, which implies that we need some + // for of CA certificate store to validate certificates. This is normally + // installed in a standard system location. + // + // Unfortunately, as one might imagine, OpenSSL is configured for where this + // standard location is at *build time*, but it often varies widely + // per-system. Consequently, it was discovered that OpenSSL will respect the + // SSL_CERT_FILE and SSL_CERT_DIR environment variables in order to assist + // in discovering the location of this file (hurray!). + // + // So, finally getting to the point, this function solely exists to support + // our static builds of OpenSSL by probing for the "standard system + // location" of certificates and setting relevant environment variable to + // point to them. + // + // Ah, and as a final note, this is only a problem on Linux, not on OS X. On + // OS X the OpenSSL binaries are stable enough that we can just rely on + // dynamic linkage (plus they have some weird modifications to OpenSSL which + // means we wouldn't want to link statically). + openssl::probe::init_ssl_cert_env_vars(); +} + +#[cfg(windows)] +pub fn openssl_init() {} + +extern { + // threads + pub fn git_libgit2_init() -> c_int; + pub fn git_libgit2_shutdown(); + + // repository + pub fn git_repository_free(repo: *mut git_repository); + pub fn git_repository_open(repo: *mut *mut git_repository, + path: *const c_char) -> c_int; + pub fn git_repository_init(repo: *mut *mut git_repository, + path: *const c_char, + is_bare: c_uint) -> c_int; + pub fn git_repository_init_ext(out: *mut *mut git_repository, + repo_path: *const c_char, + opts: *mut git_repository_init_options) + -> c_int; + pub fn git_repository_init_init_options(opts: *mut git_repository_init_options, + version: c_uint) -> c_int; + pub fn git_repository_get_namespace(repo: *mut git_repository) + -> *const c_char; + pub fn git_repository_head(out: *mut *mut git_reference, + repo: *mut git_repository) -> c_int; + pub fn git_repository_set_head(repo: *mut git_repository, + refname: *const c_char) -> c_int; + pub fn git_repository_set_head_detached(repo: *mut git_repository, + commitish: *const git_oid) -> c_int; + pub fn git_repository_is_bare(repo: *mut git_repository) -> c_int; + pub fn git_repository_is_empty(repo: *mut git_repository) -> c_int; + pub fn git_repository_is_shallow(repo: *mut git_repository) -> c_int; + pub fn git_repository_path(repo: *mut git_repository) -> *const c_char; + pub fn git_repository_state(repo: *mut git_repository) -> c_int; + pub fn git_repository_workdir(repo: *mut git_repository) -> *const c_char; + pub fn git_repository_index(out: *mut *mut git_index, + repo: *mut git_repository) -> c_int; + pub fn git_repository_config(out: *mut *mut git_config, + repo: *mut git_repository) -> c_int; + pub fn git_repository_config_snapshot(out: *mut *mut git_config, + repo: *mut git_repository) -> c_int; + pub fn git_repository_discover(out: *mut git_buf, + start_path: *const c_char, + across_fs: c_int, + ceiling_dirs: *const c_char) -> c_int; + + // revparse + pub fn git_revparse(revspec: *mut git_revspec, + repo: *mut git_repository, + spec: *const c_char) -> c_int; + pub fn git_revparse_single(out: *mut *mut git_object, + repo: *mut git_repository, + spec: *const c_char) -> c_int; + pub fn git_revparse_ext(object_out: *mut *mut git_object, + reference_out: *mut *mut git_reference, + repo: *mut git_repository, + spec: *const c_char) -> c_int; + + // object + pub fn git_object_dup(dest: *mut *mut git_object, + source: *mut git_object) -> c_int; + pub fn git_object_id(obj: *const git_object) -> *const git_oid; + pub fn git_object_free(object: *mut git_object); + pub fn git_object_lookup(dest: *mut *mut git_object, + repo: *mut git_repository, + id: *const git_oid, + kind: git_otype) -> c_int; + pub fn git_object_type(obj: *const git_object) -> git_otype; + pub fn git_object_peel(peeled: *mut *mut git_object, + object: *const git_object, + target_type: git_otype) -> c_int; + pub fn git_object_short_id(out: *mut git_buf, + obj: *const git_object) -> c_int; + pub fn git_object_type2string(kind: git_otype) -> *const c_char; + pub fn git_object_string2type(s: *const c_char) -> git_otype; + pub fn git_object_typeisloose(kind: git_otype) -> c_int; + + // oid + pub fn git_oid_fromraw(out: *mut git_oid, raw: *const c_uchar); + pub fn git_oid_fromstrn(out: *mut git_oid, str: *const c_char, + len: size_t) -> c_int; + pub fn git_oid_tostr(out: *mut c_char, n: size_t, + id: *const git_oid) -> *mut c_char; + pub fn git_oid_cmp(a: *const git_oid, b: *const git_oid) -> c_int; + pub fn git_oid_equal(a: *const git_oid, b: *const git_oid) -> c_int; + pub fn git_oid_streq(id: *const git_oid, str: *const c_char) -> c_int; + pub fn git_oid_iszero(id: *const git_oid) -> c_int; + + // giterr + pub fn giterr_last() -> *const git_error; + pub fn giterr_clear(); + pub fn giterr_detach(cpy: *mut git_error) -> c_int; + pub fn giterr_set_str(error_class: c_int, string: *const c_char); + + // remote + pub fn git_remote_create(out: *mut *mut git_remote, + repo: *mut git_repository, + name: *const c_char, + url: *const c_char) -> c_int; + pub fn git_remote_lookup(out: *mut *mut git_remote, + repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_remote_create_anonymous(out: *mut *mut git_remote, + repo: *mut git_repository, + url: *const c_char, + fetch: *const c_char) -> c_int; + pub fn git_remote_delete(repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_remote_free(remote: *mut git_remote); + pub fn git_remote_name(remote: *const git_remote) -> *const c_char; + pub fn git_remote_pushurl(remote: *const git_remote) -> *const c_char; + pub fn git_remote_refspec_count(remote: *const git_remote) -> size_t; + pub fn git_remote_url(remote: *const git_remote) -> *const c_char; + pub fn git_remote_connect(remote: *mut git_remote, + dir: git_direction) -> c_int; + pub fn git_remote_connected(remote: *mut git_remote) -> c_int; + pub fn git_remote_disconnect(remote: *mut git_remote); + pub fn git_remote_save(remote: *const git_remote) -> c_int; + pub fn git_remote_add_fetch(remote: *mut git_remote, + refspec: *const c_char) -> c_int; + pub fn git_remote_add_push(remote: *mut git_remote, + refspec: *const c_char) -> c_int; + pub fn git_remote_clear_refspecs(remote: *mut git_remote); + pub fn git_remote_download(remote: *mut git_remote, + refspecs: *const git_strarray) -> c_int; + pub fn git_remote_stop(remote: *mut git_remote); + pub fn git_remote_dup(dest: *mut *mut git_remote, + source: *mut git_remote) -> c_int; + pub fn git_remote_get_fetch_refspecs(array: *mut git_strarray, + remote: *const git_remote) -> c_int; + pub fn git_remote_get_refspec(remote: *const git_remote, + n: size_t) -> *const git_refspec; + pub fn git_remote_is_valid_name(remote_name: *const c_char) -> c_int; + pub fn git_remote_list(out: *mut git_strarray, + repo: *mut git_repository) -> c_int; + pub fn git_remote_rename(problems: *mut git_strarray, + repo: *mut git_repository, + name: *const c_char, + new_name: *const c_char) -> c_int; + pub fn git_remote_fetch(remote: *mut git_remote, + refspecs: *const git_strarray, + reflog_message: *const c_char) -> c_int; + pub fn git_remote_update_tips(remote: *mut git_remote, + reflog_message: *const c_char) -> c_int; + pub fn git_remote_update_fetchhead(remote: *mut git_remote) -> c_int; + pub fn git_remote_set_url(remote: *mut git_remote, + url: *const c_char) -> c_int; + pub fn git_remote_set_pushurl(remote: *mut git_remote, + pushurl: *const c_char) -> c_int; + pub fn git_remote_set_update_fetchhead(remote: *mut git_remote, + update: c_int); + pub fn git_remote_set_fetch_refspecs(remote: *mut git_remote, + array: *mut git_strarray) -> c_int; + pub fn git_remote_set_push_refspecs(remote: *mut git_remote, + array: *mut git_strarray) -> c_int; + pub fn git_remote_set_callbacks(remote: *mut git_remote, + callbacks: *const git_remote_callbacks) + -> c_int; + pub fn git_remote_init_callbacks(opts: *mut git_remote_callbacks, + version: c_uint) -> c_int; + pub fn git_remote_stats(remote: *mut git_remote) + -> *const git_transfer_progress; + pub fn git_remote_ls(out: *mut *mut *const git_remote_head, + size: *mut size_t, + remote: *mut git_remote) -> c_int; + + // refspec + pub fn git_refspec_direction(spec: *const git_refspec) -> git_direction; + pub fn git_refspec_dst(spec: *const git_refspec) -> *const c_char; + pub fn git_refspec_dst_matches(spec: *const git_refspec, + refname: *const c_char) -> c_int; + pub fn git_refspec_src(spec: *const git_refspec) -> *const c_char; + pub fn git_refspec_src_matches(spec: *const git_refspec, + refname: *const c_char) -> c_int; + pub fn git_refspec_force(spec: *const git_refspec) -> c_int; + pub fn git_refspec_string(spec: *const git_refspec) -> *const c_char; + + // strarray + pub fn git_strarray_free(array: *mut git_strarray); + + // signature + pub fn git_signature_default(out: *mut *mut git_signature, + repo: *mut git_repository) -> c_int; + pub fn git_signature_free(sig: *mut git_signature); + pub fn git_signature_new(out: *mut *mut git_signature, + name: *const c_char, + email: *const c_char, + time: git_time_t, + offset: c_int) -> c_int; + pub fn git_signature_now(out: *mut *mut git_signature, + name: *const c_char, + email: *const c_char) -> c_int; + pub fn git_signature_dup(dest: *mut *mut git_signature, + sig: *const git_signature) -> c_int; + + // status + pub fn git_status_list_new(out: *mut *mut git_status_list, + repo: *mut git_repository, + options: *const git_status_options) -> c_int; + pub fn git_status_list_entrycount(list: *mut git_status_list) -> size_t; + pub fn git_status_byindex(statuslist: *mut git_status_list, + idx: size_t) -> *const git_status_entry; + pub fn git_status_list_free(list: *mut git_status_list); + pub fn git_status_init_options(opts: *mut git_status_options, + version: c_uint) -> c_int; + pub fn git_status_file(status_flags: *mut c_uint, + repo: *mut git_repository, + path: *const c_char) -> c_int; + pub fn git_status_should_ignore(ignored: *mut c_int, + repo: *mut git_repository, + path: *const c_char) -> c_int; + + // clone + pub fn git_clone(out: *mut *mut git_repository, + url: *const c_char, + local_path: *const c_char, + options: *const git_clone_options) -> c_int; + pub fn git_clone_init_options(opts: *mut git_clone_options, + version: c_uint) -> c_int; + + // reset + pub fn git_reset(repo: *mut git_repository, + target: *mut git_object, + reset_type: git_reset_t, + checkout_opts: *mut git_checkout_options) -> c_int; + pub fn git_reset_default(repo: *mut git_repository, + target: *mut git_object, + pathspecs: *mut git_strarray) -> c_int; + + // reference + pub fn git_reference_cmp(ref1: *const git_reference, + ref2: *const git_reference) -> c_int; + pub fn git_reference_delete(r: *mut git_reference) -> c_int; + pub fn git_reference_free(r: *mut git_reference); + pub fn git_reference_is_branch(r: *const git_reference) -> c_int; + pub fn git_reference_is_note(r: *const git_reference) -> c_int; + pub fn git_reference_is_remote(r: *const git_reference) -> c_int; + pub fn git_reference_is_tag(r: *const git_reference) -> c_int; + pub fn git_reference_is_valid_name(name: *const c_char) -> c_int; + pub fn git_reference_lookup(out: *mut *mut git_reference, + repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_reference_name(r: *const git_reference) -> *const c_char; + pub fn git_reference_name_to_id(out: *mut git_oid, + repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_reference_peel(out: *mut *mut git_object, + r: *const git_reference, + otype: git_otype) -> c_int; + pub fn git_reference_rename(new_ref: *mut *mut git_reference, + r: *mut git_reference, + new_name: *const c_char, + force: c_int, + log_message: *const c_char) -> c_int; + pub fn git_reference_resolve(out: *mut *mut git_reference, + r: *const git_reference) -> c_int; + pub fn git_reference_shorthand(r: *const git_reference) -> *const c_char; + pub fn git_reference_symbolic_target(r: *const git_reference) -> *const c_char; + pub fn git_reference_target(r: *const git_reference) -> *const git_oid; + pub fn git_reference_target_peel(r: *const git_reference) -> *const git_oid; + pub fn git_reference_type(r: *const git_reference) -> git_ref_t; + pub fn git_reference_iterator_new(out: *mut *mut git_reference_iterator, + repo: *mut git_repository) -> c_int; + pub fn git_reference_iterator_glob_new(out: *mut *mut git_reference_iterator, + repo: *mut git_repository, + glob: *const c_char) -> c_int; + pub fn git_reference_iterator_free(iter: *mut git_reference_iterator); + pub fn git_reference_next(out: *mut *mut git_reference, + iter: *mut git_reference_iterator) -> c_int; + pub fn git_reference_next_name(out: *mut *const c_char, + iter: *mut git_reference_iterator) -> c_int; + pub fn git_reference_create(out: *mut *mut git_reference, + repo: *mut git_repository, + name: *const c_char, + id: *const git_oid, + force: c_int, + log_message: *const c_char) -> c_int; + pub fn git_reference_symbolic_create(out: *mut *mut git_reference, + repo: *mut git_repository, + name: *const c_char, + target: *const c_char, + force: c_int, + log_message: *const c_char) -> c_int; + + // submodules + pub fn git_submodule_add_finalize(submodule: *mut git_submodule) -> c_int; + pub fn git_submodule_add_setup(submodule: *mut *mut git_submodule, + repo: *mut git_repository, + url: *const c_char, + path: *const c_char, + use_gitlink: c_int) -> c_int; + pub fn git_submodule_add_to_index(submodule: *mut git_submodule, + write_index: c_int) -> c_int; + pub fn git_submodule_branch(submodule: *mut git_submodule) -> *const c_char; + pub fn git_submodule_foreach(repo: *mut git_repository, + callback: extern fn(*mut git_submodule, + *const c_char, + *mut c_void) -> c_int, + payload: *mut c_void) -> c_int; + pub fn git_submodule_free(submodule: *mut git_submodule); + pub fn git_submodule_head_id(submodule: *mut git_submodule) -> *const git_oid; + pub fn git_submodule_index_id(submodule: *mut git_submodule) -> *const git_oid; + pub fn git_submodule_init(submodule: *mut git_submodule, + overwrite: c_int) -> c_int; + pub fn git_submodule_location(status: *mut c_uint, + submodule: *mut git_submodule) -> c_int; + pub fn git_submodule_lookup(out: *mut *mut git_submodule, + repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_submodule_name(submodule: *mut git_submodule) -> *const c_char; + pub fn git_submodule_open(repo: *mut *mut git_repository, + submodule: *mut git_submodule) -> c_int; + pub fn git_submodule_path(submodule: *mut git_submodule) -> *const c_char; + pub fn git_submodule_reload(submodule: *mut git_submodule, + force: c_int) -> c_int; + pub fn git_submodule_reload_all(repo: *mut git_repository, + force: c_int) -> c_int; + pub fn git_submodule_save(submodule: *mut git_submodule) -> c_int; + pub fn git_submodule_set_ignore(submodule: *mut git_submodule, + ignore: git_submodule_ignore_t) + -> git_submodule_ignore_t; + pub fn git_submodule_set_update(submodule: *mut git_submodule, + update: git_submodule_update_t) + -> git_submodule_update_t; + pub fn git_submodule_set_url(submodule: *mut git_submodule, + url: *const c_char) -> c_int; + pub fn git_submodule_sync(submodule: *mut git_submodule) -> c_int; + pub fn git_submodule_update_strategy(submodule: *mut git_submodule) + -> git_submodule_update_t; + // pub fn git_submodule_update(submodule: *mut git_submodule, + // init: c_int, + // options: *mut git_submodule_update_options) + // -> c_int; + pub fn git_submodule_url(submodule: *mut git_submodule) -> *const c_char; + pub fn git_submodule_wd_id(submodule: *mut git_submodule) -> *const git_oid; + pub fn git_submodule_status(status: *mut c_uint, + submodule: *mut git_submodule) -> c_int; + + // blob + pub fn git_blob_free(blob: *mut git_blob); + pub fn git_blob_id(blob: *const git_blob) -> *const git_oid; + pub fn git_blob_is_binary(blob: *const git_blob) -> c_int; + pub fn git_blob_lookup(blob: *mut *mut git_blob, repo: *mut git_repository, + id: *const git_oid) -> c_int; + pub fn git_blob_lookup_prefix(blob: *mut *mut git_blob, + repo: *mut git_repository, + id: *const git_oid, + len: size_t) -> c_int; + pub fn git_blob_rawcontent(blob: *const git_blob) -> *const c_void; + pub fn git_blob_rawsize(blob: *const git_blob) -> git_off_t; + pub fn git_blob_create_frombuffer(id: *mut git_oid, + repo: *mut git_repository, + buffer: *const c_void, + len: size_t) -> c_int; + pub fn git_blob_create_fromdisk(id: *mut git_oid, + repo: *mut git_repository, + path: *const c_char) -> c_int; + pub fn git_blob_create_fromworkdir(id: *mut git_oid, + repo: *mut git_repository, + relative_path: *const c_char) -> c_int; + + // tree + pub fn git_tree_entry_byid(tree: *const git_tree, + id: *const git_oid) -> *const git_tree_entry; + pub fn git_tree_entry_byindex(tree: *const git_tree, + idx: size_t) -> *const git_tree_entry; + pub fn git_tree_entry_byname(tree: *const git_tree, + filename: *const c_char) -> *const git_tree_entry; + pub fn git_tree_entry_bypath(out: *mut *mut git_tree_entry, + tree: *const git_tree, + filename: *const c_char) -> c_int; + pub fn git_tree_entry_cmp(e1: *const git_tree_entry, + e2: *const git_tree_entry) -> c_int; + pub fn git_tree_entry_dup(dest: *mut *mut git_tree_entry, + src: *const git_tree_entry) -> c_int; + pub fn git_tree_entry_filemode(entry: *const git_tree_entry) -> git_filemode_t; + pub fn git_tree_entry_filemode_raw(entry: *const git_tree_entry) -> git_filemode_t; + pub fn git_tree_entry_free(entry: *mut git_tree_entry); + pub fn git_tree_entry_id(entry: *const git_tree_entry) -> *const git_oid; + pub fn git_tree_entry_name(entry: *const git_tree_entry) -> *const c_char; + pub fn git_tree_entry_to_object(out: *mut *mut git_object, + repo: *mut git_repository, + entry: *const git_tree_entry) -> c_int; + pub fn git_tree_entry_type(entry: *const git_tree_entry) -> git_otype; + pub fn git_tree_entrycount(tree: *const git_tree) -> size_t; + pub fn git_tree_free(tree: *mut git_tree); + pub fn git_tree_id(tree: *const git_tree) -> *const git_oid; + pub fn git_tree_lookup(tree: *mut *mut git_tree, + repo: *mut git_repository, + id: *const git_oid) -> c_int; + pub fn git_tree_walk(tree: *const git_tree, + mode: git_treewalk_mode, + callback: git_treewalk_cb, + payload: *mut c_void) -> c_int; + + // buf + pub fn git_buf_free(buffer: *mut git_buf); + pub fn git_buf_grow(buffer: *mut git_buf, target_size: size_t) -> c_int; + pub fn git_buf_set(buffer: *mut git_buf, data: *const c_void, + datalen: size_t) -> c_int; + + // commit + pub fn git_commit_author(commit: *const git_commit) -> *const git_signature; + pub fn git_commit_committer(commit: *const git_commit) -> *const git_signature; + pub fn git_commit_free(commit: *mut git_commit); + pub fn git_commit_id(commit: *const git_commit) -> *const git_oid; + pub fn git_commit_lookup(commit: *mut *mut git_commit, + repo: *mut git_repository, + id: *const git_oid) -> c_int; + pub fn git_commit_message(commit: *const git_commit) -> *const c_char; + pub fn git_commit_message_encoding(commit: *const git_commit) -> *const c_char; + pub fn git_commit_message_raw(commit: *const git_commit) -> *const c_char; + pub fn git_commit_nth_gen_ancestor(commit: *mut *mut git_commit, + commit: *const git_commit, + n: c_uint) -> c_int; + pub fn git_commit_parent(out: *mut *mut git_commit, + commit: *const git_commit, + n: c_uint) -> c_int; + pub fn git_commit_parent_id(commit: *const git_commit, + n: c_uint) -> *const git_oid; + pub fn git_commit_parentcount(commit: *const git_commit) -> c_uint; + pub fn git_commit_raw_header(commit: *const git_commit) -> *const c_char; + pub fn git_commit_summary(commit: *mut git_commit) -> *const c_char; + pub fn git_commit_time(commit: *const git_commit) -> git_time_t; + pub fn git_commit_time_offset(commit: *const git_commit) -> c_int; + pub fn git_commit_tree(tree_out: *mut *mut git_tree, + commit: *const git_commit) -> c_int; + pub fn git_commit_tree_id(commit: *const git_commit) -> *const git_oid; + pub fn git_commit_amend(id: *mut git_oid, + commit_to_amend: *const git_commit, + update_ref: *const c_char, + author: *const git_signature, + committer: *const git_signature, + message_encoding: *const c_char, + message: *const c_char, + tree: *const git_tree) -> c_int; + pub fn git_commit_create(id: *mut git_oid, + repo: *mut git_repository, + update_ref: *const c_char, + author: *const git_signature, + committer: *const git_signature, + message_encoding: *const c_char, + message: *const c_char, + tree: *const git_tree, + parent_count: size_t, + parents: *const *const git_commit) -> c_int; + + // branch + pub fn git_branch_create(out: *mut *mut git_reference, + repo: *mut git_repository, + branch_name: *const c_char, + target: *const git_commit, + force: c_int) -> c_int; + pub fn git_branch_delete(branch: *mut git_reference) -> c_int; + pub fn git_branch_is_head(branch: *const git_reference) -> c_int; + pub fn git_branch_iterator_free(iter: *mut git_branch_iterator); + pub fn git_branch_iterator_new(iter: *mut *mut git_branch_iterator, + repo: *mut git_repository, + list_flags: git_branch_t) -> c_int; + pub fn git_branch_lookup(out: *mut *mut git_reference, + repo: *mut git_repository, + branch_name: *const c_char, + branch_type: git_branch_t) -> c_int; + pub fn git_branch_move(out: *mut *mut git_reference, + branch: *mut git_reference, + new_branch_name: *const c_char, + force: c_int) -> c_int; + pub fn git_branch_name(out: *mut *const c_char, + branch: *const git_reference) -> c_int; + pub fn git_branch_next(out: *mut *mut git_reference, + out_type: *mut git_branch_t, + iter: *mut git_branch_iterator) -> c_int; + pub fn git_branch_set_upstream(branch: *mut git_reference, + upstream_name: *const c_char) -> c_int; + pub fn git_branch_upstream(out: *mut *mut git_reference, + branch: *const git_reference) -> c_int; + + // index + pub fn git_index_add(index: *mut git_index, + entry: *const git_index_entry) -> c_int; + pub fn git_index_add_all(index: *mut git_index, + pathspec: *const git_strarray, + flags: c_uint, + callback: Option, + payload: *mut c_void) -> c_int; + pub fn git_index_add_bypath(index: *mut git_index, + path: *const c_char) -> c_int; + pub fn git_index_clear(index: *mut git_index) -> c_int; + pub fn git_index_entry_stage(entry: *const git_index_entry) -> c_int; + pub fn git_index_entrycount(entry: *const git_index) -> size_t; + pub fn git_index_find(at_pos: *mut size_t, + index: *mut git_index, + path: *const c_char) -> c_int; + pub fn git_index_free(index: *mut git_index); + pub fn git_index_get_byindex(index: *mut git_index, + n: size_t) -> *const git_index_entry; + pub fn git_index_get_bypath(index: *mut git_index, + path: *const c_char, + stage: c_int) -> *const git_index_entry; + pub fn git_index_new(index: *mut *mut git_index) -> c_int; + pub fn git_index_open(index: *mut *mut git_index, + index_path: *const c_char) -> c_int; + pub fn git_index_path(index: *const git_index) -> *const c_char; + pub fn git_index_read(index: *mut git_index, force: c_int) -> c_int; + pub fn git_index_read_tree(index: *mut git_index, + tree: *const git_tree) -> c_int; + pub fn git_index_remove(index: *mut git_index, + path: *const c_char, + stage: c_int) -> c_int; + pub fn git_index_remove_all(index: *mut git_index, + pathspec: *const git_strarray, + callback: Option, + payload: *mut c_void) -> c_int; + pub fn git_index_remove_bypath(index: *mut git_index, + path: *const c_char) -> c_int; + pub fn git_index_remove_directory(index: *mut git_index, + dir: *const c_char, + stage: c_int) -> c_int; + pub fn git_index_update_all(index: *mut git_index, + pathspec: *const git_strarray, + callback: Option, + payload: *mut c_void) -> c_int; + pub fn git_index_write(index: *mut git_index) -> c_int; + pub fn git_index_write_tree(out: *mut git_oid, + index: *mut git_index) -> c_int; + pub fn git_index_write_tree_to(out: *mut git_oid, + index: *mut git_index, + repo: *mut git_repository) -> c_int; + + // config + pub fn git_config_add_file_ondisk(cfg: *mut git_config, + path: *const c_char, + level: git_config_level_t, + force: c_int) -> c_int; + pub fn git_config_delete_entry(cfg: *mut git_config, + name: *const c_char) -> c_int; + pub fn git_config_delete_multivar(cfg: *mut git_config, + name: *const c_char, + regexp: *const c_char) -> c_int; + pub fn git_config_find_global(out: *mut git_buf) -> c_int; + pub fn git_config_find_system(out: *mut git_buf) -> c_int; + pub fn git_config_find_xdg(out: *mut git_buf) -> c_int; + pub fn git_config_free(cfg: *mut git_config); + pub fn git_config_get_bool(out: *mut c_int, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_get_entry(out: *mut *mut git_config_entry, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_get_int32(out: *mut i32, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_get_int64(out: *mut i64, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_get_string(out: *mut *const c_char, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_get_string_buf(out: *mut git_buf, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_get_path(out: *mut git_buf, + cfg: *const git_config, + name: *const c_char) -> c_int; + pub fn git_config_iterator_free(iter: *mut git_config_iterator); + pub fn git_config_iterator_glob_new(out: *mut *mut git_config_iterator, + cfg: *const git_config, + regexp: *const c_char) -> c_int; + pub fn git_config_iterator_new(out: *mut *mut git_config_iterator, + cfg: *const git_config) -> c_int; + pub fn git_config_new(out: *mut *mut git_config) -> c_int; + pub fn git_config_next(entry: *mut *mut git_config_entry, + iter: *mut git_config_iterator) -> c_int; + pub fn git_config_open_default(out: *mut *mut git_config) -> c_int; + pub fn git_config_open_global(out: *mut *mut git_config, + config: *mut git_config) -> c_int; + pub fn git_config_open_level(out: *mut *mut git_config, + parent: *const git_config, + level: git_config_level_t) -> c_int; + pub fn git_config_open_ondisk(out: *mut *mut git_config, + path: *const c_char) -> c_int; + pub fn git_config_parse_bool(out: *mut c_int, + value: *const c_char) -> c_int; + pub fn git_config_parse_int32(out: *mut i32, + value: *const c_char) -> c_int; + pub fn git_config_parse_int64(out: *mut i64, + value: *const c_char) -> c_int; + pub fn git_config_set_bool(cfg: *mut git_config, + name: *const c_char, + value: c_int) -> c_int; + pub fn git_config_set_int32(cfg: *mut git_config, + name: *const c_char, + value: i32) -> c_int; + pub fn git_config_set_int64(cfg: *mut git_config, + name: *const c_char, + value: i64) -> c_int; + pub fn git_config_set_string(cfg: *mut git_config, + name: *const c_char, + value: *const c_char) -> c_int; + pub fn git_config_snapshot(out: *mut *mut git_config, + config: *mut git_config) -> c_int; + pub fn git_config_entry_free(entry: *mut git_config_entry); + + // cred + pub fn git_cred_default_new(out: *mut *mut git_cred) -> c_int; + pub fn git_cred_has_username(cred: *mut git_cred) -> c_int; + pub fn git_cred_ssh_custom_new(out: *mut *mut git_cred, + username: *const c_char, + publickey: *const c_char, + publickey_len: size_t, + sign_callback: git_cred_sign_callback, + payload: *mut c_void) -> c_int; + pub fn git_cred_ssh_interactive_new(out: *mut *mut git_cred, + username: *const c_char, + prompt_callback: git_cred_ssh_interactive_callback, + payload: *mut c_void) -> c_int; + pub fn git_cred_ssh_key_from_agent(out: *mut *mut git_cred, + username: *const c_char) -> c_int; + pub fn git_cred_ssh_key_new(out: *mut *mut git_cred, + username: *const c_char, + publickey: *const c_char, + privatekey: *const c_char, + passphrase: *const c_char) -> c_int; + pub fn git_cred_userpass(cred: *mut *mut git_cred, + url: *const c_char, + user_from_url: *const c_char, + allowed_types: c_uint, + payload: *mut c_void) -> c_int; + pub fn git_cred_userpass_plaintext_new(out: *mut *mut git_cred, + username: *const c_char, + password: *const c_char) -> c_int; + pub fn git_cred_username_new(cred: *mut *mut git_cred, + username: *const c_char) -> c_int; + + // push + pub fn git_push_add_refspec(push: *mut git_push, + refspec: *const c_char) -> c_int; + pub fn git_push_finish(push: *mut git_push) -> c_int; + pub fn git_push_free(push: *mut git_push); + pub fn git_push_init_options(opts: *mut git_push_options, + version: c_uint) -> c_int; + pub fn git_push_new(out: *mut *mut git_push, + remote: *mut git_remote) -> c_int; + pub fn git_push_set_options(push: *mut git_push, + opts: *const git_push_options) -> c_int; + pub fn git_push_update_tips(push: *mut git_push, + signature: *const git_signature, + reflog_message: *const c_char) -> c_int; + pub fn git_push_status_foreach(push: *mut git_push, + cb: extern fn(*const c_char, + *const c_char, + *mut c_void) -> c_int, + data: *mut c_void) -> c_int; + + // tags + pub fn git_tag_annotation_create(oid: *mut git_oid, + repo: *mut git_repository, + tag_name: *const c_char, + target: *const git_object, + tagger: *const git_signature, + message: *const c_char) -> c_int; + pub fn git_tag_create(oid: *mut git_oid, + repo: *mut git_repository, + tag_name: *const c_char, + target: *const git_object, + tagger: *const git_signature, + message: *const c_char, + force: c_int) -> c_int; + pub fn git_tag_create_frombuffer(oid: *mut git_oid, + repo: *mut git_repository, + buffer: *const c_char, + force: c_int) -> c_int; + pub fn git_tag_create_lightweight(oid: *mut git_oid, + repo: *mut git_repository, + tag_name: *const c_char, + target: *const git_object, + force: c_int) -> c_int; + pub fn git_tag_delete(repo: *mut git_repository, + tag_name: *const c_char) -> c_int; + pub fn git_tag_foreach(repo: *mut git_repository, + callback: git_tag_foreach_cb, + payload: *mut c_void) -> c_int; + pub fn git_tag_free(tag: *mut git_tag); + pub fn git_tag_id(tag: *const git_tag) -> *const git_oid; + pub fn git_tag_list(tag_names: *mut git_strarray, + repo: *mut git_repository) -> c_int; + pub fn git_tag_list_match(tag_names: *mut git_strarray, + pattern: *const c_char, + repo: *mut git_repository) -> c_int; + pub fn git_tag_lookup(out: *mut *mut git_tag, + repo: *mut git_repository, + id: *const git_oid) -> c_int; + pub fn git_tag_lookup_prefix(out: *mut *mut git_tag, + repo: *mut git_repository, + id: *const git_oid, + len: size_t) -> c_int; + pub fn git_tag_message(tag: *const git_tag) -> *const c_char; + pub fn git_tag_name(tag: *const git_tag) -> *const c_char; + pub fn git_tag_peel(tag_target_out: *mut *mut git_object, + tag: *const git_tag) -> c_int; + pub fn git_tag_tagger(tag: *const git_tag) -> *const git_signature; + pub fn git_tag_target(target_out: *mut *mut git_object, + tag: *const git_tag) -> c_int; + pub fn git_tag_target_id(tag: *const git_tag) -> *const git_oid; + pub fn git_tag_target_type(tag: *const git_tag) -> git_otype; + + // checkout + pub fn git_checkout_head(repo: *mut git_repository, + opts: *const git_checkout_options) -> c_int; + pub fn git_checkout_index(repo: *mut git_repository, + index: *mut git_index, + opts: *const git_checkout_options) -> c_int; + pub fn git_checkout_tree(repo: *mut git_repository, + treeish: *const git_object, + opts: *const git_checkout_options) -> c_int; + pub fn git_checkout_init_options(opts: *mut git_checkout_options, + version: c_uint) -> c_int; + + // notes + pub fn git_note_author(note: *const git_note) -> *const git_signature; + pub fn git_note_committer(note: *const git_note) -> *const git_signature; + pub fn git_note_create(out: *mut git_oid, + repo: *mut git_repository, + notes_ref: *const c_char, + author: *const git_signature, + committer: *const git_signature, + oid: *const git_oid, + note: *const c_char, + force: c_int) -> c_int; + pub fn git_note_default_ref(out: *mut git_buf, + repo: *mut git_repository) -> c_int; + pub fn git_note_free(note: *mut git_note); + pub fn git_note_id(note: *const git_note) -> *const git_oid; + pub fn git_note_iterator_free(it: *mut git_note_iterator); + pub fn git_note_iterator_new(out: *mut *mut git_note_iterator, + repo: *mut git_repository, + notes_ref: *const c_char) -> c_int; + pub fn git_note_message(note: *const git_note) -> *const c_char; + pub fn git_note_next(note_id: *mut git_oid, + annotated_id: *mut git_oid, + it: *mut git_note_iterator) -> c_int; + pub fn git_note_read(out: *mut *mut git_note, + repo: *mut git_repository, + notes_ref: *const c_char, + oid: *const git_oid) -> c_int; + pub fn git_note_remove(repo: *mut git_repository, + notes_ref: *const c_char, + author: *const git_signature, + committer: *const git_signature, + oid: *const git_oid) -> c_int; + + // blame + pub fn git_blame_file(out: *mut *mut git_blame, + repo: *mut git_repository, + path: *const c_char, + options: *mut git_blame_options) -> c_int; + pub fn git_blame_free(blame: *mut git_blame); + + pub fn git_blame_init_options(opts: *mut git_blame_options, + version: c_uint) -> c_int; + pub fn git_blame_get_hunk_count(blame: *mut git_blame) -> u32; + + pub fn git_blame_get_hunk_byline(blame: *mut git_blame, + lineno: u32) -> *const git_blame_hunk; + pub fn git_blame_get_hunk_byindex(blame: *mut git_blame, + index: u32) -> *const git_blame_hunk; + + // revwalk + pub fn git_revwalk_new(out: *mut *mut git_revwalk, + repo: *mut git_repository) -> c_int; + pub fn git_revwalk_free(walk: *mut git_revwalk); + + pub fn git_revwalk_reset(walk: *mut git_revwalk); + + pub fn git_revwalk_sorting(walk: *mut git_revwalk, sort_mode: c_uint); + + pub fn git_revwalk_push_head(walk: *mut git_revwalk) -> c_int; + pub fn git_revwalk_push(walk: *mut git_revwalk, + oid: *const git_oid) -> c_int; + pub fn git_revwalk_push_ref(walk: *mut git_revwalk, + refname: *const c_char) -> c_int; + pub fn git_revwalk_push_glob(walk: *mut git_revwalk, + glob: *const c_char) -> c_int; + pub fn git_revwalk_push_range(walk: *mut git_revwalk, + range: *const c_char) -> c_int; + pub fn git_revwalk_simplify_first_parent(walk: *mut git_revwalk); + + pub fn git_revwalk_hide_head(walk: *mut git_revwalk) -> c_int; + pub fn git_revwalk_hide(walk: *mut git_revwalk, + oid: *const git_oid) -> c_int; + pub fn git_revwalk_hide_ref(walk: *mut git_revwalk, + refname: *const c_char) -> c_int; + pub fn git_revwalk_hide_glob(walk: *mut git_revwalk, + refname: *const c_char) -> c_int; + + pub fn git_revwalk_next(out: *mut git_oid, walk: *mut git_revwalk) -> c_int; + + // merge + pub fn git_merge_base(out: *mut git_oid, + repo: *mut git_repository, + one: *const git_oid, + two: *const git_oid) -> c_int; + + // pathspec + pub fn git_pathspec_free(ps: *mut git_pathspec); + pub fn git_pathspec_match_diff(out: *mut *mut git_pathspec_match_list, + diff: *mut git_diff, + flags: u32, + ps: *mut git_pathspec) -> c_int; + pub fn git_pathspec_match_index(out: *mut *mut git_pathspec_match_list, + index: *mut git_index, + flags: u32, + ps: *mut git_pathspec) -> c_int; + pub fn git_pathspec_match_list_diff_entry(m: *const git_pathspec_match_list, + pos: size_t) -> *const git_diff_delta; + pub fn git_pathspec_match_list_entry(m: *const git_pathspec_match_list, + pos: size_t) -> *const c_char; + pub fn git_pathspec_match_list_entrycount(m: *const git_pathspec_match_list) + -> size_t; + pub fn git_pathspec_match_list_failed_entry(m: *const git_pathspec_match_list, + pos: size_t) -> *const c_char; + pub fn git_pathspec_match_list_failed_entrycount( + m: *const git_pathspec_match_list) -> size_t; + pub fn git_pathspec_match_list_free(m: *const git_pathspec_match_list); + pub fn git_pathspec_match_tree(out: *mut *mut git_pathspec_match_list, + tree: *mut git_tree, + flags: u32, + ps: *mut git_pathspec) -> c_int; + pub fn git_pathspec_match_workdir(out: *mut *mut git_pathspec_match_list, + repo: *mut git_repository, + flags: u32, + ps: *mut git_pathspec) -> c_int; + pub fn git_pathspec_matches_path(ps: *const git_pathspec, + flags: u32, + path: *const c_char) -> c_int; + pub fn git_pathspec_new(out: *mut *mut git_pathspec, + pathspec: *const git_strarray) -> c_int; + + // diff + pub fn git_diff_blob_to_buffer(old_blob: *const git_blob, + old_as_path: *const c_char, + buffer: *const c_char, + buffer_len: size_t, + buffer_as_path: *const c_char, + options: *const git_diff_options, + file_cb: git_diff_file_cb, + hunk_cb: git_diff_hunk_cb, + line_cb: git_diff_line_cb, + payload: *mut c_void) -> c_int; + pub fn git_diff_blobs(old_blob: *const git_blob, + old_as_path: *const c_char, + new_blob: *const git_blob, + new_as_path: *const c_char, + options: *const git_diff_options, + file_cb: git_diff_file_cb, + hunk_cb: git_diff_hunk_cb, + line_cb: git_diff_line_cb, + payload: *mut c_void) -> c_int; + pub fn git_diff_buffers(old_buffer: *const c_void, + old_len: size_t, + old_as_path: *const c_char, + new_buffer: *const c_void, + new_len: size_t, + new_as_path: *const c_char, + options: *const git_diff_options, + file_cb: git_diff_file_cb, + hunk_cb: git_diff_hunk_cb, + line_cb: git_diff_line_cb, + payload: *mut c_void) -> c_int; + pub fn git_diff_find_similar(diff: *mut git_diff, + options: *const git_diff_find_options) -> c_int; + pub fn git_diff_find_init_options(opts: *mut git_diff_find_options, + version: c_uint) -> c_int; + pub fn git_diff_foreach(diff: *mut git_diff, + file_cb: git_diff_file_cb, + hunk_cb: git_diff_hunk_cb, + line_cb: git_diff_line_cb, + payload: *mut c_void) -> c_int; + pub fn git_diff_free(diff: *mut git_diff); + pub fn git_diff_get_delta(diff: *const git_diff, + idx: size_t) -> *const git_diff_delta; + pub fn git_diff_get_stats(out: *mut *mut git_diff_stats, + diff: *mut git_diff) -> c_int; + pub fn git_diff_index_to_workdir(diff: *mut *mut git_diff, + repo: *mut git_repository, + index: *mut git_index, + opts: *const git_diff_options) -> c_int; + pub fn git_diff_init_options(opts: *mut git_diff_options, + version: c_uint) -> c_int; + pub fn git_diff_is_sorted_icase(diff: *const git_diff) -> c_int; + pub fn git_diff_merge(onto: *mut git_diff, + from: *const git_diff) -> c_int; + pub fn git_diff_num_deltas(diff: *const git_diff) -> size_t; + pub fn git_diff_num_deltas_of_type(diff: *const git_diff, + delta: git_delta_t) -> size_t; + pub fn git_diff_print(diff: *mut git_diff, + format: git_diff_format_t, + print_cb: git_diff_line_cb, + payload: *mut c_void) -> c_int; + pub fn git_diff_stats_deletions(stats: *const git_diff_stats) -> size_t; + pub fn git_diff_stats_files_changed(stats: *const git_diff_stats) -> size_t; + pub fn git_diff_stats_free(stats: *mut git_diff_stats); + pub fn git_diff_stats_insertions(stats: *const git_diff_stats) -> size_t; + pub fn git_diff_stats_to_buf(out: *mut git_buf, + stats: *const git_diff_stats, + format: u32, // git_diff_stats_format_t + width: size_t) -> c_int; + pub fn git_diff_status_char(status: git_delta_t) -> c_char; + pub fn git_diff_tree_to_index(diff: *mut *mut git_diff, + repo: *mut git_repository, + old_tree: *mut git_tree, + index: *mut git_index, + opts: *const git_diff_options) -> c_int; + pub fn git_diff_tree_to_tree(diff: *mut *mut git_diff, + repo: *mut git_repository, + old_tree: *mut git_tree, + new_tree: *mut git_tree, + opts: *const git_diff_options) -> c_int; + pub fn git_diff_tree_to_workdir(diff: *mut *mut git_diff, + repo: *mut git_repository, + old_tree: *mut git_tree, + opts: *const git_diff_options) -> c_int; + pub fn git_diff_tree_to_workdir_with_index(diff: *mut *mut git_diff, + repo: *mut git_repository, + old_tree: *mut git_tree, + opts: *const git_diff_options) + -> c_int; + + pub fn git_graph_ahead_behind(ahead: *mut size_t, behind: *mut size_t, + repo: *mut git_repository, + local: *const git_oid, upstream: *const git_oid) + -> c_int; + + pub fn git_graph_descendant_of(repo: *mut git_repository, + commit: *const git_oid, ancestor: *const git_oid) + -> c_int; + + // reflog + pub fn git_reflog_append(reflog: *mut git_reflog, + id: *const git_oid, + committer: *const git_signature, + msg: *const c_char) -> c_int; + pub fn git_reflog_delete(repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_reflog_drop(reflog: *mut git_reflog, + idx: size_t, + rewrite_previous_entry: c_int) -> c_int; + pub fn git_reflog_entry_byindex(reflog: *const git_reflog, + idx: size_t) -> *const git_reflog_entry; + pub fn git_reflog_entry_committer(entry: *const git_reflog_entry) + -> *const git_signature; + pub fn git_reflog_entry_id_new(entry: *const git_reflog_entry) + -> *const git_oid; + pub fn git_reflog_entry_id_old(entry: *const git_reflog_entry) + -> *const git_oid; + pub fn git_reflog_entry_message(entry: *const git_reflog_entry) + -> *const c_char; + pub fn git_reflog_entrycount(reflog: *mut git_reflog) -> size_t; + pub fn git_reflog_free(reflog: *mut git_reflog); + pub fn git_reflog_read(out: *mut *mut git_reflog, + repo: *mut git_repository, + name: *const c_char) -> c_int; + pub fn git_reflog_rename(repo: *mut git_repository, + old_name: *const c_char, + name: *const c_char) -> c_int; + pub fn git_reflog_write(reflog: *mut git_reflog) -> c_int; + + // transport + pub fn git_transport_register(prefix: *const c_char, + cb: git_transport_cb, + param: *mut c_void) -> c_int; + pub fn git_transport_unregister(prefix: *const c_char) -> c_int; + pub fn git_transport_smart(out: *mut *mut git_transport, + owner: *mut git_remote, + payload: *mut c_void) -> c_int; +} + +#[test] +fn smoke() { + unsafe { git_threads_init(); } +} + +pub fn issue_14344_workaround() { + libssh2::issue_14344_workaround(); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/.HEADER b/deps/libgit2-sys-0.2.17/libgit2/.HEADER new file mode 100644 index 000000000..fd8430bc8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/.HEADER @@ -0,0 +1,24 @@ +/* + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * In addition to the permissions in the GNU General Public License, + * the authors give you unlimited permission to link the compiled + * version of this file into combinations with other programs, + * and to distribute those combinations without any restriction + * coming from the use of this file. (The General Public License + * restrictions do apply in other respects; for example, they cover + * modification of the file, and distribution when not linked into + * a combined executable.) + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/.editorconfig b/deps/libgit2-sys-0.2.17/libgit2/.editorconfig new file mode 100644 index 000000000..be59274e8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/.editorconfig @@ -0,0 +1,14 @@ +; Check http://editorconfig.org/ for more informations +; Top-most EditorConfig file +root = true + +; tab indentation +[*] +indent_style = tab +trim_trailing_whitespace = true +insert_final_newline = true + +; 4-column space indentation +[*.md] +indent_style = space +indent_size = 4 diff --git a/deps/libgit2-sys-0.2.17/libgit2/.gitattributes b/deps/libgit2-sys-0.2.17/libgit2/.gitattributes new file mode 100644 index 000000000..f90540b55 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/.gitattributes @@ -0,0 +1,2 @@ +*.c eol=lf +*.h eol=lf diff --git a/deps/libgit2-sys-0.2.17/libgit2/.gitignore b/deps/libgit2-sys-0.2.17/libgit2/.gitignore new file mode 100644 index 000000000..1ef1ec730 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/.gitignore @@ -0,0 +1,33 @@ +/tests/clar.suite +/tests/clar.suite.rule +/tests/.clarcache +/apidocs +/trash-*.exe +/libgit2.pc +/config.mak +*.o +*.a +*.exe +*.gcda +*.gcno +*.gcov +.lock-wafbuild +.waf* +build/ +build-amiga/ +tests/tmp/ +msvc/Debug/ +msvc/Release/ +*.sln +*.suo +*.vc*proj* +*.sdf +*.opensdf +*.aps +*.cmake +!cmake/Modules/*.cmake +.DS_Store +*~ +.*.swp +tags +mkmf.log diff --git a/deps/libgit2-sys-0.2.17/libgit2/.mailmap b/deps/libgit2-sys-0.2.17/libgit2/.mailmap new file mode 100644 index 000000000..c656f64c7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/.mailmap @@ -0,0 +1,21 @@ +Vicent Martí Vicent Marti +Vicent Martí Vicent Martí +Michael Schubert schu +Ben Straub Ben Straub +Ben Straub Ben Straub +Carlos Martín Nieto +Carlos Martín Nieto +nulltoken +Scott J. Goldman +Martin Woodward +Peter DrahoÅ¡ +Adam Roben +Adam Roben +Xavier L. +Xavier L. +Sascha Cunz +Authmillenon +Authmillenon +Edward Thomson +J. David Ibáñez +Russell Belfer diff --git a/deps/libgit2-sys-0.2.17/libgit2/.travis.yml b/deps/libgit2-sys-0.2.17/libgit2/.travis.yml new file mode 100644 index 000000000..28ec0e0af --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/.travis.yml @@ -0,0 +1,77 @@ +# Travis-CI Build for libgit2 +# see travis-ci.org for details + +language: c + +os: + - linux + - osx + +compiler: + - gcc + - clang + +# Settings to try +env: + global: + - secure: "YnhS+8n6B+uoyaYfaJ3Lei7cSJqHDPiKJCKFIF2c87YDfmCvAJke8QtE7IzjYDs7UFkTCM4ox+ph2bERUrxZbSCyEkHdjIZpKuMJfYWja/jgMqTMxdyOH9y8JLFbZsSXDIXDwqBlC6vVyl1fP90M35wuWcNTs6tctfVWVofEFbs=" + - GITTEST_INVASIVE_FS_SIZE=1 + matrix: + - OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release" + - OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON" + +matrix: + fast_finish: true + exclude: + - os: osx + compiler: gcc + include: + - compiler: i586-mingw32msvc-gcc + env: OPTIONS="-DCMAKE_TOOLCHAIN_FILE=../script/toolchain-mingw32.cmake" SKIP_TESTS=1 + os: linux + - compiler: gcc + env: COVERITY=1 + os: linux + - compiler: gcc + env: + - VALGRIND=1 + OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug" + os: linux + allow_failures: + - env: COVERITY=1 + - env: + - VALGRIND=1 + OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug" + +install: + - ./script/install-deps-${TRAVIS_OS_NAME}.sh + +# Run the Build script and tests +script: + - script/cibuild.sh + +# Run Tests +after_success: + - if [ "$TRAVIS_OS_NAME" = "linux" -a -n "$VALGRIND" ]; then sudo apt-get -qq install valgrind; fi + - if [ "$TRAVIS_OS_NAME" = "linux" -a -n "$VALGRIND" ]; then valgrind --leak-check=full --show-reachable=yes --suppressions=./libgit2_clar.supp _build/libgit2_clar -ionline; fi + +# Only watch the development and master branches +branches: + only: + - development + - master + +# Notify development list when needed +notifications: + irc: + channels: + - irc.freenode.net#libgit2 + on_success: change + on_failure: always + use_notice: true + skip_join: true + campfire: + on_success: always + on_failure: always + rooms: + - secure: "sH0dpPWMirbEe7AvLddZ2yOp8rzHalGmv0bYL/LIhVw3JDI589HCYckeLMSB\n3e/FeXw4bn0EqXWEXijVa4ijbilVY6d8oprdqMdWHEodng4KvY5vID3iZSGT\nxylhahO1XHmRynKQLOAvxlc93IlpVW38vQfby8giIY1nkpspb2w=" diff --git a/deps/libgit2-sys-0.2.17/libgit2/AUTHORS b/deps/libgit2-sys-0.2.17/libgit2/AUTHORS new file mode 100644 index 000000000..2eaec0ff6 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/AUTHORS @@ -0,0 +1,75 @@ +The following people contribute or have contributed +to the libgit2 project (sorted alphabetically): + +Alex Budovski +Alexei Sholik +Andreas Ericsson +Anton "antong" Gyllenberg +Ankur Sethi +Arthur Schreiber +Ben Noordhuis +Ben Straub +Benjamin C Meyer +Brian Downing +Brian Lopez +Carlos Martín Nieto +Colin Timmermans +Daniel Huckstep +Dave Borowitz +David Boyce +David Glesser +Dmitry Kakurin +Dmitry Kovega +Emeric Fermas +Emmanuel Rodriguez +Florian Forster +Holger Weiss +Ingmar Vanhassel +J. David Ibáñez +Jacques Germishuys +Jakob Pfender +Jason Penny +Jason R. McNeil +Jerome Lambourg +Johan 't Hart +John Wiegley +Jonathan "Duke" Leto +Julien Miotte +Julio Espinoza-Sokal +Justin Love +Kelly "kelly.leahy" Leahy +Kirill A. Shutemov +Lambert CLARA +Luc Bertrand +Marc Pegon +Marcel Groothuis +Marco Villegas +Michael "schu" Schubert +Microsoft Corporation +Olivier Ramonat +Peter DrahoÅ¡ +Pierre Habouzit +Przemyslaw Pawelczyk +Ramsay Jones +Robert G. Jakabosky +Romain Geissler +Romain Muller +Russell Belfer +Sakari Jokinen +Samuel Charles "Sam" Day +Sarath Lakshman +Sascha Cunz +Sascha Peilicke +Scott Chacon +Sebastian Schuberth +Sergey Nikishin +Shawn O. Pearce +Shuhei Tanuma +Steve Frécinaux +Sven Strickroth +Tim Branyen +Tim Clem +Tim Harder +Torsten Bögershausen +Trent Mick +Vicent Marti diff --git a/deps/libgit2-sys-0.2.17/libgit2/CHANGELOG.md b/deps/libgit2-sys-0.2.17/libgit2/CHANGELOG.md new file mode 100644 index 000000000..be8e92400 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/CHANGELOG.md @@ -0,0 +1,332 @@ +v0.22 + 1 +------ + +### Changes or improvements + +* Patience and minimal diff drivers can now be used for merges. + +* Merges can now ignore whitespace changes. + +* Updated binary identification in CRLF filtering to avoid false positives in + UTF-8 files. + +* Rename and copy detection is enabled for small files. + +* Checkout can now handle an initial checkout of a repository, making + `GIT_CHECKOUT_SAFE_CREATE` unnecessary for users of clone. + +* The signature parameter in the ref-modifying functions has been + removed. Use `git_repository_set_ident()` and + `git_repository_ident()` to override the signature to be used. + +* The local transport now auto-scales the number of threads to use + when creating the packfile instead of sticking to one. + +* Reference renaming now uses the right id for the old value. + +* The annotated version of branch creation, HEAD detaching and reset + allow for specifying the expression from the user to be put into the + reflog. + +### API additions + +* The `git_merge_options` gained a `file_flags` member. + +* Parsing and retrieving a configuration value as a path is exposed + via `git_config_parse_path()` and `git_config_get_path()` + respectively. + +* `git_repository_set_ident()` and `git_repository_ident()` serve to + set and query which identity will be used when writing to the + reflog. + +* `git_config_entry_free()` frees a config entry. + +* `git_config_get_string_buf()` provides a way to safely retrieve a + string from a non-snapshot configuration. + +* `git_annotated_commit_from_revspec()` allows to get an annotated + commit from an extended sha synatx string. + +* `git_repository_set_head_detached_from_annotated()`, + `git_branch_create_from_annotated()` and + `git_reset_from_annotated()` allow for the caller to provide an + annotated commit through which they can control what expression is + put into the reflog as the source/target. + +* `git_index_add_frombuffer()` can now create a blob from memory + buffer and add it to the index which is attached to a repository. + +### API removals + +### Breaking API changes + +* The `git_merge_options` structure member `flags` has been renamed + to `tree_flags`. + +* The `git_merge_file_options` structure member `flags` is now + an unsigned int. It was previously a `git_merge_file_flags_t`. + +* `GIT_CHECKOUT_SAFE_CREATE` has been removed. Most users will generally + be able to switch to `GIT_CHECKOUT_SAFE`, but if you require missing + file handling during checkout, you may now use `GIT_CHECKOUT_SAFE | + GIT_CHECKOUT_RECREATE_MISSING`. + +* The `git_clone_options` and `git_submodule_update_options` + structures no longer have a `signature` field. + +* The following functions have removed the signature and/or log message + parameters in favour of git-emulating ones. + + * `git_branch_create()`, `git_branch_move()` + * `git_rebase_init()`, `git_rebase_abort()` + * `git_reference_symbolic_create_matching()`, + `git_reference_symbolic_create()`, `git_reference_create()`, + `git_reference_create_matching()`, + `git_reference_symbolic_set_target()`, + `git_reference_set_target()`, `git_reference_rename()` + * `git_remote_update_tips()`, `git_remote_fetch()`, `git_remote_push()` + * `git_repository_set_head()`, + `git_repository_set_head_detached()`, + `git_repository_detach_head()` + * `git_reset()` + +* `git_config_get_entry()` now gives back a ref-counted + `git_config_entry`. You must free it when you no longer need it. + +* `git_config_get_string()` will return an error if used on a + non-snapshot configuration, as there can be no guarantee that the + returned pointer is valid. + +* `git_note_default_ref()` now uses a `git_buf` to return the string, + as the string is otherwise not guaranteed to stay allocated. + +v0.22 +------ + +### Changes or improvements + +* `git_signature_new()` now requires a non-empty email address. + +* Use CommonCrypto libraries for SHA-1 calculation on Mac OS X. + +* Disable SSL compression and SSLv2 and SSLv3 ciphers in favor of TLSv1 + in OpenSSL. + +* The fetch behavior of remotes with autotag set to `GIT_REMOTE_DOWNLOAD_TAGS_ALL` + has been changed to match git 1.9.0 and later. In this mode, libgit2 now + fetches all tags in addition to whatever else needs to be fetched. + +* `git_checkout()` now handles case-changing renames correctly on + case-insensitive filesystems; for example renaming "readme" to "README". + +* The search for libssh2 is now done via pkg-config instead of a + custom search of a few directories. + +* Add support for core.protectHFS and core.protectNTFS. Add more + validation for filenames which we write such as references. + +* The local transport now generates textual progress output like + git-upload-pack does ("counting objects"). + +* `git_checkout_index()` can now check out an in-memory index that is not + necessarily the repository's index, so you may check out an index + that was produced by git_merge and friends while retaining the cached + information. + +* Remove the default timeout for receiving / sending data over HTTP using + the WinHTTP transport layer. + +* Add SPNEGO (Kerberos) authentication using GSSAPI on Unix systems. + +* Provide built-in objects for the empty blob (e69de29) and empty + tree (4b825dc) objects. + +* The index' tree cache is now filled upon read-tree and write-tree + and the cache is written to disk. + +* LF -> CRLF filter refuses to handle mixed-EOL files + +* LF -> CRLF filter now runs when * text = auto (with Git for Windows 1.9.4) + +* File unlocks are atomic again via rename. Read-only files on Windows are + made read-write if necessary. + +* Share open packfiles across repositories to share descriptors and mmaps. + +* Use a map for the treebuilder, making insertion O(1) + +* The build system now accepts an option EMBED_SSH_PATH which when set + tells it to include a copy of libssh2 at the given location. This is + enabled for MSVC. + +* Add support for refspecs with the asterisk in the middle of a + pattern. + +* Fetching now performs opportunistic updates. To achieve this, we + introduce a difference between active and passive refspecs, which + make `git_remote_download()` and `git_remote_fetch()` to take a list of + resfpecs to be the active list, similarly to how git fetch accepts a + list on the command-line. + +* The THREADSAFE option to build libgit2 with threading support has + been flipped to be on by default. + +* The remote object has learnt to prune remote-tracking branches. If + the remote is configured to do so, this will happen via + `git_remote_fetch()`. You can also call `git_remote_prune()` after + connecting or fetching to perform the prune. + + +### API additions + +* Introduce `git_buf_text_is_binary()` and `git_buf_text_contains_nul()` for + consumers to perform binary detection on a git_buf. + +* `git_branch_upstream_remote()` has been introduced to provide the + branch..remote configuration value. + +* Introduce `git_describe_commit()` and `git_describe_workdir()` to provide + a description of the current commit (and working tree, respectively) + based on the nearest tag or reference + +* Introduce `git_merge_bases()` and the `git_oidarray` type to expose all + merge bases between two commits. + +* Introduce `git_merge_bases_many()` to expose all merge bases between + multiple commits. + +* Introduce rebase functionality (using the merge algorithm only). + Introduce `git_rebase_init()` to begin a new rebase session, + `git_rebase_open()` to open an in-progress rebase session, + `git_rebase_commit()` to commit the current rebase operation, + `git_rebase_next()` to apply the next rebase operation, + `git_rebase_abort()` to abort an in-progress rebase and `git_rebase_finish()` + to complete a rebase operation. + +* Introduce `git_note_author()` and `git_note_committer()` to get the author + and committer information on a `git_note`, respectively. + +* A factory function for ssh has been added which allows to change the + path of the programs to execute for receive-pack and upload-pack on + the server, `git_transport_ssh_with_paths()`. + +* The ssh transport supports asking the remote host for accepted + credential types as well as multiple challeges using a single + connection. This requires to know which username you want to connect + as, so this introduces the USERNAME credential type which the ssh + transport will use to ask for the username. + +* The `GIT_EPEEL` error code has been introduced when we cannot peel a tag + to the requested object type; if the given object otherwise cannot be + peeled, `GIT_EINVALIDSPEC` is returned. + +* Introduce `GIT_REPOSITORY_INIT_RELATIVE_GITLINK` to use relative paths + when writing gitlinks, as is used by git core for submodules. + +* `git_remote_prune()` has been added. See above for description. + + +* Introduce reference transactions, which allow multiple references to + be locked at the same time and updates be queued. This also allows + us to safely update a reflog with arbitrary contents, as we need to + do for stash. + +### API removals + +* `git_remote_supported_url()` and `git_remote_is_valid_url()` have been + removed as they have become essentially useless with rsync-style ssh paths. + +* `git_clone_into()` and `git_clone_local_into()` have been removed from the + public API in favour of `git_clone callbacks`. + +* The option to ignore certificate errors via `git_remote_cert_check()` + is no longer present. Instead, `git_remote_callbacks` has gained a new + entry which lets the user perform their own certificate checks. + +### Breaking API changes + +* `git_cherry_pick()` is now `git_cherrypick()`. + +* The `git_submodule_update()` function was renamed to + `git_submodule_update_strategy()`. `git_submodule_update()` is now used to + provide functionalty similar to "git submodule update". + +* `git_treebuilder_create()` was renamed to `git_treebuilder_new()` to better + reflect it being a constructor rather than something which writes to + disk. + +* `git_treebuilder_new()` (was `git_treebuilder_create()`) now takes a + repository so that it can query repository configuration. + Subsequently, `git_treebuilder_write()` no longer takes a repository. + +* `git_threads_init()` and `git_threads_shutdown()` have been renamed to + `git_libgit2_init()` and `git_libgit2_shutdown()` to better explain what + their purpose is, as it's grown to be more than just about threads. + +* `git_libgit2_init()` and `git_libgit2_shutdown()` now return the number of + initializations of the library, so consumers may schedule work on the + first initialization. + +* The `git_transport_register()` function no longer takes a priority and takes + a URL scheme name (eg "http") instead of a prefix like "http://" + +* `git_index_name_entrycount()` and `git_index_reuc_entrycount()` now + return size_t instead of unsigned int. + +* The `context_lines` and `interhunk_lines` fields in `git_diff`_options are + now `uint32_t` instead of `uint16_t`. This allows to set them to `UINT_MAX`, + in effect asking for "infinite" context e.g. to iterate over all the + unmodified lines of a diff. + +* `git_status_file()` now takes an exact path. Use `git_status_list_new()` if + pathspec searching is needed. + +* `git_note_create()` has changed the position of the notes reference + name to match `git_note_remove()`. + +* Rename `git_remote_load()` to `git_remote_lookup()` to bring it in line + with the rest of the lookup functions. + +* `git_remote_rename()` now takes the repository and the remote's + current name. Accepting a remote indicates we want to change it, + which we only did partially. It is much clearer if we accept a name + and no loaded objects are changed. + +* `git_remote_delete()` now accepts the repository and the remote's name + instead of a loaded remote. + +* `git_merge_head` is now `git_annotated_commit`, to better reflect its usage + for multiple functions (including rebase) + +* The `git_clone_options` struct no longer provides the `ignore_cert_errors` or + `remote_name` members for remote customization. + + Instead, the `git_clone_options` struct has two new members, `remote_cb` and + `remote_cb_payload`, which allow the caller to completely override the remote + creation process. If needed, the caller can use this callback to give their + remote a name other than the default (origin) or disable cert checking. + + The `remote_callbacks` member has been preserved for convenience, although it + is not used when a remote creation callback is supplied. + +* The `git_clone`_options struct now provides `repository_cb` and + `repository_cb_payload` to allow the user to create a repository with + custom options. + +* The `git_push` struct to perform a push has been replaced with + `git_remote_upload()`. The refspecs and options are passed as a + function argument. `git_push_update_tips()` is now also + `git_remote_update_tips()` and the callbacks are in the same struct as + the rest. + +* The `git_remote_set_transport()` function now sets a transport factory function, + rather than a pre-existing transport instance. + +* The `git_transport` structure definition has moved into the sys/transport.h + file. + +* libgit2 no longer automatically sets the OpenSSL locking + functions. This is not something which we can know to do. A + last-resort convenience function is provided in sys/openssl.h, + `git_openssl_set_locking()` which can be used to set the locking. diff --git a/deps/libgit2-sys-0.2.17/libgit2/CMakeLists.txt b/deps/libgit2-sys-0.2.17/libgit2/CMakeLists.txt new file mode 100644 index 000000000..d64726e7f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/CMakeLists.txt @@ -0,0 +1,562 @@ +# CMake build script for the libgit2 project +# +# Building (out of source build): +# > mkdir build && cd build +# > cmake .. [-DSETTINGS=VALUE] +# > cmake --build . +# +# Testing: +# > ctest -V +# +# Install: +# > cmake --build . --target install + +PROJECT(libgit2 C) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +CMAKE_POLICY(SET CMP0015 NEW) + +# Add find modules to the path +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") + +INCLUDE(CheckLibraryExists) +INCLUDE(AddCFlagIfSupported) +INCLUDE(FindPkgConfig) + +# Build options +# +OPTION( SONAME "Set the (SO)VERSION of the target" ON ) +OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON ) +OPTION( THREADSAFE "Build libgit2 as threadsafe" ON ) +OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON ) +OPTION( BUILD_EXAMPLES "Build library usage example apps" OFF ) +OPTION( TAGS "Generate tags" OFF ) +OPTION( PROFILE "Generate profiling information" OFF ) +OPTION( ENABLE_TRACE "Enables tracing support" OFF ) +OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF ) + +OPTION( ANDROID "Build for android NDK" OFF ) + +OPTION( USE_OPENSSL "Link with and use openssl library" ON ) +OPTION( USE_ICONV "Link with and use iconv library" OFF ) +OPTION( USE_SSH "Link with libssh to enable SSH support" ON ) +OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF ) +OPTION( VALGRIND "Configure build for valgrind" OFF ) + +IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + SET( USE_ICONV ON ) +ENDIF() + +IF(MSVC) + # This option is only available when building with MSVC. By default, libgit2 + # is build using the cdecl calling convention, which is useful if you're + # writing C. However, the CLR and Win32 API both expect stdcall. + # + # If you are writing a CLR program and want to link to libgit2, you'll want + # to turn this on by invoking CMake with the "-DSTDCALL=ON" argument. + OPTION( STDCALL "Build libgit2 with the __stdcall convention" OFF ) + + # This option must match the settings used in your program, in particular if you + # are linking statically + OPTION( STATIC_CRT "Link the static CRT libraries" ON ) + + # If you want to embed a copy of libssh2 into libgit2, pass a + # path to libssh2 + OPTION( EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF ) + + ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) +ENDIF() + +IF(WIN32) + # By default, libgit2 is built with WinHTTP. To use the built-in + # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument. + OPTION( WINHTTP "Use Win32 WinHTTP routines" ON ) +ENDIF() + +# This variable will contain the libraries we need to put into +# libgit2.pc's Requires.private. That is, what we're linking to or +# what someone who's statically linking us needs to link to. +SET(LIBGIT2_PC_REQUIRES "") +# This will be set later if we use the system's http-parser library or +# use iconv (OSX) and will be written to the Libs.private field in the +# pc file. +SET(LIBGIT2_PC_LIBS "") + +# Installation paths +# +SET(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.") +SET(LIB_INSTALL_DIR lib CACHE PATH "Where to install libraries to.") +SET(INCLUDE_INSTALL_DIR include CACHE PATH "Where to install headers to.") + +FUNCTION(TARGET_OS_LIBRARIES target) + IF(WIN32) + TARGET_LINK_LIBRARIES(${target} ws2_32) + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") + TARGET_LINK_LIBRARIES(${target} socket nsl) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lsocket -lnsl" PARENT_SCOPE) + ENDIF() + CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT) + IF(NEED_LIBRT) + TARGET_LINK_LIBRARIES(${target} rt) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lrt" PARENT_SCOPE) + ENDIF() + + IF(THREADSAFE) + TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF() +ENDFUNCTION() + +# For the MSVC IDE, this function splits up the source files like windows +# explorer does. This is esp. useful with the libgit2_clar project, were +# usually 2 or more files share the same name. Sadly, this file grouping +# is a per-directory option in cmake and not per-target, resulting in +# empty virtual folders "tests" for the git2.dll +FUNCTION(MSVC_SPLIT_SOURCES target) + IF(MSVC_IDE) + GET_TARGET_PROPERTY(sources ${target} SOURCES) + FOREACH(source ${sources}) + IF(source MATCHES ".*/") + STRING(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" rel ${source}) + IF(rel) + STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel}) + IF(rel) + STRING(REPLACE "/" "\\\\" rel ${rel}) + SOURCE_GROUP(${rel} FILES ${source}) + ENDIF() + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() +ENDFUNCTION() + +FILE(STRINGS "include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$") + +STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}") +STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}") +STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}") +SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}") + +FILE(STRINGS "include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$") +STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}") + +# Find required dependencies +INCLUDE_DIRECTORIES(src include) + +IF (WIN32 AND EMBED_SSH_PATH) + FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c") + INCLUDE_DIRECTORIES("${EMBED_SSH_PATH}/include") + FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") + ADD_DEFINITIONS(-DGIT_SSH) +ENDIF() + +IF (WIN32 AND WINHTTP) + ADD_DEFINITIONS(-DGIT_WINHTTP) + INCLUDE_DIRECTORIES(deps/http-parser) + FILE(GLOB SRC_HTTP deps/http-parser/*.c deps/http-parser/*.h) + + # Since MinGW does not come with headers or an import library for winhttp, + # we have to include a private header and generate our own import library + IF (MINGW) + FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH) + IF (NOT DLLTOOL) + MESSAGE(FATAL_ERROR "Could not find dlltool command") + ENDIF () + + SET(LIBWINHTTP_PATH "${CMAKE_CURRENT_BINARY_DIR}/deps/winhttp") + FILE(MAKE_DIRECTORY ${LIBWINHTTP_PATH}) + + IF ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(WINHTTP_DEF "${CMAKE_CURRENT_SOURCE_DIR}/deps/winhttp/winhttp64.def") + ELSE() + set(WINHTTP_DEF "${CMAKE_CURRENT_SOURCE_DIR}/deps/winhttp/winhttp.def") + ENDIF() + + ADD_CUSTOM_COMMAND( + OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a + COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a + DEPENDS ${WINHTTP_DEF} + WORKING_DIRECTORY ${LIBWINHTTP_PATH} + ) + + SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c + PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a + ) + + INCLUDE_DIRECTORIES(deps/winhttp) + LINK_DIRECTORIES(${LIBWINHTTP_PATH}) + ENDIF () + + LINK_LIBRARIES(winhttp rpcrt4 crypt32) +ELSE () + IF (NOT AMIGA AND USE_OPENSSL) + FIND_PACKAGE(OpenSSL) + ENDIF () + + FIND_PACKAGE(HTTP_Parser) + IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) + INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS}) + LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES}) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lhttp_parser") + ELSE() + MESSAGE(STATUS "http-parser was not found or is too old; using bundled 3rd-party sources.") + INCLUDE_DIRECTORIES(deps/http-parser) + FILE(GLOB SRC_HTTP deps/http-parser/*.c deps/http-parser/*.h) + ENDIF() +ENDIF() + +# Specify sha1 implementation +IF (WIN32 AND NOT MINGW AND NOT SHA1_TYPE STREQUAL "builtin") + ADD_DEFINITIONS(-DWIN32_SHA1) + FILE(GLOB SRC_SHA1 src/hash/hash_win32.c) +ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + ADD_DEFINITIONS(-DGIT_COMMON_CRYPTO) +ELSEIF (OPENSSL_FOUND AND NOT SHA1_TYPE STREQUAL "builtin") + ADD_DEFINITIONS(-DOPENSSL_SHA1) + IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lssl") + ELSE() + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl") + ENDIF () +ELSE() + FILE(GLOB SRC_SHA1 src/hash/hash_generic.c) +ENDIF() + +# Enable tracing +IF (ENABLE_TRACE STREQUAL "ON") + ADD_DEFINITIONS(-DGIT_TRACE) +ENDIF() + +# Include POSIX regex when it is required +IF(WIN32 OR AMIGA OR ANDROID OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") + INCLUDE_DIRECTORIES(deps/regex) + SET(SRC_REGEX deps/regex/regex.c) +ENDIF() + +# Optional external dependency: zlib +FIND_PACKAGE(ZLIB) +IF (ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) + LINK_LIBRARIES(${ZLIB_LIBRARIES}) + IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lz") + ELSE() + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib") + ENDIF() +ELSE() + MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." ) + INCLUDE_DIRECTORIES(deps/zlib) + ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP) + FILE(GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h) +ENDIF() + +# Optional external dependency: libssh2 +IF (USE_SSH) + PKG_CHECK_MODULES(LIBSSH2 libssh2) +ENDIF() +IF (LIBSSH2_FOUND) + ADD_DEFINITIONS(-DGIT_SSH) + INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIRS}) + LINK_DIRECTORIES(${LIBSSH2_LIBRARY_DIRS}) + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} libssh2") + SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES}) +ELSE() + MESSAGE(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") +ENDIF() + +# Optional external dependency: libgssapi +IF (USE_GSSAPI) + FIND_PACKAGE(GSSAPI) +ENDIF() +IF (GSSAPI_FOUND) + ADD_DEFINITIONS(-DGIT_GSSAPI) +ENDIF() + +# Optional external dependency: iconv +IF (USE_ICONV) + FIND_PACKAGE(Iconv) +ENDIF() +IF (ICONV_FOUND) + ADD_DEFINITIONS(-DGIT_USE_ICONV) + INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${ICONV_LIBRARIES}") +ENDIF() + +# Platform specific compilation flags +IF (MSVC) + + STRING(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + + # /GF - String pooling + # /MP - Parallel build + SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}") + + IF (STDCALL) + # /Gz - stdcall calling convention + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz") + ENDIF () + + IF (STATIC_CRT) + SET(CRT_FLAG_DEBUG "/MTd") + SET(CRT_FLAG_RELEASE "/MT") + ELSE() + SET(CRT_FLAG_DEBUG "/MDd") + SET(CRT_FLAG_RELEASE "/MD") + ENDIF() + + # /Zi - Create debugging information + # /Od - Disable optimization + # /D_DEBUG - #define _DEBUG + # /MTd - Statically link the multithreaded debug version of the CRT + # /MDd - Dynamically link the multithreaded debug version of the CRT + # /RTC1 - Run time checks + SET(CMAKE_C_FLAGS_DEBUG "/Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}") + + # /DNDEBUG - Disables asserts + # /MT - Statically link the multithreaded release version of the CRT + # /MD - Dynamically link the multithreaded release version of the CRT + # /O2 - Optimize for speed + # /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off) + # /GL - Link time code generation (whole program optimization) + # /Gy - Function-level linking + SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}") + + # /Oy- - Disable frame pointer omission (FPO) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}") + + # /O1 - Optimize for size + SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}") + + # /DYNAMICBASE - Address space load randomization (ASLR) + # /NXCOMPAT - Data execution prevention (DEP) + # /LARGEADDRESSAWARE - >2GB user address space on x86 + # /VERSION - Embed version information in PE header + SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}") + + # /DEBUG - Create a PDB + # /LTCG - Link time code generation (whole program optimization) + # /OPT:REF /OPT:ICF - Fold out duplicate code at link step + # /INCREMENTAL:NO - Required to use /LTCG + # /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug) + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG") + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO") + SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup") + SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO") + + # Same linker settings for DLL as EXE + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") + SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") + SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") + + SET(WIN_RC "src/win32/git2.rc") + + # Precompiled headers + +ELSE () + SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra ${CMAKE_C_FLAGS}") + + IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") + SET(CMAKE_C_FLAGS "-std=c99 -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}") + ENDIF() + + IF (WIN32 AND NOT CYGWIN) + SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG") + ENDIF () + + IF (MINGW) # MinGW always does PIC and complains if we tell it to + STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}") + # MinGW >= 3.14 uses the C99-style stdio functions + # automatically, but forks like mingw-w64 still want + # us to define this in order to use them + ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1) + + ELSEIF (BUILD_SHARED_LIBS) + ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden) + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + ENDIF () + + ADD_C_FLAG_IF_SUPPORTED(-Wno-missing-field-initializers) + ADD_C_FLAG_IF_SUPPORTED(-Wstrict-aliasing=2) + ADD_C_FLAG_IF_SUPPORTED(-Wstrict-prototypes) + ADD_C_FLAG_IF_SUPPORTED(-Wdeclaration-after-statement) + ADD_C_FLAG_IF_SUPPORTED(-Wno-unused-const-variable) + ADD_C_FLAG_IF_SUPPORTED(-Wno-unused-function) + + IF (APPLE) # Apple deprecated OpenSSL + ADD_C_FLAG_IF_SUPPORTED(-Wno-deprecated-declarations) + ENDIF() + + IF (PROFILE) + SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}") + SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}") + ENDIF () +ENDIF() + +IF( NOT CMAKE_CONFIGURATION_TYPES ) + # Build Debug by default + IF (NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) + ENDIF () +ELSE() + # Using a multi-configuration generator eg MSVC or Xcode + # that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE +ENDIF() + +IF (OPENSSL_FOUND) + ADD_DEFINITIONS(-DGIT_SSL) + INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) + SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES}) +ENDIF() + +IF (THREADSAFE) + IF (NOT WIN32) + FIND_PACKAGE(Threads REQUIRED) + ENDIF() + + ADD_DEFINITIONS(-DGIT_THREADS) +ENDIF() + +ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) + +# Collect sourcefiles +FILE(GLOB SRC_H include/git2.h include/git2/*.h include/git2/sys/*.h) + +# On Windows use specific platform sources +IF (WIN32 AND NOT CYGWIN) + ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0501) + FILE(GLOB SRC_OS src/win32/*.c src/win32/*.h) +ELSEIF (AMIGA) + ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP) +ELSE() + IF (VALGRIND) + ADD_DEFINITIONS(-DNO_MMAP) + ENDIF() + FILE(GLOB SRC_OS src/unix/*.c src/unix/*.h) +ENDIF() +FILE(GLOB SRC_GIT2 src/*.c src/*.h src/transports/*.c src/transports/*.h src/xdiff/*.c src/xdiff/*.h) + +# Determine architecture of the machine +IF (CMAKE_SIZEOF_VOID_P EQUAL 8) + ADD_DEFINITIONS(-DGIT_ARCH_64) +ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4) + ADD_DEFINITIONS(-DGIT_ARCH_32) +ELSE() + MESSAGE(FATAL_ERROR "Unsupported architecture") +ENDIF() + +# Compile and link libgit2 +ADD_LIBRARY(git2 ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1} ${WIN_RC}) +TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES}) +TARGET_LINK_LIBRARIES(git2 ${SSH_LIBRARIES}) +TARGET_LINK_LIBRARIES(git2 ${GSSAPI_LIBRARIES}) +TARGET_LINK_LIBRARIES(git2 ${ICONV_LIBRARIES}) +TARGET_OS_LIBRARIES(git2) + +# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240) +# Win64+MSVC+static libs = linker error +IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64") +ENDIF() + +MSVC_SPLIT_SOURCES(git2) + +IF (SONAME) + SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING}) + SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_SOVERSION}) + IF (LIBGIT2_FILENAME) + ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\") + SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME}) + ENDIF() +ENDIF() +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libgit2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc @ONLY) + +IF (MSVC_IDE) + # Precompiled headers + SET_TARGET_PROPERTIES(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") + SET_SOURCE_FILES_PROPERTIES(src/win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h") +ENDIF () + +# Install +INSTALL(TARGETS git2 + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} +) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig ) +INSTALL(DIRECTORY include/git2 DESTINATION ${INCLUDE_INSTALL_DIR} ) +INSTALL(FILES include/git2.h DESTINATION ${INCLUDE_INSTALL_DIR} ) + +# Tests +IF (BUILD_CLAR) + FIND_PACKAGE(PythonInterp REQUIRED) + + SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/tests/resources/") + SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tests") + SET(CLAR_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/tests/resources" CACHE PATH "Path to test resources.") + ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") + ADD_DEFINITIONS(-DCLAR_RESOURCES=\"${TEST_RESOURCES}\") + ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\") + + INCLUDE_DIRECTORIES(${CLAR_PATH}) + FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h) + SET(SRC_CLAR "${CLAR_PATH}/main.c" "${CLAR_PATH}/clar_libgit2.c" "${CLAR_PATH}/clar_libgit2_trace.c" "${CLAR_PATH}/clar_libgit2_timer.c" "${CLAR_PATH}/clar.c") + + ADD_CUSTOM_COMMAND( + OUTPUT ${CLAR_PATH}/clar.suite + COMMAND ${PYTHON_EXECUTABLE} generate.py -f -xonline -xstress . + DEPENDS ${SRC_TEST} + WORKING_DIRECTORY ${CLAR_PATH} + ) + + SET_SOURCE_FILES_PROPERTIES( + ${CLAR_PATH}/clar.c + PROPERTIES OBJECT_DEPENDS ${CLAR_PATH}/clar.suite) + + ADD_EXECUTABLE(libgit2_clar ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_CLAR} ${SRC_TEST} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1}) + + TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES}) + TARGET_LINK_LIBRARIES(libgit2_clar ${SSH_LIBRARIES}) + TARGET_LINK_LIBRARIES(libgit2_clar ${GSSAPI_LIBRARIES}) + TARGET_LINK_LIBRARIES(libgit2_clar ${ICONV_LIBRARIES}) + TARGET_OS_LIBRARIES(libgit2_clar) + MSVC_SPLIT_SOURCES(libgit2_clar) + + IF (MSVC_IDE) + # Precompiled headers + SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") + ENDIF () + + ENABLE_TESTING() + IF (WINHTTP OR OPENSSL_FOUND) + ADD_TEST(libgit2_clar libgit2_clar -ionline) + ELSE () + ADD_TEST(libgit2_clar libgit2_clar -v) + ENDIF () +ENDIF () + +IF (TAGS) + FIND_PROGRAM(CTAGS ctags) + IF (NOT CTAGS) + MESSAGE(FATAL_ERROR "Could not find ctags command") + ENDIF () + + FILE(GLOB_RECURSE SRC_ALL *.[ch]) + + ADD_CUSTOM_COMMAND( + OUTPUT tags + COMMAND ${CTAGS} -a ${SRC_ALL} + DEPENDS ${SRC_ALL} + ) + ADD_CUSTOM_TARGET( + do_tags ALL + DEPENDS tags + ) +ENDIF () + +IF (BUILD_EXAMPLES) + ADD_SUBDIRECTORY(examples) +ENDIF () diff --git a/deps/libgit2-sys-0.2.17/libgit2/CONTRIBUTING.md b/deps/libgit2-sys-0.2.17/libgit2/CONTRIBUTING.md new file mode 100644 index 000000000..71fad63a9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/CONTRIBUTING.md @@ -0,0 +1,146 @@ +# Welcome to libgit2! + +We're making it easy to do interesting things with git, and we'd love to have +your help. + +## Licensing + +By contributing to libgit2, you agree to release your contribution under +the terms of the license. Except for the `examples` directory, all code +is released under the [GPL v2 with linking exception](COPYING). + +The `examples` code is governed by the +[CC0 Public Domain Dedication](examples/COPYING), so that you may copy +from them into your own application. + +## Discussion & Chat + +We hang out in the +[`#libgit2`](http://webchat.freenode.net/?channels=#libgit2)) channel on +irc.freenode.net. + +Also, feel free to open an +[Issue](https://github.com/libgit2/libgit2/issues/new) to start a discussion +about any concerns you have. We like to use Issues for that so there is an +easily accessible permanent record of the conversation. + +## Libgit2 Versions + +The `master` branch is the main branch where development happens. +Releases are tagged +(e.g. [v0.21.0](https://github.com/libgit2/libgit2/releases/tag/v0.21.0) ) +and when a critical bug fix needs to be backported, it will be done on a +`-maint` maintenance branch. + +## Reporting Bugs + +First, know which version of libgit2 your problem is in and include it in +your bug report. This can either be a tag (e.g. +[v0.17.0](https://github.com/libgit2/libgit2/releases/tag/v0.17.0)) or a +commit SHA +(e.g. [01be7863](https://github.com/libgit2/libgit2/commit/01be7863)). +Using [`git describe`](http://git-scm.com/docs/git-describe) is a +great way to tell us what version you're working with. + +If you're not running against the latest `master` branch version, +please compile and test against that to avoid re-reporting an issue that's +already been fixed. + +It's *incredibly* helpful to be able to reproduce the problem. Please +include a list of steps, a bit of code, and/or a zipped repository (if +possible). Note that some of the libgit2 developers are employees of +GitHub, so if your repository is private, find us on IRC and we'll figure +out a way to help you. + +## Pull Requests + +Our work flow is a [typical GitHub +flow](https://guides.github.com/introduction/flow/index.html), where +contributors fork the [libgit2 repository](https://github.com/libgit2/libgit2), +make their changes on branch, and submit a +[Pull Request](https://help.github.com/articles/using-pull-requests) +(a.k.a. "PR"). Pull requests should usually be targeted at the `master` +branch. + +Life will be a lot easier for you (and us) if you follow this pattern +(i.e. fork, named branch, submit PR). If you use your fork's `master` +branch directly, things can get messy. + +Please include a nice description of your changes when you submit your PR; +if we have to read the whole diff to figure out why you're contributing +in the first place, you're less likely to get feedback and have your change +merged in. + +If you are starting to work on a particular area, feel free to submit a PR +that highlights your work in progress (and note in the PR title that it's +not ready to merge). These early PRs are welcome and will help in getting +visibility for your fix, allow others to comment early on the changes and +also let others know that you are currently working on something. + +Before wrapping up a PR, you should be sure to: + +* Write tests to cover any functional changes +* Update documentation for any changed public APIs +* Add to the [`CHANGELOG.md`](CHANGELOG.md) file describing any major changes + +## Unit Tests + +We believe that our unit tests allow us to keep the quality of libgit2 +high: any new changes must not cause unit test failures, and new changes +should include unit tests that cover the bug fixes or new features. +For bug fixes, we prefer unit tests that illustrate the failure before +the change, but pass with your changes. + +In addition to new tests, please ensure that your changes do not cause +any other test failures. Running the entire test suite is helpful +before you submit a pull request. When you build libgit2, the test +suite will also be built. You can run all tests by simply running +the resultant `libgit2_clar` binary. If you want to run a specific +unit test, you can name it with the `-s` option. For example: + + libgit2_clar -sstatus::worktree::long_filenames + +Or you can run an entire class of tests. For example, to run all the +worktree status tests: + + libgit2_clar -sstatus::worktree + +## Porting Code From Other Open-Source Projects + +`libgit2` is licensed under the terms of the GPL v2 with a linking +exception. Any code brought in must be compatible with those terms. + +The most common case is porting code from core Git. Git is a pure GPL +project, which means that in order to port code to this project, we need the +explicit permission of the author. Check the +[`git.git-authors`](https://github.com/libgit2/libgit2/blob/development/git.git-authors) +file for authors who have already consented. + +Other licenses have other requirements; check the license of the library +you're porting code *from* to see what you need to do. As a general rule, +MIT and BSD (3-clause) licenses are typically no problem. Apache 2.0 +license typically doesn't work due to GPL incompatibility. + +If your pull request uses code from core Git, another project, or code +from a forum / Stack Overflow, then *please* flag this in your PR and make +sure you've given proper credit to the original author in the code +snippet. + +## Style Guide + +The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C) +(a.k.a. C89) compatible. Internally, `libgit2` is written using a portable +subset of C99 - in order to compile with GCC, Clang, MSVC, etc., we keep +local variable declarations at the tops of blocks only and avoid `//` style +comments. Additionally, `libgit2` follows some extra conventions for +function and type naming, code formatting, and testing. + +We like to keep the source code consistent and easy to read. Maintaining +this takes some discipline, but it's been more than worth it. Take a look +at the [conventions +file](https://github.com/libgit2/libgit2/blob/development/CONVENTIONS.md). + +## Starter Projects + +See our [projects +list](https://github.com/libgit2/libgit2/blob/development/PROJECTS.md). diff --git a/deps/libgit2-sys-0.2.17/libgit2/CONVENTIONS.md b/deps/libgit2-sys-0.2.17/libgit2/CONVENTIONS.md new file mode 100644 index 000000000..5b8238a78 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/CONVENTIONS.md @@ -0,0 +1,234 @@ +# Libgit2 Conventions + +We like to keep the source consistent and readable. Herein are some +guidelines that should help with that. + +## Compatibility + +`libgit2` runs on many different platforms with many different compilers. + +The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C) +(a.k.a. C89) compatible. + +Internally, `libgit2` is written using a portable subset of C99 - in order +to maximize compatibility (e.g. with MSVC) we avoid certain C99 +extensions. Specifically, we keep local variable declarations at the tops +of blocks only and we avoid `//` style comments. + +Also, to the greatest extent possible, we try to avoid lots of `#ifdef`s +inside the core code base. This is somewhat unavoidable, but since it can +really hamper maintainability, we keep it to a minimum. + +## Match Surrounding Code + +If there is one rule to take away from this document, it is *new code should +match the surrounding code in a way that makes it impossible to distinguish +the new from the old.* Consistency is more important to us than anyone's +personal opinion about where braces should be placed or spaces vs. tabs. + +If a section of code is being completely rewritten, it is okay to bring it +in line with the standards that are laid out here, but we will not accept +submissions that contain a large number of changes that are merely +reformatting. + +## Naming Things + +All external types and functions start with `git_` and all `#define` macros +start with `GIT_`. The `libgit2` API is mostly broken into related +functional modules each with a corresponding header. All functions in a +module should be named like `git_modulename_functioname()` +(e.g. `git_repository_open()`). + +Functions with a single output parameter should name that parameter `out`. +Multiple outputs should be named `foo_out`, `bar_out`, etc. + +Parameters of type `git_oid` should be named `id`, or `foo_id`. Calls that +return an OID should be named `git_foo_id`. + +Where a callback function is used, the function should also include a +user-supplied extra input that is a `void *` named "payload" that will be +passed through to the callback at each invocation. + +## Typedefs + +Wherever possible, use `typedef`. In some cases, if a structure is just a +collection of function pointers, the pointer types don't need to be +separately typedef'd, but loose function pointer types should be. + +## Exports + +All exported functions must be declared as: + +```c +GIT_EXTERN(result_type) git_modulename_functionname(arg_list); +``` + +## Internals + +Functions whose *modulename* is followed by two underscores, +for example `git_odb__read_packed`, are semi-private functions. +They are primarily intended for use within the library itself, +and may disappear or change their signature in a future release. + +## Parameters + +Out parameters come first. + +Whenever possible, pass argument pointers as `const`. Some structures (such +as `git_repository` and `git_index`) have mutable internal structure that +prevents this. + +Callbacks should always take a `void *` payload as their last parameter. +Callback pointers are grouped with their payloads, and typically come last +when passed as arguments: + +```c +int git_foo(git_repository *repo, git_foo_cb callback, void *payload); +``` + +## Memory Ownership + +Some APIs allocate memory which the caller is responsible for freeing; others +return a pointer into a buffer that's owned by some other object. Make this +explicit in the documentation. + +## Return codes + +Most public APIs should return an `int` error code. As is typical with most +C library functions, a zero value indicates success and a negative value +indicates failure. + +Some bindings will transform these returned error codes into exception +types, so returning a semantically appropriate error code is important. +Check +[`include/git2/errors.h`](https://github.com/libgit2/libgit2/blob/development/include/git2/errors.h) +for the return codes already defined. + +In your implementation, use `giterr_set()` to provide extended error +information to callers. + +If a `libgit2` function internally invokes another function that reports an +error, but the error is not propagated up, use `giterr_clear()` to prevent +callers from getting the wrong error message later on. + + +## Structs + +Most public types should be opaque, e.g.: + +```C +typedef struct git_odb git_odb; +``` + +...with allocation functions returning an "instance" created within +the library, and not within the application. This allows the type +to grow (or shrink) in size without rebuilding client code. + +To preserve ABI compatibility, include an `int version` field in all opaque +structures, and initialize to the latest version in the construction call. +Increment the "latest" version whenever the structure changes, and try to only +append to the end of the structure. + +## Option Structures + +If a function's parameter count is too high, it may be desirable to package +up the options in a structure. Make them transparent, include a version +field, and provide an initializer constant or constructor. Using these +structures should be this easy: + +```C +git_foo_options opts = GIT_FOO_OPTIONS_INIT; +opts.baz = BAZ_OPTION_ONE; +git_foo(&opts); +``` + +## Enumerations + +Typedef all enumerated types. If each option stands alone, use the enum +type for passing them as parameters; if they are flags to be OR'ed together, +pass them as `unsigned int` or `uint32_t` or some appropriate type. + +## Code Layout + +Try to keep lines less than 80 characters long. This is a loose +requirement, but going significantly over 80 columns is not nice. + +Use common sense to wrap most code lines; public function declarations +can use a couple of different styles: + +```c +/** All on one line is okay if it fits */ +GIT_EXTERN(int) git_foo_simple(git_oid *id); + +/** Otherwise one argument per line is a good next step */ +GIT_EXTERN(int) git_foo_id( + git_oid **out, + int a, + int b); +``` + +Indent with tabs; set your editor's tab width to 4 for best effect. + +Avoid trailing whitespace and only commit Unix-style newlines (i.e. no CRLF +in the repository - just set `core.autocrlf` to true if you are writing code +on a Windows machine). + +## Documentation + +All comments should conform to Doxygen "javadoc" style conventions for +formatting the public API documentation. Try to document every parameter, +and keep the comments up to date if you change the parameter list. + +## Public Header Template + +Use this template when creating a new public header. + +```C +#ifndef INCLUDE_git_${filename}_h__ +#define INCLUDE_git_${filename}_h__ + +#include "git/common.h" + +/** + * @file git/${filename}.h + * @brief Git some description + * @defgroup git_${filename} some description routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/* ... definitions ... */ + +/** @} */ +GIT_END_DECL +#endif +``` + +## Inlined functions + +All inlined functions must be declared as: + +```C +GIT_INLINE(result_type) git_modulename_functionname(arg_list); +``` + +`GIT_INLINE` (or `inline`) should not be used in public headers in order +to preserve ANSI C compatibility. + +## Tests + +`libgit2` uses the [clar](https://github.com/vmg/clar) testing framework. + +All PRs should have corresponding tests. + +* If the PR fixes an existing issue, the test should fail prior to applying + the PR and succeed after applying it. +* If the PR is for new functionality, then the tests should exercise that + new functionality to a certain extent. We don't require 100% coverage + right now (although we are getting stricter over time). + +When adding new tests, we prefer if you attempt to reuse existing test data +(in `tests-clar/resources/`) if possible. If you are going to add new test +repositories, please try to strip them of unnecessary files (e.g. sample +hooks, etc). diff --git a/deps/libgit2-sys-0.2.17/libgit2/COPYING b/deps/libgit2-sys-0.2.17/libgit2/COPYING new file mode 100644 index 000000000..6f6115e3b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/COPYING @@ -0,0 +1,914 @@ + libgit2 is Copyright (C) the libgit2 contributors, + unless otherwise stated. See the AUTHORS file for details. + + Note that the only valid version of the GPL as far as this project + is concerned is _this_ particular version of the license (ie v2, not + v2.2 or v3.x or whatever), unless explicitly otherwise stated. + +---------------------------------------------------------------------- + + LINKING EXCEPTION + + In addition to the permissions in the GNU General Public License, + the authors give you unlimited permission to link the compiled + version of this library into combinations with other programs, + and to distribute those combinations without any restriction + coming from the use of this file. (The General Public License + restrictions do apply in other respects; for example, they cover + modification of the file, and distribution when not linked into + a combined executable.) + +---------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + +---------------------------------------------------------------------- + +The bundled ZLib code is licensed under the ZLib license: + +Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +---------------------------------------------------------------------- + +The Clar framework is licensed under the ISC license: + +Copyright (c) 2011-2015 Vicent Marti + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +---------------------------------------------------------------------- + +The regex library (deps/regex/) is licensed under the GNU LGPL + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + +---------------------------------------------------------------------- diff --git a/deps/libgit2-sys-0.2.17/libgit2/Makefile.embed b/deps/libgit2-sys-0.2.17/libgit2/Makefile.embed new file mode 100644 index 000000000..eb8a78ebf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/Makefile.embed @@ -0,0 +1,60 @@ +PLATFORM=$(shell uname -s) + +ifneq (,$(CROSS_COMPILE)) + PREFIX=$(CROSS_COMPILE)- +else + PREFIX= +endif + +MINGW=0 +ifneq (,$(findstring MINGW32,$(PLATFORM))) + MINGW=1 +endif +ifneq (,$(findstring mingw,$(CROSS_COMPILE))) + MINGW=1 +endif + +rm=rm -f +AR=$(PREFIX)ar cq +RANLIB=$(PREFIX)ranlib + +LIBNAME=libgit2.a + +ifeq ($(MINGW),1) + CC=gcc +else + CC=cc +endif + +CC:=$(PREFIX)$(CC) + +INCLUDES= -I. -Isrc -Iinclude -Ideps/http-parser -Ideps/zlib + +DEFINES= $(INCLUDES) -DNO_VIZ -DSTDC -DNO_GZIP -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $(EXTRA_DEFINES) +CFLAGS= -g $(DEFINES) -Wall -Wextra -Wno-missing-field-initializers -O2 $(EXTRA_CFLAGS) + +SRCS = $(wildcard src/*.c) $(wildcard src/transports/*.c) $(wildcard src/xdiff/*.c) $(wildcard deps/http-parser/*.c) $(wildcard deps/zlib/*.c) src/hash/hash_generic.c + +ifeq ($(MINGW),1) + SRCS += $(wildcard src/win32/*.c) $(wildcard src/compat/*.c) deps/regex/regex.c + INCLUDES += -Ideps/regex + DEFINES += -DWIN32 -D_WIN32_WINNT=0x0501 -D__USE_MINGW_ANSI_STDIO=1 +else + SRCS += $(wildcard src/unix/*.c) + CFLAGS += -fPIC +endif + +OBJS = $(patsubst %.c,%.o,$(SRCS)) + +%.c.o: + $(CC) $(CFLAGS) -c $*.c + +all: $(LIBNAME) + +$(LIBNAME): $(OBJS) + $(rm) $@ + $(AR) $@ $(OBJS) + $(RANLIB) $@ + +clean: + $(rm) $(OBJS) $(LIBNAME) diff --git a/deps/libgit2-sys-0.2.17/libgit2/PROJECTS.md b/deps/libgit2-sys-0.2.17/libgit2/PROJECTS.md new file mode 100644 index 000000000..4f200b7f9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/PROJECTS.md @@ -0,0 +1,101 @@ +Projects For LibGit2 +==================== + +So, you want to start helping out with `libgit2`? That's fantastic! We +welcome contributions and we promise we'll try to be nice. + +This is a list of libgit2 related projects that new contributors can take +on. It includes a number of good starter projects and well as some larger +ideas that no one is actively working on. + +## Before You Start + +Please start by reading the [README.md](README.md), +[CONTRIBUTING.md](CONTRIBUTING.md), and [CONVENTIONS.md](CONVENTIONS.md) +files before diving into one of these projects. Those explain our work +flow and coding conventions to help ensure that your work will be easily +integrated into libgit2. + +Next, work through the build instructions and make sure you can clone the +repository, compile it, and run the tests successfully. That will make +sure that your development environment is set up correctly and you are +ready to start on libgit2 development. + +## Starter Projects + +These are good small projects to get started with libgit2. + +* Look at the `examples/` programs, find an existing one that mirrors a + core Git command and add a missing command-line option. There are many + gaps right now and this helps demonstrate how to use the library. Here + are some specific ideas (though there are many more): + * Fix the `examples/diff.c` implementation of the `-B` + (a.k.a. `--break-rewrites`) command line option to actually look for + the optional `[][/]` configuration values. There is an + existing comment that reads `/* TODO: parse thresholds */`. The + trick to this one will be doing it in a manner that is clean and + simple, but still handles the various cases correctly (e.g. `-B/70%` + is apparently a legal setting). + * Implement the `--log-size` option for `examples/log.c`. I think all + the data is available, you would just need to add the code into the + `print_commit()` routine (along with a way of passing the option + into that function). + * As an extension to the matching idea for `examples/log.c`, add the + `-i` option to use `strcasestr()` for matches. + * For `examples/log.c`, implement the `--first-parent` option now that + libgit2 supports it in the revwalk API. +* Pick a Git command that is not already emulated in `examples/` and write + a new example that mirrors the behavior. Examples don't have to be + perfect emulations, but should demonstrate how to use the libgit2 APIs + to get results that are similar to Git commands. This lets you (and us) + easily exercise a particular facet of the API and measure compatability + and feature parity with core git. +* Submit a PR to clarify documentation! While we do try to document all of + the APIs, your fresh eyes on the documentation will find areas that are + confusing much more easily. + +If none of these appeal to you, take a look at our issues list to see if +there are any unresolved issues you'd like to jump in on. + +## Larger Projects + +These are ideas for larger projects mostly taken from our backlog of +[Issues](https://github.com/libgit2/libgit2/issues). Please don't dive +into one of these as a first project for libgit2 - we'd rather get to +know you first by successfully shipping your work on one of the smaller +projects above. + +Some of these projects are broken down into subprojects and/or have +some incremental steps listed towards the larger goal. Those steps +might make good smaller projects by themselves. + +* Port part of the Git test suite to run against the command line emulation + in examples/ + * Pick a Git command that is emulated in our examples/ area + * Extract the Git tests that exercise that command + * Convert the tests to call our emulation + * These tests could go in examples/tests/... +* Fix symlink support for files in the .git directory (i.e. don't overwrite + the symlinks when writing the file contents back out) +* Add hooks API to enumerate and manage hooks (not run them at this point) + * Enumeration of available hooks + * Lookup API to see which hooks have a script and get the script + * Read/write API to load a hook script and write a hook script + * Eventually, callback API to invoke a hook callback when libgit2 + executes the action in question +* Isolate logic of ignore evaluation into a standalone API +* Upgrade internal libxdiff code to latest from core Git +* Improve index internals with hashtable lookup for files instead of + using binary search every time +* Tree builder improvements: + * Extend to allow building a tree hierarchy +* Apply-patch API +* Add a patch editing API to enable "git add -p" type operations +* Textconv API to filter binary data before generating diffs (something + like the current Filter API, probably). +* Performance profiling and improvement +* Support "git replace" ref replacements +* Include conflicts in diff results and in status + * GIT_DELTA_CONFLICT for items in conflict (with multiple files) + * Appropriate flags for status +* Support sparse checkout (i.e. "core.sparsecheckout" and ".git/info/sparse-checkout") diff --git a/deps/libgit2-sys-0.2.17/libgit2/README.md b/deps/libgit2-sys-0.2.17/libgit2/README.md new file mode 100644 index 000000000..882924231 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/README.md @@ -0,0 +1,244 @@ +libgit2 - the Git linkable library +================================== + +[![Travis Build Status](https://secure.travis-ci.org/libgit2/libgit2.svg?branch=master)](http://travis-ci.org/libgit2/libgit2) +[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/xvof5b4t5480a2q3/branch/master?svg=true)](https://ci.appveyor.com/project/libgit2/libgit2/branch/master) +[![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) + +`libgit2` is a portable, pure C implementation of the Git core methods +provided as a re-entrant linkable library with a solid API, allowing you to +write native speed custom Git applications in any language with bindings. + +`libgit2` is licensed under a **very permissive license** (GPLv2 with a special +Linking Exception). This basically means that you can link it (unmodified) +with any kind of software without having to release its source code. +Additionally, the example code has been released to the public domain (see the +[separate license](examples/COPYING) for more information). + +* Website: [libgit2.github.com](http://libgit2.github.com) +* StackOverflow Tag: [libgit2](http://stackoverflow.com/questions/tagged/libgit2) +* Issues: [GitHub Issues](https://github.com/libgit2/libgit2/issues) (Right here!) +* API documentation: +* IRC: [#libgit2](irc://irc.freenode.net/libgit2) on irc.freenode.net. +* Mailing list: The libgit2 mailing list was + traditionally hosted in Librelist but has been deprecated. We encourage you to + [use StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) instead for any questions regarding + the library, or [open an issue](https://github.com/libgit2/libgit2/issues) + on GitHub for bug reports. The mailing list archives are still available at + . + + +What It Can Do +============== + +`libgit2` is already very usable and is being used in production for many +applications including the GitHub.com site, in Plastic SCM and also powering +Microsoft's Visual Studio tools for Git. The library provides: + +* SHA conversions, formatting and shortening +* abstracted ODB backend system +* commit, tag, tree and blob parsing, editing, and write-back +* tree traversal +* revision walking +* index file (staging area) manipulation +* reference management (including packed references) +* config file management +* high level repository management +* thread safety and reentrancy +* descriptive and detailed error messages +* ...and more (over 175 different API calls) + +Optional dependencies +===================== + +While the library provides git functionality without the need for +dependencies, it can make use of a few libraries to add to it: + +- pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation +- OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions +- LibSSH2 to enable the SSH transport +- iconv (OSX) to handle the HFS+ path encoding peculiarities + +Initialization +=============== + +The library needs to keep track of some global state. Call + + git_libgit2_init(); + +before calling any other libgit2 functions. You can call this function many times. A matching number of calls to + + git_libgit2_shutdown(); + +will free the resources. Note that if you have worker threads, you should +call `git_libgit2_shutdown` *after* those threads have exited. If you +require assistance coordinating this, simply have the worker threads call +`git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown. + +Threading +========= + +See [THREADING](THREADING.md) for information + +Building libgit2 - Using CMake +============================== + +`libgit2` builds cleanly on most platforms without any external dependencies. +Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available; +they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API +for threading. + +The `libgit2` library is built using [CMake]() (version 2.6 or newer) on all platforms. + +On most systems you can build the library using the following commands + + $ mkdir build && cd build + $ cmake .. + $ cmake --build . + +Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace. + +To install the library you can specify the install prefix by setting: + + $ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix + $ cmake --build . --target install + +For more advanced use or questions about CMake please read . + +The following CMake variables are declared: + +- `BIN_INSTALL_DIR`: Where to install binaries to. +- `LIB_INSTALL_DIR`: Where to install libraries to. +- `INCLUDE_INSTALL_DIR`: Where to install headers to. +- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON) +- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON) +- `THREADSAFE`: Build libgit2 with threading support (defaults to ON) +- `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON) + +Compiler and linker options +--------------------------- + +CMake lets you specify a few variables to control the behavior of the +compiler and linker. These flags are rarely used but can be useful for +64-bit to 32-bit cross-compilation. + +- `CMAKE_C_FLAGS`: Set your own compiler flags +- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries +- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`: +Tell CMake where to find those specific libraries + +MacOS X +------- + +If you want to build a universal binary for Mac OS X, CMake sets it +all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"` +when configuring. + +Windows +------- + +You need to run the CMake commands from the Visual Studio command +prompt, not the regular or Windows SDK one. Select the right generator +for your version with the `-G "Visual Studio X" option. + +See [the website](https://libgit2.github.com/docs/guides/build-and-link) +for more detailed instructions. + +Android +------- + +Extract toolchain from NDK using, `make-standalone-toolchain.sh` script. +Optionally, crosscompile and install OpenSSL inside of it. Then create CMake +toolchain file that configures paths to your crosscompiler (substitute `{PATH}` +with full path to the toolchain): + + SET(CMAKE_SYSTEM_NAME Linux) + SET(CMAKE_SYSTEM_VERSION Android) + + SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc) + SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++) + SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/) + + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile} -DANDROID=1` to cmake command +when configuring. + +Language Bindings +================================== + +Here are the bindings to libgit2 that are currently available: + +* C++ + * libqgit2, Qt bindings +* Chicken Scheme + * chicken-git +* D + * dlibgit +* Delphi + * GitForDelphi +* Erlang + * Geef +* Go + * git2go +* GObject + * libgit2-glib +* Haskell + * hgit2 +* Java + * Jagged +* Julia + * LibGit2.jl +* Lua + * luagit2 +* .NET + * libgit2sharp +* Node.js + * node-gitteh + * nodegit +* Objective-C + * objective-git +* OCaml + * libgit2-ocaml +* Parrot Virtual Machine + * parrot-libgit2 +* Perl + * Git-Raw +* PHP + * php-git +* PowerShell + * GitPowerShell +* Python + * pygit2 +* R + * git2r +* Ruby + * Rugged +* Rust + * git2-rs +* Swift + * Gift +* Vala + * libgit2.vapi + +If you start another language binding to libgit2, please let us know so +we can add it to the list. + +How Can I Contribute? +================================== + +Check the [contribution guidelines](CONTRIBUTING.md) to understand our +workflow, the libgit2 [coding conventions](CONVENTIONS.md), and out list of +[good starting projects](PROJECTS.md). + +License +================================== + +`libgit2` is under GPL2 **with linking exception**. This means you can link to +and use the library from any program, proprietary or open source; paid or +gratis. However, you cannot modify libgit2 and distribute it without +supplying the source. + +See the [COPYING file](COPYING) for the full license text. diff --git a/deps/libgit2-sys-0.2.17/libgit2/THREADING.md b/deps/libgit2-sys-0.2.17/libgit2/THREADING.md new file mode 100644 index 000000000..c9bee5184 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/THREADING.md @@ -0,0 +1,89 @@ +Threads in libgit2 +================== + +You may safely use any libgit2 object from any thread, though there +may be issues depending on the cryptographic libraries libgit2 or its +dependencies link to (more on this later). For libgit2 itself, +provided you take the following into consideration you won't run into +issues: + +Sharing objects +--------------- + +Use an object from a single thread at a time. Most data structures do +not guard against concurrent access themselves. This is because they +are rarely used in isolation and it makes more sense to synchronize +access via a larger lock or similar mechanism. + +There are some objects which are read-only/immutable and are thus safe +to share across threads, such as references and configuration +snapshots. + +Error messages +-------------- + +The error message is thread-local. The `giterr_last()` call must +happen on the same thread as the error in order to get the +message. Often this will be the case regardless, but if you use +something like the [GCD](http://en.wikipedia.org/wiki/Grand_Central_Dispatch) +on Mac OS X (where code is executed on an arbitrary thread), the code +must make sure to retrieve the error code on the thread where the error +happened. + +Threads and cryptographic libraries +======================================= + +On Windows +---------- + +When built as a native Windows DLL, libgit2 uses WinCNG and WinHTTP, +both of which are thread-safe. You do not need to do anything special. + +When using libssh2 which itself uses WinCNG, there are no special +steps necessary. If you are using a MinGW or similar environment where +libssh2 uses OpenSSL or libgcrypt, then the non-Windows case affects +you. + +Non-Windows +----------- + +On the rest of the platforms, libgit2 uses OpenSSL to be able to use +HTTPS as a transport. This library is made to be thread-implementation +agnostic, and the users of the library must set which locking function +it should use. This means that libgit2 cannot know what to set as the +user of libgit2 may use OpenSSL independently and the locking settings +must survive libgit2 shutting down. + +libgit2 does provide a last-resort convenience function +`git_openssl_set_locking()` (available in `sys/openssl.h`) to use the +platform-native mutex mechanisms to perform the locking, which you may +rely on if you do not want to use OpenSSL outside of libgit2, or you +know that libgit2 will outlive the rest of the operations. It is not +safe to use OpenSSL multi-threaded after libgit2's shutdown function +has been called. + +If your programming language offers a package/bindings for OpenSSL, +you should very strongly prefer to use that in order to set up +locking, as they provide a level of coördination which is impossible +when using this function. + +See the +[OpenSSL documentation](https://www.openssl.org/docs/crypto/threads.html) +on threading for more details. + +Be also aware that libgit2 may not always link against OpenSSL in the +future if there are alternatives provided by the system. + +libssh2 may be linked against OpenSSL or libgcrypt. If it uses +OpenSSL, you only need to set up threading for OpenSSL once and the +above paragraphs are enough. If it uses libgcrypt, then you need to +set up its locking before using it multi-threaded. libgit2 has no +direct connection to libgcrypt and thus has not convenience functions for +it (but libgcrypt has macros). Read libgcrypt's +[threading documentation for more information](http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html) + +It is your responsibility as an application author or packager to know +what your dependencies are linked against and to take the appropriate +steps to ensure the cryptographic libraries are thread-safe. We agree +that this situation is far from ideal but at this time it is something +the application authors need to deal with. diff --git a/deps/libgit2-sys-0.2.17/libgit2/api.docurium b/deps/libgit2-sys-0.2.17/libgit2/api.docurium new file mode 100644 index 000000000..9e17817db --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/api.docurium @@ -0,0 +1,13 @@ +{ + "name": "libgit2", + "github": "libgit2/libgit2", + "input": "include/git2", + "prefix": "git_", + "output": "docs", + "branch": "gh-pages", + "examples": "examples", + "legacy": { + "input": {"src/git": ["v0.1.0"], + "src/git2": ["v0.2.0", "v0.3.0"]} + } +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/appveyor.yml b/deps/libgit2-sys-0.2.17/libgit2/appveyor.yml new file mode 100644 index 000000000..cf9564b6d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/appveyor.yml @@ -0,0 +1,38 @@ +version: '{build}' +branches: + only: + - master +environment: + GITTEST_INVASIVE_FS_STRUCTURE: 1 + GITTEST_INVASIVE_FS_SIZE: 1 + + matrix: + - GENERATOR: "Visual Studio 11" + ARCH: 32 + - GENERATOR: "Visual Studio 11 Win64" + ARCH: 64 + - GENERATOR: "MSYS Makefiles" + ARCH: 32 + - GENERATOR: "MSYS Makefiles" + ARCH: i686 # this is for 32-bit MinGW-w64 + - GENERATOR: "MSYS Makefiles" + ARCH: 64 +matrix: + allow_failures: + - GENERATOR: "MSYS Makefiles" + ARCH: 32 +cache: +- i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z +- x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z +build_script: +- ps: | + mkdir build + cd build + if ($env:GENERATOR -ne "MSYS Makefiles") { + cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$env:GENERATOR" + cmake --build . --config RelWithDebInfo + } +- cmd: | + if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh) +test_script: +- ps: ctest -V . diff --git a/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/AddCFlagIfSupported.cmake b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/AddCFlagIfSupported.cmake new file mode 100644 index 000000000..67fc89510 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/AddCFlagIfSupported.cmake @@ -0,0 +1,16 @@ +# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it +# ADD_C_FLAG_IF_SUPPORTED() +# - the compiler flag to test +# This internally calls the CHECK_C_COMPILER_FLAG macro. + +INCLUDE(CheckCCompilerFlag) + +MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG) + STRING(TOUPPER ${_FLAG} UPCASE) + STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE}) + CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED) + + IF(IS_${UPCASE_PRETTY}_SUPPORTED) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}") + ENDIF() +ENDMACRO() diff --git a/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindGSSAPI.cmake b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindGSSAPI.cmake new file mode 100644 index 000000000..8520d35df --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindGSSAPI.cmake @@ -0,0 +1,324 @@ +# - Try to find GSSAPI +# Once done this will define +# +# KRB5_CONFIG - Path to krb5-config +# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI +# +# Read-Only variables: +# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found +# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Keberos has been found +# GSSAPI_FOUND - system has GSSAPI +# GSSAPI_INCLUDE_DIR - the GSSAPI include directory +# GSSAPI_LIBRARIES - Link these to use GSSAPI +# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI +# +#============================================================================= +# Copyright (c) 2013 Andreas Schneider +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# + +find_path(GSSAPI_ROOT_DIR + NAMES + include/gssapi.h + include/gssapi/gssapi.h + HINTS + ${_GSSAPI_ROOT_HINTS} + PATHS + ${_GSSAPI_ROOT_PATHS} +) +mark_as_advanced(GSSAPI_ROOT_DIR) + +if (UNIX) + find_program(KRB5_CONFIG + NAMES + krb5-config + PATHS + ${GSSAPI_ROOT_DIR}/bin + /opt/local/bin) + mark_as_advanced(KRB5_CONFIG) + + if (KRB5_CONFIG) + # Check if we have MIT KRB5 + execute_process( + COMMAND + ${KRB5_CONFIG} --vendor + RESULT_VARIABLE + _GSSAPI_VENDOR_RESULT + OUTPUT_VARIABLE + _GSSAPI_VENDOR_STRING) + + if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*") + set(GSSAPI_FLAVOR_MIT TRUE) + else() + execute_process( + COMMAND + ${KRB5_CONFIG} --libs gssapi + RESULT_VARIABLE + _GSSAPI_LIBS_RESULT + OUTPUT_VARIABLE + _GSSAPI_LIBS_STRING) + + if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*") + set(GSSAPI_FLAVOR_HEIMDAL TRUE) + endif() + endif() + + # Get the include dir + execute_process( + COMMAND + ${KRB5_CONFIG} --cflags gssapi + RESULT_VARIABLE + _GSSAPI_INCLUDE_RESULT + OUTPUT_VARIABLE + _GSSAPI_INCLUDE_STRING) + string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}") + string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}") + endif() + + if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL) + # Check for HEIMDAL + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_GSSAPI heimdal-gssapi) + endif (PKG_CONFIG_FOUND) + + if (_GSSAPI_FOUND) + set(GSSAPI_FLAVOR_HEIMDAL TRUE) + else() + find_path(_GSSAPI_ROKEN + NAMES + roken.h + PATHS + ${GSSAPI_ROOT_DIR}/include + ${_GSSAPI_INCLUDEDIR}) + if (_GSSAPI_ROKEN) + set(GSSAPI_FLAVOR_HEIMDAL TRUE) + endif() + endif () + endif() +endif (UNIX) + +find_path(GSSAPI_INCLUDE_DIR + NAMES + gssapi.h + gssapi/gssapi.h + PATHS + ${GSSAPI_ROOT_DIR}/include + ${_GSSAPI_INCLUDEDIR} +) + +if (GSSAPI_FLAVOR_MIT) + find_library(GSSAPI_LIBRARY + NAMES + gssapi_krb5 + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(KRB5_LIBRARY + NAMES + krb5 + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(K5CRYPTO_LIBRARY + NAMES + k5crypto + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(COM_ERR_LIBRARY + NAMES + com_err + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + if (GSSAPI_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${GSSAPI_LIBRARY} + ) + endif (GSSAPI_LIBRARY) + + if (KRB5_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${KRB5_LIBRARY} + ) + endif (KRB5_LIBRARY) + + if (K5CRYPTO_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${K5CRYPTO_LIBRARY} + ) + endif (K5CRYPTO_LIBRARY) + + if (COM_ERR_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${COM_ERR_LIBRARY} + ) + endif (COM_ERR_LIBRARY) +endif (GSSAPI_FLAVOR_MIT) + +if (GSSAPI_FLAVOR_HEIMDAL) + find_library(GSSAPI_LIBRARY + NAMES + gssapi + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(KRB5_LIBRARY + NAMES + krb5 + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(HCRYPTO_LIBRARY + NAMES + hcrypto + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(COM_ERR_LIBRARY + NAMES + com_err + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(HEIMNTLM_LIBRARY + NAMES + heimntlm + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(HX509_LIBRARY + NAMES + hx509 + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(ASN1_LIBRARY + NAMES + asn1 + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(WIND_LIBRARY + NAMES + wind + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + find_library(ROKEN_LIBRARY + NAMES + roken + PATHS + ${GSSAPI_ROOT_DIR}/lib + ${_GSSAPI_LIBDIR} + ) + + if (GSSAPI_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${GSSAPI_LIBRARY} + ) + endif (GSSAPI_LIBRARY) + + if (KRB5_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${KRB5_LIBRARY} + ) + endif (KRB5_LIBRARY) + + if (HCRYPTO_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${HCRYPTO_LIBRARY} + ) + endif (HCRYPTO_LIBRARY) + + if (COM_ERR_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${COM_ERR_LIBRARY} + ) + endif (COM_ERR_LIBRARY) + + if (HEIMNTLM_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${HEIMNTLM_LIBRARY} + ) + endif (HEIMNTLM_LIBRARY) + + if (HX509_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${HX509_LIBRARY} + ) + endif (HX509_LIBRARY) + + if (ASN1_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${ASN1_LIBRARY} + ) + endif (ASN1_LIBRARY) + + if (WIND_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${WIND_LIBRARY} + ) + endif (WIND_LIBRARY) + + if (ROKEN_LIBRARY) + set(GSSAPI_LIBRARIES + ${GSSAPI_LIBRARIES} + ${WIND_LIBRARY} + ) + endif (ROKEN_LIBRARY) +endif (GSSAPI_FLAVOR_HEIMDAL) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR) + +if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES) + set(GSSAPI_FOUND TRUE) +endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES) + +# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view +mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES) diff --git a/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindHTTP_Parser.cmake b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindHTTP_Parser.cmake new file mode 100644 index 000000000..d92bf75cc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindHTTP_Parser.cmake @@ -0,0 +1,39 @@ +# - Try to find http-parser +# +# Defines the following variables: +# +# HTTP_PARSER_FOUND - system has http-parser +# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory +# HTTP_PARSER_LIBRARIES - Link these to use http-parser +# HTTP_PARSER_VERSION_MAJOR - major version +# HTTP_PARSER_VERSION_MINOR - minor version +# HTTP_PARSER_VERSION_STRING - the version of http-parser found + +# Find the header and library +FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h) +FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser) + +# Found the header, read version +if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h") + FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H) + IF (HTTP_PARSER_H) + STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}") + STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}") + SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}") + ENDIF() + UNSET(HTTP_PARSER_H) +ENDIF() + +# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND +# to TRUE if all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) + +# Hide advanced variables +MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) + +# Set standard variables +IF (HTTP_PARSER_FOUND) + SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY}) + set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR}) +ENDIF() diff --git a/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindIconv.cmake b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindIconv.cmake new file mode 100644 index 000000000..c5a419011 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/cmake/Modules/FindIconv.cmake @@ -0,0 +1,43 @@ +# - Try to find Iconv +# Once done this will define +# +# ICONV_FOUND - system has Iconv +# ICONV_INCLUDE_DIR - the Iconv include directory +# ICONV_LIBRARIES - Link these to use Iconv +# + +IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + # Already in cache, be silent + SET(ICONV_FIND_QUIETLY TRUE) +ENDIF() + +FIND_PATH(ICONV_INCLUDE_DIR iconv.h PATHS /opt/local/include NO_DEFAULT_PATH) +FIND_PATH(ICONV_INCLUDE_DIR iconv.h) + +FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c NO_DEFAULT_PATH PATHS /opt/local/lib) +FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c) + +IF(ICONV_INCLUDE_DIR AND iconv_lib) + SET(ICONV_FOUND TRUE) +ENDIF() + +IF(ICONV_FOUND) + # split iconv into -L and -l linker options, so we can set them for pkg-config + GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH) + GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE) + STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name}) + SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}") + + IF(NOT ICONV_FIND_QUIETLY) + MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") + ENDIF(NOT ICONV_FIND_QUIETLY) +ELSE() + IF(Iconv_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Iconv") + ENDIF(Iconv_FIND_REQUIRED) +ENDIF() + +MARK_AS_ADVANCED( + ICONV_INCLUDE_DIR + ICONV_LIBRARIES +) diff --git a/deps/libgit2-sys-0.2.17/libgit2/docs/checkout-internals.md b/deps/libgit2-sys-0.2.17/libgit2/docs/checkout-internals.md new file mode 100644 index 000000000..6147ffdd8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/docs/checkout-internals.md @@ -0,0 +1,204 @@ +Checkout Internals +================== + +Checkout has to handle a lot of different cases. It examines the +differences between the target tree, the baseline tree and the working +directory, plus the contents of the index, and groups files into five +categories: + +1. UNMODIFIED - Files that match in all places. +2. SAFE - Files where the working directory and the baseline content + match that can be safely updated to the target. +3. DIRTY/MISSING - Files where the working directory differs from the + baseline but there is no conflicting change with the target. One + example is a file that doesn't exist in the working directory - no + data would be lost as a result of writing this file. Which action + will be taken with these files depends on the options you use. +4. CONFLICTS - Files where changes in the working directory conflict + with changes to be applied by the target. If conflicts are found, + they prevent any other modifications from being made (although there + are options to override that and force the update, of course). +5. UNTRACKED/IGNORED - Files in the working directory that are untracked + or ignored (i.e. only in the working directory, not the other places). + +Right now, this classification is done via 3 iterators (for the three +trees), with a final lookup in the index. At some point, this may move to +a 4 iterator version to incorporate the index better. + +The actual checkout is done in five phases (at least right now). + +1. The diff between the baseline and the target tree is used as a base + list of possible updates to be applied. +2. Iterate through the diff and the working directory, building a list of + actions to be taken (and sending notifications about conflicts and + dirty files). +3. Remove any files / directories as needed (because alphabetical + iteration means that an untracked directory will end up sorted *after* + a blob that should be checked out with the same name). +4. Update all blobs. +5. Update all submodules (after 4 in case a new .gitmodules blob was + checked out) + +Checkout could be driven either off a target-to-workdir diff or a +baseline-to-target diff. There are pros and cons of each. + +Target-to-workdir means the diff includes every file that could be +modified, which simplifies bookkeeping, but the code to constantly refer +back to the baseline gets complicated. + +Baseline-to-target has simpler code because the diff defines the action to +take, but needs special handling for untracked and ignored files, if they +need to be removed. + +The current checkout implementation is based on a baseline-to-target diff. + + +Picking Actions +=============== + +The most interesting aspect of this is phase 2, picking the actions that +should be taken. There are a lot of corner cases, so it may be easier to +start by looking at the rules for a simple 2-iterator diff: + +Key +--- +- B1,B2,B3 - blobs with different SHAs, +- Bi - ignored blob (WD only) +- T1,T2,T3 - trees with different SHAs, +- Ti - ignored tree (WD only) +- x - nothing + +Diff with 2 non-workdir iterators +--------------------------------- + +| | Old | New | | +|----|-----|-----|------------------------------------------------------------| +| 0 | x | x | nothing | +| 1 | x | B1 | added blob | +| 2 | x | T1 | added tree | +| 3 | B1 | x | removed blob | +| 4 | B1 | B1 | unmodified blob | +| 5 | B1 | B2 | modified blob | +| 6 | B1 | T1 | typechange blob -> tree | +| 7 | T1 | x | removed tree | +| 8 | T1 | B1 | typechange tree -> blob | +| 9 | T1 | T1 | unmodified tree | +| 10 | T1 | T2 | modified tree (implies modified/added/removed blob inside) | + + +Now, let's make the "New" iterator into a working directory iterator, so +we replace "added" items with either untracked or ignored, like this: + +Diff with non-work & workdir iterators +-------------------------------------- + +| | Old | New | | +|----|-----|-----|------------------------------------------------------------| +| 0 | x | x | nothing | +| 1 | x | B1 | untracked blob | +| 2 | x | Bi | ignored file | +| 3 | x | T1 | untracked tree | +| 4 | x | Ti | ignored tree | +| 5 | B1 | x | removed blob | +| 6 | B1 | B1 | unmodified blob | +| 7 | B1 | B2 | modified blob | +| 8 | B1 | T1 | typechange blob -> tree | +| 9 | B1 | Ti | removed blob AND ignored tree as separate items | +| 10 | T1 | x | removed tree | +| 11 | T1 | B1 | typechange tree -> blob | +| 12 | T1 | Bi | removed tree AND ignored blob as separate items | +| 13 | T1 | T1 | unmodified tree | +| 14 | T1 | T2 | modified tree (implies modified/added/removed blob inside) | + +Note: if there is a corresponding entry in the old tree, then a working +directory item won't be ignored (i.e. no Bi or Ti for tracked items). + + +Now, expand this to three iterators: a baseline tree, a target tree, and +an actual working directory tree: + +Checkout From 3 Iterators (2 not workdir, 1 workdir) +---------------------------------------------------- + +(base == old HEAD; target == what to checkout; actual == working dir) + +| |base | target | actual/workdir | | +|-----|-----|------- |----------------|--------------------------------------------------------------------| +| 0 | x | x | x | nothing | +| 1 | x | x | B1/Bi/T1/Ti | untracked/ignored blob/tree (SAFE) | +| 2+ | x | B1 | x | add blob (SAFE) | +| 3 | x | B1 | B1 | independently added blob (FORCEABLE-2) | +| 4* | x | B1 | B2/Bi/T1/Ti | add blob with content conflict (FORCEABLE-2) | +| 5+ | x | T1 | x | add tree (SAFE) | +| 6* | x | T1 | B1/Bi | add tree with blob conflict (FORCEABLE-2) | +| 7 | x | T1 | T1/i | independently added tree (SAFE+MISSING) | +| 8 | B1 | x | x | independently deleted blob (SAFE+MISSING) | +| 9- | B1 | x | B1 | delete blob (SAFE) | +| 10- | B1 | x | B2 | delete of modified blob (FORCEABLE-1) | +| 11 | B1 | x | T1/Ti | independently deleted blob AND untrack/ign tree (SAFE+MISSING !!!) | +| 12 | B1 | B1 | x | locally deleted blob (DIRTY || SAFE+CREATE) | +| 13+ | B1 | B2 | x | update to deleted blob (SAFE+MISSING) | +| 14 | B1 | B1 | B1 | unmodified file (SAFE) | +| 15 | B1 | B1 | B2 | locally modified file (DIRTY) | +| 16+ | B1 | B2 | B1 | update unmodified blob (SAFE) | +| 17 | B1 | B2 | B2 | independently updated blob (FORCEABLE-1) | +| 18+ | B1 | B2 | B3 | update to modified blob (FORCEABLE-1) | +| 19 | B1 | B1 | T1/Ti | locally deleted blob AND untrack/ign tree (DIRTY) | +| 20* | B1 | B2 | T1/Ti | update to deleted blob AND untrack/ign tree (F-1) | +| 21+ | B1 | T1 | x | add tree with locally deleted blob (SAFE+MISSING) | +| 22* | B1 | T1 | B1 | add tree AND deleted blob (SAFE) | +| 23* | B1 | T1 | B2 | add tree with delete of modified blob (F-1) | +| 24 | B1 | T1 | T1 | add tree with deleted blob (F-1) | +| 25 | T1 | x | x | independently deleted tree (SAFE+MISSING) | +| 26 | T1 | x | B1/Bi | independently deleted tree AND untrack/ign blob (F-1) | +| 27- | T1 | x | T1 | deleted tree (MAYBE SAFE) | +| 28+ | T1 | B1 | x | deleted tree AND added blob (SAFE+MISSING) | +| 29 | T1 | B1 | B1 | independently typechanged tree -> blob (F-1) | +| 30+ | T1 | B1 | B2 | typechange tree->blob with conflicting blob (F-1) | +| 31* | T1 | B1 | T1/T2 | typechange tree->blob (MAYBE SAFE) | +| 32+ | T1 | T1 | x | restore locally deleted tree (SAFE+MISSING) | +| 33 | T1 | T1 | B1/Bi | locally typechange tree->untrack/ign blob (DIRTY) | +| 34 | T1 | T1 | T1/T2 | unmodified tree (MAYBE SAFE) | +| 35+ | T1 | T2 | x | update locally deleted tree (SAFE+MISSING) | +| 36* | T1 | T2 | B1/Bi | update to tree with typechanged tree->blob conflict (F-1) | +| 37 | T1 | T2 | T1/T2/T3 | update to existing tree (MAYBE SAFE) | + + +The number is followed by ' ' if no change is needed or '+' if the case +needs to write to disk or '-' if something must be deleted and '*' if +there should be a delete followed by an write. + +There are four tiers of safe cases: + +* SAFE == completely safe to update +* SAFE+MISSING == safe except the workdir is missing the expect content +* MAYBE SAFE == safe if workdir tree matches (or is missing) baseline + content, which is unknown at this point +* FORCEABLE == conflict unless FORCE is given +* DIRTY == no conflict but change is not applied unless FORCE + +Some slightly unusual circumstances: + +* 8 - parent dir is only deleted when file is, so parent will be left if + empty even though it would be deleted if the file were present +* 11 - core git does not consider this a conflict but attempts to delete T1 + and gives "unable to unlink file" error yet does not skip the rest + of the operation +* 12 - without FORCE file is left deleted (i.e. not restored) so new wd is + dirty (and warning message "D file" is printed), with FORCE, file is + restored. +* 24 - This should be considered MAYBE SAFE since effectively it is 7 and 8 + combined, but core git considers this a conflict unless forced. +* 26 - This combines two cases (1 & 25) (and also implied 8 for tree content) + which are ok on their own, but core git treat this as a conflict. + If not forced, this is a conflict. If forced, this actually doesn't + have to write anything and leaves the new blob as an untracked file. +* 32 - This is the only case where the baseline and target values match + and yet we will still write to the working directory. In all other + cases, if baseline == target, we don't touch the workdir (it is + either already right or is "dirty"). However, since this case also + implies that a ?/B1/x case will exist as well, it can be skipped. + +Cases 3, 17, 24, 26, and 29 are all considered conflicts even though +none of them will require making any updates to the working directory. + diff --git a/deps/libgit2-sys-0.2.17/libgit2/docs/diff-internals.md b/deps/libgit2-sys-0.2.17/libgit2/docs/diff-internals.md new file mode 100644 index 000000000..da4c5a17c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/docs/diff-internals.md @@ -0,0 +1,92 @@ +Diff is broken into four phases: + +1. Building a list of things that have changed. These changes are called + deltas (git_diff_delta objects) and are grouped into a git_diff_list. +2. Applying file similarity measurement for rename and copy detection (and + to potentially split files that have changed radically). This step is + optional. +3. Computing the textual diff for each delta. Not all deltas have a + meaningful textual diff. For those that do, the textual diff can + either be generated on the fly and passed to output callbacks or can be + turned into a git_diff_patch object. +4. Formatting the diff and/or patch into standard text formats (such as + patches, raw lists, etc). + +In the source code, step 1 is implemented in `src/diff.c`, step 2 in +`src/diff_tform.c`, step 3 in `src/diff_patch.c`, and step 4 in +`src/diff_print.c`. Additionally, when it comes to accessing file +content, everything goes through diff drivers that are implemented in +`src/diff_driver.c`. + +External Objects +---------------- + +* `git_diff_options` represents user choices about how a diff should be + performed and is passed to most diff generating functions. +* `git_diff_file` represents an item on one side of a possible delta +* `git_diff_delta` represents a pair of items that have changed in some + way - it contains two `git_diff_file` plus a status and other stuff. +* `git_diff_list` is a list of deltas along with information about how + those particular deltas were found. +* `git_diff_patch` represents the actual diff between a pair of items. In + some cases, a delta may not have a corresponding patch, if the objects + are binary, for example. The content of a patch will be a set of hunks + and lines. +* A `hunk` is range of lines described by a `git_diff_range` (i.e. "lines + 10-20 in the old file became lines 12-23 in the new"). It will have a + header that compactly represents that information, and it will have a + number of lines of context surrounding added and deleted lines. +* A `line` is simple a line of data along with a `git_diff_line_t` value + that tells how the data should be interpreted (e.g. context or added). + +Internal Objects +---------------- + +* `git_diff_file_content` is an internal structure that represents the + data on one side of an item to be diffed; it is an augmented + `git_diff_file` with more flags and the actual file data. + + * it is created from a repository plus a) a git_diff_file, b) a git_blob, + or c) raw data and size + * there are three main operations on git_diff_file_content: + + * _initialization_ sets up the data structure and does what it can up to, + but not including loading and looking at the actual data + * _loading_ loads the data, preprocesses it (i.e. applies filters) and + potentially analyzes it (to decide if binary) + * _free_ releases loaded data and frees any allocated memory + +* The internal structure of a `git_diff_patch` stores the actual diff + between a pair of `git_diff_file_content` items + + * it may be "unset" if the items are not diffable + * "empty" if the items are the same + * otherwise it will consist of a set of hunks each of which covers some + number of lines of context, additions and deletions + * a patch is created from two git_diff_file_content items + * a patch is fully instantiated in three phases: + + * initial creation and initialization + * loading of data and preliminary data examination + * diffing of data and optional storage of diffs + * (TBD) if a patch is asked to store the diffs and the size of the diff + is significantly smaller than the raw data of the two sides, then the + patch may be flattened using a pool of string data + +* `git_diff_output` is an internal structure that represents an output + target for a `git_diff_patch` + * It consists of file, hunk, and line callbacks, plus a payload + * There is a standard flattened output that can be used for plain text output + * Typically we use a `git_xdiff_output` which drives the callbacks via the + xdiff code taken from core Git. + +* `git_diff_driver` is an internal structure that encapsulates the logic + for a given type of file + * a driver is looked up based on the name and mode of a file. + * the driver can then be used to: + * determine if a file is binary (by attributes, by git_diff_options + settings, or by examining the content) + * give you a function pointer that is used to evaluate function context + for hunk headers + * At some point, the logic for getting a filtered version of file content + or calculating the OID of a file may be moved into the driver. diff --git a/deps/libgit2-sys-0.2.17/libgit2/docs/error-handling.md b/deps/libgit2-sys-0.2.17/libgit2/docs/error-handling.md new file mode 100644 index 000000000..2dbe64a71 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/docs/error-handling.md @@ -0,0 +1,270 @@ +Error reporting in libgit2 +========================== + +Libgit2 tries to follow the POSIX style: functions return an `int` value +with 0 (zero) indicating success and negative values indicating an error. +There are specific negative error codes for each "expected failure" +(e.g. `GIT_ENOTFOUND` for files that take a path which might be missing) +and a generic error code (-1) for all critical or non-specific failures +(e.g. running out of memory or system corruption). + +When a negative value is returned, an error message is also set. The +message can be accessed via the `giterr_last` function which will return a +pointer to a `git_error` structure containing the error message text and +the class of error (i.e. what part of the library generated the error). + +For instance: An object lookup by SHA prefix (`git_object_lookup_prefix`) +has two expected failure cases: the SHA is not found at all which returns +`GIT_ENOTFOUND` or the SHA prefix is ambiguous (i.e. two or more objects +share the prefix) which returns `GIT_EAMBIGUOUS`. There are any number of +critical failures (such as a packfile being corrupted, a loose object +having the wrong access permissions, etc.) all of which will return -1. +When the object lookup is successful, it will return 0. + +If libgit2 was compiled with threads enabled (`-DTHREADSAFE=ON` when using +CMake), then the error message will be kept in thread-local storage, so it +will not be modified by other threads. If threads are not enabled, then +the error message is in global data. + +All of the error return codes, the `git_error` type, the error access +functions, and the error classes are defined in `include/git2/errors.h`. +See the documentation there for details on the APIs for accessing, +clearing, and even setting error codes. + +When writing libgit2 code, please be smart and conservative when returning +error codes. Functions usually have a maximum of two or three "expected +errors" and in most cases only one. If you feel there are more possible +expected error scenarios, then the API you are writing may be at too high +a level for core libgit2. + +Example usage +------------- + +When using libgit2, you will typically capture the return value from +functions using an `int` variable and check to see if it is negative. +When that happens, you can, if you wish, look at the specific value or +look at the error message that was generated. + +~~~c +{ + git_repository *repo; + int error = git_repository_open(&repo, "path/to/repo"); + + if (error < 0) { + fprintf(stderr, "Could not open repository: %s\n", giterr_last()->message); + exit(1); + } + + ... use `repo` here ... + + git_repository_free(repo); /* void function - no error return code */ +} +~~~ + +Some of the error return values do have meaning. Optionally, you can look +at the specific error values to decide what to do. + +~~~c +{ + git_repository *repo; + const char *path = "path/to/repo"; + int error = git_repository_open(&repo, path); + + if (error < 0) { + if (error == GIT_ENOTFOUND) + fprintf(stderr, "Could not find repository at path '%s'\n", path); + else + fprintf(stderr, "Unable to open repository: %s\n", + giterr_last()->message); + exit(1); + } + + ... happy ... +} +~~~ + +Some of the higher-level language bindings may use a range of information +from libgit2 to convert error return codes into exceptions, including the +specific error return codes and even the class of error and the error +message returned by `giterr_last`, but the full range of that logic is +beyond the scope of this document. + +Example internal implementation +------------------------------- + +Internally, libgit2 detects error scenarios, records error messages, and +returns error values. Errors from low-level functions are generally +passed upwards (unless the higher level can either handle the error or +wants to translate the error into something more meaningful). + +~~~c +int git_repository_open(git_repository **repository, const char *path) +{ + /* perform some logic to open the repository */ + if (p_exists(path) < 0) { + giterr_set(GITERR_REPOSITORY, "The path '%s' doesn't exist", path); + return GIT_ENOTFOUND; + } + + ... +} +~~~ + +The public error API +-------------------- + +- `const git_error *giterr_last(void)`: The main function used to look up + the last error. This may return NULL if no error has occurred. + Otherwise this should return a `git_error` object indicating the class + of error and the error message that was generated by the library. + + The last error is stored in thread-local storage when libgit2 is + compiled with thread support, so you do not have to worry about another + thread overwriting the value. When thread support is off, the last + error is a global value. + + _Note_ There are some known bugs in the library where this may return + NULL even when an error code was generated. Please report these as + bugs, but in the meantime, please code defensively and check for NULL + when calling this function. + +- `void geterr_clear(void)`: This function clears the last error. The + library will call this when an error is generated by low level function + and the higher level function handles the error. + + _Note_ There are some known bugs in the library where a low level + function's error message is not cleared by higher level code that + handles the error and returns zero. Please report these as bugs, but in + the meantime, a zero return value from a libgit2 API does not guarantee + that `giterr_last()` will return NULL. + +- `void giterr_set_str(int error_class, const char *message)`: This + function can be used when writing a custom backend module to set the + libgit2 error message. See the documentation on this function for its + use. Normal usage of libgit2 will probably never need to call this API. + +- `void giterr_set_oom(void)`: This is a standard function for reporting + an out-of-memory error. It is written in a manner that it doesn't have + to allocate any extra memory in order to record the error, so this is + the best way to report that scenario. + +Deviations from the standard +---------------------------- + +There are some public functions that do not return `int` values. There +are two primary cases: + +* `void` return values: If a function has a `void` return, then it will + never fail. This primary will be used for object destructors. + +* `git_xyz *` return values: These are simple accessor functions where the + only meaningful error would typically be looking something up by index + and having the index be out of bounds. In those cases, the function + will typically return NULL. + +* Boolean return values: There are some cases where a function cannot fail + and wants to return a boolean value. In those cases, we try to return 1 + for true and 0 for false. These cases are rare and the return value for + the function should probably be an `unsigned int` to denote these cases. + If you find an exception, please open an issue and let's fix it. + +There are a few other exceptions to these rules here and there in the +library, but those are extremely rare and should probably be converted +over to other to more standard patterns for usage. Feel free to open +issues pointing these out. + +There are some known bugs in the library where some functions may return a +negative value but not set an error message and some other functions may +return zero (no error) and yet leave an error message set. Please report +these cases as issues and they will be fixed. In the meanwhile, please +code defensively, checking that the return value of `giterr_last` is not +NULL before using it, and not relying on `giterr_last` to return NULL when +a function returns 0 for success. + +The internal error API +---------------------- + +- `void giterr_set(int error_class, const char *fmt, ...)`: This is the + main internal function for setting an error. It works like `printf` to + format the error message. See the notes of `giterr_set_str` for a + general description of how error messages are stored (and also about + special handling for `error_class` of `GITERR_OS`). + +Writing error messages +---------------------- + +Here are some guidelines when writing error messages: + +- Use proper English, and an impersonal or past tenses: *The given path + does not exist*, *Failed to lookup object in ODB* + +- Use short, direct and objective messages. **One line, max**. libgit2 is + a low level library: think that all the messages reported will be thrown + as Ruby or Python exceptions. Think how long are common exception + messages in those languages. + +- **Do not add redundant information to the error message**, specially + information that can be inferred from the context. + + E.g. in `git_repository_open`, do not report a message like "Failed to + open repository: path not found". Somebody is calling that + function. If it fails, they already know that the repository failed to + open! + +General guidelines for error reporting +-------------------------------------- + +- Libgit2 does not handle programming errors with these + functions. Programming errors are `assert`ed, and when their source is + internal, fixed as soon as possible. This is C, people. + + Example of programming errors that would **not** be handled: passing + NULL to a function that expects a valid pointer; passing a `git_tree` + to a function that expects a `git_commit`. All these cases need to be + identified with `assert` and fixed asap. + + Example of a runtime error: failing to parse a `git_tree` because it + contains invalid data. Failing to open a file because it doesn't exist + on disk. These errors are handled, a meaningful error message is set, + and an error code is returned. + +- In general, *do not* try to overwrite errors internally and *do* + propagate error codes from lower level functions to the higher level. + There are some cases where propagating an error code will be more + confusing rather than less, so there are some exceptions to this rule, + but the default behavior should be to simply clean up and pass the error + on up to the caller. + + **WRONG** + + ~~~c + int git_commit_parent(...) + { + ... + + if (git_commit_lookup(parent, repo, parent_id) < 0) { + giterr_set(GITERR_COMMIT, "Overwrite lookup error message"); + return -1; /* mask error code */ + } + + ... + } + ~~~ + + **RIGHT** + + ~~~c + int git_commit_parent(...) + { + ... + + error = git_commit_lookup(parent, repo, parent_id); + if (error < 0) { + /* cleanup intermediate objects if necessary */ + /* leave error message and propagate error code */ + return error; + } + + ... + } + ~~~ diff --git a/deps/libgit2-sys-0.2.17/libgit2/docs/merge-df_conflicts.txt b/deps/libgit2-sys-0.2.17/libgit2/docs/merge-df_conflicts.txt new file mode 100644 index 000000000..09780ee2d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/docs/merge-df_conflicts.txt @@ -0,0 +1,41 @@ +Anc / Our / Thr represent the ancestor / ours / theirs side of a merge +from branch "branch" into HEAD. Workdir represents the expected files in +the working directory. Index represents the expected files in the index, +with stage markers. + + Anc Our Thr Workdir Index +1 D D + D/F D/F D/F [0] + +2 D D+ D~HEAD (mod/del) D/F [0] + D/F D/F D [1] + D [2] + +3 D D D/F D/F [0] + D/F + +4 D D+ D~branch (mod/del) D/F [0] + D/F D/F D [1] + D [3] + +5 D D/F (add/add) D/F [2] + D/F D/F [3] + D/F + +6 D/F D/F D D [0] + D + +7 D/F D/F+ D/F (mod/del) D/F [1] + D D~branch (fil/dir) D/F [2] + D [3] + +8 D/F D/F D D [0] + D + +9 D/F D/F+ D/F (mod/del) D/F [1] + D D~HEAD (fil/dir) D [2] + D/F [3] + +10 D/F D/F (fil/dir) D/F [0] + D D~HEAD D [2] + D diff --git a/deps/libgit2-sys-0.2.17/libgit2/git.git-authors b/deps/libgit2-sys-0.2.17/libgit2/git.git-authors new file mode 100644 index 000000000..9131a1fa1 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/git.git-authors @@ -0,0 +1,74 @@ +# This document lists the authors that have given voice to +# their decision regarding relicensing the GPL'd code from +# git.git to the GPL + gcc-exception license used by libgit2. +# +# Note that the permission is given for libgit2 use only. For +# other uses, you must ask each of the contributors yourself. +# +# To show the owners of a file in git.git, one can run the +# following command: +# +# git blame -C -C -M -- file | \ +# sed -e 's/[^(]*(\([^0-9]*\).*/\1/' -e 's/[\t ]*$//' | \ +# sort | uniq -c | sort -nr +# +# If everyone on the list that produces are on the list in +# the recently added file "git.git-authors", it *should* be +# safe to include that code in libgit2, but make sure to +# read the file to ensure the code doesn't originate from +# somewhere else. +# +# The format of this list is +# "ok/no/ask/???""Author""" +# +# "ok" means the author consents to relicensing all their +# contributed code (possibly with some exceptions) +# "no" means the author does not consent +# "ask" means that the contributor wants to give/withhold +# his/her consent on a patch-by-patch basis. +# "???" means the person is a prominent contributor who has +# not yet made his/her standpoint clear. +# +# Please try to keep the list alphabetically ordered. It will +# help in case we get all 600-ish git.git authors on it. +# +# (Paul Kocher is the author of the mozilla-sha1 implementation +# but has otherwise not contributed to git.) +# +ok Adam Simpkins (http transport) +ok Adrian Johnson +ok Alexey Shumkin +ok Andreas Ericsson +ok Boyd Lynn Gerber +ok Brandon Casey +ok Brian Downing +ok Brian Gernhardt +ok Christian Couder +ok Daniel Barkalow +ok Florian Forster +ok Gustaf Hendeby +ok Holger Weiss +ok Jeff King +ok Johannes Schindelin +ok Johannes Sixt +ask Jonathan Nieder +ok Junio C Hamano +ok Kristian Høgsberg +ok Linus Torvalds +ok Lukas Sandström +ok Matthieu Moy +ok Michael Haggerty +ok Nicolas Pitre +ok Paolo Bonzini +ok Paul Kocher +ok Peter Hagervall +ok Petr Onderka +ok Pierre Habouzit +ok Pieter de Bie +ok René Scharfe +ok Sebastian Schuberth +ok Shawn O. Pearce +ok Steffen Prohaska +ok Sven Verdoolaege +ask Thomas Rast (ok before 6-Oct-2013) +ok Torsten Bögershausen diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2.h new file mode 100644 index 000000000..cf6b5cb89 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_git_git_h__ +#define INCLUDE_git_git_h__ + +#include "git2/annotated_commit.h" +#include "git2/attr.h" +#include "git2/blob.h" +#include "git2/blame.h" +#include "git2/branch.h" +#include "git2/buffer.h" +#include "git2/checkout.h" +#include "git2/cherrypick.h" +#include "git2/clone.h" +#include "git2/commit.h" +#include "git2/common.h" +#include "git2/config.h" +#include "git2/describe.h" +#include "git2/diff.h" +#include "git2/errors.h" +#include "git2/filter.h" +#include "git2/global.h" +#include "git2/graph.h" +#include "git2/ignore.h" +#include "git2/index.h" +#include "git2/indexer.h" +#include "git2/merge.h" +#include "git2/message.h" +#include "git2/net.h" +#include "git2/notes.h" +#include "git2/object.h" +#include "git2/odb.h" +#include "git2/odb_backend.h" +#include "git2/oid.h" +#include "git2/pack.h" +#include "git2/patch.h" +#include "git2/pathspec.h" +#include "git2/push.h" +#include "git2/rebase.h" +#include "git2/refdb.h" +#include "git2/reflog.h" +#include "git2/refs.h" +#include "git2/refspec.h" +#include "git2/remote.h" +#include "git2/repository.h" +#include "git2/reset.h" +#include "git2/revert.h" +#include "git2/revparse.h" +#include "git2/revwalk.h" +#include "git2/signature.h" +#include "git2/stash.h" +#include "git2/status.h" +#include "git2/submodule.h" +#include "git2/tag.h" +#include "git2/transport.h" +#include "git2/tree.h" +#include "git2/types.h" +#include "git2/version.h" + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/annotated_commit.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/annotated_commit.h new file mode 100644 index 000000000..7fb896a5f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/annotated_commit.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_annotated_commit_h__ +#define INCLUDE_git_annotated_commit_h__ + +#include "common.h" +#include "repository.h" +#include "types.h" + +/** + * @file git2/annotated_commit.h + * @brief Git annotated commit routines + * @defgroup git_annotated_commit Git annotated commit routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Creates a `git_annotated_commit` from the given reference. + * The resulting git_annotated_commit must be freed with + * `git_annotated_commit_free`. + * + * @param out pointer to store the git_annotated_commit result in + * @param repo repository that contains the given reference + * @param ref reference to use to lookup the git_annotated_commit + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_annotated_commit_from_ref( + git_annotated_commit **out, + git_repository *repo, + const git_reference *ref); + +/** + * Creates a `git_annotated_commit` from the given fetch head data. + * The resulting git_annotated_commit must be freed with + * `git_annotated_commit_free`. + * + * @param out pointer to store the git_annotated_commit result in + * @param repo repository that contains the given commit + * @param branch_name name of the (remote) branch + * @param remote_url url of the remote + * @param id the commit object id of the remote branch + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_annotated_commit_from_fetchhead( + git_annotated_commit **out, + git_repository *repo, + const char *branch_name, + const char *remote_url, + const git_oid *id); + +/** + * Creates a `git_annotated_commit` from the given commit id. + * The resulting git_annotated_commit must be freed with + * `git_annotated_commit_free`. + * + * An annotated commit contains information about how it was + * looked up, which may be useful for functions like merge or + * rebase to provide context to the operation. For example, + * conflict files will include the name of the source or target + * branches being merged. It is therefore preferable to use the + * most specific function (eg `git_annotated_commit_from_ref`) + * instead of this one when that data is known. + * + * @param out pointer to store the git_annotated_commit result in + * @param repo repository that contains the given commit + * @param id the commit object id to lookup + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_annotated_commit_lookup( + git_annotated_commit **out, + git_repository *repo, + const git_oid *id); + +/** + * Creates a `git_annotated_comit` from a revision string. + * + * See `man gitrevisions`, or + * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + * information on the syntax accepted. + * + * @param out pointer to store the git_annotated_commit result in + * @param repo repository that contains the given commit + * @param revspec the extended sha syntax string to use to lookup the commit + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_annotated_commit_from_revspec( + git_annotated_commit **out, + git_repository *repo, + const char *revspec); + +/** + * Gets the commit ID that the given `git_annotated_commit` refers to. + * + * @param commit the given annotated commit + * @return commit id + */ +GIT_EXTERN(const git_oid *) git_annotated_commit_id( + const git_annotated_commit *commit); + +/** + * Frees a `git_annotated_commit`. + * + * @param commit annotated commit to free + */ +GIT_EXTERN(void) git_annotated_commit_free( + git_annotated_commit *commit); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/attr.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/attr.h new file mode 100644 index 000000000..0238f3dd7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/attr.h @@ -0,0 +1,245 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_attr_h__ +#define INCLUDE_git_attr_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/attr.h + * @brief Git attribute management routines + * @defgroup git_attr Git attribute management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * GIT_ATTR_TRUE checks if an attribute is set on. In core git + * parlance, this the value for "Set" attributes. + * + * For example, if the attribute file contains: + * + * *.c foo + * + * Then for file `xyz.c` looking up attribute "foo" gives a value for + * which `GIT_ATTR_TRUE(value)` is true. + */ +#define GIT_ATTR_TRUE(attr) (git_attr_value(attr) == GIT_ATTR_TRUE_T) + +/** + * GIT_ATTR_FALSE checks if an attribute is set off. In core git + * parlance, this is the value for attributes that are "Unset" (not to + * be confused with values that a "Unspecified"). + * + * For example, if the attribute file contains: + * + * *.h -foo + * + * Then for file `zyx.h` looking up attribute "foo" gives a value for + * which `GIT_ATTR_FALSE(value)` is true. + */ +#define GIT_ATTR_FALSE(attr) (git_attr_value(attr) == GIT_ATTR_FALSE_T) + +/** + * GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This + * may be due to the attribute not being mentioned at all or because + * the attribute was explicitly set unspecified via the `!` operator. + * + * For example, if the attribute file contains: + * + * *.c foo + * *.h -foo + * onefile.c !foo + * + * Then for `onefile.c` looking up attribute "foo" yields a value with + * `GIT_ATTR_UNSPECIFIED(value)` of true. Also, looking up "foo" on + * file `onefile.rb` or looking up "bar" on any file will all give + * `GIT_ATTR_UNSPECIFIED(value)` of true. + */ +#define GIT_ATTR_UNSPECIFIED(attr) (git_attr_value(attr) == GIT_ATTR_UNSPECIFIED_T) + +/** + * GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as + * opposed to TRUE, FALSE or UNSPECIFIED). This would be the case if + * for a file with something like: + * + * *.txt eol=lf + * + * Given this, looking up "eol" for `onefile.txt` will give back the + * string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true. + */ +#define GIT_ATTR_HAS_VALUE(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_T) + +/** + * Possible states for an attribute + */ +typedef enum { + GIT_ATTR_UNSPECIFIED_T = 0, /**< The attribute has been left unspecified */ + GIT_ATTR_TRUE_T, /**< The attribute has been set */ + GIT_ATTR_FALSE_T, /**< The attribute has been unset */ + GIT_ATTR_VALUE_T, /**< This attribute has a value */ +} git_attr_t; + +/** + * Return the value type for a given attribute. + * + * This can be either `TRUE`, `FALSE`, `UNSPECIFIED` (if the attribute + * was not set at all), or `VALUE`, if the attribute was set to an + * actual string. + * + * If the attribute has a `VALUE` string, it can be accessed normally + * as a NULL-terminated C string. + * + * @param attr The attribute + * @return the value type for the attribute + */ +GIT_EXTERN(git_attr_t) git_attr_value(const char *attr); + +/** + * Check attribute flags: Reading values from index and working directory. + * + * When checking attributes, it is possible to check attribute files + * in both the working directory (if there is one) and the index (if + * there is one). You can explicitly choose where to check and in + * which order using the following flags. + * + * Core git usually checks the working directory then the index, + * except during a checkout when it checks the index first. It will + * use index only for creating archives or for a bare repo (if an + * index has been specified for the bare repo). + */ +#define GIT_ATTR_CHECK_FILE_THEN_INDEX 0 +#define GIT_ATTR_CHECK_INDEX_THEN_FILE 1 +#define GIT_ATTR_CHECK_INDEX_ONLY 2 + +/** + * Check attribute flags: Using the system attributes file. + * + * Normally, attribute checks include looking in the /etc (or system + * equivalent) directory for a `gitattributes` file. Passing this + * flag will cause attribute checks to ignore that file. + */ +#define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2) + +/** + * Look up the value of one git attribute for path. + * + * @param value_out Output of the value of the attribute. Use the GIT_ATTR_... + * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just + * use the string value for attributes set to a value. You + * should NOT modify or free this value. + * @param repo The repository containing the path. + * @param flags A combination of GIT_ATTR_CHECK... flags. + * @param path The path to check for attributes. Relative paths are + * interpreted relative to the repo root. The file does + * not have to exist, but if it does not, then it will be + * treated as a plain file (not a directory). + * @param name The name of the attribute to look up. + */ +GIT_EXTERN(int) git_attr_get( + const char **value_out, + git_repository *repo, + uint32_t flags, + const char *path, + const char *name); + +/** + * Look up a list of git attributes for path. + * + * Use this if you have a known list of attributes that you want to + * look up in a single call. This is somewhat more efficient than + * calling `git_attr_get()` multiple times. + * + * For example, you might write: + * + * const char *attrs[] = { "crlf", "diff", "foo" }; + * const char **values[3]; + * git_attr_get_many(values, repo, 0, "my/fun/file.c", 3, attrs); + * + * Then you could loop through the 3 values to get the settings for + * the three attributes you asked about. + * + * @param values_out An array of num_attr entries that will have string + * pointers written into it for the values of the attributes. + * You should not modify or free the values that are written + * into this array (although of course, you should free the + * array itself if you allocated it). + * @param repo The repository containing the path. + * @param flags A combination of GIT_ATTR_CHECK... flags. + * @param path The path inside the repo to check attributes. This + * does not have to exist, but if it does not, then + * it will be treated as a plain file (i.e. not a directory). + * @param num_attr The number of attributes being looked up + * @param names An array of num_attr strings containing attribute names. + */ +GIT_EXTERN(int) git_attr_get_many( + const char **values_out, + git_repository *repo, + uint32_t flags, + const char *path, + size_t num_attr, + const char **names); + +typedef int (*git_attr_foreach_cb)(const char *name, const char *value, void *payload); + +/** + * Loop over all the git attributes for a path. + * + * @param repo The repository containing the path. + * @param flags A combination of GIT_ATTR_CHECK... flags. + * @param path Path inside the repo to check attributes. This does not have + * to exist, but if it does not, then it will be treated as a + * plain file (i.e. not a directory). + * @param callback Function to invoke on each attribute name and value. The + * value may be NULL is the attribute is explicitly set to + * UNSPECIFIED using the '!' sign. Callback will be invoked + * only once per attribute name, even if there are multiple + * rules for a given file. The highest priority rule will be + * used. Return a non-zero value from this to stop looping. + * The value will be returned from `git_attr_foreach`. + * @param payload Passed on as extra parameter to callback function. + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_attr_foreach( + git_repository *repo, + uint32_t flags, + const char *path, + git_attr_foreach_cb callback, + void *payload); + +/** + * Flush the gitattributes cache. + * + * Call this if you have reason to believe that the attributes files on + * disk no longer match the cached contents of memory. This will cause + * the attributes files to be reloaded the next time that an attribute + * access function is called. + */ +GIT_EXTERN(void) git_attr_cache_flush( + git_repository *repo); + +/** + * Add a macro definition. + * + * Macros will automatically be loaded from the top level `.gitattributes` + * file of the repository (plus the build-in "binary" macro). This + * function allows you to add others. For example, to add the default + * macro, you would call: + * + * git_attr_add_macro(repo, "binary", "-diff -crlf"); + */ +GIT_EXTERN(int) git_attr_add_macro( + git_repository *repo, + const char *name, + const char *values); + +/** @} */ +GIT_END_DECL +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/blame.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/blame.h new file mode 100644 index 000000000..173e9994b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/blame.h @@ -0,0 +1,212 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_git_blame_h__ +#define INCLUDE_git_blame_h__ + +#include "common.h" +#include "oid.h" + +/** + * @file git2/blame.h + * @brief Git blame routines + * @defgroup git_blame Git blame routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Flags for indicating option behavior for git_blame APIs. + */ +typedef enum { + /** Normal blame, the default */ + GIT_BLAME_NORMAL = 0, + /** Track lines that have moved within a file (like `git blame -M`). + * NOT IMPLEMENTED. */ + GIT_BLAME_TRACK_COPIES_SAME_FILE = (1<<0), + /** Track lines that have moved across files in the same commit (like `git blame -C`). + * NOT IMPLEMENTED. */ + GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = (1<<1), + /** Track lines that have been copied from another file that exists in the + * same commit (like `git blame -CC`). Implies SAME_FILE. + * NOT IMPLEMENTED. */ + GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = (1<<2), + /** Track lines that have been copied from another file that exists in *any* + * commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES. + * NOT IMPLEMENTED. */ + GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = (1<<3), + /** Restrict the search of commits to those reachable following only the + * first parents. */ + GIT_BLAME_FIRST_PARENT = (1<<4), +} git_blame_flag_t; + +/** + * Blame options structure + * + * Use zeros to indicate default settings. It's easiest to use the + * `GIT_BLAME_OPTIONS_INIT` macro: + * git_blame_options opts = GIT_BLAME_OPTIONS_INIT; + * + * - `flags` is a combination of the `git_blame_flag_t` values above. + * - `min_match_characters` is the lower bound on the number of alphanumeric + * characters that must be detected as moving/copying within a file for it to + * associate those lines with the parent commit. The default value is 20. + * This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*` + * flags are specified. + * - `newest_commit` is the id of the newest commit to consider. The default + * is HEAD. + * - `oldest_commit` is the id of the oldest commit to consider. The default + * is the first commit encountered with a NULL parent. + * - `min_line` is the first line in the file to blame. The default is 1 (line + * numbers start with 1). + * - `max_line` is the last line in the file to blame. The default is the last + * line of the file. + */ +typedef struct git_blame_options { + unsigned int version; + + uint32_t flags; + uint16_t min_match_characters; + git_oid newest_commit; + git_oid oldest_commit; + uint32_t min_line; + uint32_t max_line; +} git_blame_options; + +#define GIT_BLAME_OPTIONS_VERSION 1 +#define GIT_BLAME_OPTIONS_INIT {GIT_BLAME_OPTIONS_VERSION} + +/** + * Initializes a `git_blame_options` with default values. Equivalent to + * creating an instance with GIT_BLAME_OPTIONS_INIT. + * + * @param opts The `git_blame_options` struct to initialize + * @param version Version of struct; pass `GIT_BLAME_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_blame_init_options( + git_blame_options *opts, + unsigned int version); + +/** + * Structure that represents a blame hunk. + * + * - `lines_in_hunk` is the number of lines in this hunk + * - `final_commit_id` is the OID of the commit where this line was last + * changed. + * - `final_start_line_number` is the 1-based line number where this hunk + * begins, in the final version of the file + * - `orig_commit_id` is the OID of the commit where this hunk was found. This + * will usually be the same as `final_commit_id`, except when + * `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified. + * - `orig_path` is the path to the file where this hunk originated, as of the + * commit specified by `orig_commit_id`. + * - `orig_start_line_number` is the 1-based line number where this hunk begins + * in the file named by `orig_path` in the commit specified by + * `orig_commit_id`. + * - `boundary` is 1 iff the hunk has been tracked to a boundary commit (the + * root, or the commit specified in git_blame_options.oldest_commit) + */ +typedef struct git_blame_hunk { + uint16_t lines_in_hunk; + + git_oid final_commit_id; + uint16_t final_start_line_number; + git_signature *final_signature; + + git_oid orig_commit_id; + const char *orig_path; + uint16_t orig_start_line_number; + git_signature *orig_signature; + + char boundary; +} git_blame_hunk; + + +/* Opaque structure to hold blame results */ +typedef struct git_blame git_blame; + +/** + * Gets the number of hunks that exist in the blame structure. + */ +GIT_EXTERN(uint32_t) git_blame_get_hunk_count(git_blame *blame); + +/** + * Gets the blame hunk at the given index. + * + * @param blame the blame structure to query + * @param index index of the hunk to retrieve + * @return the hunk at the given index, or NULL on error + */ +GIT_EXTERN(const git_blame_hunk*) git_blame_get_hunk_byindex( + git_blame *blame, + uint32_t index); + +/** + * Gets the hunk that relates to the given line number in the newest commit. + * + * @param blame the blame structure to query + * @param lineno the (1-based) line number to find a hunk for + * @return the hunk that contains the given line, or NULL on error + */ +GIT_EXTERN(const git_blame_hunk*) git_blame_get_hunk_byline( + git_blame *blame, + uint32_t lineno); + +/** + * Get the blame for a single file. + * + * @param out pointer that will receive the blame object + * @param repo repository whose history is to be walked + * @param path path to file to consider + * @param options options for the blame operation. If NULL, this is treated as + * though GIT_BLAME_OPTIONS_INIT were passed. + * @return 0 on success, or an error code. (use giterr_last for information + * about the error.) + */ +GIT_EXTERN(int) git_blame_file( + git_blame **out, + git_repository *repo, + const char *path, + git_blame_options *options); + + +/** + * Get blame data for a file that has been modified in memory. The `reference` + * parameter is a pre-calculated blame for the in-odb history of the file. This + * means that once a file blame is completed (which can be expensive), updating + * the buffer blame is very fast. + * + * Lines that differ between the buffer and the committed version are marked as + * having a zero OID for their final_commit_id. + * + * @param out pointer that will receive the resulting blame data + * @param reference cached blame from the history of the file (usually the output + * from git_blame_file) + * @param buffer the (possibly) modified contents of the file + * @param buffer_len number of valid bytes in the buffer + * @return 0 on success, or an error code. (use giterr_last for information + * about the error) + */ +GIT_EXTERN(int) git_blame_buffer( + git_blame **out, + git_blame *reference, + const char *buffer, + size_t buffer_len); + +/** + * Free memory allocated by git_blame_file or git_blame_buffer. + * + * @param blame the blame structure to free + */ +GIT_EXTERN(void) git_blame_free(git_blame *blame); + +/** @} */ +GIT_END_DECL +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/blob.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/blob.h new file mode 100644 index 000000000..c24ff7e7f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/blob.h @@ -0,0 +1,223 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_blob_h__ +#define INCLUDE_git_blob_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "object.h" +#include "buffer.h" + +/** + * @file git2/blob.h + * @brief Git blob load and write routines + * @defgroup git_blob Git blob load and write routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Lookup a blob object from a repository. + * + * @param blob pointer to the looked up blob + * @param repo the repo to use when locating the blob. + * @param id identity of the blob to locate. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id); + +/** + * Lookup a blob object from a repository, + * given a prefix of its identifier (short id). + * + * @see git_object_lookup_prefix + * + * @param blob pointer to the looked up blob + * @param repo the repo to use when locating the blob. + * @param id identity of the blob to locate. + * @param len the length of the short identifier + * @return 0 or an error code + */ +GIT_EXTERN(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, size_t len); + +/** + * Close an open blob + * + * This is a wrapper around git_object_free() + * + * IMPORTANT: + * It *is* necessary to call this method when you stop + * using a blob. Failure to do so will cause a memory leak. + * + * @param blob the blob to close + */ +GIT_EXTERN(void) git_blob_free(git_blob *blob); + +/** + * Get the id of a blob. + * + * @param blob a previously loaded blob. + * @return SHA1 hash for this blob. + */ +GIT_EXTERN(const git_oid *) git_blob_id(const git_blob *blob); + +/** + * Get the repository that contains the blob. + * + * @param blob A previously loaded blob. + * @return Repository that contains this blob. + */ +GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob); + +/** + * Get a read-only buffer with the raw content of a blob. + * + * A pointer to the raw content of a blob is returned; + * this pointer is owned internally by the object and shall + * not be free'd. The pointer may be invalidated at a later + * time. + * + * @param blob pointer to the blob + * @return the pointer + */ +GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob); + +/** + * Get the size in bytes of the contents of a blob + * + * @param blob pointer to the blob + * @return size on bytes + */ +GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob); + +/** + * Get a buffer with the filtered content of a blob. + * + * This applies filters as if the blob was being checked out to the + * working directory under the specified filename. This may apply + * CRLF filtering or other types of changes depending on the file + * attributes set for the blob and the content detected in it. + * + * The output is written into a `git_buf` which the caller must free + * when done (via `git_buf_free`). + * + * If no filters need to be applied, then the `out` buffer will just be + * populated with a pointer to the raw content of the blob. In that case, + * be careful to *not* free the blob until done with the buffer. To keep + * the data detached from the blob, call `git_buf_grow` on the buffer + * with a `want_size` of 0 and the buffer will be reallocated to be + * detached from the blob. + * + * @param out The git_buf to be filled in + * @param blob Pointer to the blob + * @param as_path Path used for file attribute lookups, etc. + * @param check_for_binary_data Should this test if blob content contains + * NUL bytes / looks like binary data before applying filters? + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_blob_filtered_content( + git_buf *out, + git_blob *blob, + const char *as_path, + int check_for_binary_data); + +/** + * Read a file from the working folder of a repository + * and write it to the Object Database as a loose blob + * + * @param id return the id of the written blob + * @param repo repository where the blob will be written. + * this repository cannot be bare + * @param relative_path file from which the blob will be created, + * relative to the repository's working dir + * @return 0 or an error code + */ +GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path); + +/** + * Read a file from the filesystem and write its content + * to the Object Database as a loose blob + * + * @param id return the id of the written blob + * @param repo repository where the blob will be written. + * this repository can be bare or not + * @param path file from which the blob will be created + * @return 0 or an error code + */ +GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path); + + +typedef int (*git_blob_chunk_cb)(char *content, size_t max_length, void *payload); + +/** + * Write a loose blob to the Object Database from a + * provider of chunks of data. + * + * If the `hintpath` parameter is filled, it will be used to determine + * what git filters should be applied to the object before it is written + * to the object database. + * + * The implementation of the callback MUST respect the following rules: + * + * - `content` must be filled by the callback. The maximum number of + * bytes that the buffer can accept per call is defined by the + * `max_length` parameter. Allocation and freeing of the buffer will + * be taken care of by libgit2. + * + * - The `callback` must return the number of bytes that have been + * written to the `content` buffer. + * + * - When there is no more data to stream, `callback` should return + * 0. This will prevent it from being invoked anymore. + * + * - If an error occurs, the callback should return a negative value. + * This value will be returned to the caller. + * + * @param id Return the id of the written blob + * @param repo Repository where the blob will be written. + * This repository can be bare or not. + * @param hintpath If not NULL, will be used to select data filters + * to apply onto the content of the blob to be created. + * @return 0 or error code (from either libgit2 or callback function) + */ +GIT_EXTERN(int) git_blob_create_fromchunks( + git_oid *id, + git_repository *repo, + const char *hintpath, + git_blob_chunk_cb callback, + void *payload); + +/** + * Write an in-memory buffer to the ODB as a blob + * + * @param id return the id of the written blob + * @param repo repository where to blob will be written + * @param buffer data to be written into the blob + * @param len length of the data + * @return 0 or an error code + */ +GIT_EXTERN(int) git_blob_create_frombuffer( + git_oid *id, git_repository *repo, const void *buffer, size_t len); + +/** + * Determine if the blob content is most certainly binary or not. + * + * The heuristic used to guess if a file is binary is taken from core git: + * Searching for NUL bytes and looking for a reasonable ratio of printable + * to non-printable characters among the first 8000 bytes. + * + * @param blob The blob which content should be analyzed + * @return 1 if the content of the blob is detected + * as binary; 0 otherwise. + */ +GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/branch.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/branch.h new file mode 100644 index 000000000..34354f4e5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/branch.h @@ -0,0 +1,280 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_branch_h__ +#define INCLUDE_git_branch_h__ + +#include "common.h" +#include "oid.h" +#include "types.h" + +/** + * @file git2/branch.h + * @brief Git branch parsing routines + * @defgroup git_branch Git branch management + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new branch pointing at a target commit + * + * A new direct reference will be created pointing to + * this target commit. If `force` is true and a reference + * already exists with the given name, it'll be replaced. + * + * The returned reference must be freed by the user. + * + * The branch name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param out Pointer where to store the underlying reference. + * + * @param branch_name Name for the branch; this name is + * validated for consistency. It should also not conflict with + * an already existing branch name. + * + * @param target Commit to which this branch should point. This object + * must belong to the given `repo`. + * + * @param force Overwrite existing branch. + * + * @return 0, GIT_EINVALIDSPEC or an error code. + * A proper reference is written in the refs/heads namespace + * pointing to the provided target commit. + */ +GIT_EXTERN(int) git_branch_create( + git_reference **out, + git_repository *repo, + const char *branch_name, + const git_commit *target, + int force); + +/** + * Create a new branch pointing at a target commit + * + * This behaves like `git_branch_create()` but takes an annotated + * commit, which lets you specify which extended sha syntax string was + * specified by a user, allowing for more exact reflog messages. + * + * See the documentation for `git_branch_create()`. + * + * @see git_branch_create + */ +GIT_EXTERN(int) git_branch_create_from_annotated( + git_reference **ref_out, + git_repository *repository, + const char *branch_name, + const git_annotated_commit *commit, + int force); + +/** + * Delete an existing branch reference. + * + * If the branch is successfully deleted, the passed reference + * object will be invalidated. The reference must be freed manually + * by the user. + * + * @param branch A valid reference representing a branch + * @return 0 on success, or an error code. + */ +GIT_EXTERN(int) git_branch_delete(git_reference *branch); + +/** Iterator type for branches */ +typedef struct git_branch_iterator git_branch_iterator; + +/** + * Create an iterator which loops over the requested branches. + * + * @param out the iterator + * @param repo Repository where to find the branches. + * @param list_flags Filtering flags for the branch + * listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE + * or GIT_BRANCH_ALL. + * + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_branch_iterator_new( + git_branch_iterator **out, + git_repository *repo, + git_branch_t list_flags); + +/** + * Retrieve the next branch from the iterator + * + * @param out the reference + * @param out_type the type of branch (local or remote-tracking) + * @param iter the branch iterator + * @return 0 on success, GIT_ITEROVER if there are no more branches or an error code. + */ +GIT_EXTERN(int) git_branch_next(git_reference **out, git_branch_t *out_type, git_branch_iterator *iter); + +/** + * Free a branch iterator + * + * @param iter the iterator to free + */ +GIT_EXTERN(void) git_branch_iterator_free(git_branch_iterator *iter); + +/** + * Move/rename an existing local branch reference. + * + * The new branch name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param branch Current underlying reference of the branch. + * + * @param new_branch_name Target name of the branch once the move + * is performed; this name is validated for consistency. + * + * @param force Overwrite existing branch. + * + * @return 0 on success, GIT_EINVALIDSPEC or an error code. + */ +GIT_EXTERN(int) git_branch_move( + git_reference **out, + git_reference *branch, + const char *new_branch_name, + int force); + +/** + * Lookup a branch by its name in a repository. + * + * The generated reference must be freed by the user. + * + * The branch name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param out pointer to the looked-up branch reference + * + * @param repo the repository to look up the branch + * + * @param branch_name Name of the branch to be looked-up; + * this name is validated for consistency. + * + * @param branch_type Type of the considered branch. This should + * be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE. + * + * @return 0 on success; GIT_ENOTFOUND when no matching branch + * exists, GIT_EINVALIDSPEC, otherwise an error code. + */ +GIT_EXTERN(int) git_branch_lookup( + git_reference **out, + git_repository *repo, + const char *branch_name, + git_branch_t branch_type); + +/** + * Return the name of the given local or remote branch. + * + * The name of the branch matches the definition of the name + * for git_branch_lookup. That is, if the returned name is given + * to git_branch_lookup() then the reference is returned that + * was given to this function. + * + * @param out where the pointer of branch name is stored; + * this is valid as long as the ref is not freed. + * @param ref the reference ideally pointing to a branch + * + * @return 0 on success; otherwise an error code (e.g., if the + * ref is no local or remote branch). + */ +GIT_EXTERN(int) git_branch_name( + const char **out, + const git_reference *ref); + +/** + * Return the reference supporting the remote tracking branch, + * given a local branch reference. + * + * @param out Pointer where to store the retrieved + * reference. + * + * @param branch Current underlying reference of the branch. + * + * @return 0 on success; GIT_ENOTFOUND when no remote tracking + * reference exists, otherwise an error code. + */ +GIT_EXTERN(int) git_branch_upstream( + git_reference **out, + const git_reference *branch); + +/** + * Set the upstream configuration for a given local branch + * + * @param branch the branch to configure + * + * @param upstream_name remote-tracking or local branch to set as + * upstream. Pass NULL to unset. + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_branch_set_upstream(git_reference *branch, const char *upstream_name); + +/** + * Return the name of the reference supporting the remote tracking branch, + * given the name of a local branch reference. + * + * @param out Pointer to the user-allocated git_buf which will be + * filled with the name of the reference. + * + * @param repo the repository where the branches live + * + * @param refname reference name of the local branch. + * + * @return 0, GIT_ENOTFOUND when no remote tracking reference exists, + * otherwise an error code. + */ +GIT_EXTERN(int) git_branch_upstream_name( + git_buf *out, + git_repository *repo, + const char *refname); + +/** + * Determine if the current local branch is pointed at by HEAD. + * + * @param branch Current underlying reference of the branch. + * + * @return 1 if HEAD points at the branch, 0 if it isn't, + * error code otherwise. + */ +GIT_EXTERN(int) git_branch_is_head( + const git_reference *branch); + +/** + * Return the name of remote that the remote tracking branch belongs to. + * + * @param out Pointer to the user-allocated git_buf which will be filled with the name of the remote. + * + * @param repo The repository where the branch lives. + * + * @param canonical_branch_name name of the remote tracking branch. + * + * @return 0, GIT_ENOTFOUND + * when no remote matching remote was found, + * GIT_EAMBIGUOUS when the branch maps to several remotes, + * otherwise an error code. + */ +GIT_EXTERN(int) git_branch_remote_name( + git_buf *out, + git_repository *repo, + const char *canonical_branch_name); + + +/** + * Retrieve the name fo the upstream remote of a local branch + * + * @param buf the buffer into which to write the name + * @param repo the repository in which to look + * @param refname the full name of the branch + * @return 0 or an error code + */ + GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/buffer.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/buffer.h new file mode 100644 index 000000000..9fc6a5805 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/buffer.h @@ -0,0 +1,128 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_buf_h__ +#define INCLUDE_git_buf_h__ + +#include "common.h" + +/** + * @file git2/buffer.h + * @brief Buffer export structure + * + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * A data buffer for exporting data from libgit2 + * + * Sometimes libgit2 wants to return an allocated data buffer to the + * caller and have the caller take responsibility for freeing that memory. + * This can be awkward if the caller does not have easy access to the same + * allocation functions that libgit2 is using. In those cases, libgit2 + * will fill in a `git_buf` and the caller can use `git_buf_free()` to + * release it when they are done. + * + * A `git_buf` may also be used for the caller to pass in a reference to + * a block of memory they hold. In this case, libgit2 will not resize or + * free the memory, but will read from it as needed. + * + * A `git_buf` is a public structure with three fields: + * + * - `ptr` points to the start of the allocated memory. If it is NULL, + * then the `git_buf` is considered empty and libgit2 will feel free + * to overwrite it with new data. + * + * - `size` holds the size (in bytes) of the data that is actually used. + * + * - `asize` holds the known total amount of allocated memory if the `ptr` + * was allocated by libgit2. It may be larger than `size`. If `ptr` + * was not allocated by libgit2 and should not be resized and/or freed, + * then `asize` will be set to zero. + * + * Some APIs may occasionally do something slightly unusual with a buffer, + * such as setting `ptr` to a value that was passed in by the user. In + * those cases, the behavior will be clearly documented by the API. + */ +typedef struct { + char *ptr; + size_t asize, size; +} git_buf; + +/** + * Static initializer for git_buf from static buffer + */ +#define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) } + +/** + * Free the memory referred to by the git_buf. + * + * Note that this does not free the `git_buf` itself, just the memory + * pointed to by `buffer->ptr`. This will not free the memory if it looks + * like it was not allocated internally, but it will clear the buffer back + * to the empty state. + * + * @param buffer The buffer to deallocate + */ +GIT_EXTERN(void) git_buf_free(git_buf *buffer); + +/** + * Resize the buffer allocation to make more space. + * + * This will attempt to grow the buffer to accommodate the target size. + * + * If the buffer refers to memory that was not allocated by libgit2 (i.e. + * the `asize` field is zero), then `ptr` will be replaced with a newly + * allocated block of data. Be careful so that memory allocated by the + * caller is not lost. As a special variant, if you pass `target_size` as + * 0 and the memory is not allocated by libgit2, this will allocate a new + * buffer of size `size` and copy the external data into it. + * + * Currently, this will never shrink a buffer, only expand it. + * + * If the allocation fails, this will return an error and the buffer will be + * marked as invalid for future operations, invaliding the contents. + * + * @param buffer The buffer to be resized; may or may not be allocated yet + * @param target_size The desired available size + * @return 0 on success, -1 on allocation failure + */ +GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size); + +/** + * Set buffer to a copy of some raw data. + * + * @param buffer The buffer to set + * @param data The data to copy into the buffer + * @param datalen The length of the data to copy into the buffer + * @return 0 on success, -1 on allocation failure + */ +GIT_EXTERN(int) git_buf_set( + git_buf *buffer, const void *data, size_t datalen); + +/** +* Check quickly if buffer looks like it contains binary data +* +* @param buf Buffer to check +* @return 1 if buffer looks like non-text data +*/ +GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf); + +/** +* Check quickly if buffer contains a NUL byte +* +* @param buf Buffer to check +* @return 1 if buffer contains a NUL byte +*/ +GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf); + +GIT_END_DECL + +/** @} */ + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/checkout.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/checkout.h new file mode 100644 index 000000000..ed39bd3cb --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/checkout.h @@ -0,0 +1,349 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_checkout_h__ +#define INCLUDE_git_checkout_h__ + +#include "common.h" +#include "types.h" +#include "diff.h" + +/** + * @file git2/checkout.h + * @brief Git checkout routines + * @defgroup git_checkout Git checkout routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Checkout behavior flags + * + * In libgit2, checkout is used to update the working directory and index + * to match a target tree. Unlike git checkout, it does not move the HEAD + * commit for you - use `git_repository_set_head` or the like to do that. + * + * Checkout looks at (up to) four things: the "target" tree you want to + * check out, the "baseline" tree of what was checked out previously, the + * working directory for actual files, and the index for staged changes. + * + * You give checkout one of three strategies for update: + * + * - `GIT_CHECKOUT_NONE` is a dry-run strategy that checks for conflicts, + * etc., but doesn't make any actual changes. + * + * - `GIT_CHECKOUT_FORCE` is at the opposite extreme, taking any action to + * make the working directory match the target (including potentially + * discarding modified files). + * + * - `GIT_CHECKOUT_SAFE` is between these two options, it will only make + * modifications that will not lose changes. + * + * | target == baseline | target != baseline | + * ---------------------|-----------------------|----------------------| + * workdir == baseline | no action | create, update, or | + * | | delete file | + * ---------------------|-----------------------|----------------------| + * workdir exists and | no action | conflict (notify | + * is != baseline | notify dirty MODIFIED | and cancel checkout) | + * ---------------------|-----------------------|----------------------| + * workdir missing, | notify dirty DELETED | create file | + * baseline present | | | + * ---------------------|-----------------------|----------------------| + * + * To emulate `git checkout`, use `GIT_CHECKOUT_SAFE` with a checkout + * notification callback (see below) that displays information about dirty + * files. The default behavior will cancel checkout on conflicts. + * + * To emulate `git checkout-index`, use `GIT_CHECKOUT_SAFE` with a + * notification callback that cancels the operation if a dirty-but-existing + * file is found in the working directory. This core git command isn't + * quite "force" but is sensitive about some types of changes. + * + * To emulate `git checkout -f`, use `GIT_CHECKOUT_FORCE`. + * + * + * There are some additional flags to modified the behavior of checkout: + * + * - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates + * even if there are conflicts (instead of cancelling the checkout). + * + * - GIT_CHECKOUT_REMOVE_UNTRACKED means remove untracked files (i.e. not + * in target, baseline, or index, and not ignored) from the working dir. + * + * - GIT_CHECKOUT_REMOVE_IGNORED means remove ignored files (that are also + * untracked) from the working directory as well. + * + * - GIT_CHECKOUT_UPDATE_ONLY means to only update the content of files that + * already exist. Files will not be created nor deleted. This just skips + * applying adds, deletes, and typechanges. + * + * - GIT_CHECKOUT_DONT_UPDATE_INDEX prevents checkout from writing the + * updated files' information to the index. + * + * - Normally, checkout will reload the index and git attributes from disk + * before any operations. GIT_CHECKOUT_NO_REFRESH prevents this reload. + * + * - Unmerged index entries are conflicts. GIT_CHECKOUT_SKIP_UNMERGED skips + * files with unmerged index entries instead. GIT_CHECKOUT_USE_OURS and + * GIT_CHECKOUT_USE_THEIRS to proceed with the checkout using either the + * stage 2 ("ours") or stage 3 ("theirs") version of files in the index. + * + * - GIT_CHECKOUT_DONT_OVERWRITE_IGNORED prevents ignored files from being + * overwritten. Normally, files that are ignored in the working directory + * are not considered "precious" and may be overwritten if the checkout + * target contains that file. + * + * - GIT_CHECKOUT_DONT_REMOVE_EXISTING prevents checkout from removing + * files or folders that fold to the same name on case insensitive + * filesystems. This can cause files to retain their existing names + * and write through existing symbolic links. + */ +typedef enum { + GIT_CHECKOUT_NONE = 0, /**< default is a dry run, no actual updates */ + + /** Allow safe updates that cannot overwrite uncommitted data */ + GIT_CHECKOUT_SAFE = (1u << 0), + + /** Allow all updates to force working directory to look like index */ + GIT_CHECKOUT_FORCE = (1u << 1), + + + /** Allow checkout to recreate missing files */ + GIT_CHECKOUT_RECREATE_MISSING = (1u << 2), + + /** Allow checkout to make safe updates even if conflicts are found */ + GIT_CHECKOUT_ALLOW_CONFLICTS = (1u << 4), + + /** Remove untracked files not in index (that are not ignored) */ + GIT_CHECKOUT_REMOVE_UNTRACKED = (1u << 5), + + /** Remove ignored files not in index */ + GIT_CHECKOUT_REMOVE_IGNORED = (1u << 6), + + /** Only update existing files, don't create new ones */ + GIT_CHECKOUT_UPDATE_ONLY = (1u << 7), + + /** + * Normally checkout updates index entries as it goes; this stops that. + * Implies `GIT_CHECKOUT_DONT_WRITE_INDEX`. + */ + GIT_CHECKOUT_DONT_UPDATE_INDEX = (1u << 8), + + /** Don't refresh index/config/etc before doing checkout */ + GIT_CHECKOUT_NO_REFRESH = (1u << 9), + + /** Allow checkout to skip unmerged files */ + GIT_CHECKOUT_SKIP_UNMERGED = (1u << 10), + /** For unmerged files, checkout stage 2 from index */ + GIT_CHECKOUT_USE_OURS = (1u << 11), + /** For unmerged files, checkout stage 3 from index */ + GIT_CHECKOUT_USE_THEIRS = (1u << 12), + + /** Treat pathspec as simple list of exact match file paths */ + GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1u << 13), + + /** Ignore directories in use, they will be left empty */ + GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = (1u << 18), + + /** Don't overwrite ignored files that exist in the checkout target */ + GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = (1u << 19), + + /** Write normal merge files for conflicts */ + GIT_CHECKOUT_CONFLICT_STYLE_MERGE = (1u << 20), + + /** Include common ancestor data in diff3 format files for conflicts */ + GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1u << 21), + + /** Don't overwrite existing files or folders */ + GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1u << 22), + + /** Normally checkout writes the index upon completion; this prevents that. */ + GIT_CHECKOUT_DONT_WRITE_INDEX = (1u << 23), + + /** + * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED + */ + + /** Recursively checkout submodules with same options (NOT IMPLEMENTED) */ + GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16), + /** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */ + GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17), + +} git_checkout_strategy_t; + +/** + * Checkout notification flags + * + * Checkout will invoke an options notification callback (`notify_cb`) for + * certain cases - you pick which ones via `notify_flags`: + * + * - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths. + * + * - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that + * do not need an update but no longer match the baseline. Core git + * displays these files when checkout runs, but won't stop the checkout. + * + * - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed. + * + * - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files. + * + * - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files. + * + * Returning a non-zero value from this callback will cancel the checkout. + * The non-zero return value will be propagated back and returned by the + * git_checkout_... call. + * + * Notification callbacks are made prior to modifying any files on disk, + * so canceling on any notification will still happen prior to any files + * being modified. + */ +typedef enum { + GIT_CHECKOUT_NOTIFY_NONE = 0, + GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0), + GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1), + GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2), + GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3), + GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4), + + GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu +} git_checkout_notify_t; + +typedef struct { + size_t mkdir_calls; + size_t stat_calls; + size_t chmod_calls; +} git_checkout_perfdata; + +/** Checkout notification callback function */ +typedef int (*git_checkout_notify_cb)( + git_checkout_notify_t why, + const char *path, + const git_diff_file *baseline, + const git_diff_file *target, + const git_diff_file *workdir, + void *payload); + +/** Checkout progress notification function */ +typedef void (*git_checkout_progress_cb)( + const char *path, + size_t completed_steps, + size_t total_steps, + void *payload); + +/** Checkout perfdata notification function */ +typedef void (*git_checkout_perfdata_cb)( + const git_checkout_perfdata *perfdata, + void *payload); + +/** + * Checkout options structure + * + * Zero out for defaults. Initialize with `GIT_CHECKOUT_OPTIONS_INIT` macro to + * correctly set the `version` field. E.g. + * + * git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; + */ +typedef struct git_checkout_options { + unsigned int version; + + unsigned int checkout_strategy; /**< default will be a dry run */ + + int disable_filters; /**< don't apply filters like CRLF conversion */ + unsigned int dir_mode; /**< default is 0755 */ + unsigned int file_mode; /**< default is 0644 or 0755 as dictated by blob */ + int file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */ + + unsigned int notify_flags; /**< see `git_checkout_notify_t` above */ + git_checkout_notify_cb notify_cb; + void *notify_payload; + + /** Optional callback to notify the consumer of checkout progress. */ + git_checkout_progress_cb progress_cb; + void *progress_payload; + + /** When not zeroed out, array of fnmatch patterns specifying which + * paths should be taken into account, otherwise all files. Use + * GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list. + */ + git_strarray paths; + + git_tree *baseline; /**< expected content of workdir, defaults to HEAD */ + + const char *target_directory; /**< alternative checkout path to workdir */ + + const char *ancestor_label; /**< the name of the common ancestor side of conflicts */ + const char *our_label; /**< the name of the "our" side of conflicts */ + const char *their_label; /**< the name of the "their" side of conflicts */ + + /** Optional callback to notify the consumer of performance data. */ + git_checkout_perfdata_cb perfdata_cb; + void *perfdata_payload; +} git_checkout_options; + +#define GIT_CHECKOUT_OPTIONS_VERSION 1 +#define GIT_CHECKOUT_OPTIONS_INIT {GIT_CHECKOUT_OPTIONS_VERSION} + +/** +* Initializes a `git_checkout_options` with default values. Equivalent to +* creating an instance with GIT_CHECKOUT_OPTIONS_INIT. +* +* @param opts the `git_checkout_options` struct to initialize. +* @param version Version of struct; pass `GIT_CHECKOUT_OPTIONS_VERSION` +* @return Zero on success; -1 on failure. +*/ +GIT_EXTERN(int) git_checkout_init_options( + git_checkout_options *opts, + unsigned int version); + +/** + * Updates files in the index and the working tree to match the content of + * the commit pointed at by HEAD. + * + * @param repo repository to check out (must be non-bare) + * @param opts specifies checkout options (may be NULL) + * @return 0 on success, GIT_EUNBORNBRANCH if HEAD points to a non + * existing branch, non-zero value returned by `notify_cb`, or + * other error code < 0 (use giterr_last for error details) + */ +GIT_EXTERN(int) git_checkout_head( + git_repository *repo, + const git_checkout_options *opts); + +/** + * Updates files in the working tree to match the content of the index. + * + * @param repo repository into which to check out (must be non-bare) + * @param index index to be checked out (or NULL to use repository index) + * @param opts specifies checkout options (may be NULL) + * @return 0 on success, non-zero return value from `notify_cb`, or error + * code < 0 (use giterr_last for error details) + */ +GIT_EXTERN(int) git_checkout_index( + git_repository *repo, + git_index *index, + const git_checkout_options *opts); + +/** + * Updates files in the index and working tree to match the content of the + * tree pointed at by the treeish. + * + * @param repo repository to check out (must be non-bare) + * @param treeish a commit, tag or tree which content will be used to update + * the working directory (or NULL to use HEAD) + * @param opts specifies checkout options (may be NULL) + * @return 0 on success, non-zero return value from `notify_cb`, or error + * code < 0 (use giterr_last for error details) + */ +GIT_EXTERN(int) git_checkout_tree( + git_repository *repo, + const git_object *treeish, + const git_checkout_options *opts); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/cherrypick.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/cherrypick.h new file mode 100644 index 000000000..edec96a94 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/cherrypick.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_cherrypick_h__ +#define INCLUDE_git_cherrypick_h__ + +#include "common.h" +#include "types.h" +#include "merge.h" + +/** + * @file git2/cherrypick.h + * @brief Git cherry-pick routines + * @defgroup git_cherrypick Git cherry-pick routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Cherry-pick options + */ +typedef struct { + unsigned int version; + + /** For merge commits, the "mainline" is treated as the parent. */ + unsigned int mainline; + + git_merge_options merge_opts; /**< Options for the merging */ + git_checkout_options checkout_opts; /**< Options for the checkout */ +} git_cherrypick_options; + +#define GIT_CHERRYPICK_OPTIONS_VERSION 1 +#define GIT_CHERRYPICK_OPTIONS_INIT {GIT_CHERRYPICK_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT} + +/** + * Initializes a `git_cherrypick_options` with default values. Equivalent to + * creating an instance with GIT_CHERRYPICK_OPTIONS_INIT. + * + * @param opts the `git_cherrypick_options` struct to initialize + * @param version Version of struct; pass `GIT_CHERRYPICK_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_cherrypick_init_options( + git_cherrypick_options *opts, + unsigned int version); + +/** + * Cherry-picks the given commit against the given "our" commit, producing an + * index that reflects the result of the cherry-pick. + * + * The returned index must be freed explicitly with `git_index_free`. + * + * @param out pointer to store the index result in + * @param repo the repository that contains the given commits + * @param cherrypick_commit the commit to cherry-pick + * @param our_commit the commit to revert against (eg, HEAD) + * @param mainline the parent of the revert commit, if it is a merge + * @param merge_options the merge options (or null for defaults) + * @return zero on success, -1 on failure. + */ +GIT_EXTERN(int) git_cherrypick_commit( + git_index **out, + git_repository *repo, + git_commit *cherrypick_commit, + git_commit *our_commit, + unsigned int mainline, + const git_merge_options *merge_options); + +/** + * Cherry-pick the given commit, producing changes in the index and working directory. + * + * @param repo the repository to cherry-pick + * @param commit the commit to cherry-pick + * @param cherrypick_options the cherry-pick options (or null for defaults) + * @return zero on success, -1 on failure. + */ +GIT_EXTERN(int) git_cherrypick( + git_repository *repo, + git_commit *commit, + const git_cherrypick_options *cherrypick_options); + +/** @} */ +GIT_END_DECL + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/clone.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/clone.h new file mode 100644 index 000000000..d3bd42485 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/clone.h @@ -0,0 +1,208 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_clone_h__ +#define INCLUDE_git_clone_h__ + +#include "common.h" +#include "types.h" +#include "indexer.h" +#include "checkout.h" +#include "remote.h" +#include "transport.h" + + +/** + * @file git2/clone.h + * @brief Git cloning routines + * @defgroup git_clone Git cloning routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Options for bypassing the git-aware transport on clone. Bypassing + * it means that instead of a fetch, libgit2 will copy the object + * database directory instead of figuring out what it needs, which is + * faster. If possible, it will hardlink the files to save space. + */ +typedef enum { + /** + * Auto-detect (default), libgit2 will bypass the git-aware + * transport for local paths, but use a normal fetch for + * `file://` urls. + */ + GIT_CLONE_LOCAL_AUTO, + /** + * Bypass the git-aware transport even for a `file://` url. + */ + GIT_CLONE_LOCAL, + /** + * Do no bypass the git-aware transport + */ + GIT_CLONE_NO_LOCAL, + /** + * Bypass the git-aware transport, but do not try to use + * hardlinks. + */ + GIT_CLONE_LOCAL_NO_LINKS, +} git_clone_local_t; + +/** + * The signature of a function matching git_remote_create, with an additional + * void* as a callback payload. + * + * Callers of git_clone may provide a function matching this signature to override + * the remote creation and customization process during a clone operation. + * + * @param out the resulting remote + * @param repo the repository in which to create the remote + * @param name the remote's name + * @param url the remote's url + * @param payload an opaque payload + * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code + */ +typedef int (*git_remote_create_cb)( + git_remote **out, + git_repository *repo, + const char *name, + const char *url, + void *payload); + +/** + * The signature of a function matchin git_repository_init, with an + * aditional void * as callback payload. + * + * Callers of git_clone my provide a function matching this signature + * to override the repository creation and customization process + * during a clone operation. + * + * @param out the resulting repository + * @param path path in which to create the repository + * @param bare whether the repository is bare. This is the value from the clone options + * @param payload payload specified by the options + * @return 0, or a negative value to indicate error + */ +typedef int (*git_repository_create_cb)( + git_repository **out, + const char *path, + int bare, + void *payload); + +/** + * Clone options structure + * + * Use the GIT_CLONE_OPTIONS_INIT to get the default settings, like this: + * + * git_clone_options opts = GIT_CLONE_OPTIONS_INIT; + */ +typedef struct git_clone_options { + unsigned int version; + + /** + * These options are passed to the checkout step. To disable + * checkout, set the `checkout_strategy` to + * `GIT_CHECKOUT_NONE`. + */ + git_checkout_options checkout_opts; + + /** + * Callbacks to use for reporting fetch progress, and for acquiring + * credentials in the event they are needed. This parameter is ignored if + * the remote_cb parameter is set; if you provide a remote creation + * callback, then you have the opportunity to configure remote callbacks in + * provided function. + */ + git_remote_callbacks remote_callbacks; + + /** + * Set to zero (false) to create a standard repo, or non-zero + * for a bare repo + */ + int bare; + + /** + * Whether to use a fetch or copy the object database. + */ + git_clone_local_t local; + + /** + * The name of the branch to checkout. NULL means use the + * remote's default branch. + */ + const char* checkout_branch; + + /** + * A callback used to create the new repository into which to + * clone. If NULL, the 'bare' field will be used to determine + * whether to create a bare repository. + */ + git_repository_create_cb repository_cb; + + /** + * An opaque payload to pass to the git_repository creation callback. + * This parameter is ignored unless repository_cb is non-NULL. + */ + void *repository_cb_payload; + + /** + * A callback used to create the git_remote, prior to its being + * used to perform the clone operation. See the documentation for + * git_remote_create_cb for details. This parameter may be NULL, + * indicating that git_clone should provide default behavior. + */ + git_remote_create_cb remote_cb; + + /** + * An opaque payload to pass to the git_remote creation callback. + * This parameter is ignored unless remote_cb is non-NULL. + */ + void *remote_cb_payload; +} git_clone_options; + +#define GIT_CLONE_OPTIONS_VERSION 1 +#define GIT_CLONE_OPTIONS_INIT { GIT_CLONE_OPTIONS_VERSION, \ + { GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }, \ + GIT_REMOTE_CALLBACKS_INIT } + +/** + * Initializes a `git_clone_options` with default values. Equivalent to + * creating an instance with GIT_CLONE_OPTIONS_INIT. + * + * @param opts The `git_clone_options` struct to initialize + * @param version Version of struct; pass `GIT_CLONE_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_clone_init_options( + git_clone_options *opts, + unsigned int version); + +/** + * Clone a remote repository. + * + * By default this creates its repository and initial remote to match + * git's defaults. You can use the options in the callback to + * customize how these are created. + * + * @param out pointer that will receive the resulting repository object + * @param url the remote repository to clone + * @param local_path local directory to clone to + * @param options configuration options for the clone. If NULL, the + * function works as though GIT_OPTIONS_INIT were passed. + * @return 0 on success, any non-zero return value from a callback + * function, or a negative value to indicate an error (use + * `giterr_last` for a detailed error message) + */ +GIT_EXTERN(int) git_clone( + git_repository **out, + const char *url, + const char *local_path, + const git_clone_options *options); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/commit.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/commit.h new file mode 100644 index 000000000..fb53a701b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/commit.h @@ -0,0 +1,357 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_commit_h__ +#define INCLUDE_git_commit_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "object.h" + +/** + * @file git2/commit.h + * @brief Git commit parsing, formatting routines + * @defgroup git_commit Git commit parsing, formatting routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Lookup a commit object from a repository. + * + * The returned object should be released with `git_commit_free` when no + * longer needed. + * + * @param commit pointer to the looked up commit + * @param repo the repo to use when locating the commit. + * @param id identity of the commit to locate. If the object is + * an annotated tag it will be peeled back to the commit. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_lookup( + git_commit **commit, git_repository *repo, const git_oid *id); + +/** + * Lookup a commit object from a repository, given a prefix of its + * identifier (short id). + * + * The returned object should be released with `git_commit_free` when no + * longer needed. + * + * @see git_object_lookup_prefix + * + * @param commit pointer to the looked up commit + * @param repo the repo to use when locating the commit. + * @param id identity of the commit to locate. If the object is + * an annotated tag it will be peeled back to the commit. + * @param len the length of the short identifier + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_lookup_prefix( + git_commit **commit, git_repository *repo, const git_oid *id, size_t len); + +/** + * Close an open commit + * + * This is a wrapper around git_object_free() + * + * IMPORTANT: + * It *is* necessary to call this method when you stop + * using a commit. Failure to do so will cause a memory leak. + * + * @param commit the commit to close + */ + +GIT_EXTERN(void) git_commit_free(git_commit *commit); + +/** + * Get the id of a commit. + * + * @param commit a previously loaded commit. + * @return object identity for the commit. + */ +GIT_EXTERN(const git_oid *) git_commit_id(const git_commit *commit); + +/** + * Get the repository that contains the commit. + * + * @param commit A previously loaded commit. + * @return Repository that contains this commit. + */ +GIT_EXTERN(git_repository *) git_commit_owner(const git_commit *commit); + +/** + * Get the encoding for the message of a commit, + * as a string representing a standard encoding name. + * + * The encoding may be NULL if the `encoding` header + * in the commit is missing; in that case UTF-8 is assumed. + * + * @param commit a previously loaded commit. + * @return NULL, or the encoding + */ +GIT_EXTERN(const char *) git_commit_message_encoding(const git_commit *commit); + +/** + * Get the full message of a commit. + * + * The returned message will be slightly prettified by removing any + * potential leading newlines. + * + * @param commit a previously loaded commit. + * @return the message of a commit + */ +GIT_EXTERN(const char *) git_commit_message(const git_commit *commit); + +/** + * Get the full raw message of a commit. + * + * @param commit a previously loaded commit. + * @return the raw message of a commit + */ +GIT_EXTERN(const char *) git_commit_message_raw(const git_commit *commit); + +/** + * Get the short "summary" of the git commit message. + * + * The returned message is the summary of the commit, comprising the + * first paragraph of the message with whitespace trimmed and squashed. + * + * @param commit a previously loaded commit. + * @return the summary of a commit or NULL on error + */ +GIT_EXTERN(const char *) git_commit_summary(git_commit *commit); + +/** + * Get the commit time (i.e. committer time) of a commit. + * + * @param commit a previously loaded commit. + * @return the time of a commit + */ +GIT_EXTERN(git_time_t) git_commit_time(const git_commit *commit); + +/** + * Get the commit timezone offset (i.e. committer's preferred timezone) of a commit. + * + * @param commit a previously loaded commit. + * @return positive or negative timezone offset, in minutes from UTC + */ +GIT_EXTERN(int) git_commit_time_offset(const git_commit *commit); + +/** + * Get the committer of a commit. + * + * @param commit a previously loaded commit. + * @return the committer of a commit + */ +GIT_EXTERN(const git_signature *) git_commit_committer(const git_commit *commit); + +/** + * Get the author of a commit. + * + * @param commit a previously loaded commit. + * @return the author of a commit + */ +GIT_EXTERN(const git_signature *) git_commit_author(const git_commit *commit); + +/** + * Get the full raw text of the commit header. + * + * @param commit a previously loaded commit + * @return the header text of the commit + */ +GIT_EXTERN(const char *) git_commit_raw_header(const git_commit *commit); + +/** + * Get the tree pointed to by a commit. + * + * @param tree_out pointer where to store the tree object + * @param commit a previously loaded commit. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, const git_commit *commit); + +/** + * Get the id of the tree pointed to by a commit. This differs from + * `git_commit_tree` in that no attempts are made to fetch an object + * from the ODB. + * + * @param commit a previously loaded commit. + * @return the id of tree pointed to by commit. + */ +GIT_EXTERN(const git_oid *) git_commit_tree_id(const git_commit *commit); + +/** + * Get the number of parents of this commit + * + * @param commit a previously loaded commit. + * @return integer of count of parents + */ +GIT_EXTERN(unsigned int) git_commit_parentcount(const git_commit *commit); + +/** + * Get the specified parent of the commit. + * + * @param out Pointer where to store the parent commit + * @param commit a previously loaded commit. + * @param n the position of the parent (from 0 to `parentcount`) + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_parent( + git_commit **out, + const git_commit *commit, + unsigned int n); + +/** + * Get the oid of a specified parent for a commit. This is different from + * `git_commit_parent`, which will attempt to load the parent commit from + * the ODB. + * + * @param commit a previously loaded commit. + * @param n the position of the parent (from 0 to `parentcount`) + * @return the id of the parent, NULL on error. + */ +GIT_EXTERN(const git_oid *) git_commit_parent_id( + const git_commit *commit, + unsigned int n); + +/** + * Get the commit object that is the th generation ancestor + * of the named commit object, following only the first parents. + * The returned commit has to be freed by the caller. + * + * Passing `0` as the generation number returns another instance of the + * base commit itself. + * + * @param ancestor Pointer where to store the ancestor commit + * @param commit a previously loaded commit. + * @param n the requested generation + * @return 0 on success; GIT_ENOTFOUND if no matching ancestor exists + * or an error code + */ +GIT_EXTERN(int) git_commit_nth_gen_ancestor( + git_commit **ancestor, + const git_commit *commit, + unsigned int n); + +/** + * Create new commit in the repository from a list of `git_object` pointers + * + * The message will **not** be cleaned up automatically. You can do that + * with the `git_message_prettify()` function. + * + * @param id Pointer in which to store the OID of the newly created commit + * + * @param repo Repository where to store the commit + * + * @param update_ref If not NULL, name of the reference that + * will be updated to point to this commit. If the reference + * is not direct, it will be resolved to a direct reference. + * Use "HEAD" to update the HEAD of the current branch and + * make it point to this commit. If the reference doesn't + * exist yet, it will be created. If it does exist, the first + * parent must be the tip of this branch. + * + * @param author Signature with author and author time of commit + * + * @param committer Signature with committer and * commit time of commit + * + * @param message_encoding The encoding for the message in the + * commit, represented with a standard encoding name. + * E.g. "UTF-8". If NULL, no encoding header is written and + * UTF-8 is assumed. + * + * @param message Full message for this commit + * + * @param tree An instance of a `git_tree` object that will + * be used as the tree for the commit. This tree object must + * also be owned by the given `repo`. + * + * @param parent_count Number of parents for this commit + * + * @param parents Array of `parent_count` pointers to `git_commit` + * objects that will be used as the parents for this commit. This + * array may be NULL if `parent_count` is 0 (root commit). All the + * given commits must be owned by the `repo`. + * + * @return 0 or an error code + * The created commit will be written to the Object Database and + * the given reference will be updated to point to it + */ +GIT_EXTERN(int) git_commit_create( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree, + size_t parent_count, + const git_commit *parents[]); + +/** + * Create new commit in the repository using a variable argument list. + * + * The message will **not** be cleaned up automatically. You can do that + * with the `git_message_prettify()` function. + * + * The parents for the commit are specified as a variable list of pointers + * to `const git_commit *`. Note that this is a convenience method which may + * not be safe to export for certain languages or compilers + * + * All other parameters remain the same as `git_commit_create()`. + * + * @see git_commit_create + */ +GIT_EXTERN(int) git_commit_create_v( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree, + size_t parent_count, + ...); + +/** + * Amend an existing commit by replacing only non-NULL values. + * + * This creates a new commit that is exactly the same as the old commit, + * except that any non-NULL values will be updated. The new commit has + * the same parents as the old commit. + * + * The `update_ref` value works as in the regular `git_commit_create()`, + * updating the ref to point to the newly rewritten commit. If you want + * to amend a commit that is not currently the tip of the branch and then + * rewrite the following commits to reach a ref, pass this as NULL and + * update the rest of the commit chain and ref separately. + * + * Unlike `git_commit_create()`, the `author`, `committer`, `message`, + * `message_encoding`, and `tree` parameters can be NULL in which case this + * will use the values from the original `commit_to_amend`. + * + * All parameters have the same meanings as in `git_commit_create()`. + * + * @see git_commit_create + */ +GIT_EXTERN(int) git_commit_amend( + git_oid *id, + const git_commit *commit_to_amend, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/common.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/common.h new file mode 100644 index 000000000..d84a76512 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/common.h @@ -0,0 +1,250 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_common_h__ +#define INCLUDE_git_common_h__ + +#include +#include + +#ifdef _MSC_VER +# include "inttypes.h" +#else +# include +#endif + +#ifdef __cplusplus +# define GIT_BEGIN_DECL extern "C" { +# define GIT_END_DECL } +#else + /** Start declarations in C mode */ +# define GIT_BEGIN_DECL /* empty */ + /** End declarations in C mode */ +# define GIT_END_DECL /* empty */ +#endif + +/** Declare a public function exported for application use. */ +#if __GNUC__ >= 4 +# define GIT_EXTERN(type) extern \ + __attribute__((visibility("default"))) \ + type +#elif defined(_MSC_VER) +# define GIT_EXTERN(type) __declspec(dllexport) type +#else +# define GIT_EXTERN(type) extern type +#endif + +/** Declare a function's takes printf style arguments. */ +#ifdef __GNUC__ +# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b))) +#else +# define GIT_FORMAT_PRINTF(a,b) /* empty */ +#endif + +#if (defined(_WIN32)) && !defined(__CYGWIN__) +#define GIT_WIN32 1 +#endif + +#ifdef __amigaos4__ +#include +#endif + +/** + * @file git2/common.h + * @brief Git common platform definitions + * @defgroup git_common Git common platform definitions + * @ingroup Git + * @{ + */ + +GIT_BEGIN_DECL + +/** + * The separator used in path list strings (ie like in the PATH + * environment variable). A semi-colon ";" is used on Windows, and + * a colon ":" for all other systems. + */ +#ifdef GIT_WIN32 +#define GIT_PATH_LIST_SEPARATOR ';' +#else +#define GIT_PATH_LIST_SEPARATOR ':' +#endif + +/** + * The maximum length of a valid git path. + */ +#define GIT_PATH_MAX 4096 + +/** + * The string representation of the null object ID. + */ +#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000" + +/** + * Return the version of the libgit2 library + * being currently used. + * + * @param major Store the major version number + * @param minor Store the minor version number + * @param rev Store the revision (patch) number + */ +GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev); + +/** + * Combinations of these values describe the features with which libgit2 + * was compiled + */ +typedef enum { + GIT_FEATURE_THREADS = (1 << 0), + GIT_FEATURE_HTTPS = (1 << 1), + GIT_FEATURE_SSH = (1 << 2), +} git_feature_t; + +/** + * Query compile time options for libgit2. + * + * @return A combination of GIT_FEATURE_* values. + * + * - GIT_FEATURE_THREADS + * Libgit2 was compiled with thread support. Note that thread support is + * still to be seen as a 'work in progress' - basic object lookups are + * believed to be threadsafe, but other operations may not be. + * + * - GIT_FEATURE_HTTPS + * Libgit2 supports the https:// protocol. This requires the openssl + * library to be found when compiling libgit2. + * + * - GIT_FEATURE_SSH + * Libgit2 supports the SSH protocol for network operations. This requires + * the libssh2 library to be found when compiling libgit2 + */ +GIT_EXTERN(int) git_libgit2_features(void); + +/** + * Global library options + * + * These are used to select which global option to set or get and are + * used in `git_libgit2_opts()`. + */ +typedef enum { + GIT_OPT_GET_MWINDOW_SIZE, + GIT_OPT_SET_MWINDOW_SIZE, + GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, + GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, + GIT_OPT_GET_SEARCH_PATH, + GIT_OPT_SET_SEARCH_PATH, + GIT_OPT_SET_CACHE_OBJECT_LIMIT, + GIT_OPT_SET_CACHE_MAX_SIZE, + GIT_OPT_ENABLE_CACHING, + GIT_OPT_GET_CACHED_MEMORY, + GIT_OPT_GET_TEMPLATE_PATH, + GIT_OPT_SET_TEMPLATE_PATH, + GIT_OPT_SET_SSL_CERT_LOCATIONS, +} git_libgit2_opt_t; + +/** + * Set or query a library global option + * + * Available options: + * + * * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *): + * + * > Get the maximum mmap window size + * + * * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t): + * + * > Set the maximum mmap window size + * + * * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *): + * + * > Get the maximum memory that will be mapped in total by the library + * + * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t): + * + * >Set the maximum amount of memory that can be mapped at any time + * by the library + * + * * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf) + * + * > Get the search path for a given level of config data. "level" must + * > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or + * > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out` + * > buffer. + * + * * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path) + * + * > Set the search path for a level of config data. The search path + * > applied to shared attributes and ignore files, too. + * > + * > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR. + * > Pass NULL to reset to the default (generally based on environment + * > variables). Use magic path `$PATH` to include the old value + * > of the path (if you want to prepend or append, for instance). + * > + * > - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL, + * > or GIT_CONFIG_LEVEL_XDG. + * + * * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size) + * + * > Set the maximum data size for the given type of object to be + * > considered eligible for caching in memory. Setting to value to + * > zero means that that type of object will not be cached. + * > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k + * > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG. + * + * * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes) + * + * > Set the maximum total data size that will be cached in memory + * > across all repositories before libgit2 starts evicting objects + * > from the cache. This is a soft limit, in that the library might + * > briefly exceed it, but will start aggressively evicting objects + * > from cache when that happens. The default cache size is 256MB. + * + * * opts(GIT_OPT_ENABLE_CACHING, int enabled) + * + * > Enable or disable caching completely. + * > + * > Because caches are repository-specific, disabling the cache + * > cannot immediately clear all cached objects, but each cache will + * > be cleared on the next attempt to update anything in it. + * + * * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed) + * + * > Get the current bytes in cache and the maximum that would be + * > allowed in the cache. + * + * * opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out) + * + * > Get the default template path. + * > The path is written to the `out` buffer. + * + * * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path) + * + * > Set the default template path. + * > + * > - `path` directory of template. + * + * * opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, const char *file, const char *path) + * + * > Set the SSL certificate-authority locations. + * > + * > - `file` is the location of a file containing several + * > certificates concatenated together. + * > - `path` is the location of a directory holding several + * > certificates, one per file. + * > + * > Either parameter may be `NULL`, but not both. + * + * @param option Option key + * @param ... value to set the option + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_libgit2_opts(int option, ...); + +/** @} */ +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/config.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/config.h new file mode 100644 index 000000000..6d3fdb0c2 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/config.h @@ -0,0 +1,694 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_config_h__ +#define INCLUDE_git_config_h__ + +#include "common.h" +#include "types.h" +#include "buffer.h" + +/** + * @file git2/config.h + * @brief Git config management routines + * @defgroup git_config Git config management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Priority level of a config file. + * These priority levels correspond to the natural escalation logic + * (from higher to lower) when searching for config entries in git.git. + * + * git_config_open_default() and git_repository_config() honor those + * priority levels as well. + */ +typedef enum { + /** System-wide configuration file; /etc/gitconfig on Linux systems */ + GIT_CONFIG_LEVEL_SYSTEM = 1, + + /** XDG compatible configuration file; typically ~/.config/git/config */ + GIT_CONFIG_LEVEL_XDG = 2, + + /** User-specific configuration file (also called Global configuration + * file); typically ~/.gitconfig + */ + GIT_CONFIG_LEVEL_GLOBAL = 3, + + /** Repository specific configuration file; $WORK_DIR/.git/config on + * non-bare repos + */ + GIT_CONFIG_LEVEL_LOCAL = 4, + + /** Application specific configuration file; freely defined by applications + */ + GIT_CONFIG_LEVEL_APP = 5, + + /** Represents the highest level available config file (i.e. the most + * specific config file available that actually is loaded) + */ + GIT_CONFIG_HIGHEST_LEVEL = -1, +} git_config_level_t; + +/** + * An entry in a configuration file + */ +typedef struct git_config_entry { + const char *name; /**< Name of the entry (normalised) */ + const char *value; /**< String value of the entry */ + git_config_level_t level; /**< Which config file this was found in */ + void (*free)(struct git_config_entry *entry); /**< Free function for this entry */ + void *payload; /**< Opaque value for the free function. Do not read or write */ +} git_config_entry; + +/** + * Free a config entry + */ +GIT_EXTERN(void) git_config_entry_free(git_config_entry *); + +typedef int (*git_config_foreach_cb)(const git_config_entry *, void *); +typedef struct git_config_iterator git_config_iterator; + +/** + * Config var type + */ +typedef enum { + GIT_CVAR_FALSE = 0, + GIT_CVAR_TRUE = 1, + GIT_CVAR_INT32, + GIT_CVAR_STRING +} git_cvar_t; + +/** + * Mapping from config variables to values. + */ +typedef struct { + git_cvar_t cvar_type; + const char *str_match; + int map_value; +} git_cvar_map; + +/** + * Locate the path to the global configuration file + * + * The user or global configuration file is usually + * located in `$HOME/.gitconfig`. + * + * This method will try to guess the full path to that + * file, if the file exists. The returned path + * may be used on any `git_config` call to load the + * global configuration file. + * + * This method will not guess the path to the xdg compatible + * config file (.config/git/config). + * + * @param out Pointer to a user-allocated git_buf in which to store the path + * @return 0 if a global configuration file has been found. Its path will be stored in `out`. + */ +GIT_EXTERN(int) git_config_find_global(git_buf *out); + +/** + * Locate the path to the global xdg compatible configuration file + * + * The xdg compatible configuration file is usually + * located in `$HOME/.config/git/config`. + * + * This method will try to guess the full path to that + * file, if the file exists. The returned path + * may be used on any `git_config` call to load the + * xdg compatible configuration file. + * + * @param out Pointer to a user-allocated git_buf in which to store the path + * @return 0 if a xdg compatible configuration file has been + * found. Its path will be stored in `out`. + */ +GIT_EXTERN(int) git_config_find_xdg(git_buf *out); + +/** + * Locate the path to the system configuration file + * + * If /etc/gitconfig doesn't exist, it will look for + * %PROGRAMFILES%\Git\etc\gitconfig. + * + * @param out Pointer to a user-allocated git_buf in which to store the path + * @return 0 if a system configuration file has been + * found. Its path will be stored in `out`. + */ +GIT_EXTERN(int) git_config_find_system(git_buf *out); + +/** + * Open the global, XDG and system configuration files + * + * Utility wrapper that finds the global, XDG and system configuration files + * and opens them into a single prioritized config object that can be + * used when accessing default config data outside a repository. + * + * @param out Pointer to store the config instance + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_open_default(git_config **out); + +/** + * Allocate a new configuration object + * + * This object is empty, so you have to add a file to it before you + * can do anything with it. + * + * @param out pointer to the new configuration + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_new(git_config **out); + +/** + * Add an on-disk config file instance to an existing config + * + * The on-disk file pointed at by `path` will be opened and + * parsed; it's expected to be a native Git config file following + * the default Git config syntax (see man git-config). + * + * Note that the configuration object will free the file + * automatically. + * + * Further queries on this config object will access each + * of the config file instances in order (instances with + * a higher priority level will be accessed first). + * + * @param cfg the configuration to add the file to + * @param path path to the configuration file to add + * @param level the priority level of the backend + * @param force replace config file at the given priority level + * @return 0 on success, GIT_EEXISTS when adding more than one file + * for a given priority level (and force_replace set to 0), + * GIT_ENOTFOUND when the file doesn't exist or error code + */ +GIT_EXTERN(int) git_config_add_file_ondisk( + git_config *cfg, + const char *path, + git_config_level_t level, + int force); + +/** + * Create a new config instance containing a single on-disk file + * + * This method is a simple utility wrapper for the following sequence + * of calls: + * - git_config_new + * - git_config_add_file_ondisk + * + * @param out The configuration instance to create + * @param path Path to the on-disk file to open + * @return 0 on success, GIT_ENOTFOUND when the file doesn't exist + * or an error code + */ +GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path); + +/** + * Build a single-level focused config object from a multi-level one. + * + * The returned config object can be used to perform get/set/delete operations + * on a single specific level. + * + * Getting several times the same level from the same parent multi-level config + * will return different config instances, but containing the same config_file + * instance. + * + * @param out The configuration instance to create + * @param parent Multi-level config to search for the given level + * @param level Configuration level to search for + * @return 0, GIT_ENOTFOUND if the passed level cannot be found in the + * multi-level parent config, or an error code + */ +GIT_EXTERN(int) git_config_open_level( + git_config **out, + const git_config *parent, + git_config_level_t level); + +/** + * Open the global/XDG configuration file according to git's rules + * + * Git allows you to store your global configuration at + * `$HOME/.config` or `$XDG_CONFIG_HOME/git/config`. For backwards + * compatability, the XDG file shouldn't be used unless the use has + * created it explicitly. With this function you'll open the correct + * one to write to. + * + * @param out pointer in which to store the config object + * @param config the config object in which to look + */ +GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config); + +/** + * Create a snapshot of the configuration + * + * Create a snapshot of the current state of a configuration, which + * allows you to look into a consistent view of the configuration for + * looking up complex values (e.g. a remote, submodule). + * + * The string returned when querying such a config object is valid + * until it is freed. + * + * @param out pointer in which to store the snapshot config object + * @param config configuration to snapshot + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_snapshot(git_config **out, git_config *config); + +/** + * Free the configuration and its associated memory and files + * + * @param cfg the configuration to free + */ +GIT_EXTERN(void) git_config_free(git_config *cfg); + +/** + * Get the git_config_entry of a config variable. + * + * Free the git_config_entry after use with `git_config_entry_free()`. + * + * @param out pointer to the variable git_config_entry + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_entry( + git_config_entry **out, + const git_config *cfg, + const char *name); + +/** + * Get the value of an integer config variable. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out pointer to the variable where the value should be stored + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name); + +/** + * Get the value of a long integer config variable. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out pointer to the variable where the value should be stored + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name); + +/** + * Get the value of a boolean config variable. + * + * This function uses the usual C convention of 0 being false and + * anything else true. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out pointer to the variable where the value should be stored + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name); + +/** + * Get the value of a path config variable. + * + * A leading '~' will be expanded to the global search path (which + * defaults to the user's home directory but can be overridden via + * `git_libgit2_opts()`. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out the buffer in which to store the result + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_path(git_buf *out, const git_config *cfg, const char *name); + +/** + * Get the value of a string config variable. + * + * This function can only be used on snapshot config objects. The + * string is owned by the config and should not be freed by the + * user. The pointer will be valid until the config is freed. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out pointer to the string + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name); + +/** + * Get the value of a string config variable. + * + * The value of the config will be copied into the buffer. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out buffer in which to store the string + * @param cfg where to look for the variable + * @param name the variable's name + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_get_string_buf(git_buf *out, const git_config *cfg, const char *name); + +/** + * Get each value of a multivar in a foreach callback + * + * The callback will be called on each variable found + * + * @param cfg where to look for the variable + * @param name the variable's name + * @param regexp regular expression to filter which variables we're + * interested in. Use NULL to indicate all + * @param callback the function to be called on each value of the variable + * @param payload opaque pointer to pass to the callback + */ +GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload); + +/** + * Get each value of a multivar + * + * @param out pointer to store the iterator + * @param cfg where to look for the variable + * @param name the variable's name + * @param regexp regular expression to filter which variables we're + * interested in. Use NULL to indicate all + */ +GIT_EXTERN(int) git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp); + +/** + * Return the current entry and advance the iterator + * + * The pointers returned by this function are valid until the iterator + * is freed. + * + * @param entry pointer to store the entry + * @param iter the iterator + * @return 0 or an error code. GIT_ITEROVER if the iteration has completed + */ +GIT_EXTERN(int) git_config_next(git_config_entry **entry, git_config_iterator *iter); + +/** + * Free a config iterator + * + * @param iter the iterator to free + */ +GIT_EXTERN(void) git_config_iterator_free(git_config_iterator *iter); + +/** + * Set the value of an integer config variable in the config file + * with the highest level (usually the local one). + * + * @param cfg where to look for the variable + * @param name the variable's name + * @param value Integer value for the variable + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value); + +/** + * Set the value of a long integer config variable in the config file + * with the highest level (usually the local one). + * + * @param cfg where to look for the variable + * @param name the variable's name + * @param value Long integer value for the variable + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value); + +/** + * Set the value of a boolean config variable in the config file + * with the highest level (usually the local one). + * + * @param cfg where to look for the variable + * @param name the variable's name + * @param value the value to store + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value); + +/** + * Set the value of a string config variable in the config file + * with the highest level (usually the local one). + * + * A copy of the string is made and the user is free to use it + * afterwards. + * + * @param cfg where to look for the variable + * @param name the variable's name + * @param value the string to store. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value); + +/** + * Set a multivar in the local config file. + * + * @param cfg where to look for the variable + * @param name the variable's name + * @param regexp a regular expression to indicate which values to replace + * @param value the new value. + */ +GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value); + +/** + * Delete a config variable from the config file + * with the highest level (usually the local one). + * + * @param cfg the configuration + * @param name the variable to delete + */ +GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name); + +/** + * Deletes one or several entries from a multivar in the local config file. + * + * @param cfg where to look for the variables + * @param name the variable's name + * @param regexp a regular expression to indicate which values to delete + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp); + +/** + * Perform an operation on each config variable. + * + * The callback receives the normalized name and value of each variable + * in the config backend, and the data pointer passed to this function. + * If the callback returns a non-zero value, the function stops iterating + * and returns that value to the caller. + * + * The pointers passed to the callback are only valid as long as the + * iteration is ongoing. + * + * @param cfg where to get the variables from + * @param callback the function to call on each variable + * @param payload the data to pass to the callback + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_config_foreach( + const git_config *cfg, + git_config_foreach_cb callback, + void *payload); + +/** + * Iterate over all the config variables + * + * Use `git_config_next` to advance the iteration and + * `git_config_iterator_free` when done. + * + * @param out pointer to store the iterator + * @param cfg where to ge the variables from + */ +GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_config *cfg); + +/** + * Iterate over all the config variables whose name matches a pattern + * + * Use `git_config_next` to advance the iteration and + * `git_config_iterator_free` when done. + * + * @param out pointer to store the iterator + * @param cfg where to ge the variables from + * @param regexp regular expression to match the names + */ +GIT_EXTERN(int) git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp); + +/** + * Perform an operation on each config variable matching a regular expression. + * + * This behaviors like `git_config_foreach` with an additional filter of a + * regular expression that filters which config keys are passed to the + * callback. + * + * The pointers passed to the callback are only valid as long as the + * iteration is ongoing. + * + * @param cfg where to get the variables from + * @param regexp regular expression to match against config names + * @param callback the function to call on each variable + * @param payload the data to pass to the callback + * @return 0 or the return value of the callback which didn't return 0 + */ +GIT_EXTERN(int) git_config_foreach_match( + const git_config *cfg, + const char *regexp, + git_config_foreach_cb callback, + void *payload); + +/** + * Query the value of a config variable and return it mapped to + * an integer constant. + * + * This is a helper method to easily map different possible values + * to a variable to integer constants that easily identify them. + * + * A mapping array looks as follows: + * + * git_cvar_map autocrlf_mapping[] = { + * {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, + * {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, + * {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT}, + * {GIT_CVAR_STRING, "default", GIT_AUTO_CRLF_DEFAULT}}; + * + * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the + * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter. + * + * The same thing applies for any "true" value such as "true", "yes" or "1", storing + * the `GIT_AUTO_CRLF_TRUE` variable. + * + * Otherwise, if the value matches the string "input" (with case insensitive comparison), + * the given constant will be stored in `out`, and likewise for "default". + * + * If not a single match can be made to store in `out`, an error code will be + * returned. + * + * @param out place to store the result of the mapping + * @param cfg config file to get the variables from + * @param name name of the config variable to lookup + * @param maps array of `git_cvar_map` objects specifying the possible mappings + * @param map_n number of mapping objects in `maps` + * @return 0 on success, error code otherwise + */ +GIT_EXTERN(int) git_config_get_mapped( + int *out, + const git_config *cfg, + const char *name, + const git_cvar_map *maps, + size_t map_n); + +/** + * Maps a string value to an integer constant + * + * @param out place to store the result of the parsing + * @param maps array of `git_cvar_map` objects specifying the possible mappings + * @param map_n number of mapping objects in `maps` + * @param value value to parse + */ +GIT_EXTERN(int) git_config_lookup_map_value( + int *out, + const git_cvar_map *maps, + size_t map_n, + const char *value); + +/** + * Parse a string value as a bool. + * + * Valid values for true are: 'true', 'yes', 'on', 1 or any + * number different from 0 + * Valid values for false are: 'false', 'no', 'off', 0 + * + * @param out place to store the result of the parsing + * @param value value to parse + */ +GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value); + +/** + * Parse a string value as an int32. + * + * An optional value suffix of 'k', 'm', or 'g' will + * cause the value to be multiplied by 1024, 1048576, + * or 1073741824 prior to output. + * + * @param out place to store the result of the parsing + * @param value value to parse + */ +GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value); + +/** + * Parse a string value as an int64. + * + * An optional value suffix of 'k', 'm', or 'g' will + * cause the value to be multiplied by 1024, 1048576, + * or 1073741824 prior to output. + * + * @param out place to store the result of the parsing + * @param value value to parse + */ +GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value); + +/** + * Parse a string value as a path. + * + * A leading '~' will be expanded to the global search path (which + * defaults to the user's home directory but can be overridden via + * `git_libgit2_opts()`. + * + * If the value does not begin with a tilde, the input will be + * returned. + * + * @param out placae to store the result of parsing + * @param value the path to evaluate + */ +GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value); + +/** + * Perform an operation on each config variable in given config backend + * matching a regular expression. + * + * This behaviors like `git_config_foreach_match` except instead of all config + * entries it just enumerates through the given backend entry. + * + * @param backend where to get the variables from + * @param regexp regular expression to match against config names (can be NULL) + * @param callback the function to call on each variable + * @param payload the data to pass to the callback + */ +GIT_EXTERN(int) git_config_backend_foreach_match( + git_config_backend *backend, + const char *regexp, + git_config_foreach_cb callback, + void *payload); + + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/cred_helpers.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/cred_helpers.h new file mode 100644 index 000000000..1d8809211 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/cred_helpers.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_cred_helpers_h__ +#define INCLUDE_git_cred_helpers_h__ + +#include "transport.h" + +/** + * @file git2/cred_helpers.h + * @brief Utility functions for credential management + * @defgroup git_cred_helpers credential management helpers + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Payload for git_cred_stock_userpass_plaintext. + */ +typedef struct git_cred_userpass_payload { + char *username; + char *password; +} git_cred_userpass_payload; + + +/** + * Stock callback usable as a git_cred_acquire_cb. This calls + * git_cred_userpass_plaintext_new unless the protocol has not specified + * `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type. + * + * @param cred The newly created credential object. + * @param url The resource for which we are demanding a credential. + * @param user_from_url The username that was embedded in a "user@host" + * remote url, or NULL if not included. + * @param allowed_types A bitmask stating which cred types are OK to return. + * @param payload The payload provided when specifying this callback. (This is + * interpreted as a `git_cred_userpass_payload*`.) + */ +GIT_EXTERN(int) git_cred_userpass( + git_cred **cred, + const char *url, + const char *user_from_url, + unsigned int allowed_types, + void *payload); + + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/describe.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/describe.h new file mode 100644 index 000000000..d01a3f74c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/describe.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_describe_h__ +#define INCLUDE_git_describe_h__ + +#include "common.h" +#include "types.h" +#include "buffer.h" + +/** + * @file git2/describe.h + * @brief Git describing routines + * @defgroup git_describe Git describing routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Reference lookup strategy + * + * These behave like the --tags and --all optios to git-describe, + * namely they say to look for any reference in either refs/tags/ or + * refs/ respectively. + */ +typedef enum { + GIT_DESCRIBE_DEFAULT, + GIT_DESCRIBE_TAGS, + GIT_DESCRIBE_ALL, +} git_describe_strategy_t; + +/** + * Describe options structure + * + * Initialize with `GIT_DESCRIBE_OPTIONS_INIT` macro to correctly set + * the `version` field. E.g. + * + * git_describe_options opts = GIT_DESCRIBE_OPTIONS_INIT; + */ +typedef struct git_describe_options { + unsigned int version; + + unsigned int max_candidates_tags; /** default: 10 */ + unsigned int describe_strategy; /** default: GIT_DESCRIBE_DEFAULT */ + const char *pattern; + /** + * When calculating the distance from the matching tag or + * reference, only walk down the first-parent ancestry. + */ + int only_follow_first_parent; + /** + * If no matching tag or reference is found, the describe + * operation would normally fail. If this option is set, it + * will instead fall back to showing the full id of the + * commit. + */ + int show_commit_oid_as_fallback; +} git_describe_options; + +#define GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS 10 +#define GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE 7 + +#define GIT_DESCRIBE_OPTIONS_VERSION 1 +#define GIT_DESCRIBE_OPTIONS_INIT { \ + GIT_DESCRIBE_OPTIONS_VERSION, \ + GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS, \ +} + +GIT_EXTERN(int) git_describe_init_options(git_describe_options *opts, unsigned int version); + +/** + * Options for formatting the describe string + */ +typedef struct { + unsigned int version; + + /** + * Size of the abbreviated commit id to use. This value is the + * lower bound for the length of the abbreviated string. The + * default is 7. + */ + unsigned int abbreviated_size; + + /** + * Set to use the long format even when a shorter name could be used. + */ + int always_use_long_format; + + /** + * If the workdir is dirty and this is set, this string will + * be appended to the description string. + */ + char *dirty_suffix; +} git_describe_format_options; + +#define GIT_DESCRIBE_FORMAT_OPTIONS_VERSION 1 +#define GIT_DESCRIBE_FORMAT_OPTIONS_INIT { \ + GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, \ + GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE, \ + } + +GIT_EXTERN(int) git_describe_init_format_options(git_describe_format_options *opts, unsigned int version); + +typedef struct git_describe_result git_describe_result; + +/** + * Describe a commit + * + * Perform the describe operation on the given committish object. + * + * @param result pointer to store the result. You must free this once + * you're done with it. + * @param committish a committish to describe + * @param opts the lookup options + */ +GIT_EXTERN(int) git_describe_commit( + git_describe_result **result, + git_object *committish, + git_describe_options *opts); + +/** + * Describe a commit + * + * Perform the describe operation on the current commit and the + * worktree. After peforming describe on HEAD, a status is run and the + * description is considered to be dirty if there are. + * + * @param out pointer to store the result. You must free this once + * you're done with it. + * @param repo the repository in which to perform the describe + * @param opts the lookup options + */ +GIT_EXTERN(int) git_describe_workdir( + git_describe_result **out, + git_repository *repo, + git_describe_options *opts); + +/** + * Print the describe result to a buffer + * + * @param out The buffer to store the result + * @param result the result from `git_describe_commit()` or + * `git_describe_workdir()`. + * @param opts the formatting options + */ +GIT_EXTERN(int) git_describe_format( + git_buf *out, + const git_describe_result *result, + const git_describe_format_options *opts); + +/** + * Free the describe result. + */ +GIT_EXTERN(void) git_describe_result_free(git_describe_result *result); + +/** @} */ +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/diff.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/diff.h new file mode 100644 index 000000000..9fcc3bb08 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/diff.h @@ -0,0 +1,1245 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_diff_h__ +#define INCLUDE_git_diff_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "tree.h" +#include "refs.h" + +/** + * @file git2/diff.h + * @brief Git tree and file differencing routines. + * + * Overview + * -------- + * + * Calculating diffs is generally done in two phases: building a list of + * diffs then traversing it. This makes is easier to share logic across + * the various types of diffs (tree vs tree, workdir vs index, etc.), and + * also allows you to insert optional diff post-processing phases, + * such as rename detection, in between the steps. When you are done with + * a diff object, it must be freed. + * + * Terminology + * ----------- + * + * To understand the diff APIs, you should know the following terms: + * + * - A `diff` represents the cumulative list of differences between two + * snapshots of a repository (possibly filtered by a set of file name + * patterns). This is the `git_diff` object. + * + * - A `delta` is a file pair with an old and new revision. The old version + * may be absent if the file was just created and the new version may be + * absent if the file was deleted. A diff is mostly just a list of deltas. + * + * - A `binary` file / delta is a file (or pair) for which no text diffs + * should be generated. A diff can contain delta entries that are + * binary, but no diff content will be output for those files. There is + * a base heuristic for binary detection and you can further tune the + * behavior with git attributes or diff flags and option settings. + * + * - A `hunk` is a span of modified lines in a delta along with some stable + * surrounding context. You can configure the amount of context and other + * properties of how hunks are generated. Each hunk also comes with a + * header that described where it starts and ends in both the old and new + * versions in the delta. + * + * - A `line` is a range of characters inside a hunk. It could be a context + * line (i.e. in both old and new versions), an added line (i.e. only in + * the new version), or a removed line (i.e. only in the old version). + * Unfortunately, we don't know anything about the encoding of data in the + * file being diffed, so we cannot tell you much about the line content. + * Line data will not be NUL-byte terminated, however, because it will be + * just a span of bytes inside the larger file. + * + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Flags for diff options. A combination of these flags can be passed + * in via the `flags` value in the `git_diff_options`. + */ +typedef enum { + /** Normal diff, the default */ + GIT_DIFF_NORMAL = 0, + + /* + * Options controlling which files will be in the diff + */ + + /** Reverse the sides of the diff */ + GIT_DIFF_REVERSE = (1u << 0), + + /** Include ignored files in the diff */ + GIT_DIFF_INCLUDE_IGNORED = (1u << 1), + + /** Even with GIT_DIFF_INCLUDE_IGNORED, an entire ignored directory + * will be marked with only a single entry in the diff; this flag + * adds all files under the directory as IGNORED entries, too. + */ + GIT_DIFF_RECURSE_IGNORED_DIRS = (1u << 2), + + /** Include untracked files in the diff */ + GIT_DIFF_INCLUDE_UNTRACKED = (1u << 3), + + /** Even with GIT_DIFF_INCLUDE_UNTRACKED, an entire untracked + * directory will be marked with only a single entry in the diff + * (a la what core Git does in `git status`); this flag adds *all* + * files under untracked directories as UNTRACKED entries, too. + */ + GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1u << 4), + + /** Include unmodified files in the diff */ + GIT_DIFF_INCLUDE_UNMODIFIED = (1u << 5), + + /** Normally, a type change between files will be converted into a + * DELETED record for the old and an ADDED record for the new; this + * options enabled the generation of TYPECHANGE delta records. + */ + GIT_DIFF_INCLUDE_TYPECHANGE = (1u << 6), + + /** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still + * generally show as a DELETED blob. This flag tries to correctly + * label blob->tree transitions as TYPECHANGE records with new_file's + * mode set to tree. Note: the tree SHA will not be available. + */ + GIT_DIFF_INCLUDE_TYPECHANGE_TREES = (1u << 7), + + /** Ignore file mode changes */ + GIT_DIFF_IGNORE_FILEMODE = (1u << 8), + + /** Treat all submodules as unmodified */ + GIT_DIFF_IGNORE_SUBMODULES = (1u << 9), + + /** Use case insensitive filename comparisons */ + GIT_DIFF_IGNORE_CASE = (1u << 10), + + /** If the pathspec is set in the diff options, this flags means to + * apply it as an exact match instead of as an fnmatch pattern. + */ + GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1u << 12), + + /** Disable updating of the `binary` flag in delta records. This is + * useful when iterating over a diff if you don't need hunk and data + * callbacks and want to avoid having to load file completely. + */ + GIT_DIFF_SKIP_BINARY_CHECK = (1u << 13), + + /** When diff finds an untracked directory, to match the behavior of + * core Git, it scans the contents for IGNORED and UNTRACKED files. + * If *all* contents are IGNORED, then the directory is IGNORED; if + * any contents are not IGNORED, then the directory is UNTRACKED. + * This is extra work that may not matter in many cases. This flag + * turns off that scan and immediately labels an untracked directory + * as UNTRACKED (changing the behavior to not match core Git). + */ + GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS = (1u << 14), + + /** When diff finds a file in the working directory with stat + * information different from the index, but the OID ends up being the + * same, write the correct stat information into the index. Note: + * without this flag, diff will always leave the index untouched. + */ + GIT_DIFF_UPDATE_INDEX = (1u << 15), + + /** Include unreadable files in the diff */ + GIT_DIFF_INCLUDE_UNREADABLE = (1u << 16), + + /** Include unreadable files in the diff */ + GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 17), + + /* + * Options controlling how output will be generated + */ + + /** Treat all files as text, disabling binary attributes & detection */ + GIT_DIFF_FORCE_TEXT = (1u << 20), + /** Treat all files as binary, disabling text diffs */ + GIT_DIFF_FORCE_BINARY = (1u << 21), + + /** Ignore all whitespace */ + GIT_DIFF_IGNORE_WHITESPACE = (1u << 22), + /** Ignore changes in amount of whitespace */ + GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1u << 23), + /** Ignore whitespace at end of line */ + GIT_DIFF_IGNORE_WHITESPACE_EOL = (1u << 24), + + /** When generating patch text, include the content of untracked + * files. This automatically turns on GIT_DIFF_INCLUDE_UNTRACKED but + * it does not turn on GIT_DIFF_RECURSE_UNTRACKED_DIRS. Add that + * flag if you want the content of every single UNTRACKED file. + */ + GIT_DIFF_SHOW_UNTRACKED_CONTENT = (1u << 25), + + /** When generating output, include the names of unmodified files if + * they are included in the git_diff. Normally these are skipped in + * the formats that list files (e.g. name-only, name-status, raw). + * Even with this, these will not be included in patch format. + */ + GIT_DIFF_SHOW_UNMODIFIED = (1u << 26), + + /** Use the "patience diff" algorithm */ + GIT_DIFF_PATIENCE = (1u << 28), + /** Take extra time to find minimal diff */ + GIT_DIFF_MINIMAL = (1 << 29), + + /** Include the necessary deflate / delta information so that `git-apply` + * can apply given diff information to binary files. + */ + GIT_DIFF_SHOW_BINARY = (1 << 30), +} git_diff_option_t; + +/** + * The diff object that contains all individual file deltas. + * + * This is an opaque structure which will be allocated by one of the diff + * generator functions below (such as `git_diff_tree_to_tree`). You are + * responsible for releasing the object memory when done, using the + * `git_diff_free()` function. + */ +typedef struct git_diff git_diff; + +/** + * Flags for the delta object and the file objects on each side. + * + * These flags are used for both the `flags` value of the `git_diff_delta` + * and the flags for the `git_diff_file` objects representing the old and + * new sides of the delta. Values outside of this public range should be + * considered reserved for internal or future use. + */ +typedef enum { + GIT_DIFF_FLAG_BINARY = (1u << 0), /**< file(s) treated as binary data */ + GIT_DIFF_FLAG_NOT_BINARY = (1u << 1), /**< file(s) treated as text data */ + GIT_DIFF_FLAG_VALID_ID = (1u << 2), /**< `id` value is known correct */ +} git_diff_flag_t; + +/** + * What type of change is described by a git_diff_delta? + * + * `GIT_DELTA_RENAMED` and `GIT_DELTA_COPIED` will only show up if you run + * `git_diff_find_similar()` on the diff object. + * + * `GIT_DELTA_TYPECHANGE` only shows up given `GIT_DIFF_INCLUDE_TYPECHANGE` + * in the option flags (otherwise type changes will be split into ADDED / + * DELETED pairs). + */ +typedef enum { + GIT_DELTA_UNMODIFIED = 0, /**< no changes */ + GIT_DELTA_ADDED = 1, /**< entry does not exist in old version */ + GIT_DELTA_DELETED = 2, /**< entry does not exist in new version */ + GIT_DELTA_MODIFIED = 3, /**< entry content changed between old and new */ + GIT_DELTA_RENAMED = 4, /**< entry was renamed between old and new */ + GIT_DELTA_COPIED = 5, /**< entry was copied from another old entry */ + GIT_DELTA_IGNORED = 6, /**< entry is ignored item in workdir */ + GIT_DELTA_UNTRACKED = 7, /**< entry is untracked item in workdir */ + GIT_DELTA_TYPECHANGE = 8, /**< type of entry changed between old and new */ + GIT_DELTA_UNREADABLE = 9, /**< entry is unreadable */ +} git_delta_t; + +/** + * Description of one side of a delta. + * + * Although this is called a "file", it could represent a file, a symbolic + * link, a submodule commit id, or even a tree (although that only if you + * are tracking type changes or ignored/untracked directories). + * + * The `oid` is the `git_oid` of the item. If the entry represents an + * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), + * then the oid will be zeroes. + * + * `path` is the NUL-terminated path to the entry relative to the working + * directory of the repository. + * + * `size` is the size of the entry in bytes. + * + * `flags` is a combination of the `git_diff_flag_t` types + * + * `mode` is, roughly, the stat() `st_mode` value for the item. This will + * be restricted to one of the `git_filemode_t` values. + */ +typedef struct { + git_oid id; + const char *path; + git_off_t size; + uint32_t flags; + uint16_t mode; +} git_diff_file; + +/** + * Description of changes to one entry. + * + * When iterating over a diff, this will be passed to most callbacks and + * you can use the contents to understand exactly what has changed. + * + * The `old_file` represents the "from" side of the diff and the `new_file` + * represents to "to" side of the diff. What those means depend on the + * function that was used to generate the diff and will be documented below. + * You can also use the `GIT_DIFF_REVERSE` flag to flip it around. + * + * Although the two sides of the delta are named "old_file" and "new_file", + * they actually may correspond to entries that represent a file, a symbolic + * link, a submodule commit id, or even a tree (if you are tracking type + * changes or ignored/untracked directories). + * + * Under some circumstances, in the name of efficiency, not all fields will + * be filled in, but we generally try to fill in as much as possible. One + * example is that the "flags" field may not have either the `BINARY` or the + * `NOT_BINARY` flag set to avoid examining file contents if you do not pass + * in hunk and/or line callbacks to the diff foreach iteration function. It + * will just use the git attributes for those files. + * + * The similarity score is zero unless you call `git_diff_find_similar()` + * which does a similarity analysis of files in the diff. Use that + * function to do rename and copy detection, and to split heavily modified + * files in add/delete pairs. After that call, deltas with a status of + * GIT_DELTA_RENAMED or GIT_DELTA_COPIED will have a similarity score + * between 0 and 100 indicating how similar the old and new sides are. + * + * If you ask `git_diff_find_similar` to find heavily modified files to + * break, but to not *actually* break the records, then GIT_DELTA_MODIFIED + * records may have a non-zero similarity score if the self-similarity is + * below the split threshold. To display this value like core Git, invert + * the score (a la `printf("M%03d", 100 - delta->similarity)`). + */ +typedef struct { + git_delta_t status; + uint32_t flags; /**< git_diff_flag_t values */ + uint16_t similarity; /**< for RENAMED and COPIED, value 0-100 */ + uint16_t nfiles; /**< number of files in this delta */ + git_diff_file old_file; + git_diff_file new_file; +} git_diff_delta; + +/** + * Diff notification callback function. + * + * The callback will be called for each file, just before the `git_delta_t` + * gets inserted into the diff. + * + * When the callback: + * - returns < 0, the diff process will be aborted. + * - returns > 0, the delta will not be inserted into the diff, but the + * diff process continues. + * - returns 0, the delta is inserted into the diff, and the diff process + * continues. + */ +typedef int (*git_diff_notify_cb)( + const git_diff *diff_so_far, + const git_diff_delta *delta_to_add, + const char *matched_pathspec, + void *payload); + +/** + * Structure describing options about how the diff should be executed. + * + * Setting all values of the structure to zero will yield the default + * values. Similarly, passing NULL for the options structure will + * give the defaults. The default values are marked below. + * + * - `flags` is a combination of the `git_diff_option_t` values above + * - `context_lines` is the number of unchanged lines that define the + * boundary of a hunk (and to display before and after) + * - `interhunk_lines` is the maximum number of unchanged lines between + * hunk boundaries before the hunks will be merged into a one. + * - `old_prefix` is the virtual "directory" to prefix to old file names + * in hunk headers (default "a") + * - `new_prefix` is the virtual "directory" to prefix to new file names + * in hunk headers (default "b") + * - `pathspec` is an array of paths / fnmatch patterns to constrain diff + * - `max_size` is a file size (in bytes) above which a blob will be marked + * as binary automatically; pass a negative value to disable. + * - `notify_cb` is an optional callback function, notifying the consumer of + * which files are being examined as the diff is generated + * - `notify_payload` is the payload data to pass to the `notify_cb` function + * - `ignore_submodules` overrides the submodule ignore setting for all + * submodules in the diff. + */ +typedef struct { + unsigned int version; /**< version for the struct */ + uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */ + + /* options controlling which files are in the diff */ + + git_submodule_ignore_t ignore_submodules; /**< submodule ignore rule */ + git_strarray pathspec; /**< defaults to include all paths */ + git_diff_notify_cb notify_cb; + void *notify_payload; + + /* options controlling how to diff text is generated */ + + uint32_t context_lines; /**< defaults to 3 */ + uint32_t interhunk_lines; /**< defaults to 0 */ + uint16_t id_abbrev; /**< default 'core.abbrev' or 7 if unset */ + git_off_t max_size; /**< defaults to 512MB */ + const char *old_prefix; /**< defaults to "a" */ + const char *new_prefix; /**< defaults to "b" */ +} git_diff_options; + +/* The current version of the diff options structure */ +#define GIT_DIFF_OPTIONS_VERSION 1 + +/* Stack initializer for diff options. Alternatively use + * `git_diff_options_init` programmatic initialization. + */ +#define GIT_DIFF_OPTIONS_INIT \ + {GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_DEFAULT, {NULL,0}, NULL, NULL, 3} + +/** + * Initializes a `git_diff_options` with default values. Equivalent to + * creating an instance with GIT_DIFF_OPTIONS_INIT. + * + * @param opts The `git_diff_options` struct to initialize + * @param version Version of struct; pass `GIT_DIFF_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_diff_init_options( + git_diff_options *opts, + unsigned int version); + +/** + * When iterating over a diff, callback that will be made per file. + * + * @param delta A pointer to the delta data for the file + * @param progress Goes from 0 to 1 over the diff + * @param payload User-specified pointer from foreach function + */ +typedef int (*git_diff_file_cb)( + const git_diff_delta *delta, + float progress, + void *payload); + +/** + * Structure describing a hunk of a diff. + */ +typedef struct { + int old_start; /**< Starting line number in old_file */ + int old_lines; /**< Number of lines in old_file */ + int new_start; /**< Starting line number in new_file */ + int new_lines; /**< Number of lines in new_file */ + size_t header_len; /**< Number of bytes in header text */ + char header[128]; /**< Header text, NUL-byte terminated */ +} git_diff_hunk; + +/** + * When iterating over a diff, callback that will be made per hunk. + */ +typedef int (*git_diff_hunk_cb)( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + void *payload); + +/** + * Line origin constants. + * + * These values describe where a line came from and will be passed to + * the git_diff_line_cb when iterating over a diff. There are some + * special origin constants at the end that are used for the text + * output callbacks to demarcate lines that are actually part of + * the file or hunk headers. + */ +typedef enum { + /* These values will be sent to `git_diff_line_cb` along with the line */ + GIT_DIFF_LINE_CONTEXT = ' ', + GIT_DIFF_LINE_ADDITION = '+', + GIT_DIFF_LINE_DELETION = '-', + + GIT_DIFF_LINE_CONTEXT_EOFNL = '=', /**< Both files have no LF at end */ + GIT_DIFF_LINE_ADD_EOFNL = '>', /**< Old has no LF at end, new does */ + GIT_DIFF_LINE_DEL_EOFNL = '<', /**< Old has LF at end, new does not */ + + /* The following values will only be sent to a `git_diff_line_cb` when + * the content of a diff is being formatted through `git_diff_print`. + */ + GIT_DIFF_LINE_FILE_HDR = 'F', + GIT_DIFF_LINE_HUNK_HDR = 'H', + GIT_DIFF_LINE_BINARY = 'B' /**< For "Binary files x and y differ" */ +} git_diff_line_t; + +/** + * Structure describing a line (or data span) of a diff. + */ +typedef struct { + char origin; /**< A git_diff_line_t value */ + int old_lineno; /**< Line number in old file or -1 for added line */ + int new_lineno; /**< Line number in new file or -1 for deleted line */ + int num_lines; /**< Number of newline characters in content */ + size_t content_len; /**< Number of bytes of data */ + git_off_t content_offset; /**< Offset in the original file to the content */ + const char *content; /**< Pointer to diff text, not NUL-byte terminated */ +} git_diff_line; + +/** + * When iterating over a diff, callback that will be made per text diff + * line. In this context, the provided range will be NULL. + * + * When printing a diff, callback that will be made to output each line + * of text. This uses some extra GIT_DIFF_LINE_... constants for output + * of lines of file and hunk headers. + */ +typedef int (*git_diff_line_cb)( + const git_diff_delta *delta, /**< delta that contains this data */ + const git_diff_hunk *hunk, /**< hunk containing this data */ + const git_diff_line *line, /**< line data */ + void *payload); /**< user reference data */ + +/** + * Flags to control the behavior of diff rename/copy detection. + */ +typedef enum { + /** Obey `diff.renames`. Overridden by any other GIT_DIFF_FIND_... flag. */ + GIT_DIFF_FIND_BY_CONFIG = 0, + + /** Look for renames? (`--find-renames`) */ + GIT_DIFF_FIND_RENAMES = (1u << 0), + + /** Consider old side of MODIFIED for renames? (`--break-rewrites=N`) */ + GIT_DIFF_FIND_RENAMES_FROM_REWRITES = (1u << 1), + + /** Look for copies? (a la `--find-copies`). */ + GIT_DIFF_FIND_COPIES = (1u << 2), + + /** Consider UNMODIFIED as copy sources? (`--find-copies-harder`). + * + * For this to work correctly, use GIT_DIFF_INCLUDE_UNMODIFIED when + * the initial `git_diff` is being generated. + */ + GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED = (1u << 3), + + /** Mark significant rewrites for split (`--break-rewrites=/M`) */ + GIT_DIFF_FIND_REWRITES = (1u << 4), + /** Actually split large rewrites into delete/add pairs */ + GIT_DIFF_BREAK_REWRITES = (1u << 5), + /** Mark rewrites for split and break into delete/add pairs */ + GIT_DIFF_FIND_AND_BREAK_REWRITES = + (GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES), + + /** Find renames/copies for UNTRACKED items in working directory. + * + * For this to work correctly, use GIT_DIFF_INCLUDE_UNTRACKED when the + * initial `git_diff` is being generated (and obviously the diff must + * be against the working directory for this to make sense). + */ + GIT_DIFF_FIND_FOR_UNTRACKED = (1u << 6), + + /** Turn on all finding features. */ + GIT_DIFF_FIND_ALL = (0x0ff), + + /** Measure similarity ignoring leading whitespace (default) */ + GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE = 0, + /** Measure similarity ignoring all whitespace */ + GIT_DIFF_FIND_IGNORE_WHITESPACE = (1u << 12), + /** Measure similarity including all data */ + GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE = (1u << 13), + /** Measure similarity only by comparing SHAs (fast and cheap) */ + GIT_DIFF_FIND_EXACT_MATCH_ONLY = (1u << 14), + + /** Do not break rewrites unless they contribute to a rename. + * + * Normally, GIT_DIFF_FIND_AND_BREAK_REWRITES will measure the self- + * similarity of modified files and split the ones that have changed a + * lot into a DELETE / ADD pair. Then the sides of that pair will be + * considered candidates for rename and copy detection. + * + * If you add this flag in and the split pair is *not* used for an + * actual rename or copy, then the modified record will be restored to + * a regular MODIFIED record instead of being split. + */ + GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY = (1u << 15), + + /** Remove any UNMODIFIED deltas after find_similar is done. + * + * Using GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED to emulate the + * --find-copies-harder behavior requires building a diff with the + * GIT_DIFF_INCLUDE_UNMODIFIED flag. If you do not want UNMODIFIED + * records in the final result, pass this flag to have them removed. + */ + GIT_DIFF_FIND_REMOVE_UNMODIFIED = (1u << 16), +} git_diff_find_t; + +/** + * Pluggable similarity metric + */ +typedef struct { + int (*file_signature)( + void **out, const git_diff_file *file, + const char *fullpath, void *payload); + int (*buffer_signature)( + void **out, const git_diff_file *file, + const char *buf, size_t buflen, void *payload); + void (*free_signature)(void *sig, void *payload); + int (*similarity)(int *score, void *siga, void *sigb, void *payload); + void *payload; +} git_diff_similarity_metric; + +/** + * Control behavior of rename and copy detection + * + * These options mostly mimic parameters that can be passed to git-diff. + * + * - `rename_threshold` is the same as the -M option with a value + * - `copy_threshold` is the same as the -C option with a value + * - `rename_from_rewrite_threshold` matches the top of the -B option + * - `break_rewrite_threshold` matches the bottom of the -B option + * - `rename_limit` is the maximum number of matches to consider for + * a particular file. This is a little different from the `-l` option + * to regular Git because we will still process up to this many matches + * before abandoning the search. + * + * The `metric` option allows you to plug in a custom similarity metric. + * Set it to NULL for the default internal metric which is based on sampling + * hashes of ranges of data in the file. The default metric is a pretty + * good similarity approximation that should work fairly well for both text + * and binary data, and is pretty fast with fixed memory overhead. + */ +typedef struct { + unsigned int version; + + /** + * Combination of git_diff_find_t values (default GIT_DIFF_FIND_BY_CONFIG). + * NOTE: if you don't explicitly set this, `diff.renames` could be set + * to false, resulting in `git_diff_find_similar` doing nothing. + */ + uint32_t flags; + + /** Similarity to consider a file renamed (default 50) */ + uint16_t rename_threshold; + /** Similarity of modified to be eligible rename source (default 50) */ + uint16_t rename_from_rewrite_threshold; + /** Similarity to consider a file a copy (default 50) */ + uint16_t copy_threshold; + /** Similarity to split modify into delete/add pair (default 60) */ + uint16_t break_rewrite_threshold; + + /** Maximum similarity sources to examine for a file (somewhat like + * git-diff's `-l` option or `diff.renameLimit` config) (default 200) + */ + size_t rename_limit; + + /** Pluggable similarity metric; pass NULL to use internal metric */ + git_diff_similarity_metric *metric; +} git_diff_find_options; + +#define GIT_DIFF_FIND_OPTIONS_VERSION 1 +#define GIT_DIFF_FIND_OPTIONS_INIT {GIT_DIFF_FIND_OPTIONS_VERSION} + +/** + * Initializes a `git_diff_find_options` with default values. Equivalent to + * creating an instance with GIT_DIFF_FIND_OPTIONS_INIT. + * + * @param opts The `git_diff_find_options` struct to initialize + * @param version Version of struct; pass `GIT_DIFF_FIND_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_diff_find_init_options( + git_diff_find_options *opts, + unsigned int version); + +/** @name Diff Generator Functions + * + * These are the functions you would use to create (or destroy) a + * git_diff from various objects in a repository. + */ +/**@{*/ + +/** + * Deallocate a diff. + * + * @param diff The previously created diff; cannot be used after free. + */ +GIT_EXTERN(void) git_diff_free(git_diff *diff); + +/** + * Create a diff with the difference between two tree objects. + * + * This is equivalent to `git diff ` + * + * The first tree will be used for the "old_file" side of the delta and the + * second tree will be used for the "new_file" side of the delta. You can + * pass NULL to indicate an empty tree, although it is an error to pass + * NULL for both the `old_tree` and `new_tree`. + * + * @param diff Output pointer to a git_diff pointer to be allocated. + * @param repo The repository containing the trees. + * @param old_tree A git_tree object to diff from, or NULL for empty tree. + * @param new_tree A git_tree object to diff to, or NULL for empty tree. + * @param opts Structure with options to influence diff or NULL for defaults. + */ +GIT_EXTERN(int) git_diff_tree_to_tree( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + git_tree *new_tree, + const git_diff_options *opts); /**< can be NULL for defaults */ + +/** + * Create a diff between a tree and repository index. + * + * This is equivalent to `git diff --cached ` or if you pass + * the HEAD tree, then like `git diff --cached`. + * + * The tree you pass will be used for the "old_file" side of the delta, and + * the index will be used for the "new_file" side of the delta. + * + * If you pass NULL for the index, then the existing index of the `repo` + * will be used. In this case, the index will be refreshed from disk + * (if it has changed) before the diff is generated. + * + * @param diff Output pointer to a git_diff pointer to be allocated. + * @param repo The repository containing the tree and index. + * @param old_tree A git_tree object to diff from, or NULL for empty tree. + * @param index The index to diff with; repo index used if NULL. + * @param opts Structure with options to influence diff or NULL for defaults. + */ +GIT_EXTERN(int) git_diff_tree_to_index( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + git_index *index, + const git_diff_options *opts); /**< can be NULL for defaults */ + +/** + * Create a diff between the repository index and the workdir directory. + * + * This matches the `git diff` command. See the note below on + * `git_diff_tree_to_workdir` for a discussion of the difference between + * `git diff` and `git diff HEAD` and how to emulate a `git diff ` + * using libgit2. + * + * The index will be used for the "old_file" side of the delta, and the + * working directory will be used for the "new_file" side of the delta. + * + * If you pass NULL for the index, then the existing index of the `repo` + * will be used. In this case, the index will be refreshed from disk + * (if it has changed) before the diff is generated. + * + * @param diff Output pointer to a git_diff pointer to be allocated. + * @param repo The repository. + * @param index The index to diff from; repo index used if NULL. + * @param opts Structure with options to influence diff or NULL for defaults. + */ +GIT_EXTERN(int) git_diff_index_to_workdir( + git_diff **diff, + git_repository *repo, + git_index *index, + const git_diff_options *opts); /**< can be NULL for defaults */ + +/** + * Create a diff between a tree and the working directory. + * + * The tree you provide will be used for the "old_file" side of the delta, + * and the working directory will be used for the "new_file" side. + * + * This is not the same as `git diff ` or `git diff-index + * `. Those commands use information from the index, whereas this + * function strictly returns the differences between the tree and the files + * in the working directory, regardless of the state of the index. Use + * `git_diff_tree_to_workdir_with_index` to emulate those commands. + * + * To see difference between this and `git_diff_tree_to_workdir_with_index`, + * consider the example of a staged file deletion where the file has then + * been put back into the working dir and further modified. The + * tree-to-workdir diff for that file is 'modified', but `git diff` would + * show status 'deleted' since there is a staged delete. + * + * @param diff A pointer to a git_diff pointer that will be allocated. + * @param repo The repository containing the tree. + * @param old_tree A git_tree object to diff from, or NULL for empty tree. + * @param opts Structure with options to influence diff or NULL for defaults. + */ +GIT_EXTERN(int) git_diff_tree_to_workdir( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + const git_diff_options *opts); /**< can be NULL for defaults */ + +/** + * Create a diff between a tree and the working directory using index data + * to account for staged deletes, tracked files, etc. + * + * This emulates `git diff ` by diffing the tree to the index and + * the index to the working directory and blending the results into a + * single diff that includes staged deleted, etc. + * + * @param diff A pointer to a git_diff pointer that will be allocated. + * @param repo The repository containing the tree. + * @param old_tree A git_tree object to diff from, or NULL for empty tree. + * @param opts Structure with options to influence diff or NULL for defaults. + */ +GIT_EXTERN(int) git_diff_tree_to_workdir_with_index( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + const git_diff_options *opts); /**< can be NULL for defaults */ + +/** + * Merge one diff into another. + * + * This merges items from the "from" list into the "onto" list. The + * resulting diff will have all items that appear in either list. + * If an item appears in both lists, then it will be "merged" to appear + * as if the old version was from the "onto" list and the new version + * is from the "from" list (with the exception that if the item has a + * pending DELETE in the middle, then it will show as deleted). + * + * @param onto Diff to merge into. + * @param from Diff to merge. + */ +GIT_EXTERN(int) git_diff_merge( + git_diff *onto, + const git_diff *from); + +/** + * Transform a diff marking file renames, copies, etc. + * + * This modifies a diff in place, replacing old entries that look + * like renames or copies with new entries reflecting those changes. + * This also will, if requested, break modified files into add/remove + * pairs if the amount of change is above a threshold. + * + * @param diff diff to run detection algorithms on + * @param options Control how detection should be run, NULL for defaults + * @return 0 on success, -1 on failure + */ +GIT_EXTERN(int) git_diff_find_similar( + git_diff *diff, + const git_diff_find_options *options); + +/**@}*/ + + +/** @name Diff Processor Functions + * + * These are the functions you apply to a diff to process it + * or read it in some way. + */ +/**@{*/ + +/** + * Query how many diff records are there in a diff. + * + * @param diff A git_diff generated by one of the above functions + * @return Count of number of deltas in the list + */ +GIT_EXTERN(size_t) git_diff_num_deltas(const git_diff *diff); + +/** + * Query how many diff deltas are there in a diff filtered by type. + * + * This works just like `git_diff_entrycount()` with an extra parameter + * that is a `git_delta_t` and returns just the count of how many deltas + * match that particular type. + * + * @param diff A git_diff generated by one of the above functions + * @param type A git_delta_t value to filter the count + * @return Count of number of deltas matching delta_t type + */ +GIT_EXTERN(size_t) git_diff_num_deltas_of_type( + const git_diff *diff, git_delta_t type); + +/** + * Return the diff delta for an entry in the diff list. + * + * The `git_diff_delta` pointer points to internal data and you do not + * have to release it when you are done with it. It will go away when + * the * `git_diff` (or any associated `git_patch`) goes away. + * + * Note that the flags on the delta related to whether it has binary + * content or not may not be set if there are no attributes set for the + * file and there has been no reason to load the file data at this point. + * For now, if you need those flags to be up to date, your only option is + * to either use `git_diff_foreach` or create a `git_patch`. + * + * @param diff Diff list object + * @param idx Index into diff list + * @return Pointer to git_diff_delta (or NULL if `idx` out of range) + */ +GIT_EXTERN(const git_diff_delta *) git_diff_get_delta( + const git_diff *diff, size_t idx); + +/** + * Check if deltas are sorted case sensitively or insensitively. + * + * @param diff diff to check + * @return 0 if case sensitive, 1 if case is ignored + */ +GIT_EXTERN(int) git_diff_is_sorted_icase(const git_diff *diff); + +/** + * Loop over all deltas in a diff issuing callbacks. + * + * This will iterate through all of the files described in a diff. You + * should provide a file callback to learn about each file. + * + * The "hunk" and "line" callbacks are optional, and the text diff of the + * files will only be calculated if they are not NULL. Of course, these + * callbacks will not be invoked for binary files on the diff or for + * files whose only changed is a file mode change. + * + * Returning a non-zero value from any of the callbacks will terminate + * the iteration and return the value to the user. + * + * @param diff A git_diff generated by one of the above functions. + * @param file_cb Callback function to make per file in the diff. + * @param hunk_cb Optional callback to make per hunk of text diff. This + * callback is called to describe a range of lines in the + * diff. It will not be issued for binary files. + * @param line_cb Optional callback to make per line of diff text. This + * same callback will be made for context lines, added, and + * removed lines, and even for a deleted trailing newline. + * @param payload Reference pointer that will be passed to your callbacks. + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_diff_foreach( + git_diff *diff, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb line_cb, + void *payload); + +/** + * Look up the single character abbreviation for a delta status code. + * + * When you run `git diff --name-status` it uses single letter codes in + * the output such as 'A' for added, 'D' for deleted, 'M' for modified, + * etc. This function converts a git_delta_t value into these letters for + * your own purposes. GIT_DELTA_UNTRACKED will return a space (i.e. ' '). + * + * @param status The git_delta_t value to look up + * @return The single character label for that code + */ +GIT_EXTERN(char) git_diff_status_char(git_delta_t status); + +/** + * Possible output formats for diff data + */ +typedef enum { + GIT_DIFF_FORMAT_PATCH = 1u, /**< full git diff */ + GIT_DIFF_FORMAT_PATCH_HEADER = 2u, /**< just the file headers of patch */ + GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */ + GIT_DIFF_FORMAT_NAME_ONLY = 4u, /**< like git diff --name-only */ + GIT_DIFF_FORMAT_NAME_STATUS = 5u, /**< like git diff --name-status */ +} git_diff_format_t; + +/** + * Iterate over a diff generating formatted text output. + * + * Returning a non-zero value from the callbacks will terminate the + * iteration and return the non-zero value to the caller. + * + * @param diff A git_diff generated by one of the above functions. + * @param format A git_diff_format_t value to pick the text format. + * @param print_cb Callback to make per line of diff text. + * @param payload Reference pointer that will be passed to your callback. + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_diff_print( + git_diff *diff, + git_diff_format_t format, + git_diff_line_cb print_cb, + void *payload); + +/**@}*/ + + +/* + * Misc + */ + +/** + * Directly run a diff on two blobs. + * + * Compared to a file, a blob lacks some contextual information. As such, + * the `git_diff_file` given to the callback will have some fake data; i.e. + * `mode` will be 0 and `path` will be NULL. + * + * NULL is allowed for either `old_blob` or `new_blob` and will be treated + * as an empty blob, with the `oid` set to NULL in the `git_diff_file` data. + * Passing NULL for both blobs is a noop; no callbacks will be made at all. + * + * We do run a binary content check on the blob content and if either blob + * looks like binary data, the `git_diff_delta` binary attribute will be set + * to 1 and no call to the hunk_cb nor line_cb will be made (unless you pass + * `GIT_DIFF_FORCE_TEXT` of course). + * + * @param old_blob Blob for old side of diff, or NULL for empty blob + * @param old_as_path Treat old blob as if it had this filename; can be NULL + * @param new_blob Blob for new side of diff, or NULL for empty blob + * @param new_as_path Treat new blob as if it had this filename; can be NULL + * @param options Options for diff, or NULL for default options + * @param file_cb Callback for "file"; made once if there is a diff; can be NULL + * @param hunk_cb Callback for each hunk in diff; can be NULL + * @param line_cb Callback for each line in diff; can be NULL + * @param payload Payload passed to each callback function + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_diff_blobs( + const git_blob *old_blob, + const char *old_as_path, + const git_blob *new_blob, + const char *new_as_path, + const git_diff_options *options, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb line_cb, + void *payload); + +/** + * Directly run a diff between a blob and a buffer. + * + * As with `git_diff_blobs`, comparing a blob and buffer lacks some context, + * so the `git_diff_file` parameters to the callbacks will be faked a la the + * rules for `git_diff_blobs()`. + * + * Passing NULL for `old_blob` will be treated as an empty blob (i.e. the + * `file_cb` will be invoked with GIT_DELTA_ADDED and the diff will be the + * entire content of the buffer added). Passing NULL to the buffer will do + * the reverse, with GIT_DELTA_REMOVED and blob content removed. + * + * @param old_blob Blob for old side of diff, or NULL for empty blob + * @param old_as_path Treat old blob as if it had this filename; can be NULL + * @param buffer Raw data for new side of diff, or NULL for empty + * @param buffer_len Length of raw data for new side of diff + * @param buffer_as_path Treat buffer as if it had this filename; can be NULL + * @param options Options for diff, or NULL for default options + * @param file_cb Callback for "file"; made once if there is a diff; can be NULL + * @param hunk_cb Callback for each hunk in diff; can be NULL + * @param line_cb Callback for each line in diff; can be NULL + * @param payload Payload passed to each callback function + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_diff_blob_to_buffer( + const git_blob *old_blob, + const char *old_as_path, + const char *buffer, + size_t buffer_len, + const char *buffer_as_path, + const git_diff_options *options, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb line_cb, + void *payload); + +/** + * Directly run a diff between two buffers. + * + * Even more than with `git_diff_blobs`, comparing two buffer lacks + * context, so the `git_diff_file` parameters to the callbacks will be + * faked a la the rules for `git_diff_blobs()`. + * + * @param old_buffer Raw data for old side of diff, or NULL for empty + * @param old_len Length of the raw data for old side of the diff + * @param old_as_path Treat old buffer as if it had this filename; can be NULL + * @param new_buffer Raw data for new side of diff, or NULL for empty + * @param new_len Length of raw data for new side of diff + * @param new_as_path Treat buffer as if it had this filename; can be NULL + * @param options Options for diff, or NULL for default options + * @param file_cb Callback for "file"; made once if there is a diff; can be NULL + * @param hunk_cb Callback for each hunk in diff; can be NULL + * @param line_cb Callback for each line in diff; can be NULL + * @param payload Payload passed to each callback function + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_diff_buffers( + const void *old_buffer, + size_t old_len, + const char *old_as_path, + const void *new_buffer, + size_t new_len, + const char *new_as_path, + const git_diff_options *options, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb line_cb, + void *payload); + +/** + * This is an opaque structure which is allocated by `git_diff_get_stats`. + * You are responsible for releasing the object memory when done, using the + * `git_diff_stats_free()` function. + */ +typedef struct git_diff_stats git_diff_stats; + +/** + * Formatting options for diff stats + */ +typedef enum { + /** No stats*/ + GIT_DIFF_STATS_NONE = 0, + + /** Full statistics, equivalent of `--stat` */ + GIT_DIFF_STATS_FULL = (1u << 0), + + /** Short statistics, equivalent of `--shortstat` */ + GIT_DIFF_STATS_SHORT = (1u << 1), + + /** Number statistics, equivalent of `--numstat` */ + GIT_DIFF_STATS_NUMBER = (1u << 2), + + /** Extended header information such as creations, renames and mode changes, equivalent of `--summary` */ + GIT_DIFF_STATS_INCLUDE_SUMMARY = (1u << 3), +} git_diff_stats_format_t; + +/** + * Accumlate diff statistics for all patches. + * + * @param out Structure containg the diff statistics. + * @param diff A git_diff generated by one of the above functions. + * @return 0 on success; non-zero on error + */ +GIT_EXTERN(int) git_diff_get_stats( + git_diff_stats **out, + git_diff *diff); + +/** + * Get the total number of files changed in a diff + * + * @param stats A `git_diff_stats` generated by one of the above functions. + * @return total number of files changed in the diff + */ +GIT_EXTERN(size_t) git_diff_stats_files_changed( + const git_diff_stats *stats); + +/** + * Get the total number of insertions in a diff + * + * @param stats A `git_diff_stats` generated by one of the above functions. + * @return total number of insertions in the diff + */ +GIT_EXTERN(size_t) git_diff_stats_insertions( + const git_diff_stats *stats); + +/** + * Get the total number of deletions in a diff + * + * @param stats A `git_diff_stats` generated by one of the above functions. + * @return total number of deletions in the diff + */ +GIT_EXTERN(size_t) git_diff_stats_deletions( + const git_diff_stats *stats); + +/** + * Print diff statistics to a `git_buf`. + * + * @param out buffer to store the formatted diff statistics in. + * @param stats A `git_diff_stats` generated by one of the above functions. + * @param format Formatting option. + * @param width Target width for output (only affects GIT_DIFF_STATS_FULL) + * @return 0 on success; non-zero on error + */ +GIT_EXTERN(int) git_diff_stats_to_buf( + git_buf *out, + const git_diff_stats *stats, + git_diff_stats_format_t format, + size_t width); + +/** + * Deallocate a `git_diff_stats`. + * + * @param stats The previously created statistics object; + * cannot be used after free. + */ +GIT_EXTERN(void) git_diff_stats_free(git_diff_stats *stats); + +/** + * Formatting options for diff e-mail generation + */ +typedef enum { + /** Normal patch, the default */ + GIT_DIFF_FORMAT_EMAIL_NONE = 0, + + /** Don't insert "[PATCH]" in the subject header*/ + GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0), + +} git_diff_format_email_flags_t; + +/** + * Options for controlling the formatting of the generated e-mail. + */ +typedef struct { + unsigned int version; + + git_diff_format_email_flags_t flags; + + /** This patch number */ + size_t patch_no; + + /** Total number of patches in this series */ + size_t total_patches; + + /** id to use for the commit */ + const git_oid *id; + + /** Summary of the change */ + const char *summary; + + /** Author of the change */ + const git_signature *author; +} git_diff_format_email_options; + +#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION 1 +#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT {GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, 0, 1, 1, NULL, NULL, NULL} + +/** + * Create an e-mail ready patch from a diff. + * + * @param out buffer to store the e-mail patch in + * @param diff containing the commit + * @param opts structure with options to influence content and formatting. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_diff_format_email( + git_buf *out, + git_diff *diff, + const git_diff_format_email_options *opts); + +/** + * Create an e-mail ready patch for a commit. + * + * Does not support creating patches for merge commits (yet). + * + * @param out buffer to store the e-mail patch in + * @param repo containing the commit + * @param commit pointer to up commit + * @param patch_no patch number of the commit + * @param total_patches total number of patches in the patch set + * @param flags determines the formatting of the e-mail + * @param diff_opts structure with options to influence diff or NULL for defaults. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_diff_commit_as_email( + git_buf *out, + git_repository *repo, + git_commit *commit, + size_t patch_no, + size_t total_patches, + git_diff_format_email_flags_t flags, + const git_diff_options *diff_opts); + +/** + * Initializes a `git_diff_format_email_options` with default values. + * + * Equivalent to creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT. + * + * @param opts The `git_diff_format_email_options` struct to initialize + * @param version Version of struct; pass `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_diff_format_email_init_options( + git_diff_format_email_options *opts, + unsigned int version); + +GIT_END_DECL + +/** @} */ + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/errors.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/errors.h new file mode 100644 index 000000000..ef4fabb7d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/errors.h @@ -0,0 +1,160 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_errors_h__ +#define INCLUDE_git_errors_h__ + +#include "common.h" + +/** + * @file git2/errors.h + * @brief Git error handling routines and variables + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** Generic return codes */ +typedef enum { + GIT_OK = 0, /**< No error */ + + GIT_ERROR = -1, /**< Generic error */ + GIT_ENOTFOUND = -3, /**< Requested object could not be found */ + GIT_EEXISTS = -4, /**< Object exists preventing operation */ + GIT_EAMBIGUOUS = -5, /**< More than one object matches */ + GIT_EBUFS = -6, /**< Output buffer too short to hold data */ + + /* GIT_EUSER is a special error that is never generated by libgit2 + * code. You can return it from a callback (e.g to stop an iteration) + * to know that it was generated by the callback and not by libgit2. + */ + GIT_EUSER = -7, + + GIT_EBAREREPO = -8, /**< Operation not allowed on bare repository */ + GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */ + GIT_EUNMERGED = -10, /**< Merge in progress prevented operation */ + GIT_ENONFASTFORWARD = -11, /**< Reference was not fast-forwardable */ + GIT_EINVALIDSPEC = -12, /**< Name/ref spec was not in a valid format */ + GIT_EMERGECONFLICT = -13, /**< Merge conflicts prevented operation */ + GIT_ELOCKED = -14, /**< Lock file prevented operation */ + GIT_EMODIFIED = -15, /**< Reference value does not match expected */ + GIT_EAUTH = -16, /**< Authentication error */ + GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */ + GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */ + GIT_EPEEL = -19, /**< The requested peel operation is not possible */ + + GIT_PASSTHROUGH = -30, /**< Internal only */ + GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */ +} git_error_code; + +/** + * Structure to store extra details of the last error that occurred. + * + * This is kept on a per-thread basis if GIT_THREADS was defined when the + * library was build, otherwise one is kept globally for the library + */ +typedef struct { + char *message; + int klass; +} git_error; + +/** Error classes */ +typedef enum { + GITERR_NONE = 0, + GITERR_NOMEMORY, + GITERR_OS, + GITERR_INVALID, + GITERR_REFERENCE, + GITERR_ZLIB, + GITERR_REPOSITORY, + GITERR_CONFIG, + GITERR_REGEX, + GITERR_ODB, + GITERR_INDEX, + GITERR_OBJECT, + GITERR_NET, + GITERR_TAG, + GITERR_TREE, + GITERR_INDEXER, + GITERR_SSL, + GITERR_SUBMODULE, + GITERR_THREAD, + GITERR_STASH, + GITERR_CHECKOUT, + GITERR_FETCHHEAD, + GITERR_MERGE, + GITERR_SSH, + GITERR_FILTER, + GITERR_REVERT, + GITERR_CALLBACK, + GITERR_CHERRYPICK, + GITERR_DESCRIBE, + GITERR_REBASE, + GITERR_FILESYSTEM +} git_error_t; + +/** + * Return the last `git_error` object that was generated for the + * current thread or NULL if no error has occurred. + * + * @return A git_error object. + */ +GIT_EXTERN(const git_error *) giterr_last(void); + +/** + * Clear the last library error that occurred for this thread. + */ +GIT_EXTERN(void) giterr_clear(void); + +/** + * Get the last error data and clear it. + * + * This copies the last error into the given `git_error` struct + * and returns 0 if the copy was successful, leaving the error + * cleared as if `giterr_clear` had been called. + * + * If there was no existing error in the library, -1 will be returned + * and the contents of `cpy` will be left unmodified. + */ +GIT_EXTERN(int) giterr_detach(git_error *cpy); + +/** + * Set the error message string for this thread. + * + * This function is public so that custom ODB backends and the like can + * relay an error message through libgit2. Most regular users of libgit2 + * will never need to call this function -- actually, calling it in most + * circumstances (for example, calling from within a callback function) + * will just end up having the value overwritten by libgit2 internals. + * + * This error message is stored in thread-local storage and only applies + * to the particular thread that this libgit2 call is made from. + * + * NOTE: Passing the `error_class` as GITERR_OS has a special behavior: we + * attempt to append the system default error message for the last OS error + * that occurred and then clear the last error. The specific implementation + * of looking up and clearing this last OS error will vary by platform. + * + * @param error_class One of the `git_error_t` enum above describing the + * general subsystem that is responsible for the error. + * @param string The formatted error message to keep + */ +GIT_EXTERN(void) giterr_set_str(int error_class, const char *string); + +/** + * Set the error message to a special value for memory allocation failure. + * + * The normal `giterr_set_str()` function attempts to `strdup()` the string + * that is passed in. This is not a good idea when the error in question + * is a memory allocation failure. That circumstance has a special setter + * function that sets the error string to a known and statically allocated + * internal value. + */ +GIT_EXTERN(void) giterr_set_oom(void); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/filter.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/filter.h new file mode 100644 index 000000000..dc59e6341 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/filter.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_filter_h__ +#define INCLUDE_git_filter_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "buffer.h" + +/** + * @file git2/filter.h + * @brief Git filter APIs + * + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Filters are applied in one of two directions: smudging - which is + * exporting a file from the Git object database to the working directory, + * and cleaning - which is importing a file from the working directory to + * the Git object database. These values control which direction of + * change is being applied. + */ +typedef enum { + GIT_FILTER_TO_WORKTREE = 0, + GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE, + GIT_FILTER_TO_ODB = 1, + GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB, +} git_filter_mode_t; + +/** + * Filter option flags. + */ +typedef enum { + GIT_FILTER_DEFAULT = 0u, + GIT_FILTER_ALLOW_UNSAFE = (1u << 0), +} git_filter_flag_t; + +/** + * A filter that can transform file data + * + * This represents a filter that can be used to transform or even replace + * file data. Libgit2 includes one built in filter and it is possible to + * write your own (see git2/sys/filter.h for information on that). + * + * The two builtin filters are: + * + * * "crlf" which uses the complex rules with the "text", "eol", and + * "crlf" file attributes to decide how to convert between LF and CRLF + * line endings + * * "ident" which replaces "$Id$" in a blob with "$Id: $" upon + * checkout and replaced "$Id: $" with "$Id$" on checkin. + */ +typedef struct git_filter git_filter; + +/** + * List of filters to be applied + * + * This represents a list of filters to be applied to a file / blob. You + * can build the list with one call, apply it with another, and dispose it + * with a third. In typical usage, there are not many occasions where a + * git_filter_list is needed directly since the library will generally + * handle conversions for you, but it can be convenient to be able to + * build and apply the list sometimes. + */ +typedef struct git_filter_list git_filter_list; + +/** + * Load the filter list for a given path. + * + * This will return 0 (success) but set the output git_filter_list to NULL + * if no filters are requested for the given file. + * + * @param filters Output newly created git_filter_list (or NULL) + * @param repo Repository object that contains `path` + * @param blob The blob to which the filter will be applied (if known) + * @param path Relative path of the file to be filtered + * @param mode Filtering direction (WT->ODB or ODB->WT) + * @param flags Combination of `git_filter_flag_t` flags + * @return 0 on success (which could still return NULL if no filters are + * needed for the requested file), <0 on error + */ +GIT_EXTERN(int) git_filter_list_load( + git_filter_list **filters, + git_repository *repo, + git_blob *blob, /* can be NULL */ + const char *path, + git_filter_mode_t mode, + uint32_t flags); + +/** + * Apply filter list to a data buffer. + * + * See `git2/buffer.h` for background on `git_buf` objects. + * + * If the `in` buffer holds data allocated by libgit2 (i.e. `in->asize` is + * not zero), then it will be overwritten when applying the filters. If + * not, then it will be left untouched. + * + * If there are no filters to apply (or `filters` is NULL), then the `out` + * buffer will reference the `in` buffer data (with `asize` set to zero) + * instead of allocating data. This keeps allocations to a minimum, but + * it means you have to be careful about freeing the `in` data since `out` + * may be pointing to it! + * + * @param out Buffer to store the result of the filtering + * @param filters A loaded git_filter_list (or NULL) + * @param in Buffer containing the data to filter + * @return 0 on success, an error code otherwise + */ +GIT_EXTERN(int) git_filter_list_apply_to_data( + git_buf *out, + git_filter_list *filters, + git_buf *in); + +/** + * Apply filter list to the contents of a file on disk + */ +GIT_EXTERN(int) git_filter_list_apply_to_file( + git_buf *out, + git_filter_list *filters, + git_repository *repo, + const char *path); + +/** + * Apply filter list to the contents of a blob + */ +GIT_EXTERN(int) git_filter_list_apply_to_blob( + git_buf *out, + git_filter_list *filters, + git_blob *blob); + +GIT_EXTERN(int) git_filter_list_stream_data( + git_filter_list *filters, + git_buf *data, + git_writestream *target); + +GIT_EXTERN(int) git_filter_list_stream_file( + git_filter_list *filters, + git_repository *repo, + const char *path, + git_writestream *target); + +GIT_EXTERN(int) git_filter_list_stream_blob( + git_filter_list *filters, + git_blob *blob, + git_writestream *target); + +/** + * Free a git_filter_list + * + * @param filters A git_filter_list created by `git_filter_list_load` + */ +GIT_EXTERN(void) git_filter_list_free(git_filter_list *filters); + + +GIT_END_DECL + +/** @} */ + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/global.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/global.h new file mode 100644 index 000000000..ce5bdf444 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/global.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_global_h__ +#define INCLUDE_git_global_h__ + +#include "common.h" + +GIT_BEGIN_DECL + +/** + * Init the global state + * + * This function must the called before any other libgit2 function in + * order to set up global state and threading. + * + * This function may be called multiple times - it will return the number + * of times the initialization has been called (including this one) that have + * not subsequently been shutdown. + * + * @return the number of initializations of the library, or an error code. + */ +GIT_EXTERN(int) git_libgit2_init(void); + +/** + * Shutdown the global state + * + * Clean up the global state and threading context after calling it as + * many times as `git_libgit2_init()` was called - it will return the + * number of remainining initializations that have not been shutdown + * (after this one). + * + * @return the number of remaining initializations of the library, or an + * error code. + */ +GIT_EXTERN(int) git_libgit2_shutdown(void); + +/** @} */ +GIT_END_DECL +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/graph.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/graph.h new file mode 100644 index 000000000..c997d8ca9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/graph.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_graph_h__ +#define INCLUDE_git_graph_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" + +/** + * @file git2/graph.h + * @brief Git graph traversal routines + * @defgroup git_revwalk Git graph traversal routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Count the number of unique commits between two commit objects + * + * There is no need for branches containing the commits to have any + * upstream relationship, but it helps to think of one as a branch and + * the other as its upstream, the `ahead` and `behind` values will be + * what git would report for the branches. + * + * @param ahead number of unique from commits in `upstream` + * @param behind number of unique from commits in `local` + * @param repo the repository where the commits exist + * @param local the commit for local + * @param upstream the commit for upstream + */ +GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream); + + +/** + * Determine if a commit is the descendant of another commit. + * + * @param commit a previously loaded commit. + * @param ancestor a potential ancestor commit. + * @return 1 if the given commit is a descendant of the potential ancestor, + * 0 if not, error code otherwise. + */ +GIT_EXTERN(int) git_graph_descendant_of( + git_repository *repo, + const git_oid *commit, + const git_oid *ancestor); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/ignore.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/ignore.h new file mode 100644 index 000000000..d0c1877a8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/ignore.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_ignore_h__ +#define INCLUDE_git_ignore_h__ + +#include "common.h" +#include "types.h" + +GIT_BEGIN_DECL + +/** + * Add ignore rules for a repository. + * + * Excludesfile rules (i.e. .gitignore rules) are generally read from + * .gitignore files in the repository tree or from a shared system file + * only if a "core.excludesfile" config value is set. The library also + * keeps a set of per-repository internal ignores that can be configured + * in-memory and will not persist. This function allows you to add to + * that internal rules list. + * + * Example usage: + * + * error = git_ignore_add_rule(myrepo, "*.c\ndir/\nFile with space\n"); + * + * This would add three rules to the ignores. + * + * @param repo The repository to add ignore rules to. + * @param rules Text of rules, a la the contents of a .gitignore file. + * It is okay to have multiple rules in the text; if so, + * each rule should be terminated with a newline. + * @return 0 on success + */ +GIT_EXTERN(int) git_ignore_add_rule( + git_repository *repo, + const char *rules); + +/** + * Clear ignore rules that were explicitly added. + * + * Resets to the default internal ignore rules. This will not turn off + * rules in .gitignore files that actually exist in the filesystem. + * + * The default internal ignores ignore ".", ".." and ".git" entries. + * + * @param repo The repository to remove ignore rules from. + * @return 0 on success + */ +GIT_EXTERN(int) git_ignore_clear_internal_rules( + git_repository *repo); + +/** + * Test if the ignore rules apply to a given path. + * + * This function checks the ignore rules to see if they would apply to the + * given file. This indicates if the file would be ignored regardless of + * whether the file is already in the index or committed to the repository. + * + * One way to think of this is if you were to do "git add ." on the + * directory containing the file, would it be added or not? + * + * @param ignored boolean returning 0 if the file is not ignored, 1 if it is + * @param repo a repository object + * @param path the file to check ignores for, relative to the repo's workdir. + * @return 0 if ignore rules could be processed for the file (regardless + * of whether it exists or not), or an error < 0 if they could not. + */ +GIT_EXTERN(int) git_ignore_path_is_ignored( + int *ignored, + git_repository *repo, + const char *path); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/index.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/index.h new file mode 100644 index 000000000..92636adeb --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/index.h @@ -0,0 +1,734 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_index_h__ +#define INCLUDE_git_index_h__ + +#include "common.h" +#include "indexer.h" +#include "types.h" +#include "oid.h" +#include "strarray.h" + +/** + * @file git2/index.h + * @brief Git index parsing and manipulation routines + * @defgroup git_index Git index parsing and manipulation routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** Time structure used in a git index entry */ +typedef struct { + git_time_t seconds; + /* nsec should not be stored as time_t compatible */ + unsigned int nanoseconds; +} git_index_time; + +/** + * In-memory representation of a file entry in the index. + * + * This is a public structure that represents a file entry in the index. + * The meaning of the fields corresponds to core Git's documentation (in + * "Documentation/technical/index-format.txt"). + * + * The `flags` field consists of a number of bit fields which can be + * accessed via the first set of `GIT_IDXENTRY_...` bitmasks below. These + * flags are all read from and persisted to disk. + * + * The `flags_extended` field also has a number of bit fields which can be + * accessed via the later `GIT_IDXENTRY_...` bitmasks below. Some of + * these flags are read from and written to disk, but some are set aside + * for in-memory only reference. + */ +typedef struct git_index_entry { + git_index_time ctime; + git_index_time mtime; + + unsigned int dev; + unsigned int ino; + unsigned int mode; + unsigned int uid; + unsigned int gid; + git_off_t file_size; + + git_oid id; + + unsigned short flags; + unsigned short flags_extended; + + const char *path; +} git_index_entry; + +/** + * Bitmasks for on-disk fields of `git_index_entry`'s `flags` + * + * These bitmasks match the four fields in the `git_index_entry` `flags` + * value both in memory and on disk. You can use them to interpret the + * data in the `flags`. + */ +#define GIT_IDXENTRY_NAMEMASK (0x0fff) +#define GIT_IDXENTRY_STAGEMASK (0x3000) +#define GIT_IDXENTRY_STAGESHIFT 12 + +/** + * Flags for index entries + */ +typedef enum { + GIT_IDXENTRY_EXTENDED = (0x4000), + GIT_IDXENTRY_VALID = (0x8000), +} git_indxentry_flag_t; + +#define GIT_IDXENTRY_STAGE(E) \ + (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT) + +#define GIT_IDXENTRY_STAGE_SET(E,S) do { \ + (E)->flags = ((E)->flags & ~GIT_IDXENTRY_STAGEMASK) | \ + (((S) & 0x03) << GIT_IDXENTRY_STAGESHIFT); } while (0) + +/** + * Bitmasks for on-disk fields of `git_index_entry`'s `flags_extended` + * + * In memory, the `flags_extended` fields are divided into two parts: the + * fields that are read from and written to disk, and other fields that + * in-memory only and used by libgit2. Only the flags in + * `GIT_IDXENTRY_EXTENDED_FLAGS` will get saved on-disk. + * + * Thee first three bitmasks match the three fields in the + * `git_index_entry` `flags_extended` value that belong on disk. You + * can use them to interpret the data in the `flags_extended`. + * + * The rest of the bitmasks match the other fields in the `git_index_entry` + * `flags_extended` value that are only used in-memory by libgit2. + * You can use them to interpret the data in the `flags_extended`. + * + */ +typedef enum { + + GIT_IDXENTRY_INTENT_TO_ADD = (1 << 13), + GIT_IDXENTRY_SKIP_WORKTREE = (1 << 14), + /** Reserved for future extension */ + GIT_IDXENTRY_EXTENDED2 = (1 << 15), + + GIT_IDXENTRY_EXTENDED_FLAGS = (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE), + GIT_IDXENTRY_UPDATE = (1 << 0), + GIT_IDXENTRY_REMOVE = (1 << 1), + GIT_IDXENTRY_UPTODATE = (1 << 2), + GIT_IDXENTRY_ADDED = (1 << 3), + + GIT_IDXENTRY_HASHED = (1 << 4), + GIT_IDXENTRY_UNHASHED = (1 << 5), + GIT_IDXENTRY_WT_REMOVE = (1 << 6), /**< remove in work directory */ + GIT_IDXENTRY_CONFLICTED = (1 << 7), + + GIT_IDXENTRY_UNPACKED = (1 << 8), + GIT_IDXENTRY_NEW_SKIP_WORKTREE = (1 << 9), +} git_idxentry_extended_flag_t; + +/** Capabilities of system that affect index actions. */ +typedef enum { + GIT_INDEXCAP_IGNORE_CASE = 1, + GIT_INDEXCAP_NO_FILEMODE = 2, + GIT_INDEXCAP_NO_SYMLINKS = 4, + GIT_INDEXCAP_FROM_OWNER = -1, +} git_indexcap_t; + +/** Callback for APIs that add/remove/update files matching pathspec */ +typedef int (*git_index_matched_path_cb)( + const char *path, const char *matched_pathspec, void *payload); + +/** Flags for APIs that add files matching pathspec */ +typedef enum { + GIT_INDEX_ADD_DEFAULT = 0, + GIT_INDEX_ADD_FORCE = (1u << 0), + GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = (1u << 1), + GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2), +} git_index_add_option_t; + +/** + * Match any index stage. + * + * Some index APIs take a stage to match; pass this value to match + * any entry matching the path regardless of stage. + */ +#define GIT_INDEX_STAGE_ANY -1 + +/** @name Index File Functions + * + * These functions work on the index file itself. + */ +/**@{*/ + +/** + * Create a new bare Git index object as a memory representation + * of the Git index file in 'index_path', without a repository + * to back it. + * + * Since there is no ODB or working directory behind this index, + * any Index methods which rely on these (e.g. index_add_bypath) + * will fail with the GIT_ERROR error code. + * + * If you need to access the index of an actual repository, + * use the `git_repository_index` wrapper. + * + * The index must be freed once it's no longer in use. + * + * @param out the pointer for the new index + * @param index_path the path to the index file in disk + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_open(git_index **out, const char *index_path); + +/** + * Create an in-memory index object. + * + * This index object cannot be read/written to the filesystem, + * but may be used to perform in-memory index operations. + * + * The index must be freed once it's no longer in use. + * + * @param out the pointer for the new index + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_new(git_index **out); + +/** + * Free an existing index object. + * + * @param index an existing index object + */ +GIT_EXTERN(void) git_index_free(git_index *index); + +/** + * Get the repository this index relates to + * + * @param index The index + * @return A pointer to the repository + */ +GIT_EXTERN(git_repository *) git_index_owner(const git_index *index); + +/** + * Read index capabilities flags. + * + * @param index An existing index object + * @return A combination of GIT_INDEXCAP values + */ +GIT_EXTERN(int) git_index_caps(const git_index *index); + +/** + * Set index capabilities flags. + * + * If you pass `GIT_INDEXCAP_FROM_OWNER` for the caps, then the + * capabilities will be read from the config of the owner object, + * looking at `core.ignorecase`, `core.filemode`, `core.symlinks`. + * + * @param index An existing index object + * @param caps A combination of GIT_INDEXCAP values + * @return 0 on success, -1 on failure + */ +GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps); + +/** + * Update the contents of an existing index object in memory by reading + * from the hard disk. + * + * If `force` is true, this performs a "hard" read that discards in-memory + * changes and always reloads the on-disk index data. If there is no + * on-disk version, the index will be cleared. + * + * If `force` is false, this does a "soft" read that reloads the index + * data from disk only if it has changed since the last time it was + * loaded. Purely in-memory index data will be untouched. Be aware: if + * there are changes on disk, unwritten in-memory changes are discarded. + * + * @param index an existing index object + * @param force if true, always reload, vs. only read if file has changed + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_read(git_index *index, int force); + +/** + * Write an existing index object from memory back to disk + * using an atomic file lock. + * + * @param index an existing index object + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_write(git_index *index); + +/** + * Get the full path to the index file on disk. + * + * @param index an existing index object + * @return path to index file or NULL for in-memory index + */ +GIT_EXTERN(const char *) git_index_path(const git_index *index); + +/** + * Read a tree into the index file with stats + * + * The current index contents will be replaced by the specified tree. + * + * @param index an existing index object + * @param tree tree to read + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_read_tree(git_index *index, const git_tree *tree); + +/** + * Write the index as a tree + * + * This method will scan the index and write a representation + * of its current state back to disk; it recursively creates + * tree objects for each of the subtrees stored in the index, + * but only returns the OID of the root tree. This is the OID + * that can be used e.g. to create a commit. + * + * The index instance cannot be bare, and needs to be associated + * to an existing repository. + * + * The index must not contain any file in conflict. + * + * @param out Pointer where to store the OID of the written tree + * @param index Index to write + * @return 0 on success, GIT_EUNMERGED when the index is not clean + * or an error code + */ +GIT_EXTERN(int) git_index_write_tree(git_oid *out, git_index *index); + +/** + * Write the index as a tree to the given repository + * + * This method will do the same as `git_index_write_tree`, but + * letting the user choose the repository where the tree will + * be written. + * + * The index must not contain any file in conflict. + * + * @param out Pointer where to store OID of the the written tree + * @param index Index to write + * @param repo Repository where to write the tree + * @return 0 on success, GIT_EUNMERGED when the index is not clean + * or an error code + */ +GIT_EXTERN(int) git_index_write_tree_to(git_oid *out, git_index *index, git_repository *repo); + +/**@}*/ + +/** @name Raw Index Entry Functions + * + * These functions work on index entries, and allow for raw manipulation + * of the entries. + */ +/**@{*/ + +/* Index entry manipulation */ + +/** + * Get the count of entries currently in the index + * + * @param index an existing index object + * @return integer of count of current entries + */ +GIT_EXTERN(size_t) git_index_entrycount(const git_index *index); + +/** + * Clear the contents (all the entries) of an index object. + * + * This clears the index object in memory; changes must be explicitly + * written to disk for them to take effect persistently. + * + * @param index an existing index object + * @return 0 on success, error code < 0 on failure + */ +GIT_EXTERN(int) git_index_clear(git_index *index); + +/** + * Get a pointer to one of the entries in the index + * + * The entry is not modifiable and should not be freed. Because the + * `git_index_entry` struct is a publicly defined struct, you should + * be able to make your own permanent copy of the data if necessary. + * + * @param index an existing index object + * @param n the position of the entry + * @return a pointer to the entry; NULL if out of bounds + */ +GIT_EXTERN(const git_index_entry *) git_index_get_byindex( + git_index *index, size_t n); + +/** + * Get a pointer to one of the entries in the index + * + * The entry is not modifiable and should not be freed. Because the + * `git_index_entry` struct is a publicly defined struct, you should + * be able to make your own permanent copy of the data if necessary. + * + * @param index an existing index object + * @param path path to search + * @param stage stage to search + * @return a pointer to the entry; NULL if it was not found + */ +GIT_EXTERN(const git_index_entry *) git_index_get_bypath( + git_index *index, const char *path, int stage); + +/** + * Remove an entry from the index + * + * @param index an existing index object + * @param path path to search + * @param stage stage to search + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_remove(git_index *index, const char *path, int stage); + +/** + * Remove all entries from the index under a given directory + * + * @param index an existing index object + * @param dir container directory path + * @param stage stage to search + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_remove_directory( + git_index *index, const char *dir, int stage); + +/** + * Add or update an index entry from an in-memory struct + * + * If a previous index entry exists that has the same path and stage + * as the given 'source_entry', it will be replaced. Otherwise, the + * 'source_entry' will be added. + * + * A full copy (including the 'path' string) of the given + * 'source_entry' will be inserted on the index. + * + * @param index an existing index object + * @param source_entry new entry object + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_entry); + +/** + * Return the stage number from a git index entry + * + * This entry is calculated from the entry's flag attribute like this: + * + * (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT + * + * @param entry The entry + * @return the stage number + */ +GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry); + +/**@}*/ + +/** @name Workdir Index Entry Functions + * + * These functions work on index entries specifically in the working + * directory (ie, stage 0). + */ +/**@{*/ + +/** + * Add or update an index entry from a file on disk + * + * The file `path` must be relative to the repository's + * working folder and must be readable. + * + * This method will fail in bare index instances. + * + * This forces the file to be added to the index, not looking + * at gitignore rules. Those rules can be evaluated through + * the git_status APIs (in status.h) before calling this. + * + * If this file currently is the result of a merge conflict, this + * file will no longer be marked as conflicting. The data about + * the conflict will be moved to the "resolve undo" (REUC) section. + * + * @param index an existing index object + * @param path filename to add + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path); + +/** + * Add or update an index entry from a buffer in memory + * + * This method will create a blob in the repository that owns the + * index and then add the index entry to the index. The `path` of the + * entry represents the position of the blob relative to the + * repository's root folder. + * + * If a previous index entry exists that has the same path as the + * given 'entry', it will be replaced. Otherwise, the 'entry' will be + * added. The `id` and the `file_size` of the 'entry' are updated with the + * real value of the blob. + * + * This forces the file to be added to the index, not looking + * at gitignore rules. Those rules can be evaluated through + * the git_status APIs (in status.h) before calling this. + * + * If this file currently is the result of a merge conflict, this + * file will no longer be marked as conflicting. The data about + * the conflict will be moved to the "resolve undo" (REUC) section. + * + * @param index an existing index object + * @param entry filename to add + * @param buffer data to be written into the blob + * @param len length of the data + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_add_frombuffer( + git_index *index, + const git_index_entry *entry, + const void *buffer, size_t len); + +/** + * Remove an index entry corresponding to a file on disk + * + * The file `path` must be relative to the repository's + * working folder. It may exist. + * + * If this file currently is the result of a merge conflict, this + * file will no longer be marked as conflicting. The data about + * the conflict will be moved to the "resolve undo" (REUC) section. + * + * @param index an existing index object + * @param path filename to remove + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_remove_bypath(git_index *index, const char *path); + +/** + * Add or update index entries matching files in the working directory. + * + * This method will fail in bare index instances. + * + * The `pathspec` is a list of file names or shell glob patterns that will + * matched against files in the repository's working directory. Each file + * that matches will be added to the index (either updating an existing + * entry or adding a new entry). You can disable glob expansion and force + * exact matching with the `GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH` flag. + * + * Files that are ignored will be skipped (unlike `git_index_add_bypath`). + * If a file is already tracked in the index, then it *will* be updated + * even if it is ignored. Pass the `GIT_INDEX_ADD_FORCE` flag to + * skip the checking of ignore rules. + * + * To emulate `git add -A` and generate an error if the pathspec contains + * the exact path of an ignored file (when not using FORCE), add the + * `GIT_INDEX_ADD_CHECK_PATHSPEC` flag. This checks that each entry + * in the `pathspec` that is an exact match to a filename on disk is + * either not ignored or already in the index. If this check fails, the + * function will return GIT_EINVALIDSPEC. + * + * To emulate `git add -A` with the "dry-run" option, just use a callback + * function that always returns a positive value. See below for details. + * + * If any files are currently the result of a merge conflict, those files + * will no longer be marked as conflicting. The data about the conflicts + * will be moved to the "resolve undo" (REUC) section. + * + * If you provide a callback function, it will be invoked on each matching + * item in the working directory immediately *before* it is added to / + * updated in the index. Returning zero will add the item to the index, + * greater than zero will skip the item, and less than zero will abort the + * scan and return that value to the caller. + * + * @param index an existing index object + * @param pathspec array of path patterns + * @param flags combination of git_index_add_option_t flags + * @param callback notification callback for each added/updated path (also + * gets index of matching pathspec entry); can be NULL; + * return 0 to add, >0 to skip, <0 to abort scan. + * @param payload payload passed through to callback function + * @return 0 on success, negative callback return value, or error code + */ +GIT_EXTERN(int) git_index_add_all( + git_index *index, + const git_strarray *pathspec, + unsigned int flags, + git_index_matched_path_cb callback, + void *payload); + +/** + * Remove all matching index entries. + * + * If you provide a callback function, it will be invoked on each matching + * item in the index immediately *before* it is removed. Return 0 to + * remove the item, > 0 to skip the item, and < 0 to abort the scan. + * + * @param index An existing index object + * @param pathspec array of path patterns + * @param callback notification callback for each removed path (also + * gets index of matching pathspec entry); can be NULL; + * return 0 to add, >0 to skip, <0 to abort scan. + * @param payload payload passed through to callback function + * @return 0 on success, negative callback return value, or error code + */ +GIT_EXTERN(int) git_index_remove_all( + git_index *index, + const git_strarray *pathspec, + git_index_matched_path_cb callback, + void *payload); + +/** + * Update all index entries to match the working directory + * + * This method will fail in bare index instances. + * + * This scans the existing index entries and synchronizes them with the + * working directory, deleting them if the corresponding working directory + * file no longer exists otherwise updating the information (including + * adding the latest version of file to the ODB if needed). + * + * If you provide a callback function, it will be invoked on each matching + * item in the index immediately *before* it is updated (either refreshed + * or removed depending on working directory state). Return 0 to proceed + * with updating the item, > 0 to skip the item, and < 0 to abort the scan. + * + * @param index An existing index object + * @param pathspec array of path patterns + * @param callback notification callback for each updated path (also + * gets index of matching pathspec entry); can be NULL; + * return 0 to add, >0 to skip, <0 to abort scan. + * @param payload payload passed through to callback function + * @return 0 on success, negative callback return value, or error code + */ +GIT_EXTERN(int) git_index_update_all( + git_index *index, + const git_strarray *pathspec, + git_index_matched_path_cb callback, + void *payload); + +/** + * Find the first position of any entries which point to given + * path in the Git index. + * + * @param at_pos the address to which the position of the index entry is written (optional) + * @param index an existing index object + * @param path path to search + * @return a zero-based position in the index if found; GIT_ENOTFOUND otherwise + */ +GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *path); + +/**@}*/ + +/** @name Conflict Index Entry Functions + * + * These functions work on conflict index entries specifically (ie, stages 1-3) + */ +/**@{*/ + +/** + * Add or update index entries to represent a conflict + * + * The entries are the entries from the tree included in the merge. Any + * entry may be null to indicate that that file was not present in the + * trees during the merge. For example, ancestor_entry may be NULL to + * indicate that a file was added in both branches and must be resolved. + * + * @param index an existing index object + * @param ancestor_entry the entry data for the ancestor of the conflict + * @param our_entry the entry data for our side of the merge conflict + * @param their_entry the entry data for their side of the merge conflict + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_conflict_add( + git_index *index, + const git_index_entry *ancestor_entry, + const git_index_entry *our_entry, + const git_index_entry *their_entry); + +/** + * Get the index entries that represent a conflict of a single file. + * + * The entries are not modifiable and should not be freed. Because the + * `git_index_entry` struct is a publicly defined struct, you should + * be able to make your own permanent copy of the data if necessary. + * + * @param ancestor_out Pointer to store the ancestor entry + * @param our_out Pointer to store the our entry + * @param their_out Pointer to store the their entry + * @param index an existing index object + * @param path path to search + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_conflict_get( + const git_index_entry **ancestor_out, + const git_index_entry **our_out, + const git_index_entry **their_out, + git_index *index, + const char *path); + +/** + * Removes the index entries that represent a conflict of a single file. + * + * @param index an existing index object + * @param path path to remove conflicts for + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_conflict_remove(git_index *index, const char *path); + +/** + * Remove all conflicts in the index (entries with a stage greater than 0). + * + * @param index an existing index object + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_conflict_cleanup(git_index *index); + +/** + * Determine if the index contains entries representing file conflicts. + * + * @return 1 if at least one conflict is found, 0 otherwise. + */ +GIT_EXTERN(int) git_index_has_conflicts(const git_index *index); + +/** + * Create an iterator for the conflicts in the index. + * + * The index must not be modified while iterating; the results are undefined. + * + * @param iterator_out The newly created conflict iterator + * @param index The index to scan + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_conflict_iterator_new( + git_index_conflict_iterator **iterator_out, + git_index *index); + +/** + * Returns the current conflict (ancestor, ours and theirs entry) and + * advance the iterator internally to the next value. + * + * @param ancestor_out Pointer to store the ancestor side of the conflict + * @param our_out Pointer to store our side of the conflict + * @param their_out Pointer to store their side of the conflict + * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code + * (negative value) + */ +GIT_EXTERN(int) git_index_conflict_next( + const git_index_entry **ancestor_out, + const git_index_entry **our_out, + const git_index_entry **their_out, + git_index_conflict_iterator *iterator); + +/** + * Frees a `git_index_conflict_iterator`. + * + * @param iterator pointer to the iterator + */ +GIT_EXTERN(void) git_index_conflict_iterator_free( + git_index_conflict_iterator *iterator); + +/**@}*/ + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/indexer.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/indexer.h new file mode 100644 index 000000000..d2d315e47 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/indexer.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef _INCLUDE_git_indexer_h__ +#define _INCLUDE_git_indexer_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" + +GIT_BEGIN_DECL + +typedef struct git_indexer git_indexer; + +/** + * Create a new indexer instance + * + * @param out where to store the indexer instance + * @param path to the directory where the packfile should be stored + * @param mode permissions to use creating packfile or 0 for defaults + * @param odb object database from which to read base objects when + * fixing thin packs. Pass NULL if no thin pack is expected (an error + * will be returned if there are bases missing) + * @param progress_cb function to call with progress information + * @param progress_cb_payload payload for the progress callback + */ +GIT_EXTERN(int) git_indexer_new( + git_indexer **out, + const char *path, + unsigned int mode, + git_odb *odb, + git_transfer_progress_cb progress_cb, + void *progress_cb_payload); + +/** + * Add data to the indexer + * + * @param idx the indexer + * @param data the data to add + * @param size the size of the data in bytes + * @param stats stat storage + */ +GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats); + +/** + * Finalize the pack and index + * + * Resolve any pending deltas and write out the index file + * + * @param idx the indexer + */ +GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_transfer_progress *stats); + +/** + * Get the packfile's hash + * + * A packfile's name is derived from the sorted hashing of all object + * names. This is only correct after the index has been finalized. + * + * @param idx the indexer instance + */ +GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx); + +/** + * Free the indexer and its resources + * + * @param idx the indexer to free + */ +GIT_EXTERN(void) git_indexer_free(git_indexer *idx); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/inttypes.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/inttypes.h new file mode 100644 index 000000000..17364c7f8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/inttypes.h @@ -0,0 +1,309 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#if _MSC_VER >= 1600 +#include +#else +#include "stdint.h" +#endif + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 + +// The fprintf macros for signed integers are: +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +#endif // __STDC_FORMAT_MACROS ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/merge.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/merge.h new file mode 100644 index 000000000..d3360a7e0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/merge.h @@ -0,0 +1,550 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_merge_h__ +#define INCLUDE_git_merge_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "oidarray.h" +#include "checkout.h" +#include "index.h" +#include "annotated_commit.h" + +/** + * @file git2/merge.h + * @brief Git merge routines + * @defgroup git_merge Git merge routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * The file inputs to `git_merge_file`. Callers should populate the + * `git_merge_file_input` structure with descriptions of the files in + * each side of the conflict for use in producing the merge file. + */ +typedef struct { + unsigned int version; + + /** Pointer to the contents of the file. */ + const char *ptr; + + /** Size of the contents pointed to in `ptr`. */ + size_t size; + + /** File name of the conflicted file, or `NULL` to not merge the path. */ + const char *path; + + /** File mode of the conflicted file, or `0` to not merge the mode. */ + unsigned int mode; +} git_merge_file_input; + +#define GIT_MERGE_FILE_INPUT_VERSION 1 +#define GIT_MERGE_FILE_INPUT_INIT {GIT_MERGE_FILE_INPUT_VERSION} + +/** + * Initializes a `git_merge_file_input` with default values. Equivalent to + * creating an instance with GIT_MERGE_FILE_INPUT_INIT. + * + * @param opts the `git_merge_file_input` instance to initialize. + * @param version the version of the struct; you should pass + * `GIT_MERGE_FILE_INPUT_VERSION` here. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_merge_file_init_input( + git_merge_file_input *opts, + unsigned int version); + +/** + * Flags for `git_merge_tree` options. A combination of these flags can be + * passed in via the `tree_flags` value in the `git_merge_options`. + */ +typedef enum { + /** + * Detect renames that occur between the common ancestor and the "ours" + * side or the common ancestor and the "theirs" side. This will enable + * the ability to merge between a modified and renamed file. + */ + GIT_MERGE_TREE_FIND_RENAMES = (1 << 0), +} git_merge_tree_flag_t; + +/** + * Merge file favor options for `git_merge_options` instruct the file-level + * merging functionality how to deal with conflicting regions of the files. + */ +typedef enum { + /** + * When a region of a file is changed in both branches, a conflict + * will be recorded in the index so that `git_checkout` can produce + * a merge file with conflict markers in the working directory. + * This is the default. + */ + GIT_MERGE_FILE_FAVOR_NORMAL = 0, + + /** + * When a region of a file is changed in both branches, the file + * created in the index will contain the "ours" side of any conflicting + * region. The index will not record a conflict. + */ + GIT_MERGE_FILE_FAVOR_OURS = 1, + + /** + * When a region of a file is changed in both branches, the file + * created in the index will contain the "theirs" side of any conflicting + * region. The index will not record a conflict. + */ + GIT_MERGE_FILE_FAVOR_THEIRS = 2, + + /** + * When a region of a file is changed in both branches, the file + * created in the index will contain each unique line from each side, + * which has the result of combining both files. The index will not + * record a conflict. + */ + GIT_MERGE_FILE_FAVOR_UNION = 3, +} git_merge_file_favor_t; + +/** + * File merging flags + */ +typedef enum { + /** Defaults */ + GIT_MERGE_FILE_DEFAULT = 0, + + /** Create standard conflicted merge files */ + GIT_MERGE_FILE_STYLE_MERGE = (1 << 0), + + /** Create diff3-style files */ + GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1), + + /** Condense non-alphanumeric regions for simplified diff file */ + GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2), + + /** Ignore all whitespace */ + GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3), + + /** Ignore changes in amount of whitespace */ + GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4), + + /** Ignore whitespace at end of line */ + GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5), + + /** Use the "patience diff" algorithm */ + GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6), + + /** Take extra time to find minimal diff */ + GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), +} git_merge_file_flags_t; + +/** + * Options for merging a file + */ +typedef struct { + unsigned int version; + + /** + * Label for the ancestor file side of the conflict which will be prepended + * to labels in diff3-format merge files. + */ + const char *ancestor_label; + + /** + * Label for our file side of the conflict which will be prepended + * to labels in merge files. + */ + const char *our_label; + + /** + * Label for their file side of the conflict which will be prepended + * to labels in merge files. + */ + const char *their_label; + + /** The file to favor in region conflicts. */ + git_merge_file_favor_t favor; + + /** Merge file flags. */ + unsigned int flags; +} git_merge_file_options; + +#define GIT_MERGE_FILE_OPTIONS_VERSION 1 +#define GIT_MERGE_FILE_OPTIONS_INIT {GIT_MERGE_FILE_OPTIONS_VERSION} + +/** + * Initializes a `git_merge_file_options` with default values. Equivalent to + * creating an instance with GIT_MERGE_FILE_OPTIONS_INIT. + * + * @param opts the `git_merge_file_options` instance to initialize. + * @param version the version of the struct; you should pass + * `GIT_MERGE_FILE_OPTIONS_VERSION` here. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_merge_file_init_options( + git_merge_file_options *opts, + unsigned int version); + +/** + * Information about file-level merging + */ +typedef struct { + /** + * True if the output was automerged, false if the output contains + * conflict markers. + */ + unsigned int automergeable; + + /** + * The path that the resultant merge file should use, or NULL if a + * filename conflict would occur. + */ + const char *path; + + /** The mode that the resultant merge file should use. */ + unsigned int mode; + + /** The contents of the merge. */ + const char *ptr; + + /** The length of the merge contents. */ + size_t len; +} git_merge_file_result; + +/** + * Merging options + */ +typedef struct { + unsigned int version; + git_merge_tree_flag_t tree_flags; + + /** + * Similarity to consider a file renamed (default 50). If + * `GIT_MERGE_TREE_FIND_RENAMES` is enabled, added files will be compared + * with deleted files to determine their similarity. Files that are + * more similar than the rename threshold (percentage-wise) will be + * treated as a rename. + */ + unsigned int rename_threshold; + + /** + * Maximum similarity sources to examine for renames (default 200). + * If the number of rename candidates (add / delete pairs) is greater + * than this value, inexact rename detection is aborted. + * + * This setting overrides the `merge.renameLimit` configuration value. + */ + unsigned int target_limit; + + /** Pluggable similarity metric; pass NULL to use internal metric */ + git_diff_similarity_metric *metric; + + /** Flags for handling conflicting content. */ + git_merge_file_favor_t file_favor; + + unsigned int file_flags; +} git_merge_options; + +#define GIT_MERGE_OPTIONS_VERSION 1 +#define GIT_MERGE_OPTIONS_INIT {GIT_MERGE_OPTIONS_VERSION} + +/** + * Initializes a `git_merge_options` with default values. Equivalent to + * creating an instance with GIT_MERGE_OPTIONS_INIT. + * + * @param opts the `git_merge_options` instance to initialize. + * @param version the version of the struct; you should pass + * `GIT_MERGE_OPTIONS_VERSION` here. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_merge_init_options( + git_merge_options *opts, + unsigned int version); + +/** + * The results of `git_merge_analysis` indicate the merge opportunities. + */ +typedef enum { + /** No merge is possible. (Unused.) */ + GIT_MERGE_ANALYSIS_NONE = 0, + + /** + * A "normal" merge; both HEAD and the given merge input have diverged + * from their common ancestor. The divergent commits must be merged. + */ + GIT_MERGE_ANALYSIS_NORMAL = (1 << 0), + + /** + * All given merge inputs are reachable from HEAD, meaning the + * repository is up-to-date and no merge needs to be performed. + */ + GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1), + + /** + * The given merge input is a fast-forward from HEAD and no merge + * needs to be performed. Instead, the client can check out the + * given merge input. + */ + GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2), + + /** + * The HEAD of the current repository is "unborn" and does not point to + * a valid commit. No merge can be performed, but the caller may wish + * to simply set HEAD to the target commit(s). + */ + GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), +} git_merge_analysis_t; + +/** + * The user's stated preference for merges. + */ +typedef enum { + /** + * No configuration was found that suggests a preferred behavior for + * merge. + */ + GIT_MERGE_PREFERENCE_NONE = 0, + + /** + * There is a `merge.ff=false` configuration setting, suggesting that + * the user does not want to allow a fast-forward merge. + */ + GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0), + + /** + * There is a `merge.ff=only` configuration setting, suggesting that + * the user only wants fast-forward merges. + */ + GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1), +} git_merge_preference_t; + +/** + * Analyzes the given branch(es) and determines the opportunities for + * merging them into the HEAD of the repository. + * + * @param analysis_out analysis enumeration that the result is written into + * @param repo the repository to merge + * @param their_heads the heads to merge into + * @param their_heads_len the number of heads to merge + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_merge_analysis( + git_merge_analysis_t *analysis_out, + git_merge_preference_t *preference_out, + git_repository *repo, + const git_annotated_commit **their_heads, + size_t their_heads_len); + +/** + * Find a merge base between two commits + * + * @param out the OID of a merge base between 'one' and 'two' + * @param repo the repository where the commits exist + * @param one one of the commits + * @param two the other commit + * @return 0 on success, GIT_ENOTFOUND if not found or error code + */ +GIT_EXTERN(int) git_merge_base( + git_oid *out, + git_repository *repo, + const git_oid *one, + const git_oid *two); + +/** + * Find merge bases between two commits + * + * @param out array in which to store the resulting ids + * @param repo the repository where the commits exist + * @param one one of the commits + * @param two the other commit + * @return 0 on success, GIT_ENOTFOUND if not found or error code + */ +GIT_EXTERN(int) git_merge_bases( + git_oidarray *out, + git_repository *repo, + const git_oid *one, + const git_oid *two); + +/** + * Find a merge base given a list of commits + * + * @param out the OID of a merge base considering all the commits + * @param repo the repository where the commits exist + * @param length The number of commits in the provided `input_array` + * @param input_array oids of the commits + * @return Zero on success; GIT_ENOTFOUND or -1 on failure. + */ +GIT_EXTERN(int) git_merge_base_many( + git_oid *out, + git_repository *repo, + size_t length, + const git_oid input_array[]); + +/** + * Find all merge bases given a list of commits + * + * @param out array in which to store the resulting ids + * @param repo the repository where the commits exist + * @param length The number of commits in the provided `input_array` + * @param input_array oids of the commits + * @return Zero on success; GIT_ENOTFOUND or -1 on failure. + */ +GIT_EXTERN(int) git_merge_bases_many( + git_oidarray *out, + git_repository *repo, + size_t length, + const git_oid input_array[]); + +/** + * Find a merge base in preparation for an octopus merge + * + * @param out the OID of a merge base considering all the commits + * @param repo the repository where the commits exist + * @param length The number of commits in the provided `input_array` + * @param input_array oids of the commits + * @return Zero on success; GIT_ENOTFOUND or -1 on failure. + */ +GIT_EXTERN(int) git_merge_base_octopus( + git_oid *out, + git_repository *repo, + size_t length, + const git_oid input_array[]); + +/** + * Merge two files as they exist in the in-memory data structures, using + * the given common ancestor as the baseline, producing a + * `git_merge_file_result` that reflects the merge result. The + * `git_merge_file_result` must be freed with `git_merge_file_result_free`. + * + * Note that this function does not reference a repository and any + * configuration must be passed as `git_merge_file_options`. + * + * @param out The git_merge_file_result to be filled in + * @param ancestor The contents of the ancestor file + * @param ours The contents of the file in "our" side + * @param theirs The contents of the file in "their" side + * @param opts The merge file options or `NULL` for defaults + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_merge_file( + git_merge_file_result *out, + const git_merge_file_input *ancestor, + const git_merge_file_input *ours, + const git_merge_file_input *theirs, + const git_merge_file_options *opts); + +/** + * Merge two files as they exist in the index, using the given common + * ancestor as the baseline, producing a `git_merge_file_result` that + * reflects the merge result. The `git_merge_file_result` must be freed with + * `git_merge_file_result_free`. + * + * @param out The git_merge_file_result to be filled in + * @param repo The repository + * @param ancestor The index entry for the ancestor file (stage level 1) + * @param ours The index entry for our file (stage level 2) + * @param theirs The index entry for their file (stage level 3) + * @param opts The merge file options or NULL + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_merge_file_from_index( + git_merge_file_result *out, + git_repository *repo, + const git_index_entry *ancestor, + const git_index_entry *ours, + const git_index_entry *theirs, + const git_merge_file_options *opts); + +/** + * Frees a `git_merge_file_result`. + * + * @param result The result to free or `NULL` + */ +GIT_EXTERN(void) git_merge_file_result_free(git_merge_file_result *result); + +/** + * Merge two trees, producing a `git_index` that reflects the result of + * the merge. The index may be written as-is to the working directory + * or checked out. If the index is to be converted to a tree, the caller + * should resolve any conflicts that arose as part of the merge. + * + * The returned index must be freed explicitly with `git_index_free`. + * + * @param out pointer to store the index result in + * @param repo repository that contains the given trees + * @param ancestor_tree the common ancestor between the trees (or null if none) + * @param our_tree the tree that reflects the destination tree + * @param their_tree the tree to merge in to `our_tree` + * @param opts the merge tree options (or null for defaults) + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_merge_trees( + git_index **out, + git_repository *repo, + const git_tree *ancestor_tree, + const git_tree *our_tree, + const git_tree *their_tree, + const git_merge_options *opts); + +/** + * Merge two commits, producing a `git_index` that reflects the result of + * the merge. The index may be written as-is to the working directory + * or checked out. If the index is to be converted to a tree, the caller + * should resolve any conflicts that arose as part of the merge. + * + * The merge performed uses the first common ancestor, unlike the + * `git-merge-recursive` strategy, which may produce an artificial common + * ancestor tree when there are multiple ancestors. + * + * The returned index must be freed explicitly with `git_index_free`. + * + * @param out pointer to store the index result in + * @param repo repository that contains the given trees + * @param our_commit the commit that reflects the destination tree + * @param their_commit the commit to merge in to `our_commit` + * @param opts the merge tree options (or null for defaults) + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_merge_commits( + git_index **out, + git_repository *repo, + const git_commit *our_commit, + const git_commit *their_commit, + const git_merge_options *opts); + +/** + * Merges the given commit(s) into HEAD, writing the results into the working + * directory. Any changes are staged for commit and any conflicts are written + * to the index. Callers should inspect the repository's index after this + * completes, resolve any conflicts and prepare a commit. + * + * The merge performed uses the first common ancestor, unlike the + * `git-merge-recursive` strategy, which may produce an artificial common + * ancestor tree when there are multiple ancestors. + * + * For compatibility with git, the repository is put into a merging + * state. Once the commit is done (or if the uses wishes to abort), + * you should clear this state by calling + * `git_repository_state_cleanup()`. + * + * @param repo the repository to merge + * @param their_heads the heads to merge into + * @param their_heads_len the number of heads to merge + * @param merge_opts merge options + * @param checkout_opts checkout options + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_merge( + git_repository *repo, + const git_annotated_commit **their_heads, + size_t their_heads_len, + const git_merge_options *merge_opts, + const git_checkout_options *checkout_opts); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/message.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/message.h new file mode 100644 index 000000000..d78b1dce5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/message.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_message_h__ +#define INCLUDE_git_message_h__ + +#include "common.h" +#include "buffer.h" + +/** + * @file git2/message.h + * @brief Git message management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Clean up message from excess whitespace and make sure that the last line + * ends with a '\n'. + * + * Optionally, can remove lines starting with a "#". + * + * @param out The user-allocated git_buf which will be filled with the + * cleaned up message. + * + * @param message The message to be prettified. + * + * @param strip_comments Non-zero to remove comment lines, 0 to leave them in. + * + * @param comment_char Comment character. Lines starting with this character + * are considered to be comments and removed if `strip_comments` is non-zero. + * + * @return 0 or an error code. + */ +GIT_EXTERN(int) git_message_prettify(git_buf *out, const char *message, int strip_comments, char comment_char); + +/** @} */ +GIT_END_DECL + +#endif /* INCLUDE_git_message_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/net.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/net.h new file mode 100644 index 000000000..04dff34bc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/net.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_net_h__ +#define INCLUDE_git_net_h__ + +#include "common.h" +#include "oid.h" +#include "types.h" + +/** + * @file git2/net.h + * @brief Git networking declarations + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +#define GIT_DEFAULT_PORT "9418" + +/** + * Direction of the connection. + * + * We need this because we need to know whether we should call + * git-upload-pack or git-receive-pack on the remote end when get_refs + * gets called. + */ +typedef enum { + GIT_DIRECTION_FETCH = 0, + GIT_DIRECTION_PUSH = 1 +} git_direction; + +/** + * Description of a reference advertised by a remote server, given out + * on `ls` calls. + */ +struct git_remote_head { + int local; /* available locally */ + git_oid oid; + git_oid loid; + char *name; + /** + * If the server send a symref mapping for this ref, this will + * point to the target. + */ + char *symref_target; +}; + +/** + * Callback for listing the remote heads + */ +typedef int (*git_headlist_cb)(git_remote_head *rhead, void *payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/notes.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/notes.h new file mode 100644 index 000000000..3a626cafd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/notes.h @@ -0,0 +1,217 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_note_h__ +#define INCLUDE_git_note_h__ + +#include "oid.h" + +/** + * @file git2/notes.h + * @brief Git notes management routines + * @defgroup git_note Git notes management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Callback for git_note_foreach. + * + * Receives: + * - blob_id: Oid of the blob containing the message + * - annotated_object_id: Oid of the git object being annotated + * - payload: Payload data passed to `git_note_foreach` + */ +typedef int (*git_note_foreach_cb)( + const git_oid *blob_id, const git_oid *annotated_object_id, void *payload); + +/** + * note iterator + */ +typedef struct git_iterator git_note_iterator; + +/** + * Creates a new iterator for notes + * + * The iterator must be freed manually by the user. + * + * @param out pointer to the iterator + * @param repo repository where to look up the note + * @param notes_ref canonical name of the reference to use (optional); defaults to + * "refs/notes/commits" + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_iterator_new( + git_note_iterator **out, + git_repository *repo, + const char *notes_ref); + +/** + * Frees an git_note_iterator + * + * @param it pointer to the iterator + */ +GIT_EXTERN(void) git_note_iterator_free(git_note_iterator *it); + +/** + * Return the current item (note_id and annotated_id) and advance the iterator + * internally to the next value + * + * @param note_id id of blob containing the message + * @param annotated_id id of the git object being annotated + * @param it pointer to the iterator + * + * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code + * (negative value) + */ +GIT_EXTERN(int) git_note_next( + git_oid* note_id, + git_oid* annotated_id, + git_note_iterator *it); + + +/** + * Read the note for an object + * + * The note must be freed manually by the user. + * + * @param out pointer to the read note; NULL in case of error + * @param repo repository where to look up the note + * @param notes_ref canonical name of the reference to use (optional); defaults to + * "refs/notes/commits" + * @param oid OID of the git object to read the note from + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_read( + git_note **out, + git_repository *repo, + const char *notes_ref, + const git_oid *oid); + +/** + * Get the note author + * + * @param note the note + * @return the author + */ +GIT_EXTERN(const git_signature *) git_note_author(const git_note *note); + +/** + * Get the note committer + * + * @param note the note + * @return the committer + */ +GIT_EXTERN(const git_signature *) git_note_committer(const git_note *note); + + +/** + * Get the note message + * + * @param note the note + * @return the note message + */ +GIT_EXTERN(const char *) git_note_message(const git_note *note); + + +/** + * Get the note object's id + * + * @param note the note + * @return the note object's id + */ +GIT_EXTERN(const git_oid *) git_note_id(const git_note *note); + +/** + * Add a note for an object + * + * @param out pointer to store the OID (optional); NULL in case of error + * @param repo repository where to store the note + * @param notes_ref canonical name of the reference to use (optional); + * defaults to "refs/notes/commits" + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer + * @param oid OID of the git object to decorate + * @param note Content of the note to add for object oid + * @param force Overwrite existing note + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_create( + git_oid *out, + git_repository *repo, + const char *notes_ref, + const git_signature *author, + const git_signature *committer, + const git_oid *oid, + const char *note, + int force); + + +/** + * Remove the note for an object + * + * @param repo repository where the note lives + * @param notes_ref canonical name of the reference to use (optional); + * defaults to "refs/notes/commits" + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer + * @param oid OID of the git object to remove the note from + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_remove( + git_repository *repo, + const char *notes_ref, + const git_signature *author, + const git_signature *committer, + const git_oid *oid); + +/** + * Free a git_note object + * + * @param note git_note object + */ +GIT_EXTERN(void) git_note_free(git_note *note); + +/** + * Get the default notes reference for a repository + * + * @param out buffer in which to store the name of the default notes reference + * @param repo The Git repository + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_default_ref(git_buf *out, git_repository *repo); + +/** + * Loop over all the notes within a specified namespace + * and issue a callback for each one. + * + * @param repo Repository where to find the notes. + * + * @param notes_ref Reference to read from (optional); defaults to + * "refs/notes/commits". + * + * @param note_cb Callback to invoke per found annotation. Return non-zero + * to stop looping. + * + * @param payload Extra parameter to callback function. + * + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_note_foreach( + git_repository *repo, + const char *notes_ref, + git_note_foreach_cb note_cb, + void *payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/object.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/object.h new file mode 100644 index 000000000..a798c9dc3 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/object.h @@ -0,0 +1,242 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_object_h__ +#define INCLUDE_git_object_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "buffer.h" + +/** + * @file git2/object.h + * @brief Git revision object management routines + * @defgroup git_object Git revision object management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Lookup a reference to one of the objects in a repository. + * + * The generated reference is owned by the repository and + * should be closed with the `git_object_free` method + * instead of free'd manually. + * + * The 'type' parameter must match the type of the object + * in the odb; the method will fail otherwise. + * The special value 'GIT_OBJ_ANY' may be passed to let + * the method guess the object's type. + * + * @param object pointer to the looked-up object + * @param repo the repository to look up the object + * @param id the unique identifier for the object + * @param type the type of the object + * @return 0 or an error code + */ +GIT_EXTERN(int) git_object_lookup( + git_object **object, + git_repository *repo, + const git_oid *id, + git_otype type); + +/** + * Lookup a reference to one of the objects in a repository, + * given a prefix of its identifier (short id). + * + * The object obtained will be so that its identifier + * matches the first 'len' hexadecimal characters + * (packets of 4 bits) of the given 'id'. + * 'len' must be at least GIT_OID_MINPREFIXLEN, and + * long enough to identify a unique object matching + * the prefix; otherwise the method will fail. + * + * The generated reference is owned by the repository and + * should be closed with the `git_object_free` method + * instead of free'd manually. + * + * The 'type' parameter must match the type of the object + * in the odb; the method will fail otherwise. + * The special value 'GIT_OBJ_ANY' may be passed to let + * the method guess the object's type. + * + * @param object_out pointer where to store the looked-up object + * @param repo the repository to look up the object + * @param id a short identifier for the object + * @param len the length of the short identifier + * @param type the type of the object + * @return 0 or an error code + */ +GIT_EXTERN(int) git_object_lookup_prefix( + git_object **object_out, + git_repository *repo, + const git_oid *id, + size_t len, + git_otype type); + + +/** + * Lookup an object that represents a tree entry. + * + * @param out buffer that receives a pointer to the object (which must be freed + * by the caller) + * @param treeish root object that can be peeled to a tree + * @param path relative path from the root object to the desired object + * @param type type of object desired + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_object_lookup_bypath( + git_object **out, + const git_object *treeish, + const char *path, + git_otype type); + +/** + * Get the id (SHA1) of a repository object + * + * @param obj the repository object + * @return the SHA1 id + */ +GIT_EXTERN(const git_oid *) git_object_id(const git_object *obj); + +/** + * Get a short abbreviated OID string for the object + * + * This starts at the "core.abbrev" length (default 7 characters) and + * iteratively extends to a longer string if that length is ambiguous. + * The result will be unambiguous (at least until new objects are added to + * the repository). + * + * @param out Buffer to write string into + * @param obj The object to get an ID for + * @return 0 on success, <0 for error + */ +GIT_EXTERN(int) git_object_short_id(git_buf *out, const git_object *obj); + +/** + * Get the object type of an object + * + * @param obj the repository object + * @return the object's type + */ +GIT_EXTERN(git_otype) git_object_type(const git_object *obj); + +/** + * Get the repository that owns this object + * + * Freeing or calling `git_repository_close` on the + * returned pointer will invalidate the actual object. + * + * Any other operation may be run on the repository without + * affecting the object. + * + * @param obj the object + * @return the repository who owns this object + */ +GIT_EXTERN(git_repository *) git_object_owner(const git_object *obj); + +/** + * Close an open object + * + * This method instructs the library to close an existing + * object; note that git_objects are owned and cached by the repository + * so the object may or may not be freed after this library call, + * depending on how aggressive is the caching mechanism used + * by the repository. + * + * IMPORTANT: + * It *is* necessary to call this method when you stop using + * an object. Failure to do so will cause a memory leak. + * + * @param object the object to close + */ +GIT_EXTERN(void) git_object_free(git_object *object); + +/** + * Convert an object type to its string representation. + * + * The result is a pointer to a string in static memory and + * should not be free()'ed. + * + * @param type object type to convert. + * @return the corresponding string representation. + */ +GIT_EXTERN(const char *) git_object_type2string(git_otype type); + +/** + * Convert a string object type representation to it's git_otype. + * + * @param str the string to convert. + * @return the corresponding git_otype. + */ +GIT_EXTERN(git_otype) git_object_string2type(const char *str); + +/** + * Determine if the given git_otype is a valid loose object type. + * + * @param type object type to test. + * @return true if the type represents a valid loose object type, + * false otherwise. + */ +GIT_EXTERN(int) git_object_typeisloose(git_otype type); + +/** + * Get the size in bytes for the structure which + * acts as an in-memory representation of any given + * object type. + * + * For all the core types, this would the equivalent + * of calling `sizeof(git_commit)` if the core types + * were not opaque on the external API. + * + * @param type object type to get its size + * @return size in bytes of the object + */ +GIT_EXTERN(size_t) git_object__size(git_otype type); + +/** + * Recursively peel an object until an object of the specified type is met. + * + * If the query cannot be satisfied due to the object model, + * GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a + * tree). + * + * If you pass `GIT_OBJ_ANY` as the target type, then the object will + * be peeled until the type changes. A tag will be peeled until the + * referenced object is no longer a tag, and a commit will be peeled + * to a tree. Any other object type will return GIT_EINVALIDSPEC. + * + * If peeling a tag we discover an object which cannot be peeled to + * the target type due to the object model, GIT_EPEEL will be + * returned. + * + * You must free the returned object. + * + * @param peeled Pointer to the peeled git_object + * @param object The object to be processed + * @param target_type The type of the requested object (a GIT_OBJ_ value) + * @return 0 on success, GIT_EINVALIDSPEC, GIT_EPEEL, or an error code + */ +GIT_EXTERN(int) git_object_peel( + git_object **peeled, + const git_object *object, + git_otype target_type); + +/** + * Create an in-memory copy of a Git object. The copy must be + * explicitly free'd or it will leak. + * + * @param dest Pointer to store the copy of the object + * @param source Original object to copy + */ +GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source); + +/** @} */ +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/odb.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/odb.h new file mode 100644 index 000000000..114f6b317 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/odb.h @@ -0,0 +1,495 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_odb_h__ +#define INCLUDE_git_odb_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" + +/** + * @file git2/odb.h + * @brief Git object database routines + * @defgroup git_odb Git object database routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Function type for callbacks from git_odb_foreach. + */ +typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload); + +/** + * Create a new object database with no backends. + * + * Before the ODB can be used for read/writing, a custom database + * backend must be manually added using `git_odb_add_backend()` + * + * @param out location to store the database pointer, if opened. + * Set to NULL if the open failed. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_new(git_odb **out); + +/** + * Create a new object database and automatically add + * the two default backends: + * + * - git_odb_backend_loose: read and write loose object files + * from disk, assuming `objects_dir` as the Objects folder + * + * - git_odb_backend_pack: read objects from packfiles, + * assuming `objects_dir` as the Objects folder which + * contains a 'pack/' folder with the corresponding data + * + * @param out location to store the database pointer, if opened. + * Set to NULL if the open failed. + * @param objects_dir path of the backends' "objects" directory. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir); + +/** + * Add an on-disk alternate to an existing Object DB. + * + * Note that the added path must point to an `objects`, not + * to a full repository, to use it as an alternate store. + * + * Alternate backends are always checked for objects *after* + * all the main backends have been exhausted. + * + * Writing is disabled on alternate backends. + * + * @param odb database to add the backend to + * @param path path to the objects folder for the alternate + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_odb_add_disk_alternate(git_odb *odb, const char *path); + +/** + * Close an open object database. + * + * @param db database pointer to close. If NULL no action is taken. + */ +GIT_EXTERN(void) git_odb_free(git_odb *db); + +/** + * Read an object from the database. + * + * This method queries all available ODB backends + * trying to read the given OID. + * + * The returned object is reference counted and + * internally cached, so it should be closed + * by the user once it's no longer in use. + * + * @param out pointer where to store the read object + * @param db database to search for the object in. + * @param id identity of the object to read. + * @return + * - 0 if the object was read; + * - GIT_ENOTFOUND if the object is not in the database. + */ +GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id); + +/** + * Read an object from the database, given a prefix + * of its identifier. + * + * This method queries all available ODB backends + * trying to match the 'len' first hexadecimal + * characters of the 'short_id'. + * The remaining (GIT_OID_HEXSZ-len)*4 bits of + * 'short_id' must be 0s. + * 'len' must be at least GIT_OID_MINPREFIXLEN, + * and the prefix must be long enough to identify + * a unique object in all the backends; the + * method will fail otherwise. + * + * The returned object is reference counted and + * internally cached, so it should be closed + * by the user once it's no longer in use. + * + * @param out pointer where to store the read object + * @param db database to search for the object in. + * @param short_id a prefix of the id of the object to read. + * @param len the length of the prefix + * @return + * - 0 if the object was read; + * - GIT_ENOTFOUND if the object is not in the database. + * - GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix) + */ +GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len); + +/** + * Read the header of an object from the database, without + * reading its full contents. + * + * The header includes the length and the type of an object. + * + * Note that most backends do not support reading only the header + * of an object, so the whole object will be read and then the + * header will be returned. + * + * @param len_out pointer where to store the length + * @param type_out pointer where to store the type + * @param db database to search for the object in. + * @param id identity of the object to read. + * @return + * - 0 if the object was read; + * - GIT_ENOTFOUND if the object is not in the database. + */ +GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id); + +/** + * Determine if the given object can be found in the object database. + * + * @param db database to be searched for the given object. + * @param id the object to search for. + * @return + * - 1, if the object was found + * - 0, otherwise + */ +GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id); + +/** + * Determine if objects can be found in the object database from a short OID. + * + * @param out The full OID of the found object if just one is found. + * @param db The database to be searched for the given object. + * @param short_id A prefix of the id of the object to read. + * @param len The length of the prefix. + * @return 0 if found, GIT_ENOTFOUND if not found, GIT_EAMBIGUOUS if multiple + * matches were found, other value < 0 if there was a read error. + */ +GIT_EXTERN(int) git_odb_exists_prefix( + git_oid *out, git_odb *db, const git_oid *short_id, size_t len); + +/** + * Refresh the object database to load newly added files. + * + * If the object databases have changed on disk while the library + * is running, this function will force a reload of the underlying + * indexes. + * + * Use this function when you're confident that an external + * application has tampered with the ODB. + * + * NOTE that it is not necessary to call this function at all. The + * library will automatically attempt to refresh the ODB + * when a lookup fails, to see if the looked up object exists + * on disk but hasn't been loaded yet. + * + * @param db database to refresh + * @return 0 on success, error code otherwise + */ +GIT_EXTERN(int) git_odb_refresh(struct git_odb *db); + +/** + * List all objects available in the database + * + * The callback will be called for each object available in the + * database. Note that the objects are likely to be returned in the index + * order, which would make accessing the objects in that order inefficient. + * Return a non-zero value from the callback to stop looping. + * + * @param db database to use + * @param cb the callback to call for each object + * @param payload data to pass to the callback + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload); + +/** + * Write an object directly into the ODB + * + * This method writes a full object straight into the ODB. + * For most cases, it is preferred to write objects through a write + * stream, which is both faster and less memory intensive, specially + * for big objects. + * + * This method is provided for compatibility with custom backends + * which are not able to support streaming writes + * + * @param out pointer to store the OID result of the write + * @param odb object database where to store the object + * @param data buffer with the data to store + * @param len size of the buffer + * @param type type of the data to store + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_otype type); + +/** + * Open a stream to write an object into the ODB + * + * The type and final length of the object must be specified + * when opening the stream. + * + * The returned stream will be of type `GIT_STREAM_WRONLY`, and it + * won't be effective until `git_odb_stream_finalize_write` is called + * and returns without an error + * + * The stream must always be freed when done with `git_odb_stream_free` or + * will leak memory. + * + * @see git_odb_stream + * + * @param out pointer where to store the stream + * @param db object database where the stream will write + * @param size final size of the object that will be written + * @param type type of the object that will be written + * @return 0 if the stream was created; error code otherwise + */ +GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, size_t size, git_otype type); + +/** + * Write to an odb stream + * + * This method will fail if the total number of received bytes exceeds the + * size declared with `git_odb_open_wstream()` + * + * @param stream the stream + * @param buffer the data to write + * @param len the buffer's length + * @return 0 if the write succeeded; error code otherwise + */ +GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len); + +/** + * Finish writing to an odb stream + * + * The object will take its final name and will be available to the + * odb. + * + * This method will fail if the total number of received bytes + * differs from the size declared with `git_odb_open_wstream()` + * + * @param out pointer to store the resulting object's id + * @param stream the stream + * @return 0 on success; an error code otherwise + */ +GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream); + +/** + * Read from an odb stream + * + * Most backends don't implement streaming reads + */ +GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len); + +/** + * Free an odb stream + * + * @param stream the stream to free + */ +GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream); + +/** + * Open a stream to read an object from the ODB + * + * Note that most backends do *not* support streaming reads + * because they store their objects as compressed/delta'ed blobs. + * + * It's recommended to use `git_odb_read` instead, which is + * assured to work on all backends. + * + * The returned stream will be of type `GIT_STREAM_RDONLY` and + * will have the following methods: + * + * - stream->read: read `n` bytes from the stream + * - stream->free: free the stream + * + * The stream must always be free'd or will leak memory. + * + * @see git_odb_stream + * + * @param out pointer where to store the stream + * @param db object database where the stream will read from + * @param oid oid of the object the stream will read from + * @return 0 if the stream was created; error code otherwise + */ +GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **out, git_odb *db, const git_oid *oid); + +/** + * Open a stream for writing a pack file to the ODB. + * + * If the ODB layer understands pack files, then the given + * packfile will likely be streamed directly to disk (and a + * corresponding index created). If the ODB layer does not + * understand pack files, the objects will be stored in whatever + * format the ODB layer uses. + * + * @see git_odb_writepack + * + * @param out pointer to the writepack functions + * @param db object database where the stream will read from + * @param progress_cb function to call with progress information. + * Be aware that this is called inline with network and indexing operations, + * so performance may be affected. + * @param progress_payload payload for the progress callback + */ +GIT_EXTERN(int) git_odb_write_pack( + git_odb_writepack **out, + git_odb *db, + git_transfer_progress_cb progress_cb, + void *progress_payload); + +/** + * Determine the object-ID (sha1 hash) of a data buffer + * + * The resulting SHA-1 OID will be the identifier for the data + * buffer as if the data buffer it were to written to the ODB. + * + * @param out the resulting object-ID. + * @param data data to hash + * @param len size of the data + * @param type of the data to hash + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type); + +/** + * Read a file from disk and fill a git_oid with the object id + * that the file would have if it were written to the Object + * Database as an object of the given type (w/o applying filters). + * Similar functionality to git.git's `git hash-object` without + * the `-w` flag, however, with the --no-filters flag. + * If you need filters, see git_repository_hashfile. + * + * @param out oid structure the result is written into. + * @param path file to read and determine object id for + * @param type the type of the object that will be hashed + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type); + +/** + * Create a copy of an odb_object + * + * The returned copy must be manually freed with `git_odb_object_free`. + * Note that because of an implementation detail, the returned copy will be + * the same pointer as `source`: the object is internally refcounted, so the + * copy still needs to be freed twice. + * + * @param dest pointer where to store the copy + * @param source object to copy + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_object_dup(git_odb_object **dest, git_odb_object *source); + +/** + * Close an ODB object + * + * This method must always be called once a `git_odb_object` is no + * longer needed, otherwise memory will leak. + * + * @param object object to close + */ +GIT_EXTERN(void) git_odb_object_free(git_odb_object *object); + +/** + * Return the OID of an ODB object + * + * This is the OID from which the object was read from + * + * @param object the object + * @return a pointer to the OID + */ +GIT_EXTERN(const git_oid *) git_odb_object_id(git_odb_object *object); + +/** + * Return the data of an ODB object + * + * This is the uncompressed, raw data as read from the ODB, + * without the leading header. + * + * This pointer is owned by the object and shall not be free'd. + * + * @param object the object + * @return a pointer to the data + */ +GIT_EXTERN(const void *) git_odb_object_data(git_odb_object *object); + +/** + * Return the size of an ODB object + * + * This is the real size of the `data` buffer, not the + * actual size of the object. + * + * @param object the object + * @return the size + */ +GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object); + +/** + * Return the type of an ODB object + * + * @param object the object + * @return the type + */ +GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object); + +/** + * Add a custom backend to an existing Object DB + * + * The backends are checked in relative ordering, based on the + * value of the `priority` parameter. + * + * Read for more information. + * + * @param odb database to add the backend to + * @param backend pointer to a git_odb_backend instance + * @param priority Value for ordering the backends queue + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority); + +/** + * Add a custom backend to an existing Object DB; this + * backend will work as an alternate. + * + * Alternate backends are always checked for objects *after* + * all the main backends have been exhausted. + * + * The backends are checked in relative ordering, based on the + * value of the `priority` parameter. + * + * Writing is disabled on alternate backends. + * + * Read for more information. + * + * @param odb database to add the backend to + * @param backend pointer to a git_odb_backend instance + * @param priority Value for ordering the backends queue + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority); + +/** + * Get the number of ODB backend objects + * + * @param odb object database + * @return number of backends in the ODB + */ +GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb); + +/** + * Lookup an ODB backend object by index + * + * @param out output pointer to ODB backend at pos + * @param odb object database + * @param pos index into object database backend list + * @return 0 on success; GIT_ENOTFOUND if pos is invalid; other errors < 0 + */ +GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/odb_backend.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/odb_backend.h new file mode 100644 index 000000000..4d772cab9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/odb_backend.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_odb_backend_h__ +#define INCLUDE_git_odb_backend_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/backend.h + * @brief Git custom backend functions + * @defgroup git_odb Git object database routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/* + * Constructors for in-box ODB backends. + */ + +/** + * Create a backend for the packfiles. + * + * @param out location to store the odb backend pointer + * @param objects_dir the Git repository's objects directory + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir); + +/** + * Create a backend for loose objects + * + * @param out location to store the odb backend pointer + * @param objects_dir the Git repository's objects directory + * @param compression_level zlib compression level to use + * @param do_fsync whether to do an fsync() after writing (currently ignored) + * @param dir_mode permissions to use creating a directory or 0 for defaults + * @param file_mode permissions to use creating a file or 0 for defaults + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_backend_loose( + git_odb_backend **out, + const char *objects_dir, + int compression_level, + int do_fsync, + unsigned int dir_mode, + unsigned int file_mode); + +/** + * Create a backend out of a single packfile + * + * This can be useful for inspecting the contents of a single + * packfile. + * + * @param out location to store the odb backend pointer + * @param index_file path to the packfile's .idx file + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file); + +/** Streaming mode */ +typedef enum { + GIT_STREAM_RDONLY = (1 << 1), + GIT_STREAM_WRONLY = (1 << 2), + GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY), +} git_odb_stream_t; + +/** + * A stream to read/write from a backend. + * + * This represents a stream of data being written to or read from a + * backend. When writing, the frontend functions take care of + * calculating the object's id and all `finalize_write` needs to do is + * store the object with the id it is passed. + */ +struct git_odb_stream { + git_odb_backend *backend; + unsigned int mode; + void *hash_ctx; + + size_t declared_size; + size_t received_bytes; + + /** + * Write at most `len` bytes into `buffer` and advance the stream. + */ + int (*read)(git_odb_stream *stream, char *buffer, size_t len); + + /** + * Write `len` bytes from `buffer` into the stream. + */ + int (*write)(git_odb_stream *stream, const char *buffer, size_t len); + + /** + * Store the contents of the stream as an object with the id + * specified in `oid`. + * + * This method might not be invoked if: + * - an error occurs earlier with the `write` callback, + * - the object referred to by `oid` already exists in any backend, or + * - the final number of received bytes differs from the size declared + * with `git_odb_open_wstream()` + */ + int (*finalize_write)(git_odb_stream *stream, const git_oid *oid); + + /** + * Free the stream's memory. + * + * This method might be called without a call to `finalize_write` if + * an error occurs or if the object is already present in the ODB. + */ + void (*free)(git_odb_stream *stream); +}; + +/** A stream to write a pack file to the ODB */ +struct git_odb_writepack { + git_odb_backend *backend; + + int (*append)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats); + int (*commit)(git_odb_writepack *writepack, git_transfer_progress *stats); + void (*free)(git_odb_writepack *writepack); +}; + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/oid.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/oid.h new file mode 100644 index 000000000..8ad51c8ba --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/oid.h @@ -0,0 +1,269 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_oid_h__ +#define INCLUDE_git_oid_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/oid.h + * @brief Git object id routines + * @defgroup git_oid Git object id routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** Size (in bytes) of a raw/binary oid */ +#define GIT_OID_RAWSZ 20 + +/** Size (in bytes) of a hex formatted oid */ +#define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2) + +/** Minimum length (in number of hex characters, + * i.e. packets of 4 bits) of an oid prefix */ +#define GIT_OID_MINPREFIXLEN 4 + +/** Unique identity of any object (commit, tree, blob, tag). */ +typedef struct git_oid { + /** raw binary formatted id */ + unsigned char id[GIT_OID_RAWSZ]; +} git_oid; + +/** + * Parse a hex formatted object id into a git_oid. + * + * @param out oid structure the result is written into. + * @param str input hex string; must be pointing at the start of + * the hex sequence and have at least the number of bytes + * needed for an oid encoded in hex (40 bytes). + * @return 0 or an error code + */ +GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str); + +/** + * Parse a hex formatted null-terminated string into a git_oid. + * + * @param out oid structure the result is written into. + * @param str input hex string; must be at least 4 characters + * long and null-terminated. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str); + +/** + * Parse N characters of a hex formatted object id into a git_oid + * + * If N is odd, N-1 characters will be parsed instead. + * The remaining space in the git_oid will be set to zero. + * + * @param out oid structure the result is written into. + * @param str input hex string of at least size `length` + * @param length length of the input string + * @return 0 or an error code + */ +GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length); + +/** + * Copy an already raw oid into a git_oid structure. + * + * @param out oid structure the result is written into. + * @param raw the raw input bytes to be copied. + */ +GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw); + +/** + * Format a git_oid into a hex string. + * + * @param out output hex string; must be pointing at the start of + * the hex sequence and have at least the number of bytes + * needed for an oid encoded in hex (40 bytes). Only the + * oid digits are written; a '\\0' terminator must be added + * by the caller if it is required. + * @param id oid structure to format. + */ +GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id); + +/** + * Format a git_oid into a partial hex string. + * + * @param out output hex string; you say how many bytes to write. + * If the number of bytes is > GIT_OID_HEXSZ, extra bytes + * will be zeroed; if not, a '\0' terminator is NOT added. + * @param n number of characters to write into out string + * @param id oid structure to format. + */ +GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id); + +/** + * Format a git_oid into a loose-object path string. + * + * The resulting string is "aa/...", where "aa" is the first two + * hex digits of the oid and "..." is the remaining 38 digits. + * + * @param out output hex string; must be pointing at the start of + * the hex sequence and have at least the number of bytes + * needed for an oid encoded in hex (41 bytes). Only the + * oid digits are written; a '\\0' terminator must be added + * by the caller if it is required. + * @param id oid structure to format. + */ +GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id); + +/** + * Format a git_oid into a statically allocated c-string. + * + * The c-string is owned by the library and should not be freed + * by the user. If libgit2 is built with thread support, the string + * will be stored in TLS (i.e. one buffer per thread) to allow for + * concurrent calls of the function. + * + * @param oid The oid structure to format + * @return the c-string + */ +GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid); + +/** + * Format a git_oid into a buffer as a hex format c-string. + * + * If the buffer is smaller than GIT_OID_HEXSZ+1, then the resulting + * oid c-string will be truncated to n-1 characters (but will still be + * NUL-byte terminated). + * + * If there are any input parameter errors (out == NULL, n == 0, oid == + * NULL), then a pointer to an empty string is returned, so that the + * return value can always be printed. + * + * @param out the buffer into which the oid string is output. + * @param n the size of the out buffer. + * @param id the oid structure to format. + * @return the out buffer pointer, assuming no input parameter + * errors, otherwise a pointer to an empty string. + */ +GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id); + +/** + * Copy an oid from one structure to another. + * + * @param out oid structure the result is written into. + * @param src oid structure to copy from. + */ +GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src); + +/** + * Compare two oid structures. + * + * @param a first oid structure. + * @param b second oid structure. + * @return <0, 0, >0 if a < b, a == b, a > b. + */ +GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b); + +/** + * Compare two oid structures for equality + * + * @param a first oid structure. + * @param b second oid structure. + * @return true if equal, false otherwise + */ +GIT_EXTERN(int) git_oid_equal(const git_oid *a, const git_oid *b); + +/** + * Compare the first 'len' hexadecimal characters (packets of 4 bits) + * of two oid structures. + * + * @param a first oid structure. + * @param b second oid structure. + * @param len the number of hex chars to compare + * @return 0 in case of a match + */ +GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len); + +/** + * Check if an oid equals an hex formatted object id. + * + * @param id oid structure. + * @param str input hex string of an object id. + * @return 0 in case of a match, -1 otherwise. + */ +GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str); + +/** + * Compare an oid to an hex formatted object id. + * + * @param id oid structure. + * @param str input hex string of an object id. + * @return -1 if str is not valid, <0 if id sorts before str, + * 0 if id matches str, >0 if id sorts after str. + */ +GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str); + +/** + * Check is an oid is all zeros. + * + * @return 1 if all zeros, 0 otherwise. + */ +GIT_EXTERN(int) git_oid_iszero(const git_oid *id); + +/** + * OID Shortener object + */ +typedef struct git_oid_shorten git_oid_shorten; + +/** + * Create a new OID shortener. + * + * The OID shortener is used to process a list of OIDs + * in text form and return the shortest length that would + * uniquely identify all of them. + * + * E.g. look at the result of `git log --abbrev`. + * + * @param min_length The minimal length for all identifiers, + * which will be used even if shorter OIDs would still + * be unique. + * @return a `git_oid_shorten` instance, NULL if OOM + */ +GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length); + +/** + * Add a new OID to set of shortened OIDs and calculate + * the minimal length to uniquely identify all the OIDs in + * the set. + * + * The OID is expected to be a 40-char hexadecimal string. + * The OID is owned by the user and will not be modified + * or freed. + * + * For performance reasons, there is a hard-limit of how many + * OIDs can be added to a single set (around ~32000, assuming + * a mostly randomized distribution), which should be enough + * for any kind of program, and keeps the algorithm fast and + * memory-efficient. + * + * Attempting to add more than those OIDs will result in a + * GITERR_INVALID error + * + * @param os a `git_oid_shorten` instance + * @param text_id an OID in text form + * @return the minimal length to uniquely identify all OIDs + * added so far to the set; or an error code (<0) if an + * error occurs. + */ +GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_id); + +/** + * Free an OID shortener instance + * + * @param os a `git_oid_shorten` instance + */ +GIT_EXTERN(void) git_oid_shorten_free(git_oid_shorten *os); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/oidarray.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/oidarray.h new file mode 100644 index 000000000..0b3204597 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/oidarray.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_oidarray_h__ +#define INCLUDE_git_oidarray_h__ + +#include "common.h" +#include "oid.h" + +GIT_BEGIN_DECL + +/** Array of object ids */ +typedef struct git_oidarray { + git_oid *ids; + size_t count; +} git_oidarray; + +/** + * Free the OID array + * + * This method must (and must only) be called on `git_oidarray` + * objects where the array is allocated by the library. Not doing so, + * will result in a memory leak. + * + * This does not free the `git_oidarray` itself, since the library will + * never allocate that object directly itself (it is more commonly embedded + * inside another struct or created on the stack). + * + * @param array git_oidarray from which to free oid data + */ +GIT_EXTERN(void) git_oidarray_free(git_oidarray *array); + +/** @} */ +GIT_END_DECL + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/pack.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/pack.h new file mode 100644 index 000000000..4cf426273 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/pack.h @@ -0,0 +1,228 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_pack_h__ +#define INCLUDE_git_pack_h__ + +#include "common.h" +#include "oid.h" + +/** + * @file git2/pack.h + * @brief Git pack management routines + * + * Packing objects + * --------------- + * + * Creation of packfiles requires two steps: + * + * - First, insert all the objects you want to put into the packfile + * using `git_packbuilder_insert` and `git_packbuilder_insert_tree`. + * It's important to add the objects in recency order ("in the order + * that they are 'reachable' from head"). + * + * "ANY order will give you a working pack, ... [but it is] the thing + * that gives packs good locality. It keeps the objects close to the + * head (whether they are old or new, but they are _reachable_ from the + * head) at the head of the pack. So packs actually have absolutely + * _wonderful_ IO patterns." - Linus Torvalds + * git.git/Documentation/technical/pack-heuristics.txt + * + * - Second, use `git_packbuilder_write` or `git_packbuilder_foreach` to + * write the resulting packfile. + * + * libgit2 will take care of the delta ordering and generation. + * `git_packbuilder_set_threads` can be used to adjust the number of + * threads used for the process. + * + * See tests/pack/packbuilder.c for an example. + * + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Stages that are reported by the packbuilder progress callback. + */ +typedef enum { + GIT_PACKBUILDER_ADDING_OBJECTS = 0, + GIT_PACKBUILDER_DELTAFICATION = 1, +} git_packbuilder_stage_t; + +/** + * Initialize a new packbuilder + * + * @param out The new packbuilder object + * @param repo The repository + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_new(git_packbuilder **out, git_repository *repo); + +/** + * Set number of threads to spawn + * + * By default, libgit2 won't spawn any threads at all; + * when set to 0, libgit2 will autodetect the number of + * CPUs. + * + * @param pb The packbuilder + * @param n Number of threads to spawn + * @return number of actual threads to be used + */ +GIT_EXTERN(unsigned int) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n); + +/** + * Insert a single object + * + * For an optimal pack it's mandatory to insert objects in recency order, + * commits followed by trees and blobs. + * + * @param pb The packbuilder + * @param id The oid of the commit + * @param name The name; might be NULL + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *id, const char *name); + +/** + * Insert a root tree object + * + * This will add the tree as well as all referenced trees and blobs. + * + * @param pb The packbuilder + * @param id The oid of the root tree + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *id); + +/** + * Insert a commit object + * + * This will add a commit as well as the completed referenced tree. + * + * @param pb The packbuilder + * @param id The oid of the commit + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id); + +/** + * Insert objects as given by the walk + * + * Those commits and all objects they reference will be inserted into + * the packbuilder. + * + * @param pb the packbuilder + * @param walk the revwalk to use to fill the packbuilder + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk); + +/** + * Write the contents of the packfile to an in-memory buffer + * + * The contents of the buffer will become a valid packfile, even though there + * will be no attached index + * + * @param buf Buffer where to write the packfile + * @param pb The packbuilder + */ +GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); + +/** + * Write the new pack and corresponding index file to path. + * + * @param pb The packbuilder + * @param path to the directory where the packfile and index should be stored + * @param mode permissions to use creating a packfile or 0 for defaults + * @param progress_cb function to call with progress information from the indexer (optional) + * @param progress_cb_payload payload for the progress callback (optional) + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_write( + git_packbuilder *pb, + const char *path, + unsigned int mode, + git_transfer_progress_cb progress_cb, + void *progress_cb_payload); + +/** +* Get the packfile's hash +* +* A packfile's name is derived from the sorted hashing of all object +* names. This is only correct after the packfile has been written. +* +* @param pb The packbuilder object +*/ +GIT_EXTERN(const git_oid *) git_packbuilder_hash(git_packbuilder *pb); + +typedef int (*git_packbuilder_foreach_cb)(void *buf, size_t size, void *payload); + +/** + * Create the new pack and pass each object to the callback + * + * @param pb the packbuilder + * @param cb the callback to call with each packed object's buffer + * @param payload the callback's data + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_foreach_cb cb, void *payload); + +/** + * Get the total number of objects the packbuilder will write out + * + * @param pb the packbuilder + * @return the number of objects in the packfile + */ +GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb); + +/** + * Get the number of objects the packbuilder has already written out + * + * @param pb the packbuilder + * @return the number of objects which have already been written + */ +GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb); + +/** Packbuilder progress notification function */ +typedef int (*git_packbuilder_progress)( + int stage, + unsigned int current, + unsigned int total, + void *payload); + +/** + * Set the callbacks for a packbuilder + * + * @param pb The packbuilder object + * @param progress_cb Function to call with progress information during + * pack building. Be aware that this is called inline with pack building + * operations, so performance may be affected. + * @param progress_cb_payload Payload for progress callback. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_packbuilder_set_callbacks( + git_packbuilder *pb, + git_packbuilder_progress progress_cb, + void *progress_cb_payload); + +/** + * Free the packbuilder and all associated data + * + * @param pb The packbuilder + */ +GIT_EXTERN(void) git_packbuilder_free(git_packbuilder *pb); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/patch.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/patch.h new file mode 100644 index 000000000..790cb74fc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/patch.h @@ -0,0 +1,274 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_patch_h__ +#define INCLUDE_git_patch_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "diff.h" + +/** + * @file git2/patch.h + * @brief Patch handling routines. + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * The diff patch is used to store all the text diffs for a delta. + * + * You can easily loop over the content of patches and get information about + * them. + */ +typedef struct git_patch git_patch; + +/** + * Return a patch for an entry in the diff list. + * + * The `git_patch` is a newly created object contains the text diffs + * for the delta. You have to call `git_patch_free()` when you are + * done with it. You can use the patch object to loop over all the hunks + * and lines in the diff of the one delta. + * + * For an unchanged file or a binary file, no `git_patch` will be + * created, the output will be set to NULL, and the `binary` flag will be + * set true in the `git_diff_delta` structure. + * + * It is okay to pass NULL for either of the output parameters; if you pass + * NULL for the `git_patch`, then the text diff will not be calculated. + * + * @param out Output parameter for the delta patch object + * @param diff Diff list object + * @param idx Index into diff list + * @return 0 on success, other value < 0 on error + */ +GIT_EXTERN(int) git_patch_from_diff( + git_patch **out, git_diff *diff, size_t idx); + +/** + * Directly generate a patch from the difference between two blobs. + * + * This is just like `git_diff_blobs()` except it generates a patch object + * for the difference instead of directly making callbacks. You can use the + * standard `git_patch` accessor functions to read the patch data, and + * you must call `git_patch_free()` on the patch when done. + * + * @param out The generated patch; NULL on error + * @param old_blob Blob for old side of diff, or NULL for empty blob + * @param old_as_path Treat old blob as if it had this filename; can be NULL + * @param new_blob Blob for new side of diff, or NULL for empty blob + * @param new_as_path Treat new blob as if it had this filename; can be NULL + * @param opts Options for diff, or NULL for default options + * @return 0 on success or error code < 0 + */ +GIT_EXTERN(int) git_patch_from_blobs( + git_patch **out, + const git_blob *old_blob, + const char *old_as_path, + const git_blob *new_blob, + const char *new_as_path, + const git_diff_options *opts); + +/** + * Directly generate a patch from the difference between a blob and a buffer. + * + * This is just like `git_diff_blob_to_buffer()` except it generates a patch + * object for the difference instead of directly making callbacks. You can + * use the standard `git_patch` accessor functions to read the patch + * data, and you must call `git_patch_free()` on the patch when done. + * + * @param out The generated patch; NULL on error + * @param old_blob Blob for old side of diff, or NULL for empty blob + * @param old_as_path Treat old blob as if it had this filename; can be NULL + * @param buffer Raw data for new side of diff, or NULL for empty + * @param buffer_len Length of raw data for new side of diff + * @param buffer_as_path Treat buffer as if it had this filename; can be NULL + * @param opts Options for diff, or NULL for default options + * @return 0 on success or error code < 0 + */ +GIT_EXTERN(int) git_patch_from_blob_and_buffer( + git_patch **out, + const git_blob *old_blob, + const char *old_as_path, + const char *buffer, + size_t buffer_len, + const char *buffer_as_path, + const git_diff_options *opts); + +/** + * Directly generate a patch from the difference between two buffers. + * + * This is just like `git_diff_buffers()` except it generates a patch + * object for the difference instead of directly making callbacks. You can + * use the standard `git_patch` accessor functions to read the patch + * data, and you must call `git_patch_free()` on the patch when done. + * + * @param out The generated patch; NULL on error + * @param old_buffer Raw data for old side of diff, or NULL for empty + * @param old_len Length of the raw data for old side of the diff + * @param old_as_path Treat old buffer as if it had this filename; can be NULL + * @param new_buffer Raw data for new side of diff, or NULL for empty + * @param new_len Length of raw data for new side of diff + * @param new_as_path Treat buffer as if it had this filename; can be NULL + * @param opts Options for diff, or NULL for default options + * @return 0 on success or error code < 0 + */ +GIT_EXTERN(int) git_patch_from_buffers( + git_patch **out, + const void *old_buffer, + size_t old_len, + const char *old_as_path, + const char *new_buffer, + size_t new_len, + const char *new_as_path, + const git_diff_options *opts); + +/** + * Free a git_patch object. + */ +GIT_EXTERN(void) git_patch_free(git_patch *patch); + +/** + * Get the delta associated with a patch. This delta points to internal + * data and you do not have to release it when you are done with it. + */ +GIT_EXTERN(const git_diff_delta *) git_patch_get_delta(const git_patch *patch); + +/** + * Get the number of hunks in a patch + */ +GIT_EXTERN(size_t) git_patch_num_hunks(const git_patch *patch); + +/** + * Get line counts of each type in a patch. + * + * This helps imitate a diff --numstat type of output. For that purpose, + * you only need the `total_additions` and `total_deletions` values, but we + * include the `total_context` line count in case you want the total number + * of lines of diff output that will be generated. + * + * All outputs are optional. Pass NULL if you don't need a particular count. + * + * @param total_context Count of context lines in output, can be NULL. + * @param total_additions Count of addition lines in output, can be NULL. + * @param total_deletions Count of deletion lines in output, can be NULL. + * @param patch The git_patch object + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_patch_line_stats( + size_t *total_context, + size_t *total_additions, + size_t *total_deletions, + const git_patch *patch); + +/** + * Get the information about a hunk in a patch + * + * Given a patch and a hunk index into the patch, this returns detailed + * information about that hunk. Any of the output pointers can be passed + * as NULL if you don't care about that particular piece of information. + * + * @param out Output pointer to git_diff_hunk of hunk + * @param lines_in_hunk Output count of total lines in this hunk + * @param patch Input pointer to patch object + * @param hunk_idx Input index of hunk to get information about + * @return 0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error + */ +GIT_EXTERN(int) git_patch_get_hunk( + const git_diff_hunk **out, + size_t *lines_in_hunk, + git_patch *patch, + size_t hunk_idx); + +/** + * Get the number of lines in a hunk. + * + * @param patch The git_patch object + * @param hunk_idx Index of the hunk + * @return Number of lines in hunk or -1 if invalid hunk index + */ +GIT_EXTERN(int) git_patch_num_lines_in_hunk( + const git_patch *patch, + size_t hunk_idx); + +/** + * Get data about a line in a hunk of a patch. + * + * Given a patch, a hunk index, and a line index in the hunk, this + * will return a lot of details about that line. If you pass a hunk + * index larger than the number of hunks or a line index larger than + * the number of lines in the hunk, this will return -1. + * + * @param out The git_diff_line data for this line + * @param patch The patch to look in + * @param hunk_idx The index of the hunk + * @param line_of_hunk The index of the line in the hunk + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_patch_get_line_in_hunk( + const git_diff_line **out, + git_patch *patch, + size_t hunk_idx, + size_t line_of_hunk); + +/** + * Look up size of patch diff data in bytes + * + * This returns the raw size of the patch data. This only includes the + * actual data from the lines of the diff, not the file or hunk headers. + * + * If you pass `include_context` as true (non-zero), this will be the size + * of all of the diff output; if you pass it as false (zero), this will + * only include the actual changed lines (as if `context_lines` was 0). + * + * @param patch A git_patch representing changes to one file + * @param include_context Include context lines in size if non-zero + * @param include_hunk_headers Include hunk header lines if non-zero + * @param include_file_headers Include file header lines if non-zero + * @return The number of bytes of data + */ +GIT_EXTERN(size_t) git_patch_size( + git_patch *patch, + int include_context, + int include_hunk_headers, + int include_file_headers); + +/** + * Serialize the patch to text via callback. + * + * Returning a non-zero value from the callback will terminate the iteration + * and return that value to the caller. + * + * @param patch A git_patch representing changes to one file + * @param print_cb Callback function to output lines of the patch. Will be + * called for file headers, hunk headers, and diff lines. + * @param payload Reference pointer that will be passed to your callbacks. + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_patch_print( + git_patch *patch, + git_diff_line_cb print_cb, + void *payload); + +/** + * Get the content of a patch as a single diff text. + * + * @param out The git_buf to be filled in + * @param patch A git_patch representing changes to one file + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_patch_to_buf( + git_buf *out, + git_patch *patch); + +GIT_END_DECL + +/**@}*/ + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/pathspec.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/pathspec.h new file mode 100644 index 000000000..de6f027c5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/pathspec.h @@ -0,0 +1,263 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_pathspec_h__ +#define INCLUDE_git_pathspec_h__ + +#include "common.h" +#include "types.h" +#include "strarray.h" +#include "diff.h" + +GIT_BEGIN_DECL + +/** + * Compiled pathspec + */ +typedef struct git_pathspec git_pathspec; + +/** + * List of filenames matching a pathspec + */ +typedef struct git_pathspec_match_list git_pathspec_match_list; + +/** + * Options controlling how pathspec match should be executed + * + * - GIT_PATHSPEC_IGNORE_CASE forces match to ignore case; otherwise + * match will use native case sensitivity of platform filesystem + * - GIT_PATHSPEC_USE_CASE forces case sensitive match; otherwise + * match will use native case sensitivity of platform filesystem + * - GIT_PATHSPEC_NO_GLOB disables glob patterns and just uses simple + * string comparison for matching + * - GIT_PATHSPEC_NO_MATCH_ERROR means the match functions return error + * code GIT_ENOTFOUND if no matches are found; otherwise no matches is + * still success (return 0) but `git_pathspec_match_list_entrycount` + * will indicate 0 matches. + * - GIT_PATHSPEC_FIND_FAILURES means that the `git_pathspec_match_list` + * should track which patterns matched which files so that at the end of + * the match we can identify patterns that did not match any files. + * - GIT_PATHSPEC_FAILURES_ONLY means that the `git_pathspec_match_list` + * does not need to keep the actual matching filenames. Use this to + * just test if there were any matches at all or in combination with + * GIT_PATHSPEC_FIND_FAILURES to validate a pathspec. + */ +typedef enum { + GIT_PATHSPEC_DEFAULT = 0, + GIT_PATHSPEC_IGNORE_CASE = (1u << 0), + GIT_PATHSPEC_USE_CASE = (1u << 1), + GIT_PATHSPEC_NO_GLOB = (1u << 2), + GIT_PATHSPEC_NO_MATCH_ERROR = (1u << 3), + GIT_PATHSPEC_FIND_FAILURES = (1u << 4), + GIT_PATHSPEC_FAILURES_ONLY = (1u << 5), +} git_pathspec_flag_t; + +/** + * Compile a pathspec + * + * @param out Output of the compiled pathspec + * @param pathspec A git_strarray of the paths to match + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_pathspec_new( + git_pathspec **out, const git_strarray *pathspec); + +/** + * Free a pathspec + * + * @param ps The compiled pathspec + */ +GIT_EXTERN(void) git_pathspec_free(git_pathspec *ps); + +/** + * Try to match a path against a pathspec + * + * Unlike most of the other pathspec matching functions, this will not + * fall back on the native case-sensitivity for your platform. You must + * explicitly pass flags to control case sensitivity or else this will + * fall back on being case sensitive. + * + * @param ps The compiled pathspec + * @param flags Combination of git_pathspec_flag_t options to control match + * @param path The pathname to attempt to match + * @return 1 is path matches spec, 0 if it does not + */ +GIT_EXTERN(int) git_pathspec_matches_path( + const git_pathspec *ps, uint32_t flags, const char *path); + +/** + * Match a pathspec against the working directory of a repository. + * + * This matches the pathspec against the current files in the working + * directory of the repository. It is an error to invoke this on a bare + * repo. This handles git ignores (i.e. ignored files will not be + * considered to match the `pathspec` unless the file is tracked in the + * index). + * + * If `out` is not NULL, this returns a `git_patchspec_match_list`. That + * contains the list of all matched filenames (unless you pass the + * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of + * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` + * flag). You must call `git_pathspec_match_list_free()` on this object. + * + * @param out Output list of matches; pass NULL to just get return value + * @param repo The repository in which to match; bare repo is an error + * @param flags Combination of git_pathspec_flag_t options to control match + * @param ps Pathspec to be matched + * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and + * the GIT_PATHSPEC_NO_MATCH_ERROR flag was given + */ +GIT_EXTERN(int) git_pathspec_match_workdir( + git_pathspec_match_list **out, + git_repository *repo, + uint32_t flags, + git_pathspec *ps); + +/** + * Match a pathspec against entries in an index. + * + * This matches the pathspec against the files in the repository index. + * + * NOTE: At the moment, the case sensitivity of this match is controlled + * by the current case-sensitivity of the index object itself and the + * USE_CASE and IGNORE_CASE flags will have no effect. This behavior will + * be corrected in a future release. + * + * If `out` is not NULL, this returns a `git_patchspec_match_list`. That + * contains the list of all matched filenames (unless you pass the + * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of + * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` + * flag). You must call `git_pathspec_match_list_free()` on this object. + * + * @param out Output list of matches; pass NULL to just get return value + * @param index The index to match against + * @param flags Combination of git_pathspec_flag_t options to control match + * @param ps Pathspec to be matched + * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and + * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used + */ +GIT_EXTERN(int) git_pathspec_match_index( + git_pathspec_match_list **out, + git_index *index, + uint32_t flags, + git_pathspec *ps); + +/** + * Match a pathspec against files in a tree. + * + * This matches the pathspec against the files in the given tree. + * + * If `out` is not NULL, this returns a `git_patchspec_match_list`. That + * contains the list of all matched filenames (unless you pass the + * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of + * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` + * flag). You must call `git_pathspec_match_list_free()` on this object. + * + * @param out Output list of matches; pass NULL to just get return value + * @param tree The root-level tree to match against + * @param flags Combination of git_pathspec_flag_t options to control match + * @param ps Pathspec to be matched + * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and + * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used + */ +GIT_EXTERN(int) git_pathspec_match_tree( + git_pathspec_match_list **out, + git_tree *tree, + uint32_t flags, + git_pathspec *ps); + +/** + * Match a pathspec against files in a diff list. + * + * This matches the pathspec against the files in the given diff list. + * + * If `out` is not NULL, this returns a `git_patchspec_match_list`. That + * contains the list of all matched filenames (unless you pass the + * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of + * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` + * flag). You must call `git_pathspec_match_list_free()` on this object. + * + * @param out Output list of matches; pass NULL to just get return value + * @param diff A generated diff list + * @param flags Combination of git_pathspec_flag_t options to control match + * @param ps Pathspec to be matched + * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and + * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used + */ +GIT_EXTERN(int) git_pathspec_match_diff( + git_pathspec_match_list **out, + git_diff *diff, + uint32_t flags, + git_pathspec *ps); + +/** + * Free memory associates with a git_pathspec_match_list + * + * @param m The git_pathspec_match_list to be freed + */ +GIT_EXTERN(void) git_pathspec_match_list_free(git_pathspec_match_list *m); + +/** + * Get the number of items in a match list. + * + * @param m The git_pathspec_match_list object + * @return Number of items in match list + */ +GIT_EXTERN(size_t) git_pathspec_match_list_entrycount( + const git_pathspec_match_list *m); + +/** + * Get a matching filename by position. + * + * This routine cannot be used if the match list was generated by + * `git_pathspec_match_diff`. If so, it will always return NULL. + * + * @param m The git_pathspec_match_list object + * @param pos The index into the list + * @return The filename of the match + */ +GIT_EXTERN(const char *) git_pathspec_match_list_entry( + const git_pathspec_match_list *m, size_t pos); + +/** + * Get a matching diff delta by position. + * + * This routine can only be used if the match list was generated by + * `git_pathspec_match_diff`. Otherwise it will always return NULL. + * + * @param m The git_pathspec_match_list object + * @param pos The index into the list + * @return The filename of the match + */ +GIT_EXTERN(const git_diff_delta *) git_pathspec_match_list_diff_entry( + const git_pathspec_match_list *m, size_t pos); + +/** + * Get the number of pathspec items that did not match. + * + * This will be zero unless you passed GIT_PATHSPEC_FIND_FAILURES when + * generating the git_pathspec_match_list. + * + * @param m The git_pathspec_match_list object + * @return Number of items in original pathspec that had no matches + */ +GIT_EXTERN(size_t) git_pathspec_match_list_failed_entrycount( + const git_pathspec_match_list *m); + +/** + * Get an original pathspec string that had no matches. + * + * This will be return NULL for positions out of range. + * + * @param m The git_pathspec_match_list object + * @param pos The index into the failed items + * @return The pathspec pattern that didn't match anything + */ +GIT_EXTERN(const char *) git_pathspec_match_list_failed_entry( + const git_pathspec_match_list *m, size_t pos); + +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/push.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/push.h new file mode 100644 index 000000000..ecabff397 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/push.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_push_h__ +#define INCLUDE_git_push_h__ + +#include "common.h" +#include "pack.h" + +/** + * @file git2/push.h + * @brief Git push management functions + * @defgroup git_push push management functions + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Controls the behavior of a git_push object. + */ +typedef struct { + unsigned int version; + + /** + * If the transport being used to push to the remote requires the creation + * of a pack file, this controls the number of worker threads used by + * the packbuilder when creating that pack file to be sent to the remote. + * + * If set to 0, the packbuilder will auto-detect the number of threads + * to create. The default value is 1. + */ + unsigned int pb_parallelism; +} git_push_options; + +#define GIT_PUSH_OPTIONS_VERSION 1 +#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION } + +/** + * Initializes a `git_push_options` with default values. Equivalent to + * creating an instance with GIT_PUSH_OPTIONS_INIT. + * + * @param opts the `git_push_options` instance to initialize. + * @param version the version of the struct; you should pass + * `GIT_PUSH_OPTIONS_VERSION` here. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_push_init_options( + git_push_options *opts, + unsigned int version); + +/** Push network progress notification function */ +typedef int (*git_push_transfer_progress)( + unsigned int current, + unsigned int total, + size_t bytes, + void* payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/rebase.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/rebase.h new file mode 100644 index 000000000..58b66b7fa --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/rebase.h @@ -0,0 +1,270 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_rebase_h__ +#define INCLUDE_git_rebase_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "annotated_commit.h" + +/** + * @file git2/rebase.h + * @brief Git rebase routines + * @defgroup git_rebase Git merge routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Rebase options + * + * Use to tell the rebase machinery how to operate. + */ +typedef struct { + unsigned int version; + + /** + * Provide a quiet rebase experience; unused by libgit2 but provided for + * interoperability with other clients. + */ + int quiet; + + /** + * Canonical name of the notes reference used to rewrite notes for + * rebased commits when finishing the rebase; if NULL, the contents of + * the coniguration option `notes.rewriteRef` is examined, unless the + * configuration option `notes.rewrite.rebase` is set to false. If + * `notes.rewriteRef` is NULL, notes will not be rewritten. + */ + const char *rewrite_notes_ref; +} git_rebase_options; + +/** + * Type of rebase operation in-progress after calling `git_rebase_next`. + */ +typedef enum { + /** + * The given commit is to be cherry-picked. The client should commit + * the changes and continue if there are no conflicts. + */ + GIT_REBASE_OPERATION_PICK = 0, + + /** + * The given commit is to be cherry-picked, but the client should prompt + * the user to provide an updated commit message. + */ + GIT_REBASE_OPERATION_REWORD, + + /** + * The given commit is to be cherry-picked, but the client should stop + * to allow the user to edit the changes before committing them. + */ + GIT_REBASE_OPERATION_EDIT, + + /** + * The given commit is to be squashed into the previous commit. The + * commit message will be merged with the previous message. + */ + GIT_REBASE_OPERATION_SQUASH, + + /** + * The given commit is to be squashed into the previous commit. The + * commit message from this commit will be discarded. + */ + GIT_REBASE_OPERATION_FIXUP, + + /** + * No commit will be cherry-picked. The client should run the given + * command and (if successful) continue. + */ + GIT_REBASE_OPERATION_EXEC, +} git_rebase_operation_t; + +#define GIT_REBASE_OPTIONS_VERSION 1 +#define GIT_REBASE_OPTIONS_INIT {GIT_REBASE_OPTIONS_VERSION} + +/** + * A rebase operation + * + * Describes a single instruction/operation to be performed during the + * rebase. + */ +typedef struct { + /** The type of rebase operation. */ + git_rebase_operation_t type; + + /** + * The commit ID being cherry-picked. This will be populated for + * all operations except those of type `GIT_REBASE_OPERATION_EXEC`. + */ + const git_oid id; + + /** + * The executable the user has requested be run. This will only + * be populated for operations of type `GIT_REBASE_OPERATION_EXEC`. + */ + const char *exec; +} git_rebase_operation; + +/** + * Initializes a `git_rebase_options` with default values. Equivalent to + * creating an instance with GIT_REBASE_OPTIONS_INIT. + * + * @param opts the `git_rebase_options` instance to initialize. + * @param version the version of the struct; you should pass + * `GIT_REBASE_OPTIONS_VERSION` here. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_rebase_init_options( + git_rebase_options *opts, + unsigned int version); + +/** + * Initializes a rebase operation to rebase the changes in `branch` + * relative to `upstream` onto another branch. To begin the rebase + * process, call `git_rebase_next`. When you have finished with this + * object, call `git_rebase_free`. + * + * @param out Pointer to store the rebase object + * @param repo The repository to perform the rebase + * @param branch The terminal commit to rebase, or NULL to rebase the + * current branch + * @param upstream The commit to begin rebasing from, or NULL to rebase all + * reachable commits + * @param onto The branch to rebase onto, or NULL to rebase onto the given + * upstream + * @param opts Options to specify how rebase is performed + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_rebase_init( + git_rebase **out, + git_repository *repo, + const git_annotated_commit *branch, + const git_annotated_commit *upstream, + const git_annotated_commit *onto, + const git_rebase_options *opts); + +/** + * Opens an existing rebase that was previously started by either an + * invocation of `git_rebase_init` or by another client. + * + * @param out Pointer to store the rebase object + * @param repo The repository that has a rebase in-progress + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_rebase_open(git_rebase **out, git_repository *repo); + +/** + * Gets the count of rebase operations that are to be applied. + * + * @param rebase The in-progress rebase + * @return The number of rebase operations in total + */ +GIT_EXTERN(size_t) git_rebase_operation_entrycount(git_rebase *rebase); + +/** + * Gets the index of the rebase operation that is currently being applied. + * + * @param rebase The in-progress rebase + * @return The index of the rebase operation currently being applied. + */ +GIT_EXTERN(size_t) git_rebase_operation_current(git_rebase *rebase); + +/** + * Gets the rebase operation specified by the given index. + * + * @param rebase The in-progress rebase + * @param idx The index of the rebase operation to retrieve + * @return The rebase operation or NULL if `idx` was out of bounds + */ +GIT_EXTERN(git_rebase_operation *) git_rebase_operation_byindex( + git_rebase *rebase, + size_t idx); + +/** + * Performs the next rebase operation and returns the information about it. + * If the operation is one that applies a patch (which is any operation except + * GIT_REBASE_OPERATION_EXEC) then the patch will be applied and the index and + * working directory will be updated with the changes. If there are conflicts, + * you will need to address those before committing the changes. + * + * @param operation Pointer to store the rebase operation that is to be performed next + * @param rebase The rebase in progress + * @param checkout_opts Options to specify how the patch should be checked out + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_rebase_next( + git_rebase_operation **operation, + git_rebase *rebase, + git_checkout_options *checkout_opts); + +/** + * Commits the current patch. You must have resolved any conflicts that + * were introduced during the patch application from the `git_rebase_next` + * invocation. + * + * @param id Pointer in which to store the OID of the newly created commit + * @param rebase The rebase that is in-progress + * @param author The author of the updated commit, or NULL to keep the + * author from the original commit + * @param committer The committer of the rebase + * @param message_encoding The encoding for the message in the commit, + * represented with a standard encoding name. If message is NULL, + * this should also be NULL, and the encoding from the original + * commit will be maintained. If message is specified, this may be + * NULL to indicate that "UTF-8" is to be used. + * @param message The message for this commit, or NULL to use the message + * from the original commit. + * @return Zero on success, GIT_EUNMERGED if there are unmerged changes in + * the index, GIT_EAPPLIED if the current commit has already + * been applied to the upstream and there is nothing to commit, + * -1 on failure. + */ +GIT_EXTERN(int) git_rebase_commit( + git_oid *id, + git_rebase *rebase, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message); + +/** + * Aborts a rebase that is currently in progress, resetting the repository + * and working directory to their state before rebase began. + * + * @param rebase The rebase that is in-progress + * @return Zero on success; GIT_ENOTFOUND if a rebase is not in progress, + * -1 on other errors. + */ +GIT_EXTERN(int) git_rebase_abort(git_rebase *rebase); + +/** + * Finishes a rebase that is currently in progress once all patches have + * been applied. + * + * @param rebase The rebase that is in-progress + * @param signature The identity that is finishing the rebase (optional) + * @param opts Options to specify how rebase is finished + * @return Zero on success; -1 on error + */ +GIT_EXTERN(int) git_rebase_finish( + git_rebase *rebase, + const git_signature *signature, + const git_rebase_options *opts); + +/** + * Frees the `git_rebase` object. + * + * @param rebase The rebase object + */ +GIT_EXTERN(void) git_rebase_free(git_rebase *rebase); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/refdb.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/refdb.h new file mode 100644 index 000000000..a315876ae --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/refdb.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_refdb_h__ +#define INCLUDE_git_refdb_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "refs.h" + +/** + * @file git2/refdb.h + * @brief Git custom refs backend functions + * @defgroup git_refdb Git custom refs backend API + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new reference database with no backends. + * + * Before the Ref DB can be used for read/writing, a custom database + * backend must be manually set using `git_refdb_set_backend()` + * + * @param out location to store the database pointer, if opened. + * Set to NULL if the open failed. + * @param repo the repository + * @return 0 or an error code + */ +GIT_EXTERN(int) git_refdb_new(git_refdb **out, git_repository *repo); + +/** + * Create a new reference database and automatically add + * the default backends: + * + * - git_refdb_dir: read and write loose and packed refs + * from disk, assuming the repository dir as the folder + * + * @param out location to store the database pointer, if opened. + * Set to NULL if the open failed. + * @param repo the repository + * @return 0 or an error code + */ +GIT_EXTERN(int) git_refdb_open(git_refdb **out, git_repository *repo); + +/** + * Suggests that the given refdb compress or optimize its references. + * This mechanism is implementation specific. For on-disk reference + * databases, for example, this may pack all loose references. + */ +GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb); + +/** + * Close an open reference database. + * + * @param refdb reference database pointer or NULL + */ +GIT_EXTERN(void) git_refdb_free(git_refdb *refdb); + +/** @} */ +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/reflog.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/reflog.h new file mode 100644 index 000000000..c949a28f0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/reflog.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_reflog_h__ +#define INCLUDE_git_reflog_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" + +/** + * @file git2/reflog.h + * @brief Git reflog management routines + * @defgroup git_reflog Git reflog management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Read the reflog for the given reference + * + * If there is no reflog file for the given + * reference yet, an empty reflog object will + * be returned. + * + * The reflog must be freed manually by using + * git_reflog_free(). + * + * @param out pointer to reflog + * @param repo the repostiory + * @param name reference to look up + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reflog_read(git_reflog **out, git_repository *repo, const char *name); + +/** + * Write an existing in-memory reflog object back to disk + * using an atomic file lock. + * + * @param reflog an existing reflog object + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reflog_write(git_reflog *reflog); + +/** + * Add a new entry to the in-memory reflog. + * + * `msg` is optional and can be NULL. + * + * @param reflog an existing reflog object + * @param id the OID the reference is now pointing to + * @param committer the signature of the committer + * @param msg the reflog message + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *id, const git_signature *committer, const char *msg); + +/** + * Rename a reflog + * + * The reflog to be renamed is expected to already exist + * + * The new name will be checked for validity. + * See `git_reference_create_symbolic()` for rules about valid names. + * + * @param repo the repository + * @param old_name the old name of the reference + * @param name the new name of the reference + * @return 0 on success, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_reflog_rename(git_repository *repo, const char *old_name, const char *name); + +/** + * Delete the reflog for the given reference + * + * @param repo the repository + * @param name the reflog to delete + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reflog_delete(git_repository *repo, const char *name); + +/** + * Get the number of log entries in a reflog + * + * @param reflog the previously loaded reflog + * @return the number of log entries + */ +GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog *reflog); + +/** + * Lookup an entry by its index + * + * Requesting the reflog entry with an index of 0 (zero) will + * return the most recently created entry. + * + * @param reflog a previously loaded reflog + * @param idx the position of the entry to lookup. Should be greater than or + * equal to 0 (zero) and less than `git_reflog_entrycount()`. + * @return the entry; NULL if not found + */ +GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(const git_reflog *reflog, size_t idx); + +/** + * Remove an entry from the reflog by its index + * + * To ensure there's no gap in the log history, set `rewrite_previous_entry` + * param value to 1. When deleting entry `n`, member old_oid of entry `n-1` + * (if any) will be updated with the value of member new_oid of entry `n+1`. + * + * @param reflog a previously loaded reflog. + * + * @param idx the position of the entry to remove. Should be greater than or + * equal to 0 (zero) and less than `git_reflog_entrycount()`. + * + * @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise. + * + * @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist + * or an error code. + */ +GIT_EXTERN(int) git_reflog_drop( + git_reflog *reflog, + size_t idx, + int rewrite_previous_entry); + +/** + * Get the old oid + * + * @param entry a reflog entry + * @return the old oid + */ +GIT_EXTERN(const git_oid *) git_reflog_entry_id_old(const git_reflog_entry *entry); + +/** + * Get the new oid + * + * @param entry a reflog entry + * @return the new oid at this time + */ +GIT_EXTERN(const git_oid *) git_reflog_entry_id_new(const git_reflog_entry *entry); + +/** + * Get the committer of this entry + * + * @param entry a reflog entry + * @return the committer + */ +GIT_EXTERN(const git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry); + +/** + * Get the log message + * + * @param entry a reflog entry + * @return the log msg + */ +GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry *entry); + +/** + * Free the reflog + * + * @param reflog reflog to free + */ +GIT_EXTERN(void) git_reflog_free(git_reflog *reflog); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/refs.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/refs.h new file mode 100644 index 000000000..db84ed03a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/refs.h @@ -0,0 +1,735 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_refs_h__ +#define INCLUDE_git_refs_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "strarray.h" + +/** + * @file git2/refs.h + * @brief Git reference management routines + * @defgroup git_reference Git reference management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Lookup a reference by name in a repository. + * + * The returned reference must be freed by the user. + * + * The name will be checked for validity. + * See `git_reference_symbolic_create()` for rules about valid names. + * + * @param out pointer to the looked-up reference + * @param repo the repository to look up the reference + * @param name the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...) + * @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code. + */ +GIT_EXTERN(int) git_reference_lookup(git_reference **out, git_repository *repo, const char *name); + +/** + * Lookup a reference by name and resolve immediately to OID. + * + * This function provides a quick way to resolve a reference name straight + * through to the object id that it refers to. This avoids having to + * allocate or free any `git_reference` objects for simple situations. + * + * The name will be checked for validity. + * See `git_reference_symbolic_create()` for rules about valid names. + * + * @param out Pointer to oid to be filled in + * @param repo The repository in which to look up the reference + * @param name The long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...) + * @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code. + */ +GIT_EXTERN(int) git_reference_name_to_id( + git_oid *out, git_repository *repo, const char *name); + +/** + * Lookup a reference by DWIMing its short name + * + * Apply the git precendence rules to the given shorthand to determine + * which reference the user is referring to. + * + * @param out pointer in which to store the reference + * @param repo the repository in which to look + * @param shorthand the short name for the reference + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, const char *shorthand); + +/** + * Conditionally create a new symbolic reference. + * + * A symbolic reference is a reference name that refers to another + * reference name. If the other name moves, the symbolic name will move, + * too. As a simple example, the "HEAD" reference might refer to + * "refs/heads/master" while on the "master" branch of a repository. + * + * The symbolic reference will be created in the repository and written to + * the disk. The generated reference object must be freed by the user. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * This function will return an error if a reference already exists with the + * given name unless `force` is true, in which case it will be overwritten. + * + * The message for the reflog will be ignored if the reference does + * not belong in the standard set (HEAD, branches and remote-tracking + * branches) and it does not have a reflog. + * + * It will return GIT_EMODIFIED if the reference's value at the time + * of updating does not match the one passed through `current_value` + * (i.e. if the ref has changed since the user read it). + * + * @param out Pointer to the newly created reference + * @param repo Repository where that reference will live + * @param name The name of the reference + * @param target The target of the reference + * @param force Overwrite existing references + * @param current_value The expected value of the reference when updating + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC, GIT_EMODIFIED or an error code + */ +GIT_EXTERN(int) git_reference_symbolic_create_matching(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *current_value, const char *log_message); + +/** + * Create a new symbolic reference. + * + * A symbolic reference is a reference name that refers to another + * reference name. If the other name moves, the symbolic name will move, + * too. As a simple example, the "HEAD" reference might refer to + * "refs/heads/master" while on the "master" branch of a repository. + * + * The symbolic reference will be created in the repository and written to + * the disk. The generated reference object must be freed by the user. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * This function will return an error if a reference already exists with the + * given name unless `force` is true, in which case it will be overwritten. + * + * The message for the reflog will be ignored if the reference does + * not belong in the standard set (HEAD, branches and remote-tracking + * branches) and it does not have a reflog. + * + * @param out Pointer to the newly created reference + * @param repo Repository where that reference will live + * @param name The name of the reference + * @param target The target of the reference + * @param force Overwrite existing references + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *log_message); + +/** + * Create a new direct reference. + * + * A direct reference (also called an object id reference) refers directly + * to a specific object id (a.k.a. OID or SHA) in the repository. The id + * permanently refers to the object (although the reference itself can be + * moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0" + * refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977. + * + * The direct reference will be created in the repository and written to + * the disk. The generated reference object must be freed by the user. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * This function will return an error if a reference already exists with the + * given name unless `force` is true, in which case it will be overwritten. + * + * The message for the reflog will be ignored if the reference does + * not belong in the standard set (HEAD, branches and remote-tracking + * branches) and and it does not have a reflog. + * + * @param out Pointer to the newly created reference + * @param repo Repository where that reference will live + * @param name The name of the reference + * @param id The object id pointed to by the reference. + * @param force Overwrite existing references + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const char *log_message); + +/** + * Conditionally create new direct reference + * + * A direct reference (also called an object id reference) refers directly + * to a specific object id (a.k.a. OID or SHA) in the repository. The id + * permanently refers to the object (although the reference itself can be + * moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0" + * refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977. + * + * The direct reference will be created in the repository and written to + * the disk. The generated reference object must be freed by the user. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * This function will return an error if a reference already exists with the + * given name unless `force` is true, in which case it will be overwritten. + * + * The message for the reflog will be ignored if the reference does + * not belong in the standard set (HEAD, branches and remote-tracking + * branches) and and it does not have a reflog. + * + * It will return GIT_EMODIFIED if the reference's value at the time + * of updating does not match the one passed through `current_id` + * (i.e. if the ref has changed since the user read it). + * + * @param out Pointer to the newly created reference + * @param repo Repository where that reference will live + * @param name The name of the reference + * @param id The object id pointed to by the reference. + * @param force Overwrite existing references + * @param current_id The expected value of the reference at the time of update + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EMODIFIED if the value of the reference + * has changed, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_reference_create_matching(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const git_oid *current_id, const char *log_message); + +/** + * Get the OID pointed to by a direct reference. + * + * Only available if the reference is direct (i.e. an object id reference, + * not a symbolic one). + * + * To find the OID of a symbolic ref, call `git_reference_resolve()` and + * then this function (or maybe use `git_reference_name_to_id()` to + * directly resolve a reference name all the way through to an OID). + * + * @param ref The reference + * @return a pointer to the oid if available, NULL otherwise + */ +GIT_EXTERN(const git_oid *) git_reference_target(const git_reference *ref); + +/** + * Return the peeled OID target of this reference. + * + * This peeled OID only applies to direct references that point to + * a hard Tag object: it is the result of peeling such Tag. + * + * @param ref The reference + * @return a pointer to the oid if available, NULL otherwise + */ +GIT_EXTERN(const git_oid *) git_reference_target_peel(const git_reference *ref); + +/** + * Get full name to the reference pointed to by a symbolic reference. + * + * Only available if the reference is symbolic. + * + * @param ref The reference + * @return a pointer to the name if available, NULL otherwise + */ +GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference *ref); + +/** + * Get the type of a reference. + * + * Either direct (GIT_REF_OID) or symbolic (GIT_REF_SYMBOLIC) + * + * @param ref The reference + * @return the type + */ +GIT_EXTERN(git_ref_t) git_reference_type(const git_reference *ref); + +/** + * Get the full name of a reference. + * + * See `git_reference_symbolic_create()` for rules about valid names. + * + * @param ref The reference + * @return the full name for the ref + */ +GIT_EXTERN(const char *) git_reference_name(const git_reference *ref); + +/** + * Resolve a symbolic reference to a direct reference. + * + * This method iteratively peels a symbolic reference until it resolves to + * a direct reference to an OID. + * + * The peeled reference is returned in the `resolved_ref` argument, and + * must be freed manually once it's no longer needed. + * + * If a direct reference is passed as an argument, a copy of that + * reference is returned. This copy must be manually freed too. + * + * @param out Pointer to the peeled reference + * @param ref The reference + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reference_resolve(git_reference **out, const git_reference *ref); + +/** + * Get the repository where a reference resides. + * + * @param ref The reference + * @return a pointer to the repo + */ +GIT_EXTERN(git_repository *) git_reference_owner(const git_reference *ref); + +/** + * Create a new reference with the same name as the given reference but a + * different symbolic target. The reference must be a symbolic reference, + * otherwise this will fail. + * + * The new reference will be written to disk, overwriting the given reference. + * + * The target name will be checked for validity. + * See `git_reference_symbolic_create()` for rules about valid names. + * + * The message for the reflog will be ignored if the reference does + * not belong in the standard set (HEAD, branches and remote-tracking + * branches) and and it does not have a reflog. + * + * @param out Pointer to the newly created reference + * @param ref The reference + * @param target The new target for the reference + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_reference_symbolic_set_target( + git_reference **out, + git_reference *ref, + const char *target, + const char *log_message); + +/** + * Conditionally create a new reference with the same name as the given reference but a + * different OID target. The reference must be a direct reference, otherwise + * this will fail. + * + * The new reference will be written to disk, overwriting the given reference. + * + * @param out Pointer to the newly created reference + * @param ref The reference + * @param id The new target OID for the reference + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EMODIFIED if the value of the reference + * has changed since it was read, or an error code + */ +GIT_EXTERN(int) git_reference_set_target( + git_reference **out, + git_reference *ref, + const git_oid *id, + const char *log_message); + +/** + * Rename an existing reference. + * + * This method works for both direct and symbolic references. + * + * The new name will be checked for validity. + * See `git_reference_symbolic_create()` for rules about valid names. + * + * If the `force` flag is not enabled, and there's already + * a reference with the given name, the renaming will fail. + * + * IMPORTANT: + * The user needs to write a proper reflog entry if the + * reflog is enabled for the repository. We only rename + * the reflog if it exists. + * + * @param ref The reference to rename + * @param new_name The new name for the reference + * @param force Overwrite an existing reference + * @param log_message The one line long message to be appended to the reflog + * @return 0 on success, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code + * + */ +GIT_EXTERN(int) git_reference_rename( + git_reference **new_ref, + git_reference *ref, + const char *new_name, + int force, + const char *log_message); + +/** + * Delete an existing reference. + * + * This method works for both direct and symbolic references. The reference + * will be immediately removed on disk but the memory will not be freed. + * Callers must call `git_reference_free`. + * + * This function will return an error if the reference has changed + * from the time it was looked up. + * + * @param ref The reference to remove + * @return 0, GIT_EMODIFIED or an error code + */ +GIT_EXTERN(int) git_reference_delete(git_reference *ref); + +/** + * Delete an existing reference by name + * + * This method removes the named reference from the repository without + * looking at its old value. + * + * @param name The reference to remove + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reference_remove(git_repository *repo, const char *name); + +/** + * Fill a list with all the references that can be found in a repository. + * + * The string array will be filled with the names of all references; these + * values are owned by the user and should be free'd manually when no + * longer needed, using `git_strarray_free()`. + * + * @param array Pointer to a git_strarray structure where + * the reference names will be stored + * @param repo Repository where to find the refs + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo); + +typedef int (*git_reference_foreach_cb)(git_reference *reference, void *payload); +typedef int (*git_reference_foreach_name_cb)(const char *name, void *payload); + +/** + * Perform a callback on each reference in the repository. + * + * The `callback` function will be called for each reference in the + * repository, receiving the reference object and the `payload` value + * passed to this method. Returning a non-zero value from the callback + * will terminate the iteration. + * + * @param repo Repository where to find the refs + * @param callback Function which will be called for every listed ref + * @param payload Additional data to pass to the callback + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_reference_foreach( + git_repository *repo, + git_reference_foreach_cb callback, + void *payload); + +/** + * Perform a callback on the fully-qualified name of each reference. + * + * The `callback` function will be called for each reference in the + * repository, receiving the name of the reference and the `payload` value + * passed to this method. Returning a non-zero value from the callback + * will terminate the iteration. + * + * @param repo Repository where to find the refs + * @param callback Function which will be called for every listed ref name + * @param payload Additional data to pass to the callback + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_reference_foreach_name( + git_repository *repo, + git_reference_foreach_name_cb callback, + void *payload); + +/** + * Free the given reference. + * + * @param ref git_reference + */ +GIT_EXTERN(void) git_reference_free(git_reference *ref); + +/** + * Compare two references. + * + * @param ref1 The first git_reference + * @param ref2 The second git_reference + * @return 0 if the same, else a stable but meaningless ordering. + */ +GIT_EXTERN(int) git_reference_cmp( + const git_reference *ref1, + const git_reference *ref2); + +/** + * Create an iterator for the repo's references + * + * @param out pointer in which to store the iterator + * @param repo the repository + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reference_iterator_new( + git_reference_iterator **out, + git_repository *repo); + +/** + * Create an iterator for the repo's references that match the + * specified glob + * + * @param out pointer in which to store the iterator + * @param repo the repository + * @param glob the glob to match against the reference names + * @return 0 or an error code + */ +GIT_EXTERN(int) git_reference_iterator_glob_new( + git_reference_iterator **out, + git_repository *repo, + const char *glob); + +/** + * Get the next reference + * + * @param out pointer in which to store the reference + * @param iter the iterator + * @return 0, GIT_ITEROVER if there are no more; or an error code + */ +GIT_EXTERN(int) git_reference_next(git_reference **out, git_reference_iterator *iter); + +/** + * Get the next reference's name + * + * This function is provided for convenience in case only the names + * are interesting as it avoids the allocation of the `git_reference` + * object which `git_reference_next()` needs. + * + * @param out pointer in which to store the string + * @param iter the iterator + * @return 0, GIT_ITEROVER if there are no more; or an error code + */ +GIT_EXTERN(int) git_reference_next_name(const char **out, git_reference_iterator *iter); + +/** + * Free the iterator and its associated resources + * + * @param iter the iterator to free + */ +GIT_EXTERN(void) git_reference_iterator_free(git_reference_iterator *iter); + +/** + * Perform a callback on each reference in the repository whose name + * matches the given pattern. + * + * This function acts like `git_reference_foreach()` with an additional + * pattern match being applied to the reference name before issuing the + * callback function. See that function for more information. + * + * The pattern is matched using fnmatch or "glob" style where a '*' matches + * any sequence of letters, a '?' matches any letter, and square brackets + * can be used to define character ranges (such as "[0-9]" for digits). + * + * @param repo Repository where to find the refs + * @param glob Pattern to match (fnmatch-style) against reference name. + * @param callback Function which will be called for every listed ref + * @param payload Additional data to pass to the callback + * @return 0 on success, GIT_EUSER on non-zero callback, or error code + */ +GIT_EXTERN(int) git_reference_foreach_glob( + git_repository *repo, + const char *glob, + git_reference_foreach_name_cb callback, + void *payload); + +/** + * Check if a reflog exists for the specified reference. + * + * @param repo the repository + * @param refname the reference's name + * @return 0 when no reflog can be found, 1 when it exists; + * otherwise an error code. + */ +GIT_EXTERN(int) git_reference_has_log(git_repository *repo, const char *refname); + +/** + * Ensure there is a reflog for a particular reference. + * + * Make sure that successive updates to the reference will append to + * its log. + * + * @param repo the repository + * @param refname the reference's name + * @return 0 or an error code. + */ +GIT_EXTERN(int) git_reference_ensure_log(git_repository *repo, const char *refname); + +/** + * Check if a reference is a local branch. + * + * @param ref A git reference + * + * @return 1 when the reference lives in the refs/heads + * namespace; 0 otherwise. + */ +GIT_EXTERN(int) git_reference_is_branch(const git_reference *ref); + +/** + * Check if a reference is a remote tracking branch + * + * @param ref A git reference + * + * @return 1 when the reference lives in the refs/remotes + * namespace; 0 otherwise. + */ +GIT_EXTERN(int) git_reference_is_remote(const git_reference *ref); + +/** + * Check if a reference is a tag + * + * @param ref A git reference + * + * @return 1 when the reference lives in the refs/tags + * namespace; 0 otherwise. + */ +GIT_EXTERN(int) git_reference_is_tag(const git_reference *ref); + +/** + * Check if a reference is a note + * + * @param ref A git reference + * + * @return 1 when the reference lives in the refs/notes + * namespace; 0 otherwise. + */ +GIT_EXTERN(int) git_reference_is_note(const git_reference *ref); + +/** + * Normalization options for reference lookup + */ +typedef enum { + /** + * No particular normalization. + */ + GIT_REF_FORMAT_NORMAL = 0u, + + /** + * Control whether one-level refnames are accepted + * (i.e., refnames that do not contain multiple /-separated + * components). Those are expected to be written only using + * uppercase letters and underscore (FETCH_HEAD, ...) + */ + GIT_REF_FORMAT_ALLOW_ONELEVEL = (1u << 0), + + /** + * Interpret the provided name as a reference pattern for a + * refspec (as used with remote repositories). If this option + * is enabled, the name is allowed to contain a single * () + * in place of a one full pathname component + * (e.g., foo//bar but not foo/bar). + */ + GIT_REF_FORMAT_REFSPEC_PATTERN = (1u << 1), + + /** + * Interpret the name as part of a refspec in shorthand form + * so the `ONELEVEL` naming rules aren't enforced and 'master' + * becomes a valid name. + */ + GIT_REF_FORMAT_REFSPEC_SHORTHAND = (1u << 2), +} git_reference_normalize_t; + +/** + * Normalize reference name and check validity. + * + * This will normalize the reference name by removing any leading slash + * '/' characters and collapsing runs of adjacent slashes between name + * components into a single slash. + * + * Once normalized, if the reference name is valid, it will be returned in + * the user allocated buffer. + * + * See `git_reference_symbolic_create()` for rules about valid names. + * + * @param buffer_out User allocated buffer to store normalized name + * @param buffer_size Size of buffer_out + * @param name Reference name to be checked. + * @param flags Flags to constrain name validation rules - see the + * GIT_REF_FORMAT constants above. + * @return 0 on success, GIT_EBUFS if buffer is too small, GIT_EINVALIDSPEC + * or an error code. + */ +GIT_EXTERN(int) git_reference_normalize_name( + char *buffer_out, + size_t buffer_size, + const char *name, + unsigned int flags); + +/** + * Recursively peel reference until object of the specified type is found. + * + * The retrieved `peeled` object is owned by the repository + * and should be closed with the `git_object_free` method. + * + * If you pass `GIT_OBJ_ANY` as the target type, then the object + * will be peeled until a non-tag object is met. + * + * @param out Pointer to the peeled git_object + * @param ref The reference to be processed + * @param type The type of the requested object (GIT_OBJ_COMMIT, + * GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY). + * @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code + */ +GIT_EXTERN(int) git_reference_peel( + git_object **out, + git_reference *ref, + git_otype type); + +/** + * Ensure the reference name is well-formed. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * @param refname name to be checked. + * @return 1 if the reference name is acceptable; 0 if it isn't + */ +GIT_EXTERN(int) git_reference_is_valid_name(const char *refname); + +/** + * Get the reference's short name + * + * This will transform the reference name into a name "human-readable" + * version. If no shortname is appropriate, it will return the full + * name. + * + * The memory is owned by the reference and must not be freed. + * + * @param ref a reference + * @return the human-readable version of the name + */ +GIT_EXTERN(const char *) git_reference_shorthand(const git_reference *ref); + + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/refspec.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/refspec.h new file mode 100644 index 000000000..9acdc72d5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/refspec.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_refspec_h__ +#define INCLUDE_git_refspec_h__ + +#include "common.h" +#include "types.h" +#include "net.h" +#include "buffer.h" + +/** + * @file git2/refspec.h + * @brief Git refspec attributes + * @defgroup git_refspec Git refspec attributes + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Get the source specifier + * + * @param refspec the refspec + * @return the refspec's source specifier + */ +GIT_EXTERN(const char *) git_refspec_src(const git_refspec *refspec); + +/** + * Get the destination specifier + * + * @param refspec the refspec + * @return the refspec's destination specifier + */ +GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec); + +/** + * Get the refspec's string + * + * @param refspec the refspec + * @returns the refspec's original string + */ +GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec); + +/** + * Get the force update setting + * + * @param refspec the refspec + * @return 1 if force update has been set, 0 otherwise + */ +GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec); + +/** + * Get the refspec's direction. + * + * @param spec refspec + * @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH + */ +GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec); + +/** + * Check if a refspec's source descriptor matches a reference + * + * @param refspec the refspec + * @param refname the name of the reference to check + * @return 1 if the refspec matches, 0 otherwise + */ +GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *refname); + +/** + * Check if a refspec's destination descriptor matches a reference + * + * @param refspec the refspec + * @param refname the name of the reference to check + * @return 1 if the refspec matches, 0 otherwise + */ +GIT_EXTERN(int) git_refspec_dst_matches(const git_refspec *refspec, const char *refname); + +/** + * Transform a reference to its target following the refspec's rules + * + * @param out where to store the target name + * @param spec the refspec + * @param name the name of the reference to transform + * @return 0, GIT_EBUFS or another error + */ +GIT_EXTERN(int) git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name); + +/** + * Transform a target reference to its source reference following the refspec's rules + * + * @param out where to store the source reference name + * @param spec the refspec + * @param name the name of the reference to transform + * @return 0, GIT_EBUFS or another error + */ +GIT_EXTERN(int) git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/remote.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/remote.h new file mode 100644 index 000000000..f85c38429 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/remote.h @@ -0,0 +1,693 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_remote_h__ +#define INCLUDE_git_remote_h__ + +#include "common.h" +#include "repository.h" +#include "refspec.h" +#include "net.h" +#include "indexer.h" +#include "strarray.h" +#include "transport.h" +#include "push.h" + +/** + * @file git2/remote.h + * @brief Git remote management functions + * @defgroup git_remote remote management functions + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload); + +/** + * Add a remote with the default fetch refspec to the repository's configuration. This + * calls git_remote_save before returning. + * + * @param out the resulting remote + * @param repo the repository in which to create the remote + * @param name the remote's name + * @param url the remote's url + * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code + */ +GIT_EXTERN(int) git_remote_create( + git_remote **out, + git_repository *repo, + const char *name, + const char *url); + +/** + * Add a remote with the provided fetch refspec (or default if NULL) to the repository's + * configuration. This + * calls git_remote_save before returning. + * + * @param out the resulting remote + * @param repo the repository in which to create the remote + * @param name the remote's name + * @param url the remote's url + * @param fetch the remote fetch value + * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code + */ +GIT_EXTERN(int) git_remote_create_with_fetchspec( + git_remote **out, + git_repository *repo, + const char *name, + const char *url, + const char *fetch); + +/** + * Create an anonymous remote + * + * Create a remote with the given url and refspec in memory. You can use + * this when you have a URL instead of a remote's name. Note that anonymous + * remotes cannot be converted to persisted remotes. + * + * The name, when provided, will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param out pointer to the new remote object + * @param repo the associated repository + * @param url the remote repository's URL + * @param fetch the fetch refspec to use for this remote. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_create_anonymous( + git_remote **out, + git_repository *repo, + const char *url, + const char *fetch); + +/** + * Get the information for a particular remote + * + * The name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param out pointer to the new remote object + * @param repo the associated repository + * @param name the remote's name + * @return 0, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_remote_lookup(git_remote **out, git_repository *repo, const char *name); + +/** + * Save a remote to its repository's configuration + * + * One can't save a in-memory remote. Doing so will + * result in a GIT_EINVALIDSPEC being returned. + * + * @param remote the remote to save to config + * @return 0, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_remote_save(const git_remote *remote); + +/** + * Create a copy of an existing remote. All internal strings are also + * duplicated. Callbacks are not duplicated. + * + * Call `git_remote_free` to free the data. + * + * @param dest pointer where to store the copy + * @param source object to copy + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_dup(git_remote **dest, git_remote *source); + +/** + * Get the remote's repository + * + * @param remote the remote + * @return a pointer to the repository + */ +GIT_EXTERN(git_repository *) git_remote_owner(const git_remote *remote); + +/** + * Get the remote's name + * + * @param remote the remote + * @return a pointer to the name or NULL for in-memory remotes + */ +GIT_EXTERN(const char *) git_remote_name(const git_remote *remote); + +/** + * Get the remote's url + * + * @param remote the remote + * @return a pointer to the url + */ +GIT_EXTERN(const char *) git_remote_url(const git_remote *remote); + +/** + * Get the remote's url for pushing + * + * @param remote the remote + * @return a pointer to the url or NULL if no special url for pushing is set + */ +GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote); + +/** + * Set the remote's url + * + * Existing connections will not be updated. + * + * @param remote the remote + * @param url the url to set + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_set_url(git_remote *remote, const char* url); + +/** + * Set the remote's url for pushing + * + * Existing connections will not be updated. + * + * @param remote the remote + * @param url the url to set or NULL to clear the pushurl + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_set_pushurl(git_remote *remote, const char* url); + +/** + * Add a fetch refspec to the remote + * + * Convenience function for adding a single fetch refspec to the + * current list in the remote. + * + * @param remote the remote + * @param refspec the new fetch refspec + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec); + +/** + * Get the remote's list of fetch refspecs + * + * The memory is owned by the user and should be freed with + * `git_strarray_free`. + * + * @param array pointer to the array in which to store the strings + * @param remote the remote to query + */ +GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote); + +/** + * Set the remote's list of fetch refspecs + * + * The contents of the string array are copied. + * + * @param remote the remote to modify + * @param array the new list of fetch resfpecs + */ +GIT_EXTERN(int) git_remote_set_fetch_refspecs(git_remote *remote, git_strarray *array); + +/** + * Add a push refspec to the remote + * + * Convenience function for adding a single push refspec to the + * current list in the remote. + * + * @param remote the remote + * @param refspec the new push refspec + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec); + +/** + * Get the remote's list of push refspecs + * + * The memory is owned by the user and should be freed with + * `git_strarray_free`. + * + * @param array pointer to the array in which to store the strings + * @param remote the remote to query + */ +GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote); + +/** + * Set the remote's list of push refspecs + * + * The contents of the string array are copied. + * + * @param remote the remote to modify + * @param array the new list of push resfpecs + */ +GIT_EXTERN(int) git_remote_set_push_refspecs(git_remote *remote, git_strarray *array); + +/** + * Clear the refspecs + * + * Remove all configured fetch and push refspecs from the remote. + * + * @param remote the remote + */ +GIT_EXTERN(void) git_remote_clear_refspecs(git_remote *remote); + +/** + * Get the number of refspecs for a remote + * + * @param remote the remote + * @return the amount of refspecs configured in this remote + */ +GIT_EXTERN(size_t) git_remote_refspec_count(const git_remote *remote); + +/** + * Get a refspec from the remote + * + * @param remote the remote to query + * @param n the refspec to get + * @return the nth refspec + */ +GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote, size_t n); + +/** + * Open a connection to a remote + * + * The transport is selected based on the URL. The direction argument + * is due to a limitation of the git protocol (over TCP or SSH) which + * starts up a specific binary which can only do the one or the other. + * + * @param remote the remote to connect to + * @param direction GIT_DIRECTION_FETCH if you want to fetch or + * GIT_DIRECTION_PUSH if you want to push + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction); + +/** + * Get the remote repository's reference advertisement list + * + * Get the list of references with which the server responds to a new + * connection. + * + * The remote (or more exactly its transport) must have connected to + * the remote repository. This list is available as soon as the + * connection to the remote is initiated and it remains available + * after disconnecting. + * + * The memory belongs to the remote. The pointer will be valid as long + * as a new connection is not initiated, but it is recommended that + * you make a copy in order to make use of the data. + * + * @param out pointer to the array + * @param size the number of remote heads + * @param remote the remote + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote); + +/** + * Download and index the packfile + * + * Connect to the remote if it hasn't been done yet, negotiate with + * the remote git which objects are missing, download and index the + * packfile. + * + * The .idx file will be created and both it and the packfile with be + * renamed to their final name. + * + * @param remote the remote + * @param refspecs the refspecs to use for this negotiation and + * download. Use NULL or an empty array to use the base refspecs + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs); + +/** + * Create a packfile and send it to the server + * + * Connect to the remote if it hasn't been done yet, negotiate with + * the remote git which objects are missing, create a packfile with the missing objects and send it. + * + * @param remote the remote + * @param refspecs the refspecs to use for this negotiation and + * upload. Use NULL or an empty array to use the base refspecs + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts); + +/** + * Check whether the remote is connected + * + * Check whether the remote's underlying transport is connected to the + * remote host. + * + * @param remote the remote + * @return 1 if it's connected, 0 otherwise. + */ +GIT_EXTERN(int) git_remote_connected(const git_remote *remote); + +/** + * Cancel the operation + * + * At certain points in its operation, the network code checks whether + * the operation has been cancelled and if so stops the operation. + * + * @param remote the remote + */ +GIT_EXTERN(void) git_remote_stop(git_remote *remote); + +/** + * Disconnect from the remote + * + * Close the connection to the remote. + * + * @param remote the remote to disconnect from + */ +GIT_EXTERN(void) git_remote_disconnect(git_remote *remote); + +/** + * Free the memory associated with a remote + * + * This also disconnects from the remote, if the connection + * has not been closed yet (using git_remote_disconnect). + * + * @param remote the remote to free + */ +GIT_EXTERN(void) git_remote_free(git_remote *remote); + +/** + * Update the tips to the new state + * + * @param remote the remote to update + * @param reflog_message The message to insert into the reflogs. If + * NULL and fetching, the default is "fetch ", where is + * the name of the remote (or its url, for in-memory remotes). This + * parameter is ignored when pushing. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_update_tips( + git_remote *remote, + const char *reflog_message); + +/** + * Prune tracking refs that are no longer present on remote + * + * @param remote the remote to prune + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_prune(git_remote *remote); + +/** + * Download new data and update tips + * + * Convenience function to connect to a remote, download the data, + * disconnect and update the remote-tracking branches. + * + * @param remote the remote to fetch from + * @param refspecs the refspecs to use for this fetch. Pass NULL or an + * empty array to use the base refspecs. + * @param reflog_message The message to insert into the reflogs. If NULL, the + * default is "fetch" + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_fetch( + git_remote *remote, + const git_strarray *refspecs, + const char *reflog_message); + +/** + * Perform a push + * + * Peform all the steps from a push. + * + * @param remote the remote to push to + * @param refspecs the refspecs to use for pushing. If none are + * passed, the configured refspecs will be used + * @param opts the options + */ +GIT_EXTERN(int) git_remote_push(git_remote *remote, + const git_strarray *refspecs, + const git_push_options *opts); + +/** + * Get a list of the configured remotes for a repo + * + * The string array must be freed by the user. + * + * @param out a string array which receives the names of the remotes + * @param repo the repository to query + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo); + +/** + * Argument to the completion callback which tells it which operation + * finished. + */ +typedef enum git_remote_completion_type { + GIT_REMOTE_COMPLETION_DOWNLOAD, + GIT_REMOTE_COMPLETION_INDEXING, + GIT_REMOTE_COMPLETION_ERROR, +} git_remote_completion_type; + +/** + * The callback settings structure + * + * Set the callbacks to be called by the remote when informing the user + * about the progress of the network operations. + */ +struct git_remote_callbacks { + unsigned int version; + /** + * Textual progress from the remote. Text send over the + * progress side-band will be passed to this function (this is + * the 'counting objects' output. + */ + git_transport_message_cb sideband_progress; + + /** + * Completion is called when different parts of the download + * process are done (currently unused). + */ + int (*completion)(git_remote_completion_type type, void *data); + + /** + * This will be called if the remote host requires + * authentication in order to connect to it. + * + * Returning GIT_PASSTHROUGH will make libgit2 behave as + * though this field isn't set. + */ + git_cred_acquire_cb credentials; + + /** + * If cert verification fails, this will be called to let the + * user make the final decision of whether to allow the + * connection to proceed. Returns 1 to allow the connection, 0 + * to disallow it or a negative value to indicate an error. + */ + git_transport_certificate_check_cb certificate_check; + + /** + * During the download of new data, this will be regularly + * called with the current count of progress done by the + * indexer. + */ + git_transfer_progress_cb transfer_progress; + + /** + * Each time a reference is updated locally, this function + * will be called with information about it. + */ + int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data); + + /** + * Function to call with progress information during pack + * building. Be aware that this is called inline with pack + * building operations, so performance may be affected. + */ + git_packbuilder_progress pack_progress; + + /** + * Function to call with progress information during the + * upload portion of a push. Be aware that this is called + * inline with pack building operations, so performance may be + * affected. + */ + git_push_transfer_progress push_transfer_progress; + + /** + * Called for each updated reference on push. If `status` is + * not `NULL`, the update was rejected by the remote server + * and `status` contains the reason given. + */ + int (*push_update_reference)(const char *refname, const char *status, void *data); + + /** + * This will be passed to each of the callbacks in this struct + * as the last parameter. + */ + void *payload; +}; + +#define GIT_REMOTE_CALLBACKS_VERSION 1 +#define GIT_REMOTE_CALLBACKS_INIT {GIT_REMOTE_CALLBACKS_VERSION} + +/** + * Initializes a `git_remote_callbacks` with default values. Equivalent to + * creating an instance with GIT_REMOTE_CALLBACKS_INIT. + * + * @param opts the `git_remote_callbacks` struct to initialize + * @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_remote_init_callbacks( + git_remote_callbacks *opts, + unsigned int version); + +/** + * Set the callbacks for a remote + * + * Note that the remote keeps its own copy of the data and you need to + * call this function again if you want to change the callbacks. + * + * @param remote the remote to configure + * @param callbacks a pointer to the user's callback settings + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *callbacks); + +/** + * Retrieve the current callback structure + * + * This provides read access to the callbacks structure as the remote + * sees it. + * + * @param remote the remote to query + * @return a pointer to the callbacks structure + */ +GIT_EXTERN(const git_remote_callbacks *) git_remote_get_callbacks(git_remote *remote); + +/** + * Get the statistics structure that is filled in by the fetch operation. + */ +GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote); + +/** + * Automatic tag following option + * + * Lets us select the --tags option to use. + */ +typedef enum { + GIT_REMOTE_DOWNLOAD_TAGS_AUTO = 0, + GIT_REMOTE_DOWNLOAD_TAGS_NONE = 1, + GIT_REMOTE_DOWNLOAD_TAGS_ALL = 2 +} git_remote_autotag_option_t; + +/** + * Retrieve the tag auto-follow setting + * + * @param remote the remote to query + * @return the auto-follow setting + */ +GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *remote); + +/** + * Set the tag auto-follow setting + * + * @param remote the remote to configure + * @param value a GIT_REMOTE_DOWNLOAD_TAGS value + */ +GIT_EXTERN(void) git_remote_set_autotag( + git_remote *remote, + git_remote_autotag_option_t value); + +/** + * Retrieve the ref-prune setting + * + * @param remote the remote to query + * @return the ref-prune setting + */ +GIT_EXTERN(int) git_remote_prune_refs(const git_remote *remote); + +/** + * Give the remote a new name + * + * All remote-tracking branches and configuration settings + * for the remote are updated. + * + * The new name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * No loaded instances of a the remote with the old name will change + * their name or their list of refspecs. + * + * @param problems non-default refspecs cannot be renamed and will be + * stored here for further processing by the caller. Always free this + * strarray on successful return. + * @param repo the repository in which to rename + * @param name the current name of the reamote + * @param new_name the new name the remote should bear + * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code + */ +GIT_EXTERN(int) git_remote_rename( + git_strarray *problems, + git_repository *repo, + const char *name, + const char *new_name); + +/** + * Retrieve the update FETCH_HEAD setting. + * + * @param remote the remote to query + * @return the update FETCH_HEAD setting + */ +GIT_EXTERN(int) git_remote_update_fetchhead(git_remote *remote); + +/** + * Sets the update FETCH_HEAD setting. By default, FETCH_HEAD will be + * updated on every fetch. Set to 0 to disable. + * + * @param remote the remote to configure + * @param value 0 to disable updating FETCH_HEAD + */ +GIT_EXTERN(void) git_remote_set_update_fetchhead(git_remote *remote, int value); + +/** + * Ensure the remote name is well-formed. + * + * @param remote_name name to be checked. + * @return 1 if the reference name is acceptable; 0 if it isn't + */ +GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name); + +/** +* Delete an existing persisted remote. +* +* All remote-tracking branches and configuration settings +* for the remote will be removed. +* +* @param repo the repository in which to act +* @param name the name of the remove to delete +* @return 0 on success, or an error code. +*/ +GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name); + +/** + * Retrieve the name of the remote's default branch + * + * The default branch of a repository is the branch which HEAD points + * to. If the remote does not support reporting this information + * directly, it performs the guess as git does; that is, if there are + * multiple branches which point to the same commit, the first one is + * chosen. If the master branch is a candidate, it wins. + * + * This function must only be called after connecting. + * + * @param out the buffern in which to store the reference name + * @param remote the remote + * @return 0, GIT_ENOTFOUND if the remote does not have any references + * or none of them point to HEAD's commit, or an error message. + */ +GIT_EXTERN(int) git_remote_default_branch(git_buf *out, git_remote *remote); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/repository.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/repository.h new file mode 100644 index 000000000..ce56fef0f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/repository.h @@ -0,0 +1,754 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_repository_h__ +#define INCLUDE_git_repository_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "buffer.h" + +/** + * @file git2/repository.h + * @brief Git repository management routines + * @defgroup git_repository Git repository management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Open a git repository. + * + * The 'path' argument must point to either a git repository + * folder, or an existing work dir. + * + * The method will automatically detect if 'path' is a normal + * or bare repository or fail is 'path' is neither. + * + * @param out pointer to the repo which will be opened + * @param path the path to the repository + * @return 0 or an error code + */ +GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path); + +/** + * Create a "fake" repository to wrap an object database + * + * Create a repository object to wrap an object database to be used + * with the API when all you have is an object database. This doesn't + * have any paths associated with it, so use with care. + * + * @param out pointer to the repo + * @param odb the object database to wrap + * @return 0 or an error code + */ +GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb); + +/** + * Look for a git repository and copy its path in the given buffer. + * The lookup start from base_path and walk across parent directories + * if nothing has been found. The lookup ends when the first repository + * is found, or when reaching a directory referenced in ceiling_dirs + * or when the filesystem changes (in case across_fs is true). + * + * The method will automatically detect if the repository is bare + * (if there is a repository). + * + * @param out A pointer to a user-allocated git_buf which will contain + * the found path. + * + * @param start_path The base path where the lookup starts. + * + * @param across_fs If true, then the lookup will not stop when a + * filesystem device change is detected while exploring parent directories. + * + * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of + * absolute symbolic link free paths. The lookup will stop when any + * of this paths is reached. Note that the lookup always performs on + * start_path no matter start_path appears in ceiling_dirs ceiling_dirs + * might be NULL (which is equivalent to an empty string) + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_repository_discover( + git_buf *out, + const char *start_path, + int across_fs, + const char *ceiling_dirs); + +/** + * Option flags for `git_repository_open_ext`. + * + * * GIT_REPOSITORY_OPEN_NO_SEARCH - Only open the repository if it can be + * immediately found in the start_path. Do not walk up from the + * start_path looking at parent directories. + * * GIT_REPOSITORY_OPEN_CROSS_FS - Unless this flag is set, open will not + * continue searching across filesystem boundaries (i.e. when `st_dev` + * changes from the `stat` system call). (E.g. Searching in a user's home + * directory "/home/user/source/" will not return "/.git/" as the found + * repo if "/" is a different filesystem than "/home".) + * * GIT_REPOSITORY_OPEN_BARE - Open repository as a bare repo regardless + * of core.bare config, and defer loading config file for faster setup. + * Unlike `git_repository_open_bare`, this can follow gitlinks. + */ +typedef enum { + GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0), + GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1), + GIT_REPOSITORY_OPEN_BARE = (1 << 2), +} git_repository_open_flag_t; + +/** + * Find and open a repository with extended controls. + * + * @param out Pointer to the repo which will be opened. This can + * actually be NULL if you only want to use the error code to + * see if a repo at this path could be opened. + * @param path Path to open as git repository. If the flags + * permit "searching", then this can be a path to a subdirectory + * inside the working directory of the repository. + * @param flags A combination of the GIT_REPOSITORY_OPEN flags above. + * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR delimited list of path + * prefixes at which the search for a containing repository should + * terminate. + * @return 0 on success, GIT_ENOTFOUND if no repository could be found, + * or -1 if there was a repository but open failed for some reason + * (such as repo corruption or system errors). + */ +GIT_EXTERN(int) git_repository_open_ext( + git_repository **out, + const char *path, + unsigned int flags, + const char *ceiling_dirs); + +/** + * Open a bare repository on the serverside. + * + * This is a fast open for bare repositories that will come in handy + * if you're e.g. hosting git repositories and need to access them + * efficiently + * + * @param out Pointer to the repo which will be opened. + * @param bare_path Direct path to the bare repository + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_repository_open_bare(git_repository **out, const char *bare_path); + +/** + * Free a previously allocated repository + * + * Note that after a repository is free'd, all the objects it has spawned + * will still exist until they are manually closed by the user + * with `git_object_free`, but accessing any of the attributes of + * an object without a backing repository will result in undefined + * behavior + * + * @param repo repository handle to close. If NULL nothing occurs. + */ +GIT_EXTERN(void) git_repository_free(git_repository *repo); + +/** + * Creates a new Git repository in the given folder. + * + * TODO: + * - Reinit the repository + * + * @param out pointer to the repo which will be created or reinitialized + * @param path the path to the repository + * @param is_bare if true, a Git repository without a working directory is + * created at the pointed path. If false, provided path will be + * considered as the working directory into which the .git directory + * will be created. + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_repository_init( + git_repository **out, + const char *path, + unsigned is_bare); + +/** + * Option flags for `git_repository_init_ext`. + * + * These flags configure extra behaviors to `git_repository_init_ext`. + * In every case, the default behavior is the zero value (i.e. flag is + * not set). Just OR the flag values together for the `flags` parameter + * when initializing a new repo. Details of individual values are: + * + * * BARE - Create a bare repository with no working directory. + * * NO_REINIT - Return an GIT_EEXISTS error if the repo_path appears to + * already be an git repository. + * * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo + * path for non-bare repos (if it is not already there), but + * passing this flag prevents that behavior. + * * MKDIR - Make the repo_path (and workdir_path) as needed. Init is + * always willing to create the ".git" directory even without this + * flag. This flag tells init to create the trailing component of + * the repo and workdir paths as needed. + * * MKPATH - Recursively make all components of the repo and workdir + * paths as necessary. + * * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to + * initialize a new repo. This flags enables external templates, + * looking the "template_path" from the options if set, or the + * `init.templatedir` global config if not, or falling back on + * "/usr/share/git-core/templates" if it exists. + * * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is + * specified, use relative paths for the gitdir and core.worktree. + */ +typedef enum { + GIT_REPOSITORY_INIT_BARE = (1u << 0), + GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1), + GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2), + GIT_REPOSITORY_INIT_MKDIR = (1u << 3), + GIT_REPOSITORY_INIT_MKPATH = (1u << 4), + GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5), + GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6), +} git_repository_init_flag_t; + +/** + * Mode options for `git_repository_init_ext`. + * + * Set the mode field of the `git_repository_init_options` structure + * either to the custom mode that you would like, or to one of the + * following modes: + * + * * SHARED_UMASK - Use permissions configured by umask - the default. + * * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo + * to be group writable and "g+sx" for sticky group assignment. + * * SHARED_ALL - Use "--shared=all" behavior, adding world readability. + * * Anything else - Set to custom value. + */ +typedef enum { + GIT_REPOSITORY_INIT_SHARED_UMASK = 0, + GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775, + GIT_REPOSITORY_INIT_SHARED_ALL = 0002777, +} git_repository_init_mode_t; + +/** + * Extended options structure for `git_repository_init_ext`. + * + * This contains extra options for `git_repository_init_ext` that enable + * additional initialization features. The fields are: + * + * * flags - Combination of GIT_REPOSITORY_INIT flags above. + * * mode - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_... + * constants above, or to a custom value that you would like. + * * workdir_path - The path to the working dir or NULL for default (i.e. + * repo_path parent on non-bare repos). IF THIS IS RELATIVE PATH, + * IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH. If this is not + * the "natural" working directory, a .git gitlink file will be + * created here linking to the repo_path. + * * description - If set, this will be used to initialize the "description" + * file in the repository, instead of using the template content. + * * template_path - When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set, + * this contains the path to use for the template directory. If + * this is NULL, the config or default directory options will be + * used instead. + * * initial_head - The name of the head to point HEAD at. If NULL, then + * this will be treated as "master" and the HEAD ref will be set + * to "refs/heads/master". If this begins with "refs/" it will be + * used verbatim; otherwise "refs/heads/" will be prefixed. + * * origin_url - If this is non-NULL, then after the rest of the + * repository initialization is completed, an "origin" remote + * will be added pointing to this URL. + */ +typedef struct { + unsigned int version; + uint32_t flags; + uint32_t mode; + const char *workdir_path; + const char *description; + const char *template_path; + const char *initial_head; + const char *origin_url; +} git_repository_init_options; + +#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1 +#define GIT_REPOSITORY_INIT_OPTIONS_INIT {GIT_REPOSITORY_INIT_OPTIONS_VERSION} + +/** + * Initializes a `git_repository_init_options` with default values. Equivalent + * to creating an instance with GIT_REPOSITORY_INIT_OPTIONS_INIT. + * + * @param opts the `git_repository_init_options` struct to initialize + * @param version Version of struct; pass `GIT_REPOSITORY_INIT_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_repository_init_init_options( + git_repository_init_options *opts, + unsigned int version); + +/** + * Create a new Git repository in the given folder with extended controls. + * + * This will initialize a new git repository (creating the repo_path + * if requested by flags) and working directory as needed. It will + * auto-detect the case sensitivity of the file system and if the + * file system supports file mode bits correctly. + * + * @param out Pointer to the repo which will be created or reinitialized. + * @param repo_path The path to the repository. + * @param opts Pointer to git_repository_init_options struct. + * @return 0 or an error code on failure. + */ +GIT_EXTERN(int) git_repository_init_ext( + git_repository **out, + const char *repo_path, + git_repository_init_options *opts); + +/** + * Retrieve and resolve the reference pointed at by HEAD. + * + * The returned `git_reference` will be owned by caller and + * `git_reference_free()` must be called when done with it to release the + * allocated memory and prevent a leak. + * + * @param out pointer to the reference which will be retrieved + * @param repo a repository object + * + * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing + * branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise + */ +GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo); + +/** + * Check if a repository's HEAD is detached + * + * A repository's HEAD is detached when it points directly to a commit + * instead of a branch. + * + * @param repo Repo to test + * @return 1 if HEAD is detached, 0 if it's not; error code if there + * was an error. + */ +GIT_EXTERN(int) git_repository_head_detached(git_repository *repo); + +/** + * Check if the current branch is unborn + * + * An unborn branch is one named from HEAD but which doesn't exist in + * the refs namespace, because it doesn't have any commit to point to. + * + * @param repo Repo to test + * @return 1 if the current branch is unborn, 0 if it's not; error + * code if there was an error + */ +GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo); + +/** + * Check if a repository is empty + * + * An empty repository has just been initialized and contains no references + * apart from HEAD, which must be pointing to the unborn master branch. + * + * @param repo Repo to test + * @return 1 if the repository is empty, 0 if it isn't, error code + * if the repository is corrupted + */ +GIT_EXTERN(int) git_repository_is_empty(git_repository *repo); + +/** + * Get the path of this repository + * + * This is the path of the `.git` folder for normal repositories, + * or of the repository itself for bare repositories. + * + * @param repo A repository object + * @return the path to the repository + */ +GIT_EXTERN(const char *) git_repository_path(git_repository *repo); + +/** + * Get the path of the working directory for this repository + * + * If the repository is bare, this function will always return + * NULL. + * + * @param repo A repository object + * @return the path to the working dir, if it exists + */ +GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); + +/** + * Set the path to the working directory for this repository + * + * The working directory doesn't need to be the same one + * that contains the `.git` folder for this repository. + * + * If this repository is bare, setting its working directory + * will turn it into a normal repository, capable of performing + * all the common workdir operations (checkout, status, index + * manipulation, etc). + * + * @param repo A repository object + * @param workdir The path to a working directory + * @param update_gitlink Create/update gitlink in workdir and set config + * "core.worktree" (if workdir is not the parent of the .git directory) + * @return 0, or an error code + */ +GIT_EXTERN(int) git_repository_set_workdir( + git_repository *repo, const char *workdir, int update_gitlink); + +/** + * Check if a repository is bare + * + * @param repo Repo to test + * @return 1 if the repository is bare, 0 otherwise. + */ +GIT_EXTERN(int) git_repository_is_bare(git_repository *repo); + +/** + * Get the configuration file for this repository. + * + * If a configuration file has not been set, the default + * config set for the repository will be returned, including + * global and system configurations (if they are available). + * + * The configuration file must be freed once it's no longer + * being used by the user. + * + * @param out Pointer to store the loaded configuration + * @param repo A repository object + * @return 0, or an error code + */ +GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo); + +/** + * Get a snapshot of the repository's configuration + * + * Convenience function to take a snapshot from the repository's + * configuration. The contents of this snapshot will not change, + * even if the underlying config files are modified. + * + * The configuration file must be freed once it's no longer + * being used by the user. + * + * @param out Pointer to store the loaded configuration + * @param repo the repository + * @return 0, or an error code + */ +GIT_EXTERN(int) git_repository_config_snapshot(git_config **out, git_repository *repo); + +/** + * Get the Object Database for this repository. + * + * If a custom ODB has not been set, the default + * database for the repository will be returned (the one + * located in `.git/objects`). + * + * The ODB must be freed once it's no longer being used by + * the user. + * + * @param out Pointer to store the loaded ODB + * @param repo A repository object + * @return 0, or an error code + */ +GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo); + +/** + * Get the Reference Database Backend for this repository. + * + * If a custom refsdb has not been set, the default database for + * the repository will be returned (the one that manipulates loose + * and packed references in the `.git` directory). + * + * The refdb must be freed once it's no longer being used by + * the user. + * + * @param out Pointer to store the loaded refdb + * @param repo A repository object + * @return 0, or an error code + */ +GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo); + +/** + * Get the Index file for this repository. + * + * If a custom index has not been set, the default + * index for the repository will be returned (the one + * located in `.git/index`). + * + * The index must be freed once it's no longer being used by + * the user. + * + * @param out Pointer to store the loaded index + * @param repo A repository object + * @return 0, or an error code + */ +GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo); + +/** + * Retrieve git's prepared message + * + * Operations such as git revert/cherry-pick/merge with the -n option + * stop just short of creating a commit with the changes and save + * their prepared message in .git/MERGE_MSG so the next git-commit + * execution can present it to the user for them to amend if they + * wish. + * + * Use this function to get the contents of this file. Don't forget to + * remove the file after you create the commit. + * + * @param out git_buf to write data into + * @param repo Repository to read prepared message from + * @return 0, GIT_ENOTFOUND if no message exists or an error code + */ +GIT_EXTERN(int) git_repository_message(git_buf *out, git_repository *repo); + +/** + * Remove git's prepared message. + * + * Remove the message that `git_repository_message` retrieves. + */ +GIT_EXTERN(int) git_repository_message_remove(git_repository *repo); + +/** + * Remove all the metadata associated with an ongoing command like merge, + * revert, cherry-pick, etc. For example: MERGE_HEAD, MERGE_MSG, etc. + * + * @param repo A repository object + * @return 0 on success, or error + */ +GIT_EXTERN(int) git_repository_state_cleanup(git_repository *repo); + +typedef int (*git_repository_fetchhead_foreach_cb)(const char *ref_name, + const char *remote_url, + const git_oid *oid, + unsigned int is_merge, + void *payload); + +/** + * Invoke 'callback' for each entry in the given FETCH_HEAD file. + * + * Return a non-zero value from the callback to stop the loop. + * + * @param repo A repository object + * @param callback Callback function + * @param payload Pointer to callback data (optional) + * @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if + * there is no FETCH_HEAD file, or other error code. + */ +GIT_EXTERN(int) git_repository_fetchhead_foreach( + git_repository *repo, + git_repository_fetchhead_foreach_cb callback, + void *payload); + +typedef int (*git_repository_mergehead_foreach_cb)(const git_oid *oid, + void *payload); + +/** + * If a merge is in progress, invoke 'callback' for each commit ID in the + * MERGE_HEAD file. + * + * Return a non-zero value from the callback to stop the loop. + * + * @param repo A repository object + * @param callback Callback function + * @param payload Pointer to callback data (optional) + * @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if + * there is no MERGE_HEAD file, or other error code. + */ +GIT_EXTERN(int) git_repository_mergehead_foreach( + git_repository *repo, + git_repository_mergehead_foreach_cb callback, + void *payload); + +/** + * Calculate hash of file using repository filtering rules. + * + * If you simply want to calculate the hash of a file on disk with no filters, + * you can just use the `git_odb_hashfile()` API. However, if you want to + * hash a file in the repository and you want to apply filtering rules (e.g. + * crlf filters) before generating the SHA, then use this function. + * + * Note: if the repository has `core.safecrlf` set to fail and the + * filtering triggers that failure, then this function will return an + * error and not calculate the hash of the file. + * + * @param out Output value of calculated SHA + * @param repo Repository pointer + * @param path Path to file on disk whose contents should be hashed. If the + * repository is not NULL, this can be a relative path. + * @param type The object type to hash as (e.g. GIT_OBJ_BLOB) + * @param as_path The path to use to look up filtering rules. If this is + * NULL, then the `path` parameter will be used instead. If + * this is passed as the empty string, then no filters will be + * applied when calculating the hash. + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_repository_hashfile( + git_oid *out, + git_repository *repo, + const char *path, + git_otype type, + const char *as_path); + +/** + * Make the repository HEAD point to the specified reference. + * + * If the provided reference points to a Tree or a Blob, the HEAD is + * unaltered and -1 is returned. + * + * If the provided reference points to a branch, the HEAD will point + * to that branch, staying attached, or become attached if it isn't yet. + * If the branch doesn't exist yet, no error will be return. The HEAD + * will then be attached to an unborn branch. + * + * Otherwise, the HEAD will be detached and will directly point to + * the Commit. + * + * @param repo Repository pointer + * @param refname Canonical name of the reference the HEAD should point at + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_repository_set_head( + git_repository* repo, + const char* refname); + +/** + * Make the repository HEAD directly point to the Commit. + * + * If the provided committish cannot be found in the repository, the HEAD + * is unaltered and GIT_ENOTFOUND is returned. + * + * If the provided commitish cannot be peeled into a commit, the HEAD + * is unaltered and -1 is returned. + * + * Otherwise, the HEAD will eventually be detached and will directly point to + * the peeled Commit. + * + * @param repo Repository pointer + * @param commitish Object id of the Commit the HEAD should point to + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_repository_set_head_detached( + git_repository* repo, + const git_oid* commitish); + +/** + * Make the repository HEAD directly point to the Commit. + * + * This behaves like `git_repository_set_head_detached()` but takes an + * annotated commit, which lets you specify which extended sha syntax + * string was specified by a user, allowing for more exact reflog + * messages. + * + * See the documentation for `git_repository_set_head_detached()`. + * + * @see git_repository_set_head_detached + */ +GIT_EXTERN(int) git_repository_set_head_detached_from_annotated( + git_repository *repo, + const git_annotated_commit *commitish); + +/** + * Detach the HEAD. + * + * If the HEAD is already detached and points to a Commit, 0 is returned. + * + * If the HEAD is already detached and points to a Tag, the HEAD is + * updated into making it point to the peeled Commit, and 0 is returned. + * + * If the HEAD is already detached and points to a non commitish, the HEAD is + * unaltered, and -1 is returned. + * + * Otherwise, the HEAD will be detached and point to the peeled Commit. + * + * @param repo Repository pointer + * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing + * branch or an error code + */ +GIT_EXTERN(int) git_repository_detach_head( + git_repository* repo); + +/** + * Repository state + * + * These values represent possible states for the repository to be in, + * based on the current operation which is ongoing. + */ +typedef enum { + GIT_REPOSITORY_STATE_NONE, + GIT_REPOSITORY_STATE_MERGE, + GIT_REPOSITORY_STATE_REVERT, + GIT_REPOSITORY_STATE_CHERRYPICK, + GIT_REPOSITORY_STATE_BISECT, + GIT_REPOSITORY_STATE_REBASE, + GIT_REPOSITORY_STATE_REBASE_INTERACTIVE, + GIT_REPOSITORY_STATE_REBASE_MERGE, + GIT_REPOSITORY_STATE_APPLY_MAILBOX, + GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE, +} git_repository_state_t; + +/** + * Determines the status of a git repository - ie, whether an operation + * (merge, cherry-pick, etc) is in progress. + * + * @param repo Repository pointer + * @return The state of the repository + */ +GIT_EXTERN(int) git_repository_state(git_repository *repo); + +/** + * Sets the active namespace for this Git Repository + * + * This namespace affects all reference operations for the repo. + * See `man gitnamespaces` + * + * @param repo The repo + * @param nmspace The namespace. This should not include the refs + * folder, e.g. to namespace all references under `refs/namespaces/foo/`, + * use `foo` as the namespace. + * @return 0 on success, -1 on error + */ +GIT_EXTERN(int) git_repository_set_namespace(git_repository *repo, const char *nmspace); + +/** + * Get the currently active namespace for this repository + * + * @param repo The repo + * @return the active namespace, or NULL if there isn't one + */ +GIT_EXTERN(const char *) git_repository_get_namespace(git_repository *repo); + + +/** + * Determine if the repository was a shallow clone + * + * @param repo The repository + * @return 1 if shallow, zero if not + */ +GIT_EXTERN(int) git_repository_is_shallow(git_repository *repo); + +/** + * Retrieve the configured identity to use for reflogs + * + * The memory is owned by the repository and must not be freed by the + * user. + * + * @param name where to store the pointer to the name + * @param email where to store the pointer to the email + * @param repo the repository + */ +GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, const git_repository *repo); + +/** + * Set the identity to be used for writing reflogs + * + * If both are set, this name and email will be used to write to the + * reflog. Pass NULL to unset. When unset, the identity will be taken + * from the repository's configuration. + * + * @param repo the repository to configure + * @param name the name to use for the reflog entries + * @param name the email to use for the reflog entries + */ +GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name, const char *email); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/reset.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/reset.h new file mode 100644 index 000000000..c03dbed8c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/reset.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_reset_h__ +#define INCLUDE_git_reset_h__ + +#include "common.h" +#include "types.h" +#include "strarray.h" + +/** + * @file git2/reset.h + * @brief Git reset management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Kinds of reset operation + */ +typedef enum { + GIT_RESET_SOFT = 1, /**< Move the head to the given commit */ + GIT_RESET_MIXED = 2, /**< SOFT plus reset index to the commit */ + GIT_RESET_HARD = 3, /**< MIXED plus changes in working tree discarded */ +} git_reset_t; + +/** + * Sets the current head to the specified commit oid and optionally + * resets the index and working tree to match. + * + * SOFT reset means the Head will be moved to the commit. + * + * MIXED reset will trigger a SOFT reset, plus the index will be replaced + * with the content of the commit tree. + * + * HARD reset will trigger a MIXED reset and the working directory will be + * replaced with the content of the index. (Untracked and ignored files + * will be left alone, however.) + * + * TODO: Implement remaining kinds of resets. + * + * @param repo Repository where to perform the reset operation. + * + * @param target Committish to which the Head should be moved to. This object + * must belong to the given `repo` and can either be a git_commit or a + * git_tag. When a git_tag is being passed, it should be dereferencable + * to a git_commit which oid will be used as the target of the branch. + * + * @param reset_type Kind of reset operation to perform. + * + * @param checkout_opts Checkout options to be used for a HARD reset. + * The checkout_strategy field will be overridden (based on reset_type). + * This parameter can be used to propagate notify and progress callbacks. + * + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_reset( + git_repository *repo, + git_object *target, + git_reset_t reset_type, + git_checkout_options *checkout_opts); + +/** + * Sets the current head to the specified commit oid and optionally + * resets the index and working tree to match. + * + * This behaves like `git_reset()` but takes an annotated commit, + * which lets you specify which extended sha syntax string was + * specified by a user, allowing for more exact reflog messages. + * + * See the documentation for `git_reset()`. + * + * @see git_reset + */ +GIT_EXTERN(int) git_reset_from_annotated( + git_repository *repo, + git_annotated_commit *commit, + git_reset_t reset_type, + git_checkout_options *checkout_opts); + +/** + * Updates some entries in the index from the target commit tree. + * + * The scope of the updated entries is determined by the paths + * being passed in the `pathspec` parameters. + * + * Passing a NULL `target` will result in removing + * entries in the index matching the provided pathspecs. + * + * @param repo Repository where to perform the reset operation. + * + * @param target The committish which content will be used to reset the content + * of the index. + * + * @param pathspecs List of pathspecs to operate on. + * + * @return 0 on success or an error code < 0 + */ +GIT_EXTERN(int) git_reset_default( + git_repository *repo, + git_object *target, + git_strarray* pathspecs); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/revert.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/revert.h new file mode 100644 index 000000000..2de194219 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/revert.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_revert_h__ +#define INCLUDE_git_revert_h__ + +#include "common.h" +#include "types.h" +#include "merge.h" + +/** + * @file git2/revert.h + * @brief Git revert routines + * @defgroup git_revert Git revert routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Options for revert + */ +typedef struct { + unsigned int version; + + /** For merge commits, the "mainline" is treated as the parent. */ + unsigned int mainline; + + git_merge_options merge_opts; /**< Options for the merging */ + git_checkout_options checkout_opts; /**< Options for the checkout */ +} git_revert_options; + +#define GIT_REVERT_OPTIONS_VERSION 1 +#define GIT_REVERT_OPTIONS_INIT {GIT_REVERT_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT} + +/** + * Initializes a `git_revert_options` with default values. Equivalent to + * creating an instance with GIT_REVERT_OPTIONS_INIT. + * + * @param opts the `git_revert_options` struct to initialize + * @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_revert_init_options( + git_revert_options *opts, + unsigned int version); + +/** + * Reverts the given commit against the given "our" commit, producing an + * index that reflects the result of the revert. + * + * The returned index must be freed explicitly with `git_index_free`. + * + * @param out pointer to store the index result in + * @param repo the repository that contains the given commits + * @param revert_commit the commit to revert + * @param our_commit the commit to revert against (eg, HEAD) + * @param mainline the parent of the revert commit, if it is a merge + * @param merge_options the merge options (or null for defaults) + * @return zero on success, -1 on failure. + */ +GIT_EXTERN(int) git_revert_commit( + git_index **out, + git_repository *repo, + git_commit *revert_commit, + git_commit *our_commit, + unsigned int mainline, + const git_merge_options *merge_options); + +/** + * Reverts the given commit, producing changes in the index and working directory. + * + * @param repo the repository to revert + * @param commit the commit to revert + * @param given_opts merge flags + * @return zero on success, -1 on failure. + */ +GIT_EXTERN(int) git_revert( + git_repository *repo, + git_commit *commit, + const git_revert_options *given_opts); + +/** @} */ +GIT_END_DECL +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/revparse.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/revparse.h new file mode 100644 index 000000000..d170e1621 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/revparse.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_revparse_h__ +#define INCLUDE_git_revparse_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/revparse.h + * @brief Git revision parsing routines + * @defgroup git_revparse Git revision parsing routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Find a single object, as specified by a revision string. + * + * See `man gitrevisions`, or + * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + * information on the syntax accepted. + * + * The returned object should be released with `git_object_free` when no + * longer needed. + * + * @param out pointer to output object + * @param repo the repository to search in + * @param spec the textual specification for an object + * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_revparse_single( + git_object **out, git_repository *repo, const char *spec); + +/** + * Find a single object and intermediate reference by a revision string. + * + * See `man gitrevisions`, or + * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + * information on the syntax accepted. + * + * In some cases (`@{<-n>}` or `@{upstream}`), the expression may + * point to an intermediate reference. When such expressions are being passed + * in, `reference_out` will be valued as well. + * + * The returned object should be released with `git_object_free` and the + * returned reference with `git_reference_free` when no longer needed. + * + * @param object_out pointer to output object + * @param reference_out pointer to output reference or NULL + * @param repo the repository to search in + * @param spec the textual specification for an object + * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC + * or an error code + */ +GIT_EXTERN(int) git_revparse_ext( + git_object **object_out, + git_reference **reference_out, + git_repository *repo, + const char *spec); + +/** + * Revparse flags. These indicate the intended behavior of the spec passed to + * git_revparse. + */ +typedef enum { + /** The spec targeted a single object. */ + GIT_REVPARSE_SINGLE = 1 << 0, + /** The spec targeted a range of commits. */ + GIT_REVPARSE_RANGE = 1 << 1, + /** The spec used the '...' operator, which invokes special semantics. */ + GIT_REVPARSE_MERGE_BASE = 1 << 2, +} git_revparse_mode_t; + +/** + * Git Revision Spec: output of a `git_revparse` operation + */ +typedef struct { + /** The left element of the revspec; must be freed by the user */ + git_object *from; + /** The right element of the revspec; must be freed by the user */ + git_object *to; + /** The intent of the revspec (i.e. `git_revparse_mode_t` flags) */ + unsigned int flags; +} git_revspec; + +/** + * Parse a revision string for `from`, `to`, and intent. + * + * See `man gitrevisions` or + * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + * information on the syntax accepted. + * + * @param revspec Pointer to an user-allocated git_revspec struct where + * the result of the rev-parse will be stored + * @param repo the repository to search in + * @param spec the rev-parse spec to parse + * @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code + */ +GIT_EXTERN(int) git_revparse( + git_revspec *revspec, + git_repository *repo, + const char *spec); + + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/revwalk.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/revwalk.h new file mode 100644 index 000000000..0a5fdce21 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/revwalk.h @@ -0,0 +1,295 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_revwalk_h__ +#define INCLUDE_git_revwalk_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" + +/** + * @file git2/revwalk.h + * @brief Git revision traversal routines + * @defgroup git_revwalk Git revision traversal routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Flags to specify the sorting which a revwalk should perform. + */ +typedef enum { + /** + * Sort the repository contents in no particular ordering; + * this sorting is arbitrary, implementation-specific + * and subject to change at any time. + * This is the default sorting for new walkers. + */ + GIT_SORT_NONE = 0, + + /** + * Sort the repository contents in topological order + * (parents before children); this sorting mode + * can be combined with time sorting. + */ + GIT_SORT_TOPOLOGICAL = 1 << 0, + + /** + * Sort the repository contents by commit time; + * this sorting mode can be combined with + * topological sorting. + */ + GIT_SORT_TIME = 1 << 1, + + /** + * Iterate through the repository contents in reverse + * order; this sorting mode can be combined with + * any of the above. + */ + GIT_SORT_REVERSE = 1 << 2, +} git_sort_t; + +/** + * Allocate a new revision walker to iterate through a repo. + * + * This revision walker uses a custom memory pool and an internal + * commit cache, so it is relatively expensive to allocate. + * + * For maximum performance, this revision walker should be + * reused for different walks. + * + * This revision walker is *not* thread safe: it may only be + * used to walk a repository on a single thread; however, + * it is possible to have several revision walkers in + * several different threads walking the same repository. + * + * @param out pointer to the new revision walker + * @param repo the repo to walk through + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo); + +/** + * Reset the revision walker for reuse. + * + * This will clear all the pushed and hidden commits, and + * leave the walker in a blank state (just like at + * creation) ready to receive new commit pushes and + * start a new walk. + * + * The revision walk is automatically reset when a walk + * is over. + * + * @param walker handle to reset. + */ +GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker); + +/** + * Mark a commit to start traversal from. + * + * The given OID must belong to a committish on the walked + * repository. + * + * The given commit will be used as one of the roots + * when starting the revision walk. At least one commit + * must be pushed onto the walker before a walk can + * be started. + * + * @param walk the walker being used for the traversal. + * @param id the oid of the commit to start from. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *id); + +/** + * Push matching references + * + * The OIDs pointed to by the references that match the given glob + * pattern will be pushed to the revision walker. + * + * A leading 'refs/' is implied if not present as well as a trailing + * '/\*' if the glob lacks '?', '\*' or '['. + * + * Any references matching this glob which do not point to a + * committish will be ignored. + * + * @param walk the walker being used for the traversal + * @param glob the glob pattern references should match + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_push_glob(git_revwalk *walk, const char *glob); + +/** + * Push the repository's HEAD + * + * @param walk the walker being used for the traversal + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk); + +/** + * Mark a commit (and its ancestors) uninteresting for the output. + * + * The given OID must belong to a committish on the walked + * repository. + * + * The resolved commit and all its parents will be hidden from the + * output on the revision walk. + * + * @param walk the walker being used for the traversal. + * @param commit_id the oid of commit that will be ignored during the traversal + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *commit_id); + +/** + * Hide matching references. + * + * The OIDs pointed to by the references that match the given glob + * pattern and their ancestors will be hidden from the output on the + * revision walk. + * + * A leading 'refs/' is implied if not present as well as a trailing + * '/\*' if the glob lacks '?', '\*' or '['. + * + * Any references matching this glob which do not point to a + * committish will be ignored. + * + * @param walk the walker being used for the traversal + * @param glob the glob pattern references should match + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_hide_glob(git_revwalk *walk, const char *glob); + +/** + * Hide the repository's HEAD + * + * @param walk the walker being used for the traversal + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_hide_head(git_revwalk *walk); + +/** + * Push the OID pointed to by a reference + * + * The reference must point to a committish. + * + * @param walk the walker being used for the traversal + * @param refname the reference to push + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_push_ref(git_revwalk *walk, const char *refname); + +/** + * Hide the OID pointed to by a reference + * + * The reference must point to a committish. + * + * @param walk the walker being used for the traversal + * @param refname the reference to hide + * @return 0 or an error code + */ +GIT_EXTERN(int) git_revwalk_hide_ref(git_revwalk *walk, const char *refname); + +/** + * Get the next commit from the revision walk. + * + * The initial call to this method is *not* blocking when + * iterating through a repo with a time-sorting mode. + * + * Iterating with Topological or inverted modes makes the initial + * call blocking to preprocess the commit list, but this block should be + * mostly unnoticeable on most repositories (topological preprocessing + * times at 0.3s on the git.git repo). + * + * The revision walker is reset when the walk is over. + * + * @param out Pointer where to store the oid of the next commit + * @param walk the walker to pop the commit from. + * @return 0 if the next commit was found; + * GIT_ITEROVER if there are no commits left to iterate + */ +GIT_EXTERN(int) git_revwalk_next(git_oid *out, git_revwalk *walk); + +/** + * Change the sorting mode when iterating through the + * repository's contents. + * + * Changing the sorting mode resets the walker. + * + * @param walk the walker being used for the traversal. + * @param sort_mode combination of GIT_SORT_XXX flags + */ +GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode); + +/** + * Push and hide the respective endpoints of the given range. + * + * The range should be of the form + * .. + * where each is in the form accepted by 'git_revparse_single'. + * The left-hand commit will be hidden and the right-hand commit pushed. + * + * @param walk the walker being used for the traversal + * @param range the range + * @return 0 or an error code + * + */ +GIT_EXTERN(int) git_revwalk_push_range(git_revwalk *walk, const char *range); + +/** + * Simplify the history by first-parent + * + * No parents other than the first for each commit will be enqueued. + */ +GIT_EXTERN(void) git_revwalk_simplify_first_parent(git_revwalk *walk); + + +/** + * Free a revision walker previously allocated. + * + * @param walk traversal handle to close. If NULL nothing occurs. + */ +GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk); + +/** + * Return the repository on which this walker + * is operating. + * + * @param walk the revision walker + * @return the repository being walked + */ +GIT_EXTERN(git_repository *) git_revwalk_repository(git_revwalk *walk); + +/** + * This is a callback function that user can provide to hide a + * commit and its parents. If the callback function returns non-zero value, + * then this commit and its parents will be hidden. + * + * @param commit_id oid of Commit + * @param payload User-specified pointer to data to be passed as data payload + */ +typedef int(*git_revwalk_hide_cb)( + const git_oid *commit_id, + void *payload); + +/** + * Adds a callback function to hide a commit and its parents + * + * @param walk the revision walker + * @param hide_cb callback function to hide a commit and its parents + * @param payload data payload to be passed to callback function + */ +GIT_EXTERN(int) git_revwalk_add_hide_cb( + git_revwalk *walk, + git_revwalk_hide_cb hide_cb, + void *payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/signature.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/signature.h new file mode 100644 index 000000000..feb1b4073 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/signature.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_signature_h__ +#define INCLUDE_git_signature_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/signature.h + * @brief Git signature creation + * @defgroup git_signature Git signature creation + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new action signature. + * + * Call `git_signature_free()` to free the data. + * + * Note: angle brackets ('<' and '>') characters are not allowed + * to be used in either the `name` or the `email` parameter. + * + * @param out new signature, in case of error NULL + * @param name name of the person + * @param email email of the person + * @param time time when the action happened + * @param offset timezone offset in minutes for the time + * @return 0 or an error code + */ +GIT_EXTERN(int) git_signature_new(git_signature **out, const char *name, const char *email, git_time_t time, int offset); + +/** + * Create a new action signature with a timestamp of 'now'. + * + * Call `git_signature_free()` to free the data. + * + * @param out new signature, in case of error NULL + * @param name name of the person + * @param email email of the person + * @return 0 or an error code + */ +GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const char *email); + +/** + * Create a new action signature with default user and now timestamp. + * + * This looks up the user.name and user.email from the configuration and + * uses the current time as the timestamp, and creates a new signature + * based on that information. It will return GIT_ENOTFOUND if either the + * user.name or user.email are not set. + * + * @param out new signature + * @param repo repository pointer + * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code + */ +GIT_EXTERN(int) git_signature_default(git_signature **out, git_repository *repo); + +/** + * Create a copy of an existing signature. All internal strings are also + * duplicated. + * + * Call `git_signature_free()` to free the data. + * + * @param dest pointer where to store the copy + * @param sig signature to duplicate + * @return 0 or an error code + */ +GIT_EXTERN(int) git_signature_dup(git_signature **dest, const git_signature *sig); + +/** + * Free an existing signature. + * + * Because the signature is not an opaque structure, it is legal to free it + * manually, but be sure to free the "name" and "email" strings in addition + * to the structure itself. + * + * @param sig signature to free + */ +GIT_EXTERN(void) git_signature_free(git_signature *sig); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/stash.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/stash.h new file mode 100644 index 000000000..280c647e8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/stash.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_stash_h__ +#define INCLUDE_git_stash_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/stash.h + * @brief Git stash management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Stash flags + */ +typedef enum { + /** + * No option, default + */ + GIT_STASH_DEFAULT = 0, + + /** + * All changes already added to the index are left intact in + * the working directory + */ + GIT_STASH_KEEP_INDEX = (1 << 0), + + /** + * All untracked files are also stashed and then cleaned up + * from the working directory + */ + GIT_STASH_INCLUDE_UNTRACKED = (1 << 1), + + /** + * All ignored files are also stashed and then cleaned up from + * the working directory + */ + GIT_STASH_INCLUDE_IGNORED = (1 << 2), +} git_stash_flags; + +/** + * Save the local modifications to a new stash. + * + * @param out Object id of the commit containing the stashed state. + * This commit is also the target of the direct reference refs/stash. + * + * @param repo The owning repository. + * + * @param stasher The identity of the person performing the stashing. + * + * @param message Optional description along with the stashed state. + * + * @param flags Flags to control the stashing process. (see GIT_STASH_* above) + * + * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash, + * or error code. + */ +GIT_EXTERN(int) git_stash_save( + git_oid *out, + git_repository *repo, + const git_signature *stasher, + const char *message, + unsigned int flags); + +/** + * This is a callback function you can provide to iterate over all the + * stashed states that will be invoked per entry. + * + * @param index The position within the stash list. 0 points to the + * most recent stashed state. + * @param message The stash message. + * @param stash_id The commit oid of the stashed state. + * @param payload Extra parameter to callback function. + * @return 0 to continue iterating or non-zero to stop + */ +typedef int (*git_stash_cb)( + size_t index, + const char* message, + const git_oid *stash_id, + void *payload); + +/** + * Loop over all the stashed states and issue a callback for each one. + * + * If the callback returns a non-zero value, this will stop looping. + * + * @param repo Repository where to find the stash. + * + * @param callback Callback to invoke per found stashed state. The most + * recent stash state will be enumerated first. + * + * @param payload Extra parameter to callback function. + * + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_stash_foreach( + git_repository *repo, + git_stash_cb callback, + void *payload); + +/** + * Remove a single stashed state from the stash list. + * + * @param repo The owning repository. + * + * @param index The position within the stash list. 0 points to the + * most recent stashed state. + * + * @return 0 on success, or error code + */ + +GIT_EXTERN(int) git_stash_drop( + git_repository *repo, + size_t index); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/status.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/status.h new file mode 100644 index 000000000..5f211810d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/status.h @@ -0,0 +1,369 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_status_h__ +#define INCLUDE_git_status_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/status.h + * @brief Git file status routines + * @defgroup git_status Git file status routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Status flags for a single file. + * + * A combination of these values will be returned to indicate the status of + * a file. Status compares the working directory, the index, and the + * current HEAD of the repository. The `GIT_STATUS_INDEX` set of flags + * represents the status of file in the index relative to the HEAD, and the + * `GIT_STATUS_WT` set of flags represent the status of the file in the + * working directory relative to the index. + */ +typedef enum { + GIT_STATUS_CURRENT = 0, + + GIT_STATUS_INDEX_NEW = (1u << 0), + GIT_STATUS_INDEX_MODIFIED = (1u << 1), + GIT_STATUS_INDEX_DELETED = (1u << 2), + GIT_STATUS_INDEX_RENAMED = (1u << 3), + GIT_STATUS_INDEX_TYPECHANGE = (1u << 4), + + GIT_STATUS_WT_NEW = (1u << 7), + GIT_STATUS_WT_MODIFIED = (1u << 8), + GIT_STATUS_WT_DELETED = (1u << 9), + GIT_STATUS_WT_TYPECHANGE = (1u << 10), + GIT_STATUS_WT_RENAMED = (1u << 11), + GIT_STATUS_WT_UNREADABLE = (1u << 12), + + GIT_STATUS_IGNORED = (1u << 14), +} git_status_t; + +/** + * Function pointer to receive status on individual files + * + * `path` is the relative path to the file from the root of the repository. + * + * `status_flags` is a combination of `git_status_t` values that apply. + * + * `payload` is the value you passed to the foreach function as payload. + */ +typedef int (*git_status_cb)( + const char *path, unsigned int status_flags, void *payload); + +/** + * Select the files on which to report status. + * + * With `git_status_foreach_ext`, this will control which changes get + * callbacks. With `git_status_list_new`, these will control which + * changes are included in the list. + * + * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This roughly + * matches `git status --porcelain` regarding which files are + * included and in what order. + * - GIT_STATUS_SHOW_INDEX_ONLY only gives status based on HEAD to index + * comparison, not looking at working directory changes. + * - GIT_STATUS_SHOW_WORKDIR_ONLY only gives status based on index to + * working directory comparison, not comparing the index to the HEAD. + */ +typedef enum { + GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0, + GIT_STATUS_SHOW_INDEX_ONLY = 1, + GIT_STATUS_SHOW_WORKDIR_ONLY = 2, +} git_status_show_t; + +/** + * Flags to control status callbacks + * + * - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should be made + * on untracked files. These will only be made if the workdir files are + * included in the status "show" option. + * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files get callbacks. + * Again, these callbacks will only be made if the workdir files are + * included in the status "show" option. + * - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback should be + * made even on unmodified files. + * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that submodules should be + * skipped. This only applies if there are no pending typechanges to + * the submodule (either from or to another type). + * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that all files in + * untracked directories should be included. Normally if an entire + * directory is new, then just the top-level directory is included (with + * a trailing slash on the entry name). This flag says to include all + * of the individual files in the directory instead. + * - GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH indicates that the given path + * should be treated as a literal path, and not as a pathspec pattern. + * - GIT_STATUS_OPT_RECURSE_IGNORED_DIRS indicates that the contents of + * ignored directories should be included in the status. This is like + * doing `git ls-files -o -i --exclude-standard` with core git. + * - GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX indicates that rename detection + * should be processed between the head and the index and enables + * the GIT_STATUS_INDEX_RENAMED as a possible status flag. + * - GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR indicates that rename + * detection should be run between the index and the working directory + * and enabled GIT_STATUS_WT_RENAMED as a possible status flag. + * - GIT_STATUS_OPT_SORT_CASE_SENSITIVELY overrides the native case + * sensitivity for the file system and forces the output to be in + * case-sensitive order + * - GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY overrides the native case + * sensitivity for the file system and forces the output to be in + * case-insensitive order + * - GIT_STATUS_OPT_RENAMES_FROM_REWRITES indicates that rename detection + * should include rewritten files + * - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of + * doing a "soft" index reload (i.e. reloading the index data if the + * file on disk has been modified outside libgit2). + * - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache + * in the index for files that are unchanged but have out of date stat + * information in the index. It will result in less work being done on + * subsequent calls to get status. This is mutually exclusive with the + * NO_REFRESH option. + * + * Calling `git_status_foreach()` is like calling the extended version + * with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED, + * and GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS. Those options are bundled + * together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline. + */ +typedef enum { + GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0), + GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1), + GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2), + GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3), + GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4), + GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5), + GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6), + GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1u << 7), + GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1u << 8), + GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1u << 9), + GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10), + GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1u << 11), + GIT_STATUS_OPT_NO_REFRESH = (1u << 12), + GIT_STATUS_OPT_UPDATE_INDEX = (1u << 13), + GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1u << 14), + GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15), +} git_status_opt_t; + +#define GIT_STATUS_OPT_DEFAULTS \ + (GIT_STATUS_OPT_INCLUDE_IGNORED | \ + GIT_STATUS_OPT_INCLUDE_UNTRACKED | \ + GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS) + +/** + * Options to control how `git_status_foreach_ext()` will issue callbacks. + * + * This structure is set so that zeroing it out will give you relatively + * sane defaults. + * + * The `show` value is one of the `git_status_show_t` constants that + * control which files to scan and in what order. + * + * The `flags` value is an OR'ed combination of the `git_status_opt_t` + * values above. + * + * The `pathspec` is an array of path patterns to match (using + * fnmatch-style matching), or just an array of paths to match exactly if + * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags. + */ +typedef struct { + unsigned int version; + git_status_show_t show; + unsigned int flags; + git_strarray pathspec; +} git_status_options; + +#define GIT_STATUS_OPTIONS_VERSION 1 +#define GIT_STATUS_OPTIONS_INIT {GIT_STATUS_OPTIONS_VERSION} + +/** + * Initializes a `git_status_options` with default values. Equivalent to + * creating an instance with GIT_STATUS_OPTIONS_INIT. + * + * @param opts The `git_status_options` instance to initialize. + * @param version Version of struct; pass `GIT_STATUS_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_status_init_options( + git_status_options *opts, + unsigned int version); + +/** + * A status entry, providing the differences between the file as it exists + * in HEAD and the index, and providing the differences between the index + * and the working directory. + * + * The `status` value provides the status flags for this file. + * + * The `head_to_index` value provides detailed information about the + * differences between the file in HEAD and the file in the index. + * + * The `index_to_workdir` value provides detailed information about the + * differences between the file in the index and the file in the + * working directory. + */ +typedef struct { + git_status_t status; + git_diff_delta *head_to_index; + git_diff_delta *index_to_workdir; +} git_status_entry; + + +/** + * Gather file statuses and run a callback for each one. + * + * The callback is passed the path of the file, the status (a combination of + * the `git_status_t` values above) and the `payload` data pointer passed + * into this function. + * + * If the callback returns a non-zero value, this function will stop looping + * and return that value to caller. + * + * @param repo A repository object + * @param callback The function to call on each file + * @param payload Pointer to pass through to callback function + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_status_foreach( + git_repository *repo, + git_status_cb callback, + void *payload); + +/** + * Gather file status information and run callbacks as requested. + * + * This is an extended version of the `git_status_foreach()` API that + * allows for more granular control over which paths will be processed and + * in what order. See the `git_status_options` structure for details + * about the additional controls that this makes available. + * + * Note that if a `pathspec` is given in the `git_status_options` to filter + * the status, then the results from rename detection (if you enable it) may + * not be accurate. To do rename detection properly, this must be called + * with no `pathspec` so that all files can be considered. + * + * @param repo Repository object + * @param opts Status options structure + * @param callback The function to call on each file + * @param payload Pointer to pass through to callback function + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_status_foreach_ext( + git_repository *repo, + const git_status_options *opts, + git_status_cb callback, + void *payload); + +/** + * Get file status for a single file. + * + * This tries to get status for the filename that you give. If no files + * match that name (in either the HEAD, index, or working directory), this + * returns GIT_ENOTFOUND. + * + * If the name matches multiple files (for example, if the `path` names a + * directory or if running on a case- insensitive filesystem and yet the + * HEAD has two entries that both match the path), then this returns + * GIT_EAMBIGUOUS because it cannot give correct results. + * + * This does not do any sort of rename detection. Renames require a set of + * targets and because of the path filtering, there is not enough + * information to check renames correctly. To check file status with rename + * detection, there is no choice but to do a full `git_status_list_new` and + * scan through looking for the path that you are interested in. + * + * @param status_flags Output combination of git_status_t values for file + * @param repo A repository object + * @param path The exact path to retrieve status for relative to the + * repository working directory + * @return 0 on success, GIT_ENOTFOUND if the file is not found in the HEAD, + * index, and work tree, GIT_EAMBIGUOUS if `path` matches multiple files + * or if it refers to a folder, and -1 on other errors. + */ +GIT_EXTERN(int) git_status_file( + unsigned int *status_flags, + git_repository *repo, + const char *path); + +/** + * Gather file status information and populate the `git_status_list`. + * + * Note that if a `pathspec` is given in the `git_status_options` to filter + * the status, then the results from rename detection (if you enable it) may + * not be accurate. To do rename detection properly, this must be called + * with no `pathspec` so that all files can be considered. + * + * @param out Pointer to store the status results in + * @param repo Repository object + * @param opts Status options structure + * @return 0 on success or error code + */ +GIT_EXTERN(int) git_status_list_new( + git_status_list **out, + git_repository *repo, + const git_status_options *opts); + +/** + * Gets the count of status entries in this list. + * + * If there are no changes in status (at least according the options given + * when the status list was created), this can return 0. + * + * @param statuslist Existing status list object + * @return the number of status entries + */ +GIT_EXTERN(size_t) git_status_list_entrycount( + git_status_list *statuslist); + +/** + * Get a pointer to one of the entries in the status list. + * + * The entry is not modifiable and should not be freed. + * + * @param statuslist Existing status list object + * @param idx Position of the entry + * @return Pointer to the entry; NULL if out of bounds + */ +GIT_EXTERN(const git_status_entry *) git_status_byindex( + git_status_list *statuslist, + size_t idx); + +/** + * Free an existing status list + * + * @param statuslist Existing status list object + */ +GIT_EXTERN(void) git_status_list_free( + git_status_list *statuslist); + +/** + * Test if the ignore rules apply to a given file. + * + * This function checks the ignore rules to see if they would apply to the + * given file. This indicates if the file would be ignored regardless of + * whether the file is already in the index or committed to the repository. + * + * One way to think of this is if you were to do "git add ." on the + * directory containing the file, would it be added or not? + * + * @param ignored Boolean returning 0 if the file is not ignored, 1 if it is + * @param repo A repository object + * @param path The file to check ignores for, rooted at the repo's workdir. + * @return 0 if ignore rules could be processed for the file (regardless + * of whether it exists or not), or an error < 0 if they could not. + */ +GIT_EXTERN(int) git_status_should_ignore( + int *ignored, + git_repository *repo, + const char *path); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/stdint.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/stdint.h new file mode 100644 index 000000000..c66fbb817 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/stdint.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/strarray.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/strarray.h new file mode 100644 index 000000000..86fa25f3f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/strarray.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_strarray_h__ +#define INCLUDE_git_strarray_h__ + +#include "common.h" + +/** + * @file git2/strarray.h + * @brief Git string array routines + * @defgroup git_strarray Git string array routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** Array of strings */ +typedef struct git_strarray { + char **strings; + size_t count; +} git_strarray; + +/** + * Close a string array object + * + * This method should be called on `git_strarray` objects where the strings + * array is allocated and contains allocated strings, such as what you + * would get from `git_strarray_copy()`. Not doing so, will result in a + * memory leak. + * + * This does not free the `git_strarray` itself, since the library will + * never allocate that object directly itself (it is more commonly embedded + * inside another struct or created on the stack). + * + * @param array git_strarray from which to free string data + */ +GIT_EXTERN(void) git_strarray_free(git_strarray *array); + +/** + * Copy a string array object from source to target. + * + * Note: target is overwritten and hence should be empty, otherwise its + * contents are leaked. Call git_strarray_free() if necessary. + * + * @param tgt target + * @param src source + * @return 0 on success, < 0 on allocation failure + */ +GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); + + +/** @} */ +GIT_END_DECL + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/submodule.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/submodule.h new file mode 100644 index 000000000..245b2a2c1 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/submodule.h @@ -0,0 +1,650 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_submodule_h__ +#define INCLUDE_git_submodule_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "remote.h" +#include "checkout.h" + +/** + * @file git2/submodule.h + * @brief Git submodule management utilities + * + * Submodule support in libgit2 builds a list of known submodules and keeps + * it in the repository. The list is built from the .gitmodules file, the + * .git/config file, the index, and the HEAD tree. Items in the working + * directory that look like submodules (i.e. a git repo) but are not + * mentioned in those places won't be tracked. + * + * @defgroup git_submodule Git submodule management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Return codes for submodule status. + * + * A combination of these flags will be returned to describe the status of a + * submodule. Depending on the "ignore" property of the submodule, some of + * the flags may never be returned because they indicate changes that are + * supposed to be ignored. + * + * Submodule info is contained in 4 places: the HEAD tree, the index, config + * files (both .git/config and .gitmodules), and the working directory. Any + * or all of those places might be missing information about the submodule + * depending on what state the repo is in. We consider all four places to + * build the combination of status flags. + * + * There are four values that are not really status, but give basic info + * about what sources of submodule data are available. These will be + * returned even if ignore is set to "ALL". + * + * * IN_HEAD - superproject head contains submodule + * * IN_INDEX - superproject index contains submodule + * * IN_CONFIG - superproject gitmodules has submodule + * * IN_WD - superproject workdir has submodule + * + * The following values will be returned so long as ignore is not "ALL". + * + * * INDEX_ADDED - in index, not in head + * * INDEX_DELETED - in head, not in index + * * INDEX_MODIFIED - index and head don't match + * * WD_UNINITIALIZED - workdir contains empty directory + * * WD_ADDED - in workdir, not index + * * WD_DELETED - in index, not workdir + * * WD_MODIFIED - index and workdir head don't match + * + * The following can only be returned if ignore is "NONE" or "UNTRACKED". + * + * * WD_INDEX_MODIFIED - submodule workdir index is dirty + * * WD_WD_MODIFIED - submodule workdir has modified files + * + * Lastly, the following will only be returned for ignore "NONE". + * + * * WD_UNTRACKED - wd contains untracked files + */ +typedef enum { + GIT_SUBMODULE_STATUS_IN_HEAD = (1u << 0), + GIT_SUBMODULE_STATUS_IN_INDEX = (1u << 1), + GIT_SUBMODULE_STATUS_IN_CONFIG = (1u << 2), + GIT_SUBMODULE_STATUS_IN_WD = (1u << 3), + GIT_SUBMODULE_STATUS_INDEX_ADDED = (1u << 4), + GIT_SUBMODULE_STATUS_INDEX_DELETED = (1u << 5), + GIT_SUBMODULE_STATUS_INDEX_MODIFIED = (1u << 6), + GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = (1u << 7), + GIT_SUBMODULE_STATUS_WD_ADDED = (1u << 8), + GIT_SUBMODULE_STATUS_WD_DELETED = (1u << 9), + GIT_SUBMODULE_STATUS_WD_MODIFIED = (1u << 10), + GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = (1u << 11), + GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = (1u << 12), + GIT_SUBMODULE_STATUS_WD_UNTRACKED = (1u << 13), +} git_submodule_status_t; + +#define GIT_SUBMODULE_STATUS__IN_FLAGS 0x000Fu +#define GIT_SUBMODULE_STATUS__INDEX_FLAGS 0x0070u +#define GIT_SUBMODULE_STATUS__WD_FLAGS 0x3F80u + +#define GIT_SUBMODULE_STATUS_IS_UNMODIFIED(S) \ + (((S) & ~GIT_SUBMODULE_STATUS__IN_FLAGS) == 0) + +#define GIT_SUBMODULE_STATUS_IS_INDEX_UNMODIFIED(S) \ + (((S) & GIT_SUBMODULE_STATUS__INDEX_FLAGS) == 0) + +#define GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(S) \ + (((S) & (GIT_SUBMODULE_STATUS__WD_FLAGS & \ + ~GIT_SUBMODULE_STATUS_WD_UNINITIALIZED)) == 0) + +#define GIT_SUBMODULE_STATUS_IS_WD_DIRTY(S) \ + (((S) & (GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED | \ + GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | \ + GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0) + +/** + * Submodule update options structure + * + * Use the GIT_SUBMODULE_UPDATE_OPTIONS_INIT to get the default settings, + * like this: + * + * git_submodule_update_options opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; + */ +typedef struct git_submodule_update_options { + unsigned int version; + + /** + * These options are passed to the checkout step. To disable + * checkout, set the `checkout_strategy` to + * `GIT_CHECKOUT_NONE`. Generally you will want the use + * GIT_CHECKOUT_SAFE to update files in the working + * directory. Use the `clone_checkout_strategy` field + * to set the checkout strategy that will be used in + * the case where update needs to clone the repository. + */ + git_checkout_options checkout_opts; + + /** + * Callbacks to use for reporting fetch progress, and for acquiring + * credentials in the event they are needed. + */ + git_remote_callbacks remote_callbacks; + + /** + * The checkout strategy to use when the sub repository needs to + * be cloned. Use GIT_CHECKOUT_SAFE to create all files + * in the working directory for the newly cloned repository. + */ + unsigned int clone_checkout_strategy; +} git_submodule_update_options; + +#define GIT_SUBMODULE_UPDATE_OPTIONS_VERSION 1 +#define GIT_SUBMODULE_UPDATE_OPTIONS_INIT \ + { GIT_CHECKOUT_OPTIONS_VERSION, \ + { GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }, \ + GIT_REMOTE_CALLBACKS_INIT, GIT_CHECKOUT_SAFE } + +/** + * Initializes a `git_submodule_update_options` with default values. + * Equivalent to creating an instance with GIT_SUBMODULE_UPDATE_OPTIONS_INIT. + * + * @param opts The `git_submodule_update_options` instance to initialize. + * @param version Version of struct; pass `GIT_SUBMODULE_UPDATE_OPTIONS_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_submodule_update_init_options( + git_submodule_update_options *opts, unsigned int version); + +/** + * Update a submodule. This will clone a missing submodule and + * checkout the subrepository to the commit specified in the index of + * containing repository. + * + * @param submodule Submodule object + * @param init If the submodule is not initialized, setting this flag to true + * will initialize the submodule before updating. Otherwise, this will + * return an error if attempting to update an uninitialzed repository. + * but setting this to true forces them to be updated. + * @param options configuration options for the update. If NULL, the + * function works as though GIT_SUBMODULE_UPDATE_OPTIONS_INIT was passed. + * @return 0 on success, any non-zero return value from a callback + * function, or a negative value to indicate an error (use + * `giterr_last` for a detailed error message). + */ +GIT_EXTERN(int) git_submodule_update(git_submodule *submodule, int init, git_submodule_update_options *options); + +/** + * Lookup submodule information by name or path. + * + * Given either the submodule name or path (they are usually the same), this + * returns a structure describing the submodule. + * + * There are two expected error scenarios: + * + * - The submodule is not mentioned in the HEAD, the index, and the config, + * but does "exist" in the working directory (i.e. there is a subdirectory + * that appears to be a Git repository). In this case, this function + * returns GIT_EEXISTS to indicate a sub-repository exists but not in a + * state where a git_submodule can be instantiated. + * - The submodule is not mentioned in the HEAD, index, or config and the + * working directory doesn't contain a value git repo at that path. + * There may or may not be anything else at that path, but nothing that + * looks like a submodule. In this case, this returns GIT_ENOTFOUND. + * + * You must call `git_submodule_free` when done with the submodule. + * + * @param out Output ptr to submodule; pass NULL to just get return code + * @param repo The parent repository + * @param name The name of or path to the submodule; trailing slashes okay + * @return 0 on success, GIT_ENOTFOUND if submodule does not exist, + * GIT_EEXISTS if a repository is found in working directory only, + * -1 on other errors. + */ +GIT_EXTERN(int) git_submodule_lookup( + git_submodule **out, + git_repository *repo, + const char *name); + +/** + * Release a submodule + * + * @param submodule Submodule object + */ +GIT_EXTERN(void) git_submodule_free(git_submodule *submodule); + +/** + * Iterate over all tracked submodules of a repository. + * + * See the note on `git_submodule` above. This iterates over the tracked + * submodules as described therein. + * + * If you are concerned about items in the working directory that look like + * submodules but are not tracked, the diff API will generate a diff record + * for workdir items that look like submodules but are not tracked, showing + * them as added in the workdir. Also, the status API will treat the entire + * subdirectory of a contained git repo as a single GIT_STATUS_WT_NEW item. + * + * @param repo The repository + * @param callback Function to be called with the name of each submodule. + * Return a non-zero value to terminate the iteration. + * @param payload Extra data to pass to callback + * @return 0 on success, -1 on error, or non-zero return value of callback + */ +GIT_EXTERN(int) git_submodule_foreach( + git_repository *repo, + int (*callback)(git_submodule *sm, const char *name, void *payload), + void *payload); + +/** + * Set up a new git submodule for checkout. + * + * This does "git submodule add" up to the fetch and checkout of the + * submodule contents. It preps a new submodule, creates an entry in + * .gitmodules and creates an empty initialized repository either at the + * given path in the working directory or in .git/modules with a gitlink + * from the working directory to the new repo. + * + * To fully emulate "git submodule add" call this function, then open the + * submodule repo and perform the clone step as needed. Lastly, call + * `git_submodule_add_finalize()` to wrap up adding the new submodule and + * .gitmodules to the index to be ready to commit. + * + * You must call `git_submodule_free` on the submodule object when done. + * + * @param out The newly created submodule ready to open for clone + * @param repo The repository in which you want to create the submodule + * @param url URL for the submodule's remote + * @param path Path at which the submodule should be created + * @param use_gitlink Should workdir contain a gitlink to the repo in + * .git/modules vs. repo directly in workdir. + * @return 0 on success, GIT_EEXISTS if submodule already exists, + * -1 on other errors. + */ +GIT_EXTERN(int) git_submodule_add_setup( + git_submodule **out, + git_repository *repo, + const char *url, + const char *path, + int use_gitlink); + +/** + * Resolve the setup of a new git submodule. + * + * This should be called on a submodule once you have called add setup + * and done the clone of the submodule. This adds the .gitmodules file + * and the newly cloned submodule to the index to be ready to be committed + * (but doesn't actually do the commit). + * + * @param submodule The submodule to finish adding. + */ +GIT_EXTERN(int) git_submodule_add_finalize(git_submodule *submodule); + +/** + * Add current submodule HEAD commit to index of superproject. + * + * @param submodule The submodule to add to the index + * @param write_index Boolean if this should immediately write the index + * file. If you pass this as false, you will have to get the + * git_index and explicitly call `git_index_write()` on it to + * save the change. + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_submodule_add_to_index( + git_submodule *submodule, + int write_index); + +/** + * Write submodule settings to .gitmodules file. + * + * This commits any in-memory changes to the submodule to the gitmodules + * file on disk. You may also be interested in `git_submodule_init()` which + * writes submodule info to ".git/config" (which is better for local changes + * to submodule settings) and/or `git_submodule_sync()` which writes + * settings about remotes to the actual submodule repository. + * + * @param submodule The submodule to write. + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_submodule_save(git_submodule *submodule); + +/** + * Get the containing repository for a submodule. + * + * This returns a pointer to the repository that contains the submodule. + * This is a just a reference to the repository that was passed to the + * original `git_submodule_lookup()` call, so if that repository has been + * freed, then this may be a dangling reference. + * + * @param submodule Pointer to submodule object + * @return Pointer to `git_repository` + */ +GIT_EXTERN(git_repository *) git_submodule_owner(git_submodule *submodule); + +/** + * Get the name of submodule. + * + * @param submodule Pointer to submodule object + * @return Pointer to the submodule name + */ +GIT_EXTERN(const char *) git_submodule_name(git_submodule *submodule); + +/** + * Get the path to the submodule. + * + * The path is almost always the same as the submodule name, but the + * two are actually not required to match. + * + * @param submodule Pointer to submodule object + * @return Pointer to the submodule path + */ +GIT_EXTERN(const char *) git_submodule_path(git_submodule *submodule); + +/** + * Get the URL for the submodule. + * + * @param submodule Pointer to submodule object + * @return Pointer to the submodule url + */ +GIT_EXTERN(const char *) git_submodule_url(git_submodule *submodule); + +/** + * Resolve a submodule url relative to the given repository. + * + * @param out buffer to store the absolute submodule url in + * @param repo Pointer to repository object + * @param url Relative url + * @return 0 or an error code + */ +GIT_EXTERN(int) git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *url); + +/** +* Get the branch for the submodule. +* +* @param submodule Pointer to submodule object +* @return Pointer to the submodule branch +*/ +GIT_EXTERN(const char *) git_submodule_branch(git_submodule *submodule); + +/** + * Set the URL for the submodule. + * + * This sets the URL in memory for the submodule. This will be used for + * any following submodule actions while this submodule data is in memory. + * + * After calling this, you may wish to call `git_submodule_save()` to write + * the changes back to the ".gitmodules" file and `git_submodule_sync()` to + * write the changes to the checked out submodule repository. + * + * @param submodule Pointer to the submodule object + * @param url URL that should be used for the submodule + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_submodule_set_url(git_submodule *submodule, const char *url); + +/** + * Get the OID for the submodule in the index. + * + * @param submodule Pointer to submodule object + * @return Pointer to git_oid or NULL if submodule is not in index. + */ +GIT_EXTERN(const git_oid *) git_submodule_index_id(git_submodule *submodule); + +/** + * Get the OID for the submodule in the current HEAD tree. + * + * @param submodule Pointer to submodule object + * @return Pointer to git_oid or NULL if submodule is not in the HEAD. + */ +GIT_EXTERN(const git_oid *) git_submodule_head_id(git_submodule *submodule); + +/** + * Get the OID for the submodule in the current working directory. + * + * This returns the OID that corresponds to looking up 'HEAD' in the checked + * out submodule. If there are pending changes in the index or anything + * else, this won't notice that. You should call `git_submodule_status()` + * for a more complete picture about the state of the working directory. + * + * @param submodule Pointer to submodule object + * @return Pointer to git_oid or NULL if submodule is not checked out. + */ +GIT_EXTERN(const git_oid *) git_submodule_wd_id(git_submodule *submodule); + +/** + * Get the ignore rule that will be used for the submodule. + * + * These values control the behavior of `git_submodule_status()` for this + * submodule. There are four ignore values: + * + * - **GIT_SUBMODULE_IGNORE_NONE** will consider any change to the contents + * of the submodule from a clean checkout to be dirty, including the + * addition of untracked files. This is the default if unspecified. + * - **GIT_SUBMODULE_IGNORE_UNTRACKED** examines the contents of the + * working tree (i.e. call `git_status_foreach()` on the submodule) but + * UNTRACKED files will not count as making the submodule dirty. + * - **GIT_SUBMODULE_IGNORE_DIRTY** means to only check if the HEAD of the + * submodule has moved for status. This is fast since it does not need to + * scan the working tree of the submodule at all. + * - **GIT_SUBMODULE_IGNORE_ALL** means not to open the submodule repo. + * The working directory will be consider clean so long as there is a + * checked out version present. + * + * plus the special **GIT_SUBMODULE_IGNORE_RESET** which can be used with + * `git_submodule_set_ignore()` to revert to the on-disk setting. + * + * @param submodule The submodule to check + * @return The current git_submodule_ignore_t valyue what will be used for + * this submodule. + */ +GIT_EXTERN(git_submodule_ignore_t) git_submodule_ignore( + git_submodule *submodule); + +/** + * Set the ignore rule for the submodule. + * + * This sets the in-memory ignore rule for the submodule which will + * control the behavior of `git_submodule_status()`. + * + * To make changes persistent, call `git_submodule_save()` to write the + * value to disk (in the ".gitmodules" and ".git/config" files). + * + * Call with `GIT_SUBMODULE_IGNORE_RESET` or call `git_submodule_reload()` + * to revert the in-memory rule to the value that is on disk. + * + * @param submodule The submodule to update + * @param ignore The new value for the ignore rule + * @return old value for ignore + */ +GIT_EXTERN(git_submodule_ignore_t) git_submodule_set_ignore( + git_submodule *submodule, + git_submodule_ignore_t ignore); + +/** + * Get the update rule that will be used for the submodule. + * + * This value controls the behavior of the `git submodule update` command. + * There are four useful values documented with `git_submodule_update_t` + * plus the `GIT_SUBMODULE_UPDATE_RESET` which can be used to revert to + * the on-disk setting. + * + * @param submodule The submodule to check + * @return The current git_submodule_update_t value that will be used + * for this submodule. + */ +GIT_EXTERN(git_submodule_update_t) git_submodule_update_strategy( + git_submodule *submodule); + +/** + * Set the update rule for the submodule. + * + * The initial value comes from the ".git/config" setting of + * `submodule.$name.update` for this submodule (which is initialized from + * the ".gitmodules" file). Using this function sets the update rule in + * memory for the submodule. Call `git_submodule_save()` to write out the + * new update rule. + * + * Calling this again with GIT_SUBMODULE_UPDATE_RESET or calling + * `git_submodule_reload()` will revert the rule to the on disk value. + * + * @param submodule The submodule to update + * @param update The new value to use + * @return old value for update + */ +GIT_EXTERN(git_submodule_update_t) git_submodule_set_update( + git_submodule *submodule, + git_submodule_update_t update); + +/** + * Read the fetchRecurseSubmodules rule for a submodule. + * + * This accesses the submodule..fetchRecurseSubmodules value for + * the submodule that controls fetching behavior for the submodule. + * + * Note that at this time, libgit2 does not honor this setting and the + * fetch functionality current ignores submodules. + * + * @return 0 if fetchRecurseSubmodules is false, 1 if true + */ +GIT_EXTERN(git_submodule_recurse_t) git_submodule_fetch_recurse_submodules( + git_submodule *submodule); + +/** + * Set the fetchRecurseSubmodules rule for a submodule. + * + * This sets the submodule..fetchRecurseSubmodules value for + * the submodule. You should call `git_submodule_save()` if you want + * to persist the new value. + * + * @param submodule The submodule to modify + * @param fetch_recurse_submodules Boolean value + * @return old value for fetchRecurseSubmodules + */ +GIT_EXTERN(git_submodule_recurse_t) git_submodule_set_fetch_recurse_submodules( + git_submodule *submodule, + git_submodule_recurse_t fetch_recurse_submodules); + +/** + * Copy submodule info into ".git/config" file. + * + * Just like "git submodule init", this copies information about the + * submodule into ".git/config". You can use the accessor functions + * above to alter the in-memory git_submodule object and control what + * is written to the config, overriding what is in .gitmodules. + * + * @param submodule The submodule to write into the superproject config + * @param overwrite By default, existing entries will not be overwritten, + * but setting this to true forces them to be updated. + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_submodule_init(git_submodule *submodule, int overwrite); + +/** + * Set up the subrepository for a submodule in preparation for clone. + * + * This function can be called to init and set up a submodule + * repository from a submodule in preparation to clone it from + * its remote. + * + * @param out Output pointer to the created git repository. + * @param sm The submodule to create a new subrepository from. + * @param use_gitlink Should the workdir contain a gitlink to + * the repo in .git/modules vs. repo directly in workdir. + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_submodule_repo_init( + git_repository **out, + const git_submodule *sm, + int use_gitlink); + +/** + * Copy submodule remote info into submodule repo. + * + * This copies the information about the submodules URL into the checked out + * submodule config, acting like "git submodule sync". This is useful if + * you have altered the URL for the submodule (or it has been altered by a + * fetch of upstream changes) and you need to update your local repo. + */ +GIT_EXTERN(int) git_submodule_sync(git_submodule *submodule); + +/** + * Open the repository for a submodule. + * + * This is a newly opened repository object. The caller is responsible for + * calling `git_repository_free()` on it when done. Multiple calls to this + * function will return distinct `git_repository` objects. This will only + * work if the submodule is checked out into the working directory. + * + * @param repo Pointer to the submodule repo which was opened + * @param submodule Submodule to be opened + * @return 0 on success, <0 if submodule repo could not be opened. + */ +GIT_EXTERN(int) git_submodule_open( + git_repository **repo, + git_submodule *submodule); + +/** + * Reread submodule info from config, index, and HEAD. + * + * Call this to reread cached submodule information for this submodule if + * you have reason to believe that it has changed. + * + * @param submodule The submodule to reload + * @param force Force reload even if the data doesn't seem out of date + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_submodule_reload(git_submodule *submodule, int force); + +/** + * Reread all submodule info. + * + * Call this to reload all cached submodule information for the repo. + * + * @param repo The repository to reload submodule data for + * @param force Force full reload even if the data doesn't seem out of date + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_submodule_reload_all(git_repository *repo, int force); + +/** + * Get the status for a submodule. + * + * This looks at a submodule and tries to determine the status. It + * will return a combination of the `GIT_SUBMODULE_STATUS` values above. + * How deeply it examines the working directory to do this will depend + * on the `git_submodule_ignore_t` value for the submodule - which can be + * set either temporarily or permanently with `git_submodule_set_ignore()`. + * + * @param status Combination of `GIT_SUBMODULE_STATUS` flags + * @param submodule Submodule for which to get status + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_submodule_status( + unsigned int *status, + git_submodule *submodule); + +/** + * Get the locations of submodule information. + * + * This is a bit like a very lightweight version of `git_submodule_status`. + * It just returns a made of the first four submodule status values (i.e. + * the ones like GIT_SUBMODULE_STATUS_IN_HEAD, etc) that tell you where the + * submodule data comes from (i.e. the HEAD commit, gitmodules file, etc.). + * This can be useful if you want to know if the submodule is present in the + * working directory at this point in time, etc. + * + * @param location_status Combination of first four `GIT_SUBMODULE_STATUS` flags + * @param submodule Submodule for which to get status + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_submodule_location( + unsigned int *location_status, + git_submodule *submodule); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/commit.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/commit.h new file mode 100644 index 000000000..627d3ae2e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/commit.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_commit_h__ +#define INCLUDE_sys_git_commit_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" + +/** + * @file git2/sys/commit.h + * @brief Low-level Git commit creation + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create new commit in the repository from a list of `git_oid` values. + * + * See documentation for `git_commit_create()` for information about the + * parameters, as the meaning is identical excepting that `tree` and + * `parents` now take `git_oid`. This is a dangerous API in that nor + * the `tree`, neither the `parents` list of `git_oid`s are checked for + * validity. + * + * @see git_commit_create + */ +GIT_EXTERN(int) git_commit_create_from_ids( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_oid *tree, + size_t parent_count, + const git_oid *parents[]); + +/** + * Callback function to return parents for commit. + * + * This is invoked with the count of the number of parents processed so far + * along with the user supplied payload. This should return a git_oid of + * the next parent or NULL if all parents have been provided. + */ +typedef const git_oid *(*git_commit_parent_callback)(size_t idx, void *payload); + +/** + * Create a new commit in the repository with an callback to supply parents. + * + * See documentation for `git_commit_create()` for information about the + * parameters, as the meaning is identical excepting that `tree` takes a + * `git_oid` and doesn't check for validity, and `parent_cb` is invoked + * with `parent_payload` and should return `git_oid` values or NULL to + * indicate that all parents are accounted for. + * + * @see git_commit_create + */ +GIT_EXTERN(int) git_commit_create_from_callback( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_oid *tree, + git_commit_parent_callback parent_cb, + void *parent_payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/config.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/config.h new file mode 100644 index 000000000..b5b7df15f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/config.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_config_backend_h__ +#define INCLUDE_sys_git_config_backend_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/config.h" + +/** + * @file git2/sys/config.h + * @brief Git config backend routines + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Every iterator must have this struct as its first element, so the + * API can talk to it. You'd define your iterator as + * + * struct my_iterator { + * git_config_iterator parent; + * ... + * } + * + * and assign `iter->parent.backend` to your `git_config_backend`. + */ +struct git_config_iterator { + git_config_backend *backend; + unsigned int flags; + + /** + * Return the current entry and advance the iterator. The + * memory belongs to the library. + */ + int (*next)(git_config_entry **entry, git_config_iterator *iter); + + /** + * Free the iterator + */ + void (*free)(git_config_iterator *iter); +}; + +/** + * Generic backend that implements the interface to + * access a configuration file + */ +struct git_config_backend { + unsigned int version; + /** True if this backend is for a snapshot */ + int readonly; + struct git_config *cfg; + + /* Open means open the file/database and parse if necessary */ + int (*open)(struct git_config_backend *, git_config_level_t level); + int (*get)(struct git_config_backend *, const char *key, git_config_entry **entry); + int (*set)(struct git_config_backend *, const char *key, const char *value); + int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value); + int (*del)(struct git_config_backend *, const char *key); + int (*del_multivar)(struct git_config_backend *, const char *key, const char *regexp); + int (*iterator)(git_config_iterator **, struct git_config_backend *); + /** Produce a read-only version of this backend */ + int (*snapshot)(struct git_config_backend **, struct git_config_backend *); + void (*free)(struct git_config_backend *); +}; +#define GIT_CONFIG_BACKEND_VERSION 1 +#define GIT_CONFIG_BACKEND_INIT {GIT_CONFIG_BACKEND_VERSION} + +/** + * Initializes a `git_config_backend` with default values. Equivalent to + * creating an instance with GIT_CONFIG_BACKEND_INIT. + * + * @param opts the `git_config_backend` struct to initialize. + * @param version Version of struct; pass `GIT_CONFIG_BACKEND_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_config_init_backend( + git_config_backend *backend, + unsigned int version); + +/** + * Add a generic config file instance to an existing config + * + * Note that the configuration object will free the file + * automatically. + * + * Further queries on this config object will access each + * of the config file instances in order (instances with + * a higher priority level will be accessed first). + * + * @param cfg the configuration to add the file to + * @param file the configuration file (backend) to add + * @param level the priority level of the backend + * @param force if a config file already exists for the given + * priority level, replace it + * @return 0 on success, GIT_EEXISTS when adding more than one file + * for a given priority level (and force_replace set to 0), or error code + */ +GIT_EXTERN(int) git_config_add_backend( + git_config *cfg, + git_config_backend *file, + git_config_level_t level, + int force); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/diff.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/diff.h new file mode 100644 index 000000000..034d5c478 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/diff.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_diff_h__ +#define INCLUDE_sys_git_diff_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" +#include "git2/diff.h" +#include "git2/status.h" + +/** + * @file git2/sys/diff.h + * @brief Low-level Git diff utilities + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Diff print callback that writes to a git_buf. + * + * This function is provided not for you to call it directly, but instead + * so you can use it as a function pointer to the `git_diff_print` or + * `git_patch_print` APIs. When using those APIs, you specify a callback + * to actually handle the diff and/or patch data. + * + * Use this callback to easily write that data to a `git_buf` buffer. You + * must pass a `git_buf *` value as the payload to the `git_diff_print` + * and/or `git_patch_print` function. The data will be appended to the + * buffer (after any existing content). + */ +GIT_EXTERN(int) git_diff_print_callback__to_buf( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *payload); /*< payload must be a `git_buf *` */ + +/** + * Diff print callback that writes to stdio FILE handle. + * + * This function is provided not for you to call it directly, but instead + * so you can use it as a function pointer to the `git_diff_print` or + * `git_patch_print` APIs. When using those APIs, you specify a callback + * to actually handle the diff and/or patch data. + * + * Use this callback to easily write that data to a stdio FILE handle. You + * must pass a `FILE *` value (such as `stdout` or `stderr` or the return + * value from `fopen()`) as the payload to the `git_diff_print` + * and/or `git_patch_print` function. If you pass NULL, this will write + * data to `stdout`. + */ +GIT_EXTERN(int) git_diff_print_callback__to_file_handle( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *payload); /*< payload must be a `FILE *` */ + + +/** + * Performance data from diffing + */ +typedef struct { + unsigned int version; + size_t stat_calls; /*< Number of stat() calls performed */ + size_t oid_calculations; /*< Number of ID calculations */ +} git_diff_perfdata; + +#define GIT_DIFF_PERFDATA_VERSION 1 +#define GIT_DIFF_PERFDATA_INIT {GIT_DIFF_PERFDATA_VERSION,0,0} + +/** + * Get performance data for a diff object. + * + * @param out Structure to be filled with diff performance data + * @param diff Diff to read performance data from + * @return 0 for success, <0 for error + */ +GIT_EXTERN(int) git_diff_get_perfdata( + git_diff_perfdata *out, const git_diff *diff); + +/** + * Get performance data for diffs from a git_status_list + */ +GIT_EXTERN(int) git_status_list_get_perfdata( + git_diff_perfdata *out, const git_status_list *status); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/filter.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/filter.h new file mode 100644 index 000000000..5fd8d5566 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/filter.h @@ -0,0 +1,309 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_filter_h__ +#define INCLUDE_sys_git_filter_h__ + +#include "git2/filter.h" + +/** + * @file git2/sys/filter.h + * @brief Git filter backend and plugin routines + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Look up a filter by name + * + * @param name The name of the filter + * @return Pointer to the filter object or NULL if not found + */ +GIT_EXTERN(git_filter *) git_filter_lookup(const char *name); + +#define GIT_FILTER_CRLF "crlf" +#define GIT_FILTER_IDENT "ident" + +/** + * This is priority that the internal CRLF filter will be registered with + */ +#define GIT_FILTER_CRLF_PRIORITY 0 + +/** + * This is priority that the internal ident filter will be registered with + */ +#define GIT_FILTER_IDENT_PRIORITY 100 + +/** + * This is priority to use with a custom filter to imitate a core Git + * filter driver, so that it will be run last on checkout and first on + * checkin. You do not have to use this, but it helps compatibility. + */ +#define GIT_FILTER_DRIVER_PRIORITY 200 + +/** + * Create a new empty filter list + * + * Normally you won't use this because `git_filter_list_load` will create + * the filter list for you, but you can use this in combination with the + * `git_filter_lookup` and `git_filter_list_push` functions to assemble + * your own chains of filters. + */ +GIT_EXTERN(int) git_filter_list_new( + git_filter_list **out, + git_repository *repo, + git_filter_mode_t mode, + uint32_t options); + +/** + * Add a filter to a filter list with the given payload. + * + * Normally you won't have to do this because the filter list is created + * by calling the "check" function on registered filters when the filter + * attributes are set, but this does allow more direct manipulation of + * filter lists when desired. + * + * Note that normally the "check" function can set up a payload for the + * filter. Using this function, you can either pass in a payload if you + * know the expected payload format, or you can pass NULL. Some filters + * may fail with a NULL payload. Good luck! + */ +GIT_EXTERN(int) git_filter_list_push( + git_filter_list *fl, git_filter *filter, void *payload); + +/** + * Look up how many filters are in the list + * + * We will attempt to apply all of these filters to any data passed in, + * but note that the filter apply action still has the option of skipping + * data that is passed in (for example, the CRLF filter will skip data + * that appears to be binary). + * + * @param fl A filter list + * @return The number of filters in the list + */ +GIT_EXTERN(size_t) git_filter_list_length(const git_filter_list *fl); + +/** + * A filter source represents a file/blob to be processed + */ +typedef struct git_filter_source git_filter_source; + +/** + * Get the repository that the source data is coming from. + */ +GIT_EXTERN(git_repository *) git_filter_source_repo(const git_filter_source *src); + +/** + * Get the path that the source data is coming from. + */ +GIT_EXTERN(const char *) git_filter_source_path(const git_filter_source *src); + +/** + * Get the file mode of the source file + * If the mode is unknown, this will return 0 + */ +GIT_EXTERN(uint16_t) git_filter_source_filemode(const git_filter_source *src); + +/** + * Get the OID of the source + * If the OID is unknown (often the case with GIT_FILTER_CLEAN) then + * this will return NULL. + */ +GIT_EXTERN(const git_oid *) git_filter_source_id(const git_filter_source *src); + +/** + * Get the git_filter_mode_t to be used + */ +GIT_EXTERN(git_filter_mode_t) git_filter_source_mode(const git_filter_source *src); + +/** + * Get the combination git_filter_flag_t options to be applied + */ +GIT_EXTERN(uint32_t) git_filter_source_flags(const git_filter_source *src); + +/* + * struct git_filter + * + * The filter lifecycle: + * - initialize - first use of filter + * - shutdown - filter removed/unregistered from system + * - check - considering filter for file + * - apply - apply filter to file contents + * - cleanup - done with file + */ + +/** + * Initialize callback on filter + * + * Specified as `filter.initialize`, this is an optional callback invoked + * before a filter is first used. It will be called once at most. + * + * If non-NULL, the filter's `initialize` callback will be invoked right + * before the first use of the filter, so you can defer expensive + * initialization operations (in case libgit2 is being used in a way that + * doesn't need the filter). + */ +typedef int (*git_filter_init_fn)(git_filter *self); + +/** + * Shutdown callback on filter + * + * Specified as `filter.shutdown`, this is an optional callback invoked + * when the filter is unregistered or when libgit2 is shutting down. It + * will be called once at most and should release resources as needed. + * This may be called even if the `initialize` callback was not made. + * + * Typically this function will free the `git_filter` object itself. + */ +typedef void (*git_filter_shutdown_fn)(git_filter *self); + +/** + * Callback to decide if a given source needs this filter + * + * Specified as `filter.check`, this is an optional callback that checks + * if filtering is needed for a given source. + * + * It should return 0 if the filter should be applied (i.e. success), + * GIT_PASSTHROUGH if the filter should not be applied, or an error code + * to fail out of the filter processing pipeline and return to the caller. + * + * The `attr_values` will be set to the values of any attributes given in + * the filter definition. See `git_filter` below for more detail. + * + * The `payload` will be a pointer to a reference payload for the filter. + * This will start as NULL, but `check` can assign to this pointer for + * later use by the `apply` callback. Note that the value should be heap + * allocated (not stack), so that it doesn't go away before the `apply` + * callback can use it. If a filter allocates and assigns a value to the + * `payload`, it will need a `cleanup` callback to free the payload. + */ +typedef int (*git_filter_check_fn)( + git_filter *self, + void **payload, /* points to NULL ptr on entry, may be set */ + const git_filter_source *src, + const char **attr_values); + +/** + * Callback to actually perform the data filtering + * + * Specified as `filter.apply`, this is the callback that actually filters + * data. If it successfully writes the output, it should return 0. Like + * `check`, it can return GIT_PASSTHROUGH to indicate that the filter + * doesn't want to run. Other error codes will stop filter processing and + * return to the caller. + * + * The `payload` value will refer to any payload that was set by the + * `check` callback. It may be read from or written to as needed. + */ +typedef int (*git_filter_apply_fn)( + git_filter *self, + void **payload, /* may be read and/or set */ + git_buf *to, + const git_buf *from, + const git_filter_source *src); + +typedef int (*git_filter_stream_fn)( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next); + +/** + * Callback to clean up after filtering has been applied + * + * Specified as `filter.cleanup`, this is an optional callback invoked + * after the filter has been applied. If the `check` or `apply` callbacks + * allocated a `payload` to keep per-source filter state, use this + * callback to free that payload and release resources as required. + */ +typedef void (*git_filter_cleanup_fn)( + git_filter *self, + void *payload); + +/** + * Filter structure used to register custom filters. + * + * To associate extra data with a filter, allocate extra data and put the + * `git_filter` struct at the start of your data buffer, then cast the + * `self` pointer to your larger structure when your callback is invoked. + * + * `version` should be set to GIT_FILTER_VERSION + * + * `attributes` is a whitespace-separated list of attribute names to check + * for this filter (e.g. "eol crlf text"). If the attribute name is bare, + * it will be simply loaded and passed to the `check` callback. If it has + * a value (i.e. "name=value"), the attribute must match that value for + * the filter to be applied. + * + * The `initialize`, `shutdown`, `check`, `apply`, and `cleanup` callbacks + * are all documented above with the respective function pointer typedefs. + */ +struct git_filter { + unsigned int version; + + const char *attributes; + + git_filter_init_fn initialize; + git_filter_shutdown_fn shutdown; + git_filter_check_fn check; + git_filter_apply_fn apply; + git_filter_stream_fn stream; + git_filter_cleanup_fn cleanup; +}; + +#define GIT_FILTER_VERSION 1 + +/** + * Register a filter under a given name with a given priority. + * + * As mentioned elsewhere, the initialize callback will not be invoked + * immediately. It is deferred until the filter is used in some way. + * + * A filter's attribute checks and `check` and `apply` callbacks will be + * issued in order of `priority` on smudge (to workdir), and in reverse + * order of `priority` on clean (to odb). + * + * Two filters are preregistered with libgit2: + * - GIT_FILTER_CRLF with priority 0 + * - GIT_FILTER_IDENT with priority 100 + * + * Currently the filter registry is not thread safe, so any registering or + * deregistering of filters must be done outside of any possible usage of + * the filters (i.e. during application setup or shutdown). + * + * @param name A name by which the filter can be referenced. Attempting + * to register with an in-use name will return GIT_EEXISTS. + * @param filter The filter definition. This pointer will be stored as is + * by libgit2 so it must be a durable allocation (either static + * or on the heap). + * @param priority The priority for filter application + * @return 0 on successful registry, error code <0 on failure + */ +GIT_EXTERN(int) git_filter_register( + const char *name, git_filter *filter, int priority); + +/** + * Remove the filter with the given name + * + * Attempting to remove the builtin libgit2 filters is not permitted and + * will return an error. + * + * Currently the filter registry is not thread safe, so any registering or + * deregistering of filters must be done outside of any possible usage of + * the filters (i.e. during application setup or shutdown). + * + * @param name The name under which the filter was registered + * @return 0 on success, error code <0 on failure + */ +GIT_EXTERN(int) git_filter_unregister(const char *name); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/hashsig.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/hashsig.h new file mode 100644 index 000000000..09c19aec0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/hashsig.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_hashsig_h__ +#define INCLUDE_sys_hashsig_h__ + +#include "git2/common.h" + +GIT_BEGIN_DECL + +/** + * Similarity signature of arbitrary text content based on line hashes + */ +typedef struct git_hashsig git_hashsig; + +/** + * Options for hashsig computation + * + * The options GIT_HASHSIG_NORMAL, GIT_HASHSIG_IGNORE_WHITESPACE, + * GIT_HASHSIG_SMART_WHITESPACE are exclusive and should not be combined. + */ +typedef enum { + /** + * Use all data + */ + GIT_HASHSIG_NORMAL = 0, + + /** + * Ignore whitespace + */ + GIT_HASHSIG_IGNORE_WHITESPACE = (1 << 0), + + /** + * Ignore \r and all space after \n + */ + GIT_HASHSIG_SMART_WHITESPACE = (1 << 1), + + /** + * Allow hashing of small files + */ + GIT_HASHSIG_ALLOW_SMALL_FILES = (1 << 2) +} git_hashsig_option_t; + +/** + * Compute a similarity signature for a text buffer + * + * If you have passed the option GIT_HASHSIG_IGNORE_WHITESPACE, then the + * whitespace will be removed from the buffer while it is being processed, + * modifying the buffer in place. Sorry about that! + * + * @param out The computed similarity signature. + * @param buf The input buffer. + * @param buflen The input buffer size. + * @param opts The signature computation options (see above). + * @return 0 on success, GIT_EBUFS if the buffer doesn't contain enough data to + * compute a valid signature (unless GIT_HASHSIG_ALLOW_SMALL_FILES is set), or + * error code. + */ +GIT_EXTERN(int) git_hashsig_create( + git_hashsig **out, + const char *buf, + size_t buflen, + git_hashsig_option_t opts); + +/** + * Compute a similarity signature for a text file + * + * This walks through the file, only loading a maximum of 4K of file data at + * a time. Otherwise, it acts just like `git_hashsig_create`. + * + * @param out The computed similarity signature. + * @param path The path to the input file. + * @param opts The signature computation options (see above). + * @return 0 on success, GIT_EBUFS if the buffer doesn't contain enough data to + * compute a valid signature (unless GIT_HASHSIG_ALLOW_SMALL_FILES is set), or + * error code. + */ +GIT_EXTERN(int) git_hashsig_create_fromfile( + git_hashsig **out, + const char *path, + git_hashsig_option_t opts); + +/** + * Release memory for a content similarity signature + * + * @param sig The similarity signature to free. + */ +GIT_EXTERN(void) git_hashsig_free(git_hashsig *sig); + +/** + * Measure similarity score between two similarity signatures + * + * @param a The first similarity signature to compare. + * @param b The second similarity signature to compare. + * @return [0 to 100] on success as the similarity score, or error code. + */ +GIT_EXTERN(int) git_hashsig_compare( + const git_hashsig *a, + const git_hashsig *b); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/index.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/index.h new file mode 100644 index 000000000..29a99f798 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/index.h @@ -0,0 +1,177 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_index_h__ +#define INCLUDE_sys_git_index_h__ + +/** + * @file git2/sys/index.h + * @brief Low-level Git index manipulation routines + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** Representation of a rename conflict entry in the index. */ +typedef struct git_index_name_entry { + char *ancestor; + char *ours; + char *theirs; +} git_index_name_entry; + +/** Representation of a resolve undo entry in the index. */ +typedef struct git_index_reuc_entry { + unsigned int mode[3]; + git_oid oid[3]; + char *path; +} git_index_reuc_entry; + +/** @name Conflict Name entry functions + * + * These functions work on rename conflict entries. + */ +/**@{*/ + +/** + * Get the count of filename conflict entries currently in the index. + * + * @param index an existing index object + * @return integer of count of current filename conflict entries + */ +GIT_EXTERN(size_t) git_index_name_entrycount(git_index *index); + +/** + * Get a filename conflict entry from the index. + * + * The returned entry is read-only and should not be modified + * or freed by the caller. + * + * @param index an existing index object + * @param n the position of the entry + * @return a pointer to the filename conflict entry; NULL if out of bounds + */ +GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex( + git_index *index, size_t n); + +/** + * Record the filenames involved in a rename conflict. + * + * @param index an existing index object + * @param ancestor the path of the file as it existed in the ancestor + * @param ours the path of the file as it existed in our tree + * @param theirs the path of the file as it existed in their tree + */ +GIT_EXTERN(int) git_index_name_add(git_index *index, + const char *ancestor, const char *ours, const char *theirs); + +/** + * Remove all filename conflict entries. + * + * @param index an existing index object + */ +GIT_EXTERN(void) git_index_name_clear(git_index *index); + +/**@}*/ + +/** @name Resolve Undo (REUC) index entry manipulation. + * + * These functions work on the Resolve Undo index extension and contains + * data about the original files that led to a merge conflict. + */ +/**@{*/ + +/** + * Get the count of resolve undo entries currently in the index. + * + * @param index an existing index object + * @return integer of count of current resolve undo entries + */ +GIT_EXTERN(size_t) git_index_reuc_entrycount(git_index *index); + +/** + * Finds the resolve undo entry that points to the given path in the Git + * index. + * + * @param at_pos the address to which the position of the reuc entry is written (optional) + * @param index an existing index object + * @param path path to search + * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND) + */ +GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path); + +/** + * Get a resolve undo entry from the index. + * + * The returned entry is read-only and should not be modified + * or freed by the caller. + * + * @param index an existing index object + * @param path path to search + * @return the resolve undo entry; NULL if not found + */ +GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path); + +/** + * Get a resolve undo entry from the index. + * + * The returned entry is read-only and should not be modified + * or freed by the caller. + * + * @param index an existing index object + * @param n the position of the entry + * @return a pointer to the resolve undo entry; NULL if out of bounds + */ +GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n); + +/** + * Adds a resolve undo entry for a file based on the given parameters. + * + * The resolve undo entry contains the OIDs of files that were involved + * in a merge conflict after the conflict has been resolved. This allows + * conflicts to be re-resolved later. + * + * If there exists a resolve undo entry for the given path in the index, + * it will be removed. + * + * This method will fail in bare index instances. + * + * @param index an existing index object + * @param path filename to add + * @param ancestor_mode mode of the ancestor file + * @param ancestor_id oid of the ancestor file + * @param our_mode mode of our file + * @param our_id oid of our file + * @param their_mode mode of their file + * @param their_id oid of their file + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path, + int ancestor_mode, const git_oid *ancestor_id, + int our_mode, const git_oid *our_id, + int their_mode, const git_oid *their_id); + +/** + * Remove an resolve undo entry from the index + * + * @param index an existing index object + * @param n position of the resolve undo entry to remove + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n); + +/** + * Remove all resolve undo entries from the index + * + * @param index an existing index object + */ +GIT_EXTERN(void) git_index_reuc_clear(git_index *index); + +/**@}*/ + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/mempack.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/mempack.h new file mode 100644 index 000000000..96074fb77 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/mempack.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_odb_mempack_h__ +#define INCLUDE_sys_git_odb_mempack_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" +#include "git2/odb.h" + +/** + * @file git2/sys/mempack.h + * @brief Custom ODB backend that permits packing objects in-memory + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Instantiate a new mempack backend. + * + * The backend must be added to an existing ODB with the highest + * priority. + * + * git_mempack_new(&mempacker); + * git_repository_odb(&odb, repository); + * git_odb_add_backend(odb, mempacker, 999); + * + * Once the backend has been loaded, all writes to the ODB will + * instead be queued in memory, and can be finalized with + * `git_mempack_dump`. + * + * Subsequent reads will also be served from the in-memory store + * to ensure consistency, until the memory store is dumped. + * + * @param out Poiter where to store the ODB backend + * @return 0 on success; error code otherwise + */ +int git_mempack_new(git_odb_backend **out); + +/** + * Dump all the queued in-memory writes to a packfile. + * + * The contents of the packfile will be stored in the given buffer. + * It is the caller's responsibility to ensure that the generated + * packfile is available to the repository (e.g. by writing it + * to disk, or doing something crazy like distributing it across + * several copies of the repository over a network). + * + * Once the generated packfile is available to the repository, + * call `git_mempack_reset` to cleanup the memory store. + * + * Calling `git_mempack_reset` before the packfile has been + * written to disk will result in an inconsistent repository + * (the objects in the memory store won't be accessible). + * + * @param pack Buffer where to store the raw packfile + * @param repo The active repository where the backend is loaded + * @param backend The mempack backend + * @return 0 on success; error code otherwise + */ +int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *backend); + +/** + * Reset the memory packer by clearing all the queued objects. + * + * This assumes that `git_mempack_dump` has been called before to + * store all the queued objects into a single packfile. + * + * Alternatively, call `reset` without a previous dump to "undo" + * all the recently written objects, giving transaction-like + * semantics to the Git repository. + * + * @param backend The mempack backend + */ +void git_mempack_reset(git_odb_backend *backend); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/odb_backend.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/odb_backend.h new file mode 100644 index 000000000..1fc3c3159 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/odb_backend.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_odb_backend_h__ +#define INCLUDE_sys_git_odb_backend_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" +#include "git2/odb.h" + +/** + * @file git2/sys/backend.h + * @brief Git custom backend implementors functions + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * An instance for a custom backend + */ +struct git_odb_backend { + unsigned int version; + git_odb *odb; + + /* read and read_prefix each return to libgit2 a buffer which + * will be freed later. The buffer should be allocated using + * the function git_odb_backend_malloc to ensure that it can + * be safely freed later. */ + int (* read)( + void **, size_t *, git_otype *, git_odb_backend *, const git_oid *); + + /* To find a unique object given a prefix of its oid. The oid given + * must be so that the remaining (GIT_OID_HEXSZ - len)*4 bits are 0s. + */ + int (* read_prefix)( + git_oid *, void **, size_t *, git_otype *, + git_odb_backend *, const git_oid *, size_t); + + int (* read_header)( + size_t *, git_otype *, git_odb_backend *, const git_oid *); + + /** + * Write an object into the backend. The id of the object has + * already been calculated and is passed in. + */ + int (* write)( + git_odb_backend *, const git_oid *, const void *, size_t, git_otype); + + int (* writestream)( + git_odb_stream **, git_odb_backend *, size_t, git_otype); + + int (* readstream)( + git_odb_stream **, git_odb_backend *, const git_oid *); + + int (* exists)( + git_odb_backend *, const git_oid *); + + int (* exists_prefix)( + git_oid *, git_odb_backend *, const git_oid *, size_t); + + /** + * If the backend implements a refreshing mechanism, it should be exposed + * through this endpoint. Each call to `git_odb_refresh()` will invoke it. + * + * However, the backend implementation should try to stay up-to-date as much + * as possible by itself as libgit2 will not automatically invoke + * `git_odb_refresh()`. For instance, a potential strategy for the backend + * implementation to achieve this could be to internally invoke this + * endpoint on failed lookups (ie. `exists()`, `read()`, `read_header()`). + */ + int (* refresh)(git_odb_backend *); + + int (* foreach)( + git_odb_backend *, git_odb_foreach_cb cb, void *payload); + + int (* writepack)( + git_odb_writepack **, git_odb_backend *, git_odb *odb, + git_transfer_progress_cb progress_cb, void *progress_payload); + + void (* free)(git_odb_backend *); +}; + +#define GIT_ODB_BACKEND_VERSION 1 +#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION} + +/** + * Initializes a `git_odb_backend` with default values. Equivalent to + * creating an instance with GIT_ODB_BACKEND_INIT. + * + * @param opts the `git_odb_backend` struct to initialize. + * @param version Version the struct; pass `GIT_ODB_BACKEND_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_odb_init_backend( + git_odb_backend *backend, + unsigned int version); + +GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/openssl.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/openssl.h new file mode 100644 index 000000000..b41c55c6d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/openssl.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_openssl_h__ +#define INCLUDE_git_openssl_h__ + +#include "git2/common.h" + +GIT_BEGIN_DECL + +/** + * Initialize the OpenSSL locks + * + * OpenSSL requires the application to determine how it performs + * locking. + * + * This is a last-resort convenience function which libgit2 provides for + * allocating and initializing the locks as well as setting the + * locking function to use the system's native locking functions. + * + * The locking function will be cleared and the memory will be freed + * when you call git_threads_sutdown(). + * + * If your programming language has an OpenSSL package/bindings, it + * likely sets up locking. You should very strongly prefer that over + * this function. + * + * @return 0 on success, -1 if there are errors or if libgit2 was not + * built with OpenSSL and threading support. + */ +GIT_EXTERN(int) git_openssl_set_locking(void); + +GIT_END_DECL +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refdb_backend.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refdb_backend.h new file mode 100644 index 000000000..d943e550f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refdb_backend.h @@ -0,0 +1,217 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_refdb_backend_h__ +#define INCLUDE_sys_git_refdb_backend_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" + +/** + * @file git2/refdb_backend.h + * @brief Git custom refs backend functions + * @defgroup git_refdb_backend Git custom refs backend API + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + + +/** + * Every backend's iterator must have a pointer to itself as the first + * element, so the API can talk to it. You'd define your iterator as + * + * struct my_iterator { + * git_reference_iterator parent; + * ... + * } + * + * and assign `iter->parent.backend` to your `git_refdb_backend`. + */ +struct git_reference_iterator { + git_refdb *db; + + /** + * Return the current reference and advance the iterator. + */ + int (*next)( + git_reference **ref, + git_reference_iterator *iter); + + /** + * Return the name of the current reference and advance the iterator + */ + int (*next_name)( + const char **ref_name, + git_reference_iterator *iter); + + /** + * Free the iterator + */ + void (*free)( + git_reference_iterator *iter); +}; + +/** An instance for a custom backend */ +struct git_refdb_backend { + unsigned int version; + + /** + * Queries the refdb backend to determine if the given ref_name + * exists. A refdb implementation must provide this function. + */ + int (*exists)( + int *exists, + git_refdb_backend *backend, + const char *ref_name); + + /** + * Queries the refdb backend for a given reference. A refdb + * implementation must provide this function. + */ + int (*lookup)( + git_reference **out, + git_refdb_backend *backend, + const char *ref_name); + + /** + * Allocate an iterator object for the backend. + * + * A refdb implementation must provide this function. + */ + int (*iterator)( + git_reference_iterator **iter, + struct git_refdb_backend *backend, + const char *glob); + + /* + * Writes the given reference to the refdb. A refdb implementation + * must provide this function. + */ + int (*write)(git_refdb_backend *backend, + const git_reference *ref, int force, + const git_signature *who, const char *message, + const git_oid *old, const char *old_target); + + int (*rename)( + git_reference **out, git_refdb_backend *backend, + const char *old_name, const char *new_name, int force, + const git_signature *who, const char *message); + + /** + * Deletes the given reference from the refdb. A refdb implementation + * must provide this function. + */ + int (*del)(git_refdb_backend *backend, const char *ref_name, const git_oid *old_id, const char *old_target); + + /** + * Suggests that the given refdb compress or optimize its references. + * This mechanism is implementation specific. (For on-disk reference + * databases, this may pack all loose references.) A refdb + * implementation may provide this function; if it is not provided, + * nothing will be done. + */ + int (*compress)(git_refdb_backend *backend); + + /** + * Query whether a particular reference has a log (may be empty) + */ + int (*has_log)(git_refdb_backend *backend, const char *refname); + + /** + * Make sure a particular reference will have a reflog which + * will be appended to on writes. + */ + int (*ensure_log)(git_refdb_backend *backend, const char *refname); + + /** + * Frees any resources held by the refdb. A refdb implementation may + * provide this function; if it is not provided, nothing will be done. + */ + void (*free)(git_refdb_backend *backend); + + /** + * Read the reflog for the given reference name. + */ + int (*reflog_read)(git_reflog **out, git_refdb_backend *backend, const char *name); + + /** + * Write a reflog to disk. + */ + int (*reflog_write)(git_refdb_backend *backend, git_reflog *reflog); + + /** + * Rename a reflog + */ + int (*reflog_rename)(git_refdb_backend *_backend, const char *old_name, const char *new_name); + + /** + * Remove a reflog. + */ + int (*reflog_delete)(git_refdb_backend *backend, const char *name); + + /** + * Lock a reference. The opaque parameter will be passed to the unlock function + */ + int (*lock)(void **payload_out, git_refdb_backend *backend, const char *refname); + + /** + * Unlock a reference. Only one of target or symbolic_target + * will be set. success indicates whether to update the + * reference or discard the lock (if it's false) + */ + int (*unlock)(git_refdb_backend *backend, void *payload, int success, int update_reflog, + const git_reference *ref, const git_signature *sig, const char *message); +}; + +#define GIT_REFDB_BACKEND_VERSION 1 +#define GIT_REFDB_BACKEND_INIT {GIT_REFDB_BACKEND_VERSION} + +/** + * Initializes a `git_refdb_backend` with default values. Equivalent to + * creating an instance with GIT_REFDB_BACKEND_INIT. + * + * @param opts the `git_refdb_backend` struct to initialize + * @param version Version of struct; pass `GIT_REFDB_BACKEND_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_refdb_init_backend( + git_refdb_backend *backend, + unsigned int version); + +/** + * Constructors for default filesystem-based refdb backend + * + * Under normal usage, this is called for you when the repository is + * opened / created, but you can use this to explicitly construct a + * filesystem refdb backend for a repository. + * + * @param backend_out Output pointer to the git_refdb_backend object + * @param repo Git repository to access + * @return 0 on success, <0 error code on failure + */ +GIT_EXTERN(int) git_refdb_backend_fs( + git_refdb_backend **backend_out, + git_repository *repo); + +/** + * Sets the custom backend to an existing reference DB + * + * The `git_refdb` will take ownership of the `git_refdb_backend` so you + * should NOT free it after calling this function. + * + * @param refdb database to add the backend to + * @param backend pointer to a git_refdb_backend instance + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_refdb_set_backend( + git_refdb *refdb, + git_refdb_backend *backend); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/reflog.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/reflog.h new file mode 100644 index 000000000..c9d0041b9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/reflog.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_reflog_h__ +#define INCLUDE_sys_git_reflog_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" + +GIT_BEGIN_DECL + +GIT_EXTERN(git_reflog_entry *) git_reflog_entry__alloc(void); +GIT_EXTERN(void) git_reflog_entry__free(git_reflog_entry *entry); + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refs.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refs.h new file mode 100644 index 000000000..d2ce2e0b9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/refs.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_refdb_h__ +#define INCLUDE_sys_git_refdb_h__ + +#include "git2/common.h" +#include "git2/types.h" +#include "git2/oid.h" + +/** + * @file git2/sys/refs.h + * @brief Low-level Git ref creation + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new direct reference from an OID. + * + * @param name the reference name + * @param oid the object id for a direct reference + * @param peel the first non-tag object's OID, or NULL + * @return the created git_reference or NULL on error + */ +GIT_EXTERN(git_reference *) git_reference__alloc( + const char *name, + const git_oid *oid, + const git_oid *peel); + +/** + * Create a new symbolic reference. + * + * @param name the reference name + * @param target the target for a symbolic reference + * @return the created git_reference or NULL on error + */ +GIT_EXTERN(git_reference *) git_reference__alloc_symbolic( + const char *name, + const char *target); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/repository.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/repository.h new file mode 100644 index 000000000..800396c86 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/repository.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_repository_h__ +#define INCLUDE_sys_git_repository_h__ + +#include "git2/common.h" +#include "git2/types.h" + +/** + * @file git2/sys/repository.h + * @brief Git repository custom implementation routines + * @defgroup git_backend Git custom backend APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new repository with neither backends nor config object + * + * Note that this is only useful if you wish to associate the repository + * with a non-filesystem-backed object database and config store. + * + * @param out The blank repository + * @return 0 on success, or an error code + */ +GIT_EXTERN(int) git_repository_new(git_repository **out); + +/** + * Reset all the internal state in a repository. + * + * This will free all the mapped memory and internal objects + * of the repository and leave it in a "blank" state. + * + * There's no need to call this function directly unless you're + * trying to aggressively cleanup the repo before its + * deallocation. `git_repository_free` already performs this operation + * before deallocation the repo. + */ +GIT_EXTERN(void) git_repository__cleanup(git_repository *repo); + +/** + * Update the filesystem config settings for an open repository + * + * When a repository is initialized, config values are set based on the + * properties of the filesystem that the repository is on, such as + * "core.ignorecase", "core.filemode", "core.symlinks", etc. If the + * repository is moved to a new filesystem, these properties may no + * longer be correct and API calls may not behave as expected. This + * call reruns the phase of repository initialization that sets those + * properties to compensate for the current filesystem of the repo. + * + * @param repo A repository object + * @param recurse_submodules Should submodules be updated recursively + * @return 0 on success, < 0 on error + */ +GIT_EXTERN(int) git_repository_reinit_filesystem( + git_repository *repo, + int recurse_submodules); + +/** + * Set the configuration file for this repository + * + * This configuration file will be used for all configuration + * queries involving this repository. + * + * The repository will keep a reference to the config file; + * the user must still free the config after setting it + * to the repository, or it will leak. + * + * @param repo A repository object + * @param config A Config object + */ +GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config); + +/** + * Set the Object Database for this repository + * + * The ODB will be used for all object-related operations + * involving this repository. + * + * The repository will keep a reference to the ODB; the user + * must still free the ODB object after setting it to the + * repository, or it will leak. + * + * @param repo A repository object + * @param odb An ODB object + */ +GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb); + +/** + * Set the Reference Database Backend for this repository + * + * The refdb will be used for all reference related operations + * involving this repository. + * + * The repository will keep a reference to the refdb; the user + * must still free the refdb object after setting it to the + * repository, or it will leak. + * + * @param repo A repository object + * @param refdb An refdb object + */ +GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb); + +/** + * Set the index file for this repository + * + * This index will be used for all index-related operations + * involving this repository. + * + * The repository will keep a reference to the index file; + * the user must still free the index after setting it + * to the repository, or it will leak. + * + * @param repo A repository object + * @param index An index object + */ +GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index); + +/** + * Set a repository to be bare. + * + * Clear the working directory and set core.bare to true. You may also + * want to call `git_repository_set_index(repo, NULL)` since a bare repo + * typically does not have an index, but this function will not do that + * for you. + * + * @param repo Repo to make bare + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_repository_set_bare(git_repository *repo); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/stream.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/stream.h new file mode 100644 index 000000000..c22179fab --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/stream.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_stream_h__ +#define INCLUDE_sys_git_stream_h__ + +#include "git2/common.h" +#include "git2/types.h" + +GIT_BEGIN_DECL + +#define GIT_STREAM_VERSION 1 + +/** + * Every stream must have this struct as its first element, so the + * API can talk to it. You'd define your stream as + * + * struct my_stream { + * git_stream parent; + * ... + * } + * + * and fill the functions + */ +typedef struct git_stream { + int version; + + int encrypted; + int (*connect)(struct git_stream *); + int (*certificate)(git_cert **, struct git_stream *); + ssize_t (*read)(struct git_stream *, void *, size_t); + ssize_t (*write)(struct git_stream *, const char *, size_t, int); + int (*close)(struct git_stream *); + void (*free)(struct git_stream *); +} git_stream; + +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/transport.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/transport.h new file mode 100644 index 000000000..2cb1a97eb --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/sys/transport.h @@ -0,0 +1,373 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_sys_git_transport_h +#define INCLUDE_sys_git_transport_h + +#include "git2/net.h" +#include "git2/types.h" + +/** + * @file git2/sys/transport.h + * @brief Git custom transport registration interfaces and functions + * @defgroup git_transport Git custom transport registration + * @ingroup Git + * @{ + */ + +GIT_BEGIN_DECL + +/** + * Flags to pass to transport + * + * Currently unused. + */ +typedef enum { + GIT_TRANSPORTFLAGS_NONE = 0, +} git_transport_flags_t; + +typedef struct git_transport git_transport; + +struct git_transport { + unsigned int version; + /* Set progress and error callbacks */ + int (*set_callbacks)( + git_transport *transport, + git_transport_message_cb progress_cb, + git_transport_message_cb error_cb, + git_transport_certificate_check_cb certificate_check_cb, + void *payload); + + /* Connect the transport to the remote repository, using the given + * direction. */ + int (*connect)( + git_transport *transport, + const char *url, + git_cred_acquire_cb cred_acquire_cb, + void *cred_acquire_payload, + int direction, + int flags); + + /* This function may be called after a successful call to + * connect(). The array returned is owned by the transport and + * is guaranteed until the next call of a transport function. */ + int (*ls)( + const git_remote_head ***out, + size_t *size, + git_transport *transport); + + /* Executes the push whose context is in the git_push object. */ + int (*push)(git_transport *transport, git_push *push); + + /* This function may be called after a successful call to connect(), when + * the direction is FETCH. The function performs a negotiation to calculate + * the wants list for the fetch. */ + int (*negotiate_fetch)( + git_transport *transport, + git_repository *repo, + const git_remote_head * const *refs, + size_t count); + + /* This function may be called after a successful call to negotiate_fetch(), + * when the direction is FETCH. This function retrieves the pack file for + * the fetch from the remote end. */ + int (*download_pack)( + git_transport *transport, + git_repository *repo, + git_transfer_progress *stats, + git_transfer_progress_cb progress_cb, + void *progress_payload); + + /* Checks to see if the transport is connected */ + int (*is_connected)(git_transport *transport); + + /* Reads the flags value previously passed into connect() */ + int (*read_flags)(git_transport *transport, int *flags); + + /* Cancels any outstanding transport operation */ + void (*cancel)(git_transport *transport); + + /* This function is the reverse of connect() -- it terminates the + * connection to the remote end. */ + int (*close)(git_transport *transport); + + /* Frees/destructs the git_transport object. */ + void (*free)(git_transport *transport); +}; + +#define GIT_TRANSPORT_VERSION 1 +#define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION} + +/** + * Initializes a `git_transport` with default values. Equivalent to + * creating an instance with GIT_TRANSPORT_INIT. + * + * @param opts the `git_transport` struct to initialize + * @param version Version of struct; pass `GIT_TRANSPORT_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_transport_init( + git_transport *opts, + unsigned int version); + +/** + * Function to use to create a transport from a URL. The transport database + * is scanned to find a transport that implements the scheme of the URI (i.e. + * git:// or http://) and a transport object is returned to the caller. + * + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport + * @param url The URL to connect to + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url); + +/** + * Create an ssh transport with custom git command paths + * + * This is a factory function suitable for setting as the transport + * callback in a remote (or for a clone in the options). + * + * The payload argument must be a strarray pointer with the paths for + * the `git-upload-pack` and `git-receive-pack` at index 0 and 1. + * + * @param out the resulting transport + * @param owner the owning remote + * @param payload a strarray with the paths + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload); + +/* Signature of a function which creates a transport */ +typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param); + +/** + * Add a custom transport definition, to be used in addition to the built-in + * set of transports that come with libgit2. + * + * The caller is responsible for synchronizing calls to git_transport_register + * and git_transport_unregister with other calls to the library that + * instantiate transports. + * + * @param prefix The scheme (ending in "://") to match, i.e. "git://" + * @param cb The callback used to create an instance of the transport + * @param param A fixed parameter to pass to cb at creation time + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_register( + const char *prefix, + git_transport_cb cb, + void *param); + +/** + * + * Unregister a custom transport definition which was previously registered + * with git_transport_register. + * + * @param prefix From the previous call to git_transport_register + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_unregister( + const char *prefix); + +/* Transports which come with libgit2 (match git_transport_cb). The expected + * value for "param" is listed in-line below. */ + +/** + * Create an instance of the dummy transport. + * + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport + * @param payload You must pass NULL for this parameter. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_dummy( + git_transport **out, + git_remote *owner, + /* NULL */ void *payload); + +/** + * Create an instance of the local transport. + * + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport + * @param payload You must pass NULL for this parameter. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_local( + git_transport **out, + git_remote *owner, + /* NULL */ void *payload); + +/** + * Create an instance of the smart transport. + * + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport + * @param payload A pointer to a git_smart_subtransport_definition + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transport_smart( + git_transport **out, + git_remote *owner, + /* (git_smart_subtransport_definition *) */ void *payload); + +/* + *** End of base transport interface *** + *** Begin interface for subtransports for the smart transport *** + */ + +/* The smart transport knows how to speak the git protocol, but it has no + * knowledge of how to establish a connection between it and another endpoint, + * or how to move data back and forth. For this, a subtransport interface is + * declared, and the smart transport delegates this work to the subtransports. + * Three subtransports are implemented: git, http, and winhttp. (The http and + * winhttp transports each implement both http and https.) */ + +/* Subtransports can either be RPC = 0 (persistent connection) or RPC = 1 + * (request/response). The smart transport handles the differences in its own + * logic. The git subtransport is RPC = 0, while http and winhttp are both + * RPC = 1. */ + +/* Actions that the smart transport can ask + * a subtransport to perform */ +typedef enum { + GIT_SERVICE_UPLOADPACK_LS = 1, + GIT_SERVICE_UPLOADPACK = 2, + GIT_SERVICE_RECEIVEPACK_LS = 3, + GIT_SERVICE_RECEIVEPACK = 4, +} git_smart_service_t; + +typedef struct git_smart_subtransport git_smart_subtransport; +typedef struct git_smart_subtransport_stream git_smart_subtransport_stream; + +/* A stream used by the smart transport to read and write data + * from a subtransport */ +struct git_smart_subtransport_stream { + /* The owning subtransport */ + git_smart_subtransport *subtransport; + + int (*read)( + git_smart_subtransport_stream *stream, + char *buffer, + size_t buf_size, + size_t *bytes_read); + + int (*write)( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len); + + void (*free)( + git_smart_subtransport_stream *stream); +}; + +/* An implementation of a subtransport which carries data for the + * smart transport */ +struct git_smart_subtransport { + int (* action)( + git_smart_subtransport_stream **out, + git_smart_subtransport *transport, + const char *url, + git_smart_service_t action); + + /* Subtransports are guaranteed a call to close() between + * calls to action(), except for the following two "natural" progressions + * of actions against a constant URL. + * + * 1. UPLOADPACK_LS -> UPLOADPACK + * 2. RECEIVEPACK_LS -> RECEIVEPACK */ + int (*close)(git_smart_subtransport *transport); + + void (*free)(git_smart_subtransport *transport); +}; + +/* A function which creates a new subtransport for the smart transport */ +typedef int (*git_smart_subtransport_cb)( + git_smart_subtransport **out, + git_transport* owner, + void* param); + +/** + * Definition for a "subtransport" + * + * This is used to let the smart protocol code know about the protocol + * which you are implementing. + */ +typedef struct git_smart_subtransport_definition { + /** The function to use to create the git_smart_subtransport */ + git_smart_subtransport_cb callback; + + /** + * True if the protocol is stateless; false otherwise. For example, + * http:// is stateless, but git:// is not. + */ + unsigned rpc; + + /** Param of the callback + */ + void* param; +} git_smart_subtransport_definition; + +/* Smart transport subtransports that come with libgit2 */ + +/** + * Create an instance of the http subtransport. This subtransport + * also supports https. On Win32, this subtransport may be implemented + * using the WinHTTP library. + * + * @param out The newly created subtransport + * @param owner The smart transport to own this subtransport + * @return 0 or an error code + */ +GIT_EXTERN(int) git_smart_subtransport_http( + git_smart_subtransport **out, + git_transport* owner, + void *param); + +/** + * Create an instance of the git subtransport. + * + * @param out The newly created subtransport + * @param owner The smart transport to own this subtransport + * @return 0 or an error code + */ +GIT_EXTERN(int) git_smart_subtransport_git( + git_smart_subtransport **out, + git_transport* owner, + void *param); + +/** + * Create an instance of the ssh subtransport. + * + * @param out The newly created subtransport + * @param owner The smart transport to own this subtransport + * @return 0 or an error code + */ +GIT_EXTERN(int) git_smart_subtransport_ssh( + git_smart_subtransport **out, + git_transport* owner, + void *param); + +/** + * Sets a custom transport factory for the remote. The caller can use this + * function to override the transport used for this remote when performing + * network operations. + * + * @param remote the remote to configure + * @param transport_cb the function to use to create a transport + * @param payload opaque parameter passed to transport_cb + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_set_transport( + git_remote *remote, + git_transport_cb transport_cb, + void *payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/tag.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/tag.h new file mode 100644 index 000000000..c822cee7c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/tag.h @@ -0,0 +1,352 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_tag_h__ +#define INCLUDE_git_tag_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "object.h" +#include "strarray.h" + +/** + * @file git2/tag.h + * @brief Git tag parsing routines + * @defgroup git_tag Git tag management + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Lookup a tag object from the repository. + * + * @param out pointer to the looked up tag + * @param repo the repo to use when locating the tag. + * @param id identity of the tag to locate. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tag_lookup( + git_tag **out, git_repository *repo, const git_oid *id); + +/** + * Lookup a tag object from the repository, + * given a prefix of its identifier (short id). + * + * @see git_object_lookup_prefix + * + * @param out pointer to the looked up tag + * @param repo the repo to use when locating the tag. + * @param id identity of the tag to locate. + * @param len the length of the short identifier + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tag_lookup_prefix( + git_tag **out, git_repository *repo, const git_oid *id, size_t len); + +/** + * Close an open tag + * + * You can no longer use the git_tag pointer after this call. + * + * IMPORTANT: You MUST call this method when you are through with a tag to + * release memory. Failure to do so will cause a memory leak. + * + * @param tag the tag to close + */ +GIT_EXTERN(void) git_tag_free(git_tag *tag); + +/** + * Get the id of a tag. + * + * @param tag a previously loaded tag. + * @return object identity for the tag. + */ +GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag); + +/** + * Get the repository that contains the tag. + * + * @param tag A previously loaded tag. + * @return Repository that contains this tag. + */ +GIT_EXTERN(git_repository *) git_tag_owner(const git_tag *tag); + +/** + * Get the tagged object of a tag + * + * This method performs a repository lookup for the + * given object and returns it + * + * @param target_out pointer where to store the target + * @param tag a previously loaded tag. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tag_target(git_object **target_out, const git_tag *tag); + +/** + * Get the OID of the tagged object of a tag + * + * @param tag a previously loaded tag. + * @return pointer to the OID + */ +GIT_EXTERN(const git_oid *) git_tag_target_id(const git_tag *tag); + +/** + * Get the type of a tag's tagged object + * + * @param tag a previously loaded tag. + * @return type of the tagged object + */ +GIT_EXTERN(git_otype) git_tag_target_type(const git_tag *tag); + +/** + * Get the name of a tag + * + * @param tag a previously loaded tag. + * @return name of the tag + */ +GIT_EXTERN(const char *) git_tag_name(const git_tag *tag); + +/** + * Get the tagger (author) of a tag + * + * @param tag a previously loaded tag. + * @return reference to the tag's author or NULL when unspecified + */ +GIT_EXTERN(const git_signature *) git_tag_tagger(const git_tag *tag); + +/** + * Get the message of a tag + * + * @param tag a previously loaded tag. + * @return message of the tag or NULL when unspecified + */ +GIT_EXTERN(const char *) git_tag_message(const git_tag *tag); + + +/** + * Create a new tag in the repository from an object + * + * A new reference will also be created pointing to + * this tag object. If `force` is true and a reference + * already exists with the given name, it'll be replaced. + * + * The message will not be cleaned up. This can be achieved + * through `git_message_prettify()`. + * + * The tag name will be checked for validity. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * @param oid Pointer where to store the OID of the + * newly created tag. If the tag already exists, this parameter + * will be the oid of the existing tag, and the function will + * return a GIT_EEXISTS error code. + * + * @param repo Repository where to store the tag + * + * @param tag_name Name for the tag; this name is validated + * for consistency. It should also not conflict with an + * already existing tag name + * + * @param target Object to which this tag points. This object + * must belong to the given `repo`. + * + * @param tagger Signature of the tagger for this tag, and + * of the tagging time + * + * @param message Full message for this tag + * + * @param force Overwrite existing references + * + * @return 0 on success, GIT_EINVALIDSPEC or an error code + * A tag object is written to the ODB, and a proper reference + * is written in the /refs/tags folder, pointing to it + */ +GIT_EXTERN(int) git_tag_create( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message, + int force); + +/** + * Create a new tag in the object database pointing to a git_object + * + * The message will not be cleaned up. This can be achieved + * through `git_message_prettify()`. + * + * @param oid Pointer where to store the OID of the + * newly created tag + * + * @param repo Repository where to store the tag + * + * @param tag_name Name for the tag + * + * @param target Object to which this tag points. This object + * must belong to the given `repo`. + * + * @param tagger Signature of the tagger for this tag, and + * of the tagging time + * + * @param message Full message for this tag + * + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_tag_annotation_create( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message); + +/** + * Create a new tag in the repository from a buffer + * + * @param oid Pointer where to store the OID of the newly created tag + * @param repo Repository where to store the tag + * @param buffer Raw tag data + * @param force Overwrite existing tags + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_tag_create_frombuffer( + git_oid *oid, + git_repository *repo, + const char *buffer, + int force); + +/** + * Create a new lightweight tag pointing at a target object + * + * A new direct reference will be created pointing to + * this target object. If `force` is true and a reference + * already exists with the given name, it'll be replaced. + * + * The tag name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param oid Pointer where to store the OID of the provided + * target object. If the tag already exists, this parameter + * will be filled with the oid of the existing pointed object + * and the function will return a GIT_EEXISTS error code. + * + * @param repo Repository where to store the lightweight tag + * + * @param tag_name Name for the tag; this name is validated + * for consistency. It should also not conflict with an + * already existing tag name + * + * @param target Object to which this tag points. This object + * must belong to the given `repo`. + * + * @param force Overwrite existing references + * + * @return 0 on success, GIT_EINVALIDSPEC or an error code + * A proper reference is written in the /refs/tags folder, + * pointing to the provided target object + */ +GIT_EXTERN(int) git_tag_create_lightweight( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + int force); + +/** + * Delete an existing tag reference. + * + * The tag name will be checked for validity. + * See `git_tag_create()` for rules about valid names. + * + * @param repo Repository where lives the tag + * + * @param tag_name Name of the tag to be deleted; + * this name is validated for consistency. + * + * @return 0 on success, GIT_EINVALIDSPEC or an error code + */ +GIT_EXTERN(int) git_tag_delete( + git_repository *repo, + const char *tag_name); + +/** + * Fill a list with all the tags in the Repository + * + * The string array will be filled with the names of the + * matching tags; these values are owned by the user and + * should be free'd manually when no longer needed, using + * `git_strarray_free`. + * + * @param tag_names Pointer to a git_strarray structure where + * the tag names will be stored + * @param repo Repository where to find the tags + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tag_list( + git_strarray *tag_names, + git_repository *repo); + +/** + * Fill a list with all the tags in the Repository + * which name match a defined pattern + * + * If an empty pattern is provided, all the tags + * will be returned. + * + * The string array will be filled with the names of the + * matching tags; these values are owned by the user and + * should be free'd manually when no longer needed, using + * `git_strarray_free`. + * + * @param tag_names Pointer to a git_strarray structure where + * the tag names will be stored + * @param pattern Standard fnmatch pattern + * @param repo Repository where to find the tags + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tag_list_match( + git_strarray *tag_names, + const char *pattern, + git_repository *repo); + + +typedef int (*git_tag_foreach_cb)(const char *name, git_oid *oid, void *payload); + +/** + * Call callback `cb' for each tag in the repository + * + * @param repo Repository + * @param callback Callback function + * @param payload Pointer to callback data (optional) + */ +GIT_EXTERN(int) git_tag_foreach( + git_repository *repo, + git_tag_foreach_cb callback, + void *payload); + + +/** + * Recursively peel a tag until a non tag git_object is found + * + * The retrieved `tag_target` object is owned by the repository + * and should be closed with the `git_object_free` method. + * + * @param tag_target_out Pointer to the peeled git_object + * @param tag The tag to be processed + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tag_peel( + git_object **tag_target_out, + const git_tag *tag); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/trace.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/trace.h new file mode 100644 index 000000000..f9b4d6ff6 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/trace.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_trace_h__ +#define INCLUDE_git_trace_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/trace.h + * @brief Git tracing configuration routines + * @defgroup git_trace Git tracing configuration routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Available tracing levels. When tracing is set to a particular level, + * callers will be provided tracing at the given level and all lower levels. + */ +typedef enum { + /** No tracing will be performed. */ + GIT_TRACE_NONE = 0, + + /** Severe errors that may impact the program's execution */ + GIT_TRACE_FATAL = 1, + + /** Errors that do not impact the program's execution */ + GIT_TRACE_ERROR = 2, + + /** Warnings that suggest abnormal data */ + GIT_TRACE_WARN = 3, + + /** Informational messages about program execution */ + GIT_TRACE_INFO = 4, + + /** Detailed data that allows for debugging */ + GIT_TRACE_DEBUG = 5, + + /** Exceptionally detailed debugging data */ + GIT_TRACE_TRACE = 6 +} git_trace_level_t; + +/** + * An instance for a tracing function + */ +typedef void (*git_trace_callback)(git_trace_level_t level, const char *msg); + +/** + * Sets the system tracing configuration to the specified level with the + * specified callback. When system events occur at a level equal to, or + * lower than, the given level they will be reported to the given callback. + * + * @param level Level to set tracing to + * @param cb Function to call with trace data + * @return 0 or an error code + */ +GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/transaction.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/transaction.h new file mode 100644 index 000000000..64abb0c69 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/transaction.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_transaction_h__ +#define INCLUDE_git_transaction_h__ + +#include "common.h" +GIT_BEGIN_DECL + +/** + * Create a new transaction object + * + * This does not lock anything, but sets up the transaction object to + * know from which repository to lock. + * + * @param out the resulting transaction + * @param repo the repository in which to lock + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transaction_new(git_transaction **out, git_repository *repo); + +/** + * Lock a reference + * + * Lock the specified reference. This is the first step to updating a + * reference. + * + * @param tx the transaction + * @param refname the reference to lock + * @return 0 or an error message + */ +GIT_EXTERN(int) git_transaction_lock_ref(git_transaction *tx, const char *refname); + +/** + * Set the target of a reference + * + * Set the target of the specified reference. This reference must be + * locked. + * + * @param tx the transaction + * @param refname reference to update + * @param target target to set the reference to + * @param sig signature to use in the reflog; pass NULL to read the identity from the config + * @param msg message to use in the reflog + * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code + */ +GIT_EXTERN(int) git_transaction_set_target(git_transaction *tx, const char *refname, const git_oid *target, const git_signature *sig, const char *msg); + +/** + * Set the target of a reference + * + * Set the target of the specified reference. This reference must be + * locked. + * + * @param tx the transaction + * @param refname reference to update + * @param target target to set the reference to + * @param sig signature to use in the reflog; pass NULL to read the identity from the config + * @param msg message to use in the reflog + * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code + */ +GIT_EXTERN(int) git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg); + +/** + * Set the reflog of a reference + * + * Set the specified reference's reflog. If this is combined with + * setting the target, that update won't be written to the reflog. + * + * @param tx the transaction + * @param refname the reference whose reflog to set + * @param reflog the reflog as it should be written out + * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code + */ +GIT_EXTERN(int) git_transaction_set_reflog(git_transaction *tx, const char *refname, const git_reflog *reflog); + +/** + * Remove a reference + * + * @param tx the transaction + * @param refname the reference to remove + * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code + */ +GIT_EXTERN(int) git_transaction_remove(git_transaction *tx, const char *refname); + +/** + * Commit the changes from the transaction + * + * Perform the changes that have been queued. The updates will be made + * one by one, and the first failure will stop the processing. + * + * @param tx the transaction + * @return 0 or an error code + */ +GIT_EXTERN(int) git_transaction_commit(git_transaction *tx); + +/** + * Free the resources allocated by this transaction + * + * If any references remain locked, they will be unlocked without any + * changes made to them. + * + * @param tx the transaction + */ +GIT_EXTERN(void) git_transaction_free(git_transaction *tx); + +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/transport.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/transport.h new file mode 100644 index 000000000..c10907f5f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/transport.h @@ -0,0 +1,311 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_transport_h__ +#define INCLUDE_git_transport_h__ + +#include "indexer.h" +#include "net.h" +#include "types.h" + +/** + * @file git2/transport.h + * @brief Git transport interfaces and functions + * @defgroup git_transport interfaces and functions + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Type of SSH host fingerprint + */ +typedef enum { + /** MD5 is available */ + GIT_CERT_SSH_MD5 = (1 << 0), + /** SHA-1 is available */ + GIT_CERT_SSH_SHA1 = (1 << 1), +} git_cert_ssh_t; + +/** + * Hostkey information taken from libssh2 + */ +typedef struct { + /** + * Type of certificate. Here to share the header with + * `git_cert`. + */ + git_cert_t cert_type; + /** + * A hostkey type from libssh2, either + * `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1` + */ + git_cert_ssh_t type; + + /** + * Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will + * have the MD5 hash of the hostkey. + */ + unsigned char hash_md5[16]; + + /** + * Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will + * have the SHA-1 hash of the hostkey. + */ + unsigned char hash_sha1[20]; +} git_cert_hostkey; + +/** + * X.509 certificate information + */ +typedef struct { + /** + * Type of certificate. Here to share the header with + * `git_cert`. + */ + git_cert_t cert_type; + /** + * Pointer to the X.509 certificate data + */ + void *data; + /** + * Length of the memory block pointed to by `data`. + */ + size_t len; +} git_cert_x509; + +/* + *** Begin interface for credentials acquisition *** + */ + +/** Authentication type requested */ +typedef enum { + /* git_cred_userpass_plaintext */ + GIT_CREDTYPE_USERPASS_PLAINTEXT = (1u << 0), + + /* git_cred_ssh_key */ + GIT_CREDTYPE_SSH_KEY = (1u << 1), + + /* git_cred_ssh_custom */ + GIT_CREDTYPE_SSH_CUSTOM = (1u << 2), + + /* git_cred_default */ + GIT_CREDTYPE_DEFAULT = (1u << 3), + + /* git_cred_ssh_interactive */ + GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4), + + /** + * Username-only information + * + * If the SSH transport does not know which username to use, + * it will ask via this credential type. + */ + GIT_CREDTYPE_USERNAME = (1u << 5), +} git_credtype_t; + +/* The base structure for all credential types */ +typedef struct git_cred git_cred; + +struct git_cred { + git_credtype_t credtype; + void (*free)(git_cred *cred); +}; + +/** A plaintext username and password */ +typedef struct { + git_cred parent; + char *username; + char *password; +} git_cred_userpass_plaintext; + + +/* + * If the user hasn't included libssh2.h before git2.h, we need to + * define a few types for the callback signatures. + */ +#ifndef LIBSSH2_VERSION +typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION; +typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT; +typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE; +#endif + +typedef int (*git_cred_sign_callback)(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, const unsigned char *data, size_t data_len, void **abstract); +typedef void (*git_cred_ssh_interactive_callback)(const char* name, int name_len, const char* instruction, int instruction_len, int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT* prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE* responses, void **abstract); + +/** + * A ssh key from disk + */ +typedef struct git_cred_ssh_key { + git_cred parent; + char *username; + char *publickey; + char *privatekey; + char *passphrase; +} git_cred_ssh_key; + +/** + * Keyboard-interactive based ssh authentication + */ +typedef struct git_cred_ssh_interactive { + git_cred parent; + char *username; + git_cred_ssh_interactive_callback prompt_callback; + void *payload; +} git_cred_ssh_interactive; + +/** + * A key with a custom signature function + */ +typedef struct git_cred_ssh_custom { + git_cred parent; + char *username; + char *publickey; + size_t publickey_len; + git_cred_sign_callback sign_callback; + void *payload; +} git_cred_ssh_custom; + +/** A key for NTLM/Kerberos "default" credentials */ +typedef struct git_cred git_cred_default; + +/** Username-only credential information */ +typedef struct git_cred_username { + git_cred parent; + char username[1]; +} git_cred_username; + +/** + * Check whether a credential object contains username information. + * + * @param cred object to check + * @return 1 if the credential object has non-NULL username, 0 otherwise + */ +GIT_EXTERN(int) git_cred_has_username(git_cred *cred); + +/** + * Create a new plain-text username and password credential object. + * The supplied credential parameter will be internally duplicated. + * + * @param out The newly created credential object. + * @param username The username of the credential. + * @param password The password of the credential. + * @return 0 for success or an error code for failure + */ +GIT_EXTERN(int) git_cred_userpass_plaintext_new( + git_cred **out, + const char *username, + const char *password); + +/** + * Create a new passphrase-protected ssh key credential object. + * The supplied credential parameter will be internally duplicated. + * + * @param out The newly created credential object. + * @param username username to use to authenticate + * @param publickey The path to the public key of the credential. + * @param privatekey The path to the private key of the credential. + * @param passphrase The passphrase of the credential. + * @return 0 for success or an error code for failure + */ +GIT_EXTERN(int) git_cred_ssh_key_new( + git_cred **out, + const char *username, + const char *publickey, + const char *privatekey, + const char *passphrase); + +/** + * Create a new ssh keyboard-interactive based credential object. + * The supplied credential parameter will be internally duplicated. + * + * @param username Username to use to authenticate. + * @param prompt_callback The callback method used for prompts. + * @param payload Additional data to pass to the callback. + * @return 0 for success or an error code for failure. + */ +GIT_EXTERN(int) git_cred_ssh_interactive_new( + git_cred **out, + const char *username, + git_cred_ssh_interactive_callback prompt_callback, + void *payload); + +/** + * Create a new ssh key credential object used for querying an ssh-agent. + * The supplied credential parameter will be internally duplicated. + * + * @param out The newly created credential object. + * @param username username to use to authenticate + * @return 0 for success or an error code for failure + */ +GIT_EXTERN(int) git_cred_ssh_key_from_agent( + git_cred **out, + const char *username); + +/** + * Create an ssh key credential with a custom signing function. + * + * This lets you use your own function to sign the challenge. + * + * This function and its credential type is provided for completeness + * and wraps `libssh2_userauth_publickey()`, which is undocumented. + * + * The supplied credential parameter will be internally duplicated. + * + * @param out The newly created credential object. + * @param username username to use to authenticate + * @param publickey The bytes of the public key. + * @param publickey_len The length of the public key in bytes. + * @param sign_callback The callback method to sign the data during the challenge. + * @param payload Additional data to pass to the callback. + * @return 0 for success or an error code for failure + */ +GIT_EXTERN(int) git_cred_ssh_custom_new( + git_cred **out, + const char *username, + const char *publickey, + size_t publickey_len, + git_cred_sign_callback sign_callback, + void *payload); + +/** + * Create a "default" credential usable for Negotiate mechanisms like NTLM + * or Kerberos authentication. + * + * @return 0 for success or an error code for failure + */ +GIT_EXTERN(int) git_cred_default_new(git_cred **out); + +/** + * Create a credential to specify a username. + * + * This is used with ssh authentication to query for the username if + * none is specified in the url. + */ +GIT_EXTERN(int) git_cred_username_new(git_cred **cred, const char *username); + +/** + * Signature of a function which acquires a credential object. + * + * - cred: The newly created credential object. + * - url: The resource for which we are demanding a credential. + * - username_from_url: The username that was embedded in a "user\@host" + * remote url, or NULL if not included. + * - allowed_types: A bitmask stating which cred types are OK to return. + * - payload: The payload provided when specifying this callback. + * - returns 0 for success, < 0 to indicate an error, > 0 to indicate + * no credential was acquired + */ +typedef int (*git_cred_acquire_cb)( + git_cred **cred, + const char *url, + const char *username_from_url, + unsigned int allowed_types, + void *payload); + +/** @} */ +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/tree.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/tree.h new file mode 100644 index 000000000..550a44857 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/tree.h @@ -0,0 +1,415 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_tree_h__ +#define INCLUDE_git_tree_h__ + +#include "common.h" +#include "types.h" +#include "oid.h" +#include "object.h" + +/** + * @file git2/tree.h + * @brief Git tree parsing, loading routines + * @defgroup git_tree Git tree parsing, loading routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Lookup a tree object from the repository. + * + * @param out Pointer to the looked up tree + * @param repo The repo to use when locating the tree. + * @param id Identity of the tree to locate. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tree_lookup( + git_tree **out, git_repository *repo, const git_oid *id); + +/** + * Lookup a tree object from the repository, + * given a prefix of its identifier (short id). + * + * @see git_object_lookup_prefix + * + * @param out pointer to the looked up tree + * @param repo the repo to use when locating the tree. + * @param id identity of the tree to locate. + * @param len the length of the short identifier + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tree_lookup_prefix( + git_tree **out, + git_repository *repo, + const git_oid *id, + size_t len); + +/** + * Close an open tree + * + * You can no longer use the git_tree pointer after this call. + * + * IMPORTANT: You MUST call this method when you stop using a tree to + * release memory. Failure to do so will cause a memory leak. + * + * @param tree The tree to close + */ +GIT_EXTERN(void) git_tree_free(git_tree *tree); + +/** + * Get the id of a tree. + * + * @param tree a previously loaded tree. + * @return object identity for the tree. + */ +GIT_EXTERN(const git_oid *) git_tree_id(const git_tree *tree); + +/** + * Get the repository that contains the tree. + * + * @param tree A previously loaded tree. + * @return Repository that contains this tree. + */ +GIT_EXTERN(git_repository *) git_tree_owner(const git_tree *tree); + +/** + * Get the number of entries listed in a tree + * + * @param tree a previously loaded tree. + * @return the number of entries in the tree + */ +GIT_EXTERN(size_t) git_tree_entrycount(const git_tree *tree); + +/** + * Lookup a tree entry by its filename + * + * This returns a git_tree_entry that is owned by the git_tree. You don't + * have to free it, but you must not use it after the git_tree is released. + * + * @param tree a previously loaded tree. + * @param filename the filename of the desired entry + * @return the tree entry; NULL if not found + */ +GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname( + const git_tree *tree, const char *filename); + +/** + * Lookup a tree entry by its position in the tree + * + * This returns a git_tree_entry that is owned by the git_tree. You don't + * have to free it, but you must not use it after the git_tree is released. + * + * @param tree a previously loaded tree. + * @param idx the position in the entry list + * @return the tree entry; NULL if not found + */ +GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex( + const git_tree *tree, size_t idx); + +/** + * Lookup a tree entry by SHA value. + * + * This returns a git_tree_entry that is owned by the git_tree. You don't + * have to free it, but you must not use it after the git_tree is released. + * + * Warning: this must examine every entry in the tree, so it is not fast. + * + * @param tree a previously loaded tree. + * @param id the sha being looked for + * @return the tree entry; NULL if not found + */ +GIT_EXTERN(const git_tree_entry *) git_tree_entry_byid( + const git_tree *tree, const git_oid *id); + +/** + * Retrieve a tree entry contained in a tree or in any of its subtrees, + * given its relative path. + * + * Unlike the other lookup functions, the returned tree entry is owned by + * the user and must be freed explicitly with `git_tree_entry_free()`. + * + * @param out Pointer where to store the tree entry + * @param root Previously loaded tree which is the root of the relative path + * @param path Path to the contained entry + * @return 0 on success; GIT_ENOTFOUND if the path does not exist + */ +GIT_EXTERN(int) git_tree_entry_bypath( + git_tree_entry **out, + const git_tree *root, + const char *path); + +/** + * Duplicate a tree entry + * + * Create a copy of a tree entry. The returned copy is owned by the user, + * and must be freed explicitly with `git_tree_entry_free()`. + * + * @param dest pointer where to store the copy + * @param source tree entry to duplicate + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source); + +/** + * Free a user-owned tree entry + * + * IMPORTANT: This function is only needed for tree entries owned by the + * user, such as the ones returned by `git_tree_entry_dup()` or + * `git_tree_entry_bypath()`. + * + * @param entry The entry to free + */ +GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry); + +/** + * Get the filename of a tree entry + * + * @param entry a tree entry + * @return the name of the file + */ +GIT_EXTERN(const char *) git_tree_entry_name(const git_tree_entry *entry); + +/** + * Get the id of the object pointed by the entry + * + * @param entry a tree entry + * @return the oid of the object + */ +GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry); + +/** + * Get the type of the object pointed by the entry + * + * @param entry a tree entry + * @return the type of the pointed object + */ +GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry); + +/** + * Get the UNIX file attributes of a tree entry + * + * @param entry a tree entry + * @return filemode as an integer + */ +GIT_EXTERN(git_filemode_t) git_tree_entry_filemode(const git_tree_entry *entry); + +/** + * Get the raw UNIX file attributes of a tree entry + * + * This function does not perform any normalization and is only useful + * if you need to be able to recreate the original tree object. + * + * @param entry a tree entry + * @return filemode as an integer + */ + +GIT_EXTERN(git_filemode_t) git_tree_entry_filemode_raw(const git_tree_entry *entry); +/** + * Compare two tree entries + * + * @param e1 first tree entry + * @param e2 second tree entry + * @return <0 if e1 is before e2, 0 if e1 == e2, >0 if e1 is after e2 + */ +GIT_EXTERN(int) git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2); + +/** + * Convert a tree entry to the git_object it points to. + * + * You must call `git_object_free()` on the object when you are done with it. + * + * @param object_out pointer to the converted object + * @param repo repository where to lookup the pointed object + * @param entry a tree entry + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tree_entry_to_object( + git_object **object_out, + git_repository *repo, + const git_tree_entry *entry); + +/** + * Create a new tree builder. + * + * The tree builder can be used to create or modify trees in memory and + * write them as tree objects to the database. + * + * If the `source` parameter is not NULL, the tree builder will be + * initialized with the entries of the given tree. + * + * If the `source` parameter is NULL, the tree builder will start with no + * entries and will have to be filled manually. + * + * @param out Pointer where to store the tree builder + * @param repo Repository in which to store the object + * @param source Source tree to initialize the builder (optional) + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_treebuilder_new( + git_treebuilder **out, git_repository *repo, const git_tree *source); + +/** + * Clear all the entires in the builder + * + * @param bld Builder to clear + */ +GIT_EXTERN(void) git_treebuilder_clear(git_treebuilder *bld); + +/** + * Get the number of entries listed in a treebuilder + * + * @param bld a previously loaded treebuilder. + * @return the number of entries in the treebuilder + */ +GIT_EXTERN(unsigned int) git_treebuilder_entrycount(git_treebuilder *bld); + +/** + * Free a tree builder + * + * This will clear all the entries and free to builder. + * Failing to free the builder after you're done using it + * will result in a memory leak + * + * @param bld Builder to free + */ +GIT_EXTERN(void) git_treebuilder_free(git_treebuilder *bld); + +/** + * Get an entry from the builder from its filename + * + * The returned entry is owned by the builder and should + * not be freed manually. + * + * @param bld Tree builder + * @param filename Name of the entry + * @return pointer to the entry; NULL if not found + */ +GIT_EXTERN(const git_tree_entry *) git_treebuilder_get( + git_treebuilder *bld, const char *filename); + +/** + * Add or update an entry to the builder + * + * Insert a new entry for `filename` in the builder with the + * given attributes. + * + * If an entry named `filename` already exists, its attributes + * will be updated with the given ones. + * + * The optional pointer `out` can be used to retrieve a pointer to the + * newly created/updated entry. Pass NULL if you do not need it. The + * pointer may not be valid past the next operation in this + * builder. Duplicate the entry if you want to keep it. + * + * No attempt is being made to ensure that the provided oid points + * to an existing git object in the object database, nor that the + * attributes make sense regarding the type of the pointed at object. + * + * @param out Pointer to store the entry (optional) + * @param bld Tree builder + * @param filename Filename of the entry + * @param id SHA1 oid of the entry + * @param filemode Folder attributes of the entry. This parameter must + * be valued with one of the following entries: 0040000, 0100644, + * 0100755, 0120000 or 0160000. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_treebuilder_insert( + const git_tree_entry **out, + git_treebuilder *bld, + const char *filename, + const git_oid *id, + git_filemode_t filemode); + +/** + * Remove an entry from the builder by its filename + * + * @param bld Tree builder + * @param filename Filename of the entry to remove + */ +GIT_EXTERN(int) git_treebuilder_remove( + git_treebuilder *bld, const char *filename); + +/** + * Callback for git_treebuilder_filter + * + * The return value is treated as a boolean, with zero indicating that the + * entry should be left alone and any non-zero value meaning that the + * entry should be removed from the treebuilder list (i.e. filtered out). + */ +typedef int (*git_treebuilder_filter_cb)( + const git_tree_entry *entry, void *payload); + +/** + * Selectively remove entries in the tree + * + * The `filter` callback will be called for each entry in the tree with a + * pointer to the entry and the provided `payload`; if the callback returns + * non-zero, the entry will be filtered (removed from the builder). + * + * @param bld Tree builder + * @param filter Callback to filter entries + * @param payload Extra data to pass to filter callback + */ +GIT_EXTERN(void) git_treebuilder_filter( + git_treebuilder *bld, + git_treebuilder_filter_cb filter, + void *payload); + +/** + * Write the contents of the tree builder as a tree object + * + * The tree builder will be written to the given `repo`, and its + * identifying SHA1 hash will be stored in the `id` pointer. + * + * @param id Pointer to store the OID of the newly written tree + * @param bld Tree builder to write + * @return 0 or an error code + */ +GIT_EXTERN(int) git_treebuilder_write( + git_oid *id, git_treebuilder *bld); + + +/** Callback for the tree traversal method */ +typedef int (*git_treewalk_cb)( + const char *root, const git_tree_entry *entry, void *payload); + +/** Tree traversal modes */ +typedef enum { + GIT_TREEWALK_PRE = 0, /* Pre-order */ + GIT_TREEWALK_POST = 1, /* Post-order */ +} git_treewalk_mode; + +/** + * Traverse the entries in a tree and its subtrees in post or pre order. + * + * The entries will be traversed in the specified order, children subtrees + * will be automatically loaded as required, and the `callback` will be + * called once per entry with the current (relative) root for the entry and + * the entry data itself. + * + * If the callback returns a positive value, the passed entry will be + * skipped on the traversal (in pre mode). A negative value stops the walk. + * + * @param tree The tree to walk + * @param mode Traversal mode (pre or post-order) + * @param callback Function to call on each tree entry + * @param payload Opaque pointer to be passed on each callback + * @return 0 or an error code + */ +GIT_EXTERN(int) git_tree_walk( + const git_tree *tree, + git_treewalk_mode mode, + git_treewalk_cb callback, + void *payload); + +/** @} */ + +GIT_END_DECL +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/types.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/types.h new file mode 100644 index 000000000..c90ac4776 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/types.h @@ -0,0 +1,425 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_types_h__ +#define INCLUDE_git_types_h__ + +#include "common.h" + +/** + * @file git2/types.h + * @brief libgit2 base & compatibility types + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Cross-platform compatibility types for off_t / time_t + * + * NOTE: This needs to be in a public header so that both the library + * implementation and client applications both agree on the same types. + * Otherwise we get undefined behavior. + * + * Use the "best" types that each platform provides. Currently we truncate + * these intermediate representations for compatibility with the git ABI, but + * if and when it changes to support 64 bit types, our code will naturally + * adapt. + * NOTE: These types should match those that are returned by our internal + * stat() functions, for all platforms. + */ +#include +#ifdef __amigaos4__ +#include +#endif + +#if defined(_MSC_VER) + +typedef __int64 git_off_t; +typedef __time64_t git_time_t; + +#elif defined(__MINGW32__) + +typedef off64_t git_off_t; +typedef __time64_t git_time_t; + +#elif defined(__HAIKU__) + +typedef __haiku_std_int64 git_off_t; +typedef __haiku_std_int64 git_time_t; + +#else /* POSIX */ + +/* + * Note: Can't use off_t since if a client program includes + * before us (directly or indirectly), they'll get 32 bit off_t in their client + * app, even though /we/ define _FILE_OFFSET_BITS=64. + */ +typedef int64_t git_off_t; +typedef int64_t git_time_t; + +#endif + +/** Basic type (loose or packed) of any Git object. */ +typedef enum { + GIT_OBJ_ANY = -2, /**< Object can be any of the following */ + GIT_OBJ_BAD = -1, /**< Object is invalid. */ + GIT_OBJ__EXT1 = 0, /**< Reserved for future use. */ + GIT_OBJ_COMMIT = 1, /**< A commit object. */ + GIT_OBJ_TREE = 2, /**< A tree (directory listing) object. */ + GIT_OBJ_BLOB = 3, /**< A file revision object. */ + GIT_OBJ_TAG = 4, /**< An annotated tag object. */ + GIT_OBJ__EXT2 = 5, /**< Reserved for future use. */ + GIT_OBJ_OFS_DELTA = 6, /**< A delta, base is given by an offset. */ + GIT_OBJ_REF_DELTA = 7, /**< A delta, base is given by object id. */ +} git_otype; + +/** An open object database handle. */ +typedef struct git_odb git_odb; + +/** A custom backend in an ODB */ +typedef struct git_odb_backend git_odb_backend; + +/** An object read from the ODB */ +typedef struct git_odb_object git_odb_object; + +/** A stream to read/write from the ODB */ +typedef struct git_odb_stream git_odb_stream; + +/** A stream to write a packfile to the ODB */ +typedef struct git_odb_writepack git_odb_writepack; + +/** An open refs database handle. */ +typedef struct git_refdb git_refdb; + +/** A custom backend for refs */ +typedef struct git_refdb_backend git_refdb_backend; + +/** + * Representation of an existing git repository, + * including all its object contents + */ +typedef struct git_repository git_repository; + +/** Representation of a generic object in a repository */ +typedef struct git_object git_object; + +/** Representation of an in-progress walk through the commits in a repo */ +typedef struct git_revwalk git_revwalk; + +/** Parsed representation of a tag object. */ +typedef struct git_tag git_tag; + +/** In-memory representation of a blob object. */ +typedef struct git_blob git_blob; + +/** Parsed representation of a commit object. */ +typedef struct git_commit git_commit; + +/** Representation of each one of the entries in a tree object. */ +typedef struct git_tree_entry git_tree_entry; + +/** Representation of a tree object. */ +typedef struct git_tree git_tree; + +/** Constructor for in-memory trees */ +typedef struct git_treebuilder git_treebuilder; + +/** Memory representation of an index file. */ +typedef struct git_index git_index; + +/** An iterator for conflicts in the index. */ +typedef struct git_index_conflict_iterator git_index_conflict_iterator; + +/** Memory representation of a set of config files */ +typedef struct git_config git_config; + +/** Interface to access a configuration file */ +typedef struct git_config_backend git_config_backend; + +/** Representation of a reference log entry */ +typedef struct git_reflog_entry git_reflog_entry; + +/** Representation of a reference log */ +typedef struct git_reflog git_reflog; + +/** Representation of a git note */ +typedef struct git_note git_note; + +/** Representation of a git packbuilder */ +typedef struct git_packbuilder git_packbuilder; + +/** Time in a signature */ +typedef struct git_time { + git_time_t time; /**< time in seconds from epoch */ + int offset; /**< timezone offset, in minutes */ +} git_time; + +/** An action signature (e.g. for committers, taggers, etc) */ +typedef struct git_signature { + char *name; /**< full name of the author */ + char *email; /**< email of the author */ + git_time when; /**< time when the action happened */ +} git_signature; + +/** In-memory representation of a reference. */ +typedef struct git_reference git_reference; + +/** Iterator for references */ +typedef struct git_reference_iterator git_reference_iterator; + +/** Transactional interface to references */ +typedef struct git_transaction git_transaction; + +/** Annotated commits, the input to merge and rebase. */ +typedef struct git_annotated_commit git_annotated_commit; + +/** Merge result */ +typedef struct git_merge_result git_merge_result; + +/** Representation of a status collection */ +typedef struct git_status_list git_status_list; + +/** Representation of a rebase */ +typedef struct git_rebase git_rebase; + +/** Basic type of any Git reference. */ +typedef enum { + GIT_REF_INVALID = 0, /**< Invalid reference */ + GIT_REF_OID = 1, /**< A reference which points at an object id */ + GIT_REF_SYMBOLIC = 2, /**< A reference which points at another reference */ + GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC, +} git_ref_t; + +/** Basic type of any Git branch. */ +typedef enum { + GIT_BRANCH_LOCAL = 1, + GIT_BRANCH_REMOTE = 2, + GIT_BRANCH_ALL = GIT_BRANCH_LOCAL|GIT_BRANCH_REMOTE, +} git_branch_t; + +/** Valid modes for index and tree entries. */ +typedef enum { + GIT_FILEMODE_UNREADABLE = 0000000, + GIT_FILEMODE_TREE = 0040000, + GIT_FILEMODE_BLOB = 0100644, + GIT_FILEMODE_BLOB_EXECUTABLE = 0100755, + GIT_FILEMODE_LINK = 0120000, + GIT_FILEMODE_COMMIT = 0160000, +} git_filemode_t; + +/* + * A refspec specifies the mapping between remote and local reference + * names when fetch or pushing. + */ +typedef struct git_refspec git_refspec; + +/** + * Git's idea of a remote repository. A remote can be anonymous (in + * which case it does not have backing configuration entires). + */ +typedef struct git_remote git_remote; + +/** + * Preparation for a push operation. Can be used to configure what to + * push and the level of parallelism of the packfile builder. + */ +typedef struct git_push git_push; + +/* documentation in the definition */ +typedef struct git_remote_head git_remote_head; +typedef struct git_remote_callbacks git_remote_callbacks; + +/** + * This is passed as the first argument to the callback to allow the + * user to see the progress. + * + * - total_objects: number of objects in the packfile being downloaded + * - indexed_objects: received objects that have been hashed + * - received_objects: objects which have been downloaded + * - local_objects: locally-available objects that have been injected + * in order to fix a thin pack. + * - received-bytes: size of the packfile received up to now + */ +typedef struct git_transfer_progress { + unsigned int total_objects; + unsigned int indexed_objects; + unsigned int received_objects; + unsigned int local_objects; + unsigned int total_deltas; + unsigned int indexed_deltas; + size_t received_bytes; +} git_transfer_progress; + +/** + * Type for progress callbacks during indexing. Return a value less than zero + * to cancel the transfer. + * + * @param stats Structure containing information about the state of the transfer + * @param payload Payload provided by caller + */ +typedef int (*git_transfer_progress_cb)(const git_transfer_progress *stats, void *payload); + +/** + * Type for messages delivered by the transport. Return a negative value + * to cancel the network operation. + * + * @param str The message from the transport + * @param len The length of the message + * @param payload Payload provided by the caller + */ +typedef int (*git_transport_message_cb)(const char *str, int len, void *payload); + +/** + * Type of host certificate structure that is passed to the check callback + */ +typedef enum git_cert_t { + /** + * The `data` argument to the callback will be a pointer to + * the DER-encoded data. + */ + GIT_CERT_X509, + /** + * The `data` argument to the callback will be a pointer to a + * `git_cert_hostkey` structure. + */ + GIT_CERT_HOSTKEY_LIBSSH2, +} git_cert_t; + +/** + * Parent type for `git_cert_hostkey` and `git_cert_x509`. + */ +typedef struct { + /** + * Type of certificate. A `GIT_CERT_` value. + */ + git_cert_t cert_type; +} git_cert; + +/** + * Callback for the user's custom certificate checks. + * + * @param cert The host certificate + * @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think + * this certificate is valid + * @param host Hostname of the host libgit2 connected to + * @param payload Payload provided by the caller + */ +typedef int (*git_transport_certificate_check_cb)(git_cert *cert, int valid, const char *host, void *payload); + +/** + * Opaque structure representing a submodule. + */ +typedef struct git_submodule git_submodule; + +/** + * Submodule update values + * + * These values represent settings for the `submodule.$name.update` + * configuration value which says how to handle `git submodule update` for + * this submodule. The value is usually set in the ".gitmodules" file and + * copied to ".git/config" when the submodule is initialized. + * + * You can override this setting on a per-submodule basis with + * `git_submodule_set_update()` and write the changed value to disk using + * `git_submodule_save()`. If you have overwritten the value, you can + * revert it by passing `GIT_SUBMODULE_UPDATE_RESET` to the set function. + * + * The values are: + * + * - GIT_SUBMODULE_UPDATE_RESET: reset to the on-disk value. + * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is + * updated, checkout the new detached HEAD to the submodule directory. + * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked + * out branch onto the commit from the superproject. + * - GIT_SUBMODULE_UPDATE_MERGE: update by merging the commit in the + * superproject into the current checkout out branch of the submodule. + * - GIT_SUBMODULE_UPDATE_NONE: do not update this submodule even when + * the commit in the superproject is updated. + * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer + * when we don't want any particular update rule to be specified. + */ +typedef enum { + GIT_SUBMODULE_UPDATE_RESET = -1, + + GIT_SUBMODULE_UPDATE_CHECKOUT = 1, + GIT_SUBMODULE_UPDATE_REBASE = 2, + GIT_SUBMODULE_UPDATE_MERGE = 3, + GIT_SUBMODULE_UPDATE_NONE = 4, + + GIT_SUBMODULE_UPDATE_DEFAULT = 0 +} git_submodule_update_t; + +/** + * Submodule ignore values + * + * These values represent settings for the `submodule.$name.ignore` + * configuration value which says how deeply to look at the working + * directory when getting submodule status. + * + * You can override this value in memory on a per-submodule basis with + * `git_submodule_set_ignore()` and can write the changed value to disk + * with `git_submodule_save()`. If you have overwritten the value, you + * can revert to the on disk value by using `GIT_SUBMODULE_IGNORE_RESET`. + * + * The values are: + * + * - GIT_SUBMODULE_IGNORE_RESET: reset to the on-disk value. + * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an + * untracked file, will mark the submodule as dirty. Ignored files are + * still ignored, of course. + * - GIT_SUBMODULE_IGNORE_UNTRACKED: ignore untracked files; only changes + * to tracked files, or the index or the HEAD commit will matter. + * - GIT_SUBMODULE_IGNORE_DIRTY: ignore changes in the working directory, + * only considering changes if the HEAD of submodule has moved from the + * value in the superproject. + * - GIT_SUBMODULE_IGNORE_ALL: never check if the submodule is dirty + * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer + * when we don't want any particular ignore rule to be specified. + */ +typedef enum { + GIT_SUBMODULE_IGNORE_RESET = -1, /**< reset to on-disk value */ + + GIT_SUBMODULE_IGNORE_NONE = 1, /**< any change or untracked == dirty */ + GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /**< dirty if tracked files change */ + GIT_SUBMODULE_IGNORE_DIRTY = 3, /**< only dirty if HEAD moved */ + GIT_SUBMODULE_IGNORE_ALL = 4, /**< never dirty */ + + GIT_SUBMODULE_IGNORE_DEFAULT = 0 +} git_submodule_ignore_t; + +/** + * Options for submodule recurse. + * + * Represent the value of `submodule.$name.fetchRecurseSubmodules` + * + * * GIT_SUBMODULE_RECURSE_RESET - reset to the on-disk value + * * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules + * * GIT_SUBMODULE_RECURSE_YES - recurse into submodules + * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when + * commit not already in local clone + */ +typedef enum { + GIT_SUBMODULE_RECURSE_RESET = -1, + + GIT_SUBMODULE_RECURSE_NO = 0, + GIT_SUBMODULE_RECURSE_YES = 1, + GIT_SUBMODULE_RECURSE_ONDEMAND = 2, +} git_submodule_recurse_t; + +/** A type to write in a streaming fashion, for example, for filters. */ +typedef struct git_writestream git_writestream; + +struct git_writestream { + int (*write)(git_writestream *stream, const char *buffer, size_t len); + int (*close)(git_writestream *stream); + void (*free)(git_writestream *stream); +}; + +/** @} */ +GIT_END_DECL + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/include/git2/version.h b/deps/libgit2-sys-0.2.17/libgit2/include/git2/version.h new file mode 100644 index 000000000..456bbe258 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/include/git2/version.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_version_h__ +#define INCLUDE_git_version_h__ + +#define LIBGIT2_VERSION "0.22.0" +#define LIBGIT2_VER_MAJOR 0 +#define LIBGIT2_VER_MINOR 22 +#define LIBGIT2_VER_REVISION 0 +#define LIBGIT2_VER_PATCH 0 + +#define LIBGIT2_SOVERSION 22 + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/libgit2.pc.in b/deps/libgit2-sys-0.2.17/libgit2/libgit2.pc.in new file mode 100644 index 000000000..8f5279234 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/libgit2.pc.in @@ -0,0 +1,10 @@ +libdir=@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@ +includedir=@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@ + +Name: libgit2 +Description: The git library, take 2 +Version: @LIBGIT2_VERSION_STRING@ +Requires.private: @LIBGIT2_PC_REQUIRES@ +Libs.private: @LIBGIT2_PC_LIBS@ +Libs: -L${libdir} -lgit2 +Cflags: -I${includedir} diff --git a/deps/libgit2-sys-0.2.17/libgit2/libgit2_clar.supp b/deps/libgit2-sys-0.2.17/libgit2/libgit2_clar.supp new file mode 100644 index 000000000..bd22ada46 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/libgit2_clar.supp @@ -0,0 +1,49 @@ +{ + ignore-zlib-errors-cond + Memcheck:Cond + obj:*libz.so* +} + +{ + ignore-giterr-set-leak + Memcheck:Leak + ... + fun:giterr_set +} + +{ + ignore-git-global-state-leak + Memcheck:Leak + ... + fun:git__global_state +} + +{ + ignore-openssl-ssl-leak + Memcheck:Leak + ... + obj:*libssl.so* + ... +} + +{ + ignore-openssl-crypto-leak + Memcheck:Leak + ... + obj:*libcrypto.so* + ... +} + +{ + ignore-openssl-crypto-cond + Memcheck:Cond + obj:*libcrypto.so* + ... +} + +{ + ignore-glibc-getaddrinfo-cache + Memcheck:Leak + ... + fun:__check_pf +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/script/appveyor-mingw.sh b/deps/libgit2-sys-0.2.17/libgit2/script/appveyor-mingw.sh new file mode 100755 index 000000000..48e0bad0a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/script/appveyor-mingw.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e +cd `dirname "$0"`/.. +if [ "$ARCH" = "32" ]; then + echo 'C:\MinGW\ /MinGW' > /etc/fstab +elif [ "$ARCH" = "i686" ]; then + f=i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z + if ! [ -e $f ]; then + curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/sjlj/$f + fi + 7z x $f > /dev/null + mv mingw32 /MinGW +else + f=x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z + if ! [ -e $f ]; then + curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/$f + fi + 7z x $f > /dev/null + mv mingw64 /MinGW +fi +cd build +cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$GENERATOR" +cmake --build . --config RelWithDebInfo diff --git a/deps/libgit2-sys-0.2.17/libgit2/script/cibuild.sh b/deps/libgit2-sys-0.2.17/libgit2/script/cibuild.sh new file mode 100755 index 000000000..bdc352931 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/script/cibuild.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +if [ -n "$COVERITY" ]; +then + ./script/coverity.sh; + exit $?; +fi + +mkdir _build +cd _build +# shellcheck disable=SC2086 +cmake .. -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS || exit $? +make -j2 install || exit $? + +# If this platform doesn't support test execution, bail out now +if [ -n "$SKIP_TESTS" ]; +then + exit $?; +fi + +# Create a test repo which we can use for the online::push tests +mkdir "$HOME"/_temp +git init --bare "$HOME"/_temp/test.git +git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$HOME"/_temp "$HOME"/_temp 2>/dev/null & +export GITTEST_REMOTE_URL="git://localhost/test.git" + +# Run the test suite +ctest -V . || exit $? + +# Now that we've tested the raw git protocol, let's set up ssh to we +# can do the push tests over it + +killall git-daemon + +if [ "$TRAVIS_OS_NAME" = "osx" ]; then + echo 'PasswordAuthentication yes' | sudo tee -a /etc/sshd_config +else + sudo start ssh +fi + +ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q +cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys +ssh-keyscan -t rsa localhost >>~/.ssh/known_hosts + +# Get the fingerprint for localhost and remove the colons so we can parse it as a hex number +export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F localhost -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':') + +export GITTEST_REMOTE_URL="ssh://localhost/$HOME/_temp/test.git" +export GITTEST_REMOTE_USER=$USER +export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa" +export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub" +export GITTEST_REMOTE_SSH_PASSPHRASE="" + +if [ -e ./libgit2_clar ]; then + ./libgit2_clar -sonline::push -sonline::clone::ssh_cert && + ./libgit2_clar -sonline::clone::ssh_with_paths + if [ "$TRAVIS_OS_NAME" = "linux" ]; then + ./libgit2_clar -sonline::clone::cred_callback + fi +fi diff --git a/deps/libgit2-sys-0.2.17/libgit2/script/coverity.sh b/deps/libgit2-sys-0.2.17/libgit2/script/coverity.sh new file mode 100755 index 000000000..dcfeffc1d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/script/coverity.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +# Environment check +[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1 + +# Only run this on our branches +echo "Pull request: $TRAVIS_PULL_REQUEST | Slug: $TRAVIS_REPO_SLUG" +if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "libgit2/libgit2" ]; +then + echo "Only analyzing 'development' on the main repo." + exit 0 +fi + +COV_VERSION=6.6.1 +case $(uname -m) in + i?86) BITS=32 ;; + amd64|x86_64) BITS=64 ;; +esac +SCAN_TOOL=https://scan.coverity.com/download/linux-${BITS} +TOOL_BASE=$(pwd)/_coverity-scan + +# Install coverity tools +if [ ! -d "$TOOL_BASE" ]; then + echo "Downloading coverity..." + mkdir -p "$TOOL_BASE" + pushd "$TOOL_BASE" + wget -O coverity_tool.tgz $SCAN_TOOL \ + --post-data "project=libgit2&token=$COVERITY_TOKEN" + tar xzf coverity_tool.tgz + popd + TOOL_DIR=$(find "$TOOL_BASE" -type d -name 'cov-analysis*') + ln -s "$TOOL_DIR" "$TOOL_BASE"/cov-analysis +fi + +COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build" + +# Configure and build +rm -rf _build +mkdir _build +cd _build +cmake .. -DTHREADSAFE=ON +COVERITY_UNSUPPORTED=1 \ + $COV_BUILD --dir cov-int \ + cmake --build . + +# Upload results +tar czf libgit2.tgz cov-int +SHA=$(git rev-parse --short HEAD) +curl \ + --form project=libgit2 \ + --form token="$COVERITY_TOKEN" \ + --form email=bs@github.com \ + --form file=@libgit2.tgz \ + --form version="$SHA" \ + --form description="Travis build" \ + http://scan5.coverity.com/cgi-bin/upload.py diff --git a/deps/libgit2-sys-0.2.17/libgit2/script/install-deps-linux.sh b/deps/libgit2-sys-0.2.17/libgit2/script/install-deps-linux.sh new file mode 100755 index 000000000..347922b89 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/script/install-deps-linux.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -x + +sudo apt-get -qq update && +sudo apt-get -qq install cmake libssh2-1-dev openssh-client openssh-server diff --git a/deps/libgit2-sys-0.2.17/libgit2/script/install-deps-osx.sh b/deps/libgit2-sys-0.2.17/libgit2/script/install-deps-osx.sh new file mode 100755 index 000000000..c2e0162d8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/script/install-deps-osx.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -x + +brew install libssh2 cmake diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.c b/deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.c new file mode 100644 index 000000000..3f2d2ed17 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.c @@ -0,0 +1,149 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "annotated_commit.h" + +#include "git2/commit.h" +#include "git2/refs.h" +#include "git2/repository.h" +#include "git2/annotated_commit.h" +#include "git2/revparse.h" + +static int annotated_commit_init( + git_annotated_commit **out, + git_repository *repo, + const git_oid *id, + const char *ref_name, + const char *remote_url) +{ + git_annotated_commit *annotated_commit; + int error = 0; + + assert(out && id); + + *out = NULL; + + annotated_commit = git__calloc(1, sizeof(git_annotated_commit)); + GITERR_CHECK_ALLOC(annotated_commit); + + if (ref_name) { + annotated_commit->ref_name = git__strdup(ref_name); + GITERR_CHECK_ALLOC(annotated_commit->ref_name); + } + + if (remote_url) { + annotated_commit->remote_url = git__strdup(remote_url); + GITERR_CHECK_ALLOC(annotated_commit->remote_url); + } + + git_oid_fmt(annotated_commit->id_str, id); + annotated_commit->id_str[GIT_OID_HEXSZ] = '\0'; + + if ((error = git_commit_lookup(&annotated_commit->commit, repo, id)) < 0) { + git_annotated_commit_free(annotated_commit); + return error; + } + + *out = annotated_commit; + return error; +} + +int git_annotated_commit_from_ref( + git_annotated_commit **out, + git_repository *repo, + const git_reference *ref) +{ + git_reference *resolved; + int error = 0; + + assert(out && repo && ref); + + *out = NULL; + + if ((error = git_reference_resolve(&resolved, ref)) < 0) + return error; + + error = annotated_commit_init(out, repo, git_reference_target(resolved), + git_reference_name(ref), NULL); + + git_reference_free(resolved); + return error; +} + +int git_annotated_commit_lookup( + git_annotated_commit **out, + git_repository *repo, + const git_oid *id) +{ + assert(out && repo && id); + + return annotated_commit_init(out, repo, id, NULL, NULL); +} + +int git_annotated_commit_from_fetchhead( + git_annotated_commit **out, + git_repository *repo, + const char *branch_name, + const char *remote_url, + const git_oid *id) +{ + assert(repo && id && branch_name && remote_url); + + return annotated_commit_init(out, repo, id, branch_name, remote_url); +} + +int git_annotated_commit_from_revspec( + git_annotated_commit **out, + git_repository *repo, + const char *revspec) +{ + git_object *obj, *commit; + int error; + + assert(out && repo && revspec); + + if ((error = git_revparse_single(&obj, repo, revspec)) < 0) + return error; + + if ((error = git_object_peel(&commit, obj, GIT_OBJ_COMMIT))) { + git_object_free(obj); + return error; + } + + error = annotated_commit_init(out, repo, git_object_id(commit), revspec, NULL); + + git_object_free(obj); + git_object_free(commit); + + return error; +} + + +const git_oid *git_annotated_commit_id( + const git_annotated_commit *annotated_commit) +{ + assert(annotated_commit); + return git_commit_id(annotated_commit->commit); +} + +void git_annotated_commit_free(git_annotated_commit *annotated_commit) +{ + if (annotated_commit == NULL) + return; + + if (annotated_commit->commit != NULL) + git_commit_free(annotated_commit->commit); + + if (annotated_commit->ref_name != NULL) + git__free(annotated_commit->ref_name); + + if (annotated_commit->remote_url != NULL) + git__free(annotated_commit->remote_url); + + git__free(annotated_commit); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.h b/deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.h new file mode 100644 index 000000000..e873184ae --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/annotated_commit.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_annotated_commit_h__ +#define INCLUDE_annotated_commit_h__ + +#include "git2/oid.h" + +/** Internal structure for merge inputs */ +struct git_annotated_commit { + git_commit *commit; + + char *ref_name; + char *remote_url; + + char id_str[GIT_OID_HEXSZ+1]; +}; + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/array.h b/deps/libgit2-sys-0.2.17/libgit2/src/array.h new file mode 100644 index 000000000..7cd9b7153 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/array.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_array_h__ +#define INCLUDE_array_h__ + +#include "common.h" + +/* + * Use this to declare a typesafe resizable array of items, a la: + * + * git_array_t(int) my_ints = GIT_ARRAY_INIT; + * ... + * int *i = git_array_alloc(my_ints); + * GITERR_CHECK_ALLOC(i); + * ... + * git_array_clear(my_ints); + * + * You may also want to do things like: + * + * typedef git_array_t(my_struct) my_struct_array_t; + */ +#define git_array_t(type) struct { type *ptr; size_t size, asize; } + +#define GIT_ARRAY_INIT { NULL, 0, 0 } + +#define git_array_init(a) \ + do { (a).size = (a).asize = 0; (a).ptr = NULL; } while (0) + +#define git_array_init_to_size(a, desired) \ + do { (a).size = 0; (a).asize = desired; (a).ptr = git__calloc(desired, sizeof(*(a).ptr)); } while (0) + +#define git_array_clear(a) \ + do { git__free((a).ptr); git_array_init(a); } while (0) + +#define GITERR_CHECK_ARRAY(a) GITERR_CHECK_ALLOC((a).ptr) + + +typedef git_array_t(char) git_array_generic_t; + +/* use a generic array for growth so this can return the new item */ +GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size) +{ + volatile git_array_generic_t *a = _a; + size_t new_size; + char *new_array; + + if (a->size < 8) { + new_size = 8; + } else { + if (GIT_MULTIPLY_SIZET_OVERFLOW(&new_size, a->size, 3)) + goto on_oom; + new_size /= 2; + } + + if ((new_array = git__reallocarray(a->ptr, new_size, item_size)) == NULL) + goto on_oom; + + a->ptr = new_array; a->asize = new_size; a->size++; + return a->ptr + (a->size - 1) * item_size; + +on_oom: + git_array_clear(*a); + return NULL; +} + +#define git_array_alloc(a) \ + (((a).size >= (a).asize) ? \ + git_array_grow(&(a), sizeof(*(a).ptr)) : \ + ((a).ptr ? &(a).ptr[(a).size++] : NULL)) + +#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL) + +#define git_array_pop(a) ((a).size ? &(a).ptr[--(a).size] : NULL) + +#define git_array_get(a, i) (((i) < (a).size) ? &(a).ptr[(i)] : NULL) + +#define git_array_size(a) (a).size + +#define git_array_valid_index(a, i) ((i) < (a).size) + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/attr.c b/deps/libgit2-sys-0.2.17/libgit2/src/attr.c new file mode 100644 index 000000000..38420807a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/attr.c @@ -0,0 +1,543 @@ +#include "common.h" +#include "repository.h" +#include "sysdir.h" +#include "config.h" +#include "attr_file.h" +#include "ignore.h" +#include "git2/oid.h" +#include + +GIT__USE_STRMAP + +const char *git_attr__true = "[internal]__TRUE__"; +const char *git_attr__false = "[internal]__FALSE__"; +const char *git_attr__unset = "[internal]__UNSET__"; + +git_attr_t git_attr_value(const char *attr) +{ + if (attr == NULL || attr == git_attr__unset) + return GIT_ATTR_UNSPECIFIED_T; + + if (attr == git_attr__true) + return GIT_ATTR_TRUE_T; + + if (attr == git_attr__false) + return GIT_ATTR_FALSE_T; + + return GIT_ATTR_VALUE_T; +} + +static int collect_attr_files( + git_repository *repo, + git_attr_session *attr_session, + uint32_t flags, + const char *path, + git_vector *files); + +static void release_attr_files(git_vector *files); + +int git_attr_get( + const char **value, + git_repository *repo, + uint32_t flags, + const char *pathname, + const char *name) +{ + int error; + git_attr_path path; + git_vector files = GIT_VECTOR_INIT; + size_t i, j; + git_attr_file *file; + git_attr_name attr; + git_attr_rule *rule; + + assert(value && repo && name); + + *value = NULL; + + if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0) + return -1; + + if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0) + goto cleanup; + + memset(&attr, 0, sizeof(attr)); + attr.name = name; + attr.name_hash = git_attr_file__name_hash(name); + + git_vector_foreach(&files, i, file) { + + git_attr_file__foreach_matching_rule(file, &path, j, rule) { + size_t pos; + + if (!git_vector_bsearch(&pos, &rule->assigns, &attr)) { + *value = ((git_attr_assignment *)git_vector_get( + &rule->assigns, pos))->value; + goto cleanup; + } + } + } + +cleanup: + release_attr_files(&files); + git_attr_path__free(&path); + + return error; +} + + +typedef struct { + git_attr_name name; + git_attr_assignment *found; +} attr_get_many_info; + +int git_attr_get_many_with_session( + const char **values, + git_repository *repo, + git_attr_session *attr_session, + uint32_t flags, + const char *pathname, + size_t num_attr, + const char **names) +{ + int error; + git_attr_path path; + git_vector files = GIT_VECTOR_INIT; + size_t i, j, k; + git_attr_file *file; + git_attr_rule *rule; + attr_get_many_info *info = NULL; + size_t num_found = 0; + + if (!num_attr) + return 0; + + assert(values && repo && names); + + if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0) + return -1; + + if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0) + goto cleanup; + + info = git__calloc(num_attr, sizeof(attr_get_many_info)); + GITERR_CHECK_ALLOC(info); + + git_vector_foreach(&files, i, file) { + + git_attr_file__foreach_matching_rule(file, &path, j, rule) { + + for (k = 0; k < num_attr; k++) { + size_t pos; + + if (info[k].found != NULL) /* already found assignment */ + continue; + + if (!info[k].name.name) { + info[k].name.name = names[k]; + info[k].name.name_hash = git_attr_file__name_hash(names[k]); + } + + if (!git_vector_bsearch(&pos, &rule->assigns, &info[k].name)) { + info[k].found = (git_attr_assignment *) + git_vector_get(&rule->assigns, pos); + values[k] = info[k].found->value; + + if (++num_found == num_attr) + goto cleanup; + } + } + } + } + + for (k = 0; k < num_attr; k++) { + if (!info[k].found) + values[k] = NULL; + } + +cleanup: + release_attr_files(&files); + git_attr_path__free(&path); + git__free(info); + + return error; +} + +int git_attr_get_many( + const char **values, + git_repository *repo, + uint32_t flags, + const char *pathname, + size_t num_attr, + const char **names) +{ + return git_attr_get_many_with_session( + values, repo, NULL, flags, pathname, num_attr, names); +} + +int git_attr_foreach( + git_repository *repo, + uint32_t flags, + const char *pathname, + int (*callback)(const char *name, const char *value, void *payload), + void *payload) +{ + int error; + git_attr_path path; + git_vector files = GIT_VECTOR_INIT; + size_t i, j, k; + git_attr_file *file; + git_attr_rule *rule; + git_attr_assignment *assign; + git_strmap *seen = NULL; + + assert(repo && callback); + + if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0) + return -1; + + if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 || + (error = git_strmap_alloc(&seen)) < 0) + goto cleanup; + + git_vector_foreach(&files, i, file) { + + git_attr_file__foreach_matching_rule(file, &path, j, rule) { + + git_vector_foreach(&rule->assigns, k, assign) { + /* skip if higher priority assignment was already seen */ + if (git_strmap_exists(seen, assign->name)) + continue; + + git_strmap_insert(seen, assign->name, assign, error); + if (error < 0) + goto cleanup; + + error = callback(assign->name, assign->value, payload); + if (error) { + giterr_set_after_callback(error); + goto cleanup; + } + } + } + } + +cleanup: + git_strmap_free(seen); + release_attr_files(&files); + git_attr_path__free(&path); + + return error; +} + +static int preload_attr_file( + git_repository *repo, + git_attr_session *attr_session, + git_attr_file_source source, + const char *base, + const char *file) +{ + int error; + git_attr_file *preload = NULL; + + if (!file) + return 0; + if (!(error = git_attr_cache__get( + &preload, repo, attr_session, source, base, file, git_attr_file__parse_buffer))) + git_attr_file__free(preload); + + return error; +} + +static int system_attr_file( + git_buf *out, + git_attr_session *attr_session) +{ + int error; + + if (!attr_session) { + error = git_sysdir_find_system_file(out, GIT_ATTR_FILE_SYSTEM); + + if (error == GIT_ENOTFOUND) + giterr_clear(); + + return error; + } + + if (!attr_session->init_sysdir) { + error = git_sysdir_find_system_file(&attr_session->sysdir, GIT_ATTR_FILE_SYSTEM); + + if (error == GIT_ENOTFOUND) + giterr_clear(); + else if (error) + return error; + + attr_session->init_sysdir = 1; + } + + if (attr_session->sysdir.size == 0) + return GIT_ENOTFOUND; + + /* We can safely provide a git_buf with no allocation (asize == 0) to + * a consumer. This allows them to treat this as a regular `git_buf`, + * but their call to `git_buf_free` will not attempt to free it. + */ + git_buf_attach_notowned( + out, attr_session->sysdir.ptr, attr_session->sysdir.size); + return 0; +} + +static int attr_setup(git_repository *repo, git_attr_session *attr_session) +{ + int error = 0; + const char *workdir = git_repository_workdir(repo); + git_index *idx = NULL; + git_buf sys = GIT_BUF_INIT; + + if (attr_session && attr_session->init_setup) + return 0; + + if ((error = git_attr_cache__init(repo)) < 0) + return error; + + /* preload attribute files that could contain macros so the + * definitions will be available for later file parsing + */ + + error = system_attr_file(&sys, attr_session); + + if (error == 0) + error = preload_attr_file( + repo, attr_session, GIT_ATTR_FILE__FROM_FILE, NULL, sys.ptr); + else if (error != GIT_ENOTFOUND) + return error; + + git_buf_free(&sys); + + if ((error = preload_attr_file( + repo, attr_session, GIT_ATTR_FILE__FROM_FILE, + NULL, git_repository_attr_cache(repo)->cfg_attr_file)) < 0) + return error; + + if ((error = preload_attr_file( + repo, attr_session, GIT_ATTR_FILE__FROM_FILE, + git_repository_path(repo), GIT_ATTR_FILE_INREPO)) < 0) + return error; + + if (workdir != NULL && + (error = preload_attr_file( + repo, attr_session, GIT_ATTR_FILE__FROM_FILE, workdir, GIT_ATTR_FILE)) < 0) + return error; + + if ((error = git_repository_index__weakptr(&idx, repo)) < 0 || + (error = preload_attr_file( + repo, attr_session, GIT_ATTR_FILE__FROM_INDEX, NULL, GIT_ATTR_FILE)) < 0) + return error; + + if (attr_session) + attr_session->init_setup = 1; + + return error; +} + +int git_attr_add_macro( + git_repository *repo, + const char *name, + const char *values) +{ + int error; + git_attr_rule *macro = NULL; + git_pool *pool; + + if ((error = git_attr_cache__init(repo)) < 0) + return error; + + macro = git__calloc(1, sizeof(git_attr_rule)); + GITERR_CHECK_ALLOC(macro); + + pool = &git_repository_attr_cache(repo)->pool; + + macro->match.pattern = git_pool_strdup(pool, name); + GITERR_CHECK_ALLOC(macro->match.pattern); + + macro->match.length = strlen(macro->match.pattern); + macro->match.flags = GIT_ATTR_FNMATCH_MACRO; + + error = git_attr_assignment__parse(repo, pool, ¯o->assigns, &values); + + if (!error) + error = git_attr_cache__insert_macro(repo, macro); + + if (error < 0) + git_attr_rule__free(macro); + + return error; +} + +typedef struct { + git_repository *repo; + git_attr_session *attr_session; + uint32_t flags; + const char *workdir; + git_index *index; + git_vector *files; +} attr_walk_up_info; + +static int attr_decide_sources( + uint32_t flags, bool has_wd, bool has_index, git_attr_file_source *srcs) +{ + int count = 0; + + switch (flags & 0x03) { + case GIT_ATTR_CHECK_FILE_THEN_INDEX: + if (has_wd) + srcs[count++] = GIT_ATTR_FILE__FROM_FILE; + if (has_index) + srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; + break; + case GIT_ATTR_CHECK_INDEX_THEN_FILE: + if (has_index) + srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; + if (has_wd) + srcs[count++] = GIT_ATTR_FILE__FROM_FILE; + break; + case GIT_ATTR_CHECK_INDEX_ONLY: + if (has_index) + srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; + break; + } + + return count; +} + +static int push_attr_file( + git_repository *repo, + git_attr_session *attr_session, + git_vector *list, + git_attr_file_source source, + const char *base, + const char *filename) +{ + int error = 0; + git_attr_file *file = NULL; + + error = git_attr_cache__get(&file, repo, attr_session, + source, base, filename, git_attr_file__parse_buffer); + + if (error < 0) + return error; + + if (file != NULL) { + if ((error = git_vector_insert(list, file)) < 0) + git_attr_file__free(file); + } + + return error; +} + +static int push_one_attr(void *ref, const char *path) +{ + int error = 0, n_src, i; + attr_walk_up_info *info = (attr_walk_up_info *)ref; + git_attr_file_source src[2]; + + n_src = attr_decide_sources( + info->flags, info->workdir != NULL, info->index != NULL, src); + + for (i = 0; !error && i < n_src; ++i) + error = push_attr_file(info->repo, info->attr_session, + info->files, src[i], path, GIT_ATTR_FILE); + + return error; +} + +static void release_attr_files(git_vector *files) +{ + size_t i; + git_attr_file *file; + + git_vector_foreach(files, i, file) { + git_attr_file__free(file); + files->contents[i] = NULL; + } + git_vector_free(files); +} + +static int collect_attr_files( + git_repository *repo, + git_attr_session *attr_session, + uint32_t flags, + const char *path, + git_vector *files) +{ + int error = 0; + git_buf dir = GIT_BUF_INIT; + const char *workdir = git_repository_workdir(repo); + attr_walk_up_info info = { NULL }; + + if ((error = attr_setup(repo, attr_session)) < 0) + return error; + + /* Resolve path in a non-bare repo */ + if (workdir != NULL) + error = git_path_find_dir(&dir, path, workdir); + else + error = git_path_dirname_r(&dir, path); + if (error < 0) + goto cleanup; + + /* in precendence order highest to lowest: + * - $GIT_DIR/info/attributes + * - path components with .gitattributes + * - config core.attributesfile + * - $GIT_PREFIX/etc/gitattributes + */ + + error = push_attr_file( + repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, + git_repository_path(repo), GIT_ATTR_FILE_INREPO); + if (error < 0) + goto cleanup; + + info.repo = repo; + info.attr_session = attr_session; + info.flags = flags; + info.workdir = workdir; + if (git_repository_index__weakptr(&info.index, repo) < 0) + giterr_clear(); /* no error even if there is no index */ + info.files = files; + + if (!strcmp(dir.ptr, ".")) + error = push_one_attr(&info, ""); + else + error = git_path_walk_up(&dir, workdir, push_one_attr, &info); + + if (error < 0) + goto cleanup; + + if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) { + error = push_attr_file( + repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, + NULL, git_repository_attr_cache(repo)->cfg_attr_file); + if (error < 0) + goto cleanup; + } + + if ((flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) { + error = system_attr_file(&dir, attr_session); + + if (!error) + error = push_attr_file( + repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, + NULL, dir.ptr); + else if (error == GIT_ENOTFOUND) + error = 0; + } + + cleanup: + if (error < 0) + release_attr_files(files); + git_buf_free(&dir); + + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/attr.h b/deps/libgit2-sys-0.2.17/libgit2/src/attr.h new file mode 100644 index 000000000..f9f216d07 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/attr.h @@ -0,0 +1,13 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_attr_h__ +#define INCLUDE_attr_h__ + +#include "attr_file.h" +#include "attrcache.h" + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/attr_file.c b/deps/libgit2-sys-0.2.17/libgit2/src/attr_file.c new file mode 100644 index 000000000..8997946b9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/attr_file.c @@ -0,0 +1,867 @@ +#include "common.h" +#include "repository.h" +#include "filebuf.h" +#include "attr_file.h" +#include "attrcache.h" +#include "git2/blob.h" +#include "git2/tree.h" +#include "index.h" +#include + +static void attr_file_free(git_attr_file *file) +{ + bool unlock = !git_mutex_lock(&file->lock); + git_attr_file__clear_rules(file, false); + git_pool_clear(&file->pool); + if (unlock) + git_mutex_unlock(&file->lock); + git_mutex_free(&file->lock); + + git__memzero(file, sizeof(*file)); + git__free(file); +} + +int git_attr_file__new( + git_attr_file **out, + git_attr_file_entry *entry, + git_attr_file_source source) +{ + git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file)); + GITERR_CHECK_ALLOC(attrs); + + if (git_mutex_init(&attrs->lock) < 0) { + giterr_set(GITERR_OS, "Failed to initialize lock"); + git__free(attrs); + return -1; + } + + if (git_pool_init(&attrs->pool, 1, 0) < 0) { + attr_file_free(attrs); + return -1; + } + + GIT_REFCOUNT_INC(attrs); + attrs->entry = entry; + attrs->source = source; + *out = attrs; + return 0; +} + +int git_attr_file__clear_rules(git_attr_file *file, bool need_lock) +{ + unsigned int i; + git_attr_rule *rule; + + if (need_lock && git_mutex_lock(&file->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock attribute file"); + return -1; + } + + git_vector_foreach(&file->rules, i, rule) + git_attr_rule__free(rule); + git_vector_free(&file->rules); + + if (need_lock) + git_mutex_unlock(&file->lock); + + return 0; +} + +void git_attr_file__free(git_attr_file *file) +{ + if (!file) + return; + GIT_REFCOUNT_DEC(file, attr_file_free); +} + +static int attr_file_oid_from_index( + git_oid *oid, git_repository *repo, const char *path) +{ + int error; + git_index *idx; + size_t pos; + const git_index_entry *entry; + + if ((error = git_repository_index__weakptr(&idx, repo)) < 0 || + (error = git_index__find_pos(&pos, idx, path, 0, 0)) < 0) + return error; + + if (!(entry = git_index_get_byindex(idx, pos))) + return GIT_ENOTFOUND; + + *oid = entry->id; + return 0; +} + +int git_attr_file__load( + git_attr_file **out, + git_repository *repo, + git_attr_session *attr_session, + git_attr_file_entry *entry, + git_attr_file_source source, + git_attr_file_parser parser) +{ + int error = 0; + git_blob *blob = NULL; + git_buf content = GIT_BUF_INIT; + git_attr_file *file; + struct stat st; + bool nonexistent = false; + + *out = NULL; + + switch (source) { + case GIT_ATTR_FILE__IN_MEMORY: + /* in-memory attribute file doesn't need data */ + break; + case GIT_ATTR_FILE__FROM_INDEX: { + git_oid id; + + if ((error = attr_file_oid_from_index(&id, repo, entry->path)) < 0 || + (error = git_blob_lookup(&blob, repo, &id)) < 0) + return error; + + /* Do not assume that data straight from the ODB is NULL-terminated; + * copy the contents of a file to a buffer to work on */ + git_buf_put(&content, git_blob_rawcontent(blob), git_blob_rawsize(blob)); + break; + } + case GIT_ATTR_FILE__FROM_FILE: { + int fd; + + /* For open or read errors, pretend that we got ENOTFOUND. */ + /* TODO: issue warning when warning API is available */ + + if (p_stat(entry->fullpath, &st) < 0 || + S_ISDIR(st.st_mode) || + (fd = git_futils_open_ro(entry->fullpath)) < 0 || + (error = git_futils_readbuffer_fd(&content, fd, (size_t)st.st_size)) < 0) + nonexistent = true; + else + p_close(fd); + + break; + } + default: + giterr_set(GITERR_INVALID, "Unknown file source %d", source); + return -1; + } + + if ((error = git_attr_file__new(&file, entry, source)) < 0) + goto cleanup; + + /* store the key of the attr_reader; don't bother with cache + * invalidation during the same attr reader session. + */ + if (attr_session) + file->session_key = attr_session->key; + + if (parser && (error = parser(repo, file, git_buf_cstr(&content))) < 0) { + git_attr_file__free(file); + goto cleanup; + } + + /* write cache breakers */ + if (nonexistent) + file->nonexistent = 1; + else if (source == GIT_ATTR_FILE__FROM_INDEX) + git_oid_cpy(&file->cache_data.oid, git_blob_id(blob)); + else if (source == GIT_ATTR_FILE__FROM_FILE) + git_futils_filestamp_set_from_stat(&file->cache_data.stamp, &st); + /* else always cacheable */ + + *out = file; + +cleanup: + git_blob_free(blob); + git_buf_free(&content); + + return error; +} + +int git_attr_file__out_of_date( + git_repository *repo, + git_attr_session *attr_session, + git_attr_file *file) +{ + if (!file) + return 1; + + /* we are never out of date if we just created this data in the same + * attr_session; otherwise, nonexistent files must be invalidated + */ + if (attr_session && attr_session->key == file->session_key) + return 0; + else if (file->nonexistent) + return 1; + + switch (file->source) { + case GIT_ATTR_FILE__IN_MEMORY: + return 0; + + case GIT_ATTR_FILE__FROM_FILE: + return git_futils_filestamp_check( + &file->cache_data.stamp, file->entry->fullpath); + + case GIT_ATTR_FILE__FROM_INDEX: { + int error; + git_oid id; + + if ((error = attr_file_oid_from_index( + &id, repo, file->entry->path)) < 0) + return error; + + return (git_oid__cmp(&file->cache_data.oid, &id) != 0); + } + + default: + giterr_set(GITERR_INVALID, "Invalid file type %d", file->source); + return -1; + } +} + +static int sort_by_hash_and_name(const void *a_raw, const void *b_raw); +static void git_attr_rule__clear(git_attr_rule *rule); +static bool parse_optimized_patterns( + git_attr_fnmatch *spec, + git_pool *pool, + const char *pattern); + +int git_attr_file__parse_buffer( + git_repository *repo, git_attr_file *attrs, const char *data) +{ + int error = 0; + const char *scan = data, *context = NULL; + git_attr_rule *rule = NULL; + + /* if subdir file path, convert context for file paths */ + if (attrs->entry && + git_path_root(attrs->entry->path) < 0 && + !git__suffixcmp(attrs->entry->path, "/" GIT_ATTR_FILE)) + context = attrs->entry->path; + + if (git_mutex_lock(&attrs->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock attribute file"); + return -1; + } + + while (!error && *scan) { + /* allocate rule if needed */ + if (!rule && !(rule = git__calloc(1, sizeof(*rule)))) { + error = -1; + break; + } + + rule->match.flags = + GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_ALLOWMACRO; + + /* parse the next "pattern attr attr attr" line */ + if (!(error = git_attr_fnmatch__parse( + &rule->match, &attrs->pool, context, &scan)) && + !(error = git_attr_assignment__parse( + repo, &attrs->pool, &rule->assigns, &scan))) + { + if (rule->match.flags & GIT_ATTR_FNMATCH_MACRO) + /* TODO: warning if macro found in file below repo root */ + error = git_attr_cache__insert_macro(repo, rule); + else + error = git_vector_insert(&attrs->rules, rule); + } + + /* if the rule wasn't a pattern, on to the next */ + if (error < 0) { + git_attr_rule__clear(rule); /* reset rule contents */ + if (error == GIT_ENOTFOUND) + error = 0; + } else { + rule = NULL; /* vector now "owns" the rule */ + } + } + + git_mutex_unlock(&attrs->lock); + git_attr_rule__free(rule); + + return error; +} + +uint32_t git_attr_file__name_hash(const char *name) +{ + uint32_t h = 5381; + int c; + assert(name); + while ((c = (int)*name++) != 0) + h = ((h << 5) + h) + c; + return h; +} + +int git_attr_file__lookup_one( + git_attr_file *file, + git_attr_path *path, + const char *attr, + const char **value) +{ + size_t i; + git_attr_name name; + git_attr_rule *rule; + + *value = NULL; + + name.name = attr; + name.name_hash = git_attr_file__name_hash(attr); + + git_attr_file__foreach_matching_rule(file, path, i, rule) { + size_t pos; + + if (!git_vector_bsearch(&pos, &rule->assigns, &name)) { + *value = ((git_attr_assignment *) + git_vector_get(&rule->assigns, pos))->value; + break; + } + } + + return 0; +} + +int git_attr_file__load_standalone(git_attr_file **out, const char *path) +{ + int error; + git_attr_file *file; + git_buf content = GIT_BUF_INIT; + + error = git_attr_file__new(&file, NULL, GIT_ATTR_FILE__FROM_FILE); + if (error < 0) + return error; + + error = git_attr_cache__alloc_file_entry( + &file->entry, NULL, path, &file->pool); + if (error < 0) { + git_attr_file__free(file); + return error; + } + /* because the cache entry is allocated from the file's own pool, we + * don't have to free it - freeing file+pool will free cache entry, too. + */ + + if (!(error = git_futils_readbuffer(&content, path))) { + error = git_attr_file__parse_buffer(NULL, file, content.ptr); + git_buf_free(&content); + } + + if (error < 0) + git_attr_file__free(file); + else + *out = file; + + return error; +} + +bool git_attr_fnmatch__match( + git_attr_fnmatch *match, + git_attr_path *path) +{ + const char *filename; + int flags = 0; + + /* + * If the rule was generated in a subdirectory, we must only + * use it for paths inside that directory. We can thus return + * a non-match if the prefixes don't match. + */ + if (match->containing_dir) { + if (match->flags & GIT_ATTR_FNMATCH_ICASE) { + if (git__strncasecmp(path->path, match->containing_dir, match->containing_dir_length)) + return 0; + } else { + if (git__prefixcmp(path->path, match->containing_dir)) + return 0; + } + } + + if (match->flags & GIT_ATTR_FNMATCH_ICASE) + flags |= FNM_CASEFOLD; + if (match->flags & GIT_ATTR_FNMATCH_LEADINGDIR) + flags |= FNM_LEADING_DIR; + + if (match->flags & GIT_ATTR_FNMATCH_FULLPATH) { + filename = path->path; + flags |= FNM_PATHNAME; + } else { + filename = path->basename; + + if (path->is_dir) + flags |= FNM_LEADING_DIR; + } + + if ((match->flags & GIT_ATTR_FNMATCH_DIRECTORY) && !path->is_dir) { + int matchval; + + /* for attribute checks or root ignore checks, fail match */ + if (!(match->flags & GIT_ATTR_FNMATCH_IGNORE) || + path->basename == path->path) + return false; + + /* for ignore checks, use container of current item for check */ + path->basename[-1] = '\0'; + flags |= FNM_LEADING_DIR; + matchval = p_fnmatch(match->pattern, path->path, flags); + path->basename[-1] = '/'; + return (matchval != FNM_NOMATCH); + } + + /* if path is a directory prefix of a negated pattern, then match */ + if ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) && path->is_dir) { + size_t pathlen = strlen(path->path); + bool prefixed = (pathlen <= match->length) && + ((match->flags & GIT_ATTR_FNMATCH_ICASE) ? + !strncasecmp(match->pattern, path->path, pathlen) : + !strncmp(match->pattern, path->path, pathlen)); + + if (prefixed && git_path_at_end_of_segment(&match->pattern[pathlen])) + return true; + } + + return (p_fnmatch(match->pattern, filename, flags) != FNM_NOMATCH); +} + +bool git_attr_rule__match( + git_attr_rule *rule, + git_attr_path *path) +{ + bool matched = git_attr_fnmatch__match(&rule->match, path); + + if (rule->match.flags & GIT_ATTR_FNMATCH_NEGATIVE) + matched = !matched; + + return matched; +} + +git_attr_assignment *git_attr_rule__lookup_assignment( + git_attr_rule *rule, const char *name) +{ + size_t pos; + git_attr_name key; + key.name = name; + key.name_hash = git_attr_file__name_hash(name); + + if (git_vector_bsearch(&pos, &rule->assigns, &key)) + return NULL; + + return git_vector_get(&rule->assigns, pos); +} + +int git_attr_path__init( + git_attr_path *info, const char *path, const char *base) +{ + ssize_t root; + + /* build full path as best we can */ + git_buf_init(&info->full, 0); + + if (git_path_join_unrooted(&info->full, path, base, &root) < 0) + return -1; + + info->path = info->full.ptr + root; + + /* remove trailing slashes */ + while (info->full.size > 0) { + if (info->full.ptr[info->full.size - 1] != '/') + break; + info->full.size--; + } + info->full.ptr[info->full.size] = '\0'; + + /* skip leading slashes in path */ + while (*info->path == '/') + info->path++; + + /* find trailing basename component */ + info->basename = strrchr(info->path, '/'); + if (info->basename) + info->basename++; + if (!info->basename || !*info->basename) + info->basename = info->path; + + info->is_dir = (int)git_path_isdir(info->full.ptr); + + return 0; +} + +void git_attr_path__free(git_attr_path *info) +{ + git_buf_free(&info->full); + info->path = NULL; + info->basename = NULL; +} + +/* + * From gitattributes(5): + * + * Patterns have the following format: + * + * - A blank line matches no files, so it can serve as a separator for + * readability. + * + * - A line starting with # serves as a comment. + * + * - An optional prefix ! which negates the pattern; any matching file + * excluded by a previous pattern will become included again. If a negated + * pattern matches, this will override lower precedence patterns sources. + * + * - If the pattern ends with a slash, it is removed for the purpose of the + * following description, but it would only find a match with a directory. In + * other words, foo/ will match a directory foo and paths underneath it, but + * will not match a regular file or a symbolic link foo (this is consistent + * with the way how pathspec works in general in git). + * + * - If the pattern does not contain a slash /, git treats it as a shell glob + * pattern and checks for a match against the pathname without leading + * directories. + * + * - Otherwise, git treats the pattern as a shell glob suitable for consumption + * by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will + * not match a / in the pathname. For example, "Documentation/\*.html" matches + * "Documentation/git.html" but not "Documentation/ppc/ppc.html". A leading + * slash matches the beginning of the pathname; for example, "/\*.c" matches + * "cat-file.c" but not "mozilla-sha1/sha1.c". + */ + +/* + * This will return 0 if the spec was filled out, + * GIT_ENOTFOUND if the fnmatch does not require matching, or + * another error code there was an actual problem. + */ +int git_attr_fnmatch__parse( + git_attr_fnmatch *spec, + git_pool *pool, + const char *context, + const char **base) +{ + const char *pattern, *scan; + int slash_count, allow_space; + + assert(spec && base && *base); + + if (parse_optimized_patterns(spec, pool, *base)) + return 0; + + spec->flags = (spec->flags & GIT_ATTR_FNMATCH__INCOMING); + allow_space = ((spec->flags & GIT_ATTR_FNMATCH_ALLOWSPACE) != 0); + + pattern = *base; + + while (git__isspace(*pattern)) pattern++; + if (!*pattern || *pattern == '#') { + *base = git__next_line(pattern); + return GIT_ENOTFOUND; + } + + if (*pattern == '[' && (spec->flags & GIT_ATTR_FNMATCH_ALLOWMACRO) != 0) { + if (strncmp(pattern, "[attr]", 6) == 0) { + spec->flags = spec->flags | GIT_ATTR_FNMATCH_MACRO; + pattern += 6; + } + /* else a character range like [a-e]* which is accepted */ + } + + if (*pattern == '!' && (spec->flags & GIT_ATTR_FNMATCH_ALLOWNEG) != 0) { + spec->flags = spec->flags | + GIT_ATTR_FNMATCH_NEGATIVE | GIT_ATTR_FNMATCH_LEADINGDIR; + pattern++; + } + + slash_count = 0; + for (scan = pattern; *scan != '\0'; ++scan) { + /* scan until (non-escaped) white space */ + if (git__isspace(*scan) && *(scan - 1) != '\\') { + if (!allow_space || (*scan != ' ' && *scan != '\t' && *scan != '\r')) + break; + } + + if (*scan == '/') { + spec->flags = spec->flags | GIT_ATTR_FNMATCH_FULLPATH; + slash_count++; + if (pattern == scan) + pattern++; + } + /* remember if we see an unescaped wildcard in pattern */ + else if (git__iswildcard(*scan) && + (scan == pattern || (*(scan - 1) != '\\'))) + spec->flags = spec->flags | GIT_ATTR_FNMATCH_HASWILD; + } + + *base = scan; + + if ((spec->length = scan - pattern) == 0) + return GIT_ENOTFOUND; + + /* + * Remove one trailing \r in case this is a CRLF delimited + * file, in the case of Icon\r\r\n, we still leave the first + * \r there to match against. + */ + if (pattern[spec->length - 1] == '\r') + if (--spec->length == 0) + return GIT_ENOTFOUND; + + if (pattern[spec->length - 1] == '/') { + spec->length--; + spec->flags = spec->flags | GIT_ATTR_FNMATCH_DIRECTORY; + if (--slash_count <= 0) + spec->flags = spec->flags & ~GIT_ATTR_FNMATCH_FULLPATH; + } + if ((spec->flags & GIT_ATTR_FNMATCH_NOLEADINGDIR) == 0 && + spec->length >= 2 && + pattern[spec->length - 1] == '*' && + pattern[spec->length - 2] == '/') { + spec->length -= 2; + spec->flags = spec->flags | GIT_ATTR_FNMATCH_LEADINGDIR; + /* leave FULLPATH match on, however */ + } + + if (context) { + char *slash = strchr(context, '/'); + size_t len; + if (slash) { + /* include the slash for easier matching */ + len = slash - context + 1; + spec->containing_dir = git_pool_strndup(pool, context, len); + spec->containing_dir_length = len; + } + } + + if ((spec->flags & GIT_ATTR_FNMATCH_FULLPATH) != 0 && + context != NULL && git_path_root(pattern) < 0) + { + /* use context path minus the trailing filename */ + char *slash = strrchr(context, '/'); + size_t contextlen = slash ? slash - context + 1 : 0; + + /* given an unrooted fullpath match from a file inside a repo, + * prefix the pattern with the relative directory of the source file + */ + spec->pattern = git_pool_malloc( + pool, (uint32_t)(contextlen + spec->length + 1)); + if (spec->pattern) { + memcpy(spec->pattern, context, contextlen); + memcpy(spec->pattern + contextlen, pattern, spec->length); + spec->length += contextlen; + spec->pattern[spec->length] = '\0'; + } + } else { + spec->pattern = git_pool_strndup(pool, pattern, spec->length); + } + + if (!spec->pattern) { + *base = git__next_line(pattern); + return -1; + } else { + /* strip '\' that might have be used for internal whitespace */ + spec->length = git__unescape(spec->pattern); + /* TODO: convert remaining '\' into '/' for POSIX ??? */ + } + + return 0; +} + +static bool parse_optimized_patterns( + git_attr_fnmatch *spec, + git_pool *pool, + const char *pattern) +{ + if (!pattern[1] && (pattern[0] == '*' || pattern[0] == '.')) { + spec->flags = GIT_ATTR_FNMATCH_MATCH_ALL; + spec->pattern = git_pool_strndup(pool, pattern, 1); + spec->length = 1; + + return true; + } + + return false; +} + +static int sort_by_hash_and_name(const void *a_raw, const void *b_raw) +{ + const git_attr_name *a = a_raw; + const git_attr_name *b = b_raw; + + if (b->name_hash < a->name_hash) + return 1; + else if (b->name_hash > a->name_hash) + return -1; + else + return strcmp(b->name, a->name); +} + +static void git_attr_assignment__free(git_attr_assignment *assign) +{ + /* name and value are stored in a git_pool associated with the + * git_attr_file, so they do not need to be freed here + */ + assign->name = NULL; + assign->value = NULL; + git__free(assign); +} + +static int merge_assignments(void **old_raw, void *new_raw) +{ + git_attr_assignment **old = (git_attr_assignment **)old_raw; + git_attr_assignment *new = (git_attr_assignment *)new_raw; + + GIT_REFCOUNT_DEC(*old, git_attr_assignment__free); + *old = new; + return GIT_EEXISTS; +} + +int git_attr_assignment__parse( + git_repository *repo, + git_pool *pool, + git_vector *assigns, + const char **base) +{ + int error; + const char *scan = *base; + git_attr_assignment *assign = NULL; + + assert(assigns && !assigns->length); + + git_vector_set_cmp(assigns, sort_by_hash_and_name); + + while (*scan && *scan != '\n') { + const char *name_start, *value_start; + + /* skip leading blanks */ + while (git__isspace(*scan) && *scan != '\n') scan++; + + /* allocate assign if needed */ + if (!assign) { + assign = git__calloc(1, sizeof(git_attr_assignment)); + GITERR_CHECK_ALLOC(assign); + GIT_REFCOUNT_INC(assign); + } + + assign->name_hash = 5381; + assign->value = git_attr__true; + + /* look for magic name prefixes */ + if (*scan == '-') { + assign->value = git_attr__false; + scan++; + } else if (*scan == '!') { + assign->value = git_attr__unset; /* explicit unspecified state */ + scan++; + } else if (*scan == '#') /* comment rest of line */ + break; + + /* find the name */ + name_start = scan; + while (*scan && !git__isspace(*scan) && *scan != '=') { + assign->name_hash = + ((assign->name_hash << 5) + assign->name_hash) + *scan; + scan++; + } + if (scan == name_start) { + /* must have found lone prefix (" - ") or leading = ("=foo") + * or end of buffer -- advance until whitespace and continue + */ + while (*scan && !git__isspace(*scan)) scan++; + continue; + } + + /* allocate permanent storage for name */ + assign->name = git_pool_strndup(pool, name_start, scan - name_start); + GITERR_CHECK_ALLOC(assign->name); + + /* if there is an equals sign, find the value */ + if (*scan == '=') { + for (value_start = ++scan; *scan && !git__isspace(*scan); ++scan); + + /* if we found a value, allocate permanent storage for it */ + if (scan > value_start) { + assign->value = git_pool_strndup(pool, value_start, scan - value_start); + GITERR_CHECK_ALLOC(assign->value); + } + } + + /* expand macros (if given a repo with a macro cache) */ + if (repo != NULL && assign->value == git_attr__true) { + git_attr_rule *macro = + git_attr_cache__lookup_macro(repo, assign->name); + + if (macro != NULL) { + unsigned int i; + git_attr_assignment *massign; + + git_vector_foreach(¯o->assigns, i, massign) { + GIT_REFCOUNT_INC(massign); + + error = git_vector_insert_sorted( + assigns, massign, &merge_assignments); + if (error < 0 && error != GIT_EEXISTS) { + git_attr_assignment__free(assign); + return error; + } + } + } + } + + /* insert allocated assign into vector */ + error = git_vector_insert_sorted(assigns, assign, &merge_assignments); + if (error < 0 && error != GIT_EEXISTS) + return error; + + /* clear assign since it is now "owned" by the vector */ + assign = NULL; + } + + if (assign != NULL) + git_attr_assignment__free(assign); + + *base = git__next_line(scan); + + return (assigns->length == 0) ? GIT_ENOTFOUND : 0; +} + +static void git_attr_rule__clear(git_attr_rule *rule) +{ + unsigned int i; + git_attr_assignment *assign; + + if (!rule) + return; + + if (!(rule->match.flags & GIT_ATTR_FNMATCH_IGNORE)) { + git_vector_foreach(&rule->assigns, i, assign) + GIT_REFCOUNT_DEC(assign, git_attr_assignment__free); + git_vector_free(&rule->assigns); + } + + /* match.pattern is stored in a git_pool, so no need to free */ + rule->match.pattern = NULL; + rule->match.length = 0; +} + +void git_attr_rule__free(git_attr_rule *rule) +{ + git_attr_rule__clear(rule); + git__free(rule); +} + +int git_attr_session__init(git_attr_session *session, git_repository *repo) +{ + assert(repo); + + session->key = git_atomic_inc(&repo->attr_session_key); + + return 0; +} + +void git_attr_session__free(git_attr_session *session) +{ + if (!session) + return; + + git_buf_free(&session->sysdir); + git_buf_free(&session->tmp); + + memset(session, 0, sizeof(git_attr_session)); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/attr_file.h b/deps/libgit2-sys-0.2.17/libgit2/src/attr_file.h new file mode 100644 index 000000000..aa9a16de0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/attr_file.h @@ -0,0 +1,216 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_attr_file_h__ +#define INCLUDE_attr_file_h__ + +#include "git2/oid.h" +#include "git2/attr.h" +#include "vector.h" +#include "pool.h" +#include "buffer.h" +#include "fileops.h" + +#define GIT_ATTR_FILE ".gitattributes" +#define GIT_ATTR_FILE_INREPO "info/attributes" +#define GIT_ATTR_FILE_SYSTEM "gitattributes" +#define GIT_ATTR_FILE_XDG "attributes" + +#define GIT_ATTR_FNMATCH_NEGATIVE (1U << 0) +#define GIT_ATTR_FNMATCH_DIRECTORY (1U << 1) +#define GIT_ATTR_FNMATCH_FULLPATH (1U << 2) +#define GIT_ATTR_FNMATCH_MACRO (1U << 3) +#define GIT_ATTR_FNMATCH_IGNORE (1U << 4) +#define GIT_ATTR_FNMATCH_HASWILD (1U << 5) +#define GIT_ATTR_FNMATCH_ALLOWSPACE (1U << 6) +#define GIT_ATTR_FNMATCH_ICASE (1U << 7) +#define GIT_ATTR_FNMATCH_MATCH_ALL (1U << 8) +#define GIT_ATTR_FNMATCH_ALLOWNEG (1U << 9) +#define GIT_ATTR_FNMATCH_ALLOWMACRO (1U << 10) +#define GIT_ATTR_FNMATCH_LEADINGDIR (1U << 11) +#define GIT_ATTR_FNMATCH_NOLEADINGDIR (1U << 12) + +#define GIT_ATTR_FNMATCH__INCOMING \ + (GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG | \ + GIT_ATTR_FNMATCH_ALLOWMACRO | GIT_ATTR_FNMATCH_NOLEADINGDIR) + +typedef enum { + GIT_ATTR_FILE__IN_MEMORY = 0, + GIT_ATTR_FILE__FROM_FILE = 1, + GIT_ATTR_FILE__FROM_INDEX = 2, + + GIT_ATTR_FILE_NUM_SOURCES = 3 +} git_attr_file_source; + +extern const char *git_attr__true; +extern const char *git_attr__false; +extern const char *git_attr__unset; + +typedef struct { + char *pattern; + size_t length; + char *containing_dir; + size_t containing_dir_length; + unsigned int flags; +} git_attr_fnmatch; + +typedef struct { + git_attr_fnmatch match; + git_vector assigns; /* vector of */ +} git_attr_rule; + +typedef struct { + git_refcount unused; + const char *name; + uint32_t name_hash; +} git_attr_name; + +typedef struct { + git_refcount rc; /* for macros */ + char *name; + uint32_t name_hash; + const char *value; +} git_attr_assignment; + +typedef struct git_attr_file_entry git_attr_file_entry; + +typedef struct { + git_refcount rc; + git_mutex lock; + git_attr_file_entry *entry; + git_attr_file_source source; + git_vector rules; /* vector of or */ + git_pool pool; + unsigned int nonexistent:1; + int session_key; + union { + git_oid oid; + git_futils_filestamp stamp; + } cache_data; +} git_attr_file; + +struct git_attr_file_entry { + git_attr_file *file[GIT_ATTR_FILE_NUM_SOURCES]; + const char *path; /* points into fullpath */ + char fullpath[GIT_FLEX_ARRAY]; +}; + +typedef struct { + git_buf full; + char *path; + char *basename; + int is_dir; +} git_attr_path; + +/* A git_attr_session can provide an "instance" of reading, to prevent cache + * invalidation during a single operation instance (like checkout). + */ + +typedef struct { + int key; + unsigned int init_setup:1, + init_sysdir:1; + git_buf sysdir; + git_buf tmp; +} git_attr_session; + +extern int git_attr_session__init(git_attr_session *attr_session, git_repository *repo); +extern void git_attr_session__free(git_attr_session *session); + +extern int git_attr_get_many_with_session( + const char **values_out, + git_repository *repo, + git_attr_session *attr_session, + uint32_t flags, + const char *path, + size_t num_attr, + const char **names); + +typedef int (*git_attr_file_parser)( + git_repository *repo, + git_attr_file *file, + const char *data); + +/* + * git_attr_file API + */ + +int git_attr_file__new( + git_attr_file **out, + git_attr_file_entry *entry, + git_attr_file_source source); + +void git_attr_file__free(git_attr_file *file); + +int git_attr_file__load( + git_attr_file **out, + git_repository *repo, + git_attr_session *attr_session, + git_attr_file_entry *ce, + git_attr_file_source source, + git_attr_file_parser parser); + +int git_attr_file__load_standalone( + git_attr_file **out, const char *path); + +int git_attr_file__out_of_date( + git_repository *repo, git_attr_session *session, git_attr_file *file); + +int git_attr_file__parse_buffer( + git_repository *repo, git_attr_file *attrs, const char *data); + +int git_attr_file__clear_rules( + git_attr_file *file, bool need_lock); + +int git_attr_file__lookup_one( + git_attr_file *file, + git_attr_path *path, + const char *attr, + const char **value); + +/* loop over rules in file from bottom to top */ +#define git_attr_file__foreach_matching_rule(file, path, iter, rule) \ + git_vector_rforeach(&(file)->rules, (iter), (rule)) \ + if (git_attr_rule__match((rule), (path))) + +uint32_t git_attr_file__name_hash(const char *name); + + +/* + * other utilities + */ + +extern int git_attr_fnmatch__parse( + git_attr_fnmatch *spec, + git_pool *pool, + const char *source, + const char **base); + +extern bool git_attr_fnmatch__match( + git_attr_fnmatch *rule, + git_attr_path *path); + +extern void git_attr_rule__free(git_attr_rule *rule); + +extern bool git_attr_rule__match( + git_attr_rule *rule, + git_attr_path *path); + +extern git_attr_assignment *git_attr_rule__lookup_assignment( + git_attr_rule *rule, const char *name); + +extern int git_attr_path__init( + git_attr_path *info, const char *path, const char *base); + +extern void git_attr_path__free(git_attr_path *info); + +extern int git_attr_assignment__parse( + git_repository *repo, /* needed to expand macros */ + git_pool *pool, + git_vector *assigns, + const char **scan); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/attrcache.c b/deps/libgit2-sys-0.2.17/libgit2/src/attrcache.c new file mode 100644 index 000000000..5bc260460 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/attrcache.c @@ -0,0 +1,455 @@ +#include "common.h" +#include "repository.h" +#include "attr_file.h" +#include "config.h" +#include "sysdir.h" +#include "ignore.h" + +GIT__USE_STRMAP + +GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache) +{ + GIT_UNUSED(cache); /* avoid warning if threading is off */ + + if (git_mutex_lock(&cache->lock) < 0) { + giterr_set(GITERR_OS, "Unable to get attr cache lock"); + return -1; + } + return 0; +} + +GIT_INLINE(void) attr_cache_unlock(git_attr_cache *cache) +{ + GIT_UNUSED(cache); /* avoid warning if threading is off */ + git_mutex_unlock(&cache->lock); +} + +GIT_INLINE(git_attr_file_entry *) attr_cache_lookup_entry( + git_attr_cache *cache, const char *path) +{ + khiter_t pos = git_strmap_lookup_index(cache->files, path); + + if (git_strmap_valid_index(cache->files, pos)) + return git_strmap_value_at(cache->files, pos); + else + return NULL; +} + +int git_attr_cache__alloc_file_entry( + git_attr_file_entry **out, + const char *base, + const char *path, + git_pool *pool) +{ + size_t baselen = 0, pathlen = strlen(path); + size_t cachesize = sizeof(git_attr_file_entry) + pathlen + 1; + git_attr_file_entry *ce; + + if (base != NULL && git_path_root(path) < 0) { + baselen = strlen(base); + cachesize += baselen; + + if (baselen && base[baselen - 1] != '/') + cachesize++; + } + + ce = git_pool_mallocz(pool, (uint32_t)cachesize); + GITERR_CHECK_ALLOC(ce); + + if (baselen) { + memcpy(ce->fullpath, base, baselen); + + if (base[baselen - 1] != '/') + ce->fullpath[baselen++] = '/'; + } + memcpy(&ce->fullpath[baselen], path, pathlen); + + ce->path = &ce->fullpath[baselen]; + *out = ce; + + return 0; +} + +/* call with attrcache locked */ +static int attr_cache_make_entry( + git_attr_file_entry **out, git_repository *repo, const char *path) +{ + int error = 0; + git_attr_cache *cache = git_repository_attr_cache(repo); + git_attr_file_entry *entry = NULL; + + error = git_attr_cache__alloc_file_entry( + &entry, git_repository_workdir(repo), path, &cache->pool); + + if (!error) { + git_strmap_insert(cache->files, entry->path, entry, error); + if (error > 0) + error = 0; + } + + *out = entry; + return error; +} + +/* insert entry or replace existing if we raced with another thread */ +static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file) +{ + git_attr_file_entry *entry; + git_attr_file *old; + + if (attr_cache_lock(cache) < 0) + return -1; + + entry = attr_cache_lookup_entry(cache, file->entry->path); + + GIT_REFCOUNT_OWN(file, entry); + GIT_REFCOUNT_INC(file); + + old = git__compare_and_swap( + &entry->file[file->source], entry->file[file->source], file); + + if (old) { + GIT_REFCOUNT_OWN(old, NULL); + git_attr_file__free(old); + } + + attr_cache_unlock(cache); + return 0; +} + +static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file) +{ + int error = 0; + git_attr_file_entry *entry; + + if (!file) + return 0; + if ((error = attr_cache_lock(cache)) < 0) + return error; + + if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL) + file = git__compare_and_swap(&entry->file[file->source], file, NULL); + + attr_cache_unlock(cache); + + if (file) { + GIT_REFCOUNT_OWN(file, NULL); + git_attr_file__free(file); + } + + return error; +} + +/* Look up cache entry and file. + * - If entry is not present, create it while the cache is locked. + * - If file is present, increment refcount before returning it, so the + * cache can be unlocked and it won't go away. + */ +static int attr_cache_lookup( + git_attr_file **out_file, + git_attr_file_entry **out_entry, + git_repository *repo, + git_attr_session *attr_session, + git_attr_file_source source, + const char *base, + const char *filename) +{ + int error = 0; + git_buf path = GIT_BUF_INIT; + const char *wd = git_repository_workdir(repo), *relfile; + git_attr_cache *cache = git_repository_attr_cache(repo); + git_attr_file_entry *entry = NULL; + git_attr_file *file = NULL; + + /* join base and path as needed */ + if (base != NULL && git_path_root(filename) < 0) { + git_buf *p = attr_session ? &attr_session->tmp : &path; + + if (git_buf_joinpath(p, base, filename) < 0) + return -1; + + filename = p->ptr; + } + + relfile = filename; + if (wd && !git__prefixcmp(relfile, wd)) + relfile += strlen(wd); + + /* check cache for existing entry */ + if ((error = attr_cache_lock(cache)) < 0) + goto cleanup; + + entry = attr_cache_lookup_entry(cache, relfile); + if (!entry) + error = attr_cache_make_entry(&entry, repo, relfile); + else if (entry->file[source] != NULL) { + file = entry->file[source]; + GIT_REFCOUNT_INC(file); + } + + attr_cache_unlock(cache); + +cleanup: + *out_file = file; + *out_entry = entry; + + git_buf_free(&path); + return error; +} + +int git_attr_cache__get( + git_attr_file **out, + git_repository *repo, + git_attr_session *attr_session, + git_attr_file_source source, + const char *base, + const char *filename, + git_attr_file_parser parser) +{ + int error = 0; + git_attr_cache *cache = git_repository_attr_cache(repo); + git_attr_file_entry *entry = NULL; + git_attr_file *file = NULL, *updated = NULL; + + if ((error = attr_cache_lookup( + &file, &entry, repo, attr_session, source, base, filename)) < 0) + return error; + + /* load file if we don't have one or if existing one is out of date */ + if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0) + error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser); + + /* if we loaded the file, insert into and/or update cache */ + if (updated) { + if ((error = attr_cache_upsert(cache, updated)) < 0) + git_attr_file__free(updated); + else { + git_attr_file__free(file); /* offset incref from lookup */ + file = updated; + } + } + + /* if file could not be loaded */ + if (error < 0) { + /* remove existing entry */ + if (file) { + attr_cache_remove(cache, file); + git_attr_file__free(file); /* offset incref from lookup */ + file = NULL; + } + /* no error if file simply doesn't exist */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + } + + *out = file; + return error; +} + +bool git_attr_cache__is_cached( + git_repository *repo, + git_attr_file_source source, + const char *filename) +{ + git_attr_cache *cache = git_repository_attr_cache(repo); + git_strmap *files; + khiter_t pos; + git_attr_file_entry *entry; + + if (!cache || !(files = cache->files)) + return false; + + pos = git_strmap_lookup_index(files, filename); + if (!git_strmap_valid_index(files, pos)) + return false; + + entry = git_strmap_value_at(files, pos); + + return entry && (entry->file[source] != NULL); +} + + +static int attr_cache__lookup_path( + char **out, git_config *cfg, const char *key, const char *fallback) +{ + git_buf buf = GIT_BUF_INIT; + int error; + git_config_entry *entry = NULL; + + *out = NULL; + + if ((error = git_config__lookup_entry(&entry, cfg, key, false)) < 0) + return error; + + if (entry) { + const char *cfgval = entry->value; + + /* expand leading ~/ as needed */ + if (cfgval && cfgval[0] == '~' && cfgval[1] == '/' && + !git_sysdir_find_global_file(&buf, &cfgval[2])) + *out = git_buf_detach(&buf); + else if (cfgval) + *out = git__strdup(cfgval); + } + else if (!git_sysdir_find_xdg_file(&buf, fallback)) + *out = git_buf_detach(&buf); + + git_config_entry_free(entry); + git_buf_free(&buf); + + return error; +} + +static void attr_cache__free(git_attr_cache *cache) +{ + bool unlock; + + if (!cache) + return; + + unlock = (git_mutex_lock(&cache->lock) == 0); + + if (cache->files != NULL) { + git_attr_file_entry *entry; + git_attr_file *file; + int i; + + git_strmap_foreach_value(cache->files, entry, { + for (i = 0; i < GIT_ATTR_FILE_NUM_SOURCES; ++i) { + if ((file = git__swap(entry->file[i], NULL)) != NULL) { + GIT_REFCOUNT_OWN(file, NULL); + git_attr_file__free(file); + } + } + }); + git_strmap_free(cache->files); + } + + if (cache->macros != NULL) { + git_attr_rule *rule; + + git_strmap_foreach_value(cache->macros, rule, { + git_attr_rule__free(rule); + }); + git_strmap_free(cache->macros); + } + + git_pool_clear(&cache->pool); + + git__free(cache->cfg_attr_file); + cache->cfg_attr_file = NULL; + + git__free(cache->cfg_excl_file); + cache->cfg_excl_file = NULL; + + if (unlock) + git_mutex_unlock(&cache->lock); + git_mutex_free(&cache->lock); + + git__free(cache); +} + +int git_attr_cache__do_init(git_repository *repo) +{ + int ret = 0; + git_attr_cache *cache = git_repository_attr_cache(repo); + git_config *cfg = NULL; + + if (cache) + return 0; + + cache = git__calloc(1, sizeof(git_attr_cache)); + GITERR_CHECK_ALLOC(cache); + + /* set up lock */ + if (git_mutex_init(&cache->lock) < 0) { + giterr_set(GITERR_OS, "Unable to initialize lock for attr cache"); + git__free(cache); + return -1; + } + + if ((ret = git_repository_config_snapshot(&cfg, repo)) < 0) + goto cancel; + + /* cache config settings for attributes and ignores */ + ret = attr_cache__lookup_path( + &cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG, GIT_ATTR_FILE_XDG); + if (ret < 0) + goto cancel; + + ret = attr_cache__lookup_path( + &cache->cfg_excl_file, cfg, GIT_IGNORE_CONFIG, GIT_IGNORE_FILE_XDG); + if (ret < 0) + goto cancel; + + /* allocate hashtable for attribute and ignore file contents, + * hashtable for attribute macros, and string pool + */ + if ((ret = git_strmap_alloc(&cache->files)) < 0 || + (ret = git_strmap_alloc(&cache->macros)) < 0 || + (ret = git_pool_init(&cache->pool, 1, 0)) < 0) + goto cancel; + + cache = git__compare_and_swap(&repo->attrcache, NULL, cache); + if (cache) + goto cancel; /* raced with another thread, free this but no error */ + + git_config_free(cfg); + + /* insert default macros */ + return git_attr_add_macro(repo, "binary", "-diff -crlf -text"); + +cancel: + attr_cache__free(cache); + git_config_free(cfg); + return ret; +} + +void git_attr_cache_flush(git_repository *repo) +{ + git_attr_cache *cache; + + /* this could be done less expensively, but for now, we'll just free + * the entire attrcache and let the next use reinitialize it... + */ + if (repo && (cache = git__swap(repo->attrcache, NULL)) != NULL) + attr_cache__free(cache); +} + +int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro) +{ + git_attr_cache *cache = git_repository_attr_cache(repo); + git_strmap *macros = cache->macros; + int error; + + /* TODO: generate warning log if (macro->assigns.length == 0) */ + if (macro->assigns.length == 0) + return 0; + + if (git_mutex_lock(&cache->lock) < 0) { + giterr_set(GITERR_OS, "Unable to get attr cache lock"); + error = -1; + } else { + git_strmap_insert(macros, macro->match.pattern, macro, error); + git_mutex_unlock(&cache->lock); + } + + return (error < 0) ? -1 : 0; +} + +git_attr_rule *git_attr_cache__lookup_macro( + git_repository *repo, const char *name) +{ + git_strmap *macros = git_repository_attr_cache(repo)->macros; + khiter_t pos; + + pos = git_strmap_lookup_index(macros, name); + + if (!git_strmap_valid_index(macros, pos)) + return NULL; + + return (git_attr_rule *)git_strmap_value_at(macros, pos); +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/attrcache.h b/deps/libgit2-sys-0.2.17/libgit2/src/attrcache.h new file mode 100644 index 000000000..44e1ffdce --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/attrcache.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_attrcache_h__ +#define INCLUDE_attrcache_h__ + +#include "attr_file.h" +#include "strmap.h" + +#define GIT_ATTR_CONFIG "core.attributesfile" +#define GIT_IGNORE_CONFIG "core.excludesfile" + +typedef struct { + char *cfg_attr_file; /* cached value of core.attributesfile */ + char *cfg_excl_file; /* cached value of core.excludesfile */ + git_strmap *files; /* hash path to git_attr_cache_entry records */ + git_strmap *macros; /* hash name to vector */ + git_mutex lock; + git_pool pool; +} git_attr_cache; + +extern int git_attr_cache__do_init(git_repository *repo); + +#define git_attr_cache__init(REPO) \ + (git_repository_attr_cache(REPO) ? 0 : git_attr_cache__do_init(REPO)) + +/* get file - loading and reload as needed */ +extern int git_attr_cache__get( + git_attr_file **file, + git_repository *repo, + git_attr_session *attr_session, + git_attr_file_source source, + const char *base, + const char *filename, + git_attr_file_parser parser); + +extern bool git_attr_cache__is_cached( + git_repository *repo, + git_attr_file_source source, + const char *path); + +extern int git_attr_cache__alloc_file_entry( + git_attr_file_entry **out, + const char *base, + const char *path, + git_pool *pool); + +extern int git_attr_cache__insert_macro( + git_repository *repo, git_attr_rule *macro); + +extern git_attr_rule *git_attr_cache__lookup_macro( + git_repository *repo, const char *name); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/bitvec.h b/deps/libgit2-sys-0.2.17/libgit2/src/bitvec.h new file mode 100644 index 000000000..544832d95 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/bitvec.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_bitvec_h__ +#define INCLUDE_bitvec_h__ + +#include "common.h" + +/* + * This is a silly little fixed length bit vector type that will store + * vectors of 64 bits or less directly in the structure and allocate + * memory for vectors longer than 64 bits. You can use the two versions + * transparently through the API and avoid heap allocation completely when + * using a short bit vector as a result. + */ +typedef struct { + size_t length; + union { + uint64_t *words; + uint64_t bits; + } u; +} git_bitvec; + +GIT_INLINE(int) git_bitvec_init(git_bitvec *bv, size_t capacity) +{ + memset(bv, 0x0, sizeof(*bv)); + + if (capacity >= 64) { + bv->length = (capacity / 64) + 1; + bv->u.words = git__calloc(bv->length, sizeof(uint64_t)); + if (!bv->u.words) + return -1; + } + + return 0; +} + +#define GIT_BITVEC_MASK(BIT) ((uint64_t)1 << (BIT % 64)) +#define GIT_BITVEC_WORD(BV, BIT) (BV->length ? &BV->u.words[BIT / 64] : &BV->u.bits) + +GIT_INLINE(void) git_bitvec_set(git_bitvec *bv, size_t bit, bool on) +{ + uint64_t *word = GIT_BITVEC_WORD(bv, bit); + uint64_t mask = GIT_BITVEC_MASK(bit); + + if (on) + *word |= mask; + else + *word &= ~mask; +} + +GIT_INLINE(bool) git_bitvec_get(git_bitvec *bv, size_t bit) +{ + uint64_t *word = GIT_BITVEC_WORD(bv, bit); + return (*word & GIT_BITVEC_MASK(bit)) != 0; +} + +GIT_INLINE(void) git_bitvec_clear(git_bitvec *bv) +{ + if (!bv->length) + bv->u.bits = 0; + else + memset(bv->u.words, 0x0, bv->length * sizeof(uint64_t)); +} + +GIT_INLINE(void) git_bitvec_free(git_bitvec *bv) +{ + if (bv->length) + git__free(bv->u.words); +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/blame.c b/deps/libgit2-sys-0.2.17/libgit2/src/blame.c new file mode 100644 index 000000000..4a12cb85b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/blame.c @@ -0,0 +1,511 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "blame.h" +#include "git2/commit.h" +#include "git2/revparse.h" +#include "git2/revwalk.h" +#include "git2/tree.h" +#include "git2/diff.h" +#include "git2/blob.h" +#include "git2/signature.h" +#include "util.h" +#include "repository.h" +#include "blame_git.h" + + +static int hunk_byfinalline_search_cmp(const void *key, const void *entry) +{ + git_blame_hunk *hunk = (git_blame_hunk*)entry; + + size_t lineno = *(size_t*)key; + size_t lines_in_hunk = (size_t)hunk->lines_in_hunk; + size_t final_start_line_number = (size_t)hunk->final_start_line_number; + + if (lineno < final_start_line_number) + return -1; + if (lineno >= final_start_line_number + lines_in_hunk) + return 1; + return 0; +} + +static int paths_cmp(const void *a, const void *b) { return git__strcmp((char*)a, (char*)b); } +static int hunk_cmp(const void *_a, const void *_b) +{ + git_blame_hunk *a = (git_blame_hunk*)_a, + *b = (git_blame_hunk*)_b; + + return a->final_start_line_number - b->final_start_line_number; +} + +static bool hunk_ends_at_or_before_line(git_blame_hunk *hunk, size_t line) +{ + return line >= (size_t)(hunk->final_start_line_number + hunk->lines_in_hunk - 1); +} + +static bool hunk_starts_at_or_after_line(git_blame_hunk *hunk, size_t line) +{ + return line <= hunk->final_start_line_number; +} + +static git_blame_hunk* new_hunk( + uint16_t start, + uint16_t lines, + uint16_t orig_start, + const char *path) +{ + git_blame_hunk *hunk = git__calloc(1, sizeof(git_blame_hunk)); + if (!hunk) return NULL; + + hunk->lines_in_hunk = lines; + hunk->final_start_line_number = start; + hunk->orig_start_line_number = orig_start; + hunk->orig_path = path ? git__strdup(path) : NULL; + + return hunk; +} + +static git_blame_hunk* dup_hunk(git_blame_hunk *hunk) +{ + git_blame_hunk *newhunk = new_hunk( + hunk->final_start_line_number, + hunk->lines_in_hunk, + hunk->orig_start_line_number, + hunk->orig_path); + + if (!newhunk) + return NULL; + + git_oid_cpy(&newhunk->orig_commit_id, &hunk->orig_commit_id); + git_oid_cpy(&newhunk->final_commit_id, &hunk->final_commit_id); + newhunk->boundary = hunk->boundary; + git_signature_dup(&newhunk->final_signature, hunk->final_signature); + git_signature_dup(&newhunk->orig_signature, hunk->orig_signature); + return newhunk; +} + +static void free_hunk(git_blame_hunk *hunk) +{ + git__free((void*)hunk->orig_path); + git_signature_free(hunk->final_signature); + git_signature_free(hunk->orig_signature); + git__free(hunk); +} + +/* Starting with the hunk that includes start_line, shift all following hunks' + * final_start_line by shift_by lines */ +static void shift_hunks_by(git_vector *v, size_t start_line, int shift_by) +{ + size_t i; + + if (!git_vector_bsearch2(&i, v, hunk_byfinalline_search_cmp, &start_line)) { + for (; i < v->length; i++) { + git_blame_hunk *hunk = (git_blame_hunk*)v->contents[i]; + hunk->final_start_line_number += shift_by; + } + } +} + +git_blame* git_blame__alloc( + git_repository *repo, + git_blame_options opts, + const char *path) +{ + git_blame *gbr = git__calloc(1, sizeof(git_blame)); + if (!gbr) + return NULL; + + gbr->repository = repo; + gbr->options = opts; + + if (git_vector_init(&gbr->hunks, 8, hunk_cmp) < 0 || + git_vector_init(&gbr->paths, 8, paths_cmp) < 0 || + (gbr->path = git__strdup(path)) == NULL || + git_vector_insert(&gbr->paths, git__strdup(path)) < 0) + { + git_blame_free(gbr); + return NULL; + } + + return gbr; +} + +void git_blame_free(git_blame *blame) +{ + size_t i; + git_blame_hunk *hunk; + + if (!blame) return; + + git_vector_foreach(&blame->hunks, i, hunk) + free_hunk(hunk); + git_vector_free(&blame->hunks); + + git_vector_free_deep(&blame->paths); + + git_array_clear(blame->line_index); + + git__free(blame->path); + git_blob_free(blame->final_blob); + git__free(blame); +} + +uint32_t git_blame_get_hunk_count(git_blame *blame) +{ + assert(blame); + return (uint32_t)blame->hunks.length; +} + +const git_blame_hunk *git_blame_get_hunk_byindex(git_blame *blame, uint32_t index) +{ + assert(blame); + return (git_blame_hunk*)git_vector_get(&blame->hunks, index); +} + +const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, uint32_t lineno) +{ + size_t i, new_lineno = (size_t)lineno; + assert(blame); + + if (!git_vector_bsearch2(&i, &blame->hunks, hunk_byfinalline_search_cmp, &new_lineno)) { + return git_blame_get_hunk_byindex(blame, (uint32_t)i); + } + + return NULL; +} + +static void normalize_options( + git_blame_options *out, + const git_blame_options *in, + git_repository *repo) +{ + git_blame_options dummy = GIT_BLAME_OPTIONS_INIT; + if (!in) in = &dummy; + + memcpy(out, in, sizeof(git_blame_options)); + + /* No newest_commit => HEAD */ + if (git_oid_iszero(&out->newest_commit)) { + git_reference_name_to_id(&out->newest_commit, repo, "HEAD"); + } + + /* min_line 0 really means 1 */ + if (!out->min_line) out->min_line = 1; + /* max_line 0 really means N, but we don't know N yet */ + + /* Fix up option implications */ + if (out->flags & GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES) + out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES; + if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES) + out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES; + if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES) + out->flags |= GIT_BLAME_TRACK_COPIES_SAME_FILE; +} + +static git_blame_hunk *split_hunk_in_vector( + git_vector *vec, + git_blame_hunk *hunk, + size_t rel_line, + bool return_new) +{ + size_t new_line_count; + git_blame_hunk *nh; + + /* Don't split if already at a boundary */ + if (rel_line <= 0 || + rel_line >= hunk->lines_in_hunk) + { + return hunk; + } + + new_line_count = hunk->lines_in_hunk - rel_line; + nh = new_hunk((uint16_t)(hunk->final_start_line_number+rel_line), (uint16_t)new_line_count, + (uint16_t)(hunk->orig_start_line_number+rel_line), hunk->orig_path); + + if (!nh) + return NULL; + + git_oid_cpy(&nh->final_commit_id, &hunk->final_commit_id); + git_oid_cpy(&nh->orig_commit_id, &hunk->orig_commit_id); + + /* Adjust hunk that was split */ + hunk->lines_in_hunk -= (uint16_t)new_line_count; + git_vector_insert_sorted(vec, nh, NULL); + { + git_blame_hunk *ret = return_new ? nh : hunk; + return ret; + } +} + +/* + * Construct a list of char indices for where lines begin + * Adapted from core git: + * https://github.com/gitster/git/blob/be5c9fb9049ed470e7005f159bb923a5f4de1309/builtin/blame.c#L1760-L1789 + */ +static int index_blob_lines(git_blame *blame) +{ + const char *buf = blame->final_buf; + git_off_t len = blame->final_buf_size; + int num = 0, incomplete = 0, bol = 1; + size_t *i; + + if (len && buf[len-1] != '\n') + incomplete++; /* incomplete line at the end */ + while (len--) { + if (bol) { + i = git_array_alloc(blame->line_index); + GITERR_CHECK_ALLOC(i); + *i = buf - blame->final_buf; + bol = 0; + } + if (*buf++ == '\n') { + num++; + bol = 1; + } + } + i = git_array_alloc(blame->line_index); + GITERR_CHECK_ALLOC(i); + *i = buf - blame->final_buf; + blame->num_lines = num + incomplete; + return blame->num_lines; +} + +static git_blame_hunk* hunk_from_entry(git_blame__entry *e) +{ + git_blame_hunk *h = new_hunk( + e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path); + + if (!h) + return NULL; + + git_oid_cpy(&h->final_commit_id, git_commit_id(e->suspect->commit)); + git_oid_cpy(&h->orig_commit_id, git_commit_id(e->suspect->commit)); + git_signature_dup(&h->final_signature, git_commit_author(e->suspect->commit)); + git_signature_dup(&h->orig_signature, git_commit_author(e->suspect->commit)); + h->boundary = e->is_boundary ? 1 : 0; + return h; +} + +static int load_blob(git_blame *blame) +{ + int error; + + if (blame->final_blob) return 0; + + error = git_commit_lookup(&blame->final, blame->repository, &blame->options.newest_commit); + if (error < 0) + goto cleanup; + error = git_object_lookup_bypath((git_object**)&blame->final_blob, + (git_object*)blame->final, blame->path, GIT_OBJ_BLOB); + +cleanup: + return error; +} + +static int blame_internal(git_blame *blame) +{ + int error; + git_blame__entry *ent = NULL; + git_blame__origin *o; + + if ((error = load_blob(blame)) < 0 || + (error = git_blame__get_origin(&o, blame, blame->final, blame->path)) < 0) + goto cleanup; + blame->final_buf = git_blob_rawcontent(blame->final_blob); + blame->final_buf_size = git_blob_rawsize(blame->final_blob); + + ent = git__calloc(1, sizeof(git_blame__entry)); + GITERR_CHECK_ALLOC(ent); + + ent->num_lines = index_blob_lines(blame); + ent->lno = blame->options.min_line - 1; + ent->num_lines = ent->num_lines - blame->options.min_line + 1; + if (blame->options.max_line > 0) + ent->num_lines = blame->options.max_line - blame->options.min_line + 1; + ent->s_lno = ent->lno; + ent->suspect = o; + + blame->ent = ent; + + git_blame__like_git(blame, blame->options.flags); + +cleanup: + for (ent = blame->ent; ent; ) { + git_blame__entry *e = ent->next; + git_blame_hunk *h = hunk_from_entry(ent); + + git_vector_insert(&blame->hunks, h); + + git_blame__free_entry(ent); + ent = e; + } + + return error; +} + +/******************************************************************************* + * File blaming + ******************************************************************************/ + +int git_blame_file( + git_blame **out, + git_repository *repo, + const char *path, + git_blame_options *options) +{ + int error = -1; + git_blame_options normOptions = GIT_BLAME_OPTIONS_INIT; + git_blame *blame = NULL; + + assert(out && repo && path); + normalize_options(&normOptions, options, repo); + + blame = git_blame__alloc(repo, normOptions, path); + GITERR_CHECK_ALLOC(blame); + + if ((error = load_blob(blame)) < 0) + goto on_error; + + if ((error = blame_internal(blame)) < 0) + goto on_error; + + *out = blame; + return 0; + +on_error: + git_blame_free(blame); + return error; +} + +/******************************************************************************* + * Buffer blaming + *******************************************************************************/ + +static bool hunk_is_bufferblame(git_blame_hunk *hunk) +{ + return git_oid_iszero(&hunk->final_commit_id); +} + +static int buffer_hunk_cb( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + void *payload) +{ + git_blame *blame = (git_blame*)payload; + uint32_t wedge_line; + + GIT_UNUSED(delta); + + wedge_line = (hunk->old_lines == 0) ? hunk->new_start : hunk->old_start; + blame->current_diff_line = wedge_line; + + blame->current_hunk = (git_blame_hunk*)git_blame_get_hunk_byline(blame, wedge_line); + if (!blame->current_hunk) { + /* Line added at the end of the file */ + blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path); + GITERR_CHECK_ALLOC(blame->current_hunk); + + git_vector_insert(&blame->hunks, blame->current_hunk); + } else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){ + /* If this hunk doesn't start between existing hunks, split a hunk up so it does */ + blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk, + wedge_line - blame->current_hunk->orig_start_line_number, true); + GITERR_CHECK_ALLOC(blame->current_hunk); + } + + return 0; +} + +static int ptrs_equal_cmp(const void *a, const void *b) { return ab ? 1 : 0; } +static int buffer_line_cb( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *payload) +{ + git_blame *blame = (git_blame*)payload; + + GIT_UNUSED(delta); + GIT_UNUSED(hunk); + GIT_UNUSED(line); + + if (line->origin == GIT_DIFF_LINE_ADDITION) { + if (hunk_is_bufferblame(blame->current_hunk) && + hunk_ends_at_or_before_line(blame->current_hunk, blame->current_diff_line)) { + /* Append to the current buffer-blame hunk */ + blame->current_hunk->lines_in_hunk++; + shift_hunks_by(&blame->hunks, blame->current_diff_line+1, 1); + } else { + /* Create a new buffer-blame hunk with this line */ + shift_hunks_by(&blame->hunks, blame->current_diff_line, 1); + blame->current_hunk = new_hunk((uint16_t)blame->current_diff_line, 1, 0, blame->path); + GITERR_CHECK_ALLOC(blame->current_hunk); + + git_vector_insert_sorted(&blame->hunks, blame->current_hunk, NULL); + } + blame->current_diff_line++; + } + + if (line->origin == GIT_DIFF_LINE_DELETION) { + /* Trim the line from the current hunk; remove it if it's now empty */ + size_t shift_base = blame->current_diff_line + blame->current_hunk->lines_in_hunk+1; + + if (--(blame->current_hunk->lines_in_hunk) == 0) { + size_t i; + shift_base--; + if (!git_vector_search2(&i, &blame->hunks, ptrs_equal_cmp, blame->current_hunk)) { + git_vector_remove(&blame->hunks, i); + free_hunk(blame->current_hunk); + blame->current_hunk = (git_blame_hunk*)git_blame_get_hunk_byindex(blame, (uint32_t)i); + } + } + shift_hunks_by(&blame->hunks, shift_base, -1); + } + return 0; +} + +int git_blame_buffer( + git_blame **out, + git_blame *reference, + const char *buffer, + size_t buffer_len) +{ + git_blame *blame; + git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; + size_t i; + git_blame_hunk *hunk; + + diffopts.context_lines = 0; + + assert(out && reference && buffer && buffer_len); + + blame = git_blame__alloc(reference->repository, reference->options, reference->path); + GITERR_CHECK_ALLOC(blame); + + /* Duplicate all of the hunk structures in the reference blame */ + git_vector_foreach(&reference->hunks, i, hunk) { + git_blame_hunk *h = dup_hunk(hunk); + GITERR_CHECK_ALLOC(h); + + git_vector_insert(&blame->hunks, h); + } + + /* Diff to the reference blob */ + git_diff_blob_to_buffer(reference->final_blob, blame->path, + buffer, buffer_len, blame->path, + &diffopts, NULL, buffer_hunk_cb, buffer_line_cb, blame); + + *out = blame; + return 0; +} + +int git_blame_init_options(git_blame_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_blame_options, GIT_BLAME_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/blame.h b/deps/libgit2-sys-0.2.17/libgit2/src/blame.h new file mode 100644 index 000000000..7e23de808 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/blame.h @@ -0,0 +1,93 @@ +#ifndef INCLUDE_blame_h__ +#define INCLUDE_blame_h__ + +#include "git2/blame.h" +#include "common.h" +#include "vector.h" +#include "diff.h" +#include "array.h" +#include "git2/oid.h" + +/* + * One blob in a commit that is being suspected + */ +typedef struct git_blame__origin { + int refcnt; + struct git_blame__origin *previous; + git_commit *commit; + git_blob *blob; + char path[GIT_FLEX_ARRAY]; +} git_blame__origin; + +/* + * Each group of lines is described by a git_blame__entry; it can be split + * as we pass blame to the parents. They form a linked list in the + * scoreboard structure, sorted by the target line number. + */ +typedef struct git_blame__entry { + struct git_blame__entry *prev; + struct git_blame__entry *next; + + /* the first line of this group in the final image; + * internally all line numbers are 0 based. + */ + int lno; + + /* how many lines this group has */ + int num_lines; + + /* the commit that introduced this group into the final image */ + git_blame__origin *suspect; + + /* true if the suspect is truly guilty; false while we have not + * checked if the group came from one of its parents. + */ + bool guilty; + + /* true if the entry has been scanned for copies in the current parent + */ + bool scanned; + + /* the line number of the first line of this group in the + * suspect's file; internally all line numbers are 0 based. + */ + int s_lno; + + /* how significant this entry is -- cached to avoid + * scanning the lines over and over. + */ + unsigned score; + + /* Whether this entry has been tracked to a boundary commit. + */ + bool is_boundary; +} git_blame__entry; + +struct git_blame { + char *path; + git_repository *repository; + git_blame_options options; + + git_vector hunks; + git_vector paths; + + git_blob *final_blob; + git_array_t(size_t) line_index; + + size_t current_diff_line; + git_blame_hunk *current_hunk; + + /* Scoreboard fields */ + git_commit *final; + git_blame__entry *ent; + int num_lines; + const char *final_buf; + git_off_t final_buf_size; +}; + +git_blame *git_blame__alloc( + git_repository *repo, + git_blame_options opts, + const char *path); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/blame_git.c b/deps/libgit2-sys-0.2.17/libgit2/src/blame_git.c new file mode 100644 index 000000000..e863efe2e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/blame_git.c @@ -0,0 +1,628 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "blame_git.h" +#include "commit.h" +#include "blob.h" +#include "xdiff/xinclude.h" + +/* + * Origin is refcounted and usually we keep the blob contents to be + * reused. + */ +static git_blame__origin *origin_incref(git_blame__origin *o) +{ + if (o) + o->refcnt++; + return o; +} + +static void origin_decref(git_blame__origin *o) +{ + if (o && --o->refcnt <= 0) { + if (o->previous) + origin_decref(o->previous); + git_blob_free(o->blob); + git_commit_free(o->commit); + git__free(o); + } +} + +/* Given a commit and a path in it, create a new origin structure. */ +static int make_origin(git_blame__origin **out, git_commit *commit, const char *path) +{ + git_blame__origin *o; + size_t path_len = strlen(path), alloc_len; + int error = 0; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); + o = git__calloc(1, alloc_len); + GITERR_CHECK_ALLOC(o); + + o->commit = commit; + o->refcnt = 1; + strcpy(o->path, path); + + if (!(error = git_object_lookup_bypath((git_object**)&o->blob, (git_object*)commit, + path, GIT_OBJ_BLOB))) { + *out = o; + } else { + origin_decref(o); + } + return error; +} + +/* Locate an existing origin or create a new one. */ +int git_blame__get_origin( + git_blame__origin **out, + git_blame *blame, + git_commit *commit, + const char *path) +{ + git_blame__entry *e; + + for (e = blame->ent; e; e = e->next) { + if (e->suspect->commit == commit && !strcmp(e->suspect->path, path)) { + *out = origin_incref(e->suspect); + } + } + return make_origin(out, commit, path); +} + +typedef struct blame_chunk_cb_data { + git_blame *blame; + git_blame__origin *target; + git_blame__origin *parent; + long tlno; + long plno; +}blame_chunk_cb_data; + +static bool same_suspect(git_blame__origin *a, git_blame__origin *b) +{ + if (a == b) + return true; + if (git_oid_cmp(git_commit_id(a->commit), git_commit_id(b->commit))) + return false; + return 0 == strcmp(a->path, b->path); +} + +/* find the line number of the last line the target is suspected for */ +static int find_last_in_target(git_blame *blame, git_blame__origin *target) +{ + git_blame__entry *e; + int last_in_target = -1; + + for (e=blame->ent; e; e=e->next) { + if (e->guilty || !same_suspect(e->suspect, target)) + continue; + if (last_in_target < e->s_lno + e->num_lines) + last_in_target = e->s_lno + e->num_lines; + } + return last_in_target; +} + +/* + * It is known that lines between tlno to same came from parent, and e + * has an overlap with that range. it also is known that parent's + * line plno corresponds to e's line tlno. + * + * <---- e -----> + * <------> (entirely within) + * <------------> (extends past) + * <------------> (starts before) + * <------------------> (entirely encloses) + * + * Split e into potentially three parts; before this chunk, the chunk + * to be blamed for the parent, and after that portion. + */ +static void split_overlap(git_blame__entry *split, git_blame__entry *e, + int tlno, int plno, int same, git_blame__origin *parent) +{ + int chunk_end_lno; + + if (e->s_lno < tlno) { + /* there is a pre-chunk part not blamed on the parent */ + split[0].suspect = origin_incref(e->suspect); + split[0].lno = e->lno; + split[0].s_lno = e->s_lno; + split[0].num_lines = tlno - e->s_lno; + split[1].lno = e->lno + tlno - e->s_lno; + split[1].s_lno = plno; + } else { + split[1].lno = e->lno; + split[1].s_lno = plno + (e->s_lno - tlno); + } + + if (same < e->s_lno + e->num_lines) { + /* there is a post-chunk part not blamed on parent */ + split[2].suspect = origin_incref(e->suspect); + split[2].lno = e->lno + (same - e->s_lno); + split[2].s_lno = e->s_lno + (same - e->s_lno); + split[2].num_lines = e->s_lno + e->num_lines - same; + chunk_end_lno = split[2].lno; + } else { + chunk_end_lno = e->lno + e->num_lines; + } + split[1].num_lines = chunk_end_lno - split[1].lno; + + /* + * if it turns out there is nothing to blame the parent for, forget about + * the splitting. !split[1].suspect signals this. + */ + if (split[1].num_lines < 1) + return; + split[1].suspect = origin_incref(parent); +} + +/* + * Link in a new blame entry to the scoreboard. Entries that cover the same + * line range have been removed from the scoreboard previously. + */ +static void add_blame_entry(git_blame *blame, git_blame__entry *e) +{ + git_blame__entry *ent, *prev = NULL; + + origin_incref(e->suspect); + + for (ent = blame->ent; ent && ent->lno < e->lno; ent = ent->next) + prev = ent; + + /* prev, if not NULL, is the last one that is below e */ + e->prev = prev; + if (prev) { + e->next = prev->next; + prev->next = e; + } else { + e->next = blame->ent; + blame->ent = e; + } + if (e->next) + e->next->prev = e; +} + +/* + * src typically is on-stack; we want to copy the information in it to + * a malloced blame_entry that is already on the linked list of the scoreboard. + * The origin of dst loses a refcnt while the origin of src gains one. + */ +static void dup_entry(git_blame__entry *dst, git_blame__entry *src) +{ + git_blame__entry *p, *n; + + p = dst->prev; + n = dst->next; + origin_incref(src->suspect); + origin_decref(dst->suspect); + memcpy(dst, src, sizeof(*src)); + dst->prev = p; + dst->next = n; + dst->score = 0; +} + +/* + * split_overlap() divided an existing blame e into up to three parts in split. + * Adjust the linked list of blames in the scoreboard to reflect the split. + */ +static void split_blame(git_blame *blame, git_blame__entry *split, git_blame__entry *e) +{ + git_blame__entry *new_entry; + + if (split[0].suspect && split[2].suspect) { + /* The first part (reuse storage for the existing entry e */ + dup_entry(e, &split[0]); + + /* The last part -- me */ + new_entry = git__malloc(sizeof(*new_entry)); + memcpy(new_entry, &(split[2]), sizeof(git_blame__entry)); + add_blame_entry(blame, new_entry); + + /* ... and the middle part -- parent */ + new_entry = git__malloc(sizeof(*new_entry)); + memcpy(new_entry, &(split[1]), sizeof(git_blame__entry)); + add_blame_entry(blame, new_entry); + } else if (!split[0].suspect && !split[2].suspect) { + /* + * The parent covers the entire area; reuse storage for e and replace it + * with the parent + */ + dup_entry(e, &split[1]); + } else if (split[0].suspect) { + /* me and then parent */ + dup_entry(e, &split[0]); + new_entry = git__malloc(sizeof(*new_entry)); + memcpy(new_entry, &(split[1]), sizeof(git_blame__entry)); + add_blame_entry(blame, new_entry); + } else { + /* parent and then me */ + dup_entry(e, &split[1]); + new_entry = git__malloc(sizeof(*new_entry)); + memcpy(new_entry, &(split[2]), sizeof(git_blame__entry)); + add_blame_entry(blame, new_entry); + } +} + +/* + * After splitting the blame, the origins used by the on-stack blame_entry + * should lose one refcnt each. + */ +static void decref_split(git_blame__entry *split) +{ + int i; + for (i=0; i<3; i++) + origin_decref(split[i].suspect); +} + +/* + * Helper for blame_chunk(). blame_entry e is known to overlap with the patch + * hunk; split it and pass blame to the parent. + */ +static void blame_overlap( + git_blame *blame, + git_blame__entry *e, + int tlno, + int plno, + int same, + git_blame__origin *parent) +{ + git_blame__entry split[3] = {{0}}; + + split_overlap(split, e, tlno, plno, same, parent); + if (split[1].suspect) + split_blame(blame, split, e); + decref_split(split); +} + +/* + * Process one hunk from the patch between the current suspect for blame_entry + * e and its parent. Find and split the overlap, and pass blame to the + * overlapping part to the parent. + */ +static void blame_chunk( + git_blame *blame, + int tlno, + int plno, + int same, + git_blame__origin *target, + git_blame__origin *parent) +{ + git_blame__entry *e; + + for (e = blame->ent; e; e = e->next) { + if (e->guilty || !same_suspect(e->suspect, target)) + continue; + if (same <= e->s_lno) + continue; + if (tlno < e->s_lno + e->num_lines) { + blame_overlap(blame, e, tlno, plno, same, parent); + } + } +} + +static int my_emit( + xdfenv_t *xe, + xdchange_t *xscr, + xdemitcb_t *ecb, + xdemitconf_t const *xecfg) +{ + xdchange_t *xch = xscr; + GIT_UNUSED(xe); + GIT_UNUSED(xecfg); + while (xch) { + blame_chunk_cb_data *d = ecb->priv; + blame_chunk(d->blame, d->tlno, d->plno, xch->i2, d->target, d->parent); + d->plno = xch->i1 + xch->chg1; + d->tlno = xch->i2 + xch->chg2; + xch = xch->next; + } + return 0; +} + +static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx) +{ + const int blk = 1024; + long trimmed = 0, recovered = 0; + char *ap = a->ptr + a->size; + char *bp = b->ptr + b->size; + long smaller = (long)((a->size < b->size) ? a->size : b->size); + + if (ctx) + return; + + while (blk + trimmed <= smaller && !memcmp(ap - blk, bp - blk, blk)) { + trimmed += blk; + ap -= blk; + bp -= blk; + } + + while (recovered < trimmed) + if (ap[recovered++] == '\n') + break; + a->size -= trimmed - recovered; + b->size -= trimmed - recovered; +} + +static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data) +{ + xpparam_t xpp = {0}; + xdemitconf_t xecfg = {0}; + xdemitcb_t ecb = {0}; + + xecfg.emit_func = (void(*)(void))my_emit; + ecb.priv = cb_data; + + trim_common_tail(&file_a, &file_b, 0); + return xdl_diff(&file_a, &file_b, &xpp, &xecfg, &ecb); +} + +static void fill_origin_blob(git_blame__origin *o, mmfile_t *file) +{ + memset(file, 0, sizeof(*file)); + if (o->blob) { + file->ptr = (char*)git_blob_rawcontent(o->blob); + file->size = (size_t)git_blob_rawsize(o->blob); + } +} + +static int pass_blame_to_parent( + git_blame *blame, + git_blame__origin *target, + git_blame__origin *parent) +{ + int last_in_target; + mmfile_t file_p, file_o; + blame_chunk_cb_data d = { blame, target, parent, 0, 0 }; + + last_in_target = find_last_in_target(blame, target); + if (last_in_target < 0) + return 1; /* nothing remains for this target */ + + fill_origin_blob(parent, &file_p); + fill_origin_blob(target, &file_o); + + diff_hunks(file_p, file_o, &d); + /* The reset (i.e. anything after tlno) are the same as the parent */ + blame_chunk(blame, d.tlno, d.plno, last_in_target, target, parent); + + return 0; +} + +static int paths_on_dup(void **old, void *new) +{ + GIT_UNUSED(old); + git__free(new); + return -1; +} + +static git_blame__origin* find_origin( + git_blame *blame, + git_commit *parent, + git_blame__origin *origin) +{ + git_blame__origin *porigin = NULL; + git_diff *difflist = NULL; + git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; + git_tree *otree=NULL, *ptree=NULL; + + /* Get the trees from this commit and its parent */ + if (0 != git_commit_tree(&otree, origin->commit) || + 0 != git_commit_tree(&ptree, parent)) + goto cleanup; + + /* Configure the diff */ + diffopts.context_lines = 0; + diffopts.flags = GIT_DIFF_SKIP_BINARY_CHECK; + + /* Check to see if files we're interested have changed */ + diffopts.pathspec.count = blame->paths.length; + diffopts.pathspec.strings = (char**)blame->paths.contents; + if (0 != git_diff_tree_to_tree(&difflist, blame->repository, ptree, otree, &diffopts)) + goto cleanup; + + if (!git_diff_num_deltas(difflist)) { + /* No changes; copy data */ + git_blame__get_origin(&porigin, blame, parent, origin->path); + } else { + git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT; + int i; + + /* Generate a full diff between the two trees */ + git_diff_free(difflist); + diffopts.pathspec.count = 0; + if (0 != git_diff_tree_to_tree(&difflist, blame->repository, ptree, otree, &diffopts)) + goto cleanup; + + /* Let diff find renames */ + findopts.flags = GIT_DIFF_FIND_RENAMES; + if (0 != git_diff_find_similar(difflist, &findopts)) + goto cleanup; + + /* Find one that matches */ + for (i=0; i<(int)git_diff_num_deltas(difflist); i++) { + const git_diff_delta *delta = git_diff_get_delta(difflist, i); + + if (!git_vector_bsearch(NULL, &blame->paths, delta->new_file.path)) + { + git_vector_insert_sorted(&blame->paths, (void*)git__strdup(delta->old_file.path), + paths_on_dup); + make_origin(&porigin, parent, delta->old_file.path); + } + } + } + +cleanup: + git_diff_free(difflist); + git_tree_free(otree); + git_tree_free(ptree); + return porigin; +} + +/* + * The blobs of origin and porigin exactly match, so everything origin is + * suspected for can be blamed on the parent. + */ +static void pass_whole_blame(git_blame *blame, + git_blame__origin *origin, git_blame__origin *porigin) +{ + git_blame__entry *e; + + if (!porigin->blob) + git_object_lookup((git_object**)&porigin->blob, blame->repository, + git_blob_id(origin->blob), GIT_OBJ_BLOB); + for (e=blame->ent; e; e=e->next) { + if (!same_suspect(e->suspect, origin)) + continue; + origin_incref(porigin); + origin_decref(e->suspect); + e->suspect = porigin; + } +} + +static void pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) +{ + git_commit *commit = origin->commit; + int i, num_parents; + git_blame__origin *sg_buf[16]; + git_blame__origin *porigin, **sg_origin = sg_buf; + + num_parents = git_commit_parentcount(commit); + if (!git_oid_cmp(git_commit_id(commit), &blame->options.oldest_commit)) + /* Stop at oldest specified commit */ + num_parents = 0; + else if (opt & GIT_BLAME_FIRST_PARENT && num_parents > 1) + /* Limit search to the first parent */ + num_parents = 1; + + if (!num_parents) { + git_oid_cpy(&blame->options.oldest_commit, git_commit_id(commit)); + goto finish; + } + else if (num_parents < (int)ARRAY_SIZE(sg_buf)) + memset(sg_buf, 0, sizeof(sg_buf)); + else + sg_origin = git__calloc(num_parents, sizeof(*sg_origin)); + + for (i=0; icommit, i); + porigin = find_origin(blame, p, origin); + + if (!porigin) + continue; + if (porigin->blob && origin->blob && + !git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) { + pass_whole_blame(blame, origin, porigin); + origin_decref(porigin); + goto finish; + } + for (j = same = 0; jblob), git_blob_id(porigin->blob))) { + same = 1; + break; + } + if (!same) + sg_origin[i] = porigin; + else + origin_decref(porigin); + } + + /* Standard blame */ + for (i=0; iprevious) { + origin_incref(porigin); + origin->previous = porigin; + } + if (pass_blame_to_parent(blame, origin, porigin)) + goto finish; + } + + /* TODO: optionally find moves in parents' files */ + + /* TODO: optionally find copies in parents' files */ + +finish: + for (i=0; i pair), + * merge them together. + */ +static void coalesce(git_blame *blame) +{ + git_blame__entry *ent, *next; + + for (ent=blame->ent; ent && (next = ent->next); ent = next) { + if (same_suspect(ent->suspect, next->suspect) && + ent->guilty == next->guilty && + ent->s_lno + ent->num_lines == next->s_lno) + { + ent->num_lines += next->num_lines; + ent->next = next->next; + if (ent->next) + ent->next->prev = ent; + origin_decref(next->suspect); + git__free(next); + ent->score = 0; + next = ent; /* again */ + } + } +} + +void git_blame__like_git(git_blame *blame, uint32_t opt) +{ + while (true) { + git_blame__entry *ent; + git_blame__origin *suspect = NULL; + + /* Find a suspect to break down */ + for (ent = blame->ent; !suspect && ent; ent = ent->next) + if (!ent->guilty) + suspect = ent->suspect; + if (!suspect) + return; /* all done */ + + /* We'll use this suspect later in the loop, so hold on to it for now. */ + origin_incref(suspect); + pass_blame(blame, suspect, opt); + + /* Take responsibility for the remaining entries */ + for (ent = blame->ent; ent; ent = ent->next) { + if (same_suspect(ent->suspect, suspect)) { + ent->guilty = true; + ent->is_boundary = !git_oid_cmp( + git_commit_id(suspect->commit), + &blame->options.oldest_commit); + } + } + origin_decref(suspect); + } + + coalesce(blame); +} + +void git_blame__free_entry(git_blame__entry *ent) +{ + if (!ent) return; + origin_decref(ent->suspect); + git__free(ent); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/blame_git.h b/deps/libgit2-sys-0.2.17/libgit2/src/blame_git.h new file mode 100644 index 000000000..3ec2710b8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/blame_git.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_blame_git__ +#define INCLUDE_blame_git__ + +#include "blame.h" + +int git_blame__get_origin( + git_blame__origin **out, + git_blame *sb, + git_commit *commit, + const char *path); +void git_blame__free_entry(git_blame__entry *ent); +void git_blame__like_git(git_blame *sb, uint32_t flags); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/blob.c b/deps/libgit2-sys-0.2.17/libgit2/src/blob.c new file mode 100644 index 000000000..cf0329064 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/blob.c @@ -0,0 +1,368 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/common.h" +#include "git2/object.h" +#include "git2/repository.h" +#include "git2/odb_backend.h" + +#include "common.h" +#include "filebuf.h" +#include "blob.h" +#include "filter.h" +#include "buf_text.h" + +const void *git_blob_rawcontent(const git_blob *blob) +{ + assert(blob); + return git_odb_object_data(blob->odb_object); +} + +git_off_t git_blob_rawsize(const git_blob *blob) +{ + assert(blob); + return (git_off_t)git_odb_object_size(blob->odb_object); +} + +int git_blob__getbuf(git_buf *buffer, git_blob *blob) +{ + return git_buf_set( + buffer, + git_odb_object_data(blob->odb_object), + git_odb_object_size(blob->odb_object)); +} + +void git_blob__free(void *blob) +{ + git_odb_object_free(((git_blob *)blob)->odb_object); + git__free(blob); +} + +int git_blob__parse(void *blob, git_odb_object *odb_obj) +{ + assert(blob); + git_cached_obj_incref((git_cached_obj *)odb_obj); + ((git_blob *)blob)->odb_object = odb_obj; + return 0; +} + +int git_blob_create_frombuffer( + git_oid *id, git_repository *repo, const void *buffer, size_t len) +{ + int error; + git_odb *odb; + git_odb_stream *stream; + + assert(id && repo); + + if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 || + (error = git_odb_open_wstream(&stream, odb, len, GIT_OBJ_BLOB)) < 0) + return error; + + if ((error = git_odb_stream_write(stream, buffer, len)) == 0) + error = git_odb_stream_finalize_write(id, stream); + + git_odb_stream_free(stream); + return error; +} + +static int write_file_stream( + git_oid *id, git_odb *odb, const char *path, git_off_t file_size) +{ + int fd, error; + char buffer[4096]; + git_odb_stream *stream = NULL; + ssize_t read_len = -1, written = 0; + + if ((error = git_odb_open_wstream( + &stream, odb, (size_t)file_size, GIT_OBJ_BLOB)) < 0) + return error; + + if ((fd = git_futils_open_ro(path)) < 0) { + git_odb_stream_free(stream); + return -1; + } + + while (!error && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) { + error = git_odb_stream_write(stream, buffer, read_len); + written += read_len; + } + + p_close(fd); + + if (written != file_size || read_len < 0) { + giterr_set(GITERR_OS, "Failed to read file into stream"); + error = -1; + } + + if (!error) + error = git_odb_stream_finalize_write(id, stream); + + git_odb_stream_free(stream); + return error; +} + +static int write_file_filtered( + git_oid *id, + git_off_t *size, + git_odb *odb, + const char *full_path, + git_filter_list *fl) +{ + int error; + git_buf tgt = GIT_BUF_INIT; + + error = git_filter_list_apply_to_file(&tgt, fl, NULL, full_path); + + /* Write the file to disk if it was properly filtered */ + if (!error) { + *size = tgt.size; + + error = git_odb_write(id, odb, tgt.ptr, tgt.size, GIT_OBJ_BLOB); + } + + git_buf_free(&tgt); + return error; +} + +static int write_symlink( + git_oid *id, git_odb *odb, const char *path, size_t link_size) +{ + char *link_data; + ssize_t read_len; + int error; + + link_data = git__malloc(link_size); + GITERR_CHECK_ALLOC(link_data); + + read_len = p_readlink(path, link_data, link_size); + if (read_len != (ssize_t)link_size) { + giterr_set(GITERR_OS, "Failed to create blob. Can't read symlink '%s'", path); + git__free(link_data); + return -1; + } + + error = git_odb_write(id, odb, (void *)link_data, link_size, GIT_OBJ_BLOB); + git__free(link_data); + return error; +} + +int git_blob__create_from_paths( + git_oid *id, + struct stat *out_st, + git_repository *repo, + const char *content_path, + const char *hint_path, + mode_t hint_mode, + bool try_load_filters) +{ + int error; + struct stat st; + git_odb *odb = NULL; + git_off_t size; + mode_t mode; + git_buf path = GIT_BUF_INIT; + + assert(hint_path || !try_load_filters); + + if (!content_path) { + if (git_repository__ensure_not_bare(repo, "create blob from file") < 0) + return GIT_EBAREREPO; + + if (git_buf_joinpath( + &path, git_repository_workdir(repo), hint_path) < 0) + return -1; + + content_path = path.ptr; + } + + if ((error = git_path_lstat(content_path, &st)) < 0 || + (error = git_repository_odb(&odb, repo)) < 0) + goto done; + + if (out_st) + memcpy(out_st, &st, sizeof(st)); + + size = st.st_size; + mode = hint_mode ? hint_mode : st.st_mode; + + if (S_ISLNK(mode)) { + error = write_symlink(id, odb, content_path, (size_t)size); + } else { + git_filter_list *fl = NULL; + + if (try_load_filters) + /* Load the filters for writing this file to the ODB */ + error = git_filter_list_load( + &fl, repo, NULL, hint_path, + GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT); + + if (error < 0) + /* well, that didn't work */; + else if (fl == NULL) + /* No filters need to be applied to the document: we can stream + * directly from disk */ + error = write_file_stream(id, odb, content_path, size); + else { + /* We need to apply one or more filters */ + error = write_file_filtered(id, &size, odb, content_path, fl); + + git_filter_list_free(fl); + } + + /* + * TODO: eventually support streaming filtered files, for files + * which are bigger than a given threshold. This is not a priority + * because applying a filter in streaming mode changes the final + * size of the blob, and without knowing its final size, the blob + * cannot be written in stream mode to the ODB. + * + * The plan is to do streaming writes to a tempfile on disk and then + * opening streaming that file to the ODB, using + * `write_file_stream`. + * + * CAREFULLY DESIGNED APIS YO + */ + } + +done: + git_odb_free(odb); + git_buf_free(&path); + + return error; +} + +int git_blob_create_fromworkdir( + git_oid *id, git_repository *repo, const char *path) +{ + return git_blob__create_from_paths(id, NULL, repo, NULL, path, 0, true); +} + +int git_blob_create_fromdisk( + git_oid *id, git_repository *repo, const char *path) +{ + int error; + git_buf full_path = GIT_BUF_INIT; + const char *workdir, *hintpath; + + if ((error = git_path_prettify(&full_path, path, NULL)) < 0) { + git_buf_free(&full_path); + return error; + } + + hintpath = git_buf_cstr(&full_path); + workdir = git_repository_workdir(repo); + + if (workdir && !git__prefixcmp(hintpath, workdir)) + hintpath += strlen(workdir); + + error = git_blob__create_from_paths( + id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, true); + + git_buf_free(&full_path); + return error; +} + +#define BUFFER_SIZE 4096 + +int git_blob_create_fromchunks( + git_oid *id, + git_repository *repo, + const char *hintpath, + int (*source_cb)(char *content, size_t max_length, void *payload), + void *payload) +{ + int error; + char *content = NULL; + git_filebuf file = GIT_FILEBUF_INIT; + git_buf path = GIT_BUF_INIT; + + assert(id && repo && source_cb); + + if ((error = git_buf_joinpath( + &path, git_repository_path(repo), GIT_OBJECTS_DIR "streamed")) < 0) + goto cleanup; + + content = git__malloc(BUFFER_SIZE); + GITERR_CHECK_ALLOC(content); + + if ((error = git_filebuf_open( + &file, git_buf_cstr(&path), GIT_FILEBUF_TEMPORARY, 0666)) < 0) + goto cleanup; + + while (1) { + int read_bytes = source_cb(content, BUFFER_SIZE, payload); + + if (!read_bytes) + break; + + if (read_bytes > BUFFER_SIZE) { + giterr_set(GITERR_OBJECT, "Invalid chunk size while creating blob"); + error = GIT_EBUFS; + } else if (read_bytes < 0) { + error = giterr_set_after_callback(read_bytes); + } else { + error = git_filebuf_write(&file, content, read_bytes); + } + + if (error < 0) + goto cleanup; + } + + if ((error = git_filebuf_flush(&file)) < 0) + goto cleanup; + + error = git_blob__create_from_paths( + id, NULL, repo, file.path_lock, hintpath, 0, hintpath != NULL); + +cleanup: + git_buf_free(&path); + git_filebuf_cleanup(&file); + git__free(content); + + return error; +} + +int git_blob_is_binary(const git_blob *blob) +{ + git_buf content = GIT_BUF_INIT; + + assert(blob); + + git_buf_attach_notowned(&content, blob->odb_object->buffer, + min(blob->odb_object->cached.size, + GIT_FILTER_BYTES_TO_CHECK_NUL)); + return git_buf_text_is_binary(&content); +} + +int git_blob_filtered_content( + git_buf *out, + git_blob *blob, + const char *path, + int check_for_binary_data) +{ + int error = 0; + git_filter_list *fl = NULL; + + assert(blob && path && out); + + git_buf_sanitize(out); + + if (check_for_binary_data && git_blob_is_binary(blob)) + return 0; + + if (!(error = git_filter_list_load( + &fl, git_blob_owner(blob), blob, path, + GIT_FILTER_TO_WORKTREE, GIT_FILTER_DEFAULT))) { + + error = git_filter_list_apply_to_blob(out, fl, blob); + + git_filter_list_free(fl); + } + + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/blob.h b/deps/libgit2-sys-0.2.17/libgit2/src/blob.h new file mode 100644 index 000000000..4cd9f1e0c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/blob.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_blob_h__ +#define INCLUDE_blob_h__ + +#include "git2/blob.h" +#include "repository.h" +#include "odb.h" +#include "fileops.h" + +struct git_blob { + git_object object; + git_odb_object *odb_object; +}; + +void git_blob__free(void *blob); +int git_blob__parse(void *blob, git_odb_object *obj); +int git_blob__getbuf(git_buf *buffer, git_blob *blob); + +extern int git_blob__create_from_paths( + git_oid *out_oid, + struct stat *out_st, + git_repository *repo, + const char *full_path, + const char *hint_path, + mode_t hint_mode, + bool apply_filters); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/branch.c b/deps/libgit2-sys-0.2.17/libgit2/src/branch.c new file mode 100644 index 000000000..10be6f70c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/branch.c @@ -0,0 +1,666 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "commit.h" +#include "tag.h" +#include "config.h" +#include "refspec.h" +#include "refs.h" +#include "remote.h" +#include "annotated_commit.h" + +#include "git2/branch.h" + +static int retrieve_branch_reference( + git_reference **branch_reference_out, + git_repository *repo, + const char *branch_name, + int is_remote) +{ + git_reference *branch = NULL; + int error = 0; + char *prefix; + git_buf ref_name = GIT_BUF_INIT; + + prefix = is_remote ? GIT_REFS_REMOTES_DIR : GIT_REFS_HEADS_DIR; + + if ((error = git_buf_joinpath(&ref_name, prefix, branch_name)) < 0) + /* OOM */; + else if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0) + giterr_set( + GITERR_REFERENCE, "Cannot locate %s branch '%s'", + is_remote ? "remote-tracking" : "local", branch_name); + + *branch_reference_out = branch; /* will be NULL on error */ + + git_buf_free(&ref_name); + return error; +} + +static int not_a_local_branch(const char *reference_name) +{ + giterr_set( + GITERR_INVALID, + "Reference '%s' is not a local branch.", reference_name); + return -1; +} + +static int create_branch( + git_reference **ref_out, + git_repository *repository, + const char *branch_name, + const git_commit *commit, + const char *from, + int force) +{ + int is_head = 0; + git_reference *branch = NULL; + git_buf canonical_branch_name = GIT_BUF_INIT, + log_message = GIT_BUF_INIT; + int error = -1; + + assert(branch_name && commit && ref_out); + assert(git_object_owner((const git_object *)commit) == repository); + + if (force && git_branch_lookup(&branch, repository, branch_name, GIT_BRANCH_LOCAL) == 0) { + error = git_branch_is_head(branch); + git_reference_free(branch); + branch = NULL; + + if (error < 0) + goto cleanup; + + is_head = error; + } + + if (is_head && force) { + giterr_set(GITERR_REFERENCE, "Cannot force update branch '%s' as it is " + "the current HEAD of the repository.", branch_name); + error = -1; + goto cleanup; + } + + if (git_buf_joinpath(&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name) < 0) + goto cleanup; + + if (git_buf_printf(&log_message, "branch: Created from %s", from) < 0) + goto cleanup; + + error = git_reference_create(&branch, repository, + git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force, + git_buf_cstr(&log_message)); + + if (!error) + *ref_out = branch; + +cleanup: + git_buf_free(&canonical_branch_name); + git_buf_free(&log_message); + return error; +} + +int git_branch_create( + git_reference **ref_out, + git_repository *repository, + const char *branch_name, + const git_commit *commit, + int force) +{ + return create_branch(ref_out, repository, branch_name, commit, git_oid_tostr_s(git_commit_id(commit)), force); +} + +int git_branch_create_from_annotated( + git_reference **ref_out, + git_repository *repository, + const char *branch_name, + const git_annotated_commit *commit, + int force) +{ + return create_branch(ref_out, repository, branch_name, commit->commit, commit->ref_name, force); +} + +int git_branch_delete(git_reference *branch) +{ + int is_head; + git_buf config_section = GIT_BUF_INIT; + int error = -1; + + assert(branch); + + if (!git_reference_is_branch(branch) && !git_reference_is_remote(branch)) { + giterr_set(GITERR_INVALID, "Reference '%s' is not a valid branch.", + git_reference_name(branch)); + return GIT_ENOTFOUND; + } + + if ((is_head = git_branch_is_head(branch)) < 0) + return is_head; + + if (is_head) { + giterr_set(GITERR_REFERENCE, "Cannot delete branch '%s' as it is " + "the current HEAD of the repository.", git_reference_name(branch)); + return -1; + } + + if (git_buf_join(&config_section, '.', "branch", + git_reference_name(branch) + strlen(GIT_REFS_HEADS_DIR)) < 0) + goto on_error; + + if (git_config_rename_section( + git_reference_owner(branch), git_buf_cstr(&config_section), NULL) < 0) + goto on_error; + + if (git_reference_delete(branch) < 0) + goto on_error; + + if ((error = git_reflog_delete(git_reference_owner(branch), git_reference_name(branch))) < 0) { + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + goto on_error; + } + + error = 0; + +on_error: + git_buf_free(&config_section); + return error; +} + +typedef struct { + git_reference_iterator *iter; + unsigned int flags; +} branch_iter; + +int git_branch_next(git_reference **out, git_branch_t *out_type, git_branch_iterator *_iter) +{ + branch_iter *iter = (branch_iter *) _iter; + git_reference *ref; + int error; + + while ((error = git_reference_next(&ref, iter->iter)) == 0) { + if ((iter->flags & GIT_BRANCH_LOCAL) && + !git__prefixcmp(ref->name, GIT_REFS_HEADS_DIR)) { + *out = ref; + *out_type = GIT_BRANCH_LOCAL; + + return 0; + } else if ((iter->flags & GIT_BRANCH_REMOTE) && + !git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR)) { + *out = ref; + *out_type = GIT_BRANCH_REMOTE; + + return 0; + } else { + git_reference_free(ref); + } + } + + return error; +} + +int git_branch_iterator_new( + git_branch_iterator **out, + git_repository *repo, + git_branch_t list_flags) +{ + branch_iter *iter; + + iter = git__calloc(1, sizeof(branch_iter)); + GITERR_CHECK_ALLOC(iter); + + iter->flags = list_flags; + + if (git_reference_iterator_new(&iter->iter, repo) < 0) { + git__free(iter); + return -1; + } + + *out = (git_branch_iterator *) iter; + + return 0; +} + +void git_branch_iterator_free(git_branch_iterator *_iter) +{ + branch_iter *iter = (branch_iter *) _iter; + + if (iter == NULL) + return; + + git_reference_iterator_free(iter->iter); + git__free(iter); +} + +int git_branch_move( + git_reference **out, + git_reference *branch, + const char *new_branch_name, + int force) +{ + git_buf new_reference_name = GIT_BUF_INIT, + old_config_section = GIT_BUF_INIT, + new_config_section = GIT_BUF_INIT, + log_message = GIT_BUF_INIT; + int error; + + assert(branch && new_branch_name); + + if (!git_reference_is_branch(branch)) + return not_a_local_branch(git_reference_name(branch)); + + if ((error = git_buf_joinpath(&new_reference_name, GIT_REFS_HEADS_DIR, new_branch_name)) < 0) + goto done; + + if ((error = git_buf_printf(&log_message, "branch: renamed %s to %s", + git_reference_name(branch), git_buf_cstr(&new_reference_name))) < 0) + goto done; + + /* first update ref then config so failure won't trash config */ + + error = git_reference_rename( + out, branch, git_buf_cstr(&new_reference_name), force, + git_buf_cstr(&log_message)); + if (error < 0) + goto done; + + git_buf_join(&old_config_section, '.', "branch", + git_reference_name(branch) + strlen(GIT_REFS_HEADS_DIR)); + git_buf_join(&new_config_section, '.', "branch", new_branch_name); + + error = git_config_rename_section( + git_reference_owner(branch), + git_buf_cstr(&old_config_section), + git_buf_cstr(&new_config_section)); + +done: + git_buf_free(&new_reference_name); + git_buf_free(&old_config_section); + git_buf_free(&new_config_section); + git_buf_free(&log_message); + + return error; +} + +int git_branch_lookup( + git_reference **ref_out, + git_repository *repo, + const char *branch_name, + git_branch_t branch_type) +{ + assert(ref_out && repo && branch_name); + + return retrieve_branch_reference(ref_out, repo, branch_name, branch_type == GIT_BRANCH_REMOTE); +} + +int git_branch_name( + const char **out, + const git_reference *ref) +{ + const char *branch_name; + + assert(out && ref); + + branch_name = ref->name; + + if (git_reference_is_branch(ref)) { + branch_name += strlen(GIT_REFS_HEADS_DIR); + } else if (git_reference_is_remote(ref)) { + branch_name += strlen(GIT_REFS_REMOTES_DIR); + } else { + giterr_set(GITERR_INVALID, + "Reference '%s' is neither a local nor a remote branch.", ref->name); + return -1; + } + *out = branch_name; + return 0; +} + +static int retrieve_upstream_configuration( + git_buf *out, + const git_config *config, + const char *canonical_branch_name, + const char *format) +{ + git_buf buf = GIT_BUF_INIT; + int error; + + if (git_buf_printf(&buf, format, + canonical_branch_name + strlen(GIT_REFS_HEADS_DIR)) < 0) + return -1; + + error = git_config_get_string_buf(out, config, git_buf_cstr(&buf)); + git_buf_free(&buf); + return error; +} + +int git_branch_upstream_name( + git_buf *out, + git_repository *repo, + const char *refname) +{ + git_buf remote_name = GIT_BUF_INIT; + git_buf merge_name = GIT_BUF_INIT; + git_buf buf = GIT_BUF_INIT; + int error = -1; + git_remote *remote = NULL; + const git_refspec *refspec; + git_config *config; + + assert(out && refname); + + git_buf_sanitize(out); + + if (!git_reference__is_branch(refname)) + return not_a_local_branch(refname); + + if ((error = git_repository_config_snapshot(&config, repo)) < 0) + return error; + + if ((error = retrieve_upstream_configuration( + &remote_name, config, refname, "branch.%s.remote")) < 0) + goto cleanup; + + if ((error = retrieve_upstream_configuration( + &merge_name, config, refname, "branch.%s.merge")) < 0) + goto cleanup; + + if (git_buf_len(&remote_name) == 0 || git_buf_len(&merge_name) == 0) { + giterr_set(GITERR_REFERENCE, + "branch '%s' does not have an upstream", refname); + error = GIT_ENOTFOUND; + goto cleanup; + } + + if (strcmp(".", git_buf_cstr(&remote_name)) != 0) { + if ((error = git_remote_lookup(&remote, repo, git_buf_cstr(&remote_name))) < 0) + goto cleanup; + + refspec = git_remote__matching_refspec(remote, git_buf_cstr(&merge_name)); + if (!refspec) { + error = GIT_ENOTFOUND; + goto cleanup; + } + + if (git_refspec_transform(&buf, refspec, git_buf_cstr(&merge_name)) < 0) + goto cleanup; + } else + if (git_buf_set(&buf, git_buf_cstr(&merge_name), git_buf_len(&merge_name)) < 0) + goto cleanup; + + error = git_buf_set(out, git_buf_cstr(&buf), git_buf_len(&buf)); + +cleanup: + git_config_free(config); + git_remote_free(remote); + git_buf_free(&remote_name); + git_buf_free(&merge_name); + git_buf_free(&buf); + return error; +} + +int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname) +{ + int error; + git_config *cfg; + + if (!git_reference__is_branch(refname)) + return not_a_local_branch(refname); + + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) + return error; + + git_buf_sanitize(buf); + + if ((error = retrieve_upstream_configuration(buf, cfg, refname, "branch.%s.remote")) < 0) + return error; + + if (git_buf_len(buf) == 0) { + giterr_set(GITERR_REFERENCE, "branch '%s' does not have an upstream remote", refname); + error = GIT_ENOTFOUND; + git_buf_clear(buf); + } + + return error; +} + +int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refname) +{ + git_strarray remote_list = {0}; + size_t i; + git_remote *remote; + const git_refspec *fetchspec; + int error = 0; + char *remote_name = NULL; + + assert(buf && repo && refname); + + git_buf_sanitize(buf); + + /* Verify that this is a remote branch */ + if (!git_reference__is_remote(refname)) { + giterr_set(GITERR_INVALID, "Reference '%s' is not a remote branch.", + refname); + error = GIT_ERROR; + goto cleanup; + } + + /* Get the remotes */ + if ((error = git_remote_list(&remote_list, repo)) < 0) + goto cleanup; + + /* Find matching remotes */ + for (i = 0; i < remote_list.count; i++) { + if ((error = git_remote_lookup(&remote, repo, remote_list.strings[i])) < 0) + continue; + + fetchspec = git_remote__matching_dst_refspec(remote, refname); + if (fetchspec) { + /* If we have not already set out yet, then set + * it to the matching remote name. Otherwise + * multiple remotes match this reference, and it + * is ambiguous. */ + if (!remote_name) { + remote_name = remote_list.strings[i]; + } else { + git_remote_free(remote); + + giterr_set(GITERR_REFERENCE, + "Reference '%s' is ambiguous", refname); + error = GIT_EAMBIGUOUS; + goto cleanup; + } + } + + git_remote_free(remote); + } + + if (remote_name) { + git_buf_clear(buf); + error = git_buf_puts(buf, remote_name); + } else { + giterr_set(GITERR_REFERENCE, + "Could not determine remote for '%s'", refname); + error = GIT_ENOTFOUND; + } + +cleanup: + if (error < 0) + git_buf_free(buf); + + git_strarray_free(&remote_list); + return error; +} + +int git_branch_upstream( + git_reference **tracking_out, + const git_reference *branch) +{ + int error; + git_buf tracking_name = GIT_BUF_INIT; + + if ((error = git_branch_upstream_name(&tracking_name, + git_reference_owner(branch), git_reference_name(branch))) < 0) + return error; + + error = git_reference_lookup( + tracking_out, + git_reference_owner(branch), + git_buf_cstr(&tracking_name)); + + git_buf_free(&tracking_name); + return error; +} + +static int unset_upstream(git_config *config, const char *shortname) +{ + git_buf buf = GIT_BUF_INIT; + + if (git_buf_printf(&buf, "branch.%s.remote", shortname) < 0) + return -1; + + if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0) + goto on_error; + + git_buf_clear(&buf); + if (git_buf_printf(&buf, "branch.%s.merge", shortname) < 0) + goto on_error; + + if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0) + goto on_error; + + git_buf_free(&buf); + return 0; + +on_error: + git_buf_free(&buf); + return -1; +} + +int git_branch_set_upstream(git_reference *branch, const char *upstream_name) +{ + git_buf key = GIT_BUF_INIT, value = GIT_BUF_INIT; + git_reference *upstream; + git_repository *repo; + git_remote *remote = NULL; + git_config *config; + const char *name, *shortname; + int local; + const git_refspec *fetchspec; + + name = git_reference_name(branch); + if (!git_reference__is_branch(name)) + return not_a_local_branch(name); + + if (git_repository_config__weakptr(&config, git_reference_owner(branch)) < 0) + return -1; + + shortname = name + strlen(GIT_REFS_HEADS_DIR); + + if (upstream_name == NULL) + return unset_upstream(config, shortname); + + repo = git_reference_owner(branch); + + /* First we need to figure out whether it's a branch or remote-tracking */ + if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_LOCAL) == 0) + local = 1; + else if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_REMOTE) == 0) + local = 0; + else { + giterr_set(GITERR_REFERENCE, + "Cannot set upstream for branch '%s'", shortname); + return GIT_ENOTFOUND; + } + + /* + * If it's local, the remote is "." and the branch name is + * simply the refname. Otherwise we need to figure out what + * the remote-tracking branch's name on the remote is and use + * that. + */ + if (local) + git_buf_puts(&value, "."); + else + git_branch_remote_name(&value, repo, git_reference_name(upstream)); + + if (git_buf_printf(&key, "branch.%s.remote", shortname) < 0) + goto on_error; + + if (git_config_set_string(config, git_buf_cstr(&key), git_buf_cstr(&value)) < 0) + goto on_error; + + if (local) { + git_buf_clear(&value); + if (git_buf_puts(&value, git_reference_name(upstream)) < 0) + goto on_error; + } else { + /* Get the remoe-tracking branch's refname in its repo */ + if (git_remote_lookup(&remote, repo, git_buf_cstr(&value)) < 0) + goto on_error; + + fetchspec = git_remote__matching_dst_refspec(remote, git_reference_name(upstream)); + git_buf_clear(&value); + if (!fetchspec || git_refspec_rtransform(&value, fetchspec, git_reference_name(upstream)) < 0) + goto on_error; + + git_remote_free(remote); + remote = NULL; + } + + git_buf_clear(&key); + if (git_buf_printf(&key, "branch.%s.merge", shortname) < 0) + goto on_error; + + if (git_config_set_string(config, git_buf_cstr(&key), git_buf_cstr(&value)) < 0) + goto on_error; + + git_reference_free(upstream); + git_buf_free(&key); + git_buf_free(&value); + + return 0; + +on_error: + git_reference_free(upstream); + git_buf_free(&key); + git_buf_free(&value); + git_remote_free(remote); + + return -1; +} + +int git_branch_is_head( + const git_reference *branch) +{ + git_reference *head; + bool is_same = false; + int error; + + assert(branch); + + if (!git_reference_is_branch(branch)) + return false; + + error = git_repository_head(&head, git_reference_owner(branch)); + + if (error == GIT_EUNBORNBRANCH || error == GIT_ENOTFOUND) + return false; + + if (error < 0) + return -1; + + is_same = strcmp( + git_reference_name(branch), + git_reference_name(head)) == 0; + + git_reference_free(head); + + return is_same; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/branch.h b/deps/libgit2-sys-0.2.17/libgit2/src/branch.h new file mode 100644 index 000000000..d02f2af0d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/branch.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_branch_h__ +#define INCLUDE_branch_h__ + +#include "buffer.h" + +int git_branch_upstream__name( + git_buf *tracking_name, + git_repository *repo, + const char *canonical_branch_name); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/buf_text.c b/deps/libgit2-sys-0.2.17/libgit2/src/buf_text.c new file mode 100644 index 000000000..864e39cab --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/buf_text.c @@ -0,0 +1,317 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "buf_text.h" + +int git_buf_text_puts_escaped( + git_buf *buf, + const char *string, + const char *esc_chars, + const char *esc_with) +{ + const char *scan; + size_t total = 0, esc_len = strlen(esc_with), count, alloclen; + + if (!string) + return 0; + + for (scan = string; *scan; ) { + /* count run of non-escaped characters */ + count = strcspn(scan, esc_chars); + total += count; + scan += count; + /* count run of escaped characters */ + count = strspn(scan, esc_chars); + total += count * (esc_len + 1); + scan += count; + } + + GITERR_CHECK_ALLOC_ADD(&alloclen, total, 1); + if (git_buf_grow_by(buf, alloclen) < 0) + return -1; + + for (scan = string; *scan; ) { + count = strcspn(scan, esc_chars); + + memmove(buf->ptr + buf->size, scan, count); + scan += count; + buf->size += count; + + for (count = strspn(scan, esc_chars); count > 0; --count) { + /* copy escape sequence */ + memmove(buf->ptr + buf->size, esc_with, esc_len); + buf->size += esc_len; + /* copy character to be escaped */ + buf->ptr[buf->size] = *scan; + buf->size++; + scan++; + } + } + + buf->ptr[buf->size] = '\0'; + + return 0; +} + +void git_buf_text_unescape(git_buf *buf) +{ + buf->size = git__unescape(buf->ptr); +} + +int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src) +{ + const char *scan = src->ptr; + const char *scan_end = src->ptr + src->size; + const char *next = memchr(scan, '\r', src->size); + size_t new_size; + char *out; + + assert(tgt != src); + + if (!next) + return git_buf_set(tgt, src->ptr, src->size); + + /* reduce reallocs while in the loop */ + GITERR_CHECK_ALLOC_ADD(&new_size, src->size, 1); + if (git_buf_grow(tgt, new_size) < 0) + return -1; + + out = tgt->ptr; + tgt->size = 0; + + /* Find the next \r and copy whole chunk up to there to tgt */ + for (; next; scan = next + 1, next = memchr(scan, '\r', scan_end - scan)) { + if (next > scan) { + size_t copylen = (size_t)(next - scan); + memcpy(out, scan, copylen); + out += copylen; + } + + /* Do not drop \r unless it is followed by \n */ + if (next + 1 == scan_end || next[1] != '\n') + *out++ = '\r'; + } + + /* Copy remaining input into dest */ + if (scan < scan_end) { + size_t remaining = (size_t)(scan_end - scan); + memcpy(out, scan, remaining); + out += remaining; + } + + tgt->size = (size_t)(out - tgt->ptr); + tgt->ptr[tgt->size] = '\0'; + + return 0; +} + +int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src) +{ + const char *start = src->ptr; + const char *end = start + src->size; + const char *scan = start; + const char *next = memchr(scan, '\n', src->size); + size_t alloclen; + + assert(tgt != src); + + if (!next) + return git_buf_set(tgt, src->ptr, src->size); + + /* attempt to reduce reallocs while in the loop */ + GITERR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + if (git_buf_grow(tgt, alloclen) < 0) + return -1; + tgt->size = 0; + + for (; next; scan = next + 1, next = memchr(scan, '\n', end - scan)) { + size_t copylen = next - scan; + + /* if we find mixed line endings, bail */ + if (next > start && next[-1] == '\r') { + git_buf_free(tgt); + return GIT_PASSTHROUGH; + } + + GITERR_CHECK_ALLOC_ADD(&alloclen, copylen, 3); + if (git_buf_grow_by(tgt, alloclen) < 0) + return -1; + + if (next > scan) { + memcpy(tgt->ptr + tgt->size, scan, copylen); + tgt->size += copylen; + } + + tgt->ptr[tgt->size++] = '\r'; + tgt->ptr[tgt->size++] = '\n'; + } + + tgt->ptr[tgt->size] = '\0'; + return git_buf_put(tgt, scan, end - scan); +} + +int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings) +{ + size_t i; + const char *str, *pfx; + + git_buf_clear(buf); + + if (!strings || !strings->count) + return 0; + + /* initialize common prefix to first string */ + if (git_buf_sets(buf, strings->strings[0]) < 0) + return -1; + + /* go through the rest of the strings, truncating to shared prefix */ + for (i = 1; i < strings->count; ++i) { + + for (str = strings->strings[i], pfx = buf->ptr; + *str && *str == *pfx; str++, pfx++) + /* scanning */; + + git_buf_truncate(buf, pfx - buf->ptr); + + if (!buf->size) + break; + } + + return 0; +} + +bool git_buf_text_is_binary(const git_buf *buf) +{ + const char *scan = buf->ptr, *end = buf->ptr + buf->size; + git_bom_t bom; + int printable = 0, nonprintable = 0; + + scan += git_buf_text_detect_bom(&bom, buf, 0); + + if (bom > GIT_BOM_UTF8) + return 1; + + while (scan < end) { + unsigned char c = *scan++; + + /* Printable characters are those above SPACE (0x1F) excluding DEL, + * and including BS, ESC and FF. + */ + if ((c > 0x1F && c != 127) || c == '\b' || c == '\033' || c == '\014') + printable++; + else if (c == '\0') + return true; + else if (!git__isspace(c)) + nonprintable++; + } + + return ((printable >> 7) < nonprintable); +} + +bool git_buf_text_contains_nul(const git_buf *buf) +{ + return (memchr(buf->ptr, '\0', buf->size) != NULL); +} + +int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf, size_t offset) +{ + const char *ptr; + size_t len; + + *bom = GIT_BOM_NONE; + /* need at least 2 bytes after offset to look for any BOM */ + if (buf->size < offset + 2) + return 0; + + ptr = buf->ptr + offset; + len = buf->size - offset; + + switch (*ptr++) { + case 0: + if (len >= 4 && ptr[0] == 0 && ptr[1] == '\xFE' && ptr[2] == '\xFF') { + *bom = GIT_BOM_UTF32_BE; + return 4; + } + break; + case '\xEF': + if (len >= 3 && ptr[0] == '\xBB' && ptr[1] == '\xBF') { + *bom = GIT_BOM_UTF8; + return 3; + } + break; + case '\xFE': + if (*ptr == '\xFF') { + *bom = GIT_BOM_UTF16_BE; + return 2; + } + break; + case '\xFF': + if (*ptr != '\xFE') + break; + if (len >= 4 && ptr[1] == 0 && ptr[2] == 0) { + *bom = GIT_BOM_UTF32_LE; + return 4; + } else { + *bom = GIT_BOM_UTF16_LE; + return 2; + } + break; + default: + break; + } + + return 0; +} + +bool git_buf_text_gather_stats( + git_buf_text_stats *stats, const git_buf *buf, bool skip_bom) +{ + const char *scan = buf->ptr, *end = buf->ptr + buf->size; + int skip; + + memset(stats, 0, sizeof(*stats)); + + /* BOM detection */ + skip = git_buf_text_detect_bom(&stats->bom, buf, 0); + if (skip_bom) + scan += skip; + + /* Ignore EOF character */ + if (buf->size > 0 && end[-1] == '\032') + end--; + + /* Counting loop */ + while (scan < end) { + unsigned char c = *scan++; + + if (c > 0x1F && c != 0x7F) + stats->printable++; + else switch (c) { + case '\0': + stats->nul++; + stats->nonprintable++; + break; + case '\n': + stats->lf++; + break; + case '\r': + stats->cr++; + if (scan < end && *scan == '\n') + stats->crlf++; + break; + case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/ + stats->printable++; + break; + default: + stats->nonprintable++; + break; + } + } + + return (stats->nul > 0 || + ((stats->printable >> 7) < stats->nonprintable)); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/buf_text.h b/deps/libgit2-sys-0.2.17/libgit2/src/buf_text.h new file mode 100644 index 000000000..e753a0244 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/buf_text.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_buf_text_h__ +#define INCLUDE_buf_text_h__ + +#include "buffer.h" + +typedef enum { + GIT_BOM_NONE = 0, + GIT_BOM_UTF8 = 1, + GIT_BOM_UTF16_LE = 2, + GIT_BOM_UTF16_BE = 3, + GIT_BOM_UTF32_LE = 4, + GIT_BOM_UTF32_BE = 5 +} git_bom_t; + +typedef struct { + git_bom_t bom; /* BOM found at head of text */ + unsigned int nul, cr, lf, crlf; /* NUL, CR, LF and CRLF counts */ + unsigned int printable, nonprintable; /* These are just approximations! */ +} git_buf_text_stats; + +/** + * Append string to buffer, prefixing each character from `esc_chars` with + * `esc_with` string. + * + * @param buf Buffer to append data to + * @param string String to escape and append + * @param esc_chars Characters to be escaped + * @param esc_with String to insert in from of each found character + * @return 0 on success, <0 on failure (probably allocation problem) + */ +extern int git_buf_text_puts_escaped( + git_buf *buf, + const char *string, + const char *esc_chars, + const char *esc_with); + +/** + * Append string escaping characters that are regex special + */ +GIT_INLINE(int) git_buf_text_puts_escape_regex(git_buf *buf, const char *string) +{ + return git_buf_text_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\"); +} + +/** + * Unescape all characters in a buffer in place + * + * I.e. remove backslashes + */ +extern void git_buf_text_unescape(git_buf *buf); + +/** + * Replace all \r\n with \n. + * + * @return 0 on success, -1 on memory error, GIT_PASSTHROUGH if the + * source buffer has mixed line endings. + */ +extern int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src); + +/** + * Replace all \n with \r\n. Does not modify existing \r\n. + * + * @return 0 on success, -1 on memory error + */ +extern int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src); + +/** + * Fill buffer with the common prefix of a array of strings + * + * Buffer will be set to empty if there is no common prefix + */ +extern int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strs); + +/** + * Check quickly if buffer looks like it contains binary data + * + * @param buf Buffer to check + * @return true if buffer looks like non-text data + */ +extern bool git_buf_text_is_binary(const git_buf *buf); + +/** + * Check quickly if buffer contains a NUL byte + * + * @param buf Buffer to check + * @return true if buffer contains a NUL byte + */ +extern bool git_buf_text_contains_nul(const git_buf *buf); + +/** + * Check if a buffer begins with a UTF BOM + * + * @param bom Set to the type of BOM detected or GIT_BOM_NONE + * @param buf Buffer in which to check the first bytes for a BOM + * @param offset Offset into buffer to look for BOM + * @return Number of bytes of BOM data (or 0 if no BOM found) + */ +extern int git_buf_text_detect_bom( + git_bom_t *bom, const git_buf *buf, size_t offset); + +/** + * Gather stats for a piece of text + * + * Fill the `stats` structure with counts of unreadable characters, carriage + * returns, etc, so it can be used in heuristics. This automatically skips + * a trailing EOF (\032 character). Also it will look for a BOM at the + * start of the text and can be told to skip that as well. + * + * @param stats Structure to be filled in + * @param buf Text to process + * @param skip_bom Exclude leading BOM from stats if true + * @return Does the buffer heuristically look like binary data + */ +extern bool git_buf_text_gather_stats( + git_buf_text_stats *stats, const git_buf *buf, bool skip_bom); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/buffer.c b/deps/libgit2-sys-0.2.17/libgit2/src/buffer.c new file mode 100644 index 000000000..f633c5e02 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/buffer.c @@ -0,0 +1,766 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "buffer.h" +#include "posix.h" +#include "git2/buffer.h" +#include "buf_text.h" +#include + +/* Used as default value for git_buf->ptr so that people can always + * assume ptr is non-NULL and zero terminated even for new git_bufs. + */ +char git_buf__initbuf[1]; + +char git_buf__oom[1]; + +#define ENSURE_SIZE(b, d) \ + if ((d) > buf->asize && git_buf_grow(b, (d)) < 0)\ + return -1; + + +void git_buf_init(git_buf *buf, size_t initial_size) +{ + buf->asize = 0; + buf->size = 0; + buf->ptr = git_buf__initbuf; + + if (initial_size) + git_buf_grow(buf, initial_size); +} + +int git_buf_try_grow( + git_buf *buf, size_t target_size, bool mark_oom, bool preserve_external) +{ + char *new_ptr; + size_t new_size; + + if (buf->ptr == git_buf__oom) + return -1; + + if (!target_size) + target_size = buf->size; + + if (target_size <= buf->asize) + return 0; + + if (buf->asize == 0) { + new_size = target_size; + new_ptr = NULL; + } else { + new_size = buf->asize; + new_ptr = buf->ptr; + } + + /* grow the buffer size by 1.5, until it's big enough + * to fit our target size */ + while (new_size < target_size) + new_size = (new_size << 1) - (new_size >> 1); + + /* round allocation up to multiple of 8 */ + new_size = (new_size + 7) & ~7; + + if (new_size < buf->size) { + if (mark_oom) + buf->ptr = git_buf__oom; + + giterr_set_oom(); + return -1; + } + + new_ptr = git__realloc(new_ptr, new_size); + + if (!new_ptr) { + if (mark_oom) { + if (buf->ptr && (buf->ptr != git_buf__initbuf)) + git__free(buf->ptr); + buf->ptr = git_buf__oom; + } + return -1; + } + + if (preserve_external && !buf->asize && buf->ptr != NULL && buf->size > 0) + memcpy(new_ptr, buf->ptr, min(buf->size, new_size)); + + buf->asize = new_size; + buf->ptr = new_ptr; + + /* truncate the existing buffer size if necessary */ + if (buf->size >= buf->asize) + buf->size = buf->asize - 1; + buf->ptr[buf->size] = '\0'; + + return 0; +} + +int git_buf_grow(git_buf *buffer, size_t target_size) +{ + return git_buf_try_grow(buffer, target_size, true, true); +} + +int git_buf_grow_by(git_buf *buffer, size_t additional_size) +{ + size_t newsize; + + if (GIT_ADD_SIZET_OVERFLOW(&newsize, buffer->size, additional_size)) { + buffer->ptr = git_buf__oom; + return -1; + } + + return git_buf_try_grow(buffer, newsize, true, true); +} + +void git_buf_free(git_buf *buf) +{ + if (!buf) return; + + if (buf->asize > 0 && buf->ptr != NULL && buf->ptr != git_buf__oom) + git__free(buf->ptr); + + git_buf_init(buf, 0); +} + +void git_buf_sanitize(git_buf *buf) +{ + if (buf->ptr == NULL) { + assert(buf->size == 0 && buf->asize == 0); + buf->ptr = git_buf__initbuf; + } else if (buf->asize > buf->size) + buf->ptr[buf->size] = '\0'; +} + +void git_buf_clear(git_buf *buf) +{ + buf->size = 0; + + if (!buf->ptr) { + buf->ptr = git_buf__initbuf; + buf->asize = 0; + } + + if (buf->asize > 0) + buf->ptr[0] = '\0'; +} + +int git_buf_set(git_buf *buf, const void *data, size_t len) +{ + size_t alloclen; + + if (len == 0 || data == NULL) { + git_buf_clear(buf); + } else { + if (data != buf->ptr) { + GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); + ENSURE_SIZE(buf, alloclen); + memmove(buf->ptr, data, len); + } + + buf->size = len; + if (buf->asize > buf->size) + buf->ptr[buf->size] = '\0'; + + } + return 0; +} + +int git_buf_is_binary(const git_buf *buf) +{ + return git_buf_text_is_binary(buf); +} + +int git_buf_contains_nul(const git_buf *buf) +{ + return git_buf_text_contains_nul(buf); +} + +int git_buf_sets(git_buf *buf, const char *string) +{ + return git_buf_set(buf, string, string ? strlen(string) : 0); +} + +int git_buf_putc(git_buf *buf, char c) +{ + size_t new_size; + GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, 2); + ENSURE_SIZE(buf, new_size); + buf->ptr[buf->size++] = c; + buf->ptr[buf->size] = '\0'; + return 0; +} + +int git_buf_putcn(git_buf *buf, char c, size_t len) +{ + size_t new_size; + GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); + GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); + ENSURE_SIZE(buf, new_size); + memset(buf->ptr + buf->size, c, len); + buf->size += len; + buf->ptr[buf->size] = '\0'; + return 0; +} + +int git_buf_put(git_buf *buf, const char *data, size_t len) +{ + if (len) { + size_t new_size; + + assert(data); + + GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); + GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); + ENSURE_SIZE(buf, new_size); + memmove(buf->ptr + buf->size, data, len); + buf->size += len; + buf->ptr[buf->size] = '\0'; + } + return 0; +} + +int git_buf_puts(git_buf *buf, const char *string) +{ + assert(string); + return git_buf_put(buf, string, strlen(string)); +} + +static const char base64_encode[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +int git_buf_encode_base64(git_buf *buf, const char *data, size_t len) +{ + size_t extra = len % 3; + uint8_t *write, a, b, c; + const uint8_t *read = (const uint8_t *)data; + size_t blocks = (len / 3) + !!extra, alloclen; + + GITERR_CHECK_ALLOC_ADD(&blocks, blocks, 1); + GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 4); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size); + + ENSURE_SIZE(buf, alloclen); + write = (uint8_t *)&buf->ptr[buf->size]; + + /* convert each run of 3 bytes into 4 output bytes */ + for (len -= extra; len > 0; len -= 3) { + a = *read++; + b = *read++; + c = *read++; + + *write++ = base64_encode[a >> 2]; + *write++ = base64_encode[(a & 0x03) << 4 | b >> 4]; + *write++ = base64_encode[(b & 0x0f) << 2 | c >> 6]; + *write++ = base64_encode[c & 0x3f]; + } + + if (extra > 0) { + a = *read++; + b = (extra > 1) ? *read++ : 0; + + *write++ = base64_encode[a >> 2]; + *write++ = base64_encode[(a & 0x03) << 4 | b >> 4]; + *write++ = (extra > 1) ? base64_encode[(b & 0x0f) << 2] : '='; + *write++ = '='; + } + + buf->size = ((char *)write) - buf->ptr; + buf->ptr[buf->size] = '\0'; + + return 0; +} + +/* The inverse of base64_encode, offset by '+' == 43. */ +static const int8_t base64_decode[] = { + 62, + -1, -1, -1, + 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + -1, -1, -1, 0, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + -1, -1, -1, -1, -1, -1, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 +}; + +#define BASE64_DECODE_VALUE(c) (((c) < 43 || (c) > 122) ? -1 : base64_decode[c - 43]) + +int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len) +{ + size_t i; + int8_t a, b, c, d; + size_t orig_size = buf->size, new_size; + + assert(len % 4 == 0); + GITERR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size); + GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); + ENSURE_SIZE(buf, new_size); + + for (i = 0; i < len; i += 4) { + if ((a = BASE64_DECODE_VALUE(base64[i])) < 0 || + (b = BASE64_DECODE_VALUE(base64[i+1])) < 0 || + (c = BASE64_DECODE_VALUE(base64[i+2])) < 0 || + (d = BASE64_DECODE_VALUE(base64[i+3])) < 0) { + buf->size = orig_size; + buf->ptr[buf->size] = '\0'; + + giterr_set(GITERR_INVALID, "Invalid base64 input"); + return -1; + } + + buf->ptr[buf->size++] = ((a << 2) | (b & 0x30) >> 4); + buf->ptr[buf->size++] = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); + buf->ptr[buf->size++] = (c & 0x03) << 6 | (d & 0x3f); + } + + buf->ptr[buf->size] = '\0'; + return 0; +} + +static const char b85str[] = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; + +int git_buf_encode_base85(git_buf *buf, const char *data, size_t len) +{ + size_t blocks = (len / 4) + !!(len % 4), alloclen; + + GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 5); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + + ENSURE_SIZE(buf, alloclen); + + while (len) { + uint32_t acc = 0; + char b85[5]; + int i; + + for (i = 24; i >= 0; i -= 8) { + uint8_t ch = *data++; + acc |= ch << i; + + if (--len == 0) + break; + } + + for (i = 4; i >= 0; i--) { + int val = acc % 85; + acc /= 85; + + b85[i] = b85str[val]; + } + + for (i = 0; i < 5; i++) + buf->ptr[buf->size++] = b85[i]; + } + + buf->ptr[buf->size] = '\0'; + + return 0; +} + +int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) +{ + size_t expected_size, new_size; + int len; + + GITERR_CHECK_ALLOC_MULTIPLY(&expected_size, strlen(format), 2); + GITERR_CHECK_ALLOC_ADD(&expected_size, expected_size, buf->size); + ENSURE_SIZE(buf, expected_size); + + while (1) { + va_list args; + va_copy(args, ap); + + len = p_vsnprintf( + buf->ptr + buf->size, + buf->asize - buf->size, + format, args + ); + + va_end(args); + + if (len < 0) { + git__free(buf->ptr); + buf->ptr = git_buf__oom; + return -1; + } + + if ((size_t)len + 1 <= buf->asize - buf->size) { + buf->size += len; + break; + } + + GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); + GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); + ENSURE_SIZE(buf, new_size); + } + + return 0; +} + +int git_buf_printf(git_buf *buf, const char *format, ...) +{ + int r; + va_list ap; + + va_start(ap, format); + r = git_buf_vprintf(buf, format, ap); + va_end(ap); + + return r; +} + +void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf) +{ + size_t copylen; + + assert(data && datasize && buf); + + data[0] = '\0'; + + if (buf->size == 0 || buf->asize <= 0) + return; + + copylen = buf->size; + if (copylen > datasize - 1) + copylen = datasize - 1; + memmove(data, buf->ptr, copylen); + data[copylen] = '\0'; +} + +void git_buf_consume(git_buf *buf, const char *end) +{ + if (end > buf->ptr && end <= buf->ptr + buf->size) { + size_t consumed = end - buf->ptr; + memmove(buf->ptr, end, buf->size - consumed); + buf->size -= consumed; + buf->ptr[buf->size] = '\0'; + } +} + +void git_buf_truncate(git_buf *buf, size_t len) +{ + if (len >= buf->size) + return; + + buf->size = len; + if (buf->size < buf->asize) + buf->ptr[buf->size] = '\0'; +} + +void git_buf_shorten(git_buf *buf, size_t amount) +{ + if (buf->size > amount) + git_buf_truncate(buf, buf->size - amount); + else + git_buf_clear(buf); +} + +void git_buf_rtruncate_at_char(git_buf *buf, char separator) +{ + ssize_t idx = git_buf_rfind_next(buf, separator); + git_buf_truncate(buf, idx < 0 ? 0 : (size_t)idx); +} + +void git_buf_swap(git_buf *buf_a, git_buf *buf_b) +{ + git_buf t = *buf_a; + *buf_a = *buf_b; + *buf_b = t; +} + +char *git_buf_detach(git_buf *buf) +{ + char *data = buf->ptr; + + if (buf->asize == 0 || buf->ptr == git_buf__oom) + return NULL; + + git_buf_init(buf, 0); + + return data; +} + +void git_buf_attach(git_buf *buf, char *ptr, size_t asize) +{ + git_buf_free(buf); + + if (ptr) { + buf->ptr = ptr; + buf->size = strlen(ptr); + if (asize) + buf->asize = (asize < buf->size) ? buf->size + 1 : asize; + else /* pass 0 to fall back on strlen + 1 */ + buf->asize = buf->size + 1; + } else { + git_buf_grow(buf, asize); + } +} + +void git_buf_attach_notowned(git_buf *buf, const char *ptr, size_t size) +{ + if (git_buf_is_allocated(buf)) + git_buf_free(buf); + + if (!size) { + git_buf_init(buf, 0); + } else { + buf->ptr = (char *)ptr; + buf->asize = 0; + buf->size = size; + } +} + +int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) +{ + va_list ap; + int i; + size_t total_size = 0, original_size = buf->size; + char *out, *original = buf->ptr; + + if (buf->size > 0 && buf->ptr[buf->size - 1] != separator) + ++total_size; /* space for initial separator */ + + /* Make two passes to avoid multiple reallocation */ + + va_start(ap, nbuf); + for (i = 0; i < nbuf; ++i) { + const char* segment; + size_t segment_len; + + segment = va_arg(ap, const char *); + if (!segment) + continue; + + segment_len = strlen(segment); + + GITERR_CHECK_ALLOC_ADD(&total_size, total_size, segment_len); + + if (segment_len == 0 || segment[segment_len - 1] != separator) + GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); + } + va_end(ap); + + /* expand buffer if needed */ + if (total_size == 0) + return 0; + + GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); + if (git_buf_grow_by(buf, total_size) < 0) + return -1; + + out = buf->ptr + buf->size; + + /* append separator to existing buf if needed */ + if (buf->size > 0 && out[-1] != separator) + *out++ = separator; + + va_start(ap, nbuf); + for (i = 0; i < nbuf; ++i) { + const char* segment; + size_t segment_len; + + segment = va_arg(ap, const char *); + if (!segment) + continue; + + /* deal with join that references buffer's original content */ + if (segment >= original && segment < original + original_size) { + size_t offset = (segment - original); + segment = buf->ptr + offset; + segment_len = original_size - offset; + } else { + segment_len = strlen(segment); + } + + /* skip leading separators */ + if (out > buf->ptr && out[-1] == separator) + while (segment_len > 0 && *segment == separator) { + segment++; + segment_len--; + } + + /* copy over next buffer */ + if (segment_len > 0) { + memmove(out, segment, segment_len); + out += segment_len; + } + + /* append trailing separator (except for last item) */ + if (i < nbuf - 1 && out > buf->ptr && out[-1] != separator) + *out++ = separator; + } + va_end(ap); + + /* set size based on num characters actually written */ + buf->size = out - buf->ptr; + buf->ptr[buf->size] = '\0'; + + return 0; +} + +int git_buf_join( + git_buf *buf, + char separator, + const char *str_a, + const char *str_b) +{ + size_t strlen_a = str_a ? strlen(str_a) : 0; + size_t strlen_b = strlen(str_b); + size_t alloc_len; + int need_sep = 0; + ssize_t offset_a = -1; + + /* not safe to have str_b point internally to the buffer */ + assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); + + /* figure out if we need to insert a separator */ + if (separator && strlen_a) { + while (*str_b == separator) { str_b++; strlen_b--; } + if (str_a[strlen_a - 1] != separator) + need_sep = 1; + } + + /* str_a could be part of the buffer */ + if (str_a >= buf->ptr && str_a < buf->ptr + buf->size) + offset_a = str_a - buf->ptr; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, need_sep); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); + if (git_buf_grow(buf, alloc_len) < 0) + return -1; + assert(buf->ptr); + + /* fix up internal pointers */ + if (offset_a >= 0) + str_a = buf->ptr + offset_a; + + /* do the actual copying */ + if (offset_a != 0 && str_a) + memmove(buf->ptr, str_a, strlen_a); + if (need_sep) + buf->ptr[strlen_a] = separator; + memcpy(buf->ptr + strlen_a + need_sep, str_b, strlen_b); + + buf->size = strlen_a + strlen_b + need_sep; + buf->ptr[buf->size] = '\0'; + + return 0; +} + +int git_buf_join3( + git_buf *buf, + char separator, + const char *str_a, + const char *str_b, + const char *str_c) +{ + size_t len_a = strlen(str_a), + len_b = strlen(str_b), + len_c = strlen(str_c), + len_total; + int sep_a = 0, sep_b = 0; + char *tgt; + + /* for this function, disallow pointers into the existing buffer */ + assert(str_a < buf->ptr || str_a >= buf->ptr + buf->size); + assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); + assert(str_c < buf->ptr || str_c >= buf->ptr + buf->size); + + if (separator) { + if (len_a > 0) { + while (*str_b == separator) { str_b++; len_b--; } + sep_a = (str_a[len_a - 1] != separator); + } + if (len_a > 0 || len_b > 0) + while (*str_c == separator) { str_c++; len_c--; } + if (len_b > 0) + sep_b = (str_b[len_b - 1] != separator); + } + + GITERR_CHECK_ALLOC_ADD(&len_total, len_a, sep_a); + GITERR_CHECK_ALLOC_ADD(&len_total, len_total, len_b); + GITERR_CHECK_ALLOC_ADD(&len_total, len_total, sep_b); + GITERR_CHECK_ALLOC_ADD(&len_total, len_total, len_c); + GITERR_CHECK_ALLOC_ADD(&len_total, len_total, 1); + if (git_buf_grow(buf, len_total) < 0) + return -1; + + tgt = buf->ptr; + + if (len_a) { + memcpy(tgt, str_a, len_a); + tgt += len_a; + } + if (sep_a) + *tgt++ = separator; + if (len_b) { + memcpy(tgt, str_b, len_b); + tgt += len_b; + } + if (sep_b) + *tgt++ = separator; + if (len_c) + memcpy(tgt, str_c, len_c); + + buf->size = len_a + sep_a + len_b + sep_b + len_c; + buf->ptr[buf->size] = '\0'; + + return 0; +} + +void git_buf_rtrim(git_buf *buf) +{ + while (buf->size > 0) { + if (!git__isspace(buf->ptr[buf->size - 1])) + break; + + buf->size--; + } + + if (buf->asize > buf->size) + buf->ptr[buf->size] = '\0'; +} + +int git_buf_cmp(const git_buf *a, const git_buf *b) +{ + int result = memcmp(a->ptr, b->ptr, min(a->size, b->size)); + return (result != 0) ? result : + (a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0; +} + +int git_buf_splice( + git_buf *buf, + size_t where, + size_t nb_to_remove, + const char *data, + size_t nb_to_insert) +{ + char *splice_loc; + size_t new_size, alloc_size; + + assert(buf && where <= buf->size && nb_to_remove <= buf->size - where); + + splice_loc = buf->ptr + where; + + /* Ported from git.git + * https://github.com/git/git/blob/16eed7c/strbuf.c#L159-176 + */ + GITERR_CHECK_ALLOC_ADD(&new_size, (buf->size - nb_to_remove), nb_to_insert); + GITERR_CHECK_ALLOC_ADD(&alloc_size, new_size, 1); + ENSURE_SIZE(buf, alloc_size); + + memmove(splice_loc + nb_to_insert, + splice_loc + nb_to_remove, + buf->size - where - nb_to_remove); + + memcpy(splice_loc, data, nb_to_insert); + + buf->size = new_size; + buf->ptr[buf->size] = '\0'; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/buffer.h b/deps/libgit2-sys-0.2.17/libgit2/src/buffer.h new file mode 100644 index 000000000..093ed9b60 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/buffer.h @@ -0,0 +1,209 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_buffer_h__ +#define INCLUDE_buffer_h__ + +#include "common.h" +#include "git2/strarray.h" +#include "git2/buffer.h" + +/* typedef struct { + * char *ptr; + * size_t asize, size; + * } git_buf; + */ + +extern char git_buf__initbuf[]; +extern char git_buf__oom[]; + +/* Use to initialize buffer structure when git_buf is on stack */ +#define GIT_BUF_INIT { git_buf__initbuf, 0, 0 } + +GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf) +{ + return (buf->ptr != NULL && buf->asize > 0); +} + +/** + * Initialize a git_buf structure. + * + * For the cases where GIT_BUF_INIT cannot be used to do static + * initialization. + */ +extern void git_buf_init(git_buf *buf, size_t initial_size); + +/** + * Resize the buffer allocation to make more space. + * + * This will attempt to grow the buffer to accommodate the additional size. + * It is similar to `git_buf_grow`, but performs the new size calculation, + * checking for overflow. + * + * Like `git_buf_grow`, if this is a user-supplied buffer, this will allocate + * a new buffer. + */ +extern int git_buf_grow_by(git_buf *buffer, size_t additional_size); + +/** + * Attempt to grow the buffer to hold at least `target_size` bytes. + * + * If the allocation fails, this will return an error. If `mark_oom` is true, + * this will mark the buffer as invalid for future operations; if false, + * existing buffer content will be preserved, but calling code must handle + * that buffer was not expanded. If `preserve_external` is true, then any + * existing data pointed to be `ptr` even if `asize` is zero will be copied + * into the newly allocated buffer. + */ +extern int git_buf_try_grow( + git_buf *buf, size_t target_size, bool mark_oom, bool preserve_external); + +/** + * Sanitizes git_buf structures provided from user input. Users of the + * library, when providing git_buf's, may wish to provide a NULL ptr for + * ease of handling. The buffer routines, however, expect a non-NULL ptr + * always. This helper method simply handles NULL input, converting to a + * git_buf__initbuf. + */ +extern void git_buf_sanitize(git_buf *buf); + +extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b); +extern char *git_buf_detach(git_buf *buf); +extern void git_buf_attach(git_buf *buf, char *ptr, size_t asize); + +/* Populates a `git_buf` where the contents are not "owned" by the + * buffer, and calls to `git_buf_free` will not free the given buf. + */ +extern void git_buf_attach_notowned( + git_buf *buf, const char *ptr, size_t size); + +/** + * Test if there have been any reallocation failures with this git_buf. + * + * Any function that writes to a git_buf can fail due to memory allocation + * issues. If one fails, the git_buf will be marked with an OOM error and + * further calls to modify the buffer will fail. Check git_buf_oom() at the + * end of your sequence and it will be true if you ran out of memory at any + * point with that buffer. + * + * @return false if no error, true if allocation error + */ +GIT_INLINE(bool) git_buf_oom(const git_buf *buf) +{ + return (buf->ptr == git_buf__oom); +} + +/* + * Functions below that return int value error codes will return 0 on + * success or -1 on failure (which generally means an allocation failed). + * Using a git_buf where the allocation has failed with result in -1 from + * all further calls using that buffer. As a result, you can ignore the + * return code of these functions and call them in a series then just call + * git_buf_oom at the end. + */ +int git_buf_sets(git_buf *buf, const char *string); +int git_buf_putc(git_buf *buf, char c); +int git_buf_putcn(git_buf *buf, char c, size_t len); +int git_buf_put(git_buf *buf, const char *data, size_t len); +int git_buf_puts(git_buf *buf, const char *string); +int git_buf_printf(git_buf *buf, const char *format, ...) GIT_FORMAT_PRINTF(2, 3); +int git_buf_vprintf(git_buf *buf, const char *format, va_list ap); +void git_buf_clear(git_buf *buf); +void git_buf_consume(git_buf *buf, const char *end); +void git_buf_truncate(git_buf *buf, size_t len); +void git_buf_shorten(git_buf *buf, size_t amount); +void git_buf_rtruncate_at_char(git_buf *path, char separator); + +/** General join with separator */ +int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...); +/** Fast join of two strings - first may legally point into `buf` data */ +int git_buf_join(git_buf *buf, char separator, const char *str_a, const char *str_b); +/** Fast join of three strings - cannot reference `buf` data */ +int git_buf_join3(git_buf *buf, char separator, const char *str_a, const char *str_b, const char *str_c); + +/** + * Join two strings as paths, inserting a slash between as needed. + * @return 0 on success, -1 on failure + */ +GIT_INLINE(int) git_buf_joinpath(git_buf *buf, const char *a, const char *b) +{ + return git_buf_join(buf, '/', a, b); +} + +GIT_INLINE(const char *) git_buf_cstr(const git_buf *buf) +{ + return buf->ptr; +} + +GIT_INLINE(size_t) git_buf_len(const git_buf *buf) +{ + return buf->size; +} + +void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf); + +#define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1) + +GIT_INLINE(ssize_t) git_buf_rfind_next(const git_buf *buf, char ch) +{ + ssize_t idx = (ssize_t)buf->size - 1; + while (idx >= 0 && buf->ptr[idx] == ch) idx--; + while (idx >= 0 && buf->ptr[idx] != ch) idx--; + return idx; +} + +GIT_INLINE(ssize_t) git_buf_rfind(const git_buf *buf, char ch) +{ + ssize_t idx = (ssize_t)buf->size - 1; + while (idx >= 0 && buf->ptr[idx] != ch) idx--; + return idx; +} + +GIT_INLINE(ssize_t) git_buf_find(const git_buf *buf, char ch) +{ + void *found = memchr(buf->ptr, ch, buf->size); + return found ? (ssize_t)((const char *)found - buf->ptr) : -1; +} + +/* Remove whitespace from the end of the buffer */ +void git_buf_rtrim(git_buf *buf); + +int git_buf_cmp(const git_buf *a, const git_buf *b); + +/* Write data as base64 encoded in buffer */ +int git_buf_encode_base64(git_buf *buf, const char *data, size_t len); +/* Decode the given bas64 and write the result to the buffer */ +int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len); + +/* Write data as "base85" encoded in buffer */ +int git_buf_encode_base85(git_buf *buf, const char *data, size_t len); + +/* + * Insert, remove or replace a portion of the buffer. + * + * @param buf The buffer to work with + * + * @param where The location in the buffer where the transformation + * should be applied. + * + * @param nb_to_remove The number of chars to be removed. 0 to not + * remove any character in the buffer. + * + * @param data A pointer to the data which should be inserted. + * + * @param nb_to_insert The number of chars to be inserted. 0 to not + * insert any character from the buffer. + * + * @return 0 or an error code. + */ +int git_buf_splice( + git_buf *buf, + size_t where, + size_t nb_to_remove, + const char *data, + size_t nb_to_insert); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/cache.c b/deps/libgit2-sys-0.2.17/libgit2/src/cache.c new file mode 100644 index 000000000..8dc9cbf9c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/cache.c @@ -0,0 +1,280 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "repository.h" +#include "commit.h" +#include "thread-utils.h" +#include "util.h" +#include "cache.h" +#include "odb.h" +#include "object.h" +#include "git2/oid.h" + +GIT__USE_OIDMAP + +bool git_cache__enabled = true; +ssize_t git_cache__max_storage = (256 * 1024 * 1024); +git_atomic_ssize git_cache__current_storage = {0}; + +static size_t git_cache__max_object_size[8] = { + 0, /* GIT_OBJ__EXT1 */ + 4096, /* GIT_OBJ_COMMIT */ + 4096, /* GIT_OBJ_TREE */ + 0, /* GIT_OBJ_BLOB */ + 4096, /* GIT_OBJ_TAG */ + 0, /* GIT_OBJ__EXT2 */ + 0, /* GIT_OBJ_OFS_DELTA */ + 0 /* GIT_OBJ_REF_DELTA */ +}; + +int git_cache_set_max_object_size(git_otype type, size_t size) +{ + if (type < 0 || (size_t)type >= ARRAY_SIZE(git_cache__max_object_size)) { + giterr_set(GITERR_INVALID, "type out of range"); + return -1; + } + + git_cache__max_object_size[type] = size; + return 0; +} + +void git_cache_dump_stats(git_cache *cache) +{ + git_cached_obj *object; + + if (kh_size(cache->map) == 0) + return; + + printf("Cache %p: %d items cached, %d bytes\n", + cache, kh_size(cache->map), (int)cache->used_memory); + + kh_foreach_value(cache->map, object, { + char oid_str[9]; + printf(" %s%c %s (%d)\n", + git_object_type2string(object->type), + object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ', + git_oid_tostr(oid_str, sizeof(oid_str), &object->oid), + (int)object->size + ); + }); +} + +int git_cache_init(git_cache *cache) +{ + memset(cache, 0, sizeof(*cache)); + cache->map = git_oidmap_alloc(); + if (git_rwlock_init(&cache->lock)) { + giterr_set(GITERR_OS, "Failed to initialize cache rwlock"); + return -1; + } + return 0; +} + +/* called with lock */ +static void clear_cache(git_cache *cache) +{ + git_cached_obj *evict = NULL; + + if (kh_size(cache->map) == 0) + return; + + kh_foreach_value(cache->map, evict, { + git_cached_obj_decref(evict); + }); + + kh_clear(oid, cache->map); + git_atomic_ssize_add(&git_cache__current_storage, -cache->used_memory); + cache->used_memory = 0; +} + +void git_cache_clear(git_cache *cache) +{ + if (git_rwlock_wrlock(&cache->lock) < 0) + return; + + clear_cache(cache); + + git_rwlock_wrunlock(&cache->lock); +} + +void git_cache_free(git_cache *cache) +{ + git_cache_clear(cache); + git_oidmap_free(cache->map); + git_rwlock_free(&cache->lock); + git__memzero(cache, sizeof(*cache)); +} + +/* Called with lock */ +static void cache_evict_entries(git_cache *cache) +{ + uint32_t seed = rand(); + size_t evict_count = 8; + ssize_t evicted_memory = 0; + + /* do not infinite loop if there's not enough entries to evict */ + if (evict_count > kh_size(cache->map)) { + clear_cache(cache); + return; + } + + while (evict_count > 0) { + khiter_t pos = seed++ % kh_end(cache->map); + + if (kh_exist(cache->map, pos)) { + git_cached_obj *evict = kh_val(cache->map, pos); + + evict_count--; + evicted_memory += evict->size; + git_cached_obj_decref(evict); + + kh_del(oid, cache->map, pos); + } + } + + cache->used_memory -= evicted_memory; + git_atomic_ssize_add(&git_cache__current_storage, -evicted_memory); +} + +static bool cache_should_store(git_otype object_type, size_t object_size) +{ + size_t max_size = git_cache__max_object_size[object_type]; + return git_cache__enabled && object_size < max_size; +} + +static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags) +{ + khiter_t pos; + git_cached_obj *entry = NULL; + + if (!git_cache__enabled || git_rwlock_rdlock(&cache->lock) < 0) + return NULL; + + pos = kh_get(oid, cache->map, oid); + if (pos != kh_end(cache->map)) { + entry = kh_val(cache->map, pos); + + if (flags && entry->flags != flags) { + entry = NULL; + } else { + git_cached_obj_incref(entry); + } + } + + git_rwlock_rdunlock(&cache->lock); + + return entry; +} + +static void *cache_store(git_cache *cache, git_cached_obj *entry) +{ + khiter_t pos; + + git_cached_obj_incref(entry); + + if (!git_cache__enabled && cache->used_memory > 0) { + git_cache_clear(cache); + return entry; + } + + if (!cache_should_store(entry->type, entry->size)) + return entry; + + if (git_rwlock_wrlock(&cache->lock) < 0) + return entry; + + /* soften the load on the cache */ + if (git_cache__current_storage.val > git_cache__max_storage) + cache_evict_entries(cache); + + pos = kh_get(oid, cache->map, &entry->oid); + + /* not found */ + if (pos == kh_end(cache->map)) { + int rval; + + pos = kh_put(oid, cache->map, &entry->oid, &rval); + if (rval >= 0) { + kh_key(cache->map, pos) = &entry->oid; + kh_val(cache->map, pos) = entry; + git_cached_obj_incref(entry); + cache->used_memory += entry->size; + git_atomic_ssize_add(&git_cache__current_storage, (ssize_t)entry->size); + } + } + /* found */ + else { + git_cached_obj *stored_entry = kh_val(cache->map, pos); + + if (stored_entry->flags == entry->flags) { + git_cached_obj_decref(entry); + git_cached_obj_incref(stored_entry); + entry = stored_entry; + } else if (stored_entry->flags == GIT_CACHE_STORE_RAW && + entry->flags == GIT_CACHE_STORE_PARSED) { + git_cached_obj_decref(stored_entry); + git_cached_obj_incref(entry); + + kh_key(cache->map, pos) = &entry->oid; + kh_val(cache->map, pos) = entry; + } else { + /* NO OP */ + } + } + + git_rwlock_wrunlock(&cache->lock); + return entry; +} + +void *git_cache_store_raw(git_cache *cache, git_odb_object *entry) +{ + entry->cached.flags = GIT_CACHE_STORE_RAW; + return cache_store(cache, (git_cached_obj *)entry); +} + +void *git_cache_store_parsed(git_cache *cache, git_object *entry) +{ + entry->cached.flags = GIT_CACHE_STORE_PARSED; + return cache_store(cache, (git_cached_obj *)entry); +} + +git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid) +{ + return cache_get(cache, oid, GIT_CACHE_STORE_RAW); +} + +git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid) +{ + return cache_get(cache, oid, GIT_CACHE_STORE_PARSED); +} + +void *git_cache_get_any(git_cache *cache, const git_oid *oid) +{ + return cache_get(cache, oid, GIT_CACHE_STORE_ANY); +} + +void git_cached_obj_decref(void *_obj) +{ + git_cached_obj *obj = _obj; + + if (git_atomic_dec(&obj->refcount) == 0) { + switch (obj->flags) { + case GIT_CACHE_STORE_RAW: + git_odb_object__free(_obj); + break; + + case GIT_CACHE_STORE_PARSED: + git_object__free(_obj); + break; + + default: + git__free(_obj); + break; + } + } +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/cache.h b/deps/libgit2-sys-0.2.17/libgit2/src/cache.h new file mode 100644 index 000000000..697123739 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/cache.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_cache_h__ +#define INCLUDE_cache_h__ + +#include "git2/common.h" +#include "git2/oid.h" +#include "git2/odb.h" + +#include "thread-utils.h" +#include "oidmap.h" + +enum { + GIT_CACHE_STORE_ANY = 0, + GIT_CACHE_STORE_RAW = 1, + GIT_CACHE_STORE_PARSED = 2 +}; + +typedef struct { + git_oid oid; + int16_t type; /* git_otype value */ + uint16_t flags; /* GIT_CACHE_STORE value */ + size_t size; + git_atomic refcount; +} git_cached_obj; + +typedef struct { + git_oidmap *map; + git_rwlock lock; + ssize_t used_memory; +} git_cache; + +extern bool git_cache__enabled; +extern ssize_t git_cache__max_storage; +extern git_atomic_ssize git_cache__current_storage; + +int git_cache_set_max_object_size(git_otype type, size_t size); + +int git_cache_init(git_cache *cache); +void git_cache_free(git_cache *cache); +void git_cache_clear(git_cache *cache); + +void *git_cache_store_raw(git_cache *cache, git_odb_object *entry); +void *git_cache_store_parsed(git_cache *cache, git_object *entry); + +git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid); +git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid); +void *git_cache_get_any(git_cache *cache, const git_oid *oid); + +GIT_INLINE(size_t) git_cache_size(git_cache *cache) +{ + return (size_t)kh_size(cache->map); +} + +GIT_INLINE(void) git_cached_obj_incref(void *_obj) +{ + git_cached_obj *obj = _obj; + git_atomic_inc(&obj->refcount); +} + +void git_cached_obj_decref(void *_obj); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/cc-compat.h b/deps/libgit2-sys-0.2.17/libgit2/src/cc-compat.h new file mode 100644 index 000000000..cefdc928b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/cc-compat.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_compat_h__ +#define INCLUDE_compat_h__ + +#include + +/* + * See if our compiler is known to support flexible array members. + */ +#ifndef GIT_FLEX_ARRAY +# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# define GIT_FLEX_ARRAY /* empty */ +# elif defined(__GNUC__) +# if (__GNUC__ >= 3) +# define GIT_FLEX_ARRAY /* empty */ +# else +# define GIT_FLEX_ARRAY 0 /* older GNU extension */ +# endif +# endif + +/* Default to safer but a bit wasteful traditional style */ +# ifndef GIT_FLEX_ARRAY +# define GIT_FLEX_ARRAY 1 +# endif +#endif + +#ifdef __GNUC__ +# define GIT_TYPEOF(x) (__typeof__(x)) +#else +# define GIT_TYPEOF(x) +#endif + +#if defined(__GNUC__) +# define GIT_ALIGN(x,size) x __attribute__ ((aligned(size))) +#elif defined(_MSC_VER) +# define GIT_ALIGN(x,size) __declspec(align(size)) x +#else +# define GIT_ALIGN(x,size) x +#endif + +#define GIT_UNUSED(x) ((void)(x)) + +/* Define the printf format specifer to use for size_t output */ +#if defined(_MSC_VER) || defined(__MINGW32__) +# define PRIuZ "Iu" +# define PRIxZ "Ix" +# define PRIdZ "Id" +#else +# define PRIuZ "zu" +# define PRIxZ "zx" +# define PRIdZ "zd" +#endif + +/* Micosoft Visual C/C++ */ +#if defined(_MSC_VER) +/* disable "deprecated function" warnings */ +# pragma warning ( disable : 4996 ) +/* disable "conditional expression is constant" level 4 warnings */ +# pragma warning ( disable : 4127 ) +#endif + +#if defined (_MSC_VER) + typedef unsigned char bool; +# ifndef true +# define true 1 +# endif +# ifndef false +# define false 0 +# endif +#else +# include +#endif + +#ifndef va_copy +# ifdef __va_copy +# define va_copy(dst, src) __va_copy(dst, src) +# else +# define va_copy(dst, src) ((dst) = (src)) +# endif +#endif + +#endif /* INCLUDE_compat_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/checkout.c b/deps/libgit2-sys-0.2.17/libgit2/src/checkout.c new file mode 100644 index 000000000..0b6e298a0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/checkout.c @@ -0,0 +1,2669 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include + +#include "checkout.h" + +#include "git2/repository.h" +#include "git2/refs.h" +#include "git2/tree.h" +#include "git2/blob.h" +#include "git2/config.h" +#include "git2/diff.h" +#include "git2/submodule.h" +#include "git2/sys/index.h" +#include "git2/sys/filter.h" + +#include "refs.h" +#include "repository.h" +#include "index.h" +#include "filter.h" +#include "blob.h" +#include "diff.h" +#include "pathspec.h" +#include "buf_text.h" +#include "merge_file.h" +#include "path.h" +#include "attr.h" +#include "pool.h" +#include "strmap.h" + +GIT__USE_STRMAP + +/* See docs/checkout-internals.md for more information */ + +enum { + CHECKOUT_ACTION__NONE = 0, + CHECKOUT_ACTION__REMOVE = 1, + CHECKOUT_ACTION__UPDATE_BLOB = 2, + CHECKOUT_ACTION__UPDATE_SUBMODULE = 4, + CHECKOUT_ACTION__CONFLICT = 8, + CHECKOUT_ACTION__REMOVE_CONFLICT = 16, + CHECKOUT_ACTION__UPDATE_CONFLICT = 32, + CHECKOUT_ACTION__MAX = 32, + CHECKOUT_ACTION__DEFER_REMOVE = 64, + CHECKOUT_ACTION__REMOVE_AND_UPDATE = + (CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE), +}; + +typedef struct { + git_repository *repo; + git_iterator *target; + git_diff *diff; + git_checkout_options opts; + bool opts_free_baseline; + char *pfx; + git_index *index; + git_pool pool; + git_vector removes; + git_vector remove_conflicts; + git_vector update_conflicts; + git_vector *update_reuc; + git_vector *update_names; + git_buf path; + size_t workdir_len; + git_buf tmp; + unsigned int strategy; + int can_symlink; + bool reload_submodules; + size_t total_steps; + size_t completed_steps; + git_checkout_perfdata perfdata; + git_strmap *mkdir_map; + git_attr_session attr_session; +} checkout_data; + +typedef struct { + const git_index_entry *ancestor; + const git_index_entry *ours; + const git_index_entry *theirs; + + int name_collision:1, + directoryfile:1, + one_to_two:1, + binary:1, + submodule:1; +} checkout_conflictdata; + +static int checkout_notify( + checkout_data *data, + git_checkout_notify_t why, + const git_diff_delta *delta, + const git_index_entry *wditem) +{ + git_diff_file wdfile; + const git_diff_file *baseline = NULL, *target = NULL, *workdir = NULL; + const char *path = NULL; + + if (!data->opts.notify_cb || + (why & data->opts.notify_flags) == 0) + return 0; + + if (wditem) { + memset(&wdfile, 0, sizeof(wdfile)); + + git_oid_cpy(&wdfile.id, &wditem->id); + wdfile.path = wditem->path; + wdfile.size = wditem->file_size; + wdfile.flags = GIT_DIFF_FLAG_VALID_ID; + wdfile.mode = wditem->mode; + + workdir = &wdfile; + + path = wditem->path; + } + + if (delta) { + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: + case GIT_DELTA_MODIFIED: + case GIT_DELTA_TYPECHANGE: + default: + baseline = &delta->old_file; + target = &delta->new_file; + break; + case GIT_DELTA_ADDED: + case GIT_DELTA_IGNORED: + case GIT_DELTA_UNTRACKED: + case GIT_DELTA_UNREADABLE: + target = &delta->new_file; + break; + case GIT_DELTA_DELETED: + baseline = &delta->old_file; + break; + } + + path = delta->old_file.path; + } + + { + int error = data->opts.notify_cb( + why, path, baseline, target, workdir, data->opts.notify_payload); + + return giterr_set_after_callback_function( + error, "git_checkout notification"); + } +} + +static bool checkout_is_workdir_modified( + checkout_data *data, + const git_diff_file *baseitem, + const git_diff_file *newitem, + const git_index_entry *wditem) +{ + git_oid oid; + const git_index_entry *ie; + + /* handle "modified" submodule */ + if (wditem->mode == GIT_FILEMODE_COMMIT) { + git_submodule *sm; + unsigned int sm_status = 0; + const git_oid *sm_oid = NULL; + bool rval = false; + + if (git_submodule_lookup(&sm, data->repo, wditem->path) < 0) { + giterr_clear(); + return true; + } + + if (git_submodule_status(&sm_status, sm) < 0 || + GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status)) + rval = true; + else if ((sm_oid = git_submodule_wd_id(sm)) == NULL) + rval = false; + else + rval = (git_oid__cmp(&baseitem->id, sm_oid) != 0); + + git_submodule_free(sm); + return rval; + } + + /* Look at the cache to decide if the workdir is modified. If not, + * we can simply compare the oid in the cache to the baseitem instead + * of hashing the file. If so, we allow the checkout to proceed if the + * oid is identical (ie, the staged item is what we're trying to check + * out.) + */ + if ((ie = git_index_get_bypath(data->index, wditem->path, 0)) != NULL) { + if (wditem->mtime.seconds == ie->mtime.seconds && + wditem->mtime.nanoseconds == ie->mtime.nanoseconds && + wditem->file_size == ie->file_size) + return (git_oid__cmp(&baseitem->id, &ie->id) != 0 && + git_oid_cmp(&newitem->id, &ie->id) != 0); + } + + /* depending on where base is coming from, we may or may not know + * the actual size of the data, so we can't rely on this shortcut. + */ + if (baseitem->size && wditem->file_size != baseitem->size) + return true; + + if (git_diff__oid_for_entry(&oid, data->diff, wditem, NULL) < 0) + return false; + + return (git_oid__cmp(&baseitem->id, &oid) != 0); +} + +#define CHECKOUT_ACTION_IF(FLAG,YES,NO) \ + ((data->strategy & GIT_CHECKOUT_##FLAG) ? CHECKOUT_ACTION__##YES : CHECKOUT_ACTION__##NO) + +static int checkout_action_common( + int *action, + checkout_data *data, + const git_diff_delta *delta, + const git_index_entry *wd) +{ + git_checkout_notify_t notify = GIT_CHECKOUT_NOTIFY_NONE; + + if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) + *action = (*action & ~CHECKOUT_ACTION__REMOVE); + + if ((*action & CHECKOUT_ACTION__UPDATE_BLOB) != 0) { + if (S_ISGITLINK(delta->new_file.mode)) + *action = (*action & ~CHECKOUT_ACTION__UPDATE_BLOB) | + CHECKOUT_ACTION__UPDATE_SUBMODULE; + + /* to "update" a symlink, we must remove the old one first */ + if (delta->new_file.mode == GIT_FILEMODE_LINK && wd != NULL) + *action |= CHECKOUT_ACTION__REMOVE; + + notify = GIT_CHECKOUT_NOTIFY_UPDATED; + } + + if ((*action & CHECKOUT_ACTION__CONFLICT) != 0) + notify = GIT_CHECKOUT_NOTIFY_CONFLICT; + + return checkout_notify(data, notify, delta, wd); +} + +static int checkout_action_no_wd( + int *action, + checkout_data *data, + const git_diff_delta *delta) +{ + int error = 0; + + *action = CHECKOUT_ACTION__NONE; + + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: /* case 12 */ + error = checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL); + if (error) + return error; + *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, NONE); + break; + case GIT_DELTA_ADDED: /* case 2 or 28 (and 5 but not really) */ + *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); + break; + case GIT_DELTA_MODIFIED: /* case 13 (and 35 but not really) */ + *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, CONFLICT); + break; + case GIT_DELTA_TYPECHANGE: /* case 21 (B->T) and 28 (T->B)*/ + if (delta->new_file.mode == GIT_FILEMODE_TREE) + *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); + break; + case GIT_DELTA_DELETED: /* case 8 or 25 */ + *action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE); + break; + default: /* impossible */ + break; + } + + return checkout_action_common(action, data, delta, NULL); +} + +static bool wd_item_is_removable(git_iterator *iter, const git_index_entry *wd) +{ + git_buf *full = NULL; + + if (wd->mode != GIT_FILEMODE_TREE) + return true; + if (git_iterator_current_workdir_path(&full, iter) < 0) + return true; + return !full || !git_path_contains(full, DOT_GIT); +} + +static int checkout_queue_remove(checkout_data *data, const char *path) +{ + char *copy = git_pool_strdup(&data->pool, path); + GITERR_CHECK_ALLOC(copy); + return git_vector_insert(&data->removes, copy); +} + +/* note that this advances the iterator over the wd item */ +static int checkout_action_wd_only( + checkout_data *data, + git_iterator *workdir, + const git_index_entry **wditem, + git_vector *pathspec) +{ + int error = 0; + bool remove = false; + git_checkout_notify_t notify = GIT_CHECKOUT_NOTIFY_NONE; + const git_index_entry *wd = *wditem; + + if (!git_pathspec__match( + pathspec, wd->path, + (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, + git_iterator_ignore_case(workdir), NULL, NULL)) + return git_iterator_advance(wditem, workdir); + + /* check if item is tracked in the index but not in the checkout diff */ + if (data->index != NULL) { + size_t pos; + + error = git_index__find_pos( + &pos, data->index, wd->path, 0, GIT_INDEX_STAGE_ANY); + + if (wd->mode != GIT_FILEMODE_TREE) { + if (!error) { /* found by git_index__find_pos call */ + notify = GIT_CHECKOUT_NOTIFY_DIRTY; + remove = ((data->strategy & GIT_CHECKOUT_FORCE) != 0); + } else if (error != GIT_ENOTFOUND) + return error; + else + error = 0; /* git_index__find_pos does not set error msg */ + } else { + /* for tree entries, we have to see if there are any index + * entries that are contained inside that tree + */ + const git_index_entry *e = git_index_get_byindex(data->index, pos); + + if (e != NULL && data->diff->pfxcomp(e->path, wd->path) == 0) { + notify = GIT_CHECKOUT_NOTIFY_DIRTY; + remove = ((data->strategy & GIT_CHECKOUT_FORCE) != 0); + } + } + } + + if (notify != GIT_CHECKOUT_NOTIFY_NONE) { + /* if we found something in the index, notify and advance */ + if ((error = checkout_notify(data, notify, NULL, wd)) != 0) + return error; + + if (remove && wd_item_is_removable(workdir, wd)) + error = checkout_queue_remove(data, wd->path); + + if (!error) + error = git_iterator_advance(wditem, workdir); + } else { + /* untracked or ignored - can't know which until we advance through */ + bool over = false, removable = wd_item_is_removable(workdir, wd); + git_iterator_status_t untracked_state; + + /* copy the entry for issuing notification callback later */ + git_index_entry saved_wd = *wd; + git_buf_sets(&data->tmp, wd->path); + saved_wd.path = data->tmp.ptr; + + error = git_iterator_advance_over_with_status( + wditem, &untracked_state, workdir); + if (error == GIT_ITEROVER) + over = true; + else if (error < 0) + return error; + + if (untracked_state == GIT_ITERATOR_STATUS_IGNORED) { + notify = GIT_CHECKOUT_NOTIFY_IGNORED; + remove = ((data->strategy & GIT_CHECKOUT_REMOVE_IGNORED) != 0); + } else { + notify = GIT_CHECKOUT_NOTIFY_UNTRACKED; + remove = ((data->strategy & GIT_CHECKOUT_REMOVE_UNTRACKED) != 0); + } + + if ((error = checkout_notify(data, notify, NULL, &saved_wd)) != 0) + return error; + + if (remove && removable) + error = checkout_queue_remove(data, saved_wd.path); + + if (!error && over) /* restore ITEROVER if needed */ + error = GIT_ITEROVER; + } + + return error; +} + +static bool submodule_is_config_only( + checkout_data *data, + const char *path) +{ + git_submodule *sm = NULL; + unsigned int sm_loc = 0; + bool rval = false; + + if (git_submodule_lookup(&sm, data->repo, path) < 0) + return true; + + if (git_submodule_location(&sm_loc, sm) < 0 || + sm_loc == GIT_SUBMODULE_STATUS_IN_CONFIG) + rval = true; + + git_submodule_free(sm); + + return rval; +} + +static int checkout_action_with_wd( + int *action, + checkout_data *data, + const git_diff_delta *delta, + git_iterator *workdir, + const git_index_entry *wd) +{ + *action = CHECKOUT_ACTION__NONE; + + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: /* case 14/15 or 33 */ + if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) { + GITERR_CHECK_ERROR( + checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) ); + *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, NONE); + } + break; + case GIT_DELTA_ADDED: /* case 3, 4 or 6 */ + if (git_iterator_current_is_ignored(workdir)) + *action = CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, UPDATE_BLOB); + else + *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT); + break; + case GIT_DELTA_DELETED: /* case 9 or 10 (or 26 but not really) */ + if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT); + else + *action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE); + break; + case GIT_DELTA_MODIFIED: /* case 16, 17, 18 (or 36 but not really) */ + if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) + *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT); + else + *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); + break; + case GIT_DELTA_TYPECHANGE: /* case 22, 23, 29, 30 */ + if (delta->old_file.mode == GIT_FILEMODE_TREE) { + if (wd->mode == GIT_FILEMODE_TREE) + /* either deleting items in old tree will delete the wd dir, + * or we'll get a conflict when we attempt blob update... + */ + *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); + else if (wd->mode == GIT_FILEMODE_COMMIT) { + /* workdir is possibly a "phantom" submodule - treat as a + * tree if the only submodule info came from the config + */ + if (submodule_is_config_only(data, wd->path)) + *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); + else + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); + } else + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT); + } + else if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); + else + *action = CHECKOUT_ACTION_IF(SAFE, REMOVE_AND_UPDATE, NONE); + + /* don't update if the typechange is to a tree */ + if (delta->new_file.mode == GIT_FILEMODE_TREE) + *action = (*action & ~CHECKOUT_ACTION__UPDATE_BLOB); + break; + default: /* impossible */ + break; + } + + return checkout_action_common(action, data, delta, wd); +} + +static int checkout_action_with_wd_blocker( + int *action, + checkout_data *data, + const git_diff_delta *delta, + const git_index_entry *wd) +{ + *action = CHECKOUT_ACTION__NONE; + + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: + /* should show delta as dirty / deleted */ + GITERR_CHECK_ERROR( + checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) ); + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE); + break; + case GIT_DELTA_ADDED: + case GIT_DELTA_MODIFIED: + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); + break; + case GIT_DELTA_DELETED: + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT); + break; + case GIT_DELTA_TYPECHANGE: + /* not 100% certain about this... */ + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); + break; + default: /* impossible */ + break; + } + + return checkout_action_common(action, data, delta, wd); +} + +static int checkout_action_with_wd_dir( + int *action, + checkout_data *data, + const git_diff_delta *delta, + git_iterator *workdir, + const git_index_entry *wd) +{ + *action = CHECKOUT_ACTION__NONE; + + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: /* case 19 or 24 (or 34 but not really) */ + GITERR_CHECK_ERROR( + checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL)); + GITERR_CHECK_ERROR( + checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd)); + break; + case GIT_DELTA_ADDED:/* case 4 (and 7 for dir) */ + case GIT_DELTA_MODIFIED: /* case 20 (or 37 but not really) */ + if (delta->old_file.mode == GIT_FILEMODE_COMMIT) + /* expected submodule (and maybe found one) */; + else if (delta->new_file.mode != GIT_FILEMODE_TREE) + *action = git_iterator_current_is_ignored(workdir) ? + CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) : + CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); + break; + case GIT_DELTA_DELETED: /* case 11 (and 27 for dir) */ + if (delta->old_file.mode != GIT_FILEMODE_TREE) + GITERR_CHECK_ERROR( + checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd)); + break; + case GIT_DELTA_TYPECHANGE: /* case 24 or 31 */ + if (delta->old_file.mode == GIT_FILEMODE_TREE) { + /* For typechange from dir, remove dir and add blob, but it is + * not safe to remove dir if it contains modified files. + * However, safely removing child files will remove the parent + * directory if is it left empty, so we can defer removing the + * dir and it will succeed if no children are left. + */ + *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); + if (*action != CHECKOUT_ACTION__NONE) + *action |= CHECKOUT_ACTION__DEFER_REMOVE; + } + else if (delta->new_file.mode != GIT_FILEMODE_TREE) + /* For typechange to dir, dir is already created so no action */ + *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); + break; + default: /* impossible */ + break; + } + + return checkout_action_common(action, data, delta, wd); +} + +static int checkout_action( + int *action, + checkout_data *data, + git_diff_delta *delta, + git_iterator *workdir, + const git_index_entry **wditem, + git_vector *pathspec) +{ + int cmp = -1, error; + int (*strcomp)(const char *, const char *) = data->diff->strcomp; + int (*pfxcomp)(const char *str, const char *pfx) = data->diff->pfxcomp; + int (*advance)(const git_index_entry **, git_iterator *) = NULL; + + /* move workdir iterator to follow along with deltas */ + + while (1) { + const git_index_entry *wd = *wditem; + + if (!wd) + return checkout_action_no_wd(action, data, delta); + + cmp = strcomp(wd->path, delta->old_file.path); + + /* 1. wd before delta ("a/a" before "a/b") + * 2. wd prefixes delta & should expand ("a/" before "a/b") + * 3. wd prefixes delta & cannot expand ("a/b" before "a/b/c") + * 4. wd equals delta ("a/b" and "a/b") + * 5. wd after delta & delta prefixes wd ("a/b/c" after "a/b/" or "a/b") + * 6. wd after delta ("a/c" after "a/b") + */ + + if (cmp < 0) { + cmp = pfxcomp(delta->old_file.path, wd->path); + + if (cmp == 0) { + if (wd->mode == GIT_FILEMODE_TREE) { + /* case 2 - entry prefixed by workdir tree */ + error = git_iterator_advance_into_or_over(wditem, workdir); + if (error < 0 && error != GIT_ITEROVER) + goto done; + continue; + } + + /* case 3 maybe - wd contains non-dir where dir expected */ + if (delta->old_file.path[strlen(wd->path)] == '/') { + error = checkout_action_with_wd_blocker( + action, data, delta, wd); + advance = git_iterator_advance; + goto done; + } + } + + /* case 1 - handle wd item (if it matches pathspec) */ + error = checkout_action_wd_only(data, workdir, wditem, pathspec); + if (error && error != GIT_ITEROVER) + goto done; + continue; + } + + if (cmp == 0) { + /* case 4 */ + error = checkout_action_with_wd(action, data, delta, workdir, wd); + advance = git_iterator_advance; + goto done; + } + + cmp = pfxcomp(wd->path, delta->old_file.path); + + if (cmp == 0) { /* case 5 */ + if (wd->path[strlen(delta->old_file.path)] != '/') + return checkout_action_no_wd(action, data, delta); + + if (delta->status == GIT_DELTA_TYPECHANGE) { + if (delta->old_file.mode == GIT_FILEMODE_TREE) { + error = checkout_action_with_wd(action, data, delta, workdir, wd); + advance = git_iterator_advance_into; + goto done; + } + + if (delta->new_file.mode == GIT_FILEMODE_TREE || + delta->new_file.mode == GIT_FILEMODE_COMMIT || + delta->old_file.mode == GIT_FILEMODE_COMMIT) + { + error = checkout_action_with_wd(action, data, delta, workdir, wd); + advance = git_iterator_advance; + goto done; + } + } + + return checkout_action_with_wd_dir(action, data, delta, workdir, wd); + } + + /* case 6 - wd is after delta */ + return checkout_action_no_wd(action, data, delta); + } + +done: + if (!error && advance != NULL && + (error = advance(wditem, workdir)) < 0) { + *wditem = NULL; + if (error == GIT_ITEROVER) + error = 0; + } + + return error; +} + +static int checkout_remaining_wd_items( + checkout_data *data, + git_iterator *workdir, + const git_index_entry *wd, + git_vector *spec) +{ + int error = 0; + + while (wd && !error) + error = checkout_action_wd_only(data, workdir, &wd, spec); + + if (error == GIT_ITEROVER) + error = 0; + + return error; +} + +GIT_INLINE(int) checkout_idxentry_cmp( + const git_index_entry *a, + const git_index_entry *b) +{ + if (!a && !b) + return 0; + else if (!a && b) + return -1; + else if(a && !b) + return 1; + else + return strcmp(a->path, b->path); +} + +static int checkout_conflictdata_cmp(const void *a, const void *b) +{ + const checkout_conflictdata *ca = a; + const checkout_conflictdata *cb = b; + int diff; + + if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 && + (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0) + diff = checkout_idxentry_cmp(ca->theirs, cb->theirs); + + return diff; +} + +int checkout_conflictdata_empty( + const git_vector *conflicts, size_t idx, void *payload) +{ + checkout_conflictdata *conflict; + + GIT_UNUSED(payload); + + if ((conflict = git_vector_get(conflicts, idx)) == NULL) + return -1; + + if (conflict->ancestor || conflict->ours || conflict->theirs) + return 0; + + git__free(conflict); + return 1; +} + +GIT_INLINE(bool) conflict_pathspec_match( + checkout_data *data, + git_iterator *workdir, + git_vector *pathspec, + const git_index_entry *ancestor, + const git_index_entry *ours, + const git_index_entry *theirs) +{ + /* if the pathspec matches ours *or* theirs, proceed */ + if (ours && git_pathspec__match(pathspec, ours->path, + (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, + git_iterator_ignore_case(workdir), NULL, NULL)) + return true; + + if (theirs && git_pathspec__match(pathspec, theirs->path, + (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, + git_iterator_ignore_case(workdir), NULL, NULL)) + return true; + + if (ancestor && git_pathspec__match(pathspec, ancestor->path, + (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, + git_iterator_ignore_case(workdir), NULL, NULL)) + return true; + + return false; +} + +GIT_INLINE(int) checkout_conflict_detect_submodule(checkout_conflictdata *conflict) +{ + conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) || + (conflict->ours && S_ISGITLINK(conflict->ours->mode)) || + (conflict->theirs && S_ISGITLINK(conflict->theirs->mode))); + return 0; +} + +GIT_INLINE(int) checkout_conflict_detect_binary(git_repository *repo, checkout_conflictdata *conflict) +{ + git_blob *ancestor_blob = NULL, *our_blob = NULL, *their_blob = NULL; + int error = 0; + + if (conflict->submodule) + return 0; + + if (conflict->ancestor) { + if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor->id)) < 0) + goto done; + + conflict->binary = git_blob_is_binary(ancestor_blob); + } + + if (!conflict->binary && conflict->ours) { + if ((error = git_blob_lookup(&our_blob, repo, &conflict->ours->id)) < 0) + goto done; + + conflict->binary = git_blob_is_binary(our_blob); + } + + if (!conflict->binary && conflict->theirs) { + if ((error = git_blob_lookup(&their_blob, repo, &conflict->theirs->id)) < 0) + goto done; + + conflict->binary = git_blob_is_binary(their_blob); + } + +done: + git_blob_free(ancestor_blob); + git_blob_free(our_blob); + git_blob_free(their_blob); + + return error; +} + +static int checkout_conflict_append_update( + const git_index_entry *ancestor, + const git_index_entry *ours, + const git_index_entry *theirs, + void *payload) +{ + checkout_data *data = payload; + checkout_conflictdata *conflict; + int error; + + conflict = git__calloc(1, sizeof(checkout_conflictdata)); + GITERR_CHECK_ALLOC(conflict); + + conflict->ancestor = ancestor; + conflict->ours = ours; + conflict->theirs = theirs; + + if ((error = checkout_conflict_detect_submodule(conflict)) < 0 || + (error = checkout_conflict_detect_binary(data->repo, conflict)) < 0) + { + git__free(conflict); + return error; + } + + if (git_vector_insert(&data->update_conflicts, conflict)) + return -1; + + return 0; +} + +static int checkout_conflicts_foreach( + checkout_data *data, + git_index *index, + git_iterator *workdir, + git_vector *pathspec, + int (*cb)(const git_index_entry *, const git_index_entry *, const git_index_entry *, void *), + void *payload) +{ + git_index_conflict_iterator *iterator = NULL; + const git_index_entry *ancestor, *ours, *theirs; + int error = 0; + + if ((error = git_index_conflict_iterator_new(&iterator, index)) < 0) + goto done; + + /* Collect the conflicts */ + while ((error = git_index_conflict_next(&ancestor, &ours, &theirs, iterator)) == 0) { + if (!conflict_pathspec_match(data, workdir, pathspec, ancestor, ours, theirs)) + continue; + + if ((error = cb(ancestor, ours, theirs, payload)) < 0) + goto done; + } + + if (error == GIT_ITEROVER) + error = 0; + +done: + git_index_conflict_iterator_free(iterator); + + return error; +} + +static int checkout_conflicts_load(checkout_data *data, git_iterator *workdir, git_vector *pathspec) +{ + git_index *index; + + /* Only write conficts from sources that have them: indexes. */ + if ((index = git_iterator_get_index(data->target)) == NULL) + return 0; + + data->update_conflicts._cmp = checkout_conflictdata_cmp; + + if (checkout_conflicts_foreach(data, index, workdir, pathspec, checkout_conflict_append_update, data) < 0) + return -1; + + /* Collect the REUC and NAME entries */ + data->update_reuc = &index->reuc; + data->update_names = &index->names; + + return 0; +} + +GIT_INLINE(int) checkout_conflicts_cmp_entry( + const char *path, + const git_index_entry *entry) +{ + return strcmp((const char *)path, entry->path); +} + +static int checkout_conflicts_cmp_ancestor(const void *p, const void *c) +{ + const char *path = p; + const checkout_conflictdata *conflict = c; + + if (!conflict->ancestor) + return 1; + + return checkout_conflicts_cmp_entry(path, conflict->ancestor); +} + +static checkout_conflictdata *checkout_conflicts_search_ancestor( + checkout_data *data, + const char *path) +{ + size_t pos; + + if (git_vector_bsearch2(&pos, &data->update_conflicts, checkout_conflicts_cmp_ancestor, path) < 0) + return NULL; + + return git_vector_get(&data->update_conflicts, pos); +} + +static checkout_conflictdata *checkout_conflicts_search_branch( + checkout_data *data, + const char *path) +{ + checkout_conflictdata *conflict; + size_t i; + + git_vector_foreach(&data->update_conflicts, i, conflict) { + int cmp = -1; + + if (conflict->ancestor) + break; + + if (conflict->ours) + cmp = checkout_conflicts_cmp_entry(path, conflict->ours); + else if (conflict->theirs) + cmp = checkout_conflicts_cmp_entry(path, conflict->theirs); + + if (cmp == 0) + return conflict; + } + + return NULL; +} + +static int checkout_conflicts_load_byname_entry( + checkout_conflictdata **ancestor_out, + checkout_conflictdata **ours_out, + checkout_conflictdata **theirs_out, + checkout_data *data, + const git_index_name_entry *name_entry) +{ + checkout_conflictdata *ancestor, *ours = NULL, *theirs = NULL; + int error = 0; + + *ancestor_out = NULL; + *ours_out = NULL; + *theirs_out = NULL; + + if (!name_entry->ancestor) { + giterr_set(GITERR_INDEX, "A NAME entry exists without an ancestor"); + error = -1; + goto done; + } + + if (!name_entry->ours && !name_entry->theirs) { + giterr_set(GITERR_INDEX, "A NAME entry exists without an ours or theirs"); + error = -1; + goto done; + } + + if ((ancestor = checkout_conflicts_search_ancestor(data, + name_entry->ancestor)) == NULL) { + giterr_set(GITERR_INDEX, + "A NAME entry referenced ancestor entry '%s' which does not exist in the main index", + name_entry->ancestor); + error = -1; + goto done; + } + + if (name_entry->ours) { + if (strcmp(name_entry->ancestor, name_entry->ours) == 0) + ours = ancestor; + else if ((ours = checkout_conflicts_search_branch(data, name_entry->ours)) == NULL || + ours->ours == NULL) { + giterr_set(GITERR_INDEX, + "A NAME entry referenced our entry '%s' which does not exist in the main index", + name_entry->ours); + error = -1; + goto done; + } + } + + if (name_entry->theirs) { + if (strcmp(name_entry->ancestor, name_entry->theirs) == 0) + theirs = ancestor; + else if (name_entry->ours && strcmp(name_entry->ours, name_entry->theirs) == 0) + theirs = ours; + else if ((theirs = checkout_conflicts_search_branch(data, name_entry->theirs)) == NULL || + theirs->theirs == NULL) { + giterr_set(GITERR_INDEX, + "A NAME entry referenced their entry '%s' which does not exist in the main index", + name_entry->theirs); + error = -1; + goto done; + } + } + + *ancestor_out = ancestor; + *ours_out = ours; + *theirs_out = theirs; + +done: + return error; +} + +static int checkout_conflicts_coalesce_renames( + checkout_data *data) +{ + git_index *index; + const git_index_name_entry *name_entry; + checkout_conflictdata *ancestor_conflict, *our_conflict, *their_conflict; + size_t i, names; + int error = 0; + + if ((index = git_iterator_get_index(data->target)) == NULL) + return 0; + + /* Juggle entries based on renames */ + names = git_index_name_entrycount(index); + + for (i = 0; i < names; i++) { + name_entry = git_index_name_get_byindex(index, i); + + if ((error = checkout_conflicts_load_byname_entry( + &ancestor_conflict, &our_conflict, &their_conflict, + data, name_entry)) < 0) + goto done; + + if (our_conflict && our_conflict != ancestor_conflict) { + ancestor_conflict->ours = our_conflict->ours; + our_conflict->ours = NULL; + + if (our_conflict->theirs) + our_conflict->name_collision = 1; + + if (our_conflict->name_collision) + ancestor_conflict->name_collision = 1; + } + + if (their_conflict && their_conflict != ancestor_conflict) { + ancestor_conflict->theirs = their_conflict->theirs; + their_conflict->theirs = NULL; + + if (their_conflict->ours) + their_conflict->name_collision = 1; + + if (their_conflict->name_collision) + ancestor_conflict->name_collision = 1; + } + + if (our_conflict && our_conflict != ancestor_conflict && + their_conflict && their_conflict != ancestor_conflict) + ancestor_conflict->one_to_two = 1; + } + + git_vector_remove_matching( + &data->update_conflicts, checkout_conflictdata_empty, NULL); + +done: + return error; +} + +static int checkout_conflicts_mark_directoryfile( + checkout_data *data) +{ + git_index *index; + checkout_conflictdata *conflict; + const git_index_entry *entry; + size_t i, j, len; + const char *path; + int prefixed, error = 0; + + if ((index = git_iterator_get_index(data->target)) == NULL) + return 0; + + len = git_index_entrycount(index); + + /* Find d/f conflicts */ + git_vector_foreach(&data->update_conflicts, i, conflict) { + if ((conflict->ours && conflict->theirs) || + (!conflict->ours && !conflict->theirs)) + continue; + + path = conflict->ours ? + conflict->ours->path : conflict->theirs->path; + + if ((error = git_index_find(&j, index, path)) < 0) { + if (error == GIT_ENOTFOUND) + giterr_set(GITERR_INDEX, + "Index inconsistency, could not find entry for expected conflict '%s'", path); + + goto done; + } + + for (; j < len; j++) { + if ((entry = git_index_get_byindex(index, j)) == NULL) { + giterr_set(GITERR_INDEX, + "Index inconsistency, truncated index while loading expected conflict '%s'", path); + error = -1; + goto done; + } + + prefixed = git_path_equal_or_prefixed(path, entry->path, NULL); + + if (prefixed == GIT_PATH_EQUAL) + continue; + + if (prefixed == GIT_PATH_PREFIX) + conflict->directoryfile = 1; + + break; + } + } + +done: + return error; +} + +static int checkout_get_update_conflicts( + checkout_data *data, + git_iterator *workdir, + git_vector *pathspec) +{ + int error = 0; + + if (data->strategy & GIT_CHECKOUT_SKIP_UNMERGED) + return 0; + + if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 || + (error = checkout_conflicts_coalesce_renames(data)) < 0 || + (error = checkout_conflicts_mark_directoryfile(data)) < 0) + goto done; + +done: + return error; +} + +static int checkout_conflict_append_remove( + const git_index_entry *ancestor, + const git_index_entry *ours, + const git_index_entry *theirs, + void *payload) +{ + checkout_data *data = payload; + const char *name; + + assert(ancestor || ours || theirs); + + if (ancestor) + name = git__strdup(ancestor->path); + else if (ours) + name = git__strdup(ours->path); + else if (theirs) + name = git__strdup(theirs->path); + else + abort(); + + GITERR_CHECK_ALLOC(name); + + return git_vector_insert(&data->remove_conflicts, (char *)name); +} + +static int checkout_get_remove_conflicts( + checkout_data *data, + git_iterator *workdir, + git_vector *pathspec) +{ + if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0) + return 0; + + return checkout_conflicts_foreach(data, data->index, workdir, pathspec, checkout_conflict_append_remove, data); +} + +static int checkout_verify_paths( + git_repository *repo, + int action, + git_diff_delta *delta) +{ + unsigned int flags = GIT_PATH_REJECT_DEFAULTS | GIT_PATH_REJECT_DOT_GIT; + + if (action & CHECKOUT_ACTION__REMOVE) { + if (!git_path_isvalid(repo, delta->old_file.path, flags)) { + giterr_set(GITERR_CHECKOUT, "Cannot remove invalid path '%s'", delta->old_file.path); + return -1; + } + } + + if (action & ~CHECKOUT_ACTION__REMOVE) { + if (!git_path_isvalid(repo, delta->new_file.path, flags)) { + giterr_set(GITERR_CHECKOUT, "Cannot checkout to invalid path '%s'", delta->new_file.path); + return -1; + } + } + + return 0; +} + +static int checkout_get_actions( + uint32_t **actions_ptr, + size_t **counts_ptr, + checkout_data *data, + git_iterator *workdir) +{ + int error = 0, act; + const git_index_entry *wditem; + git_vector pathspec = GIT_VECTOR_INIT, *deltas; + git_pool pathpool = GIT_POOL_INIT_STRINGPOOL; + git_diff_delta *delta; + size_t i, *counts = NULL; + uint32_t *actions = NULL; + + if (data->opts.paths.count > 0 && + git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0) + return -1; + + if ((error = git_iterator_current(&wditem, workdir)) < 0 && + error != GIT_ITEROVER) + goto fail; + + deltas = &data->diff->deltas; + + *counts_ptr = counts = git__calloc(CHECKOUT_ACTION__MAX+1, sizeof(size_t)); + *actions_ptr = actions = git__calloc( + deltas->length ? deltas->length : 1, sizeof(uint32_t)); + if (!counts || !actions) { + error = -1; + goto fail; + } + + git_vector_foreach(deltas, i, delta) { + if ((error = checkout_action(&act, data, delta, workdir, &wditem, &pathspec)) == 0) + error = checkout_verify_paths(data->repo, act, delta); + + if (error != 0) + goto fail; + + actions[i] = act; + + if (act & CHECKOUT_ACTION__REMOVE) + counts[CHECKOUT_ACTION__REMOVE]++; + if (act & CHECKOUT_ACTION__UPDATE_BLOB) + counts[CHECKOUT_ACTION__UPDATE_BLOB]++; + if (act & CHECKOUT_ACTION__UPDATE_SUBMODULE) + counts[CHECKOUT_ACTION__UPDATE_SUBMODULE]++; + if (act & CHECKOUT_ACTION__CONFLICT) + counts[CHECKOUT_ACTION__CONFLICT]++; + } + + error = checkout_remaining_wd_items(data, workdir, wditem, &pathspec); + if (error) + goto fail; + + counts[CHECKOUT_ACTION__REMOVE] += data->removes.length; + + if (counts[CHECKOUT_ACTION__CONFLICT] > 0 && + (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) + { + giterr_set(GITERR_CHECKOUT, "%d %s checkout", + (int)counts[CHECKOUT_ACTION__CONFLICT], + counts[CHECKOUT_ACTION__CONFLICT] == 1 ? + "conflict prevents" : "conflicts prevent"); + error = GIT_EMERGECONFLICT; + goto fail; + } + + + if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 || + (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0) + goto fail; + + counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts); + counts[CHECKOUT_ACTION__UPDATE_CONFLICT] = git_vector_length(&data->update_conflicts); + + git_pathspec__vfree(&pathspec); + git_pool_clear(&pathpool); + + return 0; + +fail: + *counts_ptr = NULL; + git__free(counts); + *actions_ptr = NULL; + git__free(actions); + + git_pathspec__vfree(&pathspec); + git_pool_clear(&pathpool); + + return error; +} + +static bool should_remove_existing(checkout_data *data) +{ + int ignorecase = 0; + + git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE); + + return (ignorecase && + (data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0); +} + +#define MKDIR_NORMAL \ + GIT_MKDIR_PATH | GIT_MKDIR_VERIFY_DIR +#define MKDIR_REMOVE_EXISTING \ + MKDIR_NORMAL | GIT_MKDIR_REMOVE_FILES | GIT_MKDIR_REMOVE_SYMLINKS + +static int checkout_mkdir( + checkout_data *data, + const char *path, + const char *base, + mode_t mode, + unsigned int flags) +{ + struct git_futils_mkdir_options mkdir_opts = {0}; + int error; + + mkdir_opts.dir_map = data->mkdir_map; + mkdir_opts.pool = &data->pool; + + error = git_futils_mkdir_ext( + path, base, mode, flags, &mkdir_opts); + + data->perfdata.mkdir_calls += mkdir_opts.perfdata.mkdir_calls; + data->perfdata.stat_calls += mkdir_opts.perfdata.stat_calls; + data->perfdata.chmod_calls += mkdir_opts.perfdata.chmod_calls; + + return error; +} + +static int mkpath2file( + checkout_data *data, const char *path, unsigned int mode) +{ + struct stat st; + bool remove_existing = should_remove_existing(data); + unsigned int flags = + (remove_existing ? MKDIR_REMOVE_EXISTING : MKDIR_NORMAL) | + GIT_MKDIR_SKIP_LAST; + int error; + + if ((error = checkout_mkdir( + data, path, data->opts.target_directory, mode, flags)) < 0) + return error; + + if (remove_existing) { + data->perfdata.stat_calls++; + + if (p_lstat(path, &st) == 0) { + + /* Some file, symlink or folder already exists at this name. + * We would have removed it in remove_the_old unless we're on + * a case inensitive filesystem (or the user has asked us not + * to). Remove the similarly named file to write the new. + */ + error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES); + } else if (errno != ENOENT) { + giterr_set(GITERR_OS, "Failed to stat file '%s'", path); + return GIT_EEXISTS; + } else { + giterr_clear(); + } + } + + return error; +} + +struct checkout_stream { + git_writestream base; + const char *path; + int fd; + int open; +}; + +static int checkout_stream_write( + git_writestream *s, const char *buffer, size_t len) +{ + struct checkout_stream *stream = (struct checkout_stream *)s; + int ret; + + if ((ret = p_write(stream->fd, buffer, len)) < 0) + giterr_set(GITERR_OS, "Could not write to '%s'", stream->path); + + return ret; +} + +static int checkout_stream_close(git_writestream *s) +{ + struct checkout_stream *stream = (struct checkout_stream *)s; + assert(stream && stream->open); + + stream->open = 0; + return p_close(stream->fd); +} + +static void checkout_stream_free(git_writestream *s) +{ + GIT_UNUSED(s); +} + +static int blob_content_to_file( + checkout_data *data, + struct stat *st, + git_blob *blob, + const char *path, + const char *hint_path, + mode_t entry_filemode) +{ + int flags = data->opts.file_open_flags; + mode_t file_mode = data->opts.file_mode ? + data->opts.file_mode : entry_filemode; + git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; + struct checkout_stream writer; + mode_t mode; + git_filter_list *fl = NULL; + int fd; + int error = 0; + + if (hint_path == NULL) + hint_path = path; + + if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0) + return error; + + if (flags <= 0) + flags = O_CREAT | O_TRUNC | O_WRONLY; + if (!(mode = file_mode)) + mode = GIT_FILEMODE_BLOB; + + if ((fd = p_open(path, flags, mode)) < 0) { + giterr_set(GITERR_OS, "Could not open '%s' for writing", path); + return fd; + } + + filter_opts.attr_session = &data->attr_session; + filter_opts.temp_buf = &data->tmp; + + if (!data->opts.disable_filters && + (error = git_filter_list__load_ext( + &fl, data->repo, blob, hint_path, + GIT_FILTER_TO_WORKTREE, &filter_opts))) + return error; + + /* setup the writer */ + memset(&writer, 0, sizeof(struct checkout_stream)); + writer.base.write = checkout_stream_write; + writer.base.close = checkout_stream_close; + writer.base.free = checkout_stream_free; + writer.path = path; + writer.fd = fd; + writer.open = 1; + + error = git_filter_list_stream_blob(fl, blob, (git_writestream *)&writer); + + assert(writer.open == 0); + + git_filter_list_free(fl); + + if (error < 0) + return error; + + if (GIT_PERMS_IS_EXEC(mode)) { + data->perfdata.chmod_calls++; + + if ((error = p_chmod(path, mode)) < 0) { + giterr_set(GITERR_OS, "Failed to set permissions on '%s'", path); + return error; + } + } + + if (st) { + data->perfdata.stat_calls++; + + if ((error = p_stat(path, st)) < 0) { + giterr_set(GITERR_OS, "Error statting '%s'", path); + return error; + } + + st->st_mode = entry_filemode; + } + + return 0; +} + +static int blob_content_to_link( + checkout_data *data, + struct stat *st, + git_blob *blob, + const char *path) +{ + git_buf linktarget = GIT_BUF_INIT; + int error; + + if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0) + return error; + + if ((error = git_blob__getbuf(&linktarget, blob)) < 0) + return error; + + if (data->can_symlink) { + if ((error = p_symlink(git_buf_cstr(&linktarget), path)) < 0) + giterr_set(GITERR_OS, "Could not create symlink %s", path); + } else { + error = git_futils_fake_symlink(git_buf_cstr(&linktarget), path); + } + + if (!error) { + data->perfdata.stat_calls++; + + if ((error = p_lstat(path, st)) < 0) + giterr_set(GITERR_CHECKOUT, "Could not stat symlink %s", path); + + st->st_mode = GIT_FILEMODE_LINK; + } + + git_buf_free(&linktarget); + + return error; +} + +static int checkout_update_index( + checkout_data *data, + const git_diff_file *file, + struct stat *st) +{ + git_index_entry entry; + + if (!data->index) + return 0; + + memset(&entry, 0, sizeof(entry)); + entry.path = (char *)file->path; /* cast to prevent warning */ + git_index_entry__init_from_stat(&entry, st, true); + git_oid_cpy(&entry.id, &file->id); + + return git_index_add(data->index, &entry); +} + +static int checkout_submodule_update_index( + checkout_data *data, + const git_diff_file *file) +{ + struct stat st; + + /* update the index unless prevented */ + if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0) + return 0; + + git_buf_truncate(&data->path, data->workdir_len); + if (git_buf_puts(&data->path, file->path) < 0) + return -1; + + data->perfdata.stat_calls++; + if (p_stat(git_buf_cstr(&data->path), &st) < 0) { + giterr_set( + GITERR_CHECKOUT, "Could not stat submodule %s\n", file->path); + return GIT_ENOTFOUND; + } + + st.st_mode = GIT_FILEMODE_COMMIT; + + return checkout_update_index(data, file, &st); +} + +static int checkout_submodule( + checkout_data *data, + const git_diff_file *file) +{ + bool remove_existing = should_remove_existing(data); + int error = 0; + + /* Until submodules are supported, UPDATE_ONLY means do nothing here */ + if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) + return 0; + + if ((error = checkout_mkdir( + data, + file->path, data->opts.target_directory, data->opts.dir_mode, + remove_existing ? MKDIR_REMOVE_EXISTING : MKDIR_NORMAL)) < 0) + return error; + + if ((error = git_submodule_lookup(NULL, data->repo, file->path)) < 0) { + /* I've observed repos with submodules in the tree that do not + * have a .gitmodules - core Git just makes an empty directory + */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + return checkout_submodule_update_index(data, file); + } + + return error; + } + + /* TODO: Support checkout_strategy options. Two circumstances: + * 1 - submodule already checked out, but we need to move the HEAD + * to the new OID, or + * 2 - submodule not checked out and we should recursively check it out + * + * Checkout will not execute a pull on the submodule, but a clone + * command should probably be able to. Do we need a submodule callback? + */ + + return checkout_submodule_update_index(data, file); +} + +static void report_progress( + checkout_data *data, + const char *path) +{ + if (data->opts.progress_cb) + data->opts.progress_cb( + path, data->completed_steps, data->total_steps, + data->opts.progress_payload); +} + +static int checkout_safe_for_update_only( + checkout_data *data, const char *path, mode_t expected_mode) +{ + struct stat st; + + data->perfdata.stat_calls++; + + if (p_lstat(path, &st) < 0) { + /* if doesn't exist, then no error and no update */ + if (errno == ENOENT || errno == ENOTDIR) + return 0; + + /* otherwise, stat error and no update */ + giterr_set(GITERR_OS, "Failed to stat file '%s'", path); + return -1; + } + + /* only safe for update if this is the same type of file */ + if ((st.st_mode & ~0777) == (expected_mode & ~0777)) + return 1; + + return 0; +} + +static int checkout_write_content( + checkout_data *data, + const git_oid *oid, + const char *full_path, + const char *hint_path, + unsigned int mode, + struct stat *st) +{ + int error = 0; + git_blob *blob; + + if ((error = git_blob_lookup(&blob, data->repo, oid)) < 0) + return error; + + if (S_ISLNK(mode)) + error = blob_content_to_link(data, st, blob, full_path); + else + error = blob_content_to_file(data, st, blob, full_path, hint_path, mode); + + git_blob_free(blob); + + /* if we try to create the blob and an existing directory blocks it from + * being written, then there must have been a typechange conflict in a + * parent directory - suppress the error and try to continue. + */ + if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 && + (error == GIT_ENOTFOUND || error == GIT_EEXISTS)) + { + giterr_clear(); + error = 0; + } + + return error; +} + +static int checkout_blob( + checkout_data *data, + const git_diff_file *file) +{ + int error = 0; + struct stat st; + + git_buf_truncate(&data->path, data->workdir_len); + if (git_buf_puts(&data->path, file->path) < 0) + return -1; + + if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) { + int rval = checkout_safe_for_update_only( + data, git_buf_cstr(&data->path), file->mode); + if (rval <= 0) + return rval; + } + + error = checkout_write_content( + data, &file->id, git_buf_cstr(&data->path), NULL, file->mode, &st); + + /* update the index unless prevented */ + if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0) + error = checkout_update_index(data, file, &st); + + /* update the submodule data if this was a new .gitmodules file */ + if (!error && strcmp(file->path, ".gitmodules") == 0) + data->reload_submodules = true; + + return error; +} + +static int checkout_remove_the_old( + unsigned int *actions, + checkout_data *data) +{ + int error = 0; + git_diff_delta *delta; + const char *str; + size_t i; + const char *workdir = git_buf_cstr(&data->path); + uint32_t flg = GIT_RMDIR_EMPTY_PARENTS | + GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_REMOVE_BLOCKERS; + + if (data->opts.checkout_strategy & GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES) + flg |= GIT_RMDIR_SKIP_NONEMPTY; + + git_buf_truncate(&data->path, data->workdir_len); + + git_vector_foreach(&data->diff->deltas, i, delta) { + if (actions[i] & CHECKOUT_ACTION__REMOVE) { + error = git_futils_rmdir_r(delta->old_file.path, workdir, flg); + if (error < 0) + return error; + + data->completed_steps++; + report_progress(data, delta->old_file.path); + + if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 && + (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 && + data->index != NULL) + { + (void)git_index_remove(data->index, delta->old_file.path, 0); + } + } + } + + git_vector_foreach(&data->removes, i, str) { + error = git_futils_rmdir_r(str, workdir, flg); + if (error < 0) + return error; + + data->completed_steps++; + report_progress(data, str); + + if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 && + data->index != NULL) + { + if (str[strlen(str) - 1] == '/') + (void)git_index_remove_directory(data->index, str, 0); + else + (void)git_index_remove(data->index, str, 0); + } + } + + return 0; +} + +static int checkout_deferred_remove(git_repository *repo, const char *path) +{ +#if 0 + int error = git_futils_rmdir_r( + path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS); + + if (error == GIT_ENOTFOUND) { + error = 0; + giterr_clear(); + } + + return error; +#else + GIT_UNUSED(repo); + GIT_UNUSED(path); + assert(false); + return 0; +#endif +} + +static int checkout_create_the_new( + unsigned int *actions, + checkout_data *data) +{ + int error = 0; + git_diff_delta *delta; + size_t i; + + git_vector_foreach(&data->diff->deltas, i, delta) { + if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) { + /* this had a blocker directory that should only be removed iff + * all of the contents of the directory were safely removed + */ + if ((error = checkout_deferred_remove( + data->repo, delta->old_file.path)) < 0) + return error; + } + + if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) { + error = checkout_blob(data, &delta->new_file); + if (error < 0) + return error; + + data->completed_steps++; + report_progress(data, delta->new_file.path); + } + } + + return 0; +} + +static int checkout_create_submodules( + unsigned int *actions, + checkout_data *data) +{ + int error = 0; + git_diff_delta *delta; + size_t i; + + /* initial reload of submodules if .gitmodules was changed */ + if (data->reload_submodules && + (error = git_submodule_reload_all(data->repo, 1)) < 0) + return error; + + git_vector_foreach(&data->diff->deltas, i, delta) { + if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) { + /* this has a blocker directory that should only be removed iff + * all of the contents of the directory were safely removed + */ + if ((error = checkout_deferred_remove( + data->repo, delta->old_file.path)) < 0) + return error; + } + + if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) { + int error = checkout_submodule(data, &delta->new_file); + if (error < 0) + return error; + + data->completed_steps++; + report_progress(data, delta->new_file.path); + } + } + + /* final reload once submodules have been updated */ + return git_submodule_reload_all(data->repo, 1); +} + +static int checkout_lookup_head_tree(git_tree **out, git_repository *repo) +{ + int error = 0; + git_reference *ref = NULL; + git_object *head; + + if (!(error = git_repository_head(&ref, repo)) && + !(error = git_reference_peel(&head, ref, GIT_OBJ_TREE))) + *out = (git_tree *)head; + + git_reference_free(ref); + + return error; +} + + +static int conflict_entry_name( + git_buf *out, + const char *side_name, + const char *filename) +{ + if (git_buf_puts(out, side_name) < 0 || + git_buf_putc(out, ':') < 0 || + git_buf_puts(out, filename) < 0) + return -1; + + return 0; +} + +static int checkout_path_suffixed(git_buf *path, const char *suffix) +{ + size_t path_len; + int i = 0, error = 0; + + if ((error = git_buf_putc(path, '~')) < 0 || (error = git_buf_puts(path, suffix)) < 0) + return -1; + + path_len = git_buf_len(path); + + while (git_path_exists(git_buf_cstr(path)) && i < INT_MAX) { + git_buf_truncate(path, path_len); + + if ((error = git_buf_putc(path, '_')) < 0 || + (error = git_buf_printf(path, "%d", i)) < 0) + return error; + + i++; + } + + if (i == INT_MAX) { + git_buf_truncate(path, path_len); + + giterr_set(GITERR_CHECKOUT, "Could not write '%s': working directory file exists", path); + return GIT_EEXISTS; + } + + return 0; +} + +static int checkout_write_entry( + checkout_data *data, + checkout_conflictdata *conflict, + const git_index_entry *side) +{ + const char *hint_path = NULL, *suffix; + struct stat st; + int error; + + assert (side == conflict->ours || side == conflict->theirs); + + git_buf_truncate(&data->path, data->workdir_len); + if (git_buf_puts(&data->path, side->path) < 0) + return -1; + + if ((conflict->name_collision || conflict->directoryfile) && + (data->strategy & GIT_CHECKOUT_USE_OURS) == 0 && + (data->strategy & GIT_CHECKOUT_USE_THEIRS) == 0) { + + if (side == conflict->ours) + suffix = data->opts.our_label ? data->opts.our_label : + "ours"; + else + suffix = data->opts.their_label ? data->opts.their_label : + "theirs"; + + if (checkout_path_suffixed(&data->path, suffix) < 0) + return -1; + + hint_path = side->path; + } + + if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 && + (error = checkout_safe_for_update_only(data, git_buf_cstr(&data->path), side->mode)) <= 0) + return error; + + return checkout_write_content(data, + &side->id, git_buf_cstr(&data->path), hint_path, side->mode, &st); +} + +static int checkout_write_entries( + checkout_data *data, + checkout_conflictdata *conflict) +{ + int error = 0; + + if ((error = checkout_write_entry(data, conflict, conflict->ours)) >= 0) + error = checkout_write_entry(data, conflict, conflict->theirs); + + return error; +} + +static int checkout_merge_path( + git_buf *out, + checkout_data *data, + checkout_conflictdata *conflict, + git_merge_file_result *result) +{ + const char *our_label_raw, *their_label_raw, *suffix; + int error = 0; + + if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0) + return error; + + /* Most conflicts simply use the filename in the index */ + if (!conflict->name_collision) + return 0; + + /* Rename 2->1 conflicts need the branch name appended */ + our_label_raw = data->opts.our_label ? data->opts.our_label : "ours"; + their_label_raw = data->opts.their_label ? data->opts.their_label : "theirs"; + suffix = strcmp(result->path, conflict->ours->path) == 0 ? our_label_raw : their_label_raw; + + if ((error = checkout_path_suffixed(out, suffix)) < 0) + return error; + + return 0; +} + +static int checkout_write_merge( + checkout_data *data, + checkout_conflictdata *conflict) +{ + git_buf our_label = GIT_BUF_INIT, their_label = GIT_BUF_INIT, + path_suffixed = GIT_BUF_INIT, path_workdir = GIT_BUF_INIT, + in_data = GIT_BUF_INIT, out_data = GIT_BUF_INIT; + git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT; + git_merge_file_result result = {0}; + git_filebuf output = GIT_FILEBUF_INIT; + git_filter_list *fl = NULL; + git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; + int error = 0; + + if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3) + opts.flags |= GIT_MERGE_FILE_STYLE_DIFF3; + + opts.ancestor_label = data->opts.ancestor_label ? + data->opts.ancestor_label : "ancestor"; + opts.our_label = data->opts.our_label ? + data->opts.our_label : "ours"; + opts.their_label = data->opts.their_label ? + data->opts.their_label : "theirs"; + + /* If all the paths are identical, decorate the diff3 file with the branch + * names. Otherwise, append branch_name:path. + */ + if (conflict->ours && conflict->theirs && + strcmp(conflict->ours->path, conflict->theirs->path) != 0) { + + if ((error = conflict_entry_name( + &our_label, opts.our_label, conflict->ours->path)) < 0 || + (error = conflict_entry_name( + &their_label, opts.their_label, conflict->theirs->path)) < 0) + goto done; + + opts.our_label = git_buf_cstr(&our_label); + opts.their_label = git_buf_cstr(&their_label); + } + + if ((error = git_merge_file_from_index(&result, data->repo, + conflict->ancestor, conflict->ours, conflict->theirs, &opts)) < 0) + goto done; + + if (result.path == NULL || result.mode == 0) { + giterr_set(GITERR_CHECKOUT, "Could not merge contents of file"); + error = GIT_EMERGECONFLICT; + goto done; + } + + if ((error = checkout_merge_path(&path_workdir, data, conflict, &result)) < 0) + goto done; + + if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 && + (error = checkout_safe_for_update_only(data, git_buf_cstr(&path_workdir), result.mode)) <= 0) + goto done; + + if (!data->opts.disable_filters) { + in_data.ptr = (char *)result.ptr; + in_data.size = result.len; + + filter_opts.attr_session = &data->attr_session; + filter_opts.temp_buf = &data->tmp; + + if ((error = git_filter_list__load_ext( + &fl, data->repo, NULL, git_buf_cstr(&path_workdir), + GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 || + (error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0) + goto done; + } else { + out_data.ptr = (char *)result.ptr; + out_data.size = result.len; + } + + if ((error = mkpath2file(data, path_workdir.ptr, data->opts.dir_mode)) < 0 || + (error = git_filebuf_open(&output, git_buf_cstr(&path_workdir), GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 || + (error = git_filebuf_write(&output, out_data.ptr, out_data.size)) < 0 || + (error = git_filebuf_commit(&output)) < 0) + goto done; + +done: + git_filter_list_free(fl); + + git_buf_free(&out_data); + git_buf_free(&our_label); + git_buf_free(&their_label); + + git_merge_file_result_free(&result); + git_buf_free(&path_workdir); + git_buf_free(&path_suffixed); + + return error; +} + +static int checkout_conflict_add( + checkout_data *data, + const git_index_entry *conflict) +{ + int error = git_index_remove(data->index, conflict->path, 0); + + if (error == GIT_ENOTFOUND) + giterr_clear(); + else if (error < 0) + return error; + + return git_index_add(data->index, conflict); +} + +static int checkout_conflict_update_index( + checkout_data *data, + checkout_conflictdata *conflict) +{ + int error = 0; + + if (conflict->ancestor) + error = checkout_conflict_add(data, conflict->ancestor); + + if (!error && conflict->ours) + error = checkout_conflict_add(data, conflict->ours); + + if (!error && conflict->theirs) + error = checkout_conflict_add(data, conflict->theirs); + + return error; +} + +static int checkout_create_conflicts(checkout_data *data) +{ + checkout_conflictdata *conflict; + size_t i; + int error = 0; + + git_vector_foreach(&data->update_conflicts, i, conflict) { + + /* Both deleted: nothing to do */ + if (conflict->ours == NULL && conflict->theirs == NULL) + error = 0; + + else if ((data->strategy & GIT_CHECKOUT_USE_OURS) && + conflict->ours) + error = checkout_write_entry(data, conflict, conflict->ours); + else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) && + conflict->theirs) + error = checkout_write_entry(data, conflict, conflict->theirs); + + /* Ignore the other side of name collisions. */ + else if ((data->strategy & GIT_CHECKOUT_USE_OURS) && + !conflict->ours && conflict->name_collision) + error = 0; + else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) && + !conflict->theirs && conflict->name_collision) + error = 0; + + /* For modify/delete, name collisions and d/f conflicts, write + * the file (potentially with the name mangled. + */ + else if (conflict->ours != NULL && conflict->theirs == NULL) + error = checkout_write_entry(data, conflict, conflict->ours); + else if (conflict->ours == NULL && conflict->theirs != NULL) + error = checkout_write_entry(data, conflict, conflict->theirs); + + /* Add/add conflicts and rename 1->2 conflicts, write the + * ours/theirs sides (potentially name mangled). + */ + else if (conflict->one_to_two) + error = checkout_write_entries(data, conflict); + + /* If all sides are links, write the ours side */ + else if (S_ISLNK(conflict->ours->mode) && + S_ISLNK(conflict->theirs->mode)) + error = checkout_write_entry(data, conflict, conflict->ours); + /* Link/file conflicts, write the file side */ + else if (S_ISLNK(conflict->ours->mode)) + error = checkout_write_entry(data, conflict, conflict->theirs); + else if (S_ISLNK(conflict->theirs->mode)) + error = checkout_write_entry(data, conflict, conflict->ours); + + /* If any side is a gitlink, do nothing. */ + else if (conflict->submodule) + error = 0; + + /* If any side is binary, write the ours side */ + else if (conflict->binary) + error = checkout_write_entry(data, conflict, conflict->ours); + + else if (!error) + error = checkout_write_merge(data, conflict); + + /* Update the index extensions (REUC and NAME) if we're checking + * out a different index. (Otherwise just leave them there.) + */ + if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0) + error = checkout_conflict_update_index(data, conflict); + + if (error) + break; + + data->completed_steps++; + report_progress(data, + conflict->ours ? conflict->ours->path : + (conflict->theirs ? conflict->theirs->path : conflict->ancestor->path)); + } + + return error; +} + +static int checkout_remove_conflicts(checkout_data *data) +{ + const char *conflict; + size_t i; + + git_vector_foreach(&data->remove_conflicts, i, conflict) { + if (git_index_conflict_remove(data->index, conflict) < 0) + return -1; + + data->completed_steps++; + } + + return 0; +} + +static int checkout_extensions_update_index(checkout_data *data) +{ + const git_index_reuc_entry *reuc_entry; + const git_index_name_entry *name_entry; + size_t i; + int error = 0; + + if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) + return 0; + + if (data->update_reuc) { + git_vector_foreach(data->update_reuc, i, reuc_entry) { + if ((error = git_index_reuc_add(data->index, reuc_entry->path, + reuc_entry->mode[0], &reuc_entry->oid[0], + reuc_entry->mode[1], &reuc_entry->oid[1], + reuc_entry->mode[2], &reuc_entry->oid[2])) < 0) + goto done; + } + } + + if (data->update_names) { + git_vector_foreach(data->update_names, i, name_entry) { + if ((error = git_index_name_add(data->index, name_entry->ancestor, + name_entry->ours, name_entry->theirs)) < 0) + goto done; + } + } + +done: + return error; +} + +static void checkout_data_clear(checkout_data *data) +{ + if (data->opts_free_baseline) { + git_tree_free(data->opts.baseline); + data->opts.baseline = NULL; + } + + git_vector_free(&data->removes); + git_pool_clear(&data->pool); + + git_vector_free_deep(&data->remove_conflicts); + git_vector_free_deep(&data->update_conflicts); + + git__free(data->pfx); + data->pfx = NULL; + + git_strmap_free(data->mkdir_map); + + git_buf_free(&data->path); + git_buf_free(&data->tmp); + + git_index_free(data->index); + data->index = NULL; + + git_strmap_free(data->mkdir_map); + + git_attr_session__free(&data->attr_session); +} + +static int checkout_data_init( + checkout_data *data, + git_iterator *target, + const git_checkout_options *proposed) +{ + int error = 0; + git_repository *repo = git_iterator_owner(target); + + memset(data, 0, sizeof(*data)); + + if (!repo) { + giterr_set(GITERR_CHECKOUT, "Cannot checkout nothing"); + return -1; + } + + if ((!proposed || !proposed->target_directory) && + (error = git_repository__ensure_not_bare(repo, "checkout")) < 0) + return error; + + data->repo = repo; + data->target = target; + + GITERR_CHECK_VERSION( + proposed, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options"); + + if (!proposed) + GIT_INIT_STRUCTURE(&data->opts, GIT_CHECKOUT_OPTIONS_VERSION); + else + memmove(&data->opts, proposed, sizeof(git_checkout_options)); + + if (!data->opts.target_directory) + data->opts.target_directory = git_repository_workdir(repo); + else if (!git_path_isdir(data->opts.target_directory) && + (error = checkout_mkdir(data, + data->opts.target_directory, NULL, + GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0) + goto cleanup; + + /* refresh config and index content unless NO_REFRESH is given */ + if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) { + git_config *cfg; + + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) + goto cleanup; + + /* Get the repository index and reload it (unless we're checking + * out the index; then it has the changes we're trying to check + * out and those should not be overwritten.) + */ + if ((error = git_repository_index(&data->index, data->repo)) < 0) + goto cleanup; + + if (data->index != git_iterator_get_index(target)) { + if ((error = git_index_read(data->index, true)) < 0) + goto cleanup; + + /* cannot checkout if unresolved conflicts exist */ + if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) == 0 && + git_index_has_conflicts(data->index)) { + error = GIT_EMERGECONFLICT; + giterr_set(GITERR_CHECKOUT, + "unresolved conflicts exist in the index"); + goto cleanup; + } + + /* clean conflict data in the current index */ + git_index_name_clear(data->index); + git_index_reuc_clear(data->index); + } + } + + /* if you are forcing, allow all safe updates, plus recreate missing */ + if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0) + data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE | + GIT_CHECKOUT_RECREATE_MISSING; + + /* if the repository does not actually have an index file, then this + * is an initial checkout (perhaps from clone), so we allow safe updates + */ + if (!data->index->on_disk && + (data->opts.checkout_strategy & GIT_CHECKOUT_SAFE) != 0) + data->opts.checkout_strategy |= GIT_CHECKOUT_RECREATE_MISSING; + + data->strategy = data->opts.checkout_strategy; + + /* opts->disable_filters is false by default */ + + if (!data->opts.dir_mode) + data->opts.dir_mode = GIT_DIR_MODE; + + if (!data->opts.file_open_flags) + data->opts.file_open_flags = O_CREAT | O_TRUNC | O_WRONLY; + + data->pfx = git_pathspec_prefix(&data->opts.paths); + + if ((error = git_repository__cvar( + &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0) + goto cleanup; + + if (!data->opts.baseline) { + data->opts_free_baseline = true; + + error = checkout_lookup_head_tree(&data->opts.baseline, repo); + + if (error == GIT_EUNBORNBRANCH) { + error = 0; + giterr_clear(); + } + + if (error < 0) + goto cleanup; + } + + if ((data->opts.checkout_strategy & + (GIT_CHECKOUT_CONFLICT_STYLE_MERGE | GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)) == 0) { + git_config_entry *conflict_style = NULL; + git_config *cfg = NULL; + + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 || + (error = git_config_get_entry(&conflict_style, cfg, "merge.conflictstyle")) < 0 || + error == GIT_ENOTFOUND) + ; + else if (error) + goto cleanup; + else if (strcmp(conflict_style->value, "merge") == 0) + data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_MERGE; + else if (strcmp(conflict_style->value, "diff3") == 0) + data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_DIFF3; + else { + giterr_set(GITERR_CHECKOUT, "unknown style '%s' given for 'merge.conflictstyle'", + conflict_style); + error = -1; + git_config_entry_free(conflict_style); + goto cleanup; + } + git_config_entry_free(conflict_style); + } + + if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 || + (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 || + (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 || + (error = git_pool_init(&data->pool, 1, 0)) < 0 || + (error = git_buf_puts(&data->path, data->opts.target_directory)) < 0 || + (error = git_path_to_dir(&data->path)) < 0 || + (error = git_strmap_alloc(&data->mkdir_map)) < 0) + goto cleanup; + + data->workdir_len = git_buf_len(&data->path); + + git_attr_session__init(&data->attr_session, data->repo); + +cleanup: + if (error < 0) + checkout_data_clear(data); + + return error; +} + +#define CHECKOUT_INDEX_DONT_WRITE_MASK \ + (GIT_CHECKOUT_DONT_UPDATE_INDEX | GIT_CHECKOUT_DONT_WRITE_INDEX) + +int git_checkout_iterator( + git_iterator *target, + git_index *index, + const git_checkout_options *opts) +{ + int error = 0; + git_iterator *baseline = NULL, *workdir = NULL; + checkout_data data = {0}; + git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT; + uint32_t *actions = NULL; + size_t *counts = NULL; + git_iterator_flag_t iterflags = 0; + + /* initialize structures and options */ + error = checkout_data_init(&data, target, opts); + if (error < 0) + return error; + + diff_opts.flags = + GIT_DIFF_INCLUDE_UNMODIFIED | + GIT_DIFF_INCLUDE_UNREADABLE | + GIT_DIFF_INCLUDE_UNTRACKED | + GIT_DIFF_RECURSE_UNTRACKED_DIRS | /* needed to match baseline */ + GIT_DIFF_INCLUDE_IGNORED | + GIT_DIFF_INCLUDE_TYPECHANGE | + GIT_DIFF_INCLUDE_TYPECHANGE_TREES | + GIT_DIFF_SKIP_BINARY_CHECK; + if (data.opts.checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) + diff_opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH; + if (data.opts.paths.count > 0) + diff_opts.pathspec = data.opts.paths; + + /* set up iterators */ + + iterflags = git_iterator_ignore_case(target) ? + GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE; + + if ((error = git_iterator_reset(target, data.pfx, data.pfx)) < 0 || + (error = git_iterator_for_workdir_ext( + &workdir, data.repo, data.opts.target_directory, index, NULL, + iterflags | GIT_ITERATOR_DONT_AUTOEXPAND, + data.pfx, data.pfx)) < 0 || + (error = git_iterator_for_tree( + &baseline, data.opts.baseline, + iterflags, data.pfx, data.pfx)) < 0) + goto cleanup; + + /* Should not have case insensitivity mismatch */ + assert(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline)); + + /* Generate baseline-to-target diff which will include an entry for + * every possible update that might need to be made. + */ + if ((error = git_diff__from_iterators( + &data.diff, data.repo, baseline, target, &diff_opts)) < 0) + goto cleanup; + + /* Loop through diff (and working directory iterator) building a list of + * actions to be taken, plus look for conflicts and send notifications, + * then loop through conflicts. + */ + if ((error = checkout_get_actions(&actions, &counts, &data, workdir)) != 0) + goto cleanup; + + data.total_steps = counts[CHECKOUT_ACTION__REMOVE] + + counts[CHECKOUT_ACTION__REMOVE_CONFLICT] + + counts[CHECKOUT_ACTION__UPDATE_BLOB] + + counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] + + counts[CHECKOUT_ACTION__UPDATE_CONFLICT]; + + report_progress(&data, NULL); /* establish 0 baseline */ + + /* To deal with some order dependencies, perform remaining checkout + * in three passes: removes, then update blobs, then update submodules. + */ + if (counts[CHECKOUT_ACTION__REMOVE] > 0 && + (error = checkout_remove_the_old(actions, &data)) < 0) + goto cleanup; + + if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 && + (error = checkout_remove_conflicts(&data)) < 0) + goto cleanup; + + if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 && + (error = checkout_create_the_new(actions, &data)) < 0) + goto cleanup; + + if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 && + (error = checkout_create_submodules(actions, &data)) < 0) + goto cleanup; + + if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 && + (error = checkout_create_conflicts(&data)) < 0) + goto cleanup; + + if (data.index != git_iterator_get_index(target) && + (error = checkout_extensions_update_index(&data)) < 0) + goto cleanup; + + assert(data.completed_steps == data.total_steps); + + if (data.opts.perfdata_cb) + data.opts.perfdata_cb(&data.perfdata, data.opts.perfdata_payload); + +cleanup: + if (!error && data.index != NULL && + (data.strategy & CHECKOUT_INDEX_DONT_WRITE_MASK) == 0) + error = git_index_write(data.index); + + git_diff_free(data.diff); + git_iterator_free(workdir); + git_iterator_free(baseline); + git__free(actions); + git__free(counts); + checkout_data_clear(&data); + + return error; +} + +int git_checkout_index( + git_repository *repo, + git_index *index, + const git_checkout_options *opts) +{ + int error, owned = 0; + git_iterator *index_i; + + if (!index && !repo) { + giterr_set(GITERR_CHECKOUT, + "Must provide either repository or index to checkout"); + return -1; + } + + if (index && repo && + git_index_owner(index) && + git_index_owner(index) != repo) { + giterr_set(GITERR_CHECKOUT, + "Index to checkout does not match repository"); + return -1; + } else if(index && repo && !git_index_owner(index)) { + GIT_REFCOUNT_OWN(index, repo); + owned = 1; + } + + if (!repo) + repo = git_index_owner(index); + + if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0) + return error; + GIT_REFCOUNT_INC(index); + + if (!(error = git_iterator_for_index(&index_i, index, 0, NULL, NULL))) + error = git_checkout_iterator(index_i, index, opts); + + if (owned) + GIT_REFCOUNT_OWN(index, NULL); + + git_iterator_free(index_i); + git_index_free(index); + + return error; +} + +int git_checkout_tree( + git_repository *repo, + const git_object *treeish, + const git_checkout_options *opts) +{ + int error; + git_index *index; + git_tree *tree = NULL; + git_iterator *tree_i = NULL; + + if (!treeish && !repo) { + giterr_set(GITERR_CHECKOUT, + "Must provide either repository or tree to checkout"); + return -1; + } + if (treeish && repo && git_object_owner(treeish) != repo) { + giterr_set(GITERR_CHECKOUT, + "Object to checkout does not match repository"); + return -1; + } + + if (!repo) + repo = git_object_owner(treeish); + + if (treeish) { + if (git_object_peel((git_object **)&tree, treeish, GIT_OBJ_TREE) < 0) { + giterr_set( + GITERR_CHECKOUT, "Provided object cannot be peeled to a tree"); + return -1; + } + } + else { + if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) { + if (error != GIT_EUNBORNBRANCH) + giterr_set( + GITERR_CHECKOUT, + "HEAD could not be peeled to a tree and no treeish given"); + return error; + } + } + + if ((error = git_repository_index(&index, repo)) < 0) + return error; + + if (!(error = git_iterator_for_tree(&tree_i, tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL))) + error = git_checkout_iterator(tree_i, index, opts); + + git_iterator_free(tree_i); + git_index_free(index); + git_tree_free(tree); + + return error; +} + +int git_checkout_head( + git_repository *repo, + const git_checkout_options *opts) +{ + assert(repo); + return git_checkout_tree(repo, NULL, opts); +} + +int git_checkout_init_options(git_checkout_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_checkout_options, GIT_CHECKOUT_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/checkout.h b/deps/libgit2-sys-0.2.17/libgit2/src/checkout.h new file mode 100644 index 000000000..60aa29b26 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/checkout.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_checkout_h__ +#define INCLUDE_checkout_h__ + +#include "git2/checkout.h" +#include "iterator.h" + +#define GIT_CHECKOUT__NOTIFY_CONFLICT_TREE (1u << 12) + +/** + * Update the working directory to match the target iterator. The + * expected baseline value can be passed in via the checkout options + * or else will default to the HEAD commit. + */ +extern int git_checkout_iterator( + git_iterator *target, + git_index *index, + const git_checkout_options *opts); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/cherrypick.c b/deps/libgit2-sys-0.2.17/libgit2/src/cherrypick.c new file mode 100644 index 000000000..c92975194 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/cherrypick.c @@ -0,0 +1,229 @@ +/* +* Copyright (C) the libgit2 contributors. All rights reserved. +* +* This file is part of libgit2, distributed under the GNU GPL v2 with +* a Linking Exception. For full terms see the included COPYING file. +*/ + +#include "common.h" +#include "repository.h" +#include "filebuf.h" +#include "merge.h" +#include "vector.h" +#include "index.h" + +#include "git2/types.h" +#include "git2/merge.h" +#include "git2/cherrypick.h" +#include "git2/commit.h" +#include "git2/sys/commit.h" + +#define GIT_CHERRYPICK_FILE_MODE 0666 + +static int write_cherrypick_head( + git_repository *repo, + const char *commit_oidstr) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_CHERRYPICK_HEAD_FILE)) >= 0 && + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) >= 0 && + (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) + error = git_filebuf_commit(&file); + + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int write_merge_msg( + git_repository *repo, + const char *commit_msg) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) < 0 || + (error = git_filebuf_printf(&file, "%s", commit_msg)) < 0) + goto cleanup; + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int cherrypick_normalize_opts( + git_repository *repo, + git_cherrypick_options *opts, + const git_cherrypick_options *given, + const char *their_label) +{ + int error = 0; + unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE | + GIT_CHECKOUT_ALLOW_CONFLICTS; + + GIT_UNUSED(repo); + + if (given != NULL) + memcpy(opts, given, sizeof(git_cherrypick_options)); + else { + git_cherrypick_options default_opts = GIT_CHERRYPICK_OPTIONS_INIT; + memcpy(opts, &default_opts, sizeof(git_cherrypick_options)); + } + + if (!opts->checkout_opts.checkout_strategy) + opts->checkout_opts.checkout_strategy = default_checkout_strategy; + + if (!opts->checkout_opts.our_label) + opts->checkout_opts.our_label = "HEAD"; + + if (!opts->checkout_opts.their_label) + opts->checkout_opts.their_label = their_label; + + return error; +} + +static int cherrypick_state_cleanup(git_repository *repo) +{ + const char *state_files[] = { GIT_CHERRYPICK_HEAD_FILE, GIT_MERGE_MSG_FILE }; + + return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); +} + +static int cherrypick_seterr(git_commit *commit, const char *fmt) +{ + char commit_oidstr[GIT_OID_HEXSZ + 1]; + + giterr_set(GITERR_CHERRYPICK, fmt, + git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); + + return -1; +} + +int git_cherrypick_commit( + git_index **out, + git_repository *repo, + git_commit *cherrypick_commit, + git_commit *our_commit, + unsigned int mainline, + const git_merge_options *merge_opts) +{ + git_commit *parent_commit = NULL; + git_tree *parent_tree = NULL, *our_tree = NULL, *cherrypick_tree = NULL; + int parent = 0, error = 0; + + assert(out && repo && cherrypick_commit && our_commit); + + if (git_commit_parentcount(cherrypick_commit) > 1) { + if (!mainline) + return cherrypick_seterr(cherrypick_commit, + "Mainline branch is not specified but %s is a merge commit"); + + parent = mainline; + } else { + if (mainline) + return cherrypick_seterr(cherrypick_commit, + "Mainline branch specified but %s is not a merge commit"); + + parent = git_commit_parentcount(cherrypick_commit); + } + + if (parent && + ((error = git_commit_parent(&parent_commit, cherrypick_commit, (parent - 1))) < 0 || + (error = git_commit_tree(&parent_tree, parent_commit)) < 0)) + goto done; + + if ((error = git_commit_tree(&cherrypick_tree, cherrypick_commit)) < 0 || + (error = git_commit_tree(&our_tree, our_commit)) < 0) + goto done; + + error = git_merge_trees(out, repo, parent_tree, our_tree, cherrypick_tree, merge_opts); + +done: + git_tree_free(parent_tree); + git_tree_free(our_tree); + git_tree_free(cherrypick_tree); + git_commit_free(parent_commit); + + return error; +} + +int git_cherrypick( + git_repository *repo, + git_commit *commit, + const git_cherrypick_options *given_opts) +{ + git_cherrypick_options opts; + git_reference *our_ref = NULL; + git_commit *our_commit = NULL; + char commit_oidstr[GIT_OID_HEXSZ + 1]; + const char *commit_msg, *commit_summary; + git_buf their_label = GIT_BUF_INIT; + git_index *index = NULL; + git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; + int error = 0; + + assert(repo && commit); + + GITERR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options"); + + if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0) + return error; + + if ((commit_msg = git_commit_message(commit)) == NULL || + (commit_summary = git_commit_summary(commit)) == NULL) { + error = -1; + goto on_error; + } + + git_oid_nfmt(commit_oidstr, sizeof(commit_oidstr), git_commit_id(commit)); + + if ((error = write_merge_msg(repo, commit_msg)) < 0 || + (error = git_buf_printf(&their_label, "%.7s... %s", commit_oidstr, commit_summary)) < 0 || + (error = cherrypick_normalize_opts(repo, &opts, given_opts, git_buf_cstr(&their_label))) < 0 || + (error = git_indexwriter_init_for_operation(&indexwriter, repo, &opts.checkout_opts.checkout_strategy)) < 0 || + (error = write_cherrypick_head(repo, commit_oidstr)) < 0 || + (error = git_repository_head(&our_ref, repo)) < 0 || + (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 || + (error = git_cherrypick_commit(&index, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 || + (error = git_merge__check_result(repo, index)) < 0 || + (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 || + (error = git_checkout_index(repo, index, &opts.checkout_opts)) < 0 || + (error = git_indexwriter_commit(&indexwriter)) < 0) + goto on_error; + + goto done; + +on_error: + cherrypick_state_cleanup(repo); + +done: + git_indexwriter_cleanup(&indexwriter); + git_index_free(index); + git_commit_free(our_commit); + git_reference_free(our_ref); + git_buf_free(&their_label); + + return error; +} + +int git_cherrypick_init_options( + git_cherrypick_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_cherrypick_options, GIT_CHERRYPICK_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/clone.c b/deps/libgit2-sys-0.2.17/libgit2/src/clone.c new file mode 100644 index 000000000..7e5d3302e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/clone.c @@ -0,0 +1,566 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include + +#include "git2/clone.h" +#include "git2/remote.h" +#include "git2/revparse.h" +#include "git2/branch.h" +#include "git2/config.h" +#include "git2/checkout.h" +#include "git2/commit.h" +#include "git2/tree.h" + +#include "common.h" +#include "remote.h" +#include "fileops.h" +#include "refs.h" +#include "path.h" +#include "repository.h" +#include "odb.h" + +static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link); + +static int create_branch( + git_reference **branch, + git_repository *repo, + const git_oid *target, + const char *name, + const char *log_message) +{ + git_commit *head_obj = NULL; + git_reference *branch_ref = NULL; + git_buf refname = GIT_BUF_INIT; + int error; + + /* Find the target commit */ + if ((error = git_commit_lookup(&head_obj, repo, target)) < 0) + return error; + + /* Create the new branch */ + if ((error = git_buf_printf(&refname, GIT_REFS_HEADS_DIR "%s", name)) < 0) + return error; + + error = git_reference_create(&branch_ref, repo, git_buf_cstr(&refname), target, 0, log_message); + git_buf_free(&refname); + git_commit_free(head_obj); + + if (!error) + *branch = branch_ref; + else + git_reference_free(branch_ref); + + return error; +} + +static int setup_tracking_config( + git_repository *repo, + const char *branch_name, + const char *remote_name, + const char *merge_target) +{ + git_config *cfg; + git_buf remote_key = GIT_BUF_INIT, merge_key = GIT_BUF_INIT; + int error = -1; + + if (git_repository_config__weakptr(&cfg, repo) < 0) + return -1; + + if (git_buf_printf(&remote_key, "branch.%s.remote", branch_name) < 0) + goto cleanup; + + if (git_buf_printf(&merge_key, "branch.%s.merge", branch_name) < 0) + goto cleanup; + + if (git_config_set_string(cfg, git_buf_cstr(&remote_key), remote_name) < 0) + goto cleanup; + + if (git_config_set_string(cfg, git_buf_cstr(&merge_key), merge_target) < 0) + goto cleanup; + + error = 0; + +cleanup: + git_buf_free(&remote_key); + git_buf_free(&merge_key); + return error; +} + +static int create_tracking_branch( + git_reference **branch, + git_repository *repo, + const git_oid *target, + const char *branch_name, + const char *log_message) +{ + int error; + + if ((error = create_branch(branch, repo, target, branch_name, log_message)) < 0) + return error; + + return setup_tracking_config( + repo, + branch_name, + GIT_REMOTE_ORIGIN, + git_reference_name(*branch)); +} + +static int update_head_to_new_branch( + git_repository *repo, + const git_oid *target, + const char *name, + const char *reflog_message) +{ + git_reference *tracking_branch = NULL; + int error; + + if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR)) + name += strlen(GIT_REFS_HEADS_DIR); + + error = create_tracking_branch(&tracking_branch, repo, target, name, + reflog_message); + + if (!error) + error = git_repository_set_head( + repo, git_reference_name(tracking_branch)); + + git_reference_free(tracking_branch); + + /* if it already existed, then the user's refspec created it for us, ignore it' */ + if (error == GIT_EEXISTS) + error = 0; + + return error; +} + +static int update_head_to_remote( + git_repository *repo, + git_remote *remote, + const char *reflog_message) +{ + int error = 0; + size_t refs_len; + git_refspec *refspec; + const git_remote_head *remote_head, **refs; + const git_oid *remote_head_id; + git_buf remote_master_name = GIT_BUF_INIT; + git_buf branch = GIT_BUF_INIT; + + if ((error = git_remote_ls(&refs, &refs_len, remote)) < 0) + return error; + + /* We cloned an empty repository or one with an unborn HEAD */ + if (refs_len == 0 || strcmp(refs[0]->name, GIT_HEAD_FILE)) + return setup_tracking_config( + repo, "master", GIT_REMOTE_ORIGIN, GIT_REFS_HEADS_MASTER_FILE); + + /* We know we have HEAD, let's see where it points */ + remote_head = refs[0]; + assert(remote_head); + + remote_head_id = &remote_head->oid; + + error = git_remote_default_branch(&branch, remote); + if (error == GIT_ENOTFOUND) { + error = git_repository_set_head_detached( + repo, remote_head_id); + goto cleanup; + } + + refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch)); + + if (refspec == NULL) { + giterr_set(GITERR_NET, "the remote's default branch does not fit the refspec configuration"); + error = GIT_EINVALIDSPEC; + goto cleanup; + } + + /* Determine the remote tracking reference name from the local master */ + if ((error = git_refspec_transform( + &remote_master_name, + refspec, + git_buf_cstr(&branch))) < 0) + goto cleanup; + + error = update_head_to_new_branch( + repo, + remote_head_id, + git_buf_cstr(&branch), + reflog_message); + +cleanup: + git_buf_free(&remote_master_name); + git_buf_free(&branch); + + return error; +} + +static int update_head_to_branch( + git_repository *repo, + const char *remote_name, + const char *branch, + const char *reflog_message) +{ + int retcode; + git_buf remote_branch_name = GIT_BUF_INIT; + git_reference* remote_ref = NULL; + + assert(remote_name && branch); + + if ((retcode = git_buf_printf(&remote_branch_name, GIT_REFS_REMOTES_DIR "%s/%s", + remote_name, branch)) < 0 ) + goto cleanup; + + if ((retcode = git_reference_lookup(&remote_ref, repo, git_buf_cstr(&remote_branch_name))) < 0) + goto cleanup; + + retcode = update_head_to_new_branch(repo, git_reference_target(remote_ref), branch, + reflog_message); + +cleanup: + git_reference_free(remote_ref); + git_buf_free(&remote_branch_name); + return retcode; +} + +static int default_repository_create(git_repository **out, const char *path, int bare, void *payload) +{ + GIT_UNUSED(payload); + + return git_repository_init(out, path, bare); +} + +static int default_remote_create( + git_remote **out, + git_repository *repo, + const char *name, + const char *url, + void *payload) +{ + int error; + git_remote_callbacks *callbacks = payload; + + if ((error = git_remote_create(out, repo, name, url)) < 0) + return error; + + return git_remote_set_callbacks(*out, callbacks); +} + +/* + * submodules? + */ + +static int create_and_configure_origin( + git_remote **out, + git_repository *repo, + const char *url, + const git_clone_options *options) +{ + int error; + git_remote *origin = NULL; + char buf[GIT_PATH_MAX]; + git_remote_create_cb remote_create = options->remote_cb; + void *payload = options->remote_cb_payload; + + /* If the path exists and is a dir, the url should be the absolute path */ + if (git_path_root(url) < 0 && git_path_exists(url) && git_path_isdir(url)) { + if (p_realpath(url, buf) == NULL) + return -1; + + url = buf; + } + + if (!remote_create) { + remote_create = default_remote_create; + payload = (void *)&options->remote_callbacks; + } + + if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0) + goto on_error; + + if ((error = git_remote_save(origin)) < 0) + goto on_error; + + *out = origin; + return 0; + +on_error: + git_remote_free(origin); + return error; +} + +static bool should_checkout( + git_repository *repo, + bool is_bare, + const git_checkout_options *opts) +{ + if (is_bare) + return false; + + if (!opts) + return false; + + if (opts->checkout_strategy == GIT_CHECKOUT_NONE) + return false; + + return !git_repository_head_unborn(repo); +} + +static int checkout_branch(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, const char *reflog_message) +{ + int error; + + if (branch) + error = update_head_to_branch(repo, git_remote_name(remote), branch, + reflog_message); + /* Point HEAD to the same ref as the remote's head */ + else + error = update_head_to_remote(repo, remote, reflog_message); + + if (!error && should_checkout(repo, git_repository_is_bare(repo), co_opts)) + error = git_checkout_head(repo, co_opts); + + return error; +} + +static int clone_into(git_repository *repo, git_remote *_remote, const git_checkout_options *co_opts, const char *branch) +{ + int error; + git_buf reflog_message = GIT_BUF_INIT; + git_remote *remote; + const git_remote_callbacks *callbacks; + + assert(repo && _remote); + + if (!git_repository_is_empty(repo)) { + giterr_set(GITERR_INVALID, "the repository is not empty"); + return -1; + } + + if ((error = git_remote_dup(&remote, _remote)) < 0) + return error; + + callbacks = git_remote_get_callbacks(_remote); + if (!giterr__check_version(callbacks, 1, "git_remote_callbacks") && + (error = git_remote_set_callbacks(remote, callbacks)) < 0) + goto cleanup; + + if ((error = git_remote_add_fetch(remote, "refs/tags/*:refs/tags/*")) < 0) + goto cleanup; + + git_remote_set_update_fetchhead(remote, 0); + git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote)); + + if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0) + goto cleanup; + + error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message)); + +cleanup: + git_remote_free(remote); + git_buf_free(&reflog_message); + + return error; +} + +int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t local) +{ + git_buf fromurl = GIT_BUF_INIT; + const char *path = url_or_path; + bool is_url, is_local; + + if (local == GIT_CLONE_NO_LOCAL) + return 0; + + if ((is_url = git_path_is_local_file_url(url_or_path)) != 0) { + if (git_path_fromurl(&fromurl, url_or_path) < 0) { + is_local = -1; + goto done; + } + + path = fromurl.ptr; + } + + is_local = (!is_url || local != GIT_CLONE_LOCAL_AUTO) && + git_path_isdir(path); + +done: + git_buf_free(&fromurl); + return is_local; +} + +int git_clone( + git_repository **out, + const char *url, + const char *local_path, + const git_clone_options *_options) +{ + int error = 0; + git_repository *repo = NULL; + git_remote *origin; + git_clone_options options = GIT_CLONE_OPTIONS_INIT; + uint32_t rmdir_flags = GIT_RMDIR_REMOVE_FILES; + git_repository_create_cb repository_cb; + + assert(out && url && local_path); + + if (_options) + memcpy(&options, _options, sizeof(git_clone_options)); + + GITERR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options"); + + /* Only clone to a new directory or an empty directory */ + if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) { + giterr_set(GITERR_INVALID, + "'%s' exists and is not an empty directory", local_path); + return GIT_EEXISTS; + } + + /* Only remove the root directory on failure if we create it */ + if (git_path_exists(local_path)) + rmdir_flags |= GIT_RMDIR_SKIP_ROOT; + + if (options.repository_cb) + repository_cb = options.repository_cb; + else + repository_cb = default_repository_create; + + if ((error = repository_cb(&repo, local_path, options.bare, options.repository_cb_payload)) < 0) + return error; + + if (!(error = create_and_configure_origin(&origin, repo, url, &options))) { + int clone_local = git_clone__should_clone_local(url, options.local); + int link = options.local != GIT_CLONE_LOCAL_NO_LINKS; + + if (clone_local == 1) + error = clone_local_into( + repo, origin, &options.checkout_opts, + options.checkout_branch, link); + else if (clone_local == 0) + error = clone_into( + repo, origin, &options.checkout_opts, + options.checkout_branch); + else + error = -1; + + git_remote_free(origin); + } + + if (error != 0) { + git_error_state last_error = {0}; + giterr_capture(&last_error, error); + + git_repository_free(repo); + repo = NULL; + + (void)git_futils_rmdir_r(local_path, NULL, rmdir_flags); + + giterr_restore(&last_error); + } + + *out = repo; + return error; +} + +int git_clone_init_options(git_clone_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_clone_options, GIT_CLONE_OPTIONS_INIT); + return 0; +} + +static const char *repository_base(git_repository *repo) +{ + if (git_repository_is_bare(repo)) + return git_repository_path(repo); + + return git_repository_workdir(repo); +} + +static bool can_link(const char *src, const char *dst, int link) +{ +#ifdef GIT_WIN32 + GIT_UNUSED(src); + GIT_UNUSED(dst); + GIT_UNUSED(link); + return false; +#else + + struct stat st_src, st_dst; + + if (!link) + return false; + + if (p_stat(src, &st_src) < 0) + return false; + + if (p_stat(dst, &st_dst) < 0) + return false; + + return st_src.st_dev == st_dst.st_dev; +#endif +} + +static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link) +{ + int error, flags; + git_repository *src; + git_buf src_odb = GIT_BUF_INIT, dst_odb = GIT_BUF_INIT, src_path = GIT_BUF_INIT; + git_buf reflog_message = GIT_BUF_INIT; + + assert(repo && remote); + + if (!git_repository_is_empty(repo)) { + giterr_set(GITERR_INVALID, "the repository is not empty"); + return -1; + } + + /* + * Let's figure out what path we should use for the source + * repo, if it's not rooted, the path should be relative to + * the repository's worktree/gitdir. + */ + if ((error = git_path_from_url_or_path(&src_path, git_remote_url(remote))) < 0) + return error; + + /* Copy .git/objects/ from the source to the target */ + if ((error = git_repository_open(&src, git_buf_cstr(&src_path))) < 0) { + git_buf_free(&src_path); + return error; + } + + git_buf_joinpath(&src_odb, git_repository_path(src), GIT_OBJECTS_DIR); + git_buf_joinpath(&dst_odb, git_repository_path(repo), GIT_OBJECTS_DIR); + if (git_buf_oom(&src_odb) || git_buf_oom(&dst_odb)) { + error = -1; + goto cleanup; + } + + flags = 0; + if (can_link(git_repository_path(src), git_repository_path(repo), link)) + flags |= GIT_CPDIR_LINK_FILES; + + if ((error = git_futils_cp_r(git_buf_cstr(&src_odb), git_buf_cstr(&dst_odb), + flags, GIT_OBJECT_DIR_MODE)) < 0) + goto cleanup; + + git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote)); + + if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0) + goto cleanup; + + error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message)); + +cleanup: + git_buf_free(&reflog_message); + git_buf_free(&src_path); + git_buf_free(&src_odb); + git_buf_free(&dst_odb); + git_repository_free(src); + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/clone.h b/deps/libgit2-sys-0.2.17/libgit2/src/clone.h new file mode 100644 index 000000000..14ca5d44c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/clone.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_clone_h__ +#define INCLUDE_clone_h__ + +extern int git_clone__should_clone_local(const char *url, git_clone_local_t local); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/commit.c b/deps/libgit2-sys-0.2.17/libgit2/src/commit.c new file mode 100644 index 000000000..84f24c6cf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/commit.c @@ -0,0 +1,510 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/common.h" +#include "git2/object.h" +#include "git2/repository.h" +#include "git2/signature.h" +#include "git2/sys/commit.h" + +#include "common.h" +#include "odb.h" +#include "commit.h" +#include "signature.h" +#include "message.h" +#include "refs.h" + +void git_commit__free(void *_commit) +{ + git_commit *commit = _commit; + + git_array_clear(commit->parent_ids); + + git_signature_free(commit->author); + git_signature_free(commit->committer); + + git__free(commit->raw_header); + git__free(commit->raw_message); + git__free(commit->message_encoding); + git__free(commit->summary); + + git__free(commit); +} + +int git_commit_create_from_callback( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_oid *tree, + git_commit_parent_callback parent_cb, + void *parent_payload) +{ + git_reference *ref = NULL; + int error = 0, matched_parent = 0; + const git_oid *current_id = NULL; + git_buf commit = GIT_BUF_INIT; + size_t i = 0; + git_odb *odb; + const git_oid *parent; + + assert(id && repo && tree && parent_cb); + + if (update_ref) { + error = git_reference_lookup_resolved(&ref, repo, update_ref, 10); + if (error < 0 && error != GIT_ENOTFOUND) + return error; + } + giterr_clear(); + + if (ref) + current_id = git_reference_target(ref); + + git_oid__writebuf(&commit, "tree ", tree); + + while ((parent = parent_cb(i, parent_payload)) != NULL) { + git_oid__writebuf(&commit, "parent ", parent); + if (i == 0 && current_id && git_oid_equal(current_id, parent)) + matched_parent = 1; + i++; + } + + if (ref && !matched_parent) { + git_reference_free(ref); + git_buf_free(&commit); + giterr_set(GITERR_OBJECT, "failed to create commit: current tip is not the first parent"); + return GIT_EMODIFIED; + } + + git_signature__writebuf(&commit, "author ", author); + git_signature__writebuf(&commit, "committer ", committer); + + if (message_encoding != NULL) + git_buf_printf(&commit, "encoding %s\n", message_encoding); + + git_buf_putc(&commit, '\n'); + + if (git_buf_puts(&commit, message) < 0) + goto on_error; + + if (git_repository_odb__weakptr(&odb, repo) < 0) + goto on_error; + + if (git_odb_write(id, odb, commit.ptr, commit.size, GIT_OBJ_COMMIT) < 0) + goto on_error; + + git_buf_free(&commit); + + if (update_ref != NULL) { + error = git_reference__update_for_commit( + repo, ref, update_ref, id, "commit"); + git_reference_free(ref); + return error; + } + + return 0; + +on_error: + git_buf_free(&commit); + giterr_set(GITERR_OBJECT, "Failed to create commit."); + return -1; +} + +typedef struct { + size_t total; + va_list args; +} commit_parent_varargs; + +static const git_oid *commit_parent_from_varargs(size_t curr, void *payload) +{ + commit_parent_varargs *data = payload; + const git_commit *commit; + if (curr >= data->total) + return NULL; + commit = va_arg(data->args, const git_commit *); + return commit ? git_commit_id(commit) : NULL; +} + +int git_commit_create_v( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree, + size_t parent_count, + ...) +{ + int error = 0; + commit_parent_varargs data; + + assert(tree && git_tree_owner(tree) == repo); + + data.total = parent_count; + va_start(data.args, parent_count); + + error = git_commit_create_from_callback( + id, repo, update_ref, author, committer, + message_encoding, message, git_tree_id(tree), + commit_parent_from_varargs, &data); + + va_end(data.args); + return error; +} + +typedef struct { + size_t total; + const git_oid **parents; +} commit_parent_oids; + +static const git_oid *commit_parent_from_ids(size_t curr, void *payload) +{ + commit_parent_oids *data = payload; + return (curr < data->total) ? data->parents[curr] : NULL; +} + +int git_commit_create_from_ids( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_oid *tree, + size_t parent_count, + const git_oid *parents[]) +{ + commit_parent_oids data = { parent_count, parents }; + + return git_commit_create_from_callback( + id, repo, update_ref, author, committer, + message_encoding, message, tree, + commit_parent_from_ids, &data); +} + +typedef struct { + size_t total; + const git_commit **parents; + git_repository *repo; +} commit_parent_data; + +static const git_oid *commit_parent_from_array(size_t curr, void *payload) +{ + commit_parent_data *data = payload; + const git_commit *commit; + if (curr >= data->total) + return NULL; + commit = data->parents[curr]; + if (git_commit_owner(commit) != data->repo) + return NULL; + return git_commit_id(commit); +} + +int git_commit_create( + git_oid *id, + git_repository *repo, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree, + size_t parent_count, + const git_commit *parents[]) +{ + commit_parent_data data = { parent_count, parents, repo }; + + assert(tree && git_tree_owner(tree) == repo); + + return git_commit_create_from_callback( + id, repo, update_ref, author, committer, + message_encoding, message, git_tree_id(tree), + commit_parent_from_array, &data); +} + +static const git_oid *commit_parent_for_amend(size_t curr, void *payload) +{ + const git_commit *commit_to_amend = payload; + if (curr >= git_array_size(commit_to_amend->parent_ids)) + return NULL; + return git_array_get(commit_to_amend->parent_ids, curr); +} + +int git_commit_amend( + git_oid *id, + const git_commit *commit_to_amend, + const char *update_ref, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree) +{ + git_repository *repo; + git_oid tree_id; + git_reference *ref; + int error; + + assert(id && commit_to_amend); + + repo = git_commit_owner(commit_to_amend); + + if (!author) + author = git_commit_author(commit_to_amend); + if (!committer) + committer = git_commit_committer(commit_to_amend); + if (!message_encoding) + message_encoding = git_commit_message_encoding(commit_to_amend); + if (!message) + message = git_commit_message(commit_to_amend); + + if (!tree) { + git_tree *old_tree; + GITERR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) ); + git_oid_cpy(&tree_id, git_tree_id(old_tree)); + git_tree_free(old_tree); + } else { + assert(git_tree_owner(tree) == repo); + git_oid_cpy(&tree_id, git_tree_id(tree)); + } + + if (update_ref) { + if ((error = git_reference_lookup_resolved(&ref, repo, update_ref, 5)) < 0) + return error; + + if (git_oid_cmp(git_commit_id(commit_to_amend), git_reference_target(ref))) { + git_reference_free(ref); + giterr_set(GITERR_REFERENCE, "commit to amend is not the tip of the given branch"); + return -1; + } + } + + error = git_commit_create_from_callback( + id, repo, NULL, author, committer, message_encoding, message, + &tree_id, commit_parent_for_amend, (void *)commit_to_amend); + + if (!error && update_ref) { + error = git_reference__update_for_commit( + repo, ref, NULL, id, "commit"); + git_reference_free(ref); + } + + return error; +} + +int git_commit__parse(void *_commit, git_odb_object *odb_obj) +{ + git_commit *commit = _commit; + const char *buffer_start = git_odb_object_data(odb_obj), *buffer; + const char *buffer_end = buffer_start + git_odb_object_size(odb_obj); + git_oid parent_id; + size_t header_len; + + buffer = buffer_start; + + /* Allocate for one, which will allow not to realloc 90% of the time */ + git_array_init_to_size(commit->parent_ids, 1); + GITERR_CHECK_ARRAY(commit->parent_ids); + + /* The tree is always the first field */ + if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0) + goto bad_buffer; + + /* + * TODO: commit grafts! + */ + + while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) { + git_oid *new_id = git_array_alloc(commit->parent_ids); + GITERR_CHECK_ALLOC(new_id); + + git_oid_cpy(new_id, &parent_id); + } + + commit->author = git__malloc(sizeof(git_signature)); + GITERR_CHECK_ALLOC(commit->author); + + if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0) + return -1; + + /* Always parse the committer; we need the commit time */ + commit->committer = git__malloc(sizeof(git_signature)); + GITERR_CHECK_ALLOC(commit->committer); + + if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0) + return -1; + + /* Parse add'l header entries */ + while (buffer < buffer_end) { + const char *eoln = buffer; + if (buffer[-1] == '\n' && buffer[0] == '\n') + break; + + while (eoln < buffer_end && *eoln != '\n') + ++eoln; + + if (git__prefixcmp(buffer, "encoding ") == 0) { + buffer += strlen("encoding "); + + commit->message_encoding = git__strndup(buffer, eoln - buffer); + GITERR_CHECK_ALLOC(commit->message_encoding); + } + + if (eoln < buffer_end && *eoln == '\n') + ++eoln; + buffer = eoln; + } + + header_len = buffer - buffer_start; + commit->raw_header = git__strndup(buffer_start, header_len); + GITERR_CHECK_ALLOC(commit->raw_header); + + /* point "buffer" to data after header, +1 for the final LF */ + buffer = buffer_start + header_len + 1; + + /* extract commit message */ + if (buffer <= buffer_end) { + commit->raw_message = git__strndup(buffer, buffer_end - buffer); + GITERR_CHECK_ALLOC(commit->raw_message); + } + + return 0; + +bad_buffer: + giterr_set(GITERR_OBJECT, "Failed to parse bad commit object"); + return -1; +} + +#define GIT_COMMIT_GETTER(_rvalue, _name, _return) \ + _rvalue git_commit_##_name(const git_commit *commit) \ + {\ + assert(commit); \ + return _return; \ + } + +GIT_COMMIT_GETTER(const git_signature *, author, commit->author) +GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer) +GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message) +GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding) +GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header) +GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time) +GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset) +GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids)) +GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id) + +const char *git_commit_message(const git_commit *commit) +{ + const char *message; + + assert(commit); + + message = commit->raw_message; + + /* trim leading newlines from raw message */ + while (*message && *message == '\n') + ++message; + + return message; +} + +const char *git_commit_summary(git_commit *commit) +{ + git_buf summary = GIT_BUF_INIT; + const char *msg, *space; + + assert(commit); + + if (!commit->summary) { + for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) { + if (msg[0] == '\n' && (!msg[1] || msg[1] == '\n')) + break; + else if (msg[0] == '\n') + git_buf_putc(&summary, ' '); + else if (git__isspace(msg[0])) + space = space ? space : msg; + else if (space) { + git_buf_put(&summary, space, (msg - space) + 1); + space = NULL; + } else + git_buf_putc(&summary, *msg); + } + + commit->summary = git_buf_detach(&summary); + if (!commit->summary) + commit->summary = git__strdup(""); + } + + return commit->summary; +} + +int git_commit_tree(git_tree **tree_out, const git_commit *commit) +{ + assert(commit); + return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_id); +} + +const git_oid *git_commit_parent_id( + const git_commit *commit, unsigned int n) +{ + assert(commit); + + return git_array_get(commit->parent_ids, n); +} + +int git_commit_parent( + git_commit **parent, const git_commit *commit, unsigned int n) +{ + const git_oid *parent_id; + assert(commit); + + parent_id = git_commit_parent_id(commit, n); + if (parent_id == NULL) { + giterr_set(GITERR_INVALID, "Parent %u does not exist", n); + return GIT_ENOTFOUND; + } + + return git_commit_lookup(parent, commit->object.repo, parent_id); +} + +int git_commit_nth_gen_ancestor( + git_commit **ancestor, + const git_commit *commit, + unsigned int n) +{ + git_commit *current, *parent = NULL; + int error; + + assert(ancestor && commit); + + if (git_object_dup((git_object **) ¤t, (git_object *) commit) < 0) + return -1; + + if (n == 0) { + *ancestor = current; + return 0; + } + + while (n--) { + error = git_commit_parent(&parent, current, 0); + + git_commit_free(current); + + if (error < 0) + return error; + + current = parent; + } + + *ancestor = parent; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/commit.h b/deps/libgit2-sys-0.2.17/libgit2/src/commit.h new file mode 100644 index 000000000..efb080b50 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/commit.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_commit_h__ +#define INCLUDE_commit_h__ + +#include "git2/commit.h" +#include "tree.h" +#include "repository.h" +#include "array.h" + +#include + +struct git_commit { + git_object object; + + git_array_t(git_oid) parent_ids; + git_oid tree_id; + + git_signature *author; + git_signature *committer; + + char *message_encoding; + char *raw_message; + char *raw_header; + + char *summary; +}; + +void git_commit__free(void *commit); +int git_commit__parse(void *commit, git_odb_object *obj); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/commit_list.c b/deps/libgit2-sys-0.2.17/libgit2/src/commit_list.c new file mode 100644 index 000000000..3054c18dd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/commit_list.c @@ -0,0 +1,200 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "commit_list.h" +#include "common.h" +#include "revwalk.h" +#include "pool.h" +#include "odb.h" + +int git_commit_list_time_cmp(const void *a, const void *b) +{ + const git_commit_list_node *commit_a = a; + const git_commit_list_node *commit_b = b; + + return (commit_a->time < commit_b->time); +} + +git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p) +{ + git_commit_list *new_list = git__malloc(sizeof(git_commit_list)); + if (new_list != NULL) { + new_list->item = item; + new_list->next = *list_p; + } + *list_p = new_list; + return new_list; +} + +git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p) +{ + git_commit_list **pp = list_p; + git_commit_list *p; + + while ((p = *pp) != NULL) { + if (git_commit_list_time_cmp(p->item, item) > 0) + break; + + pp = &p->next; + } + + return git_commit_list_insert(item, pp); +} + +git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk) +{ + return (git_commit_list_node *)git_pool_malloc(&walk->commit_pool, COMMIT_ALLOC); +} + +static int commit_error(git_commit_list_node *commit, const char *msg) +{ + char commit_oid[GIT_OID_HEXSZ + 1]; + git_oid_fmt(commit_oid, &commit->oid); + commit_oid[GIT_OID_HEXSZ] = '\0'; + + giterr_set(GITERR_ODB, "Failed to parse commit %s - %s", commit_oid, msg); + + return -1; +} + +static git_commit_list_node **alloc_parents( + git_revwalk *walk, git_commit_list_node *commit, size_t n_parents) +{ + if (n_parents <= PARENTS_PER_COMMIT) + return (git_commit_list_node **)((char *)commit + sizeof(git_commit_list_node)); + + return (git_commit_list_node **)git_pool_malloc( + &walk->commit_pool, (uint32_t)(n_parents * sizeof(git_commit_list_node *))); +} + + +void git_commit_list_free(git_commit_list **list_p) +{ + git_commit_list *list = *list_p; + + if (list == NULL) + return; + + while (list) { + git_commit_list *temp = list; + list = temp->next; + git__free(temp); + } + + *list_p = NULL; +} + +git_commit_list_node *git_commit_list_pop(git_commit_list **stack) +{ + git_commit_list *top = *stack; + git_commit_list_node *item = top ? top->item : NULL; + + if (top) { + *stack = top->next; + git__free(top); + } + return item; +} + +static int commit_quick_parse( + git_revwalk *walk, + git_commit_list_node *commit, + const uint8_t *buffer, + size_t buffer_len) +{ + const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1; + const uint8_t *buffer_end = buffer + buffer_len; + const uint8_t *parents_start, *committer_start; + int i, parents = 0; + int commit_time; + + buffer += strlen("tree ") + GIT_OID_HEXSZ + 1; + + parents_start = buffer; + while (buffer + parent_len < buffer_end && memcmp(buffer, "parent ", strlen("parent ")) == 0) { + parents++; + buffer += parent_len; + } + + commit->parents = alloc_parents(walk, commit, parents); + GITERR_CHECK_ALLOC(commit->parents); + + buffer = parents_start; + for (i = 0; i < parents; ++i) { + git_oid oid; + + if (git_oid_fromstr(&oid, (const char *)buffer + strlen("parent ")) < 0) + return -1; + + commit->parents[i] = git_revwalk__commit_lookup(walk, &oid); + if (commit->parents[i] == NULL) + return -1; + + buffer += parent_len; + } + + commit->out_degree = (unsigned short)parents; + + if ((committer_start = buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL) + return commit_error(commit, "object is corrupted"); + + buffer++; + + if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL) + return commit_error(commit, "object is corrupted"); + + /* Skip trailing spaces */ + while (buffer > committer_start && git__isspace(*buffer)) + buffer--; + + /* Seek for the beginning of the pack of digits */ + while (buffer > committer_start && git__isdigit(*buffer)) + buffer--; + + /* Skip potential timezone offset */ + if ((buffer > committer_start) && (*buffer == '+' || *buffer == '-')) { + buffer--; + + while (buffer > committer_start && git__isspace(*buffer)) + buffer--; + + while (buffer > committer_start && git__isdigit(*buffer)) + buffer--; + } + + if ((buffer == committer_start) || (git__strtol32(&commit_time, (char *)(buffer + 1), NULL, 10) < 0)) + return commit_error(commit, "cannot parse commit time"); + + commit->time = (time_t)commit_time; + commit->parsed = 1; + return 0; +} + +int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit) +{ + git_odb_object *obj; + int error; + + if (commit->parsed) + return 0; + + if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0) + return error; + + if (obj->cached.type != GIT_OBJ_COMMIT) { + giterr_set(GITERR_INVALID, "Object is no commit object"); + error = -1; + } else + error = commit_quick_parse( + walk, commit, + (const uint8_t *)git_odb_object_data(obj), + git_odb_object_size(obj)); + + git_odb_object_free(obj); + return error; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/commit_list.h b/deps/libgit2-sys-0.2.17/libgit2/src/commit_list.h new file mode 100644 index 000000000..6b3f473d3 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/commit_list.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_commit_list_h__ +#define INCLUDE_commit_list_h__ + +#include "git2/oid.h" + +#define PARENT1 (1 << 0) +#define PARENT2 (1 << 1) +#define RESULT (1 << 2) +#define STALE (1 << 3) + +#define PARENTS_PER_COMMIT 2 +#define COMMIT_ALLOC \ + (sizeof(git_commit_list_node) + PARENTS_PER_COMMIT * sizeof(git_commit_list_node *)) + +#define FLAG_BITS 4 + +typedef struct git_commit_list_node { + git_oid oid; + uint32_t time; + unsigned int seen:1, + uninteresting:1, + topo_delay:1, + parsed:1, + flags : FLAG_BITS; + + unsigned short in_degree; + unsigned short out_degree; + + struct git_commit_list_node **parents; +} git_commit_list_node; + +typedef struct git_commit_list { + git_commit_list_node *item; + struct git_commit_list *next; +} git_commit_list; + +git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk); +int git_commit_list_time_cmp(const void *a, const void *b); +void git_commit_list_free(git_commit_list **list_p); +git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p); +git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p); +int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit); +git_commit_list_node *git_commit_list_pop(git_commit_list **stack); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/common.h b/deps/libgit2-sys-0.2.17/libgit2/src/common.h new file mode 100644 index 000000000..cdfc13657 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/common.h @@ -0,0 +1,205 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_common_h__ +#define INCLUDE_common_h__ + +#include "git2/common.h" +#include "cc-compat.h" + +/** Declare a function as always inlined. */ +#if defined(_MSC_VER) +# define GIT_INLINE(type) static __inline type +#else +# define GIT_INLINE(type) static inline type +#endif + +/** Support for gcc/clang __has_builtin intrinsic */ +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef GIT_WIN32 + +# include +# include +# include +# include +# include +# include "win32/msvc-compat.h" +# include "win32/mingw-compat.h" +# include "win32/error.h" +# include "win32/version.h" +# ifdef GIT_THREADS +# include "win32/pthread.h" +# endif + +#else + +# include +# include +# ifdef GIT_THREADS +# include +# include +# endif +#define GIT_STDLIB_CALL + +# include + +#endif + +#include "git2/types.h" +#include "git2/errors.h" +#include "thread-utils.h" +#include "integer.h" + +#include + +/** + * Check a pointer allocation result, returning -1 if it failed. + */ +#define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; } + +/** + * Check a return value and propagate result if non-zero. + */ +#define GITERR_CHECK_ERROR(code) \ + do { int _err = (code); if (_err) return _err; } while (0) + +/** + * Set the error message for this thread, formatting as needed. + */ +void giterr_set(int error_class, const char *string, ...); + +/** + * Set the error message for a regex failure, using the internal regex + * error code lookup and return a libgit error code. + */ +int giterr_set_regex(const regex_t *regex, int error_code); + +/** + * Set error message for user callback if needed. + * + * If the error code in non-zero and no error message is set, this + * sets a generic error message. + * + * @return This always returns the `error_code` parameter. + */ +GIT_INLINE(int) giterr_set_after_callback_function( + int error_code, const char *action) +{ + if (error_code) { + const git_error *e = giterr_last(); + if (!e || !e->message) + giterr_set(e ? e->klass : GITERR_CALLBACK, + "%s callback returned %d", action, error_code); + } + return error_code; +} + +#ifdef GIT_WIN32 +#define giterr_set_after_callback(code) \ + giterr_set_after_callback_function((code), __FUNCTION__) +#else +#define giterr_set_after_callback(code) \ + giterr_set_after_callback_function((code), __func__) +#endif + +/** + * Gets the system error code for this thread. + */ +int giterr_system_last(void); + +/** + * Sets the system error code for this thread. + */ +void giterr_system_set(int code); + +/** + * Structure to preserve libgit2 error state + */ +typedef struct { + int error_code; + git_error error_msg; +} git_error_state; + +/** + * Capture current error state to restore later, returning error code. + * If `error_code` is zero, this does nothing and returns zero. + */ +int giterr_capture(git_error_state *state, int error_code); + +/** + * Restore error state to a previous value, returning saved error code. + */ +int giterr_restore(git_error_state *state); + +/** + * Check a versioned structure for validity + */ +GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expected_max, const char *name) +{ + unsigned int actual; + + if (!structure) + return 0; + + actual = *(const unsigned int*)structure; + if (actual > 0 && actual <= expected_max) + return 0; + + giterr_set(GITERR_INVALID, "Invalid version %d on %s", actual, name); + return -1; +} +#define GITERR_CHECK_VERSION(S,V,N) if (giterr__check_version(S,V,N) < 0) return -1 + +/** + * Initialize a structure with a version. + */ +GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version) +{ + memset(structure, 0, len); + *((int*)structure) = version; +} +#define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V) + +#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \ + TYPE _tmpl = TPL; \ + GITERR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \ + memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0) + + +/** Check for additive overflow, setting an error if would occur. */ +#define GIT_ADD_SIZET_OVERFLOW(out, one, two) \ + (git__add_sizet_overflow(out, one, two) ? (giterr_set_oom(), 1) : 0) + +/** Check for additive overflow, setting an error if would occur. */ +#define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \ + (git__multiply_sizet_overflow(out, nelem, elsize) ? (giterr_set_oom(), 1) : 0) + +/** Check for additive overflow, failing if it would occur. */ +#define GITERR_CHECK_ALLOC_ADD(out, one, two) \ + if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; } + +/** Check for multiplicative overflow, failing if it would occur. */ +#define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \ + if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; } + +/* NOTE: other giterr functions are in the public errors.h header file */ + +#include "util.h" + +#endif /* INCLUDE_common_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/config.c b/deps/libgit2-sys-0.2.17/libgit2/src/config.c new file mode 100644 index 000000000..d116a9d80 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/config.c @@ -0,0 +1,1418 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "sysdir.h" +#include "config.h" +#include "git2/config.h" +#include "git2/sys/config.h" +#include "vector.h" +#include "buf_text.h" +#include "config_file.h" +#if GIT_WIN32 +# include +#endif + +#include + +void git_config_entry_free(git_config_entry *entry) +{ + if (!entry) + return; + + entry->free(entry); +} + +typedef struct { + git_refcount rc; + + git_config_backend *file; + git_config_level_t level; +} file_internal; + +static void file_internal_free(file_internal *internal) +{ + git_config_backend *file; + + file = internal->file; + file->free(file); + git__free(internal); +} + +static void config_free(git_config *cfg) +{ + size_t i; + file_internal *internal; + + for (i = 0; i < cfg->files.length; ++i) { + internal = git_vector_get(&cfg->files, i); + GIT_REFCOUNT_DEC(internal, file_internal_free); + } + + git_vector_free(&cfg->files); + + git__memzero(cfg, sizeof(*cfg)); + git__free(cfg); +} + +void git_config_free(git_config *cfg) +{ + if (cfg == NULL) + return; + + GIT_REFCOUNT_DEC(cfg, config_free); +} + +static int config_backend_cmp(const void *a, const void *b) +{ + const file_internal *bk_a = (const file_internal *)(a); + const file_internal *bk_b = (const file_internal *)(b); + + return bk_b->level - bk_a->level; +} + +int git_config_new(git_config **out) +{ + git_config *cfg; + + cfg = git__malloc(sizeof(git_config)); + GITERR_CHECK_ALLOC(cfg); + + memset(cfg, 0x0, sizeof(git_config)); + + if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) { + git__free(cfg); + return -1; + } + + *out = cfg; + GIT_REFCOUNT_INC(cfg); + return 0; +} + +int git_config_add_file_ondisk( + git_config *cfg, + const char *path, + git_config_level_t level, + int force) +{ + git_config_backend *file = NULL; + struct stat st; + int res; + + assert(cfg && path); + + res = p_stat(path, &st); + if (res < 0 && errno != ENOENT) { + giterr_set(GITERR_CONFIG, "Error stat'ing config file '%s'", path); + return -1; + } + + if (git_config_file__ondisk(&file, path) < 0) + return -1; + + if ((res = git_config_add_backend(cfg, file, level, force)) < 0) { + /* + * free manually; the file is not owned by the config + * instance yet and will not be freed on cleanup + */ + file->free(file); + return res; + } + + return 0; +} + +int git_config_open_ondisk(git_config **out, const char *path) +{ + int error; + git_config *config; + + *out = NULL; + + if (git_config_new(&config) < 0) + return -1; + + if ((error = git_config_add_file_ondisk(config, path, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0) + git_config_free(config); + else + *out = config; + + return error; +} + +int git_config_snapshot(git_config **out, git_config *in) +{ + int error = 0; + size_t i; + file_internal *internal; + git_config *config; + + *out = NULL; + + if (git_config_new(&config) < 0) + return -1; + + git_vector_foreach(&in->files, i, internal) { + git_config_backend *b; + + if ((error = internal->file->snapshot(&b, internal->file)) < 0) + break; + + if ((error = git_config_add_backend(config, b, internal->level, 0)) < 0) { + b->free(b); + break; + } + } + + if (error < 0) + git_config_free(config); + else + *out = config; + + return error; +} + +static int find_internal_file_by_level( + file_internal **internal_out, + const git_config *cfg, + git_config_level_t level) +{ + int pos = -1; + file_internal *internal; + size_t i; + + /* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config file + * which has the highest level. As config files are stored in a vector + * sorted by decreasing order of level, getting the file at position 0 + * will do the job. + */ + if (level == GIT_CONFIG_HIGHEST_LEVEL) { + pos = 0; + } else { + git_vector_foreach(&cfg->files, i, internal) { + if (internal->level == level) + pos = (int)i; + } + } + + if (pos == -1) { + giterr_set(GITERR_CONFIG, + "No config file exists for the given level '%i'", (int)level); + return GIT_ENOTFOUND; + } + + *internal_out = git_vector_get(&cfg->files, pos); + + return 0; +} + +static int duplicate_level(void **old_raw, void *new_raw) +{ + file_internal **old = (file_internal **)old_raw; + + GIT_UNUSED(new_raw); + + giterr_set(GITERR_CONFIG, "A file with the same level (%i) has already been added to the config", (int)(*old)->level); + return GIT_EEXISTS; +} + +static void try_remove_existing_file_internal( + git_config *cfg, + git_config_level_t level) +{ + int pos = -1; + file_internal *internal; + size_t i; + + git_vector_foreach(&cfg->files, i, internal) { + if (internal->level == level) + pos = (int)i; + } + + if (pos == -1) + return; + + internal = git_vector_get(&cfg->files, pos); + + if (git_vector_remove(&cfg->files, pos) < 0) + return; + + GIT_REFCOUNT_DEC(internal, file_internal_free); +} + +static int git_config__add_internal( + git_config *cfg, + file_internal *internal, + git_config_level_t level, + int force) +{ + int result; + + /* delete existing config file for level if it exists */ + if (force) + try_remove_existing_file_internal(cfg, level); + + if ((result = git_vector_insert_sorted(&cfg->files, + internal, &duplicate_level)) < 0) + return result; + + git_vector_sort(&cfg->files); + internal->file->cfg = cfg; + + GIT_REFCOUNT_INC(internal); + + return 0; +} + +int git_config_open_global(git_config **cfg_out, git_config *cfg) +{ + if (!git_config_open_level(cfg_out, cfg, GIT_CONFIG_LEVEL_XDG)) + return 0; + + return git_config_open_level(cfg_out, cfg, GIT_CONFIG_LEVEL_GLOBAL); +} + +int git_config_open_level( + git_config **cfg_out, + const git_config *cfg_parent, + git_config_level_t level) +{ + git_config *cfg; + file_internal *internal; + int res; + + if ((res = find_internal_file_by_level(&internal, cfg_parent, level)) < 0) + return res; + + if ((res = git_config_new(&cfg)) < 0) + return res; + + if ((res = git_config__add_internal(cfg, internal, level, true)) < 0) { + git_config_free(cfg); + return res; + } + + *cfg_out = cfg; + + return 0; +} + +int git_config_add_backend( + git_config *cfg, + git_config_backend *file, + git_config_level_t level, + int force) +{ + file_internal *internal; + int result; + + assert(cfg && file); + + GITERR_CHECK_VERSION(file, GIT_CONFIG_BACKEND_VERSION, "git_config_backend"); + + if ((result = file->open(file, level)) < 0) + return result; + + internal = git__malloc(sizeof(file_internal)); + GITERR_CHECK_ALLOC(internal); + + memset(internal, 0x0, sizeof(file_internal)); + + internal->file = file; + internal->level = level; + + if ((result = git_config__add_internal(cfg, internal, level, force)) < 0) { + git__free(internal); + return result; + } + + return 0; +} + +/* + * Loop over all the variables + */ + +typedef struct { + git_config_iterator parent; + git_config_iterator *current; + const git_config *cfg; + regex_t regex; + int has_regex; + size_t i; +} all_iter; + +static int find_next_backend(size_t *out, const git_config *cfg, size_t i) +{ + file_internal *internal; + + for (; i > 0; --i) { + internal = git_vector_get(&cfg->files, i - 1); + if (!internal || !internal->file) + continue; + + *out = i; + return 0; + } + + return -1; +} + +static int all_iter_next(git_config_entry **entry, git_config_iterator *_iter) +{ + all_iter *iter = (all_iter *) _iter; + file_internal *internal; + git_config_backend *backend; + size_t i; + int error = 0; + + if (iter->current != NULL && + (error = iter->current->next(entry, iter->current)) == 0) { + return 0; + } + + if (error < 0 && error != GIT_ITEROVER) + return error; + + do { + if (find_next_backend(&i, iter->cfg, iter->i) < 0) + return GIT_ITEROVER; + + internal = git_vector_get(&iter->cfg->files, i - 1); + backend = internal->file; + iter->i = i - 1; + + if (iter->current) + iter->current->free(iter->current); + + iter->current = NULL; + error = backend->iterator(&iter->current, backend); + if (error == GIT_ENOTFOUND) + continue; + + if (error < 0) + return error; + + error = iter->current->next(entry, iter->current); + /* If this backend is empty, then keep going */ + if (error == GIT_ITEROVER) + continue; + + return error; + + } while(1); + + return GIT_ITEROVER; +} + +static int all_iter_glob_next(git_config_entry **entry, git_config_iterator *_iter) +{ + int error; + all_iter *iter = (all_iter *) _iter; + + /* + * We use the "normal" function to grab the next one across + * backends and then apply the regex + */ + while ((error = all_iter_next(entry, _iter)) == 0) { + /* skip non-matching keys if regexp was provided */ + if (regexec(&iter->regex, (*entry)->name, 0, NULL, 0) != 0) + continue; + + /* and simply return if we like the entry's name */ + return 0; + } + + return error; +} + +static void all_iter_free(git_config_iterator *_iter) +{ + all_iter *iter = (all_iter *) _iter; + + if (iter->current) + iter->current->free(iter->current); + + git__free(iter); +} + +static void all_iter_glob_free(git_config_iterator *_iter) +{ + all_iter *iter = (all_iter *) _iter; + + regfree(&iter->regex); + all_iter_free(_iter); +} + +int git_config_iterator_new(git_config_iterator **out, const git_config *cfg) +{ + all_iter *iter; + + iter = git__calloc(1, sizeof(all_iter)); + GITERR_CHECK_ALLOC(iter); + + iter->parent.free = all_iter_free; + iter->parent.next = all_iter_next; + + iter->i = cfg->files.length; + iter->cfg = cfg; + + *out = (git_config_iterator *) iter; + + return 0; +} + +int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp) +{ + all_iter *iter; + int result; + + if (regexp == NULL) + return git_config_iterator_new(out, cfg); + + iter = git__calloc(1, sizeof(all_iter)); + GITERR_CHECK_ALLOC(iter); + + if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) < 0) { + giterr_set_regex(&iter->regex, result); + regfree(&iter->regex); + git__free(iter); + return -1; + } + + iter->parent.next = all_iter_glob_next; + iter->parent.free = all_iter_glob_free; + iter->i = cfg->files.length; + iter->cfg = cfg; + + *out = (git_config_iterator *) iter; + + return 0; +} + +int git_config_foreach( + const git_config *cfg, git_config_foreach_cb cb, void *payload) +{ + return git_config_foreach_match(cfg, NULL, cb, payload); +} + +int git_config_backend_foreach_match( + git_config_backend *backend, + const char *regexp, + git_config_foreach_cb cb, + void *payload) +{ + git_config_entry *entry; + git_config_iterator* iter; + regex_t regex; + int error = 0; + + if (regexp != NULL) { + if ((error = regcomp(®ex, regexp, REG_EXTENDED)) < 0) { + giterr_set_regex(®ex, error); + regfree(®ex); + return -1; + } + } + + if ((error = backend->iterator(&iter, backend)) < 0) { + iter = NULL; + return -1; + } + + while (!(iter->next(&entry, iter) < 0)) { + /* skip non-matching keys if regexp was provided */ + if (regexp && regexec(®ex, entry->name, 0, NULL, 0) != 0) + continue; + + /* abort iterator on non-zero return value */ + if ((error = cb(entry, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + if (regexp != NULL) + regfree(®ex); + + iter->free(iter); + + return error; +} + +int git_config_foreach_match( + const git_config *cfg, + const char *regexp, + git_config_foreach_cb cb, + void *payload) +{ + int error; + git_config_iterator *iter; + git_config_entry *entry; + + if ((error = git_config_iterator_glob_new(&iter, cfg, regexp)) < 0) + return error; + + while (!(error = git_config_next(&entry, iter))) { + if ((error = cb(entry, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + git_config_iterator_free(iter); + + if (error == GIT_ITEROVER) + error = 0; + + return error; +} + +/************** + * Setters + **************/ + +static int config_error_nofiles(const char *name) +{ + giterr_set(GITERR_CONFIG, + "Cannot set value for '%s' when no config files exist", name); + return GIT_ENOTFOUND; +} + +int git_config_delete_entry(git_config *cfg, const char *name) +{ + git_config_backend *file; + file_internal *internal; + + internal = git_vector_get(&cfg->files, 0); + if (!internal || !internal->file) + return config_error_nofiles(name); + file = internal->file; + + return file->del(file, name); +} + +int git_config_set_int64(git_config *cfg, const char *name, int64_t value) +{ + char str_value[32]; /* All numbers should fit in here */ + p_snprintf(str_value, sizeof(str_value), "%" PRId64, value); + return git_config_set_string(cfg, name, str_value); +} + +int git_config_set_int32(git_config *cfg, const char *name, int32_t value) +{ + return git_config_set_int64(cfg, name, (int64_t)value); +} + +int git_config_set_bool(git_config *cfg, const char *name, int value) +{ + return git_config_set_string(cfg, name, value ? "true" : "false"); +} + +int git_config_set_string(git_config *cfg, const char *name, const char *value) +{ + int error; + git_config_backend *file; + file_internal *internal; + + if (!value) { + giterr_set(GITERR_CONFIG, "The value to set cannot be NULL"); + return -1; + } + + internal = git_vector_get(&cfg->files, 0); + if (!internal || !internal->file) + return config_error_nofiles(name); + file = internal->file; + + error = file->set(file, name, value); + + if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL) + git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg)); + + return error; +} + +int git_config__update_entry( + git_config *config, + const char *key, + const char *value, + bool overwrite_existing, + bool only_if_existing) +{ + int error = 0; + git_config_entry *ce = NULL; + + if ((error = git_config__lookup_entry(&ce, config, key, false)) < 0) + return error; + + if (!ce && only_if_existing) /* entry doesn't exist */ + return 0; + if (ce && !overwrite_existing) /* entry would be overwritten */ + return 0; + if (value && ce && ce->value && !strcmp(ce->value, value)) /* no change */ + return 0; + if (!value && (!ce || !ce->value)) /* asked to delete absent entry */ + return 0; + + if (!value) + error = git_config_delete_entry(config, key); + else + error = git_config_set_string(config, key, value); + + git_config_entry_free(ce); + return error; +} + +/*********** + * Getters + ***********/ + +static int config_error_notfound(const char *name) +{ + giterr_set(GITERR_CONFIG, "Config value '%s' was not found", name); + return GIT_ENOTFOUND; +} + +enum { + GET_ALL_ERRORS = 0, + GET_NO_MISSING = 1, + GET_NO_ERRORS = 2 +}; + +static int get_entry( + git_config_entry **out, + const git_config *cfg, + const char *name, + bool normalize_name, + int want_errors) +{ + int res = GIT_ENOTFOUND; + const char *key = name; + char *normalized = NULL; + size_t i; + file_internal *internal; + + *out = NULL; + + if (normalize_name) { + if ((res = git_config__normalize_name(name, &normalized)) < 0) + goto cleanup; + key = normalized; + } + + res = GIT_ENOTFOUND; + git_vector_foreach(&cfg->files, i, internal) { + if (!internal || !internal->file) + continue; + + res = internal->file->get(internal->file, key, out); + if (res != GIT_ENOTFOUND) + break; + } + + git__free(normalized); + +cleanup: + if (res == GIT_ENOTFOUND) + res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name); + else if (res && (want_errors == GET_NO_ERRORS)) { + giterr_clear(); + res = 0; + } + + return res; +} + +int git_config_get_entry( + git_config_entry **out, const git_config *cfg, const char *name) +{ + return get_entry(out, cfg, name, true, GET_ALL_ERRORS); +} + +int git_config__lookup_entry( + git_config_entry **out, + const git_config *cfg, + const char *key, + bool no_errors) +{ + return get_entry( + out, cfg, key, false, no_errors ? GET_NO_ERRORS : GET_NO_MISSING); +} + +int git_config_get_mapped( + int *out, + const git_config *cfg, + const char *name, + const git_cvar_map *maps, + size_t map_n) +{ + git_config_entry *entry; + int ret; + + if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) + return ret; + + ret = git_config_lookup_map_value(out, maps, map_n, entry->value); + git_config_entry_free(entry); + + return ret; +} + +int git_config_get_int64(int64_t *out, const git_config *cfg, const char *name) +{ + git_config_entry *entry; + int ret; + + if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) + return ret; + + ret = git_config_parse_int64(out, entry->value); + git_config_entry_free(entry); + + return ret; +} + +int git_config_get_int32(int32_t *out, const git_config *cfg, const char *name) +{ + git_config_entry *entry; + int ret; + + if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) + return ret; + + ret = git_config_parse_int32(out, entry->value); + git_config_entry_free(entry); + + return ret; +} + +int git_config_get_bool(int *out, const git_config *cfg, const char *name) +{ + git_config_entry *entry; + int ret; + + if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) + return ret; + + ret = git_config_parse_bool(out, entry->value); + git_config_entry_free(entry); + + return ret; +} + +static int is_readonly(const git_config *cfg) +{ + size_t i; + file_internal *internal; + + git_vector_foreach(&cfg->files, i, internal) { + if (!internal || !internal->file) + continue; + + if (!internal->file->readonly) + return 0; + } + + return 1; +} + +int git_config_get_path(git_buf *out, const git_config *cfg, const char *name) +{ + git_config_entry *entry; + int error; + + if ((error = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) + return error; + + error = git_config_parse_path(out, entry->value); + git_config_entry_free(entry); + + return error; +} + +int git_config_get_string( + const char **out, const git_config *cfg, const char *name) +{ + git_config_entry *entry; + int ret; + + if (!is_readonly(cfg)) { + giterr_set(GITERR_CONFIG, "get_string called on a live config object"); + return -1; + } + + ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS); + *out = !ret ? (entry->value ? entry->value : "") : NULL; + + git_config_entry_free(entry); + + return ret; +} + +int git_config_get_string_buf( + git_buf *out, const git_config *cfg, const char *name) +{ + git_config_entry *entry; + int ret; + const char *str; + + git_buf_sanitize(out); + + ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS); + str = !ret ? (entry->value ? entry->value : "") : NULL; + + if (str) + ret = git_buf_puts(out, str); + + git_config_entry_free(entry); + + return ret; +} + +char *git_config__get_string_force( + const git_config *cfg, const char *key, const char *fallback_value) +{ + git_config_entry *entry; + char *ret; + + get_entry(&entry, cfg, key, false, GET_NO_ERRORS); + ret = (entry && entry->value) ? git__strdup(entry->value) : fallback_value ? git__strdup(fallback_value) : NULL; + git_config_entry_free(entry); + + return ret; +} + +int git_config__get_bool_force( + const git_config *cfg, const char *key, int fallback_value) +{ + int val = fallback_value; + git_config_entry *entry; + + get_entry(&entry, cfg, key, false, GET_NO_ERRORS); + + if (entry && git_config_parse_bool(&val, entry->value) < 0) + giterr_clear(); + + git_config_entry_free(entry); + return val; +} + +int git_config__get_int_force( + const git_config *cfg, const char *key, int fallback_value) +{ + int32_t val = (int32_t)fallback_value; + git_config_entry *entry; + + get_entry(&entry, cfg, key, false, GET_NO_ERRORS); + + if (entry && git_config_parse_int32(&val, entry->value) < 0) + giterr_clear(); + + git_config_entry_free(entry); + return (int)val; +} + +int git_config_get_multivar_foreach( + const git_config *cfg, const char *name, const char *regexp, + git_config_foreach_cb cb, void *payload) +{ + int err, found; + git_config_iterator *iter; + git_config_entry *entry; + + if ((err = git_config_multivar_iterator_new(&iter, cfg, name, regexp)) < 0) + return err; + + found = 0; + while ((err = iter->next(&entry, iter)) == 0) { + found = 1; + + if ((err = cb(entry, payload)) != 0) { + giterr_set_after_callback(err); + break; + } + } + + iter->free(iter); + if (err == GIT_ITEROVER) + err = 0; + + if (found == 0 && err == 0) + err = config_error_notfound(name); + + return err; +} + +typedef struct { + git_config_iterator parent; + git_config_iterator *iter; + char *name; + regex_t regex; + int have_regex; +} multivar_iter; + +static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_iter) +{ + multivar_iter *iter = (multivar_iter *) _iter; + int error = 0; + + while ((error = iter->iter->next(entry, iter->iter)) == 0) { + if (git__strcmp(iter->name, (*entry)->name)) + continue; + + if (!iter->have_regex) + return 0; + + if (regexec(&iter->regex, (*entry)->value, 0, NULL, 0) == 0) + return 0; + } + + return error; +} + +void multivar_iter_free(git_config_iterator *_iter) +{ + multivar_iter *iter = (multivar_iter *) _iter; + + iter->iter->free(iter->iter); + + git__free(iter->name); + regfree(&iter->regex); + git__free(iter); +} + +int git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp) +{ + multivar_iter *iter = NULL; + git_config_iterator *inner = NULL; + int error; + + if ((error = git_config_iterator_new(&inner, cfg)) < 0) + return error; + + iter = git__calloc(1, sizeof(multivar_iter)); + GITERR_CHECK_ALLOC(iter); + + if ((error = git_config__normalize_name(name, &iter->name)) < 0) + goto on_error; + + if (regexp != NULL) { + error = regcomp(&iter->regex, regexp, REG_EXTENDED); + if (error < 0) { + giterr_set_regex(&iter->regex, error); + error = -1; + regfree(&iter->regex); + goto on_error; + } + + iter->have_regex = 1; + } + + iter->iter = inner; + iter->parent.free = multivar_iter_free; + iter->parent.next = multivar_iter_next; + + *out = (git_config_iterator *) iter; + + return 0; + +on_error: + + inner->free(inner); + git__free(iter); + return error; +} + +int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value) +{ + git_config_backend *file; + file_internal *internal; + + internal = git_vector_get(&cfg->files, 0); + if (!internal || !internal->file) + return config_error_nofiles(name); + file = internal->file; + + return file->set_multivar(file, name, regexp, value); +} + +int git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp) +{ + git_config_backend *file; + file_internal *internal; + + internal = git_vector_get(&cfg->files, 0); + if (!internal || !internal->file) + return config_error_nofiles(name); + file = internal->file; + + return file->del_multivar(file, name, regexp); +} + +int git_config_next(git_config_entry **entry, git_config_iterator *iter) +{ + return iter->next(entry, iter); +} + +void git_config_iterator_free(git_config_iterator *iter) +{ + if (iter == NULL) + return; + + iter->free(iter); +} + +int git_config_find_global(git_buf *path) +{ + git_buf_sanitize(path); + return git_sysdir_find_global_file(path, GIT_CONFIG_FILENAME_GLOBAL); +} + +int git_config_find_xdg(git_buf *path) +{ + git_buf_sanitize(path); + return git_sysdir_find_xdg_file(path, GIT_CONFIG_FILENAME_XDG); +} + +int git_config_find_system(git_buf *path) +{ + git_buf_sanitize(path); + return git_sysdir_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM); +} + +int git_config__global_location(git_buf *buf) +{ + const git_buf *paths; + const char *sep, *start; + + if (git_sysdir_get(&paths, GIT_SYSDIR_GLOBAL) < 0) + return -1; + + /* no paths, so give up */ + if (!paths || !git_buf_len(paths)) + return -1; + + /* find unescaped separator or end of string */ + for (sep = start = git_buf_cstr(paths); *sep; ++sep) { + if (*sep == GIT_PATH_LIST_SEPARATOR && + (sep <= start || sep[-1] != '\\')) + break; + } + + if (git_buf_set(buf, start, (size_t)(sep - start)) < 0) + return -1; + + return git_buf_joinpath(buf, buf->ptr, GIT_CONFIG_FILENAME_GLOBAL); +} + +int git_config_open_default(git_config **out) +{ + int error; + git_config *cfg = NULL; + git_buf buf = GIT_BUF_INIT; + + if ((error = git_config_new(&cfg)) < 0) + return error; + + if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) { + error = git_config_add_file_ondisk(cfg, buf.ptr, + GIT_CONFIG_LEVEL_GLOBAL, 0); + } + + if (!error && !git_config_find_xdg(&buf)) + error = git_config_add_file_ondisk(cfg, buf.ptr, + GIT_CONFIG_LEVEL_XDG, 0); + + if (!error && !git_config_find_system(&buf)) + error = git_config_add_file_ondisk(cfg, buf.ptr, + GIT_CONFIG_LEVEL_SYSTEM, 0); + + git_buf_free(&buf); + + if (error) { + git_config_free(cfg); + cfg = NULL; + } + + *out = cfg; + + return error; +} + +/*********** + * Parsers + ***********/ + +int git_config_lookup_map_value( + int *out, + const git_cvar_map *maps, + size_t map_n, + const char *value) +{ + size_t i; + + if (!value) + goto fail_parse; + + for (i = 0; i < map_n; ++i) { + const git_cvar_map *m = maps + i; + + switch (m->cvar_type) { + case GIT_CVAR_FALSE: + case GIT_CVAR_TRUE: { + int bool_val; + + if (git__parse_bool(&bool_val, value) == 0 && + bool_val == (int)m->cvar_type) { + *out = m->map_value; + return 0; + } + break; + } + + case GIT_CVAR_INT32: + if (git_config_parse_int32(out, value) == 0) + return 0; + break; + + case GIT_CVAR_STRING: + if (strcasecmp(value, m->str_match) == 0) { + *out = m->map_value; + return 0; + } + break; + } + } + +fail_parse: + giterr_set(GITERR_CONFIG, "Failed to map '%s'", value); + return -1; +} + +int git_config_parse_bool(int *out, const char *value) +{ + if (git__parse_bool(out, value) == 0) + return 0; + + if (git_config_parse_int32(out, value) == 0) { + *out = !!(*out); + return 0; + } + + giterr_set(GITERR_CONFIG, "Failed to parse '%s' as a boolean value", value); + return -1; +} + +int git_config_parse_int64(int64_t *out, const char *value) +{ + const char *num_end; + int64_t num; + + if (!value || git__strtol64(&num, value, &num_end, 0) < 0) + goto fail_parse; + + switch (*num_end) { + case 'g': + case 'G': + num *= 1024; + /* fallthrough */ + + case 'm': + case 'M': + num *= 1024; + /* fallthrough */ + + case 'k': + case 'K': + num *= 1024; + + /* check that that there are no more characters after the + * given modifier suffix */ + if (num_end[1] != '\0') + return -1; + + /* fallthrough */ + + case '\0': + *out = num; + return 0; + + default: + goto fail_parse; + } + +fail_parse: + giterr_set(GITERR_CONFIG, "Failed to parse '%s' as an integer", value ? value : "(null)"); + return -1; +} + +int git_config_parse_int32(int32_t *out, const char *value) +{ + int64_t tmp; + int32_t truncate; + + if (git_config_parse_int64(&tmp, value) < 0) + goto fail_parse; + + truncate = tmp & 0xFFFFFFFF; + if (truncate != tmp) + goto fail_parse; + + *out = truncate; + return 0; + +fail_parse: + giterr_set(GITERR_CONFIG, "Failed to parse '%s' as a 32-bit integer", value ? value : "(null)"); + return -1; +} + +int git_config_parse_path(git_buf *out, const char *value) +{ + int error = 0; + const git_buf *home; + + assert(out && value); + + git_buf_sanitize(out); + + if (value[0] == '~') { + if (value[1] != '\0' && value[1] != '/') { + giterr_set(GITERR_CONFIG, "retrieving a homedir by name is not supported"); + return -1; + } + + if ((error = git_sysdir_get(&home, GIT_SYSDIR_GLOBAL)) < 0) + return error; + + git_buf_sets(out, home->ptr); + git_buf_puts(out, value + 1); + + if (git_buf_oom(out)) + return -1; + + return 0; + } + + return git_buf_sets(out, value); +} + +/* Take something the user gave us and make it nice for our hash function */ +int git_config__normalize_name(const char *in, char **out) +{ + char *name, *fdot, *ldot; + + assert(in && out); + + name = git__strdup(in); + GITERR_CHECK_ALLOC(name); + + fdot = strchr(name, '.'); + ldot = strrchr(name, '.'); + + if (fdot == NULL || fdot == name || ldot == NULL || !ldot[1]) + goto invalid; + + /* Validate and downcase up to first dot and after last dot */ + if (git_config_file_normalize_section(name, fdot) < 0 || + git_config_file_normalize_section(ldot + 1, NULL) < 0) + goto invalid; + + /* If there is a middle range, make sure it doesn't have newlines */ + while (fdot < ldot) + if (*fdot++ == '\n') + goto invalid; + + *out = name; + return 0; + +invalid: + git__free(name); + giterr_set(GITERR_CONFIG, "Invalid config item name '%s'", in); + return GIT_EINVALIDSPEC; +} + +struct rename_data { + git_config *config; + git_buf *name; + size_t old_len; +}; + +static int rename_config_entries_cb( + const git_config_entry *entry, + void *payload) +{ + int error = 0; + struct rename_data *data = (struct rename_data *)payload; + size_t base_len = git_buf_len(data->name); + + if (base_len > 0 && + !(error = git_buf_puts(data->name, entry->name + data->old_len))) + { + error = git_config_set_string( + data->config, git_buf_cstr(data->name), entry->value); + + git_buf_truncate(data->name, base_len); + } + + if (!error) + error = git_config_delete_entry(data->config, entry->name); + + return error; +} + +int git_config_rename_section( + git_repository *repo, + const char *old_section_name, + const char *new_section_name) +{ + git_config *config; + git_buf pattern = GIT_BUF_INIT, replace = GIT_BUF_INIT; + int error = 0; + struct rename_data data; + + git_buf_text_puts_escape_regex(&pattern, old_section_name); + + if ((error = git_buf_puts(&pattern, "\\..+")) < 0) + goto cleanup; + + if ((error = git_repository_config__weakptr(&config, repo)) < 0) + goto cleanup; + + data.config = config; + data.name = &replace; + data.old_len = strlen(old_section_name) + 1; + + if ((error = git_buf_join(&replace, '.', new_section_name, "")) < 0) + goto cleanup; + + if (new_section_name != NULL && + (error = git_config_file_normalize_section( + replace.ptr, strchr(replace.ptr, '.'))) < 0) + { + giterr_set( + GITERR_CONFIG, "Invalid config section '%s'", new_section_name); + goto cleanup; + } + + error = git_config_foreach_match( + config, git_buf_cstr(&pattern), rename_config_entries_cb, &data); + +cleanup: + git_buf_free(&pattern); + git_buf_free(&replace); + + return error; +} + +int git_config_init_backend(git_config_backend *backend, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + backend, version, git_config_backend, GIT_CONFIG_BACKEND_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/config.h b/deps/libgit2-sys-0.2.17/libgit2/src/config.h new file mode 100644 index 000000000..691868b1d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/config.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_config_h__ +#define INCLUDE_config_h__ + +#include "git2.h" +#include "git2/config.h" +#include "vector.h" +#include "repository.h" + +#define GIT_CONFIG_FILENAME_SYSTEM "gitconfig" +#define GIT_CONFIG_FILENAME_GLOBAL ".gitconfig" +#define GIT_CONFIG_FILENAME_XDG "config" + +#define GIT_CONFIG_FILENAME_INREPO "config" +#define GIT_CONFIG_FILE_MODE 0666 + +struct git_config { + git_refcount rc; + git_vector files; +}; + +extern int git_config__global_location(git_buf *buf); + +extern int git_config_rename_section( + git_repository *repo, + const char *old_section_name, /* eg "branch.dummy" */ + const char *new_section_name); /* NULL to drop the old section */ + +/** + * Create a configuration file backend for ondisk files + * + * These are the normal `.gitconfig` files that Core Git + * processes. Note that you first have to add this file to a + * configuration object before you can query it for configuration + * variables. + * + * @param out the new backend + * @param path where the config file is located + */ +extern int git_config_file__ondisk(git_config_backend **out, const char *path); + +extern int git_config__normalize_name(const char *in, char **out); + +/* internal only: does not normalize key and sets out to NULL if not found */ +extern int git_config__lookup_entry( + git_config_entry **out, + const git_config *cfg, + const char *key, + bool no_errors); + +/* internal only: update and/or delete entry string with constraints */ +extern int git_config__update_entry( + git_config *cfg, + const char *key, + const char *value, + bool overwrite_existing, + bool only_if_existing); + +/* + * Lookup functions that cannot fail. These functions look up a config + * value and return a fallback value if the value is missing or if any + * failures occur while trying to access the value. + */ + +extern char *git_config__get_string_force( + const git_config *cfg, const char *key, const char *fallback_value); + +extern int git_config__get_bool_force( + const git_config *cfg, const char *key, int fallback_value); + +extern int git_config__get_int_force( + const git_config *cfg, const char *key, int fallback_value); + +/* API for repository cvar-style lookups from config - not cached, but + * uses cvar value maps and fallbacks + */ +extern int git_config__cvar( + int *out, git_config *config, git_cvar_cached cvar); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/config_cache.c b/deps/libgit2-sys-0.2.17/libgit2/src/config_cache.c new file mode 100644 index 000000000..c859ec148 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/config_cache.c @@ -0,0 +1,128 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "fileops.h" +#include "repository.h" +#include "config.h" +#include "git2/config.h" +#include "vector.h" +#include "filter.h" + +struct map_data { + const char *cvar_name; + git_cvar_map *maps; + size_t map_count; + int default_value; +}; + +/* + * core.eol + * Sets the line ending type to use in the working directory for + * files that have the text property set. Alternatives are lf, crlf + * and native, which uses the platform's native line ending. The default + * value is native. See gitattributes(5) for more information on + * end-of-line conversion. + */ +static git_cvar_map _cvar_map_eol[] = { + {GIT_CVAR_FALSE, NULL, GIT_EOL_UNSET}, + {GIT_CVAR_STRING, "lf", GIT_EOL_LF}, + {GIT_CVAR_STRING, "crlf", GIT_EOL_CRLF}, + {GIT_CVAR_STRING, "native", GIT_EOL_NATIVE} +}; + +/* + * core.autocrlf + * Setting this variable to "true" is almost the same as setting + * the text attribute to "auto" on all files except that text files are + * not guaranteed to be normalized: files that contain CRLF in the + * repository will not be touched. Use this setting if you want to have + * CRLF line endings in your working directory even though the repository + * does not have normalized line endings. This variable can be set to input, + * in which case no output conversion is performed. + */ +static git_cvar_map _cvar_map_autocrlf[] = { + {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, + {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, + {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT} +}; + +static git_cvar_map _cvar_map_safecrlf[] = { + {GIT_CVAR_FALSE, NULL, GIT_SAFE_CRLF_FALSE}, + {GIT_CVAR_TRUE, NULL, GIT_SAFE_CRLF_FAIL}, + {GIT_CVAR_STRING, "warn", GIT_SAFE_CRLF_WARN} +}; + +/* + * Generic map for integer values + */ +static git_cvar_map _cvar_map_int[] = { + {GIT_CVAR_INT32, NULL, 0}, +}; + +static struct map_data _cvar_maps[] = { + {"core.autocrlf", _cvar_map_autocrlf, ARRAY_SIZE(_cvar_map_autocrlf), GIT_AUTO_CRLF_DEFAULT}, + {"core.eol", _cvar_map_eol, ARRAY_SIZE(_cvar_map_eol), GIT_EOL_DEFAULT}, + {"core.symlinks", NULL, 0, GIT_SYMLINKS_DEFAULT }, + {"core.ignorecase", NULL, 0, GIT_IGNORECASE_DEFAULT }, + {"core.filemode", NULL, 0, GIT_FILEMODE_DEFAULT }, + {"core.ignorestat", NULL, 0, GIT_IGNORESTAT_DEFAULT }, + {"core.trustctime", NULL, 0, GIT_TRUSTCTIME_DEFAULT }, + {"core.abbrev", _cvar_map_int, 1, GIT_ABBREV_DEFAULT }, + {"core.precomposeunicode", NULL, 0, GIT_PRECOMPOSE_DEFAULT }, + {"core.safecrlf", _cvar_map_safecrlf, ARRAY_SIZE(_cvar_map_safecrlf), GIT_SAFE_CRLF_DEFAULT}, + {"core.logallrefupdates", NULL, 0, GIT_LOGALLREFUPDATES_DEFAULT }, + {"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT }, + {"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_DEFAULT }, +}; + +int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar) +{ + int error = 0; + struct map_data *data = &_cvar_maps[(int)cvar]; + git_config_entry *entry; + + git_config__lookup_entry(&entry, config, data->cvar_name, false); + + if (!entry) + *out = data->default_value; + else if (data->maps) + error = git_config_lookup_map_value( + out, data->maps, data->map_count, entry->value); + else + error = git_config_parse_bool(out, entry->value); + + git_config_entry_free(entry); + return error; +} + +int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar) +{ + *out = repo->cvar_cache[(int)cvar]; + + if (*out == GIT_CVAR_NOT_CACHED) { + int error; + git_config *config; + + if ((error = git_repository_config__weakptr(&config, repo)) < 0 || + (error = git_config__cvar(out, config, cvar)) < 0) + return error; + + repo->cvar_cache[(int)cvar] = *out; + } + + return 0; +} + +void git_repository__cvar_cache_clear(git_repository *repo) +{ + int i; + + for (i = 0; i < GIT_CVAR_CACHE_MAX; ++i) + repo->cvar_cache[i] = GIT_CVAR_NOT_CACHED; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/config_file.c b/deps/libgit2-sys-0.2.17/libgit2/src/config_file.c new file mode 100644 index 000000000..732705687 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/config_file.c @@ -0,0 +1,1792 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "config.h" +#include "filebuf.h" +#include "sysdir.h" +#include "buffer.h" +#include "buf_text.h" +#include "git2/config.h" +#include "git2/sys/config.h" +#include "git2/types.h" +#include "strmap.h" +#include "array.h" + +#include +#include +#include + +GIT__USE_STRMAP + +typedef struct cvar_t { + struct cvar_t *next; + git_config_entry *entry; + bool included; /* whether this is part of [include] */ +} cvar_t; + +typedef struct git_config_file_iter { + git_config_iterator parent; + git_strmap_iter iter; + cvar_t* next_var; +} git_config_file_iter; + +/* Max depth for [include] directives */ +#define MAX_INCLUDE_DEPTH 10 + +#define CVAR_LIST_HEAD(list) ((list)->head) + +#define CVAR_LIST_TAIL(list) ((list)->tail) + +#define CVAR_LIST_NEXT(var) ((var)->next) + +#define CVAR_LIST_EMPTY(list) ((list)->head == NULL) + +#define CVAR_LIST_APPEND(list, var) do {\ + if (CVAR_LIST_EMPTY(list)) {\ + CVAR_LIST_HEAD(list) = CVAR_LIST_TAIL(list) = var;\ + } else {\ + CVAR_LIST_NEXT(CVAR_LIST_TAIL(list)) = var;\ + CVAR_LIST_TAIL(list) = var;\ + }\ +} while(0) + +#define CVAR_LIST_REMOVE_HEAD(list) do {\ + CVAR_LIST_HEAD(list) = CVAR_LIST_NEXT(CVAR_LIST_HEAD(list));\ +} while(0) + +#define CVAR_LIST_REMOVE_AFTER(var) do {\ + CVAR_LIST_NEXT(var) = CVAR_LIST_NEXT(CVAR_LIST_NEXT(var));\ +} while(0) + +#define CVAR_LIST_FOREACH(list, iter)\ + for ((iter) = CVAR_LIST_HEAD(list);\ + (iter) != NULL;\ + (iter) = CVAR_LIST_NEXT(iter)) + +/* + * Inspired by the FreeBSD functions + */ +#define CVAR_LIST_FOREACH_SAFE(start, iter, tmp)\ + for ((iter) = CVAR_LIST_HEAD(vars);\ + (iter) && (((tmp) = CVAR_LIST_NEXT(iter) || 1));\ + (iter) = (tmp)) + +struct reader { + time_t file_mtime; + size_t file_size; + char *file_path; + git_buf buffer; + char *read_ptr; + int line_number; + int eof; +}; + +typedef struct { + git_atomic refcount; + git_strmap *values; +} refcounted_strmap; + +typedef struct { + git_config_backend parent; + /* mutex to coordinate accessing the values */ + git_mutex values_mutex; + refcounted_strmap *values; +} diskfile_header; + +typedef struct { + diskfile_header header; + + git_config_level_t level; + + git_array_t(struct reader) readers; + + char *file_path; +} diskfile_backend; + +typedef struct { + diskfile_header header; + + diskfile_backend *snapshot_from; +} diskfile_readonly_backend; + +static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct reader *reader, git_config_level_t level, int depth); +static int parse_variable(struct reader *reader, char **var_name, char **var_value); +static int config_write(diskfile_backend *cfg, const char *key, const regex_t *preg, const char *value); +static char *escape_value(const char *ptr); + +int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in); +static int config_snapshot(git_config_backend **out, git_config_backend *in); + +static void set_parse_error(struct reader *reader, int col, const char *error_str) +{ + giterr_set(GITERR_CONFIG, "Failed to parse config file: %s (in %s:%d, column %d)", + error_str, reader->file_path, reader->line_number, col); +} + +static int config_error_readonly(void) +{ + giterr_set(GITERR_CONFIG, "this backend is read-only"); + return -1; +} + +static void cvar_free(cvar_t *var) +{ + if (var == NULL) + return; + + git__free((char*)var->entry->name); + git__free((char *)var->entry->value); + git__free(var->entry); + git__free(var); +} + +int git_config_file_normalize_section(char *start, char *end) +{ + char *scan; + + if (start == end) + return GIT_EINVALIDSPEC; + + /* Validate and downcase range */ + for (scan = start; *scan; ++scan) { + if (end && scan >= end) + break; + if (isalnum(*scan)) + *scan = (char)tolower(*scan); + else if (*scan != '-' || scan == start) + return GIT_EINVALIDSPEC; + } + + if (scan == start) + return GIT_EINVALIDSPEC; + + return 0; +} + +/* Add or append the new config option */ +static int append_entry(git_strmap *values, cvar_t *var) +{ + git_strmap_iter pos; + cvar_t *existing; + int error = 0; + + pos = git_strmap_lookup_index(values, var->entry->name); + if (!git_strmap_valid_index(values, pos)) { + git_strmap_insert(values, var->entry->name, var, error); + } else { + existing = git_strmap_value_at(values, pos); + while (existing->next != NULL) { + existing = existing->next; + } + existing->next = var; + } + + if (error > 0) + error = 0; + + return error; +} + +static void free_vars(git_strmap *values) +{ + cvar_t *var = NULL; + + if (values == NULL) + return; + + git_strmap_foreach_value(values, var, + while (var != NULL) { + cvar_t *next = CVAR_LIST_NEXT(var); + cvar_free(var); + var = next; + }); + + git_strmap_free(values); +} + +static void refcounted_strmap_free(refcounted_strmap *map) +{ + if (!map) + return; + + if (git_atomic_dec(&map->refcount) != 0) + return; + + free_vars(map->values); + git__free(map); +} + +/** + * Take the current values map from the backend and increase its + * refcount. This is its own function to make sure we use the mutex to + * avoid the map pointer from changing under us. + */ +static refcounted_strmap *refcounted_strmap_take(diskfile_header *h) +{ + refcounted_strmap *map; + + git_mutex_lock(&h->values_mutex); + + map = h->values; + git_atomic_inc(&map->refcount); + + git_mutex_unlock(&h->values_mutex); + + return map; +} + +static int refcounted_strmap_alloc(refcounted_strmap **out) +{ + refcounted_strmap *map; + int error; + + map = git__calloc(1, sizeof(refcounted_strmap)); + GITERR_CHECK_ALLOC(map); + + git_atomic_set(&map->refcount, 1); + + if ((error = git_strmap_alloc(&map->values)) < 0) + git__free(map); + else + *out = map; + + return error; +} + +static int config_open(git_config_backend *cfg, git_config_level_t level) +{ + int res; + struct reader *reader; + diskfile_backend *b = (diskfile_backend *)cfg; + + b->level = level; + + if ((res = refcounted_strmap_alloc(&b->header.values)) < 0) + return res; + + git_array_init(b->readers); + reader = git_array_alloc(b->readers); + if (!reader) { + refcounted_strmap_free(b->header.values); + return -1; + } + memset(reader, 0, sizeof(struct reader)); + + reader->file_path = git__strdup(b->file_path); + GITERR_CHECK_ALLOC(reader->file_path); + + git_buf_init(&reader->buffer, 0); + res = git_futils_readbuffer_updated( + &reader->buffer, b->file_path, &reader->file_mtime, &reader->file_size, NULL); + + /* It's fine if the file doesn't exist */ + if (res == GIT_ENOTFOUND) + return 0; + + if (res < 0 || (res = config_parse(b->header.values->values, b, reader, level, 0)) < 0) { + refcounted_strmap_free(b->header.values); + b->header.values = NULL; + } + + reader = git_array_get(b->readers, 0); + git_buf_free(&reader->buffer); + + return res; +} + +/* The meat of the refresh, as we want to use it in different places */ +static int config__refresh(git_config_backend *cfg) +{ + refcounted_strmap *values = NULL, *tmp; + diskfile_backend *b = (diskfile_backend *)cfg; + struct reader *reader = NULL; + int error = 0; + + if ((error = refcounted_strmap_alloc(&values)) < 0) + goto out; + + reader = git_array_get(b->readers, git_array_size(b->readers) - 1); + GITERR_CHECK_ALLOC(reader); + + if ((error = config_parse(values->values, b, reader, b->level, 0)) < 0) + goto out; + + git_mutex_lock(&b->header.values_mutex); + + tmp = b->header.values; + b->header.values = values; + values = tmp; + + git_mutex_unlock(&b->header.values_mutex); + +out: + refcounted_strmap_free(values); + if (reader) + git_buf_free(&reader->buffer); + return error; +} + +static int config_refresh(git_config_backend *cfg) +{ + int error = 0, updated = 0, any_updated = 0; + diskfile_backend *b = (diskfile_backend *)cfg; + struct reader *reader = NULL; + uint32_t i; + + for (i = 0; i < git_array_size(b->readers); i++) { + reader = git_array_get(b->readers, i); + error = git_futils_readbuffer_updated( + &reader->buffer, reader->file_path, + &reader->file_mtime, &reader->file_size, &updated); + + if (error < 0 && error != GIT_ENOTFOUND) + return error; + + if (updated) + any_updated = 1; + } + + if (!any_updated) + return (error == GIT_ENOTFOUND) ? 0 : error; + + return config__refresh(cfg); +} + +static void backend_free(git_config_backend *_backend) +{ + diskfile_backend *backend = (diskfile_backend *)_backend; + uint32_t i; + + if (backend == NULL) + return; + + for (i = 0; i < git_array_size(backend->readers); i++) { + struct reader *r = git_array_get(backend->readers, i); + git__free(r->file_path); + } + git_array_clear(backend->readers); + + git__free(backend->file_path); + refcounted_strmap_free(backend->header.values); + git_mutex_free(&backend->header.values_mutex); + git__free(backend); +} + +static void config_iterator_free( + git_config_iterator* iter) +{ + iter->backend->free(iter->backend); + git__free(iter); +} + +static int config_iterator_next( + git_config_entry **entry, + git_config_iterator *iter) +{ + git_config_file_iter *it = (git_config_file_iter *) iter; + diskfile_header *h = (diskfile_header *) it->parent.backend; + git_strmap *values = h->values->values; + int err = 0; + cvar_t * var; + + if (it->next_var == NULL) { + err = git_strmap_next((void**) &var, &(it->iter), values); + } else { + var = it->next_var; + } + + if (err < 0) { + it->next_var = NULL; + return err; + } + + *entry = var->entry; + it->next_var = CVAR_LIST_NEXT(var); + + return 0; +} + +static int config_iterator_new( + git_config_iterator **iter, + struct git_config_backend* backend) +{ + diskfile_header *h; + git_config_file_iter *it; + git_config_backend *snapshot; + diskfile_backend *b = (diskfile_backend *) backend; + int error; + + if ((error = config_snapshot(&snapshot, backend)) < 0) + return error; + + if ((error = snapshot->open(snapshot, b->level)) < 0) + return error; + + it = git__calloc(1, sizeof(git_config_file_iter)); + GITERR_CHECK_ALLOC(it); + + h = (diskfile_header *)snapshot; + + /* strmap_begin() is currently a macro returning 0 */ + GIT_UNUSED(h); + + it->parent.backend = snapshot; + it->iter = git_strmap_begin(h->values); + it->next_var = NULL; + + it->parent.next = config_iterator_next; + it->parent.free = config_iterator_free; + *iter = (git_config_iterator *) it; + + return 0; +} + +static int config_set(git_config_backend *cfg, const char *name, const char *value) +{ + diskfile_backend *b = (diskfile_backend *)cfg; + refcounted_strmap *map; + git_strmap *values; + char *key, *esc_value = NULL; + khiter_t pos; + int rval, ret; + + if ((rval = git_config__normalize_name(name, &key)) < 0) + return rval; + + map = refcounted_strmap_take(&b->header); + values = map->values; + + /* + * Try to find it in the existing values and update it if it + * only has one value. + */ + pos = git_strmap_lookup_index(values, key); + if (git_strmap_valid_index(values, pos)) { + cvar_t *existing = git_strmap_value_at(values, pos); + + if (existing->next != NULL) { + giterr_set(GITERR_CONFIG, "Multivar incompatible with simple set"); + ret = -1; + goto out; + } + + /* don't update if old and new values already match */ + if ((!existing->entry->value && !value) || + (existing->entry->value && value && + !strcmp(existing->entry->value, value))) { + ret = 0; + goto out; + } + } + + /* No early returns due to sanity checks, let's write it out and refresh */ + + if (value) { + esc_value = escape_value(value); + GITERR_CHECK_ALLOC(esc_value); + } + + if ((ret = config_write(b, key, NULL, esc_value)) < 0) + goto out; + + ret = config_refresh(cfg); + +out: + refcounted_strmap_free(map); + git__free(esc_value); + git__free(key); + return ret; +} + +/* release the map containing the entry as an equivalent to freeing it */ +static void release_map(git_config_entry *entry) +{ + refcounted_strmap *map = (refcounted_strmap *) entry->payload; + refcounted_strmap_free(map); +} + +/* + * Internal function that actually gets the value in string form + */ +static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out) +{ + diskfile_header *h = (diskfile_header *)cfg; + refcounted_strmap *map; + git_strmap *values; + khiter_t pos; + cvar_t *var; + int error = 0; + + if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0)) + return error; + + map = refcounted_strmap_take(h); + values = map->values; + + pos = git_strmap_lookup_index(values, key); + + /* no error message; the config system will write one */ + if (!git_strmap_valid_index(values, pos)) { + refcounted_strmap_free(map); + return GIT_ENOTFOUND; + } + + var = git_strmap_value_at(values, pos); + while (var->next) + var = var->next; + + *out = var->entry; + (*out)->free = release_map; + (*out)->payload = map; + + return error; +} + +static int config_set_multivar( + git_config_backend *cfg, const char *name, const char *regexp, const char *value) +{ + diskfile_backend *b = (diskfile_backend *)cfg; + refcounted_strmap *map; + git_strmap *values; + char *key; + regex_t preg; + int result; + khiter_t pos; + + assert(regexp); + + if ((result = git_config__normalize_name(name, &key)) < 0) + return result; + + map = refcounted_strmap_take(&b->header); + values = b->header.values->values; + + pos = git_strmap_lookup_index(values, key); + if (!git_strmap_valid_index(values, pos)) { + /* If we don't have it, behave like a normal set */ + result = config_set(cfg, name, value); + refcounted_strmap_free(map); + git__free(key); + return result; + } + + result = regcomp(&preg, regexp, REG_EXTENDED); + if (result < 0) { + giterr_set_regex(&preg, result); + result = -1; + goto out; + } + + /* If we do have it, set call config_write() and reload */ + if ((result = config_write(b, key, &preg, value)) < 0) + goto out; + + result = config_refresh(cfg); + +out: + refcounted_strmap_free(map); + git__free(key); + regfree(&preg); + + return result; +} + +static int config_delete(git_config_backend *cfg, const char *name) +{ + cvar_t *var; + diskfile_backend *b = (diskfile_backend *)cfg; + refcounted_strmap *map; git_strmap *values; + char *key; + int result; + khiter_t pos; + + if ((result = git_config__normalize_name(name, &key)) < 0) + return result; + + map = refcounted_strmap_take(&b->header); + values = b->header.values->values; + + pos = git_strmap_lookup_index(values, key); + git__free(key); + + if (!git_strmap_valid_index(values, pos)) { + refcounted_strmap_free(map); + giterr_set(GITERR_CONFIG, "Could not find key '%s' to delete", name); + return GIT_ENOTFOUND; + } + + var = git_strmap_value_at(values, pos); + refcounted_strmap_free(map); + + if (var->next != NULL) { + giterr_set(GITERR_CONFIG, "Cannot delete multivar with a single delete"); + return -1; + } + + if ((result = config_write(b, var->entry->name, NULL, NULL)) < 0) + return result; + + return config_refresh(cfg); +} + +static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp) +{ + diskfile_backend *b = (diskfile_backend *)cfg; + refcounted_strmap *map; + git_strmap *values; + char *key; + regex_t preg; + int result; + khiter_t pos; + + if ((result = git_config__normalize_name(name, &key)) < 0) + return result; + + map = refcounted_strmap_take(&b->header); + values = b->header.values->values; + + pos = git_strmap_lookup_index(values, key); + + if (!git_strmap_valid_index(values, pos)) { + refcounted_strmap_free(map); + git__free(key); + giterr_set(GITERR_CONFIG, "Could not find key '%s' to delete", name); + return GIT_ENOTFOUND; + } + + refcounted_strmap_free(map); + + result = regcomp(&preg, regexp, REG_EXTENDED); + if (result < 0) { + giterr_set_regex(&preg, result); + result = -1; + goto out; + } + + if ((result = config_write(b, key, &preg, NULL)) < 0) + goto out; + + result = config_refresh(cfg); + +out: + git__free(key); + regfree(&preg); + return result; +} + +static int config_snapshot(git_config_backend **out, git_config_backend *in) +{ + diskfile_backend *b = (diskfile_backend *) in; + + return git_config_file__snapshot(out, b); +} + +int git_config_file__ondisk(git_config_backend **out, const char *path) +{ + diskfile_backend *backend; + + backend = git__calloc(1, sizeof(diskfile_backend)); + GITERR_CHECK_ALLOC(backend); + + backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; + git_mutex_init(&backend->header.values_mutex); + + backend->file_path = git__strdup(path); + GITERR_CHECK_ALLOC(backend->file_path); + + backend->header.parent.open = config_open; + backend->header.parent.get = config_get; + backend->header.parent.set = config_set; + backend->header.parent.set_multivar = config_set_multivar; + backend->header.parent.del = config_delete; + backend->header.parent.del_multivar = config_delete_multivar; + backend->header.parent.iterator = config_iterator_new; + backend->header.parent.snapshot = config_snapshot; + backend->header.parent.free = backend_free; + + *out = (git_config_backend *)backend; + + return 0; +} + +static int config_set_readonly(git_config_backend *cfg, const char *name, const char *value) +{ + GIT_UNUSED(cfg); + GIT_UNUSED(name); + GIT_UNUSED(value); + + return config_error_readonly(); +} + +static int config_set_multivar_readonly( + git_config_backend *cfg, const char *name, const char *regexp, const char *value) +{ + GIT_UNUSED(cfg); + GIT_UNUSED(name); + GIT_UNUSED(regexp); + GIT_UNUSED(value); + + return config_error_readonly(); +} + +static int config_delete_multivar_readonly(git_config_backend *cfg, const char *name, const char *regexp) +{ + GIT_UNUSED(cfg); + GIT_UNUSED(name); + GIT_UNUSED(regexp); + + return config_error_readonly(); +} + +static int config_delete_readonly(git_config_backend *cfg, const char *name) +{ + GIT_UNUSED(cfg); + GIT_UNUSED(name); + + return config_error_readonly(); +} + +static void backend_readonly_free(git_config_backend *_backend) +{ + diskfile_backend *backend = (diskfile_backend *)_backend; + + if (backend == NULL) + return; + + refcounted_strmap_free(backend->header.values); + git_mutex_free(&backend->header.values_mutex); + git__free(backend); +} + +static int config_readonly_open(git_config_backend *cfg, git_config_level_t level) +{ + diskfile_readonly_backend *b = (diskfile_readonly_backend *) cfg; + diskfile_backend *src = b->snapshot_from; + diskfile_header *src_header = &src->header; + refcounted_strmap *src_map; + int error; + + if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0) + return error; + + /* We're just copying data, don't care about the level */ + GIT_UNUSED(level); + + src_map = refcounted_strmap_take(src_header); + b->header.values = src_map; + + return 0; +} + +int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in) +{ + diskfile_readonly_backend *backend; + + backend = git__calloc(1, sizeof(diskfile_readonly_backend)); + GITERR_CHECK_ALLOC(backend); + + backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; + git_mutex_init(&backend->header.values_mutex); + + backend->snapshot_from = in; + + backend->header.parent.readonly = 1; + backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; + backend->header.parent.open = config_readonly_open; + backend->header.parent.get = config_get; + backend->header.parent.set = config_set_readonly; + backend->header.parent.set_multivar = config_set_multivar_readonly; + backend->header.parent.del = config_delete_readonly; + backend->header.parent.del_multivar = config_delete_multivar_readonly; + backend->header.parent.iterator = config_iterator_new; + backend->header.parent.free = backend_readonly_free; + + *out = (git_config_backend *)backend; + + return 0; +} + +static int reader_getchar_raw(struct reader *reader) +{ + int c; + + c = *reader->read_ptr++; + + /* + Win 32 line breaks: if we find a \r\n sequence, + return only the \n as a newline + */ + if (c == '\r' && *reader->read_ptr == '\n') { + reader->read_ptr++; + c = '\n'; + } + + if (c == '\n') + reader->line_number++; + + if (c == 0) { + reader->eof = 1; + c = '\n'; + } + + return c; +} + +#define SKIP_WHITESPACE (1 << 1) +#define SKIP_COMMENTS (1 << 2) + +static int reader_getchar(struct reader *reader, int flags) +{ + const int skip_whitespace = (flags & SKIP_WHITESPACE); + const int skip_comments = (flags & SKIP_COMMENTS); + int c; + + assert(reader->read_ptr); + + do { + c = reader_getchar_raw(reader); + } while (skip_whitespace && git__isspace(c) && + !reader->eof); + + if (skip_comments && (c == '#' || c == ';')) { + do { + c = reader_getchar_raw(reader); + } while (c != '\n'); + } + + return c; +} + +/* + * Read the next char, but don't move the reading pointer. + */ +static int reader_peek(struct reader *reader, int flags) +{ + void *old_read_ptr; + int old_lineno, old_eof; + int ret; + + assert(reader->read_ptr); + + old_read_ptr = reader->read_ptr; + old_lineno = reader->line_number; + old_eof = reader->eof; + + ret = reader_getchar(reader, flags); + + reader->read_ptr = old_read_ptr; + reader->line_number = old_lineno; + reader->eof = old_eof; + + return ret; +} + +/* + * Read and consume a line, returning it in newly-allocated memory. + */ +static char *reader_readline(struct reader *reader, bool skip_whitespace) +{ + char *line = NULL; + char *line_src, *line_end; + size_t line_len, alloc_len; + + line_src = reader->read_ptr; + + if (skip_whitespace) { + /* Skip empty empty lines */ + while (git__isspace(*line_src)) + ++line_src; + } + + line_end = strchr(line_src, '\n'); + + /* no newline at EOF */ + if (line_end == NULL) + line_end = strchr(line_src, 0); + + line_len = line_end - line_src; + + if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, line_len, 1) || + (line = git__malloc(alloc_len)) == NULL) { + return NULL; + } + + memcpy(line, line_src, line_len); + + do line[line_len] = '\0'; + while (line_len-- > 0 && git__isspace(line[line_len])); + + if (*line_end == '\n') + line_end++; + + if (*line_end == '\0') + reader->eof = 1; + + reader->line_number++; + reader->read_ptr = line_end; + + return line; +} + +/* + * Consume a line, without storing it anywhere + */ +static void reader_consume_line(struct reader *reader) +{ + char *line_start, *line_end; + + line_start = reader->read_ptr; + line_end = strchr(line_start, '\n'); + /* No newline at EOF */ + if(line_end == NULL){ + line_end = strchr(line_start, '\0'); + } + + if (*line_end == '\n') + line_end++; + + if (*line_end == '\0') + reader->eof = 1; + + reader->line_number++; + reader->read_ptr = line_end; +} + +GIT_INLINE(int) config_keychar(int c) +{ + return isalnum(c) || c == '-'; +} + +static int parse_section_header_ext(struct reader *reader, const char *line, const char *base_name, char **section_name) +{ + int c, rpos; + char *first_quote, *last_quote; + git_buf buf = GIT_BUF_INIT; + size_t quoted_len, alloc_len, base_name_len = strlen(base_name); + + /* + * base_name is what came before the space. We should be at the + * first quotation mark, except for now, line isn't being kept in + * sync so we only really use it to calculate the length. + */ + + first_quote = strchr(line, '"'); + last_quote = strrchr(line, '"'); + quoted_len = last_quote - first_quote; + + if (quoted_len == 0) { + set_parse_error(reader, 0, "Missing closing quotation mark in section header"); + return -1; + } + + GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); + + git_buf_grow(&buf, alloc_len); + git_buf_printf(&buf, "%s.", base_name); + + rpos = 0; + + line = first_quote; + c = line[++rpos]; + + /* + * At the end of each iteration, whatever is stored in c will be + * added to the string. In case of error, jump to out + */ + do { + + switch (c) { + case 0: + set_parse_error(reader, 0, "Unexpected end-of-line in section header"); + git_buf_free(&buf); + return -1; + + case '"': + goto end_parse; + + case '\\': + c = line[++rpos]; + + if (c == 0) { + set_parse_error(reader, rpos, "Unexpected end-of-line in section header"); + git_buf_free(&buf); + return -1; + } + + default: + break; + } + + git_buf_putc(&buf, (char)c); + c = line[++rpos]; + } while (line + rpos < last_quote); + +end_parse: + if (line[rpos] != '"' || line[rpos + 1] != ']') { + set_parse_error(reader, rpos, "Unexpected text after closing quotes"); + git_buf_free(&buf); + return -1; + } + + *section_name = git_buf_detach(&buf); + return 0; +} + +static int parse_section_header(struct reader *reader, char **section_out) +{ + char *name, *name_end; + int name_length, c, pos; + int result; + char *line; + size_t line_len; + + line = reader_readline(reader, true); + if (line == NULL) + return -1; + + /* find the end of the variable's name */ + name_end = strrchr(line, ']'); + if (name_end == NULL) { + git__free(line); + set_parse_error(reader, 0, "Missing ']' in section header"); + return -1; + } + + GITERR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1); + name = git__malloc(line_len); + GITERR_CHECK_ALLOC(name); + + name_length = 0; + pos = 0; + + /* Make sure we were given a section header */ + c = line[pos++]; + assert(c == '['); + + c = line[pos++]; + + do { + if (git__isspace(c)){ + name[name_length] = '\0'; + result = parse_section_header_ext(reader, line, name, section_out); + git__free(line); + git__free(name); + return result; + } + + if (!config_keychar(c) && c != '.') { + set_parse_error(reader, pos, "Unexpected character in header"); + goto fail_parse; + } + + name[name_length++] = (char) tolower(c); + + } while ((c = line[pos++]) != ']'); + + if (line[pos - 1] != ']') { + set_parse_error(reader, pos, "Unexpected end of file"); + goto fail_parse; + } + + git__free(line); + + name[name_length] = 0; + *section_out = name; + + return 0; + +fail_parse: + git__free(line); + git__free(name); + return -1; +} + +static int skip_bom(struct reader *reader) +{ + git_bom_t bom; + int bom_offset = git_buf_text_detect_bom(&bom, + &reader->buffer, reader->read_ptr - reader->buffer.ptr); + + if (bom == GIT_BOM_UTF8) + reader->read_ptr += bom_offset; + + /* TODO: reference implementation is pretty stupid with BoM */ + + return 0; +} + +/* + (* basic types *) + digit = "0".."9" + integer = digit { digit } + alphabet = "a".."z" + "A" .. "Z" + + section_char = alphabet | "." | "-" + extension_char = (* any character except newline *) + any_char = (* any character *) + variable_char = "alphabet" | "-" + + + (* actual grammar *) + config = { section } + + section = header { definition } + + header = "[" section [subsection | subsection_ext] "]" + + subsection = "." section + subsection_ext = "\"" extension "\"" + + section = section_char { section_char } + extension = extension_char { extension_char } + + definition = variable_name ["=" variable_value] "\n" + + variable_name = variable_char { variable_char } + variable_value = string | boolean | integer + + string = quoted_string | plain_string + quoted_string = "\"" plain_string "\"" + plain_string = { any_char } + + boolean = boolean_true | boolean_false + boolean_true = "yes" | "1" | "true" | "on" + boolean_false = "no" | "0" | "false" | "off" +*/ + +static int strip_comments(char *line, int in_quotes) +{ + int quote_count = in_quotes; + char *ptr; + + for (ptr = line; *ptr; ++ptr) { + if (ptr[0] == '"' && ptr > line && ptr[-1] != '\\') + quote_count++; + + if ((ptr[0] == ';' || ptr[0] == '#') && (quote_count % 2) == 0) { + ptr[0] = '\0'; + break; + } + } + + /* skip any space at the end */ + while (ptr > line && git__isspace(ptr[-1])) { + ptr--; + } + ptr[0] = '\0'; + + return quote_count; +} + +static int included_path(git_buf *out, const char *dir, const char *path) +{ + /* From the user's home */ + if (path[0] == '~' && path[1] == '/') + return git_sysdir_find_global_file(out, &path[1]); + + return git_path_join_unrooted(out, path, dir, NULL); +} + +static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct reader *reader, git_config_level_t level, int depth) +{ + int c; + char *current_section = NULL; + char *var_name; + char *var_value; + cvar_t *var; + git_buf buf = GIT_BUF_INIT; + int result = 0; + uint32_t reader_idx; + + if (depth >= MAX_INCLUDE_DEPTH) { + giterr_set(GITERR_CONFIG, "Maximum config include depth reached"); + return -1; + } + + reader_idx = git_array_size(cfg_file->readers) - 1; + /* Initialize the reading position */ + reader->read_ptr = reader->buffer.ptr; + reader->eof = 0; + + /* If the file is empty, there's nothing for us to do */ + if (*reader->read_ptr == '\0') + return 0; + + skip_bom(reader); + + while (result == 0 && !reader->eof) { + + c = reader_peek(reader, SKIP_WHITESPACE); + + switch (c) { + case '\n': /* EOF when peeking, set EOF in the reader to exit the loop */ + reader->eof = 1; + break; + + case '[': /* section header, new section begins */ + git__free(current_section); + current_section = NULL; + result = parse_section_header(reader, ¤t_section); + break; + + case ';': + case '#': + reader_consume_line(reader); + break; + + default: /* assume variable declaration */ + result = parse_variable(reader, &var_name, &var_value); + if (result < 0) + break; + + git__strtolower(var_name); + git_buf_printf(&buf, "%s.%s", current_section, var_name); + git__free(var_name); + + if (git_buf_oom(&buf)) { + git__free(var_value); + return -1; + } + + var = git__calloc(1, sizeof(cvar_t)); + GITERR_CHECK_ALLOC(var); + var->entry = git__calloc(1, sizeof(git_config_entry)); + GITERR_CHECK_ALLOC(var->entry); + + var->entry->name = git_buf_detach(&buf); + var->entry->value = var_value; + var->entry->level = level; + var->included = !!depth; + + + if ((result = append_entry(values, var)) < 0) + break; + else + result = 0; + + /* Add or append the new config option */ + if (!git__strcmp(var->entry->name, "include.path")) { + struct reader *r; + git_buf path = GIT_BUF_INIT; + char *dir; + uint32_t index; + + r = git_array_alloc(cfg_file->readers); + /* The reader may have been reallocated */ + reader = git_array_get(cfg_file->readers, reader_idx); + memset(r, 0, sizeof(struct reader)); + if ((result = git_path_dirname_r(&path, reader->file_path)) < 0) + break; + + /* We need to know our index in the array, as the next config_parse call may realloc */ + index = git_array_size(cfg_file->readers) - 1; + dir = git_buf_detach(&path); + result = included_path(&path, dir, var->entry->value); + git__free(dir); + + if (result < 0) + break; + + r->file_path = git_buf_detach(&path); + git_buf_init(&r->buffer, 0); + result = git_futils_readbuffer_updated(&r->buffer, r->file_path, &r->file_mtime, + &r->file_size, NULL); + + if (result == 0) { + result = config_parse(values, cfg_file, r, level, depth+1); + r = git_array_get(cfg_file->readers, index); + reader = git_array_get(cfg_file->readers, reader_idx); + } + else if (result == GIT_ENOTFOUND) { + giterr_clear(); + result = 0; + } + + git_buf_free(&r->buffer); + + if (result < 0) + break; + } + + break; + } + } + + git__free(current_section); + return result; +} + +static int write_section(git_filebuf *file, const char *key) +{ + int result; + const char *dot; + git_buf buf = GIT_BUF_INIT; + + /* All of this just for [section "subsection"] */ + dot = strchr(key, '.'); + git_buf_putc(&buf, '['); + if (dot == NULL) { + git_buf_puts(&buf, key); + } else { + char *escaped; + git_buf_put(&buf, key, dot - key); + escaped = escape_value(dot + 1); + GITERR_CHECK_ALLOC(escaped); + git_buf_printf(&buf, " \"%s\"", escaped); + git__free(escaped); + } + git_buf_puts(&buf, "]\n"); + + if (git_buf_oom(&buf)) + return -1; + + result = git_filebuf_write(file, git_buf_cstr(&buf), buf.size); + git_buf_free(&buf); + + return result; +} + +static const char *quotes_for_value(const char *value) +{ + const char *ptr; + + if (value[0] == ' ' || value[0] == '\0') + return "\""; + + for (ptr = value; *ptr; ++ptr) { + if (*ptr == ';' || *ptr == '#') + return "\""; + } + + if (ptr[-1] == ' ') + return "\""; + + return ""; +} + +/* + * This is pretty much the parsing, except we write out anything we don't have + */ +static int config_write(diskfile_backend *cfg, const char *key, const regex_t *preg, const char* value) +{ + int result, c; + int section_matches = 0, last_section_matched = 0, preg_replaced = 0, write_trailer = 0; + const char *pre_end = NULL, *post_start = NULL, *data_start, *write_start; + char *current_section = NULL, *section, *name, *ldot; + git_filebuf file = GIT_FILEBUF_INIT; + struct reader *reader = git_array_get(cfg->readers, 0); + + /* We need to read in our own config file */ + result = git_futils_readbuffer(&reader->buffer, cfg->file_path); + + /* Initialise the reading position */ + if (result == GIT_ENOTFOUND) { + reader->read_ptr = NULL; + reader->eof = 1; + data_start = NULL; + git_buf_clear(&reader->buffer); + } else if (result == 0) { + reader->read_ptr = reader->buffer.ptr; + reader->eof = 0; + data_start = reader->read_ptr; + } else { + return -1; /* OS error when reading the file */ + } + + write_start = data_start; + + /* Lock the file */ + if ((result = git_filebuf_open( + &file, cfg->file_path, 0, GIT_CONFIG_FILE_MODE)) < 0) { + git_buf_free(&reader->buffer); + return result; + } + + skip_bom(reader); + ldot = strrchr(key, '.'); + name = ldot + 1; + section = git__strndup(key, ldot - key); + + while (!reader->eof) { + c = reader_peek(reader, SKIP_WHITESPACE); + + if (c == '\0') { /* We've arrived at the end of the file */ + break; + + } else if (c == '[') { /* section header, new section begins */ + /* + * We set both positions to the current one in case we + * need to add a variable to the end of a section. In that + * case, we want both variables to point just before the + * new section. If we actually want to replace it, the + * default case will take care of updating them. + */ + pre_end = post_start = reader->read_ptr; + + git__free(current_section); + current_section = NULL; + if (parse_section_header(reader, ¤t_section) < 0) + goto rewrite_fail; + + /* Keep track of when it stops matching */ + last_section_matched = section_matches; + section_matches = !strcmp(current_section, section); + } + + else if (c == ';' || c == '#') { + reader_consume_line(reader); + } + + else { + /* + * If the section doesn't match, but the last section did, + * it means we need to add a variable (so skip the line + * otherwise). If both the section and name match, we need + * to overwrite the variable (so skip the line + * otherwise). pre_end needs to be updated each time so we + * don't loose that information, but we only need to + * update post_start if we're going to use it in this + * iteration. + */ + if (!section_matches) { + if (!last_section_matched) { + reader_consume_line(reader); + continue; + } + } else { + int has_matched = 0; + char *var_name, *var_value; + + pre_end = reader->read_ptr; + if (parse_variable(reader, &var_name, &var_value) < 0) + goto rewrite_fail; + + /* First try to match the name of the variable */ + if (strcasecmp(name, var_name) == 0) + has_matched = 1; + + /* If the name matches, and we have a regex to match the + * value, try to match it */ + if (has_matched && preg != NULL) + has_matched = (regexec(preg, var_value, 0, NULL, 0) == 0); + + git__free(var_name); + git__free(var_value); + + /* if there is no match, keep going */ + if (!has_matched) + continue; + + post_start = reader->read_ptr; + } + + /* We've found the variable we wanted to change, so + * write anything up to it */ + git_filebuf_write(&file, write_start, pre_end - write_start); + preg_replaced = 1; + + /* Then replace the variable. If the value is NULL, it + * means we want to delete it, so don't write anything. */ + if (value != NULL) { + const char *q = quotes_for_value(value); + git_filebuf_printf(&file, "\t%s = %s%s%s\n", name, q, value, q); + } + + /* + * If we have a multivar, we should keep looking for entries, + * but only if we're in the right section. Otherwise we'll end up + * looping on the edge of a matching and a non-matching section. + */ + if (section_matches && preg != NULL) { + write_start = post_start; + continue; + } + + write_trailer = 1; + break; /* break from the loop */ + } + } + + /* + * Being here can mean that + * + * 1) our section is the last one in the file and we're + * adding a variable + * + * 2) we didn't find a section for us so we need to create it + * ourselves. + * + * 3) we're setting a multivar with a regex, which means we + * continue to search for matching values + * + * In the last case, if we've already replaced a value, we + * want to write the rest of the file. Otherwise we need to write + * out the whole file and then the new variable. + */ + if (write_trailer) { + /* Write out rest of the file */ + git_filebuf_write(&file, post_start, reader->buffer.size - (post_start - data_start)); + } else { + if (preg_replaced) { + git_filebuf_printf(&file, "\n%s", write_start); + } else { + const char *q; + + git_filebuf_write(&file, reader->buffer.ptr, reader->buffer.size); + + if (reader->buffer.size > 0 && *(reader->buffer.ptr + reader->buffer.size - 1) != '\n') + git_filebuf_write(&file, "\n", 1); + + /* And now if we just need to add a variable */ + if (!section_matches && write_section(&file, section) < 0) + goto rewrite_fail; + + /* Sanity check: if we are here, and value is NULL, that means that somebody + * touched the config file after our initial read. We should probably assert() + * this, but instead we'll handle it gracefully with an error. */ + if (value == NULL) { + giterr_set(GITERR_CONFIG, + "race condition when writing a config file (a cvar has been removed)"); + goto rewrite_fail; + } + + /* If we are here, there is at least a section line */ + q = quotes_for_value(value); + git_filebuf_printf(&file, "\t%s = %s%s%s\n", name, q, value, q); + } + } + + git__free(section); + git__free(current_section); + + /* refresh stats - if this errors, then commit will error too */ + (void)git_filebuf_stats(&reader->file_mtime, &reader->file_size, &file); + + result = git_filebuf_commit(&file); + git_buf_free(&reader->buffer); + + return result; + +rewrite_fail: + git__free(section); + git__free(current_section); + + git_filebuf_cleanup(&file); + git_buf_free(&reader->buffer); + return -1; +} + +static const char *escapes = "ntb\"\\"; +static const char *escaped = "\n\t\b\"\\"; + +/* Escape the values to write them to the file */ +static char *escape_value(const char *ptr) +{ + git_buf buf = GIT_BUF_INIT; + size_t len; + const char *esc; + + assert(ptr); + + len = strlen(ptr); + if (!len) + return git__calloc(1, sizeof(char)); + + git_buf_grow(&buf, len); + + while (*ptr != '\0') { + if ((esc = strchr(escaped, *ptr)) != NULL) { + git_buf_putc(&buf, '\\'); + git_buf_putc(&buf, escapes[esc - escaped]); + } else { + git_buf_putc(&buf, *ptr); + } + ptr++; + } + + if (git_buf_oom(&buf)) { + git_buf_free(&buf); + return NULL; + } + + return git_buf_detach(&buf); +} + +/* '\"' -> '"' etc */ +static char *fixup_line(const char *ptr, int quote_count) +{ + char *str, *out, *esc; + size_t ptr_len = strlen(ptr), alloc_len; + + if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, ptr_len, 1) || + (str = git__malloc(alloc_len)) == NULL) { + return NULL; + } + + out = str; + + while (*ptr != '\0') { + if (*ptr == '"') { + quote_count++; + } else if (*ptr != '\\') { + *out++ = *ptr; + } else { + /* backslash, check the next char */ + ptr++; + /* if we're at the end, it's a multiline, so keep the backslash */ + if (*ptr == '\0') { + *out++ = '\\'; + goto out; + } + if ((esc = strchr(escapes, *ptr)) != NULL) { + *out++ = escaped[esc - escapes]; + } else { + git__free(str); + giterr_set(GITERR_CONFIG, "Invalid escape at %s", ptr); + return NULL; + } + } + ptr++; + } + +out: + *out = '\0'; + + return str; +} + +static int is_multiline_var(const char *str) +{ + int count = 0; + const char *end = str + strlen(str); + while (end > str && end[-1] == '\\') { + count++; + end--; + } + + /* An odd number means last backslash wasn't escaped, so it's multiline */ + return count & 1; +} + +static int parse_multiline_variable(struct reader *reader, git_buf *value, int in_quotes) +{ + char *line = NULL, *proc_line = NULL; + int quote_count; + + /* Check that the next line exists */ + line = reader_readline(reader, false); + if (line == NULL) + return -1; + + /* We've reached the end of the file, there is input missing */ + if (line[0] == '\0') { + set_parse_error(reader, 0, "Unexpected end of file while parsing multine var"); + git__free(line); + return -1; + } + + quote_count = strip_comments(line, !!in_quotes); + + /* If it was just a comment, pretend it didn't exist */ + if (line[0] == '\0') { + git__free(line); + return parse_multiline_variable(reader, value, quote_count); + /* TODO: unbounded recursion. This **could** be exploitable */ + } + + /* Drop the continuation character '\': to closely follow the UNIX + * standard, this character **has** to be last one in the buf, with + * no whitespace after it */ + assert(is_multiline_var(value->ptr)); + git_buf_shorten(value, 1); + + proc_line = fixup_line(line, in_quotes); + if (proc_line == NULL) { + git__free(line); + return -1; + } + /* add this line to the multiline var */ + git_buf_puts(value, proc_line); + git__free(line); + git__free(proc_line); + + /* + * If we need to continue reading the next line, let's just + * keep putting stuff in the buffer + */ + if (is_multiline_var(value->ptr)) + return parse_multiline_variable(reader, value, quote_count); + + return 0; +} + +static int parse_variable(struct reader *reader, char **var_name, char **var_value) +{ + const char *var_end = NULL; + const char *value_start = NULL; + char *line; + int quote_count; + + line = reader_readline(reader, true); + if (line == NULL) + return -1; + + quote_count = strip_comments(line, 0); + + var_end = strchr(line, '='); + + if (var_end == NULL) + var_end = strchr(line, '\0'); + else + value_start = var_end + 1; + + do var_end--; + while (var_end>line && git__isspace(*var_end)); + + *var_name = git__strndup(line, var_end - line + 1); + GITERR_CHECK_ALLOC(*var_name); + + /* If there is no value, boolean true is assumed */ + *var_value = NULL; + + /* + * Now, let's try to parse the value + */ + if (value_start != NULL) { + while (git__isspace(value_start[0])) + value_start++; + + if (is_multiline_var(value_start)) { + git_buf multi_value = GIT_BUF_INIT; + char *proc_line = fixup_line(value_start, 0); + GITERR_CHECK_ALLOC(proc_line); + git_buf_puts(&multi_value, proc_line); + git__free(proc_line); + if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 || git_buf_oom(&multi_value)) { + git__free(*var_name); + git__free(line); + git_buf_free(&multi_value); + return -1; + } + + *var_value = git_buf_detach(&multi_value); + + } + else if (value_start[0] != '\0') { + *var_value = fixup_line(value_start, 0); + GITERR_CHECK_ALLOC(*var_value); + } else { /* equals sign but missing rhs */ + *var_value = git__strdup(""); + GITERR_CHECK_ALLOC(*var_value); + } + } + + git__free(line); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/config_file.h b/deps/libgit2-sys-0.2.17/libgit2/src/config_file.h new file mode 100644 index 000000000..0d8bf740f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/config_file.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_config_file_h__ +#define INCLUDE_config_file_h__ + +#include "git2/config.h" + +GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level) +{ + return cfg->open(cfg, level); +} + +GIT_INLINE(void) git_config_file_free(git_config_backend *cfg) +{ + if (cfg) + cfg->free(cfg); +} + +GIT_INLINE(int) git_config_file_get_string( + git_config_entry **out, git_config_backend *cfg, const char *name) +{ + return cfg->get(cfg, name, out); +} + +GIT_INLINE(int) git_config_file_set_string( + git_config_backend *cfg, const char *name, const char *value) +{ + return cfg->set(cfg, name, value); +} + +GIT_INLINE(int) git_config_file_delete( + git_config_backend *cfg, const char *name) +{ + return cfg->del(cfg, name); +} + +GIT_INLINE(int) git_config_file_foreach( + git_config_backend *cfg, + int (*fn)(const git_config_entry *entry, void *data), + void *data) +{ + return git_config_backend_foreach_match(cfg, NULL, fn, data); +} + +GIT_INLINE(int) git_config_file_foreach_match( + git_config_backend *cfg, + const char *regexp, + int (*fn)(const git_config_entry *entry, void *data), + void *data) +{ + return git_config_backend_foreach_match(cfg, regexp, fn, data); +} + +extern int git_config_file_normalize_section(char *start, char *end); + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/crlf.c b/deps/libgit2-sys-0.2.17/libgit2/src/crlf.c new file mode 100644 index 000000000..b5d1dbf32 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/crlf.c @@ -0,0 +1,360 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/attr.h" +#include "git2/blob.h" +#include "git2/index.h" +#include "git2/sys/filter.h" + +#include "common.h" +#include "fileops.h" +#include "hash.h" +#include "filter.h" +#include "buf_text.h" +#include "repository.h" + +struct crlf_attrs { + int crlf_action; + int eol; + int auto_crlf; + int safe_crlf; +}; + +struct crlf_filter { + git_filter f; +}; + +static int check_crlf(const char *value) +{ + if (GIT_ATTR_TRUE(value)) + return GIT_CRLF_TEXT; + + if (GIT_ATTR_FALSE(value)) + return GIT_CRLF_BINARY; + + if (GIT_ATTR_UNSPECIFIED(value)) + return GIT_CRLF_GUESS; + + if (strcmp(value, "input") == 0) + return GIT_CRLF_INPUT; + + if (strcmp(value, "auto") == 0) + return GIT_CRLF_AUTO; + + return GIT_CRLF_GUESS; +} + +static int check_eol(const char *value) +{ + if (GIT_ATTR_UNSPECIFIED(value)) + return GIT_EOL_UNSET; + + if (strcmp(value, "lf") == 0) + return GIT_EOL_LF; + + if (strcmp(value, "crlf") == 0) + return GIT_EOL_CRLF; + + return GIT_EOL_UNSET; +} + +static int crlf_input_action(struct crlf_attrs *ca) +{ + if (ca->crlf_action == GIT_CRLF_BINARY) + return GIT_CRLF_BINARY; + + if (ca->eol == GIT_EOL_LF) + return GIT_CRLF_INPUT; + + if (ca->eol == GIT_EOL_CRLF) + return GIT_CRLF_CRLF; + + return ca->crlf_action; +} + +static int has_cr_in_index(const git_filter_source *src) +{ + git_repository *repo = git_filter_source_repo(src); + const char *path = git_filter_source_path(src); + git_index *index; + const git_index_entry *entry; + git_blob *blob; + const void *blobcontent; + git_off_t blobsize; + bool found_cr; + + if (!path) + return false; + + if (git_repository_index__weakptr(&index, repo) < 0) { + giterr_clear(); + return false; + } + + if (!(entry = git_index_get_bypath(index, path, 0)) && + !(entry = git_index_get_bypath(index, path, 1))) + return false; + + if (!S_ISREG(entry->mode)) /* don't crlf filter non-blobs */ + return true; + + if (git_blob_lookup(&blob, repo, &entry->id) < 0) + return false; + + blobcontent = git_blob_rawcontent(blob); + blobsize = git_blob_rawsize(blob); + if (!git__is_sizet(blobsize)) + blobsize = (size_t)-1; + + found_cr = (blobcontent != NULL && + blobsize > 0 && + memchr(blobcontent, '\r', (size_t)blobsize) != NULL); + + git_blob_free(blob); + return found_cr; +} + +static int crlf_apply_to_odb( + struct crlf_attrs *ca, + git_buf *to, + const git_buf *from, + const git_filter_source *src) +{ + /* Empty file? Nothing to do */ + if (!git_buf_len(from)) + return 0; + + /* Heuristics to see if we can skip the conversion. + * Straight from Core Git. + */ + if (ca->crlf_action == GIT_CRLF_AUTO || ca->crlf_action == GIT_CRLF_GUESS) { + git_buf_text_stats stats; + + /* Check heuristics for binary vs text - returns true if binary */ + if (git_buf_text_gather_stats(&stats, from, false)) + return GIT_PASSTHROUGH; + + /* If there are no CR characters to filter out, then just pass */ + if (!stats.cr) + return GIT_PASSTHROUGH; + + /* If safecrlf is enabled, sanity-check the result. */ + if (stats.cr != stats.crlf || stats.lf != stats.crlf) { + switch (ca->safe_crlf) { + case GIT_SAFE_CRLF_FAIL: + giterr_set( + GITERR_FILTER, "LF would be replaced by CRLF in '%s'", + git_filter_source_path(src)); + return -1; + case GIT_SAFE_CRLF_WARN: + /* TODO: issue warning when warning API is available */; + break; + default: + break; + } + } + + /* + * We're currently not going to even try to convert stuff + * that has bare CR characters. Does anybody do that crazy + * stuff? + */ + if (stats.cr != stats.crlf) + return GIT_PASSTHROUGH; + + if (ca->crlf_action == GIT_CRLF_GUESS) { + /* + * If the file in the index has any CR in it, do not convert. + * This is the new safer autocrlf handling. + */ + if (has_cr_in_index(src)) + return GIT_PASSTHROUGH; + } + + if (!stats.cr) + return GIT_PASSTHROUGH; + } + + /* Actually drop the carriage returns */ + return git_buf_text_crlf_to_lf(to, from); +} + +static const char *line_ending(struct crlf_attrs *ca) +{ + switch (ca->crlf_action) { + case GIT_CRLF_BINARY: + case GIT_CRLF_INPUT: + return "\n"; + + case GIT_CRLF_CRLF: + return "\r\n"; + + case GIT_CRLF_AUTO: + case GIT_CRLF_TEXT: + case GIT_CRLF_GUESS: + break; + + default: + goto line_ending_error; + } + + switch (ca->eol) { + case GIT_EOL_UNSET: + return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n"; + + case GIT_EOL_CRLF: + return "\r\n"; + + case GIT_EOL_LF: + return "\n"; + + default: + goto line_ending_error; + } + +line_ending_error: + giterr_set(GITERR_INVALID, "Invalid input to line ending filter"); + return NULL; +} + +static int crlf_apply_to_workdir( + struct crlf_attrs *ca, git_buf *to, const git_buf *from) +{ + const char *workdir_ending = NULL; + + /* Empty file? Nothing to do. */ + if (git_buf_len(from) == 0) + return 0; + + /* Don't filter binary files */ + if (git_buf_text_is_binary(from)) + return GIT_PASSTHROUGH; + + /* Determine proper line ending */ + workdir_ending = line_ending(ca); + if (!workdir_ending) + return -1; + + /* only LF->CRLF conversion is supported, do nothing on LF platforms */ + if (strcmp(workdir_ending, "\r\n") != 0) + return GIT_PASSTHROUGH; + + return git_buf_text_lf_to_crlf(to, from); +} + +static int crlf_check( + git_filter *self, + void **payload, /* points to NULL ptr on entry, may be set */ + const git_filter_source *src, + const char **attr_values) +{ + int error; + struct crlf_attrs ca; + + GIT_UNUSED(self); + + if (!attr_values) { + ca.crlf_action = GIT_CRLF_GUESS; + ca.eol = GIT_EOL_UNSET; + } else { + ca.crlf_action = check_crlf(attr_values[2]); /* text */ + if (ca.crlf_action == GIT_CRLF_GUESS) + ca.crlf_action = check_crlf(attr_values[0]); /* clrf */ + ca.eol = check_eol(attr_values[1]); /* eol */ + } + ca.auto_crlf = GIT_AUTO_CRLF_DEFAULT; + + /* + * Use the core Git logic to see if we should perform CRLF for this file + * based on its attributes & the value of `core.autocrlf` + */ + ca.crlf_action = crlf_input_action(&ca); + + if (ca.crlf_action == GIT_CRLF_BINARY) + return GIT_PASSTHROUGH; + + if (ca.crlf_action == GIT_CRLF_GUESS || + (ca.crlf_action == GIT_CRLF_AUTO && + git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) { + + error = git_repository__cvar( + &ca.auto_crlf, git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF); + if (error < 0) + return error; + + if (ca.crlf_action == GIT_CRLF_GUESS && + ca.auto_crlf == GIT_AUTO_CRLF_FALSE) + return GIT_PASSTHROUGH; + + if (ca.auto_crlf == GIT_AUTO_CRLF_INPUT && + git_filter_source_mode(src) == GIT_FILTER_SMUDGE) + return GIT_PASSTHROUGH; + } + + if (git_filter_source_mode(src) == GIT_FILTER_CLEAN) { + error = git_repository__cvar( + &ca.safe_crlf, git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF); + if (error < 0) + return error; + + /* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */ + if ((git_filter_source_flags(src) & GIT_FILTER_ALLOW_UNSAFE) && + ca.safe_crlf == GIT_SAFE_CRLF_FAIL) + ca.safe_crlf = GIT_SAFE_CRLF_WARN; + } + + *payload = git__malloc(sizeof(ca)); + GITERR_CHECK_ALLOC(*payload); + memcpy(*payload, &ca, sizeof(ca)); + + return 0; +} + +static int crlf_apply( + git_filter *self, + void **payload, /* may be read and/or set */ + git_buf *to, + const git_buf *from, + const git_filter_source *src) +{ + /* initialize payload in case `check` was bypassed */ + if (!*payload) { + int error = crlf_check(self, payload, src, NULL); + if (error < 0 && error != GIT_PASSTHROUGH) + return error; + } + + if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE) + return crlf_apply_to_workdir(*payload, to, from); + else + return crlf_apply_to_odb(*payload, to, from, src); +} + +static void crlf_cleanup( + git_filter *self, + void *payload) +{ + GIT_UNUSED(self); + git__free(payload); +} + +git_filter *git_crlf_filter_new(void) +{ + struct crlf_filter *f = git__calloc(1, sizeof(struct crlf_filter)); + if (f == NULL) + return NULL; + + f->f.version = GIT_FILTER_VERSION; + f->f.attributes = "crlf eol text"; + f->f.initialize = NULL; + f->f.shutdown = git_filter_free; + f->f.check = crlf_check; + f->f.apply = crlf_apply; + f->f.cleanup = crlf_cleanup; + + return (git_filter *)f; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/date.c b/deps/libgit2-sys-0.2.17/libgit2/src/date.c new file mode 100644 index 000000000..0e1b31aee --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/date.c @@ -0,0 +1,904 @@ +/* + * GIT - The information manager from hell + * + * Copyright (C) Linus Torvalds, 2005 + */ + +#include "common.h" + +#ifndef GIT_WIN32 +#include +#endif + +#include "util.h" +#include "cache.h" +#include "posix.h" + +#include +#include + +typedef enum { + DATE_NORMAL = 0, + DATE_RELATIVE, + DATE_SHORT, + DATE_LOCAL, + DATE_ISO8601, + DATE_RFC2822, + DATE_RAW +} date_mode; + +/* + * This is like mktime, but without normalization of tm_wday and tm_yday. + */ +static git_time_t tm_to_time_t(const struct tm *tm) +{ + static const int mdays[] = { + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 + }; + int year = tm->tm_year - 70; + int month = tm->tm_mon; + int day = tm->tm_mday; + + if (year < 0 || year > 129) /* algo only works for 1970-2099 */ + return -1; + if (month < 0 || month > 11) /* array bounds */ + return -1; + if (month < 2 || (year + 2) % 4) + day--; + if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_sec < 0) + return -1; + return (year * 365 + (year + 1) / 4 + mdays[month] + day) * 24*60*60UL + + tm->tm_hour * 60*60 + tm->tm_min * 60 + tm->tm_sec; +} + +static const char *month_names[] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" +}; + +static const char *weekday_names[] = { + "Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays" +}; + + + +/* + * Check these. And note how it doesn't do the summer-time conversion. + * + * In my world, it's always summer, and things are probably a bit off + * in other ways too. + */ +static const struct { + const char *name; + int offset; + int dst; +} timezone_names[] = { + { "IDLW", -12, 0, }, /* International Date Line West */ + { "NT", -11, 0, }, /* Nome */ + { "CAT", -10, 0, }, /* Central Alaska */ + { "HST", -10, 0, }, /* Hawaii Standard */ + { "HDT", -10, 1, }, /* Hawaii Daylight */ + { "YST", -9, 0, }, /* Yukon Standard */ + { "YDT", -9, 1, }, /* Yukon Daylight */ + { "PST", -8, 0, }, /* Pacific Standard */ + { "PDT", -8, 1, }, /* Pacific Daylight */ + { "MST", -7, 0, }, /* Mountain Standard */ + { "MDT", -7, 1, }, /* Mountain Daylight */ + { "CST", -6, 0, }, /* Central Standard */ + { "CDT", -6, 1, }, /* Central Daylight */ + { "EST", -5, 0, }, /* Eastern Standard */ + { "EDT", -5, 1, }, /* Eastern Daylight */ + { "AST", -3, 0, }, /* Atlantic Standard */ + { "ADT", -3, 1, }, /* Atlantic Daylight */ + { "WAT", -1, 0, }, /* West Africa */ + + { "GMT", 0, 0, }, /* Greenwich Mean */ + { "UTC", 0, 0, }, /* Universal (Coordinated) */ + { "Z", 0, 0, }, /* Zulu, alias for UTC */ + + { "WET", 0, 0, }, /* Western European */ + { "BST", 0, 1, }, /* British Summer */ + { "CET", +1, 0, }, /* Central European */ + { "MET", +1, 0, }, /* Middle European */ + { "MEWT", +1, 0, }, /* Middle European Winter */ + { "MEST", +1, 1, }, /* Middle European Summer */ + { "CEST", +1, 1, }, /* Central European Summer */ + { "MESZ", +1, 1, }, /* Middle European Summer */ + { "FWT", +1, 0, }, /* French Winter */ + { "FST", +1, 1, }, /* French Summer */ + { "EET", +2, 0, }, /* Eastern Europe */ + { "EEST", +2, 1, }, /* Eastern European Daylight */ + { "WAST", +7, 0, }, /* West Australian Standard */ + { "WADT", +7, 1, }, /* West Australian Daylight */ + { "CCT", +8, 0, }, /* China Coast */ + { "JST", +9, 0, }, /* Japan Standard */ + { "EAST", +10, 0, }, /* Eastern Australian Standard */ + { "EADT", +10, 1, }, /* Eastern Australian Daylight */ + { "GST", +10, 0, }, /* Guam Standard */ + { "NZT", +12, 0, }, /* New Zealand */ + { "NZST", +12, 0, }, /* New Zealand Standard */ + { "NZDT", +12, 1, }, /* New Zealand Daylight */ + { "IDLE", +12, 0, }, /* International Date Line East */ +}; + +static size_t match_string(const char *date, const char *str) +{ + size_t i = 0; + + for (i = 0; *date; date++, str++, i++) { + if (*date == *str) + continue; + if (toupper(*date) == toupper(*str)) + continue; + if (!isalnum(*date)) + break; + return 0; + } + return i; +} + +static int skip_alpha(const char *date) +{ + int i = 0; + do { + i++; + } while (isalpha(date[i])); + return i; +} + +/* +* Parse month, weekday, or timezone name +*/ +static size_t match_alpha(const char *date, struct tm *tm, int *offset) +{ + unsigned int i; + + for (i = 0; i < 12; i++) { + size_t match = match_string(date, month_names[i]); + if (match >= 3) { + tm->tm_mon = i; + return match; + } + } + + for (i = 0; i < 7; i++) { + size_t match = match_string(date, weekday_names[i]); + if (match >= 3) { + tm->tm_wday = i; + return match; + } + } + + for (i = 0; i < ARRAY_SIZE(timezone_names); i++) { + size_t match = match_string(date, timezone_names[i].name); + if (match >= 3 || match == strlen(timezone_names[i].name)) { + int off = timezone_names[i].offset; + + /* This is bogus, but we like summer */ + off += timezone_names[i].dst; + + /* Only use the tz name offset if we don't have anything better */ + if (*offset == -1) + *offset = 60*off; + + return match; + } + } + + if (match_string(date, "PM") == 2) { + tm->tm_hour = (tm->tm_hour % 12) + 12; + return 2; + } + + if (match_string(date, "AM") == 2) { + tm->tm_hour = (tm->tm_hour % 12) + 0; + return 2; + } + + /* BAD */ + return skip_alpha(date); +} + +static int is_date(int year, int month, int day, struct tm *now_tm, time_t now, struct tm *tm) +{ + if (month > 0 && month < 13 && day > 0 && day < 32) { + struct tm check = *tm; + struct tm *r = (now_tm ? &check : tm); + time_t specified; + + r->tm_mon = month - 1; + r->tm_mday = day; + if (year == -1) { + if (!now_tm) + return 1; + r->tm_year = now_tm->tm_year; + } + else if (year >= 1970 && year < 2100) + r->tm_year = year - 1900; + else if (year > 70 && year < 100) + r->tm_year = year; + else if (year < 38) + r->tm_year = year + 100; + else + return 0; + if (!now_tm) + return 1; + + specified = tm_to_time_t(r); + + /* Be it commit time or author time, it does not make + * sense to specify timestamp way into the future. Make + * sure it is not later than ten days from now... + */ + if (now + 10*24*3600 < specified) + return 0; + tm->tm_mon = r->tm_mon; + tm->tm_mday = r->tm_mday; + if (year != -1) + tm->tm_year = r->tm_year; + return 1; + } + return 0; +} + +static size_t match_multi_number(unsigned long num, char c, const char *date, char *end, struct tm *tm) +{ + time_t now; + struct tm now_tm; + struct tm *refuse_future; + long num2, num3; + + num2 = strtol(end+1, &end, 10); + num3 = -1; + if (*end == c && isdigit(end[1])) + num3 = strtol(end+1, &end, 10); + + /* Time? Date? */ + switch (c) { + case ':': + if (num3 < 0) + num3 = 0; + if (num < 25 && num2 >= 0 && num2 < 60 && num3 >= 0 && num3 <= 60) { + tm->tm_hour = num; + tm->tm_min = num2; + tm->tm_sec = num3; + break; + } + return 0; + + case '-': + case '/': + case '.': + now = time(NULL); + refuse_future = NULL; + if (p_gmtime_r(&now, &now_tm)) + refuse_future = &now_tm; + + if (num > 70) { + /* yyyy-mm-dd? */ + if (is_date(num, num2, num3, refuse_future, now, tm)) + break; + /* yyyy-dd-mm? */ + if (is_date(num, num3, num2, refuse_future, now, tm)) + break; + } + /* Our eastern European friends say dd.mm.yy[yy] + * is the norm there, so giving precedence to + * mm/dd/yy[yy] form only when separator is not '.' + */ + if (c != '.' && + is_date(num3, num, num2, refuse_future, now, tm)) + break; + /* European dd.mm.yy[yy] or funny US dd/mm/yy[yy] */ + if (is_date(num3, num2, num, refuse_future, now, tm)) + break; + /* Funny European mm.dd.yy */ + if (c == '.' && + is_date(num3, num, num2, refuse_future, now, tm)) + break; + return 0; + } + return end - date; +} + +/* + * Have we filled in any part of the time/date yet? + * We just do a binary 'and' to see if the sign bit + * is set in all the values. + */ +static int nodate(struct tm *tm) +{ + return (tm->tm_year & + tm->tm_mon & + tm->tm_mday & + tm->tm_hour & + tm->tm_min & + tm->tm_sec) < 0; +} + +/* + * We've seen a digit. Time? Year? Date? + */ +static size_t match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt) +{ + size_t n; + char *end; + unsigned long num; + + num = strtoul(date, &end, 10); + + /* + * Seconds since 1970? We trigger on that for any numbers with + * more than 8 digits. This is because we don't want to rule out + * numbers like 20070606 as a YYYYMMDD date. + */ + if (num >= 100000000 && nodate(tm)) { + time_t time = num; + if (p_gmtime_r(&time, tm)) { + *tm_gmt = 1; + return end - date; + } + } + + /* + * Check for special formats: num[-.:/]num[same]num + */ + switch (*end) { + case ':': + case '.': + case '/': + case '-': + if (isdigit(end[1])) { + size_t match = match_multi_number(num, *end, date, end, tm); + if (match) + return match; + } + } + + /* + * None of the special formats? Try to guess what + * the number meant. We use the number of digits + * to make a more educated guess.. + */ + n = 0; + do { + n++; + } while (isdigit(date[n])); + + /* Four-digit year or a timezone? */ + if (n == 4) { + if (num <= 1400 && *offset == -1) { + unsigned int minutes = num % 100; + unsigned int hours = num / 100; + *offset = hours*60 + minutes; + } else if (num > 1900 && num < 2100) + tm->tm_year = num - 1900; + return n; + } + + /* + * Ignore lots of numerals. We took care of 4-digit years above. + * Days or months must be one or two digits. + */ + if (n > 2) + return n; + + /* + * NOTE! We will give precedence to day-of-month over month or + * year numbers in the 1-12 range. So 05 is always "mday 5", + * unless we already have a mday.. + * + * IOW, 01 Apr 05 parses as "April 1st, 2005". + */ + if (num > 0 && num < 32 && tm->tm_mday < 0) { + tm->tm_mday = num; + return n; + } + + /* Two-digit year? */ + if (n == 2 && tm->tm_year < 0) { + if (num < 10 && tm->tm_mday >= 0) { + tm->tm_year = num + 100; + return n; + } + if (num >= 70) { + tm->tm_year = num; + return n; + } + } + + if (num > 0 && num < 13 && tm->tm_mon < 0) + tm->tm_mon = num-1; + + return n; +} + +static size_t match_tz(const char *date, int *offp) +{ + char *end; + int hour = strtoul(date + 1, &end, 10); + size_t n = end - (date + 1); + int min = 0; + + if (n == 4) { + /* hhmm */ + min = hour % 100; + hour = hour / 100; + } else if (n != 2) { + min = 99; /* random stuff */ + } else if (*end == ':') { + /* hh:mm? */ + min = strtoul(end + 1, &end, 10); + if (end - (date + 1) != 5) + min = 99; /* random stuff */ + } /* otherwise we parsed "hh" */ + + /* + * Don't accept any random stuff. Even though some places have + * offset larger than 12 hours (e.g. Pacific/Kiritimati is at + * UTC+14), there is something wrong if hour part is much + * larger than that. We might also want to check that the + * minutes are divisible by 15 or something too. (Offset of + * Kathmandu, Nepal is UTC+5:45) + */ + if (min < 60 && hour < 24) { + int offset = hour * 60 + min; + if (*date == '-') + offset = -offset; + *offp = offset; + } + return end - date; +} + +/* + * Parse a string like "0 +0000" as ancient timestamp near epoch, but + * only when it appears not as part of any other string. + */ +static int match_object_header_date(const char *date, git_time_t *timestamp, int *offset) +{ + char *end; + unsigned long stamp; + int ofs; + + if (*date < '0' || '9' <= *date) + return -1; + stamp = strtoul(date, &end, 10); + if (*end != ' ' || stamp == ULONG_MAX || (end[1] != '+' && end[1] != '-')) + return -1; + date = end + 2; + ofs = strtol(date, &end, 10); + if ((*end != '\0' && (*end != '\n')) || end != date + 4) + return -1; + ofs = (ofs / 100) * 60 + (ofs % 100); + if (date[-1] == '-') + ofs = -ofs; + *timestamp = stamp; + *offset = ofs; + return 0; +} + +/* Gr. strptime is crap for this; it doesn't have a way to require RFC2822 + (i.e. English) day/month names, and it doesn't work correctly with %z. */ +static int parse_date_basic(const char *date, git_time_t *timestamp, int *offset) +{ + struct tm tm; + int tm_gmt; + git_time_t dummy_timestamp; + int dummy_offset; + + if (!timestamp) + timestamp = &dummy_timestamp; + if (!offset) + offset = &dummy_offset; + + memset(&tm, 0, sizeof(tm)); + tm.tm_year = -1; + tm.tm_mon = -1; + tm.tm_mday = -1; + tm.tm_isdst = -1; + tm.tm_hour = -1; + tm.tm_min = -1; + tm.tm_sec = -1; + *offset = -1; + tm_gmt = 0; + + if (*date == '@' && + !match_object_header_date(date + 1, timestamp, offset)) + return 0; /* success */ + for (;;) { + size_t match = 0; + unsigned char c = *date; + + /* Stop at end of string or newline */ + if (!c || c == '\n') + break; + + if (isalpha(c)) + match = match_alpha(date, &tm, offset); + else if (isdigit(c)) + match = match_digit(date, &tm, offset, &tm_gmt); + else if ((c == '-' || c == '+') && isdigit(date[1])) + match = match_tz(date, offset); + + if (!match) { + /* BAD */ + match = 1; + } + + date += match; + } + + /* mktime uses local timezone */ + *timestamp = tm_to_time_t(&tm); + if (*offset == -1) + *offset = (int)((time_t)*timestamp - mktime(&tm)) / 60; + + if (*timestamp == (git_time_t)-1) + return -1; + + if (!tm_gmt) + *timestamp -= *offset * 60; + return 0; /* success */ +} + + +/* + * Relative time update (eg "2 days ago"). If we haven't set the time + * yet, we need to set it from current time. + */ +static git_time_t update_tm(struct tm *tm, struct tm *now, unsigned long sec) +{ + time_t n; + + if (tm->tm_mday < 0) + tm->tm_mday = now->tm_mday; + if (tm->tm_mon < 0) + tm->tm_mon = now->tm_mon; + if (tm->tm_year < 0) { + tm->tm_year = now->tm_year; + if (tm->tm_mon > now->tm_mon) + tm->tm_year--; + } + + n = mktime(tm) - sec; + p_localtime_r(&n, tm); + return n; +} + +static void date_now(struct tm *tm, struct tm *now, int *num) +{ + GIT_UNUSED(num); + update_tm(tm, now, 0); +} + +static void date_yesterday(struct tm *tm, struct tm *now, int *num) +{ + GIT_UNUSED(num); + update_tm(tm, now, 24*60*60); +} + +static void date_time(struct tm *tm, struct tm *now, int hour) +{ + if (tm->tm_hour < hour) + date_yesterday(tm, now, NULL); + tm->tm_hour = hour; + tm->tm_min = 0; + tm->tm_sec = 0; +} + +static void date_midnight(struct tm *tm, struct tm *now, int *num) +{ + GIT_UNUSED(num); + date_time(tm, now, 0); +} + +static void date_noon(struct tm *tm, struct tm *now, int *num) +{ + GIT_UNUSED(num); + date_time(tm, now, 12); +} + +static void date_tea(struct tm *tm, struct tm *now, int *num) +{ + GIT_UNUSED(num); + date_time(tm, now, 17); +} + +static void date_pm(struct tm *tm, struct tm *now, int *num) +{ + int hour, n = *num; + *num = 0; + GIT_UNUSED(now); + + hour = tm->tm_hour; + if (n) { + hour = n; + tm->tm_min = 0; + tm->tm_sec = 0; + } + tm->tm_hour = (hour % 12) + 12; +} + +static void date_am(struct tm *tm, struct tm *now, int *num) +{ + int hour, n = *num; + *num = 0; + GIT_UNUSED(now); + + hour = tm->tm_hour; + if (n) { + hour = n; + tm->tm_min = 0; + tm->tm_sec = 0; + } + tm->tm_hour = (hour % 12); +} + +static void date_never(struct tm *tm, struct tm *now, int *num) +{ + time_t n = 0; + GIT_UNUSED(now); + GIT_UNUSED(num); + p_localtime_r(&n, tm); +} + +static const struct special { + const char *name; + void (*fn)(struct tm *, struct tm *, int *); +} special[] = { + { "yesterday", date_yesterday }, + { "noon", date_noon }, + { "midnight", date_midnight }, + { "tea", date_tea }, + { "PM", date_pm }, + { "AM", date_am }, + { "never", date_never }, + { "now", date_now }, + { NULL } +}; + +static const char *number_name[] = { + "zero", "one", "two", "three", "four", + "five", "six", "seven", "eight", "nine", "ten", +}; + +static const struct typelen { + const char *type; + int length; +} typelen[] = { + { "seconds", 1 }, + { "minutes", 60 }, + { "hours", 60*60 }, + { "days", 24*60*60 }, + { "weeks", 7*24*60*60 }, + { NULL } +}; + +static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm *now, int *num, int *touched) +{ + const struct typelen *tl; + const struct special *s; + const char *end = date; + int i; + + while (isalpha(*++end)) + /* scan to non-alpha */; + + for (i = 0; i < 12; i++) { + size_t match = match_string(date, month_names[i]); + if (match >= 3) { + tm->tm_mon = i; + *touched = 1; + return end; + } + } + + for (s = special; s->name; s++) { + size_t len = strlen(s->name); + if (match_string(date, s->name) == len) { + s->fn(tm, now, num); + *touched = 1; + return end; + } + } + + if (!*num) { + for (i = 1; i < 11; i++) { + size_t len = strlen(number_name[i]); + if (match_string(date, number_name[i]) == len) { + *num = i; + *touched = 1; + return end; + } + } + if (match_string(date, "last") == 4) { + *num = 1; + *touched = 1; + } + return end; + } + + tl = typelen; + while (tl->type) { + size_t len = strlen(tl->type); + if (match_string(date, tl->type) >= len-1) { + update_tm(tm, now, tl->length * *num); + *num = 0; + *touched = 1; + return end; + } + tl++; + } + + for (i = 0; i < 7; i++) { + size_t match = match_string(date, weekday_names[i]); + if (match >= 3) { + int diff, n = *num -1; + *num = 0; + + diff = tm->tm_wday - i; + if (diff <= 0) + n++; + diff += 7*n; + + update_tm(tm, now, diff * 24 * 60 * 60); + *touched = 1; + return end; + } + } + + if (match_string(date, "months") >= 5) { + int n; + update_tm(tm, now, 0); /* fill in date fields if needed */ + n = tm->tm_mon - *num; + *num = 0; + while (n < 0) { + n += 12; + tm->tm_year--; + } + tm->tm_mon = n; + *touched = 1; + return end; + } + + if (match_string(date, "years") >= 4) { + update_tm(tm, now, 0); /* fill in date fields if needed */ + tm->tm_year -= *num; + *num = 0; + *touched = 1; + return end; + } + + return end; +} + +static const char *approxidate_digit(const char *date, struct tm *tm, int *num) +{ + char *end; + unsigned long number = strtoul(date, &end, 10); + + switch (*end) { + case ':': + case '.': + case '/': + case '-': + if (isdigit(end[1])) { + size_t match = match_multi_number(number, *end, date, end, tm); + if (match) + return date + match; + } + } + + /* Accept zero-padding only for small numbers ("Dec 02", never "Dec 0002") */ + if (date[0] != '0' || end - date <= 2) + *num = number; + return end; +} + +/* + * Do we have a pending number at the end, or when + * we see a new one? Let's assume it's a month day, + * as in "Dec 6, 1992" + */ +static void pending_number(struct tm *tm, int *num) +{ + int number = *num; + + if (number) { + *num = 0; + if (tm->tm_mday < 0 && number < 32) + tm->tm_mday = number; + else if (tm->tm_mon < 0 && number < 13) + tm->tm_mon = number-1; + else if (tm->tm_year < 0) { + if (number > 1969 && number < 2100) + tm->tm_year = number - 1900; + else if (number > 69 && number < 100) + tm->tm_year = number; + else if (number < 38) + tm->tm_year = 100 + number; + /* We mess up for number = 00 ? */ + } + } +} + +static git_time_t approxidate_str(const char *date, + time_t time_sec, + int *error_ret) +{ + int number = 0; + int touched = 0; + struct tm tm = {0}, now; + + p_localtime_r(&time_sec, &tm); + now = tm; + + tm.tm_year = -1; + tm.tm_mon = -1; + tm.tm_mday = -1; + + for (;;) { + unsigned char c = *date; + if (!c) + break; + date++; + if (isdigit(c)) { + pending_number(&tm, &number); + date = approxidate_digit(date-1, &tm, &number); + touched = 1; + continue; + } + if (isalpha(c)) + date = approxidate_alpha(date-1, &tm, &now, &number, &touched); + } + pending_number(&tm, &number); + if (!touched) + *error_ret = 1; + return update_tm(&tm, &now, 0); +} + +int git__date_parse(git_time_t *out, const char *date) +{ + time_t time_sec; + git_time_t timestamp; + int offset, error_ret=0; + + if (!parse_date_basic(date, ×tamp, &offset)) { + *out = timestamp; + return 0; + } + + if (time(&time_sec) == -1) + return -1; + + *out = approxidate_str(date, time_sec, &error_ret); + return error_ret; +} + +int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date) +{ + int written; + struct tm gmt; + time_t t; + + assert(out && date); + + t = (time_t) (date->time + date->offset * 60); + + if (p_gmtime_r (&t, &gmt) == NULL) + return -1; + + written = p_snprintf(out, len, "%.3s, %u %.3s %.4u %02u:%02u:%02u %+03d%02d", + weekday_names[gmt.tm_wday], + gmt.tm_mday, + month_names[gmt.tm_mon], + gmt.tm_year + 1900, + gmt.tm_hour, gmt.tm_min, gmt.tm_sec, + date->offset / 60, date->offset % 60); + + if (written < 0 || (written > (int) len - 1)) + return -1; + + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.c b/deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.c new file mode 100644 index 000000000..89745faa0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.c @@ -0,0 +1,135 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "git2/odb.h" +#include "delta-apply.h" + +/* + * This file was heavily cribbed from BinaryDelta.java in JGit, which + * itself was heavily cribbed from patch-delta.c in the + * GIT project. The original delta patching code was written by + * Nicolas Pitre . + */ + +static int hdr_sz( + size_t *size, + const unsigned char **delta, + const unsigned char *end) +{ + const unsigned char *d = *delta; + size_t r = 0; + unsigned int c, shift = 0; + + do { + if (d == end) + return -1; + c = *d++; + r |= (c & 0x7f) << shift; + shift += 7; + } while (c & 0x80); + *delta = d; + *size = r; + return 0; +} + +int git__delta_read_header( + const unsigned char *delta, + size_t delta_len, + size_t *base_sz, + size_t *res_sz) +{ + const unsigned char *delta_end = delta + delta_len; + if ((hdr_sz(base_sz, &delta, delta_end) < 0) || + (hdr_sz(res_sz, &delta, delta_end) < 0)) + return -1; + return 0; +} + +int git__delta_apply( + git_rawobj *out, + const unsigned char *base, + size_t base_len, + const unsigned char *delta, + size_t delta_len) +{ + const unsigned char *delta_end = delta + delta_len; + size_t base_sz, res_sz, alloc_sz; + unsigned char *res_dp; + + /* Check that the base size matches the data we were given; + * if not we would underflow while accessing data from the + * base object, resulting in data corruption or segfault. + */ + if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) { + giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data"); + return -1; + } + + if (hdr_sz(&res_sz, &delta, delta_end) < 0) { + giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data"); + return -1; + } + + GITERR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1); + res_dp = git__malloc(alloc_sz); + GITERR_CHECK_ALLOC(res_dp); + + res_dp[res_sz] = '\0'; + out->data = res_dp; + out->len = res_sz; + + while (delta < delta_end) { + unsigned char cmd = *delta++; + if (cmd & 0x80) { + /* cmd is a copy instruction; copy from the base. + */ + size_t off = 0, len = 0; + + if (cmd & 0x01) off = *delta++; + if (cmd & 0x02) off |= *delta++ << 8; + if (cmd & 0x04) off |= *delta++ << 16; + if (cmd & 0x08) off |= *delta++ << 24; + + if (cmd & 0x10) len = *delta++; + if (cmd & 0x20) len |= *delta++ << 8; + if (cmd & 0x40) len |= *delta++ << 16; + if (!len) len = 0x10000; + + if (base_len < off + len || res_sz < len) + goto fail; + memcpy(res_dp, base + off, len); + res_dp += len; + res_sz -= len; + + } else if (cmd) { + /* cmd is a literal insert instruction; copy from + * the delta stream itself. + */ + if (delta_end - delta < cmd || res_sz < cmd) + goto fail; + memcpy(res_dp, delta, cmd); + delta += cmd; + res_dp += cmd; + res_sz -= cmd; + + } else { + /* cmd == 0 is reserved for future encodings. + */ + goto fail; + } + } + + if (delta != delta_end || res_sz) + goto fail; + return 0; + +fail: + git__free(out->data); + out->data = NULL; + giterr_set(GITERR_INVALID, "Failed to apply delta"); + return -1; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.h b/deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.h new file mode 100644 index 000000000..d7d99d04c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/delta-apply.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_delta_apply_h__ +#define INCLUDE_delta_apply_h__ + +#include "odb.h" + +/** + * Apply a git binary delta to recover the original content. + * + * @param out the output buffer to receive the original data. + * Only out->data and out->len are populated, as this is + * the only information available in the delta. + * @param base the base to copy from during copy instructions. + * @param base_len number of bytes available at base. + * @param delta the delta to execute copy/insert instructions from. + * @param delta_len total number of bytes in the delta. + * @return + * - 0 on a successful delta unpack. + * - GIT_ERROR if the delta is corrupt or doesn't match the base. + */ +extern int git__delta_apply( + git_rawobj *out, + const unsigned char *base, + size_t base_len, + const unsigned char *delta, + size_t delta_len); + +/** + * Read the header of a git binary delta. + * + * @param delta the delta to execute copy/insert instructions from. + * @param delta_len total number of bytes in the delta. + * @param base_sz pointer to store the base size field. + * @param res_sz pointer to store the result size field. + * @return + * - 0 on a successful decoding the header. + * - GIT_ERROR if the delta is corrupt. + */ +extern int git__delta_read_header( + const unsigned char *delta, + size_t delta_len, + size_t *base_sz, + size_t *res_sz); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/delta.c b/deps/libgit2-sys-0.2.17/libgit2/src/delta.c new file mode 100644 index 000000000..d72d820d8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/delta.c @@ -0,0 +1,443 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "delta.h" + +/* maximum hash entry list for the same hash bucket */ +#define HASH_LIMIT 64 + +#define RABIN_SHIFT 23 +#define RABIN_WINDOW 16 + +static const unsigned int T[256] = { + 0x00000000, 0xab59b4d1, 0x56b369a2, 0xfdeadd73, 0x063f6795, 0xad66d344, + 0x508c0e37, 0xfbd5bae6, 0x0c7ecf2a, 0xa7277bfb, 0x5acda688, 0xf1941259, + 0x0a41a8bf, 0xa1181c6e, 0x5cf2c11d, 0xf7ab75cc, 0x18fd9e54, 0xb3a42a85, + 0x4e4ef7f6, 0xe5174327, 0x1ec2f9c1, 0xb59b4d10, 0x48719063, 0xe32824b2, + 0x1483517e, 0xbfdae5af, 0x423038dc, 0xe9698c0d, 0x12bc36eb, 0xb9e5823a, + 0x440f5f49, 0xef56eb98, 0x31fb3ca8, 0x9aa28879, 0x6748550a, 0xcc11e1db, + 0x37c45b3d, 0x9c9defec, 0x6177329f, 0xca2e864e, 0x3d85f382, 0x96dc4753, + 0x6b369a20, 0xc06f2ef1, 0x3bba9417, 0x90e320c6, 0x6d09fdb5, 0xc6504964, + 0x2906a2fc, 0x825f162d, 0x7fb5cb5e, 0xd4ec7f8f, 0x2f39c569, 0x846071b8, + 0x798aaccb, 0xd2d3181a, 0x25786dd6, 0x8e21d907, 0x73cb0474, 0xd892b0a5, + 0x23470a43, 0x881ebe92, 0x75f463e1, 0xdeadd730, 0x63f67950, 0xc8afcd81, + 0x354510f2, 0x9e1ca423, 0x65c91ec5, 0xce90aa14, 0x337a7767, 0x9823c3b6, + 0x6f88b67a, 0xc4d102ab, 0x393bdfd8, 0x92626b09, 0x69b7d1ef, 0xc2ee653e, + 0x3f04b84d, 0x945d0c9c, 0x7b0be704, 0xd05253d5, 0x2db88ea6, 0x86e13a77, + 0x7d348091, 0xd66d3440, 0x2b87e933, 0x80de5de2, 0x7775282e, 0xdc2c9cff, + 0x21c6418c, 0x8a9ff55d, 0x714a4fbb, 0xda13fb6a, 0x27f92619, 0x8ca092c8, + 0x520d45f8, 0xf954f129, 0x04be2c5a, 0xafe7988b, 0x5432226d, 0xff6b96bc, + 0x02814bcf, 0xa9d8ff1e, 0x5e738ad2, 0xf52a3e03, 0x08c0e370, 0xa39957a1, + 0x584ced47, 0xf3155996, 0x0eff84e5, 0xa5a63034, 0x4af0dbac, 0xe1a96f7d, + 0x1c43b20e, 0xb71a06df, 0x4ccfbc39, 0xe79608e8, 0x1a7cd59b, 0xb125614a, + 0x468e1486, 0xedd7a057, 0x103d7d24, 0xbb64c9f5, 0x40b17313, 0xebe8c7c2, + 0x16021ab1, 0xbd5bae60, 0x6cb54671, 0xc7ecf2a0, 0x3a062fd3, 0x915f9b02, + 0x6a8a21e4, 0xc1d39535, 0x3c394846, 0x9760fc97, 0x60cb895b, 0xcb923d8a, + 0x3678e0f9, 0x9d215428, 0x66f4eece, 0xcdad5a1f, 0x3047876c, 0x9b1e33bd, + 0x7448d825, 0xdf116cf4, 0x22fbb187, 0x89a20556, 0x7277bfb0, 0xd92e0b61, + 0x24c4d612, 0x8f9d62c3, 0x7836170f, 0xd36fa3de, 0x2e857ead, 0x85dcca7c, + 0x7e09709a, 0xd550c44b, 0x28ba1938, 0x83e3ade9, 0x5d4e7ad9, 0xf617ce08, + 0x0bfd137b, 0xa0a4a7aa, 0x5b711d4c, 0xf028a99d, 0x0dc274ee, 0xa69bc03f, + 0x5130b5f3, 0xfa690122, 0x0783dc51, 0xacda6880, 0x570fd266, 0xfc5666b7, + 0x01bcbbc4, 0xaae50f15, 0x45b3e48d, 0xeeea505c, 0x13008d2f, 0xb85939fe, + 0x438c8318, 0xe8d537c9, 0x153feaba, 0xbe665e6b, 0x49cd2ba7, 0xe2949f76, + 0x1f7e4205, 0xb427f6d4, 0x4ff24c32, 0xe4abf8e3, 0x19412590, 0xb2189141, + 0x0f433f21, 0xa41a8bf0, 0x59f05683, 0xf2a9e252, 0x097c58b4, 0xa225ec65, + 0x5fcf3116, 0xf49685c7, 0x033df00b, 0xa86444da, 0x558e99a9, 0xfed72d78, + 0x0502979e, 0xae5b234f, 0x53b1fe3c, 0xf8e84aed, 0x17bea175, 0xbce715a4, + 0x410dc8d7, 0xea547c06, 0x1181c6e0, 0xbad87231, 0x4732af42, 0xec6b1b93, + 0x1bc06e5f, 0xb099da8e, 0x4d7307fd, 0xe62ab32c, 0x1dff09ca, 0xb6a6bd1b, + 0x4b4c6068, 0xe015d4b9, 0x3eb80389, 0x95e1b758, 0x680b6a2b, 0xc352defa, + 0x3887641c, 0x93ded0cd, 0x6e340dbe, 0xc56db96f, 0x32c6cca3, 0x999f7872, + 0x6475a501, 0xcf2c11d0, 0x34f9ab36, 0x9fa01fe7, 0x624ac294, 0xc9137645, + 0x26459ddd, 0x8d1c290c, 0x70f6f47f, 0xdbaf40ae, 0x207afa48, 0x8b234e99, + 0x76c993ea, 0xdd90273b, 0x2a3b52f7, 0x8162e626, 0x7c883b55, 0xd7d18f84, + 0x2c043562, 0x875d81b3, 0x7ab75cc0, 0xd1eee811 +}; + +static const unsigned int U[256] = { + 0x00000000, 0x7eb5200d, 0x5633f4cb, 0x2886d4c6, 0x073e5d47, 0x798b7d4a, + 0x510da98c, 0x2fb88981, 0x0e7cba8e, 0x70c99a83, 0x584f4e45, 0x26fa6e48, + 0x0942e7c9, 0x77f7c7c4, 0x5f711302, 0x21c4330f, 0x1cf9751c, 0x624c5511, + 0x4aca81d7, 0x347fa1da, 0x1bc7285b, 0x65720856, 0x4df4dc90, 0x3341fc9d, + 0x1285cf92, 0x6c30ef9f, 0x44b63b59, 0x3a031b54, 0x15bb92d5, 0x6b0eb2d8, + 0x4388661e, 0x3d3d4613, 0x39f2ea38, 0x4747ca35, 0x6fc11ef3, 0x11743efe, + 0x3eccb77f, 0x40799772, 0x68ff43b4, 0x164a63b9, 0x378e50b6, 0x493b70bb, + 0x61bda47d, 0x1f088470, 0x30b00df1, 0x4e052dfc, 0x6683f93a, 0x1836d937, + 0x250b9f24, 0x5bbebf29, 0x73386bef, 0x0d8d4be2, 0x2235c263, 0x5c80e26e, + 0x740636a8, 0x0ab316a5, 0x2b7725aa, 0x55c205a7, 0x7d44d161, 0x03f1f16c, + 0x2c4978ed, 0x52fc58e0, 0x7a7a8c26, 0x04cfac2b, 0x73e5d470, 0x0d50f47d, + 0x25d620bb, 0x5b6300b6, 0x74db8937, 0x0a6ea93a, 0x22e87dfc, 0x5c5d5df1, + 0x7d996efe, 0x032c4ef3, 0x2baa9a35, 0x551fba38, 0x7aa733b9, 0x041213b4, + 0x2c94c772, 0x5221e77f, 0x6f1ca16c, 0x11a98161, 0x392f55a7, 0x479a75aa, + 0x6822fc2b, 0x1697dc26, 0x3e1108e0, 0x40a428ed, 0x61601be2, 0x1fd53bef, + 0x3753ef29, 0x49e6cf24, 0x665e46a5, 0x18eb66a8, 0x306db26e, 0x4ed89263, + 0x4a173e48, 0x34a21e45, 0x1c24ca83, 0x6291ea8e, 0x4d29630f, 0x339c4302, + 0x1b1a97c4, 0x65afb7c9, 0x446b84c6, 0x3adea4cb, 0x1258700d, 0x6ced5000, + 0x4355d981, 0x3de0f98c, 0x15662d4a, 0x6bd30d47, 0x56ee4b54, 0x285b6b59, + 0x00ddbf9f, 0x7e689f92, 0x51d01613, 0x2f65361e, 0x07e3e2d8, 0x7956c2d5, + 0x5892f1da, 0x2627d1d7, 0x0ea10511, 0x7014251c, 0x5facac9d, 0x21198c90, + 0x099f5856, 0x772a785b, 0x4c921c31, 0x32273c3c, 0x1aa1e8fa, 0x6414c8f7, + 0x4bac4176, 0x3519617b, 0x1d9fb5bd, 0x632a95b0, 0x42eea6bf, 0x3c5b86b2, + 0x14dd5274, 0x6a687279, 0x45d0fbf8, 0x3b65dbf5, 0x13e30f33, 0x6d562f3e, + 0x506b692d, 0x2ede4920, 0x06589de6, 0x78edbdeb, 0x5755346a, 0x29e01467, + 0x0166c0a1, 0x7fd3e0ac, 0x5e17d3a3, 0x20a2f3ae, 0x08242768, 0x76910765, + 0x59298ee4, 0x279caee9, 0x0f1a7a2f, 0x71af5a22, 0x7560f609, 0x0bd5d604, + 0x235302c2, 0x5de622cf, 0x725eab4e, 0x0ceb8b43, 0x246d5f85, 0x5ad87f88, + 0x7b1c4c87, 0x05a96c8a, 0x2d2fb84c, 0x539a9841, 0x7c2211c0, 0x029731cd, + 0x2a11e50b, 0x54a4c506, 0x69998315, 0x172ca318, 0x3faa77de, 0x411f57d3, + 0x6ea7de52, 0x1012fe5f, 0x38942a99, 0x46210a94, 0x67e5399b, 0x19501996, + 0x31d6cd50, 0x4f63ed5d, 0x60db64dc, 0x1e6e44d1, 0x36e89017, 0x485db01a, + 0x3f77c841, 0x41c2e84c, 0x69443c8a, 0x17f11c87, 0x38499506, 0x46fcb50b, + 0x6e7a61cd, 0x10cf41c0, 0x310b72cf, 0x4fbe52c2, 0x67388604, 0x198da609, + 0x36352f88, 0x48800f85, 0x6006db43, 0x1eb3fb4e, 0x238ebd5d, 0x5d3b9d50, + 0x75bd4996, 0x0b08699b, 0x24b0e01a, 0x5a05c017, 0x728314d1, 0x0c3634dc, + 0x2df207d3, 0x534727de, 0x7bc1f318, 0x0574d315, 0x2acc5a94, 0x54797a99, + 0x7cffae5f, 0x024a8e52, 0x06852279, 0x78300274, 0x50b6d6b2, 0x2e03f6bf, + 0x01bb7f3e, 0x7f0e5f33, 0x57888bf5, 0x293dabf8, 0x08f998f7, 0x764cb8fa, + 0x5eca6c3c, 0x207f4c31, 0x0fc7c5b0, 0x7172e5bd, 0x59f4317b, 0x27411176, + 0x1a7c5765, 0x64c97768, 0x4c4fa3ae, 0x32fa83a3, 0x1d420a22, 0x63f72a2f, + 0x4b71fee9, 0x35c4dee4, 0x1400edeb, 0x6ab5cde6, 0x42331920, 0x3c86392d, + 0x133eb0ac, 0x6d8b90a1, 0x450d4467, 0x3bb8646a +}; + +struct index_entry { + const unsigned char *ptr; + unsigned int val; + struct index_entry *next; +}; + +struct git_delta_index { + unsigned long memsize; + const void *src_buf; + unsigned long src_size; + unsigned int hash_mask; + struct index_entry *hash[GIT_FLEX_ARRAY]; +}; + +static int lookup_index_alloc( + void **out, unsigned long *out_len, size_t entries, size_t hash_count) +{ + size_t entries_len, hash_len, index_len; + + GITERR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry)); + GITERR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *)); + + GITERR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len); + GITERR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len); + + if (!git__is_ulong(index_len)) { + giterr_set(GITERR_NOMEMORY, "Overly large delta"); + return -1; + } + + *out = git__malloc(index_len); + GITERR_CHECK_ALLOC(*out); + + *out_len = index_len; + return 0; +} + +struct git_delta_index * +git_delta_create_index(const void *buf, unsigned long bufsize) +{ + unsigned int i, hsize, hmask, entries, prev_val, *hash_count; + const unsigned char *data, *buffer = buf; + struct git_delta_index *index; + struct index_entry *entry, **hash; + void *mem; + unsigned long memsize; + + if (!buf || !bufsize) + return NULL; + + /* Determine index hash size. Note that indexing skips the + first byte to allow for optimizing the rabin polynomial + initialization in create_delta(). */ + entries = (unsigned int)(bufsize - 1) / RABIN_WINDOW; + if (bufsize >= 0xffffffffUL) { + /* + * Current delta format can't encode offsets into + * reference buffer with more than 32 bits. + */ + entries = 0xfffffffeU / RABIN_WINDOW; + } + hsize = entries / 4; + for (i = 4; i < 31 && (1u << i) < hsize; i++); + hsize = 1 << i; + hmask = hsize - 1; + + if (lookup_index_alloc(&mem, &memsize, entries, hsize) < 0) + return NULL; + + index = mem; + mem = index->hash; + hash = mem; + mem = hash + hsize; + entry = mem; + + index->memsize = memsize; + index->src_buf = buf; + index->src_size = bufsize; + index->hash_mask = hmask; + memset(hash, 0, hsize * sizeof(*hash)); + + /* allocate an array to count hash entries */ + hash_count = git__calloc(hsize, sizeof(*hash_count)); + if (!hash_count) { + git__free(index); + return NULL; + } + + /* then populate the index */ + prev_val = ~0; + for (data = buffer + entries * RABIN_WINDOW - RABIN_WINDOW; + data >= buffer; + data -= RABIN_WINDOW) { + unsigned int val = 0; + for (i = 1; i <= RABIN_WINDOW; i++) + val = ((val << 8) | data[i]) ^ T[val >> RABIN_SHIFT]; + if (val == prev_val) { + /* keep the lowest of consecutive identical blocks */ + entry[-1].ptr = data + RABIN_WINDOW; + } else { + prev_val = val; + i = val & hmask; + entry->ptr = data + RABIN_WINDOW; + entry->val = val; + entry->next = hash[i]; + hash[i] = entry++; + hash_count[i]++; + } + } + + /* + * Determine a limit on the number of entries in the same hash + * bucket. This guard us against patological data sets causing + * really bad hash distribution with most entries in the same hash + * bucket that would bring us to O(m*n) computing costs (m and n + * corresponding to reference and target buffer sizes). + * + * Make sure none of the hash buckets has more entries than + * we're willing to test. Otherwise we cull the entry list + * uniformly to still preserve a good repartition across + * the reference buffer. + */ + for (i = 0; i < hsize; i++) { + if (hash_count[i] < HASH_LIMIT) + continue; + + entry = hash[i]; + do { + struct index_entry *keep = entry; + int skip = hash_count[i] / HASH_LIMIT / 2; + do { + entry = entry->next; + } while(--skip && entry); + keep->next = entry; + } while (entry); + } + git__free(hash_count); + + return index; +} + +void git_delta_free_index(struct git_delta_index *index) +{ + git__free(index); +} + +unsigned long git_delta_sizeof_index(struct git_delta_index *index) +{ + if (index) + return index->memsize; + else + return 0; +} + +/* + * The maximum size for any opcode sequence, including the initial header + * plus rabin window plus biggest copy. + */ +#define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7) + +void * +git_delta_create( + const struct git_delta_index *index, + const void *trg_buf, + unsigned long trg_size, + unsigned long *delta_size, + unsigned long max_size) +{ + unsigned int i, outpos, outsize, moff, msize, val; + int inscnt; + const unsigned char *ref_data, *ref_top, *data, *top; + unsigned char *out; + + if (!trg_buf || !trg_size) + return NULL; + + outpos = 0; + outsize = 8192; + if (max_size && outsize >= max_size) + outsize = (unsigned int)(max_size + MAX_OP_SIZE + 1); + out = git__malloc(outsize); + if (!out) + return NULL; + + /* store reference buffer size */ + i = index->src_size; + while (i >= 0x80) { + out[outpos++] = i | 0x80; + i >>= 7; + } + out[outpos++] = i; + + /* store target buffer size */ + i = trg_size; + while (i >= 0x80) { + out[outpos++] = i | 0x80; + i >>= 7; + } + out[outpos++] = i; + + ref_data = index->src_buf; + ref_top = ref_data + index->src_size; + data = trg_buf; + top = (const unsigned char *) trg_buf + trg_size; + + outpos++; + val = 0; + for (i = 0; i < RABIN_WINDOW && data < top; i++, data++) { + out[outpos++] = *data; + val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT]; + } + inscnt = i; + + moff = 0; + msize = 0; + while (data < top) { + if (msize < 4096) { + struct index_entry *entry; + val ^= U[data[-RABIN_WINDOW]]; + val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT]; + i = val & index->hash_mask; + for (entry = index->hash[i]; entry; entry = entry->next) { + const unsigned char *ref = entry->ptr; + const unsigned char *src = data; + unsigned int ref_size = (unsigned int)(ref_top - ref); + if (entry->val != val) + continue; + if (ref_size > (unsigned int)(top - src)) + ref_size = (unsigned int)(top - src); + if (ref_size <= msize) + break; + while (ref_size-- && *src++ == *ref) + ref++; + if (msize < (unsigned int)(ref - entry->ptr)) { + /* this is our best match so far */ + msize = (unsigned int)(ref - entry->ptr); + moff = (unsigned int)(entry->ptr - ref_data); + if (msize >= 4096) /* good enough */ + break; + } + } + } + + if (msize < 4) { + if (!inscnt) + outpos++; + out[outpos++] = *data++; + inscnt++; + if (inscnt == 0x7f) { + out[outpos - inscnt - 1] = inscnt; + inscnt = 0; + } + msize = 0; + } else { + unsigned int left; + unsigned char *op; + + if (inscnt) { + while (moff && ref_data[moff-1] == data[-1]) { + /* we can match one byte back */ + msize++; + moff--; + data--; + outpos--; + if (--inscnt) + continue; + outpos--; /* remove count slot */ + inscnt--; /* make it -1 */ + break; + } + out[outpos - inscnt - 1] = inscnt; + inscnt = 0; + } + + /* A copy op is currently limited to 64KB (pack v2) */ + left = (msize < 0x10000) ? 0 : (msize - 0x10000); + msize -= left; + + op = out + outpos++; + i = 0x80; + + if (moff & 0x000000ff) + out[outpos++] = moff >> 0, i |= 0x01; + if (moff & 0x0000ff00) + out[outpos++] = moff >> 8, i |= 0x02; + if (moff & 0x00ff0000) + out[outpos++] = moff >> 16, i |= 0x04; + if (moff & 0xff000000) + out[outpos++] = moff >> 24, i |= 0x08; + + if (msize & 0x00ff) + out[outpos++] = msize >> 0, i |= 0x10; + if (msize & 0xff00) + out[outpos++] = msize >> 8, i |= 0x20; + + *op = i; + + data += msize; + moff += msize; + msize = left; + + if (msize < 4096) { + int j; + val = 0; + for (j = -RABIN_WINDOW; j < 0; j++) + val = ((val << 8) | data[j]) + ^ T[val >> RABIN_SHIFT]; + } + } + + if (outpos >= outsize - MAX_OP_SIZE) { + void *tmp = out; + outsize = outsize * 3 / 2; + if (max_size && outsize >= max_size) + outsize = max_size + MAX_OP_SIZE + 1; + if (max_size && outpos > max_size) + break; + out = git__realloc(out, outsize); + if (!out) { + git__free(tmp); + return NULL; + } + } + } + + if (inscnt) + out[outpos - inscnt - 1] = inscnt; + + if (max_size && outpos > max_size) { + git__free(out); + return NULL; + } + + *delta_size = outpos; + return out; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/delta.h b/deps/libgit2-sys-0.2.17/libgit2/src/delta.h new file mode 100644 index 000000000..4ca327992 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/delta.h @@ -0,0 +1,114 @@ +/* + * diff-delta code taken from git.git. See diff-delta.c for details. + * + */ +#ifndef INCLUDE_git_delta_h__ +#define INCLUDE_git_delta_h__ + +#include "common.h" + +/* opaque object for delta index */ +struct git_delta_index; + +/* + * create_delta_index: compute index data from given buffer + * + * This returns a pointer to a struct delta_index that should be passed to + * subsequent create_delta() calls, or to free_delta_index(). A NULL pointer + * is returned on failure. The given buffer must not be freed nor altered + * before free_delta_index() is called. The returned pointer must be freed + * using free_delta_index(). + */ +extern struct git_delta_index * +git_delta_create_index(const void *buf, unsigned long bufsize); + +/* + * free_delta_index: free the index created by create_delta_index() + * + * Given pointer must be what create_delta_index() returned, or NULL. + */ +extern void git_delta_free_index(struct git_delta_index *index); + +/* + * sizeof_delta_index: returns memory usage of delta index + * + * Given pointer must be what create_delta_index() returned, or NULL. + */ +extern unsigned long git_delta_sizeof_index(struct git_delta_index *index); + +/* + * create_delta: create a delta from given index for the given buffer + * + * This function may be called multiple times with different buffers using + * the same delta_index pointer. If max_delta_size is non-zero and the + * resulting delta is to be larger than max_delta_size then NULL is returned. + * On success, a non-NULL pointer to the buffer with the delta data is + * returned and *delta_size is updated with its size. The returned buffer + * must be freed by the caller. + */ +extern void *git_delta_create( + const struct git_delta_index *index, + const void *buf, + unsigned long bufsize, + unsigned long *delta_size, + unsigned long max_delta_size); + +/* + * diff_delta: create a delta from source buffer to target buffer + * + * If max_delta_size is non-zero and the resulting delta is to be larger + * than max_delta_size then NULL is returned. On success, a non-NULL + * pointer to the buffer with the delta data is returned and *delta_size is + * updated with its size. The returned buffer must be freed by the caller. + */ +GIT_INLINE(void *) git_delta( + const void *src_buf, unsigned long src_bufsize, + const void *trg_buf, unsigned long trg_bufsize, + unsigned long *delta_size, + unsigned long max_delta_size) +{ + struct git_delta_index *index = git_delta_create_index(src_buf, src_bufsize); + if (index) { + void *delta = git_delta_create( + index, trg_buf, trg_bufsize, delta_size, max_delta_size); + git_delta_free_index(index); + return delta; + } + return NULL; +} + +/* + * patch_delta: recreate target buffer given source buffer and delta data + * + * On success, a non-NULL pointer to the target buffer is returned and + * *trg_bufsize is updated with its size. On failure a NULL pointer is + * returned. The returned buffer must be freed by the caller. + */ +extern void *git_delta_patch( + const void *src_buf, unsigned long src_size, + const void *delta_buf, unsigned long delta_size, + unsigned long *dst_size); + +/* the smallest possible delta size is 4 bytes */ +#define GIT_DELTA_SIZE_MIN 4 + +/* + * This must be called twice on the delta data buffer, first to get the + * expected source buffer size, and again to get the target buffer size. + */ +GIT_INLINE(unsigned long) git_delta_get_hdr_size( + const unsigned char **datap, const unsigned char *top) +{ + const unsigned char *data = *datap; + unsigned long cmd, size = 0; + int i = 0; + do { + cmd = *data++; + size |= (cmd & 0x7f) << i; + i += 7; + } while (cmd & 0x80 && data < top); + *datap = data; + return size; +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/describe.c b/deps/libgit2-sys-0.2.17/libgit2/src/describe.c new file mode 100644 index 000000000..68bac2d2f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/describe.c @@ -0,0 +1,892 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2/describe.h" +#include "git2/strarray.h" +#include "git2/diff.h" +#include "git2/status.h" + +#include "common.h" +#include "commit.h" +#include "commit_list.h" +#include "oidmap.h" +#include "refs.h" +#include "revwalk.h" +#include "tag.h" +#include "vector.h" +#include "repository.h" + +GIT__USE_OIDMAP; + +/* Ported from https://github.com/git/git/blob/89dde7882f71f846ccd0359756d27bebc31108de/builtin/describe.c */ + +struct commit_name { + git_tag *tag; + unsigned prio:2; /* annotated tag = 2, tag = 1, head = 0 */ + unsigned name_checked:1; + git_oid sha1; + char *path; + + /* Khash workaround. They original key has to still be reachable */ + git_oid peeled; +}; + +static void *oidmap_value_bykey(git_oidmap *map, const git_oid *key) +{ + khint_t pos = git_oidmap_lookup_index(map, key); + + if (!git_oidmap_valid_index(map, pos)) + return NULL; + + return git_oidmap_value_at(map, pos); +} + +static struct commit_name *find_commit_name( + git_oidmap *names, + const git_oid *peeled) +{ + return (struct commit_name *)(oidmap_value_bykey(names, peeled)); +} + +static int replace_name( + git_tag **tag, + git_repository *repo, + struct commit_name *e, + unsigned int prio, + const git_oid *sha1) +{ + git_time_t e_time = 0, t_time = 0; + + if (!e || e->prio < prio) + return 1; + + if (e->prio == 2 && prio == 2) { + /* Multiple annotated tags point to the same commit. + * Select one to keep based upon their tagger date. + */ + git_tag *t = NULL; + + if (!e->tag) { + if (git_tag_lookup(&t, repo, &e->sha1) < 0) + return 1; + e->tag = t; + } + + if (git_tag_lookup(&t, repo, sha1) < 0) + return 0; + + *tag = t; + + if (e->tag->tagger) + e_time = e->tag->tagger->when.time; + + if (t->tagger) + t_time = t->tagger->when.time; + + if (e_time < t_time) + return 1; + } + + return 0; +} + +static int add_to_known_names( + git_repository *repo, + git_oidmap *names, + const char *path, + const git_oid *peeled, + unsigned int prio, + const git_oid *sha1) +{ + struct commit_name *e = find_commit_name(names, peeled); + bool found = (e != NULL); + + git_tag *tag = NULL; + if (replace_name(&tag, repo, e, prio, sha1)) { + if (!found) { + e = git__malloc(sizeof(struct commit_name)); + GITERR_CHECK_ALLOC(e); + + e->path = NULL; + e->tag = NULL; + } + + if (e->tag) + git_tag_free(e->tag); + e->tag = tag; + e->prio = prio; + e->name_checked = 0; + git_oid_cpy(&e->sha1, sha1); + git__free(e->path); + e->path = git__strdup(path); + git_oid_cpy(&e->peeled, peeled); + + if (!found) { + int ret; + + git_oidmap_insert(names, &e->peeled, e, ret); + if (ret < 0) + return -1; + } + } + else + git_tag_free(tag); + + return 0; +} + +static int retrieve_peeled_tag_or_object_oid( + git_oid *peeled_out, + git_oid *ref_target_out, + git_repository *repo, + const char *refname) +{ + git_reference *ref; + git_object *peeled = NULL; + int error; + + if ((error = git_reference_lookup_resolved(&ref, repo, refname, -1)) < 0) + return error; + + if ((error = git_reference_peel(&peeled, ref, GIT_OBJ_ANY)) < 0) + goto cleanup; + + git_oid_cpy(ref_target_out, git_reference_target(ref)); + git_oid_cpy(peeled_out, git_object_id(peeled)); + + if (git_oid_cmp(ref_target_out, peeled_out) != 0) + error = 1; /* The reference was pointing to a annotated tag */ + else + error = 0; /* Any other object */ + +cleanup: + git_reference_free(ref); + git_object_free(peeled); + return error; +} + +struct git_describe_result { + int dirty; + int exact_match; + int fallback_to_id; + git_oid commit_id; + git_repository *repo; + struct commit_name *name; + struct possible_tag *tag; +}; + +struct get_name_data +{ + git_describe_options *opts; + git_repository *repo; + git_oidmap *names; + git_describe_result *result; +}; + +static int commit_name_dup(struct commit_name **out, struct commit_name *in) +{ + struct commit_name *name; + + name = git__malloc(sizeof(struct commit_name)); + GITERR_CHECK_ALLOC(name); + + memcpy(name, in, sizeof(struct commit_name)); + name->tag = NULL; + name->path = NULL; + + if (in->tag && git_object_dup((git_object **) &name->tag, (git_object *) in->tag) < 0) + return -1; + + name->path = git__strdup(in->path); + GITERR_CHECK_ALLOC(name->path); + + *out = name; + return 0; +} + +static int get_name(const char *refname, void *payload) +{ + struct get_name_data *data; + bool is_tag, is_annotated, all; + git_oid peeled, sha1; + unsigned int prio; + int error = 0; + + data = (struct get_name_data *)payload; + is_tag = !git__prefixcmp(refname, GIT_REFS_TAGS_DIR); + all = data->opts->describe_strategy == GIT_DESCRIBE_ALL; + + /* Reject anything outside refs/tags/ unless --all */ + if (!all && !is_tag) + return 0; + + /* Accept only tags that match the pattern, if given */ + if (data->opts->pattern && (!is_tag || p_fnmatch(data->opts->pattern, + refname + strlen(GIT_REFS_TAGS_DIR), 0))) + return 0; + + /* Is it annotated? */ + if ((error = retrieve_peeled_tag_or_object_oid( + &peeled, &sha1, data->repo, refname)) < 0) + return error; + + is_annotated = error; + + /* + * By default, we only use annotated tags, but with --tags + * we fall back to lightweight ones (even without --tags, + * we still remember lightweight ones, only to give hints + * in an error message). --all allows any refs to be used. + */ + if (is_annotated) + prio = 2; + else if (is_tag) + prio = 1; + else + prio = 0; + + add_to_known_names(data->repo, data->names, + all ? refname + strlen(GIT_REFS_DIR) : refname + strlen(GIT_REFS_TAGS_DIR), + &peeled, prio, &sha1); + return 0; +} + +struct possible_tag { + struct commit_name *name; + int depth; + int found_order; + unsigned flag_within; +}; + +static int possible_tag_dup(struct possible_tag **out, struct possible_tag *in) +{ + struct possible_tag *tag; + int error; + + tag = git__malloc(sizeof(struct possible_tag)); + GITERR_CHECK_ALLOC(tag); + + memcpy(tag, in, sizeof(struct possible_tag)); + tag->name = NULL; + + if ((error = commit_name_dup(&tag->name, in->name)) < 0) { + git__free(tag); + *out = NULL; + return error; + } + + *out = tag; + return 0; +} + +static int compare_pt(const void *a_, const void *b_) +{ + struct possible_tag *a = (struct possible_tag *)a_; + struct possible_tag *b = (struct possible_tag *)b_; + if (a->depth != b->depth) + return a->depth - b->depth; + if (a->found_order != b->found_order) + return a->found_order - b->found_order; + return 0; +} + +#define SEEN (1u << 0) + +static unsigned long finish_depth_computation( + git_pqueue *list, + git_revwalk *walk, + struct possible_tag *best) +{ + unsigned long seen_commits = 0; + int error, i; + + while (git_pqueue_size(list) > 0) { + git_commit_list_node *c = git_pqueue_pop(list); + seen_commits++; + if (c->flags & best->flag_within) { + size_t index = 0; + while (git_pqueue_size(list) > index) { + git_commit_list_node *i = git_pqueue_get(list, index); + if (!(i->flags & best->flag_within)) + break; + index++; + } + if (index > git_pqueue_size(list)) + break; + } else + best->depth++; + for (i = 0; i < c->out_degree; i++) { + git_commit_list_node *p = c->parents[i]; + if ((error = git_commit_list_parse(walk, p)) < 0) + return error; + if (!(p->flags & SEEN)) + if ((error = git_pqueue_insert(list, p)) < 0) + return error; + p->flags |= c->flags; + } + } + return seen_commits; +} + +static int display_name(git_buf *buf, git_repository *repo, struct commit_name *n) +{ + if (n->prio == 2 && !n->tag) { + if (git_tag_lookup(&n->tag, repo, &n->sha1) < 0) { + giterr_set(GITERR_TAG, "Annotated tag '%s' not available", n->path); + return -1; + } + } + + if (n->tag && !n->name_checked) { + if (!git_tag_name(n->tag)) { + giterr_set(GITERR_TAG, "Annotated tag '%s' has no embedded name", n->path); + return -1; + } + + /* TODO: Cope with warnings + if (strcmp(n->tag->tag, all ? n->path + 5 : n->path)) + warning(_("tag '%s' is really '%s' here"), n->tag->tag, n->path); + */ + + n->name_checked = 1; + } + + if (n->tag) + git_buf_printf(buf, "%s", git_tag_name(n->tag)); + else + git_buf_printf(buf, "%s", n->path); + + return 0; +} + +static int find_unique_abbrev_size( + int *out, + git_repository *repo, + const git_oid *oid_in, + int abbreviated_size) +{ + size_t size = abbreviated_size; + git_odb *odb; + git_oid dummy; + int error; + + if ((error = git_repository_odb__weakptr(&odb, repo)) < 0) + return error; + + while (size < GIT_OID_HEXSZ) { + if ((error = git_odb_exists_prefix(&dummy, odb, oid_in, size)) == 0) { + *out = (int) size; + return 0; + } + + /* If the error wasn't that it's not unique, then it's a proper error */ + if (error != GIT_EAMBIGUOUS) + return error; + + /* Try again with a larger size */ + size++; + } + + /* If we didn't find any shorter prefix, we have to do the whole thing */ + *out = GIT_OID_HEXSZ; + + return 0; +} + +static int show_suffix( + git_buf *buf, + int depth, + git_repository *repo, + const git_oid* id, + size_t abbrev_size) +{ + int error, size = 0; + + char hex_oid[GIT_OID_HEXSZ]; + + if ((error = find_unique_abbrev_size(&size, repo, id, abbrev_size)) < 0) + return error; + + git_oid_fmt(hex_oid, id); + + git_buf_printf(buf, "-%d-g", depth); + + git_buf_put(buf, hex_oid, size); + + return git_buf_oom(buf) ? -1 : 0; +} + +#define MAX_CANDIDATES_TAGS FLAG_BITS - 1 + +static int describe_not_found(const git_oid *oid, const char *message_format) { + char oid_str[GIT_OID_HEXSZ + 1]; + git_oid_tostr(oid_str, sizeof(oid_str), oid); + + giterr_set(GITERR_DESCRIBE, message_format, oid_str); + return GIT_ENOTFOUND; +} + +static int describe( + struct get_name_data *data, + git_commit *commit) +{ + struct commit_name *n; + struct possible_tag *best; + bool all, tags; + git_revwalk *walk = NULL; + git_pqueue list; + git_commit_list_node *cmit, *gave_up_on = NULL; + git_vector all_matches = GIT_VECTOR_INIT; + unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; + unsigned long seen_commits = 0; /* TODO: Check long */ + unsigned int unannotated_cnt = 0; + int error; + + if (git_vector_init(&all_matches, MAX_CANDIDATES_TAGS, compare_pt) < 0) + return -1; + + if ((error = git_pqueue_init(&list, 0, 2, git_commit_list_time_cmp)) < 0) + goto cleanup; + + all = data->opts->describe_strategy == GIT_DESCRIBE_ALL; + tags = data->opts->describe_strategy == GIT_DESCRIBE_TAGS; + + git_oid_cpy(&data->result->commit_id, git_commit_id(commit)); + + n = find_commit_name(data->names, git_commit_id(commit)); + if (n && (tags || all || n->prio == 2)) { + /* + * Exact match to an existing ref. + */ + data->result->exact_match = 1; + if ((error = commit_name_dup(&data->result->name, n)) < 0) + goto cleanup; + + goto cleanup; + } + + if (!data->opts->max_candidates_tags) { + error = describe_not_found( + git_commit_id(commit), + "Cannot describe - no tag exactly matches '%s'"); + + goto cleanup; + } + + if ((error = git_revwalk_new(&walk, git_commit_owner(commit))) < 0) + goto cleanup; + + if ((cmit = git_revwalk__commit_lookup(walk, git_commit_id(commit))) == NULL) + goto cleanup; + + if ((error = git_commit_list_parse(walk, cmit)) < 0) + goto cleanup; + + cmit->flags = SEEN; + + if ((error = git_pqueue_insert(&list, cmit)) < 0) + goto cleanup; + + while (git_pqueue_size(&list) > 0) + { + int i; + + git_commit_list_node *c = (git_commit_list_node *)git_pqueue_pop(&list); + seen_commits++; + + n = find_commit_name(data->names, &c->oid); + + if (n) { + if (!tags && !all && n->prio < 2) { + unannotated_cnt++; + } else if (match_cnt < data->opts->max_candidates_tags) { + struct possible_tag *t = git__malloc(sizeof(struct commit_name)); + GITERR_CHECK_ALLOC(t); + if ((error = git_vector_insert(&all_matches, t)) < 0) + goto cleanup; + + match_cnt++; + + t->name = n; + t->depth = seen_commits - 1; + t->flag_within = 1u << match_cnt; + t->found_order = match_cnt; + c->flags |= t->flag_within; + if (n->prio == 2) + annotated_cnt++; + } + else { + gave_up_on = c; + break; + } + } + + for (cur_match = 0; cur_match < match_cnt; cur_match++) { + struct possible_tag *t = git_vector_get(&all_matches, cur_match); + if (!(c->flags & t->flag_within)) + t->depth++; + } + + if (annotated_cnt && (git_pqueue_size(&list) == 0)) { + /* + if (debug) { + char oid_str[GIT_OID_HEXSZ + 1]; + git_oid_tostr(oid_str, sizeof(oid_str), &c->oid); + + fprintf(stderr, "finished search at %s\n", oid_str); + } + */ + break; + } + for (i = 0; i < c->out_degree; i++) { + git_commit_list_node *p = c->parents[i]; + if ((error = git_commit_list_parse(walk, p)) < 0) + goto cleanup; + if (!(p->flags & SEEN)) + if ((error = git_pqueue_insert(&list, p)) < 0) + goto cleanup; + p->flags |= c->flags; + + if (data->opts->only_follow_first_parent) + break; + } + } + + if (!match_cnt) { + if (data->opts->show_commit_oid_as_fallback) { + data->result->fallback_to_id = 1; + git_oid_cpy(&data->result->commit_id, &cmit->oid); + + goto cleanup; + } + if (unannotated_cnt) { + error = describe_not_found(git_commit_id(commit), + "Cannot describe - " + "No annotated tags can describe '%s'." + "However, there were unannotated tags."); + goto cleanup; + } + else { + error = describe_not_found(git_commit_id(commit), + "Cannot describe - " + "No tags can describe '%s'."); + goto cleanup; + } + } + + git_vector_sort(&all_matches); + + best = (struct possible_tag *)git_vector_get(&all_matches, 0); + + if (gave_up_on) { + git_pqueue_insert(&list, gave_up_on); + seen_commits--; + } + if ((error = finish_depth_computation( + &list, walk, best)) < 0) + goto cleanup; + + seen_commits += error; + if ((error = possible_tag_dup(&data->result->tag, best)) < 0) + goto cleanup; + + /* + { + static const char *prio_names[] = { + "head", "lightweight", "annotated", + }; + + char oid_str[GIT_OID_HEXSZ + 1]; + + if (debug) { + for (cur_match = 0; cur_match < match_cnt; cur_match++) { + struct possible_tag *t = (struct possible_tag *)git_vector_get(&all_matches, cur_match); + fprintf(stderr, " %-11s %8d %s\n", + prio_names[t->name->prio], + t->depth, t->name->path); + } + fprintf(stderr, "traversed %lu commits\n", seen_commits); + if (gave_up_on) { + git_oid_tostr(oid_str, sizeof(oid_str), &gave_up_on->oid); + fprintf(stderr, + "more than %i tags found; listed %i most recent\n" + "gave up search at %s\n", + data->opts->max_candidates_tags, data->opts->max_candidates_tags, + oid_str); + } + } + } + */ + + git_oid_cpy(&data->result->commit_id, &cmit->oid); + +cleanup: + { + size_t i; + struct possible_tag *match; + git_vector_foreach(&all_matches, i, match) { + git__free(match); + } + } + git_vector_free(&all_matches); + git_pqueue_free(&list); + git_revwalk_free(walk); + return error; +} + +static int normalize_options( + git_describe_options *dst, + const git_describe_options *src) +{ + git_describe_options default_options = GIT_DESCRIBE_OPTIONS_INIT; + if (!src) src = &default_options; + + *dst = *src; + + if (dst->max_candidates_tags > GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS) + dst->max_candidates_tags = GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS; + + return 0; +} + +int git_describe_commit( + git_describe_result **result, + git_object *committish, + git_describe_options *opts) +{ + struct get_name_data data; + struct commit_name *name; + git_commit *commit; + int error = -1; + git_describe_options normalized; + + assert(committish); + + data.result = git__calloc(1, sizeof(git_describe_result)); + GITERR_CHECK_ALLOC(data.result); + data.result->repo = git_object_owner(committish); + + data.repo = git_object_owner(committish); + + if ((error = normalize_options(&normalized, opts)) < 0) + return error; + + GITERR_CHECK_VERSION( + &normalized, + GIT_DESCRIBE_OPTIONS_VERSION, + "git_describe_options"); + data.opts = &normalized; + + data.names = git_oidmap_alloc(); + GITERR_CHECK_ALLOC(data.names); + + /** TODO: contains to be implemented */ + + if ((error = git_object_peel((git_object **)(&commit), committish, GIT_OBJ_COMMIT)) < 0) + goto cleanup; + + if ((error = git_reference_foreach_name( + git_object_owner(committish), + get_name, &data)) < 0) + goto cleanup; + + if (git_oidmap_size(data.names) == 0) { + giterr_set(GITERR_DESCRIBE, "Cannot describe - " + "No reference found, cannot describe anything."); + error = -1; + goto cleanup; + } + + if ((error = describe(&data, commit)) < 0) + goto cleanup; + +cleanup: + git_commit_free(commit); + + git_oidmap_foreach_value(data.names, name, { + git_tag_free(name->tag); + git__free(name->path); + git__free(name); + }); + + git_oidmap_free(data.names); + + if (error < 0) + git_describe_result_free(data.result); + else + *result = data.result; + + return error; +} + +int git_describe_workdir( + git_describe_result **out, + git_repository *repo, + git_describe_options *opts) +{ + int error; + git_oid current_id; + git_status_list *status = NULL; + git_status_options status_opts = GIT_STATUS_OPTIONS_INIT; + git_describe_result *result = NULL; + git_object *commit; + + if ((error = git_reference_name_to_id(¤t_id, repo, GIT_HEAD_FILE)) < 0) + return error; + + if ((error = git_object_lookup(&commit, repo, ¤t_id, GIT_OBJ_COMMIT)) < 0) + return error; + + /* The first step is to perform a describe of HEAD, so we can leverage this */ + if ((error = git_describe_commit(&result, commit, opts)) < 0) + goto out; + + if ((error = git_status_list_new(&status, repo, &status_opts)) < 0) + goto out; + + + if (git_status_list_entrycount(status) > 0) + result->dirty = 1; + +out: + git_object_free(commit); + git_status_list_free(status); + + if (error < 0) + git_describe_result_free(result); + else + *out = result; + + return error; +} + +static int normalize_format_options( + git_describe_format_options *dst, + const git_describe_format_options *src) +{ + if (!src) { + git_describe_init_format_options(dst, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION); + return 0; + } + + memcpy(dst, src, sizeof(git_describe_format_options)); + return 0; +} + +int git_describe_format(git_buf *out, const git_describe_result *result, const git_describe_format_options *given) +{ + int error; + git_repository *repo; + struct commit_name *name; + git_describe_format_options opts; + + assert(out && result); + + GITERR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options"); + normalize_format_options(&opts, given); + + git_buf_sanitize(out); + + + if (opts.always_use_long_format && opts.abbreviated_size == 0) { + giterr_set(GITERR_DESCRIBE, "Cannot describe - " + "'always_use_long_format' is incompatible with a zero" + "'abbreviated_size'"); + return -1; + } + + + repo = result->repo; + + /* If we did find an exact match, then it's the easier method */ + if (result->exact_match) { + name = result->name; + if ((error = display_name(out, repo, name)) < 0) + return error; + + if (opts.always_use_long_format) { + const git_oid *id = name->tag ? git_tag_target_id(name->tag) : &result->commit_id; + if ((error = show_suffix(out, 0, repo, id, opts.abbreviated_size)) < 0) + return error; + } + + if (result->dirty && opts.dirty_suffix) + git_buf_puts(out, opts.dirty_suffix); + + return git_buf_oom(out) ? -1 : 0; + } + + /* If we didn't find *any* tags, we fall back to the commit's id */ + if (result->fallback_to_id) { + char hex_oid[GIT_OID_HEXSZ + 1] = {0}; + int size = 0; + + if ((error = find_unique_abbrev_size( + &size, repo, &result->commit_id, opts.abbreviated_size)) < 0) + return -1; + + git_oid_fmt(hex_oid, &result->commit_id); + git_buf_put(out, hex_oid, size); + + if (result->dirty && opts.dirty_suffix) + git_buf_puts(out, opts.dirty_suffix); + + return git_buf_oom(out) ? -1 : 0; + } + + /* Lastly, if we found a matching tag, we show that */ + name = result->tag->name; + + if ((error = display_name(out, repo, name)) < 0) + return error; + + if (opts.abbreviated_size) { + if ((error = show_suffix(out, result->tag->depth, repo, + &result->commit_id, opts.abbreviated_size)) < 0) + return error; + } + + if (result->dirty && opts.dirty_suffix) { + git_buf_puts(out, opts.dirty_suffix); + } + + return git_buf_oom(out) ? -1 : 0; +} + +void git_describe_result_free(git_describe_result *result) +{ + if (result == NULL) + return; + + if (result->name) { + git_tag_free(result->name->tag); + git__free(result->name->path); + git__free(result->name); + } + + if (result->tag) { + git_tag_free(result->tag->name->tag); + git__free(result->tag->name->path); + git__free(result->tag->name); + git__free(result->tag); + } + + git__free(result); +} + +int git_describe_init_options(git_describe_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_describe_options, GIT_DESCRIBE_OPTIONS_INIT); + return 0; +} + +int git_describe_init_format_options(git_describe_format_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_describe_format_options, GIT_DESCRIBE_FORMAT_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff.c new file mode 100644 index 000000000..f1bc28fd9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff.c @@ -0,0 +1,1647 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "diff.h" +#include "fileops.h" +#include "config.h" +#include "attr_file.h" +#include "filter.h" +#include "pathspec.h" +#include "index.h" +#include "odb.h" +#include "submodule.h" + +#define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0) +#define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0) +#define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->opts.flags = \ + (VAL) ? ((DIFF)->opts.flags | (FLAG)) : ((DIFF)->opts.flags & ~(VAL)) + +static git_diff_delta *diff_delta__alloc( + git_diff *diff, + git_delta_t status, + const char *path) +{ + git_diff_delta *delta = git__calloc(1, sizeof(git_diff_delta)); + if (!delta) + return NULL; + + delta->old_file.path = git_pool_strdup(&diff->pool, path); + if (delta->old_file.path == NULL) { + git__free(delta); + return NULL; + } + + delta->new_file.path = delta->old_file.path; + + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { + switch (status) { + case GIT_DELTA_ADDED: status = GIT_DELTA_DELETED; break; + case GIT_DELTA_DELETED: status = GIT_DELTA_ADDED; break; + default: break; /* leave other status values alone */ + } + } + delta->status = status; + + return delta; +} + +static int diff_insert_delta( + git_diff *diff, git_diff_delta *delta, const char *matched_pathspec) +{ + int error = 0; + + if (diff->opts.notify_cb) { + error = diff->opts.notify_cb( + diff, delta, matched_pathspec, diff->opts.notify_payload); + + if (error) { + git__free(delta); + + if (error > 0) /* positive value means to skip this delta */ + return 0; + else /* negative value means to cancel diff */ + return giterr_set_after_callback_function(error, "git_diff"); + } + } + + if ((error = git_vector_insert(&diff->deltas, delta)) < 0) + git__free(delta); + + return error; +} + +static int diff_delta__from_one( + git_diff *diff, + git_delta_t status, + const git_index_entry *entry) +{ + git_diff_delta *delta; + const char *matched_pathspec; + + if ((entry->flags & GIT_IDXENTRY_VALID) != 0) + return 0; + + if (status == GIT_DELTA_IGNORED && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED)) + return 0; + + if (status == GIT_DELTA_UNTRACKED && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNTRACKED)) + return 0; + + if (status == GIT_DELTA_UNREADABLE && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE)) + return 0; + + if (!git_pathspec__match( + &diff->pathspec, entry->path, + DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH), + DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE), + &matched_pathspec, NULL)) + return 0; + + delta = diff_delta__alloc(diff, status, entry->path); + GITERR_CHECK_ALLOC(delta); + + /* This fn is just for single-sided diffs */ + assert(status != GIT_DELTA_MODIFIED); + delta->nfiles = 1; + + if (delta->status == GIT_DELTA_DELETED) { + delta->old_file.mode = entry->mode; + delta->old_file.size = entry->file_size; + git_oid_cpy(&delta->old_file.id, &entry->id); + } else /* ADDED, IGNORED, UNTRACKED */ { + delta->new_file.mode = entry->mode; + delta->new_file.size = entry->file_size; + git_oid_cpy(&delta->new_file.id, &entry->id); + } + + delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + if (delta->status == GIT_DELTA_DELETED || + !git_oid_iszero(&delta->new_file.id)) + delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + return diff_insert_delta(diff, delta, matched_pathspec); +} + +static int diff_delta__from_two( + git_diff *diff, + git_delta_t status, + const git_index_entry *old_entry, + uint32_t old_mode, + const git_index_entry *new_entry, + uint32_t new_mode, + git_oid *new_oid, + const char *matched_pathspec) +{ + git_diff_delta *delta; + const char *canonical_path = old_entry->path; + + if (status == GIT_DELTA_UNMODIFIED && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNMODIFIED)) + return 0; + + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { + uint32_t temp_mode = old_mode; + const git_index_entry *temp_entry = old_entry; + old_entry = new_entry; + new_entry = temp_entry; + old_mode = new_mode; + new_mode = temp_mode; + } + + delta = diff_delta__alloc(diff, status, canonical_path); + GITERR_CHECK_ALLOC(delta); + delta->nfiles = 2; + + git_oid_cpy(&delta->old_file.id, &old_entry->id); + delta->old_file.size = old_entry->file_size; + delta->old_file.mode = old_mode; + delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + git_oid_cpy(&delta->new_file.id, &new_entry->id); + delta->new_file.size = new_entry->file_size; + delta->new_file.mode = new_mode; + + if (new_oid) { + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) + git_oid_cpy(&delta->old_file.id, new_oid); + else + git_oid_cpy(&delta->new_file.id, new_oid); + } + + if (new_oid || !git_oid_iszero(&new_entry->id)) + delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + return diff_insert_delta(diff, delta, matched_pathspec); +} + +static git_diff_delta *diff_delta__last_for_item( + git_diff *diff, + const git_index_entry *item) +{ + git_diff_delta *delta = git_vector_last(&diff->deltas); + if (!delta) + return NULL; + + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: + case GIT_DELTA_DELETED: + if (git_oid__cmp(&delta->old_file.id, &item->id) == 0) + return delta; + break; + case GIT_DELTA_ADDED: + if (git_oid__cmp(&delta->new_file.id, &item->id) == 0) + return delta; + break; + case GIT_DELTA_UNREADABLE: + case GIT_DELTA_UNTRACKED: + if (diff->strcomp(delta->new_file.path, item->path) == 0 && + git_oid__cmp(&delta->new_file.id, &item->id) == 0) + return delta; + break; + case GIT_DELTA_MODIFIED: + if (git_oid__cmp(&delta->old_file.id, &item->id) == 0 || + git_oid__cmp(&delta->new_file.id, &item->id) == 0) + return delta; + break; + default: + break; + } + + return NULL; +} + +static char *diff_strdup_prefix(git_pool *pool, const char *prefix) +{ + size_t len = strlen(prefix); + + /* append '/' at end if needed */ + if (len > 0 && prefix[len - 1] != '/') + return git_pool_strcat(pool, prefix, "/"); + else + return git_pool_strndup(pool, prefix, len + 1); +} + +GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta) +{ + const char *str = delta->old_file.path; + + if (!str || + delta->status == GIT_DELTA_ADDED || + delta->status == GIT_DELTA_RENAMED || + delta->status == GIT_DELTA_COPIED) + str = delta->new_file.path; + + return str; +} + +const char *git_diff_delta__path(const git_diff_delta *delta) +{ + return diff_delta__path(delta); +} + +int git_diff_delta__cmp(const void *a, const void *b) +{ + const git_diff_delta *da = a, *db = b; + int val = strcmp(diff_delta__path(da), diff_delta__path(db)); + return val ? val : ((int)da->status - (int)db->status); +} + +int git_diff_delta__casecmp(const void *a, const void *b) +{ + const git_diff_delta *da = a, *db = b; + int val = strcasecmp(diff_delta__path(da), diff_delta__path(db)); + return val ? val : ((int)da->status - (int)db->status); +} + +GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta) +{ + return delta->old_file.path ? + delta->old_file.path : delta->new_file.path; +} + +int git_diff_delta__i2w_cmp(const void *a, const void *b) +{ + const git_diff_delta *da = a, *db = b; + int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); + return val ? val : ((int)da->status - (int)db->status); +} + +int git_diff_delta__i2w_casecmp(const void *a, const void *b) +{ + const git_diff_delta *da = a, *db = b; + int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); + return val ? val : ((int)da->status - (int)db->status); +} + +bool git_diff_delta__should_skip( + const git_diff_options *opts, const git_diff_delta *delta) +{ + uint32_t flags = opts ? opts->flags : 0; + + if (delta->status == GIT_DELTA_UNMODIFIED && + (flags & GIT_DIFF_INCLUDE_UNMODIFIED) == 0) + return true; + + if (delta->status == GIT_DELTA_IGNORED && + (flags & GIT_DIFF_INCLUDE_IGNORED) == 0) + return true; + + if (delta->status == GIT_DELTA_UNTRACKED && + (flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0) + return true; + + if (delta->status == GIT_DELTA_UNREADABLE && + (flags & GIT_DIFF_INCLUDE_UNREADABLE) == 0) + return true; + + return false; +} + + +static const char *diff_mnemonic_prefix( + git_iterator_type_t type, bool left_side) +{ + const char *pfx = ""; + + switch (type) { + case GIT_ITERATOR_TYPE_EMPTY: pfx = "c"; break; + case GIT_ITERATOR_TYPE_TREE: pfx = "c"; break; + case GIT_ITERATOR_TYPE_INDEX: pfx = "i"; break; + case GIT_ITERATOR_TYPE_WORKDIR: pfx = "w"; break; + case GIT_ITERATOR_TYPE_FS: pfx = left_side ? "1" : "2"; break; + default: break; + } + + /* note: without a deeper look at pathspecs, there is no easy way + * to get the (o)bject / (w)ork tree mnemonics working... + */ + + return pfx; +} + +static void diff_set_ignore_case(git_diff *diff, bool ignore_case) +{ + if (!ignore_case) { + diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE; + + diff->strcomp = git__strcmp; + diff->strncomp = git__strncmp; + diff->pfxcomp = git__prefixcmp; + diff->entrycomp = git_index_entry_cmp; + + git_vector_set_cmp(&diff->deltas, git_diff_delta__cmp); + } else { + diff->opts.flags |= GIT_DIFF_IGNORE_CASE; + + diff->strcomp = git__strcasecmp; + diff->strncomp = git__strncasecmp; + diff->pfxcomp = git__prefixcmp_icase; + diff->entrycomp = git_index_entry_icmp; + + git_vector_set_cmp(&diff->deltas, git_diff_delta__casecmp); + } + + git_vector_sort(&diff->deltas); +} + +static git_diff *diff_list_alloc( + git_repository *repo, + git_iterator *old_iter, + git_iterator *new_iter) +{ + git_diff_options dflt = GIT_DIFF_OPTIONS_INIT; + git_diff *diff = git__calloc(1, sizeof(git_diff)); + if (!diff) + return NULL; + + assert(repo && old_iter && new_iter); + + GIT_REFCOUNT_INC(diff); + diff->repo = repo; + diff->old_src = old_iter->type; + diff->new_src = new_iter->type; + memcpy(&diff->opts, &dflt, sizeof(diff->opts)); + + if (git_vector_init(&diff->deltas, 0, git_diff_delta__cmp) < 0 || + git_pool_init(&diff->pool, 1, 0) < 0) { + git_diff_free(diff); + return NULL; + } + + /* Use case-insensitive compare if either iterator has + * the ignore_case bit set */ + diff_set_ignore_case( + diff, + git_iterator_ignore_case(old_iter) || + git_iterator_ignore_case(new_iter)); + + return diff; +} + +static int diff_list_apply_options( + git_diff *diff, + const git_diff_options *opts) +{ + git_config *cfg = NULL; + git_repository *repo = diff->repo; + git_pool *pool = &diff->pool; + int val; + + if (opts) { + /* copy user options (except case sensitivity info from iterators) */ + bool icase = DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE); + memcpy(&diff->opts, opts, sizeof(diff->opts)); + DIFF_FLAG_SET(diff, GIT_DIFF_IGNORE_CASE, icase); + + /* initialize pathspec from options */ + if (git_pathspec__vinit(&diff->pathspec, &opts->pathspec, pool) < 0) + return -1; + } + + /* flag INCLUDE_TYPECHANGE_TREES implies INCLUDE_TYPECHANGE */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES)) + diff->opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE; + + /* flag INCLUDE_UNTRACKED_CONTENT implies INCLUDE_UNTRACKED */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_SHOW_UNTRACKED_CONTENT)) + diff->opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED; + + /* load config values that affect diff behavior */ + if ((val = git_repository_config_snapshot(&cfg, repo)) < 0) + return val; + + if (!git_config__cvar(&val, cfg, GIT_CVAR_SYMLINKS) && val) + diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_HAS_SYMLINKS; + + if (!git_config__cvar(&val, cfg, GIT_CVAR_IGNORESTAT) && val) + diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_IGNORE_STAT; + + if ((diff->opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 && + !git_config__cvar(&val, cfg, GIT_CVAR_FILEMODE) && val) + diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_MODE_BITS; + + if (!git_config__cvar(&val, cfg, GIT_CVAR_TRUSTCTIME) && val) + diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_CTIME; + + /* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */ + + /* Set GIT_DIFFCAPS_TRUST_NANOSECS on a platform basis */ + diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_NANOSECS; + + /* If not given explicit `opts`, check `diff.xyz` configs */ + if (!opts) { + int context = git_config__get_int_force(cfg, "diff.context", 3); + diff->opts.context_lines = context >= 0 ? (uint32_t)context : 3; + + /* add other defaults here */ + } + + /* Reverse src info if diff is reversed */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { + git_iterator_type_t tmp_src = diff->old_src; + diff->old_src = diff->new_src; + diff->new_src = tmp_src; + } + + /* Unset UPDATE_INDEX unless diffing workdir and index */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) && + (!(diff->old_src == GIT_ITERATOR_TYPE_WORKDIR || + diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) || + !(diff->old_src == GIT_ITERATOR_TYPE_INDEX || + diff->new_src == GIT_ITERATOR_TYPE_INDEX))) + diff->opts.flags &= ~GIT_DIFF_UPDATE_INDEX; + + /* if ignore_submodules not explicitly set, check diff config */ + if (diff->opts.ignore_submodules <= 0) { + git_config_entry *entry; + git_config__lookup_entry(&entry, cfg, "diff.ignoresubmodules", true); + + if (entry && git_submodule_parse_ignore( + &diff->opts.ignore_submodules, entry->value) < 0) + giterr_clear(); + git_config_entry_free(entry); + } + + /* if either prefix is not set, figure out appropriate value */ + if (!diff->opts.old_prefix || !diff->opts.new_prefix) { + const char *use_old = DIFF_OLD_PREFIX_DEFAULT; + const char *use_new = DIFF_NEW_PREFIX_DEFAULT; + + if (git_config__get_bool_force(cfg, "diff.noprefix", 0)) + use_old = use_new = ""; + else if (git_config__get_bool_force(cfg, "diff.mnemonicprefix", 0)) { + use_old = diff_mnemonic_prefix(diff->old_src, true); + use_new = diff_mnemonic_prefix(diff->new_src, false); + } + + if (!diff->opts.old_prefix) + diff->opts.old_prefix = use_old; + if (!diff->opts.new_prefix) + diff->opts.new_prefix = use_new; + } + + /* strdup prefix from pool so we're not dependent on external data */ + diff->opts.old_prefix = diff_strdup_prefix(pool, diff->opts.old_prefix); + diff->opts.new_prefix = diff_strdup_prefix(pool, diff->opts.new_prefix); + + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { + const char *tmp_prefix = diff->opts.old_prefix; + diff->opts.old_prefix = diff->opts.new_prefix; + diff->opts.new_prefix = tmp_prefix; + } + + git_config_free(cfg); + + /* check strdup results for error */ + return (!diff->opts.old_prefix || !diff->opts.new_prefix) ? -1 : 0; +} + +static void diff_list_free(git_diff *diff) +{ + git_vector_free_deep(&diff->deltas); + + git_pathspec__vfree(&diff->pathspec); + git_pool_clear(&diff->pool); + + git__memzero(diff, sizeof(*diff)); + git__free(diff); +} + +void git_diff_free(git_diff *diff) +{ + if (!diff) + return; + + GIT_REFCOUNT_DEC(diff, diff_list_free); +} + +void git_diff_addref(git_diff *diff) +{ + GIT_REFCOUNT_INC(diff); +} + +int git_diff__oid_for_file( + git_oid *out, + git_diff *diff, + const char *path, + uint16_t mode, + git_off_t size) +{ + git_index_entry entry; + + memset(&entry, 0, sizeof(entry)); + entry.mode = mode; + entry.file_size = size; + entry.path = (char *)path; + + return git_diff__oid_for_entry(out, diff, &entry, NULL); +} + +int git_diff__oid_for_entry( + git_oid *out, + git_diff *diff, + const git_index_entry *src, + const git_oid *update_match) +{ + int error = 0; + git_buf full_path = GIT_BUF_INIT; + git_index_entry entry = *src; + git_filter_list *fl = NULL; + + memset(out, 0, sizeof(*out)); + + if (git_buf_joinpath( + &full_path, git_repository_workdir(diff->repo), entry.path) < 0) + return -1; + + if (!entry.mode) { + struct stat st; + + diff->perf.stat_calls++; + + if (p_stat(full_path.ptr, &st) < 0) { + error = git_path_set_error(errno, entry.path, "stat"); + git_buf_free(&full_path); + return error; + } + + git_index_entry__init_from_stat( + &entry, &st, (diff->diffcaps & GIT_DIFFCAPS_TRUST_MODE_BITS) != 0); + } + + /* calculate OID for file if possible */ + if (S_ISGITLINK(entry.mode)) { + git_submodule *sm; + + if (!git_submodule_lookup(&sm, diff->repo, entry.path)) { + const git_oid *sm_oid = git_submodule_wd_id(sm); + if (sm_oid) + git_oid_cpy(out, sm_oid); + git_submodule_free(sm); + } else { + /* if submodule lookup failed probably just in an intermediate + * state where some init hasn't happened, so ignore the error + */ + giterr_clear(); + } + } else if (S_ISLNK(entry.mode)) { + error = git_odb__hashlink(out, full_path.ptr); + diff->perf.oid_calculations++; + } else if (!git__is_sizet(entry.file_size)) { + giterr_set(GITERR_OS, "File size overflow (for 32-bits) on '%s'", + entry.path); + error = -1; + } else if (!(error = git_filter_list_load( + &fl, diff->repo, NULL, entry.path, + GIT_FILTER_TO_ODB, GIT_FILTER_ALLOW_UNSAFE))) + { + int fd = git_futils_open_ro(full_path.ptr); + if (fd < 0) + error = fd; + else { + error = git_odb__hashfd_filtered( + out, fd, (size_t)entry.file_size, GIT_OBJ_BLOB, fl); + p_close(fd); + diff->perf.oid_calculations++; + } + + git_filter_list_free(fl); + } + + /* update index for entry if requested */ + if (!error && update_match && git_oid_equal(out, update_match)) { + git_index *idx; + + if (!(error = git_repository_index__weakptr(&idx, diff->repo))) { + memcpy(&entry.id, out, sizeof(entry.id)); + error = git_index_add(idx, &entry); + } + } + + git_buf_free(&full_path); + return error; +} + +static bool diff_time_eq( + const git_index_time *a, const git_index_time *b, bool use_nanos) +{ + return a->seconds == b->seconds && + (!use_nanos || a->nanoseconds == b->nanoseconds); +} + +typedef struct { + git_repository *repo; + git_iterator *old_iter; + git_iterator *new_iter; + const git_index_entry *oitem; + const git_index_entry *nitem; +} diff_in_progress; + +#define MODE_BITS_MASK 0000777 + +static int maybe_modified_submodule( + git_delta_t *status, + git_oid *found_oid, + git_diff *diff, + diff_in_progress *info) +{ + int error = 0; + git_submodule *sub; + unsigned int sm_status = 0; + git_submodule_ignore_t ign = diff->opts.ignore_submodules; + + *status = GIT_DELTA_UNMODIFIED; + + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES) || + ign == GIT_SUBMODULE_IGNORE_ALL) + return 0; + + if ((error = git_submodule_lookup( + &sub, diff->repo, info->nitem->path)) < 0) { + + /* GIT_EEXISTS means dir with .git in it was found - ignore it */ + if (error == GIT_EEXISTS) { + giterr_clear(); + error = 0; + } + return error; + } + + if (ign <= 0 && git_submodule_ignore(sub) == GIT_SUBMODULE_IGNORE_ALL) + /* ignore it */; + else if ((error = git_submodule__status( + &sm_status, NULL, NULL, found_oid, sub, ign)) < 0) + /* return error below */; + + /* check IS_WD_UNMODIFIED because this case is only used + * when the new side of the diff is the working directory + */ + else if (!GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(sm_status)) + *status = GIT_DELTA_MODIFIED; + + /* now that we have a HEAD OID, check if HEAD moved */ + else if ((sm_status & GIT_SUBMODULE_STATUS_IN_WD) != 0 && + !git_oid_equal(&info->oitem->id, found_oid)) + *status = GIT_DELTA_MODIFIED; + + git_submodule_free(sub); + return error; +} + +static int maybe_modified( + git_diff *diff, + diff_in_progress *info) +{ + git_oid noid; + git_delta_t status = GIT_DELTA_MODIFIED; + const git_index_entry *oitem = info->oitem; + const git_index_entry *nitem = info->nitem; + unsigned int omode = oitem->mode; + unsigned int nmode = nitem->mode; + bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_TYPE_WORKDIR); + bool modified_uncertain = false; + const char *matched_pathspec; + int error = 0; + + if (!git_pathspec__match( + &diff->pathspec, oitem->path, + DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH), + DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE), + &matched_pathspec, NULL)) + return 0; + + memset(&noid, 0, sizeof(noid)); + + /* on platforms with no symlinks, preserve mode of existing symlinks */ + if (S_ISLNK(omode) && S_ISREG(nmode) && new_is_workdir && + !(diff->diffcaps & GIT_DIFFCAPS_HAS_SYMLINKS)) + nmode = omode; + + /* on platforms with no execmode, just preserve old mode */ + if (!(diff->diffcaps & GIT_DIFFCAPS_TRUST_MODE_BITS) && + (nmode & MODE_BITS_MASK) != (omode & MODE_BITS_MASK) && + new_is_workdir) + nmode = (nmode & ~MODE_BITS_MASK) | (omode & MODE_BITS_MASK); + + /* support "assume unchanged" (poorly, b/c we still stat everything) */ + if ((oitem->flags & GIT_IDXENTRY_VALID) != 0) + status = GIT_DELTA_UNMODIFIED; + + /* support "skip worktree" index bit */ + else if ((oitem->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) != 0) + status = GIT_DELTA_UNMODIFIED; + + /* if basic type of file changed, then split into delete and add */ + else if (GIT_MODE_TYPE(omode) != GIT_MODE_TYPE(nmode)) { + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE)) + status = GIT_DELTA_TYPECHANGE; + else if (nmode == GIT_FILEMODE_UNREADABLE) { + if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem))) + error = diff_delta__from_one(diff, GIT_DELTA_UNREADABLE, nitem); + return error; + } + else { + if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem))) + error = diff_delta__from_one(diff, GIT_DELTA_ADDED, nitem); + return error; + } + } + + /* if oids and modes match (and are valid), then file is unmodified */ + else if (git_oid_equal(&oitem->id, &nitem->id) && + omode == nmode && + !git_oid_iszero(&oitem->id)) + status = GIT_DELTA_UNMODIFIED; + + /* if we have an unknown OID and a workdir iterator, then check some + * circumstances that can accelerate things or need special handling + */ + else if (git_oid_iszero(&nitem->id) && new_is_workdir) { + bool use_ctime = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0); + bool use_nanos = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_NANOSECS) != 0); + + status = GIT_DELTA_UNMODIFIED; + + /* TODO: add check against index file st_mtime to avoid racy-git */ + + if (S_ISGITLINK(nmode)) { + if ((error = maybe_modified_submodule(&status, &noid, diff, info)) < 0) + return error; + } + + /* if the stat data looks different, then mark modified - this just + * means that the OID will be recalculated below to confirm change + */ + else if (omode != nmode || oitem->file_size != nitem->file_size) { + status = GIT_DELTA_MODIFIED; + modified_uncertain = + (oitem->file_size <= 0 && nitem->file_size > 0); + } + else if (!diff_time_eq(&oitem->mtime, &nitem->mtime, use_nanos) || + (use_ctime && + !diff_time_eq(&oitem->ctime, &nitem->ctime, use_nanos)) || + oitem->ino != nitem->ino || + oitem->uid != nitem->uid || + oitem->gid != nitem->gid) + { + status = GIT_DELTA_MODIFIED; + modified_uncertain = true; + } + } + + /* if mode is GITLINK and submodules are ignored, then skip */ + else if (S_ISGITLINK(nmode) && + DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES)) + status = GIT_DELTA_UNMODIFIED; + + /* if we got here and decided that the files are modified, but we + * haven't calculated the OID of the new item, then calculate it now + */ + if (modified_uncertain && git_oid_iszero(&nitem->id)) { + if (git_oid_iszero(&noid)) { + const git_oid *update_check = + DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) ? + &oitem->id : NULL; + + if ((error = git_diff__oid_for_entry( + &noid, diff, nitem, update_check)) < 0) + return error; + } + + /* if oid matches, then mark unmodified (except submodules, where + * the filesystem content may be modified even if the oid still + * matches between the index and the workdir HEAD) + */ + if (omode == nmode && !S_ISGITLINK(omode) && + git_oid_equal(&oitem->id, &noid)) + status = GIT_DELTA_UNMODIFIED; + } + + return diff_delta__from_two( + diff, status, oitem, omode, nitem, nmode, + git_oid_iszero(&noid) ? NULL : &noid, matched_pathspec); +} + +static bool entry_is_prefixed( + git_diff *diff, + const git_index_entry *item, + const git_index_entry *prefix_item) +{ + size_t pathlen; + + if (!item || diff->pfxcomp(item->path, prefix_item->path) != 0) + return false; + + pathlen = strlen(prefix_item->path); + + return (prefix_item->path[pathlen - 1] == '/' || + item->path[pathlen] == '\0' || + item->path[pathlen] == '/'); +} + +static int handle_unmatched_new_item( + git_diff *diff, diff_in_progress *info) +{ + int error = 0; + const git_index_entry *nitem = info->nitem; + git_delta_t delta_type = GIT_DELTA_UNTRACKED; + bool contains_oitem; + + /* check if this is a prefix of the other side */ + contains_oitem = entry_is_prefixed(diff, info->oitem, nitem); + + /* update delta_type if this item is ignored */ + if (git_iterator_current_is_ignored(info->new_iter)) + delta_type = GIT_DELTA_IGNORED; + + if (nitem->mode == GIT_FILEMODE_TREE) { + bool recurse_into_dir = contains_oitem; + + /* check if user requests recursion into this type of dir */ + recurse_into_dir = contains_oitem || + (delta_type == GIT_DELTA_UNTRACKED && + DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) || + (delta_type == GIT_DELTA_IGNORED && + DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS)); + + /* do not advance into directories that contain a .git file */ + if (recurse_into_dir && !contains_oitem) { + git_buf *full = NULL; + if (git_iterator_current_workdir_path(&full, info->new_iter) < 0) + return -1; + if (full && git_path_contains(full, DOT_GIT)) { + /* TODO: warning if not a valid git repository */ + recurse_into_dir = false; + } + } + + /* still have to look into untracked directories to match core git - + * with no untracked files, directory is treated as ignored + */ + if (!recurse_into_dir && + delta_type == GIT_DELTA_UNTRACKED && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS)) + { + git_diff_delta *last; + git_iterator_status_t untracked_state; + + /* attempt to insert record for this directory */ + if ((error = diff_delta__from_one(diff, delta_type, nitem)) != 0) + return error; + + /* if delta wasn't created (because of rules), just skip ahead */ + last = diff_delta__last_for_item(diff, nitem); + if (!last) + return git_iterator_advance(&info->nitem, info->new_iter); + + /* iterate into dir looking for an actual untracked file */ + if ((error = git_iterator_advance_over_with_status( + &info->nitem, &untracked_state, info->new_iter)) < 0 && + error != GIT_ITEROVER) + return error; + + /* if we found nothing or just ignored items, update the record */ + if (untracked_state == GIT_ITERATOR_STATUS_IGNORED || + untracked_state == GIT_ITERATOR_STATUS_EMPTY) { + last->status = GIT_DELTA_IGNORED; + + /* remove the record if we don't want ignored records */ + if (DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED)) { + git_vector_pop(&diff->deltas); + git__free(last); + } + } + + return 0; + } + + /* try to advance into directory if necessary */ + if (recurse_into_dir) { + error = git_iterator_advance_into(&info->nitem, info->new_iter); + + /* if real error or no error, proceed with iteration */ + if (error != GIT_ENOTFOUND) + return error; + giterr_clear(); + + /* if directory is empty, can't advance into it, so either skip + * it or ignore it + */ + if (contains_oitem) + return git_iterator_advance(&info->nitem, info->new_iter); + delta_type = GIT_DELTA_IGNORED; + } + } + + else if (delta_type == GIT_DELTA_IGNORED && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS) && + git_iterator_current_tree_is_ignored(info->new_iter)) + /* item contained in ignored directory, so skip over it */ + return git_iterator_advance(&info->nitem, info->new_iter); + + else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR) + delta_type = GIT_DELTA_ADDED; + + else if (nitem->mode == GIT_FILEMODE_COMMIT) { + /* ignore things that are not actual submodules */ + if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) { + giterr_clear(); + delta_type = GIT_DELTA_IGNORED; + + /* if this contains a tracked item, treat as normal TREE */ + if (contains_oitem) { + error = git_iterator_advance_into(&info->nitem, info->new_iter); + if (error != GIT_ENOTFOUND) + return error; + + giterr_clear(); + return git_iterator_advance(&info->nitem, info->new_iter); + } + } + } + + else if (nitem->mode == GIT_FILEMODE_UNREADABLE) { + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED)) + delta_type = GIT_DELTA_UNTRACKED; + else + delta_type = GIT_DELTA_UNREADABLE; + } + + /* Actually create the record for this item if necessary */ + if ((error = diff_delta__from_one(diff, delta_type, nitem)) != 0) + return error; + + /* If user requested TYPECHANGE records, then check for that instead of + * just generating an ADDED/UNTRACKED record + */ + if (delta_type != GIT_DELTA_IGNORED && + DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) && + contains_oitem) + { + /* this entry was prefixed with a tree - make TYPECHANGE */ + git_diff_delta *last = diff_delta__last_for_item(diff, nitem); + if (last) { + last->status = GIT_DELTA_TYPECHANGE; + last->old_file.mode = GIT_FILEMODE_TREE; + } + } + + return git_iterator_advance(&info->nitem, info->new_iter); +} + +static int handle_unmatched_old_item( + git_diff *diff, diff_in_progress *info) +{ + int error = diff_delta__from_one(diff, GIT_DELTA_DELETED, info->oitem); + if (error != 0) + return error; + + /* if we are generating TYPECHANGE records then check for that + * instead of just generating a DELETE record + */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) && + entry_is_prefixed(diff, info->nitem, info->oitem)) + { + /* this entry has become a tree! convert to TYPECHANGE */ + git_diff_delta *last = diff_delta__last_for_item(diff, info->oitem); + if (last) { + last->status = GIT_DELTA_TYPECHANGE; + last->new_file.mode = GIT_FILEMODE_TREE; + } + + /* If new_iter is a workdir iterator, then this situation + * will certainly be followed by a series of untracked items. + * Unless RECURSE_UNTRACKED_DIRS is set, skip over them... + */ + if (S_ISDIR(info->nitem->mode) && + DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) + return git_iterator_advance(&info->nitem, info->new_iter); + } + + return git_iterator_advance(&info->oitem, info->old_iter); +} + +static int handle_matched_item( + git_diff *diff, diff_in_progress *info) +{ + int error = 0; + + if ((error = maybe_modified(diff, info)) < 0) + return error; + + if (!(error = git_iterator_advance(&info->oitem, info->old_iter)) || + error == GIT_ITEROVER) + error = git_iterator_advance(&info->nitem, info->new_iter); + + return error; +} + +int git_diff__from_iterators( + git_diff **diff_ptr, + git_repository *repo, + git_iterator *old_iter, + git_iterator *new_iter, + const git_diff_options *opts) +{ + int error = 0; + diff_in_progress info; + git_diff *diff; + + *diff_ptr = NULL; + + diff = diff_list_alloc(repo, old_iter, new_iter); + GITERR_CHECK_ALLOC(diff); + + info.repo = repo; + info.old_iter = old_iter; + info.new_iter = new_iter; + + /* make iterators have matching icase behavior */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE)) { + if ((error = git_iterator_set_ignore_case(old_iter, true)) < 0 || + (error = git_iterator_set_ignore_case(new_iter, true)) < 0) + goto cleanup; + } + + /* finish initialization */ + if ((error = diff_list_apply_options(diff, opts)) < 0) + goto cleanup; + + if ((error = git_iterator_current(&info.oitem, old_iter)) < 0 && + error != GIT_ITEROVER) + goto cleanup; + if ((error = git_iterator_current(&info.nitem, new_iter)) < 0 && + error != GIT_ITEROVER) + goto cleanup; + error = 0; + + /* run iterators building diffs */ + while (!error && (info.oitem || info.nitem)) { + int cmp = info.oitem ? + (info.nitem ? diff->entrycomp(info.oitem, info.nitem) : -1) : 1; + + /* create DELETED records for old items not matched in new */ + if (cmp < 0) + error = handle_unmatched_old_item(diff, &info); + + /* create ADDED, TRACKED, or IGNORED records for new items not + * matched in old (and/or descend into directories as needed) + */ + else if (cmp > 0) + error = handle_unmatched_new_item(diff, &info); + + /* otherwise item paths match, so create MODIFIED record + * (or ADDED and DELETED pair if type changed) + */ + else + error = handle_matched_item(diff, &info); + + /* because we are iterating over two lists, ignore ITEROVER */ + if (error == GIT_ITEROVER) + error = 0; + } + + diff->perf.stat_calls += old_iter->stat_calls + new_iter->stat_calls; + +cleanup: + if (!error) + *diff_ptr = diff; + else + git_diff_free(diff); + + return error; +} + +#define DIFF_FROM_ITERATORS(MAKE_FIRST, MAKE_SECOND) do { \ + git_iterator *a = NULL, *b = NULL; \ + char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL; \ + GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \ + if (!(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \ + error = git_diff__from_iterators(diff, repo, a, b, opts); \ + git__free(pfx); git_iterator_free(a); git_iterator_free(b); \ +} while (0) + +int git_diff_tree_to_tree( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + git_tree *new_tree, + const git_diff_options *opts) +{ + int error = 0; + git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE; + + assert(diff && repo); + + /* for tree to tree diff, be case sensitive even if the index is + * currently case insensitive, unless the user explicitly asked + * for case insensitivity + */ + if (opts && (opts->flags & GIT_DIFF_IGNORE_CASE) != 0) + iflag = GIT_ITERATOR_IGNORE_CASE; + + DIFF_FROM_ITERATORS( + git_iterator_for_tree(&a, old_tree, iflag, pfx, pfx), + git_iterator_for_tree(&b, new_tree, iflag, pfx, pfx) + ); + + return error; +} + +static int diff_load_index(git_index **index, git_repository *repo) +{ + int error = git_repository_index__weakptr(index, repo); + + /* reload the repository index when user did not pass one in */ + if (!error && git_index_read(*index, false) < 0) + giterr_clear(); + + return error; +} + +int git_diff_tree_to_index( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + git_index *index, + const git_diff_options *opts) +{ + int error = 0; + bool index_ignore_case = false; + + assert(diff && repo); + + if (!index && (error = diff_load_index(&index, repo)) < 0) + return error; + + index_ignore_case = index->ignore_case; + + DIFF_FROM_ITERATORS( + git_iterator_for_tree( + &a, old_tree, GIT_ITERATOR_DONT_IGNORE_CASE, pfx, pfx), + git_iterator_for_index( + &b, index, GIT_ITERATOR_DONT_IGNORE_CASE, pfx, pfx) + ); + + /* if index is in case-insensitive order, re-sort deltas to match */ + if (!error && index_ignore_case) + diff_set_ignore_case(*diff, true); + + return error; +} + +int git_diff_index_to_workdir( + git_diff **diff, + git_repository *repo, + git_index *index, + const git_diff_options *opts) +{ + int error = 0; + + assert(diff && repo); + + if (!index && (error = diff_load_index(&index, repo)) < 0) + return error; + + DIFF_FROM_ITERATORS( + git_iterator_for_index(&a, index, 0, pfx, pfx), + git_iterator_for_workdir( + &b, repo, index, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx) + ); + + if (!error && DIFF_FLAG_IS_SET(*diff, GIT_DIFF_UPDATE_INDEX)) + error = git_index_write(index); + + return error; +} + +int git_diff_tree_to_workdir( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + const git_diff_options *opts) +{ + int error = 0; + git_index *index; + + assert(diff && repo); + + if ((error = git_repository_index__weakptr(&index, repo))) + return error; + + DIFF_FROM_ITERATORS( + git_iterator_for_tree(&a, old_tree, 0, pfx, pfx), + git_iterator_for_workdir( + &b, repo, index, old_tree, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx) + ); + + return error; +} + +int git_diff_tree_to_workdir_with_index( + git_diff **diff, + git_repository *repo, + git_tree *old_tree, + const git_diff_options *opts) +{ + int error = 0; + git_diff *d1 = NULL, *d2 = NULL; + git_index *index = NULL; + + assert(diff && repo); + + if ((error = diff_load_index(&index, repo)) < 0) + return error; + + if (!(error = git_diff_tree_to_index(&d1, repo, old_tree, index, opts)) && + !(error = git_diff_index_to_workdir(&d2, repo, index, opts))) + error = git_diff_merge(d1, d2); + + git_diff_free(d2); + + if (error) { + git_diff_free(d1); + d1 = NULL; + } + + *diff = d1; + return error; +} + +size_t git_diff_num_deltas(const git_diff *diff) +{ + assert(diff); + return diff->deltas.length; +} + +size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type) +{ + size_t i, count = 0; + const git_diff_delta *delta; + + assert(diff); + + git_vector_foreach(&diff->deltas, i, delta) { + count += (delta->status == type); + } + + return count; +} + +const git_diff_delta *git_diff_get_delta(const git_diff *diff, size_t idx) +{ + assert(diff); + return git_vector_get(&diff->deltas, idx); +} + +int git_diff_is_sorted_icase(const git_diff *diff) +{ + return (diff->opts.flags & GIT_DIFF_IGNORE_CASE) != 0; +} + +int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff) +{ + assert(out); + GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata"); + out->stat_calls = diff->perf.stat_calls; + out->oid_calculations = diff->perf.oid_calculations; + return 0; +} + +int git_diff__paired_foreach( + git_diff *head2idx, + git_diff *idx2wd, + int (*cb)(git_diff_delta *h2i, git_diff_delta *i2w, void *payload), + void *payload) +{ + int cmp, error = 0; + git_diff_delta *h2i, *i2w; + size_t i, j, i_max, j_max; + int (*strcomp)(const char *, const char *) = git__strcmp; + bool h2i_icase, i2w_icase, icase_mismatch; + + i_max = head2idx ? head2idx->deltas.length : 0; + j_max = idx2wd ? idx2wd->deltas.length : 0; + if (!i_max && !j_max) + return 0; + + /* At some point, tree-to-index diffs will probably never ignore case, + * even if that isn't true now. Index-to-workdir diffs may or may not + * ignore case, but the index filename for the idx2wd diff should + * still be using the canonical case-preserving name. + * + * Therefore the main thing we need to do here is make sure the diffs + * are traversed in a compatible order. To do this, we temporarily + * resort a mismatched diff to get the order correct. + * + * In order to traverse renames in the index->workdir, we need to + * ensure that we compare the index name on both sides, so we + * always sort by the old name in the i2w list. + */ + h2i_icase = head2idx != NULL && + (head2idx->opts.flags & GIT_DIFF_IGNORE_CASE) != 0; + + i2w_icase = idx2wd != NULL && + (idx2wd->opts.flags & GIT_DIFF_IGNORE_CASE) != 0; + + icase_mismatch = + (head2idx != NULL && idx2wd != NULL && h2i_icase != i2w_icase); + + if (icase_mismatch && h2i_icase) { + git_vector_set_cmp(&head2idx->deltas, git_diff_delta__cmp); + git_vector_sort(&head2idx->deltas); + } + + if (i2w_icase && !icase_mismatch) { + strcomp = git__strcasecmp; + + git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp); + git_vector_sort(&idx2wd->deltas); + } else if (idx2wd != NULL) { + git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp); + git_vector_sort(&idx2wd->deltas); + } + + for (i = 0, j = 0; i < i_max || j < j_max; ) { + h2i = head2idx ? GIT_VECTOR_GET(&head2idx->deltas, i) : NULL; + i2w = idx2wd ? GIT_VECTOR_GET(&idx2wd->deltas, j) : NULL; + + cmp = !i2w ? -1 : !h2i ? 1 : + strcomp(h2i->new_file.path, i2w->old_file.path); + + if (cmp < 0) { + i++; i2w = NULL; + } else if (cmp > 0) { + j++; h2i = NULL; + } else { + i++; j++; + } + + if ((error = cb(h2i, i2w, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + /* restore case-insensitive delta sort */ + if (icase_mismatch && h2i_icase) { + git_vector_set_cmp(&head2idx->deltas, git_diff_delta__casecmp); + git_vector_sort(&head2idx->deltas); + } + + /* restore idx2wd sort by new path */ + if (idx2wd != NULL) { + git_vector_set_cmp(&idx2wd->deltas, + i2w_icase ? git_diff_delta__casecmp : git_diff_delta__cmp); + git_vector_sort(&idx2wd->deltas); + } + + return error; +} + +int git_diff__commit( + git_diff **diff, + git_repository *repo, + const git_commit *commit, + const git_diff_options *opts) +{ + git_commit *parent = NULL; + git_diff *commit_diff = NULL; + git_tree *old_tree = NULL, *new_tree = NULL; + size_t parents; + int error = 0; + + if ((parents = git_commit_parentcount(commit)) > 1) { + char commit_oidstr[GIT_OID_HEXSZ + 1]; + + error = -1; + giterr_set(GITERR_INVALID, "Commit %s is a merge commit", + git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); + goto on_error; + } + + if (parents > 0) + if ((error = git_commit_parent(&parent, commit, 0)) < 0 || + (error = git_commit_tree(&old_tree, parent)) < 0) + goto on_error; + + if ((error = git_commit_tree(&new_tree, commit)) < 0 || + (error = git_diff_tree_to_tree(&commit_diff, repo, old_tree, new_tree, opts)) < 0) + goto on_error; + + *diff = commit_diff; + +on_error: + git_tree_free(new_tree); + git_tree_free(old_tree); + git_commit_free(parent); + + return error; +} + +int git_diff_format_email__append_header_tobuf( + git_buf *out, + const git_oid *id, + const git_signature *author, + const char *summary, + size_t patch_no, + size_t total_patches, + bool exclude_patchno_marker) +{ + char idstr[GIT_OID_HEXSZ + 1]; + char date_str[GIT_DATE_RFC2822_SZ]; + int error = 0; + + git_oid_fmt(idstr, id); + idstr[GIT_OID_HEXSZ] = '\0'; + + if ((error = git__date_rfc2822_fmt(date_str, sizeof(date_str), &author->when)) < 0) + return error; + + error = git_buf_printf(out, + "From %s Mon Sep 17 00:00:00 2001\n" \ + "From: %s <%s>\n" \ + "Date: %s\n" \ + "Subject: ", + idstr, + author->name, author->email, + date_str); + + if (error < 0) + return error; + + if (!exclude_patchno_marker) { + if (total_patches == 1) { + error = git_buf_puts(out, "[PATCH] "); + } else { + error = git_buf_printf(out, "[PATCH %"PRIuZ"/%"PRIuZ"] ", patch_no, total_patches); + } + + if (error < 0) + return error; + } + + error = git_buf_printf(out, "%s\n\n", summary); + + return error; +} + +int git_diff_format_email__append_patches_tobuf( + git_buf *out, + git_diff *diff) +{ + size_t i, deltas; + int error = 0; + + deltas = git_diff_num_deltas(diff); + + for (i = 0; i < deltas; ++i) { + git_patch *patch = NULL; + + if ((error = git_patch_from_diff(&patch, diff, i)) >= 0) + error = git_patch_to_buf(out, patch); + + git_patch_free(patch); + + if (error < 0) + break; + } + + return error; +} + +int git_diff_format_email( + git_buf *out, + git_diff *diff, + const git_diff_format_email_options *opts) +{ + git_diff_stats *stats = NULL; + char *summary = NULL, *loc = NULL; + bool ignore_marker; + unsigned int format_flags = 0; + size_t allocsize; + int error; + + assert(out && diff && opts); + assert(opts->summary && opts->id && opts->author); + + GITERR_CHECK_VERSION(opts, GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, "git_format_email_options"); + + if ((ignore_marker = opts->flags & GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER) == false) { + if (opts->patch_no > opts->total_patches) { + giterr_set(GITERR_INVALID, "patch %"PRIuZ" out of range. max %"PRIuZ, opts->patch_no, opts->total_patches); + return -1; + } + + if (opts->patch_no == 0) { + giterr_set(GITERR_INVALID, "invalid patch no %"PRIuZ". should be >0", opts->patch_no); + return -1; + } + } + + /* the summary we receive may not be clean. + * it could potentially contain new line characters + * or not be set, sanitize, */ + if ((loc = strpbrk(opts->summary, "\r\n")) != NULL) { + size_t offset = 0; + + if ((offset = (loc - opts->summary)) == 0) { + giterr_set(GITERR_INVALID, "summary is empty"); + error = -1; + goto on_error; + } + + GITERR_CHECK_ALLOC_ADD(&allocsize, offset, 1); + summary = git__calloc(allocsize, sizeof(char)); + GITERR_CHECK_ALLOC(summary); + + strncpy(summary, opts->summary, offset); + } + + error = git_diff_format_email__append_header_tobuf(out, + opts->id, opts->author, summary == NULL ? opts->summary : summary, + opts->patch_no, opts->total_patches, ignore_marker); + + if (error < 0) + goto on_error; + + format_flags = GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY; + + if ((error = git_buf_puts(out, "---\n")) < 0 || + (error = git_diff_get_stats(&stats, diff)) < 0 || + (error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 || + (error = git_buf_putc(out, '\n')) < 0 || + (error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0) + goto on_error; + + error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n"); + +on_error: + git__free(summary); + git_diff_stats_free(stats); + + return error; +} + +int git_diff_commit_as_email( + git_buf *out, + git_repository *repo, + git_commit *commit, + size_t patch_no, + size_t total_patches, + git_diff_format_email_flags_t flags, + const git_diff_options *diff_opts) +{ + git_diff *diff = NULL; + git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT; + int error; + + assert (out && repo && commit); + + opts.flags = flags; + opts.patch_no = patch_no; + opts.total_patches = total_patches; + opts.id = git_commit_id(commit); + opts.summary = git_commit_summary(commit); + opts.author = git_commit_author(commit); + + if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0) + return error; + + error = git_diff_format_email(out, diff, &opts); + + git_diff_free(diff); + return error; +} + +int git_diff_init_options(git_diff_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_options, GIT_DIFF_OPTIONS_INIT); + return 0; +} + +int git_diff_find_init_options( + git_diff_find_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_find_options, GIT_DIFF_FIND_OPTIONS_INIT); + return 0; +} + +int git_diff_format_email_init_options( + git_diff_format_email_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_format_email_options, + GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff.h b/deps/libgit2-sys-0.2.17/libgit2/src/diff.h new file mode 100644 index 000000000..3305238d0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_diff_h__ +#define INCLUDE_diff_h__ + +#include "git2/diff.h" +#include "git2/sys/diff.h" +#include "git2/oid.h" + +#include +#include "vector.h" +#include "buffer.h" +#include "iterator.h" +#include "repository.h" +#include "pool.h" +#include "odb.h" + +#define DIFF_OLD_PREFIX_DEFAULT "a/" +#define DIFF_NEW_PREFIX_DEFAULT "b/" + +enum { + GIT_DIFFCAPS_HAS_SYMLINKS = (1 << 0), /* symlinks on platform? */ + GIT_DIFFCAPS_IGNORE_STAT = (1 << 1), /* use stat? */ + GIT_DIFFCAPS_TRUST_MODE_BITS = (1 << 2), /* use st_mode? */ + GIT_DIFFCAPS_TRUST_CTIME = (1 << 3), /* use st_ctime? */ + GIT_DIFFCAPS_USE_DEV = (1 << 4), /* use st_dev? */ + GIT_DIFFCAPS_TRUST_NANOSECS = (1 << 5), /* use stat time nanoseconds */ +}; + +#define DIFF_FLAGS_KNOWN_BINARY (GIT_DIFF_FLAG_BINARY|GIT_DIFF_FLAG_NOT_BINARY) +#define DIFF_FLAGS_NOT_BINARY (GIT_DIFF_FLAG_NOT_BINARY|GIT_DIFF_FLAG__NO_DATA) + +enum { + GIT_DIFF_FLAG__FREE_PATH = (1 << 7), /* `path` is allocated memory */ + GIT_DIFF_FLAG__FREE_DATA = (1 << 8), /* internal file data is allocated */ + GIT_DIFF_FLAG__UNMAP_DATA = (1 << 9), /* internal file data is mmap'ed */ + GIT_DIFF_FLAG__NO_DATA = (1 << 10), /* file data should not be loaded */ + GIT_DIFF_FLAG__FREE_BLOB = (1 << 11), /* release the blob when done */ + GIT_DIFF_FLAG__LOADED = (1 << 12), /* file data has been loaded */ + + GIT_DIFF_FLAG__TO_DELETE = (1 << 16), /* delete entry during rename det. */ + GIT_DIFF_FLAG__TO_SPLIT = (1 << 17), /* split entry during rename det. */ + GIT_DIFF_FLAG__IS_RENAME_TARGET = (1 << 18), + GIT_DIFF_FLAG__IS_RENAME_SOURCE = (1 << 19), + GIT_DIFF_FLAG__HAS_SELF_SIMILARITY = (1 << 20), +}; + +#define GIT_DIFF_FLAG__CLEAR_INTERNAL(F) (F) = ((F) & 0x00FFFF) + +#define GIT_DIFF__VERBOSE (1 << 30) + +struct git_diff { + git_refcount rc; + git_repository *repo; + git_diff_options opts; + git_vector pathspec; + git_vector deltas; /* vector of git_diff_delta */ + git_pool pool; + git_iterator_type_t old_src; + git_iterator_type_t new_src; + uint32_t diffcaps; + git_diff_perfdata perf; + + int (*strcomp)(const char *, const char *); + int (*strncomp)(const char *, const char *, size_t); + int (*pfxcomp)(const char *str, const char *pfx); + int (*entrycomp)(const void *a, const void *b); +}; + +extern void git_diff__cleanup_modes( + uint32_t diffcaps, uint32_t *omode, uint32_t *nmode); + +extern void git_diff_addref(git_diff *diff); + +extern int git_diff_delta__cmp(const void *a, const void *b); +extern int git_diff_delta__casecmp(const void *a, const void *b); + +extern const char *git_diff_delta__path(const git_diff_delta *delta); + +extern bool git_diff_delta__should_skip( + const git_diff_options *opts, const git_diff_delta *delta); + +extern int git_diff_delta__format_file_header( + git_buf *out, + const git_diff_delta *delta, + const char *oldpfx, + const char *newpfx, + int oid_strlen); + +extern int git_diff__oid_for_file( + git_oid *out, git_diff *, const char *, uint16_t, git_off_t); +extern int git_diff__oid_for_entry( + git_oid *out, git_diff *, const git_index_entry *, const git_oid *update); + +extern int git_diff__from_iterators( + git_diff **diff_ptr, + git_repository *repo, + git_iterator *old_iter, + git_iterator *new_iter, + const git_diff_options *opts); + +extern int git_diff__paired_foreach( + git_diff *idx2head, + git_diff *wd2idx, + int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload), + void *payload); + +extern int git_diff_find_similar__hashsig_for_file( + void **out, const git_diff_file *f, const char *path, void *p); + +extern int git_diff_find_similar__hashsig_for_buf( + void **out, const git_diff_file *f, const char *buf, size_t len, void *p); + +extern void git_diff_find_similar__hashsig_free(void *sig, void *payload); + +extern int git_diff_find_similar__calc_similarity( + int *score, void *siga, void *sigb, void *payload); + +extern int git_diff__commit( + git_diff **diff, git_repository *repo, const git_commit *commit, const git_diff_options *opts); + +/* + * Sometimes a git_diff_file will have a zero size; this attempts to + * fill in the size without loading the blob if possible. If that is + * not possible, then it will return the git_odb_object that had to be + * loaded and the caller can use it or dispose of it as needed. + */ +GIT_INLINE(int) git_diff_file__resolve_zero_size( + git_diff_file *file, git_odb_object **odb_obj, git_repository *repo) +{ + int error; + git_odb *odb; + size_t len; + git_otype type; + + if ((error = git_repository_odb(&odb, repo)) < 0) + return error; + + error = git_odb__read_header_or_object( + odb_obj, &len, &type, odb, &file->id); + + git_odb_free(odb); + + if (!error) + file->size = (git_off_t)len; + + return error; +} + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.c new file mode 100644 index 000000000..69eef0f7a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.c @@ -0,0 +1,524 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" + +#include "git2/attr.h" + +#include "diff.h" +#include "diff_patch.h" +#include "diff_driver.h" +#include "strmap.h" +#include "map.h" +#include "buf_text.h" +#include "config.h" +#include "repository.h" + +GIT__USE_STRMAP + +typedef enum { + DIFF_DRIVER_AUTO = 0, + DIFF_DRIVER_BINARY = 1, + DIFF_DRIVER_TEXT = 2, + DIFF_DRIVER_PATTERNLIST = 3, +} git_diff_driver_t; + +typedef struct { + regex_t re; + int flags; +} git_diff_driver_pattern; + +enum { + REG_NEGATE = (1 << 15) /* get out of the way of existing flags */ +}; + +/* data for finding function context for a given file type */ +struct git_diff_driver { + git_diff_driver_t type; + uint32_t binary_flags; + uint32_t other_flags; + git_array_t(git_diff_driver_pattern) fn_patterns; + regex_t word_pattern; + char name[GIT_FLEX_ARRAY]; +}; + +#include "userdiff.h" + +struct git_diff_driver_registry { + git_strmap *drivers; +}; + +#define FORCE_DIFFABLE (GIT_DIFF_FORCE_TEXT | GIT_DIFF_FORCE_BINARY) + +static git_diff_driver global_drivers[3] = { + { DIFF_DRIVER_AUTO, 0, 0, }, + { DIFF_DRIVER_BINARY, GIT_DIFF_FORCE_BINARY, 0 }, + { DIFF_DRIVER_TEXT, GIT_DIFF_FORCE_TEXT, 0 }, +}; + +git_diff_driver_registry *git_diff_driver_registry_new() +{ + git_diff_driver_registry *reg = + git__calloc(1, sizeof(git_diff_driver_registry)); + if (!reg) + return NULL; + + if (git_strmap_alloc(®->drivers) < 0) { + git_diff_driver_registry_free(reg); + return NULL; + } + + return reg; +} + +void git_diff_driver_registry_free(git_diff_driver_registry *reg) +{ + git_diff_driver *drv; + + if (!reg) + return; + + git_strmap_foreach_value(reg->drivers, drv, git_diff_driver_free(drv)); + git_strmap_free(reg->drivers); + git__free(reg); +} + +static int diff_driver_add_patterns( + git_diff_driver *drv, const char *regex_str, int regex_flags) +{ + int error = 0; + const char *scan, *end; + git_diff_driver_pattern *pat = NULL; + git_buf buf = GIT_BUF_INIT; + + for (scan = regex_str; scan; scan = end) { + /* get pattern to fill in */ + if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) { + error = -1; + break; + } + + pat->flags = regex_flags; + if (*scan == '!') { + pat->flags |= REG_NEGATE; + ++scan; + } + + if ((end = strchr(scan, '\n')) != NULL) { + error = git_buf_set(&buf, scan, end - scan); + end++; + } else { + error = git_buf_sets(&buf, scan); + } + if (error < 0) + break; + + if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) < 0) { + /* if regex fails to compile, warn? fail? */ + error = giterr_set_regex(&pat->re, error); + regfree(&pat->re); + break; + } + } + + if (error && pat != NULL) + (void)git_array_pop(drv->fn_patterns); /* release last item */ + git_buf_free(&buf); + + return error; +} + +static int diff_driver_xfuncname(const git_config_entry *entry, void *payload) +{ + return diff_driver_add_patterns(payload, entry->value, REG_EXTENDED); +} + +static int diff_driver_funcname(const git_config_entry *entry, void *payload) +{ + return diff_driver_add_patterns(payload, entry->value, 0); +} + +static git_diff_driver_registry *git_repository_driver_registry( + git_repository *repo) +{ + if (!repo->diff_drivers) { + git_diff_driver_registry *reg = git_diff_driver_registry_new(); + reg = git__compare_and_swap(&repo->diff_drivers, NULL, reg); + + if (reg != NULL) /* if we race, free losing allocation */ + git_diff_driver_registry_free(reg); + } + + if (!repo->diff_drivers) + giterr_set(GITERR_REPOSITORY, "Unable to create diff driver registry"); + + return repo->diff_drivers; +} + +static int diff_driver_alloc( + git_diff_driver **out, size_t *namelen_out, const char *name) +{ + git_diff_driver *driver; + size_t driverlen = sizeof(git_diff_driver), + namelen = strlen(name), + alloclen; + + GITERR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + + driver = git__calloc(1, alloclen); + GITERR_CHECK_ALLOC(driver); + + memcpy(driver->name, name, namelen); + + *out = driver; + + if (namelen_out) + *namelen_out = namelen; + + return 0; +} + +static int git_diff_driver_builtin( + git_diff_driver **out, + git_diff_driver_registry *reg, + const char *driver_name) +{ + int error = 0; + git_diff_driver_definition *ddef = NULL; + git_diff_driver *drv = NULL; + size_t idx; + + for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) { + if (!strcasecmp(driver_name, builtin_defs[idx].name)) { + ddef = &builtin_defs[idx]; + break; + } + } + if (!ddef) + goto done; + + if ((error = diff_driver_alloc(&drv, NULL, ddef->name)) < 0) + goto done; + + drv->type = DIFF_DRIVER_PATTERNLIST; + + if (ddef->fns && + (error = diff_driver_add_patterns( + drv, ddef->fns, ddef->flags | REG_EXTENDED)) < 0) + goto done; + + if (ddef->words && + (error = regcomp( + &drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED))) + { + error = giterr_set_regex(&drv->word_pattern, error); + goto done; + } + + git_strmap_insert(reg->drivers, drv->name, drv, error); + if (error > 0) + error = 0; + +done: + if (error && drv) + git_diff_driver_free(drv); + else + *out = drv; + + return error; +} + +static int git_diff_driver_load( + git_diff_driver **out, git_repository *repo, const char *driver_name) +{ + int error = 0; + git_diff_driver_registry *reg; + git_diff_driver *drv = NULL; + size_t namelen; + khiter_t pos; + git_config *cfg = NULL; + git_buf name = GIT_BUF_INIT; + git_config_entry *ce = NULL; + bool found_driver = false; + + if ((reg = git_repository_driver_registry(repo)) == NULL) + return -1; + + pos = git_strmap_lookup_index(reg->drivers, driver_name); + if (git_strmap_valid_index(reg->drivers, pos)) { + *out = git_strmap_value_at(reg->drivers, pos); + return 0; + } + + if ((error = diff_driver_alloc(&drv, &namelen, driver_name)) < 0) + goto done; + + drv->type = DIFF_DRIVER_AUTO; + + /* if you can't read config for repo, just use default driver */ + if (git_repository_config_snapshot(&cfg, repo) < 0) { + giterr_clear(); + goto done; + } + + if ((error = git_buf_printf(&name, "diff.%s.binary", driver_name)) < 0) + goto done; + + switch (git_config__get_bool_force(cfg, name.ptr, -1)) { + case true: + /* if diff..binary is true, just return the binary driver */ + *out = &global_drivers[DIFF_DRIVER_BINARY]; + goto done; + case false: + /* if diff..binary is false, force binary checks off */ + /* but still may have custom function context patterns, etc. */ + drv->binary_flags = GIT_DIFF_FORCE_TEXT; + found_driver = true; + break; + default: + /* diff..binary unspecified or "auto", so just continue */ + break; + } + + /* TODO: warn if diff..command or diff..textconv are set */ + + git_buf_truncate(&name, namelen + strlen("diff..")); + git_buf_put(&name, "xfuncname", strlen("xfuncname")); + if ((error = git_config_get_multivar_foreach( + cfg, name.ptr, NULL, diff_driver_xfuncname, drv)) < 0) { + if (error != GIT_ENOTFOUND) + goto done; + giterr_clear(); /* no diff..xfuncname, so just continue */ + } + + git_buf_truncate(&name, namelen + strlen("diff..")); + git_buf_put(&name, "funcname", strlen("funcname")); + if ((error = git_config_get_multivar_foreach( + cfg, name.ptr, NULL, diff_driver_funcname, drv)) < 0) { + if (error != GIT_ENOTFOUND) + goto done; + giterr_clear(); /* no diff..funcname, so just continue */ + } + + /* if we found any patterns, set driver type to use correct callback */ + if (git_array_size(drv->fn_patterns) > 0) { + drv->type = DIFF_DRIVER_PATTERNLIST; + found_driver = true; + } + + git_buf_truncate(&name, namelen + strlen("diff..")); + git_buf_put(&name, "wordregex", strlen("wordregex")); + if ((error = git_config__lookup_entry(&ce, cfg, name.ptr, false)) < 0) + goto done; + if (!ce || !ce->value) + /* no diff..wordregex, so just continue */; + else if (!(error = regcomp(&drv->word_pattern, ce->value, REG_EXTENDED))) + found_driver = true; + else { + /* TODO: warn about bad regex instead of failure */ + error = giterr_set_regex(&drv->word_pattern, error); + goto done; + } + + /* TODO: look up diff..algorithm to turn on minimal / patience + * diff in drv->other_flags + */ + + /* if no driver config found at all, fall back on AUTO driver */ + if (!found_driver) + goto done; + + /* store driver in registry */ + git_strmap_insert(reg->drivers, drv->name, drv, error); + if (error < 0) + goto done; + error = 0; + + *out = drv; + +done: + git_config_entry_free(ce); + git_buf_free(&name); + git_config_free(cfg); + + if (!*out) { + int error2 = git_diff_driver_builtin(out, reg, driver_name); + if (!error) + error = error2; + } + + if (drv && drv != *out) + git_diff_driver_free(drv); + + return error; +} + +int git_diff_driver_lookup( + git_diff_driver **out, git_repository *repo, const char *path) +{ + int error = 0; + const char *value; + + assert(out); + *out = NULL; + + if (!repo || !path || !strlen(path)) + /* just use the auto value */; + else if ((error = git_attr_get(&value, repo, 0, path, "diff")) < 0) + /* return error below */; + else if (GIT_ATTR_UNSPECIFIED(value)) + /* just use the auto value */; + else if (GIT_ATTR_FALSE(value)) + *out = &global_drivers[DIFF_DRIVER_BINARY]; + else if (GIT_ATTR_TRUE(value)) + *out = &global_drivers[DIFF_DRIVER_TEXT]; + + /* otherwise look for driver information in config and build driver */ + else if ((error = git_diff_driver_load(out, repo, value)) < 0) { + if (error == GIT_ENOTFOUND) { + error = 0; + giterr_clear(); + } + } + + if (!*out) + *out = &global_drivers[DIFF_DRIVER_AUTO]; + + return error; +} + +void git_diff_driver_free(git_diff_driver *driver) +{ + size_t i; + + if (!driver) + return; + + for (i = 0; i < git_array_size(driver->fn_patterns); ++i) + regfree(& git_array_get(driver->fn_patterns, i)->re); + git_array_clear(driver->fn_patterns); + + regfree(&driver->word_pattern); + + git__free(driver); +} + +void git_diff_driver_update_options( + uint32_t *option_flags, git_diff_driver *driver) +{ + if ((*option_flags & FORCE_DIFFABLE) == 0) + *option_flags |= driver->binary_flags; + + *option_flags |= driver->other_flags; +} + +int git_diff_driver_content_is_binary( + git_diff_driver *driver, const char *content, size_t content_len) +{ + git_buf search = GIT_BUF_INIT; + + GIT_UNUSED(driver); + + git_buf_attach_notowned(&search, content, + min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL)); + + /* TODO: provide encoding / binary detection callbacks that can + * be UTF-8 aware, etc. For now, instead of trying to be smart, + * let's just use the simple NUL-byte detection that core git uses. + */ + + /* previously was: if (git_buf_text_is_binary(&search)) */ + if (git_buf_text_contains_nul(&search)) + return 1; + + return 0; +} + +static int diff_context_line__simple( + git_diff_driver *driver, git_buf *line) +{ + char firstch = line->ptr[0]; + GIT_UNUSED(driver); + return (git__isalpha(firstch) || firstch == '_' || firstch == '$'); +} + +static int diff_context_line__pattern_match( + git_diff_driver *driver, git_buf *line) +{ + size_t i, maxi = git_array_size(driver->fn_patterns); + regmatch_t pmatch[2]; + + for (i = 0; i < maxi; ++i) { + git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i); + + if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) { + if (pat->flags & REG_NEGATE) + return false; + + /* use pmatch data to trim line data */ + i = (pmatch[1].rm_so >= 0) ? 1 : 0; + git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so); + git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so); + git_buf_rtrim(line); + + return true; + } + } + + return false; +} + +static long diff_context_find( + const char *line, + long line_len, + char *out, + long out_size, + void *payload) +{ + git_diff_find_context_payload *ctxt = payload; + + if (git_buf_set(&ctxt->line, line, (size_t)line_len) < 0) + return -1; + git_buf_rtrim(&ctxt->line); + + if (!ctxt->line.size) + return -1; + + if (!ctxt->match_line || !ctxt->match_line(ctxt->driver, &ctxt->line)) + return -1; + + if (out_size > (long)ctxt->line.size) + out_size = (long)ctxt->line.size; + memcpy(out, ctxt->line.ptr, (size_t)out_size); + + return out_size; +} + +void git_diff_find_context_init( + git_diff_find_context_fn *findfn_out, + git_diff_find_context_payload *payload_out, + git_diff_driver *driver) +{ + *findfn_out = driver ? diff_context_find : NULL; + + memset(payload_out, 0, sizeof(*payload_out)); + if (driver) { + payload_out->driver = driver; + payload_out->match_line = (driver->type == DIFF_DRIVER_PATTERNLIST) ? + diff_context_line__pattern_match : diff_context_line__simple; + git_buf_init(&payload_out->line, 0); + } +} + +void git_diff_find_context_clear(git_diff_find_context_payload *payload) +{ + if (payload) { + git_buf_free(&payload->line); + payload->driver = NULL; + } +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.h b/deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.h new file mode 100644 index 000000000..0706dcfc5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_driver.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_diff_driver_h__ +#define INCLUDE_diff_driver_h__ + +#include "common.h" +#include "buffer.h" + +typedef struct git_diff_driver_registry git_diff_driver_registry; + +git_diff_driver_registry *git_diff_driver_registry_new(void); +void git_diff_driver_registry_free(git_diff_driver_registry *); + +typedef struct git_diff_driver git_diff_driver; + +int git_diff_driver_lookup(git_diff_driver **, git_repository *, const char *); +void git_diff_driver_free(git_diff_driver *); + +/* diff option flags to force off and on for this driver */ +void git_diff_driver_update_options(uint32_t *option_flags, git_diff_driver *); + +/* returns -1 meaning "unknown", 0 meaning not binary, 1 meaning binary */ +int git_diff_driver_content_is_binary( + git_diff_driver *, const char *content, size_t content_len); + +typedef long (*git_diff_find_context_fn)( + const char *, long, char *, long, void *); + +typedef int (*git_diff_find_context_line)( + git_diff_driver *, git_buf *); + +typedef struct { + git_diff_driver *driver; + git_diff_find_context_line match_line; + git_buf line; +} git_diff_find_context_payload; + +void git_diff_find_context_init( + git_diff_find_context_fn *findfn_out, + git_diff_find_context_payload *payload_out, + git_diff_driver *driver); + +void git_diff_find_context_clear(git_diff_find_context_payload *); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_file.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_file.c new file mode 100644 index 000000000..f7061ae83 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_file.c @@ -0,0 +1,429 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "git2/blob.h" +#include "git2/submodule.h" +#include "diff.h" +#include "diff_file.h" +#include "odb.h" +#include "fileops.h" +#include "filter.h" + +#define DIFF_MAX_FILESIZE 0x20000000 + +static bool diff_file_content_binary_by_size(git_diff_file_content *fc) +{ + /* if we have diff opts, check max_size vs file size */ + if ((fc->file->flags & DIFF_FLAGS_KNOWN_BINARY) == 0 && + fc->opts_max_size > 0 && + fc->file->size > fc->opts_max_size) + fc->file->flags |= GIT_DIFF_FLAG_BINARY; + + return ((fc->file->flags & GIT_DIFF_FLAG_BINARY) != 0); +} + +static void diff_file_content_binary_by_content(git_diff_file_content *fc) +{ + if ((fc->file->flags & DIFF_FLAGS_KNOWN_BINARY) != 0) + return; + + switch (git_diff_driver_content_is_binary( + fc->driver, fc->map.data, fc->map.len)) { + case 0: fc->file->flags |= GIT_DIFF_FLAG_NOT_BINARY; break; + case 1: fc->file->flags |= GIT_DIFF_FLAG_BINARY; break; + default: break; + } +} + +static int diff_file_content_init_common( + git_diff_file_content *fc, const git_diff_options *opts) +{ + fc->opts_flags = opts ? opts->flags : GIT_DIFF_NORMAL; + + if (opts && opts->max_size >= 0) + fc->opts_max_size = opts->max_size ? + opts->max_size : DIFF_MAX_FILESIZE; + + if (fc->src == GIT_ITERATOR_TYPE_EMPTY) + fc->src = GIT_ITERATOR_TYPE_TREE; + + if (!fc->driver && + git_diff_driver_lookup(&fc->driver, fc->repo, fc->file->path) < 0) + return -1; + + /* give driver a chance to modify options */ + git_diff_driver_update_options(&fc->opts_flags, fc->driver); + + /* make sure file is conceivable mmap-able */ + if ((git_off_t)((size_t)fc->file->size) != fc->file->size) + fc->file->flags |= GIT_DIFF_FLAG_BINARY; + /* check if user is forcing text diff the file */ + else if (fc->opts_flags & GIT_DIFF_FORCE_TEXT) { + fc->file->flags &= ~GIT_DIFF_FLAG_BINARY; + fc->file->flags |= GIT_DIFF_FLAG_NOT_BINARY; + } + /* check if user is forcing binary diff the file */ + else if (fc->opts_flags & GIT_DIFF_FORCE_BINARY) { + fc->file->flags &= ~GIT_DIFF_FLAG_NOT_BINARY; + fc->file->flags |= GIT_DIFF_FLAG_BINARY; + } + + diff_file_content_binary_by_size(fc); + + if ((fc->flags & GIT_DIFF_FLAG__NO_DATA) != 0) { + fc->flags |= GIT_DIFF_FLAG__LOADED; + fc->map.len = 0; + fc->map.data = ""; + } + + if ((fc->flags & GIT_DIFF_FLAG__LOADED) != 0) + diff_file_content_binary_by_content(fc); + + return 0; +} + +int git_diff_file_content__init_from_diff( + git_diff_file_content *fc, + git_diff *diff, + size_t delta_index, + bool use_old) +{ + git_diff_delta *delta = git_vector_get(&diff->deltas, delta_index); + bool has_data = true; + + memset(fc, 0, sizeof(*fc)); + fc->repo = diff->repo; + fc->file = use_old ? &delta->old_file : &delta->new_file; + fc->src = use_old ? diff->old_src : diff->new_src; + + if (git_diff_driver_lookup(&fc->driver, fc->repo, fc->file->path) < 0) + return -1; + + switch (delta->status) { + case GIT_DELTA_ADDED: + has_data = !use_old; break; + case GIT_DELTA_DELETED: + has_data = use_old; break; + case GIT_DELTA_UNTRACKED: + has_data = !use_old && + (diff->opts.flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) != 0; + break; + case GIT_DELTA_UNREADABLE: + case GIT_DELTA_MODIFIED: + case GIT_DELTA_COPIED: + case GIT_DELTA_RENAMED: + break; + default: + has_data = false; + break; + } + + if (!has_data) + fc->flags |= GIT_DIFF_FLAG__NO_DATA; + + return diff_file_content_init_common(fc, &diff->opts); +} + +int git_diff_file_content__init_from_src( + git_diff_file_content *fc, + git_repository *repo, + const git_diff_options *opts, + const git_diff_file_content_src *src, + git_diff_file *as_file) +{ + memset(fc, 0, sizeof(*fc)); + fc->repo = repo; + fc->file = as_file; + fc->blob = src->blob; + + if (!src->blob && !src->buf) { + fc->flags |= GIT_DIFF_FLAG__NO_DATA; + } else { + fc->flags |= GIT_DIFF_FLAG__LOADED; + fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; + fc->file->mode = GIT_FILEMODE_BLOB; + + if (src->blob) { + fc->file->size = git_blob_rawsize(src->blob); + git_oid_cpy(&fc->file->id, git_blob_id(src->blob)); + + fc->map.len = (size_t)fc->file->size; + fc->map.data = (char *)git_blob_rawcontent(src->blob); + } else { + fc->file->size = src->buflen; + git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB); + + fc->map.len = src->buflen; + fc->map.data = (char *)src->buf; + } + } + + return diff_file_content_init_common(fc, opts); +} + +static int diff_file_content_commit_to_str( + git_diff_file_content *fc, bool check_status) +{ + char oid[GIT_OID_HEXSZ+1]; + git_buf content = GIT_BUF_INIT; + const char *status = ""; + + if (check_status) { + int error = 0; + git_submodule *sm = NULL; + unsigned int sm_status = 0; + const git_oid *sm_head; + + if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) { + /* GIT_EEXISTS means a "submodule" that has not been git added */ + if (error == GIT_EEXISTS) { + giterr_clear(); + error = 0; + } + return error; + } + + if ((error = git_submodule_status(&sm_status, sm)) < 0) { + git_submodule_free(sm); + return error; + } + + /* update OID if we didn't have it previously */ + if ((fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0 && + ((sm_head = git_submodule_wd_id(sm)) != NULL || + (sm_head = git_submodule_head_id(sm)) != NULL)) + { + git_oid_cpy(&fc->file->id, sm_head); + fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; + } + + if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status)) + status = "-dirty"; + + git_submodule_free(sm); + } + + git_oid_tostr(oid, sizeof(oid), &fc->file->id); + if (git_buf_printf(&content, "Subproject commit %s%s\n", oid, status) < 0) + return -1; + + fc->map.len = git_buf_len(&content); + fc->map.data = git_buf_detach(&content); + fc->flags |= GIT_DIFF_FLAG__FREE_DATA; + + return 0; +} + +static int diff_file_content_load_blob(git_diff_file_content *fc) +{ + int error = 0; + git_odb_object *odb_obj = NULL; + + if (git_oid_iszero(&fc->file->id)) + return 0; + + if (fc->file->mode == GIT_FILEMODE_COMMIT) + return diff_file_content_commit_to_str(fc, false); + + /* if we don't know size, try to peek at object header first */ + if (!fc->file->size) { + if ((error = git_diff_file__resolve_zero_size( + fc->file, &odb_obj, fc->repo)) < 0) + return error; + } + + if (diff_file_content_binary_by_size(fc)) + return 0; + + if (odb_obj != NULL) { + error = git_object__from_odb_object( + (git_object **)&fc->blob, fc->repo, odb_obj, GIT_OBJ_BLOB); + git_odb_object_free(odb_obj); + } else { + error = git_blob_lookup( + (git_blob **)&fc->blob, fc->repo, &fc->file->id); + } + + if (!error) { + fc->flags |= GIT_DIFF_FLAG__FREE_BLOB; + fc->map.data = (void *)git_blob_rawcontent(fc->blob); + fc->map.len = (size_t)git_blob_rawsize(fc->blob); + } + + return error; +} + +static int diff_file_content_load_workdir_symlink( + git_diff_file_content *fc, git_buf *path) +{ + ssize_t alloc_len, read_len; + + /* link path on disk could be UTF-16, so prepare a buffer that is + * big enough to handle some UTF-8 data expansion + */ + alloc_len = (ssize_t)(fc->file->size * 2) + 1; + + fc->map.data = git__calloc(alloc_len, sizeof(char)); + GITERR_CHECK_ALLOC(fc->map.data); + + fc->flags |= GIT_DIFF_FLAG__FREE_DATA; + + read_len = p_readlink(git_buf_cstr(path), fc->map.data, alloc_len); + if (read_len < 0) { + giterr_set(GITERR_OS, "Failed to read symlink '%s'", fc->file->path); + return -1; + } + + fc->map.len = read_len; + return 0; +} + +static int diff_file_content_load_workdir_file( + git_diff_file_content *fc, git_buf *path) +{ + int error = 0; + git_filter_list *fl = NULL; + git_file fd = git_futils_open_ro(git_buf_cstr(path)); + git_buf raw = GIT_BUF_INIT; + + if (fd < 0) + return fd; + + if (!fc->file->size && + !(fc->file->size = git_futils_filesize(fd))) + goto cleanup; + + if (diff_file_content_binary_by_size(fc)) + goto cleanup; + + if ((error = git_filter_list_load( + &fl, fc->repo, NULL, fc->file->path, + GIT_FILTER_TO_ODB, GIT_FILTER_ALLOW_UNSAFE)) < 0) + goto cleanup; + + /* if there are no filters, try to mmap the file */ + if (fl == NULL) { + if (!(error = git_futils_mmap_ro( + &fc->map, fd, 0, (size_t)fc->file->size))) { + fc->flags |= GIT_DIFF_FLAG__UNMAP_DATA; + goto cleanup; + } + + /* if mmap failed, fall through to try readbuffer below */ + giterr_clear(); + } + + if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) { + git_buf out = GIT_BUF_INIT; + + error = git_filter_list_apply_to_data(&out, fl, &raw); + + if (out.ptr != raw.ptr) + git_buf_free(&raw); + + if (!error) { + fc->map.len = out.size; + fc->map.data = out.ptr; + fc->flags |= GIT_DIFF_FLAG__FREE_DATA; + } + } + +cleanup: + git_filter_list_free(fl); + p_close(fd); + + return error; +} + +static int diff_file_content_load_workdir(git_diff_file_content *fc) +{ + int error = 0; + git_buf path = GIT_BUF_INIT; + + if (fc->file->mode == GIT_FILEMODE_COMMIT) + return diff_file_content_commit_to_str(fc, true); + + if (fc->file->mode == GIT_FILEMODE_TREE) + return 0; + + if (git_buf_joinpath( + &path, git_repository_workdir(fc->repo), fc->file->path) < 0) + return -1; + + if (S_ISLNK(fc->file->mode)) + error = diff_file_content_load_workdir_symlink(fc, &path); + else + error = diff_file_content_load_workdir_file(fc, &path); + + /* once data is loaded, update OID if we didn't have it previously */ + if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) { + error = git_odb_hash( + &fc->file->id, fc->map.data, fc->map.len, GIT_OBJ_BLOB); + fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; + } + + git_buf_free(&path); + return error; +} + +int git_diff_file_content__load(git_diff_file_content *fc) +{ + int error = 0; + + if ((fc->flags & GIT_DIFF_FLAG__LOADED) != 0) + return 0; + + if ((fc->file->flags & GIT_DIFF_FLAG_BINARY) != 0) + return 0; + + if (fc->src == GIT_ITERATOR_TYPE_WORKDIR) + error = diff_file_content_load_workdir(fc); + else + error = diff_file_content_load_blob(fc); + if (error) + return error; + + fc->flags |= GIT_DIFF_FLAG__LOADED; + + diff_file_content_binary_by_content(fc); + + return 0; +} + +void git_diff_file_content__unload(git_diff_file_content *fc) +{ + if ((fc->flags & GIT_DIFF_FLAG__LOADED) == 0) + return; + + if (fc->flags & GIT_DIFF_FLAG__FREE_DATA) { + git__free(fc->map.data); + fc->map.data = ""; + fc->map.len = 0; + fc->flags &= ~GIT_DIFF_FLAG__FREE_DATA; + } + else if (fc->flags & GIT_DIFF_FLAG__UNMAP_DATA) { + git_futils_mmap_free(&fc->map); + fc->map.data = ""; + fc->map.len = 0; + fc->flags &= ~GIT_DIFF_FLAG__UNMAP_DATA; + } + + if (fc->flags & GIT_DIFF_FLAG__FREE_BLOB) { + git_blob_free((git_blob *)fc->blob); + fc->blob = NULL; + fc->flags &= ~GIT_DIFF_FLAG__FREE_BLOB; + } + + fc->flags &= ~GIT_DIFF_FLAG__LOADED; +} + +void git_diff_file_content__clear(git_diff_file_content *fc) +{ + git_diff_file_content__unload(fc); + + /* for now, nothing else to do */ +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_file.h b/deps/libgit2-sys-0.2.17/libgit2/src/diff_file.h new file mode 100644 index 000000000..4d290ad43 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_file.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_diff_file_h__ +#define INCLUDE_diff_file_h__ + +#include "common.h" +#include "diff.h" +#include "diff_driver.h" +#include "map.h" + +/* expanded information for one side of a delta */ +typedef struct { + git_repository *repo; + git_diff_file *file; + git_diff_driver *driver; + uint32_t flags; + uint32_t opts_flags; + git_off_t opts_max_size; + git_iterator_type_t src; + const git_blob *blob; + git_map map; +} git_diff_file_content; + +extern int git_diff_file_content__init_from_diff( + git_diff_file_content *fc, + git_diff *diff, + size_t delta_index, + bool use_old); + +typedef struct { + const git_blob *blob; + const void *buf; + size_t buflen; + const char *as_path; +} git_diff_file_content_src; + +#define GIT_DIFF_FILE_CONTENT_SRC__BLOB(BLOB,PATH) { (BLOB),NULL,0,(PATH) } +#define GIT_DIFF_FILE_CONTENT_SRC__BUF(BUF,LEN,PATH) { NULL,(BUF),(LEN),(PATH) } + +extern int git_diff_file_content__init_from_src( + git_diff_file_content *fc, + git_repository *repo, + const git_diff_options *opts, + const git_diff_file_content_src *src, + git_diff_file *as_file); + +/* this loads the blob/file-on-disk as needed */ +extern int git_diff_file_content__load(git_diff_file_content *fc); + +/* this releases the blob/file-in-memory */ +extern void git_diff_file_content__unload(git_diff_file_content *fc); + +/* this unloads and also releases any other resources */ +extern void git_diff_file_content__clear(git_diff_file_content *fc); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.c new file mode 100644 index 000000000..1c4c0e8b8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.c @@ -0,0 +1,943 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "git2/blob.h" +#include "diff.h" +#include "diff_file.h" +#include "diff_driver.h" +#include "diff_patch.h" +#include "diff_xdiff.h" +#include "fileops.h" + +/* cached information about a hunk in a diff */ +typedef struct diff_patch_hunk { + git_diff_hunk hunk; + size_t line_start; + size_t line_count; +} diff_patch_hunk; + +struct git_patch { + git_refcount rc; + git_diff *diff; /* for refcount purposes, maybe NULL for blob diffs */ + git_diff_delta *delta; + size_t delta_index; + git_diff_file_content ofile; + git_diff_file_content nfile; + uint32_t flags; + git_array_t(diff_patch_hunk) hunks; + git_array_t(git_diff_line) lines; + size_t content_size, context_size, header_size; + git_pool flattened; +}; + +enum { + GIT_DIFF_PATCH_ALLOCATED = (1 << 0), + GIT_DIFF_PATCH_INITIALIZED = (1 << 1), + GIT_DIFF_PATCH_LOADED = (1 << 2), + GIT_DIFF_PATCH_DIFFABLE = (1 << 3), + GIT_DIFF_PATCH_DIFFED = (1 << 4), + GIT_DIFF_PATCH_FLATTENED = (1 << 5), +}; + +static void diff_output_init( + git_diff_output*, const git_diff_options*, + git_diff_file_cb, git_diff_hunk_cb, git_diff_line_cb, void*); + +static void diff_output_to_patch(git_diff_output *, git_patch *); + +static void diff_patch_update_binary(git_patch *patch) +{ + if ((patch->delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0) + return; + + if ((patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0 || + (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0) + patch->delta->flags |= GIT_DIFF_FLAG_BINARY; + + else if ((patch->ofile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0 && + (patch->nfile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0) + patch->delta->flags |= GIT_DIFF_FLAG_NOT_BINARY; +} + +static void diff_patch_init_common(git_patch *patch) +{ + diff_patch_update_binary(patch); + + if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0) + patch->flags |= GIT_DIFF_PATCH_LOADED; /* LOADED but not DIFFABLE */ + + patch->flags |= GIT_DIFF_PATCH_INITIALIZED; + + if (patch->diff) + git_diff_addref(patch->diff); +} + +static int diff_patch_init_from_diff( + git_patch *patch, git_diff *diff, size_t delta_index) +{ + int error = 0; + + memset(patch, 0, sizeof(*patch)); + patch->diff = diff; + patch->delta = git_vector_get(&diff->deltas, delta_index); + patch->delta_index = delta_index; + + if ((error = git_diff_file_content__init_from_diff( + &patch->ofile, diff, delta_index, true)) < 0 || + (error = git_diff_file_content__init_from_diff( + &patch->nfile, diff, delta_index, false)) < 0) + return error; + + diff_patch_init_common(patch); + + return 0; +} + +static int diff_patch_alloc_from_diff( + git_patch **out, git_diff *diff, size_t delta_index) +{ + int error; + git_patch *patch = git__calloc(1, sizeof(git_patch)); + GITERR_CHECK_ALLOC(patch); + + if (!(error = diff_patch_init_from_diff(patch, diff, delta_index))) { + patch->flags |= GIT_DIFF_PATCH_ALLOCATED; + GIT_REFCOUNT_INC(patch); + } else { + git__free(patch); + patch = NULL; + } + + *out = patch; + return error; +} + +static int diff_patch_load(git_patch *patch, git_diff_output *output) +{ + int error = 0; + bool incomplete_data; + + if ((patch->flags & GIT_DIFF_PATCH_LOADED) != 0) + return 0; + + /* if no hunk and data callbacks and user doesn't care if data looks + * binary, then there is no need to actually load the data + */ + if ((patch->ofile.opts_flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0 && + output && !output->hunk_cb && !output->data_cb) + return 0; + + incomplete_data = + (((patch->ofile.flags & GIT_DIFF_FLAG__NO_DATA) != 0 || + (patch->ofile.file->flags & GIT_DIFF_FLAG_VALID_ID) != 0) && + ((patch->nfile.flags & GIT_DIFF_FLAG__NO_DATA) != 0 || + (patch->nfile.file->flags & GIT_DIFF_FLAG_VALID_ID) != 0)); + + /* always try to load workdir content first because filtering may + * need 2x data size and this minimizes peak memory footprint + */ + if (patch->ofile.src == GIT_ITERATOR_TYPE_WORKDIR) { + if ((error = git_diff_file_content__load(&patch->ofile)) < 0 || + (patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0) + goto cleanup; + } + if (patch->nfile.src == GIT_ITERATOR_TYPE_WORKDIR) { + if ((error = git_diff_file_content__load(&patch->nfile)) < 0 || + (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0) + goto cleanup; + } + + /* once workdir has been tried, load other data as needed */ + if (patch->ofile.src != GIT_ITERATOR_TYPE_WORKDIR) { + if ((error = git_diff_file_content__load(&patch->ofile)) < 0 || + (patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0) + goto cleanup; + } + if (patch->nfile.src != GIT_ITERATOR_TYPE_WORKDIR) { + if ((error = git_diff_file_content__load(&patch->nfile)) < 0 || + (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0) + goto cleanup; + } + + /* if previously missing an oid, and now that we have it the two sides + * are the same (and not submodules), update MODIFIED -> UNMODIFIED + */ + if (incomplete_data && + patch->ofile.file->mode == patch->nfile.file->mode && + patch->ofile.file->mode != GIT_FILEMODE_COMMIT && + git_oid_equal(&patch->ofile.file->id, &patch->nfile.file->id) && + patch->delta->status == GIT_DELTA_MODIFIED) /* not RENAMED/COPIED! */ + patch->delta->status = GIT_DELTA_UNMODIFIED; + +cleanup: + diff_patch_update_binary(patch); + + if (!error) { + /* patch is diffable only for non-binary, modified files where + * at least one side has data and the data actually changed + */ + if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) == 0 && + patch->delta->status != GIT_DELTA_UNMODIFIED && + (patch->ofile.map.len || patch->nfile.map.len) && + (patch->ofile.map.len != patch->nfile.map.len || + !git_oid_equal(&patch->ofile.file->id, &patch->nfile.file->id))) + patch->flags |= GIT_DIFF_PATCH_DIFFABLE; + + patch->flags |= GIT_DIFF_PATCH_LOADED; + } + + return error; +} + +static int diff_patch_invoke_file_callback( + git_patch *patch, git_diff_output *output) +{ + float progress = patch->diff ? + ((float)patch->delta_index / patch->diff->deltas.length) : 1.0f; + + if (!output->file_cb) + return 0; + + return giterr_set_after_callback_function( + output->file_cb(patch->delta, progress, output->payload), + "git_patch"); +} + +static int diff_patch_generate(git_patch *patch, git_diff_output *output) +{ + int error = 0; + + if ((patch->flags & GIT_DIFF_PATCH_DIFFED) != 0) + return 0; + + /* if we are not looking at the hunks and lines, don't do the diff */ + if (!output->hunk_cb && !output->data_cb) + return 0; + + if ((patch->flags & GIT_DIFF_PATCH_LOADED) == 0 && + (error = diff_patch_load(patch, output)) < 0) + return error; + + if ((patch->flags & GIT_DIFF_PATCH_DIFFABLE) == 0) + return 0; + + if (output->diff_cb != NULL && + (error = output->diff_cb(output, patch)) < 0) + patch->flags |= GIT_DIFF_PATCH_DIFFED; + + return error; +} + +static void diff_patch_free(git_patch *patch) +{ + git_diff_file_content__clear(&patch->ofile); + git_diff_file_content__clear(&patch->nfile); + + git_array_clear(patch->lines); + git_array_clear(patch->hunks); + + git_diff_free(patch->diff); /* decrements refcount */ + patch->diff = NULL; + + git_pool_clear(&patch->flattened); + + if (patch->flags & GIT_DIFF_PATCH_ALLOCATED) + git__free(patch); +} + +static int diff_required(git_diff *diff, const char *action) +{ + if (diff) + return 0; + giterr_set(GITERR_INVALID, "Must provide valid diff to %s", action); + return -1; +} + +int git_diff_foreach( + git_diff *diff, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb data_cb, + void *payload) +{ + int error = 0; + git_xdiff_output xo; + size_t idx; + git_patch patch; + + if ((error = diff_required(diff, "git_diff_foreach")) < 0) + return error; + + memset(&xo, 0, sizeof(xo)); + memset(&patch, 0, sizeof(patch)); + diff_output_init( + &xo.output, &diff->opts, file_cb, hunk_cb, data_cb, payload); + git_xdiff_init(&xo, &diff->opts); + + git_vector_foreach(&diff->deltas, idx, patch.delta) { + + /* check flags against patch status */ + if (git_diff_delta__should_skip(&diff->opts, patch.delta)) + continue; + + if ((error = diff_patch_invoke_file_callback(&patch, &xo.output)) == 0) { + if (hunk_cb || data_cb) { + if ((error = diff_patch_init_from_diff(&patch, diff, idx)) == 0) + error = diff_patch_generate(&patch, &xo.output); + } + } + + git_patch_free(&patch); + + if (error) + break; + } + + return error; +} + +typedef struct { + git_patch patch; + git_diff_delta delta; + char paths[GIT_FLEX_ARRAY]; +} diff_patch_with_delta; + +static int diff_single_generate(diff_patch_with_delta *pd, git_xdiff_output *xo) +{ + int error = 0; + git_patch *patch = &pd->patch; + bool has_old = ((patch->ofile.flags & GIT_DIFF_FLAG__NO_DATA) == 0); + bool has_new = ((patch->nfile.flags & GIT_DIFF_FLAG__NO_DATA) == 0); + + pd->delta.status = has_new ? + (has_old ? GIT_DELTA_MODIFIED : GIT_DELTA_ADDED) : + (has_old ? GIT_DELTA_DELETED : GIT_DELTA_UNTRACKED); + + if (git_oid_equal(&patch->nfile.file->id, &patch->ofile.file->id)) + pd->delta.status = GIT_DELTA_UNMODIFIED; + + patch->delta = &pd->delta; + + diff_patch_init_common(patch); + + if (pd->delta.status == GIT_DELTA_UNMODIFIED && + !(patch->ofile.opts_flags & GIT_DIFF_INCLUDE_UNMODIFIED)) + return error; + + error = diff_patch_invoke_file_callback(patch, (git_diff_output *)xo); + + if (!error) + error = diff_patch_generate(patch, (git_diff_output *)xo); + + return error; +} + +static int diff_patch_from_sources( + diff_patch_with_delta *pd, + git_xdiff_output *xo, + git_diff_file_content_src *oldsrc, + git_diff_file_content_src *newsrc, + const git_diff_options *opts) +{ + int error = 0; + git_repository *repo = + oldsrc->blob ? git_blob_owner(oldsrc->blob) : + newsrc->blob ? git_blob_owner(newsrc->blob) : NULL; + git_diff_file *lfile = &pd->delta.old_file, *rfile = &pd->delta.new_file; + git_diff_file_content *ldata = &pd->patch.ofile, *rdata = &pd->patch.nfile; + + GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); + + if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) { + void *tmp = lfile; lfile = rfile; rfile = tmp; + tmp = ldata; ldata = rdata; rdata = tmp; + } + + pd->patch.delta = &pd->delta; + + if (!oldsrc->as_path) { + if (newsrc->as_path) + oldsrc->as_path = newsrc->as_path; + else + oldsrc->as_path = newsrc->as_path = "file"; + } + else if (!newsrc->as_path) + newsrc->as_path = oldsrc->as_path; + + lfile->path = oldsrc->as_path; + rfile->path = newsrc->as_path; + + if ((error = git_diff_file_content__init_from_src( + ldata, repo, opts, oldsrc, lfile)) < 0 || + (error = git_diff_file_content__init_from_src( + rdata, repo, opts, newsrc, rfile)) < 0) + return error; + + return diff_single_generate(pd, xo); +} + +static int diff_patch_with_delta_alloc( + diff_patch_with_delta **out, + const char **old_path, + const char **new_path) +{ + diff_patch_with_delta *pd; + size_t old_len = *old_path ? strlen(*old_path) : 0; + size_t new_len = *new_path ? strlen(*new_path) : 0; + size_t alloc_len; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*pd), old_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, new_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); + + *out = pd = git__calloc(1, alloc_len); + GITERR_CHECK_ALLOC(pd); + + pd->patch.flags = GIT_DIFF_PATCH_ALLOCATED; + + if (*old_path) { + memcpy(&pd->paths[0], *old_path, old_len); + *old_path = &pd->paths[0]; + } else if (*new_path) + *old_path = &pd->paths[old_len + 1]; + + if (*new_path) { + memcpy(&pd->paths[old_len + 1], *new_path, new_len); + *new_path = &pd->paths[old_len + 1]; + } else if (*old_path) + *new_path = &pd->paths[0]; + + return 0; +} + +static int diff_from_sources( + git_diff_file_content_src *oldsrc, + git_diff_file_content_src *newsrc, + const git_diff_options *opts, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb data_cb, + void *payload) +{ + int error = 0; + diff_patch_with_delta pd; + git_xdiff_output xo; + + memset(&xo, 0, sizeof(xo)); + diff_output_init( + &xo.output, opts, file_cb, hunk_cb, data_cb, payload); + git_xdiff_init(&xo, opts); + + memset(&pd, 0, sizeof(pd)); + + error = diff_patch_from_sources(&pd, &xo, oldsrc, newsrc, opts); + + git_patch_free(&pd.patch); + + return error; +} + +static int patch_from_sources( + git_patch **out, + git_diff_file_content_src *oldsrc, + git_diff_file_content_src *newsrc, + const git_diff_options *opts) +{ + int error = 0; + diff_patch_with_delta *pd; + git_xdiff_output xo; + + assert(out); + *out = NULL; + + if ((error = diff_patch_with_delta_alloc( + &pd, &oldsrc->as_path, &newsrc->as_path)) < 0) + return error; + + memset(&xo, 0, sizeof(xo)); + diff_output_to_patch(&xo.output, &pd->patch); + git_xdiff_init(&xo, opts); + + if (!(error = diff_patch_from_sources(pd, &xo, oldsrc, newsrc, opts))) + *out = (git_patch *)pd; + else + git_patch_free((git_patch *)pd); + + return error; +} + +int git_diff_blobs( + const git_blob *old_blob, + const char *old_path, + const git_blob *new_blob, + const char *new_path, + const git_diff_options *opts, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb data_cb, + void *payload) +{ + git_diff_file_content_src osrc = + GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); + git_diff_file_content_src nsrc = + GIT_DIFF_FILE_CONTENT_SRC__BLOB(new_blob, new_path); + return diff_from_sources( + &osrc, &nsrc, opts, file_cb, hunk_cb, data_cb, payload); +} + +int git_patch_from_blobs( + git_patch **out, + const git_blob *old_blob, + const char *old_path, + const git_blob *new_blob, + const char *new_path, + const git_diff_options *opts) +{ + git_diff_file_content_src osrc = + GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); + git_diff_file_content_src nsrc = + GIT_DIFF_FILE_CONTENT_SRC__BLOB(new_blob, new_path); + return patch_from_sources(out, &osrc, &nsrc, opts); +} + +int git_diff_blob_to_buffer( + const git_blob *old_blob, + const char *old_path, + const char *buf, + size_t buflen, + const char *buf_path, + const git_diff_options *opts, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb data_cb, + void *payload) +{ + git_diff_file_content_src osrc = + GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); + git_diff_file_content_src nsrc = + GIT_DIFF_FILE_CONTENT_SRC__BUF(buf, buflen, buf_path); + return diff_from_sources( + &osrc, &nsrc, opts, file_cb, hunk_cb, data_cb, payload); +} + +int git_patch_from_blob_and_buffer( + git_patch **out, + const git_blob *old_blob, + const char *old_path, + const char *buf, + size_t buflen, + const char *buf_path, + const git_diff_options *opts) +{ + git_diff_file_content_src osrc = + GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); + git_diff_file_content_src nsrc = + GIT_DIFF_FILE_CONTENT_SRC__BUF(buf, buflen, buf_path); + return patch_from_sources(out, &osrc, &nsrc, opts); +} + +int git_diff_buffers( + const void *old_buf, + size_t old_len, + const char *old_path, + const void *new_buf, + size_t new_len, + const char *new_path, + const git_diff_options *opts, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb data_cb, + void *payload) +{ + git_diff_file_content_src osrc = + GIT_DIFF_FILE_CONTENT_SRC__BUF(old_buf, old_len, old_path); + git_diff_file_content_src nsrc = + GIT_DIFF_FILE_CONTENT_SRC__BUF(new_buf, new_len, new_path); + return diff_from_sources( + &osrc, &nsrc, opts, file_cb, hunk_cb, data_cb, payload); +} + +int git_patch_from_buffers( + git_patch **out, + const void *old_buf, + size_t old_len, + const char *old_path, + const char *new_buf, + size_t new_len, + const char *new_path, + const git_diff_options *opts) +{ + git_diff_file_content_src osrc = + GIT_DIFF_FILE_CONTENT_SRC__BUF(old_buf, old_len, old_path); + git_diff_file_content_src nsrc = + GIT_DIFF_FILE_CONTENT_SRC__BUF(new_buf, new_len, new_path); + return patch_from_sources(out, &osrc, &nsrc, opts); +} + +int git_patch_from_diff( + git_patch **patch_ptr, git_diff *diff, size_t idx) +{ + int error = 0; + git_xdiff_output xo; + git_diff_delta *delta = NULL; + git_patch *patch = NULL; + + if (patch_ptr) *patch_ptr = NULL; + + if (diff_required(diff, "git_patch_from_diff") < 0) + return -1; + + delta = git_vector_get(&diff->deltas, idx); + if (!delta) { + giterr_set(GITERR_INVALID, "Index out of range for delta in diff"); + return GIT_ENOTFOUND; + } + + if (git_diff_delta__should_skip(&diff->opts, delta)) + return 0; + + /* don't load the patch data unless we need it for binary check */ + if (!patch_ptr && + ((delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0 || + (diff->opts.flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0)) + return 0; + + if ((error = diff_patch_alloc_from_diff(&patch, diff, idx)) < 0) + return error; + + memset(&xo, 0, sizeof(xo)); + diff_output_to_patch(&xo.output, patch); + git_xdiff_init(&xo, &diff->opts); + + error = diff_patch_invoke_file_callback(patch, &xo.output); + + if (!error) + error = diff_patch_generate(patch, &xo.output); + + if (!error) { + /* TODO: if cumulative diff size is < 0.5 total size, flatten patch */ + /* TODO: and unload the file content */ + } + + if (error || !patch_ptr) + git_patch_free(patch); + else + *patch_ptr = patch; + + return error; +} + +void git_patch_free(git_patch *patch) +{ + if (patch) + GIT_REFCOUNT_DEC(patch, diff_patch_free); +} + +const git_diff_delta *git_patch_get_delta(const git_patch *patch) +{ + assert(patch); + return patch->delta; +} + +size_t git_patch_num_hunks(const git_patch *patch) +{ + assert(patch); + return git_array_size(patch->hunks); +} + +int git_patch_line_stats( + size_t *total_ctxt, + size_t *total_adds, + size_t *total_dels, + const git_patch *patch) +{ + size_t totals[3], idx; + + memset(totals, 0, sizeof(totals)); + + for (idx = 0; idx < git_array_size(patch->lines); ++idx) { + git_diff_line *line = git_array_get(patch->lines, idx); + if (!line) + continue; + + switch (line->origin) { + case GIT_DIFF_LINE_CONTEXT: totals[0]++; break; + case GIT_DIFF_LINE_ADDITION: totals[1]++; break; + case GIT_DIFF_LINE_DELETION: totals[2]++; break; + default: + /* diff --stat and --numstat don't count EOFNL marks because + * they will always be paired with a ADDITION or DELETION line. + */ + break; + } + } + + if (total_ctxt) + *total_ctxt = totals[0]; + if (total_adds) + *total_adds = totals[1]; + if (total_dels) + *total_dels = totals[2]; + + return 0; +} + +static int diff_error_outofrange(const char *thing) +{ + giterr_set(GITERR_INVALID, "Diff patch %s index out of range", thing); + return GIT_ENOTFOUND; +} + +int git_patch_get_hunk( + const git_diff_hunk **out, + size_t *lines_in_hunk, + git_patch *patch, + size_t hunk_idx) +{ + diff_patch_hunk *hunk; + assert(patch); + + hunk = git_array_get(patch->hunks, hunk_idx); + + if (!hunk) { + if (out) *out = NULL; + if (lines_in_hunk) *lines_in_hunk = 0; + return diff_error_outofrange("hunk"); + } + + if (out) *out = &hunk->hunk; + if (lines_in_hunk) *lines_in_hunk = hunk->line_count; + return 0; +} + +int git_patch_num_lines_in_hunk(const git_patch *patch, size_t hunk_idx) +{ + diff_patch_hunk *hunk; + assert(patch); + + if (!(hunk = git_array_get(patch->hunks, hunk_idx))) + return diff_error_outofrange("hunk"); + return (int)hunk->line_count; +} + +int git_patch_get_line_in_hunk( + const git_diff_line **out, + git_patch *patch, + size_t hunk_idx, + size_t line_of_hunk) +{ + diff_patch_hunk *hunk; + git_diff_line *line; + + assert(patch); + + if (!(hunk = git_array_get(patch->hunks, hunk_idx))) { + if (out) *out = NULL; + return diff_error_outofrange("hunk"); + } + + if (line_of_hunk >= hunk->line_count || + !(line = git_array_get( + patch->lines, hunk->line_start + line_of_hunk))) { + if (out) *out = NULL; + return diff_error_outofrange("line"); + } + + if (out) *out = line; + return 0; +} + +size_t git_patch_size( + git_patch *patch, + int include_context, + int include_hunk_headers, + int include_file_headers) +{ + size_t out; + + assert(patch); + + out = patch->content_size; + + if (!include_context) + out -= patch->context_size; + + if (include_hunk_headers) + out += patch->header_size; + + if (include_file_headers) { + git_buf file_header = GIT_BUF_INIT; + + if (git_diff_delta__format_file_header( + &file_header, patch->delta, NULL, NULL, 0) < 0) + giterr_clear(); + else + out += git_buf_len(&file_header); + + git_buf_free(&file_header); + } + + return out; +} + +git_diff *git_patch__diff(git_patch *patch) +{ + return patch->diff; +} + +git_diff_driver *git_patch__driver(git_patch *patch) +{ + /* ofile driver is representative for whole patch */ + return patch->ofile.driver; +} + +void git_patch__old_data( + char **ptr, size_t *len, git_patch *patch) +{ + *ptr = patch->ofile.map.data; + *len = patch->ofile.map.len; +} + +void git_patch__new_data( + char **ptr, size_t *len, git_patch *patch) +{ + *ptr = patch->nfile.map.data; + *len = patch->nfile.map.len; +} + +int git_patch__invoke_callbacks( + git_patch *patch, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb line_cb, + void *payload) +{ + int error = 0; + uint32_t i, j; + + if (file_cb) + error = file_cb(patch->delta, 0, payload); + + if (!hunk_cb && !line_cb) + return error; + + for (i = 0; !error && i < git_array_size(patch->hunks); ++i) { + diff_patch_hunk *h = git_array_get(patch->hunks, i); + + if (hunk_cb) + error = hunk_cb(patch->delta, &h->hunk, payload); + + if (!line_cb) + continue; + + for (j = 0; !error && j < h->line_count; ++j) { + git_diff_line *l = + git_array_get(patch->lines, h->line_start + j); + + error = line_cb(patch->delta, &h->hunk, l, payload); + } + } + + return error; +} + + +static int diff_patch_file_cb( + const git_diff_delta *delta, + float progress, + void *payload) +{ + GIT_UNUSED(delta); GIT_UNUSED(progress); GIT_UNUSED(payload); + return 0; +} + +static int diff_patch_hunk_cb( + const git_diff_delta *delta, + const git_diff_hunk *hunk_, + void *payload) +{ + git_patch *patch = payload; + diff_patch_hunk *hunk; + + GIT_UNUSED(delta); + + hunk = git_array_alloc(patch->hunks); + GITERR_CHECK_ALLOC(hunk); + + memcpy(&hunk->hunk, hunk_, sizeof(hunk->hunk)); + + patch->header_size += hunk_->header_len; + + hunk->line_start = git_array_size(patch->lines); + hunk->line_count = 0; + + return 0; +} + +static int diff_patch_line_cb( + const git_diff_delta *delta, + const git_diff_hunk *hunk_, + const git_diff_line *line_, + void *payload) +{ + git_patch *patch = payload; + diff_patch_hunk *hunk; + git_diff_line *line; + + GIT_UNUSED(delta); + GIT_UNUSED(hunk_); + + hunk = git_array_last(patch->hunks); + assert(hunk); /* programmer error if no hunk is available */ + + line = git_array_alloc(patch->lines); + GITERR_CHECK_ALLOC(line); + + memcpy(line, line_, sizeof(*line)); + + /* do some bookkeeping so we can provide old/new line numbers */ + + patch->content_size += line->content_len; + + if (line->origin == GIT_DIFF_LINE_ADDITION || + line->origin == GIT_DIFF_LINE_DELETION) + patch->content_size += 1; + else if (line->origin == GIT_DIFF_LINE_CONTEXT) { + patch->content_size += 1; + patch->context_size += line->content_len + 1; + } else if (line->origin == GIT_DIFF_LINE_CONTEXT_EOFNL) + patch->context_size += line->content_len; + + hunk->line_count++; + + return 0; +} + +static void diff_output_init( + git_diff_output *out, + const git_diff_options *opts, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb data_cb, + void *payload) +{ + GIT_UNUSED(opts); + + memset(out, 0, sizeof(*out)); + + out->file_cb = file_cb; + out->hunk_cb = hunk_cb; + out->data_cb = data_cb; + out->payload = payload; +} + +static void diff_output_to_patch(git_diff_output *out, git_patch *patch) +{ + diff_output_init( + out, NULL, + diff_patch_file_cb, diff_patch_hunk_cb, diff_patch_line_cb, patch); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.h b/deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.h new file mode 100644 index 000000000..df2ba4c31 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_patch.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_diff_patch_h__ +#define INCLUDE_diff_patch_h__ + +#include "common.h" +#include "diff.h" +#include "diff_file.h" +#include "array.h" +#include "git2/patch.h" + +extern git_diff *git_patch__diff(git_patch *); + +extern git_diff_driver *git_patch__driver(git_patch *); + +extern void git_patch__old_data(char **, size_t *, git_patch *); +extern void git_patch__new_data(char **, size_t *, git_patch *); + +extern int git_patch__invoke_callbacks( + git_patch *patch, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_line_cb line_cb, + void *payload); + +typedef struct git_diff_output git_diff_output; +struct git_diff_output { + /* these callbacks are issued with the diff data */ + git_diff_file_cb file_cb; + git_diff_hunk_cb hunk_cb; + git_diff_line_cb data_cb; + void *payload; + + /* this records the actual error in cases where it may be obscured */ + int error; + + /* this callback is used to do the diff and drive the other callbacks. + * see diff_xdiff.h for how to use this in practice for now. + */ + int (*diff_cb)(git_diff_output *output, git_patch *patch); +}; + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_print.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_print.c new file mode 100644 index 000000000..43a90b3d8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_print.c @@ -0,0 +1,634 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "diff.h" +#include "diff_patch.h" +#include "fileops.h" +#include "zstream.h" +#include "blob.h" +#include "delta.h" +#include "git2/sys/diff.h" + +typedef struct { + git_diff *diff; + git_diff_format_t format; + git_diff_line_cb print_cb; + void *payload; + git_buf *buf; + uint32_t flags; + int oid_strlen; + git_diff_line line; +} diff_print_info; + +static int diff_print_info_init( + diff_print_info *pi, + git_buf *out, + git_diff *diff, + git_diff_format_t format, + git_diff_line_cb cb, + void *payload) +{ + pi->diff = diff; + pi->format = format; + pi->print_cb = cb; + pi->payload = payload; + pi->buf = out; + + if (diff) + pi->flags = diff->opts.flags; + else + pi->flags = 0; + + if (diff && diff->opts.id_abbrev != 0) + pi->oid_strlen = diff->opts.id_abbrev; + else if (!diff || !diff->repo) + pi->oid_strlen = GIT_ABBREV_DEFAULT; + else if (git_repository__cvar( + &pi->oid_strlen, diff->repo, GIT_CVAR_ABBREV) < 0) + return -1; + + pi->oid_strlen += 1; /* for NUL byte */ + + if (pi->oid_strlen < 2) + pi->oid_strlen = 2; + else if (pi->oid_strlen > GIT_OID_HEXSZ + 1) + pi->oid_strlen = GIT_OID_HEXSZ + 1; + + memset(&pi->line, 0, sizeof(pi->line)); + pi->line.old_lineno = -1; + pi->line.new_lineno = -1; + pi->line.num_lines = 1; + + return 0; +} + +static char diff_pick_suffix(int mode) +{ + if (S_ISDIR(mode)) + return '/'; + else if (GIT_PERMS_IS_EXEC(mode)) /* -V536 */ + /* in git, modes are very regular, so we must have 0100755 mode */ + return '*'; + else + return ' '; +} + +char git_diff_status_char(git_delta_t status) +{ + char code; + + switch (status) { + case GIT_DELTA_ADDED: code = 'A'; break; + case GIT_DELTA_DELETED: code = 'D'; break; + case GIT_DELTA_MODIFIED: code = 'M'; break; + case GIT_DELTA_RENAMED: code = 'R'; break; + case GIT_DELTA_COPIED: code = 'C'; break; + case GIT_DELTA_IGNORED: code = 'I'; break; + case GIT_DELTA_UNTRACKED: code = '?'; break; + case GIT_DELTA_UNREADABLE: code = 'X'; break; + default: code = ' '; break; + } + + return code; +} + +static int diff_print_one_name_only( + const git_diff_delta *delta, float progress, void *data) +{ + diff_print_info *pi = data; + git_buf *out = pi->buf; + + GIT_UNUSED(progress); + + if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && + delta->status == GIT_DELTA_UNMODIFIED) + return 0; + + git_buf_clear(out); + git_buf_puts(out, delta->new_file.path); + git_buf_putc(out, '\n'); + if (git_buf_oom(out)) + return -1; + + pi->line.origin = GIT_DIFF_LINE_FILE_HDR; + pi->line.content = git_buf_cstr(out); + pi->line.content_len = git_buf_len(out); + + return pi->print_cb(delta, NULL, &pi->line, pi->payload); +} + +static int diff_print_one_name_status( + const git_diff_delta *delta, float progress, void *data) +{ + diff_print_info *pi = data; + git_buf *out = pi->buf; + char old_suffix, new_suffix, code = git_diff_status_char(delta->status); + int (*strcomp)(const char *, const char *) = + pi->diff ? pi->diff->strcomp : git__strcmp; + + GIT_UNUSED(progress); + + if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ') + return 0; + + old_suffix = diff_pick_suffix(delta->old_file.mode); + new_suffix = diff_pick_suffix(delta->new_file.mode); + + git_buf_clear(out); + + if (delta->old_file.path != delta->new_file.path && + strcomp(delta->old_file.path,delta->new_file.path) != 0) + git_buf_printf(out, "%c\t%s%c %s%c\n", code, + delta->old_file.path, old_suffix, delta->new_file.path, new_suffix); + else if (delta->old_file.mode != delta->new_file.mode && + delta->old_file.mode != 0 && delta->new_file.mode != 0) + git_buf_printf(out, "%c\t%s%c %s%c\n", code, + delta->old_file.path, old_suffix, delta->new_file.path, new_suffix); + else if (old_suffix != ' ') + git_buf_printf(out, "%c\t%s%c\n", code, delta->old_file.path, old_suffix); + else + git_buf_printf(out, "%c\t%s\n", code, delta->old_file.path); + if (git_buf_oom(out)) + return -1; + + pi->line.origin = GIT_DIFF_LINE_FILE_HDR; + pi->line.content = git_buf_cstr(out); + pi->line.content_len = git_buf_len(out); + + return pi->print_cb(delta, NULL, &pi->line, pi->payload); +} + +static int diff_print_one_raw( + const git_diff_delta *delta, float progress, void *data) +{ + diff_print_info *pi = data; + git_buf *out = pi->buf; + char code = git_diff_status_char(delta->status); + char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1]; + + GIT_UNUSED(progress); + + if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ') + return 0; + + git_buf_clear(out); + + git_oid_tostr(start_oid, pi->oid_strlen, &delta->old_file.id); + git_oid_tostr(end_oid, pi->oid_strlen, &delta->new_file.id); + + git_buf_printf( + out, (pi->oid_strlen <= GIT_OID_HEXSZ) ? + ":%06o %06o %s... %s... %c" : ":%06o %06o %s %s %c", + delta->old_file.mode, delta->new_file.mode, start_oid, end_oid, code); + + if (delta->similarity > 0) + git_buf_printf(out, "%03u", delta->similarity); + + if (delta->old_file.path != delta->new_file.path) + git_buf_printf( + out, "\t%s %s\n", delta->old_file.path, delta->new_file.path); + else + git_buf_printf( + out, "\t%s\n", delta->old_file.path ? + delta->old_file.path : delta->new_file.path); + + if (git_buf_oom(out)) + return -1; + + pi->line.origin = GIT_DIFF_LINE_FILE_HDR; + pi->line.content = git_buf_cstr(out); + pi->line.content_len = git_buf_len(out); + + return pi->print_cb(delta, NULL, &pi->line, pi->payload); +} + +static int diff_print_oid_range( + git_buf *out, const git_diff_delta *delta, int oid_strlen) +{ + char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1]; + + git_oid_tostr(start_oid, oid_strlen, &delta->old_file.id); + git_oid_tostr(end_oid, oid_strlen, &delta->new_file.id); + + /* TODO: Match git diff more closely */ + if (delta->old_file.mode == delta->new_file.mode) { + git_buf_printf(out, "index %s..%s %o\n", + start_oid, end_oid, delta->old_file.mode); + } else { + if (delta->old_file.mode == 0) { + git_buf_printf(out, "new file mode %o\n", delta->new_file.mode); + } else if (delta->new_file.mode == 0) { + git_buf_printf(out, "deleted file mode %o\n", delta->old_file.mode); + } else { + git_buf_printf(out, "old mode %o\n", delta->old_file.mode); + git_buf_printf(out, "new mode %o\n", delta->new_file.mode); + } + git_buf_printf(out, "index %s..%s\n", start_oid, end_oid); + } + + return git_buf_oom(out) ? -1 : 0; +} + +static int diff_delta_format_with_paths( + git_buf *out, + const git_diff_delta *delta, + const char *oldpfx, + const char *newpfx, + const char *template) +{ + const char *oldpath = delta->old_file.path; + const char *newpath = delta->new_file.path; + + if (git_oid_iszero(&delta->old_file.id)) { + oldpfx = ""; + oldpath = "/dev/null"; + } + if (git_oid_iszero(&delta->new_file.id)) { + newpfx = ""; + newpath = "/dev/null"; + } + + return git_buf_printf(out, template, oldpfx, oldpath, newpfx, newpath); +} + +int git_diff_delta__format_file_header( + git_buf *out, + const git_diff_delta *delta, + const char *oldpfx, + const char *newpfx, + int oid_strlen) +{ + if (!oldpfx) + oldpfx = DIFF_OLD_PREFIX_DEFAULT; + if (!newpfx) + newpfx = DIFF_NEW_PREFIX_DEFAULT; + if (!oid_strlen) + oid_strlen = GIT_ABBREV_DEFAULT + 1; + + git_buf_clear(out); + + git_buf_printf(out, "diff --git %s%s %s%s\n", + oldpfx, delta->old_file.path, newpfx, delta->new_file.path); + + GITERR_CHECK_ERROR(diff_print_oid_range(out, delta, oid_strlen)); + + if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0) + diff_delta_format_with_paths( + out, delta, oldpfx, newpfx, "--- %s%s\n+++ %s%s\n"); + + return git_buf_oom(out) ? -1 : 0; +} + +static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new) +{ + git_buf deflate = GIT_BUF_INIT, delta = GIT_BUF_INIT, *out = NULL; + const void *old_data, *new_data; + git_off_t old_data_len, new_data_len; + unsigned long delta_data_len, inflated_len; + const char *out_type = "literal"; + char *scan, *end; + int error; + + old_data = old ? git_blob_rawcontent(old) : NULL; + new_data = new ? git_blob_rawcontent(new) : NULL; + + old_data_len = old ? git_blob_rawsize(old) : 0; + new_data_len = new ? git_blob_rawsize(new) : 0; + + /* The git_delta function accepts unsigned long only */ + if (!git__is_ulong(old_data_len) || !git__is_ulong(new_data_len)) + return GIT_EBUFS; + + out = &deflate; + inflated_len = (unsigned long)new_data_len; + + if ((error = git_zstream_deflatebuf( + out, new_data, (size_t)new_data_len)) < 0) + goto done; + + /* The git_delta function accepts unsigned long only */ + if (!git__is_ulong((git_off_t)deflate.size)) { + error = GIT_EBUFS; + goto done; + } + + if (old && new) { + void *delta_data = git_delta( + old_data, (unsigned long)old_data_len, + new_data, (unsigned long)new_data_len, + &delta_data_len, (unsigned long)deflate.size); + + if (delta_data) { + error = git_zstream_deflatebuf( + &delta, delta_data, (size_t)delta_data_len); + + git__free(delta_data); + + if (error < 0) + goto done; + + if (delta.size < deflate.size) { + out = δ + out_type = "delta"; + inflated_len = delta_data_len; + } + } + } + + git_buf_printf(pi->buf, "%s %lu\n", out_type, inflated_len); + pi->line.num_lines++; + + for (scan = out->ptr, end = out->ptr + out->size; scan < end; ) { + size_t chunk_len = end - scan; + if (chunk_len > 52) + chunk_len = 52; + + if (chunk_len <= 26) + git_buf_putc(pi->buf, (char)chunk_len + 'A' - 1); + else + git_buf_putc(pi->buf, (char)chunk_len - 26 + 'a' - 1); + + git_buf_encode_base85(pi->buf, scan, chunk_len); + git_buf_putc(pi->buf, '\n'); + + if (git_buf_oom(pi->buf)) { + error = -1; + goto done; + } + + scan += chunk_len; + pi->line.num_lines++; + } + +done: + git_buf_free(&deflate); + git_buf_free(&delta); + + return error; +} + +/* git diff --binary 8d7523f~2 8d7523f~1 */ +static int diff_print_patch_file_binary( + diff_print_info *pi, const git_diff_delta *delta, + const char *oldpfx, const char *newpfx) +{ + git_blob *old = NULL, *new = NULL; + const git_oid *old_id, *new_id; + int error; + size_t pre_binary_size; + + if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0) + goto noshow; + + pre_binary_size = pi->buf->size; + git_buf_printf(pi->buf, "GIT binary patch\n"); + pi->line.num_lines++; + + old_id = (delta->status != GIT_DELTA_ADDED) ? &delta->old_file.id : NULL; + new_id = (delta->status != GIT_DELTA_DELETED) ? &delta->new_file.id : NULL; + + if (old_id && (error = git_blob_lookup(&old, pi->diff->repo, old_id)) < 0) + goto done; + if (new_id && (error = git_blob_lookup(&new, pi->diff->repo,new_id)) < 0) + goto done; + + if ((error = print_binary_hunk(pi, old, new)) < 0 || + (error = git_buf_putc(pi->buf, '\n')) < 0 || + (error = print_binary_hunk(pi, new, old)) < 0) + { + if (error == GIT_EBUFS) { + giterr_clear(); + git_buf_truncate(pi->buf, pre_binary_size); + goto noshow; + } + } + + pi->line.num_lines++; + +done: + git_blob_free(old); + git_blob_free(new); + + return error; + +noshow: + pi->line.num_lines = 1; + return diff_delta_format_with_paths( + pi->buf, delta, oldpfx, newpfx, + "Binary files %s%s and %s%s differ\n"); +} + +static int diff_print_patch_file( + const git_diff_delta *delta, float progress, void *data) +{ + int error; + diff_print_info *pi = data; + const char *oldpfx = + pi->diff ? pi->diff->opts.old_prefix : DIFF_OLD_PREFIX_DEFAULT; + const char *newpfx = + pi->diff ? pi->diff->opts.new_prefix : DIFF_NEW_PREFIX_DEFAULT; + + bool binary = !!(delta->flags & GIT_DIFF_FLAG_BINARY); + bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY); + int oid_strlen = binary && show_binary ? + GIT_OID_HEXSZ + 1 : pi->oid_strlen; + + GIT_UNUSED(progress); + + if (S_ISDIR(delta->new_file.mode) || + delta->status == GIT_DELTA_UNMODIFIED || + delta->status == GIT_DELTA_IGNORED || + delta->status == GIT_DELTA_UNREADABLE || + (delta->status == GIT_DELTA_UNTRACKED && + (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0)) + return 0; + + if ((error = git_diff_delta__format_file_header( + pi->buf, delta, oldpfx, newpfx, oid_strlen)) < 0) + return error; + + pi->line.origin = GIT_DIFF_LINE_FILE_HDR; + pi->line.content = git_buf_cstr(pi->buf); + pi->line.content_len = git_buf_len(pi->buf); + + if ((error = pi->print_cb(delta, NULL, &pi->line, pi->payload)) != 0) + return error; + + if (!binary) + return 0; + + git_buf_clear(pi->buf); + + if ((error = diff_print_patch_file_binary(pi, delta, oldpfx, newpfx)) < 0) + return error; + + pi->line.origin = GIT_DIFF_LINE_BINARY; + pi->line.content = git_buf_cstr(pi->buf); + pi->line.content_len = git_buf_len(pi->buf); + + return pi->print_cb(delta, NULL, &pi->line, pi->payload); +} + +static int diff_print_patch_hunk( + const git_diff_delta *d, + const git_diff_hunk *h, + void *data) +{ + diff_print_info *pi = data; + + if (S_ISDIR(d->new_file.mode)) + return 0; + + pi->line.origin = GIT_DIFF_LINE_HUNK_HDR; + pi->line.content = h->header; + pi->line.content_len = h->header_len; + + return pi->print_cb(d, h, &pi->line, pi->payload); +} + +static int diff_print_patch_line( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *data) +{ + diff_print_info *pi = data; + + if (S_ISDIR(delta->new_file.mode)) + return 0; + + return pi->print_cb(delta, hunk, line, pi->payload); +} + +/* print a git_diff to an output callback */ +int git_diff_print( + git_diff *diff, + git_diff_format_t format, + git_diff_line_cb print_cb, + void *payload) +{ + int error; + git_buf buf = GIT_BUF_INIT; + diff_print_info pi; + git_diff_file_cb print_file = NULL; + git_diff_hunk_cb print_hunk = NULL; + git_diff_line_cb print_line = NULL; + + switch (format) { + case GIT_DIFF_FORMAT_PATCH: + print_file = diff_print_patch_file; + print_hunk = diff_print_patch_hunk; + print_line = diff_print_patch_line; + break; + case GIT_DIFF_FORMAT_PATCH_HEADER: + print_file = diff_print_patch_file; + break; + case GIT_DIFF_FORMAT_RAW: + print_file = diff_print_one_raw; + break; + case GIT_DIFF_FORMAT_NAME_ONLY: + print_file = diff_print_one_name_only; + break; + case GIT_DIFF_FORMAT_NAME_STATUS: + print_file = diff_print_one_name_status; + break; + default: + giterr_set(GITERR_INVALID, "Unknown diff output format (%d)", format); + return -1; + } + + if (!(error = diff_print_info_init( + &pi, &buf, diff, format, print_cb, payload))) + { + error = git_diff_foreach( + diff, print_file, print_hunk, print_line, &pi); + + if (error) /* make sure error message is set */ + giterr_set_after_callback_function(error, "git_diff_print"); + } + + git_buf_free(&buf); + + return error; +} + +/* print a git_patch to an output callback */ +int git_patch_print( + git_patch *patch, + git_diff_line_cb print_cb, + void *payload) +{ + int error; + git_buf temp = GIT_BUF_INIT; + diff_print_info pi; + + assert(patch && print_cb); + + if (!(error = diff_print_info_init( + &pi, &temp, git_patch__diff(patch), + GIT_DIFF_FORMAT_PATCH, print_cb, payload))) + { + error = git_patch__invoke_callbacks( + patch, diff_print_patch_file, diff_print_patch_hunk, + diff_print_patch_line, &pi); + + if (error) /* make sure error message is set */ + giterr_set_after_callback_function(error, "git_patch_print"); + } + + git_buf_free(&temp); + + return error; +} + +int git_diff_print_callback__to_buf( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *payload) +{ + git_buf *output = payload; + GIT_UNUSED(delta); GIT_UNUSED(hunk); + + if (!output) { + giterr_set(GITERR_INVALID, "Buffer pointer must be provided"); + return -1; + } + + if (line->origin == GIT_DIFF_LINE_ADDITION || + line->origin == GIT_DIFF_LINE_DELETION || + line->origin == GIT_DIFF_LINE_CONTEXT) + git_buf_putc(output, line->origin); + + return git_buf_put(output, line->content, line->content_len); +} + +int git_diff_print_callback__to_file_handle( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *payload) +{ + FILE *fp = payload ? payload : stdout; + + GIT_UNUSED(delta); GIT_UNUSED(hunk); + + if (line->origin == GIT_DIFF_LINE_CONTEXT || + line->origin == GIT_DIFF_LINE_ADDITION || + line->origin == GIT_DIFF_LINE_DELETION) + fputc(line->origin, fp); + fwrite(line->content, 1, line->content_len, fp); + return 0; +} + +/* print a git_patch to a git_buf */ +int git_patch_to_buf(git_buf *out, git_patch *patch) +{ + assert(out && patch); + git_buf_sanitize(out); + return git_patch_print(patch, git_diff_print_callback__to_buf, out); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_stats.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_stats.c new file mode 100644 index 000000000..42ccbfb87 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_stats.c @@ -0,0 +1,336 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "vector.h" +#include "diff.h" +#include "diff_patch.h" + +#define DIFF_RENAME_FILE_SEPARATOR " => " +#define STATS_FULL_MIN_SCALE 7 + +typedef struct { + size_t insertions; + size_t deletions; +} diff_file_stats; + +struct git_diff_stats { + git_diff *diff; + diff_file_stats *filestats; + + size_t files_changed; + size_t insertions; + size_t deletions; + size_t renames; + + size_t max_name; + size_t max_filestat; + int max_digits; +}; + +static int digits_for_value(size_t val) +{ + int count = 1; + size_t placevalue = 10; + + while (val >= placevalue) { + ++count; + placevalue *= 10; + } + + return count; +} + +int git_diff_file_stats__full_to_buf( + git_buf *out, + const git_diff_delta *delta, + const diff_file_stats *filestat, + const git_diff_stats *stats, + size_t width) +{ + const char *old_path = NULL, *new_path = NULL; + size_t padding, old_size, new_size; + + old_path = delta->old_file.path; + new_path = delta->new_file.path; + old_size = delta->old_file.size; + new_size = delta->new_file.size; + + if (git_buf_printf(out, " %s", old_path) < 0) + goto on_error; + + if (strcmp(old_path, new_path) != 0) { + padding = stats->max_name - strlen(old_path) - strlen(new_path); + + if (git_buf_printf(out, DIFF_RENAME_FILE_SEPARATOR "%s", new_path) < 0) + goto on_error; + } else { + padding = stats->max_name - strlen(old_path); + + if (stats->renames > 0) + padding += strlen(DIFF_RENAME_FILE_SEPARATOR); + } + + if (git_buf_putcn(out, ' ', padding) < 0 || + git_buf_puts(out, " | ") < 0) + goto on_error; + + if (delta->flags & GIT_DIFF_FLAG_BINARY) { + if (git_buf_printf(out, + "Bin %" PRIuZ " -> %" PRIuZ " bytes", old_size, new_size) < 0) + goto on_error; + } + else { + if (git_buf_printf(out, + "%*" PRIuZ, stats->max_digits, + filestat->insertions + filestat->deletions) < 0) + goto on_error; + + if (filestat->insertions || filestat->deletions) { + if (git_buf_putc(out, ' ') < 0) + goto on_error; + + if (!width) { + if (git_buf_putcn(out, '+', filestat->insertions) < 0 || + git_buf_putcn(out, '-', filestat->deletions) < 0) + goto on_error; + } else { + size_t total = filestat->insertions + filestat->deletions; + size_t full = (total * width + stats->max_filestat / 2) / + stats->max_filestat; + size_t plus = full * filestat->insertions / total; + size_t minus = full - plus; + + if (git_buf_putcn(out, '+', max(plus, 1)) < 0 || + git_buf_putcn(out, '-', max(minus, 1)) < 0) + goto on_error; + } + } + } + + git_buf_putc(out, '\n'); + +on_error: + return (git_buf_oom(out) ? -1 : 0); +} + +int git_diff_file_stats__number_to_buf( + git_buf *out, + const git_diff_delta *delta, + const diff_file_stats *filestats) +{ + int error; + const char *path = delta->new_file.path; + + if (delta->flags & GIT_DIFF_FLAG_BINARY) + error = git_buf_printf(out, "%-8c" "%-8c" "%s\n", '-', '-', path); + else + error = git_buf_printf(out, "%-8" PRIuZ "%-8" PRIuZ "%s\n", + filestats->insertions, filestats->deletions, path); + + return error; +} + +int git_diff_file_stats__summary_to_buf( + git_buf *out, + const git_diff_delta *delta) +{ + if (delta->old_file.mode != delta->new_file.mode) { + if (delta->old_file.mode == 0) { + git_buf_printf(out, " create mode %06o %s\n", + delta->new_file.mode, delta->new_file.path); + } + else if (delta->new_file.mode == 0) { + git_buf_printf(out, " delete mode %06o %s\n", + delta->old_file.mode, delta->old_file.path); + } + else { + git_buf_printf(out, " mode change %06o => %06o %s\n", + delta->old_file.mode, delta->new_file.mode, delta->new_file.path); + } + } + + return 0; +} + +int git_diff_get_stats( + git_diff_stats **out, + git_diff *diff) +{ + size_t i, deltas; + size_t total_insertions = 0, total_deletions = 0; + git_diff_stats *stats = NULL; + int error = 0; + + assert(out && diff); + + stats = git__calloc(1, sizeof(git_diff_stats)); + GITERR_CHECK_ALLOC(stats); + + deltas = git_diff_num_deltas(diff); + + stats->filestats = git__calloc(deltas, sizeof(diff_file_stats)); + if (!stats->filestats) { + git__free(stats); + return -1; + } + + stats->diff = diff; + GIT_REFCOUNT_INC(diff); + + for (i = 0; i < deltas && !error; ++i) { + git_patch *patch = NULL; + size_t add = 0, remove = 0, namelen; + const git_diff_delta *delta; + + if ((error = git_patch_from_diff(&patch, diff, i)) < 0) + break; + + /* keep a count of renames because it will affect formatting */ + delta = git_patch_get_delta(patch); + + namelen = strlen(delta->new_file.path); + if (strcmp(delta->old_file.path, delta->new_file.path) != 0) { + namelen += strlen(delta->old_file.path); + stats->renames++; + } + + /* and, of course, count the line stats */ + error = git_patch_line_stats(NULL, &add, &remove, patch); + + git_patch_free(patch); + + stats->filestats[i].insertions = add; + stats->filestats[i].deletions = remove; + + total_insertions += add; + total_deletions += remove; + + if (stats->max_name < namelen) + stats->max_name = namelen; + if (stats->max_filestat < add + remove) + stats->max_filestat = add + remove; + } + + stats->files_changed = deltas; + stats->insertions = total_insertions; + stats->deletions = total_deletions; + stats->max_digits = digits_for_value(stats->max_filestat + 1); + + if (error < 0) { + git_diff_stats_free(stats); + stats = NULL; + } + + *out = stats; + return error; +} + +size_t git_diff_stats_files_changed( + const git_diff_stats *stats) +{ + assert(stats); + + return stats->files_changed; +} + +size_t git_diff_stats_insertions( + const git_diff_stats *stats) +{ + assert(stats); + + return stats->insertions; +} + +size_t git_diff_stats_deletions( + const git_diff_stats *stats) +{ + assert(stats); + + return stats->deletions; +} + +int git_diff_stats_to_buf( + git_buf *out, + const git_diff_stats *stats, + git_diff_stats_format_t format, + size_t width) +{ + int error = 0; + size_t i; + const git_diff_delta *delta; + + assert(out && stats); + + if (format & GIT_DIFF_STATS_NUMBER) { + for (i = 0; i < stats->files_changed; ++i) { + if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) + continue; + + error = git_diff_file_stats__number_to_buf( + out, delta, &stats->filestats[i]); + if (error < 0) + return error; + } + } + + if (format & GIT_DIFF_STATS_FULL) { + if (width > 0) { + if (width > stats->max_name + stats->max_digits + 5) + width -= (stats->max_name + stats->max_digits + 5); + if (width < STATS_FULL_MIN_SCALE) + width = STATS_FULL_MIN_SCALE; + } + if (width > stats->max_filestat) + width = 0; + + for (i = 0; i < stats->files_changed; ++i) { + if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) + continue; + + error = git_diff_file_stats__full_to_buf( + out, delta, &stats->filestats[i], stats, width); + if (error < 0) + return error; + } + } + + if (format & GIT_DIFF_STATS_FULL || format & GIT_DIFF_STATS_SHORT) { + error = git_buf_printf( + out, " %" PRIuZ " file%s changed, %" PRIuZ + " insertion%s(+), %" PRIuZ " deletion%s(-)\n", + stats->files_changed, stats->files_changed != 1 ? "s" : "", + stats->insertions, stats->insertions != 1 ? "s" : "", + stats->deletions, stats->deletions != 1 ? "s" : ""); + + if (error < 0) + return error; + } + + if (format & GIT_DIFF_STATS_INCLUDE_SUMMARY) { + for (i = 0; i < stats->files_changed; ++i) { + if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) + continue; + + error = git_diff_file_stats__summary_to_buf(out, delta); + if (error < 0) + return error; + } + } + + return error; +} + +void git_diff_stats_free(git_diff_stats *stats) +{ + if (stats == NULL) + return; + + git_diff_free(stats->diff); /* bumped refcount in constructor */ + git__free(stats->filestats); + git__free(stats); +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_tform.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_tform.c new file mode 100644 index 000000000..06c12308b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_tform.c @@ -0,0 +1,1123 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" + +#include "git2/config.h" +#include "git2/blob.h" +#include "git2/sys/hashsig.h" + +#include "diff.h" +#include "path.h" +#include "fileops.h" +#include "config.h" + +static git_diff_delta *diff_delta__dup( + const git_diff_delta *d, git_pool *pool) +{ + git_diff_delta *delta = git__malloc(sizeof(git_diff_delta)); + if (!delta) + return NULL; + + memcpy(delta, d, sizeof(git_diff_delta)); + GIT_DIFF_FLAG__CLEAR_INTERNAL(delta->flags); + + if (d->old_file.path != NULL) { + delta->old_file.path = git_pool_strdup(pool, d->old_file.path); + if (delta->old_file.path == NULL) + goto fail; + } + + if (d->new_file.path != d->old_file.path && d->new_file.path != NULL) { + delta->new_file.path = git_pool_strdup(pool, d->new_file.path); + if (delta->new_file.path == NULL) + goto fail; + } else { + delta->new_file.path = delta->old_file.path; + } + + return delta; + +fail: + git__free(delta); + return NULL; +} + +static git_diff_delta *diff_delta__merge_like_cgit( + const git_diff_delta *a, + const git_diff_delta *b, + git_pool *pool) +{ + git_diff_delta *dup; + + /* Emulate C git for merging two diffs (a la 'git diff '). + * + * When C git does a diff between the work dir and a tree, it actually + * diffs with the index but uses the workdir contents. This emulates + * those choices so we can emulate the type of diff. + * + * We have three file descriptions here, let's call them: + * f1 = a->old_file + * f2 = a->new_file AND b->old_file + * f3 = b->new_file + */ + + /* if f2 == f3 or f2 is deleted, then just dup the 'a' diff */ + if (b->status == GIT_DELTA_UNMODIFIED || a->status == GIT_DELTA_DELETED) + return diff_delta__dup(a, pool); + + /* otherwise, base this diff on the 'b' diff */ + if ((dup = diff_delta__dup(b, pool)) == NULL) + return NULL; + + /* If 'a' status is uninteresting, then we're done */ + if (a->status == GIT_DELTA_UNMODIFIED) + return dup; + + assert(a->status != GIT_DELTA_UNMODIFIED); + assert(b->status != GIT_DELTA_UNMODIFIED); + + /* A cgit exception is that the diff of a file that is only in the + * index (i.e. not in HEAD nor workdir) is given as empty. + */ + if (dup->status == GIT_DELTA_DELETED) { + if (a->status == GIT_DELTA_ADDED) + dup->status = GIT_DELTA_UNMODIFIED; + /* else don't overwrite DELETE status */ + } else { + dup->status = a->status; + } + + git_oid_cpy(&dup->old_file.id, &a->old_file.id); + dup->old_file.mode = a->old_file.mode; + dup->old_file.size = a->old_file.size; + dup->old_file.flags = a->old_file.flags; + + return dup; +} + +static git_diff_delta *diff_delta__merge_like_cgit_reversed( + const git_diff_delta *a, + const git_diff_delta *b, + git_pool *pool) +{ + git_diff_delta *dup; + + /* reversed version of above logic */ + + if (a->status == GIT_DELTA_UNMODIFIED) + return diff_delta__dup(b, pool); + + if ((dup = diff_delta__dup(a, pool)) == NULL) + return NULL; + + if (b->status == GIT_DELTA_UNMODIFIED || b->status == GIT_DELTA_UNTRACKED || b->status == GIT_DELTA_UNREADABLE) + return dup; + + if (dup->status == GIT_DELTA_DELETED) { + if (b->status == GIT_DELTA_ADDED) + dup->status = GIT_DELTA_UNMODIFIED; + } else { + dup->status = b->status; + } + + git_oid_cpy(&dup->old_file.id, &b->old_file.id); + dup->old_file.mode = b->old_file.mode; + dup->old_file.size = b->old_file.size; + dup->old_file.flags = b->old_file.flags; + + return dup; +} + +int git_diff_merge(git_diff *onto, const git_diff *from) +{ + int error = 0; + git_pool onto_pool; + git_vector onto_new; + git_diff_delta *delta; + bool ignore_case, reversed; + unsigned int i, j; + + assert(onto && from); + + if (!from->deltas.length) + return 0; + + ignore_case = ((onto->opts.flags & GIT_DIFF_IGNORE_CASE) != 0); + reversed = ((onto->opts.flags & GIT_DIFF_REVERSE) != 0); + + if (ignore_case != ((from->opts.flags & GIT_DIFF_IGNORE_CASE) != 0) || + reversed != ((from->opts.flags & GIT_DIFF_REVERSE) != 0)) { + giterr_set(GITERR_INVALID, + "Attempt to merge diffs created with conflicting options"); + return -1; + } + + if (git_vector_init( + &onto_new, onto->deltas.length, git_diff_delta__cmp) < 0 || + git_pool_init(&onto_pool, 1, 0) < 0) + return -1; + + for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) { + git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i); + const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j); + int cmp = !f ? -1 : !o ? 1 : + STRCMP_CASESELECT(ignore_case, o->old_file.path, f->old_file.path); + + if (cmp < 0) { + delta = diff_delta__dup(o, &onto_pool); + i++; + } else if (cmp > 0) { + delta = diff_delta__dup(f, &onto_pool); + j++; + } else { + delta = reversed ? + diff_delta__merge_like_cgit_reversed(o, f, &onto_pool) : + diff_delta__merge_like_cgit(o, f, &onto_pool); + i++; + j++; + } + + /* the ignore rules for the target may not match the source + * or the result of a merged delta could be skippable... + */ + if (git_diff_delta__should_skip(&onto->opts, delta)) { + git__free(delta); + continue; + } + + if ((error = !delta ? -1 : git_vector_insert(&onto_new, delta)) < 0) + break; + } + + if (!error) { + git_vector_swap(&onto->deltas, &onto_new); + git_pool_swap(&onto->pool, &onto_pool); + + if ((onto->opts.flags & GIT_DIFF_REVERSE) != 0) + onto->old_src = from->old_src; + else + onto->new_src = from->new_src; + + /* prefix strings also come from old pool, so recreate those.*/ + onto->opts.old_prefix = + git_pool_strdup_safe(&onto->pool, onto->opts.old_prefix); + onto->opts.new_prefix = + git_pool_strdup_safe(&onto->pool, onto->opts.new_prefix); + } + + git_vector_free_deep(&onto_new); + git_pool_clear(&onto_pool); + + return error; +} + +int git_diff_find_similar__hashsig_for_file( + void **out, const git_diff_file *f, const char *path, void *p) +{ + git_hashsig_option_t opt = (git_hashsig_option_t)(intptr_t)p; + + GIT_UNUSED(f); + return git_hashsig_create_fromfile((git_hashsig **)out, path, opt); +} + +int git_diff_find_similar__hashsig_for_buf( + void **out, const git_diff_file *f, const char *buf, size_t len, void *p) +{ + git_hashsig_option_t opt = (git_hashsig_option_t)(intptr_t)p; + + GIT_UNUSED(f); + return git_hashsig_create((git_hashsig **)out, buf, len, opt); +} + +void git_diff_find_similar__hashsig_free(void *sig, void *payload) +{ + GIT_UNUSED(payload); + git_hashsig_free(sig); +} + +int git_diff_find_similar__calc_similarity( + int *score, void *siga, void *sigb, void *payload) +{ + int error; + + GIT_UNUSED(payload); + error = git_hashsig_compare(siga, sigb); + if (error < 0) + return error; + + *score = error; + return 0; +} + +#define DEFAULT_THRESHOLD 50 +#define DEFAULT_BREAK_REWRITE_THRESHOLD 60 +#define DEFAULT_RENAME_LIMIT 200 + +static int normalize_find_opts( + git_diff *diff, + git_diff_find_options *opts, + const git_diff_find_options *given) +{ + git_config *cfg = NULL; + git_hashsig_option_t hashsig_opts; + + GITERR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); + + if (diff->repo != NULL && + git_repository_config__weakptr(&cfg, diff->repo) < 0) + return -1; + + if (given) + memcpy(opts, given, sizeof(*opts)); + + if (!given || + (given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG) + { + char *rule = + git_config__get_string_force(cfg, "diff.renames", "true"); + int boolval; + + if (!git__parse_bool(&boolval, rule) && !boolval) + /* don't set FIND_RENAMES if bool value is false */; + else if (!strcasecmp(rule, "copies") || !strcasecmp(rule, "copy")) + opts->flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; + else + opts->flags |= GIT_DIFF_FIND_RENAMES; + + git__free(rule); + } + + /* some flags imply others */ + + if (opts->flags & GIT_DIFF_FIND_EXACT_MATCH_ONLY) { + /* if we are only looking for exact matches, then don't turn + * MODIFIED items into ADD/DELETE pairs because it's too picky + */ + opts->flags &= ~(GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES); + + /* similarly, don't look for self-rewrites to split */ + opts->flags &= ~GIT_DIFF_FIND_RENAMES_FROM_REWRITES; + } + + if (opts->flags & GIT_DIFF_FIND_RENAMES_FROM_REWRITES) + opts->flags |= GIT_DIFF_FIND_RENAMES; + + if (opts->flags & GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED) + opts->flags |= GIT_DIFF_FIND_COPIES; + + if (opts->flags & GIT_DIFF_BREAK_REWRITES) + opts->flags |= GIT_DIFF_FIND_REWRITES; + +#define USE_DEFAULT(X) ((X) == 0 || (X) > 100) + + if (USE_DEFAULT(opts->rename_threshold)) + opts->rename_threshold = DEFAULT_THRESHOLD; + + if (USE_DEFAULT(opts->rename_from_rewrite_threshold)) + opts->rename_from_rewrite_threshold = DEFAULT_THRESHOLD; + + if (USE_DEFAULT(opts->copy_threshold)) + opts->copy_threshold = DEFAULT_THRESHOLD; + + if (USE_DEFAULT(opts->break_rewrite_threshold)) + opts->break_rewrite_threshold = DEFAULT_BREAK_REWRITE_THRESHOLD; + +#undef USE_DEFAULT + + if (!opts->rename_limit) { + opts->rename_limit = git_config__get_int_force( + cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT); + + if (opts->rename_limit <= 0) + opts->rename_limit = DEFAULT_RENAME_LIMIT; + } + + /* assign the internal metric with whitespace flag as payload */ + if (!opts->metric) { + opts->metric = git__malloc(sizeof(git_diff_similarity_metric)); + GITERR_CHECK_ALLOC(opts->metric); + + opts->metric->file_signature = git_diff_find_similar__hashsig_for_file; + opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf; + opts->metric->free_signature = git_diff_find_similar__hashsig_free; + opts->metric->similarity = git_diff_find_similar__calc_similarity; + + if (opts->flags & GIT_DIFF_FIND_IGNORE_WHITESPACE) + hashsig_opts = GIT_HASHSIG_IGNORE_WHITESPACE; + else if (opts->flags & GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE) + hashsig_opts = GIT_HASHSIG_NORMAL; + else + hashsig_opts = GIT_HASHSIG_SMART_WHITESPACE; + hashsig_opts |= GIT_HASHSIG_ALLOW_SMALL_FILES; + opts->metric->payload = (void *)hashsig_opts; + } + + return 0; +} + +static int insert_delete_side_of_split( + git_diff *diff, git_vector *onto, const git_diff_delta *delta) +{ + /* make new record for DELETED side of split */ + git_diff_delta *deleted = diff_delta__dup(delta, &diff->pool); + GITERR_CHECK_ALLOC(deleted); + + deleted->status = GIT_DELTA_DELETED; + deleted->nfiles = 1; + memset(&deleted->new_file, 0, sizeof(deleted->new_file)); + deleted->new_file.path = deleted->old_file.path; + deleted->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + return git_vector_insert(onto, deleted); +} + +static int apply_splits_and_deletes( + git_diff *diff, size_t expected_size, bool actually_split) +{ + git_vector onto = GIT_VECTOR_INIT; + size_t i; + git_diff_delta *delta; + + if (git_vector_init(&onto, expected_size, git_diff_delta__cmp) < 0) + return -1; + + /* build new delta list without TO_DELETE and splitting TO_SPLIT */ + git_vector_foreach(&diff->deltas, i, delta) { + if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0) + continue; + + if ((delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0 && actually_split) { + delta->similarity = 0; + + if (insert_delete_side_of_split(diff, &onto, delta) < 0) + goto on_error; + + if (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) + delta->status = GIT_DELTA_UNTRACKED; + else + delta->status = GIT_DELTA_ADDED; + delta->nfiles = 1; + memset(&delta->old_file, 0, sizeof(delta->old_file)); + delta->old_file.path = delta->new_file.path; + delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; + } + + /* clean up delta before inserting into new list */ + GIT_DIFF_FLAG__CLEAR_INTERNAL(delta->flags); + + if (delta->status != GIT_DELTA_COPIED && + delta->status != GIT_DELTA_RENAMED && + (delta->status != GIT_DELTA_MODIFIED || actually_split)) + delta->similarity = 0; + + /* insert into new list */ + if (git_vector_insert(&onto, delta) < 0) + goto on_error; + } + + /* cannot return an error past this point */ + + /* free deltas from old list that didn't make it to the new one */ + git_vector_foreach(&diff->deltas, i, delta) { + if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0) + git__free(delta); + } + + /* swap new delta list into place */ + git_vector_swap(&diff->deltas, &onto); + git_vector_free(&onto); + git_vector_sort(&diff->deltas); + + return 0; + +on_error: + git_vector_free_deep(&onto); + + return -1; +} + +GIT_INLINE(git_diff_file *) similarity_get_file(git_diff *diff, size_t idx) +{ + git_diff_delta *delta = git_vector_get(&diff->deltas, idx / 2); + return (idx & 1) ? &delta->new_file : &delta->old_file; +} + +typedef struct { + size_t idx; + git_iterator_type_t src; + git_repository *repo; + git_diff_file *file; + git_buf data; + git_odb_object *odb_obj; + git_blob *blob; +} similarity_info; + +static int similarity_init( + similarity_info *info, git_diff *diff, size_t file_idx) +{ + info->idx = file_idx; + info->src = (file_idx & 1) ? diff->new_src : diff->old_src; + info->repo = diff->repo; + info->file = similarity_get_file(diff, file_idx); + info->odb_obj = NULL; + info->blob = NULL; + git_buf_init(&info->data, 0); + + if (info->file->size > 0 || info->src == GIT_ITERATOR_TYPE_WORKDIR) + return 0; + + return git_diff_file__resolve_zero_size( + info->file, &info->odb_obj, info->repo); +} + +static int similarity_sig( + similarity_info *info, + const git_diff_find_options *opts, + void **cache) +{ + int error = 0; + git_diff_file *file = info->file; + + if (info->src == GIT_ITERATOR_TYPE_WORKDIR) { + if ((error = git_buf_joinpath( + &info->data, git_repository_workdir(info->repo), file->path)) < 0) + return error; + + /* if path is not a regular file, just skip this item */ + if (!git_path_isfile(info->data.ptr)) + return 0; + + /* TODO: apply wd-to-odb filters to file data if necessary */ + + error = opts->metric->file_signature( + &cache[info->idx], info->file, + info->data.ptr, opts->metric->payload); + } else { + /* if we didn't initially know the size, we might have an odb_obj + * around from earlier, so convert that, otherwise load the blob now + */ + if (info->odb_obj != NULL) + error = git_object__from_odb_object( + (git_object **)&info->blob, info->repo, + info->odb_obj, GIT_OBJ_BLOB); + else + error = git_blob_lookup(&info->blob, info->repo, &file->id); + + if (error < 0) { + /* if lookup fails, just skip this item in similarity calc */ + giterr_clear(); + } else { + size_t sz; + + /* index size may not be actual blob size if filtered */ + if (file->size != git_blob_rawsize(info->blob)) + file->size = git_blob_rawsize(info->blob); + + sz = (size_t)(git__is_sizet(file->size) ? file->size : -1); + + error = opts->metric->buffer_signature( + &cache[info->idx], info->file, + git_blob_rawcontent(info->blob), sz, opts->metric->payload); + } + } + + return error; +} + +static void similarity_unload(similarity_info *info) +{ + if (info->odb_obj) + git_odb_object_free(info->odb_obj); + + if (info->blob) + git_blob_free(info->blob); + else + git_buf_free(&info->data); +} + +#define FLAG_SET(opts,flag_name) (((opts)->flags & flag_name) != 0) + +/* - score < 0 means files cannot be compared + * - score >= 100 means files are exact match + * - score == 0 means files are completely different + */ +static int similarity_measure( + int *score, + git_diff *diff, + const git_diff_find_options *opts, + void **cache, + size_t a_idx, + size_t b_idx) +{ + git_diff_file *a_file = similarity_get_file(diff, a_idx); + git_diff_file *b_file = similarity_get_file(diff, b_idx); + bool exact_match = FLAG_SET(opts, GIT_DIFF_FIND_EXACT_MATCH_ONLY); + int error = 0; + similarity_info a_info, b_info; + + *score = -1; + + /* don't try to compare files of different types */ + if (GIT_MODE_TYPE(a_file->mode) != GIT_MODE_TYPE(b_file->mode)) + return 0; + + /* if exact match is requested, force calculation of missing OIDs now */ + if (exact_match) { + if (git_oid_iszero(&a_file->id) && + diff->old_src == GIT_ITERATOR_TYPE_WORKDIR && + !git_diff__oid_for_file(&a_file->id, + diff, a_file->path, a_file->mode, a_file->size)) + a_file->flags |= GIT_DIFF_FLAG_VALID_ID; + + if (git_oid_iszero(&b_file->id) && + diff->new_src == GIT_ITERATOR_TYPE_WORKDIR && + !git_diff__oid_for_file(&b_file->id, + diff, b_file->path, b_file->mode, b_file->size)) + b_file->flags |= GIT_DIFF_FLAG_VALID_ID; + } + + /* check OID match as a quick test */ + if (git_oid__cmp(&a_file->id, &b_file->id) == 0) { + *score = 100; + return 0; + } + + /* don't calculate signatures if we are doing exact match */ + if (exact_match) { + *score = 0; + return 0; + } + + memset(&a_info, 0, sizeof(a_info)); + memset(&b_info, 0, sizeof(b_info)); + + /* set up similarity data (will try to update missing file sizes) */ + if (!cache[a_idx] && (error = similarity_init(&a_info, diff, a_idx)) < 0) + return error; + if (!cache[b_idx] && (error = similarity_init(&b_info, diff, b_idx)) < 0) + goto cleanup; + + /* check if file sizes are nowhere near each other */ + if (a_file->size > 127 && + b_file->size > 127 && + (a_file->size > (b_file->size << 3) || + b_file->size > (a_file->size << 3))) + goto cleanup; + + /* update signature cache if needed */ + if (!cache[a_idx]) { + if ((error = similarity_sig(&a_info, opts, cache)) < 0) + goto cleanup; + } + if (!cache[b_idx]) { + if ((error = similarity_sig(&b_info, opts, cache)) < 0) + goto cleanup; + } + + /* calculate similarity provided that the metric choose to process + * both the a and b files (some may not if file is too big, etc). + */ + if (cache[a_idx] && cache[b_idx]) + error = opts->metric->similarity( + score, cache[a_idx], cache[b_idx], opts->metric->payload); + +cleanup: + similarity_unload(&a_info); + similarity_unload(&b_info); + + return error; +} + +static int calc_self_similarity( + git_diff *diff, + const git_diff_find_options *opts, + size_t delta_idx, + void **cache) +{ + int error, similarity = -1; + git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); + + if ((delta->flags & GIT_DIFF_FLAG__HAS_SELF_SIMILARITY) != 0) + return 0; + + error = similarity_measure( + &similarity, diff, opts, cache, 2 * delta_idx, 2 * delta_idx + 1); + if (error < 0) + return error; + + if (similarity >= 0) { + delta->similarity = (uint16_t)similarity; + delta->flags |= GIT_DIFF_FLAG__HAS_SELF_SIMILARITY; + } + + return 0; +} + +static bool is_rename_target( + git_diff *diff, + const git_diff_find_options *opts, + size_t delta_idx, + void **cache) +{ + git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); + + /* skip things that aren't plain blobs */ + if (!GIT_MODE_ISBLOB(delta->new_file.mode)) + return false; + + /* only consider ADDED, RENAMED, COPIED, and split MODIFIED as + * targets; maybe include UNTRACKED and IGNORED if requested. + */ + switch (delta->status) { + case GIT_DELTA_UNMODIFIED: + case GIT_DELTA_DELETED: + return false; + + case GIT_DELTA_MODIFIED: + if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && + !FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES)) + return false; + + if (calc_self_similarity(diff, opts, delta_idx, cache) < 0) + return false; + + if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && + delta->similarity < opts->break_rewrite_threshold) { + delta->flags |= GIT_DIFF_FLAG__TO_SPLIT; + break; + } + if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && + delta->similarity < opts->rename_from_rewrite_threshold) + break; + + return false; + + case GIT_DELTA_UNTRACKED: + if (!FLAG_SET(opts, GIT_DIFF_FIND_FOR_UNTRACKED)) + return false; + break; + + case GIT_DELTA_IGNORED: + return false; + + default: /* all other status values should be checked */ + break; + } + + delta->flags |= GIT_DIFF_FLAG__IS_RENAME_TARGET; + return true; +} + +static bool is_rename_source( + git_diff *diff, + const git_diff_find_options *opts, + size_t delta_idx, + void **cache) +{ + git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); + + /* skip things that aren't blobs */ + if (!GIT_MODE_ISBLOB(delta->old_file.mode)) + return false; + + switch (delta->status) { + case GIT_DELTA_ADDED: + case GIT_DELTA_UNTRACKED: + case GIT_DELTA_UNREADABLE: + case GIT_DELTA_IGNORED: + return false; + + case GIT_DELTA_DELETED: + case GIT_DELTA_TYPECHANGE: + break; + + case GIT_DELTA_UNMODIFIED: + if (!FLAG_SET(opts, GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED)) + return false; + if (FLAG_SET(opts, GIT_DIFF_FIND_REMOVE_UNMODIFIED)) + delta->flags |= GIT_DIFF_FLAG__TO_DELETE; + break; + + default: /* MODIFIED, RENAMED, COPIED */ + /* if we're finding copies, this could be a source */ + if (FLAG_SET(opts, GIT_DIFF_FIND_COPIES)) + break; + + /* otherwise, this is only a source if we can split it */ + if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && + !FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES)) + return false; + + if (calc_self_similarity(diff, opts, delta_idx, cache) < 0) + return false; + + if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && + delta->similarity < opts->break_rewrite_threshold) { + delta->flags |= GIT_DIFF_FLAG__TO_SPLIT; + break; + } + + if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && + delta->similarity < opts->rename_from_rewrite_threshold) + break; + + return false; + } + + delta->flags |= GIT_DIFF_FLAG__IS_RENAME_SOURCE; + return true; +} + +GIT_INLINE(bool) delta_is_split(git_diff_delta *delta) +{ + return (delta->status == GIT_DELTA_TYPECHANGE || + (delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0); +} + +GIT_INLINE(bool) delta_is_new_only(git_diff_delta *delta) +{ + return (delta->status == GIT_DELTA_ADDED || + delta->status == GIT_DELTA_UNTRACKED || + delta->status == GIT_DELTA_UNREADABLE || + delta->status == GIT_DELTA_IGNORED); +} + +GIT_INLINE(void) delta_make_rename( + git_diff_delta *to, const git_diff_delta *from, uint16_t similarity) +{ + to->status = GIT_DELTA_RENAMED; + to->similarity = similarity; + to->nfiles = 2; + memcpy(&to->old_file, &from->old_file, sizeof(to->old_file)); + to->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; +} + +typedef struct { + size_t idx; + uint16_t similarity; +} diff_find_match; + +int git_diff_find_similar( + git_diff *diff, + const git_diff_find_options *given_opts) +{ + size_t s, t; + int error = 0, result; + uint16_t similarity; + git_diff_delta *src, *tgt; + git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT; + size_t num_deltas, num_srcs = 0, num_tgts = 0; + size_t tried_srcs = 0, tried_tgts = 0; + size_t num_rewrites = 0, num_updates = 0, num_bumped = 0; + size_t sigcache_size; + void **sigcache = NULL; /* cache of similarity metric file signatures */ + diff_find_match *tgt2src = NULL; + diff_find_match *src2tgt = NULL; + diff_find_match *tgt2src_copy = NULL; + diff_find_match *best_match; + git_diff_file swap; + + if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0) + return error; + + num_deltas = diff->deltas.length; + + /* TODO: maybe abort if deltas.length > rename_limit ??? */ + if (!git__is_uint32(num_deltas)) + goto cleanup; + + /* No flags set; nothing to do */ + if ((opts.flags & GIT_DIFF_FIND_ALL) == 0) + goto cleanup; + + GITERR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2); + sigcache = git__calloc(sigcache_size, sizeof(void *)); + GITERR_CHECK_ALLOC(sigcache); + + /* Label rename sources and targets + * + * This will also set self-similarity scores for MODIFIED files and + * mark them for splitting if break-rewrites is enabled + */ + git_vector_foreach(&diff->deltas, t, tgt) { + if (is_rename_source(diff, &opts, t, sigcache)) + ++num_srcs; + + if (is_rename_target(diff, &opts, t, sigcache)) + ++num_tgts; + + if ((tgt->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0) + num_rewrites++; + } + + /* if there are no candidate srcs or tgts, we're done */ + if (!num_srcs || !num_tgts) + goto cleanup; + + src2tgt = git__calloc(num_deltas, sizeof(diff_find_match)); + GITERR_CHECK_ALLOC(src2tgt); + tgt2src = git__calloc(num_deltas, sizeof(diff_find_match)); + GITERR_CHECK_ALLOC(tgt2src); + + if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { + tgt2src_copy = git__calloc(num_deltas, sizeof(diff_find_match)); + GITERR_CHECK_ALLOC(tgt2src_copy); + } + + /* + * Find best-fit matches for rename / copy candidates + */ + +find_best_matches: + tried_tgts = num_bumped = 0; + + git_vector_foreach(&diff->deltas, t, tgt) { + /* skip things that are not rename targets */ + if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0) + continue; + + tried_srcs = 0; + + git_vector_foreach(&diff->deltas, s, src) { + /* skip things that are not rename sources */ + if ((src->flags & GIT_DIFF_FLAG__IS_RENAME_SOURCE) == 0) + continue; + + /* calculate similarity for this pair and find best match */ + if (s == t) + result = -1; /* don't measure self-similarity here */ + else if ((error = similarity_measure( + &result, diff, &opts, sigcache, 2 * s, 2 * t + 1)) < 0) + goto cleanup; + + if (result < 0) + continue; + similarity = (uint16_t)result; + + /* is this a better rename? */ + if (tgt2src[t].similarity < similarity && + src2tgt[s].similarity < similarity) + { + /* eject old mapping */ + if (src2tgt[s].similarity > 0) { + tgt2src[src2tgt[s].idx].similarity = 0; + num_bumped++; + } + if (tgt2src[t].similarity > 0) { + src2tgt[tgt2src[t].idx].similarity = 0; + num_bumped++; + } + + /* write new mapping */ + tgt2src[t].idx = s; + tgt2src[t].similarity = similarity; + src2tgt[s].idx = t; + src2tgt[s].similarity = similarity; + } + + /* keep best absolute match for copies */ + if (tgt2src_copy != NULL && + tgt2src_copy[t].similarity < similarity) + { + tgt2src_copy[t].idx = s; + tgt2src_copy[t].similarity = similarity; + } + + if (++tried_srcs >= num_srcs) + break; + + /* cap on maximum targets we'll examine (per "tgt" file) */ + if (tried_srcs > opts.rename_limit) + break; + } + + if (++tried_tgts >= num_tgts) + break; + } + + if (num_bumped > 0) /* try again if we bumped some items */ + goto find_best_matches; + + /* + * Rewrite the diffs with renames / copies + */ + + git_vector_foreach(&diff->deltas, t, tgt) { + /* skip things that are not rename targets */ + if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0) + continue; + + /* check if this delta was the target of a similarity */ + if (tgt2src[t].similarity) + best_match = &tgt2src[t]; + else if (tgt2src_copy && tgt2src_copy[t].similarity) + best_match = &tgt2src_copy[t]; + else + continue; + + s = best_match->idx; + src = GIT_VECTOR_GET(&diff->deltas, s); + + /* possible scenarios: + * 1. from DELETE to ADD/UNTRACK/IGNORE = RENAME + * 2. from DELETE to SPLIT/TYPECHANGE = RENAME + DELETE + * 3. from SPLIT/TYPECHANGE to ADD/UNTRACK/IGNORE = ADD + RENAME + * 4. from SPLIT/TYPECHANGE to SPLIT/TYPECHANGE = RENAME + SPLIT + * 5. from OTHER to ADD/UNTRACK/IGNORE = OTHER + COPY + */ + + if (src->status == GIT_DELTA_DELETED) { + + if (delta_is_new_only(tgt)) { + + if (best_match->similarity < opts.rename_threshold) + continue; + + delta_make_rename(tgt, src, best_match->similarity); + + src->flags |= GIT_DIFF_FLAG__TO_DELETE; + num_rewrites++; + } else { + assert(delta_is_split(tgt)); + + if (best_match->similarity < opts.rename_from_rewrite_threshold) + continue; + + memcpy(&swap, &tgt->old_file, sizeof(swap)); + + delta_make_rename(tgt, src, best_match->similarity); + num_rewrites--; + + assert(src->status == GIT_DELTA_DELETED); + memcpy(&src->old_file, &swap, sizeof(src->old_file)); + memset(&src->new_file, 0, sizeof(src->new_file)); + src->new_file.path = src->old_file.path; + src->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + num_updates++; + + if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { + /* what used to be at src t is now at src s */ + tgt2src[src2tgt[t].idx].idx = s; + } + } + } + + else if (delta_is_split(src)) { + + if (delta_is_new_only(tgt)) { + + if (best_match->similarity < opts.rename_threshold) + continue; + + delta_make_rename(tgt, src, best_match->similarity); + + src->status = (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) ? + GIT_DELTA_UNTRACKED : GIT_DELTA_ADDED; + src->nfiles = 1; + memset(&src->old_file, 0, sizeof(src->old_file)); + src->old_file.path = src->new_file.path; + src->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; + num_rewrites--; + + num_updates++; + } else { + assert(delta_is_split(src)); + + if (best_match->similarity < opts.rename_from_rewrite_threshold) + continue; + + memcpy(&swap, &tgt->old_file, sizeof(swap)); + + delta_make_rename(tgt, src, best_match->similarity); + num_rewrites--; + num_updates++; + + memcpy(&src->old_file, &swap, sizeof(src->old_file)); + + /* if we've just swapped the new element into the correct + * place, clear the SPLIT flag + */ + if (tgt2src[s].idx == t && + tgt2src[s].similarity > + opts.rename_from_rewrite_threshold) { + src->status = GIT_DELTA_RENAMED; + src->similarity = tgt2src[s].similarity; + tgt2src[s].similarity = 0; + src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; + num_rewrites--; + } + /* otherwise, if we just overwrote a source, update mapping */ + else if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { + /* what used to be at src t is now at src s */ + tgt2src[src2tgt[t].idx].idx = s; + } + + num_updates++; + } + } + + else if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { + if (tgt2src_copy[t].similarity < opts.copy_threshold) + continue; + + /* always use best possible source for copy */ + best_match = &tgt2src_copy[t]; + src = GIT_VECTOR_GET(&diff->deltas, best_match->idx); + + if (delta_is_split(tgt)) { + error = insert_delete_side_of_split(diff, &diff->deltas, tgt); + if (error < 0) + goto cleanup; + num_rewrites--; + } + + if (!delta_is_split(tgt) && !delta_is_new_only(tgt)) + continue; + + tgt->status = GIT_DELTA_COPIED; + tgt->similarity = best_match->similarity; + tgt->nfiles = 2; + memcpy(&tgt->old_file, &src->old_file, sizeof(tgt->old_file)); + tgt->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; + + num_updates++; + } + } + + /* + * Actually split and delete entries as needed + */ + + if (num_rewrites > 0 || num_updates > 0) + error = apply_splits_and_deletes( + diff, diff->deltas.length - num_rewrites, + FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) && + !FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY)); + +cleanup: + git__free(tgt2src); + git__free(src2tgt); + git__free(tgt2src_copy); + + if (sigcache) { + for (t = 0; t < num_deltas * 2; ++t) { + if (sigcache[t] != NULL) + opts.metric->free_signature(sigcache[t], opts.metric->payload); + } + git__free(sigcache); + } + + if (!given_opts || !given_opts->metric) + git__free(opts.metric); + + return error; +} + +#undef FLAG_SET diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.c b/deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.c new file mode 100644 index 000000000..e5984f1c9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.c @@ -0,0 +1,241 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "diff.h" +#include "diff_driver.h" +#include "diff_patch.h" +#include "diff_xdiff.h" + +static int git_xdiff_scan_int(const char **str, int *value) +{ + const char *scan = *str; + int v = 0, digits = 0; + /* find next digit */ + for (scan = *str; *scan && !git__isdigit(*scan); scan++); + /* parse next number */ + for (; git__isdigit(*scan); scan++, digits++) + v = (v * 10) + (*scan - '0'); + *str = scan; + *value = v; + return (digits > 0) ? 0 : -1; +} + +static int git_xdiff_parse_hunk(git_diff_hunk *hunk, const char *header) +{ + /* expect something of the form "@@ -%d[,%d] +%d[,%d] @@" */ + if (*header != '@') + goto fail; + if (git_xdiff_scan_int(&header, &hunk->old_start) < 0) + goto fail; + if (*header == ',') { + if (git_xdiff_scan_int(&header, &hunk->old_lines) < 0) + goto fail; + } else + hunk->old_lines = 1; + if (git_xdiff_scan_int(&header, &hunk->new_start) < 0) + goto fail; + if (*header == ',') { + if (git_xdiff_scan_int(&header, &hunk->new_lines) < 0) + goto fail; + } else + hunk->new_lines = 1; + if (hunk->old_start < 0 || hunk->new_start < 0) + goto fail; + + return 0; + +fail: + giterr_set(GITERR_INVALID, "Malformed hunk header from xdiff"); + return -1; +} + +typedef struct { + git_xdiff_output *xo; + git_patch *patch; + git_diff_hunk hunk; + int old_lineno, new_lineno; + mmfile_t xd_old_data, xd_new_data; +} git_xdiff_info; + +static int diff_update_lines( + git_xdiff_info *info, + git_diff_line *line, + const char *content, + size_t content_len) +{ + const char *scan = content, *scan_end = content + content_len; + + for (line->num_lines = 0; scan < scan_end; ++scan) + if (*scan == '\n') + ++line->num_lines; + + line->content = content; + line->content_len = content_len; + + /* expect " "/"-"/"+", then data */ + switch (line->origin) { + case GIT_DIFF_LINE_ADDITION: + case GIT_DIFF_LINE_DEL_EOFNL: + line->old_lineno = -1; + line->new_lineno = info->new_lineno; + info->new_lineno += (int)line->num_lines; + break; + case GIT_DIFF_LINE_DELETION: + case GIT_DIFF_LINE_ADD_EOFNL: + line->old_lineno = info->old_lineno; + line->new_lineno = -1; + info->old_lineno += (int)line->num_lines; + break; + case GIT_DIFF_LINE_CONTEXT: + case GIT_DIFF_LINE_CONTEXT_EOFNL: + line->old_lineno = info->old_lineno; + line->new_lineno = info->new_lineno; + info->old_lineno += (int)line->num_lines; + info->new_lineno += (int)line->num_lines; + break; + default: + giterr_set(GITERR_INVALID, "Unknown diff line origin %02x", + (unsigned int)line->origin); + return -1; + } + + return 0; +} + +static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len) +{ + git_xdiff_info *info = priv; + git_patch *patch = info->patch; + const git_diff_delta *delta = git_patch_get_delta(patch); + git_diff_output *output = &info->xo->output; + git_diff_line line; + + if (len == 1) { + output->error = git_xdiff_parse_hunk(&info->hunk, bufs[0].ptr); + if (output->error < 0) + return output->error; + + info->hunk.header_len = bufs[0].size; + if (info->hunk.header_len >= sizeof(info->hunk.header)) + info->hunk.header_len = sizeof(info->hunk.header) - 1; + memcpy(info->hunk.header, bufs[0].ptr, info->hunk.header_len); + info->hunk.header[info->hunk.header_len] = '\0'; + + if (output->hunk_cb != NULL && + (output->error = output->hunk_cb( + delta, &info->hunk, output->payload))) + return output->error; + + info->old_lineno = info->hunk.old_start; + info->new_lineno = info->hunk.new_start; + } + + if (len == 2 || len == 3) { + /* expect " "/"-"/"+", then data */ + line.origin = + (*bufs[0].ptr == '+') ? GIT_DIFF_LINE_ADDITION : + (*bufs[0].ptr == '-') ? GIT_DIFF_LINE_DELETION : + GIT_DIFF_LINE_CONTEXT; + + if (line.origin == GIT_DIFF_LINE_ADDITION) + line.content_offset = bufs[1].ptr - info->xd_new_data.ptr; + else if (line.origin == GIT_DIFF_LINE_DELETION) + line.content_offset = bufs[1].ptr - info->xd_old_data.ptr; + else + line.content_offset = -1; + + output->error = diff_update_lines( + info, &line, bufs[1].ptr, bufs[1].size); + + if (!output->error && output->data_cb != NULL) + output->error = output->data_cb( + delta, &info->hunk, &line, output->payload); + } + + if (len == 3 && !output->error) { + /* If we have a '+' and a third buf, then we have added a line + * without a newline and the old code had one, so DEL_EOFNL. + * If we have a '-' and a third buf, then we have removed a line + * with out a newline but added a blank line, so ADD_EOFNL. + */ + line.origin = + (*bufs[0].ptr == '+') ? GIT_DIFF_LINE_DEL_EOFNL : + (*bufs[0].ptr == '-') ? GIT_DIFF_LINE_ADD_EOFNL : + GIT_DIFF_LINE_CONTEXT_EOFNL; + + line.content_offset = -1; + + output->error = diff_update_lines( + info, &line, bufs[2].ptr, bufs[2].size); + + if (!output->error && output->data_cb != NULL) + output->error = output->data_cb( + delta, &info->hunk, &line, output->payload); + } + + return output->error; +} + +static int git_xdiff(git_diff_output *output, git_patch *patch) +{ + git_xdiff_output *xo = (git_xdiff_output *)output; + git_xdiff_info info; + git_diff_find_context_payload findctxt; + + memset(&info, 0, sizeof(info)); + info.patch = patch; + info.xo = xo; + + xo->callback.priv = &info; + + git_diff_find_context_init( + &xo->config.find_func, &findctxt, git_patch__driver(patch)); + xo->config.find_func_priv = &findctxt; + + if (xo->config.find_func != NULL) + xo->config.flags |= XDL_EMIT_FUNCNAMES; + else + xo->config.flags &= ~XDL_EMIT_FUNCNAMES; + + /* TODO: check ofile.opts_flags to see if driver-specific per-file + * updates are needed to xo->params.flags + */ + + git_patch__old_data(&info.xd_old_data.ptr, &info.xd_old_data.size, patch); + git_patch__new_data(&info.xd_new_data.ptr, &info.xd_new_data.size, patch); + + xdl_diff(&info.xd_old_data, &info.xd_new_data, + &xo->params, &xo->config, &xo->callback); + + git_diff_find_context_clear(&findctxt); + + return xo->output.error; +} + +void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts) +{ + uint32_t flags = opts ? opts->flags : 0; + + xo->output.diff_cb = git_xdiff; + + xo->config.ctxlen = opts ? opts->context_lines : 3; + xo->config.interhunkctxlen = opts ? opts->interhunk_lines : 0; + + if (flags & GIT_DIFF_IGNORE_WHITESPACE) + xo->params.flags |= XDF_WHITESPACE_FLAGS; + if (flags & GIT_DIFF_IGNORE_WHITESPACE_CHANGE) + xo->params.flags |= XDF_IGNORE_WHITESPACE_CHANGE; + if (flags & GIT_DIFF_IGNORE_WHITESPACE_EOL) + xo->params.flags |= XDF_IGNORE_WHITESPACE_AT_EOL; + + if (flags & GIT_DIFF_PATIENCE) + xo->params.flags |= XDF_PATIENCE_DIFF; + if (flags & GIT_DIFF_MINIMAL) + xo->params.flags |= XDF_NEED_MINIMAL; + + xo->callback.outf = git_xdiff_cb; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.h b/deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.h new file mode 100644 index 000000000..c547b00cf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/diff_xdiff.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_diff_xdiff_h__ +#define INCLUDE_diff_xdiff_h__ + +#include "diff.h" +#include "diff_patch.h" +#include "xdiff/xdiff.h" + +/* A git_xdiff_output is a git_diff_output with extra fields necessary + * to use libxdiff. Calling git_xdiff_init() will set the diff_cb field + * of the output to use xdiff to generate the diffs. + */ +typedef struct { + git_diff_output output; + + xdemitconf_t config; + xpparam_t params; + xdemitcb_t callback; +} git_xdiff_output; + +void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/errors.c b/deps/libgit2-sys-0.2.17/libgit2/src/errors.c new file mode 100644 index 000000000..7a2600586 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/errors.c @@ -0,0 +1,176 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "global.h" +#include "posix.h" +#include "buffer.h" + +/******************************************** + * New error handling + ********************************************/ + +static git_error g_git_oom_error = { + "Out of memory", + GITERR_NOMEMORY +}; + +static void set_error(int error_class, char *string) +{ + git_error *error = &GIT_GLOBAL->error_t; + + if (error->message != string) + git__free(error->message); + + error->message = string; + error->klass = error_class; + + GIT_GLOBAL->last_error = error; +} + +void giterr_set_oom(void) +{ + GIT_GLOBAL->last_error = &g_git_oom_error; +} + +void giterr_set(int error_class, const char *string, ...) +{ + git_buf buf = GIT_BUF_INIT; + va_list arglist; +#ifdef GIT_WIN32 + DWORD win32_error_code = (error_class == GITERR_OS) ? GetLastError() : 0; +#endif + int error_code = (error_class == GITERR_OS) ? errno : 0; + + if (string) { + va_start(arglist, string); + git_buf_vprintf(&buf, string, arglist); + va_end(arglist); + + if (error_class == GITERR_OS) + git_buf_PUTS(&buf, ": "); + } + + if (error_class == GITERR_OS) { +#ifdef GIT_WIN32 + char * win32_error = git_win32_get_error_message(win32_error_code); + if (win32_error) { + git_buf_puts(&buf, win32_error); + git__free(win32_error); + + SetLastError(0); + } + else +#endif + if (error_code) + git_buf_puts(&buf, strerror(error_code)); + + if (error_code) + errno = 0; + } + + if (!git_buf_oom(&buf)) + set_error(error_class, git_buf_detach(&buf)); +} + +void giterr_set_str(int error_class, const char *string) +{ + char *message; + + assert(string); + + message = git__strdup(string); + + if (message) + set_error(error_class, message); +} + +int giterr_set_regex(const regex_t *regex, int error_code) +{ + char error_buf[1024]; + + assert(error_code); + + regerror(error_code, regex, error_buf, sizeof(error_buf)); + giterr_set_str(GITERR_REGEX, error_buf); + + if (error_code == REG_NOMATCH) + return GIT_ENOTFOUND; + + return GIT_EINVALIDSPEC; +} + +void giterr_clear(void) +{ + if (GIT_GLOBAL->last_error != NULL) { + set_error(0, NULL); + GIT_GLOBAL->last_error = NULL; + } + + errno = 0; +#ifdef GIT_WIN32 + SetLastError(0); +#endif +} + +int giterr_detach(git_error *cpy) +{ + git_error *error = GIT_GLOBAL->last_error; + + assert(cpy); + + if (!error) + return -1; + + cpy->message = error->message; + cpy->klass = error->klass; + + error->message = NULL; + giterr_clear(); + + return 0; +} + +const git_error *giterr_last(void) +{ + return GIT_GLOBAL->last_error; +} + +int giterr_capture(git_error_state *state, int error_code) +{ + state->error_code = error_code; + if (error_code) + giterr_detach(&state->error_msg); + return error_code; +} + +int giterr_restore(git_error_state *state) +{ + if (state && state->error_code && state->error_msg.message) + set_error(state->error_msg.klass, state->error_msg.message); + else + giterr_clear(); + + return state ? state->error_code : 0; +} + +int giterr_system_last(void) +{ +#ifdef GIT_WIN32 + return GetLastError(); +#else + return errno; +#endif +} + +void giterr_system_set(int code) +{ +#ifdef GIT_WIN32 + SetLastError(code); +#else + errno = code; +#endif +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fetch.c b/deps/libgit2-sys-0.2.17/libgit2/src/fetch.c new file mode 100644 index 000000000..f61685619 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fetch.c @@ -0,0 +1,139 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/oid.h" +#include "git2/refs.h" +#include "git2/revwalk.h" +#include "git2/transport.h" + +#include "common.h" +#include "remote.h" +#include "refspec.h" +#include "pack.h" +#include "fetch.h" +#include "netops.h" +#include "repository.h" +#include "refs.h" + +static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec) +{ + int match = 0; + + if (!git_reference_is_valid_name(head->name)) + return 0; + + if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) { + /* + * If tagopt is --tags, always request tags + * in addition to the remote's refspecs + */ + if (git_refspec_src_matches(tagspec, head->name)) + match = 1; + } + + if (!match && git_remote__matching_refspec(remote, head->name)) + match = 1; + + if (!match) + return 0; + + /* If we have the object, mark it so we don't ask for it */ + if (git_odb_exists(odb, &head->oid)) { + head->local = 1; + } + else + remote->need_pack = 1; + + return git_vector_insert(&remote->refs, head); +} + +static int filter_wants(git_remote *remote) +{ + git_remote_head **heads; + git_refspec tagspec, head; + int error = 0; + git_odb *odb; + size_t i, heads_len; + + git_vector_clear(&remote->refs); + if ((error = git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true)) < 0) + return error; + + /* + * The fetch refspec can be NULL, and what this means is that the + * user didn't specify one. This is fine, as it means that we're + * not interested in any particular branch but just the remote's + * HEAD, which will be stored in FETCH_HEAD after the fetch. + */ + if (remote->active_refspecs.length == 0) { + if ((error = git_refspec__parse(&head, "HEAD", true)) < 0) + goto cleanup; + + error = git_refspec__dwim_one(&remote->active_refspecs, &head, &remote->refs); + git_refspec__free(&head); + + if (error < 0) + goto cleanup; + } + + if (git_repository_odb__weakptr(&odb, remote->repo) < 0) + goto cleanup; + + if (git_remote_ls((const git_remote_head ***)&heads, &heads_len, remote) < 0) + goto cleanup; + + for (i = 0; i < heads_len; i++) { + if ((error = maybe_want(remote, heads[i], odb, &tagspec)) < 0) + break; + } + +cleanup: + git_refspec__free(&tagspec); + + return error; +} + +/* + * In this first version, we push all our refs in and start sending + * them out. When we get an ACK we hide that commit and continue + * traversing until we're done + */ +int git_fetch_negotiate(git_remote *remote) +{ + git_transport *t = remote->transport; + + remote->need_pack = 0; + + if (filter_wants(remote) < 0) { + giterr_set(GITERR_NET, "Failed to filter the reference list for wants"); + return -1; + } + + /* Don't try to negotiate when we don't want anything */ + if (!remote->need_pack) + return 0; + + /* + * Now we have everything set up so we can start tell the + * server what we want and what we have. + */ + return t->negotiate_fetch(t, + remote->repo, + (const git_remote_head * const *)remote->refs.contents, + remote->refs.length); +} + +int git_fetch_download_pack(git_remote *remote) +{ + git_transport *t = remote->transport; + + if (!remote->need_pack) + return 0; + + return t->download_pack(t, remote->repo, &remote->stats, + remote->callbacks.transfer_progress, remote->callbacks.payload); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fetch.h b/deps/libgit2-sys-0.2.17/libgit2/src/fetch.h new file mode 100644 index 000000000..f66e44663 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fetch.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_fetch_h__ +#define INCLUDE_fetch_h__ + +#include "netops.h" + +int git_fetch_negotiate(git_remote *remote); + +int git_fetch_download_pack(git_remote *remote); + +int git_fetch__download_pack( + git_transport *t, + git_repository *repo, + git_transfer_progress *stats, + git_transfer_progress_cb progress_cb, + void *progress_payload); + +int git_fetch_setup_walk(git_revwalk **out, git_repository *repo); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.c b/deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.c new file mode 100644 index 000000000..a95ea4ca4 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.c @@ -0,0 +1,302 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/types.h" +#include "git2/oid.h" + +#include "fetchhead.h" +#include "common.h" +#include "buffer.h" +#include "fileops.h" +#include "filebuf.h" +#include "refs.h" +#include "repository.h" + +int git_fetchhead_ref_cmp(const void *a, const void *b) +{ + const git_fetchhead_ref *one = (const git_fetchhead_ref *)a; + const git_fetchhead_ref *two = (const git_fetchhead_ref *)b; + + if (one->is_merge && !two->is_merge) + return -1; + if (two->is_merge && !one->is_merge) + return 1; + + if (one->ref_name && two->ref_name) + return strcmp(one->ref_name, two->ref_name); + else if (one->ref_name) + return -1; + else if (two->ref_name) + return 1; + + return 0; +} + +int git_fetchhead_ref_create( + git_fetchhead_ref **out, + git_oid *oid, + unsigned int is_merge, + const char *ref_name, + const char *remote_url) +{ + git_fetchhead_ref *fetchhead_ref; + + assert(out && oid); + + *out = NULL; + + fetchhead_ref = git__malloc(sizeof(git_fetchhead_ref)); + GITERR_CHECK_ALLOC(fetchhead_ref); + + memset(fetchhead_ref, 0x0, sizeof(git_fetchhead_ref)); + + git_oid_cpy(&fetchhead_ref->oid, oid); + fetchhead_ref->is_merge = is_merge; + + if (ref_name) + fetchhead_ref->ref_name = git__strdup(ref_name); + + if (remote_url) + fetchhead_ref->remote_url = git__strdup(remote_url); + + *out = fetchhead_ref; + + return 0; +} + +static int fetchhead_ref_write( + git_filebuf *file, + git_fetchhead_ref *fetchhead_ref) +{ + char oid[GIT_OID_HEXSZ + 1]; + const char *type, *name; + int head = 0; + + assert(file && fetchhead_ref); + + git_oid_fmt(oid, &fetchhead_ref->oid); + oid[GIT_OID_HEXSZ] = '\0'; + + if (git__prefixcmp(fetchhead_ref->ref_name, GIT_REFS_HEADS_DIR) == 0) { + type = "branch "; + name = fetchhead_ref->ref_name + strlen(GIT_REFS_HEADS_DIR); + } else if(git__prefixcmp(fetchhead_ref->ref_name, + GIT_REFS_TAGS_DIR) == 0) { + type = "tag "; + name = fetchhead_ref->ref_name + strlen(GIT_REFS_TAGS_DIR); + } else if (!git__strcmp(fetchhead_ref->ref_name, GIT_HEAD_FILE)) { + head = 1; + } else { + type = ""; + name = fetchhead_ref->ref_name; + } + + if (head) + return git_filebuf_printf(file, "%s\t\t%s\n", oid, fetchhead_ref->remote_url); + + return git_filebuf_printf(file, "%s\t%s\t%s'%s' of %s\n", + oid, + (fetchhead_ref->is_merge) ? "" : "not-for-merge", + type, + name, + fetchhead_ref->remote_url); +} + +int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf path = GIT_BUF_INIT; + unsigned int i; + git_fetchhead_ref *fetchhead_ref; + + assert(repo && fetchhead_refs); + + if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) + return -1; + + if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) { + git_buf_free(&path); + return -1; + } + + git_buf_free(&path); + + git_vector_sort(fetchhead_refs); + + git_vector_foreach(fetchhead_refs, i, fetchhead_ref) + fetchhead_ref_write(&file, fetchhead_ref); + + return git_filebuf_commit(&file); +} + +static int fetchhead_ref_parse( + git_oid *oid, + unsigned int *is_merge, + git_buf *ref_name, + const char **remote_url, + char *line, + size_t line_num) +{ + char *oid_str, *is_merge_str, *desc, *name = NULL; + const char *type = NULL; + int error = 0; + + *remote_url = NULL; + + if (!*line) { + giterr_set(GITERR_FETCHHEAD, + "Empty line in FETCH_HEAD line %d", line_num); + return -1; + } + + /* Compat with old git clients that wrote FETCH_HEAD like a loose ref. */ + if ((oid_str = git__strsep(&line, "\t")) == NULL) { + oid_str = line; + line += strlen(line); + + *is_merge = 1; + } + + if (strlen(oid_str) != GIT_OID_HEXSZ) { + giterr_set(GITERR_FETCHHEAD, + "Invalid object ID in FETCH_HEAD line %d", line_num); + return -1; + } + + if (git_oid_fromstr(oid, oid_str) < 0) { + const git_error *oid_err = giterr_last(); + const char *err_msg = oid_err ? oid_err->message : "Invalid object ID"; + + giterr_set(GITERR_FETCHHEAD, "%s in FETCH_HEAD line %d", + err_msg, line_num); + return -1; + } + + /* Parse new data from newer git clients */ + if (*line) { + if ((is_merge_str = git__strsep(&line, "\t")) == NULL) { + giterr_set(GITERR_FETCHHEAD, + "Invalid description data in FETCH_HEAD line %d", line_num); + return -1; + } + + if (*is_merge_str == '\0') + *is_merge = 1; + else if (strcmp(is_merge_str, "not-for-merge") == 0) + *is_merge = 0; + else { + giterr_set(GITERR_FETCHHEAD, + "Invalid for-merge entry in FETCH_HEAD line %d", line_num); + return -1; + } + + if ((desc = line) == NULL) { + giterr_set(GITERR_FETCHHEAD, + "Invalid description in FETCH_HEAD line %d", line_num); + return -1; + } + + if (git__prefixcmp(desc, "branch '") == 0) { + type = GIT_REFS_HEADS_DIR; + name = desc + 8; + } else if (git__prefixcmp(desc, "tag '") == 0) { + type = GIT_REFS_TAGS_DIR; + name = desc + 5; + } else if (git__prefixcmp(desc, "'") == 0) + name = desc + 1; + + if (name) { + if ((desc = strstr(name, "' ")) == NULL || + git__prefixcmp(desc, "' of ") != 0) { + giterr_set(GITERR_FETCHHEAD, + "Invalid description in FETCH_HEAD line %d", line_num); + return -1; + } + + *desc = '\0'; + desc += 5; + } + + *remote_url = desc; + } + + git_buf_clear(ref_name); + + if (type) + git_buf_join(ref_name, '/', type, name); + else if(name) + git_buf_puts(ref_name, name); + + return error; +} + +int git_repository_fetchhead_foreach(git_repository *repo, + git_repository_fetchhead_foreach_cb cb, + void *payload) +{ + git_buf path = GIT_BUF_INIT, file = GIT_BUF_INIT, name = GIT_BUF_INIT; + const char *ref_name; + git_oid oid; + const char *remote_url; + unsigned int is_merge = 0; + char *buffer, *line; + size_t line_num = 0; + int error = 0; + + assert(repo && cb); + + if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) + return -1; + + if ((error = git_futils_readbuffer(&file, git_buf_cstr(&path))) < 0) + goto done; + + buffer = file.ptr; + + while ((line = git__strsep(&buffer, "\n")) != NULL) { + ++line_num; + + if ((error = fetchhead_ref_parse( + &oid, &is_merge, &name, &remote_url, line, line_num)) < 0) + goto done; + + if (git_buf_len(&name) > 0) + ref_name = git_buf_cstr(&name); + else + ref_name = NULL; + + error = cb(ref_name, remote_url, &oid, is_merge, payload); + if (error) { + giterr_set_after_callback(error); + goto done; + } + } + + if (*buffer) { + giterr_set(GITERR_FETCHHEAD, "No EOL at line %d", line_num+1); + error = -1; + goto done; + } + +done: + git_buf_free(&file); + git_buf_free(&path); + git_buf_free(&name); + + return error; +} + +void git_fetchhead_ref_free(git_fetchhead_ref *fetchhead_ref) +{ + if (fetchhead_ref == NULL) + return; + + git__free(fetchhead_ref->remote_url); + git__free(fetchhead_ref->ref_name); + git__free(fetchhead_ref); +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.h b/deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.h new file mode 100644 index 000000000..b03bd0f74 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fetchhead.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_fetchhead_h__ +#define INCLUDE_fetchhead_h__ + +#include "vector.h" + +typedef struct git_fetchhead_ref { + git_oid oid; + unsigned int is_merge; + char *ref_name; + char *remote_url; +} git_fetchhead_ref; + +int git_fetchhead_ref_create( + git_fetchhead_ref **fetchhead_ref_out, + git_oid *oid, + unsigned int is_merge, + const char *ref_name, + const char *remote_url); + +int git_fetchhead_ref_cmp(const void *a, const void *b); + +int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs); + +void git_fetchhead_ref_free(git_fetchhead_ref *fetchhead_ref); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/filebuf.c b/deps/libgit2-sys-0.2.17/libgit2/src/filebuf.c new file mode 100644 index 000000000..a35b59cf0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/filebuf.c @@ -0,0 +1,486 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "filebuf.h" +#include "fileops.h" + +static const size_t WRITE_BUFFER_SIZE = (4096 * 2); + +enum buferr_t { + BUFERR_OK = 0, + BUFERR_WRITE, + BUFERR_ZLIB, + BUFERR_MEM +}; + +#define ENSURE_BUF_OK(buf) if ((buf)->last_error != BUFERR_OK) { return -1; } + +static int verify_last_error(git_filebuf *file) +{ + switch (file->last_error) { + case BUFERR_WRITE: + giterr_set(GITERR_OS, "Failed to write out file"); + return -1; + + case BUFERR_MEM: + giterr_set_oom(); + return -1; + + case BUFERR_ZLIB: + giterr_set(GITERR_ZLIB, + "Buffer error when writing out ZLib data"); + return -1; + + default: + return 0; + } +} + +static int lock_file(git_filebuf *file, int flags, mode_t mode) +{ + if (git_path_exists(file->path_lock) == true) { + if (flags & GIT_FILEBUF_FORCE) + p_unlink(file->path_lock); + else { + giterr_clear(); /* actual OS error code just confuses */ + giterr_set(GITERR_OS, + "Failed to lock file '%s' for writing", file->path_lock); + return GIT_ELOCKED; + } + } + + /* create path to the file buffer is required */ + if (flags & GIT_FILEBUF_FORCE) { + /* XXX: Should dirmode here be configurable? Or is 0777 always fine? */ + file->fd = git_futils_creat_locked_withpath(file->path_lock, 0777, mode); + } else { + file->fd = git_futils_creat_locked(file->path_lock, mode); + } + + if (file->fd < 0) + return file->fd; + + file->fd_is_open = true; + + if ((flags & GIT_FILEBUF_APPEND) && git_path_exists(file->path_original) == true) { + git_file source; + char buffer[2048]; + ssize_t read_bytes; + + source = p_open(file->path_original, O_RDONLY); + if (source < 0) { + giterr_set(GITERR_OS, + "Failed to open file '%s' for reading", + file->path_original); + return -1; + } + + while ((read_bytes = p_read(source, buffer, sizeof(buffer))) > 0) { + p_write(file->fd, buffer, read_bytes); + if (file->compute_digest) + git_hash_update(&file->digest, buffer, read_bytes); + } + + p_close(source); + + if (read_bytes < 0) { + giterr_set(GITERR_OS, "Failed to read file '%s'", file->path_original); + return -1; + } + } + + return 0; +} + +void git_filebuf_cleanup(git_filebuf *file) +{ + if (file->fd_is_open && file->fd >= 0) + p_close(file->fd); + + if (file->fd_is_open && file->path_lock && git_path_exists(file->path_lock)) + p_unlink(file->path_lock); + + if (file->compute_digest) { + git_hash_ctx_cleanup(&file->digest); + file->compute_digest = 0; + } + + if (file->buffer) + git__free(file->buffer); + + /* use the presence of z_buf to decide if we need to deflateEnd */ + if (file->z_buf) { + git__free(file->z_buf); + deflateEnd(&file->zs); + } + + if (file->path_original) + git__free(file->path_original); + if (file->path_lock) + git__free(file->path_lock); + + memset(file, 0x0, sizeof(git_filebuf)); + file->fd = -1; +} + +GIT_INLINE(int) flush_buffer(git_filebuf *file) +{ + int result = file->write(file, file->buffer, file->buf_pos); + file->buf_pos = 0; + return result; +} + +int git_filebuf_flush(git_filebuf *file) +{ + return flush_buffer(file); +} + +static int write_normal(git_filebuf *file, void *source, size_t len) +{ + if (len > 0) { + if (p_write(file->fd, (void *)source, len) < 0) { + file->last_error = BUFERR_WRITE; + return -1; + } + + if (file->compute_digest) + git_hash_update(&file->digest, source, len); + } + + return 0; +} + +static int write_deflate(git_filebuf *file, void *source, size_t len) +{ + z_stream *zs = &file->zs; + + if (len > 0 || file->flush_mode == Z_FINISH) { + zs->next_in = source; + zs->avail_in = (uInt)len; + + do { + size_t have; + + zs->next_out = file->z_buf; + zs->avail_out = (uInt)file->buf_size; + + if (deflate(zs, file->flush_mode) == Z_STREAM_ERROR) { + file->last_error = BUFERR_ZLIB; + return -1; + } + + have = file->buf_size - (size_t)zs->avail_out; + + if (p_write(file->fd, file->z_buf, have) < 0) { + file->last_error = BUFERR_WRITE; + return -1; + } + + } while (zs->avail_out == 0); + + assert(zs->avail_in == 0); + + if (file->compute_digest) + git_hash_update(&file->digest, source, len); + } + + return 0; +} + +int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode) +{ + int compression, error = -1; + size_t path_len, alloc_len; + + /* opening an already open buffer is a programming error; + * assert that this never happens instead of returning + * an error code */ + assert(file && path && file->buffer == NULL); + + memset(file, 0x0, sizeof(git_filebuf)); + + if (flags & GIT_FILEBUF_DO_NOT_BUFFER) + file->do_not_buffer = true; + + file->buf_size = WRITE_BUFFER_SIZE; + file->buf_pos = 0; + file->fd = -1; + file->last_error = BUFERR_OK; + + /* Allocate the main cache buffer */ + if (!file->do_not_buffer) { + file->buffer = git__malloc(file->buf_size); + GITERR_CHECK_ALLOC(file->buffer); + } + + /* If we are hashing on-write, allocate a new hash context */ + if (flags & GIT_FILEBUF_HASH_CONTENTS) { + file->compute_digest = 1; + + if (git_hash_ctx_init(&file->digest) < 0) + goto cleanup; + } + + compression = flags >> GIT_FILEBUF_DEFLATE_SHIFT; + + /* If we are deflating on-write, */ + if (compression != 0) { + /* Initialize the ZLib stream */ + if (deflateInit(&file->zs, compression) != Z_OK) { + giterr_set(GITERR_ZLIB, "Failed to initialize zlib"); + goto cleanup; + } + + /* Allocate the Zlib cache buffer */ + file->z_buf = git__malloc(file->buf_size); + GITERR_CHECK_ALLOC(file->z_buf); + + /* Never flush */ + file->flush_mode = Z_NO_FLUSH; + file->write = &write_deflate; + } else { + file->write = &write_normal; + } + + /* If we are writing to a temp file */ + if (flags & GIT_FILEBUF_TEMPORARY) { + git_buf tmp_path = GIT_BUF_INIT; + + /* Open the file as temporary for locking */ + file->fd = git_futils_mktmp(&tmp_path, path, mode); + + if (file->fd < 0) { + git_buf_free(&tmp_path); + goto cleanup; + } + file->fd_is_open = true; + + /* No original path */ + file->path_original = NULL; + file->path_lock = git_buf_detach(&tmp_path); + GITERR_CHECK_ALLOC(file->path_lock); + } else { + path_len = strlen(path); + + /* Save the original path of the file */ + file->path_original = git__strdup(path); + GITERR_CHECK_ALLOC(file->path_original); + + /* create the locking path by appending ".lock" to the original */ + GITERR_CHECK_ALLOC_ADD(&alloc_len, path_len, GIT_FILELOCK_EXTLENGTH); + file->path_lock = git__malloc(alloc_len); + GITERR_CHECK_ALLOC(file->path_lock); + + memcpy(file->path_lock, file->path_original, path_len); + memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH); + + /* open the file for locking */ + if ((error = lock_file(file, flags, mode)) < 0) + goto cleanup; + } + + return 0; + +cleanup: + git_filebuf_cleanup(file); + return error; +} + +int git_filebuf_hash(git_oid *oid, git_filebuf *file) +{ + assert(oid && file && file->compute_digest); + + flush_buffer(file); + + if (verify_last_error(file) < 0) + return -1; + + git_hash_final(oid, &file->digest); + git_hash_ctx_cleanup(&file->digest); + file->compute_digest = 0; + + return 0; +} + +int git_filebuf_commit_at(git_filebuf *file, const char *path) +{ + git__free(file->path_original); + file->path_original = git__strdup(path); + GITERR_CHECK_ALLOC(file->path_original); + + return git_filebuf_commit(file); +} + +int git_filebuf_commit(git_filebuf *file) +{ + /* temporary files cannot be committed */ + assert(file && file->path_original); + + file->flush_mode = Z_FINISH; + flush_buffer(file); + + if (verify_last_error(file) < 0) + goto on_error; + + file->fd_is_open = false; + + if (p_close(file->fd) < 0) { + giterr_set(GITERR_OS, "Failed to close file at '%s'", file->path_lock); + goto on_error; + } + + file->fd = -1; + + if (p_rename(file->path_lock, file->path_original) < 0) { + giterr_set(GITERR_OS, "Failed to rename lockfile to '%s'", file->path_original); + goto on_error; + } + + git_filebuf_cleanup(file); + return 0; + +on_error: + git_filebuf_cleanup(file); + return -1; +} + +GIT_INLINE(void) add_to_cache(git_filebuf *file, const void *buf, size_t len) +{ + memcpy(file->buffer + file->buf_pos, buf, len); + file->buf_pos += len; +} + +int git_filebuf_write(git_filebuf *file, const void *buff, size_t len) +{ + const unsigned char *buf = buff; + + ENSURE_BUF_OK(file); + + if (file->do_not_buffer) + return file->write(file, (void *)buff, len); + + for (;;) { + size_t space_left = file->buf_size - file->buf_pos; + + /* cache if it's small */ + if (space_left > len) { + add_to_cache(file, buf, len); + return 0; + } + + add_to_cache(file, buf, space_left); + if (flush_buffer(file) < 0) + return -1; + + len -= space_left; + buf += space_left; + } +} + +int git_filebuf_reserve(git_filebuf *file, void **buffer, size_t len) +{ + size_t space_left = file->buf_size - file->buf_pos; + + *buffer = NULL; + + ENSURE_BUF_OK(file); + + if (len > file->buf_size) { + file->last_error = BUFERR_MEM; + return -1; + } + + if (space_left <= len) { + if (flush_buffer(file) < 0) + return -1; + } + + *buffer = (file->buffer + file->buf_pos); + file->buf_pos += len; + + return 0; +} + +int git_filebuf_printf(git_filebuf *file, const char *format, ...) +{ + va_list arglist; + size_t space_left, len, alloclen; + int written, res; + char *tmp_buffer; + + ENSURE_BUF_OK(file); + + space_left = file->buf_size - file->buf_pos; + + do { + va_start(arglist, format); + written = p_vsnprintf((char *)file->buffer + file->buf_pos, space_left, format, arglist); + va_end(arglist); + + if (written < 0) { + file->last_error = BUFERR_MEM; + return -1; + } + + len = written; + if (len + 1 <= space_left) { + file->buf_pos += len; + return 0; + } + + if (flush_buffer(file) < 0) + return -1; + + space_left = file->buf_size - file->buf_pos; + + } while (len + 1 <= space_left); + + if (GIT_ADD_SIZET_OVERFLOW(&alloclen, len, 1) || + !(tmp_buffer = git__malloc(alloclen))) { + file->last_error = BUFERR_MEM; + return -1; + } + + va_start(arglist, format); + written = p_vsnprintf(tmp_buffer, len + 1, format, arglist); + va_end(arglist); + + if (written < 0) { + git__free(tmp_buffer); + file->last_error = BUFERR_MEM; + return -1; + } + + res = git_filebuf_write(file, tmp_buffer, len); + git__free(tmp_buffer); + + return res; +} + +int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file) +{ + int res; + struct stat st; + + if (file->fd_is_open) + res = p_fstat(file->fd, &st); + else + res = p_stat(file->path_original, &st); + + if (res < 0) { + giterr_set(GITERR_OS, "Could not get stat info for '%s'", + file->path_original); + return res; + } + + if (mtime) + *mtime = st.st_mtime; + if (size) + *size = (size_t)st.st_size; + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/filebuf.h b/deps/libgit2-sys-0.2.17/libgit2/src/filebuf.h new file mode 100644 index 000000000..2bd18dc35 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/filebuf.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_filebuf_h__ +#define INCLUDE_filebuf_h__ + +#include "fileops.h" +#include "hash.h" +#include + +#ifdef GIT_THREADS +# define GIT_FILEBUF_THREADS +#endif + +#define GIT_FILEBUF_HASH_CONTENTS (1 << 0) +#define GIT_FILEBUF_APPEND (1 << 2) +#define GIT_FILEBUF_FORCE (1 << 3) +#define GIT_FILEBUF_TEMPORARY (1 << 4) +#define GIT_FILEBUF_DO_NOT_BUFFER (1 << 5) +#define GIT_FILEBUF_DEFLATE_SHIFT (6) + +#define GIT_FILELOCK_EXTENSION ".lock\0" +#define GIT_FILELOCK_EXTLENGTH 6 + +typedef struct git_filebuf git_filebuf; +struct git_filebuf { + char *path_original; + char *path_lock; + + int (*write)(git_filebuf *file, void *source, size_t len); + + bool compute_digest; + git_hash_ctx digest; + + unsigned char *buffer; + unsigned char *z_buf; + + z_stream zs; + int flush_mode; + + size_t buf_size, buf_pos; + git_file fd; + bool fd_is_open; + bool do_not_buffer; + int last_error; +}; + +#define GIT_FILEBUF_INIT {0} + +/* + * The git_filebuf object lifecycle is: + * - Allocate git_filebuf, preferably using GIT_FILEBUF_INIT. + * + * - Call git_filebuf_open() to initialize the filebuf for use. + * + * - Make as many calls to git_filebuf_write(), git_filebuf_printf(), + * git_filebuf_reserve() as you like. The error codes for these + * functions don't need to be checked. They are stored internally + * by the file buffer. + * + * - While you are writing, you may call git_filebuf_hash() to get + * the hash of all you have written so far. This function will + * fail if any of the previous writes to the buffer failed. + * + * - To close the git_filebuf, you may call git_filebuf_commit() or + * git_filebuf_commit_at() to save the file, or + * git_filebuf_cleanup() to abandon the file. All of these will + * free the git_filebuf object. Likewise, all of these will fail + * if any of the previous writes to the buffer failed, and set + * an error code accordingly. + */ +int git_filebuf_write(git_filebuf *lock, const void *buff, size_t len); +int git_filebuf_reserve(git_filebuf *file, void **buff, size_t len); +int git_filebuf_printf(git_filebuf *file, const char *format, ...) GIT_FORMAT_PRINTF(2, 3); + +int git_filebuf_open(git_filebuf *lock, const char *path, int flags, mode_t mode); +int git_filebuf_commit(git_filebuf *lock); +int git_filebuf_commit_at(git_filebuf *lock, const char *path); +void git_filebuf_cleanup(git_filebuf *lock); +int git_filebuf_hash(git_oid *oid, git_filebuf *file); +int git_filebuf_flush(git_filebuf *file); +int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fileops.c b/deps/libgit2-sys-0.2.17/libgit2/src/fileops.c new file mode 100644 index 000000000..993224686 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fileops.c @@ -0,0 +1,967 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "fileops.h" +#include "global.h" +#include "strmap.h" +#include +#if GIT_WIN32 +#include "win32/findfile.h" +#endif + +GIT__USE_STRMAP + +int git_futils_mkpath2file(const char *file_path, const mode_t mode) +{ + return git_futils_mkdir( + file_path, NULL, mode, + GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST | GIT_MKDIR_VERIFY_DIR); +} + +int git_futils_mktmp(git_buf *path_out, const char *filename, mode_t mode) +{ + int fd; + mode_t mask; + + p_umask(mask = p_umask(0)); + + git_buf_sets(path_out, filename); + git_buf_puts(path_out, "_git2_XXXXXX"); + + if (git_buf_oom(path_out)) + return -1; + + if ((fd = p_mkstemp(path_out->ptr)) < 0) { + giterr_set(GITERR_OS, + "Failed to create temporary file '%s'", path_out->ptr); + return -1; + } + + if (p_chmod(path_out->ptr, (mode & ~mask))) { + giterr_set(GITERR_OS, + "Failed to set permissions on file '%s'", path_out->ptr); + return -1; + } + + return fd; +} + +int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode_t mode) +{ + int fd; + + if (git_futils_mkpath2file(path, dirmode) < 0) + return -1; + + fd = p_creat(path, mode); + if (fd < 0) { + giterr_set(GITERR_OS, "Failed to create file '%s'", path); + return -1; + } + + return fd; +} + +int git_futils_creat_locked(const char *path, const mode_t mode) +{ + int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC | + O_EXCL | O_BINARY | O_CLOEXEC, mode); + + if (fd < 0) { + giterr_set(GITERR_OS, "Failed to create locked file '%s'", path); + return errno == EEXIST ? GIT_ELOCKED : -1; + } + + return fd; +} + +int git_futils_creat_locked_withpath(const char *path, const mode_t dirmode, const mode_t mode) +{ + if (git_futils_mkpath2file(path, dirmode) < 0) + return -1; + + return git_futils_creat_locked(path, mode); +} + +int git_futils_open_ro(const char *path) +{ + int fd = p_open(path, O_RDONLY); + if (fd < 0) + return git_path_set_error(errno, path, "open"); + return fd; +} + +git_off_t git_futils_filesize(git_file fd) +{ + struct stat sb; + + if (p_fstat(fd, &sb)) { + giterr_set(GITERR_OS, "Failed to stat file descriptor"); + return -1; + } + + return sb.st_size; +} + +mode_t git_futils_canonical_mode(mode_t raw_mode) +{ + if (S_ISREG(raw_mode)) + return S_IFREG | GIT_PERMS_CANONICAL(raw_mode); + else if (S_ISLNK(raw_mode)) + return S_IFLNK; + else if (S_ISGITLINK(raw_mode)) + return S_IFGITLINK; + else if (S_ISDIR(raw_mode)) + return S_IFDIR; + else + return 0; +} + +int git_futils_readbuffer_fd(git_buf *buf, git_file fd, size_t len) +{ + ssize_t read_size = 0; + size_t alloc_len; + + git_buf_clear(buf); + + if (!git__is_ssizet(len)) { + giterr_set(GITERR_INVALID, "Read too large."); + return -1; + } + + GITERR_CHECK_ALLOC_ADD(&alloc_len, len, 1); + if (git_buf_grow(buf, alloc_len) < 0) + return -1; + + /* p_read loops internally to read len bytes */ + read_size = p_read(fd, buf->ptr, len); + + if (read_size != (ssize_t)len) { + giterr_set(GITERR_OS, "Failed to read descriptor"); + git_buf_free(buf); + return -1; + } + + buf->ptr[read_size] = '\0'; + buf->size = read_size; + + return 0; +} + +int git_futils_readbuffer_updated( + git_buf *buf, const char *path, time_t *mtime, size_t *size, int *updated) +{ + git_file fd; + struct stat st; + bool changed = false; + + assert(buf && path && *path); + + if (updated != NULL) + *updated = 0; + + if (p_stat(path, &st) < 0) + return git_path_set_error(errno, path, "stat"); + + + if (S_ISDIR(st.st_mode)) { + giterr_set(GITERR_INVALID, "requested file is a directory"); + return GIT_ENOTFOUND; + } + + if (!git__is_sizet(st.st_size+1)) { + giterr_set(GITERR_OS, "Invalid regular file stat for '%s'", path); + return -1; + } + + /* + * If we were given a time and/or a size, we only want to read the file + * if it has been modified. + */ + if (size && *size != (size_t)st.st_size) + changed = true; + if (mtime && *mtime != (time_t)st.st_mtime) + changed = true; + if (!size && !mtime) + changed = true; + + if (!changed) { + return 0; + } + + if (mtime != NULL) + *mtime = st.st_mtime; + if (size != NULL) + *size = (size_t)st.st_size; + + if ((fd = git_futils_open_ro(path)) < 0) + return fd; + + if (git_futils_readbuffer_fd(buf, fd, (size_t)st.st_size) < 0) { + p_close(fd); + return -1; + } + + p_close(fd); + + if (updated != NULL) + *updated = 1; + + return 0; +} + +int git_futils_readbuffer(git_buf *buf, const char *path) +{ + return git_futils_readbuffer_updated(buf, path, NULL, NULL, NULL); +} + +int git_futils_writebuffer( + const git_buf *buf, const char *path, int flags, mode_t mode) +{ + int fd, error = 0; + + if (flags <= 0) + flags = O_CREAT | O_TRUNC | O_WRONLY; + if (!mode) + mode = GIT_FILEMODE_BLOB; + + if ((fd = p_open(path, flags, mode)) < 0) { + giterr_set(GITERR_OS, "Could not open '%s' for writing", path); + return fd; + } + + if ((error = p_write(fd, git_buf_cstr(buf), git_buf_len(buf))) < 0) { + giterr_set(GITERR_OS, "Could not write to '%s'", path); + (void)p_close(fd); + return error; + } + + if ((error = p_close(fd)) < 0) + giterr_set(GITERR_OS, "Error while closing '%s'", path); + + return error; +} + +int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmode) +{ + if (git_futils_mkpath2file(to, dirmode) < 0) + return -1; + + if (p_rename(from, to) < 0) { + giterr_set(GITERR_OS, "Failed to rename '%s' to '%s'", from, to); + return -1; + } + + return 0; +} + +int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len) +{ + return p_mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin); +} + +int git_futils_mmap_ro_file(git_map *out, const char *path) +{ + git_file fd = git_futils_open_ro(path); + git_off_t len; + int result; + + if (fd < 0) + return fd; + + len = git_futils_filesize(fd); + if (!git__is_sizet(len)) { + giterr_set(GITERR_OS, "File `%s` too large to mmap", path); + return -1; + } + + result = git_futils_mmap_ro(out, fd, 0, (size_t)len); + p_close(fd); + return result; +} + +void git_futils_mmap_free(git_map *out) +{ + p_munmap(out); +} + +GIT_INLINE(int) validate_existing( + const char *make_path, + struct stat *st, + mode_t mode, + uint32_t flags, + struct git_futils_mkdir_perfdata *perfdata) +{ + if ((S_ISREG(st->st_mode) && (flags & GIT_MKDIR_REMOVE_FILES)) || + (S_ISLNK(st->st_mode) && (flags & GIT_MKDIR_REMOVE_SYMLINKS))) { + if (p_unlink(make_path) < 0) { + giterr_set(GITERR_OS, "Failed to remove %s '%s'", + S_ISLNK(st->st_mode) ? "symlink" : "file", make_path); + return GIT_EEXISTS; + } + + perfdata->mkdir_calls++; + + if (p_mkdir(make_path, mode) < 0) { + giterr_set(GITERR_OS, "Failed to make directory '%s'", make_path); + return GIT_EEXISTS; + } + } + + else if (S_ISLNK(st->st_mode)) { + /* Re-stat the target, make sure it's a directory */ + perfdata->stat_calls++; + + if (p_stat(make_path, st) < 0) { + giterr_set(GITERR_OS, "Failed to make directory '%s'", make_path); + return GIT_EEXISTS; + } + } + + else if (!S_ISDIR(st->st_mode)) { + giterr_set(GITERR_FILESYSTEM, + "Failed to make directory '%s': directory exists", make_path); + return GIT_EEXISTS; + } + + return 0; +} + +int git_futils_mkdir_ext( + const char *path, + const char *base, + mode_t mode, + uint32_t flags, + struct git_futils_mkdir_options *opts) +{ + int error = -1; + git_buf make_path = GIT_BUF_INIT; + ssize_t root = 0, min_root_len, root_len; + char lastch = '/', *tail; + struct stat st; + + /* build path and find "root" where we should start calling mkdir */ + if (git_path_join_unrooted(&make_path, path, base, &root) < 0) + return -1; + + if (make_path.size == 0) { + giterr_set(GITERR_OS, "Attempt to create empty path"); + goto done; + } + + /* Trim trailing slashes (except the root) */ + if ((root_len = git_path_root(make_path.ptr)) < 0) + root_len = 0; + else + root_len++; + + while (make_path.size > (size_t)root_len && + make_path.ptr[make_path.size - 1] == '/') + make_path.ptr[--make_path.size] = '\0'; + + /* if we are not supposed to made the last element, truncate it */ + if ((flags & GIT_MKDIR_SKIP_LAST2) != 0) { + git_path_dirname_r(&make_path, make_path.ptr); + flags |= GIT_MKDIR_SKIP_LAST; + } + if ((flags & GIT_MKDIR_SKIP_LAST) != 0) { + git_path_dirname_r(&make_path, make_path.ptr); + } + + /* We were either given the root path (or trimmed it to + * the root), we don't have anything to do. + */ + if (make_path.size <= (size_t)root_len) { + error = 0; + goto done; + } + + /* if we are not supposed to make the whole path, reset root */ + if ((flags & GIT_MKDIR_PATH) == 0) + root = git_buf_rfind(&make_path, '/'); + + /* advance root past drive name or network mount prefix */ + min_root_len = git_path_root(make_path.ptr); + if (root < min_root_len) + root = min_root_len; + while (root >= 0 && make_path.ptr[root] == '/') + ++root; + + /* clip root to make_path length */ + if (root > (ssize_t)make_path.size) + root = (ssize_t)make_path.size; /* i.e. NUL byte of string */ + if (root < 0) + root = 0; + + /* walk down tail of path making each directory */ + for (tail = &make_path.ptr[root]; *tail; *tail = lastch) { + bool mkdir_attempted = false; + + /* advance tail to include next path component */ + while (*tail == '/') + tail++; + while (*tail && *tail != '/') + tail++; + + /* truncate path at next component */ + lastch = *tail; + *tail = '\0'; + st.st_mode = 0; + + if (opts->dir_map && git_strmap_exists(opts->dir_map, make_path.ptr)) + continue; + + /* See what's going on with this path component */ + opts->perfdata.stat_calls++; + +retry_lstat: + if (p_lstat(make_path.ptr, &st) < 0) { + if (mkdir_attempted || errno != ENOENT) { + giterr_set(GITERR_OS, "Cannot access component in path '%s'", make_path.ptr); + error = -1; + goto done; + } + + giterr_clear(); + opts->perfdata.mkdir_calls++; + mkdir_attempted = true; + if (p_mkdir(make_path.ptr, mode) < 0) { + if (errno == EEXIST) + goto retry_lstat; + giterr_set(GITERR_OS, "Failed to make directory '%s'", make_path.ptr); + error = -1; + goto done; + } + } else { + /* with exclusive create, existing dir is an error */ + if ((flags & GIT_MKDIR_EXCL) != 0) { + giterr_set(GITERR_FILESYSTEM, "Failed to make directory '%s': directory exists", make_path.ptr); + error = GIT_EEXISTS; + goto done; + } + + if ((error = validate_existing( + make_path.ptr, &st, mode, flags, &opts->perfdata)) < 0) + goto done; + } + + /* chmod if requested and necessary */ + if (((flags & GIT_MKDIR_CHMOD_PATH) != 0 || + (lastch == '\0' && (flags & GIT_MKDIR_CHMOD) != 0)) && + st.st_mode != mode) { + + opts->perfdata.chmod_calls++; + + if ((error = p_chmod(make_path.ptr, mode)) < 0 && + lastch == '\0') { + giterr_set(GITERR_OS, "Failed to set permissions on '%s'", + make_path.ptr); + goto done; + } + } + + if (opts->dir_map && opts->pool) { + char *cache_path; + size_t alloc_size; + + GITERR_CHECK_ALLOC_ADD(&alloc_size, make_path.size, 1); + if (!git__is_uint32(alloc_size)) + return -1; + cache_path = git_pool_malloc(opts->pool, (uint32_t)alloc_size); + GITERR_CHECK_ALLOC(cache_path); + + memcpy(cache_path, make_path.ptr, make_path.size + 1); + + git_strmap_insert(opts->dir_map, cache_path, cache_path, error); + if (error < 0) + goto done; + } + } + + error = 0; + + /* check that full path really is a directory if requested & needed */ + if ((flags & GIT_MKDIR_VERIFY_DIR) != 0 && + lastch != '\0') { + opts->perfdata.stat_calls++; + + if (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode)) { + giterr_set(GITERR_OS, "Path is not a directory '%s'", + make_path.ptr); + error = GIT_ENOTFOUND; + } + } + +done: + git_buf_free(&make_path); + return error; +} + +int git_futils_mkdir( + const char *path, + const char *base, + mode_t mode, + uint32_t flags) +{ + struct git_futils_mkdir_options options = {0}; + return git_futils_mkdir_ext(path, base, mode, flags, &options); +} + +int git_futils_mkdir_r(const char *path, const char *base, const mode_t mode) +{ + return git_futils_mkdir(path, base, mode, GIT_MKDIR_PATH); +} + +typedef struct { + const char *base; + size_t baselen; + uint32_t flags; + int depth; +} futils__rmdir_data; + +#define FUTILS_MAX_DEPTH 100 + +static int futils__error_cannot_rmdir(const char *path, const char *filemsg) +{ + if (filemsg) + giterr_set(GITERR_OS, "Could not remove directory. File '%s' %s", + path, filemsg); + else + giterr_set(GITERR_OS, "Could not remove directory '%s'", path); + + return -1; +} + +static int futils__rm_first_parent(git_buf *path, const char *ceiling) +{ + int error = GIT_ENOTFOUND; + struct stat st; + + while (error == GIT_ENOTFOUND) { + git_buf_rtruncate_at_char(path, '/'); + + if (!path->size || git__prefixcmp(path->ptr, ceiling) != 0) + error = 0; + else if (p_lstat_posixly(path->ptr, &st) == 0) { + if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) + error = p_unlink(path->ptr); + else if (!S_ISDIR(st.st_mode)) + error = -1; /* fail to remove non-regular file */ + } else if (errno != ENOTDIR) + error = -1; + } + + if (error) + futils__error_cannot_rmdir(path->ptr, "cannot remove parent"); + + return error; +} + +static int futils__rmdir_recurs_foreach(void *opaque, git_buf *path) +{ + int error = 0; + futils__rmdir_data *data = opaque; + struct stat st; + + if (data->depth > FUTILS_MAX_DEPTH) + error = futils__error_cannot_rmdir( + path->ptr, "directory nesting too deep"); + + else if ((error = p_lstat_posixly(path->ptr, &st)) < 0) { + if (errno == ENOENT) + error = 0; + else if (errno == ENOTDIR) { + /* asked to remove a/b/c/d/e and a/b is a normal file */ + if ((data->flags & GIT_RMDIR_REMOVE_BLOCKERS) != 0) + error = futils__rm_first_parent(path, data->base); + else + futils__error_cannot_rmdir( + path->ptr, "parent is not directory"); + } + else + error = git_path_set_error(errno, path->ptr, "rmdir"); + } + + else if (S_ISDIR(st.st_mode)) { + data->depth++; + + error = git_path_direach(path, 0, futils__rmdir_recurs_foreach, data); + + data->depth--; + + if (error < 0) + return error; + + if (data->depth == 0 && (data->flags & GIT_RMDIR_SKIP_ROOT) != 0) + return error; + + if ((error = p_rmdir(path->ptr)) < 0) { + if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) != 0 && + (errno == ENOTEMPTY || errno == EEXIST || errno == EBUSY)) + error = 0; + else + error = git_path_set_error(errno, path->ptr, "rmdir"); + } + } + + else if ((data->flags & GIT_RMDIR_REMOVE_FILES) != 0) { + if (p_unlink(path->ptr) < 0) + error = git_path_set_error(errno, path->ptr, "remove"); + } + + else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0) + error = futils__error_cannot_rmdir(path->ptr, "still present"); + + return error; +} + +static int futils__rmdir_empty_parent(void *opaque, const char *path) +{ + futils__rmdir_data *data = opaque; + int error = 0; + + if (strlen(path) <= data->baselen) + error = GIT_ITEROVER; + + else if (p_rmdir(path) < 0) { + int en = errno; + + if (en == ENOENT || en == ENOTDIR) { + /* do nothing */ + } else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) { + error = GIT_ITEROVER; + } else { + error = git_path_set_error(errno, path, "rmdir"); + } + } + + return error; +} + +int git_futils_rmdir_r( + const char *path, const char *base, uint32_t flags) +{ + int error; + git_buf fullpath = GIT_BUF_INIT; + futils__rmdir_data data; + + /* build path and find "root" where we should start calling mkdir */ + if (git_path_join_unrooted(&fullpath, path, base, NULL) < 0) + return -1; + + memset(&data, 0, sizeof(data)); + data.base = base ? base : ""; + data.baselen = base ? strlen(base) : 0; + data.flags = flags; + + error = futils__rmdir_recurs_foreach(&data, &fullpath); + + /* remove now-empty parents if requested */ + if (!error && (flags & GIT_RMDIR_EMPTY_PARENTS) != 0) + error = git_path_walk_up( + &fullpath, base, futils__rmdir_empty_parent, &data); + + if (error == GIT_ITEROVER) { + giterr_clear(); + error = 0; + } + + git_buf_free(&fullpath); + + return error; +} + +int git_futils_fake_symlink(const char *old, const char *new) +{ + int retcode = GIT_ERROR; + int fd = git_futils_creat_withpath(new, 0755, 0644); + if (fd >= 0) { + retcode = p_write(fd, old, strlen(old)); + p_close(fd); + } + return retcode; +} + +static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done) +{ + int error = 0; + char buffer[4096]; + ssize_t len = 0; + + while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0) + /* p_write() does not have the same semantics as write(). It loops + * internally and will return 0 when it has completed writing. + */ + error = p_write(ofd, buffer, len); + + if (len < 0) { + giterr_set(GITERR_OS, "Read error while copying file"); + error = (int)len; + } + + if (close_fd_when_done) { + p_close(ifd); + p_close(ofd); + } + + return error; +} + +int git_futils_cp(const char *from, const char *to, mode_t filemode) +{ + int ifd, ofd; + + if ((ifd = git_futils_open_ro(from)) < 0) + return ifd; + + if ((ofd = p_open(to, O_WRONLY | O_CREAT | O_EXCL, filemode)) < 0) { + p_close(ifd); + return git_path_set_error(errno, to, "open for writing"); + } + + return cp_by_fd(ifd, ofd, true); +} + +static int cp_link(const char *from, const char *to, size_t link_size) +{ + int error = 0; + ssize_t read_len; + char *link_data; + size_t alloc_size; + + GITERR_CHECK_ALLOC_ADD(&alloc_size, link_size, 1); + link_data = git__malloc(alloc_size); + GITERR_CHECK_ALLOC(link_data); + + read_len = p_readlink(from, link_data, link_size); + if (read_len != (ssize_t)link_size) { + giterr_set(GITERR_OS, "Failed to read symlink data for '%s'", from); + error = -1; + } + else { + link_data[read_len] = '\0'; + + if (p_symlink(link_data, to) < 0) { + giterr_set(GITERR_OS, "Could not symlink '%s' as '%s'", + link_data, to); + error = -1; + } + } + + git__free(link_data); + return error; +} + +typedef struct { + const char *to_root; + git_buf to; + ssize_t from_prefix; + uint32_t flags; + uint32_t mkdir_flags; + mode_t dirmode; +} cp_r_info; + +#define GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT (1u << 10) + +static int _cp_r_mkdir(cp_r_info *info, git_buf *from) +{ + int error = 0; + + /* create root directory the first time we need to create a directory */ + if ((info->flags & GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT) == 0) { + error = git_futils_mkdir( + info->to_root, NULL, info->dirmode, + (info->flags & GIT_CPDIR_CHMOD_DIRS) ? GIT_MKDIR_CHMOD : 0); + + info->flags |= GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT; + } + + /* create directory with root as base to prevent excess chmods */ + if (!error) + error = git_futils_mkdir( + from->ptr + info->from_prefix, info->to_root, + info->dirmode, info->mkdir_flags); + + return error; +} + +static int _cp_r_callback(void *ref, git_buf *from) +{ + int error = 0; + cp_r_info *info = ref; + struct stat from_st, to_st; + bool exists = false; + + if ((info->flags & GIT_CPDIR_COPY_DOTFILES) == 0 && + from->ptr[git_path_basename_offset(from)] == '.') + return 0; + + if ((error = git_buf_joinpath( + &info->to, info->to_root, from->ptr + info->from_prefix)) < 0) + return error; + + if (!(error = git_path_lstat(info->to.ptr, &to_st))) + exists = true; + else if (error != GIT_ENOTFOUND) + return error; + else { + giterr_clear(); + error = 0; + } + + if ((error = git_path_lstat(from->ptr, &from_st)) < 0) + return error; + + if (S_ISDIR(from_st.st_mode)) { + mode_t oldmode = info->dirmode; + + /* if we are not chmod'ing, then overwrite dirmode */ + if ((info->flags & GIT_CPDIR_CHMOD_DIRS) == 0) + info->dirmode = from_st.st_mode; + + /* make directory now if CREATE_EMPTY_DIRS is requested and needed */ + if (!exists && (info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) != 0) + error = _cp_r_mkdir(info, from); + + /* recurse onto target directory */ + if (!error && (!exists || S_ISDIR(to_st.st_mode))) + error = git_path_direach(from, 0, _cp_r_callback, info); + + if (oldmode != 0) + info->dirmode = oldmode; + + return error; + } + + if (exists) { + if ((info->flags & GIT_CPDIR_OVERWRITE) == 0) + return 0; + + if (p_unlink(info->to.ptr) < 0) { + giterr_set(GITERR_OS, "Cannot overwrite existing file '%s'", + info->to.ptr); + return GIT_EEXISTS; + } + } + + /* Done if this isn't a regular file or a symlink */ + if (!S_ISREG(from_st.st_mode) && + (!S_ISLNK(from_st.st_mode) || + (info->flags & GIT_CPDIR_COPY_SYMLINKS) == 0)) + return 0; + + /* Make container directory on demand if needed */ + if ((info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0 && + (error = _cp_r_mkdir(info, from)) < 0) + return error; + + /* make symlink or regular file */ + if (info->flags & GIT_CPDIR_LINK_FILES) { + error = p_link(from->ptr, info->to.ptr); + } else if (S_ISLNK(from_st.st_mode)) { + error = cp_link(from->ptr, info->to.ptr, (size_t)from_st.st_size); + } else { + mode_t usemode = from_st.st_mode; + + if ((info->flags & GIT_CPDIR_SIMPLE_TO_MODE) != 0) + usemode = GIT_PERMS_FOR_WRITE(usemode); + + error = git_futils_cp(from->ptr, info->to.ptr, usemode); + } + + return error; +} + +int git_futils_cp_r( + const char *from, + const char *to, + uint32_t flags, + mode_t dirmode) +{ + int error; + git_buf path = GIT_BUF_INIT; + cp_r_info info; + + if (git_buf_joinpath(&path, from, "") < 0) /* ensure trailing slash */ + return -1; + + memset(&info, 0, sizeof(info)); + info.to_root = to; + info.flags = flags; + info.dirmode = dirmode; + info.from_prefix = path.size; + git_buf_init(&info.to, 0); + + /* precalculate mkdir flags */ + if ((flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0) { + /* if not creating empty dirs, then use mkdir to create the path on + * demand right before files are copied. + */ + info.mkdir_flags = GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST; + if ((flags & GIT_CPDIR_CHMOD_DIRS) != 0) + info.mkdir_flags |= GIT_MKDIR_CHMOD_PATH; + } else { + /* otherwise, we will do simple mkdir as directories are encountered */ + info.mkdir_flags = + ((flags & GIT_CPDIR_CHMOD_DIRS) != 0) ? GIT_MKDIR_CHMOD : 0; + } + + error = _cp_r_callback(&info, &path); + + git_buf_free(&path); + git_buf_free(&info.to); + + return error; +} + +int git_futils_filestamp_check( + git_futils_filestamp *stamp, const char *path) +{ + struct stat st; + + /* if the stamp is NULL, then always reload */ + if (stamp == NULL) + return 1; + + if (p_stat(path, &st) < 0) + return GIT_ENOTFOUND; + + if (stamp->mtime == (git_time_t)st.st_mtime && + stamp->size == (git_off_t)st.st_size && + stamp->ino == (unsigned int)st.st_ino) + return 0; + + stamp->mtime = (git_time_t)st.st_mtime; + stamp->size = (git_off_t)st.st_size; + stamp->ino = (unsigned int)st.st_ino; + + return 1; +} + +void git_futils_filestamp_set( + git_futils_filestamp *target, const git_futils_filestamp *source) +{ + assert(target); + + if (source) + memcpy(target, source, sizeof(*target)); + else + memset(target, 0, sizeof(*target)); +} + + +void git_futils_filestamp_set_from_stat( + git_futils_filestamp *stamp, struct stat *st) +{ + if (st) { + stamp->mtime = (git_time_t)st->st_mtime; + stamp->size = (git_off_t)st->st_size; + stamp->ino = (unsigned int)st->st_ino; + } else { + memset(stamp, 0, sizeof(*stamp)); + } +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fileops.h b/deps/libgit2-sys-0.2.17/libgit2/src/fileops.h new file mode 100644 index 000000000..0f6466c59 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fileops.h @@ -0,0 +1,355 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_fileops_h__ +#define INCLUDE_fileops_h__ + +#include "common.h" +#include "map.h" +#include "posix.h" +#include "path.h" +#include "pool.h" +#include "strmap.h" + +/** + * Filebuffer methods + * + * Read whole files into an in-memory buffer for processing + */ +extern int git_futils_readbuffer(git_buf *obj, const char *path); +extern int git_futils_readbuffer_updated( + git_buf *obj, const char *path, time_t *mtime, size_t *size, int *updated); +extern int git_futils_readbuffer_fd(git_buf *obj, git_file fd, size_t len); + +extern int git_futils_writebuffer( + const git_buf *buf, const char *path, int open_flags, mode_t mode); + +/** + * File utils + * + * These are custom filesystem-related helper methods. They are + * rather high level, and wrap the underlying POSIX methods + * + * All these methods return 0 on success, + * or an error code on failure and an error message is set. + */ + +/** + * Create and open a file, while also + * creating all the folders in its path + */ +extern int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode_t mode); + +/** + * Create an open a process-locked file + */ +extern int git_futils_creat_locked(const char *path, const mode_t mode); + +/** + * Create an open a process-locked file, while + * also creating all the folders in its path + */ +extern int git_futils_creat_locked_withpath(const char *path, const mode_t dirmode, const mode_t mode); + +/** + * Create a path recursively + * + * If a base parameter is being passed, it's expected to be valued with a + * path pointing to an already existing directory. + */ +extern int git_futils_mkdir_r(const char *path, const char *base, const mode_t mode); + +/** + * Flags to pass to `git_futils_mkdir`. + * + * * GIT_MKDIR_EXCL is "exclusive" - i.e. generate an error if dir exists. + * * GIT_MKDIR_PATH says to make all components in the path. + * * GIT_MKDIR_CHMOD says to chmod the final directory entry after creation + * * GIT_MKDIR_CHMOD_PATH says to chmod each directory component in the path + * * GIT_MKDIR_SKIP_LAST says to leave off the last element of the path + * * GIT_MKDIR_SKIP_LAST2 says to leave off the last 2 elements of the path + * * GIT_MKDIR_VERIFY_DIR says confirm final item is a dir, not just EEXIST + * * GIT_MKDIR_REMOVE_FILES says to remove files and recreate dirs + * * GIT_MKDIR_REMOVE_SYMLINKS says to remove symlinks and recreate dirs + * + * Note that the chmod options will be executed even if the directory already + * exists, unless GIT_MKDIR_EXCL is given. + */ +typedef enum { + GIT_MKDIR_EXCL = 1, + GIT_MKDIR_PATH = 2, + GIT_MKDIR_CHMOD = 4, + GIT_MKDIR_CHMOD_PATH = 8, + GIT_MKDIR_SKIP_LAST = 16, + GIT_MKDIR_SKIP_LAST2 = 32, + GIT_MKDIR_VERIFY_DIR = 64, + GIT_MKDIR_REMOVE_FILES = 128, + GIT_MKDIR_REMOVE_SYMLINKS = 256, +} git_futils_mkdir_flags; + +struct git_futils_mkdir_perfdata +{ + size_t stat_calls; + size_t mkdir_calls; + size_t chmod_calls; +}; + +struct git_futils_mkdir_options +{ + git_strmap *dir_map; + git_pool *pool; + struct git_futils_mkdir_perfdata perfdata; +}; + +/** + * Create a directory or entire path. + * + * This makes a directory (and the entire path leading up to it if requested), + * and optionally chmods the directory immediately after (or each part of the + * path if requested). + * + * @param path The path to create. + * @param base Root for relative path. These directories will never be made. + * @param mode The mode to use for created directories. + * @param flags Combination of the mkdir flags above. + * @param opts Extended options, use `git_futils_mkdir` if you are not interested. + * @return 0 on success, else error code + */ +extern int git_futils_mkdir_ext(const char *path, const char *base, mode_t mode, uint32_t flags, struct git_futils_mkdir_options *opts); + +/** + * Create a directory or entire path. Similar to `git_futils_mkdir_withperf` + * without performance data. + */ +extern int git_futils_mkdir(const char *path, const char *base, mode_t mode, uint32_t flags); + +/** + * Create all the folders required to contain + * the full path of a file + */ +extern int git_futils_mkpath2file(const char *path, const mode_t mode); + +/** + * Flags to pass to `git_futils_rmdir_r`. + * + * * GIT_RMDIR_EMPTY_HIERARCHY - the default; remove hierarchy of empty + * dirs and generate error if any files are found. + * * GIT_RMDIR_REMOVE_FILES - attempt to remove files in the hierarchy. + * * GIT_RMDIR_SKIP_NONEMPTY - skip non-empty directories with no error. + * * GIT_RMDIR_EMPTY_PARENTS - remove containing directories up to base + * if removing this item leaves them empty + * * GIT_RMDIR_REMOVE_BLOCKERS - remove blocking file that causes ENOTDIR + * * GIT_RMDIR_SKIP_ROOT - don't remove root directory itself + */ +typedef enum { + GIT_RMDIR_EMPTY_HIERARCHY = 0, + GIT_RMDIR_REMOVE_FILES = (1 << 0), + GIT_RMDIR_SKIP_NONEMPTY = (1 << 1), + GIT_RMDIR_EMPTY_PARENTS = (1 << 2), + GIT_RMDIR_REMOVE_BLOCKERS = (1 << 3), + GIT_RMDIR_SKIP_ROOT = (1 << 4), +} git_futils_rmdir_flags; + +/** + * Remove path and any files and directories beneath it. + * + * @param path Path to the top level directory to process. + * @param base Root for relative path. + * @param flags Combination of git_futils_rmdir_flags values + * @return 0 on success; -1 on error. + */ +extern int git_futils_rmdir_r(const char *path, const char *base, uint32_t flags); + +/** + * Create and open a temporary file with a `_git2_` suffix. + * Writes the filename into path_out. + * @return On success, an open file descriptor, else an error code < 0. + */ +extern int git_futils_mktmp(git_buf *path_out, const char *filename, mode_t mode); + +/** + * Move a file on the filesystem, create the + * destination path if it doesn't exist + */ +extern int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmode); + +/** + * Copy a file + * + * The filemode will be used for the newly created file. + */ +extern int git_futils_cp( + const char *from, + const char *to, + mode_t filemode); + +/** + * Flags that can be passed to `git_futils_cp_r`. + * + * - GIT_CPDIR_CREATE_EMPTY_DIRS: create directories even if there are no + * files under them (otherwise directories will only be created lazily + * when a file inside them is copied). + * - GIT_CPDIR_COPY_SYMLINKS: copy symlinks, otherwise they are ignored. + * - GIT_CPDIR_COPY_DOTFILES: copy files with leading '.', otherwise ignored. + * - GIT_CPDIR_OVERWRITE: overwrite pre-existing files with source content, + * otherwise they are silently skipped. + * - GIT_CPDIR_CHMOD_DIRS: explicitly chmod directories to `dirmode` + * - GIT_CPDIR_SIMPLE_TO_MODE: default tries to replicate the mode of the + * source file to the target; with this flag, always use 0666 (or 0777 if + * source has exec bits set) for target. + * - GIT_CPDIR_LINK_FILES will try to use hardlinks for the files + */ +typedef enum { + GIT_CPDIR_CREATE_EMPTY_DIRS = (1u << 0), + GIT_CPDIR_COPY_SYMLINKS = (1u << 1), + GIT_CPDIR_COPY_DOTFILES = (1u << 2), + GIT_CPDIR_OVERWRITE = (1u << 3), + GIT_CPDIR_CHMOD_DIRS = (1u << 4), + GIT_CPDIR_SIMPLE_TO_MODE = (1u << 5), + GIT_CPDIR_LINK_FILES = (1u << 6), +} git_futils_cpdir_flags; + +/** + * Copy a directory tree. + * + * This copies directories and files from one root to another. You can + * pass a combinationof GIT_CPDIR flags as defined above. + * + * If you pass the CHMOD flag, then the dirmode will be applied to all + * directories that are created during the copy, overiding the natural + * permissions. If you do not pass the CHMOD flag, then the dirmode + * will actually be copied from the source files and the `dirmode` arg + * will be ignored. + */ +extern int git_futils_cp_r( + const char *from, + const char *to, + uint32_t flags, + mode_t dirmode); + +/** + * Open a file readonly and set error if needed. + */ +extern int git_futils_open_ro(const char *path); + +/** + * Get the filesize in bytes of a file + */ +extern git_off_t git_futils_filesize(git_file fd); + +#define GIT_PERMS_IS_EXEC(MODE) (((MODE) & 0111) != 0) +#define GIT_PERMS_CANONICAL(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0755 : 0644) +#define GIT_PERMS_FOR_WRITE(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0777 : 0666) + +#define GIT_MODE_PERMS_MASK 0777 +#define GIT_MODE_TYPE_MASK 0170000 +#define GIT_MODE_TYPE(MODE) ((MODE) & GIT_MODE_TYPE_MASK) +#define GIT_MODE_ISBLOB(MODE) (GIT_MODE_TYPE(MODE) == GIT_MODE_TYPE(GIT_FILEMODE_BLOB)) + +/** + * Convert a mode_t from the OS to a legal git mode_t value. + */ +extern mode_t git_futils_canonical_mode(mode_t raw_mode); + + +/** + * Read-only map all or part of a file into memory. + * When possible this function should favor a virtual memory + * style mapping over some form of malloc()+read(), as the + * data access will be random and is not likely to touch the + * majority of the region requested. + * + * @param out buffer to populate with the mapping information. + * @param fd open descriptor to configure the mapping from. + * @param begin first byte to map, this should be page aligned. + * @param len number of bytes to map. + * @return + * - 0 on success; + * - -1 on error. + */ +extern int git_futils_mmap_ro( + git_map *out, + git_file fd, + git_off_t begin, + size_t len); + +/** + * Read-only map an entire file. + * + * @param out buffer to populate with the mapping information. + * @param path path to file to be opened. + * @return + * - 0 on success; + * - GIT_ENOTFOUND if not found; + * - -1 on an unspecified OS related error. + */ +extern int git_futils_mmap_ro_file( + git_map *out, + const char *path); + +/** + * Release the memory associated with a previous memory mapping. + * @param map the mapping description previously configured. + */ +extern void git_futils_mmap_free(git_map *map); + +/** + * Create a "fake" symlink (text file containing the target path). + * + * @param new symlink file to be created + * @param old original symlink target + * @return 0 on success, -1 on error + */ +extern int git_futils_fake_symlink(const char *new, const char *old); + +/** + * A file stamp represents a snapshot of information about a file that can + * be used to test if the file changes. This portable implementation is + * based on stat data about that file, but it is possible that OS specific + * versions could be implemented in the future. + */ +typedef struct { + git_time_t mtime; + git_off_t size; + unsigned int ino; +} git_futils_filestamp; + +/** + * Compare stat information for file with reference info. + * + * This function updates the file stamp to current data for the given path + * and returns 0 if the file is up-to-date relative to the prior setting, + * 1 if the file has been changed, or GIT_ENOTFOUND if the file doesn't + * exist. This will not call giterr_set, so you must set the error if you + * plan to return an error. + * + * @param stamp File stamp to be checked + * @param path Path to stat and check if changed + * @return 0 if up-to-date, 1 if out-of-date, GIT_ENOTFOUND if cannot stat + */ +extern int git_futils_filestamp_check( + git_futils_filestamp *stamp, const char *path); + +/** + * Set or reset file stamp data + * + * This writes the target file stamp. If the source is NULL, this will set + * the target stamp to values that will definitely be out of date. If the + * source is not NULL, this copies the source values to the target. + * + * @param tgt File stamp to write to + * @param src File stamp to copy from or NULL to clear the target + */ +extern void git_futils_filestamp_set( + git_futils_filestamp *tgt, const git_futils_filestamp *src); + +/** + * Set file stamp data from stat structure + */ +extern void git_futils_filestamp_set_from_stat( + git_futils_filestamp *stamp, struct stat *st); + +#endif /* INCLUDE_fileops_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/filter.c b/deps/libgit2-sys-0.2.17/libgit2/src/filter.c new file mode 100644 index 000000000..8bd7f4d07 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/filter.c @@ -0,0 +1,957 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "fileops.h" +#include "hash.h" +#include "filter.h" +#include "repository.h" +#include "global.h" +#include "git2/sys/filter.h" +#include "git2/config.h" +#include "blob.h" +#include "attr_file.h" +#include "array.h" + +struct git_filter_source { + git_repository *repo; + const char *path; + git_oid oid; /* zero if unknown (which is likely) */ + uint16_t filemode; /* zero if unknown */ + git_filter_mode_t mode; + uint32_t flags; +}; + +typedef struct { + git_filter *filter; + void *payload; +} git_filter_entry; + +struct git_filter_list { + git_array_t(git_filter_entry) filters; + git_filter_source source; + git_buf *temp_buf; + char path[GIT_FLEX_ARRAY]; +}; + +typedef struct { + char *filter_name; + git_filter *filter; + int priority; + int initialized; + size_t nattrs, nmatches; + char *attrdata; + const char *attrs[GIT_FLEX_ARRAY]; +} git_filter_def; + +static int filter_def_priority_cmp(const void *a, const void *b) +{ + int pa = ((const git_filter_def *)a)->priority; + int pb = ((const git_filter_def *)b)->priority; + return (pa < pb) ? -1 : (pa > pb) ? 1 : 0; +} + +struct filter_registry { + git_vector filters; +}; + +static struct filter_registry *git__filter_registry = NULL; + +static void filter_registry_shutdown(void) +{ + struct filter_registry *reg = NULL; + size_t pos; + git_filter_def *fdef; + + if ((reg = git__swap(git__filter_registry, NULL)) == NULL) + return; + + git_vector_foreach(®->filters, pos, fdef) { + if (fdef->filter && fdef->filter->shutdown) { + fdef->filter->shutdown(fdef->filter); + fdef->initialized = false; + } + + git__free(fdef->filter_name); + git__free(fdef->attrdata); + git__free(fdef); + } + + git_vector_free(®->filters); + git__free(reg); +} + +static int filter_registry_initialize(void) +{ + int error = 0; + struct filter_registry *reg; + + if (git__filter_registry) + return 0; + + reg = git__calloc(1, sizeof(struct filter_registry)); + GITERR_CHECK_ALLOC(reg); + + if ((error = git_vector_init( + ®->filters, 2, filter_def_priority_cmp)) < 0) + goto cleanup; + + reg = git__compare_and_swap(&git__filter_registry, NULL, reg); + if (reg != NULL) + goto cleanup; + + git__on_shutdown(filter_registry_shutdown); + + /* try to register both default filters */ + { + git_filter *crlf = git_crlf_filter_new(); + git_filter *ident = git_ident_filter_new(); + + if (crlf && git_filter_register( + GIT_FILTER_CRLF, crlf, GIT_FILTER_CRLF_PRIORITY) < 0) + crlf = NULL; + if (ident && git_filter_register( + GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0) + ident = NULL; + + if (!crlf || !ident) + return -1; + } + + return 0; + +cleanup: + git_vector_free(®->filters); + git__free(reg); + return error; +} + +static int filter_def_scan_attrs( + git_buf *attrs, size_t *nattr, size_t *nmatch, const char *attr_str) +{ + const char *start, *scan = attr_str; + int has_eq; + + *nattr = *nmatch = 0; + + if (!scan) + return 0; + + while (*scan) { + while (git__isspace(*scan)) scan++; + + for (start = scan, has_eq = 0; *scan && !git__isspace(*scan); ++scan) { + if (*scan == '=') + has_eq = 1; + } + + if (scan > start) { + (*nattr)++; + if (has_eq || *start == '-' || *start == '+' || *start == '!') + (*nmatch)++; + + if (has_eq) + git_buf_putc(attrs, '='); + git_buf_put(attrs, start, scan - start); + git_buf_putc(attrs, '\0'); + } + } + + return 0; +} + +static void filter_def_set_attrs(git_filter_def *fdef) +{ + char *scan = fdef->attrdata; + size_t i; + + for (i = 0; i < fdef->nattrs; ++i) { + const char *name, *value; + + switch (*scan) { + case '=': + name = scan + 1; + for (scan++; *scan != '='; scan++) /* find '=' */; + *scan++ = '\0'; + value = scan; + break; + case '-': + name = scan + 1; value = git_attr__false; break; + case '+': + name = scan + 1; value = git_attr__true; break; + case '!': + name = scan + 1; value = git_attr__unset; break; + default: + name = scan; value = NULL; break; + } + + fdef->attrs[i] = name; + fdef->attrs[i + fdef->nattrs] = value; + + scan += strlen(scan) + 1; + } +} + +static int filter_def_name_key_check(const void *key, const void *fdef) +{ + const char *name = + fdef ? ((const git_filter_def *)fdef)->filter_name : NULL; + return name ? git__strcmp(key, name) : -1; +} + +static int filter_def_filter_key_check(const void *key, const void *fdef) +{ + const void *filter = fdef ? ((const git_filter_def *)fdef)->filter : NULL; + return (key == filter) ? 0 : -1; +} + +static int filter_registry_find(size_t *pos, const char *name) +{ + return git_vector_search2( + pos, &git__filter_registry->filters, filter_def_name_key_check, name); +} + +static git_filter_def *filter_registry_lookup(size_t *pos, const char *name) +{ + git_filter_def *fdef = NULL; + + if (!filter_registry_find(pos, name)) + fdef = git_vector_get(&git__filter_registry->filters, *pos); + + return fdef; +} + +int git_filter_register( + const char *name, git_filter *filter, int priority) +{ + git_filter_def *fdef; + size_t nattr = 0, nmatch = 0, alloc_len; + git_buf attrs = GIT_BUF_INIT; + + assert(name && filter); + + if (filter_registry_initialize() < 0) + return -1; + + if (!filter_registry_find(NULL, name)) { + giterr_set( + GITERR_FILTER, "Attempt to reregister existing filter '%s'", name); + return GIT_EEXISTS; + } + + if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0) + return -1; + + GITERR_CHECK_ALLOC_MULTIPLY(&alloc_len, nattr, 2); + GITERR_CHECK_ALLOC_MULTIPLY(&alloc_len, alloc_len, sizeof(char *)); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, sizeof(git_filter_def)); + + fdef = git__calloc(1, alloc_len); + GITERR_CHECK_ALLOC(fdef); + + fdef->filter_name = git__strdup(name); + GITERR_CHECK_ALLOC(fdef->filter_name); + + fdef->filter = filter; + fdef->priority = priority; + fdef->nattrs = nattr; + fdef->nmatches = nmatch; + fdef->attrdata = git_buf_detach(&attrs); + + filter_def_set_attrs(fdef); + + if (git_vector_insert(&git__filter_registry->filters, fdef) < 0) { + git__free(fdef->filter_name); + git__free(fdef->attrdata); + git__free(fdef); + return -1; + } + + git_vector_sort(&git__filter_registry->filters); + return 0; +} + +int git_filter_unregister(const char *name) +{ + size_t pos; + git_filter_def *fdef; + + assert(name); + + /* cannot unregister default filters */ + if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) { + giterr_set(GITERR_FILTER, "Cannot unregister filter '%s'", name); + return -1; + } + + if ((fdef = filter_registry_lookup(&pos, name)) == NULL) { + giterr_set(GITERR_FILTER, "Cannot find filter '%s' to unregister", name); + return GIT_ENOTFOUND; + } + + (void)git_vector_remove(&git__filter_registry->filters, pos); + + if (fdef->initialized && fdef->filter && fdef->filter->shutdown) { + fdef->filter->shutdown(fdef->filter); + fdef->initialized = false; + } + + git__free(fdef->filter_name); + git__free(fdef->attrdata); + git__free(fdef); + + return 0; +} + +static int filter_initialize(git_filter_def *fdef) +{ + int error = 0; + + if (!fdef->initialized && + fdef->filter && + fdef->filter->initialize && + (error = fdef->filter->initialize(fdef->filter)) < 0) + { + /* auto-unregister if initialize fails */ + git_filter_unregister(fdef->filter_name); + return error; + } + + fdef->initialized = true; + return 0; +} + +git_filter *git_filter_lookup(const char *name) +{ + size_t pos; + git_filter_def *fdef; + + if (filter_registry_initialize() < 0) + return NULL; + + if ((fdef = filter_registry_lookup(&pos, name)) == NULL) + return NULL; + + if (!fdef->initialized && filter_initialize(fdef) < 0) + return NULL; + + return fdef->filter; +} + +void git_filter_free(git_filter *filter) +{ + git__free(filter); +} + +git_repository *git_filter_source_repo(const git_filter_source *src) +{ + return src->repo; +} + +const char *git_filter_source_path(const git_filter_source *src) +{ + return src->path; +} + +uint16_t git_filter_source_filemode(const git_filter_source *src) +{ + return src->filemode; +} + +const git_oid *git_filter_source_id(const git_filter_source *src) +{ + return git_oid_iszero(&src->oid) ? NULL : &src->oid; +} + +git_filter_mode_t git_filter_source_mode(const git_filter_source *src) +{ + return src->mode; +} + +uint32_t git_filter_source_flags(const git_filter_source *src) +{ + return src->flags; +} + +static int filter_list_new( + git_filter_list **out, const git_filter_source *src) +{ + git_filter_list *fl = NULL; + size_t pathlen = src->path ? strlen(src->path) : 0, alloclen; + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + + fl = git__calloc(1, alloclen); + GITERR_CHECK_ALLOC(fl); + + if (src->path) + memcpy(fl->path, src->path, pathlen); + fl->source.repo = src->repo; + fl->source.path = fl->path; + fl->source.mode = src->mode; + fl->source.flags = src->flags; + + *out = fl; + return 0; +} + +static int filter_list_check_attributes( + const char ***out, + git_repository *repo, + git_attr_session *attr_session, + git_filter_def *fdef, + const git_filter_source *src) +{ + int error; + size_t i; + const char **strs = git__calloc(fdef->nattrs, sizeof(const char *)); + GITERR_CHECK_ALLOC(strs); + + error = git_attr_get_many_with_session( + strs, repo, attr_session, 0, src->path, fdef->nattrs, fdef->attrs); + + /* if no values were found but no matches are needed, it's okay! */ + if (error == GIT_ENOTFOUND && !fdef->nmatches) { + giterr_clear(); + git__free((void *)strs); + return 0; + } + + for (i = 0; !error && i < fdef->nattrs; ++i) { + const char *want = fdef->attrs[fdef->nattrs + i]; + git_attr_t want_type, found_type; + + if (!want) + continue; + + want_type = git_attr_value(want); + found_type = git_attr_value(strs[i]); + + if (want_type != found_type || + (want_type == GIT_ATTR_VALUE_T && strcmp(want, strs[i]))) + error = GIT_ENOTFOUND; + } + + if (error) + git__free((void *)strs); + else + *out = strs; + + return error; +} + +int git_filter_list_new( + git_filter_list **out, + git_repository *repo, + git_filter_mode_t mode, + uint32_t flags) +{ + git_filter_source src = { 0 }; + src.repo = repo; + src.path = NULL; + src.mode = mode; + src.flags = flags; + return filter_list_new(out, &src); +} + +int git_filter_list__load_ext( + git_filter_list **filters, + git_repository *repo, + git_blob *blob, /* can be NULL */ + const char *path, + git_filter_mode_t mode, + git_filter_options *filter_opts) +{ + int error = 0; + git_filter_list *fl = NULL; + git_filter_source src = { 0 }; + git_filter_entry *fe; + size_t idx; + git_filter_def *fdef; + + if (filter_registry_initialize() < 0) + return -1; + + src.repo = repo; + src.path = path; + src.mode = mode; + src.flags = filter_opts->flags; + + if (blob) + git_oid_cpy(&src.oid, git_blob_id(blob)); + + git_vector_foreach(&git__filter_registry->filters, idx, fdef) { + const char **values = NULL; + void *payload = NULL; + + if (!fdef || !fdef->filter) + continue; + + if (fdef->nattrs > 0) { + error = filter_list_check_attributes( + &values, repo, filter_opts->attr_session, fdef, &src); + + if (error == GIT_ENOTFOUND) { + error = 0; + continue; + } else if (error < 0) + break; + } + + if (!fdef->initialized && (error = filter_initialize(fdef)) < 0) + break; + + if (fdef->filter->check) + error = fdef->filter->check( + fdef->filter, &payload, &src, values); + + git__free((void *)values); + + if (error == GIT_PASSTHROUGH) + error = 0; + else if (error < 0) + break; + else { + if (!fl) { + if ((error = filter_list_new(&fl, &src)) < 0) + return error; + + fl->temp_buf = filter_opts->temp_buf; + } + + fe = git_array_alloc(fl->filters); + GITERR_CHECK_ALLOC(fe); + fe->filter = fdef->filter; + fe->payload = payload; + } + } + + if (error && fl != NULL) { + git_array_clear(fl->filters); + git__free(fl); + fl = NULL; + } + + *filters = fl; + return error; +} + +int git_filter_list_load( + git_filter_list **filters, + git_repository *repo, + git_blob *blob, /* can be NULL */ + const char *path, + git_filter_mode_t mode, + uint32_t flags) +{ + git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; + + filter_opts.flags = flags; + + return git_filter_list__load_ext( + filters, repo, blob, path, mode, &filter_opts); +} + +void git_filter_list_free(git_filter_list *fl) +{ + uint32_t i; + + if (!fl) + return; + + for (i = 0; i < git_array_size(fl->filters); ++i) { + git_filter_entry *fe = git_array_get(fl->filters, i); + if (fe->filter->cleanup) + fe->filter->cleanup(fe->filter, fe->payload); + } + + git_array_clear(fl->filters); + git__free(fl); +} + +int git_filter_list_push( + git_filter_list *fl, git_filter *filter, void *payload) +{ + int error = 0; + size_t pos; + git_filter_def *fdef; + git_filter_entry *fe; + + assert(fl && filter); + + if (git_vector_search2( + &pos, &git__filter_registry->filters, + filter_def_filter_key_check, filter) < 0) { + giterr_set(GITERR_FILTER, "Cannot use an unregistered filter"); + return -1; + } + + fdef = git_vector_get(&git__filter_registry->filters, pos); + + if (!fdef->initialized && (error = filter_initialize(fdef)) < 0) + return error; + + fe = git_array_alloc(fl->filters); + GITERR_CHECK_ALLOC(fe); + fe->filter = filter; + fe->payload = payload; + + return 0; +} + +size_t git_filter_list_length(const git_filter_list *fl) +{ + return fl ? git_array_size(fl->filters) : 0; +} + +struct buf_stream { + git_writestream parent; + git_buf *target; + bool complete; +}; + +static int buf_stream_write( + git_writestream *s, const char *buffer, size_t len) +{ + struct buf_stream *buf_stream = (struct buf_stream *)s; + assert(buf_stream); + + assert(buf_stream->complete == 0); + + return git_buf_put(buf_stream->target, buffer, len); +} + +static int buf_stream_close(git_writestream *s) +{ + struct buf_stream *buf_stream = (struct buf_stream *)s; + assert(buf_stream); + + assert(buf_stream->complete == 0); + buf_stream->complete = 1; + + return 0; +} + +static void buf_stream_free(git_writestream *s) +{ + GIT_UNUSED(s); +} + +static void buf_stream_init(struct buf_stream *writer, git_buf *target) +{ + memset(writer, 0, sizeof(struct buf_stream)); + + writer->parent.write = buf_stream_write; + writer->parent.close = buf_stream_close; + writer->parent.free = buf_stream_free; + writer->target = target; + + git_buf_clear(target); +} + +int git_filter_list_apply_to_data( + git_buf *tgt, git_filter_list *filters, git_buf *src) +{ + struct buf_stream writer; + int error; + + git_buf_sanitize(tgt); + git_buf_sanitize(src); + + if (!filters) { + git_buf_attach_notowned(tgt, src->ptr, src->size); + return 0; + } + + buf_stream_init(&writer, tgt); + + if ((error = git_filter_list_stream_data(filters, src, + (git_writestream *)&writer)) < 0) + return error; + + assert(writer.complete); + return error; +} + +int git_filter_list_apply_to_file( + git_buf *out, + git_filter_list *filters, + git_repository *repo, + const char *path) +{ + struct buf_stream writer; + int error; + + buf_stream_init(&writer, out); + + if ((error = git_filter_list_stream_file( + filters, repo, path, (git_writestream *)&writer)) < 0) + return error; + + assert(writer.complete); + return error; +} + +static int buf_from_blob(git_buf *out, git_blob *blob) +{ + git_off_t rawsize = git_blob_rawsize(blob); + + if (!git__is_sizet(rawsize)) { + giterr_set(GITERR_OS, "Blob is too large to filter"); + return -1; + } + + git_buf_attach_notowned(out, git_blob_rawcontent(blob), (size_t)rawsize); + return 0; +} + +int git_filter_list_apply_to_blob( + git_buf *out, + git_filter_list *filters, + git_blob *blob) +{ + struct buf_stream writer; + int error; + + buf_stream_init(&writer, out); + + if ((error = git_filter_list_stream_blob( + filters, blob, (git_writestream *)&writer)) < 0) + return error; + + assert(writer.complete); + return error; +} + +struct proxy_stream { + git_writestream parent; + git_filter *filter; + const git_filter_source *source; + void **payload; + git_buf input; + git_buf temp_buf; + git_buf *output; + git_writestream *target; +}; + +static int proxy_stream_write( + git_writestream *s, const char *buffer, size_t len) +{ + struct proxy_stream *proxy_stream = (struct proxy_stream *)s; + assert(proxy_stream); + + return git_buf_put(&proxy_stream->input, buffer, len); +} + +static int proxy_stream_close(git_writestream *s) +{ + struct proxy_stream *proxy_stream = (struct proxy_stream *)s; + git_buf *writebuf; + int error; + + assert(proxy_stream); + + error = proxy_stream->filter->apply( + proxy_stream->filter, + proxy_stream->payload, + proxy_stream->output, + &proxy_stream->input, + proxy_stream->source); + + if (error == GIT_PASSTHROUGH) { + writebuf = &proxy_stream->input; + } else if (error == 0) { + git_buf_sanitize(proxy_stream->output); + writebuf = proxy_stream->output; + } else { + return error; + } + + if ((error = proxy_stream->target->write( + proxy_stream->target, writebuf->ptr, writebuf->size)) == 0) + error = proxy_stream->target->close(proxy_stream->target); + + return error; +} + +static void proxy_stream_free(git_writestream *s) +{ + struct proxy_stream *proxy_stream = (struct proxy_stream *)s; + assert(proxy_stream); + + git_buf_free(&proxy_stream->input); + git_buf_free(&proxy_stream->temp_buf); + git__free(proxy_stream); +} + +static int proxy_stream_init( + git_writestream **out, + git_filter *filter, + git_buf *temp_buf, + void **payload, + const git_filter_source *source, + git_writestream *target) +{ + struct proxy_stream *proxy_stream = git__calloc(1, sizeof(struct proxy_stream)); + GITERR_CHECK_ALLOC(proxy_stream); + + proxy_stream->parent.write = proxy_stream_write; + proxy_stream->parent.close = proxy_stream_close; + proxy_stream->parent.free = proxy_stream_free; + proxy_stream->filter = filter; + proxy_stream->payload = payload; + proxy_stream->source = source; + proxy_stream->target = target; + proxy_stream->output = temp_buf ? temp_buf : &proxy_stream->temp_buf; + + if (temp_buf) + git_buf_clear(temp_buf); + + *out = (git_writestream *)proxy_stream; + return 0; +} + +static int stream_list_init( + git_writestream **out, + git_vector *streams, + git_filter_list *filters, + git_writestream *target) +{ + git_writestream *last_stream = target; + size_t i; + int error = 0; + + *out = NULL; + + if (!filters) { + *out = target; + return 0; + } + + /* Create filters last to first to get the chaining direction */ + for (i = 0; i < git_array_size(filters->filters); ++i) { + size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ? + git_array_size(filters->filters) - 1 - i : i; + git_filter_entry *fe = git_array_get(filters->filters, filter_idx); + git_writestream *filter_stream; + + assert(fe->filter->stream || fe->filter->apply); + + /* If necessary, create a stream that proxies the traditional + * application. + */ + if (fe->filter->stream) + error = fe->filter->stream(&filter_stream, fe->filter, + &fe->payload, &filters->source, last_stream); + else + /* Create a stream that proxies the one-shot apply */ + error = proxy_stream_init(&filter_stream, fe->filter, + filters->temp_buf, &fe->payload, &filters->source, + last_stream); + + if (error < 0) + return error; + + git_vector_insert(streams, filter_stream); + last_stream = filter_stream; + } + + *out = last_stream; + return 0; +} + +void stream_list_free(git_vector *streams) +{ + git_writestream *stream; + size_t i; + + git_vector_foreach(streams, i, stream) + stream->free(stream); + git_vector_free(streams); +} + +#define STREAM_BUFSIZE 10240 + +int git_filter_list_stream_file( + git_filter_list *filters, + git_repository *repo, + const char *path, + git_writestream *target) +{ + char buf[STREAM_BUFSIZE]; + git_buf abspath = GIT_BUF_INIT; + const char *base = repo ? git_repository_workdir(repo) : NULL; + git_vector filter_streams = GIT_VECTOR_INIT; + git_writestream *stream_start; + ssize_t readlen; + int fd, error; + + if ((error = stream_list_init( + &stream_start, &filter_streams, filters, target)) < 0 || + (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0) + goto done; + + if ((fd = git_futils_open_ro(abspath.ptr)) < 0) { + error = fd; + goto done; + } + + while ((readlen = p_read(fd, buf, STREAM_BUFSIZE)) > 0) { + if ((error = stream_start->write(stream_start, buf, readlen)) < 0) + goto done; + } + + if (!readlen) + error = stream_start->close(stream_start); + else if (readlen < 0) + error = readlen; + + p_close(fd); + +done: + stream_list_free(&filter_streams); + git_buf_free(&abspath); + return error; +} + +int git_filter_list_stream_data( + git_filter_list *filters, + git_buf *data, + git_writestream *target) +{ + git_vector filter_streams = GIT_VECTOR_INIT; + git_writestream *stream_start; + int error = 0; + + git_buf_sanitize(data); + + if ((error = stream_list_init( + &stream_start, &filter_streams, filters, target)) == 0 && + (error = + stream_start->write(stream_start, data->ptr, data->size)) == 0) + error = stream_start->close(stream_start); + + stream_list_free(&filter_streams); + return error; +} + +int git_filter_list_stream_blob( + git_filter_list *filters, + git_blob *blob, + git_writestream *target) +{ + git_buf in = GIT_BUF_INIT; + + if (buf_from_blob(&in, blob) < 0) + return -1; + + if (filters) + git_oid_cpy(&filters->source.oid, git_blob_id(blob)); + + return git_filter_list_stream_data(filters, &in, target); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/filter.h b/deps/libgit2-sys-0.2.17/libgit2/src/filter.h new file mode 100644 index 000000000..5062afba5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/filter.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_filter_h__ +#define INCLUDE_filter_h__ + +#include "common.h" +#include "attr_file.h" +#include "git2/filter.h" + +/* Amount of file to examine for NUL byte when checking binary-ness */ +#define GIT_FILTER_BYTES_TO_CHECK_NUL 8000 + +/* Possible CRLF values */ +typedef enum { + GIT_CRLF_GUESS = -1, + GIT_CRLF_BINARY = 0, + GIT_CRLF_TEXT, + GIT_CRLF_INPUT, + GIT_CRLF_CRLF, + GIT_CRLF_AUTO, +} git_crlf_t; + +typedef struct { + git_attr_session *attr_session; + git_buf *temp_buf; + uint32_t flags; +} git_filter_options; + +#define GIT_FILTER_OPTIONS_INIT {0} + +extern void git_filter_free(git_filter *filter); + +extern int git_filter_list__load_ext( + git_filter_list **filters, + git_repository *repo, + git_blob *blob, /* can be NULL */ + const char *path, + git_filter_mode_t mode, + git_filter_options *filter_opts); + +/* + * Available filters + */ + +extern git_filter *git_crlf_filter_new(void); +extern git_filter *git_ident_filter_new(void); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.c b/deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.c new file mode 100644 index 000000000..d7899e3e6 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.c @@ -0,0 +1,235 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +/* + * This file contains code originally derrived from OpenBSD fnmatch.c + * + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. + * Compares a filename or pathname to a pattern. + */ + +#include +#include +#include + +#include "fnmatch.h" + +#define EOS '\0' + +#define RANGE_MATCH 1 +#define RANGE_NOMATCH 0 +#define RANGE_ERROR (-1) + +static int rangematch(const char *, char, int, char **); + +static int +p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs) +{ + const char *stringstart; + char *newp; + char c, test; + int recurs_flags = flags & ~FNM_PERIOD; + + if (recurs-- == 0) + return FNM_NORES; + + for (stringstart = string;;) + switch (c = *pattern++) { + case EOS: + if ((flags & FNM_LEADING_DIR) && *string == '/') + return (0); + return (*string == EOS ? 0 : FNM_NOMATCH); + case '?': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + ++string; + break; + case '*': + c = *pattern; + + /* Let '**' override PATHNAME match for this segment. + * It will be restored if/when we recurse below. + */ + if (c == '*') { + flags &= ~FNM_PATHNAME; + while (c == '*') + c = *++pattern; + if (c == '/') + c = *++pattern; + } + + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + /* Optimize for pattern with * at end or before /. */ + if (c == EOS) { + if (flags & FNM_PATHNAME) + return ((flags & FNM_LEADING_DIR) || + strchr(string, '/') == NULL ? + 0 : FNM_NOMATCH); + else + return (0); + } else if (c == '/' && (flags & FNM_PATHNAME)) { + if ((string = strchr(string, '/')) == NULL) + return (FNM_NOMATCH); + break; + } + + /* General case, use recursion. */ + while ((test = *string) != EOS) { + int e; + + e = p_fnmatchx(pattern, string, recurs_flags, recurs); + if (e != FNM_NOMATCH) + return e; + if (test == '/' && (flags & FNM_PATHNAME)) + break; + ++string; + } + return (FNM_NOMATCH); + case '[': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + switch (rangematch(pattern, *string, flags, &newp)) { + case RANGE_ERROR: + /* not a good range, treat as normal text */ + goto normal; + case RANGE_MATCH: + pattern = newp; + break; + case RANGE_NOMATCH: + return (FNM_NOMATCH); + } + ++string; + break; + case '\\': + if (!(flags & FNM_NOESCAPE)) { + if ((c = *pattern++) == EOS) { + c = '\\'; + --pattern; + } + } + /* FALLTHROUGH */ + default: + normal: + if (c != *string && !((flags & FNM_CASEFOLD) && + (tolower((unsigned char)c) == + tolower((unsigned char)*string)))) + return (FNM_NOMATCH); + ++string; + break; + } + /* NOTREACHED */ +} + +static int +rangematch(const char *pattern, char test, int flags, char **newp) +{ + int negate, ok; + char c, c2; + + /* + * A bracket expression starting with an unquoted circumflex + * character produces unspecified results (IEEE 1003.2-1992, + * 3.13.2). This implementation treats it like '!', for + * consistency with the regular expression syntax. + * J.T. Conklin (conklin@ngai.kaleida.com) + */ + if ((negate = (*pattern == '!' || *pattern == '^')) != 0) + ++pattern; + + if (flags & FNM_CASEFOLD) + test = (char)tolower((unsigned char)test); + + /* + * A right bracket shall lose its special meaning and represent + * itself in a bracket expression if it occurs first in the list. + * -- POSIX.2 2.8.3.2 + */ + ok = 0; + c = *pattern++; + do { + if (c == '\\' && !(flags & FNM_NOESCAPE)) + c = *pattern++; + if (c == EOS) + return (RANGE_ERROR); + if (c == '/' && (flags & FNM_PATHNAME)) + return (RANGE_NOMATCH); + if ((flags & FNM_CASEFOLD)) + c = (char)tolower((unsigned char)c); + if (*pattern == '-' + && (c2 = *(pattern+1)) != EOS && c2 != ']') { + pattern += 2; + if (c2 == '\\' && !(flags & FNM_NOESCAPE)) + c2 = *pattern++; + if (c2 == EOS) + return (RANGE_ERROR); + if (flags & FNM_CASEFOLD) + c2 = (char)tolower((unsigned char)c2); + if (c <= test && test <= c2) + ok = 1; + } else if (c == test) + ok = 1; + } while ((c = *pattern++) != ']'); + + *newp = (char *)pattern; + return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); +} + +int +p_fnmatch(const char *pattern, const char *string, int flags) +{ + return p_fnmatchx(pattern, string, flags, 64); +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.h b/deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.h new file mode 100644 index 000000000..88af45939 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/fnmatch.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef INCLUDE_fnmatch__compat_h__ +#define INCLUDE_fnmatch__compat_h__ + +#include "common.h" + +#define FNM_NOMATCH 1 /* Match failed. */ +#define FNM_NOSYS 2 /* Function not supported (unused). */ +#define FNM_NORES 3 /* Out of resources */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ +#define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ +#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ + +#define FNM_IGNORECASE FNM_CASEFOLD +#define FNM_FILE_NAME FNM_PATHNAME + +extern int p_fnmatch(const char *pattern, const char *string, int flags); + +#endif /* _FNMATCH_H */ + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/global.c b/deps/libgit2-sys-0.2.17/libgit2/src/global.c new file mode 100644 index 000000000..1f3432d09 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/global.c @@ -0,0 +1,401 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "global.h" +#include "hash.h" +#include "sysdir.h" +#include "git2/global.h" +#include "git2/sys/openssl.h" +#include "thread-utils.h" + + +git_mutex git__mwindow_mutex; + +#define MAX_SHUTDOWN_CB 8 + +#ifdef GIT_SSL +# include +SSL_CTX *git__ssl_ctx; +# ifdef GIT_THREADS +static git_mutex *openssl_locks; +# endif +#endif + +static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB]; +static git_atomic git__n_shutdown_callbacks; +static git_atomic git__n_inits; + +void git__on_shutdown(git_global_shutdown_fn callback) +{ + int count = git_atomic_inc(&git__n_shutdown_callbacks); + assert(count <= MAX_SHUTDOWN_CB && count > 0); + git__shutdown_callbacks[count - 1] = callback; +} + +static void git__global_state_cleanup(git_global_st *st) +{ + if (!st) + return; + + git__free(st->error_t.message); + st->error_t.message = NULL; +} + +static void git__shutdown(void) +{ + int pos; + + /* Shutdown subsystems that have registered */ + for (pos = git_atomic_get(&git__n_shutdown_callbacks); pos > 0; pos = git_atomic_dec(&git__n_shutdown_callbacks)) { + git_global_shutdown_fn cb = git__swap(git__shutdown_callbacks[pos - 1], NULL); + if (cb != NULL) + cb(); + } +} + +#if defined(GIT_THREADS) && defined(GIT_SSL) +void openssl_locking_function(int mode, int n, const char *file, int line) +{ + int lock; + + GIT_UNUSED(file); + GIT_UNUSED(line); + + lock = mode & CRYPTO_LOCK; + + if (lock) { + git_mutex_lock(&openssl_locks[n]); + } else { + git_mutex_unlock(&openssl_locks[n]); + } +} + +static void shutdown_ssl_locking(void) +{ + int num_locks, i; + + num_locks = CRYPTO_num_locks(); + CRYPTO_set_locking_callback(NULL); + + for (i = 0; i < num_locks; ++i) + git_mutex_free(openssl_locks); + git__free(openssl_locks); +} +#endif + +static void init_ssl(void) +{ +#ifdef GIT_SSL + long ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; + + /* Older OpenSSL and MacOS OpenSSL doesn't have this */ +#ifdef SSL_OP_NO_COMPRESSION + ssl_opts |= SSL_OP_NO_COMPRESSION; +#endif + + SSL_load_error_strings(); + OpenSSL_add_ssl_algorithms(); + /* + * Load SSLv{2,3} and TLSv1 so that we can talk with servers + * which use the SSL hellos, which are often used for + * compatibility. We then disable SSL so we only allow OpenSSL + * to speak TLSv1 to perform the encryption itself. + */ + git__ssl_ctx = SSL_CTX_new(SSLv23_method()); + SSL_CTX_set_options(git__ssl_ctx, ssl_opts); + SSL_CTX_set_mode(git__ssl_ctx, SSL_MODE_AUTO_RETRY); + SSL_CTX_set_verify(git__ssl_ctx, SSL_VERIFY_NONE, NULL); + if (!SSL_CTX_set_default_verify_paths(git__ssl_ctx)) { + SSL_CTX_free(git__ssl_ctx); + git__ssl_ctx = NULL; + } +#endif +} + +int git_openssl_set_locking(void) +{ +#ifdef GIT_SSL +# ifdef GIT_THREADS + int num_locks, i; + + num_locks = CRYPTO_num_locks(); + openssl_locks = git__calloc(num_locks, sizeof(git_mutex)); + GITERR_CHECK_ALLOC(openssl_locks); + + for (i = 0; i < num_locks; i++) { + if (git_mutex_init(&openssl_locks[i]) != 0) { + giterr_set(GITERR_SSL, "failed to initialize openssl locks"); + return -1; + } + } + + CRYPTO_set_locking_callback(openssl_locking_function); + git__on_shutdown(shutdown_ssl_locking); + return 0; +# else + giterr_set(GITERR_THREAD, "libgit2 as not built with threads"); + return -1; +# endif +#else + giterr_set(GITERR_SSL, "libgit2 was not built with OpenSSL support"); + return -1; +#endif +} + +/** + * Handle the global state with TLS + * + * If libgit2 is built with GIT_THREADS enabled, + * the `git_libgit2_init()` function must be called + * before calling any other function of the library. + * + * This function allocates a TLS index (using pthreads + * or the native Win32 API) to store the global state + * on a per-thread basis. + * + * Any internal method that requires global state will + * then call `git__global_state()` which returns a pointer + * to the global state structure; this pointer is lazily + * allocated on each thread. + * + * Before shutting down the library, the + * `git_libgit2_shutdown` method must be called to free + * the previously reserved TLS index. + * + * If libgit2 is built without threading support, the + * `git__global_statestate()` call returns a pointer to a single, + * statically allocated global state. The `git_thread_` + * functions are not available in that case. + */ + +/* + * `git_libgit2_init()` allows subsystems to perform global setup, + * which may take place in the global scope. An explicit memory + * fence exists at the exit of `git_libgit2_init()`. Without this, + * CPU cores are free to reorder cache invalidation of `_tls_init` + * before cache invalidation of the subsystems' newly written global + * state. + */ +#if defined(GIT_THREADS) && defined(GIT_WIN32) + +static DWORD _tls_index; +static volatile LONG _mutex = 0; + +static int synchronized_threads_init(void) +{ + int error; + + _tls_index = TlsAlloc(); + if (git_mutex_init(&git__mwindow_mutex)) + return -1; + + /* Initialize any other subsystems that have global state */ + if ((error = git_hash_global_init()) >= 0) + error = git_sysdir_global_init(); + + win32_pthread_initialize(); + + return error; +} + +int git_libgit2_init(void) +{ + int ret; + + /* Enter the lock */ + while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } + + /* Only do work on a 0 -> 1 transition of the refcount */ + if ((ret = git_atomic_inc(&git__n_inits)) == 1) { + if (synchronized_threads_init() < 0) + ret = -1; + } + + /* Exit the lock */ + InterlockedExchange(&_mutex, 0); + + return ret; +} + +static void synchronized_threads_shutdown(void) +{ + void *ptr; + + /* Shut down any subsystems that have global state */ + git__shutdown(); + + ptr = TlsGetValue(_tls_index); + git__global_state_cleanup(ptr); + + TlsFree(_tls_index); + git_mutex_free(&git__mwindow_mutex); +} + +int git_libgit2_shutdown(void) +{ + int ret; + + /* Enter the lock */ + while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } + + /* Only do work on a 1 -> 0 transition of the refcount */ + if ((ret = git_atomic_dec(&git__n_inits)) == 0) + synchronized_threads_shutdown(); + + /* Exit the lock */ + InterlockedExchange(&_mutex, 0); + + return ret; +} + +git_global_st *git__global_state(void) +{ + void *ptr; + + assert(git_atomic_get(&git__n_inits) > 0); + + if ((ptr = TlsGetValue(_tls_index)) != NULL) + return ptr; + + ptr = git__malloc(sizeof(git_global_st)); + if (!ptr) + return NULL; + + memset(ptr, 0x0, sizeof(git_global_st)); + TlsSetValue(_tls_index, ptr); + return ptr; +} + +BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved) +{ + if (reason == DLL_THREAD_DETACH) { + void *ptr = TlsGetValue(_tls_index); + git__global_state_cleanup(ptr); + git__free(ptr); + } + + return TRUE; +} + +#elif defined(GIT_THREADS) && defined(_POSIX_THREADS) + +static pthread_key_t _tls_key; +static pthread_once_t _once_init = PTHREAD_ONCE_INIT; +int init_error = 0; + +static void cb__free_status(void *st) +{ + git__global_state_cleanup(st); + git__free(st); +} + +static void init_once(void) +{ + if ((init_error = git_mutex_init(&git__mwindow_mutex)) != 0) + return; + pthread_key_create(&_tls_key, &cb__free_status); + + + /* Initialize any other subsystems that have global state */ + if ((init_error = git_hash_global_init()) >= 0) + init_error = git_sysdir_global_init(); + + /* OpenSSL needs to be initialized from the main thread */ + init_ssl(); + + GIT_MEMORY_BARRIER; +} + +int git_libgit2_init(void) +{ + int ret; + + pthread_once(&_once_init, init_once); + ret = git_atomic_inc(&git__n_inits); + + return init_error ? init_error : ret; +} + +int git_libgit2_shutdown(void) +{ + void *ptr = NULL; + pthread_once_t new_once = PTHREAD_ONCE_INIT; + int ret; + + if ((ret = git_atomic_dec(&git__n_inits)) != 0) + return ret; + + /* Shut down any subsystems that have global state */ + git__shutdown(); + + ptr = pthread_getspecific(_tls_key); + pthread_setspecific(_tls_key, NULL); + + git__global_state_cleanup(ptr); + git__free(ptr); + + pthread_key_delete(_tls_key); + git_mutex_free(&git__mwindow_mutex); + _once_init = new_once; + + return 0; +} + +git_global_st *git__global_state(void) +{ + void *ptr; + + assert(git_atomic_get(&git__n_inits) > 0); + + if ((ptr = pthread_getspecific(_tls_key)) != NULL) + return ptr; + + ptr = git__malloc(sizeof(git_global_st)); + if (!ptr) + return NULL; + + memset(ptr, 0x0, sizeof(git_global_st)); + pthread_setspecific(_tls_key, ptr); + return ptr; +} + +#else + +static git_global_st __state; + +int git_libgit2_init(void) +{ + static int ssl_inited = 0; + + if (!ssl_inited) { + init_ssl(); + ssl_inited = 1; + } + + return git_atomic_inc(&git__n_inits); +} + +int git_libgit2_shutdown(void) +{ + int ret; + + /* Shut down any subsystems that have global state */ + if ((ret = git_atomic_dec(&git__n_inits)) != 0) + return ret; + + git__shutdown(); + git__global_state_cleanup(&__state); + + return 0; +} + +git_global_st *git__global_state(void) +{ + return &__state; +} + +#endif /* GIT_THREADS */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/global.h b/deps/libgit2-sys-0.2.17/libgit2/src/global.h new file mode 100644 index 000000000..a89a8d6ab --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/global.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_global_h__ +#define INCLUDE_global_h__ + +#include "common.h" +#include "mwindow.h" +#include "hash.h" + +typedef struct { + git_error *last_error; + git_error error_t; + char oid_fmt[GIT_OID_HEXSZ+1]; +} git_global_st; + +#ifdef GIT_SSL +# include +extern SSL_CTX *git__ssl_ctx; +#endif + +git_global_st *git__global_state(void); + +extern git_mutex git__mwindow_mutex; + +#define GIT_GLOBAL (git__global_state()) + +typedef void (*git_global_shutdown_fn)(void); + +extern void git__on_shutdown(git_global_shutdown_fn callback); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/graph.c b/deps/libgit2-sys-0.2.17/libgit2/src/graph.c new file mode 100644 index 000000000..8accd808c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/graph.c @@ -0,0 +1,192 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "revwalk.h" +#include "merge.h" +#include "git2/graph.h" + +static int interesting(git_pqueue *list, git_commit_list *roots) +{ + unsigned int i; + + for (i = 0; i < git_pqueue_size(list); i++) { + git_commit_list_node *commit = git_pqueue_get(list, i); + if ((commit->flags & STALE) == 0) + return 1; + } + + while(roots) { + if ((roots->item->flags & STALE) == 0) + return 1; + roots = roots->next; + } + + return 0; +} + +static int mark_parents(git_revwalk *walk, git_commit_list_node *one, + git_commit_list_node *two) +{ + unsigned int i; + git_commit_list *roots = NULL; + git_pqueue list; + + /* if the commit is repeated, we have a our merge base already */ + if (one == two) { + one->flags |= PARENT1 | PARENT2 | RESULT; + return 0; + } + + if (git_pqueue_init(&list, 0, 2, git_commit_list_time_cmp) < 0) + return -1; + + if (git_commit_list_parse(walk, one) < 0) + goto on_error; + one->flags |= PARENT1; + if (git_pqueue_insert(&list, one) < 0) + goto on_error; + + if (git_commit_list_parse(walk, two) < 0) + goto on_error; + two->flags |= PARENT2; + if (git_pqueue_insert(&list, two) < 0) + goto on_error; + + /* as long as there are non-STALE commits */ + while (interesting(&list, roots)) { + git_commit_list_node *commit = git_pqueue_pop(&list); + int flags; + + if (commit == NULL) + break; + + flags = commit->flags & (PARENT1 | PARENT2 | STALE); + if (flags == (PARENT1 | PARENT2)) { + if (!(commit->flags & RESULT)) + commit->flags |= RESULT; + /* we mark the parents of a merge stale */ + flags |= STALE; + } + + for (i = 0; i < commit->out_degree; i++) { + git_commit_list_node *p = commit->parents[i]; + if ((p->flags & flags) == flags) + continue; + + if (git_commit_list_parse(walk, p) < 0) + goto on_error; + + p->flags |= flags; + if (git_pqueue_insert(&list, p) < 0) + goto on_error; + } + + /* Keep track of root commits, to make sure the path gets marked */ + if (commit->out_degree == 0) { + if (git_commit_list_insert(commit, &roots) == NULL) + goto on_error; + } + } + + git_commit_list_free(&roots); + git_pqueue_free(&list); + return 0; + +on_error: + git_commit_list_free(&roots); + git_pqueue_free(&list); + return -1; +} + + +static int ahead_behind(git_commit_list_node *one, git_commit_list_node *two, + size_t *ahead, size_t *behind) +{ + git_commit_list_node *commit; + git_pqueue pq; + int error = 0, i; + *ahead = 0; + *behind = 0; + + if (git_pqueue_init(&pq, 0, 2, git_commit_list_time_cmp) < 0) + return -1; + + if ((error = git_pqueue_insert(&pq, one)) < 0 || + (error = git_pqueue_insert(&pq, two)) < 0) + goto done; + + while ((commit = git_pqueue_pop(&pq)) != NULL) { + if (commit->flags & RESULT || + (commit->flags & (PARENT1 | PARENT2)) == (PARENT1 | PARENT2)) + continue; + else if (commit->flags & PARENT1) + (*ahead)++; + else if (commit->flags & PARENT2) + (*behind)++; + + for (i = 0; i < commit->out_degree; i++) { + git_commit_list_node *p = commit->parents[i]; + if ((error = git_pqueue_insert(&pq, p)) < 0) + goto done; + } + commit->flags |= RESULT; + } + +done: + git_pqueue_free(&pq); + return error; +} + +int git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, + const git_oid *local, const git_oid *upstream) +{ + git_revwalk *walk; + git_commit_list_node *commit_u, *commit_l; + + if (git_revwalk_new(&walk, repo) < 0) + return -1; + + commit_u = git_revwalk__commit_lookup(walk, upstream); + if (commit_u == NULL) + goto on_error; + + commit_l = git_revwalk__commit_lookup(walk, local); + if (commit_l == NULL) + goto on_error; + + if (mark_parents(walk, commit_l, commit_u) < 0) + goto on_error; + if (ahead_behind(commit_l, commit_u, ahead, behind) < 0) + goto on_error; + + git_revwalk_free(walk); + + return 0; + +on_error: + git_revwalk_free(walk); + return -1; +} + +int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const git_oid *ancestor) +{ + git_oid merge_base; + int error; + + if (git_oid_equal(commit, ancestor)) + return 0; + + error = git_merge_base(&merge_base, repo, commit, ancestor); + /* No merge-base found, it's not a descendant */ + if (error == GIT_ENOTFOUND) + return 0; + + if (error < 0) + return error; + + return git_oid_equal(&merge_base, ancestor); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash.c b/deps/libgit2-sys-0.2.17/libgit2/src/hash.c new file mode 100644 index 000000000..f3645a913 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "hash.h" + +int git_hash_buf(git_oid *out, const void *data, size_t len) +{ + git_hash_ctx ctx; + int error = 0; + + if (git_hash_ctx_init(&ctx) < 0) + return -1; + + if ((error = git_hash_update(&ctx, data, len)) >= 0) + error = git_hash_final(out, &ctx); + + git_hash_ctx_cleanup(&ctx); + + return error; +} + +int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n) +{ + git_hash_ctx ctx; + size_t i; + int error = 0; + + if (git_hash_ctx_init(&ctx) < 0) + return -1; + + for (i = 0; i < n; i++) { + if ((error = git_hash_update(&ctx, vec[i].data, vec[i].len)) < 0) + goto done; + } + + error = git_hash_final(out, &ctx); + +done: + git_hash_ctx_cleanup(&ctx); + + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash.h b/deps/libgit2-sys-0.2.17/libgit2/src/hash.h new file mode 100644 index 000000000..0bc02a8a9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_hash_h__ +#define INCLUDE_hash_h__ + +#include "git2/oid.h" + +typedef struct git_hash_prov git_hash_prov; +typedef struct git_hash_ctx git_hash_ctx; + +int git_hash_global_init(void); +int git_hash_ctx_init(git_hash_ctx *ctx); +void git_hash_ctx_cleanup(git_hash_ctx *ctx); + +#if defined(GIT_COMMON_CRYPTO) +# include "hash/hash_common_crypto.h" +#elif defined(OPENSSL_SHA1) +# include "hash/hash_openssl.h" +#elif defined(WIN32_SHA1) +# include "hash/hash_win32.h" +#else +# include "hash/hash_generic.h" +#endif + +typedef struct { + void *data; + size_t len; +} git_buf_vec; + +int git_hash_init(git_hash_ctx *c); +int git_hash_update(git_hash_ctx *c, const void *data, size_t len); +int git_hash_final(git_oid *out, git_hash_ctx *c); + +int git_hash_buf(git_oid *out, const void *data, size_t len); +int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n); + +#endif /* INCLUDE_hash_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_common_crypto.h b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_common_crypto.h new file mode 100644 index 000000000..eeeddd0cc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_common_crypto.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_hash_common_crypto_h__ +#define INCLUDE_hash_common_crypto_h__ + +#include "hash.h" + +#include + +struct git_hash_ctx { + CC_SHA1_CTX c; +}; + +#define git_hash_global_init() 0 +#define git_hash_ctx_init(ctx) git_hash_init(ctx) +#define git_hash_ctx_cleanup(ctx) + +GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) +{ + assert(ctx); + CC_SHA1_Init(&ctx->c); + return 0; +} + +GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + assert(ctx); + CC_SHA1_Update(&ctx->c, data, len); + return 0; +} + +GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) +{ + assert(ctx); + CC_SHA1_Final(out->id, &ctx->c); + return 0; +} + +#endif /* INCLUDE_hash_common_crypto_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.c b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.c new file mode 100644 index 000000000..472a7a696 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.c @@ -0,0 +1,288 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "hash.h" +#include "hash/hash_generic.h" + +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + +/* + * Force usage of rol or ror by selecting the one with the smaller constant. + * It _can_ generate slightly smaller code (a constant of 1 is special), but + * perhaps more importantly it's possibly faster on any uarch that does a + * rotate with a loop. + */ + +#define SHA_ASM(op, x, n) (__extension__ ({ unsigned int __res; __asm__(op " %1,%0":"=r" (__res):"i" (n), "0" (x)); __res; })) +#define SHA_ROL(x,n) SHA_ASM("rol", x, n) +#define SHA_ROR(x,n) SHA_ASM("ror", x, n) + +#else + +#define SHA_ROT(X,l,r) (((X) << (l)) | ((X) >> (r))) +#define SHA_ROL(X,n) SHA_ROT(X,n,32-(n)) +#define SHA_ROR(X,n) SHA_ROT(X,32-(n),n) + +#endif + +/* + * If you have 32 registers or more, the compiler can (and should) + * try to change the array[] accesses into registers. However, on + * machines with less than ~25 registers, that won't really work, + * and at least gcc will make an unholy mess of it. + * + * So to avoid that mess which just slows things down, we force + * the stores to memory to actually happen (we might be better off + * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as + * suggested by Artur Skawina - that will also make gcc unable to + * try to do the silly "optimize away loads" part because it won't + * see what the value will be). + * + * Ben Herrenschmidt reports that on PPC, the C version comes close + * to the optimized asm with this (ie on PPC you don't want that + * 'volatile', since there are lots of registers). + * + * On ARM we get the best code generation by forcing a full memory barrier + * between each SHA_ROUND, otherwise gcc happily get wild with spilling and + * the stack frame size simply explode and performance goes down the drain. + */ + +#if defined(__i386__) || defined(__x86_64__) + #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val)) +#elif defined(__GNUC__) && defined(__arm__) + #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0) +#else + #define setW(x, val) (W(x) = (val)) +#endif + +/* + * Performance might be improved if the CPU architecture is OK with + * unaligned 32-bit loads and a fast ntohl() is available. + * Otherwise fall back to byte loads and shifts which is portable, + * and is faster on architectures with memory alignment issues. + */ + +#if defined(__i386__) || defined(__x86_64__) || \ + defined(_M_IX86) || defined(_M_X64) || \ + defined(__ppc__) || defined(__ppc64__) || \ + defined(__powerpc__) || defined(__powerpc64__) || \ + defined(__s390__) || defined(__s390x__) + +#define get_be32(p) ntohl(*(const unsigned int *)(p)) +#define put_be32(p, v) do { *(unsigned int *)(p) = htonl(v); } while (0) + +#else + +#define get_be32(p) ( \ + (*((const unsigned char *)(p) + 0) << 24) | \ + (*((const unsigned char *)(p) + 1) << 16) | \ + (*((const unsigned char *)(p) + 2) << 8) | \ + (*((const unsigned char *)(p) + 3) << 0) ) +#define put_be32(p, v) do { \ + unsigned int __v = (v); \ + *((unsigned char *)(p) + 0) = __v >> 24; \ + *((unsigned char *)(p) + 1) = __v >> 16; \ + *((unsigned char *)(p) + 2) = __v >> 8; \ + *((unsigned char *)(p) + 3) = __v >> 0; } while (0) + +#endif + +/* This "rolls" over the 512-bit array */ +#define W(x) (array[(x)&15]) + +/* + * Where do we get the source from? The first 16 iterations get it from + * the input data, the next mix it from the 512-bit array. + */ +#define SHA_SRC(t) get_be32(data + t) +#define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1) + +#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \ + unsigned int TEMP = input(t); setW(t, TEMP); \ + E += TEMP + SHA_ROL(A,5) + (fn) + (constant); \ + B = SHA_ROR(B, 2); } while (0) + +#define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) +#define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) +#define T_20_39(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E ) +#define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E ) +#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E ) + +static void hash__block(git_hash_ctx *ctx, const unsigned int *data) +{ + unsigned int A,B,C,D,E; + unsigned int array[16]; + + A = ctx->H[0]; + B = ctx->H[1]; + C = ctx->H[2]; + D = ctx->H[3]; + E = ctx->H[4]; + + /* Round 1 - iterations 0-16 take their input from 'data' */ + T_0_15( 0, A, B, C, D, E); + T_0_15( 1, E, A, B, C, D); + T_0_15( 2, D, E, A, B, C); + T_0_15( 3, C, D, E, A, B); + T_0_15( 4, B, C, D, E, A); + T_0_15( 5, A, B, C, D, E); + T_0_15( 6, E, A, B, C, D); + T_0_15( 7, D, E, A, B, C); + T_0_15( 8, C, D, E, A, B); + T_0_15( 9, B, C, D, E, A); + T_0_15(10, A, B, C, D, E); + T_0_15(11, E, A, B, C, D); + T_0_15(12, D, E, A, B, C); + T_0_15(13, C, D, E, A, B); + T_0_15(14, B, C, D, E, A); + T_0_15(15, A, B, C, D, E); + + /* Round 1 - tail. Input from 512-bit mixing array */ + T_16_19(16, E, A, B, C, D); + T_16_19(17, D, E, A, B, C); + T_16_19(18, C, D, E, A, B); + T_16_19(19, B, C, D, E, A); + + /* Round 2 */ + T_20_39(20, A, B, C, D, E); + T_20_39(21, E, A, B, C, D); + T_20_39(22, D, E, A, B, C); + T_20_39(23, C, D, E, A, B); + T_20_39(24, B, C, D, E, A); + T_20_39(25, A, B, C, D, E); + T_20_39(26, E, A, B, C, D); + T_20_39(27, D, E, A, B, C); + T_20_39(28, C, D, E, A, B); + T_20_39(29, B, C, D, E, A); + T_20_39(30, A, B, C, D, E); + T_20_39(31, E, A, B, C, D); + T_20_39(32, D, E, A, B, C); + T_20_39(33, C, D, E, A, B); + T_20_39(34, B, C, D, E, A); + T_20_39(35, A, B, C, D, E); + T_20_39(36, E, A, B, C, D); + T_20_39(37, D, E, A, B, C); + T_20_39(38, C, D, E, A, B); + T_20_39(39, B, C, D, E, A); + + /* Round 3 */ + T_40_59(40, A, B, C, D, E); + T_40_59(41, E, A, B, C, D); + T_40_59(42, D, E, A, B, C); + T_40_59(43, C, D, E, A, B); + T_40_59(44, B, C, D, E, A); + T_40_59(45, A, B, C, D, E); + T_40_59(46, E, A, B, C, D); + T_40_59(47, D, E, A, B, C); + T_40_59(48, C, D, E, A, B); + T_40_59(49, B, C, D, E, A); + T_40_59(50, A, B, C, D, E); + T_40_59(51, E, A, B, C, D); + T_40_59(52, D, E, A, B, C); + T_40_59(53, C, D, E, A, B); + T_40_59(54, B, C, D, E, A); + T_40_59(55, A, B, C, D, E); + T_40_59(56, E, A, B, C, D); + T_40_59(57, D, E, A, B, C); + T_40_59(58, C, D, E, A, B); + T_40_59(59, B, C, D, E, A); + + /* Round 4 */ + T_60_79(60, A, B, C, D, E); + T_60_79(61, E, A, B, C, D); + T_60_79(62, D, E, A, B, C); + T_60_79(63, C, D, E, A, B); + T_60_79(64, B, C, D, E, A); + T_60_79(65, A, B, C, D, E); + T_60_79(66, E, A, B, C, D); + T_60_79(67, D, E, A, B, C); + T_60_79(68, C, D, E, A, B); + T_60_79(69, B, C, D, E, A); + T_60_79(70, A, B, C, D, E); + T_60_79(71, E, A, B, C, D); + T_60_79(72, D, E, A, B, C); + T_60_79(73, C, D, E, A, B); + T_60_79(74, B, C, D, E, A); + T_60_79(75, A, B, C, D, E); + T_60_79(76, E, A, B, C, D); + T_60_79(77, D, E, A, B, C); + T_60_79(78, C, D, E, A, B); + T_60_79(79, B, C, D, E, A); + + ctx->H[0] += A; + ctx->H[1] += B; + ctx->H[2] += C; + ctx->H[3] += D; + ctx->H[4] += E; +} + +int git_hash_init(git_hash_ctx *ctx) +{ + ctx->size = 0; + + /* Initialize H with the magic constants (see FIPS180 for constants) */ + ctx->H[0] = 0x67452301; + ctx->H[1] = 0xefcdab89; + ctx->H[2] = 0x98badcfe; + ctx->H[3] = 0x10325476; + ctx->H[4] = 0xc3d2e1f0; + + return 0; +} + +int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + unsigned int lenW = ctx->size & 63; + + ctx->size += len; + + /* Read the data into W and process blocks as they get full */ + if (lenW) { + unsigned int left = 64 - lenW; + if (len < left) + left = (unsigned int)len; + memcpy(lenW + (char *)ctx->W, data, left); + lenW = (lenW + left) & 63; + len -= left; + data = ((const char *)data + left); + if (lenW) + return 0; + hash__block(ctx, ctx->W); + } + while (len >= 64) { + hash__block(ctx, data); + data = ((const char *)data + 64); + len -= 64; + } + if (len) + memcpy(ctx->W, data, len); + + return 0; +} + +int git_hash_final(git_oid *out, git_hash_ctx *ctx) +{ + static const unsigned char pad[64] = { 0x80 }; + unsigned int padlen[2]; + int i; + + /* Pad with a binary 1 (ie 0x80), then zeroes, then length */ + padlen[0] = htonl((uint32_t)(ctx->size >> 29)); + padlen[1] = htonl((uint32_t)(ctx->size << 3)); + + i = ctx->size & 63; + git_hash_update(ctx, pad, 1+ (63 & (55 - i))); + git_hash_update(ctx, padlen, 8); + + /* Output hash */ + for (i = 0; i < 5; i++) + put_be32(out->id + i*4, ctx->H[i]); + + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.h b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.h new file mode 100644 index 000000000..daeb1cda8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_generic.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_hash_generic_h__ +#define INCLUDE_hash_generic_h__ + +#include "hash.h" + +struct git_hash_ctx { + unsigned long long size; + unsigned int H[5]; + unsigned int W[16]; +}; + +#define git_hash_global_init() 0 +#define git_hash_ctx_init(ctx) git_hash_init(ctx) +#define git_hash_ctx_cleanup(ctx) + +#endif /* INCLUDE_hash_generic_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_openssl.h b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_openssl.h new file mode 100644 index 000000000..9a55d472d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_openssl.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_hash_openssl_h__ +#define INCLUDE_hash_openssl_h__ + +#include "hash.h" + +#include + +struct git_hash_ctx { + SHA_CTX c; +}; + +#define git_hash_global_init() 0 +#define git_hash_ctx_init(ctx) git_hash_init(ctx) +#define git_hash_ctx_cleanup(ctx) + +GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) +{ + assert(ctx); + SHA1_Init(&ctx->c); + return 0; +} + +GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + assert(ctx); + SHA1_Update(&ctx->c, data, len); + return 0; +} + +GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) +{ + assert(ctx); + SHA1_Final(out->id, &ctx->c); + return 0; +} + +#endif /* INCLUDE_hash_openssl_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.c b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.c new file mode 100644 index 000000000..6bae53e55 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.c @@ -0,0 +1,276 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "global.h" +#include "hash.h" +#include "hash/hash_win32.h" + +#include +#include + +static struct git_hash_prov hash_prov = {0}; + +/* Hash initialization */ + +/* Initialize CNG, if available */ +GIT_INLINE(int) hash_cng_prov_init(void) +{ + char dll_path[MAX_PATH]; + DWORD dll_path_len, size_len; + + /* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */ + if (!git_has_win32_version(6, 0, 1)) + return -1; + + /* Load bcrypt.dll explicitly from the system directory */ + if ((dll_path_len = GetSystemDirectory(dll_path, MAX_PATH)) == 0 || + dll_path_len > MAX_PATH || + StringCchCat(dll_path, MAX_PATH, "\\") < 0 || + StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 || + (hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) + return -1; + + /* Load the function addresses */ + if ((hash_prov.prov.cng.open_algorithm_provider = (hash_win32_cng_open_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptOpenAlgorithmProvider")) == NULL || + (hash_prov.prov.cng.get_property = (hash_win32_cng_get_property_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptGetProperty")) == NULL || + (hash_prov.prov.cng.create_hash = (hash_win32_cng_create_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCreateHash")) == NULL || + (hash_prov.prov.cng.finish_hash = (hash_win32_cng_finish_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptFinishHash")) == NULL || + (hash_prov.prov.cng.hash_data = (hash_win32_cng_hash_data_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptHashData")) == NULL || + (hash_prov.prov.cng.destroy_hash = (hash_win32_cng_destroy_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptDestroyHash")) == NULL || + (hash_prov.prov.cng.close_algorithm_provider = (hash_win32_cng_close_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCloseAlgorithmProvider")) == NULL) { + FreeLibrary(hash_prov.prov.cng.dll); + return -1; + } + + /* Load the SHA1 algorithm */ + if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) { + FreeLibrary(hash_prov.prov.cng.dll); + return -1; + } + + /* Get storage space for the hash object */ + if (hash_prov.prov.cng.get_property(hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_OBJECT_LEN, (PBYTE)&hash_prov.prov.cng.hash_object_size, sizeof(DWORD), &size_len, 0) < 0) { + hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); + FreeLibrary(hash_prov.prov.cng.dll); + return -1; + } + + hash_prov.type = CNG; + return 0; +} + +GIT_INLINE(void) hash_cng_prov_shutdown(void) +{ + hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); + FreeLibrary(hash_prov.prov.cng.dll); + + hash_prov.type = INVALID; +} + +/* Initialize CryptoAPI */ +GIT_INLINE(int) hash_cryptoapi_prov_init() +{ + if (!CryptAcquireContext(&hash_prov.prov.cryptoapi.handle, NULL, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + return -1; + + hash_prov.type = CRYPTOAPI; + return 0; +} + +GIT_INLINE(void) hash_cryptoapi_prov_shutdown(void) +{ + CryptReleaseContext(hash_prov.prov.cryptoapi.handle, 0); + + hash_prov.type = INVALID; +} + +static void git_hash_global_shutdown(void) +{ + if (hash_prov.type == CNG) + hash_cng_prov_shutdown(); + else if(hash_prov.type == CRYPTOAPI) + hash_cryptoapi_prov_shutdown(); +} + +int git_hash_global_init(void) +{ + int error = 0; + + if (hash_prov.type != INVALID) + return 0; + + if ((error = hash_cng_prov_init()) < 0) + error = hash_cryptoapi_prov_init(); + + git__on_shutdown(git_hash_global_shutdown); + + return error; +} + +/* CryptoAPI: available in Windows XP and newer */ + +GIT_INLINE(int) hash_ctx_cryptoapi_init(git_hash_ctx *ctx) +{ + ctx->type = CRYPTOAPI; + ctx->prov = &hash_prov; + + return git_hash_init(ctx); +} + +GIT_INLINE(int) hash_cryptoapi_init(git_hash_ctx *ctx) +{ + if (ctx->ctx.cryptoapi.valid) + CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); + + if (!CryptCreateHash(ctx->prov->prov.cryptoapi.handle, CALG_SHA1, 0, 0, &ctx->ctx.cryptoapi.hash_handle)) { + ctx->ctx.cryptoapi.valid = 0; + return -1; + } + + ctx->ctx.cryptoapi.valid = 1; + return 0; +} + +GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + assert(ctx->ctx.cryptoapi.valid); + + if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, (DWORD)len, 0)) + return -1; + + return 0; +} + +GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_ctx *ctx) +{ + DWORD len = 20; + int error = 0; + + assert(ctx->ctx.cryptoapi.valid); + + if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) + error = -1; + + CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); + ctx->ctx.cryptoapi.valid = 0; + + return error; +} + +GIT_INLINE(void) hash_ctx_cryptoapi_cleanup(git_hash_ctx *ctx) +{ + if (ctx->ctx.cryptoapi.valid) + CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); +} + +/* CNG: Available in Windows Server 2008 and newer */ + +GIT_INLINE(int) hash_ctx_cng_init(git_hash_ctx *ctx) +{ + if ((ctx->ctx.cng.hash_object = git__malloc(hash_prov.prov.cng.hash_object_size)) == NULL) + return -1; + + if (hash_prov.prov.cng.create_hash(hash_prov.prov.cng.handle, &ctx->ctx.cng.hash_handle, ctx->ctx.cng.hash_object, hash_prov.prov.cng.hash_object_size, NULL, 0, 0) < 0) { + git__free(ctx->ctx.cng.hash_object); + return -1; + } + + ctx->type = CNG; + ctx->prov = &hash_prov; + + return 0; +} + +GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx) +{ + BYTE hash[GIT_OID_RAWSZ]; + + if (!ctx->ctx.cng.updated) + return 0; + + /* CNG needs to be finished to restart */ + if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, hash, GIT_OID_RAWSZ, 0) < 0) + return -1; + + ctx->ctx.cng.updated = 0; + + return 0; +} + +GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, (ULONG)len, 0) < 0) + return -1; + + return 0; +} + +GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_ctx *ctx) +{ + if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) + return -1; + + ctx->ctx.cng.updated = 0; + + return 0; +} + +GIT_INLINE(void) hash_ctx_cng_cleanup(git_hash_ctx *ctx) +{ + ctx->prov->prov.cng.destroy_hash(ctx->ctx.cng.hash_handle); + git__free(ctx->ctx.cng.hash_object); +} + +/* Indirection between CryptoAPI and CNG */ + +int git_hash_ctx_init(git_hash_ctx *ctx) +{ + int error = 0; + + assert(ctx); + + /* + * When compiled with GIT_THREADS, the global hash_prov data is + * initialized with git_libgit2_init. Otherwise, it must be initialized + * at first use. + */ + if (hash_prov.type == INVALID && (error = git_hash_global_init()) < 0) + return error; + + memset(ctx, 0x0, sizeof(git_hash_ctx)); + + return (hash_prov.type == CNG) ? hash_ctx_cng_init(ctx) : hash_ctx_cryptoapi_init(ctx); +} + +int git_hash_init(git_hash_ctx *ctx) +{ + assert(ctx && ctx->type); + return (ctx->type == CNG) ? hash_cng_init(ctx) : hash_cryptoapi_init(ctx); +} + +int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + assert(ctx && ctx->type); + return (ctx->type == CNG) ? hash_cng_update(ctx, data, len) : hash_cryptoapi_update(ctx, data, len); +} + +int git_hash_final(git_oid *out, git_hash_ctx *ctx) +{ + assert(ctx && ctx->type); + return (ctx->type == CNG) ? hash_cng_final(out, ctx) : hash_cryptoapi_final(out, ctx); +} + +void git_hash_ctx_cleanup(git_hash_ctx *ctx) +{ + assert(ctx); + + if (ctx->type == CNG) + hash_ctx_cng_cleanup(ctx); + else if(ctx->type == CRYPTOAPI) + hash_ctx_cryptoapi_cleanup(ctx); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.h b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.h new file mode 100644 index 000000000..2eee5ca79 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hash/hash_win32.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_hash_win32_h__ +#define INCLUDE_hash_win32_h__ + +#include "common.h" +#include "hash.h" + +#include +#include + +enum hash_win32_prov_type { + INVALID = 0, + CRYPTOAPI, + CNG +}; + +/* + * CryptoAPI is available for hashing on Windows XP and newer. + */ + +struct hash_cryptoapi_prov { + HCRYPTPROV handle; +}; + +/* + * CNG (bcrypt.dll) is significantly more performant than CryptoAPI and is + * preferred, however it is only available on Windows 2008 and newer and + * must therefore be dynamically loaded, and we must inline constants that + * would not exist when building in pre-Windows 2008 environments. + */ + +#define GIT_HASH_CNG_DLL_NAME "bcrypt.dll" + +/* BCRYPT_SHA1_ALGORITHM */ +#define GIT_HASH_CNG_HASH_TYPE L"SHA1" + +/* BCRYPT_OBJECT_LENGTH */ +#define GIT_HASH_CNG_HASH_OBJECT_LEN L"ObjectLength" + +/* BCRYPT_HASH_REUSEABLE_FLAGS */ +#define GIT_HASH_CNG_HASH_REUSABLE 0x00000020 + +/* Function declarations for CNG */ +typedef NTSTATUS (WINAPI *hash_win32_cng_open_algorithm_provider_fn)( + HANDLE /* BCRYPT_ALG_HANDLE */ *phAlgorithm, + LPCWSTR pszAlgId, + LPCWSTR pszImplementation, + DWORD dwFlags); + +typedef NTSTATUS (WINAPI *hash_win32_cng_get_property_fn)( + HANDLE /* BCRYPT_HANDLE */ hObject, + LPCWSTR pszProperty, + PUCHAR pbOutput, + ULONG cbOutput, + ULONG *pcbResult, + ULONG dwFlags); + +typedef NTSTATUS (WINAPI *hash_win32_cng_create_hash_fn)( + HANDLE /* BCRYPT_ALG_HANDLE */ hAlgorithm, + HANDLE /* BCRYPT_HASH_HANDLE */ *phHash, + PUCHAR pbHashObject, ULONG cbHashObject, + PUCHAR pbSecret, + ULONG cbSecret, + ULONG dwFlags); + +typedef NTSTATUS (WINAPI *hash_win32_cng_finish_hash_fn)( + HANDLE /* BCRYPT_HASH_HANDLE */ hHash, + PUCHAR pbOutput, + ULONG cbOutput, + ULONG dwFlags); + +typedef NTSTATUS (WINAPI *hash_win32_cng_hash_data_fn)( + HANDLE /* BCRYPT_HASH_HANDLE */ hHash, + PUCHAR pbInput, + ULONG cbInput, + ULONG dwFlags); + +typedef NTSTATUS (WINAPI *hash_win32_cng_destroy_hash_fn)( + HANDLE /* BCRYPT_HASH_HANDLE */ hHash); + +typedef NTSTATUS (WINAPI *hash_win32_cng_close_algorithm_provider_fn)( + HANDLE /* BCRYPT_ALG_HANDLE */ hAlgorithm, + ULONG dwFlags); + +struct hash_cng_prov { + /* DLL for CNG */ + HINSTANCE dll; + + /* Function pointers for CNG */ + hash_win32_cng_open_algorithm_provider_fn open_algorithm_provider; + hash_win32_cng_get_property_fn get_property; + hash_win32_cng_create_hash_fn create_hash; + hash_win32_cng_finish_hash_fn finish_hash; + hash_win32_cng_hash_data_fn hash_data; + hash_win32_cng_destroy_hash_fn destroy_hash; + hash_win32_cng_close_algorithm_provider_fn close_algorithm_provider; + + HANDLE /* BCRYPT_ALG_HANDLE */ handle; + DWORD hash_object_size; +}; + +struct git_hash_prov { + enum hash_win32_prov_type type; + + union { + struct hash_cryptoapi_prov cryptoapi; + struct hash_cng_prov cng; + } prov; +}; + +/* Hash contexts */ + +struct hash_cryptoapi_ctx { + bool valid; + HCRYPTHASH hash_handle; +}; + +struct hash_cng_ctx { + bool updated; + HANDLE /* BCRYPT_HASH_HANDLE */ hash_handle; + PBYTE hash_object; +}; + +struct git_hash_ctx { + enum hash_win32_prov_type type; + git_hash_prov *prov; + + union { + struct hash_cryptoapi_ctx cryptoapi; + struct hash_cng_ctx cng; + } ctx; +}; + +#endif /* INCLUDE_hash_openssl_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/hashsig.c b/deps/libgit2-sys-0.2.17/libgit2/src/hashsig.c new file mode 100644 index 000000000..e99637d8b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/hashsig.c @@ -0,0 +1,359 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2/sys/hashsig.h" +#include "fileops.h" +#include "util.h" + +typedef uint32_t hashsig_t; +typedef uint64_t hashsig_state; + +#define HASHSIG_SCALE 100 + +#define HASHSIG_MAX_RUN 80 +#define HASHSIG_HASH_START 0x012345678ABCDEF0LL +#define HASHSIG_HASH_SHIFT 5 + +#define HASHSIG_HASH_MIX(S,CH) \ + (S) = ((S) << HASHSIG_HASH_SHIFT) - (S) + (hashsig_state)(CH) + +#define HASHSIG_HEAP_SIZE ((1 << 7) - 1) +#define HASHSIG_HEAP_MIN_SIZE 4 + +typedef int (*hashsig_cmp)(const void *a, const void *b, void *); + +typedef struct { + int size, asize; + hashsig_cmp cmp; + hashsig_t values[HASHSIG_HEAP_SIZE]; +} hashsig_heap; + +struct git_hashsig { + hashsig_heap mins; + hashsig_heap maxs; + size_t lines; + git_hashsig_option_t opt; +}; + +#define HEAP_LCHILD_OF(I) (((I)<<1)+1) +#define HEAP_RCHILD_OF(I) (((I)<<1)+2) +#define HEAP_PARENT_OF(I) (((I)-1)>>1) + +static void hashsig_heap_init(hashsig_heap *h, hashsig_cmp cmp) +{ + h->size = 0; + h->asize = HASHSIG_HEAP_SIZE; + h->cmp = cmp; +} + +static int hashsig_cmp_max(const void *a, const void *b, void *payload) +{ + hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b; + GIT_UNUSED(payload); + return (av < bv) ? -1 : (av > bv) ? 1 : 0; +} + +static int hashsig_cmp_min(const void *a, const void *b, void *payload) +{ + hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b; + GIT_UNUSED(payload); + return (av > bv) ? -1 : (av < bv) ? 1 : 0; +} + +static void hashsig_heap_up(hashsig_heap *h, int el) +{ + int parent_el = HEAP_PARENT_OF(el); + + while (el > 0 && h->cmp(&h->values[parent_el], &h->values[el], NULL) > 0) { + hashsig_t t = h->values[el]; + h->values[el] = h->values[parent_el]; + h->values[parent_el] = t; + + el = parent_el; + parent_el = HEAP_PARENT_OF(el); + } +} + +static void hashsig_heap_down(hashsig_heap *h, int el) +{ + hashsig_t v, lv, rv; + + /* 'el < h->size / 2' tests if el is bottom row of heap */ + + while (el < h->size / 2) { + int lel = HEAP_LCHILD_OF(el), rel = HEAP_RCHILD_OF(el), swapel; + + v = h->values[el]; + lv = h->values[lel]; + rv = h->values[rel]; + + if (h->cmp(&v, &lv, NULL) < 0 && h->cmp(&v, &rv, NULL) < 0) + break; + + swapel = (h->cmp(&lv, &rv, NULL) < 0) ? lel : rel; + + h->values[el] = h->values[swapel]; + h->values[swapel] = v; + + el = swapel; + } +} + +static void hashsig_heap_sort(hashsig_heap *h) +{ + /* only need to do this at the end for signature comparison */ + git__qsort_r(h->values, h->size, sizeof(hashsig_t), h->cmp, NULL); +} + +static void hashsig_heap_insert(hashsig_heap *h, hashsig_t val) +{ + /* if heap is not full, insert new element */ + if (h->size < h->asize) { + h->values[h->size++] = val; + hashsig_heap_up(h, h->size - 1); + } + + /* if heap is full, pop top if new element should replace it */ + else if (h->cmp(&val, &h->values[0], NULL) > 0) { + h->size--; + h->values[0] = h->values[h->size]; + hashsig_heap_down(h, 0); + } + +} + +typedef struct { + int use_ignores; + uint8_t ignore_ch[256]; +} hashsig_in_progress; + +static void hashsig_in_progress_init( + hashsig_in_progress *prog, git_hashsig *sig) +{ + int i; + + /* no more than one can be set */ + assert(!(sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) || + !(sig->opt & GIT_HASHSIG_SMART_WHITESPACE)); + + if (sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) { + for (i = 0; i < 256; ++i) + prog->ignore_ch[i] = git__isspace_nonlf(i); + prog->use_ignores = 1; + } else if (sig->opt & GIT_HASHSIG_SMART_WHITESPACE) { + for (i = 0; i < 256; ++i) + prog->ignore_ch[i] = git__isspace(i); + prog->use_ignores = 1; + } else { + memset(prog, 0, sizeof(*prog)); + } +} + +static int hashsig_add_hashes( + git_hashsig *sig, + const uint8_t *data, + size_t size, + hashsig_in_progress *prog) +{ + const uint8_t *scan = data, *end = data + size; + hashsig_state state = HASHSIG_HASH_START; + int use_ignores = prog->use_ignores, len; + uint8_t ch; + + while (scan < end) { + state = HASHSIG_HASH_START; + + for (len = 0; scan < end && len < HASHSIG_MAX_RUN; ) { + ch = *scan; + + if (use_ignores) + for (; scan < end && git__isspace_nonlf(ch); ch = *scan) + ++scan; + else if (sig->opt & + (GIT_HASHSIG_IGNORE_WHITESPACE | GIT_HASHSIG_SMART_WHITESPACE)) + for (; scan < end && ch == '\r'; ch = *scan) + ++scan; + + /* peek at next character to decide what to do next */ + if (sig->opt & GIT_HASHSIG_SMART_WHITESPACE) + use_ignores = (ch == '\n'); + + if (scan >= end) + break; + ++scan; + + /* check run terminator */ + if (ch == '\n' || ch == '\0') { + sig->lines++; + break; + } + + ++len; + HASHSIG_HASH_MIX(state, ch); + } + + if (len > 0) { + hashsig_heap_insert(&sig->mins, (hashsig_t)state); + hashsig_heap_insert(&sig->maxs, (hashsig_t)state); + + while (scan < end && (*scan == '\n' || !*scan)) + ++scan; + } + } + + prog->use_ignores = use_ignores; + + return 0; +} + +static int hashsig_finalize_hashes(git_hashsig *sig) +{ + if (sig->mins.size < HASHSIG_HEAP_MIN_SIZE && + !(sig->opt & GIT_HASHSIG_ALLOW_SMALL_FILES)) { + giterr_set(GITERR_INVALID, + "File too small for similarity signature calculation"); + return GIT_EBUFS; + } + + hashsig_heap_sort(&sig->mins); + hashsig_heap_sort(&sig->maxs); + + return 0; +} + +static git_hashsig *hashsig_alloc(git_hashsig_option_t opts) +{ + git_hashsig *sig = git__calloc(1, sizeof(git_hashsig)); + if (!sig) + return NULL; + + hashsig_heap_init(&sig->mins, hashsig_cmp_min); + hashsig_heap_init(&sig->maxs, hashsig_cmp_max); + sig->opt = opts; + + return sig; +} + +int git_hashsig_create( + git_hashsig **out, + const char *buf, + size_t buflen, + git_hashsig_option_t opts) +{ + int error; + hashsig_in_progress prog; + git_hashsig *sig = hashsig_alloc(opts); + GITERR_CHECK_ALLOC(sig); + + hashsig_in_progress_init(&prog, sig); + + error = hashsig_add_hashes(sig, (const uint8_t *)buf, buflen, &prog); + + if (!error) + error = hashsig_finalize_hashes(sig); + + if (!error) + *out = sig; + else + git_hashsig_free(sig); + + return error; +} + +int git_hashsig_create_fromfile( + git_hashsig **out, + const char *path, + git_hashsig_option_t opts) +{ + uint8_t buf[0x1000]; + ssize_t buflen = 0; + int error = 0, fd; + hashsig_in_progress prog; + git_hashsig *sig = hashsig_alloc(opts); + GITERR_CHECK_ALLOC(sig); + + if ((fd = git_futils_open_ro(path)) < 0) { + git__free(sig); + return fd; + } + + hashsig_in_progress_init(&prog, sig); + + while (!error) { + if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) { + if ((error = (int)buflen) < 0) + giterr_set(GITERR_OS, + "Read error on '%s' calculating similarity hashes", path); + break; + } + + error = hashsig_add_hashes(sig, buf, buflen, &prog); + } + + p_close(fd); + + if (!error) + error = hashsig_finalize_hashes(sig); + + if (!error) + *out = sig; + else + git_hashsig_free(sig); + + return error; +} + +void git_hashsig_free(git_hashsig *sig) +{ + git__free(sig); +} + +static int hashsig_heap_compare(const hashsig_heap *a, const hashsig_heap *b) +{ + int matches = 0, i, j, cmp; + + assert(a->cmp == b->cmp); + + /* hash heaps are sorted - just look for overlap vs total */ + + for (i = 0, j = 0; i < a->size && j < b->size; ) { + cmp = a->cmp(&a->values[i], &b->values[j], NULL); + + if (cmp < 0) + ++i; + else if (cmp > 0) + ++j; + else { + ++i; ++j; ++matches; + } + } + + return HASHSIG_SCALE * (matches * 2) / (a->size + b->size); +} + +int git_hashsig_compare(const git_hashsig *a, const git_hashsig *b) +{ + /* if we have no elements in either file then each file is either + * empty or blank. if we're ignoring whitespace then the files are + * similar, otherwise they're dissimilar. + */ + if (a->mins.size == 0 && b->mins.size == 0) { + if ((!a->lines && !b->lines) || + (a->opt & GIT_HASHSIG_IGNORE_WHITESPACE)) + return HASHSIG_SCALE; + else + return 0; + } + + /* if we have fewer than the maximum number of elements, then just use + * one array since the two arrays will be the same + */ + if (a->mins.size < HASHSIG_HEAP_SIZE) + return hashsig_heap_compare(&a->mins, &b->mins); + else + return (hashsig_heap_compare(&a->mins, &b->mins) + + hashsig_heap_compare(&a->maxs, &b->maxs)) / 2; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/ident.c b/deps/libgit2-sys-0.2.17/libgit2/src/ident.c new file mode 100644 index 000000000..6bc80abc7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/ident.c @@ -0,0 +1,127 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/sys/filter.h" +#include "filter.h" +#include "buffer.h" +#include "buf_text.h" + +static int ident_find_id( + const char **id_start, const char **id_end, const char *start, size_t len) +{ + const char *end = start + len, *found = NULL; + + while (len > 3 && (found = memchr(start, '$', len)) != NULL) { + size_t remaining = (size_t)(end - found) - 1; + if (remaining < 3) + return GIT_ENOTFOUND; + + start = found + 1; + len = remaining; + + if (start[0] == 'I' && start[1] == 'd') + break; + } + + if (len < 3 || !found) + return GIT_ENOTFOUND; + *id_start = found; + + if ((found = memchr(start + 2, '$', len - 2)) == NULL) + return GIT_ENOTFOUND; + + *id_end = found + 1; + return 0; +} + +static int ident_insert_id( + git_buf *to, const git_buf *from, const git_filter_source *src) +{ + char oid[GIT_OID_HEXSZ+1]; + const char *id_start, *id_end, *from_end = from->ptr + from->size; + size_t need_size; + + /* replace $Id$ with blob id */ + + if (!git_filter_source_id(src)) + return GIT_PASSTHROUGH; + + git_oid_tostr(oid, sizeof(oid), git_filter_source_id(src)); + + if (ident_find_id(&id_start, &id_end, from->ptr, from->size) < 0) + return GIT_PASSTHROUGH; + + need_size = (size_t)(id_start - from->ptr) + + 5 /* "$Id: " */ + GIT_OID_HEXSZ + 1 /* "$" */ + + (size_t)(from_end - id_end); + + if (git_buf_grow(to, need_size) < 0) + return -1; + + git_buf_set(to, from->ptr, (size_t)(id_start - from->ptr)); + git_buf_put(to, "$Id: ", 5); + git_buf_put(to, oid, GIT_OID_HEXSZ); + git_buf_putc(to, '$'); + git_buf_put(to, id_end, (size_t)(from_end - id_end)); + + return git_buf_oom(to) ? -1 : 0; +} + +static int ident_remove_id( + git_buf *to, const git_buf *from) +{ + const char *id_start, *id_end, *from_end = from->ptr + from->size; + size_t need_size; + + if (ident_find_id(&id_start, &id_end, from->ptr, from->size) < 0) + return GIT_PASSTHROUGH; + + need_size = (size_t)(id_start - from->ptr) + + 4 /* "$Id$" */ + (size_t)(from_end - id_end); + + if (git_buf_grow(to, need_size) < 0) + return -1; + + git_buf_set(to, from->ptr, (size_t)(id_start - from->ptr)); + git_buf_put(to, "$Id$", 4); + git_buf_put(to, id_end, (size_t)(from_end - id_end)); + + return git_buf_oom(to) ? -1 : 0; +} + +static int ident_apply( + git_filter *self, + void **payload, + git_buf *to, + const git_buf *from, + const git_filter_source *src) +{ + GIT_UNUSED(self); GIT_UNUSED(payload); + + /* Don't filter binary files */ + if (git_buf_text_is_binary(from)) + return GIT_PASSTHROUGH; + + if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE) + return ident_insert_id(to, from, src); + else + return ident_remove_id(to, from); +} + +git_filter *git_ident_filter_new(void) +{ + git_filter *f = git__calloc(1, sizeof(git_filter)); + if (f == NULL) + return NULL; + + f->version = GIT_FILTER_VERSION; + f->attributes = "+ident"; /* apply to files with ident attribute set */ + f->shutdown = git_filter_free; + f->apply = ident_apply; + + return f; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/ignore.c b/deps/libgit2-sys-0.2.17/libgit2/src/ignore.c new file mode 100644 index 000000000..dd299f076 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/ignore.c @@ -0,0 +1,532 @@ +#include "git2/ignore.h" +#include "common.h" +#include "ignore.h" +#include "attrcache.h" +#include "path.h" +#include "config.h" +#include "fnmatch.h" + +#define GIT_IGNORE_INTERNAL "[internal]exclude" + +#define GIT_IGNORE_DEFAULT_RULES ".\n..\n.git\n" + +/** + * A negative ignore can only unignore a file which is given explicitly before, thus + * + * foo + * !foo/bar + * + * does not unignore 'foo/bar' as it's not in the list. However + * + * foo/ + * !foo/bar + * + * does unignore 'foo/bar', as it is contained within the 'foo/' rule. + */ +static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match) +{ + int error = 0; + size_t i; + git_attr_fnmatch *rule; + char *path; + git_buf buf = GIT_BUF_INIT; + + /* path of the file relative to the workdir, so we match the rules in subdirs */ + if (match->containing_dir) { + git_buf_puts(&buf, match->containing_dir); + } + if (git_buf_puts(&buf, match->pattern) < 0) + return -1; + + path = git_buf_detach(&buf); + + git_vector_foreach(rules, i, rule) { + /* no chance of matching w/o a wilcard */ + if (!(rule->flags & GIT_ATTR_FNMATCH_HASWILD)) + continue; + + /* + * If we're dealing with a directory (which we know via the + * strchr() check) we want to use 'dirname/' as the + * pattern so p_fnmatch() honours FNM_PATHNAME + */ + git_buf_clear(&buf); + if (rule->containing_dir) { + git_buf_puts(&buf, rule->containing_dir); + } + if (!strchr(rule->pattern, '*')) + error = git_buf_printf(&buf, "%s/*", rule->pattern); + else + error = git_buf_puts(&buf, rule->pattern); + + if (error < 0) + goto out; + + + if ((error = p_fnmatch(git_buf_cstr(&buf), path, FNM_PATHNAME)) < 0) { + giterr_set(GITERR_INVALID, "error matching pattern"); + goto out; + } + + /* if we found a match, we want to keep this rule */ + if (error != FNM_NOMATCH) { + *out = 1; + error = 0; + goto out; + } + } + + *out = 0; + error = 0; + +out: + git__free(path); + git_buf_free(&buf); + return error; +} + +static int parse_ignore_file( + git_repository *repo, git_attr_file *attrs, const char *data) +{ + int error = 0; + int ignore_case = false; + const char *scan = data, *context = NULL; + git_attr_fnmatch *match = NULL; + + if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0) + giterr_clear(); + + /* if subdir file path, convert context for file paths */ + if (attrs->entry && + git_path_root(attrs->entry->path) < 0 && + !git__suffixcmp(attrs->entry->path, "/" GIT_IGNORE_FILE)) + context = attrs->entry->path; + + if (git_mutex_lock(&attrs->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock ignore file"); + return -1; + } + + while (!error && *scan) { + int valid_rule = 1; + + if (!match && !(match = git__calloc(1, sizeof(*match)))) { + error = -1; + break; + } + + match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG; + + if (!(error = git_attr_fnmatch__parse( + match, &attrs->pool, context, &scan))) + { + match->flags |= GIT_ATTR_FNMATCH_IGNORE; + + if (ignore_case) + match->flags |= GIT_ATTR_FNMATCH_ICASE; + + scan = git__next_line(scan); + + /* if a negative match doesn't actually do anything, throw it away */ + if (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) + error = does_negate_rule(&valid_rule, &attrs->rules, match); + + if (!error && valid_rule) + error = git_vector_insert(&attrs->rules, match); + } + + if (error != 0 || !valid_rule) { + match->pattern = NULL; + + if (error == GIT_ENOTFOUND) + error = 0; + } else { + match = NULL; /* vector now "owns" the match */ + } + } + + git_mutex_unlock(&attrs->lock); + git__free(match); + + return error; +} + +static int push_ignore_file( + git_ignores *ignores, + git_vector *which_list, + const char *base, + const char *filename) +{ + int error = 0; + git_attr_file *file = NULL; + + error = git_attr_cache__get( + &file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE, + base, filename, parse_ignore_file); + if (error < 0) + return error; + + if (file != NULL) { + if ((error = git_vector_insert(which_list, file)) < 0) + git_attr_file__free(file); + } + + return error; +} + +static int push_one_ignore(void *payload, const char *path) +{ + git_ignores *ign = payload; + ign->depth++; + return push_ignore_file(ign, &ign->ign_path, path, GIT_IGNORE_FILE); +} + +static int get_internal_ignores(git_attr_file **out, git_repository *repo) +{ + int error; + + if ((error = git_attr_cache__init(repo)) < 0) + return error; + + error = git_attr_cache__get( + out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL, GIT_IGNORE_INTERNAL, NULL); + + /* if internal rules list is empty, insert default rules */ + if (!error && !(*out)->rules.length) + error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES); + + return error; +} + +int git_ignore__for_path( + git_repository *repo, + const char *path, + git_ignores *ignores) +{ + int error = 0; + const char *workdir = git_repository_workdir(repo); + + assert(ignores && path); + + memset(ignores, 0, sizeof(*ignores)); + ignores->repo = repo; + + /* Read the ignore_case flag */ + if ((error = git_repository__cvar( + &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0) + goto cleanup; + + if ((error = git_attr_cache__init(repo)) < 0) + goto cleanup; + + /* given a unrooted path in a non-bare repo, resolve it */ + if (workdir && git_path_root(path) < 0) + error = git_path_find_dir(&ignores->dir, path, workdir); + else + error = git_buf_joinpath(&ignores->dir, path, ""); + if (error < 0) + goto cleanup; + + if (workdir && !git__prefixcmp(ignores->dir.ptr, workdir)) + ignores->dir_root = strlen(workdir); + + /* set up internals */ + if ((error = get_internal_ignores(&ignores->ign_internal, repo)) < 0) + goto cleanup; + + /* load .gitignore up the path */ + if (workdir != NULL) { + error = git_path_walk_up( + &ignores->dir, workdir, push_one_ignore, ignores); + if (error < 0) + goto cleanup; + } + + /* load .git/info/exclude */ + error = push_ignore_file( + ignores, &ignores->ign_global, + git_repository_path(repo), GIT_IGNORE_FILE_INREPO); + if (error < 0) + goto cleanup; + + /* load core.excludesfile */ + if (git_repository_attr_cache(repo)->cfg_excl_file != NULL) + error = push_ignore_file( + ignores, &ignores->ign_global, NULL, + git_repository_attr_cache(repo)->cfg_excl_file); + +cleanup: + if (error < 0) + git_ignore__free(ignores); + + return error; +} + +int git_ignore__push_dir(git_ignores *ign, const char *dir) +{ + if (git_buf_joinpath(&ign->dir, ign->dir.ptr, dir) < 0) + return -1; + + ign->depth++; + + return push_ignore_file( + ign, &ign->ign_path, ign->dir.ptr, GIT_IGNORE_FILE); +} + +int git_ignore__pop_dir(git_ignores *ign) +{ + if (ign->ign_path.length > 0) { + git_attr_file *file = git_vector_last(&ign->ign_path); + const char *start = file->entry->path, *end; + + /* - ign->dir looks something like "/home/user/a/b/" (or "a/b/c/d/") + * - file->path looks something like "a/b/.gitignore + * + * We are popping the last directory off ign->dir. We also want + * to remove the file from the vector if the popped directory + * matches the ignore path. We need to test if the "a/b" part of + * the file key matches the path we are about to pop. + */ + + if ((end = strrchr(start, '/')) != NULL) { + size_t dirlen = (end - start) + 1; + const char *relpath = ign->dir.ptr + ign->dir_root; + size_t pathlen = ign->dir.size - ign->dir_root; + + if (pathlen == dirlen && !memcmp(relpath, start, dirlen)) { + git_vector_pop(&ign->ign_path); + git_attr_file__free(file); + } + } + } + + if (--ign->depth > 0) { + git_buf_rtruncate_at_char(&ign->dir, '/'); + git_path_to_dir(&ign->dir); + } + + return 0; +} + +void git_ignore__free(git_ignores *ignores) +{ + unsigned int i; + git_attr_file *file; + + git_attr_file__free(ignores->ign_internal); + + git_vector_foreach(&ignores->ign_path, i, file) { + git_attr_file__free(file); + ignores->ign_path.contents[i] = NULL; + } + git_vector_free(&ignores->ign_path); + + git_vector_foreach(&ignores->ign_global, i, file) { + git_attr_file__free(file); + ignores->ign_global.contents[i] = NULL; + } + git_vector_free(&ignores->ign_global); + + git_buf_free(&ignores->dir); +} + +static bool ignore_lookup_in_rules( + int *ignored, git_attr_file *file, git_attr_path *path) +{ + size_t j; + git_attr_fnmatch *match; + + git_vector_rforeach(&file->rules, j, match) { + if (git_attr_fnmatch__match(match, path)) { + *ignored = ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0) ? + GIT_IGNORE_TRUE : GIT_IGNORE_FALSE; + return true; + } + } + + return false; +} + +int git_ignore__lookup( + int *out, git_ignores *ignores, const char *pathname) +{ + unsigned int i; + git_attr_file *file; + git_attr_path path; + + *out = GIT_IGNORE_NOTFOUND; + + if (git_attr_path__init( + &path, pathname, git_repository_workdir(ignores->repo)) < 0) + return -1; + + /* first process builtins - success means path was found */ + if (ignore_lookup_in_rules(out, ignores->ign_internal, &path)) + goto cleanup; + + /* next process files in the path */ + git_vector_foreach(&ignores->ign_path, i, file) { + if (ignore_lookup_in_rules(out, file, &path)) + goto cleanup; + } + + /* last process global ignores */ + git_vector_foreach(&ignores->ign_global, i, file) { + if (ignore_lookup_in_rules(out, file, &path)) + goto cleanup; + } + +cleanup: + git_attr_path__free(&path); + return 0; +} + +int git_ignore_add_rule(git_repository *repo, const char *rules) +{ + int error; + git_attr_file *ign_internal = NULL; + + if ((error = get_internal_ignores(&ign_internal, repo)) < 0) + return error; + + error = parse_ignore_file(repo, ign_internal, rules); + git_attr_file__free(ign_internal); + + return error; +} + +int git_ignore_clear_internal_rules(git_repository *repo) +{ + int error; + git_attr_file *ign_internal; + + if ((error = get_internal_ignores(&ign_internal, repo)) < 0) + return error; + + if (!(error = git_attr_file__clear_rules(ign_internal, true))) + error = parse_ignore_file( + repo, ign_internal, GIT_IGNORE_DEFAULT_RULES); + + git_attr_file__free(ign_internal); + return error; +} + +int git_ignore_path_is_ignored( + int *ignored, + git_repository *repo, + const char *pathname) +{ + int error; + const char *workdir; + git_attr_path path; + git_ignores ignores; + unsigned int i; + git_attr_file *file; + + assert(ignored && pathname); + + workdir = repo ? git_repository_workdir(repo) : NULL; + + memset(&path, 0, sizeof(path)); + memset(&ignores, 0, sizeof(ignores)); + + if ((error = git_attr_path__init(&path, pathname, workdir)) < 0 || + (error = git_ignore__for_path(repo, path.path, &ignores)) < 0) + goto cleanup; + + while (1) { + /* first process builtins - success means path was found */ + if (ignore_lookup_in_rules(ignored, ignores.ign_internal, &path)) + goto cleanup; + + /* next process files in the path */ + git_vector_foreach(&ignores.ign_path, i, file) { + if (ignore_lookup_in_rules(ignored, file, &path)) + goto cleanup; + } + + /* last process global ignores */ + git_vector_foreach(&ignores.ign_global, i, file) { + if (ignore_lookup_in_rules(ignored, file, &path)) + goto cleanup; + } + + /* move up one directory */ + if (path.basename == path.path) + break; + path.basename[-1] = '\0'; + while (path.basename > path.path && *path.basename != '/') + path.basename--; + if (path.basename > path.path) + path.basename++; + path.is_dir = 1; + + if ((error = git_ignore__pop_dir(&ignores)) < 0) + break; + } + + *ignored = 0; + +cleanup: + git_attr_path__free(&path); + git_ignore__free(&ignores); + return error; +} + +int git_ignore__check_pathspec_for_exact_ignores( + git_repository *repo, + git_vector *vspec, + bool no_fnmatch) +{ + int error = 0; + size_t i; + git_attr_fnmatch *match; + int ignored; + git_buf path = GIT_BUF_INIT; + const char *wd, *filename; + git_index *idx; + + if ((error = git_repository__ensure_not_bare( + repo, "validate pathspec")) < 0 || + (error = git_repository_index(&idx, repo)) < 0) + return error; + + wd = git_repository_workdir(repo); + + git_vector_foreach(vspec, i, match) { + /* skip wildcard matches (if they are being used) */ + if ((match->flags & GIT_ATTR_FNMATCH_HASWILD) != 0 && + !no_fnmatch) + continue; + + filename = match->pattern; + + /* if file is already in the index, it's fine */ + if (git_index_get_bypath(idx, filename, 0) != NULL) + continue; + + if ((error = git_buf_joinpath(&path, wd, filename)) < 0) + break; + + /* is there a file on disk that matches this exactly? */ + if (!git_path_isfile(path.ptr)) + continue; + + /* is that file ignored? */ + if ((error = git_ignore_path_is_ignored(&ignored, repo, filename)) < 0) + break; + + if (ignored) { + giterr_set(GITERR_INVALID, "pathspec contains ignored file '%s'", + filename); + error = GIT_EINVALIDSPEC; + break; + } + } + + git_index_free(idx); + git_buf_free(&path); + + return error; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/ignore.h b/deps/libgit2-sys-0.2.17/libgit2/src/ignore.h new file mode 100644 index 000000000..77668c661 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/ignore.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_ignore_h__ +#define INCLUDE_ignore_h__ + +#include "repository.h" +#include "vector.h" +#include "attr_file.h" + +#define GIT_IGNORE_FILE ".gitignore" +#define GIT_IGNORE_FILE_INREPO "info/exclude" +#define GIT_IGNORE_FILE_XDG "ignore" + +/* The git_ignores structure maintains three sets of ignores: + * - internal ignores + * - per directory ignores + * - global ignores (at lower priority than the others) + * As you traverse from one directory to another, you can push and pop + * directories onto git_ignores list efficiently. + */ +typedef struct { + git_repository *repo; + git_buf dir; /* current directory reflected in ign_path */ + git_attr_file *ign_internal; + git_vector ign_path; + git_vector ign_global; + size_t dir_root; /* offset in dir to repo root */ + int ignore_case; + int depth; +} git_ignores; + +extern int git_ignore__for_path( + git_repository *repo, const char *path, git_ignores *ign); + +extern int git_ignore__push_dir(git_ignores *ign, const char *dir); + +extern int git_ignore__pop_dir(git_ignores *ign); + +extern void git_ignore__free(git_ignores *ign); + +enum { + GIT_IGNORE_UNCHECKED = -2, + GIT_IGNORE_NOTFOUND = -1, + GIT_IGNORE_FALSE = 0, + GIT_IGNORE_TRUE = 1, +}; + +extern int git_ignore__lookup(int *out, git_ignores *ign, const char *path); + +/* command line Git sometimes generates an error message if given a + * pathspec that contains an exact match to an ignored file (provided + * --force isn't also given). This makes it easy to check it that has + * happened. Returns GIT_EINVALIDSPEC if the pathspec contains ignored + * exact matches (that are not already present in the index). + */ +extern int git_ignore__check_pathspec_for_exact_ignores( + git_repository *repo, git_vector *pathspec, bool no_fnmatch); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/index.c b/deps/libgit2-sys-0.2.17/libgit2/src/index.c new file mode 100644 index 000000000..dbcc37a58 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/index.c @@ -0,0 +1,2805 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include + +#include "common.h" +#include "repository.h" +#include "index.h" +#include "tree.h" +#include "tree-cache.h" +#include "hash.h" +#include "iterator.h" +#include "pathspec.h" +#include "ignore.h" +#include "blob.h" + +#include "git2/odb.h" +#include "git2/oid.h" +#include "git2/blob.h" +#include "git2/config.h" +#include "git2/sys/index.h" + +#define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7) +#define short_entry_size(len) entry_size(struct entry_short, len) +#define long_entry_size(len) entry_size(struct entry_long, len) + +#define minimal_entry_size (offsetof(struct entry_short, path)) + +static const size_t INDEX_FOOTER_SIZE = GIT_OID_RAWSZ; +static const size_t INDEX_HEADER_SIZE = 12; + +static const unsigned int INDEX_VERSION_NUMBER = 2; +static const unsigned int INDEX_VERSION_NUMBER_EXT = 3; + +static const unsigned int INDEX_HEADER_SIG = 0x44495243; +static const char INDEX_EXT_TREECACHE_SIG[] = {'T', 'R', 'E', 'E'}; +static const char INDEX_EXT_UNMERGED_SIG[] = {'R', 'E', 'U', 'C'}; +static const char INDEX_EXT_CONFLICT_NAME_SIG[] = {'N', 'A', 'M', 'E'}; + +#define INDEX_OWNER(idx) ((git_repository *)(GIT_REFCOUNT_OWNER(idx))) + +struct index_header { + uint32_t signature; + uint32_t version; + uint32_t entry_count; +}; + +struct index_extension { + char signature[4]; + uint32_t extension_size; +}; + +struct entry_time { + uint32_t seconds; + uint32_t nanoseconds; +}; + +struct entry_short { + struct entry_time ctime; + struct entry_time mtime; + uint32_t dev; + uint32_t ino; + uint32_t mode; + uint32_t uid; + uint32_t gid; + uint32_t file_size; + git_oid oid; + uint16_t flags; + char path[1]; /* arbitrary length */ +}; + +struct entry_long { + struct entry_time ctime; + struct entry_time mtime; + uint32_t dev; + uint32_t ino; + uint32_t mode; + uint32_t uid; + uint32_t gid; + uint32_t file_size; + git_oid oid; + uint16_t flags; + uint16_t flags_extended; + char path[1]; /* arbitrary length */ +}; + +struct entry_srch_key { + const char *path; + size_t pathlen; + int stage; +}; + +struct entry_internal { + git_index_entry entry; + size_t pathlen; + char path[GIT_FLEX_ARRAY]; +}; + +struct reuc_entry_internal { + git_index_reuc_entry entry; + size_t pathlen; + char path[GIT_FLEX_ARRAY]; +}; + +/* local declarations */ +static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size); +static int read_header(struct index_header *dest, const void *buffer); + +static int parse_index(git_index *index, const char *buffer, size_t buffer_size); +static bool is_index_extended(git_index *index); +static int write_index(git_index *index, git_filebuf *file); + +static void index_entry_free(git_index_entry *entry); +static void index_entry_reuc_free(git_index_reuc_entry *reuc); + +int git_index_entry_srch(const void *key, const void *array_member) +{ + const struct entry_srch_key *srch_key = key; + const struct entry_internal *entry = array_member; + int cmp; + size_t len1, len2, len; + + len1 = srch_key->pathlen; + len2 = entry->pathlen; + len = len1 < len2 ? len1 : len2; + + cmp = memcmp(srch_key->path, entry->path, len); + if (cmp) + return cmp; + if (len1 < len2) + return -1; + if (len1 > len2) + return 1; + + if (srch_key->stage != GIT_INDEX_STAGE_ANY) + return srch_key->stage - GIT_IDXENTRY_STAGE(&entry->entry); + + return 0; +} + +int git_index_entry_isrch(const void *key, const void *array_member) +{ + const struct entry_srch_key *srch_key = key; + const struct entry_internal *entry = array_member; + int cmp; + size_t len1, len2, len; + + len1 = srch_key->pathlen; + len2 = entry->pathlen; + len = len1 < len2 ? len1 : len2; + + cmp = strncasecmp(srch_key->path, entry->path, len); + + if (cmp) + return cmp; + if (len1 < len2) + return -1; + if (len1 > len2) + return 1; + + if (srch_key->stage != GIT_INDEX_STAGE_ANY) + return srch_key->stage - GIT_IDXENTRY_STAGE(&entry->entry); + + return 0; +} + +static int index_entry_srch_path(const void *path, const void *array_member) +{ + const git_index_entry *entry = array_member; + + return strcmp((const char *)path, entry->path); +} + +static int index_entry_isrch_path(const void *path, const void *array_member) +{ + const git_index_entry *entry = array_member; + + return strcasecmp((const char *)path, entry->path); +} + +int git_index_entry_cmp(const void *a, const void *b) +{ + int diff; + const git_index_entry *entry_a = a; + const git_index_entry *entry_b = b; + + diff = strcmp(entry_a->path, entry_b->path); + + if (diff == 0) + diff = (GIT_IDXENTRY_STAGE(entry_a) - GIT_IDXENTRY_STAGE(entry_b)); + + return diff; +} + +int git_index_entry_icmp(const void *a, const void *b) +{ + int diff; + const git_index_entry *entry_a = a; + const git_index_entry *entry_b = b; + + diff = strcasecmp(entry_a->path, entry_b->path); + + if (diff == 0) + diff = (GIT_IDXENTRY_STAGE(entry_a) - GIT_IDXENTRY_STAGE(entry_b)); + + return diff; +} + +static int conflict_name_cmp(const void *a, const void *b) +{ + const git_index_name_entry *name_a = a; + const git_index_name_entry *name_b = b; + + if (name_a->ancestor && !name_b->ancestor) + return 1; + + if (!name_a->ancestor && name_b->ancestor) + return -1; + + if (name_a->ancestor) + return strcmp(name_a->ancestor, name_b->ancestor); + + if (!name_a->ours || !name_b->ours) + return 0; + + return strcmp(name_a->ours, name_b->ours); +} + +/** + * TODO: enable this when resolving case insensitive conflicts + */ +#if 0 +static int conflict_name_icmp(const void *a, const void *b) +{ + const git_index_name_entry *name_a = a; + const git_index_name_entry *name_b = b; + + if (name_a->ancestor && !name_b->ancestor) + return 1; + + if (!name_a->ancestor && name_b->ancestor) + return -1; + + if (name_a->ancestor) + return strcasecmp(name_a->ancestor, name_b->ancestor); + + if (!name_a->ours || !name_b->ours) + return 0; + + return strcasecmp(name_a->ours, name_b->ours); +} +#endif + +static int reuc_srch(const void *key, const void *array_member) +{ + const git_index_reuc_entry *reuc = array_member; + + return strcmp(key, reuc->path); +} + +static int reuc_isrch(const void *key, const void *array_member) +{ + const git_index_reuc_entry *reuc = array_member; + + return strcasecmp(key, reuc->path); +} + +static int reuc_cmp(const void *a, const void *b) +{ + const git_index_reuc_entry *info_a = a; + const git_index_reuc_entry *info_b = b; + + return strcmp(info_a->path, info_b->path); +} + +static int reuc_icmp(const void *a, const void *b) +{ + const git_index_reuc_entry *info_a = a; + const git_index_reuc_entry *info_b = b; + + return strcasecmp(info_a->path, info_b->path); +} + +static void index_entry_reuc_free(git_index_reuc_entry *reuc) +{ + git__free(reuc); +} + +static void index_entry_free(git_index_entry *entry) +{ + if (!entry) + return; + + memset(&entry->id, 0, sizeof(entry->id)); + git__free(entry); +} + +unsigned int git_index__create_mode(unsigned int mode) +{ + if (S_ISLNK(mode)) + return S_IFLNK; + + if (S_ISDIR(mode) || (mode & S_IFMT) == (S_IFLNK | S_IFDIR)) + return (S_IFLNK | S_IFDIR); + + return S_IFREG | GIT_PERMS_CANONICAL(mode); +} + +static unsigned int index_merge_mode( + git_index *index, git_index_entry *existing, unsigned int mode) +{ + if (index->no_symlinks && S_ISREG(mode) && + existing && S_ISLNK(existing->mode)) + return existing->mode; + + if (index->distrust_filemode && S_ISREG(mode)) + return (existing && S_ISREG(existing->mode)) ? + existing->mode : git_index__create_mode(0666); + + return git_index__create_mode(mode); +} + +static int index_sort_if_needed(git_index *index, bool need_lock) +{ + /* not truly threadsafe because between when this checks and/or + * sorts the array another thread could come in and unsort it + */ + + if (git_vector_is_sorted(&index->entries)) + return 0; + + if (need_lock && git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Unable to lock index"); + return -1; + } + + git_vector_sort(&index->entries); + + if (need_lock) + git_mutex_unlock(&index->lock); + + return 0; +} + +GIT_INLINE(int) index_find_in_entries( + size_t *out, git_vector *entries, git_vector_cmp entry_srch, + const char *path, size_t path_len, int stage) +{ + struct entry_srch_key srch_key; + srch_key.path = path; + srch_key.pathlen = !path_len ? strlen(path) : path_len; + srch_key.stage = stage; + return git_vector_bsearch2(out, entries, entry_srch, &srch_key); +} + +GIT_INLINE(int) index_find( + size_t *out, git_index *index, + const char *path, size_t path_len, int stage, bool need_lock) +{ + if (index_sort_if_needed(index, need_lock) < 0) + return -1; + + return index_find_in_entries( + out, &index->entries, index->entries_search, path, path_len, stage); +} + +void git_index__set_ignore_case(git_index *index, bool ignore_case) +{ + index->ignore_case = ignore_case; + + if (ignore_case) { + index->entries_cmp_path = git__strcasecmp_cb; + index->entries_search = git_index_entry_isrch; + index->entries_search_path = index_entry_isrch_path; + index->reuc_search = reuc_isrch; + } else { + index->entries_cmp_path = git__strcmp_cb; + index->entries_search = git_index_entry_srch; + index->entries_search_path = index_entry_srch_path; + index->reuc_search = reuc_srch; + } + + git_vector_set_cmp(&index->entries, + ignore_case ? git_index_entry_icmp : git_index_entry_cmp); + index_sort_if_needed(index, true); + + git_vector_set_cmp(&index->reuc, ignore_case ? reuc_icmp : reuc_cmp); + git_vector_sort(&index->reuc); +} + +int git_index_open(git_index **index_out, const char *index_path) +{ + git_index *index; + int error = -1; + + assert(index_out); + + index = git__calloc(1, sizeof(git_index)); + GITERR_CHECK_ALLOC(index); + + if (git_mutex_init(&index->lock)) { + giterr_set(GITERR_OS, "Failed to initialize lock"); + git__free(index); + return -1; + } + + git_pool_init(&index->tree_pool, 1, 0); + + if (index_path != NULL) { + index->index_file_path = git__strdup(index_path); + if (!index->index_file_path) + goto fail; + + /* Check if index file is stored on disk already */ + if (git_path_exists(index->index_file_path) == true) + index->on_disk = 1; + } + + if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 || + git_vector_init(&index->names, 8, conflict_name_cmp) < 0 || + git_vector_init(&index->reuc, 8, reuc_cmp) < 0 || + git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0) + goto fail; + + index->entries_cmp_path = git__strcmp_cb; + index->entries_search = git_index_entry_srch; + index->entries_search_path = index_entry_srch_path; + index->reuc_search = reuc_srch; + + if (index_path != NULL && (error = git_index_read(index, true)) < 0) + goto fail; + + *index_out = index; + GIT_REFCOUNT_INC(index); + + return 0; + +fail: + git_pool_clear(&index->tree_pool); + git_index_free(index); + return error; +} + +int git_index_new(git_index **out) +{ + return git_index_open(out, NULL); +} + +static void index_free(git_index *index) +{ + /* index iterators increment the refcount of the index, so if we + * get here then there should be no outstanding iterators. + */ + assert(!git_atomic_get(&index->readers)); + + git_index_clear(index); + git_vector_free(&index->entries); + git_vector_free(&index->names); + git_vector_free(&index->reuc); + git_vector_free(&index->deleted); + + git__free(index->index_file_path); + git_mutex_free(&index->lock); + + git__memzero(index, sizeof(*index)); + git__free(index); +} + +void git_index_free(git_index *index) +{ + if (index == NULL) + return; + + GIT_REFCOUNT_DEC(index, index_free); +} + +/* call with locked index */ +static void index_free_deleted(git_index *index) +{ + int readers = (int)git_atomic_get(&index->readers); + size_t i; + + if (readers > 0 || !index->deleted.length) + return; + + for (i = 0; i < index->deleted.length; ++i) { + git_index_entry *ie = git__swap(index->deleted.contents[i], NULL); + index_entry_free(ie); + } + + git_vector_clear(&index->deleted); +} + +/* call with locked index */ +static int index_remove_entry(git_index *index, size_t pos) +{ + int error = 0; + git_index_entry *entry = git_vector_get(&index->entries, pos); + + if (entry != NULL) + git_tree_cache_invalidate_path(index->tree, entry->path); + + error = git_vector_remove(&index->entries, pos); + + if (!error) { + if (git_atomic_get(&index->readers) > 0) { + error = git_vector_insert(&index->deleted, entry); + } else { + index_entry_free(entry); + } + } + + return error; +} + +int git_index_clear(git_index *index) +{ + int error = 0; + + assert(index); + + index->tree = NULL; + git_pool_clear(&index->tree_pool); + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock index"); + return -1; + } + + while (!error && index->entries.length > 0) + error = index_remove_entry(index, index->entries.length - 1); + index_free_deleted(index); + + git_index_reuc_clear(index); + git_index_name_clear(index); + + git_futils_filestamp_set(&index->stamp, NULL); + + git_mutex_unlock(&index->lock); + + return error; +} + +static int create_index_error(int error, const char *msg) +{ + giterr_set(GITERR_INDEX, msg); + return error; +} + +int git_index_set_caps(git_index *index, int caps) +{ + unsigned int old_ignore_case; + + assert(index); + + old_ignore_case = index->ignore_case; + + if (caps == GIT_INDEXCAP_FROM_OWNER) { + git_repository *repo = INDEX_OWNER(index); + int val; + + if (!repo) + return create_index_error( + -1, "Cannot access repository to set index caps"); + + if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE)) + index->ignore_case = (val != 0); + if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE)) + index->distrust_filemode = (val == 0); + if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS)) + index->no_symlinks = (val == 0); + } + else { + index->ignore_case = ((caps & GIT_INDEXCAP_IGNORE_CASE) != 0); + index->distrust_filemode = ((caps & GIT_INDEXCAP_NO_FILEMODE) != 0); + index->no_symlinks = ((caps & GIT_INDEXCAP_NO_SYMLINKS) != 0); + } + + if (old_ignore_case != index->ignore_case) { + git_index__set_ignore_case(index, (bool)index->ignore_case); + } + + return 0; +} + +int git_index_caps(const git_index *index) +{ + return ((index->ignore_case ? GIT_INDEXCAP_IGNORE_CASE : 0) | + (index->distrust_filemode ? GIT_INDEXCAP_NO_FILEMODE : 0) | + (index->no_symlinks ? GIT_INDEXCAP_NO_SYMLINKS : 0)); +} + +int git_index_read(git_index *index, int force) +{ + int error = 0, updated; + git_buf buffer = GIT_BUF_INIT; + git_futils_filestamp stamp = index->stamp; + + if (!index->index_file_path) + return create_index_error(-1, + "Failed to read index: The index is in-memory only"); + + index->on_disk = git_path_exists(index->index_file_path); + + if (!index->on_disk) { + if (force) + return git_index_clear(index); + return 0; + } + + updated = git_futils_filestamp_check(&stamp, index->index_file_path); + if (updated < 0) { + giterr_set( + GITERR_INDEX, + "Failed to read index: '%s' no longer exists", + index->index_file_path); + return updated; + } + if (!updated && !force) + return 0; + + error = git_futils_readbuffer(&buffer, index->index_file_path); + if (error < 0) + return error; + + index->tree = NULL; + git_pool_clear(&index->tree_pool); + + error = git_index_clear(index); + + if (!error) + error = parse_index(index, buffer.ptr, buffer.size); + + if (!error) + git_futils_filestamp_set(&index->stamp, &stamp); + + git_buf_free(&buffer); + return error; +} + +int git_index__changed_relative_to( + git_index *index, const git_futils_filestamp *fs) +{ + /* attempt to update index (ignoring errors) */ + if (git_index_read(index, false) < 0) + giterr_clear(); + + return (index->stamp.mtime != fs->mtime || + index->stamp.size != fs->size || + index->stamp.ino != fs->ino); +} + +int git_index_write(git_index *index) +{ + git_indexwriter writer = GIT_INDEXWRITER_INIT; + int error; + + if ((error = git_indexwriter_init(&writer, index)) == 0) + error = git_indexwriter_commit(&writer); + + git_indexwriter_cleanup(&writer); + + return error; +} + +const char * git_index_path(const git_index *index) +{ + assert(index); + return index->index_file_path; +} + +int git_index_write_tree(git_oid *oid, git_index *index) +{ + git_repository *repo; + + assert(oid && index); + + repo = INDEX_OWNER(index); + + if (repo == NULL) + return create_index_error(-1, "Failed to write tree. " + "The index file is not backed up by an existing repository"); + + return git_tree__write_index(oid, index, repo); +} + +int git_index_write_tree_to( + git_oid *oid, git_index *index, git_repository *repo) +{ + assert(oid && index && repo); + return git_tree__write_index(oid, index, repo); +} + +size_t git_index_entrycount(const git_index *index) +{ + assert(index); + return index->entries.length; +} + +const git_index_entry *git_index_get_byindex( + git_index *index, size_t n) +{ + assert(index); + if (index_sort_if_needed(index, true) < 0) + return NULL; + return git_vector_get(&index->entries, n); +} + +const git_index_entry *git_index_get_bypath( + git_index *index, const char *path, int stage) +{ + size_t pos; + + assert(index); + + if (index_find(&pos, index, path, 0, stage, true) < 0) { + giterr_set(GITERR_INDEX, "Index does not contain %s", path); + return NULL; + } + + return git_index_get_byindex(index, pos); +} + +void git_index_entry__init_from_stat( + git_index_entry *entry, struct stat *st, bool trust_mode) +{ + entry->ctime.seconds = (git_time_t)st->st_ctime; + entry->mtime.seconds = (git_time_t)st->st_mtime; + /* entry->mtime.nanoseconds = st->st_mtimensec; */ + /* entry->ctime.nanoseconds = st->st_ctimensec; */ + entry->dev = st->st_rdev; + entry->ino = st->st_ino; + entry->mode = (!trust_mode && S_ISREG(st->st_mode)) ? + git_index__create_mode(0666) : git_index__create_mode(st->st_mode); + entry->uid = st->st_uid; + entry->gid = st->st_gid; + entry->file_size = st->st_size; +} + +static int index_entry_create( + git_index_entry **out, + git_repository *repo, + const char *path) +{ + size_t pathlen = strlen(path), alloclen; + struct entry_internal *entry; + + if (!git_path_isvalid(repo, path, + GIT_PATH_REJECT_DEFAULTS | GIT_PATH_REJECT_DOT_GIT)) { + giterr_set(GITERR_INDEX, "Invalid path: '%s'", path); + return -1; + } + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(struct entry_internal), pathlen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + entry = git__calloc(1, alloclen); + GITERR_CHECK_ALLOC(entry); + + entry->pathlen = pathlen; + memcpy(entry->path, path, pathlen); + entry->entry.path = entry->path; + + *out = (git_index_entry *)entry; + return 0; +} + +static int index_entry_init( + git_index_entry **entry_out, + git_index *index, + const char *rel_path) +{ + int error = 0; + git_index_entry *entry = NULL; + struct stat st; + git_oid oid; + + if (INDEX_OWNER(index) == NULL) + return create_index_error(-1, + "Could not initialize index entry. " + "Index is not backed up by an existing repository."); + + if (index_entry_create(&entry, INDEX_OWNER(index), rel_path) < 0) + return -1; + + /* write the blob to disk and get the oid and stat info */ + error = git_blob__create_from_paths( + &oid, &st, INDEX_OWNER(index), NULL, rel_path, 0, true); + + if (error < 0) { + index_entry_free(entry); + return error; + } + + entry->id = oid; + git_index_entry__init_from_stat(entry, &st, !index->distrust_filemode); + + *entry_out = (git_index_entry *)entry; + return 0; +} + +static git_index_reuc_entry *reuc_entry_alloc(const char *path) +{ + size_t pathlen = strlen(path), + structlen = sizeof(struct reuc_entry_internal), + alloclen; + struct reuc_entry_internal *entry; + + if (GIT_ADD_SIZET_OVERFLOW(&alloclen, structlen, pathlen) || + GIT_ADD_SIZET_OVERFLOW(&alloclen, alloclen, 1)) + return NULL; + + entry = git__calloc(1, alloclen); + if (!entry) + return NULL; + + entry->pathlen = pathlen; + memcpy(entry->path, path, pathlen); + entry->entry.path = entry->path; + + return (git_index_reuc_entry *)entry; +} + +static int index_entry_reuc_init(git_index_reuc_entry **reuc_out, + const char *path, + int ancestor_mode, const git_oid *ancestor_oid, + int our_mode, const git_oid *our_oid, + int their_mode, const git_oid *their_oid) +{ + git_index_reuc_entry *reuc = NULL; + + assert(reuc_out && path); + + *reuc_out = reuc = reuc_entry_alloc(path); + GITERR_CHECK_ALLOC(reuc); + + if ((reuc->mode[0] = ancestor_mode) > 0) + git_oid_cpy(&reuc->oid[0], ancestor_oid); + + if ((reuc->mode[1] = our_mode) > 0) + git_oid_cpy(&reuc->oid[1], our_oid); + + if ((reuc->mode[2] = their_mode) > 0) + git_oid_cpy(&reuc->oid[2], their_oid); + + return 0; +} + +static void index_entry_cpy(git_index_entry *tgt, const git_index_entry *src) +{ + const char *tgt_path = tgt->path; + memcpy(tgt, src, sizeof(*tgt)); + tgt->path = tgt_path; /* reset to existing path data */ +} + +static int index_entry_dup( + git_index_entry **out, + git_repository *repo, + const git_index_entry *src) +{ + git_index_entry *entry; + + if (!src) { + *out = NULL; + return 0; + } + + if (index_entry_create(&entry, repo, src->path) < 0) + return -1; + + index_entry_cpy(entry, src); + *out = entry; + return 0; +} + +static int has_file_name(git_index *index, + const git_index_entry *entry, size_t pos, int ok_to_replace) +{ + int retval = 0; + size_t len = strlen(entry->path); + int stage = GIT_IDXENTRY_STAGE(entry); + const char *name = entry->path; + + while (pos < index->entries.length) { + struct entry_internal *p = index->entries.contents[pos++]; + + if (len >= p->pathlen) + break; + if (memcmp(name, p->path, len)) + break; + if (GIT_IDXENTRY_STAGE(&p->entry) != stage) + continue; + if (p->path[len] != '/') + continue; + retval = -1; + if (!ok_to_replace) + break; + + if (index_remove_entry(index, --pos) < 0) + break; + } + return retval; +} + +/* + * Do we have another file with a pathname that is a proper + * subset of the name we're trying to add? + */ +static int has_dir_name(git_index *index, + const git_index_entry *entry, int ok_to_replace) +{ + int retval = 0; + int stage = GIT_IDXENTRY_STAGE(entry); + const char *name = entry->path; + const char *slash = name + strlen(name); + + for (;;) { + size_t len, pos; + + for (;;) { + if (*--slash == '/') + break; + if (slash <= entry->path) + return retval; + } + len = slash - name; + + if (!index_find(&pos, index, name, len, stage, false)) { + retval = -1; + if (!ok_to_replace) + break; + + if (index_remove_entry(index, pos) < 0) + break; + continue; + } + + /* + * Trivial optimization: if we find an entry that + * already matches the sub-directory, then we know + * we're ok, and we can exit. + */ + for (; pos < index->entries.length; ++pos) { + struct entry_internal *p = index->entries.contents[pos]; + + if (p->pathlen <= len || + p->path[len] != '/' || + memcmp(p->path, name, len)) + break; /* not our subdirectory */ + + if (GIT_IDXENTRY_STAGE(&p->entry) == stage) + return retval; + } + } + + return retval; +} + +static int check_file_directory_collision(git_index *index, + git_index_entry *entry, size_t pos, int ok_to_replace) +{ + int retval = has_file_name(index, entry, pos, ok_to_replace); + retval = retval + has_dir_name(index, entry, ok_to_replace); + + if (retval) { + giterr_set(GITERR_INDEX, + "'%s' appears as both a file and a directory", entry->path); + return -1; + } + + return 0; +} + +static int index_no_dups(void **old, void *new) +{ + const git_index_entry *entry = new; + GIT_UNUSED(old); + giterr_set(GITERR_INDEX, "'%s' appears multiple times at stage %d", + entry->path, GIT_IDXENTRY_STAGE(entry)); + return GIT_EEXISTS; +} + +/* index_insert takes ownership of the new entry - if it can't insert + * it, then it will return an error **and also free the entry**. When + * it replaces an existing entry, it will update the entry_ptr with the + * actual entry in the index (and free the passed in one). + */ +static int index_insert( + git_index *index, git_index_entry **entry_ptr, int replace) +{ + int error = 0; + size_t path_length, position; + git_index_entry *existing = NULL, *entry; + + assert(index && entry_ptr); + + entry = *entry_ptr; + + /* make sure that the path length flag is correct */ + path_length = ((struct entry_internal *)entry)->pathlen; + + entry->flags &= ~GIT_IDXENTRY_NAMEMASK; + + if (path_length < GIT_IDXENTRY_NAMEMASK) + entry->flags |= path_length & GIT_IDXENTRY_NAMEMASK; + else + entry->flags |= GIT_IDXENTRY_NAMEMASK; + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire index lock"); + return -1; + } + + git_vector_sort(&index->entries); + + /* look if an entry with this path already exists */ + if (!index_find( + &position, index, entry->path, 0, GIT_IDXENTRY_STAGE(entry), false)) { + existing = index->entries.contents[position]; + /* update filemode to existing values if stat is not trusted */ + entry->mode = index_merge_mode(index, existing, entry->mode); + } + + /* look for tree / blob name collisions, removing conflicts if requested */ + error = check_file_directory_collision(index, entry, position, replace); + if (error < 0) + /* skip changes */; + + /* if we are replacing an existing item, overwrite the existing entry + * and return it in place of the passed in one. + */ + else if (existing) { + if (replace) + index_entry_cpy(existing, entry); + index_entry_free(entry); + *entry_ptr = entry = existing; + } + else { + /* if replace is not requested or no existing entry exists, insert + * at the sorted position. (Since we re-sort after each insert to + * check for dups, this is actually cheaper in the long run.) + */ + error = git_vector_insert_sorted(&index->entries, entry, index_no_dups); + } + + if (error < 0) { + index_entry_free(*entry_ptr); + *entry_ptr = NULL; + } + + git_mutex_unlock(&index->lock); + + return error; +} + +static int index_conflict_to_reuc(git_index *index, const char *path) +{ + const git_index_entry *conflict_entries[3]; + int ancestor_mode, our_mode, their_mode; + git_oid const *ancestor_oid, *our_oid, *their_oid; + int ret; + + if ((ret = git_index_conflict_get(&conflict_entries[0], + &conflict_entries[1], &conflict_entries[2], index, path)) < 0) + return ret; + + ancestor_mode = conflict_entries[0] == NULL ? 0 : conflict_entries[0]->mode; + our_mode = conflict_entries[1] == NULL ? 0 : conflict_entries[1]->mode; + their_mode = conflict_entries[2] == NULL ? 0 : conflict_entries[2]->mode; + + ancestor_oid = conflict_entries[0] == NULL ? NULL : &conflict_entries[0]->id; + our_oid = conflict_entries[1] == NULL ? NULL : &conflict_entries[1]->id; + their_oid = conflict_entries[2] == NULL ? NULL : &conflict_entries[2]->id; + + if ((ret = git_index_reuc_add(index, path, ancestor_mode, ancestor_oid, + our_mode, our_oid, their_mode, their_oid)) >= 0) + ret = git_index_conflict_remove(index, path); + + return ret; +} + +static bool valid_filemode(const int filemode) +{ + return (filemode == GIT_FILEMODE_BLOB || + filemode == GIT_FILEMODE_BLOB_EXECUTABLE || + filemode == GIT_FILEMODE_LINK || + filemode == GIT_FILEMODE_COMMIT); +} + +int git_index_add_frombuffer( + git_index *index, const git_index_entry *source_entry, + const void *buffer, size_t len) +{ + git_index_entry *entry = NULL; + int error = 0; + git_oid id; + + assert(index && source_entry->path); + + if (INDEX_OWNER(index) == NULL) + return create_index_error(-1, + "Could not initialize index entry. " + "Index is not backed up by an existing repository."); + + if (!valid_filemode(source_entry->mode)) { + giterr_set(GITERR_INDEX, "invalid filemode"); + return -1; + } + + if (index_entry_dup(&entry, INDEX_OWNER(index), source_entry) < 0) + return -1; + + error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len); + if (error < 0) { + index_entry_free(entry); + return error; + } + + git_oid_cpy(&entry->id, &id); + entry->file_size = len; + + if ((error = index_insert(index, &entry, 1)) < 0) + return error; + + /* Adding implies conflict was resolved, move conflict entries to REUC */ + if ((error = index_conflict_to_reuc(index, entry->path)) < 0 && error != GIT_ENOTFOUND) + return error; + + git_tree_cache_invalidate_path(index->tree, entry->path); + return 0; +} + + +int git_index_add_bypath(git_index *index, const char *path) +{ + git_index_entry *entry = NULL; + int ret; + + assert(index && path); + + if ((ret = index_entry_init(&entry, index, path)) < 0 || + (ret = index_insert(index, &entry, 1)) < 0) + return ret; + + /* Adding implies conflict was resolved, move conflict entries to REUC */ + if ((ret = index_conflict_to_reuc(index, path)) < 0 && ret != GIT_ENOTFOUND) + return ret; + + git_tree_cache_invalidate_path(index->tree, entry->path); + return 0; +} + +int git_index_remove_bypath(git_index *index, const char *path) +{ + int ret; + + assert(index && path); + + if (((ret = git_index_remove(index, path, 0)) < 0 && + ret != GIT_ENOTFOUND) || + ((ret = index_conflict_to_reuc(index, path)) < 0 && + ret != GIT_ENOTFOUND)) + return ret; + + return 0; +} + + +int git_index_add(git_index *index, const git_index_entry *source_entry) +{ + git_index_entry *entry = NULL; + int ret; + + assert(index && source_entry && source_entry->path); + + if (!valid_filemode(source_entry->mode)) { + giterr_set(GITERR_INDEX, "invalid filemode"); + return -1; + } + + if ((ret = index_entry_dup(&entry, INDEX_OWNER(index), source_entry)) < 0 || + (ret = index_insert(index, &entry, 1)) < 0) + return ret; + + git_tree_cache_invalidate_path(index->tree, entry->path); + return 0; +} + +int git_index_remove(git_index *index, const char *path, int stage) +{ + int error; + size_t position; + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock index"); + return -1; + } + + if (index_find(&position, index, path, 0, stage, false) < 0) { + giterr_set( + GITERR_INDEX, "Index does not contain %s at stage %d", path, stage); + error = GIT_ENOTFOUND; + } else { + error = index_remove_entry(index, position); + } + + git_mutex_unlock(&index->lock); + return error; +} + +int git_index_remove_directory(git_index *index, const char *dir, int stage) +{ + git_buf pfx = GIT_BUF_INIT; + int error = 0; + size_t pos; + git_index_entry *entry; + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock index"); + return -1; + } + + if (!(error = git_buf_sets(&pfx, dir)) && + !(error = git_path_to_dir(&pfx))) + index_find(&pos, index, pfx.ptr, pfx.size, GIT_INDEX_STAGE_ANY, false); + + while (!error) { + entry = git_vector_get(&index->entries, pos); + if (!entry || git__prefixcmp(entry->path, pfx.ptr) != 0) + break; + + if (GIT_IDXENTRY_STAGE(entry) != stage) { + ++pos; + continue; + } + + error = index_remove_entry(index, pos); + + /* removed entry at 'pos' so we don't need to increment */ + } + + git_mutex_unlock(&index->lock); + git_buf_free(&pfx); + + return error; +} + +int git_index__find_pos( + size_t *out, git_index *index, const char *path, size_t path_len, int stage) +{ + assert(index && path); + return index_find(out, index, path, path_len, stage, true); +} + +int git_index_find(size_t *at_pos, git_index *index, const char *path) +{ + size_t pos; + + assert(index && path); + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock index"); + return -1; + } + + if (git_vector_bsearch2( + &pos, &index->entries, index->entries_search_path, path) < 0) { + git_mutex_unlock(&index->lock); + giterr_set(GITERR_INDEX, "Index does not contain %s", path); + return GIT_ENOTFOUND; + } + + /* Since our binary search only looked at path, we may be in the + * middle of a list of stages. + */ + for (; pos > 0; --pos) { + const git_index_entry *prev = git_vector_get(&index->entries, pos - 1); + + if (index->entries_cmp_path(prev->path, path) != 0) + break; + } + + if (at_pos) + *at_pos = pos; + + git_mutex_unlock(&index->lock); + return 0; +} + +int git_index_conflict_add(git_index *index, + const git_index_entry *ancestor_entry, + const git_index_entry *our_entry, + const git_index_entry *their_entry) +{ + git_index_entry *entries[3] = { 0 }; + unsigned short i; + int ret = 0; + + assert (index); + + if ((ret = index_entry_dup(&entries[0], INDEX_OWNER(index), ancestor_entry)) < 0 || + (ret = index_entry_dup(&entries[1], INDEX_OWNER(index), our_entry)) < 0 || + (ret = index_entry_dup(&entries[2], INDEX_OWNER(index), their_entry)) < 0) + goto on_error; + + for (i = 0; i < 3; i++) { + if (entries[i] == NULL) + continue; + + /* Make sure stage is correct */ + GIT_IDXENTRY_STAGE_SET(entries[i], i + 1); + + if ((ret = index_insert(index, &entries[i], 1)) < 0) + goto on_error; + + entries[i] = NULL; /* don't free if later entry fails */ + } + + return 0; + +on_error: + for (i = 0; i < 3; i++) { + if (entries[i] != NULL) + index_entry_free(entries[i]); + } + + return ret; +} + +static int index_conflict__get_byindex( + const git_index_entry **ancestor_out, + const git_index_entry **our_out, + const git_index_entry **their_out, + git_index *index, + size_t n) +{ + const git_index_entry *conflict_entry; + const char *path = NULL; + size_t count; + int stage, len = 0; + + assert(ancestor_out && our_out && their_out && index); + + *ancestor_out = NULL; + *our_out = NULL; + *their_out = NULL; + + for (count = git_index_entrycount(index); n < count; ++n) { + conflict_entry = git_vector_get(&index->entries, n); + + if (path && index->entries_cmp_path(conflict_entry->path, path) != 0) + break; + + stage = GIT_IDXENTRY_STAGE(conflict_entry); + path = conflict_entry->path; + + switch (stage) { + case 3: + *their_out = conflict_entry; + len++; + break; + case 2: + *our_out = conflict_entry; + len++; + break; + case 1: + *ancestor_out = conflict_entry; + len++; + break; + default: + break; + }; + } + + return len; +} + +int git_index_conflict_get( + const git_index_entry **ancestor_out, + const git_index_entry **our_out, + const git_index_entry **their_out, + git_index *index, + const char *path) +{ + size_t pos; + int len = 0; + + assert(ancestor_out && our_out && their_out && index && path); + + *ancestor_out = NULL; + *our_out = NULL; + *their_out = NULL; + + if (git_index_find(&pos, index, path) < 0) + return GIT_ENOTFOUND; + + if ((len = index_conflict__get_byindex( + ancestor_out, our_out, their_out, index, pos)) < 0) + return len; + else if (len == 0) + return GIT_ENOTFOUND; + + return 0; +} + +static int index_conflict_remove(git_index *index, const char *path) +{ + size_t pos = 0; + git_index_entry *conflict_entry; + int error = 0; + + if (path != NULL && git_index_find(&pos, index, path) < 0) + return GIT_ENOTFOUND; + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Unable to lock index"); + return -1; + } + + while ((conflict_entry = git_vector_get(&index->entries, pos)) != NULL) { + + if (path != NULL && + index->entries_cmp_path(conflict_entry->path, path) != 0) + break; + + if (GIT_IDXENTRY_STAGE(conflict_entry) == 0) { + pos++; + continue; + } + + if ((error = index_remove_entry(index, pos)) < 0) + break; + } + + git_mutex_unlock(&index->lock); + + return error; +} + +int git_index_conflict_remove(git_index *index, const char *path) +{ + assert(index && path); + return index_conflict_remove(index, path); +} + +int git_index_conflict_cleanup(git_index *index) +{ + assert(index); + return index_conflict_remove(index, NULL); +} + +int git_index_has_conflicts(const git_index *index) +{ + size_t i; + git_index_entry *entry; + + assert(index); + + git_vector_foreach(&index->entries, i, entry) { + if (GIT_IDXENTRY_STAGE(entry) > 0) + return 1; + } + + return 0; +} + +int git_index_conflict_iterator_new( + git_index_conflict_iterator **iterator_out, + git_index *index) +{ + git_index_conflict_iterator *it = NULL; + + assert(iterator_out && index); + + it = git__calloc(1, sizeof(git_index_conflict_iterator)); + GITERR_CHECK_ALLOC(it); + + it->index = index; + + *iterator_out = it; + return 0; +} + +int git_index_conflict_next( + const git_index_entry **ancestor_out, + const git_index_entry **our_out, + const git_index_entry **their_out, + git_index_conflict_iterator *iterator) +{ + const git_index_entry *entry; + int len; + + assert(ancestor_out && our_out && their_out && iterator); + + *ancestor_out = NULL; + *our_out = NULL; + *their_out = NULL; + + while (iterator->cur < iterator->index->entries.length) { + entry = git_index_get_byindex(iterator->index, iterator->cur); + + if (git_index_entry_stage(entry) > 0) { + if ((len = index_conflict__get_byindex( + ancestor_out, + our_out, + their_out, + iterator->index, + iterator->cur)) < 0) + return len; + + iterator->cur += len; + return 0; + } + + iterator->cur++; + } + + return GIT_ITEROVER; +} + +void git_index_conflict_iterator_free(git_index_conflict_iterator *iterator) +{ + if (iterator == NULL) + return; + + git__free(iterator); +} + +size_t git_index_name_entrycount(git_index *index) +{ + assert(index); + return index->names.length; +} + +const git_index_name_entry *git_index_name_get_byindex( + git_index *index, size_t n) +{ + assert(index); + + git_vector_sort(&index->names); + return git_vector_get(&index->names, n); +} + +static void index_name_entry_free(git_index_name_entry *ne) +{ + if (!ne) + return; + git__free(ne->ancestor); + git__free(ne->ours); + git__free(ne->theirs); + git__free(ne); +} + +int git_index_name_add(git_index *index, + const char *ancestor, const char *ours, const char *theirs) +{ + git_index_name_entry *conflict_name; + + assert((ancestor && ours) || (ancestor && theirs) || (ours && theirs)); + + conflict_name = git__calloc(1, sizeof(git_index_name_entry)); + GITERR_CHECK_ALLOC(conflict_name); + + if ((ancestor && !(conflict_name->ancestor = git__strdup(ancestor))) || + (ours && !(conflict_name->ours = git__strdup(ours))) || + (theirs && !(conflict_name->theirs = git__strdup(theirs))) || + git_vector_insert(&index->names, conflict_name) < 0) + { + index_name_entry_free(conflict_name); + return -1; + } + + return 0; +} + +void git_index_name_clear(git_index *index) +{ + size_t i; + git_index_name_entry *conflict_name; + + assert(index); + + git_vector_foreach(&index->names, i, conflict_name) + index_name_entry_free(conflict_name); + + git_vector_clear(&index->names); +} + +size_t git_index_reuc_entrycount(git_index *index) +{ + assert(index); + return index->reuc.length; +} + +static int index_reuc_insert( + git_index *index, + git_index_reuc_entry *reuc, + int replace) +{ + git_index_reuc_entry **existing = NULL; + size_t position; + + assert(index && reuc && reuc->path != NULL); + + if (!git_index_reuc_find(&position, index, reuc->path)) + existing = (git_index_reuc_entry **)&index->reuc.contents[position]; + + if (!replace || !existing) + return git_vector_insert(&index->reuc, reuc); + + /* exists, replace it */ + git__free(*existing); + *existing = reuc; + + return 0; +} + +int git_index_reuc_add(git_index *index, const char *path, + int ancestor_mode, const git_oid *ancestor_oid, + int our_mode, const git_oid *our_oid, + int their_mode, const git_oid *their_oid) +{ + git_index_reuc_entry *reuc = NULL; + int error = 0; + + assert(index && path); + + if ((error = index_entry_reuc_init(&reuc, path, ancestor_mode, + ancestor_oid, our_mode, our_oid, their_mode, their_oid)) < 0 || + (error = index_reuc_insert(index, reuc, 1)) < 0) + index_entry_reuc_free(reuc); + + return error; +} + +int git_index_reuc_find(size_t *at_pos, git_index *index, const char *path) +{ + return git_vector_bsearch2(at_pos, &index->reuc, index->reuc_search, path); +} + +const git_index_reuc_entry *git_index_reuc_get_bypath( + git_index *index, const char *path) +{ + size_t pos; + assert(index && path); + + if (!index->reuc.length) + return NULL; + + git_vector_sort(&index->reuc); + + if (git_index_reuc_find(&pos, index, path) < 0) + return NULL; + + return git_vector_get(&index->reuc, pos); +} + +const git_index_reuc_entry *git_index_reuc_get_byindex( + git_index *index, size_t n) +{ + assert(index); + + git_vector_sort(&index->reuc); + return git_vector_get(&index->reuc, n); +} + +int git_index_reuc_remove(git_index *index, size_t position) +{ + int error; + git_index_reuc_entry *reuc; + + git_vector_sort(&index->reuc); + + reuc = git_vector_get(&index->reuc, position); + error = git_vector_remove(&index->reuc, position); + + if (!error) + index_entry_reuc_free(reuc); + + return error; +} + +void git_index_reuc_clear(git_index *index) +{ + size_t i; + + assert(index); + + for (i = 0; i < index->reuc.length; ++i) + index_entry_reuc_free(git__swap(index->reuc.contents[i], NULL)); + + git_vector_clear(&index->reuc); +} + +static int index_error_invalid(const char *message) +{ + giterr_set(GITERR_INDEX, "Invalid data in index - %s", message); + return -1; +} + +static int read_reuc(git_index *index, const char *buffer, size_t size) +{ + const char *endptr; + size_t len; + int i; + + /* If called multiple times, the vector might already be initialized */ + if (index->reuc._alloc_size == 0 && + git_vector_init(&index->reuc, 16, reuc_cmp) < 0) + return -1; + + while (size) { + git_index_reuc_entry *lost; + + len = p_strnlen(buffer, size) + 1; + if (size <= len) + return index_error_invalid("reading reuc entries"); + + lost = reuc_entry_alloc(buffer); + GITERR_CHECK_ALLOC(lost); + + size -= len; + buffer += len; + + /* read 3 ASCII octal numbers for stage entries */ + for (i = 0; i < 3; i++) { + int tmp; + + if (git__strtol32(&tmp, buffer, &endptr, 8) < 0 || + !endptr || endptr == buffer || *endptr || + (unsigned)tmp > UINT_MAX) { + index_entry_reuc_free(lost); + return index_error_invalid("reading reuc entry stage"); + } + + lost->mode[i] = tmp; + + len = (endptr + 1) - buffer; + if (size <= len) { + index_entry_reuc_free(lost); + return index_error_invalid("reading reuc entry stage"); + } + + size -= len; + buffer += len; + } + + /* read up to 3 OIDs for stage entries */ + for (i = 0; i < 3; i++) { + if (!lost->mode[i]) + continue; + if (size < 20) { + index_entry_reuc_free(lost); + return index_error_invalid("reading reuc entry oid"); + } + + git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer); + size -= 20; + buffer += 20; + } + + /* entry was read successfully - insert into reuc vector */ + if (git_vector_insert(&index->reuc, lost) < 0) + return -1; + } + + /* entries are guaranteed to be sorted on-disk */ + git_vector_set_sorted(&index->reuc, true); + + return 0; +} + + +static int read_conflict_names(git_index *index, const char *buffer, size_t size) +{ + size_t len; + + /* This gets called multiple times, the vector might already be initialized */ + if (index->names._alloc_size == 0 && + git_vector_init(&index->names, 16, conflict_name_cmp) < 0) + return -1; + +#define read_conflict_name(ptr) \ + len = p_strnlen(buffer, size) + 1; \ + if (size < len) \ + return index_error_invalid("reading conflict name entries"); \ + \ + if (len == 1) \ + ptr = NULL; \ + else { \ + ptr = git__malloc(len); \ + GITERR_CHECK_ALLOC(ptr); \ + memcpy(ptr, buffer, len); \ + } \ + \ + buffer += len; \ + size -= len; + + while (size) { + git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry)); + GITERR_CHECK_ALLOC(conflict_name); + + read_conflict_name(conflict_name->ancestor); + read_conflict_name(conflict_name->ours); + read_conflict_name(conflict_name->theirs); + + if (git_vector_insert(&index->names, conflict_name) < 0) + return -1; + } + +#undef read_conflict_name + + /* entries are guaranteed to be sorted on-disk */ + git_vector_set_sorted(&index->names, true); + + return 0; +} + +static size_t read_entry( + git_index_entry **out, + git_index *index, + const void *buffer, + size_t buffer_size) +{ + size_t path_length, entry_size; + const char *path_ptr; + struct entry_short source; + git_index_entry entry = {{0}}; + + if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size) + return 0; + + /* buffer is not guaranteed to be aligned */ + memcpy(&source, buffer, sizeof(struct entry_short)); + + entry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds); + entry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds); + entry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds); + entry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds); + entry.dev = ntohl(source.dev); + entry.ino = ntohl(source.ino); + entry.mode = ntohl(source.mode); + entry.uid = ntohl(source.uid); + entry.gid = ntohl(source.gid); + entry.file_size = ntohl(source.file_size); + git_oid_cpy(&entry.id, &source.oid); + entry.flags = ntohs(source.flags); + + if (entry.flags & GIT_IDXENTRY_EXTENDED) { + uint16_t flags_raw; + size_t flags_offset; + + flags_offset = offsetof(struct entry_long, flags_extended); + memcpy(&flags_raw, (const char *) buffer + flags_offset, + sizeof(flags_raw)); + flags_raw = ntohs(flags_raw); + + memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw)); + path_ptr = (const char *) buffer + offsetof(struct entry_long, path); + } else + path_ptr = (const char *) buffer + offsetof(struct entry_short, path); + + path_length = entry.flags & GIT_IDXENTRY_NAMEMASK; + + /* if this is a very long string, we must find its + * real length without overflowing */ + if (path_length == 0xFFF) { + const char *path_end; + + path_end = memchr(path_ptr, '\0', buffer_size); + if (path_end == NULL) + return 0; + + path_length = path_end - path_ptr; + } + + if (entry.flags & GIT_IDXENTRY_EXTENDED) + entry_size = long_entry_size(path_length); + else + entry_size = short_entry_size(path_length); + + if (INDEX_FOOTER_SIZE + entry_size > buffer_size) + return 0; + + entry.path = (char *)path_ptr; + + if (index_entry_dup(out, INDEX_OWNER(index), &entry) < 0) + return 0; + + return entry_size; +} + +static int read_header(struct index_header *dest, const void *buffer) +{ + const struct index_header *source = buffer; + + dest->signature = ntohl(source->signature); + if (dest->signature != INDEX_HEADER_SIG) + return index_error_invalid("incorrect header signature"); + + dest->version = ntohl(source->version); + if (dest->version != INDEX_VERSION_NUMBER_EXT && + dest->version != INDEX_VERSION_NUMBER) + return index_error_invalid("incorrect header version"); + + dest->entry_count = ntohl(source->entry_count); + return 0; +} + +static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size) +{ + struct index_extension dest; + size_t total_size; + + /* buffer is not guaranteed to be aligned */ + memcpy(&dest, buffer, sizeof(struct index_extension)); + dest.extension_size = ntohl(dest.extension_size); + + total_size = dest.extension_size + sizeof(struct index_extension); + + if (dest.extension_size > total_size || + buffer_size < total_size || + buffer_size - total_size < INDEX_FOOTER_SIZE) + return 0; + + /* optional extension */ + if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') { + /* tree cache */ + if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) { + if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0) + return 0; + } else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) { + if (read_reuc(index, buffer + 8, dest.extension_size) < 0) + return 0; + } else if (memcmp(dest.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4) == 0) { + if (read_conflict_names(index, buffer + 8, dest.extension_size) < 0) + return 0; + } + /* else, unsupported extension. We cannot parse this, but we can skip + * it by returning `total_size */ + } else { + /* we cannot handle non-ignorable extensions; + * in fact they aren't even defined in the standard */ + return 0; + } + + return total_size; +} + +static int parse_index(git_index *index, const char *buffer, size_t buffer_size) +{ + int error = 0; + unsigned int i; + struct index_header header = { 0 }; + git_oid checksum_calculated, checksum_expected; + +#define seek_forward(_increase) { \ + if (_increase >= buffer_size) { \ + error = index_error_invalid("ran out of data while parsing"); \ + goto done; } \ + buffer += _increase; \ + buffer_size -= _increase;\ +} + + if (buffer_size < INDEX_HEADER_SIZE + INDEX_FOOTER_SIZE) + return index_error_invalid("insufficient buffer space"); + + /* Precalculate the SHA1 of the files's contents -- we'll match it to + * the provided SHA1 in the footer */ + git_hash_buf(&checksum_calculated, buffer, buffer_size - INDEX_FOOTER_SIZE); + + /* Parse header */ + if ((error = read_header(&header, buffer)) < 0) + return error; + + seek_forward(INDEX_HEADER_SIZE); + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire index lock"); + return -1; + } + + assert(!index->entries.length); + + /* Parse all the entries */ + for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) { + git_index_entry *entry; + size_t entry_size = read_entry(&entry, index, buffer, buffer_size); + + /* 0 bytes read means an object corruption */ + if (entry_size == 0) { + error = index_error_invalid("invalid entry"); + goto done; + } + + if ((error = git_vector_insert(&index->entries, entry)) < 0) { + index_entry_free(entry); + goto done; + } + + seek_forward(entry_size); + } + + if (i != header.entry_count) { + error = index_error_invalid("header entries changed while parsing"); + goto done; + } + + /* There's still space for some extensions! */ + while (buffer_size > INDEX_FOOTER_SIZE) { + size_t extension_size; + + extension_size = read_extension(index, buffer, buffer_size); + + /* see if we have read any bytes from the extension */ + if (extension_size == 0) { + error = index_error_invalid("extension is truncated"); + goto done; + } + + seek_forward(extension_size); + } + + if (buffer_size != INDEX_FOOTER_SIZE) { + error = index_error_invalid( + "buffer size does not match index footer size"); + goto done; + } + + /* 160-bit SHA-1 over the content of the index file before this checksum. */ + git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer); + + if (git_oid__cmp(&checksum_calculated, &checksum_expected) != 0) { + error = index_error_invalid( + "calculated checksum does not match expected"); + goto done; + } + +#undef seek_forward + + /* Entries are stored case-sensitively on disk, so re-sort now if + * in-memory index is supposed to be case-insensitive + */ + git_vector_set_sorted(&index->entries, !index->ignore_case); + error = index_sort_if_needed(index, false); + +done: + git_mutex_unlock(&index->lock); + return error; +} + +static bool is_index_extended(git_index *index) +{ + size_t i, extended; + git_index_entry *entry; + + extended = 0; + + git_vector_foreach(&index->entries, i, entry) { + entry->flags &= ~GIT_IDXENTRY_EXTENDED; + if (entry->flags_extended & GIT_IDXENTRY_EXTENDED_FLAGS) { + extended++; + entry->flags |= GIT_IDXENTRY_EXTENDED; + } + } + + return (extended > 0); +} + +static int write_disk_entry(git_filebuf *file, git_index_entry *entry) +{ + void *mem = NULL; + struct entry_short *ondisk; + size_t path_len, disk_size; + char *path; + + path_len = ((struct entry_internal *)entry)->pathlen; + + if (entry->flags & GIT_IDXENTRY_EXTENDED) + disk_size = long_entry_size(path_len); + else + disk_size = short_entry_size(path_len); + + if (git_filebuf_reserve(file, &mem, disk_size) < 0) + return -1; + + ondisk = (struct entry_short *)mem; + + memset(ondisk, 0x0, disk_size); + + /** + * Yes, we have to truncate. + * + * The on-disk format for Index entries clearly defines + * the time and size fields to be 4 bytes each -- so even if + * we store these values with 8 bytes on-memory, they must + * be truncated to 4 bytes before writing to disk. + * + * In 2038 I will be either too dead or too rich to care about this + */ + ondisk->ctime.seconds = htonl((uint32_t)entry->ctime.seconds); + ondisk->mtime.seconds = htonl((uint32_t)entry->mtime.seconds); + ondisk->ctime.nanoseconds = htonl(entry->ctime.nanoseconds); + ondisk->mtime.nanoseconds = htonl(entry->mtime.nanoseconds); + ondisk->dev = htonl(entry->dev); + ondisk->ino = htonl(entry->ino); + ondisk->mode = htonl(entry->mode); + ondisk->uid = htonl(entry->uid); + ondisk->gid = htonl(entry->gid); + ondisk->file_size = htonl((uint32_t)entry->file_size); + + git_oid_cpy(&ondisk->oid, &entry->id); + + ondisk->flags = htons(entry->flags); + + if (entry->flags & GIT_IDXENTRY_EXTENDED) { + struct entry_long *ondisk_ext; + ondisk_ext = (struct entry_long *)ondisk; + ondisk_ext->flags_extended = htons(entry->flags_extended); + path = ondisk_ext->path; + } + else + path = ondisk->path; + + memcpy(path, entry->path, path_len); + + return 0; +} + +static int write_entries(git_index *index, git_filebuf *file) +{ + int error = 0; + size_t i; + git_vector case_sorted, *entries; + git_index_entry *entry; + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock index"); + return -1; + } + + /* If index->entries is sorted case-insensitively, then we need + * to re-sort it case-sensitively before writing */ + if (index->ignore_case) { + git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp); + git_vector_sort(&case_sorted); + entries = &case_sorted; + } else { + entries = &index->entries; + } + + git_vector_foreach(entries, i, entry) + if ((error = write_disk_entry(file, entry)) < 0) + break; + + git_mutex_unlock(&index->lock); + + if (index->ignore_case) + git_vector_free(&case_sorted); + + return error; +} + +static int write_extension(git_filebuf *file, struct index_extension *header, git_buf *data) +{ + struct index_extension ondisk; + + memset(&ondisk, 0x0, sizeof(struct index_extension)); + memcpy(&ondisk, header, 4); + ondisk.extension_size = htonl(header->extension_size); + + git_filebuf_write(file, &ondisk, sizeof(struct index_extension)); + return git_filebuf_write(file, data->ptr, data->size); +} + +static int create_name_extension_data(git_buf *name_buf, git_index_name_entry *conflict_name) +{ + int error = 0; + + if (conflict_name->ancestor == NULL) + error = git_buf_put(name_buf, "\0", 1); + else + error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1); + + if (error != 0) + goto on_error; + + if (conflict_name->ours == NULL) + error = git_buf_put(name_buf, "\0", 1); + else + error = git_buf_put(name_buf, conflict_name->ours, strlen(conflict_name->ours) + 1); + + if (error != 0) + goto on_error; + + if (conflict_name->theirs == NULL) + error = git_buf_put(name_buf, "\0", 1); + else + error = git_buf_put(name_buf, conflict_name->theirs, strlen(conflict_name->theirs) + 1); + +on_error: + return error; +} + +static int write_name_extension(git_index *index, git_filebuf *file) +{ + git_buf name_buf = GIT_BUF_INIT; + git_vector *out = &index->names; + git_index_name_entry *conflict_name; + struct index_extension extension; + size_t i; + int error = 0; + + git_vector_foreach(out, i, conflict_name) { + if ((error = create_name_extension_data(&name_buf, conflict_name)) < 0) + goto done; + } + + memset(&extension, 0x0, sizeof(struct index_extension)); + memcpy(&extension.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4); + extension.extension_size = (uint32_t)name_buf.size; + + error = write_extension(file, &extension, &name_buf); + + git_buf_free(&name_buf); + +done: + return error; +} + +static int create_reuc_extension_data(git_buf *reuc_buf, git_index_reuc_entry *reuc) +{ + int i; + int error = 0; + + if ((error = git_buf_put(reuc_buf, reuc->path, strlen(reuc->path) + 1)) < 0) + return error; + + for (i = 0; i < 3; i++) { + if ((error = git_buf_printf(reuc_buf, "%o", reuc->mode[i])) < 0 || + (error = git_buf_put(reuc_buf, "\0", 1)) < 0) + return error; + } + + for (i = 0; i < 3; i++) { + if (reuc->mode[i] && (error = git_buf_put(reuc_buf, (char *)&reuc->oid[i].id, GIT_OID_RAWSZ)) < 0) + return error; + } + + return 0; +} + +static int write_reuc_extension(git_index *index, git_filebuf *file) +{ + git_buf reuc_buf = GIT_BUF_INIT; + git_vector *out = &index->reuc; + git_index_reuc_entry *reuc; + struct index_extension extension; + size_t i; + int error = 0; + + git_vector_foreach(out, i, reuc) { + if ((error = create_reuc_extension_data(&reuc_buf, reuc)) < 0) + goto done; + } + + memset(&extension, 0x0, sizeof(struct index_extension)); + memcpy(&extension.signature, INDEX_EXT_UNMERGED_SIG, 4); + extension.extension_size = (uint32_t)reuc_buf.size; + + error = write_extension(file, &extension, &reuc_buf); + + git_buf_free(&reuc_buf); + +done: + return error; +} + +static int write_tree_extension(git_index *index, git_filebuf *file) +{ + struct index_extension extension; + git_buf buf = GIT_BUF_INIT; + int error; + + if (index->tree == NULL) + return 0; + + if ((error = git_tree_cache_write(&buf, index->tree)) < 0) + return error; + + memset(&extension, 0x0, sizeof(struct index_extension)); + memcpy(&extension.signature, INDEX_EXT_TREECACHE_SIG, 4); + extension.extension_size = (uint32_t)buf.size; + + error = write_extension(file, &extension, &buf); + + git_buf_free(&buf); + + return error; +} + +static int write_index(git_index *index, git_filebuf *file) +{ + git_oid hash_final; + struct index_header header; + bool is_extended; + uint32_t index_version_number; + + assert(index && file); + + is_extended = is_index_extended(index); + index_version_number = is_extended ? INDEX_VERSION_NUMBER_EXT : INDEX_VERSION_NUMBER; + + header.signature = htonl(INDEX_HEADER_SIG); + header.version = htonl(index_version_number); + header.entry_count = htonl((uint32_t)index->entries.length); + + if (git_filebuf_write(file, &header, sizeof(struct index_header)) < 0) + return -1; + + if (write_entries(index, file) < 0) + return -1; + + /* write the tree cache extension */ + if (index->tree != NULL && write_tree_extension(index, file) < 0) + return -1; + + /* write the rename conflict extension */ + if (index->names.length > 0 && write_name_extension(index, file) < 0) + return -1; + + /* write the reuc extension */ + if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0) + return -1; + + /* get out the hash for all the contents we've appended to the file */ + git_filebuf_hash(&hash_final, file); + + /* write it at the end of the file */ + return git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ); +} + +int git_index_entry_stage(const git_index_entry *entry) +{ + return GIT_IDXENTRY_STAGE(entry); +} + +typedef struct read_tree_data { + git_index *index; + git_vector *old_entries; + git_vector *new_entries; + git_vector_cmp entry_cmp; + git_tree_cache *tree; +} read_tree_data; + +static int read_tree_cb( + const char *root, const git_tree_entry *tentry, void *payload) +{ + read_tree_data *data = payload; + git_index_entry *entry = NULL, *old_entry; + git_buf path = GIT_BUF_INIT; + size_t pos; + + if (git_tree_entry__is_tree(tentry)) + return 0; + + if (git_buf_joinpath(&path, root, tentry->filename) < 0) + return -1; + + if (index_entry_create(&entry, INDEX_OWNER(data->index), path.ptr) < 0) + return -1; + + entry->mode = tentry->attr; + entry->id = tentry->oid; + + /* look for corresponding old entry and copy data to new entry */ + if (data->old_entries != NULL && + !index_find_in_entries( + &pos, data->old_entries, data->entry_cmp, path.ptr, 0, 0) && + (old_entry = git_vector_get(data->old_entries, pos)) != NULL && + entry->mode == old_entry->mode && + git_oid_equal(&entry->id, &old_entry->id)) + { + index_entry_cpy(entry, old_entry); + entry->flags_extended = 0; + } + + if (path.size < GIT_IDXENTRY_NAMEMASK) + entry->flags = path.size & GIT_IDXENTRY_NAMEMASK; + else + entry->flags = GIT_IDXENTRY_NAMEMASK; + + git_buf_free(&path); + + if (git_vector_insert(data->new_entries, entry) < 0) { + index_entry_free(entry); + return -1; + } + + return 0; +} + +int git_index_read_tree(git_index *index, const git_tree *tree) +{ + int error = 0; + git_vector entries = GIT_VECTOR_INIT; + read_tree_data data; + + git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */ + + data.index = index; + data.old_entries = &index->entries; + data.new_entries = &entries; + data.entry_cmp = index->entries_search; + + index->tree = NULL; + git_pool_clear(&index->tree_pool); + + if (index_sort_if_needed(index, true) < 0) + return -1; + + error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data); + + if (!error) { + git_vector_sort(&entries); + + if ((error = git_index_clear(index)) < 0) + /* well, this isn't good */; + else if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire index lock"); + error = -1; + } else { + git_vector_swap(&entries, &index->entries); + git_mutex_unlock(&index->lock); + } + } + + git_vector_free(&entries); + if (error < 0) + return error; + + error = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool); + + return error; +} + +git_repository *git_index_owner(const git_index *index) +{ + return INDEX_OWNER(index); +} + +int git_index_add_all( + git_index *index, + const git_strarray *paths, + unsigned int flags, + git_index_matched_path_cb cb, + void *payload) +{ + int error; + git_repository *repo; + git_iterator *wditer = NULL; + const git_index_entry *wd = NULL; + git_index_entry *entry; + git_pathspec ps; + const char *match; + size_t existing; + bool no_fnmatch = (flags & GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH) != 0; + int ignorecase; + git_oid blobid; + + assert(index); + + if (INDEX_OWNER(index) == NULL) + return create_index_error(-1, + "Could not add paths to index. " + "Index is not backed up by an existing repository."); + + repo = INDEX_OWNER(index); + if ((error = git_repository__ensure_not_bare(repo, "index add all")) < 0) + return error; + + if (git_repository__cvar(&ignorecase, repo, GIT_CVAR_IGNORECASE) < 0) + return -1; + + if ((error = git_pathspec__init(&ps, paths)) < 0) + return error; + + /* optionally check that pathspec doesn't mention any ignored files */ + if ((flags & GIT_INDEX_ADD_CHECK_PATHSPEC) != 0 && + (flags & GIT_INDEX_ADD_FORCE) == 0 && + (error = git_ignore__check_pathspec_for_exact_ignores( + repo, &ps.pathspec, no_fnmatch)) < 0) + goto cleanup; + + if ((error = git_iterator_for_workdir( + &wditer, repo, NULL, NULL, 0, ps.prefix, ps.prefix)) < 0) + goto cleanup; + + while (!(error = git_iterator_advance(&wd, wditer))) { + + /* check if path actually matches */ + if (!git_pathspec__match( + &ps.pathspec, wd->path, no_fnmatch, (bool)ignorecase, &match, NULL)) + continue; + + /* skip ignored items that are not already in the index */ + if ((flags & GIT_INDEX_ADD_FORCE) == 0 && + git_iterator_current_is_ignored(wditer) && + index_find(&existing, index, wd->path, 0, 0, true) < 0) + continue; + + /* issue notification callback if requested */ + if (cb && (error = cb(wd->path, match, payload)) != 0) { + if (error > 0) /* return > 0 means skip this one */ + continue; + if (error < 0) { /* return < 0 means abort */ + giterr_set_after_callback(error); + break; + } + } + + /* TODO: Should we check if the file on disk is already an exact + * match to the file in the index and skip this work if it is? + */ + + /* write the blob to disk and get the oid */ + if ((error = git_blob_create_fromworkdir(&blobid, repo, wd->path)) < 0) + break; + + /* make the new entry to insert */ + if ((error = index_entry_dup(&entry, INDEX_OWNER(index), wd)) < 0) + break; + + entry->id = blobid; + + /* add working directory item to index */ + if ((error = index_insert(index, &entry, 1)) < 0) + break; + + git_tree_cache_invalidate_path(index->tree, wd->path); + + /* add implies conflict resolved, move conflict entries to REUC */ + if ((error = index_conflict_to_reuc(index, wd->path)) < 0) { + if (error != GIT_ENOTFOUND) + break; + giterr_clear(); + } + } + + if (error == GIT_ITEROVER) + error = 0; + +cleanup: + git_iterator_free(wditer); + git_pathspec__clear(&ps); + + return error; +} + +enum { + INDEX_ACTION_NONE = 0, + INDEX_ACTION_UPDATE = 1, + INDEX_ACTION_REMOVE = 2, +}; + +static int index_apply_to_all( + git_index *index, + int action, + const git_strarray *paths, + git_index_matched_path_cb cb, + void *payload) +{ + int error = 0; + size_t i; + git_pathspec ps; + const char *match; + git_buf path = GIT_BUF_INIT; + + assert(index); + + if ((error = git_pathspec__init(&ps, paths)) < 0) + return error; + + git_vector_sort(&index->entries); + + for (i = 0; !error && i < index->entries.length; ++i) { + git_index_entry *entry = git_vector_get(&index->entries, i); + + /* check if path actually matches */ + if (!git_pathspec__match( + &ps.pathspec, entry->path, false, (bool)index->ignore_case, + &match, NULL)) + continue; + + /* issue notification callback if requested */ + if (cb && (error = cb(entry->path, match, payload)) != 0) { + if (error > 0) { /* return > 0 means skip this one */ + error = 0; + continue; + } + if (error < 0) /* return < 0 means abort */ + break; + } + + /* index manipulation may alter entry, so don't depend on it */ + if ((error = git_buf_sets(&path, entry->path)) < 0) + break; + + switch (action) { + case INDEX_ACTION_NONE: + break; + case INDEX_ACTION_UPDATE: + error = git_index_add_bypath(index, path.ptr); + + if (error == GIT_ENOTFOUND) { + giterr_clear(); + + error = git_index_remove_bypath(index, path.ptr); + + if (!error) /* back up foreach if we removed this */ + i--; + } + break; + case INDEX_ACTION_REMOVE: + if (!(error = git_index_remove_bypath(index, path.ptr))) + i--; /* back up foreach if we removed this */ + break; + default: + giterr_set(GITERR_INVALID, "Unknown index action %d", action); + error = -1; + break; + } + } + + git_buf_free(&path); + git_pathspec__clear(&ps); + + return error; +} + +int git_index_remove_all( + git_index *index, + const git_strarray *pathspec, + git_index_matched_path_cb cb, + void *payload) +{ + int error = index_apply_to_all( + index, INDEX_ACTION_REMOVE, pathspec, cb, payload); + + if (error) /* make sure error is set if callback stopped iteration */ + giterr_set_after_callback(error); + + return error; +} + +int git_index_update_all( + git_index *index, + const git_strarray *pathspec, + git_index_matched_path_cb cb, + void *payload) +{ + int error = index_apply_to_all( + index, INDEX_ACTION_UPDATE, pathspec, cb, payload); + + if (error) /* make sure error is set if callback stopped iteration */ + giterr_set_after_callback(error); + + return error; +} + +int git_index_snapshot_new(git_vector *snap, git_index *index) +{ + int error; + + GIT_REFCOUNT_INC(index); + + if (git_mutex_lock(&index->lock) < 0) { + giterr_set(GITERR_OS, "Failed to lock index"); + return -1; + } + + git_atomic_inc(&index->readers); + git_vector_sort(&index->entries); + + error = git_vector_dup(snap, &index->entries, index->entries._cmp); + + git_mutex_unlock(&index->lock); + + if (error < 0) + git_index_free(index); + + return error; +} + +void git_index_snapshot_release(git_vector *snap, git_index *index) +{ + git_vector_free(snap); + + git_atomic_dec(&index->readers); + + if (!git_mutex_lock(&index->lock)) { + index_free_deleted(index); /* try to free pending deleted items */ + git_mutex_unlock(&index->lock); + } + + git_index_free(index); +} + +int git_index_snapshot_find( + size_t *out, git_vector *entries, git_vector_cmp entry_srch, + const char *path, size_t path_len, int stage) +{ + return index_find_in_entries(out, entries, entry_srch, path, path_len, stage); +} + +int git_indexwriter_init( + git_indexwriter *writer, + git_index *index) +{ + int error; + + GIT_REFCOUNT_INC(index); + + writer->index = index; + + if (!index->index_file_path) + return create_index_error(-1, + "Failed to write index: The index is in-memory only"); + + if ((error = git_filebuf_open( + &writer->file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) { + + if (error == GIT_ELOCKED) + giterr_set(GITERR_INDEX, "The index is locked. This might be due to a concurrent or crashed process"); + + return error; + } + + writer->should_write = 1; + + return 0; +} + +int git_indexwriter_init_for_operation( + git_indexwriter *writer, + git_repository *repo, + unsigned int *checkout_strategy) +{ + git_index *index; + int error; + + if ((error = git_repository_index__weakptr(&index, repo)) < 0 || + (error = git_indexwriter_init(writer, index)) < 0) + return error; + + writer->should_write = (*checkout_strategy & GIT_CHECKOUT_DONT_WRITE_INDEX) == 0; + *checkout_strategy |= GIT_CHECKOUT_DONT_WRITE_INDEX; + + return 0; +} + +int git_indexwriter_commit(git_indexwriter *writer) +{ + int error; + + if (!writer->should_write) + return 0; + + if (index_sort_if_needed(writer->index, true) < 0) + return -1; + + git_vector_sort(&writer->index->reuc); + + if ((error = write_index(writer->index, &writer->file)) < 0) { + git_indexwriter_cleanup(writer); + return error; + } + + if ((error = git_filebuf_commit(&writer->file)) < 0) + return error; + + if ((error = git_futils_filestamp_check( + &writer->index->stamp, writer->index->index_file_path)) < 0) { + giterr_set(GITERR_OS, "Could not read index timestamp"); + return -1; + } + + writer->index->on_disk = 1; + + git_index_free(writer->index); + writer->index = NULL; + + return 0; +} + +void git_indexwriter_cleanup(git_indexwriter *writer) +{ + git_filebuf_cleanup(&writer->file); + + git_index_free(writer->index); + writer->index = NULL; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/index.h b/deps/libgit2-sys-0.2.17/libgit2/src/index.h new file mode 100644 index 000000000..6d2904fdc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/index.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_index_h__ +#define INCLUDE_index_h__ + +#include "fileops.h" +#include "filebuf.h" +#include "vector.h" +#include "tree-cache.h" +#include "git2/odb.h" +#include "git2/index.h" + +#define GIT_INDEX_FILE "index" +#define GIT_INDEX_FILE_MODE 0666 + +struct git_index { + git_refcount rc; + + char *index_file_path; + git_futils_filestamp stamp; + + git_vector entries; + + git_mutex lock; /* lock held while entries is being changed */ + git_vector deleted; /* deleted entries if readers > 0 */ + git_atomic readers; /* number of active iterators */ + + unsigned int on_disk:1; + unsigned int ignore_case:1; + unsigned int distrust_filemode:1; + unsigned int no_symlinks:1; + + git_tree_cache *tree; + git_pool tree_pool; + + git_vector names; + git_vector reuc; + + git_vector_cmp entries_cmp_path; + git_vector_cmp entries_search; + git_vector_cmp entries_search_path; + git_vector_cmp reuc_search; +}; + +struct git_index_conflict_iterator { + git_index *index; + size_t cur; +}; + +extern void git_index_entry__init_from_stat( + git_index_entry *entry, struct stat *st, bool trust_mode); + +/* Index entry comparison functions for array sorting */ +extern int git_index_entry_cmp(const void *a, const void *b); +extern int git_index_entry_icmp(const void *a, const void *b); + +/* Index entry search functions for search using a search spec */ +extern int git_index_entry_srch(const void *a, const void *b); +extern int git_index_entry_isrch(const void *a, const void *b); + +/* Search index for `path`, returning GIT_ENOTFOUND if it does not exist + * (but not setting an error message). + * + * `at_pos` is set to the position where it is or would be inserted. + * Pass `path_len` as strlen of path or 0 to call strlen internally. + */ +extern int git_index__find_pos( + size_t *at_pos, git_index *index, const char *path, size_t path_len, int stage); + +extern void git_index__set_ignore_case(git_index *index, bool ignore_case); + +extern unsigned int git_index__create_mode(unsigned int mode); + +GIT_INLINE(const git_futils_filestamp *) git_index__filestamp(git_index *index) +{ + return &index->stamp; +} + +extern int git_index__changed_relative_to(git_index *index, const git_futils_filestamp *fs); + +/* Copy the current entries vector *and* increment the index refcount. + * Call `git_index__release_snapshot` when done. + */ +extern int git_index_snapshot_new(git_vector *snap, git_index *index); +extern void git_index_snapshot_release(git_vector *snap, git_index *index); + +/* Allow searching in a snapshot; entries must already be sorted! */ +extern int git_index_snapshot_find( + size_t *at_pos, git_vector *snap, git_vector_cmp entry_srch, + const char *path, size_t path_len, int stage); + + +typedef struct { + git_index *index; + git_filebuf file; + unsigned int should_write:1; +} git_indexwriter; + +#define GIT_INDEXWRITER_INIT { NULL, GIT_FILEBUF_INIT } + +/* Lock the index for eventual writing. */ +extern int git_indexwriter_init(git_indexwriter *writer, git_index *index); + +/* Lock the index for eventual writing by a repository operation: a merge, + * revert, cherry-pick or a rebase. Note that the given checkout strategy + * will be updated for the operation's use so that checkout will not write + * the index. + */ +extern int git_indexwriter_init_for_operation( + git_indexwriter *writer, + git_repository *repo, + unsigned int *checkout_strategy); + +/* Write the index and unlock it. */ +extern int git_indexwriter_commit(git_indexwriter *writer); + +/* Cleanup an index writing session, unlocking the file (if it is still + * locked and freeing any data structures. + */ +extern void git_indexwriter_cleanup(git_indexwriter *writer); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/indexer.c b/deps/libgit2-sys-0.2.17/libgit2/src/indexer.c new file mode 100644 index 000000000..665d50fcd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/indexer.c @@ -0,0 +1,1077 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/indexer.h" +#include "git2/object.h" + +#include "common.h" +#include "pack.h" +#include "mwindow.h" +#include "posix.h" +#include "pack.h" +#include "filebuf.h" +#include "oid.h" +#include "oidmap.h" +#include "zstream.h" + +GIT__USE_OIDMAP; + +extern git_mutex git__mwindow_mutex; + +#define UINT31_MAX (0x7FFFFFFF) + +struct entry { + git_oid oid; + uint32_t crc; + uint32_t offset; + uint64_t offset_long; +}; + +struct git_indexer { + unsigned int parsed_header :1, + opened_pack :1, + have_stream :1, + have_delta :1; + struct git_pack_header hdr; + struct git_pack_file *pack; + unsigned int mode; + git_off_t off; + git_off_t entry_start; + git_packfile_stream stream; + size_t nr_objects; + git_vector objects; + git_vector deltas; + unsigned int fanout[256]; + git_hash_ctx hash_ctx; + git_oid hash; + git_transfer_progress_cb progress_cb; + void *progress_payload; + char objbuf[8*1024]; + + /* Needed to look up objects which we want to inject to fix a thin pack */ + git_odb *odb; + + /* Fields for calculating the packfile trailer (hash of everything before it) */ + char inbuf[GIT_OID_RAWSZ]; + size_t inbuf_len; + git_hash_ctx trailer; +}; + +struct delta_info { + git_off_t delta_off; +}; + +const git_oid *git_indexer_hash(const git_indexer *idx) +{ + return &idx->hash; +} + +static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack) +{ + int error; + git_map map; + + if ((error = p_mmap(&map, sizeof(*hdr), GIT_PROT_READ, GIT_MAP_SHARED, pack->mwf.fd, 0)) < 0) + return error; + + memcpy(hdr, map.data, sizeof(*hdr)); + p_munmap(&map); + + /* Verify we recognize this pack file format. */ + if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) { + giterr_set(GITERR_INDEXER, "Wrong pack signature"); + return -1; + } + + if (!pack_version_ok(hdr->hdr_version)) { + giterr_set(GITERR_INDEXER, "Wrong pack version"); + return -1; + } + + return 0; +} + +static int objects_cmp(const void *a, const void *b) +{ + const struct entry *entrya = a; + const struct entry *entryb = b; + + return git_oid__cmp(&entrya->oid, &entryb->oid); +} + +int git_indexer_new( + git_indexer **out, + const char *prefix, + unsigned int mode, + git_odb *odb, + git_transfer_progress_cb progress_cb, + void *progress_payload) +{ + git_indexer *idx; + git_buf path = GIT_BUF_INIT, tmp_path = GIT_BUF_INIT; + static const char suff[] = "/pack"; + int error, fd = -1; + + idx = git__calloc(1, sizeof(git_indexer)); + GITERR_CHECK_ALLOC(idx); + idx->odb = odb; + idx->progress_cb = progress_cb; + idx->progress_payload = progress_payload; + idx->mode = mode ? mode : GIT_PACK_FILE_MODE; + git_hash_ctx_init(&idx->hash_ctx); + git_hash_ctx_init(&idx->trailer); + + error = git_buf_joinpath(&path, prefix, suff); + if (error < 0) + goto cleanup; + + fd = git_futils_mktmp(&tmp_path, git_buf_cstr(&path), idx->mode); + git_buf_free(&path); + if (fd < 0) + goto cleanup; + + error = git_packfile_alloc(&idx->pack, git_buf_cstr(&tmp_path)); + git_buf_free(&tmp_path); + + if (error < 0) + goto cleanup; + + idx->pack->mwf.fd = fd; + if ((error = git_mwindow_file_register(&idx->pack->mwf)) < 0) + goto cleanup; + + *out = idx; + return 0; + +cleanup: + if (fd != -1) + p_close(fd); + + git_buf_free(&path); + git_buf_free(&tmp_path); + git__free(idx); + return -1; +} + +/* Try to store the delta so we can try to resolve it later */ +static int store_delta(git_indexer *idx) +{ + struct delta_info *delta; + + delta = git__calloc(1, sizeof(struct delta_info)); + GITERR_CHECK_ALLOC(delta); + delta->delta_off = idx->entry_start; + + if (git_vector_insert(&idx->deltas, delta) < 0) + return -1; + + return 0; +} + +static void hash_header(git_hash_ctx *ctx, git_off_t len, git_otype type) +{ + char buffer[64]; + size_t hdrlen; + + hdrlen = git_odb__format_object_header(buffer, sizeof(buffer), (size_t)len, type); + git_hash_update(ctx, buffer, hdrlen); +} + +static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream) +{ + ssize_t read; + + assert(idx && stream); + + do { + if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0) + break; + + git_hash_update(&idx->hash_ctx, idx->objbuf, read); + } while (read > 0); + + if (read < 0) + return (int)read; + + return 0; +} + +/* In order to create the packfile stream, we need to skip over the delta base description */ +static int advance_delta_offset(git_indexer *idx, git_otype type) +{ + git_mwindow *w = NULL; + + assert(type == GIT_OBJ_REF_DELTA || type == GIT_OBJ_OFS_DELTA); + + if (type == GIT_OBJ_REF_DELTA) { + idx->off += GIT_OID_RAWSZ; + } else { + git_off_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start); + git_mwindow_close(&w); + if (base_off < 0) + return (int)base_off; + } + + return 0; +} + +/* Read from the stream and discard any output */ +static int read_object_stream(git_indexer *idx, git_packfile_stream *stream) +{ + ssize_t read; + + assert(stream); + + do { + read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf)); + } while (read > 0); + + if (read < 0) + return (int)read; + + return 0; +} + +static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start, git_off_t size) +{ + void *ptr; + uint32_t crc; + unsigned int left, len; + git_mwindow *w = NULL; + + crc = crc32(0L, Z_NULL, 0); + while (size) { + ptr = git_mwindow_open(mwf, &w, start, (size_t)size, &left); + if (ptr == NULL) + return -1; + + len = min(left, (unsigned int)size); + crc = crc32(crc, ptr, len); + size -= len; + start += len; + git_mwindow_close(&w); + } + + *crc_out = htonl(crc); + return 0; +} + +static int store_object(git_indexer *idx) +{ + int i, error; + khiter_t k; + git_oid oid; + struct entry *entry; + git_off_t entry_size; + struct git_pack_entry *pentry; + git_off_t entry_start = idx->entry_start; + + entry = git__calloc(1, sizeof(*entry)); + GITERR_CHECK_ALLOC(entry); + + pentry = git__calloc(1, sizeof(struct git_pack_entry)); + GITERR_CHECK_ALLOC(pentry); + + git_hash_final(&oid, &idx->hash_ctx); + entry_size = idx->off - entry_start; + if (entry_start > UINT31_MAX) { + entry->offset = UINT32_MAX; + entry->offset_long = entry_start; + } else { + entry->offset = (uint32_t)entry_start; + } + + git_oid_cpy(&pentry->sha1, &oid); + pentry->offset = entry_start; + + k = kh_put(oid, idx->pack->idx_cache, &pentry->sha1, &error); + if (error == -1) { + git__free(pentry); + giterr_set_oom(); + goto on_error; + } + + if (error == 0) { + giterr_set(GITERR_INDEXER, "duplicate object %s found in pack", git_oid_tostr_s(&pentry->sha1)); + git__free(pentry); + goto on_error; + } + + + kh_value(idx->pack->idx_cache, k) = pentry; + + git_oid_cpy(&entry->oid, &oid); + + if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0) + goto on_error; + + /* Add the object to the list */ + if (git_vector_insert(&idx->objects, entry) < 0) + goto on_error; + + for (i = oid.id[0]; i < 256; ++i) { + idx->fanout[i]++; + } + + return 0; + +on_error: + git__free(entry); + + return -1; +} + +static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start) +{ + int i, error; + khiter_t k; + + if (entry_start > UINT31_MAX) { + entry->offset = UINT32_MAX; + entry->offset_long = entry_start; + } else { + entry->offset = (uint32_t)entry_start; + } + + pentry->offset = entry_start; + k = kh_put(oid, idx->pack->idx_cache, &pentry->sha1, &error); + if (!error) + return -1; + + kh_value(idx->pack->idx_cache, k) = pentry; + + /* Add the object to the list */ + if (git_vector_insert(&idx->objects, entry) < 0) + return -1; + + for (i = entry->oid.id[0]; i < 256; ++i) { + idx->fanout[i]++; + } + + return 0; +} + +static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_start) +{ + git_oid oid; + size_t entry_size; + struct entry *entry; + struct git_pack_entry *pentry = NULL; + + entry = git__calloc(1, sizeof(*entry)); + GITERR_CHECK_ALLOC(entry); + + if (git_odb__hashobj(&oid, obj) < 0) { + giterr_set(GITERR_INDEXER, "Failed to hash object"); + goto on_error; + } + + pentry = git__calloc(1, sizeof(struct git_pack_entry)); + GITERR_CHECK_ALLOC(pentry); + + git_oid_cpy(&pentry->sha1, &oid); + git_oid_cpy(&entry->oid, &oid); + entry->crc = crc32(0L, Z_NULL, 0); + + entry_size = (size_t)(idx->off - entry_start); + if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0) + goto on_error; + + return save_entry(idx, entry, pentry, entry_start); + +on_error: + git__free(pentry); + git__free(entry); + git__free(obj->data); + return -1; +} + +static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats) +{ + if (idx->progress_cb) + return giterr_set_after_callback_function( + idx->progress_cb(stats, idx->progress_payload), + "indexer progress"); + return 0; +} + +/* Hash everything but the last 20B of input */ +static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size) +{ + size_t to_expell, to_keep; + + if (size == 0) + return; + + /* Easy case, dump the buffer and the data minus the last 20 bytes */ + if (size >= GIT_OID_RAWSZ) { + git_hash_update(&idx->trailer, idx->inbuf, idx->inbuf_len); + git_hash_update(&idx->trailer, data, size - GIT_OID_RAWSZ); + + data += size - GIT_OID_RAWSZ; + memcpy(idx->inbuf, data, GIT_OID_RAWSZ); + idx->inbuf_len = GIT_OID_RAWSZ; + return; + } + + /* We can just append */ + if (idx->inbuf_len + size <= GIT_OID_RAWSZ) { + memcpy(idx->inbuf + idx->inbuf_len, data, size); + idx->inbuf_len += size; + return; + } + + /* We need to partially drain the buffer and then append */ + to_keep = GIT_OID_RAWSZ - size; + to_expell = idx->inbuf_len - to_keep; + + git_hash_update(&idx->trailer, idx->inbuf, to_expell); + + memmove(idx->inbuf, idx->inbuf + to_expell, to_keep); + memcpy(idx->inbuf + to_keep, data, size); + idx->inbuf_len += size - to_expell; +} + +static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size) +{ + git_file fd = idx->pack->mwf.fd; + size_t page_size; + size_t page_offset; + git_off_t page_start; + unsigned char *map_data; + git_map map; + int error; + + assert(data && size); + + if ((error = git__page_size(&page_size)) < 0) + return error; + + /* the offset needs to be at the beginning of the a page boundary */ + page_offset = offset % page_size; + page_start = offset - page_offset; + + if ((error = p_mmap(&map, page_offset + size, GIT_PROT_WRITE, GIT_MAP_SHARED, fd, page_start)) < 0) + return error; + + map_data = (unsigned char *)map.data; + memcpy(map_data + page_offset, data, size); + p_munmap(&map); + + return 0; +} + +static int append_to_pack(git_indexer *idx, const void *data, size_t size) +{ + git_off_t current_size = idx->pack->mwf.size; + + if (!size) + return 0; + + /* add the extra space we need at the end */ + if (p_ftruncate(idx->pack->mwf.fd, current_size + size) < 0) { + giterr_set(GITERR_OS, "Failed to increase size of pack file '%s'", idx->pack->pack_name); + return -1; + } + + return write_at(idx, data, idx->pack->mwf.size, size); +} + +int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats) +{ + int error = -1; + size_t processed; + struct git_pack_header *hdr = &idx->hdr; + git_mwindow_file *mwf = &idx->pack->mwf; + + assert(idx && data && stats); + + processed = stats->indexed_objects; + + if ((error = append_to_pack(idx, data, size)) < 0) + return error; + + hash_partially(idx, data, (int)size); + + /* Make sure we set the new size of the pack */ + idx->pack->mwf.size += size; + + if (!idx->parsed_header) { + unsigned int total_objects; + + if ((unsigned)idx->pack->mwf.size < sizeof(struct git_pack_header)) + return 0; + + if ((error = parse_header(&idx->hdr, idx->pack)) < 0) + return error; + + idx->parsed_header = 1; + idx->nr_objects = ntohl(hdr->hdr_entries); + idx->off = sizeof(struct git_pack_header); + + /* for now, limit to 2^32 objects */ + assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects)); + if (idx->nr_objects == (size_t)((unsigned int)idx->nr_objects)) + total_objects = (unsigned int)idx->nr_objects; + else + total_objects = UINT_MAX; + + idx->pack->idx_cache = git_oidmap_alloc(); + GITERR_CHECK_ALLOC(idx->pack->idx_cache); + + idx->pack->has_cache = 1; + if (git_vector_init(&idx->objects, total_objects, objects_cmp) < 0) + return -1; + + if (git_vector_init(&idx->deltas, total_objects / 2, NULL) < 0) + return -1; + + stats->received_objects = 0; + stats->local_objects = 0; + stats->total_deltas = 0; + stats->indexed_deltas = 0; + processed = stats->indexed_objects = 0; + stats->total_objects = total_objects; + + if ((error = do_progress_callback(idx, stats)) != 0) + return error; + } + + /* Now that we have data in the pack, let's try to parse it */ + + /* As the file grows any windows we try to use will be out of date */ + git_mwindow_free_all(mwf); + + while (processed < idx->nr_objects) { + git_packfile_stream *stream = &idx->stream; + git_off_t entry_start = idx->off; + size_t entry_size; + git_otype type; + git_mwindow *w = NULL; + + if (idx->pack->mwf.size <= idx->off + 20) + return 0; + + if (!idx->have_stream) { + error = git_packfile_unpack_header(&entry_size, &type, mwf, &w, &idx->off); + if (error == GIT_EBUFS) { + idx->off = entry_start; + return 0; + } + if (error < 0) + goto on_error; + + git_mwindow_close(&w); + idx->entry_start = entry_start; + git_hash_init(&idx->hash_ctx); + + if (type == GIT_OBJ_REF_DELTA || type == GIT_OBJ_OFS_DELTA) { + error = advance_delta_offset(idx, type); + if (error == GIT_EBUFS) { + idx->off = entry_start; + return 0; + } + if (error < 0) + goto on_error; + + idx->have_delta = 1; + } else { + idx->have_delta = 0; + hash_header(&idx->hash_ctx, entry_size, type); + } + + idx->have_stream = 1; + + error = git_packfile_stream_open(stream, idx->pack, idx->off); + if (error < 0) + goto on_error; + } + + if (idx->have_delta) { + error = read_object_stream(idx, stream); + } else { + error = hash_object_stream(idx, stream); + } + + idx->off = stream->curpos; + if (error == GIT_EBUFS) + return 0; + + /* We want to free the stream reasorces no matter what here */ + idx->have_stream = 0; + git_packfile_stream_free(stream); + + if (error < 0) + goto on_error; + + if (idx->have_delta) { + error = store_delta(idx); + } else { + error = store_object(idx); + } + + if (error < 0) + goto on_error; + + if (!idx->have_delta) { + stats->indexed_objects = (unsigned int)++processed; + } + stats->received_objects++; + + if ((error = do_progress_callback(idx, stats)) != 0) + goto on_error; + } + + return 0; + +on_error: + git_mwindow_free_all(mwf); + return error; +} + +static int index_path(git_buf *path, git_indexer *idx, const char *suffix) +{ + const char prefix[] = "pack-"; + size_t slash = (size_t)path->size; + + /* search backwards for '/' */ + while (slash > 0 && path->ptr[slash - 1] != '/') + slash--; + + if (git_buf_grow(path, slash + 1 + strlen(prefix) + + GIT_OID_HEXSZ + strlen(suffix) + 1) < 0) + return -1; + + git_buf_truncate(path, slash); + git_buf_puts(path, prefix); + git_oid_fmt(path->ptr + git_buf_len(path), &idx->hash); + path->size += GIT_OID_HEXSZ; + git_buf_puts(path, suffix); + + return git_buf_oom(path) ? -1 : 0; +} + +/** + * Rewind the packfile by the trailer, as we might need to fix the + * packfile by injecting objects at the tail and must overwrite it. + */ +static void seek_back_trailer(git_indexer *idx) +{ + idx->pack->mwf.size -= GIT_OID_RAWSZ; + git_mwindow_free_all(&idx->pack->mwf); +} + +static int inject_object(git_indexer *idx, git_oid *id) +{ + git_odb_object *obj; + struct entry *entry; + struct git_pack_entry *pentry = NULL; + git_oid foo = {{0}}; + unsigned char hdr[64]; + git_buf buf = GIT_BUF_INIT; + git_off_t entry_start; + const void *data; + size_t len, hdr_len; + int error; + + seek_back_trailer(idx); + entry_start = idx->pack->mwf.size; + + if (git_odb_read(&obj, idx->odb, id) < 0) { + giterr_set(GITERR_INDEXER, "missing delta bases"); + return -1; + } + + data = git_odb_object_data(obj); + len = git_odb_object_size(obj); + + entry = git__calloc(1, sizeof(*entry)); + GITERR_CHECK_ALLOC(entry); + + entry->crc = crc32(0L, Z_NULL, 0); + + /* Write out the object header */ + hdr_len = git_packfile__object_header(hdr, len, git_odb_object_type(obj)); + if ((error = append_to_pack(idx, hdr, hdr_len)) < 0) + goto cleanup; + + idx->pack->mwf.size += hdr_len; + entry->crc = crc32(entry->crc, hdr, (uInt)hdr_len); + + if ((error = git_zstream_deflatebuf(&buf, data, len)) < 0) + goto cleanup; + + /* And then the compressed object */ + if ((error = append_to_pack(idx, buf.ptr, buf.size)) < 0) + goto cleanup; + + idx->pack->mwf.size += buf.size; + entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, (uInt)buf.size)); + git_buf_free(&buf); + + /* Write a fake trailer so the pack functions play ball */ + + if ((error = append_to_pack(idx, &foo, GIT_OID_RAWSZ)) < 0) + goto cleanup; + + idx->pack->mwf.size += GIT_OID_RAWSZ; + + pentry = git__calloc(1, sizeof(struct git_pack_entry)); + GITERR_CHECK_ALLOC(pentry); + + git_oid_cpy(&pentry->sha1, id); + git_oid_cpy(&entry->oid, id); + idx->off = entry_start + hdr_len + len; + + error = save_entry(idx, entry, pentry, entry_start); + +cleanup: + if (error) { + git__free(entry); + git__free(pentry); + } + + git_odb_object_free(obj); + return error; +} + +static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats) +{ + int error, found_ref_delta = 0; + unsigned int i; + struct delta_info *delta; + size_t size; + git_otype type; + git_mwindow *w = NULL; + git_off_t curpos = 0; + unsigned char *base_info; + unsigned int left = 0; + git_oid base; + + assert(git_vector_length(&idx->deltas) > 0); + + if (idx->odb == NULL) { + giterr_set(GITERR_INDEXER, "cannot fix a thin pack without an ODB"); + return -1; + } + + /* Loop until we find the first REF delta */ + git_vector_foreach(&idx->deltas, i, delta) { + if (!delta) + continue; + + curpos = delta->delta_off; + error = git_packfile_unpack_header(&size, &type, &idx->pack->mwf, &w, &curpos); + git_mwindow_close(&w); + if (error < 0) + return error; + + if (type == GIT_OBJ_REF_DELTA) { + found_ref_delta = 1; + break; + } + } + + if (!found_ref_delta) { + giterr_set(GITERR_INDEXER, "no REF_DELTA found, cannot inject object"); + return -1; + } + + /* curpos now points to the base information, which is an OID */ + base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos, GIT_OID_RAWSZ, &left); + if (base_info == NULL) { + giterr_set(GITERR_INDEXER, "failed to map delta information"); + return -1; + } + + git_oid_fromraw(&base, base_info); + git_mwindow_close(&w); + + if (inject_object(idx, &base) < 0) + return -1; + + stats->local_objects++; + + return 0; +} + +static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats) +{ + unsigned int i; + struct delta_info *delta; + int progressed = 0, non_null = 0, progress_cb_result; + + while (idx->deltas.length > 0) { + progressed = 0; + non_null = 0; + git_vector_foreach(&idx->deltas, i, delta) { + git_rawobj obj; + + if (!delta) + continue; + + non_null = 1; + idx->off = delta->delta_off; + if (git_packfile_unpack(&obj, idx->pack, &idx->off) < 0) + continue; + + if (hash_and_save(idx, &obj, delta->delta_off) < 0) + continue; + + git__free(obj.data); + stats->indexed_objects++; + stats->indexed_deltas++; + progressed = 1; + if ((progress_cb_result = do_progress_callback(idx, stats)) < 0) + return progress_cb_result; + + /* remove from the list */ + git_vector_set(NULL, &idx->deltas, i, NULL); + git__free(delta); + } + + /* if none were actually set, we're done */ + if (!non_null) + break; + + if (!progressed && (fix_thin_pack(idx, stats) < 0)) { + return -1; + } + } + + return 0; +} + +static int update_header_and_rehash(git_indexer *idx, git_transfer_progress *stats) +{ + void *ptr; + size_t chunk = 1024*1024; + git_off_t hashed = 0; + git_mwindow *w = NULL; + git_mwindow_file *mwf; + unsigned int left; + + mwf = &idx->pack->mwf; + + git_hash_init(&idx->trailer); + + + /* Update the header to include the numer of local objects we injected */ + idx->hdr.hdr_entries = htonl(stats->total_objects + stats->local_objects); + if (write_at(idx, &idx->hdr, 0, sizeof(struct git_pack_header)) < 0) + return -1; + + /* + * We now use the same technique as before to determine the + * hash. We keep reading up to the end and let + * hash_partially() keep the existing trailer out of the + * calculation. + */ + git_mwindow_free_all(mwf); + idx->inbuf_len = 0; + while (hashed < mwf->size) { + ptr = git_mwindow_open(mwf, &w, hashed, chunk, &left); + if (ptr == NULL) + return -1; + + hash_partially(idx, ptr, left); + hashed += left; + + git_mwindow_close(&w); + } + + return 0; +} + +int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) +{ + git_mwindow *w = NULL; + unsigned int i, long_offsets = 0, left; + int error; + struct git_pack_idx_header hdr; + git_buf filename = GIT_BUF_INIT; + struct entry *entry; + git_oid trailer_hash, file_hash; + git_hash_ctx ctx; + git_filebuf index_file = {0}; + void *packfile_trailer; + + if (git_hash_ctx_init(&ctx) < 0) + return -1; + + /* Test for this before resolve_deltas(), as it plays with idx->off */ + if (idx->off < idx->pack->mwf.size - 20) { + giterr_set(GITERR_INDEXER, "Unexpected data at the end of the pack"); + return -1; + } + + packfile_trailer = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left); + if (packfile_trailer == NULL) { + git_mwindow_close(&w); + goto on_error; + } + + /* Compare the packfile trailer as it was sent to us and what we calculated */ + git_oid_fromraw(&file_hash, packfile_trailer); + git_mwindow_close(&w); + + git_hash_final(&trailer_hash, &idx->trailer); + if (git_oid_cmp(&file_hash, &trailer_hash)) { + giterr_set(GITERR_INDEXER, "packfile trailer mismatch"); + return -1; + } + + /* Freeze the number of deltas */ + stats->total_deltas = stats->total_objects - stats->indexed_objects; + + if ((error = resolve_deltas(idx, stats)) < 0) + return error; + + if (stats->indexed_objects != stats->total_objects) { + giterr_set(GITERR_INDEXER, "early EOF"); + return -1; + } + + if (stats->local_objects > 0) { + if (update_header_and_rehash(idx, stats) < 0) + return -1; + + git_hash_final(&trailer_hash, &idx->trailer); + write_at(idx, &trailer_hash, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ); + } + + git_vector_sort(&idx->objects); + + git_buf_sets(&filename, idx->pack->pack_name); + git_buf_shorten(&filename, strlen("pack")); + git_buf_puts(&filename, "idx"); + if (git_buf_oom(&filename)) + return -1; + + if (git_filebuf_open(&index_file, filename.ptr, + GIT_FILEBUF_HASH_CONTENTS, idx->mode) < 0) + goto on_error; + + /* Write out the header */ + hdr.idx_signature = htonl(PACK_IDX_SIGNATURE); + hdr.idx_version = htonl(2); + git_filebuf_write(&index_file, &hdr, sizeof(hdr)); + + /* Write out the fanout table */ + for (i = 0; i < 256; ++i) { + uint32_t n = htonl(idx->fanout[i]); + git_filebuf_write(&index_file, &n, sizeof(n)); + } + + /* Write out the object names (SHA-1 hashes) */ + git_vector_foreach(&idx->objects, i, entry) { + git_filebuf_write(&index_file, &entry->oid, sizeof(git_oid)); + git_hash_update(&ctx, &entry->oid, GIT_OID_RAWSZ); + } + git_hash_final(&idx->hash, &ctx); + + /* Write out the CRC32 values */ + git_vector_foreach(&idx->objects, i, entry) { + git_filebuf_write(&index_file, &entry->crc, sizeof(uint32_t)); + } + + /* Write out the offsets */ + git_vector_foreach(&idx->objects, i, entry) { + uint32_t n; + + if (entry->offset == UINT32_MAX) + n = htonl(0x80000000 | long_offsets++); + else + n = htonl(entry->offset); + + git_filebuf_write(&index_file, &n, sizeof(uint32_t)); + } + + /* Write out the long offsets */ + git_vector_foreach(&idx->objects, i, entry) { + uint32_t split[2]; + + if (entry->offset != UINT32_MAX) + continue; + + split[0] = htonl(entry->offset_long >> 32); + split[1] = htonl(entry->offset_long & 0xffffffff); + + git_filebuf_write(&index_file, &split, sizeof(uint32_t) * 2); + } + + /* Write out the packfile trailer to the index */ + if (git_filebuf_write(&index_file, &trailer_hash, GIT_OID_RAWSZ) < 0) + goto on_error; + + /* Write out the hash of the idx */ + if (git_filebuf_hash(&trailer_hash, &index_file) < 0) + goto on_error; + + git_filebuf_write(&index_file, &trailer_hash, sizeof(git_oid)); + + /* Figure out what the final name should be */ + if (index_path(&filename, idx, ".idx") < 0) + goto on_error; + + /* Commit file */ + if (git_filebuf_commit_at(&index_file, filename.ptr) < 0) + goto on_error; + + git_mwindow_free_all(&idx->pack->mwf); + /* We need to close the descriptor here so Windows doesn't choke on commit_at */ + if (p_close(idx->pack->mwf.fd) < 0) { + giterr_set(GITERR_OS, "failed to close packfile"); + goto on_error; + } + + idx->pack->mwf.fd = -1; + + if (index_path(&filename, idx, ".pack") < 0) + goto on_error; + + /* And don't forget to rename the packfile to its new place. */ + p_rename(idx->pack->pack_name, git_buf_cstr(&filename)); + + git_buf_free(&filename); + git_hash_ctx_cleanup(&ctx); + return 0; + +on_error: + git_mwindow_free_all(&idx->pack->mwf); + git_filebuf_cleanup(&index_file); + git_buf_free(&filename); + git_hash_ctx_cleanup(&ctx); + return -1; +} + +void git_indexer_free(git_indexer *idx) +{ + if (idx == NULL) + return; + + git_vector_free_deep(&idx->objects); + + if (idx->pack && idx->pack->idx_cache) { + struct git_pack_entry *pentry; + kh_foreach_value( + idx->pack->idx_cache, pentry, { git__free(pentry); }); + + git_oidmap_free(idx->pack->idx_cache); + } + + git_vector_free_deep(&idx->deltas); + + if (!git_mutex_lock(&git__mwindow_mutex)) { + git_packfile_free(idx->pack); + git_mutex_unlock(&git__mwindow_mutex); + } + + git_hash_ctx_cleanup(&idx->trailer); + git_hash_ctx_cleanup(&idx->hash_ctx); + git__free(idx); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/integer.h b/deps/libgit2-sys-0.2.17/libgit2/src/integer.h new file mode 100644 index 000000000..b08094c2f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/integer.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_integer_h__ +#define INCLUDE_integer_h__ + +/** @return true if p fits into the range of a size_t */ +GIT_INLINE(int) git__is_sizet(git_off_t p) +{ + size_t r = (size_t)p; + return p == (git_off_t)r; +} + +/** @return true if p fits into the range of an ssize_t */ +GIT_INLINE(int) git__is_ssizet(size_t p) +{ + ssize_t r = (ssize_t)p; + return p == (size_t)r; +} + +/** @return true if p fits into the range of a uint32_t */ +GIT_INLINE(int) git__is_uint32(size_t p) +{ + uint32_t r = (uint32_t)p; + return p == (size_t)r; +} + +/** @return true if p fits into the range of an unsigned long */ +GIT_INLINE(int) git__is_ulong(git_off_t p) +{ + unsigned long r = (unsigned long)p; + return p == (git_off_t)r; +} + +/** @return true if p fits into the range of an int */ +GIT_INLINE(int) git__is_int(long long p) +{ + int r = (int)p; + return p == (long long)r; +} + +/** + * Sets `one + two` into `out`, unless the arithmetic would overflow. + * @return true if the result fits in a `uint64_t`, false on overflow. + */ +GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t two) +{ + if (UINT64_MAX - one < two) + return true; + *out = one + two; + return false; +} + +/* Use clang/gcc compiler intrinsics whenever possible */ +#if (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow) +# define git__add_sizet_overflow(out, one, two) \ + __builtin_uadd_overflow(one, two, out) +# define git__multiply_sizet_overflow(out, one, two) \ + __builtin_umul_overflow(one, two, out) +#elif (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow) +# define git__add_sizet_overflow(out, one, two) \ + __builtin_uaddl_overflow(one, two, out) +# define git__multiply_sizet_overflow(out, one, two) \ + __builtin_umull_overflow(one, two, out) +#else + +/** + * Sets `one + two` into `out`, unless the arithmetic would overflow. + * @return true if the result fits in a `size_t`, false on overflow. + */ +GIT_INLINE(bool) git__add_sizet_overflow(size_t *out, size_t one, size_t two) +{ + if (SIZE_MAX - one < two) + return true; + *out = one + two; + return false; +} + +/** + * Sets `one * two` into `out`, unless the arithmetic would overflow. + * @return true if the result fits in a `size_t`, false on overflow. + */ +GIT_INLINE(bool) git__multiply_sizet_overflow(size_t *out, size_t one, size_t two) +{ + if (one && SIZE_MAX / one < two) + return true; + *out = one * two; + return false; +} + +#endif + +#endif /* INCLUDE_integer_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/iterator.c b/deps/libgit2-sys-0.2.17/libgit2/src/iterator.c new file mode 100644 index 000000000..9ddacebd1 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/iterator.c @@ -0,0 +1,1708 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "iterator.h" +#include "tree.h" +#include "index.h" +#include "ignore.h" +#include "buffer.h" +#include "submodule.h" +#include + +#define ITERATOR_SET_CB(P,NAME_LC) do { \ + (P)->cb.current = NAME_LC ## _iterator__current; \ + (P)->cb.advance = NAME_LC ## _iterator__advance; \ + (P)->cb.advance_into = NAME_LC ## _iterator__advance_into; \ + (P)->cb.seek = NAME_LC ## _iterator__seek; \ + (P)->cb.reset = NAME_LC ## _iterator__reset; \ + (P)->cb.at_end = NAME_LC ## _iterator__at_end; \ + (P)->cb.free = NAME_LC ## _iterator__free; \ + } while (0) + +#define ITERATOR_CASE_FLAGS \ + (GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_DONT_IGNORE_CASE) + +#define ITERATOR_BASE_INIT(P,NAME_LC,NAME_UC,REPO) do { \ + (P)->base.type = GIT_ITERATOR_TYPE_ ## NAME_UC; \ + (P)->base.cb = &(P)->cb; \ + ITERATOR_SET_CB(P,NAME_LC); \ + (P)->base.repo = (REPO); \ + (P)->base.start = start ? git__strdup(start) : NULL; \ + (P)->base.end = end ? git__strdup(end) : NULL; \ + if ((start && !(P)->base.start) || (end && !(P)->base.end)) { \ + git__free(P); return -1; } \ + (P)->base.prefixcomp = git__prefixcmp; \ + (P)->base.flags = flags & ~ITERATOR_CASE_FLAGS; \ + if ((P)->base.flags & GIT_ITERATOR_DONT_AUTOEXPAND) \ + (P)->base.flags |= GIT_ITERATOR_INCLUDE_TREES; \ + } while (0) + +#define iterator__flag(I,F) ((((git_iterator *)(I))->flags & GIT_ITERATOR_ ## F) != 0) +#define iterator__ignore_case(I) iterator__flag(I,IGNORE_CASE) +#define iterator__include_trees(I) iterator__flag(I,INCLUDE_TREES) +#define iterator__dont_autoexpand(I) iterator__flag(I,DONT_AUTOEXPAND) +#define iterator__do_autoexpand(I) !iterator__flag(I,DONT_AUTOEXPAND) + +#define GIT_ITERATOR_FIRST_ACCESS (1 << 15) +#define iterator__has_been_accessed(I) iterator__flag(I,FIRST_ACCESS) + +#define iterator__end(I) ((git_iterator *)(I))->end +#define iterator__past_end(I,PATH) \ + (iterator__end(I) && ((git_iterator *)(I))->prefixcomp((PATH),iterator__end(I)) > 0) + + +static int iterator__reset_range( + git_iterator *iter, const char *start, const char *end) +{ + if (start) { + if (iter->start) + git__free(iter->start); + iter->start = git__strdup(start); + GITERR_CHECK_ALLOC(iter->start); + } + + if (end) { + if (iter->end) + git__free(iter->end); + iter->end = git__strdup(end); + GITERR_CHECK_ALLOC(iter->end); + } + + iter->flags &= ~GIT_ITERATOR_FIRST_ACCESS; + + return 0; +} + +static int iterator__update_ignore_case( + git_iterator *iter, + git_iterator_flag_t flags) +{ + int error = 0, ignore_case = -1; + + if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0) + ignore_case = true; + else if ((flags & GIT_ITERATOR_DONT_IGNORE_CASE) != 0) + ignore_case = false; + else { + git_index *index; + + if (!(error = git_repository_index__weakptr(&index, iter->repo))) + ignore_case = (index->ignore_case != false); + } + + if (ignore_case > 0) + iter->flags = (iter->flags | GIT_ITERATOR_IGNORE_CASE); + else if (ignore_case == 0) + iter->flags = (iter->flags & ~GIT_ITERATOR_IGNORE_CASE); + + iter->prefixcomp = iterator__ignore_case(iter) ? + git__prefixcmp_icase : git__prefixcmp; + + return error; +} + +GIT_INLINE(void) iterator__clear_entry(const git_index_entry **entry) +{ + if (entry) *entry = NULL; +} + + +static int empty_iterator__noop(const git_index_entry **e, git_iterator *i) +{ + GIT_UNUSED(i); + iterator__clear_entry(e); + return GIT_ITEROVER; +} + +static int empty_iterator__seek(git_iterator *i, const char *p) +{ + GIT_UNUSED(i); GIT_UNUSED(p); + return -1; +} + +static int empty_iterator__reset(git_iterator *i, const char *s, const char *e) +{ + GIT_UNUSED(i); GIT_UNUSED(s); GIT_UNUSED(e); + return 0; +} + +static int empty_iterator__at_end(git_iterator *i) +{ + GIT_UNUSED(i); + return 1; +} + +static void empty_iterator__free(git_iterator *i) +{ + GIT_UNUSED(i); +} + +typedef struct { + git_iterator base; + git_iterator_callbacks cb; +} empty_iterator; + +int git_iterator_for_nothing( + git_iterator **iter, + git_iterator_flag_t flags, + const char *start, + const char *end) +{ + empty_iterator *i = git__calloc(1, sizeof(empty_iterator)); + GITERR_CHECK_ALLOC(i); + +#define empty_iterator__current empty_iterator__noop +#define empty_iterator__advance empty_iterator__noop +#define empty_iterator__advance_into empty_iterator__noop + + ITERATOR_BASE_INIT(i, empty, EMPTY, NULL); + + if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0) + i->base.flags |= GIT_ITERATOR_IGNORE_CASE; + + *iter = (git_iterator *)i; + return 0; +} + + +typedef struct tree_iterator_entry tree_iterator_entry; +struct tree_iterator_entry { + tree_iterator_entry *parent; + const git_tree_entry *te; + git_tree *tree; +}; + +typedef struct tree_iterator_frame tree_iterator_frame; +struct tree_iterator_frame { + tree_iterator_frame *up, *down; + + size_t n_entries; /* items in this frame */ + size_t current; /* start of currently active range in frame */ + size_t next; /* start of next range in frame */ + + const char *start; + size_t startlen; + + tree_iterator_entry *entries[GIT_FLEX_ARRAY]; +}; + +typedef struct { + git_iterator base; + git_iterator_callbacks cb; + tree_iterator_frame *head, *root; + git_pool pool; + git_index_entry entry; + git_buf path; + int path_ambiguities; + bool path_has_filename; + bool entry_is_current; + int (*strncomp)(const char *a, const char *b, size_t sz); +} tree_iterator; + +static char *tree_iterator__current_filename( + tree_iterator *ti, const git_tree_entry *te) +{ + if (!ti->path_has_filename) { + if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0) + return NULL; + + if (git_tree_entry__is_tree(te) && git_buf_putc(&ti->path, '/') < 0) + return NULL; + + ti->path_has_filename = true; + } + + return ti->path.ptr; +} + +static void tree_iterator__rewrite_filename(tree_iterator *ti) +{ + tree_iterator_entry *scan = ti->head->entries[ti->head->current]; + ssize_t strpos = ti->path.size; + const git_tree_entry *te; + + if (strpos && ti->path.ptr[strpos - 1] == '/') + strpos--; + + for (; scan && (te = scan->te); scan = scan->parent) { + strpos -= te->filename_len; + memcpy(&ti->path.ptr[strpos], te->filename, te->filename_len); + strpos -= 1; /* separator */ + } +} + +static int tree_iterator__te_cmp( + const git_tree_entry *a, + const git_tree_entry *b, + int (*compare)(const char *, const char *, size_t)) +{ + return git_path_cmp( + a->filename, a->filename_len, a->attr == GIT_FILEMODE_TREE, + b->filename, b->filename_len, b->attr == GIT_FILEMODE_TREE, + compare); +} + +static int tree_iterator__ci_cmp(const void *a, const void *b, void *p) +{ + const tree_iterator_entry *ae = a, *be = b; + int cmp = tree_iterator__te_cmp(ae->te, be->te, git__strncasecmp); + + if (!cmp) { + /* stabilize sort order among equivalent names */ + if (!ae->parent->te || !be->parent->te) + cmp = tree_iterator__te_cmp(ae->te, be->te, git__strncmp); + else + cmp = tree_iterator__ci_cmp(ae->parent, be->parent, p); + } + + return cmp; +} + +static int tree_iterator__search_cmp(const void *key, const void *val, void *p) +{ + const tree_iterator_frame *tf = key; + const git_tree_entry *te = ((tree_iterator_entry *)val)->te; + + return git_path_cmp( + tf->start, tf->startlen, false, + te->filename, te->filename_len, te->attr == GIT_FILEMODE_TREE, + ((tree_iterator *)p)->strncomp); +} + +static bool tree_iterator__move_to_next( + tree_iterator *ti, tree_iterator_frame *tf) +{ + if (tf->next > tf->current + 1) + ti->path_ambiguities--; + + if (!tf->up) { /* at root */ + tf->current = tf->next; + return false; + } + + for (; tf->current < tf->next; tf->current++) { + git_tree_free(tf->entries[tf->current]->tree); + tf->entries[tf->current]->tree = NULL; + } + + return (tf->current < tf->n_entries); +} + +static int tree_iterator__set_next(tree_iterator *ti, tree_iterator_frame *tf) +{ + int error = 0; + const git_tree_entry *te, *last = NULL; + + tf->next = tf->current; + + for (; tf->next < tf->n_entries; tf->next++, last = te) { + te = tf->entries[tf->next]->te; + + if (last && tree_iterator__te_cmp(last, te, ti->strncomp)) + break; + + /* try to load trees for items in [current,next) range */ + if (!error && git_tree_entry__is_tree(te)) + error = git_tree_lookup( + &tf->entries[tf->next]->tree, ti->base.repo, &te->oid); + } + + if (tf->next > tf->current + 1) + ti->path_ambiguities++; + + /* if a tree lookup failed, advance over this span and return failure */ + if (error < 0) { + tree_iterator__move_to_next(ti, tf); + return error; + } + + if (last && !tree_iterator__current_filename(ti, last)) + return -1; /* must have been allocation failure */ + + return 0; +} + +GIT_INLINE(bool) tree_iterator__at_tree(tree_iterator *ti) +{ + return (ti->head->current < ti->head->n_entries && + ti->head->entries[ti->head->current]->tree != NULL); +} + +static int tree_iterator__push_frame(tree_iterator *ti) +{ + int error = 0; + tree_iterator_frame *head = ti->head, *tf = NULL; + size_t i, n_entries = 0, alloclen; + + if (head->current >= head->n_entries || !head->entries[head->current]->tree) + return GIT_ITEROVER; + + for (i = head->current; i < head->next; ++i) + n_entries += git_tree_entrycount(head->entries[i]->tree); + + GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, sizeof(tree_iterator_entry *), n_entries); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, sizeof(tree_iterator_frame)); + + tf = git__calloc(1, alloclen); + GITERR_CHECK_ALLOC(tf); + + tf->n_entries = n_entries; + + tf->up = head; + head->down = tf; + ti->head = tf; + + for (i = head->current, n_entries = 0; i < head->next; ++i) { + git_tree *tree = head->entries[i]->tree; + size_t j, max_j = git_tree_entrycount(tree); + + for (j = 0; j < max_j; ++j) { + tree_iterator_entry *entry = git_pool_malloc(&ti->pool, 1); + GITERR_CHECK_ALLOC(entry); + + entry->parent = head->entries[i]; + entry->te = git_tree_entry_byindex(tree, j); + entry->tree = NULL; + + tf->entries[n_entries++] = entry; + } + } + + /* if ignore_case, sort entries case insensitively */ + if (iterator__ignore_case(ti)) + git__tsort_r( + (void **)tf->entries, tf->n_entries, tree_iterator__ci_cmp, tf); + + /* pick tf->current based on "start" (or start at zero) */ + if (head->startlen > 0) { + git__bsearch_r((void **)tf->entries, tf->n_entries, head, + tree_iterator__search_cmp, ti, &tf->current); + + while (tf->current && + !tree_iterator__search_cmp(head, tf->entries[tf->current-1], ti)) + tf->current--; + + if ((tf->start = strchr(head->start, '/')) != NULL) { + tf->start++; + tf->startlen = strlen(tf->start); + } + } + + ti->path_has_filename = ti->entry_is_current = false; + + if ((error = tree_iterator__set_next(ti, tf)) < 0) + return error; + + /* autoexpand as needed */ + if (!iterator__include_trees(ti) && tree_iterator__at_tree(ti)) + return tree_iterator__push_frame(ti); + + return 0; +} + +static bool tree_iterator__pop_frame(tree_iterator *ti, bool final) +{ + tree_iterator_frame *tf = ti->head; + + if (!tf->up) + return false; + + ti->head = tf->up; + ti->head->down = NULL; + + tree_iterator__move_to_next(ti, tf); + + if (!final) { /* if final, don't bother to clean up */ + git_pool_free_array(&ti->pool, tf->n_entries, (void **)tf->entries); + git_buf_rtruncate_at_char(&ti->path, '/'); + } + + git__free(tf); + + return true; +} + +static void tree_iterator__pop_all(tree_iterator *ti, bool to_end, bool final) +{ + while (tree_iterator__pop_frame(ti, final)) /* pop to root */; + + if (!final) { + ti->head->current = to_end ? ti->head->n_entries : 0; + ti->path_ambiguities = 0; + git_buf_clear(&ti->path); + } +} + +static int tree_iterator__update_entry(tree_iterator *ti) +{ + tree_iterator_frame *tf; + const git_tree_entry *te; + + if (ti->entry_is_current) + return 0; + + tf = ti->head; + te = tf->entries[tf->current]->te; + + ti->entry.mode = te->attr; + git_oid_cpy(&ti->entry.id, &te->oid); + + ti->entry.path = tree_iterator__current_filename(ti, te); + GITERR_CHECK_ALLOC(ti->entry.path); + + if (ti->path_ambiguities > 0) + tree_iterator__rewrite_filename(ti); + + if (iterator__past_end(ti, ti->entry.path)) { + tree_iterator__pop_all(ti, true, false); + return GIT_ITEROVER; + } + + ti->entry_is_current = true; + + return 0; +} + +static int tree_iterator__current( + const git_index_entry **entry, git_iterator *self) +{ + int error; + tree_iterator *ti = (tree_iterator *)self; + tree_iterator_frame *tf = ti->head; + + iterator__clear_entry(entry); + + if (tf->current >= tf->n_entries) + return GIT_ITEROVER; + + if ((error = tree_iterator__update_entry(ti)) < 0) + return error; + + if (entry) + *entry = &ti->entry; + + ti->base.flags |= GIT_ITERATOR_FIRST_ACCESS; + + return 0; +} + +static int tree_iterator__advance_into( + const git_index_entry **entry, git_iterator *self) +{ + int error = 0; + tree_iterator *ti = (tree_iterator *)self; + + iterator__clear_entry(entry); + + if (tree_iterator__at_tree(ti)) + error = tree_iterator__push_frame(ti); + + if (!error && entry) + error = tree_iterator__current(entry, self); + + return error; +} + +static int tree_iterator__advance( + const git_index_entry **entry, git_iterator *self) +{ + int error; + tree_iterator *ti = (tree_iterator *)self; + tree_iterator_frame *tf = ti->head; + + iterator__clear_entry(entry); + + if (tf->current >= tf->n_entries) + return GIT_ITEROVER; + + if (!iterator__has_been_accessed(ti)) + return tree_iterator__current(entry, self); + + if (iterator__do_autoexpand(ti) && iterator__include_trees(ti) && + tree_iterator__at_tree(ti)) + return tree_iterator__advance_into(entry, self); + + if (ti->path_has_filename) { + git_buf_rtruncate_at_char(&ti->path, '/'); + ti->path_has_filename = ti->entry_is_current = false; + } + + /* scan forward and up, advancing in frame or popping frame when done */ + while (!tree_iterator__move_to_next(ti, tf) && + tree_iterator__pop_frame(ti, false)) + tf = ti->head; + + /* find next and load trees */ + if ((error = tree_iterator__set_next(ti, tf)) < 0) + return error; + + /* deal with include_trees / auto_expand as needed */ + if (!iterator__include_trees(ti) && tree_iterator__at_tree(ti)) + return tree_iterator__advance_into(entry, self); + + return tree_iterator__current(entry, self); +} + +static int tree_iterator__seek(git_iterator *self, const char *prefix) +{ + GIT_UNUSED(self); GIT_UNUSED(prefix); + return -1; +} + +static int tree_iterator__reset( + git_iterator *self, const char *start, const char *end) +{ + tree_iterator *ti = (tree_iterator *)self; + + tree_iterator__pop_all(ti, false, false); + + if (iterator__reset_range(self, start, end) < 0) + return -1; + + return tree_iterator__push_frame(ti); /* re-expand root tree */ +} + +static int tree_iterator__at_end(git_iterator *self) +{ + tree_iterator *ti = (tree_iterator *)self; + return (ti->head->current >= ti->head->n_entries); +} + +static void tree_iterator__free(git_iterator *self) +{ + tree_iterator *ti = (tree_iterator *)self; + + tree_iterator__pop_all(ti, true, false); + + git_tree_free(ti->head->entries[0]->tree); + git__free(ti->head); + git_pool_clear(&ti->pool); + git_buf_free(&ti->path); +} + +static int tree_iterator__create_root_frame(tree_iterator *ti, git_tree *tree) +{ + size_t sz = sizeof(tree_iterator_frame) + sizeof(tree_iterator_entry); + tree_iterator_frame *root = git__calloc(sz, sizeof(char)); + GITERR_CHECK_ALLOC(root); + + root->n_entries = 1; + root->next = 1; + root->start = ti->base.start; + root->startlen = root->start ? strlen(root->start) : 0; + root->entries[0] = git_pool_mallocz(&ti->pool, 1); + GITERR_CHECK_ALLOC(root->entries[0]); + root->entries[0]->tree = tree; + + ti->head = ti->root = root; + + return 0; +} + +int git_iterator_for_tree( + git_iterator **iter, + git_tree *tree, + git_iterator_flag_t flags, + const char *start, + const char *end) +{ + int error; + tree_iterator *ti; + + if (tree == NULL) + return git_iterator_for_nothing(iter, flags, start, end); + + if ((error = git_object_dup((git_object **)&tree, (git_object *)tree)) < 0) + return error; + + ti = git__calloc(1, sizeof(tree_iterator)); + GITERR_CHECK_ALLOC(ti); + + ITERATOR_BASE_INIT(ti, tree, TREE, git_tree_owner(tree)); + + if ((error = iterator__update_ignore_case((git_iterator *)ti, flags)) < 0) + goto fail; + ti->strncomp = iterator__ignore_case(ti) ? git__strncasecmp : git__strncmp; + + if ((error = git_pool_init(&ti->pool, sizeof(tree_iterator_entry),0)) < 0 || + (error = tree_iterator__create_root_frame(ti, tree)) < 0 || + (error = tree_iterator__push_frame(ti)) < 0) /* expand root now */ + goto fail; + + *iter = (git_iterator *)ti; + return 0; + +fail: + git_iterator_free((git_iterator *)ti); + return error; +} + + +typedef struct { + git_iterator base; + git_iterator_callbacks cb; + git_index *index; + git_vector entries; + git_vector_cmp entry_srch; + size_t current; + /* when not in autoexpand mode, use these to represent "tree" state */ + git_buf partial; + size_t partial_pos; + char restore_terminator; + git_index_entry tree_entry; +} index_iterator; + +static const git_index_entry *index_iterator__index_entry(index_iterator *ii) +{ + const git_index_entry *ie = git_vector_get(&ii->entries, ii->current); + + if (ie != NULL && iterator__past_end(ii, ie->path)) { + ii->current = git_vector_length(&ii->entries); + ie = NULL; + } + + return ie; +} + +static const git_index_entry *index_iterator__skip_conflicts(index_iterator *ii) +{ + const git_index_entry *ie; + + while ((ie = index_iterator__index_entry(ii)) != NULL && + git_index_entry_stage(ie) != 0) + ii->current++; + + return ie; +} + +static void index_iterator__next_prefix_tree(index_iterator *ii) +{ + const char *slash; + + if (!iterator__include_trees(ii)) + return; + + slash = strchr(&ii->partial.ptr[ii->partial_pos], '/'); + + if (slash != NULL) { + ii->partial_pos = (slash - ii->partial.ptr) + 1; + ii->restore_terminator = ii->partial.ptr[ii->partial_pos]; + ii->partial.ptr[ii->partial_pos] = '\0'; + } else { + ii->partial_pos = ii->partial.size; + } + + if (index_iterator__index_entry(ii) == NULL) + ii->partial_pos = ii->partial.size; +} + +static int index_iterator__first_prefix_tree(index_iterator *ii) +{ + const git_index_entry *ie = index_iterator__skip_conflicts(ii); + const char *scan, *prior, *slash; + + if (!ie || !iterator__include_trees(ii)) + return 0; + + /* find longest common prefix with prior index entry */ + for (scan = slash = ie->path, prior = ii->partial.ptr; + *scan && *scan == *prior; ++scan, ++prior) + if (*scan == '/') + slash = scan; + + if (git_buf_sets(&ii->partial, ie->path) < 0) + return -1; + + ii->partial_pos = (slash - ie->path) + 1; + index_iterator__next_prefix_tree(ii); + + return 0; +} + +#define index_iterator__at_tree(I) \ + (iterator__include_trees(I) && (I)->partial_pos < (I)->partial.size) + +static int index_iterator__current( + const git_index_entry **entry, git_iterator *self) +{ + index_iterator *ii = (index_iterator *)self; + const git_index_entry *ie = git_vector_get(&ii->entries, ii->current); + + if (ie != NULL && index_iterator__at_tree(ii)) { + ii->tree_entry.path = ii->partial.ptr; + ie = &ii->tree_entry; + } + + if (entry) + *entry = ie; + + ii->base.flags |= GIT_ITERATOR_FIRST_ACCESS; + + return (ie != NULL) ? 0 : GIT_ITEROVER; +} + +static int index_iterator__at_end(git_iterator *self) +{ + index_iterator *ii = (index_iterator *)self; + return (ii->current >= git_vector_length(&ii->entries)); +} + +static int index_iterator__advance( + const git_index_entry **entry, git_iterator *self) +{ + index_iterator *ii = (index_iterator *)self; + size_t entrycount = git_vector_length(&ii->entries); + const git_index_entry *ie; + + if (!iterator__has_been_accessed(ii)) + return index_iterator__current(entry, self); + + if (index_iterator__at_tree(ii)) { + if (iterator__do_autoexpand(ii)) { + ii->partial.ptr[ii->partial_pos] = ii->restore_terminator; + index_iterator__next_prefix_tree(ii); + } else { + /* advance to sibling tree (i.e. find entry with new prefix) */ + while (ii->current < entrycount) { + ii->current++; + + if (!(ie = git_vector_get(&ii->entries, ii->current)) || + ii->base.prefixcomp(ie->path, ii->partial.ptr) != 0) + break; + } + + if (index_iterator__first_prefix_tree(ii) < 0) + return -1; + } + } else { + if (ii->current < entrycount) + ii->current++; + + if (index_iterator__first_prefix_tree(ii) < 0) + return -1; + } + + return index_iterator__current(entry, self); +} + +static int index_iterator__advance_into( + const git_index_entry **entry, git_iterator *self) +{ + index_iterator *ii = (index_iterator *)self; + const git_index_entry *ie = git_vector_get(&ii->entries, ii->current); + + if (ie != NULL && index_iterator__at_tree(ii)) { + if (ii->restore_terminator) + ii->partial.ptr[ii->partial_pos] = ii->restore_terminator; + index_iterator__next_prefix_tree(ii); + } + + return index_iterator__current(entry, self); +} + +static int index_iterator__seek(git_iterator *self, const char *prefix) +{ + GIT_UNUSED(self); GIT_UNUSED(prefix); + return -1; +} + +static int index_iterator__reset( + git_iterator *self, const char *start, const char *end) +{ + index_iterator *ii = (index_iterator *)self; + const git_index_entry *ie; + + if (iterator__reset_range(self, start, end) < 0) + return -1; + + ii->current = 0; + + if (ii->base.start) + git_index_snapshot_find( + &ii->current, &ii->entries, ii->entry_srch, ii->base.start, 0, 0); + + if ((ie = index_iterator__skip_conflicts(ii)) == NULL) + return 0; + + if (git_buf_sets(&ii->partial, ie->path) < 0) + return -1; + + ii->partial_pos = 0; + + if (ii->base.start) { + size_t startlen = strlen(ii->base.start); + + ii->partial_pos = (startlen > ii->partial.size) ? + ii->partial.size : startlen; + } + + index_iterator__next_prefix_tree(ii); + + return 0; +} + +static void index_iterator__free(git_iterator *self) +{ + index_iterator *ii = (index_iterator *)self; + git_index_snapshot_release(&ii->entries, ii->index); + ii->index = NULL; + git_buf_free(&ii->partial); +} + +int git_iterator_for_index( + git_iterator **iter, + git_index *index, + git_iterator_flag_t flags, + const char *start, + const char *end) +{ + int error = 0; + index_iterator *ii = git__calloc(1, sizeof(index_iterator)); + GITERR_CHECK_ALLOC(ii); + + if ((error = git_index_snapshot_new(&ii->entries, index)) < 0) { + git__free(ii); + return error; + } + ii->index = index; + + ITERATOR_BASE_INIT(ii, index, INDEX, git_index_owner(index)); + + if ((error = iterator__update_ignore_case((git_iterator *)ii, flags)) < 0) { + git_iterator_free((git_iterator *)ii); + return error; + } + + ii->entry_srch = iterator__ignore_case(ii) ? + git_index_entry_isrch : git_index_entry_srch; + + git_vector_set_cmp(&ii->entries, iterator__ignore_case(ii) ? + git_index_entry_icmp : git_index_entry_cmp); + git_vector_sort(&ii->entries); + + git_buf_init(&ii->partial, 0); + ii->tree_entry.mode = GIT_FILEMODE_TREE; + + index_iterator__reset((git_iterator *)ii, NULL, NULL); + + *iter = (git_iterator *)ii; + return 0; +} + + +typedef struct fs_iterator_frame fs_iterator_frame; +struct fs_iterator_frame { + fs_iterator_frame *next; + git_vector entries; + size_t index; + int is_ignored; +}; + +typedef struct fs_iterator fs_iterator; +struct fs_iterator { + git_iterator base; + git_iterator_callbacks cb; + fs_iterator_frame *stack; + git_index_entry entry; + git_buf path; + size_t root_len; + uint32_t dirload_flags; + int depth; + + int (*enter_dir_cb)(fs_iterator *self); + int (*leave_dir_cb)(fs_iterator *self); + int (*update_entry_cb)(fs_iterator *self); +}; + +#define FS_MAX_DEPTH 100 + +static fs_iterator_frame *fs_iterator__alloc_frame(fs_iterator *fi) +{ + fs_iterator_frame *ff = git__calloc(1, sizeof(fs_iterator_frame)); + git_vector_cmp entry_compare = CASESELECT( + iterator__ignore_case(fi), + git_path_with_stat_cmp_icase, git_path_with_stat_cmp); + + if (ff && git_vector_init(&ff->entries, 0, entry_compare) < 0) { + git__free(ff); + ff = NULL; + } + + return ff; +} + +static void fs_iterator__free_frame(fs_iterator_frame *ff) +{ + git_vector_free_deep(&ff->entries); + git__free(ff); +} + +static void fs_iterator__pop_frame( + fs_iterator *fi, fs_iterator_frame *ff, bool pop_last) +{ + if (fi && fi->stack == ff) { + if (!ff->next && !pop_last) { + memset(&fi->entry, 0, sizeof(fi->entry)); + return; + } + + if (fi->leave_dir_cb) + (void)fi->leave_dir_cb(fi); + + fi->stack = ff->next; + fi->depth--; + } + + fs_iterator__free_frame(ff); +} + +static int fs_iterator__update_entry(fs_iterator *fi); +static int fs_iterator__advance_over( + const git_index_entry **entry, git_iterator *self); + +static int fs_iterator__entry_cmp(const void *i, const void *item) +{ + const fs_iterator *fi = (const fs_iterator *)i; + const git_path_with_stat *ps = item; + return fi->base.prefixcomp(fi->base.start, ps->path); +} + +static void fs_iterator__seek_frame_start( + fs_iterator *fi, fs_iterator_frame *ff) +{ + if (!ff) + return; + + if (fi->base.start) + git_vector_bsearch2( + &ff->index, &ff->entries, fs_iterator__entry_cmp, fi); + else + ff->index = 0; +} + +static int fs_iterator__expand_dir(fs_iterator *fi) +{ + int error; + fs_iterator_frame *ff; + + if (fi->depth > FS_MAX_DEPTH) { + giterr_set(GITERR_REPOSITORY, + "Directory nesting is too deep (%d)", fi->depth); + return -1; + } + + ff = fs_iterator__alloc_frame(fi); + GITERR_CHECK_ALLOC(ff); + + error = git_path_dirload_with_stat( + fi->path.ptr, fi->root_len, fi->dirload_flags, + fi->base.start, fi->base.end, &ff->entries); + + if (error < 0) { + git_error_state last_error = { 0 }; + giterr_capture(&last_error, error); + + /* these callbacks may clear the error message */ + fs_iterator__free_frame(ff); + fs_iterator__advance_over(NULL, (git_iterator *)fi); + /* next time return value we skipped to */ + fi->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS; + + return giterr_restore(&last_error); + } + + if (ff->entries.length == 0) { + fs_iterator__free_frame(ff); + return GIT_ENOTFOUND; + } + fi->base.stat_calls += ff->entries.length; + + fs_iterator__seek_frame_start(fi, ff); + + ff->next = fi->stack; + fi->stack = ff; + fi->depth++; + + if (fi->enter_dir_cb && (error = fi->enter_dir_cb(fi)) < 0) + return error; + + return fs_iterator__update_entry(fi); +} + +static int fs_iterator__current( + const git_index_entry **entry, git_iterator *self) +{ + fs_iterator *fi = (fs_iterator *)self; + const git_index_entry *fe = (fi->entry.path == NULL) ? NULL : &fi->entry; + + if (entry) + *entry = fe; + + fi->base.flags |= GIT_ITERATOR_FIRST_ACCESS; + + return (fe != NULL) ? 0 : GIT_ITEROVER; +} + +static int fs_iterator__at_end(git_iterator *self) +{ + return (((fs_iterator *)self)->entry.path == NULL); +} + +static int fs_iterator__advance_into( + const git_index_entry **entry, git_iterator *iter) +{ + int error = 0; + fs_iterator *fi = (fs_iterator *)iter; + + iterator__clear_entry(entry); + + /* Allow you to explicitly advance into a commit/submodule (as well as a + * tree) to avoid cases where an entry is mislabeled as a submodule in + * the working directory. The fs iterator will never have COMMMIT + * entries on it's own, but a wrapper might add them. + */ + if (fi->entry.path != NULL && + (fi->entry.mode == GIT_FILEMODE_TREE || + fi->entry.mode == GIT_FILEMODE_COMMIT)) + /* returns GIT_ENOTFOUND if the directory is empty */ + error = fs_iterator__expand_dir(fi); + + if (!error && entry) + error = fs_iterator__current(entry, iter); + + if (!error && !fi->entry.path) + error = GIT_ITEROVER; + + return error; +} + +static int fs_iterator__advance_over( + const git_index_entry **entry, git_iterator *self) +{ + int error = 0; + fs_iterator *fi = (fs_iterator *)self; + fs_iterator_frame *ff; + git_path_with_stat *next; + + if (entry != NULL) + *entry = NULL; + + while (fi->entry.path != NULL) { + ff = fi->stack; + next = git_vector_get(&ff->entries, ++ff->index); + + if (next != NULL) + break; + + fs_iterator__pop_frame(fi, ff, false); + } + + error = fs_iterator__update_entry(fi); + + if (!error && entry != NULL) + error = fs_iterator__current(entry, self); + + return error; +} + +static int fs_iterator__advance( + const git_index_entry **entry, git_iterator *self) +{ + fs_iterator *fi = (fs_iterator *)self; + + if (!iterator__has_been_accessed(fi)) + return fs_iterator__current(entry, self); + + /* given include_trees & autoexpand, we might have to go into a tree */ + if (iterator__do_autoexpand(fi) && + fi->entry.path != NULL && + fi->entry.mode == GIT_FILEMODE_TREE) + { + int error = fs_iterator__advance_into(entry, self); + if (error != GIT_ENOTFOUND) + return error; + /* continue silently past empty directories if autoexpanding */ + giterr_clear(); + } + + return fs_iterator__advance_over(entry, self); +} + +static int fs_iterator__seek(git_iterator *self, const char *prefix) +{ + GIT_UNUSED(self); + GIT_UNUSED(prefix); + /* pop stack until matching prefix */ + /* find prefix item in current frame */ + /* push subdirectories as deep as possible while matching */ + return 0; +} + +static int fs_iterator__reset( + git_iterator *self, const char *start, const char *end) +{ + int error; + fs_iterator *fi = (fs_iterator *)self; + + while (fi->stack != NULL && fi->stack->next != NULL) + fs_iterator__pop_frame(fi, fi->stack, false); + fi->depth = 0; + + if ((error = iterator__reset_range(self, start, end)) < 0) + return error; + + fs_iterator__seek_frame_start(fi, fi->stack); + + error = fs_iterator__update_entry(fi); + if (error == GIT_ITEROVER) + error = 0; + + return error; +} + +static void fs_iterator__free(git_iterator *self) +{ + fs_iterator *fi = (fs_iterator *)self; + + while (fi->stack != NULL) + fs_iterator__pop_frame(fi, fi->stack, true); + + git_buf_free(&fi->path); +} + +static int fs_iterator__update_entry(fs_iterator *fi) +{ + git_path_with_stat *ps; + + memset(&fi->entry, 0, sizeof(fi->entry)); + + if (!fi->stack) + return GIT_ITEROVER; + + ps = git_vector_get(&fi->stack->entries, fi->stack->index); + if (!ps) + return GIT_ITEROVER; + + git_buf_truncate(&fi->path, fi->root_len); + if (git_buf_put(&fi->path, ps->path, ps->path_len) < 0) + return -1; + + if (iterator__past_end(fi, fi->path.ptr + fi->root_len)) + return GIT_ITEROVER; + + fi->entry.path = ps->path; + git_index_entry__init_from_stat(&fi->entry, &ps->st, true); + + /* need different mode here to keep directories during iteration */ + fi->entry.mode = git_futils_canonical_mode(ps->st.st_mode); + + /* allow wrapper to check/update the entry (can force skip) */ + if (fi->update_entry_cb && + fi->update_entry_cb(fi) == GIT_ENOTFOUND) + return fs_iterator__advance_over(NULL, (git_iterator *)fi); + + /* if this is a tree and trees aren't included, then skip */ + if (fi->entry.mode == GIT_FILEMODE_TREE && !iterator__include_trees(fi)) { + int error = fs_iterator__advance_into(NULL, (git_iterator *)fi); + if (error != GIT_ENOTFOUND) + return error; + giterr_clear(); + return fs_iterator__advance_over(NULL, (git_iterator *)fi); + } + + return 0; +} + +static int fs_iterator__initialize( + git_iterator **out, fs_iterator *fi, const char *root) +{ + int error; + + if (git_buf_sets(&fi->path, root) < 0 || git_path_to_dir(&fi->path) < 0) { + git__free(fi); + return -1; + } + fi->root_len = fi->path.size; + + fi->dirload_flags = + (iterator__ignore_case(fi) ? GIT_PATH_DIR_IGNORE_CASE : 0) | + (iterator__flag(fi, PRECOMPOSE_UNICODE) ? + GIT_PATH_DIR_PRECOMPOSE_UNICODE : 0); + + if ((error = fs_iterator__expand_dir(fi)) < 0) { + if (error == GIT_ENOTFOUND || error == GIT_ITEROVER) { + giterr_clear(); + error = 0; + } else { + git_iterator_free((git_iterator *)fi); + fi = NULL; + } + } + + *out = (git_iterator *)fi; + return error; +} + +int git_iterator_for_filesystem( + git_iterator **out, + const char *root, + git_iterator_flag_t flags, + const char *start, + const char *end) +{ + fs_iterator *fi = git__calloc(1, sizeof(fs_iterator)); + GITERR_CHECK_ALLOC(fi); + + ITERATOR_BASE_INIT(fi, fs, FS, NULL); + + if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0) + fi->base.flags |= GIT_ITERATOR_IGNORE_CASE; + + return fs_iterator__initialize(out, fi, root); +} + + +typedef struct { + fs_iterator fi; + git_ignores ignores; + int is_ignored; + + /* + * We may have a tree or the index+snapshot to compare against + * when checking for submodules. + */ + git_tree *tree; + git_index *index; + git_vector index_snapshot; + git_vector_cmp entry_srch; + +} workdir_iterator; + +GIT_INLINE(bool) workdir_path_is_dotgit(const git_buf *path) +{ + size_t len; + + if (!path || (len = path->size) < 4) + return false; + + if (path->ptr[len - 1] == '/') + len--; + + if (tolower(path->ptr[len - 1]) != 't' || + tolower(path->ptr[len - 2]) != 'i' || + tolower(path->ptr[len - 3]) != 'g' || + tolower(path->ptr[len - 4]) != '.') + return false; + + return (len == 4 || path->ptr[len - 5] == '/'); +} + +/** + * Figure out if an entry is a submodule. + * + * We consider it a submodule if the path is listed as a submodule in + * either the tree or the index. + */ +static int is_submodule(workdir_iterator *wi, git_path_with_stat *ie) +{ + int error, is_submodule = 0; + + if (wi->tree) { + git_tree_entry *e; + + /* remove the trailing slash for finding */ + ie->path[ie->path_len-1] = '\0'; + error = git_tree_entry_bypath(&e, wi->tree, ie->path); + ie->path[ie->path_len-1] = '/'; + if (error < 0 && error != GIT_ENOTFOUND) + return 0; + if (!error) { + is_submodule = e->attr == GIT_FILEMODE_COMMIT; + git_tree_entry_free(e); + } + } + + if (!is_submodule && wi->index) { + git_index_entry *e; + size_t pos; + + error = git_index_snapshot_find(&pos, &wi->index_snapshot, wi->entry_srch, ie->path, ie->path_len-1, 0); + if (error < 0 && error != GIT_ENOTFOUND) + return 0; + + if (!error) { + e = git_vector_get(&wi->index_snapshot, pos); + + is_submodule = e->mode == GIT_FILEMODE_COMMIT; + } + } + + return is_submodule; +} + +static int workdir_iterator__enter_dir(fs_iterator *fi) +{ + workdir_iterator *wi = (workdir_iterator *)fi; + fs_iterator_frame *ff = fi->stack; + size_t pos; + git_path_with_stat *entry; + bool found_submodules = false; + + /* check if this directory is ignored */ + if (git_ignore__lookup( + &ff->is_ignored, &wi->ignores, fi->path.ptr + fi->root_len) < 0) { + giterr_clear(); + ff->is_ignored = GIT_IGNORE_NOTFOUND; + } + + /* if this is not the top level directory... */ + if (ff->next != NULL) { + ssize_t slash_pos = git_buf_rfind_next(&fi->path, '/'); + + /* inherit ignored from parent if no rule specified */ + if (ff->is_ignored <= GIT_IGNORE_NOTFOUND) + ff->is_ignored = ff->next->is_ignored; + + /* push new ignores for files in this directory */ + (void)git_ignore__push_dir(&wi->ignores, &fi->path.ptr[slash_pos + 1]); + } + + /* convert submodules to GITLINK and remove trailing slashes */ + git_vector_foreach(&ff->entries, pos, entry) { + if (!S_ISDIR(entry->st.st_mode) || !strcmp(GIT_DIR, entry->path)) + continue; + + if (is_submodule(wi, entry)) { + entry->st.st_mode = GIT_FILEMODE_COMMIT; + entry->path_len--; + entry->path[entry->path_len] = '\0'; + found_submodules = true; + } + } + + /* if we renamed submodules, re-sort and re-seek to start */ + if (found_submodules) { + git_vector_set_sorted(&ff->entries, 0); + git_vector_sort(&ff->entries); + fs_iterator__seek_frame_start(fi, ff); + } + + return 0; +} + +static int workdir_iterator__leave_dir(fs_iterator *fi) +{ + workdir_iterator *wi = (workdir_iterator *)fi; + git_ignore__pop_dir(&wi->ignores); + return 0; +} + +static int workdir_iterator__update_entry(fs_iterator *fi) +{ + workdir_iterator *wi = (workdir_iterator *)fi; + + /* skip over .git entries */ + if (workdir_path_is_dotgit(&fi->path)) + return GIT_ENOTFOUND; + + /* reset is_ignored since we haven't checked yet */ + wi->is_ignored = GIT_IGNORE_UNCHECKED; + + return 0; +} + +static void workdir_iterator__free(git_iterator *self) +{ + workdir_iterator *wi = (workdir_iterator *)self; + if (wi->index) + git_index_snapshot_release(&wi->index_snapshot, wi->index); + git_tree_free(wi->tree); + fs_iterator__free(self); + git_ignore__free(&wi->ignores); +} + +int git_iterator_for_workdir_ext( + git_iterator **out, + git_repository *repo, + const char *repo_workdir, + git_index *index, + git_tree *tree, + git_iterator_flag_t flags, + const char *start, + const char *end) +{ + int error, precompose = 0; + workdir_iterator *wi; + + if (!repo_workdir) { + if (git_repository__ensure_not_bare(repo, "scan working directory") < 0) + return GIT_EBAREREPO; + repo_workdir = git_repository_workdir(repo); + } + + /* initialize as an fs iterator then do overrides */ + wi = git__calloc(1, sizeof(workdir_iterator)); + GITERR_CHECK_ALLOC(wi); + ITERATOR_BASE_INIT((&wi->fi), fs, FS, repo); + + wi->fi.base.type = GIT_ITERATOR_TYPE_WORKDIR; + wi->fi.cb.free = workdir_iterator__free; + wi->fi.enter_dir_cb = workdir_iterator__enter_dir; + wi->fi.leave_dir_cb = workdir_iterator__leave_dir; + wi->fi.update_entry_cb = workdir_iterator__update_entry; + + if ((error = iterator__update_ignore_case((git_iterator *)wi, flags)) < 0 || + (error = git_ignore__for_path(repo, ".gitignore", &wi->ignores)) < 0) + { + git_iterator_free((git_iterator *)wi); + return error; + } + + if (tree && (error = git_object_dup((git_object **)&wi->tree, (git_object *)tree)) < 0) + return error; + + wi->index = index; + if (index && (error = git_index_snapshot_new(&wi->index_snapshot, index)) < 0) { + git_iterator_free((git_iterator *)wi); + return error; + } + wi->entry_srch = iterator__ignore_case(wi) ? + git_index_entry_isrch : git_index_entry_srch; + + + /* try to look up precompose and set flag if appropriate */ + if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0) + giterr_clear(); + else if (precompose) + wi->fi.base.flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; + + return fs_iterator__initialize(out, &wi->fi, repo_workdir); +} + + +void git_iterator_free(git_iterator *iter) +{ + if (iter == NULL) + return; + + iter->cb->free(iter); + + git__free(iter->start); + git__free(iter->end); + + memset(iter, 0, sizeof(*iter)); + + git__free(iter); +} + +int git_iterator_set_ignore_case(git_iterator *iter, bool ignore_case) +{ + bool desire_ignore_case = (ignore_case != 0); + + if (iterator__ignore_case(iter) == desire_ignore_case) + return 0; + + if (iter->type == GIT_ITERATOR_TYPE_EMPTY) { + if (desire_ignore_case) + iter->flags |= GIT_ITERATOR_IGNORE_CASE; + else + iter->flags &= ~GIT_ITERATOR_IGNORE_CASE; + } else { + giterr_set(GITERR_INVALID, + "Cannot currently set ignore case on non-empty iterators"); + return -1; + } + + return 0; +} + +git_index *git_iterator_get_index(git_iterator *iter) +{ + if (iter->type == GIT_ITERATOR_TYPE_INDEX) + return ((index_iterator *)iter)->index; + return NULL; +} + +int git_iterator_current_tree_entry( + const git_tree_entry **tree_entry, git_iterator *iter) +{ + if (iter->type != GIT_ITERATOR_TYPE_TREE) + *tree_entry = NULL; + else { + tree_iterator_frame *tf = ((tree_iterator *)iter)->head; + *tree_entry = (tf->current < tf->n_entries) ? + tf->entries[tf->current]->te : NULL; + } + + return 0; +} + +int git_iterator_current_parent_tree( + const git_tree **tree_ptr, + git_iterator *iter, + const char *parent_path) +{ + tree_iterator *ti = (tree_iterator *)iter; + tree_iterator_frame *tf; + const char *scan = parent_path; + const git_tree_entry *te; + + *tree_ptr = NULL; + + if (iter->type != GIT_ITERATOR_TYPE_TREE) + return 0; + + for (tf = ti->root; *scan; ) { + if (!(tf = tf->down) || + tf->current >= tf->n_entries || + !(te = tf->entries[tf->current]->te) || + ti->strncomp(scan, te->filename, te->filename_len) != 0) + return 0; + + scan += te->filename_len; + if (*scan == '/') + scan++; + } + + *tree_ptr = tf->entries[tf->current]->tree; + return 0; +} + +static void workdir_iterator_update_is_ignored(workdir_iterator *wi) +{ + if (git_ignore__lookup( + &wi->is_ignored, &wi->ignores, wi->fi.entry.path) < 0) { + giterr_clear(); + wi->is_ignored = GIT_IGNORE_NOTFOUND; + } + + /* use ignore from containing frame stack */ + if (wi->is_ignored <= GIT_IGNORE_NOTFOUND) + wi->is_ignored = wi->fi.stack->is_ignored; +} + +bool git_iterator_current_is_ignored(git_iterator *iter) +{ + workdir_iterator *wi = (workdir_iterator *)iter; + + if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) + return false; + + if (wi->is_ignored != GIT_IGNORE_UNCHECKED) + return (bool)(wi->is_ignored == GIT_IGNORE_TRUE); + + workdir_iterator_update_is_ignored(wi); + + return (bool)(wi->is_ignored == GIT_IGNORE_TRUE); +} + +bool git_iterator_current_tree_is_ignored(git_iterator *iter) +{ + workdir_iterator *wi = (workdir_iterator *)iter; + + if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) + return false; + + return (bool)(wi->fi.stack->is_ignored == GIT_IGNORE_TRUE); +} + +int git_iterator_cmp(git_iterator *iter, const char *path_prefix) +{ + const git_index_entry *entry; + + /* a "done" iterator is after every prefix */ + if (git_iterator_current(&entry, iter) < 0 || entry == NULL) + return 1; + + /* a NULL prefix is after any valid iterator */ + if (!path_prefix) + return -1; + + return iter->prefixcomp(entry->path, path_prefix); +} + +int git_iterator_current_workdir_path(git_buf **path, git_iterator *iter) +{ + workdir_iterator *wi = (workdir_iterator *)iter; + + if (iter->type != GIT_ITERATOR_TYPE_WORKDIR || !wi->fi.entry.path) + *path = NULL; + else + *path = &wi->fi.path; + + return 0; +} + +int git_iterator_advance_over_with_status( + const git_index_entry **entryptr, + git_iterator_status_t *status, + git_iterator *iter) +{ + int error = 0; + workdir_iterator *wi = (workdir_iterator *)iter; + char *base = NULL; + const git_index_entry *entry; + + *status = GIT_ITERATOR_STATUS_NORMAL; + + if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) + return git_iterator_advance(entryptr, iter); + if ((error = git_iterator_current(&entry, iter)) < 0) + return error; + + if (!S_ISDIR(entry->mode)) { + workdir_iterator_update_is_ignored(wi); + if (wi->is_ignored == GIT_IGNORE_TRUE) + *status = GIT_ITERATOR_STATUS_IGNORED; + return git_iterator_advance(entryptr, iter); + } + + *status = GIT_ITERATOR_STATUS_EMPTY; + + base = git__strdup(entry->path); + GITERR_CHECK_ALLOC(base); + + /* scan inside directory looking for a non-ignored item */ + while (entry && !iter->prefixcomp(entry->path, base)) { + workdir_iterator_update_is_ignored(wi); + + /* if we found an explicitly ignored item, then update from + * EMPTY to IGNORED + */ + if (wi->is_ignored == GIT_IGNORE_TRUE) + *status = GIT_ITERATOR_STATUS_IGNORED; + else if (S_ISDIR(entry->mode)) { + error = git_iterator_advance_into(&entry, iter); + + if (!error) + continue; + else if (error == GIT_ENOTFOUND) { + error = 0; + wi->is_ignored = GIT_IGNORE_TRUE; /* mark empty dirs ignored */ + } else + break; /* real error, stop here */ + } else { + /* we found a non-ignored item, treat parent as untracked */ + *status = GIT_ITERATOR_STATUS_NORMAL; + break; + } + + if ((error = git_iterator_advance(&entry, iter)) < 0) + break; + } + + /* wrap up scan back to base directory */ + while (entry && !iter->prefixcomp(entry->path, base)) + if ((error = git_iterator_advance(&entry, iter)) < 0) + break; + + *entryptr = entry; + git__free(base); + + return error; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/iterator.h b/deps/libgit2-sys-0.2.17/libgit2/src/iterator.h new file mode 100644 index 000000000..1520bffc2 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/iterator.h @@ -0,0 +1,287 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_iterator_h__ +#define INCLUDE_iterator_h__ + +#include "common.h" +#include "git2/index.h" +#include "vector.h" +#include "buffer.h" + +typedef struct git_iterator git_iterator; + +typedef enum { + GIT_ITERATOR_TYPE_EMPTY = 0, + GIT_ITERATOR_TYPE_TREE = 1, + GIT_ITERATOR_TYPE_INDEX = 2, + GIT_ITERATOR_TYPE_WORKDIR = 3, + GIT_ITERATOR_TYPE_FS = 4, +} git_iterator_type_t; + +typedef enum { + /** ignore case for entry sort order */ + GIT_ITERATOR_IGNORE_CASE = (1u << 0), + /** force case sensitivity for entry sort order */ + GIT_ITERATOR_DONT_IGNORE_CASE = (1u << 1), + /** return tree items in addition to blob items */ + GIT_ITERATOR_INCLUDE_TREES = (1u << 2), + /** don't flatten trees, requiring advance_into (implies INCLUDE_TREES) */ + GIT_ITERATOR_DONT_AUTOEXPAND = (1u << 3), + /** convert precomposed unicode to decomposed unicode */ + GIT_ITERATOR_PRECOMPOSE_UNICODE = (1u << 4), +} git_iterator_flag_t; + +typedef struct { + int (*current)(const git_index_entry **, git_iterator *); + int (*advance)(const git_index_entry **, git_iterator *); + int (*advance_into)(const git_index_entry **, git_iterator *); + int (*seek)(git_iterator *, const char *prefix); + int (*reset)(git_iterator *, const char *start, const char *end); + int (*at_end)(git_iterator *); + void (*free)(git_iterator *); +} git_iterator_callbacks; + +struct git_iterator { + git_iterator_type_t type; + git_iterator_callbacks *cb; + git_repository *repo; + char *start; + char *end; + int (*prefixcomp)(const char *str, const char *prefix); + size_t stat_calls; + unsigned int flags; +}; + +extern int git_iterator_for_nothing( + git_iterator **out, + git_iterator_flag_t flags, + const char *start, + const char *end); + +/* tree iterators will match the ignore_case value from the index of the + * repository, unless you override with a non-zero flag value + */ +extern int git_iterator_for_tree( + git_iterator **out, + git_tree *tree, + git_iterator_flag_t flags, + const char *start, + const char *end); + +/* index iterators will take the ignore_case value from the index; the + * ignore_case flags are not used + */ +extern int git_iterator_for_index( + git_iterator **out, + git_index *index, + git_iterator_flag_t flags, + const char *start, + const char *end); + +extern int git_iterator_for_workdir_ext( + git_iterator **out, + git_repository *repo, + const char *repo_workdir, + git_index *index, + git_tree *tree, + git_iterator_flag_t flags, + const char *start, + const char *end); + +/* workdir iterators will match the ignore_case value from the index of the + * repository, unless you override with a non-zero flag value + */ +GIT_INLINE(int) git_iterator_for_workdir( + git_iterator **out, + git_repository *repo, + git_index *index, + git_tree *tree, + git_iterator_flag_t flags, + const char *start, + const char *end) +{ + return git_iterator_for_workdir_ext(out, repo, NULL, index, tree, flags, start, end); +} + +/* for filesystem iterators, you have to explicitly pass in the ignore_case + * behavior that you desire + */ +extern int git_iterator_for_filesystem( + git_iterator **out, + const char *root, + git_iterator_flag_t flags, + const char *start, + const char *end); + +extern void git_iterator_free(git_iterator *iter); + +/* Return a git_index_entry structure for the current value the iterator + * is looking at or NULL if the iterator is at the end. + * + * The entry may noy be fully populated. Tree iterators will only have a + * value mode, OID, and path. Workdir iterators will not have an OID (but + * you can use `git_iterator_current_oid()` to calculate it on demand). + * + * You do not need to free the entry. It is still "owned" by the iterator. + * Once you call `git_iterator_advance()` then the old entry is no longer + * guaranteed to be valid - it may be freed or just overwritten in place. + */ +GIT_INLINE(int) git_iterator_current( + const git_index_entry **entry, git_iterator *iter) +{ + return iter->cb->current(entry, iter); +} + +/** + * Advance to the next item for the iterator. + * + * If GIT_ITERATOR_INCLUDE_TREES is set, this may be a tree item. If + * GIT_ITERATOR_DONT_AUTOEXPAND is set, calling this again when on a tree + * item will skip over all the items under that tree. + */ +GIT_INLINE(int) git_iterator_advance( + const git_index_entry **entry, git_iterator *iter) +{ + return iter->cb->advance(entry, iter); +} + +/** + * Iterate into a tree item (when GIT_ITERATOR_DONT_AUTOEXPAND is set). + * + * git_iterator_advance() steps through all items being iterated over + * (either with or without trees, depending on GIT_ITERATOR_INCLUDE_TREES), + * but if GIT_ITERATOR_DONT_AUTOEXPAND is set, it will skip to the next + * sibling of a tree instead of going to the first child of the tree. In + * that case, use this function to advance to the first child of the tree. + * + * If the current item is not a tree, this is a no-op. + * + * For filesystem and working directory iterators, a tree (i.e. directory) + * can be empty. In that case, this function returns GIT_ENOTFOUND and + * does not advance. That can't happen for tree and index iterators. + */ +GIT_INLINE(int) git_iterator_advance_into( + const git_index_entry **entry, git_iterator *iter) +{ + return iter->cb->advance_into(entry, iter); +} + +/** + * Advance into a tree or skip over it if it is empty. + * + * Because `git_iterator_advance_into` may return GIT_ENOTFOUND if the + * directory is empty (only with filesystem and working directory + * iterators) and a common response is to just call `git_iterator_advance` + * when that happens, this bundles the two into a single simple call. + */ +GIT_INLINE(int) git_iterator_advance_into_or_over( + const git_index_entry **entry, git_iterator *iter) +{ + int error = iter->cb->advance_into(entry, iter); + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = iter->cb->advance(entry, iter); + } + return error; +} + +/* Seek is currently unimplemented */ +GIT_INLINE(int) git_iterator_seek( + git_iterator *iter, const char *prefix) +{ + return iter->cb->seek(iter, prefix); +} + +/** + * Go back to the start of the iteration. + * + * This resets the iterator to the start of the iteration. It also allows + * you to reset the `start` and `end` pathname boundaries of the iteration + * when doing so. + */ +GIT_INLINE(int) git_iterator_reset( + git_iterator *iter, const char *start, const char *end) +{ + return iter->cb->reset(iter, start, end); +} + +/** + * Check if the iterator is at the end + * + * @return 0 if not at end, >0 if at end + */ +GIT_INLINE(int) git_iterator_at_end(git_iterator *iter) +{ + return iter->cb->at_end(iter); +} + +GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter) +{ + return iter->type; +} + +GIT_INLINE(git_repository *) git_iterator_owner(git_iterator *iter) +{ + return iter->repo; +} + +GIT_INLINE(git_iterator_flag_t) git_iterator_flags(git_iterator *iter) +{ + return iter->flags; +} + +GIT_INLINE(bool) git_iterator_ignore_case(git_iterator *iter) +{ + return ((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0); +} + +extern int git_iterator_set_ignore_case(git_iterator *iter, bool ignore_case); + +extern int git_iterator_current_tree_entry( + const git_tree_entry **entry_out, git_iterator *iter); + +extern int git_iterator_current_parent_tree( + const git_tree **tree_out, git_iterator *iter, const char *parent_path); + +extern bool git_iterator_current_is_ignored(git_iterator *iter); + +extern bool git_iterator_current_tree_is_ignored(git_iterator *iter); + +extern int git_iterator_cmp( + git_iterator *iter, const char *path_prefix); + +/** + * Get full path of the current item from a workdir iterator. This will + * return NULL for a non-workdir iterator. The git_buf is still owned by + * the iterator; this is exposed just for efficiency. + */ +extern int git_iterator_current_workdir_path( + git_buf **path, git_iterator *iter); + +/* Return index pointer if index iterator, else NULL */ +extern git_index *git_iterator_get_index(git_iterator *iter); + +typedef enum { + GIT_ITERATOR_STATUS_NORMAL = 0, + GIT_ITERATOR_STATUS_IGNORED = 1, + GIT_ITERATOR_STATUS_EMPTY = 2 +} git_iterator_status_t; + +/* Advance over a directory and check if it contains no files or just + * ignored files. + * + * In a tree or the index, all directories will contain files, but in the + * working directory it is possible to have an empty directory tree or a + * tree that only contains ignored files. Many Git operations treat these + * cases specially. This advances over a directory (presumably an + * untracked directory) but checks during the scan if there are any files + * and any non-ignored files. + */ +extern int git_iterator_advance_over_with_status( + const git_index_entry **entry, git_iterator_status_t *status, git_iterator *iter); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/khash.h b/deps/libgit2-sys-0.2.17/libgit2/src/khash.h new file mode 100644 index 000000000..818ac833b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/khash.h @@ -0,0 +1,622 @@ +/* The MIT License + + Copyright (c) 2008, 2009, 2011 by Attractive Chaos + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +/* + An example: + +#include "khash.h" +KHASH_MAP_INIT_INT(32, char) +int main() { + int ret, is_missing; + khiter_t k; + khash_t(32) *h = kh_init(32); + k = kh_put(32, h, 5, &ret); + kh_value(h, k) = 10; + k = kh_get(32, h, 10); + is_missing = (k == kh_end(h)); + k = kh_get(32, h, 5); + kh_del(32, h, k); + for (k = kh_begin(h); k != kh_end(h); ++k) + if (kh_exist(h, k)) kh_value(h, k) = 1; + kh_destroy(32, h); + return 0; +} +*/ + +/* + 2013-05-02 (0.2.8): + + * Use quadratic probing. When the capacity is power of 2, stepping function + i*(i+1)/2 guarantees to traverse each bucket. It is better than double + hashing on cache performance and is more robust than linear probing. + + In theory, double hashing should be more robust than quadratic probing. + However, my implementation is probably not for large hash tables, because + the second hash function is closely tied to the first hash function, + which reduce the effectiveness of double hashing. + + Reference: http://research.cs.vt.edu/AVresearch/hashing/quadratic.php + + 2011-12-29 (0.2.7): + + * Minor code clean up; no actual effect. + + 2011-09-16 (0.2.6): + + * The capacity is a power of 2. This seems to dramatically improve the + speed for simple keys. Thank Zilong Tan for the suggestion. Reference: + + - http://code.google.com/p/ulib/ + - http://nothings.org/computer/judy/ + + * Allow to optionally use linear probing which usually has better + performance for random input. Double hashing is still the default as it + is more robust to certain non-random input. + + * Added Wang's integer hash function (not used by default). This hash + function is more robust to certain non-random input. + + 2011-02-14 (0.2.5): + + * Allow to declare global functions. + + 2009-09-26 (0.2.4): + + * Improve portability + + 2008-09-19 (0.2.3): + + * Corrected the example + * Improved interfaces + + 2008-09-11 (0.2.2): + + * Improved speed a little in kh_put() + + 2008-09-10 (0.2.1): + + * Added kh_clear() + * Fixed a compiling error + + 2008-09-02 (0.2.0): + + * Changed to token concatenation which increases flexibility. + + 2008-08-31 (0.1.2): + + * Fixed a bug in kh_get(), which has not been tested previously. + + 2008-08-31 (0.1.1): + + * Added destructor +*/ + + +#ifndef __AC_KHASH_H +#define __AC_KHASH_H + +/*! + @header + + Generic hash table library. + */ + +#define AC_VERSION_KHASH_H "0.2.8" + +#include +#include +#include + +/* compiler specific configuration */ + +#if UINT_MAX == 0xffffffffu +typedef unsigned int khint32_t; +#elif ULONG_MAX == 0xffffffffu +typedef unsigned long khint32_t; +#endif + +#if ULONG_MAX == ULLONG_MAX +typedef unsigned long khint64_t; +#else +typedef unsigned long long khint64_t; +#endif + +#ifndef kh_inline +#ifdef _MSC_VER +#define kh_inline __inline +#else +#define kh_inline inline +#endif +#endif /* kh_inline */ + +typedef khint32_t khint_t; +typedef khint_t khiter_t; + +#define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2) +#define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1) +#define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3) +#define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1))) +#define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1))) +#define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1))) +#define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1)) + +#define __ac_fsize(m) ((m) < 16? 1 : (m)>>4) + +#ifndef kroundup32 +#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) +#endif + +#ifndef kcalloc +#define kcalloc(N,Z) calloc(N,Z) +#endif +#ifndef kmalloc +#define kmalloc(Z) malloc(Z) +#endif +#ifndef krealloc +#define krealloc(P,Z) realloc(P,Z) +#endif +#ifndef kreallocarray +#define kreallocarray(P,N,Z) ((SIZE_MAX - N < Z) ? NULL : krealloc(P, (N*Z))) +#endif +#ifndef kfree +#define kfree(P) free(P) +#endif + +static const double __ac_HASH_UPPER = 0.77; + +#define __KHASH_TYPE(name, khkey_t, khval_t) \ + typedef struct kh_##name##_s { \ + khint_t n_buckets, size, n_occupied, upper_bound; \ + khint32_t *flags; \ + khkey_t *keys; \ + khval_t *vals; \ + } kh_##name##_t; + +#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \ + extern kh_##name##_t *kh_init_##name(void); \ + extern void kh_destroy_##name(kh_##name##_t *h); \ + extern void kh_clear_##name(kh_##name##_t *h); \ + extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \ + extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \ + extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \ + extern void kh_del_##name(kh_##name##_t *h, khint_t x); + +#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ + SCOPE kh_##name##_t *kh_init_##name(void) { \ + return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \ + } \ + SCOPE void kh_destroy_##name(kh_##name##_t *h) \ + { \ + if (h) { \ + kfree((void *)h->keys); kfree(h->flags); \ + kfree((void *)h->vals); \ + kfree(h); \ + } \ + } \ + SCOPE void kh_clear_##name(kh_##name##_t *h) \ + { \ + if (h && h->flags) { \ + memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \ + h->size = h->n_occupied = 0; \ + } \ + } \ + SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \ + { \ + if (h->n_buckets) { \ + khint_t k, i, last, mask, step = 0; \ + mask = h->n_buckets - 1; \ + k = __hash_func(key); i = k & mask; \ + last = i; \ + while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \ + i = (i + (++step)) & mask; \ + if (i == last) return h->n_buckets; \ + } \ + return __ac_iseither(h->flags, i)? h->n_buckets : i; \ + } else return 0; \ + } \ + SCOPE int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \ + { /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \ + khint32_t *new_flags = 0; \ + khint_t j = 1; \ + { \ + kroundup32(new_n_buckets); \ + if (new_n_buckets < 4) new_n_buckets = 4; \ + if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \ + else { /* hash table size to be changed (shrink or expand); rehash */ \ + new_flags = (khint32_t*)kreallocarray(NULL, __ac_fsize(new_n_buckets), sizeof(khint32_t)); \ + if (!new_flags) return -1; \ + memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \ + if (h->n_buckets < new_n_buckets) { /* expand */ \ + khkey_t *new_keys = (khkey_t*)kreallocarray((void *)h->keys, new_n_buckets, sizeof(khkey_t)); \ + if (!new_keys) { kfree(new_flags); return -1; } \ + h->keys = new_keys; \ + if (kh_is_map) { \ + khval_t *new_vals = (khval_t*)kreallocarray((void *)h->vals, new_n_buckets, sizeof(khval_t)); \ + if (!new_vals) { kfree(new_flags); return -1; } \ + h->vals = new_vals; \ + } \ + } /* otherwise shrink */ \ + } \ + } \ + if (j) { /* rehashing is needed */ \ + for (j = 0; j != h->n_buckets; ++j) { \ + if (__ac_iseither(h->flags, j) == 0) { \ + khkey_t key = h->keys[j]; \ + khval_t val; \ + khint_t new_mask; \ + new_mask = new_n_buckets - 1; \ + if (kh_is_map) val = h->vals[j]; \ + __ac_set_isdel_true(h->flags, j); \ + while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \ + khint_t k, i, step = 0; \ + k = __hash_func(key); \ + i = k & new_mask; \ + while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \ + __ac_set_isempty_false(new_flags, i); \ + if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \ + { khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \ + if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \ + __ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \ + } else { /* write the element and jump out of the loop */ \ + h->keys[i] = key; \ + if (kh_is_map) h->vals[i] = val; \ + break; \ + } \ + } \ + } \ + } \ + if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \ + h->keys = (khkey_t*)kreallocarray((void *)h->keys, new_n_buckets, sizeof(khkey_t)); \ + if (kh_is_map) h->vals = (khval_t*)kreallocarray((void *)h->vals, new_n_buckets, sizeof(khval_t)); \ + } \ + kfree(h->flags); /* free the working space */ \ + h->flags = new_flags; \ + h->n_buckets = new_n_buckets; \ + h->n_occupied = h->size; \ + h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \ + } \ + return 0; \ + } \ + SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \ + { \ + khint_t x; \ + if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \ + if (h->n_buckets > (h->size<<1)) { \ + if (kh_resize_##name(h, h->n_buckets - 1) < 0) { /* clear "deleted" elements */ \ + *ret = -1; return h->n_buckets; \ + } \ + } else if (kh_resize_##name(h, h->n_buckets + 1) < 0) { /* expand the hash table */ \ + *ret = -1; return h->n_buckets; \ + } \ + } /* TODO: to implement automatically shrinking; resize() already support shrinking */ \ + { \ + khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \ + x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \ + if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \ + else { \ + last = i; \ + while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \ + if (__ac_isdel(h->flags, i)) site = i; \ + i = (i + (++step)) & mask; \ + if (i == last) { x = site; break; } \ + } \ + if (x == h->n_buckets) { \ + if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \ + else x = i; \ + } \ + } \ + } \ + if (__ac_isempty(h->flags, x)) { /* not present at all */ \ + h->keys[x] = key; \ + __ac_set_isboth_false(h->flags, x); \ + ++h->size; ++h->n_occupied; \ + *ret = 1; \ + } else if (__ac_isdel(h->flags, x)) { /* deleted */ \ + h->keys[x] = key; \ + __ac_set_isboth_false(h->flags, x); \ + ++h->size; \ + *ret = 2; \ + } else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \ + return x; \ + } \ + SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \ + { \ + if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \ + __ac_set_isdel_true(h->flags, x); \ + --h->size; \ + } \ + } + +#define KHASH_DECLARE(name, khkey_t, khval_t) \ + __KHASH_TYPE(name, khkey_t, khval_t) \ + __KHASH_PROTOTYPES(name, khkey_t, khval_t) + +#define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ + __KHASH_TYPE(name, khkey_t, khval_t) \ + __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) + +#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ + KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) + +/* --- BEGIN OF HASH FUNCTIONS --- */ + +/*! @function + @abstract Integer hash function + @param key The integer [khint32_t] + @return The hash value [khint_t] + */ +#define kh_int_hash_func(key) (khint32_t)(key) +/*! @function + @abstract Integer comparison function + */ +#define kh_int_hash_equal(a, b) ((a) == (b)) +/*! @function + @abstract 64-bit integer hash function + @param key The integer [khint64_t] + @return The hash value [khint_t] + */ +#define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11) +/*! @function + @abstract 64-bit integer comparison function + */ +#define kh_int64_hash_equal(a, b) ((a) == (b)) +/*! @function + @abstract const char* hash function + @param s Pointer to a null terminated string + @return The hash value + */ +static kh_inline khint_t __ac_X31_hash_string(const char *s) +{ + khint_t h = (khint_t)*s; + if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s; + return h; +} +/*! @function + @abstract Another interface to const char* hash function + @param key Pointer to a null terminated string [const char*] + @return The hash value [khint_t] + */ +#define kh_str_hash_func(key) __ac_X31_hash_string(key) +/*! @function + @abstract Const char* comparison function + */ +#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) + +static kh_inline khint_t __ac_Wang_hash(khint_t key) +{ + key += ~(key << 15); + key ^= (key >> 10); + key += (key << 3); + key ^= (key >> 6); + key += ~(key << 11); + key ^= (key >> 16); + return key; +} +#define kh_int_hash_func2(k) __ac_Wang_hash((khint_t)key) + +/* --- END OF HASH FUNCTIONS --- */ + +/* Other convenient macros... */ + +/*! + @abstract Type of the hash table. + @param name Name of the hash table [symbol] + */ +#define khash_t(name) kh_##name##_t + +/*! @function + @abstract Initiate a hash table. + @param name Name of the hash table [symbol] + @return Pointer to the hash table [khash_t(name)*] + */ +#define kh_init(name) kh_init_##name() + +/*! @function + @abstract Destroy a hash table. + @param name Name of the hash table [symbol] + @param h Pointer to the hash table [khash_t(name)*] + */ +#define kh_destroy(name, h) kh_destroy_##name(h) + +/*! @function + @abstract Reset a hash table without deallocating memory. + @param name Name of the hash table [symbol] + @param h Pointer to the hash table [khash_t(name)*] + */ +#define kh_clear(name, h) kh_clear_##name(h) + +/*! @function + @abstract Resize a hash table. + @param name Name of the hash table [symbol] + @param h Pointer to the hash table [khash_t(name)*] + @param s New size [khint_t] + */ +#define kh_resize(name, h, s) kh_resize_##name(h, s) + +/*! @function + @abstract Insert a key to the hash table. + @param name Name of the hash table [symbol] + @param h Pointer to the hash table [khash_t(name)*] + @param k Key [type of keys] + @param r Extra return code: -1 if the operation failed; + 0 if the key is present in the hash table; + 1 if the bucket is empty (never used); 2 if the element in + the bucket has been deleted [int*] + @return Iterator to the inserted element [khint_t] + */ +#define kh_put(name, h, k, r) kh_put_##name(h, k, r) + +/*! @function + @abstract Retrieve a key from the hash table. + @param name Name of the hash table [symbol] + @param h Pointer to the hash table [khash_t(name)*] + @param k Key [type of keys] + @return Iterator to the found element, or kh_end(h) if the element is absent [khint_t] + */ +#define kh_get(name, h, k) kh_get_##name(h, k) + +/*! @function + @abstract Remove a key from the hash table. + @param name Name of the hash table [symbol] + @param h Pointer to the hash table [khash_t(name)*] + @param k Iterator to the element to be deleted [khint_t] + */ +#define kh_del(name, h, k) kh_del_##name(h, k) + +/*! @function + @abstract Test whether a bucket contains data. + @param h Pointer to the hash table [khash_t(name)*] + @param x Iterator to the bucket [khint_t] + @return 1 if containing data; 0 otherwise [int] + */ +#define kh_exist(h, x) (!__ac_iseither((h)->flags, (x))) + +/*! @function + @abstract Get key given an iterator + @param h Pointer to the hash table [khash_t(name)*] + @param x Iterator to the bucket [khint_t] + @return Key [type of keys] + */ +#define kh_key(h, x) ((h)->keys[x]) + +/*! @function + @abstract Get value given an iterator + @param h Pointer to the hash table [khash_t(name)*] + @param x Iterator to the bucket [khint_t] + @return Value [type of values] + @discussion For hash sets, calling this results in segfault. + */ +#define kh_val(h, x) ((h)->vals[x]) + +/*! @function + @abstract Alias of kh_val() + */ +#define kh_value(h, x) ((h)->vals[x]) + +/*! @function + @abstract Get the start iterator + @param h Pointer to the hash table [khash_t(name)*] + @return The start iterator [khint_t] + */ +#define kh_begin(h) (khint_t)(0) + +/*! @function + @abstract Get the end iterator + @param h Pointer to the hash table [khash_t(name)*] + @return The end iterator [khint_t] + */ +#define kh_end(h) ((h)->n_buckets) + +/*! @function + @abstract Get the number of elements in the hash table + @param h Pointer to the hash table [khash_t(name)*] + @return Number of elements in the hash table [khint_t] + */ +#define kh_size(h) ((h)->size) + +/*! @function + @abstract Get the number of buckets in the hash table + @param h Pointer to the hash table [khash_t(name)*] + @return Number of buckets in the hash table [khint_t] + */ +#define kh_n_buckets(h) ((h)->n_buckets) + +/*! @function + @abstract Iterate over the entries in the hash table + @param h Pointer to the hash table [khash_t(name)*] + @param kvar Variable to which key will be assigned + @param vvar Variable to which value will be assigned + @param code Block of code to execute + */ +#define kh_foreach(h, kvar, vvar, code) { khint_t __i; \ + for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ + if (!kh_exist(h,__i)) continue; \ + (kvar) = kh_key(h,__i); \ + (vvar) = kh_val(h,__i); \ + code; \ + } } + +/*! @function + @abstract Iterate over the values in the hash table + @param h Pointer to the hash table [khash_t(name)*] + @param vvar Variable to which value will be assigned + @param code Block of code to execute + */ +#define kh_foreach_value(h, vvar, code) { khint_t __i; \ + for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ + if (!kh_exist(h,__i)) continue; \ + (vvar) = kh_val(h,__i); \ + code; \ + } } + +/* More conenient interfaces */ + +/*! @function + @abstract Instantiate a hash set containing integer keys + @param name Name of the hash table [symbol] + */ +#define KHASH_SET_INIT_INT(name) \ + KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal) + +/*! @function + @abstract Instantiate a hash map containing integer keys + @param name Name of the hash table [symbol] + @param khval_t Type of values [type] + */ +#define KHASH_MAP_INIT_INT(name, khval_t) \ + KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal) + +/*! @function + @abstract Instantiate a hash map containing 64-bit integer keys + @param name Name of the hash table [symbol] + */ +#define KHASH_SET_INIT_INT64(name) \ + KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal) + +/*! @function + @abstract Instantiate a hash map containing 64-bit integer keys + @param name Name of the hash table [symbol] + @param khval_t Type of values [type] + */ +#define KHASH_MAP_INIT_INT64(name, khval_t) \ + KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal) + +typedef const char *kh_cstr_t; +/*! @function + @abstract Instantiate a hash map containing const char* keys + @param name Name of the hash table [symbol] + */ +#define KHASH_SET_INIT_STR(name) \ + KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal) + +/*! @function + @abstract Instantiate a hash map containing const char* keys + @param name Name of the hash table [symbol] + @param khval_t Type of values [type] + */ +#define KHASH_MAP_INIT_STR(name, khval_t) \ + KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal) + +#endif /* __AC_KHASH_H */ \ No newline at end of file diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/map.h b/deps/libgit2-sys-0.2.17/libgit2/src/map.h new file mode 100644 index 000000000..da3d1e19a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/map.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_map_h__ +#define INCLUDE_map_h__ + +#include "common.h" + + +/* p_mmap() prot values */ +#define GIT_PROT_NONE 0x0 +#define GIT_PROT_READ 0x1 +#define GIT_PROT_WRITE 0x2 +#define GIT_PROT_EXEC 0x4 + +/* git__mmmap() flags values */ +#define GIT_MAP_FILE 0 +#define GIT_MAP_SHARED 1 +#define GIT_MAP_PRIVATE 2 +#define GIT_MAP_TYPE 0xf +#define GIT_MAP_FIXED 0x10 + +#ifdef __amigaos4__ +#define MAP_FAILED 0 +#endif + +typedef struct { /* memory mapped buffer */ + void *data; /* data bytes */ + size_t len; /* data length */ +#ifdef GIT_WIN32 + HANDLE fmh; /* file mapping handle */ +#endif +} git_map; + +#define GIT_MMAP_VALIDATE(out, len, prot, flags) do { \ + assert(out != NULL && len > 0); \ + assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \ + assert((flags & GIT_MAP_FIXED) == 0); } while (0) + +extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset); +extern int p_munmap(git_map *map); + +#endif /* INCLUDE_map_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/merge.c b/deps/libgit2-sys-0.2.17/libgit2/src/merge.c new file mode 100644 index 000000000..bd676aacf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/merge.c @@ -0,0 +1,2762 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "posix.h" +#include "buffer.h" +#include "repository.h" +#include "revwalk.h" +#include "commit_list.h" +#include "merge.h" +#include "path.h" +#include "refs.h" +#include "object.h" +#include "iterator.h" +#include "refs.h" +#include "diff.h" +#include "checkout.h" +#include "tree.h" +#include "merge_file.h" +#include "blob.h" +#include "oid.h" +#include "index.h" +#include "filebuf.h" +#include "config.h" +#include "oidarray.h" +#include "annotated_commit.h" + +#include "git2/types.h" +#include "git2/repository.h" +#include "git2/object.h" +#include "git2/commit.h" +#include "git2/merge.h" +#include "git2/refs.h" +#include "git2/reset.h" +#include "git2/checkout.h" +#include "git2/signature.h" +#include "git2/config.h" +#include "git2/tree.h" +#include "git2/oidarray.h" +#include "git2/annotated_commit.h" +#include "git2/sys/index.h" +#include "git2/sys/hashsig.h" + +#define GIT_MERGE_INDEX_ENTRY_EXISTS(X) ((X).mode != 0) +#define GIT_MERGE_INDEX_ENTRY_ISFILE(X) S_ISREG((X).mode) + +typedef enum { + TREE_IDX_ANCESTOR = 0, + TREE_IDX_OURS = 1, + TREE_IDX_THEIRS = 2 +} merge_tree_index_t; + +/* Tracks D/F conflicts */ +struct merge_diff_df_data { + const char *df_path; + const char *prev_path; + git_merge_diff *prev_conflict; +}; + +GIT_INLINE(int) merge_diff_detect_binary( + bool *binary_out, + git_repository *repo, + const git_merge_diff *conflict); + + +/* Merge base computation */ + +int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[]) +{ + git_revwalk *walk = NULL; + git_vector list; + git_commit_list *result = NULL; + git_commit_list_node *commit; + int error = -1; + unsigned int i; + + if (length < 2) { + giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %u.", length); + return -1; + } + + if (git_vector_init(&list, length - 1, NULL) < 0) + return -1; + + if (git_revwalk_new(&walk, repo) < 0) + goto on_error; + + for (i = 1; i < length; i++) { + commit = git_revwalk__commit_lookup(walk, &input_array[i]); + if (commit == NULL) + goto on_error; + + git_vector_insert(&list, commit); + } + + commit = git_revwalk__commit_lookup(walk, &input_array[0]); + if (commit == NULL) + goto on_error; + + if (git_merge__bases_many(&result, walk, commit, &list) < 0) + goto on_error; + + if (!result) { + giterr_set(GITERR_MERGE, "No merge base found"); + error = GIT_ENOTFOUND; + goto on_error; + } + + *out = result; + *walk_out = walk; + + git_vector_free(&list); + return 0; + +on_error: + git_vector_free(&list); + git_revwalk_free(walk); + return error; +} + +int git_merge_base_many(git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]) +{ + git_revwalk *walk; + git_commit_list *result = NULL; + int error = 0; + + assert(out && repo && input_array); + + if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0) + return error; + + git_oid_cpy(out, &result->item->oid); + + git_commit_list_free(&result); + git_revwalk_free(walk); + + return 0; +} + +int git_merge_bases_many(git_oidarray *out, git_repository *repo, size_t length, const git_oid input_array[]) +{ + git_revwalk *walk; + git_commit_list *list, *result = NULL; + int error = 0; + git_array_oid_t array; + + assert(out && repo && input_array); + + if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0) + return error; + + git_array_init(array); + + list = result; + while (list) { + git_oid *id = git_array_alloc(array); + if (id == NULL) { + error = -1; + goto cleanup; + } + + git_oid_cpy(id, &list->item->oid); + list = list->next; + } + + git_oidarray__from_array(out, &array); + +cleanup: + git_commit_list_free(&result); + git_revwalk_free(walk); + + return error; +} + +int git_merge_base_octopus(git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]) +{ + git_oid result; + unsigned int i; + int error = -1; + + assert(out && repo && input_array); + + if (length < 2) { + giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %u.", length); + return -1; + } + + result = input_array[0]; + for (i = 1; i < length; i++) { + error = git_merge_base(&result, repo, &result, &input_array[i]); + if (error < 0) + return error; + } + + *out = result; + + return 0; +} + +static int merge_bases(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, const git_oid *one, const git_oid *two) +{ + git_revwalk *walk; + git_vector list; + git_commit_list *result = NULL; + git_commit_list_node *commit; + void *contents[1]; + + if (git_revwalk_new(&walk, repo) < 0) + return -1; + + commit = git_revwalk__commit_lookup(walk, two); + if (commit == NULL) + goto on_error; + + /* This is just one value, so we can do it on the stack */ + memset(&list, 0x0, sizeof(git_vector)); + contents[0] = commit; + list.length = 1; + list.contents = contents; + + commit = git_revwalk__commit_lookup(walk, one); + if (commit == NULL) + goto on_error; + + if (git_merge__bases_many(&result, walk, commit, &list) < 0) + goto on_error; + + if (!result) { + git_revwalk_free(walk); + giterr_set(GITERR_MERGE, "No merge base found"); + return GIT_ENOTFOUND; + } + + *out = result; + *walk_out = walk; + + return 0; + +on_error: + git_revwalk_free(walk); + return -1; + +} + +int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two) +{ + int error; + git_revwalk *walk; + git_commit_list *result; + + if ((error = merge_bases(&result, &walk, repo, one, two)) < 0) + return error; + + git_oid_cpy(out, &result->item->oid); + git_commit_list_free(&result); + git_revwalk_free(walk); + + return 0; +} + +int git_merge_bases(git_oidarray *out, git_repository *repo, const git_oid *one, const git_oid *two) +{ + int error; + git_revwalk *walk; + git_commit_list *result, *list; + git_array_oid_t array; + + git_array_init(array); + + if ((error = merge_bases(&result, &walk, repo, one, two)) < 0) + return error; + + list = result; + while (list) { + git_oid *id = git_array_alloc(array); + if (id == NULL) + goto on_error; + + git_oid_cpy(id, &list->item->oid); + list = list->next; + } + + git_oidarray__from_array(out, &array); + git_commit_list_free(&result); + git_revwalk_free(walk); + + return 0; + +on_error: + git_commit_list_free(&result); + git_revwalk_free(walk); + return -1; +} + +static int interesting(git_pqueue *list) +{ + size_t i; + + for (i = 0; i < git_pqueue_size(list); i++) { + git_commit_list_node *commit = git_pqueue_get(list, i); + if ((commit->flags & STALE) == 0) + return 1; + } + + return 0; +} + +int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos) +{ + int error; + unsigned int i; + git_commit_list_node *two; + git_commit_list *result = NULL, *tmp = NULL; + git_pqueue list; + + /* If there's only the one commit, there can be no merge bases */ + if (twos->length == 0) { + *out = NULL; + return 0; + } + + /* if the commit is repeated, we have a our merge base already */ + git_vector_foreach(twos, i, two) { + if (one == two) + return git_commit_list_insert(one, out) ? 0 : -1; + } + + if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0) + return -1; + + if (git_commit_list_parse(walk, one) < 0) + return -1; + + one->flags |= PARENT1; + if (git_pqueue_insert(&list, one) < 0) + return -1; + + git_vector_foreach(twos, i, two) { + if (git_commit_list_parse(walk, two) < 0) + return -1; + + two->flags |= PARENT2; + + if (git_pqueue_insert(&list, two) < 0) + return -1; + } + + /* as long as there are non-STALE commits */ + while (interesting(&list)) { + git_commit_list_node *commit = git_pqueue_pop(&list); + int flags; + + if (commit == NULL) + break; + + flags = commit->flags & (PARENT1 | PARENT2 | STALE); + if (flags == (PARENT1 | PARENT2)) { + if (!(commit->flags & RESULT)) { + commit->flags |= RESULT; + if (git_commit_list_insert(commit, &result) == NULL) + return -1; + } + /* we mark the parents of a merge stale */ + flags |= STALE; + } + + for (i = 0; i < commit->out_degree; i++) { + git_commit_list_node *p = commit->parents[i]; + if ((p->flags & flags) == flags) + continue; + + if ((error = git_commit_list_parse(walk, p)) < 0) + return error; + + p->flags |= flags; + if (git_pqueue_insert(&list, p) < 0) + return -1; + } + } + + git_pqueue_free(&list); + + /* filter out any stale commits in the results */ + tmp = result; + result = NULL; + + while (tmp) { + struct git_commit_list *next = tmp->next; + if (!(tmp->item->flags & STALE)) + if (git_commit_list_insert_by_date(tmp->item, &result) == NULL) + return -1; + + git__free(tmp); + tmp = next; + } + + *out = result; + return 0; +} + +int git_repository_mergehead_foreach( + git_repository *repo, + git_repository_mergehead_foreach_cb cb, + void *payload) +{ + git_buf merge_head_path = GIT_BUF_INIT, merge_head_file = GIT_BUF_INIT; + char *buffer, *line; + size_t line_num = 1; + git_oid oid; + int error = 0; + + assert(repo && cb); + + if ((error = git_buf_joinpath(&merge_head_path, repo->path_repository, + GIT_MERGE_HEAD_FILE)) < 0) + return error; + + if ((error = git_futils_readbuffer(&merge_head_file, + git_buf_cstr(&merge_head_path))) < 0) + goto cleanup; + + buffer = merge_head_file.ptr; + + while ((line = git__strsep(&buffer, "\n")) != NULL) { + if (strlen(line) != GIT_OID_HEXSZ) { + giterr_set(GITERR_INVALID, "Unable to parse OID - invalid length"); + error = -1; + goto cleanup; + } + + if ((error = git_oid_fromstr(&oid, line)) < 0) + goto cleanup; + + if ((error = cb(&oid, payload)) != 0) { + giterr_set_after_callback(error); + goto cleanup; + } + + ++line_num; + } + + if (*buffer) { + giterr_set(GITERR_MERGE, "No EOL at line %d", line_num); + error = -1; + goto cleanup; + } + +cleanup: + git_buf_free(&merge_head_path); + git_buf_free(&merge_head_file); + + return error; +} + +GIT_INLINE(int) index_entry_cmp(const git_index_entry *a, const git_index_entry *b) +{ + int value = 0; + + if (a->path == NULL) + return (b->path == NULL) ? 0 : 1; + + if ((value = a->mode - b->mode) == 0 && + (value = git_oid__cmp(&a->id, &b->id)) == 0) + value = strcmp(a->path, b->path); + + return value; +} + +/* Conflict resolution */ + +static int merge_conflict_resolve_trivial( + int *resolved, + git_merge_diff_list *diff_list, + const git_merge_diff *conflict) +{ + int ours_empty, theirs_empty; + int ours_changed, theirs_changed, ours_theirs_differ; + git_index_entry const *result = NULL; + int error = 0; + + assert(resolved && diff_list && conflict); + + *resolved = 0; + + if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE || + conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) + return 0; + + if (conflict->our_status == GIT_DELTA_RENAMED || + conflict->their_status == GIT_DELTA_RENAMED) + return 0; + + ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry); + theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry); + + ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED); + theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED); + ours_theirs_differ = ours_changed && theirs_changed && + index_entry_cmp(&conflict->our_entry, &conflict->their_entry); + + /* + * Note: with only one ancestor, some cases are not distinct: + * + * 16: ancest:anc1/anc2, head:anc1, remote:anc2 = result:no merge + * 3: ancest:(empty)^, head:head, remote:(empty) = result:no merge + * 2: ancest:(empty)^, head:(empty), remote:remote = result:no merge + * + * Note that the two cases that take D/F conflicts into account + * specifically do not need to be explicitly tested, as D/F conflicts + * would fail the *empty* test: + * + * 3ALT: ancest:(empty)+, head:head, remote:*empty* = result:head + * 2ALT: ancest:(empty)+, head:*empty*, remote:remote = result:remote + * + * Note that many of these cases need not be explicitly tested, as + * they simply degrade to "all different" cases (eg, 11): + * + * 4: ancest:(empty)^, head:head, remote:remote = result:no merge + * 7: ancest:ancest+, head:(empty), remote:remote = result:no merge + * 9: ancest:ancest+, head:head, remote:(empty) = result:no merge + * 11: ancest:ancest+, head:head, remote:remote = result:no merge + */ + + /* 5ALT: ancest:*, head:head, remote:head = result:head */ + if (ours_changed && !ours_empty && !ours_theirs_differ) + result = &conflict->our_entry; + /* 6: ancest:ancest+, head:(empty), remote:(empty) = result:no merge */ + else if (ours_changed && ours_empty && theirs_empty) + *resolved = 0; + /* 8: ancest:ancest^, head:(empty), remote:ancest = result:no merge */ + else if (ours_empty && !theirs_changed) + *resolved = 0; + /* 10: ancest:ancest^, head:ancest, remote:(empty) = result:no merge */ + else if (!ours_changed && theirs_empty) + *resolved = 0; + /* 13: ancest:ancest+, head:head, remote:ancest = result:head */ + else if (ours_changed && !theirs_changed) + result = &conflict->our_entry; + /* 14: ancest:ancest+, head:ancest, remote:remote = result:remote */ + else if (!ours_changed && theirs_changed) + result = &conflict->their_entry; + else + *resolved = 0; + + if (result != NULL && + GIT_MERGE_INDEX_ENTRY_EXISTS(*result) && + (error = git_vector_insert(&diff_list->staged, (void *)result)) >= 0) + *resolved = 1; + + /* Note: trivial resolution does not update the REUC. */ + + return error; +} + +static int merge_conflict_resolve_one_removed( + int *resolved, + git_merge_diff_list *diff_list, + const git_merge_diff *conflict) +{ + int ours_empty, theirs_empty; + int ours_changed, theirs_changed; + int error = 0; + + assert(resolved && diff_list && conflict); + + *resolved = 0; + + if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE || + conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) + return 0; + + ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry); + theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry); + + ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED); + theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED); + + /* Removed in both */ + if (ours_changed && ours_empty && theirs_empty) + *resolved = 1; + /* Removed in ours */ + else if (ours_empty && !theirs_changed) + *resolved = 1; + /* Removed in theirs */ + else if (!ours_changed && theirs_empty) + *resolved = 1; + + if (*resolved) + git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); + + return error; +} + +static int merge_conflict_resolve_one_renamed( + int *resolved, + git_merge_diff_list *diff_list, + const git_merge_diff *conflict) +{ + int ours_renamed, theirs_renamed; + int ours_changed, theirs_changed; + git_index_entry *merged; + int error = 0; + + assert(resolved && diff_list && conflict); + + *resolved = 0; + + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) || + !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) + return 0; + + ours_renamed = (conflict->our_status == GIT_DELTA_RENAMED); + theirs_renamed = (conflict->their_status == GIT_DELTA_RENAMED); + + if (!ours_renamed && !theirs_renamed) + return 0; + + /* Reject one file in a 2->1 conflict */ + if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 || + conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 || + conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) + return 0; + + ours_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->our_entry.id) != 0); + theirs_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->their_entry.id) != 0); + + /* if both are modified (and not to a common target) require a merge */ + if (ours_changed && theirs_changed && + git_oid__cmp(&conflict->our_entry.id, &conflict->their_entry.id) != 0) + return 0; + + if ((merged = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL) + return -1; + + if (ours_changed) + memcpy(merged, &conflict->our_entry, sizeof(git_index_entry)); + else + memcpy(merged, &conflict->their_entry, sizeof(git_index_entry)); + + if (ours_renamed) + merged->path = conflict->our_entry.path; + else + merged->path = conflict->their_entry.path; + + *resolved = 1; + + git_vector_insert(&diff_list->staged, merged); + git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); + + return error; +} + +static int merge_conflict_resolve_automerge( + int *resolved, + git_merge_diff_list *diff_list, + const git_merge_diff *conflict, + unsigned int merge_file_favor, + unsigned int file_flags) +{ + const git_index_entry *ancestor = NULL, *ours = NULL, *theirs = NULL; + git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT; + git_merge_file_result result = {0}; + git_index_entry *index_entry; + git_odb *odb = NULL; + git_oid automerge_oid; + int error = 0; + bool binary = false; + + assert(resolved && diff_list && conflict); + + *resolved = 0; + + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) || + !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) + return 0; + + /* Reject D/F conflicts */ + if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE) + return 0; + + /* Reject submodules. */ + if (S_ISGITLINK(conflict->ancestor_entry.mode) || + S_ISGITLINK(conflict->our_entry.mode) || + S_ISGITLINK(conflict->their_entry.mode)) + return 0; + + /* Reject link/file conflicts. */ + if ((S_ISLNK(conflict->ancestor_entry.mode) ^ S_ISLNK(conflict->our_entry.mode)) || + (S_ISLNK(conflict->ancestor_entry.mode) ^ S_ISLNK(conflict->their_entry.mode))) + return 0; + + /* Reject name conflicts */ + if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 || + conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) + return 0; + + if ((conflict->our_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED && + (conflict->their_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED && + strcmp(conflict->ancestor_entry.path, conflict->their_entry.path) != 0) + return 0; + + /* Reject binary conflicts */ + if ((error = merge_diff_detect_binary(&binary, diff_list->repo, conflict)) < 0) + return error; + if (binary) + return 0; + + ancestor = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? + &conflict->ancestor_entry : NULL; + ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? + &conflict->our_entry : NULL; + theirs = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? + &conflict->their_entry : NULL; + + opts.favor = merge_file_favor; + opts.flags = file_flags; + + if ((error = git_repository_odb(&odb, diff_list->repo)) < 0 || + (error = git_merge_file_from_index(&result, diff_list->repo, ancestor, ours, theirs, &opts)) < 0 || + !result.automergeable || + (error = git_odb_write(&automerge_oid, odb, result.ptr, result.len, GIT_OBJ_BLOB)) < 0) + goto done; + + if ((index_entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL) + GITERR_CHECK_ALLOC(index_entry); + + index_entry->path = git_pool_strdup(&diff_list->pool, result.path); + GITERR_CHECK_ALLOC(index_entry->path); + + index_entry->file_size = result.len; + index_entry->mode = result.mode; + git_oid_cpy(&index_entry->id, &automerge_oid); + + git_vector_insert(&diff_list->staged, index_entry); + git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); + + *resolved = 1; + +done: + git_merge_file_result_free(&result); + git_odb_free(odb); + + return error; +} + +static int merge_conflict_resolve( + int *out, + git_merge_diff_list *diff_list, + const git_merge_diff *conflict, + unsigned int merge_file_favor, + unsigned int file_flags) +{ + int resolved = 0; + int error = 0; + + *out = 0; + + if ((error = merge_conflict_resolve_trivial(&resolved, diff_list, conflict)) < 0) + goto done; + + if (!resolved && (error = merge_conflict_resolve_one_removed(&resolved, diff_list, conflict)) < 0) + goto done; + + if (!resolved && (error = merge_conflict_resolve_one_renamed(&resolved, diff_list, conflict)) < 0) + goto done; + + if (!resolved && (error = merge_conflict_resolve_automerge(&resolved, diff_list, conflict, + merge_file_favor, file_flags)) < 0) + goto done; + + *out = resolved; + +done: + return error; +} + +/* Rename detection and coalescing */ + +struct merge_diff_similarity { + unsigned char similarity; + size_t other_idx; +}; + +static int index_entry_similarity_exact( + git_repository *repo, + git_index_entry *a, + size_t a_idx, + git_index_entry *b, + size_t b_idx, + void **cache, + const git_merge_options *opts) +{ + GIT_UNUSED(repo); + GIT_UNUSED(a_idx); + GIT_UNUSED(b_idx); + GIT_UNUSED(cache); + GIT_UNUSED(opts); + + if (git_oid__cmp(&a->id, &b->id) == 0) + return 100; + + return 0; +} + +static int index_entry_similarity_calc( + void **out, + git_repository *repo, + git_index_entry *entry, + const git_merge_options *opts) +{ + git_blob *blob; + git_diff_file diff_file = {{{0}}}; + git_off_t blobsize; + int error; + + *out = NULL; + + if ((error = git_blob_lookup(&blob, repo, &entry->id)) < 0) + return error; + + git_oid_cpy(&diff_file.id, &entry->id); + diff_file.path = entry->path; + diff_file.size = entry->file_size; + diff_file.mode = entry->mode; + diff_file.flags = 0; + + blobsize = git_blob_rawsize(blob); + + /* file too big for rename processing */ + if (!git__is_sizet(blobsize)) + return 0; + + error = opts->metric->buffer_signature(out, &diff_file, + git_blob_rawcontent(blob), (size_t)blobsize, + opts->metric->payload); + + git_blob_free(blob); + + return error; +} + +static int index_entry_similarity_inexact( + git_repository *repo, + git_index_entry *a, + size_t a_idx, + git_index_entry *b, + size_t b_idx, + void **cache, + const git_merge_options *opts) +{ + int score = 0; + int error = 0; + + if (GIT_MODE_TYPE(a->mode) != GIT_MODE_TYPE(b->mode)) + return 0; + + /* update signature cache if needed */ + if (!cache[a_idx] && (error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0) + return error; + if (!cache[b_idx] && (error = index_entry_similarity_calc(&cache[b_idx], repo, b, opts)) < 0) + return error; + + /* some metrics may not wish to process this file (too big / too small) */ + if (!cache[a_idx] || !cache[b_idx]) + return 0; + + /* compare signatures */ + if (opts->metric->similarity( + &score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0) + return -1; + + /* clip score */ + if (score < 0) + score = 0; + else if (score > 100) + score = 100; + + return score; +} + +static int merge_diff_mark_similarity( + git_repository *repo, + git_merge_diff_list *diff_list, + struct merge_diff_similarity *similarity_ours, + struct merge_diff_similarity *similarity_theirs, + int (*similarity_fn)(git_repository *, git_index_entry *, size_t, git_index_entry *, size_t, void **, const git_merge_options *), + void **cache, + const git_merge_options *opts) +{ + size_t i, j; + git_merge_diff *conflict_src, *conflict_tgt; + int similarity; + + git_vector_foreach(&diff_list->conflicts, i, conflict_src) { + /* Items can be the source of a rename iff they have an item in the + * ancestor slot and lack an item in the ours or theirs slot. */ + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry) || + (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry) && + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry))) + continue; + + git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) { + size_t our_idx = diff_list->conflicts.length + j; + size_t their_idx = (diff_list->conflicts.length * 2) + j; + + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry)) + continue; + + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) && + !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) { + similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->our_entry, our_idx, cache, opts); + + if (similarity == GIT_EBUFS) + continue; + else if (similarity < 0) + return similarity; + + if (similarity > similarity_ours[i].similarity && + similarity > similarity_ours[j].similarity) { + /* Clear previous best similarity */ + if (similarity_ours[i].similarity > 0) + similarity_ours[similarity_ours[i].other_idx].similarity = 0; + + if (similarity_ours[j].similarity > 0) + similarity_ours[similarity_ours[j].other_idx].similarity = 0; + + similarity_ours[i].similarity = similarity; + similarity_ours[i].other_idx = j; + + similarity_ours[j].similarity = similarity; + similarity_ours[j].other_idx = i; + } + } + + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) && + !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) { + similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->their_entry, their_idx, cache, opts); + + if (similarity > similarity_theirs[i].similarity && + similarity > similarity_theirs[j].similarity) { + /* Clear previous best similarity */ + if (similarity_theirs[i].similarity > 0) + similarity_theirs[similarity_theirs[i].other_idx].similarity = 0; + + if (similarity_theirs[j].similarity > 0) + similarity_theirs[similarity_theirs[j].other_idx].similarity = 0; + + similarity_theirs[i].similarity = similarity; + similarity_theirs[i].other_idx = j; + + similarity_theirs[j].similarity = similarity; + similarity_theirs[j].other_idx = i; + } + } + } + } + + return 0; +} + +/* + * Rename conflicts: + * + * Ancestor Ours Theirs + * + * 0a A A A No rename + * b A A* A No rename (ours was rewritten) + * c A A A* No rename (theirs rewritten) + * 1a A A B[A] Rename or rename/edit + * b A B[A] A (automergeable) + * 2 A B[A] B[A] Both renamed (automergeable) + * 3a A B[A] Rename/delete + * b A B[A] (same) + * 4a A B[A] B Rename/add [B~ours B~theirs] + * b A B B[A] (same) + * 5 A B[A] C[A] Both renamed ("1 -> 2") + * 6 A C[A] Both renamed ("2 -> 1") + * B C[B] [C~ours C~theirs] (automergeable) + */ +static void merge_diff_mark_rename_conflict( + git_merge_diff_list *diff_list, + struct merge_diff_similarity *similarity_ours, + bool ours_renamed, + size_t ours_source_idx, + struct merge_diff_similarity *similarity_theirs, + bool theirs_renamed, + size_t theirs_source_idx, + git_merge_diff *target, + const git_merge_options *opts) +{ + git_merge_diff *ours_source = NULL, *theirs_source = NULL; + + if (ours_renamed) + ours_source = diff_list->conflicts.contents[ours_source_idx]; + + if (theirs_renamed) + theirs_source = diff_list->conflicts.contents[theirs_source_idx]; + + /* Detect 2->1 conflicts */ + if (ours_renamed && theirs_renamed) { + /* Both renamed to the same target name. */ + if (ours_source_idx == theirs_source_idx) + ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED; + else { + ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1; + theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1; + } + } else if (ours_renamed) { + /* If our source was also renamed in theirs, this is a 1->2 */ + if (similarity_theirs[ours_source_idx].similarity >= opts->rename_threshold) + ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2; + + else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry)) { + ours_source->type = GIT_MERGE_DIFF_RENAMED_ADDED; + target->type = GIT_MERGE_DIFF_RENAMED_ADDED; + } + + else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(ours_source->their_entry)) + ours_source->type = GIT_MERGE_DIFF_RENAMED_DELETED; + + else if (ours_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED) + ours_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED; + } else if (theirs_renamed) { + /* If their source was also renamed in ours, this is a 1->2 */ + if (similarity_ours[theirs_source_idx].similarity >= opts->rename_threshold) + theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2; + + else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry)) { + theirs_source->type = GIT_MERGE_DIFF_RENAMED_ADDED; + target->type = GIT_MERGE_DIFF_RENAMED_ADDED; + } + + else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(theirs_source->our_entry)) + theirs_source->type = GIT_MERGE_DIFF_RENAMED_DELETED; + + else if (theirs_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED) + theirs_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED; + } +} + +GIT_INLINE(void) merge_diff_coalesce_rename( + git_index_entry *source_entry, + git_delta_t *source_status, + git_index_entry *target_entry, + git_delta_t *target_status) +{ + /* Coalesce the rename target into the rename source. */ + memcpy(source_entry, target_entry, sizeof(git_index_entry)); + *source_status = GIT_DELTA_RENAMED; + + memset(target_entry, 0x0, sizeof(git_index_entry)); + *target_status = GIT_DELTA_UNMODIFIED; +} + +static void merge_diff_list_coalesce_renames( + git_merge_diff_list *diff_list, + struct merge_diff_similarity *similarity_ours, + struct merge_diff_similarity *similarity_theirs, + const git_merge_options *opts) +{ + size_t i; + bool ours_renamed = 0, theirs_renamed = 0; + size_t ours_source_idx = 0, theirs_source_idx = 0; + git_merge_diff *ours_source, *theirs_source, *target; + + for (i = 0; i < diff_list->conflicts.length; i++) { + target = diff_list->conflicts.contents[i]; + + ours_renamed = 0; + theirs_renamed = 0; + + if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry) && + similarity_ours[i].similarity >= opts->rename_threshold) { + ours_source_idx = similarity_ours[i].other_idx; + + ours_source = diff_list->conflicts.contents[ours_source_idx]; + + merge_diff_coalesce_rename( + &ours_source->our_entry, + &ours_source->our_status, + &target->our_entry, + &target->our_status); + + similarity_ours[ours_source_idx].similarity = 0; + similarity_ours[i].similarity = 0; + + ours_renamed = 1; + } + + /* insufficient to determine direction */ + if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry) && + similarity_theirs[i].similarity >= opts->rename_threshold) { + theirs_source_idx = similarity_theirs[i].other_idx; + + theirs_source = diff_list->conflicts.contents[theirs_source_idx]; + + merge_diff_coalesce_rename( + &theirs_source->their_entry, + &theirs_source->their_status, + &target->their_entry, + &target->their_status); + + similarity_theirs[theirs_source_idx].similarity = 0; + similarity_theirs[i].similarity = 0; + + theirs_renamed = 1; + } + + merge_diff_mark_rename_conflict(diff_list, + similarity_ours, ours_renamed, ours_source_idx, + similarity_theirs, theirs_renamed, theirs_source_idx, + target, opts); + } +} + +static int merge_diff_empty(const git_vector *conflicts, size_t idx, void *p) +{ + git_merge_diff *conflict = conflicts->contents[idx]; + + GIT_UNUSED(p); + + return (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) && + !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) && + !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)); +} + +static void merge_diff_list_count_candidates( + git_merge_diff_list *diff_list, + size_t *src_count, + size_t *tgt_count) +{ + git_merge_diff *entry; + size_t i; + + *src_count = 0; + *tgt_count = 0; + + git_vector_foreach(&diff_list->conflicts, i, entry) { + if (GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry) && + (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->our_entry) || + !GIT_MERGE_INDEX_ENTRY_EXISTS(entry->their_entry))) + src_count++; + else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry)) + tgt_count++; + } +} + +int git_merge_diff_list__find_renames( + git_repository *repo, + git_merge_diff_list *diff_list, + const git_merge_options *opts) +{ + struct merge_diff_similarity *similarity_ours, *similarity_theirs; + void **cache = NULL; + size_t cache_size = 0; + size_t src_count, tgt_count, i; + int error = 0; + + assert(diff_list && opts); + + if ((opts->tree_flags & GIT_MERGE_TREE_FIND_RENAMES) == 0) + return 0; + + similarity_ours = git__calloc(diff_list->conflicts.length, + sizeof(struct merge_diff_similarity)); + GITERR_CHECK_ALLOC(similarity_ours); + + similarity_theirs = git__calloc(diff_list->conflicts.length, + sizeof(struct merge_diff_similarity)); + GITERR_CHECK_ALLOC(similarity_theirs); + + /* Calculate similarity between items that were deleted from the ancestor + * and added in the other branch. + */ + if ((error = merge_diff_mark_similarity(repo, diff_list, similarity_ours, + similarity_theirs, index_entry_similarity_exact, NULL, opts)) < 0) + goto done; + + if (diff_list->conflicts.length <= opts->target_limit) { + GITERR_CHECK_ALLOC_MULTIPLY(&cache_size, diff_list->conflicts.length, 3); + cache = git__calloc(cache_size, sizeof(void *)); + GITERR_CHECK_ALLOC(cache); + + merge_diff_list_count_candidates(diff_list, &src_count, &tgt_count); + + if (src_count > opts->target_limit || tgt_count > opts->target_limit) { + /* TODO: report! */ + } else { + if ((error = merge_diff_mark_similarity( + repo, diff_list, similarity_ours, similarity_theirs, + index_entry_similarity_inexact, cache, opts)) < 0) + goto done; + } + } + + /* For entries that are appropriately similar, merge the new name's entry + * into the old name. + */ + merge_diff_list_coalesce_renames(diff_list, similarity_ours, similarity_theirs, opts); + + /* And remove any entries that were merged and are now empty. */ + git_vector_remove_matching(&diff_list->conflicts, merge_diff_empty, NULL); + +done: + if (cache != NULL) { + for (i = 0; i < cache_size; ++i) { + if (cache[i] != NULL) + opts->metric->free_signature(cache[i], opts->metric->payload); + } + + git__free(cache); + } + + git__free(similarity_ours); + git__free(similarity_theirs); + + return error; +} + +/* Directory/file conflict handling */ + +GIT_INLINE(const char *) merge_diff_path( + const git_merge_diff *conflict) +{ + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry)) + return conflict->ancestor_entry.path; + else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry)) + return conflict->our_entry.path; + else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) + return conflict->their_entry.path; + + return NULL; +} + +GIT_INLINE(bool) merge_diff_any_side_added_or_modified( + const git_merge_diff *conflict) +{ + if (conflict->our_status == GIT_DELTA_ADDED || + conflict->our_status == GIT_DELTA_MODIFIED || + conflict->their_status == GIT_DELTA_ADDED || + conflict->their_status == GIT_DELTA_MODIFIED) + return true; + + return false; +} + +GIT_INLINE(bool) path_is_prefixed(const char *parent, const char *child) +{ + size_t child_len = strlen(child); + size_t parent_len = strlen(parent); + + if (child_len < parent_len || + strncmp(parent, child, parent_len) != 0) + return 0; + + return (child[parent_len] == '/'); +} + +GIT_INLINE(int) merge_diff_detect_df_conflict( + struct merge_diff_df_data *df_data, + git_merge_diff *conflict) +{ + const char *cur_path = merge_diff_path(conflict); + + /* Determine if this is a D/F conflict or the child of one */ + if (df_data->df_path && + path_is_prefixed(df_data->df_path, cur_path)) + conflict->type = GIT_MERGE_DIFF_DF_CHILD; + else if(df_data->df_path) + df_data->df_path = NULL; + else if (df_data->prev_path && + merge_diff_any_side_added_or_modified(df_data->prev_conflict) && + merge_diff_any_side_added_or_modified(conflict) && + path_is_prefixed(df_data->prev_path, cur_path)) { + conflict->type = GIT_MERGE_DIFF_DF_CHILD; + + df_data->prev_conflict->type = GIT_MERGE_DIFF_DIRECTORY_FILE; + df_data->df_path = df_data->prev_path; + } + + df_data->prev_path = cur_path; + df_data->prev_conflict = conflict; + + return 0; +} + +/* Conflict handling */ + +GIT_INLINE(int) merge_diff_detect_type( + git_merge_diff *conflict) +{ + if (conflict->our_status == GIT_DELTA_ADDED && + conflict->their_status == GIT_DELTA_ADDED) + conflict->type = GIT_MERGE_DIFF_BOTH_ADDED; + else if (conflict->our_status == GIT_DELTA_MODIFIED && + conflict->their_status == GIT_DELTA_MODIFIED) + conflict->type = GIT_MERGE_DIFF_BOTH_MODIFIED; + else if (conflict->our_status == GIT_DELTA_DELETED && + conflict->their_status == GIT_DELTA_DELETED) + conflict->type = GIT_MERGE_DIFF_BOTH_DELETED; + else if (conflict->our_status == GIT_DELTA_MODIFIED && + conflict->their_status == GIT_DELTA_DELETED) + conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED; + else if (conflict->our_status == GIT_DELTA_DELETED && + conflict->their_status == GIT_DELTA_MODIFIED) + conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED; + else + conflict->type = GIT_MERGE_DIFF_NONE; + + return 0; +} + +GIT_INLINE(int) merge_diff_detect_binary( + bool *binary_out, + git_repository *repo, + const git_merge_diff *conflict) +{ + git_blob *ancestor_blob = NULL, *our_blob = NULL, *their_blob = NULL; + int error = 0; + bool binary = false; + + if (GIT_MERGE_INDEX_ENTRY_ISFILE(conflict->ancestor_entry)) { + if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor_entry.id)) < 0) + goto done; + + binary = git_blob_is_binary(ancestor_blob); + } + + if (!binary && + GIT_MERGE_INDEX_ENTRY_ISFILE(conflict->our_entry)) { + if ((error = git_blob_lookup(&our_blob, repo, &conflict->our_entry.id)) < 0) + goto done; + + binary = git_blob_is_binary(our_blob); + } + + if (!binary && + GIT_MERGE_INDEX_ENTRY_ISFILE(conflict->their_entry)) { + if ((error = git_blob_lookup(&their_blob, repo, &conflict->their_entry.id)) < 0) + goto done; + + binary = git_blob_is_binary(their_blob); + } + + *binary_out = binary; + +done: + git_blob_free(ancestor_blob); + git_blob_free(our_blob); + git_blob_free(their_blob); + + return error; +} + +GIT_INLINE(int) index_entry_dup_pool( + git_index_entry *out, + git_pool *pool, + const git_index_entry *src) +{ + if (src != NULL) { + memcpy(out, src, sizeof(git_index_entry)); + + if ((out->path = git_pool_strdup(pool, src->path)) == NULL) + return -1; + } + + return 0; +} + +GIT_INLINE(int) merge_delta_type_from_index_entries( + const git_index_entry *ancestor, + const git_index_entry *other) +{ + if (ancestor == NULL && other == NULL) + return GIT_DELTA_UNMODIFIED; + else if (ancestor == NULL && other != NULL) + return GIT_DELTA_ADDED; + else if (ancestor != NULL && other == NULL) + return GIT_DELTA_DELETED; + else if (S_ISDIR(ancestor->mode) ^ S_ISDIR(other->mode)) + return GIT_DELTA_TYPECHANGE; + else if(S_ISLNK(ancestor->mode) ^ S_ISLNK(other->mode)) + return GIT_DELTA_TYPECHANGE; + else if (git_oid__cmp(&ancestor->id, &other->id) || + ancestor->mode != other->mode) + return GIT_DELTA_MODIFIED; + + return GIT_DELTA_UNMODIFIED; +} + +static git_merge_diff *merge_diff_from_index_entries( + git_merge_diff_list *diff_list, + const git_index_entry **entries) +{ + git_merge_diff *conflict; + git_pool *pool = &diff_list->pool; + + if ((conflict = git_pool_malloc(pool, sizeof(git_merge_diff))) == NULL) + return NULL; + + if (index_entry_dup_pool(&conflict->ancestor_entry, pool, entries[TREE_IDX_ANCESTOR]) < 0 || + index_entry_dup_pool(&conflict->our_entry, pool, entries[TREE_IDX_OURS]) < 0 || + index_entry_dup_pool(&conflict->their_entry, pool, entries[TREE_IDX_THEIRS]) < 0) + return NULL; + + conflict->our_status = merge_delta_type_from_index_entries( + entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_OURS]); + conflict->their_status = merge_delta_type_from_index_entries( + entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_THEIRS]); + + return conflict; +} + +/* Merge trees */ + +static int merge_diff_list_insert_conflict( + git_merge_diff_list *diff_list, + struct merge_diff_df_data *merge_df_data, + const git_index_entry *tree_items[3]) +{ + git_merge_diff *conflict; + + if ((conflict = merge_diff_from_index_entries(diff_list, tree_items)) == NULL || + merge_diff_detect_type(conflict) < 0 || + merge_diff_detect_df_conflict(merge_df_data, conflict) < 0 || + git_vector_insert(&diff_list->conflicts, conflict) < 0) + return -1; + + return 0; +} + +static int merge_diff_list_insert_unmodified( + git_merge_diff_list *diff_list, + const git_index_entry *tree_items[3]) +{ + int error = 0; + git_index_entry *entry; + + entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry)); + GITERR_CHECK_ALLOC(entry); + + if ((error = index_entry_dup_pool(entry, &diff_list->pool, tree_items[0])) >= 0) + error = git_vector_insert(&diff_list->staged, entry); + + return error; +} + +int git_merge_diff_list__find_differences( + git_merge_diff_list *diff_list, + const git_tree *ancestor_tree, + const git_tree *our_tree, + const git_tree *their_tree) +{ + git_iterator *iterators[3] = {0}; + const git_index_entry *items[3] = {0}, *best_cur_item, *cur_items[3]; + git_vector_cmp entry_compare = git_index_entry_cmp; + struct merge_diff_df_data df_data = {0}; + int cur_item_modified; + size_t i, j; + int error = 0; + + assert(diff_list && (our_tree || their_tree)); + + if ((error = git_iterator_for_tree(&iterators[TREE_IDX_ANCESTOR], (git_tree *)ancestor_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || + (error = git_iterator_for_tree(&iterators[TREE_IDX_OURS], (git_tree *)our_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || + (error = git_iterator_for_tree(&iterators[TREE_IDX_THEIRS], (git_tree *)their_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0) + goto done; + + /* Set up the iterators */ + for (i = 0; i < 3; i++) { + error = git_iterator_current(&items[i], iterators[i]); + + if (error < 0 && error != GIT_ITEROVER) + goto done; + } + + while (true) { + for (i = 0; i < 3; i++) + cur_items[i] = NULL; + + best_cur_item = NULL; + cur_item_modified = 0; + + /* Find the next path(s) to consume from each iterator */ + for (i = 0; i < 3; i++) { + if (items[i] == NULL) { + cur_item_modified = 1; + continue; + } + + if (best_cur_item == NULL) { + best_cur_item = items[i]; + cur_items[i] = items[i]; + } else { + int path_diff = entry_compare(items[i], best_cur_item); + + if (path_diff < 0) { + /* + * Found an item that sorts before our current item, make + * our current item this one. + */ + for (j = 0; j < i; j++) + cur_items[j] = NULL; + + cur_item_modified = 1; + best_cur_item = items[i]; + cur_items[i] = items[i]; + } else if (path_diff > 0) { + /* No entry for the current item, this is modified */ + cur_item_modified = 1; + } else if (path_diff == 0) { + cur_items[i] = items[i]; + + if (!cur_item_modified) + cur_item_modified = index_entry_cmp(best_cur_item, items[i]); + } + } + } + + if (best_cur_item == NULL) + break; + + if (cur_item_modified) + error = merge_diff_list_insert_conflict(diff_list, &df_data, cur_items); + else + error = merge_diff_list_insert_unmodified(diff_list, cur_items); + if (error < 0) + goto done; + + /* Advance each iterator that participated */ + for (i = 0; i < 3; i++) { + if (cur_items[i] == NULL) + continue; + + error = git_iterator_advance(&items[i], iterators[i]); + + if (error < 0 && error != GIT_ITEROVER) + goto done; + } + } + +done: + for (i = 0; i < 3; i++) + git_iterator_free(iterators[i]); + + if (error == GIT_ITEROVER) + error = 0; + + return error; +} + +git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo) +{ + git_merge_diff_list *diff_list = git__calloc(1, sizeof(git_merge_diff_list)); + + if (diff_list == NULL) + return NULL; + + diff_list->repo = repo; + + if (git_vector_init(&diff_list->staged, 0, NULL) < 0 || + git_vector_init(&diff_list->conflicts, 0, NULL) < 0 || + git_vector_init(&diff_list->resolved, 0, NULL) < 0 || + git_pool_init(&diff_list->pool, 1, 0) < 0) { + git_merge_diff_list__free(diff_list); + return NULL; + } + + return diff_list; +} + +void git_merge_diff_list__free(git_merge_diff_list *diff_list) +{ + if (!diff_list) + return; + + git_vector_free(&diff_list->staged); + git_vector_free(&diff_list->conflicts); + git_vector_free(&diff_list->resolved); + git_pool_clear(&diff_list->pool); + git__free(diff_list); +} + +static int merge_normalize_opts( + git_repository *repo, + git_merge_options *opts, + const git_merge_options *given) +{ + git_config *cfg = NULL; + int error = 0; + + assert(repo && opts); + + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) + return error; + + if (given != NULL) + memcpy(opts, given, sizeof(git_merge_options)); + else { + git_merge_options init = GIT_MERGE_OPTIONS_INIT; + memcpy(opts, &init, sizeof(init)); + + opts->tree_flags = GIT_MERGE_TREE_FIND_RENAMES; + opts->rename_threshold = GIT_MERGE_TREE_RENAME_THRESHOLD; + } + + if (!opts->target_limit) { + int limit = git_config__get_int_force(cfg, "merge.renamelimit", 0); + + if (!limit) + limit = git_config__get_int_force(cfg, "diff.renamelimit", 0); + + opts->target_limit = (limit <= 0) ? + GIT_MERGE_TREE_TARGET_LIMIT : (unsigned int)limit; + } + + /* assign the internal metric with whitespace flag as payload */ + if (!opts->metric) { + opts->metric = git__malloc(sizeof(git_diff_similarity_metric)); + GITERR_CHECK_ALLOC(opts->metric); + + opts->metric->file_signature = git_diff_find_similar__hashsig_for_file; + opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf; + opts->metric->free_signature = git_diff_find_similar__hashsig_free; + opts->metric->similarity = git_diff_find_similar__calc_similarity; + opts->metric->payload = (void *)GIT_HASHSIG_SMART_WHITESPACE; + } + + return 0; +} + + +static int merge_index_insert_reuc( + git_index *index, + size_t idx, + const git_index_entry *entry) +{ + const git_index_reuc_entry *reuc; + int mode[3] = { 0, 0, 0 }; + git_oid const *oid[3] = { NULL, NULL, NULL }; + size_t i; + + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(*entry)) + return 0; + + if ((reuc = git_index_reuc_get_bypath(index, entry->path)) != NULL) { + for (i = 0; i < 3; i++) { + mode[i] = reuc->mode[i]; + oid[i] = &reuc->oid[i]; + } + } + + mode[idx] = entry->mode; + oid[idx] = &entry->id; + + return git_index_reuc_add(index, entry->path, + mode[0], oid[0], mode[1], oid[1], mode[2], oid[2]); +} + +int index_from_diff_list(git_index **out, git_merge_diff_list *diff_list) +{ + git_index *index; + size_t i; + git_index_entry *entry; + git_merge_diff *conflict; + int error = 0; + + *out = NULL; + + if ((error = git_index_new(&index)) < 0) + return error; + + git_vector_foreach(&diff_list->staged, i, entry) { + if ((error = git_index_add(index, entry)) < 0) + goto on_error; + } + + git_vector_foreach(&diff_list->conflicts, i, conflict) { + const git_index_entry *ancestor = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? + &conflict->ancestor_entry : NULL; + + const git_index_entry *ours = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? + &conflict->our_entry : NULL; + + const git_index_entry *theirs = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? + &conflict->their_entry : NULL; + + if ((error = git_index_conflict_add(index, ancestor, ours, theirs)) < 0) + goto on_error; + } + + /* Add each rename entry to the rename portion of the index. */ + git_vector_foreach(&diff_list->conflicts, i, conflict) { + const char *ancestor_path, *our_path, *their_path; + + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry)) + continue; + + ancestor_path = conflict->ancestor_entry.path; + + our_path = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? + conflict->our_entry.path : NULL; + + their_path = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? + conflict->their_entry.path : NULL; + + if ((our_path && strcmp(ancestor_path, our_path) != 0) || + (their_path && strcmp(ancestor_path, their_path) != 0)) { + if ((error = git_index_name_add(index, ancestor_path, our_path, their_path)) < 0) + goto on_error; + } + } + + /* Add each entry in the resolved conflict to the REUC independently, since + * the paths may differ due to renames. */ + git_vector_foreach(&diff_list->resolved, i, conflict) { + const git_index_entry *ancestor = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? + &conflict->ancestor_entry : NULL; + + const git_index_entry *ours = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? + &conflict->our_entry : NULL; + + const git_index_entry *theirs = + GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? + &conflict->their_entry : NULL; + + if (ancestor != NULL && + (error = merge_index_insert_reuc(index, TREE_IDX_ANCESTOR, ancestor)) < 0) + goto on_error; + + if (ours != NULL && + (error = merge_index_insert_reuc(index, TREE_IDX_OURS, ours)) < 0) + goto on_error; + + if (theirs != NULL && + (error = merge_index_insert_reuc(index, TREE_IDX_THEIRS, theirs)) < 0) + goto on_error; + } + + *out = index; + return 0; + +on_error: + git_index_free(index); + + return error; +} + +int git_merge_trees( + git_index **out, + git_repository *repo, + const git_tree *ancestor_tree, + const git_tree *our_tree, + const git_tree *their_tree, + const git_merge_options *given_opts) +{ + git_merge_diff_list *diff_list; + git_merge_options opts; + git_merge_diff *conflict; + git_vector changes; + size_t i; + int error = 0; + + assert(out && repo && (our_tree || their_tree)); + + *out = NULL; + + GITERR_CHECK_VERSION(given_opts, GIT_MERGE_OPTIONS_VERSION, "git_merge_options"); + + if ((error = merge_normalize_opts(repo, &opts, given_opts)) < 0) + return error; + + diff_list = git_merge_diff_list__alloc(repo); + GITERR_CHECK_ALLOC(diff_list); + + if ((error = git_merge_diff_list__find_differences(diff_list, ancestor_tree, our_tree, their_tree)) < 0 || + (error = git_merge_diff_list__find_renames(repo, diff_list, &opts)) < 0) + goto done; + + memcpy(&changes, &diff_list->conflicts, sizeof(git_vector)); + git_vector_clear(&diff_list->conflicts); + + git_vector_foreach(&changes, i, conflict) { + int resolved = 0; + + if ((error = merge_conflict_resolve(&resolved, diff_list, conflict, opts.file_favor, opts.file_flags)) < 0) + goto done; + + if (!resolved) + git_vector_insert(&diff_list->conflicts, conflict); + } + + if (!given_opts || !given_opts->metric) + git__free(opts.metric); + + error = index_from_diff_list(out, diff_list); + +done: + git_merge_diff_list__free(diff_list); + + return error; +} + +int git_merge_commits( + git_index **out, + git_repository *repo, + const git_commit *our_commit, + const git_commit *their_commit, + const git_merge_options *opts) +{ + git_oid ancestor_oid; + git_commit *ancestor_commit = NULL; + git_tree *our_tree = NULL, *their_tree = NULL, *ancestor_tree = NULL; + int error = 0; + + if ((error = git_merge_base(&ancestor_oid, repo, git_commit_id(our_commit), git_commit_id(their_commit))) < 0 && + error == GIT_ENOTFOUND) + giterr_clear(); + else if (error < 0 || + (error = git_commit_lookup(&ancestor_commit, repo, &ancestor_oid)) < 0 || + (error = git_commit_tree(&ancestor_tree, ancestor_commit)) < 0) + goto done; + + if ((error = git_commit_tree(&our_tree, our_commit)) < 0 || + (error = git_commit_tree(&their_tree, their_commit)) < 0 || + (error = git_merge_trees(out, repo, ancestor_tree, our_tree, their_tree, opts)) < 0) + goto done; + +done: + git_commit_free(ancestor_commit); + git_tree_free(our_tree); + git_tree_free(their_tree); + git_tree_free(ancestor_tree); + + return error; +} + +/* Merge setup / cleanup */ + +static int write_merge_head( + git_repository *repo, + const git_annotated_commit *heads[], + size_t heads_len) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + size_t i; + int error = 0; + + assert(repo && heads); + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_HEAD_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) + goto cleanup; + + for (i = 0; i < heads_len; i++) { + if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->id_str)) < 0) + goto cleanup; + } + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int write_merge_mode(git_repository *repo) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + assert(repo); + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MODE_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) + goto cleanup; + + if ((error = git_filebuf_write(&file, "no-ff", 5)) < 0) + goto cleanup; + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +struct merge_msg_entry { + const git_annotated_commit *merge_head; + bool written; +}; + +static int msg_entry_is_branch( + const struct merge_msg_entry *entry, + git_vector *entries) +{ + GIT_UNUSED(entries); + + return (entry->written == 0 && + entry->merge_head->remote_url == NULL && + entry->merge_head->ref_name != NULL && + git__strncmp(GIT_REFS_HEADS_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_HEADS_DIR)) == 0); +} + +static int msg_entry_is_tracking( + const struct merge_msg_entry *entry, + git_vector *entries) +{ + GIT_UNUSED(entries); + + return (entry->written == 0 && + entry->merge_head->remote_url == NULL && + entry->merge_head->ref_name != NULL && + git__strncmp(GIT_REFS_REMOTES_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_REMOTES_DIR)) == 0); +} + +static int msg_entry_is_tag( + const struct merge_msg_entry *entry, + git_vector *entries) +{ + GIT_UNUSED(entries); + + return (entry->written == 0 && + entry->merge_head->remote_url == NULL && + entry->merge_head->ref_name != NULL && + git__strncmp(GIT_REFS_TAGS_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_TAGS_DIR)) == 0); +} + +static int msg_entry_is_remote( + const struct merge_msg_entry *entry, + git_vector *entries) +{ + if (entry->written == 0 && + entry->merge_head->remote_url != NULL && + entry->merge_head->ref_name != NULL && + git__strncmp(GIT_REFS_HEADS_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_HEADS_DIR)) == 0) + { + struct merge_msg_entry *existing; + + /* Match only branches from the same remote */ + if (entries->length == 0) + return 1; + + existing = git_vector_get(entries, 0); + + return (git__strcmp(existing->merge_head->remote_url, + entry->merge_head->remote_url) == 0); + } + + return 0; +} + +static int msg_entry_is_oid( + const struct merge_msg_entry *merge_msg_entry) +{ + return (merge_msg_entry->written == 0 && + merge_msg_entry->merge_head->ref_name == NULL && + merge_msg_entry->merge_head->remote_url == NULL); +} + +static int merge_msg_entry_written( + const struct merge_msg_entry *merge_msg_entry) +{ + return (merge_msg_entry->written == 1); +} + +static int merge_msg_entries( + git_vector *v, + const struct merge_msg_entry *entries, + size_t len, + int (*match)(const struct merge_msg_entry *entry, git_vector *entries)) +{ + size_t i; + int matches, total = 0; + + git_vector_clear(v); + + for (i = 0; i < len; i++) { + if ((matches = match(&entries[i], v)) < 0) + return matches; + else if (!matches) + continue; + + git_vector_insert(v, (struct merge_msg_entry *)&entries[i]); + total++; + } + + return total; +} + +static int merge_msg_write_entries( + git_filebuf *file, + git_vector *entries, + const char *item_name, + const char *item_plural_name, + size_t ref_name_skip, + const char *source, + char sep) +{ + struct merge_msg_entry *entry; + size_t i; + int error = 0; + + if (entries->length == 0) + return 0; + + if (sep && (error = git_filebuf_printf(file, "%c ", sep)) < 0) + goto done; + + if ((error = git_filebuf_printf(file, "%s ", + (entries->length == 1) ? item_name : item_plural_name)) < 0) + goto done; + + git_vector_foreach(entries, i, entry) { + if (i > 0 && + (error = git_filebuf_printf(file, "%s", (i == entries->length - 1) ? " and " : ", ")) < 0) + goto done; + + if ((error = git_filebuf_printf(file, "'%s'", entry->merge_head->ref_name + ref_name_skip)) < 0) + goto done; + + entry->written = 1; + } + + if (source) + error = git_filebuf_printf(file, " of %s", source); + +done: + return error; +} + +static int merge_msg_write_branches( + git_filebuf *file, + git_vector *entries, + char sep) +{ + return merge_msg_write_entries(file, entries, + "branch", "branches", strlen(GIT_REFS_HEADS_DIR), NULL, sep); +} + +static int merge_msg_write_tracking( + git_filebuf *file, + git_vector *entries, + char sep) +{ + return merge_msg_write_entries(file, entries, + "remote-tracking branch", "remote-tracking branches", 0, NULL, sep); +} + +static int merge_msg_write_tags( + git_filebuf *file, + git_vector *entries, + char sep) +{ + return merge_msg_write_entries(file, entries, + "tag", "tags", strlen(GIT_REFS_TAGS_DIR), NULL, sep); +} + +static int merge_msg_write_remotes( + git_filebuf *file, + git_vector *entries, + char sep) +{ + const char *source; + + if (entries->length == 0) + return 0; + + source = ((struct merge_msg_entry *)entries->contents[0])->merge_head->remote_url; + + return merge_msg_write_entries(file, entries, + "branch", "branches", strlen(GIT_REFS_HEADS_DIR), source, sep); +} + +static int write_merge_msg( + git_repository *repo, + const git_annotated_commit *heads[], + size_t heads_len) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + struct merge_msg_entry *entries; + git_vector matching = GIT_VECTOR_INIT; + size_t i; + char sep = 0; + int error = 0; + + assert(repo && heads); + + entries = git__calloc(heads_len, sizeof(struct merge_msg_entry)); + GITERR_CHECK_ALLOC(entries); + + if (git_vector_init(&matching, heads_len, NULL) < 0) { + git__free(entries); + return -1; + } + + for (i = 0; i < heads_len; i++) + entries[i].merge_head = heads[i]; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0 || + (error = git_filebuf_write(&file, "Merge ", 6)) < 0) + goto cleanup; + + /* + * This is to emulate the format of MERGE_MSG by core git. + * + * Core git will write all the commits specified by OID, in the order + * provided, until the first named branch or tag is reached, at which + * point all branches will be written in the order provided, then all + * tags, then all remote tracking branches and finally all commits that + * were specified by OID that were not already written. + * + * Yes. Really. + */ + for (i = 0; i < heads_len; i++) { + if (!msg_entry_is_oid(&entries[i])) + break; + + if ((error = git_filebuf_printf(&file, + "%scommit '%s'", (i > 0) ? "; " : "", + entries[i].merge_head->id_str)) < 0) + goto cleanup; + + entries[i].written = 1; + } + + if (i) + sep = ';'; + + if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_branch)) < 0 || + (error = merge_msg_write_branches(&file, &matching, sep)) < 0) + goto cleanup; + + if (matching.length) + sep =','; + + if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tracking)) < 0 || + (error = merge_msg_write_tracking(&file, &matching, sep)) < 0) + goto cleanup; + + if (matching.length) + sep =','; + + if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tag)) < 0 || + (error = merge_msg_write_tags(&file, &matching, sep)) < 0) + goto cleanup; + + if (matching.length) + sep =','; + + /* We should never be called with multiple remote branches, but handle + * it in case we are... */ + while ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_remote)) > 0) { + if ((error = merge_msg_write_remotes(&file, &matching, sep)) < 0) + goto cleanup; + + if (matching.length) + sep =','; + } + + if (error < 0) + goto cleanup; + + for (i = 0; i < heads_len; i++) { + if (merge_msg_entry_written(&entries[i])) + continue; + + if ((error = git_filebuf_printf(&file, "; commit '%s'", + entries[i].merge_head->id_str)) < 0) + goto cleanup; + } + + if ((error = git_filebuf_printf(&file, "\n")) < 0 || + (error = git_filebuf_commit(&file)) < 0) + goto cleanup; + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + git_vector_free(&matching); + git__free(entries); + + return error; +} + +int git_merge__setup( + git_repository *repo, + const git_annotated_commit *our_head, + const git_annotated_commit *heads[], + size_t heads_len) +{ + int error = 0; + + assert (repo && our_head && heads); + + if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 && + (error = write_merge_head(repo, heads, heads_len)) == 0 && + (error = write_merge_mode(repo)) == 0) { + error = write_merge_msg(repo, heads, heads_len); + } + + return error; +} + +/* Merge branches */ + +static int merge_ancestor_head( + git_annotated_commit **ancestor_head, + git_repository *repo, + const git_annotated_commit *our_head, + const git_annotated_commit **their_heads, + size_t their_heads_len) +{ + git_oid *oids, ancestor_oid; + size_t i, alloc_len; + int error = 0; + + assert(repo && our_head && their_heads); + + GITERR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1); + oids = git__calloc(alloc_len, sizeof(git_oid)); + GITERR_CHECK_ALLOC(oids); + + git_oid_cpy(&oids[0], git_commit_id(our_head->commit)); + + for (i = 0; i < their_heads_len; i++) + git_oid_cpy(&oids[i + 1], git_annotated_commit_id(their_heads[i])); + + if ((error = git_merge_base_many(&ancestor_oid, repo, their_heads_len + 1, oids)) < 0) + goto on_error; + + error = git_annotated_commit_lookup(ancestor_head, repo, &ancestor_oid); + +on_error: + git__free(oids); + return error; +} + +const char *merge_their_label(const char *branchname) +{ + const char *slash; + + if ((slash = strrchr(branchname, '/')) == NULL) + return branchname; + + if (*(slash+1) == '\0') + return "theirs"; + + return slash+1; +} + +static int merge_normalize_checkout_opts( + git_repository *repo, + git_checkout_options *checkout_opts, + const git_checkout_options *given_checkout_opts, + const git_annotated_commit *ancestor_head, + const git_annotated_commit *our_head, + size_t their_heads_len, + const git_annotated_commit **their_heads) +{ + int error = 0; + + GIT_UNUSED(repo); + + if (given_checkout_opts != NULL) + memcpy(checkout_opts, given_checkout_opts, sizeof(git_checkout_options)); + else { + git_checkout_options default_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; + default_checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; + + memcpy(checkout_opts, &default_checkout_opts, sizeof(git_checkout_options)); + } + + /* TODO: for multiple ancestors in merge-recursive, this is "merged common ancestors" */ + if (!checkout_opts->ancestor_label) { + if (ancestor_head && ancestor_head->commit) + checkout_opts->ancestor_label = git_commit_summary(ancestor_head->commit); + else + checkout_opts->ancestor_label = "ancestor"; + } + + if (!checkout_opts->our_label) { + if (our_head && our_head->ref_name) + checkout_opts->our_label = our_head->ref_name; + else + checkout_opts->our_label = "ours"; + } + + if (!checkout_opts->their_label) { + if (their_heads_len == 1 && their_heads[0]->ref_name) + checkout_opts->their_label = merge_their_label(their_heads[0]->ref_name); + else if (their_heads_len == 1) + checkout_opts->their_label = their_heads[0]->id_str; + else + checkout_opts->their_label = "theirs"; + } + + return error; +} + +static int merge_check_index(size_t *conflicts, git_repository *repo, git_index *index_new, git_vector *merged_paths) +{ + git_tree *head_tree = NULL; + git_index *index_repo = NULL; + git_iterator *iter_repo = NULL, *iter_new = NULL; + git_diff *staged_diff_list = NULL, *index_diff_list = NULL; + git_diff_delta *delta; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + git_vector staged_paths = GIT_VECTOR_INIT; + size_t i; + int error = 0; + + GIT_UNUSED(merged_paths); + + *conflicts = 0; + + /* No staged changes may exist unless the change staged is identical to + * the result of the merge. This allows one to apply to merge manually, + * then run merge. Any other staged change would be overwritten by + * a reset merge. + */ + if ((error = git_repository_head_tree(&head_tree, repo)) < 0 || + (error = git_repository_index(&index_repo, repo)) < 0 || + (error = git_diff_tree_to_index(&staged_diff_list, repo, head_tree, index_repo, &opts)) < 0) + goto done; + + if (staged_diff_list->deltas.length == 0) + goto done; + + git_vector_foreach(&staged_diff_list->deltas, i, delta) { + if ((error = git_vector_insert(&staged_paths, (char *)delta->new_file.path)) < 0) + goto done; + } + + opts.pathspec.count = staged_paths.length; + opts.pathspec.strings = (char **)staged_paths.contents; + + if ((error = git_iterator_for_index(&iter_repo, index_repo, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || + (error = git_iterator_for_index(&iter_new, index_new, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || + (error = git_diff__from_iterators(&index_diff_list, repo, iter_repo, iter_new, &opts)) < 0) + goto done; + + *conflicts = index_diff_list->deltas.length; + +done: + git_tree_free(head_tree); + git_index_free(index_repo); + git_iterator_free(iter_repo); + git_iterator_free(iter_new); + git_diff_free(staged_diff_list); + git_diff_free(index_diff_list); + git_vector_free(&staged_paths); + + return error; +} + +static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_index *index_new, git_vector *merged_paths) +{ + git_diff *wd_diff_list = NULL; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + int error = 0; + + GIT_UNUSED(index_new); + + *conflicts = 0; + + /* We need to have merged at least 1 file for the possibility to exist to + * have conflicts with the workdir. Passing 0 as the pathspec count paramter + * will consider all files in the working directory, that is, we may detect + * a conflict if there were untracked files in the workdir prior to starting + * the merge. This typically happens when cherry-picking a commmit whose + * changes have already been applied. + */ + if (merged_paths->length == 0) + return 0; + + opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED; + + /* Workdir changes may exist iff they do not conflict with changes that + * will be applied by the merge (including conflicts). Ensure that there + * are no changes in the workdir to these paths. + */ + opts.pathspec.count = merged_paths->length; + opts.pathspec.strings = (char **)merged_paths->contents; + + if ((error = git_diff_index_to_workdir(&wd_diff_list, repo, NULL, &opts)) < 0) + goto done; + + *conflicts = wd_diff_list->deltas.length; + +done: + git_diff_free(wd_diff_list); + + return error; +} + +int git_merge__check_result(git_repository *repo, git_index *index_new) +{ + git_tree *head_tree = NULL; + git_iterator *iter_head = NULL, *iter_new = NULL; + git_diff *merged_list = NULL; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + git_diff_delta *delta; + git_vector paths = GIT_VECTOR_INIT; + size_t i, index_conflicts = 0, wd_conflicts = 0, conflicts; + const git_index_entry *e; + int error = 0; + + if ((error = git_repository_head_tree(&head_tree, repo)) < 0 || + (error = git_iterator_for_tree(&iter_head, head_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || + (error = git_iterator_for_index(&iter_new, index_new, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || + (error = git_diff__from_iterators(&merged_list, repo, iter_head, iter_new, &opts)) < 0) + goto done; + + git_vector_foreach(&merged_list->deltas, i, delta) { + if ((error = git_vector_insert(&paths, (char *)delta->new_file.path)) < 0) + goto done; + } + + for (i = 0; i < git_index_entrycount(index_new); i++) { + e = git_index_get_byindex(index_new, i); + + if (git_index_entry_stage(e) != 0 && + (git_vector_last(&paths) == NULL || + strcmp(git_vector_last(&paths), e->path) != 0)) { + + if ((error = git_vector_insert(&paths, (char *)e->path)) < 0) + goto done; + } + } + + /* Make sure the index and workdir state do not prevent merging */ + if ((error = merge_check_index(&index_conflicts, repo, index_new, &paths)) < 0 || + (error = merge_check_workdir(&wd_conflicts, repo, index_new, &paths)) < 0) + goto done; + + if ((conflicts = index_conflicts + wd_conflicts) > 0) { + giterr_set(GITERR_MERGE, "%d uncommitted change%s would be overwritten by merge", + conflicts, (conflicts != 1) ? "s" : ""); + error = GIT_EMERGECONFLICT; + } + +done: + git_vector_free(&paths); + git_tree_free(head_tree); + git_iterator_free(iter_head); + git_iterator_free(iter_new); + git_diff_free(merged_list); + + return error; +} + +int git_merge__append_conflicts_to_merge_msg( + git_repository *repo, + git_index *index) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + const char *last = NULL; + size_t i; + int error; + + if (!git_index_has_conflicts(index)) + return 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_APPEND, GIT_MERGE_FILE_MODE)) < 0) + goto cleanup; + + git_filebuf_printf(&file, "\nConflicts:\n"); + + for (i = 0; i < git_index_entrycount(index); i++) { + const git_index_entry *e = git_index_get_byindex(index, i); + + if (git_index_entry_stage(e) == 0) + continue; + + if (last == NULL || strcmp(e->path, last) != 0) + git_filebuf_printf(&file, "\t%s\n", e->path); + + last = e->path; + } + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int merge_state_cleanup(git_repository *repo) +{ + const char *state_files[] = { + GIT_MERGE_HEAD_FILE, + GIT_MERGE_MODE_FILE, + GIT_MERGE_MSG_FILE, + }; + + return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); +} + +static int merge_heads( + git_annotated_commit **ancestor_head_out, + git_annotated_commit **our_head_out, + git_repository *repo, + const git_annotated_commit **their_heads, + size_t their_heads_len) +{ + git_annotated_commit *ancestor_head = NULL, *our_head = NULL; + git_reference *our_ref = NULL; + int error = 0; + + *ancestor_head_out = NULL; + *our_head_out = NULL; + + if ((error = git_repository__ensure_not_bare(repo, "merge")) < 0) + goto done; + + if ((error = git_reference_lookup(&our_ref, repo, GIT_HEAD_FILE)) < 0 || + (error = git_annotated_commit_from_ref(&our_head, repo, our_ref)) < 0) + goto done; + + if ((error = merge_ancestor_head(&ancestor_head, repo, our_head, their_heads, their_heads_len)) < 0) { + if (error != GIT_ENOTFOUND) + goto done; + + giterr_clear(); + error = 0; + } + + *ancestor_head_out = ancestor_head; + *our_head_out = our_head; + +done: + if (error < 0) { + git_annotated_commit_free(ancestor_head); + git_annotated_commit_free(our_head); + } + + git_reference_free(our_ref); + + return error; +} + +static int merge_preference(git_merge_preference_t *out, git_repository *repo) +{ + git_config *config; + const char *value; + int bool_value, error = 0; + + *out = GIT_MERGE_PREFERENCE_NONE; + + if ((error = git_repository_config_snapshot(&config, repo)) < 0) + goto done; + + if ((error = git_config_get_string(&value, config, "merge.ff")) < 0) { + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + + goto done; + } + + if (git_config_parse_bool(&bool_value, value) == 0) { + if (!bool_value) + *out |= GIT_MERGE_PREFERENCE_NO_FASTFORWARD; + } else { + if (strcasecmp(value, "only") == 0) + *out |= GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY; + } + +done: + git_config_free(config); + return error; +} + +int git_merge_analysis( + git_merge_analysis_t *analysis_out, + git_merge_preference_t *preference_out, + git_repository *repo, + const git_annotated_commit **their_heads, + size_t their_heads_len) +{ + git_annotated_commit *ancestor_head = NULL, *our_head = NULL; + int error = 0; + + assert(analysis_out && preference_out && repo && their_heads); + + if (their_heads_len != 1) { + giterr_set(GITERR_MERGE, "Can only merge a single branch"); + error = -1; + goto done; + } + + *analysis_out = GIT_MERGE_ANALYSIS_NONE; + + if ((error = merge_preference(preference_out, repo)) < 0) + goto done; + + if (git_repository_head_unborn(repo)) { + *analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_UNBORN; + goto done; + } + + if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0) + goto done; + + /* We're up-to-date if we're trying to merge our own common ancestor. */ + if (ancestor_head && git_oid_equal( + git_annotated_commit_id(ancestor_head), git_annotated_commit_id(their_heads[0]))) + *analysis_out |= GIT_MERGE_ANALYSIS_UP_TO_DATE; + + /* We're fastforwardable if we're our own common ancestor. */ + else if (ancestor_head && git_oid_equal( + git_annotated_commit_id(ancestor_head), git_annotated_commit_id(our_head))) + *analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL; + + /* Otherwise, just a normal merge is possible. */ + else + *analysis_out |= GIT_MERGE_ANALYSIS_NORMAL; + +done: + git_annotated_commit_free(ancestor_head); + git_annotated_commit_free(our_head); + return error; +} + +int git_merge( + git_repository *repo, + const git_annotated_commit **their_heads, + size_t their_heads_len, + const git_merge_options *merge_opts, + const git_checkout_options *given_checkout_opts) +{ + git_reference *our_ref = NULL; + git_checkout_options checkout_opts; + git_annotated_commit *ancestor_head = NULL, *our_head = NULL; + git_tree *ancestor_tree = NULL, *our_tree = NULL, **their_trees = NULL; + git_index *index = NULL; + git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; + size_t i; + int error = 0; + + assert(repo && their_heads); + + if (their_heads_len != 1) { + giterr_set(GITERR_MERGE, "Can only merge a single branch"); + return -1; + } + + their_trees = git__calloc(their_heads_len, sizeof(git_tree *)); + GITERR_CHECK_ALLOC(their_trees); + + if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0 || + (error = merge_normalize_checkout_opts(repo, &checkout_opts, given_checkout_opts, + ancestor_head, our_head, their_heads_len, their_heads)) < 0 || + (error = git_indexwriter_init_for_operation(&indexwriter, repo, &checkout_opts.checkout_strategy)) < 0) + goto on_error; + + /* Write the merge files to the repository. */ + if ((error = git_merge__setup(repo, our_head, their_heads, their_heads_len)) < 0) + goto on_error; + + if (ancestor_head != NULL && + (error = git_commit_tree(&ancestor_tree, ancestor_head->commit)) < 0) + goto on_error; + + if ((error = git_commit_tree(&our_tree, our_head->commit)) < 0) + goto on_error; + + for (i = 0; i < their_heads_len; i++) { + if ((error = git_commit_tree(&their_trees[i], their_heads[i]->commit)) < 0) + goto on_error; + } + + /* TODO: recursive, octopus, etc... */ + + if ((error = git_merge_trees(&index, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 || + (error = git_merge__check_result(repo, index)) < 0 || + (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 || + (error = git_checkout_index(repo, index, &checkout_opts)) < 0 || + (error = git_indexwriter_commit(&indexwriter)) < 0) + goto on_error; + + goto done; + +on_error: + merge_state_cleanup(repo); + +done: + git_indexwriter_cleanup(&indexwriter); + + git_index_free(index); + + git_tree_free(ancestor_tree); + git_tree_free(our_tree); + + for (i = 0; i < their_heads_len; i++) + git_tree_free(their_trees[i]); + + git__free(their_trees); + + git_annotated_commit_free(our_head); + git_annotated_commit_free(ancestor_head); + + git_reference_free(our_ref); + + return error; +} + +int git_merge_init_options(git_merge_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_merge_options, GIT_MERGE_OPTIONS_INIT); + return 0; +} + +int git_merge_file_init_input(git_merge_file_input *input, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + input, version, git_merge_file_input, GIT_MERGE_FILE_INPUT_INIT); + return 0; +} + +int git_merge_file_init_options( + git_merge_file_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_merge_file_options, GIT_MERGE_FILE_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/merge.h b/deps/libgit2-sys-0.2.17/libgit2/src/merge.h new file mode 100644 index 000000000..fe4505f8b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/merge.h @@ -0,0 +1,145 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_merge_h__ +#define INCLUDE_merge_h__ + +#include "vector.h" +#include "commit_list.h" +#include "pool.h" + +#include "git2/merge.h" +#include "git2/types.h" + +#define GIT_MERGE_MSG_FILE "MERGE_MSG" +#define GIT_MERGE_MODE_FILE "MERGE_MODE" +#define GIT_MERGE_FILE_MODE 0666 + +#define GIT_MERGE_TREE_RENAME_THRESHOLD 50 +#define GIT_MERGE_TREE_TARGET_LIMIT 1000 + +/** Types of changes when files are merged from branch to branch. */ +typedef enum { + /* No conflict - a change only occurs in one branch. */ + GIT_MERGE_DIFF_NONE = 0, + + /* Occurs when a file is modified in both branches. */ + GIT_MERGE_DIFF_BOTH_MODIFIED = (1 << 0), + + /* Occurs when a file is added in both branches. */ + GIT_MERGE_DIFF_BOTH_ADDED = (1 << 1), + + /* Occurs when a file is deleted in both branches. */ + GIT_MERGE_DIFF_BOTH_DELETED = (1 << 2), + + /* Occurs when a file is modified in one branch and deleted in the other. */ + GIT_MERGE_DIFF_MODIFIED_DELETED = (1 << 3), + + /* Occurs when a file is renamed in one branch and modified in the other. */ + GIT_MERGE_DIFF_RENAMED_MODIFIED = (1 << 4), + + /* Occurs when a file is renamed in one branch and deleted in the other. */ + GIT_MERGE_DIFF_RENAMED_DELETED = (1 << 5), + + /* Occurs when a file is renamed in one branch and a file with the same + * name is added in the other. Eg, A->B and new file B. Core git calls + * this a "rename/delete". */ + GIT_MERGE_DIFF_RENAMED_ADDED = (1 << 6), + + /* Occurs when both a file is renamed to the same name in the ours and + * theirs branches. Eg, A->B and A->B in both. Automergeable. */ + GIT_MERGE_DIFF_BOTH_RENAMED = (1 << 7), + + /* Occurs when a file is renamed to different names in the ours and theirs + * branches. Eg, A->B and A->C. */ + GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 = (1 << 8), + + /* Occurs when two files are renamed to the same name in the ours and + * theirs branches. Eg, A->C and B->C. */ + GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 = (1 << 9), + + /* Occurs when an item at a path in one branch is a directory, and an + * item at the same path in a different branch is a file. */ + GIT_MERGE_DIFF_DIRECTORY_FILE = (1 << 10), + + /* The child of a folder that is in a directory/file conflict. */ + GIT_MERGE_DIFF_DF_CHILD = (1 << 11), +} git_merge_diff_type_t; + + +typedef struct { + git_repository *repo; + git_pool pool; + + /* Vector of git_index_entry that represent the merged items that + * have been staged, either because only one side changed, or because + * the two changes were non-conflicting and mergeable. These items + * will be written as staged entries in the main index. + */ + git_vector staged; + + /* Vector of git_merge_diff entries that represent the conflicts that + * have not been automerged. These items will be written to high-stage + * entries in the main index. + */ + git_vector conflicts; + + /* Vector of git_merge_diff that have been automerged. These items + * will be written to the REUC when the index is produced. + */ + git_vector resolved; +} git_merge_diff_list; + +/** + * Description of changes to one file across three trees. + */ +typedef struct { + git_merge_diff_type_t type; + + git_index_entry ancestor_entry; + + git_index_entry our_entry; + git_delta_t our_status; + + git_index_entry their_entry; + git_delta_t their_status; + +} git_merge_diff; + +int git_merge__bases_many( + git_commit_list **out, + git_revwalk *walk, + git_commit_list_node *one, + git_vector *twos); + +/* + * Three-way tree differencing + */ + +git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo); + +int git_merge_diff_list__find_differences(git_merge_diff_list *merge_diff_list, + const git_tree *ancestor_tree, + const git_tree *ours_tree, + const git_tree *theirs_tree); + +int git_merge_diff_list__find_renames(git_repository *repo, git_merge_diff_list *merge_diff_list, const git_merge_options *opts); + +void git_merge_diff_list__free(git_merge_diff_list *diff_list); + +/* Merge metadata setup */ + +int git_merge__setup( + git_repository *repo, + const git_annotated_commit *our_head, + const git_annotated_commit *heads[], + size_t heads_len); + +int git_merge__check_result(git_repository *repo, git_index *index_new); + +int git_merge__append_conflicts_to_merge_msg(git_repository *repo, git_index *index); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/merge_file.c b/deps/libgit2-sys-0.2.17/libgit2/src/merge_file.c new file mode 100644 index 000000000..6d89b089d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/merge_file.c @@ -0,0 +1,292 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "repository.h" +#include "merge_file.h" +#include "posix.h" +#include "fileops.h" +#include "index.h" + +#include "git2/repository.h" +#include "git2/object.h" +#include "git2/index.h" + +#include "xdiff/xdiff.h" + +#define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0) + +GIT_INLINE(const char *) merge_file_best_path( + const git_merge_file_input *ancestor, + const git_merge_file_input *ours, + const git_merge_file_input *theirs) +{ + if (!ancestor) { + if (ours && theirs && strcmp(ours->path, theirs->path) == 0) + return ours->path; + + return NULL; + } + + if (ours && strcmp(ancestor->path, ours->path) == 0) + return theirs ? theirs->path : NULL; + else if(theirs && strcmp(ancestor->path, theirs->path) == 0) + return ours ? ours->path : NULL; + + return NULL; +} + +GIT_INLINE(int) merge_file_best_mode( + const git_merge_file_input *ancestor, + const git_merge_file_input *ours, + const git_merge_file_input *theirs) +{ + /* + * If ancestor didn't exist and either ours or theirs is executable, + * assume executable. Otherwise, if any mode changed from the ancestor, + * use that one. + */ + if (!ancestor) { + if ((ours && ours->mode == GIT_FILEMODE_BLOB_EXECUTABLE) || + (theirs && theirs->mode == GIT_FILEMODE_BLOB_EXECUTABLE)) + return GIT_FILEMODE_BLOB_EXECUTABLE; + + return GIT_FILEMODE_BLOB; + } else if (ours && theirs) { + if (ancestor->mode == ours->mode) + return theirs->mode; + + return ours->mode; + } + + return 0; +} + +int git_merge_file__input_from_index( + git_merge_file_input *input_out, + git_odb_object **odb_object_out, + git_odb *odb, + const git_index_entry *entry) +{ + int error = 0; + + assert(input_out && odb_object_out && odb && entry); + + if ((error = git_odb_read(odb_object_out, odb, &entry->id)) < 0) + goto done; + + input_out->path = entry->path; + input_out->mode = entry->mode; + input_out->ptr = (char *)git_odb_object_data(*odb_object_out); + input_out->size = git_odb_object_size(*odb_object_out); + +done: + return error; +} + +static void merge_file_normalize_opts( + git_merge_file_options *out, + const git_merge_file_options *given_opts) +{ + if (given_opts) + memcpy(out, given_opts, sizeof(git_merge_file_options)); + else { + git_merge_file_options default_opts = GIT_MERGE_FILE_OPTIONS_INIT; + memcpy(out, &default_opts, sizeof(git_merge_file_options)); + } +} + +static int git_merge_file__from_inputs( + git_merge_file_result *out, + const git_merge_file_input *ancestor, + const git_merge_file_input *ours, + const git_merge_file_input *theirs, + const git_merge_file_options *given_opts) +{ + xmparam_t xmparam; + mmfile_t ancestor_mmfile = {0}, our_mmfile = {0}, their_mmfile = {0}; + mmbuffer_t mmbuffer; + git_merge_file_options options = GIT_MERGE_FILE_OPTIONS_INIT; + const char *path; + int xdl_result; + int error = 0; + + memset(out, 0x0, sizeof(git_merge_file_result)); + + merge_file_normalize_opts(&options, given_opts); + + memset(&xmparam, 0x0, sizeof(xmparam_t)); + + if (ancestor) { + xmparam.ancestor = (options.ancestor_label) ? + options.ancestor_label : ancestor->path; + ancestor_mmfile.ptr = (char *)ancestor->ptr; + ancestor_mmfile.size = ancestor->size; + } + + xmparam.file1 = (options.our_label) ? + options.our_label : ours->path; + our_mmfile.ptr = (char *)ours->ptr; + our_mmfile.size = ours->size; + + xmparam.file2 = (options.their_label) ? + options.their_label : theirs->path; + their_mmfile.ptr = (char *)theirs->ptr; + their_mmfile.size = theirs->size; + + if (options.favor == GIT_MERGE_FILE_FAVOR_OURS) + xmparam.favor = XDL_MERGE_FAVOR_OURS; + else if (options.favor == GIT_MERGE_FILE_FAVOR_THEIRS) + xmparam.favor = XDL_MERGE_FAVOR_THEIRS; + else if (options.favor == GIT_MERGE_FILE_FAVOR_UNION) + xmparam.favor = XDL_MERGE_FAVOR_UNION; + + xmparam.level = (options.flags & GIT_MERGE_FILE_SIMPLIFY_ALNUM) ? + XDL_MERGE_ZEALOUS_ALNUM : XDL_MERGE_ZEALOUS; + + if (options.flags & GIT_MERGE_FILE_STYLE_DIFF3) + xmparam.style = XDL_MERGE_DIFF3; + + if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE) + xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE; + if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE) + xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE_CHANGE; + if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL) + xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE_AT_EOL; + + if (options.flags & GIT_MERGE_FILE_DIFF_PATIENCE) + xmparam.xpp.flags |= XDF_PATIENCE_DIFF; + + if (options.flags & GIT_MERGE_FILE_DIFF_MINIMAL) + xmparam.xpp.flags |= XDF_NEED_MINIMAL; + + if ((xdl_result = xdl_merge(&ancestor_mmfile, &our_mmfile, + &their_mmfile, &xmparam, &mmbuffer)) < 0) { + giterr_set(GITERR_MERGE, "Failed to merge files."); + error = -1; + goto done; + } + + if ((path = merge_file_best_path(ancestor, ours, theirs)) != NULL && + (out->path = strdup(path)) == NULL) { + error = -1; + goto done; + } + + out->automergeable = (xdl_result == 0); + out->ptr = (const char *)mmbuffer.ptr; + out->len = mmbuffer.size; + out->mode = merge_file_best_mode(ancestor, ours, theirs); + +done: + if (error < 0) + git_merge_file_result_free(out); + + return error; +} + +static git_merge_file_input *git_merge_file__normalize_inputs( + git_merge_file_input *out, + const git_merge_file_input *given) +{ + memcpy(out, given, sizeof(git_merge_file_input)); + + if (!out->path) + out->path = "file.txt"; + + if (!out->mode) + out->mode = 0100644; + + return out; +} + +int git_merge_file( + git_merge_file_result *out, + const git_merge_file_input *ancestor, + const git_merge_file_input *ours, + const git_merge_file_input *theirs, + const git_merge_file_options *options) +{ + git_merge_file_input inputs[3] = { {0} }; + + assert(out && ours && theirs); + + memset(out, 0x0, sizeof(git_merge_file_result)); + + if (ancestor) + ancestor = git_merge_file__normalize_inputs(&inputs[0], ancestor); + + ours = git_merge_file__normalize_inputs(&inputs[1], ours); + theirs = git_merge_file__normalize_inputs(&inputs[2], theirs); + + return git_merge_file__from_inputs(out, ancestor, ours, theirs, options); +} + +int git_merge_file_from_index( + git_merge_file_result *out, + git_repository *repo, + const git_index_entry *ancestor, + const git_index_entry *ours, + const git_index_entry *theirs, + const git_merge_file_options *options) +{ + git_merge_file_input inputs[3] = { {0} }, + *ancestor_input = NULL, *our_input = NULL, *their_input = NULL; + git_odb *odb = NULL; + git_odb_object *odb_object[3] = { 0 }; + int error = 0; + + assert(out && repo && ours && theirs); + + memset(out, 0x0, sizeof(git_merge_file_result)); + + if ((error = git_repository_odb(&odb, repo)) < 0) + goto done; + + if (ancestor) { + if ((error = git_merge_file__input_from_index( + &inputs[0], &odb_object[0], odb, ancestor)) < 0) + goto done; + + ancestor_input = &inputs[0]; + } + + if ((error = git_merge_file__input_from_index( + &inputs[1], &odb_object[1], odb, ours)) < 0) + goto done; + + our_input = &inputs[1]; + + if ((error = git_merge_file__input_from_index( + &inputs[2], &odb_object[2], odb, theirs)) < 0) + goto done; + + their_input = &inputs[2]; + + if ((error = git_merge_file__from_inputs(out, + ancestor_input, our_input, their_input, options)) < 0) + goto done; + +done: + git_odb_object_free(odb_object[0]); + git_odb_object_free(odb_object[1]); + git_odb_object_free(odb_object[2]); + git_odb_free(odb); + + return error; +} + +void git_merge_file_result_free(git_merge_file_result *result) +{ + if (result == NULL) + return; + + git__free((char *)result->path); + + /* xdiff uses malloc() not git_malloc, so we use free(), not git_free() */ + free((char *)result->ptr); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/merge_file.h b/deps/libgit2-sys-0.2.17/libgit2/src/merge_file.h new file mode 100644 index 000000000..263391ee3 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/merge_file.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_filediff_h__ +#define INCLUDE_filediff_h__ + +#include "xdiff/xdiff.h" + +#include "git2/merge.h" + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/message.c b/deps/libgit2-sys-0.2.17/libgit2/src/message.c new file mode 100644 index 000000000..6c5a2379f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/message.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "message.h" + +static size_t line_length_without_trailing_spaces(const char *line, size_t len) +{ + while (len) { + unsigned char c = line[len - 1]; + if (!git__isspace(c)) + break; + len--; + } + + return len; +} + +/* Greatly inspired from git.git "stripspace" */ +/* see https://github.com/git/git/blob/497215d8811ac7b8955693ceaad0899ecd894ed2/builtin/stripspace.c#L4-67 */ +int git_message_prettify(git_buf *message_out, const char *message, int strip_comments, char comment_char) +{ + const size_t message_len = strlen(message); + + int consecutive_empty_lines = 0; + size_t i, line_length, rtrimmed_line_length; + char *next_newline; + + git_buf_sanitize(message_out); + + for (i = 0; i < strlen(message); i += line_length) { + next_newline = memchr(message + i, '\n', message_len - i); + + if (next_newline != NULL) { + line_length = next_newline - (message + i) + 1; + } else { + line_length = message_len - i; + } + + if (strip_comments && line_length && message[i] == comment_char) + continue; + + rtrimmed_line_length = line_length_without_trailing_spaces(message + i, line_length); + + if (!rtrimmed_line_length) { + consecutive_empty_lines++; + continue; + } + + if (consecutive_empty_lines > 0 && message_out->size > 0) + git_buf_putc(message_out, '\n'); + + consecutive_empty_lines = 0; + git_buf_put(message_out, message + i, rtrimmed_line_length); + git_buf_putc(message_out, '\n'); + } + + return git_buf_oom(message_out) ? -1 : 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/message.h b/deps/libgit2-sys-0.2.17/libgit2/src/message.h new file mode 100644 index 000000000..3c4b8dc45 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/message.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_message_h__ +#define INCLUDE_message_h__ + +#include "git2/message.h" +#include "buffer.h" + +int git_message__prettify(git_buf *message_out, const char *message, int strip_comments); + +#endif /* INCLUDE_message_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/mwindow.c b/deps/libgit2-sys-0.2.17/libgit2/src/mwindow.c new file mode 100644 index 000000000..55c8d894b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/mwindow.c @@ -0,0 +1,430 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "mwindow.h" +#include "vector.h" +#include "fileops.h" +#include "map.h" +#include "global.h" +#include "strmap.h" +#include "pack.h" + +GIT__USE_STRMAP + +#define DEFAULT_WINDOW_SIZE \ + (sizeof(void*) >= 8 \ + ? 1 * 1024 * 1024 * 1024 \ + : 32 * 1024 * 1024) + +#define DEFAULT_MAPPED_LIMIT \ + ((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL)) + +size_t git_mwindow__window_size = DEFAULT_WINDOW_SIZE; +size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT; + +/* Whenever you want to read or modify this, grab git__mwindow_mutex */ +static git_mwindow_ctl mem_ctl; + +/* Global list of mwindow files, to open packs once across repos */ +git_strmap *git__pack_cache = NULL; + +/** + * Run under mwindow lock + */ +int git_mwindow_files_init(void) +{ + if (git__pack_cache) + return 0; + + git__on_shutdown(git_mwindow_files_free); + + return git_strmap_alloc(&git__pack_cache); +} + +void git_mwindow_files_free(void) +{ + git_strmap *tmp = git__pack_cache; + + git__pack_cache = NULL; + git_strmap_free(tmp); +} + +int git_mwindow_get_pack(struct git_pack_file **out, const char *path) +{ + int error; + char *packname; + git_strmap_iter pos; + struct git_pack_file *pack; + + if ((error = git_packfile__name(&packname, path)) < 0) + return error; + + if (git_mutex_lock(&git__mwindow_mutex) < 0) { + giterr_set(GITERR_OS, "failed to lock mwindow mutex"); + return -1; + } + + if (git_mwindow_files_init() < 0) { + git_mutex_unlock(&git__mwindow_mutex); + git__free(packname); + return -1; + } + + pos = git_strmap_lookup_index(git__pack_cache, packname); + git__free(packname); + + if (git_strmap_valid_index(git__pack_cache, pos)) { + pack = git_strmap_value_at(git__pack_cache, pos); + git_atomic_inc(&pack->refcount); + + git_mutex_unlock(&git__mwindow_mutex); + *out = pack; + return 0; + } + + /* If we didn't find it, we need to create it */ + if ((error = git_packfile_alloc(&pack, path)) < 0) { + git_mutex_unlock(&git__mwindow_mutex); + return error; + } + + git_atomic_inc(&pack->refcount); + + git_strmap_insert(git__pack_cache, pack->pack_name, pack, error); + git_mutex_unlock(&git__mwindow_mutex); + + if (error < 0) { + git_packfile_free(pack); + return -1; + } + + *out = pack; + return 0; +} + +void git_mwindow_put_pack(struct git_pack_file *pack) +{ + int count; + git_strmap_iter pos; + + if (git_mutex_lock(&git__mwindow_mutex) < 0) + return; + + /* put before get would be a corrupted state */ + assert(git__pack_cache); + + pos = git_strmap_lookup_index(git__pack_cache, pack->pack_name); + /* if we cannot find it, the state is corrupted */ + assert(git_strmap_valid_index(git__pack_cache, pos)); + + count = git_atomic_dec(&pack->refcount); + if (count == 0) { + git_strmap_delete_at(git__pack_cache, pos); + git_packfile_free(pack); + } + + git_mutex_unlock(&git__mwindow_mutex); + return; +} + +void git_mwindow_free_all(git_mwindow_file *mwf) +{ + if (git_mutex_lock(&git__mwindow_mutex)) { + giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); + return; + } + + git_mwindow_free_all_locked(mwf); + + git_mutex_unlock(&git__mwindow_mutex); +} + +/* + * Free all the windows in a sequence, typically because we're done + * with the file + */ +void git_mwindow_free_all_locked(git_mwindow_file *mwf) +{ + git_mwindow_ctl *ctl = &mem_ctl; + size_t i; + + /* + * Remove these windows from the global list + */ + for (i = 0; i < ctl->windowfiles.length; ++i){ + if (git_vector_get(&ctl->windowfiles, i) == mwf) { + git_vector_remove(&ctl->windowfiles, i); + break; + } + } + + if (ctl->windowfiles.length == 0) { + git_vector_free(&ctl->windowfiles); + ctl->windowfiles.contents = NULL; + } + + while (mwf->windows) { + git_mwindow *w = mwf->windows; + assert(w->inuse_cnt == 0); + + ctl->mapped -= w->window_map.len; + ctl->open_windows--; + + git_futils_mmap_free(&w->window_map); + + mwf->windows = w->next; + git__free(w); + } +} + +/* + * Check if a window 'win' contains the address 'offset' + */ +int git_mwindow_contains(git_mwindow *win, git_off_t offset) +{ + git_off_t win_off = win->offset; + return win_off <= offset + && offset <= (git_off_t)(win_off + win->window_map.len); +} + +/* + * Find the least-recently-used window in a file + */ +static void git_mwindow_scan_lru( + git_mwindow_file *mwf, + git_mwindow **lru_w, + git_mwindow **lru_l) +{ + git_mwindow *w, *w_l; + + for (w_l = NULL, w = mwf->windows; w; w = w->next) { + if (!w->inuse_cnt) { + /* + * If the current one is more recent than the last one, + * store it in the output parameter. If lru_w is NULL, + * it's the first loop, so store it as well. + */ + if (!*lru_w || w->last_used < (*lru_w)->last_used) { + *lru_w = w; + *lru_l = w_l; + } + } + w_l = w; + } +} + +/* + * Close the least recently used window. You should check to see if + * the file descriptors need closing from time to time. Called under + * lock from new_window. + */ +static int git_mwindow_close_lru(git_mwindow_file *mwf) +{ + git_mwindow_ctl *ctl = &mem_ctl; + size_t i; + git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows; + + /* FIXME: Does this give us any advantage? */ + if(mwf->windows) + git_mwindow_scan_lru(mwf, &lru_w, &lru_l); + + for (i = 0; i < ctl->windowfiles.length; ++i) { + git_mwindow *last = lru_w; + git_mwindow_file *cur = git_vector_get(&ctl->windowfiles, i); + git_mwindow_scan_lru(cur, &lru_w, &lru_l); + if (lru_w != last) + list = &cur->windows; + } + + if (!lru_w) { + giterr_set(GITERR_OS, "Failed to close memory window. Couldn't find LRU"); + return -1; + } + + ctl->mapped -= lru_w->window_map.len; + git_futils_mmap_free(&lru_w->window_map); + + if (lru_l) + lru_l->next = lru_w->next; + else + *list = lru_w->next; + + git__free(lru_w); + ctl->open_windows--; + + return 0; +} + +/* This gets called under lock from git_mwindow_open */ +static git_mwindow *new_window( + git_mwindow_file *mwf, + git_file fd, + git_off_t size, + git_off_t offset) +{ + git_mwindow_ctl *ctl = &mem_ctl; + size_t walign = git_mwindow__window_size / 2; + git_off_t len; + git_mwindow *w; + + w = git__malloc(sizeof(*w)); + + if (w == NULL) + return NULL; + + memset(w, 0x0, sizeof(*w)); + w->offset = (offset / walign) * walign; + + len = size - w->offset; + if (len > (git_off_t)git_mwindow__window_size) + len = (git_off_t)git_mwindow__window_size; + + ctl->mapped += (size_t)len; + + while (git_mwindow__mapped_limit < ctl->mapped && + git_mwindow_close_lru(mwf) == 0) /* nop */; + + /* + * We treat `mapped_limit` as a soft limit. If we can't find a + * window to close and are above the limit, we still mmap the new + * window. + */ + + if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) { + git__free(w); + return NULL; + } + + ctl->mmap_calls++; + ctl->open_windows++; + + if (ctl->mapped > ctl->peak_mapped) + ctl->peak_mapped = ctl->mapped; + + if (ctl->open_windows > ctl->peak_open_windows) + ctl->peak_open_windows = ctl->open_windows; + + return w; +} + +/* + * Open a new window, closing the least recenty used until we have + * enough space. Don't forget to add it to your list + */ +unsigned char *git_mwindow_open( + git_mwindow_file *mwf, + git_mwindow **cursor, + git_off_t offset, + size_t extra, + unsigned int *left) +{ + git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow *w = *cursor; + + if (git_mutex_lock(&git__mwindow_mutex)) { + giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); + return NULL; + } + + if (!w || !(git_mwindow_contains(w, offset) && git_mwindow_contains(w, offset + extra))) { + if (w) { + w->inuse_cnt--; + } + + for (w = mwf->windows; w; w = w->next) { + if (git_mwindow_contains(w, offset) && + git_mwindow_contains(w, offset + extra)) + break; + } + + /* + * If there isn't a suitable window, we need to create a new + * one. + */ + if (!w) { + w = new_window(mwf, mwf->fd, mwf->size, offset); + if (w == NULL) { + git_mutex_unlock(&git__mwindow_mutex); + return NULL; + } + w->next = mwf->windows; + mwf->windows = w; + } + } + + /* If we changed w, store it in the cursor */ + if (w != *cursor) { + w->last_used = ctl->used_ctr++; + w->inuse_cnt++; + *cursor = w; + } + + offset -= w->offset; + + if (left) + *left = (unsigned int)(w->window_map.len - offset); + + git_mutex_unlock(&git__mwindow_mutex); + return (unsigned char *) w->window_map.data + offset; +} + +int git_mwindow_file_register(git_mwindow_file *mwf) +{ + git_mwindow_ctl *ctl = &mem_ctl; + int ret; + + if (git_mutex_lock(&git__mwindow_mutex)) { + giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); + return -1; + } + + if (ctl->windowfiles.length == 0 && + git_vector_init(&ctl->windowfiles, 8, NULL) < 0) { + git_mutex_unlock(&git__mwindow_mutex); + return -1; + } + + ret = git_vector_insert(&ctl->windowfiles, mwf); + git_mutex_unlock(&git__mwindow_mutex); + + return ret; +} + +void git_mwindow_file_deregister(git_mwindow_file *mwf) +{ + git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_file *cur; + size_t i; + + if (git_mutex_lock(&git__mwindow_mutex)) + return; + + git_vector_foreach(&ctl->windowfiles, i, cur) { + if (cur == mwf) { + git_vector_remove(&ctl->windowfiles, i); + git_mutex_unlock(&git__mwindow_mutex); + return; + } + } + git_mutex_unlock(&git__mwindow_mutex); +} + +void git_mwindow_close(git_mwindow **window) +{ + git_mwindow *w = *window; + if (w) { + if (git_mutex_lock(&git__mwindow_mutex)) { + giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); + return; + } + + w->inuse_cnt--; + git_mutex_unlock(&git__mwindow_mutex); + *window = NULL; + } +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/mwindow.h b/deps/libgit2-sys-0.2.17/libgit2/src/mwindow.h new file mode 100644 index 000000000..63418e458 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/mwindow.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_mwindow__ +#define INCLUDE_mwindow__ + +#include "map.h" +#include "vector.h" + +typedef struct git_mwindow { + struct git_mwindow *next; + git_map window_map; + git_off_t offset; + size_t last_used; + size_t inuse_cnt; +} git_mwindow; + +typedef struct git_mwindow_file { + git_mwindow *windows; + int fd; + git_off_t size; +} git_mwindow_file; + +typedef struct git_mwindow_ctl { + size_t mapped; + unsigned int open_windows; + unsigned int mmap_calls; + unsigned int peak_open_windows; + size_t peak_mapped; + size_t used_ctr; + git_vector windowfiles; +} git_mwindow_ctl; + +int git_mwindow_contains(git_mwindow *win, git_off_t offset); +void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */ +void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */ +unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left); +int git_mwindow_file_register(git_mwindow_file *mwf); +void git_mwindow_file_deregister(git_mwindow_file *mwf); +void git_mwindow_close(git_mwindow **w_cursor); + +int git_mwindow_files_init(void); +void git_mwindow_files_free(void); + +struct git_pack_file; /* just declaration to avoid cyclical includes */ +int git_mwindow_get_pack(struct git_pack_file **out, const char *path); +void git_mwindow_put_pack(struct git_pack_file *pack); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/netops.c b/deps/libgit2-sys-0.2.17/libgit2/src/netops.c new file mode 100644 index 000000000..6047cf1ac --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/netops.c @@ -0,0 +1,282 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include +#include "git2/errors.h" + +#include "common.h" +#include "netops.h" +#include "posix.h" +#include "buffer.h" +#include "http_parser.h" +#include "global.h" + +int gitno_recv(gitno_buffer *buf) +{ + return buf->recv(buf); +} + +void gitno_buffer_setup_callback( + gitno_buffer *buf, + char *data, + size_t len, + int (*recv)(gitno_buffer *buf), void *cb_data) +{ + memset(data, 0x0, len); + buf->data = data; + buf->len = len; + buf->offset = 0; + buf->recv = recv; + buf->cb_data = cb_data; +} + +static int recv_stream(gitno_buffer *buf) +{ + git_stream *io = (git_stream *) buf->cb_data; + int ret; + + ret = git_stream_read(io, buf->data + buf->offset, buf->len - buf->offset); + if (ret < 0) + return -1; + + buf->offset += ret; + return ret; +} + +void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data, size_t len) +{ + memset(data, 0x0, len); + buf->data = data; + buf->len = len; + buf->offset = 0; + buf->recv = recv_stream; + buf->cb_data = st; +} + +/* Consume up to ptr and move the rest of the buffer to the beginning */ +void gitno_consume(gitno_buffer *buf, const char *ptr) +{ + size_t consumed; + + assert(ptr - buf->data >= 0); + assert(ptr - buf->data <= (int) buf->len); + + consumed = ptr - buf->data; + + memmove(buf->data, ptr, buf->offset - consumed); + memset(buf->data + buf->offset, 0x0, buf->len - buf->offset); + buf->offset -= consumed; +} + +/* Consume const bytes and move the rest of the buffer to the beginning */ +void gitno_consume_n(gitno_buffer *buf, size_t cons) +{ + memmove(buf->data, buf->data + cons, buf->len - buf->offset); + memset(buf->data + cons, 0x0, buf->len - buf->offset); + buf->offset -= cons; +} + +/* Match host names according to RFC 2818 rules */ +int gitno__match_host(const char *pattern, const char *host) +{ + for (;;) { + char c = tolower(*pattern++); + + if (c == '\0') + return *host ? -1 : 0; + + if (c == '*') { + c = *pattern; + /* '*' at the end matches everything left */ + if (c == '\0') + return 0; + + /* + * We've found a pattern, so move towards the next matching + * char. The '.' is handled specially because wildcards aren't + * allowed to cross subdomains. + */ + + while(*host) { + char h = tolower(*host); + if (c == h) + return gitno__match_host(pattern, host++); + if (h == '.') + return gitno__match_host(pattern, host); + host++; + } + return -1; + } + + if (c != tolower(*host++)) + return -1; + } + + return -1; +} + +static const char *prefix_http = "http://"; +static const char *prefix_https = "https://"; + +int gitno_connection_data_from_url( + gitno_connection_data *data, + const char *url, + const char *service_suffix) +{ + int error = -1; + const char *default_port = NULL, *path_search_start = NULL; + char *original_host = NULL; + + /* service_suffix is optional */ + assert(data && url); + + /* Save these for comparison later */ + original_host = data->host; + data->host = NULL; + gitno_connection_data_free_ptrs(data); + + if (!git__prefixcmp(url, prefix_http)) { + path_search_start = url + strlen(prefix_http); + default_port = "80"; + + if (data->use_ssl) { + giterr_set(GITERR_NET, "Redirect from HTTPS to HTTP is not allowed"); + goto cleanup; + } + } else if (!git__prefixcmp(url, prefix_https)) { + path_search_start = url + strlen(prefix_https); + default_port = "443"; + data->use_ssl = true; + } else if (url[0] == '/') + default_port = data->use_ssl ? "443" : "80"; + + if (!default_port) { + giterr_set(GITERR_NET, "Unrecognized URL prefix"); + goto cleanup; + } + + error = gitno_extract_url_parts( + &data->host, &data->port, &data->path, &data->user, &data->pass, + url, default_port); + + if (url[0] == '/') { + /* Relative redirect; reuse original host name and port */ + path_search_start = url; + git__free(data->host); + data->host = original_host; + original_host = NULL; + } + + if (!error) { + const char *path = strchr(path_search_start, '/'); + size_t pathlen = strlen(path); + size_t suffixlen = service_suffix ? strlen(service_suffix) : 0; + + if (suffixlen && + !memcmp(path + pathlen - suffixlen, service_suffix, suffixlen)) { + git__free(data->path); + data->path = git__strndup(path, pathlen - suffixlen); + } else { + git__free(data->path); + data->path = git__strdup(path); + } + + /* Check for errors in the resulting data */ + if (original_host && url[0] != '/' && strcmp(original_host, data->host)) { + giterr_set(GITERR_NET, "Cross host redirect not allowed"); + error = -1; + } + } + +cleanup: + if (original_host) git__free(original_host); + return error; +} + +void gitno_connection_data_free_ptrs(gitno_connection_data *d) +{ + git__free(d->host); d->host = NULL; + git__free(d->port); d->port = NULL; + git__free(d->path); d->path = NULL; + git__free(d->user); d->user = NULL; + git__free(d->pass); d->pass = NULL; +} + +#define hex2c(c) ((c | 32) % 39 - 9) +static char* unescape(char *str) +{ + int x, y; + int len = (int)strlen(str); + + for (x=y=0; str[y]; ++x, ++y) { + if ((str[x] = str[y]) == '%') { + if (y < len-2 && isxdigit(str[y+1]) && isxdigit(str[y+2])) { + str[x] = (hex2c(str[y+1]) << 4) + hex2c(str[y+2]); + y += 2; + } + } + } + str[x] = '\0'; + return str; +} + +int gitno_extract_url_parts( + char **host, + char **port, + char **path, + char **username, + char **password, + const char *url, + const char *default_port) +{ + struct http_parser_url u = {0}; + const char *_host, *_port, *_path, *_userinfo; + + if (http_parser_parse_url(url, strlen(url), false, &u)) { + giterr_set(GITERR_NET, "Malformed URL '%s'", url); + return GIT_EINVALIDSPEC; + } + + _host = url+u.field_data[UF_HOST].off; + _port = url+u.field_data[UF_PORT].off; + _path = url+u.field_data[UF_PATH].off; + _userinfo = url+u.field_data[UF_USERINFO].off; + + if (u.field_set & (1 << UF_HOST)) { + *host = git__substrdup(_host, u.field_data[UF_HOST].len); + GITERR_CHECK_ALLOC(*host); + } + + if (u.field_set & (1 << UF_PORT)) + *port = git__substrdup(_port, u.field_data[UF_PORT].len); + else + *port = git__strdup(default_port); + GITERR_CHECK_ALLOC(*port); + + if (u.field_set & (1 << UF_PATH)) { + *path = git__substrdup(_path, u.field_data[UF_PATH].len); + GITERR_CHECK_ALLOC(*path); + } else { + giterr_set(GITERR_NET, "invalid url, missing path"); + return GIT_EINVALIDSPEC; + } + + if (u.field_set & (1 << UF_USERINFO)) { + const char *colon = memchr(_userinfo, ':', u.field_data[UF_USERINFO].len); + if (colon) { + *username = unescape(git__substrdup(_userinfo, colon - _userinfo)); + *password = unescape(git__substrdup(colon+1, u.field_data[UF_USERINFO].len - (colon+1-_userinfo))); + GITERR_CHECK_ALLOC(*password); + } else { + *username = git__substrdup(_userinfo, u.field_data[UF_USERINFO].len); + } + GITERR_CHECK_ALLOC(*username); + + } + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/netops.h b/deps/libgit2-sys-0.2.17/libgit2/src/netops.h new file mode 100644 index 000000000..d5f0ca3f3 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/netops.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_netops_h__ +#define INCLUDE_netops_h__ + +#include "posix.h" +#include "common.h" +#include "stream.h" + +#ifdef GIT_SSL +# include +#endif + +typedef struct gitno_ssl { +#ifdef GIT_SSL + SSL *ssl; +#else + size_t dummy; +#endif +} gitno_ssl; + +/* Represents a socket that may or may not be using SSL */ +typedef struct gitno_socket { + GIT_SOCKET socket; + gitno_ssl ssl; +} gitno_socket; + +typedef struct gitno_buffer { + char *data; + size_t len; + size_t offset; + int (*recv)(struct gitno_buffer *buffer); + void *cb_data; +} gitno_buffer; + +/* Flags to gitno_connect */ +enum { + /* Attempt to create an SSL connection. */ + GITNO_CONNECT_SSL = 1, +}; + +/** + * Check if the name in a cert matches the wanted hostname + * + * Check if a pattern from a certificate matches the hostname we + * wanted to connect to according to RFC2818 rules (which specifies + * HTTP over TLS). Mainly, an asterisk matches anything, but is + * limited to a single url component. + * + * Note that this does not set an error message. It expects the user + * to provide the message for the user. + */ +int gitno__match_host(const char *pattern, const char *host); + +void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data, size_t len); +void gitno_buffer_setup_callback(gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data); +int gitno_recv(gitno_buffer *buf); + +void gitno_consume(gitno_buffer *buf, const char *ptr); +void gitno_consume_n(gitno_buffer *buf, size_t cons); + +typedef struct gitno_connection_data { + char *host; + char *port; + char *path; + char *user; + char *pass; + bool use_ssl; +} gitno_connection_data; + +/* + * This replaces all the pointers in `data` with freshly-allocated strings, + * that the caller is responsible for freeing. + * `gitno_connection_data_free_ptrs` is good for this. + */ + +int gitno_connection_data_from_url( + gitno_connection_data *data, + const char *url, + const char *service_suffix); + +/* This frees all the pointers IN the struct, but not the struct itself. */ +void gitno_connection_data_free_ptrs(gitno_connection_data *data); + +int gitno_extract_url_parts( + char **host, + char **port, + char **path, + char **username, + char **password, + const char *url, + const char *default_port); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/notes.c b/deps/libgit2-sys-0.2.17/libgit2/src/notes.c new file mode 100644 index 000000000..ef4b41b31 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/notes.c @@ -0,0 +1,694 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "notes.h" + +#include "git2.h" +#include "refs.h" +#include "config.h" +#include "iterator.h" +#include "signature.h" + +static int note_error_notfound(void) +{ + giterr_set(GITERR_INVALID, "Note could not be found"); + return GIT_ENOTFOUND; +} + +static int find_subtree_in_current_level( + git_tree **out, + git_repository *repo, + git_tree *parent, + const char *annotated_object_sha, + int fanout) +{ + size_t i; + const git_tree_entry *entry; + + *out = NULL; + + if (parent == NULL) + return note_error_notfound(); + + for (i = 0; i < git_tree_entrycount(parent); i++) { + entry = git_tree_entry_byindex(parent, i); + + if (!git__ishex(git_tree_entry_name(entry))) + continue; + + if (S_ISDIR(git_tree_entry_filemode(entry)) + && strlen(git_tree_entry_name(entry)) == 2 + && !strncmp(git_tree_entry_name(entry), annotated_object_sha + fanout, 2)) + return git_tree_lookup(out, repo, git_tree_entry_id(entry)); + + /* Not a DIR, so do we have an already existing blob? */ + if (!strcmp(git_tree_entry_name(entry), annotated_object_sha + fanout)) + return GIT_EEXISTS; + } + + return note_error_notfound(); +} + +static int find_subtree_r(git_tree **out, git_tree *root, + git_repository *repo, const char *target, int *fanout) +{ + int error; + git_tree *subtree = NULL; + + *out = NULL; + + error = find_subtree_in_current_level(&subtree, repo, root, target, *fanout); + if (error == GIT_EEXISTS) + return git_tree_lookup(out, repo, git_tree_id(root)); + + if (error < 0) + return error; + + *fanout += 2; + error = find_subtree_r(out, subtree, repo, target, fanout); + git_tree_free(subtree); + + return error; +} + +static int find_blob(git_oid *blob, git_tree *tree, const char *target) +{ + size_t i; + const git_tree_entry *entry; + + for (i=0; iid, note_oid); + + if (git_signature_dup(¬e->author, git_commit_author(commit)) < 0 || + git_signature_dup(¬e->committer, git_commit_committer(commit)) < 0) + return -1; + + note->message = git__strndup(git_blob_rawcontent(blob), git_blob_rawsize(blob)); + GITERR_CHECK_ALLOC(note->message); + + *out = note; + return 0; +} + +static int note_lookup( + git_note **out, + git_repository *repo, + git_commit *commit, + git_tree *tree, + const char *target) +{ + int error, fanout = 0; + git_oid oid; + git_blob *blob = NULL; + git_note *note = NULL; + git_tree *subtree = NULL; + + if ((error = find_subtree_r(&subtree, tree, repo, target, &fanout)) < 0) + goto cleanup; + + if ((error = find_blob(&oid, subtree, target + fanout)) < 0) + goto cleanup; + + if ((error = git_blob_lookup(&blob, repo, &oid)) < 0) + goto cleanup; + + if ((error = note_new(¬e, &oid, commit, blob)) < 0) + goto cleanup; + + *out = note; + +cleanup: + git_tree_free(subtree); + git_blob_free(blob); + return error; +} + +static int note_remove(git_repository *repo, + const git_signature *author, const git_signature *committer, + const char *notes_ref, git_tree *tree, + const char *target, git_commit **parents) +{ + int error; + git_tree *tree_after_removal = NULL; + git_oid oid; + + if ((error = manipulate_note_in_tree_r( + &tree_after_removal, repo, tree, NULL, target, 0, + remove_note_in_tree_eexists_cb, remove_note_in_tree_enotfound_cb)) < 0) + goto cleanup; + + error = git_commit_create(&oid, repo, notes_ref, author, committer, + NULL, GIT_NOTES_DEFAULT_MSG_RM, + tree_after_removal, + *parents == NULL ? 0 : 1, + (const git_commit **) parents); + +cleanup: + git_tree_free(tree_after_removal); + return error; +} + +static int note_get_default_ref(char **out, git_repository *repo) +{ + git_config *cfg; + int ret = git_repository_config__weakptr(&cfg, repo); + + *out = (ret != 0) ? NULL : git_config__get_string_force( + cfg, "core.notesref", GIT_NOTES_DEFAULT_REF); + + return ret; +} + +static int normalize_namespace(char **out, git_repository *repo, const char *notes_ref) +{ + if (notes_ref) { + *out = git__strdup(notes_ref); + GITERR_CHECK_ALLOC(*out); + return 0; + } + + return note_get_default_ref(out, repo); +} + +static int retrieve_note_tree_and_commit( + git_tree **tree_out, + git_commit **commit_out, + char **notes_ref_out, + git_repository *repo, + const char *notes_ref) +{ + int error; + git_oid oid; + + if ((error = normalize_namespace(notes_ref_out, repo, notes_ref)) < 0) + return error; + + if ((error = git_reference_name_to_id(&oid, repo, *notes_ref_out)) < 0) + return error; + + if (git_commit_lookup(commit_out, repo, &oid) < 0) + return error; + + if ((error = git_commit_tree(tree_out, *commit_out)) < 0) + return error; + + return 0; +} + +int git_note_read(git_note **out, git_repository *repo, + const char *notes_ref_in, const git_oid *oid) +{ + int error; + char *target = NULL, *notes_ref = NULL; + git_tree *tree = NULL; + git_commit *commit = NULL; + + target = git_oid_allocfmt(oid); + GITERR_CHECK_ALLOC(target); + + if (!(error = retrieve_note_tree_and_commit( + &tree, &commit, ¬es_ref, repo, notes_ref_in))) + error = note_lookup(out, repo, commit, tree, target); + + git__free(notes_ref); + git__free(target); + git_tree_free(tree); + git_commit_free(commit); + return error; +} + +int git_note_create( + git_oid *out, + git_repository *repo, + const char *notes_ref_in, + const git_signature *author, + const git_signature *committer, + const git_oid *oid, + const char *note, + int allow_note_overwrite) +{ + int error; + char *target = NULL, *notes_ref = NULL; + git_commit *commit = NULL; + git_tree *tree = NULL; + + target = git_oid_allocfmt(oid); + GITERR_CHECK_ALLOC(target); + + error = retrieve_note_tree_and_commit(&tree, &commit, ¬es_ref, repo, notes_ref_in); + + if (error < 0 && error != GIT_ENOTFOUND) + goto cleanup; + + error = note_write(out, repo, author, committer, notes_ref, + note, tree, target, &commit, allow_note_overwrite); + +cleanup: + git__free(notes_ref); + git__free(target); + git_commit_free(commit); + git_tree_free(tree); + return error; +} + +int git_note_remove(git_repository *repo, const char *notes_ref_in, + const git_signature *author, const git_signature *committer, + const git_oid *oid) +{ + int error; + char *target = NULL, *notes_ref; + git_commit *commit = NULL; + git_tree *tree = NULL; + + target = git_oid_allocfmt(oid); + GITERR_CHECK_ALLOC(target); + + if (!(error = retrieve_note_tree_and_commit( + &tree, &commit, ¬es_ref, repo, notes_ref_in))) + error = note_remove( + repo, author, committer, notes_ref, tree, target, &commit); + + git__free(notes_ref); + git__free(target); + git_commit_free(commit); + git_tree_free(tree); + return error; +} + +int git_note_default_ref(git_buf *out, git_repository *repo) +{ + char *default_ref; + int error; + + assert(out && repo); + + git_buf_sanitize(out); + + if ((error = note_get_default_ref(&default_ref, repo)) < 0) + return error; + + git_buf_attach(out, default_ref, strlen(default_ref)); + return 0; +} + +const git_signature *git_note_committer(const git_note *note) +{ + assert(note); + return note->committer; +} + +const git_signature *git_note_author(const git_note *note) +{ + assert(note); + return note->author; +} + +const char * git_note_message(const git_note *note) +{ + assert(note); + return note->message; +} + +const git_oid * git_note_id(const git_note *note) +{ + assert(note); + return ¬e->id; +} + +void git_note_free(git_note *note) +{ + if (note == NULL) + return; + + git_signature_free(note->committer); + git_signature_free(note->author); + git__free(note->message); + git__free(note); +} + +static int process_entry_path( + const char* entry_path, + git_oid *annotated_object_id) +{ + int error = 0; + size_t i = 0, j = 0, len; + git_buf buf = GIT_BUF_INIT; + + if ((error = git_buf_puts(&buf, entry_path)) < 0) + goto cleanup; + + len = git_buf_len(&buf); + + while (i < len) { + if (buf.ptr[i] == '/') { + i++; + continue; + } + + if (git__fromhex(buf.ptr[i]) < 0) { + /* This is not a note entry */ + goto cleanup; + } + + if (i != j) + buf.ptr[j] = buf.ptr[i]; + + i++; + j++; + } + + buf.ptr[j] = '\0'; + buf.size = j; + + if (j != GIT_OID_HEXSZ) { + /* This is not a note entry */ + goto cleanup; + } + + error = git_oid_fromstr(annotated_object_id, buf.ptr); + +cleanup: + git_buf_free(&buf); + return error; +} + +int git_note_foreach( + git_repository *repo, + const char *notes_ref, + git_note_foreach_cb note_cb, + void *payload) +{ + int error; + git_note_iterator *iter = NULL; + git_oid note_id, annotated_id; + + if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0) + return error; + + while (!(error = git_note_next(¬e_id, &annotated_id, iter))) { + if ((error = note_cb(¬e_id, &annotated_id, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + if (error == GIT_ITEROVER) + error = 0; + + git_note_iterator_free(iter); + return error; +} + + +void git_note_iterator_free(git_note_iterator *it) +{ + if (it == NULL) + return; + + git_iterator_free(it); +} + + +int git_note_iterator_new( + git_note_iterator **it, + git_repository *repo, + const char *notes_ref_in) +{ + int error; + git_commit *commit = NULL; + git_tree *tree = NULL; + char *notes_ref; + + error = retrieve_note_tree_and_commit(&tree, &commit, ¬es_ref, repo, notes_ref_in); + if (error < 0) + goto cleanup; + + if ((error = git_iterator_for_tree(it, tree, 0, NULL, NULL)) < 0) + git_iterator_free(*it); + +cleanup: + git__free(notes_ref); + git_tree_free(tree); + git_commit_free(commit); + + return error; +} + +int git_note_next( + git_oid* note_id, + git_oid* annotated_id, + git_note_iterator *it) +{ + int error; + const git_index_entry *item; + + if ((error = git_iterator_current(&item, it)) < 0) + return error; + + git_oid_cpy(note_id, &item->id); + + if (!(error = process_entry_path(item->path, annotated_id))) + git_iterator_advance(NULL, it); + + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/notes.h b/deps/libgit2-sys-0.2.17/libgit2/src/notes.h new file mode 100644 index 000000000..cfc0ca239 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/notes.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_note_h__ +#define INCLUDE_note_h__ + +#include "common.h" + +#include "git2/oid.h" +#include "git2/types.h" + +#define GIT_NOTES_DEFAULT_REF "refs/notes/commits" + +#define GIT_NOTES_DEFAULT_MSG_ADD \ + "Notes added by 'git_note_create' from libgit2" + +#define GIT_NOTES_DEFAULT_MSG_RM \ + "Notes removed by 'git_note_remove' from libgit2" + +struct git_note { + git_oid id; + + git_signature *author; + git_signature *committer; + + char *message; +}; + +#endif /* INCLUDE_notes_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/object.c b/deps/libgit2-sys-0.2.17/libgit2/src/object.c new file mode 100644 index 000000000..1073559fd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/object.c @@ -0,0 +1,469 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2/object.h" + +#include "common.h" +#include "repository.h" + +#include "commit.h" +#include "tree.h" +#include "blob.h" +#include "tag.h" + +static const int OBJECT_BASE_SIZE = 4096; + +typedef struct { + const char *str; /* type name string */ + size_t size; /* size in bytes of the object structure */ + + int (*parse)(void *self, git_odb_object *obj); + void (*free)(void *self); +} git_object_def; + +static git_object_def git_objects_table[] = { + /* 0 = GIT_OBJ__EXT1 */ + { "", 0, NULL, NULL }, + + /* 1 = GIT_OBJ_COMMIT */ + { "commit", sizeof(git_commit), git_commit__parse, git_commit__free }, + + /* 2 = GIT_OBJ_TREE */ + { "tree", sizeof(git_tree), git_tree__parse, git_tree__free }, + + /* 3 = GIT_OBJ_BLOB */ + { "blob", sizeof(git_blob), git_blob__parse, git_blob__free }, + + /* 4 = GIT_OBJ_TAG */ + { "tag", sizeof(git_tag), git_tag__parse, git_tag__free }, + + /* 5 = GIT_OBJ__EXT2 */ + { "", 0, NULL, NULL }, + /* 6 = GIT_OBJ_OFS_DELTA */ + { "OFS_DELTA", 0, NULL, NULL }, + /* 7 = GIT_OBJ_REF_DELTA */ + { "REF_DELTA", 0, NULL, NULL }, +}; + +int git_object__from_odb_object( + git_object **object_out, + git_repository *repo, + git_odb_object *odb_obj, + git_otype type) +{ + int error; + size_t object_size; + git_object_def *def; + git_object *object = NULL; + + assert(object_out); + *object_out = NULL; + + /* Validate type match */ + if (type != GIT_OBJ_ANY && type != odb_obj->cached.type) { + giterr_set(GITERR_INVALID, + "The requested type does not match the type in the ODB"); + return GIT_ENOTFOUND; + } + + if ((object_size = git_object__size(odb_obj->cached.type)) == 0) { + giterr_set(GITERR_INVALID, "The requested type is invalid"); + return GIT_ENOTFOUND; + } + + /* Allocate and initialize base object */ + object = git__calloc(1, object_size); + GITERR_CHECK_ALLOC(object); + + git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid); + object->cached.type = odb_obj->cached.type; + object->cached.size = odb_obj->cached.size; + object->repo = repo; + + /* Parse raw object data */ + def = &git_objects_table[odb_obj->cached.type]; + assert(def->free && def->parse); + + if ((error = def->parse(object, odb_obj)) < 0) + def->free(object); + else + *object_out = git_cache_store_parsed(&repo->objects, object); + + return error; +} + +void git_object__free(void *obj) +{ + git_otype type = ((git_object *)obj)->cached.type; + + if (type < 0 || ((size_t)type) >= ARRAY_SIZE(git_objects_table) || + !git_objects_table[type].free) + git__free(obj); + else + git_objects_table[type].free(obj); +} + +int git_object_lookup_prefix( + git_object **object_out, + git_repository *repo, + const git_oid *id, + size_t len, + git_otype type) +{ + git_object *object = NULL; + git_odb *odb = NULL; + git_odb_object *odb_obj = NULL; + int error = 0; + + assert(repo && object_out && id); + + if (len < GIT_OID_MINPREFIXLEN) { + giterr_set(GITERR_OBJECT, "Ambiguous lookup - OID prefix is too short"); + return GIT_EAMBIGUOUS; + } + + error = git_repository_odb__weakptr(&odb, repo); + if (error < 0) + return error; + + if (len > GIT_OID_HEXSZ) + len = GIT_OID_HEXSZ; + + if (len == GIT_OID_HEXSZ) { + git_cached_obj *cached = NULL; + + /* We want to match the full id : we can first look up in the cache, + * since there is no need to check for non ambiguousity + */ + cached = git_cache_get_any(&repo->objects, id); + if (cached != NULL) { + if (cached->flags == GIT_CACHE_STORE_PARSED) { + object = (git_object *)cached; + + if (type != GIT_OBJ_ANY && type != object->cached.type) { + git_object_free(object); + giterr_set(GITERR_INVALID, + "The requested type does not match the type in ODB"); + return GIT_ENOTFOUND; + } + + *object_out = object; + return 0; + } else if (cached->flags == GIT_CACHE_STORE_RAW) { + odb_obj = (git_odb_object *)cached; + } else { + assert(!"Wrong caching type in the global object cache"); + } + } else { + /* Object was not found in the cache, let's explore the backends. + * We could just use git_odb_read_unique_short_oid, + * it is the same cost for packed and loose object backends, + * but it may be much more costly for sqlite and hiredis. + */ + error = git_odb_read(&odb_obj, odb, id); + } + } else { + git_oid short_oid; + + /* We copy the first len*4 bits from id and fill the remaining with 0s */ + memcpy(short_oid.id, id->id, (len + 1) / 2); + if (len % 2) + short_oid.id[len / 2] &= 0xF0; + memset(short_oid.id + (len + 1) / 2, 0, (GIT_OID_HEXSZ - len) / 2); + + /* If len < GIT_OID_HEXSZ (a strict short oid was given), we have + * 2 options : + * - We always search in the cache first. If we find that short oid is + * ambiguous, we can stop. But in all the other cases, we must then + * explore all the backends (to find an object if there was match, + * or to check that oid is not ambiguous if we have found 1 match in + * the cache) + * - We never explore the cache, go right to exploring the backends + * We chose the latter : we explore directly the backends. + */ + error = git_odb_read_prefix(&odb_obj, odb, &short_oid, len); + } + + if (error < 0) + return error; + + error = git_object__from_odb_object(object_out, repo, odb_obj, type); + + git_odb_object_free(odb_obj); + + return error; +} + +int git_object_lookup(git_object **object_out, git_repository *repo, const git_oid *id, git_otype type) { + return git_object_lookup_prefix(object_out, repo, id, GIT_OID_HEXSZ, type); +} + +void git_object_free(git_object *object) +{ + if (object == NULL) + return; + + git_cached_obj_decref(object); +} + +const git_oid *git_object_id(const git_object *obj) +{ + assert(obj); + return &obj->cached.oid; +} + +git_otype git_object_type(const git_object *obj) +{ + assert(obj); + return obj->cached.type; +} + +git_repository *git_object_owner(const git_object *obj) +{ + assert(obj); + return obj->repo; +} + +const char *git_object_type2string(git_otype type) +{ + if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table)) + return ""; + + return git_objects_table[type].str; +} + +git_otype git_object_string2type(const char *str) +{ + size_t i; + + if (!str || !*str) + return GIT_OBJ_BAD; + + for (i = 0; i < ARRAY_SIZE(git_objects_table); i++) + if (!strcmp(str, git_objects_table[i].str)) + return (git_otype)i; + + return GIT_OBJ_BAD; +} + +int git_object_typeisloose(git_otype type) +{ + if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table)) + return 0; + + return (git_objects_table[type].size > 0) ? 1 : 0; +} + +size_t git_object__size(git_otype type) +{ + if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table)) + return 0; + + return git_objects_table[type].size; +} + +static int dereference_object(git_object **dereferenced, git_object *obj) +{ + git_otype type = git_object_type(obj); + + switch (type) { + case GIT_OBJ_COMMIT: + return git_commit_tree((git_tree **)dereferenced, (git_commit*)obj); + + case GIT_OBJ_TAG: + return git_tag_target(dereferenced, (git_tag*)obj); + + case GIT_OBJ_BLOB: + case GIT_OBJ_TREE: + return GIT_EPEEL; + + default: + return GIT_EINVALIDSPEC; + } +} + +static int peel_error(int error, const git_oid *oid, git_otype type) +{ + const char *type_name; + char hex_oid[GIT_OID_HEXSZ + 1]; + + type_name = git_object_type2string(type); + + git_oid_fmt(hex_oid, oid); + hex_oid[GIT_OID_HEXSZ] = '\0'; + + giterr_set(GITERR_OBJECT, "The git_object of id '%s' can not be " + "successfully peeled into a %s (git_otype=%i).", hex_oid, type_name, type); + + return error; +} + +static int check_type_combination(git_otype type, git_otype target) +{ + if (type == target) + return 0; + + switch (type) { + case GIT_OBJ_BLOB: + case GIT_OBJ_TREE: + /* a blob or tree can never be peeled to anything but themselves */ + return GIT_EINVALIDSPEC; + break; + case GIT_OBJ_COMMIT: + /* a commit can only be peeled to a tree */ + if (target != GIT_OBJ_TREE && target != GIT_OBJ_ANY) + return GIT_EINVALIDSPEC; + break; + case GIT_OBJ_TAG: + /* a tag may point to anything, so we let anything through */ + break; + default: + return GIT_EINVALIDSPEC; + } + + return 0; +} + +int git_object_peel( + git_object **peeled, + const git_object *object, + git_otype target_type) +{ + git_object *source, *deref = NULL; + int error; + + assert(object && peeled); + + assert(target_type == GIT_OBJ_TAG || + target_type == GIT_OBJ_COMMIT || + target_type == GIT_OBJ_TREE || + target_type == GIT_OBJ_BLOB || + target_type == GIT_OBJ_ANY); + + if ((error = check_type_combination(git_object_type(object), target_type)) < 0) + return peel_error(error, git_object_id(object), target_type); + + if (git_object_type(object) == target_type) + return git_object_dup(peeled, (git_object *)object); + + source = (git_object *)object; + + while (!(error = dereference_object(&deref, source))) { + + if (source != object) + git_object_free(source); + + if (git_object_type(deref) == target_type) { + *peeled = deref; + return 0; + } + + if (target_type == GIT_OBJ_ANY && + git_object_type(deref) != git_object_type(object)) + { + *peeled = deref; + return 0; + } + + source = deref; + deref = NULL; + } + + if (source != object) + git_object_free(source); + + git_object_free(deref); + + if (error) + error = peel_error(error, git_object_id(object), target_type); + + return error; +} + +int git_object_dup(git_object **dest, git_object *source) +{ + git_cached_obj_incref(source); + *dest = source; + return 0; +} + +int git_object_lookup_bypath( + git_object **out, + const git_object *treeish, + const char *path, + git_otype type) +{ + int error = -1; + git_tree *tree = NULL; + git_tree_entry *entry = NULL; + + assert(out && treeish && path); + + if ((error = git_object_peel((git_object**)&tree, treeish, GIT_OBJ_TREE)) < 0 || + (error = git_tree_entry_bypath(&entry, tree, path)) < 0) + { + goto cleanup; + } + + if (type != GIT_OBJ_ANY && git_tree_entry_type(entry) != type) + { + giterr_set(GITERR_OBJECT, + "object at path '%s' is not of the asked-for type %d", + path, type); + error = GIT_EINVALIDSPEC; + goto cleanup; + } + + error = git_tree_entry_to_object(out, git_object_owner(treeish), entry); + +cleanup: + git_tree_entry_free(entry); + git_tree_free(tree); + return error; +} + +int git_object_short_id(git_buf *out, const git_object *obj) +{ + git_repository *repo; + int len = GIT_ABBREV_DEFAULT, error; + git_oid id = {{0}}; + git_odb *odb; + + assert(out && obj); + + git_buf_sanitize(out); + repo = git_object_owner(obj); + + if ((error = git_repository__cvar(&len, repo, GIT_CVAR_ABBREV)) < 0) + return error; + + if ((error = git_repository_odb(&odb, repo)) < 0) + return error; + + while (len < GIT_OID_HEXSZ) { + /* set up short oid */ + memcpy(&id.id, &obj->cached.oid.id, (len + 1) / 2); + if (len & 1) + id.id[len / 2] &= 0xf0; + + error = git_odb_exists_prefix(NULL, odb, &id, len); + if (error != GIT_EAMBIGUOUS) + break; + + giterr_clear(); + len++; + } + + if (!error && !(error = git_buf_grow(out, len + 1))) { + git_oid_tostr(out->ptr, len + 1, &id); + out->size = len; + } + + git_odb_free(odb); + + return error; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/object.h b/deps/libgit2-sys-0.2.17/libgit2/src/object.h new file mode 100644 index 000000000..d187c55b7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/object.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_object_h__ +#define INCLUDE_object_h__ + +/** Base git object for inheritance */ +struct git_object { + git_cached_obj cached; + git_repository *repo; +}; + +/* fully free the object; internal method, DO NOT EXPORT */ +void git_object__free(void *object); + +int git_object__from_odb_object( + git_object **object_out, + git_repository *repo, + git_odb_object *odb_obj, + git_otype type); + +int git_object__resolve_to_type(git_object **obj, git_otype type); + +int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header); + +void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/object_api.c b/deps/libgit2-sys-0.2.17/libgit2/src/object_api.c new file mode 100644 index 000000000..838bba323 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/object_api.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2/object.h" + +#include "common.h" +#include "repository.h" + +#include "commit.h" +#include "tree.h" +#include "blob.h" +#include "tag.h" + +/** + * Blob + */ +int git_commit_lookup(git_commit **out, git_repository *repo, const git_oid *id) +{ + return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT); +} + +int git_commit_lookup_prefix(git_commit **out, git_repository *repo, const git_oid *id, size_t len) +{ + return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT); +} + +void git_commit_free(git_commit *obj) +{ + git_object_free((git_object *)obj); +} + +const git_oid *git_commit_id(const git_commit *obj) +{ + return git_object_id((const git_object *)obj); +} + +git_repository *git_commit_owner(const git_commit *obj) +{ + return git_object_owner((const git_object *)obj); +} + + +/** + * Tree + */ +int git_tree_lookup(git_tree **out, git_repository *repo, const git_oid *id) +{ + return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TREE); +} + +int git_tree_lookup_prefix(git_tree **out, git_repository *repo, const git_oid *id, size_t len) +{ + return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_TREE); +} + +void git_tree_free(git_tree *obj) +{ + git_object_free((git_object *)obj); +} + +const git_oid *git_tree_id(const git_tree *obj) +{ + return git_object_id((const git_object *)obj); +} + +git_repository *git_tree_owner(const git_tree *obj) +{ + return git_object_owner((const git_object *)obj); +} + + +/** + * Tag + */ +int git_tag_lookup(git_tag **out, git_repository *repo, const git_oid *id) +{ + return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TAG); +} + +int git_tag_lookup_prefix(git_tag **out, git_repository *repo, const git_oid *id, size_t len) +{ + return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_TAG); +} + +void git_tag_free(git_tag *obj) +{ + git_object_free((git_object *)obj); +} + +const git_oid *git_tag_id(const git_tag *obj) +{ + return git_object_id((const git_object *)obj); +} + +git_repository *git_tag_owner(const git_tag *obj) +{ + return git_object_owner((const git_object *)obj); +} + +/** + * Blob + */ +int git_blob_lookup(git_blob **out, git_repository *repo, const git_oid *id) +{ + return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_BLOB); +} + +int git_blob_lookup_prefix(git_blob **out, git_repository *repo, const git_oid *id, size_t len) +{ + return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_BLOB); +} + +void git_blob_free(git_blob *obj) +{ + git_object_free((git_object *)obj); +} + +const git_oid *git_blob_id(const git_blob *obj) +{ + return git_object_id((const git_object *)obj); +} + +git_repository *git_blob_owner(const git_blob *obj) +{ + return git_object_owner((const git_object *)obj); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/odb.c b/deps/libgit2-sys-0.2.17/libgit2/src/odb.c new file mode 100644 index 000000000..b1d606b4d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/odb.c @@ -0,0 +1,1157 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include +#include "git2/object.h" +#include "git2/sys/odb_backend.h" +#include "fileops.h" +#include "hash.h" +#include "odb.h" +#include "delta-apply.h" +#include "filter.h" +#include "repository.h" + +#include "git2/odb_backend.h" +#include "git2/oid.h" + +#define GIT_ALTERNATES_FILE "info/alternates" + +/* TODO: is this correct? */ +#define GIT_LOOSE_PRIORITY 2 +#define GIT_PACKED_PRIORITY 1 + +#define GIT_ALTERNATES_MAX_DEPTH 5 + +typedef struct +{ + git_odb_backend *backend; + int priority; + bool is_alternate; + ino_t disk_inode; +} backend_internal; + +static git_cache *odb_cache(git_odb *odb) +{ + if (odb->rc.owner != NULL) { + git_repository *owner = odb->rc.owner; + return &owner->objects; + } + + return &odb->own_cache; +} + +static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth); + +int git_odb__format_object_header(char *hdr, size_t n, size_t obj_len, git_otype obj_type) +{ + const char *type_str = git_object_type2string(obj_type); + int len = p_snprintf(hdr, n, "%s %"PRIuZ, type_str, obj_len); + assert(len > 0 && len <= (int)n); + return len+1; +} + +int git_odb__hashobj(git_oid *id, git_rawobj *obj) +{ + git_buf_vec vec[2]; + char header[64]; + int hdrlen; + + assert(id && obj); + + if (!git_object_typeisloose(obj->type)) + return -1; + + if (!obj->data && obj->len != 0) + return -1; + + hdrlen = git_odb__format_object_header(header, sizeof(header), obj->len, obj->type); + + vec[0].data = header; + vec[0].len = hdrlen; + vec[1].data = obj->data; + vec[1].len = obj->len; + + git_hash_vec(id, vec, 2); + + return 0; +} + + +static git_odb_object *odb_object__alloc(const git_oid *oid, git_rawobj *source) +{ + git_odb_object *object = git__calloc(1, sizeof(git_odb_object)); + + if (object != NULL) { + git_oid_cpy(&object->cached.oid, oid); + object->cached.type = source->type; + object->cached.size = source->len; + object->buffer = source->data; + } + + return object; +} + +void git_odb_object__free(void *object) +{ + if (object != NULL) { + git__free(((git_odb_object *)object)->buffer); + git__free(object); + } +} + +const git_oid *git_odb_object_id(git_odb_object *object) +{ + return &object->cached.oid; +} + +const void *git_odb_object_data(git_odb_object *object) +{ + return object->buffer; +} + +size_t git_odb_object_size(git_odb_object *object) +{ + return object->cached.size; +} + +git_otype git_odb_object_type(git_odb_object *object) +{ + return object->cached.type; +} + +int git_odb_object_dup(git_odb_object **dest, git_odb_object *source) +{ + git_cached_obj_incref(source); + *dest = source; + return 0; +} + +void git_odb_object_free(git_odb_object *object) +{ + if (object == NULL) + return; + + git_cached_obj_decref(object); +} + +int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type) +{ + int hdr_len; + char hdr[64], buffer[2048]; + git_hash_ctx ctx; + ssize_t read_len = 0; + int error = 0; + + if (!git_object_typeisloose(type)) { + giterr_set(GITERR_INVALID, "Invalid object type for hash"); + return -1; + } + + if ((error = git_hash_ctx_init(&ctx)) < 0) + return -1; + + hdr_len = git_odb__format_object_header(hdr, sizeof(hdr), size, type); + + if ((error = git_hash_update(&ctx, hdr, hdr_len)) < 0) + goto done; + + while (size > 0 && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) { + if ((error = git_hash_update(&ctx, buffer, read_len)) < 0) + goto done; + + size -= read_len; + } + + /* If p_read returned an error code, the read obviously failed. + * If size is not zero, the file was truncated after we originally + * stat'd it, so we consider this a read failure too */ + if (read_len < 0 || size > 0) { + giterr_set(GITERR_OS, "Error reading file for hashing"); + error = -1; + + goto done; + } + + error = git_hash_final(out, &ctx); + +done: + git_hash_ctx_cleanup(&ctx); + return error; +} + +int git_odb__hashfd_filtered( + git_oid *out, git_file fd, size_t size, git_otype type, git_filter_list *fl) +{ + int error; + git_buf raw = GIT_BUF_INIT; + + if (!fl) + return git_odb__hashfd(out, fd, size, type); + + /* size of data is used in header, so we have to read the whole file + * into memory to apply filters before beginning to calculate the hash + */ + + if (!(error = git_futils_readbuffer_fd(&raw, fd, size))) { + git_buf post = GIT_BUF_INIT; + + error = git_filter_list_apply_to_data(&post, fl, &raw); + + git_buf_free(&raw); + + if (!error) + error = git_odb_hash(out, post.ptr, post.size, type); + + git_buf_free(&post); + } + + return error; +} + +int git_odb__hashlink(git_oid *out, const char *path) +{ + struct stat st; + int size; + int result; + + if (git_path_lstat(path, &st) < 0) + return -1; + + if (!git__is_int(st.st_size) || (int)st.st_size < 0) { + giterr_set(GITERR_FILESYSTEM, "File size overflow for 32-bit systems"); + return -1; + } + + size = (int)st.st_size; + + if (S_ISLNK(st.st_mode)) { + char *link_data; + int read_len; + size_t alloc_size; + + GITERR_CHECK_ALLOC_ADD(&alloc_size, size, 1); + link_data = git__malloc(alloc_size); + GITERR_CHECK_ALLOC(link_data); + + read_len = p_readlink(path, link_data, size); + link_data[size] = '\0'; + if (read_len != size) { + giterr_set(GITERR_OS, "Failed to read symlink data for '%s'", path); + git__free(link_data); + return -1; + } + + result = git_odb_hash(out, link_data, size, GIT_OBJ_BLOB); + git__free(link_data); + } else { + int fd = git_futils_open_ro(path); + if (fd < 0) + return -1; + result = git_odb__hashfd(out, fd, size, GIT_OBJ_BLOB); + p_close(fd); + } + + return result; +} + +int git_odb_hashfile(git_oid *out, const char *path, git_otype type) +{ + git_off_t size; + int result, fd = git_futils_open_ro(path); + if (fd < 0) + return fd; + + if ((size = git_futils_filesize(fd)) < 0 || !git__is_sizet(size)) { + giterr_set(GITERR_OS, "File size overflow for 32-bit systems"); + p_close(fd); + return -1; + } + + result = git_odb__hashfd(out, fd, (size_t)size, type); + p_close(fd); + return result; +} + +int git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type) +{ + git_rawobj raw; + + assert(id); + + raw.data = (void *)data; + raw.len = len; + raw.type = type; + + return git_odb__hashobj(id, &raw); +} + +/** + * FAKE WSTREAM + */ + +typedef struct { + git_odb_stream stream; + char *buffer; + size_t size, written; + git_otype type; +} fake_wstream; + +static int fake_wstream__fwrite(git_odb_stream *_stream, const git_oid *oid) +{ + fake_wstream *stream = (fake_wstream *)_stream; + return _stream->backend->write(_stream->backend, oid, stream->buffer, stream->size, stream->type); +} + +static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t len) +{ + fake_wstream *stream = (fake_wstream *)_stream; + + if (stream->written + len > stream->size) + return -1; + + memcpy(stream->buffer + stream->written, data, len); + stream->written += len; + return 0; +} + +static void fake_wstream__free(git_odb_stream *_stream) +{ + fake_wstream *stream = (fake_wstream *)_stream; + + git__free(stream->buffer); + git__free(stream); +} + +static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, size_t size, git_otype type) +{ + fake_wstream *stream; + + stream = git__calloc(1, sizeof(fake_wstream)); + GITERR_CHECK_ALLOC(stream); + + stream->size = size; + stream->type = type; + stream->buffer = git__malloc(size); + if (stream->buffer == NULL) { + git__free(stream); + return -1; + } + + stream->stream.backend = backend; + stream->stream.read = NULL; /* read only */ + stream->stream.write = &fake_wstream__write; + stream->stream.finalize_write = &fake_wstream__fwrite; + stream->stream.free = &fake_wstream__free; + stream->stream.mode = GIT_STREAM_WRONLY; + + *stream_p = (git_odb_stream *)stream; + return 0; +} + +/*********************************************************** + * + * OBJECT DATABASE PUBLIC API + * + * Public calls for the ODB functionality + * + ***********************************************************/ + +static int backend_sort_cmp(const void *a, const void *b) +{ + const backend_internal *backend_a = (const backend_internal *)(a); + const backend_internal *backend_b = (const backend_internal *)(b); + + if (backend_a->is_alternate == backend_b->is_alternate) + return (backend_b->priority - backend_a->priority); + + return backend_a->is_alternate ? 1 : -1; +} + +int git_odb_new(git_odb **out) +{ + git_odb *db = git__calloc(1, sizeof(*db)); + GITERR_CHECK_ALLOC(db); + + if (git_cache_init(&db->own_cache) < 0 || + git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) { + git__free(db); + return -1; + } + + *out = db; + GIT_REFCOUNT_INC(db); + return 0; +} + +static int add_backend_internal( + git_odb *odb, git_odb_backend *backend, + int priority, bool is_alternate, ino_t disk_inode) +{ + backend_internal *internal; + + assert(odb && backend); + + GITERR_CHECK_VERSION(backend, GIT_ODB_BACKEND_VERSION, "git_odb_backend"); + + /* Check if the backend is already owned by another ODB */ + assert(!backend->odb || backend->odb == odb); + + internal = git__malloc(sizeof(backend_internal)); + GITERR_CHECK_ALLOC(internal); + + internal->backend = backend; + internal->priority = priority; + internal->is_alternate = is_alternate; + internal->disk_inode = disk_inode; + + if (git_vector_insert(&odb->backends, internal) < 0) { + git__free(internal); + return -1; + } + + git_vector_sort(&odb->backends); + internal->backend->odb = odb; + return 0; +} + +int git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority) +{ + return add_backend_internal(odb, backend, priority, false, 0); +} + +int git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority) +{ + return add_backend_internal(odb, backend, priority, true, 0); +} + +size_t git_odb_num_backends(git_odb *odb) +{ + assert(odb); + return odb->backends.length; +} + +static int git_odb__error_unsupported_in_backend(const char *action) +{ + giterr_set(GITERR_ODB, + "Cannot %s - unsupported in the loaded odb backends", action); + return -1; +} + + +int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos) +{ + backend_internal *internal; + + assert(out && odb); + internal = git_vector_get(&odb->backends, pos); + + if (internal && internal->backend) { + *out = internal->backend; + return 0; + } + + giterr_set(GITERR_ODB, "No ODB backend loaded at index %" PRIuZ, pos); + return GIT_ENOTFOUND; +} + +static int add_default_backends( + git_odb *db, const char *objects_dir, + bool as_alternates, int alternate_depth) +{ + size_t i; + struct stat st; + ino_t inode; + git_odb_backend *loose, *packed; + + /* TODO: inodes are not really relevant on Win32, so we need to find + * a cross-platform workaround for this */ +#ifdef GIT_WIN32 + GIT_UNUSED(i); + GIT_UNUSED(st); + + inode = 0; +#else + if (p_stat(objects_dir, &st) < 0) { + if (as_alternates) + return 0; + + giterr_set(GITERR_ODB, "Failed to load object database in '%s'", objects_dir); + return -1; + } + + inode = st.st_ino; + + for (i = 0; i < db->backends.length; ++i) { + backend_internal *backend = git_vector_get(&db->backends, i); + if (backend->disk_inode == inode) + return 0; + } +#endif + + /* add the loose object backend */ + if (git_odb_backend_loose(&loose, objects_dir, -1, 0, 0, 0) < 0 || + add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0) + return -1; + + /* add the packed file backend */ + if (git_odb_backend_pack(&packed, objects_dir) < 0 || + add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates, inode) < 0) + return -1; + + return load_alternates(db, objects_dir, alternate_depth); +} + +static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth) +{ + git_buf alternates_path = GIT_BUF_INIT; + git_buf alternates_buf = GIT_BUF_INIT; + char *buffer; + const char *alternate; + int result = 0; + + /* Git reports an error, we just ignore anything deeper */ + if (alternate_depth > GIT_ALTERNATES_MAX_DEPTH) + return 0; + + if (git_buf_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0) + return -1; + + if (git_path_exists(alternates_path.ptr) == false) { + git_buf_free(&alternates_path); + return 0; + } + + if (git_futils_readbuffer(&alternates_buf, alternates_path.ptr) < 0) { + git_buf_free(&alternates_path); + return -1; + } + + buffer = (char *)alternates_buf.ptr; + + /* add each alternate as a new backend; one alternate per line */ + while ((alternate = git__strtok(&buffer, "\r\n")) != NULL) { + if (*alternate == '\0' || *alternate == '#') + continue; + + /* + * Relative path: build based on the current `objects` + * folder. However, relative paths are only allowed in + * the current repository. + */ + if (*alternate == '.' && !alternate_depth) { + if ((result = git_buf_joinpath(&alternates_path, objects_dir, alternate)) < 0) + break; + alternate = git_buf_cstr(&alternates_path); + } + + if ((result = add_default_backends(odb, alternate, true, alternate_depth + 1)) < 0) + break; + } + + git_buf_free(&alternates_path); + git_buf_free(&alternates_buf); + + return result; +} + +int git_odb_add_disk_alternate(git_odb *odb, const char *path) +{ + return add_default_backends(odb, path, true, 0); +} + +int git_odb_open(git_odb **out, const char *objects_dir) +{ + git_odb *db; + + assert(out && objects_dir); + + *out = NULL; + + if (git_odb_new(&db) < 0) + return -1; + + if (add_default_backends(db, objects_dir, 0, 0) < 0) { + git_odb_free(db); + return -1; + } + + *out = db; + return 0; +} + +static void odb_free(git_odb *db) +{ + size_t i; + + for (i = 0; i < db->backends.length; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *backend = internal->backend; + + if (backend->free) backend->free(backend); + else git__free(backend); + + git__free(internal); + } + + git_vector_free(&db->backends); + git_cache_free(&db->own_cache); + + git__memzero(db, sizeof(*db)); + git__free(db); +} + +void git_odb_free(git_odb *db) +{ + if (db == NULL) + return; + + GIT_REFCOUNT_DEC(db, odb_free); +} + +int git_odb_exists(git_odb *db, const git_oid *id) +{ + git_odb_object *object; + size_t i; + bool found = false; + + assert(db && id); + + if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { + git_odb_object_free(object); + return (int)true; + } + + for (i = 0; i < db->backends.length && !found; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (b->exists != NULL) + found = (bool)b->exists(b, id); + } + + return (int)found; +} + +int git_odb_exists_prefix( + git_oid *out, git_odb *db, const git_oid *short_id, size_t len) +{ + int error = GIT_ENOTFOUND, num_found = 0; + size_t i; + git_oid key = {{0}}, last_found = {{0}}, found; + + assert(db && short_id); + + if (len < GIT_OID_MINPREFIXLEN) + return git_odb__error_ambiguous("prefix length too short"); + if (len > GIT_OID_HEXSZ) + len = GIT_OID_HEXSZ; + + if (len == GIT_OID_HEXSZ) { + if (git_odb_exists(db, short_id)) { + if (out) + git_oid_cpy(out, short_id); + return 0; + } else { + return git_odb__error_notfound("no match for id prefix", short_id); + } + } + + /* just copy valid part of short_id */ + memcpy(&key.id, short_id->id, (len + 1) / 2); + if (len & 1) + key.id[len / 2] &= 0xF0; + + for (i = 0; i < db->backends.length; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (!b->exists_prefix) + continue; + + error = b->exists_prefix(&found, b, &key, len); + if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH) + continue; + if (error) + return error; + + /* make sure found item doesn't introduce ambiguity */ + if (num_found) { + if (git_oid__cmp(&last_found, &found)) + return git_odb__error_ambiguous("multiple matches for prefix"); + } else { + git_oid_cpy(&last_found, &found); + num_found++; + } + } + + if (!num_found) + return git_odb__error_notfound("no match for id prefix", &key); + if (out) + git_oid_cpy(out, &last_found); + + return 0; +} + +int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id) +{ + int error; + git_odb_object *object; + + error = git_odb__read_header_or_object(&object, len_p, type_p, db, id); + + if (object) + git_odb_object_free(object); + + return error; +} + +int git_odb__read_header_or_object( + git_odb_object **out, size_t *len_p, git_otype *type_p, + git_odb *db, const git_oid *id) +{ + size_t i; + int error = GIT_ENOTFOUND; + git_odb_object *object; + + assert(db && id && out && len_p && type_p); + + if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { + *len_p = object->cached.size; + *type_p = object->cached.type; + *out = object; + return 0; + } + + *out = NULL; + + for (i = 0; i < db->backends.length && error < 0; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (b->read_header != NULL) + error = b->read_header(len_p, type_p, b, id); + } + + if (!error || error == GIT_PASSTHROUGH) + return 0; + + /* + * no backend could read only the header. + * try reading the whole object and freeing the contents + */ + if ((error = git_odb_read(&object, db, id)) < 0) + return error; /* error already set - pass along */ + + *len_p = object->cached.size; + *type_p = object->cached.type; + *out = object; + + return 0; +} + +static git_oid empty_blob = {{ 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1, 0xd6, 0x43, 0x4b, 0x8b, + 0x29, 0xae, 0x77, 0x5a, 0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91 }}; +static git_oid empty_tree = {{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60, + 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04 }}; + +static int hardcoded_objects(git_rawobj *raw, const git_oid *id) +{ + if (!git_oid_cmp(id, &empty_blob)) { + raw->type = GIT_OBJ_BLOB; + raw->len = 0; + raw->data = git__calloc(1, sizeof(uint8_t)); + return 0; + } else if (!git_oid_cmp(id, &empty_tree)) { + raw->type = GIT_OBJ_TREE; + raw->len = 0; + raw->data = git__calloc(1, sizeof(uint8_t)); + return 0; + } else { + return GIT_ENOTFOUND; + } +} + +int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) +{ + size_t i, reads = 0; + int error; + git_rawobj raw; + git_odb_object *object; + + assert(out && db && id); + + *out = git_cache_get_raw(odb_cache(db), id); + if (*out != NULL) + return 0; + + error = hardcoded_objects(&raw, id); + + for (i = 0; i < db->backends.length && error < 0; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (b->read != NULL) { + ++reads; + error = b->read(&raw.data, &raw.len, &raw.type, b, id); + } + } + + if (error && error != GIT_PASSTHROUGH) { + if (!reads) + return git_odb__error_notfound("no match for id", id); + return error; + } + + giterr_clear(); + if ((object = odb_object__alloc(id, &raw)) == NULL) + return -1; + + *out = git_cache_store_raw(odb_cache(db), object); + return 0; +} + +int git_odb_read_prefix( + git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len) +{ + size_t i; + int error = GIT_ENOTFOUND; + git_oid key = {{0}}, found_full_oid = {{0}}; + git_rawobj raw; + void *data = NULL; + bool found = false; + git_odb_object *object; + + assert(out && db); + + if (len < GIT_OID_MINPREFIXLEN) + return git_odb__error_ambiguous("prefix length too short"); + if (len > GIT_OID_HEXSZ) + len = GIT_OID_HEXSZ; + + if (len == GIT_OID_HEXSZ) { + *out = git_cache_get_raw(odb_cache(db), short_id); + if (*out != NULL) + return 0; + } + + /* just copy valid part of short_id */ + memcpy(&key.id, short_id->id, (len + 1) / 2); + if (len & 1) + key.id[len / 2] &= 0xF0; + + for (i = 0; i < db->backends.length; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (b->read_prefix != NULL) { + git_oid full_oid; + error = b->read_prefix(&full_oid, &raw.data, &raw.len, &raw.type, b, &key, len); + if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH) + continue; + + if (error) + return error; + + git__free(data); + data = raw.data; + + if (found && git_oid__cmp(&full_oid, &found_full_oid)) { + git__free(raw.data); + return git_odb__error_ambiguous("multiple matches for prefix"); + } + + found_full_oid = full_oid; + found = true; + } + } + + if (!found) + return git_odb__error_notfound("no match for prefix", &key); + + if ((object = odb_object__alloc(&found_full_oid, &raw)) == NULL) + return -1; + + *out = git_cache_store_raw(odb_cache(db), object); + return 0; +} + +int git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload) +{ + unsigned int i; + backend_internal *internal; + + git_vector_foreach(&db->backends, i, internal) { + git_odb_backend *b = internal->backend; + int error = b->foreach(b, cb, payload); + if (error < 0) + return error; + } + + return 0; +} + +int git_odb_write( + git_oid *oid, git_odb *db, const void *data, size_t len, git_otype type) +{ + size_t i; + int error = GIT_ERROR; + git_odb_stream *stream; + + assert(oid && db); + + git_odb_hash(oid, data, len, type); + if (git_odb_exists(db, oid)) + return 0; + + for (i = 0; i < db->backends.length && error < 0; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + /* we don't write in alternates! */ + if (internal->is_alternate) + continue; + + if (b->write != NULL) + error = b->write(b, oid, data, len, type); + } + + if (!error || error == GIT_PASSTHROUGH) + return 0; + + /* if no backends were able to write the object directly, we try a + * streaming write to the backends; just write the whole object into the + * stream in one push + */ + if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0) + return error; + + stream->write(stream, data, len); + error = stream->finalize_write(stream, oid); + git_odb_stream_free(stream); + + return error; +} + +static void hash_header(git_hash_ctx *ctx, size_t size, git_otype type) +{ + char header[64]; + int hdrlen; + + hdrlen = git_odb__format_object_header(header, sizeof(header), size, type); + git_hash_update(ctx, header, hdrlen); +} + +int git_odb_open_wstream( + git_odb_stream **stream, git_odb *db, size_t size, git_otype type) +{ + size_t i, writes = 0; + int error = GIT_ERROR; + git_hash_ctx *ctx = NULL; + + assert(stream && db); + + for (i = 0; i < db->backends.length && error < 0; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + /* we don't write in alternates! */ + if (internal->is_alternate) + continue; + + if (b->writestream != NULL) { + ++writes; + error = b->writestream(stream, b, size, type); + } else if (b->write != NULL) { + ++writes; + error = init_fake_wstream(stream, b, size, type); + } + } + + if (error < 0) { + if (error == GIT_PASSTHROUGH) + error = 0; + else if (!writes) + error = git_odb__error_unsupported_in_backend("write object"); + + goto done; + } + + ctx = git__malloc(sizeof(git_hash_ctx)); + GITERR_CHECK_ALLOC(ctx); + + if ((error = git_hash_ctx_init(ctx)) < 0) + goto done; + + hash_header(ctx, size, type); + (*stream)->hash_ctx = ctx; + + (*stream)->declared_size = size; + (*stream)->received_bytes = 0; + +done: + return error; +} + +static int git_odb_stream__invalid_length( + const git_odb_stream *stream, + const char *action) +{ + giterr_set(GITERR_ODB, + "Cannot %s - " + "Invalid length. %"PRIuZ" was expected. The " + "total size of the received chunks amounts to %"PRIuZ".", + action, stream->declared_size, stream->received_bytes); + + return -1; +} + +int git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len) +{ + git_hash_update(stream->hash_ctx, buffer, len); + + stream->received_bytes += len; + + if (stream->received_bytes > stream->declared_size) + return git_odb_stream__invalid_length(stream, + "stream_write()"); + + return stream->write(stream, buffer, len); +} + +int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream) +{ + if (stream->received_bytes != stream->declared_size) + return git_odb_stream__invalid_length(stream, + "stream_finalize_write()"); + + git_hash_final(out, stream->hash_ctx); + + if (git_odb_exists(stream->backend->odb, out)) + return 0; + + return stream->finalize_write(stream, out); +} + +int git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len) +{ + return stream->read(stream, buffer, len); +} + +void git_odb_stream_free(git_odb_stream *stream) +{ + if (stream == NULL) + return; + + git_hash_ctx_cleanup(stream->hash_ctx); + git__free(stream->hash_ctx); + stream->free(stream); +} + +int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid) +{ + size_t i, reads = 0; + int error = GIT_ERROR; + + assert(stream && db); + + for (i = 0; i < db->backends.length && error < 0; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (b->readstream != NULL) { + ++reads; + error = b->readstream(stream, b, oid); + } + } + + if (error == GIT_PASSTHROUGH) + error = 0; + if (error < 0 && !reads) + error = git_odb__error_unsupported_in_backend("read object streamed"); + + return error; +} + +int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer_progress_cb progress_cb, void *progress_payload) +{ + size_t i, writes = 0; + int error = GIT_ERROR; + + assert(out && db); + + for (i = 0; i < db->backends.length && error < 0; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + /* we don't write in alternates! */ + if (internal->is_alternate) + continue; + + if (b->writepack != NULL) { + ++writes; + error = b->writepack(out, b, db, progress_cb, progress_payload); + } + } + + if (error == GIT_PASSTHROUGH) + error = 0; + if (error < 0 && !writes) + error = git_odb__error_unsupported_in_backend("write pack"); + + return error; +} + +void *git_odb_backend_malloc(git_odb_backend *backend, size_t len) +{ + GIT_UNUSED(backend); + return git__malloc(len); +} + +int git_odb_refresh(struct git_odb *db) +{ + size_t i; + assert(db); + + for (i = 0; i < db->backends.length; ++i) { + backend_internal *internal = git_vector_get(&db->backends, i); + git_odb_backend *b = internal->backend; + + if (b->refresh != NULL) { + int error = b->refresh(b); + if (error < 0) + return error; + } + } + + return 0; +} + +int git_odb__error_notfound(const char *message, const git_oid *oid) +{ + if (oid != NULL) { + char oid_str[GIT_OID_HEXSZ + 1]; + git_oid_tostr(oid_str, sizeof(oid_str), oid); + giterr_set(GITERR_ODB, "Object not found - %s (%s)", message, oid_str); + } else + giterr_set(GITERR_ODB, "Object not found - %s", message); + + return GIT_ENOTFOUND; +} + +int git_odb__error_ambiguous(const char *message) +{ + giterr_set(GITERR_ODB, "Ambiguous SHA1 prefix - %s", message); + return GIT_EAMBIGUOUS; +} + +int git_odb_init_backend(git_odb_backend *backend, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + backend, version, git_odb_backend, GIT_ODB_BACKEND_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/odb.h b/deps/libgit2-sys-0.2.17/libgit2/src/odb.h new file mode 100644 index 000000000..61dd9a7fd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/odb.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_odb_h__ +#define INCLUDE_odb_h__ + +#include "git2/odb.h" +#include "git2/oid.h" +#include "git2/types.h" + +#include "vector.h" +#include "cache.h" +#include "posix.h" +#include "filter.h" + +#define GIT_OBJECTS_DIR "objects/" +#define GIT_OBJECT_DIR_MODE 0777 +#define GIT_OBJECT_FILE_MODE 0444 + +/* DO NOT EXPORT */ +typedef struct { + void *data; /**< Raw, decompressed object data. */ + size_t len; /**< Total number of bytes in data. */ + git_otype type; /**< Type of this object. */ +} git_rawobj; + +/* EXPORT */ +struct git_odb_object { + git_cached_obj cached; + void *buffer; +}; + +/* EXPORT */ +struct git_odb { + git_refcount rc; + git_vector backends; + git_cache own_cache; +}; + +/* + * Hash a git_rawobj internally. + * The `git_rawobj` is supposed to be previously initialized + */ +int git_odb__hashobj(git_oid *id, git_rawobj *obj); + +/* + * Format the object header such as it would appear in the on-disk object + */ +int git_odb__format_object_header(char *hdr, size_t n, size_t obj_len, git_otype obj_type); +/* + * Hash an open file descriptor. + * This is a performance call when the contents of a fd need to be hashed, + * but the fd is already open and we have the size of the contents. + * + * Saves us some `stat` calls. + * + * The fd is never closed, not even on error. It must be opened and closed + * by the caller + */ +int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type); + +/* + * Hash an open file descriptor applying an array of filters + * Acts just like git_odb__hashfd with the addition of filters... + */ +int git_odb__hashfd_filtered( + git_oid *out, git_file fd, size_t len, git_otype type, git_filter_list *fl); + +/* + * Hash a `path`, assuming it could be a POSIX symlink: if the path is a + * symlink, then the raw contents of the symlink will be hashed. Otherwise, + * this will fallback to `git_odb__hashfd`. + * + * The hash type for this call is always `GIT_OBJ_BLOB` because symlinks may + * only point to blobs. + */ +int git_odb__hashlink(git_oid *out, const char *path); + +/* + * Generate a GIT_ENOTFOUND error for the ODB. + */ +int git_odb__error_notfound(const char *message, const git_oid *oid); + +/* + * Generate a GIT_EAMBIGUOUS error for the ODB. + */ +int git_odb__error_ambiguous(const char *message); + +/* + * Attempt to read object header or just return whole object if it could + * not be read. + */ +int git_odb__read_header_or_object( + git_odb_object **out, size_t *len_p, git_otype *type_p, + git_odb *db, const git_oid *id); + +/* fully free the object; internal method, DO NOT EXPORT */ +void git_odb_object__free(void *object); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/odb_loose.c b/deps/libgit2-sys-0.2.17/libgit2/src/odb_loose.c new file mode 100644 index 000000000..bfd95588b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/odb_loose.c @@ -0,0 +1,978 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include +#include "git2/object.h" +#include "git2/sys/odb_backend.h" +#include "fileops.h" +#include "hash.h" +#include "odb.h" +#include "delta-apply.h" +#include "filebuf.h" + +#include "git2/odb_backend.h" +#include "git2/types.h" + +typedef struct { /* object header data */ + git_otype type; /* object type */ + size_t size; /* object size */ +} obj_hdr; + +typedef struct { + git_odb_stream stream; + git_filebuf fbuf; +} loose_writestream; + +typedef struct loose_backend { + git_odb_backend parent; + + int object_zlib_level; /** loose object zlib compression level. */ + int fsync_object_files; /** loose object file fsync flag. */ + mode_t object_file_mode; + mode_t object_dir_mode; + + size_t objects_dirlen; + char objects_dir[GIT_FLEX_ARRAY]; +} loose_backend; + +/* State structure for exploring directories, + * in order to locate objects matching a short oid. + */ +typedef struct { + size_t dir_len; + unsigned char short_oid[GIT_OID_HEXSZ]; /* hex formatted oid to match */ + size_t short_oid_len; + int found; /* number of matching + * objects already found */ + unsigned char res_oid[GIT_OID_HEXSZ]; /* hex formatted oid of + * the object found */ +} loose_locate_object_state; + + +/*********************************************************** + * + * MISCELLANEOUS HELPER FUNCTIONS + * + ***********************************************************/ + +static int object_file_name( + git_buf *name, const loose_backend *be, const git_oid *id) +{ + size_t alloclen; + + /* expand length for object root + 40 hex sha1 chars + 2 * '/' + '\0' */ + GITERR_CHECK_ALLOC_ADD(&alloclen, be->objects_dirlen, GIT_OID_HEXSZ); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 3); + if (git_buf_grow(name, alloclen) < 0) + return -1; + + git_buf_set(name, be->objects_dir, be->objects_dirlen); + git_path_to_dir(name); + + /* loose object filename: aa/aaa... (41 bytes) */ + git_oid_pathfmt(name->ptr + name->size, id); + name->size += GIT_OID_HEXSZ + 1; + name->ptr[name->size] = '\0'; + + return 0; +} + +static int object_mkdir(const git_buf *name, const loose_backend *be) +{ + return git_futils_mkdir( + name->ptr + be->objects_dirlen, be->objects_dir, be->object_dir_mode, + GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST | GIT_MKDIR_VERIFY_DIR); +} + +static size_t get_binary_object_header(obj_hdr *hdr, git_buf *obj) +{ + unsigned char c; + unsigned char *data = (unsigned char *)obj->ptr; + size_t shift, size, used = 0; + + if (git_buf_len(obj) == 0) + return 0; + + c = data[used++]; + hdr->type = (c >> 4) & 7; + + size = c & 15; + shift = 4; + while (c & 0x80) { + if (git_buf_len(obj) <= used) + return 0; + if (sizeof(size_t) * 8 <= shift) + return 0; + c = data[used++]; + size += (c & 0x7f) << shift; + shift += 7; + } + hdr->size = size; + + return used; +} + +static size_t get_object_header(obj_hdr *hdr, unsigned char *data) +{ + char c, typename[10]; + size_t size, used = 0; + + /* + * type name string followed by space. + */ + while ((c = data[used]) != ' ') { + typename[used++] = c; + if (used >= sizeof(typename)) + return 0; + } + typename[used] = 0; + if (used == 0) + return 0; + hdr->type = git_object_string2type(typename); + used++; /* consume the space */ + + /* + * length follows immediately in decimal (without + * leading zeros). + */ + size = data[used++] - '0'; + if (size > 9) + return 0; + if (size) { + while ((c = data[used]) != '\0') { + size_t d = c - '0'; + if (d > 9) + break; + used++; + size = size * 10 + d; + } + } + hdr->size = size; + + /* + * the length must be followed by a zero byte + */ + if (data[used++] != '\0') + return 0; + + return used; +} + + + +/*********************************************************** + * + * ZLIB RELATED FUNCTIONS + * + ***********************************************************/ + +static void init_stream(z_stream *s, void *out, size_t len) +{ + memset(s, 0, sizeof(*s)); + s->next_out = out; + s->avail_out = (uInt)len; +} + +static void set_stream_input(z_stream *s, void *in, size_t len) +{ + s->next_in = in; + s->avail_in = (uInt)len; +} + +static void set_stream_output(z_stream *s, void *out, size_t len) +{ + s->next_out = out; + s->avail_out = (uInt)len; +} + + +static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len) +{ + int status; + + init_stream(s, out, len); + set_stream_input(s, obj->ptr, git_buf_len(obj)); + + if ((status = inflateInit(s)) < Z_OK) + return status; + + return inflate(s, 0); +} + +static int finish_inflate(z_stream *s) +{ + int status = Z_OK; + + while (status == Z_OK) + status = inflate(s, Z_FINISH); + + inflateEnd(s); + + if ((status != Z_STREAM_END) || (s->avail_in != 0)) { + giterr_set(GITERR_ZLIB, "Failed to finish ZLib inflation. Stream aborted prematurely"); + return -1; + } + + return 0; +} + +static int is_zlib_compressed_data(unsigned char *data) +{ + unsigned int w; + + w = ((unsigned int)(data[0]) << 8) + data[1]; + return (data[0] & 0x8F) == 0x08 && !(w % 31); +} + +static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen) +{ + z_stream zs; + int status = Z_OK; + + memset(&zs, 0x0, sizeof(zs)); + + zs.next_out = out; + zs.avail_out = (uInt)outlen; + + zs.next_in = in; + zs.avail_in = (uInt)inlen; + + if (inflateInit(&zs) < Z_OK) { + giterr_set(GITERR_ZLIB, "Failed to inflate buffer"); + return -1; + } + + while (status == Z_OK) + status = inflate(&zs, Z_FINISH); + + inflateEnd(&zs); + + if (status != Z_STREAM_END /* || zs.avail_in != 0 */ || + zs.total_out != outlen) + { + giterr_set(GITERR_ZLIB, "Failed to inflate buffer. Stream aborted prematurely"); + return -1; + } + + return 0; +} + +static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr) +{ + unsigned char *buf, *head = hb; + size_t tail, alloc_size; + + /* + * allocate a buffer to hold the inflated data and copy the + * initial sequence of inflated data from the tail of the + * head buffer, if any. + */ + if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr->size, 1) || + (buf = git__malloc(alloc_size)) == NULL) { + inflateEnd(s); + return NULL; + } + tail = s->total_out - used; + if (used > 0 && tail > 0) { + if (tail > hdr->size) + tail = hdr->size; + memcpy(buf, head + used, tail); + } + used = tail; + + /* + * inflate the remainder of the object data, if any + */ + if (hdr->size < used) + inflateEnd(s); + else { + set_stream_output(s, buf + used, hdr->size - used); + if (finish_inflate(s)) { + git__free(buf); + return NULL; + } + } + + return buf; +} + +/* + * At one point, there was a loose object format that was intended to + * mimic the format used in pack-files. This was to allow easy copying + * of loose object data into packs. This format is no longer used, but + * we must still read it. + */ +static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_buf *obj) +{ + unsigned char *in, *buf; + obj_hdr hdr; + size_t len, used, alloclen; + + /* + * read the object header, which is an (uncompressed) + * binary encoding of the object type and size. + */ + if ((used = get_binary_object_header(&hdr, obj)) == 0 || + !git_object_typeisloose(hdr.type)) { + giterr_set(GITERR_ODB, "Failed to inflate loose object."); + return -1; + } + + /* + * allocate a buffer and inflate the data into it + */ + GITERR_CHECK_ALLOC_ADD(&alloclen, hdr.size, 1); + buf = git__malloc(alloclen); + GITERR_CHECK_ALLOC(buf); + + in = ((unsigned char *)obj->ptr) + used; + len = obj->size - used; + if (inflate_buffer(in, len, buf, hdr.size) < 0) { + git__free(buf); + return -1; + } + buf[hdr.size] = '\0'; + + out->data = buf; + out->len = hdr.size; + out->type = hdr.type; + + return 0; +} + +static int inflate_disk_obj(git_rawobj *out, git_buf *obj) +{ + unsigned char head[64], *buf; + z_stream zs; + obj_hdr hdr; + size_t used; + + /* + * check for a pack-like loose object + */ + if (!is_zlib_compressed_data((unsigned char *)obj->ptr)) + return inflate_packlike_loose_disk_obj(out, obj); + + /* + * inflate the initial part of the io buffer in order + * to parse the object header (type and size). + */ + if (start_inflate(&zs, obj, head, sizeof(head)) < Z_OK || + (used = get_object_header(&hdr, head)) == 0 || + !git_object_typeisloose(hdr.type)) + { + giterr_set(GITERR_ODB, "Failed to inflate disk object."); + return -1; + } + + /* + * allocate a buffer and inflate the object data into it + * (including the initial sequence in the head buffer). + */ + if ((buf = inflate_tail(&zs, head, used, &hdr)) == NULL) + return -1; + buf[hdr.size] = '\0'; + + out->data = buf; + out->len = hdr.size; + out->type = hdr.type; + + return 0; +} + + + + + + +/*********************************************************** + * + * ODB OBJECT READING & WRITING + * + * Backend for the public API; read headers and full objects + * from the ODB. Write raw data to the ODB. + * + ***********************************************************/ + +static int read_loose(git_rawobj *out, git_buf *loc) +{ + int error; + git_buf obj = GIT_BUF_INIT; + + assert(out && loc); + + if (git_buf_oom(loc)) + return -1; + + out->data = NULL; + out->len = 0; + out->type = GIT_OBJ_BAD; + + if (!(error = git_futils_readbuffer(&obj, loc->ptr))) + error = inflate_disk_obj(out, &obj); + + git_buf_free(&obj); + + return error; +} + +static int read_header_loose(git_rawobj *out, git_buf *loc) +{ + int error = 0, z_return = Z_ERRNO, read_bytes; + git_file fd; + z_stream zs; + obj_hdr header_obj; + unsigned char raw_buffer[16], inflated_buffer[64]; + + assert(out && loc); + + if (git_buf_oom(loc)) + return -1; + + out->data = NULL; + + if ((fd = git_futils_open_ro(loc->ptr)) < 0) + return fd; + + init_stream(&zs, inflated_buffer, sizeof(inflated_buffer)); + + z_return = inflateInit(&zs); + + while (z_return == Z_OK) { + if ((read_bytes = p_read(fd, raw_buffer, sizeof(raw_buffer))) > 0) { + set_stream_input(&zs, raw_buffer, read_bytes); + z_return = inflate(&zs, 0); + } else + z_return = Z_STREAM_END; + } + + if ((z_return != Z_STREAM_END && z_return != Z_BUF_ERROR) + || get_object_header(&header_obj, inflated_buffer) == 0 + || git_object_typeisloose(header_obj.type) == 0) + { + giterr_set(GITERR_ZLIB, "Failed to read loose object header"); + error = -1; + } else { + out->len = header_obj.size; + out->type = header_obj.type; + } + + finish_inflate(&zs); + p_close(fd); + + return error; +} + +static int locate_object( + git_buf *object_location, + loose_backend *backend, + const git_oid *oid) +{ + int error = object_file_name(object_location, backend, oid); + + if (!error && !git_path_exists(object_location->ptr)) + return GIT_ENOTFOUND; + + return error; +} + +/* Explore an entry of a directory and see if it matches a short oid */ +static int fn_locate_object_short_oid(void *state, git_buf *pathbuf) { + loose_locate_object_state *sstate = (loose_locate_object_state *)state; + + if (git_buf_len(pathbuf) - sstate->dir_len != GIT_OID_HEXSZ - 2) { + /* Entry cannot be an object. Continue to next entry */ + return 0; + } + + if (git_path_isdir(pathbuf->ptr) == false) { + /* We are already in the directory matching the 2 first hex characters, + * compare the first ncmp characters of the oids */ + if (!memcmp(sstate->short_oid + 2, + (unsigned char *)pathbuf->ptr + sstate->dir_len, + sstate->short_oid_len - 2)) { + + if (!sstate->found) { + sstate->res_oid[0] = sstate->short_oid[0]; + sstate->res_oid[1] = sstate->short_oid[1]; + memcpy(sstate->res_oid+2, pathbuf->ptr+sstate->dir_len, GIT_OID_HEXSZ-2); + } + sstate->found++; + } + } + + if (sstate->found > 1) + return GIT_EAMBIGUOUS; + + return 0; +} + +/* Locate an object matching a given short oid */ +static int locate_object_short_oid( + git_buf *object_location, + git_oid *res_oid, + loose_backend *backend, + const git_oid *short_oid, + size_t len) +{ + char *objects_dir = backend->objects_dir; + size_t dir_len = strlen(objects_dir), alloc_len; + loose_locate_object_state state; + int error; + + /* prealloc memory for OBJ_DIR/xx/xx..38x..xx */ + GITERR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 3); + if (git_buf_grow(object_location, alloc_len) < 0) + return -1; + + git_buf_set(object_location, objects_dir, dir_len); + git_path_to_dir(object_location); + + /* save adjusted position at end of dir so it can be restored later */ + dir_len = git_buf_len(object_location); + + /* Convert raw oid to hex formatted oid */ + git_oid_fmt((char *)state.short_oid, short_oid); + + /* Explore OBJ_DIR/xx/ where xx is the beginning of hex formatted short oid */ + if (git_buf_put(object_location, (char *)state.short_oid, 3) < 0) + return -1; + object_location->ptr[object_location->size - 1] = '/'; + + /* Check that directory exists */ + if (git_path_isdir(object_location->ptr) == false) + return git_odb__error_notfound("no matching loose object for prefix", short_oid); + + state.dir_len = git_buf_len(object_location); + state.short_oid_len = len; + state.found = 0; + + /* Explore directory to find a unique object matching short_oid */ + error = git_path_direach( + object_location, 0, fn_locate_object_short_oid, &state); + if (error < 0 && error != GIT_EAMBIGUOUS) + return error; + + if (!state.found) + return git_odb__error_notfound("no matching loose object for prefix", short_oid); + + if (state.found > 1) + return git_odb__error_ambiguous("multiple matches in loose objects"); + + /* Convert obtained hex formatted oid to raw */ + error = git_oid_fromstr(res_oid, (char *)state.res_oid); + if (error) + return error; + + /* Update the location according to the oid obtained */ + GITERR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); + + git_buf_truncate(object_location, dir_len); + if (git_buf_grow(object_location, alloc_len) < 0) + return -1; + + git_oid_pathfmt(object_location->ptr + dir_len, res_oid); + + object_location->size += GIT_OID_HEXSZ + 1; + object_location->ptr[object_location->size] = '\0'; + + return 0; +} + + + + + + + + + +/*********************************************************** + * + * LOOSE BACKEND PUBLIC API + * + * Implement the git_odb_backend API calls + * + ***********************************************************/ + +static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) +{ + git_buf object_path = GIT_BUF_INIT; + git_rawobj raw; + int error; + + assert(backend && oid); + + raw.len = 0; + raw.type = GIT_OBJ_BAD; + + if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) + error = git_odb__error_notfound("no matching loose object", oid); + else if ((error = read_header_loose(&raw, &object_path)) == 0) { + *len_p = raw.len; + *type_p = raw.type; + } + + git_buf_free(&object_path); + + return error; +} + +static int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) +{ + git_buf object_path = GIT_BUF_INIT; + git_rawobj raw; + int error = 0; + + assert(backend && oid); + + if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) + error = git_odb__error_notfound("no matching loose object", oid); + else if ((error = read_loose(&raw, &object_path)) == 0) { + *buffer_p = raw.data; + *len_p = raw.len; + *type_p = raw.type; + } + + git_buf_free(&object_path); + + return error; +} + +static int loose_backend__read_prefix( + git_oid *out_oid, + void **buffer_p, + size_t *len_p, + git_otype *type_p, + git_odb_backend *backend, + const git_oid *short_oid, + size_t len) +{ + int error = 0; + + assert(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ); + + if (len == GIT_OID_HEXSZ) { + /* We can fall back to regular read method */ + error = loose_backend__read(buffer_p, len_p, type_p, backend, short_oid); + if (!error) + git_oid_cpy(out_oid, short_oid); + } else { + git_buf object_path = GIT_BUF_INIT; + git_rawobj raw; + + assert(backend && short_oid); + + if ((error = locate_object_short_oid(&object_path, out_oid, + (loose_backend *)backend, short_oid, len)) == 0 && + (error = read_loose(&raw, &object_path)) == 0) + { + *buffer_p = raw.data; + *len_p = raw.len; + *type_p = raw.type; + } + + git_buf_free(&object_path); + } + + return error; +} + +static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid) +{ + git_buf object_path = GIT_BUF_INIT; + int error; + + assert(backend && oid); + + error = locate_object(&object_path, (loose_backend *)backend, oid); + + git_buf_free(&object_path); + + return !error; +} + +static int loose_backend__exists_prefix( + git_oid *out, git_odb_backend *backend, const git_oid *short_id, size_t len) +{ + git_buf object_path = GIT_BUF_INIT; + int error; + + assert(backend && out && short_id && len >= GIT_OID_MINPREFIXLEN); + + error = locate_object_short_oid( + &object_path, out, (loose_backend *)backend, short_id, len); + + git_buf_free(&object_path); + + return error; +} + +struct foreach_state { + size_t dir_len; + git_odb_foreach_cb cb; + void *data; +}; + +GIT_INLINE(int) filename_to_oid(git_oid *oid, const char *ptr) +{ + int v, i = 0; + if (strlen(ptr) != GIT_OID_HEXSZ+1) + return -1; + + if (ptr[2] != '/') { + return -1; + } + + v = (git__fromhex(ptr[i]) << 4) | git__fromhex(ptr[i+1]); + if (v < 0) + return -1; + + oid->id[0] = (unsigned char) v; + + ptr += 3; + for (i = 0; i < 38; i += 2) { + v = (git__fromhex(ptr[i]) << 4) | git__fromhex(ptr[i + 1]); + if (v < 0) + return -1; + + oid->id[1 + i/2] = (unsigned char) v; + } + + return 0; +} + +static int foreach_object_dir_cb(void *_state, git_buf *path) +{ + git_oid oid; + struct foreach_state *state = (struct foreach_state *) _state; + + if (filename_to_oid(&oid, path->ptr + state->dir_len) < 0) + return 0; + + return giterr_set_after_callback_function( + state->cb(&oid, state->data), "git_odb_foreach"); +} + +static int foreach_cb(void *_state, git_buf *path) +{ + struct foreach_state *state = (struct foreach_state *) _state; + + /* non-dir is some stray file, ignore it */ + if (!git_path_isdir(git_buf_cstr(path))) + return 0; + + return git_path_direach(path, 0, foreach_object_dir_cb, state); +} + +static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data) +{ + char *objects_dir; + int error; + git_buf buf = GIT_BUF_INIT; + struct foreach_state state; + loose_backend *backend = (loose_backend *) _backend; + + assert(backend && cb); + + objects_dir = backend->objects_dir; + + git_buf_sets(&buf, objects_dir); + git_path_to_dir(&buf); + if (git_buf_oom(&buf)) + return -1; + + memset(&state, 0, sizeof(state)); + state.cb = cb; + state.data = data; + state.dir_len = git_buf_len(&buf); + + error = git_path_direach(&buf, 0, foreach_cb, &state); + + git_buf_free(&buf); + + return error; +} + +static int loose_backend__stream_fwrite(git_odb_stream *_stream, const git_oid *oid) +{ + loose_writestream *stream = (loose_writestream *)_stream; + loose_backend *backend = (loose_backend *)_stream->backend; + git_buf final_path = GIT_BUF_INIT; + int error = 0; + + if (object_file_name(&final_path, backend, oid) < 0 || + object_mkdir(&final_path, backend) < 0) + error = -1; + else + error = git_filebuf_commit_at( + &stream->fbuf, final_path.ptr); + + git_buf_free(&final_path); + + return error; +} + +static int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len) +{ + loose_writestream *stream = (loose_writestream *)_stream; + return git_filebuf_write(&stream->fbuf, data, len); +} + +static void loose_backend__stream_free(git_odb_stream *_stream) +{ + loose_writestream *stream = (loose_writestream *)_stream; + + git_filebuf_cleanup(&stream->fbuf); + git__free(stream); +} + +static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, size_t length, git_otype type) +{ + loose_backend *backend; + loose_writestream *stream = NULL; + char hdr[64]; + git_buf tmp_path = GIT_BUF_INIT; + int hdrlen; + + assert(_backend); + + backend = (loose_backend *)_backend; + *stream_out = NULL; + + hdrlen = git_odb__format_object_header(hdr, sizeof(hdr), length, type); + + stream = git__calloc(1, sizeof(loose_writestream)); + GITERR_CHECK_ALLOC(stream); + + stream->stream.backend = _backend; + stream->stream.read = NULL; /* read only */ + stream->stream.write = &loose_backend__stream_write; + stream->stream.finalize_write = &loose_backend__stream_fwrite; + stream->stream.free = &loose_backend__stream_free; + stream->stream.mode = GIT_STREAM_WRONLY; + + if (git_buf_joinpath(&tmp_path, backend->objects_dir, "tmp_object") < 0 || + git_filebuf_open(&stream->fbuf, tmp_path.ptr, + GIT_FILEBUF_TEMPORARY | + (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT), + backend->object_file_mode) < 0 || + stream->stream.write((git_odb_stream *)stream, hdr, hdrlen) < 0) + { + git_filebuf_cleanup(&stream->fbuf); + git__free(stream); + stream = NULL; + } + git_buf_free(&tmp_path); + *stream_out = (git_odb_stream *)stream; + + return !stream ? -1 : 0; +} + +static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, const void *data, size_t len, git_otype type) +{ + int error = 0, header_len; + git_buf final_path = GIT_BUF_INIT; + char header[64]; + git_filebuf fbuf = GIT_FILEBUF_INIT; + loose_backend *backend; + + backend = (loose_backend *)_backend; + + /* prepare the header for the file */ + header_len = git_odb__format_object_header(header, sizeof(header), len, type); + + if (git_buf_joinpath(&final_path, backend->objects_dir, "tmp_object") < 0 || + git_filebuf_open(&fbuf, final_path.ptr, + GIT_FILEBUF_TEMPORARY | + (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT), + backend->object_file_mode) < 0) + { + error = -1; + goto cleanup; + } + + git_filebuf_write(&fbuf, header, header_len); + git_filebuf_write(&fbuf, data, len); + + if (object_file_name(&final_path, backend, oid) < 0 || + object_mkdir(&final_path, backend) < 0 || + git_filebuf_commit_at(&fbuf, final_path.ptr) < 0) + error = -1; + +cleanup: + if (error < 0) + git_filebuf_cleanup(&fbuf); + git_buf_free(&final_path); + return error; +} + +static void loose_backend__free(git_odb_backend *_backend) +{ + loose_backend *backend; + assert(_backend); + backend = (loose_backend *)_backend; + + git__free(backend); +} + +int git_odb_backend_loose( + git_odb_backend **backend_out, + const char *objects_dir, + int compression_level, + int do_fsync, + unsigned int dir_mode, + unsigned int file_mode) +{ + loose_backend *backend; + size_t objects_dirlen, alloclen; + + assert(backend_out && objects_dir); + + objects_dirlen = strlen(objects_dir); + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(loose_backend), objects_dirlen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 2); + backend = git__calloc(1, alloclen); + GITERR_CHECK_ALLOC(backend); + + backend->parent.version = GIT_ODB_BACKEND_VERSION; + backend->objects_dirlen = objects_dirlen; + memcpy(backend->objects_dir, objects_dir, objects_dirlen); + if (backend->objects_dir[backend->objects_dirlen - 1] != '/') + backend->objects_dir[backend->objects_dirlen++] = '/'; + + if (compression_level < 0) + compression_level = Z_BEST_SPEED; + + if (dir_mode == 0) + dir_mode = GIT_OBJECT_DIR_MODE; + + if (file_mode == 0) + file_mode = GIT_OBJECT_FILE_MODE; + + backend->object_zlib_level = compression_level; + backend->fsync_object_files = do_fsync; + backend->object_dir_mode = dir_mode; + backend->object_file_mode = file_mode; + + backend->parent.read = &loose_backend__read; + backend->parent.write = &loose_backend__write; + backend->parent.read_prefix = &loose_backend__read_prefix; + backend->parent.read_header = &loose_backend__read_header; + backend->parent.writestream = &loose_backend__stream; + backend->parent.exists = &loose_backend__exists; + backend->parent.exists_prefix = &loose_backend__exists_prefix; + backend->parent.foreach = &loose_backend__foreach; + backend->parent.free = &loose_backend__free; + + *backend_out = (git_odb_backend *)backend; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/odb_mempack.c b/deps/libgit2-sys-0.2.17/libgit2/src/odb_mempack.c new file mode 100644 index 000000000..34355270f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/odb_mempack.c @@ -0,0 +1,184 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "git2/object.h" +#include "git2/sys/odb_backend.h" +#include "fileops.h" +#include "hash.h" +#include "odb.h" +#include "array.h" +#include "oidmap.h" + +#include "git2/odb_backend.h" +#include "git2/types.h" +#include "git2/pack.h" + +GIT__USE_OIDMAP + +struct memobject { + git_oid oid; + size_t len; + git_otype type; + char data[]; +}; + +struct memory_packer_db { + git_odb_backend parent; + git_oidmap *objects; + git_array_t(struct memobject *) commits; +}; + +static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void *data, size_t len, git_otype type) +{ + struct memory_packer_db *db = (struct memory_packer_db *)_backend; + struct memobject *obj = NULL; + khiter_t pos; + size_t alloc_len; + int rval; + + pos = kh_put(oid, db->objects, oid, &rval); + if (rval < 0) + return -1; + + if (rval == 0) + return 0; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(struct memobject), len); + obj = git__malloc(alloc_len); + GITERR_CHECK_ALLOC(obj); + + memcpy(obj->data, data, len); + git_oid_cpy(&obj->oid, oid); + obj->len = len; + obj->type = type; + + kh_key(db->objects, pos) = &obj->oid; + kh_val(db->objects, pos) = obj; + + if (type == GIT_OBJ_COMMIT) { + struct memobject **store = git_array_alloc(db->commits); + GITERR_CHECK_ALLOC(store); + *store = obj; + } + + return 0; +} + +static int impl__exists(git_odb_backend *backend, const git_oid *oid) +{ + struct memory_packer_db *db = (struct memory_packer_db *)backend; + khiter_t pos; + + pos = kh_get(oid, db->objects, oid); + if (pos != kh_end(db->objects)) + return 1; + + return 0; +} + +static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) +{ + struct memory_packer_db *db = (struct memory_packer_db *)backend; + struct memobject *obj = NULL; + khiter_t pos; + + pos = kh_get(oid, db->objects, oid); + if (pos == kh_end(db->objects)) + return GIT_ENOTFOUND; + + obj = kh_val(db->objects, pos); + + *len_p = obj->len; + *type_p = obj->type; + *buffer_p = git__malloc(obj->len); + GITERR_CHECK_ALLOC(*buffer_p); + + memcpy(*buffer_p, obj->data, obj->len); + return 0; +} + +static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) +{ + struct memory_packer_db *db = (struct memory_packer_db *)backend; + struct memobject *obj = NULL; + khiter_t pos; + + pos = kh_get(oid, db->objects, oid); + if (pos == kh_end(db->objects)) + return GIT_ENOTFOUND; + + obj = kh_val(db->objects, pos); + + *len_p = obj->len; + *type_p = obj->type; + return 0; +} + +int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *_backend) +{ + struct memory_packer_db *db = (struct memory_packer_db *)_backend; + git_packbuilder *packbuilder; + uint32_t i; + int err = -1; + + if (git_packbuilder_new(&packbuilder, repo) < 0) + return -1; + + for (i = 0; i < db->commits.size; ++i) { + struct memobject *commit = db->commits.ptr[i]; + + err = git_packbuilder_insert_commit(packbuilder, &commit->oid); + if (err < 0) + goto cleanup; + } + + err = git_packbuilder_write_buf(pack, packbuilder); + +cleanup: + git_packbuilder_free(packbuilder); + return err; +} + +void git_mempack_reset(git_odb_backend *_backend) +{ + struct memory_packer_db *db = (struct memory_packer_db *)_backend; + struct memobject *object = NULL; + + kh_foreach_value(db->objects, object, { + git__free(object); + }); + + git_array_clear(db->commits); +} + +static void impl__free(git_odb_backend *_backend) +{ + git_mempack_reset(_backend); + git__free(_backend); +} + +int git_mempack_new(git_odb_backend **out) +{ + struct memory_packer_db *db; + + assert(out); + + db = git__calloc(1, sizeof(struct memory_packer_db)); + GITERR_CHECK_ALLOC(db); + + db->objects = git_oidmap_alloc(); + + db->parent.read = &impl__read; + db->parent.write = &impl__write; + db->parent.read_header = &impl__read_header; + db->parent.exists = &impl__exists; + db->parent.free = &impl__free; + + *out = (git_odb_backend *)db; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/odb_pack.c b/deps/libgit2-sys-0.2.17/libgit2/src/odb_pack.c new file mode 100644 index 000000000..1757cf920 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/odb_pack.c @@ -0,0 +1,691 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include +#include "git2/repository.h" +#include "git2/indexer.h" +#include "git2/sys/odb_backend.h" +#include "fileops.h" +#include "hash.h" +#include "odb.h" +#include "delta-apply.h" +#include "sha1_lookup.h" +#include "mwindow.h" +#include "pack.h" + +#include "git2/odb_backend.h" + +struct pack_backend { + git_odb_backend parent; + git_vector packs; + struct git_pack_file *last_found; + char *pack_folder; +}; + +struct pack_writepack { + struct git_odb_writepack parent; + git_indexer *indexer; +}; + +/** + * The wonderful tale of a Packed Object lookup query + * =================================================== + * A riveting and epic story of epicness and ASCII + * art, presented by yours truly, + * Sir Vicent of Marti + * + * + * Chapter 1: Once upon a time... + * Initialization of the Pack Backend + * -------------------------------------------------- + * + * # git_odb_backend_pack + * | Creates the pack backend structure, initializes the + * | callback pointers to our default read() and exist() methods, + * | and tries to preload all the known packfiles in the ODB. + * | + * |-# packfile_load_all + * | Tries to find the `pack` folder, if it exists. ODBs without + * | a pack folder are ignored altogether. If there's a `pack` folder + * | we run a `dirent` callback through every file in the pack folder + * | to find our packfiles. The packfiles are then sorted according + * | to a sorting callback. + * | + * |-# packfile_load__cb + * | | This callback is called from `dirent` with every single file + * | | inside the pack folder. We find the packs by actually locating + * | | their index (ends in ".idx"). From that index, we verify that + * | | the corresponding packfile exists and is valid, and if so, we + * | | add it to the pack list. + * | | + * | |-# packfile_check + * | Make sure that there's a packfile to back this index, and store + * | some very basic information regarding the packfile itself, + * | such as the full path, the size, and the modification time. + * | We don't actually open the packfile to check for internal consistency. + * | + * |-# packfile_sort__cb + * Sort all the preloaded packs according to some specific criteria: + * we prioritize the "newer" packs because it's more likely they + * contain the objects we are looking for, and we prioritize local + * packs over remote ones. + * + * + * + * Chapter 2: To be, or not to be... + * A standard packed `exist` query for an OID + * -------------------------------------------------- + * + * # pack_backend__exists + * | Check if the given SHA1 oid exists in any of the packs + * | that have been loaded for our ODB. + * | + * |-# pack_entry_find + * | Iterate through all the packs that have been preloaded + * | (starting by the pack where the latest object was found) + * | to try to find the OID in one of them. + * | + * |-# pack_entry_find1 + * | Check the index of an individual pack to see if the SHA1 + * | OID can be found. If we can find the offset to that SHA1 + * | inside of the index, that means the object is contained + * | inside of the packfile and we can stop searching. + * | Before returning, we verify that the packfile behing the + * | index we are searching still exists on disk. + * | + * |-# pack_entry_find_offset + * | | Mmap the actual index file to disk if it hasn't been opened + * | | yet, and run a binary search through it to find the OID. + * | | See for specifics + * | | on the Packfile Index format and how do we find entries in it. + * | | + * | |-# pack_index_open + * | | Guess the name of the index based on the full path to the + * | | packfile, open it and verify its contents. Only if the index + * | | has not been opened already. + * | | + * | |-# pack_index_check + * | Mmap the index file and do a quick run through the header + * | to guess the index version (right now we support v1 and v2), + * | and to verify that the size of the index makes sense. + * | + * |-# packfile_open + * See `packfile_open` in Chapter 3 + * + * + * + * Chapter 3: The neverending story... + * A standard packed `lookup` query for an OID + * -------------------------------------------------- + * TODO + * + */ + + +/*********************************************************** + * + * FORWARD DECLARATIONS + * + ***********************************************************/ + +static int packfile_sort__cb(const void *a_, const void *b_); + +static int packfile_load__cb(void *_data, git_buf *path); + +static int pack_entry_find(struct git_pack_entry *e, + struct pack_backend *backend, const git_oid *oid); + +/* Can find the offset of an object given + * a prefix of an identifier. + * Sets GIT_EAMBIGUOUS if short oid is ambiguous. + * This method assumes that len is between + * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ. + */ +static int pack_entry_find_prefix( + struct git_pack_entry *e, + struct pack_backend *backend, + const git_oid *short_oid, + size_t len); + + + +/*********************************************************** + * + * PACK WINDOW MANAGEMENT + * + ***********************************************************/ + +static int packfile_sort__cb(const void *a_, const void *b_) +{ + const struct git_pack_file *a = a_; + const struct git_pack_file *b = b_; + int st; + + /* + * Local packs tend to contain objects specific to our + * variant of the project than remote ones. In addition, + * remote ones could be on a network mounted filesystem. + * Favor local ones for these reasons. + */ + st = a->pack_local - b->pack_local; + if (st) + return -st; + + /* + * Younger packs tend to contain more recent objects, + * and more recent objects tend to get accessed more + * often. + */ + if (a->mtime < b->mtime) + return 1; + else if (a->mtime == b->mtime) + return 0; + + return -1; +} + + +static int packfile_load__cb(void *data, git_buf *path) +{ + struct pack_backend *backend = data; + struct git_pack_file *pack; + const char *path_str = git_buf_cstr(path); + size_t i, cmp_len = git_buf_len(path); + int error; + + if (cmp_len <= strlen(".idx") || git__suffixcmp(path_str, ".idx") != 0) + return 0; /* not an index */ + + cmp_len -= strlen(".idx"); + + for (i = 0; i < backend->packs.length; ++i) { + struct git_pack_file *p = git_vector_get(&backend->packs, i); + + if (memcmp(p->pack_name, path_str, cmp_len) == 0) + return 0; + } + + error = git_mwindow_get_pack(&pack, path->ptr); + + /* ignore missing .pack file as git does */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + return 0; + } + + if (!error) + error = git_vector_insert(&backend->packs, pack); + + return error; + +} + +static int pack_entry_find_inner( + struct git_pack_entry *e, + struct pack_backend *backend, + const git_oid *oid, + struct git_pack_file *last_found) +{ + size_t i; + + if (last_found && + git_pack_entry_find(e, last_found, oid, GIT_OID_HEXSZ) == 0) + return 0; + + for (i = 0; i < backend->packs.length; ++i) { + struct git_pack_file *p; + + p = git_vector_get(&backend->packs, i); + if (p == last_found) + continue; + + if (git_pack_entry_find(e, p, oid, GIT_OID_HEXSZ) == 0) { + backend->last_found = p; + return 0; + } + } + + return -1; +} + +static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backend, const git_oid *oid) +{ + struct git_pack_file *last_found = backend->last_found; + + if (backend->last_found && + git_pack_entry_find(e, backend->last_found, oid, GIT_OID_HEXSZ) == 0) + return 0; + + if (!pack_entry_find_inner(e, backend, oid, last_found)) + return 0; + + return git_odb__error_notfound("failed to find pack entry", oid); +} + +static int pack_entry_find_prefix( + struct git_pack_entry *e, + struct pack_backend *backend, + const git_oid *short_oid, + size_t len) +{ + int error; + size_t i; + git_oid found_full_oid = {{0}}; + bool found = false; + struct git_pack_file *last_found = backend->last_found; + + if (last_found) { + error = git_pack_entry_find(e, last_found, short_oid, len); + if (error == GIT_EAMBIGUOUS) + return error; + if (!error) { + git_oid_cpy(&found_full_oid, &e->sha1); + found = true; + } + } + + for (i = 0; i < backend->packs.length; ++i) { + struct git_pack_file *p; + + p = git_vector_get(&backend->packs, i); + if (p == last_found) + continue; + + error = git_pack_entry_find(e, p, short_oid, len); + if (error == GIT_EAMBIGUOUS) + return error; + if (!error) { + if (found && git_oid_cmp(&e->sha1, &found_full_oid)) + return git_odb__error_ambiguous("found multiple pack entries"); + git_oid_cpy(&found_full_oid, &e->sha1); + found = true; + backend->last_found = p; + } + } + + if (!found) + return git_odb__error_notfound("no matching pack entry for prefix", short_oid); + else + return 0; +} + + +/*********************************************************** + * + * PACKED BACKEND PUBLIC API + * + * Implement the git_odb_backend API calls + * + ***********************************************************/ +static int pack_backend__refresh(git_odb_backend *backend_) +{ + int error; + struct stat st; + git_buf path = GIT_BUF_INIT; + struct pack_backend *backend = (struct pack_backend *)backend_; + + if (backend->pack_folder == NULL) + return 0; + + if (p_stat(backend->pack_folder, &st) < 0 || !S_ISDIR(st.st_mode)) + return git_odb__error_notfound("failed to refresh packfiles", NULL); + + git_buf_sets(&path, backend->pack_folder); + + /* reload all packs */ + error = git_path_direach(&path, 0, packfile_load__cb, backend); + + git_buf_free(&path); + git_vector_sort(&backend->packs); + + return error; +} + +static int pack_backend__read_header_internal( + size_t *len_p, git_otype *type_p, + struct git_odb_backend *backend, const git_oid *oid) +{ + struct git_pack_entry e; + int error; + + assert(len_p && type_p && backend && oid); + + if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0) + return error; + + return git_packfile_resolve_header(len_p, type_p, e.p, e.offset); +} + +static int pack_backend__read_header( + size_t *len_p, git_otype *type_p, + struct git_odb_backend *backend, const git_oid *oid) +{ + int error; + + error = pack_backend__read_header_internal(len_p, type_p, backend, oid); + + if (error != GIT_ENOTFOUND) + return error; + + if ((error = pack_backend__refresh(backend)) < 0) + return error; + + return pack_backend__read_header_internal(len_p, type_p, backend, oid); +} + +static int pack_backend__read_internal( + void **buffer_p, size_t *len_p, git_otype *type_p, + git_odb_backend *backend, const git_oid *oid) +{ + struct git_pack_entry e; + git_rawobj raw; + int error; + + if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0 || + (error = git_packfile_unpack(&raw, e.p, &e.offset)) < 0) + return error; + + *buffer_p = raw.data; + *len_p = raw.len; + *type_p = raw.type; + + return 0; +} + +static int pack_backend__read( + void **buffer_p, size_t *len_p, git_otype *type_p, + git_odb_backend *backend, const git_oid *oid) +{ + int error; + + error = pack_backend__read_internal(buffer_p, len_p, type_p, backend, oid); + + if (error != GIT_ENOTFOUND) + return error; + + if ((error = pack_backend__refresh(backend)) < 0) + return error; + + return pack_backend__read_internal(buffer_p, len_p, type_p, backend, oid); +} + +static int pack_backend__read_prefix_internal( + git_oid *out_oid, + void **buffer_p, + size_t *len_p, + git_otype *type_p, + git_odb_backend *backend, + const git_oid *short_oid, + size_t len) +{ + int error = 0; + + if (len < GIT_OID_MINPREFIXLEN) + error = git_odb__error_ambiguous("prefix length too short"); + + else if (len >= GIT_OID_HEXSZ) { + /* We can fall back to regular read method */ + error = pack_backend__read(buffer_p, len_p, type_p, backend, short_oid); + if (!error) + git_oid_cpy(out_oid, short_oid); + } else { + struct git_pack_entry e; + git_rawobj raw; + + if ((error = pack_entry_find_prefix( + &e, (struct pack_backend *)backend, short_oid, len)) == 0 && + (error = git_packfile_unpack(&raw, e.p, &e.offset)) == 0) + { + *buffer_p = raw.data; + *len_p = raw.len; + *type_p = raw.type; + git_oid_cpy(out_oid, &e.sha1); + } + } + + return error; +} + +static int pack_backend__read_prefix( + git_oid *out_oid, + void **buffer_p, + size_t *len_p, + git_otype *type_p, + git_odb_backend *backend, + const git_oid *short_oid, + size_t len) +{ + int error; + + error = pack_backend__read_prefix_internal( + out_oid, buffer_p, len_p, type_p, backend, short_oid, len); + + if (error != GIT_ENOTFOUND) + return error; + + if ((error = pack_backend__refresh(backend)) < 0) + return error; + + return pack_backend__read_prefix_internal( + out_oid, buffer_p, len_p, type_p, backend, short_oid, len); +} + +static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid) +{ + struct git_pack_entry e; + int error; + + error = pack_entry_find(&e, (struct pack_backend *)backend, oid); + + if (error != GIT_ENOTFOUND) + return error == 0; + + if ((error = pack_backend__refresh(backend)) < 0) { + giterr_clear(); + return (int)false; + } + + return pack_entry_find(&e, (struct pack_backend *)backend, oid) == 0; +} + +static int pack_backend__exists_prefix( + git_oid *out, git_odb_backend *backend, const git_oid *short_id, size_t len) +{ + int error; + struct pack_backend *pb = (struct pack_backend *)backend; + struct git_pack_entry e = {0}; + + error = pack_entry_find_prefix(&e, pb, short_id, len); + + if (error == GIT_ENOTFOUND && !(error = pack_backend__refresh(backend))) + error = pack_entry_find_prefix(&e, pb, short_id, len); + + git_oid_cpy(out, &e.sha1); + + return error; +} + +static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data) +{ + int error; + struct git_pack_file *p; + struct pack_backend *backend; + unsigned int i; + + assert(_backend && cb); + backend = (struct pack_backend *)_backend; + + /* Make sure we know about the packfiles */ + if ((error = pack_backend__refresh(_backend)) < 0) + return error; + + git_vector_foreach(&backend->packs, i, p) { + if ((error = git_pack_foreach_entry(p, cb, data)) < 0) + return error; + } + + return 0; +} + +static int pack_backend__writepack_append(struct git_odb_writepack *_writepack, const void *data, size_t size, git_transfer_progress *stats) +{ + struct pack_writepack *writepack = (struct pack_writepack *)_writepack; + + assert(writepack); + + return git_indexer_append(writepack->indexer, data, size, stats); +} + +static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack, git_transfer_progress *stats) +{ + struct pack_writepack *writepack = (struct pack_writepack *)_writepack; + + assert(writepack); + + return git_indexer_commit(writepack->indexer, stats); +} + +static void pack_backend__writepack_free(struct git_odb_writepack *_writepack) +{ + struct pack_writepack *writepack = (struct pack_writepack *)_writepack; + + assert(writepack); + + git_indexer_free(writepack->indexer); + git__free(writepack); +} + +static int pack_backend__writepack(struct git_odb_writepack **out, + git_odb_backend *_backend, + git_odb *odb, + git_transfer_progress_cb progress_cb, + void *progress_payload) +{ + struct pack_backend *backend; + struct pack_writepack *writepack; + + assert(out && _backend); + + *out = NULL; + + backend = (struct pack_backend *)_backend; + + writepack = git__calloc(1, sizeof(struct pack_writepack)); + GITERR_CHECK_ALLOC(writepack); + + if (git_indexer_new(&writepack->indexer, + backend->pack_folder, 0, odb, progress_cb, progress_payload) < 0) { + git__free(writepack); + return -1; + } + + writepack->parent.backend = _backend; + writepack->parent.append = pack_backend__writepack_append; + writepack->parent.commit = pack_backend__writepack_commit; + writepack->parent.free = pack_backend__writepack_free; + + *out = (git_odb_writepack *)writepack; + + return 0; +} + +static void pack_backend__free(git_odb_backend *_backend) +{ + struct pack_backend *backend; + size_t i; + + assert(_backend); + + backend = (struct pack_backend *)_backend; + + for (i = 0; i < backend->packs.length; ++i) { + struct git_pack_file *p = git_vector_get(&backend->packs, i); + git_mwindow_put_pack(p); + } + + git_vector_free(&backend->packs); + git__free(backend->pack_folder); + git__free(backend); +} + +static int pack_backend__alloc(struct pack_backend **out, size_t initial_size) +{ + struct pack_backend *backend = git__calloc(1, sizeof(struct pack_backend)); + GITERR_CHECK_ALLOC(backend); + + if (git_vector_init(&backend->packs, initial_size, packfile_sort__cb) < 0) { + git__free(backend); + return -1; + } + + backend->parent.version = GIT_ODB_BACKEND_VERSION; + + backend->parent.read = &pack_backend__read; + backend->parent.read_prefix = &pack_backend__read_prefix; + backend->parent.read_header = &pack_backend__read_header; + backend->parent.exists = &pack_backend__exists; + backend->parent.exists_prefix = &pack_backend__exists_prefix; + backend->parent.refresh = &pack_backend__refresh; + backend->parent.foreach = &pack_backend__foreach; + backend->parent.writepack = &pack_backend__writepack; + backend->parent.free = &pack_backend__free; + + *out = backend; + return 0; +} + +int git_odb_backend_one_pack(git_odb_backend **backend_out, const char *idx) +{ + struct pack_backend *backend = NULL; + struct git_pack_file *packfile = NULL; + + if (pack_backend__alloc(&backend, 1) < 0) + return -1; + + if (git_mwindow_get_pack(&packfile, idx) < 0 || + git_vector_insert(&backend->packs, packfile) < 0) + { + pack_backend__free((git_odb_backend *)backend); + return -1; + } + + *backend_out = (git_odb_backend *)backend; + return 0; +} + +int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir) +{ + int error = 0; + struct pack_backend *backend = NULL; + git_buf path = GIT_BUF_INIT; + + if (git_mwindow_files_init() < 0) + return -1; + + if (pack_backend__alloc(&backend, 8) < 0) + return -1; + + if (!(error = git_buf_joinpath(&path, objects_dir, "pack")) && + git_path_isdir(git_buf_cstr(&path))) + { + backend->pack_folder = git_buf_detach(&path); + + error = pack_backend__refresh((git_odb_backend *)backend); + } + + if (error < 0) { + pack_backend__free((git_odb_backend *)backend); + backend = NULL; + } + + *backend_out = (git_odb_backend *)backend; + + git_buf_free(&path); + + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/offmap.h b/deps/libgit2-sys-0.2.17/libgit2/src/offmap.h new file mode 100644 index 000000000..0d0e51272 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/offmap.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2012 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_offmap_h__ +#define INCLUDE_offmap_h__ + +#include "common.h" +#include "git2/types.h" + +#define kmalloc git__malloc +#define kcalloc git__calloc +#define krealloc git__realloc +#define kreallocarray git__reallocarray +#define kfree git__free +#include "khash.h" + +__KHASH_TYPE(off, git_off_t, void *) +typedef khash_t(off) git_offmap; + +#define GIT__USE_OFFMAP \ + __KHASH_IMPL(off, static kh_inline, git_off_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal) + +#define git_offmap_alloc() kh_init(off) +#define git_offmap_free(h) kh_destroy(off, h), h = NULL +#define git_offmap_clear(h) kh_clear(off, h) + +#define git_offmap_num_entries(h) kh_size(h) + +#define git_offmap_lookup_index(h, k) kh_get(off, h, k) +#define git_offmap_valid_index(h, idx) (idx != kh_end(h)) + +#define git_offmap_exists(h, k) (kh_get(off, h, k) != kh_end(h)) + +#define git_offmap_value_at(h, idx) kh_val(h, idx) +#define git_offmap_set_value_at(h, idx, v) kh_val(h, idx) = v +#define git_offmap_delete_at(h, idx) kh_del(off, h, idx) + +#define git_offmap_insert(h, key, val, rval) do { \ + khiter_t __pos = kh_put(off, h, key, &rval); \ + if (rval >= 0) { \ + if (rval == 0) kh_key(h, __pos) = key; \ + kh_val(h, __pos) = val; \ + } } while (0) + +#define git_offmap_insert2(h, key, val, oldv, rval) do { \ + khiter_t __pos = kh_put(off, h, key, &rval); \ + if (rval >= 0) { \ + if (rval == 0) { \ + oldv = kh_val(h, __pos); \ + kh_key(h, __pos) = key; \ + } else { oldv = NULL; } \ + kh_val(h, __pos) = val; \ + } } while (0) + +#define git_offmap_delete(h, key) do { \ + khiter_t __pos = git_offmap_lookup_index(h, key); \ + if (git_offmap_valid_index(h, __pos)) \ + git_offmap_delete_at(h, __pos); } while (0) + +#define git_offmap_foreach kh_foreach +#define git_offmap_foreach_value kh_foreach_value + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/oid.c b/deps/libgit2-sys-0.2.17/libgit2/src/oid.c new file mode 100644 index 000000000..9fe2ebb65 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/oid.c @@ -0,0 +1,441 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "git2/oid.h" +#include "repository.h" +#include "global.h" +#include +#include + +static char to_hex[] = "0123456789abcdef"; + +static int oid_error_invalid(const char *msg) +{ + giterr_set(GITERR_INVALID, "Unable to parse OID - %s", msg); + return -1; +} + +int git_oid_fromstrn(git_oid *out, const char *str, size_t length) +{ + size_t p; + int v; + + assert(out && str); + + if (!length) + return oid_error_invalid("too short"); + + if (length > GIT_OID_HEXSZ) + return oid_error_invalid("too long"); + + memset(out->id, 0, GIT_OID_RAWSZ); + + for (p = 0; p < length; p++) { + v = git__fromhex(str[p]); + if (v < 0) + return oid_error_invalid("contains invalid characters"); + + out->id[p / 2] |= (unsigned char)(v << (p % 2 ? 0 : 4)); + } + + return 0; +} + +int git_oid_fromstrp(git_oid *out, const char *str) +{ + return git_oid_fromstrn(out, str, strlen(str)); +} + +int git_oid_fromstr(git_oid *out, const char *str) +{ + return git_oid_fromstrn(out, str, GIT_OID_HEXSZ); +} + +GIT_INLINE(char) *fmt_one(char *str, unsigned int val) +{ + *str++ = to_hex[val >> 4]; + *str++ = to_hex[val & 0xf]; + return str; +} + +void git_oid_nfmt(char *str, size_t n, const git_oid *oid) +{ + size_t i, max_i; + + if (!oid) { + memset(str, 0, n); + return; + } + if (n > GIT_OID_HEXSZ) { + memset(&str[GIT_OID_HEXSZ], 0, n - GIT_OID_HEXSZ); + n = GIT_OID_HEXSZ; + } + + max_i = n / 2; + + for (i = 0; i < max_i; i++) + str = fmt_one(str, oid->id[i]); + + if (n & 1) + *str++ = to_hex[oid->id[i] >> 4]; +} + +void git_oid_fmt(char *str, const git_oid *oid) +{ + git_oid_nfmt(str, GIT_OID_HEXSZ, oid); +} + +void git_oid_pathfmt(char *str, const git_oid *oid) +{ + size_t i; + + str = fmt_one(str, oid->id[0]); + *str++ = '/'; + for (i = 1; i < sizeof(oid->id); i++) + str = fmt_one(str, oid->id[i]); +} + +char *git_oid_tostr_s(const git_oid *oid) +{ + char *str = GIT_GLOBAL->oid_fmt; + git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid); + return str; +} + +char *git_oid_allocfmt(const git_oid *oid) +{ + char *str = git__malloc(GIT_OID_HEXSZ + 1); + if (!str) + return NULL; + git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid); + return str; +} + +char *git_oid_tostr(char *out, size_t n, const git_oid *oid) +{ + if (!out || n == 0) + return ""; + + if (n > GIT_OID_HEXSZ + 1) + n = GIT_OID_HEXSZ + 1; + + git_oid_nfmt(out, n - 1, oid); /* allow room for terminating NUL */ + out[n - 1] = '\0'; + + return out; +} + +int git_oid__parse( + git_oid *oid, const char **buffer_out, + const char *buffer_end, const char *header) +{ + const size_t sha_len = GIT_OID_HEXSZ; + const size_t header_len = strlen(header); + + const char *buffer = *buffer_out; + + if (buffer + (header_len + sha_len + 1) > buffer_end) + return -1; + + if (memcmp(buffer, header, header_len) != 0) + return -1; + + if (buffer[header_len + sha_len] != '\n') + return -1; + + if (git_oid_fromstr(oid, buffer + header_len) < 0) + return -1; + + *buffer_out = buffer + (header_len + sha_len + 1); + + return 0; +} + +void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid) +{ + char hex_oid[GIT_OID_HEXSZ]; + + git_oid_fmt(hex_oid, oid); + git_buf_puts(buf, header); + git_buf_put(buf, hex_oid, GIT_OID_HEXSZ); + git_buf_putc(buf, '\n'); +} + +void git_oid_fromraw(git_oid *out, const unsigned char *raw) +{ + memcpy(out->id, raw, sizeof(out->id)); +} + +void git_oid_cpy(git_oid *out, const git_oid *src) +{ + memcpy(out->id, src->id, sizeof(out->id)); +} + +int git_oid_cmp(const git_oid *a, const git_oid *b) +{ + return git_oid__cmp(a, b); +} + +int git_oid_equal(const git_oid *a, const git_oid *b) +{ + return (git_oid__cmp(a, b) == 0); +} + +int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, size_t len) +{ + const unsigned char *a = oid_a->id; + const unsigned char *b = oid_b->id; + + if (len > GIT_OID_HEXSZ) + len = GIT_OID_HEXSZ; + + while (len > 1) { + if (*a != *b) + return 1; + a++; + b++; + len -= 2; + }; + + if (len) + if ((*a ^ *b) & 0xf0) + return 1; + + return 0; +} + +int git_oid_strcmp(const git_oid *oid_a, const char *str) +{ + const unsigned char *a; + unsigned char strval; + int hexval; + + for (a = oid_a->id; *str && (a - oid_a->id) < GIT_OID_RAWSZ; ++a) { + if ((hexval = git__fromhex(*str++)) < 0) + return -1; + strval = (unsigned char)(hexval << 4); + if (*str) { + if ((hexval = git__fromhex(*str++)) < 0) + return -1; + strval |= hexval; + } + if (*a != strval) + return (*a - strval); + } + + return 0; +} + +int git_oid_streq(const git_oid *oid_a, const char *str) +{ + return git_oid_strcmp(oid_a, str) == 0 ? 0 : -1; +} + +int git_oid_iszero(const git_oid *oid_a) +{ + const unsigned char *a = oid_a->id; + unsigned int i; + for (i = 0; i < GIT_OID_RAWSZ; ++i, ++a) + if (*a != 0) + return 0; + return 1; +} + +typedef short node_index; + +typedef union { + const char *tail; + node_index children[16]; +} trie_node; + +struct git_oid_shorten { + trie_node *nodes; + size_t node_count, size; + int min_length, full; +}; + +static int resize_trie(git_oid_shorten *self, size_t new_size) +{ + self->nodes = git__reallocarray(self->nodes, new_size, sizeof(trie_node)); + GITERR_CHECK_ALLOC(self->nodes); + + if (new_size > self->size) { + memset(&self->nodes[self->size], 0x0, (new_size - self->size) * sizeof(trie_node)); + } + + self->size = new_size; + return 0; +} + +static trie_node *push_leaf(git_oid_shorten *os, node_index idx, int push_at, const char *oid) +{ + trie_node *node, *leaf; + node_index idx_leaf; + + if (os->node_count >= os->size) { + if (resize_trie(os, os->size * 2) < 0) + return NULL; + } + + idx_leaf = (node_index)os->node_count++; + + if (os->node_count == SHRT_MAX) { + os->full = 1; + return NULL; + } + + node = &os->nodes[idx]; + node->children[push_at] = -idx_leaf; + + leaf = &os->nodes[idx_leaf]; + leaf->tail = oid; + + return node; +} + +git_oid_shorten *git_oid_shorten_new(size_t min_length) +{ + git_oid_shorten *os; + + assert((size_t)((int)min_length) == min_length); + + os = git__calloc(1, sizeof(git_oid_shorten)); + if (os == NULL) + return NULL; + + if (resize_trie(os, 16) < 0) { + git__free(os); + return NULL; + } + + os->node_count = 1; + os->min_length = (int)min_length; + + return os; +} + +void git_oid_shorten_free(git_oid_shorten *os) +{ + if (os == NULL) + return; + + git__free(os->nodes); + git__free(os); +} + + +/* + * What wizardry is this? + * + * This is just a memory-optimized trie: basically a very fancy + * 16-ary tree, which is used to store the prefixes of the OID + * strings. + * + * Read more: http://en.wikipedia.org/wiki/Trie + * + * Magic that happens in this method: + * + * - Each node in the trie is an union, so it can work both as + * a normal node, or as a leaf. + * + * - Each normal node points to 16 children (one for each possible + * character in the oid). This is *not* stored in an array of + * pointers, because in a 64-bit arch this would be sucking + * 16*sizeof(void*) = 128 bytes of memory per node, which is + * insane. What we do is store Node Indexes, and use these indexes + * to look up each node in the om->index array. These indexes are + * signed shorts, so this limits the amount of unique OIDs that + * fit in the structure to about 20000 (assuming a more or less uniform + * distribution). + * + * - All the nodes in om->index array are stored contiguously in + * memory, and each of them is 32 bytes, so we fit 2x nodes per + * cache line. Convenient for speed. + * + * - To differentiate the leafs from the normal nodes, we store all + * the indexes towards a leaf as a negative index (indexes to normal + * nodes are positives). When we find that one of the children for + * a node has a negative value, that means it's going to be a leaf. + * This reduces the amount of indexes we have by two, but also reduces + * the size of each node by 1-4 bytes (the amount we would need to + * add a `is_leaf` field): this is good because it allows the nodes + * to fit cleanly in cache lines. + * + * - Once we reach an empty children, instead of continuing to insert + * new nodes for each remaining character of the OID, we store a pointer + * to the tail in the leaf; if the leaf is reached again, we turn it + * into a normal node and use the tail to create a new leaf. + * + * This is a pretty good balance between performance and memory usage. + */ +int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid) +{ + int i; + bool is_leaf; + node_index idx; + + if (os->full) { + giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); + return -1; + } + + if (text_oid == NULL) + return os->min_length; + + idx = 0; + is_leaf = false; + + for (i = 0; i < GIT_OID_HEXSZ; ++i) { + int c = git__fromhex(text_oid[i]); + trie_node *node; + + if (c == -1) { + giterr_set(GITERR_INVALID, "Unable to shorten OID - invalid hex value"); + return -1; + } + + node = &os->nodes[idx]; + + if (is_leaf) { + const char *tail; + + tail = node->tail; + node->tail = NULL; + + node = push_leaf(os, idx, git__fromhex(tail[0]), &tail[1]); + if (node == NULL) { + if (os->full) + giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); + return -1; + } + } + + if (node->children[c] == 0) { + if (push_leaf(os, idx, c, &text_oid[i + 1]) == NULL) { + if (os->full) + giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); + return -1; + } + break; + } + + idx = node->children[c]; + is_leaf = false; + + if (idx < 0) { + node->children[c] = idx = -idx; + is_leaf = true; + } + } + + if (++i > os->min_length) + os->min_length = i; + + return os->min_length; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/oid.h b/deps/libgit2-sys-0.2.17/libgit2/src/oid.h new file mode 100644 index 000000000..aa1f0bfdc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/oid.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_oid_h__ +#define INCLUDE_oid_h__ + +#include "git2/oid.h" + +/** + * Format a git_oid into a newly allocated c-string. + * + * The c-string is owned by the caller and needs to be manually freed. + * + * @param id the oid structure to format + * @return the c-string; NULL if memory is exhausted. Caller must + * deallocate the string with git__free(). + */ +char *git_oid_allocfmt(const git_oid *id); + +GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2) +{ + int i; + + for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) { + if (*sha1 != *sha2) + return *sha1 - *sha2; + } + + return 0; +} + +/* + * Compare two oid structures. + * + * @param a first oid structure. + * @param b second oid structure. + * @return <0, 0, >0 if a < b, a == b, a > b. + */ +GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b) +{ + return git_oid__hashcmp(a->id, b->id); +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/oidarray.c b/deps/libgit2-sys-0.2.17/libgit2/src/oidarray.c new file mode 100644 index 000000000..1d51a2958 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/oidarray.c @@ -0,0 +1,21 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/oidarray.h" +#include "oidarray.h" +#include "array.h" + +void git_oidarray_free(git_oidarray *arr) +{ + git__free(arr->ids); +} + +void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array) +{ + arr->count = array->size; + arr->ids = array->ptr; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/oidarray.h b/deps/libgit2-sys-0.2.17/libgit2/src/oidarray.h new file mode 100644 index 000000000..a7215ae6c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/oidarray.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_oidarray_h__ +#define INCLUDE_oidarray_h__ + +#include "common.h" +#include "git2/oidarray.h" +#include "array.h" + +typedef git_array_t(git_oid) git_array_oid_t; + +extern void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/oidmap.h b/deps/libgit2-sys-0.2.17/libgit2/src/oidmap.h new file mode 100644 index 000000000..d2c451e7f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/oidmap.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_oidmap_h__ +#define INCLUDE_oidmap_h__ + +#include "common.h" +#include "git2/oid.h" + +#define kmalloc git__malloc +#define kcalloc git__calloc +#define krealloc git__realloc +#define kreallocarray git__reallocarray +#define kfree git__free +#include "khash.h" + +__KHASH_TYPE(oid, const git_oid *, void *) +typedef khash_t(oid) git_oidmap; + +GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid) +{ + khint_t h; + memcpy(&h, oid, sizeof(khint_t)); + return h; +} + +#define GIT__USE_OIDMAP \ + __KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal) + +#define git_oidmap_alloc() kh_init(oid) +#define git_oidmap_free(h) kh_destroy(oid,h), h = NULL + +#define git_oidmap_lookup_index(h, k) kh_get(oid, h, k) +#define git_oidmap_valid_index(h, idx) (idx != kh_end(h)) + +#define git_oidmap_value_at(h, idx) kh_val(h, idx) + +#define git_oidmap_insert(h, key, val, rval) do { \ + khiter_t __pos = kh_put(oid, h, key, &rval); \ + if (rval >= 0) { \ + if (rval == 0) kh_key(h, __pos) = key; \ + kh_val(h, __pos) = val; \ + } } while (0) + +#define git_oidmap_foreach_value kh_foreach_value + +#define git_oidmap_size(h) kh_size(h) + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.c b/deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.c new file mode 100644 index 000000000..9ddf6e4be --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.c @@ -0,0 +1,381 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifdef GIT_SSL + +#include + +#include "global.h" +#include "posix.h" +#include "stream.h" +#include "socket_stream.h" +#include "netops.h" +#include "git2/transport.h" + +#ifndef GIT_WIN32 +# include +# include +# include +#endif + +#include +#include +#include + +static int ssl_set_error(SSL *ssl, int error) +{ + int err; + unsigned long e; + + err = SSL_get_error(ssl, error); + + assert(err != SSL_ERROR_WANT_READ); + assert(err != SSL_ERROR_WANT_WRITE); + + switch (err) { + case SSL_ERROR_WANT_CONNECT: + case SSL_ERROR_WANT_ACCEPT: + giterr_set(GITERR_NET, "SSL error: connection failure\n"); + break; + case SSL_ERROR_WANT_X509_LOOKUP: + giterr_set(GITERR_NET, "SSL error: x509 error\n"); + break; + case SSL_ERROR_SYSCALL: + e = ERR_get_error(); + if (e > 0) { + giterr_set(GITERR_NET, "SSL error: %s", + ERR_error_string(e, NULL)); + break; + } else if (error < 0) { + giterr_set(GITERR_OS, "SSL error: syscall failure"); + break; + } + giterr_set(GITERR_NET, "SSL error: received early EOF"); + break; + case SSL_ERROR_SSL: + e = ERR_get_error(); + giterr_set(GITERR_NET, "SSL error: %s", + ERR_error_string(e, NULL)); + break; + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + default: + giterr_set(GITERR_NET, "SSL error: unknown error"); + break; + } + return -1; +} + +static int ssl_teardown(SSL *ssl) +{ + int ret; + + ret = SSL_shutdown(ssl); + if (ret < 0) + ret = ssl_set_error(ssl, ret); + else + ret = 0; + + SSL_free(ssl); + return ret; +} + +static int check_host_name(const char *name, const char *host) +{ + if (!strcasecmp(name, host)) + return 0; + + if (gitno__match_host(name, host) < 0) + return -1; + + return 0; +} + +static int verify_server_cert(SSL *ssl, const char *host) +{ + X509 *cert; + X509_NAME *peer_name; + ASN1_STRING *str; + unsigned char *peer_cn = NULL; + int matched = -1, type = GEN_DNS; + GENERAL_NAMES *alts; + struct in6_addr addr6; + struct in_addr addr4; + void *addr; + int i = -1,j; + + if (SSL_get_verify_result(ssl) != X509_V_OK) { + giterr_set(GITERR_SSL, "The SSL certificate is invalid"); + return GIT_ECERTIFICATE; + } + + /* Try to parse the host as an IP address to see if it is */ + if (p_inet_pton(AF_INET, host, &addr4)) { + type = GEN_IPADD; + addr = &addr4; + } else { + if(p_inet_pton(AF_INET6, host, &addr6)) { + type = GEN_IPADD; + addr = &addr6; + } + } + + + cert = SSL_get_peer_certificate(ssl); + if (!cert) { + giterr_set(GITERR_SSL, "the server did not provide a certificate"); + return -1; + } + + /* Check the alternative names */ + alts = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); + if (alts) { + int num; + + num = sk_GENERAL_NAME_num(alts); + for (i = 0; i < num && matched != 1; i++) { + const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i); + const char *name = (char *) ASN1_STRING_data(gn->d.ia5); + size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5); + + /* Skip any names of a type we're not looking for */ + if (gn->type != type) + continue; + + if (type == GEN_DNS) { + /* If it contains embedded NULs, don't even try */ + if (memchr(name, '\0', namelen)) + continue; + + if (check_host_name(name, host) < 0) + matched = 0; + else + matched = 1; + } else if (type == GEN_IPADD) { + /* Here name isn't so much a name but a binary representation of the IP */ + matched = !!memcmp(name, addr, namelen); + } + } + } + GENERAL_NAMES_free(alts); + + if (matched == 0) + goto cert_fail_name; + + if (matched == 1) + return 0; + + /* If no alternative names are available, check the common name */ + peer_name = X509_get_subject_name(cert); + if (peer_name == NULL) + goto on_error; + + if (peer_name) { + /* Get the index of the last CN entry */ + while ((j = X509_NAME_get_index_by_NID(peer_name, NID_commonName, i)) >= 0) + i = j; + } + + if (i < 0) + goto on_error; + + str = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(peer_name, i)); + if (str == NULL) + goto on_error; + + /* Work around a bug in OpenSSL whereby ASN1_STRING_to_UTF8 fails if it's already in utf-8 */ + if (ASN1_STRING_type(str) == V_ASN1_UTF8STRING) { + int size = ASN1_STRING_length(str); + + if (size > 0) { + peer_cn = OPENSSL_malloc(size + 1); + GITERR_CHECK_ALLOC(peer_cn); + memcpy(peer_cn, ASN1_STRING_data(str), size); + peer_cn[size] = '\0'; + } + } else { + int size = ASN1_STRING_to_UTF8(&peer_cn, str); + GITERR_CHECK_ALLOC(peer_cn); + if (memchr(peer_cn, '\0', size)) + goto cert_fail_name; + } + + if (check_host_name((char *)peer_cn, host) < 0) + goto cert_fail_name; + + OPENSSL_free(peer_cn); + + return 0; + +on_error: + OPENSSL_free(peer_cn); + return ssl_set_error(ssl, 0); + +cert_fail_name: + OPENSSL_free(peer_cn); + giterr_set(GITERR_SSL, "hostname does not match certificate"); + return GIT_ECERTIFICATE; +} + +typedef struct { + git_stream parent; + git_socket_stream *socket; + SSL *ssl; + git_cert_x509 cert_info; +} openssl_stream; + +int openssl_close(git_stream *stream); + +int openssl_connect(git_stream *stream) +{ + int ret; + openssl_stream *st = (openssl_stream *) stream; + + if ((ret = git_stream_connect((git_stream *)st->socket)) < 0) + return ret; + + if ((ret = SSL_set_fd(st->ssl, st->socket->s)) <= 0) { + openssl_close((git_stream *) st); + return ssl_set_error(st->ssl, ret); + } + + if ((ret = SSL_connect(st->ssl)) <= 0) + return ssl_set_error(st->ssl, ret); + + return verify_server_cert(st->ssl, st->socket->host); +} + +int openssl_certificate(git_cert **out, git_stream *stream) +{ + openssl_stream *st = (openssl_stream *) stream; + int len; + X509 *cert = SSL_get_peer_certificate(st->ssl); + unsigned char *guard, *encoded_cert; + + /* Retrieve the length of the certificate first */ + len = i2d_X509(cert, NULL); + if (len < 0) { + giterr_set(GITERR_NET, "failed to retrieve certificate information"); + return -1; + } + + encoded_cert = git__malloc(len); + GITERR_CHECK_ALLOC(encoded_cert); + /* i2d_X509 makes 'guard' point to just after the data */ + guard = encoded_cert; + + len = i2d_X509(cert, &guard); + if (len < 0) { + git__free(encoded_cert); + giterr_set(GITERR_NET, "failed to retrieve certificate information"); + return -1; + } + + st->cert_info.cert_type = GIT_CERT_X509; + st->cert_info.data = encoded_cert; + st->cert_info.len = len; + + *out = (git_cert *)&st->cert_info; + return 0; +} + +ssize_t openssl_write(git_stream *stream, const char *data, size_t len, int flags) +{ + openssl_stream *st = (openssl_stream *) stream; + int ret; + size_t off = 0; + + GIT_UNUSED(flags); + + while (off < len) { + ret = SSL_write(st->ssl, data + off, len - off); + if (ret <= 0 && ret != SSL_ERROR_WANT_WRITE) + return ssl_set_error(st->ssl, ret); + + off += ret; + } + + return off; +} + +ssize_t openssl_read(git_stream *stream, void *data, size_t len) +{ + openssl_stream *st = (openssl_stream *) stream; + int ret; + + do { + ret = SSL_read(st->ssl, data, len); + } while (SSL_get_error(st->ssl, ret) == SSL_ERROR_WANT_READ); + + if (ret < 0) { + ssl_set_error(st->ssl, ret); + return -1; + } + + return ret; +} + +int openssl_close(git_stream *stream) +{ + openssl_stream *st = (openssl_stream *) stream; + int ret; + + if ((ret = ssl_teardown(st->ssl)) < 0) + return -1; + + return git_stream_close((git_stream *)st->socket); +} + +void openssl_free(git_stream *stream) +{ + openssl_stream *st = (openssl_stream *) stream; + + git__free(st->cert_info.data); + git_stream_free((git_stream *) st->socket); + git__free(st); +} + +int git_openssl_stream_new(git_stream **out, const char *host, const char *port) +{ + openssl_stream *st; + + st = git__calloc(1, sizeof(openssl_stream)); + GITERR_CHECK_ALLOC(st); + + if (git_socket_stream_new((git_stream **) &st->socket, host, port)) + return -1; + + st->ssl = SSL_new(git__ssl_ctx); + if (st->ssl == NULL) { + giterr_set(GITERR_SSL, "failed to create ssl object"); + return -1; + } + + st->parent.version = GIT_STREAM_VERSION; + st->parent.encrypted = 1; + st->parent.connect = openssl_connect; + st->parent.certificate = openssl_certificate; + st->parent.read = openssl_read; + st->parent.write = openssl_write; + st->parent.close = openssl_close; + st->parent.free = openssl_free; + + *out = (git_stream *) st; + return 0; +} + +#else + +#include "stream.h" + +int git_openssl_stream_new(git_stream **out, const char *host, const char *port) +{ + giterr_set(GITERR_SSL, "openssl is not supported in this version"); + return -1; +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.h b/deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.h new file mode 100644 index 000000000..9ca06489e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/openssl_stream.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_openssl_stream_h__ +#define INCLUDE_openssl_stream_h__ + +#include "git2/sys/stream.h" + +extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.c b/deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.c new file mode 100644 index 000000000..0f43b98e0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.c @@ -0,0 +1,1686 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "pack-objects.h" + +#include "zstream.h" +#include "delta.h" +#include "iterator.h" +#include "netops.h" +#include "pack.h" +#include "thread-utils.h" +#include "tree.h" +#include "util.h" +#include "revwalk.h" +#include "commit_list.h" + +#include "git2/pack.h" +#include "git2/commit.h" +#include "git2/tag.h" +#include "git2/indexer.h" +#include "git2/config.h" + +struct unpacked { + git_pobject *object; + void *data; + struct git_delta_index *index; + int depth; +}; + +struct tree_walk_context { + git_packbuilder *pb; + git_buf buf; +}; + +struct pack_write_context { + git_indexer *indexer; + git_transfer_progress *stats; +}; + +GIT__USE_OIDMAP; + +#ifdef GIT_THREADS + +#define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \ + int result = git_mutex_##op(&(pb)->mtx); \ + assert(!result); \ + GIT_UNUSED(result); \ + } while (0) + +#else + +#define GIT_PACKBUILDER__MUTEX_OP(pb,mtx,op) GIT_UNUSED(pb) + +#endif /* GIT_THREADS */ + +#define git_packbuilder__cache_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, lock) +#define git_packbuilder__cache_unlock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, unlock) +#define git_packbuilder__progress_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, progress_mutex, lock) +#define git_packbuilder__progress_unlock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, progress_mutex, unlock) + +/* The minimal interval between progress updates (in seconds). */ +#define MIN_PROGRESS_UPDATE_INTERVAL 0.5 + +/* Size of the buffer to feed to zlib */ +#define COMPRESS_BUFLEN (1024 * 1024) + +static unsigned name_hash(const char *name) +{ + unsigned c, hash = 0; + + if (!name) + return 0; + + /* + * This effectively just creates a sortable number from the + * last sixteen non-whitespace characters. Last characters + * count "most", so things that end in ".c" sort together. + */ + while ((c = *name++) != 0) { + if (git__isspace(c)) + continue; + hash = (hash >> 2) + (c << 24); + } + return hash; +} + +static int packbuilder_config(git_packbuilder *pb) +{ + git_config *config; + int ret; + int64_t val; + + if ((ret = git_repository_config_snapshot(&config, pb->repo)) < 0) + return ret; + +#define config_get(KEY,DST,DFLT) do { \ + ret = git_config_get_int64(&val, config, KEY); \ + if (!ret) (DST) = val; \ + else if (ret == GIT_ENOTFOUND) (DST) = (DFLT); \ + else if (ret < 0) return -1; } while (0) + + config_get("pack.deltaCacheSize", pb->max_delta_cache_size, + GIT_PACK_DELTA_CACHE_SIZE); + config_get("pack.deltaCacheLimit", pb->cache_max_small_delta_size, + GIT_PACK_DELTA_CACHE_LIMIT); + config_get("pack.deltaCacheSize", pb->big_file_threshold, + GIT_PACK_BIG_FILE_THRESHOLD); + config_get("pack.windowMemory", pb->window_memory_limit, 0); + +#undef config_get + + git_config_free(config); + + return 0; +} + +int git_packbuilder_new(git_packbuilder **out, git_repository *repo) +{ + git_packbuilder *pb; + + *out = NULL; + + pb = git__calloc(1, sizeof(*pb)); + GITERR_CHECK_ALLOC(pb); + + pb->object_ix = git_oidmap_alloc(); + if (!pb->object_ix) + goto on_error; + + pb->walk_objects = git_oidmap_alloc(); + if (!pb->walk_objects) + goto on_error; + + if (git_pool_init(&pb->object_pool, sizeof(git_walk_object), 0) < 0) + goto on_error; + + pb->repo = repo; + pb->nr_threads = 1; /* do not spawn any thread by default */ + + if (git_hash_ctx_init(&pb->ctx) < 0 || + git_zstream_init(&pb->zstream) < 0 || + git_repository_odb(&pb->odb, repo) < 0 || + packbuilder_config(pb) < 0) + goto on_error; + +#ifdef GIT_THREADS + + if (git_mutex_init(&pb->cache_mutex) || + git_mutex_init(&pb->progress_mutex) || + git_cond_init(&pb->progress_cond)) + { + giterr_set(GITERR_OS, "Failed to initialize packbuilder mutex"); + goto on_error; + } + +#endif + + *out = pb; + return 0; + +on_error: + git_packbuilder_free(pb); + return -1; +} + +unsigned int git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n) +{ + assert(pb); + +#ifdef GIT_THREADS + pb->nr_threads = n; +#else + GIT_UNUSED(n); + assert(1 == pb->nr_threads); +#endif + + return pb->nr_threads; +} + +static void rehash(git_packbuilder *pb) +{ + git_pobject *po; + khiter_t pos; + unsigned int i; + int ret; + + kh_clear(oid, pb->object_ix); + for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) { + pos = kh_put(oid, pb->object_ix, &po->id, &ret); + kh_value(pb->object_ix, pos) = po; + } +} + +int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, + const char *name) +{ + git_pobject *po; + khiter_t pos; + size_t newsize; + int ret; + + assert(pb && oid); + + /* If the object already exists in the hash table, then we don't + * have any work to do */ + pos = kh_get(oid, pb->object_ix, oid); + if (pos != kh_end(pb->object_ix)) + return 0; + + if (pb->nr_objects >= pb->nr_alloc) { + GITERR_CHECK_ALLOC_ADD(&newsize, pb->nr_alloc, 1024); + GITERR_CHECK_ALLOC_MULTIPLY(&newsize, newsize, 3 / 2); + + if (!git__is_uint32(newsize)) { + giterr_set(GITERR_NOMEMORY, "Packfile too large to fit in memory."); + return -1; + } + + pb->nr_alloc = (uint32_t)newsize; + + pb->object_list = git__reallocarray(pb->object_list, + pb->nr_alloc, sizeof(*po)); + GITERR_CHECK_ALLOC(pb->object_list); + rehash(pb); + } + + po = pb->object_list + pb->nr_objects; + memset(po, 0x0, sizeof(*po)); + + if ((ret = git_odb_read_header(&po->size, &po->type, pb->odb, oid)) < 0) + return ret; + + pb->nr_objects++; + git_oid_cpy(&po->id, oid); + po->hash = name_hash(name); + + pos = kh_put(oid, pb->object_ix, &po->id, &ret); + if (ret < 0) { + giterr_set_oom(); + return ret; + } + assert(ret != 0); + kh_value(pb->object_ix, pos) = po; + + pb->done = false; + + if (pb->progress_cb) { + double current_time = git__timer(); + double elapsed = current_time - pb->last_progress_report_time; + + if (elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) { + pb->last_progress_report_time = current_time; + + ret = pb->progress_cb( + GIT_PACKBUILDER_ADDING_OBJECTS, + pb->nr_objects, 0, pb->progress_cb_payload); + + if (ret) + return giterr_set_after_callback(ret); + } + } + + return 0; +} + +static int get_delta(void **out, git_odb *odb, git_pobject *po) +{ + git_odb_object *src = NULL, *trg = NULL; + unsigned long delta_size; + void *delta_buf; + + *out = NULL; + + if (git_odb_read(&src, odb, &po->delta->id) < 0 || + git_odb_read(&trg, odb, &po->id) < 0) + goto on_error; + + delta_buf = git_delta( + git_odb_object_data(src), (unsigned long)git_odb_object_size(src), + git_odb_object_data(trg), (unsigned long)git_odb_object_size(trg), + &delta_size, 0); + + if (!delta_buf || delta_size != po->delta_size) { + giterr_set(GITERR_INVALID, "Delta size changed"); + goto on_error; + } + + *out = delta_buf; + + git_odb_object_free(src); + git_odb_object_free(trg); + return 0; + +on_error: + git_odb_object_free(src); + git_odb_object_free(trg); + return -1; +} + +static int write_object( + git_packbuilder *pb, + git_pobject *po, + int (*write_cb)(void *buf, size_t size, void *cb_data), + void *cb_data) +{ + git_odb_object *obj = NULL; + git_otype type; + unsigned char hdr[10], *zbuf = NULL; + void *data = NULL; + size_t hdr_len, zbuf_len = COMPRESS_BUFLEN, data_len; + int error; + + /* + * If we have a delta base, let's use the delta to save space. + * Otherwise load the whole object. 'data' ends up pointing to + * whatever data we want to put into the packfile. + */ + if (po->delta) { + if (po->delta_data) + data = po->delta_data; + else if ((error = get_delta(&data, pb->odb, po)) < 0) + goto done; + + data_len = po->delta_size; + type = GIT_OBJ_REF_DELTA; + } else { + if ((error = git_odb_read(&obj, pb->odb, &po->id)) < 0) + goto done; + + data = (void *)git_odb_object_data(obj); + data_len = git_odb_object_size(obj); + type = git_odb_object_type(obj); + } + + /* Write header */ + hdr_len = git_packfile__object_header(hdr, data_len, type); + + if ((error = write_cb(hdr, hdr_len, cb_data)) < 0 || + (error = git_hash_update(&pb->ctx, hdr, hdr_len)) < 0) + goto done; + + if (type == GIT_OBJ_REF_DELTA) { + if ((error = write_cb(po->delta->id.id, GIT_OID_RAWSZ, cb_data)) < 0 || + (error = git_hash_update(&pb->ctx, po->delta->id.id, GIT_OID_RAWSZ)) < 0) + goto done; + } + + /* Write data */ + if (po->z_delta_size) { + data_len = po->z_delta_size; + + if ((error = write_cb(data, data_len, cb_data)) < 0 || + (error = git_hash_update(&pb->ctx, data, data_len)) < 0) + goto done; + } else { + zbuf = git__malloc(zbuf_len); + GITERR_CHECK_ALLOC(zbuf); + + git_zstream_reset(&pb->zstream); + git_zstream_set_input(&pb->zstream, data, data_len); + + while (!git_zstream_done(&pb->zstream)) { + if ((error = git_zstream_get_output(zbuf, &zbuf_len, &pb->zstream)) < 0 || + (error = write_cb(zbuf, zbuf_len, cb_data)) < 0 || + (error = git_hash_update(&pb->ctx, zbuf, zbuf_len)) < 0) + goto done; + + zbuf_len = COMPRESS_BUFLEN; /* reuse buffer */ + } + } + + /* + * If po->delta is true, data is a delta and it is our + * responsibility to free it (otherwise it's a git_object's + * data). We set po->delta_data to NULL in case we got the + * data from there instead of get_delta(). If we didn't, + * there's no harm. + */ + if (po->delta) { + git__free(data); + po->delta_data = NULL; + } + + pb->nr_written++; + +done: + git__free(zbuf); + git_odb_object_free(obj); + return error; +} + +enum write_one_status { + WRITE_ONE_SKIP = -1, /* already written */ + WRITE_ONE_BREAK = 0, /* writing this will bust the limit; not written */ + WRITE_ONE_WRITTEN = 1, /* normal */ + WRITE_ONE_RECURSIVE = 2 /* already scheduled to be written */ +}; + +static int write_one( + enum write_one_status *status, + git_packbuilder *pb, + git_pobject *po, + int (*write_cb)(void *buf, size_t size, void *cb_data), + void *cb_data) +{ + int error; + + if (po->recursing) { + *status = WRITE_ONE_RECURSIVE; + return 0; + } else if (po->written) { + *status = WRITE_ONE_SKIP; + return 0; + } + + if (po->delta) { + po->recursing = 1; + + if ((error = write_one(status, pb, po->delta, write_cb, cb_data)) < 0) + return error; + + /* we cannot depend on this one */ + if (*status == WRITE_ONE_RECURSIVE) + po->delta = NULL; + } + + *status = WRITE_ONE_WRITTEN; + po->written = 1; + po->recursing = 0; + + return write_object(pb, po, write_cb, cb_data); +} + +GIT_INLINE(void) add_to_write_order(git_pobject **wo, unsigned int *endp, + git_pobject *po) +{ + if (po->filled) + return; + wo[(*endp)++] = po; + po->filled = 1; +} + +static void add_descendants_to_write_order(git_pobject **wo, unsigned int *endp, + git_pobject *po) +{ + int add_to_order = 1; + while (po) { + if (add_to_order) { + git_pobject *s; + /* add this node... */ + add_to_write_order(wo, endp, po); + /* all its siblings... */ + for (s = po->delta_sibling; s; s = s->delta_sibling) { + add_to_write_order(wo, endp, s); + } + } + /* drop down a level to add left subtree nodes if possible */ + if (po->delta_child) { + add_to_order = 1; + po = po->delta_child; + } else { + add_to_order = 0; + /* our sibling might have some children, it is next */ + if (po->delta_sibling) { + po = po->delta_sibling; + continue; + } + /* go back to our parent node */ + po = po->delta; + while (po && !po->delta_sibling) { + /* we're on the right side of a subtree, keep + * going up until we can go right again */ + po = po->delta; + } + if (!po) { + /* done- we hit our original root node */ + return; + } + /* pass it off to sibling at this level */ + po = po->delta_sibling; + } + }; +} + +static void add_family_to_write_order(git_pobject **wo, unsigned int *endp, + git_pobject *po) +{ + git_pobject *root; + + for (root = po; root->delta; root = root->delta) + ; /* nothing */ + add_descendants_to_write_order(wo, endp, root); +} + +static int cb_tag_foreach(const char *name, git_oid *oid, void *data) +{ + git_packbuilder *pb = data; + git_pobject *po; + khiter_t pos; + + GIT_UNUSED(name); + + pos = kh_get(oid, pb->object_ix, oid); + if (pos == kh_end(pb->object_ix)) + return 0; + + po = kh_value(pb->object_ix, pos); + po->tagged = 1; + + /* TODO: peel objects */ + + return 0; +} + +static git_pobject **compute_write_order(git_packbuilder *pb) +{ + unsigned int i, wo_end, last_untagged; + git_pobject **wo; + + if ((wo = git__mallocarray(pb->nr_objects, sizeof(*wo))) == NULL) + return NULL; + + for (i = 0; i < pb->nr_objects; i++) { + git_pobject *po = pb->object_list + i; + po->tagged = 0; + po->filled = 0; + po->delta_child = NULL; + po->delta_sibling = NULL; + } + + /* + * Fully connect delta_child/delta_sibling network. + * Make sure delta_sibling is sorted in the original + * recency order. + */ + for (i = pb->nr_objects; i > 0;) { + git_pobject *po = &pb->object_list[--i]; + if (!po->delta) + continue; + /* Mark me as the first child */ + po->delta_sibling = po->delta->delta_child; + po->delta->delta_child = po; + } + + /* + * Mark objects that are at the tip of tags. + */ + if (git_tag_foreach(pb->repo, &cb_tag_foreach, pb) < 0) { + git__free(wo); + return NULL; + } + + /* + * Give the objects in the original recency order until + * we see a tagged tip. + */ + for (i = wo_end = 0; i < pb->nr_objects; i++) { + git_pobject *po = pb->object_list + i; + if (po->tagged) + break; + add_to_write_order(wo, &wo_end, po); + } + last_untagged = i; + + /* + * Then fill all the tagged tips. + */ + for (; i < pb->nr_objects; i++) { + git_pobject *po = pb->object_list + i; + if (po->tagged) + add_to_write_order(wo, &wo_end, po); + } + + /* + * And then all remaining commits and tags. + */ + for (i = last_untagged; i < pb->nr_objects; i++) { + git_pobject *po = pb->object_list + i; + if (po->type != GIT_OBJ_COMMIT && + po->type != GIT_OBJ_TAG) + continue; + add_to_write_order(wo, &wo_end, po); + } + + /* + * And then all the trees. + */ + for (i = last_untagged; i < pb->nr_objects; i++) { + git_pobject *po = pb->object_list + i; + if (po->type != GIT_OBJ_TREE) + continue; + add_to_write_order(wo, &wo_end, po); + } + + /* + * Finally all the rest in really tight order + */ + for (i = last_untagged; i < pb->nr_objects; i++) { + git_pobject *po = pb->object_list + i; + if (!po->filled) + add_family_to_write_order(wo, &wo_end, po); + } + + if (wo_end != pb->nr_objects) { + giterr_set(GITERR_INVALID, "invalid write order"); + return NULL; + } + + return wo; +} + +static int write_pack(git_packbuilder *pb, + int (*write_cb)(void *buf, size_t size, void *cb_data), + void *cb_data) +{ + git_pobject **write_order; + git_pobject *po; + enum write_one_status status; + struct git_pack_header ph; + git_oid entry_oid; + unsigned int i = 0; + int error = 0; + + write_order = compute_write_order(pb); + if (write_order == NULL) { + error = -1; + goto done; + } + + /* Write pack header */ + ph.hdr_signature = htonl(PACK_SIGNATURE); + ph.hdr_version = htonl(PACK_VERSION); + ph.hdr_entries = htonl(pb->nr_objects); + + if ((error = write_cb(&ph, sizeof(ph), cb_data)) < 0 || + (error = git_hash_update(&pb->ctx, &ph, sizeof(ph))) < 0) + goto done; + + pb->nr_remaining = pb->nr_objects; + do { + pb->nr_written = 0; + for ( ; i < pb->nr_objects; ++i) { + po = write_order[i]; + + if ((error = write_one(&status, pb, po, write_cb, cb_data)) < 0) + goto done; + } + + pb->nr_remaining -= pb->nr_written; + } while (pb->nr_remaining && i < pb->nr_objects); + + if ((error = git_hash_final(&entry_oid, &pb->ctx)) < 0) + goto done; + + error = write_cb(entry_oid.id, GIT_OID_RAWSZ, cb_data); + +done: + /* if callback cancelled writing, we must still free delta_data */ + for ( ; i < pb->nr_objects; ++i) { + po = write_order[i]; + if (po->delta_data) { + git__free(po->delta_data); + po->delta_data = NULL; + } + } + + git__free(write_order); + return error; +} + +static int write_pack_buf(void *buf, size_t size, void *data) +{ + git_buf *b = (git_buf *)data; + return git_buf_put(b, buf, size); +} + +static int type_size_sort(const void *_a, const void *_b) +{ + const git_pobject *a = (git_pobject *)_a; + const git_pobject *b = (git_pobject *)_b; + + if (a->type > b->type) + return -1; + if (a->type < b->type) + return 1; + if (a->hash > b->hash) + return -1; + if (a->hash < b->hash) + return 1; + /* + * TODO + * + if (a->preferred_base > b->preferred_base) + return -1; + if (a->preferred_base < b->preferred_base) + return 1; + */ + if (a->size > b->size) + return -1; + if (a->size < b->size) + return 1; + return a < b ? -1 : (a > b); /* newest first */ +} + +static int delta_cacheable(git_packbuilder *pb, unsigned long src_size, + unsigned long trg_size, unsigned long delta_size) +{ + if (pb->max_delta_cache_size && + pb->delta_cache_size + delta_size > pb->max_delta_cache_size) + return 0; + + if (delta_size < pb->cache_max_small_delta_size) + return 1; + + /* cache delta, if objects are large enough compared to delta size */ + if ((src_size >> 20) + (trg_size >> 21) > (delta_size >> 10)) + return 1; + + return 0; +} + +static int try_delta(git_packbuilder *pb, struct unpacked *trg, + struct unpacked *src, int max_depth, + unsigned long *mem_usage, int *ret) +{ + git_pobject *trg_object = trg->object; + git_pobject *src_object = src->object; + git_odb_object *obj; + unsigned long trg_size, src_size, delta_size, + sizediff, max_size, sz; + unsigned int ref_depth; + void *delta_buf; + + /* Don't bother doing diffs between different types */ + if (trg_object->type != src_object->type) { + *ret = -1; + return 0; + } + + *ret = 0; + + /* TODO: support reuse-delta */ + + /* Let's not bust the allowed depth. */ + if (src->depth >= max_depth) + return 0; + + /* Now some size filtering heuristics. */ + trg_size = (unsigned long)trg_object->size; + if (!trg_object->delta) { + max_size = trg_size/2 - 20; + ref_depth = 1; + } else { + max_size = trg_object->delta_size; + ref_depth = trg->depth; + } + + max_size = (uint64_t)max_size * (max_depth - src->depth) / + (max_depth - ref_depth + 1); + if (max_size == 0) + return 0; + + src_size = (unsigned long)src_object->size; + sizediff = src_size < trg_size ? trg_size - src_size : 0; + if (sizediff >= max_size) + return 0; + if (trg_size < src_size / 32) + return 0; + + /* Load data if not already done */ + if (!trg->data) { + if (git_odb_read(&obj, pb->odb, &trg_object->id) < 0) + return -1; + + sz = (unsigned long)git_odb_object_size(obj); + trg->data = git__malloc(sz); + GITERR_CHECK_ALLOC(trg->data); + memcpy(trg->data, git_odb_object_data(obj), sz); + + git_odb_object_free(obj); + + if (sz != trg_size) { + giterr_set(GITERR_INVALID, + "Inconsistent target object length"); + return -1; + } + + *mem_usage += sz; + } + if (!src->data) { + size_t obj_sz; + + if (git_odb_read(&obj, pb->odb, &src_object->id) < 0 || + !git__is_ulong(obj_sz = git_odb_object_size(obj))) + return -1; + + sz = (unsigned long)obj_sz; + src->data = git__malloc(sz); + GITERR_CHECK_ALLOC(src->data); + memcpy(src->data, git_odb_object_data(obj), sz); + + git_odb_object_free(obj); + + if (sz != src_size) { + giterr_set(GITERR_INVALID, + "Inconsistent source object length"); + return -1; + } + + *mem_usage += sz; + } + if (!src->index) { + src->index = git_delta_create_index(src->data, src_size); + if (!src->index) + return 0; /* suboptimal pack - out of memory */ + + *mem_usage += git_delta_sizeof_index(src->index); + } + + delta_buf = git_delta_create(src->index, trg->data, trg_size, + &delta_size, max_size); + if (!delta_buf) + return 0; + + if (trg_object->delta) { + /* Prefer only shallower same-sized deltas. */ + if (delta_size == trg_object->delta_size && + src->depth + 1 >= trg->depth) { + git__free(delta_buf); + return 0; + } + } + + git_packbuilder__cache_lock(pb); + if (trg_object->delta_data) { + git__free(trg_object->delta_data); + pb->delta_cache_size -= trg_object->delta_size; + trg_object->delta_data = NULL; + } + if (delta_cacheable(pb, src_size, trg_size, delta_size)) { + bool overflow = git__add_uint64_overflow( + &pb->delta_cache_size, pb->delta_cache_size, delta_size); + + git_packbuilder__cache_unlock(pb); + + if (overflow || + !(trg_object->delta_data = git__realloc(delta_buf, delta_size))) + return -1; + } else { + /* create delta when writing the pack */ + git_packbuilder__cache_unlock(pb); + git__free(delta_buf); + } + + trg_object->delta = src_object; + trg_object->delta_size = delta_size; + trg->depth = src->depth + 1; + + *ret = 1; + return 0; +} + +static unsigned int check_delta_limit(git_pobject *me, unsigned int n) +{ + git_pobject *child = me->delta_child; + unsigned int m = n; + + while (child) { + unsigned int c = check_delta_limit(child, n + 1); + if (m < c) + m = c; + child = child->delta_sibling; + } + return m; +} + +static unsigned long free_unpacked(struct unpacked *n) +{ + unsigned long freed_mem = git_delta_sizeof_index(n->index); + git_delta_free_index(n->index); + n->index = NULL; + if (n->data) { + freed_mem += (unsigned long)n->object->size; + git__free(n->data); + n->data = NULL; + } + n->object = NULL; + n->depth = 0; + return freed_mem; +} + +static int find_deltas(git_packbuilder *pb, git_pobject **list, + unsigned int *list_size, unsigned int window, + int depth) +{ + git_pobject *po; + git_buf zbuf = GIT_BUF_INIT; + struct unpacked *array; + uint32_t idx = 0, count = 0; + unsigned long mem_usage = 0; + unsigned int i; + int error = -1; + + array = git__calloc(window, sizeof(struct unpacked)); + GITERR_CHECK_ALLOC(array); + + for (;;) { + struct unpacked *n = array + idx; + int max_depth, j, best_base = -1; + + git_packbuilder__progress_lock(pb); + if (!*list_size) { + git_packbuilder__progress_unlock(pb); + break; + } + + po = *list++; + (*list_size)--; + git_packbuilder__progress_unlock(pb); + + mem_usage -= free_unpacked(n); + n->object = po; + + while (pb->window_memory_limit && + mem_usage > pb->window_memory_limit && + count > 1) { + uint32_t tail = (idx + window - count) % window; + mem_usage -= free_unpacked(array + tail); + count--; + } + + /* + * If the current object is at pack edge, take the depth the + * objects that depend on the current object into account + * otherwise they would become too deep. + */ + max_depth = depth; + if (po->delta_child) { + max_depth -= check_delta_limit(po, 0); + if (max_depth <= 0) + goto next; + } + + j = window; + while (--j > 0) { + int ret; + uint32_t other_idx = idx + j; + struct unpacked *m; + + if (other_idx >= window) + other_idx -= window; + + m = array + other_idx; + if (!m->object) + break; + + if (try_delta(pb, n, m, max_depth, &mem_usage, &ret) < 0) + goto on_error; + if (ret < 0) + break; + else if (ret > 0) + best_base = other_idx; + } + + /* + * If we decided to cache the delta data, then it is best + * to compress it right away. First because we have to do + * it anyway, and doing it here while we're threaded will + * save a lot of time in the non threaded write phase, + * as well as allow for caching more deltas within + * the same cache size limit. + * ... + * But only if not writing to stdout, since in that case + * the network is most likely throttling writes anyway, + * and therefore it is best to go to the write phase ASAP + * instead, as we can afford spending more time compressing + * between writes at that moment. + */ + if (po->delta_data) { + if (git_zstream_deflatebuf(&zbuf, po->delta_data, po->delta_size) < 0) + goto on_error; + + git__free(po->delta_data); + po->delta_data = git__malloc(zbuf.size); + GITERR_CHECK_ALLOC(po->delta_data); + + memcpy(po->delta_data, zbuf.ptr, zbuf.size); + po->z_delta_size = (unsigned long)zbuf.size; + git_buf_clear(&zbuf); + + git_packbuilder__cache_lock(pb); + pb->delta_cache_size -= po->delta_size; + pb->delta_cache_size += po->z_delta_size; + git_packbuilder__cache_unlock(pb); + } + + /* + * If we made n a delta, and if n is already at max + * depth, leaving it in the window is pointless. we + * should evict it first. + */ + if (po->delta && max_depth <= n->depth) + continue; + + /* + * Move the best delta base up in the window, after the + * currently deltified object, to keep it longer. It will + * be the first base object to be attempted next. + */ + if (po->delta) { + struct unpacked swap = array[best_base]; + int dist = (window + idx - best_base) % window; + int dst = best_base; + while (dist--) { + int src = (dst + 1) % window; + array[dst] = array[src]; + dst = src; + } + array[dst] = swap; + } + + next: + idx++; + if (count + 1 < window) + count++; + if (idx >= window) + idx = 0; + } + error = 0; + +on_error: + for (i = 0; i < window; ++i) { + git__free(array[i].index); + git__free(array[i].data); + } + git__free(array); + git_buf_free(&zbuf); + + return error; +} + +#ifdef GIT_THREADS + +struct thread_params { + git_thread thread; + git_packbuilder *pb; + + git_pobject **list; + + git_cond cond; + git_mutex mutex; + + unsigned int list_size; + unsigned int remaining; + + int window; + int depth; + int working; + int data_ready; +}; + +static void *threaded_find_deltas(void *arg) +{ + struct thread_params *me = arg; + + while (me->remaining) { + if (find_deltas(me->pb, me->list, &me->remaining, + me->window, me->depth) < 0) { + ; /* TODO */ + } + + git_packbuilder__progress_lock(me->pb); + me->working = 0; + git_cond_signal(&me->pb->progress_cond); + git_packbuilder__progress_unlock(me->pb); + + if (git_mutex_lock(&me->mutex)) { + giterr_set(GITERR_THREAD, "unable to lock packfile condition mutex"); + return NULL; + } + + while (!me->data_ready) + git_cond_wait(&me->cond, &me->mutex); + + /* + * We must not set ->data_ready before we wait on the + * condition because the main thread may have set it to 1 + * before we get here. In order to be sure that new + * work is available if we see 1 in ->data_ready, it + * was initialized to 0 before this thread was spawned + * and we reset it to 0 right away. + */ + me->data_ready = 0; + git_mutex_unlock(&me->mutex); + } + /* leave ->working 1 so that this doesn't get more work assigned */ + return NULL; +} + +static int ll_find_deltas(git_packbuilder *pb, git_pobject **list, + unsigned int list_size, unsigned int window, + int depth) +{ + struct thread_params *p; + int i, ret, active_threads = 0; + + if (!pb->nr_threads) + pb->nr_threads = git_online_cpus(); + + if (pb->nr_threads <= 1) { + find_deltas(pb, list, &list_size, window, depth); + return 0; + } + + p = git__mallocarray(pb->nr_threads, sizeof(*p)); + GITERR_CHECK_ALLOC(p); + + /* Partition the work among the threads */ + for (i = 0; i < pb->nr_threads; ++i) { + unsigned sub_size = list_size / (pb->nr_threads - i); + + /* don't use too small segments or no deltas will be found */ + if (sub_size < 2*window && i+1 < pb->nr_threads) + sub_size = 0; + + p[i].pb = pb; + p[i].window = window; + p[i].depth = depth; + p[i].working = 1; + p[i].data_ready = 0; + + /* try to split chunks on "path" boundaries */ + while (sub_size && sub_size < list_size && + list[sub_size]->hash && + list[sub_size]->hash == list[sub_size-1]->hash) + sub_size++; + + p[i].list = list; + p[i].list_size = sub_size; + p[i].remaining = sub_size; + + list += sub_size; + list_size -= sub_size; + } + + /* Start work threads */ + for (i = 0; i < pb->nr_threads; ++i) { + if (!p[i].list_size) + continue; + + git_mutex_init(&p[i].mutex); + git_cond_init(&p[i].cond); + + ret = git_thread_create(&p[i].thread, NULL, + threaded_find_deltas, &p[i]); + if (ret) { + giterr_set(GITERR_THREAD, "unable to create thread"); + return -1; + } + active_threads++; + } + + /* + * Now let's wait for work completion. Each time a thread is done + * with its work, we steal half of the remaining work from the + * thread with the largest number of unprocessed objects and give + * it to that newly idle thread. This ensure good load balancing + * until the remaining object list segments are simply too short + * to be worth splitting anymore. + */ + while (active_threads) { + struct thread_params *target = NULL; + struct thread_params *victim = NULL; + unsigned sub_size = 0; + + /* Start by locating a thread that has transitioned its + * 'working' flag from 1 -> 0. This indicates that it is + * ready to receive more work using our work-stealing + * algorithm. */ + git_packbuilder__progress_lock(pb); + for (;;) { + for (i = 0; !target && i < pb->nr_threads; i++) + if (!p[i].working) + target = &p[i]; + if (target) + break; + git_cond_wait(&pb->progress_cond, &pb->progress_mutex); + } + + /* At this point we hold the progress lock and have located + * a thread to receive more work. We still need to locate a + * thread from which to steal work (the victim). */ + for (i = 0; i < pb->nr_threads; i++) + if (p[i].remaining > 2*window && + (!victim || victim->remaining < p[i].remaining)) + victim = &p[i]; + + if (victim) { + sub_size = victim->remaining / 2; + list = victim->list + victim->list_size - sub_size; + while (sub_size && list[0]->hash && + list[0]->hash == list[-1]->hash) { + list++; + sub_size--; + } + if (!sub_size) { + /* + * It is possible for some "paths" to have + * so many objects that no hash boundary + * might be found. Let's just steal the + * exact half in that case. + */ + sub_size = victim->remaining / 2; + list -= sub_size; + } + target->list = list; + victim->list_size -= sub_size; + victim->remaining -= sub_size; + } + target->list_size = sub_size; + target->remaining = sub_size; + target->working = 1; + git_packbuilder__progress_unlock(pb); + + if (git_mutex_lock(&target->mutex)) { + giterr_set(GITERR_THREAD, "unable to lock packfile condition mutex"); + git__free(p); + return -1; + } + + target->data_ready = 1; + git_cond_signal(&target->cond); + git_mutex_unlock(&target->mutex); + + if (!sub_size) { + git_thread_join(&target->thread, NULL); + git_cond_free(&target->cond); + git_mutex_free(&target->mutex); + active_threads--; + } + } + + git__free(p); + return 0; +} + +#else +#define ll_find_deltas(pb, l, ls, w, d) find_deltas(pb, l, &ls, w, d) +#endif + +static int prepare_pack(git_packbuilder *pb) +{ + git_pobject **delta_list; + unsigned int i, n = 0; + + if (pb->nr_objects == 0 || pb->done) + return 0; /* nothing to do */ + + /* + * Although we do not report progress during deltafication, we + * at least report that we are in the deltafication stage + */ + if (pb->progress_cb) + pb->progress_cb(GIT_PACKBUILDER_DELTAFICATION, 0, pb->nr_objects, pb->progress_cb_payload); + + delta_list = git__mallocarray(pb->nr_objects, sizeof(*delta_list)); + GITERR_CHECK_ALLOC(delta_list); + + for (i = 0; i < pb->nr_objects; ++i) { + git_pobject *po = pb->object_list + i; + + /* Make sure the item is within our size limits */ + if (po->size < 50 || po->size > pb->big_file_threshold) + continue; + + delta_list[n++] = po; + } + + if (n > 1) { + git__tsort((void **)delta_list, n, type_size_sort); + if (ll_find_deltas(pb, delta_list, n, + GIT_PACK_WINDOW + 1, + GIT_PACK_DEPTH) < 0) { + git__free(delta_list); + return -1; + } + } + + pb->done = true; + git__free(delta_list); + return 0; +} + +#define PREPARE_PACK if (prepare_pack(pb) < 0) { return -1; } + +int git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t size, void *payload), void *payload) +{ + PREPARE_PACK; + return write_pack(pb, cb, payload); +} + +int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb) +{ + PREPARE_PACK; + git_buf_sanitize(buf); + return write_pack(pb, &write_pack_buf, buf); +} + +static int write_cb(void *buf, size_t len, void *payload) +{ + struct pack_write_context *ctx = payload; + return git_indexer_append(ctx->indexer, buf, len, ctx->stats); +} + +int git_packbuilder_write( + git_packbuilder *pb, + const char *path, + unsigned int mode, + git_transfer_progress_cb progress_cb, + void *progress_cb_payload) +{ + git_indexer *indexer; + git_transfer_progress stats; + struct pack_write_context ctx; + + PREPARE_PACK; + + if (git_indexer_new( + &indexer, path, mode, pb->odb, progress_cb, progress_cb_payload) < 0) + return -1; + + ctx.indexer = indexer; + ctx.stats = &stats; + + if (git_packbuilder_foreach(pb, write_cb, &ctx) < 0 || + git_indexer_commit(indexer, &stats) < 0) { + git_indexer_free(indexer); + return -1; + } + + git_oid_cpy(&pb->pack_oid, git_indexer_hash(indexer)); + + git_indexer_free(indexer); + return 0; +} + +#undef PREPARE_PACK + +const git_oid *git_packbuilder_hash(git_packbuilder *pb) +{ + return &pb->pack_oid; +} + + +static int cb_tree_walk( + const char *root, const git_tree_entry *entry, void *payload) +{ + int error; + struct tree_walk_context *ctx = payload; + + /* A commit inside a tree represents a submodule commit and should be skipped. */ + if (git_tree_entry_type(entry) == GIT_OBJ_COMMIT) + return 0; + + if (!(error = git_buf_sets(&ctx->buf, root)) && + !(error = git_buf_puts(&ctx->buf, git_tree_entry_name(entry)))) + error = git_packbuilder_insert( + ctx->pb, git_tree_entry_id(entry), git_buf_cstr(&ctx->buf)); + + return error; +} + +int git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *oid) +{ + git_commit *commit; + + if (git_commit_lookup(&commit, pb->repo, oid) < 0 || + git_packbuilder_insert(pb, oid, NULL) < 0) + return -1; + + if (git_packbuilder_insert_tree(pb, git_commit_tree_id(commit)) < 0) + return -1; + + git_commit_free(commit); + return 0; +} + +int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid) +{ + int error; + git_tree *tree = NULL; + struct tree_walk_context context = { pb, GIT_BUF_INIT }; + + if (!(error = git_tree_lookup(&tree, pb->repo, oid)) && + !(error = git_packbuilder_insert(pb, oid, NULL))) + error = git_tree_walk(tree, GIT_TREEWALK_PRE, cb_tree_walk, &context); + + git_tree_free(tree); + git_buf_free(&context.buf); + return error; +} + +uint32_t git_packbuilder_object_count(git_packbuilder *pb) +{ + return pb->nr_objects; +} + +uint32_t git_packbuilder_written(git_packbuilder *pb) +{ + return pb->nr_written; +} + +int lookup_walk_object(git_walk_object **out, git_packbuilder *pb, const git_oid *id) +{ + git_walk_object *obj; + + obj = git_pool_mallocz(&pb->object_pool, 1); + if (!obj) { + giterr_set_oom(); + return -1; + } + + git_oid_cpy(&obj->id, id); + + *out = obj; + return 0; +} + +static int retrieve_object(git_walk_object **out, git_packbuilder *pb, const git_oid *id) +{ + int error; + khiter_t pos; + git_walk_object *obj; + + pos = git_oidmap_lookup_index(pb->walk_objects, id); + if (git_oidmap_valid_index(pb->walk_objects, pos)) { + obj = git_oidmap_value_at(pb->walk_objects, pos); + } else { + if ((error = lookup_walk_object(&obj, pb, id)) < 0) + return error; + + git_oidmap_insert(pb->walk_objects, &obj->id, obj, error); + } + + *out = obj; + return 0; +} + +static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id) +{ + int error; + git_walk_object *obj; + + if ((error = retrieve_object(&obj, pb, id)) < 0) + return error; + + obj->uninteresting = 1; + + return 0; +} + +static int mark_tree_uninteresting(git_packbuilder *pb, const git_oid *id) +{ + git_walk_object *obj; + git_tree *tree; + int error; + size_t i; + + if ((error = retrieve_object(&obj, pb, id)) < 0) + return error; + + if (obj->uninteresting) + return 0; + + obj->uninteresting = 1; + + if ((error = git_tree_lookup(&tree, pb->repo, id)) < 0) + return error; + + for (i = 0; i < git_tree_entrycount(tree); i++) { + const git_tree_entry *entry = git_tree_entry_byindex(tree, i); + const git_oid *entry_id = git_tree_entry_id(entry); + switch (git_tree_entry_type(entry)) { + case GIT_OBJ_TREE: + if ((error = mark_tree_uninteresting(pb, entry_id)) < 0) + goto cleanup; + break; + case GIT_OBJ_BLOB: + if ((error = mark_blob_uninteresting(pb, entry_id)) < 0) + goto cleanup; + break; + default: + /* it's a submodule or something unknown, we don't want it */ + ; + } + } + +cleanup: + git_tree_free(tree); + return error; +} + +/* + * Mark the edges of the graph uninteresting. Since we start from a + * git_revwalk, the commits are already uninteresting, but we need to + * mark the trees and blobs. + */ +static int mark_edges_uninteresting(git_packbuilder *pb, git_commit_list *commits) +{ + int error; + git_commit_list *list; + git_commit *commit; + + for (list = commits; list; list = list->next) { + if (!list->item->uninteresting) + continue; + + if ((error = git_commit_lookup(&commit, pb->repo, &list->item->oid)) < 0) + return error; + + error = mark_tree_uninteresting(pb, git_commit_tree_id(commit)); + git_commit_free(commit); + + if (error < 0) + return error; + } + + return 0; +} + +int insert_tree(git_packbuilder *pb, git_tree *tree) +{ + size_t i; + int error; + git_tree *subtree; + git_walk_object *obj; + const char *name; + + if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0) + return error; + + if (obj->seen) + return 0; + + obj->seen = 1; + + if ((error = git_packbuilder_insert(pb, &obj->id, NULL))) + return error; + + for (i = 0; i < git_tree_entrycount(tree); i++) { + const git_tree_entry *entry = git_tree_entry_byindex(tree, i); + const git_oid *entry_id = git_tree_entry_id(entry); + switch (git_tree_entry_type(entry)) { + case GIT_OBJ_TREE: + if ((error = git_tree_lookup(&subtree, pb->repo, entry_id)) < 0) + return error; + + error = insert_tree(pb, subtree); + git_tree_free(subtree); + + if (error < 0) + return error; + + break; + case GIT_OBJ_BLOB: + name = git_tree_entry_name(entry); + if ((error = git_packbuilder_insert(pb, entry_id, name)) < 0) + return error; + break; + default: + /* it's a submodule or something unknown, we don't want it */ + ; + } + } + + + return error; +} + +int insert_commit(git_packbuilder *pb, git_walk_object *obj) +{ + int error; + git_commit *commit = NULL; + git_tree *tree = NULL; + + obj->seen = 1; + + if ((error = git_packbuilder_insert(pb, &obj->id, NULL)) < 0) + return error; + + if ((error = git_commit_lookup(&commit, pb->repo, &obj->id)) < 0) + return error; + + if ((error = git_tree_lookup(&tree, pb->repo, git_commit_tree_id(commit))) < 0) + goto cleanup; + + if ((error = insert_tree(pb, tree)) < 0) + goto cleanup; + +cleanup: + git_commit_free(commit); + git_tree_free(tree); + return error; +} + +int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk) +{ + int error; + git_oid id; + git_walk_object *obj; + + assert(pb && walk); + + if ((error = mark_edges_uninteresting(pb, walk->user_input)) < 0) + return error; + + /* + * TODO: git marks the parents of the edges + * uninteresting. This may provide a speed advantage, but does + * seem to assume the remote does not have a single-commit + * history on the other end. + */ + + /* walk down each tree up to the blobs and insert them, stopping when uninteresting */ + while ((error = git_revwalk_next(&id, walk)) == 0) { + if ((error = retrieve_object(&obj, pb, &id)) < 0) + return error; + + if (obj->seen || obj->uninteresting) + continue; + + if ((error = insert_commit(pb, obj)) < 0) + return error; + } + + if (error == GIT_ITEROVER) + error = 0; + + return 0; +} + +int git_packbuilder_set_callbacks(git_packbuilder *pb, git_packbuilder_progress progress_cb, void *progress_cb_payload) +{ + if (!pb) + return -1; + + pb->progress_cb = progress_cb; + pb->progress_cb_payload = progress_cb_payload; + + return 0; +} + +void git_packbuilder_free(git_packbuilder *pb) +{ + if (pb == NULL) + return; + +#ifdef GIT_THREADS + + git_mutex_free(&pb->cache_mutex); + git_mutex_free(&pb->progress_mutex); + git_cond_free(&pb->progress_cond); + +#endif + + if (pb->odb) + git_odb_free(pb->odb); + + if (pb->object_ix) + git_oidmap_free(pb->object_ix); + + if (pb->object_list) + git__free(pb->object_list); + + git_oidmap_free(pb->walk_objects); + git_pool_clear(&pb->object_pool); + + git_hash_ctx_cleanup(&pb->ctx); + git_zstream_free(&pb->zstream); + + git__free(pb); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.h b/deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.h new file mode 100644 index 000000000..9af5c0b09 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pack-objects.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_pack_objects_h__ +#define INCLUDE_pack_objects_h__ + +#include "common.h" + +#include "buffer.h" +#include "hash.h" +#include "oidmap.h" +#include "netops.h" +#include "zstream.h" +#include "pool.h" + +#include "git2/oid.h" +#include "git2/pack.h" + +#define GIT_PACK_WINDOW 10 /* number of objects to possibly delta against */ +#define GIT_PACK_DEPTH 50 /* max delta depth */ +#define GIT_PACK_DELTA_CACHE_SIZE (256 * 1024 * 1024) +#define GIT_PACK_DELTA_CACHE_LIMIT 1000 +#define GIT_PACK_BIG_FILE_THRESHOLD (512 * 1024 * 1024) + +typedef struct git_pobject { + git_oid id; + git_otype type; + git_off_t offset; + + size_t size; + + unsigned int hash; /* name hint hash */ + + struct git_pobject *delta; /* delta base object */ + struct git_pobject *delta_child; /* deltified objects who bases me */ + struct git_pobject *delta_sibling; /* other deltified objects + * who uses the same base as + * me */ + + void *delta_data; + unsigned long delta_size; + unsigned long z_delta_size; + + int written:1, + recursing:1, + tagged:1, + filled:1; +} git_pobject; + +typedef struct { + git_oid id; + unsigned int uninteresting:1, + seen:1; +} git_walk_object; + +struct git_packbuilder { + git_repository *repo; /* associated repository */ + git_odb *odb; /* associated object database */ + + git_hash_ctx ctx; + git_zstream zstream; + + uint32_t nr_objects, + nr_alloc, + nr_written, + nr_remaining; + + git_pobject *object_list; + + git_oidmap *object_ix; + + git_oidmap *walk_objects; + git_pool object_pool; + + git_oid pack_oid; /* hash of written pack */ + + /* synchronization objects */ + git_mutex cache_mutex; + git_mutex progress_mutex; + git_cond progress_cond; + + /* configs */ + uint64_t delta_cache_size; + uint64_t max_delta_cache_size; + uint64_t cache_max_small_delta_size; + uint64_t big_file_threshold; + uint64_t window_memory_limit; + + int nr_threads; /* nr of threads to use */ + + git_packbuilder_progress progress_cb; + void *progress_cb_payload; + double last_progress_report_time; /* the time progress was last reported */ + + bool done; +}; + +int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); + +#endif /* INCLUDE_pack_objects_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pack.c b/deps/libgit2-sys-0.2.17/libgit2/src/pack.c new file mode 100644 index 000000000..5d0a27b91 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pack.c @@ -0,0 +1,1381 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "odb.h" +#include "pack.h" +#include "delta-apply.h" +#include "sha1_lookup.h" +#include "mwindow.h" +#include "fileops.h" +#include "oid.h" + +#include + +GIT__USE_OFFMAP; +GIT__USE_OIDMAP; + +static int packfile_open(struct git_pack_file *p); +static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n); +int packfile_unpack_compressed( + git_rawobj *obj, + struct git_pack_file *p, + git_mwindow **w_curs, + git_off_t *curpos, + size_t size, + git_otype type); + +/* Can find the offset of an object given + * a prefix of an identifier. + * Throws GIT_EAMBIGUOUSOIDPREFIX if short oid + * is ambiguous within the pack. + * This method assumes that len is between + * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ. + */ +static int pack_entry_find_offset( + git_off_t *offset_out, + git_oid *found_oid, + struct git_pack_file *p, + const git_oid *short_oid, + size_t len); + +static int packfile_error(const char *message) +{ + giterr_set(GITERR_ODB, "Invalid pack file - %s", message); + return -1; +} + +/******************** + * Delta base cache + ********************/ + +static git_pack_cache_entry *new_cache_object(git_rawobj *source) +{ + git_pack_cache_entry *e = git__calloc(1, sizeof(git_pack_cache_entry)); + if (!e) + return NULL; + + git_atomic_inc(&e->refcount); + memcpy(&e->raw, source, sizeof(git_rawobj)); + + return e; +} + +static void free_cache_object(void *o) +{ + git_pack_cache_entry *e = (git_pack_cache_entry *)o; + + if (e != NULL) { + assert(e->refcount.val == 0); + git__free(e->raw.data); + git__free(e); + } +} + +static void cache_free(git_pack_cache *cache) +{ + khiter_t k; + + if (cache->entries) { + for (k = kh_begin(cache->entries); k != kh_end(cache->entries); k++) { + if (kh_exist(cache->entries, k)) + free_cache_object(kh_value(cache->entries, k)); + } + + git_offmap_free(cache->entries); + cache->entries = NULL; + } +} + +static int cache_init(git_pack_cache *cache) +{ + cache->entries = git_offmap_alloc(); + GITERR_CHECK_ALLOC(cache->entries); + + cache->memory_limit = GIT_PACK_CACHE_MEMORY_LIMIT; + + if (git_mutex_init(&cache->lock)) { + giterr_set(GITERR_OS, "Failed to initialize pack cache mutex"); + + git__free(cache->entries); + cache->entries = NULL; + + return -1; + } + + return 0; +} + +static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset) +{ + khiter_t k; + git_pack_cache_entry *entry = NULL; + + if (git_mutex_lock(&cache->lock) < 0) + return NULL; + + k = kh_get(off, cache->entries, offset); + if (k != kh_end(cache->entries)) { /* found it */ + entry = kh_value(cache->entries, k); + git_atomic_inc(&entry->refcount); + entry->last_usage = cache->use_ctr++; + } + git_mutex_unlock(&cache->lock); + + return entry; +} + +/* Run with the cache lock held */ +static void free_lowest_entry(git_pack_cache *cache) +{ + git_pack_cache_entry *entry; + khiter_t k; + + for (k = kh_begin(cache->entries); k != kh_end(cache->entries); k++) { + if (!kh_exist(cache->entries, k)) + continue; + + entry = kh_value(cache->entries, k); + + if (entry && entry->refcount.val == 0) { + cache->memory_used -= entry->raw.len; + kh_del(off, cache->entries, k); + free_cache_object(entry); + } + } +} + +static int cache_add( + git_pack_cache_entry **cached_out, + git_pack_cache *cache, + git_rawobj *base, + git_off_t offset) +{ + git_pack_cache_entry *entry; + int error, exists = 0; + khiter_t k; + + if (base->len > GIT_PACK_CACHE_SIZE_LIMIT) + return -1; + + entry = new_cache_object(base); + if (entry) { + if (git_mutex_lock(&cache->lock) < 0) { + giterr_set(GITERR_OS, "failed to lock cache"); + git__free(entry); + return -1; + } + /* Add it to the cache if nobody else has */ + exists = kh_get(off, cache->entries, offset) != kh_end(cache->entries); + if (!exists) { + while (cache->memory_used + base->len > cache->memory_limit) + free_lowest_entry(cache); + + k = kh_put(off, cache->entries, offset, &error); + assert(error != 0); + kh_value(cache->entries, k) = entry; + cache->memory_used += entry->raw.len; + + *cached_out = entry; + } + git_mutex_unlock(&cache->lock); + /* Somebody beat us to adding it into the cache */ + if (exists) { + git__free(entry); + return -1; + } + } + + return 0; +} + +/*********************************************************** + * + * PACK INDEX METHODS + * + ***********************************************************/ + +static void pack_index_free(struct git_pack_file *p) +{ + if (p->oids) { + git__free(p->oids); + p->oids = NULL; + } + if (p->index_map.data) { + git_futils_mmap_free(&p->index_map); + p->index_map.data = NULL; + } +} + +static int pack_index_check(const char *path, struct git_pack_file *p) +{ + struct git_pack_idx_header *hdr; + uint32_t version, nr, i, *index; + void *idx_map; + size_t idx_size; + struct stat st; + int error; + /* TODO: properly open the file without access time using O_NOATIME */ + git_file fd = git_futils_open_ro(path); + if (fd < 0) + return fd; + + if (p_fstat(fd, &st) < 0) { + p_close(fd); + giterr_set(GITERR_OS, "Unable to stat pack index '%s'", path); + return -1; + } + + if (!S_ISREG(st.st_mode) || + !git__is_sizet(st.st_size) || + (idx_size = (size_t)st.st_size) < 4 * 256 + 20 + 20) + { + p_close(fd); + giterr_set(GITERR_ODB, "Invalid pack index '%s'", path); + return -1; + } + + error = git_futils_mmap_ro(&p->index_map, fd, 0, idx_size); + + p_close(fd); + + if (error < 0) + return error; + + hdr = idx_map = p->index_map.data; + + if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) { + version = ntohl(hdr->idx_version); + + if (version < 2 || version > 2) { + git_futils_mmap_free(&p->index_map); + return packfile_error("unsupported index version"); + } + + } else + version = 1; + + nr = 0; + index = idx_map; + + if (version > 1) + index += 2; /* skip index header */ + + for (i = 0; i < 256; i++) { + uint32_t n = ntohl(index[i]); + if (n < nr) { + git_futils_mmap_free(&p->index_map); + return packfile_error("index is non-monotonic"); + } + nr = n; + } + + if (version == 1) { + /* + * Total size: + * - 256 index entries 4 bytes each + * - 24-byte entries * nr (20-byte sha1 + 4-byte offset) + * - 20-byte SHA1 of the packfile + * - 20-byte SHA1 file checksum + */ + if (idx_size != 4*256 + nr * 24 + 20 + 20) { + git_futils_mmap_free(&p->index_map); + return packfile_error("index is corrupted"); + } + } else if (version == 2) { + /* + * Minimum size: + * - 8 bytes of header + * - 256 index entries 4 bytes each + * - 20-byte sha1 entry * nr + * - 4-byte crc entry * nr + * - 4-byte offset entry * nr + * - 20-byte SHA1 of the packfile + * - 20-byte SHA1 file checksum + * And after the 4-byte offset table might be a + * variable sized table containing 8-byte entries + * for offsets larger than 2^31. + */ + unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20; + unsigned long max_size = min_size; + + if (nr) + max_size += (nr - 1)*8; + + if (idx_size < min_size || idx_size > max_size) { + git_futils_mmap_free(&p->index_map); + return packfile_error("wrong index size"); + } + } + + p->num_objects = nr; + p->index_version = version; + return 0; +} + +static int pack_index_open(struct git_pack_file *p) +{ + char *idx_name; + int error = 0; + size_t name_len, base_len; + + if (p->index_version > -1) + return 0; + + name_len = strlen(p->pack_name); + assert(name_len > strlen(".pack")); /* checked by git_pack_file alloc */ + + if ((idx_name = git__malloc(name_len)) == NULL) + return -1; + + base_len = name_len - strlen(".pack"); + memcpy(idx_name, p->pack_name, base_len); + memcpy(idx_name + base_len, ".idx", sizeof(".idx")); + + if ((error = git_mutex_lock(&p->lock)) < 0) { + git__free(idx_name); + return error; + } + + if (p->index_version == -1) + error = pack_index_check(idx_name, p); + + git__free(idx_name); + + git_mutex_unlock(&p->lock); + + return error; +} + +static unsigned char *pack_window_open( + struct git_pack_file *p, + git_mwindow **w_cursor, + git_off_t offset, + unsigned int *left) +{ + if (p->mwf.fd == -1 && packfile_open(p) < 0) + return NULL; + + /* Since packfiles end in a hash of their content and it's + * pointless to ask for an offset into the middle of that + * hash, and the pack_window_contains function above wouldn't match + * don't allow an offset too close to the end of the file. + */ + if (offset > (p->mwf.size - 20)) + return NULL; + + return git_mwindow_open(&p->mwf, w_cursor, offset, 20, left); + } + +/* + * The per-object header is a pretty dense thing, which is + * - first byte: low four bits are "size", + * then three bits of "type", + * with the high bit being "size continues". + * - each byte afterwards: low seven bits are size continuation, + * with the high bit being "size continues" + */ +size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type) +{ + unsigned char *hdr_base; + unsigned char c; + + assert(type >= GIT_OBJ_COMMIT && type <= GIT_OBJ_REF_DELTA); + + /* TODO: add support for chunked objects; see git.git 6c0d19b1 */ + + c = (unsigned char)((type << 4) | (size & 15)); + size >>= 4; + hdr_base = hdr; + + while (size) { + *hdr++ = c | 0x80; + c = size & 0x7f; + size >>= 7; + } + *hdr++ = c; + + return (hdr - hdr_base); +} + + +static int packfile_unpack_header1( + unsigned long *usedp, + size_t *sizep, + git_otype *type, + const unsigned char *buf, + unsigned long len) +{ + unsigned shift; + unsigned long size, c; + unsigned long used = 0; + + c = buf[used++]; + *type = (c >> 4) & 7; + size = c & 15; + shift = 4; + while (c & 0x80) { + if (len <= used) { + giterr_set(GITERR_ODB, "buffer too small"); + return GIT_EBUFS; + } + + if (bitsizeof(long) <= shift) { + *usedp = 0; + giterr_set(GITERR_ODB, "packfile corrupted"); + return -1; + } + + c = buf[used++]; + size += (c & 0x7f) << shift; + shift += 7; + } + + *sizep = (size_t)size; + *usedp = used; + return 0; +} + +int git_packfile_unpack_header( + size_t *size_p, + git_otype *type_p, + git_mwindow_file *mwf, + git_mwindow **w_curs, + git_off_t *curpos) +{ + unsigned char *base; + unsigned int left; + unsigned long used; + int ret; + + /* pack_window_open() assures us we have [base, base + 20) available + * as a range that we can look at at. (Its actually the hash + * size that is assured.) With our object header encoding + * the maximum deflated object size is 2^137, which is just + * insane, so we know won't exceed what we have been given. + */ +/* base = pack_window_open(p, w_curs, *curpos, &left); */ + base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left); + if (base == NULL) + return GIT_EBUFS; + + ret = packfile_unpack_header1(&used, size_p, type_p, base, left); + git_mwindow_close(w_curs); + if (ret == GIT_EBUFS) + return ret; + else if (ret < 0) + return packfile_error("header length is zero"); + + *curpos += used; + return 0; +} + +int git_packfile_resolve_header( + size_t *size_p, + git_otype *type_p, + struct git_pack_file *p, + git_off_t offset) +{ + git_mwindow *w_curs = NULL; + git_off_t curpos = offset; + size_t size; + git_otype type; + git_off_t base_offset; + int error; + + error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); + git_mwindow_close(&w_curs); + if (error < 0) + return error; + + if (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) { + size_t base_size; + git_rawobj delta; + base_offset = get_delta_base(p, &w_curs, &curpos, type, offset); + git_mwindow_close(&w_curs); + error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, size, type); + git_mwindow_close(&w_curs); + if (error < 0) + return error; + error = git__delta_read_header(delta.data, delta.len, &base_size, size_p); + git__free(delta.data); + if (error < 0) + return error; + } else + *size_p = size; + + while (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) { + curpos = base_offset; + error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); + git_mwindow_close(&w_curs); + if (error < 0) + return error; + if (type != GIT_OBJ_OFS_DELTA && type != GIT_OBJ_REF_DELTA) + break; + base_offset = get_delta_base(p, &w_curs, &curpos, type, base_offset); + git_mwindow_close(&w_curs); + } + *type_p = type; + + return error; +} + +#define SMALL_STACK_SIZE 64 + +/** + * Generate the chain of dependencies which we need to get to the + * object at `off`. `chain` is used a stack, popping gives the right + * order to apply deltas on. If an object is found in the pack's base + * cache, we stop calculating there. + */ +static int pack_dependency_chain(git_dependency_chain *chain_out, + git_pack_cache_entry **cached_out, git_off_t *cached_off, + struct pack_chain_elem *small_stack, size_t *stack_sz, + struct git_pack_file *p, git_off_t obj_offset) +{ + git_dependency_chain chain = GIT_ARRAY_INIT; + git_mwindow *w_curs = NULL; + git_off_t curpos = obj_offset, base_offset; + int error = 0, use_heap = 0; + size_t size, elem_pos; + git_otype type; + + elem_pos = 0; + while (true) { + struct pack_chain_elem *elem; + git_pack_cache_entry *cached = NULL; + + /* if we have a base cached, we can stop here instead */ + if ((cached = cache_get(&p->bases, obj_offset)) != NULL) { + *cached_out = cached; + *cached_off = obj_offset; + break; + } + + /* if we run out of space on the small stack, use the array */ + if (elem_pos == SMALL_STACK_SIZE) { + git_array_init_to_size(chain, elem_pos); + GITERR_CHECK_ARRAY(chain); + memcpy(chain.ptr, small_stack, elem_pos * sizeof(struct pack_chain_elem)); + chain.size = elem_pos; + use_heap = 1; + } + + curpos = obj_offset; + if (!use_heap) { + elem = &small_stack[elem_pos]; + } else { + elem = git_array_alloc(chain); + if (!elem) { + error = -1; + goto on_error; + } + } + + elem->base_key = obj_offset; + + error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); + git_mwindow_close(&w_curs); + + if (error < 0) + goto on_error; + + elem->offset = curpos; + elem->size = size; + elem->type = type; + elem->base_key = obj_offset; + + if (type != GIT_OBJ_OFS_DELTA && type != GIT_OBJ_REF_DELTA) + break; + + base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset); + git_mwindow_close(&w_curs); + + if (base_offset == 0) { + error = packfile_error("delta offset is zero"); + goto on_error; + } + if (base_offset < 0) { /* must actually be an error code */ + error = (int)base_offset; + goto on_error; + } + + /* we need to pass the pos *after* the delta-base bit */ + elem->offset = curpos; + + /* go through the loop again, but with the new object */ + obj_offset = base_offset; + elem_pos++; + } + + + *stack_sz = elem_pos + 1; + *chain_out = chain; + return error; + +on_error: + git_array_clear(chain); + return error; +} + +int git_packfile_unpack( + git_rawobj *obj, + struct git_pack_file *p, + git_off_t *obj_offset) +{ + git_mwindow *w_curs = NULL; + git_off_t curpos = *obj_offset; + int error, free_base = 0; + git_dependency_chain chain = GIT_ARRAY_INIT; + struct pack_chain_elem *elem = NULL, *stack; + git_pack_cache_entry *cached = NULL; + struct pack_chain_elem small_stack[SMALL_STACK_SIZE]; + size_t stack_size = 0, elem_pos, alloclen; + git_otype base_type; + + /* + * TODO: optionally check the CRC on the packfile + */ + + error = pack_dependency_chain(&chain, &cached, obj_offset, small_stack, &stack_size, p, *obj_offset); + if (error < 0) + return error; + + obj->data = NULL; + obj->len = 0; + obj->type = GIT_OBJ_BAD; + + /* let's point to the right stack */ + stack = chain.ptr ? chain.ptr : small_stack; + + elem_pos = stack_size; + if (cached) { + memcpy(obj, &cached->raw, sizeof(git_rawobj)); + base_type = obj->type; + elem_pos--; /* stack_size includes the base, which isn't actually there */ + } else { + elem = &stack[--elem_pos]; + base_type = elem->type; + } + + switch (base_type) { + case GIT_OBJ_COMMIT: + case GIT_OBJ_TREE: + case GIT_OBJ_BLOB: + case GIT_OBJ_TAG: + if (!cached) { + curpos = elem->offset; + error = packfile_unpack_compressed(obj, p, &w_curs, &curpos, elem->size, elem->type); + git_mwindow_close(&w_curs); + base_type = elem->type; + } + if (error < 0) + goto cleanup; + break; + case GIT_OBJ_OFS_DELTA: + case GIT_OBJ_REF_DELTA: + error = packfile_error("dependency chain ends in a delta"); + goto cleanup; + default: + error = packfile_error("invalid packfile type in header"); + goto cleanup; + } + + /* + * Finding the object we want a cached base element is + * problematic, as we need to make sure we don't accidentally + * give the caller the cached object, which it would then feel + * free to free, so we need to copy the data. + */ + if (cached && stack_size == 1) { + void *data = obj->data; + + GITERR_CHECK_ALLOC_ADD(&alloclen, obj->len, 1); + obj->data = git__malloc(alloclen); + GITERR_CHECK_ALLOC(obj->data); + + memcpy(obj->data, data, obj->len + 1); + git_atomic_dec(&cached->refcount); + goto cleanup; + } + + /* we now apply each consecutive delta until we run out */ + while (elem_pos > 0 && !error) { + git_rawobj base, delta; + + /* + * We can now try to add the base to the cache, as + * long as it's not already the cached one. + */ + if (!cached) + free_base = !!cache_add(&cached, &p->bases, obj, elem->base_key); + + elem = &stack[elem_pos - 1]; + curpos = elem->offset; + error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, elem->size, elem->type); + git_mwindow_close(&w_curs); + + if (error < 0) + break; + + /* the current object becomes the new base, on which we apply the delta */ + base = *obj; + obj->data = NULL; + obj->len = 0; + obj->type = GIT_OBJ_BAD; + + error = git__delta_apply(obj, base.data, base.len, delta.data, delta.len); + obj->type = base_type; + /* + * We usually don't want to free the base at this + * point, as we put it into the cache in the previous + * iteration. free_base lets us know that we got the + * base object directly from the packfile, so we can free it. + */ + git__free(delta.data); + if (free_base) { + free_base = 0; + git__free(base.data); + } + + if (cached) { + git_atomic_dec(&cached->refcount); + cached = NULL; + } + + if (error < 0) + break; + + elem_pos--; + } + +cleanup: + if (error < 0) + git__free(obj->data); + + if (elem) + *obj_offset = curpos; + + git_array_clear(chain); + return error; +} + +static void *use_git_alloc(void *opaq, unsigned int count, unsigned int size) +{ + GIT_UNUSED(opaq); + return git__calloc(count, size); +} + +static void use_git_free(void *opaq, void *ptr) +{ + GIT_UNUSED(opaq); + git__free(ptr); +} + +int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos) +{ + int st; + + memset(obj, 0, sizeof(git_packfile_stream)); + obj->curpos = curpos; + obj->p = p; + obj->zstream.zalloc = use_git_alloc; + obj->zstream.zfree = use_git_free; + obj->zstream.next_in = Z_NULL; + obj->zstream.next_out = Z_NULL; + st = inflateInit(&obj->zstream); + if (st != Z_OK) { + git__free(obj); + giterr_set(GITERR_ZLIB, "failed to init packfile stream"); + return -1; + } + + return 0; +} + +ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len) +{ + unsigned char *in; + size_t written; + int st; + + if (obj->done) + return 0; + + in = pack_window_open(obj->p, &obj->mw, obj->curpos, &obj->zstream.avail_in); + if (in == NULL) + return GIT_EBUFS; + + obj->zstream.next_out = buffer; + obj->zstream.avail_out = (unsigned int)len; + obj->zstream.next_in = in; + + st = inflate(&obj->zstream, Z_SYNC_FLUSH); + git_mwindow_close(&obj->mw); + + obj->curpos += obj->zstream.next_in - in; + written = len - obj->zstream.avail_out; + + if (st != Z_OK && st != Z_STREAM_END) { + giterr_set(GITERR_ZLIB, "error reading from the zlib stream"); + return -1; + } + + if (st == Z_STREAM_END) + obj->done = 1; + + + /* If we didn't write anything out but we're not done, we need more data */ + if (!written && st != Z_STREAM_END) + return GIT_EBUFS; + + return written; + +} + +void git_packfile_stream_free(git_packfile_stream *obj) +{ + inflateEnd(&obj->zstream); +} + +int packfile_unpack_compressed( + git_rawobj *obj, + struct git_pack_file *p, + git_mwindow **w_curs, + git_off_t *curpos, + size_t size, + git_otype type) +{ + size_t buf_size; + int st; + z_stream stream; + unsigned char *buffer, *in; + + GITERR_CHECK_ALLOC_ADD(&buf_size, size, 1); + buffer = git__calloc(1, buf_size); + GITERR_CHECK_ALLOC(buffer); + + memset(&stream, 0, sizeof(stream)); + stream.next_out = buffer; + stream.avail_out = (uInt)buf_size; + stream.zalloc = use_git_alloc; + stream.zfree = use_git_free; + + st = inflateInit(&stream); + if (st != Z_OK) { + git__free(buffer); + giterr_set(GITERR_ZLIB, "failed to init zlib stream on unpack"); + + return -1; + } + + do { + in = pack_window_open(p, w_curs, *curpos, &stream.avail_in); + stream.next_in = in; + st = inflate(&stream, Z_FINISH); + git_mwindow_close(w_curs); + + if (!stream.avail_out) + break; /* the payload is larger than it should be */ + + if (st == Z_BUF_ERROR && in == NULL) { + inflateEnd(&stream); + git__free(buffer); + return GIT_EBUFS; + } + + *curpos += stream.next_in - in; + } while (st == Z_OK || st == Z_BUF_ERROR); + + inflateEnd(&stream); + + if ((st != Z_STREAM_END) || stream.total_out != size) { + git__free(buffer); + giterr_set(GITERR_ZLIB, "error inflating zlib stream"); + return -1; + } + + obj->type = type; + obj->len = size; + obj->data = buffer; + return 0; +} + +/* + * curpos is where the data starts, delta_obj_offset is the where the + * header starts + */ +git_off_t get_delta_base( + struct git_pack_file *p, + git_mwindow **w_curs, + git_off_t *curpos, + git_otype type, + git_off_t delta_obj_offset) +{ + unsigned int left = 0; + unsigned char *base_info; + git_off_t base_offset; + git_oid unused; + + base_info = pack_window_open(p, w_curs, *curpos, &left); + /* Assumption: the only reason this would fail is because the file is too small */ + if (base_info == NULL) + return GIT_EBUFS; + /* pack_window_open() assured us we have [base_info, base_info + 20) + * as a range that we can look at without walking off the + * end of the mapped window. Its actually the hash size + * that is assured. An OFS_DELTA longer than the hash size + * is stupid, as then a REF_DELTA would be smaller to store. + */ + if (type == GIT_OBJ_OFS_DELTA) { + unsigned used = 0; + unsigned char c = base_info[used++]; + base_offset = c & 127; + while (c & 128) { + if (left <= used) + return GIT_EBUFS; + base_offset += 1; + if (!base_offset || MSB(base_offset, 7)) + return 0; /* overflow */ + c = base_info[used++]; + base_offset = (base_offset << 7) + (c & 127); + } + base_offset = delta_obj_offset - base_offset; + if (base_offset <= 0 || base_offset >= delta_obj_offset) + return 0; /* out of bound */ + *curpos += used; + } else if (type == GIT_OBJ_REF_DELTA) { + /* If we have the cooperative cache, search in it first */ + if (p->has_cache) { + khiter_t k; + git_oid oid; + + git_oid_fromraw(&oid, base_info); + k = kh_get(oid, p->idx_cache, &oid); + if (k != kh_end(p->idx_cache)) { + *curpos += 20; + return ((struct git_pack_entry *)kh_value(p->idx_cache, k))->offset; + } + } + /* The base entry _must_ be in the same pack */ + if (pack_entry_find_offset(&base_offset, &unused, p, (git_oid *)base_info, GIT_OID_HEXSZ) < 0) + return packfile_error("base entry delta is not in the same pack"); + *curpos += 20; + } else + return 0; + + return base_offset; +} + +/*********************************************************** + * + * PACKFILE METHODS + * + ***********************************************************/ + +void git_packfile_free(struct git_pack_file *p) +{ + if (!p) + return; + + cache_free(&p->bases); + + if (p->mwf.fd >= 0) { + git_mwindow_free_all_locked(&p->mwf); + p_close(p->mwf.fd); + } + + pack_index_free(p); + + git__free(p->bad_object_sha1); + + git_mutex_free(&p->lock); + git_mutex_free(&p->bases.lock); + git__free(p); +} + +static int packfile_open(struct git_pack_file *p) +{ + struct stat st; + struct git_pack_header hdr; + git_oid sha1; + unsigned char *idx_sha1; + + if (p->index_version == -1 && pack_index_open(p) < 0) + return git_odb__error_notfound("failed to open packfile", NULL); + + /* if mwf opened by another thread, return now */ + if (git_mutex_lock(&p->lock) < 0) + return packfile_error("failed to get lock for open"); + + if (p->mwf.fd >= 0) { + git_mutex_unlock(&p->lock); + return 0; + } + + /* TODO: open with noatime */ + p->mwf.fd = git_futils_open_ro(p->pack_name); + if (p->mwf.fd < 0) + goto cleanup; + + if (p_fstat(p->mwf.fd, &st) < 0 || + git_mwindow_file_register(&p->mwf) < 0) + goto cleanup; + + /* If we created the struct before we had the pack we lack size. */ + if (!p->mwf.size) { + if (!S_ISREG(st.st_mode)) + goto cleanup; + p->mwf.size = (git_off_t)st.st_size; + } else if (p->mwf.size != st.st_size) + goto cleanup; + +#if 0 + /* We leave these file descriptors open with sliding mmap; + * there is no point keeping them open across exec(), though. + */ + fd_flag = fcntl(p->mwf.fd, F_GETFD, 0); + if (fd_flag < 0) + goto cleanup; + + fd_flag |= FD_CLOEXEC; + if (fcntl(p->pack_fd, F_SETFD, fd_flag) == -1) + goto cleanup; +#endif + + /* Verify we recognize this pack file format. */ + if (p_read(p->mwf.fd, &hdr, sizeof(hdr)) < 0 || + hdr.hdr_signature != htonl(PACK_SIGNATURE) || + !pack_version_ok(hdr.hdr_version)) + goto cleanup; + + /* Verify the pack matches its index. */ + if (p->num_objects != ntohl(hdr.hdr_entries) || + p_lseek(p->mwf.fd, p->mwf.size - GIT_OID_RAWSZ, SEEK_SET) == -1 || + p_read(p->mwf.fd, sha1.id, GIT_OID_RAWSZ) < 0) + goto cleanup; + + idx_sha1 = ((unsigned char *)p->index_map.data) + p->index_map.len - 40; + + if (git_oid__cmp(&sha1, (git_oid *)idx_sha1) != 0) + goto cleanup; + + git_mutex_unlock(&p->lock); + return 0; + +cleanup: + giterr_set(GITERR_OS, "Invalid packfile '%s'", p->pack_name); + + if (p->mwf.fd >= 0) + p_close(p->mwf.fd); + p->mwf.fd = -1; + + git_mutex_unlock(&p->lock); + + return -1; +} + +int git_packfile__name(char **out, const char *path) +{ + size_t path_len; + git_buf buf = GIT_BUF_INIT; + + path_len = strlen(path); + + if (path_len < strlen(".idx")) + return git_odb__error_notfound("invalid packfile path", NULL); + + if (git_buf_printf(&buf, "%.*s.pack", (int)(path_len - strlen(".idx")), path) < 0) + return -1; + + *out = git_buf_detach(&buf); + return 0; +} + +int git_packfile_alloc(struct git_pack_file **pack_out, const char *path) +{ + struct stat st; + struct git_pack_file *p; + size_t path_len = path ? strlen(path) : 0, alloc_len; + + *pack_out = NULL; + + if (path_len < strlen(".idx")) + return git_odb__error_notfound("invalid packfile path", NULL); + + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*p), path_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); + + p = git__calloc(1, alloc_len); + GITERR_CHECK_ALLOC(p); + + memcpy(p->pack_name, path, path_len + 1); + + /* + * Make sure a corresponding .pack file exists and that + * the index looks sane. + */ + if (git__suffixcmp(path, ".idx") == 0) { + size_t root_len = path_len - strlen(".idx"); + + memcpy(p->pack_name + root_len, ".keep", sizeof(".keep")); + if (git_path_exists(p->pack_name) == true) + p->pack_keep = 1; + + memcpy(p->pack_name + root_len, ".pack", sizeof(".pack")); + } + + if (p_stat(p->pack_name, &st) < 0 || !S_ISREG(st.st_mode)) { + git__free(p); + return git_odb__error_notfound("packfile not found", NULL); + } + + /* ok, it looks sane as far as we can check without + * actually mapping the pack file. + */ + p->mwf.fd = -1; + p->mwf.size = st.st_size; + p->pack_local = 1; + p->mtime = (git_time_t)st.st_mtime; + p->index_version = -1; + + if (git_mutex_init(&p->lock)) { + giterr_set(GITERR_OS, "Failed to initialize packfile mutex"); + git__free(p); + return -1; + } + + if (cache_init(&p->bases) < 0) { + git__free(p); + return -1; + } + + *pack_out = p; + + return 0; +} + +/*********************************************************** + * + * PACKFILE ENTRY SEARCH INTERNALS + * + ***********************************************************/ + +static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n) +{ + const unsigned char *index = p->index_map.data; + index += 4 * 256; + if (p->index_version == 1) { + return ntohl(*((uint32_t *)(index + 24 * n))); + } else { + uint32_t off; + index += 8 + p->num_objects * (20 + 4); + off = ntohl(*((uint32_t *)(index + 4 * n))); + if (!(off & 0x80000000)) + return off; + index += p->num_objects * 4 + (off & 0x7fffffff) * 8; + return (((uint64_t)ntohl(*((uint32_t *)(index + 0)))) << 32) | + ntohl(*((uint32_t *)(index + 4))); + } +} + +static int git__memcmp4(const void *a, const void *b) { + return memcmp(a, b, 4); +} + +int git_pack_foreach_entry( + struct git_pack_file *p, + git_odb_foreach_cb cb, + void *data) +{ + const unsigned char *index = p->index_map.data, *current; + uint32_t i; + int error = 0; + + if (index == NULL) { + if ((error = pack_index_open(p)) < 0) + return error; + + assert(p->index_map.data); + + index = p->index_map.data; + } + + if (p->index_version > 1) { + index += 8; + } + + index += 4 * 256; + + if (p->oids == NULL) { + git_vector offsets, oids; + + if ((error = git_vector_init(&oids, p->num_objects, NULL))) + return error; + + if ((error = git_vector_init(&offsets, p->num_objects, git__memcmp4))) + return error; + + if (p->index_version > 1) { + const unsigned char *off = index + 24 * p->num_objects; + for (i = 0; i < p->num_objects; i++) + git_vector_insert(&offsets, (void*)&off[4 * i]); + git_vector_sort(&offsets); + git_vector_foreach(&offsets, i, current) + git_vector_insert(&oids, (void*)&index[5 * (current - off)]); + } else { + for (i = 0; i < p->num_objects; i++) + git_vector_insert(&offsets, (void*)&index[24 * i]); + git_vector_sort(&offsets); + git_vector_foreach(&offsets, i, current) + git_vector_insert(&oids, (void*)¤t[4]); + } + + git_vector_free(&offsets); + p->oids = (git_oid **)git_vector_detach(NULL, NULL, &oids); + } + + for (i = 0; i < p->num_objects; i++) + if ((error = cb(p->oids[i], data)) != 0) + return giterr_set_after_callback(error); + + return error; +} + +static int pack_entry_find_offset( + git_off_t *offset_out, + git_oid *found_oid, + struct git_pack_file *p, + const git_oid *short_oid, + size_t len) +{ + const uint32_t *level1_ofs = p->index_map.data; + const unsigned char *index = p->index_map.data; + unsigned hi, lo, stride; + int pos, found = 0; + const unsigned char *current = 0; + + *offset_out = 0; + + if (p->index_version == -1) { + int error; + + if ((error = pack_index_open(p)) < 0) + return error; + assert(p->index_map.data); + + index = p->index_map.data; + level1_ofs = p->index_map.data; + } + + if (p->index_version > 1) { + level1_ofs += 2; + index += 8; + } + + index += 4 * 256; + hi = ntohl(level1_ofs[(int)short_oid->id[0]]); + lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(level1_ofs[(int)short_oid->id[0] - 1])); + + if (p->index_version > 1) { + stride = 20; + } else { + stride = 24; + index += 4; + } + +#ifdef INDEX_DEBUG_LOOKUP + printf("%02x%02x%02x... lo %u hi %u nr %d\n", + short_oid->id[0], short_oid->id[1], short_oid->id[2], lo, hi, p->num_objects); +#endif + +#ifdef GIT_USE_LOOKUP + pos = sha1_entry_pos(index, stride, 0, lo, hi, p->num_objects, short_oid->id); +#else + pos = sha1_position(index, stride, lo, hi, short_oid->id); +#endif + + if (pos >= 0) { + /* An object matching exactly the oid was found */ + found = 1; + current = index + pos * stride; + } else { + /* No object was found */ + /* pos refers to the object with the "closest" oid to short_oid */ + pos = - 1 - pos; + if (pos < (int)p->num_objects) { + current = index + pos * stride; + + if (!git_oid_ncmp(short_oid, (const git_oid *)current, len)) + found = 1; + } + } + + if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)p->num_objects) { + /* Check for ambiguousity */ + const unsigned char *next = current + stride; + + if (!git_oid_ncmp(short_oid, (const git_oid *)next, len)) { + found = 2; + } + } + + if (!found) + return git_odb__error_notfound("failed to find offset for pack entry", short_oid); + if (found > 1) + return git_odb__error_ambiguous("found multiple offsets for pack entry"); + + *offset_out = nth_packed_object_offset(p, pos); + git_oid_fromraw(found_oid, current); + +#ifdef INDEX_DEBUG_LOOKUP + { + unsigned char hex_sha1[GIT_OID_HEXSZ + 1]; + git_oid_fmt(hex_sha1, found_oid); + hex_sha1[GIT_OID_HEXSZ] = '\0'; + printf("found lo=%d %s\n", lo, hex_sha1); + } +#endif + + return 0; +} + +int git_pack_entry_find( + struct git_pack_entry *e, + struct git_pack_file *p, + const git_oid *short_oid, + size_t len) +{ + git_off_t offset; + git_oid found_oid; + int error; + + assert(p); + + if (len == GIT_OID_HEXSZ && p->num_bad_objects) { + unsigned i; + for (i = 0; i < p->num_bad_objects; i++) + if (git_oid__cmp(short_oid, &p->bad_object_sha1[i]) == 0) + return packfile_error("bad object found in packfile"); + } + + error = pack_entry_find_offset(&offset, &found_oid, p, short_oid, len); + if (error < 0) + return error; + + /* we found a unique entry in the index; + * make sure the packfile backing the index + * still exists on disk */ + if (p->mwf.fd == -1 && (error = packfile_open(p)) < 0) + return error; + + e->offset = offset; + e->p = p; + + git_oid_cpy(&e->sha1, &found_oid); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pack.h b/deps/libgit2-sys-0.2.17/libgit2/src/pack.h new file mode 100644 index 000000000..b3d5b2993 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pack.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_pack_h__ +#define INCLUDE_pack_h__ + +#include + +#include "git2/oid.h" + +#include "common.h" +#include "map.h" +#include "mwindow.h" +#include "odb.h" +#include "oidmap.h" +#include "array.h" + +#define GIT_PACK_FILE_MODE 0444 + +#define PACK_SIGNATURE 0x5041434b /* "PACK" */ +#define PACK_VERSION 2 +#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3)) +struct git_pack_header { + uint32_t hdr_signature; + uint32_t hdr_version; + uint32_t hdr_entries; +}; + +/* + * The first four bytes of index formats later than version 1 should + * start with this signature, as all older git binaries would find this + * value illegal and abort reading the file. + * + * This is the case because the number of objects in a packfile + * cannot exceed 1,431,660,000 as every object would need at least + * 3 bytes of data and the overall packfile cannot exceed 4 GiB with + * version 1 of the index file due to the offsets limited to 32 bits. + * Clearly the signature exceeds this maximum. + * + * Very old git binaries will also compare the first 4 bytes to the + * next 4 bytes in the index and abort with a "non-monotonic index" + * error if the second 4 byte word is smaller than the first 4 + * byte word. This would be true in the proposed future index + * format as idx_signature would be greater than idx_version. + */ + +#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */ + +struct git_pack_idx_header { + uint32_t idx_signature; + uint32_t idx_version; +}; + +typedef struct git_pack_cache_entry { + size_t last_usage; /* enough? */ + git_atomic refcount; + git_rawobj raw; +} git_pack_cache_entry; + +struct pack_chain_elem { + git_off_t base_key; + git_off_t offset; + size_t size; + git_otype type; +}; + +typedef git_array_t(struct pack_chain_elem) git_dependency_chain; + +#include "offmap.h" +#include "oidmap.h" + +#define GIT_PACK_CACHE_MEMORY_LIMIT 16 * 1024 * 1024 +#define GIT_PACK_CACHE_SIZE_LIMIT 1024 * 1024 /* don't bother caching anything over 1MB */ + +typedef struct { + size_t memory_used; + size_t memory_limit; + size_t use_ctr; + git_mutex lock; + git_offmap *entries; +} git_pack_cache; + +struct git_pack_file { + git_mwindow_file mwf; + git_map index_map; + git_mutex lock; /* protect updates to mwf and index_map */ + git_atomic refcount; + + uint32_t num_objects; + uint32_t num_bad_objects; + git_oid *bad_object_sha1; /* array of git_oid */ + + int index_version; + git_time_t mtime; + unsigned pack_local:1, pack_keep:1, has_cache:1; + git_oidmap *idx_cache; + git_oid **oids; + + git_pack_cache bases; /* delta base cache */ + + /* something like ".git/objects/pack/xxxxx.pack" */ + char pack_name[GIT_FLEX_ARRAY]; /* more */ +}; + +struct git_pack_entry { + git_off_t offset; + git_oid sha1; + struct git_pack_file *p; +}; + +typedef struct git_packfile_stream { + git_off_t curpos; + int done; + z_stream zstream; + struct git_pack_file *p; + git_mwindow *mw; +} git_packfile_stream; + +size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type); + +int git_packfile__name(char **out, const char *path); + +int git_packfile_unpack_header( + size_t *size_p, + git_otype *type_p, + git_mwindow_file *mwf, + git_mwindow **w_curs, + git_off_t *curpos); + +int git_packfile_resolve_header( + size_t *size_p, + git_otype *type_p, + struct git_pack_file *p, + git_off_t offset); + +int git_packfile_unpack(git_rawobj *obj, struct git_pack_file *p, git_off_t *obj_offset); +int packfile_unpack_compressed( + git_rawobj *obj, + struct git_pack_file *p, + git_mwindow **w_curs, + git_off_t *curpos, + size_t size, + git_otype type); + +int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos); +ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len); +void git_packfile_stream_free(git_packfile_stream *obj); + +git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs, + git_off_t *curpos, git_otype type, + git_off_t delta_obj_offset); + +void git_packfile_free(struct git_pack_file *p); +int git_packfile_alloc(struct git_pack_file **pack_out, const char *path); + +int git_pack_entry_find( + struct git_pack_entry *e, + struct git_pack_file *p, + const git_oid *short_oid, + size_t len); +int git_pack_foreach_entry( + struct git_pack_file *p, + git_odb_foreach_cb cb, + void *data); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/path.c b/deps/libgit2-sys-0.2.17/libgit2/src/path.c new file mode 100644 index 000000000..993fcf60f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/path.c @@ -0,0 +1,1531 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "path.h" +#include "posix.h" +#include "repository.h" +#ifdef GIT_WIN32 +#include "win32/posix.h" +#include "win32/w32_util.h" +#else +#include +#endif +#include +#include + +#define LOOKS_LIKE_DRIVE_PREFIX(S) (git__isalpha((S)[0]) && (S)[1] == ':') + +#ifdef GIT_WIN32 +static bool looks_like_network_computer_name(const char *path, int pos) +{ + if (pos < 3) + return false; + + if (path[0] != '/' || path[1] != '/') + return false; + + while (pos-- > 2) { + if (path[pos] == '/') + return false; + } + + return true; +} +#endif + +/* + * Based on the Android implementation, BSD licensed. + * http://android.git.kernel.org/ + * + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +int git_path_basename_r(git_buf *buffer, const char *path) +{ + const char *endp, *startp; + int len, result; + + /* Empty or NULL string gets treated as "." */ + if (path == NULL || *path == '\0') { + startp = "."; + len = 1; + goto Exit; + } + + /* Strip trailing slashes */ + endp = path + strlen(path) - 1; + while (endp > path && *endp == '/') + endp--; + + /* All slashes becomes "/" */ + if (endp == path && *endp == '/') { + startp = "/"; + len = 1; + goto Exit; + } + + /* Find the start of the base */ + startp = endp; + while (startp > path && *(startp - 1) != '/') + startp--; + + /* Cast is safe because max path < max int */ + len = (int)(endp - startp + 1); + +Exit: + result = len; + + if (buffer != NULL && git_buf_set(buffer, startp, len) < 0) + return -1; + + return result; +} + +/* + * Based on the Android implementation, BSD licensed. + * Check http://android.git.kernel.org/ + */ +int git_path_dirname_r(git_buf *buffer, const char *path) +{ + const char *endp; + int result, len; + + /* Empty or NULL string gets treated as "." */ + if (path == NULL || *path == '\0') { + path = "."; + len = 1; + goto Exit; + } + + /* Strip trailing slashes */ + endp = path + strlen(path) - 1; + while (endp > path && *endp == '/') + endp--; + + /* Find the start of the dir */ + while (endp > path && *endp != '/') + endp--; + + /* Either the dir is "/" or there are no slashes */ + if (endp == path) { + path = (*endp == '/') ? "/" : "."; + len = 1; + goto Exit; + } + + do { + endp--; + } while (endp > path && *endp == '/'); + + /* Cast is safe because max path < max int */ + len = (int)(endp - path + 1); + +#ifdef GIT_WIN32 + /* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return + 'C:/' here */ + + if (len == 2 && LOOKS_LIKE_DRIVE_PREFIX(path)) { + len = 3; + goto Exit; + } + + /* Similarly checks if we're dealing with a network computer name + '//computername/.git' will return '//computername/' */ + + if (looks_like_network_computer_name(path, len)) { + len++; + goto Exit; + } + +#endif + +Exit: + result = len; + + if (buffer != NULL && git_buf_set(buffer, path, len) < 0) + return -1; + + return result; +} + + +char *git_path_dirname(const char *path) +{ + git_buf buf = GIT_BUF_INIT; + char *dirname; + + git_path_dirname_r(&buf, path); + dirname = git_buf_detach(&buf); + git_buf_free(&buf); /* avoid memleak if error occurs */ + + return dirname; +} + +char *git_path_basename(const char *path) +{ + git_buf buf = GIT_BUF_INIT; + char *basename; + + git_path_basename_r(&buf, path); + basename = git_buf_detach(&buf); + git_buf_free(&buf); /* avoid memleak if error occurs */ + + return basename; +} + +size_t git_path_basename_offset(git_buf *buffer) +{ + ssize_t slash; + + if (!buffer || buffer->size <= 0) + return 0; + + slash = git_buf_rfind_next(buffer, '/'); + + if (slash >= 0 && buffer->ptr[slash] == '/') + return (size_t)(slash + 1); + + return 0; +} + +const char *git_path_topdir(const char *path) +{ + size_t len; + ssize_t i; + + assert(path); + len = strlen(path); + + if (!len || path[len - 1] != '/') + return NULL; + + for (i = (ssize_t)len - 2; i >= 0; --i) + if (path[i] == '/') + break; + + return &path[i + 1]; +} + +int git_path_root(const char *path) +{ + int offset = 0; + + /* Does the root of the path look like a windows drive ? */ + if (LOOKS_LIKE_DRIVE_PREFIX(path)) + offset += 2; + +#ifdef GIT_WIN32 + /* Are we dealing with a windows network path? */ + else if ((path[0] == '/' && path[1] == '/' && path[2] != '/') || + (path[0] == '\\' && path[1] == '\\' && path[2] != '\\')) + { + offset += 2; + + /* Skip the computer name segment */ + while (path[offset] && path[offset] != '/' && path[offset] != '\\') + offset++; + } +#endif + + if (path[offset] == '/' || path[offset] == '\\') + return offset; + + return -1; /* Not a real error - signals that path is not rooted */ +} + +int git_path_join_unrooted( + git_buf *path_out, const char *path, const char *base, ssize_t *root_at) +{ + ssize_t root; + + assert(path && path_out); + + root = (ssize_t)git_path_root(path); + + if (base != NULL && root < 0) { + if (git_buf_joinpath(path_out, base, path) < 0) + return -1; + + root = (ssize_t)strlen(base); + } else { + if (git_buf_sets(path_out, path) < 0) + return -1; + + if (root < 0) + root = 0; + else if (base) + git_path_equal_or_prefixed(base, path, &root); + } + + if (root_at) + *root_at = root; + + return 0; +} + +int git_path_prettify(git_buf *path_out, const char *path, const char *base) +{ + char buf[GIT_PATH_MAX]; + + assert(path && path_out); + + /* construct path if needed */ + if (base != NULL && git_path_root(path) < 0) { + if (git_buf_joinpath(path_out, base, path) < 0) + return -1; + path = path_out->ptr; + } + + if (p_realpath(path, buf) == NULL) { + /* giterr_set resets the errno when dealing with a GITERR_OS kind of error */ + int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_ENOTFOUND : -1; + giterr_set(GITERR_OS, "Failed to resolve path '%s'", path); + + git_buf_clear(path_out); + + return error; + } + + return git_buf_sets(path_out, buf); +} + +int git_path_prettify_dir(git_buf *path_out, const char *path, const char *base) +{ + int error = git_path_prettify(path_out, path, base); + return (error < 0) ? error : git_path_to_dir(path_out); +} + +int git_path_to_dir(git_buf *path) +{ + if (path->asize > 0 && + git_buf_len(path) > 0 && + path->ptr[git_buf_len(path) - 1] != '/') + git_buf_putc(path, '/'); + + return git_buf_oom(path) ? -1 : 0; +} + +void git_path_string_to_dir(char* path, size_t size) +{ + size_t end = strlen(path); + + if (end && path[end - 1] != '/' && end < size) { + path[end] = '/'; + path[end + 1] = '\0'; + } +} + +int git__percent_decode(git_buf *decoded_out, const char *input) +{ + int len, hi, lo, i; + assert(decoded_out && input); + + len = (int)strlen(input); + git_buf_clear(decoded_out); + + for(i = 0; i < len; i++) + { + char c = input[i]; + + if (c != '%') + goto append; + + if (i >= len - 2) + goto append; + + hi = git__fromhex(input[i + 1]); + lo = git__fromhex(input[i + 2]); + + if (hi < 0 || lo < 0) + goto append; + + c = (char)(hi << 4 | lo); + i += 2; + +append: + if (git_buf_putc(decoded_out, c) < 0) + return -1; + } + + return 0; +} + +static int error_invalid_local_file_uri(const char *uri) +{ + giterr_set(GITERR_CONFIG, "'%s' is not a valid local file URI", uri); + return -1; +} + +static int local_file_url_prefixlen(const char *file_url) +{ + int len = -1; + + if (git__prefixcmp(file_url, "file://") == 0) { + if (file_url[7] == '/') + len = 8; + else if (git__prefixcmp(file_url + 7, "localhost/") == 0) + len = 17; + } + + return len; +} + +bool git_path_is_local_file_url(const char *file_url) +{ + return (local_file_url_prefixlen(file_url) > 0); +} + +int git_path_fromurl(git_buf *local_path_out, const char *file_url) +{ + int offset; + + assert(local_path_out && file_url); + + if ((offset = local_file_url_prefixlen(file_url)) < 0 || + file_url[offset] == '\0' || file_url[offset] == '/') + return error_invalid_local_file_uri(file_url); + +#ifndef GIT_WIN32 + offset--; /* A *nix absolute path starts with a forward slash */ +#endif + + git_buf_clear(local_path_out); + return git__percent_decode(local_path_out, file_url + offset); +} + +int git_path_walk_up( + git_buf *path, + const char *ceiling, + int (*cb)(void *data, const char *), + void *data) +{ + int error = 0; + git_buf iter; + ssize_t stop = 0, scan; + char oldc = '\0'; + + assert(path && cb); + + if (ceiling != NULL) { + if (git__prefixcmp(path->ptr, ceiling) == 0) + stop = (ssize_t)strlen(ceiling); + else + stop = git_buf_len(path); + } + scan = git_buf_len(path); + + /* empty path: yield only once */ + if (!scan) { + error = cb(data, ""); + if (error) + giterr_set_after_callback(error); + return error; + } + + iter.ptr = path->ptr; + iter.size = git_buf_len(path); + iter.asize = path->asize; + + while (scan >= stop) { + error = cb(data, iter.ptr); + iter.ptr[scan] = oldc; + + if (error) { + giterr_set_after_callback(error); + break; + } + + scan = git_buf_rfind_next(&iter, '/'); + if (scan >= 0) { + scan++; + oldc = iter.ptr[scan]; + iter.size = scan; + iter.ptr[scan] = '\0'; + } + } + + if (scan >= 0) + iter.ptr[scan] = oldc; + + /* relative path: yield for the last component */ + if (!error && stop == 0 && iter.ptr[0] != '/') { + error = cb(data, ""); + if (error) + giterr_set_after_callback(error); + } + + return error; +} + +bool git_path_exists(const char *path) +{ + assert(path); + return p_access(path, F_OK) == 0; +} + +bool git_path_isdir(const char *path) +{ + struct stat st; + if (p_stat(path, &st) < 0) + return false; + + return S_ISDIR(st.st_mode) != 0; +} + +bool git_path_isfile(const char *path) +{ + struct stat st; + + assert(path); + if (p_stat(path, &st) < 0) + return false; + + return S_ISREG(st.st_mode) != 0; +} + +#ifdef GIT_WIN32 + +bool git_path_is_empty_dir(const char *path) +{ + git_win32_path filter_w; + bool empty = false; + + if (git_win32__findfirstfile_filter(filter_w, path)) { + WIN32_FIND_DATAW findData; + HANDLE hFind = FindFirstFileW(filter_w, &findData); + + /* FindFirstFile will fail if there are no children to the given + * path, which can happen if the given path is a file (and obviously + * has no children) or if the given path is an empty mount point. + * (Most directories have at least directory entries '.' and '..', + * but ridiculously another volume mounted in another drive letter's + * path space do not, and thus have nothing to enumerate.) If + * FindFirstFile fails, check if this is a directory-like thing + * (a mount point). + */ + if (hFind == INVALID_HANDLE_VALUE) + return git_path_isdir(path); + + /* If the find handle was created successfully, then it's a directory */ + empty = true; + + do { + /* Allow the enumeration to return . and .. and still be considered + * empty. In the special case of drive roots (i.e. C:\) where . and + * .. do not occur, we can still consider the path to be an empty + * directory if there's nothing there. */ + if (!git_path_is_dot_or_dotdotW(findData.cFileName)) { + empty = false; + break; + } + } while (FindNextFileW(hFind, &findData)); + + FindClose(hFind); + } + + return empty; +} + +#else + +static int path_found_entry(void *payload, git_buf *path) +{ + GIT_UNUSED(payload); + return !git_path_is_dot_or_dotdot(path->ptr); +} + +bool git_path_is_empty_dir(const char *path) +{ + int error; + git_buf dir = GIT_BUF_INIT; + + if (!git_path_isdir(path)) + return false; + + if ((error = git_buf_sets(&dir, path)) != 0) + giterr_clear(); + else + error = git_path_direach(&dir, 0, path_found_entry, NULL); + + git_buf_free(&dir); + + return !error; +} + +#endif + +int git_path_set_error(int errno_value, const char *path, const char *action) +{ + switch (errno_value) { + case ENOENT: + case ENOTDIR: + giterr_set(GITERR_OS, "Could not find '%s' to %s", path, action); + return GIT_ENOTFOUND; + + case EINVAL: + case ENAMETOOLONG: + giterr_set(GITERR_OS, "Invalid path for filesystem '%s'", path); + return GIT_EINVALIDSPEC; + + case EEXIST: + giterr_set(GITERR_OS, "Failed %s - '%s' already exists", action, path); + return GIT_EEXISTS; + + default: + giterr_set(GITERR_OS, "Could not %s '%s'", action, path); + return -1; + } +} + +int git_path_lstat(const char *path, struct stat *st) +{ + if (p_lstat(path, st) == 0) + return 0; + + return git_path_set_error(errno, path, "stat"); +} + +static bool _check_dir_contents( + git_buf *dir, + const char *sub, + bool (*predicate)(const char *)) +{ + bool result; + size_t dir_size = git_buf_len(dir); + size_t sub_size = strlen(sub); + size_t alloc_size; + + /* leave base valid even if we could not make space for subdir */ + if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, dir_size, sub_size) || + GIT_ADD_SIZET_OVERFLOW(&alloc_size, alloc_size, 2) || + git_buf_try_grow(dir, alloc_size, false, false) < 0) + return false; + + /* save excursion */ + git_buf_joinpath(dir, dir->ptr, sub); + + result = predicate(dir->ptr); + + /* restore path */ + git_buf_truncate(dir, dir_size); + return result; +} + +bool git_path_contains(git_buf *dir, const char *item) +{ + return _check_dir_contents(dir, item, &git_path_exists); +} + +bool git_path_contains_dir(git_buf *base, const char *subdir) +{ + return _check_dir_contents(base, subdir, &git_path_isdir); +} + +bool git_path_contains_file(git_buf *base, const char *file) +{ + return _check_dir_contents(base, file, &git_path_isfile); +} + +int git_path_find_dir(git_buf *dir, const char *path, const char *base) +{ + int error = git_path_join_unrooted(dir, path, base, NULL); + + if (!error) { + char buf[GIT_PATH_MAX]; + if (p_realpath(dir->ptr, buf) != NULL) + error = git_buf_sets(dir, buf); + } + + /* call dirname if this is not a directory */ + if (!error) /* && git_path_isdir(dir->ptr) == false) */ + error = (git_path_dirname_r(dir, dir->ptr) < 0) ? -1 : 0; + + if (!error) + error = git_path_to_dir(dir); + + return error; +} + +int git_path_resolve_relative(git_buf *path, size_t ceiling) +{ + char *base, *to, *from, *next; + size_t len; + + if (!path || git_buf_oom(path)) + return -1; + + if (ceiling > path->size) + ceiling = path->size; + + /* recognize drive prefixes, etc. that should not be backed over */ + if (ceiling == 0) + ceiling = git_path_root(path->ptr) + 1; + + /* recognize URL prefixes that should not be backed over */ + if (ceiling == 0) { + for (next = path->ptr; *next && git__isalpha(*next); ++next); + if (next[0] == ':' && next[1] == '/' && next[2] == '/') + ceiling = (next + 3) - path->ptr; + } + + base = to = from = path->ptr + ceiling; + + while (*from) { + for (next = from; *next && *next != '/'; ++next); + + len = next - from; + + if (len == 1 && from[0] == '.') + /* do nothing with singleton dot */; + + else if (len == 2 && from[0] == '.' && from[1] == '.') { + /* error out if trying to up one from a hard base */ + if (to == base && ceiling != 0) { + giterr_set(GITERR_INVALID, + "Cannot strip root component off url"); + return -1; + } + + /* no more path segments to strip, + * use '../' as a new base path */ + if (to == base) { + if (*next == '/') + len++; + + if (to != from) + memmove(to, from, len); + + to += len; + /* this is now the base, can't back up from a + * relative prefix */ + base = to; + } else { + /* back up a path segment */ + while (to > base && to[-1] == '/') to--; + while (to > base && to[-1] != '/') to--; + } + } else { + if (*next == '/' && *from != '/') + len++; + + if (to != from) + memmove(to, from, len); + + to += len; + } + + from += len; + + while (*from == '/') from++; + } + + *to = '\0'; + + path->size = to - path->ptr; + + return 0; +} + +int git_path_apply_relative(git_buf *target, const char *relpath) +{ + git_buf_joinpath(target, git_buf_cstr(target), relpath); + return git_path_resolve_relative(target, 0); +} + +int git_path_cmp( + const char *name1, size_t len1, int isdir1, + const char *name2, size_t len2, int isdir2, + int (*compare)(const char *, const char *, size_t)) +{ + unsigned char c1, c2; + size_t len = len1 < len2 ? len1 : len2; + int cmp; + + cmp = compare(name1, name2, len); + if (cmp) + return cmp; + + c1 = name1[len]; + c2 = name2[len]; + + if (c1 == '\0' && isdir1) + c1 = '/'; + + if (c2 == '\0' && isdir2) + c2 = '/'; + + return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0; +} + +int git_path_make_relative(git_buf *path, const char *parent) +{ + const char *p, *q, *p_dirsep, *q_dirsep; + size_t plen = path->size, newlen, alloclen, depth = 1, i, offset; + + for (p_dirsep = p = path->ptr, q_dirsep = q = parent; *p && *q; p++, q++) { + if (*p == '/' && *q == '/') { + p_dirsep = p; + q_dirsep = q; + } + else if (*p != *q) + break; + } + + /* need at least 1 common path segment */ + if ((p_dirsep == path->ptr || q_dirsep == parent) && + (*p_dirsep != '/' || *q_dirsep != '/')) { + giterr_set(GITERR_INVALID, + "%s is not a parent of %s", parent, path->ptr); + return GIT_ENOTFOUND; + } + + if (*p == '/' && !*q) + p++; + else if (!*p && *q == '/') + q++; + else if (!*p && !*q) + return git_buf_clear(path), 0; + else { + p = p_dirsep + 1; + q = q_dirsep + 1; + } + + plen -= (p - path->ptr); + + if (!*q) + return git_buf_set(path, p, plen); + + for (; (q = strchr(q, '/')) && *(q + 1); q++) + depth++; + + GITERR_CHECK_ALLOC_MULTIPLY(&newlen, depth, 3); + GITERR_CHECK_ALLOC_ADD(&newlen, newlen, plen); + + GITERR_CHECK_ALLOC_ADD(&alloclen, newlen, 1); + + /* save the offset as we might realllocate the pointer */ + offset = p - path->ptr; + if (git_buf_try_grow(path, alloclen, 1, 0) < 0) + return -1; + p = path->ptr + offset; + + memmove(path->ptr + (depth * 3), p, plen + 1); + + for (i = 0; i < depth; i++) + memcpy(path->ptr + (i * 3), "../", 3); + + path->size = newlen; + return 0; +} + +bool git_path_has_non_ascii(const char *path, size_t pathlen) +{ + const uint8_t *scan = (const uint8_t *)path, *end; + + for (end = scan + pathlen; scan < end; ++scan) + if (*scan & 0x80) + return true; + + return false; +} + +#ifdef GIT_USE_ICONV + +int git_path_iconv_init_precompose(git_path_iconv_t *ic) +{ + git_buf_init(&ic->buf, 0); + ic->map = iconv_open(GIT_PATH_REPO_ENCODING, GIT_PATH_NATIVE_ENCODING); + return 0; +} + +void git_path_iconv_clear(git_path_iconv_t *ic) +{ + if (ic) { + if (ic->map != (iconv_t)-1) + iconv_close(ic->map); + git_buf_free(&ic->buf); + } +} + +int git_path_iconv(git_path_iconv_t *ic, char **in, size_t *inlen) +{ + char *nfd = *in, *nfc; + size_t nfdlen = *inlen, nfclen, wantlen = nfdlen, alloclen, rv; + int retry = 1; + + if (!ic || ic->map == (iconv_t)-1 || + !git_path_has_non_ascii(*in, *inlen)) + return 0; + + git_buf_clear(&ic->buf); + + while (1) { + GITERR_CHECK_ALLOC_ADD(&alloclen, wantlen, 1); + if (git_buf_grow(&ic->buf, alloclen) < 0) + return -1; + + nfc = ic->buf.ptr + ic->buf.size; + nfclen = ic->buf.asize - ic->buf.size; + + rv = iconv(ic->map, &nfd, &nfdlen, &nfc, &nfclen); + + ic->buf.size = (nfc - ic->buf.ptr); + + if (rv != (size_t)-1) + break; + + /* if we cannot convert the data (probably because iconv thinks + * it is not valid UTF-8 source data), then use original data + */ + if (errno != E2BIG) + return 0; + + /* make space for 2x the remaining data to be converted + * (with per retry overhead to avoid infinite loops) + */ + wantlen = ic->buf.size + max(nfclen, nfdlen) * 2 + (size_t)(retry * 4); + + if (retry++ > 4) + goto fail; + } + + ic->buf.ptr[ic->buf.size] = '\0'; + + *in = ic->buf.ptr; + *inlen = ic->buf.size; + + return 0; + +fail: + giterr_set(GITERR_OS, "Unable to convert unicode path data"); + return -1; +} + +static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D.XXXXXX"; +static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX"; + +/* Check if the platform is decomposing unicode data for us. We will + * emulate core Git and prefer to use precomposed unicode data internally + * on these platforms, composing the decomposed unicode on the fly. + * + * This mainly happens on the Mac where HDFS stores filenames as + * decomposed unicode. Even on VFAT and SAMBA file systems, the Mac will + * return decomposed unicode from readdir() even when the actual + * filesystem is storing precomposed unicode. + */ +bool git_path_does_fs_decompose_unicode(const char *root) +{ + git_buf path = GIT_BUF_INIT; + int fd; + bool found_decomposed = false; + char tmp[6]; + + /* Create a file using a precomposed path and then try to find it + * using the decomposed name. If the lookup fails, then we will mark + * that we should precompose unicode for this repository. + */ + if (git_buf_joinpath(&path, root, nfc_file) < 0 || + (fd = p_mkstemp(path.ptr)) < 0) + goto done; + p_close(fd); + + /* record trailing digits generated by mkstemp */ + memcpy(tmp, path.ptr + path.size - sizeof(tmp), sizeof(tmp)); + + /* try to look up as NFD path */ + if (git_buf_joinpath(&path, root, nfd_file) < 0) + goto done; + memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp)); + + found_decomposed = git_path_exists(path.ptr); + + /* remove temporary file (using original precomposed path) */ + if (git_buf_joinpath(&path, root, nfc_file) < 0) + goto done; + memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp)); + + (void)p_unlink(path.ptr); + +done: + git_buf_free(&path); + return found_decomposed; +} + +#else + +bool git_path_does_fs_decompose_unicode(const char *root) +{ + GIT_UNUSED(root); + return false; +} + +#endif + +#if defined(__sun) || defined(__GNU__) +typedef char path_dirent_data[sizeof(struct dirent) + FILENAME_MAX + 1]; +#else +typedef struct dirent path_dirent_data; +#endif + +int git_path_direach( + git_buf *path, + uint32_t flags, + int (*fn)(void *, git_buf *), + void *arg) +{ + int error = 0; + ssize_t wd_len; + DIR *dir; + path_dirent_data de_data; + struct dirent *de, *de_buf = (struct dirent *)&de_data; + + GIT_UNUSED(flags); + +#ifdef GIT_USE_ICONV + git_path_iconv_t ic = GIT_PATH_ICONV_INIT; +#endif + + if (git_path_to_dir(path) < 0) + return -1; + + wd_len = git_buf_len(path); + + if ((dir = opendir(path->ptr)) == NULL) { + giterr_set(GITERR_OS, "Failed to open directory '%s'", path->ptr); + if (errno == ENOENT) + return GIT_ENOTFOUND; + + return -1; + } + +#ifdef GIT_USE_ICONV + if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0) + (void)git_path_iconv_init_precompose(&ic); +#endif + + while (p_readdir_r(dir, de_buf, &de) == 0 && de != NULL) { + char *de_path = de->d_name; + size_t de_len = strlen(de_path); + + if (git_path_is_dot_or_dotdot(de_path)) + continue; + +#ifdef GIT_USE_ICONV + if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0) + break; +#endif + + if ((error = git_buf_put(path, de_path, de_len)) < 0) + break; + + error = fn(arg, path); + + git_buf_truncate(path, wd_len); /* restore path */ + + if (error != 0) { + giterr_set_after_callback(error); + break; + } + } + + closedir(dir); + +#ifdef GIT_USE_ICONV + git_path_iconv_clear(&ic); +#endif + + return error; +} + +static int entry_path_alloc( + char **out, + const char *path, + size_t path_len, + const char *de_path, + size_t de_len, + size_t alloc_extra) +{ + int need_slash = (path_len > 0 && path[path_len-1] != '/') ? 1 : 0; + size_t alloc_size; + char *entry_path; + + GITERR_CHECK_ALLOC_ADD(&alloc_size, path_len, de_len); + GITERR_CHECK_ALLOC_ADD(&alloc_size, alloc_size, need_slash); + GITERR_CHECK_ALLOC_ADD(&alloc_size, alloc_size, 1); + GITERR_CHECK_ALLOC_ADD(&alloc_size, alloc_size, alloc_extra); + entry_path = git__calloc(1, alloc_size); + GITERR_CHECK_ALLOC(entry_path); + + if (path_len) + memcpy(entry_path, path, path_len); + + if (need_slash) + entry_path[path_len] = '/'; + + memcpy(&entry_path[path_len + need_slash], de_path, de_len); + + *out = entry_path; + return 0; +} + +int git_path_dirload( + const char *path, + size_t prefix_len, + size_t alloc_extra, + unsigned int flags, + git_vector *contents) +{ + int error; + DIR *dir; + size_t path_len; + path_dirent_data de_data; + struct dirent *de, *de_buf = (struct dirent *)&de_data; + + GIT_UNUSED(flags); + +#ifdef GIT_USE_ICONV + git_path_iconv_t ic = GIT_PATH_ICONV_INIT; +#endif + + assert(path && contents); + + path_len = strlen(path); + + if (!path_len || path_len < prefix_len) { + giterr_set(GITERR_INVALID, "Invalid directory path '%s'", path); + return -1; + } + if ((dir = opendir(path)) == NULL) { + giterr_set(GITERR_OS, "Failed to open directory '%s'", path); + return -1; + } + +#ifdef GIT_USE_ICONV + if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0) + (void)git_path_iconv_init_precompose(&ic); +#endif + + path += prefix_len; + path_len -= prefix_len; + + while ((error = p_readdir_r(dir, de_buf, &de)) == 0 && de != NULL) { + char *entry_path, *de_path = de->d_name; + size_t de_len = strlen(de_path); + + if (git_path_is_dot_or_dotdot(de_path)) + continue; + +#ifdef GIT_USE_ICONV + if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0) + break; +#endif + + if ((error = entry_path_alloc(&entry_path, + path, path_len, de_path, de_len, alloc_extra)) < 0) + break; + + if ((error = git_vector_insert(contents, entry_path)) < 0) { + git__free(entry_path); + break; + } + } + + closedir(dir); + +#ifdef GIT_USE_ICONV + git_path_iconv_clear(&ic); +#endif + + if (error != 0) + giterr_set(GITERR_OS, "Failed to process directory entry in '%s'", path); + + return error; +} + +int git_path_with_stat_cmp(const void *a, const void *b) +{ + const git_path_with_stat *psa = a, *psb = b; + return strcmp(psa->path, psb->path); +} + +int git_path_with_stat_cmp_icase(const void *a, const void *b) +{ + const git_path_with_stat *psa = a, *psb = b; + return strcasecmp(psa->path, psb->path); +} + +int git_path_dirload_with_stat( + const char *path, + size_t prefix_len, + unsigned int flags, + const char *start_stat, + const char *end_stat, + git_vector *contents) +{ + int error; + unsigned int i; + git_path_with_stat *ps; + git_buf full = GIT_BUF_INIT; + int (*strncomp)(const char *a, const char *b, size_t sz); + size_t start_len = start_stat ? strlen(start_stat) : 0; + size_t end_len = end_stat ? strlen(end_stat) : 0, cmp_len; + + if (git_buf_set(&full, path, prefix_len) < 0) + return -1; + + error = git_path_dirload( + path, prefix_len, sizeof(git_path_with_stat) + 1, flags, contents); + if (error < 0) { + git_buf_free(&full); + return error; + } + + strncomp = (flags & GIT_PATH_DIR_IGNORE_CASE) != 0 ? + git__strncasecmp : git__strncmp; + + /* stat struct at start of git_path_with_stat, so shift path text */ + git_vector_foreach(contents, i, ps) { + size_t path_len = strlen((char *)ps); + memmove(ps->path, ps, path_len + 1); + ps->path_len = path_len; + } + + git_vector_foreach(contents, i, ps) { + /* skip if before start_stat or after end_stat */ + cmp_len = min(start_len, ps->path_len); + if (cmp_len && strncomp(ps->path, start_stat, cmp_len) < 0) + continue; + cmp_len = min(end_len, ps->path_len); + if (cmp_len && strncomp(ps->path, end_stat, cmp_len) > 0) + continue; + + git_buf_truncate(&full, prefix_len); + + if ((error = git_buf_joinpath(&full, full.ptr, ps->path)) < 0 || + (error = git_path_lstat(full.ptr, &ps->st)) < 0) { + + if (error == GIT_ENOTFOUND) { + /* file was removed between readdir and lstat */ + char *entry_path = git_vector_get(contents, i); + git_vector_remove(contents, i--); + git__free(entry_path); + } else { + /* Treat the file as unreadable if we get any other error */ + memset(&ps->st, 0, sizeof(ps->st)); + ps->st.st_mode = GIT_FILEMODE_UNREADABLE; + } + + giterr_clear(); + error = 0; + continue; + } + + if (S_ISDIR(ps->st.st_mode)) { + ps->path[ps->path_len++] = '/'; + ps->path[ps->path_len] = '\0'; + } + else if (!S_ISREG(ps->st.st_mode) && !S_ISLNK(ps->st.st_mode)) { + char *entry_path = git_vector_get(contents, i); + git_vector_remove(contents, i--); + git__free(entry_path); + } + } + + /* sort now that directory suffix is added */ + git_vector_sort(contents); + + git_buf_free(&full); + + return error; +} + +int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path) +{ + if (git_path_is_local_file_url(url_or_path)) + return git_path_fromurl(local_path_out, url_or_path); + else + return git_buf_sets(local_path_out, url_or_path); +} + +/* Reject paths like AUX or COM1, or those versions that end in a dot or + * colon. ("AUX." or "AUX:") + */ +GIT_INLINE(bool) verify_dospath( + const char *component, + size_t len, + const char dospath[3], + bool trailing_num) +{ + size_t last = trailing_num ? 4 : 3; + + if (len < last || git__strncasecmp(component, dospath, 3) != 0) + return true; + + if (trailing_num && (component[3] < '1' || component[3] > '9')) + return true; + + return (len > last && + component[last] != '.' && + component[last] != ':'); +} + +static int32_t next_hfs_char(const char **in, size_t *len) +{ + while (*len) { + int32_t codepoint; + int cp_len = git__utf8_iterate((const uint8_t *)(*in), (int)(*len), &codepoint); + if (cp_len < 0) + return -1; + + (*in) += cp_len; + (*len) -= cp_len; + + /* these code points are ignored completely */ + switch (codepoint) { + case 0x200c: /* ZERO WIDTH NON-JOINER */ + case 0x200d: /* ZERO WIDTH JOINER */ + case 0x200e: /* LEFT-TO-RIGHT MARK */ + case 0x200f: /* RIGHT-TO-LEFT MARK */ + case 0x202a: /* LEFT-TO-RIGHT EMBEDDING */ + case 0x202b: /* RIGHT-TO-LEFT EMBEDDING */ + case 0x202c: /* POP DIRECTIONAL FORMATTING */ + case 0x202d: /* LEFT-TO-RIGHT OVERRIDE */ + case 0x202e: /* RIGHT-TO-LEFT OVERRIDE */ + case 0x206a: /* INHIBIT SYMMETRIC SWAPPING */ + case 0x206b: /* ACTIVATE SYMMETRIC SWAPPING */ + case 0x206c: /* INHIBIT ARABIC FORM SHAPING */ + case 0x206d: /* ACTIVATE ARABIC FORM SHAPING */ + case 0x206e: /* NATIONAL DIGIT SHAPES */ + case 0x206f: /* NOMINAL DIGIT SHAPES */ + case 0xfeff: /* ZERO WIDTH NO-BREAK SPACE */ + continue; + } + + /* fold into lowercase -- this will only fold characters in + * the ASCII range, which is perfectly fine, because the + * git folder name can only be composed of ascii characters + */ + return tolower(codepoint); + } + return 0; /* NULL byte -- end of string */ +} + +static bool verify_dotgit_hfs(const char *path, size_t len) +{ + if (next_hfs_char(&path, &len) != '.' || + next_hfs_char(&path, &len) != 'g' || + next_hfs_char(&path, &len) != 'i' || + next_hfs_char(&path, &len) != 't' || + next_hfs_char(&path, &len) != 0) + return true; + + return false; +} + +GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size_t len) +{ + git_buf *reserved = git_repository__reserved_names_win32; + size_t reserved_len = git_repository__reserved_names_win32_len; + size_t start = 0, i; + + if (repo) + git_repository__reserved_names(&reserved, &reserved_len, repo, true); + + for (i = 0; i < reserved_len; i++) { + git_buf *r = &reserved[i]; + + if (len >= r->size && + strncasecmp(path, r->ptr, r->size) == 0) { + start = r->size; + break; + } + } + + if (!start) + return true; + + /* Reject paths like ".git\" */ + if (path[start] == '\\') + return false; + + /* Reject paths like '.git ' or '.git.' */ + for (i = start; i < len; i++) { + if (path[i] != ' ' && path[i] != '.') + return true; + } + + return false; +} + +GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags) +{ + if ((flags & GIT_PATH_REJECT_BACKSLASH) && c == '\\') + return false; + + if ((flags & GIT_PATH_REJECT_SLASH) && c == '/') + return false; + + if (flags & GIT_PATH_REJECT_NT_CHARS) { + if (c < 32) + return false; + + switch (c) { + case '<': + case '>': + case ':': + case '"': + case '|': + case '?': + case '*': + return false; + } + } + + return true; +} + +/* + * We fundamentally don't like some paths when dealing with user-inputted + * strings (in checkout or ref names): we don't want dot or dot-dot + * anywhere, we want to avoid writing weird paths on Windows that can't + * be handled by tools that use the non-\\?\ APIs, we don't want slashes + * or double slashes at the end of paths that can make them ambiguous. + * + * For checkout, we don't want to recurse into ".git" either. + */ +static bool verify_component( + git_repository *repo, + const char *component, + size_t len, + unsigned int flags) +{ + if (len == 0) + return false; + + if ((flags & GIT_PATH_REJECT_TRAVERSAL) && + len == 1 && component[0] == '.') + return false; + + if ((flags & GIT_PATH_REJECT_TRAVERSAL) && + len == 2 && component[0] == '.' && component[1] == '.') + return false; + + if ((flags & GIT_PATH_REJECT_TRAILING_DOT) && component[len-1] == '.') + return false; + + if ((flags & GIT_PATH_REJECT_TRAILING_SPACE) && component[len-1] == ' ') + return false; + + if ((flags & GIT_PATH_REJECT_TRAILING_COLON) && component[len-1] == ':') + return false; + + if (flags & GIT_PATH_REJECT_DOS_PATHS) { + if (!verify_dospath(component, len, "CON", false) || + !verify_dospath(component, len, "PRN", false) || + !verify_dospath(component, len, "AUX", false) || + !verify_dospath(component, len, "NUL", false) || + !verify_dospath(component, len, "COM", true) || + !verify_dospath(component, len, "LPT", true)) + return false; + } + + if (flags & GIT_PATH_REJECT_DOT_GIT_HFS && + !verify_dotgit_hfs(component, len)) + return false; + + if (flags & GIT_PATH_REJECT_DOT_GIT_NTFS && + !verify_dotgit_ntfs(repo, component, len)) + return false; + + if ((flags & GIT_PATH_REJECT_DOT_GIT_HFS) == 0 && + (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) == 0 && + (flags & GIT_PATH_REJECT_DOT_GIT) && + len == 4 && + component[0] == '.' && + (component[1] == 'g' || component[1] == 'G') && + (component[2] == 'i' || component[2] == 'I') && + (component[3] == 't' || component[3] == 'T')) + return false; + + return true; +} + +GIT_INLINE(unsigned int) dotgit_flags( + git_repository *repo, + unsigned int flags) +{ + int protectHFS = 0, protectNTFS = 0; + +#ifdef __APPLE__ + protectHFS = 1; +#endif + +#ifdef GIT_WIN32 + protectNTFS = 1; +#endif + + if (repo && !protectHFS) + git_repository__cvar(&protectHFS, repo, GIT_CVAR_PROTECTHFS); + if (protectHFS) + flags |= GIT_PATH_REJECT_DOT_GIT_HFS; + + if (repo && !protectNTFS) + git_repository__cvar(&protectNTFS, repo, GIT_CVAR_PROTECTNTFS); + if (protectNTFS) + flags |= GIT_PATH_REJECT_DOT_GIT_NTFS; + + return flags; +} + +bool git_path_isvalid( + git_repository *repo, + const char *path, + unsigned int flags) +{ + const char *start, *c; + + /* Upgrade the ".git" checks based on platform */ + if ((flags & GIT_PATH_REJECT_DOT_GIT)) + flags = dotgit_flags(repo, flags); + + for (start = c = path; *c; c++) { + if (!verify_char(*c, flags)) + return false; + + if (*c == '/') { + if (!verify_component(repo, start, (c - start), flags)) + return false; + + start = c+1; + } + } + + return verify_component(repo, start, (c - start), flags); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/path.h b/deps/libgit2-sys-0.2.17/libgit2/src/path.h new file mode 100644 index 000000000..440b5420c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/path.h @@ -0,0 +1,522 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_path_h__ +#define INCLUDE_path_h__ + +#include "common.h" +#include "posix.h" +#include "buffer.h" +#include "vector.h" + +/** + * Path manipulation utils + * + * These are path utilities that munge paths without actually + * looking at the real filesystem. + */ + +/* + * The dirname() function shall take a pointer to a character string + * that contains a pathname, and return a pointer to a string that is a + * pathname of the parent directory of that file. Trailing '/' characters + * in the path are not counted as part of the path. + * + * If path does not contain a '/', then dirname() shall return a pointer to + * the string ".". If path is a null pointer or points to an empty string, + * dirname() shall return a pointer to the string "." . + * + * The `git_path_dirname` implementation is thread safe. The returned + * string must be manually free'd. + * + * The `git_path_dirname_r` implementation writes the dirname to a `git_buf` + * if the buffer pointer is not NULL. + * It returns an error code < 0 if there is an allocation error, otherwise + * the length of the dirname (which will be > 0). + */ +extern char *git_path_dirname(const char *path); +extern int git_path_dirname_r(git_buf *buffer, const char *path); + +/* + * This function returns the basename of the file, which is the last + * part of its full name given by fname, with the drive letter and + * leading directories stripped off. For example, the basename of + * c:/foo/bar/file.ext is file.ext, and the basename of a:foo is foo. + * + * Trailing slashes and backslashes are significant: the basename of + * c:/foo/bar/ is an empty string after the rightmost slash. + * + * The `git_path_basename` implementation is thread safe. The returned + * string must be manually free'd. + * + * The `git_path_basename_r` implementation writes the basename to a `git_buf`. + * It returns an error code < 0 if there is an allocation error, otherwise + * the length of the basename (which will be >= 0). + */ +extern char *git_path_basename(const char *path); +extern int git_path_basename_r(git_buf *buffer, const char *path); + +/* Return the offset of the start of the basename. Unlike the other + * basename functions, this returns 0 if the path is empty. + */ +extern size_t git_path_basename_offset(git_buf *buffer); + +extern const char *git_path_topdir(const char *path); + +/** + * Find offset to root of path if path has one. + * + * This will return a number >= 0 which is the offset to the start of the + * path, if the path is rooted (i.e. "/rooted/path" returns 0 and + * "c:/windows/rooted/path" returns 2). If the path is not rooted, this + * returns < 0. + */ +extern int git_path_root(const char *path); + +/** + * Ensure path has a trailing '/'. + */ +extern int git_path_to_dir(git_buf *path); + +/** + * Ensure string has a trailing '/' if there is space for it. + */ +extern void git_path_string_to_dir(char* path, size_t size); + +/** + * Taken from git.git; returns nonzero if the given path is "." or "..". + */ +GIT_INLINE(int) git_path_is_dot_or_dotdot(const char *name) +{ + return (name[0] == '.' && + (name[1] == '\0' || + (name[1] == '.' && name[2] == '\0'))); +} + +#ifdef GIT_WIN32 +GIT_INLINE(int) git_path_is_dot_or_dotdotW(const wchar_t *name) +{ + return (name[0] == L'.' && + (name[1] == L'\0' || + (name[1] == L'.' && name[2] == L'\0'))); +} + +/** + * Convert backslashes in path to forward slashes. + */ +GIT_INLINE(void) git_path_mkposix(char *path) +{ + while (*path) { + if (*path == '\\') + *path = '/'; + + path++; + } +} +#else +# define git_path_mkposix(p) /* blank */ +#endif + +/** + * Check if string is a relative path (i.e. starts with "./" or "../") + */ +GIT_INLINE(int) git_path_is_relative(const char *p) +{ + return (p[0] == '.' && (p[1] == '/' || (p[1] == '.' && p[2] == '/'))); +} + +/** + * Check if string is at end of path segment (i.e. looking at '/' or '\0') + */ +GIT_INLINE(int) git_path_at_end_of_segment(const char *p) +{ + return !*p || *p == '/'; +} + +extern int git__percent_decode(git_buf *decoded_out, const char *input); + +/** + * Extract path from file:// URL. + */ +extern int git_path_fromurl(git_buf *local_path_out, const char *file_url); + + +/** + * Path filesystem utils + * + * These are path utilities that actually access the filesystem. + */ + +/** + * Check if a file exists and can be accessed. + * @return true or false + */ +extern bool git_path_exists(const char *path); + +/** + * Check if the given path points to a directory. + * @return true or false + */ +extern bool git_path_isdir(const char *path); + +/** + * Check if the given path points to a regular file. + * @return true or false + */ +extern bool git_path_isfile(const char *path); + +/** + * Check if the given path is a directory, and is empty. + */ +extern bool git_path_is_empty_dir(const char *path); + +/** + * Stat a file and/or link and set error if needed. + */ +extern int git_path_lstat(const char *path, struct stat *st); + +/** + * Check if the parent directory contains the item. + * + * @param dir Directory to check. + * @param item Item that might be in the directory. + * @return 0 if item exists in directory, <0 otherwise. + */ +extern bool git_path_contains(git_buf *dir, const char *item); + +/** + * Check if the given path contains the given subdirectory. + * + * @param parent Directory path that might contain subdir + * @param subdir Subdirectory name to look for in parent + * @return true if subdirectory exists, false otherwise. + */ +extern bool git_path_contains_dir(git_buf *parent, const char *subdir); + +/** + * Make the path relative to the given parent path. + * + * @param path The path to make relative + * @param parent The parent path to make path relative to + * @return 0 if path was made relative, GIT_ENOTFOUND + * if there was not common root between the paths, + * or <0. + */ +extern int git_path_make_relative(git_buf *path, const char *parent); + +/** + * Check if the given path contains the given file. + * + * @param dir Directory path that might contain file + * @param file File name to look for in parent + * @return true if file exists, false otherwise. + */ +extern bool git_path_contains_file(git_buf *dir, const char *file); + +/** + * Prepend base to unrooted path or just copy path over. + * + * This will optionally return the index into the path where the "root" + * is, either the end of the base directory prefix or the path root. + */ +extern int git_path_join_unrooted( + git_buf *path_out, const char *path, const char *base, ssize_t *root_at); + +/** + * Clean up path, prepending base if it is not already rooted. + */ +extern int git_path_prettify(git_buf *path_out, const char *path, const char *base); + +/** + * Clean up path, prepending base if it is not already rooted and + * appending a slash. + */ +extern int git_path_prettify_dir(git_buf *path_out, const char *path, const char *base); + +/** + * Get a directory from a path. + * + * If path is a directory, this acts like `git_path_prettify_dir` + * (cleaning up path and appending a '/'). If path is a normal file, + * this prettifies it, then removed the filename a la dirname and + * appends the trailing '/'. If the path does not exist, it is + * treated like a regular filename. + */ +extern int git_path_find_dir(git_buf *dir, const char *path, const char *base); + +/** + * Resolve relative references within a path. + * + * This eliminates "./" and "../" relative references inside a path, + * as well as condensing multiple slashes into single ones. It will + * not touch the path before the "ceiling" length. + * + * Additionally, this will recognize an "c:/" drive prefix or a "xyz://" URL + * prefix and not touch that part of the path. + */ +extern int git_path_resolve_relative(git_buf *path, size_t ceiling); + +/** + * Apply a relative path to base path. + * + * Note that the base path could be a filename or a URL and this + * should still work. The relative path is walked segment by segment + * with three rules: series of slashes will be condensed to a single + * slash, "." will be eaten with no change, and ".." will remove a + * segment from the base path. + */ +extern int git_path_apply_relative(git_buf *target, const char *relpath); + +enum { + GIT_PATH_DIR_IGNORE_CASE = (1u << 0), + GIT_PATH_DIR_PRECOMPOSE_UNICODE = (1u << 1), +}; + +/** + * Walk each directory entry, except '.' and '..', calling fn(state). + * + * @param pathbuf Buffer the function reads the initial directory + * path from, and updates with each successive entry's name. + * @param flags Combination of GIT_PATH_DIR flags. + * @param callback Callback for each entry. Passed the `payload` and each + * successive path inside the directory as a full path. This may + * safely append text to the pathbuf if needed. Return non-zero to + * cancel iteration (and return value will be propagated back). + * @param payload Passed to callback as first argument. + * @return 0 on success or error code from OS error or from callback + */ +extern int git_path_direach( + git_buf *pathbuf, + uint32_t flags, + int (*callback)(void *payload, git_buf *path), + void *payload); + +/** + * Sort function to order two paths + */ +extern int git_path_cmp( + const char *name1, size_t len1, int isdir1, + const char *name2, size_t len2, int isdir2, + int (*compare)(const char *, const char *, size_t)); + +/** + * Invoke callback up path directory by directory until the ceiling is + * reached (inclusive of a final call at the root_path). + * + * Returning anything other than 0 from the callback function + * will stop the iteration and propagate the error to the caller. + * + * @param pathbuf Buffer the function reads the directory from and + * and updates with each successive name. + * @param ceiling Prefix of path at which to stop walking up. If NULL, + * this will walk all the way up to the root. If not a prefix of + * pathbuf, the callback will be invoked a single time on the + * original input path. + * @param callback Function to invoke on each path. Passed the `payload` + * and the buffer containing the current path. The path should not + * be modified in any way. Return non-zero to stop iteration. + * @param state Passed to fn as the first ath. + */ +extern int git_path_walk_up( + git_buf *pathbuf, + const char *ceiling, + int (*callback)(void *payload, const char *path), + void *payload); + +/** + * Load all directory entries (except '.' and '..') into a vector. + * + * For cases where `git_path_direach()` is not appropriate, this + * allows you to load the filenames in a directory into a vector + * of strings. That vector can then be sorted, iterated, or whatever. + * Remember to free alloc of the allocated strings when you are done. + * + * @param path The directory to read from. + * @param prefix_len When inserting entries, the trailing part of path + * will be prefixed after this length. I.e. given path "/a/b" and + * prefix_len 3, the entries will look like "b/e1", "b/e2", etc. + * @param alloc_extra Extra bytes to add to each string allocation in + * case you want to append anything funny. + * @param flags Combination of GIT_PATH_DIR flags. + * @param contents Vector to fill with directory entry names. + */ +extern int git_path_dirload( + const char *path, + size_t prefix_len, + size_t alloc_extra, + uint32_t flags, + git_vector *contents); + + +typedef struct { + struct stat st; + size_t path_len; + char path[GIT_FLEX_ARRAY]; +} git_path_with_stat; + +extern int git_path_with_stat_cmp(const void *a, const void *b); +extern int git_path_with_stat_cmp_icase(const void *a, const void *b); + +/** + * Load all directory entries along with stat info into a vector. + * + * This adds four things on top of plain `git_path_dirload`: + * + * 1. Each entry in the vector is a `git_path_with_stat` struct that + * contains both the path and the stat info + * 2. The entries will be sorted alphabetically + * 3. Entries that are directories will be suffixed with a '/' + * 4. Optionally, you can be a start and end prefix and only elements + * after the start and before the end (inclusively) will be stat'ed. + * + * @param path The directory to read from + * @param prefix_len The trailing part of path to prefix to entry paths + * @param flags GIT_PATH_DIR flags from above + * @param start_stat As optimization, only stat values after this prefix + * @param end_stat As optimization, only stat values before this prefix + * @param contents Vector to fill with git_path_with_stat structures + */ +extern int git_path_dirload_with_stat( + const char *path, + size_t prefix_len, + uint32_t flags, + const char *start_stat, + const char *end_stat, + git_vector *contents); + +enum { GIT_PATH_NOTEQUAL = 0, GIT_PATH_EQUAL = 1, GIT_PATH_PREFIX = 2 }; + +/* + * Determines if a path is equal to or potentially a child of another. + * @param parent The possible parent + * @param child The possible child + */ +GIT_INLINE(int) git_path_equal_or_prefixed( + const char *parent, + const char *child, + ssize_t *prefixlen) +{ + const char *p = parent, *c = child; + int lastslash = 0; + + while (*p && *c) { + lastslash = (*p == '/'); + + if (*p++ != *c++) + return GIT_PATH_NOTEQUAL; + } + + if (*p != '\0') + return GIT_PATH_NOTEQUAL; + + if (*c == '\0') { + if (prefixlen) + *prefixlen = p - parent; + + return GIT_PATH_EQUAL; + } + + if (*c == '/' || lastslash) { + if (prefixlen) + *prefixlen = (p - parent) - lastslash; + + return GIT_PATH_PREFIX; + } + + return GIT_PATH_NOTEQUAL; +} + +/* translate errno to libgit2 error code and set error message */ +extern int git_path_set_error( + int errno_value, const char *path, const char *action); + +/* check if non-ascii characters are present in filename */ +extern bool git_path_has_non_ascii(const char *path, size_t pathlen); + +#define GIT_PATH_REPO_ENCODING "UTF-8" + +#ifdef __APPLE__ +#define GIT_PATH_NATIVE_ENCODING "UTF-8-MAC" +#else +#define GIT_PATH_NATIVE_ENCODING "UTF-8" +#endif + +#ifdef GIT_USE_ICONV + +#include + +typedef struct { + iconv_t map; + git_buf buf; +} git_path_iconv_t; + +#define GIT_PATH_ICONV_INIT { (iconv_t)-1, GIT_BUF_INIT } + +/* Init iconv data for converting decomposed UTF-8 to precomposed */ +extern int git_path_iconv_init_precompose(git_path_iconv_t *ic); + +/* Clear allocated iconv data */ +extern void git_path_iconv_clear(git_path_iconv_t *ic); + +/* + * Rewrite `in` buffer using iconv map if necessary, replacing `in` + * pointer internal iconv buffer if rewrite happened. The `in` pointer + * will be left unchanged if no rewrite was needed. + */ +extern int git_path_iconv(git_path_iconv_t *ic, char **in, size_t *inlen); + +#endif /* GIT_USE_ICONV */ + +extern bool git_path_does_fs_decompose_unicode(const char *root); + +/* Used for paths to repositories on the filesystem */ +extern bool git_path_is_local_file_url(const char *file_url); +extern int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path); + +/* Flags to determine path validity in `git_path_isvalid` */ +#define GIT_PATH_REJECT_TRAVERSAL (1 << 0) +#define GIT_PATH_REJECT_DOT_GIT (1 << 1) +#define GIT_PATH_REJECT_SLASH (1 << 2) +#define GIT_PATH_REJECT_BACKSLASH (1 << 3) +#define GIT_PATH_REJECT_TRAILING_DOT (1 << 4) +#define GIT_PATH_REJECT_TRAILING_SPACE (1 << 5) +#define GIT_PATH_REJECT_TRAILING_COLON (1 << 6) +#define GIT_PATH_REJECT_DOS_PATHS (1 << 7) +#define GIT_PATH_REJECT_NT_CHARS (1 << 8) +#define GIT_PATH_REJECT_DOT_GIT_HFS (1 << 9) +#define GIT_PATH_REJECT_DOT_GIT_NTFS (1 << 10) + +/* Default path safety for writing files to disk: since we use the + * Win32 "File Namespace" APIs ("\\?\") we need to protect from + * paths that the normal Win32 APIs would not write. + */ +#ifdef GIT_WIN32 +# define GIT_PATH_REJECT_DEFAULTS \ + GIT_PATH_REJECT_TRAVERSAL | \ + GIT_PATH_REJECT_BACKSLASH | \ + GIT_PATH_REJECT_TRAILING_DOT | \ + GIT_PATH_REJECT_TRAILING_SPACE | \ + GIT_PATH_REJECT_TRAILING_COLON | \ + GIT_PATH_REJECT_DOS_PATHS | \ + GIT_PATH_REJECT_NT_CHARS +#else +# define GIT_PATH_REJECT_DEFAULTS GIT_PATH_REJECT_TRAVERSAL +#endif + +/* + * Determine whether a path is a valid git path or not - this must not contain + * a '.' or '..' component, or a component that is ".git" (in any case). + * + * `repo` is optional. If specified, it will be used to determine the short + * path name to reject (if `GIT_PATH_REJECT_DOS_SHORTNAME` is specified), + * in addition to the default of "git~1". + */ +extern bool git_path_isvalid( + git_repository *repo, + const char *path, + unsigned int flags); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pathspec.c b/deps/libgit2-sys-0.2.17/libgit2/src/pathspec.c new file mode 100644 index 000000000..fab6f9a76 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pathspec.c @@ -0,0 +1,725 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/pathspec.h" +#include "git2/diff.h" +#include "pathspec.h" +#include "buf_text.h" +#include "attr_file.h" +#include "iterator.h" +#include "repository.h" +#include "index.h" +#include "bitvec.h" +#include "diff.h" + +/* what is the common non-wildcard prefix for all items in the pathspec */ +char *git_pathspec_prefix(const git_strarray *pathspec) +{ + git_buf prefix = GIT_BUF_INIT; + const char *scan; + + if (!pathspec || !pathspec->count || + git_buf_text_common_prefix(&prefix, pathspec) < 0) + return NULL; + + /* diff prefix will only be leading non-wildcards */ + for (scan = prefix.ptr; *scan; ++scan) { + if (git__iswildcard(*scan) && + (scan == prefix.ptr || (*(scan - 1) != '\\'))) + break; + } + git_buf_truncate(&prefix, scan - prefix.ptr); + + if (prefix.size <= 0) { + git_buf_free(&prefix); + return NULL; + } + + git_buf_text_unescape(&prefix); + + return git_buf_detach(&prefix); +} + +/* is there anything in the spec that needs to be filtered on */ +bool git_pathspec_is_empty(const git_strarray *pathspec) +{ + size_t i; + + if (pathspec == NULL) + return true; + + for (i = 0; i < pathspec->count; ++i) { + const char *str = pathspec->strings[i]; + + if (str && str[0]) + return false; + } + + return true; +} + +/* build a vector of fnmatch patterns to evaluate efficiently */ +int git_pathspec__vinit( + git_vector *vspec, const git_strarray *strspec, git_pool *strpool) +{ + size_t i; + + memset(vspec, 0, sizeof(*vspec)); + + if (git_pathspec_is_empty(strspec)) + return 0; + + if (git_vector_init(vspec, strspec->count, NULL) < 0) + return -1; + + for (i = 0; i < strspec->count; ++i) { + int ret; + const char *pattern = strspec->strings[i]; + git_attr_fnmatch *match = git__calloc(1, sizeof(git_attr_fnmatch)); + if (!match) + return -1; + + match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE | + GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_NOLEADINGDIR; + + ret = git_attr_fnmatch__parse(match, strpool, NULL, &pattern); + if (ret == GIT_ENOTFOUND) { + git__free(match); + continue; + } else if (ret < 0) { + git__free(match); + return ret; + } + + if (git_vector_insert(vspec, match) < 0) + return -1; + } + + return 0; +} + +/* free data from the pathspec vector */ +void git_pathspec__vfree(git_vector *vspec) +{ + git_vector_free_deep(vspec); +} + +struct pathspec_match_context { + int fnmatch_flags; + int (*strcomp)(const char *, const char *); + int (*strncomp)(const char *, const char *, size_t); +}; + +static void pathspec_match_context_init( + struct pathspec_match_context *ctxt, + bool disable_fnmatch, + bool casefold) +{ + if (disable_fnmatch) + ctxt->fnmatch_flags = -1; + else if (casefold) + ctxt->fnmatch_flags = FNM_CASEFOLD; + else + ctxt->fnmatch_flags = 0; + + if (casefold) { + ctxt->strcomp = git__strcasecmp; + ctxt->strncomp = git__strncasecmp; + } else { + ctxt->strcomp = git__strcmp; + ctxt->strncomp = git__strncmp; + } +} + +static int pathspec_match_one( + const git_attr_fnmatch *match, + struct pathspec_match_context *ctxt, + const char *path) +{ + int result = (match->flags & GIT_ATTR_FNMATCH_MATCH_ALL) ? 0 : FNM_NOMATCH; + + if (result == FNM_NOMATCH) + result = ctxt->strcomp(match->pattern, path) ? FNM_NOMATCH : 0; + + if (ctxt->fnmatch_flags >= 0 && result == FNM_NOMATCH) + result = p_fnmatch(match->pattern, path, ctxt->fnmatch_flags); + + /* if we didn't match, look for exact dirname prefix match */ + if (result == FNM_NOMATCH && + (match->flags & GIT_ATTR_FNMATCH_HASWILD) == 0 && + ctxt->strncomp(path, match->pattern, match->length) == 0 && + path[match->length] == '/') + result = 0; + + /* if we didn't match and this is a negative match, check for exact + * match of filename with leading '!' + */ + if (result == FNM_NOMATCH && + (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 && + *path == '!' && + ctxt->strncomp(path + 1, match->pattern, match->length) == 0 && + (!path[match->length + 1] || path[match->length + 1] == '/')) + return 1; + + if (result == 0) + return (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) ? 0 : 1; + return -1; +} + +static int git_pathspec__match_at( + size_t *matched_at, + const git_vector *vspec, + struct pathspec_match_context *ctxt, + const char *path0, + const char *path1) +{ + int result = GIT_ENOTFOUND; + size_t i = 0; + const git_attr_fnmatch *match; + + git_vector_foreach(vspec, i, match) { + if (path0 && (result = pathspec_match_one(match, ctxt, path0)) >= 0) + break; + if (path1 && (result = pathspec_match_one(match, ctxt, path1)) >= 0) + break; + } + + *matched_at = i; + return result; +} + +/* match a path against the vectorized pathspec */ +bool git_pathspec__match( + const git_vector *vspec, + const char *path, + bool disable_fnmatch, + bool casefold, + const char **matched_pathspec, + size_t *matched_at) +{ + int result; + size_t pos; + struct pathspec_match_context ctxt; + + if (matched_pathspec) + *matched_pathspec = NULL; + if (matched_at) + *matched_at = GIT_PATHSPEC_NOMATCH; + + if (!vspec || !vspec->length) + return true; + + pathspec_match_context_init(&ctxt, disable_fnmatch, casefold); + + result = git_pathspec__match_at(&pos, vspec, &ctxt, path, NULL); + if (result >= 0) { + if (matched_pathspec) { + const git_attr_fnmatch *match = git_vector_get(vspec, pos); + *matched_pathspec = match->pattern; + } + + if (matched_at) + *matched_at = pos; + } + + return (result > 0); +} + + +int git_pathspec__init(git_pathspec *ps, const git_strarray *paths) +{ + int error = 0; + + memset(ps, 0, sizeof(*ps)); + + ps->prefix = git_pathspec_prefix(paths); + + if ((error = git_pool_init(&ps->pool, 1, 0)) < 0 || + (error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 0) + git_pathspec__clear(ps); + + return error; +} + +void git_pathspec__clear(git_pathspec *ps) +{ + git__free(ps->prefix); + git_pathspec__vfree(&ps->pathspec); + git_pool_clear(&ps->pool); + memset(ps, 0, sizeof(*ps)); +} + +int git_pathspec_new(git_pathspec **out, const git_strarray *pathspec) +{ + int error = 0; + git_pathspec *ps = git__malloc(sizeof(git_pathspec)); + GITERR_CHECK_ALLOC(ps); + + if ((error = git_pathspec__init(ps, pathspec)) < 0) { + git__free(ps); + return error; + } + + GIT_REFCOUNT_INC(ps); + *out = ps; + return 0; +} + +static void pathspec_free(git_pathspec *ps) +{ + git_pathspec__clear(ps); + git__free(ps); +} + +void git_pathspec_free(git_pathspec *ps) +{ + if (!ps) + return; + GIT_REFCOUNT_DEC(ps, pathspec_free); +} + +int git_pathspec_matches_path( + const git_pathspec *ps, uint32_t flags, const char *path) +{ + bool no_fnmatch = (flags & GIT_PATHSPEC_NO_GLOB) != 0; + bool casefold = (flags & GIT_PATHSPEC_IGNORE_CASE) != 0; + + assert(ps && path); + + return (0 != git_pathspec__match( + &ps->pathspec, path, no_fnmatch, casefold, NULL, NULL)); +} + +static void pathspec_match_free(git_pathspec_match_list *m) +{ + if (!m) + return; + + git_pathspec_free(m->pathspec); + m->pathspec = NULL; + + git_array_clear(m->matches); + git_array_clear(m->failures); + git_pool_clear(&m->pool); + git__free(m); +} + +static git_pathspec_match_list *pathspec_match_alloc( + git_pathspec *ps, int datatype) +{ + git_pathspec_match_list *m = git__calloc(1, sizeof(git_pathspec_match_list)); + + if (m != NULL && git_pool_init(&m->pool, 1, 0) < 0) { + pathspec_match_free(m); + m = NULL; + } + + if (!m) + return NULL; + + /* need to keep reference to pathspec and increment refcount because + * failures array stores pointers to the pattern strings of the + * pathspec that had no matches + */ + GIT_REFCOUNT_INC(ps); + m->pathspec = ps; + m->datatype = datatype; + + return m; +} + +GIT_INLINE(size_t) pathspec_mark_pattern(git_bitvec *used, size_t pos) +{ + if (!git_bitvec_get(used, pos)) { + git_bitvec_set(used, pos, true); + return 1; + } + + return 0; +} + +static size_t pathspec_mark_remaining( + git_bitvec *used, + git_vector *patterns, + struct pathspec_match_context *ctxt, + size_t start, + const char *path0, + const char *path1) +{ + size_t count = 0; + + if (path1 == path0) + path1 = NULL; + + for (; start < patterns->length; ++start) { + const git_attr_fnmatch *pat = git_vector_get(patterns, start); + + if (git_bitvec_get(used, start)) + continue; + + if (path0 && pathspec_match_one(pat, ctxt, path0) > 0) + count += pathspec_mark_pattern(used, start); + else if (path1 && pathspec_match_one(pat, ctxt, path1) > 0) + count += pathspec_mark_pattern(used, start); + } + + return count; +} + +static int pathspec_build_failure_array( + git_pathspec_string_array_t *failures, + git_vector *patterns, + git_bitvec *used, + git_pool *pool) +{ + size_t pos; + char **failed; + const git_attr_fnmatch *pat; + + for (pos = 0; pos < patterns->length; ++pos) { + if (git_bitvec_get(used, pos)) + continue; + + if ((failed = git_array_alloc(*failures)) == NULL) + return -1; + + pat = git_vector_get(patterns, pos); + + if ((*failed = git_pool_strdup(pool, pat->pattern)) == NULL) + return -1; + } + + return 0; +} + +static int pathspec_match_from_iterator( + git_pathspec_match_list **out, + git_iterator *iter, + uint32_t flags, + git_pathspec *ps) +{ + int error = 0; + git_pathspec_match_list *m = NULL; + const git_index_entry *entry = NULL; + struct pathspec_match_context ctxt; + git_vector *patterns = &ps->pathspec; + bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0; + bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0; + size_t pos, used_ct = 0, found_files = 0; + git_index *index = NULL; + git_bitvec used_patterns; + char **file; + + if (git_bitvec_init(&used_patterns, patterns->length) < 0) + return -1; + + if (out) { + *out = m = pathspec_match_alloc(ps, PATHSPEC_DATATYPE_STRINGS); + GITERR_CHECK_ALLOC(m); + } + + if ((error = git_iterator_reset(iter, ps->prefix, ps->prefix)) < 0) + goto done; + + if (git_iterator_type(iter) == GIT_ITERATOR_TYPE_WORKDIR && + (error = git_repository_index__weakptr( + &index, git_iterator_owner(iter))) < 0) + goto done; + + pathspec_match_context_init( + &ctxt, (flags & GIT_PATHSPEC_NO_GLOB) != 0, + git_iterator_ignore_case(iter)); + + while (!(error = git_iterator_advance(&entry, iter))) { + /* search for match with entry->path */ + int result = git_pathspec__match_at( + &pos, patterns, &ctxt, entry->path, NULL); + + /* no matches for this path */ + if (result < 0) + continue; + + /* if result was a negative pattern match, then don't list file */ + if (!result) { + used_ct += pathspec_mark_pattern(&used_patterns, pos); + continue; + } + + /* check if path is ignored and untracked */ + if (index != NULL && + git_iterator_current_is_ignored(iter) && + git_index__find_pos(NULL, index, entry->path, 0, GIT_INDEX_STAGE_ANY) < 0) + continue; + + /* mark the matched pattern as used */ + used_ct += pathspec_mark_pattern(&used_patterns, pos); + ++found_files; + + /* if find_failures is on, check if any later patterns also match */ + if (find_failures && used_ct < patterns->length) + used_ct += pathspec_mark_remaining( + &used_patterns, patterns, &ctxt, pos + 1, entry->path, NULL); + + /* if only looking at failures, exit early or just continue */ + if (failures_only || !out) { + if (used_ct == patterns->length) + break; + continue; + } + + /* insert matched path into matches array */ + if ((file = (char **)git_array_alloc(m->matches)) == NULL || + (*file = git_pool_strdup(&m->pool, entry->path)) == NULL) { + error = -1; + goto done; + } + } + + if (error < 0 && error != GIT_ITEROVER) + goto done; + error = 0; + + /* insert patterns that had no matches into failures array */ + if (find_failures && used_ct < patterns->length && + (error = pathspec_build_failure_array( + &m->failures, patterns, &used_patterns, &m->pool)) < 0) + goto done; + + /* if every pattern failed to match, then we have failed */ + if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_files) { + giterr_set(GITERR_INVALID, "No matching files were found"); + error = GIT_ENOTFOUND; + } + +done: + git_bitvec_free(&used_patterns); + + if (error < 0) { + pathspec_match_free(m); + if (out) *out = NULL; + } + + return error; +} + +static git_iterator_flag_t pathspec_match_iter_flags(uint32_t flags) +{ + git_iterator_flag_t f = 0; + + if ((flags & GIT_PATHSPEC_IGNORE_CASE) != 0) + f |= GIT_ITERATOR_IGNORE_CASE; + else if ((flags & GIT_PATHSPEC_USE_CASE) != 0) + f |= GIT_ITERATOR_DONT_IGNORE_CASE; + + return f; +} + +int git_pathspec_match_workdir( + git_pathspec_match_list **out, + git_repository *repo, + uint32_t flags, + git_pathspec *ps) +{ + int error = 0; + git_iterator *iter; + + assert(repo); + + if (!(error = git_iterator_for_workdir( + &iter, repo, NULL, NULL, pathspec_match_iter_flags(flags), NULL, NULL))) { + + error = pathspec_match_from_iterator(out, iter, flags, ps); + + git_iterator_free(iter); + } + + return error; +} + +int git_pathspec_match_index( + git_pathspec_match_list **out, + git_index *index, + uint32_t flags, + git_pathspec *ps) +{ + int error = 0; + git_iterator *iter; + + assert(index); + + if (!(error = git_iterator_for_index( + &iter, index, pathspec_match_iter_flags(flags), NULL, NULL))) { + + error = pathspec_match_from_iterator(out, iter, flags, ps); + + git_iterator_free(iter); + } + + return error; +} + +int git_pathspec_match_tree( + git_pathspec_match_list **out, + git_tree *tree, + uint32_t flags, + git_pathspec *ps) +{ + int error = 0; + git_iterator *iter; + + assert(tree); + + if (!(error = git_iterator_for_tree( + &iter, tree, pathspec_match_iter_flags(flags), NULL, NULL))) { + + error = pathspec_match_from_iterator(out, iter, flags, ps); + + git_iterator_free(iter); + } + + return error; +} + +int git_pathspec_match_diff( + git_pathspec_match_list **out, + git_diff *diff, + uint32_t flags, + git_pathspec *ps) +{ + int error = 0; + git_pathspec_match_list *m = NULL; + struct pathspec_match_context ctxt; + git_vector *patterns = &ps->pathspec; + bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0; + bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0; + size_t i, pos, used_ct = 0, found_deltas = 0; + const git_diff_delta *delta, **match; + git_bitvec used_patterns; + + assert(diff); + + if (git_bitvec_init(&used_patterns, patterns->length) < 0) + return -1; + + if (out) { + *out = m = pathspec_match_alloc(ps, PATHSPEC_DATATYPE_DIFF); + GITERR_CHECK_ALLOC(m); + } + + pathspec_match_context_init( + &ctxt, (flags & GIT_PATHSPEC_NO_GLOB) != 0, + git_diff_is_sorted_icase(diff)); + + git_vector_foreach(&diff->deltas, i, delta) { + /* search for match with delta */ + int result = git_pathspec__match_at( + &pos, patterns, &ctxt, delta->old_file.path, delta->new_file.path); + + /* no matches for this path */ + if (result < 0) + continue; + + /* mark the matched pattern as used */ + used_ct += pathspec_mark_pattern(&used_patterns, pos); + + /* if result was a negative pattern match, then don't list file */ + if (!result) + continue; + + ++found_deltas; + + /* if find_failures is on, check if any later patterns also match */ + if (find_failures && used_ct < patterns->length) + used_ct += pathspec_mark_remaining( + &used_patterns, patterns, &ctxt, pos + 1, + delta->old_file.path, delta->new_file.path); + + /* if only looking at failures, exit early or just continue */ + if (failures_only || !out) { + if (used_ct == patterns->length) + break; + continue; + } + + /* insert matched delta into matches array */ + if (!(match = (const git_diff_delta **)git_array_alloc(m->matches))) { + error = -1; + goto done; + } else { + *match = delta; + } + } + + /* insert patterns that had no matches into failures array */ + if (find_failures && used_ct < patterns->length && + (error = pathspec_build_failure_array( + &m->failures, patterns, &used_patterns, &m->pool)) < 0) + goto done; + + /* if every pattern failed to match, then we have failed */ + if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_deltas) { + giterr_set(GITERR_INVALID, "No matching deltas were found"); + error = GIT_ENOTFOUND; + } + +done: + git_bitvec_free(&used_patterns); + + if (error < 0) { + pathspec_match_free(m); + if (out) *out = NULL; + } + + return error; +} + +void git_pathspec_match_list_free(git_pathspec_match_list *m) +{ + if (m) + pathspec_match_free(m); +} + +size_t git_pathspec_match_list_entrycount( + const git_pathspec_match_list *m) +{ + return m ? git_array_size(m->matches) : 0; +} + +const char *git_pathspec_match_list_entry( + const git_pathspec_match_list *m, size_t pos) +{ + if (!m || m->datatype != PATHSPEC_DATATYPE_STRINGS || + !git_array_valid_index(m->matches, pos)) + return NULL; + + return *((const char **)git_array_get(m->matches, pos)); +} + +const git_diff_delta *git_pathspec_match_list_diff_entry( + const git_pathspec_match_list *m, size_t pos) +{ + if (!m || m->datatype != PATHSPEC_DATATYPE_DIFF || + !git_array_valid_index(m->matches, pos)) + return NULL; + + return *((const git_diff_delta **)git_array_get(m->matches, pos)); +} + +size_t git_pathspec_match_list_failed_entrycount( + const git_pathspec_match_list *m) +{ + return m ? git_array_size(m->failures) : 0; +} + +const char * git_pathspec_match_list_failed_entry( + const git_pathspec_match_list *m, size_t pos) +{ + char **entry = m ? git_array_get(m->failures, pos) : NULL; + + return entry ? *entry : NULL; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pathspec.h b/deps/libgit2-sys-0.2.17/libgit2/src/pathspec.h new file mode 100644 index 000000000..40cd21c3f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pathspec.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_pathspec_h__ +#define INCLUDE_pathspec_h__ + +#include "common.h" +#include +#include "buffer.h" +#include "vector.h" +#include "pool.h" +#include "array.h" + +/* public compiled pathspec */ +struct git_pathspec { + git_refcount rc; + char *prefix; + git_vector pathspec; + git_pool pool; +}; + +enum { + PATHSPEC_DATATYPE_STRINGS = 0, + PATHSPEC_DATATYPE_DIFF = 1, +}; + +typedef git_array_t(char *) git_pathspec_string_array_t; + +/* public interface to pathspec matching */ +struct git_pathspec_match_list { + git_pathspec *pathspec; + git_array_t(void *) matches; + git_pathspec_string_array_t failures; + git_pool pool; + int datatype; +}; + +/* what is the common non-wildcard prefix for all items in the pathspec */ +extern char *git_pathspec_prefix(const git_strarray *pathspec); + +/* is there anything in the spec that needs to be filtered on */ +extern bool git_pathspec_is_empty(const git_strarray *pathspec); + +/* build a vector of fnmatch patterns to evaluate efficiently */ +extern int git_pathspec__vinit( + git_vector *vspec, const git_strarray *strspec, git_pool *strpool); + +/* free data from the pathspec vector */ +extern void git_pathspec__vfree(git_vector *vspec); + +#define GIT_PATHSPEC_NOMATCH ((size_t)-1) + +/* + * Match a path against the vectorized pathspec. + * The matched pathspec is passed back into the `matched_pathspec` parameter, + * unless it is passed as NULL by the caller. + */ +extern bool git_pathspec__match( + const git_vector *vspec, + const char *path, + bool disable_fnmatch, + bool casefold, + const char **matched_pathspec, + size_t *matched_at); + +/* easy pathspec setup */ + +extern int git_pathspec__init(git_pathspec *ps, const git_strarray *paths); + +extern void git_pathspec__clear(git_pathspec *ps); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pool.c b/deps/libgit2-sys-0.2.17/libgit2/src/pool.c new file mode 100644 index 000000000..c93d78182 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pool.c @@ -0,0 +1,325 @@ +#include "pool.h" +#include "posix.h" +#ifndef GIT_WIN32 +#include +#endif + +struct git_pool_page { + git_pool_page *next; + uint32_t size; + uint32_t avail; + GIT_ALIGN(char data[GIT_FLEX_ARRAY], 8); +}; + +struct pool_freelist { + struct pool_freelist *next; +}; + +#define GIT_POOL_MIN_USABLE 4 +#define GIT_POOL_MIN_PAGESZ 2 * sizeof(void*) + +static void *pool_alloc_page(git_pool *pool, uint32_t size); +static void pool_insert_page(git_pool *pool, git_pool_page *page); + +int git_pool_init( + git_pool *pool, uint32_t item_size, uint32_t items_per_page) +{ + assert(pool); + + if (!item_size) + item_size = 1; + /* round up item_size for decent object alignment */ + if (item_size > 4) + item_size = (item_size + 7) & ~7; + else if (item_size == 3) + item_size = 4; + + if (!items_per_page) + items_per_page = git_pool__suggest_items_per_page(item_size); + if (item_size * items_per_page < GIT_POOL_MIN_PAGESZ) + items_per_page = (GIT_POOL_MIN_PAGESZ + item_size - 1) / item_size; + + memset(pool, 0, sizeof(git_pool)); + pool->item_size = item_size; + pool->page_size = item_size * items_per_page; + + return 0; +} + +void git_pool_clear(git_pool *pool) +{ + git_pool_page *scan, *next; + + for (scan = pool->open; scan != NULL; scan = next) { + next = scan->next; + git__free(scan); + } + pool->open = NULL; + + for (scan = pool->full; scan != NULL; scan = next) { + next = scan->next; + git__free(scan); + } + pool->full = NULL; + + pool->free_list = NULL; + + pool->items = 0; + + pool->has_string_alloc = 0; + pool->has_multi_item_alloc = 0; + pool->has_large_page_alloc = 0; +} + +void git_pool_swap(git_pool *a, git_pool *b) +{ + git_pool temp; + + if (a == b) + return; + + memcpy(&temp, a, sizeof(temp)); + memcpy(a, b, sizeof(temp)); + memcpy(b, &temp, sizeof(temp)); +} + +static void pool_insert_page(git_pool *pool, git_pool_page *page) +{ + git_pool_page *scan; + + /* If there are no open pages or this page has the most open space, + * insert it at the beginning of the list. This is the common case. + */ + if (pool->open == NULL || pool->open->avail < page->avail) { + page->next = pool->open; + pool->open = page; + return; + } + + /* Otherwise insert into sorted position. */ + for (scan = pool->open; + scan->next && scan->next->avail > page->avail; + scan = scan->next); + page->next = scan->next; + scan->next = page; +} + +static void *pool_alloc_page(git_pool *pool, uint32_t size) +{ + git_pool_page *page; + uint32_t new_page_size; + size_t alloc_size; + + if (size <= pool->page_size) + new_page_size = pool->page_size; + else { + new_page_size = size; + pool->has_large_page_alloc = 1; + } + + if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, new_page_size, sizeof(git_pool_page)) || + !(page = git__calloc(1, alloc_size))) + return NULL; + + page->size = new_page_size; + page->avail = new_page_size - size; + + if (page->avail > 0) + pool_insert_page(pool, page); + else { + page->next = pool->full; + pool->full = page; + } + + pool->items++; + + return page->data; +} + +GIT_INLINE(void) pool_remove_page( + git_pool *pool, git_pool_page *page, git_pool_page *prev) +{ + if (prev == NULL) + pool->open = page->next; + else + prev->next = page->next; +} + +void *git_pool_malloc(git_pool *pool, uint32_t items) +{ + git_pool_page *scan = pool->open, *prev; + uint32_t size = ((items * pool->item_size) + 7) & ~7; + void *ptr = NULL; + + pool->has_string_alloc = 0; + if (items > 1) + pool->has_multi_item_alloc = 1; + else if (pool->free_list != NULL) { + ptr = pool->free_list; + pool->free_list = ((struct pool_freelist *)pool->free_list)->next; + return ptr; + } + + /* just add a block if there is no open one to accommodate this */ + if (size >= pool->page_size || !scan || scan->avail < size) + return pool_alloc_page(pool, size); + + pool->items++; + + /* find smallest block in free list with space */ + for (scan = pool->open, prev = NULL; + scan->next && scan->next->avail >= size; + prev = scan, scan = scan->next); + + /* allocate space from the block */ + ptr = &scan->data[scan->size - scan->avail]; + scan->avail -= size; + + /* move to full list if there is almost no space left */ + if (scan->avail < pool->item_size || scan->avail < GIT_POOL_MIN_USABLE) { + pool_remove_page(pool, scan, prev); + scan->next = pool->full; + pool->full = scan; + } + /* reorder list if block is now smaller than the one after it */ + else if (scan->next != NULL && scan->next->avail > scan->avail) { + pool_remove_page(pool, scan, prev); + pool_insert_page(pool, scan); + } + + return ptr; +} + +char *git_pool_strndup(git_pool *pool, const char *str, size_t n) +{ + char *ptr = NULL; + + assert(pool && str && pool->item_size == sizeof(char)); + + if ((uint32_t)(n + 1) < n) + return NULL; + + if ((ptr = git_pool_malloc(pool, (uint32_t)(n + 1))) != NULL) { + memcpy(ptr, str, n); + ptr[n] = '\0'; + } + + pool->has_string_alloc = 1; + + return ptr; +} + +char *git_pool_strdup(git_pool *pool, const char *str) +{ + assert(pool && str && pool->item_size == sizeof(char)); + + return git_pool_strndup(pool, str, strlen(str)); +} + +char *git_pool_strdup_safe(git_pool *pool, const char *str) +{ + return str ? git_pool_strdup(pool, str) : NULL; +} + +char *git_pool_strcat(git_pool *pool, const char *a, const char *b) +{ + void *ptr; + size_t len_a, len_b; + + assert(pool && pool->item_size == sizeof(char)); + + len_a = a ? strlen(a) : 0; + len_b = b ? strlen(b) : 0; + + if ((ptr = git_pool_malloc(pool, (uint32_t)(len_a + len_b + 1))) != NULL) { + if (len_a) + memcpy(ptr, a, len_a); + if (len_b) + memcpy(((char *)ptr) + len_a, b, len_b); + *(((char *)ptr) + len_a + len_b) = '\0'; + } + pool->has_string_alloc = 1; + + return ptr; +} + +void git_pool_free(git_pool *pool, void *ptr) +{ + struct pool_freelist *item = ptr; + + assert(pool && pool->item_size >= sizeof(void*)); + + if (item) { + item->next = pool->free_list; + pool->free_list = item; + } +} + +void git_pool_free_array(git_pool *pool, size_t count, void **ptrs) +{ + struct pool_freelist **items = (struct pool_freelist **)ptrs; + size_t i; + + assert(pool && ptrs && pool->item_size >= sizeof(void*)); + + if (!count) + return; + + for (i = count - 1; i > 0; --i) + items[i]->next = items[i - 1]; + + items[i]->next = pool->free_list; + pool->free_list = items[count - 1]; +} + +uint32_t git_pool__open_pages(git_pool *pool) +{ + uint32_t ct = 0; + git_pool_page *scan; + for (scan = pool->open; scan != NULL; scan = scan->next) ct++; + return ct; +} + +uint32_t git_pool__full_pages(git_pool *pool) +{ + uint32_t ct = 0; + git_pool_page *scan; + for (scan = pool->full; scan != NULL; scan = scan->next) ct++; + return ct; +} + +bool git_pool__ptr_in_pool(git_pool *pool, void *ptr) +{ + git_pool_page *scan; + for (scan = pool->open; scan != NULL; scan = scan->next) + if ((void *)scan->data <= ptr && + (void *)(((char *)scan->data) + scan->size) > ptr) + return true; + for (scan = pool->full; scan != NULL; scan = scan->next) + if ((void *)scan->data <= ptr && + (void *)(((char *)scan->data) + scan->size) > ptr) + return true; + return false; +} + +uint32_t git_pool__system_page_size(void) +{ + static uint32_t size = 0; + + if (!size) { + size_t page_size; + if (git__page_size(&page_size) < 0) + page_size = 4096; + size = page_size - 2 * sizeof(void *); /* allow space for malloc overhead */ + } + + return size; +} + +uint32_t git_pool__suggest_items_per_page(uint32_t item_size) +{ + uint32_t page_bytes = + git_pool__system_page_size() - sizeof(git_pool_page); + return page_bytes / item_size; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pool.h b/deps/libgit2-sys-0.2.17/libgit2/src/pool.h new file mode 100644 index 000000000..b0007f315 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pool.h @@ -0,0 +1,148 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_pool_h__ +#define INCLUDE_pool_h__ + +#include "common.h" + +typedef struct git_pool_page git_pool_page; + +/** + * Chunked allocator. + * + * A `git_pool` can be used when you want to cheaply allocate + * multiple items of the same type and are willing to free them + * all together with a single call. The two most common cases + * are a set of fixed size items (such as lots of OIDs) or a + * bunch of strings. + * + * Internally, a `git_pool` allocates pages of memory and then + * deals out blocks from the trailing unused portion of each page. + * The pages guarantee that the number of actual allocations done + * will be much smaller than the number of items needed. + * + * For examples of how to set up a `git_pool` see `git_pool_init`. + */ +typedef struct { + git_pool_page *open; /* pages with space left */ + git_pool_page *full; /* pages with no space left */ + void *free_list; /* optional: list of freed blocks */ + uint32_t item_size; /* size of single alloc unit in bytes */ + uint32_t page_size; /* size of page in bytes */ + uint32_t items; + unsigned has_string_alloc : 1; /* was the strdup function used */ + unsigned has_multi_item_alloc : 1; /* was items ever > 1 in malloc */ + unsigned has_large_page_alloc : 1; /* are any pages > page_size */ +} git_pool; + +#define GIT_POOL_INIT_STRINGPOOL { 0, 0, 0, 1, 4000, 0, 0, 0, 0 } + +/** + * Initialize a pool. + * + * To allocation strings, use like this: + * + * git_pool_init(&string_pool, 1, 0); + * my_string = git_pool_strdup(&string_pool, your_string); + * + * To allocate items of fixed size, use like this: + * + * git_pool_init(&pool, sizeof(item), 0); + * my_item = git_pool_malloc(&pool, 1); + * + * Of course, you can use this in other ways, but those are the + * two most common patterns. + */ +extern int git_pool_init( + git_pool *pool, uint32_t item_size, uint32_t items_per_page); + +/** + * Free all items in pool + */ +extern void git_pool_clear(git_pool *pool); + +/** + * Swap two pools with one another + */ +extern void git_pool_swap(git_pool *a, git_pool *b); + +/** + * Allocate space for one or more items from a pool. + */ +extern void *git_pool_malloc(git_pool *pool, uint32_t items); + +/** + * Allocate space and zero it out. + */ +GIT_INLINE(void *) git_pool_mallocz(git_pool *pool, uint32_t items) +{ + void *ptr = git_pool_malloc(pool, items); + if (ptr) + memset(ptr, 0, (size_t)items * (size_t)pool->item_size); + return ptr; +} + +/** + * Allocate space and duplicate string data into it. + * + * This is allowed only for pools with item_size == sizeof(char) + */ +extern char *git_pool_strndup(git_pool *pool, const char *str, size_t n); + +/** + * Allocate space and duplicate a string into it. + * + * This is allowed only for pools with item_size == sizeof(char) + */ +extern char *git_pool_strdup(git_pool *pool, const char *str); + +/** + * Allocate space and duplicate a string into it, NULL is no error. + * + * This is allowed only for pools with item_size == sizeof(char) + */ +extern char *git_pool_strdup_safe(git_pool *pool, const char *str); + +/** + * Allocate space for the concatenation of two strings. + * + * This is allowed only for pools with item_size == sizeof(char) + */ +extern char *git_pool_strcat(git_pool *pool, const char *a, const char *b); + +/** + * Push a block back onto the free list for the pool. + * + * This is allowed only if the item_size is >= sizeof(void*). + * + * In some cases, it is helpful to "release" an allocated block + * for reuse. Pools don't support a general purpose free, but + * they will keep a simple free blocks linked list provided the + * native block size is large enough to hold a void pointer + */ +extern void git_pool_free(git_pool *pool, void *ptr); + +/** + * Push an array of pool allocated blocks efficiently onto the free list. + * + * This has the same constraints as `git_pool_free()` above. + */ +extern void git_pool_free_array(git_pool *pool, size_t count, void **ptrs); + +/* + * Misc utilities + */ + +extern uint32_t git_pool__open_pages(git_pool *pool); + +extern uint32_t git_pool__full_pages(git_pool *pool); + +extern bool git_pool__ptr_in_pool(git_pool *pool, void *ptr); + +extern uint32_t git_pool__suggest_items_per_page(uint32_t item_size); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/posix.c b/deps/libgit2-sys-0.2.17/libgit2/src/posix.c new file mode 100644 index 000000000..8d86aa8bf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/posix.c @@ -0,0 +1,259 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "posix.h" +#include "path.h" +#include +#include + +#ifndef GIT_WIN32 + +#ifdef NO_ADDRINFO + +int p_getaddrinfo( + const char *host, + const char *port, + struct addrinfo *hints, + struct addrinfo **info) +{ + struct addrinfo *ainfo, *ai; + int p = 0; + + GIT_UNUSED(hints); + + if ((ainfo = malloc(sizeof(struct addrinfo))) == NULL) + return -1; + + if ((ainfo->ai_hostent = gethostbyname(host)) == NULL) { + free(ainfo); + return -2; + } + + ainfo->ai_servent = getservbyname(port, 0); + + if (ainfo->ai_servent) + ainfo->ai_port = ainfo->ai_servent->s_port; + else + ainfo->ai_port = atol(port); + + memcpy(&ainfo->ai_addr_in.sin_addr, + ainfo->ai_hostent->h_addr_list[0], + ainfo->ai_hostent->h_length); + + ainfo->ai_protocol = 0; + ainfo->ai_socktype = hints->ai_socktype; + ainfo->ai_family = ainfo->ai_hostent->h_addrtype; + ainfo->ai_addr_in.sin_family = ainfo->ai_family; + ainfo->ai_addr_in.sin_port = ainfo->ai_port; + ainfo->ai_addr = (struct addrinfo *)&ainfo->ai_addr_in; + ainfo->ai_addrlen = sizeof(struct sockaddr_in); + + *info = ainfo; + + if (ainfo->ai_hostent->h_addr_list[1] == NULL) { + ainfo->ai_next = NULL; + return 0; + } + + ai = ainfo; + + for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) { + ai->ai_next = malloc(sizeof(struct addrinfo)); + memcpy(&ai->ai_next, ainfo, sizeof(struct addrinfo)); + memcpy(&ai->ai_next->ai_addr_in.sin_addr, + ainfo->ai_hostent->h_addr_list[p], + ainfo->ai_hostent->h_length); + ai->ai_next->ai_addr = (struct addrinfo *)&ai->ai_next->ai_addr_in; + ai = ai->ai_next; + } + + ai->ai_next = NULL; + return 0; +} + +void p_freeaddrinfo(struct addrinfo *info) +{ + struct addrinfo *p, *next; + + p = info; + + while(p != NULL) { + next = p->ai_next; + free(p); + p = next; + } +} + +const char *p_gai_strerror(int ret) +{ + switch(ret) { + case -1: return "Out of memory"; break; + case -2: return "Address lookup failed"; break; + default: return "Unknown error"; break; + } +} + +#endif /* NO_ADDRINFO */ + +int p_open(const char *path, volatile int flags, ...) +{ + mode_t mode = 0; + + if (flags & O_CREAT) { + va_list arg_list; + + va_start(arg_list, flags); + mode = (mode_t)va_arg(arg_list, int); + va_end(arg_list); + } + + return open(path, flags | O_BINARY | O_CLOEXEC, mode); +} + +int p_creat(const char *path, mode_t mode) +{ + return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC, mode); +} + +int p_getcwd(char *buffer_out, size_t size) +{ + char *cwd_buffer; + + assert(buffer_out && size > 0); + + cwd_buffer = getcwd(buffer_out, size); + + if (cwd_buffer == NULL) + return -1; + + git_path_mkposix(buffer_out); + git_path_string_to_dir(buffer_out, size); /* append trailing slash */ + + return 0; +} + +int p_rename(const char *from, const char *to) +{ + if (!link(from, to)) { + p_unlink(from); + return 0; + } + + if (!rename(from, to)) + return 0; + + return -1; +} + +#endif /* GIT_WIN32 */ + +ssize_t p_read(git_file fd, void *buf, size_t cnt) +{ + char *b = buf; + + if (!git__is_ssizet(cnt)) { +#ifdef GIT_WIN32 + SetLastError(ERROR_INVALID_PARAMETER); +#endif + errno = EINVAL; + return -1; + } + + while (cnt) { + ssize_t r; +#ifdef GIT_WIN32 + r = read(fd, b, cnt > INT_MAX ? INT_MAX : (unsigned int)cnt); +#else + r = read(fd, b, cnt); +#endif + if (r < 0) { + if (errno == EINTR || errno == EAGAIN) + continue; + return -1; + } + if (!r) + break; + cnt -= r; + b += r; + } + return (b - (char *)buf); +} + +int p_write(git_file fd, const void *buf, size_t cnt) +{ + const char *b = buf; + + while (cnt) { + ssize_t r; +#ifdef GIT_WIN32 + assert((size_t)((unsigned int)cnt) == cnt); + r = write(fd, b, (unsigned int)cnt); +#else + r = write(fd, b, cnt); +#endif + if (r < 0) { + if (errno == EINTR || GIT_ISBLOCKED(errno)) + continue; + return -1; + } + if (!r) { + errno = EPIPE; + return -1; + } + cnt -= r; + b += r; + } + return 0; +} + +#ifdef NO_MMAP + +#include "map.h" + +int git__page_size(size_t *page_size) +{ + /* dummy; here we don't need any alignment anyway */ + *page_size = 4096; + return 0; +} + + +int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) +{ + GIT_MMAP_VALIDATE(out, len, prot, flags); + + out->data = NULL; + out->len = 0; + + if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) { + giterr_set(GITERR_OS, "Trying to map shared-writeable"); + return -1; + } + + out->data = malloc(len); + GITERR_CHECK_ALLOC(out->data); + + if (!git__is_ssizet(len) || + (p_lseek(fd, offset, SEEK_SET) < 0) || + (p_read(fd, out->data, len) != (ssize_t)len)) { + giterr_set(GITERR_OS, "mmap emulation failed"); + return -1; + } + + out->len = len; + return 0; +} + +int p_munmap(git_map *map) +{ + assert(map != NULL); + free(map->data); + + return 0; +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/posix.h b/deps/libgit2-sys-0.2.17/libgit2/src/posix.h new file mode 100644 index 000000000..22f472c90 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/posix.h @@ -0,0 +1,161 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_posix_h__ +#define INCLUDE_posix_h__ + +#include "common.h" +#include +#include +#include "fnmatch.h" + +/* stat: file mode type testing macros */ +#ifndef S_IFGITLINK +#define S_IFGITLINK 0160000 +#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK) +#endif + +#ifndef S_IFLNK +#define S_IFLNK 0120000 +#undef _S_IFLNK +#define _S_IFLNK S_IFLNK +#endif + +#ifndef S_IXUSR +#define S_IXUSR 00100 +#endif + +#ifndef S_ISLNK +#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#endif + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif + +#ifndef S_ISFIFO +#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) +#endif + +/* if S_ISGID is not defined, then don't try to set it */ +#ifndef S_ISGID +#define S_ISGID 0 +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + +/* access() mode parameter #defines */ +#ifndef F_OK +#define F_OK 0 /* existence check */ +#endif +#ifndef W_OK +#define W_OK 2 /* write mode check */ +#endif +#ifndef R_OK +#define R_OK 4 /* read mode check */ +#endif + +/* Determine whether an errno value indicates that a read or write failed + * because the descriptor is blocked. + */ +#if defined(EWOULDBLOCK) +#define GIT_ISBLOCKED(e) ((e) == EAGAIN || (e) == EWOULDBLOCK) +#else +#define GIT_ISBLOCKED(e) ((e) == EAGAIN) +#endif + +/* define some standard errnos that the runtime may be missing. for example, + * mingw lacks EAFNOSUPPORT. */ +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT (INT_MAX-1) +#endif + +typedef int git_file; + +/** + * Standard POSIX Methods + * + * All the methods starting with the `p_` prefix are + * direct ports of the standard POSIX methods. + * + * Some of the methods are slightly wrapped to provide + * saner defaults. Some of these methods are emulated + * in Windows platforms. + * + * Use your manpages to check the docs on these. + */ + +extern ssize_t p_read(git_file fd, void *buf, size_t cnt); +extern int p_write(git_file fd, const void *buf, size_t cnt); + +#define p_close(fd) close(fd) +#define p_umask(m) umask(m) + +extern int p_open(const char *path, int flags, ...); +extern int p_creat(const char *path, mode_t mode); +extern int p_getcwd(char *buffer_out, size_t size); +extern int p_rename(const char *from, const char *to); + +extern int git__page_size(size_t *page_size); + +/** + * Platform-dependent methods + */ +#ifdef GIT_WIN32 +# include "win32/posix.h" +#else +# include "unix/posix.h" +#endif + +#include "strnlen.h" + +#ifdef NO_READDIR_R +# include +GIT_INLINE(int) p_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) +{ + GIT_UNUSED(entry); + *result = readdir(dirp); + return 0; +} +#else /* NO_READDIR_R */ +# define p_readdir_r(d,e,r) readdir_r(d,e,r) +#endif + +#ifdef NO_ADDRINFO +# include +struct addrinfo { + struct hostent *ai_hostent; + struct servent *ai_servent; + struct sockaddr_in ai_addr_in; + struct sockaddr *ai_addr; + size_t ai_addrlen; + int ai_family; + int ai_socktype; + int ai_protocol; + long ai_port; + struct addrinfo *ai_next; +}; + +extern int p_getaddrinfo(const char *host, const char *port, + struct addrinfo *hints, struct addrinfo **info); +extern void p_freeaddrinfo(struct addrinfo *info); +extern const char *p_gai_strerror(int ret); +#else +# define p_getaddrinfo(a, b, c, d) getaddrinfo(a, b, c, d) +# define p_freeaddrinfo(a) freeaddrinfo(a) +# define p_gai_strerror(c) gai_strerror(c) +#endif /* NO_ADDRINFO */ + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pqueue.c b/deps/libgit2-sys-0.2.17/libgit2/src/pqueue.c new file mode 100644 index 000000000..54a60ca04 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pqueue.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "pqueue.h" +#include "util.h" + +#define PQUEUE_LCHILD_OF(I) (((I)<<1)+1) +#define PQUEUE_RCHILD_OF(I) (((I)<<1)+2) +#define PQUEUE_PARENT_OF(I) (((I)-1)>>1) + +int git_pqueue_init( + git_pqueue *pq, + uint32_t flags, + size_t init_size, + git_vector_cmp cmp) +{ + int error = git_vector_init(pq, init_size, cmp); + + if (!error) { + /* mix in our flags */ + pq->flags |= flags; + + /* if fixed size heap, pretend vector is exactly init_size elements */ + if ((flags & GIT_PQUEUE_FIXED_SIZE) && init_size > 0) + pq->_alloc_size = init_size; + } + + return error; +} + +static void pqueue_up(git_pqueue *pq, size_t el) +{ + size_t parent_el = PQUEUE_PARENT_OF(el); + void *kid = git_vector_get(pq, el); + + while (el > 0) { + void *parent = pq->contents[parent_el]; + + if (pq->_cmp(parent, kid) <= 0) + break; + + pq->contents[el] = parent; + + el = parent_el; + parent_el = PQUEUE_PARENT_OF(el); + } + + pq->contents[el] = kid; +} + +static void pqueue_down(git_pqueue *pq, size_t el) +{ + void *parent = git_vector_get(pq, el), *kid, *rkid; + + while (1) { + size_t kid_el = PQUEUE_LCHILD_OF(el); + + if ((kid = git_vector_get(pq, kid_el)) == NULL) + break; + + if ((rkid = git_vector_get(pq, kid_el + 1)) != NULL && + pq->_cmp(kid, rkid) > 0) { + kid = rkid; + kid_el += 1; + } + + if (pq->_cmp(parent, kid) <= 0) + break; + + pq->contents[el] = kid; + el = kid_el; + } + + pq->contents[el] = parent; +} + +int git_pqueue_insert(git_pqueue *pq, void *item) +{ + int error = 0; + + /* if heap is full, pop the top element if new one should replace it */ + if ((pq->flags & GIT_PQUEUE_FIXED_SIZE) != 0 && + pq->length >= pq->_alloc_size) + { + /* skip this item if below min item in heap */ + if (pq->_cmp(item, git_vector_get(pq, 0)) <= 0) + return 0; + /* otherwise remove the min item before inserting new */ + (void)git_pqueue_pop(pq); + } + + if (!(error = git_vector_insert(pq, item))) + pqueue_up(pq, pq->length - 1); + + return error; +} + +void *git_pqueue_pop(git_pqueue *pq) +{ + void *rval = git_pqueue_get(pq, 0); + + if (git_pqueue_size(pq) > 1) { + /* move last item to top of heap, shrink, and push item down */ + pq->contents[0] = git_vector_last(pq); + git_vector_pop(pq); + pqueue_down(pq, 0); + } else { + /* all we need to do is shrink the heap in this case */ + git_vector_pop(pq); + } + + return rval; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/pqueue.h b/deps/libgit2-sys-0.2.17/libgit2/src/pqueue.h new file mode 100644 index 000000000..da7b74edf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/pqueue.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_pqueue_h__ +#define INCLUDE_pqueue_h__ + +#include "vector.h" + +typedef git_vector git_pqueue; + +enum { + /* flag meaning: don't grow heap, keep highest values only */ + GIT_PQUEUE_FIXED_SIZE = (GIT_VECTOR_FLAG_MAX << 1), +}; + +/** + * Initialize priority queue + * + * @param pq The priority queue struct to initialize + * @param flags Flags (see above) to control queue behavior + * @param init_size The initial queue size + * @param cmp The entry priority comparison function + * @return 0 on success, <0 on error + */ +extern int git_pqueue_init( + git_pqueue *pq, + uint32_t flags, + size_t init_size, + git_vector_cmp cmp); + +#define git_pqueue_free git_vector_free +#define git_pqueue_clear git_vector_clear +#define git_pqueue_size git_vector_length +#define git_pqueue_get git_vector_get + +/** + * Insert a new item into the queue + * + * @param pq The priority queue + * @param item Pointer to the item data + * @return 0 on success, <0 on failure + */ +extern int git_pqueue_insert(git_pqueue *pq, void *item); + +/** + * Remove the top item in the priority queue + * + * @param pq The priority queue + * @return item from heap on success, NULL if queue is empty + */ +extern void *git_pqueue_pop(git_pqueue *pq); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/push.c b/deps/libgit2-sys-0.2.17/libgit2/src/push.c new file mode 100644 index 000000000..d4171bbd6 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/push.c @@ -0,0 +1,694 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2.h" + +#include "common.h" +#include "pack.h" +#include "pack-objects.h" +#include "remote.h" +#include "vector.h" +#include "push.h" +#include "tree.h" + +static int push_spec_rref_cmp(const void *a, const void *b) +{ + const push_spec *push_spec_a = a, *push_spec_b = b; + + return strcmp(push_spec_a->refspec.dst, push_spec_b->refspec.dst); +} + +static int push_status_ref_cmp(const void *a, const void *b) +{ + const push_status *push_status_a = a, *push_status_b = b; + + return strcmp(push_status_a->ref, push_status_b->ref); +} + +int git_push_new(git_push **out, git_remote *remote) +{ + git_push *p; + + *out = NULL; + + p = git__calloc(1, sizeof(*p)); + GITERR_CHECK_ALLOC(p); + + p->repo = remote->repo; + p->remote = remote; + p->report_status = 1; + p->pb_parallelism = 1; + + if (git_vector_init(&p->specs, 0, push_spec_rref_cmp) < 0) { + git__free(p); + return -1; + } + + if (git_vector_init(&p->status, 0, push_status_ref_cmp) < 0) { + git_vector_free(&p->specs); + git__free(p); + return -1; + } + + *out = p; + return 0; +} + +int git_push_set_options(git_push *push, const git_push_options *opts) +{ + if (!push || !opts) + return -1; + + GITERR_CHECK_VERSION(opts, GIT_PUSH_OPTIONS_VERSION, "git_push_options"); + + push->pb_parallelism = opts->pb_parallelism; + + return 0; +} + +int git_push_set_callbacks( + git_push *push, + git_packbuilder_progress pack_progress_cb, + void *pack_progress_cb_payload, + git_push_transfer_progress transfer_progress_cb, + void *transfer_progress_cb_payload) +{ + if (!push) + return -1; + + push->pack_progress_cb = pack_progress_cb; + push->pack_progress_cb_payload = pack_progress_cb_payload; + + push->transfer_progress_cb = transfer_progress_cb; + push->transfer_progress_cb_payload = transfer_progress_cb_payload; + + return 0; +} + +static void free_refspec(push_spec *spec) +{ + if (spec == NULL) + return; + + git_refspec__free(&spec->refspec); + git__free(spec); +} + +static int check_rref(char *ref) +{ + if (git__prefixcmp(ref, "refs/")) { + giterr_set(GITERR_INVALID, "Not a valid reference '%s'", ref); + return -1; + } + + return 0; +} + +static int check_lref(git_push *push, char *ref) +{ + /* lref must be resolvable to an existing object */ + git_object *obj; + int error = git_revparse_single(&obj, push->repo, ref); + git_object_free(obj); + + if (!error) + return 0; + + if (error == GIT_ENOTFOUND) + giterr_set(GITERR_REFERENCE, + "src refspec '%s' does not match any existing object", ref); + else + giterr_set(GITERR_INVALID, "Not a valid reference '%s'", ref); + return -1; +} + +static int parse_refspec(git_push *push, push_spec **spec, const char *str) +{ + push_spec *s; + + *spec = NULL; + + s = git__calloc(1, sizeof(*s)); + GITERR_CHECK_ALLOC(s); + + if (git_refspec__parse(&s->refspec, str, false) < 0) { + giterr_set(GITERR_INVALID, "invalid refspec %s", str); + goto on_error; + } + + if (s->refspec.src && s->refspec.src[0] != '\0' && + check_lref(push, s->refspec.src) < 0) { + goto on_error; + } + + if (check_rref(s->refspec.dst) < 0) + goto on_error; + + *spec = s; + return 0; + +on_error: + free_refspec(s); + return -1; +} + +int git_push_add_refspec(git_push *push, const char *refspec) +{ + push_spec *spec; + + if (parse_refspec(push, &spec, refspec) < 0 || + git_vector_insert(&push->specs, spec) < 0) + return -1; + + return 0; +} + +int git_push_update_tips(git_push *push) +{ + git_buf remote_ref_name = GIT_BUF_INIT; + size_t i, j; + git_refspec *fetch_spec; + push_spec *push_spec = NULL; + git_reference *remote_ref; + push_status *status; + int error = 0; + + git_vector_foreach(&push->status, i, status) { + int fire_callback = 1; + + /* Skip unsuccessful updates which have non-empty messages */ + if (status->msg) + continue; + + /* Find the corresponding remote ref */ + fetch_spec = git_remote__matching_refspec(push->remote, status->ref); + if (!fetch_spec) + continue; + + if ((error = git_refspec_transform(&remote_ref_name, fetch_spec, status->ref)) < 0) + goto on_error; + + /* Find matching push ref spec */ + git_vector_foreach(&push->specs, j, push_spec) { + if (!strcmp(push_spec->refspec.dst, status->ref)) + break; + } + + /* Could not find the corresponding push ref spec for this push update */ + if (j == push->specs.length) + continue; + + /* Update the remote ref */ + if (git_oid_iszero(&push_spec->loid)) { + error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name)); + + if (error >= 0) { + error = git_reference_delete(remote_ref); + git_reference_free(remote_ref); + } + } else { + error = git_reference_create(NULL, push->remote->repo, + git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, + "update by push"); + } + + if (error < 0) { + if (error != GIT_ENOTFOUND) + goto on_error; + + giterr_clear(); + fire_callback = 0; + } + + if (fire_callback && push->remote->callbacks.update_tips) { + error = push->remote->callbacks.update_tips(git_buf_cstr(&remote_ref_name), + &push_spec->roid, &push_spec->loid, push->remote->callbacks.payload); + + if (error < 0) + goto on_error; + } + } + + error = 0; + +on_error: + git_buf_free(&remote_ref_name); + return error; +} + +/** + * Insert all tags until we find a non-tag object, which is returned + * in `out`. + */ +static int enqueue_tag(git_object **out, git_push *push, git_oid *id) +{ + git_object *obj = NULL, *target = NULL; + int error; + + if ((error = git_object_lookup(&obj, push->repo, id, GIT_OBJ_TAG)) < 0) + return error; + + while (git_object_type(obj) == GIT_OBJ_TAG) { + if ((error = git_packbuilder_insert(push->pb, git_object_id(obj), NULL)) < 0) + break; + + if ((error = git_tag_target(&target, (git_tag *) obj)) < 0) + break; + + git_object_free(obj); + obj = target; + } + + if (error < 0) + git_object_free(obj); + else + *out = obj; + + return error; +} + +static int revwalk(git_vector *commits, git_push *push) +{ + git_remote_head *head; + push_spec *spec; + git_revwalk *rw; + git_oid oid; + unsigned int i; + int error = -1; + + if (git_revwalk_new(&rw, push->repo) < 0) + return -1; + + git_revwalk_sorting(rw, GIT_SORT_TIME); + + git_vector_foreach(&push->specs, i, spec) { + git_otype type; + size_t size; + + if (git_oid_iszero(&spec->loid)) + /* + * Delete reference on remote side; + * nothing to do here. + */ + continue; + + if (git_oid_equal(&spec->loid, &spec->roid)) + continue; /* up-to-date */ + + if (git_odb_read_header(&size, &type, push->repo->_odb, &spec->loid) < 0) + goto on_error; + + if (type == GIT_OBJ_TAG) { + git_object *target; + + if ((error = enqueue_tag(&target, push, &spec->loid)) < 0) + goto on_error; + + if (git_object_type(target) == GIT_OBJ_COMMIT) { + if (git_revwalk_push(rw, git_object_id(target)) < 0) { + git_object_free(target); + goto on_error; + } + } else { + if (git_packbuilder_insert( + push->pb, git_object_id(target), NULL) < 0) { + git_object_free(target); + goto on_error; + } + } + git_object_free(target); + } else if (git_revwalk_push(rw, &spec->loid) < 0) + goto on_error; + + if (!spec->refspec.force) { + git_oid base; + + if (git_oid_iszero(&spec->roid)) + continue; + + if (!git_odb_exists(push->repo->_odb, &spec->roid)) { + giterr_set(GITERR_REFERENCE, + "Cannot push because a reference that you are trying to update on the remote contains commits that are not present locally."); + error = GIT_ENONFASTFORWARD; + goto on_error; + } + + error = git_merge_base(&base, push->repo, + &spec->loid, &spec->roid); + + if (error == GIT_ENOTFOUND || + (!error && !git_oid_equal(&base, &spec->roid))) { + giterr_set(GITERR_REFERENCE, + "Cannot push non-fastforwardable reference"); + error = GIT_ENONFASTFORWARD; + goto on_error; + } + + if (error < 0) + goto on_error; + } + } + + git_vector_foreach(&push->remote->refs, i, head) { + if (git_oid_iszero(&head->oid)) + continue; + + /* TODO */ + git_revwalk_hide(rw, &head->oid); + } + + while ((error = git_revwalk_next(&oid, rw)) == 0) { + git_oid *o = git__malloc(GIT_OID_RAWSZ); + if (!o) { + error = -1; + goto on_error; + } + git_oid_cpy(o, &oid); + if ((error = git_vector_insert(commits, o)) < 0) + goto on_error; + } + +on_error: + git_revwalk_free(rw); + return error == GIT_ITEROVER ? 0 : error; +} + +static int enqueue_object( + const git_tree_entry *entry, + git_packbuilder *pb) +{ + switch (git_tree_entry_type(entry)) { + case GIT_OBJ_COMMIT: + return 0; + case GIT_OBJ_TREE: + return git_packbuilder_insert_tree(pb, &entry->oid); + default: + return git_packbuilder_insert(pb, &entry->oid, entry->filename); + } +} + +static int queue_differences( + git_tree *base, + git_tree *delta, + git_packbuilder *pb) +{ + git_tree *b_child = NULL, *d_child = NULL; + size_t b_length = git_tree_entrycount(base); + size_t d_length = git_tree_entrycount(delta); + size_t i = 0, j = 0; + int error; + + while (i < b_length && j < d_length) { + const git_tree_entry *b_entry = git_tree_entry_byindex(base, i); + const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j); + int cmp = 0; + + if (!git_oid__cmp(&b_entry->oid, &d_entry->oid)) + goto loop; + + cmp = strcmp(b_entry->filename, d_entry->filename); + + /* If the entries are both trees and they have the same name but are + * different, then we'll recurse after adding the right-hand entry */ + if (!cmp && + git_tree_entry__is_tree(b_entry) && + git_tree_entry__is_tree(d_entry)) { + /* Add the right-hand entry */ + if ((error = git_packbuilder_insert(pb, &d_entry->oid, + d_entry->filename)) < 0) + goto on_error; + + /* Acquire the subtrees and recurse */ + if ((error = git_tree_lookup(&b_child, + git_tree_owner(base), &b_entry->oid)) < 0 || + (error = git_tree_lookup(&d_child, + git_tree_owner(delta), &d_entry->oid)) < 0 || + (error = queue_differences(b_child, d_child, pb)) < 0) + goto on_error; + + git_tree_free(b_child); b_child = NULL; + git_tree_free(d_child); d_child = NULL; + } + /* If the object is new or different in the right-hand tree, + * then enumerate it */ + else if (cmp >= 0 && + (error = enqueue_object(d_entry, pb)) < 0) + goto on_error; + + loop: + if (cmp <= 0) i++; + if (cmp >= 0) j++; + } + + /* Drain the right-hand tree of entries */ + for (; j < d_length; j++) + if ((error = enqueue_object(git_tree_entry_byindex(delta, j), pb)) < 0) + goto on_error; + + error = 0; + +on_error: + if (b_child) + git_tree_free(b_child); + + if (d_child) + git_tree_free(d_child); + + return error; +} + +static int queue_objects(git_push *push) +{ + git_vector commits = GIT_VECTOR_INIT; + git_oid *oid; + size_t i; + unsigned j; + int error; + + if ((error = revwalk(&commits, push)) < 0) + goto on_error; + + git_vector_foreach(&commits, i, oid) { + git_commit *parent = NULL, *commit; + git_tree *tree = NULL, *ptree = NULL; + size_t parentcount; + + if ((error = git_commit_lookup(&commit, push->repo, oid)) < 0) + goto on_error; + + /* Insert the commit */ + if ((error = git_packbuilder_insert(push->pb, oid, NULL)) < 0) + goto loop_error; + + parentcount = git_commit_parentcount(commit); + + if (!parentcount) { + if ((error = git_packbuilder_insert_tree(push->pb, + git_commit_tree_id(commit))) < 0) + goto loop_error; + } else { + if ((error = git_tree_lookup(&tree, push->repo, + git_commit_tree_id(commit))) < 0 || + (error = git_packbuilder_insert(push->pb, + git_commit_tree_id(commit), NULL)) < 0) + goto loop_error; + + /* For each parent, add the items which are different */ + for (j = 0; j < parentcount; j++) { + if ((error = git_commit_parent(&parent, commit, j)) < 0 || + (error = git_commit_tree(&ptree, parent)) < 0 || + (error = queue_differences(ptree, tree, push->pb)) < 0) + goto loop_error; + + git_tree_free(ptree); ptree = NULL; + git_commit_free(parent); parent = NULL; + } + } + + error = 0; + + loop_error: + if (tree) + git_tree_free(tree); + + if (ptree) + git_tree_free(ptree); + + if (parent) + git_commit_free(parent); + + git_commit_free(commit); + + if (error < 0) + goto on_error; + } + + error = 0; + +on_error: + git_vector_free_deep(&commits); + return error; +} + +static int calculate_work(git_push *push) +{ + git_remote_head *head; + push_spec *spec; + unsigned int i, j; + + /* Update local and remote oids*/ + + git_vector_foreach(&push->specs, i, spec) { + if (spec->refspec.src && spec->refspec.src[0]!= '\0') { + /* This is a create or update. Local ref must exist. */ + if (git_reference_name_to_id( + &spec->loid, push->repo, spec->refspec.src) < 0) { + giterr_set(GITERR_REFERENCE, "No such reference '%s'", spec->refspec.src); + return -1; + } + } + + /* Remote ref may or may not (e.g. during create) already exist. */ + git_vector_foreach(&push->remote->refs, j, head) { + if (!strcmp(spec->refspec.dst, head->name)) { + git_oid_cpy(&spec->roid, &head->oid); + break; + } + } + } + + return 0; +} + +static int do_push(git_push *push) +{ + int error = 0; + git_transport *transport = push->remote->transport; + + if (!transport->push) { + giterr_set(GITERR_NET, "Remote transport doesn't support push"); + error = -1; + goto on_error; + } + + /* + * A pack-file MUST be sent if either create or update command + * is used, even if the server already has all the necessary + * objects. In this case the client MUST send an empty pack-file. + */ + + if ((error = git_packbuilder_new(&push->pb, push->repo)) < 0) + goto on_error; + + git_packbuilder_set_threads(push->pb, push->pb_parallelism); + + if (push->pack_progress_cb) + if ((error = git_packbuilder_set_callbacks(push->pb, push->pack_progress_cb, push->pack_progress_cb_payload)) < 0) + goto on_error; + + if ((error = calculate_work(push)) < 0 || + (error = queue_objects(push)) < 0 || + (error = transport->push(transport, push)) < 0) + goto on_error; + +on_error: + git_packbuilder_free(push->pb); + return error; +} + +static int filter_refs(git_remote *remote) +{ + const git_remote_head **heads; + size_t heads_len, i; + + git_vector_clear(&remote->refs); + + if (git_remote_ls(&heads, &heads_len, remote) < 0) + return -1; + + for (i = 0; i < heads_len; i++) { + if (git_vector_insert(&remote->refs, (void *)heads[i]) < 0) + return -1; + } + + return 0; +} + +int git_push_finish(git_push *push) +{ + int error; + + if (!git_remote_connected(push->remote) && + (error = git_remote_connect(push->remote, GIT_DIRECTION_PUSH)) < 0) + return error; + + if ((error = filter_refs(push->remote)) < 0 || + (error = do_push(push)) < 0) + return error; + + if (!push->unpack_ok) { + error = -1; + giterr_set(GITERR_NET, "unpacking the sent packfile failed on the remote"); + } + + return error; +} + +int git_push_status_foreach(git_push *push, + int (*cb)(const char *ref, const char *msg, void *data), + void *data) +{ + push_status *status; + unsigned int i; + + git_vector_foreach(&push->status, i, status) { + int error = cb(status->ref, status->msg, data); + if (error) + return giterr_set_after_callback(error); + } + + return 0; +} + +void git_push_status_free(push_status *status) +{ + if (status == NULL) + return; + + git__free(status->msg); + git__free(status->ref); + git__free(status); +} + +void git_push_free(git_push *push) +{ + push_spec *spec; + push_status *status; + unsigned int i; + + if (push == NULL) + return; + + git_vector_foreach(&push->specs, i, spec) { + free_refspec(spec); + } + git_vector_free(&push->specs); + + git_vector_foreach(&push->status, i, status) { + git_push_status_free(status); + } + git_vector_free(&push->status); + + git__free(push); +} + +int git_push_init_options(git_push_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_push_options, GIT_PUSH_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/push.h b/deps/libgit2-sys-0.2.17/libgit2/src/push.h new file mode 100644 index 000000000..b19d40e03 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/push.h @@ -0,0 +1,159 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_push_h__ +#define INCLUDE_push_h__ + +#include "git2.h" +#include "refspec.h" + +typedef struct push_spec { + struct git_refspec refspec; + + git_oid loid; + git_oid roid; +} push_spec; + +typedef struct push_status { + bool ok; + + char *ref; + char *msg; +} push_status; + +struct git_push { + git_repository *repo; + git_packbuilder *pb; + git_remote *remote; + git_vector specs; + bool report_status; + + /* report-status */ + bool unpack_ok; + git_vector status; + + /* options */ + unsigned pb_parallelism; + + git_packbuilder_progress pack_progress_cb; + void *pack_progress_cb_payload; + git_push_transfer_progress transfer_progress_cb; + void *transfer_progress_cb_payload; +}; + +/** + * Free the given push status object + * + * @param status The push status object + */ +void git_push_status_free(push_status *status); + +/** + * Create a new push object + * + * @param out New push object + * @param remote Remote instance + * + * @return 0 or an error code + */ +int git_push_new(git_push **out, git_remote *remote); + +/** + * Set options on a push object + * + * @param push The push object + * @param opts The options to set on the push object + * + * @return 0 or an error code + */ +int git_push_set_options( + git_push *push, + const git_push_options *opts); + +/** + * Set the callbacks for a push + * + * @param push The push object + * @param pack_progress_cb Function to call with progress information during + * pack building. Be aware that this is called inline with pack building + * operations, so performance may be affected. + * @param pack_progress_cb_payload Payload for the pack progress callback. + * @param transfer_progress_cb Function to call with progress information during + * the upload portion of a push. Be aware that this is called inline with + * pack building operations, so performance may be affected. + * @param transfer_progress_cb_payload Payload for the network progress callback. + * @return 0 or an error code + */ +int git_push_set_callbacks( + git_push *push, + git_packbuilder_progress pack_progress_cb, + void *pack_progress_cb_payload, + git_push_transfer_progress transfer_progress_cb, + void *transfer_progress_cb_payload); + +/** + * Add a refspec to be pushed + * + * @param push The push object + * @param refspec Refspec string + * + * @return 0 or an error code + */ +int git_push_add_refspec(git_push *push, const char *refspec); + +/** + * Update remote tips after a push + * + * @param push The push object + * @param signature The identity to use when updating reflogs + * + * @return 0 or an error code + */ +int git_push_update_tips(git_push *push); + +/** + * Perform the push + * + * This function will return an error in case of a protocol error or + * the server being unable to unpack the data we sent. + * + * The return value does not reflect whether the server accepted or + * refused any reference updates. Use `git_push_status_foreach()` in + * order to find out which updates were accepted or rejected. + * + * @param push The push object + * + * @return 0 or an error code + */ +int git_push_finish(git_push *push); + +/** + * Invoke callback `cb' on each status entry + * + * For each of the updated references, we receive a status report in the + * form of `ok refs/heads/master` or `ng refs/heads/master `. + * `msg != NULL` means the reference has not been updated for the given + * reason. + * + * Return a non-zero value from the callback to stop the loop. + * + * @param push The push object + * @param cb The callback to call on each object + * + * @return 0 on success, non-zero callback return value, or error code + */ +int git_push_status_foreach(git_push *push, + int (*cb)(const char *ref, const char *msg, void *data), + void *data); + +/** + * Free the given push object + * + * @param push The push object + */ +void git_push_free(git_push *push); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/rebase.c b/deps/libgit2-sys-0.2.17/libgit2/src/rebase.c new file mode 100644 index 000000000..eb25d4c3a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/rebase.c @@ -0,0 +1,1171 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "buffer.h" +#include "repository.h" +#include "posix.h" +#include "filebuf.h" +#include "merge.h" +#include "array.h" +#include "config.h" +#include "annotated_commit.h" +#include "index.h" + +#include +#include +#include +#include +#include +#include +#include + +#define REBASE_APPLY_DIR "rebase-apply" +#define REBASE_MERGE_DIR "rebase-merge" + +#define HEAD_NAME_FILE "head-name" +#define ORIG_HEAD_FILE "orig-head" +#define HEAD_FILE "head" +#define ONTO_FILE "onto" +#define ONTO_NAME_FILE "onto_name" +#define QUIET_FILE "quiet" + +#define MSGNUM_FILE "msgnum" +#define END_FILE "end" +#define CMT_FILE_FMT "cmt.%" PRIuZ +#define CURRENT_FILE "current" +#define REWRITTEN_FILE "rewritten" + +#define ORIG_DETACHED_HEAD "detached HEAD" + +#define NOTES_DEFAULT_REF NULL + +#define REBASE_DIR_MODE 0777 +#define REBASE_FILE_MODE 0666 + +typedef enum { + GIT_REBASE_TYPE_NONE = 0, + GIT_REBASE_TYPE_APPLY = 1, + GIT_REBASE_TYPE_MERGE = 2, + GIT_REBASE_TYPE_INTERACTIVE = 3, +} git_rebase_type_t; + +struct git_rebase { + git_repository *repo; + + git_rebase_type_t type; + char *state_path; + + int head_detached : 1, + quiet : 1, + started : 1; + + char *orig_head_name; + git_oid orig_head_id; + + git_oid onto_id; + char *onto_name; + + git_array_t(git_rebase_operation) operations; + size_t current; +}; + +#define GIT_REBASE_STATE_INIT {0} + +static int rebase_state_type( + git_rebase_type_t *type_out, + char **path_out, + git_repository *repo) +{ + git_buf path = GIT_BUF_INIT; + git_rebase_type_t type = GIT_REBASE_TYPE_NONE; + + if (git_buf_joinpath(&path, repo->path_repository, REBASE_APPLY_DIR) < 0) + return -1; + + if (git_path_isdir(git_buf_cstr(&path))) { + type = GIT_REBASE_TYPE_APPLY; + goto done; + } + + git_buf_clear(&path); + if (git_buf_joinpath(&path, repo->path_repository, REBASE_MERGE_DIR) < 0) + return -1; + + if (git_path_isdir(git_buf_cstr(&path))) { + type = GIT_REBASE_TYPE_MERGE; + goto done; + } + +done: + *type_out = type; + + if (type != GIT_REBASE_TYPE_NONE && path_out) + *path_out = git_buf_detach(&path); + + git_buf_free(&path); + + return 0; +} + +GIT_INLINE(int) rebase_readfile( + git_buf *out, + git_buf *state_path, + const char *filename) +{ + size_t state_path_len = state_path->size; + int error; + + git_buf_clear(out); + + if ((error = git_buf_joinpath(state_path, state_path->ptr, filename)) < 0 || + (error = git_futils_readbuffer(out, state_path->ptr)) < 0) + goto done; + + git_buf_rtrim(out); + +done: + git_buf_truncate(state_path, state_path_len); + return error; +} + +GIT_INLINE(int) rebase_readint( + size_t *out, git_buf *asc_out, git_buf *state_path, const char *filename) +{ + int32_t num; + const char *eol; + int error = 0; + + if ((error = rebase_readfile(asc_out, state_path, filename)) < 0) + return error; + + if (git__strtol32(&num, asc_out->ptr, &eol, 10) < 0 || num < 0 || *eol) { + giterr_set(GITERR_REBASE, "The file '%s' contains an invalid numeric value", filename); + return -1; + } + + *out = (size_t) num; + + return 0; +} + +GIT_INLINE(int) rebase_readoid( + git_oid *out, git_buf *str_out, git_buf *state_path, const char *filename) +{ + int error; + + if ((error = rebase_readfile(str_out, state_path, filename)) < 0) + return error; + + if (str_out->size != GIT_OID_HEXSZ || git_oid_fromstr(out, str_out->ptr) < 0) { + giterr_set(GITERR_REBASE, "The file '%s' contains an invalid object ID", filename); + return -1; + } + + return 0; +} + +static git_rebase_operation *rebase_operation_alloc( + git_rebase *rebase, + git_rebase_operation_t type, + git_oid *id, + const char *exec) +{ + git_rebase_operation *operation; + + assert((type == GIT_REBASE_OPERATION_EXEC) == !id); + assert((type == GIT_REBASE_OPERATION_EXEC) == !!exec); + + if ((operation = git_array_alloc(rebase->operations)) == NULL) + return NULL; + + operation->type = type; + git_oid_cpy((git_oid *)&operation->id, id); + operation->exec = exec; + + return operation; +} + +static int rebase_open_merge(git_rebase *rebase) +{ + git_buf state_path = GIT_BUF_INIT, buf = GIT_BUF_INIT, cmt = GIT_BUF_INIT; + git_oid id; + git_rebase_operation *operation; + size_t i, msgnum = 0, end; + int error; + + if ((error = git_buf_puts(&state_path, rebase->state_path)) < 0) + goto done; + + /* Read 'msgnum' if it exists (otherwise, let msgnum = 0) */ + if ((error = rebase_readint(&msgnum, &buf, &state_path, MSGNUM_FILE)) < 0 && + error != GIT_ENOTFOUND) + goto done; + + if (msgnum) { + rebase->started = 1; + rebase->current = msgnum - 1; + } + + /* Read 'end' */ + if ((error = rebase_readint(&end, &buf, &state_path, END_FILE)) < 0) + goto done; + + /* Read 'current' if it exists */ + if ((error = rebase_readoid(&id, &buf, &state_path, CURRENT_FILE)) < 0 && + error != GIT_ENOTFOUND) + goto done; + + /* Read cmt.* */ + git_array_init_to_size(rebase->operations, end); + GITERR_CHECK_ARRAY(rebase->operations); + + for (i = 0; i < end; i++) { + git_buf_clear(&cmt); + + if ((error = git_buf_printf(&cmt, "cmt.%" PRIuZ, (i+1))) < 0 || + (error = rebase_readoid(&id, &buf, &state_path, cmt.ptr)) < 0) + goto done; + + operation = rebase_operation_alloc(rebase, GIT_REBASE_OPERATION_PICK, &id, NULL); + GITERR_CHECK_ALLOC(operation); + } + + /* Read 'onto_name' */ + if ((error = rebase_readfile(&buf, &state_path, ONTO_NAME_FILE)) < 0) + goto done; + + rebase->onto_name = git_buf_detach(&buf); + +done: + git_buf_free(&cmt); + git_buf_free(&state_path); + git_buf_free(&buf); + + return error; +} + +int git_rebase_open(git_rebase **out, git_repository *repo) +{ + git_rebase *rebase; + git_buf path = GIT_BUF_INIT, orig_head_name = GIT_BUF_INIT, + orig_head_id = GIT_BUF_INIT, onto_id = GIT_BUF_INIT; + int state_path_len, error; + + assert(repo); + + rebase = git__calloc(1, sizeof(git_rebase)); + GITERR_CHECK_ALLOC(rebase); + + rebase->repo = repo; + + if ((error = rebase_state_type(&rebase->type, &rebase->state_path, repo)) < 0) + goto done; + + if (rebase->type == GIT_REBASE_TYPE_NONE) { + giterr_set(GITERR_REBASE, "There is no rebase in progress"); + error = GIT_ENOTFOUND; + goto done; + } + + if ((error = git_buf_puts(&path, rebase->state_path)) < 0) + goto done; + + state_path_len = git_buf_len(&path); + + if ((error = git_buf_joinpath(&path, path.ptr, HEAD_NAME_FILE)) < 0 || + (error = git_futils_readbuffer(&orig_head_name, path.ptr)) < 0) + goto done; + + git_buf_rtrim(&orig_head_name); + + if (strcmp(ORIG_DETACHED_HEAD, orig_head_name.ptr) == 0) + rebase->head_detached = 1; + + git_buf_truncate(&path, state_path_len); + + if ((error = git_buf_joinpath(&path, path.ptr, ORIG_HEAD_FILE)) < 0) + goto done; + + if (!git_path_isfile(path.ptr)) { + /* Previous versions of git.git used 'head' here; support that. */ + git_buf_truncate(&path, state_path_len); + + if ((error = git_buf_joinpath(&path, path.ptr, HEAD_FILE)) < 0) + goto done; + } + + if ((error = git_futils_readbuffer(&orig_head_id, path.ptr)) < 0) + goto done; + + git_buf_rtrim(&orig_head_id); + + if ((error = git_oid_fromstr(&rebase->orig_head_id, orig_head_id.ptr)) < 0) + goto done; + + git_buf_truncate(&path, state_path_len); + + if ((error = git_buf_joinpath(&path, path.ptr, ONTO_FILE)) < 0 || + (error = git_futils_readbuffer(&onto_id, path.ptr)) < 0) + goto done; + + git_buf_rtrim(&onto_id); + + if ((error = git_oid_fromstr(&rebase->onto_id, onto_id.ptr)) < 0) + goto done; + + if (!rebase->head_detached) + rebase->orig_head_name = git_buf_detach(&orig_head_name); + + switch (rebase->type) { + case GIT_REBASE_TYPE_INTERACTIVE: + giterr_set(GITERR_REBASE, "Interactive rebase is not supported"); + error = -1; + break; + case GIT_REBASE_TYPE_MERGE: + error = rebase_open_merge(rebase); + break; + case GIT_REBASE_TYPE_APPLY: + giterr_set(GITERR_REBASE, "Patch application rebase is not supported"); + error = -1; + break; + default: + abort(); + } + +done: + if (error == 0) + *out = rebase; + else + git_rebase_free(rebase); + + git_buf_free(&path); + git_buf_free(&orig_head_name); + git_buf_free(&orig_head_id); + git_buf_free(&onto_id); + return error; +} + +static int rebase_cleanup(git_rebase *rebase) +{ + return git_path_isdir(rebase->state_path) ? + git_futils_rmdir_r(rebase->state_path, NULL, GIT_RMDIR_REMOVE_FILES) : + 0; +} + +static int rebase_setupfile(git_rebase *rebase, const char *filename, int flags, const char *fmt, ...) +{ + git_buf path = GIT_BUF_INIT, + contents = GIT_BUF_INIT; + va_list ap; + int error; + + va_start(ap, fmt); + git_buf_vprintf(&contents, fmt, ap); + va_end(ap); + + if ((error = git_buf_joinpath(&path, rebase->state_path, filename)) == 0) + error = git_futils_writebuffer(&contents, path.ptr, flags, REBASE_FILE_MODE); + + git_buf_free(&path); + git_buf_free(&contents); + + return error; +} + +static const char *rebase_onto_name(const git_annotated_commit *onto) +{ + if (onto->ref_name && git__strncmp(onto->ref_name, "refs/heads/", 11) == 0) + return onto->ref_name + 11; + else if (onto->ref_name) + return onto->ref_name; + else + return onto->id_str; +} + +static int rebase_setupfiles_merge(git_rebase *rebase) +{ + git_buf commit_filename = GIT_BUF_INIT; + char id_str[GIT_OID_HEXSZ]; + git_rebase_operation *operation; + size_t i; + int error = 0; + + if ((error = rebase_setupfile(rebase, END_FILE, -1, "%d\n", git_array_size(rebase->operations))) < 0 || + (error = rebase_setupfile(rebase, ONTO_NAME_FILE, -1, "%s\n", rebase->onto_name)) < 0) + goto done; + + for (i = 0; i < git_array_size(rebase->operations); i++) { + operation = git_array_get(rebase->operations, i); + + git_buf_clear(&commit_filename); + git_buf_printf(&commit_filename, CMT_FILE_FMT, i+1); + + git_oid_fmt(id_str, &operation->id); + + if ((error = rebase_setupfile(rebase, commit_filename.ptr, -1, + "%.*s\n", GIT_OID_HEXSZ, id_str)) < 0) + goto done; + } + +done: + git_buf_free(&commit_filename); + return error; +} + +static int rebase_setupfiles(git_rebase *rebase) +{ + char onto[GIT_OID_HEXSZ], orig_head[GIT_OID_HEXSZ]; + + git_oid_fmt(onto, &rebase->onto_id); + git_oid_fmt(orig_head, &rebase->orig_head_id); + + if (p_mkdir(rebase->state_path, REBASE_DIR_MODE) < 0) { + giterr_set(GITERR_OS, "Failed to create rebase directory '%s'", rebase->state_path); + return -1; + } + + if (git_repository__set_orig_head(rebase->repo, &rebase->orig_head_id) < 0 || + rebase_setupfile(rebase, HEAD_NAME_FILE, -1, "%s\n", rebase->orig_head_name) < 0 || + rebase_setupfile(rebase, ONTO_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, onto) < 0 || + rebase_setupfile(rebase, ORIG_HEAD_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, orig_head) < 0 || + rebase_setupfile(rebase, QUIET_FILE, -1, rebase->quiet ? "t\n" : "\n") < 0) + return -1; + + return rebase_setupfiles_merge(rebase); +} + +int git_rebase_init_options(git_rebase_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_rebase_options, GIT_REBASE_OPTIONS_INIT); + return 0; +} + +static int rebase_normalize_opts( + git_repository *repo, + git_rebase_options *opts, + const git_rebase_options *given_opts) +{ + git_rebase_options default_opts = GIT_REBASE_OPTIONS_INIT; + git_config *config; + + if (given_opts) + memcpy(opts, given_opts, sizeof(git_rebase_options)); + else + memcpy(opts, &default_opts, sizeof(git_rebase_options)); + + if (git_repository_config(&config, repo) < 0) + return -1; + + if (given_opts && given_opts->rewrite_notes_ref) { + opts->rewrite_notes_ref = git__strdup(given_opts->rewrite_notes_ref); + GITERR_CHECK_ALLOC(opts->rewrite_notes_ref); + } else if (git_config__get_bool_force(config, "notes.rewrite.rebase", 1)) { + char *rewrite_ref = git_config__get_string_force( + config, "notes.rewriteref", NOTES_DEFAULT_REF); + + if (rewrite_ref) { + opts->rewrite_notes_ref = rewrite_ref; + GITERR_CHECK_ALLOC(opts->rewrite_notes_ref); + } + } + + git_config_free(config); + + return 0; +} + +static void rebase_opts_free(git_rebase_options *opts) +{ + if (!opts) + return; + + git__free((char *)opts->rewrite_notes_ref); +} + +static int rebase_ensure_not_in_progress(git_repository *repo) +{ + int error; + git_rebase_type_t type; + + if ((error = rebase_state_type(&type, NULL, repo)) < 0) + return error; + + if (type != GIT_REBASE_TYPE_NONE) { + giterr_set(GITERR_REBASE, "There is an existing rebase in progress"); + return -1; + } + + return 0; +} + +static int rebase_ensure_not_dirty(git_repository *repo) +{ + git_tree *head = NULL; + git_index *index = NULL; + git_diff *diff = NULL; + int error; + + if ((error = git_repository_head_tree(&head, repo)) < 0 || + (error = git_repository_index(&index, repo)) < 0 || + (error = git_diff_tree_to_index(&diff, repo, head, index, NULL)) < 0) + goto done; + + if (git_diff_num_deltas(diff) > 0) { + giterr_set(GITERR_REBASE, "Uncommitted changes exist in index"); + error = -1; + goto done; + } + + git_diff_free(diff); + diff = NULL; + + if ((error = git_diff_index_to_workdir(&diff, repo, index, NULL)) < 0) + goto done; + + if (git_diff_num_deltas(diff) > 0) { + giterr_set(GITERR_REBASE, "Unstaged changes exist in workdir"); + error = -1; + } + +done: + git_diff_free(diff); + git_index_free(index); + git_tree_free(head); + + return error; +} + +static int rebase_init_operations( + git_rebase *rebase, + git_repository *repo, + const git_annotated_commit *branch, + const git_annotated_commit *upstream, + const git_annotated_commit *onto) +{ + git_revwalk *revwalk = NULL; + git_commit *commit; + git_oid id; + bool merge; + git_rebase_operation *operation; + int error; + + if (!upstream) + upstream = onto; + + if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 || + (error = git_revwalk_push(revwalk, git_annotated_commit_id(branch))) < 0 || + (error = git_revwalk_hide(revwalk, git_annotated_commit_id(upstream))) < 0) + goto done; + + git_revwalk_sorting(revwalk, GIT_SORT_REVERSE | GIT_SORT_TIME); + + while ((error = git_revwalk_next(&id, revwalk)) == 0) { + if ((error = git_commit_lookup(&commit, repo, &id)) < 0) + goto done; + + merge = (git_commit_parentcount(commit) > 1); + git_commit_free(commit); + + if (merge) + continue; + + operation = rebase_operation_alloc(rebase, GIT_REBASE_OPERATION_PICK, &id, NULL); + GITERR_CHECK_ALLOC(operation); + } + + error = 0; + +done: + git_revwalk_free(revwalk); + return error; +} + +static int rebase_init_merge( + git_rebase *rebase, + git_repository *repo, + const git_annotated_commit *branch, + const git_annotated_commit *upstream, + const git_annotated_commit *onto) +{ + if (rebase_init_operations(rebase, repo, branch, upstream, onto) < 0) + return -1; + + rebase->onto_name = git__strdup(rebase_onto_name(onto)); + GITERR_CHECK_ALLOC(rebase->onto_name); + + return 0; +} + +static int rebase_init( + git_rebase *rebase, + git_repository *repo, + const git_annotated_commit *branch, + const git_annotated_commit *upstream, + const git_annotated_commit *onto, + const git_rebase_options *opts) +{ + git_reference *head_ref = NULL; + git_annotated_commit *head_branch = NULL; + git_buf state_path = GIT_BUF_INIT; + int error; + + if ((error = git_buf_joinpath(&state_path, repo->path_repository, REBASE_MERGE_DIR)) < 0) + goto done; + + if (!branch) { + if ((error = git_repository_head(&head_ref, repo)) < 0 || + (error = git_annotated_commit_from_ref(&head_branch, repo, head_ref)) < 0) + goto done; + + branch = head_branch; + } + + rebase->repo = repo; + rebase->type = GIT_REBASE_TYPE_MERGE; + rebase->state_path = git_buf_detach(&state_path); + rebase->orig_head_name = git__strdup(branch->ref_name ? branch->ref_name : ORIG_DETACHED_HEAD); + rebase->quiet = opts->quiet; + + git_oid_cpy(&rebase->orig_head_id, git_annotated_commit_id(branch)); + git_oid_cpy(&rebase->onto_id, git_annotated_commit_id(onto)); + + if (!rebase->orig_head_name || !rebase->state_path) + return -1; + + error = rebase_init_merge(rebase, repo, branch, upstream, onto); + + git_buf_free(&state_path); + +done: + git_reference_free(head_ref); + git_annotated_commit_free(head_branch); + + return error; +} + +int git_rebase_init( + git_rebase **out, + git_repository *repo, + const git_annotated_commit *branch, + const git_annotated_commit *upstream, + const git_annotated_commit *onto, + const git_rebase_options *given_opts) +{ + git_rebase *rebase = NULL; + git_rebase_options opts; + git_buf reflog = GIT_BUF_INIT; + git_commit *onto_commit = NULL; + git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; + git_reference *head_ref = NULL; + int error; + + assert(repo && (upstream || onto)); + + *out = NULL; + + GITERR_CHECK_VERSION(given_opts, GIT_REBASE_OPTIONS_VERSION, "git_rebase_options"); + + if (!onto) + onto = upstream; + + checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; + + if ((error = rebase_normalize_opts(repo, &opts, given_opts)) < 0 || + (error = git_repository__ensure_not_bare(repo, "rebase")) < 0 || + (error = rebase_ensure_not_in_progress(repo)) < 0 || + (error = rebase_ensure_not_dirty(repo)) < 0 || + (error = git_commit_lookup( + &onto_commit, repo, git_annotated_commit_id(onto))) < 0) + return error; + + rebase = git__calloc(1, sizeof(git_rebase)); + GITERR_CHECK_ALLOC(rebase); + + if ((error = rebase_init( + rebase, repo, branch, upstream, onto, &opts)) < 0 || + (error = rebase_setupfiles(rebase)) < 0 || + (error = git_buf_printf(&reflog, + "rebase: checkout %s", rebase_onto_name(onto))) < 0 || + (error = git_checkout_tree( + repo, (git_object *)onto_commit, &checkout_opts)) < 0 || + (error = git_reference_create(&head_ref, repo, GIT_HEAD_FILE, + git_annotated_commit_id(onto), 1, reflog.ptr)) < 0) + goto done; + + *out = rebase; + +done: + git_reference_free(head_ref); + if (error < 0) { + rebase_cleanup(rebase); + git_rebase_free(rebase); + } + + git_commit_free(onto_commit); + git_buf_free(&reflog); + rebase_opts_free(&opts); + + return error; +} + +static void normalize_checkout_opts( + git_rebase *rebase, + git_commit *current_commit, + git_checkout_options *checkout_opts, + const git_checkout_options *given_checkout_opts) +{ + if (given_checkout_opts != NULL) + memcpy(checkout_opts, given_checkout_opts, sizeof(git_checkout_options)); + else { + git_checkout_options default_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; + default_checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; + + memcpy(checkout_opts, &default_checkout_opts, sizeof(git_checkout_options)); + } + + if (!checkout_opts->ancestor_label) + checkout_opts->ancestor_label = "ancestor"; + + if (rebase->type == GIT_REBASE_TYPE_MERGE) { + if (!checkout_opts->our_label) + checkout_opts->our_label = rebase->onto_name; + + if (!checkout_opts->their_label) + checkout_opts->their_label = git_commit_summary(current_commit); + } else { + abort(); + } +} + +GIT_INLINE(int) rebase_movenext(git_rebase *rebase) +{ + size_t next = rebase->started ? rebase->current + 1 : 0; + + if (next == git_array_size(rebase->operations)) + return GIT_ITEROVER; + + rebase->started = 1; + rebase->current = next; + + return 0; +} + +static int rebase_next_merge( + git_rebase_operation **out, + git_rebase *rebase, + git_checkout_options *given_checkout_opts) +{ + git_buf path = GIT_BUF_INIT; + git_checkout_options checkout_opts = {0}; + git_commit *current_commit = NULL, *parent_commit = NULL; + git_tree *current_tree = NULL, *head_tree = NULL, *parent_tree = NULL; + git_index *index = NULL; + git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; + git_rebase_operation *operation; + char current_idstr[GIT_OID_HEXSZ]; + unsigned int parent_count; + int error; + + *out = NULL; + + if ((error = rebase_movenext(rebase)) < 0) + goto done; + + operation = git_array_get(rebase->operations, rebase->current); + + if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || + (error = git_commit_tree(¤t_tree, current_commit)) < 0 || + (error = git_repository_head_tree(&head_tree, rebase->repo)) < 0) + goto done; + + if ((parent_count = git_commit_parentcount(current_commit)) > 1) { + giterr_set(GITERR_REBASE, "Cannot rebase a merge commit"); + error = -1; + goto done; + } else if (parent_count) { + if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 || + (error = git_commit_tree(&parent_tree, parent_commit)) < 0) + goto done; + } + + git_oid_fmt(current_idstr, &operation->id); + + normalize_checkout_opts(rebase, current_commit, &checkout_opts, given_checkout_opts); + + if ((error = git_indexwriter_init_for_operation(&indexwriter, rebase->repo, &checkout_opts.checkout_strategy)) < 0 || + (error = rebase_setupfile(rebase, MSGNUM_FILE, -1, "%d\n", rebase->current+1)) < 0 || + (error = rebase_setupfile(rebase, CURRENT_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, current_idstr)) < 0 || + (error = git_merge_trees(&index, rebase->repo, parent_tree, head_tree, current_tree, NULL)) < 0 || + (error = git_merge__check_result(rebase->repo, index)) < 0 || + (error = git_checkout_index(rebase->repo, index, &checkout_opts)) < 0 || + (error = git_indexwriter_commit(&indexwriter)) < 0) + goto done; + + *out = operation; + +done: + git_indexwriter_cleanup(&indexwriter); + git_index_free(index); + git_tree_free(current_tree); + git_tree_free(head_tree); + git_tree_free(parent_tree); + git_commit_free(parent_commit); + git_commit_free(current_commit); + git_buf_free(&path); + + return error; +} + +int git_rebase_next( + git_rebase_operation **out, + git_rebase *rebase, + git_checkout_options *checkout_opts) +{ + int error; + + assert(out && rebase); + + switch (rebase->type) { + case GIT_REBASE_TYPE_MERGE: + error = rebase_next_merge(out, rebase, checkout_opts); + break; + default: + abort(); + } + + return error; +} + +static int rebase_commit_merge( + git_oid *commit_id, + git_rebase *rebase, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message) +{ + git_index *index = NULL; + git_reference *head = NULL; + git_commit *current_commit = NULL, *head_commit = NULL, *commit = NULL; + git_rebase_operation *operation; + git_tree *head_tree = NULL, *tree = NULL; + git_diff *diff = NULL; + git_oid tree_id; + git_buf reflog_msg = GIT_BUF_INIT; + char old_idstr[GIT_OID_HEXSZ], new_idstr[GIT_OID_HEXSZ]; + int error; + + operation = git_array_get(rebase->operations, rebase->current); + assert(operation); + + if ((error = git_repository_index(&index, rebase->repo)) < 0) + goto done; + + if (git_index_has_conflicts(index)) { + giterr_set(GITERR_REBASE, "Conflicts have not been resolved"); + error = GIT_EMERGECONFLICT; + goto done; + } + + if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || + (error = git_repository_head(&head, rebase->repo)) < 0 || + (error = git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT)) < 0 || + (error = git_commit_tree(&head_tree, head_commit)) < 0 || + (error = git_diff_tree_to_index(&diff, rebase->repo, head_tree, index, NULL)) < 0) + goto done; + + if (git_diff_num_deltas(diff) == 0) { + giterr_set(GITERR_REBASE, "This patch has already been applied"); + error = GIT_EAPPLIED; + goto done; + } + + if ((error = git_index_write_tree(&tree_id, index)) < 0 || + (error = git_tree_lookup(&tree, rebase->repo, &tree_id)) < 0) + goto done; + + if (!author) + author = git_commit_author(current_commit); + + if (!message) { + message_encoding = git_commit_message_encoding(current_commit); + message = git_commit_message(current_commit); + } + + if ((error = git_commit_create(commit_id, rebase->repo, NULL, author, + committer, message_encoding, message, tree, 1, + (const git_commit **)&head_commit)) < 0 || + (error = git_commit_lookup(&commit, rebase->repo, commit_id)) < 0 || + (error = git_reference__update_for_commit( + rebase->repo, NULL, "HEAD", commit_id, "rebase")) < 0) + goto done; + + git_oid_fmt(old_idstr, git_commit_id(current_commit)); + git_oid_fmt(new_idstr, commit_id); + + error = rebase_setupfile(rebase, REWRITTEN_FILE, O_CREAT|O_WRONLY|O_APPEND, + "%.*s %.*s\n", GIT_OID_HEXSZ, old_idstr, GIT_OID_HEXSZ, new_idstr); + +done: + git_buf_free(&reflog_msg); + git_commit_free(commit); + git_diff_free(diff); + git_tree_free(tree); + git_tree_free(head_tree); + git_commit_free(head_commit); + git_commit_free(current_commit); + git_reference_free(head); + git_index_free(index); + + return error; +} + +int git_rebase_commit( + git_oid *id, + git_rebase *rebase, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message) +{ + int error; + + assert(rebase && committer); + + switch (rebase->type) { + case GIT_REBASE_TYPE_MERGE: + error = rebase_commit_merge( + id, rebase, author, committer, message_encoding, message); + break; + default: + abort(); + } + + return error; +} + +int git_rebase_abort(git_rebase *rebase) +{ + git_reference *orig_head_ref = NULL; + git_commit *orig_head_commit = NULL; + int error; + + assert(rebase); + + error = rebase->head_detached ? + git_reference_create(&orig_head_ref, rebase->repo, GIT_HEAD_FILE, + &rebase->orig_head_id, 1, "rebase: aborting") : + git_reference_symbolic_create( + &orig_head_ref, rebase->repo, GIT_HEAD_FILE, rebase->orig_head_name, 1, + "rebase: aborting"); + + if (error < 0) + goto done; + + if ((error = git_commit_lookup( + &orig_head_commit, rebase->repo, &rebase->orig_head_id)) < 0 || + (error = git_reset(rebase->repo, (git_object *)orig_head_commit, + GIT_RESET_HARD, NULL)) < 0) + goto done; + + error = rebase_cleanup(rebase); + +done: + git_commit_free(orig_head_commit); + git_reference_free(orig_head_ref); + + return error; +} + +static int rebase_copy_note( + git_rebase *rebase, + git_oid *from, + git_oid *to, + const git_signature *committer, + const git_rebase_options *opts) +{ + git_note *note = NULL; + git_oid note_id; + git_signature *who = NULL; + int error; + + if ((error = git_note_read(¬e, rebase->repo, opts->rewrite_notes_ref, from)) < 0) { + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + + goto done; + } + + if (!committer) { + if((error = git_signature_default(&who, rebase->repo)) < 0) { + if (error != GIT_ENOTFOUND || + (error = git_signature_now(&who, "unknown", "unknown")) < 0) + goto done; + + giterr_clear(); + } + + committer = who; + } + + error = git_note_create(¬e_id, rebase->repo, opts->rewrite_notes_ref, + git_note_author(note), committer, to, git_note_message(note), 0); + +done: + git_note_free(note); + git_signature_free(who); + + return error; +} + +static int rebase_copy_notes( + git_rebase *rebase, + const git_signature *committer, + const git_rebase_options *opts) +{ + git_buf path = GIT_BUF_INIT, rewritten = GIT_BUF_INIT; + char *pair_list, *fromstr, *tostr, *end; + git_oid from, to; + unsigned int linenum = 1; + int error = 0; + + if (!opts->rewrite_notes_ref) + goto done; + + if ((error = git_buf_joinpath(&path, rebase->state_path, REWRITTEN_FILE)) < 0 || + (error = git_futils_readbuffer(&rewritten, path.ptr)) < 0) + goto done; + + pair_list = rewritten.ptr; + + while (*pair_list) { + fromstr = pair_list; + + if ((end = strchr(fromstr, '\n')) == NULL) + goto on_error; + + pair_list = end+1; + *end = '\0'; + + if ((end = strchr(fromstr, ' ')) == NULL) + goto on_error; + + tostr = end+1; + *end = '\0'; + + if (strlen(fromstr) != GIT_OID_HEXSZ || + strlen(tostr) != GIT_OID_HEXSZ || + git_oid_fromstr(&from, fromstr) < 0 || + git_oid_fromstr(&to, tostr) < 0) + goto on_error; + + if ((error = rebase_copy_note(rebase, &from, &to, committer, opts)) < 0) + goto done; + + linenum++; + } + + goto done; + +on_error: + giterr_set(GITERR_REBASE, "Invalid rewritten file at line %d", linenum); + error = -1; + +done: + git_buf_free(&rewritten); + git_buf_free(&path); + + return error; +} + +int git_rebase_finish( + git_rebase *rebase, + const git_signature *signature, + const git_rebase_options *given_opts) +{ + git_rebase_options opts; + git_reference *terminal_ref = NULL, *branch_ref = NULL, *head_ref = NULL; + git_commit *terminal_commit = NULL; + git_buf branch_msg = GIT_BUF_INIT, head_msg = GIT_BUF_INIT; + char onto[GIT_OID_HEXSZ]; + int error; + + assert(rebase); + + GITERR_CHECK_VERSION(given_opts, GIT_REBASE_OPTIONS_VERSION, "git_rebase_options"); + + if ((error = rebase_normalize_opts(rebase->repo, &opts, given_opts)) < 0) + goto done; + + git_oid_fmt(onto, &rebase->onto_id); + + if ((error = git_buf_printf(&branch_msg, "rebase finished: %s onto %.*s", + rebase->orig_head_name, GIT_OID_HEXSZ, onto)) < 0 || + (error = git_buf_printf(&head_msg, "rebase finished: returning to %s", + rebase->orig_head_name)) < 0 || + (error = git_repository_head(&terminal_ref, rebase->repo)) < 0 || + (error = git_reference_peel((git_object **)&terminal_commit, + terminal_ref, GIT_OBJ_COMMIT)) < 0 || + (error = git_reference_create_matching(&branch_ref, + rebase->repo, rebase->orig_head_name, git_commit_id(terminal_commit), 1, + &rebase->orig_head_id, branch_msg.ptr)) < 0 || + (error = git_reference_symbolic_create(&head_ref, + rebase->repo, GIT_HEAD_FILE, rebase->orig_head_name, 1, + head_msg.ptr)) < 0 || + (error = rebase_copy_notes(rebase, signature, &opts)) < 0) + goto done; + + error = rebase_cleanup(rebase); + +done: + git_buf_free(&head_msg); + git_buf_free(&branch_msg); + git_commit_free(terminal_commit); + git_reference_free(head_ref); + git_reference_free(branch_ref); + git_reference_free(terminal_ref); + rebase_opts_free(&opts); + + return error; +} + +size_t git_rebase_operation_entrycount(git_rebase *rebase) +{ + assert(rebase); + + return git_array_size(rebase->operations); +} + +size_t git_rebase_operation_current(git_rebase *rebase) +{ + assert(rebase); + + return rebase->current; +} + +git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx) +{ + assert(rebase); + + return git_array_get(rebase->operations, idx); +} + +void git_rebase_free(git_rebase *rebase) +{ + if (rebase == NULL) + return; + + git__free(rebase->onto_name); + git__free(rebase->orig_head_name); + git__free(rebase->state_path); + git_array_clear(rebase->operations); + git__free(rebase); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refdb.c b/deps/libgit2-sys-0.2.17/libgit2/src/refdb.c new file mode 100644 index 000000000..16fb519a6 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refdb.c @@ -0,0 +1,263 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "posix.h" + +#include "git2/object.h" +#include "git2/refs.h" +#include "git2/refdb.h" +#include "git2/sys/refdb_backend.h" + +#include "hash.h" +#include "refdb.h" +#include "refs.h" +#include "reflog.h" + +int git_refdb_new(git_refdb **out, git_repository *repo) +{ + git_refdb *db; + + assert(out && repo); + + db = git__calloc(1, sizeof(*db)); + GITERR_CHECK_ALLOC(db); + + db->repo = repo; + + *out = db; + GIT_REFCOUNT_INC(db); + return 0; +} + +int git_refdb_open(git_refdb **out, git_repository *repo) +{ + git_refdb *db; + git_refdb_backend *dir; + + assert(out && repo); + + *out = NULL; + + if (git_refdb_new(&db, repo) < 0) + return -1; + + /* Add the default (filesystem) backend */ + if (git_refdb_backend_fs(&dir, repo) < 0) { + git_refdb_free(db); + return -1; + } + + db->repo = repo; + db->backend = dir; + + *out = db; + return 0; +} + +static void refdb_free_backend(git_refdb *db) +{ + if (db->backend) { + if (db->backend->free) + db->backend->free(db->backend); + else + git__free(db->backend); + } +} + +int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend) +{ + refdb_free_backend(db); + db->backend = backend; + + return 0; +} + +int git_refdb_compress(git_refdb *db) +{ + assert(db); + + if (db->backend->compress) + return db->backend->compress(db->backend); + + return 0; +} + +void git_refdb__free(git_refdb *db) +{ + refdb_free_backend(db); + git__memzero(db, sizeof(*db)); + git__free(db); +} + +void git_refdb_free(git_refdb *db) +{ + if (db == NULL) + return; + + GIT_REFCOUNT_DEC(db, git_refdb__free); +} + +int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name) +{ + assert(exists && refdb && refdb->backend); + + return refdb->backend->exists(exists, refdb->backend, ref_name); +} + +int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name) +{ + git_reference *ref; + int error; + + assert(db && db->backend && out && ref_name); + + error = db->backend->lookup(&ref, db->backend, ref_name); + if (error < 0) + return error; + + GIT_REFCOUNT_INC(db); + ref->db = db; + + *out = ref; + return 0; +} + +int git_refdb_iterator(git_reference_iterator **out, git_refdb *db, const char *glob) +{ + if (!db->backend || !db->backend->iterator) { + giterr_set(GITERR_REFERENCE, "This backend doesn't support iterators"); + return -1; + } + + if (db->backend->iterator(out, db->backend, glob) < 0) + return -1; + + GIT_REFCOUNT_INC(db); + (*out)->db = db; + + return 0; +} + +int git_refdb_iterator_next(git_reference **out, git_reference_iterator *iter) +{ + int error; + + if ((error = iter->next(out, iter)) < 0) + return error; + + GIT_REFCOUNT_INC(iter->db); + (*out)->db = iter->db; + + return 0; +} + +int git_refdb_iterator_next_name(const char **out, git_reference_iterator *iter) +{ + return iter->next_name(out, iter); +} + +void git_refdb_iterator_free(git_reference_iterator *iter) +{ + GIT_REFCOUNT_DEC(iter->db, git_refdb__free); + iter->free(iter); +} + +int git_refdb_write(git_refdb *db, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target) +{ + assert(db && db->backend); + + GIT_REFCOUNT_INC(db); + ref->db = db; + + return db->backend->write(db->backend, ref, force, who, message, old_id, old_target); +} + +int git_refdb_rename( + git_reference **out, + git_refdb *db, + const char *old_name, + const char *new_name, + int force, + const git_signature *who, + const char *message) +{ + int error; + + assert(db && db->backend); + error = db->backend->rename(out, db->backend, old_name, new_name, force, who, message); + if (error < 0) + return error; + + if (out) { + GIT_REFCOUNT_INC(db); + (*out)->db = db; + } + + return 0; +} + +int git_refdb_delete(struct git_refdb *db, const char *ref_name, const git_oid *old_id, const char *old_target) +{ + assert(db && db->backend); + return db->backend->del(db->backend, ref_name, old_id, old_target); +} + +int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name) +{ + int error; + + assert(db && db->backend); + + if ((error = db->backend->reflog_read(out, db->backend, name)) < 0) + return error; + + GIT_REFCOUNT_INC(db); + (*out)->db = db; + + return 0; +} + +int git_refdb_has_log(git_refdb *db, const char *refname) +{ + assert(db && refname); + + return db->backend->has_log(db->backend, refname); +} + +int git_refdb_ensure_log(git_refdb *db, const char *refname) +{ + assert(db && refname); + + return db->backend->ensure_log(db->backend, refname); +} + +int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + backend, version, git_refdb_backend, GIT_REFDB_BACKEND_INIT); + return 0; +} + +int git_refdb_lock(void **payload, git_refdb *db, const char *refname) +{ + assert(payload && db && refname); + + if (!db->backend->lock) { + giterr_set(GITERR_REFERENCE, "backend does not support locking"); + return -1; + } + + return db->backend->lock(payload, db->backend, refname); +} + +int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message) +{ + assert(db); + + return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refdb.h b/deps/libgit2-sys-0.2.17/libgit2/src/refdb.h new file mode 100644 index 000000000..4ee3b8065 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refdb.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_refdb_h__ +#define INCLUDE_refdb_h__ + +#include "git2/refdb.h" +#include "repository.h" + +struct git_refdb { + git_refcount rc; + git_repository *repo; + git_refdb_backend *backend; +}; + +void git_refdb__free(git_refdb *db); + +int git_refdb_exists( + int *exists, + git_refdb *refdb, + const char *ref_name); + +int git_refdb_lookup( + git_reference **out, + git_refdb *refdb, + const char *ref_name); + +int git_refdb_rename( + git_reference **out, + git_refdb *db, + const char *old_name, + const char *new_name, + int force, + const git_signature *who, + const char *message); + +int git_refdb_iterator(git_reference_iterator **out, git_refdb *db, const char *glob); +int git_refdb_iterator_next(git_reference **out, git_reference_iterator *iter); +int git_refdb_iterator_next_name(const char **out, git_reference_iterator *iter); +void git_refdb_iterator_free(git_reference_iterator *iter); + +int git_refdb_write(git_refdb *refdb, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target); +int git_refdb_delete(git_refdb *refdb, const char *ref_name, const git_oid *old_id, const char *old_target); + +int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name); +int git_refdb_reflog_write(git_reflog *reflog); + +int git_refdb_has_log(git_refdb *db, const char *refname); +int git_refdb_ensure_log(git_refdb *refdb, const char *refname); + +int git_refdb_lock(void **payload, git_refdb *db, const char *refname); +int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.c b/deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.c new file mode 100644 index 000000000..e1a77f3ff --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.c @@ -0,0 +1,1957 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "refs.h" +#include "hash.h" +#include "repository.h" +#include "fileops.h" +#include "filebuf.h" +#include "pack.h" +#include "reflog.h" +#include "refdb.h" +#include "refdb_fs.h" +#include "iterator.h" +#include "sortedcache.h" +#include "signature.h" + +#include +#include +#include +#include +#include +#include +#include + +GIT__USE_STRMAP + +#define DEFAULT_NESTING_LEVEL 5 +#define MAX_NESTING_LEVEL 10 + +enum { + PACKREF_HAS_PEEL = 1, + PACKREF_WAS_LOOSE = 2, + PACKREF_CANNOT_PEEL = 4, + PACKREF_SHADOWED = 8, +}; + +enum { + PEELING_NONE = 0, + PEELING_STANDARD, + PEELING_FULL +}; + +struct packref { + git_oid oid; + git_oid peel; + char flags; + char name[GIT_FLEX_ARRAY]; +}; + +typedef struct refdb_fs_backend { + git_refdb_backend parent; + + git_repository *repo; + char *path; + + git_sortedcache *refcache; + int peeling_mode; + git_iterator_flag_t iterator_flags; + uint32_t direach_flags; +} refdb_fs_backend; + +static int packref_cmp(const void *a_, const void *b_) +{ + const struct packref *a = a_, *b = b_; + return strcmp(a->name, b->name); +} + +static int packed_reload(refdb_fs_backend *backend) +{ + int error; + git_buf packedrefs = GIT_BUF_INIT; + char *scan, *eof, *eol; + + if (!backend->path) + return 0; + + error = git_sortedcache_lockandload(backend->refcache, &packedrefs); + + /* + * If we can't find the packed-refs, clear table and return. + * Any other error just gets passed through. + * If no error, and file wasn't changed, just return. + * Anything else means we need to refresh the packed refs. + */ + if (error <= 0) { + if (error == GIT_ENOTFOUND) { + git_sortedcache_clear(backend->refcache, true); + giterr_clear(); + error = 0; + } + return error; + } + + /* At this point, refresh the packed refs from the loaded buffer. */ + + git_sortedcache_clear(backend->refcache, false); + + scan = (char *)packedrefs.ptr; + eof = scan + packedrefs.size; + + backend->peeling_mode = PEELING_NONE; + + if (*scan == '#') { + static const char *traits_header = "# pack-refs with: "; + + if (git__prefixcmp(scan, traits_header) == 0) { + scan += strlen(traits_header); + eol = strchr(scan, '\n'); + + if (!eol) + goto parse_failed; + *eol = '\0'; + + if (strstr(scan, " fully-peeled ") != NULL) { + backend->peeling_mode = PEELING_FULL; + } else if (strstr(scan, " peeled ") != NULL) { + backend->peeling_mode = PEELING_STANDARD; + } + + scan = eol + 1; + } + } + + while (scan < eof && *scan == '#') { + if (!(eol = strchr(scan, '\n'))) + goto parse_failed; + scan = eol + 1; + } + + while (scan < eof) { + struct packref *ref; + git_oid oid; + + /* parse " \n" */ + + if (git_oid_fromstr(&oid, scan) < 0) + goto parse_failed; + scan += GIT_OID_HEXSZ; + + if (*scan++ != ' ') + goto parse_failed; + if (!(eol = strchr(scan, '\n'))) + goto parse_failed; + *eol = '\0'; + if (eol[-1] == '\r') + eol[-1] = '\0'; + + if (git_sortedcache_upsert((void **)&ref, backend->refcache, scan) < 0) + goto parse_failed; + scan = eol + 1; + + git_oid_cpy(&ref->oid, &oid); + + /* look for optional "^\n" */ + + if (*scan == '^') { + if (git_oid_fromstr(&oid, scan + 1) < 0) + goto parse_failed; + scan += GIT_OID_HEXSZ + 1; + + if (scan < eof) { + if (!(eol = strchr(scan, '\n'))) + goto parse_failed; + scan = eol + 1; + } + + git_oid_cpy(&ref->peel, &oid); + ref->flags |= PACKREF_HAS_PEEL; + } + else if (backend->peeling_mode == PEELING_FULL || + (backend->peeling_mode == PEELING_STANDARD && + git__prefixcmp(ref->name, GIT_REFS_TAGS_DIR) == 0)) + ref->flags |= PACKREF_CANNOT_PEEL; + } + + git_sortedcache_wunlock(backend->refcache); + git_buf_free(&packedrefs); + + return 0; + +parse_failed: + giterr_set(GITERR_REFERENCE, "Corrupted packed references file"); + + git_sortedcache_clear(backend->refcache, false); + git_sortedcache_wunlock(backend->refcache); + git_buf_free(&packedrefs); + + return -1; +} + +static int loose_parse_oid( + git_oid *oid, const char *filename, git_buf *file_content) +{ + const char *str = git_buf_cstr(file_content); + + if (git_buf_len(file_content) < GIT_OID_HEXSZ) + goto corrupted; + + /* we need to get 40 OID characters from the file */ + if (git_oid_fromstr(oid, str) < 0) + goto corrupted; + + /* If the file is longer than 40 chars, the 41st must be a space */ + str += GIT_OID_HEXSZ; + if (*str == '\0' || git__isspace(*str)) + return 0; + +corrupted: + giterr_set(GITERR_REFERENCE, "Corrupted loose reference file: %s", filename); + return -1; +} + +static int loose_readbuffer(git_buf *buf, const char *base, const char *path) +{ + int error; + + /* build full path to file */ + if ((error = git_buf_joinpath(buf, base, path)) < 0 || + (error = git_futils_readbuffer(buf, buf->ptr)) < 0) + git_buf_free(buf); + + return error; +} + +static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name) +{ + int error = 0; + git_buf ref_file = GIT_BUF_INIT; + struct packref *ref = NULL; + git_oid oid; + + /* if we fail to load the loose reference, assume someone changed + * the filesystem under us and skip it... + */ + if (loose_readbuffer(&ref_file, backend->path, name) < 0) { + giterr_clear(); + goto done; + } + + /* skip symbolic refs */ + if (!git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF)) + goto done; + + /* parse OID from file */ + if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0) + goto done; + + git_sortedcache_wlock(backend->refcache); + + if (!(error = git_sortedcache_upsert( + (void **)&ref, backend->refcache, name))) { + + git_oid_cpy(&ref->oid, &oid); + ref->flags = PACKREF_WAS_LOOSE; + } + + git_sortedcache_wunlock(backend->refcache); + +done: + git_buf_free(&ref_file); + return error; +} + +static int _dirent_loose_load(void *payload, git_buf *full_path) +{ + refdb_fs_backend *backend = payload; + const char *file_path; + + if (git__suffixcmp(full_path->ptr, ".lock") == 0) + return 0; + + if (git_path_isdir(full_path->ptr)) { + int error = git_path_direach( + full_path, backend->direach_flags, _dirent_loose_load, backend); + /* Race with the filesystem, ignore it */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + return 0; + } + + return error; + } + + file_path = full_path->ptr + strlen(backend->path); + + return loose_lookup_to_packfile(backend, file_path); +} + +/* + * Load all the loose references from the repository + * into the in-memory Packfile, and build a vector with + * all the references so it can be written back to + * disk. + */ +static int packed_loadloose(refdb_fs_backend *backend) +{ + int error; + git_buf refs_path = GIT_BUF_INIT; + + if (git_buf_joinpath(&refs_path, backend->path, GIT_REFS_DIR) < 0) + return -1; + + /* + * Load all the loose files from disk into the Packfile table. + * This will overwrite any old packed entries with their + * updated loose versions + */ + error = git_path_direach( + &refs_path, backend->direach_flags, _dirent_loose_load, backend); + + git_buf_free(&refs_path); + + return error; +} + +static int refdb_fs_backend__exists( + int *exists, + git_refdb_backend *_backend, + const char *ref_name) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + git_buf ref_path = GIT_BUF_INIT; + + assert(backend); + + if (packed_reload(backend) < 0 || + git_buf_joinpath(&ref_path, backend->path, ref_name) < 0) + return -1; + + *exists = git_path_isfile(ref_path.ptr) || + (git_sortedcache_lookup(backend->refcache, ref_name) != NULL); + + git_buf_free(&ref_path); + return 0; +} + +static const char *loose_parse_symbolic(git_buf *file_content) +{ + const unsigned int header_len = (unsigned int)strlen(GIT_SYMREF); + const char *refname_start; + + refname_start = (const char *)file_content->ptr; + + if (git_buf_len(file_content) < header_len + 1) { + giterr_set(GITERR_REFERENCE, "Corrupted loose reference file"); + return NULL; + } + + /* + * Assume we have already checked for the header + * before calling this function + */ + refname_start += header_len; + + return refname_start; +} + +static int loose_lookup( + git_reference **out, + refdb_fs_backend *backend, + const char *ref_name) +{ + git_buf ref_file = GIT_BUF_INIT; + int error = 0; + + if (out) + *out = NULL; + + if ((error = loose_readbuffer(&ref_file, backend->path, ref_name)) < 0) + /* cannot read loose ref file - gah */; + else if (git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF) == 0) { + const char *target; + + git_buf_rtrim(&ref_file); + + if (!(target = loose_parse_symbolic(&ref_file))) + error = -1; + else if (out != NULL) + *out = git_reference__alloc_symbolic(ref_name, target); + } else { + git_oid oid; + + if (!(error = loose_parse_oid(&oid, ref_name, &ref_file)) && + out != NULL) + *out = git_reference__alloc(ref_name, &oid, NULL); + } + + git_buf_free(&ref_file); + return error; +} + +static int ref_error_notfound(const char *name) +{ + giterr_set(GITERR_REFERENCE, "Reference '%s' not found", name); + return GIT_ENOTFOUND; +} + +static int packed_lookup( + git_reference **out, + refdb_fs_backend *backend, + const char *ref_name) +{ + int error = 0; + struct packref *entry; + + if (packed_reload(backend) < 0) + return -1; + + if (git_sortedcache_rlock(backend->refcache) < 0) + return -1; + + entry = git_sortedcache_lookup(backend->refcache, ref_name); + if (!entry) { + error = ref_error_notfound(ref_name); + } else { + *out = git_reference__alloc(ref_name, &entry->oid, &entry->peel); + if (!*out) + error = -1; + } + + git_sortedcache_runlock(backend->refcache); + + return error; +} + +static int refdb_fs_backend__lookup( + git_reference **out, + git_refdb_backend *_backend, + const char *ref_name) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + int error; + + assert(backend); + + if (!(error = loose_lookup(out, backend, ref_name))) + return 0; + + /* only try to lookup this reference on the packfile if it + * wasn't found on the loose refs; not if there was a critical error */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = packed_lookup(out, backend, ref_name); + } + + return error; +} + +typedef struct { + git_reference_iterator parent; + + char *glob; + + git_pool pool; + git_vector loose; + + git_sortedcache *cache; + size_t loose_pos; + size_t packed_pos; +} refdb_fs_iter; + +static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter) +{ + refdb_fs_iter *iter = (refdb_fs_iter *) _iter; + + git_vector_free(&iter->loose); + git_pool_clear(&iter->pool); + git_sortedcache_free(iter->cache); + git__free(iter); +} + +static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter) +{ + int error = 0; + git_buf path = GIT_BUF_INIT; + git_iterator *fsit = NULL; + const git_index_entry *entry = NULL; + + if (!backend->path) /* do nothing if no path for loose refs */ + return 0; + + if ((error = git_buf_printf(&path, "%s/refs", backend->path)) < 0 || + (error = git_iterator_for_filesystem( + &fsit, path.ptr, backend->iterator_flags, NULL, NULL)) < 0) { + git_buf_free(&path); + return error; + } + + error = git_buf_sets(&path, GIT_REFS_DIR); + + while (!error && !git_iterator_advance(&entry, fsit)) { + const char *ref_name; + struct packref *ref; + char *ref_dup; + + git_buf_truncate(&path, strlen(GIT_REFS_DIR)); + git_buf_puts(&path, entry->path); + ref_name = git_buf_cstr(&path); + + if (git__suffixcmp(ref_name, ".lock") == 0 || + (iter->glob && p_fnmatch(iter->glob, ref_name, 0) != 0)) + continue; + + git_sortedcache_rlock(backend->refcache); + ref = git_sortedcache_lookup(backend->refcache, ref_name); + if (ref) + ref->flags |= PACKREF_SHADOWED; + git_sortedcache_runlock(backend->refcache); + + ref_dup = git_pool_strdup(&iter->pool, ref_name); + if (!ref_dup) + error = -1; + else + error = git_vector_insert(&iter->loose, ref_dup); + } + + git_iterator_free(fsit); + git_buf_free(&path); + + return error; +} + +static int refdb_fs_backend__iterator_next( + git_reference **out, git_reference_iterator *_iter) +{ + int error = GIT_ITEROVER; + refdb_fs_iter *iter = (refdb_fs_iter *)_iter; + refdb_fs_backend *backend = (refdb_fs_backend *)iter->parent.db->backend; + struct packref *ref; + + while (iter->loose_pos < iter->loose.length) { + const char *path = git_vector_get(&iter->loose, iter->loose_pos++); + + if (loose_lookup(out, backend, path) == 0) + return 0; + + giterr_clear(); + } + + if (!iter->cache) { + if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0) + return error; + } + + error = GIT_ITEROVER; + while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) { + ref = git_sortedcache_entry(iter->cache, iter->packed_pos++); + if (!ref) /* stop now if another thread deleted refs and we past end */ + break; + + if (ref->flags & PACKREF_SHADOWED) + continue; + if (iter->glob && p_fnmatch(iter->glob, ref->name, 0) != 0) + continue; + + *out = git_reference__alloc(ref->name, &ref->oid, &ref->peel); + error = (*out != NULL) ? 0 : -1; + break; + } + + return error; +} + +static int refdb_fs_backend__iterator_next_name( + const char **out, git_reference_iterator *_iter) +{ + int error = GIT_ITEROVER; + refdb_fs_iter *iter = (refdb_fs_iter *)_iter; + refdb_fs_backend *backend = (refdb_fs_backend *)iter->parent.db->backend; + struct packref *ref; + + while (iter->loose_pos < iter->loose.length) { + const char *path = git_vector_get(&iter->loose, iter->loose_pos++); + + if (loose_lookup(NULL, backend, path) == 0) { + *out = path; + return 0; + } + + giterr_clear(); + } + + if (!iter->cache) { + if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0) + return error; + } + + error = GIT_ITEROVER; + while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) { + ref = git_sortedcache_entry(iter->cache, iter->packed_pos++); + if (!ref) /* stop now if another thread deleted refs and we past end */ + break; + + if (ref->flags & PACKREF_SHADOWED) + continue; + if (iter->glob && p_fnmatch(iter->glob, ref->name, 0) != 0) + continue; + + *out = ref->name; + error = 0; + break; + } + + return error; +} + +static int refdb_fs_backend__iterator( + git_reference_iterator **out, git_refdb_backend *_backend, const char *glob) +{ + refdb_fs_iter *iter; + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + + assert(backend); + + if (packed_reload(backend) < 0) + return -1; + + iter = git__calloc(1, sizeof(refdb_fs_iter)); + GITERR_CHECK_ALLOC(iter); + + if (git_pool_init(&iter->pool, 1, 0) < 0 || + git_vector_init(&iter->loose, 8, NULL) < 0) + goto fail; + + if (glob != NULL && + (iter->glob = git_pool_strdup(&iter->pool, glob)) == NULL) + goto fail; + + iter->parent.next = refdb_fs_backend__iterator_next; + iter->parent.next_name = refdb_fs_backend__iterator_next_name; + iter->parent.free = refdb_fs_backend__iterator_free; + + if (iter_load_loose_paths(backend, iter) < 0) + goto fail; + + *out = (git_reference_iterator *)iter; + return 0; + +fail: + refdb_fs_backend__iterator_free((git_reference_iterator *)iter); + return -1; +} + +static bool ref_is_available( + const char *old_ref, const char *new_ref, const char *this_ref) +{ + if (old_ref == NULL || strcmp(old_ref, this_ref)) { + size_t reflen = strlen(this_ref); + size_t newlen = strlen(new_ref); + size_t cmplen = reflen < newlen ? reflen : newlen; + const char *lead = reflen < newlen ? new_ref : this_ref; + + if (!strncmp(new_ref, this_ref, cmplen) && lead[cmplen] == '/') { + return false; + } + } + + return true; +} + +static int reference_path_available( + refdb_fs_backend *backend, + const char *new_ref, + const char* old_ref, + int force) +{ + size_t i; + + if (packed_reload(backend) < 0) + return -1; + + if (!force) { + int exists; + + if (refdb_fs_backend__exists( + &exists, (git_refdb_backend *)backend, new_ref) < 0) + return -1; + + if (exists) { + giterr_set(GITERR_REFERENCE, + "Failed to write reference '%s': a reference with " + "that name already exists.", new_ref); + return GIT_EEXISTS; + } + } + + git_sortedcache_rlock(backend->refcache); + + for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) { + struct packref *ref = git_sortedcache_entry(backend->refcache, i); + + if (ref && !ref_is_available(old_ref, new_ref, ref->name)) { + git_sortedcache_runlock(backend->refcache); + giterr_set(GITERR_REFERENCE, + "Path to reference '%s' collides with existing one", new_ref); + return -1; + } + } + + git_sortedcache_runlock(backend->refcache); + return 0; +} + +static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *name) +{ + int error; + git_buf ref_path = GIT_BUF_INIT; + + assert(file && backend && name); + + if (!git_path_isvalid(backend->repo, name, GIT_PATH_REJECT_DEFAULTS)) { + giterr_set(GITERR_INVALID, "Invalid reference name '%s'.", name); + return GIT_EINVALIDSPEC; + } + + /* Remove a possibly existing empty directory hierarchy + * which name would collide with the reference name + */ + if (git_futils_rmdir_r(name, backend->path, GIT_RMDIR_SKIP_NONEMPTY) < 0) + return -1; + + if (git_buf_joinpath(&ref_path, backend->path, name) < 0) + return -1; + + error = git_filebuf_open(file, ref_path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE); + + git_buf_free(&ref_path); + return error; +} + +static int loose_commit(git_filebuf *file, const git_reference *ref) +{ + assert(file && ref); + + if (ref->type == GIT_REF_OID) { + char oid[GIT_OID_HEXSZ + 1]; + git_oid_nfmt(oid, sizeof(oid), &ref->target.oid); + + git_filebuf_printf(file, "%s\n", oid); + } else if (ref->type == GIT_REF_SYMBOLIC) { + git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic); + } else { + assert(0); /* don't let this happen */ + } + + return git_filebuf_commit(file); +} + +static int refdb_fs_backend__lock(void **out, git_refdb_backend *_backend, const char *refname) +{ + int error; + git_filebuf *lock; + refdb_fs_backend *backend = (refdb_fs_backend *) _backend; + + lock = git__calloc(1, sizeof(git_filebuf)); + GITERR_CHECK_ALLOC(lock); + + if ((error = loose_lock(lock, backend, refname)) < 0) { + git__free(lock); + return error; + } + + *out = lock; + return 0; +} + +static int refdb_fs_backend__write_tail( + git_refdb_backend *_backend, + const git_reference *ref, + git_filebuf *file, + int update_reflog, + const git_signature *who, + const char *message, + const git_oid *old_id, + const char *old_target); + +static int refdb_fs_backend__delete_tail( + git_refdb_backend *_backend, + git_filebuf *file, + const char *ref_name, + const git_oid *old_id, const char *old_target); + +static int refdb_fs_backend__unlock(git_refdb_backend *backend, void *payload, int success, int update_reflog, + const git_reference *ref, const git_signature *sig, const char *message) +{ + git_filebuf *lock = (git_filebuf *) payload; + int error = 0; + + if (success == 2) + error = refdb_fs_backend__delete_tail(backend, lock, ref->name, NULL, NULL); + else if (success) + error = refdb_fs_backend__write_tail(backend, ref, lock, update_reflog, sig, message, NULL, NULL); + else + git_filebuf_cleanup(lock); + + git__free(lock); + return error; +} + +/* + * Find out what object this reference resolves to. + * + * For references that point to a 'big' tag (e.g. an + * actual tag object on the repository), we need to + * cache on the packfile the OID of the object to + * which that 'big tag' is pointing to. + */ +static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref) +{ + git_object *object; + + if (ref->flags & PACKREF_HAS_PEEL || ref->flags & PACKREF_CANNOT_PEEL) + return 0; + + /* + * Find the tagged object in the repository + */ + if (git_object_lookup(&object, backend->repo, &ref->oid, GIT_OBJ_ANY) < 0) + return -1; + + /* + * If the tagged object is a Tag object, we need to resolve it; + * if the ref is actually a 'weak' ref, we don't need to resolve + * anything. + */ + if (git_object_type(object) == GIT_OBJ_TAG) { + git_tag *tag = (git_tag *)object; + + /* + * Find the object pointed at by this tag + */ + git_oid_cpy(&ref->peel, git_tag_target_id(tag)); + ref->flags |= PACKREF_HAS_PEEL; + + /* + * The reference has now cached the resolved OID, and is + * marked at such. When written to the packfile, it'll be + * accompanied by this resolved oid + */ + } + + git_object_free(object); + return 0; +} + +/* + * Write a single reference into a packfile + */ +static int packed_write_ref(struct packref *ref, git_filebuf *file) +{ + char oid[GIT_OID_HEXSZ + 1]; + git_oid_nfmt(oid, sizeof(oid), &ref->oid); + + /* + * For references that peel to an object in the repo, we must + * write the resulting peel on a separate line, e.g. + * + * 6fa8a902cc1d18527e1355773c86721945475d37 refs/tags/libgit2-0.4 + * ^2ec0cb7959b0bf965d54f95453f5b4b34e8d3100 + * + * This obviously only applies to tags. + * The required peels have already been loaded into `ref->peel_target`. + */ + if (ref->flags & PACKREF_HAS_PEEL) { + char peel[GIT_OID_HEXSZ + 1]; + git_oid_nfmt(peel, sizeof(peel), &ref->peel); + + if (git_filebuf_printf(file, "%s %s\n^%s\n", oid, ref->name, peel) < 0) + return -1; + } else { + if (git_filebuf_printf(file, "%s %s\n", oid, ref->name) < 0) + return -1; + } + + return 0; +} + +/* + * Remove all loose references + * + * Once we have successfully written a packfile, + * all the loose references that were packed must be + * removed from disk. + * + * This is a dangerous method; make sure the packfile + * is well-written, because we are destructing references + * here otherwise. + */ +static int packed_remove_loose(refdb_fs_backend *backend) +{ + size_t i; + git_buf full_path = GIT_BUF_INIT; + int failed = 0; + + /* backend->refcache is already locked when this is called */ + + for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) { + struct packref *ref = git_sortedcache_entry(backend->refcache, i); + + if (!ref || !(ref->flags & PACKREF_WAS_LOOSE)) + continue; + + if (git_buf_joinpath(&full_path, backend->path, ref->name) < 0) + return -1; /* critical; do not try to recover on oom */ + + if (git_path_exists(full_path.ptr) && p_unlink(full_path.ptr) < 0) { + if (failed) + continue; + + giterr_set(GITERR_REFERENCE, + "Failed to remove loose reference '%s' after packing: %s", + full_path.ptr, strerror(errno)); + failed = 1; + } + + /* + * if we fail to remove a single file, this is *not* good, + * but we should keep going and remove as many as possible. + * After we've removed as many files as possible, we return + * the error code anyway. + */ + } + + git_buf_free(&full_path); + return failed ? -1 : 0; +} + +/* + * Write all the contents in the in-memory packfile to disk. + */ +static int packed_write(refdb_fs_backend *backend) +{ + git_sortedcache *refcache = backend->refcache; + git_filebuf pack_file = GIT_FILEBUF_INIT; + size_t i; + + /* lock the cache to updates while we do this */ + if (git_sortedcache_wlock(refcache) < 0) + return -1; + + /* Open the file! */ + if (git_filebuf_open(&pack_file, git_sortedcache_path(refcache), 0, GIT_PACKEDREFS_FILE_MODE) < 0) + goto fail; + + /* Packfiles have a header... apparently + * This is in fact not required, but we might as well print it + * just for kicks */ + if (git_filebuf_printf(&pack_file, "%s\n", GIT_PACKEDREFS_HEADER) < 0) + goto fail; + + for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) { + struct packref *ref = git_sortedcache_entry(refcache, i); + + if (packed_find_peel(backend, ref) < 0) + goto fail; + + if (packed_write_ref(ref, &pack_file) < 0) + goto fail; + } + + /* if we've written all the references properly, we can commit + * the packfile to make the changes effective */ + if (git_filebuf_commit(&pack_file) < 0) + goto fail; + + /* when and only when the packfile has been properly written, + * we can go ahead and remove the loose refs */ + if (packed_remove_loose(backend) < 0) + goto fail; + + git_sortedcache_updated(refcache); + git_sortedcache_wunlock(refcache); + + /* we're good now */ + return 0; + +fail: + git_filebuf_cleanup(&pack_file); + git_sortedcache_wunlock(refcache); + + return -1; +} + +static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message); +static int has_reflog(git_repository *repo, const char *name); + +/* We only write if it's under heads/, remotes/ or notes/ or if it already has a log */ +static int should_write_reflog(int *write, git_repository *repo, const char *name) +{ + int error, logall; + + error = git_repository__cvar(&logall, repo, GIT_CVAR_LOGALLREFUPDATES); + if (error < 0) + return error; + + /* Defaults to the opposite of the repo being bare */ + if (logall == GIT_LOGALLREFUPDATES_UNSET) + logall = !git_repository_is_bare(repo); + + if (!logall) { + *write = 0; + } else if (has_reflog(repo, name)) { + *write = 1; + } else if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR) || + !git__strcmp(name, GIT_HEAD_FILE) || + !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) || + !git__prefixcmp(name, GIT_REFS_NOTES_DIR)) { + *write = 1; + } else { + *write = 0; + } + + return 0; +} + +static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name, + const git_oid *old_id, const char *old_target) +{ + int error = 0; + git_reference *old_ref = NULL; + + *cmp = 0; + /* It "matches" if there is no old value to compare against */ + if (!old_id && !old_target) + return 0; + + if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) + goto out; + + /* If the types don't match, there's no way the values do */ + if (old_id && old_ref->type != GIT_REF_OID) { + *cmp = -1; + goto out; + } + if (old_target && old_ref->type != GIT_REF_SYMBOLIC) { + *cmp = 1; + goto out; + } + + if (old_id && old_ref->type == GIT_REF_OID) + *cmp = git_oid_cmp(old_id, &old_ref->target.oid); + + if (old_target && old_ref->type == GIT_REF_SYMBOLIC) + *cmp = git__strcmp(old_target, old_ref->target.symbolic); + +out: + git_reference_free(old_ref); + + return error; +} + +/* + * The git.git comment regarding this, for your viewing pleasure: + * + * Special hack: If a branch is updated directly and HEAD + * points to it (may happen on the remote side of a push + * for example) then logically the HEAD reflog should be + * updated too. + * A generic solution implies reverse symref information, + * but finding all symrefs pointing to the given branch + * would be rather costly for this rare event (the direct + * update of a branch) to be worth it. So let's cheat and + * check with HEAD only which should cover 99% of all usage + * scenarios (even 100% of the default ones). + */ +static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message) +{ + int error; + git_oid old_id = {{0}}; + git_reference *tmp = NULL, *head = NULL, *peeled = NULL; + const char *name; + + if (ref->type == GIT_REF_SYMBOLIC) + return 0; + + /* if we can't resolve, we use {0}*40 as old id */ + git_reference_name_to_id(&old_id, backend->repo, ref->name); + + if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0) + return error; + + if (git_reference_type(head) == GIT_REF_OID) + goto cleanup; + + if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0) + goto cleanup; + + /* Go down the symref chain until we find the branch */ + while (git_reference_type(tmp) == GIT_REF_SYMBOLIC) { + error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp)); + if (error < 0) + break; + + git_reference_free(tmp); + tmp = peeled; + } + + if (error == GIT_ENOTFOUND) { + error = 0; + name = git_reference_symbolic_target(tmp); + } else if (error < 0) { + goto cleanup; + } else { + name = git_reference_name(tmp); + } + + if (strcmp(name, ref->name)) + goto cleanup; + + error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message); + +cleanup: + git_reference_free(tmp); + git_reference_free(head); + return error; +} + +static int refdb_fs_backend__write( + git_refdb_backend *_backend, + const git_reference *ref, + int force, + const git_signature *who, + const char *message, + const git_oid *old_id, + const char *old_target) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + git_filebuf file = GIT_FILEBUF_INIT; + int error = 0; + + assert(backend); + + error = reference_path_available(backend, ref->name, NULL, force); + if (error < 0) + return error; + + /* We need to perform the reflog append and old value check under the ref's lock */ + if ((error = loose_lock(&file, backend, ref->name)) < 0) + return error; + + return refdb_fs_backend__write_tail(_backend, ref, &file, true, who, message, old_id, old_target); +} + +static int refdb_fs_backend__write_tail( + git_refdb_backend *_backend, + const git_reference *ref, + git_filebuf *file, + int update_reflog, + const git_signature *who, + const char *message, + const git_oid *old_id, + const char *old_target) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + int error = 0, cmp = 0, should_write; + const char *new_target = NULL; + const git_oid *new_id = NULL; + + if ((error = cmp_old_ref(&cmp, _backend, ref->name, old_id, old_target)) < 0) + goto on_error; + + if (cmp) { + giterr_set(GITERR_REFERENCE, "old reference value does not match"); + error = GIT_EMODIFIED; + goto on_error; + } + + if (ref->type == GIT_REF_SYMBOLIC) + new_target = ref->target.symbolic; + else + new_id = &ref->target.oid; + + error = cmp_old_ref(&cmp, _backend, ref->name, new_id, new_target); + if (error < 0 && error != GIT_ENOTFOUND) + goto on_error; + + /* Don't update if we have the same value */ + if (!error && !cmp) { + error = 0; + goto on_error; /* not really error */ + } + + if (update_reflog) { + if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0) + goto on_error; + + if (should_write) { + if ((error = reflog_append(backend, ref, NULL, NULL, who, message)) < 0) + goto on_error; + if ((error = maybe_append_head(backend, ref, who, message)) < 0) + goto on_error; + } + } + + return loose_commit(file, ref); + +on_error: + git_filebuf_cleanup(file); + return error; +} + +static int refdb_fs_backend__delete( + git_refdb_backend *_backend, + const char *ref_name, + const git_oid *old_id, const char *old_target) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + git_filebuf file = GIT_FILEBUF_INIT; + int error = 0; + + assert(backend && ref_name); + + if ((error = loose_lock(&file, backend, ref_name)) < 0) + return error; + + return refdb_fs_backend__delete_tail(_backend, &file, ref_name, old_id, old_target); +} + +static int refdb_fs_backend__delete_tail( + git_refdb_backend *_backend, + git_filebuf *file, + const char *ref_name, + const git_oid *old_id, const char *old_target) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + git_buf loose_path = GIT_BUF_INIT; + size_t pack_pos; + int error = 0, cmp = 0; + bool loose_deleted = 0; + + error = cmp_old_ref(&cmp, _backend, ref_name, old_id, old_target); + if (error < 0) + goto cleanup; + + if (cmp) { + giterr_set(GITERR_REFERENCE, "old reference value does not match"); + error = GIT_EMODIFIED; + goto cleanup; + } + + /* If a loose reference exists, remove it from the filesystem */ + if (git_buf_joinpath(&loose_path, backend->path, ref_name) < 0) + return -1; + + if (git_path_isfile(loose_path.ptr)) { + error = p_unlink(loose_path.ptr); + loose_deleted = 1; + } + + git_buf_free(&loose_path); + + if (error != 0) + goto cleanup; + + if ((error = packed_reload(backend)) < 0) + goto cleanup; + + /* If a packed reference exists, remove it from the packfile and repack */ + if ((error = git_sortedcache_wlock(backend->refcache)) < 0) + goto cleanup; + + if (!(error = git_sortedcache_lookup_index( + &pack_pos, backend->refcache, ref_name))) + error = git_sortedcache_remove(backend->refcache, pack_pos); + + git_sortedcache_wunlock(backend->refcache); + + if (error == GIT_ENOTFOUND) { + error = loose_deleted ? 0 : ref_error_notfound(ref_name); + goto cleanup; + } + + error = packed_write(backend); + +cleanup: + git_filebuf_cleanup(file); + + return error; +} + +static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name); + +static int refdb_fs_backend__rename( + git_reference **out, + git_refdb_backend *_backend, + const char *old_name, + const char *new_name, + int force, + const git_signature *who, + const char *message) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + git_reference *old, *new; + git_filebuf file = GIT_FILEBUF_INIT; + int error; + + assert(backend); + + if ((error = reference_path_available( + backend, new_name, old_name, force)) < 0 || + (error = refdb_fs_backend__lookup(&old, _backend, old_name)) < 0) + return error; + + if ((error = refdb_fs_backend__delete(_backend, old_name, NULL, NULL)) < 0) { + git_reference_free(old); + return error; + } + + new = git_reference__set_name(old, new_name); + if (!new) { + git_reference_free(old); + return -1; + } + + if ((error = loose_lock(&file, backend, new->name)) < 0) { + git_reference_free(new); + return error; + } + + /* Try to rename the refog; it's ok if the old doesn't exist */ + error = refdb_reflog_fs__rename(_backend, old_name, new_name); + if (((error == 0) || (error == GIT_ENOTFOUND)) && + ((error = reflog_append(backend, new, git_reference_target(new), NULL, who, message)) < 0)) { + git_reference_free(new); + git_filebuf_cleanup(&file); + return error; + } + + if (error < 0) { + git_reference_free(new); + git_filebuf_cleanup(&file); + return error; + } + + + if ((error = loose_commit(&file, new)) < 0 || out == NULL) { + git_reference_free(new); + return error; + } + + *out = new; + return 0; +} + +static int refdb_fs_backend__compress(git_refdb_backend *_backend) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + + assert(backend); + + if (packed_reload(backend) < 0 || /* load the existing packfile */ + packed_loadloose(backend) < 0 || /* add all the loose refs */ + packed_write(backend) < 0) /* write back to disk */ + return -1; + + return 0; +} + +static void refdb_fs_backend__free(git_refdb_backend *_backend) +{ + refdb_fs_backend *backend = (refdb_fs_backend *)_backend; + + assert(backend); + + git_sortedcache_free(backend->refcache); + git__free(backend->path); + git__free(backend); +} + +static int setup_namespace(git_buf *path, git_repository *repo) +{ + char *parts, *start, *end; + + /* Not all repositories have a path */ + if (repo->path_repository == NULL) + return 0; + + /* Load the path to the repo first */ + git_buf_puts(path, repo->path_repository); + + /* if the repo is not namespaced, nothing else to do */ + if (repo->namespace == NULL) + return 0; + + parts = end = git__strdup(repo->namespace); + if (parts == NULL) + return -1; + + /* + * From `man gitnamespaces`: + * namespaces which include a / will expand to a hierarchy + * of namespaces; for example, GIT_NAMESPACE=foo/bar will store + * refs under refs/namespaces/foo/refs/namespaces/bar/ + */ + while ((start = git__strsep(&end, "/")) != NULL) { + git_buf_printf(path, "refs/namespaces/%s/", start); + } + + git_buf_printf(path, "refs/namespaces/%s/refs", end); + git__free(parts); + + /* Make sure that the folder with the namespace exists */ + if (git_futils_mkdir_r(git_buf_cstr(path), repo->path_repository, 0777) < 0) + return -1; + + /* Return root of the namespaced path, i.e. without the trailing '/refs' */ + git_buf_rtruncate_at_char(path, '/'); + return 0; +} + +static int reflog_alloc(git_reflog **reflog, const char *name) +{ + git_reflog *log; + + *reflog = NULL; + + log = git__calloc(1, sizeof(git_reflog)); + GITERR_CHECK_ALLOC(log); + + log->ref_name = git__strdup(name); + GITERR_CHECK_ALLOC(log->ref_name); + + if (git_vector_init(&log->entries, 0, NULL) < 0) { + git__free(log->ref_name); + git__free(log); + return -1; + } + + *reflog = log; + + return 0; +} + +static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) +{ + const char *ptr; + git_reflog_entry *entry; + +#define seek_forward(_increase) do { \ + if (_increase >= buf_size) { \ + giterr_set(GITERR_INVALID, "Ran out of data while parsing reflog"); \ + goto fail; \ + } \ + buf += _increase; \ + buf_size -= _increase; \ + } while (0) + + while (buf_size > GIT_REFLOG_SIZE_MIN) { + entry = git__calloc(1, sizeof(git_reflog_entry)); + GITERR_CHECK_ALLOC(entry); + + entry->committer = git__malloc(sizeof(git_signature)); + GITERR_CHECK_ALLOC(entry->committer); + + if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0) + goto fail; + seek_forward(GIT_OID_HEXSZ + 1); + + if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < 0) + goto fail; + seek_forward(GIT_OID_HEXSZ + 1); + + ptr = buf; + + /* Seek forward to the end of the signature. */ + while (*buf && *buf != '\t' && *buf != '\n') + seek_forward(1); + + if (git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf) < 0) + goto fail; + + if (*buf == '\t') { + /* We got a message. Read everything till we reach LF. */ + seek_forward(1); + ptr = buf; + + while (*buf && *buf != '\n') + seek_forward(1); + + entry->msg = git__strndup(ptr, buf - ptr); + GITERR_CHECK_ALLOC(entry->msg); + } else + entry->msg = NULL; + + while (*buf && *buf == '\n' && buf_size > 1) + seek_forward(1); + + if (git_vector_insert(&log->entries, entry) < 0) + goto fail; + } + + return 0; + +#undef seek_forward + +fail: + if (entry) + git_reflog_entry__free(entry); + + return -1; +} + +static int create_new_reflog_file(const char *filepath) +{ + int fd, error; + + if ((error = git_futils_mkpath2file(filepath, GIT_REFLOG_DIR_MODE)) < 0) + return error; + + if ((fd = p_open(filepath, + O_WRONLY | O_CREAT, + GIT_REFLOG_FILE_MODE)) < 0) + return -1; + + return p_close(fd); +} + +GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name) +{ + return git_buf_join3(path, '/', repo->path_repository, GIT_REFLOG_DIR, name); +} + +static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name) +{ + refdb_fs_backend *backend; + git_repository *repo; + git_buf path = GIT_BUF_INIT; + int error; + + assert(_backend && name); + + backend = (refdb_fs_backend *) _backend; + repo = backend->repo; + + if ((error = retrieve_reflog_path(&path, repo, name)) < 0) + return error; + + error = create_new_reflog_file(git_buf_cstr(&path)); + git_buf_free(&path); + + return error; +} + +static int has_reflog(git_repository *repo, const char *name) +{ + int ret = 0; + git_buf path = GIT_BUF_INIT; + + if (retrieve_reflog_path(&path, repo, name) < 0) + goto cleanup; + + ret = git_path_isfile(git_buf_cstr(&path)); + +cleanup: + git_buf_free(&path); + return ret; +} + +static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *name) +{ + refdb_fs_backend *backend; + + assert(_backend && name); + + backend = (refdb_fs_backend *) _backend; + + return has_reflog(backend->repo, name); +} + +static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend, const char *name) +{ + int error = -1; + git_buf log_path = GIT_BUF_INIT; + git_buf log_file = GIT_BUF_INIT; + git_reflog *log = NULL; + git_repository *repo; + refdb_fs_backend *backend; + + assert(out && _backend && name); + + backend = (refdb_fs_backend *) _backend; + repo = backend->repo; + + if (reflog_alloc(&log, name) < 0) + return -1; + + if (retrieve_reflog_path(&log_path, repo, name) < 0) + goto cleanup; + + error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path)); + if (error < 0 && error != GIT_ENOTFOUND) + goto cleanup; + + if ((error == GIT_ENOTFOUND) && + ((error = create_new_reflog_file(git_buf_cstr(&log_path))) < 0)) + goto cleanup; + + if ((error = reflog_parse(log, + git_buf_cstr(&log_file), git_buf_len(&log_file))) < 0) + goto cleanup; + + *out = log; + goto success; + +cleanup: + git_reflog_free(log); + +success: + git_buf_free(&log_file); + git_buf_free(&log_path); + + return error; +} + +static int serialize_reflog_entry( + git_buf *buf, + const git_oid *oid_old, + const git_oid *oid_new, + const git_signature *committer, + const char *msg) +{ + char raw_old[GIT_OID_HEXSZ+1]; + char raw_new[GIT_OID_HEXSZ+1]; + + git_oid_tostr(raw_old, GIT_OID_HEXSZ+1, oid_old); + git_oid_tostr(raw_new, GIT_OID_HEXSZ+1, oid_new); + + git_buf_clear(buf); + + git_buf_puts(buf, raw_old); + git_buf_putc(buf, ' '); + git_buf_puts(buf, raw_new); + + git_signature__writebuf(buf, " ", committer); + + /* drop trailing LF */ + git_buf_rtrim(buf); + + if (msg) { + git_buf_putc(buf, '\t'); + git_buf_puts(buf, msg); + } + + git_buf_putc(buf, '\n'); + + return git_buf_oom(buf); +} + +static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char *refname) +{ + git_repository *repo; + git_buf log_path = GIT_BUF_INIT; + int error; + + repo = backend->repo; + + if (!git_path_isvalid(backend->repo, refname, GIT_PATH_REJECT_DEFAULTS)) { + giterr_set(GITERR_INVALID, "Invalid reference name '%s'.", refname); + return GIT_EINVALIDSPEC; + } + + if (retrieve_reflog_path(&log_path, repo, refname) < 0) + return -1; + + if (!git_path_isfile(git_buf_cstr(&log_path))) { + giterr_set(GITERR_INVALID, + "Log file for reference '%s' doesn't exist.", refname); + error = -1; + goto cleanup; + } + + error = git_filebuf_open(file, git_buf_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE); + +cleanup: + git_buf_free(&log_path); + + return error; +} + +static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflog) +{ + int error = -1; + unsigned int i; + git_reflog_entry *entry; + refdb_fs_backend *backend; + git_buf log = GIT_BUF_INIT; + git_filebuf fbuf = GIT_FILEBUF_INIT; + + assert(_backend && reflog); + + backend = (refdb_fs_backend *) _backend; + + if ((error = lock_reflog(&fbuf, backend, reflog->ref_name)) < 0) + return -1; + + git_vector_foreach(&reflog->entries, i, entry) { + if (serialize_reflog_entry(&log, &(entry->oid_old), &(entry->oid_cur), entry->committer, entry->msg) < 0) + goto cleanup; + + if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0) + goto cleanup; + } + + error = git_filebuf_commit(&fbuf); + goto success; + +cleanup: + git_filebuf_cleanup(&fbuf); + +success: + git_buf_free(&log); + + return error; +} + +/* Append to the reflog, must be called under reference lock */ +static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *who, const char *message) +{ + int error, is_symbolic; + git_oid old_id = {{0}}, new_id = {{0}}; + git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT; + git_repository *repo = backend->repo; + + is_symbolic = ref->type == GIT_REF_SYMBOLIC; + + /* "normal" symbolic updates do not write */ + if (is_symbolic && + strcmp(ref->name, GIT_HEAD_FILE) && + !(old && new)) + return 0; + + /* From here on is_symoblic also means that it's HEAD */ + + if (old) { + git_oid_cpy(&old_id, old); + } else { + error = git_reference_name_to_id(&old_id, repo, ref->name); + if (error < 0 && error != GIT_ENOTFOUND) + return error; + } + + if (new) { + git_oid_cpy(&new_id, new); + } else { + if (!is_symbolic) { + git_oid_cpy(&new_id, git_reference_target(ref)); + } else { + error = git_reference_name_to_id(&new_id, repo, git_reference_symbolic_target(ref)); + if (error < 0 && error != GIT_ENOTFOUND) + return error; + /* detaching HEAD does not create an entry */ + if (error == GIT_ENOTFOUND) + return 0; + + giterr_clear(); + } + } + + if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0) + goto cleanup; + + if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0) + goto cleanup; + + if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) && + (error != GIT_EEXISTS)) { + goto cleanup; + } + + /* If the new branch matches part of the namespace of a previously deleted branch, + * there maybe an obsolete/unused directory (or directory hierarchy) in the way. + */ + if (git_path_isdir(git_buf_cstr(&path)) && + (git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) { + error = -1; + goto cleanup; + } + + error = git_futils_writebuffer(&buf, git_buf_cstr(&path), O_WRONLY|O_CREAT|O_APPEND, GIT_REFLOG_FILE_MODE); + +cleanup: + git_buf_free(&buf); + git_buf_free(&path); + + return error; +} + +static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name) +{ + int error = 0, fd; + git_buf old_path = GIT_BUF_INIT; + git_buf new_path = GIT_BUF_INIT; + git_buf temp_path = GIT_BUF_INIT; + git_buf normalized = GIT_BUF_INIT; + git_repository *repo; + refdb_fs_backend *backend; + + assert(_backend && old_name && new_name); + + backend = (refdb_fs_backend *) _backend; + repo = backend->repo; + + if ((error = git_reference__normalize_name( + &normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0) + return error; + + if (git_buf_joinpath(&temp_path, repo->path_repository, GIT_REFLOG_DIR) < 0) + return -1; + + if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0) + return -1; + + if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0) + return -1; + + if (!git_path_exists(git_buf_cstr(&old_path))) { + error = GIT_ENOTFOUND; + goto cleanup; + } + + /* + * Move the reflog to a temporary place. This two-phase renaming is required + * in order to cope with funny renaming use cases when one tries to move a reference + * to a partially colliding namespace: + * - a/b -> a/b/c + * - a/b/c/d -> a/b/c + */ + if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0) + return -1; + + if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) { + error = -1; + goto cleanup; + } + + p_close(fd); + + if (p_rename(git_buf_cstr(&old_path), git_buf_cstr(&temp_path)) < 0) { + giterr_set(GITERR_OS, "Failed to rename reflog for %s", new_name); + error = -1; + goto cleanup; + } + + if (git_path_isdir(git_buf_cstr(&new_path)) && + (git_futils_rmdir_r(git_buf_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) { + error = -1; + goto cleanup; + } + + if (git_futils_mkpath2file(git_buf_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) { + error = -1; + goto cleanup; + } + + if (p_rename(git_buf_cstr(&temp_path), git_buf_cstr(&new_path)) < 0) { + giterr_set(GITERR_OS, "Failed to rename reflog for %s", new_name); + error = -1; + } + +cleanup: + git_buf_free(&temp_path); + git_buf_free(&old_path); + git_buf_free(&new_path); + git_buf_free(&normalized); + + return error; +} + +static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name) +{ + int error; + git_buf path = GIT_BUF_INIT; + + git_repository *repo; + refdb_fs_backend *backend; + + assert(_backend && name); + + backend = (refdb_fs_backend *) _backend; + repo = backend->repo; + + error = retrieve_reflog_path(&path, repo, name); + + if (!error && git_path_exists(path.ptr)) + error = p_unlink(path.ptr); + + git_buf_free(&path); + + return error; + +} + +int git_refdb_backend_fs( + git_refdb_backend **backend_out, + git_repository *repository) +{ + int t = 0; + git_buf path = GIT_BUF_INIT; + refdb_fs_backend *backend; + + backend = git__calloc(1, sizeof(refdb_fs_backend)); + GITERR_CHECK_ALLOC(backend); + + backend->repo = repository; + + if (setup_namespace(&path, repository) < 0) + goto fail; + + backend->path = git_buf_detach(&path); + + if (git_buf_joinpath(&path, backend->path, GIT_PACKEDREFS_FILE) < 0 || + git_sortedcache_new( + &backend->refcache, offsetof(struct packref, name), + NULL, NULL, packref_cmp, git_buf_cstr(&path)) < 0) + goto fail; + + git_buf_free(&path); + + if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) { + backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE; + backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE; + } + if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t) { + backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; + backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE; + } + + backend->parent.exists = &refdb_fs_backend__exists; + backend->parent.lookup = &refdb_fs_backend__lookup; + backend->parent.iterator = &refdb_fs_backend__iterator; + backend->parent.write = &refdb_fs_backend__write; + backend->parent.del = &refdb_fs_backend__delete; + backend->parent.rename = &refdb_fs_backend__rename; + backend->parent.compress = &refdb_fs_backend__compress; + backend->parent.lock = &refdb_fs_backend__lock; + backend->parent.unlock = &refdb_fs_backend__unlock; + backend->parent.has_log = &refdb_reflog_fs__has_log; + backend->parent.ensure_log = &refdb_reflog_fs__ensure_log; + backend->parent.free = &refdb_fs_backend__free; + backend->parent.reflog_read = &refdb_reflog_fs__read; + backend->parent.reflog_write = &refdb_reflog_fs__write; + backend->parent.reflog_rename = &refdb_reflog_fs__rename; + backend->parent.reflog_delete = &refdb_reflog_fs__delete; + + *backend_out = (git_refdb_backend *)backend; + return 0; + +fail: + git_buf_free(&path); + git__free(backend->path); + git__free(backend); + return -1; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.h b/deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.h new file mode 100644 index 000000000..79e296833 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refdb_fs.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_refdb_fs_h__ +#define INCLUDE_refdb_fs_h__ + +typedef struct { + git_strmap *packfile; + time_t packfile_time; +} git_refcache; + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/reflog.c b/deps/libgit2-sys-0.2.17/libgit2/src/reflog.c new file mode 100644 index 000000000..22aa7d8ed --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/reflog.c @@ -0,0 +1,232 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "reflog.h" +#include "repository.h" +#include "filebuf.h" +#include "signature.h" +#include "refdb.h" + +#include + +git_reflog_entry *git_reflog_entry__alloc(void) +{ + return git__calloc(1, sizeof(git_reflog_entry)); +} + +void git_reflog_entry__free(git_reflog_entry *entry) +{ + git_signature_free(entry->committer); + + git__free(entry->msg); + git__free(entry); +} + +void git_reflog_free(git_reflog *reflog) +{ + size_t i; + git_reflog_entry *entry; + + if (reflog == NULL) + return; + + if (reflog->db) + GIT_REFCOUNT_DEC(reflog->db, git_refdb__free); + + for (i=0; i < reflog->entries.length; i++) { + entry = git_vector_get(&reflog->entries, i); + + git_reflog_entry__free(entry); + } + + git_vector_free(&reflog->entries); + git__free(reflog->ref_name); + git__free(reflog); +} + +int git_reflog_read(git_reflog **reflog, git_repository *repo, const char *name) +{ + git_refdb *refdb; + int error; + + assert(reflog && repo && name); + + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + return error; + + return git_refdb_reflog_read(reflog, refdb, name); +} + +int git_reflog_write(git_reflog *reflog) +{ + git_refdb *db; + + assert(reflog && reflog->db); + + db = reflog->db; + return db->backend->reflog_write(db->backend, reflog); +} + +int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_signature *committer, const char *msg) +{ + git_reflog_entry *entry; + const git_reflog_entry *previous; + const char *newline; + + assert(reflog && new_oid && committer); + + entry = git__calloc(1, sizeof(git_reflog_entry)); + GITERR_CHECK_ALLOC(entry); + + if ((git_signature_dup(&entry->committer, committer)) < 0) + goto cleanup; + + if (msg != NULL) { + if ((entry->msg = git__strdup(msg)) == NULL) + goto cleanup; + + newline = strchr(msg, '\n'); + + if (newline) { + if (newline[1] != '\0') { + giterr_set(GITERR_INVALID, "Reflog message cannot contain newline"); + goto cleanup; + } + + entry->msg[newline - msg] = '\0'; + } + } + + previous = git_reflog_entry_byindex(reflog, 0); + + if (previous == NULL) + git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO); + else + git_oid_cpy(&entry->oid_old, &previous->oid_cur); + + git_oid_cpy(&entry->oid_cur, new_oid); + + if (git_vector_insert(&reflog->entries, entry) < 0) + goto cleanup; + + return 0; + +cleanup: + git_reflog_entry__free(entry); + return -1; +} + +int git_reflog_rename(git_repository *repo, const char *old_name, const char *new_name) +{ + git_refdb *refdb; + int error; + + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + return -1; + + return refdb->backend->reflog_rename(refdb->backend, old_name, new_name); +} + +int git_reflog_delete(git_repository *repo, const char *name) +{ + git_refdb *refdb; + int error; + + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + return -1; + + return refdb->backend->reflog_delete(refdb->backend, name); +} + +size_t git_reflog_entrycount(git_reflog *reflog) +{ + assert(reflog); + return reflog->entries.length; +} + +const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size_t idx) +{ + assert(reflog); + + if (idx >= reflog->entries.length) + return NULL; + + return git_vector_get( + &reflog->entries, reflog_inverse_index(idx, reflog->entries.length)); +} + +const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry) +{ + assert(entry); + return &entry->oid_old; +} + +const git_oid * git_reflog_entry_id_new(const git_reflog_entry *entry) +{ + assert(entry); + return &entry->oid_cur; +} + +const git_signature * git_reflog_entry_committer(const git_reflog_entry *entry) +{ + assert(entry); + return entry->committer; +} + +const char * git_reflog_entry_message(const git_reflog_entry *entry) +{ + assert(entry); + return entry->msg; +} + +int git_reflog_drop(git_reflog *reflog, size_t idx, int rewrite_previous_entry) +{ + size_t entrycount; + git_reflog_entry *entry, *previous; + + entrycount = git_reflog_entrycount(reflog); + + entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx); + + if (entry == NULL) { + giterr_set(GITERR_REFERENCE, "No reflog entry at index "PRIuZ, idx); + return GIT_ENOTFOUND; + } + + git_reflog_entry__free(entry); + + if (git_vector_remove( + &reflog->entries, reflog_inverse_index(idx, entrycount)) < 0) + return -1; + + if (!rewrite_previous_entry) + return 0; + + /* No need to rewrite anything when removing the most recent entry */ + if (idx == 0) + return 0; + + /* Have the latest entry just been dropped? */ + if (entrycount == 1) + return 0; + + entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx - 1); + + /* If the oldest entry has just been removed... */ + if (idx == entrycount - 1) { + /* ...clear the oid_old member of the "new" oldest entry */ + if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0) + return -1; + + return 0; + } + + previous = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx); + git_oid_cpy(&entry->oid_old, &previous->oid_cur); + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/reflog.h b/deps/libgit2-sys-0.2.17/libgit2/src/reflog.h new file mode 100644 index 000000000..2d31ae47d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/reflog.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_reflog_h__ +#define INCLUDE_reflog_h__ + +#include "common.h" +#include "git2/reflog.h" +#include "vector.h" + +#define GIT_REFLOG_DIR "logs/" +#define GIT_REFLOG_DIR_MODE 0777 +#define GIT_REFLOG_FILE_MODE 0666 + +#define GIT_REFLOG_SIZE_MIN (2*GIT_OID_HEXSZ+2+17) + +struct git_reflog_entry { + git_oid oid_old; + git_oid oid_cur; + + git_signature *committer; + + char *msg; +}; + +struct git_reflog { + git_refdb *db; + char *ref_name; + git_vector entries; +}; + +GIT_INLINE(size_t) reflog_inverse_index(size_t idx, size_t total) +{ + return (total - 1) - idx; +} + +#endif /* INCLUDE_reflog_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refs.c b/deps/libgit2-sys-0.2.17/libgit2/src/refs.c new file mode 100644 index 000000000..ff5e24067 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refs.c @@ -0,0 +1,1305 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "refs.h" +#include "hash.h" +#include "repository.h" +#include "fileops.h" +#include "filebuf.h" +#include "pack.h" +#include "reflog.h" +#include "refdb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GIT__USE_STRMAP + +#define DEFAULT_NESTING_LEVEL 5 +#define MAX_NESTING_LEVEL 10 + +enum { + GIT_PACKREF_HAS_PEEL = 1, + GIT_PACKREF_WAS_LOOSE = 2 +}; + +static git_reference *alloc_ref(const char *name) +{ + git_reference *ref = NULL; + size_t namelen = strlen(name), reflen; + + if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) && + !GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) && + (ref = git__calloc(1, reflen)) != NULL) + memcpy(ref->name, name, namelen + 1); + + return ref; +} + +git_reference *git_reference__alloc_symbolic( + const char *name, const char *target) +{ + git_reference *ref; + + assert(name && target); + + ref = alloc_ref(name); + if (!ref) + return NULL; + + ref->type = GIT_REF_SYMBOLIC; + + if ((ref->target.symbolic = git__strdup(target)) == NULL) { + git__free(ref); + return NULL; + } + + return ref; +} + +git_reference *git_reference__alloc( + const char *name, + const git_oid *oid, + const git_oid *peel) +{ + git_reference *ref; + + assert(name && oid); + + ref = alloc_ref(name); + if (!ref) + return NULL; + + ref->type = GIT_REF_OID; + git_oid_cpy(&ref->target.oid, oid); + + if (peel != NULL) + git_oid_cpy(&ref->peel, peel); + + return ref; +} + +git_reference *git_reference__set_name( + git_reference *ref, const char *name) +{ + size_t namelen = strlen(name); + size_t reflen; + git_reference *rewrite = NULL; + + if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) && + !GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) && + (rewrite = git__realloc(ref, reflen)) != NULL) + memcpy(rewrite->name, name, namelen + 1); + + return rewrite; +} + +void git_reference_free(git_reference *reference) +{ + if (reference == NULL) + return; + + if (reference->type == GIT_REF_SYMBOLIC) + git__free(reference->target.symbolic); + + if (reference->db) + GIT_REFCOUNT_DEC(reference->db, git_refdb__free); + + git__free(reference); +} + +int git_reference_delete(git_reference *ref) +{ + const git_oid *old_id = NULL; + const char *old_target = NULL; + + if (ref->type == GIT_REF_OID) + old_id = &ref->target.oid; + else + old_target = ref->target.symbolic; + + return git_refdb_delete(ref->db, ref->name, old_id, old_target); +} + +int git_reference_remove(git_repository *repo, const char *name) +{ + git_refdb *db; + int error; + + if ((error = git_repository_refdb__weakptr(&db, repo)) < 0) + return error; + + return git_refdb_delete(db, name, NULL, NULL); +} + +int git_reference_lookup(git_reference **ref_out, + git_repository *repo, const char *name) +{ + return git_reference_lookup_resolved(ref_out, repo, name, 0); +} + +int git_reference_name_to_id( + git_oid *out, git_repository *repo, const char *name) +{ + int error; + git_reference *ref; + + if ((error = git_reference_lookup_resolved(&ref, repo, name, -1)) < 0) + return error; + + git_oid_cpy(out, git_reference_target(ref)); + git_reference_free(ref); + return 0; +} + +static int reference_normalize_for_repo( + git_refname_t out, + git_repository *repo, + const char *name) +{ + int precompose; + unsigned int flags = GIT_REF_FORMAT_ALLOW_ONELEVEL; + + if (!git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) && + precompose) + flags |= GIT_REF_FORMAT__PRECOMPOSE_UNICODE; + + return git_reference_normalize_name(out, GIT_REFNAME_MAX, name, flags); +} + +int git_reference_lookup_resolved( + git_reference **ref_out, + git_repository *repo, + const char *name, + int max_nesting) +{ + git_refname_t scan_name; + git_ref_t scan_type; + int error = 0, nesting; + git_reference *ref = NULL; + git_refdb *refdb; + + assert(ref_out && repo && name); + + *ref_out = NULL; + + if (max_nesting > MAX_NESTING_LEVEL) + max_nesting = MAX_NESTING_LEVEL; + else if (max_nesting < 0) + max_nesting = DEFAULT_NESTING_LEVEL; + + scan_type = GIT_REF_SYMBOLIC; + + if ((error = reference_normalize_for_repo(scan_name, repo, name)) < 0) + return error; + + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + return error; + + for (nesting = max_nesting; + nesting >= 0 && scan_type == GIT_REF_SYMBOLIC; + nesting--) + { + if (nesting != max_nesting) { + strncpy(scan_name, ref->target.symbolic, sizeof(scan_name)); + git_reference_free(ref); + } + + if ((error = git_refdb_lookup(&ref, refdb, scan_name)) < 0) + return error; + + scan_type = ref->type; + } + + if (scan_type != GIT_REF_OID && max_nesting != 0) { + giterr_set(GITERR_REFERENCE, + "Cannot resolve reference (>%u levels deep)", max_nesting); + git_reference_free(ref); + return -1; + } + + *ref_out = ref; + return 0; +} + +int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname) +{ + int error = 0, i; + bool fallbackmode = true, foundvalid = false; + git_reference *ref; + git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT; + + static const char* formatters[] = { + "%s", + GIT_REFS_DIR "%s", + GIT_REFS_TAGS_DIR "%s", + GIT_REFS_HEADS_DIR "%s", + GIT_REFS_REMOTES_DIR "%s", + GIT_REFS_REMOTES_DIR "%s/" GIT_HEAD_FILE, + NULL + }; + + if (*refname) + git_buf_puts(&name, refname); + else { + git_buf_puts(&name, GIT_HEAD_FILE); + fallbackmode = false; + } + + for (i = 0; formatters[i] && (fallbackmode || i == 0); i++) { + + git_buf_clear(&refnamebuf); + + if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0) + goto cleanup; + + if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) { + error = GIT_EINVALIDSPEC; + continue; + } + foundvalid = true; + + error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1); + + if (!error) { + *out = ref; + error = 0; + goto cleanup; + } + + if (error != GIT_ENOTFOUND) + goto cleanup; + } + +cleanup: + if (error && !foundvalid) { + /* never found a valid reference name */ + giterr_set(GITERR_REFERENCE, + "Could not use '%s' as valid reference name", git_buf_cstr(&name)); + } + + git_buf_free(&name); + git_buf_free(&refnamebuf); + return error; +} + +/** + * Getters + */ +git_ref_t git_reference_type(const git_reference *ref) +{ + assert(ref); + return ref->type; +} + +const char *git_reference_name(const git_reference *ref) +{ + assert(ref); + return ref->name; +} + +git_repository *git_reference_owner(const git_reference *ref) +{ + assert(ref); + return ref->db->repo; +} + +const git_oid *git_reference_target(const git_reference *ref) +{ + assert(ref); + + if (ref->type != GIT_REF_OID) + return NULL; + + return &ref->target.oid; +} + +const git_oid *git_reference_target_peel(const git_reference *ref) +{ + assert(ref); + + if (ref->type != GIT_REF_OID || git_oid_iszero(&ref->peel)) + return NULL; + + return &ref->peel; +} + +const char *git_reference_symbolic_target(const git_reference *ref) +{ + assert(ref); + + if (ref->type != GIT_REF_SYMBOLIC) + return NULL; + + return ref->target.symbolic; +} + +static int reference__create( + git_reference **ref_out, + git_repository *repo, + const char *name, + const git_oid *oid, + const char *symbolic, + int force, + const git_signature *signature, + const char *log_message, + const git_oid *old_id, + const char *old_target) +{ + git_refname_t normalized; + git_refdb *refdb; + git_reference *ref = NULL; + int error = 0; + + assert(repo && name); + assert(symbolic || signature); + + if (ref_out) + *ref_out = NULL; + + error = reference_normalize_for_repo(normalized, repo, name); + if (error < 0) + return error; + + error = git_repository_refdb__weakptr(&refdb, repo); + if (error < 0) + return error; + + if (oid != NULL) { + git_odb *odb; + + assert(symbolic == NULL); + + /* Sanity check the reference being created - target must exist. */ + if ((error = git_repository_odb__weakptr(&odb, repo)) < 0) + return error; + + if (!git_odb_exists(odb, oid)) { + giterr_set(GITERR_REFERENCE, + "Target OID for the reference doesn't exist on the repository"); + return -1; + } + + ref = git_reference__alloc(normalized, oid, NULL); + } else { + git_refname_t normalized_target; + + if ((error = reference_normalize_for_repo(normalized_target, repo, symbolic)) < 0) + return error; + + ref = git_reference__alloc_symbolic(normalized, normalized_target); + } + + GITERR_CHECK_ALLOC(ref); + + if ((error = git_refdb_write(refdb, ref, force, signature, log_message, old_id, old_target)) < 0) { + git_reference_free(ref); + return error; + } + + if (ref_out == NULL) + git_reference_free(ref); + else + *ref_out = ref; + + return 0; +} + +int configured_ident(git_signature **out, const git_repository *repo) +{ + if (repo->ident_name && repo->ident_email) + return git_signature_now(out, repo->ident_name, repo->ident_email); + + /* if not configured let us fall-through to the next method */ + return -1; +} + +int git_reference__log_signature(git_signature **out, git_repository *repo) +{ + int error; + git_signature *who; + + if(((error = configured_ident(&who, repo)) < 0) && + ((error = git_signature_default(&who, repo)) < 0) && + ((error = git_signature_now(&who, "unknown", "unknown")) < 0)) + return error; + + *out = who; + return 0; +} + +int git_reference_create_matching( + git_reference **ref_out, + git_repository *repo, + const char *name, + const git_oid *id, + int force, + const git_oid *old_id, + const char *log_message) + +{ + int error; + git_signature *who = NULL; + + assert(id); + + if ((error = git_reference__log_signature(&who, repo)) < 0) + return error; + + error = reference__create( + ref_out, repo, name, id, NULL, force, who, log_message, old_id, NULL); + + git_signature_free(who); + return error; +} + +int git_reference_create( + git_reference **ref_out, + git_repository *repo, + const char *name, + const git_oid *id, + int force, + const char *log_message) +{ + return git_reference_create_matching(ref_out, repo, name, id, force, NULL, log_message); +} + +int git_reference_symbolic_create_matching( + git_reference **ref_out, + git_repository *repo, + const char *name, + const char *target, + int force, + const char *old_target, + const char *log_message) +{ + int error; + git_signature *who = NULL; + + assert(target); + + if ((error = git_reference__log_signature(&who, repo)) < 0) + return error; + + error = reference__create( + ref_out, repo, name, NULL, target, force, who, log_message, NULL, old_target); + + git_signature_free(who); + return error; +} + +int git_reference_symbolic_create( + git_reference **ref_out, + git_repository *repo, + const char *name, + const char *target, + int force, + const char *log_message) +{ + return git_reference_symbolic_create_matching(ref_out, repo, name, target, force, NULL, log_message); +} + +static int ensure_is_an_updatable_direct_reference(git_reference *ref) +{ + if (ref->type == GIT_REF_OID) + return 0; + + giterr_set(GITERR_REFERENCE, "Cannot set OID on symbolic reference"); + return -1; +} + +int git_reference_set_target( + git_reference **out, + git_reference *ref, + const git_oid *id, + const char *log_message) +{ + int error; + git_repository *repo; + + assert(out && ref && id); + + repo = ref->db->repo; + + if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0) + return error; + + return git_reference_create_matching(out, repo, ref->name, id, 1, &ref->target.oid, log_message); +} + +static int ensure_is_an_updatable_symbolic_reference(git_reference *ref) +{ + if (ref->type == GIT_REF_SYMBOLIC) + return 0; + + giterr_set(GITERR_REFERENCE, "Cannot set symbolic target on a direct reference"); + return -1; +} + +int git_reference_symbolic_set_target( + git_reference **out, + git_reference *ref, + const char *target, + const char *log_message) +{ + int error; + + assert(out && ref && target); + + if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0) + return error; + + return git_reference_symbolic_create_matching( + out, ref->db->repo, ref->name, target, 1, ref->target.symbolic, log_message); +} + +static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force, + const git_signature *signature, const char *message) +{ + git_refname_t normalized; + bool should_head_be_updated = false; + int error = 0; + + assert(ref && new_name && signature); + + if ((error = reference_normalize_for_repo( + normalized, git_reference_owner(ref), new_name)) < 0) + return error; + + + /* Check if we have to update HEAD. */ + if ((error = git_branch_is_head(ref)) < 0) + return error; + + should_head_be_updated = (error > 0); + + if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0) + return error; + + /* Update HEAD it was pointing to the reference being renamed */ + if (should_head_be_updated && + (error = git_repository_set_head(ref->db->repo, normalized)) < 0) { + giterr_set(GITERR_REFERENCE, "Failed to update HEAD after renaming reference"); + return error; + } + + return 0; +} + + +int git_reference_rename( + git_reference **out, + git_reference *ref, + const char *new_name, + int force, + const char *log_message) +{ + git_signature *who; + int error; + + if ((error = git_reference__log_signature(&who, ref->db->repo)) < 0) + return error; + + error = reference__rename(out, ref, new_name, force, who, log_message); + git_signature_free(who); + + return error; +} + +int git_reference_resolve(git_reference **ref_out, const git_reference *ref) +{ + switch (git_reference_type(ref)) { + case GIT_REF_OID: + return git_reference_lookup(ref_out, ref->db->repo, ref->name); + + case GIT_REF_SYMBOLIC: + return git_reference_lookup_resolved(ref_out, ref->db->repo, ref->target.symbolic, -1); + + default: + giterr_set(GITERR_REFERENCE, "Invalid reference"); + return -1; + } +} + +int git_reference_foreach( + git_repository *repo, + git_reference_foreach_cb callback, + void *payload) +{ + git_reference_iterator *iter; + git_reference *ref; + int error; + + if ((error = git_reference_iterator_new(&iter, repo)) < 0) + return error; + + while (!(error = git_reference_next(&ref, iter))) { + if ((error = callback(ref, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + if (error == GIT_ITEROVER) + error = 0; + + git_reference_iterator_free(iter); + return error; +} + +int git_reference_foreach_name( + git_repository *repo, + git_reference_foreach_name_cb callback, + void *payload) +{ + git_reference_iterator *iter; + const char *refname; + int error; + + if ((error = git_reference_iterator_new(&iter, repo)) < 0) + return error; + + while (!(error = git_reference_next_name(&refname, iter))) { + if ((error = callback(refname, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + if (error == GIT_ITEROVER) + error = 0; + + git_reference_iterator_free(iter); + return error; +} + +int git_reference_foreach_glob( + git_repository *repo, + const char *glob, + git_reference_foreach_name_cb callback, + void *payload) +{ + git_reference_iterator *iter; + const char *refname; + int error; + + if ((error = git_reference_iterator_glob_new(&iter, repo, glob)) < 0) + return error; + + while (!(error = git_reference_next_name(&refname, iter))) { + if ((error = callback(refname, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + if (error == GIT_ITEROVER) + error = 0; + + git_reference_iterator_free(iter); + return error; +} + +int git_reference_iterator_new(git_reference_iterator **out, git_repository *repo) +{ + git_refdb *refdb; + + if (git_repository_refdb__weakptr(&refdb, repo) < 0) + return -1; + + return git_refdb_iterator(out, refdb, NULL); +} + +int git_reference_iterator_glob_new( + git_reference_iterator **out, git_repository *repo, const char *glob) +{ + git_refdb *refdb; + + if (git_repository_refdb__weakptr(&refdb, repo) < 0) + return -1; + + return git_refdb_iterator(out, refdb, glob); +} + +int git_reference_next(git_reference **out, git_reference_iterator *iter) +{ + return git_refdb_iterator_next(out, iter); +} + +int git_reference_next_name(const char **out, git_reference_iterator *iter) +{ + return git_refdb_iterator_next_name(out, iter); +} + +void git_reference_iterator_free(git_reference_iterator *iter) +{ + if (iter == NULL) + return; + + git_refdb_iterator_free(iter); +} + +static int cb__reflist_add(const char *ref, void *data) +{ + char *name = git__strdup(ref); + GITERR_CHECK_ALLOC(name); + return git_vector_insert((git_vector *)data, name); +} + +int git_reference_list( + git_strarray *array, + git_repository *repo) +{ + git_vector ref_list; + + assert(array && repo); + + array->strings = NULL; + array->count = 0; + + if (git_vector_init(&ref_list, 8, NULL) < 0) + return -1; + + if (git_reference_foreach_name( + repo, &cb__reflist_add, (void *)&ref_list) < 0) { + git_vector_free(&ref_list); + return -1; + } + + array->strings = (char **)git_vector_detach(&array->count, NULL, &ref_list); + + return 0; +} + +static int is_valid_ref_char(char ch) +{ + if ((unsigned) ch <= ' ') + return 0; + + switch (ch) { + case '~': + case '^': + case ':': + case '\\': + case '?': + case '[': + case '*': + return 0; + default: + return 1; + } +} + +static int ensure_segment_validity(const char *name) +{ + const char *current = name; + char prev = '\0'; + const int lock_len = (int)strlen(GIT_FILELOCK_EXTENSION); + int segment_len; + + if (*current == '.') + return -1; /* Refname starts with "." */ + + for (current = name; ; current++) { + if (*current == '\0' || *current == '/') + break; + + if (!is_valid_ref_char(*current)) + return -1; /* Illegal character in refname */ + + if (prev == '.' && *current == '.') + return -1; /* Refname contains ".." */ + + if (prev == '@' && *current == '{') + return -1; /* Refname contains "@{" */ + + prev = *current; + } + + segment_len = (int)(current - name); + + /* A refname component can not end with ".lock" */ + if (segment_len >= lock_len && + !memcmp(current - lock_len, GIT_FILELOCK_EXTENSION, lock_len)) + return -1; + + return segment_len; +} + +static bool is_all_caps_and_underscore(const char *name, size_t len) +{ + size_t i; + char c; + + assert(name && len > 0); + + for (i = 0; i < len; i++) + { + c = name[i]; + if ((c < 'A' || c > 'Z') && c != '_') + return false; + } + + if (*name == '_' || name[len - 1] == '_') + return false; + + return true; +} + +/* Inspired from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/refs.c#L36-100 */ +int git_reference__normalize_name( + git_buf *buf, + const char *name, + unsigned int flags) +{ + char *current; + int segment_len, segments_count = 0, error = GIT_EINVALIDSPEC; + unsigned int process_flags; + bool normalize = (buf != NULL); + +#ifdef GIT_USE_ICONV + git_path_iconv_t ic = GIT_PATH_ICONV_INIT; +#endif + + assert(name); + + process_flags = flags; + current = (char *)name; + + if (*current == '/') + goto cleanup; + + if (normalize) + git_buf_clear(buf); + +#ifdef GIT_USE_ICONV + if ((flags & GIT_REF_FORMAT__PRECOMPOSE_UNICODE) != 0) { + size_t namelen = strlen(current); + if ((error = git_path_iconv_init_precompose(&ic)) < 0 || + (error = git_path_iconv(&ic, ¤t, &namelen)) < 0) + goto cleanup; + error = GIT_EINVALIDSPEC; + } +#endif + + while (true) { + segment_len = ensure_segment_validity(current); + if (segment_len < 0) { + if ((process_flags & GIT_REF_FORMAT_REFSPEC_PATTERN) && + current[0] == '*' && + (current[1] == '\0' || current[1] == '/')) { + /* Accept one wildcard as a full refname component. */ + process_flags &= ~GIT_REF_FORMAT_REFSPEC_PATTERN; + segment_len = 1; + } else + goto cleanup; + } + + if (segment_len > 0) { + if (normalize) { + size_t cur_len = git_buf_len(buf); + + git_buf_joinpath(buf, git_buf_cstr(buf), current); + git_buf_truncate(buf, + cur_len + segment_len + (segments_count ? 1 : 0)); + + if (git_buf_oom(buf)) { + error = -1; + goto cleanup; + } + } + + segments_count++; + } + + /* No empty segment is allowed when not normalizing */ + if (segment_len == 0 && !normalize) + goto cleanup; + + if (current[segment_len] == '\0') + break; + + current += segment_len + 1; + } + + /* A refname can not be empty */ + if (segment_len == 0 && segments_count == 0) + goto cleanup; + + /* A refname can not end with "." */ + if (current[segment_len - 1] == '.') + goto cleanup; + + /* A refname can not end with "/" */ + if (current[segment_len - 1] == '/') + goto cleanup; + + if ((segments_count == 1 ) && !(flags & GIT_REF_FORMAT_ALLOW_ONELEVEL)) + goto cleanup; + + if ((segments_count == 1 ) && + !(flags & GIT_REF_FORMAT_REFSPEC_SHORTHAND) && + !(is_all_caps_and_underscore(name, (size_t)segment_len) || + ((flags & GIT_REF_FORMAT_REFSPEC_PATTERN) && !strcmp("*", name)))) + goto cleanup; + + if ((segments_count > 1) + && (is_all_caps_and_underscore(name, strchr(name, '/') - name))) + goto cleanup; + + error = 0; + +cleanup: + if (error == GIT_EINVALIDSPEC) + giterr_set( + GITERR_REFERENCE, + "The given reference name '%s' is not valid", name); + + if (error && normalize) + git_buf_free(buf); + +#ifdef GIT_USE_ICONV + git_path_iconv_clear(&ic); +#endif + + return error; +} + +int git_reference_normalize_name( + char *buffer_out, + size_t buffer_size, + const char *name, + unsigned int flags) +{ + git_buf buf = GIT_BUF_INIT; + int error; + + if ((error = git_reference__normalize_name(&buf, name, flags)) < 0) + goto cleanup; + + if (git_buf_len(&buf) > buffer_size - 1) { + giterr_set( + GITERR_REFERENCE, + "The provided buffer is too short to hold the normalization of '%s'", name); + error = GIT_EBUFS; + goto cleanup; + } + + git_buf_copy_cstr(buffer_out, buffer_size, &buf); + + error = 0; + +cleanup: + git_buf_free(&buf); + return error; +} + +#define GIT_REF_TYPEMASK (GIT_REF_OID | GIT_REF_SYMBOLIC) + +int git_reference_cmp( + const git_reference *ref1, + const git_reference *ref2) +{ + git_ref_t type1, type2; + assert(ref1 && ref2); + + type1 = git_reference_type(ref1); + type2 = git_reference_type(ref2); + + /* let's put symbolic refs before OIDs */ + if (type1 != type2) + return (type1 == GIT_REF_SYMBOLIC) ? -1 : 1; + + if (type1 == GIT_REF_SYMBOLIC) + return strcmp(ref1->target.symbolic, ref2->target.symbolic); + + return git_oid__cmp(&ref1->target.oid, &ref2->target.oid); +} + +/** + * Get the end of a chain of references. If the final one is not + * found, we return the reference just before that. + */ +static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting) +{ + git_reference *ref; + int error = 0; + + if (nesting > MAX_NESTING_LEVEL) { + giterr_set(GITERR_REFERENCE, "Reference chain too deep (%d)", nesting); + return GIT_ENOTFOUND; + } + + /* set to NULL to let the caller know that they're at the end of the chain */ + if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) { + *out = NULL; + return error; + } + + if (git_reference_type(ref) == GIT_REF_OID) { + *out = ref; + error = 0; + } else { + error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1); + if (error == GIT_ENOTFOUND && !*out) + *out = ref; + else + git_reference_free(ref); + } + + return error; +} + +/* + * Starting with the reference given by `ref_name`, follows symbolic + * references until a direct reference is found and updated the OID + * on that direct reference to `oid`. + */ +int git_reference__update_terminal( + git_repository *repo, + const char *ref_name, + const git_oid *oid, + const git_signature *sig, + const char *log_message) +{ + git_reference *ref = NULL, *ref2 = NULL; + git_signature *who = NULL; + const git_signature *to_use; + int error = 0; + + if (!sig && (error = git_reference__log_signature(&who, repo)) < 0) + return error; + + to_use = sig ? sig : who; + error = get_terminal(&ref, repo, ref_name, 0); + + /* found a dangling symref */ + if (error == GIT_ENOTFOUND && ref) { + assert(git_reference_type(ref) == GIT_REF_SYMBOLIC); + giterr_clear(); + error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use, + log_message, NULL, NULL); + } else if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use, + log_message, NULL, NULL); + } else if (error == 0) { + assert(git_reference_type(ref) == GIT_REF_OID); + error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use, + log_message, &ref->target.oid, NULL); + } + + git_reference_free(ref2); + git_reference_free(ref); + git_signature_free(who); + return error; +} + +int git_reference__update_for_commit( + git_repository *repo, + git_reference *ref, + const char *ref_name, + const git_oid *id, + const char *operation) +{ + git_reference *ref_new = NULL; + git_commit *commit = NULL; + git_buf reflog_msg = GIT_BUF_INIT; + const git_signature *who; + int error; + + if ((error = git_commit_lookup(&commit, repo, id)) < 0 || + (error = git_buf_printf(&reflog_msg, "%s%s: %s", + operation ? operation : "commit", + git_commit_parentcount(commit) == 0 ? " (initial)" : "", + git_commit_summary(commit))) < 0) + goto done; + + who = git_commit_committer(commit); + + if (ref) { + if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0) + return error; + + error = reference__create(&ref_new, repo, ref->name, id, NULL, 1, who, + git_buf_cstr(&reflog_msg), &ref->target.oid, NULL); + } + else + error = git_reference__update_terminal( + repo, ref_name, id, who, git_buf_cstr(&reflog_msg)); + +done: + git_reference_free(ref_new); + git_buf_free(&reflog_msg); + git_commit_free(commit); + return error; +} + +int git_reference_has_log(git_repository *repo, const char *refname) +{ + int error; + git_refdb *refdb; + + assert(repo && refname); + + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + return error; + + return git_refdb_has_log(refdb, refname); +} + +int git_reference_ensure_log(git_repository *repo, const char *refname) +{ + int error; + git_refdb *refdb; + + assert(repo && refname); + + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + return error; + + return git_refdb_ensure_log(refdb, refname); +} + +int git_reference__is_branch(const char *ref_name) +{ + return git__prefixcmp(ref_name, GIT_REFS_HEADS_DIR) == 0; +} + +int git_reference_is_branch(const git_reference *ref) +{ + assert(ref); + return git_reference__is_branch(ref->name); +} + +int git_reference__is_remote(const char *ref_name) +{ + return git__prefixcmp(ref_name, GIT_REFS_REMOTES_DIR) == 0; +} + +int git_reference_is_remote(const git_reference *ref) +{ + assert(ref); + return git_reference__is_remote(ref->name); +} + +int git_reference__is_tag(const char *ref_name) +{ + return git__prefixcmp(ref_name, GIT_REFS_TAGS_DIR) == 0; +} + +int git_reference_is_tag(const git_reference *ref) +{ + assert(ref); + return git_reference__is_tag(ref->name); +} + +int git_reference__is_note(const char *ref_name) +{ + return git__prefixcmp(ref_name, GIT_REFS_NOTES_DIR) == 0; +} + +int git_reference_is_note(const git_reference *ref) +{ + assert(ref); + return git_reference__is_note(ref->name); +} + +static int peel_error(int error, git_reference *ref, const char* msg) +{ + giterr_set( + GITERR_INVALID, + "The reference '%s' cannot be peeled - %s", git_reference_name(ref), msg); + return error; +} + +int git_reference_peel( + git_object **peeled, + git_reference *ref, + git_otype target_type) +{ + git_reference *resolved = NULL; + git_object *target = NULL; + int error; + + assert(ref); + + if (ref->type == GIT_REF_OID) { + resolved = ref; + } else { + if ((error = git_reference_resolve(&resolved, ref)) < 0) + return peel_error(error, ref, "Cannot resolve reference"); + } + + if (!git_oid_iszero(&resolved->peel)) { + error = git_object_lookup(&target, + git_reference_owner(ref), &resolved->peel, GIT_OBJ_ANY); + } else { + error = git_object_lookup(&target, + git_reference_owner(ref), &resolved->target.oid, GIT_OBJ_ANY); + } + + if (error < 0) { + peel_error(error, ref, "Cannot retrieve reference target"); + goto cleanup; + } + + if (target_type == GIT_OBJ_ANY && git_object_type(target) != GIT_OBJ_TAG) + error = git_object_dup(peeled, target); + else + error = git_object_peel(peeled, target, target_type); + +cleanup: + git_object_free(target); + + if (resolved != ref) + git_reference_free(resolved); + + return error; +} + +int git_reference__is_valid_name(const char *refname, unsigned int flags) +{ + if (git_reference__normalize_name(NULL, refname, flags) < 0) { + giterr_clear(); + return false; + } + + return true; +} + +int git_reference_is_valid_name(const char *refname) +{ + return git_reference__is_valid_name(refname, GIT_REF_FORMAT_ALLOW_ONELEVEL); +} + +const char *git_reference__shorthand(const char *name) +{ + if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR)) + return name + strlen(GIT_REFS_HEADS_DIR); + else if (!git__prefixcmp(name, GIT_REFS_TAGS_DIR)) + return name + strlen(GIT_REFS_TAGS_DIR); + else if (!git__prefixcmp(name, GIT_REFS_REMOTES_DIR)) + return name + strlen(GIT_REFS_REMOTES_DIR); + else if (!git__prefixcmp(name, GIT_REFS_DIR)) + return name + strlen(GIT_REFS_DIR); + + /* No shorthands are avaiable, so just return the name */ + return name; +} + +const char *git_reference_shorthand(const git_reference *ref) +{ + return git_reference__shorthand(ref->name); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refs.h b/deps/libgit2-sys-0.2.17/libgit2/src/refs.h new file mode 100644 index 000000000..f78ea06b0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refs.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_refs_h__ +#define INCLUDE_refs_h__ + +#include "common.h" +#include "git2/oid.h" +#include "git2/refs.h" +#include "git2/refdb.h" +#include "strmap.h" +#include "buffer.h" +#include "oid.h" + +#define GIT_REFS_DIR "refs/" +#define GIT_REFS_HEADS_DIR GIT_REFS_DIR "heads/" +#define GIT_REFS_TAGS_DIR GIT_REFS_DIR "tags/" +#define GIT_REFS_REMOTES_DIR GIT_REFS_DIR "remotes/" +#define GIT_REFS_NOTES_DIR GIT_REFS_DIR "notes/" +#define GIT_REFS_DIR_MODE 0777 +#define GIT_REFS_FILE_MODE 0666 + +#define GIT_RENAMED_REF_FILE GIT_REFS_DIR "RENAMED-REF" + +#define GIT_SYMREF "ref: " +#define GIT_PACKEDREFS_FILE "packed-refs" +#define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled fully-peeled " +#define GIT_PACKEDREFS_FILE_MODE 0666 + +#define GIT_HEAD_FILE "HEAD" +#define GIT_ORIG_HEAD_FILE "ORIG_HEAD" +#define GIT_FETCH_HEAD_FILE "FETCH_HEAD" +#define GIT_MERGE_HEAD_FILE "MERGE_HEAD" +#define GIT_REVERT_HEAD_FILE "REVERT_HEAD" +#define GIT_CHERRYPICK_HEAD_FILE "CHERRY_PICK_HEAD" +#define GIT_BISECT_LOG_FILE "BISECT_LOG" +#define GIT_REBASE_MERGE_DIR "rebase-merge/" +#define GIT_REBASE_MERGE_INTERACTIVE_FILE GIT_REBASE_MERGE_DIR "interactive" +#define GIT_REBASE_APPLY_DIR "rebase-apply/" +#define GIT_REBASE_APPLY_REBASING_FILE GIT_REBASE_APPLY_DIR "rebasing" +#define GIT_REBASE_APPLY_APPLYING_FILE GIT_REBASE_APPLY_DIR "applying" +#define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master" + +#define GIT_STASH_FILE "stash" +#define GIT_REFS_STASH_FILE GIT_REFS_DIR GIT_STASH_FILE + +#define GIT_REF_FORMAT__PRECOMPOSE_UNICODE (1u << 16) + +#define GIT_REFNAME_MAX 1024 + +typedef char git_refname_t[GIT_REFNAME_MAX]; + +struct git_reference { + git_refdb *db; + git_ref_t type; + + union { + git_oid oid; + char *symbolic; + } target; + + git_oid peel; + char name[GIT_FLEX_ARRAY]; +}; + +git_reference *git_reference__set_name(git_reference *ref, const char *name); + +int git_reference__normalize_name(git_buf *buf, const char *name, unsigned int flags); +int git_reference__update_terminal(git_repository *repo, const char *ref_name, const git_oid *oid, const git_signature *sig, const char *log_message); +int git_reference__is_valid_name(const char *refname, unsigned int flags); +int git_reference__is_branch(const char *ref_name); +int git_reference__is_remote(const char *ref_name); +int git_reference__is_tag(const char *ref_name); +const char *git_reference__shorthand(const char *name); + +/** + * Lookup a reference by name and try to resolve to an OID. + * + * You can control how many dereferences this will attempt to resolve the + * reference with the `max_deref` parameter, or pass -1 to use a sane + * default. If you pass 0 for `max_deref`, this will not attempt to resolve + * the reference. For any value of `max_deref` other than 0, not + * successfully resolving the reference will be reported as an error. + + * The generated reference must be freed by the user. + * + * @param reference_out Pointer to the looked-up reference + * @param repo The repository to look up the reference + * @param name The long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...) + * @param max_deref Maximum number of dereferences to make of symbolic refs, 0 means simple lookup, < 0 means use default reasonable value + * @return 0 on success or < 0 on error; not being able to resolve the reference is an error unless 0 was passed for max_deref + */ +int git_reference_lookup_resolved( + git_reference **reference_out, + git_repository *repo, + const char *name, + int max_deref); + +int git_reference__log_signature(git_signature **out, git_repository *repo); + +/** Update a reference after a commit. */ +int git_reference__update_for_commit( + git_repository *repo, + git_reference *ref, + const char *ref_name, + const git_oid *id, + const char *operation); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refspec.c b/deps/libgit2-sys-0.2.17/libgit2/src/refspec.c new file mode 100644 index 000000000..ad8141248 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refspec.c @@ -0,0 +1,356 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/errors.h" + +#include "common.h" +#include "refspec.h" +#include "util.h" +#include "posix.h" +#include "refs.h" +#include "vector.h" + +int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch) +{ + // Ported from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/remote.c#L518-636 + + size_t llen; + int is_glob = 0; + const char *lhs, *rhs; + int flags; + + assert(refspec && input); + + memset(refspec, 0x0, sizeof(git_refspec)); + refspec->push = !is_fetch; + + lhs = input; + if (*lhs == '+') { + refspec->force = 1; + lhs++; + } + + rhs = strrchr(lhs, ':'); + + /* + * Before going on, special case ":" (or "+:") as a refspec + * for matching refs. + */ + if (!is_fetch && rhs == lhs && rhs[1] == '\0') { + refspec->matching = 1; + return 0; + } + + if (rhs) { + size_t rlen = strlen(++rhs); + is_glob = (1 <= rlen && strchr(rhs, '*')); + refspec->dst = git__strndup(rhs, rlen); + } + + llen = (rhs ? (size_t)(rhs - lhs - 1) : strlen(lhs)); + if (1 <= llen && memchr(lhs, '*', llen)) { + if ((rhs && !is_glob) || (!rhs && is_fetch)) + goto invalid; + is_glob = 1; + } else if (rhs && is_glob) + goto invalid; + + refspec->pattern = is_glob; + refspec->src = git__strndup(lhs, llen); + flags = GIT_REF_FORMAT_ALLOW_ONELEVEL | GIT_REF_FORMAT_REFSPEC_SHORTHAND + | (is_glob ? GIT_REF_FORMAT_REFSPEC_PATTERN : 0); + + if (is_fetch) { + /* + * LHS + * - empty is allowed; it means HEAD. + * - otherwise it must be a valid looking ref. + */ + if (!*refspec->src) + ; /* empty is ok */ + else if (!git_reference__is_valid_name(refspec->src, flags)) + goto invalid; + /* + * RHS + * - missing is ok, and is same as empty. + * - empty is ok; it means not to store. + * - otherwise it must be a valid looking ref. + */ + if (!refspec->dst) + ; /* ok */ + else if (!*refspec->dst) + ; /* ok */ + else if (!git_reference__is_valid_name(refspec->dst, flags)) + goto invalid; + } else { + /* + * LHS + * - empty is allowed; it means delete. + * - when wildcarded, it must be a valid looking ref. + * - otherwise, it must be an extended SHA-1, but + * there is no existing way to validate this. + */ + if (!*refspec->src) + ; /* empty is ok */ + else if (is_glob) { + if (!git_reference__is_valid_name(refspec->src, flags)) + goto invalid; + } + else { + ; /* anything goes, for now */ + } + /* + * RHS + * - missing is allowed, but LHS then must be a + * valid looking ref. + * - empty is not allowed. + * - otherwise it must be a valid looking ref. + */ + if (!refspec->dst) { + if (!git_reference__is_valid_name(refspec->src, flags)) + goto invalid; + } else if (!*refspec->dst) { + goto invalid; + } else { + if (!git_reference__is_valid_name(refspec->dst, flags)) + goto invalid; + } + + /* if the RHS is empty, then it's a copy of the LHS */ + if (!refspec->dst) { + refspec->dst = git__strdup(refspec->src); + GITERR_CHECK_ALLOC(refspec->dst); + } + } + + refspec->string = git__strdup(input); + GITERR_CHECK_ALLOC(refspec->string); + + return 0; + + invalid: + giterr_set( + GITERR_INVALID, + "'%s' is not a valid refspec.", input); + return -1; +} + +void git_refspec__free(git_refspec *refspec) +{ + if (refspec == NULL) + return; + + git__free(refspec->src); + git__free(refspec->dst); + git__free(refspec->string); +} + +const char *git_refspec_src(const git_refspec *refspec) +{ + return refspec == NULL ? NULL : refspec->src; +} + +const char *git_refspec_dst(const git_refspec *refspec) +{ + return refspec == NULL ? NULL : refspec->dst; +} + +const char *git_refspec_string(const git_refspec *refspec) +{ + return refspec == NULL ? NULL : refspec->string; +} + +int git_refspec_force(const git_refspec *refspec) +{ + assert(refspec); + + return refspec->force; +} + +int git_refspec_src_matches(const git_refspec *refspec, const char *refname) +{ + if (refspec == NULL || refspec->src == NULL) + return false; + + return (p_fnmatch(refspec->src, refname, 0) == 0); +} + +int git_refspec_dst_matches(const git_refspec *refspec, const char *refname) +{ + if (refspec == NULL || refspec->dst == NULL) + return false; + + return (p_fnmatch(refspec->dst, refname, 0) == 0); +} + +static int refspec_transform( + git_buf *out, const char *from, const char *to, const char *name) +{ + const char *from_star, *to_star; + const char *name_slash, *from_slash; + size_t replacement_len, star_offset; + + git_buf_sanitize(out); + git_buf_clear(out); + + /* + * There are two parts to each side of a refspec, the bit + * before the star and the bit after it. The star can be in + * the middle of the pattern, so we need to look at each bit + * individually. + */ + from_star = strchr(from, '*'); + to_star = strchr(to, '*'); + + assert(from_star && to_star); + + /* star offset, both in 'from' and in 'name' */ + star_offset = from_star - from; + + /* the first half is copied over */ + git_buf_put(out, to, to_star - to); + + /* then we copy over the replacement, from the star's offset to the next slash in 'name' */ + name_slash = strchr(name + star_offset, '/'); + if (!name_slash) + name_slash = strrchr(name, '\0'); + + /* if there is no slash after the star in 'from', we want to copy everything over */ + from_slash = strchr(from + star_offset, '/'); + if (!from_slash) + name_slash = strrchr(name, '\0'); + + replacement_len = (name_slash - name) - star_offset; + git_buf_put(out, name + star_offset, replacement_len); + + return git_buf_puts(out, to_star + 1); +} + +int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name) +{ + assert(out && spec && name); + git_buf_sanitize(out); + + if (!git_refspec_src_matches(spec, name)) { + giterr_set(GITERR_INVALID, "ref '%s' doesn't match the source", name); + return -1; + } + + if (!spec->pattern) + return git_buf_puts(out, spec->dst); + + return refspec_transform(out, spec->src, spec->dst, name); +} + +int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name) +{ + assert(out && spec && name); + git_buf_sanitize(out); + + if (!git_refspec_dst_matches(spec, name)) { + giterr_set(GITERR_INVALID, "ref '%s' doesn't match the destination", name); + return -1; + } + + if (!spec->pattern) + return git_buf_puts(out, spec->src); + + return refspec_transform(out, spec->dst, spec->src, name); +} + +int git_refspec__serialize(git_buf *out, const git_refspec *refspec) +{ + if (refspec->force) + git_buf_putc(out, '+'); + + git_buf_printf(out, "%s:%s", + refspec->src != NULL ? refspec->src : "", + refspec->dst != NULL ? refspec->dst : ""); + + return git_buf_oom(out) == false; +} + +int git_refspec_is_wildcard(const git_refspec *spec) +{ + assert(spec && spec->src); + + return (spec->src[strlen(spec->src) - 1] == '*'); +} + +git_direction git_refspec_direction(const git_refspec *spec) +{ + assert(spec); + + return spec->push; +} + +int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs) +{ + git_buf buf = GIT_BUF_INIT; + size_t j, pos; + git_remote_head key; + + const char* formatters[] = { + GIT_REFS_DIR "%s", + GIT_REFS_TAGS_DIR "%s", + GIT_REFS_HEADS_DIR "%s", + NULL + }; + + git_refspec *cur = git__calloc(1, sizeof(git_refspec)); + GITERR_CHECK_ALLOC(cur); + + cur->force = spec->force; + cur->push = spec->push; + cur->pattern = spec->pattern; + cur->matching = spec->matching; + cur->string = git__strdup(spec->string); + + /* shorthand on the lhs */ + if (git__prefixcmp(spec->src, GIT_REFS_DIR)) { + for (j = 0; formatters[j]; j++) { + git_buf_clear(&buf); + if (git_buf_printf(&buf, formatters[j], spec->src) < 0) + return -1; + + key.name = (char *) git_buf_cstr(&buf); + if (!git_vector_search(&pos, refs, &key)) { + /* we found something to match the shorthand, set src to that */ + cur->src = git_buf_detach(&buf); + } + } + } + + /* No shorthands found, copy over the name */ + if (cur->src == NULL && spec->src != NULL) { + cur->src = git__strdup(spec->src); + GITERR_CHECK_ALLOC(cur->src); + } + + if (spec->dst && git__prefixcmp(spec->dst, GIT_REFS_DIR)) { + /* if it starts with "remotes" then we just prepend "refs/" */ + if (!git__prefixcmp(spec->dst, "remotes/")) { + git_buf_puts(&buf, GIT_REFS_DIR); + } else { + git_buf_puts(&buf, GIT_REFS_HEADS_DIR); + } + + if (git_buf_puts(&buf, spec->dst) < 0) + return -1; + + cur->dst = git_buf_detach(&buf); + } + + git_buf_free(&buf); + + if (cur->dst == NULL && spec->dst != NULL) { + cur->dst = git__strdup(spec->dst); + GITERR_CHECK_ALLOC(cur->dst); + } + + return git_vector_insert(out, cur); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/refspec.h b/deps/libgit2-sys-0.2.17/libgit2/src/refspec.h new file mode 100644 index 000000000..9a87c97a5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/refspec.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_refspec_h__ +#define INCLUDE_refspec_h__ + +#include "git2/refspec.h" +#include "buffer.h" +#include "vector.h" + +struct git_refspec { + char *string; + char *src; + char *dst; + unsigned int force :1, + push : 1, + pattern :1, + matching :1; +}; + +#define GIT_REFSPEC_TAGS "refs/tags/*:refs/tags/*" + +int git_refspec__parse( + struct git_refspec *refspec, + const char *str, + bool is_fetch); + +void git_refspec__free(git_refspec *refspec); + +int git_refspec__serialize(git_buf *out, const git_refspec *refspec); + +/** + * Determines if a refspec is a wildcard refspec. + * + * @param spec the refspec + * @return 1 if the refspec is a wildcard, 0 otherwise + */ +int git_refspec_is_wildcard(const git_refspec *spec); + +/** + * DWIM `spec` with `refs` existing on the remote, append the dwim'ed + * result in `out`. + */ +int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/remote.c b/deps/libgit2-sys-0.2.17/libgit2/src/remote.c new file mode 100644 index 000000000..ac7c43c78 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/remote.c @@ -0,0 +1,2396 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2/config.h" +#include "git2/types.h" +#include "git2/oid.h" +#include "git2/net.h" + +#include "common.h" +#include "config.h" +#include "repository.h" +#include "remote.h" +#include "fetch.h" +#include "refs.h" +#include "refspec.h" +#include "fetchhead.h" +#include "push.h" + +static int dwim_refspecs(git_vector *out, git_vector *refspecs, git_vector *refs); +static int lookup_remote_prune_config(git_remote *remote, git_config *config, const char *name); + +static int add_refspec_to(git_vector *vector, const char *string, bool is_fetch) +{ + git_refspec *spec; + + spec = git__calloc(1, sizeof(git_refspec)); + GITERR_CHECK_ALLOC(spec); + + if (git_refspec__parse(spec, string, is_fetch) < 0) { + git__free(spec); + return -1; + } + + spec->push = !is_fetch; + if (git_vector_insert(vector, spec) < 0) { + git_refspec__free(spec); + git__free(spec); + return -1; + } + + return 0; +} + +static int add_refspec(git_remote *remote, const char *string, bool is_fetch) +{ + return add_refspec_to(&remote->refspecs, string, is_fetch); +} + +static int download_tags_value(git_remote *remote, git_config *cfg) +{ + git_config_entry *ce; + git_buf buf = GIT_BUF_INIT; + int error; + + /* The 0 value is the default (auto), let's see if we need to change it */ + if (git_buf_printf(&buf, "remote.%s.tagopt", remote->name) < 0) + return -1; + + error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false); + git_buf_free(&buf); + + if (!error && ce && ce->value) { + if (!strcmp(ce->value, "--no-tags")) + remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_NONE; + else if (!strcmp(ce->value, "--tags")) + remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; + } + + git_config_entry_free(ce); + return error; +} + +static int ensure_remote_name_is_valid(const char *name) +{ + int error = 0; + + if (!git_remote_is_valid_name(name)) { + giterr_set( + GITERR_CONFIG, + "'%s' is not a valid remote name.", name ? name : "(null)"); + error = GIT_EINVALIDSPEC; + } + + return error; +} + +#if 0 +/* We could export this as a helper */ +static int get_check_cert(int *out, git_repository *repo) +{ + git_config *cfg; + const char *val; + int error = 0; + + assert(out && repo); + + /* By default, we *DO* want to verify the certificate. */ + *out = 1; + + /* Go through the possible sources for SSL verification settings, from + * most specific to least specific. */ + + /* GIT_SSL_NO_VERIFY environment variable */ + if ((val = getenv("GIT_SSL_NO_VERIFY")) != NULL) + return git_config_parse_bool(out, val); + + /* http.sslVerify config setting */ + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) + return error; + + *out = git_config__get_bool_force(cfg, "http.sslverify", 1); + return 0; +} +#endif + +static int canonicalize_url(git_buf *out, const char *in) +{ +#ifdef GIT_WIN32 + const char *c; + + /* Given a UNC path like \\server\path, we need to convert this + * to //server/path for compatibility with core git. + */ + if (in[0] == '\\' && in[1] == '\\' && + (git__isalpha(in[2]) || git__isdigit(in[2]))) { + for (c = in; *c; c++) + git_buf_putc(out, *c == '\\' ? '/' : *c); + + return git_buf_oom(out) ? -1 : 0; + } +#endif + + return git_buf_puts(out, in); +} + +static int create_internal(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch) +{ + git_remote *remote; + git_config *config = NULL; + git_buf canonical_url = GIT_BUF_INIT, fetchbuf = GIT_BUF_INIT; + int error = -1; + + /* name is optional */ + assert(out && repo && url); + + remote = git__calloc(1, sizeof(git_remote)); + GITERR_CHECK_ALLOC(remote); + + remote->repo = repo; + remote->update_fetchhead = 1; + + if (git_vector_init(&remote->refs, 32, NULL) < 0 || + canonicalize_url(&canonical_url, url) < 0) + goto on_error; + + remote->url = git_buf_detach(&canonical_url); + + if (name != NULL) { + remote->name = git__strdup(name); + GITERR_CHECK_ALLOC(remote->name); + } + + if (fetch != NULL) { + if (add_refspec(remote, fetch, true) < 0) + goto on_error; + + if ((error = git_repository_config_snapshot(&config, repo)) < 0) + goto on_error; + + if (lookup_remote_prune_config(remote, config, name) < 0) + goto on_error; + + /* Move the data over to where the matching functions can find them */ + if (dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs) < 0) + goto on_error; + } + + if (!name) + /* A remote without a name doesn't download tags */ + remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_NONE; + + *out = remote; + error = 0; + +on_error: + if (error) + git_remote_free(remote); + + git_config_free(config); + git_buf_free(&fetchbuf); + git_buf_free(&canonical_url); + return error; +} + +static int ensure_remote_doesnot_exist(git_repository *repo, const char *name) +{ + int error; + git_remote *remote; + + error = git_remote_lookup(&remote, repo, name); + + if (error == GIT_ENOTFOUND) + return 0; + + if (error < 0) + return error; + + git_remote_free(remote); + + giterr_set( + GITERR_CONFIG, + "Remote '%s' already exists.", name); + + return GIT_EEXISTS; +} + + +int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url) +{ + git_buf buf = GIT_BUF_INIT; + int error; + + if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0) + return -1; + + error = git_remote_create_with_fetchspec(out, repo, name, url, git_buf_cstr(&buf)); + git_buf_free(&buf); + + return error; +} + +int git_remote_create_with_fetchspec(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch) +{ + git_remote *remote = NULL; + int error; + + if ((error = ensure_remote_name_is_valid(name)) < 0) + return error; + + if ((error = ensure_remote_doesnot_exist(repo, name)) < 0) + return error; + + if (create_internal(&remote, repo, name, url, fetch) < 0) + goto on_error; + + if (git_remote_save(remote) < 0) + goto on_error; + + *out = remote; + + return 0; + +on_error: + git_remote_free(remote); + return -1; +} + +int git_remote_create_anonymous(git_remote **out, git_repository *repo, const char *url, const char *fetch) +{ + int error; + git_remote *remote; + + if ((error = create_internal(&remote, repo, NULL, url, fetch)) < 0) + return error; + + *out = remote; + return 0; +} + +int git_remote_dup(git_remote **dest, git_remote *source) +{ + int error = 0; + git_strarray refspecs = { 0 }; + git_remote *remote = git__calloc(1, sizeof(git_remote)); + GITERR_CHECK_ALLOC(remote); + + if (source->name != NULL) { + remote->name = git__strdup(source->name); + GITERR_CHECK_ALLOC(remote->name); + } + + if (source->url != NULL) { + remote->url = git__strdup(source->url); + GITERR_CHECK_ALLOC(remote->url); + } + + if (source->pushurl != NULL) { + remote->pushurl = git__strdup(source->pushurl); + GITERR_CHECK_ALLOC(remote->pushurl); + } + + remote->transport_cb = source->transport_cb; + remote->transport_cb_payload = source->transport_cb_payload; + remote->repo = source->repo; + remote->download_tags = source->download_tags; + remote->update_fetchhead = source->update_fetchhead; + remote->prune_refs = source->prune_refs; + + if (git_vector_init(&remote->refs, 32, NULL) < 0 || + git_vector_init(&remote->refspecs, 2, NULL) < 0 || + git_vector_init(&remote->active_refspecs, 2, NULL) < 0) { + error = -1; + goto cleanup; + } + + if ((error = git_remote_get_fetch_refspecs(&refspecs, source)) < 0 || + (error = git_remote_set_fetch_refspecs(remote, &refspecs)) < 0) + goto cleanup; + + git_strarray_free(&refspecs); + + if ((error = git_remote_get_push_refspecs(&refspecs, source)) < 0 || + (error = git_remote_set_push_refspecs(remote, &refspecs)) < 0) + goto cleanup; + + *dest = remote; + +cleanup: + + git_strarray_free(&refspecs); + + if (error < 0) + git__free(remote); + + return error; +} + +struct refspec_cb_data { + git_remote *remote; + int fetch; +}; + +static int refspec_cb(const git_config_entry *entry, void *payload) +{ + struct refspec_cb_data *data = (struct refspec_cb_data *)payload; + return add_refspec(data->remote, entry->value, data->fetch); +} + +static int get_optional_config( + bool *found, git_config *config, git_buf *buf, + git_config_foreach_cb cb, void *payload) +{ + int error = 0; + const char *key = git_buf_cstr(buf); + + if (git_buf_oom(buf)) + return -1; + + if (cb != NULL) + error = git_config_get_multivar_foreach(config, key, NULL, cb, payload); + else + error = git_config_get_string(payload, config, key); + + if (found) + *found = !error; + + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + + return error; +} + +int git_remote_lookup(git_remote **out, git_repository *repo, const char *name) +{ + git_remote *remote; + git_buf buf = GIT_BUF_INIT; + const char *val; + int error = 0; + git_config *config; + struct refspec_cb_data data = { NULL }; + bool optional_setting_found = false, found; + + assert(out && repo && name); + + if ((error = ensure_remote_name_is_valid(name)) < 0) + return error; + + if ((error = git_repository_config_snapshot(&config, repo)) < 0) + return error; + + remote = git__calloc(1, sizeof(git_remote)); + GITERR_CHECK_ALLOC(remote); + + remote->update_fetchhead = 1; + remote->name = git__strdup(name); + GITERR_CHECK_ALLOC(remote->name); + + if (git_vector_init(&remote->refs, 32, NULL) < 0 || + git_vector_init(&remote->refspecs, 2, NULL) < 0 || + git_vector_init(&remote->passive_refspecs, 2, NULL) < 0 || + git_vector_init(&remote->active_refspecs, 2, NULL) < 0) { + error = -1; + goto cleanup; + } + + if ((error = git_buf_printf(&buf, "remote.%s.url", name)) < 0) + goto cleanup; + + if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0) + goto cleanup; + + optional_setting_found |= found; + + remote->repo = repo; + + if (found && strlen(val) > 0) { + remote->url = git__strdup(val); + GITERR_CHECK_ALLOC(remote->url); + } + + val = NULL; + git_buf_clear(&buf); + git_buf_printf(&buf, "remote.%s.pushurl", name); + + if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0) + goto cleanup; + + optional_setting_found |= found; + + if (!optional_setting_found) { + error = GIT_ENOTFOUND; + giterr_set(GITERR_CONFIG, "Remote '%s' does not exist.", name); + goto cleanup; + } + + if (found && strlen(val) > 0) { + remote->pushurl = git__strdup(val); + GITERR_CHECK_ALLOC(remote->pushurl); + } + + data.remote = remote; + data.fetch = true; + + git_buf_clear(&buf); + git_buf_printf(&buf, "remote.%s.fetch", name); + + if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0) + goto cleanup; + + data.fetch = false; + git_buf_clear(&buf); + git_buf_printf(&buf, "remote.%s.push", name); + + if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0) + goto cleanup; + + if (download_tags_value(remote, config) < 0) + goto cleanup; + + if ((error = lookup_remote_prune_config(remote, config, name)) < 0) + goto cleanup; + + /* Move the data over to where the matching functions can find them */ + if (dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs) < 0) + goto cleanup; + + *out = remote; + +cleanup: + git_config_free(config); + git_buf_free(&buf); + + if (error < 0) + git_remote_free(remote); + + return error; +} + +static int lookup_remote_prune_config(git_remote *remote, git_config *config, const char *name) +{ + git_buf buf = GIT_BUF_INIT; + int error = 0; + + git_buf_printf(&buf, "remote.%s.prune", name); + + if ((error = git_config_get_bool(&remote->prune_refs, config, git_buf_cstr(&buf))) < 0) { + if (error == GIT_ENOTFOUND) { + giterr_clear(); + + if ((error = git_config_get_bool(&remote->prune_refs, config, "fetch.prune")) < 0) { + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + } + } + } + + git_buf_free(&buf); + return error; +} + +static int update_config_refspec(const git_remote *remote, git_config *config, int direction) +{ + git_buf name = GIT_BUF_INIT; + unsigned int push; + const char *dir; + size_t i; + int error = 0; + const char *cname; + + push = direction == GIT_DIRECTION_PUSH; + dir = push ? "push" : "fetch"; + + if (git_buf_printf(&name, "remote.%s.%s", remote->name, dir) < 0) + return -1; + cname = git_buf_cstr(&name); + + /* Clear out the existing config */ + while (!error) + error = git_config_delete_multivar(config, cname, ".*"); + + if (error != GIT_ENOTFOUND) + return error; + + for (i = 0; i < remote->refspecs.length; i++) { + git_refspec *spec = git_vector_get(&remote->refspecs, i); + + if (spec->push != push) + continue; + + // "$^" is a unmatcheable regexp: it will not match anything at all, so + // all values will be considered new and we will not replace any + // present value. + if ((error = git_config_set_multivar( + config, cname, "$^", spec->string)) < 0) { + goto cleanup; + } + } + + giterr_clear(); + error = 0; + +cleanup: + git_buf_free(&name); + + return error; +} + +int git_remote_save(const git_remote *remote) +{ + int error; + git_config *cfg; + const char *tagopt = NULL; + git_buf buf = GIT_BUF_INIT; + git_config_entry *existing = NULL; + + assert(remote); + + if (!remote->name) { + giterr_set(GITERR_INVALID, "Can't save an anonymous remote."); + return GIT_EINVALIDSPEC; + } + + if ((error = ensure_remote_name_is_valid(remote->name)) < 0) + return error; + + if ((error = git_repository_config__weakptr(&cfg, remote->repo)) < 0) + return error; + + if ((error = git_buf_printf(&buf, "remote.%s.url", remote->name)) < 0) + return error; + + /* after this point, buffer is allocated so end with cleanup */ + + if ((error = git_config_set_string( + cfg, git_buf_cstr(&buf), remote->url)) < 0) + goto cleanup; + + git_buf_clear(&buf); + if ((error = git_buf_printf(&buf, "remote.%s.pushurl", remote->name)) < 0) + goto cleanup; + + if ((error = git_config__update_entry( + cfg, git_buf_cstr(&buf), remote->pushurl, true, false)) < 0) + goto cleanup; + + if ((error = update_config_refspec(remote, cfg, GIT_DIRECTION_FETCH)) < 0) + goto cleanup; + + if ((error = update_config_refspec(remote, cfg, GIT_DIRECTION_PUSH)) < 0) + goto cleanup; + + /* + * What action to take depends on the old and new values. This + * is describes by the table below. tagopt means whether the + * is already a value set in the config + * + * AUTO ALL or NONE + * +-----------------------+ + * tagopt | remove | set | + * +---------+-------------| + * !tagopt | nothing | set | + * +---------+-------------+ + */ + + git_buf_clear(&buf); + if ((error = git_buf_printf(&buf, "remote.%s.tagopt", remote->name)) < 0) + goto cleanup; + + if ((error = git_config__lookup_entry( + &existing, cfg, git_buf_cstr(&buf), false)) < 0) + goto cleanup; + + if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) + tagopt = "--tags"; + else if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_NONE) + tagopt = "--no-tags"; + else if (existing != NULL) + tagopt = NULL; + + error = git_config__update_entry( + cfg, git_buf_cstr(&buf), tagopt, true, false); + +cleanup: + git_config_entry_free(existing); + git_buf_free(&buf); + return error; +} + +const char *git_remote_name(const git_remote *remote) +{ + assert(remote); + return remote->name; +} + +git_repository *git_remote_owner(const git_remote *remote) +{ + assert(remote); + return remote->repo; +} + +const char *git_remote_url(const git_remote *remote) +{ + assert(remote); + return remote->url; +} + +int git_remote_set_url(git_remote *remote, const char* url) +{ + assert(remote); + assert(url); + + git__free(remote->url); + remote->url = git__strdup(url); + GITERR_CHECK_ALLOC(remote->url); + + return 0; +} + +const char *git_remote_pushurl(const git_remote *remote) +{ + assert(remote); + return remote->pushurl; +} + +int git_remote_set_pushurl(git_remote *remote, const char* url) +{ + assert(remote); + + git__free(remote->pushurl); + if (url) { + remote->pushurl = git__strdup(url); + GITERR_CHECK_ALLOC(remote->pushurl); + } else { + remote->pushurl = NULL; + } + return 0; +} + +const char* git_remote__urlfordirection(git_remote *remote, int direction) +{ + assert(remote); + + assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH); + + if (direction == GIT_DIRECTION_FETCH) { + return remote->url; + } + + if (direction == GIT_DIRECTION_PUSH) { + return remote->pushurl ? remote->pushurl : remote->url; + } + + return NULL; +} + +int git_remote_connect(git_remote *remote, git_direction direction) +{ + git_transport *t; + const char *url; + int flags = GIT_TRANSPORTFLAGS_NONE; + int error; + + assert(remote); + + t = remote->transport; + + url = git_remote__urlfordirection(remote, direction); + if (url == NULL) { + giterr_set(GITERR_INVALID, + "Malformed remote '%s' - missing URL", remote->name); + return -1; + } + + /* If we don't have a transport object yet, and the caller specified a + * custom transport factory, use that */ + if (!t && remote->transport_cb && + (error = remote->transport_cb(&t, remote, remote->transport_cb_payload)) < 0) + return error; + + /* If we still don't have a transport, then use the global + * transport registrations which map URI schemes to transport factories */ + if (!t && (error = git_transport_new(&t, remote, url)) < 0) + return error; + + if (t->set_callbacks && + (error = t->set_callbacks(t, remote->callbacks.sideband_progress, NULL, remote->callbacks.certificate_check, remote->callbacks.payload)) < 0) + goto on_error; + + if ((error = t->connect(t, url, remote->callbacks.credentials, remote->callbacks.payload, direction, flags)) != 0) + goto on_error; + + remote->transport = t; + + return 0; + +on_error: + t->free(t); + + if (t == remote->transport) + remote->transport = NULL; + + return error; +} + +int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote) +{ + assert(remote); + + if (!remote->transport) { + giterr_set(GITERR_NET, "this remote has never connected"); + return -1; + } + + return remote->transport->ls(out, size, remote->transport); +} + +int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url) +{ + git_config *cfg; + git_config_entry *ce = NULL; + const char *val = NULL; + int error; + + assert(remote); + + if (!proxy_url || !remote->repo) + return -1; + + *proxy_url = NULL; + + if ((error = git_repository_config__weakptr(&cfg, remote->repo)) < 0) + return error; + + /* Go through the possible sources for proxy configuration, from most specific + * to least specific. */ + + /* remote..proxy config setting */ + if (remote->name && remote->name[0]) { + git_buf buf = GIT_BUF_INIT; + + if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0) + return error; + + error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false); + git_buf_free(&buf); + + if (error < 0) + return error; + + if (ce && ce->value) { + val = ce->value; + goto found; + } + } + + /* http.proxy config setting */ + if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0) + return error; + if (ce && ce->value) { + val = ce->value; + goto found; + } + + /* HTTP_PROXY / HTTPS_PROXY environment variables */ + val = use_ssl ? getenv("HTTPS_PROXY") : getenv("HTTP_PROXY"); + +found: + if (val && val[0]) { + *proxy_url = git__strdup(val); + GITERR_CHECK_ALLOC(*proxy_url); + } + git_config_entry_free(ce); + + return 0; +} + +/* DWIM `refspecs` based on `refs` and append the output to `out` */ +static int dwim_refspecs(git_vector *out, git_vector *refspecs, git_vector *refs) +{ + size_t i; + git_refspec *spec; + + git_vector_foreach(refspecs, i, spec) { + if (git_refspec__dwim_one(out, spec, refs) < 0) + return -1; + } + + return 0; +} + +static void free_refspecs(git_vector *vec) +{ + size_t i; + git_refspec *spec; + + git_vector_foreach(vec, i, spec) { + git_refspec__free(spec); + git__free(spec); + } + + git_vector_clear(vec); +} + +static int remote_head_cmp(const void *_a, const void *_b) +{ + const git_remote_head *a = (git_remote_head *) _a; + const git_remote_head *b = (git_remote_head *) _b; + + return git__strcmp_cb(a->name, b->name); +} + +static int ls_to_vector(git_vector *out, git_remote *remote) +{ + git_remote_head **heads; + size_t heads_len, i; + + if (git_remote_ls((const git_remote_head ***)&heads, &heads_len, remote) < 0) + return -1; + + if (git_vector_init(out, heads_len, remote_head_cmp) < 0) + return -1; + + for (i = 0; i < heads_len; i++) { + if (git_vector_insert(out, heads[i]) < 0) + return -1; + } + + return 0; +} + +int git_remote_download(git_remote *remote, const git_strarray *refspecs) +{ + int error = -1; + size_t i; + git_vector refs, specs, *to_active; + + assert(remote); + + if (ls_to_vector(&refs, remote) < 0) + return -1; + + if ((git_vector_init(&specs, 0, NULL)) < 0) + goto on_error; + + remote->passed_refspecs = 0; + if (!refspecs || !refspecs->count) { + to_active = &remote->refspecs; + } else { + for (i = 0; i < refspecs->count; i++) { + if ((error = add_refspec_to(&specs, refspecs->strings[i], true)) < 0) + goto on_error; + } + + to_active = &specs; + remote->passed_refspecs = 1; + } + + free_refspecs(&remote->passive_refspecs); + if ((error = dwim_refspecs(&remote->passive_refspecs, &remote->refspecs, &refs)) < 0) + goto on_error; + + free_refspecs(&remote->active_refspecs); + error = dwim_refspecs(&remote->active_refspecs, to_active, &refs); + + git_vector_free(&refs); + free_refspecs(&specs); + git_vector_free(&specs); + + if (error < 0) + return error; + + if (remote->push) { + git_push_free(remote->push); + remote->push = NULL; + } + + if ((error = git_fetch_negotiate(remote)) < 0) + return error; + + return git_fetch_download_pack(remote); + +on_error: + git_vector_free(&refs); + free_refspecs(&specs); + git_vector_free(&specs); + return error; +} + +int git_remote_fetch( + git_remote *remote, + const git_strarray *refspecs, + const char *reflog_message) +{ + int error; + git_buf reflog_msg_buf = GIT_BUF_INIT; + + /* Connect and download everything */ + if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH)) != 0) + return error; + + error = git_remote_download(remote, refspecs); + + /* We don't need to be connected anymore */ + git_remote_disconnect(remote); + + /* If the download failed, return the error */ + if (error != 0) + return error; + + /* Default reflog message */ + if (reflog_message) + git_buf_sets(&reflog_msg_buf, reflog_message); + else { + git_buf_printf(&reflog_msg_buf, "fetch %s", + remote->name ? remote->name : remote->url); + } + + /* Create "remote/foo" branches for all remote branches */ + error = git_remote_update_tips(remote, git_buf_cstr(&reflog_msg_buf)); + git_buf_free(&reflog_msg_buf); + if (error < 0) + return error; + + if (remote->prune_refs) + error = git_remote_prune(remote); + + return error; +} + +static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *update_heads, const char *fetchspec_src) +{ + unsigned int i; + git_remote_head *remote_ref; + + assert(update_heads && fetchspec_src); + + *out = NULL; + + git_vector_foreach(update_heads, i, remote_ref) { + if (strcmp(remote_ref->name, fetchspec_src) == 0) { + *out = remote_ref; + break; + } + } + + return 0; +} + +static int ref_to_update(int *update, git_buf *remote_name, git_remote *remote, git_refspec *spec, const char *ref_name) +{ + int error = 0; + git_repository *repo; + git_buf upstream_remote = GIT_BUF_INIT; + git_buf upstream_name = GIT_BUF_INIT; + + repo = git_remote_owner(remote); + + if ((!git_reference__is_branch(ref_name)) || + !git_remote_name(remote) || + (error = git_branch_upstream_remote(&upstream_remote, repo, ref_name) < 0) || + git__strcmp(git_remote_name(remote), git_buf_cstr(&upstream_remote)) || + (error = git_branch_upstream_name(&upstream_name, repo, ref_name)) < 0 || + !git_refspec_dst_matches(spec, git_buf_cstr(&upstream_name)) || + (error = git_refspec_rtransform(remote_name, spec, upstream_name.ptr)) < 0) { + /* Not an error if there is no upstream */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + + *update = 0; + } else { + *update = 1; + } + + git_buf_free(&upstream_remote); + git_buf_free(&upstream_name); + return error; +} + +static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_refspec *spec, git_vector *update_heads, git_reference *ref) +{ + git_reference *resolved_ref = NULL; + git_buf remote_name = GIT_BUF_INIT; + git_config *config = NULL; + const char *ref_name; + int error = 0, update; + + assert(out && spec && ref); + + *out = NULL; + + error = git_reference_resolve(&resolved_ref, ref); + + /* If we're in an unborn branch, let's pretend nothing happened */ + if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REF_SYMBOLIC) { + ref_name = git_reference_symbolic_target(ref); + error = 0; + } else { + ref_name = git_reference_name(resolved_ref); + } + + if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0) + goto cleanup; + + if (update) + error = remote_head_for_fetchspec_src(out, update_heads, git_buf_cstr(&remote_name)); + +cleanup: + git_buf_free(&remote_name); + git_reference_free(resolved_ref); + git_config_free(config); + return error; +} + +static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git_vector *update_heads) +{ + git_reference *head_ref = NULL; + git_fetchhead_ref *fetchhead_ref; + git_remote_head *remote_ref, *merge_remote_ref; + git_vector fetchhead_refs; + bool include_all_fetchheads; + unsigned int i = 0; + int error = 0; + + assert(remote); + + /* no heads, nothing to do */ + if (update_heads->length == 0) + return 0; + + if (git_vector_init(&fetchhead_refs, update_heads->length, git_fetchhead_ref_cmp) < 0) + return -1; + + /* Iff refspec is * (but not subdir slash star), include tags */ + include_all_fetchheads = (strcmp(GIT_REFS_HEADS_DIR "*", git_refspec_src(spec)) == 0); + + /* Determine what to merge: if refspec was a wildcard, just use HEAD */ + if (git_refspec_is_wildcard(spec)) { + if ((error = git_reference_lookup(&head_ref, remote->repo, GIT_HEAD_FILE)) < 0 || + (error = remote_head_for_ref(&merge_remote_ref, remote, spec, update_heads, head_ref)) < 0) + goto cleanup; + } else { + /* If we're fetching a single refspec, that's the only thing that should be in FETCH_HEAD. */ + if ((error = remote_head_for_fetchspec_src(&merge_remote_ref, update_heads, git_refspec_src(spec))) < 0) + goto cleanup; + } + + /* Create the FETCH_HEAD file */ + git_vector_foreach(update_heads, i, remote_ref) { + int merge_this_fetchhead = (merge_remote_ref == remote_ref); + + if (!include_all_fetchheads && + !git_refspec_src_matches(spec, remote_ref->name) && + !merge_this_fetchhead) + continue; + + if (git_fetchhead_ref_create(&fetchhead_ref, + &remote_ref->oid, + merge_this_fetchhead, + remote_ref->name, + git_remote_url(remote)) < 0) + goto cleanup; + + if (git_vector_insert(&fetchhead_refs, fetchhead_ref) < 0) + goto cleanup; + } + + git_fetchhead_write(remote->repo, &fetchhead_refs); + +cleanup: + for (i = 0; i < fetchhead_refs.length; ++i) + git_fetchhead_ref_free(fetchhead_refs.contents[i]); + + git_vector_free(&fetchhead_refs); + git_reference_free(head_ref); + + return error; +} + +/** + * Generate a list of candidates for pruning by getting a list of + * references which match the rhs of an active refspec. + */ +static int prune_candidates(git_vector *candidates, git_remote *remote) +{ + git_strarray arr = { 0 }; + size_t i; + int error; + + if ((error = git_reference_list(&arr, remote->repo)) < 0) + return error; + + for (i = 0; i < arr.count; i++) { + const char *refname = arr.strings[i]; + char *refname_dup; + + if (!git_remote__matching_dst_refspec(remote, refname)) + continue; + + refname_dup = git__strdup(refname); + GITERR_CHECK_ALLOC(refname_dup); + + if ((error = git_vector_insert(candidates, refname_dup)) < 0) + goto out; + } + +out: + git_strarray_free(&arr); + return error; +} + +static int find_head(const void *_a, const void *_b) +{ + git_remote_head *a = (git_remote_head *) _a; + git_remote_head *b = (git_remote_head *) _b; + + return strcmp(a->name, b->name); +} + +int git_remote_prune(git_remote *remote) +{ + size_t i, j; + git_vector remote_refs = GIT_VECTOR_INIT; + git_vector candidates = GIT_VECTOR_INIT; + const git_refspec *spec; + const char *refname; + int error; + git_oid zero_id = {{ 0 }}; + + if ((error = ls_to_vector(&remote_refs, remote)) < 0) + goto cleanup; + + git_vector_set_cmp(&remote_refs, find_head); + + if ((error = prune_candidates(&candidates, remote)) < 0) + goto cleanup; + + /* + * Remove those entries from the candidate list for which we + * can find a remote reference in at least one refspec. + */ + git_vector_foreach(&candidates, i, refname) { + git_vector_foreach(&remote->active_refspecs, j, spec) { + git_buf buf = GIT_BUF_INIT; + size_t pos; + char *src_name; + git_remote_head key = {0}; + + if (!git_refspec_dst_matches(spec, refname)) + continue; + + if ((error = git_refspec_rtransform(&buf, spec, refname)) < 0) + goto cleanup; + + key.name = (char *) git_buf_cstr(&buf); + error = git_vector_search(&pos, &remote_refs, &key); + git_buf_free(&buf); + + if (error < 0 && error != GIT_ENOTFOUND) + goto cleanup; + + if (error == GIT_ENOTFOUND) + continue; + + /* if we did find a source, remove it from the candiates */ + if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0) + goto cleanup; + + git__free(src_name); + break; + } + } + + /* + * For those candidates still left in the list, we need to + * remove them. We do not remove symrefs, as those are for + * stuff like origin/HEAD which will never match, but we do + * not want to remove them. + */ + git_vector_foreach(&candidates, i, refname) { + git_reference *ref; + git_oid id; + + if (refname == NULL) + continue; + + error = git_reference_lookup(&ref, remote->repo, refname); + /* as we want it gone, let's not consider this an error */ + if (error == GIT_ENOTFOUND) + continue; + + if (error < 0) + goto cleanup; + + if (git_reference_type(ref) == GIT_REF_SYMBOLIC) { + git_reference_free(ref); + continue; + } + + git_oid_cpy(&id, git_reference_target(ref)); + error = git_reference_delete(ref); + git_reference_free(ref); + if (error < 0) + goto cleanup; + + if (remote->callbacks.update_tips) + error = remote->callbacks.update_tips(refname, &id, &zero_id, remote->callbacks.payload); + + if (error < 0) + goto cleanup; + } + +cleanup: + git_vector_free(&remote_refs); + git_vector_free_deep(&candidates); + return error; +} + +static int update_tips_for_spec( + git_remote *remote, + git_refspec *spec, + git_vector *refs, + const char *log_message) +{ + int error = 0, autotag; + unsigned int i = 0; + git_buf refname = GIT_BUF_INIT; + git_oid old; + git_odb *odb; + git_remote_head *head; + git_reference *ref; + git_refspec tagspec; + git_vector update_heads; + + assert(remote); + + if (git_repository_odb__weakptr(&odb, remote->repo) < 0) + return -1; + + if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0) + return -1; + + /* Make a copy of the transport's refs */ + if (git_vector_init(&update_heads, 16, NULL) < 0) + return -1; + + for (; i < refs->length; ++i) { + head = git_vector_get(refs, i); + autotag = 0; + + /* Ignore malformed ref names (which also saves us from tag^{} */ + if (!git_reference_is_valid_name(head->name)) + continue; + + if (git_refspec_src_matches(&tagspec, head->name)) { + if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_NONE) { + + if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_AUTO) + autotag = 1; + + git_buf_clear(&refname); + if (git_buf_puts(&refname, head->name) < 0) + goto on_error; + } else { + continue; + } + } else if (git_refspec_src_matches(spec, head->name) && spec->dst) { + if (git_refspec_transform(&refname, spec, head->name) < 0) + goto on_error; + } else { + continue; + } + + /* In autotag mode, only create tags for objects already in db */ + if (autotag && !git_odb_exists(odb, &head->oid)) + continue; + + if (!autotag && git_vector_insert(&update_heads, head) < 0) + goto on_error; + + error = git_reference_name_to_id(&old, remote->repo, refname.ptr); + if (error < 0 && error != GIT_ENOTFOUND) + goto on_error; + + if (error == GIT_ENOTFOUND) { + memset(&old, 0, GIT_OID_RAWSZ); + + if (autotag && git_vector_insert(&update_heads, head) < 0) + goto on_error; + } + + if (!git_oid__cmp(&old, &head->oid)) + continue; + + /* In autotag mode, don't overwrite any locally-existing tags */ + error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag, + log_message); + if (error < 0 && error != GIT_EEXISTS) + goto on_error; + + git_reference_free(ref); + + if (remote->callbacks.update_tips != NULL) { + if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.payload) < 0) + goto on_error; + } + } + + if (git_remote_update_fetchhead(remote) && + (error = git_remote_write_fetchhead(remote, spec, &update_heads)) < 0) + goto on_error; + + git_vector_free(&update_heads); + git_refspec__free(&tagspec); + git_buf_free(&refname); + return 0; + +on_error: + git_vector_free(&update_heads); + git_refspec__free(&tagspec); + git_buf_free(&refname); + return -1; + +} + +/** + * Iteration over the three vectors, with a pause whenever we find a match + * + * On each stop, we store the iteration stat in the inout i,j,k + * parameters, and return the currently matching passive refspec as + * well as the head which we matched. + */ +static int next_head(const git_remote *remote, git_vector *refs, + git_refspec **out_spec, git_remote_head **out_head, + size_t *out_i, size_t *out_j, size_t *out_k) +{ + const git_vector *active, *passive; + git_remote_head *head; + git_refspec *spec, *passive_spec; + size_t i, j, k; + + active = &remote->active_refspecs; + passive = &remote->passive_refspecs; + + i = *out_i; + j = *out_j; + k = *out_k; + + for (; i < refs->length; i++) { + head = git_vector_get(refs, i); + + if (!git_reference_is_valid_name(head->name)) + continue; + + for (; j < active->length; j++) { + spec = git_vector_get(active, j); + + if (!git_refspec_src_matches(spec, head->name)) + continue; + + for (; k < passive->length; k++) { + passive_spec = git_vector_get(passive, k); + + if (!git_refspec_src_matches(passive_spec, head->name)) + continue; + + *out_spec = passive_spec; + *out_head = head; + *out_i = i; + *out_j = j; + *out_k = k + 1; + return 0; + + } + k = 0; + } + j = 0; + } + + return GIT_ITEROVER; +} + +static int opportunistic_updates(const git_remote *remote, git_vector *refs, const char *msg) +{ + size_t i, j, k; + git_refspec *spec; + git_remote_head *head; + git_reference *ref; + git_buf refname = GIT_BUF_INIT; + int error; + + i = j = k = 0; + + while ((error = next_head(remote, refs, &spec, &head, &i, &j, &k)) == 0) { + /* + * If we got here, there is a refspec which was used + * for fetching which matches the source of one of the + * passive refspecs, so we should update that + * remote-tracking branch, but not add it to + * FETCH_HEAD + */ + + if ((error = git_refspec_transform(&refname, spec, head->name)) < 0) + return error; + + error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, true, msg); + git_buf_free(&refname); + git_reference_free(ref); + + if (error < 0) + return error; + } + + return 0; +} + +int git_remote_update_tips( + git_remote *remote, + const char *reflog_message) +{ + git_refspec *spec, tagspec; + git_vector refs = GIT_VECTOR_INIT; + int error; + size_t i; + + /* push has its own logic hidden away in the push object */ + if (remote->push) { + return git_push_update_tips(remote->push); + } + + if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0) + return -1; + + + if ((error = ls_to_vector(&refs, remote)) < 0) + goto out; + + if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) { + if ((error = update_tips_for_spec(remote, &tagspec, &refs, reflog_message)) < 0) + goto out; + } + + git_vector_foreach(&remote->active_refspecs, i, spec) { + if (spec->push) + continue; + + if ((error = update_tips_for_spec(remote, spec, &refs, reflog_message)) < 0) + goto out; + } + + /* only try to do opportunisitic updates if the refpec lists differ */ + if (remote->passed_refspecs) + error = opportunistic_updates(remote, &refs, reflog_message); + +out: + git_vector_free(&refs); + git_refspec__free(&tagspec); + return error; +} + +int git_remote_connected(const git_remote *remote) +{ + assert(remote); + + if (!remote->transport || !remote->transport->is_connected) + return 0; + + /* Ask the transport if it's connected. */ + return remote->transport->is_connected(remote->transport); +} + +void git_remote_stop(git_remote *remote) +{ + assert(remote); + + if (remote->transport && remote->transport->cancel) + remote->transport->cancel(remote->transport); +} + +void git_remote_disconnect(git_remote *remote) +{ + assert(remote); + + if (git_remote_connected(remote)) + remote->transport->close(remote->transport); +} + +void git_remote_free(git_remote *remote) +{ + if (remote == NULL) + return; + + if (remote->transport != NULL) { + git_remote_disconnect(remote); + + remote->transport->free(remote->transport); + remote->transport = NULL; + } + + git_vector_free(&remote->refs); + + free_refspecs(&remote->refspecs); + git_vector_free(&remote->refspecs); + + free_refspecs(&remote->active_refspecs); + git_vector_free(&remote->active_refspecs); + + free_refspecs(&remote->passive_refspecs); + git_vector_free(&remote->passive_refspecs); + + git_push_free(remote->push); + git__free(remote->url); + git__free(remote->pushurl); + git__free(remote->name); + git__free(remote); +} + +static int remote_list_cb(const git_config_entry *entry, void *payload) +{ + git_vector *list = payload; + const char *name = entry->name + strlen("remote."); + size_t namelen = strlen(name); + char *remote_name; + + /* we know name matches "remote..(push)?url" */ + + if (!strcmp(&name[namelen - 4], ".url")) + remote_name = git__strndup(name, namelen - 4); /* strip ".url" */ + else + remote_name = git__strndup(name, namelen - 8); /* strip ".pushurl" */ + GITERR_CHECK_ALLOC(remote_name); + + return git_vector_insert(list, remote_name); +} + +int git_remote_list(git_strarray *remotes_list, git_repository *repo) +{ + int error; + git_config *cfg; + git_vector list = GIT_VECTOR_INIT; + + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) + return error; + + if ((error = git_vector_init(&list, 4, git__strcmp_cb)) < 0) + return error; + + error = git_config_foreach_match( + cfg, "^remote\\..*\\.(push)?url$", remote_list_cb, &list); + + if (error < 0) { + git_vector_free_deep(&list); + return error; + } + + git_vector_uniq(&list, git__free); + + remotes_list->strings = + (char **)git_vector_detach(&remotes_list->count, NULL, &list); + + return 0; +} + +int git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *callbacks) +{ + assert(remote && callbacks); + + GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); + + memcpy(&remote->callbacks, callbacks, sizeof(git_remote_callbacks)); + + if (remote->transport && remote->transport->set_callbacks) + return remote->transport->set_callbacks(remote->transport, + remote->callbacks.sideband_progress, + NULL, + remote->callbacks.certificate_check, + remote->callbacks.payload); + + return 0; +} + +const git_remote_callbacks *git_remote_get_callbacks(git_remote *remote) +{ + assert(remote); + + return &remote->callbacks; +} + +int git_remote_set_transport( + git_remote *remote, + git_transport_cb transport_cb, + void *payload) +{ + assert(remote); + + if (remote->transport) { + giterr_set(GITERR_NET, "A transport is already bound to this remote"); + return -1; + } + + remote->transport_cb = transport_cb; + remote->transport_cb_payload = payload; + return 0; +} + +const git_transfer_progress* git_remote_stats(git_remote *remote) +{ + assert(remote); + return &remote->stats; +} + +git_remote_autotag_option_t git_remote_autotag(const git_remote *remote) +{ + return remote->download_tags; +} + +void git_remote_set_autotag(git_remote *remote, git_remote_autotag_option_t value) +{ + remote->download_tags = value; +} + +int git_remote_prune_refs(const git_remote *remote) +{ + return remote->prune_refs; +} + +static int rename_remote_config_section( + git_repository *repo, + const char *old_name, + const char *new_name) +{ + git_buf old_section_name = GIT_BUF_INIT, + new_section_name = GIT_BUF_INIT; + int error = -1; + + if (git_buf_printf(&old_section_name, "remote.%s", old_name) < 0) + goto cleanup; + + if (new_name && + (git_buf_printf(&new_section_name, "remote.%s", new_name) < 0)) + goto cleanup; + + error = git_config_rename_section( + repo, + git_buf_cstr(&old_section_name), + new_name ? git_buf_cstr(&new_section_name) : NULL); + +cleanup: + git_buf_free(&old_section_name); + git_buf_free(&new_section_name); + + return error; +} + +struct update_data { + git_config *config; + const char *old_remote_name; + const char *new_remote_name; +}; + +static int update_config_entries_cb( + const git_config_entry *entry, + void *payload) +{ + struct update_data *data = (struct update_data *)payload; + + if (strcmp(entry->value, data->old_remote_name)) + return 0; + + return git_config_set_string( + data->config, entry->name, data->new_remote_name); +} + +static int update_branch_remote_config_entry( + git_repository *repo, + const char *old_name, + const char *new_name) +{ + int error; + struct update_data data = { NULL }; + + if ((error = git_repository_config__weakptr(&data.config, repo)) < 0) + return error; + + data.old_remote_name = old_name; + data.new_remote_name = new_name; + + return git_config_foreach_match( + data.config, "branch\\..+\\.remote", update_config_entries_cb, &data); +} + +static int rename_one_remote_reference( + git_reference *reference_in, + const char *old_remote_name, + const char *new_remote_name) +{ + int error; + git_reference *ref = NULL, *dummy = NULL; + git_buf namespace = GIT_BUF_INIT, old_namespace = GIT_BUF_INIT; + git_buf new_name = GIT_BUF_INIT; + git_buf log_message = GIT_BUF_INIT; + size_t pfx_len; + const char *target; + + if ((error = git_buf_printf(&namespace, GIT_REFS_REMOTES_DIR "%s/", new_remote_name)) < 0) + return error; + + pfx_len = strlen(GIT_REFS_REMOTES_DIR) + strlen(old_remote_name) + 1; + git_buf_puts(&new_name, namespace.ptr); + if ((error = git_buf_puts(&new_name, git_reference_name(reference_in) + pfx_len)) < 0) + goto cleanup; + + if ((error = git_buf_printf(&log_message, + "renamed remote %s to %s", + old_remote_name, new_remote_name)) < 0) + goto cleanup; + + if ((error = git_reference_rename(&ref, reference_in, git_buf_cstr(&new_name), 1, + git_buf_cstr(&log_message))) < 0) + goto cleanup; + + if (git_reference_type(ref) != GIT_REF_SYMBOLIC) + goto cleanup; + + /* Handle refs like origin/HEAD -> origin/master */ + target = git_reference_symbolic_target(ref); + if ((error = git_buf_printf(&old_namespace, GIT_REFS_REMOTES_DIR "%s/", old_remote_name)) < 0) + goto cleanup; + + if (git__prefixcmp(target, old_namespace.ptr)) + goto cleanup; + + git_buf_clear(&new_name); + git_buf_puts(&new_name, namespace.ptr); + if ((error = git_buf_puts(&new_name, target + pfx_len)) < 0) + goto cleanup; + + error = git_reference_symbolic_set_target(&dummy, ref, git_buf_cstr(&new_name), + git_buf_cstr(&log_message)); + + git_reference_free(dummy); + +cleanup: + git_reference_free(reference_in); + git_reference_free(ref); + git_buf_free(&namespace); + git_buf_free(&old_namespace); + git_buf_free(&new_name); + git_buf_free(&log_message); + return error; +} + +static int rename_remote_references( + git_repository *repo, + const char *old_name, + const char *new_name) +{ + int error; + git_buf buf = GIT_BUF_INIT; + git_reference *ref; + git_reference_iterator *iter; + + if ((error = git_buf_printf(&buf, GIT_REFS_REMOTES_DIR "%s/*", old_name)) < 0) + return error; + + error = git_reference_iterator_glob_new(&iter, repo, git_buf_cstr(&buf)); + git_buf_free(&buf); + + if (error < 0) + return error; + + while ((error = git_reference_next(&ref, iter)) == 0) { + if ((error = rename_one_remote_reference(ref, old_name, new_name)) < 0) + break; + } + + git_reference_iterator_free(iter); + + return (error == GIT_ITEROVER) ? 0 : error; +} + +static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const char *new_name) +{ + git_config *config; + git_buf base = GIT_BUF_INIT, var = GIT_BUF_INIT, val = GIT_BUF_INIT; + const git_refspec *spec; + size_t i; + int error = 0; + + if ((error = git_repository_config__weakptr(&config, remote->repo)) < 0) + return error; + + if ((error = git_vector_init(problems, 1, NULL)) < 0) + return error; + + if ((error = git_buf_printf( + &base, "+refs/heads/*:refs/remotes/%s/*", remote->name)) < 0) + return error; + + git_vector_foreach(&remote->refspecs, i, spec) { + if (spec->push) + continue; + + /* Does the dst part of the refspec follow the expected format? */ + if (strcmp(git_buf_cstr(&base), spec->string)) { + char *dup; + + dup = git__strdup(spec->string); + GITERR_CHECK_ALLOC(dup); + + if ((error = git_vector_insert(problems, dup)) < 0) + break; + + continue; + } + + /* If we do want to move it to the new section */ + + git_buf_clear(&val); + git_buf_clear(&var); + + if (git_buf_printf( + &val, "+refs/heads/*:refs/remotes/%s/*", new_name) < 0 || + git_buf_printf(&var, "remote.%s.fetch", new_name) < 0) + { + error = -1; + break; + } + + if ((error = git_config_set_string( + config, git_buf_cstr(&var), git_buf_cstr(&val))) < 0) + break; + } + + git_buf_free(&base); + git_buf_free(&var); + git_buf_free(&val); + + if (error < 0) { + char *str; + git_vector_foreach(problems, i, str) + git__free(str); + + git_vector_free(problems); + } + + return error; +} + +int git_remote_rename(git_strarray *out, git_repository *repo, const char *name, const char *new_name) +{ + int error; + git_vector problem_refspecs = GIT_VECTOR_INIT; + git_remote *remote = NULL; + + assert(out && repo && name && new_name); + + if ((error = git_remote_lookup(&remote, repo, name)) < 0) + return error; + + if ((error = ensure_remote_name_is_valid(new_name)) < 0) + goto cleanup; + + if ((error = ensure_remote_doesnot_exist(repo, new_name)) < 0) + goto cleanup; + + if ((error = rename_remote_config_section(repo, name, new_name)) < 0) + goto cleanup; + + if ((error = update_branch_remote_config_entry(repo, name, new_name)) < 0) + goto cleanup; + + if ((error = rename_remote_references(repo, name, new_name)) < 0) + goto cleanup; + + if ((error = rename_fetch_refspecs(&problem_refspecs, remote, new_name)) < 0) + goto cleanup; + + out->count = problem_refspecs.length; + out->strings = (char **) problem_refspecs.contents; + +cleanup: + if (error < 0) + git_vector_free(&problem_refspecs); + + git_remote_free(remote); + return error; +} + +int git_remote_update_fetchhead(git_remote *remote) +{ + return (remote->update_fetchhead != 0); +} + +void git_remote_set_update_fetchhead(git_remote *remote, int value) +{ + remote->update_fetchhead = (value != 0); +} + +int git_remote_is_valid_name( + const char *remote_name) +{ + git_buf buf = GIT_BUF_INIT; + git_refspec refspec; + int error = -1; + + if (!remote_name || *remote_name == '\0') + return 0; + + git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name); + error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true); + + git_buf_free(&buf); + git_refspec__free(&refspec); + + giterr_clear(); + return error == 0; +} + +git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname) +{ + git_refspec *spec; + size_t i; + + git_vector_foreach(&remote->active_refspecs, i, spec) { + if (spec->push) + continue; + + if (git_refspec_src_matches(spec, refname)) + return spec; + } + + return NULL; +} + +git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname) +{ + git_refspec *spec; + size_t i; + + git_vector_foreach(&remote->active_refspecs, i, spec) { + if (spec->push) + continue; + + if (git_refspec_dst_matches(spec, refname)) + return spec; + } + + return NULL; +} + +void git_remote_clear_refspecs(git_remote *remote) +{ + git_refspec *spec; + size_t i; + + git_vector_foreach(&remote->refspecs, i, spec) { + git_refspec__free(spec); + git__free(spec); + } + git_vector_clear(&remote->refspecs); +} + +int git_remote_add_fetch(git_remote *remote, const char *refspec) +{ + return add_refspec(remote, refspec, true); +} + +int git_remote_add_push(git_remote *remote, const char *refspec) +{ + return add_refspec(remote, refspec, false); +} + +static int set_refspecs(git_remote *remote, git_strarray *array, int push) +{ + git_vector *vec = &remote->refspecs; + git_refspec *spec; + size_t i; + + /* Start by removing any refspecs of the same type */ + for (i = 0; i < vec->length; i++) { + spec = git_vector_get(vec, i); + if (spec->push != push) + continue; + + git_refspec__free(spec); + git__free(spec); + git_vector_remove(vec, i); + i--; + } + + /* And now we add the new ones */ + + for (i = 0; i < array->count; i++) { + if (add_refspec(remote, array->strings[i], !push) < 0) + return -1; + } + + return 0; +} + +int git_remote_set_fetch_refspecs(git_remote *remote, git_strarray *array) +{ + return set_refspecs(remote, array, false); +} + +int git_remote_set_push_refspecs(git_remote *remote, git_strarray *array) +{ + return set_refspecs(remote, array, true); +} + +static int copy_refspecs(git_strarray *array, const git_remote *remote, unsigned int push) +{ + size_t i; + git_vector refspecs; + git_refspec *spec; + char *dup; + + if (git_vector_init(&refspecs, remote->refspecs.length, NULL) < 0) + return -1; + + git_vector_foreach(&remote->refspecs, i, spec) { + if (spec->push != push) + continue; + + if ((dup = git__strdup(spec->string)) == NULL) + goto on_error; + + if (git_vector_insert(&refspecs, dup) < 0) { + git__free(dup); + goto on_error; + } + } + + array->strings = (char **)refspecs.contents; + array->count = refspecs.length; + + return 0; + +on_error: + git_vector_free_deep(&refspecs); + + return -1; +} + +int git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote) +{ + return copy_refspecs(array, remote, false); +} + +int git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote) +{ + return copy_refspecs(array, remote, true); +} + +size_t git_remote_refspec_count(const git_remote *remote) +{ + return remote->refspecs.length; +} + +const git_refspec *git_remote_get_refspec(const git_remote *remote, size_t n) +{ + return git_vector_get(&remote->refspecs, n); +} + +int git_remote_init_callbacks(git_remote_callbacks *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_remote_callbacks, GIT_REMOTE_CALLBACKS_INIT); + return 0; +} + +/* asserts a branch..remote format */ +static const char *name_offset(size_t *len_out, const char *name) +{ + size_t prefix_len; + const char *dot; + + prefix_len = strlen("remote."); + dot = strchr(name + prefix_len, '.'); + + assert(dot); + + *len_out = dot - name - prefix_len; + return name + prefix_len; +} + +static int remove_branch_config_related_entries( + git_repository *repo, + const char *remote_name) +{ + int error; + git_config *config; + git_config_entry *entry; + git_config_iterator *iter; + git_buf buf = GIT_BUF_INIT; + + if ((error = git_repository_config__weakptr(&config, repo)) < 0) + return error; + + if ((error = git_config_iterator_glob_new(&iter, config, "branch\\..+\\.remote")) < 0) + return error; + + /* find any branches with us as upstream and remove that config */ + while ((error = git_config_next(&entry, iter)) == 0) { + const char *branch; + size_t branch_len; + + if (strcmp(remote_name, entry->value)) + continue; + + branch = name_offset(&branch_len, entry->name); + + git_buf_clear(&buf); + if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0) + break; + + if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) + break; + + git_buf_clear(&buf); + if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0) + break; + + if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) + break; + } + + if (error == GIT_ITEROVER) + error = 0; + + git_buf_free(&buf); + git_config_iterator_free(iter); + return error; +} + +static int remove_refs(git_repository *repo, const git_refspec *spec) +{ + git_reference_iterator *iter = NULL; + git_vector refs; + const char *name; + char *dup; + int error; + size_t i; + + if ((error = git_vector_init(&refs, 8, NULL)) < 0) + return error; + + if ((error = git_reference_iterator_new(&iter, repo)) < 0) + goto cleanup; + + while ((error = git_reference_next_name(&name, iter)) == 0) { + if (!git_refspec_dst_matches(spec, name)) + continue; + + dup = git__strdup(name); + if (!dup) { + error = -1; + goto cleanup; + } + + if ((error = git_vector_insert(&refs, dup)) < 0) + goto cleanup; + } + if (error == GIT_ITEROVER) + error = 0; + if (error < 0) + goto cleanup; + + git_vector_foreach(&refs, i, name) { + if ((error = git_reference_remove(repo, name)) < 0) + break; + } + +cleanup: + git_reference_iterator_free(iter); + git_vector_foreach(&refs, i, dup) { + git__free(dup); + } + git_vector_free(&refs); + return error; +} + +static int remove_remote_tracking(git_repository *repo, const char *remote_name) +{ + git_remote *remote; + int error; + size_t i, count; + + /* we want to use what's on the config, regardless of changes to the instance in memory */ + if ((error = git_remote_lookup(&remote, repo, remote_name)) < 0) + return error; + + count = git_remote_refspec_count(remote); + for (i = 0; i < count; i++) { + const git_refspec *refspec = git_remote_get_refspec(remote, i); + + /* shouldn't ever actually happen */ + if (refspec == NULL) + continue; + + if ((error = remove_refs(repo, refspec)) < 0) + break; + } + + git_remote_free(remote); + return error; +} + +int git_remote_delete(git_repository *repo, const char *name) +{ + int error; + + assert(repo && name); + + if ((error = remove_branch_config_related_entries(repo, name)) < 0 || + (error = remove_remote_tracking(repo, name)) < 0 || + (error = rename_remote_config_section(repo, name, NULL)) < 0) + return error; + + return 0; +} + +int git_remote_default_branch(git_buf *out, git_remote *remote) +{ + const git_remote_head **heads; + const git_remote_head *guess = NULL; + const git_oid *head_id; + size_t heads_len, i; + int error; + + assert(out); + + if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0) + return error; + + if (heads_len == 0) + return GIT_ENOTFOUND; + + if (strcmp(heads[0]->name, GIT_HEAD_FILE)) + return GIT_ENOTFOUND; + + git_buf_sanitize(out); + /* the first one must be HEAD so if that has the symref info, we're done */ + if (heads[0]->symref_target) + return git_buf_puts(out, heads[0]->symref_target); + + /* + * If there's no symref information, we have to look over them + * and guess. We return the first match unless the master + * branch is a candidate. Then we return the master branch. + */ + head_id = &heads[0]->oid; + + for (i = 1; i < heads_len; i++) { + if (git_oid_cmp(head_id, &heads[i]->oid)) + continue; + + if (git__prefixcmp(heads[i]->name, GIT_REFS_HEADS_DIR)) + continue; + + if (!guess) { + guess = heads[i]; + continue; + } + + if (!git__strcmp(GIT_REFS_HEADS_MASTER_FILE, heads[i]->name)) { + guess = heads[i]; + break; + } + } + + if (!guess) + return GIT_ENOTFOUND; + + return git_buf_puts(out, guess->name); +} + +int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts) +{ + size_t i; + int error; + git_push *push; + git_refspec *spec; + git_remote_callbacks *cbs; + + assert(remote); + + if (!git_remote_connected(remote) && + (error = git_remote_connect(remote, GIT_DIRECTION_PUSH)) < 0) + goto cleanup; + + free_refspecs(&remote->active_refspecs); + if (dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs) < 0) + goto cleanup; + + if (remote->push) { + git_push_free(remote->push); + remote->push = NULL; + } + + if ((error = git_push_new(&remote->push, remote)) < 0) + return error; + + push = remote->push; + + if (opts && (error = git_push_set_options(push, opts)) < 0) + goto cleanup; + + if (refspecs && refspecs->count > 0) { + for (i = 0; i < refspecs->count; i++) { + if ((error = git_push_add_refspec(push, refspecs->strings[i])) < 0) + goto cleanup; + } + } else { + git_vector_foreach(&remote->refspecs, i, spec) { + if (!spec->push) + continue; + if ((error = git_push_add_refspec(push, spec->string)) < 0) + goto cleanup; + } + } + + cbs = &remote->callbacks; + if ((error = git_push_set_callbacks(push, + cbs->pack_progress, cbs->payload, + cbs->push_transfer_progress, cbs->payload)) < 0) + goto cleanup; + + if ((error = git_push_finish(push)) < 0) + goto cleanup; + + if (cbs->push_update_reference && + (error = git_push_status_foreach(push, cbs->push_update_reference, cbs->payload)) < 0) + goto cleanup; + +cleanup: + return error; +} + +int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts) +{ + int error; + + assert(remote && refspecs); + + if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH)) < 0) + return error; + + if ((error = git_remote_upload(remote, refspecs, opts)) < 0) + return error; + + error = git_remote_update_tips(remote, NULL); + + git_remote_disconnect(remote); + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/remote.h b/deps/libgit2-sys-0.2.17/libgit2/src/remote.h new file mode 100644 index 000000000..a28b565ce --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/remote.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_remote_h__ +#define INCLUDE_remote_h__ + +#include "git2/remote.h" +#include "git2/transport.h" +#include "git2/sys/transport.h" + +#include "refspec.h" +#include "vector.h" + +#define GIT_REMOTE_ORIGIN "origin" + +struct git_remote { + char *name; + char *url; + char *pushurl; + git_vector refs; + git_vector refspecs; + git_vector active_refspecs; + git_vector passive_refspecs; + git_transport_cb transport_cb; + void *transport_cb_payload; + git_transport *transport; + git_repository *repo; + git_push *push; + git_remote_callbacks callbacks; + git_transfer_progress stats; + unsigned int need_pack; + git_remote_autotag_option_t download_tags; + int update_fetchhead; + int prune_refs; + int passed_refspecs; +}; + +const char* git_remote__urlfordirection(struct git_remote *remote, int direction); +int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url); + +git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname); +git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/repo_template.h b/deps/libgit2-sys-0.2.17/libgit2/src/repo_template.h new file mode 100644 index 000000000..099279aa7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/repo_template.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_repo_template_h__ +#define INCLUDE_repo_template_h__ + +#define GIT_OBJECTS_INFO_DIR GIT_OBJECTS_DIR "info/" +#define GIT_OBJECTS_PACK_DIR GIT_OBJECTS_DIR "pack/" + +#define GIT_HOOKS_DIR "hooks/" +#define GIT_HOOKS_DIR_MODE 0777 + +#define GIT_HOOKS_README_FILE GIT_HOOKS_DIR "README.sample" +#define GIT_HOOKS_README_MODE 0777 +#define GIT_HOOKS_README_CONTENT \ +"#!/bin/sh\n"\ +"#\n"\ +"# Place appropriately named executable hook scripts into this directory\n"\ +"# to intercept various actions that git takes. See `git help hooks` for\n"\ +"# more information.\n" + +#define GIT_INFO_DIR "info/" +#define GIT_INFO_DIR_MODE 0777 + +#define GIT_INFO_EXCLUDE_FILE GIT_INFO_DIR "exclude" +#define GIT_INFO_EXCLUDE_MODE 0666 +#define GIT_INFO_EXCLUDE_CONTENT \ +"# File patterns to ignore; see `git help ignore` for more information.\n"\ +"# Lines that start with '#' are comments.\n" + +#define GIT_DESC_FILE "description" +#define GIT_DESC_MODE 0666 +#define GIT_DESC_CONTENT \ +"Unnamed repository; edit this file 'description' to name the repository.\n" + +typedef struct { + const char *path; + mode_t mode; + const char *content; +} repo_template_item; + +static repo_template_item repo_template[] = { + { GIT_OBJECTS_INFO_DIR, GIT_OBJECT_DIR_MODE, NULL }, /* '/objects/info/' */ + { GIT_OBJECTS_PACK_DIR, GIT_OBJECT_DIR_MODE, NULL }, /* '/objects/pack/' */ + { GIT_REFS_HEADS_DIR, GIT_REFS_DIR_MODE, NULL }, /* '/refs/heads/' */ + { GIT_REFS_TAGS_DIR, GIT_REFS_DIR_MODE, NULL }, /* '/refs/tags/' */ + { GIT_HOOKS_DIR, GIT_HOOKS_DIR_MODE, NULL }, /* '/hooks/' */ + { GIT_INFO_DIR, GIT_INFO_DIR_MODE, NULL }, /* '/info/' */ + { GIT_DESC_FILE, GIT_DESC_MODE, GIT_DESC_CONTENT }, + { GIT_HOOKS_README_FILE, GIT_HOOKS_README_MODE, GIT_HOOKS_README_CONTENT }, + { GIT_INFO_EXCLUDE_FILE, GIT_INFO_EXCLUDE_MODE, GIT_INFO_EXCLUDE_CONTENT }, + { NULL, 0, NULL } +}; + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/repository.c b/deps/libgit2-sys-0.2.17/libgit2/src/repository.c new file mode 100644 index 000000000..7cffc9f6b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/repository.c @@ -0,0 +1,2290 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include + +#include "git2/object.h" +#include "git2/refdb.h" +#include "git2/sys/repository.h" + +#include "common.h" +#include "repository.h" +#include "commit.h" +#include "tag.h" +#include "blob.h" +#include "fileops.h" +#include "sysdir.h" +#include "filebuf.h" +#include "index.h" +#include "config.h" +#include "refs.h" +#include "filter.h" +#include "odb.h" +#include "remote.h" +#include "merge.h" +#include "diff_driver.h" +#include "annotated_commit.h" + +#ifdef GIT_WIN32 +# include "win32/w32_util.h" +#endif + +#define GIT_FILE_CONTENT_PREFIX "gitdir:" + +#define GIT_BRANCH_MASTER "master" + +#define GIT_REPO_VERSION 0 + +git_buf git_repository__reserved_names_win32[] = { + { DOT_GIT, 0, CONST_STRLEN(DOT_GIT) }, + { GIT_DIR_SHORTNAME, 0, CONST_STRLEN(GIT_DIR_SHORTNAME) } +}; +size_t git_repository__reserved_names_win32_len = 2; + +git_buf git_repository__reserved_names_posix[] = { + { DOT_GIT, 0, CONST_STRLEN(DOT_GIT) }, +}; +size_t git_repository__reserved_names_posix_len = 1; + +static void set_odb(git_repository *repo, git_odb *odb) +{ + if (odb) { + GIT_REFCOUNT_OWN(odb, repo); + GIT_REFCOUNT_INC(odb); + } + + if ((odb = git__swap(repo->_odb, odb)) != NULL) { + GIT_REFCOUNT_OWN(odb, NULL); + git_odb_free(odb); + } +} + +static void set_refdb(git_repository *repo, git_refdb *refdb) +{ + if (refdb) { + GIT_REFCOUNT_OWN(refdb, repo); + GIT_REFCOUNT_INC(refdb); + } + + if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) { + GIT_REFCOUNT_OWN(refdb, NULL); + git_refdb_free(refdb); + } +} + +static void set_config(git_repository *repo, git_config *config) +{ + if (config) { + GIT_REFCOUNT_OWN(config, repo); + GIT_REFCOUNT_INC(config); + } + + if ((config = git__swap(repo->_config, config)) != NULL) { + GIT_REFCOUNT_OWN(config, NULL); + git_config_free(config); + } + + git_repository__cvar_cache_clear(repo); +} + +static void set_index(git_repository *repo, git_index *index) +{ + if (index) { + GIT_REFCOUNT_OWN(index, repo); + GIT_REFCOUNT_INC(index); + } + + if ((index = git__swap(repo->_index, index)) != NULL) { + GIT_REFCOUNT_OWN(index, NULL); + git_index_free(index); + } +} + +void git_repository__cleanup(git_repository *repo) +{ + assert(repo); + + git_cache_clear(&repo->objects); + git_attr_cache_flush(repo); + git_submodule_cache_free(repo); + + set_config(repo, NULL); + set_index(repo, NULL); + set_odb(repo, NULL); + set_refdb(repo, NULL); +} + +void git_repository_free(git_repository *repo) +{ + size_t i; + + if (repo == NULL) + return; + + git_repository__cleanup(repo); + + git_cache_free(&repo->objects); + + git_diff_driver_registry_free(repo->diff_drivers); + repo->diff_drivers = NULL; + + for (i = 0; i < repo->reserved_names.size; i++) + git_buf_free(git_array_get(repo->reserved_names, i)); + git_array_clear(repo->reserved_names); + + git__free(repo->path_gitlink); + git__free(repo->path_repository); + git__free(repo->workdir); + git__free(repo->namespace); + git__free(repo->ident_name); + git__free(repo->ident_email); + + git__memzero(repo, sizeof(*repo)); + git__free(repo); +} + +/* + * Git repository open methods + * + * Open a repository object from its path + */ +static bool valid_repository_path(git_buf *repository_path) +{ + /* Check OBJECTS_DIR first, since it will generate the longest path name */ + if (git_path_contains_dir(repository_path, GIT_OBJECTS_DIR) == false) + return false; + + /* Ensure HEAD file exists */ + if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false) + return false; + + if (git_path_contains_dir(repository_path, GIT_REFS_DIR) == false) + return false; + + return true; +} + +static git_repository *repository_alloc(void) +{ + git_repository *repo = git__calloc(1, sizeof(git_repository)); + + if (repo == NULL || + git_cache_init(&repo->objects) < 0) + goto on_error; + + git_array_init_to_size(repo->reserved_names, 4); + if (!repo->reserved_names.ptr) + goto on_error; + + /* set all the entries in the cvar cache to `unset` */ + git_repository__cvar_cache_clear(repo); + + return repo; + +on_error: + if (repo) + git_cache_free(&repo->objects); + + git__free(repo); + return NULL; +} + +int git_repository_new(git_repository **out) +{ + git_repository *repo; + + *out = repo = repository_alloc(); + GITERR_CHECK_ALLOC(repo); + + repo->is_bare = 1; + + return 0; +} + +static int load_config_data(git_repository *repo, const git_config *config) +{ + int is_bare; + + /* Try to figure out if it's bare, default to non-bare if it's not set */ + if (git_config_get_bool(&is_bare, config, "core.bare") < 0) + repo->is_bare = 0; + else + repo->is_bare = is_bare; + + return 0; +} + +static int load_workdir(git_repository *repo, git_config *config, git_buf *parent_path) +{ + int error; + git_config_entry *ce; + git_buf worktree = GIT_BUF_INIT; + + if (repo->is_bare) + return 0; + + if ((error = git_config__lookup_entry( + &ce, config, "core.worktree", false)) < 0) + return error; + + if (ce && ce->value) { + if ((error = git_path_prettify_dir( + &worktree, ce->value, repo->path_repository)) < 0) + goto cleanup; + + repo->workdir = git_buf_detach(&worktree); + } + else if (parent_path && git_path_isdir(parent_path->ptr)) + repo->workdir = git_buf_detach(parent_path); + else { + if (git_path_dirname_r(&worktree, repo->path_repository) < 0 || + git_path_to_dir(&worktree) < 0) { + error = -1; + goto cleanup; + } + + repo->workdir = git_buf_detach(&worktree); + } + + GITERR_CHECK_ALLOC(repo->workdir); +cleanup: + git_config_entry_free(ce); + return error; +} + +/* + * This function returns furthest offset into path where a ceiling dir + * is found, so we can stop processing the path at that point. + * + * Note: converting this to use git_bufs instead of GIT_PATH_MAX buffers on + * the stack could remove directories name limits, but at the cost of doing + * repeated malloc/frees inside the loop below, so let's not do it now. + */ +static int find_ceiling_dir_offset( + const char *path, + const char *ceiling_directories) +{ + char buf[GIT_PATH_MAX + 1]; + char buf2[GIT_PATH_MAX + 1]; + const char *ceil, *sep; + size_t len, max_len = 0, min_len; + + assert(path); + + min_len = (size_t)(git_path_root(path) + 1); + + if (ceiling_directories == NULL || min_len == 0) + return (int)min_len; + + for (sep = ceil = ceiling_directories; *sep; ceil = sep + 1) { + for (sep = ceil; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++); + len = sep - ceil; + + if (len == 0 || len >= sizeof(buf) || git_path_root(ceil) == -1) + continue; + + strncpy(buf, ceil, len); + buf[len] = '\0'; + + if (p_realpath(buf, buf2) == NULL) + continue; + + len = strlen(buf2); + if (len > 0 && buf2[len-1] == '/') + buf[--len] = '\0'; + + if (!strncmp(path, buf2, len) && + (path[len] == '/' || !path[len]) && + len > max_len) + { + max_len = len; + } + } + + return (int)(max_len <= min_len ? min_len : max_len); +} + +/* + * Read the contents of `file_path` and set `path_out` to the repo dir that + * it points to. Before calling, set `path_out` to the base directory that + * should be used if the contents of `file_path` are a relative path. + */ +static int read_gitfile(git_buf *path_out, const char *file_path) +{ + int error = 0; + git_buf file = GIT_BUF_INIT; + size_t prefix_len = strlen(GIT_FILE_CONTENT_PREFIX); + + assert(path_out && file_path); + + if (git_futils_readbuffer(&file, file_path) < 0) + return -1; + + git_buf_rtrim(&file); + /* apparently on Windows, some people use backslashes in paths */ + git_path_mkposix(file.ptr); + + if (git_buf_len(&file) <= prefix_len || + memcmp(git_buf_cstr(&file), GIT_FILE_CONTENT_PREFIX, prefix_len) != 0) + { + giterr_set(GITERR_REPOSITORY, + "The `.git` file at '%s' is malformed", file_path); + error = -1; + } + else if ((error = git_path_dirname_r(path_out, file_path)) >= 0) { + const char *gitlink = git_buf_cstr(&file) + prefix_len; + while (*gitlink && git__isspace(*gitlink)) gitlink++; + + error = git_path_prettify_dir( + path_out, gitlink, git_buf_cstr(path_out)); + } + + git_buf_free(&file); + return error; +} + +static int find_repo( + git_buf *repo_path, + git_buf *parent_path, + git_buf *link_path, + const char *start_path, + uint32_t flags, + const char *ceiling_dirs) +{ + int error; + git_buf path = GIT_BUF_INIT; + struct stat st; + dev_t initial_device = 0; + bool try_with_dot_git = ((flags & GIT_REPOSITORY_OPEN_BARE) != 0); + int ceiling_offset; + + git_buf_free(repo_path); + + if ((error = git_path_prettify(&path, start_path, NULL)) < 0) + return error; + + ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs); + + if (!try_with_dot_git && + (error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0) + return error; + + while (!error && !git_buf_len(repo_path)) { + if (p_stat(path.ptr, &st) == 0) { + /* check that we have not crossed device boundaries */ + if (initial_device == 0) + initial_device = st.st_dev; + else if (st.st_dev != initial_device && + (flags & GIT_REPOSITORY_OPEN_CROSS_FS) == 0) + break; + + if (S_ISDIR(st.st_mode)) { + if (valid_repository_path(&path)) { + git_path_to_dir(&path); + git_buf_set(repo_path, path.ptr, path.size); + break; + } + } + else if (S_ISREG(st.st_mode)) { + git_buf repo_link = GIT_BUF_INIT; + + if (!(error = read_gitfile(&repo_link, path.ptr))) { + if (valid_repository_path(&repo_link)) { + git_buf_swap(repo_path, &repo_link); + + if (link_path) + error = git_buf_put(link_path, + path.ptr, path.size); + } + + git_buf_free(&repo_link); + break; + } + git_buf_free(&repo_link); + } + } + + /* move up one directory level */ + if (git_path_dirname_r(&path, path.ptr) < 0) { + error = -1; + break; + } + + if (try_with_dot_git) { + /* if we tried original dir with and without .git AND either hit + * directory ceiling or NO_SEARCH was requested, then be done. + */ + if (path.ptr[ceiling_offset] == '\0' || + (flags & GIT_REPOSITORY_OPEN_NO_SEARCH) != 0) + break; + /* otherwise look first for .git item */ + error = git_buf_joinpath(&path, path.ptr, DOT_GIT); + } + try_with_dot_git = !try_with_dot_git; + } + + if (!error && parent_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) { + if (!git_buf_len(repo_path)) + git_buf_clear(parent_path); + else { + git_path_dirname_r(parent_path, path.ptr); + git_path_to_dir(parent_path); + } + if (git_buf_oom(parent_path)) + return -1; + } + + git_buf_free(&path); + + if (!git_buf_len(repo_path) && !error) { + giterr_set(GITERR_REPOSITORY, + "Could not find repository from '%s'", start_path); + error = GIT_ENOTFOUND; + } + + return error; +} + +int git_repository_open_bare( + git_repository **repo_ptr, + const char *bare_path) +{ + int error; + git_buf path = GIT_BUF_INIT; + git_repository *repo = NULL; + + if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0) + return error; + + if (!valid_repository_path(&path)) { + git_buf_free(&path); + giterr_set(GITERR_REPOSITORY, "Path is not a repository: %s", bare_path); + return GIT_ENOTFOUND; + } + + repo = repository_alloc(); + GITERR_CHECK_ALLOC(repo); + + repo->path_repository = git_buf_detach(&path); + GITERR_CHECK_ALLOC(repo->path_repository); + + /* of course we're bare! */ + repo->is_bare = 1; + repo->workdir = NULL; + + *repo_ptr = repo; + return 0; +} + +int git_repository_open_ext( + git_repository **repo_ptr, + const char *start_path, + unsigned int flags, + const char *ceiling_dirs) +{ + int error; + git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT, + link_path = GIT_BUF_INIT; + git_repository *repo; + + if (repo_ptr) + *repo_ptr = NULL; + + error = find_repo( + &path, &parent, &link_path, start_path, flags, ceiling_dirs); + + if (error < 0 || !repo_ptr) + return error; + + repo = repository_alloc(); + GITERR_CHECK_ALLOC(repo); + + repo->path_repository = git_buf_detach(&path); + GITERR_CHECK_ALLOC(repo->path_repository); + + if (link_path.size) { + repo->path_gitlink = git_buf_detach(&link_path); + GITERR_CHECK_ALLOC(repo->path_gitlink); + } + + if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) + repo->is_bare = 1; + else { + git_config *config = NULL; + + if ((error = git_repository_config_snapshot(&config, repo)) < 0 || + (error = load_config_data(repo, config)) < 0 || + (error = load_workdir(repo, config, &parent)) < 0) + git_repository_free(repo); + + git_config_free(config); + } + + if (!error) + *repo_ptr = repo; + git_buf_free(&parent); + + return error; +} + +int git_repository_open(git_repository **repo_out, const char *path) +{ + return git_repository_open_ext( + repo_out, path, GIT_REPOSITORY_OPEN_NO_SEARCH, NULL); +} + +int git_repository_wrap_odb(git_repository **repo_out, git_odb *odb) +{ + git_repository *repo; + + repo = repository_alloc(); + GITERR_CHECK_ALLOC(repo); + + git_repository_set_odb(repo, odb); + *repo_out = repo; + + return 0; +} + +int git_repository_discover( + git_buf *out, + const char *start_path, + int across_fs, + const char *ceiling_dirs) +{ + uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0; + + assert(start_path); + + git_buf_sanitize(out); + + return find_repo(out, NULL, NULL, start_path, flags, ceiling_dirs); +} + +static int load_config( + git_config **out, + git_repository *repo, + const char *global_config_path, + const char *xdg_config_path, + const char *system_config_path) +{ + int error; + git_buf config_path = GIT_BUF_INIT; + git_config *cfg = NULL; + + assert(repo && out); + + if ((error = git_config_new(&cfg)) < 0) + return error; + + error = git_buf_joinpath( + &config_path, repo->path_repository, GIT_CONFIG_FILENAME_INREPO); + if (error < 0) + goto on_error; + + if ((error = git_config_add_file_ondisk( + cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0 && + error != GIT_ENOTFOUND) + goto on_error; + + git_buf_free(&config_path); + + if (global_config_path != NULL && + (error = git_config_add_file_ondisk( + cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, 0)) < 0 && + error != GIT_ENOTFOUND) + goto on_error; + + if (xdg_config_path != NULL && + (error = git_config_add_file_ondisk( + cfg, xdg_config_path, GIT_CONFIG_LEVEL_XDG, 0)) < 0 && + error != GIT_ENOTFOUND) + goto on_error; + + if (system_config_path != NULL && + (error = git_config_add_file_ondisk( + cfg, system_config_path, GIT_CONFIG_LEVEL_SYSTEM, 0)) < 0 && + error != GIT_ENOTFOUND) + goto on_error; + + giterr_clear(); /* clear any lingering ENOTFOUND errors */ + + *out = cfg; + return 0; + +on_error: + git_buf_free(&config_path); + git_config_free(cfg); + *out = NULL; + return error; +} + +static const char *path_unless_empty(git_buf *buf) +{ + return git_buf_len(buf) > 0 ? git_buf_cstr(buf) : NULL; +} + +int git_repository_config__weakptr(git_config **out, git_repository *repo) +{ + int error = 0; + + if (repo->_config == NULL) { + git_buf global_buf = GIT_BUF_INIT; + git_buf xdg_buf = GIT_BUF_INIT; + git_buf system_buf = GIT_BUF_INIT; + git_config *config; + + git_config_find_global(&global_buf); + git_config_find_xdg(&xdg_buf); + git_config_find_system(&system_buf); + + /* If there is no global file, open a backend for it anyway */ + if (git_buf_len(&global_buf) == 0) + git_config__global_location(&global_buf); + + error = load_config( + &config, repo, + path_unless_empty(&global_buf), + path_unless_empty(&xdg_buf), + path_unless_empty(&system_buf)); + if (!error) { + GIT_REFCOUNT_OWN(config, repo); + + config = git__compare_and_swap(&repo->_config, NULL, config); + if (config != NULL) { + GIT_REFCOUNT_OWN(config, NULL); + git_config_free(config); + } + } + + git_buf_free(&global_buf); + git_buf_free(&xdg_buf); + git_buf_free(&system_buf); + } + + *out = repo->_config; + return error; +} + +int git_repository_config(git_config **out, git_repository *repo) +{ + if (git_repository_config__weakptr(out, repo) < 0) + return -1; + + GIT_REFCOUNT_INC(*out); + return 0; +} + +int git_repository_config_snapshot(git_config **out, git_repository *repo) +{ + int error; + git_config *weak; + + if ((error = git_repository_config__weakptr(&weak, repo)) < 0) + return error; + + return git_config_snapshot(out, weak); +} + +void git_repository_set_config(git_repository *repo, git_config *config) +{ + assert(repo && config); + set_config(repo, config); +} + +int git_repository_odb__weakptr(git_odb **out, git_repository *repo) +{ + int error = 0; + + assert(repo && out); + + if (repo->_odb == NULL) { + git_buf odb_path = GIT_BUF_INIT; + git_odb *odb; + + if ((error = git_buf_joinpath(&odb_path, repo->path_repository, GIT_OBJECTS_DIR)) < 0) + return error; + + error = git_odb_open(&odb, odb_path.ptr); + if (!error) { + GIT_REFCOUNT_OWN(odb, repo); + + odb = git__compare_and_swap(&repo->_odb, NULL, odb); + if (odb != NULL) { + GIT_REFCOUNT_OWN(odb, NULL); + git_odb_free(odb); + } + } + + git_buf_free(&odb_path); + } + + *out = repo->_odb; + return error; +} + +int git_repository_odb(git_odb **out, git_repository *repo) +{ + if (git_repository_odb__weakptr(out, repo) < 0) + return -1; + + GIT_REFCOUNT_INC(*out); + return 0; +} + +void git_repository_set_odb(git_repository *repo, git_odb *odb) +{ + assert(repo && odb); + set_odb(repo, odb); +} + +int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo) +{ + int error = 0; + + assert(out && repo); + + if (repo->_refdb == NULL) { + git_refdb *refdb; + + error = git_refdb_open(&refdb, repo); + if (!error) { + GIT_REFCOUNT_OWN(refdb, repo); + + refdb = git__compare_and_swap(&repo->_refdb, NULL, refdb); + if (refdb != NULL) { + GIT_REFCOUNT_OWN(refdb, NULL); + git_refdb_free(refdb); + } + } + } + + *out = repo->_refdb; + return error; +} + +int git_repository_refdb(git_refdb **out, git_repository *repo) +{ + if (git_repository_refdb__weakptr(out, repo) < 0) + return -1; + + GIT_REFCOUNT_INC(*out); + return 0; +} + +void git_repository_set_refdb(git_repository *repo, git_refdb *refdb) +{ + assert(repo && refdb); + set_refdb(repo, refdb); +} + +int git_repository_index__weakptr(git_index **out, git_repository *repo) +{ + int error = 0; + + assert(out && repo); + + if (repo->_index == NULL) { + git_buf index_path = GIT_BUF_INIT; + git_index *index; + + if ((error = git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE)) < 0) + return error; + + error = git_index_open(&index, index_path.ptr); + if (!error) { + GIT_REFCOUNT_OWN(index, repo); + + index = git__compare_and_swap(&repo->_index, NULL, index); + if (index != NULL) { + GIT_REFCOUNT_OWN(index, NULL); + git_index_free(index); + } + + error = git_index_set_caps(repo->_index, GIT_INDEXCAP_FROM_OWNER); + } + + git_buf_free(&index_path); + } + + *out = repo->_index; + return error; +} + +int git_repository_index(git_index **out, git_repository *repo) +{ + if (git_repository_index__weakptr(out, repo) < 0) + return -1; + + GIT_REFCOUNT_INC(*out); + return 0; +} + +void git_repository_set_index(git_repository *repo, git_index *index) +{ + assert(repo); + set_index(repo, index); +} + +int git_repository_set_namespace(git_repository *repo, const char *namespace) +{ + git__free(repo->namespace); + + if (namespace == NULL) { + repo->namespace = NULL; + return 0; + } + + return (repo->namespace = git__strdup(namespace)) ? 0 : -1; +} + +const char *git_repository_get_namespace(git_repository *repo) +{ + return repo->namespace; +} + +#ifdef GIT_WIN32 +static int reserved_names_add8dot3(git_repository *repo, const char *path) +{ + char *name = git_win32_path_8dot3_name(path); + const char *def = GIT_DIR_SHORTNAME; + size_t name_len, def_len = CONST_STRLEN(GIT_DIR_SHORTNAME); + git_buf *buf; + + if (!name) + return 0; + + name_len = strlen(name); + + if (name_len == def_len && memcmp(name, def, def_len) == 0) { + git__free(name); + return 0; + } + + if ((buf = git_array_alloc(repo->reserved_names)) == NULL) + return -1; + + git_buf_attach(buf, name, name_len); + return true; +} + +bool git_repository__reserved_names( + git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs) +{ + GIT_UNUSED(include_ntfs); + + if (repo->reserved_names.size == 0) { + git_buf *buf; + size_t i; + + /* Add the static defaults */ + for (i = 0; i < git_repository__reserved_names_win32_len; i++) { + if ((buf = git_array_alloc(repo->reserved_names)) == NULL) + goto on_error; + + buf->ptr = git_repository__reserved_names_win32[i].ptr; + buf->size = git_repository__reserved_names_win32[i].size; + } + + /* Try to add any repo-specific reserved names */ + if (!repo->is_bare) { + const char *reserved_path = repo->path_gitlink ? + repo->path_gitlink : repo->path_repository; + + if (reserved_names_add8dot3(repo, reserved_path) < 0) + goto on_error; + } + } + + *out = repo->reserved_names.ptr; + *outlen = repo->reserved_names.size; + + return true; + + /* Always give good defaults, even on OOM */ +on_error: + *out = git_repository__reserved_names_win32; + *outlen = git_repository__reserved_names_win32_len; + + return false; +} +#else +bool git_repository__reserved_names( + git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs) +{ + GIT_UNUSED(repo); + + if (include_ntfs) { + *out = git_repository__reserved_names_win32; + *outlen = git_repository__reserved_names_win32_len; + } else { + *out = git_repository__reserved_names_posix; + *outlen = git_repository__reserved_names_posix_len; + } + + return true; +} +#endif + +static int check_repositoryformatversion(git_config *config) +{ + int version; + + if (git_config_get_int32(&version, config, "core.repositoryformatversion") < 0) + return -1; + + if (GIT_REPO_VERSION < version) { + giterr_set(GITERR_REPOSITORY, + "Unsupported repository version %d. Only versions up to %d are supported.", + version, GIT_REPO_VERSION); + return -1; + } + + return 0; +} + +static int repo_init_create_head(const char *git_dir, const char *ref_name) +{ + git_buf ref_path = GIT_BUF_INIT; + git_filebuf ref = GIT_FILEBUF_INIT; + const char *fmt; + + if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 || + git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE) < 0) + goto fail; + + if (!ref_name) + ref_name = GIT_BRANCH_MASTER; + + if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0) + fmt = "ref: %s\n"; + else + fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n"; + + if (git_filebuf_printf(&ref, fmt, ref_name) < 0 || + git_filebuf_commit(&ref) < 0) + goto fail; + + git_buf_free(&ref_path); + return 0; + +fail: + git_buf_free(&ref_path); + git_filebuf_cleanup(&ref); + return -1; +} + +static bool is_chmod_supported(const char *file_path) +{ + struct stat st1, st2; + + if (p_stat(file_path, &st1) < 0) + return false; + + if (p_chmod(file_path, st1.st_mode ^ S_IXUSR) < 0) + return false; + + if (p_stat(file_path, &st2) < 0) + return false; + + return (st1.st_mode != st2.st_mode); +} + +static bool is_filesystem_case_insensitive(const char *gitdir_path) +{ + git_buf path = GIT_BUF_INIT; + int is_insensitive = -1; + + if (!git_buf_joinpath(&path, gitdir_path, "CoNfIg")) + is_insensitive = git_path_exists(git_buf_cstr(&path)); + + git_buf_free(&path); + return is_insensitive; +} + +static bool are_symlinks_supported(const char *wd_path) +{ + git_buf path = GIT_BUF_INIT; + int fd; + struct stat st; + int symlinks_supported = -1; + + if ((fd = git_futils_mktmp(&path, wd_path, 0666)) < 0 || + p_close(fd) < 0 || + p_unlink(path.ptr) < 0 || + p_symlink("testing", path.ptr) < 0 || + p_lstat(path.ptr, &st) < 0) + symlinks_supported = false; + else + symlinks_supported = (S_ISLNK(st.st_mode) != 0); + + (void)p_unlink(path.ptr); + git_buf_free(&path); + + return symlinks_supported; +} + +static int create_empty_file(const char *path, mode_t mode) +{ + int fd; + + if ((fd = p_creat(path, mode)) < 0) { + giterr_set(GITERR_OS, "Error while creating '%s'", path); + return -1; + } + + if (p_close(fd) < 0) { + giterr_set(GITERR_OS, "Error while closing '%s'", path); + return -1; + } + + return 0; +} + +static int repo_local_config( + git_config **out, + git_buf *config_dir, + git_repository *repo, + const char *repo_dir) +{ + int error = 0; + git_config *parent; + const char *cfg_path; + + if (git_buf_joinpath(config_dir, repo_dir, GIT_CONFIG_FILENAME_INREPO) < 0) + return -1; + cfg_path = git_buf_cstr(config_dir); + + /* make LOCAL config if missing */ + if (!git_path_isfile(cfg_path) && + (error = create_empty_file(cfg_path, GIT_CONFIG_FILE_MODE)) < 0) + return error; + + /* if no repo, just open that file directly */ + if (!repo) + return git_config_open_ondisk(out, cfg_path); + + /* otherwise, open parent config and get that level */ + if ((error = git_repository_config__weakptr(&parent, repo)) < 0) + return error; + + if (git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL) < 0) { + giterr_clear(); + + if (!(error = git_config_add_file_ondisk( + parent, cfg_path, GIT_CONFIG_LEVEL_LOCAL, false))) + error = git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL); + } + + git_config_free(parent); + + return error; +} + +static int repo_init_fs_configs( + git_config *cfg, + const char *cfg_path, + const char *repo_dir, + const char *work_dir, + bool update_ignorecase) +{ + int error = 0; + + if (!work_dir) + work_dir = repo_dir; + + if ((error = git_config_set_bool( + cfg, "core.filemode", is_chmod_supported(cfg_path))) < 0) + return error; + + if (!are_symlinks_supported(work_dir)) { + if ((error = git_config_set_bool(cfg, "core.symlinks", false)) < 0) + return error; + } else if (git_config_delete_entry(cfg, "core.symlinks") < 0) + giterr_clear(); + + if (update_ignorecase) { + if (is_filesystem_case_insensitive(repo_dir)) { + if ((error = git_config_set_bool(cfg, "core.ignorecase", true)) < 0) + return error; + } else if (git_config_delete_entry(cfg, "core.ignorecase") < 0) + giterr_clear(); + } + +#ifdef GIT_USE_ICONV + if ((error = git_config_set_bool( + cfg, "core.precomposeunicode", + git_path_does_fs_decompose_unicode(work_dir))) < 0) + return error; + /* on non-iconv platforms, don't even set core.precomposeunicode */ +#endif + + return 0; +} + +static int repo_init_config( + const char *repo_dir, + const char *work_dir, + uint32_t flags, + uint32_t mode) +{ + int error = 0; + git_buf cfg_path = GIT_BUF_INIT, worktree_path = GIT_BUF_INIT; + git_config *config = NULL; + bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0); + bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0); + + if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0) + goto cleanup; + + if (is_reinit && (error = check_repositoryformatversion(config)) < 0) + goto cleanup; + +#define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \ + if ((error = git_config_set_##TYPE(config, NAME, VAL)) < 0) \ + goto cleanup; } while (0) + + SET_REPO_CONFIG(bool, "core.bare", is_bare); + SET_REPO_CONFIG(int32, "core.repositoryformatversion", GIT_REPO_VERSION); + + if ((error = repo_init_fs_configs( + config, cfg_path.ptr, repo_dir, work_dir, !is_reinit)) < 0) + goto cleanup; + + if (!is_bare) { + SET_REPO_CONFIG(bool, "core.logallrefupdates", true); + + if (!(flags & GIT_REPOSITORY_INIT__NATURAL_WD)) { + if ((error = git_buf_sets(&worktree_path, work_dir)) < 0) + goto cleanup; + + if ((flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK)) + if ((error = git_path_make_relative(&worktree_path, repo_dir)) < 0) + goto cleanup; + + SET_REPO_CONFIG(string, "core.worktree", worktree_path.ptr); + } else if (is_reinit) { + if (git_config_delete_entry(config, "core.worktree") < 0) + giterr_clear(); + } + } + + if (mode == GIT_REPOSITORY_INIT_SHARED_GROUP) { + SET_REPO_CONFIG(int32, "core.sharedrepository", 1); + SET_REPO_CONFIG(bool, "receive.denyNonFastforwards", true); + } + else if (mode == GIT_REPOSITORY_INIT_SHARED_ALL) { + SET_REPO_CONFIG(int32, "core.sharedrepository", 2); + SET_REPO_CONFIG(bool, "receive.denyNonFastforwards", true); + } + +cleanup: + git_buf_free(&cfg_path); + git_buf_free(&worktree_path); + git_config_free(config); + + return error; +} + +static int repo_reinit_submodule_fs(git_submodule *sm, const char *n, void *p) +{ + git_repository *smrepo = NULL; + GIT_UNUSED(n); GIT_UNUSED(p); + + if (git_submodule_open(&smrepo, sm) < 0 || + git_repository_reinit_filesystem(smrepo, true) < 0) + giterr_clear(); + git_repository_free(smrepo); + + return 0; +} + +int git_repository_reinit_filesystem(git_repository *repo, int recurse) +{ + int error = 0; + git_buf path = GIT_BUF_INIT; + git_config *config = NULL; + const char *repo_dir = git_repository_path(repo); + + if (!(error = repo_local_config(&config, &path, repo, repo_dir))) + error = repo_init_fs_configs( + config, path.ptr, repo_dir, git_repository_workdir(repo), true); + + git_config_free(config); + git_buf_free(&path); + + git_repository__cvar_cache_clear(repo); + + if (!repo->is_bare && recurse) + (void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL); + + return error; +} + +static int repo_write_template( + const char *git_dir, + bool allow_overwrite, + const char *file, + mode_t mode, + bool hidden, + const char *content) +{ + git_buf path = GIT_BUF_INIT; + int fd, error = 0, flags; + + if (git_buf_joinpath(&path, git_dir, file) < 0) + return -1; + + if (allow_overwrite) + flags = O_WRONLY | O_CREAT | O_TRUNC; + else + flags = O_WRONLY | O_CREAT | O_EXCL; + + fd = p_open(git_buf_cstr(&path), flags, mode); + + if (fd >= 0) { + error = p_write(fd, content, strlen(content)); + + p_close(fd); + } + else if (errno != EEXIST) + error = fd; + +#ifdef GIT_WIN32 + if (!error && hidden) { + if (git_win32__sethidden(path.ptr) < 0) + error = -1; + } +#else + GIT_UNUSED(hidden); +#endif + + git_buf_free(&path); + + if (error) + giterr_set(GITERR_OS, + "Failed to initialize repository with template '%s'", file); + + return error; +} + +static int repo_write_gitlink( + const char *in_dir, const char *to_repo, bool use_relative_path) +{ + int error; + git_buf buf = GIT_BUF_INIT; + git_buf path_to_repo = GIT_BUF_INIT; + struct stat st; + + git_path_dirname_r(&buf, to_repo); + git_path_to_dir(&buf); + if (git_buf_oom(&buf)) + return -1; + + /* don't write gitlink to natural workdir */ + if (git__suffixcmp(to_repo, "/" DOT_GIT "/") == 0 && + strcmp(in_dir, buf.ptr) == 0) + { + error = GIT_PASSTHROUGH; + goto cleanup; + } + + if ((error = git_buf_joinpath(&buf, in_dir, DOT_GIT)) < 0) + goto cleanup; + + if (!p_stat(buf.ptr, &st) && !S_ISREG(st.st_mode)) { + giterr_set(GITERR_REPOSITORY, + "Cannot overwrite gitlink file into path '%s'", in_dir); + error = GIT_EEXISTS; + goto cleanup; + } + + git_buf_clear(&buf); + + error = git_buf_sets(&path_to_repo, to_repo); + + if (!error && use_relative_path) + error = git_path_make_relative(&path_to_repo, in_dir); + + if (!error) + error = git_buf_join(&buf, ' ', GIT_FILE_CONTENT_PREFIX, path_to_repo.ptr); + + if (!error) + error = repo_write_template(in_dir, true, DOT_GIT, 0666, true, buf.ptr); + +cleanup: + git_buf_free(&buf); + git_buf_free(&path_to_repo); + return error; +} + +static mode_t pick_dir_mode(git_repository_init_options *opts) +{ + if (opts->mode == GIT_REPOSITORY_INIT_SHARED_UMASK) + return 0777; + if (opts->mode == GIT_REPOSITORY_INIT_SHARED_GROUP) + return (0775 | S_ISGID); + if (opts->mode == GIT_REPOSITORY_INIT_SHARED_ALL) + return (0777 | S_ISGID); + return opts->mode; +} + +#include "repo_template.h" + +static int repo_init_structure( + const char *repo_dir, + const char *work_dir, + git_repository_init_options *opts) +{ + int error = 0; + repo_template_item *tpl; + bool external_tpl = + ((opts->flags & GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE) != 0); + mode_t dmode = pick_dir_mode(opts); + bool chmod = opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK; + + /* Hide the ".git" directory */ +#ifdef GIT_WIN32 + if ((opts->flags & GIT_REPOSITORY_INIT__HAS_DOTGIT) != 0) { + if (git_win32__sethidden(repo_dir) < 0) { + giterr_set(GITERR_OS, + "Failed to mark Git repository folder as hidden"); + return -1; + } + } +#endif + + /* Create the .git gitlink if appropriate */ + if ((opts->flags & GIT_REPOSITORY_INIT_BARE) == 0 && + (opts->flags & GIT_REPOSITORY_INIT__NATURAL_WD) == 0) + { + if (repo_write_gitlink(work_dir, repo_dir, opts->flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK) < 0) + return -1; + } + + /* Copy external template if requested */ + if (external_tpl) { + git_config *cfg = NULL; + const char *tdir = NULL; + bool default_template = false; + git_buf template_buf = GIT_BUF_INIT; + + if (opts->template_path) + tdir = opts->template_path; + else if ((error = git_config_open_default(&cfg)) >= 0) { + if (!git_config_get_path(&template_buf, cfg, "init.templatedir")) + tdir = template_buf.ptr; + giterr_clear(); + } + + if (!tdir) { + if (!(error = git_sysdir_find_template_dir(&template_buf))) + tdir = template_buf.ptr; + default_template = true; + } + + if (tdir) { + uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_SIMPLE_TO_MODE; + if (opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK) + cpflags |= GIT_CPDIR_CHMOD_DIRS; + error = git_futils_cp_r(tdir, repo_dir, cpflags, dmode); + } + + git_buf_free(&template_buf); + git_config_free(cfg); + + if (error < 0) { + if (!default_template) + return error; + + /* if template was default, ignore error and use internal */ + giterr_clear(); + external_tpl = false; + error = 0; + } + } + + /* Copy internal template + * - always ensure existence of dirs + * - only create files if no external template was specified + */ + for (tpl = repo_template; !error && tpl->path; ++tpl) { + if (!tpl->content) { + uint32_t mkdir_flags = GIT_MKDIR_PATH; + if (chmod) + mkdir_flags |= GIT_MKDIR_CHMOD; + + error = git_futils_mkdir( + tpl->path, repo_dir, dmode, mkdir_flags); + } + else if (!external_tpl) { + const char *content = tpl->content; + + if (opts->description && strcmp(tpl->path, GIT_DESC_FILE) == 0) + content = opts->description; + + error = repo_write_template( + repo_dir, false, tpl->path, tpl->mode, false, content); + } + } + + return error; +} + +static int mkdir_parent(git_buf *buf, uint32_t mode, bool skip2) +{ + /* When making parent directories during repository initialization + * don't try to set gid or grant world write access + */ + return git_futils_mkdir( + buf->ptr, NULL, mode & ~(S_ISGID | 0002), + GIT_MKDIR_PATH | GIT_MKDIR_VERIFY_DIR | + (skip2 ? GIT_MKDIR_SKIP_LAST2 : GIT_MKDIR_SKIP_LAST)); +} + +static int repo_init_directories( + git_buf *repo_path, + git_buf *wd_path, + const char *given_repo, + git_repository_init_options *opts) +{ + int error = 0; + bool is_bare, add_dotgit, has_dotgit, natural_wd; + mode_t dirmode; + + /* There are three possible rules for what we are allowed to create: + * - MKPATH means anything we need + * - MKDIR means just the .git directory and its parent and the workdir + * - Neither means only the .git directory can be created + * + * There are 5 "segments" of path that we might need to deal with: + * 1. The .git directory + * 2. The parent of the .git directory + * 3. Everything above the parent of the .git directory + * 4. The working directory (often the same as #2) + * 5. Everything above the working directory (often the same as #3) + * + * For all directories created, we start with the init_mode value for + * permissions and then strip off bits in some cases: + * + * For MKPATH, we create #3 (and #5) paths without S_ISGID or S_IWOTH + * For MKPATH and MKDIR, we create #2 (and #4) without S_ISGID + * For all rules, we create #1 using the untouched init_mode + */ + + /* set up repo path */ + + is_bare = ((opts->flags & GIT_REPOSITORY_INIT_BARE) != 0); + + add_dotgit = + (opts->flags & GIT_REPOSITORY_INIT_NO_DOTGIT_DIR) == 0 && + !is_bare && + git__suffixcmp(given_repo, "/" DOT_GIT) != 0 && + git__suffixcmp(given_repo, "/" GIT_DIR) != 0; + + if (git_buf_joinpath(repo_path, given_repo, add_dotgit ? GIT_DIR : "") < 0) + return -1; + + has_dotgit = (git__suffixcmp(repo_path->ptr, "/" GIT_DIR) == 0); + if (has_dotgit) + opts->flags |= GIT_REPOSITORY_INIT__HAS_DOTGIT; + + /* set up workdir path */ + + if (!is_bare) { + if (opts->workdir_path) { + if (git_path_join_unrooted( + wd_path, opts->workdir_path, repo_path->ptr, NULL) < 0) + return -1; + } else if (has_dotgit) { + if (git_path_dirname_r(wd_path, repo_path->ptr) < 0) + return -1; + } else { + giterr_set(GITERR_REPOSITORY, "Cannot pick working directory" + " for non-bare repository that isn't a '.git' directory"); + return -1; + } + + if (git_path_to_dir(wd_path) < 0) + return -1; + } else { + git_buf_clear(wd_path); + } + + natural_wd = + has_dotgit && + wd_path->size > 0 && + wd_path->size + strlen(GIT_DIR) == repo_path->size && + memcmp(repo_path->ptr, wd_path->ptr, wd_path->size) == 0; + if (natural_wd) + opts->flags |= GIT_REPOSITORY_INIT__NATURAL_WD; + + /* create directories as needed / requested */ + + dirmode = pick_dir_mode(opts); + + if ((opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0) { + /* create path #5 */ + if (wd_path->size > 0 && + (error = mkdir_parent(wd_path, dirmode, false)) < 0) + return error; + + /* create path #3 (if not the same as #5) */ + if (!natural_wd && + (error = mkdir_parent(repo_path, dirmode, has_dotgit)) < 0) + return error; + } + + if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || + (opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0) + { + /* create path #4 */ + if (wd_path->size > 0 && + (error = git_futils_mkdir( + wd_path->ptr, NULL, dirmode & ~S_ISGID, + GIT_MKDIR_VERIFY_DIR)) < 0) + return error; + + /* create path #2 (if not the same as #4) */ + if (!natural_wd && + (error = git_futils_mkdir( + repo_path->ptr, NULL, dirmode & ~S_ISGID, + GIT_MKDIR_VERIFY_DIR | GIT_MKDIR_SKIP_LAST)) < 0) + return error; + } + + if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || + (opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0 || + has_dotgit) + { + /* create path #1 */ + error = git_futils_mkdir(repo_path->ptr, NULL, dirmode, + GIT_MKDIR_VERIFY_DIR | ((dirmode & S_ISGID) ? GIT_MKDIR_CHMOD : 0)); + } + + /* prettify both directories now that they are created */ + + if (!error) { + error = git_path_prettify_dir(repo_path, repo_path->ptr, NULL); + + if (!error && wd_path->size > 0) + error = git_path_prettify_dir(wd_path, wd_path->ptr, NULL); + } + + return error; +} + +static int repo_init_create_origin(git_repository *repo, const char *url) +{ + int error; + git_remote *remote; + + if (!(error = git_remote_create(&remote, repo, GIT_REMOTE_ORIGIN, url))) { + git_remote_free(remote); + } + + return error; +} + +int git_repository_init( + git_repository **repo_out, const char *path, unsigned is_bare) +{ + git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT; + + opts.flags = GIT_REPOSITORY_INIT_MKPATH; /* don't love this default */ + if (is_bare) + opts.flags |= GIT_REPOSITORY_INIT_BARE; + + return git_repository_init_ext(repo_out, path, &opts); +} + +int git_repository_init_ext( + git_repository **out, + const char *given_repo, + git_repository_init_options *opts) +{ + int error; + git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT; + + assert(out && given_repo && opts); + + GITERR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options"); + + error = repo_init_directories(&repo_path, &wd_path, given_repo, opts); + if (error < 0) + goto cleanup; + + if (valid_repository_path(&repo_path)) { + + if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) { + giterr_set(GITERR_REPOSITORY, + "Attempt to reinitialize '%s'", given_repo); + error = GIT_EEXISTS; + goto cleanup; + } + + opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT; + + error = repo_init_config( + repo_path.ptr, wd_path.ptr, opts->flags, opts->mode); + + /* TODO: reinitialize the templates */ + } + else { + if (!(error = repo_init_structure( + repo_path.ptr, wd_path.ptr, opts)) && + !(error = repo_init_config( + repo_path.ptr, wd_path.ptr, opts->flags, opts->mode))) + error = repo_init_create_head( + repo_path.ptr, opts->initial_head); + } + if (error < 0) + goto cleanup; + + error = git_repository_open(out, repo_path.ptr); + + if (!error && opts->origin_url) + error = repo_init_create_origin(*out, opts->origin_url); + +cleanup: + git_buf_free(&repo_path); + git_buf_free(&wd_path); + + return error; +} + +int git_repository_head_detached(git_repository *repo) +{ + git_reference *ref; + git_odb *odb = NULL; + int exists; + + if (git_repository_odb__weakptr(&odb, repo) < 0) + return -1; + + if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0) + return -1; + + if (git_reference_type(ref) == GIT_REF_SYMBOLIC) { + git_reference_free(ref); + return 0; + } + + exists = git_odb_exists(odb, git_reference_target(ref)); + + git_reference_free(ref); + return exists; +} + +int git_repository_head(git_reference **head_out, git_repository *repo) +{ + git_reference *head; + int error; + + if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0) + return error; + + if (git_reference_type(head) == GIT_REF_OID) { + *head_out = head; + return 0; + } + + error = git_reference_lookup_resolved(head_out, repo, git_reference_symbolic_target(head), -1); + git_reference_free(head); + + return error == GIT_ENOTFOUND ? GIT_EUNBORNBRANCH : error; +} + +int git_repository_head_unborn(git_repository *repo) +{ + git_reference *ref = NULL; + int error; + + error = git_repository_head(&ref, repo); + git_reference_free(ref); + + if (error == GIT_EUNBORNBRANCH) { + giterr_clear(); + return 1; + } + + if (error < 0) + return -1; + + return 0; +} + +static int at_least_one_cb(const char *refname, void *payload) +{ + GIT_UNUSED(refname); + GIT_UNUSED(payload); + return GIT_PASSTHROUGH; +} + +static int repo_contains_no_reference(git_repository *repo) +{ + int error = git_reference_foreach_name(repo, &at_least_one_cb, NULL); + + if (error == GIT_PASSTHROUGH) + return 0; + + if (!error) + return 1; + + return error; +} + +int git_repository_is_empty(git_repository *repo) +{ + git_reference *head = NULL; + int is_empty = 0; + + if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) + return -1; + + if (git_reference_type(head) == GIT_REF_SYMBOLIC) + is_empty = + (strcmp(git_reference_symbolic_target(head), + GIT_REFS_HEADS_DIR "master") == 0) && + repo_contains_no_reference(repo); + + git_reference_free(head); + + return is_empty; +} + +const char *git_repository_path(git_repository *repo) +{ + assert(repo); + return repo->path_repository; +} + +const char *git_repository_workdir(git_repository *repo) +{ + assert(repo); + + if (repo->is_bare) + return NULL; + + return repo->workdir; +} + +int git_repository_set_workdir( + git_repository *repo, const char *workdir, int update_gitlink) +{ + int error = 0; + git_buf path = GIT_BUF_INIT; + + assert(repo && workdir); + + if (git_path_prettify_dir(&path, workdir, NULL) < 0) + return -1; + + if (repo->workdir && strcmp(repo->workdir, path.ptr) == 0) + return 0; + + if (update_gitlink) { + git_config *config; + + if (git_repository_config__weakptr(&config, repo) < 0) + return -1; + + error = repo_write_gitlink(path.ptr, git_repository_path(repo), false); + + /* passthrough error means gitlink is unnecessary */ + if (error == GIT_PASSTHROUGH) + error = git_config_delete_entry(config, "core.worktree"); + else if (!error) + error = git_config_set_string(config, "core.worktree", path.ptr); + + if (!error) + error = git_config_set_bool(config, "core.bare", false); + } + + if (!error) { + char *old_workdir = repo->workdir; + + repo->workdir = git_buf_detach(&path); + repo->is_bare = 0; + + git__free(old_workdir); + } + + return error; +} + +int git_repository_is_bare(git_repository *repo) +{ + assert(repo); + return repo->is_bare; +} + +int git_repository_set_bare(git_repository *repo) +{ + int error; + git_config *config; + + assert(repo); + + if (repo->is_bare) + return 0; + + if ((error = git_repository_config__weakptr(&config, repo)) < 0) + return error; + + if ((error = git_config_set_bool(config, "core.bare", true)) < 0) + return error; + + if ((error = git_config__update_entry(config, "core.worktree", NULL, true, true)) < 0) + return error; + + git__free(repo->workdir); + repo->workdir = NULL; + repo->is_bare = 1; + + return 0; +} + +int git_repository_head_tree(git_tree **tree, git_repository *repo) +{ + git_reference *head; + git_object *obj; + int error; + + if ((error = git_repository_head(&head, repo)) < 0) + return error; + + if ((error = git_reference_peel(&obj, head, GIT_OBJ_TREE)) < 0) + goto cleanup; + + *tree = (git_tree *)obj; + +cleanup: + git_reference_free(head); + return error; +} + +int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + char orig_head_str[GIT_OID_HEXSZ]; + int error = 0; + + git_oid_fmt(orig_head_str, orig_head); + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 && + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 && + (error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0) + error = git_filebuf_commit(&file); + + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +int git_repository_message(git_buf *out, git_repository *repo) +{ + git_buf path = GIT_BUF_INIT; + struct stat st; + int error; + + git_buf_sanitize(out); + + if (git_buf_joinpath(&path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0) + return -1; + + if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) { + if (errno == ENOENT) + error = GIT_ENOTFOUND; + giterr_set(GITERR_OS, "Could not access message file"); + } else { + error = git_futils_readbuffer(out, git_buf_cstr(&path)); + } + + git_buf_free(&path); + + return error; +} + +int git_repository_message_remove(git_repository *repo) +{ + git_buf path = GIT_BUF_INIT; + int error; + + if (git_buf_joinpath(&path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0) + return -1; + + error = p_unlink(git_buf_cstr(&path)); + git_buf_free(&path); + + return error; +} + +int git_repository_hashfile( + git_oid *out, + git_repository *repo, + const char *path, + git_otype type, + const char *as_path) +{ + int error; + git_filter_list *fl = NULL; + git_file fd = -1; + git_off_t len; + git_buf full_path = GIT_BUF_INIT; + + assert(out && path && repo); /* as_path can be NULL */ + + /* At some point, it would be nice if repo could be NULL to just + * apply filter rules defined in system and global files, but for + * now that is not possible because git_filters_load() needs it. + */ + + error = git_path_join_unrooted( + &full_path, path, git_repository_workdir(repo), NULL); + if (error < 0) + return error; + + if (!as_path) + as_path = path; + + /* passing empty string for "as_path" indicated --no-filters */ + if (strlen(as_path) > 0) { + error = git_filter_list_load( + &fl, repo, NULL, as_path, + GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT); + if (error < 0) + return error; + } else { + error = 0; + } + + /* at this point, error is a count of the number of loaded filters */ + + fd = git_futils_open_ro(full_path.ptr); + if (fd < 0) { + error = fd; + goto cleanup; + } + + len = git_futils_filesize(fd); + if (len < 0) { + error = (int)len; + goto cleanup; + } + + if (!git__is_sizet(len)) { + giterr_set(GITERR_OS, "File size overflow for 32-bit systems"); + error = -1; + goto cleanup; + } + + error = git_odb__hashfd_filtered(out, fd, (size_t)len, type, fl); + +cleanup: + if (fd >= 0) + p_close(fd); + git_filter_list_free(fl); + git_buf_free(&full_path); + + return error; +} + +static int checkout_message(git_buf *out, git_reference *old, const char *new) +{ + git_buf_puts(out, "checkout: moving from "); + + if (git_reference_type(old) == GIT_REF_SYMBOLIC) + git_buf_puts(out, git_reference__shorthand(git_reference_symbolic_target(old))); + else + git_buf_puts(out, git_oid_tostr_s(git_reference_target(old))); + + git_buf_puts(out, " to "); + + if (git_reference__is_branch(new)) + git_buf_puts(out, git_reference__shorthand(new)); + else + git_buf_puts(out, new); + + if (git_buf_oom(out)) + return -1; + + return 0; +} + +int git_repository_set_head( + git_repository* repo, + const char* refname) +{ + git_reference *ref = NULL, *current = NULL, *new_head = NULL; + git_buf log_message = GIT_BUF_INIT; + int error; + + assert(repo && refname); + + if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) + return error; + + if ((error = checkout_message(&log_message, current, refname)) < 0) + goto cleanup; + + error = git_reference_lookup(&ref, repo, refname); + if (error < 0 && error != GIT_ENOTFOUND) + goto cleanup; + + if (!error) { + if (git_reference_is_branch(ref)) { + error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, + git_reference_name(ref), true, git_buf_cstr(&log_message)); + } else { + error = git_repository_set_head_detached(repo, git_reference_target(ref)); + } + } else if (git_reference__is_branch(refname)) { + error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, refname, + true, git_buf_cstr(&log_message)); + } + +cleanup: + git_buf_free(&log_message); + git_reference_free(current); + git_reference_free(ref); + git_reference_free(new_head); + return error; +} + +static int detach(git_repository *repo, const git_oid *id, const char *from) +{ + int error; + git_buf log_message = GIT_BUF_INIT; + git_object *object = NULL, *peeled = NULL; + git_reference *new_head = NULL, *current = NULL; + + assert(repo && id); + + if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) + return error; + + if ((error = git_object_lookup(&object, repo, id, GIT_OBJ_ANY)) < 0) + goto cleanup; + + if ((error = git_object_peel(&peeled, object, GIT_OBJ_COMMIT)) < 0) + goto cleanup; + + if (from == NULL) + from = git_oid_tostr_s(git_object_id(peeled)); + + if ((error = checkout_message(&log_message, current, from)) < 0) + goto cleanup; + + error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), true, git_buf_cstr(&log_message)); + +cleanup: + git_buf_free(&log_message); + git_object_free(object); + git_object_free(peeled); + git_reference_free(current); + git_reference_free(new_head); + return error; +} + +int git_repository_set_head_detached( + git_repository* repo, + const git_oid* commitish) +{ + return detach(repo, commitish, NULL); +} + +int git_repository_set_head_detached_from_annotated( + git_repository *repo, + const git_annotated_commit *commitish) +{ + assert(repo && commitish); + + return detach(repo, git_annotated_commit_id(commitish), commitish->ref_name); +} + +int git_repository_detach_head(git_repository* repo) +{ + git_reference *old_head = NULL, *new_head = NULL, *current = NULL; + git_object *object = NULL; + git_buf log_message = GIT_BUF_INIT; + int error; + + assert(repo); + + if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) + return error; + + if ((error = git_repository_head(&old_head, repo)) < 0) + goto cleanup; + + if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJ_COMMIT)) < 0) + goto cleanup; + + if ((error = checkout_message(&log_message, current, git_oid_tostr_s(git_object_id(object)))) < 0) + goto cleanup; + + error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head), + 1, git_buf_cstr(&log_message)); + +cleanup: + git_buf_free(&log_message); + git_object_free(object); + git_reference_free(old_head); + git_reference_free(new_head); + git_reference_free(current); + return error; +} + +/** + * Loosely ported from git.git + * https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh#L198-289 + */ +int git_repository_state(git_repository *repo) +{ + git_buf repo_path = GIT_BUF_INIT; + int state = GIT_REPOSITORY_STATE_NONE; + + assert(repo); + + if (git_buf_puts(&repo_path, repo->path_repository) < 0) + return -1; + + if (git_path_contains_file(&repo_path, GIT_REBASE_MERGE_INTERACTIVE_FILE)) + state = GIT_REPOSITORY_STATE_REBASE_INTERACTIVE; + else if (git_path_contains_dir(&repo_path, GIT_REBASE_MERGE_DIR)) + state = GIT_REPOSITORY_STATE_REBASE_MERGE; + else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_REBASING_FILE)) + state = GIT_REPOSITORY_STATE_REBASE; + else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_APPLYING_FILE)) + state = GIT_REPOSITORY_STATE_APPLY_MAILBOX; + else if (git_path_contains_dir(&repo_path, GIT_REBASE_APPLY_DIR)) + state = GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE; + else if (git_path_contains_file(&repo_path, GIT_MERGE_HEAD_FILE)) + state = GIT_REPOSITORY_STATE_MERGE; + else if(git_path_contains_file(&repo_path, GIT_REVERT_HEAD_FILE)) + state = GIT_REPOSITORY_STATE_REVERT; + else if(git_path_contains_file(&repo_path, GIT_CHERRYPICK_HEAD_FILE)) + state = GIT_REPOSITORY_STATE_CHERRYPICK; + else if(git_path_contains_file(&repo_path, GIT_BISECT_LOG_FILE)) + state = GIT_REPOSITORY_STATE_BISECT; + + git_buf_free(&repo_path); + return state; +} + +int git_repository__cleanup_files( + git_repository *repo, const char *files[], size_t files_len) +{ + git_buf buf = GIT_BUF_INIT; + size_t i; + int error; + + for (error = 0, i = 0; !error && i < files_len; ++i) { + const char *path; + + if (git_buf_joinpath(&buf, repo->path_repository, files[i]) < 0) + return -1; + + path = git_buf_cstr(&buf); + + if (git_path_isfile(path)) { + error = p_unlink(path); + } else if (git_path_isdir(path)) { + error = git_futils_rmdir_r(path, NULL, + GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_REMOVE_BLOCKERS); + } + + git_buf_clear(&buf); + } + + git_buf_free(&buf); + return error; +} + +static const char *state_files[] = { + GIT_MERGE_HEAD_FILE, + GIT_MERGE_MODE_FILE, + GIT_MERGE_MSG_FILE, + GIT_REVERT_HEAD_FILE, + GIT_CHERRYPICK_HEAD_FILE, + GIT_BISECT_LOG_FILE, + GIT_REBASE_MERGE_DIR, + GIT_REBASE_APPLY_DIR, +}; + +int git_repository_state_cleanup(git_repository *repo) +{ + assert(repo); + + return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); +} + +int git_repository_is_shallow(git_repository *repo) +{ + git_buf path = GIT_BUF_INIT; + struct stat st; + int error; + + if ((error = git_buf_joinpath(&path, repo->path_repository, "shallow")) < 0) + return error; + + error = git_path_lstat(path.ptr, &st); + git_buf_free(&path); + + if (error == GIT_ENOTFOUND) { + giterr_clear(); + return 0; + } + + if (error < 0) + return error; + return st.st_size == 0 ? 0 : 1; +} + +int git_repository_init_init_options( + git_repository_init_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_repository_init_options, + GIT_REPOSITORY_INIT_OPTIONS_INIT); + return 0; +} + +int git_repository_ident(const char **name, const char **email, const git_repository *repo) +{ + *name = repo->ident_name; + *email = repo->ident_email; + + return 0; +} + +int git_repository_set_ident(git_repository *repo, const char *name, const char *email) +{ + char *tmp_name = NULL, *tmp_email = NULL; + + if (name) { + tmp_name = git__strdup(name); + GITERR_CHECK_ALLOC(tmp_name); + } + + if (email) { + tmp_email = git__strdup(email); + GITERR_CHECK_ALLOC(tmp_email); + } + + tmp_name = git__swap(repo->ident_name, tmp_name); + tmp_email = git__swap(repo->ident_email, tmp_email); + + git__free(tmp_name); + git__free(tmp_email); + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/repository.h b/deps/libgit2-sys-0.2.17/libgit2/src/repository.h new file mode 100644 index 000000000..253287368 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/repository.h @@ -0,0 +1,216 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_repository_h__ +#define INCLUDE_repository_h__ + +#include "git2/common.h" +#include "git2/oid.h" +#include "git2/odb.h" +#include "git2/repository.h" +#include "git2/object.h" +#include "git2/config.h" + +#include "array.h" +#include "cache.h" +#include "refs.h" +#include "buffer.h" +#include "object.h" +#include "attrcache.h" +#include "submodule.h" +#include "diff_driver.h" + +#define DOT_GIT ".git" +#define GIT_DIR DOT_GIT "/" +#define GIT_DIR_MODE 0755 +#define GIT_BARE_DIR_MODE 0777 + +/* Default DOS-compatible 8.3 "short name" for a git repository, "GIT~1" */ +#define GIT_DIR_SHORTNAME "GIT~1" + +/** Cvar cache identifiers */ +typedef enum { + GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */ + GIT_CVAR_EOL, /* core.eol */ + GIT_CVAR_SYMLINKS, /* core.symlinks */ + GIT_CVAR_IGNORECASE, /* core.ignorecase */ + GIT_CVAR_FILEMODE, /* core.filemode */ + GIT_CVAR_IGNORESTAT, /* core.ignorestat */ + GIT_CVAR_TRUSTCTIME, /* core.trustctime */ + GIT_CVAR_ABBREV, /* core.abbrev */ + GIT_CVAR_PRECOMPOSE, /* core.precomposeunicode */ + GIT_CVAR_SAFE_CRLF, /* core.safecrlf */ + GIT_CVAR_LOGALLREFUPDATES, /* core.logallrefupdates */ + GIT_CVAR_PROTECTHFS, /* core.protectHFS */ + GIT_CVAR_PROTECTNTFS, /* core.protectNTFS */ + GIT_CVAR_CACHE_MAX +} git_cvar_cached; + +/** + * CVAR value enumerations + * + * These are the values that are actually stored in the cvar cache, instead + * of their string equivalents. These values are internal and symbolic; + * make sure that none of them is set to `-1`, since that is the unique + * identifier for "not cached" + */ +typedef enum { + /* The value hasn't been loaded from the cache yet */ + GIT_CVAR_NOT_CACHED = -1, + + /* core.safecrlf: false, 'fail', 'warn' */ + GIT_SAFE_CRLF_FALSE = 0, + GIT_SAFE_CRLF_FAIL = 1, + GIT_SAFE_CRLF_WARN = 2, + + /* core.autocrlf: false, true, 'input; */ + GIT_AUTO_CRLF_FALSE = 0, + GIT_AUTO_CRLF_TRUE = 1, + GIT_AUTO_CRLF_INPUT = 2, + GIT_AUTO_CRLF_DEFAULT = GIT_AUTO_CRLF_FALSE, + + /* core.eol: unset, 'crlf', 'lf', 'native' */ + GIT_EOL_UNSET = 0, + GIT_EOL_CRLF = 1, + GIT_EOL_LF = 2, +#ifdef GIT_WIN32 + GIT_EOL_NATIVE = GIT_EOL_CRLF, +#else + GIT_EOL_NATIVE = GIT_EOL_LF, +#endif + GIT_EOL_DEFAULT = GIT_EOL_NATIVE, + + /* core.symlinks: bool */ + GIT_SYMLINKS_DEFAULT = GIT_CVAR_TRUE, + /* core.ignorecase */ + GIT_IGNORECASE_DEFAULT = GIT_CVAR_FALSE, + /* core.filemode */ + GIT_FILEMODE_DEFAULT = GIT_CVAR_TRUE, + /* core.ignorestat */ + GIT_IGNORESTAT_DEFAULT = GIT_CVAR_FALSE, + /* core.trustctime */ + GIT_TRUSTCTIME_DEFAULT = GIT_CVAR_TRUE, + /* core.abbrev */ + GIT_ABBREV_DEFAULT = 7, + /* core.precomposeunicode */ + GIT_PRECOMPOSE_DEFAULT = GIT_CVAR_FALSE, + /* core.safecrlf */ + GIT_SAFE_CRLF_DEFAULT = GIT_CVAR_FALSE, + /* core.logallrefupdates */ + GIT_LOGALLREFUPDATES_UNSET = 2, + GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET, + /* core.protectHFS */ + GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE, + /* core.protectNTFS */ + GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_FALSE, +} git_cvar_value; + +/* internal repository init flags */ +enum { + GIT_REPOSITORY_INIT__HAS_DOTGIT = (1u << 16), + GIT_REPOSITORY_INIT__NATURAL_WD = (1u << 17), + GIT_REPOSITORY_INIT__IS_REINIT = (1u << 18), +}; + +/** Internal structure for repository object */ +struct git_repository { + git_odb *_odb; + git_refdb *_refdb; + git_config *_config; + git_index *_index; + git_submodule_cache *_submodules; + + git_cache objects; + git_attr_cache *attrcache; + git_diff_driver_registry *diff_drivers; + + char *path_repository; + char *path_gitlink; + char *workdir; + char *namespace; + + char *ident_name; + char *ident_email; + + git_array_t(git_buf) reserved_names; + + unsigned is_bare:1; + + unsigned int lru_counter; + + git_atomic attr_session_key; + + git_cvar_value cvar_cache[GIT_CVAR_CACHE_MAX]; +}; + +GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo) +{ + return repo->attrcache; +} + +int git_repository_head_tree(git_tree **tree, git_repository *repo); + +/* + * Weak pointers to repository internals. + * + * The returned pointers do not need to be freed. Do not keep + * permanent references to these (i.e. between API calls), since they may + * become invalidated if the user replaces a repository internal. + */ +int git_repository_config__weakptr(git_config **out, git_repository *repo); +int git_repository_odb__weakptr(git_odb **out, git_repository *repo); +int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo); +int git_repository_index__weakptr(git_index **out, git_repository *repo); + +/* + * CVAR cache + * + * Efficient access to the most used config variables of a repository. + * The cache is cleared every time the config backend is replaced. + */ +int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar); +void git_repository__cvar_cache_clear(git_repository *repo); + +GIT_INLINE(int) git_repository__ensure_not_bare( + git_repository *repo, + const char *operation_name) +{ + if (!git_repository_is_bare(repo)) + return 0; + + giterr_set( + GITERR_REPOSITORY, + "Cannot %s. This operation is not allowed against bare repositories.", + operation_name); + + return GIT_EBAREREPO; +} + +int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head); + +int git_repository__cleanup_files(git_repository *repo, const char *files[], size_t files_len); + +/* The default "reserved names" for a repository */ +extern git_buf git_repository__reserved_names_win32[]; +extern size_t git_repository__reserved_names_win32_len; + +extern git_buf git_repository__reserved_names_posix[]; +extern size_t git_repository__reserved_names_posix_len; + +/* + * Gets any "reserved names" in the repository. This will return paths + * that should not be allowed in the repository (like ".git") to avoid + * conflicting with the repository path, or with alternate mechanisms to + * the repository path (eg, "GIT~1"). Every attempt will be made to look + * up all possible reserved names - if there was a conflict for the shortname + * GIT~1, for example, this function will try to look up the alternate + * shortname. If that fails, this function returns false, but out and outlen + * will still be populated with good defaults. + */ +bool git_repository__reserved_names( + git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/reset.c b/deps/libgit2-sys-0.2.17/libgit2/src/reset.c new file mode 100644 index 000000000..aaebf4198 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/reset.c @@ -0,0 +1,198 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "commit.h" +#include "tag.h" +#include "merge.h" +#include "diff.h" +#include "annotated_commit.h" +#include "git2/reset.h" +#include "git2/checkout.h" +#include "git2/merge.h" +#include "git2/refs.h" + +#define ERROR_MSG "Cannot perform reset" + +int git_reset_default( + git_repository *repo, + git_object *target, + git_strarray* pathspecs) +{ + git_object *commit = NULL; + git_tree *tree = NULL; + git_diff *diff = NULL; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + size_t i, max_i; + git_index_entry entry; + int error; + git_index *index = NULL; + + assert(pathspecs != NULL && pathspecs->count > 0); + + memset(&entry, 0, sizeof(git_index_entry)); + + if ((error = git_repository_index(&index, repo)) < 0) + goto cleanup; + + if (target) { + if (git_object_owner(target) != repo) { + giterr_set(GITERR_OBJECT, + "%s_default - The given target does not belong to this repository.", ERROR_MSG); + return -1; + } + + if ((error = git_object_peel(&commit, target, GIT_OBJ_COMMIT)) < 0 || + (error = git_commit_tree(&tree, (git_commit *)commit)) < 0) + goto cleanup; + } + + opts.pathspec = *pathspecs; + opts.flags = GIT_DIFF_REVERSE; + + if ((error = git_diff_tree_to_index( + &diff, repo, tree, index, &opts)) < 0) + goto cleanup; + + for (i = 0, max_i = git_diff_num_deltas(diff); i < max_i; ++i) { + const git_diff_delta *delta = git_diff_get_delta(diff, i); + + assert(delta->status == GIT_DELTA_ADDED || + delta->status == GIT_DELTA_MODIFIED || + delta->status == GIT_DELTA_DELETED); + + error = git_index_conflict_remove(index, delta->old_file.path); + if (error < 0) { + if (delta->status == GIT_DELTA_ADDED && error == GIT_ENOTFOUND) + giterr_clear(); + else + goto cleanup; + } + + if (delta->status == GIT_DELTA_DELETED) { + if ((error = git_index_remove(index, delta->old_file.path, 0)) < 0) + goto cleanup; + } else { + entry.mode = delta->new_file.mode; + git_oid_cpy(&entry.id, &delta->new_file.id); + entry.path = (char *)delta->new_file.path; + + if ((error = git_index_add(index, &entry)) < 0) + goto cleanup; + } + } + + error = git_index_write(index); + +cleanup: + git_object_free(commit); + git_tree_free(tree); + git_index_free(index); + git_diff_free(diff); + + return error; +} + +static int reset( + git_repository *repo, + git_object *target, + const char *to, + git_reset_t reset_type, + git_checkout_options *checkout_opts) +{ + git_object *commit = NULL; + git_index *index = NULL; + git_tree *tree = NULL; + int error = 0; + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; + git_buf log_message = GIT_BUF_INIT; + + assert(repo && target); + + if (checkout_opts) + opts = *checkout_opts; + + if (git_object_owner(target) != repo) { + giterr_set(GITERR_OBJECT, + "%s - The given target does not belong to this repository.", ERROR_MSG); + return -1; + } + + if (reset_type != GIT_RESET_SOFT && + (error = git_repository__ensure_not_bare(repo, + reset_type == GIT_RESET_MIXED ? "reset mixed" : "reset hard")) < 0) + return error; + + if ((error = git_object_peel(&commit, target, GIT_OBJ_COMMIT)) < 0 || + (error = git_repository_index(&index, repo)) < 0 || + (error = git_commit_tree(&tree, (git_commit *)commit)) < 0) + goto cleanup; + + if (reset_type == GIT_RESET_SOFT && + (git_repository_state(repo) == GIT_REPOSITORY_STATE_MERGE || + git_index_has_conflicts(index))) + { + giterr_set(GITERR_OBJECT, "%s (soft) in the middle of a merge.", ERROR_MSG); + error = GIT_EUNMERGED; + goto cleanup; + } + + if ((error = git_buf_printf(&log_message, "reset: moving to %s", to)) < 0) + return error; + + /* move HEAD to the new target */ + if ((error = git_reference__update_terminal(repo, GIT_HEAD_FILE, + git_object_id(commit), NULL, git_buf_cstr(&log_message))) < 0) + goto cleanup; + + if (reset_type == GIT_RESET_HARD) { + /* overwrite working directory with HEAD */ + opts.checkout_strategy = GIT_CHECKOUT_FORCE; + + if ((error = git_checkout_tree(repo, (git_object *)tree, &opts)) < 0) + goto cleanup; + } + + if (reset_type > GIT_RESET_SOFT) { + /* reset index to the target content */ + + if ((error = git_index_read_tree(index, tree)) < 0 || + (error = git_index_write(index)) < 0) + goto cleanup; + + if ((error = git_repository_state_cleanup(repo)) < 0) { + giterr_set(GITERR_INDEX, "%s - failed to clean up merge data", ERROR_MSG); + goto cleanup; + } + } + +cleanup: + git_object_free(commit); + git_index_free(index); + git_tree_free(tree); + git_buf_free(&log_message); + + return error; +} + +int git_reset( + git_repository *repo, + git_object *target, + git_reset_t reset_type, + git_checkout_options *checkout_opts) +{ + return reset(repo, target, git_oid_tostr_s(git_object_id(target)), reset_type, checkout_opts); +} + +int git_reset_from_annotated( + git_repository *repo, + git_annotated_commit *commit, + git_reset_t reset_type, + git_checkout_options *checkout_opts) +{ + return reset(repo, (git_object *) commit->commit, commit->ref_name, reset_type, checkout_opts); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/revert.c b/deps/libgit2-sys-0.2.17/libgit2/src/revert.c new file mode 100644 index 000000000..c481e7dea --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/revert.c @@ -0,0 +1,231 @@ +/* +* Copyright (C) the libgit2 contributors. All rights reserved. +* +* This file is part of libgit2, distributed under the GNU GPL v2 with +* a Linking Exception. For full terms see the included COPYING file. +*/ + +#include "common.h" +#include "repository.h" +#include "filebuf.h" +#include "merge.h" +#include "index.h" + +#include "git2/types.h" +#include "git2/merge.h" +#include "git2/revert.h" +#include "git2/commit.h" +#include "git2/sys/commit.h" + +#define GIT_REVERT_FILE_MODE 0666 + +static int write_revert_head( + git_repository *repo, + const char *commit_oidstr) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_REVERT_HEAD_FILE)) >= 0 && + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) >= 0 && + (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) + error = git_filebuf_commit(&file); + + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int write_merge_msg( + git_repository *repo, + const char *commit_oidstr, + const char *commit_msgline) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) < 0 || + (error = git_filebuf_printf(&file, "Revert \"%s\"\n\nThis reverts commit %s.\n", + commit_msgline, commit_oidstr)) < 0) + goto cleanup; + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int revert_normalize_opts( + git_repository *repo, + git_revert_options *opts, + const git_revert_options *given, + const char *their_label) +{ + int error = 0; + unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE | + GIT_CHECKOUT_ALLOW_CONFLICTS; + + GIT_UNUSED(repo); + + if (given != NULL) + memcpy(opts, given, sizeof(git_revert_options)); + else { + git_revert_options default_opts = GIT_REVERT_OPTIONS_INIT; + memcpy(opts, &default_opts, sizeof(git_revert_options)); + } + + if (!opts->checkout_opts.checkout_strategy) + opts->checkout_opts.checkout_strategy = default_checkout_strategy; + + if (!opts->checkout_opts.our_label) + opts->checkout_opts.our_label = "HEAD"; + + if (!opts->checkout_opts.their_label) + opts->checkout_opts.their_label = their_label; + + return error; +} + +static int revert_state_cleanup(git_repository *repo) +{ + const char *state_files[] = { GIT_REVERT_HEAD_FILE, GIT_MERGE_MSG_FILE }; + + return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); +} + +static int revert_seterr(git_commit *commit, const char *fmt) +{ + char commit_oidstr[GIT_OID_HEXSZ + 1]; + + git_oid_fmt(commit_oidstr, git_commit_id(commit)); + commit_oidstr[GIT_OID_HEXSZ] = '\0'; + + giterr_set(GITERR_REVERT, fmt, commit_oidstr); + + return -1; +} + +int git_revert_commit( + git_index **out, + git_repository *repo, + git_commit *revert_commit, + git_commit *our_commit, + unsigned int mainline, + const git_merge_options *merge_opts) +{ + git_commit *parent_commit = NULL; + git_tree *parent_tree = NULL, *our_tree = NULL, *revert_tree = NULL; + int parent = 0, error = 0; + + assert(out && repo && revert_commit && our_commit); + + if (git_commit_parentcount(revert_commit) > 1) { + if (!mainline) + return revert_seterr(revert_commit, + "Mainline branch is not specified but %s is a merge commit"); + + parent = mainline; + } else { + if (mainline) + return revert_seterr(revert_commit, + "Mainline branch specified but %s is not a merge commit"); + + parent = git_commit_parentcount(revert_commit); + } + + if (parent && + ((error = git_commit_parent(&parent_commit, revert_commit, (parent - 1))) < 0 || + (error = git_commit_tree(&parent_tree, parent_commit)) < 0)) + goto done; + + if ((error = git_commit_tree(&revert_tree, revert_commit)) < 0 || + (error = git_commit_tree(&our_tree, our_commit)) < 0) + goto done; + + error = git_merge_trees(out, repo, revert_tree, our_tree, parent_tree, merge_opts); + +done: + git_tree_free(parent_tree); + git_tree_free(our_tree); + git_tree_free(revert_tree); + git_commit_free(parent_commit); + + return error; +} + +int git_revert( + git_repository *repo, + git_commit *commit, + const git_revert_options *given_opts) +{ + git_revert_options opts; + git_reference *our_ref = NULL; + git_commit *our_commit = NULL; + char commit_oidstr[GIT_OID_HEXSZ + 1]; + const char *commit_msg; + git_buf their_label = GIT_BUF_INIT; + git_index *index = NULL; + git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; + int error; + + assert(repo && commit); + + GITERR_CHECK_VERSION(given_opts, GIT_REVERT_OPTIONS_VERSION, "git_revert_options"); + + if ((error = git_repository__ensure_not_bare(repo, "revert")) < 0) + return error; + + git_oid_fmt(commit_oidstr, git_commit_id(commit)); + commit_oidstr[GIT_OID_HEXSZ] = '\0'; + + if ((commit_msg = git_commit_summary(commit)) == NULL) { + error = -1; + goto on_error; + } + + if ((error = git_buf_printf(&their_label, "parent of %.7s... %s", commit_oidstr, commit_msg)) < 0 || + (error = revert_normalize_opts(repo, &opts, given_opts, git_buf_cstr(&their_label))) < 0 || + (error = git_indexwriter_init_for_operation(&indexwriter, repo, &opts.checkout_opts.checkout_strategy)) < 0 || + (error = write_revert_head(repo, commit_oidstr)) < 0 || + (error = write_merge_msg(repo, commit_oidstr, commit_msg)) < 0 || + (error = git_repository_head(&our_ref, repo)) < 0 || + (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 || + (error = git_revert_commit(&index, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 || + (error = git_merge__check_result(repo, index)) < 0 || + (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 || + (error = git_checkout_index(repo, index, &opts.checkout_opts)) < 0 || + (error = git_indexwriter_commit(&indexwriter)) < 0) + goto on_error; + + goto done; + +on_error: + revert_state_cleanup(repo); + +done: + git_indexwriter_cleanup(&indexwriter); + git_index_free(index); + git_commit_free(our_commit); + git_reference_free(our_ref); + git_buf_free(&their_label); + + return error; +} + +int git_revert_init_options(git_revert_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_revert_options, GIT_REVERT_OPTIONS_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/revparse.c b/deps/libgit2-sys-0.2.17/libgit2/src/revparse.c new file mode 100644 index 000000000..e0ec3941d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/revparse.c @@ -0,0 +1,913 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include + +#include "common.h" +#include "buffer.h" +#include "tree.h" +#include "refdb.h" + +#include "git2.h" + +static int maybe_sha_or_abbrev(git_object** out, git_repository *repo, const char *spec, size_t speclen) +{ + git_oid oid; + + if (git_oid_fromstrn(&oid, spec, speclen) < 0) + return GIT_ENOTFOUND; + + return git_object_lookup_prefix(out, repo, &oid, speclen, GIT_OBJ_ANY); +} + +static int maybe_sha(git_object** out, git_repository *repo, const char *spec) +{ + size_t speclen = strlen(spec); + + if (speclen != GIT_OID_HEXSZ) + return GIT_ENOTFOUND; + + return maybe_sha_or_abbrev(out, repo, spec, speclen); +} + +static int maybe_abbrev(git_object** out, git_repository *repo, const char *spec) +{ + size_t speclen = strlen(spec); + + return maybe_sha_or_abbrev(out, repo, spec, speclen); +} + +static int build_regex(regex_t *regex, const char *pattern) +{ + int error; + + if (*pattern == '\0') { + giterr_set(GITERR_REGEX, "Empty pattern"); + return GIT_EINVALIDSPEC; + } + + error = regcomp(regex, pattern, REG_EXTENDED); + if (!error) + return 0; + + error = giterr_set_regex(regex, error); + + regfree(regex); + + return error; +} + +static int maybe_describe(git_object**out, git_repository *repo, const char *spec) +{ + const char *substr; + int error; + regex_t regex; + + substr = strstr(spec, "-g"); + + if (substr == NULL) + return GIT_ENOTFOUND; + + if (build_regex(®ex, ".+-[0-9]+-g[0-9a-fA-F]+") < 0) + return -1; + + error = regexec(®ex, spec, 0, NULL, 0); + regfree(®ex); + + if (error) + return GIT_ENOTFOUND; + + return maybe_abbrev(out, repo, substr+2); +} + +static int revparse_lookup_object( + git_object **object_out, + git_reference **reference_out, + git_repository *repo, + const char *spec) +{ + int error; + git_reference *ref; + + if ((error = maybe_sha(object_out, repo, spec)) != GIT_ENOTFOUND) + return error; + + error = git_reference_dwim(&ref, repo, spec); + if (!error) { + + error = git_object_lookup( + object_out, repo, git_reference_target(ref), GIT_OBJ_ANY); + + if (!error) + *reference_out = ref; + + return error; + } + + if (error != GIT_ENOTFOUND) + return error; + + if ((strlen(spec) < GIT_OID_HEXSZ) && + ((error = maybe_abbrev(object_out, repo, spec)) != GIT_ENOTFOUND)) + return error; + + if ((error = maybe_describe(object_out, repo, spec)) != GIT_ENOTFOUND) + return error; + + giterr_set(GITERR_REFERENCE, "Revspec '%s' not found.", spec); + return GIT_ENOTFOUND; +} + +static int try_parse_numeric(int *n, const char *curly_braces_content) +{ + int32_t content; + const char *end_ptr; + + if (git__strtol32(&content, curly_braces_content, &end_ptr, 10) < 0) + return -1; + + if (*end_ptr != '\0') + return -1; + + *n = (int)content; + return 0; +} + +static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position) +{ + git_reference *ref = NULL; + git_reflog *reflog = NULL; + regex_t preg; + int error = -1; + size_t i, numentries, cur; + const git_reflog_entry *entry; + const char *msg; + regmatch_t regexmatches[2]; + git_buf buf = GIT_BUF_INIT; + + cur = position; + + if (*identifier != '\0' || *base_ref != NULL) + return GIT_EINVALIDSPEC; + + if (build_regex(&preg, "checkout: moving from (.*) to .*") < 0) + return -1; + + if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0) + goto cleanup; + + if (git_reflog_read(&reflog, repo, GIT_HEAD_FILE) < 0) + goto cleanup; + + numentries = git_reflog_entrycount(reflog); + + for (i = 0; i < numentries; i++) { + entry = git_reflog_entry_byindex(reflog, i); + msg = git_reflog_entry_message(entry); + if (!msg) + continue; + + if (regexec(&preg, msg, 2, regexmatches, 0)) + continue; + + cur--; + + if (cur > 0) + continue; + + git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so); + + if ((error = git_reference_dwim(base_ref, repo, git_buf_cstr(&buf))) == 0) + goto cleanup; + + if (error < 0 && error != GIT_ENOTFOUND) + goto cleanup; + + error = maybe_abbrev(out, repo, git_buf_cstr(&buf)); + + goto cleanup; + } + + error = GIT_ENOTFOUND; + +cleanup: + git_reference_free(ref); + git_buf_free(&buf); + regfree(&preg); + git_reflog_free(reflog); + return error; +} + +static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t identifier) +{ + git_reflog *reflog; + size_t numentries; + const git_reflog_entry *entry; + bool search_by_pos = (identifier <= 100000000); + + if (git_reflog_read(&reflog, git_reference_owner(ref), git_reference_name(ref)) < 0) + return -1; + + numentries = git_reflog_entrycount(reflog); + + if (search_by_pos) { + if (numentries < identifier + 1) + goto notfound; + + entry = git_reflog_entry_byindex(reflog, identifier); + git_oid_cpy(oid, git_reflog_entry_id_new(entry)); + } else { + size_t i; + git_time commit_time; + + for (i = 0; i < numentries; i++) { + entry = git_reflog_entry_byindex(reflog, i); + commit_time = git_reflog_entry_committer(entry)->when; + + if (commit_time.time > (git_time_t)identifier) + continue; + + git_oid_cpy(oid, git_reflog_entry_id_new(entry)); + break; + } + + if (i == numentries) + goto notfound; + } + + git_reflog_free(reflog); + return 0; + +notfound: + giterr_set( + GITERR_REFERENCE, + "Reflog for '%s' has only %"PRIuZ" entries, asked for %"PRIuZ, + git_reference_name(ref), numentries, identifier); + + git_reflog_free(reflog); + return GIT_ENOTFOUND; +} + +static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position) +{ + git_reference *ref; + git_oid oid; + int error = -1; + + if (*base_ref == NULL) { + if ((error = git_reference_dwim(&ref, repo, identifier)) < 0) + return error; + } else { + ref = *base_ref; + *base_ref = NULL; + } + + if (position == 0) { + error = git_object_lookup(out, repo, git_reference_target(ref), GIT_OBJ_ANY); + goto cleanup; + } + + if ((error = retrieve_oid_from_reflog(&oid, ref, position)) < 0) + goto cleanup; + + error = git_object_lookup(out, repo, &oid, GIT_OBJ_ANY); + +cleanup: + git_reference_free(ref); + return error; +} + +static int retrieve_remote_tracking_reference(git_reference **base_ref, const char *identifier, git_repository *repo) +{ + git_reference *tracking, *ref; + int error = -1; + + if (*base_ref == NULL) { + if ((error = git_reference_dwim(&ref, repo, identifier)) < 0) + return error; + } else { + ref = *base_ref; + *base_ref = NULL; + } + + if (!git_reference_is_branch(ref)) { + error = GIT_EINVALIDSPEC; + goto cleanup; + } + + if ((error = git_branch_upstream(&tracking, ref)) < 0) + goto cleanup; + + *base_ref = tracking; + +cleanup: + git_reference_free(ref); + return error; +} + +static int handle_at_syntax(git_object **out, git_reference **ref, const char *spec, size_t identifier_len, git_repository* repo, const char *curly_braces_content) +{ + bool is_numeric; + int parsed = 0, error = -1; + git_buf identifier = GIT_BUF_INIT; + git_time_t timestamp; + + assert(*out == NULL); + + if (git_buf_put(&identifier, spec, identifier_len) < 0) + return -1; + + is_numeric = !try_parse_numeric(&parsed, curly_braces_content); + + if (*curly_braces_content == '-' && (!is_numeric || parsed == 0)) { + error = GIT_EINVALIDSPEC; + goto cleanup; + } + + if (is_numeric) { + if (parsed < 0) + error = retrieve_previously_checked_out_branch_or_revision(out, ref, repo, git_buf_cstr(&identifier), -parsed); + else + error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), parsed); + + goto cleanup; + } + + if (!strcmp(curly_braces_content, "u") || !strcmp(curly_braces_content, "upstream")) { + error = retrieve_remote_tracking_reference(ref, git_buf_cstr(&identifier), repo); + + goto cleanup; + } + + if (git__date_parse(×tamp, curly_braces_content) < 0) + goto cleanup; + + error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (size_t)timestamp); + +cleanup: + git_buf_free(&identifier); + return error; +} + +static git_otype parse_obj_type(const char *str) +{ + if (!strcmp(str, "commit")) + return GIT_OBJ_COMMIT; + + if (!strcmp(str, "tree")) + return GIT_OBJ_TREE; + + if (!strcmp(str, "blob")) + return GIT_OBJ_BLOB; + + if (!strcmp(str, "tag")) + return GIT_OBJ_TAG; + + return GIT_OBJ_BAD; +} + +static int dereference_to_non_tag(git_object **out, git_object *obj) +{ + if (git_object_type(obj) == GIT_OBJ_TAG) + return git_tag_peel(out, (git_tag *)obj); + + return git_object_dup(out, obj); +} + +static int handle_caret_parent_syntax(git_object **out, git_object *obj, int n) +{ + git_object *temp_commit = NULL; + int error; + + if ((error = git_object_peel(&temp_commit, obj, GIT_OBJ_COMMIT)) < 0) + return (error == GIT_EAMBIGUOUS || error == GIT_ENOTFOUND) ? + GIT_EINVALIDSPEC : error; + + if (n == 0) { + *out = temp_commit; + return 0; + } + + error = git_commit_parent((git_commit **)out, (git_commit*)temp_commit, n - 1); + + git_object_free(temp_commit); + return error; +} + +static int handle_linear_syntax(git_object **out, git_object *obj, int n) +{ + git_object *temp_commit = NULL; + int error; + + if ((error = git_object_peel(&temp_commit, obj, GIT_OBJ_COMMIT)) < 0) + return (error == GIT_EAMBIGUOUS || error == GIT_ENOTFOUND) ? + GIT_EINVALIDSPEC : error; + + error = git_commit_nth_gen_ancestor((git_commit **)out, (git_commit*)temp_commit, n); + + git_object_free(temp_commit); + return error; +} + +static int handle_colon_syntax( + git_object **out, + git_object *obj, + const char *path) +{ + git_object *tree; + int error = -1; + git_tree_entry *entry = NULL; + + if ((error = git_object_peel(&tree, obj, GIT_OBJ_TREE)) < 0) + return error == GIT_ENOTFOUND ? GIT_EINVALIDSPEC : error; + + if (*path == '\0') { + *out = tree; + return 0; + } + + /* + * TODO: Handle the relative path syntax + * (:./relative/path and :../relative/path) + */ + if ((error = git_tree_entry_bypath(&entry, (git_tree *)tree, path)) < 0) + goto cleanup; + + error = git_tree_entry_to_object(out, git_object_owner(tree), entry); + +cleanup: + git_tree_entry_free(entry); + git_object_free(tree); + + return error; +} + +static int walk_and_search(git_object **out, git_revwalk *walk, regex_t *regex) +{ + int error; + git_oid oid; + git_object *obj; + + while (!(error = git_revwalk_next(&oid, walk))) { + + error = git_object_lookup(&obj, git_revwalk_repository(walk), &oid, GIT_OBJ_COMMIT); + if ((error < 0) && (error != GIT_ENOTFOUND)) + return -1; + + if (!regexec(regex, git_commit_message((git_commit*)obj), 0, NULL, 0)) { + *out = obj; + return 0; + } + + git_object_free(obj); + } + + if (error < 0 && error == GIT_ITEROVER) + error = GIT_ENOTFOUND; + + return error; +} + +static int handle_grep_syntax(git_object **out, git_repository *repo, const git_oid *spec_oid, const char *pattern) +{ + regex_t preg; + git_revwalk *walk = NULL; + int error; + + if ((error = build_regex(&preg, pattern)) < 0) + return error; + + if ((error = git_revwalk_new(&walk, repo)) < 0) + goto cleanup; + + git_revwalk_sorting(walk, GIT_SORT_TIME); + + if (spec_oid == NULL) { + if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0) + goto cleanup; + } else if ((error = git_revwalk_push(walk, spec_oid)) < 0) + goto cleanup; + + error = walk_and_search(out, walk, &preg); + +cleanup: + regfree(&preg); + git_revwalk_free(walk); + + return error; +} + +static int handle_caret_curly_syntax(git_object **out, git_object *obj, const char *curly_braces_content) +{ + git_otype expected_type; + + if (*curly_braces_content == '\0') + return dereference_to_non_tag(out, obj); + + if (*curly_braces_content == '/') + return handle_grep_syntax(out, git_object_owner(obj), git_object_id(obj), curly_braces_content + 1); + + expected_type = parse_obj_type(curly_braces_content); + + if (expected_type == GIT_OBJ_BAD) + return GIT_EINVALIDSPEC; + + return git_object_peel(out, obj, expected_type); +} + +static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t *pos) +{ + git_buf_clear(buf); + + assert(spec[*pos] == '^' || spec[*pos] == '@'); + + (*pos)++; + + if (spec[*pos] == '\0' || spec[*pos] != '{') + return GIT_EINVALIDSPEC; + + (*pos)++; + + while (spec[*pos] != '}') { + if (spec[*pos] == '\0') + return GIT_EINVALIDSPEC; + + git_buf_putc(buf, spec[(*pos)++]); + } + + (*pos)++; + + return 0; +} + +static int extract_path(git_buf *buf, const char *spec, size_t *pos) +{ + git_buf_clear(buf); + + assert(spec[*pos] == ':'); + + (*pos)++; + + if (git_buf_puts(buf, spec + *pos) < 0) + return -1; + + *pos += git_buf_len(buf); + + return 0; +} + +static int extract_how_many(int *n, const char *spec, size_t *pos) +{ + const char *end_ptr; + int parsed, accumulated; + char kind = spec[*pos]; + + assert(spec[*pos] == '^' || spec[*pos] == '~'); + + accumulated = 0; + + do { + do { + (*pos)++; + accumulated++; + } while (spec[(*pos)] == kind && kind == '~'); + + if (git__isdigit(spec[*pos])) { + if (git__strtol32(&parsed, spec + *pos, &end_ptr, 10) < 0) + return GIT_EINVALIDSPEC; + + accumulated += (parsed - 1); + *pos = end_ptr - spec; + } + + } while (spec[(*pos)] == kind && kind == '~'); + + *n = accumulated; + + return 0; +} + +static int object_from_reference(git_object **object, git_reference *reference) +{ + git_reference *resolved = NULL; + int error; + + if (git_reference_resolve(&resolved, reference) < 0) + return -1; + + error = git_object_lookup(object, reference->db->repo, git_reference_target(resolved), GIT_OBJ_ANY); + git_reference_free(resolved); + + return error; +} + +static int ensure_base_rev_loaded(git_object **object, git_reference **reference, const char *spec, size_t identifier_len, git_repository *repo, bool allow_empty_identifier) +{ + int error; + git_buf identifier = GIT_BUF_INIT; + + if (*object != NULL) + return 0; + + if (*reference != NULL) + return object_from_reference(object, *reference); + + if (!allow_empty_identifier && identifier_len == 0) + return GIT_EINVALIDSPEC; + + if (git_buf_put(&identifier, spec, identifier_len) < 0) + return -1; + + error = revparse_lookup_object(object, reference, repo, git_buf_cstr(&identifier)); + git_buf_free(&identifier); + + return error; +} + +static int ensure_base_rev_is_not_known_yet(git_object *object) +{ + if (object == NULL) + return 0; + + return GIT_EINVALIDSPEC; +} + +static bool any_left_hand_identifier(git_object *object, git_reference *reference, size_t identifier_len) +{ + if (object != NULL) + return true; + + if (reference != NULL) + return true; + + if (identifier_len > 0) + return true; + + return false; +} + +static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_reference *reference) +{ + if (!ensure_base_rev_is_not_known_yet(object) && reference == NULL) + return 0; + + return GIT_EINVALIDSPEC; +} + +int revparse__ext( + git_object **object_out, + git_reference **reference_out, + size_t *identifier_len_out, + git_repository *repo, + const char *spec) +{ + size_t pos = 0, identifier_len = 0; + int error = -1, n; + git_buf buf = GIT_BUF_INIT; + + git_reference *reference = NULL; + git_object *base_rev = NULL; + + bool should_return_reference = true; + + assert(object_out && reference_out && repo && spec); + + *object_out = NULL; + *reference_out = NULL; + + while (spec[pos]) { + switch (spec[pos]) { + case '^': + should_return_reference = false; + + if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) + goto cleanup; + + if (spec[pos+1] == '{') { + git_object *temp_object = NULL; + + if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0) + goto cleanup; + + if ((error = handle_caret_curly_syntax(&temp_object, base_rev, git_buf_cstr(&buf))) < 0) + goto cleanup; + + git_object_free(base_rev); + base_rev = temp_object; + } else { + git_object *temp_object = NULL; + + if ((error = extract_how_many(&n, spec, &pos)) < 0) + goto cleanup; + + if ((error = handle_caret_parent_syntax(&temp_object, base_rev, n)) < 0) + goto cleanup; + + git_object_free(base_rev); + base_rev = temp_object; + } + break; + + case '~': + { + git_object *temp_object = NULL; + + should_return_reference = false; + + if ((error = extract_how_many(&n, spec, &pos)) < 0) + goto cleanup; + + if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) + goto cleanup; + + if ((error = handle_linear_syntax(&temp_object, base_rev, n)) < 0) + goto cleanup; + + git_object_free(base_rev); + base_rev = temp_object; + break; + } + + case ':': + { + git_object *temp_object = NULL; + + should_return_reference = false; + + if ((error = extract_path(&buf, spec, &pos)) < 0) + goto cleanup; + + if (any_left_hand_identifier(base_rev, reference, identifier_len)) { + if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, true)) < 0) + goto cleanup; + + if ((error = handle_colon_syntax(&temp_object, base_rev, git_buf_cstr(&buf))) < 0) + goto cleanup; + } else { + if (*git_buf_cstr(&buf) == '/') { + if ((error = handle_grep_syntax(&temp_object, repo, NULL, git_buf_cstr(&buf) + 1)) < 0) + goto cleanup; + } else { + + /* + * TODO: support merge-stage path lookup (":2:Makefile") + * and plain index blob lookup (:i-am/a/blob) + */ + giterr_set(GITERR_INVALID, "Unimplemented"); + error = GIT_ERROR; + goto cleanup; + } + } + + git_object_free(base_rev); + base_rev = temp_object; + break; + } + + case '@': + { + if (spec[pos+1] == '{') { + git_object *temp_object = NULL; + + if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0) + goto cleanup; + + if ((error = ensure_base_rev_is_not_known_yet(base_rev)) < 0) + goto cleanup; + + if ((error = handle_at_syntax(&temp_object, &reference, spec, identifier_len, repo, git_buf_cstr(&buf))) < 0) + goto cleanup; + + if (temp_object != NULL) + base_rev = temp_object; + break; + } else { + /* Fall through */ + } + } + + default: + if ((error = ensure_left_hand_identifier_is_not_known_yet(base_rev, reference)) < 0) + goto cleanup; + + pos++; + identifier_len++; + } + } + + if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) + goto cleanup; + + if (!should_return_reference) { + git_reference_free(reference); + reference = NULL; + } + + *object_out = base_rev; + *reference_out = reference; + *identifier_len_out = identifier_len; + error = 0; + +cleanup: + if (error) { + if (error == GIT_EINVALIDSPEC) + giterr_set(GITERR_INVALID, + "Failed to parse revision specifier - Invalid pattern '%s'", spec); + + git_object_free(base_rev); + git_reference_free(reference); + } + + git_buf_free(&buf); + return error; +} + +int git_revparse_ext( + git_object **object_out, + git_reference **reference_out, + git_repository *repo, + const char *spec) +{ + int error; + size_t identifier_len; + git_object *obj = NULL; + git_reference *ref = NULL; + + if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0) + goto cleanup; + + *object_out = obj; + *reference_out = ref; + GIT_UNUSED(identifier_len); + + return 0; + +cleanup: + git_object_free(obj); + git_reference_free(ref); + return error; +} + +int git_revparse_single(git_object **out, git_repository *repo, const char *spec) +{ + int error; + git_object *obj = NULL; + git_reference *ref = NULL; + + *out = NULL; + + if ((error = git_revparse_ext(&obj, &ref, repo, spec)) < 0) + goto cleanup; + + git_reference_free(ref); + + *out = obj; + + return 0; + +cleanup: + git_object_free(obj); + git_reference_free(ref); + return error; +} + +int git_revparse( + git_revspec *revspec, + git_repository *repo, + const char *spec) +{ + const char *dotdot; + int error = 0; + + assert(revspec && repo && spec); + + memset(revspec, 0x0, sizeof(*revspec)); + + if ((dotdot = strstr(spec, "..")) != NULL) { + char *lstr; + const char *rstr; + revspec->flags = GIT_REVPARSE_RANGE; + + lstr = git__substrdup(spec, dotdot - spec); + rstr = dotdot + 2; + if (dotdot[2] == '.') { + revspec->flags |= GIT_REVPARSE_MERGE_BASE; + rstr++; + } + + error = git_revparse_single(&revspec->from, repo, lstr); + if (!error) + error = git_revparse_single(&revspec->to, repo, rstr); + + git__free((void*)lstr); + } else { + revspec->flags = GIT_REVPARSE_SINGLE; + error = git_revparse_single(&revspec->from, repo, spec); + } + + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/revwalk.c b/deps/libgit2-sys-0.2.17/libgit2/src/revwalk.c new file mode 100644 index 000000000..a6d823ec8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/revwalk.c @@ -0,0 +1,648 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "commit.h" +#include "odb.h" +#include "pool.h" + +#include "revwalk.h" +#include "git2/revparse.h" +#include "merge.h" + +GIT__USE_OIDMAP; + +git_commit_list_node *git_revwalk__commit_lookup( + git_revwalk *walk, const git_oid *oid) +{ + git_commit_list_node *commit; + khiter_t pos; + int ret; + + /* lookup and reserve space if not already present */ + pos = kh_get(oid, walk->commits, oid); + if (pos != kh_end(walk->commits)) + return kh_value(walk->commits, pos); + + commit = git_commit_list_alloc_node(walk); + if (commit == NULL) + return NULL; + + git_oid_cpy(&commit->oid, oid); + + pos = kh_put(oid, walk->commits, &commit->oid, &ret); + assert(ret != 0); + kh_value(walk->commits, pos) = commit; + + return commit; +} + +static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit) +{ + int error; + unsigned short i; + git_array_t(git_commit_list_node *) pending = GIT_ARRAY_INIT; + git_commit_list_node **tmp; + + assert(commit); + + do { + commit->uninteresting = 1; + + if ((error = git_commit_list_parse(walk, commit)) < 0) + return error; + + for (i = 0; i < commit->out_degree; ++i) + if (!commit->parents[i]->uninteresting) { + git_commit_list_node **node = git_array_alloc(pending); + GITERR_CHECK_ALLOC(node); + *node = commit->parents[i]; + } + + tmp = git_array_pop(pending); + commit = tmp ? *tmp : NULL; + + } while (commit != NULL); + + git_array_clear(pending); + + return 0; +} + +static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int hide) +{ + int error; + + if (!hide && walk->hide_cb) + hide = walk->hide_cb(&commit->oid, walk->hide_cb_payload); + + if (hide && mark_uninteresting(walk, commit) < 0) + return -1; + + if (commit->seen) + return 0; + + commit->seen = 1; + + if ((error = git_commit_list_parse(walk, commit)) < 0) + return error; + + if (!hide) + return walk->enqueue(walk, commit); + + return 0; +} + +static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit) +{ + unsigned short i, max; + int error = 0; + + max = commit->out_degree; + if (walk->first_parent && commit->out_degree) + max = 1; + + for (i = 0; i < max && !error; ++i) + error = process_commit(walk, commit->parents[i], commit->uninteresting); + + return error; +} + +static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting, int from_glob) +{ + git_oid commit_id; + int error; + git_object *obj, *oobj; + git_commit_list_node *commit; + git_commit_list *list; + + if ((error = git_object_lookup(&oobj, walk->repo, oid, GIT_OBJ_ANY)) < 0) + return error; + + error = git_object_peel(&obj, oobj, GIT_OBJ_COMMIT); + git_object_free(oobj); + + if (error == GIT_ENOTFOUND || error == GIT_EINVALIDSPEC || error == GIT_EPEEL) { + /* If this comes from e.g. push_glob("tags"), ignore this */ + if (from_glob) + return 0; + + giterr_set(GITERR_INVALID, "Object is not a committish"); + return -1; + } + if (error < 0) + return error; + + git_oid_cpy(&commit_id, git_object_id(obj)); + git_object_free(obj); + + commit = git_revwalk__commit_lookup(walk, &commit_id); + if (commit == NULL) + return -1; /* error already reported by failed lookup */ + + if (uninteresting) + walk->did_hide = 1; + else + walk->did_push = 1; + + commit->uninteresting = uninteresting; + list = walk->user_input; + if (git_commit_list_insert(commit, &list) == NULL) { + giterr_set_oom(); + return -1; + } + + walk->user_input = list; + + return 0; +} + +int git_revwalk_push(git_revwalk *walk, const git_oid *oid) +{ + assert(walk && oid); + return push_commit(walk, oid, 0, false); +} + + +int git_revwalk_hide(git_revwalk *walk, const git_oid *oid) +{ + assert(walk && oid); + return push_commit(walk, oid, 1, false); +} + +static int push_ref(git_revwalk *walk, const char *refname, int hide, int from_glob) +{ + git_oid oid; + + if (git_reference_name_to_id(&oid, walk->repo, refname) < 0) + return -1; + + return push_commit(walk, &oid, hide, from_glob); +} + +static int push_glob(git_revwalk *walk, const char *glob, int hide) +{ + int error = 0; + git_buf buf = GIT_BUF_INIT; + git_reference *ref; + git_reference_iterator *iter; + size_t wildcard; + + assert(walk && glob); + + /* refs/ is implied if not given in the glob */ + if (git__prefixcmp(glob, GIT_REFS_DIR) != 0) + git_buf_joinpath(&buf, GIT_REFS_DIR, glob); + else + git_buf_puts(&buf, glob); + if (git_buf_oom(&buf)) + return -1; + + /* If no '?', '*' or '[' exist, we append '/ *' to the glob */ + wildcard = strcspn(glob, "?*["); + if (!glob[wildcard]) + git_buf_put(&buf, "/*", 2); + + if ((error = git_reference_iterator_glob_new(&iter, walk->repo, buf.ptr)) < 0) + goto out; + + while ((error = git_reference_next(&ref, iter)) == 0) { + error = push_ref(walk, git_reference_name(ref), hide, true); + git_reference_free(ref); + if (error < 0) + break; + } + git_reference_iterator_free(iter); + + if (error == GIT_ITEROVER) + error = 0; +out: + git_buf_free(&buf); + return error; +} + +int git_revwalk_push_glob(git_revwalk *walk, const char *glob) +{ + assert(walk && glob); + return push_glob(walk, glob, 0); +} + +int git_revwalk_hide_glob(git_revwalk *walk, const char *glob) +{ + assert(walk && glob); + return push_glob(walk, glob, 1); +} + +int git_revwalk_push_head(git_revwalk *walk) +{ + assert(walk); + return push_ref(walk, GIT_HEAD_FILE, 0, false); +} + +int git_revwalk_hide_head(git_revwalk *walk) +{ + assert(walk); + return push_ref(walk, GIT_HEAD_FILE, 1, false); +} + +int git_revwalk_push_ref(git_revwalk *walk, const char *refname) +{ + assert(walk && refname); + return push_ref(walk, refname, 0, false); +} + +int git_revwalk_push_range(git_revwalk *walk, const char *range) +{ + git_revspec revspec; + int error = 0; + + if ((error = git_revparse(&revspec, walk->repo, range))) + return error; + + if (revspec.flags & GIT_REVPARSE_MERGE_BASE) { + /* TODO: support "..." */ + giterr_set(GITERR_INVALID, "Symmetric differences not implemented in revwalk"); + return GIT_EINVALIDSPEC; + } + + if ((error = push_commit(walk, git_object_id(revspec.from), 1, false))) + goto out; + + error = push_commit(walk, git_object_id(revspec.to), 0, false); + +out: + git_object_free(revspec.from); + git_object_free(revspec.to); + return error; +} + +int git_revwalk_hide_ref(git_revwalk *walk, const char *refname) +{ + assert(walk && refname); + return push_ref(walk, refname, 1, false); +} + +static int revwalk_enqueue_timesort(git_revwalk *walk, git_commit_list_node *commit) +{ + return git_pqueue_insert(&walk->iterator_time, commit); +} + +static int revwalk_enqueue_unsorted(git_revwalk *walk, git_commit_list_node *commit) +{ + return git_commit_list_insert(commit, &walk->iterator_rand) ? 0 : -1; +} + +static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk *walk) +{ + int error; + git_commit_list_node *next; + + while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) + if (!next->uninteresting) { + if ((error = process_commit_parents(walk, next)) < 0) + return error; + + *object_out = next; + return 0; + } + + giterr_clear(); + return GIT_ITEROVER; +} + +static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk *walk) +{ + int error; + git_commit_list_node *next; + + while ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL) + if (!next->uninteresting) { + if ((error = process_commit_parents(walk, next)) < 0) + return error; + + *object_out = next; + return 0; + } + + giterr_clear(); + return GIT_ITEROVER; +} + +static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk *walk) +{ + git_commit_list_node *next; + unsigned short i, max; + + for (;;) { + next = git_commit_list_pop(&walk->iterator_topo); + if (next == NULL) { + giterr_clear(); + return GIT_ITEROVER; + } + + if (next->in_degree > 0) { + next->topo_delay = 1; + continue; + } + + + max = next->out_degree; + if (walk->first_parent && next->out_degree) + max = 1; + + for (i = 0; i < max; ++i) { + git_commit_list_node *parent = next->parents[i]; + + if (--parent->in_degree == 0 && parent->topo_delay) { + parent->topo_delay = 0; + if (git_commit_list_insert(parent, &walk->iterator_topo) == NULL) + return -1; + } + } + + *object_out = next; + return 0; + } +} + +static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *walk) +{ + *object_out = git_commit_list_pop(&walk->iterator_reverse); + return *object_out ? 0 : GIT_ITEROVER; +} + + +static int interesting(git_pqueue *list) +{ + size_t i; + + for (i = 0; i < git_pqueue_size(list); i++) { + git_commit_list_node *commit = git_pqueue_get(list, i); + if (!commit->uninteresting) + return 1; + } + + return 0; +} + +static int contains(git_pqueue *list, git_commit_list_node *node) +{ + size_t i; + + for (i = 0; i < git_pqueue_size(list); i++) { + git_commit_list_node *commit = git_pqueue_get(list, i); + if (commit == node) + return 1; + } + + return 0; +} + +static int premark_uninteresting(git_revwalk *walk) +{ + int error = 0; + unsigned short i; + git_pqueue q; + git_commit_list *list; + git_commit_list_node *commit, *parent; + + if ((error = git_pqueue_init(&q, 0, 8, git_commit_list_time_cmp)) < 0) + return error; + + for (list = walk->user_input; list; list = list->next) { + if ((error = git_commit_list_parse(walk, list->item)) < 0) + goto cleanup; + + if ((error = git_pqueue_insert(&q, list->item)) < 0) + goto cleanup; + } + + while (interesting(&q)) { + commit = git_pqueue_pop(&q); + + for (i = 0; i < commit->out_degree; i++) { + parent = commit->parents[i]; + + if ((error = git_commit_list_parse(walk, parent)) < 0) + goto cleanup; + + if (commit->uninteresting) + parent->uninteresting = 1; + + if (contains(&q, parent)) + continue; + + if ((error = git_pqueue_insert(&q, parent)) < 0) + goto cleanup; + } + } + +cleanup: + git_pqueue_free(&q); + return error; +} + +static int prepare_walk(git_revwalk *walk) +{ + int error; + git_commit_list *list; + git_commit_list_node *next; + + /* If there were no pushes, we know that the walk is already over */ + if (!walk->did_push) { + giterr_clear(); + return GIT_ITEROVER; + } + + if (walk->did_hide && (error = premark_uninteresting(walk)) < 0) + return error; + + for (list = walk->user_input; list; list = list->next) { + if (process_commit(walk, list->item, list->item->uninteresting) < 0) + return -1; + } + + + if (walk->sorting & GIT_SORT_TOPOLOGICAL) { + unsigned short i; + + while ((error = walk->get_next(&next, walk)) == 0) { + for (i = 0; i < next->out_degree; ++i) { + git_commit_list_node *parent = next->parents[i]; + parent->in_degree++; + } + + if (git_commit_list_insert(next, &walk->iterator_topo) == NULL) + return -1; + } + + if (error != GIT_ITEROVER) + return error; + + walk->get_next = &revwalk_next_toposort; + } + + if (walk->sorting & GIT_SORT_REVERSE) { + + while ((error = walk->get_next(&next, walk)) == 0) + if (git_commit_list_insert(next, &walk->iterator_reverse) == NULL) + return -1; + + if (error != GIT_ITEROVER) + return error; + + walk->get_next = &revwalk_next_reverse; + } + + walk->walking = 1; + return 0; +} + + +int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo) +{ + git_revwalk *walk = git__calloc(1, sizeof(git_revwalk)); + GITERR_CHECK_ALLOC(walk); + + walk->commits = git_oidmap_alloc(); + GITERR_CHECK_ALLOC(walk->commits); + + if (git_pqueue_init( + &walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0 || + git_pool_init(&walk->commit_pool, 1, + git_pool__suggest_items_per_page(COMMIT_ALLOC) * COMMIT_ALLOC) < 0) + return -1; + + walk->get_next = &revwalk_next_unsorted; + walk->enqueue = &revwalk_enqueue_unsorted; + + walk->repo = repo; + + if (git_repository_odb(&walk->odb, repo) < 0) { + git_revwalk_free(walk); + return -1; + } + + *revwalk_out = walk; + return 0; +} + +void git_revwalk_free(git_revwalk *walk) +{ + if (walk == NULL) + return; + + git_revwalk_reset(walk); + git_odb_free(walk->odb); + + git_oidmap_free(walk->commits); + git_pool_clear(&walk->commit_pool); + git_pqueue_free(&walk->iterator_time); + git__free(walk); +} + +git_repository *git_revwalk_repository(git_revwalk *walk) +{ + assert(walk); + return walk->repo; +} + +void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode) +{ + assert(walk); + + if (walk->walking) + git_revwalk_reset(walk); + + walk->sorting = sort_mode; + + if (walk->sorting & GIT_SORT_TIME) { + walk->get_next = &revwalk_next_timesort; + walk->enqueue = &revwalk_enqueue_timesort; + } else { + walk->get_next = &revwalk_next_unsorted; + walk->enqueue = &revwalk_enqueue_unsorted; + } +} + +void git_revwalk_simplify_first_parent(git_revwalk *walk) +{ + walk->first_parent = 1; +} + +int git_revwalk_next(git_oid *oid, git_revwalk *walk) +{ + int error; + git_commit_list_node *next; + + assert(walk && oid); + + if (!walk->walking) { + if ((error = prepare_walk(walk)) < 0) + return error; + } + + error = walk->get_next(&next, walk); + + if (error == GIT_ITEROVER) { + git_revwalk_reset(walk); + giterr_clear(); + return GIT_ITEROVER; + } + + if (!error) + git_oid_cpy(oid, &next->oid); + + return error; +} + +void git_revwalk_reset(git_revwalk *walk) +{ + git_commit_list_node *commit; + + assert(walk); + + kh_foreach_value(walk->commits, commit, { + commit->seen = 0; + commit->in_degree = 0; + commit->topo_delay = 0; + commit->uninteresting = 0; + commit->flags = 0; + }); + + git_pqueue_clear(&walk->iterator_time); + git_commit_list_free(&walk->iterator_topo); + git_commit_list_free(&walk->iterator_rand); + git_commit_list_free(&walk->iterator_reverse); + git_commit_list_free(&walk->user_input); + walk->first_parent = 0; + walk->walking = 0; + walk->did_push = walk->did_hide = 0; +} + +int git_revwalk_add_hide_cb( + git_revwalk *walk, + git_revwalk_hide_cb hide_cb, + void *payload) +{ + assert(walk); + + if (walk->walking) + git_revwalk_reset(walk); + + if (walk->hide_cb) { + /* There is already a callback added */ + giterr_set(GITERR_INVALID, "There is already a callback added to hide commits in revision walker."); + return -1; + } + + walk->hide_cb = hide_cb; + walk->hide_cb_payload = payload; + + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/revwalk.h b/deps/libgit2-sys-0.2.17/libgit2/src/revwalk.h new file mode 100644 index 000000000..6b363d40f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/revwalk.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_revwalk_h__ +#define INCLUDE_revwalk_h__ + +#include "git2/revwalk.h" +#include "oidmap.h" +#include "commit_list.h" +#include "pqueue.h" +#include "pool.h" +#include "vector.h" + +#include "oidmap.h" + +struct git_revwalk { + git_repository *repo; + git_odb *odb; + + git_oidmap *commits; + git_pool commit_pool; + + git_commit_list *iterator_topo; + git_commit_list *iterator_rand; + git_commit_list *iterator_reverse; + git_pqueue iterator_time; + + int (*get_next)(git_commit_list_node **, git_revwalk *); + int (*enqueue)(git_revwalk *, git_commit_list_node *); + + unsigned walking:1, + first_parent: 1, + did_hide: 1, + did_push: 1; + unsigned int sorting; + + /* the pushes and hides */ + git_commit_list *user_input; + + /* hide callback */ + git_revwalk_hide_cb hide_cb; + void *hide_cb_payload; +}; + +git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oid *oid); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/settings.c b/deps/libgit2-sys-0.2.17/libgit2/src/settings.c new file mode 100644 index 000000000..971b50935 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/settings.c @@ -0,0 +1,162 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifdef GIT_SSL +# include +#endif + +#include +#include "common.h" +#include "sysdir.h" +#include "cache.h" +#include "global.h" + +void git_libgit2_version(int *major, int *minor, int *rev) +{ + *major = LIBGIT2_VER_MAJOR; + *minor = LIBGIT2_VER_MINOR; + *rev = LIBGIT2_VER_REVISION; +} + +int git_libgit2_features() +{ + return 0 +#ifdef GIT_THREADS + | GIT_FEATURE_THREADS +#endif +#if defined(GIT_SSL) || defined(GIT_WINHTTP) + | GIT_FEATURE_HTTPS +#endif +#if defined(GIT_SSH) + | GIT_FEATURE_SSH +#endif + ; +} + +/* Declarations for tuneable settings */ +extern size_t git_mwindow__window_size; +extern size_t git_mwindow__mapped_limit; + +static int config_level_to_sysdir(int config_level) +{ + int val = -1; + + switch (config_level) { + case GIT_CONFIG_LEVEL_SYSTEM: val = GIT_SYSDIR_SYSTEM; break; + case GIT_CONFIG_LEVEL_XDG: val = GIT_SYSDIR_XDG; break; + case GIT_CONFIG_LEVEL_GLOBAL: val = GIT_SYSDIR_GLOBAL; break; + default: + giterr_set( + GITERR_INVALID, "Invalid config path selector %d", config_level); + } + + return val; +} + +int git_libgit2_opts(int key, ...) +{ + int error = 0; + va_list ap; + + va_start(ap, key); + + switch (key) { + case GIT_OPT_SET_MWINDOW_SIZE: + git_mwindow__window_size = va_arg(ap, size_t); + break; + + case GIT_OPT_GET_MWINDOW_SIZE: + *(va_arg(ap, size_t *)) = git_mwindow__window_size; + break; + + case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT: + git_mwindow__mapped_limit = va_arg(ap, size_t); + break; + + case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT: + *(va_arg(ap, size_t *)) = git_mwindow__mapped_limit; + break; + + case GIT_OPT_GET_SEARCH_PATH: + if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) { + git_buf *out = va_arg(ap, git_buf *); + const git_buf *tmp; + + git_buf_sanitize(out); + if ((error = git_sysdir_get(&tmp, error)) < 0) + break; + + error = git_buf_sets(out, tmp->ptr); + } + break; + + case GIT_OPT_SET_SEARCH_PATH: + if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) + error = git_sysdir_set(error, va_arg(ap, const char *)); + break; + + case GIT_OPT_SET_CACHE_OBJECT_LIMIT: + { + git_otype type = (git_otype)va_arg(ap, int); + size_t size = va_arg(ap, size_t); + error = git_cache_set_max_object_size(type, size); + break; + } + + case GIT_OPT_SET_CACHE_MAX_SIZE: + git_cache__max_storage = va_arg(ap, ssize_t); + break; + + case GIT_OPT_ENABLE_CACHING: + git_cache__enabled = (va_arg(ap, int) != 0); + break; + + case GIT_OPT_GET_CACHED_MEMORY: + *(va_arg(ap, ssize_t *)) = git_cache__current_storage.val; + *(va_arg(ap, ssize_t *)) = git_cache__max_storage; + break; + + case GIT_OPT_GET_TEMPLATE_PATH: + { + git_buf *out = va_arg(ap, git_buf *); + const git_buf *tmp; + + git_buf_sanitize(out); + if ((error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0) + break; + + error = git_buf_sets(out, tmp->ptr); + } + break; + + case GIT_OPT_SET_TEMPLATE_PATH: + error = git_sysdir_set(GIT_SYSDIR_TEMPLATE, va_arg(ap, const char *)); + break; + + case GIT_OPT_SET_SSL_CERT_LOCATIONS: +#ifdef GIT_SSL + { + const char *file = va_arg(ap, const char *); + const char *path = va_arg(ap, const char *); + if (!SSL_CTX_load_verify_locations(git__ssl_ctx, file, path)) { + giterr_set(GITERR_NET, "SSL error: %s", + ERR_error_string(ERR_get_error(), NULL)); + error = -1; + } + } +#else + giterr_set(GITERR_NET, "Cannot set certificate locations: OpenSSL is not enabled"); + error = -1; +#endif + break; + } + + va_end(ap); + + return error; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.c b/deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.c new file mode 100644 index 000000000..c6b561340 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.c @@ -0,0 +1,249 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include + +#include "sha1_lookup.h" +#include "common.h" +#include "oid.h" + +/* + * Conventional binary search loop looks like this: + * + * unsigned lo, hi; + * do { + * unsigned mi = (lo + hi) / 2; + * int cmp = "entry pointed at by mi" minus "target"; + * if (!cmp) + * return (mi is the wanted one) + * if (cmp > 0) + * hi = mi; "mi is larger than target" + * else + * lo = mi+1; "mi is smaller than target" + * } while (lo < hi); + * + * The invariants are: + * + * - When entering the loop, lo points at a slot that is never + * above the target (it could be at the target), hi points at a + * slot that is guaranteed to be above the target (it can never + * be at the target). + * + * - We find a point 'mi' between lo and hi (mi could be the same + * as lo, but never can be as same as hi), and check if it hits + * the target. There are three cases: + * + * - if it is a hit, we are happy. + * + * - if it is strictly higher than the target, we set it to hi, + * and repeat the search. + * + * - if it is strictly lower than the target, we update lo to + * one slot after it, because we allow lo to be at the target. + * + * If the loop exits, there is no matching entry. + * + * When choosing 'mi', we do not have to take the "middle" but + * anywhere in between lo and hi, as long as lo <= mi < hi is + * satisfied. When we somehow know that the distance between the + * target and lo is much shorter than the target and hi, we could + * pick mi that is much closer to lo than the midway. + * + * Now, we can take advantage of the fact that SHA-1 is a good hash + * function, and as long as there are enough entries in the table, we + * can expect uniform distribution. An entry that begins with for + * example "deadbeef..." is much likely to appear much later than in + * the midway of the table. It can reasonably be expected to be near + * 87% (222/256) from the top of the table. + * + * However, we do not want to pick "mi" too precisely. If the entry at + * the 87% in the above example turns out to be higher than the target + * we are looking for, we would end up narrowing the search space down + * only by 13%, instead of 50% we would get if we did a simple binary + * search. So we would want to hedge our bets by being less aggressive. + * + * The table at "table" holds at least "nr" entries of "elem_size" + * bytes each. Each entry has the SHA-1 key at "key_offset". The + * table is sorted by the SHA-1 key of the entries. The caller wants + * to find the entry with "key", and knows that the entry at "lo" is + * not higher than the entry it is looking for, and that the entry at + * "hi" is higher than the entry it is looking for. + */ +int sha1_entry_pos(const void *table, + size_t elem_size, + size_t key_offset, + unsigned lo, unsigned hi, unsigned nr, + const unsigned char *key) +{ + const unsigned char *base = (const unsigned char*)table; + const unsigned char *hi_key, *lo_key; + unsigned ofs_0; + + if (!nr || lo >= hi) + return -1; + + if (nr == hi) + hi_key = NULL; + else + hi_key = base + elem_size * hi + key_offset; + lo_key = base + elem_size * lo + key_offset; + + ofs_0 = 0; + do { + int cmp; + unsigned ofs, mi, range; + unsigned lov, hiv, kyv; + const unsigned char *mi_key; + + range = hi - lo; + if (hi_key) { + for (ofs = ofs_0; ofs < 20; ofs++) + if (lo_key[ofs] != hi_key[ofs]) + break; + ofs_0 = ofs; + /* + * byte 0 thru (ofs-1) are the same between + * lo and hi; ofs is the first byte that is + * different. + * + * If ofs==20, then no bytes are different, + * meaning we have entries with duplicate + * keys. We know that we are in a solid run + * of this entry (because the entries are + * sorted, and our lo and hi are the same, + * there can be nothing but this single key + * in between). So we can stop the search. + * Either one of these entries is it (and + * we do not care which), or we do not have + * it. + * + * Furthermore, we know that one of our + * endpoints must be the edge of the run of + * duplicates. For example, given this + * sequence: + * + * idx 0 1 2 3 4 5 + * key A C C C C D + * + * If we are searching for "B", we might + * hit the duplicate run at lo=1, hi=3 + * (e.g., by first mi=3, then mi=0). But we + * can never have lo > 1, because B < C. + * That is, if our key is less than the + * run, we know that "lo" is the edge, but + * we can say nothing of "hi". Similarly, + * if our key is greater than the run, we + * know that "hi" is the edge, but we can + * say nothing of "lo". + * + * Therefore if we do not find it, we also + * know where it would go if it did exist: + * just on the far side of the edge that we + * know about. + */ + if (ofs == 20) { + mi = lo; + mi_key = base + elem_size * mi + key_offset; + cmp = memcmp(mi_key, key, 20); + if (!cmp) + return mi; + if (cmp < 0) + return -1 - hi; + else + return -1 - lo; + } + + hiv = hi_key[ofs_0]; + if (ofs_0 < 19) + hiv = (hiv << 8) | hi_key[ofs_0+1]; + } else { + hiv = 256; + if (ofs_0 < 19) + hiv <<= 8; + } + lov = lo_key[ofs_0]; + kyv = key[ofs_0]; + if (ofs_0 < 19) { + lov = (lov << 8) | lo_key[ofs_0+1]; + kyv = (kyv << 8) | key[ofs_0+1]; + } + assert(lov < hiv); + + if (kyv < lov) + return -1 - lo; + if (hiv < kyv) + return -1 - hi; + + /* + * Even if we know the target is much closer to 'hi' + * than 'lo', if we pick too precisely and overshoot + * (e.g. when we know 'mi' is closer to 'hi' than to + * 'lo', pick 'mi' that is higher than the target), we + * end up narrowing the search space by a smaller + * amount (i.e. the distance between 'mi' and 'hi') + * than what we would have (i.e. about half of 'lo' + * and 'hi'). Hedge our bets to pick 'mi' less + * aggressively, i.e. make 'mi' a bit closer to the + * middle than we would otherwise pick. + */ + kyv = (kyv * 6 + lov + hiv) / 8; + if (lov < hiv - 1) { + if (kyv == lov) + kyv++; + else if (kyv == hiv) + kyv--; + } + mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo; + +#ifdef INDEX_DEBUG_LOOKUP + printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi); + printf("ofs %u lov %x, hiv %x, kyv %x\n", + ofs_0, lov, hiv, kyv); +#endif + + if (!(lo <= mi && mi < hi)) { + giterr_set(GITERR_INVALID, "Assertion failure. Binary search invariant is false"); + return -1; + } + + mi_key = base + elem_size * mi + key_offset; + cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0); + if (!cmp) + return mi; + if (cmp > 0) { + hi = mi; + hi_key = mi_key; + } else { + lo = mi + 1; + lo_key = mi_key + elem_size; + } + } while (lo < hi); + return -((int)lo)-1; +} + +int sha1_position(const void *table, + size_t stride, + unsigned lo, unsigned hi, + const unsigned char *key) +{ + const unsigned char *base = table; + + do { + unsigned mi = (lo + hi) / 2; + int cmp = git_oid__hashcmp(base + mi * stride, key); + + if (!cmp) + return mi; + + if (cmp > 0) + hi = mi; + else + lo = mi+1; + } while (lo < hi); + + return -((int)lo)-1; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.h b/deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.h new file mode 100644 index 000000000..3799620c7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/sha1_lookup.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sha1_lookup_h__ +#define INCLUDE_sha1_lookup_h__ + +#include + +int sha1_entry_pos(const void *table, + size_t elem_size, + size_t key_offset, + unsigned lo, unsigned hi, unsigned nr, + const unsigned char *key); + +int sha1_position(const void *table, + size_t stride, + unsigned lo, unsigned hi, + const unsigned char *key); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/signature.c b/deps/libgit2-sys-0.2.17/libgit2/src/signature.c new file mode 100644 index 000000000..818cd300e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/signature.c @@ -0,0 +1,283 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "signature.h" +#include "repository.h" +#include "git2/common.h" +#include "posix.h" + +void git_signature_free(git_signature *sig) +{ + if (sig == NULL) + return; + + git__free(sig->name); + sig->name = NULL; + git__free(sig->email); + sig->email = NULL; + git__free(sig); +} + +static int signature_error(const char *msg) +{ + giterr_set(GITERR_INVALID, "Failed to parse signature - %s", msg); + return -1; +} + +static bool contains_angle_brackets(const char *input) +{ + return strchr(input, '<') != NULL || strchr(input, '>') != NULL; +} + +static char *extract_trimmed(const char *ptr, size_t len) +{ + while (len && git__isspace(ptr[0])) { + ptr++; len--; + } + + while (len && git__isspace(ptr[len - 1])) { + len--; + } + + return git__substrdup(ptr, len); +} + +int git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset) +{ + git_signature *p = NULL; + + assert(name && email); + + *sig_out = NULL; + + if (contains_angle_brackets(name) || + contains_angle_brackets(email)) { + return signature_error( + "Neither `name` nor `email` should contain angle brackets chars."); + } + + p = git__calloc(1, sizeof(git_signature)); + GITERR_CHECK_ALLOC(p); + + p->name = extract_trimmed(name, strlen(name)); + p->email = extract_trimmed(email, strlen(email)); + + if (p->name == NULL || p->email == NULL) + return -1; /* oom */ + + if (p->name[0] == '\0' || p->email[0] == '\0') { + git_signature_free(p); + return signature_error("Signature cannot have an empty name or email"); + } + + p->when.time = time; + p->when.offset = offset; + + *sig_out = p; + return 0; +} + +int git_signature_dup(git_signature **dest, const git_signature *source) +{ + git_signature *signature; + + if (source == NULL) + return 0; + + signature = git__calloc(1, sizeof(git_signature)); + GITERR_CHECK_ALLOC(signature); + + signature->name = git__strdup(source->name); + GITERR_CHECK_ALLOC(signature->name); + + signature->email = git__strdup(source->email); + GITERR_CHECK_ALLOC(signature->email); + + signature->when.time = source->when.time; + signature->when.offset = source->when.offset; + + *dest = signature; + + return 0; +} + +int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool) +{ + git_signature *signature; + + if (source == NULL) + return 0; + + signature = git_pool_mallocz(pool, sizeof(git_signature)); + GITERR_CHECK_ALLOC(signature); + + signature->name = git_pool_strdup(pool, source->name); + GITERR_CHECK_ALLOC(signature->name); + + signature->email = git_pool_strdup(pool, source->email); + GITERR_CHECK_ALLOC(signature->email); + + signature->when.time = source->when.time; + signature->when.offset = source->when.offset; + + *dest = signature; + + return 0; +} + +int git_signature_now(git_signature **sig_out, const char *name, const char *email) +{ + time_t now; + time_t offset; + struct tm *utc_tm; + git_signature *sig; + struct tm _utc; + + *sig_out = NULL; + + /* + * Get the current time as seconds since the epoch and + * transform that into a tm struct containing the time at + * UTC. Give that to mktime which considers it a local time + * (tm_isdst = -1 asks it to take DST into account) and gives + * us that time as seconds since the epoch. The difference + * between its return value and 'now' is our offset to UTC. + */ + time(&now); + utc_tm = p_gmtime_r(&now, &_utc); + utc_tm->tm_isdst = -1; + offset = (time_t)difftime(now, mktime(utc_tm)); + offset /= 60; + + if (git_signature_new(&sig, name, email, now, (int)offset) < 0) + return -1; + + *sig_out = sig; + + return 0; +} + +int git_signature_default(git_signature **out, git_repository *repo) +{ + int error; + git_config *cfg; + const char *user_name, *user_email; + + if ((error = git_repository_config_snapshot(&cfg, repo)) < 0) + return error; + + if (!(error = git_config_get_string(&user_name, cfg, "user.name")) && + !(error = git_config_get_string(&user_email, cfg, "user.email"))) + error = git_signature_now(out, user_name, user_email); + + git_config_free(cfg); + return error; +} + +int git_signature__parse(git_signature *sig, const char **buffer_out, + const char *buffer_end, const char *header, char ender) +{ + const char *buffer = *buffer_out; + const char *email_start, *email_end; + + memset(sig, 0, sizeof(git_signature)); + + if ((buffer_end = memchr(buffer, ender, buffer_end - buffer)) == NULL) + return signature_error("no newline given"); + + if (header) { + const size_t header_len = strlen(header); + + if (buffer + header_len >= buffer_end || memcmp(buffer, header, header_len) != 0) + return signature_error("expected prefix doesn't match actual"); + + buffer += header_len; + } + + email_start = git__memrchr(buffer, '<', buffer_end - buffer); + email_end = git__memrchr(buffer, '>', buffer_end - buffer); + + if (!email_start || !email_end || email_end <= email_start) + return signature_error("malformed e-mail"); + + email_start += 1; + sig->name = extract_trimmed(buffer, email_start - buffer - 1); + sig->email = extract_trimmed(email_start, email_end - email_start); + + /* Do we even have a time at the end of the signature? */ + if (email_end + 2 < buffer_end) { + const char *time_start = email_end + 2; + const char *time_end; + + if (git__strtol64(&sig->when.time, time_start, &time_end, 10) < 0) + return signature_error("invalid Unix timestamp"); + + /* do we have a timezone? */ + if (time_end + 1 < buffer_end) { + int offset, hours, mins; + const char *tz_start, *tz_end; + + tz_start = time_end + 1; + + if ((tz_start[0] != '-' && tz_start[0] != '+') || + git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0) { + //malformed timezone, just assume it's zero + offset = 0; + } + + hours = offset / 100; + mins = offset % 100; + + /* + * only store timezone if it's not overflowing; + * see http://www.worldtimezone.com/faq.html + */ + if (hours < 14 && mins < 59) { + sig->when.offset = (hours * 60) + mins; + if (tz_start[0] == '-') + sig->when.offset = -sig->when.offset; + } + } + } + + *buffer_out = buffer_end + 1; + return 0; +} + +void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig) +{ + int offset, hours, mins; + char sign; + + assert(buf && sig); + + offset = sig->when.offset; + sign = (sig->when.offset < 0) ? '-' : '+'; + + if (offset < 0) + offset = -offset; + + hours = offset / 60; + mins = offset % 60; + + git_buf_printf(buf, "%s%s <%s> %u %c%02d%02d\n", + header ? header : "", sig->name, sig->email, + (unsigned)sig->when.time, sign, hours, mins); +} + +bool git_signature__equal(const git_signature *one, const git_signature *two) +{ + assert(one && two); + + return + git__strcmp(one->name, two->name) == 0 && + git__strcmp(one->email, two->email) == 0 && + one->when.time == two->when.time && + one->when.offset == two->when.offset; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/signature.h b/deps/libgit2-sys-0.2.17/libgit2/src/signature.h new file mode 100644 index 000000000..75265df52 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/signature.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_signature_h__ +#define INCLUDE_signature_h__ + +#include "git2/common.h" +#include "git2/signature.h" +#include "repository.h" +#include + +int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender); +void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig); +bool git_signature__equal(const git_signature *one, const git_signature *two); + +int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.c b/deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.c new file mode 100644 index 000000000..71f49118e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.c @@ -0,0 +1,212 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "posix.h" +#include "netops.h" +#include "stream.h" +#include "socket_stream.h" + +#ifndef _WIN32 +# include +# include +# include +# include +# include +# include +# include +#else +# include +# include +# ifdef _MSC_VER +# pragma comment(lib, "ws2_32") +# endif +#endif + +#ifdef GIT_WIN32 +static void net_set_error(const char *str) +{ + int error = WSAGetLastError(); + char * win32_error = git_win32_get_error_message(error); + + if (win32_error) { + giterr_set(GITERR_NET, "%s: %s", str, win32_error); + git__free(win32_error); + } else { + giterr_set(GITERR_NET, str); + } +} +#else +static void net_set_error(const char *str) +{ + giterr_set(GITERR_NET, "%s: %s", str, strerror(errno)); +} +#endif + +static int close_socket(GIT_SOCKET s) +{ + if (s == INVALID_SOCKET) + return 0; + +#ifdef GIT_WIN32 + if (SOCKET_ERROR == closesocket(s)) + return -1; + + if (0 != WSACleanup()) { + giterr_set(GITERR_OS, "Winsock cleanup failed"); + return -1; + } + + return 0; +#else + return close(s); +#endif + +} + +int socket_connect(git_stream *stream) +{ + struct addrinfo *info = NULL, *p; + struct addrinfo hints; + git_socket_stream *st = (git_socket_stream *) stream; + GIT_SOCKET s = INVALID_SOCKET; + int ret; + +#ifdef GIT_WIN32 + /* on win32, the WSA context needs to be initialized + * before any socket calls can be performed */ + WSADATA wsd; + + if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { + giterr_set(GITERR_OS, "Winsock init failed"); + return -1; + } + + if (LOBYTE(wsd.wVersion) != 2 || HIBYTE(wsd.wVersion) != 2) { + WSACleanup(); + giterr_set(GITERR_OS, "Winsock init failed"); + return -1; + } +#endif + + memset(&hints, 0x0, sizeof(struct addrinfo)); + hints.ai_socktype = SOCK_STREAM; + hints.ai_family = AF_UNSPEC; + + if ((ret = p_getaddrinfo(st->host, st->port, &hints, &info)) != 0) { + giterr_set(GITERR_NET, + "Failed to resolve address for %s: %s", st->host, p_gai_strerror(ret)); + return -1; + } + + for (p = info; p != NULL; p = p->ai_next) { + s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); + + if (s == INVALID_SOCKET) { + net_set_error("error creating socket"); + break; + } + + if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0) + break; + + /* If we can't connect, try the next one */ + close_socket(s); + s = INVALID_SOCKET; + } + + /* Oops, we couldn't connect to any address */ + if (s == INVALID_SOCKET && p == NULL) { + giterr_set(GITERR_OS, "Failed to connect to %s", st->host); + p_freeaddrinfo(info); + return -1; + } + + st->s = s; + p_freeaddrinfo(info); + return 0; +} + +ssize_t socket_write(git_stream *stream, const char *data, size_t len, int flags) +{ + ssize_t ret; + size_t off = 0; + git_socket_stream *st = (git_socket_stream *) stream; + + while (off < len) { + errno = 0; + ret = p_send(st->s, data + off, len - off, flags); + if (ret < 0) { + net_set_error("Error sending data"); + return -1; + } + + off += ret; + } + + return off; +} + +ssize_t socket_read(git_stream *stream, void *data, size_t len) +{ + ssize_t ret; + git_socket_stream *st = (git_socket_stream *) stream; + + if ((ret = p_recv(st->s, data, len, 0)) < 0) + net_set_error("Error receiving socket data"); + + return ret; +} + +int socket_close(git_stream *stream) +{ + git_socket_stream *st = (git_socket_stream *) stream; + int error; + + error = close_socket(st->s); + st->s = INVALID_SOCKET; + + return error; +} + +void socket_free(git_stream *stream) +{ + git_socket_stream *st = (git_socket_stream *) stream; + + git__free(st->host); + git__free(st->port); + git__free(st); +} + +int git_socket_stream_new(git_stream **out, const char *host, const char *port) +{ + git_socket_stream *st; + + assert(out && host); + + st = git__calloc(1, sizeof(git_socket_stream)); + GITERR_CHECK_ALLOC(st); + + st->host = git__strdup(host); + GITERR_CHECK_ALLOC(st->host); + + if (port) { + st->port = git__strdup(port); + GITERR_CHECK_ALLOC(st->port); + } + + st->parent.version = GIT_STREAM_VERSION; + st->parent.connect = socket_connect; + st->parent.write = socket_write; + st->parent.read = socket_read; + st->parent.close = socket_close; + st->parent.free = socket_free; + st->s = INVALID_SOCKET; + + *out = (git_stream *) st; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.h b/deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.h new file mode 100644 index 000000000..8e9949fcd --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/socket_stream.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_socket_stream_h__ +#define INCLUDE_socket_stream_h__ + +#include "netops.h" + +typedef struct { + git_stream parent; + char *host; + char *port; + GIT_SOCKET s; +} git_socket_stream; + +extern int git_socket_stream_new(git_stream **out, const char *host, const char *port); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.c b/deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.c new file mode 100644 index 000000000..115175724 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.c @@ -0,0 +1,380 @@ +#include "sortedcache.h" + +GIT__USE_STRMAP + +int git_sortedcache_new( + git_sortedcache **out, + size_t item_path_offset, + git_sortedcache_free_item_fn free_item, + void *free_item_payload, + git_vector_cmp item_cmp, + const char *path) +{ + git_sortedcache *sc; + size_t pathlen, alloclen; + + pathlen = path ? strlen(path) : 0; + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + sc = git__calloc(1, alloclen); + GITERR_CHECK_ALLOC(sc); + + if (git_pool_init(&sc->pool, 1, 0) < 0 || + git_vector_init(&sc->items, 4, item_cmp) < 0 || + git_strmap_alloc(&sc->map) < 0) + goto fail; + + if (git_rwlock_init(&sc->lock)) { + giterr_set(GITERR_OS, "Failed to initialize lock"); + goto fail; + } + + sc->item_path_offset = item_path_offset; + sc->free_item = free_item; + sc->free_item_payload = free_item_payload; + GIT_REFCOUNT_INC(sc); + if (pathlen) + memcpy(sc->path, path, pathlen); + + *out = sc; + return 0; + +fail: + git_strmap_free(sc->map); + git_vector_free(&sc->items); + git_pool_clear(&sc->pool); + git__free(sc); + return -1; +} + +void git_sortedcache_incref(git_sortedcache *sc) +{ + GIT_REFCOUNT_INC(sc); +} + +const char *git_sortedcache_path(git_sortedcache *sc) +{ + return sc->path; +} + +static void sortedcache_clear(git_sortedcache *sc) +{ + git_strmap_clear(sc->map); + + if (sc->free_item) { + size_t i; + void *item; + + git_vector_foreach(&sc->items, i, item) { + sc->free_item(sc->free_item_payload, item); + } + } + + git_vector_clear(&sc->items); + + git_pool_clear(&sc->pool); +} + +static void sortedcache_free(git_sortedcache *sc) +{ + /* acquire write lock to make sure everyone else is done */ + if (git_sortedcache_wlock(sc) < 0) + return; + + sortedcache_clear(sc); + git_vector_free(&sc->items); + git_strmap_free(sc->map); + + git_sortedcache_wunlock(sc); + + git_rwlock_free(&sc->lock); + git__free(sc); +} + +void git_sortedcache_free(git_sortedcache *sc) +{ + if (!sc) + return; + GIT_REFCOUNT_DEC(sc, sortedcache_free); +} + +static int sortedcache_copy_item(void *payload, void *tgt_item, void *src_item) +{ + git_sortedcache *sc = payload; + /* path will already have been copied by upsert */ + memcpy(tgt_item, src_item, sc->item_path_offset); + return 0; +} + +/* copy a sorted cache */ +int git_sortedcache_copy( + git_sortedcache **out, + git_sortedcache *src, + bool lock, + int (*copy_item)(void *payload, void *tgt_item, void *src_item), + void *payload) +{ + int error = 0; + git_sortedcache *tgt; + size_t i; + void *src_item, *tgt_item; + + /* just use memcpy if no special copy fn is passed in */ + if (!copy_item) { + copy_item = sortedcache_copy_item; + payload = src; + } + + if ((error = git_sortedcache_new( + &tgt, src->item_path_offset, + src->free_item, src->free_item_payload, + src->items._cmp, src->path)) < 0) + return error; + + if (lock && git_sortedcache_rlock(src) < 0) { + git_sortedcache_free(tgt); + return -1; + } + + git_vector_foreach(&src->items, i, src_item) { + char *path = ((char *)src_item) + src->item_path_offset; + + if ((error = git_sortedcache_upsert(&tgt_item, tgt, path)) < 0 || + (error = copy_item(payload, tgt_item, src_item)) < 0) + break; + } + + if (lock) + git_sortedcache_runlock(src); + if (error) + git_sortedcache_free(tgt); + + *out = !error ? tgt : NULL; + + return error; +} + +/* lock sortedcache while making modifications */ +int git_sortedcache_wlock(git_sortedcache *sc) +{ + GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ + + if (git_rwlock_wrlock(&sc->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire write lock on cache"); + return -1; + } + return 0; +} + +/* unlock sorted cache when done with modifications */ +void git_sortedcache_wunlock(git_sortedcache *sc) +{ + git_vector_sort(&sc->items); + git_rwlock_wrunlock(&sc->lock); +} + +/* lock sortedcache for read */ +int git_sortedcache_rlock(git_sortedcache *sc) +{ + GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ + + if (git_rwlock_rdlock(&sc->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire read lock on cache"); + return -1; + } + return 0; +} + +/* unlock sorted cache when done reading */ +void git_sortedcache_runlock(git_sortedcache *sc) +{ + GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ + git_rwlock_rdunlock(&sc->lock); +} + +/* if the file has changed, lock cache and load file contents into buf; + * returns <0 on error, >0 if file has not changed + */ +int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf) +{ + int error, fd; + + if ((error = git_sortedcache_wlock(sc)) < 0) + return error; + + if ((error = git_futils_filestamp_check(&sc->stamp, sc->path)) <= 0) + goto unlock; + + if (!git__is_sizet(sc->stamp.size)) { + giterr_set(GITERR_INVALID, "Unable to load file larger than size_t"); + error = -1; + goto unlock; + } + + if ((fd = git_futils_open_ro(sc->path)) < 0) { + error = fd; + goto unlock; + } + + if (buf) + error = git_futils_readbuffer_fd(buf, fd, (size_t)sc->stamp.size); + + (void)p_close(fd); + + if (error < 0) + goto unlock; + + return 1; /* return 1 -> file needs reload and was successfully loaded */ + +unlock: + git_sortedcache_wunlock(sc); + return error; +} + +void git_sortedcache_updated(git_sortedcache *sc) +{ + /* update filestamp to latest value */ + git_futils_filestamp_check(&sc->stamp, sc->path); +} + +/* release all items in sorted cache */ +int git_sortedcache_clear(git_sortedcache *sc, bool wlock) +{ + if (wlock && git_sortedcache_wlock(sc) < 0) + return -1; + + sortedcache_clear(sc); + + if (wlock) + git_sortedcache_wunlock(sc); + + return 0; +} + +/* find and/or insert item, returning pointer to item data */ +int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key) +{ + int error = 0; + khiter_t pos; + void *item; + size_t keylen, itemlen; + char *item_key; + + pos = git_strmap_lookup_index(sc->map, key); + if (git_strmap_valid_index(sc->map, pos)) { + item = git_strmap_value_at(sc->map, pos); + goto done; + } + + keylen = strlen(key); + itemlen = sc->item_path_offset + keylen + 1; + itemlen = (itemlen + 7) & ~7; + + if ((item = git_pool_mallocz(&sc->pool, (uint32_t)itemlen)) == NULL) { + /* don't use GITERR_CHECK_ALLOC b/c of lock */ + error = -1; + goto done; + } + + /* one strange thing is that even if the vector or hash table insert + * fail, there is no way to free the pool item so we just abandon it + */ + + item_key = ((char *)item) + sc->item_path_offset; + memcpy(item_key, key, keylen); + + pos = kh_put(str, sc->map, item_key, &error); + if (error < 0) + goto done; + + if (!error) + kh_key(sc->map, pos) = item_key; + kh_val(sc->map, pos) = item; + + error = git_vector_insert(&sc->items, item); + if (error < 0) + git_strmap_delete_at(sc->map, pos); + +done: + if (out) + *out = !error ? item : NULL; + return error; +} + +/* lookup item by key */ +void *git_sortedcache_lookup(const git_sortedcache *sc, const char *key) +{ + khiter_t pos = git_strmap_lookup_index(sc->map, key); + if (git_strmap_valid_index(sc->map, pos)) + return git_strmap_value_at(sc->map, pos); + return NULL; +} + +/* find out how many items are in the cache */ +size_t git_sortedcache_entrycount(const git_sortedcache *sc) +{ + return git_vector_length(&sc->items); +} + +/* lookup item by index */ +void *git_sortedcache_entry(git_sortedcache *sc, size_t pos) +{ + /* make sure the items are sorted so this gets the correct item */ + if (!git_vector_is_sorted(&sc->items)) + git_vector_sort(&sc->items); + + return git_vector_get(&sc->items, pos); +} + +/* helper struct so bsearch callback can know offset + key value for cmp */ +struct sortedcache_magic_key { + size_t offset; + const char *key; +}; + +static int sortedcache_magic_cmp(const void *key, const void *value) +{ + const struct sortedcache_magic_key *magic = key; + const char *value_key = ((const char *)value) + magic->offset; + return strcmp(magic->key, value_key); +} + +/* lookup index of item by key */ +int git_sortedcache_lookup_index( + size_t *out, git_sortedcache *sc, const char *key) +{ + struct sortedcache_magic_key magic; + + magic.offset = sc->item_path_offset; + magic.key = key; + + return git_vector_bsearch2(out, &sc->items, sortedcache_magic_cmp, &magic); +} + +/* remove entry from cache */ +int git_sortedcache_remove(git_sortedcache *sc, size_t pos) +{ + char *item; + khiter_t mappos; + + /* because of pool allocation, this can't actually remove the item, + * but we can remove it from the items vector and the hash table. + */ + + if ((item = git_vector_get(&sc->items, pos)) == NULL) { + giterr_set(GITERR_INVALID, "Removing item out of range"); + return GIT_ENOTFOUND; + } + + (void)git_vector_remove(&sc->items, pos); + + mappos = git_strmap_lookup_index(sc->map, item + sc->item_path_offset); + git_strmap_delete_at(sc->map, mappos); + + if (sc->free_item) + sc->free_item(sc->free_item_payload, item); + + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.h b/deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.h new file mode 100644 index 000000000..4cacad62b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/sortedcache.h @@ -0,0 +1,178 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sorted_cache_h__ +#define INCLUDE_sorted_cache_h__ + +#include "util.h" +#include "fileops.h" +#include "vector.h" +#include "thread-utils.h" +#include "pool.h" +#include "strmap.h" + +#include + +/* + * The purpose of this data structure is to cache the parsed contents of a + * file (a.k.a. the backing file) where each item in the file can be + * identified by a key string and you want to both look them up by name + * and traverse them in sorted order. Each item is assumed to itself end + * in a GIT_FLEX_ARRAY. + */ + +typedef void (*git_sortedcache_free_item_fn)(void *payload, void *item); + +typedef struct { + git_refcount rc; + git_rwlock lock; + size_t item_path_offset; + git_sortedcache_free_item_fn free_item; + void *free_item_payload; + git_pool pool; + git_vector items; + git_strmap *map; + git_futils_filestamp stamp; + char path[GIT_FLEX_ARRAY]; +} git_sortedcache; + +/* Create a new sortedcache + * + * Even though every sortedcache stores items with a GIT_FLEX_ARRAY at + * the end containing their key string, you have to provide the item_cmp + * sorting function because the sorting function doesn't get a payload + * and therefore can't know the offset to the item key string. :-( + * + * @param out The allocated git_sortedcache + * @param item_path_offset Offset to the GIT_FLEX_ARRAY item key in the + * struct - use offsetof(struct mine, key-field) to get this + * @param free_item Optional callback to free each item + * @param free_item_payload Optional payload passed to free_item callback + * @param item_cmp Compare the keys of two items + * @param path The path to the backing store file for this cache; this + * may be NULL. The cache makes it easy to load this and check + * if it has been modified since the last load and/or write. + */ +int git_sortedcache_new( + git_sortedcache **out, + size_t item_path_offset, /* use offsetof(struct, path-field) macro */ + git_sortedcache_free_item_fn free_item, + void *free_item_payload, + git_vector_cmp item_cmp, + const char *path); + +/* Copy a sorted cache + * + * - `copy_item` can be NULL to just use memcpy + * - if `lock`, grabs read lock on `src` during copy and releases after + */ +int git_sortedcache_copy( + git_sortedcache **out, + git_sortedcache *src, + bool lock, + int (*copy_item)(void *payload, void *tgt_item, void *src_item), + void *payload); + +/* Free sorted cache (first calling `free_item` callbacks) + * + * Don't call on a locked collection - it may acquire a write lock + */ +void git_sortedcache_free(git_sortedcache *sc); + +/* Increment reference count - balance with call to free */ +void git_sortedcache_incref(git_sortedcache *sc); + +/* Get the pathname associated with this cache at creation time */ +const char *git_sortedcache_path(git_sortedcache *sc); + +/* + * CACHE WRITE FUNCTIONS + * + * The following functions require you to have a writer lock to make the + * modification. Some of the functions take a `wlock` parameter and + * will optionally lock and unlock for you if that is passed as true. + * + */ + +/* Lock sortedcache for write */ +int git_sortedcache_wlock(git_sortedcache *sc); + +/* Unlock sorted cache when done with write */ +void git_sortedcache_wunlock(git_sortedcache *sc); + +/* Lock cache and load backing file into a buffer. + * + * This grabs a write lock on the cache then looks at the modification + * time and size of the file on disk. + * + * If the file appears to have changed, this loads the file contents into + * the buffer and returns a positive value leaving the cache locked - the + * caller should parse the file content, update the cache as needed, then + * release the lock. NOTE: In this case, the caller MUST unlock the cache. + * + * If the file appears to be unchanged, then this automatically releases + * the lock on the cache, clears the buffer, and returns 0. + * + * @return 0 if up-to-date, 1 if out-of-date, <0 on error + */ +int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf); + +/* Refresh file timestamp after write completes + * You should already be holding the write lock when you call this. + */ +void git_sortedcache_updated(git_sortedcache *sc); + +/* Release all items in sorted cache + * + * If `wlock` is true, grabs write lock and releases when done, otherwise + * you should already be holding a write lock when you call this. + */ +int git_sortedcache_clear(git_sortedcache *sc, bool wlock); + +/* Find and/or insert item, returning pointer to item data. + * You should already be holding the write lock when you call this. + */ +int git_sortedcache_upsert( + void **out, git_sortedcache *sc, const char *key); + +/* Removes entry at pos from cache + * You should already be holding the write lock when you call this. + */ +int git_sortedcache_remove(git_sortedcache *sc, size_t pos); + +/* + * CACHE READ FUNCTIONS + * + * The following functions access items in the cache. To prevent the + * results from being invalidated before they can be used, you should be + * holding either a read lock or a write lock when using these functions. + * + */ + +/* Lock sortedcache for read */ +int git_sortedcache_rlock(git_sortedcache *sc); + +/* Unlock sorted cache when done with read */ +void git_sortedcache_runlock(git_sortedcache *sc); + +/* Lookup item by key - returns NULL if not found */ +void *git_sortedcache_lookup(const git_sortedcache *sc, const char *key); + +/* Get how many items are in the cache + * + * You can call this function without holding a lock, but be aware + * that it may change before you use it. + */ +size_t git_sortedcache_entrycount(const git_sortedcache *sc); + +/* Lookup item by index - returns NULL if out of range */ +void *git_sortedcache_entry(git_sortedcache *sc, size_t pos); + +/* Lookup index of item by key - returns GIT_ENOTFOUND if not found */ +int git_sortedcache_lookup_index( + size_t *out, git_sortedcache *sc, const char *key); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/stash.c b/deps/libgit2-sys-0.2.17/libgit2/src/stash.c new file mode 100644 index 000000000..8aa48cafe --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/stash.c @@ -0,0 +1,653 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "repository.h" +#include "commit.h" +#include "tree.h" +#include "reflog.h" +#include "git2/diff.h" +#include "git2/stash.h" +#include "git2/status.h" +#include "git2/checkout.h" +#include "git2/index.h" +#include "git2/transaction.h" +#include "signature.h" + +static int create_error(int error, const char *msg) +{ + giterr_set(GITERR_STASH, "Cannot stash changes - %s", msg); + return error; +} + +static int retrieve_head(git_reference **out, git_repository *repo) +{ + int error = git_repository_head(out, repo); + + if (error == GIT_EUNBORNBRANCH) + return create_error(error, "You do not have the initial commit yet."); + + return error; +} + +static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit) +{ + char *formatted_oid; + + formatted_oid = git_oid_allocfmt(b_commit); + GITERR_CHECK_ALLOC(formatted_oid); + + git_buf_put(out, formatted_oid, 7); + git__free(formatted_oid); + + return git_buf_oom(out) ? -1 : 0; +} + +static int append_commit_description(git_buf *out, git_commit* commit) +{ + const char *message; + size_t pos = 0, len; + + if (append_abbreviated_oid(out, git_commit_id(commit)) < 0) + return -1; + + message = git_commit_message(commit); + len = strlen(message); + + /* TODO: Replace with proper commit short message + * when git_commit_message_short() is implemented. + */ + while (pos < len && message[pos] != '\n') + pos++; + + git_buf_putc(out, ' '); + git_buf_put(out, message, pos); + git_buf_putc(out, '\n'); + + return git_buf_oom(out) ? -1 : 0; +} + +static int retrieve_base_commit_and_message( + git_commit **b_commit, + git_buf *stash_message, + git_repository *repo) +{ + git_reference *head = NULL; + int error; + + if ((error = retrieve_head(&head, repo)) < 0) + return error; + + if (strcmp("HEAD", git_reference_name(head)) == 0) + error = git_buf_puts(stash_message, "(no branch): "); + else + error = git_buf_printf( + stash_message, + "%s: ", + git_reference_name(head) + strlen(GIT_REFS_HEADS_DIR)); + if (error < 0) + goto cleanup; + + if ((error = git_commit_lookup( + b_commit, repo, git_reference_target(head))) < 0) + goto cleanup; + + if ((error = append_commit_description(stash_message, *b_commit)) < 0) + goto cleanup; + +cleanup: + git_reference_free(head); + return error; +} + +static int build_tree_from_index(git_tree **out, git_index *index) +{ + int error; + git_oid i_tree_oid; + + if ((error = git_index_write_tree(&i_tree_oid, index)) < 0) + return -1; + + return git_tree_lookup(out, git_index_owner(index), &i_tree_oid); +} + +static int commit_index( + git_commit **i_commit, + git_index *index, + const git_signature *stasher, + const char *message, + const git_commit *parent) +{ + git_tree *i_tree = NULL; + git_oid i_commit_oid; + git_buf msg = GIT_BUF_INIT; + int error; + + if ((error = build_tree_from_index(&i_tree, index)) < 0) + goto cleanup; + + if ((error = git_buf_printf(&msg, "index on %s\n", message)) < 0) + goto cleanup; + + if ((error = git_commit_create( + &i_commit_oid, + git_index_owner(index), + NULL, + stasher, + stasher, + NULL, + git_buf_cstr(&msg), + i_tree, + 1, + &parent)) < 0) + goto cleanup; + + error = git_commit_lookup(i_commit, git_index_owner(index), &i_commit_oid); + +cleanup: + git_tree_free(i_tree); + git_buf_free(&msg); + return error; +} + +struct stash_update_rules { + bool include_changed; + bool include_untracked; + bool include_ignored; +}; + +static int stash_update_index_from_diff( + git_index *index, + const git_diff *diff, + struct stash_update_rules *data) +{ + int error = 0; + size_t d, max_d = git_diff_num_deltas(diff); + + for (d = 0; !error && d < max_d; ++d) { + const char *add_path = NULL; + const git_diff_delta *delta = git_diff_get_delta(diff, d); + + switch (delta->status) { + case GIT_DELTA_IGNORED: + if (data->include_ignored) + add_path = delta->new_file.path; + break; + + case GIT_DELTA_UNTRACKED: + if (data->include_untracked && + delta->new_file.mode != GIT_FILEMODE_TREE) + add_path = delta->new_file.path; + break; + + case GIT_DELTA_ADDED: + case GIT_DELTA_MODIFIED: + if (data->include_changed) + add_path = delta->new_file.path; + break; + + case GIT_DELTA_DELETED: + if (data->include_changed && + !git_index_find(NULL, index, delta->old_file.path)) + error = git_index_remove(index, delta->old_file.path, 0); + break; + + default: + /* Unimplemented */ + giterr_set( + GITERR_INVALID, + "Cannot update index. Unimplemented status (%d)", + delta->status); + return -1; + } + + if (add_path != NULL) + error = git_index_add_bypath(index, add_path); + } + + return error; +} + +static int build_untracked_tree( + git_tree **tree_out, + git_index *index, + git_commit *i_commit, + uint32_t flags) +{ + git_tree *i_tree = NULL; + git_diff *diff = NULL; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + struct stash_update_rules data = {0}; + int error; + + git_index_clear(index); + + if (flags & GIT_STASH_INCLUDE_UNTRACKED) { + opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | + GIT_DIFF_RECURSE_UNTRACKED_DIRS; + data.include_untracked = true; + } + + if (flags & GIT_STASH_INCLUDE_IGNORED) { + opts.flags |= GIT_DIFF_INCLUDE_IGNORED | + GIT_DIFF_RECURSE_IGNORED_DIRS; + data.include_ignored = true; + } + + if ((error = git_commit_tree(&i_tree, i_commit)) < 0) + goto cleanup; + + if ((error = git_diff_tree_to_workdir( + &diff, git_index_owner(index), i_tree, &opts)) < 0) + goto cleanup; + + if ((error = stash_update_index_from_diff(index, diff, &data)) < 0) + goto cleanup; + + error = build_tree_from_index(tree_out, index); + +cleanup: + git_diff_free(diff); + git_tree_free(i_tree); + return error; +} + +static int commit_untracked( + git_commit **u_commit, + git_index *index, + const git_signature *stasher, + const char *message, + git_commit *i_commit, + uint32_t flags) +{ + git_tree *u_tree = NULL; + git_oid u_commit_oid; + git_buf msg = GIT_BUF_INIT; + int error; + + if ((error = build_untracked_tree(&u_tree, index, i_commit, flags)) < 0) + goto cleanup; + + if ((error = git_buf_printf(&msg, "untracked files on %s\n", message)) < 0) + goto cleanup; + + if ((error = git_commit_create( + &u_commit_oid, + git_index_owner(index), + NULL, + stasher, + stasher, + NULL, + git_buf_cstr(&msg), + u_tree, + 0, + NULL)) < 0) + goto cleanup; + + error = git_commit_lookup(u_commit, git_index_owner(index), &u_commit_oid); + +cleanup: + git_tree_free(u_tree); + git_buf_free(&msg); + return error; +} + +static int build_workdir_tree( + git_tree **tree_out, + git_index *index, + git_commit *b_commit) +{ + git_repository *repo = git_index_owner(index); + git_tree *b_tree = NULL; + git_diff *diff = NULL; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + struct stash_update_rules data = {0}; + int error; + + opts.flags = GIT_DIFF_IGNORE_SUBMODULES; + + if ((error = git_commit_tree(&b_tree, b_commit)) < 0) + goto cleanup; + + if ((error = git_diff_tree_to_workdir(&diff, repo, b_tree, &opts)) < 0) + goto cleanup; + + data.include_changed = true; + + if ((error = stash_update_index_from_diff(index, diff, &data)) < 0) + goto cleanup; + + error = build_tree_from_index(tree_out, index); + +cleanup: + git_diff_free(diff); + git_tree_free(b_tree); + + return error; +} + +static int commit_worktree( + git_oid *w_commit_oid, + git_index *index, + const git_signature *stasher, + const char *message, + git_commit *i_commit, + git_commit *b_commit, + git_commit *u_commit) +{ + int error = 0; + git_tree *w_tree = NULL, *i_tree = NULL; + const git_commit *parents[] = { NULL, NULL, NULL }; + + parents[0] = b_commit; + parents[1] = i_commit; + parents[2] = u_commit; + + if ((error = git_commit_tree(&i_tree, i_commit)) < 0) + goto cleanup; + + if ((error = git_index_read_tree(index, i_tree)) < 0) + goto cleanup; + + if ((error = build_workdir_tree(&w_tree, index, b_commit)) < 0) + goto cleanup; + + error = git_commit_create( + w_commit_oid, + git_index_owner(index), + NULL, + stasher, + stasher, + NULL, + message, + w_tree, + u_commit ? 3 : 2, + parents); + +cleanup: + git_tree_free(i_tree); + git_tree_free(w_tree); + return error; +} + +static int prepare_worktree_commit_message( + git_buf* msg, + const char *user_message) +{ + git_buf buf = GIT_BUF_INIT; + int error; + + if ((error = git_buf_set(&buf, git_buf_cstr(msg), git_buf_len(msg))) < 0) + return error; + + git_buf_clear(msg); + + if (!user_message) + git_buf_printf(msg, "WIP on %s", git_buf_cstr(&buf)); + else { + const char *colon; + + if ((colon = strchr(git_buf_cstr(&buf), ':')) == NULL) + goto cleanup; + + git_buf_puts(msg, "On "); + git_buf_put(msg, git_buf_cstr(&buf), colon - buf.ptr); + git_buf_printf(msg, ": %s\n", user_message); + } + + error = (git_buf_oom(msg) || git_buf_oom(&buf)) ? -1 : 0; + +cleanup: + git_buf_free(&buf); + + return error; +} + +static int update_reflog( + git_oid *w_commit_oid, + git_repository *repo, + const char *message) +{ + git_reference *stash; + int error; + + if ((error = git_reference_ensure_log(repo, GIT_REFS_STASH_FILE)) < 0) + return error; + + error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1, message); + + git_reference_free(stash); + + return error; +} + +static int is_dirty_cb(const char *path, unsigned int status, void *payload) +{ + GIT_UNUSED(path); + GIT_UNUSED(status); + GIT_UNUSED(payload); + + return GIT_PASSTHROUGH; +} + +static int ensure_there_are_changes_to_stash( + git_repository *repo, + bool include_untracked_files, + bool include_ignored_files) +{ + int error; + git_status_options opts = GIT_STATUS_OPTIONS_INIT; + + opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR; + opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES; + + if (include_untracked_files) + opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED | + GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS; + + if (include_ignored_files) + opts.flags |= GIT_STATUS_OPT_INCLUDE_IGNORED | + GIT_STATUS_OPT_RECURSE_IGNORED_DIRS; + + error = git_status_foreach_ext(repo, &opts, is_dirty_cb, NULL); + + if (error == GIT_PASSTHROUGH) + return 0; + + if (!error) + return create_error(GIT_ENOTFOUND, "There is nothing to stash."); + + return error; +} + +static int reset_index_and_workdir( + git_repository *repo, + git_commit *commit, + bool remove_untracked, + bool remove_ignored) +{ + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; + + opts.checkout_strategy = GIT_CHECKOUT_FORCE; + + if (remove_untracked) + opts.checkout_strategy |= GIT_CHECKOUT_REMOVE_UNTRACKED; + + if (remove_ignored) + opts.checkout_strategy |= GIT_CHECKOUT_REMOVE_IGNORED; + + return git_checkout_tree(repo, (git_object *)commit, &opts); +} + +int git_stash_save( + git_oid *out, + git_repository *repo, + const git_signature *stasher, + const char *message, + uint32_t flags) +{ + git_index *index = NULL; + git_commit *b_commit = NULL, *i_commit = NULL, *u_commit = NULL; + git_buf msg = GIT_BUF_INIT; + int error; + + assert(out && repo && stasher); + + if ((error = git_repository__ensure_not_bare(repo, "stash save")) < 0) + return error; + + if ((error = retrieve_base_commit_and_message(&b_commit, &msg, repo)) < 0) + goto cleanup; + + if ((error = ensure_there_are_changes_to_stash( + repo, + (flags & GIT_STASH_INCLUDE_UNTRACKED) != 0, + (flags & GIT_STASH_INCLUDE_IGNORED) != 0)) < 0) + goto cleanup; + + if ((error = git_repository_index(&index, repo)) < 0) + goto cleanup; + + if ((error = commit_index( + &i_commit, index, stasher, git_buf_cstr(&msg), b_commit)) < 0) + goto cleanup; + + if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) && + (error = commit_untracked( + &u_commit, index, stasher, git_buf_cstr(&msg), + i_commit, flags)) < 0) + goto cleanup; + + if ((error = prepare_worktree_commit_message(&msg, message)) < 0) + goto cleanup; + + if ((error = commit_worktree( + out, index, stasher, git_buf_cstr(&msg), + i_commit, b_commit, u_commit)) < 0) + goto cleanup; + + git_buf_rtrim(&msg); + + if ((error = update_reflog(out, repo, git_buf_cstr(&msg))) < 0) + goto cleanup; + + if ((error = reset_index_and_workdir( + repo, + ((flags & GIT_STASH_KEEP_INDEX) != 0) ? i_commit : b_commit, + (flags & GIT_STASH_INCLUDE_UNTRACKED) != 0, + (flags & GIT_STASH_INCLUDE_IGNORED) != 0)) < 0) + goto cleanup; + +cleanup: + + git_buf_free(&msg); + git_commit_free(i_commit); + git_commit_free(b_commit); + git_commit_free(u_commit); + git_index_free(index); + + return error; +} + +int git_stash_foreach( + git_repository *repo, + git_stash_cb callback, + void *payload) +{ + git_reference *stash; + git_reflog *reflog = NULL; + int error; + size_t i, max; + const git_reflog_entry *entry; + + error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE); + if (error == GIT_ENOTFOUND) { + giterr_clear(); + return 0; + } + if (error < 0) + goto cleanup; + + if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0) + goto cleanup; + + max = git_reflog_entrycount(reflog); + for (i = 0; i < max; i++) { + entry = git_reflog_entry_byindex(reflog, i); + + error = callback(i, + git_reflog_entry_message(entry), + git_reflog_entry_id_new(entry), + payload); + + if (error) { + giterr_set_after_callback(error); + break; + } + } + +cleanup: + git_reference_free(stash); + git_reflog_free(reflog); + return error; +} + +int git_stash_drop( + git_repository *repo, + size_t index) +{ + git_transaction *tx; + git_reference *stash = NULL; + git_reflog *reflog = NULL; + size_t max; + int error; + + if ((error = git_transaction_new(&tx, repo)) < 0) + return error; + + if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0) + goto cleanup; + + if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0) + goto cleanup; + + if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0) + goto cleanup; + + max = git_reflog_entrycount(reflog); + + if (index > max - 1) { + error = GIT_ENOTFOUND; + giterr_set(GITERR_STASH, "No stashed state at position %" PRIuZ, index); + goto cleanup; + } + + if ((error = git_reflog_drop(reflog, index, true)) < 0) + goto cleanup; + + if ((error = git_transaction_set_reflog(tx, GIT_REFS_STASH_FILE, reflog)) < 0) + goto cleanup; + + if (max == 1) { + if ((error = git_transaction_remove(tx, GIT_REFS_STASH_FILE)) < 0) + goto cleanup; + } else if (index == 0) { + const git_reflog_entry *entry; + + entry = git_reflog_entry_byindex(reflog, 0); + if ((error = git_transaction_set_target(tx, GIT_REFS_STASH_FILE, &entry->oid_cur, NULL, NULL)) < 0) + goto cleanup; + } + + error = git_transaction_commit(tx); + +cleanup: + git_reference_free(stash); + git_transaction_free(tx); + git_reflog_free(reflog); + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/status.c b/deps/libgit2-sys-0.2.17/libgit2/src/status.c new file mode 100644 index 000000000..720ccb7eb --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/status.c @@ -0,0 +1,558 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "git2.h" +#include "fileops.h" +#include "hash.h" +#include "vector.h" +#include "tree.h" +#include "status.h" +#include "git2/status.h" +#include "repository.h" +#include "ignore.h" +#include "index.h" + +#include "git2/diff.h" +#include "diff.h" + +static unsigned int index_delta2status(const git_diff_delta *head2idx) +{ + git_status_t st = GIT_STATUS_CURRENT; + + switch (head2idx->status) { + case GIT_DELTA_ADDED: + case GIT_DELTA_COPIED: + st = GIT_STATUS_INDEX_NEW; + break; + case GIT_DELTA_DELETED: + st = GIT_STATUS_INDEX_DELETED; + break; + case GIT_DELTA_MODIFIED: + st = GIT_STATUS_INDEX_MODIFIED; + break; + case GIT_DELTA_RENAMED: + st = GIT_STATUS_INDEX_RENAMED; + + if (!git_oid_equal(&head2idx->old_file.id, &head2idx->new_file.id)) + st |= GIT_STATUS_INDEX_MODIFIED; + break; + case GIT_DELTA_TYPECHANGE: + st = GIT_STATUS_INDEX_TYPECHANGE; + break; + default: + break; + } + + return st; +} + +static unsigned int workdir_delta2status( + git_diff *diff, git_diff_delta *idx2wd) +{ + git_status_t st = GIT_STATUS_CURRENT; + + switch (idx2wd->status) { + case GIT_DELTA_ADDED: + case GIT_DELTA_COPIED: + case GIT_DELTA_UNTRACKED: + st = GIT_STATUS_WT_NEW; + break; + case GIT_DELTA_UNREADABLE: + st = GIT_STATUS_WT_UNREADABLE; + break; + case GIT_DELTA_DELETED: + st = GIT_STATUS_WT_DELETED; + break; + case GIT_DELTA_MODIFIED: + st = GIT_STATUS_WT_MODIFIED; + break; + case GIT_DELTA_IGNORED: + st = GIT_STATUS_IGNORED; + break; + case GIT_DELTA_RENAMED: + st = GIT_STATUS_WT_RENAMED; + + if (!git_oid_equal(&idx2wd->old_file.id, &idx2wd->new_file.id)) { + /* if OIDs don't match, we might need to calculate them now to + * discern between RENAMED vs RENAMED+MODIFED + */ + if (git_oid_iszero(&idx2wd->old_file.id) && + diff->old_src == GIT_ITERATOR_TYPE_WORKDIR && + !git_diff__oid_for_file( + &idx2wd->old_file.id, diff, idx2wd->old_file.path, + idx2wd->old_file.mode, idx2wd->old_file.size)) + idx2wd->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + if (git_oid_iszero(&idx2wd->new_file.id) && + diff->new_src == GIT_ITERATOR_TYPE_WORKDIR && + !git_diff__oid_for_file( + &idx2wd->new_file.id, diff, idx2wd->new_file.path, + idx2wd->new_file.mode, idx2wd->new_file.size)) + idx2wd->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; + + if (!git_oid_equal(&idx2wd->old_file.id, &idx2wd->new_file.id)) + st |= GIT_STATUS_WT_MODIFIED; + } + break; + case GIT_DELTA_TYPECHANGE: + st = GIT_STATUS_WT_TYPECHANGE; + break; + default: + break; + } + + return st; +} + +static bool status_is_included( + git_status_list *status, + git_diff_delta *head2idx, + git_diff_delta *idx2wd) +{ + if (!(status->opts.flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES)) + return 1; + + /* if excluding submodules and this is a submodule everywhere */ + if (head2idx) { + if (head2idx->status != GIT_DELTA_ADDED && + head2idx->old_file.mode != GIT_FILEMODE_COMMIT) + return 1; + if (head2idx->status != GIT_DELTA_DELETED && + head2idx->new_file.mode != GIT_FILEMODE_COMMIT) + return 1; + } + if (idx2wd) { + if (idx2wd->status != GIT_DELTA_ADDED && + idx2wd->old_file.mode != GIT_FILEMODE_COMMIT) + return 1; + if (idx2wd->status != GIT_DELTA_DELETED && + idx2wd->new_file.mode != GIT_FILEMODE_COMMIT) + return 1; + } + + /* only get here if every valid mode is GIT_FILEMODE_COMMIT */ + return 0; +} + +static git_status_t status_compute( + git_status_list *status, + git_diff_delta *head2idx, + git_diff_delta *idx2wd) +{ + git_status_t st = GIT_STATUS_CURRENT; + + if (head2idx) + st |= index_delta2status(head2idx); + + if (idx2wd) + st |= workdir_delta2status(status->idx2wd, idx2wd); + + return st; +} + +static int status_collect( + git_diff_delta *head2idx, + git_diff_delta *idx2wd, + void *payload) +{ + git_status_list *status = payload; + git_status_entry *status_entry; + + if (!status_is_included(status, head2idx, idx2wd)) + return 0; + + status_entry = git__malloc(sizeof(git_status_entry)); + GITERR_CHECK_ALLOC(status_entry); + + status_entry->status = status_compute(status, head2idx, idx2wd); + status_entry->head_to_index = head2idx; + status_entry->index_to_workdir = idx2wd; + + return git_vector_insert(&status->paired, status_entry); +} + +GIT_INLINE(int) status_entry_cmp_base( + const void *a, + const void *b, + int (*strcomp)(const char *a, const char *b)) +{ + const git_status_entry *entry_a = a; + const git_status_entry *entry_b = b; + const git_diff_delta *delta_a, *delta_b; + + delta_a = entry_a->index_to_workdir ? entry_a->index_to_workdir : + entry_a->head_to_index; + delta_b = entry_b->index_to_workdir ? entry_b->index_to_workdir : + entry_b->head_to_index; + + if (!delta_a && delta_b) + return -1; + if (delta_a && !delta_b) + return 1; + if (!delta_a && !delta_b) + return 0; + + return strcomp(delta_a->new_file.path, delta_b->new_file.path); +} + +static int status_entry_icmp(const void *a, const void *b) +{ + return status_entry_cmp_base(a, b, git__strcasecmp); +} + +static int status_entry_cmp(const void *a, const void *b) +{ + return status_entry_cmp_base(a, b, git__strcmp); +} + +static git_status_list *git_status_list_alloc(git_index *index) +{ + git_status_list *status = NULL; + int (*entrycmp)(const void *a, const void *b); + + if (!(status = git__calloc(1, sizeof(git_status_list)))) + return NULL; + + entrycmp = index->ignore_case ? status_entry_icmp : status_entry_cmp; + + if (git_vector_init(&status->paired, 0, entrycmp) < 0) { + git__free(status); + return NULL; + } + + return status; +} + +static int status_validate_options(const git_status_options *opts) +{ + if (!opts) + return 0; + + GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options"); + + if (opts->show > GIT_STATUS_SHOW_WORKDIR_ONLY) { + giterr_set(GITERR_INVALID, "Unknown status 'show' option"); + return -1; + } + + if ((opts->flags & GIT_STATUS_OPT_NO_REFRESH) != 0 && + (opts->flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) { + giterr_set(GITERR_INVALID, "Updating index from status " + "is not allowed when index refresh is disabled"); + return -1; + } + + return 0; +} + +int git_status_list_new( + git_status_list **out, + git_repository *repo, + const git_status_options *opts) +{ + git_index *index = NULL; + git_status_list *status = NULL; + git_diff_options diffopt = GIT_DIFF_OPTIONS_INIT; + git_diff_find_options findopt = GIT_DIFF_FIND_OPTIONS_INIT; + git_tree *head = NULL; + git_status_show_t show = + opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR; + int error = 0; + unsigned int flags = opts ? opts->flags : GIT_STATUS_OPT_DEFAULTS; + + *out = NULL; + + if (status_validate_options(opts) < 0) + return -1; + + if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 || + (error = git_repository_index(&index, repo)) < 0) + return error; + + /* if there is no HEAD, that's okay - we'll make an empty iterator */ + if ((error = git_repository_head_tree(&head, repo)) < 0) { + if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) + goto done; + giterr_clear(); + } + + /* refresh index from disk unless prevented */ + if ((flags & GIT_STATUS_OPT_NO_REFRESH) == 0 && + git_index_read(index, false) < 0) + giterr_clear(); + + status = git_status_list_alloc(index); + GITERR_CHECK_ALLOC(status); + + if (opts) { + memcpy(&status->opts, opts, sizeof(git_status_options)); + memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec)); + } + + diffopt.flags = GIT_DIFF_INCLUDE_TYPECHANGE; + findopt.flags = GIT_DIFF_FIND_FOR_UNTRACKED; + + if ((flags & GIT_STATUS_OPT_INCLUDE_UNTRACKED) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNTRACKED; + if ((flags & GIT_STATUS_OPT_INCLUDE_IGNORED) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_IGNORED; + if ((flags & GIT_STATUS_OPT_INCLUDE_UNMODIFIED) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNMODIFIED; + if ((flags & GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_UNTRACKED_DIRS; + if ((flags & GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_DISABLE_PATHSPEC_MATCH; + if ((flags & GIT_STATUS_OPT_RECURSE_IGNORED_DIRS) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_IGNORED_DIRS; + if ((flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES; + if ((flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_UPDATE_INDEX; + if ((flags & GIT_STATUS_OPT_INCLUDE_UNREADABLE) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNREADABLE; + if ((flags & GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED; + + if ((flags & GIT_STATUS_OPT_RENAMES_FROM_REWRITES) != 0) + findopt.flags = findopt.flags | + GIT_DIFF_FIND_AND_BREAK_REWRITES | + GIT_DIFF_FIND_RENAMES_FROM_REWRITES | + GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY; + + if (show != GIT_STATUS_SHOW_WORKDIR_ONLY) { + if ((error = git_diff_tree_to_index( + &status->head2idx, repo, head, index, &diffopt)) < 0) + goto done; + + if ((flags & GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX) != 0 && + (error = git_diff_find_similar(status->head2idx, &findopt)) < 0) + goto done; + } + + if (show != GIT_STATUS_SHOW_INDEX_ONLY) { + if ((error = git_diff_index_to_workdir( + &status->idx2wd, repo, index, &diffopt)) < 0) { + goto done; + } + + if ((flags & GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR) != 0 && + (error = git_diff_find_similar(status->idx2wd, &findopt)) < 0) + goto done; + } + + error = git_diff__paired_foreach( + status->head2idx, status->idx2wd, status_collect, status); + if (error < 0) + goto done; + + if (flags & GIT_STATUS_OPT_SORT_CASE_SENSITIVELY) + git_vector_set_cmp(&status->paired, status_entry_cmp); + if (flags & GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY) + git_vector_set_cmp(&status->paired, status_entry_icmp); + + if ((flags & + (GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX | + GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR | + GIT_STATUS_OPT_SORT_CASE_SENSITIVELY | + GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY)) != 0) + git_vector_sort(&status->paired); + +done: + if (error < 0) { + git_status_list_free(status); + status = NULL; + } + + *out = status; + + git_tree_free(head); + git_index_free(index); + + return error; +} + +size_t git_status_list_entrycount(git_status_list *status) +{ + assert(status); + + return status->paired.length; +} + +const git_status_entry *git_status_byindex(git_status_list *status, size_t i) +{ + assert(status); + + return git_vector_get(&status->paired, i); +} + +void git_status_list_free(git_status_list *status) +{ + if (status == NULL) + return; + + git_diff_free(status->head2idx); + git_diff_free(status->idx2wd); + + git_vector_free_deep(&status->paired); + + git__memzero(status, sizeof(*status)); + git__free(status); +} + +int git_status_foreach_ext( + git_repository *repo, + const git_status_options *opts, + git_status_cb cb, + void *payload) +{ + git_status_list *status; + const git_status_entry *status_entry; + size_t i; + int error = 0; + + if ((error = git_status_list_new(&status, repo, opts)) < 0) { + return error; + } + + git_vector_foreach(&status->paired, i, status_entry) { + const char *path = status_entry->head_to_index ? + status_entry->head_to_index->old_file.path : + status_entry->index_to_workdir->old_file.path; + + if ((error = cb(path, status_entry->status, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + + git_status_list_free(status); + + return error; +} + +int git_status_foreach(git_repository *repo, git_status_cb cb, void *payload) +{ + return git_status_foreach_ext(repo, NULL, cb, payload); +} + +struct status_file_info { + char *expected; + unsigned int count; + unsigned int status; + int fnm_flags; + int ambiguous; +}; + +static int get_one_status(const char *path, unsigned int status, void *data) +{ + struct status_file_info *sfi = data; + int (*strcomp)(const char *a, const char *b); + + sfi->count++; + sfi->status = status; + + strcomp = (sfi->fnm_flags & FNM_CASEFOLD) ? git__strcasecmp : git__strcmp; + + if (sfi->count > 1 || + (strcomp(sfi->expected, path) != 0 && + p_fnmatch(sfi->expected, path, sfi->fnm_flags) != 0)) + { + sfi->ambiguous = true; + return GIT_EAMBIGUOUS; /* giterr_set will be done by caller */ + } + + return 0; +} + +int git_status_file( + unsigned int *status_flags, + git_repository *repo, + const char *path) +{ + int error; + git_status_options opts = GIT_STATUS_OPTIONS_INIT; + struct status_file_info sfi = {0}; + git_index *index; + + assert(status_flags && repo && path); + + if ((error = git_repository_index__weakptr(&index, repo)) < 0) + return error; + + if ((sfi.expected = git__strdup(path)) == NULL) + return -1; + if (index->ignore_case) + sfi.fnm_flags = FNM_CASEFOLD; + + opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR; + opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED | + GIT_STATUS_OPT_RECURSE_IGNORED_DIRS | + GIT_STATUS_OPT_INCLUDE_UNTRACKED | + GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS | + GIT_STATUS_OPT_INCLUDE_UNMODIFIED | + GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH; + opts.pathspec.count = 1; + opts.pathspec.strings = &sfi.expected; + + error = git_status_foreach_ext(repo, &opts, get_one_status, &sfi); + + if (error < 0 && sfi.ambiguous) { + giterr_set(GITERR_INVALID, + "Ambiguous path '%s' given to git_status_file", sfi.expected); + error = GIT_EAMBIGUOUS; + } + + if (!error && !sfi.count) { + giterr_set(GITERR_INVALID, + "Attempt to get status of nonexistent file '%s'", path); + error = GIT_ENOTFOUND; + } + + *status_flags = sfi.status; + + git__free(sfi.expected); + + return error; +} + +int git_status_should_ignore( + int *ignored, + git_repository *repo, + const char *path) +{ + return git_ignore_path_is_ignored(ignored, repo, path); +} + +int git_status_init_options(git_status_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_status_options, GIT_STATUS_OPTIONS_INIT); + return 0; +} + +int git_status_list_get_perfdata( + git_diff_perfdata *out, const git_status_list *status) +{ + assert(out); + GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata"); + + out->stat_calls = 0; + out->oid_calculations = 0; + + if (status->head2idx) { + out->stat_calls += status->head2idx->perf.stat_calls; + out->oid_calculations += status->head2idx->perf.oid_calculations; + } + if (status->idx2wd) { + out->stat_calls += status->idx2wd->perf.stat_calls; + out->oid_calculations += status->idx2wd->perf.oid_calculations; + } + + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/status.h b/deps/libgit2-sys-0.2.17/libgit2/src/status.h new file mode 100644 index 000000000..33008b89c --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/status.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_status_h__ +#define INCLUDE_status_h__ + +#include "diff.h" +#include "git2/status.h" +#include "git2/diff.h" + +struct git_status_list { + git_status_options opts; + + git_diff *head2idx; + git_diff *idx2wd; + + git_vector paired; +}; + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/stream.h b/deps/libgit2-sys-0.2.17/libgit2/src/stream.h new file mode 100644 index 000000000..d810e704d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/stream.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_stream_h__ +#define INCLUDE_stream_h__ + +#include "common.h" +#include "git2/sys/stream.h" + +GIT_INLINE(int) git_stream_connect(git_stream *st) +{ + return st->connect(st); +} + +GIT_INLINE(int) git_stream_is_encrypted(git_stream *st) +{ + return st->encrypted; +} + +GIT_INLINE(int) git_stream_certificate(git_cert **out, git_stream *st) +{ + if (!st->encrypted) { + giterr_set(GITERR_INVALID, "an unencrypted stream does not have a certificate"); + return -1; + } + + return st->certificate(out, st); +} + +GIT_INLINE(ssize_t) git_stream_read(git_stream *st, void *data, size_t len) +{ + return st->read(st, data, len); +} + +GIT_INLINE(ssize_t) git_stream_write(git_stream *st, const char *data, size_t len, int flags) +{ + return st->write(st, data, len, flags); +} + +GIT_INLINE(int) git_stream_close(git_stream *st) +{ + return st->close(st); +} + +GIT_INLINE(void) git_stream_free(git_stream *st) +{ + st->free(st); +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/strmap.c b/deps/libgit2-sys-0.2.17/libgit2/src/strmap.c new file mode 100644 index 000000000..b26a13d1f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/strmap.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "strmap.h" + +int git_strmap_next( + void **data, + git_strmap_iter* iter, + git_strmap *map) +{ + if (!map) + return GIT_ERROR; + + while (*iter != git_strmap_end(map)) { + if (!(git_strmap_has_data(map, *iter))) { + ++(*iter); + continue; + } + + *data = git_strmap_value_at(map, *iter); + + ++(*iter); + + return GIT_OK; + } + + return GIT_ITEROVER; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/strmap.h b/deps/libgit2-sys-0.2.17/libgit2/src/strmap.h new file mode 100644 index 000000000..520984744 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/strmap.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_strmap_h__ +#define INCLUDE_strmap_h__ + +#include "common.h" + +#define kmalloc git__malloc +#define kcalloc git__calloc +#define krealloc git__realloc +#define kreallocarray git__reallocarray +#define kfree git__free +#include "khash.h" + +__KHASH_TYPE(str, const char *, void *) +typedef khash_t(str) git_strmap; +typedef khiter_t git_strmap_iter; + +#define GIT__USE_STRMAP \ + __KHASH_IMPL(str, static kh_inline, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal) + +#define git_strmap_alloc(hp) \ + ((*(hp) = kh_init(str)) == NULL) ? giterr_set_oom(), -1 : 0 + +#define git_strmap_free(h) kh_destroy(str, h), h = NULL +#define git_strmap_clear(h) kh_clear(str, h) + +#define git_strmap_num_entries(h) kh_size(h) + +#define git_strmap_lookup_index(h, k) kh_get(str, h, k) +#define git_strmap_valid_index(h, idx) (idx != kh_end(h)) + +#define git_strmap_exists(h, k) (kh_get(str, h, k) != kh_end(h)) +#define git_strmap_has_data(h, idx) kh_exist(h, idx) + +#define git_strmap_key(h, idx) kh_key(h, idx) +#define git_strmap_value_at(h, idx) kh_val(h, idx) +#define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v +#define git_strmap_delete_at(h, idx) kh_del(str, h, idx) + +#define git_strmap_insert(h, key, val, rval) do { \ + khiter_t __pos = kh_put(str, h, key, &rval); \ + if (rval >= 0) { \ + if (rval == 0) kh_key(h, __pos) = key; \ + kh_val(h, __pos) = val; \ + } } while (0) + +#define git_strmap_insert2(h, key, val, oldv, rval) do { \ + khiter_t __pos = kh_put(str, h, key, &rval); \ + if (rval >= 0) { \ + if (rval == 0) { \ + oldv = kh_val(h, __pos); \ + kh_key(h, __pos) = key; \ + } else { oldv = NULL; } \ + kh_val(h, __pos) = val; \ + } } while (0) + +#define git_strmap_delete(h, key) do { \ + khiter_t __pos = git_strmap_lookup_index(h, key); \ + if (git_strmap_valid_index(h, __pos)) \ + git_strmap_delete_at(h, __pos); } while (0) + +#define git_strmap_foreach kh_foreach +#define git_strmap_foreach_value kh_foreach_value + +#define git_strmap_begin kh_begin +#define git_strmap_end kh_end + +int git_strmap_next( + void **data, + git_strmap_iter* iter, + git_strmap *map); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/strnlen.h b/deps/libgit2-sys-0.2.17/libgit2/src/strnlen.h new file mode 100644 index 000000000..eecfe3c02 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/strnlen.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_strlen_h__ +#define INCLUDE_strlen_h__ + +#if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__) || defined(__MidnightBSD__) ||\ + (defined(_MSC_VER) && _MSC_VER < 1500) +# define NO_STRNLEN +#endif + +#ifdef NO_STRNLEN +GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) { + const char *end = memchr(s, 0, maxlen); + return end ? (size_t)(end - s) : maxlen; +} +#else +# define p_strnlen strnlen +#endif + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/submodule.c b/deps/libgit2-sys-0.2.17/libgit2/src/submodule.c new file mode 100644 index 000000000..c3bb6fe0e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/submodule.c @@ -0,0 +1,2227 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "git2/config.h" +#include "git2/sys/config.h" +#include "git2/types.h" +#include "git2/index.h" +#include "buffer.h" +#include "buf_text.h" +#include "vector.h" +#include "posix.h" +#include "config_file.h" +#include "config.h" +#include "repository.h" +#include "submodule.h" +#include "tree.h" +#include "iterator.h" +#include "path.h" +#include "index.h" + +#define GIT_MODULES_FILE ".gitmodules" + +static git_cvar_map _sm_update_map[] = { + {GIT_CVAR_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT}, + {GIT_CVAR_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE}, + {GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE}, + {GIT_CVAR_STRING, "none", GIT_SUBMODULE_UPDATE_NONE}, + {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE}, + {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT}, +}; + +static git_cvar_map _sm_ignore_map[] = { + {GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE}, + {GIT_CVAR_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED}, + {GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, + {GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, + {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE}, + {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL}, +}; + +static git_cvar_map _sm_recurse_map[] = { + {GIT_CVAR_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND}, + {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO}, + {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES}, +}; + +enum { + CACHE_OK = 0, + CACHE_REFRESH = 1, + CACHE_FLUSH = 2 +}; +enum { + GITMODULES_EXISTING = 0, + GITMODULES_CREATE = 1, +}; + +static kh_inline khint_t str_hash_no_trailing_slash(const char *s) +{ + khint_t h; + + for (h = 0; *s; ++s) + if (s[1] != '\0' || *s != '/') + h = (h << 5) - h + *s; + + return h; +} + +static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b) +{ + size_t alen = a ? strlen(a) : 0; + size_t blen = b ? strlen(b) : 0; + + if (alen > 0 && a[alen - 1] == '/') + alen--; + if (blen > 0 && b[blen - 1] == '/') + blen--; + + return (alen == blen && strncmp(a, b, alen) == 0); +} + +__KHASH_IMPL( + str, static kh_inline, const char *, void *, 1, + str_hash_no_trailing_slash, str_equal_no_trailing_slash) + +static int submodule_cache_init(git_repository *repo, int refresh); +static void submodule_cache_free(git_submodule_cache *cache); + +static git_config_backend *open_gitmodules(git_submodule_cache *, int gitmod); +static int get_url_base(git_buf *url, git_repository *repo); +static int lookup_head_remote_key(git_buf *remote_key, git_repository *repo); +static int submodule_get(git_submodule **, git_submodule_cache *, const char *, const char *); +static int submodule_load_from_config(const git_config_entry *, void *); +static int submodule_load_from_wd_lite(git_submodule *); +static void submodule_get_index_status(unsigned int *, git_submodule *); +static void submodule_get_wd_status(unsigned int *, git_submodule *, git_repository *, git_submodule_ignore_t); + +static int submodule_cmp(const void *a, const void *b) +{ + return strcmp(((git_submodule *)a)->name, ((git_submodule *)b)->name); +} + +static int submodule_config_key_trunc_puts(git_buf *key, const char *suffix) +{ + ssize_t idx = git_buf_rfind(key, '.'); + git_buf_truncate(key, (size_t)(idx + 1)); + return git_buf_puts(key, suffix); +} + +/* lookup submodule or return ENOTFOUND if it doesn't exist */ +static int submodule_lookup( + git_submodule **out, + git_submodule_cache *cache, + const char *name, + const char *alternate) +{ + khiter_t pos; + + /* lock cache */ + + pos = git_strmap_lookup_index(cache->submodules, name); + + if (!git_strmap_valid_index(cache->submodules, pos) && alternate) + pos = git_strmap_lookup_index(cache->submodules, alternate); + + if (!git_strmap_valid_index(cache->submodules, pos)) { + /* unlock cache */ + return GIT_ENOTFOUND; /* don't set error - caller will cope */ + } + + if (out != NULL) { + git_submodule *sm = git_strmap_value_at(cache->submodules, pos); + GIT_REFCOUNT_INC(sm); + *out = sm; + } + + /* unlock cache */ + + return 0; +} + +/* clear a set of flags on all submodules */ +static void submodule_cache_clear_flags( + git_submodule_cache *cache, uint32_t mask) +{ + git_submodule *sm; + uint32_t inverted_mask = ~mask; + + git_strmap_foreach_value(cache->submodules, sm, { + sm->flags &= inverted_mask; + }); +} + +/* + * PUBLIC APIS + */ + +bool git_submodule__is_submodule(git_repository *repo, const char *name) +{ + git_strmap *map; + + if (submodule_cache_init(repo, CACHE_OK) < 0) { + giterr_clear(); + return false; + } + + if (!repo->_submodules || !(map = repo->_submodules->submodules)) + return false; + + return git_strmap_valid_index(map, git_strmap_lookup_index(map, name)); +} + +static void submodule_set_lookup_error(int error, const char *name) +{ + if (!error) + return; + + giterr_set(GITERR_SUBMODULE, (error == GIT_ENOTFOUND) ? + "No submodule named '%s'" : + "Submodule '%s' has not been added yet", name); +} + +int git_submodule__lookup( + git_submodule **out, /* NULL if user only wants to test existence */ + git_repository *repo, + const char *name) /* trailing slash is allowed */ +{ + int error; + + assert(repo && name); + + if ((error = submodule_cache_init(repo, CACHE_OK)) < 0) + return error; + + if ((error = submodule_lookup(out, repo->_submodules, name, NULL)) < 0) + submodule_set_lookup_error(error, name); + + return error; +} + +int git_submodule_lookup( + git_submodule **out, /* NULL if user only wants to test existence */ + git_repository *repo, + const char *name) /* trailing slash is allowed */ +{ + int error; + + assert(repo && name); + + if ((error = submodule_cache_init(repo, CACHE_REFRESH)) < 0) + return error; + + if ((error = submodule_lookup(out, repo->_submodules, name, NULL)) < 0) { + + /* check if a plausible submodule exists at path */ + if (git_repository_workdir(repo)) { + git_buf path = GIT_BUF_INIT; + + if (git_buf_join3(&path, + '/', git_repository_workdir(repo), name, DOT_GIT) < 0) + return -1; + + if (git_path_exists(path.ptr)) + error = GIT_EEXISTS; + + git_buf_free(&path); + } + + submodule_set_lookup_error(error, name); + } + + return error; +} + +static void submodule_free_dup(void *sm) +{ + git_submodule_free(sm); +} + +int git_submodule_foreach( + git_repository *repo, + int (*callback)(git_submodule *sm, const char *name, void *payload), + void *payload) +{ + int error; + size_t i; + git_submodule *sm; + git_submodule_cache *cache; + git_vector snapshot = GIT_VECTOR_INIT; + + assert(repo && callback); + + if ((error = submodule_cache_init(repo, CACHE_REFRESH)) < 0) + return error; + + cache = repo->_submodules; + + if (git_mutex_lock(&cache->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire lock on submodule cache"); + return -1; + } + + if (!(error = git_vector_init( + &snapshot, kh_size(cache->submodules), submodule_cmp))) { + + git_strmap_foreach_value(cache->submodules, sm, { + if ((error = git_vector_insert(&snapshot, sm)) < 0) + break; + GIT_REFCOUNT_INC(sm); + }); + } + + git_mutex_unlock(&cache->lock); + + if (error < 0) + goto done; + + git_vector_uniq(&snapshot, submodule_free_dup); + + git_vector_foreach(&snapshot, i, sm) { + if ((error = callback(sm, sm->name, payload)) != 0) { + giterr_set_after_callback(error); + break; + } + } + +done: + git_vector_foreach(&snapshot, i, sm) + git_submodule_free(sm); + git_vector_free(&snapshot); + + return error; +} + +void git_submodule_cache_free(git_repository *repo) +{ + git_submodule_cache *cache; + + assert(repo); + + if ((cache = git__swap(repo->_submodules, NULL)) != NULL) + submodule_cache_free(cache); +} + +static int submodule_repo_init( + git_repository **out, + git_repository *parent_repo, + const char *path, + const char *url, + bool use_gitlink) +{ + int error = 0; + git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT; + git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT; + git_repository *subrepo = NULL; + + error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path); + if (error < 0) + goto cleanup; + + initopt.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT; + initopt.origin_url = url; + + /* init submodule repository and add origin remote as needed */ + + /* New style: sub-repo goes in /modules// with a + * gitlink in the sub-repo workdir directory to that repository + * + * Old style: sub-repo goes directly into repo//.git/ + */ + if (use_gitlink) { + error = git_buf_join3( + &repodir, '/', git_repository_path(parent_repo), "modules", path); + if (error < 0) + goto cleanup; + + initopt.workdir_path = workdir.ptr; + initopt.flags |= + GIT_REPOSITORY_INIT_NO_DOTGIT_DIR | + GIT_REPOSITORY_INIT_RELATIVE_GITLINK; + + error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt); + } else + error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt); + +cleanup: + git_buf_free(&workdir); + git_buf_free(&repodir); + + *out = subrepo; + + return error; +} + +int git_submodule_add_setup( + git_submodule **out, + git_repository *repo, + const char *url, + const char *path, + int use_gitlink) +{ + int error = 0; + git_config_backend *mods = NULL; + git_submodule *sm = NULL; + git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT; + git_repository *subrepo = NULL; + + assert(repo && url && path); + + /* see if there is already an entry for this submodule */ + + if (git_submodule_lookup(NULL, repo, path) < 0) + giterr_clear(); + else { + giterr_set(GITERR_SUBMODULE, + "Attempt to add submodule '%s' that already exists", path); + return GIT_EEXISTS; + } + + /* validate and normalize path */ + + if (git__prefixcmp(path, git_repository_workdir(repo)) == 0) + path += strlen(git_repository_workdir(repo)); + + if (git_path_root(path) >= 0) { + giterr_set(GITERR_SUBMODULE, "Submodule path must be a relative path"); + error = -1; + goto cleanup; + } + + /* update .gitmodules */ + + if (!(mods = open_gitmodules(repo->_submodules, GITMODULES_CREATE))) { + giterr_set(GITERR_SUBMODULE, + "Adding submodules to a bare repository is not supported"); + return -1; + } + + if ((error = git_buf_printf(&name, "submodule.%s.path", path)) < 0 || + (error = git_config_file_set_string(mods, name.ptr, path)) < 0) + goto cleanup; + + if ((error = submodule_config_key_trunc_puts(&name, "url")) < 0 || + (error = git_config_file_set_string(mods, name.ptr, url)) < 0) + goto cleanup; + + git_buf_clear(&name); + + /* init submodule repository and add origin remote as needed */ + + error = git_buf_joinpath(&name, git_repository_workdir(repo), path); + if (error < 0) + goto cleanup; + + /* if the repo does not already exist, then init a new repo and add it. + * Otherwise, just add the existing repo. + */ + if (!(git_path_exists(name.ptr) && + git_path_contains(&name, DOT_GIT))) { + + /* resolve the actual URL to use */ + if ((error = git_submodule_resolve_url(&real_url, repo, url)) < 0) + goto cleanup; + + if ((error = submodule_repo_init(&subrepo, repo, path, real_url.ptr, use_gitlink)) < 0) + goto cleanup; + } + + /* add submodule to hash and "reload" it */ + + if (git_mutex_lock(&repo->_submodules->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire lock on submodule cache"); + error = -1; + goto cleanup; + } + + if (!(error = submodule_get(&sm, repo->_submodules, path, NULL)) && + !(error = git_submodule_reload(sm, false))) + error = git_submodule_init(sm, false); + + git_mutex_unlock(&repo->_submodules->lock); + +cleanup: + if (error && sm) { + git_submodule_free(sm); + sm = NULL; + } + if (out != NULL) + *out = sm; + + git_config_file_free(mods); + git_repository_free(subrepo); + git_buf_free(&real_url); + git_buf_free(&name); + + return error; +} + +int git_submodule_repo_init( + git_repository **out, + const git_submodule *sm, + int use_gitlink) +{ + int error; + git_repository *sub_repo = NULL; + const char *configured_url; + git_config *cfg = NULL; + git_buf buf = GIT_BUF_INIT; + + assert(out && sm); + + /* get the configured remote url of the submodule */ + if ((error = git_buf_printf(&buf, "submodule.%s.url", sm->name)) < 0 || + (error = git_repository_config_snapshot(&cfg, sm->repo)) < 0 || + (error = git_config_get_string(&configured_url, cfg, buf.ptr)) < 0 || + (error = submodule_repo_init(&sub_repo, sm->repo, sm->path, configured_url, use_gitlink)) < 0) + goto done; + + *out = sub_repo; + +done: + git_config_free(cfg); + git_buf_free(&buf); + return error; +} + +int git_submodule_add_finalize(git_submodule *sm) +{ + int error; + git_index *index; + + assert(sm); + + if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 || + (error = git_index_add_bypath(index, GIT_MODULES_FILE)) < 0) + return error; + + return git_submodule_add_to_index(sm, true); +} + +int git_submodule_add_to_index(git_submodule *sm, int write_index) +{ + int error; + git_repository *sm_repo = NULL; + git_index *index; + git_buf path = GIT_BUF_INIT; + git_commit *head; + git_index_entry entry; + struct stat st; + + assert(sm); + + /* force reload of wd OID by git_submodule_open */ + sm->flags = sm->flags & ~GIT_SUBMODULE_STATUS__WD_OID_VALID; + + if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 || + (error = git_buf_joinpath( + &path, git_repository_workdir(sm->repo), sm->path)) < 0 || + (error = git_submodule_open(&sm_repo, sm)) < 0) + goto cleanup; + + /* read stat information for submodule working directory */ + if (p_stat(path.ptr, &st) < 0) { + giterr_set(GITERR_SUBMODULE, + "Cannot add submodule without working directory"); + error = -1; + goto cleanup; + } + + memset(&entry, 0, sizeof(entry)); + entry.path = sm->path; + git_index_entry__init_from_stat( + &entry, &st, !(git_index_caps(index) & GIT_INDEXCAP_NO_FILEMODE)); + + /* calling git_submodule_open will have set sm->wd_oid if possible */ + if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) { + giterr_set(GITERR_SUBMODULE, + "Cannot add submodule without HEAD to index"); + error = -1; + goto cleanup; + } + git_oid_cpy(&entry.id, &sm->wd_oid); + + if ((error = git_commit_lookup(&head, sm_repo, &sm->wd_oid)) < 0) + goto cleanup; + + entry.ctime.seconds = git_commit_time(head); + entry.ctime.nanoseconds = 0; + entry.mtime.seconds = git_commit_time(head); + entry.mtime.nanoseconds = 0; + + git_commit_free(head); + + /* add it */ + error = git_index_add(index, &entry); + + /* write it, if requested */ + if (!error && write_index) { + error = git_index_write(index); + + if (!error) + git_oid_cpy(&sm->index_oid, &sm->wd_oid); + } + +cleanup: + git_repository_free(sm_repo); + git_buf_free(&path); + return error; +} + +const char *git_submodule_ignore_to_str(git_submodule_ignore_t ignore) +{ + int i; + for (i = 0; i < (int)ARRAY_SIZE(_sm_ignore_map); ++i) + if (_sm_ignore_map[i].map_value == ignore) + return _sm_ignore_map[i].str_match; + return NULL; +} + +const char *git_submodule_update_to_str(git_submodule_update_t update) +{ + int i; + for (i = 0; i < (int)ARRAY_SIZE(_sm_update_map); ++i) + if (_sm_update_map[i].map_value == update) + return _sm_update_map[i].str_match; + return NULL; +} + +const char *git_submodule_recurse_to_str(git_submodule_recurse_t recurse) +{ + int i; + for (i = 0; i < (int)ARRAY_SIZE(_sm_recurse_map); ++i) + if (_sm_recurse_map[i].map_value == recurse) + return _sm_recurse_map[i].str_match; + return NULL; +} + +int git_submodule_save(git_submodule *submodule) +{ + int error = 0; + git_config_backend *mods; + git_buf key = GIT_BUF_INIT; + const char *val; + + assert(submodule); + + mods = open_gitmodules(submodule->repo->_submodules, GITMODULES_CREATE); + if (!mods) { + giterr_set(GITERR_SUBMODULE, + "Adding submodules to a bare repository is not supported"); + return -1; + } + + if ((error = git_buf_printf(&key, "submodule.%s.", submodule->name)) < 0) + goto cleanup; + + /* save values for path, url, update, ignore, fetchRecurseSubmodules */ + + if ((error = submodule_config_key_trunc_puts(&key, "path")) < 0 || + (error = git_config_file_set_string(mods, key.ptr, submodule->path)) < 0) + goto cleanup; + + if ((error = submodule_config_key_trunc_puts(&key, "url")) < 0 || + (error = git_config_file_set_string(mods, key.ptr, submodule->url)) < 0) + goto cleanup; + + if ((error = submodule_config_key_trunc_puts(&key, "branch")) < 0 || + (error = git_config_file_set_string(mods, key.ptr, submodule->branch)) < 0) + goto cleanup; + + if (!(error = submodule_config_key_trunc_puts(&key, "update")) && + (val = git_submodule_update_to_str(submodule->update)) != NULL) + error = git_config_file_set_string(mods, key.ptr, val); + if (error < 0) + goto cleanup; + + if (!(error = submodule_config_key_trunc_puts(&key, "ignore")) && + (val = git_submodule_ignore_to_str(submodule->ignore)) != NULL) + error = git_config_file_set_string(mods, key.ptr, val); + if (error < 0) + goto cleanup; + + if (!(error = submodule_config_key_trunc_puts(&key, "fetchRecurseSubmodules")) && + (val = git_submodule_recurse_to_str(submodule->fetch_recurse)) != NULL) + error = git_config_file_set_string(mods, key.ptr, val); + if (error < 0) + goto cleanup; + + /* update internal defaults */ + + submodule->ignore_default = submodule->ignore; + submodule->update_default = submodule->update; + submodule->fetch_recurse_default = submodule->fetch_recurse; + submodule->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; + +cleanup: + git_config_file_free(mods); + git_buf_free(&key); + + return error; +} + +git_repository *git_submodule_owner(git_submodule *submodule) +{ + assert(submodule); + return submodule->repo; +} + +const char *git_submodule_name(git_submodule *submodule) +{ + assert(submodule); + return submodule->name; +} + +const char *git_submodule_path(git_submodule *submodule) +{ + assert(submodule); + return submodule->path; +} + +const char *git_submodule_url(git_submodule *submodule) +{ + assert(submodule); + return submodule->url; +} + +int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *url) +{ + int error = 0; + + assert(out && repo && url); + + git_buf_sanitize(out); + + if (git_path_is_relative(url)) { + if (!(error = get_url_base(out, repo))) + error = git_path_apply_relative(out, url); + } else if (strchr(url, ':') != NULL || url[0] == '/') { + error = git_buf_sets(out, url); + } else { + giterr_set(GITERR_SUBMODULE, "Invalid format for submodule URL"); + error = -1; + } + + return error; +} + +const char *git_submodule_branch(git_submodule *submodule) +{ + assert(submodule); + return submodule->branch; +} + +int git_submodule_set_url(git_submodule *submodule, const char *url) +{ + assert(submodule && url); + + git__free(submodule->url); + + submodule->url = git__strdup(url); + GITERR_CHECK_ALLOC(submodule->url); + + return 0; +} + +const git_oid *git_submodule_index_id(git_submodule *submodule) +{ + assert(submodule); + + if (submodule->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID) + return &submodule->index_oid; + else + return NULL; +} + +const git_oid *git_submodule_head_id(git_submodule *submodule) +{ + assert(submodule); + + if (submodule->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID) + return &submodule->head_oid; + else + return NULL; +} + +const git_oid *git_submodule_wd_id(git_submodule *submodule) +{ + assert(submodule); + + /* load unless we think we have a valid oid */ + if (!(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) { + git_repository *subrepo; + + /* calling submodule open grabs the HEAD OID if possible */ + if (!git_submodule_open_bare(&subrepo, submodule)) + git_repository_free(subrepo); + else + giterr_clear(); + } + + if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) + return &submodule->wd_oid; + else + return NULL; +} + +git_submodule_ignore_t git_submodule_ignore(git_submodule *submodule) +{ + assert(submodule); + return (submodule->ignore < GIT_SUBMODULE_IGNORE_NONE) ? + GIT_SUBMODULE_IGNORE_NONE : submodule->ignore; +} + +git_submodule_ignore_t git_submodule_set_ignore( + git_submodule *submodule, git_submodule_ignore_t ignore) +{ + git_submodule_ignore_t old; + + assert(submodule); + + if (ignore == GIT_SUBMODULE_IGNORE_RESET) + ignore = submodule->ignore_default; + + old = submodule->ignore; + submodule->ignore = ignore; + return old; +} + +git_submodule_update_t git_submodule_update_strategy(git_submodule *submodule) +{ + assert(submodule); + return (submodule->update < GIT_SUBMODULE_UPDATE_CHECKOUT) ? + GIT_SUBMODULE_UPDATE_CHECKOUT : submodule->update; +} + +git_submodule_update_t git_submodule_set_update( + git_submodule *submodule, git_submodule_update_t update) +{ + git_submodule_update_t old; + + assert(submodule); + + if (update == GIT_SUBMODULE_UPDATE_RESET) + update = submodule->update_default; + + old = submodule->update; + submodule->update = update; + return old; +} + +git_submodule_recurse_t git_submodule_fetch_recurse_submodules( + git_submodule *submodule) +{ + assert(submodule); + return submodule->fetch_recurse; +} + +git_submodule_recurse_t git_submodule_set_fetch_recurse_submodules( + git_submodule *submodule, + git_submodule_recurse_t fetch_recurse_submodules) +{ + git_submodule_recurse_t old; + + assert(submodule); + + if (fetch_recurse_submodules == GIT_SUBMODULE_RECURSE_RESET) + fetch_recurse_submodules = submodule->fetch_recurse_default; + + old = submodule->fetch_recurse; + submodule->fetch_recurse = fetch_recurse_submodules; + return old; +} + +static int submodule_repo_create( + git_repository **out, + git_repository *parent_repo, + const char *path) +{ + int error = 0; + git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT; + git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT; + git_repository *subrepo = NULL; + + initopt.flags = + GIT_REPOSITORY_INIT_MKPATH | + GIT_REPOSITORY_INIT_NO_REINIT | + GIT_REPOSITORY_INIT_NO_DOTGIT_DIR | + GIT_REPOSITORY_INIT_RELATIVE_GITLINK; + + /* Workdir: path to sub-repo working directory */ + error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path); + if (error < 0) + goto cleanup; + + initopt.workdir_path = workdir.ptr; + + /** + * Repodir: path to the sub-repo. sub-repo goes in: + * /modules// with a gitlink in the + * sub-repo workdir directory to that repository. + */ + error = git_buf_join3( + &repodir, '/', git_repository_path(parent_repo), "modules", path); + if (error < 0) + goto cleanup; + + error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt); + +cleanup: + git_buf_free(&workdir); + git_buf_free(&repodir); + + *out = subrepo; + + return error; +} + +/** + * Callback to override sub-repository creation when + * cloning a sub-repository. + */ +static int git_submodule_update_repo_init_cb( + git_repository **out, + const char *path, + int bare, + void *payload) +{ + git_submodule *sm; + + GIT_UNUSED(bare); + + sm = payload; + + return submodule_repo_create(out, sm->repo, path); +} + +int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_submodule_update_options, GIT_SUBMODULE_UPDATE_OPTIONS_INIT); + return 0; +} + +int git_submodule_update(git_submodule *sm, int init, git_submodule_update_options *_update_options) +{ + int error; + unsigned int submodule_status; + git_config *config = NULL; + const char *submodule_url; + git_repository *sub_repo = NULL; + git_remote *remote = NULL; + git_object *target_commit = NULL; + git_buf buf = GIT_BUF_INIT; + git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; + git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT; + + assert(sm); + + if (_update_options) + memcpy(&update_options, _update_options, sizeof(git_submodule_update_options)); + + GITERR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options"); + + /* Copy over the remote callbacks */ + clone_options.remote_callbacks = update_options.remote_callbacks; + + /* Get the status of the submodule to determine if it is already initialized */ + if ((error = git_submodule_status(&submodule_status, sm)) < 0) + goto done; + + /* + * If submodule work dir is not already initialized, check to see + * what we need to do (initialize, clone, return error...) + */ + if (submodule_status & GIT_SUBMODULE_STATUS_WD_UNINITIALIZED) { + /* + * Work dir is not initialized, check to see if the submodule + * info has been copied into .git/config + */ + if ((error = git_repository_config_snapshot(&config, sm->repo)) < 0 || + (error = git_buf_printf(&buf, "submodule.%s.url", git_submodule_name(sm))) < 0) + goto done; + + if ((error = git_config_get_string(&submodule_url, config, git_buf_cstr(&buf))) < 0) { + /* + * If the error is not "not found" or if it is "not found" and we are not + * initializing the submodule, then return error. + */ + if (error != GIT_ENOTFOUND) + goto done; + + if (error == GIT_ENOTFOUND && !init) { + giterr_set(GITERR_SUBMODULE, "Submodule is not initialized."); + error = GIT_ERROR; + goto done; + } + + /* The submodule has not been initialized yet - initialize it now.*/ + if ((error = git_submodule_init(sm, 0)) < 0) + goto done; + + git_config_free(config); + config = NULL; + + if ((error = git_repository_config_snapshot(&config, sm->repo)) < 0 || + (error = git_config_get_string(&submodule_url, config, git_buf_cstr(&buf))) < 0) + goto done; + } + + /** submodule is initialized - now clone it **/ + /* override repo creation */ + clone_options.repository_cb = git_submodule_update_repo_init_cb; + clone_options.repository_cb_payload = sm; + + /* + * Do not perform checkout as part of clone, instead we + * will checkout the specific commit manually. + */ + clone_options.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE; + update_options.checkout_opts.checkout_strategy = update_options.clone_checkout_strategy; + + if ((error = git_clone(&sub_repo, submodule_url, sm->path, &clone_options)) < 0 || + (error = git_repository_set_head_detached(sub_repo, git_submodule_index_id(sm))) < 0 || + (error = git_checkout_head(sub_repo, &update_options.checkout_opts)) != 0) + goto done; + } else { + /** + * Work dir is initialized - look up the commit in the parent repository's index, + * update the workdir contents of the subrepository, and set the subrepository's + * head to the new commit. + */ + if ((error = git_submodule_open(&sub_repo, sm)) < 0 || + (error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm), GIT_OBJ_COMMIT)) < 0 || + (error = git_checkout_tree(sub_repo, target_commit, &update_options.checkout_opts)) != 0 || + (error = git_repository_set_head_detached(sub_repo, git_submodule_index_id(sm))) < 0) + goto done; + + /* Invalidate the wd flags as the workdir has been updated. */ + sm->flags = sm->flags & + ~(GIT_SUBMODULE_STATUS_IN_WD | + GIT_SUBMODULE_STATUS__WD_OID_VALID | + GIT_SUBMODULE_STATUS__WD_SCANNED); + } + +done: + git_buf_free(&buf); + git_config_free(config); + git_object_free(target_commit); + git_remote_free(remote); + git_repository_free(sub_repo); + + return error; +} + +int git_submodule_init(git_submodule *sm, int overwrite) +{ + int error; + const char *val; + git_buf key = GIT_BUF_INIT, effective_submodule_url = GIT_BUF_INIT; + git_config *cfg = NULL; + + if (!sm->url) { + giterr_set(GITERR_SUBMODULE, + "No URL configured for submodule '%s'", sm->name); + return -1; + } + + if ((error = git_repository_config(&cfg, sm->repo)) < 0) + return error; + + /* write "submodule.NAME.url" */ + + if ((error = git_submodule_resolve_url(&effective_submodule_url, sm->repo, sm->url)) < 0 || + (error = git_buf_printf(&key, "submodule.%s.url", sm->name)) < 0 || + (error = git_config__update_entry( + cfg, key.ptr, effective_submodule_url.ptr, overwrite != 0, false)) < 0) + goto cleanup; + + /* write "submodule.NAME.update" if not default */ + + val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ? + NULL : git_submodule_update_to_str(sm->update); + + if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 || + (error = git_config__update_entry( + cfg, key.ptr, val, overwrite != 0, false)) < 0) + goto cleanup; + + /* success */ + +cleanup: + git_config_free(cfg); + git_buf_free(&key); + git_buf_free(&effective_submodule_url); + + return error; +} + +int git_submodule_sync(git_submodule *sm) +{ + int error = 0; + git_config *cfg = NULL; + git_buf key = GIT_BUF_INIT; + git_repository *smrepo = NULL; + + if (!sm->url) { + giterr_set(GITERR_SUBMODULE, + "No URL configured for submodule '%s'", sm->name); + return -1; + } + + /* copy URL over to config only if it already exists */ + + if (!(error = git_repository_config__weakptr(&cfg, sm->repo)) && + !(error = git_buf_printf(&key, "submodule.%s.url", sm->name))) + error = git_config__update_entry(cfg, key.ptr, sm->url, true, true); + + /* if submodule exists in the working directory, update remote url */ + + if (!error && + (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) != 0 && + !(error = git_submodule_open(&smrepo, sm))) + { + git_buf remote_name = GIT_BUF_INIT; + + if ((error = git_repository_config__weakptr(&cfg, smrepo)) < 0) + /* return error from reading submodule config */; + else if ((error = lookup_head_remote_key(&remote_name, smrepo)) < 0) { + giterr_clear(); + error = git_buf_sets(&key, "remote.origin.url"); + } else { + error = git_buf_join3( + &key, '.', "remote", remote_name.ptr, "url"); + git_buf_free(&remote_name); + } + + if (!error) + error = git_config__update_entry(cfg, key.ptr, sm->url, true, false); + + git_repository_free(smrepo); + } + + git_buf_free(&key); + + return error; +} + +static int git_submodule__open( + git_repository **subrepo, git_submodule *sm, bool bare) +{ + int error; + git_buf path = GIT_BUF_INIT; + unsigned int flags = GIT_REPOSITORY_OPEN_NO_SEARCH; + const char *wd; + + assert(sm && subrepo); + + if (git_repository__ensure_not_bare( + sm->repo, "open submodule repository") < 0) + return GIT_EBAREREPO; + + wd = git_repository_workdir(sm->repo); + + if (git_buf_joinpath(&path, wd, sm->path) < 0 || + git_buf_joinpath(&path, path.ptr, DOT_GIT) < 0) + return -1; + + sm->flags = sm->flags & + ~(GIT_SUBMODULE_STATUS_IN_WD | + GIT_SUBMODULE_STATUS__WD_OID_VALID | + GIT_SUBMODULE_STATUS__WD_SCANNED); + + if (bare) + flags |= GIT_REPOSITORY_OPEN_BARE; + + error = git_repository_open_ext(subrepo, path.ptr, flags, wd); + + /* if we opened the submodule successfully, grab HEAD OID, etc. */ + if (!error) { + sm->flags |= GIT_SUBMODULE_STATUS_IN_WD | + GIT_SUBMODULE_STATUS__WD_SCANNED; + + if (!git_reference_name_to_id(&sm->wd_oid, *subrepo, GIT_HEAD_FILE)) + sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID; + else + giterr_clear(); + } else if (git_path_exists(path.ptr)) { + sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED | + GIT_SUBMODULE_STATUS_IN_WD; + } else { + git_buf_rtruncate_at_char(&path, '/'); /* remove "/.git" */ + + if (git_path_isdir(path.ptr)) + sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED; + } + + git_buf_free(&path); + + return error; +} + +int git_submodule_open_bare(git_repository **subrepo, git_submodule *sm) +{ + return git_submodule__open(subrepo, sm, true); +} + +int git_submodule_open(git_repository **subrepo, git_submodule *sm) +{ + return git_submodule__open(subrepo, sm, false); +} + +int git_submodule_reload_all(git_repository *repo, int force) +{ + return submodule_cache_init(repo, force ? CACHE_FLUSH : CACHE_REFRESH); +} + +static void submodule_update_from_index_entry( + git_submodule *sm, const git_index_entry *ie) +{ + bool already_found = (sm->flags & GIT_SUBMODULE_STATUS_IN_INDEX) != 0; + + if (!S_ISGITLINK(ie->mode)) { + if (!already_found) + sm->flags |= GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE; + } else { + if (already_found) + sm->flags |= GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES; + else + git_oid_cpy(&sm->index_oid, &ie->id); + + sm->flags |= GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS__INDEX_OID_VALID; + } +} + +static int submodule_update_index(git_submodule *sm) +{ + git_index *index; + const git_index_entry *ie; + + if (git_repository_index__weakptr(&index, sm->repo) < 0) + return -1; + + sm->flags = sm->flags & + ~(GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS__INDEX_OID_VALID); + + if (!(ie = git_index_get_bypath(index, sm->path, 0))) + return 0; + + submodule_update_from_index_entry(sm, ie); + + return 0; +} + +static void submodule_update_from_head_data( + git_submodule *sm, mode_t mode, const git_oid *id) +{ + if (!S_ISGITLINK(mode)) + sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE; + else { + git_oid_cpy(&sm->head_oid, id); + + sm->flags |= GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS__HEAD_OID_VALID; + } +} + +static int submodule_update_head(git_submodule *submodule) +{ + git_tree *head = NULL; + git_tree_entry *te = NULL; + + submodule->flags = submodule->flags & + ~(GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS__HEAD_OID_VALID); + + /* if we can't look up file in current head, then done */ + if (git_repository_head_tree(&head, submodule->repo) < 0 || + git_tree_entry_bypath(&te, head, submodule->path) < 0) + giterr_clear(); + else + submodule_update_from_head_data(submodule, te->attr, &te->oid); + + git_tree_entry_free(te); + git_tree_free(head); + return 0; +} + + +int git_submodule_reload(git_submodule *sm, int force) +{ + int error = 0; + git_config_backend *mods; + git_submodule_cache *cache; + + GIT_UNUSED(force); + + assert(sm); + + cache = sm->repo->_submodules; + + /* refresh index data */ + if ((error = submodule_update_index(sm)) < 0) + return error; + + /* refresh HEAD tree data */ + if ((error = submodule_update_head(sm)) < 0) + return error; + + /* done if bare */ + if (git_repository_is_bare(sm->repo)) + return error; + + /* refresh config data */ + mods = open_gitmodules(cache, GITMODULES_EXISTING); + if (mods != NULL) { + git_buf path = GIT_BUF_INIT; + + git_buf_sets(&path, "submodule\\."); + git_buf_text_puts_escape_regex(&path, sm->name); + git_buf_puts(&path, ".*"); + + if (git_buf_oom(&path)) + error = -1; + else + error = git_config_file_foreach_match( + mods, path.ptr, submodule_load_from_config, cache); + + git_buf_free(&path); + git_config_file_free(mods); + + if (error < 0) + return error; + } + + /* refresh wd data */ + sm->flags &= + ~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID | + GIT_SUBMODULE_STATUS__WD_FLAGS); + + return submodule_load_from_wd_lite(sm); +} + +static void submodule_copy_oid_maybe( + git_oid *tgt, const git_oid *src, bool valid) +{ + if (tgt) { + if (valid) + memcpy(tgt, src, sizeof(*tgt)); + else + memset(tgt, 0, sizeof(*tgt)); + } +} + +int git_submodule__status( + unsigned int *out_status, + git_oid *out_head_id, + git_oid *out_index_id, + git_oid *out_wd_id, + git_submodule *sm, + git_submodule_ignore_t ign) +{ + unsigned int status; + git_repository *smrepo = NULL; + + if (ign < GIT_SUBMODULE_IGNORE_NONE) + ign = sm->ignore; + + /* only return location info if ignore == all */ + if (ign == GIT_SUBMODULE_IGNORE_ALL) { + *out_status = (sm->flags & GIT_SUBMODULE_STATUS__IN_FLAGS); + return 0; + } + + /* refresh the index OID */ + if (submodule_update_index(sm) < 0) + return -1; + + /* refresh the HEAD OID */ + if (submodule_update_head(sm) < 0) + return -1; + + /* for ignore == dirty, don't scan the working directory */ + if (ign == GIT_SUBMODULE_IGNORE_DIRTY) { + /* git_submodule_open_bare will load WD OID data */ + if (git_submodule_open_bare(&smrepo, sm) < 0) + giterr_clear(); + else + git_repository_free(smrepo); + smrepo = NULL; + } else if (git_submodule_open(&smrepo, sm) < 0) { + giterr_clear(); + smrepo = NULL; + } + + status = GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(sm->flags); + + submodule_get_index_status(&status, sm); + submodule_get_wd_status(&status, sm, smrepo, ign); + + git_repository_free(smrepo); + + *out_status = status; + + submodule_copy_oid_maybe(out_head_id, &sm->head_oid, + (sm->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID) != 0); + submodule_copy_oid_maybe(out_index_id, &sm->index_oid, + (sm->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID) != 0); + submodule_copy_oid_maybe(out_wd_id, &sm->wd_oid, + (sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) != 0); + + return 0; +} + +int git_submodule_status(unsigned int *status, git_submodule *sm) +{ + assert(status && sm); + + return git_submodule__status(status, NULL, NULL, NULL, sm, 0); +} + +int git_submodule_location(unsigned int *location, git_submodule *sm) +{ + assert(location && sm); + + return git_submodule__status( + location, NULL, NULL, NULL, sm, GIT_SUBMODULE_IGNORE_ALL); +} + + +/* + * INTERNAL FUNCTIONS + */ + +static int submodule_alloc( + git_submodule **out, git_submodule_cache *cache, const char *name) +{ + size_t namelen; + git_submodule *sm; + + if (!name || !(namelen = strlen(name))) { + giterr_set(GITERR_SUBMODULE, "Invalid submodule name"); + return -1; + } + + sm = git__calloc(1, sizeof(git_submodule)); + GITERR_CHECK_ALLOC(sm); + + sm->name = sm->path = git__strdup(name); + if (!sm->name) { + git__free(sm); + return -1; + } + + GIT_REFCOUNT_INC(sm); + sm->ignore = sm->ignore_default = GIT_SUBMODULE_IGNORE_NONE; + sm->update = sm->update_default = GIT_SUBMODULE_UPDATE_CHECKOUT; + sm->fetch_recurse = sm->fetch_recurse_default = GIT_SUBMODULE_RECURSE_NO; + sm->repo = cache->repo; + sm->branch = NULL; + + *out = sm; + return 0; +} + +static void submodule_cache_remove_item( + git_submodule_cache *cache, + git_submodule *item, + bool free_after_remove) +{ + git_strmap *map; + const char *name, *alt; + + if (!cache || !(map = cache->submodules) || !item) + return; + + name = item->name; + alt = (item->path != item->name) ? item->path : NULL; + + for (; name; name = alt, alt = NULL) { + khiter_t pos = git_strmap_lookup_index(map, name); + git_submodule *found; + + if (!git_strmap_valid_index(map, pos)) + continue; + + found = git_strmap_value_at(map, pos); + + if (found != item) + continue; + + git_strmap_set_value_at(map, pos, NULL); + git_strmap_delete_at(map, pos); + + if (free_after_remove) + git_submodule_free(found); + } +} + +static void submodule_release(git_submodule *sm) +{ + if (!sm) + return; + + if (sm->repo) { + git_submodule_cache *cache = sm->repo->_submodules; + sm->repo = NULL; + submodule_cache_remove_item(cache, sm, false); + } + + if (sm->path != sm->name) + git__free(sm->path); + git__free(sm->name); + git__free(sm->url); + git__free(sm->branch); + git__memzero(sm, sizeof(*sm)); + git__free(sm); +} + +void git_submodule_free(git_submodule *sm) +{ + if (!sm) + return; + GIT_REFCOUNT_DEC(sm, submodule_release); +} + +static int submodule_get( + git_submodule **out, + git_submodule_cache *cache, + const char *name, + const char *alternate) +{ + int error = 0; + khiter_t pos; + git_submodule *sm; + + pos = git_strmap_lookup_index(cache->submodules, name); + + if (!git_strmap_valid_index(cache->submodules, pos) && alternate) + pos = git_strmap_lookup_index(cache->submodules, alternate); + + if (!git_strmap_valid_index(cache->submodules, pos)) { + if ((error = submodule_alloc(&sm, cache, name)) < 0) + return error; + + /* insert value at name - if another thread beats us to it, then use + * their record and release our own. + */ + pos = kh_put(str, cache->submodules, sm->name, &error); + + if (error < 0) + goto done; + else if (error == 0) { + git_submodule_free(sm); + sm = git_strmap_value_at(cache->submodules, pos); + } else { + error = 0; + git_strmap_set_value_at(cache->submodules, pos, sm); + } + } else { + sm = git_strmap_value_at(cache->submodules, pos); + } + +done: + if (error < 0) + git_submodule_free(sm); + else if (out) { + GIT_REFCOUNT_INC(sm); + *out = sm; + } + + return error; +} + +static int submodule_config_error(const char *property, const char *value) +{ + giterr_set(GITERR_INVALID, + "Invalid value for submodule '%s' property: '%s'", property, value); + return -1; +} + +int git_submodule_parse_ignore(git_submodule_ignore_t *out, const char *value) +{ + int val; + + if (git_config_lookup_map_value( + &val, _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), value) < 0) { + *out = GIT_SUBMODULE_IGNORE_NONE; + return submodule_config_error("ignore", value); + } + + *out = (git_submodule_ignore_t)val; + return 0; +} + +int git_submodule_parse_update(git_submodule_update_t *out, const char *value) +{ + int val; + + if (git_config_lookup_map_value( + &val, _sm_update_map, ARRAY_SIZE(_sm_update_map), value) < 0) { + *out = GIT_SUBMODULE_UPDATE_CHECKOUT; + return submodule_config_error("update", value); + } + + *out = (git_submodule_update_t)val; + return 0; +} + +int git_submodule_parse_recurse(git_submodule_recurse_t *out, const char *value) +{ + int val; + + if (git_config_lookup_map_value( + &val, _sm_recurse_map, ARRAY_SIZE(_sm_recurse_map), value) < 0) { + *out = GIT_SUBMODULE_RECURSE_YES; + return submodule_config_error("recurse", value); + } + + *out = (git_submodule_recurse_t)val; + return 0; +} + +static int submodule_load_from_config( + const git_config_entry *entry, void *payload) +{ + git_submodule_cache *cache = payload; + const char *namestart, *property; + const char *key = entry->name, *value = entry->value, *path; + char *alternate = NULL, *replaced = NULL; + git_buf name = GIT_BUF_INIT; + git_submodule *sm = NULL; + int error = 0; + + if (git__prefixcmp(key, "submodule.") != 0) + return 0; + + namestart = key + strlen("submodule."); + property = strrchr(namestart, '.'); + + if (!property || (property == namestart)) + return 0; + + property++; + path = !strcasecmp(property, "path") ? value : NULL; + + if ((error = git_buf_set(&name, namestart, property - namestart - 1)) < 0 || + (error = submodule_get(&sm, cache, name.ptr, path)) < 0) + goto done; + + sm->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; + + /* Only from config might we get differing names & paths. If so, then + * update the submodule and insert under the alternative key. + */ + + /* TODO: if case insensitive filesystem, then the following strcmps + * should be strcasecmp + */ + + if (strcmp(sm->name, name.ptr) != 0) { /* name changed */ + if (!strcmp(sm->path, name.ptr)) { /* already set as path */ + replaced = sm->name; + sm->name = sm->path; + } else { + if (sm->name != sm->path) + replaced = sm->name; + alternate = sm->name = git_buf_detach(&name); + } + } + else if (path && strcmp(path, sm->path) != 0) { /* path changed */ + if (!strcmp(sm->name, value)) { /* already set as name */ + replaced = sm->path; + sm->path = sm->name; + } else { + if (sm->path != sm->name) + replaced = sm->path; + if ((alternate = git__strdup(value)) == NULL) { + error = -1; + goto done; + } + sm->path = alternate; + } + } + + /* Deregister under name being replaced */ + if (replaced) { + git_strmap_delete(cache->submodules, replaced); + git_submodule_free(sm); + git__free(replaced); + } + + /* Insert under alternate key */ + if (alternate) { + void *old_sm = NULL; + git_strmap_insert2(cache->submodules, alternate, sm, old_sm, error); + + if (error < 0) + goto done; + if (error > 0) + error = 0; + + GIT_REFCOUNT_INC(sm); /* increase refcount for new key */ + + /* if we replaced an old module under this key, release the old one */ + if (old_sm && ((git_submodule *)old_sm) != sm) { + git_submodule_free(old_sm); + /* TODO: log warning about multiple submodules with same path */ + } + } + + /* TODO: Look up path in index and if it is present but not a GITLINK + * then this should be deleted (at least to match git's behavior) + */ + + if (path) + goto done; + + /* copy other properties into submodule entry */ + if (strcasecmp(property, "url") == 0) { + git__free(sm->url); + sm->url = NULL; + + if (value != NULL && (sm->url = git__strdup(value)) == NULL) { + error = -1; + goto done; + } + } + else if (strcasecmp(property, "branch") == 0) { + git__free(sm->branch); + sm->branch = NULL; + + if (value != NULL && (sm->branch = git__strdup(value)) == NULL) { + error = -1; + goto done; + } + } + else if (strcasecmp(property, "update") == 0) { + if ((error = git_submodule_parse_update(&sm->update, value)) < 0) + goto done; + sm->update_default = sm->update; + } + else if (strcasecmp(property, "fetchRecurseSubmodules") == 0) { + if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) + goto done; + sm->fetch_recurse_default = sm->fetch_recurse; + } + else if (strcasecmp(property, "ignore") == 0) { + if ((error = git_submodule_parse_ignore(&sm->ignore, value)) < 0) + goto done; + sm->ignore_default = sm->ignore; + } + /* ignore other unknown submodule properties */ + +done: + git_submodule_free(sm); /* offset refcount inc from submodule_get() */ + git_buf_free(&name); + return error; +} + +static int submodule_load_from_wd_lite(git_submodule *sm) +{ + git_buf path = GIT_BUF_INIT; + + if (git_buf_joinpath(&path, git_repository_workdir(sm->repo), sm->path) < 0) + return -1; + + if (git_path_isdir(path.ptr)) + sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED; + + if (git_path_contains(&path, DOT_GIT)) + sm->flags |= GIT_SUBMODULE_STATUS_IN_WD; + + git_buf_free(&path); + return 0; +} + +static int submodule_cache_refresh_from_index( + git_submodule_cache *cache, git_index *idx) +{ + int error; + git_iterator *i; + const git_index_entry *entry; + + if ((error = git_iterator_for_index(&i, idx, 0, NULL, NULL)) < 0) + return error; + + while (!(error = git_iterator_advance(&entry, i))) { + khiter_t pos = git_strmap_lookup_index(cache->submodules, entry->path); + git_submodule *sm; + + if (git_strmap_valid_index(cache->submodules, pos)) { + sm = git_strmap_value_at(cache->submodules, pos); + + if (S_ISGITLINK(entry->mode)) + submodule_update_from_index_entry(sm, entry); + else + sm->flags |= GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE; + } else if (S_ISGITLINK(entry->mode)) { + if (!submodule_get(&sm, cache, entry->path, NULL)) { + submodule_update_from_index_entry(sm, entry); + git_submodule_free(sm); + } + } + } + + if (error == GIT_ITEROVER) + error = 0; + + git_iterator_free(i); + + return error; +} + +static int submodule_cache_refresh_from_head( + git_submodule_cache *cache, git_tree *head) +{ + int error; + git_iterator *i; + const git_index_entry *entry; + + if ((error = git_iterator_for_tree(&i, head, 0, NULL, NULL)) < 0) + return error; + + while (!(error = git_iterator_advance(&entry, i))) { + khiter_t pos = git_strmap_lookup_index(cache->submodules, entry->path); + git_submodule *sm; + + if (git_strmap_valid_index(cache->submodules, pos)) { + sm = git_strmap_value_at(cache->submodules, pos); + + if (S_ISGITLINK(entry->mode)) + submodule_update_from_head_data(sm, entry->mode, &entry->id); + else + sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE; + } else if (S_ISGITLINK(entry->mode)) { + if (!submodule_get(&sm, cache, entry->path, NULL)) { + submodule_update_from_head_data( + sm, entry->mode, &entry->id); + git_submodule_free(sm); + } + } + } + + if (error == GIT_ITEROVER) + error = 0; + + git_iterator_free(i); + + return error; +} + +static git_config_backend *open_gitmodules( + git_submodule_cache *cache, + int okay_to_create) +{ + const char *workdir = git_repository_workdir(cache->repo); + git_buf path = GIT_BUF_INIT; + git_config_backend *mods = NULL; + + if (workdir != NULL) { + if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0) + return NULL; + + if (okay_to_create || git_path_isfile(path.ptr)) { + /* git_config_file__ondisk should only fail if OOM */ + if (git_config_file__ondisk(&mods, path.ptr) < 0) + mods = NULL; + /* open should only fail here if the file is malformed */ + else if (git_config_file_open(mods, GIT_CONFIG_LEVEL_LOCAL) < 0) { + git_config_file_free(mods); + mods = NULL; + } + } + } + + git_buf_free(&path); + + return mods; +} + +static void submodule_cache_free(git_submodule_cache *cache) +{ + git_submodule *sm; + + if (!cache) + return; + + git_strmap_foreach_value(cache->submodules, sm, { + sm->repo = NULL; /* disconnect from repo */ + git_submodule_free(sm); + }); + git_strmap_free(cache->submodules); + + git_buf_free(&cache->gitmodules_path); + git_mutex_free(&cache->lock); + git__free(cache); +} + +static int submodule_cache_alloc( + git_submodule_cache **out, git_repository *repo) +{ + git_submodule_cache *cache = git__calloc(1, sizeof(git_submodule_cache)); + GITERR_CHECK_ALLOC(cache); + + if (git_mutex_init(&cache->lock) < 0) { + giterr_set(GITERR_OS, "Unable to initialize submodule cache lock"); + git__free(cache); + return -1; + } + + if (git_strmap_alloc(&cache->submodules) < 0) { + submodule_cache_free(cache); + return -1; + } + + cache->repo = repo; + git_buf_init(&cache->gitmodules_path, 0); + + *out = cache; + return 0; +} + +static int submodule_cache_refresh(git_submodule_cache *cache, int refresh) +{ + int error = 0, update_index, update_head, update_gitmod; + git_index *idx = NULL; + git_tree *head = NULL; + const char *wd = NULL; + git_buf path = GIT_BUF_INIT; + git_submodule *sm; + git_config_backend *mods = NULL; + uint32_t mask; + + if (!cache || !cache->repo || !refresh) + return 0; + + if (git_mutex_lock(&cache->lock) < 0) { + giterr_set(GITERR_OS, "Unable to acquire lock on submodule cache"); + return -1; + } + + /* get sources that we will need to check */ + + if (git_repository_index(&idx, cache->repo) < 0) + giterr_clear(); + if (git_repository_head_tree(&head, cache->repo) < 0) + giterr_clear(); + + wd = git_repository_workdir(cache->repo); + if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0) + goto cleanup; + + /* check for invalidation */ + + if (refresh == CACHE_FLUSH) + update_index = update_head = update_gitmod = true; + else { + update_index = + !idx || git_index__changed_relative_to(idx, &cache->index_stamp); + update_head = + !head || !git_oid_equal(&cache->head_id, git_tree_id(head)); + + update_gitmod = (wd != NULL) ? + git_futils_filestamp_check(&cache->gitmodules_stamp, path.ptr) : + (cache->gitmodules_stamp.mtime != 0); + } + + /* clear submodule flags that are to be refreshed */ + + mask = 0; + if (!idx || update_index) + mask |= GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS__INDEX_FLAGS | + GIT_SUBMODULE_STATUS__INDEX_OID_VALID | + GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES; + if (!head || update_head) + mask |= GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS__HEAD_OID_VALID; + if (update_gitmod) + mask |= GIT_SUBMODULE_STATUS_IN_CONFIG; + if (mask != 0) + mask |= GIT_SUBMODULE_STATUS_IN_WD | + GIT_SUBMODULE_STATUS__WD_SCANNED | + GIT_SUBMODULE_STATUS__WD_FLAGS | + GIT_SUBMODULE_STATUS__WD_OID_VALID; + else + goto cleanup; /* nothing to do */ + + submodule_cache_clear_flags(cache, mask); + + /* add back submodule information from index */ + + if (idx && update_index) { + if ((error = submodule_cache_refresh_from_index(cache, idx)) < 0) + goto cleanup; + + git_futils_filestamp_set( + &cache->index_stamp, git_index__filestamp(idx)); + } + + /* add submodule information from HEAD */ + + if (head && update_head) { + if ((error = submodule_cache_refresh_from_head(cache, head)) < 0) + goto cleanup; + + git_oid_cpy(&cache->head_id, git_tree_id(head)); + } + + /* add submodule information from .gitmodules */ + + if (wd && update_gitmod > 0) { + if ((mods = open_gitmodules(cache, false)) != NULL && + (error = git_config_file_foreach( + mods, submodule_load_from_config, cache)) < 0) + goto cleanup; + } + + /* shallow scan submodules in work tree as needed */ + + if (wd && mask != 0) { + git_strmap_foreach_value(cache->submodules, sm, { + submodule_load_from_wd_lite(sm); + }); + } + + /* remove submodules that no longer exist */ + + git_strmap_foreach_value(cache->submodules, sm, { + /* purge unless in HEAD, index, or .gitmodules; no sm for wd only */ + if (sm != NULL && + !(sm->flags & + (GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS_IN_CONFIG))) + submodule_cache_remove_item(cache, sm, true); + }); + +cleanup: + git_config_file_free(mods); + + /* TODO: if we got an error, mark submodule config as invalid? */ + + git_mutex_unlock(&cache->lock); + + git_index_free(idx); + git_tree_free(head); + git_buf_free(&path); + + return error; +} + +static int submodule_cache_init(git_repository *repo, int cache_refresh) +{ + int error = 0; + git_submodule_cache *cache = NULL; + + /* if submodules already exist, just refresh as requested */ + if (repo->_submodules) + return submodule_cache_refresh(repo->_submodules, cache_refresh); + + /* otherwise create a new cache, load it, and atomically swap it in */ + if (!(error = submodule_cache_alloc(&cache, repo)) && + !(error = submodule_cache_refresh(cache, CACHE_FLUSH))) + cache = git__compare_and_swap(&repo->_submodules, NULL, cache); + + /* might have raced with another thread to set cache, so free if needed */ + if (cache) + submodule_cache_free(cache); + + return error; +} + +/* Lookup name of remote of the local tracking branch HEAD points to */ +static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo) +{ + int error; + git_reference *head = NULL; + git_buf upstream_name = GIT_BUF_INIT; + + /* lookup and dereference HEAD */ + if ((error = git_repository_head(&head, repo)) < 0) + return error; + + /** + * If head does not refer to a branch, then return + * GIT_ENOTFOUND to indicate that we could not find + * a remote key for the local tracking branch HEAD points to. + **/ + if (!git_reference_is_branch(head)) { + giterr_set(GITERR_INVALID, + "HEAD does not refer to a branch."); + error = GIT_ENOTFOUND; + goto done; + } + + /* lookup remote tracking branch of HEAD */ + if ((error = git_branch_upstream_name( + &upstream_name, + repo, + git_reference_name(head))) < 0) + goto done; + + /* lookup remote of remote tracking branch */ + if ((error = git_branch_remote_name(remote_name, repo, upstream_name.ptr)) < 0) + goto done; + +done: + git_buf_free(&upstream_name); + git_reference_free(head); + + return error; +} + +/* Lookup the remote of the local tracking branch HEAD points to */ +static int lookup_head_remote(git_remote **remote, git_repository *repo) +{ + int error; + git_buf remote_name = GIT_BUF_INIT; + + /* lookup remote of remote tracking branch name */ + if (!(error = lookup_head_remote_key(&remote_name, repo))) + error = git_remote_lookup(remote, repo, remote_name.ptr); + + git_buf_free(&remote_name); + + return error; +} + +/* Lookup remote, either from HEAD or fall back on origin */ +static int lookup_default_remote(git_remote **remote, git_repository *repo) +{ + int error = lookup_head_remote(remote, repo); + + /* if that failed, use 'origin' instead */ + if (error == GIT_ENOTFOUND) + error = git_remote_lookup(remote, repo, "origin"); + + if (error == GIT_ENOTFOUND) + giterr_set( + GITERR_SUBMODULE, + "Cannot get default remote for submodule - no local tracking " + "branch for HEAD and origin does not exist"); + + return error; +} + +static int get_url_base(git_buf *url, git_repository *repo) +{ + int error; + git_remote *remote = NULL; + + if (!(error = lookup_default_remote(&remote, repo))) { + error = git_buf_sets(url, git_remote_url(remote)); + git_remote_free(remote); + } + else if (error == GIT_ENOTFOUND) { + /* if repository does not have a default remote, use workdir instead */ + giterr_clear(); + error = git_buf_sets(url, git_repository_workdir(repo)); + } + + return error; +} + +static void submodule_get_index_status(unsigned int *status, git_submodule *sm) +{ + const git_oid *head_oid = git_submodule_head_id(sm); + const git_oid *index_oid = git_submodule_index_id(sm); + + *status = *status & ~GIT_SUBMODULE_STATUS__INDEX_FLAGS; + + if (!head_oid) { + if (index_oid) + *status |= GIT_SUBMODULE_STATUS_INDEX_ADDED; + } + else if (!index_oid) + *status |= GIT_SUBMODULE_STATUS_INDEX_DELETED; + else if (!git_oid_equal(head_oid, index_oid)) + *status |= GIT_SUBMODULE_STATUS_INDEX_MODIFIED; +} + + +static void submodule_get_wd_status( + unsigned int *status, + git_submodule *sm, + git_repository *sm_repo, + git_submodule_ignore_t ign) +{ + const git_oid *index_oid = git_submodule_index_id(sm); + const git_oid *wd_oid = + (sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) ? &sm->wd_oid : NULL; + git_tree *sm_head = NULL; + git_index *index = NULL; + git_diff_options opt = GIT_DIFF_OPTIONS_INIT; + git_diff *diff; + + *status = *status & ~GIT_SUBMODULE_STATUS__WD_FLAGS; + + if (!index_oid) { + if (wd_oid) + *status |= GIT_SUBMODULE_STATUS_WD_ADDED; + } + else if (!wd_oid) { + if ((sm->flags & GIT_SUBMODULE_STATUS__WD_SCANNED) != 0 && + (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) == 0) + *status |= GIT_SUBMODULE_STATUS_WD_UNINITIALIZED; + else + *status |= GIT_SUBMODULE_STATUS_WD_DELETED; + } + else if (!git_oid_equal(index_oid, wd_oid)) + *status |= GIT_SUBMODULE_STATUS_WD_MODIFIED; + + /* if we have no repo, then we're done */ + if (!sm_repo) + return; + + /* the diffs below could be optimized with an early termination + * option to the git_diff functions, but for now this is sufficient + * (and certainly no worse that what core git does). + */ + + if (ign == GIT_SUBMODULE_IGNORE_NONE) + opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED; + + (void)git_repository_index__weakptr(&index, sm_repo); + + /* if we don't have an unborn head, check diff with index */ + if (git_repository_head_tree(&sm_head, sm_repo) < 0) + giterr_clear(); + else { + /* perform head to index diff on submodule */ + if (git_diff_tree_to_index(&diff, sm_repo, sm_head, index, &opt) < 0) + giterr_clear(); + else { + if (git_diff_num_deltas(diff) > 0) + *status |= GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED; + git_diff_free(diff); + diff = NULL; + } + + git_tree_free(sm_head); + } + + /* perform index-to-workdir diff on submodule */ + if (git_diff_index_to_workdir(&diff, sm_repo, index, &opt) < 0) + giterr_clear(); + else { + size_t untracked = + git_diff_num_deltas_of_type(diff, GIT_DELTA_UNTRACKED); + + if (untracked > 0) + *status |= GIT_SUBMODULE_STATUS_WD_UNTRACKED; + + if (git_diff_num_deltas(diff) != untracked) + *status |= GIT_SUBMODULE_STATUS_WD_WD_MODIFIED; + + git_diff_free(diff); + diff = NULL; + } +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/submodule.h b/deps/libgit2-sys-0.2.17/libgit2/src/submodule.h new file mode 100644 index 000000000..a6182beca --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/submodule.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_submodule_h__ +#define INCLUDE_submodule_h__ + +#include "git2/submodule.h" +#include "git2/repository.h" +#include "fileops.h" + +/* Notes: + * + * Submodule information can be in four places: the index, the config files + * (both .git/config and .gitmodules), the HEAD tree, and the working + * directory. + * + * In the index: + * - submodule is found by path + * - may be missing, present, or of the wrong type + * - will have an oid if present + * + * In the HEAD tree: + * - submodule is found by path + * - may be missing, present, or of the wrong type + * - will have an oid if present + * + * In the config files: + * - submodule is found by submodule "name" which is usually the path + * - may be missing or present + * - will have a name, path, url, and other properties + * + * In the working directory: + * - submodule is found by path + * - may be missing, an empty directory, a checked out directory, + * or of the wrong type + * - if checked out, will have a HEAD oid + * - if checked out, will have git history that can be used to compare oids + * - if checked out, may have modified files and/or untracked files + */ + +/** + * Description of submodule + * + * This record describes a submodule found in a repository. There should be + * an entry for every submodule found in the HEAD and index, and for every + * submodule described in .gitmodules. The fields are as follows: + * + * - `rc` tracks the refcount of how many hash table entries in the + * git_submodule_cache there are for this submodule. It only comes into + * play if the name and path of the submodule differ. + * + * - `name` is the name of the submodule from .gitmodules. + * - `path` is the path to the submodule from the repo root. It is almost + * always the same as `name`. + * - `url` is the url for the submodule. + * - `update` is a git_submodule_update_t value - see gitmodules(5) update. + * - `update_default` is the update value from the config + * - `ignore` is a git_submodule_ignore_t value - see gitmodules(5) ignore. + * - `ignore_default` is the ignore value from the config + * - `fetch_recurse` is a git_submodule_recurse_t value - see gitmodules(5) + * fetchRecurseSubmodules. + * - `fetch_recurse_default` is the recurse value from the config + * + * - `repo` is the parent repository that contains this submodule. + * - `flags` after for internal use, tracking where this submodule has been + * found (head, index, config, workdir) and known status info, etc. + * - `head_oid` is the SHA1 for the submodule path in the repo HEAD. + * - `index_oid` is the SHA1 for the submodule recorded in the index. + * - `wd_oid` is the SHA1 for the HEAD of the checked out submodule. + * + * If the submodule has been added to .gitmodules but not yet git added, + * then the `index_oid` will be zero but still marked valid. If the + * submodule has been deleted, but the delete has not been committed yet, + * then the `index_oid` will be set, but the `url` will be NULL. + */ +struct git_submodule { + git_refcount rc; + + /* information from config */ + char *name; + char *path; /* important: may just point to "name" string */ + char *url; + char *branch; + git_submodule_update_t update; + git_submodule_update_t update_default; + git_submodule_ignore_t ignore; + git_submodule_ignore_t ignore_default; + git_submodule_recurse_t fetch_recurse; + git_submodule_recurse_t fetch_recurse_default; + + /* internal information */ + git_repository *repo; + uint32_t flags; + git_oid head_oid; + git_oid index_oid; + git_oid wd_oid; +}; + +/** + * The git_submodule_cache stores known submodules along with timestamps, + * etc. about when they were loaded + */ +typedef struct { + git_repository *repo; + git_strmap *submodules; + git_mutex lock; + + /* cache invalidation data */ + git_oid head_id; + git_futils_filestamp index_stamp; + git_buf gitmodules_path; + git_futils_filestamp gitmodules_stamp; + git_futils_filestamp config_stamp; +} git_submodule_cache; + +/* Force revalidation of submodule data cache (alloc as needed) */ +extern int git_submodule_cache_refresh(git_repository *repo); + +/* Release all submodules */ +extern void git_submodule_cache_free(git_repository *repo); + +/* Additional flags on top of public GIT_SUBMODULE_STATUS values */ +enum { + GIT_SUBMODULE_STATUS__WD_SCANNED = (1u << 20), + GIT_SUBMODULE_STATUS__HEAD_OID_VALID = (1u << 21), + GIT_SUBMODULE_STATUS__INDEX_OID_VALID = (1u << 22), + GIT_SUBMODULE_STATUS__WD_OID_VALID = (1u << 23), + GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE = (1u << 24), + GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE = (1u << 25), + GIT_SUBMODULE_STATUS__WD_NOT_SUBMODULE = (1u << 26), + GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES = (1u << 27), +}; + +#define GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(S) \ + ((S) & ~(0xFFFFFFFFu << 20)) + +/* Internal submodule check does not attempt to refresh cached data */ +extern bool git_submodule__is_submodule(git_repository *repo, const char *name); + +/* Internal lookup does not attempt to refresh cached data */ +extern int git_submodule__lookup( + git_submodule **out, git_repository *repo, const char *path); + +/* Internal status fn returns status and optionally the various OIDs */ +extern int git_submodule__status( + unsigned int *out_status, + git_oid *out_head_id, + git_oid *out_index_id, + git_oid *out_wd_id, + git_submodule *sm, + git_submodule_ignore_t ign); + +/* Open submodule repository as bare repo for quick HEAD check, etc. */ +extern int git_submodule_open_bare( + git_repository **repo, + git_submodule *submodule); + +extern int git_submodule_parse_ignore( + git_submodule_ignore_t *out, const char *value); +extern int git_submodule_parse_update( + git_submodule_update_t *out, const char *value); + +extern const char *git_submodule_ignore_to_str(git_submodule_ignore_t); +extern const char *git_submodule_update_to_str(git_submodule_update_t); +extern const char *git_submodule_recurse_to_str(git_submodule_recurse_t); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/sysdir.c b/deps/libgit2-sys-0.2.17/libgit2/src/sysdir.c new file mode 100644 index 000000000..cd94a8b57 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/sysdir.c @@ -0,0 +1,252 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "sysdir.h" +#include "global.h" +#include "buffer.h" +#include "path.h" +#include +#if GIT_WIN32 +#include "win32/findfile.h" +#endif + +static int git_sysdir_guess_system_dirs(git_buf *out) +{ +#ifdef GIT_WIN32 + return git_win32__find_system_dirs(out, L"etc\\"); +#else + return git_buf_sets(out, "/etc"); +#endif +} + +static int git_sysdir_guess_global_dirs(git_buf *out) +{ +#ifdef GIT_WIN32 + return git_win32__find_global_dirs(out); +#else + return git_buf_sets(out, getenv("HOME")); +#endif +} + +static int git_sysdir_guess_xdg_dirs(git_buf *out) +{ +#ifdef GIT_WIN32 + return git_win32__find_xdg_dirs(out); +#else + const char *env = NULL; + + if ((env = getenv("XDG_CONFIG_HOME")) != NULL) + return git_buf_joinpath(out, env, "git"); + else if ((env = getenv("HOME")) != NULL) + return git_buf_joinpath(out, env, ".config/git"); + + git_buf_clear(out); + return 0; +#endif +} + +static int git_sysdir_guess_template_dirs(git_buf *out) +{ +#ifdef GIT_WIN32 + return git_win32__find_system_dirs(out, L"share\\git-core\\templates"); +#else + return git_buf_sets(out, "/usr/share/git-core/templates"); +#endif +} + +typedef int (*git_sysdir_guess_cb)(git_buf *out); + +static git_buf git_sysdir__dirs[GIT_SYSDIR__MAX] = + { GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT }; + +static git_sysdir_guess_cb git_sysdir__dir_guess[GIT_SYSDIR__MAX] = { + git_sysdir_guess_system_dirs, + git_sysdir_guess_global_dirs, + git_sysdir_guess_xdg_dirs, + git_sysdir_guess_template_dirs, +}; + +static int git_sysdir__dirs_shutdown_set = 0; + +int git_sysdir_global_init(void) +{ + git_sysdir_t i; + const git_buf *path; + int error = 0; + + for (i = 0; !error && i < GIT_SYSDIR__MAX; i++) + error = git_sysdir_get(&path, i); + + return error; +} + +void git_sysdir_global_shutdown(void) +{ + int i; + for (i = 0; i < GIT_SYSDIR__MAX; ++i) + git_buf_free(&git_sysdir__dirs[i]); + + git_sysdir__dirs_shutdown_set = 0; +} + +static int git_sysdir_check_selector(git_sysdir_t which) +{ + if (which < GIT_SYSDIR__MAX) + return 0; + + giterr_set(GITERR_INVALID, "config directory selector out of range"); + return -1; +} + + +int git_sysdir_get(const git_buf **out, git_sysdir_t which) +{ + assert(out); + + *out = NULL; + + GITERR_CHECK_ERROR(git_sysdir_check_selector(which)); + + if (!git_buf_len(&git_sysdir__dirs[which])) { + /* prepare shutdown if we're going to need it */ + if (!git_sysdir__dirs_shutdown_set) { + git__on_shutdown(git_sysdir_global_shutdown); + git_sysdir__dirs_shutdown_set = 1; + } + + GITERR_CHECK_ERROR( + git_sysdir__dir_guess[which](&git_sysdir__dirs[which])); + } + + *out = &git_sysdir__dirs[which]; + return 0; +} + +int git_sysdir_get_str( + char *out, + size_t outlen, + git_sysdir_t which) +{ + const git_buf *path = NULL; + + GITERR_CHECK_ERROR(git_sysdir_check_selector(which)); + GITERR_CHECK_ERROR(git_sysdir_get(&path, which)); + + if (!out || path->size >= outlen) { + giterr_set(GITERR_NOMEMORY, "Buffer is too short for the path"); + return GIT_EBUFS; + } + + git_buf_copy_cstr(out, outlen, path); + return 0; +} + +#define PATH_MAGIC "$PATH" + +int git_sysdir_set(git_sysdir_t which, const char *search_path) +{ + const char *expand_path = NULL; + git_buf merge = GIT_BUF_INIT; + + GITERR_CHECK_ERROR(git_sysdir_check_selector(which)); + + if (search_path != NULL) + expand_path = strstr(search_path, PATH_MAGIC); + + /* init with default if not yet done and needed (ignoring error) */ + if ((!search_path || expand_path) && + !git_buf_len(&git_sysdir__dirs[which])) + git_sysdir__dir_guess[which](&git_sysdir__dirs[which]); + + /* if $PATH is not referenced, then just set the path */ + if (!expand_path) + return git_buf_sets(&git_sysdir__dirs[which], search_path); + + /* otherwise set to join(before $PATH, old value, after $PATH) */ + if (expand_path > search_path) + git_buf_set(&merge, search_path, expand_path - search_path); + + if (git_buf_len(&git_sysdir__dirs[which])) + git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR, + merge.ptr, git_sysdir__dirs[which].ptr); + + expand_path += strlen(PATH_MAGIC); + if (*expand_path) + git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR, merge.ptr, expand_path); + + git_buf_swap(&git_sysdir__dirs[which], &merge); + git_buf_free(&merge); + + return git_buf_oom(&git_sysdir__dirs[which]) ? -1 : 0; +} + +static int git_sysdir_find_in_dirlist( + git_buf *path, + const char *name, + git_sysdir_t which, + const char *label) +{ + size_t len; + const char *scan, *next = NULL; + const git_buf *syspath; + + GITERR_CHECK_ERROR(git_sysdir_get(&syspath, which)); + if (!syspath || !git_buf_len(syspath)) + goto done; + + for (scan = git_buf_cstr(syspath); scan; scan = next) { + /* find unescaped separator or end of string */ + for (next = scan; *next; ++next) { + if (*next == GIT_PATH_LIST_SEPARATOR && + (next <= scan || next[-1] != '\\')) + break; + } + + len = (size_t)(next - scan); + next = (*next ? next + 1 : NULL); + if (!len) + continue; + + GITERR_CHECK_ERROR(git_buf_set(path, scan, len)); + if (name) + GITERR_CHECK_ERROR(git_buf_joinpath(path, path->ptr, name)); + + if (git_path_exists(path->ptr)) + return 0; + } + +done: + git_buf_free(path); + giterr_set(GITERR_OS, "The %s file '%s' doesn't exist", label, name); + return GIT_ENOTFOUND; +} + +int git_sysdir_find_system_file(git_buf *path, const char *filename) +{ + return git_sysdir_find_in_dirlist( + path, filename, GIT_SYSDIR_SYSTEM, "system"); +} + +int git_sysdir_find_global_file(git_buf *path, const char *filename) +{ + return git_sysdir_find_in_dirlist( + path, filename, GIT_SYSDIR_GLOBAL, "global"); +} + +int git_sysdir_find_xdg_file(git_buf *path, const char *filename) +{ + return git_sysdir_find_in_dirlist( + path, filename, GIT_SYSDIR_XDG, "global/xdg"); +} + +int git_sysdir_find_template_dir(git_buf *path) +{ + return git_sysdir_find_in_dirlist( + path, NULL, GIT_SYSDIR_TEMPLATE, "template"); +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/sysdir.h b/deps/libgit2-sys-0.2.17/libgit2/src/sysdir.h new file mode 100644 index 000000000..f1bbf0bae --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/sysdir.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sysdir_h__ +#define INCLUDE_sysdir_h__ + +#include "common.h" +#include "posix.h" +#include "buffer.h" + +/** + * Find a "global" file (i.e. one in a user's home directory). + * + * @param path buffer to write the full path into + * @param filename name of file to find in the home directory + * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error + */ +extern int git_sysdir_find_global_file(git_buf *path, const char *filename); + +/** + * Find an "XDG" file (i.e. one in user's XDG config path). + * + * @param path buffer to write the full path into + * @param filename name of file to find in the home directory + * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error + */ +extern int git_sysdir_find_xdg_file(git_buf *path, const char *filename); + +/** + * Find a "system" file (i.e. one shared for all users of the system). + * + * @param path buffer to write the full path into + * @param filename name of file to find in the home directory + * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error + */ +extern int git_sysdir_find_system_file(git_buf *path, const char *filename); + +/** + * Find template directory. + * + * @param path buffer to write the full path into + * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error + */ +extern int git_sysdir_find_template_dir(git_buf *path); + +typedef enum { + GIT_SYSDIR_SYSTEM = 0, + GIT_SYSDIR_GLOBAL = 1, + GIT_SYSDIR_XDG = 2, + GIT_SYSDIR_TEMPLATE = 3, + GIT_SYSDIR__MAX = 4, +} git_sysdir_t; + +/** + * Configures global data for configuration file search paths. + * + * @return 0 on success, <0 on failure + */ +extern int git_sysdir_global_init(void); + +/** + * Get the search path for global/system/xdg files + * + * @param out pointer to git_buf containing search path + * @param which which list of paths to return + * @return 0 on success, <0 on failure + */ +extern int git_sysdir_get(const git_buf **out, git_sysdir_t which); + +/** + * Get search path into a preallocated buffer + * + * @param out String buffer to write into + * @param outlen Size of string buffer + * @param which Which search path to return + * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure + */ + +extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which); + +/** + * Set search paths for global/system/xdg files + * + * The first occurrence of the magic string "$PATH" in the new value will + * be replaced with the old value of the search path. + * + * @param which Which search path to modify + * @param paths New search path (separated by GIT_PATH_LIST_SEPARATOR) + * @return 0 on success, <0 on failure (allocation error) + */ +extern int git_sysdir_set(git_sysdir_t which, const char *paths); + +/** + * Free the configuration file search paths. + */ +extern void git_sysdir_global_shutdown(void); + +#endif /* INCLUDE_sysdir_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tag.c b/deps/libgit2-sys-0.2.17/libgit2/src/tag.c new file mode 100644 index 000000000..6e69d760d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tag.c @@ -0,0 +1,511 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "commit.h" +#include "tag.h" +#include "signature.h" +#include "message.h" +#include "git2/object.h" +#include "git2/repository.h" +#include "git2/signature.h" +#include "git2/odb_backend.h" + +void git_tag__free(void *_tag) +{ + git_tag *tag = _tag; + git_signature_free(tag->tagger); + git__free(tag->message); + git__free(tag->tag_name); + git__free(tag); +} + +int git_tag_target(git_object **target, const git_tag *t) +{ + assert(t); + return git_object_lookup(target, t->object.repo, &t->target, t->type); +} + +const git_oid *git_tag_target_id(const git_tag *t) +{ + assert(t); + return &t->target; +} + +git_otype git_tag_target_type(const git_tag *t) +{ + assert(t); + return t->type; +} + +const char *git_tag_name(const git_tag *t) +{ + assert(t); + return t->tag_name; +} + +const git_signature *git_tag_tagger(const git_tag *t) +{ + return t->tagger; +} + +const char *git_tag_message(const git_tag *t) +{ + assert(t); + return t->message; +} + +static int tag_error(const char *str) +{ + giterr_set(GITERR_TAG, "Failed to parse tag. %s", str); + return -1; +} + +static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end) +{ + static const char *tag_types[] = { + NULL, "commit\n", "tree\n", "blob\n", "tag\n" + }; + + unsigned int i; + size_t text_len, alloc_len; + char *search; + + if (git_oid__parse(&tag->target, &buffer, buffer_end, "object ") < 0) + return tag_error("Object field invalid"); + + if (buffer + 5 >= buffer_end) + return tag_error("Object too short"); + + if (memcmp(buffer, "type ", 5) != 0) + return tag_error("Type field not found"); + buffer += 5; + + tag->type = GIT_OBJ_BAD; + + for (i = 1; i < ARRAY_SIZE(tag_types); ++i) { + size_t type_length = strlen(tag_types[i]); + + if (buffer + type_length >= buffer_end) + return tag_error("Object too short"); + + if (memcmp(buffer, tag_types[i], type_length) == 0) { + tag->type = i; + buffer += type_length; + break; + } + } + + if (tag->type == GIT_OBJ_BAD) + return tag_error("Invalid object type"); + + if (buffer + 4 >= buffer_end) + return tag_error("Object too short"); + + if (memcmp(buffer, "tag ", 4) != 0) + return tag_error("Tag field not found"); + + buffer += 4; + + search = memchr(buffer, '\n', buffer_end - buffer); + if (search == NULL) + return tag_error("Object too short"); + + text_len = search - buffer; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, text_len, 1); + tag->tag_name = git__malloc(alloc_len); + GITERR_CHECK_ALLOC(tag->tag_name); + + memcpy(tag->tag_name, buffer, text_len); + tag->tag_name[text_len] = '\0'; + + buffer = search + 1; + + tag->tagger = NULL; + if (buffer < buffer_end && *buffer != '\n') { + tag->tagger = git__malloc(sizeof(git_signature)); + GITERR_CHECK_ALLOC(tag->tagger); + + if (git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') < 0) + return -1; + } + + tag->message = NULL; + if (buffer < buffer_end) { + if( *buffer != '\n' ) + return tag_error("No new line before message"); + + text_len = buffer_end - ++buffer; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, text_len, 1); + tag->message = git__malloc(alloc_len); + GITERR_CHECK_ALLOC(tag->message); + + memcpy(tag->message, buffer, text_len); + tag->message[text_len] = '\0'; + } + + return 0; +} + +int git_tag__parse(void *_tag, git_odb_object *odb_obj) +{ + git_tag *tag = _tag; + const char *buffer = git_odb_object_data(odb_obj); + const char *buffer_end = buffer + git_odb_object_size(odb_obj); + + return tag_parse(tag, buffer, buffer_end); +} + +static int retrieve_tag_reference( + git_reference **tag_reference_out, + git_buf *ref_name_out, + git_repository *repo, + const char *tag_name) +{ + git_reference *tag_ref; + int error; + + *tag_reference_out = NULL; + + if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) + return -1; + + error = git_reference_lookup(&tag_ref, repo, ref_name_out->ptr); + if (error < 0) + return error; /* Be it not foundo or corrupted */ + + *tag_reference_out = tag_ref; + + return 0; +} + +static int retrieve_tag_reference_oid( + git_oid *oid, + git_buf *ref_name_out, + git_repository *repo, + const char *tag_name) +{ + if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) + return -1; + + return git_reference_name_to_id(oid, repo, ref_name_out->ptr); +} + +static int write_tag_annotation( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message) +{ + git_buf tag = GIT_BUF_INIT; + git_odb *odb; + + git_oid__writebuf(&tag, "object ", git_object_id(target)); + git_buf_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target))); + git_buf_printf(&tag, "tag %s\n", tag_name); + git_signature__writebuf(&tag, "tagger ", tagger); + git_buf_putc(&tag, '\n'); + + if (git_buf_puts(&tag, message) < 0) + goto on_error; + + if (git_repository_odb__weakptr(&odb, repo) < 0) + goto on_error; + + if (git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG) < 0) + goto on_error; + + git_buf_free(&tag); + return 0; + +on_error: + git_buf_free(&tag); + giterr_set(GITERR_OBJECT, "Failed to create tag annotation."); + return -1; +} + +static int git_tag_create__internal( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message, + int allow_ref_overwrite, + int create_tag_annotation) +{ + git_reference *new_ref = NULL; + git_buf ref_name = GIT_BUF_INIT; + + int error; + + assert(repo && tag_name && target); + assert(!create_tag_annotation || (tagger && message)); + + if (git_object_owner(target) != repo) { + giterr_set(GITERR_INVALID, "The given target does not belong to this repository"); + return -1; + } + + error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag_name); + if (error < 0 && error != GIT_ENOTFOUND) + goto cleanup; + + /** Ensure the tag name doesn't conflict with an already existing + * reference unless overwriting has explicitly been requested **/ + if (error == 0 && !allow_ref_overwrite) { + git_buf_free(&ref_name); + giterr_set(GITERR_TAG, "Tag already exists"); + return GIT_EEXISTS; + } + + if (create_tag_annotation) { + if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0) + return -1; + } else + git_oid_cpy(oid, git_object_id(target)); + + error = git_reference_create(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite, NULL); + +cleanup: + git_reference_free(new_ref); + git_buf_free(&ref_name); + return error; +} + +int git_tag_create( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message, + int allow_ref_overwrite) +{ + return git_tag_create__internal(oid, repo, tag_name, target, tagger, message, allow_ref_overwrite, 1); +} + +int git_tag_annotation_create( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message) +{ + assert(oid && repo && tag_name && target && tagger && message); + + return write_tag_annotation(oid, repo, tag_name, target, tagger, message); +} + +int git_tag_create_lightweight( + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + int allow_ref_overwrite) +{ + return git_tag_create__internal(oid, repo, tag_name, target, NULL, NULL, allow_ref_overwrite, 0); +} + +int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite) +{ + git_tag tag; + int error; + git_odb *odb; + git_odb_stream *stream; + git_odb_object *target_obj; + + git_reference *new_ref = NULL; + git_buf ref_name = GIT_BUF_INIT; + + assert(oid && buffer); + + memset(&tag, 0, sizeof(tag)); + + if (git_repository_odb__weakptr(&odb, repo) < 0) + return -1; + + /* validate the buffer */ + if (tag_parse(&tag, buffer, buffer + strlen(buffer)) < 0) + return -1; + + /* validate the target */ + if (git_odb_read(&target_obj, odb, &tag.target) < 0) + goto on_error; + + if (tag.type != target_obj->cached.type) { + giterr_set(GITERR_TAG, "The type for the given target is invalid"); + goto on_error; + } + + error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag.tag_name); + if (error < 0 && error != GIT_ENOTFOUND) + goto on_error; + + /* We don't need these objects after this */ + git_signature_free(tag.tagger); + git__free(tag.tag_name); + git__free(tag.message); + git_odb_object_free(target_obj); + + /** Ensure the tag name doesn't conflict with an already existing + * reference unless overwriting has explictly been requested **/ + if (error == 0 && !allow_ref_overwrite) { + giterr_set(GITERR_TAG, "Tag already exists"); + return GIT_EEXISTS; + } + + /* write the buffer */ + if ((error = git_odb_open_wstream( + &stream, odb, strlen(buffer), GIT_OBJ_TAG)) < 0) + return error; + + if (!(error = git_odb_stream_write(stream, buffer, strlen(buffer)))) + error = git_odb_stream_finalize_write(oid, stream); + + git_odb_stream_free(stream); + + if (error < 0) { + git_buf_free(&ref_name); + return error; + } + + error = git_reference_create( + &new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite, NULL); + + git_reference_free(new_ref); + git_buf_free(&ref_name); + + return error; + +on_error: + git_signature_free(tag.tagger); + git__free(tag.tag_name); + git__free(tag.message); + git_odb_object_free(target_obj); + return -1; +} + +int git_tag_delete(git_repository *repo, const char *tag_name) +{ + git_reference *tag_ref; + git_buf ref_name = GIT_BUF_INIT; + int error; + + error = retrieve_tag_reference(&tag_ref, &ref_name, repo, tag_name); + + git_buf_free(&ref_name); + + if (error < 0) + return error; + + error = git_reference_delete(tag_ref); + + git_reference_free(tag_ref); + + return error; +} + +typedef struct { + git_repository *repo; + git_tag_foreach_cb cb; + void *cb_data; +} tag_cb_data; + +static int tags_cb(const char *ref, void *data) +{ + int error; + git_oid oid; + tag_cb_data *d = (tag_cb_data *)data; + + if (git__prefixcmp(ref, GIT_REFS_TAGS_DIR) != 0) + return 0; /* no tag */ + + if (!(error = git_reference_name_to_id(&oid, d->repo, ref))) { + if ((error = d->cb(ref, &oid, d->cb_data)) != 0) + giterr_set_after_callback_function(error, "git_tag_foreach"); + } + + return error; +} + +int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data) +{ + tag_cb_data data; + + assert(repo && cb); + + data.cb = cb; + data.cb_data = cb_data; + data.repo = repo; + + return git_reference_foreach_name(repo, &tags_cb, &data); +} + +typedef struct { + git_vector *taglist; + const char *pattern; +} tag_filter_data; + +#define GIT_REFS_TAGS_DIR_LEN strlen(GIT_REFS_TAGS_DIR) + +static int tag_list_cb(const char *tag_name, git_oid *oid, void *data) +{ + tag_filter_data *filter = (tag_filter_data *)data; + GIT_UNUSED(oid); + + if (!*filter->pattern || + p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == 0) + { + char *matched = git__strdup(tag_name + GIT_REFS_TAGS_DIR_LEN); + GITERR_CHECK_ALLOC(matched); + + return git_vector_insert(filter->taglist, matched); + } + + return 0; +} + +int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_repository *repo) +{ + int error; + tag_filter_data filter; + git_vector taglist; + + assert(tag_names && repo && pattern); + + if ((error = git_vector_init(&taglist, 8, NULL)) < 0) + return error; + + filter.taglist = &taglist; + filter.pattern = pattern; + + error = git_tag_foreach(repo, &tag_list_cb, (void *)&filter); + + if (error < 0) + git_vector_free(&taglist); + + tag_names->strings = + (char **)git_vector_detach(&tag_names->count, NULL, &taglist); + + return 0; +} + +int git_tag_list(git_strarray *tag_names, git_repository *repo) +{ + return git_tag_list_match(tag_names, "", repo); +} + +int git_tag_peel(git_object **tag_target, const git_tag *tag) +{ + return git_object_peel(tag_target, (const git_object *)tag, GIT_OBJ_ANY); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tag.h b/deps/libgit2-sys-0.2.17/libgit2/src/tag.h new file mode 100644 index 000000000..d0cd393c7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tag.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_tag_h__ +#define INCLUDE_tag_h__ + +#include "git2/tag.h" +#include "repository.h" +#include "odb.h" + +struct git_tag { + git_object object; + + git_oid target; + git_otype type; + + char *tag_name; + git_signature *tagger; + char *message; +}; + +void git_tag__free(void *tag); +int git_tag__parse(void *tag, git_odb_object *obj); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.c b/deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.c new file mode 100644 index 000000000..c3baf411a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "thread-utils.h" + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#elif defined(hpux) || defined(__hpux) || defined(_hpux) +# include +#endif + +/* + * By doing this in two steps we can at least get + * the function to be somewhat coherent, even + * with this disgusting nest of #ifdefs. + */ +#ifndef _SC_NPROCESSORS_ONLN +# ifdef _SC_NPROC_ONLN +# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN +# elif defined _SC_CRAY_NCPU +# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU +# endif +#endif + +int git_online_cpus(void) +{ +#ifdef _SC_NPROCESSORS_ONLN + long ncpus; +#endif + +#ifdef _WIN32 + SYSTEM_INFO info; + GetSystemInfo(&info); + + if ((int)info.dwNumberOfProcessors > 0) + return (int)info.dwNumberOfProcessors; +#elif defined(hpux) || defined(__hpux) || defined(_hpux) + struct pst_dynamic psd; + + if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0)) + return (int)psd.psd_proc_cnt; +#endif + +#ifdef _SC_NPROCESSORS_ONLN + if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0) + return (int)ncpus; +#endif + + return 1; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.h b/deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.h new file mode 100644 index 000000000..dd1136caf --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/thread-utils.h @@ -0,0 +1,286 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_thread_utils_h__ +#define INCLUDE_thread_utils_h__ + +/* Common operations even if threading has been disabled */ +typedef struct { +#if defined(GIT_WIN32) + volatile long val; +#else + volatile int val; +#endif +} git_atomic; + +#ifdef GIT_ARCH_64 + +typedef struct { +#if defined(GIT_WIN32) + __int64 val; +#else + int64_t val; +#endif +} git_atomic64; + +typedef git_atomic64 git_atomic_ssize; + +#define git_atomic_ssize_add git_atomic64_add + +#else + +typedef git_atomic git_atomic_ssize; + +#define git_atomic_ssize_add git_atomic_add + +#endif + +#ifdef GIT_THREADS + +#if !defined(GIT_WIN32) + +typedef struct { + pthread_t thread; +} git_thread; + +#define git_thread_create(git_thread_ptr, attr, start_routine, arg) \ + pthread_create(&(git_thread_ptr)->thread, attr, start_routine, arg) +#define git_thread_join(git_thread_ptr, status) \ + pthread_join((git_thread_ptr)->thread, status) + +#endif + +/* Pthreads Mutex */ +#define git_mutex pthread_mutex_t +#define git_mutex_init(a) pthread_mutex_init(a, NULL) +#define git_mutex_lock(a) pthread_mutex_lock(a) +#define git_mutex_unlock(a) pthread_mutex_unlock(a) +#define git_mutex_free(a) pthread_mutex_destroy(a) + +/* Pthreads condition vars */ +#define git_cond pthread_cond_t +#define git_cond_init(c) pthread_cond_init(c, NULL) +#define git_cond_free(c) pthread_cond_destroy(c) +#define git_cond_wait(c, l) pthread_cond_wait(c, l) +#define git_cond_signal(c) pthread_cond_signal(c) +#define git_cond_broadcast(c) pthread_cond_broadcast(c) + +/* Pthread (-ish) rwlock + * + * This differs from normal pthreads rwlocks in two ways: + * 1. Separate APIs for releasing read locks and write locks (as + * opposed to the pure POSIX API which only has one unlock fn) + * 2. You should not use recursive read locks (i.e. grabbing a read + * lock in a thread that already holds a read lock) because the + * Windows implementation doesn't support it + */ +#define git_rwlock pthread_rwlock_t +#define git_rwlock_init(a) pthread_rwlock_init(a, NULL) +#define git_rwlock_rdlock(a) pthread_rwlock_rdlock(a) +#define git_rwlock_rdunlock(a) pthread_rwlock_rdunlock(a) +#define git_rwlock_wrlock(a) pthread_rwlock_wrlock(a) +#define git_rwlock_wrunlock(a) pthread_rwlock_wrunlock(a) +#define git_rwlock_free(a) pthread_rwlock_destroy(a) +#define GIT_RWLOCK_STATIC_INIT PTHREAD_RWLOCK_INITIALIZER + +#ifndef GIT_WIN32 +#define pthread_rwlock_rdunlock pthread_rwlock_unlock +#define pthread_rwlock_wrunlock pthread_rwlock_unlock +#endif + + +GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) +{ +#if defined(GIT_WIN32) + InterlockedExchange(&a->val, (LONG)val); +#elif defined(__GNUC__) + __sync_lock_test_and_set(&a->val, val); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +GIT_INLINE(int) git_atomic_inc(git_atomic *a) +{ +#if defined(GIT_WIN32) + return InterlockedIncrement(&a->val); +#elif defined(__GNUC__) + return __sync_add_and_fetch(&a->val, 1); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) +{ +#if defined(GIT_WIN32) + return InterlockedExchangeAdd(&a->val, addend); +#elif defined(__GNUC__) + return __sync_add_and_fetch(&a->val, addend); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +GIT_INLINE(int) git_atomic_dec(git_atomic *a) +{ +#if defined(GIT_WIN32) + return InterlockedDecrement(&a->val); +#elif defined(__GNUC__) + return __sync_sub_and_fetch(&a->val, 1); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +GIT_INLINE(void *) git___compare_and_swap( + void * volatile *ptr, void *oldval, void *newval) +{ + volatile void *foundval; +#if defined(GIT_WIN32) + foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval); +#elif defined(__GNUC__) + foundval = __sync_val_compare_and_swap(ptr, oldval, newval); +#else +# error "Unsupported architecture for atomic operations" +#endif + return (foundval == oldval) ? oldval : newval; +} + +GIT_INLINE(volatile void *) git___swap( + void * volatile *ptr, void *newval) +{ +#if defined(GIT_WIN32) + return InterlockedExchangePointer(ptr, newval); +#else + return __sync_lock_test_and_set(ptr, newval); +#endif +} + +#ifdef GIT_ARCH_64 + +GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend) +{ +#if defined(GIT_WIN32) + return InterlockedExchangeAdd64(&a->val, addend); +#elif defined(__GNUC__) + return __sync_add_and_fetch(&a->val, addend); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +#endif + +#else + +#define git_thread unsigned int +#define git_thread_create(thread, attr, start_routine, arg) 0 +#define git_thread_join(id, status) (void)0 + +/* Pthreads Mutex */ +#define git_mutex unsigned int +GIT_INLINE(int) git_mutex_init(git_mutex *mutex) \ + { GIT_UNUSED(mutex); return 0; } +GIT_INLINE(int) git_mutex_lock(git_mutex *mutex) \ + { GIT_UNUSED(mutex); return 0; } +#define git_mutex_unlock(a) (void)0 +#define git_mutex_free(a) (void)0 + +/* Pthreads condition vars */ +#define git_cond unsigned int +#define git_cond_init(c, a) (void)0 +#define git_cond_free(c) (void)0 +#define git_cond_wait(c, l) (void)0 +#define git_cond_signal(c) (void)0 +#define git_cond_broadcast(c) (void)0 + +/* Pthreads rwlock */ +#define git_rwlock unsigned int +#define git_rwlock_init(a) 0 +#define git_rwlock_rdlock(a) 0 +#define git_rwlock_rdunlock(a) (void)0 +#define git_rwlock_wrlock(a) 0 +#define git_rwlock_wrunlock(a) (void)0 +#define git_rwlock_free(a) (void)0 +#define GIT_RWLOCK_STATIC_INIT 0 + + +GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) +{ + a->val = val; +} + +GIT_INLINE(int) git_atomic_inc(git_atomic *a) +{ + return ++a->val; +} + +GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) +{ + a->val += addend; + return a->val; +} + +GIT_INLINE(int) git_atomic_dec(git_atomic *a) +{ + return --a->val; +} + +GIT_INLINE(void *) git___compare_and_swap( + void * volatile *ptr, void *oldval, void *newval) +{ + if (*ptr == oldval) + *ptr = newval; + else + oldval = newval; + return oldval; +} + +GIT_INLINE(volatile void *) git___swap( + void * volatile *ptr, void *newval) +{ + volatile void *old = *ptr; + *ptr = newval; + return old; +} + +#ifdef GIT_ARCH_64 + +GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend) +{ + a->val += addend; + return a->val; +} + +#endif + +#endif + +GIT_INLINE(int) git_atomic_get(git_atomic *a) +{ + return (int)a->val; +} + +/* Atomically replace oldval with newval + * @return oldval if it was replaced or newval if it was not + */ +#define git__compare_and_swap(P,O,N) \ + git___compare_and_swap((void * volatile *)P, O, N) + +#define git__swap(ptr, val) (void *)git___swap((void * volatile *)&ptr, val) + +extern int git_online_cpus(void); + +#if defined(GIT_THREADS) && defined(GIT_WIN32) +# define GIT_MEMORY_BARRIER MemoryBarrier() +#elif defined(GIT_THREADS) +# define GIT_MEMORY_BARRIER __sync_synchronize() +#else +# define GIT_MEMORY_BARRIER /* noop */ +#endif + +#endif /* INCLUDE_thread_utils_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/trace.c b/deps/libgit2-sys-0.2.17/libgit2/src/trace.c new file mode 100644 index 000000000..ee5039f56 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/trace.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "buffer.h" +#include "common.h" +#include "global.h" +#include "trace.h" +#include "git2/trace.h" + +#ifdef GIT_TRACE + +struct git_trace_data git_trace__data = {0}; + +#endif + +int git_trace_set(git_trace_level_t level, git_trace_callback callback) +{ +#ifdef GIT_TRACE + assert(level == 0 || callback != NULL); + + git_trace__data.level = level; + git_trace__data.callback = callback; + GIT_MEMORY_BARRIER; + + return 0; +#else + GIT_UNUSED(level); + GIT_UNUSED(callback); + + giterr_set(GITERR_INVALID, + "This version of libgit2 was not built with tracing."); + return -1; +#endif +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/trace.h b/deps/libgit2-sys-0.2.17/libgit2/src/trace.h new file mode 100644 index 000000000..486084d01 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/trace.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_trace_h__ +#define INCLUDE_trace_h__ + +#include +#include "buffer.h" + +#ifdef GIT_TRACE + +struct git_trace_data { + git_trace_level_t level; + git_trace_callback callback; +}; + +extern struct git_trace_data git_trace__data; + +GIT_INLINE(void) git_trace__write_fmt( + git_trace_level_t level, + const char *fmt, ...) +{ + git_trace_callback callback = git_trace__data.callback; + git_buf message = GIT_BUF_INIT; + va_list ap; + + va_start(ap, fmt); + git_buf_vprintf(&message, fmt, ap); + va_end(ap); + + callback(level, git_buf_cstr(&message)); + + git_buf_free(&message); +} + +#define git_trace_level() (git_trace__data.level) +#define git_trace(l, ...) { \ + if (git_trace__data.level >= l && \ + git_trace__data.callback != NULL) { \ + git_trace__write_fmt(l, __VA_ARGS__); \ + } \ + } + +#else + +GIT_INLINE(void) git_trace__null( + git_trace_level_t level, + const char *fmt, ...) +{ + GIT_UNUSED(level); + GIT_UNUSED(fmt); +} + +#define git_trace_level() ((void)0) +#define git_trace git_trace__null + +#endif + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transaction.c b/deps/libgit2-sys-0.2.17/libgit2/src/transaction.c new file mode 100644 index 000000000..7b45b8bf2 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transaction.c @@ -0,0 +1,352 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "repository.h" +#include "strmap.h" +#include "refdb.h" +#include "pool.h" +#include "reflog.h" +#include "signature.h" + +#include "git2/signature.h" +#include "git2/sys/refs.h" +#include "git2/sys/refdb_backend.h" + +GIT__USE_STRMAP + +typedef struct { + const char *name; + void *payload; + + git_ref_t ref_type; + union { + git_oid id; + char *symbolic; + } target; + git_reflog *reflog; + + const char *message; + git_signature *sig; + + unsigned int committed :1, + remove :1; +} transaction_node; + +struct git_transaction { + git_repository *repo; + git_refdb *db; + + git_strmap *locks; + git_pool pool; +}; + +int git_transaction_new(git_transaction **out, git_repository *repo) +{ + int error; + git_pool pool; + git_transaction *tx = NULL; + + assert(out && repo); + + if ((error = git_pool_init(&pool, 1, 0)) < 0) + return error; + + tx = git_pool_mallocz(&pool, sizeof(git_transaction)); + if (!tx) { + error = -1; + goto on_error; + } + + if ((error = git_strmap_alloc(&tx->locks)) < 0) { + error = -1; + goto on_error; + } + + if ((error = git_repository_refdb(&tx->db, repo)) < 0) + goto on_error; + + memcpy(&tx->pool, &pool, sizeof(git_pool)); + tx->repo = repo; + *out = tx; + return 0; + +on_error: + git_pool_clear(&pool); + return error; +} + +int git_transaction_lock_ref(git_transaction *tx, const char *refname) +{ + int error; + transaction_node *node; + + assert(tx && refname); + + node = git_pool_mallocz(&tx->pool, sizeof(transaction_node)); + GITERR_CHECK_ALLOC(node); + + node->name = git_pool_strdup(&tx->pool, refname); + GITERR_CHECK_ALLOC(node->name); + + if ((error = git_refdb_lock(&node->payload, tx->db, refname)) < 0) + return error; + + git_strmap_insert(tx->locks, node->name, node, error); + if (error < 0) + goto cleanup; + + return 0; + +cleanup: + git_refdb_unlock(tx->db, node->payload, false, false, NULL, NULL, NULL); + + return error; +} + +static int find_locked(transaction_node **out, git_transaction *tx, const char *refname) +{ + git_strmap_iter pos; + transaction_node *node; + + pos = git_strmap_lookup_index(tx->locks, refname); + if (!git_strmap_valid_index(tx->locks, pos)) { + giterr_set(GITERR_REFERENCE, "the specified reference is not locked"); + return GIT_ENOTFOUND; + } + + node = git_strmap_value_at(tx->locks, pos); + + *out = node; + return 0; +} + +static int copy_common(transaction_node *node, git_transaction *tx, const git_signature *sig, const char *msg) +{ + if (sig && git_signature__pdup(&node->sig, sig, &tx->pool) < 0) + return -1; + + if (!node->sig) { + git_signature *tmp; + int error; + + if (git_reference__log_signature(&tmp, tx->repo) < 0) + return -1; + + /* make sure the sig we use is in our pool */ + error = git_signature__pdup(&node->sig, tmp, &tx->pool); + git_signature_free(tmp); + if (error < 0) + return error; + } + + if (msg) { + node->message = git_pool_strdup(&tx->pool, msg); + GITERR_CHECK_ALLOC(node->message); + } + + return 0; +} + +int git_transaction_set_target(git_transaction *tx, const char *refname, const git_oid *target, const git_signature *sig, const char *msg) +{ + int error; + transaction_node *node; + + assert(tx && refname && target); + + if ((error = find_locked(&node, tx, refname)) < 0) + return error; + + if ((error = copy_common(node, tx, sig, msg)) < 0) + return error; + + git_oid_cpy(&node->target.id, target); + node->ref_type = GIT_REF_OID; + + return 0; +} + +int git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg) +{ + int error; + transaction_node *node; + + assert(tx && refname && target); + + if ((error = find_locked(&node, tx, refname)) < 0) + return error; + + if ((error = copy_common(node, tx, sig, msg)) < 0) + return error; + + node->target.symbolic = git_pool_strdup(&tx->pool, target); + GITERR_CHECK_ALLOC(node->target.symbolic); + node->ref_type = GIT_REF_SYMBOLIC; + + return 0; +} + +int git_transaction_remove(git_transaction *tx, const char *refname) +{ + int error; + transaction_node *node; + + if ((error = find_locked(&node, tx, refname)) < 0) + return error; + + node->remove = true; + node->ref_type = GIT_REF_OID; /* the id will be ignored */ + + return 0; +} + +static int dup_reflog(git_reflog **out, const git_reflog *in, git_pool *pool) +{ + git_reflog *reflog; + git_reflog_entry *entries; + size_t len, i; + + reflog = git_pool_mallocz(pool, sizeof(git_reflog)); + GITERR_CHECK_ALLOC(reflog); + + reflog->ref_name = git_pool_strdup(pool, in->ref_name); + GITERR_CHECK_ALLOC(reflog->ref_name); + + len = in->entries.length; + reflog->entries.length = len; + reflog->entries.contents = git_pool_mallocz(pool, len * sizeof(void *)); + GITERR_CHECK_ALLOC(reflog->entries.contents); + + entries = git_pool_mallocz(pool, len * sizeof(git_reflog_entry)); + GITERR_CHECK_ALLOC(entries); + + for (i = 0; i < len; i++) { + const git_reflog_entry *src; + git_reflog_entry *tgt; + + tgt = &entries[i]; + reflog->entries.contents[i] = tgt; + + src = git_vector_get(&in->entries, i); + git_oid_cpy(&tgt->oid_old, &src->oid_old); + git_oid_cpy(&tgt->oid_cur, &src->oid_cur); + + tgt->msg = git_pool_strdup(pool, src->msg); + GITERR_CHECK_ALLOC(tgt->msg); + + if (git_signature__pdup(&tgt->committer, src->committer, pool) < 0) + return -1; + } + + + *out = reflog; + return 0; +} + +int git_transaction_set_reflog(git_transaction *tx, const char *refname, const git_reflog *reflog) +{ + int error; + transaction_node *node; + + assert(tx && refname && reflog); + + if ((error = find_locked(&node, tx, refname)) < 0) + return error; + + if ((error = dup_reflog(&node->reflog, reflog, &tx->pool)) < 0) + return error; + + return 0; +} + +static int update_target(git_refdb *db, transaction_node *node) +{ + git_reference *ref; + int error, update_reflog; + + if (node->ref_type == GIT_REF_OID) { + ref = git_reference__alloc(node->name, &node->target.id, NULL); + } else if (node->ref_type == GIT_REF_SYMBOLIC) { + ref = git_reference__alloc_symbolic(node->name, node->target.symbolic); + } else { + abort(); + } + + GITERR_CHECK_ALLOC(ref); + update_reflog = node->reflog == NULL; + + if (node->remove) { + error = git_refdb_unlock(db, node->payload, 2, false, ref, NULL, NULL); + } else if (node->ref_type == GIT_REF_OID) { + error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message); + } else if (node->ref_type == GIT_REF_SYMBOLIC) { + error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message); + } else { + abort(); + } + + git_reference_free(ref); + node->committed = true; + + return error; +} + +int git_transaction_commit(git_transaction *tx) +{ + transaction_node *node; + git_strmap_iter pos; + int error = 0; + + assert(tx); + + for (pos = kh_begin(tx->locks); pos < kh_end(tx->locks); pos++) { + if (!git_strmap_has_data(tx->locks, pos)) + continue; + + node = git_strmap_value_at(tx->locks, pos); + if (node->reflog) { + if ((error = tx->db->backend->reflog_write(tx->db->backend, node->reflog)) < 0) + return error; + } + + if (node->ref_type != GIT_REF_INVALID) { + if ((error = update_target(tx->db, node)) < 0) + return error; + } + } + + return 0; +} + +void git_transaction_free(git_transaction *tx) +{ + transaction_node *node; + git_pool pool; + git_strmap_iter pos; + + assert(tx); + + /* start by unlocking the ones we've left hanging, if any */ + for (pos = kh_begin(tx->locks); pos < kh_end(tx->locks); pos++) { + if (!git_strmap_has_data(tx->locks, pos)) + continue; + + node = git_strmap_value_at(tx->locks, pos); + if (node->committed) + continue; + + git_refdb_unlock(tx->db, node->payload, false, false, NULL, NULL, NULL); + } + + git_refdb_free(tx->db); + git_strmap_free(tx->locks); + + /* tx is inside the pool, so we need to extract the data */ + memcpy(&pool, &tx->pool, sizeof(git_pool)); + git_pool_clear(&pool); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transport.c b/deps/libgit2-sys-0.2.17/libgit2/src/transport.c new file mode 100644 index 000000000..fc9c692b8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transport.c @@ -0,0 +1,220 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "git2/types.h" +#include "git2/remote.h" +#include "git2/net.h" +#include "git2/transport.h" +#include "git2/sys/transport.h" +#include "path.h" + +typedef struct transport_definition { + char *prefix; + git_transport_cb fn; + void *param; +} transport_definition; + +static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1, NULL }; +static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0, NULL }; +#ifdef GIT_SSH +static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL }; +#endif + +static transport_definition local_transport_definition = { "file://", git_transport_local, NULL }; + +static transport_definition transports[] = { + { "git://", git_transport_smart, &git_subtransport_definition }, + { "http://", git_transport_smart, &http_subtransport_definition }, +#if defined(GIT_SSL) || defined(GIT_WINHTTP) + { "https://", git_transport_smart, &http_subtransport_definition }, +#endif + { "file://", git_transport_local, NULL }, +#ifdef GIT_SSH + { "ssh://", git_transport_smart, &ssh_subtransport_definition }, +#endif + { NULL, 0, 0 } +}; + +static git_vector custom_transports = GIT_VECTOR_INIT; + +#define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0])) - 1 + +static transport_definition * transport_find_by_url(const char *url) +{ + size_t i = 0; + transport_definition *d; + + /* Find a user transport who wants to deal with this URI */ + git_vector_foreach(&custom_transports, i, d) { + if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { + return d; + } + } + + /* Find a system transport for this URI */ + for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) { + d = &transports[i]; + + if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { + return d; + } + } + + return NULL; +} + +static int transport_find_fn( + git_transport_cb *out, + const char *url, + void **param) +{ + transport_definition *definition = transport_find_by_url(url); + +#ifdef GIT_WIN32 + /* On Windows, it might not be possible to discern between absolute local + * and ssh paths - first check if this is a valid local path that points + * to a directory and if so assume local path, else assume SSH */ + + /* Check to see if the path points to a file on the local file system */ + if (!definition && git_path_exists(url) && git_path_isdir(url)) + definition = &local_transport_definition; +#endif + + /* For other systems, perform the SSH check first, to avoid going to the + * filesystem if it is not necessary */ + + /* It could be a SSH remote path. Check to see if there's a : + * SSH is an unsupported transport mechanism in this version of libgit2 */ + if (!definition && strrchr(url, ':')) { + // re-search transports again with ssh:// as url so that we can find a third party ssh transport + definition = transport_find_by_url("ssh://"); + } + +#ifndef GIT_WIN32 + /* Check to see if the path points to a file on the local file system */ + if (!definition && git_path_exists(url) && git_path_isdir(url)) + definition = &local_transport_definition; +#endif + + if (!definition) + return GIT_ENOTFOUND; + + *out = definition->fn; + *param = definition->param; + + return 0; +} + +/************** + * Public API * + **************/ + +int git_transport_new(git_transport **out, git_remote *owner, const char *url) +{ + git_transport_cb fn; + git_transport *transport; + void *param; + int error; + + if ((error = transport_find_fn(&fn, url, ¶m)) == GIT_ENOTFOUND) { + giterr_set(GITERR_NET, "Unsupported URL protocol"); + return -1; + } else if (error < 0) + return error; + + if ((error = fn(&transport, owner, param)) < 0) + return error; + + GITERR_CHECK_VERSION(transport, GIT_TRANSPORT_VERSION, "git_transport"); + + *out = transport; + + return 0; +} + +int git_transport_register( + const char *scheme, + git_transport_cb cb, + void *param) +{ + git_buf prefix = GIT_BUF_INIT; + transport_definition *d, *definition = NULL; + size_t i; + int error = 0; + + assert(scheme); + assert(cb); + + if ((error = git_buf_printf(&prefix, "%s://", scheme)) < 0) + goto on_error; + + git_vector_foreach(&custom_transports, i, d) { + if (strcasecmp(d->prefix, prefix.ptr) == 0) { + error = GIT_EEXISTS; + goto on_error; + } + } + + definition = git__calloc(1, sizeof(transport_definition)); + GITERR_CHECK_ALLOC(definition); + + definition->prefix = git_buf_detach(&prefix); + definition->fn = cb; + definition->param = param; + + if (git_vector_insert(&custom_transports, definition) < 0) + goto on_error; + + return 0; + +on_error: + git_buf_free(&prefix); + git__free(definition); + return error; +} + +int git_transport_unregister(const char *scheme) +{ + git_buf prefix = GIT_BUF_INIT; + transport_definition *d; + size_t i; + int error = 0; + + assert(scheme); + + if ((error = git_buf_printf(&prefix, "%s://", scheme)) < 0) + goto done; + + git_vector_foreach(&custom_transports, i, d) { + if (strcasecmp(d->prefix, prefix.ptr) == 0) { + if ((error = git_vector_remove(&custom_transports, i)) < 0) + goto done; + + git__free(d->prefix); + git__free(d); + + if (!custom_transports.length) + git_vector_free(&custom_transports); + + error = 0; + goto done; + } + } + + error = GIT_ENOTFOUND; + +done: + git_buf_free(&prefix); + return error; +} + +int git_transport_init(git_transport *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_transport, GIT_TRANSPORT_INIT); + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.c new file mode 100644 index 000000000..c1154db34 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2.h" +#include "buffer.h" +#include "auth.h" + +static int basic_next_token( + git_buf *out, git_http_auth_context *ctx, git_cred *c) +{ + git_cred_userpass_plaintext *cred; + git_buf raw = GIT_BUF_INIT; + int error = -1; + + GIT_UNUSED(ctx); + + if (c->credtype != GIT_CREDTYPE_USERPASS_PLAINTEXT) { + giterr_set(GITERR_INVALID, "invalid credential type for basic auth"); + goto on_error; + } + + cred = (git_cred_userpass_plaintext *)c; + + git_buf_printf(&raw, "%s:%s", cred->username, cred->password); + + if (git_buf_oom(&raw) || + git_buf_puts(out, "Authorization: Basic ") < 0 || + git_buf_encode_base64(out, git_buf_cstr(&raw), raw.size) < 0 || + git_buf_puts(out, "\r\n") < 0) + goto on_error; + + error = 0; + +on_error: + if (raw.size) + git__memzero(raw.ptr, raw.size); + + git_buf_free(&raw); + return error; +} + +static git_http_auth_context basic_context = { + GIT_AUTHTYPE_BASIC, + GIT_CREDTYPE_USERPASS_PLAINTEXT, + NULL, + basic_next_token, + NULL +}; + +int git_http_auth_basic( + git_http_auth_context **out, const gitno_connection_data *connection_data) +{ + GIT_UNUSED(connection_data); + + *out = &basic_context; + return 0; +} + +int git_http_auth_dummy( + git_http_auth_context **out, const gitno_connection_data *connection_data) +{ + GIT_UNUSED(connection_data); + + *out = NULL; + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.h b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.h new file mode 100644 index 000000000..52138cf8f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_http_auth_h__ +#define INCLUDE_http_auth_h__ + +#include "git2.h" +#include "netops.h" + +typedef enum { + GIT_AUTHTYPE_BASIC = 1, + GIT_AUTHTYPE_NEGOTIATE = 2, +} git_http_authtype_t; + +typedef struct git_http_auth_context git_http_auth_context; + +struct git_http_auth_context { + /** Type of scheme */ + git_http_authtype_t type; + + /** Supported credentials */ + git_credtype_t credtypes; + + /** Sets the challenge on the authentication context */ + int (*set_challenge)(git_http_auth_context *ctx, const char *challenge); + + /** Gets the next authentication token from the context */ + int (*next_token)(git_buf *out, git_http_auth_context *ctx, git_cred *cred); + + /** Frees the authentication context */ + void (*free)(git_http_auth_context *ctx); +}; + +typedef struct { + /** Type of scheme */ + git_http_authtype_t type; + + /** Name of the scheme (as used in the Authorization header) */ + const char *name; + + /** Credential types this scheme supports */ + git_credtype_t credtypes; + + /** Function to initialize an authentication context */ + int (*init_context)( + git_http_auth_context **out, + const gitno_connection_data *connection_data); +} git_http_auth_scheme; + +int git_http_auth_dummy( + git_http_auth_context **out, + const gitno_connection_data *connection_data); + +int git_http_auth_basic( + git_http_auth_context **out, + const gitno_connection_data *connection_data); + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.c new file mode 100644 index 000000000..8b99fc735 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.c @@ -0,0 +1,275 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifdef GIT_GSSAPI + +#include "git2.h" +#include "common.h" +#include "buffer.h" +#include "auth.h" + +#include +#include + +static gss_OID_desc negotiate_oid_spnego = + { 6, (void *) "\x2b\x06\x01\x05\x05\x02" }; +static gss_OID_desc negotiate_oid_krb5 = + { 9, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" }; + +static gss_OID negotiate_oids[] = + { &negotiate_oid_spnego, &negotiate_oid_krb5, NULL }; + +typedef struct { + git_http_auth_context parent; + unsigned configured : 1, + complete : 1; + git_buf target; + char *challenge; + gss_ctx_id_t gss_context; + gss_OID oid; +} http_auth_negotiate_context; + +static void negotiate_err_set( + OM_uint32 status_major, + OM_uint32 status_minor, + const char *message) +{ + gss_buffer_desc buffer = GSS_C_EMPTY_BUFFER; + OM_uint32 status_display, context = 0; + + if (gss_display_status(&status_display, status_major, GSS_C_GSS_CODE, + GSS_C_NO_OID, &context, &buffer) == GSS_S_COMPLETE) { + giterr_set(GITERR_NET, "%s: %.*s (%d.%d)", + message, (int)buffer.length, (const char *)buffer.value, + status_major, status_minor); + gss_release_buffer(&status_minor, &buffer); + } else { + giterr_set(GITERR_NET, "%s: unknown negotiate error (%d.%d)", + message, status_major, status_minor); + } +} + +static int negotiate_set_challenge( + git_http_auth_context *c, + const char *challenge) +{ + http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c; + + assert(ctx && ctx->configured && challenge); + + git__free(ctx->challenge); + + ctx->challenge = git__strdup(challenge); + GITERR_CHECK_ALLOC(ctx->challenge); + + return 0; +} + +static int negotiate_next_token( + git_buf *buf, + git_http_auth_context *c, + git_cred *cred) +{ + http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c; + OM_uint32 status_major, status_minor; + gss_buffer_desc target_buffer = GSS_C_EMPTY_BUFFER, + input_token = GSS_C_EMPTY_BUFFER, + output_token = GSS_C_EMPTY_BUFFER; + gss_buffer_t input_token_ptr = GSS_C_NO_BUFFER; + git_buf input_buf = GIT_BUF_INIT; + gss_name_t server = NULL; + gss_OID mech; + size_t challenge_len; + int error = 0; + + assert(buf && ctx && ctx->configured && cred && cred->credtype == GIT_CREDTYPE_DEFAULT); + + if (ctx->complete) + return 0; + + target_buffer.value = (void *)ctx->target.ptr; + target_buffer.length = ctx->target.size; + + status_major = gss_import_name(&status_minor, &target_buffer, + GSS_C_NT_HOSTBASED_SERVICE, &server); + + if (GSS_ERROR(status_major)) { + negotiate_err_set(status_major, status_minor, + "Could not parse principal"); + error = -1; + goto done; + } + + challenge_len = ctx->challenge ? strlen(ctx->challenge) : 0; + + if (challenge_len < 9) { + giterr_set(GITERR_NET, "No negotiate challenge sent from server"); + error = -1; + goto done; + } else if (challenge_len > 9) { + if (git_buf_decode_base64(&input_buf, + ctx->challenge + 10, challenge_len - 10) < 0) { + giterr_set(GITERR_NET, "Invalid negotiate challenge from server"); + error = -1; + goto done; + } + + input_token.value = input_buf.ptr; + input_token.length = input_buf.size; + input_token_ptr = &input_token; + } else if (ctx->gss_context != GSS_C_NO_CONTEXT) { + giterr_set(GITERR_NET, "Could not restart authentication"); + error = -1; + goto done; + } + + mech = &negotiate_oid_spnego; + + if (GSS_ERROR(status_major = gss_init_sec_context( + &status_minor, + GSS_C_NO_CREDENTIAL, + &ctx->gss_context, + server, + mech, + GSS_C_DELEG_FLAG | GSS_C_MUTUAL_FLAG, + GSS_C_INDEFINITE, + GSS_C_NO_CHANNEL_BINDINGS, + input_token_ptr, + NULL, + &output_token, + NULL, + NULL))) { + negotiate_err_set(status_major, status_minor, "Negotiate failure"); + error = -1; + goto done; + } + + /* This message merely told us auth was complete; we do not respond. */ + if (status_major == GSS_S_COMPLETE) { + ctx->complete = 1; + goto done; + } + + git_buf_puts(buf, "Authorization: Negotiate "); + git_buf_encode_base64(buf, output_token.value, output_token.length); + git_buf_puts(buf, "\r\n"); + + if (git_buf_oom(buf)) + error = -1; + +done: + gss_release_name(&status_minor, &server); + gss_release_buffer(&status_minor, (gss_buffer_t) &output_token); + git_buf_free(&input_buf); + return error; +} + +static void negotiate_context_free(git_http_auth_context *c) +{ + http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c; + OM_uint32 status_minor; + + if (ctx->gss_context != GSS_C_NO_CONTEXT) { + gss_delete_sec_context( + &status_minor, &ctx->gss_context, GSS_C_NO_BUFFER); + ctx->gss_context = GSS_C_NO_CONTEXT; + } + + git_buf_free(&ctx->target); + + git__free(ctx->challenge); + + ctx->configured = 0; + ctx->complete = 0; + ctx->oid = NULL; + + git__free(ctx); +} + +static int negotiate_init_context( + http_auth_negotiate_context *ctx, + const gitno_connection_data *connection_data) +{ + OM_uint32 status_major, status_minor; + gss_OID item, *oid; + gss_OID_set mechanism_list; + size_t i; + + /* Query supported mechanisms looking for SPNEGO) */ + if (GSS_ERROR(status_major = + gss_indicate_mechs(&status_minor, &mechanism_list))) { + negotiate_err_set(status_major, status_minor, + "could not query mechanisms"); + return -1; + } + + if (mechanism_list) { + for (oid = negotiate_oids; *oid; oid++) { + for (i = 0; i < mechanism_list->count; i++) { + item = &mechanism_list->elements[i]; + + if (item->length == (*oid)->length && + memcmp(item->elements, (*oid)->elements, item->length) == 0) { + ctx->oid = *oid; + break; + } + + } + + if (ctx->oid) + break; + } + } + + gss_release_oid_set(&status_minor, &mechanism_list); + + if (!ctx->oid) { + giterr_set(GITERR_NET, "Negotiate authentication is not supported"); + return -1; + } + + git_buf_puts(&ctx->target, "HTTP@"); + git_buf_puts(&ctx->target, connection_data->host); + + if (git_buf_oom(&ctx->target)) + return -1; + + ctx->gss_context = GSS_C_NO_CONTEXT; + ctx->configured = 1; + + return 0; +} + +int git_http_auth_negotiate( + git_http_auth_context **out, + const gitno_connection_data *connection_data) +{ + http_auth_negotiate_context *ctx; + + *out = NULL; + + ctx = git__calloc(1, sizeof(http_auth_negotiate_context)); + GITERR_CHECK_ALLOC(ctx); + + if (negotiate_init_context(ctx, connection_data) < 0) { + git__free(ctx); + return -1; + } + + ctx->parent.type = GIT_AUTHTYPE_NEGOTIATE; + ctx->parent.credtypes = GIT_CREDTYPE_DEFAULT; + ctx->parent.set_challenge = negotiate_set_challenge; + ctx->parent.next_token = negotiate_next_token; + ctx->parent.free = negotiate_context_free; + + *out = (git_http_auth_context *)ctx; + + return 0; +} + +#endif /* GIT_GSSAPI */ + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.h b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.h new file mode 100644 index 000000000..d7270b7ab --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/auth_negotiate.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_auth_negotiate_h__ +#define INCLUDE_auth_negotiate_h__ + +#include "git2.h" +#include "auth.h" + +#ifdef GIT_GSSAPI + +extern int git_http_auth_negotiate( + git_http_auth_context **out, + const gitno_connection_data *connection_data); + +#else + +#define git_http_auth_negotiate git_http_auth_dummy + +#endif /* GIT_GSSAPI */ + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.c new file mode 100644 index 000000000..8163d3115 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.c @@ -0,0 +1,326 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2.h" +#include "smart.h" +#include "git2/cred_helpers.h" + +int git_cred_has_username(git_cred *cred) +{ + if (cred->credtype == GIT_CREDTYPE_DEFAULT) + return 0; + + return 1; +} + +const char *git_cred__username(git_cred *cred) +{ + switch (cred->credtype) { + case GIT_CREDTYPE_USERNAME: + { + git_cred_username *c = (git_cred_username *) cred; + return c->username; + } + case GIT_CREDTYPE_USERPASS_PLAINTEXT: + { + git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *) cred; + return c->username; + } + case GIT_CREDTYPE_SSH_KEY: + { + git_cred_ssh_key *c = (git_cred_ssh_key *) cred; + return c->username; + } + case GIT_CREDTYPE_SSH_CUSTOM: + { + git_cred_ssh_custom *c = (git_cred_ssh_custom *) cred; + return c->username; + } + case GIT_CREDTYPE_SSH_INTERACTIVE: + { + git_cred_ssh_interactive *c = (git_cred_ssh_interactive *) cred; + return c->username; + } + + default: + return NULL; + } +} + +static void plaintext_free(struct git_cred *cred) +{ + git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; + + git__free(c->username); + + /* Zero the memory which previously held the password */ + if (c->password) { + size_t pass_len = strlen(c->password); + git__memzero(c->password, pass_len); + git__free(c->password); + } + + git__free(c); +} + +int git_cred_userpass_plaintext_new( + git_cred **cred, + const char *username, + const char *password) +{ + git_cred_userpass_plaintext *c; + + assert(cred && username && password); + + c = git__malloc(sizeof(git_cred_userpass_plaintext)); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_USERPASS_PLAINTEXT; + c->parent.free = plaintext_free; + c->username = git__strdup(username); + + if (!c->username) { + git__free(c); + return -1; + } + + c->password = git__strdup(password); + + if (!c->password) { + git__free(c->username); + git__free(c); + return -1; + } + + *cred = &c->parent; + return 0; +} + +static void ssh_key_free(struct git_cred *cred) +{ + git_cred_ssh_key *c = + (git_cred_ssh_key *)cred; + + git__free(c->username); + + if (c->privatekey) { + /* Zero the memory which previously held the private key */ + size_t key_len = strlen(c->privatekey); + git__memzero(c->privatekey, key_len); + git__free(c->privatekey); + } + + if (c->passphrase) { + /* Zero the memory which previously held the passphrase */ + size_t pass_len = strlen(c->passphrase); + git__memzero(c->passphrase, pass_len); + git__free(c->passphrase); + } + + if (c->publickey) { + /* Zero the memory which previously held the public key */ + size_t key_len = strlen(c->publickey); + git__memzero(c->publickey, key_len); + git__free(c->publickey); + } + + git__free(c); +} + +static void ssh_interactive_free(struct git_cred *cred) +{ + git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred; + + git__free(c->username); + + git__free(c); +} + +static void ssh_custom_free(struct git_cred *cred) +{ + git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred; + + git__free(c->username); + + if (c->publickey) { + /* Zero the memory which previously held the publickey */ + size_t key_len = strlen(c->publickey); + git__memzero(c->publickey, key_len); + git__free(c->publickey); + } + + git__free(c); +} + +static void default_free(struct git_cred *cred) +{ + git_cred_default *c = (git_cred_default *)cred; + + git__free(c); +} + +static void username_free(struct git_cred *cred) +{ + git__free(cred); +} + +int git_cred_ssh_key_new( + git_cred **cred, + const char *username, + const char *publickey, + const char *privatekey, + const char *passphrase) +{ + git_cred_ssh_key *c; + + assert(username && cred && privatekey); + + c = git__calloc(1, sizeof(git_cred_ssh_key)); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_SSH_KEY; + c->parent.free = ssh_key_free; + + c->username = git__strdup(username); + GITERR_CHECK_ALLOC(c->username); + + c->privatekey = git__strdup(privatekey); + GITERR_CHECK_ALLOC(c->privatekey); + + if (publickey) { + c->publickey = git__strdup(publickey); + GITERR_CHECK_ALLOC(c->publickey); + } + + if (passphrase) { + c->passphrase = git__strdup(passphrase); + GITERR_CHECK_ALLOC(c->passphrase); + } + + *cred = &c->parent; + return 0; +} + +int git_cred_ssh_interactive_new( + git_cred **out, + const char *username, + git_cred_ssh_interactive_callback prompt_callback, + void *payload) +{ + git_cred_ssh_interactive *c; + + assert(out && username && prompt_callback); + + c = git__calloc(1, sizeof(git_cred_ssh_interactive)); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_SSH_INTERACTIVE; + c->parent.free = ssh_interactive_free; + + c->username = git__strdup(username); + GITERR_CHECK_ALLOC(c->username); + + c->prompt_callback = prompt_callback; + c->payload = payload; + + *out = &c->parent; + return 0; +} + +int git_cred_ssh_key_from_agent(git_cred **cred, const char *username) { + git_cred_ssh_key *c; + + assert(username && cred); + + c = git__calloc(1, sizeof(git_cred_ssh_key)); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_SSH_KEY; + c->parent.free = ssh_key_free; + + c->username = git__strdup(username); + GITERR_CHECK_ALLOC(c->username); + + c->privatekey = NULL; + + *cred = &c->parent; + return 0; +} + +int git_cred_ssh_custom_new( + git_cred **cred, + const char *username, + const char *publickey, + size_t publickey_len, + git_cred_sign_callback sign_callback, + void *payload) +{ + git_cred_ssh_custom *c; + + assert(username && cred); + + c = git__calloc(1, sizeof(git_cred_ssh_custom)); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_SSH_CUSTOM; + c->parent.free = ssh_custom_free; + + c->username = git__strdup(username); + GITERR_CHECK_ALLOC(c->username); + + if (publickey_len > 0) { + c->publickey = git__malloc(publickey_len); + GITERR_CHECK_ALLOC(c->publickey); + + memcpy(c->publickey, publickey, publickey_len); + } + + c->publickey_len = publickey_len; + c->sign_callback = sign_callback; + c->payload = payload; + + *cred = &c->parent; + return 0; +} + +int git_cred_default_new(git_cred **cred) +{ + git_cred_default *c; + + assert(cred); + + c = git__calloc(1, sizeof(git_cred_default)); + GITERR_CHECK_ALLOC(c); + + c->credtype = GIT_CREDTYPE_DEFAULT; + c->free = default_free; + + *cred = c; + return 0; +} + +int git_cred_username_new(git_cred **cred, const char *username) +{ + git_cred_username *c; + size_t len, allocsize; + + assert(cred); + + len = strlen(username); + + GITERR_CHECK_ALLOC_ADD(&allocsize, sizeof(git_cred_username), len); + GITERR_CHECK_ALLOC_ADD(&allocsize, allocsize, 1); + c = git__malloc(allocsize); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_USERNAME; + c->parent.free = username_free; + memcpy(c->username, username, len + 1); + + *cred = (git_cred *) c; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.h b/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.h new file mode 100644 index 000000000..2de8deee8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_cred_h__ +#define INCLUDE_git_cred_h__ + +#include "git2/transport.h" + +const char *git_cred__username(git_cred *cred); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred_helpers.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred_helpers.c new file mode 100644 index 000000000..5cc9b0869 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/cred_helpers.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "git2/cred_helpers.h" + +int git_cred_userpass( + git_cred **cred, + const char *url, + const char *user_from_url, + unsigned int allowed_types, + void *payload) +{ + git_cred_userpass_payload *userpass = (git_cred_userpass_payload*)payload; + const char *effective_username = NULL; + + GIT_UNUSED(url); + + if (!userpass || !userpass->password) return -1; + + /* Username resolution: a username can be passed with the URL, the + * credentials payload, or both. Here's what we do. Note that if we get + * this far, we know that any password the url may contain has already + * failed at least once, so we ignore it. + * + * | Payload | URL | Used | + * +-------------+----------+-----------+ + * | yes | no | payload | + * | yes | yes | payload | + * | no | yes | url | + * | no | no | FAIL | + */ + if (userpass->username) + effective_username = userpass->username; + else if (user_from_url) + effective_username = user_from_url; + else + return -1; + + if (GIT_CREDTYPE_USERNAME & allowed_types) + return git_cred_username_new(cred, effective_username); + + if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 || + git_cred_userpass_plaintext_new(cred, effective_username, userpass->password) < 0) + return -1; + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/git.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/git.c new file mode 100644 index 000000000..7e0a47414 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/git.c @@ -0,0 +1,363 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "git2.h" +#include "buffer.h" +#include "netops.h" +#include "git2/sys/transport.h" +#include "stream.h" +#include "socket_stream.h" + +#define OWNING_SUBTRANSPORT(s) ((git_subtransport *)(s)->parent.subtransport) + +static const char prefix_git[] = "git://"; +static const char cmd_uploadpack[] = "git-upload-pack"; +static const char cmd_receivepack[] = "git-receive-pack"; + +typedef struct { + git_smart_subtransport_stream parent; + git_stream *io; + const char *cmd; + char *url; + unsigned sent_command : 1; +} git_proto_stream; + +typedef struct { + git_smart_subtransport parent; + git_transport *owner; + git_proto_stream *current_stream; +} git_subtransport; + +/* + * Create a git protocol request. + * + * For example: 0035git-upload-pack /libgit2/libgit2\0host=github.com\0 + */ +static int gen_proto(git_buf *request, const char *cmd, const char *url) +{ + char *delim, *repo; + char host[] = "host="; + size_t len; + + delim = strchr(url, '/'); + if (delim == NULL) { + giterr_set(GITERR_NET, "Malformed URL"); + return -1; + } + + repo = delim; + + delim = strchr(url, ':'); + if (delim == NULL) + delim = strchr(url, '/'); + + len = 4 + strlen(cmd) + 1 + strlen(repo) + 1 + strlen(host) + (delim - url) + 1; + + git_buf_grow(request, len); + git_buf_printf(request, "%04x%s %s%c%s", + (unsigned int)(len & 0x0FFFF), cmd, repo, 0, host); + git_buf_put(request, url, delim - url); + git_buf_putc(request, '\0'); + + if (git_buf_oom(request)) + return -1; + + return 0; +} + +static int send_command(git_proto_stream *s) +{ + int error; + git_buf request = GIT_BUF_INIT; + + error = gen_proto(&request, s->cmd, s->url); + if (error < 0) + goto cleanup; + + error = git_stream_write(s->io, request.ptr, request.size, 0); + if (error >= 0) + s->sent_command = 1; + +cleanup: + git_buf_free(&request); + return error; +} + +static int git_proto_stream_read( + git_smart_subtransport_stream *stream, + char *buffer, + size_t buf_size, + size_t *bytes_read) +{ + int error; + git_proto_stream *s = (git_proto_stream *)stream; + gitno_buffer buf; + + *bytes_read = 0; + + if (!s->sent_command && (error = send_command(s)) < 0) + return error; + + gitno_buffer_setup_fromstream(s->io, &buf, buffer, buf_size); + + if ((error = gitno_recv(&buf)) < 0) + return error; + + *bytes_read = buf.offset; + + return 0; +} + +static int git_proto_stream_write( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + int error; + git_proto_stream *s = (git_proto_stream *)stream; + + if (!s->sent_command && (error = send_command(s)) < 0) + return error; + + return git_stream_write(s->io, buffer, len, 0); +} + +static void git_proto_stream_free(git_smart_subtransport_stream *stream) +{ + git_proto_stream *s = (git_proto_stream *)stream; + git_subtransport *t = OWNING_SUBTRANSPORT(s); + int ret; + + GIT_UNUSED(ret); + + t->current_stream = NULL; + + git_stream_close(s->io); + git_stream_free(s->io); + git__free(s->url); + git__free(s); +} + +static int git_proto_stream_alloc( + git_subtransport *t, + const char *url, + const char *cmd, + const char *host, + const char *port, + git_smart_subtransport_stream **stream) +{ + git_proto_stream *s; + + if (!stream) + return -1; + + s = git__calloc(1, sizeof(git_proto_stream)); + GITERR_CHECK_ALLOC(s); + + s->parent.subtransport = &t->parent; + s->parent.read = git_proto_stream_read; + s->parent.write = git_proto_stream_write; + s->parent.free = git_proto_stream_free; + + s->cmd = cmd; + s->url = git__strdup(url); + + if (!s->url) { + git__free(s); + return -1; + } + + if ((git_socket_stream_new(&s->io, host, port)) < 0) + return -1; + + GITERR_CHECK_VERSION(s->io, GIT_STREAM_VERSION, "git_stream"); + + *stream = &s->parent; + return 0; +} + +static int _git_uploadpack_ls( + git_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL; + const char *stream_url = url; + git_proto_stream *s; + int error; + + *stream = NULL; + + if (!git__prefixcmp(url, prefix_git)) + stream_url += strlen(prefix_git); + + if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT)) < 0) + return error; + + error = git_proto_stream_alloc(t, stream_url, cmd_uploadpack, host, port, stream); + + git__free(host); + git__free(port); + git__free(path); + git__free(user); + git__free(pass); + + + if (error < 0) { + git_proto_stream_free(*stream); + return error; + } + + s = (git_proto_stream *) *stream; + if ((error = git_stream_connect(s->io)) < 0) { + git_proto_stream_free(*stream); + return error; + } + + t->current_stream = s; + + return 0; +} + +static int _git_uploadpack( + git_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + GIT_UNUSED(url); + + if (t->current_stream) { + *stream = &t->current_stream->parent; + return 0; + } + + giterr_set(GITERR_NET, "Must call UPLOADPACK_LS before UPLOADPACK"); + return -1; +} + +static int _git_receivepack_ls( + git_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL; + const char *stream_url = url; + git_proto_stream *s; + int error; + + *stream = NULL; + if (!git__prefixcmp(url, prefix_git)) + stream_url += strlen(prefix_git); + + if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT)) < 0) + return error; + + error = git_proto_stream_alloc(t, stream_url, cmd_receivepack, host, port, stream); + + git__free(host); + git__free(port); + git__free(path); + git__free(user); + git__free(pass); + + if (error < 0) { + git_proto_stream_free(*stream); + return error; + } + + s = (git_proto_stream *) *stream; + + if ((error = git_stream_connect(s->io)) < 0) + return error; + + t->current_stream = s; + + return 0; +} + +static int _git_receivepack( + git_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + GIT_UNUSED(url); + + if (t->current_stream) { + *stream = &t->current_stream->parent; + return 0; + } + + giterr_set(GITERR_NET, "Must call RECEIVEPACK_LS before RECEIVEPACK"); + return -1; +} + +static int _git_action( + git_smart_subtransport_stream **stream, + git_smart_subtransport *subtransport, + const char *url, + git_smart_service_t action) +{ + git_subtransport *t = (git_subtransport *) subtransport; + + switch (action) { + case GIT_SERVICE_UPLOADPACK_LS: + return _git_uploadpack_ls(t, url, stream); + + case GIT_SERVICE_UPLOADPACK: + return _git_uploadpack(t, url, stream); + + case GIT_SERVICE_RECEIVEPACK_LS: + return _git_receivepack_ls(t, url, stream); + + case GIT_SERVICE_RECEIVEPACK: + return _git_receivepack(t, url, stream); + } + + *stream = NULL; + return -1; +} + +static int _git_close(git_smart_subtransport *subtransport) +{ + git_subtransport *t = (git_subtransport *) subtransport; + + assert(!t->current_stream); + + GIT_UNUSED(t); + + return 0; +} + +static void _git_free(git_smart_subtransport *subtransport) +{ + git_subtransport *t = (git_subtransport *) subtransport; + + assert(!t->current_stream); + + git__free(t); +} + +int git_smart_subtransport_git(git_smart_subtransport **out, git_transport *owner, void *param) +{ + git_subtransport *t; + + GIT_UNUSED(param); + + if (!out) + return -1; + + t = git__calloc(1, sizeof(git_subtransport)); + GITERR_CHECK_ALLOC(t); + + t->owner = owner; + t->parent.action = _git_action; + t->parent.close = _git_close; + t->parent.free = _git_free; + + *out = (git_smart_subtransport *) t; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/http.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/http.c new file mode 100644 index 000000000..6b100df7a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/http.c @@ -0,0 +1,1038 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef GIT_WINHTTP + +#include "git2.h" +#include "http_parser.h" +#include "buffer.h" +#include "netops.h" +#include "smart.h" +#include "auth.h" +#include "auth_negotiate.h" +#include "openssl_stream.h" +#include "socket_stream.h" + +git_http_auth_scheme auth_schemes[] = { + { GIT_AUTHTYPE_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate }, + { GIT_AUTHTYPE_BASIC, "Basic", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_basic }, +}; + +static const char *upload_pack_service = "upload-pack"; +static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack"; +static const char *upload_pack_service_url = "/git-upload-pack"; +static const char *receive_pack_service = "receive-pack"; +static const char *receive_pack_ls_service_url = "/info/refs?service=git-receive-pack"; +static const char *receive_pack_service_url = "/git-receive-pack"; +static const char *get_verb = "GET"; +static const char *post_verb = "POST"; + +#define OWNING_SUBTRANSPORT(s) ((http_subtransport *)(s)->parent.subtransport) + +#define PARSE_ERROR_GENERIC -1 +#define PARSE_ERROR_REPLAY -2 + +#define CHUNK_SIZE 4096 + +enum last_cb { + NONE, + FIELD, + VALUE +}; + +typedef struct { + git_smart_subtransport_stream parent; + const char *service; + const char *service_url; + char *redirect_url; + const char *verb; + char *chunk_buffer; + unsigned chunk_buffer_len; + unsigned sent_request : 1, + received_response : 1, + chunked : 1, + redirect_count : 3; +} http_stream; + +typedef struct { + git_smart_subtransport parent; + transport_smart *owner; + git_stream *io; + gitno_connection_data connection_data; + bool connected; + + /* Parser structures */ + http_parser parser; + http_parser_settings settings; + gitno_buffer parse_buffer; + git_buf parse_header_name; + git_buf parse_header_value; + char parse_buffer_data[2048]; + char *content_type; + char *location; + git_vector www_authenticate; + enum last_cb last_cb; + int parse_error; + unsigned parse_finished : 1; + + /* Authentication */ + git_cred *cred; + git_cred *url_cred; + git_vector auth_contexts; +} http_subtransport; + +typedef struct { + http_stream *s; + http_subtransport *t; + + /* Target buffer details from read() */ + char *buffer; + size_t buf_size; + size_t *bytes_read; +} parser_context; + +static bool credtype_match(git_http_auth_scheme *scheme, void *data) +{ + unsigned int credtype = *(unsigned int *)data; + + return !!(scheme->credtypes & credtype); +} + +static bool challenge_match(git_http_auth_scheme *scheme, void *data) +{ + const char *scheme_name = scheme->name; + const char *challenge = (const char *)data; + size_t scheme_len; + + scheme_len = strlen(scheme_name); + return (strncmp(challenge, scheme_name, scheme_len) == 0 && + (challenge[scheme_len] == '\0' || challenge[scheme_len] == ' ')); +} + +static int auth_context_match( + git_http_auth_context **out, + http_subtransport *t, + bool (*scheme_match)(git_http_auth_scheme *scheme, void *data), + void *data) +{ + git_http_auth_scheme *scheme = NULL; + git_http_auth_context *context = NULL, *c; + size_t i; + + *out = NULL; + + for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) { + if (scheme_match(&auth_schemes[i], data)) { + scheme = &auth_schemes[i]; + break; + } + } + + if (!scheme) + return 0; + + /* See if authentication has already started for this scheme */ + git_vector_foreach(&t->auth_contexts, i, c) { + if (c->type == scheme->type) { + context = c; + break; + } + } + + if (!context) { + if (scheme->init_context(&context, &t->connection_data) < 0) + return -1; + else if (!context) + return 0; + else if (git_vector_insert(&t->auth_contexts, context) < 0) + return -1; + } + + *out = context; + + return 0; +} + +static int apply_credentials(git_buf *buf, http_subtransport *t) +{ + git_cred *cred = t->cred; + git_http_auth_context *context; + + /* Apply the credentials given to us in the URL */ + if (!cred && t->connection_data.user && t->connection_data.pass) { + if (!t->url_cred && + git_cred_userpass_plaintext_new(&t->url_cred, + t->connection_data.user, t->connection_data.pass) < 0) + return -1; + + cred = t->url_cred; + } + + if (!cred) + return 0; + + /* Get or create a context for the best scheme for this cred type */ + if (auth_context_match(&context, t, credtype_match, &cred->credtype) < 0) + return -1; + + return context->next_token(buf, context, cred); +} + +static int gen_request( + git_buf *buf, + http_stream *s, + size_t content_length) +{ + http_subtransport *t = OWNING_SUBTRANSPORT(s); + const char *path = t->connection_data.path ? t->connection_data.path : "/"; + + git_buf_printf(buf, "%s %s%s HTTP/1.1\r\n", s->verb, path, s->service_url); + + git_buf_puts(buf, "User-Agent: git/1.0 (libgit2 " LIBGIT2_VERSION ")\r\n"); + git_buf_printf(buf, "Host: %s\r\n", t->connection_data.host); + + if (s->chunked || content_length > 0) { + git_buf_printf(buf, "Accept: application/x-git-%s-result\r\n", s->service); + git_buf_printf(buf, "Content-Type: application/x-git-%s-request\r\n", s->service); + + if (s->chunked) + git_buf_puts(buf, "Transfer-Encoding: chunked\r\n"); + else + git_buf_printf(buf, "Content-Length: %"PRIuZ "\r\n", content_length); + } else + git_buf_puts(buf, "Accept: */*\r\n"); + + /* Apply credentials to the request */ + if (apply_credentials(buf, t) < 0) + return -1; + + git_buf_puts(buf, "\r\n"); + + if (git_buf_oom(buf)) + return -1; + + return 0; +} + +static int parse_authenticate_response( + git_vector *www_authenticate, + http_subtransport *t, + int *allowed_types) +{ + git_http_auth_context *context; + char *challenge; + size_t i; + + git_vector_foreach(www_authenticate, i, challenge) { + if (auth_context_match(&context, t, challenge_match, challenge) < 0) + return -1; + else if (!context) + continue; + + if (context->set_challenge && + context->set_challenge(context, challenge) < 0) + return -1; + + *allowed_types |= context->credtypes; + } + + return 0; +} + +static int on_header_ready(http_subtransport *t) +{ + git_buf *name = &t->parse_header_name; + git_buf *value = &t->parse_header_value; + + if (!strcasecmp("Content-Type", git_buf_cstr(name))) { + if (!t->content_type) { + t->content_type = git__strdup(git_buf_cstr(value)); + GITERR_CHECK_ALLOC(t->content_type); + } + } + else if (!strcmp("WWW-Authenticate", git_buf_cstr(name))) { + char *dup = git__strdup(git_buf_cstr(value)); + GITERR_CHECK_ALLOC(dup); + + git_vector_insert(&t->www_authenticate, dup); + } + else if (!strcasecmp("Location", git_buf_cstr(name))) { + if (!t->location) { + t->location = git__strdup(git_buf_cstr(value)); + GITERR_CHECK_ALLOC(t->location); + } + } + + return 0; +} + +static int on_header_field(http_parser *parser, const char *str, size_t len) +{ + parser_context *ctx = (parser_context *) parser->data; + http_subtransport *t = ctx->t; + + /* Both parse_header_name and parse_header_value are populated + * and ready for consumption */ + if (VALUE == t->last_cb) + if (on_header_ready(t) < 0) + return t->parse_error = PARSE_ERROR_GENERIC; + + if (NONE == t->last_cb || VALUE == t->last_cb) + git_buf_clear(&t->parse_header_name); + + if (git_buf_put(&t->parse_header_name, str, len) < 0) + return t->parse_error = PARSE_ERROR_GENERIC; + + t->last_cb = FIELD; + return 0; +} + +static int on_header_value(http_parser *parser, const char *str, size_t len) +{ + parser_context *ctx = (parser_context *) parser->data; + http_subtransport *t = ctx->t; + + assert(NONE != t->last_cb); + + if (FIELD == t->last_cb) + git_buf_clear(&t->parse_header_value); + + if (git_buf_put(&t->parse_header_value, str, len) < 0) + return t->parse_error = PARSE_ERROR_GENERIC; + + t->last_cb = VALUE; + return 0; +} + +static int on_headers_complete(http_parser *parser) +{ + parser_context *ctx = (parser_context *) parser->data; + http_subtransport *t = ctx->t; + http_stream *s = ctx->s; + git_buf buf = GIT_BUF_INIT; + int error = 0, no_callback = 0, allowed_auth_types = 0; + + /* Both parse_header_name and parse_header_value are populated + * and ready for consumption. */ + if (VALUE == t->last_cb) + if (on_header_ready(t) < 0) + return t->parse_error = PARSE_ERROR_GENERIC; + + /* Capture authentication headers which may be a 401 (authentication + * is not complete) or a 200 (simply informing us that auth *is* + * complete.) + */ + if (parse_authenticate_response(&t->www_authenticate, t, + &allowed_auth_types) < 0) + return t->parse_error = PARSE_ERROR_GENERIC; + + /* Check for an authentication failure. */ + if (parser->status_code == 401 && get_verb == s->verb) { + if (!t->owner->cred_acquire_cb) { + no_callback = 1; + } else { + if (allowed_auth_types && + (!t->cred || 0 == (t->cred->credtype & allowed_auth_types))) { + + error = t->owner->cred_acquire_cb(&t->cred, + t->owner->url, + t->connection_data.user, + allowed_auth_types, + t->owner->cred_acquire_payload); + + if (error == GIT_PASSTHROUGH) { + no_callback = 1; + } else if (error < 0) { + return PARSE_ERROR_GENERIC; + } else { + assert(t->cred); + + if (!(t->cred->credtype & allowed_auth_types)) { + giterr_set(GITERR_NET, "credentials callback returned an invalid cred type"); + return t->parse_error = PARSE_ERROR_GENERIC; + } + + /* Successfully acquired a credential. */ + t->parse_error = PARSE_ERROR_REPLAY; + return 0; + } + } + } + + if (no_callback) { + giterr_set(GITERR_NET, "authentication required but no callback set"); + return t->parse_error = PARSE_ERROR_GENERIC; + } + } + + /* Check for a redirect. + * Right now we only permit a redirect to the same hostname. */ + if ((parser->status_code == 301 || + parser->status_code == 302 || + (parser->status_code == 303 && get_verb == s->verb) || + parser->status_code == 307) && + t->location) { + + if (s->redirect_count >= 7) { + giterr_set(GITERR_NET, "Too many redirects"); + return t->parse_error = PARSE_ERROR_GENERIC; + } + + if (gitno_connection_data_from_url(&t->connection_data, t->location, s->service_url) < 0) + return t->parse_error = PARSE_ERROR_GENERIC; + + /* Set the redirect URL on the stream. This is a transfer of + * ownership of the memory. */ + if (s->redirect_url) + git__free(s->redirect_url); + + s->redirect_url = t->location; + t->location = NULL; + + t->connected = 0; + s->redirect_count++; + + t->parse_error = PARSE_ERROR_REPLAY; + return 0; + } + + /* Check for a 200 HTTP status code. */ + if (parser->status_code != 200) { + giterr_set(GITERR_NET, + "Unexpected HTTP status code: %d", + parser->status_code); + return t->parse_error = PARSE_ERROR_GENERIC; + } + + /* The response must contain a Content-Type header. */ + if (!t->content_type) { + giterr_set(GITERR_NET, "No Content-Type header in response"); + return t->parse_error = PARSE_ERROR_GENERIC; + } + + /* The Content-Type header must match our expectation. */ + if (get_verb == s->verb) + git_buf_printf(&buf, + "application/x-git-%s-advertisement", + ctx->s->service); + else + git_buf_printf(&buf, + "application/x-git-%s-result", + ctx->s->service); + + if (git_buf_oom(&buf)) + return t->parse_error = PARSE_ERROR_GENERIC; + + if (strcmp(t->content_type, git_buf_cstr(&buf))) { + git_buf_free(&buf); + giterr_set(GITERR_NET, + "Invalid Content-Type: %s", + t->content_type); + return t->parse_error = PARSE_ERROR_GENERIC; + } + + git_buf_free(&buf); + + return 0; +} + +static int on_message_complete(http_parser *parser) +{ + parser_context *ctx = (parser_context *) parser->data; + http_subtransport *t = ctx->t; + + t->parse_finished = 1; + + return 0; +} + +static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len) +{ + parser_context *ctx = (parser_context *) parser->data; + http_subtransport *t = ctx->t; + + /* If our goal is to replay the request (either an auth failure or + * a redirect) then don't bother buffering since we're ignoring the + * content anyway. + */ + if (t->parse_error == PARSE_ERROR_REPLAY) + return 0; + + if (ctx->buf_size < len) { + giterr_set(GITERR_NET, "Can't fit data in the buffer"); + return t->parse_error = PARSE_ERROR_GENERIC; + } + + memcpy(ctx->buffer, str, len); + *(ctx->bytes_read) += len; + ctx->buffer += len; + ctx->buf_size -= len; + + return 0; +} + +static void clear_parser_state(http_subtransport *t) +{ + http_parser_init(&t->parser, HTTP_RESPONSE); + gitno_buffer_setup_fromstream(t->io, + &t->parse_buffer, + t->parse_buffer_data, + sizeof(t->parse_buffer_data)); + + t->last_cb = NONE; + t->parse_error = 0; + t->parse_finished = 0; + + git_buf_free(&t->parse_header_name); + git_buf_init(&t->parse_header_name, 0); + + git_buf_free(&t->parse_header_value); + git_buf_init(&t->parse_header_value, 0); + + git__free(t->content_type); + t->content_type = NULL; + + git__free(t->location); + t->location = NULL; + + git_vector_free_deep(&t->www_authenticate); +} + +static int write_chunk(git_stream *io, const char *buffer, size_t len) +{ + git_buf buf = GIT_BUF_INIT; + + /* Chunk header */ + git_buf_printf(&buf, "%X\r\n", (unsigned)len); + + if (git_buf_oom(&buf)) + return -1; + + if (git_stream_write(io, buf.ptr, buf.size, 0) < 0) { + git_buf_free(&buf); + return -1; + } + + git_buf_free(&buf); + + /* Chunk body */ + if (len > 0 && git_stream_write(io, buffer, len, 0) < 0) + return -1; + + /* Chunk footer */ + if (git_stream_write(io, "\r\n", 2, 0) < 0) + return -1; + + return 0; +} + +static int http_connect(http_subtransport *t) +{ + int error; + + if (t->connected && + http_should_keep_alive(&t->parser) && + t->parse_finished) + return 0; + + if (t->io) { + git_stream_close(t->io); + git_stream_free(t->io); + t->io = NULL; + } + + if (t->connection_data.use_ssl) { + error = git_openssl_stream_new(&t->io, t->connection_data.host, t->connection_data.port); + } else { + error = git_socket_stream_new(&t->io, t->connection_data.host, t->connection_data.port); + } + + if (error < 0) + return error; + + GITERR_CHECK_VERSION(t->io, GIT_STREAM_VERSION, "git_stream"); + + error = git_stream_connect(t->io); + +#ifdef GIT_SSL + if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL && + git_stream_is_encrypted(t->io)) { + git_cert *cert; + int is_valid; + + if ((error = git_stream_certificate(&cert, t->io)) < 0) + return error; + + giterr_clear(); + is_valid = error != GIT_ECERTIFICATE; + error = t->owner->certificate_check_cb(cert, is_valid, t->connection_data.host, t->owner->message_cb_payload); + + if (error < 0) { + if (!giterr_last()) + giterr_set(GITERR_NET, "user cancelled certificate check"); + + return error; + } + } +#endif + if (error < 0) + return error; + + t->connected = 1; + return 0; +} + +static int http_stream_read( + git_smart_subtransport_stream *stream, + char *buffer, + size_t buf_size, + size_t *bytes_read) +{ + http_stream *s = (http_stream *)stream; + http_subtransport *t = OWNING_SUBTRANSPORT(s); + parser_context ctx; + size_t bytes_parsed; + +replay: + *bytes_read = 0; + + assert(t->connected); + + if (!s->sent_request) { + git_buf request = GIT_BUF_INIT; + + clear_parser_state(t); + + if (gen_request(&request, s, 0) < 0) + return -1; + + if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) { + git_buf_free(&request); + return -1; + } + + git_buf_free(&request); + + s->sent_request = 1; + } + + if (!s->received_response) { + if (s->chunked) { + assert(s->verb == post_verb); + + /* Flush, if necessary */ + if (s->chunk_buffer_len > 0 && + write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0) + return -1; + + s->chunk_buffer_len = 0; + + /* Write the final chunk. */ + if (git_stream_write(t->io, "0\r\n\r\n", 5, 0) < 0) + return -1; + } + + s->received_response = 1; + } + + while (!*bytes_read && !t->parse_finished) { + size_t data_offset; + int error; + + /* + * Make the parse_buffer think it's as full of data as + * the buffer, so it won't try to recv more data than + * we can put into it. + * + * data_offset is the actual data offset from which we + * should tell the parser to start reading. + */ + if (buf_size >= t->parse_buffer.len) { + t->parse_buffer.offset = 0; + } else { + t->parse_buffer.offset = t->parse_buffer.len - buf_size; + } + + data_offset = t->parse_buffer.offset; + + if (gitno_recv(&t->parse_buffer) < 0) + return -1; + + /* This call to http_parser_execute will result in invocations of the + * on_* family of callbacks. The most interesting of these is + * on_body_fill_buffer, which is called when data is ready to be copied + * into the target buffer. We need to marshal the buffer, buf_size, and + * bytes_read parameters to this callback. */ + ctx.t = t; + ctx.s = s; + ctx.buffer = buffer; + ctx.buf_size = buf_size; + ctx.bytes_read = bytes_read; + + /* Set the context, call the parser, then unset the context. */ + t->parser.data = &ctx; + + bytes_parsed = http_parser_execute(&t->parser, + &t->settings, + t->parse_buffer.data + data_offset, + t->parse_buffer.offset - data_offset); + + t->parser.data = NULL; + + /* If there was a handled authentication failure, then parse_error + * will have signaled us that we should replay the request. */ + if (PARSE_ERROR_REPLAY == t->parse_error) { + s->sent_request = 0; + + if ((error = http_connect(t)) < 0) + return error; + + goto replay; + } + + if (t->parse_error < 0) + return -1; + + if (bytes_parsed != t->parse_buffer.offset - data_offset) { + giterr_set(GITERR_NET, + "HTTP parser error: %s", + http_errno_description((enum http_errno)t->parser.http_errno)); + return -1; + } + } + + return 0; +} + +static int http_stream_write_chunked( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + http_stream *s = (http_stream *)stream; + http_subtransport *t = OWNING_SUBTRANSPORT(s); + + assert(t->connected); + + /* Send the request, if necessary */ + if (!s->sent_request) { + git_buf request = GIT_BUF_INIT; + + clear_parser_state(t); + + if (gen_request(&request, s, 0) < 0) + return -1; + + if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) { + git_buf_free(&request); + return -1; + } + + git_buf_free(&request); + + s->sent_request = 1; + } + + if (len > CHUNK_SIZE) { + /* Flush, if necessary */ + if (s->chunk_buffer_len > 0) { + if (write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0) + return -1; + + s->chunk_buffer_len = 0; + } + + /* Write chunk directly */ + if (write_chunk(t->io, buffer, len) < 0) + return -1; + } + else { + /* Append as much to the buffer as we can */ + int count = min(CHUNK_SIZE - s->chunk_buffer_len, len); + + if (!s->chunk_buffer) + s->chunk_buffer = git__malloc(CHUNK_SIZE); + + memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count); + s->chunk_buffer_len += count; + buffer += count; + len -= count; + + /* Is the buffer full? If so, then flush */ + if (CHUNK_SIZE == s->chunk_buffer_len) { + if (write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0) + return -1; + + s->chunk_buffer_len = 0; + + if (len > 0) { + memcpy(s->chunk_buffer, buffer, len); + s->chunk_buffer_len = len; + } + } + } + + return 0; +} + +static int http_stream_write_single( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + http_stream *s = (http_stream *)stream; + http_subtransport *t = OWNING_SUBTRANSPORT(s); + git_buf request = GIT_BUF_INIT; + + assert(t->connected); + + if (s->sent_request) { + giterr_set(GITERR_NET, "Subtransport configured for only one write"); + return -1; + } + + clear_parser_state(t); + + if (gen_request(&request, s, len) < 0) + return -1; + + if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) + goto on_error; + + if (len && git_stream_write(t->io, buffer, len, 0) < 0) + goto on_error; + + git_buf_free(&request); + s->sent_request = 1; + + return 0; + +on_error: + git_buf_free(&request); + return -1; +} + +static void http_stream_free(git_smart_subtransport_stream *stream) +{ + http_stream *s = (http_stream *)stream; + + if (s->chunk_buffer) + git__free(s->chunk_buffer); + + if (s->redirect_url) + git__free(s->redirect_url); + + git__free(s); +} + +static int http_stream_alloc(http_subtransport *t, + git_smart_subtransport_stream **stream) +{ + http_stream *s; + + if (!stream) + return -1; + + s = git__calloc(sizeof(http_stream), 1); + GITERR_CHECK_ALLOC(s); + + s->parent.subtransport = &t->parent; + s->parent.read = http_stream_read; + s->parent.write = http_stream_write_single; + s->parent.free = http_stream_free; + + *stream = (git_smart_subtransport_stream *)s; + return 0; +} + +static int http_uploadpack_ls( + http_subtransport *t, + git_smart_subtransport_stream **stream) +{ + http_stream *s; + + if (http_stream_alloc(t, stream) < 0) + return -1; + + s = (http_stream *)*stream; + + s->service = upload_pack_service; + s->service_url = upload_pack_ls_service_url; + s->verb = get_verb; + + return 0; +} + +static int http_uploadpack( + http_subtransport *t, + git_smart_subtransport_stream **stream) +{ + http_stream *s; + + if (http_stream_alloc(t, stream) < 0) + return -1; + + s = (http_stream *)*stream; + + s->service = upload_pack_service; + s->service_url = upload_pack_service_url; + s->verb = post_verb; + + return 0; +} + +static int http_receivepack_ls( + http_subtransport *t, + git_smart_subtransport_stream **stream) +{ + http_stream *s; + + if (http_stream_alloc(t, stream) < 0) + return -1; + + s = (http_stream *)*stream; + + s->service = receive_pack_service; + s->service_url = receive_pack_ls_service_url; + s->verb = get_verb; + + return 0; +} + +static int http_receivepack( + http_subtransport *t, + git_smart_subtransport_stream **stream) +{ + http_stream *s; + + if (http_stream_alloc(t, stream) < 0) + return -1; + + s = (http_stream *)*stream; + + /* Use Transfer-Encoding: chunked for this request */ + s->chunked = 1; + s->parent.write = http_stream_write_chunked; + + s->service = receive_pack_service; + s->service_url = receive_pack_service_url; + s->verb = post_verb; + + return 0; +} + +static int http_action( + git_smart_subtransport_stream **stream, + git_smart_subtransport *subtransport, + const char *url, + git_smart_service_t action) +{ + http_subtransport *t = (http_subtransport *)subtransport; + int ret; + + if (!stream) + return -1; + + if ((!t->connection_data.host || !t->connection_data.port || !t->connection_data.path) && + (ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0) + return ret; + + if ((ret = http_connect(t)) < 0) + return ret; + + switch (action) { + case GIT_SERVICE_UPLOADPACK_LS: + return http_uploadpack_ls(t, stream); + + case GIT_SERVICE_UPLOADPACK: + return http_uploadpack(t, stream); + + case GIT_SERVICE_RECEIVEPACK_LS: + return http_receivepack_ls(t, stream); + + case GIT_SERVICE_RECEIVEPACK: + return http_receivepack(t, stream); + } + + *stream = NULL; + return -1; +} + +static int http_close(git_smart_subtransport *subtransport) +{ + http_subtransport *t = (http_subtransport *) subtransport; + git_http_auth_context *context; + size_t i; + + clear_parser_state(t); + + if (t->io) { + git_stream_close(t->io); + git_stream_free(t->io); + t->io = NULL; + } + + if (t->cred) { + t->cred->free(t->cred); + t->cred = NULL; + } + + if (t->url_cred) { + t->url_cred->free(t->url_cred); + t->url_cred = NULL; + } + + git_vector_foreach(&t->auth_contexts, i, context) { + if (context->free) + context->free(context); + } + + git_vector_clear(&t->auth_contexts); + + gitno_connection_data_free_ptrs(&t->connection_data); + memset(&t->connection_data, 0x0, sizeof(gitno_connection_data)); + + return 0; +} + +static void http_free(git_smart_subtransport *subtransport) +{ + http_subtransport *t = (http_subtransport *) subtransport; + + http_close(subtransport); + + git_vector_free(&t->auth_contexts); + git__free(t); +} + +int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner, void *param) +{ + http_subtransport *t; + + GIT_UNUSED(param); + + if (!out) + return -1; + + t = git__calloc(sizeof(http_subtransport), 1); + GITERR_CHECK_ALLOC(t); + + t->owner = (transport_smart *)owner; + t->parent.action = http_action; + t->parent.close = http_close; + t->parent.free = http_free; + + t->settings.on_header_field = on_header_field; + t->settings.on_header_value = on_header_value; + t->settings.on_headers_complete = on_headers_complete; + t->settings.on_body = on_body_fill_buffer; + t->settings.on_message_complete = on_message_complete; + + *out = (git_smart_subtransport *) t; + return 0; +} + +#endif /* !GIT_WINHTTP */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/local.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/local.c new file mode 100644 index 000000000..64ddbd970 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/local.c @@ -0,0 +1,716 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "common.h" +#include "git2/types.h" +#include "git2/net.h" +#include "git2/repository.h" +#include "git2/object.h" +#include "git2/tag.h" +#include "git2/transport.h" +#include "git2/revwalk.h" +#include "git2/odb_backend.h" +#include "git2/pack.h" +#include "git2/commit.h" +#include "git2/revparse.h" +#include "git2/push.h" +#include "pack-objects.h" +#include "refs.h" +#include "posix.h" +#include "path.h" +#include "buffer.h" +#include "repository.h" +#include "odb.h" +#include "push.h" +#include "remote.h" + +typedef struct { + git_transport parent; + git_remote *owner; + char *url; + int direction; + int flags; + git_atomic cancelled; + git_repository *repo; + git_transport_message_cb progress_cb; + git_transport_message_cb error_cb; + void *message_cb_payload; + git_vector refs; + unsigned connected : 1, + have_refs : 1; +} transport_local; + +static void free_head(git_remote_head *head) +{ + git__free(head->name); + git__free(head->symref_target); + git__free(head); +} + +static void free_heads(git_vector *heads) +{ + git_remote_head *head; + size_t i; + + git_vector_foreach(heads, i, head) + free_head(head); + + git_vector_free(heads); +} + +static int add_ref(transport_local *t, const char *name) +{ + const char peeled[] = "^{}"; + git_reference *ref, *resolved; + git_remote_head *head; + git_oid obj_id; + git_object *obj = NULL, *target = NULL; + git_buf buf = GIT_BUF_INIT; + int error; + + if ((error = git_reference_lookup(&ref, t->repo, name)) < 0) + return error; + + error = git_reference_resolve(&resolved, ref); + if (error < 0) { + git_reference_free(ref); + if (!strcmp(name, GIT_HEAD_FILE) && error == GIT_ENOTFOUND) { + /* This is actually okay. Empty repos often have a HEAD that + * points to a nonexistent "refs/heads/master". */ + giterr_clear(); + return 0; + } + return error; + } + + git_oid_cpy(&obj_id, git_reference_target(resolved)); + git_reference_free(resolved); + + head = git__calloc(1, sizeof(git_remote_head)); + GITERR_CHECK_ALLOC(head); + + head->name = git__strdup(name); + GITERR_CHECK_ALLOC(head->name); + + git_oid_cpy(&head->oid, &obj_id); + + if (git_reference_type(ref) == GIT_REF_SYMBOLIC) { + head->symref_target = git__strdup(git_reference_symbolic_target(ref)); + GITERR_CHECK_ALLOC(head->symref_target); + } + git_reference_free(ref); + + if ((error = git_vector_insert(&t->refs, head)) < 0) { + free_head(head); + return error; + } + + /* If it's not a tag, we don't need to try to peel it */ + if (git__prefixcmp(name, GIT_REFS_TAGS_DIR)) + return 0; + + if ((error = git_object_lookup(&obj, t->repo, &head->oid, GIT_OBJ_ANY)) < 0) + return error; + + head = NULL; + + /* If it's not an annotated tag, or if we're mocking + * git-receive-pack, just get out */ + if (git_object_type(obj) != GIT_OBJ_TAG || + t->direction != GIT_DIRECTION_FETCH) { + git_object_free(obj); + return 0; + } + + /* And if it's a tag, peel it, and add it to the list */ + head = git__calloc(1, sizeof(git_remote_head)); + GITERR_CHECK_ALLOC(head); + + if (git_buf_join(&buf, 0, name, peeled) < 0) { + free_head(head); + return -1; + } + head->name = git_buf_detach(&buf); + + if (!(error = git_tag_peel(&target, (git_tag *)obj))) { + git_oid_cpy(&head->oid, git_object_id(target)); + + if ((error = git_vector_insert(&t->refs, head)) < 0) { + free_head(head); + } + } + + git_object_free(obj); + git_object_free(target); + + return error; +} + +static int store_refs(transport_local *t) +{ + size_t i; + git_remote_head *head; + git_strarray ref_names = {0}; + + assert(t); + + if (git_reference_list(&ref_names, t->repo) < 0) + goto on_error; + + /* Clear all heads we might have fetched in a previous connect */ + git_vector_foreach(&t->refs, i, head) { + git__free(head->name); + git__free(head); + } + + /* Clear the vector so we can reuse it */ + git_vector_clear(&t->refs); + + /* Sort the references first */ + git__tsort((void **)ref_names.strings, ref_names.count, &git__strcmp_cb); + + /* Add HEAD iff direction is fetch */ + if (t->direction == GIT_DIRECTION_FETCH && add_ref(t, GIT_HEAD_FILE) < 0) + goto on_error; + + for (i = 0; i < ref_names.count; ++i) { + if (add_ref(t, ref_names.strings[i]) < 0) + goto on_error; + } + + t->have_refs = 1; + git_strarray_free(&ref_names); + return 0; + +on_error: + git_vector_free(&t->refs); + git_strarray_free(&ref_names); + return -1; +} + +/* + * Try to open the url as a git directory. The direction doesn't + * matter in this case because we're calculating the heads ourselves. + */ +static int local_connect( + git_transport *transport, + const char *url, + git_cred_acquire_cb cred_acquire_cb, + void *cred_acquire_payload, + int direction, int flags) +{ + git_repository *repo; + int error; + transport_local *t = (transport_local *) transport; + const char *path; + git_buf buf = GIT_BUF_INIT; + + GIT_UNUSED(cred_acquire_cb); + GIT_UNUSED(cred_acquire_payload); + + if (t->connected) + return 0; + + free_heads(&t->refs); + + t->url = git__strdup(url); + GITERR_CHECK_ALLOC(t->url); + t->direction = direction; + t->flags = flags; + + /* 'url' may be a url or path; convert to a path */ + if ((error = git_path_from_url_or_path(&buf, url)) < 0) { + git_buf_free(&buf); + return error; + } + path = git_buf_cstr(&buf); + + error = git_repository_open(&repo, path); + + git_buf_free(&buf); + + if (error < 0) + return -1; + + t->repo = repo; + + if (store_refs(t) < 0) + return -1; + + t->connected = 1; + + return 0; +} + +static int local_ls(const git_remote_head ***out, size_t *size, git_transport *transport) +{ + transport_local *t = (transport_local *)transport; + + if (!t->have_refs) { + giterr_set(GITERR_NET, "The transport has not yet loaded the refs"); + return -1; + } + + *out = (const git_remote_head **)t->refs.contents; + *size = t->refs.length; + + return 0; +} + +static int local_negotiate_fetch( + git_transport *transport, + git_repository *repo, + const git_remote_head * const *refs, + size_t count) +{ + transport_local *t = (transport_local*)transport; + git_remote_head *rhead; + unsigned int i; + + GIT_UNUSED(refs); + GIT_UNUSED(count); + + /* Fill in the loids */ + git_vector_foreach(&t->refs, i, rhead) { + git_object *obj; + + int error = git_revparse_single(&obj, repo, rhead->name); + if (!error) + git_oid_cpy(&rhead->loid, git_object_id(obj)); + else if (error != GIT_ENOTFOUND) + return error; + else + giterr_clear(); + git_object_free(obj); + } + + return 0; +} + +static int local_push_copy_object( + git_odb *local_odb, + git_odb *remote_odb, + git_pobject *obj) +{ + int error = 0; + git_odb_object *odb_obj = NULL; + git_odb_stream *odb_stream; + size_t odb_obj_size; + git_otype odb_obj_type; + git_oid remote_odb_obj_oid; + + /* Object already exists in the remote ODB; do nothing and return 0*/ + if (git_odb_exists(remote_odb, &obj->id)) + return 0; + + if ((error = git_odb_read(&odb_obj, local_odb, &obj->id)) < 0) + return error; + + odb_obj_size = git_odb_object_size(odb_obj); + odb_obj_type = git_odb_object_type(odb_obj); + + if ((error = git_odb_open_wstream(&odb_stream, remote_odb, + odb_obj_size, odb_obj_type)) < 0) + goto on_error; + + if (git_odb_stream_write(odb_stream, (char *)git_odb_object_data(odb_obj), + odb_obj_size) < 0 || + git_odb_stream_finalize_write(&remote_odb_obj_oid, odb_stream) < 0) { + error = -1; + } else if (git_oid__cmp(&obj->id, &remote_odb_obj_oid) != 0) { + giterr_set(GITERR_ODB, "Error when writing object to remote odb " + "during local push operation. Remote odb object oid does not " + "match local oid."); + error = -1; + } + + git_odb_stream_free(odb_stream); + +on_error: + git_odb_object_free(odb_obj); + return error; +} + +static int local_push_update_remote_ref( + git_repository *remote_repo, + const char *lref, + const char *rref, + git_oid *loid, + git_oid *roid) +{ + int error; + git_reference *remote_ref = NULL; + + /* check for lhs, if it's empty it means to delete */ + if (lref[0] != '\0') { + /* Create or update a ref */ + error = git_reference_create(NULL, remote_repo, rref, loid, + !git_oid_iszero(roid), NULL); + } else { + /* Delete a ref */ + if ((error = git_reference_lookup(&remote_ref, remote_repo, rref)) < 0) { + if (error == GIT_ENOTFOUND) + error = 0; + return error; + } + + error = git_reference_delete(remote_ref); + git_reference_free(remote_ref); + } + + return error; +} + +static int local_push( + git_transport *transport, + git_push *push) +{ + transport_local *t = (transport_local *)transport; + git_odb *remote_odb = NULL; + git_odb *local_odb = NULL; + git_repository *remote_repo = NULL; + push_spec *spec; + char *url = NULL; + const char *path; + git_buf buf = GIT_BUF_INIT; + int error; + unsigned int i; + size_t j; + + /* 'push->remote->url' may be a url or path; convert to a path */ + if ((error = git_path_from_url_or_path(&buf, push->remote->url)) < 0) { + git_buf_free(&buf); + return error; + } + path = git_buf_cstr(&buf); + + error = git_repository_open(&remote_repo, path); + + git_buf_free(&buf); + + if (error < 0) + return error; + + /* We don't currently support pushing locally to non-bare repos. Proper + non-bare repo push support would require checking configs to see if + we should override the default 'don't let this happen' behavior */ + if (!remote_repo->is_bare) { + error = GIT_EBAREREPO; + giterr_set(GITERR_INVALID, "Local push doesn't (yet) support pushing to non-bare repos."); + goto on_error; + } + + if ((error = git_repository_odb__weakptr(&remote_odb, remote_repo)) < 0 || + (error = git_repository_odb__weakptr(&local_odb, push->repo)) < 0) + goto on_error; + + for (i = 0; i < push->pb->nr_objects; i++) { + if ((error = local_push_copy_object(local_odb, remote_odb, + &push->pb->object_list[i])) < 0) + goto on_error; + } + + push->unpack_ok = 1; + + git_vector_foreach(&push->specs, j, spec) { + push_status *status; + const git_error *last; + char *ref = spec->refspec.dst; + + status = git__calloc(1, sizeof(push_status)); + if (!status) + goto on_error; + + status->ref = git__strdup(ref); + if (!status->ref) { + git_push_status_free(status); + goto on_error; + } + + error = local_push_update_remote_ref(remote_repo, spec->refspec.src, spec->refspec.dst, + &spec->loid, &spec->roid); + + switch (error) { + case GIT_OK: + break; + case GIT_EINVALIDSPEC: + status->msg = git__strdup("funny refname"); + break; + case GIT_ENOTFOUND: + status->msg = git__strdup("Remote branch not found to delete"); + break; + default: + last = giterr_last(); + + if (last && last->message) + status->msg = git__strdup(last->message); + else + status->msg = git__strdup("Unspecified error encountered"); + break; + } + + /* failed to allocate memory for a status message */ + if (error < 0 && !status->msg) { + git_push_status_free(status); + goto on_error; + } + + /* failed to insert the ref update status */ + if ((error = git_vector_insert(&push->status, status)) < 0) { + git_push_status_free(status); + goto on_error; + } + } + + if (push->specs.length) { + int flags = t->flags; + url = git__strdup(t->url); + + if (!url || t->parent.close(&t->parent) < 0 || + t->parent.connect(&t->parent, url, + push->remote->callbacks.credentials, NULL, GIT_DIRECTION_PUSH, flags)) + goto on_error; + } + + error = 0; + +on_error: + git_repository_free(remote_repo); + git__free(url); + + return error; +} + +typedef struct foreach_data { + git_transfer_progress *stats; + git_transfer_progress_cb progress_cb; + void *progress_payload; + git_odb_writepack *writepack; +} foreach_data; + +static int foreach_cb(void *buf, size_t len, void *payload) +{ + foreach_data *data = (foreach_data*)payload; + + data->stats->received_bytes += len; + return data->writepack->append(data->writepack, buf, len, data->stats); +} + +static const char *counting_objects_fmt = "Counting objects %d\r"; + +static int local_download_pack( + git_transport *transport, + git_repository *repo, + git_transfer_progress *stats, + git_transfer_progress_cb progress_cb, + void *progress_payload) +{ + transport_local *t = (transport_local*)transport; + git_revwalk *walk = NULL; + git_remote_head *rhead; + unsigned int i; + int error = -1; + git_packbuilder *pack = NULL; + git_odb_writepack *writepack = NULL; + git_odb *odb = NULL; + git_buf progress_info = GIT_BUF_INIT; + + if ((error = git_revwalk_new(&walk, t->repo)) < 0) + goto cleanup; + git_revwalk_sorting(walk, GIT_SORT_TIME); + + if ((error = git_packbuilder_new(&pack, t->repo)) < 0) + goto cleanup; + + stats->total_objects = 0; + stats->indexed_objects = 0; + stats->received_objects = 0; + stats->received_bytes = 0; + + git_vector_foreach(&t->refs, i, rhead) { + git_object *obj; + if ((error = git_object_lookup(&obj, t->repo, &rhead->oid, GIT_OBJ_ANY)) < 0) + goto cleanup; + + if (git_object_type(obj) == GIT_OBJ_COMMIT) { + /* Revwalker includes only wanted commits */ + error = git_revwalk_push(walk, &rhead->oid); + if (!error && !git_oid_iszero(&rhead->loid)) { + error = git_revwalk_hide(walk, &rhead->loid); + if (error == GIT_ENOTFOUND) + error = 0; + } + } else { + error = git_packbuilder_insert(pack, &rhead->oid, rhead->name); + } + git_object_free(obj); + if (error < 0) + goto cleanup; + } + + if ((error = git_packbuilder_insert_walk(pack, walk))) + goto cleanup; + + if ((error = git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack))) < 0) + goto cleanup; + + if (t->progress_cb && + (error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload)) < 0) + goto cleanup; + + /* Walk the objects, building a packfile */ + if ((error = git_repository_odb__weakptr(&odb, repo)) < 0) + goto cleanup; + + /* One last one with the newline */ + git_buf_clear(&progress_info); + git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack)); + if ((error = git_buf_putc(&progress_info, '\n')) < 0) + goto cleanup; + + if (t->progress_cb && + (error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload)) < 0) + goto cleanup; + + if ((error = git_odb_write_pack(&writepack, odb, progress_cb, progress_payload)) != 0) + goto cleanup; + + /* Write the data to the ODB */ + { + foreach_data data = {0}; + data.stats = stats; + data.progress_cb = progress_cb; + data.progress_payload = progress_payload; + data.writepack = writepack; + + /* autodetect */ + git_packbuilder_set_threads(pack, 0); + + if ((error = git_packbuilder_foreach(pack, foreach_cb, &data)) != 0) + goto cleanup; + } + + error = writepack->commit(writepack, stats); + +cleanup: + if (writepack) writepack->free(writepack); + git_buf_free(&progress_info); + git_packbuilder_free(pack); + git_revwalk_free(walk); + return error; +} + +static int local_set_callbacks( + git_transport *transport, + git_transport_message_cb progress_cb, + git_transport_message_cb error_cb, + git_transport_certificate_check_cb certificate_check_cb, + void *message_cb_payload) +{ + transport_local *t = (transport_local *)transport; + + GIT_UNUSED(certificate_check_cb); + + t->progress_cb = progress_cb; + t->error_cb = error_cb; + t->message_cb_payload = message_cb_payload; + + return 0; +} + +static int local_is_connected(git_transport *transport) +{ + transport_local *t = (transport_local *)transport; + + return t->connected; +} + +static int local_read_flags(git_transport *transport, int *flags) +{ + transport_local *t = (transport_local *)transport; + + *flags = t->flags; + + return 0; +} + +static void local_cancel(git_transport *transport) +{ + transport_local *t = (transport_local *)transport; + + git_atomic_set(&t->cancelled, 1); +} + +static int local_close(git_transport *transport) +{ + transport_local *t = (transport_local *)transport; + + t->connected = 0; + + if (t->repo) { + git_repository_free(t->repo); + t->repo = NULL; + } + + if (t->url) { + git__free(t->url); + t->url = NULL; + } + + return 0; +} + +static void local_free(git_transport *transport) +{ + transport_local *t = (transport_local *)transport; + + free_heads(&t->refs); + + /* Close the transport, if it's still open. */ + local_close(transport); + + /* Free the transport */ + git__free(t); +} + +/************** + * Public API * + **************/ + +int git_transport_local(git_transport **out, git_remote *owner, void *param) +{ + int error; + transport_local *t; + + GIT_UNUSED(param); + + t = git__calloc(1, sizeof(transport_local)); + GITERR_CHECK_ALLOC(t); + + t->parent.version = GIT_TRANSPORT_VERSION; + t->parent.set_callbacks = local_set_callbacks; + t->parent.connect = local_connect; + t->parent.negotiate_fetch = local_negotiate_fetch; + t->parent.download_pack = local_download_pack; + t->parent.push = local_push; + t->parent.close = local_close; + t->parent.free = local_free; + t->parent.ls = local_ls; + t->parent.is_connected = local_is_connected; + t->parent.read_flags = local_read_flags; + t->parent.cancel = local_cancel; + + if ((error = git_vector_init(&t->refs, 0, NULL)) < 0) { + git__free(t); + return error; + } + + t->owner = owner; + + *out = (git_transport *) t; + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.c new file mode 100644 index 000000000..85a49e543 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.c @@ -0,0 +1,419 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2.h" +#include "smart.h" +#include "refs.h" +#include "refspec.h" + +static int git_smart__recv_cb(gitno_buffer *buf) +{ + transport_smart *t = (transport_smart *) buf->cb_data; + size_t old_len, bytes_read; + int error; + + assert(t->current_stream); + + old_len = buf->offset; + + if ((error = t->current_stream->read(t->current_stream, buf->data + buf->offset, buf->len - buf->offset, &bytes_read)) < 0) + return error; + + buf->offset += bytes_read; + + if (t->packetsize_cb && !t->cancelled.val) { + error = t->packetsize_cb(bytes_read, t->packetsize_payload); + if (error) { + git_atomic_set(&t->cancelled, 1); + return GIT_EUSER; + } + } + + return (int)(buf->offset - old_len); +} + +GIT_INLINE(int) git_smart__reset_stream(transport_smart *t, bool close_subtransport) +{ + if (t->current_stream) { + t->current_stream->free(t->current_stream); + t->current_stream = NULL; + } + + if (close_subtransport && + t->wrapped->close(t->wrapped) < 0) + return -1; + + return 0; +} + +static int git_smart__set_callbacks( + git_transport *transport, + git_transport_message_cb progress_cb, + git_transport_message_cb error_cb, + git_transport_certificate_check_cb certificate_check_cb, + void *message_cb_payload) +{ + transport_smart *t = (transport_smart *)transport; + + t->progress_cb = progress_cb; + t->error_cb = error_cb; + t->certificate_check_cb = certificate_check_cb; + t->message_cb_payload = message_cb_payload; + + return 0; +} + +int git_smart__update_heads(transport_smart *t, git_vector *symrefs) +{ + size_t i; + git_pkt *pkt; + + git_vector_clear(&t->heads); + git_vector_foreach(&t->refs, i, pkt) { + git_pkt_ref *ref = (git_pkt_ref *) pkt; + if (pkt->type != GIT_PKT_REF) + continue; + + if (symrefs) { + git_refspec *spec; + git_buf buf = GIT_BUF_INIT; + size_t j; + int error = 0; + + git_vector_foreach(symrefs, j, spec) { + git_buf_clear(&buf); + if (git_refspec_src_matches(spec, ref->head.name) && + !(error = git_refspec_transform(&buf, spec, ref->head.name))) + ref->head.symref_target = git_buf_detach(&buf); + } + + git_buf_free(&buf); + + if (error < 0) + return error; + } + + if (git_vector_insert(&t->heads, &ref->head) < 0) + return -1; + } + + return 0; +} + +static void free_symrefs(git_vector *symrefs) +{ + git_refspec *spec; + size_t i; + + git_vector_foreach(symrefs, i, spec) { + git_refspec__free(spec); + git__free(spec); + } + + git_vector_free(symrefs); +} + +static int git_smart__connect( + git_transport *transport, + const char *url, + git_cred_acquire_cb cred_acquire_cb, + void *cred_acquire_payload, + int direction, + int flags) +{ + transport_smart *t = (transport_smart *)transport; + git_smart_subtransport_stream *stream; + int error; + git_pkt *pkt; + git_pkt_ref *first; + git_vector symrefs; + git_smart_service_t service; + + if (git_smart__reset_stream(t, true) < 0) + return -1; + + t->url = git__strdup(url); + GITERR_CHECK_ALLOC(t->url); + + t->direction = direction; + t->flags = flags; + t->cred_acquire_cb = cred_acquire_cb; + t->cred_acquire_payload = cred_acquire_payload; + + if (GIT_DIRECTION_FETCH == t->direction) + service = GIT_SERVICE_UPLOADPACK_LS; + else if (GIT_DIRECTION_PUSH == t->direction) + service = GIT_SERVICE_RECEIVEPACK_LS; + else { + giterr_set(GITERR_NET, "Invalid direction"); + return -1; + } + + if ((error = t->wrapped->action(&stream, t->wrapped, t->url, service)) < 0) + return error; + + /* Save off the current stream (i.e. socket) that we are working with */ + t->current_stream = stream; + + gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t); + + /* 2 flushes for RPC; 1 for stateful */ + if ((error = git_smart__store_refs(t, t->rpc ? 2 : 1)) < 0) + return error; + + /* Strip the comment packet for RPC */ + if (t->rpc) { + pkt = (git_pkt *)git_vector_get(&t->refs, 0); + + if (!pkt || GIT_PKT_COMMENT != pkt->type) { + giterr_set(GITERR_NET, "Invalid response"); + return -1; + } else { + /* Remove the comment pkt from the list */ + git_vector_remove(&t->refs, 0); + git__free(pkt); + } + } + + /* We now have loaded the refs. */ + t->have_refs = 1; + + first = (git_pkt_ref *)git_vector_get(&t->refs, 0); + + if ((error = git_vector_init(&symrefs, 1, NULL)) < 0) + return error; + + /* Detect capabilities */ + if (git_smart__detect_caps(first, &t->caps, &symrefs) < 0) + return -1; + + /* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */ + if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") && + git_oid_iszero(&first->head.oid)) { + git_vector_clear(&t->refs); + git_pkt_free((git_pkt *)first); + } + + /* Keep a list of heads for _ls */ + git_smart__update_heads(t, &symrefs); + + free_symrefs(&symrefs); + + if (t->rpc && git_smart__reset_stream(t, false) < 0) + return -1; + + /* We're now logically connected. */ + t->connected = 1; + + return 0; +} + +static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transport *transport) +{ + transport_smart *t = (transport_smart *)transport; + + if (!t->have_refs) { + giterr_set(GITERR_NET, "The transport has not yet loaded the refs"); + return -1; + } + + *out = (const git_remote_head **) t->heads.contents; + *size = t->heads.length; + + return 0; +} + +int git_smart__negotiation_step(git_transport *transport, void *data, size_t len) +{ + transport_smart *t = (transport_smart *)transport; + git_smart_subtransport_stream *stream; + int error; + + if (t->rpc && git_smart__reset_stream(t, false) < 0) + return -1; + + if (GIT_DIRECTION_FETCH != t->direction) { + giterr_set(GITERR_NET, "This operation is only valid for fetch"); + return -1; + } + + if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) < 0) + return error; + + /* If this is a stateful implementation, the stream we get back should be the same */ + assert(t->rpc || t->current_stream == stream); + + /* Save off the current stream (i.e. socket) that we are working with */ + t->current_stream = stream; + + if ((error = stream->write(stream, (const char *)data, len)) < 0) + return error; + + gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t); + + return 0; +} + +int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **stream) +{ + int error; + + if (t->rpc && git_smart__reset_stream(t, false) < 0) + return -1; + + if (GIT_DIRECTION_PUSH != t->direction) { + giterr_set(GITERR_NET, "This operation is only valid for push"); + return -1; + } + + if ((error = t->wrapped->action(stream, t->wrapped, t->url, GIT_SERVICE_RECEIVEPACK)) < 0) + return error; + + /* If this is a stateful implementation, the stream we get back should be the same */ + assert(t->rpc || t->current_stream == *stream); + + /* Save off the current stream (i.e. socket) that we are working with */ + t->current_stream = *stream; + + gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t); + + return 0; +} + +static void git_smart__cancel(git_transport *transport) +{ + transport_smart *t = (transport_smart *)transport; + + git_atomic_set(&t->cancelled, 1); +} + +static int git_smart__is_connected(git_transport *transport) +{ + transport_smart *t = (transport_smart *)transport; + + return t->connected; +} + +static int git_smart__read_flags(git_transport *transport, int *flags) +{ + transport_smart *t = (transport_smart *)transport; + + *flags = t->flags; + + return 0; +} + +static int git_smart__close(git_transport *transport) +{ + transport_smart *t = (transport_smart *)transport; + git_vector *common = &t->common; + unsigned int i; + git_pkt *p; + int ret; + git_smart_subtransport_stream *stream; + const char flush[] = "0000"; + + /* + * If we're still connected at this point and not using RPC, + * we should say goodbye by sending a flush, or git-daemon + * will complain that we disconnected unexpectedly. + */ + if (t->connected && !t->rpc && + !t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) { + t->current_stream->write(t->current_stream, flush, 4); + } + + ret = git_smart__reset_stream(t, true); + + git_vector_foreach(common, i, p) + git_pkt_free(p); + + git_vector_free(common); + + if (t->url) { + git__free(t->url); + t->url = NULL; + } + + t->connected = 0; + + return ret; +} + +static void git_smart__free(git_transport *transport) +{ + transport_smart *t = (transport_smart *)transport; + git_vector *refs = &t->refs; + unsigned int i; + git_pkt *p; + + /* Make sure that the current stream is closed, if we have one. */ + git_smart__close(transport); + + /* Free the subtransport */ + t->wrapped->free(t->wrapped); + + git_vector_free(&t->heads); + git_vector_foreach(refs, i, p) + git_pkt_free(p); + + git_vector_free(refs); + + git__free(t); +} + +static int ref_name_cmp(const void *a, const void *b) +{ + const git_pkt_ref *ref_a = a, *ref_b = b; + + return strcmp(ref_a->head.name, ref_b->head.name); +} + +int git_transport_smart(git_transport **out, git_remote *owner, void *param) +{ + transport_smart *t; + git_smart_subtransport_definition *definition = (git_smart_subtransport_definition *)param; + + if (!param) + return -1; + + t = git__calloc(1, sizeof(transport_smart)); + GITERR_CHECK_ALLOC(t); + + t->parent.version = GIT_TRANSPORT_VERSION; + t->parent.set_callbacks = git_smart__set_callbacks; + t->parent.connect = git_smart__connect; + t->parent.close = git_smart__close; + t->parent.free = git_smart__free; + t->parent.negotiate_fetch = git_smart__negotiate_fetch; + t->parent.download_pack = git_smart__download_pack; + t->parent.push = git_smart__push; + t->parent.ls = git_smart__ls; + t->parent.is_connected = git_smart__is_connected; + t->parent.read_flags = git_smart__read_flags; + t->parent.cancel = git_smart__cancel; + + t->owner = owner; + t->rpc = definition->rpc; + + if (git_vector_init(&t->refs, 16, ref_name_cmp) < 0) { + git__free(t); + return -1; + } + + if (git_vector_init(&t->heads, 16, ref_name_cmp) < 0) { + git__free(t); + return -1; + } + + if (definition->callback(&t->wrapped, &t->parent, definition->param) < 0) { + git__free(t); + return -1; + } + + *out = (git_transport *) t; + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.h b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.h new file mode 100644 index 000000000..44e241adc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart.h @@ -0,0 +1,189 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2.h" +#include "vector.h" +#include "netops.h" +#include "buffer.h" +#include "push.h" +#include "git2/sys/transport.h" + +#define GIT_SIDE_BAND_DATA 1 +#define GIT_SIDE_BAND_PROGRESS 2 +#define GIT_SIDE_BAND_ERROR 3 + +#define GIT_CAP_OFS_DELTA "ofs-delta" +#define GIT_CAP_MULTI_ACK "multi_ack" +#define GIT_CAP_MULTI_ACK_DETAILED "multi_ack_detailed" +#define GIT_CAP_SIDE_BAND "side-band" +#define GIT_CAP_SIDE_BAND_64K "side-band-64k" +#define GIT_CAP_INCLUDE_TAG "include-tag" +#define GIT_CAP_DELETE_REFS "delete-refs" +#define GIT_CAP_REPORT_STATUS "report-status" +#define GIT_CAP_THIN_PACK "thin-pack" +#define GIT_CAP_SYMREF "symref" + +enum git_pkt_type { + GIT_PKT_CMD, + GIT_PKT_FLUSH, + GIT_PKT_REF, + GIT_PKT_HAVE, + GIT_PKT_ACK, + GIT_PKT_NAK, + GIT_PKT_PACK, + GIT_PKT_COMMENT, + GIT_PKT_ERR, + GIT_PKT_DATA, + GIT_PKT_PROGRESS, + GIT_PKT_OK, + GIT_PKT_NG, + GIT_PKT_UNPACK, +}; + +/* Used for multi_ack and mutli_ack_detailed */ +enum git_ack_status { + GIT_ACK_NONE, + GIT_ACK_CONTINUE, + GIT_ACK_COMMON, + GIT_ACK_READY +}; + +/* This would be a flush pkt */ +typedef struct { + enum git_pkt_type type; +} git_pkt; + +struct git_pkt_cmd { + enum git_pkt_type type; + char *cmd; + char *path; + char *host; +}; + +/* This is a pkt-line with some info in it */ +typedef struct { + enum git_pkt_type type; + git_remote_head head; + char *capabilities; +} git_pkt_ref; + +/* Useful later */ +typedef struct { + enum git_pkt_type type; + git_oid oid; + enum git_ack_status status; +} git_pkt_ack; + +typedef struct { + enum git_pkt_type type; + char comment[GIT_FLEX_ARRAY]; +} git_pkt_comment; + +typedef struct { + enum git_pkt_type type; + int len; + char data[GIT_FLEX_ARRAY]; +} git_pkt_data; + +typedef git_pkt_data git_pkt_progress; + +typedef struct { + enum git_pkt_type type; + int len; + char error[GIT_FLEX_ARRAY]; +} git_pkt_err; + +typedef struct { + enum git_pkt_type type; + char *ref; +} git_pkt_ok; + +typedef struct { + enum git_pkt_type type; + char *ref; + char *msg; +} git_pkt_ng; + +typedef struct { + enum git_pkt_type type; + int unpack_ok; +} git_pkt_unpack; + +typedef struct transport_smart_caps { + int common:1, + ofs_delta:1, + multi_ack: 1, + multi_ack_detailed: 1, + side_band:1, + side_band_64k:1, + include_tag:1, + delete_refs:1, + report_status:1, + thin_pack:1; +} transport_smart_caps; + +typedef int (*packetsize_cb)(size_t received, void *payload); + +typedef struct { + git_transport parent; + git_remote *owner; + char *url; + git_cred_acquire_cb cred_acquire_cb; + void *cred_acquire_payload; + int direction; + int flags; + git_transport_message_cb progress_cb; + git_transport_message_cb error_cb; + git_transport_certificate_check_cb certificate_check_cb; + void *message_cb_payload; + git_smart_subtransport *wrapped; + git_smart_subtransport_stream *current_stream; + transport_smart_caps caps; + git_vector refs; + git_vector heads; + git_vector common; + git_atomic cancelled; + packetsize_cb packetsize_cb; + void *packetsize_payload; + unsigned rpc : 1, + have_refs : 1, + connected : 1; + gitno_buffer buffer; + char buffer_data[65536]; +} transport_smart; + +/* smart_protocol.c */ +int git_smart__store_refs(transport_smart *t, int flushes); +int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs); +int git_smart__push(git_transport *transport, git_push *push); + +int git_smart__negotiate_fetch( + git_transport *transport, + git_repository *repo, + const git_remote_head * const *refs, + size_t count); + +int git_smart__download_pack( + git_transport *transport, + git_repository *repo, + git_transfer_progress *stats, + git_transfer_progress_cb progress_cb, + void *progress_payload); + +/* smart.c */ +int git_smart__negotiation_step(git_transport *transport, void *data, size_t len); +int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **out); + +int git_smart__update_heads(transport_smart *t, git_vector *symrefs); + +/* smart_pkt.c */ +int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len); +int git_pkt_buffer_flush(git_buf *buf); +int git_pkt_send_flush(GIT_SOCKET s); +int git_pkt_buffer_done(git_buf *buf); +int git_pkt_buffer_wants(const git_remote_head * const *refs, size_t count, transport_smart_caps *caps, git_buf *buf); +int git_pkt_buffer_have(git_oid *oid, git_buf *buf); +void git_pkt_free(git_pkt *pkt); diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_pkt.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_pkt.c new file mode 100644 index 000000000..d214c9fa5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_pkt.c @@ -0,0 +1,596 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" + +#include "git2/types.h" +#include "git2/errors.h" +#include "git2/refs.h" +#include "git2/revwalk.h" + +#include "smart.h" +#include "util.h" +#include "netops.h" +#include "posix.h" +#include "buffer.h" + +#include + +#define PKT_LEN_SIZE 4 +static const char pkt_done_str[] = "0009done\n"; +static const char pkt_flush_str[] = "0000"; +static const char pkt_have_prefix[] = "0032have "; +static const char pkt_want_prefix[] = "0032want "; + +static int flush_pkt(git_pkt **out) +{ + git_pkt *pkt; + + pkt = git__malloc(sizeof(git_pkt)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_FLUSH; + *out = pkt; + + return 0; +} + +/* the rest of the line will be useful for multi_ack and multi_ack_detailed */ +static int ack_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_ack *pkt; + GIT_UNUSED(line); + GIT_UNUSED(len); + + pkt = git__calloc(1, sizeof(git_pkt_ack)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_ACK; + line += 3; + len -= 3; + + if (len >= GIT_OID_HEXSZ) { + git_oid_fromstr(&pkt->oid, line + 1); + line += GIT_OID_HEXSZ + 1; + len -= GIT_OID_HEXSZ + 1; + } + + if (len >= 7) { + if (!git__prefixcmp(line + 1, "continue")) + pkt->status = GIT_ACK_CONTINUE; + if (!git__prefixcmp(line + 1, "common")) + pkt->status = GIT_ACK_COMMON; + if (!git__prefixcmp(line + 1, "ready")) + pkt->status = GIT_ACK_READY; + } + + *out = (git_pkt *) pkt; + + return 0; +} + +static int nak_pkt(git_pkt **out) +{ + git_pkt *pkt; + + pkt = git__malloc(sizeof(git_pkt)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_NAK; + *out = pkt; + + return 0; +} + +static int pack_pkt(git_pkt **out) +{ + git_pkt *pkt; + + pkt = git__malloc(sizeof(git_pkt)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_PACK; + *out = pkt; + + return 0; +} + +static int comment_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_comment *pkt; + size_t alloclen; + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_comment), len); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + pkt = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_COMMENT; + memcpy(pkt->comment, line, len); + pkt->comment[len] = '\0'; + + *out = (git_pkt *) pkt; + + return 0; +} + +static int err_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_err *pkt; + size_t alloclen; + + /* Remove "ERR " from the line */ + line += 4; + len -= 4; + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + pkt = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_ERR; + pkt->len = (int)len; + memcpy(pkt->error, line, len); + pkt->error[len] = '\0'; + + *out = (git_pkt *) pkt; + + return 0; +} + +static int data_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_data *pkt; + size_t alloclen; + + line++; + len--; + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len); + pkt = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_DATA; + pkt->len = (int) len; + memcpy(pkt->data, line, len); + + *out = (git_pkt *) pkt; + + return 0; +} + +static int sideband_progress_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_progress *pkt; + size_t alloclen; + + line++; + len--; + + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len); + pkt = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_PROGRESS; + pkt->len = (int) len; + memcpy(pkt->data, line, len); + + *out = (git_pkt *) pkt; + + return 0; +} + +static int sideband_error_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_err *pkt; + size_t alloc_len; + + line++; + len--; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(git_pkt_err), len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); + pkt = git__malloc(alloc_len); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_ERR; + pkt->len = (int)len; + memcpy(pkt->error, line, len); + pkt->error[len] = '\0'; + + *out = (git_pkt *)pkt; + + return 0; +} + +/* + * Parse an other-ref line. + */ +static int ref_pkt(git_pkt **out, const char *line, size_t len) +{ + int error; + git_pkt_ref *pkt; + size_t alloclen; + + pkt = git__malloc(sizeof(git_pkt_ref)); + GITERR_CHECK_ALLOC(pkt); + + memset(pkt, 0x0, sizeof(git_pkt_ref)); + pkt->type = GIT_PKT_REF; + if ((error = git_oid_fromstr(&pkt->head.oid, line)) < 0) + goto error_out; + + /* Check for a bit of consistency */ + if (line[GIT_OID_HEXSZ] != ' ') { + giterr_set(GITERR_NET, "Error parsing pkt-line"); + error = -1; + goto error_out; + } + + /* Jump from the name */ + line += GIT_OID_HEXSZ + 1; + len -= (GIT_OID_HEXSZ + 1); + + if (line[len - 1] == '\n') + --len; + + GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); + pkt->head.name = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt->head.name); + + memcpy(pkt->head.name, line, len); + pkt->head.name[len] = '\0'; + + if (strlen(pkt->head.name) < len) { + pkt->capabilities = strchr(pkt->head.name, '\0') + 1; + } + + *out = (git_pkt *)pkt; + return 0; + +error_out: + git__free(pkt); + return error; +} + +static int ok_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_ok *pkt; + const char *ptr; + size_t alloc_len; + + pkt = git__malloc(sizeof(*pkt)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_OK; + + line += 3; /* skip "ok " */ + if (!(ptr = strchr(line, '\n'))) { + giterr_set(GITERR_NET, "Invalid packet line"); + return -1; + } + len = ptr - line; + + GITERR_CHECK_ALLOC_ADD(&alloc_len, len, 1); + pkt->ref = git__malloc(alloc_len); + GITERR_CHECK_ALLOC(pkt->ref); + + memcpy(pkt->ref, line, len); + pkt->ref[len] = '\0'; + + *out = (git_pkt *)pkt; + return 0; +} + +static int ng_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_ng *pkt; + const char *ptr; + size_t alloclen; + + pkt = git__malloc(sizeof(*pkt)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_NG; + + line += 3; /* skip "ng " */ + if (!(ptr = strchr(line, ' '))) { + giterr_set(GITERR_NET, "Invalid packet line"); + return -1; + } + len = ptr - line; + + GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); + pkt->ref = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt->ref); + + memcpy(pkt->ref, line, len); + pkt->ref[len] = '\0'; + + line = ptr + 1; + if (!(ptr = strchr(line, '\n'))) { + giterr_set(GITERR_NET, "Invalid packet line"); + return -1; + } + len = ptr - line; + + GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); + pkt->msg = git__malloc(alloclen); + GITERR_CHECK_ALLOC(pkt->msg); + + memcpy(pkt->msg, line, len); + pkt->msg[len] = '\0'; + + *out = (git_pkt *)pkt; + return 0; +} + +static int unpack_pkt(git_pkt **out, const char *line, size_t len) +{ + git_pkt_unpack *pkt; + + GIT_UNUSED(len); + + pkt = git__malloc(sizeof(*pkt)); + GITERR_CHECK_ALLOC(pkt); + + pkt->type = GIT_PKT_UNPACK; + if (!git__prefixcmp(line, "unpack ok")) + pkt->unpack_ok = 1; + else + pkt->unpack_ok = 0; + + *out = (git_pkt *)pkt; + return 0; +} + +static int32_t parse_len(const char *line) +{ + char num[PKT_LEN_SIZE + 1]; + int i, error; + int32_t len; + const char *num_end; + + memcpy(num, line, PKT_LEN_SIZE); + num[PKT_LEN_SIZE] = '\0'; + + for (i = 0; i < PKT_LEN_SIZE; ++i) { + if (!isxdigit(num[i])) { + giterr_set(GITERR_NET, "Found invalid hex digit in length"); + return -1; + } + } + + if ((error = git__strtol32(&len, num, &num_end, 16)) < 0) + return error; + + return len; +} + +/* + * As per the documentation, the syntax is: + * + * pkt-line = data-pkt / flush-pkt + * data-pkt = pkt-len pkt-payload + * pkt-len = 4*(HEXDIG) + * pkt-payload = (pkt-len -4)*(OCTET) + * flush-pkt = "0000" + * + * Which means that the first four bytes are the length of the line, + * in ASCII hexadecimal (including itself) + */ + +int git_pkt_parse_line( + git_pkt **head, const char *line, const char **out, size_t bufflen) +{ + int ret; + int32_t len; + + /* Not even enough for the length */ + if (bufflen > 0 && bufflen < PKT_LEN_SIZE) + return GIT_EBUFS; + + len = parse_len(line); + if (len < 0) { + /* + * If we fail to parse the length, it might be because the + * server is trying to send us the packfile already. + */ + if (bufflen >= 4 && !git__prefixcmp(line, "PACK")) { + giterr_clear(); + *out = line; + return pack_pkt(head); + } + + return (int)len; + } + + /* + * If we were given a buffer length, then make sure there is + * enough in the buffer to satisfy this line + */ + if (bufflen > 0 && bufflen < (size_t)len) + return GIT_EBUFS; + + line += PKT_LEN_SIZE; + /* + * TODO: How do we deal with empty lines? Try again? with the next + * line? + */ + if (len == PKT_LEN_SIZE) { + *out = line; + return 0; + } + + if (len == 0) { /* Flush pkt */ + *out = line; + return flush_pkt(head); + } + + len -= PKT_LEN_SIZE; /* the encoded length includes its own size */ + + if (*line == GIT_SIDE_BAND_DATA) + ret = data_pkt(head, line, len); + else if (*line == GIT_SIDE_BAND_PROGRESS) + ret = sideband_progress_pkt(head, line, len); + else if (*line == GIT_SIDE_BAND_ERROR) + ret = sideband_error_pkt(head, line, len); + else if (!git__prefixcmp(line, "ACK")) + ret = ack_pkt(head, line, len); + else if (!git__prefixcmp(line, "NAK")) + ret = nak_pkt(head); + else if (!git__prefixcmp(line, "ERR ")) + ret = err_pkt(head, line, len); + else if (*line == '#') + ret = comment_pkt(head, line, len); + else if (!git__prefixcmp(line, "ok")) + ret = ok_pkt(head, line, len); + else if (!git__prefixcmp(line, "ng")) + ret = ng_pkt(head, line, len); + else if (!git__prefixcmp(line, "unpack")) + ret = unpack_pkt(head, line, len); + else + ret = ref_pkt(head, line, len); + + *out = line + len; + + return ret; +} + +void git_pkt_free(git_pkt *pkt) +{ + if (pkt->type == GIT_PKT_REF) { + git_pkt_ref *p = (git_pkt_ref *) pkt; + git__free(p->head.name); + git__free(p->head.symref_target); + } + + if (pkt->type == GIT_PKT_OK) { + git_pkt_ok *p = (git_pkt_ok *) pkt; + git__free(p->ref); + } + + if (pkt->type == GIT_PKT_NG) { + git_pkt_ng *p = (git_pkt_ng *) pkt; + git__free(p->ref); + git__free(p->msg); + } + + git__free(pkt); +} + +int git_pkt_buffer_flush(git_buf *buf) +{ + return git_buf_put(buf, pkt_flush_str, strlen(pkt_flush_str)); +} + +static int buffer_want_with_caps(const git_remote_head *head, transport_smart_caps *caps, git_buf *buf) +{ + git_buf str = GIT_BUF_INIT; + char oid[GIT_OID_HEXSZ +1] = {0}; + size_t len; + + /* Prefer multi_ack_detailed */ + if (caps->multi_ack_detailed) + git_buf_puts(&str, GIT_CAP_MULTI_ACK_DETAILED " "); + else if (caps->multi_ack) + git_buf_puts(&str, GIT_CAP_MULTI_ACK " "); + + /* Prefer side-band-64k if the server supports both */ + if (caps->side_band_64k) + git_buf_printf(&str, "%s ", GIT_CAP_SIDE_BAND_64K); + else if (caps->side_band) + git_buf_printf(&str, "%s ", GIT_CAP_SIDE_BAND); + + if (caps->include_tag) + git_buf_puts(&str, GIT_CAP_INCLUDE_TAG " "); + + if (caps->thin_pack) + git_buf_puts(&str, GIT_CAP_THIN_PACK " "); + + if (caps->ofs_delta) + git_buf_puts(&str, GIT_CAP_OFS_DELTA " "); + + if (git_buf_oom(&str)) + return -1; + + len = strlen("XXXXwant ") + GIT_OID_HEXSZ + 1 /* NUL */ + + git_buf_len(&str) + 1 /* LF */; + + if (len > 0xffff) { + giterr_set(GITERR_NET, + "Tried to produce packet with invalid length %d", len); + return -1; + } + + git_buf_grow_by(buf, len); + git_oid_fmt(oid, &head->oid); + git_buf_printf(buf, + "%04xwant %s %s\n", (unsigned int)len, oid, git_buf_cstr(&str)); + git_buf_free(&str); + + return git_buf_oom(buf); +} + +/* + * All "want" packets have the same length and format, so what we do + * is overwrite the OID each time. + */ + +int git_pkt_buffer_wants( + const git_remote_head * const *refs, + size_t count, + transport_smart_caps *caps, + git_buf *buf) +{ + size_t i = 0; + const git_remote_head *head; + + if (caps->common) { + for (; i < count; ++i) { + head = refs[i]; + if (!head->local) + break; + } + + if (buffer_want_with_caps(refs[i], caps, buf) < 0) + return -1; + + i++; + } + + for (; i < count; ++i) { + char oid[GIT_OID_HEXSZ]; + + head = refs[i]; + if (head->local) + continue; + + git_oid_fmt(oid, &head->oid); + git_buf_put(buf, pkt_want_prefix, strlen(pkt_want_prefix)); + git_buf_put(buf, oid, GIT_OID_HEXSZ); + git_buf_putc(buf, '\n'); + if (git_buf_oom(buf)) + return -1; + } + + return git_pkt_buffer_flush(buf); +} + +int git_pkt_buffer_have(git_oid *oid, git_buf *buf) +{ + char oidhex[GIT_OID_HEXSZ + 1]; + + memset(oidhex, 0x0, sizeof(oidhex)); + git_oid_fmt(oidhex, oid); + return git_buf_printf(buf, "%s%s\n", pkt_have_prefix, oidhex); +} + +int git_pkt_buffer_done(git_buf *buf) +{ + return git_buf_puts(buf, pkt_done_str); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_protocol.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_protocol.c new file mode 100644 index 000000000..f023db4df --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/smart_protocol.c @@ -0,0 +1,1035 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "git2.h" +#include "git2/odb_backend.h" + +#include "smart.h" +#include "refs.h" +#include "repository.h" +#include "push.h" +#include "pack-objects.h" +#include "remote.h" +#include "util.h" + +#define NETWORK_XFER_THRESHOLD (100*1024) +/* The minimal interval between progress updates (in seconds). */ +#define MIN_PROGRESS_UPDATE_INTERVAL 0.5 + +int git_smart__store_refs(transport_smart *t, int flushes) +{ + gitno_buffer *buf = &t->buffer; + git_vector *refs = &t->refs; + int error, flush = 0, recvd; + const char *line_end = NULL; + git_pkt *pkt = NULL; + size_t i; + + /* Clear existing refs in case git_remote_connect() is called again + * after git_remote_disconnect(). + */ + git_vector_foreach(refs, i, pkt) { + git_pkt_free(pkt); + } + git_vector_clear(refs); + pkt = NULL; + + do { + if (buf->offset > 0) + error = git_pkt_parse_line(&pkt, buf->data, &line_end, buf->offset); + else + error = GIT_EBUFS; + + if (error < 0 && error != GIT_EBUFS) + return error; + + if (error == GIT_EBUFS) { + if ((recvd = gitno_recv(buf)) < 0) + return recvd; + + if (recvd == 0 && !flush) { + giterr_set(GITERR_NET, "Early EOF"); + return -1; + } + + continue; + } + + gitno_consume(buf, line_end); + if (pkt->type == GIT_PKT_ERR) { + giterr_set(GITERR_NET, "Remote error: %s", ((git_pkt_err *)pkt)->error); + git__free(pkt); + return -1; + } + + if (pkt->type != GIT_PKT_FLUSH && git_vector_insert(refs, pkt) < 0) + return -1; + + if (pkt->type == GIT_PKT_FLUSH) { + flush++; + git_pkt_free(pkt); + } + } while (flush < flushes); + + return flush; +} + +static int append_symref(const char **out, git_vector *symrefs, const char *ptr) +{ + int error; + const char *end; + git_buf buf = GIT_BUF_INIT; + git_refspec *mapping = NULL; + + ptr += strlen(GIT_CAP_SYMREF); + if (*ptr != '=') + goto on_invalid; + + ptr++; + if (!(end = strchr(ptr, ' ')) && + !(end = strchr(ptr, '\0'))) + goto on_invalid; + + if ((error = git_buf_put(&buf, ptr, end - ptr)) < 0) + return error; + + /* symref mapping has refspec format */ + mapping = git__calloc(1, sizeof(git_refspec)); + GITERR_CHECK_ALLOC(mapping); + + error = git_refspec__parse(mapping, git_buf_cstr(&buf), true); + git_buf_free(&buf); + + /* if the error isn't OOM, then it's a parse error; let's use a nicer message */ + if (error < 0) { + if (giterr_last()->klass != GITERR_NOMEMORY) + goto on_invalid; + + return error; + } + + if ((error = git_vector_insert(symrefs, mapping)) < 0) + return error; + + *out = end; + return 0; + +on_invalid: + giterr_set(GITERR_NET, "remote sent invalid symref"); + git_refspec__free(mapping); + return -1; +} + +int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs) +{ + const char *ptr; + + /* No refs or capabilites, odd but not a problem */ + if (pkt == NULL || pkt->capabilities == NULL) + return 0; + + ptr = pkt->capabilities; + while (ptr != NULL && *ptr != '\0') { + if (*ptr == ' ') + ptr++; + + if (!git__prefixcmp(ptr, GIT_CAP_OFS_DELTA)) { + caps->common = caps->ofs_delta = 1; + ptr += strlen(GIT_CAP_OFS_DELTA); + continue; + } + + /* Keep multi_ack_detailed before multi_ack */ + if (!git__prefixcmp(ptr, GIT_CAP_MULTI_ACK_DETAILED)) { + caps->common = caps->multi_ack_detailed = 1; + ptr += strlen(GIT_CAP_MULTI_ACK_DETAILED); + continue; + } + + if (!git__prefixcmp(ptr, GIT_CAP_MULTI_ACK)) { + caps->common = caps->multi_ack = 1; + ptr += strlen(GIT_CAP_MULTI_ACK); + continue; + } + + if (!git__prefixcmp(ptr, GIT_CAP_INCLUDE_TAG)) { + caps->common = caps->include_tag = 1; + ptr += strlen(GIT_CAP_INCLUDE_TAG); + continue; + } + + /* Keep side-band check after side-band-64k */ + if (!git__prefixcmp(ptr, GIT_CAP_SIDE_BAND_64K)) { + caps->common = caps->side_band_64k = 1; + ptr += strlen(GIT_CAP_SIDE_BAND_64K); + continue; + } + + if (!git__prefixcmp(ptr, GIT_CAP_SIDE_BAND)) { + caps->common = caps->side_band = 1; + ptr += strlen(GIT_CAP_SIDE_BAND); + continue; + } + + if (!git__prefixcmp(ptr, GIT_CAP_DELETE_REFS)) { + caps->common = caps->delete_refs = 1; + ptr += strlen(GIT_CAP_DELETE_REFS); + continue; + } + + if (!git__prefixcmp(ptr, GIT_CAP_THIN_PACK)) { + caps->common = caps->thin_pack = 1; + ptr += strlen(GIT_CAP_THIN_PACK); + continue; + } + + if (!git__prefixcmp(ptr, GIT_CAP_SYMREF)) { + int error; + + if ((error = append_symref(&ptr, symrefs, ptr)) < 0) + return error; + + continue; + } + + /* We don't know this capability, so skip it */ + ptr = strchr(ptr, ' '); + } + + return 0; +} + +static int recv_pkt(git_pkt **out, gitno_buffer *buf) +{ + const char *ptr = buf->data, *line_end = ptr; + git_pkt *pkt = NULL; + int pkt_type, error = 0, ret; + + do { + if (buf->offset > 0) + error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->offset); + else + error = GIT_EBUFS; + + if (error == 0) + break; /* return the pkt */ + + if (error < 0 && error != GIT_EBUFS) + return error; + + if ((ret = gitno_recv(buf)) < 0) + return ret; + } while (error); + + gitno_consume(buf, line_end); + pkt_type = pkt->type; + if (out != NULL) + *out = pkt; + else + git__free(pkt); + + return pkt_type; +} + +static int store_common(transport_smart *t) +{ + git_pkt *pkt = NULL; + gitno_buffer *buf = &t->buffer; + int error; + + do { + if ((error = recv_pkt(&pkt, buf)) < 0) + return error; + + if (pkt->type == GIT_PKT_ACK) { + if (git_vector_insert(&t->common, pkt) < 0) + return -1; + } else { + git__free(pkt); + return 0; + } + + } while (1); + + return 0; +} + +static int fetch_setup_walk(git_revwalk **out, git_repository *repo) +{ + git_revwalk *walk = NULL; + git_strarray refs; + unsigned int i; + git_reference *ref; + int error; + + if ((error = git_reference_list(&refs, repo)) < 0) + return error; + + if ((error = git_revwalk_new(&walk, repo)) < 0) + return error; + + git_revwalk_sorting(walk, GIT_SORT_TIME); + + for (i = 0; i < refs.count; ++i) { + /* No tags */ + if (!git__prefixcmp(refs.strings[i], GIT_REFS_TAGS_DIR)) + continue; + + if ((error = git_reference_lookup(&ref, repo, refs.strings[i])) < 0) + goto on_error; + + if (git_reference_type(ref) == GIT_REF_SYMBOLIC) + continue; + + if ((error = git_revwalk_push(walk, git_reference_target(ref))) < 0) + goto on_error; + + git_reference_free(ref); + } + + git_strarray_free(&refs); + *out = walk; + return 0; + +on_error: + git_revwalk_free(walk); + git_reference_free(ref); + git_strarray_free(&refs); + return error; +} + +static int wait_while_ack(gitno_buffer *buf) +{ + int error; + git_pkt_ack *pkt = NULL; + + while (1) { + git__free(pkt); + + if ((error = recv_pkt((git_pkt **)&pkt, buf)) < 0) + return error; + + if (pkt->type == GIT_PKT_NAK) + break; + + if (pkt->type == GIT_PKT_ACK && + (pkt->status != GIT_ACK_CONTINUE && + pkt->status != GIT_ACK_COMMON)) { + git__free(pkt); + return 0; + } + } + + git__free(pkt); + return 0; +} + +int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, const git_remote_head * const *wants, size_t count) +{ + transport_smart *t = (transport_smart *)transport; + gitno_buffer *buf = &t->buffer; + git_buf data = GIT_BUF_INIT; + git_revwalk *walk = NULL; + int error = -1, pkt_type; + unsigned int i; + git_oid oid; + + if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0) + return error; + + if ((error = fetch_setup_walk(&walk, repo)) < 0) + goto on_error; + + /* + * Our support for ACK extensions is simply to parse them. On + * the first ACK we will accept that as enough common + * objects. We give up if we haven't found an answer in the + * first 256 we send. + */ + i = 0; + while (i < 256) { + error = git_revwalk_next(&oid, walk); + + if (error < 0) { + if (GIT_ITEROVER == error) + break; + + goto on_error; + } + + git_pkt_buffer_have(&oid, &data); + i++; + if (i % 20 == 0) { + if (t->cancelled.val) { + giterr_set(GITERR_NET, "The fetch was cancelled by the user"); + error = GIT_EUSER; + goto on_error; + } + + git_pkt_buffer_flush(&data); + if (git_buf_oom(&data)) { + error = -1; + goto on_error; + } + + if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0) + goto on_error; + + git_buf_clear(&data); + if (t->caps.multi_ack || t->caps.multi_ack_detailed) { + if ((error = store_common(t)) < 0) + goto on_error; + } else { + pkt_type = recv_pkt(NULL, buf); + + if (pkt_type == GIT_PKT_ACK) { + break; + } else if (pkt_type == GIT_PKT_NAK) { + continue; + } else if (pkt_type < 0) { + /* recv_pkt returned an error */ + error = pkt_type; + goto on_error; + } else { + giterr_set(GITERR_NET, "Unexpected pkt type"); + error = -1; + goto on_error; + } + } + } + + if (t->common.length > 0) + break; + + if (i % 20 == 0 && t->rpc) { + git_pkt_ack *pkt; + unsigned int i; + + if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0) + goto on_error; + + git_vector_foreach(&t->common, i, pkt) { + if ((error = git_pkt_buffer_have(&pkt->oid, &data)) < 0) + goto on_error; + } + + if (git_buf_oom(&data)) { + error = -1; + goto on_error; + } + } + } + + /* Tell the other end that we're done negotiating */ + if (t->rpc && t->common.length > 0) { + git_pkt_ack *pkt; + unsigned int i; + + if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0) + goto on_error; + + git_vector_foreach(&t->common, i, pkt) { + if ((error = git_pkt_buffer_have(&pkt->oid, &data)) < 0) + goto on_error; + } + + if (git_buf_oom(&data)) { + error = -1; + goto on_error; + } + } + + if ((error = git_pkt_buffer_done(&data)) < 0) + goto on_error; + + if (t->cancelled.val) { + giterr_set(GITERR_NET, "The fetch was cancelled by the user"); + error = GIT_EUSER; + goto on_error; + } + if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0) + goto on_error; + + git_buf_free(&data); + git_revwalk_free(walk); + + /* Now let's eat up whatever the server gives us */ + if (!t->caps.multi_ack && !t->caps.multi_ack_detailed) { + pkt_type = recv_pkt(NULL, buf); + + if (pkt_type < 0) { + return pkt_type; + } else if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) { + giterr_set(GITERR_NET, "Unexpected pkt type"); + return -1; + } + } else { + error = wait_while_ack(buf); + } + + return error; + +on_error: + git_revwalk_free(walk); + git_buf_free(&data); + return error; +} + +static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack, gitno_buffer *buf, git_transfer_progress *stats) +{ + int recvd; + + do { + if (t->cancelled.val) { + giterr_set(GITERR_NET, "The fetch was cancelled by the user"); + return GIT_EUSER; + } + + if (writepack->append(writepack, buf->data, buf->offset, stats) < 0) + return -1; + + gitno_consume_n(buf, buf->offset); + + if ((recvd = gitno_recv(buf)) < 0) + return recvd; + } while(recvd > 0); + + if (writepack->commit(writepack, stats) < 0) + return -1; + + return 0; +} + +struct network_packetsize_payload +{ + git_transfer_progress_cb callback; + void *payload; + git_transfer_progress *stats; + size_t last_fired_bytes; +}; + +static int network_packetsize(size_t received, void *payload) +{ + struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload; + + /* Accumulate bytes */ + npp->stats->received_bytes += received; + + /* Fire notification if the threshold is reached */ + if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) { + npp->last_fired_bytes = npp->stats->received_bytes; + + if (npp->callback(npp->stats, npp->payload)) + return GIT_EUSER; + } + + return 0; +} + +int git_smart__download_pack( + git_transport *transport, + git_repository *repo, + git_transfer_progress *stats, + git_transfer_progress_cb transfer_progress_cb, + void *progress_payload) +{ + transport_smart *t = (transport_smart *)transport; + gitno_buffer *buf = &t->buffer; + git_odb *odb; + struct git_odb_writepack *writepack = NULL; + int error = 0; + struct network_packetsize_payload npp = {0}; + + memset(stats, 0, sizeof(git_transfer_progress)); + + if (transfer_progress_cb) { + npp.callback = transfer_progress_cb; + npp.payload = progress_payload; + npp.stats = stats; + t->packetsize_cb = &network_packetsize; + t->packetsize_payload = &npp; + + /* We might have something in the buffer already from negotiate_fetch */ + if (t->buffer.offset > 0 && !t->cancelled.val) + if (t->packetsize_cb(t->buffer.offset, t->packetsize_payload)) + git_atomic_set(&t->cancelled, 1); + } + + if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 || + ((error = git_odb_write_pack(&writepack, odb, transfer_progress_cb, progress_payload)) != 0)) + goto done; + + /* + * If the remote doesn't support the side-band, we can feed + * the data directly to the pack writer. Otherwise, we need to + * check which one belongs there. + */ + if (!t->caps.side_band && !t->caps.side_band_64k) { + error = no_sideband(t, writepack, buf, stats); + goto done; + } + + do { + git_pkt *pkt = NULL; + + /* Check cancellation before network call */ + if (t->cancelled.val) { + giterr_clear(); + error = GIT_EUSER; + goto done; + } + + if ((error = recv_pkt(&pkt, buf)) >= 0) { + /* Check cancellation after network call */ + if (t->cancelled.val) { + giterr_clear(); + error = GIT_EUSER; + } else if (pkt->type == GIT_PKT_PROGRESS) { + if (t->progress_cb) { + git_pkt_progress *p = (git_pkt_progress *) pkt; + error = t->progress_cb(p->data, p->len, t->message_cb_payload); + } + } else if (pkt->type == GIT_PKT_DATA) { + git_pkt_data *p = (git_pkt_data *) pkt; + + if (p->len) + error = writepack->append(writepack, p->data, p->len, stats); + } else if (pkt->type == GIT_PKT_FLUSH) { + /* A flush indicates the end of the packfile */ + git__free(pkt); + break; + } + } + + git__free(pkt); + if (error < 0) + goto done; + + } while (1); + + /* + * Trailing execution of transfer_progress_cb, if necessary... + * Only the callback through the npp datastructure currently + * updates the last_fired_bytes value. It is possible that + * progress has already been reported with the correct + * "received_bytes" value, but until (if?) this is unified + * then we will report progress again to be sure that the + * correct last received_bytes value is reported. + */ + if (npp.callback && npp.stats->received_bytes > npp.last_fired_bytes) { + error = npp.callback(npp.stats, npp.payload); + if (error != 0) + goto done; + } + + error = writepack->commit(writepack, stats); + +done: + if (writepack) + writepack->free(writepack); + if (transfer_progress_cb) { + t->packetsize_cb = NULL; + t->packetsize_payload = NULL; + } + + return error; +} + +static int gen_pktline(git_buf *buf, git_push *push) +{ + push_spec *spec; + size_t i, len; + char old_id[GIT_OID_HEXSZ+1], new_id[GIT_OID_HEXSZ+1]; + + old_id[GIT_OID_HEXSZ] = '\0'; new_id[GIT_OID_HEXSZ] = '\0'; + + git_vector_foreach(&push->specs, i, spec) { + len = 2*GIT_OID_HEXSZ + 7 + strlen(spec->refspec.dst); + + if (i == 0) { + ++len; /* '\0' */ + if (push->report_status) + len += strlen(GIT_CAP_REPORT_STATUS) + 1; + len += strlen(GIT_CAP_SIDE_BAND_64K) + 1; + } + + git_oid_fmt(old_id, &spec->roid); + git_oid_fmt(new_id, &spec->loid); + + git_buf_printf(buf, "%04"PRIxZ"%s %s %s", len, old_id, new_id, spec->refspec.dst); + + if (i == 0) { + git_buf_putc(buf, '\0'); + /* Core git always starts their capabilities string with a space */ + if (push->report_status) { + git_buf_putc(buf, ' '); + git_buf_printf(buf, GIT_CAP_REPORT_STATUS); + } + git_buf_putc(buf, ' '); + git_buf_printf(buf, GIT_CAP_SIDE_BAND_64K); + } + + git_buf_putc(buf, '\n'); + } + + git_buf_puts(buf, "0000"); + return git_buf_oom(buf) ? -1 : 0; +} + +static int add_push_report_pkt(git_push *push, git_pkt *pkt) +{ + push_status *status; + + switch (pkt->type) { + case GIT_PKT_OK: + status = git__calloc(1, sizeof(push_status)); + GITERR_CHECK_ALLOC(status); + status->msg = NULL; + status->ref = git__strdup(((git_pkt_ok *)pkt)->ref); + if (!status->ref || + git_vector_insert(&push->status, status) < 0) { + git_push_status_free(status); + return -1; + } + break; + case GIT_PKT_NG: + status = git__calloc(1, sizeof(push_status)); + GITERR_CHECK_ALLOC(status); + status->ref = git__strdup(((git_pkt_ng *)pkt)->ref); + status->msg = git__strdup(((git_pkt_ng *)pkt)->msg); + if (!status->ref || !status->msg || + git_vector_insert(&push->status, status) < 0) { + git_push_status_free(status); + return -1; + } + break; + case GIT_PKT_UNPACK: + push->unpack_ok = ((git_pkt_unpack *)pkt)->unpack_ok; + break; + case GIT_PKT_FLUSH: + return GIT_ITEROVER; + default: + giterr_set(GITERR_NET, "report-status: protocol error"); + return -1; + } + + return 0; +} + +static int add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt) +{ + git_pkt *pkt; + const char *line = data_pkt->data, *line_end; + size_t line_len = data_pkt->len; + int error; + + while (line_len > 0) { + error = git_pkt_parse_line(&pkt, line, &line_end, line_len); + + if (error < 0) + return error; + + /* Advance in the buffer */ + line_len -= (line_end - line); + line = line_end; + + error = add_push_report_pkt(push, pkt); + + git_pkt_free(pkt); + + if (error < 0 && error != GIT_ITEROVER) + return error; + } + + return 0; +} + +static int parse_report(transport_smart *transport, git_push *push) +{ + git_pkt *pkt = NULL; + const char *line_end = NULL; + gitno_buffer *buf = &transport->buffer; + int error, recvd; + + for (;;) { + if (buf->offset > 0) + error = git_pkt_parse_line(&pkt, buf->data, + &line_end, buf->offset); + else + error = GIT_EBUFS; + + if (error < 0 && error != GIT_EBUFS) + return -1; + + if (error == GIT_EBUFS) { + if ((recvd = gitno_recv(buf)) < 0) + return recvd; + + if (recvd == 0) { + giterr_set(GITERR_NET, "Early EOF"); + return -1; + } + continue; + } + + gitno_consume(buf, line_end); + + error = 0; + + switch (pkt->type) { + case GIT_PKT_DATA: + /* This is a sideband packet which contains other packets */ + error = add_push_report_sideband_pkt(push, (git_pkt_data *)pkt); + break; + case GIT_PKT_ERR: + giterr_set(GITERR_NET, "report-status: Error reported: %s", + ((git_pkt_err *)pkt)->error); + error = -1; + break; + case GIT_PKT_PROGRESS: + if (transport->progress_cb) { + git_pkt_progress *p = (git_pkt_progress *) pkt; + error = transport->progress_cb(p->data, p->len, transport->message_cb_payload); + } + break; + default: + error = add_push_report_pkt(push, pkt); + break; + } + + git_pkt_free(pkt); + + /* add_push_report_pkt returns GIT_ITEROVER when it receives a flush */ + if (error == GIT_ITEROVER) + return 0; + + if (error < 0) + return error; + } +} + +static int add_ref_from_push_spec(git_vector *refs, push_spec *push_spec) +{ + git_pkt_ref *added = git__calloc(1, sizeof(git_pkt_ref)); + GITERR_CHECK_ALLOC(added); + + added->type = GIT_PKT_REF; + git_oid_cpy(&added->head.oid, &push_spec->loid); + added->head.name = git__strdup(push_spec->refspec.dst); + + if (!added->head.name || + git_vector_insert(refs, added) < 0) { + git_pkt_free((git_pkt *)added); + return -1; + } + + return 0; +} + +static int update_refs_from_report( + git_vector *refs, + git_vector *push_specs, + git_vector *push_report) +{ + git_pkt_ref *ref; + push_spec *push_spec; + push_status *push_status; + size_t i, j, refs_len; + int cmp; + + /* For each push spec we sent to the server, we should have + * gotten back a status packet in the push report */ + if (push_specs->length != push_report->length) { + giterr_set(GITERR_NET, "report-status: protocol error"); + return -1; + } + + /* We require that push_specs be sorted with push_spec_rref_cmp, + * and that push_report be sorted with push_status_ref_cmp */ + git_vector_sort(push_specs); + git_vector_sort(push_report); + + git_vector_foreach(push_specs, i, push_spec) { + push_status = git_vector_get(push_report, i); + + /* For each push spec we sent to the server, we should have + * gotten back a status packet in the push report which matches */ + if (strcmp(push_spec->refspec.dst, push_status->ref)) { + giterr_set(GITERR_NET, "report-status: protocol error"); + return -1; + } + } + + /* We require that refs be sorted with ref_name_cmp */ + git_vector_sort(refs); + i = j = 0; + refs_len = refs->length; + + /* Merge join push_specs with refs */ + while (i < push_specs->length && j < refs_len) { + push_spec = git_vector_get(push_specs, i); + push_status = git_vector_get(push_report, i); + ref = git_vector_get(refs, j); + + cmp = strcmp(push_spec->refspec.dst, ref->head.name); + + /* Iterate appropriately */ + if (cmp <= 0) i++; + if (cmp >= 0) j++; + + /* Add case */ + if (cmp < 0 && + !push_status->msg && + add_ref_from_push_spec(refs, push_spec) < 0) + return -1; + + /* Update case, delete case */ + if (cmp == 0 && + !push_status->msg) + git_oid_cpy(&ref->head.oid, &push_spec->loid); + } + + for (; i < push_specs->length; i++) { + push_spec = git_vector_get(push_specs, i); + push_status = git_vector_get(push_report, i); + + /* Add case */ + if (!push_status->msg && + add_ref_from_push_spec(refs, push_spec) < 0) + return -1; + } + + /* Remove any refs which we updated to have a zero OID. */ + git_vector_rforeach(refs, i, ref) { + if (git_oid_iszero(&ref->head.oid)) { + git_vector_remove(refs, i); + git_pkt_free((git_pkt *)ref); + } + } + + git_vector_sort(refs); + + return 0; +} + +struct push_packbuilder_payload +{ + git_smart_subtransport_stream *stream; + git_packbuilder *pb; + git_push_transfer_progress cb; + void *cb_payload; + size_t last_bytes; + double last_progress_report_time; +}; + +static int stream_thunk(void *buf, size_t size, void *data) +{ + int error = 0; + struct push_packbuilder_payload *payload = data; + + if ((error = payload->stream->write(payload->stream, (const char *)buf, size)) < 0) + return error; + + if (payload->cb) { + double current_time = git__timer(); + payload->last_bytes += size; + + if ((current_time - payload->last_progress_report_time) >= MIN_PROGRESS_UPDATE_INTERVAL) { + payload->last_progress_report_time = current_time; + error = payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload); + } + } + + return error; +} + +int git_smart__push(git_transport *transport, git_push *push) +{ + transport_smart *t = (transport_smart *)transport; + struct push_packbuilder_payload packbuilder_payload = {0}; + git_buf pktline = GIT_BUF_INIT; + int error = 0, need_pack = 0; + push_spec *spec; + unsigned int i; + + packbuilder_payload.pb = push->pb; + + if (push->transfer_progress_cb) { + packbuilder_payload.cb = push->transfer_progress_cb; + packbuilder_payload.cb_payload = push->transfer_progress_cb_payload; + } + +#ifdef PUSH_DEBUG +{ + git_remote_head *head; + char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0'; + + git_vector_foreach(&push->remote->refs, i, head) { + git_oid_fmt(hex, &head->oid); + fprintf(stderr, "%s (%s)\n", hex, head->name); + } + + git_vector_foreach(&push->specs, i, spec) { + git_oid_fmt(hex, &spec->roid); + fprintf(stderr, "%s (%s) -> ", hex, spec->lref); + git_oid_fmt(hex, &spec->loid); + fprintf(stderr, "%s (%s)\n", hex, spec->rref ? + spec->rref : spec->lref); + } +} +#endif + + /* + * Figure out if we need to send a packfile; which is in all + * cases except when we only send delete commands + */ + git_vector_foreach(&push->specs, i, spec) { + if (spec->refspec.src && spec->refspec.src[0] != '\0') { + need_pack = 1; + break; + } + } + + if ((error = git_smart__get_push_stream(t, &packbuilder_payload.stream)) < 0 || + (error = gen_pktline(&pktline, push)) < 0 || + (error = packbuilder_payload.stream->write(packbuilder_payload.stream, git_buf_cstr(&pktline), git_buf_len(&pktline))) < 0) + goto done; + + if (need_pack && + (error = git_packbuilder_foreach(push->pb, &stream_thunk, &packbuilder_payload)) < 0) + goto done; + + /* If we sent nothing or the server doesn't support report-status, then + * we consider the pack to have been unpacked successfully */ + if (!push->specs.length || !push->report_status) + push->unpack_ok = 1; + else if ((error = parse_report(t, push)) < 0) + goto done; + + /* If progress is being reported write the final report */ + if (push->transfer_progress_cb) { + error = push->transfer_progress_cb( + push->pb->nr_written, + push->pb->nr_objects, + packbuilder_payload.last_bytes, + push->transfer_progress_cb_payload); + + if (error < 0) + goto done; + } + + if (push->status.length) { + error = update_refs_from_report(&t->refs, &push->specs, &push->status); + if (error < 0) + goto done; + + error = git_smart__update_heads(t, NULL); + } + +done: + git_buf_free(&pktline); + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/ssh.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/ssh.c new file mode 100644 index 000000000..c5b081151 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/ssh.c @@ -0,0 +1,830 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifdef GIT_SSH +#include +#endif + +#include "git2.h" +#include "buffer.h" +#include "netops.h" +#include "smart.h" +#include "cred.h" +#include "socket_stream.h" + +#ifdef GIT_SSH + +#define OWNING_SUBTRANSPORT(s) ((ssh_subtransport *)(s)->parent.subtransport) + +static const char prefix_ssh[] = "ssh://"; +static const char cmd_uploadpack[] = "git-upload-pack"; +static const char cmd_receivepack[] = "git-receive-pack"; + +typedef struct { + git_smart_subtransport_stream parent; + git_stream *io; + LIBSSH2_SESSION *session; + LIBSSH2_CHANNEL *channel; + const char *cmd; + char *url; + unsigned sent_command : 1; +} ssh_stream; + +typedef struct { + git_smart_subtransport parent; + transport_smart *owner; + ssh_stream *current_stream; + git_cred *cred; + char *cmd_uploadpack; + char *cmd_receivepack; +} ssh_subtransport; + +static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *username); + +static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg) +{ + char *ssherr; + libssh2_session_last_error(session, &ssherr, NULL, 0); + + giterr_set(GITERR_SSH, "%s: %s", errmsg, ssherr); +} + +/* + * Create a git protocol request. + * + * For example: git-upload-pack '/libgit2/libgit2' + */ +static int gen_proto(git_buf *request, const char *cmd, const char *url) +{ + char *repo; + int len; + + if (!git__prefixcmp(url, prefix_ssh)) { + url = url + strlen(prefix_ssh); + repo = strchr(url, '/'); + } else { + repo = strchr(url, ':'); + if (repo) repo++; + } + + if (!repo) { + giterr_set(GITERR_NET, "Malformed git protocol URL"); + return -1; + } + + len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1; + + git_buf_grow(request, len); + git_buf_printf(request, "%s '%s'", cmd, repo); + git_buf_putc(request, '\0'); + + if (git_buf_oom(request)) + return -1; + + return 0; +} + +static int send_command(ssh_stream *s) +{ + int error; + git_buf request = GIT_BUF_INIT; + + error = gen_proto(&request, s->cmd, s->url); + if (error < 0) + goto cleanup; + + error = libssh2_channel_exec(s->channel, request.ptr); + if (error < LIBSSH2_ERROR_NONE) { + ssh_error(s->session, "SSH could not execute request"); + goto cleanup; + } + + s->sent_command = 1; + +cleanup: + git_buf_free(&request); + return error; +} + +static int ssh_stream_read( + git_smart_subtransport_stream *stream, + char *buffer, + size_t buf_size, + size_t *bytes_read) +{ + int rc; + ssh_stream *s = (ssh_stream *)stream; + + *bytes_read = 0; + + if (!s->sent_command && send_command(s) < 0) + return -1; + + if ((rc = libssh2_channel_read(s->channel, buffer, buf_size)) < LIBSSH2_ERROR_NONE) { + ssh_error(s->session, "SSH could not read data");; + return -1; + } + + *bytes_read = rc; + + return 0; +} + +static int ssh_stream_write( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + ssh_stream *s = (ssh_stream *)stream; + size_t off = 0; + ssize_t ret = 0; + + if (!s->sent_command && send_command(s) < 0) + return -1; + + do { + ret = libssh2_channel_write(s->channel, buffer + off, len - off); + if (ret < 0) + break; + + off += ret; + + } while (off < len); + + if (ret < 0) { + ssh_error(s->session, "SSH could not write data"); + return -1; + } + + return 0; +} + +static void ssh_stream_free(git_smart_subtransport_stream *stream) +{ + ssh_stream *s = (ssh_stream *)stream; + ssh_subtransport *t = OWNING_SUBTRANSPORT(s); + int ret; + + GIT_UNUSED(ret); + + t->current_stream = NULL; + + if (s->channel) { + libssh2_channel_close(s->channel); + libssh2_channel_free(s->channel); + s->channel = NULL; + } + + if (s->session) { + libssh2_session_free(s->session); + s->session = NULL; + } + + if (s->io) { + git_stream_close(s->io); + git_stream_free(s->io); + s->io = NULL; + } + + git__free(s->url); + git__free(s); +} + +static int ssh_stream_alloc( + ssh_subtransport *t, + const char *url, + const char *cmd, + git_smart_subtransport_stream **stream) +{ + ssh_stream *s; + + assert(stream); + + s = git__calloc(sizeof(ssh_stream), 1); + GITERR_CHECK_ALLOC(s); + + s->parent.subtransport = &t->parent; + s->parent.read = ssh_stream_read; + s->parent.write = ssh_stream_write; + s->parent.free = ssh_stream_free; + + s->cmd = cmd; + + s->url = git__strdup(url); + if (!s->url) { + git__free(s); + return -1; + } + + *stream = &s->parent; + return 0; +} + +static int git_ssh_extract_url_parts( + char **host, + char **username, + const char *url) +{ + char *colon, *at; + const char *start; + + colon = strchr(url, ':'); + + + at = strchr(url, '@'); + if (at) { + start = at + 1; + *username = git__substrdup(url, at - url); + GITERR_CHECK_ALLOC(*username); + } else { + start = url; + *username = NULL; + } + + if (colon == NULL || (colon < start)) { + giterr_set(GITERR_NET, "Malformed URL"); + return -1; + } + + *host = git__substrdup(start, colon - start); + GITERR_CHECK_ALLOC(*host); + + return 0; +} + +static int ssh_agent_auth(LIBSSH2_SESSION *session, git_cred_ssh_key *c) { + int rc = LIBSSH2_ERROR_NONE; + + struct libssh2_agent_publickey *curr, *prev = NULL; + + LIBSSH2_AGENT *agent = libssh2_agent_init(session); + + if (agent == NULL) + return -1; + + rc = libssh2_agent_connect(agent); + + if (rc != LIBSSH2_ERROR_NONE) + goto shutdown; + + rc = libssh2_agent_list_identities(agent); + + if (rc != LIBSSH2_ERROR_NONE) + goto shutdown; + + while (1) { + rc = libssh2_agent_get_identity(agent, &curr, prev); + + if (rc < 0) + goto shutdown; + + if (rc == 1) + goto shutdown; + + rc = libssh2_agent_userauth(agent, c->username, curr); + + if (rc == 0) + break; + + prev = curr; + } + +shutdown: + + if (rc != LIBSSH2_ERROR_NONE) + ssh_error(session, "error authenticating"); + + libssh2_agent_disconnect(agent); + libssh2_agent_free(agent); + + return rc; +} + +static int _git_ssh_authenticate_session( + LIBSSH2_SESSION* session, + git_cred* cred) +{ + int rc; + + do { + giterr_clear(); + switch (cred->credtype) { + case GIT_CREDTYPE_USERPASS_PLAINTEXT: { + git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; + rc = libssh2_userauth_password(session, c->username, c->password); + break; + } + case GIT_CREDTYPE_SSH_KEY: { + git_cred_ssh_key *c = (git_cred_ssh_key *)cred; + + if (c->privatekey) + rc = libssh2_userauth_publickey_fromfile( + session, c->username, c->publickey, + c->privatekey, c->passphrase); + else + rc = ssh_agent_auth(session, c); + + break; + } + case GIT_CREDTYPE_SSH_CUSTOM: { + git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred; + + rc = libssh2_userauth_publickey( + session, c->username, (const unsigned char *)c->publickey, + c->publickey_len, c->sign_callback, &c->payload); + break; + } + case GIT_CREDTYPE_SSH_INTERACTIVE: { + void **abstract = libssh2_session_abstract(session); + git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred; + + /* ideally, we should be able to set this by calling + * libssh2_session_init_ex() instead of libssh2_session_init(). + * libssh2's API is inconsistent here i.e. libssh2_userauth_publickey() + * allows you to pass the `abstract` as part of the call, whereas + * libssh2_userauth_keyboard_interactive() does not! + * + * The only way to set the `abstract` pointer is by calling + * libssh2_session_abstract(), which will replace the existing + * pointer as is done below. This is safe for now (at time of writing), + * but may not be valid in future. + */ + *abstract = c->payload; + + rc = libssh2_userauth_keyboard_interactive( + session, c->username, c->prompt_callback); + break; + } + default: + rc = LIBSSH2_ERROR_AUTHENTICATION_FAILED; + } + } while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); + + if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED || rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED) + return GIT_EAUTH; + + if (rc != LIBSSH2_ERROR_NONE) { + if (!giterr_last()) + ssh_error(session, "Failed to authenticate SSH session"); + return -1; + } + + return 0; +} + +static int request_creds(git_cred **out, ssh_subtransport *t, const char *user, int auth_methods) +{ + int error, no_callback = 0; + git_cred *cred = NULL; + + if (!t->owner->cred_acquire_cb) { + no_callback = 1; + } else { + error = t->owner->cred_acquire_cb(&cred, t->owner->url, user, auth_methods, + t->owner->cred_acquire_payload); + + if (error == GIT_PASSTHROUGH) + no_callback = 1; + else if (error < 0) + return error; + else if (!cred) { + giterr_set(GITERR_SSH, "Callback failed to initialize SSH credentials"); + return -1; + } + } + + if (no_callback) { + giterr_set(GITERR_SSH, "authentication required but no callback set"); + return -1; + } + + if (!(cred->credtype & auth_methods)) { + cred->free(cred); + giterr_set(GITERR_SSH, "callback returned unsupported credentials type"); + return -1; + } + + *out = cred; + + return 0; +} + +static int _git_ssh_session_create( + LIBSSH2_SESSION** session, + git_stream *io) +{ + int rc = 0; + LIBSSH2_SESSION* s; + git_socket_stream *socket = (git_socket_stream *) io; + + assert(session); + + s = libssh2_session_init(); + if (!s) { + giterr_set(GITERR_NET, "Failed to initialize SSH session"); + return -1; + } + + do { + rc = libssh2_session_startup(s, socket->s); + } while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); + + if (rc != LIBSSH2_ERROR_NONE) { + ssh_error(s, "Failed to start SSH session"); + libssh2_session_free(s); + return -1; + } + + libssh2_session_set_blocking(s, 1); + + *session = s; + + return 0; +} + +static int _git_ssh_setup_conn( + ssh_subtransport *t, + const char *url, + const char *cmd, + git_smart_subtransport_stream **stream) +{ + char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL; + const char *default_port="22"; + int auth_methods, error = 0; + ssh_stream *s; + git_cred *cred = NULL; + LIBSSH2_SESSION* session=NULL; + LIBSSH2_CHANNEL* channel=NULL; + + t->current_stream = NULL; + + *stream = NULL; + if (ssh_stream_alloc(t, url, cmd, stream) < 0) + return -1; + + s = (ssh_stream *)*stream; + s->session = NULL; + s->channel = NULL; + + if (!git__prefixcmp(url, prefix_ssh)) { + if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, default_port)) < 0) + goto done; + } else { + if ((error = git_ssh_extract_url_parts(&host, &user, url)) < 0) + goto done; + port = git__strdup(default_port); + GITERR_CHECK_ALLOC(port); + } + + if ((error = git_socket_stream_new(&s->io, host, port)) < 0 || + (error = git_stream_connect(s->io)) < 0) + goto done; + + if ((error = _git_ssh_session_create(&session, s->io)) < 0) + goto done; + + if (t->owner->certificate_check_cb != NULL) { + git_cert_hostkey cert = { 0 }, *cert_ptr; + const char *key; + + cert.cert_type = GIT_CERT_HOSTKEY_LIBSSH2; + + key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); + if (key != NULL) { + cert.type |= GIT_CERT_SSH_SHA1; + memcpy(&cert.hash_sha1, key, 20); + } + + key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + if (key != NULL) { + cert.type |= GIT_CERT_SSH_MD5; + memcpy(&cert.hash_md5, key, 16); + } + + if (cert.type == 0) { + giterr_set(GITERR_SSH, "unable to get the host key"); + error = -1; + goto done; + } + + /* We don't currently trust any hostkeys */ + giterr_clear(); + + cert_ptr = &cert; + + error = t->owner->certificate_check_cb((git_cert *) cert_ptr, 0, host, t->owner->message_cb_payload); + if (error < 0) { + if (!giterr_last()) + giterr_set(GITERR_NET, "user cancelled hostkey check"); + + goto done; + } + } + + /* we need the username to ask for auth methods */ + if (!user) { + if ((error = request_creds(&cred, t, NULL, GIT_CREDTYPE_USERNAME)) < 0) + goto done; + + user = git__strdup(((git_cred_username *) cred)->username); + cred->free(cred); + cred = NULL; + if (!user) + goto done; + } else if (user && pass) { + if ((error = git_cred_userpass_plaintext_new(&cred, user, pass)) < 0) + goto done; + } + + if ((error = list_auth_methods(&auth_methods, session, user)) < 0) + goto done; + + error = GIT_EAUTH; + /* if we already have something to try */ + if (cred && auth_methods & cred->credtype) + error = _git_ssh_authenticate_session(session, cred); + + while (error == GIT_EAUTH) { + if (cred) { + cred->free(cred); + cred = NULL; + } + + if ((error = request_creds(&cred, t, user, auth_methods)) < 0) + goto done; + + if (strcmp(user, git_cred__username(cred))) { + giterr_set(GITERR_SSH, "username does not match previous request"); + error = -1; + goto done; + } + + error = _git_ssh_authenticate_session(session, cred); + } + + if (error < 0) + goto done; + + channel = libssh2_channel_open_session(session); + if (!channel) { + error = -1; + ssh_error(session, "Failed to open SSH channel"); + goto done; + } + + libssh2_channel_set_blocking(channel, 1); + + s->session = session; + s->channel = channel; + + t->current_stream = s; + +done: + if (error < 0) { + if (*stream) + ssh_stream_free(*stream); + + if (session) + libssh2_session_free(session); + } + + if (cred) + cred->free(cred); + + git__free(host); + git__free(port); + git__free(path); + git__free(user); + git__free(pass); + + return error; +} + +static int ssh_uploadpack_ls( + ssh_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + const char *cmd = t->cmd_uploadpack ? t->cmd_uploadpack : cmd_uploadpack; + + return _git_ssh_setup_conn(t, url, cmd, stream); +} + +static int ssh_uploadpack( + ssh_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + GIT_UNUSED(url); + + if (t->current_stream) { + *stream = &t->current_stream->parent; + return 0; + } + + giterr_set(GITERR_NET, "Must call UPLOADPACK_LS before UPLOADPACK"); + return -1; +} + +static int ssh_receivepack_ls( + ssh_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + const char *cmd = t->cmd_receivepack ? t->cmd_receivepack : cmd_receivepack; + + + return _git_ssh_setup_conn(t, url, cmd, stream); +} + +static int ssh_receivepack( + ssh_subtransport *t, + const char *url, + git_smart_subtransport_stream **stream) +{ + GIT_UNUSED(url); + + if (t->current_stream) { + *stream = &t->current_stream->parent; + return 0; + } + + giterr_set(GITERR_NET, "Must call RECEIVEPACK_LS before RECEIVEPACK"); + return -1; +} + +static int _ssh_action( + git_smart_subtransport_stream **stream, + git_smart_subtransport *subtransport, + const char *url, + git_smart_service_t action) +{ + ssh_subtransport *t = (ssh_subtransport *) subtransport; + + switch (action) { + case GIT_SERVICE_UPLOADPACK_LS: + return ssh_uploadpack_ls(t, url, stream); + + case GIT_SERVICE_UPLOADPACK: + return ssh_uploadpack(t, url, stream); + + case GIT_SERVICE_RECEIVEPACK_LS: + return ssh_receivepack_ls(t, url, stream); + + case GIT_SERVICE_RECEIVEPACK: + return ssh_receivepack(t, url, stream); + } + + *stream = NULL; + return -1; +} + +static int _ssh_close(git_smart_subtransport *subtransport) +{ + ssh_subtransport *t = (ssh_subtransport *) subtransport; + + assert(!t->current_stream); + + GIT_UNUSED(t); + + return 0; +} + +static void _ssh_free(git_smart_subtransport *subtransport) +{ + ssh_subtransport *t = (ssh_subtransport *) subtransport; + + assert(!t->current_stream); + + git__free(t->cmd_uploadpack); + git__free(t->cmd_receivepack); + git__free(t); +} + +#define SSH_AUTH_PUBLICKEY "publickey" +#define SSH_AUTH_PASSWORD "password" +#define SSH_AUTH_KEYBOARD_INTERACTIVE "keyboard-interactive" + +static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *username) +{ + const char *list, *ptr; + + *out = 0; + + list = libssh2_userauth_list(session, username, strlen(username)); + + /* either error, or the remote accepts NONE auth, which is bizarre, let's punt */ + if (list == NULL && !libssh2_userauth_authenticated(session)) + return -1; + + ptr = list; + while (ptr) { + if (*ptr == ',') + ptr++; + + if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) { + *out |= GIT_CREDTYPE_SSH_KEY; + *out |= GIT_CREDTYPE_SSH_CUSTOM; + ptr += strlen(SSH_AUTH_PUBLICKEY); + continue; + } + + if (!git__prefixcmp(ptr, SSH_AUTH_PASSWORD)) { + *out |= GIT_CREDTYPE_USERPASS_PLAINTEXT; + ptr += strlen(SSH_AUTH_PASSWORD); + continue; + } + + if (!git__prefixcmp(ptr, SSH_AUTH_KEYBOARD_INTERACTIVE)) { + *out |= GIT_CREDTYPE_SSH_INTERACTIVE; + ptr += strlen(SSH_AUTH_KEYBOARD_INTERACTIVE); + continue; + } + + /* Skipt it if we don't know it */ + ptr = strchr(ptr, ','); + } + + return 0; +} +#endif + +int git_smart_subtransport_ssh( + git_smart_subtransport **out, git_transport *owner, void *param) +{ +#ifdef GIT_SSH + ssh_subtransport *t; + + assert(out); + + GIT_UNUSED(param); + + t = git__calloc(sizeof(ssh_subtransport), 1); + GITERR_CHECK_ALLOC(t); + + t->owner = (transport_smart *)owner; + t->parent.action = _ssh_action; + t->parent.close = _ssh_close; + t->parent.free = _ssh_free; + + *out = (git_smart_subtransport *) t; + return 0; +#else + GIT_UNUSED(owner); + GIT_UNUSED(param); + + assert(out); + *out = NULL; + + giterr_set(GITERR_INVALID, "Cannot create SSH transport. Library was built without SSH support"); + return -1; +#endif +} + +int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload) +{ +#ifdef GIT_SSH + git_strarray *paths = (git_strarray *) payload; + git_transport *transport; + transport_smart *smart; + ssh_subtransport *t; + int error; + git_smart_subtransport_definition ssh_definition = { + git_smart_subtransport_ssh, + 0, /* no RPC */ + NULL, + }; + + if (paths->count != 2) { + giterr_set(GITERR_SSH, "invalid ssh paths, must be two strings"); + return GIT_EINVALIDSPEC; + } + + if ((error = git_transport_smart(&transport, owner, &ssh_definition)) < 0) + return error; + + smart = (transport_smart *) transport; + t = (ssh_subtransport *) smart->wrapped; + + t->cmd_uploadpack = git__strdup(paths->strings[0]); + GITERR_CHECK_ALLOC(t->cmd_uploadpack); + t->cmd_receivepack = git__strdup(paths->strings[1]); + GITERR_CHECK_ALLOC(t->cmd_receivepack); + + *out = transport; + return 0; +#else + GIT_UNUSED(owner); + GIT_UNUSED(payload); + + assert(out); + *out = NULL; + + giterr_set(GITERR_INVALID, "Cannot create SSH transport. Library was built without SSH support"); + return -1; +#endif +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/transports/winhttp.c b/deps/libgit2-sys-0.2.17/libgit2/src/transports/winhttp.c new file mode 100644 index 000000000..f84e2ae9f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/transports/winhttp.c @@ -0,0 +1,1351 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifdef GIT_WINHTTP + +#include "git2.h" +#include "git2/transport.h" +#include "buffer.h" +#include "posix.h" +#include "netops.h" +#include "smart.h" +#include "remote.h" +#include "repository.h" + +#include +#include + +/* For IInternetSecurityManager zone check */ +#include +#include + +#define WIDEN2(s) L ## s +#define WIDEN(s) WIDEN2(s) + +#define MAX_CONTENT_TYPE_LEN 100 +#define WINHTTP_OPTION_PEERDIST_EXTENSION_STATE 109 +#define CACHED_POST_BODY_BUF_SIZE 4096 +#define UUID_LENGTH_CCH 32 +#define TIMEOUT_INFINITE -1 +#define DEFAULT_CONNECT_TIMEOUT 60000 +#ifndef WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH +#define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0 +#endif + +static const char *prefix_https = "https://"; +static const char *upload_pack_service = "upload-pack"; +static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack"; +static const char *upload_pack_service_url = "/git-upload-pack"; +static const char *receive_pack_service = "receive-pack"; +static const char *receive_pack_ls_service_url = "/info/refs?service=git-receive-pack"; +static const char *receive_pack_service_url = "/git-receive-pack"; +static const wchar_t *get_verb = L"GET"; +static const wchar_t *post_verb = L"POST"; +static const wchar_t *pragma_nocache = L"Pragma: no-cache"; +static const wchar_t *transfer_encoding = L"Transfer-Encoding: chunked"; +static const int no_check_cert_flags = SECURITY_FLAG_IGNORE_CERT_CN_INVALID | + SECURITY_FLAG_IGNORE_CERT_DATE_INVALID | + SECURITY_FLAG_IGNORE_UNKNOWN_CA; + +#if defined(__MINGW32__) +const CLSID CLSID_InternetSecurityManager = { 0x7B8A2D94, 0x0AC9, 0x11D1, + { 0x89, 0x6C, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4 } }; +const IID IID_IInternetSecurityManager = { 0x79EAC9EE, 0xBAF9, 0x11CE, + { 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B } }; +#endif + +#define OWNING_SUBTRANSPORT(s) ((winhttp_subtransport *)(s)->parent.subtransport) + +typedef enum { + GIT_WINHTTP_AUTH_BASIC = 1, + GIT_WINHTTP_AUTH_NEGOTIATE = 2, +} winhttp_authmechanism_t; + +typedef struct { + git_smart_subtransport_stream parent; + const char *service; + const char *service_url; + const wchar_t *verb; + HINTERNET request; + wchar_t *request_uri; + char *chunk_buffer; + unsigned chunk_buffer_len; + HANDLE post_body; + DWORD post_body_len; + unsigned sent_request : 1, + received_response : 1, + chunked : 1; +} winhttp_stream; + +typedef struct { + git_smart_subtransport parent; + transport_smart *owner; + gitno_connection_data connection_data; + git_cred *cred; + git_cred *url_cred; + int auth_mechanism; + HINTERNET session; + HINTERNET connection; +} winhttp_subtransport; + +static int apply_basic_credential(HINTERNET request, git_cred *cred) +{ + git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; + git_buf buf = GIT_BUF_INIT, raw = GIT_BUF_INIT; + wchar_t *wide = NULL; + int error = -1, wide_len; + + git_buf_printf(&raw, "%s:%s", c->username, c->password); + + if (git_buf_oom(&raw) || + git_buf_puts(&buf, "Authorization: Basic ") < 0 || + git_buf_encode_base64(&buf, git_buf_cstr(&raw), raw.size) < 0) + goto on_error; + + if ((wide_len = git__utf8_to_16_alloc(&wide, git_buf_cstr(&buf))) < 0) { + giterr_set(GITERR_OS, "Failed to convert string to wide form"); + goto on_error; + } + + if (!WinHttpAddRequestHeaders(request, wide, (ULONG) -1L, WINHTTP_ADDREQ_FLAG_ADD)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + goto on_error; + } + + error = 0; + +on_error: + /* We were dealing with plaintext passwords, so clean up after ourselves a bit. */ + if (wide) + memset(wide, 0x0, wide_len * sizeof(wchar_t)); + + if (buf.size) + memset(buf.ptr, 0x0, buf.size); + + if (raw.size) + memset(raw.ptr, 0x0, raw.size); + + git__free(wide); + git_buf_free(&buf); + git_buf_free(&raw); + return error; +} + +static int apply_default_credentials(HINTERNET request) +{ + /* Either the caller explicitly requested that default credentials be passed, + * or our fallback credential callback was invoked and checked that the target + * URI was in the appropriate Internet Explorer security zone. By setting this + * flag, we guarantee that the credentials are delivered by WinHTTP. The default + * is "medium" which applies to the intranet and sounds like it would correspond + * to Internet Explorer security zones, but in fact does not. */ + DWORD data = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW; + + if (!WinHttpSetOption(request, WINHTTP_OPTION_AUTOLOGON_POLICY, &data, sizeof(DWORD))) + return -1; + + return 0; +} + +static int fallback_cred_acquire_cb( + git_cred **cred, + const char *url, + const char *username_from_url, + unsigned int allowed_types, + void *payload) +{ + int error = 1; + + GIT_UNUSED(username_from_url); + GIT_UNUSED(payload); + + /* If the target URI supports integrated Windows authentication + * as an authentication mechanism */ + if (GIT_CREDTYPE_DEFAULT & allowed_types) { + wchar_t *wide_url; + + /* Convert URL to wide characters */ + if (git__utf8_to_16_alloc(&wide_url, url) < 0) { + giterr_set(GITERR_OS, "Failed to convert string to wide form"); + return -1; + } + + if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) { + IInternetSecurityManager* pISM; + + /* And if the target URI is in the My Computer, Intranet, or Trusted zones */ + if (SUCCEEDED(CoCreateInstance(&CLSID_InternetSecurityManager, NULL, + CLSCTX_ALL, &IID_IInternetSecurityManager, (void **)&pISM))) { + DWORD dwZone; + + if (SUCCEEDED(pISM->lpVtbl->MapUrlToZone(pISM, wide_url, &dwZone, 0)) && + (URLZONE_LOCAL_MACHINE == dwZone || + URLZONE_INTRANET == dwZone || + URLZONE_TRUSTED == dwZone)) { + git_cred *existing = *cred; + + if (existing) + existing->free(existing); + + /* Then use default Windows credentials to authenticate this request */ + error = git_cred_default_new(cred); + } + + pISM->lpVtbl->Release(pISM); + } + + CoUninitialize(); + } + + git__free(wide_url); + } + + return error; +} + +static int certificate_check(winhttp_stream *s, int valid) +{ + int error; + winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); + PCERT_CONTEXT cert_ctx; + DWORD cert_ctx_size = sizeof(cert_ctx); + git_cert_x509 cert; + + /* If there is no override, we should fail if WinHTTP doesn't think it's fine */ + if (t->owner->certificate_check_cb == NULL && !valid) + return GIT_ECERTIFICATE; + + if (t->owner->certificate_check_cb == NULL || !t->connection_data.use_ssl) + return 0; + + if (!WinHttpQueryOption(s->request, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert_ctx, &cert_ctx_size)) { + giterr_set(GITERR_OS, "failed to get server certificate"); + return -1; + } + + giterr_clear(); + cert.cert_type = GIT_CERT_X509; + cert.data = cert_ctx->pbCertEncoded; + cert.len = cert_ctx->cbCertEncoded; + error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->cred_acquire_payload); + CertFreeCertificateContext(cert_ctx); + + if (error < 0 && !giterr_last()) + giterr_set(GITERR_NET, "user cancelled certificate check"); + + return error; +} + +static void winhttp_stream_close(winhttp_stream *s) +{ + if (s->chunk_buffer) { + git__free(s->chunk_buffer); + s->chunk_buffer = NULL; + } + + if (s->post_body) { + CloseHandle(s->post_body); + s->post_body = NULL; + } + + if (s->request_uri) { + git__free(s->request_uri); + s->request_uri = NULL; + } + + if (s->request) { + WinHttpCloseHandle(s->request); + s->request = NULL; + } + + s->sent_request = 0; +} + +static int winhttp_stream_connect(winhttp_stream *s) +{ + winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); + git_buf buf = GIT_BUF_INIT; + char *proxy_url = NULL; + wchar_t ct[MAX_CONTENT_TYPE_LEN]; + LPCWSTR types[] = { L"*/*", NULL }; + BOOL peerdist = FALSE; + int error = -1; + unsigned long disable_redirects = WINHTTP_DISABLE_REDIRECTS; + int default_timeout = TIMEOUT_INFINITE; + int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT; + + /* Prepare URL */ + git_buf_printf(&buf, "%s%s", t->connection_data.path, s->service_url); + + if (git_buf_oom(&buf)) + return -1; + + /* Convert URL to wide characters */ + if (git__utf8_to_16_alloc(&s->request_uri, git_buf_cstr(&buf)) < 0) { + giterr_set(GITERR_OS, "Failed to convert string to wide form"); + goto on_error; + } + + /* Establish request */ + s->request = WinHttpOpenRequest( + t->connection, + s->verb, + s->request_uri, + NULL, + WINHTTP_NO_REFERER, + types, + t->connection_data.use_ssl ? WINHTTP_FLAG_SECURE : 0); + + if (!s->request) { + giterr_set(GITERR_OS, "Failed to open request"); + goto on_error; + } + + if (!WinHttpSetTimeouts(s->request, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { + giterr_set(GITERR_OS, "Failed to set timeouts for WinHTTP"); + goto on_error; + } + + /* Set proxy if necessary */ + if (git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url) < 0) + goto on_error; + + if (proxy_url) { + WINHTTP_PROXY_INFO proxy_info; + wchar_t *proxy_wide; + + /* Convert URL to wide characters */ + int proxy_wide_len = git__utf8_to_16_alloc(&proxy_wide, proxy_url); + + if (proxy_wide_len < 0) { + giterr_set(GITERR_OS, "Failed to convert string to wide form"); + goto on_error; + } + + /* Strip any trailing forward slash on the proxy URL; + * WinHTTP doesn't like it if one is present */ + if (proxy_wide_len > 1 && L'/' == proxy_wide[proxy_wide_len - 2]) + proxy_wide[proxy_wide_len - 2] = L'\0'; + + proxy_info.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; + proxy_info.lpszProxy = proxy_wide; + proxy_info.lpszProxyBypass = NULL; + + if (!WinHttpSetOption(s->request, + WINHTTP_OPTION_PROXY, + &proxy_info, + sizeof(WINHTTP_PROXY_INFO))) { + giterr_set(GITERR_OS, "Failed to set proxy"); + git__free(proxy_wide); + goto on_error; + } + + git__free(proxy_wide); + } + + /* Disable WinHTTP redirects so we can handle them manually. Why, you ask? + * http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/b2ff8879-ab9f-4218-8f09-16d25dff87ae + */ + if (!WinHttpSetOption(s->request, + WINHTTP_OPTION_DISABLE_FEATURE, + &disable_redirects, + sizeof(disable_redirects))) { + giterr_set(GITERR_OS, "Failed to disable redirects"); + goto on_error; + } + + /* Strip unwanted headers (X-P2P-PeerDist, X-P2P-PeerDistEx) that WinHTTP + * adds itself. This option may not be supported by the underlying + * platform, so we do not error-check it */ + WinHttpSetOption(s->request, + WINHTTP_OPTION_PEERDIST_EXTENSION_STATE, + &peerdist, + sizeof(peerdist)); + + /* Send Pragma: no-cache header */ + if (!WinHttpAddRequestHeaders(s->request, pragma_nocache, (ULONG) -1L, WINHTTP_ADDREQ_FLAG_ADD)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + goto on_error; + } + + if (post_verb == s->verb) { + /* Send Content-Type and Accept headers -- only necessary on a POST */ + git_buf_clear(&buf); + if (git_buf_printf(&buf, + "Content-Type: application/x-git-%s-request", + s->service) < 0) + goto on_error; + + if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { + giterr_set(GITERR_OS, "Failed to convert content-type to wide characters"); + goto on_error; + } + + if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, + WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + goto on_error; + } + + git_buf_clear(&buf); + if (git_buf_printf(&buf, + "Accept: application/x-git-%s-result", + s->service) < 0) + goto on_error; + + if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { + giterr_set(GITERR_OS, "Failed to convert accept header to wide characters"); + goto on_error; + } + + if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, + WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + goto on_error; + } + } + + /* If requested, disable certificate validation */ + if (t->connection_data.use_ssl) { + int flags; + + if (t->owner->parent.read_flags(&t->owner->parent, &flags) < 0) + goto on_error; + } + + /* If we have a credential on the subtransport, apply it to the request */ + if (t->cred && + t->cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT && + t->auth_mechanism == GIT_WINHTTP_AUTH_BASIC && + apply_basic_credential(s->request, t->cred) < 0) + goto on_error; + else if (t->cred && + t->cred->credtype == GIT_CREDTYPE_DEFAULT && + t->auth_mechanism == GIT_WINHTTP_AUTH_NEGOTIATE && + apply_default_credentials(s->request) < 0) + goto on_error; + + /* If no other credentials have been applied and the URL has username and + * password, use those */ + if (!t->cred && t->connection_data.user && t->connection_data.pass) { + if (!t->url_cred && + git_cred_userpass_plaintext_new(&t->url_cred, t->connection_data.user, t->connection_data.pass) < 0) + goto on_error; + if (apply_basic_credential(s->request, t->url_cred) < 0) + goto on_error; + } + + /* We've done everything up to calling WinHttpSendRequest. */ + + error = 0; + +on_error: + if (error < 0) + winhttp_stream_close(s); + + git__free(proxy_url); + git_buf_free(&buf); + return error; +} + +static int parse_unauthorized_response( + HINTERNET request, + int *allowed_types, + int *auth_mechanism) +{ + DWORD supported, first, target; + + *allowed_types = 0; + *auth_mechanism = 0; + + /* WinHttpQueryHeaders() must be called before WinHttpQueryAuthSchemes(). + * We can assume this was already done, since we know we are unauthorized. + */ + if (!WinHttpQueryAuthSchemes(request, &supported, &first, &target)) { + giterr_set(GITERR_OS, "Failed to parse supported auth schemes"); + return -1; + } + + if (WINHTTP_AUTH_SCHEME_BASIC & supported) { + *allowed_types |= GIT_CREDTYPE_USERPASS_PLAINTEXT; + *auth_mechanism = GIT_WINHTTP_AUTH_BASIC; + } + + if ((WINHTTP_AUTH_SCHEME_NTLM & supported) || + (WINHTTP_AUTH_SCHEME_NEGOTIATE & supported)) { + *allowed_types |= GIT_CREDTYPE_DEFAULT; + *auth_mechanism = GIT_WINHTTP_AUTH_NEGOTIATE; + } + + return 0; +} + +static int write_chunk(HINTERNET request, const char *buffer, size_t len) +{ + DWORD bytes_written; + git_buf buf = GIT_BUF_INIT; + + /* Chunk header */ + git_buf_printf(&buf, "%X\r\n", len); + + if (git_buf_oom(&buf)) + return -1; + + if (!WinHttpWriteData(request, + git_buf_cstr(&buf), (DWORD)git_buf_len(&buf), + &bytes_written)) { + git_buf_free(&buf); + giterr_set(GITERR_OS, "Failed to write chunk header"); + return -1; + } + + git_buf_free(&buf); + + /* Chunk body */ + if (!WinHttpWriteData(request, + buffer, (DWORD)len, + &bytes_written)) { + giterr_set(GITERR_OS, "Failed to write chunk"); + return -1; + } + + /* Chunk footer */ + if (!WinHttpWriteData(request, + "\r\n", 2, + &bytes_written)) { + giterr_set(GITERR_OS, "Failed to write chunk footer"); + return -1; + } + + return 0; +} + +static int winhttp_close_connection(winhttp_subtransport *t) +{ + int ret = 0; + + if (t->connection) { + if (!WinHttpCloseHandle(t->connection)) { + giterr_set(GITERR_OS, "Unable to close connection"); + ret = -1; + } + + t->connection = NULL; + } + + if (t->session) { + if (!WinHttpCloseHandle(t->session)) { + giterr_set(GITERR_OS, "Unable to close session"); + ret = -1; + } + + t->session = NULL; + } + + return ret; +} + +static int winhttp_connect( + winhttp_subtransport *t) +{ + wchar_t *ua = L"git/1.0 (libgit2 " WIDEN(LIBGIT2_VERSION) L")"; + wchar_t *wide_host; + int32_t port; + int error = -1; + int default_timeout = TIMEOUT_INFINITE; + int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT; + + t->session = NULL; + t->connection = NULL; + + /* Prepare port */ + if (git__strtol32(&port, t->connection_data.port, NULL, 10) < 0) + return -1; + + /* Prepare host */ + if (git__utf8_to_16_alloc(&wide_host, t->connection_data.host) < 0) { + giterr_set(GITERR_OS, "Unable to convert host to wide characters"); + return -1; + } + + /* Establish session */ + t->session = WinHttpOpen( + ua, + WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, + WINHTTP_NO_PROXY_NAME, + WINHTTP_NO_PROXY_BYPASS, + 0); + + if (!t->session) { + giterr_set(GITERR_OS, "Failed to init WinHTTP"); + goto on_error; + } + + if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { + giterr_set(GITERR_OS, "Failed to set timeouts for WinHTTP"); + goto on_error; + } + + + /* Establish connection */ + t->connection = WinHttpConnect( + t->session, + wide_host, + (INTERNET_PORT) port, + 0); + + if (!t->connection) { + giterr_set(GITERR_OS, "Failed to connect to host"); + goto on_error; + } + + error = 0; + +on_error: + if (error < 0) + winhttp_close_connection(t); + + git__free(wide_host); + + return error; +} + +static int do_send_request(winhttp_stream *s, size_t len, int ignore_length) +{ + if (ignore_length) { + if (!WinHttpSendRequest(s->request, + WINHTTP_NO_ADDITIONAL_HEADERS, 0, + WINHTTP_NO_REQUEST_DATA, 0, + WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0)) { + return -1; + } + } else { + if (!WinHttpSendRequest(s->request, + WINHTTP_NO_ADDITIONAL_HEADERS, 0, + WINHTTP_NO_REQUEST_DATA, 0, + len, 0)) { + return -1; + } + } + + return 0; +} + +static int send_request(winhttp_stream *s, size_t len, int ignore_length) +{ + int request_failed = 0, cert_valid = 1, error = 0; + DWORD ignore_flags; + + if ((error = do_send_request(s, len, ignore_length)) < 0) + request_failed = 1; + + if (request_failed) { + if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) { + giterr_set(GITERR_OS, "failed to send request"); + return -1; + } else { + cert_valid = 0; + } + } + + giterr_clear(); + if ((error = certificate_check(s, cert_valid)) < 0) { + if (!giterr_last()) + giterr_set(GITERR_OS, "user cancelled certificate check"); + + return error; + } + + /* if neither the request nor the certificate check returned errors, we're done */ + if (!request_failed) + return 0; + + ignore_flags = no_check_cert_flags; + + if (!WinHttpSetOption(s->request, WINHTTP_OPTION_SECURITY_FLAGS, &ignore_flags, sizeof(ignore_flags))) { + giterr_set(GITERR_OS, "failed to set security options"); + return -1; + } + + if ((error = do_send_request(s, len, ignore_length)) < 0) + giterr_set(GITERR_OS, "failed to send request"); + + return error; +} + +static int winhttp_stream_read( + git_smart_subtransport_stream *stream, + char *buffer, + size_t buf_size, + size_t *bytes_read) +{ + winhttp_stream *s = (winhttp_stream *)stream; + winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); + DWORD dw_bytes_read; + char replay_count = 0; + int error; + +replay: + /* Enforce a reasonable cap on the number of replays */ + if (++replay_count >= 7) { + giterr_set(GITERR_NET, "Too many redirects or authentication replays"); + return -1; + } + + /* Connect if necessary */ + if (!s->request && winhttp_stream_connect(s) < 0) + return -1; + + if (!s->received_response) { + DWORD status_code, status_code_length, content_type_length, bytes_written; + char expected_content_type_8[MAX_CONTENT_TYPE_LEN]; + wchar_t expected_content_type[MAX_CONTENT_TYPE_LEN], content_type[MAX_CONTENT_TYPE_LEN]; + + if (!s->sent_request) { + + if ((error = send_request(s, s->post_body_len, 0)) < 0) + return error; + + s->sent_request = 1; + } + + if (s->chunked) { + assert(s->verb == post_verb); + + /* Flush, if necessary */ + if (s->chunk_buffer_len > 0 && + write_chunk(s->request, s->chunk_buffer, s->chunk_buffer_len) < 0) + return -1; + + s->chunk_buffer_len = 0; + + /* Write the final chunk. */ + if (!WinHttpWriteData(s->request, + "0\r\n\r\n", 5, + &bytes_written)) { + giterr_set(GITERR_OS, "Failed to write final chunk"); + return -1; + } + } + else if (s->post_body) { + char *buffer; + DWORD len = s->post_body_len, bytes_read; + + if (INVALID_SET_FILE_POINTER == SetFilePointer(s->post_body, + 0, 0, FILE_BEGIN) && + NO_ERROR != GetLastError()) { + giterr_set(GITERR_OS, "Failed to reset file pointer"); + return -1; + } + + buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE); + + while (len > 0) { + DWORD bytes_written; + + if (!ReadFile(s->post_body, buffer, + min(CACHED_POST_BODY_BUF_SIZE, len), + &bytes_read, NULL) || + !bytes_read) { + git__free(buffer); + giterr_set(GITERR_OS, "Failed to read from temp file"); + return -1; + } + + if (!WinHttpWriteData(s->request, buffer, + bytes_read, &bytes_written)) { + git__free(buffer); + giterr_set(GITERR_OS, "Failed to write data"); + return -1; + } + + len -= bytes_read; + assert(bytes_read == bytes_written); + } + + git__free(buffer); + + /* Eagerly close the temp file */ + CloseHandle(s->post_body); + s->post_body = NULL; + } + + if (!WinHttpReceiveResponse(s->request, 0)) { + giterr_set(GITERR_OS, "Failed to receive response"); + return -1; + } + + /* Verify that we got a 200 back */ + status_code_length = sizeof(status_code); + + if (!WinHttpQueryHeaders(s->request, + WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, + WINHTTP_HEADER_NAME_BY_INDEX, + &status_code, &status_code_length, + WINHTTP_NO_HEADER_INDEX)) { + giterr_set(GITERR_OS, "Failed to retrieve status code"); + return -1; + } + + /* The implementation of WinHTTP prior to Windows 7 will not + * redirect to an identical URI. Some Git hosters use self-redirects + * as part of their DoS mitigation strategy. Check first to see if we + * have a redirect status code, and that we haven't already streamed + * a post body. (We can't replay a streamed POST.) */ + if (!s->chunked && + (HTTP_STATUS_MOVED == status_code || + HTTP_STATUS_REDIRECT == status_code || + (HTTP_STATUS_REDIRECT_METHOD == status_code && + get_verb == s->verb) || + HTTP_STATUS_REDIRECT_KEEP_VERB == status_code)) { + + /* Check for Windows 7. This workaround is only necessary on + * Windows Vista and earlier. Windows 7 is version 6.1. */ + wchar_t *location; + DWORD location_length; + char *location8; + + /* OK, fetch the Location header from the redirect. */ + if (WinHttpQueryHeaders(s->request, + WINHTTP_QUERY_LOCATION, + WINHTTP_HEADER_NAME_BY_INDEX, + WINHTTP_NO_OUTPUT_BUFFER, + &location_length, + WINHTTP_NO_HEADER_INDEX) || + GetLastError() != ERROR_INSUFFICIENT_BUFFER) { + giterr_set(GITERR_OS, "Failed to read Location header"); + return -1; + } + + location = git__malloc(location_length); + GITERR_CHECK_ALLOC(location); + + if (!WinHttpQueryHeaders(s->request, + WINHTTP_QUERY_LOCATION, + WINHTTP_HEADER_NAME_BY_INDEX, + location, + &location_length, + WINHTTP_NO_HEADER_INDEX)) { + giterr_set(GITERR_OS, "Failed to read Location header"); + git__free(location); + return -1; + } + + /* Convert the Location header to UTF-8 */ + if (git__utf16_to_8_alloc(&location8, location) < 0) { + giterr_set(GITERR_OS, "Failed to convert Location header to UTF-8"); + git__free(location); + return -1; + } + + git__free(location); + + /* Replay the request */ + winhttp_stream_close(s); + + if (!git__prefixcmp_icase(location8, prefix_https)) { + /* Upgrade to secure connection; disconnect and start over */ + if (gitno_connection_data_from_url(&t->connection_data, location8, s->service_url) < 0) { + git__free(location8); + return -1; + } + + winhttp_close_connection(t); + + if (winhttp_connect(t) < 0) + return -1; + } + + git__free(location8); + goto replay; + } + + /* Handle authentication failures */ + if (HTTP_STATUS_DENIED == status_code && get_verb == s->verb) { + int allowed_types; + + if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanism) < 0) + return -1; + + if (allowed_types && + (!t->cred || 0 == (t->cred->credtype & allowed_types))) { + int cred_error = 1; + + /* Start with the user-supplied credential callback, if present */ + if (t->owner->cred_acquire_cb) { + cred_error = t->owner->cred_acquire_cb(&t->cred, t->owner->url, + t->connection_data.user, allowed_types, t->owner->cred_acquire_payload); + + if (cred_error < 0) + return cred_error; + } + + /* Invoke the fallback credentials acquisition callback if necessary */ + if (cred_error > 0) { + cred_error = fallback_cred_acquire_cb(&t->cred, t->owner->url, + t->connection_data.user, allowed_types, NULL); + + if (cred_error < 0) + return cred_error; + } + + if (!cred_error) { + assert(t->cred); + + winhttp_stream_close(s); + + /* Successfully acquired a credential */ + goto replay; + } + } + } + + if (HTTP_STATUS_OK != status_code) { + giterr_set(GITERR_NET, "Request failed with status code: %d", status_code); + return -1; + } + + /* Verify that we got the correct content-type back */ + if (post_verb == s->verb) + p_snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-result", s->service); + else + p_snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-advertisement", s->service); + + if (git__utf8_to_16(expected_content_type, MAX_CONTENT_TYPE_LEN, expected_content_type_8) < 0) { + giterr_set(GITERR_OS, "Failed to convert expected content-type to wide characters"); + return -1; + } + + content_type_length = sizeof(content_type); + + if (!WinHttpQueryHeaders(s->request, + WINHTTP_QUERY_CONTENT_TYPE, + WINHTTP_HEADER_NAME_BY_INDEX, + &content_type, &content_type_length, + WINHTTP_NO_HEADER_INDEX)) { + giterr_set(GITERR_OS, "Failed to retrieve response content-type"); + return -1; + } + + if (wcscmp(expected_content_type, content_type)) { + giterr_set(GITERR_NET, "Received unexpected content-type"); + return -1; + } + + s->received_response = 1; + } + + if (!WinHttpReadData(s->request, + (LPVOID)buffer, + (DWORD)buf_size, + &dw_bytes_read)) + { + giterr_set(GITERR_OS, "Failed to read data"); + return -1; + } + + *bytes_read = dw_bytes_read; + + return 0; +} + +static int winhttp_stream_write_single( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + winhttp_stream *s = (winhttp_stream *)stream; + DWORD bytes_written; + int error; + + if (!s->request && winhttp_stream_connect(s) < 0) + return -1; + + /* This implementation of write permits only a single call. */ + if (s->sent_request) { + giterr_set(GITERR_NET, "Subtransport configured for only one write"); + return -1; + } + + if ((error = send_request(s, len, 0)) < 0) + return error; + + s->sent_request = 1; + + if (!WinHttpWriteData(s->request, + (LPCVOID)buffer, + (DWORD)len, + &bytes_written)) { + giterr_set(GITERR_OS, "Failed to write data"); + return -1; + } + + assert((DWORD)len == bytes_written); + + return 0; +} + +static int put_uuid_string(LPWSTR buffer, size_t buffer_len_cch) +{ + UUID uuid; + RPC_STATUS status = UuidCreate(&uuid); + int result; + + if (RPC_S_OK != status && + RPC_S_UUID_LOCAL_ONLY != status && + RPC_S_UUID_NO_ADDRESS != status) { + giterr_set(GITERR_NET, "Unable to generate name for temp file"); + return -1; + } + + if (buffer_len_cch < UUID_LENGTH_CCH + 1) { + giterr_set(GITERR_NET, "Buffer too small for name of temp file"); + return -1; + } + +#if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) + result = swprintf_s(buffer, buffer_len_cch, +#else + result = wsprintfW(buffer, +#endif + L"%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x", + uuid.Data1, uuid.Data2, uuid.Data3, + uuid.Data4[0], uuid.Data4[1], uuid.Data4[2], uuid.Data4[3], + uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]); + + if (result < UUID_LENGTH_CCH) { + giterr_set(GITERR_OS, "Unable to generate name for temp file"); + return -1; + } + + return 0; +} + +static int get_temp_file(LPWSTR buffer, DWORD buffer_len_cch) +{ + size_t len; + + if (!GetTempPathW(buffer_len_cch, buffer)) { + giterr_set(GITERR_OS, "Failed to get temp path"); + return -1; + } + + len = wcslen(buffer); + + if (buffer[len - 1] != '\\' && len < buffer_len_cch) + buffer[len++] = '\\'; + + if (put_uuid_string(&buffer[len], (size_t)buffer_len_cch - len) < 0) + return -1; + + return 0; +} + +static int winhttp_stream_write_buffered( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + winhttp_stream *s = (winhttp_stream *)stream; + DWORD bytes_written; + + if (!s->request && winhttp_stream_connect(s) < 0) + return -1; + + /* Buffer the payload, using a temporary file so we delegate + * memory management of the data to the operating system. */ + if (!s->post_body) { + wchar_t temp_path[MAX_PATH + 1]; + + if (get_temp_file(temp_path, MAX_PATH + 1) < 0) + return -1; + + s->post_body = CreateFileW(temp_path, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_DELETE, NULL, + CREATE_NEW, + FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_SEQUENTIAL_SCAN, + NULL); + + if (INVALID_HANDLE_VALUE == s->post_body) { + s->post_body = NULL; + giterr_set(GITERR_OS, "Failed to create temporary file"); + return -1; + } + } + + if (!WriteFile(s->post_body, buffer, (DWORD)len, &bytes_written, NULL)) { + giterr_set(GITERR_OS, "Failed to write to temporary file"); + return -1; + } + + assert((DWORD)len == bytes_written); + + s->post_body_len += bytes_written; + + return 0; +} + +static int winhttp_stream_write_chunked( + git_smart_subtransport_stream *stream, + const char *buffer, + size_t len) +{ + winhttp_stream *s = (winhttp_stream *)stream; + winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); + int error; + + if (!s->request && winhttp_stream_connect(s) < 0) + return -1; + + if (!s->sent_request) { + /* Send Transfer-Encoding: chunked header */ + if (!WinHttpAddRequestHeaders(s->request, + transfer_encoding, (ULONG) -1L, + WINHTTP_ADDREQ_FLAG_ADD)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + return -1; + } + + if ((error = send_request(s, 0, 1)) < 0) + return error; + + s->sent_request = 1; + } + + if (len > CACHED_POST_BODY_BUF_SIZE) { + /* Flush, if necessary */ + if (s->chunk_buffer_len > 0) { + if (write_chunk(s->request, s->chunk_buffer, s->chunk_buffer_len) < 0) + return -1; + + s->chunk_buffer_len = 0; + } + + /* Write chunk directly */ + if (write_chunk(s->request, buffer, len) < 0) + return -1; + } + else { + /* Append as much to the buffer as we can */ + int count = (int)min(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, len); + + if (!s->chunk_buffer) + s->chunk_buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE); + + memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count); + s->chunk_buffer_len += count; + buffer += count; + len -= count; + + /* Is the buffer full? If so, then flush */ + if (CACHED_POST_BODY_BUF_SIZE == s->chunk_buffer_len) { + if (write_chunk(s->request, s->chunk_buffer, s->chunk_buffer_len) < 0) + return -1; + + s->chunk_buffer_len = 0; + + /* Is there any remaining data from the source? */ + if (len > 0) { + memcpy(s->chunk_buffer, buffer, len); + s->chunk_buffer_len = (unsigned int)len; + } + } + } + + return 0; +} + +static void winhttp_stream_free(git_smart_subtransport_stream *stream) +{ + winhttp_stream *s = (winhttp_stream *)stream; + + winhttp_stream_close(s); + git__free(s); +} + +static int winhttp_stream_alloc(winhttp_subtransport *t, winhttp_stream **stream) +{ + winhttp_stream *s; + + if (!stream) + return -1; + + s = git__calloc(1, sizeof(winhttp_stream)); + GITERR_CHECK_ALLOC(s); + + s->parent.subtransport = &t->parent; + s->parent.read = winhttp_stream_read; + s->parent.write = winhttp_stream_write_single; + s->parent.free = winhttp_stream_free; + + *stream = s; + + return 0; +} + +static int winhttp_uploadpack_ls( + winhttp_subtransport *t, + winhttp_stream *s) +{ + GIT_UNUSED(t); + + s->service = upload_pack_service; + s->service_url = upload_pack_ls_service_url; + s->verb = get_verb; + + return 0; +} + +static int winhttp_uploadpack( + winhttp_subtransport *t, + winhttp_stream *s) +{ + GIT_UNUSED(t); + + s->service = upload_pack_service; + s->service_url = upload_pack_service_url; + s->verb = post_verb; + + return 0; +} + +static int winhttp_receivepack_ls( + winhttp_subtransport *t, + winhttp_stream *s) +{ + GIT_UNUSED(t); + + s->service = receive_pack_service; + s->service_url = receive_pack_ls_service_url; + s->verb = get_verb; + + return 0; +} + +static int winhttp_receivepack( + winhttp_subtransport *t, + winhttp_stream *s) +{ + GIT_UNUSED(t); + + /* WinHTTP only supports Transfer-Encoding: chunked + * on Windows Vista (NT 6.0) and higher. */ + s->chunked = git_has_win32_version(6, 0, 0); + + if (s->chunked) + s->parent.write = winhttp_stream_write_chunked; + else + s->parent.write = winhttp_stream_write_buffered; + + s->service = receive_pack_service; + s->service_url = receive_pack_service_url; + s->verb = post_verb; + + return 0; +} + +static int winhttp_action( + git_smart_subtransport_stream **stream, + git_smart_subtransport *subtransport, + const char *url, + git_smart_service_t action) +{ + winhttp_subtransport *t = (winhttp_subtransport *)subtransport; + winhttp_stream *s; + int ret = -1; + + if (!t->connection) + if ((ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0 || + (ret = winhttp_connect(t)) < 0) + return ret; + + if (winhttp_stream_alloc(t, &s) < 0) + return -1; + + if (!stream) + return -1; + + switch (action) + { + case GIT_SERVICE_UPLOADPACK_LS: + ret = winhttp_uploadpack_ls(t, s); + break; + + case GIT_SERVICE_UPLOADPACK: + ret = winhttp_uploadpack(t, s); + break; + + case GIT_SERVICE_RECEIVEPACK_LS: + ret = winhttp_receivepack_ls(t, s); + break; + + case GIT_SERVICE_RECEIVEPACK: + ret = winhttp_receivepack(t, s); + break; + + default: + assert(0); + } + + if (!ret) + *stream = &s->parent; + + return ret; +} + +static int winhttp_close(git_smart_subtransport *subtransport) +{ + winhttp_subtransport *t = (winhttp_subtransport *)subtransport; + + gitno_connection_data_free_ptrs(&t->connection_data); + memset(&t->connection_data, 0x0, sizeof(gitno_connection_data)); + + if (t->cred) { + t->cred->free(t->cred); + t->cred = NULL; + } + + if (t->url_cred) { + t->url_cred->free(t->url_cred); + t->url_cred = NULL; + } + + return winhttp_close_connection(t); +} + +static void winhttp_free(git_smart_subtransport *subtransport) +{ + winhttp_subtransport *t = (winhttp_subtransport *)subtransport; + + winhttp_close(subtransport); + + git__free(t); +} + +int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner, void *param) +{ + winhttp_subtransport *t; + + GIT_UNUSED(param); + + if (!out) + return -1; + + t = git__calloc(1, sizeof(winhttp_subtransport)); + GITERR_CHECK_ALLOC(t); + + t->owner = (transport_smart *)owner; + t->parent.action = winhttp_action; + t->parent.close = winhttp_close; + t->parent.free = winhttp_free; + + *out = (git_smart_subtransport *) t; + return 0; +} + +#endif /* GIT_WINHTTP */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.c b/deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.c new file mode 100644 index 000000000..b37be0f0d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.c @@ -0,0 +1,269 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "tree-cache.h" +#include "pool.h" +#include "tree.h" + +static git_tree_cache *find_child( + const git_tree_cache *tree, const char *path, const char *end) +{ + size_t i, dirlen = end ? (size_t)(end - path) : strlen(path); + + for (i = 0; i < tree->children_count; ++i) { + git_tree_cache *child = tree->children[i]; + + if (child->namelen == dirlen && !memcmp(path, child->name, dirlen)) + return child; + } + + return NULL; +} + +void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path) +{ + const char *ptr = path, *end; + + if (tree == NULL) + return; + + tree->entry_count = -1; + + while (ptr != NULL) { + end = strchr(ptr, '/'); + + if (end == NULL) /* End of path */ + break; + + tree = find_child(tree, ptr, end); + if (tree == NULL) /* We don't have that tree */ + return; + + tree->entry_count = -1; + ptr = end + 1; + } +} + +const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path) +{ + const char *ptr = path, *end; + + if (tree == NULL) { + return NULL; + } + + while (1) { + end = strchr(ptr, '/'); + + tree = find_child(tree, ptr, end); + if (tree == NULL) /* Can't find it */ + return NULL; + + if (end == NULL || *end + 1 == '\0') + return tree; + + ptr = end + 1; + } +} + +static int read_tree_internal(git_tree_cache **out, + const char **buffer_in, const char *buffer_end, + git_pool *pool) +{ + git_tree_cache *tree = NULL; + const char *name_start, *buffer; + int count; + + buffer = name_start = *buffer_in; + + if ((buffer = memchr(buffer, '\0', buffer_end - buffer)) == NULL) + goto corrupted; + + if (++buffer >= buffer_end) + goto corrupted; + + if (git_tree_cache_new(&tree, name_start, pool) < 0) + return -1; + + /* Blank-terminated ASCII decimal number of entries in this tree */ + if (git__strtol32(&count, buffer, &buffer, 10) < 0) + goto corrupted; + + tree->entry_count = count; + + if (*buffer != ' ' || ++buffer >= buffer_end) + goto corrupted; + + /* Number of children of the tree, newline-terminated */ + if (git__strtol32(&count, buffer, &buffer, 10) < 0 || count < 0) + goto corrupted; + + tree->children_count = count; + + if (*buffer != '\n' || ++buffer > buffer_end) + goto corrupted; + + /* The SHA1 is only there if it's not invalidated */ + if (tree->entry_count >= 0) { + /* 160-bit SHA-1 for this tree and it's children */ + if (buffer + GIT_OID_RAWSZ > buffer_end) + goto corrupted; + + git_oid_fromraw(&tree->oid, (const unsigned char *)buffer); + buffer += GIT_OID_RAWSZ; + } + + /* Parse children: */ + if (tree->children_count > 0) { + unsigned int i; + + tree->children = git_pool_malloc(pool, tree->children_count * sizeof(git_tree_cache *)); + GITERR_CHECK_ALLOC(tree->children); + + memset(tree->children, 0x0, tree->children_count * sizeof(git_tree_cache *)); + + for (i = 0; i < tree->children_count; ++i) { + if (read_tree_internal(&tree->children[i], &buffer, buffer_end, pool) < 0) + goto corrupted; + } + } + + *buffer_in = buffer; + *out = tree; + return 0; + + corrupted: + giterr_set(GITERR_INDEX, "Corrupted TREE extension in index"); + return -1; +} + +int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool) +{ + const char *buffer_end = buffer + buffer_size; + + if (read_tree_internal(tree, &buffer, buffer_end, pool) < 0) + return -1; + + if (buffer < buffer_end) { + giterr_set(GITERR_INDEX, "Corrupted TREE extension in index (unexpected trailing data)"); + return -1; + } + + return 0; +} + +static int read_tree_recursive(git_tree_cache *cache, const git_tree *tree, git_pool *pool) +{ + git_repository *repo; + size_t i, j, nentries, ntrees; + int error; + + repo = git_tree_owner(tree); + + git_oid_cpy(&cache->oid, git_tree_id(tree)); + nentries = git_tree_entrycount(tree); + + /* + * We make sure we know how many trees we need to allocate for + * so we don't have to realloc and change the pointers for the + * parents. + */ + ntrees = 0; + for (i = 0; i < nentries; i++) { + const git_tree_entry *entry; + + entry = git_tree_entry_byindex(tree, i); + if (git_tree_entry_filemode(entry) == GIT_FILEMODE_TREE) + ntrees++; + } + + cache->children_count = ntrees; + cache->children = git_pool_mallocz(pool, ntrees * sizeof(git_tree_cache *)); + GITERR_CHECK_ALLOC(cache->children); + + j = 0; + for (i = 0; i < nentries; i++) { + const git_tree_entry *entry; + git_tree *subtree; + + entry = git_tree_entry_byindex(tree, i); + if (git_tree_entry_filemode(entry) != GIT_FILEMODE_TREE) { + cache->entry_count++; + continue; + } + + if ((error = git_tree_cache_new(&cache->children[j], git_tree_entry_name(entry), pool)) < 0) + return error; + + if ((error = git_tree_lookup(&subtree, repo, git_tree_entry_id(entry))) < 0) + return error; + + error = read_tree_recursive(cache->children[j], subtree, pool); + git_tree_free(subtree); + cache->entry_count += cache->children[j]->entry_count; + j++; + + if (error < 0) + return error; + } + + return 0; +} + +int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool) +{ + int error; + git_tree_cache *cache; + + if ((error = git_tree_cache_new(&cache, "", pool)) < 0) + return error; + + if ((error = read_tree_recursive(cache, tree, pool)) < 0) + return error; + + *out = cache; + return 0; +} + +int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool) +{ + size_t name_len; + git_tree_cache *tree; + + name_len = strlen(name); + tree = git_pool_malloc(pool, sizeof(git_tree_cache) + name_len + 1); + GITERR_CHECK_ALLOC(tree); + + memset(tree, 0x0, sizeof(git_tree_cache)); + /* NUL-terminated tree name */ + tree->namelen = name_len; + memcpy(tree->name, name, name_len); + tree->name[name_len] = '\0'; + + *out = tree; + return 0; +} + +static void write_tree(git_buf *out, git_tree_cache *tree) +{ + size_t i; + + git_buf_printf(out, "%s%c%"PRIdZ" %"PRIuZ"\n", tree->name, 0, tree->entry_count, tree->children_count); + + if (tree->entry_count != -1) + git_buf_put(out, (const char *) &tree->oid, GIT_OID_RAWSZ); + + for (i = 0; i < tree->children_count; i++) + write_tree(out, tree->children[i]); +} + +int git_tree_cache_write(git_buf *out, git_tree_cache *tree) +{ + write_tree(out, tree); + + return git_buf_oom(out) ? -1 : 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.h b/deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.h new file mode 100644 index 000000000..c44ca7cf5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tree-cache.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_tree_cache_h__ +#define INCLUDE_tree_cache_h__ + +#include "common.h" +#include "pool.h" +#include "buffer.h" +#include "git2/oid.h" + +typedef struct git_tree_cache { + struct git_tree_cache **children; + size_t children_count; + + ssize_t entry_count; + git_oid oid; + size_t namelen; + char name[GIT_FLEX_ARRAY]; +} git_tree_cache; + +int git_tree_cache_write(git_buf *out, git_tree_cache *tree); +int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool); +void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path); +const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path); +int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool); +/** + * Read a tree as the root of the tree cache (like for `git read-tree`) + */ +int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool); +void git_tree_cache_free(git_tree_cache *tree); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tree.c b/deps/libgit2-sys-0.2.17/libgit2/src/tree.c new file mode 100644 index 000000000..47ed20dbb --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tree.c @@ -0,0 +1,982 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "commit.h" +#include "tree.h" +#include "git2/repository.h" +#include "git2/object.h" +#include "fileops.h" +#include "tree-cache.h" +#include "index.h" + +#define DEFAULT_TREE_SIZE 16 +#define MAX_FILEMODE_BYTES 6 + +GIT__USE_STRMAP + +static bool valid_filemode(const int filemode) +{ + return (filemode == GIT_FILEMODE_TREE + || filemode == GIT_FILEMODE_BLOB + || filemode == GIT_FILEMODE_BLOB_EXECUTABLE + || filemode == GIT_FILEMODE_LINK + || filemode == GIT_FILEMODE_COMMIT); +} + +GIT_INLINE(git_filemode_t) normalize_filemode(git_filemode_t filemode) +{ + /* Tree bits set, but it's not a commit */ + if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_TREE) + return GIT_FILEMODE_TREE; + + /* If any of the x bits are set */ + if (GIT_PERMS_IS_EXEC(filemode)) + return GIT_FILEMODE_BLOB_EXECUTABLE; + + /* 16XXXX means commit */ + if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_COMMIT) + return GIT_FILEMODE_COMMIT; + + /* 12XXXX means commit */ + if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_LINK) + return GIT_FILEMODE_LINK; + + /* Otherwise, return a blob */ + return GIT_FILEMODE_BLOB; +} + +static int valid_entry_name(git_repository *repo, const char *filename) +{ + return *filename != '\0' && + git_path_isvalid(repo, filename, + GIT_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT | GIT_PATH_REJECT_SLASH); +} + +static int entry_sort_cmp(const void *a, const void *b) +{ + const git_tree_entry *e1 = (const git_tree_entry *)a; + const git_tree_entry *e2 = (const git_tree_entry *)b; + + return git_path_cmp( + e1->filename, e1->filename_len, git_tree_entry__is_tree(e1), + e2->filename, e2->filename_len, git_tree_entry__is_tree(e2), + git__strncmp); +} + +int git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2) +{ + return entry_sort_cmp(e1, e2); +} + +int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2) +{ + return git_path_cmp( + e1->filename, e1->filename_len, git_tree_entry__is_tree(e1), + e2->filename, e2->filename_len, git_tree_entry__is_tree(e2), + git__strncasecmp); +} + +static git_tree_entry *alloc_entry(const char *filename) +{ + git_tree_entry *entry = NULL; + size_t filename_len = strlen(filename), tree_len; + + if (GIT_ADD_SIZET_OVERFLOW(&tree_len, sizeof(git_tree_entry), filename_len) || + GIT_ADD_SIZET_OVERFLOW(&tree_len, tree_len, 1) || + !(entry = git__malloc(tree_len))) + return NULL; + + memset(entry, 0x0, sizeof(git_tree_entry)); + memcpy(entry->filename, filename, filename_len); + entry->filename[filename_len] = 0; + entry->filename_len = filename_len; + + return entry; +} + +struct tree_key_search { + const char *filename; + size_t filename_len; +}; + +static int homing_search_cmp(const void *key, const void *array_member) +{ + const struct tree_key_search *ksearch = key; + const git_tree_entry *entry = array_member; + + const size_t len1 = ksearch->filename_len; + const size_t len2 = entry->filename_len; + + return memcmp( + ksearch->filename, + entry->filename, + len1 < len2 ? len1 : len2 + ); +} + +/* + * Search for an entry in a given tree. + * + * Note that this search is performed in two steps because + * of the way tree entries are sorted internally in git: + * + * Entries in a tree are not sorted alphabetically; two entries + * with the same root prefix will have different positions + * depending on whether they are folders (subtrees) or normal files. + * + * Consequently, it is not possible to find an entry on the tree + * with a binary search if you don't know whether the filename + * you're looking for is a folder or a normal file. + * + * To work around this, we first perform a homing binary search + * on the tree, using the minimal length root prefix of our filename. + * Once the comparisons for this homing search start becoming + * ambiguous because of folder vs file sorting, we look linearly + * around the area for our target file. + */ +static int tree_key_search( + size_t *at_pos, git_vector *entries, const char *filename, size_t filename_len) +{ + struct tree_key_search ksearch; + const git_tree_entry *entry; + size_t homing, i; + + ksearch.filename = filename; + ksearch.filename_len = filename_len; + + /* Initial homing search; find an entry on the tree with + * the same prefix as the filename we're looking for */ + if (git_vector_bsearch2(&homing, entries, &homing_search_cmp, &ksearch) < 0) + return GIT_ENOTFOUND; /* just a signal error; not passed back to user */ + + /* We found a common prefix. Look forward as long as + * there are entries that share the common prefix */ + for (i = homing; i < entries->length; ++i) { + entry = entries->contents[i]; + + if (homing_search_cmp(&ksearch, entry) < 0) + break; + + if (entry->filename_len == filename_len && + memcmp(filename, entry->filename, filename_len) == 0) { + if (at_pos) + *at_pos = i; + + return 0; + } + } + + /* If we haven't found our filename yet, look backwards + * too as long as we have entries with the same prefix */ + if (homing > 0) { + i = homing - 1; + + do { + entry = entries->contents[i]; + + if (homing_search_cmp(&ksearch, entry) > 0) + break; + + if (entry->filename_len == filename_len && + memcmp(filename, entry->filename, filename_len) == 0) { + if (at_pos) + *at_pos = i; + + return 0; + } + } while (i-- > 0); + } + + /* The filename doesn't exist at all */ + return GIT_ENOTFOUND; +} + +void git_tree_entry_free(git_tree_entry *entry) +{ + if (entry == NULL) + return; + + git__free(entry); +} + +int git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source) +{ + size_t total_size; + git_tree_entry *copy; + + assert(source); + + GITERR_CHECK_ALLOC_ADD(&total_size, sizeof(git_tree_entry), source->filename_len); + GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); + + copy = git__malloc(total_size); + GITERR_CHECK_ALLOC(copy); + + memcpy(copy, source, total_size); + + *dest = copy; + return 0; +} + +void git_tree__free(void *_tree) +{ + git_tree *tree = _tree; + size_t i; + git_tree_entry *e; + + git_vector_foreach(&tree->entries, i, e) + git_tree_entry_free(e); + + git_vector_free(&tree->entries); + git__free(tree); +} + +git_filemode_t git_tree_entry_filemode(const git_tree_entry *entry) +{ + return normalize_filemode(entry->attr); +} + +git_filemode_t git_tree_entry_filemode_raw(const git_tree_entry *entry) +{ + return entry->attr; +} + +const char *git_tree_entry_name(const git_tree_entry *entry) +{ + assert(entry); + return entry->filename; +} + +const git_oid *git_tree_entry_id(const git_tree_entry *entry) +{ + assert(entry); + return &entry->oid; +} + +git_otype git_tree_entry_type(const git_tree_entry *entry) +{ + assert(entry); + + if (S_ISGITLINK(entry->attr)) + return GIT_OBJ_COMMIT; + else if (S_ISDIR(entry->attr)) + return GIT_OBJ_TREE; + else + return GIT_OBJ_BLOB; +} + +int git_tree_entry_to_object( + git_object **object_out, + git_repository *repo, + const git_tree_entry *entry) +{ + assert(entry && object_out); + return git_object_lookup(object_out, repo, &entry->oid, GIT_OBJ_ANY); +} + +static const git_tree_entry *entry_fromname( + const git_tree *tree, const char *name, size_t name_len) +{ + size_t idx; + + /* be safe when we cast away constness - i.e. don't trigger a sort */ + assert(git_vector_is_sorted(&tree->entries)); + + if (tree_key_search(&idx, (git_vector *)&tree->entries, name, name_len) < 0) + return NULL; + + return git_vector_get(&tree->entries, idx); +} + +const git_tree_entry *git_tree_entry_byname( + const git_tree *tree, const char *filename) +{ + assert(tree && filename); + return entry_fromname(tree, filename, strlen(filename)); +} + +const git_tree_entry *git_tree_entry_byindex( + const git_tree *tree, size_t idx) +{ + assert(tree); + return git_vector_get(&tree->entries, idx); +} + +const git_tree_entry *git_tree_entry_byid( + const git_tree *tree, const git_oid *id) +{ + size_t i; + const git_tree_entry *e; + + assert(tree); + + git_vector_foreach(&tree->entries, i, e) { + if (memcmp(&e->oid.id, &id->id, sizeof(id->id)) == 0) + return e; + } + + return NULL; +} + +int git_tree__prefix_position(const git_tree *tree, const char *path) +{ + const git_vector *entries = &tree->entries; + struct tree_key_search ksearch; + size_t at_pos; + + if (!path) + return 0; + + ksearch.filename = path; + ksearch.filename_len = strlen(path); + + /* be safe when we cast away constness - i.e. don't trigger a sort */ + assert(git_vector_is_sorted(&tree->entries)); + + /* Find tree entry with appropriate prefix */ + git_vector_bsearch2( + &at_pos, (git_vector *)entries, &homing_search_cmp, &ksearch); + + for (; at_pos < entries->length; ++at_pos) { + const git_tree_entry *entry = entries->contents[at_pos]; + if (homing_search_cmp(&ksearch, entry) < 0) + break; + } + + for (; at_pos > 0; --at_pos) { + const git_tree_entry *entry = entries->contents[at_pos - 1]; + if (homing_search_cmp(&ksearch, entry) > 0) + break; + } + + return (int)at_pos; +} + +size_t git_tree_entrycount(const git_tree *tree) +{ + assert(tree); + return tree->entries.length; +} + +unsigned int git_treebuilder_entrycount(git_treebuilder *bld) +{ + assert(bld); + + return git_strmap_num_entries(bld->map); +} + +static int tree_error(const char *str, const char *path) +{ + if (path) + giterr_set(GITERR_TREE, "%s - %s", str, path); + else + giterr_set(GITERR_TREE, "%s", str); + return -1; +} + +int git_tree__parse(void *_tree, git_odb_object *odb_obj) +{ + git_tree *tree = _tree; + const char *buffer = git_odb_object_data(odb_obj); + const char *buffer_end = buffer + git_odb_object_size(odb_obj); + + if (git_vector_init(&tree->entries, DEFAULT_TREE_SIZE, entry_sort_cmp) < 0) + return -1; + + while (buffer < buffer_end) { + git_tree_entry *entry; + int attr; + + if (git__strtol32(&attr, buffer, &buffer, 8) < 0 || !buffer) + return tree_error("Failed to parse tree. Can't parse filemode", NULL); + + if (*buffer++ != ' ') + return tree_error("Failed to parse tree. Object is corrupted", NULL); + + if (memchr(buffer, 0, buffer_end - buffer) == NULL) + return tree_error("Failed to parse tree. Object is corrupted", NULL); + + /** Allocate the entry and store it in the entries vector */ + { + entry = alloc_entry(buffer); + GITERR_CHECK_ALLOC(entry); + + if (git_vector_insert(&tree->entries, entry) < 0) { + git__free(entry); + return -1; + } + + entry->attr = attr; + } + + while (buffer < buffer_end && *buffer != 0) + buffer++; + + buffer++; + + git_oid_fromraw(&entry->oid, (const unsigned char *)buffer); + buffer += GIT_OID_RAWSZ; + } + + git_vector_sort(&tree->entries); + + return 0; +} + +static size_t find_next_dir(const char *dirname, git_index *index, size_t start) +{ + size_t dirlen, i, entries = git_index_entrycount(index); + + dirlen = strlen(dirname); + for (i = start; i < entries; ++i) { + const git_index_entry *entry = git_index_get_byindex(index, i); + if (strlen(entry->path) < dirlen || + memcmp(entry->path, dirname, dirlen) || + (dirlen > 0 && entry->path[dirlen] != '/')) { + break; + } + } + + return i; +} + +static int append_entry( + git_treebuilder *bld, + const char *filename, + const git_oid *id, + git_filemode_t filemode) +{ + git_tree_entry *entry; + int error = 0; + + if (!valid_entry_name(bld->repo, filename)) + return tree_error("Failed to insert entry. Invalid name for a tree entry", filename); + + entry = alloc_entry(filename); + GITERR_CHECK_ALLOC(entry); + + git_oid_cpy(&entry->oid, id); + entry->attr = (uint16_t)filemode; + + git_strmap_insert(bld->map, entry->filename, entry, error); + if (error < 0) { + git_tree_entry_free(entry); + giterr_set(GITERR_TREE, "failed to append entry %s to the tree builder", filename); + return -1; + } + + return 0; +} + +static int write_tree( + git_oid *oid, + git_repository *repo, + git_index *index, + const char *dirname, + size_t start) +{ + git_treebuilder *bld = NULL; + size_t i, entries = git_index_entrycount(index); + int error; + size_t dirname_len = strlen(dirname); + const git_tree_cache *cache; + + cache = git_tree_cache_get(index->tree, dirname); + if (cache != NULL && cache->entry_count >= 0){ + git_oid_cpy(oid, &cache->oid); + return (int)find_next_dir(dirname, index, start); + } + + if ((error = git_treebuilder_new(&bld, repo, NULL)) < 0 || bld == NULL) + return -1; + + /* + * This loop is unfortunate, but necessary. The index doesn't have + * any directores, so we need to handle that manually, and we + * need to keep track of the current position. + */ + for (i = start; i < entries; ++i) { + const git_index_entry *entry = git_index_get_byindex(index, i); + const char *filename, *next_slash; + + /* + * If we've left our (sub)tree, exit the loop and return. The + * first check is an early out (and security for the + * third). The second check is a simple prefix comparison. The + * third check catches situations where there is a directory + * win32/sys and a file win32mmap.c. Without it, the following + * code believes there is a file win32/mmap.c + */ + if (strlen(entry->path) < dirname_len || + memcmp(entry->path, dirname, dirname_len) || + (dirname_len > 0 && entry->path[dirname_len] != '/')) { + break; + } + + filename = entry->path + dirname_len; + if (*filename == '/') + filename++; + next_slash = strchr(filename, '/'); + if (next_slash) { + git_oid sub_oid; + int written; + char *subdir, *last_comp; + + subdir = git__strndup(entry->path, next_slash - entry->path); + GITERR_CHECK_ALLOC(subdir); + + /* Write out the subtree */ + written = write_tree(&sub_oid, repo, index, subdir, i); + if (written < 0) { + git__free(subdir); + goto on_error; + } else { + i = written - 1; /* -1 because of the loop increment */ + } + + /* + * We need to figure out what we want toinsert + * into this tree. If we're traversing + * deps/zlib/, then we only want to write + * 'zlib' into the tree. + */ + last_comp = strrchr(subdir, '/'); + if (last_comp) { + last_comp++; /* Get rid of the '/' */ + } else { + last_comp = subdir; + } + + error = append_entry(bld, last_comp, &sub_oid, S_IFDIR); + git__free(subdir); + if (error < 0) + goto on_error; + } else { + error = append_entry(bld, filename, &entry->id, entry->mode); + if (error < 0) + goto on_error; + } + } + + if (git_treebuilder_write(oid, bld) < 0) + goto on_error; + + git_treebuilder_free(bld); + return (int)i; + +on_error: + git_treebuilder_free(bld); + return -1; +} + +int git_tree__write_index( + git_oid *oid, git_index *index, git_repository *repo) +{ + int ret; + git_tree *tree; + bool old_ignore_case = false; + + assert(oid && index && repo); + + if (git_index_has_conflicts(index)) { + giterr_set(GITERR_INDEX, + "Cannot create a tree from a not fully merged index."); + return GIT_EUNMERGED; + } + + if (index->tree != NULL && index->tree->entry_count >= 0) { + git_oid_cpy(oid, &index->tree->oid); + return 0; + } + + /* The tree cache didn't help us; we'll have to write + * out a tree. If the index is ignore_case, we must + * make it case-sensitive for the duration of the tree-write + * operation. */ + + if (index->ignore_case) { + old_ignore_case = true; + git_index__set_ignore_case(index, false); + } + + ret = write_tree(oid, repo, index, "", 0); + + if (old_ignore_case) + git_index__set_ignore_case(index, true); + + index->tree = NULL; + + if (ret < 0) + return ret; + + git_pool_clear(&index->tree_pool); + + if ((ret = git_tree_lookup(&tree, repo, oid)) < 0) + return ret; + + /* Read the tree cache into the index */ + ret = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool); + git_tree_free(tree); + + return ret; +} + +int git_treebuilder_new( + git_treebuilder **builder_p, + git_repository *repo, + const git_tree *source) +{ + git_treebuilder *bld; + size_t i; + + assert(builder_p && repo); + + bld = git__calloc(1, sizeof(git_treebuilder)); + GITERR_CHECK_ALLOC(bld); + + bld->repo = repo; + + if (git_strmap_alloc(&bld->map) < 0) { + git__free(bld); + return -1; + } + + if (source != NULL) { + git_tree_entry *entry_src; + + git_vector_foreach(&source->entries, i, entry_src) { + if (append_entry( + bld, entry_src->filename, + &entry_src->oid, + entry_src->attr) < 0) + goto on_error; + } + } + + *builder_p = bld; + return 0; + +on_error: + git_treebuilder_free(bld); + return -1; +} + +int git_treebuilder_insert( + const git_tree_entry **entry_out, + git_treebuilder *bld, + const char *filename, + const git_oid *id, + git_filemode_t filemode) +{ + git_tree_entry *entry; + int error; + git_strmap_iter pos; + + assert(bld && id && filename); + + if (!valid_filemode(filemode)) + return tree_error("Failed to insert entry. Invalid filemode for file", filename); + + if (!valid_entry_name(bld->repo, filename)) + return tree_error("Failed to insert entry. Invalid name for a tree entry", filename); + + pos = git_strmap_lookup_index(bld->map, filename); + if (git_strmap_valid_index(bld->map, pos)) { + entry = git_strmap_value_at(bld->map, pos); + } else { + entry = alloc_entry(filename); + GITERR_CHECK_ALLOC(entry); + + git_strmap_insert(bld->map, entry->filename, entry, error); + + if (error < 0) { + git_tree_entry_free(entry); + giterr_set(GITERR_TREE, "failed to insert %s", filename); + return -1; + } + } + + git_oid_cpy(&entry->oid, id); + entry->attr = filemode; + + if (entry_out) + *entry_out = entry; + + return 0; +} + +static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filename) +{ + git_tree_entry *entry = NULL; + git_strmap_iter pos; + + assert(bld && filename); + + pos = git_strmap_lookup_index(bld->map, filename); + if (git_strmap_valid_index(bld->map, pos)) + entry = git_strmap_value_at(bld->map, pos); + + return entry; +} + +const git_tree_entry *git_treebuilder_get(git_treebuilder *bld, const char *filename) +{ + return treebuilder_get(bld, filename); +} + +int git_treebuilder_remove(git_treebuilder *bld, const char *filename) +{ + git_tree_entry *entry = treebuilder_get(bld, filename); + + if (entry == NULL) + return tree_error("Failed to remove entry. File isn't in the tree", filename); + + git_strmap_delete(bld->map, filename); + git_tree_entry_free(entry); + + return 0; +} + +int git_treebuilder_write(git_oid *oid, git_treebuilder *bld) +{ + int error = 0; + size_t i, entrycount; + git_buf tree = GIT_BUF_INIT; + git_odb *odb; + git_tree_entry *entry; + git_vector entries; + + assert(bld); + + entrycount = git_strmap_num_entries(bld->map); + if (git_vector_init(&entries, entrycount, entry_sort_cmp) < 0) + return -1; + + git_strmap_foreach_value(bld->map, entry, { + if (git_vector_insert(&entries, entry) < 0) + return -1; + }); + + git_vector_sort(&entries); + + /* Grow the buffer beforehand to an estimated size */ + error = git_buf_grow(&tree, entrycount * 72); + + for (i = 0; i < entries.length && !error; ++i) { + git_tree_entry *entry = git_vector_get(&entries, i); + + git_buf_printf(&tree, "%o ", entry->attr); + git_buf_put(&tree, entry->filename, entry->filename_len + 1); + git_buf_put(&tree, (char *)entry->oid.id, GIT_OID_RAWSZ); + + if (git_buf_oom(&tree)) + error = -1; + } + + git_vector_free(&entries); + + if (!error && + !(error = git_repository_odb__weakptr(&odb, bld->repo))) + error = git_odb_write(oid, odb, tree.ptr, tree.size, GIT_OBJ_TREE); + + git_buf_free(&tree); + return error; +} + +void git_treebuilder_filter( + git_treebuilder *bld, + git_treebuilder_filter_cb filter, + void *payload) +{ + const char *filename; + git_tree_entry *entry; + + assert(bld && filter); + + git_strmap_foreach(bld->map, filename, entry, { + if (filter(entry, payload)) { + git_strmap_delete(bld->map, filename); + git_tree_entry_free(entry); + } + }); +} + +void git_treebuilder_clear(git_treebuilder *bld) +{ + git_tree_entry *e; + + assert(bld); + + git_strmap_foreach_value(bld->map, e, git_tree_entry_free(e)); + git_strmap_clear(bld->map); +} + +void git_treebuilder_free(git_treebuilder *bld) +{ + if (bld == NULL) + return; + + git_treebuilder_clear(bld); + git_strmap_free(bld->map); + git__free(bld); +} + +static size_t subpath_len(const char *path) +{ + const char *slash_pos = strchr(path, '/'); + if (slash_pos == NULL) + return strlen(path); + + return slash_pos - path; +} + +int git_tree_entry_bypath( + git_tree_entry **entry_out, + const git_tree *root, + const char *path) +{ + int error = 0; + git_tree *subtree; + const git_tree_entry *entry; + size_t filename_len; + + /* Find how long is the current path component (i.e. + * the filename between two slashes */ + filename_len = subpath_len(path); + + if (filename_len == 0) { + giterr_set(GITERR_TREE, "Invalid tree path given"); + return GIT_ENOTFOUND; + } + + entry = entry_fromname(root, path, filename_len); + + if (entry == NULL) { + giterr_set(GITERR_TREE, + "The path '%s' does not exist in the given tree", path); + return GIT_ENOTFOUND; + } + + switch (path[filename_len]) { + case '/': + /* If there are more components in the path... + * then this entry *must* be a tree */ + if (!git_tree_entry__is_tree(entry)) { + giterr_set(GITERR_TREE, + "The path '%s' does not exist in the given tree", path); + return GIT_ENOTFOUND; + } + + /* If there's only a slash left in the path, we + * return the current entry; otherwise, we keep + * walking down the path */ + if (path[filename_len + 1] != '\0') + break; + + case '\0': + /* If there are no more components in the path, return + * this entry */ + return git_tree_entry_dup(entry_out, entry); + } + + if (git_tree_lookup(&subtree, root->object.repo, &entry->oid) < 0) + return -1; + + error = git_tree_entry_bypath( + entry_out, + subtree, + path + filename_len + 1 + ); + + git_tree_free(subtree); + return error; +} + +static int tree_walk( + const git_tree *tree, + git_treewalk_cb callback, + git_buf *path, + void *payload, + bool preorder) +{ + int error = 0; + size_t i; + const git_tree_entry *entry; + + git_vector_foreach(&tree->entries, i, entry) { + if (preorder) { + error = callback(path->ptr, entry, payload); + if (error < 0) { /* negative value stops iteration */ + giterr_set_after_callback_function(error, "git_tree_walk"); + break; + } + if (error > 0) { /* positive value skips this entry */ + error = 0; + continue; + } + } + + if (git_tree_entry__is_tree(entry)) { + git_tree *subtree; + size_t path_len = git_buf_len(path); + + error = git_tree_lookup(&subtree, tree->object.repo, &entry->oid); + if (error < 0) + break; + + /* append the next entry to the path */ + git_buf_puts(path, entry->filename); + git_buf_putc(path, '/'); + + if (git_buf_oom(path)) + error = -1; + else + error = tree_walk(subtree, callback, path, payload, preorder); + + git_tree_free(subtree); + if (error != 0) + break; + + git_buf_truncate(path, path_len); + } + + if (!preorder) { + error = callback(path->ptr, entry, payload); + if (error < 0) { /* negative value stops iteration */ + giterr_set_after_callback_function(error, "git_tree_walk"); + break; + } + error = 0; + } + } + + return error; +} + +int git_tree_walk( + const git_tree *tree, + git_treewalk_mode mode, + git_treewalk_cb callback, + void *payload) +{ + int error = 0; + git_buf root_path = GIT_BUF_INIT; + + if (mode != GIT_TREEWALK_POST && mode != GIT_TREEWALK_PRE) { + giterr_set(GITERR_INVALID, "Invalid walking mode for tree walk"); + return -1; + } + + error = tree_walk( + tree, callback, &root_path, payload, (mode == GIT_TREEWALK_PRE)); + + git_buf_free(&root_path); + + return error; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tree.h b/deps/libgit2-sys-0.2.17/libgit2/src/tree.h new file mode 100644 index 000000000..d01b6fd41 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tree.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_tree_h__ +#define INCLUDE_tree_h__ + +#include "git2/tree.h" +#include "repository.h" +#include "odb.h" +#include "vector.h" +#include "strmap.h" + +struct git_tree_entry { + uint16_t attr; + git_oid oid; + size_t filename_len; + char filename[1]; +}; + +struct git_tree { + git_object object; + git_vector entries; +}; + +struct git_treebuilder { + git_repository *repo; + git_strmap *map; +}; + +GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e) +{ + return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr)); +} + +extern int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2); + +void git_tree__free(void *tree); +int git_tree__parse(void *tree, git_odb_object *obj); + +/** + * Lookup the first position in the tree with a given prefix. + * + * @param tree a previously loaded tree. + * @param prefix the beginning of a path to find in the tree. + * @return index of the first item at or after the given prefix. + */ +int git_tree__prefix_position(const git_tree *tree, const char *prefix); + + +/** + * Write a tree to the given repository + */ +int git_tree__write_index( + git_oid *oid, git_index *index, git_repository *repo); + +/** + * Obsolete mode kept for compatibility reasons + */ +#define GIT_FILEMODE_BLOB_GROUP_WRITABLE 0100664 + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/tsort.c b/deps/libgit2-sys-0.2.17/libgit2/src/tsort.c new file mode 100644 index 000000000..e59819204 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/tsort.c @@ -0,0 +1,385 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" + +/** + * An array-of-pointers implementation of Python's Timsort + * Based on code by Christopher Swenson under the MIT license + * + * Copyright (c) 2010 Christopher Swenson + * Copyright (c) 2011 Vicent Marti + */ + +#ifndef MAX +# define MAX(x,y) (((x) > (y) ? (x) : (y))) +#endif + +#ifndef MIN +# define MIN(x,y) (((x) < (y) ? (x) : (y))) +#endif + +static int binsearch( + void **dst, const void *x, size_t size, git__sort_r_cmp cmp, void *payload) +{ + int l, c, r; + void *lx, *cx; + + assert(size > 0); + + l = 0; + r = (int)size - 1; + c = r >> 1; + lx = dst[l]; + + /* check for beginning conditions */ + if (cmp(x, lx, payload) < 0) + return 0; + + else if (cmp(x, lx, payload) == 0) { + int i = 1; + while (cmp(x, dst[i], payload) == 0) + i++; + return i; + } + + /* guaranteed not to be >= rx */ + cx = dst[c]; + while (1) { + const int val = cmp(x, cx, payload); + if (val < 0) { + if (c - l <= 1) return c; + r = c; + } else if (val > 0) { + if (r - c <= 1) return c + 1; + l = c; + lx = cx; + } else { + do { + cx = dst[++c]; + } while (cmp(x, cx, payload) == 0); + return c; + } + c = l + ((r - l) >> 1); + cx = dst[c]; + } +} + +/* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */ +static void bisort( + void **dst, size_t start, size_t size, git__sort_r_cmp cmp, void *payload) +{ + size_t i; + void *x; + int location; + + for (i = start; i < size; i++) { + int j; + /* If this entry is already correct, just move along */ + if (cmp(dst[i - 1], dst[i], payload) <= 0) + continue; + + /* Else we need to find the right place, shift everything over, and squeeze in */ + x = dst[i]; + location = binsearch(dst, x, i, cmp, payload); + for (j = (int)i - 1; j >= location; j--) { + dst[j + 1] = dst[j]; + } + dst[location] = x; + } +} + + +/* timsort implementation, based on timsort.txt */ +struct tsort_run { + ssize_t start; + ssize_t length; +}; + +struct tsort_store { + size_t alloc; + git__sort_r_cmp cmp; + void *payload; + void **storage; +}; + +static void reverse_elements(void **dst, ssize_t start, ssize_t end) +{ + while (start < end) { + void *tmp = dst[start]; + dst[start] = dst[end]; + dst[end] = tmp; + + start++; + end--; + } +} + +static ssize_t count_run( + void **dst, ssize_t start, ssize_t size, struct tsort_store *store) +{ + ssize_t curr = start + 2; + + if (size - start == 1) + return 1; + + if (start >= size - 2) { + if (store->cmp(dst[size - 2], dst[size - 1], store->payload) > 0) { + void *tmp = dst[size - 1]; + dst[size - 1] = dst[size - 2]; + dst[size - 2] = tmp; + } + + return 2; + } + + if (store->cmp(dst[start], dst[start + 1], store->payload) <= 0) { + while (curr < size - 1 && + store->cmp(dst[curr - 1], dst[curr], store->payload) <= 0) + curr++; + + return curr - start; + } else { + while (curr < size - 1 && + store->cmp(dst[curr - 1], dst[curr], store->payload) > 0) + curr++; + + /* reverse in-place */ + reverse_elements(dst, start, curr - 1); + return curr - start; + } +} + +static size_t compute_minrun(size_t n) +{ + int r = 0; + while (n >= 64) { + r |= n & 1; + n >>= 1; + } + return n + r; +} + +static int check_invariant(struct tsort_run *stack, ssize_t stack_curr) +{ + if (stack_curr < 2) + return 1; + + else if (stack_curr == 2) { + const ssize_t A = stack[stack_curr - 2].length; + const ssize_t B = stack[stack_curr - 1].length; + return (A > B); + } else { + const ssize_t A = stack[stack_curr - 3].length; + const ssize_t B = stack[stack_curr - 2].length; + const ssize_t C = stack[stack_curr - 1].length; + return !((A <= B + C) || (B <= C)); + } +} + +static int resize(struct tsort_store *store, size_t new_size) +{ + if (store->alloc < new_size) { + void **tempstore; + + tempstore = git__reallocarray(store->storage, new_size, sizeof(void *)); + + /** + * Do not propagate on OOM; this will abort the sort and + * leave the array unsorted, but no error code will be + * raised + */ + if (tempstore == NULL) + return -1; + + store->storage = tempstore; + store->alloc = new_size; + } + + return 0; +} + +static void merge(void **dst, const struct tsort_run *stack, ssize_t stack_curr, struct tsort_store *store) +{ + const ssize_t A = stack[stack_curr - 2].length; + const ssize_t B = stack[stack_curr - 1].length; + const ssize_t curr = stack[stack_curr - 2].start; + + void **storage; + ssize_t i, j, k; + + if (resize(store, MIN(A, B)) < 0) + return; + + storage = store->storage; + + /* left merge */ + if (A < B) { + memcpy(storage, &dst[curr], A * sizeof(void *)); + i = 0; + j = curr + A; + + for (k = curr; k < curr + A + B; k++) { + if ((i < A) && (j < curr + A + B)) { + if (store->cmp(storage[i], dst[j], store->payload) <= 0) + dst[k] = storage[i++]; + else + dst[k] = dst[j++]; + } else if (i < A) { + dst[k] = storage[i++]; + } else + dst[k] = dst[j++]; + } + } else { + memcpy(storage, &dst[curr + A], B * sizeof(void *)); + i = B - 1; + j = curr + A - 1; + + for (k = curr + A + B - 1; k >= curr; k--) { + if ((i >= 0) && (j >= curr)) { + if (store->cmp(dst[j], storage[i], store->payload) > 0) + dst[k] = dst[j--]; + else + dst[k] = storage[i--]; + } else if (i >= 0) + dst[k] = storage[i--]; + else + dst[k] = dst[j--]; + } + } +} + +static ssize_t collapse(void **dst, struct tsort_run *stack, ssize_t stack_curr, struct tsort_store *store, ssize_t size) +{ + ssize_t A, B, C; + + while (1) { + /* if the stack only has one thing on it, we are done with the collapse */ + if (stack_curr <= 1) + break; + + /* if this is the last merge, just do it */ + if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) { + merge(dst, stack, stack_curr, store); + stack[0].length += stack[1].length; + stack_curr--; + break; + } + + /* check if the invariant is off for a stack of 2 elements */ + else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) { + merge(dst, stack, stack_curr, store); + stack[0].length += stack[1].length; + stack_curr--; + break; + } + else if (stack_curr == 2) + break; + + A = stack[stack_curr - 3].length; + B = stack[stack_curr - 2].length; + C = stack[stack_curr - 1].length; + + /* check first invariant */ + if (A <= B + C) { + if (A < C) { + merge(dst, stack, stack_curr - 1, store); + stack[stack_curr - 3].length += stack[stack_curr - 2].length; + stack[stack_curr - 2] = stack[stack_curr - 1]; + stack_curr--; + } else { + merge(dst, stack, stack_curr, store); + stack[stack_curr - 2].length += stack[stack_curr - 1].length; + stack_curr--; + } + } else if (B <= C) { + merge(dst, stack, stack_curr, store); + stack[stack_curr - 2].length += stack[stack_curr - 1].length; + stack_curr--; + } else + break; + } + + return stack_curr; +} + +#define PUSH_NEXT() do {\ + len = count_run(dst, curr, size, store);\ + run = minrun;\ + if (run < minrun) run = minrun;\ + if (run > (ssize_t)size - curr) run = size - curr;\ + if (run > len) {\ + bisort(&dst[curr], len, run, cmp, payload);\ + len = run;\ + }\ + run_stack[stack_curr].start = curr;\ + run_stack[stack_curr++].length = len;\ + curr += len;\ + if (curr == (ssize_t)size) {\ + /* finish up */ \ + while (stack_curr > 1) { \ + merge(dst, run_stack, stack_curr, store); \ + run_stack[stack_curr - 2].length += run_stack[stack_curr - 1].length; \ + stack_curr--; \ + } \ + if (store->storage != NULL) {\ + git__free(store->storage);\ + store->storage = NULL;\ + }\ + return;\ + }\ +}\ +while (0) + +void git__tsort_r( + void **dst, size_t size, git__sort_r_cmp cmp, void *payload) +{ + struct tsort_store _store, *store = &_store; + struct tsort_run run_stack[128]; + + ssize_t stack_curr = 0; + ssize_t len, run; + ssize_t curr = 0; + ssize_t minrun; + + if (size < 64) { + bisort(dst, 1, size, cmp, payload); + return; + } + + /* compute the minimum run length */ + minrun = (ssize_t)compute_minrun(size); + + /* temporary storage for merges */ + store->alloc = 0; + store->storage = NULL; + store->cmp = cmp; + store->payload = payload; + + PUSH_NEXT(); + PUSH_NEXT(); + PUSH_NEXT(); + + while (1) { + if (!check_invariant(run_stack, stack_curr)) { + stack_curr = collapse(dst, run_stack, stack_curr, store, size); + continue; + } + + PUSH_NEXT(); + } +} + +static int tsort_r_cmp(const void *a, const void *b, void *payload) +{ + return ((git__tsort_cmp)payload)(a, b); +} + +void git__tsort(void **dst, size_t size, git__tsort_cmp cmp) +{ + git__tsort_r(dst, size, tsort_r_cmp, cmp); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/unix/map.c b/deps/libgit2-sys-0.2.17/libgit2/src/unix/map.c new file mode 100644 index 000000000..87ee6594b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/unix/map.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include + +#if !defined(GIT_WIN32) && !defined(NO_MMAP) + +#include "map.h" +#include +#include +#include + +int git__page_size(size_t *page_size) +{ + long sc_page_size = sysconf(_SC_PAGE_SIZE); + if (sc_page_size < 0) { + giterr_set_str(GITERR_OS, "Can't determine system page size"); + return -1; + } + *page_size = (size_t) sc_page_size; + return 0; +} + +int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) +{ + int mprot = PROT_READ; + int mflag = 0; + + GIT_MMAP_VALIDATE(out, len, prot, flags); + + out->data = NULL; + out->len = 0; + + if (prot & GIT_PROT_WRITE) + mprot |= PROT_WRITE; + + if ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED) + mflag = MAP_SHARED; + else if ((flags & GIT_MAP_TYPE) == GIT_MAP_PRIVATE) + mflag = MAP_PRIVATE; + else + mflag = MAP_SHARED; + + out->data = mmap(NULL, len, mprot, mflag, fd, offset); + + if (!out->data || out->data == MAP_FAILED) { + giterr_set(GITERR_OS, "Failed to mmap. Could not write data"); + return -1; + } + + out->len = len; + + return 0; +} + +int p_munmap(git_map *map) +{ + assert(map != NULL); + munmap(map->data, map->len); + + return 0; +} + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/unix/posix.h b/deps/libgit2-sys-0.2.17/libgit2/src/unix/posix.h new file mode 100644 index 000000000..e4f3ac67a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/unix/posix.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_posix__unix_h__ +#define INCLUDE_posix__unix_h__ + +#include +#include + +typedef int GIT_SOCKET; +#define INVALID_SOCKET -1 + +#define p_lseek(f,n,w) lseek(f, n, w) +#define p_fstat(f,b) fstat(f, b) +#define p_lstat(p,b) lstat(p,b) +#define p_stat(p,b) stat(p, b) + +#define p_readlink(a, b, c) readlink(a, b, c) +#define p_symlink(o,n) symlink(o, n) +#define p_link(o,n) link(o, n) +#define p_unlink(p) unlink(p) +#define p_mkdir(p,m) mkdir(p, m) +#define p_fsync(fd) fsync(fd) +extern char *p_realpath(const char *, char *); + +#define p_recv(s,b,l,f) recv(s,b,l,f) +#define p_send(s,b,l,f) send(s,b,l,f) +#define p_inet_pton(a, b, c) inet_pton(a, b, c) + +#define p_strcasecmp(s1, s2) strcasecmp(s1, s2) +#define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c) +#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) +#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__) +#define p_mkstemp(p) mkstemp(p) +#define p_chdir(p) chdir(p) +#define p_chmod(p,m) chmod(p, m) +#define p_rmdir(p) rmdir(p) +#define p_access(p,m) access(p,m) +#define p_ftruncate(fd, sz) ftruncate(fd, sz) + +/* see win32/posix.h for explanation about why this exists */ +#define p_lstat_posixly(p,b) lstat(p,b) + +#define p_localtime_r(c, r) localtime_r(c, r) +#define p_gmtime_r(c, r) gmtime_r(c, r) + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/unix/realpath.c b/deps/libgit2-sys-0.2.17/libgit2/src/unix/realpath.c new file mode 100644 index 000000000..2e49150c2 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/unix/realpath.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include + +#ifndef GIT_WIN32 + +#include +#include +#include +#include + +char *p_realpath(const char *pathname, char *resolved) +{ + char *ret; + if ((ret = realpath(pathname, resolved)) == NULL) + return NULL; + +#ifdef __OpenBSD__ + /* The OpenBSD realpath function behaves differently, + * figure out if the file exists */ + if (access(ret, F_OK) < 0) + ret = NULL; +#endif + return ret; +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/userdiff.h b/deps/libgit2-sys-0.2.17/libgit2/src/userdiff.h new file mode 100644 index 000000000..91c1f42dc --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/userdiff.h @@ -0,0 +1,208 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_userdiff_h__ +#define INCLUDE_userdiff_h__ + +/* + * This file isolates the built in diff driver function name patterns. + * Most of these patterns are taken from Git (with permission from the + * original authors for relicensing to libgit2). + */ + +typedef struct { + const char *name; + const char *fns; + const char *words; + int flags; +} git_diff_driver_definition; + +#define WORD_DEFAULT "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" + +/* + * These builtin driver definition macros have same signature as in core + * git userdiff.c so that the data can be extracted verbatim + */ +#define PATTERNS(NAME, FN_PATS, WORD_PAT) \ + { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, 0 } +#define IPATTERN(NAME, FN_PATS, WORD_PAT) \ + { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, REG_ICASE } + +/* + * The table of diff driver patterns + * + * Function name patterns are a list of newline separated patterns that + * match a function declaration (i.e. the line you want in the hunk header), + * or a negative pattern prefixed with a '!' to reject a pattern (such as + * rejecting goto labels in C code). + * + * Word boundary patterns are just a simple pattern that will be OR'ed with + * the default value above (i.e. whitespace or non-ASCII characters). + */ +static git_diff_driver_definition builtin_defs[] = { + +IPATTERN("ada", + "!^(.*[ \t])?(is[ \t]+new|renames|is[ \t]+separate)([ \t].*)?$\n" + "!^[ \t]*with[ \t].*$\n" + "^[ \t]*((procedure|function)[ \t]+.*)$\n" + "^[ \t]*((package|protected|task)[ \t]+.*)$", + /* -- */ + "[a-zA-Z][a-zA-Z0-9_]*" + "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" + "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), + +IPATTERN("fortran", + "!^([C*]|[ \t]*!)\n" + "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n" + "^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA" + "|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$", + /* -- */ + "[a-zA-Z][a-zA-Z0-9_]*" + "|\\.([Ee][Qq]|[Nn][Ee]|[Gg][TtEe]|[Ll][TtEe]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Aa][Nn][Dd]|[Oo][Rr]|[Nn]?[Ee][Qq][Vv]|[Nn][Oo][Tt])\\." + /* numbers and format statements like 2E14.4, or ES12.6, 9X. + * Don't worry about format statements without leading digits since + * they would have been matched above as a variable anyway. */ + "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?" + "|//|\\*\\*|::|[/<>=]="), + +PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$", + "[^<>= \t]+"), + +PATTERNS("java", + "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" + "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=" + "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), + +PATTERNS("matlab", + "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$", + "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"), + +PATTERNS("objc", + /* Negate C statements that can look like functions */ + "!^[ \t]*(do|for|if|else|return|switch|while)\n" + /* Objective-C methods */ + "^[ \t]*([-+][ \t]*\\([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*\\)[ \t]*[A-Za-z_].*)$\n" + /* C functions */ + "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$\n" + /* Objective-C class/protocol definitions */ + "^(@(implementation|interface|protocol)[ \t].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("pascal", + "^(((class[ \t]+)?(procedure|function)|constructor|destructor|interface|" + "implementation|initialization|finalization)[ \t]*.*)$" + "\n" + "^(.*=[ \t]*(class|record).*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" + "|<>|<=|>=|:=|\\.\\."), + +PATTERNS("perl", + "^package .*\n" + "^sub [[:alnum:]_':]+[ \t]*" + "(\\([^)]*\\)[ \t]*)?" /* prototype */ + /* + * Attributes. A regex can't count nested parentheses, + * so just slurp up whatever we see, taking care not + * to accept lines like "sub foo; # defined elsewhere". + * + * An attribute could contain a semicolon, but at that + * point it seems reasonable enough to give up. + */ + "(:[^;#]*)?" + "(\\{[ \t]*)?" /* brace can come here or on the next line */ + "(#.*)?$\n" /* comment */ + "^(BEGIN|END|INIT|CHECK|UNITCHECK|AUTOLOAD|DESTROY)[ \t]*" + "(\\{[ \t]*)?" /* brace can come here or on the next line */ + "(#.*)?$\n" + "^=head[0-9] .*", /* POD */ + /* -- */ + "[[:alpha:]_'][[:alnum:]_']*" + "|0[xb]?[0-9a-fA-F_]*" + /* taking care not to interpret 3..5 as (3.)(.5) */ + "|[0-9a-fA-F_]+(\\.[0-9a-fA-F_]+)?([eE][-+]?[0-9_]+)?" + "|=>|-[rwxoRWXOezsfdlpSugkbctTBMAC>]|~~|::" + "|&&=|\\|\\|=|//=|\\*\\*=" + "|&&|\\|\\||//|\\+\\+|--|\\*\\*|\\.\\.\\.?" + "|[-+*/%.^&<>=!|]=" + "|=~|!~" + "|<<|<>|<=>|>>"), + +PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"), + +PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", + /* -- */ + "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." + "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), + +PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", + "[={}\"]|[^={}\" \t]+"), + +PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", + "\\\\[a-zA-Z@]+|\\\\.|[a-zA-Z0-9\x80-\xff]+"), + +PATTERNS("cpp", + /* Jump targets or access declarations */ + "!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n" + /* functions/methods, variables, and compounds at top level */ + "^((::[[:space:]]*)?[A-Za-z_].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"), + +PATTERNS("csharp", + /* Keywords */ + "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n" + /* Methods and constructors */ + "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n" + /* Properties */ + "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n" + /* Type definitions */ + "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n" + /* Namespace */ + "^[ \t]*(namespace[ \t]+.*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("php", + "^[ \t]*(((public|private|protected|static|final)[ \t]+)*((class|function)[ \t].*))$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("javascript", + "([a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z0-9_$]+)*[ \t]*=[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n" + "([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*:[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n" + "[^a-zA-Z0-9_\\$](function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), +}; + +#undef IPATTERN +#undef PATTERNS +#undef WORD_DEFAULT + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/util.c b/deps/libgit2-sys-0.2.17/libgit2/src/util.c new file mode 100644 index 000000000..6bb7d03ee --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/util.c @@ -0,0 +1,767 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include +#include "common.h" +#include +#include +#include "posix.h" + +#ifdef _MSC_VER +# include +#endif + +void git_strarray_free(git_strarray *array) +{ + size_t i; + + if (array == NULL) + return; + + for (i = 0; i < array->count; ++i) + git__free(array->strings[i]); + + git__free(array->strings); + + memset(array, 0, sizeof(*array)); +} + +int git_strarray_copy(git_strarray *tgt, const git_strarray *src) +{ + size_t i; + + assert(tgt && src); + + memset(tgt, 0, sizeof(*tgt)); + + if (!src->count) + return 0; + + tgt->strings = git__calloc(src->count, sizeof(char *)); + GITERR_CHECK_ALLOC(tgt->strings); + + for (i = 0; i < src->count; ++i) { + if (!src->strings[i]) + continue; + + tgt->strings[tgt->count] = git__strdup(src->strings[i]); + if (!tgt->strings[tgt->count]) { + git_strarray_free(tgt); + memset(tgt, 0, sizeof(*tgt)); + return -1; + } + + tgt->count++; + } + + return 0; +} + +int git__strtol64(int64_t *result, const char *nptr, const char **endptr, int base) +{ + const char *p; + int64_t n, nn; + int c, ovfl, v, neg, ndig; + + p = nptr; + neg = 0; + n = 0; + ndig = 0; + ovfl = 0; + + /* + * White space + */ + while (git__isspace(*p)) + p++; + + /* + * Sign + */ + if (*p == '-' || *p == '+') + if (*p++ == '-') + neg = 1; + + /* + * Base + */ + if (base == 0) { + if (*p != '0') + base = 10; + else { + base = 8; + if (p[1] == 'x' || p[1] == 'X') { + p += 2; + base = 16; + } + } + } else if (base == 16 && *p == '0') { + if (p[1] == 'x' || p[1] == 'X') + p += 2; + } else if (base < 0 || 36 < base) + goto Return; + + /* + * Non-empty sequence of digits + */ + for (;; p++,ndig++) { + c = *p; + v = base; + if ('0'<=c && c<='9') + v = c - '0'; + else if ('a'<=c && c<='z') + v = c - 'a' + 10; + else if ('A'<=c && c<='Z') + v = c - 'A' + 10; + if (v >= base) + break; + nn = n*base + v; + if (nn < n) + ovfl = 1; + n = nn; + } + +Return: + if (ndig == 0) { + giterr_set(GITERR_INVALID, "Failed to convert string to long. Not a number"); + return -1; + } + + if (endptr) + *endptr = p; + + if (ovfl) { + giterr_set(GITERR_INVALID, "Failed to convert string to long. Overflow error"); + return -1; + } + + *result = neg ? -n : n; + return 0; +} + +int git__strtol32(int32_t *result, const char *nptr, const char **endptr, int base) +{ + int error; + int32_t tmp_int; + int64_t tmp_long; + + if ((error = git__strtol64(&tmp_long, nptr, endptr, base)) < 0) + return error; + + tmp_int = tmp_long & 0xFFFFFFFF; + if (tmp_int != tmp_long) { + giterr_set(GITERR_INVALID, "Failed to convert. '%s' is too large", nptr); + return -1; + } + + *result = tmp_int; + + return error; +} + +int git__strcmp(const char *a, const char *b) +{ + while (*a && *b && *a == *b) + ++a, ++b; + return (int)(*(const unsigned char *)a) - (int)(*(const unsigned char *)b); +} + +int git__strcasecmp(const char *a, const char *b) +{ + while (*a && *b && tolower(*a) == tolower(*b)) + ++a, ++b; + return (tolower(*a) - tolower(*b)); +} + +int git__strcasesort_cmp(const char *a, const char *b) +{ + int cmp = 0; + + while (*a && *b) { + if (*a != *b) { + if (tolower(*a) != tolower(*b)) + break; + /* use case in sort order even if not in equivalence */ + if (!cmp) + cmp = (int)(*(const uint8_t *)a) - (int)(*(const uint8_t *)b); + } + + ++a, ++b; + } + + if (*a || *b) + return tolower(*a) - tolower(*b); + + return cmp; +} + +int git__strncmp(const char *a, const char *b, size_t sz) +{ + while (sz && *a && *b && *a == *b) + --sz, ++a, ++b; + if (!sz) + return 0; + return (int)(*(const unsigned char *)a) - (int)(*(const unsigned char *)b); +} + +int git__strncasecmp(const char *a, const char *b, size_t sz) +{ + int al, bl; + + do { + al = (unsigned char)tolower(*a); + bl = (unsigned char)tolower(*b); + ++a, ++b; + } while (--sz && al && al == bl); + + return al - bl; +} + +void git__strntolower(char *str, size_t len) +{ + size_t i; + + for (i = 0; i < len; ++i) { + str[i] = (char) tolower(str[i]); + } +} + +void git__strtolower(char *str) +{ + git__strntolower(str, strlen(str)); +} + +int git__prefixcmp(const char *str, const char *prefix) +{ + for (;;) { + unsigned char p = *(prefix++), s; + if (!p) + return 0; + if ((s = *(str++)) != p) + return s - p; + } +} + +int git__prefixcmp_icase(const char *str, const char *prefix) +{ + return strncasecmp(str, prefix, strlen(prefix)); +} + +int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix) +{ + int s, p; + + while(str_n--) { + s = (unsigned char)tolower(*str++); + p = (unsigned char)tolower(*prefix++); + + if (s != p) + return s - p; + } + + return (0 - *prefix); +} + +int git__suffixcmp(const char *str, const char *suffix) +{ + size_t a = strlen(str); + size_t b = strlen(suffix); + if (a < b) + return -1; + return strcmp(str + (a - b), suffix); +} + +char *git__strtok(char **end, const char *sep) +{ + char *ptr = *end; + + while (*ptr && strchr(sep, *ptr)) + ++ptr; + + if (*ptr) { + char *start = ptr; + *end = start + 1; + + while (**end && !strchr(sep, **end)) + ++*end; + + if (**end) { + **end = '\0'; + ++*end; + } + + return start; + } + + return NULL; +} + +/* Similar to strtok, but does not collapse repeated tokens. */ +char *git__strsep(char **end, const char *sep) +{ + char *start = *end, *ptr = *end; + + while (*ptr && !strchr(sep, *ptr)) + ++ptr; + + if (*ptr) { + *end = ptr + 1; + *ptr = '\0'; + + return start; + } + + return NULL; +} + +void git__hexdump(const char *buffer, size_t len) +{ + static const size_t LINE_WIDTH = 16; + + size_t line_count, last_line, i, j; + const char *line; + + line_count = (len / LINE_WIDTH); + last_line = (len % LINE_WIDTH); + + for (i = 0; i < line_count; ++i) { + line = buffer + (i * LINE_WIDTH); + for (j = 0; j < LINE_WIDTH; ++j, ++line) + printf("%02X ", (unsigned char)*line & 0xFF); + + printf("| "); + + line = buffer + (i * LINE_WIDTH); + for (j = 0; j < LINE_WIDTH; ++j, ++line) + printf("%c", (*line >= 32 && *line <= 126) ? *line : '.'); + + printf("\n"); + } + + if (last_line > 0) { + + line = buffer + (line_count * LINE_WIDTH); + for (j = 0; j < last_line; ++j, ++line) + printf("%02X ", (unsigned char)*line & 0xFF); + + for (j = 0; j < (LINE_WIDTH - last_line); ++j) + printf(" "); + + printf("| "); + + line = buffer + (line_count * LINE_WIDTH); + for (j = 0; j < last_line; ++j, ++line) + printf("%c", (*line >= 32 && *line <= 126) ? *line : '.'); + + printf("\n"); + } + + printf("\n"); +} + +#ifdef GIT_LEGACY_HASH +uint32_t git__hash(const void *key, int len, unsigned int seed) +{ + const uint32_t m = 0x5bd1e995; + const int r = 24; + uint32_t h = seed ^ len; + + const unsigned char *data = (const unsigned char *)key; + + while(len >= 4) { + uint32_t k = *(uint32_t *)data; + + k *= m; + k ^= k >> r; + k *= m; + + h *= m; + h ^= k; + + data += 4; + len -= 4; + } + + switch(len) { + case 3: h ^= data[2] << 16; + case 2: h ^= data[1] << 8; + case 1: h ^= data[0]; + h *= m; + }; + + h ^= h >> 13; + h *= m; + h ^= h >> 15; + + return h; +} +#else +/* + Cross-platform version of Murmurhash3 + http://code.google.com/p/smhasher/wiki/MurmurHash3 + by Austin Appleby (aappleby@gmail.com) + + This code is on the public domain. +*/ +uint32_t git__hash(const void *key, int len, uint32_t seed) +{ + +#define MURMUR_BLOCK() {\ + k1 *= c1; \ + k1 = git__rotl(k1,11);\ + k1 *= c2;\ + h1 ^= k1;\ + h1 = h1*3 + 0x52dce729;\ + c1 = c1*5 + 0x7b7d159c;\ + c2 = c2*5 + 0x6bce6396;\ +} + + const uint8_t *data = (const uint8_t*)key; + const int nblocks = len / 4; + + const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4); + const uint8_t *tail = (const uint8_t *)(data + nblocks * 4); + + uint32_t h1 = 0x971e137b ^ seed; + uint32_t k1; + + uint32_t c1 = 0x95543787; + uint32_t c2 = 0x2ad7eb25; + + int i; + + for (i = -nblocks; i; i++) { + k1 = blocks[i]; + MURMUR_BLOCK(); + } + + k1 = 0; + + switch(len & 3) { + case 3: k1 ^= tail[2] << 16; + case 2: k1 ^= tail[1] << 8; + case 1: k1 ^= tail[0]; + MURMUR_BLOCK(); + } + + h1 ^= len; + h1 ^= h1 >> 16; + h1 *= 0x85ebca6b; + h1 ^= h1 >> 13; + h1 *= 0xc2b2ae35; + h1 ^= h1 >> 16; + + return h1; +} +#endif + +/** + * A modified `bsearch` from the BSD glibc. + * + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. [rescinded 22 July 1999] + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +int git__bsearch( + void **array, + size_t array_len, + const void *key, + int (*compare)(const void *, const void *), + size_t *position) +{ + size_t lim; + int cmp = -1; + void **part, **base = array; + + for (lim = array_len; lim != 0; lim >>= 1) { + part = base + (lim >> 1); + cmp = (*compare)(key, *part); + if (cmp == 0) { + base = part; + break; + } + if (cmp > 0) { /* key > p; take right partition */ + base = part + 1; + lim--; + } /* else take left partition */ + } + + if (position) + *position = (base - array); + + return (cmp == 0) ? 0 : GIT_ENOTFOUND; +} + +int git__bsearch_r( + void **array, + size_t array_len, + const void *key, + int (*compare_r)(const void *, const void *, void *), + void *payload, + size_t *position) +{ + size_t lim; + int cmp = -1; + void **part, **base = array; + + for (lim = array_len; lim != 0; lim >>= 1) { + part = base + (lim >> 1); + cmp = (*compare_r)(key, *part, payload); + if (cmp == 0) { + base = part; + break; + } + if (cmp > 0) { /* key > p; take right partition */ + base = part + 1; + lim--; + } /* else take left partition */ + } + + if (position) + *position = (base - array); + + return (cmp == 0) ? 0 : GIT_ENOTFOUND; +} + +/** + * A strcmp wrapper + * + * We don't want direct pointers to the CRT on Windows, we may + * get stdcall conflicts. + */ +int git__strcmp_cb(const void *a, const void *b) +{ + return strcmp((const char *)a, (const char *)b); +} + +int git__strcasecmp_cb(const void *a, const void *b) +{ + return strcasecmp((const char *)a, (const char *)b); +} + +int git__parse_bool(int *out, const char *value) +{ + /* A missing value means true */ + if (value == NULL || + !strcasecmp(value, "true") || + !strcasecmp(value, "yes") || + !strcasecmp(value, "on")) { + *out = 1; + return 0; + } + if (!strcasecmp(value, "false") || + !strcasecmp(value, "no") || + !strcasecmp(value, "off") || + value[0] == '\0') { + *out = 0; + return 0; + } + + return -1; +} + +size_t git__unescape(char *str) +{ + char *scan, *pos = str; + + if (!str) + return 0; + + for (scan = str; *scan; pos++, scan++) { + if (*scan == '\\' && *(scan + 1) != '\0') + scan++; /* skip '\' but include next char */ + if (pos != scan) + *pos = *scan; + } + + if (pos != scan) { + *pos = '\0'; + } + + return (pos - str); +} + +#if defined(GIT_WIN32) || defined(BSD) +typedef struct { + git__sort_r_cmp cmp; + void *payload; +} git__qsort_r_glue; + +static int GIT_STDLIB_CALL git__qsort_r_glue_cmp( + void *payload, const void *a, const void *b) +{ + git__qsort_r_glue *glue = payload; + return glue->cmp(a, b, glue->payload); +} +#endif + +void git__qsort_r( + void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload) +{ +#if defined(__MINGW32__) || defined(AMIGA) || \ + defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__gnu_hurd__) || defined(__ANDROID_API__) || \ + defined(__sun) || defined(__CYGWIN__) || \ + (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8) || \ + (defined(_MSC_VER) && _MSC_VER < 1500) + git__insertsort_r(els, nel, elsize, NULL, cmp, payload); +#elif defined(GIT_WIN32) + git__qsort_r_glue glue = { cmp, payload }; + qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue); +#elif defined(BSD) + git__qsort_r_glue glue = { cmp, payload }; + qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp); +#else + qsort_r(els, nel, elsize, cmp, payload); +#endif +} + +void git__insertsort_r( + void *els, size_t nel, size_t elsize, void *swapel, + git__sort_r_cmp cmp, void *payload) +{ + uint8_t *base = els; + uint8_t *end = base + nel * elsize; + uint8_t *i, *j; + bool freeswap = !swapel; + + if (freeswap) + swapel = git__malloc(elsize); + + for (i = base + elsize; i < end; i += elsize) + for (j = i; j > base && cmp(j, j - elsize, payload) < 0; j -= elsize) { + memcpy(swapel, j, elsize); + memcpy(j, j - elsize, elsize); + memcpy(j - elsize, swapel, elsize); + } + + if (freeswap) + git__free(swapel); +} + +/* + * git__utf8_iterate is taken from the utf8proc project, + * http://www.public-software-group.org/utf8proc + * + * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the ""Software""), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +static const int8_t utf8proc_utf8class[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +int git__utf8_charlen(const uint8_t *str, int str_len) +{ + int length, i; + + length = utf8proc_utf8class[str[0]]; + if (!length) + return -1; + + if (str_len >= 0 && length > str_len) + return -str_len; + + for (i = 1; i < length; i++) { + if ((str[i] & 0xC0) != 0x80) + return -i; + } + + return length; +} + +int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst) +{ + int length; + int32_t uc = -1; + + *dst = -1; + length = git__utf8_charlen(str, str_len); + if (length < 0) + return -1; + + switch (length) { + case 1: + uc = str[0]; + break; + case 2: + uc = ((str[0] & 0x1F) << 6) + (str[1] & 0x3F); + if (uc < 0x80) uc = -1; + break; + case 3: + uc = ((str[0] & 0x0F) << 12) + ((str[1] & 0x3F) << 6) + + (str[2] & 0x3F); + if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) || + (uc >= 0xFDD0 && uc < 0xFDF0)) uc = -1; + break; + case 4: + uc = ((str[0] & 0x07) << 18) + ((str[1] & 0x3F) << 12) + + ((str[2] & 0x3F) << 6) + (str[3] & 0x3F); + if (uc < 0x10000 || uc >= 0x110000) uc = -1; + break; + } + + if (uc < 0 || ((uc & 0xFFFF) >= 0xFFFE)) + return -1; + + *dst = uc; + return length; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/util.h b/deps/libgit2-sys-0.2.17/libgit2/src/util.h new file mode 100644 index 000000000..38dcae79b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/util.h @@ -0,0 +1,473 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_util_h__ +#define INCLUDE_util_h__ + +#include "common.h" +#include "strnlen.h" + +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define bitsizeof(x) (CHAR_BIT * sizeof(x)) +#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits)))) +#ifndef min +# define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +# define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#define GIT_DATE_RFC2822_SZ 32 + +/** + * Return the length of a constant string. + * We are aware that `strlen` performs the same task and is usually + * optimized away by the compiler, whilst being safer because it returns + * valid values when passed a pointer instead of a constant string; however + * this macro will transparently work with wide-char and single-char strings. + */ +#define CONST_STRLEN(x) ((sizeof(x)/sizeof(x[0])) - 1) + +/* + * Custom memory allocation wrappers + * that set error code and error message + * on allocation failure + */ +GIT_INLINE(void *) git__malloc(size_t len) +{ + void *ptr = malloc(len); + if (!ptr) giterr_set_oom(); + return ptr; +} + +GIT_INLINE(void *) git__calloc(size_t nelem, size_t elsize) +{ + void *ptr = calloc(nelem, elsize); + if (!ptr) giterr_set_oom(); + return ptr; +} + +GIT_INLINE(char *) git__strdup(const char *str) +{ + char *ptr = strdup(str); + if (!ptr) giterr_set_oom(); + return ptr; +} + +GIT_INLINE(char *) git__strndup(const char *str, size_t n) +{ + size_t length = 0, alloclength; + char *ptr; + + length = p_strnlen(str, n); + + if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) || + !(ptr = git__malloc(alloclength))) + return NULL; + + if (length) + memcpy(ptr, str, length); + + ptr[length] = '\0'; + + return ptr; +} + +/* NOTE: This doesn't do null or '\0' checking. Watch those boundaries! */ +GIT_INLINE(char *) git__substrdup(const char *start, size_t n) +{ + char *ptr; + size_t alloclen; + + if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) || + !(ptr = git__malloc(alloclen))) + return NULL; + + memcpy(ptr, start, n); + ptr[n] = '\0'; + return ptr; +} + +GIT_INLINE(void *) git__realloc(void *ptr, size_t size) +{ + void *new_ptr = realloc(ptr, size); + if (!new_ptr) giterr_set_oom(); + return new_ptr; +} + +/** + * Similar to `git__realloc`, except that it is suitable for reallocing an + * array to a new number of elements of `nelem`, each of size `elsize`. + * The total size calculation is checked for overflow. + */ +GIT_INLINE(void *) git__reallocarray(void *ptr, size_t nelem, size_t elsize) +{ + size_t newsize; + return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ? + NULL : realloc(ptr, newsize); +} + +/** + * Similar to `git__calloc`, except that it does not zero memory. + */ +GIT_INLINE(void *) git__mallocarray(size_t nelem, size_t elsize) +{ + return git__reallocarray(NULL, nelem, elsize); +} + +GIT_INLINE(void) git__free(void *ptr) +{ + free(ptr); +} + +#define STRCMP_CASESELECT(IGNORE_CASE, STR1, STR2) \ + ((IGNORE_CASE) ? strcasecmp((STR1), (STR2)) : strcmp((STR1), (STR2))) + +#define CASESELECT(IGNORE_CASE, ICASE, CASE) \ + ((IGNORE_CASE) ? (ICASE) : (CASE)) + +extern int git__prefixcmp(const char *str, const char *prefix); +extern int git__prefixcmp_icase(const char *str, const char *prefix); +extern int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix); +extern int git__suffixcmp(const char *str, const char *suffix); + +GIT_INLINE(int) git__signum(int val) +{ + return ((val > 0) - (val < 0)); +} + +extern int git__strtol32(int32_t *n, const char *buff, const char **end_buf, int base); +extern int git__strtol64(int64_t *n, const char *buff, const char **end_buf, int base); + +extern void git__hexdump(const char *buffer, size_t n); +extern uint32_t git__hash(const void *key, int len, uint32_t seed); + +/* 32-bit cross-platform rotl */ +#ifdef _MSC_VER /* use built-in method in MSVC */ +# define git__rotl(v, s) (uint32_t)_rotl(v, s) +#else /* use bitops in GCC; with o2 this gets optimized to a rotl instruction */ +# define git__rotl(v, s) (uint32_t)(((uint32_t)(v) << (s)) | ((uint32_t)(v) >> (32 - (s)))) +#endif + +extern char *git__strtok(char **end, const char *sep); +extern char *git__strsep(char **end, const char *sep); + +extern void git__strntolower(char *str, size_t len); +extern void git__strtolower(char *str); + +GIT_INLINE(const char *) git__next_line(const char *s) +{ + while (*s && *s != '\n') s++; + while (*s == '\n' || *s == '\r') s++; + return s; +} + +GIT_INLINE(const void *) git__memrchr(const void *s, int c, size_t n) +{ + const unsigned char *cp; + + if (n != 0) { + cp = (unsigned char *)s + n; + do { + if (*(--cp) == (unsigned char)c) + return cp; + } while (--n != 0); + } + + return NULL; +} + +typedef int (*git__tsort_cmp)(const void *a, const void *b); + +extern void git__tsort(void **dst, size_t size, git__tsort_cmp cmp); + +typedef int (*git__sort_r_cmp)(const void *a, const void *b, void *payload); + +extern void git__tsort_r( + void **dst, size_t size, git__sort_r_cmp cmp, void *payload); + +extern void git__qsort_r( + void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload); + +extern void git__insertsort_r( + void *els, size_t nel, size_t elsize, void *swapel, + git__sort_r_cmp cmp, void *payload); + +/** + * @param position If non-NULL, this will be set to the position where the + * element is or would be inserted if not found. + * @return 0 if found; GIT_ENOTFOUND if not found + */ +extern int git__bsearch( + void **array, + size_t array_len, + const void *key, + int (*compare)(const void *key, const void *element), + size_t *position); + +extern int git__bsearch_r( + void **array, + size_t array_len, + const void *key, + int (*compare_r)(const void *key, const void *element, void *payload), + void *payload, + size_t *position); + +extern int git__strcmp_cb(const void *a, const void *b); +extern int git__strcasecmp_cb(const void *a, const void *b); + +extern int git__strcmp(const char *a, const char *b); +extern int git__strcasecmp(const char *a, const char *b); +extern int git__strncmp(const char *a, const char *b, size_t sz); +extern int git__strncasecmp(const char *a, const char *b, size_t sz); + +extern int git__strcasesort_cmp(const char *a, const char *b); + +#include "thread-utils.h" + +typedef struct { + git_atomic refcount; + void *owner; +} git_refcount; + +typedef void (*git_refcount_freeptr)(void *r); + +#define GIT_REFCOUNT_INC(r) { \ + git_atomic_inc(&((git_refcount *)(r))->refcount); \ +} + +#define GIT_REFCOUNT_DEC(_r, do_free) { \ + git_refcount *r = (git_refcount *)(_r); \ + int val = git_atomic_dec(&r->refcount); \ + if (val <= 0 && r->owner == NULL) { do_free(_r); } \ +} + +#define GIT_REFCOUNT_OWN(r, o) { \ + ((git_refcount *)(r))->owner = o; \ +} + +#define GIT_REFCOUNT_OWNER(r) (((git_refcount *)(r))->owner) + +#define GIT_REFCOUNT_VAL(r) git_atomic_get(&((git_refcount *)(r))->refcount) + + +static signed char from_hex[] = { +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 00 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 20 */ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 30 */ +-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 40 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 50 */ +-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 60 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 70 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 90 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a0 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* b0 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* c0 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* d0 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* e0 */ +-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* f0 */ +}; + +GIT_INLINE(int) git__fromhex(char h) +{ + return from_hex[(unsigned char) h]; +} + +GIT_INLINE(int) git__ishex(const char *str) +{ + unsigned i; + for (i=0; str[i] != '\0'; i++) + if (git__fromhex(str[i]) < 0) + return 0; + return 1; +} + +GIT_INLINE(size_t) git__size_t_bitmask(size_t v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + + return v; +} + +GIT_INLINE(size_t) git__size_t_powerof2(size_t v) +{ + return git__size_t_bitmask(v) + 1; +} + +GIT_INLINE(bool) git__isupper(int c) +{ + return (c >= 'A' && c <= 'Z'); +} + +GIT_INLINE(bool) git__isalpha(int c) +{ + return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +} + +GIT_INLINE(bool) git__isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} + +GIT_INLINE(bool) git__isspace(int c) +{ + return (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' || c == '\v'); +} + +GIT_INLINE(bool) git__isspace_nonlf(int c) +{ + return (c == ' ' || c == '\t' || c == '\f' || c == '\r' || c == '\v'); +} + +GIT_INLINE(bool) git__iswildcard(int c) +{ + return (c == '*' || c == '?' || c == '['); +} + +/* + * Parse a string value as a boolean, just like Core Git does. + * + * Valid values for true are: 'true', 'yes', 'on' + * Valid values for false are: 'false', 'no', 'off' + */ +extern int git__parse_bool(int *out, const char *value); + +/* + * Parse a string into a value as a git_time_t. + * + * Sample valid input: + * - "yesterday" + * - "July 17, 2003" + * - "2003-7-17 08:23" + */ +extern int git__date_parse(git_time_t *out, const char *date); + +/* + * Format a git_time as a RFC2822 string + * + * @param out buffer to store formatted date; a '\\0' terminator will automatically be added. + * @param len size of the buffer; should be atleast `GIT_DATE_RFC2822_SZ` in size; + * @param date the date to be formatted + * @return 0 if successful; -1 on error + */ +extern int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date); + +/* + * Unescapes a string in-place. + * + * Edge cases behavior: + * - "jackie\" -> "jacky\" + * - "chan\\" -> "chan\" + */ +extern size_t git__unescape(char *str); + +/* + * Iterate through an UTF-8 string, yielding one + * codepoint at a time. + * + * @param str current position in the string + * @param str_len size left in the string; -1 if the string is NULL-terminated + * @param dst pointer where to store the current codepoint + * @return length in bytes of the read codepoint; -1 if the codepoint was invalid + */ +extern int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst); + +/* + * Safely zero-out memory, making sure that the compiler + * doesn't optimize away the operation. + */ +GIT_INLINE(void) git__memzero(void *data, size_t size) +{ +#ifdef _MSC_VER + SecureZeroMemory((PVOID)data, size); +#else + volatile uint8_t *scan = (volatile uint8_t *)data; + + while (size--) + *scan++ = 0x0; +#endif +} + +#ifdef GIT_WIN32 + +GIT_INLINE(double) git__timer(void) +{ + /* We need the initial tick count to detect if the tick + * count has rolled over. */ + static DWORD initial_tick_count = 0; + + /* GetTickCount returns the number of milliseconds that have + * elapsed since the system was started. */ + DWORD count = GetTickCount(); + + if(initial_tick_count == 0) { + initial_tick_count = count; + } else if (count < initial_tick_count) { + /* The tick count has rolled over - adjust for it. */ + count = (0xFFFFFFFF - initial_tick_count) + count; + } + + return (double) count / (double) 1000; +} + +#elif __APPLE__ + +#include + +GIT_INLINE(double) git__timer(void) +{ + uint64_t time = mach_absolute_time(); + static double scaling_factor = 0; + + if (scaling_factor == 0) { + mach_timebase_info_data_t info; + (void)mach_timebase_info(&info); + scaling_factor = (double)info.numer / (double)info.denom; + } + + return (double)time * scaling_factor / 1.0E9; +} + +#elif defined(AMIGA) + +#include + +GIT_INLINE(double) git__timer(void) +{ + struct TimeVal tv; + ITimer->GetUpTime(&tv); + return (double)tv.Seconds + (double)tv.Microseconds / 1.0E6; +} + +#else + +#include + +GIT_INLINE(double) git__timer(void) +{ + struct timespec tp; + + if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { + return (double) tp.tv_sec + (double) tp.tv_nsec / 1.0E9; + } else { + /* Fall back to using gettimeofday */ + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + return (double)tv.tv_sec + (double)tv.tv_usec / 1.0E6; + } +} + +#endif + +#endif /* INCLUDE_util_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/vector.c b/deps/libgit2-sys-0.2.17/libgit2/src/vector.c new file mode 100644 index 000000000..93d09bb5b --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/vector.c @@ -0,0 +1,354 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "vector.h" + +/* In elements, not bytes */ +#define MIN_ALLOCSIZE 8 + +GIT_INLINE(size_t) compute_new_size(git_vector *v) +{ + size_t new_size = v->_alloc_size; + + /* Use a resize factor of 1.5, which is quick to compute using integer + * instructions and less than the golden ratio (1.618...) */ + if (new_size < MIN_ALLOCSIZE) + new_size = MIN_ALLOCSIZE; + else if (new_size <= (SIZE_MAX / 3) * 2) + new_size += new_size / 2; + else + new_size = SIZE_MAX; + + return new_size; +} + +GIT_INLINE(int) resize_vector(git_vector *v, size_t new_size) +{ + void *new_contents; + + new_contents = git__reallocarray(v->contents, new_size, sizeof(void *)); + GITERR_CHECK_ALLOC(new_contents); + + v->_alloc_size = new_size; + v->contents = new_contents; + + return 0; +} + +int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp) +{ + size_t bytes; + + assert(v && src); + + GITERR_CHECK_ALLOC_MULTIPLY(&bytes, src->length, sizeof(void *)); + + v->_alloc_size = src->length; + v->_cmp = cmp ? cmp : src->_cmp; + v->length = src->length; + v->flags = src->flags; + if (cmp != src->_cmp) + git_vector_set_sorted(v, 0); + v->contents = git__malloc(bytes); + GITERR_CHECK_ALLOC(v->contents); + + memcpy(v->contents, src->contents, bytes); + + return 0; +} + +void git_vector_free(git_vector *v) +{ + assert(v); + + git__free(v->contents); + v->contents = NULL; + + v->length = 0; + v->_alloc_size = 0; +} + +void git_vector_free_deep(git_vector *v) +{ + size_t i; + + assert(v); + + for (i = 0; i < v->length; ++i) { + git__free(v->contents[i]); + v->contents[i] = NULL; + } + + git_vector_free(v); +} + +int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp) +{ + assert(v); + + v->_alloc_size = 0; + v->_cmp = cmp; + v->length = 0; + v->flags = GIT_VECTOR_SORTED; + v->contents = NULL; + + return resize_vector(v, max(initial_size, MIN_ALLOCSIZE)); +} + +void **git_vector_detach(size_t *size, size_t *asize, git_vector *v) +{ + void **data = v->contents; + + if (size) + *size = v->length; + if (asize) + *asize = v->_alloc_size; + + v->_alloc_size = 0; + v->length = 0; + v->contents = NULL; + + return data; +} + +int git_vector_insert(git_vector *v, void *element) +{ + assert(v); + + if (v->length >= v->_alloc_size && + resize_vector(v, compute_new_size(v)) < 0) + return -1; + + v->contents[v->length++] = element; + + git_vector_set_sorted(v, v->length <= 1); + + return 0; +} + +int git_vector_insert_sorted( + git_vector *v, void *element, int (*on_dup)(void **old, void *new)) +{ + int result; + size_t pos; + + assert(v && v->_cmp); + + if (!git_vector_is_sorted(v)) + git_vector_sort(v); + + if (v->length >= v->_alloc_size && + resize_vector(v, compute_new_size(v)) < 0) + return -1; + + /* If we find the element and have a duplicate handler callback, + * invoke it. If it returns non-zero, then cancel insert, otherwise + * proceed with normal insert. + */ + if (!git__bsearch(v->contents, v->length, element, v->_cmp, &pos) && + on_dup && (result = on_dup(&v->contents[pos], element)) < 0) + return result; + + /* shift elements to the right */ + if (pos < v->length) + memmove(v->contents + pos + 1, v->contents + pos, + (v->length - pos) * sizeof(void *)); + + v->contents[pos] = element; + v->length++; + + return 0; +} + +void git_vector_sort(git_vector *v) +{ + assert(v); + + if (git_vector_is_sorted(v) || !v->_cmp) + return; + + if (v->length > 1) + git__tsort(v->contents, v->length, v->_cmp); + git_vector_set_sorted(v, 1); +} + +int git_vector_bsearch2( + size_t *at_pos, + git_vector *v, + git_vector_cmp key_lookup, + const void *key) +{ + assert(v && key && key_lookup); + + /* need comparison function to sort the vector */ + if (!v->_cmp) + return -1; + + git_vector_sort(v); + + return git__bsearch(v->contents, v->length, key, key_lookup, at_pos); +} + +int git_vector_search2( + size_t *at_pos, const git_vector *v, git_vector_cmp key_lookup, const void *key) +{ + size_t i; + + assert(v && key && key_lookup); + + for (i = 0; i < v->length; ++i) { + if (key_lookup(key, v->contents[i]) == 0) { + if (at_pos) + *at_pos = i; + + return 0; + } + } + + return GIT_ENOTFOUND; +} + +static int strict_comparison(const void *a, const void *b) +{ + return (a == b) ? 0 : -1; +} + +int git_vector_search(size_t *at_pos, const git_vector *v, const void *entry) +{ + return git_vector_search2(at_pos, v, v->_cmp ? v->_cmp : strict_comparison, entry); +} + +int git_vector_remove(git_vector *v, size_t idx) +{ + size_t shift_count; + + assert(v); + + if (idx >= v->length) + return GIT_ENOTFOUND; + + shift_count = v->length - idx - 1; + + if (shift_count) + memmove(&v->contents[idx], &v->contents[idx + 1], + shift_count * sizeof(void *)); + + v->length--; + return 0; +} + +void git_vector_pop(git_vector *v) +{ + if (v->length > 0) + v->length--; +} + +void git_vector_uniq(git_vector *v, void (*git_free_cb)(void *)) +{ + git_vector_cmp cmp; + size_t i, j; + + if (v->length <= 1) + return; + + git_vector_sort(v); + cmp = v->_cmp ? v->_cmp : strict_comparison; + + for (i = 0, j = 1 ; j < v->length; ++j) + if (!cmp(v->contents[i], v->contents[j])) { + if (git_free_cb) + git_free_cb(v->contents[i]); + + v->contents[i] = v->contents[j]; + } else + v->contents[++i] = v->contents[j]; + + v->length -= j - i - 1; +} + +void git_vector_remove_matching( + git_vector *v, + int (*match)(const git_vector *v, size_t idx, void *payload), + void *payload) +{ + size_t i, j; + + for (i = 0, j = 0; j < v->length; ++j) { + v->contents[i] = v->contents[j]; + + if (!match(v, i, payload)) + i++; + } + + v->length = i; +} + +void git_vector_clear(git_vector *v) +{ + assert(v); + v->length = 0; + git_vector_set_sorted(v, 1); +} + +void git_vector_swap(git_vector *a, git_vector *b) +{ + git_vector t; + + assert(a && b); + + if (a != b) { + memcpy(&t, a, sizeof(t)); + memcpy(a, b, sizeof(t)); + memcpy(b, &t, sizeof(t)); + } +} + +int git_vector_resize_to(git_vector *v, size_t new_length) +{ + if (new_length > v->_alloc_size && + resize_vector(v, new_length) < 0) + return -1; + + if (new_length > v->length) + memset(&v->contents[v->length], 0, + sizeof(void *) * (new_length - v->length)); + + v->length = new_length; + + return 0; +} + +int git_vector_set(void **old, git_vector *v, size_t position, void *value) +{ + if (position + 1 > v->length) { + if (git_vector_resize_to(v, position + 1) < 0) + return -1; + } + + if (old != NULL) + *old = v->contents[position]; + + v->contents[position] = value; + + return 0; +} + +int git_vector_verify_sorted(const git_vector *v) +{ + size_t i; + + if (!git_vector_is_sorted(v)) + return -1; + + for (i = 1; i < v->length; ++i) { + if (v->_cmp(v->contents[i - 1], v->contents[i]) > 0) + return -1; + } + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/vector.h b/deps/libgit2-sys-0.2.17/libgit2/src/vector.h new file mode 100644 index 000000000..aac46c4b3 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/vector.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_vector_h__ +#define INCLUDE_vector_h__ + +#include "common.h" + +typedef int (*git_vector_cmp)(const void *, const void *); + +enum { + GIT_VECTOR_SORTED = (1u << 0), + GIT_VECTOR_FLAG_MAX = (1u << 1), +}; + +typedef struct git_vector { + size_t _alloc_size; + git_vector_cmp _cmp; + void **contents; + size_t length; + uint32_t flags; +} git_vector; + +#define GIT_VECTOR_INIT {0} + +int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp); +void git_vector_free(git_vector *v); +void git_vector_free_deep(git_vector *v); /* free each entry and self */ +void git_vector_clear(git_vector *v); +int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp); +void git_vector_swap(git_vector *a, git_vector *b); + +void **git_vector_detach(size_t *size, size_t *asize, git_vector *v); + +void git_vector_sort(git_vector *v); + +/** Linear search for matching entry using internal comparison function */ +int git_vector_search(size_t *at_pos, const git_vector *v, const void *entry); + +/** Linear search for matching entry using explicit comparison function */ +int git_vector_search2(size_t *at_pos, const git_vector *v, git_vector_cmp cmp, const void *key); + +/** + * Binary search for matching entry using explicit comparison function that + * returns position where item would go if not found. + */ +int git_vector_bsearch2( + size_t *at_pos, git_vector *v, git_vector_cmp cmp, const void *key); + +/** Binary search for matching entry using internal comparison function */ +GIT_INLINE(int) git_vector_bsearch(size_t *at_pos, git_vector *v, const void *key) +{ + return git_vector_bsearch2(at_pos, v, v->_cmp, key); +} + +GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position) +{ + return (position < v->length) ? v->contents[position] : NULL; +} + +#define GIT_VECTOR_GET(V,I) ((I) < (V)->length ? (V)->contents[(I)] : NULL) + +GIT_INLINE(size_t) git_vector_length(const git_vector *v) +{ + return v->length; +} + +GIT_INLINE(void *) git_vector_last(const git_vector *v) +{ + return (v->length > 0) ? git_vector_get(v, v->length - 1) : NULL; +} + +#define git_vector_foreach(v, iter, elem) \ + for ((iter) = 0; (iter) < (v)->length && ((elem) = (v)->contents[(iter)], 1); (iter)++ ) + +#define git_vector_rforeach(v, iter, elem) \ + for ((iter) = (v)->length - 1; (iter) < SIZE_MAX && ((elem) = (v)->contents[(iter)], 1); (iter)-- ) + +int git_vector_insert(git_vector *v, void *element); +int git_vector_insert_sorted(git_vector *v, void *element, + int (*on_dup)(void **old, void *new)); +int git_vector_remove(git_vector *v, size_t idx); +void git_vector_pop(git_vector *v); +void git_vector_uniq(git_vector *v, void (*git_free_cb)(void *)); + +void git_vector_remove_matching( + git_vector *v, + int (*match)(const git_vector *v, size_t idx, void *payload), + void *payload); + +int git_vector_resize_to(git_vector *v, size_t new_length); +int git_vector_set(void **old, git_vector *v, size_t position, void *value); + +/** Check if vector is sorted */ +#define git_vector_is_sorted(V) (((V)->flags & GIT_VECTOR_SORTED) != 0) + +/** Directly set sorted state of vector */ +#define git_vector_set_sorted(V,S) do { \ + (V)->flags = (S) ? ((V)->flags | GIT_VECTOR_SORTED) : \ + ((V)->flags & ~GIT_VECTOR_SORTED); } while (0) + +/** Set the comparison function used for sorting the vector */ +GIT_INLINE(void) git_vector_set_cmp(git_vector *v, git_vector_cmp cmp) +{ + if (cmp != v->_cmp) { + v->_cmp = cmp; + git_vector_set_sorted(v, 0); + } +} + +/* Just use this in tests, not for realz. returns -1 if not sorted */ +int git_vector_verify_sorted(const git_vector *v); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.c new file mode 100644 index 000000000..c15757085 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.c @@ -0,0 +1,119 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#define GIT__WIN32_NO_WRAP_DIR +#include "posix.h" + +git__DIR *git__opendir(const char *dir) +{ + git_win32_path filter_w; + git__DIR *new = NULL; + size_t dirlen, alloclen; + + if (!dir || !git_win32__findfirstfile_filter(filter_w, dir)) + return NULL; + + dirlen = strlen(dir); + + if (GIT_ADD_SIZET_OVERFLOW(&alloclen, sizeof(*new), dirlen) || + GIT_ADD_SIZET_OVERFLOW(&alloclen, alloclen, 1) || + !(new = git__calloc(1, alloclen))) + return NULL; + + memcpy(new->dir, dir, dirlen); + + new->h = FindFirstFileW(filter_w, &new->f); + + if (new->h == INVALID_HANDLE_VALUE) { + giterr_set(GITERR_OS, "Could not open directory '%s'", dir); + git__free(new); + return NULL; + } + + new->first = 1; + return new; +} + +int git__readdir_ext( + git__DIR *d, + struct git__dirent *entry, + struct git__dirent **result, + int *is_dir) +{ + if (!d || !entry || !result || d->h == INVALID_HANDLE_VALUE) + return -1; + + *result = NULL; + + if (d->first) + d->first = 0; + else if (!FindNextFileW(d->h, &d->f)) { + if (GetLastError() == ERROR_NO_MORE_FILES) + return 0; + giterr_set(GITERR_OS, "Could not read from directory '%s'", d->dir); + return -1; + } + + /* Convert the path to UTF-8 */ + if (git_win32_path_to_utf8(entry->d_name, d->f.cFileName) < 0) + return -1; + + entry->d_ino = 0; + + *result = entry; + + if (is_dir != NULL) + *is_dir = ((d->f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); + + return 0; +} + +struct git__dirent *git__readdir(git__DIR *d) +{ + struct git__dirent *result; + if (git__readdir_ext(d, &d->entry, &result, NULL) < 0) + return NULL; + return result; +} + +void git__rewinddir(git__DIR *d) +{ + git_win32_path filter_w; + + if (!d) + return; + + if (d->h != INVALID_HANDLE_VALUE) { + FindClose(d->h); + d->h = INVALID_HANDLE_VALUE; + d->first = 0; + } + + if (!git_win32__findfirstfile_filter(filter_w, d->dir)) + return; + + d->h = FindFirstFileW(filter_w, &d->f); + + if (d->h == INVALID_HANDLE_VALUE) + giterr_set(GITERR_OS, "Could not open directory '%s'", d->dir); + else + d->first = 1; +} + +int git__closedir(git__DIR *d) +{ + if (!d) + return 0; + + if (d->h != INVALID_HANDLE_VALUE) { + FindClose(d->h); + d->h = INVALID_HANDLE_VALUE; + } + + git__free(d); + return 0; +} + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.h new file mode 100644 index 000000000..bef39d774 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/dir.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_dir_h__ +#define INCLUDE_dir_h__ + +#include "common.h" +#include "w32_util.h" + +struct git__dirent { + int d_ino; + git_win32_utf8_path d_name; +}; + +typedef struct { + HANDLE h; + WIN32_FIND_DATAW f; + struct git__dirent entry; + int first; + char dir[GIT_FLEX_ARRAY]; +} git__DIR; + +extern git__DIR *git__opendir(const char *); +extern struct git__dirent *git__readdir(git__DIR *); +extern int git__readdir_ext( + git__DIR *, struct git__dirent *, struct git__dirent **, int *); +extern void git__rewinddir(git__DIR *); +extern int git__closedir(git__DIR *); + +# ifndef GIT__WIN32_NO_WRAP_DIR +# define dirent git__dirent +# define DIR git__DIR +# define opendir git__opendir +# define readdir git__readdir +# define readdir_r(d,e,r) git__readdir_ext((d),(e),(r),NULL) +# define rewinddir git__rewinddir +# define closedir git__closedir +# endif + +#endif /* INCLUDE_dir_h__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/error.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/error.c new file mode 100644 index 000000000..6b450093f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/error.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "error.h" +#include "utf-conv.h" + +#ifdef GIT_WINHTTP +# include +#endif + +char *git_win32_get_error_message(DWORD error_code) +{ + LPWSTR lpMsgBuf = NULL; + HMODULE hModule = NULL; + char *utf8_msg = NULL; + DWORD dwFlags = + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS; + + if (!error_code) + return NULL; + +#ifdef GIT_WINHTTP + /* Errors raised by WinHTTP are not in the system resource table */ + if (error_code >= WINHTTP_ERROR_BASE && + error_code <= WINHTTP_ERROR_LAST) + hModule = GetModuleHandleW(L"winhttp"); +#endif + + GIT_UNUSED(hModule); + + if (hModule) + dwFlags |= FORMAT_MESSAGE_FROM_HMODULE; + else + dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM; + + if (FormatMessageW(dwFlags, hModule, error_code, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&lpMsgBuf, 0, NULL)) { + /* Convert the message to UTF-8. If this fails, we will + * return NULL, which is a condition expected by the caller */ + if (git__utf16_to_8_alloc(&utf8_msg, lpMsgBuf) < 0) + utf8_msg = NULL; + + LocalFree(lpMsgBuf); + } + + return utf8_msg; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/error.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/error.h new file mode 100644 index 000000000..12947a2e6 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/error.h @@ -0,0 +1,13 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_git_win32_error_h__ +#define INCLUDE_git_win32_error_h__ + +extern char *git_win32_get_error_message(DWORD error_code); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.c new file mode 100644 index 000000000..de27dd060 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.c @@ -0,0 +1,217 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "path_w32.h" +#include "utf-conv.h" +#include "path.h" +#include "findfile.h" + +#define REG_MSYSGIT_INSTALL_LOCAL L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" + +#ifndef _WIN64 +#define REG_MSYSGIT_INSTALL REG_MSYSGIT_INSTALL_LOCAL +#else +#define REG_MSYSGIT_INSTALL L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" +#endif + +typedef struct { + git_win32_path path; + DWORD len; +} _findfile_path; + +static int git_win32__expand_path(_findfile_path *dest, const wchar_t *src) +{ + dest->len = ExpandEnvironmentStringsW(src, dest->path, ARRAY_SIZE(dest->path)); + + if (!dest->len || dest->len > ARRAY_SIZE(dest->path)) + return -1; + + return 0; +} + +static int win32_path_to_8(git_buf *dest, const wchar_t *src) +{ + git_win32_utf8_path utf8_path; + + if (git_win32_path_to_utf8(utf8_path, src) < 0) { + giterr_set(GITERR_OS, "Unable to convert path to UTF-8"); + return -1; + } + + /* Convert backslashes to forward slashes */ + git_path_mkposix(utf8_path); + + return git_buf_sets(dest, utf8_path); +} + +static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen) +{ + wchar_t term, *base = path; + + assert(path && buf && buflen); + + term = (*path == L'"') ? *path++ : L';'; + + for (buflen--; *path && *path != term && buflen; buflen--) + *buf++ = *path++; + + *buf = L'\0'; /* reserved a byte via initial subtract */ + + while (*path == term || *path == L';') + path++; + + return (path != base) ? path : NULL; +} + +static int win32_find_git_in_path(git_buf *buf, const wchar_t *gitexe, const wchar_t *subdir) +{ + wchar_t *env = _wgetenv(L"PATH"), lastch; + _findfile_path root; + size_t gitexe_len = wcslen(gitexe); + + if (!env) + return -1; + + while ((env = win32_walkpath(env, root.path, MAX_PATH-1)) && *root.path) { + root.len = (DWORD)wcslen(root.path); + lastch = root.path[root.len - 1]; + + /* ensure trailing slash (MAX_PATH-1 to walkpath guarantees space) */ + if (lastch != L'/' && lastch != L'\\') { + root.path[root.len++] = L'\\'; + root.path[root.len] = L'\0'; + } + + if (root.len + gitexe_len >= MAX_PATH) + continue; + wcscpy(&root.path[root.len], gitexe); + + if (_waccess(root.path, F_OK) == 0 && root.len > 5) { + /* replace "bin\\" or "cmd\\" with subdir */ + wcscpy(&root.path[root.len - 4], subdir); + + win32_path_to_8(buf, root.path); + return 0; + } + } + + return GIT_ENOTFOUND; +} + +static int win32_find_git_in_registry( + git_buf *buf, const HKEY hive, const wchar_t *key, const wchar_t *subdir) +{ + HKEY hKey; + int error = GIT_ENOTFOUND; + + assert(buf); + + if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) { + DWORD dwType, cbData; + git_win32_path path; + + /* Ensure that the buffer is big enough to have the suffix attached + * after we receive the result. */ + cbData = (DWORD)(sizeof(path) - wcslen(subdir) * sizeof(wchar_t)); + + /* InstallLocation points to the root of the git directory */ + if (!RegQueryValueExW(hKey, L"InstallLocation", NULL, &dwType, (LPBYTE)path, &cbData) && + dwType == REG_SZ) { + + /* Append the suffix */ + wcscat(path, subdir); + + /* Convert to UTF-8, with forward slashes, and output the path + * to the provided buffer */ + if (!win32_path_to_8(buf, path)) + error = 0; + } + + RegCloseKey(hKey); + } + + return error; +} + +static int win32_find_existing_dirs( + git_buf *out, const wchar_t *tmpl[]) +{ + _findfile_path path16; + git_buf buf = GIT_BUF_INIT; + + git_buf_clear(out); + + for (; *tmpl != NULL; tmpl++) { + if (!git_win32__expand_path(&path16, *tmpl) && + path16.path[0] != L'%' && + !_waccess(path16.path, F_OK)) + { + win32_path_to_8(&buf, path16.path); + + if (buf.size) + git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); + } + } + + git_buf_free(&buf); + + return (git_buf_oom(out) ? -1 : 0); +} + +int git_win32__find_system_dirs(git_buf *out, const wchar_t *subdir) +{ + git_buf buf = GIT_BUF_INIT; + + /* directories where git.exe & git.cmd are found */ + if (!win32_find_git_in_path(&buf, L"git.exe", subdir) && buf.size) + git_buf_set(out, buf.ptr, buf.size); + else + git_buf_clear(out); + + if (!win32_find_git_in_path(&buf, L"git.cmd", subdir) && buf.size) + git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); + + /* directories where git is installed according to registry */ + if (!win32_find_git_in_registry( + &buf, HKEY_CURRENT_USER, REG_MSYSGIT_INSTALL_LOCAL, subdir) && buf.size) + git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); + + if (!win32_find_git_in_registry( + &buf, HKEY_LOCAL_MACHINE, REG_MSYSGIT_INSTALL, subdir) && buf.size) + git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); + + git_buf_free(&buf); + + return (git_buf_oom(out) ? -1 : 0); +} + +int git_win32__find_global_dirs(git_buf *out) +{ + static const wchar_t *global_tmpls[4] = { + L"%HOME%\\", + L"%HOMEDRIVE%%HOMEPATH%\\", + L"%USERPROFILE%\\", + NULL, + }; + + return win32_find_existing_dirs(out, global_tmpls); +} + +int git_win32__find_xdg_dirs(git_buf *out) +{ + static const wchar_t *global_tmpls[7] = { + L"%XDG_CONFIG_HOME%\\git", + L"%APPDATA%\\git", + L"%LOCALAPPDATA%\\git", + L"%HOME%\\.config\\git", + L"%HOMEDRIVE%%HOMEPATH%\\.config\\git", + L"%USERPROFILE%\\.config\\git", + NULL, + }; + + return win32_find_existing_dirs(out, global_tmpls); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.h new file mode 100644 index 000000000..a50319b9a --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/findfile.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_git_findfile_h__ +#define INCLUDE_git_findfile_h__ + +extern int git_win32__find_system_dirs(git_buf *out, const wchar_t *subpath); +extern int git_win32__find_global_dirs(git_buf *out); +extern int git_win32__find_xdg_dirs(git_buf *out); + +#endif + diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/git2.rc b/deps/libgit2-sys-0.2.17/libgit2/src/win32/git2.rc new file mode 100644 index 000000000..3571bc683 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/git2.rc @@ -0,0 +1,44 @@ +#include +#include "../../include/git2/version.h" + +#ifndef LIBGIT2_FILENAME +# define LIBGIT2_FILENAME "git2" +#endif + +#ifndef LIBGIT2_COMMENTS +# define LIBGIT2_COMMENTS "For more information visit http://libgit2.github.com/" +#endif + +VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH + PRODUCTVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0 +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + BEGIN + VALUE "FileDescription", "libgit2 - the Git linkable library\0" + VALUE "FileVersion", LIBGIT2_VERSION "\0" + VALUE "InternalName", LIBGIT2_FILENAME ".dll\0" + VALUE "LegalCopyright", "Copyright (C) the libgit2 contributors. All rights reserved.\0" + VALUE "OriginalFilename", LIBGIT2_FILENAME ".dll\0" + VALUE "ProductName", "libgit2\0" + VALUE "ProductVersion", LIBGIT2_VERSION "\0" + VALUE "Comments", LIBGIT2_COMMENTS "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/map.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/map.c new file mode 100644 index 000000000..a99c30f7e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/map.c @@ -0,0 +1,122 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "map.h" +#include + +#ifndef NO_MMAP + +static DWORD get_page_size(void) +{ + static DWORD page_size; + SYSTEM_INFO sys; + + if (!page_size) { + GetSystemInfo(&sys); + page_size = sys.dwAllocationGranularity; + } + + return page_size; +} + +int git__page_size(size_t *page_size) +{ + *page_size = get_page_size(); + return 0; +} + +int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) +{ + HANDLE fh = (HANDLE)_get_osfhandle(fd); + DWORD page_size = get_page_size(); + DWORD fmap_prot = 0; + DWORD view_prot = 0; + DWORD off_low = 0; + DWORD off_hi = 0; + git_off_t page_start; + git_off_t page_offset; + + GIT_MMAP_VALIDATE(out, len, prot, flags); + + out->data = NULL; + out->len = 0; + out->fmh = NULL; + + if (fh == INVALID_HANDLE_VALUE) { + errno = EBADF; + giterr_set(GITERR_OS, "Failed to mmap. Invalid handle value"); + return -1; + } + + if (prot & GIT_PROT_WRITE) + fmap_prot |= PAGE_READWRITE; + else if (prot & GIT_PROT_READ) + fmap_prot |= PAGE_READONLY; + + if (prot & GIT_PROT_WRITE) + view_prot |= FILE_MAP_WRITE; + if (prot & GIT_PROT_READ) + view_prot |= FILE_MAP_READ; + + page_start = (offset / page_size) * page_size; + page_offset = offset - page_start; + + if (page_offset != 0) { /* offset must be multiple of page size */ + errno = EINVAL; + giterr_set(GITERR_OS, "Failed to mmap. Offset must be multiple of page size"); + return -1; + } + + out->fmh = CreateFileMapping(fh, NULL, fmap_prot, 0, 0, NULL); + if (!out->fmh || out->fmh == INVALID_HANDLE_VALUE) { + giterr_set(GITERR_OS, "Failed to mmap. Invalid handle value"); + out->fmh = NULL; + return -1; + } + + assert(sizeof(git_off_t) == 8); + + off_low = (DWORD)(page_start); + off_hi = (DWORD)(page_start >> 32); + out->data = MapViewOfFile(out->fmh, view_prot, off_hi, off_low, len); + if (!out->data) { + giterr_set(GITERR_OS, "Failed to mmap. No data written"); + CloseHandle(out->fmh); + out->fmh = NULL; + return -1; + } + out->len = len; + + return 0; +} + +int p_munmap(git_map *map) +{ + int error = 0; + + assert(map != NULL); + + if (map->data) { + if (!UnmapViewOfFile(map->data)) { + giterr_set(GITERR_OS, "Failed to munmap. Could not unmap view of file"); + error = -1; + } + map->data = NULL; + } + + if (map->fmh) { + if (!CloseHandle(map->fmh)) { + giterr_set(GITERR_OS, "Failed to munmap. Could not close handle"); + error = -1; + } + map->fmh = NULL; + } + + return error; +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/mingw-compat.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/mingw-compat.h new file mode 100644 index 000000000..a4a5a31c7 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/mingw-compat.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_mingw_compat__ +#define INCLUDE_mingw_compat__ + +#if defined(__MINGW32__) + +#undef stat + +#if _WIN32_WINNT >= 0x0601 +#define stat __stat64 +#else +#define stat _stati64 +#endif + +#if _WIN32_WINNT < 0x0600 && !defined(__MINGW64_VERSION_MAJOR) +#undef MemoryBarrier +void __mingworg_MemoryBarrier(void); +#define MemoryBarrier __mingworg_MemoryBarrier +#define VOLUME_NAME_DOS 0x0 +#endif + +#endif + +#endif /* INCLUDE_mingw_compat__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/msvc-compat.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/msvc-compat.h new file mode 100644 index 000000000..8004bc1f8 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/msvc-compat.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_msvc_compat__ +#define INCLUDE_msvc_compat__ + +#if defined(_MSC_VER) + +/* 64-bit stat information, regardless of USE_32BIT_TIME_T define */ +#define stat __stat64 + +typedef unsigned short mode_t; +typedef SSIZE_T ssize_t; + +#define strcasecmp(s1, s2) _stricmp(s1, s2) +#define strncasecmp(s1, s2, c) _strnicmp(s1, s2, c) + +#endif + +#define GIT_STDLIB_CALL __cdecl + +#endif /* INCLUDE_msvc_compat__ */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.c new file mode 100644 index 000000000..d66969c4d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.c @@ -0,0 +1,305 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "path.h" +#include "path_w32.h" +#include "utf-conv.h" + +#define PATH__NT_NAMESPACE L"\\\\?\\" +#define PATH__NT_NAMESPACE_LEN 4 + +#define PATH__ABSOLUTE_LEN 3 + +#define path__is_dirsep(p) ((p) == '/' || (p) == '\\') + +#define path__is_absolute(p) \ + (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/')) + +#define path__is_nt_namespace(p) \ + (((p)[0] == '\\' && (p)[1] == '\\' && (p)[2] == '?' && (p)[3] == '\\') || \ + ((p)[0] == '/' && (p)[1] == '/' && (p)[2] == '?' && (p)[3] == '/')) + +#define path__is_unc(p) \ + (((p)[0] == '\\' && (p)[1] == '\\') || ((p)[0] == '/' && (p)[1] == '/')) + +GIT_INLINE(int) path__cwd(wchar_t *path, int size) +{ + int len; + + if ((len = GetCurrentDirectoryW(size, path)) == 0) { + errno = GetLastError() == ERROR_ACCESS_DENIED ? EACCES : ENOENT; + return -1; + } else if (len > size) { + errno = ENAMETOOLONG; + return -1; + } + + /* The Win32 APIs may return "\\?\" once you've used it first. + * But it may not. What a gloriously predictible API! + */ + if (wcsncmp(path, PATH__NT_NAMESPACE, PATH__NT_NAMESPACE_LEN)) + return len; + + len -= PATH__NT_NAMESPACE_LEN; + + memmove(path, path + PATH__NT_NAMESPACE_LEN, sizeof(wchar_t) * len); + return len; +} + +static wchar_t *path__skip_server(wchar_t *path) +{ + wchar_t *c; + + for (c = path; *c; c++) { + if (path__is_dirsep(*c)) + return c + 1; + } + + return c; +} + +static wchar_t *path__skip_prefix(wchar_t *path) +{ + if (path__is_nt_namespace(path)) { + path += PATH__NT_NAMESPACE_LEN; + + if (wcsncmp(path, L"UNC\\", 4) == 0) + path = path__skip_server(path + 4); + else if (path__is_absolute(path)) + path += PATH__ABSOLUTE_LEN; + } else if (path__is_absolute(path)) { + path += PATH__ABSOLUTE_LEN; + } else if (path__is_unc(path)) { + path = path__skip_server(path + 2); + } + + return path; +} + +int git_win32_path_canonicalize(git_win32_path path) +{ + wchar_t *base, *from, *to, *next; + size_t len; + + base = to = path__skip_prefix(path); + + /* Unposixify if the prefix */ + for (from = path; from < to; from++) { + if (*from == L'/') + *from = L'\\'; + } + + while (*from) { + for (next = from; *next; ++next) { + if (*next == L'/') { + *next = L'\\'; + break; + } + + if (*next == L'\\') + break; + } + + len = next - from; + + if (len == 1 && from[0] == L'.') + /* do nothing with singleton dot */; + + else if (len == 2 && from[0] == L'.' && from[1] == L'.') { + if (to == base) { + /* no more path segments to strip, eat the "../" */ + if (*next == L'\\') + len++; + + base = to; + } else { + /* back up a path segment */ + while (to > base && to[-1] == L'\\') to--; + while (to > base && to[-1] != L'\\') to--; + } + } else { + if (*next == L'\\' && *from != L'\\') + len++; + + if (to != from) + memmove(to, from, sizeof(wchar_t) * len); + + to += len; + } + + from += len; + + while (*from == L'\\') from++; + } + + /* Strip trailing backslashes */ + while (to > base && to[-1] == L'\\') to--; + + *to = L'\0'; + + return (to - path); +} + +int git_win32_path__cwd(wchar_t *out, size_t len) +{ + int cwd_len; + + if ((cwd_len = path__cwd(out, len)) < 0) + return -1; + + /* UNC paths */ + if (wcsncmp(L"\\\\", out, 2) == 0) { + /* Our buffer must be at least 5 characters larger than the + * current working directory: we swallow one of the leading + * '\'s, but we we add a 'UNC' specifier to the path, plus + * a trailing directory separator, plus a NUL. + */ + if (cwd_len > MAX_PATH - 4) { + errno = ENAMETOOLONG; + return -1; + } + + memmove(out+2, out, sizeof(wchar_t) * cwd_len); + out[0] = L'U'; + out[1] = L'N'; + out[2] = L'C'; + + cwd_len += 2; + } + + /* Our buffer must be at least 2 characters larger than the current + * working directory. (One character for the directory separator, + * one for the null. + */ + else if (cwd_len > MAX_PATH - 2) { + errno = ENAMETOOLONG; + return -1; + } + + return cwd_len; +} + +int git_win32_path_from_utf8(git_win32_path out, const char *src) +{ + wchar_t *dest = out; + + /* All win32 paths are in NT-prefixed format, beginning with "\\?\". */ + memcpy(dest, PATH__NT_NAMESPACE, sizeof(wchar_t) * PATH__NT_NAMESPACE_LEN); + dest += PATH__NT_NAMESPACE_LEN; + + /* See if this is an absolute path (beginning with a drive letter) */ + if (path__is_absolute(src)) { + if (git__utf8_to_16(dest, MAX_PATH, src) < 0) + return -1; + } + /* File-prefixed NT-style paths beginning with \\?\ */ + else if (path__is_nt_namespace(src)) { + /* Skip the NT prefix, the destination already contains it */ + if (git__utf8_to_16(dest, MAX_PATH, src + PATH__NT_NAMESPACE_LEN) < 0) + return -1; + } + /* UNC paths */ + else if (path__is_unc(src)) { + memcpy(dest, L"UNC\\", sizeof(wchar_t) * 4); + dest += 4; + + /* Skip the leading "\\" */ + if (git__utf8_to_16(dest, MAX_PATH - 2, src + 2) < 0) + return -1; + } + /* Absolute paths omitting the drive letter */ + else if (src[0] == '\\' || src[0] == '/') { + if (path__cwd(dest, MAX_PATH) < 0) + return -1; + + if (!path__is_absolute(dest)) { + errno = ENOENT; + return -1; + } + + /* Skip the drive letter specification ("C:") */ + if (git__utf8_to_16(dest + 2, MAX_PATH - 2, src) < 0) + return -1; + } + /* Relative paths */ + else { + int cwd_len; + + if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0) + return -1; + + dest[cwd_len++] = L'\\'; + + if (git__utf8_to_16(dest + cwd_len, MAX_PATH - cwd_len, src) < 0) + return -1; + } + + return git_win32_path_canonicalize(out); +} + +int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src) +{ + char *out = dest; + int len; + + /* Strip NT namespacing "\\?\" */ + if (path__is_nt_namespace(src)) { + src += 4; + + /* "\\?\UNC\server\share" -> "\\server\share" */ + if (wcsncmp(src, L"UNC\\", 4) == 0) { + src += 4; + + memcpy(dest, "\\\\", 2); + out = dest + 2; + } + } + + if ((len = git__utf16_to_8(out, GIT_WIN_PATH_UTF8, src)) < 0) + return len; + + git_path_mkposix(dest); + + return len; +} + +char *git_win32_path_8dot3_name(const char *path) +{ + git_win32_path longpath, shortpath; + wchar_t *start; + char *shortname; + int len, namelen = 1; + + if (git_win32_path_from_utf8(longpath, path) < 0) + return NULL; + + len = GetShortPathNameW(longpath, shortpath, GIT_WIN_PATH_UTF16); + + while (len && shortpath[len-1] == L'\\') + shortpath[--len] = L'\0'; + + if (len == 0 || len >= GIT_WIN_PATH_UTF16) + return NULL; + + for (start = shortpath + (len - 1); + start > shortpath && *(start-1) != '/' && *(start-1) != '\\'; + start--) + namelen++; + + /* We may not have actually been given a short name. But if we have, + * it will be in the ASCII byte range, so we don't need to worry about + * multi-byte sequences and can allocate naively. + */ + if (namelen > 12 || (shortname = git__malloc(namelen + 1)) == NULL) + return NULL; + + if ((len = git__utf16_to_8(shortname, namelen + 1, start)) < 0) + return NULL; + + return shortname; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.h new file mode 100644 index 000000000..033afbb0f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/path_w32.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_path_w32_h__ +#define INCLUDE_git_path_w32_h__ + +#include "common.h" + +/* + * Provides a large enough buffer to support Windows paths: MAX_PATH is + * 260, corresponding to a maximum path length of 259 characters plus a + * NULL terminator. Prefixing with "\\?\" adds 4 characters, but if the + * original was a UNC path, then we turn "\\server\share" into + * "\\?\UNC\server\share". So we replace the first two characters with + * 8 characters, a net gain of 6, so the maximum length is MAX_PATH+6. + */ +#define GIT_WIN_PATH_UTF16 MAX_PATH+6 + +/* Maximum size of a UTF-8 Win32 path. We remove the "\\?\" or "\\?\UNC\" + * prefixes for presentation, bringing us back to 259 (non-NULL) + * characters. UTF-8 does have 4-byte sequences, but they are encoded in + * UTF-16 using surrogate pairs, which takes up the space of two characters. + * Two characters in the range U+0800 -> U+FFFF take up more space in UTF-8 + * (6 bytes) than one surrogate pair (4 bytes). + */ +#define GIT_WIN_PATH_UTF8 (259 * 3 + 1) + +/* + * The length of a Windows "shortname", for 8.3 compatibility. + */ +#define GIT_WIN_PATH_SHORTNAME 13 + +/* Win32 path types */ +typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16]; +typedef char git_win32_utf8_path[GIT_WIN_PATH_UTF8]; + +/** + * Create a Win32 path (in UCS-2 format) from a UTF-8 string. + * + * @param dest The buffer to receive the wide string. + * @param src The UTF-8 string to convert. + * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure + */ +extern int git_win32_path_from_utf8(git_win32_path dest, const char *src); + +/** + * Canonicalize a Win32 UCS-2 path so that it is suitable for delivery to the + * Win32 APIs: remove multiple directory separators, squashing to a single one, + * strip trailing directory separators, ensure directory separators are all + * canonical (always backslashes, never forward slashes) and process any + * directory entries of '.' or '..'. + * + * This processes the buffer in place. + * + * @param path The buffer to process + * @return The new length of the buffer, in wchar_t's (not counting the NULL terminator) + */ +extern int git_win32_path_canonicalize(git_win32_path path); + +/** + * Create an internal format (posix-style) UTF-8 path from a Win32 UCS-2 path. + * + * @param dest The buffer to receive the UTF-8 string. + * @param src The wide string to convert. + * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure + */ +extern int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src); + +/** + * Get the short name for the terminal path component in the given path. + * For example, given "C:\Foo\Bar\Asdf.txt", this will return the short name + * for the file "Asdf.txt". + * + * @param path The given path in UTF-8 + * @return The name of the shortname for the given path + */ +extern char *git_win32_path_8dot3_name(const char *path); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/posix.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/posix.h new file mode 100644 index 000000000..4bc6bfe2e --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/posix.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_posix__w32_h__ +#define INCLUDE_posix__w32_h__ + +#include "common.h" +#include "../posix.h" +#include "path_w32.h" +#include "utf-conv.h" +#include "dir.h" + +typedef SOCKET GIT_SOCKET; + +#define p_lseek(f,n,w) _lseeki64(f, n, w) +#define p_fstat(f,b) _fstat64(f, b) +extern int p_lstat(const char *file_name, struct stat *buf); +extern int p_stat(const char* path, struct stat* buf); + +extern int p_readlink(const char *path, char *buf, size_t bufsiz); +extern int p_symlink(const char *old, const char *new); +extern int p_link(const char *old, const char *new); +extern int p_unlink(const char *path); +extern int p_mkdir(const char *path, mode_t mode); +extern int p_fsync(int fd); +extern char *p_realpath(const char *orig_path, char *buffer); + +extern int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags); +extern int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags); +extern int p_inet_pton(int af, const char* src, void* dst); + +extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr); +extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4); +extern int p_mkstemp(char *tmp_path); +extern int p_chdir(const char* path); +extern int p_chmod(const char* path, mode_t mode); +extern int p_rmdir(const char* path); +extern int p_access(const char* path, mode_t mode); +extern int p_ftruncate(int fd, git_off_t size); + +/* p_lstat is almost but not quite POSIX correct. Specifically, the use of + * ENOTDIR is wrong, in that it does not mean precisely that a non-directory + * entry was encountered. Making it correct is potentially expensive, + * however, so this is a separate version of p_lstat to use when correct + * POSIX ENOTDIR semantics is required. + */ +extern int p_lstat_posixly(const char *filename, struct stat *buf); + +extern struct tm * p_localtime_r (const time_t *timer, struct tm *result); +extern struct tm * p_gmtime_r (const time_t *timer, struct tm *result); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/posix_w32.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/posix_w32.c new file mode 100644 index 000000000..544b1ebd5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/posix_w32.c @@ -0,0 +1,776 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#include "../posix.h" +#include "../fileops.h" +#include "path.h" +#include "path_w32.h" +#include "utf-conv.h" +#include "repository.h" +#include "reparse.h" +#include +#include +#include +#include + +#ifndef FILE_NAME_NORMALIZED +# define FILE_NAME_NORMALIZED 0 +#endif + +#ifndef IO_REPARSE_TAG_SYMLINK +#define IO_REPARSE_TAG_SYMLINK (0xA000000CL) +#endif + +/* Options which we always provide to _wopen. + * + * _O_BINARY - Raw access; no translation of CR or LF characters + * _O_NOINHERIT - Do not mark the created handle as inheritable by child processes. + * The Windows default is 'not inheritable', but the CRT's default (following + * POSIX convention) is 'inheritable'. We have no desire for our handles to be + * inheritable on Windows, so specify the flag to get default behavior back. */ +#define STANDARD_OPEN_FLAGS (_O_BINARY | _O_NOINHERIT) + +/* Allowable mode bits on Win32. Using mode bits that are not supported on + * Win32 (eg S_IRWXU) is generally ignored, but Wine warns loudly about it + * so we simply remove them. + */ +#define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE) + +/* GetFinalPathNameByHandleW signature */ +typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD); + +/** + * Truncate or extend file. + * + * We now take a "git_off_t" rather than "long" because + * files may be longer than 2Gb. + */ +int p_ftruncate(int fd, git_off_t size) +{ + if (size < 0) { + errno = EINVAL; + return -1; + } + +#if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) + return ((_chsize_s(fd, size) == 0) ? 0 : -1); +#else + /* TODO MINGW32 Find a replacement for _chsize() that handles big files. */ + if (size > INT32_MAX) { + errno = EFBIG; + return -1; + } + return _chsize(fd, (long)size); +#endif +} + +int p_mkdir(const char *path, mode_t mode) +{ + git_win32_path buf; + + GIT_UNUSED(mode); + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + return _wmkdir(buf); +} + +int p_link(const char *old, const char *new) +{ + GIT_UNUSED(old); + GIT_UNUSED(new); + errno = ENOSYS; + return -1; +} + +int p_unlink(const char *path) +{ + git_win32_path buf; + int error; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + error = _wunlink(buf); + + /* If the file could not be deleted because it was + * read-only, clear the bit and try again */ + if (error == -1 && errno == EACCES) { + _wchmod(buf, 0666); + error = _wunlink(buf); + } + + return error; +} + +int p_fsync(int fd) +{ + HANDLE fh = (HANDLE)_get_osfhandle(fd); + + if (fh == INVALID_HANDLE_VALUE) { + errno = EBADF; + return -1; + } + + if (!FlushFileBuffers(fh)) { + DWORD code = GetLastError(); + + if (code == ERROR_INVALID_HANDLE) + errno = EINVAL; + else + errno = EIO; + + return -1; + } + + return 0; +} + +GIT_INLINE(time_t) filetime_to_time_t(const FILETIME *ft) +{ + long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; + winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */ + winTime /= 10000000; /* Nano to seconds resolution */ + return (time_t)winTime; +} + +static bool path_is_volume(wchar_t *target, size_t target_len) +{ + return (target_len && wcsncmp(target, L"\\??\\Volume{", 11) == 0); +} + +/* On success, returns the length, in characters, of the path stored in dest. + * On failure, returns a negative value. */ +static int readlink_w( + git_win32_path dest, + const git_win32_path path) +{ + BYTE buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + GIT_REPARSE_DATA_BUFFER *reparse_buf = (GIT_REPARSE_DATA_BUFFER *)buf; + HANDLE handle = NULL; + DWORD ioctl_ret; + wchar_t *target; + size_t target_len; + + int error = -1; + + handle = CreateFileW(path, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (handle == INVALID_HANDLE_VALUE) { + errno = ENOENT; + return -1; + } + + if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, + reparse_buf, sizeof(buf), &ioctl_ret, NULL)) { + errno = EINVAL; + goto on_error; + } + + switch (reparse_buf->ReparseTag) { + case IO_REPARSE_TAG_SYMLINK: + target = reparse_buf->SymbolicLinkReparseBuffer.PathBuffer + + (reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); + target_len = reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR); + break; + case IO_REPARSE_TAG_MOUNT_POINT: + target = reparse_buf->MountPointReparseBuffer.PathBuffer + + (reparse_buf->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); + target_len = reparse_buf->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); + break; + default: + errno = EINVAL; + goto on_error; + } + + if (path_is_volume(target, target_len)) { + /* This path is a reparse point that represents another volume mounted + * at this location, it is not a symbolic link our input was canonical. + */ + errno = EINVAL; + error = -1; + } else if (target_len) { + /* The path may need to have a prefix removed. */ + target_len = git_win32__canonicalize_path(target, target_len); + + /* Need one additional character in the target buffer + * for the terminating NULL. */ + if (GIT_WIN_PATH_UTF16 > target_len) { + wcscpy(dest, target); + error = (int)target_len; + } + } + +on_error: + CloseHandle(handle); + return error; +} + +#define WIN32_IS_WSEP(CH) ((CH) == L'/' || (CH) == L'\\') + +static int lstat_w( + wchar_t *path, + struct stat *buf, + bool posix_enotdir) +{ + WIN32_FILE_ATTRIBUTE_DATA fdata; + + if (GetFileAttributesExW(path, GetFileExInfoStandard, &fdata)) { + int fMode = S_IREAD; + + if (!buf) + return 0; + + if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + fMode |= S_IFDIR; + else + fMode |= S_IFREG; + + if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) + fMode |= S_IWRITE; + + buf->st_ino = 0; + buf->st_gid = 0; + buf->st_uid = 0; + buf->st_nlink = 1; + buf->st_mode = (mode_t)fMode; + buf->st_size = ((git_off_t)fdata.nFileSizeHigh << 32) + fdata.nFileSizeLow; + buf->st_dev = buf->st_rdev = (_getdrive() - 1); + buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime)); + buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime)); + buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); + + if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { + git_win32_path target; + + if (readlink_w(target, path) >= 0) { + buf->st_mode = (buf->st_mode & ~S_IFMT) | S_IFLNK; + + /* st_size gets the UTF-8 length of the target name, in bytes, + * not counting the NULL terminator */ + if ((buf->st_size = git__utf16_to_8(NULL, 0, target)) < 0) + return -1; + } + } + + return 0; + } + + errno = ENOENT; + + /* To match POSIX behavior, set ENOTDIR when any of the folders in the + * file path is a regular file, otherwise set ENOENT. + */ + if (posix_enotdir) { + size_t path_len = wcslen(path); + + /* scan up path until we find an existing item */ + while (1) { + DWORD attrs; + + /* remove last directory component */ + for (path_len--; path_len > 0 && !WIN32_IS_WSEP(path[path_len]); path_len--); + + if (path_len <= 0) + break; + + path[path_len] = L'\0'; + attrs = GetFileAttributesW(path); + + if (attrs != INVALID_FILE_ATTRIBUTES) { + if (!(attrs & FILE_ATTRIBUTE_DIRECTORY)) + errno = ENOTDIR; + break; + } + } + } + + return -1; +} + +static int do_lstat(const char *path, struct stat *buf, bool posixly_correct) +{ + git_win32_path path_w; + int len; + + if ((len = git_win32_path_from_utf8(path_w, path)) < 0) + return -1; + + git_win32__path_trim_end(path_w, len); + + return lstat_w(path_w, buf, posixly_correct); +} + +int p_lstat(const char *filename, struct stat *buf) +{ + return do_lstat(filename, buf, false); +} + +int p_lstat_posixly(const char *filename, struct stat *buf) +{ + return do_lstat(filename, buf, true); +} + +int p_readlink(const char *path, char *buf, size_t bufsiz) +{ + git_win32_path path_w, target_w; + git_win32_utf8_path target; + int len; + + /* readlink(2) does not NULL-terminate the string written + * to the target buffer. Furthermore, the target buffer need + * not be large enough to hold the entire result. A truncated + * result should be written in this case. Since this truncation + * could occur in the middle of the encoding of a code point, + * we need to buffer the result on the stack. */ + + if (git_win32_path_from_utf8(path_w, path) < 0 || + readlink_w(target_w, path_w) < 0 || + (len = git_win32_path_to_utf8(target, target_w)) < 0) + return -1; + + bufsiz = min((size_t)len, bufsiz); + memcpy(buf, target, bufsiz); + + return (int)bufsiz; +} + +int p_symlink(const char *old, const char *new) +{ + /* Real symlinks on NTFS require admin privileges. Until this changes, + * libgit2 just creates a text file with the link target in the contents. + */ + return git_futils_fake_symlink(old, new); +} + +int p_open(const char *path, int flags, ...) +{ + git_win32_path buf; + mode_t mode = 0; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + if (flags & O_CREAT) { + va_list arg_list; + + va_start(arg_list, flags); + mode = (mode_t)va_arg(arg_list, int); + va_end(arg_list); + } + + return _wopen(buf, flags | STANDARD_OPEN_FLAGS, mode & WIN32_MODE_MASK); +} + +int p_creat(const char *path, mode_t mode) +{ + git_win32_path buf; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + return _wopen(buf, + _O_WRONLY | _O_CREAT | _O_TRUNC | STANDARD_OPEN_FLAGS, + mode & WIN32_MODE_MASK); +} + +int p_getcwd(char *buffer_out, size_t size) +{ + git_win32_path buf; + wchar_t *cwd = _wgetcwd(buf, GIT_WIN_PATH_UTF16); + + if (!cwd) + return -1; + + /* Convert the working directory back to UTF-8 */ + if (git__utf16_to_8(buffer_out, size, cwd) < 0) { + DWORD code = GetLastError(); + + if (code == ERROR_INSUFFICIENT_BUFFER) + errno = ERANGE; + else + errno = EINVAL; + + return -1; + } + + return 0; +} + +/* + * Returns the address of the GetFinalPathNameByHandleW function. + * This function is available on Windows Vista and higher. + */ +static PFGetFinalPathNameByHandleW get_fpnbyhandle(void) +{ + static PFGetFinalPathNameByHandleW pFunc = NULL; + PFGetFinalPathNameByHandleW toReturn = pFunc; + + if (!toReturn) { + HMODULE hModule = GetModuleHandleW(L"kernel32"); + + if (hModule) + toReturn = (PFGetFinalPathNameByHandleW)GetProcAddress(hModule, "GetFinalPathNameByHandleW"); + + pFunc = toReturn; + } + + assert(toReturn); + + return toReturn; +} + +static int getfinalpath_w( + git_win32_path dest, + const wchar_t *path) +{ + PFGetFinalPathNameByHandleW pgfp = get_fpnbyhandle(); + HANDLE hFile; + DWORD dwChars; + + if (!pgfp) + return -1; + + /* Use FILE_FLAG_BACKUP_SEMANTICS so we can open a directory. Do not + * specify FILE_FLAG_OPEN_REPARSE_POINT; we want to open a handle to the + * target of the link. */ + hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (INVALID_HANDLE_VALUE == hFile) + return -1; + + /* Call GetFinalPathNameByHandle */ + dwChars = pgfp(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED); + CloseHandle(hFile); + + if (!dwChars || dwChars >= GIT_WIN_PATH_UTF16) + return -1; + + /* The path may be delivered to us with a prefix; canonicalize */ + return (int)git_win32__canonicalize_path(dest, dwChars); +} + +static int follow_and_lstat_link(git_win32_path path, struct stat* buf) +{ + git_win32_path target_w; + + if (getfinalpath_w(target_w, path) < 0) + return -1; + + return lstat_w(target_w, buf, false); +} + +int p_stat(const char* path, struct stat* buf) +{ + git_win32_path path_w; + int len; + + if ((len = git_win32_path_from_utf8(path_w, path)) < 0 || + lstat_w(path_w, buf, false) < 0) + return -1; + + /* The item is a symbolic link or mount point. No need to iterate + * to follow multiple links; use GetFinalPathNameFromHandle. */ + if (S_ISLNK(buf->st_mode)) + return follow_and_lstat_link(path_w, buf); + + return 0; +} + +int p_chdir(const char* path) +{ + git_win32_path buf; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + return _wchdir(buf); +} + +int p_chmod(const char* path, mode_t mode) +{ + git_win32_path buf; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + return _wchmod(buf, mode); +} + +int p_rmdir(const char* path) +{ + git_win32_path buf; + int error; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + error = _wrmdir(buf); + + if (error == -1) { + switch (GetLastError()) { + /* _wrmdir() is documented to return EACCES if "A program has an open + * handle to the directory." This sounds like what everybody else calls + * EBUSY. Let's convert appropriate error codes. + */ + case ERROR_SHARING_VIOLATION: + errno = EBUSY; + break; + + /* This error can be returned when trying to rmdir an extant file. */ + case ERROR_DIRECTORY: + errno = ENOTDIR; + break; + } + } + + return error; +} + +char *p_realpath(const char *orig_path, char *buffer) +{ + git_win32_path orig_path_w, buffer_w; + + if (git_win32_path_from_utf8(orig_path_w, orig_path) < 0) + return NULL; + + /* Note that if the path provided is a relative path, then the current directory + * is used to resolve the path -- which is a concurrency issue because the current + * directory is a process-wide variable. */ + if (!GetFullPathNameW(orig_path_w, GIT_WIN_PATH_UTF16, buffer_w, NULL)) { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + errno = ENAMETOOLONG; + else + errno = EINVAL; + + return NULL; + } + + /* The path must exist. */ + if (GetFileAttributesW(buffer_w) == INVALID_FILE_ATTRIBUTES) { + errno = ENOENT; + return NULL; + } + + if (!buffer && !(buffer = git__malloc(GIT_WIN_PATH_UTF8))) { + errno = ENOMEM; + return NULL; + } + + /* Convert the path to UTF-8. If the caller provided a buffer, then it + * is assumed to be GIT_WIN_PATH_UTF8 characters in size. If it isn't, + * then we may overflow. */ + if (git_win32_path_to_utf8(buffer, buffer_w) < 0) + return NULL; + + git_path_mkposix(buffer); + + return buffer; +} + +int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) +{ +#if defined(_MSC_VER) + int len; + + if (count == 0) + return _vscprintf(format, argptr); + + #if _MSC_VER >= 1500 + len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr); + #else + len = _vsnprintf(buffer, count, format, argptr); + #endif + + if (len < 0) + return _vscprintf(format, argptr); + + return len; +#else /* MinGW */ + return vsnprintf(buffer, count, format, argptr); +#endif +} + +int p_snprintf(char *buffer, size_t count, const char *format, ...) +{ + va_list va; + int r; + + va_start(va, format); + r = p_vsnprintf(buffer, count, format, va); + va_end(va); + + return r; +} + +/* TODO: wut? */ +int p_mkstemp(char *tmp_path) +{ +#if defined(_MSC_VER) && _MSC_VER >= 1500 + if (_mktemp_s(tmp_path, strlen(tmp_path) + 1) != 0) + return -1; +#else + if (_mktemp(tmp_path) == NULL) + return -1; +#endif + + return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); //-V536 +} + +int p_access(const char* path, mode_t mode) +{ + git_win32_path buf; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + return _waccess(buf, mode & WIN32_MODE_MASK); +} + +static int ensure_writable(wchar_t *fpath) +{ + DWORD attrs; + + attrs = GetFileAttributesW(fpath); + if (attrs == INVALID_FILE_ATTRIBUTES) { + if (GetLastError() == ERROR_FILE_NOT_FOUND) + return 0; + + giterr_set(GITERR_OS, "failed to get attributes"); + return -1; + } + + if (!(attrs & FILE_ATTRIBUTE_READONLY)) + return 0; + + attrs &= ~FILE_ATTRIBUTE_READONLY; + if (!SetFileAttributesW(fpath, attrs)) { + giterr_set(GITERR_OS, "failed to set attributes"); + return -1; + } + + return 0; +} + +int p_rename(const char *from, const char *to) +{ + git_win32_path wfrom; + git_win32_path wto; + int rename_tries; + int rename_succeeded; + int error; + + if (git_win32_path_from_utf8(wfrom, from) < 0 || + git_win32_path_from_utf8(wto, to) < 0) + return -1; + + /* wait up to 50ms if file is locked by another thread or process */ + rename_tries = 0; + rename_succeeded = 0; + while (rename_tries < 10) { + if (ensure_writable(wto) == 0 && + MoveFileExW(wfrom, wto, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) != 0) { + rename_succeeded = 1; + break; + } + + error = GetLastError(); + if (error == ERROR_SHARING_VIOLATION || error == ERROR_ACCESS_DENIED) { + Sleep(5); + rename_tries++; + } else + break; + } + + return rename_succeeded ? 0 : -1; +} + +int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags) +{ + if ((size_t)((int)length) != length) + return -1; /* giterr_set will be done by caller */ + + return recv(socket, buffer, (int)length, flags); +} + +int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags) +{ + if ((size_t)((int)length) != length) + return -1; /* giterr_set will be done by caller */ + + return send(socket, buffer, (int)length, flags); +} + +/** + * Borrowed from http://old.nabble.com/Porting-localtime_r-and-gmtime_r-td15282276.html + * On Win32, `gmtime_r` doesn't exist but `gmtime` is threadsafe, so we can use that + */ +struct tm * +p_localtime_r (const time_t *timer, struct tm *result) +{ + struct tm *local_result; + local_result = localtime (timer); + + if (local_result == NULL || result == NULL) + return NULL; + + memcpy (result, local_result, sizeof (struct tm)); + return result; +} +struct tm * +p_gmtime_r (const time_t *timer, struct tm *result) +{ + struct tm *local_result; + local_result = gmtime (timer); + + if (local_result == NULL || result == NULL) + return NULL; + + memcpy (result, local_result, sizeof (struct tm)); + return result; +} + +int p_inet_pton(int af, const char *src, void *dst) +{ + struct sockaddr_storage sin; + void *addr; + int sin_len = sizeof(struct sockaddr_storage), addr_len; + int error = 0; + + if (af == AF_INET) { + addr = &((struct sockaddr_in *)&sin)->sin_addr; + addr_len = sizeof(struct in_addr); + } else if (af == AF_INET6) { + addr = &((struct sockaddr_in6 *)&sin)->sin6_addr; + addr_len = sizeof(struct in6_addr); + } else { + errno = EAFNOSUPPORT; + return -1; + } + + if ((error = WSAStringToAddressA((LPSTR)src, af, NULL, (LPSOCKADDR)&sin, &sin_len)) == 0) { + memcpy(dst, addr, addr_len); + return 1; + } + + switch(WSAGetLastError()) { + case WSAEINVAL: + return 0; + case WSAEFAULT: + errno = ENOSPC; + return -1; + case WSA_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + return -1; + } + + errno = EINVAL; + return -1; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.c new file mode 100644 index 000000000..5f656a45d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.c @@ -0,0 +1 @@ +#include "precompiled.h" diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.h new file mode 100644 index 000000000..33ce106d3 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/precompiled.h @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#ifdef GIT_THREADS + #include "win32/pthread.h" +#endif + +#include "git2.h" +#include "common.h" diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.c new file mode 100644 index 000000000..ec45ecbe5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.c @@ -0,0 +1,267 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "pthread.h" +#include "../global.h" + +#define CLEAN_THREAD_EXIT 0x6F012842 + +/* The thread procedure stub used to invoke the caller's procedure + * and capture the return value for later collection. Windows will + * only hold a DWORD, but we need to be able to store an entire + * void pointer. This requires the indirection. */ +static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter) +{ + git_win32_thread *thread = lpParameter; + + thread->result = thread->proc(thread->param); + + return CLEAN_THREAD_EXIT; +} + +int git_win32__thread_create( + git_win32_thread *GIT_RESTRICT thread, + const pthread_attr_t *GIT_RESTRICT attr, + void *(*start_routine)(void*), + void *GIT_RESTRICT arg) +{ + GIT_UNUSED(attr); + + thread->result = NULL; + thread->param = arg; + thread->proc = start_routine; + thread->thread = CreateThread( + NULL, 0, git_win32__threadproc, thread, 0, NULL); + + return thread->thread ? 0 : -1; +} + +int git_win32__thread_join( + git_win32_thread *thread, + void **value_ptr) +{ + DWORD exit; + + if (WaitForSingleObject(thread->thread, INFINITE) != WAIT_OBJECT_0) + return -1; + + if (!GetExitCodeThread(thread->thread, &exit)) { + CloseHandle(thread->thread); + return -1; + } + + /* Check for the thread having exited uncleanly. If exit was unclean, + * then we don't have a return value to give back to the caller. */ + if (exit != CLEAN_THREAD_EXIT) { + assert(false); + thread->result = NULL; + } + + if (value_ptr) + *value_ptr = thread->result; + + CloseHandle(thread->thread); + return 0; +} + +int pthread_mutex_init( + pthread_mutex_t *GIT_RESTRICT mutex, + const pthread_mutexattr_t *GIT_RESTRICT mutexattr) +{ + GIT_UNUSED(mutexattr); + InitializeCriticalSection(mutex); + return 0; +} + +int pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + DeleteCriticalSection(mutex); + return 0; +} + +int pthread_mutex_lock(pthread_mutex_t *mutex) +{ + EnterCriticalSection(mutex); + return 0; +} + +int pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + LeaveCriticalSection(mutex); + return 0; +} + +int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) +{ + /* We don't support non-default attributes. */ + if (attr) + return EINVAL; + + /* This is an auto-reset event. */ + *cond = CreateEventW(NULL, FALSE, FALSE, NULL); + assert(*cond); + + /* If we can't create the event, claim that the reason was out-of-memory. + * The actual reason can be fetched with GetLastError(). */ + return *cond ? 0 : ENOMEM; +} + +int pthread_cond_destroy(pthread_cond_t *cond) +{ + BOOL closed; + + if (!cond) + return EINVAL; + + closed = CloseHandle(*cond); + assert(closed); + GIT_UNUSED(closed); + + *cond = NULL; + return 0; +} + +int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +{ + int error; + DWORD wait_result; + + if (!cond || !mutex) + return EINVAL; + + /* The caller must be holding the mutex. */ + error = pthread_mutex_unlock(mutex); + + if (error) + return error; + + wait_result = WaitForSingleObject(*cond, INFINITE); + assert(WAIT_OBJECT_0 == wait_result); + GIT_UNUSED(wait_result); + + return pthread_mutex_lock(mutex); +} + +int pthread_cond_signal(pthread_cond_t *cond) +{ + BOOL signaled; + + if (!cond) + return EINVAL; + + signaled = SetEvent(*cond); + assert(signaled); + GIT_UNUSED(signaled); + + return 0; +} + +/* pthread_cond_broadcast is not implemented because doing so with just + * Win32 events is quite complicated, and no caller in libgit2 uses it + * yet. + */ +int pthread_num_processors_np(void) +{ + DWORD_PTR p, s; + int n = 0; + + if (GetProcessAffinityMask(GetCurrentProcess(), &p, &s)) + for (; p; p >>= 1) + n += p&1; + + return n ? n : 1; +} + +typedef void (WINAPI *win32_srwlock_fn)(GIT_SRWLOCK *); + +static win32_srwlock_fn win32_srwlock_initialize; +static win32_srwlock_fn win32_srwlock_acquire_shared; +static win32_srwlock_fn win32_srwlock_release_shared; +static win32_srwlock_fn win32_srwlock_acquire_exclusive; +static win32_srwlock_fn win32_srwlock_release_exclusive; + +int pthread_rwlock_init( + pthread_rwlock_t *GIT_RESTRICT lock, + const pthread_rwlockattr_t *GIT_RESTRICT attr) +{ + GIT_UNUSED(attr); + + if (win32_srwlock_initialize) + win32_srwlock_initialize(&lock->native.srwl); + else + InitializeCriticalSection(&lock->native.csec); + + return 0; +} + +int pthread_rwlock_rdlock(pthread_rwlock_t *lock) +{ + if (win32_srwlock_acquire_shared) + win32_srwlock_acquire_shared(&lock->native.srwl); + else + EnterCriticalSection(&lock->native.csec); + + return 0; +} + +int pthread_rwlock_rdunlock(pthread_rwlock_t *lock) +{ + if (win32_srwlock_release_shared) + win32_srwlock_release_shared(&lock->native.srwl); + else + LeaveCriticalSection(&lock->native.csec); + + return 0; +} + +int pthread_rwlock_wrlock(pthread_rwlock_t *lock) +{ + if (win32_srwlock_acquire_exclusive) + win32_srwlock_acquire_exclusive(&lock->native.srwl); + else + EnterCriticalSection(&lock->native.csec); + + return 0; +} + +int pthread_rwlock_wrunlock(pthread_rwlock_t *lock) +{ + if (win32_srwlock_release_exclusive) + win32_srwlock_release_exclusive(&lock->native.srwl); + else + LeaveCriticalSection(&lock->native.csec); + + return 0; +} + +int pthread_rwlock_destroy(pthread_rwlock_t *lock) +{ + if (!win32_srwlock_initialize) + DeleteCriticalSection(&lock->native.csec); + git__memzero(lock, sizeof(*lock)); + return 0; +} + +int win32_pthread_initialize(void) +{ + HMODULE hModule = GetModuleHandleW(L"kernel32"); + + if (hModule) { + win32_srwlock_initialize = (win32_srwlock_fn) + GetProcAddress(hModule, "InitializeSRWLock"); + win32_srwlock_acquire_shared = (win32_srwlock_fn) + GetProcAddress(hModule, "AcquireSRWLockShared"); + win32_srwlock_release_shared = (win32_srwlock_fn) + GetProcAddress(hModule, "ReleaseSRWLockShared"); + win32_srwlock_acquire_exclusive = (win32_srwlock_fn) + GetProcAddress(hModule, "AcquireSRWLockExclusive"); + win32_srwlock_release_exclusive = (win32_srwlock_fn) + GetProcAddress(hModule, "ReleaseSRWLockExclusive"); + } + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.h new file mode 100644 index 000000000..e4826ca7f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/pthread.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef GIT_PTHREAD_H +#define GIT_PTHREAD_H + +#include "../common.h" + +#if defined (_MSC_VER) +# define GIT_RESTRICT __restrict +#else +# define GIT_RESTRICT __restrict__ +#endif + +typedef struct { + HANDLE thread; + void *(*proc)(void *); + void *param; + void *result; +} git_win32_thread; + +typedef int pthread_mutexattr_t; +typedef int pthread_condattr_t; +typedef int pthread_attr_t; +typedef int pthread_rwlockattr_t; + +typedef CRITICAL_SECTION pthread_mutex_t; +typedef HANDLE pthread_cond_t; + +typedef struct { void *Ptr; } GIT_SRWLOCK; + +typedef struct { + union { + GIT_SRWLOCK srwl; + CRITICAL_SECTION csec; + } native; +} pthread_rwlock_t; + +#define PTHREAD_MUTEX_INITIALIZER {(void*)-1} + +int git_win32__thread_create( + git_win32_thread *GIT_RESTRICT, + const pthread_attr_t *GIT_RESTRICT, + void *(*) (void *), + void *GIT_RESTRICT); + +int git_win32__thread_join( + git_win32_thread *, + void **); + +#ifdef GIT_THREADS + +typedef git_win32_thread git_thread; + +#define git_thread_create(git_thread_ptr, attr, start_routine, arg) \ + git_win32__thread_create(git_thread_ptr, attr, start_routine, arg) +#define git_thread_join(git_thread_ptr, status) \ + git_win32__thread_join(git_thread_ptr, status) + +#endif + +int pthread_mutex_init( + pthread_mutex_t *GIT_RESTRICT mutex, + const pthread_mutexattr_t *GIT_RESTRICT mutexattr); +int pthread_mutex_destroy(pthread_mutex_t *); +int pthread_mutex_lock(pthread_mutex_t *); +int pthread_mutex_unlock(pthread_mutex_t *); + +int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); +int pthread_cond_destroy(pthread_cond_t *); +int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); +int pthread_cond_signal(pthread_cond_t *); +/* pthread_cond_broadcast is not supported on Win32 yet. */ + +int pthread_num_processors_np(void); + +int pthread_rwlock_init( + pthread_rwlock_t *GIT_RESTRICT lock, + const pthread_rwlockattr_t *GIT_RESTRICT attr); +int pthread_rwlock_rdlock(pthread_rwlock_t *); +int pthread_rwlock_rdunlock(pthread_rwlock_t *); +int pthread_rwlock_wrlock(pthread_rwlock_t *); +int pthread_rwlock_wrunlock(pthread_rwlock_t *); +int pthread_rwlock_destroy(pthread_rwlock_t *); + +extern int win32_pthread_initialize(void); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/reparse.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/reparse.h new file mode 100644 index 000000000..70f9fd652 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/reparse.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) the libgit2 contributors. All rights reserved. +* +* This file is part of libgit2, distributed under the GNU GPL v2 with +* a Linking Exception. For full terms see the included COPYING file. +*/ + +#ifndef INCLUDE_git_win32_reparse_h__ +#define INCLUDE_git_win32_reparse_h__ + +/* This structure is defined on MSDN at +* http://msdn.microsoft.com/en-us/library/windows/hardware/ff552012(v=vs.85).aspx +* +* It was formerly included in the Windows 2000 SDK and remains defined in +* MinGW, so we must define it with a silly name to avoid conflicting. +*/ +typedef struct _GIT_REPARSE_DATA_BUFFER { + ULONG ReparseTag; + USHORT ReparseDataLength; + USHORT Reserved; + union { + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + ULONG Flags; + WCHAR PathBuffer[1]; + } SymbolicLinkReparseBuffer; + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + WCHAR PathBuffer[1]; + } MountPointReparseBuffer; + struct { + UCHAR DataBuffer[1]; + } GenericReparseBuffer; + }; +} GIT_REPARSE_DATA_BUFFER; + +#define REPARSE_DATA_HEADER_SIZE 8 +#define REPARSE_DATA_MOUNTPOINT_HEADER_SIZE 8 +#define REPARSE_DATA_UNION_SIZE 12 + +/* Missing in MinGW */ +#ifndef FSCTL_GET_REPARSE_POINT +# define FSCTL_GET_REPARSE_POINT 0x000900a8 +#endif + +/* Missing in MinGW */ +#ifndef FSCTL_SET_REPARSE_POINT +# define FSCTL_SET_REPARSE_POINT 0x000900a4 +#endif + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.c new file mode 100644 index 000000000..0dad4eab0 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.c @@ -0,0 +1,166 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "utf-conv.h" + +#ifndef WC_ERR_INVALID_CHARS +# define WC_ERR_INVALID_CHARS 0x80 +#endif + +GIT_INLINE(DWORD) get_wc_flags(void) +{ + static char inited = 0; + static DWORD flags; + + /* Invalid code point check supported on Vista+ only */ + if (!inited) { + flags = git_has_win32_version(6, 0, 0) ? WC_ERR_INVALID_CHARS : 0; + inited = 1; + } + + return flags; +} + +GIT_INLINE(void) git__set_errno(void) +{ + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + errno = ENAMETOOLONG; + else + errno = EINVAL; +} + +/** + * Converts a UTF-8 string to wide characters. + * + * @param dest The buffer to receive the wide string. + * @param dest_size The size of the buffer, in characters. + * @param src The UTF-8 string to convert. + * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure + */ +int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src) +{ + int len; + + /* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to + * turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's + * length. MultiByteToWideChar never returns int's minvalue, so underflow is not possible */ + if ((len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, dest, (int)dest_size) - 1) < 0) + git__set_errno(); + + return len; +} + +/** + * Converts a wide string to UTF-8. + * + * @param dest The buffer to receive the UTF-8 string. + * @param dest_size The size of the buffer, in bytes. + * @param src The wide string to convert. + * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure + */ +int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src) +{ + int len; + + /* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to + * turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's + * length. WideCharToMultiByte never returns int's minvalue, so underflow is not possible */ + if ((len = WideCharToMultiByte(CP_UTF8, get_wc_flags(), src, -1, dest, (int)dest_size, NULL, NULL) - 1) < 0) + git__set_errno(); + + return len; +} + +/** + * Converts a UTF-8 string to wide characters. + * Memory is allocated to hold the converted string. + * The caller is responsible for freeing the string with git__free. + * + * @param dest Receives a pointer to the wide string. + * @param src The UTF-8 string to convert. + * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure + */ +int git__utf8_to_16_alloc(wchar_t **dest, const char *src) +{ + int utf16_size; + + *dest = NULL; + + /* Length of -1 indicates NULL termination of the input string */ + utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, NULL, 0); + + if (!utf16_size) { + git__set_errno(); + return -1; + } + + if (!(*dest = git__mallocarray(utf16_size, sizeof(wchar_t)))) { + errno = ENOMEM; + return -1; + } + + utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, *dest, utf16_size); + + if (!utf16_size) { + git__set_errno(); + + git__free(*dest); + *dest = NULL; + } + + /* Subtract 1 from the result to turn 0 into -1 (an error code) and to not count the NULL + * terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue, + * so underflow is not possible */ + return utf16_size - 1; +} + +/** + * Converts a wide string to UTF-8. + * Memory is allocated to hold the converted string. + * The caller is responsible for freeing the string with git__free. + * + * @param dest Receives a pointer to the UTF-8 string. + * @param src The wide string to convert. + * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure + */ +int git__utf16_to_8_alloc(char **dest, const wchar_t *src) +{ + int utf8_size; + DWORD dwFlags = get_wc_flags(); + + *dest = NULL; + + /* Length of -1 indicates NULL termination of the input string */ + utf8_size = WideCharToMultiByte(CP_UTF8, dwFlags, src, -1, NULL, 0, NULL, NULL); + + if (!utf8_size) { + git__set_errno(); + return -1; + } + + *dest = git__malloc(utf8_size); + + if (!*dest) { + errno = ENOMEM; + return -1; + } + + utf8_size = WideCharToMultiByte(CP_UTF8, dwFlags, src, -1, *dest, utf8_size, NULL, NULL); + + if (!utf8_size) { + git__set_errno(); + + git__free(*dest); + *dest = NULL; + } + + /* Subtract 1 from the result to turn 0 into -1 (an error code) and to not count the NULL + * terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue, + * so underflow is not possible */ + return utf8_size - 1; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.h new file mode 100644 index 000000000..89cdb96da --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/utf-conv.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_utfconv_h__ +#define INCLUDE_git_utfconv_h__ + +#include +#include "common.h" + +/** + * Converts a UTF-8 string to wide characters. + * + * @param dest The buffer to receive the wide string. + * @param dest_size The size of the buffer, in characters. + * @param src The UTF-8 string to convert. + * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure + */ +int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src); + +/** + * Converts a wide string to UTF-8. + * + * @param dest The buffer to receive the UTF-8 string. + * @param dest_size The size of the buffer, in bytes. + * @param src The wide string to convert. + * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure + */ +int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src); + +/** + * Converts a UTF-8 string to wide characters. + * Memory is allocated to hold the converted string. + * The caller is responsible for freeing the string with git__free. + * + * @param dest Receives a pointer to the wide string. + * @param src The UTF-8 string to convert. + * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure + */ +int git__utf8_to_16_alloc(wchar_t **dest, const char *src); + +/** + * Converts a wide string to UTF-8. + * Memory is allocated to hold the converted string. + * The caller is responsible for freeing the string with git__free. + * + * @param dest Receives a pointer to the UTF-8 string. + * @param src The wide string to convert. + * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure + */ +int git__utf16_to_8_alloc(char **dest, const wchar_t *src); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/version.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/version.h new file mode 100644 index 000000000..79667697f --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/version.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_win32_version_h__ +#define INCLUDE_win32_version_h__ + +#include + +GIT_INLINE(int) git_has_win32_version(int major, int minor, int service_pack) +{ + OSVERSIONINFOEX version_test = {0}; + DWORD version_test_mask; + DWORDLONG version_condition_mask = 0; + + version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + version_test.dwMajorVersion = major; + version_test.dwMinorVersion = minor; + version_test.wServicePackMajor = (WORD)service_pack; + version_test.wServicePackMinor = 0; + + version_test_mask = (VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR); + + VER_SET_CONDITION(version_condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(version_condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); + + if (!VerifyVersionInfo(&version_test, version_test_mask, version_condition_mask)) + return 0; + + return 1; +} + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.c b/deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.c new file mode 100644 index 000000000..2e52525d5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.c @@ -0,0 +1,139 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "w32_util.h" + +/** + * Creates a FindFirstFile(Ex) filter string from a UTF-8 path. + * The filter string enumerates all items in the directory. + * + * @param dest The buffer to receive the filter string. + * @param src The UTF-8 path of the directory to enumerate. + * @return True if the filter string was created successfully; false otherwise + */ +bool git_win32__findfirstfile_filter(git_win32_path dest, const char *src) +{ + static const wchar_t suffix[] = L"\\*"; + int len = git_win32_path_from_utf8(dest, src); + + /* Ensure the path was converted */ + if (len < 0) + return false; + + /* Ensure that the path does not end with a trailing slash, + * because we're about to add one. Don't rely our trim_end + * helper, because we want to remove the backslash even for + * drive letter paths, in this case. */ + if (len > 0 && + (dest[len - 1] == L'/' || dest[len - 1] == L'\\')) { + dest[len - 1] = L'\0'; + len--; + } + + /* Ensure we have enough room to add the suffix */ + if ((size_t)len >= GIT_WIN_PATH_UTF16 - CONST_STRLEN(suffix)) + return false; + + wcscat(dest, suffix); + return true; +} + +/** + * Ensures the given path (file or folder) has the +H (hidden) attribute set. + * + * @param path The path which should receive the +H bit. + * @return 0 on success; -1 on failure + */ +int git_win32__sethidden(const char *path) +{ + git_win32_path buf; + DWORD attrs; + + if (git_win32_path_from_utf8(buf, path) < 0) + return -1; + + attrs = GetFileAttributesW(buf); + + /* Ensure the path exists */ + if (attrs == INVALID_FILE_ATTRIBUTES) + return -1; + + /* If the item isn't already +H, add the bit */ + if ((attrs & FILE_ATTRIBUTE_HIDDEN) == 0 && + !SetFileAttributesW(buf, attrs | FILE_ATTRIBUTE_HIDDEN)) + return -1; + + return 0; +} + +/** + * Removes any trailing backslashes from a path, except in the case of a drive + * letter path (C:\, D:\, etc.). This function cannot fail. + * + * @param path The path which should be trimmed. + * @return The length of the modified string (<= the input length) + */ +size_t git_win32__path_trim_end(wchar_t *str, size_t len) +{ + while (1) { + if (!len || str[len - 1] != L'\\') + break; + + /* Don't trim backslashes from drive letter paths, which + * are 3 characters long and of the form C:\, D:\, etc. */ + if (len == 3 && git_win32__isalpha(str[0]) && str[1] == ':') + break; + + len--; + } + + str[len] = L'\0'; + + return len; +} + +/** + * Removes any of the following namespace prefixes from a path, + * if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail. + * + * @param path The path which should be converted. + * @return The length of the modified string (<= the input length) + */ +size_t git_win32__canonicalize_path(wchar_t *str, size_t len) +{ + static const wchar_t dosdevices_prefix[] = L"\\\?\?\\"; + static const wchar_t nt_prefix[] = L"\\\\?\\"; + static const wchar_t unc_prefix[] = L"UNC\\"; + size_t to_advance = 0; + + /* "\??\" -- DOS Devices prefix */ + if (len >= CONST_STRLEN(dosdevices_prefix) && + !wcsncmp(str, dosdevices_prefix, CONST_STRLEN(dosdevices_prefix))) { + to_advance += CONST_STRLEN(dosdevices_prefix); + len -= CONST_STRLEN(dosdevices_prefix); + } + /* "\\?\" -- NT namespace prefix */ + else if (len >= CONST_STRLEN(nt_prefix) && + !wcsncmp(str, nt_prefix, CONST_STRLEN(nt_prefix))) { + to_advance += CONST_STRLEN(nt_prefix); + len -= CONST_STRLEN(nt_prefix); + } + + /* "\??\UNC\", "\\?\UNC\" -- UNC prefix */ + if (to_advance && len >= CONST_STRLEN(unc_prefix) && + !wcsncmp(str + to_advance, unc_prefix, CONST_STRLEN(unc_prefix))) { + to_advance += CONST_STRLEN(unc_prefix); + len -= CONST_STRLEN(unc_prefix); + } + + if (to_advance) { + memmove(str, str + to_advance, len * sizeof(wchar_t)); + str[len] = L'\0'; + } + + return git_win32__path_trim_end(str, len); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.h b/deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.h new file mode 100644 index 000000000..9c1b94359 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/win32/w32_util.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_w32_util_h__ +#define INCLUDE_w32_util_h__ + +#include "utf-conv.h" +#include "path_w32.h" + +GIT_INLINE(bool) git_win32__isalpha(wchar_t c) +{ + return ((c >= L'A' && c <= L'Z') || (c >= L'a' && c <= L'z')); +} + +/** + * Creates a FindFirstFile(Ex) filter string from a UTF-8 path. + * The filter string enumerates all items in the directory. + * + * @param dest The buffer to receive the filter string. + * @param src The UTF-8 path of the directory to enumerate. + * @return True if the filter string was created successfully; false otherwise + */ +bool git_win32__findfirstfile_filter(git_win32_path dest, const char *src); + +/** + * Ensures the given path (file or folder) has the +H (hidden) attribute set. + * + * @param path The path which should receive the +H bit. + * @return 0 on success; -1 on failure + */ +int git_win32__sethidden(const char *path); + +/** + * Removes any trailing backslashes from a path, except in the case of a drive + * letter path (C:\, D:\, etc.). This function cannot fail. + * + * @param path The path which should be trimmed. + * @return The length of the modified string (<= the input length) + */ +size_t git_win32__path_trim_end(wchar_t *str, size_t len); + +/** + * Removes any of the following namespace prefixes from a path, + * if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail. + * + * @param path The path which should be converted. + * @return The length of the modified string (<= the input length) + */ +size_t git_win32__canonicalize_path(wchar_t *str, size_t len); + +#endif diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiff.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiff.h new file mode 100644 index 000000000..cb8b235b5 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiff.h @@ -0,0 +1,135 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XDIFF_H) +#define XDIFF_H + +#ifdef __cplusplus +extern "C" { +#endif /* #ifdef __cplusplus */ + + +#define XDF_NEED_MINIMAL (1 << 1) +#define XDF_IGNORE_WHITESPACE (1 << 2) +#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 3) +#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 4) +#define XDF_PATIENCE_DIFF (1 << 5) +#define XDF_HISTOGRAM_DIFF (1 << 6) +#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE | XDF_IGNORE_WHITESPACE_AT_EOL) + +#define XDL_PATCH_NORMAL '-' +#define XDL_PATCH_REVERSE '+' +#define XDL_PATCH_MODEMASK ((1 << 8) - 1) +#define XDL_PATCH_IGNOREBSPACE (1 << 8) + +#define XDL_EMIT_FUNCNAMES (1 << 0) +#define XDL_EMIT_COMMON (1 << 1) +#define XDL_EMIT_FUNCCONTEXT (1 << 2) + +#define XDL_MMB_READONLY (1 << 0) + +#define XDL_MMF_ATOMIC (1 << 0) + +#define XDL_BDOP_INS 1 +#define XDL_BDOP_CPY 2 +#define XDL_BDOP_INSB 3 + +/* merge simplification levels */ +#define XDL_MERGE_MINIMAL 0 +#define XDL_MERGE_EAGER 1 +#define XDL_MERGE_ZEALOUS 2 +#define XDL_MERGE_ZEALOUS_ALNUM 3 + +/* merge favor modes */ +#define XDL_MERGE_FAVOR_OURS 1 +#define XDL_MERGE_FAVOR_THEIRS 2 +#define XDL_MERGE_FAVOR_UNION 3 + +/* merge output styles */ +#define XDL_MERGE_DIFF3 1 + +typedef struct s_mmfile { + char *ptr; + size_t size; +} mmfile_t; + +typedef struct s_mmbuffer { + char *ptr; + size_t size; +} mmbuffer_t; + +typedef struct s_xpparam { + unsigned long flags; +} xpparam_t; + +typedef struct s_xdemitcb { + void *priv; + int (*outf)(void *, mmbuffer_t *, int); +} xdemitcb_t; + +typedef long (*find_func_t)(const char *line, long line_len, char *buffer, long buffer_size, void *priv); + +typedef struct s_xdemitconf { + long ctxlen; + long interhunkctxlen; + unsigned long flags; + find_func_t find_func; + void *find_func_priv; + void (*emit_func)(void); +} xdemitconf_t; + +typedef struct s_bdiffparam { + long bsize; +} bdiffparam_t; + + +#define xdl_malloc(x) malloc(x) +#define xdl_free(ptr) free(ptr) +#define xdl_realloc(ptr,x) realloc(ptr,x) + +void *xdl_mmfile_first(mmfile_t *mmf, long *size); +long xdl_mmfile_size(mmfile_t *mmf); + +int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdemitconf_t const *xecfg, xdemitcb_t *ecb); + +typedef struct s_xmparam { + xpparam_t xpp; + int marker_size; + int level; + int favor; + int style; + const char *ancestor; /* label for orig */ + const char *file1; /* label for mf1 */ + const char *file2; /* label for mf2 */ +} xmparam_t; + +#define DEFAULT_CONFLICT_MARKER_SIZE 7 + +int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2, + xmparam_t const *xmp, mmbuffer_t *result); + +#ifdef __cplusplus +} +#endif /* #ifdef __cplusplus */ + +#endif /* #if !defined(XDIFF_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.c new file mode 100644 index 000000000..84aa0fcfe --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.c @@ -0,0 +1,572 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#include "xinclude.h" + + + +#define XDL_MAX_COST_MIN 256 +#define XDL_HEUR_MIN_COST 256 +#define XDL_LINE_MAX (long)((1UL << (CHAR_BIT * sizeof(long) - 1)) - 1) +#define XDL_SNAKE_CNT 20 +#define XDL_K_HEUR 4 + + + +typedef struct s_xdpsplit { + long i1, i2; + int min_lo, min_hi; +} xdpsplit_t; + + + + +static long xdl_split(unsigned long const *ha1, long off1, long lim1, + unsigned long const *ha2, long off2, long lim2, + long *kvdf, long *kvdb, int need_min, xdpsplit_t *spl, + xdalgoenv_t *xenv); +static xdchange_t *xdl_add_change(xdchange_t *xscr, long i1, long i2, long chg1, long chg2); + + + + + +/* + * See "An O(ND) Difference Algorithm and its Variations", by Eugene Myers. + * Basically considers a "box" (off1, off2, lim1, lim2) and scan from both + * the forward diagonal starting from (off1, off2) and the backward diagonal + * starting from (lim1, lim2). If the K values on the same diagonal crosses + * returns the furthest point of reach. We might end up having to expensive + * cases using this algorithm is full, so a little bit of heuristic is needed + * to cut the search and to return a suboptimal point. + */ +static long xdl_split(unsigned long const *ha1, long off1, long lim1, + unsigned long const *ha2, long off2, long lim2, + long *kvdf, long *kvdb, int need_min, xdpsplit_t *spl, + xdalgoenv_t *xenv) { + long dmin = off1 - lim2, dmax = lim1 - off2; + long fmid = off1 - off2, bmid = lim1 - lim2; + long odd = (fmid - bmid) & 1; + long fmin = fmid, fmax = fmid; + long bmin = bmid, bmax = bmid; + long ec, d, i1, i2, prev1, best, dd, v, k; + + /* + * Set initial diagonal values for both forward and backward path. + */ + kvdf[fmid] = off1; + kvdb[bmid] = lim1; + + for (ec = 1;; ec++) { + int got_snake = 0; + + /* + * We need to extent the diagonal "domain" by one. If the next + * values exits the box boundaries we need to change it in the + * opposite direction because (max - min) must be a power of two. + * Also we initialize the external K value to -1 so that we can + * avoid extra conditions check inside the core loop. + */ + if (fmin > dmin) + kvdf[--fmin - 1] = -1; + else + ++fmin; + if (fmax < dmax) + kvdf[++fmax + 1] = -1; + else + --fmax; + + for (d = fmax; d >= fmin; d -= 2) { + if (kvdf[d - 1] >= kvdf[d + 1]) + i1 = kvdf[d - 1] + 1; + else + i1 = kvdf[d + 1]; + prev1 = i1; + i2 = i1 - d; + for (; i1 < lim1 && i2 < lim2 && ha1[i1] == ha2[i2]; i1++, i2++); + if (i1 - prev1 > xenv->snake_cnt) + got_snake = 1; + kvdf[d] = i1; + if (odd && bmin <= d && d <= bmax && kvdb[d] <= i1) { + spl->i1 = i1; + spl->i2 = i2; + spl->min_lo = spl->min_hi = 1; + return ec; + } + } + + /* + * We need to extent the diagonal "domain" by one. If the next + * values exits the box boundaries we need to change it in the + * opposite direction because (max - min) must be a power of two. + * Also we initialize the external K value to -1 so that we can + * avoid extra conditions check inside the core loop. + */ + if (bmin > dmin) + kvdb[--bmin - 1] = XDL_LINE_MAX; + else + ++bmin; + if (bmax < dmax) + kvdb[++bmax + 1] = XDL_LINE_MAX; + else + --bmax; + + for (d = bmax; d >= bmin; d -= 2) { + if (kvdb[d - 1] < kvdb[d + 1]) + i1 = kvdb[d - 1]; + else + i1 = kvdb[d + 1] - 1; + prev1 = i1; + i2 = i1 - d; + for (; i1 > off1 && i2 > off2 && ha1[i1 - 1] == ha2[i2 - 1]; i1--, i2--); + if (prev1 - i1 > xenv->snake_cnt) + got_snake = 1; + kvdb[d] = i1; + if (!odd && fmin <= d && d <= fmax && i1 <= kvdf[d]) { + spl->i1 = i1; + spl->i2 = i2; + spl->min_lo = spl->min_hi = 1; + return ec; + } + } + + if (need_min) + continue; + + /* + * If the edit cost is above the heuristic trigger and if + * we got a good snake, we sample current diagonals to see + * if some of the, have reached an "interesting" path. Our + * measure is a function of the distance from the diagonal + * corner (i1 + i2) penalized with the distance from the + * mid diagonal itself. If this value is above the current + * edit cost times a magic factor (XDL_K_HEUR) we consider + * it interesting. + */ + if (got_snake && ec > xenv->heur_min) { + for (best = 0, d = fmax; d >= fmin; d -= 2) { + dd = d > fmid ? d - fmid: fmid - d; + i1 = kvdf[d]; + i2 = i1 - d; + v = (i1 - off1) + (i2 - off2) - dd; + + if (v > XDL_K_HEUR * ec && v > best && + off1 + xenv->snake_cnt <= i1 && i1 < lim1 && + off2 + xenv->snake_cnt <= i2 && i2 < lim2) { + for (k = 1; ha1[i1 - k] == ha2[i2 - k]; k++) + if (k == xenv->snake_cnt) { + best = v; + spl->i1 = i1; + spl->i2 = i2; + break; + } + } + } + if (best > 0) { + spl->min_lo = 1; + spl->min_hi = 0; + return ec; + } + + for (best = 0, d = bmax; d >= bmin; d -= 2) { + dd = d > bmid ? d - bmid: bmid - d; + i1 = kvdb[d]; + i2 = i1 - d; + v = (lim1 - i1) + (lim2 - i2) - dd; + + if (v > XDL_K_HEUR * ec && v > best && + off1 < i1 && i1 <= lim1 - xenv->snake_cnt && + off2 < i2 && i2 <= lim2 - xenv->snake_cnt) { + for (k = 0; ha1[i1 + k] == ha2[i2 + k]; k++) + if (k == xenv->snake_cnt - 1) { + best = v; + spl->i1 = i1; + spl->i2 = i2; + break; + } + } + } + if (best > 0) { + spl->min_lo = 0; + spl->min_hi = 1; + return ec; + } + } + + /* + * Enough is enough. We spent too much time here and now we collect + * the furthest reaching path using the (i1 + i2) measure. + */ + if (ec >= xenv->mxcost) { + long fbest, fbest1, bbest, bbest1; + + fbest = fbest1 = -1; + for (d = fmax; d >= fmin; d -= 2) { + i1 = XDL_MIN(kvdf[d], lim1); + i2 = i1 - d; + if (lim2 < i2) + i1 = lim2 + d, i2 = lim2; + if (fbest < i1 + i2) { + fbest = i1 + i2; + fbest1 = i1; + } + } + + bbest = bbest1 = XDL_LINE_MAX; + for (d = bmax; d >= bmin; d -= 2) { + i1 = XDL_MAX(off1, kvdb[d]); + i2 = i1 - d; + if (i2 < off2) + i1 = off2 + d, i2 = off2; + if (i1 + i2 < bbest) { + bbest = i1 + i2; + bbest1 = i1; + } + } + + if ((lim1 + lim2) - bbest < fbest - (off1 + off2)) { + spl->i1 = fbest1; + spl->i2 = fbest - fbest1; + spl->min_lo = 1; + spl->min_hi = 0; + } else { + spl->i1 = bbest1; + spl->i2 = bbest - bbest1; + spl->min_lo = 0; + spl->min_hi = 1; + } + return ec; + } + } +} + + +/* + * Rule: "Divide et Impera". Recursively split the box in sub-boxes by calling + * the box splitting function. Note that the real job (marking changed lines) + * is done in the two boundary reaching checks. + */ +int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1, + diffdata_t *dd2, long off2, long lim2, + long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv) { + unsigned long const *ha1 = dd1->ha, *ha2 = dd2->ha; + + /* + * Shrink the box by walking through each diagonal snake (SW and NE). + */ + for (; off1 < lim1 && off2 < lim2 && ha1[off1] == ha2[off2]; off1++, off2++); + for (; off1 < lim1 && off2 < lim2 && ha1[lim1 - 1] == ha2[lim2 - 1]; lim1--, lim2--); + + /* + * If one dimension is empty, then all records on the other one must + * be obviously changed. + */ + if (off1 == lim1) { + char *rchg2 = dd2->rchg; + long *rindex2 = dd2->rindex; + + for (; off2 < lim2; off2++) + rchg2[rindex2[off2]] = 1; + } else if (off2 == lim2) { + char *rchg1 = dd1->rchg; + long *rindex1 = dd1->rindex; + + for (; off1 < lim1; off1++) + rchg1[rindex1[off1]] = 1; + } else { + xdpsplit_t spl; + spl.i1 = spl.i2 = 0; + + /* + * Divide ... + */ + if (xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb, + need_min, &spl, xenv) < 0) { + + return -1; + } + + /* + * ... et Impera. + */ + if (xdl_recs_cmp(dd1, off1, spl.i1, dd2, off2, spl.i2, + kvdf, kvdb, spl.min_lo, xenv) < 0 || + xdl_recs_cmp(dd1, spl.i1, lim1, dd2, spl.i2, lim2, + kvdf, kvdb, spl.min_hi, xenv) < 0) { + + return -1; + } + } + + return 0; +} + + +int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdfenv_t *xe) { + long ndiags; + long *kvd, *kvdf, *kvdb; + xdalgoenv_t xenv; + diffdata_t dd1, dd2; + + if (xpp->flags & XDF_PATIENCE_DIFF) + return xdl_do_patience_diff(mf1, mf2, xpp, xe); + + if (xpp->flags & XDF_HISTOGRAM_DIFF) + return xdl_do_histogram_diff(mf1, mf2, xpp, xe); + + if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) { + + return -1; + } + + /* + * Allocate and setup K vectors to be used by the differential algorithm. + * One is to store the forward path and one to store the backward path. + */ + ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3; + if (!(kvd = (long *) xdl_malloc((2 * ndiags + 2) * sizeof(long)))) { + + xdl_free_env(xe); + return -1; + } + kvdf = kvd; + kvdb = kvdf + ndiags; + kvdf += xe->xdf2.nreff + 1; + kvdb += xe->xdf2.nreff + 1; + + xenv.mxcost = xdl_bogosqrt(ndiags); + if (xenv.mxcost < XDL_MAX_COST_MIN) + xenv.mxcost = XDL_MAX_COST_MIN; + xenv.snake_cnt = XDL_SNAKE_CNT; + xenv.heur_min = XDL_HEUR_MIN_COST; + + dd1.nrec = xe->xdf1.nreff; + dd1.ha = xe->xdf1.ha; + dd1.rchg = xe->xdf1.rchg; + dd1.rindex = xe->xdf1.rindex; + dd2.nrec = xe->xdf2.nreff; + dd2.ha = xe->xdf2.ha; + dd2.rchg = xe->xdf2.rchg; + dd2.rindex = xe->xdf2.rindex; + + if (xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec, + kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0, &xenv) < 0) { + + xdl_free(kvd); + xdl_free_env(xe); + return -1; + } + + xdl_free(kvd); + + return 0; +} + + +static xdchange_t *xdl_add_change(xdchange_t *xscr, long i1, long i2, long chg1, long chg2) { + xdchange_t *xch; + + if (!(xch = (xdchange_t *) xdl_malloc(sizeof(xdchange_t)))) + return NULL; + + xch->next = xscr; + xch->i1 = i1; + xch->i2 = i2; + xch->chg1 = chg1; + xch->chg2 = chg2; + + return xch; +} + + +int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { + long ix, ixo, ixs, ixref, grpsiz, nrec = xdf->nrec; + char *rchg = xdf->rchg, *rchgo = xdfo->rchg; + xrecord_t **recs = xdf->recs; + + /* + * This is the same of what GNU diff does. Move back and forward + * change groups for a consistent and pretty diff output. This also + * helps in finding joinable change groups and reduce the diff size. + */ + for (ix = ixo = 0;;) { + /* + * Find the first changed line in the to-be-compacted file. + * We need to keep track of both indexes, so if we find a + * changed lines group on the other file, while scanning the + * to-be-compacted file, we need to skip it properly. Note + * that loops that are testing for changed lines on rchg* do + * not need index bounding since the array is prepared with + * a zero at position -1 and N. + */ + for (; ix < nrec && !rchg[ix]; ix++) + while (rchgo[ixo++]); + if (ix == nrec) + break; + + /* + * Record the start of a changed-group in the to-be-compacted file + * and find the end of it, on both to-be-compacted and other file + * indexes (ix and ixo). + */ + ixs = ix; + for (ix++; rchg[ix]; ix++); + for (; rchgo[ixo]; ixo++); + + do { + grpsiz = ix - ixs; + + /* + * If the line before the current change group, is equal to + * the last line of the current change group, shift backward + * the group. + */ + while (ixs > 0 && recs[ixs - 1]->ha == recs[ix - 1]->ha && + xdl_recmatch(recs[ixs - 1]->ptr, recs[ixs - 1]->size, recs[ix - 1]->ptr, recs[ix - 1]->size, flags)) { + rchg[--ixs] = 1; + rchg[--ix] = 0; + + /* + * This change might have joined two change groups, + * so we try to take this scenario in account by moving + * the start index accordingly (and so the other-file + * end-of-group index). + */ + for (; rchg[ixs - 1]; ixs--); + while (rchgo[--ixo]); + } + + /* + * Record the end-of-group position in case we are matched + * with a group of changes in the other file (that is, the + * change record before the end-of-group index in the other + * file is set). + */ + ixref = rchgo[ixo - 1] ? ix: nrec; + + /* + * If the first line of the current change group, is equal to + * the line next of the current change group, shift forward + * the group. + */ + while (ix < nrec && recs[ixs]->ha == recs[ix]->ha && + xdl_recmatch(recs[ixs]->ptr, recs[ixs]->size, recs[ix]->ptr, recs[ix]->size, flags)) { + rchg[ixs++] = 0; + rchg[ix++] = 1; + + /* + * This change might have joined two change groups, + * so we try to take this scenario in account by moving + * the start index accordingly (and so the other-file + * end-of-group index). Keep tracking the reference + * index in case we are shifting together with a + * corresponding group of changes in the other file. + */ + for (; rchg[ix]; ix++); + while (rchgo[++ixo]) + ixref = ix; + } + } while (grpsiz != ix - ixs); + + /* + * Try to move back the possibly merged group of changes, to match + * the recorded position in the other file. + */ + while (ixref < ix) { + rchg[--ixs] = 1; + rchg[--ix] = 0; + while (rchgo[--ixo]); + } + } + + return 0; +} + + +int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr) { + xdchange_t *cscr = NULL, *xch; + char *rchg1 = xe->xdf1.rchg, *rchg2 = xe->xdf2.rchg; + long i1, i2, l1, l2; + + /* + * Trivial. Collects "groups" of changes and creates an edit script. + */ + for (i1 = xe->xdf1.nrec, i2 = xe->xdf2.nrec; i1 >= 0 || i2 >= 0; i1--, i2--) + if (rchg1[i1 - 1] || rchg2[i2 - 1]) { + for (l1 = i1; rchg1[i1 - 1]; i1--); + for (l2 = i2; rchg2[i2 - 1]; i2--); + + if (!(xch = xdl_add_change(cscr, i1, i2, l1 - i1, l2 - i2))) { + xdl_free_script(cscr); + return -1; + } + cscr = xch; + } + + *xscr = cscr; + + return 0; +} + + +void xdl_free_script(xdchange_t *xscr) { + xdchange_t *xch; + + while ((xch = xscr) != NULL) { + xscr = xscr->next; + xdl_free(xch); + } +} + + +int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdemitconf_t const *xecfg, xdemitcb_t *ecb) { + xdchange_t *xscr; + xdfenv_t xe; + emit_func_t ef = xecfg->emit_func ? + (emit_func_t)xecfg->emit_func : xdl_emit_diff; + + if (xdl_do_diff(mf1, mf2, xpp, &xe) < 0) { + + return -1; + } + if (xdl_change_compact(&xe.xdf1, &xe.xdf2, xpp->flags) < 0 || + xdl_change_compact(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 || + xdl_build_script(&xe, &xscr) < 0) { + + xdl_free_env(&xe); + return -1; + } + if (xscr) { + if (ef(&xe, xscr, ecb, xecfg) < 0) { + + xdl_free_script(xscr); + xdl_free_env(&xe); + return -1; + } + xdl_free_script(xscr); + } + xdl_free_env(&xe); + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.h new file mode 100644 index 000000000..7a92ea9c4 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xdiffi.h @@ -0,0 +1,63 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XDIFFI_H) +#define XDIFFI_H + + +typedef struct s_diffdata { + long nrec; + unsigned long const *ha; + long *rindex; + char *rchg; +} diffdata_t; + +typedef struct s_xdalgoenv { + long mxcost; + long snake_cnt; + long heur_min; +} xdalgoenv_t; + +typedef struct s_xdchange { + struct s_xdchange *next; + long i1, i2; + long chg1, chg2; +} xdchange_t; + + + +int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1, + diffdata_t *dd2, long off2, long lim2, + long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv); +int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdfenv_t *xe); +int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags); +int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr); +void xdl_free_script(xdchange_t *xscr); +int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg); +int xdl_do_patience_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdfenv_t *env); +int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdfenv_t *env); + +#endif /* #if !defined(XDIFFI_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.c new file mode 100644 index 000000000..e3e63d902 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.c @@ -0,0 +1,253 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#include "xinclude.h" + + + + +static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec); +static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb); + + + + +static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec) { + + *rec = xdf->recs[ri]->ptr; + + return xdf->recs[ri]->size; +} + + +static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb) { + long size, psize = (long)strlen(pre); + char const *rec; + + size = xdl_get_rec(xdf, ri, &rec); + if (xdl_emit_diffrec(rec, size, pre, psize, ecb) < 0) { + + return -1; + } + + return 0; +} + + +/* + * Starting at the passed change atom, find the latest change atom to be included + * inside the differential hunk according to the specified configuration. + */ +xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg) { + xdchange_t *xch, *xchp; + long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen; + + for (xchp = xscr, xch = xscr->next; xch; xchp = xch, xch = xch->next) + if (xch->i1 - (xchp->i1 + xchp->chg1) > max_common) + break; + + return xchp; +} + + +static long def_ff(const char *rec, long len, char *buf, long sz, void *priv) +{ + (void)priv; + + if (len > 0 && + (isalpha((unsigned char)*rec) || /* identifier? */ + *rec == '_' || /* also identifier? */ + *rec == '$')) { /* identifiers from VMS and other esoterico */ + if (len > sz) + len = sz; + while (0 < len && isspace((unsigned char)rec[len - 1])) + len--; + memcpy(buf, rec, len); + return len; + } + return -1; +} + +static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg) { + xdfile_t *xdf = &xe->xdf2; + const char *rchg = xdf->rchg; + long ix; + + (void)xscr; + (void)xecfg; + + for (ix = 0; ix < xdf->nrec; ix++) { + if (rchg[ix]) + continue; + if (xdl_emit_record(xdf, ix, "", ecb)) + return -1; + } + return 0; +} + +struct func_line { + long len; + char buf[80]; +}; + +static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg, + struct func_line *func_line, long start, long limit) +{ + find_func_t ff = xecfg->find_func ? xecfg->find_func : def_ff; + long l, size, step = (start > limit) ? -1 : 1; + char *buf, dummy[1]; + + buf = func_line ? func_line->buf : dummy; + size = func_line ? sizeof(func_line->buf) : sizeof(dummy); + + for (l = start; l != limit && 0 <= l && l < xe->xdf1.nrec; l += step) { + const char *rec; + long reclen = xdl_get_rec(&xe->xdf1, l, &rec); + long len = ff(rec, reclen, buf, size, xecfg->find_func_priv); + if (len >= 0) { + if (func_line) + func_line->len = len; + return l; + } + } + return -1; +} + +int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg) { + long s1, s2, e1, e2, lctx; + xdchange_t *xch, *xche; + long funclineprev = -1; + struct func_line func_line = { 0 }; + + if (xecfg->flags & XDL_EMIT_COMMON) + return xdl_emit_common(xe, xscr, ecb, xecfg); + + for (xch = xscr; xch; xch = xche->next) { + xche = xdl_get_hunk(xch, xecfg); + + s1 = XDL_MAX(xch->i1 - xecfg->ctxlen, 0); + s2 = XDL_MAX(xch->i2 - xecfg->ctxlen, 0); + + if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) { + long fs1 = get_func_line(xe, xecfg, NULL, xch->i1, -1); + if (fs1 < 0) + fs1 = 0; + if (fs1 < s1) { + s2 -= s1 - fs1; + s1 = fs1; + } + } + + again: + lctx = xecfg->ctxlen; + lctx = XDL_MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1)); + lctx = XDL_MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2)); + + e1 = xche->i1 + xche->chg1 + lctx; + e2 = xche->i2 + xche->chg2 + lctx; + + if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) { + long fe1 = get_func_line(xe, xecfg, NULL, + xche->i1 + xche->chg1, + xe->xdf1.nrec); + if (fe1 < 0) + fe1 = xe->xdf1.nrec; + if (fe1 > e1) { + e2 += fe1 - e1; + e1 = fe1; + } + + /* + * Overlap with next change? Then include it + * in the current hunk and start over to find + * its new end. + */ + if (xche->next) { + long l = xche->next->i1; + if (l <= e1 || + get_func_line(xe, xecfg, NULL, l, e1) < 0) { + xche = xche->next; + goto again; + } + } + } + + /* + * Emit current hunk header. + */ + + if (xecfg->flags & XDL_EMIT_FUNCNAMES) { + get_func_line(xe, xecfg, &func_line, + s1 - 1, funclineprev); + funclineprev = s1 - 1; + } + if (xdl_emit_hunk_hdr(s1 + 1, e1 - s1, s2 + 1, e2 - s2, + func_line.buf, func_line.len, ecb) < 0) + return -1; + + /* + * Emit pre-context. + */ + for (; s2 < xch->i2; s2++) + if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0) + return -1; + + for (s1 = xch->i1, s2 = xch->i2;; xch = xch->next) { + /* + * Merge previous with current change atom. + */ + for (; s1 < xch->i1 && s2 < xch->i2; s1++, s2++) + if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0) + return -1; + + /* + * Removes lines from the first file. + */ + for (s1 = xch->i1; s1 < xch->i1 + xch->chg1; s1++) + if (xdl_emit_record(&xe->xdf1, s1, "-", ecb) < 0) + return -1; + + /* + * Adds lines from the second file. + */ + for (s2 = xch->i2; s2 < xch->i2 + xch->chg2; s2++) + if (xdl_emit_record(&xe->xdf2, s2, "+", ecb) < 0) + return -1; + + if (xch == xche) + break; + s1 = xch->i1 + xch->chg1; + s2 = xch->i2 + xch->chg2; + } + + /* + * Emit post-context. + */ + for (s2 = xche->i2 + xche->chg2; s2 < e2; s2++) + if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0) + return -1; + } + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.h new file mode 100644 index 000000000..c2e2e8302 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xemit.h @@ -0,0 +1,36 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XEMIT_H) +#define XEMIT_H + + +typedef int (*emit_func_t)(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg); + +xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg); +int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg); + + + +#endif /* #if !defined(XEMIT_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xhistogram.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xhistogram.c new file mode 100644 index 000000000..c84812893 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xhistogram.c @@ -0,0 +1,371 @@ +/* + * Copyright (C) 2010, Google Inc. + * and other copyright owners as documented in JGit's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "xinclude.h" +#include "xtypes.h" +#include "xdiff.h" + +#define MAX_PTR UINT_MAX +#define MAX_CNT UINT_MAX + +#define LINE_END(n) (line##n + count##n - 1) +#define LINE_END_PTR(n) (*line##n + *count##n - 1) + +struct histindex { + struct record { + unsigned int ptr, cnt; + struct record *next; + } **records, /* an occurrence */ + **line_map; /* map of line to record chain */ + chastore_t rcha; + unsigned int *next_ptrs; + unsigned int table_bits, + records_size, + line_map_size; + + unsigned int max_chain_length, + key_shift, + ptr_shift; + + unsigned int cnt, + has_common; + + xdfenv_t *env; + xpparam_t const *xpp; +}; + +struct region { + unsigned int begin1, end1; + unsigned int begin2, end2; +}; + +#define LINE_MAP(i, a) (i->line_map[(a) - i->ptr_shift]) + +#define NEXT_PTR(index, ptr) \ + (index->next_ptrs[(ptr) - index->ptr_shift]) + +#define CNT(index, ptr) \ + ((LINE_MAP(index, ptr))->cnt) + +#define REC(env, s, l) \ + (env->xdf##s.recs[l - 1]) + +static int cmp_recs(xpparam_t const *xpp, + xrecord_t *r1, xrecord_t *r2) +{ + return r1->ha == r2->ha && + xdl_recmatch(r1->ptr, r1->size, r2->ptr, r2->size, + xpp->flags); +} + +#define CMP_ENV(xpp, env, s1, l1, s2, l2) \ + (cmp_recs(xpp, REC(env, s1, l1), REC(env, s2, l2))) + +#define CMP(i, s1, l1, s2, l2) \ + (cmp_recs(i->xpp, REC(i->env, s1, l1), REC(i->env, s2, l2))) + +#define TABLE_HASH(index, side, line) \ + XDL_HASHLONG((REC(index->env, side, line))->ha, index->table_bits) + +static int scanA(struct histindex *index, unsigned int line1, unsigned int count1) +{ + unsigned int ptr; + unsigned int tbl_idx; + unsigned int chain_len; + struct record **rec_chain, *rec; + + for (ptr = LINE_END(1); line1 <= ptr; ptr--) { + tbl_idx = TABLE_HASH(index, 1, ptr); + rec_chain = index->records + tbl_idx; + rec = *rec_chain; + + chain_len = 0; + while (rec) { + if (CMP(index, 1, rec->ptr, 1, ptr)) { + /* + * ptr is identical to another element. Insert + * it onto the front of the existing element + * chain. + */ + NEXT_PTR(index, ptr) = rec->ptr; + rec->ptr = ptr; + /* cap rec->cnt at MAX_CNT */ + rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1); + LINE_MAP(index, ptr) = rec; + goto continue_scan; + } + + rec = rec->next; + chain_len++; + } + + if (chain_len == index->max_chain_length) + return -1; + + /* + * This is the first time we have ever seen this particular + * element in the sequence. Construct a new chain for it. + */ + if (!(rec = xdl_cha_alloc(&index->rcha))) + return -1; + rec->ptr = ptr; + rec->cnt = 1; + rec->next = *rec_chain; + *rec_chain = rec; + LINE_MAP(index, ptr) = rec; + +continue_scan: + ; /* no op */ + } + + return 0; +} + +static int try_lcs( + struct histindex *index, struct region *lcs, unsigned int b_ptr, + unsigned int line1, unsigned int count1, + unsigned int line2, unsigned int count2) +{ + unsigned int b_next = b_ptr + 1; + struct record *rec = index->records[TABLE_HASH(index, 2, b_ptr)]; + unsigned int as, ae, bs, be, np, rc; + int should_break; + + for (; rec; rec = rec->next) { + if (rec->cnt > index->cnt) { + if (!index->has_common) + index->has_common = CMP(index, 1, rec->ptr, 2, b_ptr); + continue; + } + + as = rec->ptr; + if (!CMP(index, 1, as, 2, b_ptr)) + continue; + + index->has_common = 1; + for (;;) { + should_break = 0; + np = NEXT_PTR(index, as); + bs = b_ptr; + ae = as; + be = bs; + rc = rec->cnt; + + while (line1 < as && line2 < bs + && CMP(index, 1, as - 1, 2, bs - 1)) { + as--; + bs--; + if (1 < rc) + rc = XDL_MIN(rc, CNT(index, as)); + } + while (ae < LINE_END(1) && be < LINE_END(2) + && CMP(index, 1, ae + 1, 2, be + 1)) { + ae++; + be++; + if (1 < rc) + rc = XDL_MIN(rc, CNT(index, ae)); + } + + if (b_next <= be) + b_next = be + 1; + if (lcs->end1 - lcs->begin1 < ae - as || rc < index->cnt) { + lcs->begin1 = as; + lcs->begin2 = bs; + lcs->end1 = ae; + lcs->end2 = be; + index->cnt = rc; + } + + if (np == 0) + break; + + while (np <= ae) { + np = NEXT_PTR(index, np); + if (np == 0) { + should_break = 1; + break; + } + } + + if (should_break) + break; + + as = np; + } + } + return b_next; +} + +static int find_lcs( + struct histindex *index, struct region *lcs, + unsigned int line1, unsigned int count1, + unsigned int line2, unsigned int count2) +{ + unsigned int b_ptr; + + if (scanA(index, line1, count1)) + return -1; + + index->cnt = index->max_chain_length + 1; + + for (b_ptr = line2; b_ptr <= LINE_END(2); ) + b_ptr = try_lcs(index, lcs, b_ptr, line1, count1, line2, count2); + + return index->has_common && index->max_chain_length < index->cnt; +} + +static int fall_back_to_classic_diff(struct histindex *index, + int line1, int count1, int line2, int count2) +{ + xpparam_t xpp; + xpp.flags = index->xpp->flags & ~XDF_HISTOGRAM_DIFF; + + return xdl_fall_back_diff(index->env, &xpp, + line1, count1, line2, count2); +} + +static int histogram_diff( + xpparam_t const *xpp, xdfenv_t *env, + unsigned int line1, unsigned int count1, + unsigned int line2, unsigned int count2) +{ + struct histindex index; + struct region lcs; + unsigned int sz; + int result = -1; + + if (count1 <= 0 && count2 <= 0) + return 0; + + if (LINE_END(1) >= MAX_PTR) + return -1; + + if (!count1) { + while(count2--) + env->xdf2.rchg[line2++ - 1] = 1; + return 0; + } else if (!count2) { + while(count1--) + env->xdf1.rchg[line1++ - 1] = 1; + return 0; + } + + memset(&index, 0, sizeof(index)); + + index.env = env; + index.xpp = xpp; + + index.records = NULL; + index.line_map = NULL; + /* in case of early xdl_cha_free() */ + index.rcha.head = NULL; + + index.table_bits = xdl_hashbits(count1); + sz = index.records_size = 1 << index.table_bits; + sz *= sizeof(struct record *); + if (!(index.records = (struct record **) xdl_malloc(sz))) + goto cleanup; + memset(index.records, 0, sz); + + sz = index.line_map_size = count1; + sz *= sizeof(struct record *); + if (!(index.line_map = (struct record **) xdl_malloc(sz))) + goto cleanup; + memset(index.line_map, 0, sz); + + sz = index.line_map_size; + sz *= sizeof(unsigned int); + if (!(index.next_ptrs = (unsigned int *) xdl_malloc(sz))) + goto cleanup; + memset(index.next_ptrs, 0, sz); + + /* lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx() */ + if (xdl_cha_init(&index.rcha, sizeof(struct record), count1 / 4 + 1) < 0) + goto cleanup; + + index.ptr_shift = line1; + index.max_chain_length = 64; + + memset(&lcs, 0, sizeof(lcs)); + if (find_lcs(&index, &lcs, line1, count1, line2, count2)) + result = fall_back_to_classic_diff(&index, line1, count1, line2, count2); + else { + if (lcs.begin1 == 0 && lcs.begin2 == 0) { + while (count1--) + env->xdf1.rchg[line1++ - 1] = 1; + while (count2--) + env->xdf2.rchg[line2++ - 1] = 1; + result = 0; + } else { + result = histogram_diff(xpp, env, + line1, lcs.begin1 - line1, + line2, lcs.begin2 - line2); + if (result) + goto cleanup; + result = histogram_diff(xpp, env, + lcs.end1 + 1, LINE_END(1) - lcs.end1, + lcs.end2 + 1, LINE_END(2) - lcs.end2); + if (result) + goto cleanup; + } + } + +cleanup: + xdl_free(index.records); + xdl_free(index.line_map); + xdl_free(index.next_ptrs); + xdl_cha_free(&index.rcha); + + return result; +} + +int xdl_do_histogram_diff(mmfile_t *file1, mmfile_t *file2, + xpparam_t const *xpp, xdfenv_t *env) +{ + if (xdl_prepare_env(file1, file2, xpp, env) < 0) + return -1; + + return histogram_diff(xpp, env, + env->xdf1.dstart + 1, env->xdf1.dend - env->xdf1.dstart + 1, + env->xdf2.dstart + 1, env->xdf2.dend - env->xdf2.dstart + 1); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xinclude.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xinclude.h new file mode 100644 index 000000000..4a1cde909 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xinclude.h @@ -0,0 +1,46 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XINCLUDE_H) +#define XINCLUDE_H + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#else +#include +#endif + +#include "xmacros.h" +#include "xdiff.h" +#include "xtypes.h" +#include "xutils.h" +#include "xprepare.h" +#include "xdiffi.h" +#include "xemit.h" + + +#endif /* #if !defined(XINCLUDE_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmacros.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmacros.h new file mode 100644 index 000000000..165a895a9 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmacros.h @@ -0,0 +1,54 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XMACROS_H) +#define XMACROS_H + + + + +#define XDL_MIN(a, b) ((a) < (b) ? (a): (b)) +#define XDL_MAX(a, b) ((a) > (b) ? (a): (b)) +#define XDL_ABS(v) ((v) >= 0 ? (v): -(v)) +#define XDL_ISDIGIT(c) ((c) >= '0' && (c) <= '9') +#define XDL_ISSPACE(c) (isspace((unsigned char)(c))) +#define XDL_ADDBITS(v,b) ((v) + ((v) >> (b))) +#define XDL_MASKBITS(b) ((1UL << (b)) - 1) +#define XDL_HASHLONG(v,b) (XDL_ADDBITS((unsigned long)(v), b) & XDL_MASKBITS(b)) +#define XDL_PTRFREE(p) do { if (p) { xdl_free(p); (p) = NULL; } } while (0) +#define XDL_LE32_PUT(p, v) \ +do { \ + unsigned char *__p = (unsigned char *) (p); \ + *__p++ = (unsigned char) (v); \ + *__p++ = (unsigned char) ((v) >> 8); \ + *__p++ = (unsigned char) ((v) >> 16); \ + *__p = (unsigned char) ((v) >> 24); \ +} while (0) +#define XDL_LE32_GET(p, v) \ +do { \ + unsigned char const *__p = (unsigned char const *) (p); \ + (v) = (unsigned long) __p[0] | ((unsigned long) __p[1]) << 8 | \ + ((unsigned long) __p[2]) << 16 | ((unsigned long) __p[3]) << 24; \ +} while (0) + + +#endif /* #if !defined(XMACROS_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmerge.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmerge.c new file mode 100644 index 000000000..84e424672 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xmerge.c @@ -0,0 +1,619 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003-2006 Davide Libenzi, Johannes E. Schindelin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#include "xinclude.h" + +typedef struct s_xdmerge { + struct s_xdmerge *next; + /* + * 0 = conflict, + * 1 = no conflict, take first, + * 2 = no conflict, take second. + * 3 = no conflict, take both. + */ + int mode; + /* + * These point at the respective postimages. E.g. is + * how side #1 wants to change the common ancestor; if there is no + * overlap, lines before i1 in the postimage of side #1 appear + * in the merge result as a region touched by neither side. + */ + long i1, i2; + long chg1, chg2; + /* + * These point at the preimage; of course there is just one + * preimage, that is from the shared common ancestor. + */ + long i0; + long chg0; +} xdmerge_t; + +static int xdl_append_merge(xdmerge_t **merge, int mode, + long i0, long chg0, + long i1, long chg1, + long i2, long chg2) +{ + xdmerge_t *m = *merge; + if (m && (i1 <= m->i1 + m->chg1 || i2 <= m->i2 + m->chg2)) { + if (mode != m->mode) + m->mode = 0; + m->chg0 = i0 + chg0 - m->i0; + m->chg1 = i1 + chg1 - m->i1; + m->chg2 = i2 + chg2 - m->i2; + } else { + m = xdl_malloc(sizeof(xdmerge_t)); + if (!m) + return -1; + m->next = NULL; + m->mode = mode; + m->i0 = i0; + m->chg0 = chg0; + m->i1 = i1; + m->chg1 = chg1; + m->i2 = i2; + m->chg2 = chg2; + if (*merge) + (*merge)->next = m; + *merge = m; + } + return 0; +} + +static int xdl_cleanup_merge(xdmerge_t *c) +{ + int count = 0; + xdmerge_t *next_c; + + /* were there conflicts? */ + for (; c; c = next_c) { + if (c->mode == 0) + count++; + next_c = c->next; + free(c); + } + return count; +} + +static int xdl_merge_cmp_lines(xdfenv_t *xe1, int i1, xdfenv_t *xe2, int i2, + int line_count, long flags) +{ + int i; + xrecord_t **rec1 = xe1->xdf2.recs + i1; + xrecord_t **rec2 = xe2->xdf2.recs + i2; + + for (i = 0; i < line_count; i++) { + int result = xdl_recmatch(rec1[i]->ptr, rec1[i]->size, + rec2[i]->ptr, rec2[i]->size, flags); + if (!result) + return -1; + } + return 0; +} + +static int xdl_recs_copy_0(int use_orig, xdfenv_t *xe, int i, int count, int add_nl, char *dest) +{ + xrecord_t **recs; + int size = 0; + + recs = (use_orig ? xe->xdf1.recs : xe->xdf2.recs) + i; + + if (count < 1) + return 0; + + for (i = 0; i < count; size += recs[i++]->size) + if (dest) + memcpy(dest + size, recs[i]->ptr, recs[i]->size); + if (add_nl) { + i = recs[count - 1]->size; + if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') { + if (dest) + dest[size] = '\n'; + size++; + } + } + return size; +} + +static int xdl_recs_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest) +{ + return xdl_recs_copy_0(0, xe, i, count, add_nl, dest); +} + +static int xdl_orig_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest) +{ + return xdl_recs_copy_0(1, xe, i, count, add_nl, dest); +} + +static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, + xdfenv_t *xe2, const char *name2, + const char *name3, + int size, int i, int style, + xdmerge_t *m, char *dest, int marker_size) +{ + int marker1_size = (name1 ? (int)strlen(name1) + 1 : 0); + int marker2_size = (name2 ? (int)strlen(name2) + 1 : 0); + int marker3_size = (name3 ? (int)strlen(name3) + 1 : 0); + + if (marker_size <= 0) + marker_size = DEFAULT_CONFLICT_MARKER_SIZE; + + /* Before conflicting part */ + size += xdl_recs_copy(xe1, i, m->i1 - i, 0, + dest ? dest + size : NULL); + + if (!dest) { + size += marker_size + 1 + marker1_size; + } else { + memset(dest + size, '<', marker_size); + size += marker_size; + if (marker1_size) { + dest[size] = ' '; + memcpy(dest + size + 1, name1, marker1_size - 1); + size += marker1_size; + } + dest[size++] = '\n'; + } + + /* Postimage from side #1 */ + size += xdl_recs_copy(xe1, m->i1, m->chg1, 1, + dest ? dest + size : NULL); + + if (style == XDL_MERGE_DIFF3) { + /* Shared preimage */ + if (!dest) { + size += marker_size + 1 + marker3_size; + } else { + memset(dest + size, '|', marker_size); + size += marker_size; + if (marker3_size) { + dest[size] = ' '; + memcpy(dest + size + 1, name3, marker3_size - 1); + size += marker3_size; + } + dest[size++] = '\n'; + } + size += xdl_orig_copy(xe1, m->i0, m->chg0, 1, + dest ? dest + size : NULL); + } + + if (!dest) { + size += marker_size + 1; + } else { + memset(dest + size, '=', marker_size); + size += marker_size; + dest[size++] = '\n'; + } + + /* Postimage from side #2 */ + size += xdl_recs_copy(xe2, m->i2, m->chg2, 1, + dest ? dest + size : NULL); + if (!dest) { + size += marker_size + 1 + marker2_size; + } else { + memset(dest + size, '>', marker_size); + size += marker_size; + if (marker2_size) { + dest[size] = ' '; + memcpy(dest + size + 1, name2, marker2_size - 1); + size += marker2_size; + } + dest[size++] = '\n'; + } + return size; +} + +static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1, + xdfenv_t *xe2, const char *name2, + const char *ancestor_name, + int favor, + xdmerge_t *m, char *dest, int style, + int marker_size) +{ + int size, i; + + for (size = i = 0; m; m = m->next) { + if (favor && !m->mode) + m->mode = favor; + + if (m->mode == 0) + size = fill_conflict_hunk(xe1, name1, xe2, name2, + ancestor_name, + size, i, style, m, dest, + marker_size); + else if (m->mode & 3) { + /* Before conflicting part */ + size += xdl_recs_copy(xe1, i, m->i1 - i, 0, + dest ? dest + size : NULL); + /* Postimage from side #1 */ + if (m->mode & 1) + size += xdl_recs_copy(xe1, m->i1, m->chg1, 1, + dest ? dest + size : NULL); + /* Postimage from side #2 */ + if (m->mode & 2) + size += xdl_recs_copy(xe2, m->i2, m->chg2, 1, + dest ? dest + size : NULL); + } else + continue; + i = m->i1 + m->chg1; + } + size += xdl_recs_copy(xe1, i, xe1->xdf2.nrec - i, 0, + dest ? dest + size : NULL); + return size; +} + +/* + * Sometimes, changes are not quite identical, but differ in only a few + * lines. Try hard to show only these few lines as conflicting. + */ +static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, + xpparam_t const *xpp) +{ + for (; m; m = m->next) { + mmfile_t t1, t2; + xdfenv_t xe; + xdchange_t *xscr, *x; + int i1 = m->i1, i2 = m->i2; + + /* let's handle just the conflicts */ + if (m->mode) + continue; + + /* no sense refining a conflict when one side is empty */ + if (m->chg1 == 0 || m->chg2 == 0) + continue; + + /* + * This probably does not work outside git, since + * we have a very simple mmfile structure. + */ + t1.ptr = (char *)xe1->xdf2.recs[m->i1]->ptr; + t1.size = xe1->xdf2.recs[m->i1 + m->chg1 - 1]->ptr + + xe1->xdf2.recs[m->i1 + m->chg1 - 1]->size - t1.ptr; + t2.ptr = (char *)xe2->xdf2.recs[m->i2]->ptr; + t2.size = xe2->xdf2.recs[m->i2 + m->chg2 - 1]->ptr + + xe2->xdf2.recs[m->i2 + m->chg2 - 1]->size - t2.ptr; + if (xdl_do_diff(&t1, &t2, xpp, &xe) < 0) + return -1; + if (xdl_change_compact(&xe.xdf1, &xe.xdf2, xpp->flags) < 0 || + xdl_change_compact(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 || + xdl_build_script(&xe, &xscr) < 0) { + xdl_free_env(&xe); + return -1; + } + if (!xscr) { + /* If this happens, the changes are identical. */ + xdl_free_env(&xe); + m->mode = 4; + continue; + } + x = xscr; + m->i1 = xscr->i1 + i1; + m->chg1 = xscr->chg1; + m->i2 = xscr->i2 + i2; + m->chg2 = xscr->chg2; + while (xscr->next) { + xdmerge_t *m2 = xdl_malloc(sizeof(xdmerge_t)); + if (!m2) { + xdl_free_env(&xe); + xdl_free_script(x); + return -1; + } + xscr = xscr->next; + m2->next = m->next; + m->next = m2; + m = m2; + m->mode = 0; + m->i1 = xscr->i1 + i1; + m->chg1 = xscr->chg1; + m->i2 = xscr->i2 + i2; + m->chg2 = xscr->chg2; + } + xdl_free_env(&xe); + xdl_free_script(x); + } + return 0; +} + +static int line_contains_alnum(const char *ptr, long size) +{ + while (size--) + if (isalnum((unsigned char)*(ptr++))) + return 1; + return 0; +} + +static int lines_contain_alnum(xdfenv_t *xe, int i, int chg) +{ + for (; chg; chg--, i++) + if (line_contains_alnum(xe->xdf2.recs[i]->ptr, + xe->xdf2.recs[i]->size)) + return 1; + return 0; +} + +/* + * This function merges m and m->next, marking everything between those hunks + * as conflicting, too. + */ +static void xdl_merge_two_conflicts(xdmerge_t *m) +{ + xdmerge_t *next_m = m->next; + m->chg1 = next_m->i1 + next_m->chg1 - m->i1; + m->chg2 = next_m->i2 + next_m->chg2 - m->i2; + m->next = next_m->next; + free(next_m); +} + +/* + * If there are less than 3 non-conflicting lines between conflicts, + * it appears simpler -- because it takes up less (or as many) lines -- + * if the lines are moved into the conflicts. + */ +static int xdl_simplify_non_conflicts(xdfenv_t *xe1, xdmerge_t *m, + int simplify_if_no_alnum) +{ + int result = 0; + + if (!m) + return result; + for (;;) { + xdmerge_t *next_m = m->next; + int begin, end; + + if (!next_m) + return result; + + begin = m->i1 + m->chg1; + end = next_m->i1; + + if (m->mode != 0 || next_m->mode != 0 || + (end - begin > 3 && + (!simplify_if_no_alnum || + lines_contain_alnum(xe1, begin, end - begin)))) { + m = next_m; + } else { + result++; + xdl_merge_two_conflicts(m); + } + } +} + +/* + * level == 0: mark all overlapping changes as conflict + * level == 1: mark overlapping changes as conflict only if not identical + * level == 2: analyze non-identical changes for minimal conflict set + * level == 3: analyze non-identical changes for minimal conflict set, but + * treat hunks not containing any letter or number as conflicting + * + * returns < 0 on error, == 0 for no conflicts, else number of conflicts + */ +static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, + xdfenv_t *xe2, xdchange_t *xscr2, + xmparam_t const *xmp, mmbuffer_t *result) +{ + xdmerge_t *changes, *c; + xpparam_t const *xpp = &xmp->xpp; + const char *const ancestor_name = xmp->ancestor; + const char *const name1 = xmp->file1; + const char *const name2 = xmp->file2; + int i0, i1, i2, chg0, chg1, chg2; + int level = xmp->level; + int style = xmp->style; + int favor = xmp->favor; + + if (style == XDL_MERGE_DIFF3) { + /* + * "diff3 -m" output does not make sense for anything + * more aggressive than XDL_MERGE_EAGER. + */ + if (XDL_MERGE_EAGER < level) + level = XDL_MERGE_EAGER; + } + + c = changes = NULL; + + while (xscr1 && xscr2) { + if (!changes) + changes = c; + if (xscr1->i1 + xscr1->chg1 < xscr2->i1) { + i0 = xscr1->i1; + i1 = xscr1->i2; + i2 = xscr2->i2 - xscr2->i1 + xscr1->i1; + chg0 = xscr1->chg1; + chg1 = xscr1->chg2; + chg2 = xscr1->chg1; + if (xdl_append_merge(&c, 1, + i0, chg0, i1, chg1, i2, chg2)) { + xdl_cleanup_merge(changes); + return -1; + } + xscr1 = xscr1->next; + continue; + } + if (xscr2->i1 + xscr2->chg1 < xscr1->i1) { + i0 = xscr2->i1; + i1 = xscr1->i2 - xscr1->i1 + xscr2->i1; + i2 = xscr2->i2; + chg0 = xscr2->chg1; + chg1 = xscr2->chg1; + chg2 = xscr2->chg2; + if (xdl_append_merge(&c, 2, + i0, chg0, i1, chg1, i2, chg2)) { + xdl_cleanup_merge(changes); + return -1; + } + xscr2 = xscr2->next; + continue; + } + if (level == XDL_MERGE_MINIMAL || xscr1->i1 != xscr2->i1 || + xscr1->chg1 != xscr2->chg1 || + xscr1->chg2 != xscr2->chg2 || + xdl_merge_cmp_lines(xe1, xscr1->i2, + xe2, xscr2->i2, + xscr1->chg2, xpp->flags)) { + /* conflict */ + int off = xscr1->i1 - xscr2->i1; + int ffo = off + xscr1->chg1 - xscr2->chg1; + + i0 = xscr1->i1; + i1 = xscr1->i2; + i2 = xscr2->i2; + if (off > 0) { + i0 -= off; + i1 -= off; + } + else + i2 += off; + chg0 = xscr1->i1 + xscr1->chg1 - i0; + chg1 = xscr1->i2 + xscr1->chg2 - i1; + chg2 = xscr2->i2 + xscr2->chg2 - i2; + if (ffo < 0) { + chg0 -= ffo; + chg1 -= ffo; + } else + chg2 += ffo; + if (xdl_append_merge(&c, 0, + i0, chg0, i1, chg1, i2, chg2)) { + xdl_cleanup_merge(changes); + return -1; + } + } + + i1 = xscr1->i1 + xscr1->chg1; + i2 = xscr2->i1 + xscr2->chg1; + + if (i1 >= i2) + xscr2 = xscr2->next; + if (i2 >= i1) + xscr1 = xscr1->next; + } + while (xscr1) { + if (!changes) + changes = c; + i0 = xscr1->i1; + i1 = xscr1->i2; + i2 = xscr1->i1 + xe2->xdf2.nrec - xe2->xdf1.nrec; + chg0 = xscr1->chg1; + chg1 = xscr1->chg2; + chg2 = xscr1->chg1; + if (xdl_append_merge(&c, 1, + i0, chg0, i1, chg1, i2, chg2)) { + xdl_cleanup_merge(changes); + return -1; + } + xscr1 = xscr1->next; + } + while (xscr2) { + if (!changes) + changes = c; + i0 = xscr2->i1; + i1 = xscr2->i1 + xe1->xdf2.nrec - xe1->xdf1.nrec; + i2 = xscr2->i2; + chg0 = xscr2->chg1; + chg1 = xscr2->chg1; + chg2 = xscr2->chg2; + if (xdl_append_merge(&c, 2, + i0, chg0, i1, chg1, i2, chg2)) { + xdl_cleanup_merge(changes); + return -1; + } + xscr2 = xscr2->next; + } + if (!changes) + changes = c; + /* refine conflicts */ + if (XDL_MERGE_ZEALOUS <= level && + (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 || + xdl_simplify_non_conflicts(xe1, changes, + XDL_MERGE_ZEALOUS < level) < 0)) { + xdl_cleanup_merge(changes); + return -1; + } + /* output */ + if (result) { + int marker_size = xmp->marker_size; + int size = xdl_fill_merge_buffer(xe1, name1, xe2, name2, + ancestor_name, + favor, changes, NULL, style, + marker_size); + result->ptr = xdl_malloc(size); + if (!result->ptr) { + xdl_cleanup_merge(changes); + return -1; + } + result->size = size; + xdl_fill_merge_buffer(xe1, name1, xe2, name2, + ancestor_name, favor, changes, + result->ptr, style, marker_size); + } + return xdl_cleanup_merge(changes); +} + +int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2, + xmparam_t const *xmp, mmbuffer_t *result) +{ + xdchange_t *xscr1, *xscr2; + xdfenv_t xe1, xe2; + int status; + xpparam_t const *xpp = &xmp->xpp; + + result->ptr = NULL; + result->size = 0; + + if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0 || + xdl_do_diff(orig, mf2, xpp, &xe2) < 0) { + return -1; + } + if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 || + xdl_change_compact(&xe1.xdf2, &xe1.xdf1, xpp->flags) < 0 || + xdl_build_script(&xe1, &xscr1) < 0) { + xdl_free_env(&xe1); + return -1; + } + if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 || + xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 || + xdl_build_script(&xe2, &xscr2) < 0) { + xdl_free_env(&xe2); + return -1; + } + status = 0; + if (!xscr1) { + result->ptr = xdl_malloc(mf2->size); + memcpy(result->ptr, mf2->ptr, mf2->size); + result->size = mf2->size; + } else if (!xscr2) { + result->ptr = xdl_malloc(mf1->size); + memcpy(result->ptr, mf1->ptr, mf1->size); + result->size = mf1->size; + } else { + status = xdl_do_merge(&xe1, xscr1, + &xe2, xscr2, + xmp, result); + } + xdl_free_script(xscr1); + xdl_free_script(xscr2); + + xdl_free_env(&xe1); + xdl_free_env(&xe2); + + return status; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xpatience.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xpatience.c new file mode 100644 index 000000000..fdd7d0263 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xpatience.c @@ -0,0 +1,358 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003-2009 Davide Libenzi, Johannes E. Schindelin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ +#include "xinclude.h" +#include "xtypes.h" +#include "xdiff.h" + +/* + * The basic idea of patience diff is to find lines that are unique in + * both files. These are intuitively the ones that we want to see as + * common lines. + * + * The maximal ordered sequence of such line pairs (where ordered means + * that the order in the sequence agrees with the order of the lines in + * both files) naturally defines an initial set of common lines. + * + * Now, the algorithm tries to extend the set of common lines by growing + * the line ranges where the files have identical lines. + * + * Between those common lines, the patience diff algorithm is applied + * recursively, until no unique line pairs can be found; these line ranges + * are handled by the well-known Myers algorithm. + */ + +#define NON_UNIQUE ULONG_MAX + +/* + * This is a hash mapping from line hash to line numbers in the first and + * second file. + */ +struct hashmap { + int nr, alloc; + struct entry { + unsigned long hash; + /* + * 0 = unused entry, 1 = first line, 2 = second, etc. + * line2 is NON_UNIQUE if the line is not unique + * in either the first or the second file. + */ + unsigned long line1, line2; + /* + * "next" & "previous" are used for the longest common + * sequence; + * initially, "next" reflects only the order in file1. + */ + struct entry *next, *previous; + } *entries, *first, *last; + /* were common records found? */ + unsigned long has_matches; + mmfile_t *file1, *file2; + xdfenv_t *env; + xpparam_t const *xpp; +}; + +/* The argument "pass" is 1 for the first file, 2 for the second. */ +static void insert_record(int line, struct hashmap *map, int pass) +{ + xrecord_t **records = pass == 1 ? + map->env->xdf1.recs : map->env->xdf2.recs; + xrecord_t *record = records[line - 1], *other; + /* + * After xdl_prepare_env() (or more precisely, due to + * xdl_classify_record()), the "ha" member of the records (AKA lines) + * is _not_ the hash anymore, but a linearized version of it. In + * other words, the "ha" member is guaranteed to start with 0 and + * the second record's ha can only be 0 or 1, etc. + * + * So we multiply ha by 2 in the hope that the hashing was + * "unique enough". + */ + int index = (int)((record->ha << 1) % map->alloc); + + while (map->entries[index].line1) { + other = map->env->xdf1.recs[map->entries[index].line1 - 1]; + if (map->entries[index].hash != record->ha || + !xdl_recmatch(record->ptr, record->size, + other->ptr, other->size, + map->xpp->flags)) { + if (++index >= map->alloc) + index = 0; + continue; + } + if (pass == 2) + map->has_matches = 1; + if (pass == 1 || map->entries[index].line2) + map->entries[index].line2 = NON_UNIQUE; + else + map->entries[index].line2 = line; + return; + } + if (pass == 2) + return; + map->entries[index].line1 = line; + map->entries[index].hash = record->ha; + if (!map->first) + map->first = map->entries + index; + if (map->last) { + map->last->next = map->entries + index; + map->entries[index].previous = map->last; + } + map->last = map->entries + index; + map->nr++; +} + +/* + * This function has to be called for each recursion into the inter-hunk + * parts, as previously non-unique lines can become unique when being + * restricted to a smaller part of the files. + * + * It is assumed that env has been prepared using xdl_prepare(). + */ +static int fill_hashmap(mmfile_t *file1, mmfile_t *file2, + xpparam_t const *xpp, xdfenv_t *env, + struct hashmap *result, + int line1, int count1, int line2, int count2) +{ + result->file1 = file1; + result->file2 = file2; + result->xpp = xpp; + result->env = env; + + /* We know exactly how large we want the hash map */ + result->alloc = count1 * 2; + result->entries = (struct entry *) + xdl_malloc(result->alloc * sizeof(struct entry)); + if (!result->entries) + return -1; + memset(result->entries, 0, result->alloc * sizeof(struct entry)); + + /* First, fill with entries from the first file */ + while (count1--) + insert_record(line1++, result, 1); + + /* Then search for matches in the second file */ + while (count2--) + insert_record(line2++, result, 2); + + return 0; +} + +/* + * Find the longest sequence with a smaller last element (meaning a smaller + * line2, as we construct the sequence with entries ordered by line1). + */ +static int binary_search(struct entry **sequence, int longest, + struct entry *entry) +{ + int left = -1, right = longest; + + while (left + 1 < right) { + int middle = (left + right) / 2; + /* by construction, no two entries can be equal */ + if (sequence[middle]->line2 > entry->line2) + right = middle; + else + left = middle; + } + /* return the index in "sequence", _not_ the sequence length */ + return left; +} + +/* + * The idea is to start with the list of common unique lines sorted by + * the order in file1. For each of these pairs, the longest (partial) + * sequence whose last element's line2 is smaller is determined. + * + * For efficiency, the sequences are kept in a list containing exactly one + * item per sequence length: the sequence with the smallest last + * element (in terms of line2). + */ +static struct entry *find_longest_common_sequence(struct hashmap *map) +{ + struct entry **sequence = xdl_malloc(map->nr * sizeof(struct entry *)); + int longest = 0, i; + struct entry *entry; + + for (entry = map->first; entry; entry = entry->next) { + if (!entry->line2 || entry->line2 == NON_UNIQUE) + continue; + i = binary_search(sequence, longest, entry); + entry->previous = i < 0 ? NULL : sequence[i]; + sequence[++i] = entry; + if (i == longest) + longest++; + } + + /* No common unique lines were found */ + if (!longest) { + xdl_free(sequence); + return NULL; + } + + /* Iterate starting at the last element, adjusting the "next" members */ + entry = sequence[longest - 1]; + entry->next = NULL; + while (entry->previous) { + entry->previous->next = entry; + entry = entry->previous; + } + xdl_free(sequence); + return entry; +} + +static int match(struct hashmap *map, int line1, int line2) +{ + xrecord_t *record1 = map->env->xdf1.recs[line1 - 1]; + xrecord_t *record2 = map->env->xdf2.recs[line2 - 1]; + return xdl_recmatch(record1->ptr, record1->size, + record2->ptr, record2->size, map->xpp->flags); +} + +static int patience_diff(mmfile_t *file1, mmfile_t *file2, + xpparam_t const *xpp, xdfenv_t *env, + int line1, int count1, int line2, int count2); + +static int walk_common_sequence(struct hashmap *map, struct entry *first, + int line1, int count1, int line2, int count2) +{ + int end1 = line1 + count1, end2 = line2 + count2; + int next1, next2; + + for (;;) { + /* Try to grow the line ranges of common lines */ + if (first) { + next1 = first->line1; + next2 = first->line2; + while (next1 > line1 && next2 > line2 && + match(map, next1 - 1, next2 - 1)) { + next1--; + next2--; + } + } else { + next1 = end1; + next2 = end2; + } + while (line1 < next1 && line2 < next2 && + match(map, line1, line2)) { + line1++; + line2++; + } + + /* Recurse */ + if (next1 > line1 || next2 > line2) { + struct hashmap submap; + + memset(&submap, 0, sizeof(submap)); + if (patience_diff(map->file1, map->file2, + map->xpp, map->env, + line1, next1 - line1, + line2, next2 - line2)) + return -1; + } + + if (!first) + return 0; + + while (first->next && + first->next->line1 == first->line1 + 1 && + first->next->line2 == first->line2 + 1) + first = first->next; + + line1 = first->line1 + 1; + line2 = first->line2 + 1; + + first = first->next; + } +} + +static int fall_back_to_classic_diff(struct hashmap *map, + int line1, int count1, int line2, int count2) +{ + xpparam_t xpp; + xpp.flags = map->xpp->flags & ~XDF_PATIENCE_DIFF; + + return xdl_fall_back_diff(map->env, &xpp, + line1, count1, line2, count2); +} + +/* + * Recursively find the longest common sequence of unique lines, + * and if none was found, ask xdl_do_diff() to do the job. + * + * This function assumes that env was prepared with xdl_prepare_env(). + */ +static int patience_diff(mmfile_t *file1, mmfile_t *file2, + xpparam_t const *xpp, xdfenv_t *env, + int line1, int count1, int line2, int count2) +{ + struct hashmap map; + struct entry *first; + int result = 0; + + /* trivial case: one side is empty */ + if (!count1) { + while(count2--) + env->xdf2.rchg[line2++ - 1] = 1; + return 0; + } else if (!count2) { + while(count1--) + env->xdf1.rchg[line1++ - 1] = 1; + return 0; + } + + memset(&map, 0, sizeof(map)); + if (fill_hashmap(file1, file2, xpp, env, &map, + line1, count1, line2, count2)) + return -1; + + /* are there any matching lines at all? */ + if (!map.has_matches) { + while(count1--) + env->xdf1.rchg[line1++ - 1] = 1; + while(count2--) + env->xdf2.rchg[line2++ - 1] = 1; + xdl_free(map.entries); + return 0; + } + + first = find_longest_common_sequence(&map); + if (first) + result = walk_common_sequence(&map, first, + line1, count1, line2, count2); + else + result = fall_back_to_classic_diff(&map, + line1, count1, line2, count2); + + xdl_free(map.entries); + return result; +} + +int xdl_do_patience_diff(mmfile_t *file1, mmfile_t *file2, + xpparam_t const *xpp, xdfenv_t *env) +{ + if (xdl_prepare_env(file1, file2, xpp, env) < 0) + return -1; + + /* environment is cleaned up in xdl_diff() */ + return patience_diff(file1, file2, xpp, env, + 1, env->xdf1.nrec, 1, env->xdf2.nrec); +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.c new file mode 100644 index 000000000..e419f4f72 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.c @@ -0,0 +1,483 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#include "xinclude.h" + + +#define XDL_KPDIS_RUN 4 +#define XDL_MAX_EQLIMIT 1024 +#define XDL_SIMSCAN_WINDOW 100 +#define XDL_GUESS_NLINES1 256 +#define XDL_GUESS_NLINES2 20 + + +typedef struct s_xdlclass { + struct s_xdlclass *next; + unsigned long ha; + char const *line; + long size; + long idx; + long len1, len2; +} xdlclass_t; + +typedef struct s_xdlclassifier { + unsigned int hbits; + long hsize; + xdlclass_t **rchash; + chastore_t ncha; + xdlclass_t **rcrecs; + long alloc; + long count; + long flags; +} xdlclassifier_t; + + + + +static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags); +static void xdl_free_classifier(xdlclassifier_t *cf); +static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t **rhash, + unsigned int hbits, xrecord_t *rec); +static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_t const *xpp, + xdlclassifier_t *cf, xdfile_t *xdf); +static void xdl_free_ctx(xdfile_t *xdf); +static int xdl_clean_mmatch(char const *dis, long i, long s, long e); +static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2); +static int xdl_trim_ends(xdfile_t *xdf1, xdfile_t *xdf2); +static int xdl_optimize_ctxs(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2); + + + + +static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) { + cf->flags = flags; + + cf->hbits = xdl_hashbits((unsigned int) size); + cf->hsize = 1 << cf->hbits; + + if (xdl_cha_init(&cf->ncha, sizeof(xdlclass_t), size / 4 + 1) < 0) { + + return -1; + } + if (!(cf->rchash = (xdlclass_t **) xdl_malloc(cf->hsize * sizeof(xdlclass_t *)))) { + + xdl_cha_free(&cf->ncha); + return -1; + } + memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *)); + + cf->alloc = size; + if (!(cf->rcrecs = (xdlclass_t **) xdl_malloc(cf->alloc * sizeof(xdlclass_t *)))) { + + xdl_free(cf->rchash); + xdl_cha_free(&cf->ncha); + return -1; + } + + cf->count = 0; + + return 0; +} + + +static void xdl_free_classifier(xdlclassifier_t *cf) { + + xdl_free(cf->rcrecs); + xdl_free(cf->rchash); + xdl_cha_free(&cf->ncha); +} + + +static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t **rhash, + unsigned int hbits, xrecord_t *rec) { + long hi; + char const *line; + xdlclass_t *rcrec; + xdlclass_t **rcrecs; + + line = rec->ptr; + hi = (long) XDL_HASHLONG(rec->ha, cf->hbits); + for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next) + if (rcrec->ha == rec->ha && + xdl_recmatch(rcrec->line, rcrec->size, + rec->ptr, rec->size, cf->flags)) + break; + + if (!rcrec) { + if (!(rcrec = xdl_cha_alloc(&cf->ncha))) { + + return -1; + } + rcrec->idx = cf->count++; + if (cf->count > cf->alloc) { + cf->alloc *= 2; + if (!(rcrecs = (xdlclass_t **) xdl_realloc(cf->rcrecs, cf->alloc * sizeof(xdlclass_t *)))) { + + return -1; + } + cf->rcrecs = rcrecs; + } + cf->rcrecs[rcrec->idx] = rcrec; + rcrec->line = line; + rcrec->size = rec->size; + rcrec->ha = rec->ha; + rcrec->len1 = rcrec->len2 = 0; + rcrec->next = cf->rchash[hi]; + cf->rchash[hi] = rcrec; + } + + (pass == 1) ? rcrec->len1++ : rcrec->len2++; + + rec->ha = (unsigned long) rcrec->idx; + + hi = (long) XDL_HASHLONG(rec->ha, hbits); + rec->next = rhash[hi]; + rhash[hi] = rec; + + return 0; +} + + +static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_t const *xpp, + xdlclassifier_t *cf, xdfile_t *xdf) { + unsigned int hbits; + long nrec, hsize, bsize; + unsigned long hav; + char const *blk, *cur, *top, *prev; + xrecord_t *crec; + xrecord_t **recs, **rrecs; + xrecord_t **rhash; + unsigned long *ha; + char *rchg; + long *rindex; + + ha = NULL; + rindex = NULL; + rchg = NULL; + rhash = NULL; + recs = NULL; + + if (xdl_cha_init(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0) + goto abort; + if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *)))) + goto abort; + + if (xpp->flags & XDF_HISTOGRAM_DIFF) + hbits = hsize = 0; + else { + hbits = xdl_hashbits((unsigned int) narec); + hsize = 1 << hbits; + if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *)))) + goto abort; + memset(rhash, 0, hsize * sizeof(xrecord_t *)); + } + + nrec = 0; + if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) { + for (top = blk + bsize; cur < top; ) { + prev = cur; + hav = xdl_hash_record(&cur, top, xpp->flags); + if (nrec >= narec) { + narec *= 2; + if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *)))) + goto abort; + recs = rrecs; + } + if (!(crec = xdl_cha_alloc(&xdf->rcha))) + goto abort; + crec->ptr = prev; + crec->size = (long) (cur - prev); + crec->ha = hav; + recs[nrec++] = crec; + + if (!(xpp->flags & XDF_HISTOGRAM_DIFF) && + xdl_classify_record(pass, cf, rhash, hbits, crec) < 0) + goto abort; + } + } + + if (!(rchg = (char *) xdl_malloc((nrec + 2) * sizeof(char)))) + goto abort; + memset(rchg, 0, (nrec + 2) * sizeof(char)); + + if (!(rindex = (long *) xdl_malloc((nrec + 1) * sizeof(long)))) + goto abort; + if (!(ha = (unsigned long *) xdl_malloc((nrec + 1) * sizeof(unsigned long)))) + goto abort; + + xdf->nrec = nrec; + xdf->recs = recs; + xdf->hbits = hbits; + xdf->rhash = rhash; + xdf->rchg = rchg + 1; + xdf->rindex = rindex; + xdf->nreff = 0; + xdf->ha = ha; + xdf->dstart = 0; + xdf->dend = nrec - 1; + + return 0; + +abort: + xdl_free(ha); + xdl_free(rindex); + xdl_free(rchg); + xdl_free(rhash); + xdl_free(recs); + xdl_cha_free(&xdf->rcha); + return -1; +} + + +static void xdl_free_ctx(xdfile_t *xdf) { + + xdl_free(xdf->rhash); + xdl_free(xdf->rindex); + xdl_free(xdf->rchg - 1); + xdl_free(xdf->ha); + xdl_free(xdf->recs); + xdl_cha_free(&xdf->rcha); +} + + +int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdfenv_t *xe) { + long enl1, enl2, sample; + xdlclassifier_t cf; + + memset(&cf, 0, sizeof(cf)); + + /* + * For histogram diff, we can afford a smaller sample size and + * thus a poorer estimate of the number of lines, as the hash + * table (rhash) won't be filled up/grown. The number of lines + * (nrecs) will be updated correctly anyway by + * xdl_prepare_ctx(). + */ + sample = xpp->flags & XDF_HISTOGRAM_DIFF ? XDL_GUESS_NLINES2 : XDL_GUESS_NLINES1; + + enl1 = xdl_guess_lines(mf1, sample) + 1; + enl2 = xdl_guess_lines(mf2, sample) + 1; + + if (!(xpp->flags & XDF_HISTOGRAM_DIFF) && + xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0) { + + return -1; + } + + if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) { + + xdl_free_classifier(&cf); + return -1; + } + if (xdl_prepare_ctx(2, mf2, enl2, xpp, &cf, &xe->xdf2) < 0) { + + xdl_free_ctx(&xe->xdf1); + xdl_free_classifier(&cf); + return -1; + } + + if (!(xpp->flags & XDF_PATIENCE_DIFF) && + !(xpp->flags & XDF_HISTOGRAM_DIFF) && + xdl_optimize_ctxs(&cf, &xe->xdf1, &xe->xdf2) < 0) { + + xdl_free_ctx(&xe->xdf2); + xdl_free_ctx(&xe->xdf1); + return -1; + } + + if (!(xpp->flags & XDF_HISTOGRAM_DIFF)) + xdl_free_classifier(&cf); + + return 0; +} + + +void xdl_free_env(xdfenv_t *xe) { + + xdl_free_ctx(&xe->xdf2); + xdl_free_ctx(&xe->xdf1); +} + + +static int xdl_clean_mmatch(char const *dis, long i, long s, long e) { + long r, rdis0, rpdis0, rdis1, rpdis1; + + /* + * Limits the window the is examined during the similar-lines + * scan. The loops below stops when dis[i - r] == 1 (line that + * has no match), but there are corner cases where the loop + * proceed all the way to the extremities by causing huge + * performance penalties in case of big files. + */ + if (i - s > XDL_SIMSCAN_WINDOW) + s = i - XDL_SIMSCAN_WINDOW; + if (e - i > XDL_SIMSCAN_WINDOW) + e = i + XDL_SIMSCAN_WINDOW; + + /* + * Scans the lines before 'i' to find a run of lines that either + * have no match (dis[j] == 0) or have multiple matches (dis[j] > 1). + * Note that we always call this function with dis[i] > 1, so the + * current line (i) is already a multimatch line. + */ + for (r = 1, rdis0 = 0, rpdis0 = 1; (i - r) >= s; r++) { + if (!dis[i - r]) + rdis0++; + else if (dis[i - r] == 2) + rpdis0++; + else + break; + } + /* + * If the run before the line 'i' found only multimatch lines, we + * return 0 and hence we don't make the current line (i) discarded. + * We want to discard multimatch lines only when they appear in the + * middle of runs with nomatch lines (dis[j] == 0). + */ + if (rdis0 == 0) + return 0; + for (r = 1, rdis1 = 0, rpdis1 = 1; (i + r) <= e; r++) { + if (!dis[i + r]) + rdis1++; + else if (dis[i + r] == 2) + rpdis1++; + else + break; + } + /* + * If the run after the line 'i' found only multimatch lines, we + * return 0 and hence we don't make the current line (i) discarded. + */ + if (rdis1 == 0) + return 0; + rdis1 += rdis0; + rpdis1 += rpdis0; + + return rpdis1 * XDL_KPDIS_RUN < (rpdis1 + rdis1); +} + + +/* + * Try to reduce the problem complexity, discard records that have no + * matches on the other file. Also, lines that have multiple matches + * might be potentially discarded if they happear in a run of discardable. + */ +static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2) { + long i, nm, nreff, mlim; + xrecord_t **recs; + xdlclass_t *rcrec; + char *dis, *dis1, *dis2; + + if (!(dis = (char *) xdl_malloc(xdf1->nrec + xdf2->nrec + 2))) { + + return -1; + } + memset(dis, 0, xdf1->nrec + xdf2->nrec + 2); + dis1 = dis; + dis2 = dis1 + xdf1->nrec + 1; + + if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT) + mlim = XDL_MAX_EQLIMIT; + for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) { + rcrec = cf->rcrecs[(*recs)->ha]; + nm = rcrec ? rcrec->len2 : 0; + dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; + } + + if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT) + mlim = XDL_MAX_EQLIMIT; + for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) { + rcrec = cf->rcrecs[(*recs)->ha]; + nm = rcrec ? rcrec->len1 : 0; + dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; + } + + for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; + i <= xdf1->dend; i++, recs++) { + if (dis1[i] == 1 || + (dis1[i] == 2 && !xdl_clean_mmatch(dis1, i, xdf1->dstart, xdf1->dend))) { + xdf1->rindex[nreff] = i; + xdf1->ha[nreff] = (*recs)->ha; + nreff++; + } else + xdf1->rchg[i] = 1; + } + xdf1->nreff = nreff; + + for (nreff = 0, i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; + i <= xdf2->dend; i++, recs++) { + if (dis2[i] == 1 || + (dis2[i] == 2 && !xdl_clean_mmatch(dis2, i, xdf2->dstart, xdf2->dend))) { + xdf2->rindex[nreff] = i; + xdf2->ha[nreff] = (*recs)->ha; + nreff++; + } else + xdf2->rchg[i] = 1; + } + xdf2->nreff = nreff; + + xdl_free(dis); + + return 0; +} + + +/* + * Early trim initial and terminal matching records. + */ +static int xdl_trim_ends(xdfile_t *xdf1, xdfile_t *xdf2) { + long i, lim; + xrecord_t **recs1, **recs2; + + recs1 = xdf1->recs; + recs2 = xdf2->recs; + for (i = 0, lim = XDL_MIN(xdf1->nrec, xdf2->nrec); i < lim; + i++, recs1++, recs2++) + if ((*recs1)->ha != (*recs2)->ha) + break; + + xdf1->dstart = xdf2->dstart = i; + + recs1 = xdf1->recs + xdf1->nrec - 1; + recs2 = xdf2->recs + xdf2->nrec - 1; + for (lim -= i, i = 0; i < lim; i++, recs1--, recs2--) + if ((*recs1)->ha != (*recs2)->ha) + break; + + xdf1->dend = xdf1->nrec - i - 1; + xdf2->dend = xdf2->nrec - i - 1; + + return 0; +} + + +static int xdl_optimize_ctxs(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2) { + + if (xdl_trim_ends(xdf1, xdf2) < 0 || + xdl_cleanup_records(cf, xdf1, xdf2) < 0) { + + return -1; + } + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.h new file mode 100644 index 000000000..8fb06a537 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xprepare.h @@ -0,0 +1,34 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XPREPARE_H) +#define XPREPARE_H + + + +int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, + xdfenv_t *xe); +void xdl_free_env(xdfenv_t *xe); + + + +#endif /* #if !defined(XPREPARE_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xtypes.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xtypes.h new file mode 100644 index 000000000..2511aef8d --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xtypes.h @@ -0,0 +1,67 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XTYPES_H) +#define XTYPES_H + + + +typedef struct s_chanode { + struct s_chanode *next; + long icurr; +} chanode_t; + +typedef struct s_chastore { + chanode_t *head, *tail; + long isize, nsize; + chanode_t *ancur; + chanode_t *sncur; + long scurr; +} chastore_t; + +typedef struct s_xrecord { + struct s_xrecord *next; + char const *ptr; + long size; + unsigned long ha; +} xrecord_t; + +typedef struct s_xdfile { + chastore_t rcha; + long nrec; + unsigned int hbits; + xrecord_t **rhash; + long dstart, dend; + xrecord_t **recs; + char *rchg; + long *rindex; + long nreff; + unsigned long *ha; +} xdfile_t; + +typedef struct s_xdfenv { + xdfile_t xdf1, xdf2; +} xdfenv_t; + + + +#endif /* #if !defined(XTYPES_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.c b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.c new file mode 100644 index 000000000..bb7bdee49 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.c @@ -0,0 +1,419 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#include "xinclude.h" + + + + +long xdl_bogosqrt(long n) { + long i; + + /* + * Classical integer square root approximation using shifts. + */ + for (i = 1; n > 0; n >>= 2) + i <<= 1; + + return i; +} + + +int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize, + xdemitcb_t *ecb) { + int i = 2; + mmbuffer_t mb[3]; + + mb[0].ptr = (char *) pre; + mb[0].size = psize; + mb[1].ptr = (char *) rec; + mb[1].size = size; + if (size > 0 && rec[size - 1] != '\n') { + mb[2].ptr = (char *) "\n\\ No newline at end of file\n"; + mb[2].size = strlen(mb[2].ptr); + i++; + } + if (ecb->outf(ecb->priv, mb, i) < 0) { + + return -1; + } + + return 0; +} + +void *xdl_mmfile_first(mmfile_t *mmf, long *size) +{ + *size = (long)mmf->size; + return mmf->ptr; +} + + +long xdl_mmfile_size(mmfile_t *mmf) +{ + return (long)mmf->size; +} + + +int xdl_cha_init(chastore_t *cha, long isize, long icount) { + + cha->head = cha->tail = NULL; + cha->isize = isize; + cha->nsize = icount * isize; + cha->ancur = cha->sncur = NULL; + cha->scurr = 0; + + return 0; +} + + +void xdl_cha_free(chastore_t *cha) { + chanode_t *cur, *tmp; + + for (cur = cha->head; (tmp = cur) != NULL;) { + cur = cur->next; + xdl_free(tmp); + } +} + + +void *xdl_cha_alloc(chastore_t *cha) { + chanode_t *ancur; + void *data; + + if (!(ancur = cha->ancur) || ancur->icurr == cha->nsize) { + if (!(ancur = (chanode_t *) xdl_malloc(sizeof(chanode_t) + cha->nsize))) { + + return NULL; + } + ancur->icurr = 0; + ancur->next = NULL; + if (cha->tail) + cha->tail->next = ancur; + if (!cha->head) + cha->head = ancur; + cha->tail = ancur; + cha->ancur = ancur; + } + + data = (char *) ancur + sizeof(chanode_t) + ancur->icurr; + ancur->icurr += cha->isize; + + return data; +} + + +void *xdl_cha_first(chastore_t *cha) { + chanode_t *sncur; + + if (!(cha->sncur = sncur = cha->head)) + return NULL; + + cha->scurr = 0; + + return (char *) sncur + sizeof(chanode_t) + cha->scurr; +} + + +void *xdl_cha_next(chastore_t *cha) { + chanode_t *sncur; + + if (!(sncur = cha->sncur)) + return NULL; + cha->scurr += cha->isize; + if (cha->scurr == sncur->icurr) { + if (!(sncur = cha->sncur = sncur->next)) + return NULL; + cha->scurr = 0; + } + + return (char *) sncur + sizeof(chanode_t) + cha->scurr; +} + + +long xdl_guess_lines(mmfile_t *mf, long sample) { + long nl = 0, size, tsize = 0; + char const *data, *cur, *top; + + if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) { + for (top = data + size; nl < sample && cur < top; ) { + nl++; + if (!(cur = memchr(cur, '\n', top - cur))) + cur = top; + else + cur++; + } + tsize += (long) (cur - data); + } + + if (nl && tsize) + nl = xdl_mmfile_size(mf) / (tsize / nl); + + return nl + 1; +} + +int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) +{ + int i1, i2; + + if (s1 == s2 && !memcmp(l1, l2, s1)) + return 1; + if (!(flags & XDF_WHITESPACE_FLAGS)) + return 0; + + i1 = 0; + i2 = 0; + + /* + * -w matches everything that matches with -b, and -b in turn + * matches everything that matches with --ignore-space-at-eol. + * + * Each flavor of ignoring needs different logic to skip whitespaces + * while we have both sides to compare. + */ + if (flags & XDF_IGNORE_WHITESPACE) { + goto skip_ws; + while (i1 < s1 && i2 < s2) { + if (l1[i1++] != l2[i2++]) + return 0; + skip_ws: + while (i1 < s1 && XDL_ISSPACE(l1[i1])) + i1++; + while (i2 < s2 && XDL_ISSPACE(l2[i2])) + i2++; + } + } else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) { + while (i1 < s1 && i2 < s2) { + if (XDL_ISSPACE(l1[i1]) && XDL_ISSPACE(l2[i2])) { + /* Skip matching spaces and try again */ + while (i1 < s1 && XDL_ISSPACE(l1[i1])) + i1++; + while (i2 < s2 && XDL_ISSPACE(l2[i2])) + i2++; + continue; + } + if (l1[i1++] != l2[i2++]) + return 0; + } + } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL) { + while (i1 < s1 && i2 < s2 && l1[i1++] == l2[i2++]) + ; /* keep going */ + } + + /* + * After running out of one side, the remaining side must have + * nothing but whitespace for the lines to match. Note that + * ignore-whitespace-at-eol case may break out of the loop + * while there still are characters remaining on both lines. + */ + if (i1 < s1) { + while (i1 < s1 && XDL_ISSPACE(l1[i1])) + i1++; + if (s1 != i1) + return 0; + } + if (i2 < s2) { + while (i2 < s2 && XDL_ISSPACE(l2[i2])) + i2++; + return (s2 == i2); + } + return 1; +} + +static unsigned long xdl_hash_record_with_whitespace(char const **data, + char const *top, long flags) { + unsigned long ha = 5381; + char const *ptr = *data; + + for (; ptr < top && *ptr != '\n'; ptr++) { + if (XDL_ISSPACE(*ptr)) { + const char *ptr2 = ptr; + int at_eol; + while (ptr + 1 < top && XDL_ISSPACE(ptr[1]) + && ptr[1] != '\n') + ptr++; + at_eol = (top <= ptr + 1 || ptr[1] == '\n'); + if (flags & XDF_IGNORE_WHITESPACE) + ; /* already handled */ + else if (flags & XDF_IGNORE_WHITESPACE_CHANGE + && !at_eol) { + ha += (ha << 5); + ha ^= (unsigned long) ' '; + } + else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL + && !at_eol) { + while (ptr2 != ptr + 1) { + ha += (ha << 5); + ha ^= (unsigned long) *ptr2; + ptr2++; + } + } + continue; + } + ha += (ha << 5); + ha ^= (unsigned long) *ptr; + } + *data = ptr < top ? ptr + 1: ptr; + + return ha; +} + + +unsigned long xdl_hash_record(char const **data, char const *top, long flags) { + unsigned long ha = 5381; + char const *ptr = *data; + + if (flags & XDF_WHITESPACE_FLAGS) + return xdl_hash_record_with_whitespace(data, top, flags); + + for (; ptr < top && *ptr != '\n'; ptr++) { + ha += (ha << 5); + ha ^= (unsigned long) *ptr; + } + *data = ptr < top ? ptr + 1: ptr; + + return ha; +} + + +unsigned int xdl_hashbits(unsigned int size) { + unsigned int val = 1, bits = 0; + + for (; val < size && bits < CHAR_BIT * sizeof(unsigned int); val <<= 1, bits++); + return bits ? bits: 1; +} + + +int xdl_num_out(char *out, long val) { + char *ptr, *str = out; + char buf[32]; + + ptr = buf + sizeof(buf) - 1; + *ptr = '\0'; + if (val < 0) { + *--ptr = '-'; + val = -val; + } + for (; val && ptr > buf; val /= 10) + *--ptr = "0123456789"[val % 10]; + if (*ptr) + for (; *ptr; ptr++, str++) + *str = *ptr; + else + *str++ = '0'; + *str = '\0'; + + return (int)(str - out); +} + + +long xdl_atol(char const *str, char const **next) { + long val, base; + char const *top; + + for (top = str; XDL_ISDIGIT(*top); top++); + if (next) + *next = top; + for (val = 0, base = 1, top--; top >= str; top--, base *= 10) + val += base * (long)(*top - '0'); + return val; +} + + +int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, + const char *func, long funclen, xdemitcb_t *ecb) { + int nb = 0; + mmbuffer_t mb; + char buf[128]; + + memcpy(buf, "@@ -", 4); + nb += 4; + + nb += xdl_num_out(buf + nb, c1 ? s1: s1 - 1); + + if (c1 != 1) { + memcpy(buf + nb, ",", 1); + nb += 1; + + nb += xdl_num_out(buf + nb, c1); + } + + memcpy(buf + nb, " +", 2); + nb += 2; + + nb += xdl_num_out(buf + nb, c2 ? s2: s2 - 1); + + if (c2 != 1) { + memcpy(buf + nb, ",", 1); + nb += 1; + + nb += xdl_num_out(buf + nb, c2); + } + + memcpy(buf + nb, " @@", 3); + nb += 3; + if (func && funclen) { + buf[nb++] = ' '; + if (funclen > (long)sizeof(buf) - nb - 1) + funclen = (long)sizeof(buf) - nb - 1; + memcpy(buf + nb, func, funclen); + nb += funclen; + } + buf[nb++] = '\n'; + + mb.ptr = buf; + mb.size = nb; + if (ecb->outf(ecb->priv, &mb, 1) < 0) + return -1; + + return 0; +} + +int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp, + int line1, int count1, int line2, int count2) +{ + /* + * This probably does not work outside Git, since + * we have a very simple mmfile structure. + * + * Note: ideally, we would reuse the prepared environment, but + * the libxdiff interface does not (yet) allow for diffing only + * ranges of lines instead of the whole files. + */ + mmfile_t subfile1, subfile2; + xdfenv_t env; + + subfile1.ptr = (char *)diff_env->xdf1.recs[line1 - 1]->ptr; + subfile1.size = diff_env->xdf1.recs[line1 + count1 - 2]->ptr + + diff_env->xdf1.recs[line1 + count1 - 2]->size - subfile1.ptr; + subfile2.ptr = (char *)diff_env->xdf2.recs[line2 - 1]->ptr; + subfile2.size = diff_env->xdf2.recs[line2 + count2 - 2]->ptr + + diff_env->xdf2.recs[line2 + count2 - 2]->size - subfile2.ptr; + if (xdl_do_diff(&subfile1, &subfile2, xpp, &env) < 0) + return -1; + + memcpy(diff_env->xdf1.rchg + line1 - 1, env.xdf1.rchg, count1); + memcpy(diff_env->xdf2.rchg + line2 - 1, env.xdf2.rchg, count2); + + xdl_free_env(&env); + + return 0; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.h b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.h new file mode 100644 index 000000000..714719a89 --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/xdiff/xutils.h @@ -0,0 +1,49 @@ +/* + * LibXDiff by Davide Libenzi ( File Differential Library ) + * Copyright (C) 2003 Davide Libenzi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Davide Libenzi + * + */ + +#if !defined(XUTILS_H) +#define XUTILS_H + + + +long xdl_bogosqrt(long n); +int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize, + xdemitcb_t *ecb); +int xdl_cha_init(chastore_t *cha, long isize, long icount); +void xdl_cha_free(chastore_t *cha); +void *xdl_cha_alloc(chastore_t *cha); +void *xdl_cha_first(chastore_t *cha); +void *xdl_cha_next(chastore_t *cha); +long xdl_guess_lines(mmfile_t *mf, long sample); +int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags); +unsigned long xdl_hash_record(char const **data, char const *top, long flags); +unsigned int xdl_hashbits(unsigned int size); +int xdl_num_out(char *out, long val); +long xdl_atol(char const *str, char const **next); +int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, + const char *func, long funclen, xdemitcb_t *ecb); +int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp, + int line1, int count1, int line2, int count2); + + + +#endif /* #if !defined(XUTILS_H) */ diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/zstream.c b/deps/libgit2-sys-0.2.17/libgit2/src/zstream.c new file mode 100644 index 000000000..2130bc3ca --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/zstream.c @@ -0,0 +1,156 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include + +#include "zstream.h" +#include "buffer.h" + +#define ZSTREAM_BUFFER_SIZE (1024 * 1024) +#define ZSTREAM_BUFFER_MIN_EXTRA 8 + +static int zstream_seterr(git_zstream *zs) +{ + if (zs->zerr == Z_OK || zs->zerr == Z_STREAM_END) + return 0; + + if (zs->zerr == Z_MEM_ERROR) + giterr_set_oom(); + else if (zs->z.msg) + giterr_set(GITERR_ZLIB, zs->z.msg); + else + giterr_set(GITERR_ZLIB, "Unknown compression error"); + + return -1; +} + +int git_zstream_init(git_zstream *zstream) +{ + zstream->zerr = deflateInit(&zstream->z, Z_DEFAULT_COMPRESSION); + return zstream_seterr(zstream); +} + +void git_zstream_free(git_zstream *zstream) +{ + deflateEnd(&zstream->z); +} + +void git_zstream_reset(git_zstream *zstream) +{ + deflateReset(&zstream->z); + zstream->in = NULL; + zstream->in_len = 0; + zstream->zerr = Z_STREAM_END; +} + +int git_zstream_set_input(git_zstream *zstream, const void *in, size_t in_len) +{ + zstream->in = in; + zstream->in_len = in_len; + zstream->zerr = Z_OK; + return 0; +} + +bool git_zstream_done(git_zstream *zstream) +{ + return (!zstream->in_len && zstream->zerr == Z_STREAM_END); +} + +size_t git_zstream_suggest_output_len(git_zstream *zstream) +{ + if (zstream->in_len > ZSTREAM_BUFFER_SIZE) + return ZSTREAM_BUFFER_SIZE; + else if (zstream->in_len > ZSTREAM_BUFFER_MIN_EXTRA) + return zstream->in_len; + else + return ZSTREAM_BUFFER_MIN_EXTRA; +} + +int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream) +{ + int zflush = Z_FINISH; + size_t out_remain = *out_len; + + while (out_remain > 0 && zstream->zerr != Z_STREAM_END) { + size_t out_queued, in_queued, out_used, in_used; + + /* set up in data */ + zstream->z.next_in = (Bytef *)zstream->in; + zstream->z.avail_in = (uInt)zstream->in_len; + if ((size_t)zstream->z.avail_in != zstream->in_len) { + zstream->z.avail_in = INT_MAX; + zflush = Z_NO_FLUSH; + } else { + zflush = Z_FINISH; + } + in_queued = (size_t)zstream->z.avail_in; + + /* set up out data */ + zstream->z.next_out = out; + zstream->z.avail_out = (uInt)out_remain; + if ((size_t)zstream->z.avail_out != out_remain) + zstream->z.avail_out = INT_MAX; + out_queued = (size_t)zstream->z.avail_out; + + /* compress next chunk */ + zstream->zerr = deflate(&zstream->z, zflush); + + if (zstream->zerr == Z_STREAM_ERROR) + return zstream_seterr(zstream); + + out_used = (out_queued - zstream->z.avail_out); + out_remain -= out_used; + out = ((char *)out) + out_used; + + in_used = (in_queued - zstream->z.avail_in); + zstream->in_len -= in_used; + zstream->in += in_used; + } + + /* either we finished the input or we did not flush the data */ + assert(zstream->in_len > 0 || zflush == Z_FINISH); + + /* set out_size to number of bytes actually written to output */ + *out_len = *out_len - out_remain; + + return 0; +} + +int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len) +{ + git_zstream zs = GIT_ZSTREAM_INIT; + int error = 0; + + if ((error = git_zstream_init(&zs)) < 0) + return error; + + if ((error = git_zstream_set_input(&zs, in, in_len)) < 0) + goto done; + + while (!git_zstream_done(&zs)) { + size_t step = git_zstream_suggest_output_len(&zs), written; + + if ((error = git_buf_grow_by(out, step)) < 0) + goto done; + + written = out->asize - out->size; + + if ((error = git_zstream_get_output( + out->ptr + out->size, &written, &zs)) < 0) + goto done; + + out->size += written; + } + + /* NULL terminate for consistency if possible */ + if (out->size < out->asize) + out->ptr[out->size] = '\0'; + +done: + git_zstream_free(&zs); + return error; +} diff --git a/deps/libgit2-sys-0.2.17/libgit2/src/zstream.h b/deps/libgit2-sys-0.2.17/libgit2/src/zstream.h new file mode 100644 index 000000000..9b5bf6ace --- /dev/null +++ b/deps/libgit2-sys-0.2.17/libgit2/src/zstream.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_zstream_h__ +#define INCLUDE_zstream_h__ + +#include + +#include "common.h" +#include "buffer.h" + +typedef struct { + z_stream z; + const char *in; + size_t in_len; + int zerr; +} git_zstream; + +#define GIT_ZSTREAM_INIT {{0}} + +int git_zstream_init(git_zstream *zstream); +void git_zstream_free(git_zstream *zstream); + +int git_zstream_set_input(git_zstream *zstream, const void *in, size_t in_len); + +size_t git_zstream_suggest_output_len(git_zstream *zstream); + +int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream); + +bool git_zstream_done(git_zstream *zstream); + +void git_zstream_reset(git_zstream *zstream); + +int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len); + +#endif /* INCLUDE_zstream_h__ */ diff --git a/deps/libssh2-sys-0.1.25/.gitattributes b/deps/libssh2-sys-0.1.25/.gitattributes new file mode 100644 index 000000000..27280b85e --- /dev/null +++ b/deps/libssh2-sys-0.1.25/.gitattributes @@ -0,0 +1,2 @@ +# apparently libssh2 has trouble with CRLF, but of course only on windows +* text eol=lf diff --git a/deps/libssh2-sys-0.1.25/Cargo.toml b/deps/libssh2-sys-0.1.25/Cargo.toml new file mode 100644 index 000000000..501bba532 --- /dev/null +++ b/deps/libssh2-sys-0.1.25/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "libssh2-sys" +version = "0.1.25" +authors = ["Alex Crichton "] +links = "ssh2" +build = "build.rs" +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/ssh2-rs" +description = "Native bindings to the libssh2 library" + +[lib] +name = "libssh2_sys" +path = "lib.rs" + +[dependencies] +libz-sys = "0.1.0" +libc = "0.1" + +[target.i686-apple-darwin.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-apple-darwin.dependencies] +openssl-sys = "0.6.0" +[target.i686-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +[target.aarch64-unknown-linux-gnu.dependencies] +openssl-sys = "0.6.0" +[target.arm-unknown-linux-gnueabihf.dependencies] +openssl-sys = "0.6.0" +[target.i686-unknown-freebsd.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-freebsd.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-dragonfly.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-bitrig.dependencies] +openssl-sys = "0.6.0" +[target.x86_64-unknown-openbsd.dependencies] +openssl-sys = "0.6.0" + +[build-dependencies] +pkg-config = "0.3" diff --git a/deps/libssh2-sys-0.1.25/build.rs b/deps/libssh2-sys-0.1.25/build.rs new file mode 100644 index 000000000..60d3931f9 --- /dev/null +++ b/deps/libssh2-sys-0.1.25/build.rs @@ -0,0 +1,161 @@ +extern crate pkg_config; + +use std::env; +use std::fs::{self, File}; +use std::io::prelude::*; +use std::path::PathBuf; +use std::process::Command; + +macro_rules! t { + ($e:expr) => (match $e { + Ok(n) => n, + Err(e) => panic!("\n{} failed with {}\n", stringify!($e), e), + }) +} + +fn main() { + let args = env::args_os(); + + // Oh boy! If we're compiling on MSVC, then it turns out this build script + // itself is going to be used as a compiler! Currently the nmake build + // files for libssh2 *always* add the /GL compiler option to compiler + // invocations to enable whole program optimization. + // + // Unfortunately this requires the linker be passed /LTCG as a parameter, + // and we don't currently have a great way of passing that parameter to the + // Rust compiler itself. As such, this script uses itself as a compiler for + // the MSVC code and passes the /GL- option to disable whole program + // optimization, allowing the linker to succeed. + if args.len() > 1 { + let args = args.collect::>(); + assert!(Command::new("cl").args(&args) + .arg("/GL-") + .status().unwrap() + .success()); + return + } + + match pkg_config::find_library("libssh2") { + Ok(..) => return, + Err(..) => {} + } + + let mut cflags = env::var("CFLAGS").unwrap_or(String::new()); + let target = env::var("TARGET").unwrap(); + let windows = target.contains("windows"); + cflags.push_str(" -ffunction-sections -fdata-sections"); + + if target.contains("i686") { + cflags.push_str(" -m32"); + } else if target.contains("x86_64") { + cflags.push_str(" -m64"); + } + if !target.contains("i686") { + cflags.push_str(" -fPIC"); + } + + match env::var("DEP_OPENSSL_ROOT") { + Ok(s) => { + cflags.push_str(&format!(" -I{}/include", s)); + cflags.push_str(&format!(" -L{}/lib", s)); + } + Err(..) => {} + } + + let dst = PathBuf::from(&env::var_os("OUT_DIR").unwrap()); + let root = t!(env::current_dir()).join("libssh2-1.5.0"); + + let _ = fs::remove_dir_all(&dst.join("include")); + let _ = fs::remove_dir_all(dst.join("lib")); + let _ = fs::remove_dir_all(dst.join("build")); + t!(fs::create_dir(dst.join("build"))); + + if !windows { + run(Command::new(root.join("configure")) + .env("CFLAGS", &cflags) + .current_dir(dst.join("build")) + .arg("--enable-shared=no") + .arg("--disable-examples-build") + .arg(format!("--prefix={}", dst.display()))); + run(Command::new(&make()) + .arg(&format!("-j{}", env::var("NUM_JOBS").unwrap())) + .current_dir(dst.join("build/src"))); + run(Command::new(&make()) + .arg("install") + .current_dir(dst.join("build/src"))); + run(Command::new(&make()) + .arg("install-data") + .current_dir(dst.join("build"))); + + // Unfortunately the pkg-config file generated for libssh2 indicates + // that it depends on zlib, but most systems don't actually have a + // zlib.pc, so pkg-config will say that libssh2 doesn't exist. We + // generally take care of the zlib dependency elsewhere, so we just + // remove that part from the pkg-config file + let mut pc = String::new(); + let pkgconfig = dst.join("lib/pkgconfig/libssh2.pc"); + t!(t!(File::open(&pkgconfig)).read_to_string(&mut pc)); + let pc = pc.replace(",zlib", ""); + let bytes = pc.as_bytes(); + t!(t!(File::create(pkgconfig)).write_all(bytes)); + + } else { + t!(fs::create_dir(dst.join("lib"))); + + if target.contains("msvc") { + run(Command::new("nmake") + .current_dir(&root) + .arg("/nologo") + // see above for why we set CC here + .env("CC", env::current_exe().unwrap()) + .env_remove("TARGET") + .arg("/fNMakefile") + .arg("BUILD_STATIC_LIB=1") + .arg("WITH_WINCNG=1")); + t!(fs::copy(root.join("Release/src/libssh2.lib"), + dst.join("lib/libssh2.a"))); + t!(fs::remove_dir_all(root.join("Release"))); + } else { + run(Command::new("make") + .current_dir(root.join("win32")) + .arg("-fGNUmakefile") + .arg("WITH_WINCNG=1") + .arg("WITH_ZLIB=1") + .arg("lib")); + t!(fs::remove_dir_all(root.join("win32/release"))); + t!(fs::copy(root.join("win32/libssh2.a"), dst.join("lib/libssh2.a"))); + t!(fs::remove_file(root.join("win32/libssh2.a"))); + } + + let root = root.join("include"); + let dst = dst.join("include"); + t!(fs::create_dir_all(&dst)); + t!(fs::copy(root.join("libssh2.h"), dst.join("libssh2.h"))); + t!(fs::copy(root.join("libssh2_publickey.h"), + dst.join("libssh2_publickey.h"))); + t!(fs::copy(root.join("libssh2_sftp.h"), dst.join("libssh2_sftp.h"))); + } + + if windows { + println!("cargo:rustc-link-lib=ws2_32"); + println!("cargo:rustc-link-lib=bcrypt"); + println!("cargo:rustc-link-lib=crypt32"); + println!("cargo:rustc-link-lib=user32"); + } + println!("cargo:rustc-link-search=native={}/lib", dst.display()); + println!("cargo:rustc-link-lib=static=ssh2"); + println!("cargo:root={}", dst.display()); + println!("cargo:include={}/include", dst.display()); +} + +fn make() -> &'static str { + if cfg!(target_os = "freebsd") {"gmake"} else {"make"} +} + +fn run(cmd: &mut Command) { + println!("running: {:?}", cmd); + let status = t!(cmd.status()); + if !status.success() { + panic!("command did not succeed, exited with: {}", status); + } +} diff --git a/deps/libssh2-sys-0.1.25/lib.rs b/deps/libssh2-sys-0.1.25/lib.rs new file mode 100644 index 000000000..6ac80d49a --- /dev/null +++ b/deps/libssh2-sys-0.1.25/lib.rs @@ -0,0 +1,520 @@ +#![doc(html_root_url = "http://alexcrichton.com/ssh2-rs")] +#![allow(bad_style)] + +extern crate libc; + +#[cfg(not(target_env = "msvc"))] +extern crate libz_sys; +#[cfg(unix)] +extern crate openssl_sys; + +use libc::{c_int, size_t, c_void, c_char, c_long, c_uchar, c_uint, c_ulong}; +use libc::ssize_t; + +pub const SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT: c_int = 1; +pub const SSH_DISCONNECT_PROTOCOL_ERROR: c_int = 2; +pub const SSH_DISCONNECT_KEY_EXCHANGE_FAILED: c_int = 3; +pub const SSH_DISCONNECT_RESERVED: c_int = 4; +pub const SSH_DISCONNECT_MAC_ERROR: c_int = 5; +pub const SSH_DISCONNECT_COMPRESSION_ERROR: c_int = 6; +pub const SSH_DISCONNECT_SERVICE_NOT_AVAILABLE: c_int = 7; +pub const SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED: c_int = 8; +pub const SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE: c_int = 9; +pub const SSH_DISCONNECT_CONNECTION_LOST: c_int = 10; +pub const SSH_DISCONNECT_BY_APPLICATION: c_int = 11; +pub const SSH_DISCONNECT_TOO_MANY_CONNECTIONS: c_int = 12; +pub const SSH_DISCONNECT_AUTH_CANCELLED_BY_USER: c_int = 13; +pub const SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE: c_int = 14; +pub const SSH_DISCONNECT_ILLEGAL_USER_NAME: c_int = 15; + +pub const LIBSSH2_FLAG_SIGPIPE: c_int = 1; +pub const LIBSSH2_FLAG_COMPRESS: c_int = 2; + +pub const LIBSSH2_HOSTKEY_TYPE_UNKNOWN: c_int = 0; +pub const LIBSSH2_HOSTKEY_TYPE_RSA: c_int = 1; +pub const LIBSSH2_HOSTKEY_TYPE_DSS: c_int = 2; + +pub const LIBSSH2_METHOD_KEX: c_int = 0; +pub const LIBSSH2_METHOD_HOSTKEY: c_int = 1; +pub const LIBSSH2_METHOD_CRYPT_CS: c_int = 2; +pub const LIBSSH2_METHOD_CRYPT_SC: c_int = 3; +pub const LIBSSH2_METHOD_MAC_CS: c_int = 4; +pub const LIBSSH2_METHOD_MAC_SC: c_int = 5; +pub const LIBSSH2_METHOD_COMP_CS: c_int = 6; +pub const LIBSSH2_METHOD_COMP_SC: c_int = 7; +pub const LIBSSH2_METHOD_LANG_CS: c_int = 8; +pub const LIBSSH2_METHOD_LANG_SC: c_int = 9; + +pub const LIBSSH2_CHANNEL_PACKET_DEFAULT: c_uint = 32768; +pub const LIBSSH2_CHANNEL_WINDOW_DEFAULT: c_uint = 2 * 1024 * 1024; + +pub const LIBSSH2_ERROR_BANNER_RECV: c_int = -2; +pub const LIBSSH2_ERROR_BANNER_SEND: c_int = -3; +pub const LIBSSH2_ERROR_INVALID_MAC: c_int = -4; +pub const LIBSSH2_ERROR_KEX_FAILURE: c_int = -5; +pub const LIBSSH2_ERROR_ALLOC: c_int = -6; +pub const LIBSSH2_ERROR_SOCKET_SEND: c_int = -7; +pub const LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: c_int = -8; +pub const LIBSSH2_ERROR_TIMEOUT: c_int = -9; +pub const LIBSSH2_ERROR_HOSTKEY_INIT: c_int = -10; +pub const LIBSSH2_ERROR_HOSTKEY_SIGN: c_int = -11; +pub const LIBSSH2_ERROR_DECRYPT: c_int = -12; +pub const LIBSSH2_ERROR_SOCKET_DISCONNECT: c_int = -13; +pub const LIBSSH2_ERROR_PROTO: c_int = -14; +pub const LIBSSH2_ERROR_PASSWORD_EXPIRED: c_int = -15; +pub const LIBSSH2_ERROR_FILE: c_int = -16; +pub const LIBSSH2_ERROR_METHOD_NONE: c_int = -17; +pub const LIBSSH2_ERROR_AUTHENTICATION_FAILED: c_int = -18; +pub const LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED: c_int = + LIBSSH2_ERROR_AUTHENTICATION_FAILED; +pub const LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: c_int = -19; +pub const LIBSSH2_ERROR_CHANNEL_OUTOFORDER: c_int = -20; +pub const LIBSSH2_ERROR_CHANNEL_FAILURE: c_int = -21; +pub const LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: c_int = -22; +pub const LIBSSH2_ERROR_CHANNEL_UNKNOWN: c_int = -23; +pub const LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: c_int = -24; +pub const LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: c_int = -25; +pub const LIBSSH2_ERROR_CHANNEL_CLOSED: c_int = -26; +pub const LIBSSH2_ERROR_CHANNEL_EOF_SENT: c_int = -27; +pub const LIBSSH2_ERROR_SCP_PROTOCOL: c_int = -28; +pub const LIBSSH2_ERROR_ZLIB: c_int = -29; +pub const LIBSSH2_ERROR_SOCKET_TIMEOUT: c_int = -30; +pub const LIBSSH2_ERROR_SFTP_PROTOCOL: c_int = -31; +pub const LIBSSH2_ERROR_REQUEST_DENIED: c_int = -32; +pub const LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: c_int = -33; +pub const LIBSSH2_ERROR_INVAL: c_int = -34; +pub const LIBSSH2_ERROR_INVALID_POLL_TYPE: c_int = -35; +pub const LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: c_int = -36; +pub const LIBSSH2_ERROR_EAGAIN: c_int = -37; +pub const LIBSSH2_ERROR_BUFFER_TOO_SMALL: c_int = -38; +pub const LIBSSH2_ERROR_BAD_USE: c_int = -39; +pub const LIBSSH2_ERROR_COMPRESS: c_int = -40; +pub const LIBSSH2_ERROR_OUT_OF_BOUNDARY: c_int = -41; +pub const LIBSSH2_ERROR_AGENT_PROTOCOL: c_int = -42; +pub const LIBSSH2_ERROR_SOCKET_RECV: c_int = -43; +pub const LIBSSH2_ERROR_ENCRYPT: c_int = -44; +pub const LIBSSH2_ERROR_BAD_SOCKET: c_int = -45; +pub const LIBSSH2_ERROR_KNOWN_HOSTS: c_int = -46; + +pub const LIBSSH2_HOSTKEY_HASH_MD5: c_int = 1; +pub const LIBSSH2_HOSTKEY_HASH_SHA1: c_int = 2; + +pub const LIBSSH2_KNOWNHOST_FILE_OPENSSH: c_int = 1; + +pub const LIBSSH2_KNOWNHOST_CHECK_MATCH: c_int = 0; +pub const LIBSSH2_KNOWNHOST_CHECK_MISMATCH: c_int = 1; +pub const LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: c_int = 2; +pub const LIBSSH2_KNOWNHOST_CHECK_FAILURE: c_int = 3; + +pub const LIBSSH2_KNOWNHOST_TYPE_PLAIN: c_int = 1; +pub const LIBSSH2_KNOWNHOST_TYPE_SHA1: c_int = 2; +pub const LIBSSH2_KNOWNHOST_TYPE_CUSTOM: c_int = 3; +pub const LIBSSH2_KNOWNHOST_KEYENC_RAW: c_int = 1 << 16; +pub const LIBSSH2_KNOWNHOST_KEYENC_BASE64: c_int = 2 << 16; +pub const LIBSSH2_KNOWNHOST_KEY_RSA1: c_int = 1 << 18; +pub const LIBSSH2_KNOWNHOST_KEY_SSHRSA: c_int = 2 << 18; +pub const LIBSSH2_KNOWNHOST_KEY_SSHDSS: c_int = 3 << 18; +pub const LIBSSH2_KNOWNHOST_KEY_UNKNOWN: c_int = 7 << 18; + +pub const LIBSSH2_FXF_READ: c_ulong = 0x00000001; +pub const LIBSSH2_FXF_WRITE: c_ulong = 0x00000002; +pub const LIBSSH2_FXF_APPEND: c_ulong = 0x00000004; +pub const LIBSSH2_FXF_CREAT: c_ulong = 0x00000008; +pub const LIBSSH2_FXF_TRUNC: c_ulong = 0x00000010; +pub const LIBSSH2_FXF_EXCL: c_ulong = 0x00000020; + +pub const LIBSSH2_SFTP_OPENFILE: c_int = 0; +pub const LIBSSH2_SFTP_OPENDIR: c_int = 1; + +pub const LIBSSH2_SFTP_ATTR_SIZE: c_ulong = 0x00000001; +pub const LIBSSH2_SFTP_ATTR_UIDGID: c_ulong = 0x00000002; +pub const LIBSSH2_SFTP_ATTR_PERMISSIONS: c_ulong = 0x00000004; +pub const LIBSSH2_SFTP_ATTR_ACMODTIME: c_ulong = 0x00000008; +pub const LIBSSH2_SFTP_ATTR_EXTENDED: c_ulong = 0x80000000; + +pub const LIBSSH2_SFTP_STAT: c_int = 0; +pub const LIBSSH2_SFTP_LSTAT: c_int = 1; +pub const LIBSSH2_SFTP_SETSTAT: c_int = 2; + +pub const LIBSSH2_SFTP_SYMLINK: c_int = 0; +pub const LIBSSH2_SFTP_READLINK: c_int = 1; +pub const LIBSSH2_SFTP_REALPATH: c_int = 2; + +pub const LIBSSH2_SFTP_RENAME_OVERWRITE: c_long = 0x1; +pub const LIBSSH2_SFTP_RENAME_ATOMIC: c_long = 0x2; +pub const LIBSSH2_SFTP_RENAME_NATIVE: c_long = 0x4; + +pub enum LIBSSH2_SESSION {} +pub enum LIBSSH2_AGENT {} +pub enum LIBSSH2_CHANNEL {} +pub enum LIBSSH2_LISTENER {} +pub enum LIBSSH2_KNOWNHOSTS {} +pub enum LIBSSH2_SFTP {} +pub enum LIBSSH2_SFTP_HANDLE {} + +#[repr(C)] +pub struct libssh2_agent_publickey { + pub magic: c_uint, + pub node: *mut c_void, + pub blob: *mut c_uchar, + pub blob_len: size_t, + pub comment: *const c_char, +} + +#[repr(C)] +pub struct libssh2_knownhost { + pub magic: c_uint, + pub node: *mut c_void, + pub name: *mut c_char, + pub key: *mut c_char, + pub typemask: c_int, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct LIBSSH2_SFTP_ATTRIBUTES { + pub flags: c_ulong, + pub filesize: u64, + pub uid: c_ulong, + pub gid: c_ulong, + pub permissions: c_ulong, + pub atime: c_ulong, + pub mtime: c_ulong, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct LIBSSH2_SFTP_STATVFS { + pub f_bsize: u64, + pub f_frsize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: u64, + pub f_flag: u64, + pub f_namemax: u64, +} + +pub type LIBSSH2_ALLOC_FUNC = extern fn(size_t, *mut *mut c_void) -> *mut c_void; +pub type LIBSSH2_FREE_FUNC = extern fn(*mut c_void, *mut *mut c_void); +pub type LIBSSH2_REALLOC_FUNC = extern fn(*mut c_void, size_t, *mut *mut c_void) + -> *mut c_void; +pub type LIBSSH2_PASSWD_CHANGEREQ_FUNC = extern fn(sess: *mut LIBSSH2_SESSION, + newpw: *mut *mut c_char, + newpw_len: *mut c_int, + abstrakt: *mut *mut c_void); + +#[cfg(unix)] pub type libssh2_socket_t = c_int; +#[cfg(windows)] pub type libssh2_socket_t = libc::SOCKET; + +extern { + // misc + pub fn libssh2_init(flag: c_int) -> c_int; + pub fn libssh2_exit(); + pub fn libssh2_free(sess: *mut LIBSSH2_SESSION, ptr: *mut c_void); + pub fn libssh2_hostkey_hash(session: *mut LIBSSH2_SESSION, + hash_type: c_int) -> *const c_char; + + // session + pub fn libssh2_session_init_ex(alloc: Option, + free: Option, + realloc: Option) + -> *mut LIBSSH2_SESSION; + pub fn libssh2_session_free(sess: *mut LIBSSH2_SESSION) -> c_int; + pub fn libssh2_session_banner_get(sess: *mut LIBSSH2_SESSION) -> *const c_char; + pub fn libssh2_session_banner_set(sess: *mut LIBSSH2_SESSION, + banner: *const c_char) -> c_int; + pub fn libssh2_session_disconnect_ex(sess: *mut LIBSSH2_SESSION, + reason: c_int, + description: *const c_char, + lang: *const c_char) -> c_int; + pub fn libssh2_session_flag(sess: *mut LIBSSH2_SESSION, + flag: c_int, value: c_int) -> c_int; + pub fn libssh2_session_get_blocking(session: *mut LIBSSH2_SESSION) -> c_int; + pub fn libssh2_session_get_timeout(sess: *mut LIBSSH2_SESSION) -> c_long; + pub fn libssh2_session_hostkey(sess: *mut LIBSSH2_SESSION, + len: *mut size_t, + kind: *mut c_int) -> *const c_char; + pub fn libssh2_session_method_pref(sess: *mut LIBSSH2_SESSION, + method_type: c_int, + prefs: *const c_char) -> c_int; + pub fn libssh2_session_methods(sess: *mut LIBSSH2_SESSION, + method_type: c_int) -> *const c_char; + pub fn libssh2_session_set_blocking(session: *mut LIBSSH2_SESSION, + blocking: c_int); + pub fn libssh2_session_set_timeout(session: *mut LIBSSH2_SESSION, + timeout: c_long); + pub fn libssh2_session_supported_algs(session: *mut LIBSSH2_SESSION, + method_type: c_int, + algs: *mut *mut *const c_char) -> c_int; + pub fn libssh2_session_last_error(sess: *mut LIBSSH2_SESSION, + msg: *mut *mut c_char, + len: *mut c_int, + want_buf: c_int) -> c_int; + pub fn libssh2_session_handshake(sess: *mut LIBSSH2_SESSION, + socket: libssh2_socket_t) -> c_int; + pub fn libssh2_keepalive_config(sess: *mut LIBSSH2_SESSION, + want_reply: c_int, + interval: c_uint) -> c_int; + pub fn libssh2_keepalive_send(sess: *mut LIBSSH2_SESSION, + seconds_to_next: *mut c_int) -> c_int; + + // agent + pub fn libssh2_agent_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_AGENT; + pub fn libssh2_agent_free(agent: *mut LIBSSH2_AGENT); + pub fn libssh2_agent_connect(agent: *mut LIBSSH2_AGENT) -> c_int; + pub fn libssh2_agent_disconnect(agent: *mut LIBSSH2_AGENT) -> c_int; + pub fn libssh2_agent_list_identities(agent: *mut LIBSSH2_AGENT) -> c_int; + pub fn libssh2_agent_get_identity(agent: *mut LIBSSH2_AGENT, + store: *mut *mut libssh2_agent_publickey, + prev: *mut libssh2_agent_publickey) + -> c_int; + pub fn libssh2_agent_userauth(agent: *mut LIBSSH2_AGENT, + username: *const c_char, + identity: *mut libssh2_agent_publickey) -> c_int; + + // channels + pub fn libssh2_channel_free(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_close(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_wait_closed(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_wait_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_process_startup(chan: *mut LIBSSH2_CHANNEL, + req: *const c_char, + req_len: c_uint, + msg: *const c_char, + msg_len: c_uint) -> c_int; + pub fn libssh2_channel_flush_ex(chan: *mut LIBSSH2_CHANNEL, + streamid: c_int) -> c_int; + pub fn libssh2_channel_write_ex(chan: *mut LIBSSH2_CHANNEL, + stream_id: c_int, + buf: *mut c_char, + buflen: size_t) -> c_int; + pub fn libssh2_channel_get_exit_signal(chan: *mut LIBSSH2_CHANNEL, + exitsignal: *mut *mut c_char, + exitsignal_len: *mut size_t, + errmsg: *mut *mut c_char, + errmsg_len: *mut size_t, + langtag: *mut *mut c_char, + langtag_len: *mut size_t) -> c_int; + pub fn libssh2_channel_get_exit_status(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_open_ex(sess: *mut LIBSSH2_SESSION, + channel_type: *const c_char, + channel_type_len: c_uint, + window_size: c_uint, + packet_size: c_uint, + message: *const c_char, + message_len: c_uint) -> *mut LIBSSH2_CHANNEL; + pub fn libssh2_channel_read_ex(chan: *mut LIBSSH2_CHANNEL, + stream_id: c_int, + buf: *mut c_char, + buflen: size_t) -> c_int; + pub fn libssh2_channel_setenv_ex(chan: *mut LIBSSH2_CHANNEL, + var: *const c_char, + varlen: c_uint, + val: *const c_char, + vallen: c_uint) -> c_int; + pub fn libssh2_channel_send_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int; + pub fn libssh2_channel_request_pty_ex(chan: *mut LIBSSH2_CHANNEL, + term: *const c_char, + termlen: c_uint, + modes: *const c_char, + modeslen: c_uint, + width: c_int, + height: c_int, + width_px: c_int, + height_px: c_int) -> c_int; + pub fn libssh2_channel_request_pty_size_ex(chan: *mut LIBSSH2_CHANNEL, + width: c_int, + height: c_int, + width_px: c_int, + height_px: c_int) -> c_int; + pub fn libssh2_channel_window_read_ex(chan: *mut LIBSSH2_CHANNEL, + read_avail: *mut c_uint, + window_size_initial: *mut c_uint) + -> c_uint; + pub fn libssh2_channel_window_write_ex(chan: *mut LIBSSH2_CHANNEL, + window_size_initial: *mut c_uint) + -> c_uint; + pub fn libssh2_channel_receive_window_adjust2(chan: *mut LIBSSH2_CHANNEL, + adjust: c_uint, + force: c_uchar, + window: *mut c_uint) -> c_int; + pub fn libssh2_channel_direct_tcpip_ex(ses: *mut LIBSSH2_SESSION, + host: *const c_char, + port: c_int, + shost: *const c_char, + sport: c_int) + -> *mut LIBSSH2_CHANNEL; + pub fn libssh2_channel_forward_accept(listener: *mut LIBSSH2_LISTENER) + -> *mut LIBSSH2_CHANNEL; + pub fn libssh2_channel_forward_cancel(listener: *mut LIBSSH2_LISTENER) + -> c_int; + pub fn libssh2_channel_forward_listen_ex(sess: *mut LIBSSH2_SESSION, + host: *mut c_char, + port: c_int, + bound_port: *mut c_int, + queue_maxsize: c_int) + -> *mut LIBSSH2_LISTENER; + + // userauth + pub fn libssh2_userauth_authenticated(sess: *mut LIBSSH2_SESSION) -> c_int; + pub fn libssh2_userauth_list(sess: *mut LIBSSH2_SESSION, + username: *const c_char, + username_len: c_uint) -> *const c_char; + pub fn libssh2_userauth_hostbased_fromfile_ex(sess: *mut LIBSSH2_SESSION, + username: *const c_char, + username_len: c_uint, + publickey: *const c_char, + privatekey: *const c_char, + passphrase: *const c_char, + hostname: *const c_char, + hostname_len: c_uint, + local_username: *const c_char, + local_len: c_uint) -> c_int; + pub fn libssh2_userauth_publickey_fromfile_ex(sess: *mut LIBSSH2_SESSION, + username: *const c_char, + username_len: c_uint, + publickey: *const c_char, + privatekey: *const c_char, + passphrase: *const c_char) + -> c_int; + pub fn libssh2_userauth_password_ex(session: *mut LIBSSH2_SESSION, + username: *const c_char, + username_len: c_uint, + password: *const c_char, + password_len: c_uint, + password_change_cb: + Option) + -> c_int; + + // knownhost + pub fn libssh2_knownhost_free(hosts: *mut LIBSSH2_KNOWNHOSTS); + pub fn libssh2_knownhost_addc(hosts: *mut LIBSSH2_KNOWNHOSTS, + host: *mut c_char, + salt: *mut c_char, + key: *mut c_char, + keylen: size_t, + comment: *const c_char, + commentlen: size_t, + typemask: c_int, + store: *mut *mut libssh2_knownhost) -> c_int; + pub fn libssh2_knownhost_check(hosts: *mut LIBSSH2_KNOWNHOSTS, + host: *const c_char, + key: *const c_char, + keylen: size_t, + typemask: c_int, + knownhost: *mut *mut libssh2_knownhost) + -> c_int; + pub fn libssh2_knownhost_checkp(hosts: *mut LIBSSH2_KNOWNHOSTS, + host: *const c_char, + port: c_int, + key: *const c_char, + keylen: size_t, + typemask: c_int, + knownhost: *mut *mut libssh2_knownhost) + -> c_int; + pub fn libssh2_knownhost_del(hosts: *mut LIBSSH2_KNOWNHOSTS, + entry: *mut libssh2_knownhost) -> c_int; + pub fn libssh2_knownhost_get(hosts: *mut LIBSSH2_KNOWNHOSTS, + store: *mut *mut libssh2_knownhost, + prev: *mut libssh2_knownhost) -> c_int; + pub fn libssh2_knownhost_readfile(hosts: *mut LIBSSH2_KNOWNHOSTS, + filename: *const c_char, + kind: c_int) -> c_int; + pub fn libssh2_knownhost_readline(hosts: *mut LIBSSH2_KNOWNHOSTS, + line: *const c_char, + len: size_t, + kind: c_int) -> c_int; + pub fn libssh2_knownhost_writefile(hosts: *mut LIBSSH2_KNOWNHOSTS, + filename: *const c_char, + kind: c_int) -> c_int; + pub fn libssh2_knownhost_writeline(hosts: *mut LIBSSH2_KNOWNHOSTS, + known: *mut libssh2_knownhost, + buffer: *mut c_char, + buflen: size_t, + outlen: *mut size_t, + kind: c_int) -> c_int; + pub fn libssh2_knownhost_init(sess: *mut LIBSSH2_SESSION) + -> *mut LIBSSH2_KNOWNHOSTS; + + // scp + pub fn libssh2_scp_recv(sess: *mut LIBSSH2_SESSION, + path: *const c_char, + sb: *mut libc::stat) -> *mut LIBSSH2_CHANNEL; + pub fn libssh2_scp_send64(sess: *mut LIBSSH2_SESSION, + path: *const c_char, + mode: c_int, + size: u64, + mtime: libc::time_t, + atime: libc::time_t) -> *mut LIBSSH2_CHANNEL; + + // sftp + pub fn libssh2_sftp_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_SFTP; + pub fn libssh2_sftp_shutdown(sftp: *mut LIBSSH2_SFTP) -> c_int; + pub fn libssh2_sftp_last_error(sftp: *mut LIBSSH2_SFTP) -> c_ulong; + pub fn libssh2_sftp_open_ex(sftp: *mut LIBSSH2_SFTP, + filename: *const c_char, + filename_len: c_uint, + flags: c_ulong, + mode: c_long, + open_type: c_int) -> *mut LIBSSH2_SFTP_HANDLE; + pub fn libssh2_sftp_close_handle(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int; + pub fn libssh2_sftp_mkdir_ex(sftp: *mut LIBSSH2_SFTP, + path: *const c_char, + path_len: c_uint, + mode: c_long) -> c_int; + pub fn libssh2_sftp_fsync(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int; + pub fn libssh2_sftp_fstat_ex(handle: *mut LIBSSH2_SFTP_HANDLE, + attrs: *mut LIBSSH2_SFTP_ATTRIBUTES, + setstat: c_int) -> c_int; + pub fn libssh2_sftp_fstatvfs(handle: *mut LIBSSH2_SFTP_HANDLE, + attrs: *mut LIBSSH2_SFTP_STATVFS) -> c_int; + pub fn libssh2_sftp_stat_ex(sftp: *mut LIBSSH2_SFTP, + path: *const c_char, + path_len: c_uint, + stat_type: c_int, + attrs: *mut LIBSSH2_SFTP_ATTRIBUTES) -> c_int; + pub fn libssh2_sftp_read(handle: *mut LIBSSH2_SFTP_HANDLE, + buf: *mut c_char, + len: size_t) -> ssize_t; + pub fn libssh2_sftp_symlink_ex(sftp: *mut LIBSSH2_SFTP, + path: *const c_char, + path_len: c_uint, + target: *mut c_char, + target_len: c_uint, + link_type: c_int) -> c_int; + pub fn libssh2_sftp_rename_ex(sftp: *mut LIBSSH2_SFTP, + src: *const c_char, + src_len: c_uint, + dst: *const c_char, + dst_len: c_uint, + flags: c_long) -> c_int; + pub fn libssh2_sftp_rmdir_ex(sftp: *mut LIBSSH2_SFTP, + path: *const c_char, + path_len: c_uint) -> c_int; + pub fn libssh2_sftp_write(handle: *mut LIBSSH2_SFTP_HANDLE, + buffer: *const c_char, + len: size_t) -> ssize_t; + pub fn libssh2_sftp_tell64(handle: *mut LIBSSH2_SFTP_HANDLE) -> u64; + pub fn libssh2_sftp_seek64(handle: *mut LIBSSH2_SFTP_HANDLE, off: u64); + pub fn libssh2_sftp_readdir_ex(handle: *mut LIBSSH2_SFTP_HANDLE, + buffer: *mut c_char, + buffer_len: size_t, + longentry: *mut c_char, + longentry_len: size_t, + attrs: *mut LIBSSH2_SFTP_ATTRIBUTES) -> c_int; + pub fn libssh2_sftp_unlink_ex(sftp: *mut LIBSSH2_SFTP, + filename: *const c_char, + filename_len: c_uint) -> c_int; +} + +#[test] +fn smoke() { + unsafe { libssh2_init(0) }; +} + +pub fn issue_14344_workaround() {} diff --git a/deps/libz-sys-0.1.6/.gitignore b/deps/libz-sys-0.1.6/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/libz-sys-0.1.6/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/libz-sys-0.1.6/Cargo.toml b/deps/libz-sys-0.1.6/Cargo.toml new file mode 100644 index 000000000..a6d1fa69e --- /dev/null +++ b/deps/libz-sys-0.1.6/Cargo.toml @@ -0,0 +1,18 @@ +[package] + +name = "libz-sys" +version = "0.1.6" +authors = ["Alex Crichton "] +links = "z" +build = "build.rs" +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/libz-sys" +description = """ +Bindings to the system libz library (also known as zlib). +""" + +[dependencies] +libc = "0.1" + +[build-dependencies] +pkg-config = "0.3" diff --git a/deps/libz-sys-0.1.6/LICENSE-APACHE b/deps/libz-sys-0.1.6/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/libz-sys-0.1.6/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/libz-sys-0.1.6/LICENSE-MIT b/deps/libz-sys-0.1.6/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/libz-sys-0.1.6/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/libz-sys-0.1.6/README.md b/deps/libz-sys-0.1.6/README.md new file mode 100644 index 000000000..ee7be8b72 --- /dev/null +++ b/deps/libz-sys-0.1.6/README.md @@ -0,0 +1,11 @@ +# libz-sys + +A common library for linking `libz` to rust programs (also known as zlib). + +# License + +`libz-sys` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/libz-sys-0.1.6/build.rs b/deps/libz-sys-0.1.6/build.rs new file mode 100644 index 000000000..ad8b100c8 --- /dev/null +++ b/deps/libz-sys-0.1.6/build.rs @@ -0,0 +1,71 @@ +extern crate pkg_config; + +use std::env; +use std::ffi::OsString; +use std::fs; +use std::path::PathBuf; +use std::process::Command; + +macro_rules! t { + ($e:expr) => (match $e { + Ok(n) => n, + Err(e) => panic!("\n{} failed with {}\n", stringify!($e), e), + }) +} + +fn main() { + if pkg_config::find_library("zlib").is_ok() { + return + } + + // Practically all platforms come with libz installed already, but MSVC is + // one of those sole platforms that doesn't! + let target = env::var("TARGET").unwrap(); + if target.contains("msvc") { + build_msvc_zlib(); + } else { + println!("cargo:rustc-link-lib=z"); + } +} + +fn build_msvc_zlib() { + let src = t!(env::current_dir()).join("src/zlib-1.2.8"); + let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + + t!(fs::create_dir_all(dst.join("lib"))); + t!(fs::create_dir_all(dst.join("include"))); + + let mut top = OsString::from("TOP="); + top.push(&src); + run(Command::new("nmake") + .current_dir(dst.join("lib")) + .arg("/f") + .arg(src.join("win32/Makefile.msc")) + .arg(top) + .arg("zlib.lib")); + + for file in t!(fs::read_dir(&src)) { + let file = t!(file).path(); + if let Some(s) = file.file_name().and_then(|s| s.to_str()) { + if s.ends_with(".h") { + t!(fs::copy(&file, dst.join("include").join(s))); + } + } + } + + println!("cargo:rustc-link-lib=zlib"); + println!("cargo:rustc-link-search={}/lib", dst.to_string_lossy()); + println!("cargo:root={}", dst.to_string_lossy()); + println!("cargo:include={}/include", dst.to_string_lossy()); +} + +fn run(cmd: &mut Command) { + println!("running: {:?}", cmd); + let status = match cmd.status() { + Ok(s) => s, + Err(e) => panic!("failed to run: {}", e), + }; + if !status.success() { + panic!("failed to run successfully: {}", status); + } +} diff --git a/deps/libz-sys-0.1.6/src/lib.rs b/deps/libz-sys-0.1.6/src/lib.rs new file mode 100644 index 000000000..5f913f362 --- /dev/null +++ b/deps/libz-sys-0.1.6/src/lib.rs @@ -0,0 +1,176 @@ +#![allow(non_camel_case_types)] + +extern crate libc; + +use libc::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void}; + +pub type alloc_func = unsafe extern fn (voidpf, uInt, uInt) -> voidpf; +pub type Bytef = u8; +pub type free_func = unsafe extern fn (voidpf, voidpf); +pub type gzFile = *mut gzFile_s; +pub type in_func = unsafe extern fn (*mut c_void, *mut *const c_uchar) -> c_uint; +pub type out_func = unsafe extern fn (*mut c_void, *mut c_uchar, c_uint) -> c_int; +pub type uInt = c_uint; +pub type uLong = c_ulong; +pub type uLongf = c_ulong; +pub type voidp = *mut c_void; +pub type voidpc = *const c_void; +pub type voidpf = *mut c_void; + +pub enum gzFile_s {} +pub enum internal_state {} + +#[cfg(unix)] pub type z_off_t = libc::off_t; +#[cfg(not(unix))] pub type z_off_t = c_long; + +#[repr(C)] +pub struct gz_header { + pub text: c_int, + pub time: uLong, + pub xflags: c_int, + pub os: c_int, + pub extra: *mut Bytef, + pub extra_len: uInt, + pub extra_max: uInt, + pub name: *mut Bytef, + pub name_max: uInt, + pub comment: *mut Bytef, + pub comm_max: uInt, + pub hcrc: c_int, + pub done: c_int, +} +pub type gz_headerp = *mut gz_header; + +#[repr(C)] +pub struct z_stream { + pub next_in: *const Bytef, + pub avail_in: uInt, + pub total_in: uLong, + pub next_out: *mut Bytef, + pub avail_out: uInt, + pub total_out: uLong, + pub msg: *const c_char, + pub state: *mut internal_state, + pub zalloc: alloc_func, + pub zfree: free_func, + pub opaque: voidpf, + pub data_type: c_int, + pub adler: uLong, + pub reserved: uLong, +} +pub type z_streamp = *mut z_stream; + +extern "system" { + pub fn adler32(adler: uLong, buf: *const Bytef, len: uInt) -> uLong; + pub fn adler32_combine(adler1: uLong, adler2: uLong, len2: z_off_t) -> uLong; + pub fn compress(dest: *mut Bytef, destLen: *mut uLongf, + source: *const Bytef, sourceLen: uLong) -> c_int; + pub fn compress2(dest: *mut Bytef, destLen: *mut uLongf, + source: *const Bytef, sourceLen: uLong, + level: c_int) -> c_int; + pub fn compressBound(sourceLen: uLong) -> uLong; + pub fn crc32(crc: uLong, buf: *const Bytef, len: uInt) -> uLong; + pub fn crc32_combine(crc1: uLong, crc2: uLong, len2: z_off_t) -> uLong; + pub fn deflate(strm: z_streamp, flush: c_int) -> c_int; + pub fn deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong; + pub fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int; + pub fn deflateEnd(strm: z_streamp) -> c_int; + pub fn deflateInit(strm: z_streamp, level: c_int) -> c_int; + pub fn deflateInit2(strm: z_streamp, level: c_int, method: c_int, + windowBits: c_int, memLevel: c_int, + strategy: c_int) -> c_int; + pub fn deflateParams(strm: z_streamp, level: c_int, + strategy: c_int) -> c_int; + pub fn deflatePending(strm: z_streamp, pending: *mut libc::c_uint, + bits: *mut c_int) -> c_int; + pub fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; + pub fn deflateReset(strm: z_streamp) -> c_int; + pub fn deflateSetDictionary(strm: z_streamp, dictionary: *const Bytef, + dictLength: uInt) -> c_int; + pub fn deflateSetHeader(strm: z_streamp, head: gz_headerp) -> c_int; + pub fn deflateTune(strm: z_streamp, good_length: c_int, max_lazy: c_int, + nice_length: c_int, max_chain: c_int) -> c_int; + pub fn gzbuffer(file: gzFile, size: c_uint) -> c_int; + pub fn gzdirect(file: gzFile) -> c_int; + pub fn gzdopen(fd: c_int, mode: *const c_char) -> gzFile; + pub fn gzclearerr(file: gzFile); + pub fn gzclose(file: gzFile) -> c_int; + pub fn gzclose_r(file: gzFile) -> c_int; + pub fn gzclose_w(file: gzFile) -> c_int; + pub fn gzeof(file: gzFile) -> c_int; + pub fn gzerror(file: gzFile, errnum: *mut c_int) -> *const c_char; + pub fn gzflush(file: gzFile, flush: c_int) -> c_int; + pub fn gzgetc(file: gzFile) -> c_int; + pub fn gzgets(file: gzFile, buf: *mut c_char, len: c_int) -> *mut c_char; + pub fn gzoffset(file: gzFile) -> z_off_t; + pub fn gzopen(path: *const c_char, mode: *const c_char) -> gzFile; + pub fn gzputc(file: gzFile, c: c_int) -> c_int; + pub fn gzputs(file: gzFile, s: *const c_char) -> c_int; + pub fn gzread(file: gzFile, buf: voidp, len: c_uint) -> c_int; + pub fn gzrewind(file: gzFile) -> c_int; + pub fn gzseek(file: gzFile, offset: z_off_t, whence: c_int) -> z_off_t; + pub fn gzsetparams(file: gzFile, level: c_int, strategy: c_int) -> c_int; + pub fn gztell(file: gzFile) -> z_off_t; + pub fn gzungetc(c: c_int, file: gzFile) -> c_int; + pub fn gzwrite(file: gzFile, buf: voidpc, len: c_uint) -> c_int; + pub fn inflate(strm: z_streamp, flush: c_int) -> c_int; + pub fn inflateBack(strm: z_streamp, _in: in_func, in_desc: *mut c_void, + out: out_func, out_desc: *mut c_void) -> c_int; + pub fn inflateBackEnd(strm: z_streamp) -> c_int; + pub fn inflateBackInit(strm: z_streamp, windowBits: c_int, + window: *mut c_uchar) -> c_int; + pub fn inflateCopy(dest: z_streamp, source: z_streamp) -> c_int; + pub fn inflateEnd(strm: z_streamp) -> c_int; + pub fn inflateGetDictionary(strm: z_streamp, dictionary: *mut Bytef, + dictLength: *mut uInt) -> c_int; + pub fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int; + pub fn inflateInit(strm: z_streamp) -> c_int; + pub fn inflateInit2(strm: z_streamp, windowBits: c_int) -> c_int; + pub fn inflateMark(strm: z_streamp) -> c_long; + pub fn inflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; + pub fn inflateReset(strm: z_streamp) -> c_int; + pub fn inflateReset2(strm: z_streamp, windowBits: c_int) -> c_int; + pub fn inflateSetDictionary(strm: z_streamp, dictionary: *const Bytef, + dictLength: uInt) -> c_int; + pub fn inflateSync(strm: z_streamp) -> c_int; + pub fn uncompress(dest: *mut Bytef, destLen: *mut uLongf, + source: *const Bytef, sourceLen: uLong) -> c_int; + pub fn zlibCompileFlags() -> uLong; + pub fn zlibVersion() -> *const c_char; +} + +pub const Z_NO_FLUSH: c_int = 0; +pub const Z_PARTIAL_FLUSH: c_int = 1; +pub const Z_SYNC_FLUSH: c_int = 2; +pub const Z_FULL_FLUSH: c_int = 3; +pub const Z_FINISH: c_int = 4; +pub const Z_BLOCK: c_int = 5; +pub const Z_TREES: c_int = 6; + +pub const Z_OK: c_int = 0; +pub const Z_STREAM_END: c_int = 1; +pub const Z_NEED_DICT: c_int = 2; +pub const Z_ERRNO: c_int = -1; +pub const Z_STREAM_ERROR: c_int = -2; +pub const Z_DATA_ERROR: c_int = -3; +pub const Z_MEM_ERROR: c_int = -4; +pub const Z_BUF_ERROR: c_int = -5; +pub const Z_VERSION_ERROR: c_int = -6; + +pub const Z_NO_COMPRESSION: c_int = 0; +pub const Z_BEST_SPEED: c_int = 1; +pub const Z_BEST_COMPRESSION: c_int = 9; +pub const Z_DEFAULT_COMPRESSION: c_int = -1; + +pub const Z_FILTERED: c_int = 1; +pub const Z_HUFFMAN_ONLY: c_int = 2; +pub const Z_RLE: c_int = 3; +pub const Z_FIXED: c_int = 4; +pub const Z_DEFAULT_STRATEGY: c_int = 0; + +pub const Z_BINARY: c_int = 0; +pub const Z_TEXT: c_int = 1; +pub const Z_ASCII: c_int = Z_TEXT; +pub const Z_UNKNOWN: c_int = 2; + +pub const Z_DEFLATED: c_int = 8; diff --git a/deps/log-0.3.1/.gitignore b/deps/log-0.3.1/.gitignore new file mode 100644 index 000000000..2c96eb1b6 --- /dev/null +++ b/deps/log-0.3.1/.gitignore @@ -0,0 +1,2 @@ +target/ +Cargo.lock diff --git a/deps/log-0.3.1/.travis.yml b/deps/log-0.3.1/.travis.yml new file mode 100644 index 000000000..397e33a2d --- /dev/null +++ b/deps/log-0.3.1/.travis.yml @@ -0,0 +1,20 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo test --verbose --manifest-path env/Cargo.toml + - cargo doc --manifest-path env/Cargo.toml +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '' > env/target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n env/target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: bNUxFmA5uEdKKdVDtgb+5WQuMRDZ6QxK5152sIZWSimxyr/x5erNZ1uacPh02Ng92dbUQ66wz90WPmqTwoL0EeJ/FmZDd29hRHXe82MNpz47QX3cGMgFNldQ2GmJmCHBXKu373B80o/ZB+BTVcYcl1ksTXuIhQg2wZtXh8bZ9F4= +notifications: + email: + on_success: never diff --git a/deps/log-0.3.1/Cargo.toml b/deps/log-0.3.1/Cargo.toml new file mode 100644 index 000000000..4d61c32dc --- /dev/null +++ b/deps/log-0.3.1/Cargo.toml @@ -0,0 +1,20 @@ +[package] + +name = "log" +version = "0.3.1" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/log" +documentation = "http://doc.rust-lang.org/log" +homepage = "https://github.com/rust-lang/log" +description = """ +A lightweight logging facade for Rust +""" + +[[test]] +name = "filters" +harness = false + +[dependencies] +libc = "0.1" diff --git a/deps/log-0.3.1/LICENSE-APACHE b/deps/log-0.3.1/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/log-0.3.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/log-0.3.1/LICENSE-MIT b/deps/log-0.3.1/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/log-0.3.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/log-0.3.1/README.md b/deps/log-0.3.1/README.md new file mode 100644 index 000000000..1ac0189b7 --- /dev/null +++ b/deps/log-0.3.1/README.md @@ -0,0 +1,80 @@ +log +=== + +A Rust library providing a lightweight logging *facade*. + +[![Build Status](https://travis-ci.org/rust-lang/log.svg?branch=master)](https://travis-ci.org/rust-lang/log) + +* [`log` documentation](http://doc.rust-lang.org/log) +* [`env_logger` documentation](http://doc.rust-lang.org/log/env_logger) + +A logging facade provides a single logging API that abstracts over the actual +logging implementation. Libraries can use the logging API provided by this +crate, and the consumer of those libraries can choose the logging +implementation that is most suitable for its use case. + +## Usage + +## In libraries + +Libraries should link only to the `log` crate, and use the provided macros to +log whatever information will be useful to downstream consumers: + +```toml +[dependencies] +log = "0.3" +``` + +```rust +#[macro_use] +extern crate log; + +pub fn shave_the_yak(yak: &Yak) { + trace!("Commencing yak shaving"); + + loop { + match find_a_razor() { + Ok(razor) => { + info!("Razor located: {}", razor); + yak.shave(razor); + break; + } + Err(err) => { + warn!("Unable to locate a razor: {}, retrying", err); + } + } + } +} +``` + +## In executables + +Executables should chose a logger implementation and initialize it early in the +runtime of the program. Logger implementations will typically include a +function to do this. Any log messages generated before the logger is +initialized will be ignored. + +The executable itself may use the `log` crate to log as well. + +The `env_logger` crate provides a logger implementation that mirrors the +functionality of the old revision of the `log` crate. + +```toml +[dependencies] +log = "0.3" +env_logger = "0.3" +``` + +```rust +#[macro_use] +extern crate log; +extern crate env_logger; + +fn main() { + env_logger::init().unwrap(); + + info!("starting up"); + + // ... +} +``` diff --git a/deps/log-0.3.1/src/lib.rs b/deps/log-0.3.1/src/lib.rs new file mode 100644 index 000000000..04271511f --- /dev/null +++ b/deps/log-0.3.1/src/lib.rs @@ -0,0 +1,773 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A lightweight logging facade. +//! +//! A logging facade provides a single logging API that abstracts over the +//! actual logging implementation. Libraries can use the logging API provided +//! by this crate, and the consumer of those libraries can choose the logging +//! framework that is most suitable for its use case. +//! +//! If no logging implementation is selected, the facade falls back to a "noop" +//! implementation that ignores all log messages. The overhead in this case +//! is very small - just an integer load, comparison and jump. +//! +//! A log request consists of a target, a level, and a body. A target is a +//! string which defaults to the module path of the location of the log +//! request, though that default may be overridden. Logger implementations +//! typically use the target to filter requests based on some user +//! configuration. +//! +//! # Use +//! +//! ## In libraries +//! +//! Libraries should link only to the `log` crate, and use the provided +//! macros to log whatever information will be useful to downstream consumers. +//! +//! ### Examples +//! +//! ```rust +//! # #![allow(unstable)] +//! #[macro_use] +//! extern crate log; +//! +//! # #[derive(Debug)] pub struct Yak(String); +//! # impl Yak { fn shave(&self, _: u32) {} } +//! # fn find_a_razor() -> Result { Ok(1) } +//! pub fn shave_the_yak(yak: &Yak) { +//! info!(target: "yak_events", "Commencing yak shaving for {:?}", yak); +//! +//! loop { +//! match find_a_razor() { +//! Ok(razor) => { +//! info!("Razor located: {}", razor); +//! yak.shave(razor); +//! break; +//! } +//! Err(err) => { +//! warn!("Unable to locate a razor: {}, retrying", err); +//! } +//! } +//! } +//! } +//! # fn main() {} +//! ``` +//! +//! ## In executables +//! +//! Executables should chose a logging framework and initialize it early in the +//! runtime of the program. Logging frameworks will typically include a +//! function to do this. Any log messages generated before the framework is +//! initialized will be ignored. +//! +//! The executable itself may use the `log` crate to log as well. +//! +//! ### Warning +//! +//! The logging system may only be initialized once. +//! +//! ### Examples +//! +//! ```rust,ignore +//! #[macro_use] +//! extern crate log; +//! extern crate my_logger; +//! +//! fn main() { +//! my_logger::init(); +//! +//! info!("starting up"); +//! +//! // ... +//! } +//! ``` +//! +//! # Logger implementations +//! +//! Loggers implement the `Log` trait. Here's a very basic example that simply +//! logs all messages at the `Error`, `Warn` or `Info` levels to stdout: +//! +//! ```rust +//! extern crate log; +//! +//! use log::{LogRecord, LogLevel, LogMetadata}; +//! +//! struct SimpleLogger; +//! +//! impl log::Log for SimpleLogger { +//! fn enabled(&self, metadata: &LogMetadata) -> bool { +//! metadata.level() <= LogLevel::Info +//! } +//! +//! fn log(&self, record: &LogRecord) { +//! if self.enabled(record.metadata()) { +//! println!("{} - {}", record.level(), record.args()); +//! } +//! } +//! } +//! +//! # fn main() {} +//! ``` +//! +//! Loggers are installed by calling the `set_logger` function. It takes a +//! closure which is provided a `MaxLogLevel` token and returns a `Log` trait +//! object. The `MaxLogLevel` token controls the global maximum log level. The +//! logging facade uses this as an optimization to improve performance of log +//! messages at levels that are disabled. In the case of our example logger, +//! we'll want to set the maximum log level to `Info`, since we ignore any +//! `Debug` or `Trace` level log messages. A logging framework should provide a +//! function that wraps a call to `set_logger`, handling initialization of the +//! logger: +//! +//! ```rust +//! # extern crate log; +//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, LogMetadata}; +//! # struct SimpleLogger; +//! # impl log::Log for SimpleLogger { +//! # fn enabled(&self, _: &LogMetadata) -> bool { false } +//! # fn log(&self, _: &log::LogRecord) {} +//! # } +//! # fn main() {} +//! pub fn init() -> Result<(), SetLoggerError> { +//! log::set_logger(|max_log_level| { +//! max_log_level.set(LogLevelFilter::Info); +//! Box::new(SimpleLogger) +//! }) +//! } +//! ``` + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/log/")] +#![warn(missing_docs)] + +extern crate libc; + +use std::ascii::AsciiExt; +use std::cmp; +use std::error; +use std::fmt; +use std::mem; +use std::ops::Deref; +use std::str::FromStr; +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; +mod macros; + +// The setup here is a bit weird to make at_exit work. +// +// There are four different states that we care about: the logger's +// uninitialized, the logger's initializing (set_logger's been called but +// LOGGER hasn't actually been set yet), the logger's active, or the logger's +// shutting down inside of at_exit. +// +// The LOGGER static is normally a Box> with some special possible +// values as well. The uninitialized and initializing states are represented by +// the values 0 and 1 respectively. The shutting down state is also represented +// by 1. Any other value is a valid pointer to the logger. +// +// The at_exit routine needs to make sure that no threads are actively logging +// when it deallocates the logger. The number of actively logging threads is +// tracked in the REFCOUNT static. The routine first sets LOGGER back to 1. +// All logging calls past that point will immediately return without accessing +// the logger. At that point, the at_exit routine just waits for the refcount +// to reach 0 before deallocating the logger. Note that the refcount does not +// necessarily monotonically decrease at this point, as new log calls still +// increment and decrement it, but the interval in between is small enough that +// the wait is really just for the active log calls to finish. +static LOGGER: AtomicUsize = ATOMIC_USIZE_INIT; +static REFCOUNT: AtomicUsize = ATOMIC_USIZE_INIT; + +const UNINITIALIZED: usize = 0; +const INITIALIZING: usize = 1; + +static MAX_LOG_LEVEL_FILTER: AtomicUsize = ATOMIC_USIZE_INIT; + +static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO", + "DEBUG", "TRACE"]; + +/// An enum representing the available verbosity levels of the logging framework +/// +/// A `LogLevel` may be compared directly to a `LogLevelFilter`. +#[repr(usize)] +#[derive(Copy, Eq, Debug)] +pub enum LogLevel { + /// The "error" level. + /// + /// Designates very serious errors. + Error = 1, // This way these line up with the discriminants for LogLevelFilter below + /// The "warn" level. + /// + /// Designates hazardous situations. + Warn, + /// The "info" level. + /// + /// Designates useful information. + Info, + /// The "debug" level. + /// + /// Designates lower priority information. + Debug, + /// The "trace" level. + /// + /// Designates very low priority, often extremely verbose, information. + Trace, +} + +impl Clone for LogLevel { + #[inline] + fn clone(&self) -> LogLevel { + *self + } +} + +impl PartialEq for LogLevel { + #[inline] + fn eq(&self, other: &LogLevel) -> bool { + *self as usize == *other as usize + } +} + +impl PartialEq for LogLevel { + #[inline] + fn eq(&self, other: &LogLevelFilter) -> bool { + *self as usize == *other as usize + } +} + +impl PartialOrd for LogLevel { + #[inline] + fn partial_cmp(&self, other: &LogLevel) -> Option { + Some(self.cmp(other)) + } +} + +impl PartialOrd for LogLevel { + #[inline] + fn partial_cmp(&self, other: &LogLevelFilter) -> Option { + Some((*self as usize).cmp(&(*other as usize))) + } +} + +impl Ord for LogLevel { + #[inline] + fn cmp(&self, other: &LogLevel) -> cmp::Ordering { + (*self as usize).cmp(&(*other as usize)) + } +} + +fn ok_or(t: Option, e: E) -> Result { + match t { + Some(t) => Ok(t), + None => Err(e), + } +} + +impl FromStr for LogLevel { + type Err = (); + fn from_str(level: &str) -> Result { + ok_or(LOG_LEVEL_NAMES.iter() + .position(|&name| name.eq_ignore_ascii_case(level)) + .into_iter() + .filter(|&idx| idx != 0) + .map(|idx| LogLevel::from_usize(idx).unwrap()) + .next(), ()) + } +} + +impl fmt::Display for LogLevel { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.pad(LOG_LEVEL_NAMES[*self as usize]) + } +} + +impl LogLevel { + fn from_usize(u: usize) -> Option { + match u { + 1 => Some(LogLevel::Error), + 2 => Some(LogLevel::Warn), + 3 => Some(LogLevel::Info), + 4 => Some(LogLevel::Debug), + 5 => Some(LogLevel::Trace), + _ => None + } + } + + /// Returns the most verbose logging level. + #[inline] + pub fn max() -> LogLevel { + LogLevel::Trace + } + + /// Converts the `LogLevel` to the equivalent `LogLevelFilter`. + #[inline] + pub fn to_log_level_filter(&self) -> LogLevelFilter { + LogLevelFilter::from_usize(*self as usize).unwrap() + } +} + +/// An enum representing the available verbosity level filters of the logging +/// framework. +/// +/// A `LogLevelFilter` may be compared directly to a `LogLevel`. +#[repr(usize)] +#[derive(Copy, Eq, Debug)] +pub enum LogLevelFilter { + /// A level lower than all log levels. + Off, + /// Corresponds to the `Error` log level. + Error, + /// Corresponds to the `Warn` log level. + Warn, + /// Corresponds to the `Trace` log level. + Info, + /// Corresponds to the `Debug` log level. + Debug, + /// Corresponds to the `Trace` log level. + Trace, +} + +// Deriving generates terrible impls of these traits + +impl Clone for LogLevelFilter { + #[inline] + fn clone(&self) -> LogLevelFilter { + *self + } +} + +impl PartialEq for LogLevelFilter { + #[inline] + fn eq(&self, other: &LogLevelFilter) -> bool { + *self as usize == *other as usize + } +} + +impl PartialEq for LogLevelFilter { + #[inline] + fn eq(&self, other: &LogLevel) -> bool { + other.eq(self) + } +} + +impl PartialOrd for LogLevelFilter { + #[inline] + fn partial_cmp(&self, other: &LogLevelFilter) -> Option { + Some(self.cmp(other)) + } +} + +impl PartialOrd for LogLevelFilter { + #[inline] + fn partial_cmp(&self, other: &LogLevel) -> Option { + other.partial_cmp(self).map(|x| x.reverse()) + } +} + +impl Ord for LogLevelFilter { + #[inline] + fn cmp(&self, other: &LogLevelFilter) -> cmp::Ordering { + (*self as usize).cmp(&(*other as usize)) + } +} + +impl FromStr for LogLevelFilter { + type Err = (); + fn from_str(level: &str) -> Result { + ok_or(LOG_LEVEL_NAMES.iter() + .position(|&name| name.eq_ignore_ascii_case(level)) + .map(|p| LogLevelFilter::from_usize(p).unwrap()), ()) + } +} + +impl fmt::Display for LogLevelFilter { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "{}", LOG_LEVEL_NAMES[*self as usize]) + } +} + +impl LogLevelFilter { + fn from_usize(u: usize) -> Option { + match u { + 0 => Some(LogLevelFilter::Off), + 1 => Some(LogLevelFilter::Error), + 2 => Some(LogLevelFilter::Warn), + 3 => Some(LogLevelFilter::Info), + 4 => Some(LogLevelFilter::Debug), + 5 => Some(LogLevelFilter::Trace), + _ => None + } + } + /// Returns the most verbose logging level filter. + #[inline] + pub fn max() -> LogLevelFilter { + LogLevelFilter::Trace + } + + /// Converts `self` to the equivalent `LogLevel`. + /// + /// Returns `None` if `self` is `LogLevelFilter::Off`. + #[inline] + pub fn to_log_level(&self) -> Option { + LogLevel::from_usize(*self as usize) + } +} + +/// The "payload" of a log message. +pub struct LogRecord<'a> { + metadata: LogMetadata<'a>, + location: &'a LogLocation, + args: fmt::Arguments<'a>, +} + +impl<'a> LogRecord<'a> { + /// The message body. + pub fn args(&self) -> &fmt::Arguments<'a> { + &self.args + } + + /// Metadata about the log directive. + pub fn metadata(&self) -> &LogMetadata { + &self.metadata + } + + /// The location of the log directive. + pub fn location(&self) -> &LogLocation { + self.location + } + + /// The verbosity level of the message. + pub fn level(&self) -> LogLevel { + self.metadata.level() + } + + /// The name of the target of the directive. + pub fn target(&self) -> &str { + self.metadata.target() + } +} + +/// Metadata about a log message. +pub struct LogMetadata<'a> { + level: LogLevel, + target: &'a str, +} + +impl<'a> LogMetadata<'a> { + /// The verbosity level of the message. + pub fn level(&self) -> LogLevel { + self.level + } + + /// The name of the target of the directive. + pub fn target(&self) -> &str { + self.target + } +} + +/// A trait encapsulating the operations required of a logger +pub trait Log: Sync+Send { + /// Determines if a log message with the specified metadata would be + /// logged. + /// + /// This is used by the `log_enabled!` macro to allow callers to avoid + /// expensive computation of log message arguments if the message would be + /// discarded anyway. + fn enabled(&self, metadata: &LogMetadata) -> bool; + + /// Logs the `LogRecord`. + /// + /// Note that `enabled` is *not* necessarily called before this method. + /// Implementations of `log` should perform all necessary filtering + /// internally. + fn log(&self, record: &LogRecord); +} + +/// The location of a log message. +/// +/// # Warning +/// +/// The fields of this struct are public so that they may be initialized by the +/// `log!` macro. They are subject to change at any time and should never be +/// accessed directly. +#[derive(Copy, Clone, Debug)] +pub struct LogLocation { + #[doc(hidden)] + pub __module_path: &'static str, + #[doc(hidden)] + pub __file: &'static str, + #[doc(hidden)] + pub __line: u32, +} + +impl LogLocation { + /// The module path of the message. + pub fn module_path(&self) -> &str { + self.__module_path + } + + /// The source file containing the message. + pub fn file(&self) -> &str { + self.__file + } + + /// The line containing the message. + pub fn line(&self) -> u32 { + self.__line + } +} + +/// A token providing read and write access to the global maximum log level +/// filter. +/// +/// The maximum log level is used as an optimization to avoid evaluating log +/// messages that will be ignored by the logger. Any message with a level +/// higher than the maximum log level filter will be ignored. A logger should +/// make sure to keep the maximum log level filter in sync with its current +/// configuration. +#[allow(missing_copy_implementations)] +pub struct MaxLogLevelFilter(()); + +impl fmt::Debug for MaxLogLevelFilter { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "MaxLogLevelFilter") + } +} + +impl MaxLogLevelFilter { + /// Gets the current maximum log level filter. + pub fn get(&self) -> LogLevelFilter { + max_log_level() + } + + /// Sets the maximum log level. + pub fn set(&self, level: LogLevelFilter) { + MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst) + } +} + +/// Returns the current maximum log level. +/// +/// The `log!`, `error!`, `warn!`, `info!`, `debug!`, and `trace!` macros check +/// this value and discard any message logged at a higher level. The maximum +/// log level is set by the `MaxLogLevel` token passed to loggers. +#[inline(always)] +pub fn max_log_level() -> LogLevelFilter { + unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) } +} + +/// Sets the global logger. +/// +/// The `make_logger` closure is passed a `MaxLogLevel` object, which the +/// logger should use to keep the global maximum log level in sync with the +/// highest log level that the logger will not ignore. +/// +/// This function may only be called once in the lifetime of a program. Any log +/// events that occur before the call to `set_logger` completes will be +/// ignored. +/// +/// This function does not typically need to be called manually. Logger +/// implementations should provide an initialization method that calls +/// `set_logger` internally. +pub fn set_logger(make_logger: M) -> Result<(), SetLoggerError> + where M: FnOnce(MaxLogLevelFilter) -> Box { + if LOGGER.compare_and_swap(UNINITIALIZED, INITIALIZING, + Ordering::SeqCst) != UNINITIALIZED { + return Err(SetLoggerError(())); + } + + let logger = Box::new(make_logger(MaxLogLevelFilter(()))); + let logger = unsafe { mem::transmute::>, usize>(logger) }; + LOGGER.store(logger, Ordering::SeqCst); + + unsafe { + assert_eq!(libc::atexit(shutdown), 0); + } + return Ok(()); + + extern fn shutdown() { + // Set to INITIALIZING to prevent re-initialization after + let logger = LOGGER.swap(INITIALIZING, Ordering::SeqCst); + + while REFCOUNT.load(Ordering::SeqCst) != 0 { + // FIXME add a sleep here when it doesn't involve timers + } + + unsafe { mem::transmute::>>(logger); } + } +} + +/// The type returned by `set_logger` if `set_logger` has already been called. +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub struct SetLoggerError(()); + +impl fmt::Display for SetLoggerError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "attempted to set a logger after the logging system \ + was already initialized") + } +} + +impl error::Error for SetLoggerError { + fn description(&self) -> &str { "set_logger() called multiple times" } +} + +struct LoggerGuard(usize); + +impl Drop for LoggerGuard { + fn drop(&mut self) { + REFCOUNT.fetch_sub(1, Ordering::SeqCst); + } +} + +impl Deref for LoggerGuard { + type Target = Box; + + fn deref(&self) -> &Box { + unsafe { mem::transmute(self.0) } + } +} + +fn logger() -> Option { + REFCOUNT.fetch_add(1, Ordering::SeqCst); + let logger = LOGGER.load(Ordering::SeqCst); + if logger == UNINITIALIZED || logger == INITIALIZING { + REFCOUNT.fetch_sub(1, Ordering::SeqCst); + None + } else { + Some(LoggerGuard(logger)) + } +} + +// WARNING +// This is not considered part of the crate's public API. It is subject to +// change at any time. +#[doc(hidden)] +pub fn __enabled(level: LogLevel, target: &str) -> bool { + if let Some(logger) = logger() { + logger.enabled(&LogMetadata { level: level, target: target }) + } else { + false + } +} + +// WARNING +// This is not considered part of the crate's public API. It is subject to +// change at any time. +#[doc(hidden)] +pub fn __log(level: LogLevel, target: &str, loc: &LogLocation, + args: fmt::Arguments) { + if let Some(logger) = logger() { + let record = LogRecord { + metadata: LogMetadata { + level: level, + target: target, + }, + location: loc, + args: args + }; + logger.log(&record) + } +} + +#[cfg(test)] +mod tests { + use std::error::Error; + use super::{LogLevel, LogLevelFilter, SetLoggerError}; + + #[test] + fn test_loglevelfilter_from_str() { + let tests = [ + ("off", Ok(LogLevelFilter::Off)), + ("error", Ok(LogLevelFilter::Error)), + ("warn", Ok(LogLevelFilter::Warn)), + ("info", Ok(LogLevelFilter::Info)), + ("debug", Ok(LogLevelFilter::Debug)), + ("trace", Ok(LogLevelFilter::Trace)), + ("OFF", Ok(LogLevelFilter::Off)), + ("ERROR", Ok(LogLevelFilter::Error)), + ("WARN", Ok(LogLevelFilter::Warn)), + ("INFO", Ok(LogLevelFilter::Info)), + ("DEBUG", Ok(LogLevelFilter::Debug)), + ("TRACE", Ok(LogLevelFilter::Trace)), + ("asdf", Err(())), + ]; + for &(s, ref expected) in &tests { + assert_eq!(expected, &s.parse()); + } + } + + #[test] + fn test_loglevel_from_str() { + let tests = [ + ("OFF", Err(())), + ("error", Ok(LogLevel::Error)), + ("warn", Ok(LogLevel::Warn)), + ("info", Ok(LogLevel::Info)), + ("debug", Ok(LogLevel::Debug)), + ("trace", Ok(LogLevel::Trace)), + ("ERROR", Ok(LogLevel::Error)), + ("WARN", Ok(LogLevel::Warn)), + ("INFO", Ok(LogLevel::Info)), + ("DEBUG", Ok(LogLevel::Debug)), + ("TRACE", Ok(LogLevel::Trace)), + ("asdf", Err(())), + ]; + for &(s, ref expected) in &tests { + assert_eq!(expected, &s.parse()); + } + } + + #[test] + fn test_loglevel_show() { + assert_eq!("INFO", LogLevel::Info.to_string()); + assert_eq!("ERROR", LogLevel::Error.to_string()); + } + + #[test] + fn test_loglevelfilter_show() { + assert_eq!("OFF", LogLevelFilter::Off.to_string()); + assert_eq!("ERROR", LogLevelFilter::Error.to_string()); + } + + #[test] + fn test_cross_cmp() { + assert!(LogLevel::Debug > LogLevelFilter::Error); + assert!(LogLevelFilter::Warn < LogLevel::Trace); + assert!(LogLevelFilter::Off < LogLevel::Error); + } + + #[test] + fn test_cross_eq() { + assert!(LogLevel::Error == LogLevelFilter::Error); + assert!(LogLevelFilter::Off != LogLevel::Error); + assert!(LogLevel::Trace == LogLevelFilter::Trace); + } + + #[test] + fn test_to_log_level() { + assert_eq!(Some(LogLevel::Error), LogLevelFilter::Error.to_log_level()); + assert_eq!(None, LogLevelFilter::Off.to_log_level()); + assert_eq!(Some(LogLevel::Debug), LogLevelFilter::Debug.to_log_level()); + } + + #[test] + fn test_to_log_level_filter() { + assert_eq!(LogLevelFilter::Error, LogLevel::Error.to_log_level_filter()); + assert_eq!(LogLevelFilter::Trace, LogLevel::Trace.to_log_level_filter()); + } + + #[test] + fn test_error_trait() { + let e = SetLoggerError(()); + assert_eq!(e.description(), "set_logger() called multiple times"); + } +} diff --git a/deps/log-0.3.1/src/macros.rs b/deps/log-0.3.1/src/macros.rs new file mode 100644 index 000000000..e2f372f1a --- /dev/null +++ b/deps/log-0.3.1/src/macros.rs @@ -0,0 +1,145 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +/// The standard logging macro. +/// +/// This macro will generically log with the specified `LogLevel` and `format!` +/// based argument list. +/// +/// The `log_level` cfg can be used to statically disable logging at various +/// levels. +#[macro_export] +macro_rules! log { + (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({ + static LOC: $crate::LogLocation = $crate::LogLocation { + __line: line!(), + __file: file!(), + __module_path: module_path!(), + }; + let lvl = $lvl; + if !cfg!(log_level = "off") && + (lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) && + (lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) && + (lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) && + (lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) && + lvl <= $crate::max_log_level() { + $crate::__log(lvl, $target, &LOC, format_args!($($arg)+)) + } + }); + ($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+)) +} + +/// Logs a message at the error level. +/// +/// Logging at this level is disabled if the `log_level = "off"` cfg is +/// present. +#[macro_export] +macro_rules! error { + (target: $target:expr, $($arg:tt)*) => ( + log!(target: $target, $crate::LogLevel::Error, $($arg)*); + ); + ($($arg:tt)*) => ( + log!($crate::LogLevel::Error, $($arg)*); + ) +} + +/// Logs a message at the warn level. +/// +/// Logging at this level is disabled if any of the following cfgs are present: +/// `log_level = "off"` or `log_level = "error"`. +#[macro_export] +macro_rules! warn { + (target: $target:expr, $($arg:tt)*) => ( + log!(target: $target, $crate::LogLevel::Warn, $($arg)*); + ); + ($($arg:tt)*) => ( + log!($crate::LogLevel::Warn, $($arg)*); + ) +} + +/// Logs a message at the info level. +/// +/// Logging at this level is disabled if any of the following cfgs are present: +/// `log_level = "off"`, `log_level = "error"`, or +/// `log_level = "warn"`. +#[macro_export] +macro_rules! info { + (target: $target:expr, $($arg:tt)*) => ( + log!(target: $target, $crate::LogLevel::Info, $($arg)*); + ); + ($($arg:tt)*) => ( + log!($crate::LogLevel::Info, $($arg)*); + ) +} + +/// Logs a message at the debug level. +/// +/// Logging at this level is disabled if any of the following cfgs are present: +/// `log_level = "off"`, `log_level = "error"`, `log_level = "warn"`, +/// or `log_level = "info"`. +#[macro_export] +macro_rules! debug { + (target: $target:expr, $($arg:tt)*) => ( + log!(target: $target, $crate::LogLevel::Debug, $($arg)*); + ); + ($($arg:tt)*) => ( + log!($crate::LogLevel::Debug, $($arg)*); + ) +} + +/// Logs a message at the trace level. +/// +/// Logging at this level is disabled if any of the following cfgs are present: +/// `log_level = "off"`, `log_level = "error"`, `log_level = "warn"`, +/// `log_level = "info"`, or `log_level = "debug"`. +#[macro_export] +macro_rules! trace { + (target: $target:expr, $($arg:tt)*) => ( + log!(target: $target, $crate::LogLevel::Trace, $($arg)*); + ); + ($($arg:tt)*) => ( + log!($crate::LogLevel::Trace, $($arg)*); + ) +} + +/// Determines if a message logged at the specified level in that module will +/// be logged. +/// +/// This can be used to avoid expensive computation of log message arguments if +/// the message would be ignored anyway. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] +/// # extern crate log; +/// use log::LogLevel::Debug; +/// +/// # fn foo() { +/// if log_enabled!(Debug) { +/// debug!("expensive debug data: {}", expensive_call()); +/// } +/// # } +/// # fn expensive_call() -> u32 { 0 } +/// # fn main() {} +/// ``` +#[macro_export] +macro_rules! log_enabled { + (target: $target:expr, $lvl:expr) => ({ + let lvl = $lvl; + !cfg!(log_level = "off") && + (lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) && + (lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) && + (lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) && + (lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) && + lvl <= $crate::max_log_level() && + $crate::__enabled(lvl, $target) + }); + ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl)) +} diff --git a/deps/log-0.3.1/tests/filters.rs b/deps/log-0.3.1/tests/filters.rs new file mode 100644 index 000000000..75ea52829 --- /dev/null +++ b/deps/log-0.3.1/tests/filters.rs @@ -0,0 +1,64 @@ +#[macro_use] extern crate log; + +use std::sync::{Arc, Mutex}; +use log::{LogLevel, set_logger, LogLevelFilter, Log, LogRecord, LogMetadata}; +use log::MaxLogLevelFilter; + +struct State { + last_log: Mutex>, + filter: MaxLogLevelFilter, +} + +impl Log for Arc { + fn enabled(&self, _: &LogMetadata) -> bool { + true + } + + fn log(&self, record: &LogRecord) { + *self.last_log.lock().unwrap() = Some(record.level()); + } +} + +fn main() { + let mut a = None; + set_logger(|max| { + let me = Arc::new(State { + last_log: Mutex::new(None), + filter: max, + }); + a = Some(me.clone()); + Box::new(me) + }).unwrap(); + let a = a.unwrap(); + + test(&a, LogLevelFilter::Off); + test(&a, LogLevelFilter::Error); + test(&a, LogLevelFilter::Warn); + test(&a, LogLevelFilter::Info); + test(&a, LogLevelFilter::Debug); + test(&a, LogLevelFilter::Trace); +} + +fn test(a: &State, filter: LogLevelFilter) { + a.filter.set(filter); + error!(""); + last(&a, t(LogLevel::Error, filter)); + warn!(""); + last(&a, t(LogLevel::Warn, filter)); + info!(""); + last(&a, t(LogLevel::Info, filter)); + debug!(""); + last(&a, t(LogLevel::Debug, filter)); + trace!(""); + last(&a, t(LogLevel::Trace, filter)); + + fn t(lvl: LogLevel, filter: LogLevelFilter) -> Option { + if lvl <= filter {Some(lvl)} else {None} + } +} + +fn last(state: &State, expected: Option) { + let mut lvl = state.last_log.lock().unwrap(); + assert_eq!(*lvl, expected); + *lvl = None; +} diff --git a/deps/matches-0.1.2/Cargo.toml b/deps/matches-0.1.2/Cargo.toml new file mode 100644 index 000000000..124ee8af1 --- /dev/null +++ b/deps/matches-0.1.2/Cargo.toml @@ -0,0 +1,14 @@ +[package] + +name = "matches" +version = "0.1.2" +authors = ["Simon Sapin "] +license = "MIT" +repository = "https://github.com/SimonSapin/rust-std-candidates" +description = "A macro to evaluate, as a boolean, whether an expression matches a pattern." + + +[lib] +name = "matches" +path = "lib.rs" +doctest = false diff --git a/deps/matches-0.1.2/lib.rs b/deps/matches-0.1.2/lib.rs new file mode 100644 index 000000000..09586095e --- /dev/null +++ b/deps/matches-0.1.2/lib.rs @@ -0,0 +1,28 @@ +#[macro_export] +macro_rules! matches { + ($expression: expr, $($pattern:tt)+) => { + _tt_as_expr_hack! { + match $expression { + $($pattern)+ => true, + _ => false + } + } + } +} + + +/// Work around "error: unexpected token: `an interpolated tt`", whatever that means. +#[macro_export] +macro_rules! _tt_as_expr_hack( + ($value:expr) => ($value) +); + + +#[test] +fn it_works() { + let foo = Some("-12"); + assert!(matches!(foo, Some(bar) if + matches!(bar.as_bytes()[0], b'+' | b'-') && + matches!(bar.as_bytes()[1], b'0'...b'9') + )); +} diff --git a/deps/memchr-0.1.3/.gitignore b/deps/memchr-0.1.3/.gitignore new file mode 100644 index 000000000..d24edbd87 --- /dev/null +++ b/deps/memchr-0.1.3/.gitignore @@ -0,0 +1,9 @@ +.*.swp +doc +tags +examples/ss10pusa.csv +build +target +Cargo.lock +scratch* +bench_large/huge diff --git a/deps/memchr-0.1.3/.travis.yml b/deps/memchr-0.1.3/.travis.yml new file mode 100644 index 000000000..faea53eef --- /dev/null +++ b/deps/memchr-0.1.3/.travis.yml @@ -0,0 +1,12 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc + - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then + cargo bench --verbose; + fi diff --git a/deps/memchr-0.1.3/COPYING b/deps/memchr-0.1.3/COPYING new file mode 100644 index 000000000..bb9c20a09 --- /dev/null +++ b/deps/memchr-0.1.3/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/deps/memchr-0.1.3/Cargo.toml b/deps/memchr-0.1.3/Cargo.toml new file mode 100644 index 000000000..f5f6ec217 --- /dev/null +++ b/deps/memchr-0.1.3/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "memchr" +version = "0.1.3" #:version +authors = ["Andrew Gallant "] +description = "Safe interface to memchr." +documentation = "http://burntsushi.net/rustdoc/memchr/" +homepage = "https://github.com/BurntSushi/rust-memchr" +repository = "https://github.com/BurntSushi/rust-memchr" +readme = "README.md" +keywords = ["memchr", "char", "scan", "strchr", "string"] +license = "Unlicense/MIT" + +[lib] +name = "memchr" + +[dependencies] +libc = "0.1.*" + +[dev-dependencies] +quickcheck = "0.2.*" diff --git a/deps/memchr-0.1.3/LICENSE-MIT b/deps/memchr-0.1.3/LICENSE-MIT new file mode 100644 index 000000000..3b0a5dc09 --- /dev/null +++ b/deps/memchr-0.1.3/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/memchr-0.1.3/Makefile b/deps/memchr-0.1.3/Makefile new file mode 100644 index 000000000..9f956f4c4 --- /dev/null +++ b/deps/memchr-0.1.3/Makefile @@ -0,0 +1,14 @@ +all: + echo Nothing to do... + +ctags: + ctags --recurse --options=ctags.rust --languages=Rust + +docs: + cargo doc + in-dir ./target/doc fix-perms + rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/ + +push: + git push origin master + git push github master diff --git a/deps/memchr-0.1.3/README.md b/deps/memchr-0.1.3/README.md new file mode 100644 index 000000000..1b1a7ef8e --- /dev/null +++ b/deps/memchr-0.1.3/README.md @@ -0,0 +1,23 @@ +This crate provides a single function, `memchr`, which exposes a safe interface +to the corresponding function in `libc`. + +[![Build status](https://api.travis-ci.org/BurntSushi/rust-memchr.png)](https://travis-ci.org/BurntSushi/rust-memchr) +[![](http://meritbadge.herokuapp.com/memchr)](https://crates.io/crates/memchr) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +[http://burntsushi.net/rustdoc/memchr/](http://burntsushi.net/rustdoc/memchr/). + + +### Performance + +On my system (Linux/amd64), `memchr` is about an order of magnitude faster than +the more idiomatic `haystack.iter().position(|&b| b == needle)`: + +``` +test iterator ... bench: 5,301 ns/iter (+/- 2,745) +test libc_memchr ... bench: 203 ns/iter (+/- 17) +``` diff --git a/deps/memchr-0.1.3/UNLICENSE b/deps/memchr-0.1.3/UNLICENSE new file mode 100644 index 000000000..68a49daad --- /dev/null +++ b/deps/memchr-0.1.3/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/deps/memchr-0.1.3/benches/bench.rs b/deps/memchr-0.1.3/benches/bench.rs new file mode 100644 index 000000000..cd93ae482 --- /dev/null +++ b/deps/memchr-0.1.3/benches/bench.rs @@ -0,0 +1,26 @@ +#![feature(test)] + +extern crate memchr; +extern crate test; + +use std::iter; + +fn bench_data() -> Vec { iter::repeat(b'z').take(10000).collect() } + +#[bench] +fn iterator(b: &mut test::Bencher) { + let haystack = bench_data(); + let needle = b'a'; + b.iter(|| { + assert!(haystack.iter().position(|&b| b == needle).is_none()); + }); +} + +#[bench] +fn libc_memchr(b: &mut test::Bencher) { + let haystack = bench_data(); + let needle = b'a'; + b.iter(|| { + assert!(memchr::memchr(needle, &haystack).is_none()); + }); +} diff --git a/deps/memchr-0.1.3/ctags.rust b/deps/memchr-0.1.3/ctags.rust new file mode 100644 index 000000000..b42edf757 --- /dev/null +++ b/deps/memchr-0.1.3/ctags.rust @@ -0,0 +1,11 @@ +--langdef=Rust +--langmap=Rust:.rs +--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/ +--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ diff --git a/deps/memchr-0.1.3/session.vim b/deps/memchr-0.1.3/session.vim new file mode 100644 index 000000000..213c95660 --- /dev/null +++ b/deps/memchr-0.1.3/session.vim @@ -0,0 +1 @@ +au BufWritePost *.rs silent!make ctags > /dev/null 2>&1 diff --git a/deps/memchr-0.1.3/src/lib.rs b/deps/memchr-0.1.3/src/lib.rs new file mode 100644 index 000000000..2668c2a64 --- /dev/null +++ b/deps/memchr-0.1.3/src/lib.rs @@ -0,0 +1,95 @@ +/*! +This crate defines a single function, `memchr`, which exposes a safe interface +to the corresponding function in `libc`. +*/ + +#![deny(missing_docs)] + +extern crate libc; + +use libc::funcs::c95::string; +use libc::types::common::c95::c_void; +use libc::types::os::arch::c95::{c_int, size_t}; + +/// A safe interface to `memchr`. +/// +/// Returns the index corresponding to the first occurrence of `needle` in +/// `haystack`, or `None` if one is not found. +/// +/// memchr reduces to super-optimized machine code at around an order of +/// magnitude faster than `haystack.iter().position(|&b| b == needle)`. +/// (See benchmarks.) +/// +/// # Example +/// +/// This shows how to find the first position of a byte in a byte string. +/// +/// ```rust +/// use memchr::memchr; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memchr(b'k', haystack), Some(8)); +/// ``` +pub fn memchr(needle: u8, haystack: &[u8]) -> Option { + let p = unsafe { + string::memchr( + haystack.as_ptr() as *const c_void, + needle as c_int, + haystack.len() as size_t) + }; + if p.is_null() { + None + } else { + Some(p as usize - (haystack.as_ptr() as usize)) + } +} + +#[cfg(test)] +mod tests { + extern crate quickcheck; + + use super::memchr; + + #[test] + fn matches_one() { + assert_eq!(Some(0), memchr(b'a', b"a")); + } + + #[test] + fn matches_begin() { + assert_eq!(Some(0), memchr(b'a', b"aaaa")); + } + + #[test] + fn matches_end() { + assert_eq!(Some(4), memchr(b'z', b"aaaaz")); + } + + #[test] + fn matches_nul() { + assert_eq!(Some(4), memchr(b'\x00', b"aaaa\x00")); + } + + #[test] + fn matches_past_nul() { + assert_eq!(Some(5), memchr(b'z', b"aaaa\x00z")); + } + + #[test] + fn no_match_empty() { + assert_eq!(None, memchr(b'a', b"")); + } + + #[test] + fn no_match() { + assert_eq!(None, memchr(b'a', b"xyz")); + } + + #[test] + fn qc_never_fail() { + fn prop(needle: u8, haystack: Vec) -> bool { + memchr(needle, &haystack); true + } + quickcheck::quickcheck(prop as fn(u8, Vec) -> bool); + } +} diff --git a/deps/miniz-sys-0.1.5/Cargo.toml b/deps/miniz-sys-0.1.5/Cargo.toml new file mode 100644 index 000000000..f68115b02 --- /dev/null +++ b/deps/miniz-sys-0.1.5/Cargo.toml @@ -0,0 +1,22 @@ +[package] + +name = "miniz-sys" +version = "0.1.5" +authors = ["Alex Crichton "] +links = "miniz" +build = "build.rs" +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/flate2-rs" +description = """ +Bindings to the miniz.c library. +""" + +[lib] +name = "miniz_sys" +path = "lib.rs" + +[dependencies] +libc = "0.1" + +[build-dependencies] +gcc = "0.3" diff --git a/deps/miniz-sys-0.1.5/build.rs b/deps/miniz-sys-0.1.5/build.rs new file mode 100644 index 000000000..2038d86a5 --- /dev/null +++ b/deps/miniz-sys-0.1.5/build.rs @@ -0,0 +1,8 @@ +extern crate gcc; + +use std::env; + +fn main() { + gcc::compile_library("libminiz.a", &["miniz.c"]); + println!("cargo:root={}", env::var("OUT_DIR").unwrap()); +} diff --git a/deps/miniz-sys-0.1.5/lib.rs b/deps/miniz-sys-0.1.5/lib.rs new file mode 100644 index 000000000..13e2678f8 --- /dev/null +++ b/deps/miniz-sys-0.1.5/lib.rs @@ -0,0 +1,72 @@ +#![doc(html_root_url = "http://alexcrichton.com/flate2-rs")] +#![allow(bad_style)] + +extern crate libc; + +pub const MZ_NO_FLUSH: libc::c_int = 0; +pub const MZ_SYNC_FLUSH: libc::c_int = 2; +pub const MZ_FINISH: libc::c_int = 4; + +pub const MZ_OK: libc::c_int = 0; +pub const MZ_STREAM_END: libc::c_int = 1; +pub const MZ_NEED_DICT: libc::c_int = 2; +pub const MZ_ERRNO: libc::c_int = -1; +pub const MZ_STREAM_ERROR: libc::c_int = -2; +pub const MZ_DATA_ERROR: libc::c_int = -3; +pub const MZ_MEM_ERROR: libc::c_int = -4; +pub const MZ_BUF_ERROR: libc::c_int = -5; +pub const MZ_VERSION_ERROR: libc::c_int = -6; +pub const MZ_PARAM_ERROR: libc::c_int = -10000; + +pub const MZ_DEFLATED: libc::c_int = 8; +pub const MZ_DEFAULT_WINDOW_BITS: libc::c_int = 15; +pub const MZ_DEFAULT_STRATEGY: libc::c_int = 0; + +#[repr(C)] +pub struct mz_stream { + pub next_in: *const u8, + pub avail_in: libc::c_uint, + pub total_in: libc::c_ulong, + + pub next_out: *mut u8, + pub avail_out: libc::c_uint, + pub total_out: libc::c_ulong, + + pub msg: *const libc::c_char, + pub state: *mut mz_internal_state, + + pub zalloc: Option, + pub zfree: Option, + pub opaque: *mut libc::c_void, + + pub data_type: libc::c_int, + pub adler: libc::c_ulong, + pub reserved: libc::c_ulong, +} + +pub enum mz_internal_state {} + +pub type mz_alloc_func = extern fn(*mut libc::c_void, + libc::size_t, + libc::size_t) -> *mut libc::c_void; +pub type mz_free_func = extern fn(*mut libc::c_void, *mut libc::c_void); + +extern { + pub fn mz_deflateInit2(stream: *mut mz_stream, + level: libc::c_int, + method: libc::c_int, + window_bits: libc::c_int, + mem_level: libc::c_int, + strategy: libc::c_int) -> libc::c_int; + pub fn mz_deflate(stream: *mut mz_stream, flush: libc::c_int) -> libc::c_int; + pub fn mz_deflateEnd(stream: *mut mz_stream) -> libc::c_int; + + pub fn mz_inflateInit2(stream: *mut mz_stream, + window_bits: libc::c_int) -> libc::c_int; + pub fn mz_inflate(stream: *mut mz_stream, flush: libc::c_int) -> libc::c_int; + pub fn mz_inflateEnd(stream: *mut mz_stream) -> libc::c_int; + + pub fn mz_crc32(crc: libc::c_ulong, ptr: *const u8, + len: libc::size_t) -> libc::c_ulong; +} + diff --git a/deps/miniz-sys-0.1.5/miniz.c b/deps/miniz-sys-0.1.5/miniz.c new file mode 100644 index 000000000..f1a662195 --- /dev/null +++ b/deps/miniz-sys-0.1.5/miniz.c @@ -0,0 +1,4986 @@ +/* miniz.c v1.16 beta r1 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing + See "unlicense" statement at the end of this file. + Rich Geldreich , last updated Oct. 13, 2013 + Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt + + Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define + MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). + + * Change History + 10/19/13 v1.16 beta r1 - Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. + - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. + I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm + going to mark this release as beta for a few weeks and continue testing it at work/home on various things. + - The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). + This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and + would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). + So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. + - The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the + caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. + This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output + (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return + TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" + failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios. + - Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp. + 10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!): + - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug + would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() + (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). + - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size + - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. + Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). + - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes + - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed + - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. + - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti + - Merged MZ_FORCEINLINE fix from hdeanclark + - Fix include before config #ifdef, thanks emil.brink + - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can + set it to 1 for real-time compression). + - Merged in some compiler fixes from paulharris's github repro. + - Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3. + - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. + - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. + - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled + - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch + 5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include (thanks fermtect). + 5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. + - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. + - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. + - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly + "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). + - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. + - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. + - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. + - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) + - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). + 4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. + level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson for the feedback/bug report. + 5/28/11 v1.11 - Added statement from unlicense.org + 5/27/11 v1.10 - Substantial compressor optimizations: + - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a + - Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). + - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. + - Refactored the compression code for better readability and maintainability. + - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large + drop in throughput on some files). + 5/15/11 v1.09 - Initial stable release. + + * Low-level Deflate/Inflate implementation notes: + + Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or + greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses + approximately as well as zlib. + + Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function + coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory + block large enough to hold the entire file. + + The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation. + + * zlib-style API notes: + + miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in + zlib replacement in many apps: + The z_stream struct, optional memory allocation callbacks + deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound + inflateInit/inflateInit2/inflate/inflateEnd + compress, compress2, compressBound, uncompress + CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines. + Supports raw deflate streams or standard zlib streams with adler-32 checking. + + Limitations: + The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries. + I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but + there are no guarantees that miniz.c pulls this off perfectly. + + * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by + Alex Evans. Supports 1-4 bytes/pixel images. + + * ZIP archive API notes: + + The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to + get the job done with minimal fuss. There are simple API's to retrieve file information, read files from + existing archives, create new archives, append new files to existing archives, or clone archive data from + one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h), + or you can specify custom file read/write callbacks. + + - Archive reading: Just call this function to read a single file from a disk archive: + + void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, + size_t *pSize, mz_uint zip_flags); + + For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central + directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files. + + - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file: + + int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); + + The locate operation can optionally check file comments too, which (as one example) can be used to identify + multiple versions of the same file in an archive. This function uses a simple linear search through the central + directory, so it's not very fast. + + Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and + retrieve detailed info on each file by calling mz_zip_reader_file_stat(). + + - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data + to disk and builds an exact image of the central directory in memory. The central directory image is written + all at once at the end of the archive file when the archive is finalized. + + The archive writer can optionally align each file's local header and file data to any power of 2 alignment, + which can be useful when the archive will be read from optical media. Also, the writer supports placing + arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still + readable by any ZIP tool. + + - Archive appending: The simple way to add a single file to an archive is to call this function: + + mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, + const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); + + The archive will be created if it doesn't already exist, otherwise it'll be appended to. + Note the appending is done in-place and is not an atomic operation, so if something goes wrong + during the operation it's possible the archive could be left without a central directory (although the local + file headers and file data will be fine, so the archive will be recoverable). + + For more complex archive modification scenarios: + 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to + preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the + compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and + you're done. This is safe but requires a bunch of temporary disk space or heap memory. + + 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(), + append new files as needed, then finalize the archive which will write an updated central directory to the + original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a + possibility that the archive's central directory could be lost with this method if anything goes wrong, though. + + - ZIP archive support limitations: + No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files. + Requires streams capable of seeking. + + * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the + below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it. + + * Important: For best perf. be sure to customize the below macros for your target platform: + #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 + #define MINIZ_LITTLE_ENDIAN 1 + #define MINIZ_HAS_64BIT_REGISTERS 1 + + * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz + uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files + (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). +*/ + +#ifndef MINIZ_HEADER_INCLUDED +#define MINIZ_HEADER_INCLUDED + +#include + +// Defines to completely disable specific portions of miniz.c: +// If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. + +// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. +//#define MINIZ_NO_STDIO + +// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or +// get/set file times, and the C run-time funcs that get/set times won't be called. +// The current downside is the times written to your archives will be from 1979. +//#define MINIZ_NO_TIME + +// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. +//#define MINIZ_NO_ARCHIVE_APIS + +// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's. +//#define MINIZ_NO_ARCHIVE_WRITING_APIS + +// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. +//#define MINIZ_NO_ZLIB_APIS + +// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. +//#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES + +// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. +// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc +// callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user +// functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. +//#define MINIZ_NO_MALLOC + +#if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) + // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux + #define MINIZ_NO_TIME +#endif + +#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) + #include +#endif + +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) +// MINIZ_X86_OR_X64_CPU is only used to help set the below macros. +#define MINIZ_X86_OR_X64_CPU 1 +#endif + +#if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU +// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. +#define MINIZ_LITTLE_ENDIAN 1 +#endif + +#if MINIZ_X86_OR_X64_CPU +// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. +#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 +#endif + +#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) +// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). +#define MINIZ_HAS_64BIT_REGISTERS 1 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// ------------------- zlib-style API Definitions. + +// For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! +typedef unsigned long mz_ulong; + +// mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. +void mz_free(void *p); + +#define MZ_ADLER32_INIT (1) +// mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. +mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); + +#define MZ_CRC32_INIT (0) +// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. +mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); + +// Compression strategies. +enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 }; + +// Method +#define MZ_DEFLATED 8 + +#ifndef MINIZ_NO_ZLIB_APIS + +// Heap allocation callbacks. +// Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. +typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); +typedef void (*mz_free_func)(void *opaque, void *address); +typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); + +// TODO: I can't encode "1.16" here, argh +#define MZ_VERSION "9.1.15" +#define MZ_VERNUM 0x91F0 +#define MZ_VER_MAJOR 9 +#define MZ_VER_MINOR 1 +#define MZ_VER_REVISION 15 +#define MZ_VER_SUBREVISION 0 + +// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). +enum { MZ_NO_FLUSH = 0, MZ_PARTIAL_FLUSH = 1, MZ_SYNC_FLUSH = 2, MZ_FULL_FLUSH = 3, MZ_FINISH = 4, MZ_BLOCK = 5 }; + +// Return status codes. MZ_PARAM_ERROR is non-standard. +enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 }; + +// Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. +enum { MZ_NO_COMPRESSION = 0, MZ_BEST_SPEED = 1, MZ_BEST_COMPRESSION = 9, MZ_UBER_COMPRESSION = 10, MZ_DEFAULT_LEVEL = 6, MZ_DEFAULT_COMPRESSION = -1 }; + +// Window bits +#define MZ_DEFAULT_WINDOW_BITS 15 + +struct mz_internal_state; + +// Compression/decompression stream struct. +typedef struct mz_stream_s +{ + const unsigned char *next_in; // pointer to next byte to read + unsigned int avail_in; // number of bytes available at next_in + mz_ulong total_in; // total number of bytes consumed so far + + unsigned char *next_out; // pointer to next byte to write + unsigned int avail_out; // number of bytes that can be written to next_out + mz_ulong total_out; // total number of bytes produced so far + + char *msg; // error msg (unused) + struct mz_internal_state *state; // internal state, allocated by zalloc/zfree + + mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc) + mz_free_func zfree; // optional heap free function (defaults to free) + void *opaque; // heap alloc function user pointer + + int data_type; // data_type (unused) + mz_ulong adler; // adler32 of the source or uncompressed data + mz_ulong reserved; // not used +} mz_stream; + +typedef mz_stream *mz_streamp; + +// Returns the version string of miniz.c. +const char *mz_version(void); + +// mz_deflateInit() initializes a compressor with default options: +// Parameters: +// pStream must point to an initialized mz_stream struct. +// level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. +// level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. +// (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) +// Return values: +// MZ_OK on success. +// MZ_STREAM_ERROR if the stream is bogus. +// MZ_PARAM_ERROR if the input parameters are bogus. +// MZ_MEM_ERROR on out of memory. +int mz_deflateInit(mz_streamp pStream, int level); + +// mz_deflateInit2() is like mz_deflate(), except with more control: +// Additional parameters: +// method must be MZ_DEFLATED +// window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) +// mem_level must be between [1, 9] (it's checked but ignored by miniz.c) +int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); + +// Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). +int mz_deflateReset(mz_streamp pStream); + +// mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. +// Parameters: +// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. +// flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. +// Return values: +// MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). +// MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. +// MZ_STREAM_ERROR if the stream is bogus. +// MZ_PARAM_ERROR if one of the parameters is invalid. +// MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) +int mz_deflate(mz_streamp pStream, int flush); + +// mz_deflateEnd() deinitializes a compressor: +// Return values: +// MZ_OK on success. +// MZ_STREAM_ERROR if the stream is bogus. +int mz_deflateEnd(mz_streamp pStream); + +// mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. +mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); + +// Single-call compression functions mz_compress() and mz_compress2(): +// Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. +int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); +int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); + +// mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). +mz_ulong mz_compressBound(mz_ulong source_len); + +// Initializes a decompressor. +int mz_inflateInit(mz_streamp pStream); + +// mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: +// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). +int mz_inflateInit2(mz_streamp pStream, int window_bits); + +// Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. +// Parameters: +// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. +// flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. +// On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). +// MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. +// Return values: +// MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. +// MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. +// MZ_STREAM_ERROR if the stream is bogus. +// MZ_DATA_ERROR if the deflate stream is invalid. +// MZ_PARAM_ERROR if one of the parameters is invalid. +// MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again +// with more input data, or with more room in the output buffer (except when using single call decompression, described above). +int mz_inflate(mz_streamp pStream, int flush); + +// Deinitializes a decompressor. +int mz_inflateEnd(mz_streamp pStream); + +// Single-call decompression. +// Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. +int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); + +// Returns a string description of the specified error code, or NULL if the error code is invalid. +const char *mz_error(int err); + +// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. +// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. +#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES + typedef unsigned char Byte; + typedef unsigned int uInt; + typedef mz_ulong uLong; + typedef Byte Bytef; + typedef uInt uIntf; + typedef char charf; + typedef int intf; + typedef void *voidpf; + typedef uLong uLongf; + typedef void *voidp; + typedef void *const voidpc; + #define Z_NULL 0 + #define Z_NO_FLUSH MZ_NO_FLUSH + #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH + #define Z_SYNC_FLUSH MZ_SYNC_FLUSH + #define Z_FULL_FLUSH MZ_FULL_FLUSH + #define Z_FINISH MZ_FINISH + #define Z_BLOCK MZ_BLOCK + #define Z_OK MZ_OK + #define Z_STREAM_END MZ_STREAM_END + #define Z_NEED_DICT MZ_NEED_DICT + #define Z_ERRNO MZ_ERRNO + #define Z_STREAM_ERROR MZ_STREAM_ERROR + #define Z_DATA_ERROR MZ_DATA_ERROR + #define Z_MEM_ERROR MZ_MEM_ERROR + #define Z_BUF_ERROR MZ_BUF_ERROR + #define Z_VERSION_ERROR MZ_VERSION_ERROR + #define Z_PARAM_ERROR MZ_PARAM_ERROR + #define Z_NO_COMPRESSION MZ_NO_COMPRESSION + #define Z_BEST_SPEED MZ_BEST_SPEED + #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION + #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION + #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY + #define Z_FILTERED MZ_FILTERED + #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY + #define Z_RLE MZ_RLE + #define Z_FIXED MZ_FIXED + #define Z_DEFLATED MZ_DEFLATED + #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS + #define alloc_func mz_alloc_func + #define free_func mz_free_func + #define internal_state mz_internal_state + #define z_stream mz_stream + #define deflateInit mz_deflateInit + #define deflateInit2 mz_deflateInit2 + #define deflateReset mz_deflateReset + #define deflate mz_deflate + #define deflateEnd mz_deflateEnd + #define deflateBound mz_deflateBound + #define compress mz_compress + #define compress2 mz_compress2 + #define compressBound mz_compressBound + #define inflateInit mz_inflateInit + #define inflateInit2 mz_inflateInit2 + #define inflate mz_inflate + #define inflateEnd mz_inflateEnd + #define uncompress mz_uncompress + #define crc32 mz_crc32 + #define adler32 mz_adler32 + #define MAX_WBITS 15 + #define MAX_MEM_LEVEL 9 + #define zError mz_error + #define ZLIB_VERSION MZ_VERSION + #define ZLIB_VERNUM MZ_VERNUM + #define ZLIB_VER_MAJOR MZ_VER_MAJOR + #define ZLIB_VER_MINOR MZ_VER_MINOR + #define ZLIB_VER_REVISION MZ_VER_REVISION + #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION + #define zlibVersion mz_version + #define zlib_version mz_version() +#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES + +#endif // MINIZ_NO_ZLIB_APIS + +// ------------------- Types and macros + +typedef unsigned char mz_uint8; +typedef signed short mz_int16; +typedef unsigned short mz_uint16; +typedef unsigned int mz_uint32; +typedef unsigned int mz_uint; +typedef long long mz_int64; +typedef unsigned long long mz_uint64; +typedef int mz_bool; + +#define MZ_FALSE (0) +#define MZ_TRUE (1) + +// An attempt to work around MSVC's spammy "warning C4127: conditional expression is constant" message. +#ifdef _MSC_VER + #define MZ_MACRO_END while (0, 0) +#else + #define MZ_MACRO_END while (0) +#endif + +// ------------------- ZIP archive reading/writing + +#ifndef MINIZ_NO_ARCHIVE_APIS + +enum +{ + MZ_ZIP_MAX_IO_BUF_SIZE = 64*1024, + MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260, + MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256 +}; + +typedef struct +{ + mz_uint32 m_file_index; + mz_uint32 m_central_dir_ofs; + mz_uint16 m_version_made_by; + mz_uint16 m_version_needed; + mz_uint16 m_bit_flag; + mz_uint16 m_method; +#ifndef MINIZ_NO_TIME + time_t m_time; +#endif + mz_uint32 m_crc32; + mz_uint64 m_comp_size; + mz_uint64 m_uncomp_size; + mz_uint16 m_internal_attr; + mz_uint32 m_external_attr; + mz_uint64 m_local_header_ofs; + mz_uint32 m_comment_size; + char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; + char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; +} mz_zip_archive_file_stat; + +typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); +typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); + +struct mz_zip_internal_state_tag; +typedef struct mz_zip_internal_state_tag mz_zip_internal_state; + +typedef enum +{ + MZ_ZIP_MODE_INVALID = 0, + MZ_ZIP_MODE_READING = 1, + MZ_ZIP_MODE_WRITING = 2, + MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 +} mz_zip_mode; + +typedef struct mz_zip_archive_tag +{ + mz_uint64 m_archive_size; + mz_uint64 m_central_directory_file_ofs; + mz_uint m_total_files; + mz_zip_mode m_zip_mode; + + mz_uint m_file_offset_alignment; + + mz_alloc_func m_pAlloc; + mz_free_func m_pFree; + mz_realloc_func m_pRealloc; + void *m_pAlloc_opaque; + + mz_file_read_func m_pRead; + mz_file_write_func m_pWrite; + void *m_pIO_opaque; + + mz_zip_internal_state *m_pState; + +} mz_zip_archive; + +typedef enum +{ + MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, + MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, + MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, + MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800 +} mz_zip_flags; + +// ZIP archive reading + +// Inits a ZIP archive reader. +// These functions read and validate the archive's central directory. +mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags); +mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags); + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags); +#endif + +// Returns the total number of files in the archive. +mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); + +// Returns detailed information about an archive file entry. +mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat); + +// Determines if an archive file entry is a directory entry. +mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index); +mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index); + +// Retrieves the filename of an archive file entry. +// Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. +mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size); + +// Attempts to locates a file in the archive's central directory. +// Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH +// Returns -1 if the file cannot be found. +int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); + +// Extracts a archive file to a memory buffer using no memory allocation. +mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); +mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); + +// Extracts a archive file to a memory buffer. +mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags); +mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags); + +// Extracts a archive file to a dynamically allocated heap buffer. +void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags); +void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags); + +// Extracts a archive file using a callback function to output the file's data. +mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); +mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); + +#ifndef MINIZ_NO_STDIO +// Extracts a archive file to a disk file and sets its last accessed and modified times. +// This function only extracts files, not archive directory records. +mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags); +mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags); +#endif + +// Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. +mz_bool mz_zip_reader_end(mz_zip_archive *pZip); + +// ZIP archive writing + +#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +// Inits a ZIP archive writer. +mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); +mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); +#endif + +// Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. +// For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. +// For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). +// Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. +// Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before +// the archive is finalized the file's central directory will be hosed. +mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); + +// Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. +// To add a directory entry, call this method with an archive name ending in a forwardslash with empty buffer. +// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. +mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags); +mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); + +#ifndef MINIZ_NO_STDIO +// Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. +// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. +mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); +#endif + +// Adds a file to an archive by fully cloning the data from another archive. +// This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data, and comment fields. +mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index); + +// Finalizes the archive by writing the central directory records followed by the end of central directory record. +// After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). +// An archive must be manually finalized by calling this function for it to be valid. +mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); +mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize); + +// Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. +// Note for the archive to be valid, it must have been finalized before ending. +mz_bool mz_zip_writer_end(mz_zip_archive *pZip); + +// Misc. high-level helper functions: + +// mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. +// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. +mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); + +// Reads a single file from an archive into a heap block. +// Returns NULL on failure. +void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); + +#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +#endif // #ifndef MINIZ_NO_ARCHIVE_APIS + +// ------------------- Low-level Decompression API Definitions + +// Decompression flags used by tinfl_decompress(). +// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. +// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. +// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). +// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. +enum +{ + TINFL_FLAG_PARSE_ZLIB_HEADER = 1, + TINFL_FLAG_HAS_MORE_INPUT = 2, + TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, + TINFL_FLAG_COMPUTE_ADLER32 = 8 +}; + +// High level decompression functions: +// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). +// On entry: +// pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. +// On return: +// Function returns a pointer to the decompressed data, or NULL on failure. +// *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. +// The caller must call mz_free() on the returned block when it's no longer needed. +void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); + +// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. +// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. +#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) +size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); + +// tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. +// Returns 1 on success or 0 on failure. +typedef int (*tinfl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); +int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); + +struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; + +// Max size of LZ dictionary. +#define TINFL_LZ_DICT_SIZE 32768 + +// Return status. +typedef enum +{ + // This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data + // is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). + // If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. + TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4, + + // This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) + TINFL_STATUS_BAD_PARAM = -3, + + // This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. + TINFL_STATUS_ADLER32_MISMATCH = -2, + + // This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. + TINFL_STATUS_FAILED = -1, + + // Any status code less than TINFL_STATUS_DONE must indicate a failure. + + // This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and + // if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. + TINFL_STATUS_DONE = 0, + + // This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT + // flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to + // proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. + TINFL_STATUS_NEEDS_MORE_INPUT = 1, + + // This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. + // Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect + // (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible + // so I may need to add some code to address this. + TINFL_STATUS_HAS_MORE_OUTPUT = 2 + +} tinfl_status; + +// Initializes the decompressor to its initial state. +#define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END +#define tinfl_get_adler32(r) (r)->m_check_adler32 + +// Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. +// This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. +tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); + +// Internal/private bits follow. +enum +{ + TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19, + TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS +}; + +typedef struct +{ + mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; + mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; +} tinfl_huff_table; + +#if MINIZ_HAS_64BIT_REGISTERS + #define TINFL_USE_64BIT_BITBUF 1 +#endif + +#if TINFL_USE_64BIT_BITBUF + typedef mz_uint64 tinfl_bit_buf_t; + #define TINFL_BITBUF_SIZE (64) +#else + typedef mz_uint32 tinfl_bit_buf_t; + #define TINFL_BITBUF_SIZE (32) +#endif + +struct tinfl_decompressor_tag +{ + mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; + tinfl_bit_buf_t m_bit_buf; + size_t m_dist_from_out_buf_start; + tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; + mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; +}; + +// ------------------- Low-level Compression API Definitions + +// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). +#define TDEFL_LESS_MEMORY 0 + +// tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): +// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). +enum +{ + TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF +}; + +// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. +// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). +// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. +// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). +// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) +// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. +// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. +// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. +// The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). +enum +{ + TDEFL_WRITE_ZLIB_HEADER = 0x01000, + TDEFL_COMPUTE_ADLER32 = 0x02000, + TDEFL_GREEDY_PARSING_FLAG = 0x04000, + TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, + TDEFL_RLE_MATCHES = 0x10000, + TDEFL_FILTER_MATCHES = 0x20000, + TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, + TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 +}; + +// High level compression functions: +// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). +// On entry: +// pSrc_buf, src_buf_len: Pointer and size of source block to compress. +// flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. +// On return: +// Function returns a pointer to the compressed data, or NULL on failure. +// *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. +// The caller must free() the returned block when it's no longer needed. +void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); + +// tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. +// Returns 0 on failure. +size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); + +// Compresses an image to a compressed PNG file in memory. +// On entry: +// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. +// The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. +// level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL +// If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). +// On return: +// Function returns a pointer to the compressed data, or NULL on failure. +// *pLen_out will be set to the size of the PNG image file. +// The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. +void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip); +void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); + +// Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. +typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); + +// tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. +mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); + +enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 }; + +// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). +#if TDEFL_LESS_MEMORY +enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; +#else +enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; +#endif + +// The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. +typedef enum +{ + TDEFL_STATUS_BAD_PARAM = -2, + TDEFL_STATUS_PUT_BUF_FAILED = -1, + TDEFL_STATUS_OKAY = 0, + TDEFL_STATUS_DONE = 1, +} tdefl_status; + +// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums +typedef enum +{ + TDEFL_NO_FLUSH = 0, + TDEFL_SYNC_FLUSH = 2, + TDEFL_FULL_FLUSH = 3, + TDEFL_FINISH = 4 +} tdefl_flush; + +// tdefl's compression state structure. +typedef struct +{ + tdefl_put_buf_func_ptr m_pPut_buf_func; + void *m_pPut_buf_user; + mz_uint m_flags, m_max_probes[2]; + int m_greedy_parsing; + mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; + mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; + mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; + mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; + tdefl_status m_prev_return_status; + const void *m_pIn_buf; + void *m_pOut_buf; + size_t *m_pIn_buf_size, *m_pOut_buf_size; + tdefl_flush m_flush; + const mz_uint8 *m_pSrc; + size_t m_src_buf_left, m_out_buf_ofs; + mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; + mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; + mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; + mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; + mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; + mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; + mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; + mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; +} tdefl_compressor; + +// Initializes the compressor. +// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. +// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. +// If pBut_buf_func is NULL the user should always call the tdefl_compress() API. +// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) +tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); + +// Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. +tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush); + +// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. +// tdefl_compress_buffer() always consumes the entire input buffer. +tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush); + +tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); +mz_uint32 tdefl_get_adler32(tdefl_compressor *d); + +// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros. +#ifndef MINIZ_NO_ZLIB_APIS +// Create tdefl_compress() flags given zlib-style compression parameters. +// level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) +// window_bits may be -15 (raw deflate) or 15 (zlib) +// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED +mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); +#endif // #ifndef MINIZ_NO_ZLIB_APIS + +// Allocate the tdefl_compressor and tinfl_decompressor structures in C so that +// non-C language bindings to tdefl_ and tinfl_ API don't need to worry about +// structure size and allocation mechanism. +tdefl_compressor *tdefl_compressor_alloc(); +void tdefl_compressor_free(tdefl_compressor *pComp); +tinfl_decompressor *tinfl_decompressor_alloc(); +void tinfl_decompressor_free(tinfl_decompressor *pDecomp); + +#ifdef __cplusplus +} +#endif + +#endif // MINIZ_HEADER_INCLUDED + +// ------------------- End of Header: Implementation follows. (If you only want the header, define MINIZ_HEADER_FILE_ONLY.) + +#ifndef MINIZ_HEADER_FILE_ONLY + +typedef unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 : -1]; +typedef unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 : -1]; +typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; + +#include +#include + +#define MZ_ASSERT(x) assert(x) + +#ifdef MINIZ_NO_MALLOC + #define MZ_MALLOC(x) NULL + #define MZ_FREE(x) (void)x, ((void)0) + #define MZ_REALLOC(p, x) NULL +#else + #define MZ_MALLOC(x) malloc(x) + #define MZ_FREE(x) free(x) + #define MZ_REALLOC(p, x) realloc(p, x) +#endif + +#define MZ_MAX(a,b) (((a)>(b))?(a):(b)) +#define MZ_MIN(a,b) (((a)<(b))?(a):(b)) +#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) + #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) +#else + #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) + #define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) +#endif + +#ifdef _MSC_VER + #define MZ_FORCEINLINE __forceinline +#elif defined(__GNUC__) + #define MZ_FORCEINLINE inline __attribute__((__always_inline__)) +#else + #define MZ_FORCEINLINE inline +#endif + +#ifdef __cplusplus + extern "C" { +#endif + +// ------------------- zlib-style API's + +mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) +{ + mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; + if (!ptr) return MZ_ADLER32_INIT; + while (buf_len) { + for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { + s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; + s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; + } + for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; + s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; + } + return (s2 << 16) + s1; +} + +// Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/ +mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) +{ + static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, + 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; + mz_uint32 crcu32 = (mz_uint32)crc; + if (!ptr) return MZ_CRC32_INIT; + crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; } + return ~crcu32; +} + +void mz_free(void *p) +{ + MZ_FREE(p); +} + +#ifndef MINIZ_NO_ZLIB_APIS + +static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); } +static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } +static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque, (void)address, (void)items, (void)size; return MZ_REALLOC(address, items * size); } + +const char *mz_version(void) +{ + return MZ_VERSION; +} + +int mz_deflateInit(mz_streamp pStream, int level) +{ + return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); +} + +int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy) +{ + tdefl_compressor *pComp; + mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); + + if (!pStream) return MZ_STREAM_ERROR; + if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) return MZ_PARAM_ERROR; + + pStream->data_type = 0; + pStream->adler = MZ_ADLER32_INIT; + pStream->msg = NULL; + pStream->reserved = 0; + pStream->total_in = 0; + pStream->total_out = 0; + if (!pStream->zalloc) pStream->zalloc = def_alloc_func; + if (!pStream->zfree) pStream->zfree = def_free_func; + + pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor)); + if (!pComp) + return MZ_MEM_ERROR; + + pStream->state = (struct mz_internal_state *)pComp; + + if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) + { + mz_deflateEnd(pStream); + return MZ_PARAM_ERROR; + } + + return MZ_OK; +} + +int mz_deflateReset(mz_streamp pStream) +{ + if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) return MZ_STREAM_ERROR; + pStream->total_in = pStream->total_out = 0; + tdefl_init((tdefl_compressor*)pStream->state, NULL, NULL, ((tdefl_compressor*)pStream->state)->m_flags); + return MZ_OK; +} + +int mz_deflate(mz_streamp pStream, int flush) +{ + size_t in_bytes, out_bytes; + mz_ulong orig_total_in, orig_total_out; + int mz_status = MZ_OK; + + if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) return MZ_STREAM_ERROR; + if (!pStream->avail_out) return MZ_BUF_ERROR; + + if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; + + if (((tdefl_compressor*)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE) + return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; + + orig_total_in = pStream->total_in; orig_total_out = pStream->total_out; + for ( ; ; ) + { + tdefl_status defl_status; + in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; + + defl_status = tdefl_compress((tdefl_compressor*)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush); + pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; + pStream->total_in += (mz_uint)in_bytes; pStream->adler = tdefl_get_adler32((tdefl_compressor*)pStream->state); + + pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; + pStream->total_out += (mz_uint)out_bytes; + + if (defl_status < 0) + { + mz_status = MZ_STREAM_ERROR; + break; + } + else if (defl_status == TDEFL_STATUS_DONE) + { + mz_status = MZ_STREAM_END; + break; + } + else if (!pStream->avail_out) + break; + else if ((!pStream->avail_in) && (flush != MZ_FINISH)) + { + if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out)) + break; + return MZ_BUF_ERROR; // Can't make forward progress without some input. + } + } + return mz_status; +} + +int mz_deflateEnd(mz_streamp pStream) +{ + if (!pStream) return MZ_STREAM_ERROR; + if (pStream->state) + { + pStream->zfree(pStream->opaque, pStream->state); + pStream->state = NULL; + } + return MZ_OK; +} + +mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) +{ + (void)pStream; + // This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) + return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); +} + +int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level) +{ + int status; + mz_stream stream; + memset(&stream, 0, sizeof(stream)); + + // In case mz_ulong is 64-bits (argh I hate longs). + if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; + + stream.next_in = pSource; + stream.avail_in = (mz_uint32)source_len; + stream.next_out = pDest; + stream.avail_out = (mz_uint32)*pDest_len; + + status = mz_deflateInit(&stream, level); + if (status != MZ_OK) return status; + + status = mz_deflate(&stream, MZ_FINISH); + if (status != MZ_STREAM_END) + { + mz_deflateEnd(&stream); + return (status == MZ_OK) ? MZ_BUF_ERROR : status; + } + + *pDest_len = stream.total_out; + return mz_deflateEnd(&stream); +} + +int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) +{ + return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); +} + +mz_ulong mz_compressBound(mz_ulong source_len) +{ + return mz_deflateBound(NULL, source_len); +} + +typedef struct +{ + tinfl_decompressor m_decomp; + mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits; + mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; + tinfl_status m_last_status; +} inflate_state; + +int mz_inflateInit2(mz_streamp pStream, int window_bits) +{ + inflate_state *pDecomp; + if (!pStream) return MZ_STREAM_ERROR; + if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) return MZ_PARAM_ERROR; + + pStream->data_type = 0; + pStream->adler = 0; + pStream->msg = NULL; + pStream->total_in = 0; + pStream->total_out = 0; + pStream->reserved = 0; + if (!pStream->zalloc) pStream->zalloc = def_alloc_func; + if (!pStream->zfree) pStream->zfree = def_free_func; + + pDecomp = (inflate_state*)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state)); + if (!pDecomp) return MZ_MEM_ERROR; + + pStream->state = (struct mz_internal_state *)pDecomp; + + tinfl_init(&pDecomp->m_decomp); + pDecomp->m_dict_ofs = 0; + pDecomp->m_dict_avail = 0; + pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; + pDecomp->m_first_call = 1; + pDecomp->m_has_flushed = 0; + pDecomp->m_window_bits = window_bits; + + return MZ_OK; +} + +int mz_inflateInit(mz_streamp pStream) +{ + return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); +} + +int mz_inflate(mz_streamp pStream, int flush) +{ + inflate_state* pState; + mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; + size_t in_bytes, out_bytes, orig_avail_in; + tinfl_status status; + + if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR; + if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; + if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; + + pState = (inflate_state*)pStream->state; + if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; + orig_avail_in = pStream->avail_in; + + first_call = pState->m_first_call; pState->m_first_call = 0; + if (pState->m_last_status < 0) return MZ_DATA_ERROR; + + if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; + pState->m_has_flushed |= (flush == MZ_FINISH); + + if ((flush == MZ_FINISH) && (first_call)) + { + // MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. + decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; + in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; + status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags); + pState->m_last_status = status; + pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; + pStream->adler = tinfl_get_adler32(&pState->m_decomp); + pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; + + if (status < 0) + return MZ_DATA_ERROR; + else if (status != TINFL_STATUS_DONE) + { + pState->m_last_status = TINFL_STATUS_FAILED; + return MZ_BUF_ERROR; + } + return MZ_STREAM_END; + } + // flush != MZ_FINISH then we must assume there's more input. + if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; + + if (pState->m_dict_avail) + { + n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); + memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); + pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; + pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); + return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; + } + + for ( ; ; ) + { + in_bytes = pStream->avail_in; + out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; + + status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); + pState->m_last_status = status; + + pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; + pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); + + pState->m_dict_avail = (mz_uint)out_bytes; + + n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); + memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); + pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; + pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); + + if (status < 0) + return MZ_DATA_ERROR; // Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). + else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) + return MZ_BUF_ERROR; // Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. + else if (flush == MZ_FINISH) + { + // The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. + if (status == TINFL_STATUS_DONE) + return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; + // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. + else if (!pStream->avail_out) + return MZ_BUF_ERROR; + } + else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail)) + break; + } + + return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; +} + +int mz_inflateEnd(mz_streamp pStream) +{ + if (!pStream) + return MZ_STREAM_ERROR; + if (pStream->state) + { + pStream->zfree(pStream->opaque, pStream->state); + pStream->state = NULL; + } + return MZ_OK; +} + +int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) +{ + mz_stream stream; + int status; + memset(&stream, 0, sizeof(stream)); + + // In case mz_ulong is 64-bits (argh I hate longs). + if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; + + stream.next_in = pSource; + stream.avail_in = (mz_uint32)source_len; + stream.next_out = pDest; + stream.avail_out = (mz_uint32)*pDest_len; + + status = mz_inflateInit(&stream); + if (status != MZ_OK) + return status; + + status = mz_inflate(&stream, MZ_FINISH); + if (status != MZ_STREAM_END) + { + mz_inflateEnd(&stream); + return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; + } + *pDest_len = stream.total_out; + + return mz_inflateEnd(&stream); +} + +const char *mz_error(int err) +{ + static struct { int m_err; const char *m_pDesc; } s_error_descs[] = + { + { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, + { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } + }; + mz_uint i; for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc; + return NULL; +} + +#endif //MINIZ_NO_ZLIB_APIS + +// ------------------- Low-level Decompression (completely independent from all compression API's) + +#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) +#define TINFL_MEMSET(p, c, l) memset(p, c, l) + +#define TINFL_CR_BEGIN switch(r->m_state) { case 0: +#define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END +#define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END +#define TINFL_CR_FINISH } + +#define TINFL_GET_BYTE(state_index, c) do { \ + while (pIn_buf_cur >= pIn_buf_end) { \ + TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ + } c = *pIn_buf_cur++; } MZ_MACRO_END + +#define TINFL_NEED_BITS(state_index, n) do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n)) +#define TINFL_SKIP_BITS(state_index, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END +#define TINFL_GET_BITS(state_index, b, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END + +// TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. +// It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a +// Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the +// bit buffer contains >=15 bits (deflate's max. Huffman code size). +#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ + do { \ + temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ + if (temp >= 0) { \ + code_len = temp >> 9; \ + if ((code_len) && (num_bits >= code_len)) \ + break; \ + } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ + code_len = TINFL_FAST_LOOKUP_BITS; \ + do { \ + temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ + } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \ + } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \ + } while (num_bits < 15); + +// TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read +// beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully +// decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. +// The slow path is only executed at the very end of the input buffer. +// v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes +// following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. +#define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \ + int temp; mz_uint code_len, c; \ + if (num_bits < 15) { \ + if ((pIn_buf_end - pIn_buf_cur) < 2) { \ + TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ + } else { \ + bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \ + } \ + } \ + if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \ + code_len = temp >> 9, temp &= 511; \ + else { \ + code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \ + } sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END + +tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags) +{ + static const int s_length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; + static const int s_length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + static const int s_dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; + static const int s_dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + static const mz_uint8 s_length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + static const int s_min_table_sizes[3] = { 257, 1, 4 }; + + tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf; + const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; + mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; + size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; + + // Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). + if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0; return TINFL_STATUS_BAD_PARAM; } + + num_bits = r->m_num_bits; bit_buf = r->m_bit_buf; dist = r->m_dist; counter = r->m_counter; num_extra = r->m_num_extra; dist_from_out_buf_start = r->m_dist_from_out_buf_start; + TINFL_CR_BEGIN + + bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; r->m_z_adler32 = r->m_check_adler32 = 1; + if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) + { + TINFL_GET_BYTE(1, r->m_zhdr0); TINFL_GET_BYTE(2, r->m_zhdr1); + counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); + if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->m_zhdr0 >> 4))))); + if (counter) { TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); } + } + + do + { + TINFL_GET_BITS(3, r->m_final, 3); r->m_type = r->m_final >> 1; + if (r->m_type == 0) + { + TINFL_SKIP_BITS(5, num_bits & 7); + for (counter = 0; counter < 4; ++counter) { if (num_bits) TINFL_GET_BITS(6, r->m_raw_header[counter], 8); else TINFL_GET_BYTE(7, r->m_raw_header[counter]); } + if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); } + while ((counter) && (num_bits)) + { + TINFL_GET_BITS(51, dist, 8); + while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); } + *pOut_buf_cur++ = (mz_uint8)dist; + counter--; + } + while (counter) + { + size_t n; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); } + while (pIn_buf_cur >= pIn_buf_end) + { + TINFL_CR_RETURN(38, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); + } + n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter); + TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (mz_uint)n; + } + } + else if (r->m_type == 3) + { + TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); + } + else + { + if (r->m_type == 1) + { + mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; + r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); + for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; + } + else + { + for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; } + MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } + r->m_table_sizes[2] = 19; + } + for ( ; (int)r->m_type >= 0; r->m_type--) + { + int tree_next, tree_cur; tinfl_huff_table *pTable; + mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree); + for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++; + used_syms = 0, total = 0; next_code[0] = next_code[1] = 0; + for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); } + if ((65536 != total) && (used_syms > 1)) + { + TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); + } + for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index) + { + mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index]; if (!code_size) continue; + cur_code = next_code[code_size]++; for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1); + if (code_size <= TINFL_FAST_LOOKUP_BITS) { mz_int16 k = (mz_int16)((code_size << 9) | sym_index); while (rev_code < TINFL_FAST_LOOKUP_SIZE) { pTable->m_look_up[rev_code] = k; rev_code += (1 << code_size); } continue; } + if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) { pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } + rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); + for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) + { + tree_cur -= ((rev_code >>= 1) & 1); + if (!pTable->m_tree[-tree_cur - 1]) { pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } else tree_cur = pTable->m_tree[-tree_cur - 1]; + } + tree_cur -= ((rev_code >>= 1) & 1); pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index; + } + if (r->m_type == 2) + { + for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]); ) + { + mz_uint s; TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); if (dist < 16) { r->m_len_codes[counter++] = (mz_uint8)dist; continue; } + if ((dist == 16) && (!counter)) + { + TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); + } + num_extra = "\02\03\07"[dist - 16]; TINFL_GET_BITS(18, s, num_extra); s += "\03\03\013"[dist - 16]; + TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); counter += s; + } + if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) + { + TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); + } + TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]); + } + } + for ( ; ; ) + { + mz_uint8 *pSrc; + for ( ; ; ) + { + if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2)) + { + TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]); + if (counter >= 256) + break; + while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); } + *pOut_buf_cur++ = (mz_uint8)counter; + } + else + { + int sym2; mz_uint code_len; +#if TINFL_USE_64BIT_BITBUF + if (num_bits < 30) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); pIn_buf_cur += 4; num_bits += 32; } +#else + if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } +#endif + if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) + code_len = sym2 >> 9; + else + { + code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); + } + counter = sym2; bit_buf >>= code_len; num_bits -= code_len; + if (counter & 256) + break; + +#if !TINFL_USE_64BIT_BITBUF + if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } +#endif + if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) + code_len = sym2 >> 9; + else + { + code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); + } + bit_buf >>= code_len; num_bits -= code_len; + + pOut_buf_cur[0] = (mz_uint8)counter; + if (sym2 & 256) + { + pOut_buf_cur++; + counter = sym2; + break; + } + pOut_buf_cur[1] = (mz_uint8)sym2; + pOut_buf_cur += 2; + } + } + if ((counter &= 511) == 256) break; + + num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257]; + if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; } + + TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]); + num_extra = s_dist_extra[dist]; dist = s_dist_base[dist]; + if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; } + + dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; + if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) + { + TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); + } + + pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask); + + if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) + { + while (counter--) + { + while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); } + *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask]; + } + continue; + } +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES + else if ((counter >= 9) && (counter <= dist)) + { + const mz_uint8 *pSrc_end = pSrc + (counter & ~7); + do + { + ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; + ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; + pOut_buf_cur += 8; + } while ((pSrc += 8) < pSrc_end); + if ((counter &= 7) < 3) + { + if (counter) + { + pOut_buf_cur[0] = pSrc[0]; + if (counter > 1) + pOut_buf_cur[1] = pSrc[1]; + pOut_buf_cur += counter; + } + continue; + } + } +#endif + do + { + pOut_buf_cur[0] = pSrc[0]; + pOut_buf_cur[1] = pSrc[1]; + pOut_buf_cur[2] = pSrc[2]; + pOut_buf_cur += 3; pSrc += 3; + } while ((int)(counter -= 3) > 2); + if ((int)counter > 0) + { + pOut_buf_cur[0] = pSrc[0]; + if ((int)counter > 1) + pOut_buf_cur[1] = pSrc[1]; + pOut_buf_cur += counter; + } + } + } + } while (!(r->m_final & 1)); + + // Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. + // I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. + TINFL_SKIP_BITS(32, num_bits & 7); + while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) { --pIn_buf_cur; num_bits -= 8; } bit_buf &= (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); + MZ_ASSERT(!num_bits); // if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). + + if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) + { + for (counter = 0; counter < 4; ++counter) { mz_uint s; if (num_bits) TINFL_GET_BITS(41, s, 8); else TINFL_GET_BYTE(42, s); r->m_z_adler32 = (r->m_z_adler32 << 8) | s; } + } + TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); + + TINFL_CR_FINISH + +common_exit: + // As long as we aren't telling the caller that we NEED more input to make forward progress: + // Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. + // We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. + if ((status != TINFL_STATUS_NEEDS_MORE_INPUT) && (status != TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS)) { while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) { --pIn_buf_cur; num_bits -= 8; } } + r->m_num_bits = num_bits; r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); r->m_dist = dist; r->m_counter = counter; r->m_num_extra = num_extra; r->m_dist_from_out_buf_start = dist_from_out_buf_start; + *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next; + if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0)) + { + const mz_uint8 *ptr = pOut_buf_next; size_t buf_len = *pOut_buf_size; + mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; size_t block_len = buf_len % 5552; + while (buf_len) + { + for (i = 0; i + 7 < block_len; i += 8, ptr += 8) + { + s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; + s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; + } + for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; + s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; + } + r->m_check_adler32 = (s2 << 16) + s1; if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) status = TINFL_STATUS_ADLER32_MISMATCH; + } + return status; +} + +// Higher level helper functions. +void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) +{ + tinfl_decompressor decomp; void *pBuf = NULL, *pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0; + *pOut_len = 0; + tinfl_init(&decomp); + for ( ; ; ) + { + size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; + tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8*)pBuf, pBuf ? (mz_uint8*)pBuf + *pOut_len : NULL, &dst_buf_size, + (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); + if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) + { + MZ_FREE(pBuf); *pOut_len = 0; return NULL; + } + src_buf_ofs += src_buf_size; + *pOut_len += dst_buf_size; + if (status == TINFL_STATUS_DONE) break; + new_out_buf_capacity = out_buf_capacity * 2; if (new_out_buf_capacity < 128) new_out_buf_capacity = 128; + pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); + if (!pNew_buf) + { + MZ_FREE(pBuf); *pOut_len = 0; return NULL; + } + pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity; + } + return pBuf; +} + +size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) +{ + tinfl_decompressor decomp; tinfl_status status; tinfl_init(&decomp); + status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf, &src_buf_len, (mz_uint8*)pOut_buf, (mz_uint8*)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); + return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len; +} + +int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) +{ + int result = 0; + tinfl_decompressor decomp; + mz_uint8 *pDict = (mz_uint8*)MZ_MALLOC(TINFL_LZ_DICT_SIZE); size_t in_buf_ofs = 0, dict_ofs = 0; + if (!pDict) + return TINFL_STATUS_FAILED; + tinfl_init(&decomp); + for ( ; ; ) + { + size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; + tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, + (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); + in_buf_ofs += in_buf_size; + if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) + break; + if (status != TINFL_STATUS_HAS_MORE_OUTPUT) + { + result = (status == TINFL_STATUS_DONE); + break; + } + dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); + } + MZ_FREE(pDict); + *pIn_buf_size = in_buf_ofs; + return result; +} + +// ------------------- Low-level Compression (independent from all decompression API's) + +// Purposely making these tables static for faster init and thread safety. +static const mz_uint16 s_tdefl_len_sym[256] = { + 257,258,259,260,261,262,263,264,265,265,266,266,267,267,268,268,269,269,269,269,270,270,270,270,271,271,271,271,272,272,272,272, + 273,273,273,273,273,273,273,273,274,274,274,274,274,274,274,274,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276,276, + 277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278, + 279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280, + 281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281, + 282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282, + 283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283, + 284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,285 }; + +static const mz_uint8 s_tdefl_len_extra[256] = { + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0 }; + +static const mz_uint8 s_tdefl_small_dist_sym[512] = { + 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, + 11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14, + 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, + 14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, + 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17, + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 }; + +static const mz_uint8 s_tdefl_small_dist_extra[512] = { + 0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7 }; + +static const mz_uint8 s_tdefl_large_dist_sym[128] = { + 0,0,18,19,20,20,21,21,22,22,22,22,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26, + 26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, + 28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29 }; + +static const mz_uint8 s_tdefl_large_dist_extra[128] = { + 0,0,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 }; + +// Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. +typedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq; +static tdefl_sym_freq* tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq* pSyms0, tdefl_sym_freq* pSyms1) +{ + mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; tdefl_sym_freq* pCur_syms = pSyms0, *pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist); + for (i = 0; i < num_syms; i++) { mz_uint freq = pSyms0[i].m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; } + while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--; + for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) + { + const mz_uint32* pHist = &hist[pass << 8]; + mz_uint offsets[256], cur_ofs = 0; + for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; } + for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i]; + { tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; } + } + return pCur_syms; +} + +// tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. +static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) +{ + int root, leaf, next, avbl, used, dpth; + if (n==0) return; else if (n==1) { A[0].m_key = 1; return; } + A[0].m_key += A[1].m_key; root = 0; leaf = 2; + for (next=1; next < n-1; next++) + { + if (leaf>=n || A[root].m_key=n || (root=0; next--) A[next].m_key = A[A[next].m_key].m_key+1; + avbl = 1; used = dpth = 0; root = n-2; next = n-1; + while (avbl>0) + { + while (root>=0 && (int)A[root].m_key==dpth) { used++; root--; } + while (avbl>used) { A[next--].m_key = (mz_uint16)(dpth); avbl--; } + avbl = 2*used; dpth++; used = 0; + } +} + +// Limits canonical Huffman code table's max code size. +enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 }; +static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) +{ + int i; mz_uint32 total = 0; if (code_list_len <= 1) return; + for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i]; + for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); + while (total != (1UL << max_code_size)) + { + pNum_codes[max_code_size]--; + for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; } + total--; + } +} + +static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table) +{ + int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; MZ_CLEAR_OBJ(num_codes); + if (static_table) + { + for (i = 0; i < table_len; i++) num_codes[d->m_huff_code_sizes[table_num][i]]++; + } + else + { + tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; + int num_used_syms = 0; + const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; + for (i = 0; i < table_len; i++) if (pSym_count[i]) { syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; syms0[num_used_syms++].m_sym_index = (mz_uint16)i; } + + pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); + + for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++; + + tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit); + + MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); MZ_CLEAR_OBJ(d->m_huff_codes[table_num]); + for (i = 1, j = num_used_syms; i <= code_size_limit; i++) + for (l = num_codes[i]; l > 0; l--) d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); + } + + next_code[1] = 0; for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1); + + for (i = 0; i < table_len; i++) + { + mz_uint rev_code = 0, code, code_size; if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue; + code = next_code[code_size]++; for (l = code_size; l > 0; l--, code >>= 1) rev_code = (rev_code << 1) | (code & 1); + d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; + } +} + +#define TDEFL_PUT_BITS(b, l) do { \ + mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \ + d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \ + while (d->m_bits_in >= 8) { \ + if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ + *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ + d->m_bit_buffer >>= 8; \ + d->m_bits_in -= 8; \ + } \ +} MZ_MACRO_END + +#define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \ + if (rle_repeat_count < 3) { \ + d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ + while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ + } else { \ + d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); packed_code_sizes[num_packed_code_sizes++] = 16; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \ +} rle_repeat_count = 0; } } + +#define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \ + if (rle_z_count < 3) { \ + d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \ + } else if (rle_z_count <= 10) { \ + d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); packed_code_sizes[num_packed_code_sizes++] = 17; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \ + } else { \ + d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); packed_code_sizes[num_packed_code_sizes++] = 18; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \ +} rle_z_count = 0; } } + +static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; + +static void tdefl_start_dynamic_block(tdefl_compressor *d) +{ + int num_lit_codes, num_dist_codes, num_bit_lengths; mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index; + mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF; + + d->m_huff_count[0][256] = 1; + + tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); + tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); + + for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break; + for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break; + + memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); + memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes); + total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0; + + memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); + for (i = 0; i < total_code_sizes_to_pack; i++) + { + mz_uint8 code_size = code_sizes_to_pack[i]; + if (!code_size) + { + TDEFL_RLE_PREV_CODE_SIZE(); + if (++rle_z_count == 138) { TDEFL_RLE_ZERO_CODE_SIZE(); } + } + else + { + TDEFL_RLE_ZERO_CODE_SIZE(); + if (code_size != prev_code_size) + { + TDEFL_RLE_PREV_CODE_SIZE(); + d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size; + } + else if (++rle_repeat_count == 6) + { + TDEFL_RLE_PREV_CODE_SIZE(); + } + } + prev_code_size = code_size; + } + if (rle_repeat_count) { TDEFL_RLE_PREV_CODE_SIZE(); } else { TDEFL_RLE_ZERO_CODE_SIZE(); } + + tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); + + TDEFL_PUT_BITS(2, 2); + + TDEFL_PUT_BITS(num_lit_codes - 257, 5); + TDEFL_PUT_BITS(num_dist_codes - 1, 5); + + for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) break; + num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); TDEFL_PUT_BITS(num_bit_lengths - 4, 4); + for (i = 0; (int)i < num_bit_lengths; i++) TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); + + for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; ) + { + mz_uint code = packed_code_sizes[packed_code_sizes_index++]; MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); + TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); + if (code >= 16) TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]); + } +} + +static void tdefl_start_static_block(tdefl_compressor *d) +{ + mz_uint i; + mz_uint8 *p = &d->m_huff_code_sizes[0][0]; + + for (i = 0; i <= 143; ++i) *p++ = 8; + for ( ; i <= 255; ++i) *p++ = 9; + for ( ; i <= 279; ++i) *p++ = 7; + for ( ; i <= 287; ++i) *p++ = 8; + + memset(d->m_huff_code_sizes[1], 5, 32); + + tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); + tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); + + TDEFL_PUT_BITS(1, 2); +} + +static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS +static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) +{ + mz_uint flags; + mz_uint8 *pLZ_codes; + mz_uint8 *pOutput_buf = d->m_pOutput_buf; + mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; + mz_uint64 bit_buffer = d->m_bit_buffer; + mz_uint bits_in = d->m_bits_in; + +#define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); } + + flags = 1; + for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1) + { + if (flags == 1) + flags = *pLZ_codes++ | 0x100; + + if (flags & 1) + { + mz_uint s0, s1, n0, n1, sym, num_extra_bits; + mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3; + + MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); + + // This sequence coaxes MSVC into using cmov's vs. jmp's. + s0 = s_tdefl_small_dist_sym[match_dist & 511]; + n0 = s_tdefl_small_dist_extra[match_dist & 511]; + s1 = s_tdefl_large_dist_sym[match_dist >> 8]; + n1 = s_tdefl_large_dist_extra[match_dist >> 8]; + sym = (match_dist < 512) ? s0 : s1; + num_extra_bits = (match_dist < 512) ? n0 : n1; + + MZ_ASSERT(d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); + } + else + { + mz_uint lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + + if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) + { + flags >>= 1; + lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + + if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) + { + flags >>= 1; + lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + } + } + } + + if (pOutput_buf >= d->m_pOutput_buf_end) + return MZ_FALSE; + + *(mz_uint64*)pOutput_buf = bit_buffer; + pOutput_buf += (bits_in >> 3); + bit_buffer >>= (bits_in & ~7); + bits_in &= 7; + } + +#undef TDEFL_PUT_BITS_FAST + + d->m_pOutput_buf = pOutput_buf; + d->m_bits_in = 0; + d->m_bit_buffer = 0; + + while (bits_in) + { + mz_uint32 n = MZ_MIN(bits_in, 16); + TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); + bit_buffer >>= n; + bits_in -= n; + } + + TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); + + return (d->m_pOutput_buf < d->m_pOutput_buf_end); +} +#else +static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) +{ + mz_uint flags; + mz_uint8 *pLZ_codes; + + flags = 1; + for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1) + { + if (flags == 1) + flags = *pLZ_codes++ | 0x100; + if (flags & 1) + { + mz_uint sym, num_extra_bits; + mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; + + MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); + + if (match_dist < 512) + { + sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist]; + } + else + { + sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; + } + MZ_ASSERT(d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); + } + else + { + mz_uint lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + } + } + + TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); + + return (d->m_pOutput_buf < d->m_pOutput_buf_end); +} +#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS + +static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) +{ + if (static_block) + tdefl_start_static_block(d); + else + tdefl_start_dynamic_block(d); + return tdefl_compress_lz_codes(d); +} + +static int tdefl_flush_block(tdefl_compressor *d, int flush) +{ + mz_uint saved_bit_buf, saved_bits_in; + mz_uint8 *pSaved_output_buf; + mz_bool comp_block_succeeded = MZ_FALSE; + int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; + mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf; + + d->m_pOutput_buf = pOutput_buf_start; + d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; + + MZ_ASSERT(!d->m_output_flush_remaining); + d->m_output_flush_ofs = 0; + d->m_output_flush_remaining = 0; + + *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); + d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); + + if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) + { + TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8); + } + + TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); + + pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in; + + if (!use_raw_block) + comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48)); + + // If the block gets expanded, forget the current contents of the output buffer and send a raw block instead. + if ( ((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) && + ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size) ) + { + mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; + TDEFL_PUT_BITS(0, 2); + if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } + for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) + { + TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); + } + for (i = 0; i < d->m_total_lz_bytes; ++i) + { + TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8); + } + } + // Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes. + else if (!comp_block_succeeded) + { + d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; + tdefl_compress_block(d, MZ_TRUE); + } + + if (flush) + { + if (flush == TDEFL_FINISH) + { + if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } + if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } } + } + else + { + mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); } + } + } + + MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); + + memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); + memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); + + d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++; + + if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) + { + if (d->m_pPut_buf_func) + { + *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; + if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) + return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); + } + else if (pOutput_buf_start == d->m_output_buf) + { + int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); + memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy); + d->m_out_buf_ofs += bytes_to_copy; + if ((n -= bytes_to_copy) != 0) + { + d->m_output_flush_ofs = bytes_to_copy; + d->m_output_flush_remaining = n; + } + } + else + { + d->m_out_buf_ofs += n; + } + } + + return d->m_output_flush_remaining; +} + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES +#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p) +static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) +{ + mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; + mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; + const mz_uint16 *s = (const mz_uint16*)(d->m_dict + pos), *p, *q; + mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s); + MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; + for ( ; ; ) + { + for ( ; ; ) + { + if (--num_probes_left == 0) return; + #define TDEFL_PROBE \ + next_probe_pos = d->m_next[probe_pos]; \ + if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ + probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ + if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; + TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; + } + if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; + do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && + (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); + if (!probe_len) + { + *pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break; + } + else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8*)p == *(const mz_uint8*)q)) > match_len) + { + *pMatch_dist = dist; if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) break; + c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); + } + } +} +#else +static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) +{ + mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; + mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; + const mz_uint8 *s = d->m_dict + pos, *p, *q; + mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; + MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; + for ( ; ; ) + { + for ( ; ; ) + { + if (--num_probes_left == 0) return; + #define TDEFL_PROBE \ + next_probe_pos = d->m_next[probe_pos]; \ + if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ + probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ + if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break; + TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; + } + if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break; + if (probe_len > match_len) + { + *pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return; + c0 = d->m_dict[pos + match_len]; c1 = d->m_dict[pos + match_len - 1]; + } + } +} +#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN +static mz_bool tdefl_compress_fast(tdefl_compressor *d) +{ + // Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. + mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; + mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; + mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; + + while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) + { + const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; + mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; + mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); + d->m_src_buf_left -= num_bytes_to_process; + lookahead_size += num_bytes_to_process; + + while (num_bytes_to_process) + { + mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); + memcpy(d->m_dict + dst_pos, d->m_pSrc, n); + if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) + memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); + d->m_pSrc += n; + dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; + num_bytes_to_process -= n; + } + + dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); + if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break; + + while (lookahead_size >= 4) + { + mz_uint cur_match_dist, cur_match_len = 1; + mz_uint8 *pCur_dict = d->m_dict + cur_pos; + mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; + mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK; + mz_uint probe_pos = d->m_hash[hash]; + d->m_hash[hash] = (mz_uint16)lookahead_pos; + + if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram)) + { + const mz_uint16 *p = (const mz_uint16 *)pCur_dict; + const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); + mz_uint32 probe_len = 32; + do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && + (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); + cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); + if (!probe_len) + cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; + + if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U))) + { + cur_match_len = 1; + *pLZ_code_buf++ = (mz_uint8)first_trigram; + *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); + d->m_huff_count[0][(mz_uint8)first_trigram]++; + } + else + { + mz_uint32 s0, s1; + cur_match_len = MZ_MIN(cur_match_len, lookahead_size); + + MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); + + cur_match_dist--; + + pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); + *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; + pLZ_code_buf += 3; + *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); + + s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; + s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; + d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; + + d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++; + } + } + else + { + *pLZ_code_buf++ = (mz_uint8)first_trigram; + *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); + d->m_huff_count[0][(mz_uint8)first_trigram]++; + } + + if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } + + total_lz_bytes += cur_match_len; + lookahead_pos += cur_match_len; + dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE); + cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; + MZ_ASSERT(lookahead_size >= cur_match_len); + lookahead_size -= cur_match_len; + + if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) + { + int n; + d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; + d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; + if ((n = tdefl_flush_block(d, 0)) != 0) + return (n < 0) ? MZ_FALSE : MZ_TRUE; + total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; + } + } + + while (lookahead_size) + { + mz_uint8 lit = d->m_dict[cur_pos]; + + total_lz_bytes++; + *pLZ_code_buf++ = lit; + *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); + if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } + + d->m_huff_count[0][lit]++; + + lookahead_pos++; + dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE); + cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; + lookahead_size--; + + if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) + { + int n; + d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; + d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; + if ((n = tdefl_flush_block(d, 0)) != 0) + return (n < 0) ? MZ_FALSE : MZ_TRUE; + total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; + } + } + } + + d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; + d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; + return MZ_TRUE; +} +#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + +static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit) +{ + d->m_total_lz_bytes++; + *d->m_pLZ_code_buf++ = lit; + *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } + d->m_huff_count[0][lit]++; +} + +static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) +{ + mz_uint32 s0, s1; + + MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE)); + + d->m_total_lz_bytes += match_len; + + d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); + + match_dist -= 1; + d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); + d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); d->m_pLZ_code_buf += 3; + + *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } + + s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; + d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; + + if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; +} + +static mz_bool tdefl_compress_normal(tdefl_compressor *d) +{ + const mz_uint8 *pSrc = d->m_pSrc; size_t src_buf_left = d->m_src_buf_left; + tdefl_flush flush = d->m_flush; + + while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) + { + mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; + // Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN. + if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) + { + mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; + mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; + mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); + const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; + src_buf_left -= num_bytes_to_process; + d->m_lookahead_size += num_bytes_to_process; + while (pSrc != pSrc_end) + { + mz_uint8 c = *pSrc++; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; + hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); + d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); + dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ins_pos++; + } + } + else + { + while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) + { + mz_uint8 c = *pSrc++; + mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; + src_buf_left--; + d->m_dict[dst_pos] = c; + if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) + d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; + if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) + { + mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; + mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); + d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); + } + } + } + d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); + if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) + break; + + // Simple lazy/greedy parsing state machine. + len_to_move = 1; cur_match_dist = 0; cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; + if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) + { + if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) + { + mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; + cur_match_len = 0; while (cur_match_len < d->m_lookahead_size) { if (d->m_dict[cur_pos + cur_match_len] != c) break; cur_match_len++; } + if (cur_match_len < TDEFL_MIN_MATCH_LEN) cur_match_len = 0; else cur_match_dist = 1; + } + } + else + { + tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len); + } + if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) + { + cur_match_dist = cur_match_len = 0; + } + if (d->m_saved_match_len) + { + if (cur_match_len > d->m_saved_match_len) + { + tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); + if (cur_match_len >= 128) + { + tdefl_record_match(d, cur_match_len, cur_match_dist); + d->m_saved_match_len = 0; len_to_move = cur_match_len; + } + else + { + d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; + } + } + else + { + tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); + len_to_move = d->m_saved_match_len - 1; d->m_saved_match_len = 0; + } + } + else if (!cur_match_dist) + tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); + else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) + { + tdefl_record_match(d, cur_match_len, cur_match_dist); + len_to_move = cur_match_len; + } + else + { + d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; + } + // Move the lookahead forward by len_to_move bytes. + d->m_lookahead_pos += len_to_move; + MZ_ASSERT(d->m_lookahead_size >= len_to_move); + d->m_lookahead_size -= len_to_move; + d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE); + // Check if it's time to flush the current LZ codes to the internal output buffer. + if ( (d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || + ( (d->m_total_lz_bytes > 31*1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) ) + { + int n; + d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; + if ((n = tdefl_flush_block(d, 0)) != 0) + return (n < 0) ? MZ_FALSE : MZ_TRUE; + } + } + + d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; + return MZ_TRUE; +} + +static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) +{ + if (d->m_pIn_buf_size) + { + *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; + } + + if (d->m_pOut_buf_size) + { + size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining); + memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n); + d->m_output_flush_ofs += (mz_uint)n; + d->m_output_flush_remaining -= (mz_uint)n; + d->m_out_buf_ofs += n; + + *d->m_pOut_buf_size = d->m_out_buf_ofs; + } + + return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY; +} + +tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush) +{ + if (!d) + { + if (pIn_buf_size) *pIn_buf_size = 0; + if (pOut_buf_size) *pOut_buf_size = 0; + return TDEFL_STATUS_BAD_PARAM; + } + + d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size; + d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size; + d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; + d->m_out_buf_ofs = 0; + d->m_flush = flush; + + if ( ((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) || + (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) ) + { + if (pIn_buf_size) *pIn_buf_size = 0; + if (pOut_buf_size) *pOut_buf_size = 0; + return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); + } + d->m_wants_to_finish |= (flush == TDEFL_FINISH); + + if ((d->m_output_flush_remaining) || (d->m_finished)) + return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && + ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && + ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) + { + if (!tdefl_compress_fast(d)) + return d->m_prev_return_status; + } + else +#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + { + if (!tdefl_compress_normal(d)) + return d->m_prev_return_status; + } + + if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf)) + d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf); + + if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining)) + { + if (tdefl_flush_block(d, flush) < 0) + return d->m_prev_return_status; + d->m_finished = (flush == TDEFL_FINISH); + if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; } + } + + return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); +} + +tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush) +{ + MZ_ASSERT(d->m_pPut_buf_func); return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); +} + +tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) +{ + d->m_pPut_buf_func = pPut_buf_func; d->m_pPut_buf_user = pPut_buf_user; + d->m_flags = (mz_uint)(flags); d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; + d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; + if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash); + d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; + d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; + d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; + d->m_pOutput_buf = d->m_output_buf; d->m_pOutput_buf_end = d->m_output_buf; d->m_prev_return_status = TDEFL_STATUS_OKAY; + d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; d->m_adler32 = 1; + d->m_pIn_buf = NULL; d->m_pOut_buf = NULL; + d->m_pIn_buf_size = NULL; d->m_pOut_buf_size = NULL; + d->m_flush = TDEFL_NO_FLUSH; d->m_pSrc = NULL; d->m_src_buf_left = 0; d->m_out_buf_ofs = 0; + memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); + memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); + return TDEFL_STATUS_OKAY; +} + +tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) +{ + return d->m_prev_return_status; +} + +mz_uint32 tdefl_get_adler32(tdefl_compressor *d) +{ + return d->m_adler32; +} + +mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) +{ + tdefl_compressor *pComp; mz_bool succeeded; if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE; + pComp = (tdefl_compressor*)MZ_MALLOC(sizeof(tdefl_compressor)); if (!pComp) return MZ_FALSE; + succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY); + succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE); + MZ_FREE(pComp); return succeeded; +} + +typedef struct +{ + size_t m_size, m_capacity; + mz_uint8 *m_pBuf; + mz_bool m_expandable; +} tdefl_output_buffer; + +static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) +{ + tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; + size_t new_size = p->m_size + len; + if (new_size > p->m_capacity) + { + size_t new_capacity = p->m_capacity; mz_uint8 *pNew_buf; if (!p->m_expandable) return MZ_FALSE; + do { new_capacity = MZ_MAX(128U, new_capacity << 1U); } while (new_size > new_capacity); + pNew_buf = (mz_uint8*)MZ_REALLOC(p->m_pBuf, new_capacity); if (!pNew_buf) return MZ_FALSE; + p->m_pBuf = pNew_buf; p->m_capacity = new_capacity; + } + memcpy((mz_uint8*)p->m_pBuf + p->m_size, pBuf, len); p->m_size = new_size; + return MZ_TRUE; +} + +void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) +{ + tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); + if (!pOut_len) return MZ_FALSE; else *pOut_len = 0; + out_buf.m_expandable = MZ_TRUE; + if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return NULL; + *pOut_len = out_buf.m_size; return out_buf.m_pBuf; +} + +size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) +{ + tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); + if (!pOut_buf) return 0; + out_buf.m_pBuf = (mz_uint8*)pOut_buf; out_buf.m_capacity = out_buf_len; + if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0; + return out_buf.m_size; +} + +#ifndef MINIZ_NO_ZLIB_APIS +static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; + +// level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). +mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy) +{ + mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); + if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER; + + if (!level) comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; + else if (strategy == MZ_FILTERED) comp_flags |= TDEFL_FILTER_MATCHES; + else if (strategy == MZ_HUFFMAN_ONLY) comp_flags &= ~TDEFL_MAX_PROBES_MASK; + else if (strategy == MZ_FIXED) comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; + else if (strategy == MZ_RLE) comp_flags |= TDEFL_RLE_MATCHES; + + return comp_flags; +} +#endif //MINIZ_NO_ZLIB_APIS + +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable:4204) // nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) +#endif + +// Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at +// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. +// This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. +void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip) +{ + // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined. + static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; + tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0; + if (!pComp) return NULL; + MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; } + // write dummy header + for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf); + // compress image data + tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); + for (y = 0; y < h; ++y) { tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); tdefl_compress_buffer(pComp, (mz_uint8*)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); } + if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) { MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } + // write real header + *pLen_out = out_buf.m_size-41; + { + static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; + mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0, + (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; + c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); + memcpy(out_buf.m_pBuf, pnghdr, 41); + } + // write footer (IDAT CRC-32, followed by IEND chunk) + if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0; MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } + c = (mz_uint32)mz_crc32(MZ_CRC32_INIT,out_buf.m_pBuf+41-4, *pLen_out+4); for (i=0; i<4; ++i, c<<=8) (out_buf.m_pBuf+out_buf.m_size-16)[i] = (mz_uint8)(c >> 24); + // compute final size of file, grab compressed data buffer and return + *pLen_out += 57; MZ_FREE(pComp); return out_buf.m_pBuf; +} + +void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) +{ + // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out) + return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); +} + +// Allocate the tdefl_compressor and tinfl_decompressor structures in C so that +// non-C language bindings to tdefL_ and tinfl_ API don't need to worry about +// structure size and allocation mechanism. +tdefl_compressor *tdefl_compressor_alloc() +{ + return (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); +} + +void tdefl_compressor_free(tdefl_compressor* pComp) +{ + MZ_FREE(pComp); +} + +tinfl_decompressor *tinfl_decompressor_alloc() +{ + tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor)); + if (pDecomp) + tinfl_init(pDecomp); + return pDecomp; +} + +void tinfl_decompressor_free(tinfl_decompressor *pDecomp) +{ + MZ_FREE(pDecomp); +} + +#ifdef _MSC_VER +#pragma warning (pop) +#endif + +// ------------------- .ZIP archive reading + +#ifndef MINIZ_NO_ARCHIVE_APIS + +#ifdef MINIZ_NO_STDIO + #define MZ_FILE void * +#else + #include + #include + + #if defined(_MSC_VER) || defined(__MINGW64__) + static FILE *mz_fopen(const char *pFilename, const char *pMode) + { + FILE* pFile = NULL; + fopen_s(&pFile, pFilename, pMode); + return pFile; + } + static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) + { + FILE* pFile = NULL; + if (freopen_s(&pFile, pPath, pMode, pStream)) + return NULL; + return pFile; + } + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN mz_fopen + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 _ftelli64 + #define MZ_FSEEK64 _fseeki64 + #define MZ_FILE_STAT_STRUCT _stat + #define MZ_FILE_STAT _stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN mz_freopen + #define MZ_DELETE_FILE remove + #elif defined(__MINGW32__) + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftello64 + #define MZ_FSEEK64 fseeko64 + #define MZ_FILE_STAT_STRUCT _stat + #define MZ_FILE_STAT _stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(f, m, s) freopen(f, m, s) + #define MZ_DELETE_FILE remove + #elif defined(__TINYC__) + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftell + #define MZ_FSEEK64 fseek + #define MZ_FILE_STAT_STRUCT stat + #define MZ_FILE_STAT stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(f, m, s) freopen(f, m, s) + #define MZ_DELETE_FILE remove + #elif defined(__GNUC__) && _LARGEFILE64_SOURCE + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen64(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftello64 + #define MZ_FSEEK64 fseeko64 + #define MZ_FILE_STAT_STRUCT stat64 + #define MZ_FILE_STAT stat64 + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) + #define MZ_DELETE_FILE remove + #else + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftello + #define MZ_FSEEK64 fseeko + #define MZ_FILE_STAT_STRUCT stat + #define MZ_FILE_STAT stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(f, m, s) freopen(f, m, s) + #define MZ_DELETE_FILE remove + #endif // #ifdef _MSC_VER +#endif // #ifdef MINIZ_NO_STDIO + +#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) + +// Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. +enum +{ + // ZIP archive identifiers and record sizes + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, + MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, + // Central directory header record offsets + MZ_ZIP_CDH_SIG_OFS = 0, MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, MZ_ZIP_CDH_BIT_FLAG_OFS = 8, + MZ_ZIP_CDH_METHOD_OFS = 10, MZ_ZIP_CDH_FILE_TIME_OFS = 12, MZ_ZIP_CDH_FILE_DATE_OFS = 14, MZ_ZIP_CDH_CRC32_OFS = 16, + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, + MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, MZ_ZIP_CDH_DISK_START_OFS = 34, MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, + // Local directory header offsets + MZ_ZIP_LDH_SIG_OFS = 0, MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, MZ_ZIP_LDH_BIT_FLAG_OFS = 6, MZ_ZIP_LDH_METHOD_OFS = 8, MZ_ZIP_LDH_FILE_TIME_OFS = 10, + MZ_ZIP_LDH_FILE_DATE_OFS = 12, MZ_ZIP_LDH_CRC32_OFS = 14, MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, + MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, + // End of central directory offsets + MZ_ZIP_ECDH_SIG_OFS = 0, MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, +}; + +typedef struct +{ + void *m_p; + size_t m_size, m_capacity; + mz_uint m_element_size; +} mz_zip_array; + +struct mz_zip_internal_state_tag +{ + mz_zip_array m_central_dir; + mz_zip_array m_central_dir_offsets; + mz_zip_array m_sorted_central_dir_offsets; + MZ_FILE *m_pFile; + void *m_pMem; + size_t m_mem_size; + size_t m_mem_capacity; +}; + +#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size +#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index] + +static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray) +{ + pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); + memset(pArray, 0, sizeof(mz_zip_array)); +} + +static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing) +{ + void *pNew_p; size_t new_capacity = min_new_capacity; MZ_ASSERT(pArray->m_element_size); if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE; + if (growing) { new_capacity = MZ_MAX(1, pArray->m_capacity); while (new_capacity < min_new_capacity) new_capacity *= 2; } + if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) return MZ_FALSE; + pArray->m_p = pNew_p; pArray->m_capacity = new_capacity; + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing) +{ + if (new_capacity > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) return MZ_FALSE; } + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing) +{ + if (new_size > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) return MZ_FALSE; } + pArray->m_size = new_size; + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) +{ + return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n) +{ + size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE; + memcpy((mz_uint8*)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); + return MZ_TRUE; +} + +#ifndef MINIZ_NO_TIME +static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) +{ + struct tm tm; + memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; + tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31; + tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62; + return mktime(&tm); +} + +static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) +{ +#ifdef _MSC_VER + struct tm tm_struct; + struct tm *tm = &tm_struct; + errno_t err = localtime_s(tm, &time); + if (err) + { + *pDOS_date = 0; *pDOS_time = 0; + return; + } +#else + struct tm *tm = localtime(&time); +#endif + *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1)); + *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday); +} +#endif + +#ifndef MINIZ_NO_STDIO +static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) +{ +#ifdef MINIZ_NO_TIME + (void)pFilename; *pDOS_date = *pDOS_time = 0; +#else + struct MZ_FILE_STAT_STRUCT file_stat; + // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. + if (MZ_FILE_STAT(pFilename, &file_stat) != 0) + return MZ_FALSE; + mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); +#endif // #ifdef MINIZ_NO_TIME + return MZ_TRUE; +} + +#ifndef MINIZ_NO_TIME +static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time) +{ + struct utimbuf t; t.actime = access_time; t.modtime = modified_time; + return !utime(pFilename, &t); +} +#endif // #ifndef MINIZ_NO_TIME +#endif // #ifndef MINIZ_NO_STDIO + +static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags) +{ + (void)flags; + if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) + return MZ_FALSE; + + if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; + if (!pZip->m_pFree) pZip->m_pFree = def_free_func; + if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; + + pZip->m_zip_mode = MZ_ZIP_MODE_READING; + pZip->m_archive_size = 0; + pZip->m_central_directory_file_ofs = 0; + pZip->m_total_files = 0; + + if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) + return MZ_FALSE; + memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) +{ + const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; + const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); + mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); + mz_uint8 l = 0, r = 0; + pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; + pE = pL + MZ_MIN(l_len, r_len); + while (pL < pE) + { + if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) + break; + pL++; pR++; + } + return (pL == pE) ? (l_len < r_len) : (l < r); +} + +#define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END + +// Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.) +static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip) +{ + mz_zip_internal_state *pState = pZip->m_pState; + const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; + const mz_zip_array *pCentral_dir = &pState->m_central_dir; + mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); + const int size = pZip->m_total_files; + int start = (size - 2) >> 1, end; + while (start >= 0) + { + int child, root = start; + for ( ; ; ) + { + if ((child = (root << 1) + 1) >= size) + break; + child += (((child + 1) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]))); + if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) + break; + MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; + } + start--; + } + + end = size - 1; + while (end > 0) + { + int child, root = 0; + MZ_SWAP_UINT32(pIndices[end], pIndices[0]); + for ( ; ; ) + { + if ((child = (root << 1) + 1) >= end) + break; + child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])); + if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) + break; + MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; + } + end--; + } +} + +static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags) +{ + mz_uint cdir_size, num_this_disk, cdir_disk_index; + mz_uint64 cdir_ofs; + mz_int64 cur_file_ofs; + const mz_uint8 *p; + mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; mz_uint8 *pBuf = (mz_uint8 *)buf_u32; + mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); + // Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there. + if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) + return MZ_FALSE; + // Find the end of central directory record by scanning the file from the end towards the beginning. + cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); + for ( ; ; ) + { + int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) + return MZ_FALSE; + for (i = n - 4; i >= 0; --i) + if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) + break; + if (i >= 0) + { + cur_file_ofs += i; + break; + } + if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) + return MZ_FALSE; + cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); + } + // Read and verify the end of central directory record. + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) || + ((pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS))) + return MZ_FALSE; + + num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); + cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); + if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1))) + return MZ_FALSE; + + if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) + return MZ_FALSE; + + cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); + if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) + return MZ_FALSE; + + pZip->m_central_directory_file_ofs = cdir_ofs; + + if (pZip->m_total_files) + { + mz_uint i, n; + + // Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and another to hold the sorted indices. + if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || + (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE))) + return MZ_FALSE; + + if (sort_central_dir) + { + if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) + return MZ_FALSE; + } + + if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size) + return MZ_FALSE; + + // Now create an index into the central directory file records, do some basic sanity checking on each record, and check for zip64 entries (which are not yet supported). + p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; + for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) + { + mz_uint total_header_size, comp_size, decomp_size, disk_index; + if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) + return MZ_FALSE; + MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); + if (sort_central_dir) + MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i; + comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF)) + return MZ_FALSE; + disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); + if ((disk_index != num_this_disk) && (disk_index != 1)) + return MZ_FALSE; + if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) + return MZ_FALSE; + if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n) + return MZ_FALSE; + n -= total_header_size; p += total_header_size; + } + } + + if (sort_central_dir) + mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); + + return MZ_TRUE; +} + +mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags) +{ + if ((!pZip) || (!pZip->m_pRead)) + return MZ_FALSE; + if (!mz_zip_reader_init_internal(pZip, flags)) + return MZ_FALSE; + pZip->m_archive_size = size; + if (!mz_zip_reader_read_central_dir(pZip, flags)) + { + mz_zip_reader_end(pZip); + return MZ_FALSE; + } + return MZ_TRUE; +} + +static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); + memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); + return s; +} + +mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags) +{ + if (!mz_zip_reader_init_internal(pZip, flags)) + return MZ_FALSE; + pZip->m_archive_size = size; + pZip->m_pRead = mz_zip_mem_read_func; + pZip->m_pIO_opaque = pZip; +#ifdef __cplusplus + pZip->m_pState->m_pMem = const_cast(pMem); +#else + pZip->m_pState->m_pMem = (void *)pMem; +#endif + pZip->m_pState->m_mem_size = size; + if (!mz_zip_reader_read_central_dir(pZip, flags)) + { + mz_zip_reader_end(pZip); + return MZ_FALSE; + } + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); + if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) + return 0; + return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); +} + +mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags) +{ + mz_uint64 file_size; + MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb"); + if (!pFile) + return MZ_FALSE; + if (MZ_FSEEK64(pFile, 0, SEEK_END)) + { + MZ_FCLOSE(pFile); + return MZ_FALSE; + } + file_size = MZ_FTELL64(pFile); + if (!mz_zip_reader_init_internal(pZip, flags)) + { + MZ_FCLOSE(pFile); + return MZ_FALSE; + } + pZip->m_pRead = mz_zip_file_read_func; + pZip->m_pIO_opaque = pZip; + pZip->m_pState->m_pFile = pFile; + pZip->m_archive_size = file_size; + if (!mz_zip_reader_read_central_dir(pZip, flags)) + { + mz_zip_reader_end(pZip); + return MZ_FALSE; + } + return MZ_TRUE; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) +{ + return pZip ? pZip->m_total_files : 0; +} + +static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index) +{ + if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return NULL; + return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); +} + +mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index) +{ + mz_uint m_bit_flag; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if (!p) + return MZ_FALSE; + m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); + return (m_bit_flag & 1); +} + +mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index) +{ + mz_uint filename_len, external_attr; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if (!p) + return MZ_FALSE; + + // First see if the filename ends with a '/' character. + filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); + if (filename_len) + { + if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') + return MZ_TRUE; + } + + // Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct. + // Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field. + // FIXME: Remove this check? Is it necessary - we already check the filename. + external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); + if ((external_attr & 0x10) != 0) + return MZ_TRUE; + + return MZ_FALSE; +} + +mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat) +{ + mz_uint n; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if ((!p) || (!pStat)) + return MZ_FALSE; + + // Unpack the central directory record. + pStat->m_file_index = file_index; + pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); + pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); + pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); + pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); + pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); +#ifndef MINIZ_NO_TIME + pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); +#endif + pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); + pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); + pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); + pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); + + // Copy as much of the filename and comment as possible. + n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); + memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pStat->m_filename[n] = '\0'; + + n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); + pStat->m_comment_size = n; + memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0'; + + return MZ_TRUE; +} + +mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size) +{ + mz_uint n; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if (!p) { if (filename_buf_size) pFilename[0] = '\0'; return 0; } + n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); + if (filename_buf_size) + { + n = MZ_MIN(n, filename_buf_size - 1); + memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); + pFilename[n] = '\0'; + } + return n + 1; +} + +static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags) +{ + mz_uint i; + if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) + return 0 == memcmp(pA, pB, len); + for (i = 0; i < len; ++i) + if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) + return MZ_FALSE; + return MZ_TRUE; +} + +static MZ_FORCEINLINE int mz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len) +{ + const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; + mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); + mz_uint8 l = 0, r = 0; + pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; + pE = pL + MZ_MIN(l_len, r_len); + while (pL < pE) + { + if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) + break; + pL++; pR++; + } + return (pL == pE) ? (int)(l_len - r_len) : (l - r); +} + +static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename) +{ + mz_zip_internal_state *pState = pZip->m_pState; + const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; + const mz_zip_array *pCentral_dir = &pState->m_central_dir; + mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); + const int size = pZip->m_total_files; + const mz_uint filename_len = (mz_uint)strlen(pFilename); + int l = 0, h = size - 1; + while (l <= h) + { + int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len); + if (!comp) + return file_index; + else if (comp < 0) + l = m + 1; + else + h = m - 1; + } + return -1; +} + +int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags) +{ + mz_uint file_index; size_t name_len, comment_len; + if ((!pZip) || (!pZip->m_pState) || (!pName) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return -1; + if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) + return mz_zip_reader_locate_file_binary_search(pZip, pName); + name_len = strlen(pName); if (name_len > 0xFFFF) return -1; + comment_len = pComment ? strlen(pComment) : 0; if (comment_len > 0xFFFF) return -1; + for (file_index = 0; file_index < pZip->m_total_files; file_index++) + { + const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); + mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); + const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; + if (filename_len < name_len) + continue; + if (comment_len) + { + mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); + const char *pFile_comment = pFilename + filename_len + file_extra_len; + if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags))) + continue; + } + if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) + { + int ofs = filename_len - 1; + do + { + if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':')) + break; + } while (--ofs >= 0); + ofs++; + pFilename += ofs; filename_len -= ofs; + } + if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags))) + return file_index; + } + return -1; +} + +mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) +{ + int status = TINFL_STATUS_DONE; + mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; + mz_zip_archive_file_stat file_stat; + void *pRead_buf; + mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; + tinfl_decompressor inflator; + + if ((buf_size) && (!pBuf)) + return MZ_FALSE; + + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + + // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) + if (!file_stat.m_comp_size) + return MZ_TRUE; + + // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). + // I'm torn how to handle this case - should it fail instead? + if (mz_zip_reader_is_file_a_directory(pZip, file_index)) + return MZ_TRUE; + + // Encryption and patch files are not supported. + if (file_stat.m_bit_flag & (1 | 32)) + return MZ_FALSE; + + // This function only supports stored and deflate. + if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) + return MZ_FALSE; + + // Ensure supplied output buffer is large enough. + needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; + if (buf_size < needed_size) + return MZ_FALSE; + + // Read and parse the local directory entry. + cur_file_ofs = file_stat.m_local_header_ofs; + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) + return MZ_FALSE; + + cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); + if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) + return MZ_FALSE; + + if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) + { + // The file is stored or the caller has requested the compressed data. + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size) + return MZ_FALSE; + return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32); + } + + // Decompress the file either directly from memory or from a file input buffer. + tinfl_init(&inflator); + + if (pZip->m_pState->m_pMem) + { + // Read directly from the archive in memory. + pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; + read_buf_size = read_buf_avail = file_stat.m_comp_size; + comp_remaining = 0; + } + else if (pUser_read_buf) + { + // Use a user provided read buffer. + if (!user_read_buf_size) + return MZ_FALSE; + pRead_buf = (mz_uint8 *)pUser_read_buf; + read_buf_size = user_read_buf_size; + read_buf_avail = 0; + comp_remaining = file_stat.m_comp_size; + } + else + { + // Temporarily allocate a read buffer. + read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); +#ifdef _MSC_VER + if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) +#else + if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) +#endif + return MZ_FALSE; + if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) + return MZ_FALSE; + read_buf_avail = 0; + comp_remaining = file_stat.m_comp_size; + } + + do + { + size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); + if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) + { + read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + cur_file_ofs += read_buf_avail; + comp_remaining -= read_buf_avail; + read_buf_ofs = 0; + } + in_buf_size = (size_t)read_buf_avail; + status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); + read_buf_avail -= in_buf_size; + read_buf_ofs += in_buf_size; + out_buf_ofs += out_buf_size; + } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); + + if (status == TINFL_STATUS_DONE) + { + // Make sure the entire file was decompressed, and check its CRC. + if ((out_buf_ofs != file_stat.m_uncomp_size) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)) + status = TINFL_STATUS_FAILED; + } + + if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + + return status == TINFL_STATUS_DONE; +} + +mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) +{ + int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); + if (file_index < 0) + return MZ_FALSE; + return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size); +} + +mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) +{ + return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0); +} + +mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) +{ + return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0); +} + +void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) +{ + mz_uint64 comp_size, uncomp_size, alloc_size; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + void *pBuf; + + if (pSize) + *pSize = 0; + if (!p) + return NULL; + + comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + + alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; +#ifdef _MSC_VER + if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) +#else + if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) +#endif + return NULL; + if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) + return NULL; + + if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return NULL; + } + + if (pSize) *pSize = (size_t)alloc_size; + return pBuf; +} + +void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) +{ + int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); + if (file_index < 0) + { + if (pSize) *pSize = 0; + return MZ_FALSE; + } + return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); +} + +mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) +{ + int status = TINFL_STATUS_DONE; mz_uint file_crc32 = MZ_CRC32_INIT; + mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs; + mz_zip_archive_file_stat file_stat; + void *pRead_buf = NULL; void *pWrite_buf = NULL; + mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; + + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + + // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) + if (!file_stat.m_comp_size) + return MZ_TRUE; + + // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). + // I'm torn how to handle this case - should it fail instead? + if (mz_zip_reader_is_file_a_directory(pZip, file_index)) + return MZ_TRUE; + + // Encryption and patch files are not supported. + if (file_stat.m_bit_flag & (1 | 32)) + return MZ_FALSE; + + // This function only supports stored and deflate. + if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) + return MZ_FALSE; + + // Read and parse the local directory entry. + cur_file_ofs = file_stat.m_local_header_ofs; + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) + return MZ_FALSE; + + cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); + if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) + return MZ_FALSE; + + // Decompress the file either directly from memory or from a file input buffer. + if (pZip->m_pState->m_pMem) + { + pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; + read_buf_size = read_buf_avail = file_stat.m_comp_size; + comp_remaining = 0; + } + else + { + read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); + if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) + return MZ_FALSE; + read_buf_avail = 0; + comp_remaining = file_stat.m_comp_size; + } + + if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) + { + // The file is stored or the caller has requested the compressed data. + if (pZip->m_pState->m_pMem) + { +#ifdef _MSC_VER + if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) +#else + if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) +#endif + return MZ_FALSE; + if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) + status = TINFL_STATUS_FAILED; + else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) + file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size); + cur_file_ofs += file_stat.m_comp_size; + out_buf_ofs += file_stat.m_comp_size; + comp_remaining = 0; + } + else + { + while (comp_remaining) + { + read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + + if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) + file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); + + if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + cur_file_ofs += read_buf_avail; + out_buf_ofs += read_buf_avail; + comp_remaining -= read_buf_avail; + } + } + } + else + { + tinfl_decompressor inflator; + tinfl_init(&inflator); + + if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) + status = TINFL_STATUS_FAILED; + else + { + do + { + mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); + size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); + if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) + { + read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + cur_file_ofs += read_buf_avail; + comp_remaining -= read_buf_avail; + read_buf_ofs = 0; + } + + in_buf_size = (size_t)read_buf_avail; + status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); + read_buf_avail -= in_buf_size; + read_buf_ofs += in_buf_size; + + if (out_buf_size) + { + if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size) + { + status = TINFL_STATUS_FAILED; + break; + } + file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); + if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) + { + status = TINFL_STATUS_FAILED; + break; + } + } + } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT)); + } + } + + if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) + { + // Make sure the entire file was decompressed, and check its CRC. + if ((out_buf_ofs != file_stat.m_uncomp_size) || (file_crc32 != file_stat.m_crc32)) + status = TINFL_STATUS_FAILED; + } + + if (!pZip->m_pState->m_pMem) + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + if (pWrite_buf) + pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); + + return status == TINFL_STATUS_DONE; +} + +mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) +{ + int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); + if (file_index < 0) + return MZ_FALSE; + return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags); +} + +#ifndef MINIZ_NO_STDIO +static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n) +{ + (void)ofs; return MZ_FWRITE(pBuf, 1, n, (MZ_FILE*)pOpaque); +} + +mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags) +{ + mz_bool status; + mz_zip_archive_file_stat file_stat; + MZ_FILE *pFile; + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + pFile = MZ_FOPEN(pDst_filename, "wb"); + if (!pFile) + return MZ_FALSE; + status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags); + if (MZ_FCLOSE(pFile) == EOF) + return MZ_FALSE; +#ifndef MINIZ_NO_TIME + if (status) + mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); +#endif + return status; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_bool mz_zip_reader_end(mz_zip_archive *pZip) +{ + if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return MZ_FALSE; + + if (pZip->m_pState) + { + mz_zip_internal_state *pState = pZip->m_pState; pZip->m_pState = NULL; + mz_zip_array_clear(pZip, &pState->m_central_dir); + mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); + mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); + +#ifndef MINIZ_NO_STDIO + if (pState->m_pFile) + { + MZ_FCLOSE(pState->m_pFile); + pState->m_pFile = NULL; + } +#endif // #ifndef MINIZ_NO_STDIO + + pZip->m_pFree(pZip->m_pAlloc_opaque, pState); + } + pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; + + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) +{ + int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); + if (file_index < 0) + return MZ_FALSE; + return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); +} +#endif + +// ------------------- .ZIP archive writing + +#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); } +static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); p[2] = (mz_uint8)(v >> 16); p[3] = (mz_uint8)(v >> 24); } +#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) +#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) + +mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) +{ + if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) + return MZ_FALSE; + + if (pZip->m_file_offset_alignment) + { + // Ensure user specified file offset alignment is a power of 2. + if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) + return MZ_FALSE; + } + + if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; + if (!pZip->m_pFree) pZip->m_pFree = def_free_func; + if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; + + pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; + pZip->m_archive_size = existing_size; + pZip->m_central_directory_file_ofs = 0; + pZip->m_total_files = 0; + + if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) + return MZ_FALSE; + memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); + return MZ_TRUE; +} + +static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + mz_zip_internal_state *pState = pZip->m_pState; + mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); +#ifdef _MSC_VER + if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) +#else + if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) +#endif + return 0; + if (new_size > pState->m_mem_capacity) + { + void *pNew_block; + size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2; + if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) + return 0; + pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity; + } + memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); + pState->m_mem_size = (size_t)new_size; + return n; +} + +mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size) +{ + pZip->m_pWrite = mz_zip_heap_write_func; + pZip->m_pIO_opaque = pZip; + if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) + return MZ_FALSE; + if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning))) + { + if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size))) + { + mz_zip_writer_end(pZip); + return MZ_FALSE; + } + pZip->m_pState->m_mem_capacity = initial_allocation_size; + } + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); + if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) + return 0; + return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); +} + +mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning) +{ + MZ_FILE *pFile; + pZip->m_pWrite = mz_zip_file_write_func; + pZip->m_pIO_opaque = pZip; + if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) + return MZ_FALSE; + if (NULL == (pFile = MZ_FOPEN(pFilename, "wb"))) + { + mz_zip_writer_end(pZip); + return MZ_FALSE; + } + pZip->m_pState->m_pFile = pFile; + if (size_to_reserve_at_beginning) + { + mz_uint64 cur_ofs = 0; char buf[4096]; MZ_CLEAR_OBJ(buf); + do + { + size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) + { + mz_zip_writer_end(pZip); + return MZ_FALSE; + } + cur_ofs += n; size_to_reserve_at_beginning -= n; + } while (size_to_reserve_at_beginning); + } + return MZ_TRUE; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename) +{ + mz_zip_internal_state *pState; + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return MZ_FALSE; + // No sense in trying to write to an archive that's already at the support max size + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) + return MZ_FALSE; + + pState = pZip->m_pState; + + if (pState->m_pFile) + { +#ifdef MINIZ_NO_STDIO + pFilename; return MZ_FALSE; +#else + // Archive is being read from stdio - try to reopen as writable. + if (pZip->m_pIO_opaque != pZip) + return MZ_FALSE; + if (!pFilename) + return MZ_FALSE; + pZip->m_pWrite = mz_zip_file_write_func; + if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) + { + // The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it. + mz_zip_reader_end(pZip); + return MZ_FALSE; + } +#endif // #ifdef MINIZ_NO_STDIO + } + else if (pState->m_pMem) + { + // Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback. + if (pZip->m_pIO_opaque != pZip) + return MZ_FALSE; + pState->m_mem_capacity = pState->m_mem_size; + pZip->m_pWrite = mz_zip_heap_write_func; + } + // Archive is being read via a user provided read function - make sure the user has specified a write function too. + else if (!pZip->m_pWrite) + return MZ_FALSE; + + // Start writing new files at the archive's current central directory location. + pZip->m_archive_size = pZip->m_central_directory_file_ofs; + pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; + pZip->m_central_directory_file_ofs = 0; + + return MZ_TRUE; +} + +mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) +{ + return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); +} + +typedef struct +{ + mz_zip_archive *m_pZip; + mz_uint64 m_cur_archive_file_ofs; + mz_uint64 m_comp_size; +} mz_zip_writer_add_state; + +static mz_bool mz_zip_writer_add_put_buf_callback(const void* pBuf, int len, void *pUser) +{ + mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; + if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len) + return MZ_FALSE; + pState->m_cur_archive_file_ofs += len; + pState->m_comp_size += len; + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date) +{ + (void)pZip; + memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) +{ + (void)pZip; + memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs); + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) +{ + mz_zip_internal_state *pState = pZip->m_pState; + mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; + size_t orig_central_dir_size = pState->m_central_dir.m_size; + mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; + + // No zip64 support yet + if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) + return MZ_FALSE; + + if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1))) + { + // Try to push the central directory array back into its original state. + mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); + return MZ_FALSE; + } + + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) +{ + // Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes. + if (*pArchive_name == '/') + return MZ_FALSE; + while (*pArchive_name) + { + if ((*pArchive_name == '\\') || (*pArchive_name == ':')) + return MZ_FALSE; + pArchive_name++; + } + return MZ_TRUE; +} + +static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) +{ + mz_uint32 n; + if (!pZip->m_file_offset_alignment) + return 0; + n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); + return (pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1); +} + +static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) +{ + char buf[4096]; + memset(buf, 0, MZ_MIN(sizeof(buf), n)); + while (n) + { + mz_uint32 s = MZ_MIN(sizeof(buf), n); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) + return MZ_FALSE; + cur_file_ofs += s; n -= s; + } + return MZ_TRUE; +} + +mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32) +{ + mz_uint16 method = 0, dos_time = 0, dos_date = 0; + mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; + mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; + size_t archive_name_size; + mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; + tdefl_compressor *pComp = NULL; + mz_bool store_data_uncompressed; + mz_zip_internal_state *pState; + + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + level = level_and_flags & 0xF; + store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION)) + return MZ_FALSE; + + pState = pZip->m_pState; + + if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) + return MZ_FALSE; + // No zip64 support yet + if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) + return MZ_FALSE; + if (!mz_zip_writer_validate_archive_name(pArchive_name)) + return MZ_FALSE; + +#ifndef MINIZ_NO_TIME + { + time_t cur_time; time(&cur_time); + mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date); + } +#endif // #ifndef MINIZ_NO_TIME + + archive_name_size = strlen(pArchive_name); + if (archive_name_size > 0xFFFF) + return MZ_FALSE; + + num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); + + // no zip64 support yet + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) + return MZ_FALSE; + + if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) + { + // Set DOS Subdirectory attribute bit. + ext_attributes |= 0x10; + // Subdirectories cannot contain data. + if ((buf_size) || (uncomp_size)) + return MZ_FALSE; + } + + // Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.) + if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) + return MZ_FALSE; + + if ((!store_data_uncompressed) && (buf_size)) + { + if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) + return MZ_FALSE; + } + + if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + local_dir_header_ofs += num_alignment_padding_bytes; + if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } + cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); + + MZ_CLEAR_OBJ(local_dir_header); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + cur_archive_file_ofs += archive_name_size; + + if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) + { + uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8*)pBuf, buf_size); + uncomp_size = buf_size; + if (uncomp_size <= 3) + { + level = 0; + store_data_uncompressed = MZ_TRUE; + } + } + + if (store_data_uncompressed) + { + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + + cur_archive_file_ofs += buf_size; + comp_size = buf_size; + + if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) + method = MZ_DEFLATED; + } + else if (buf_size) + { + mz_zip_writer_add_state state; + + state.m_pZip = pZip; + state.m_cur_archive_file_ofs = cur_archive_file_ofs; + state.m_comp_size = 0; + + if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) || + (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + + comp_size = state.m_comp_size; + cur_archive_file_ofs = state.m_cur_archive_file_ofs; + + method = MZ_DEFLATED; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + pComp = NULL; + + // no zip64 support yet + if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) + return MZ_FALSE; + + if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) + return MZ_FALSE; + + if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) + return MZ_FALSE; + + pZip->m_total_files++; + pZip->m_archive_size = cur_archive_file_ofs; + + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) +{ + mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; + mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; + mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; + size_t archive_name_size; + mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; + MZ_FILE *pSrc_file = NULL; + + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + level = level_and_flags & 0xF; + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) + return MZ_FALSE; + if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) + return MZ_FALSE; + if (!mz_zip_writer_validate_archive_name(pArchive_name)) + return MZ_FALSE; + + archive_name_size = strlen(pArchive_name); + if (archive_name_size > 0xFFFF) + return MZ_FALSE; + + num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); + + // no zip64 support yet + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) + return MZ_FALSE; + + pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); + if (!pSrc_file) + return MZ_FALSE; + MZ_FSEEK64(pSrc_file, 0, SEEK_END); + uncomp_size = MZ_FTELL64(pSrc_file); + MZ_FSEEK64(pSrc_file, 0, SEEK_SET); + + if (uncomp_size > 0xFFFFFFFF) + { + // No zip64 support yet + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + if (uncomp_size <= 3) + level = 0; + + if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) + { + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + local_dir_header_ofs += num_alignment_padding_bytes; + if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } + cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); + + MZ_CLEAR_OBJ(local_dir_header); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) + { + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + cur_archive_file_ofs += archive_name_size; + + if (uncomp_size) + { + mz_uint64 uncomp_remaining = uncomp_size; + void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); + if (!pRead_buf) + { + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + if (!level) + { + while (uncomp_remaining) + { + mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); + if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); + uncomp_remaining -= n; + cur_archive_file_ofs += n; + } + comp_size = uncomp_size; + } + else + { + mz_bool result = MZ_FALSE; + mz_zip_writer_add_state state; + tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); + if (!pComp) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + state.m_pZip = pZip; + state.m_cur_archive_file_ofs = cur_archive_file_ofs; + state.m_comp_size = 0; + + if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + for ( ; ; ) + { + size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE); + tdefl_status status; + + if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) + break; + + uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); + uncomp_remaining -= in_buf_size; + + status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); + if (status == TDEFL_STATUS_DONE) + { + result = MZ_TRUE; + break; + } + else if (status != TDEFL_STATUS_OKAY) + break; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + + if (!result) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + comp_size = state.m_comp_size; + cur_archive_file_ofs = state.m_cur_archive_file_ofs; + + method = MZ_DEFLATED; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + } + + MZ_FCLOSE(pSrc_file); pSrc_file = NULL; + + // no zip64 support yet + if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) + return MZ_FALSE; + + if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) + return MZ_FALSE; + + if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) + return MZ_FALSE; + + pZip->m_total_files++; + pZip->m_archive_size = cur_archive_file_ofs; + + return MZ_TRUE; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index) +{ + mz_uint n, bit_flags, num_alignment_padding_bytes; + mz_uint64 comp_bytes_remaining, local_dir_header_ofs; + mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; + mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; + mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; + size_t orig_central_dir_size; + mz_zip_internal_state *pState; + void *pBuf; const mz_uint8 *pSrc_central_header; + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) + return MZ_FALSE; + if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index))) + return MZ_FALSE; + pState = pZip->m_pState; + + num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); + + // no zip64 support yet + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) + return MZ_FALSE; + + cur_src_file_ofs = MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS); + cur_dst_file_ofs = pZip->m_archive_size; + + if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) + return MZ_FALSE; + cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; + + if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes)) + return MZ_FALSE; + cur_dst_file_ofs += num_alignment_padding_bytes; + local_dir_header_ofs = cur_dst_file_ofs; + if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } + + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; + + n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); + comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + + if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining))))) + return MZ_FALSE; + + while (comp_bytes_remaining) + { + n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining); + if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + cur_src_file_ofs += n; + + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + cur_dst_file_ofs += n; + + comp_bytes_remaining -= n; + } + + bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); + if (bit_flags & 8) + { + // Copy data descriptor + if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + + n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + + cur_src_file_ofs += n; + cur_dst_file_ofs += n; + } + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + + // no zip64 support yet + if (cur_dst_file_ofs > 0xFFFFFFFF) + return MZ_FALSE; + + orig_central_dir_size = pState->m_central_dir.m_size; + + memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); + MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs); + if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) + return MZ_FALSE; + + n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); + if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) + { + mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); + return MZ_FALSE; + } + + if (pState->m_central_dir.m_size > 0xFFFFFFFF) + return MZ_FALSE; + n = (mz_uint32)orig_central_dir_size; + if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) + { + mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); + return MZ_FALSE; + } + + pZip->m_total_files++; + pZip->m_archive_size = cur_dst_file_ofs; + + return MZ_TRUE; +} + +mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) +{ + mz_zip_internal_state *pState; + mz_uint64 central_dir_ofs, central_dir_size; + mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE]; + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) + return MZ_FALSE; + + pState = pZip->m_pState; + + // no zip64 support yet + if ((pZip->m_total_files > 0xFFFF) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) + return MZ_FALSE; + + central_dir_ofs = 0; + central_dir_size = 0; + if (pZip->m_total_files) + { + // Write central directory + central_dir_ofs = pZip->m_archive_size; + central_dir_size = pState->m_central_dir.m_size; + pZip->m_central_directory_file_ofs = central_dir_ofs; + if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size) + return MZ_FALSE; + pZip->m_archive_size += central_dir_size; + } + + // Write end of central directory record + MZ_CLEAR_OBJ(hdr); + MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); + MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files); + MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); + MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size); + MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs); + + if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, sizeof(hdr)) != sizeof(hdr)) + return MZ_FALSE; +#ifndef MINIZ_NO_STDIO + if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) + return MZ_FALSE; +#endif // #ifndef MINIZ_NO_STDIO + + pZip->m_archive_size += sizeof(hdr); + + pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; + return MZ_TRUE; +} + +mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize) +{ + if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) + return MZ_FALSE; + if (pZip->m_pWrite != mz_zip_heap_write_func) + return MZ_FALSE; + if (!mz_zip_writer_finalize_archive(pZip)) + return MZ_FALSE; + + *pBuf = pZip->m_pState->m_pMem; + *pSize = pZip->m_pState->m_mem_size; + pZip->m_pState->m_pMem = NULL; + pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; + return MZ_TRUE; +} + +mz_bool mz_zip_writer_end(mz_zip_archive *pZip) +{ + mz_zip_internal_state *pState; + mz_bool status = MZ_TRUE; + if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) + return MZ_FALSE; + + pState = pZip->m_pState; + pZip->m_pState = NULL; + mz_zip_array_clear(pZip, &pState->m_central_dir); + mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); + mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); + +#ifndef MINIZ_NO_STDIO + if (pState->m_pFile) + { + MZ_FCLOSE(pState->m_pFile); + pState->m_pFile = NULL; + } +#endif // #ifndef MINIZ_NO_STDIO + + if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); + pState->m_pMem = NULL; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pState); + pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; + return status; +} + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) +{ + mz_bool status, created_new_archive = MZ_FALSE; + mz_zip_archive zip_archive; + struct MZ_FILE_STAT_STRUCT file_stat; + MZ_CLEAR_OBJ(zip_archive); + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) + return MZ_FALSE; + if (!mz_zip_writer_validate_archive_name(pArchive_name)) + return MZ_FALSE; + if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) + { + // Create a new archive. + if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0)) + return MZ_FALSE; + created_new_archive = MZ_TRUE; + } + else + { + // Append to an existing archive. + if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) + return MZ_FALSE; + if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) + { + mz_zip_reader_end(&zip_archive); + return MZ_FALSE; + } + } + status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0); + // Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) + if (!mz_zip_writer_finalize_archive(&zip_archive)) + status = MZ_FALSE; + if (!mz_zip_writer_end(&zip_archive)) + status = MZ_FALSE; + if ((!status) && (created_new_archive)) + { + // It's a new archive and something went wrong, so just delete it. + int ignoredStatus = MZ_DELETE_FILE(pZip_filename); + (void)ignoredStatus; + } + return status; +} + +void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags) +{ + int file_index; + mz_zip_archive zip_archive; + void *p = NULL; + + if (pSize) + *pSize = 0; + + if ((!pZip_filename) || (!pArchive_name)) + return NULL; + + MZ_CLEAR_OBJ(zip_archive); + if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) + return NULL; + + if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, flags)) >= 0) + p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); + + mz_zip_reader_end(&zip_archive); + return p; +} + +#endif // #ifndef MINIZ_NO_STDIO + +#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +#endif // #ifndef MINIZ_NO_ARCHIVE_APIS + +#ifdef __cplusplus +} +#endif + +#endif // MINIZ_HEADER_FILE_ONLY + +/* + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or + distribute this software, either in source code form or as a compiled + binary, for any purpose, commercial or non-commercial, and by any + means. + + In jurisdictions that recognize copyright laws, the author or authors + of this software dedicate any and all copyright interest in the + software to the public domain. We make this dedication for the benefit + of the public at large and to the detriment of our heirs and + successors. We intend this dedication to be an overt act of + relinquishment in perpetuity of all present and future rights to this + software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + For more information, please refer to +*/ diff --git a/deps/num_cpus-0.2.6/.gitignore b/deps/num_cpus-0.2.6/.gitignore new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/deps/num_cpus-0.2.6/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/deps/num_cpus-0.2.6/Cargo.toml b/deps/num_cpus-0.2.6/Cargo.toml new file mode 100644 index 000000000..298261d62 --- /dev/null +++ b/deps/num_cpus-0.2.6/Cargo.toml @@ -0,0 +1,12 @@ +[package] + +name = "num_cpus" +version = "0.2.6" +description = "Get the number of CPUs on a machine." +authors = ["Sean McArthur "] +license = "MIT" +repository = "https://github.com/seanmonstar/num_cpus" + + +[dependencies] +libc = "0.1.7" diff --git a/deps/num_cpus-0.2.6/LICENSE b/deps/num_cpus-0.2.6/LICENSE new file mode 100644 index 000000000..8e91dc998 --- /dev/null +++ b/deps/num_cpus-0.2.6/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/deps/num_cpus-0.2.6/README.md b/deps/num_cpus-0.2.6/README.md new file mode 100644 index 000000000..ba370c69b --- /dev/null +++ b/deps/num_cpus-0.2.6/README.md @@ -0,0 +1,25 @@ +# num_cpus + +A replacement for the deprecated `std::os::num_cpus`. + +## Usage + +Add to Cargo.toml: + +``` +[dependencies] +num_cpus = "*" +``` + +In your `main.rs` or `lib.rs`: + +```rust +extern crate num_cpus; + +// elsewhere +let num = num_cpus::get(); +``` + +## License + +MIT diff --git a/deps/num_cpus-0.2.6/src/lib.rs b/deps/num_cpus-0.2.6/src/lib.rs new file mode 100644 index 000000000..8f17464df --- /dev/null +++ b/deps/num_cpus-0.2.6/src/lib.rs @@ -0,0 +1,96 @@ +//! Replaces the deprecated functionality of std::os::num_cpus. +#![cfg_attr(test, deny(warnings))] +#![deny(missing_docs)] + +extern crate libc; + +/// Returns the number of CPUs of the current machine. +#[inline] +pub fn get() -> usize { + get_num_cpus() +} + +#[cfg(windows)] +fn get_num_cpus() -> usize { + unsafe { + let mut sysinfo: libc::SYSTEM_INFO = ::std::mem::uninitialized(); + libc::GetSystemInfo(&mut sysinfo); + sysinfo.dwNumberOfProcessors as usize + } +} + +#[cfg( + any( + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd" + ) +)] +fn get_num_cpus() -> usize { + use libc::{c_int, c_uint}; + use libc::funcs::bsd44::sysctl; + use std::ptr; + + //XXX: uplift to libc? + const CTL_HW: c_int = 6; + const HW_AVAILCPU: c_int = 25; + const HW_NCPU: c_int = 3; + + let mut cpus: c_uint = 0; + let mut CPUS_SIZE = ::std::mem::size_of::(); + let mut mib: [c_int; 4] = [CTL_HW, HW_AVAILCPU, 0, 0]; + + unsafe { + sysctl(mib.as_mut_ptr(), 2, + &mut cpus as *mut _ as *mut _, &mut CPUS_SIZE as *mut _ as *mut _, + ptr::null_mut(), 0); + } + + if cpus < 1 { + mib[1] = HW_NCPU; + unsafe { + sysctl(mib.as_mut_ptr(), 2, + &mut cpus as *mut _ as *mut _, &mut CPUS_SIZE as *mut _ as *mut _, + ptr::null_mut(), 0); + } + if cpus < 1 { + cpus = 1; + } + } + + cpus as usize +} + +#[cfg( + any( + target_os = "linux", + target_os = "nacl", + target_os = "macos", + target_os = "ios" + ) +)] +fn get_num_cpus() -> usize { + unsafe { + libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize + } +} + +#[cfg(target_os= "android")] +fn get_num_cpus() -> usize { + //to-do: replace with libc::_SC_NPROCESSORS_ONLN once available + unsafe { + libc::sysconf(97) as usize + } +} + +#[test] +fn lower_bound() { + assert!(get() > 0); +} + + +#[test] +fn upper_bound() { + assert!(get() < 236_451); +} diff --git a/deps/openssl-sys-0.6.3/Cargo.toml b/deps/openssl-sys-0.6.3/Cargo.toml new file mode 100644 index 000000000..f3fbfc182 --- /dev/null +++ b/deps/openssl-sys-0.6.3/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "openssl-sys" +version = "0.6.3" +authors = ["Alex Crichton ", + "Steven Fackler "] +license = "MIT" +description = "FFI bindings to OpenSSL" +repository = "https://github.com/sfackler/rust-openssl" +documentation = "https://sfackler.github.io/rust-openssl/doc/v0.6.3/openssl_sys" + +links = "openssl" +build = "build.rs" + +[features] +tlsv1_2 = [] +tlsv1_1 = [] +dtlsv1 = [] +dtlsv1_2 = [] +sslv2 = [] +aes_xts = [] +npn = [] + +[dependencies] +libc = "0.1" + +[build-dependencies] +pkg-config = "0.3" +gcc = "0.3" + +[target.le32-unknown-nacl.dependencies] +libressl-pnacl-sys = "2.1.0" +[target.x86_64-unknown-nacl.dependencies] +libressl-pnacl-sys = "2.1.0" +[target.i686-unknown-nacl.dependencies] +libressl-pnacl-sys = "2.1.0" +[target.arm-unknown-nacl.dependencies] +libressl-pnacl-sys = "2.1.0" diff --git a/deps/openssl-sys-0.6.3/LICENSE-MIT b/deps/openssl-sys-0.6.3/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/openssl-sys-0.6.3/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/openssl-sys-0.6.3/build.rs b/deps/openssl-sys-0.6.3/build.rs new file mode 100644 index 000000000..de43c462f --- /dev/null +++ b/deps/openssl-sys-0.6.3/build.rs @@ -0,0 +1,95 @@ +extern crate pkg_config; +extern crate gcc; + +use std::env; +use std::path::PathBuf; + +fn main() { + let target = env::var("TARGET").unwrap(); + + // libressl_pnacl_sys links the libs needed. + if target.ends_with("nacl") { return; } + + let lib_dir = env::var("OPENSSL_LIB_DIR").ok(); + let include_dir = env::var("OPENSSL_INCLUDE_DIR").ok(); + + if lib_dir.is_none() && include_dir.is_none() { + if let Ok(info) = pkg_config::find_library("openssl") { + build_old_openssl_shim(&info.include_paths); + return; + } + if let Some(mingw_paths) = get_mingw_in_path() { + for path in mingw_paths { + println!("cargo:rustc-flags=-L native={}", path); + } + } + } + + let libs_env = env::var("OPENSSL_LIBS").ok(); + let libs = match libs_env { + Some(ref v) => v.split(":").collect(), + None => if target.contains("windows") { + if get_mingw_in_path().is_some() && lib_dir.is_none() && include_dir.is_none() { + vec!("eay32", "ssleay32") + } else { + vec!("eay32", "ssl32") + } + } else { + vec!("crypto", "ssl") + } + }; + + let mode = if env::var_os("OPENSSL_STATIC").is_some() { + "static" + } else { + "dylib" + }; + + if let Some(lib_dir) = lib_dir { + println!("cargo:rustc-flags=-L native={}", lib_dir); + } + + let libs_arg = libs.iter().fold(String::new(), |args, lib| args + &format!(" -l {0}={1}", mode, lib)); + println!("cargo:rustc-flags={0}", libs_arg); + + let mut include_dirs = vec![]; + + if let Some(include_dir) = include_dir { + include_dirs.push(PathBuf::from(&include_dir)); + } + + build_old_openssl_shim(&include_dirs); +} + +fn build_old_openssl_shim(include_paths: &[PathBuf]) { + let mut config = gcc::Config::new(); + + for path in include_paths { + config.include(path); + } + + config.file("src/old_openssl_shim.c") + .compile("libold_openssl_shim.a"); +} + +fn get_mingw_in_path() -> Option> { + match env::var_os("PATH") { + Some(env_path) => { + let paths: Vec = env::split_paths(&env_path).filter_map(|path| { + use std::ascii::AsciiExt; + + match path.to_str() { + Some(path_str) => { + if path_str.to_ascii_lowercase().contains("mingw") { + Some(path_str.to_string()) + } else { None } + }, + None => None + } + }).collect(); + + if paths.len() > 0 { Some(paths) } else { None } + }, + None => None + } +} diff --git a/deps/openssl-sys-0.6.3/src/lib.rs b/deps/openssl-sys-0.6.3/src/lib.rs new file mode 100644 index 000000000..d77264bec --- /dev/null +++ b/deps/openssl-sys-0.6.3/src/lib.rs @@ -0,0 +1,615 @@ +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow(dead_code)] +#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.6.3")] + +extern crate libc; + +#[cfg(target_os = "nacl")] +extern crate libressl_pnacl_sys; + +use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t}; +use std::mem; +use std::ptr; +use std::sync::{Mutex, MutexGuard}; +use std::sync::{Once, ONCE_INIT}; + +pub type ASN1_INTEGER = c_void; +pub type ASN1_STRING = c_void; +pub type ASN1_TIME = c_void; +pub type BIO = c_void; +pub type BIO_METHOD = c_void; +pub type BN_CTX = c_void; +pub type COMP_METHOD = c_void; +pub type CRYPTO_EX_DATA = c_void; +pub type ENGINE = c_void; +pub type EVP_CIPHER = c_void; +pub type EVP_CIPHER_CTX = c_void; +pub type EVP_MD = c_void; +pub type EVP_PKEY = c_void; +pub type EVP_PKEY_CTX = c_void; +pub type RSA = c_void; +pub type SSL = c_void; +pub type SSL_CTX = c_void; +pub type SSL_METHOD = c_void; +pub type X509 = c_void; +pub type X509_CRL = c_void; +pub type X509_EXTENSION = c_void; +pub type X509_NAME = c_void; +pub type X509_NAME_ENTRY = c_void; +pub type X509_REQ = c_void; +pub type X509_STORE_CTX = c_void; + +#[repr(C)] +pub struct EVP_MD_CTX { + digest: *mut EVP_MD, + engine: *mut c_void, + flags: c_ulong, + md_data: *mut c_void, + pctx: *mut EVP_PKEY_CTX, + update: *mut c_void +} + +impl Copy for EVP_MD_CTX {} +impl Clone for EVP_MD_CTX { + fn clone(&self) -> EVP_MD_CTX { *self } +} + +#[repr(C)] +pub struct HMAC_CTX { + md: *mut EVP_MD, + md_ctx: EVP_MD_CTX, + i_ctx: EVP_MD_CTX, + o_ctx: EVP_MD_CTX, + key_length: c_uint, + key: [c_uchar; 128] +} + +impl Copy for HMAC_CTX {} +impl Clone for HMAC_CTX { + fn clone(&self) -> HMAC_CTX { *self } +} + +#[repr(C)] +pub struct X509V3_CTX { + flags: c_int, + issuer_cert: *mut c_void, + subject_cert: *mut c_void, + subject_req: *mut c_void, + crl: *mut c_void, + db_meth: *mut c_void, + db: *mut c_void, + // I like the last comment line, it is copied from OpenSSL sources: + // Maybe more here +} + +impl Copy for X509V3_CTX {} +impl Clone for X509V3_CTX { + fn clone(&self) -> X509V3_CTX { *self } +} + +#[repr(C)] +pub struct BIGNUM { + pub d: *mut c_void, + pub top: c_int, + pub dmax: c_int, + pub neg: c_int, + pub flags: c_int, +} + +impl Copy for BIGNUM {} +impl Clone for BIGNUM { + fn clone(&self) -> BIGNUM { *self } +} + +pub type CRYPTO_EX_new = extern "C" fn(parent: *mut c_void, ptr: *mut c_void, + ad: *const CRYPTO_EX_DATA, idx: c_int, + argl: c_long, argp: *const c_void) -> c_int; +pub type CRYPTO_EX_dup = extern "C" fn(to: *mut CRYPTO_EX_DATA, + from: *mut CRYPTO_EX_DATA, from_d: *mut c_void, + idx: c_int, argl: c_long, argp: *mut c_void) + -> c_int; +pub type CRYPTO_EX_free = extern "C" fn(parent: *mut c_void, ptr: *mut c_void, + ad: *mut CRYPTO_EX_DATA, idx: c_int, + argl: c_long, argp: *mut c_void); +pub type PasswordCallback = extern "C" fn(buf: *mut c_char, size: c_int, + rwflag: c_int, user_data: *mut c_void) + -> c_int; + +pub const BIO_CTRL_EOF: c_int = 2; +pub const BIO_C_SET_BUF_MEM_EOF_RETURN: c_int = 130; + +pub const CRYPTO_LOCK: c_int = 1; + +pub const MBSTRING_ASC: c_int = MBSTRING_FLAG | 1; +pub const MBSTRING_BMP: c_int = MBSTRING_FLAG | 2; +pub const MBSTRING_FLAG: c_int = 0x1000; +pub const MBSTRING_UNIV: c_int = MBSTRING_FLAG | 4; +pub const MBSTRING_UTF8: c_int = MBSTRING_FLAG; + +pub const NID_ext_key_usage: c_int = 126; +pub const NID_key_usage: c_int = 83; + +pub const SSL_CTRL_OPTIONS: c_int = 32; +pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; + +pub const SSL_CTRL_SET_TLSEXT_HOSTNAME: c_int = 55; +pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14; + +pub const SSL_CTRL_SET_READ_AHEAD: c_int = 41; +pub const SSL_ERROR_NONE: c_int = 0; +pub const SSL_ERROR_SSL: c_int = 1; +pub const SSL_ERROR_SYSCALL: c_int = 5; +pub const SSL_ERROR_WANT_ACCEPT: c_int = 8; +pub const SSL_ERROR_WANT_CONNECT: c_int = 7; +pub const SSL_ERROR_WANT_READ: c_int = 2; +pub const SSL_ERROR_WANT_WRITE: c_int = 3; +pub const SSL_ERROR_WANT_X509_LOOKUP: c_int = 4; +pub const SSL_ERROR_ZERO_RETURN: c_int = 6; +pub const SSL_VERIFY_NONE: c_int = 0; +pub const SSL_VERIFY_PEER: c_int = 1; +pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT: c_int = 2; + +pub const TLSEXT_NAMETYPE_host_name: c_long = 0; + +pub const SSL_TLSEXT_ERR_OK: c_int = 0; +pub const SSL_TLSEXT_ERR_ALERT_WARNING: c_int = 1; +pub const SSL_TLSEXT_ERR_ALERT_FATAL: c_int = 2; +pub const SSL_TLSEXT_ERR_NOACK: c_int = 3; + +#[cfg(feature = "npn")] +pub const OPENSSL_NPN_UNSUPPORTED: c_int = 0; +#[cfg(feature = "npn")] +pub const OPENSSL_NPN_NEGOTIATED: c_int = 1; +#[cfg(feature = "npn")] +pub const OPENSSL_NPN_NO_OVERLAP: c_int = 2; + +pub const V_ASN1_GENERALIZEDTIME: c_int = 24; +pub const V_ASN1_UTCTIME: c_int = 23; + +pub const X509_FILETYPE_ASN1: c_int = 2; +pub const X509_FILETYPE_DEFAULT: c_int = 3; +pub const X509_FILETYPE_PEM: c_int = 1; +pub const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: c_int = 31; +pub const X509_V_ERR_AKID_SKID_MISMATCH: c_int = 30; +pub const X509_V_ERR_APPLICATION_VERIFICATION: c_int = 50; +pub const X509_V_ERR_CERT_CHAIN_TOO_LONG: c_int = 22; +pub const X509_V_ERR_CERT_HAS_EXPIRED: c_int = 10; +pub const X509_V_ERR_CERT_NOT_YET_VALID: c_int = 9; +pub const X509_V_ERR_CERT_REJECTED: c_int = 28; +pub const X509_V_ERR_CERT_REVOKED: c_int = 23; +pub const X509_V_ERR_CERT_SIGNATURE_FAILURE: c_int = 7; +pub const X509_V_ERR_CERT_UNTRUSTED: c_int = 27; +pub const X509_V_ERR_CRL_HAS_EXPIRED: c_int = 12; +pub const X509_V_ERR_CRL_NOT_YET_VALID: c_int = 11; +pub const X509_V_ERR_CRL_PATH_VALIDATION_ERROR: c_int = 54; +pub const X509_V_ERR_CRL_SIGNATURE_FAILURE: c_int = 8; +pub const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: c_int = 18; +pub const X509_V_ERR_DIFFERENT_CRL_SCOPE: c_int = 44; +pub const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: c_int = 14; +pub const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: c_int = 13; +pub const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: c_int = 15; +pub const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: c_int = 16; +pub const X509_V_ERR_EXCLUDED_VIOLATION: c_int = 48; +pub const X509_V_ERR_INVALID_CA: c_int = 24; +pub const X509_V_ERR_INVALID_EXTENSION: c_int = 41; +pub const X509_V_ERR_INVALID_NON_CA: c_int = 37; +pub const X509_V_ERR_INVALID_POLICY_EXTENSION: c_int = 42; +pub const X509_V_ERR_INVALID_PURPOSE: c_int = 26; +pub const X509_V_ERR_KEYUSAGE_NO_CERTSIGN: c_int = 32; +pub const X509_V_ERR_KEYUSAGE_NO_CRL_SIGN: c_int = 35; +pub const X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: c_int = 39; +pub const X509_V_ERR_NO_EXPLICIT_POLICY: c_int = 43; +pub const X509_V_ERR_OUT_OF_MEM: c_int = 17; +pub const X509_V_ERR_PATH_LENGTH_EXCEEDED: c_int = 25; +pub const X509_V_ERR_PERMITTED_VIOLATION: c_int = 47; +pub const X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: c_int = 40; +pub const X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: c_int = 38; +pub const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: c_int = 19; +pub const X509_V_ERR_SUBJECT_ISSUER_MISMATCH: c_int = 29; +pub const X509_V_ERR_SUBTREE_MINMAX: c_int = 49; +pub const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: c_int = 6; +pub const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: c_int = 4; +pub const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: c_int = 5; +pub const X509_V_ERR_UNABLE_TO_GET_CRL: c_int = 3; +pub const X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: c_int = 33; +pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: c_int = 2; +pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: c_int = 20; +pub const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: c_int = 21; +pub const X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION: c_int = 36; +pub const X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: c_int = 34; +pub const X509_V_ERR_UNNESTED_RESOURCE: c_int = 46; +pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: c_int = 52; +pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: c_int = 51; +pub const X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: c_int = 45; +pub const X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: c_int = 53; +pub const X509_V_OK: c_int = 0; + +static mut MUTEXES: *mut Vec> = 0 as *mut Vec>; +static mut GUARDS: *mut Vec>> = 0 as *mut Vec>>; + +extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char, + _line: c_int) { + unsafe { + let mutex = &(*MUTEXES)[n as usize]; + + if mode & CRYPTO_LOCK != 0 { + (*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); + } else { + &(*GUARDS)[n as usize].take(); + } + } +} + +pub fn init() { + static mut INIT: Once = ONCE_INIT; + + unsafe { + INIT.call_once(|| { + SSL_library_init(); + SSL_load_error_strings(); + + let num_locks = CRYPTO_num_locks(); + let mut mutexes = Box::new(Vec::new()); + for _ in 0..num_locks { + mutexes.push(Mutex::new(())); + } + MUTEXES = mem::transmute(mutexes); + let guards: Box>>> = + Box::new((0..num_locks).map(|_| None).collect()); + GUARDS = mem::transmute(guards); + + CRYPTO_set_locking_callback(locking_function); + }) + } +} + +// Functions converted from macros +pub unsafe fn BIO_eof(b: *mut BIO) -> bool { + BIO_ctrl(b, BIO_CTRL_EOF, 0, ptr::null_mut()) == 1 +} + +pub unsafe fn SSL_CTX_set_options(ssl: *mut SSL_CTX, op: c_long) -> c_long { + SSL_CTX_ctrl(ssl, SSL_CTRL_OPTIONS, op, ptr::null_mut()) +} + +pub unsafe fn BIO_set_mem_eof_return(b: *mut BIO, v: c_int) { + BIO_ctrl(b, BIO_C_SET_BUF_MEM_EOF_RETURN, v as c_long, ptr::null_mut()); +} + +pub unsafe fn SSL_CTX_get_options(ssl: *mut SSL_CTX) -> c_long { + SSL_CTX_ctrl(ssl, SSL_CTRL_OPTIONS, 0, ptr::null_mut()) +} + +pub unsafe fn SSL_CTX_clear_options(ssl: *mut SSL_CTX, op: c_long) -> c_long { + SSL_CTX_ctrl(ssl, SSL_CTRL_CLEAR_OPTIONS, (op), ptr::null_mut()) +} + +pub unsafe fn SSL_CTX_add_extra_chain_cert(ssl: *mut SSL_CTX, cert: *mut X509) -> c_long { + SSL_CTX_ctrl(ssl, SSL_CTRL_EXTRA_CHAIN_CERT, 0, cert) +} + +pub unsafe fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long { + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, ptr::null_mut()) +} + +// True functions +extern "C" { + pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int; + pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING; + pub fn ASN1_TIME_free(tm: *mut ASN1_TIME); + + pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; + pub fn BIO_free_all(b: *mut BIO); + pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO; + pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int; + pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int; + pub fn BIO_s_mem() -> *const BIO_METHOD; + + pub fn BN_new() -> *mut BIGNUM; + pub fn BN_dup(n: *mut BIGNUM) -> *mut BIGNUM; + pub fn BN_clear_free(bn: *mut BIGNUM); + + pub fn BN_CTX_new() -> *mut BN_CTX; + pub fn BN_CTX_free(ctx: *mut BN_CTX); + + pub fn BN_num_bits(bn: *mut BIGNUM) -> c_int; + pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int); + pub fn BN_set_word(bn: *mut BIGNUM, n: c_ulong) -> c_int; + + /* Arithmetic operations on BIGNUMs */ + pub fn BN_add(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; + pub fn BN_div(dv: *mut BIGNUM, rem: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_exp(r: *mut BIGNUM, a: *mut BIGNUM, p: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_gcd(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_mod_add(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_mod_exp(r: *mut BIGNUM, a: *mut BIGNUM, p: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_mod_inverse(r: *mut BIGNUM, a: *mut BIGNUM, n: *mut BIGNUM, ctx: *mut BN_CTX) -> *const BIGNUM; + pub fn BN_mod_mul(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_mod_sqr(r: *mut BIGNUM, a: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_mod_sub(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_mul(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_nnmod(rem: *mut BIGNUM, a: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_add_word(r: *mut BIGNUM, w: c_ulong) -> c_int; + pub fn BN_sub_word(r: *mut BIGNUM, w: c_ulong) -> c_int; + pub fn BN_mul_word(r: *mut BIGNUM, w: c_ulong) -> c_int; + pub fn BN_div_word(r: *mut BIGNUM, w: c_ulong) -> c_ulong; + pub fn BN_mod_word(r: *const BIGNUM, w: c_ulong) -> c_ulong; + pub fn BN_sqr(r: *mut BIGNUM, a: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; + pub fn BN_sub(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; + + /* Bit operations on BIGNUMs */ + pub fn BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int; + pub fn BN_is_bit_set(a: *mut BIGNUM, n: c_int) -> c_int; + pub fn BN_lshift(r: *mut BIGNUM, a: *mut BIGNUM, n: c_int) -> c_int; + pub fn BN_lshift1(r: *mut BIGNUM, a: *mut BIGNUM) -> c_int; + pub fn BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int; + pub fn BN_rshift(r: *mut BIGNUM, a: *mut BIGNUM, n: c_int) -> c_int; + pub fn BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int; + pub fn BN_rshift1(r: *mut BIGNUM, a: *mut BIGNUM) -> c_int; + + /* Comparisons on BIGNUMs */ + pub fn BN_cmp(a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; + pub fn BN_ucmp(a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; + + /* Prime handling */ + pub fn BN_generate_prime_ex(r: *mut BIGNUM, bits: c_int, safe: c_int, add: *mut BIGNUM, rem: *mut BIGNUM, cb: *const c_void) -> c_int; + pub fn BN_is_prime_ex(p: *mut BIGNUM, checks: c_int, ctx: *mut BN_CTX, cb: *const c_void) -> c_int; + pub fn BN_is_prime_fasttest_ex(p: *mut BIGNUM, checks: c_int, ctx: *mut BN_CTX, do_trial_division: c_int, cb: *const c_void) -> c_int; + + /* Random number handling */ + pub fn BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; + pub fn BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; + pub fn BN_rand_range(r: *mut BIGNUM, range: *mut BIGNUM) -> c_int; + pub fn BN_pseudo_rand_range(r: *mut BIGNUM, range: *mut BIGNUM) -> c_int; + + /* Conversion from/to binary representation */ + pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM; + pub fn BN_bn2bin(a: *mut BIGNUM, to: *mut u8) -> c_int; + + /* Conversion from/to decimal string representation */ + pub fn BN_dec2bn(a: *const *mut BIGNUM, s: *const c_char) -> c_int; + pub fn BN_bn2dec(a: *mut BIGNUM) -> *const c_char; + + /* Conversion from/to hexidecimal string representation */ + pub fn BN_hex2bn(a: *const *mut BIGNUM, s: *const c_char) -> c_int; + pub fn BN_bn2hex(a: *mut BIGNUM) -> *const c_char; + + pub fn CRYPTO_num_locks() -> c_int; + pub fn CRYPTO_set_locking_callback(func: extern "C" fn(mode: c_int, + n: c_int, + file: *const c_char, + line: c_int)); + pub fn CRYPTO_free(buf: *mut c_void); + pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, + len: size_t) -> c_int; + + pub fn ERR_get_error() -> c_ulong; + + pub fn ERR_lib_error_string(err: c_ulong) -> *const c_char; + pub fn ERR_func_error_string(err: c_ulong) -> *const c_char; + pub fn ERR_reason_error_string(err: c_ulong) -> *const c_char; + + pub fn ERR_load_crypto_strings(); + + pub fn EVP_md5() -> *const EVP_MD; + pub fn EVP_ripemd160() -> *const EVP_MD; + pub fn EVP_sha1() -> *const EVP_MD; + pub fn EVP_sha224() -> *const EVP_MD; + pub fn EVP_sha256() -> *const EVP_MD; + pub fn EVP_sha384() -> *const EVP_MD; + pub fn EVP_sha512() -> *const EVP_MD; + + pub fn EVP_aes_128_cbc() -> *const EVP_CIPHER; + pub fn EVP_aes_128_ecb() -> *const EVP_CIPHER; + #[cfg(feature = "aes_xts")] + pub fn EVP_aes_128_xts() -> *const EVP_CIPHER; + // fn EVP_aes_128_ctr() -> EVP_CIPHER; + // fn EVP_aes_128_gcm() -> EVP_CIPHER; + pub fn EVP_aes_256_cbc() -> *const EVP_CIPHER; + pub fn EVP_aes_256_ecb() -> *const EVP_CIPHER; + #[cfg(feature = "aes_xts")] + pub fn EVP_aes_256_xts() -> *const EVP_CIPHER; + // fn EVP_aes_256_ctr() -> EVP_CIPHER; + // fn EVP_aes_256_gcm() -> EVP_CIPHER; + pub fn EVP_rc4() -> *const EVP_CIPHER; + + pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX; + pub fn EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int) -> c_int; + pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX); + + pub fn EVP_CipherInit(ctx: *mut EVP_CIPHER_CTX, evp: *const EVP_CIPHER, + key: *const u8, iv: *const u8, mode: c_int) -> c_int; + pub fn EVP_CipherUpdate(ctx: *mut EVP_CIPHER_CTX, outbuf: *mut u8, + outlen: &mut c_int, inbuf: *const u8, inlen: c_int) -> c_int; + pub fn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int) -> c_int; + + pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int; + pub fn EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *const ENGINE) -> c_int; + pub fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const u8, n: c_uint) -> c_int; + pub fn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; + pub fn EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; + + pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; + pub fn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int; + pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); + + pub fn EVP_PKEY_new() -> *mut EVP_PKEY; + pub fn EVP_PKEY_free(k: *mut EVP_PKEY); + pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *const c_void) -> c_int; + pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA; + pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int; + pub fn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int; + + pub fn HMAC_CTX_init(ctx: *mut HMAC_CTX); + pub fn HMAC_CTX_cleanup(ctx: *mut HMAC_CTX); + pub fn HMAC_CTX_copy(dst: *mut HMAC_CTX, src: *const HMAC_CTX) -> c_int; + + // Pre-1.0 versions of these didn't return anything, so the shims bridge that gap + #[cfg_attr(target_os = "nacl", link_name = "HMAC_Init_ex")] + pub fn HMAC_Init_ex_shim(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE) -> c_int; + #[cfg_attr(target_os = "nacl", link_name = "HMAC_Final")] + pub fn HMAC_Final_shim(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint) -> c_int; + #[cfg_attr(target_os = "nacl", link_name = "HMAC_Update")] + pub fn HMAC_Update_shim(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint) -> c_int; + + + pub fn PEM_read_bio_X509(bio: *mut BIO, out: *mut *mut X509, callback: Option, + user_data: *mut c_void) -> *mut X509; + pub fn PEM_read_bio_X509_REQ(bio: *mut BIO, out: *mut *mut X509_REQ, callback: Option, + user_data: *mut c_void) -> *mut X509_REQ; + pub fn PEM_read_bio_PrivateKey(bio: *mut BIO, out: *mut *mut EVP_PKEY, callback: Option, + user_data: *mut c_void) -> *mut X509; + + pub fn PEM_write_bio_PrivateKey(bio: *mut BIO, pkey: *mut EVP_PKEY, cipher: *const EVP_CIPHER, + kstr: *mut c_char, klen: c_int, + callback: Option, + user_data: *mut c_void) -> c_int; + pub fn PEM_write_bio_X509(bio: *mut BIO, x509: *mut X509) -> c_int; + pub fn PEM_write_bio_X509_REQ(bio: *mut BIO, x509: *mut X509_REQ) -> c_int; + + pub fn PKCS5_PBKDF2_HMAC_SHA1(pass: *const u8, passlen: c_int, + salt: *const u8, saltlen: c_int, + iter: c_int, keylen: c_int, + out: *mut u8) -> c_int; + + + pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int; + + pub fn RSA_generate_key(modsz: c_int, e: c_ulong, cb: *const c_void, cbarg: *const c_void) -> *mut RSA; + pub fn RSA_private_decrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, + pad: c_int) -> c_int; + pub fn RSA_public_encrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, + pad: c_int) -> c_int; + pub fn RSA_sign(t: c_int, m: *const u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint, + k: *mut RSA) -> c_int; + pub fn RSA_size(k: *mut RSA) -> c_int; + pub fn RSA_verify(t: c_int, m: *const u8, mlen: c_uint, sig: *const u8, siglen: c_uint, + k: *mut RSA) -> c_int; + + pub fn SSL_library_init() -> c_int; + + pub fn SSL_load_error_strings(); + + #[cfg(feature = "sslv2")] + pub fn SSLv2_method() -> *const SSL_METHOD; + pub fn SSLv3_method() -> *const SSL_METHOD; + pub fn TLSv1_method() -> *const SSL_METHOD; + #[cfg(feature = "tlsv1_1")] + pub fn TLSv1_1_method() -> *const SSL_METHOD; + #[cfg(feature = "tlsv1_2")] + pub fn TLSv1_2_method() -> *const SSL_METHOD; + #[cfg(feature = "dtlsv1")] + pub fn DTLSv1_method() -> *const SSL_METHOD; + #[cfg(feature = "dtlsv1_2")] + pub fn DTLSv1_2_method() -> *const SSL_METHOD; + pub fn SSLv23_method() -> *const SSL_METHOD; + + pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL; + pub fn SSL_pending(ssl: *const SSL) -> c_int; + pub fn SSL_free(ssl: *mut SSL); + pub fn SSL_set_bio(ssl: *mut SSL, rbio: *mut BIO, wbio: *mut BIO); + pub fn SSL_get_rbio(ssl: *mut SSL) -> *mut BIO; + pub fn SSL_get_wbio(ssl: *mut SSL) -> *mut BIO; + pub fn SSL_accept(ssl: *mut SSL) -> c_int; + pub fn SSL_connect(ssl: *mut SSL) -> c_int; + pub fn SSL_ctrl(ssl: *mut SSL, cmd: c_int, larg: c_long, + parg: *mut c_void) -> c_long; + pub fn SSL_get_error(ssl: *mut SSL, ret: c_int) -> c_int; + pub fn SSL_read(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; + pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int; + pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int; + pub fn SSL_get_SSL_CTX(ssl: *mut SSL) -> *mut SSL_CTX; + pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const COMP_METHOD; + pub fn SSL_get_peer_certificate(ssl: *mut SSL) -> *mut X509; + + pub fn SSL_COMP_get_name(comp: *const COMP_METHOD) -> *const c_char; + + pub fn SSL_CTX_new(method: *const SSL_METHOD) -> *mut SSL_CTX; + pub fn SSL_CTX_free(ctx: *mut SSL_CTX); + pub fn SSL_CTX_set_verify(ctx: *mut SSL_CTX, mode: c_int, + verify_callback: Option c_int>); + pub fn SSL_CTX_set_verify_depth(ctx: *mut SSL_CTX, depth: c_int); + pub fn SSL_CTX_load_verify_locations(ctx: *mut SSL_CTX, CAfile: *const c_char, + CApath: *const c_char) -> c_int; + pub fn SSL_CTX_get_ex_new_index(argl: c_long, argp: *const c_void, + new_func: Option, + dup_func: Option, + free_func: Option) + -> c_int; + pub fn SSL_CTX_set_ex_data(ctx: *mut SSL_CTX, idx: c_int, data: *mut c_void) + -> c_int; + pub fn SSL_CTX_get_ex_data(ctx: *mut SSL_CTX, idx: c_int) -> *mut c_void; + + pub fn SSL_CTX_use_certificate_file(ctx: *mut SSL_CTX, cert_file: *const c_char, file_type: c_int) -> c_int; + pub fn SSL_CTX_use_certificate(ctx: *mut SSL_CTX, cert: *mut X509) -> c_int; + + pub fn SSL_CTX_use_PrivateKey_file(ctx: *mut SSL_CTX, key_file: *const c_char, file_type: c_int) -> c_int; + pub fn SSL_CTX_use_PrivateKey(ctx: *mut SSL_CTX, key: *mut EVP_PKEY) -> c_int; + pub fn SSL_CTX_check_private_key(ctx: *mut SSL_CTX) -> c_int; + + pub fn SSL_CTX_set_cipher_list(ssl: *mut SSL_CTX, s: *const c_char) -> c_int; + + pub fn SSL_CTX_ctrl(ssl: *mut SSL_CTX, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; + #[cfg(feature = "npn")] + pub fn SSL_CTX_set_next_protos_advertised_cb(ssl: *mut SSL_CTX, + cb: extern "C" fn(ssl: *mut SSL, + out: *mut *const c_uchar, + outlen: *mut c_uint, + arg: *mut c_void) -> c_int, + arg: *mut c_void); + #[cfg(feature = "npn")] + pub fn SSL_CTX_set_next_proto_select_cb(ssl: *mut SSL_CTX, + cb: extern "C" fn(ssl: *mut SSL, + out: *mut *mut c_uchar, + outlen: *mut c_uchar, + inbuf: *const c_uchar, + inlen: c_uint, + arg: *mut c_void) -> c_int, + arg: *mut c_void); + #[cfg(feature = "npn")] + pub fn SSL_select_next_proto(out: *mut *mut c_uchar, outlen: *mut c_uchar, + inbuf: *const c_uchar, inlen: c_uint, + client: *const c_uchar, client_len: c_uint) -> c_int; + #[cfg(feature = "npn")] + pub fn SSL_get0_next_proto_negotiated(s: *const SSL, data: *mut *const c_uchar, len: *mut c_uint); + + pub fn X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int; + pub fn X509_digest(x: *mut X509, digest: *const EVP_MD, buf: *mut c_char, len: *mut c_uint) -> c_int; + pub fn X509_free(x: *mut X509); + pub fn X509_REQ_free(x: *mut X509_REQ); + pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER; + pub fn X509_get_subject_name(x: *mut X509) -> *mut X509_NAME; + pub fn X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME; + pub fn X509_new() -> *mut X509; + pub fn X509_set_issuer_name(x: *mut X509, name: *mut X509_NAME) -> c_int; + pub fn X509_set_notAfter(x: *mut X509, tm: *const ASN1_TIME) -> c_int; + pub fn X509_set_notBefore(x: *mut X509, tm: *const ASN1_TIME) -> c_int; + pub fn X509_set_version(x: *mut X509, version: c_ulong) -> c_int; + pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int; + pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; + pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; + pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ; + + pub fn X509_EXTENSION_free(ext: *mut X509_EXTENSION); + + pub fn X509_NAME_add_entry_by_txt(x: *mut X509, field: *const c_char, ty: c_int, bytes: *const c_char, len: c_int, loc: c_int, set: c_int) -> c_int; + pub fn X509_NAME_get_index_by_NID(n: *mut X509_NAME, nid: c_int, last_pos: c_int) ->c_int; + pub fn X509_NAME_get_entry(n: *mut X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY; + pub fn X509_NAME_ENTRY_get_data(ne: *mut X509_NAME_ENTRY) -> *mut ASN1_STRING; + + pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_char, s: *mut ASN1_STRING) -> c_int; + + pub fn X509_STORE_CTX_get_current_cert(ct: *mut X509_STORE_CTX) -> *mut X509; + pub fn X509_STORE_CTX_get_error(ctx: *mut X509_STORE_CTX) -> c_int; + pub fn X509_STORE_CTX_get_ex_data(ctx: *mut X509_STORE_CTX, idx: c_int) -> *mut c_void; + + pub fn X509V3_EXT_conf_nid(conf: *mut c_void, ctx: *mut X509V3_CTX, ext_nid: c_int, value: *mut c_char) -> *mut X509_EXTENSION; + pub fn X509V3_set_ctx(ctx: *mut X509V3_CTX, issuer: *mut X509, subject: *mut X509, req: *mut X509_REQ, crl: *mut X509_CRL, flags: c_int); + + pub fn i2d_RSA_PUBKEY(k: *mut RSA, buf: *const *mut u8) -> c_int; + pub fn d2i_RSA_PUBKEY(k: *const *mut RSA, buf: *const *const u8, len: c_uint) -> *mut RSA; + pub fn i2d_RSAPrivateKey(k: *mut RSA, buf: *const *mut u8) -> c_int; + pub fn d2i_RSAPrivateKey(k: *const *mut RSA, buf: *const *const u8, len: c_uint) -> *mut RSA; +} + +pub mod probe; diff --git a/deps/openssl-sys-0.6.3/src/old_openssl_shim.c b/deps/openssl-sys-0.6.3/src/old_openssl_shim.c new file mode 100644 index 000000000..19ce74fc0 --- /dev/null +++ b/deps/openssl-sys-0.6.3/src/old_openssl_shim.c @@ -0,0 +1,49 @@ +#include + +#if OPENSSL_VERSION_NUMBER < 0x1000000L +// Copied from openssl crypto/hmac/hmac.c +int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx) + { + if (!EVP_MD_CTX_copy(&dctx->i_ctx, &sctx->i_ctx)) + goto err; + if (!EVP_MD_CTX_copy(&dctx->o_ctx, &sctx->o_ctx)) + goto err; + if (!EVP_MD_CTX_copy(&dctx->md_ctx, &sctx->md_ctx)) + goto err; + memcpy(dctx->key, sctx->key, HMAC_MAX_MD_CBLOCK); + dctx->key_length = sctx->key_length; + dctx->md = sctx->md; + return 1; + err: + return 0; + } + +int HMAC_Init_ex_shim(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl) { + HMAC_Init_ex(ctx, key, key_len, md, impl); + return 1; +} + +int HMAC_Update_shim(HMAC_CTX *ctx, const unsigned char *data, int len) { + HMAC_Update(ctx, data, len); + return 1; +} + +int HMAC_Final_shim(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) { + HMAC_Final(ctx, md, len); + return 1; +} + +#else + +int HMAC_Init_ex_shim(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl) { + return HMAC_Init_ex(ctx, key, key_len, md, impl); +} + +int HMAC_Update_shim(HMAC_CTX *ctx, const unsigned char *data, int len) { + return HMAC_Update(ctx, data, len); +} + +int HMAC_Final_shim(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) { + return HMAC_Final(ctx, md, len); +} +#endif diff --git a/deps/openssl-sys-0.6.3/src/probe.rs b/deps/openssl-sys-0.6.3/src/probe.rs new file mode 100644 index 000000000..6a67e478b --- /dev/null +++ b/deps/openssl-sys-0.6.3/src/probe.rs @@ -0,0 +1,73 @@ +use std::env; +use std::fs; +use std::path::PathBuf; + +pub struct ProbeResult { + pub cert_file: Option, + pub cert_dir: Option, +} + +/// Probe the system for the directory in which CA certificates should likely be +/// found. +/// +/// This will only search known system locations. +pub fn find_certs_dirs() -> Vec { + // see http://gagravarr.org/writing/openssl-certs/others.shtml + [ + "/var/ssl", + "/usr/share/ssl", + "/usr/local/ssl", + "/usr/local/openssl", + "/usr/local/share", + "/usr/lib/ssl", + "/usr/ssl", + "/etc/openssl", + "/etc/pki/tls", + "/etc/ssl", + ].iter().map(|s| PathBuf::from(*s)).filter(|p| { + fs::metadata(p).is_ok() + }).collect() +} + +pub fn init_ssl_cert_env_vars() { + let ProbeResult { cert_file, cert_dir } = probe(); + match cert_file { + Some(path) => put("SSL_CERT_FILE", path), + None => {} + } + match cert_dir { + Some(path) => put("SSL_CERT_DIR", path), + None => {} + } + + fn put(var: &str, path: PathBuf) { + // Don't stomp over what anyone else has set + match env::var(var) { + Ok(..) => {} + Err(..) => env::set_var(var, &path), + } + } +} + +pub fn probe() -> ProbeResult { + let mut result = ProbeResult { + cert_file: env::var_os("SSL_CERT_FILE").map(PathBuf::from), + cert_dir: env::var_os("SSL_CERT_DIR").map(PathBuf::from), + }; + for certs_dir in find_certs_dirs().iter() { + // cert.pem looks to be an openssl 1.0.1 thing, while + // certs/ca-certificates.crt appears to be a 0.9.8 thing + try(&mut result.cert_file, certs_dir.join("cert.pem")); + try(&mut result.cert_file, certs_dir.join("certs/ca-certificates.crt")); + try(&mut result.cert_file, certs_dir.join("certs/ca-root-nss.crt")); + + try(&mut result.cert_dir, certs_dir.join("certs")); + } + result +} + +fn try(dst: &mut Option, val: PathBuf) { + if dst.is_none() && fs::metadata(&val).is_ok() { + *dst = Some(val); + } +} diff --git a/deps/pkg-config-0.3.5/.gitignore b/deps/pkg-config-0.3.5/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/pkg-config-0.3.5/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/pkg-config-0.3.5/.travis.yml b/deps/pkg-config-0.3.5/.travis.yml new file mode 100644 index 000000000..c56bccdb9 --- /dev/null +++ b/deps/pkg-config-0.3.5/.travis.yml @@ -0,0 +1,25 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - | + [ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: XlfwiQ+fPgRWqFwHbyPTma2FAVtgN+IXFpkiIdh1sKxWEeHMqABrTtOKf/NugDYCGsOJfr2vb5qFL6teBV2lTXOffUIWj+1hMd0N/FbVKWzABBV02XdxQi8w2ptPez5LPRTEfXJRRHmJpc8ww2aCTIrdT3AQE2oqZM/jHJTi/1U= +notifications: + email: + on_success: never diff --git a/deps/pkg-config-0.3.5/Cargo.toml b/deps/pkg-config-0.3.5/Cargo.toml new file mode 100644 index 000000000..85c6d2ef9 --- /dev/null +++ b/deps/pkg-config-0.3.5/Cargo.toml @@ -0,0 +1,13 @@ +[package] + +name = "pkg-config" +version = "0.3.5" +authors = ["Alex Crichton "] +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/pkg-config-rs" +documentation = "http://alexcrichton.com/pkg-config-rs" +description = """ +A library to run the pkg-config system tool at build time in order to be used in +Cargo build scripts. +""" +keywords = ["build-dependencies"] diff --git a/deps/pkg-config-0.3.5/LICENSE-APACHE b/deps/pkg-config-0.3.5/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/pkg-config-0.3.5/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/pkg-config-0.3.5/LICENSE-MIT b/deps/pkg-config-0.3.5/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/pkg-config-0.3.5/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/pkg-config-0.3.5/README.md b/deps/pkg-config-0.3.5/README.md new file mode 100644 index 000000000..4db41e2bb --- /dev/null +++ b/deps/pkg-config-0.3.5/README.md @@ -0,0 +1,25 @@ +# pkg-config-rs + +[![Build Status](https://travis-ci.org/alexcrichton/pkg-config-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/pkg-config-rs) + +[Documentation](http://alexcrichton.com/pkg-config-rs) + +A simple library meant to be used as a build dependency with Cargo packages in +order to use the system `pkg-config` tool (if available) to determine where a +library is located. + +```rust +extern crate pkg_config; + +fn main() { + pkg_config::find_library("foo").unwrap(); +} +``` + +# License + +`pkg-config-rs` is primarily distributed under the terms of both the MIT +license and the Apache License (Version 2.0), with portions covered by various +BSD-like licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/pkg-config-0.3.5/src/lib.rs b/deps/pkg-config-0.3.5/src/lib.rs new file mode 100644 index 000000000..57dbd9156 --- /dev/null +++ b/deps/pkg-config-0.3.5/src/lib.rs @@ -0,0 +1,291 @@ +//! A build dependency for Cargo libraries to find system artifacts through the +//! `pkg-config` utility. +//! +//! This library will shell out to `pkg-config` as part of build scripts and +//! probe the system to determine how to link to a specified library. The +//! `Config` structure serves as a method of configuring how `pkg-config` is +//! invoked in a builder style. +//! +//! A number of environment variables are available to globally configure how +//! this crate will invoke `pkg-config`: +//! +//! * `PKG_CONFIG_ALLOW_CROSS` - if this variable is not set, then `pkg-config` +//! will automatically be disabled for all cross compiles. +//! * `FOO_NO_PKG_CONFIG` - if set, this will disable running `pkg-config` when +//! probing for the library named `foo`. +//! +//! There are also a number of environment variables which can configure how a +//! library is linked to (dynamically vs statically). These variables control +//! whether the `--static` flag is passed. Note that this behavior can be +//! overridden by configuring explicitly on `Config`. The variables are checked +//! in the following order: +//! +//! * `FOO_STATIC` - pass `--static` for the library `foo` +//! * `FOO_DYNAMIC` - do not pass `--static` for the library `foo` +//! * `PKG_CONFIG_ALL_STATIC` - pass `--static` for all libraries +//! * `PKG_CONFIG_ALL_DYNAMIC` - do not pass `--static` for all libraries +//! +//! After running `pkg-config` all appropriate Cargo metadata will be printed on +//! stdout if the search was successful. +//! +//! # Example +//! +//! Find the system library named `foo`. +//! +//! ```no_run +//! extern crate pkg_config; +//! +//! fn main() { +//! pkg_config::find_library("foo").unwrap(); +//! } +//! ``` +//! +//! Configure how library `foo` is linked to. +//! +//! ```no_run +//! extern crate pkg_config; +//! +//! fn main() { +//! pkg_config::Config::new().statik(true).find("foo").unwrap(); +//! } +//! ``` + +#![doc(html_root_url = "http://alexcrichton.com/pkg-config-rs")] +#![cfg_attr(test, deny(warnings))] + +use std::ascii::AsciiExt; +use std::env; +use std::ffi::{OsStr, OsString}; +use std::fs; +use std::path::{PathBuf, Path}; +use std::process::Command; +use std::str; + +pub fn target_supported() -> bool { + env::var("HOST") == env::var("TARGET") || + env::var_os("PKG_CONFIG_ALLOW_CROSS").is_some() +} + +#[derive(Clone)] +pub struct Config { + statik: Option, + atleast_version: Option, + extra_args: Vec, +} + +#[derive(Debug)] +pub struct Library { + pub libs: Vec, + pub link_paths: Vec, + pub frameworks: Vec, + pub framework_paths: Vec, + pub include_paths: Vec, + pub version: String, + _priv: (), +} + +/// Simple shortcut for using all default options for finding a library. +pub fn find_library(name: &str) -> Result { + Config::new().find(name) +} + +impl Config { + /// Creates a new set of configuration options which are all initially set + /// to "blank". + pub fn new() -> Config { + Config { + statik: None, + atleast_version: None, + extra_args: vec![], + } + } + + /// Indicate whether the `--static` flag should be passed. + /// + /// This will override the inference from environment variables described in + /// the crate documentation. + pub fn statik(&mut self, statik: bool) -> &mut Config { + self.statik = Some(statik); + self + } + + /// Indicate that the library must be at least version `vers`. + pub fn atleast_version(&mut self, vers: &str) -> &mut Config { + self.atleast_version = Some(vers.to_string()); + self + } + + /// Add an argument to pass to pkg-config. + /// + /// It's placed after all of the arguments generated by this library. + pub fn arg>(&mut self, arg: S) -> &mut Config { + self.extra_args.push(arg.as_ref().to_os_string()); + self + } + + /// Run `pkg-config` to find the library `name`. + /// + /// This will use all configuration previously set to specify how + /// `pkg-config` is run. + pub fn find(&self, name: &str) -> Result { + if env::var_os(&format!("{}_NO_PKG_CONFIG", envify(name))).is_some() { + return Err(format!("pkg-config requested to be aborted for {}", name)) + } else if !target_supported() { + return Err("pkg-config doesn't handle cross compilation. Use \ + PKG_CONFIG_ALLOW_CROSS=1 to override".to_string()); + } + + let mut library = Library::new(); + + let output = try!(run(self.command(name, &["--libs", "--cflags"]))); + library.parse_libs_cflags(name, &output, self); + + let output = try!(run(self.command(name, &["--modversion"]))); + library.parse_modversion(&output); + + Ok(library) + } + + /// Run `pkg-config` to get the value of a variable from a package using + /// --variable. + pub fn get_variable(package: &str, variable: &str) -> Result { + let arg = format!("--variable={}", variable); + let cfg = Config::new(); + Ok(try!(run(cfg.command(package, &[&arg]))).trim_right().to_owned()) + } + + fn is_static(&self, name: &str) -> bool { + self.statik.unwrap_or_else(|| infer_static(name)) + } + + fn command(&self, name: &str, args: &[&str]) -> Command { + let mut cmd = Command::new("pkg-config"); + if self.is_static(name) { + cmd.arg("--static"); + } + cmd.args(args) + .args(&self.extra_args) + .env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1"); + if let Some(ref version) = self.atleast_version { + cmd.arg(&format!("{} >= {}", name, version)); + } else { + cmd.arg(name); + } + cmd + } +} + +impl Library { + fn new() -> Library { + Library { + libs: Vec::new(), + link_paths: Vec::new(), + include_paths: Vec::new(), + frameworks: Vec::new(), + framework_paths: Vec::new(), + version: String::new(), + _priv: (), + } + } + + fn parse_libs_cflags(&mut self, name: &str, output: &str, config: &Config) { + let parts = output.split(' ') + .filter(|l| l.len() > 2) + .map(|arg| (&arg[0..2], &arg[2..])) + .collect::>(); + + let mut dirs = Vec::new(); + let statik = config.is_static(name); + for &(flag, val) in parts.iter() { + match flag { + "-L" => { + println!("cargo:rustc-link-search=native={}", val); + dirs.push(PathBuf::from(val)); + self.link_paths.push(PathBuf::from(val)); + } + "-F" => { + println!("cargo:rustc-link-search=framework={}", val); + self.framework_paths.push(PathBuf::from(val)); + } + "-I" => { + self.include_paths.push(PathBuf::from(val)); + } + "-l" => { + self.libs.push(val.to_string()); + if statik && !is_system(val, &dirs) { + println!("cargo:rustc-link-lib=static={}", val); + } else { + println!("cargo:rustc-link-lib={}", val); + } + } + _ => {} + } + } + + let mut iter = output.split(' '); + while let Some(part) = iter.next() { + if part != "-framework" { continue } + if let Some(lib) = iter.next() { + println!("cargo:rustc-link-lib=framework={}", lib); + self.frameworks.push(lib.to_string()); + } + } + } + + fn parse_modversion(&mut self, output: &str) { + self.version.push_str(output.trim()); + } +} + +fn infer_static(name: &str) -> bool { + let name = envify(name); + if env::var_os(&format!("{}_STATIC", name)).is_some() { + true + } else if env::var_os(&format!("{}_DYNAMIC", name)).is_some() { + false + } else if env::var_os("PKG_CONFIG_ALL_STATIC").is_some() { + true + } else if env::var_os("PKG_CONFIG_ALL_DYNAMIC").is_some() { + false + } else { + false + } +} + +fn envify(name: &str) -> String { + name.chars().map(|c| c.to_ascii_uppercase()).map(|c| { + if c == '-' {'_'} else {c} + }).collect() +} + +fn is_system(name: &str, dirs: &[PathBuf]) -> bool { + let libname = format!("lib{}.a", name); + let root = Path::new("/usr"); + !dirs.iter().any(|d| { + !d.starts_with(root) && fs::metadata(&d.join(&libname)).is_ok() + }) +} + +fn run(mut cmd: Command) -> Result { + let out = try!(cmd.output().map_err(|e| { + format!("failed to run `{:?}`: {}", cmd, e) + })); + + let stdout = String::from_utf8(out.stdout).unwrap(); + if out.status.success() { + return Ok(stdout); + } + + let stderr = str::from_utf8(&out.stderr).unwrap(); + let mut msg = format!("`{:?}` did not exit successfully: {}", cmd, out.status); + if stdout.len() > 0 { + msg.push_str("\n--- stdout\n"); + msg.push_str(&stdout); + } + if stderr.len() > 0 { + msg.push_str("\n--- stderr\n"); + msg.push_str(stderr); + } + + return Err(msg); +} diff --git a/deps/pkg-config-0.3.5/tests/foo.pc b/deps/pkg-config-0.3.5/tests/foo.pc new file mode 100644 index 000000000..b1ae3d8ce --- /dev/null +++ b/deps/pkg-config-0.3.5/tests/foo.pc @@ -0,0 +1,16 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/valgrind +arch=amd64 +os=linux +platform=amd64-linux +valt_load_address=0x38000000 + +Name: Valgrind +Description: A dynamic binary instrumentation framework +Version: 3.10.0.SVN +Requires: +Libs: -L${libdir}/valgrind -lcoregrind-amd64-linux -lvex-amd64-linux -lgcc +Cflags: -I${includedir} + diff --git a/deps/pkg-config-0.3.5/tests/framework.pc b/deps/pkg-config-0.3.5/tests/framework.pc new file mode 100644 index 000000000..57c0447f1 --- /dev/null +++ b/deps/pkg-config-0.3.5/tests/framework.pc @@ -0,0 +1,16 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/valgrind +arch=amd64 +os=linux +platform=amd64-linux +valt_load_address=0x38000000 + +Name: Valgrind +Description: A dynamic binary instrumentation framework +Version: 3.10.0.SVN +Requires: +Libs: -F${libdir} -framework foo +Cflags: -I${includedir} + diff --git a/deps/pkg-config-0.3.5/tests/test.rs b/deps/pkg-config-0.3.5/tests/test.rs new file mode 100644 index 000000000..3946bb37c --- /dev/null +++ b/deps/pkg-config-0.3.5/tests/test.rs @@ -0,0 +1,86 @@ +#![feature(std_misc)] + +extern crate pkg_config; + +use std::env; +use std::sync::{StaticMutex, MUTEX_INIT}; +use std::path::PathBuf; + +static LOCK: StaticMutex = MUTEX_INIT; + +fn reset() { + for (k, _) in env::vars() { + if k.contains("PKG_CONFIG") || k.contains("DYNAMIC") || + k.contains("STATIC") { + env::remove_var(&k); + } + } + env::remove_var("TARGET"); + env::remove_var("HOST"); + env::set_var("PKG_CONFIG_PATH", &env::current_dir().unwrap().join("tests")); +} + +fn find(name: &str) -> Result { + pkg_config::find_library(name) +} + +#[test] +fn cross_disabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + find("foo").unwrap_err(); +} + +#[test] +fn cross_enabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); + find("foo").unwrap(); +} + +#[test] +fn package_disabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("FOO_NO_PKG_CONFIG", "1"); + find("foo").unwrap_err(); +} + +#[test] +fn output_ok() { + let _g = LOCK.lock(); + reset(); + let lib = find("foo").unwrap(); + assert!(lib.libs.contains(&"gcc".to_string())); + assert!(lib.libs.contains(&"coregrind-amd64-linux".to_string())); + assert!(lib.link_paths.contains(&PathBuf::from("/usr/lib/valgrind"))); +} + +#[test] +fn framework() { + let _g = LOCK.lock(); + reset(); + let lib = find("framework").unwrap(); + assert!(lib.frameworks.contains(&"foo".to_string())); + assert!(lib.framework_paths.contains(&PathBuf::from("/usr/lib"))); +} + +#[test] +fn get_variable() { + let _g = LOCK.lock(); + reset(); + let prefix = pkg_config::Config::get_variable("foo", "prefix").unwrap(); + assert_eq!(prefix, "/usr"); +} + +#[test] +fn version() { + let _g = LOCK.lock(); + reset(); + assert_eq!(&find("foo").unwrap().version[..], "3.10.0.SVN"); +} diff --git a/deps/regex-0.1.38/.gitignore b/deps/regex-0.1.38/.gitignore new file mode 100644 index 000000000..e11b71446 --- /dev/null +++ b/deps/regex-0.1.38/.gitignore @@ -0,0 +1,4 @@ +target +Cargo.lock +bench-log +.*.swp diff --git a/deps/regex-0.1.38/.travis.yml b/deps/regex-0.1.38/.travis.yml new file mode 100644 index 000000000..0e28eb433 --- /dev/null +++ b/deps/regex-0.1.38/.travis.yml @@ -0,0 +1,34 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - ./run-shootout-test + - | + [ $TRAVIS_RUST_VERSION != nightly ] || ( + cargo test --verbose --features pattern && + cargo bench --verbose && + cargo test --manifest-path=regex_macros/Cargo.toml && + cargo bench --manifest-path=regex_macros/Cargo.toml + ) + - cargo doc + - cargo test --verbose --manifest-path=regex-syntax/Cargo.toml + - cargo doc --verbose --manifest-path=regex-syntax/Cargo.toml +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: VvIrYRW/a8FmBA61hn1bDrqWwR92tANOT6PCeLYd9A9ViQrN07PE6uGsnd9iwr8itck10Ctl1mThZYUkK8BDFEmlvSxOFJ/Po5eRe6A1CYuFF40zizJ+3NllVkN20kwoQDe0kxwZVDGO9Yi1icHUrbRPWDfS+1tfobO/UT8Dlng= +notifications: + email: + on_success: never diff --git a/deps/regex-0.1.38/Cargo.toml b/deps/regex-0.1.38/Cargo.toml new file mode 100644 index 000000000..84f51e7cf --- /dev/null +++ b/deps/regex-0.1.38/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "regex" +version = "0.1.38" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/regex" +documentation = "http://doc.rust-lang.org/regex" +homepage = "https://github.com/rust-lang/regex" +description = """ +An implementation of regular expressions for Rust. +""" + +[[test]] +path = "regex_macros/tests/test_dynamic.rs" +name = "dynamic" + +[[test]] +path = "regex_macros/tests/test_dynamic_nfa.rs" +name = "dynamic_nfa" + +[[test]] +path = "regex_macros/tests/test_dynamic_backtrack.rs" +name = "dynamic_backtrack" + +[[bench]] +name = "all" +path = "regex_macros/benches/bench_dynamic.rs" +test = false +bench = true + +[dependencies] +aho-corasick = "0.2" +memchr = "0.1" +regex-syntax = { path = "regex-syntax", version = "0.1" } + +[dev-dependencies] +rand = "0.3" + +[features] +pattern = [] + +[profile.bench] +lto = true diff --git a/deps/regex-0.1.38/LICENSE-APACHE b/deps/regex-0.1.38/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/regex-0.1.38/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/regex-0.1.38/LICENSE-MIT b/deps/regex-0.1.38/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/regex-0.1.38/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/regex-0.1.38/README.md b/deps/regex-0.1.38/README.md new file mode 100644 index 000000000..94b43bc94 --- /dev/null +++ b/deps/regex-0.1.38/README.md @@ -0,0 +1,35 @@ +regex +===== + +A Rust library for parsing, compiling, and executing regular expressions. + +[![Build Status](https://travis-ci.org/rust-lang/regex.svg?branch=master)](https://travis-ci.org/rust-lang/regex) +[![Build status](https://ci.appveyor.com/api/projects/status/22g48bo866qr4u77?svg=true)](https://ci.appveyor.com/project/alexcrichton/regex) +[![](http://meritbadge.herokuapp.com/regex)](https://crates.io/crates/regex) + +[Documentation](http://doc.rust-lang.org/regex) + + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +regex = "0.1.8" +``` + +and this to your crate root: + +```rust +extern crate regex; +``` + + +# License + +`regex` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/regex-0.1.38/appveyor.yml b/deps/regex-0.1.38/appveyor.yml new file mode 100644 index 000000000..b3ec520a2 --- /dev/null +++ b/deps/regex-0.1.38/appveyor.yml @@ -0,0 +1,23 @@ +environment: + CARGO_TARGET: x86_64-pc-windows-gnu + matrix: + - TARGET: x86_64-pc-windows-msvc + - TARGET: i686-pc-windows-gnu +install: + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rustc-nightly-${env:TARGET}.tar.gz" + - ps: Start-FileDownload "https://static.rust-lang.org/cargo-dist/cargo-nightly-${env:CARGO_TARGET}.tar.gz" + - 7z x rustc-nightly-%TARGET%.tar.gz > nul + - 7z x rustc-nightly-%TARGET%.tar > nul + - 7z x cargo-nightly-%CARGO_TARGET%.tar.gz > nul + - 7z x cargo-nightly-%CARGO_TARGET%.tar > nul + - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 + - set PATH=%PATH%;%cd%/rustc-nightly-%TARGET%/rustc/bin + - set PATH=%PATH%;%cd%/cargo-nightly-%CARGO_TARGET%/cargo/bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/regex-0.1.38/examples/regexdna-input.txt b/deps/regex-0.1.38/examples/regexdna-input.txt new file mode 100644 index 000000000..fb2326339 --- /dev/null +++ b/deps/regex-0.1.38/examples/regexdna-input.txt @@ -0,0 +1,1671 @@ +>ONE Homo sapiens alu +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC +CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT +GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC +GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA +GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA +GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA +GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG +AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT +CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA +GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA +AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC +GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT +ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG +GAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATC +GCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGC +GGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGG +TCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAA +AAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAG +GAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACT +CCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCC +TGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAG +ACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGC +GTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGA +ACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGA +CAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCA +CTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCA +ACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCG +CCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGG +AGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTC +CGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCG +AGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACC +CCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAG +CTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAG +CCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGG +CCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAA +AAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGC +TGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCC +ACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGG +CTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGG +AGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATT +AGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAA +TCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGC +CTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAA +TCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAG +CCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGT +GGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCG +GGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAG +CGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG +GGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATG +GTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGT +AATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTT +GCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCT +CAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCG +GGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTC +TCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACT +CGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAG +ATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGG +CGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTG +AGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATA +CAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGG +CAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGC +ACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCAC +GCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTC +GAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCG +GGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCT +TGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGG +CGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCA +GCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGG +CCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGC +GCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGG +CGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGA +CTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGG +CCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAA +ACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCC +CAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGT +GAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAA +AGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGG +ATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTAC +TAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGA +GGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGC +GCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGG +TGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTC +AGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAA +ATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGA +GAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC +AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTG +TAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGAC +CAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGT +GGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAAC +CCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACA +GAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACT +TTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAAC +ATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCC +TGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAG +GTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCG +TCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAG +GCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCC +GTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCT +ACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCC +GAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCC +GGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCAC +CTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAA +ATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTG +AGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCAC +TGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCT +CACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAG +TTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAG +CCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATC +GCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCT +GGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATC +CCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCC +TGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGG +CGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG +AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCG +AGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGG +AGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGT +GAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAA +TCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGC +AGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCA +AAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGG +CGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTC +TACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCG +GGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGAT +CGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCG +CGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAG +GTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACA +AAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCA +GGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCAC +TCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGC +CTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGA +GACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGG +CGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTG +AACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCG +ACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGC +ACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCC +AACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGC +GCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCG +GAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACT +CCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCC +GAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAAC +CCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA +GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGA +GCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAG +GCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGAT +CACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTA +AAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGG +CTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGC +CACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTG +GCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAG +GAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAAT +TAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGA +ATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAG +CCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTA +ATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCA +GCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGG +TGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCC +GGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGA +GCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTT +GGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACAT +GGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTG +TAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGT +TGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTC +TCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGC +GGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGT +CTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTAC +TCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGA +GATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGG +GCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCT +GAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT +ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAG +GCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTG +CACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCA +CGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTT +CGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCC +GGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGC +TTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGG +GCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCC +AGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTG +GCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCG +CGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAG +GCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAG +ACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAG +GCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGA +AACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATC +CCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAG +TGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAA +AAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCG +GATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTA +CTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGG +AGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCG +CGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCG +GTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGT +CAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAA +AATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGG +AGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTC +CAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCT +GTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA +CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCG +TGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAA +CCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGAC +AGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCAC +TTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAA +CATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGC +CTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGA +GGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCC +GTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGA +GGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCC +CGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGC +TACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGC +CGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGC +CGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCA +CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAA +AATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCT +GAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCA +CTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGC +TCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGA +GTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTA +GCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAAT +CGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCC +TGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAAT +CCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGC +CTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTG +GCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGG +GAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGC +GAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG +GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGG +TGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTA +ATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTG +CAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTC +AAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGG +GCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCT +CTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTC +GGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGA +TCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGC +GCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGA +GGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATAC +AAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGC +AGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCA +CTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACG +CCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCG +AGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGG +GCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTT +GAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGC +GACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAG +CACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGC +CAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCG +CGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGC +GGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGAC +TCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGC +CGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAA +CCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCC +AGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTG +AGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC +CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT +GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC +GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA +GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA +GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA +GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG +AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT +CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA +GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA +AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC +GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT +ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG +GAGGCTGAGGCAGGAGAATC +>TWO IUB ambiguity codes +cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg +tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa +NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt +cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga +gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa +HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca +tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt +tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt +acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct +tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt +gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa +accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt +RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt +tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag +cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg +ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat +actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg +YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa +KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata +aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa +aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg +gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc +tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK +tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt +ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg +ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa +BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt +aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc +tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc +cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac +aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga +tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga +aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD +gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg +ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV +taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa +ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat +gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg +gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa +tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt +tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt +taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca +cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag +aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt +cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt +ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW +attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag +ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa +attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc +tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta +aagacYRcaggattHaYgtKtaatgcVcaataMYacccatatcacgWDBtgaatcBaata +cKcttRaRtgatgaBDacggtaattaaYtataStgVHDtDctgactcaaatKtacaatgc +gYatBtRaDatHaactgtttatatDttttaaaKVccYcaaccNcBcgHaaVcattHctcg +attaaatBtatgcaaaaatYMctSactHatacgaWacattacMBgHttcgaatVaaaaca +BatatVtctgaaaaWtctRacgBMaatSgRgtgtcgactatcRtattaScctaStagKga +DcWgtYtDDWKRgRtHatRtggtcgaHgggcgtattaMgtcagccaBggWVcWctVaaat +tcgNaatcKWagcNaHtgaaaSaaagctcYctttRVtaaaatNtataaccKtaRgtttaM +tgtKaBtRtNaggaSattHatatWactcagtgtactaKctatttgRYYatKatgtccgtR +tttttatttaatatVgKtttgtatgtNtataRatWYNgtRtHggtaaKaYtKSDcatcKg +taaYatcSRctaVtSMWtVtRWHatttagataDtVggacagVcgKWagBgatBtaaagNc +aRtagcataBggactaacacRctKgttaatcctHgDgttKHHagttgttaatgHBtatHc +DaagtVaBaRccctVgtgDtacRHSctaagagcggWYaBtSaKtHBtaaactYacgNKBa +VYgtaacttagtVttcttaatgtBtatMtMtttaattaatBWccatRtttcatagVgMMt +agctStKctaMactacDNYgKYHgaWcgaHgagattacVgtttgtRaSttaWaVgataat +gtgtYtaStattattMtNgWtgttKaccaatagNYttattcgtatHcWtctaaaNVYKKt +tWtggcDtcgaagtNcagatacgcattaagaccWctgcagcttggNSgaNcHggatgtVt +catNtRaaBNcHVagagaaBtaaSggDaatWaatRccaVgggStctDaacataKttKatt +tggacYtattcSatcttagcaatgaVBMcttDattctYaaRgatgcattttNgVHtKcYR +aatRKctgtaaacRatVSagctgtWacBtKVatctgttttKcgtctaaDcaagtatcSat +aWVgcKKataWaYttcccSaatgaaaacccWgcRctWatNcWtBRttYaattataaNgac +acaatagtttVNtataNaYtaatRaVWKtBatKagtaatataDaNaaaaataMtaagaaS +tccBcaatNgaataWtHaNactgtcDtRcYaaVaaaaaDgtttRatctatgHtgttKtga +aNSgatactttcgagWaaatctKaaDaRttgtggKKagcDgataaattgSaacWaVtaNM +acKtcaDaaatttctRaaVcagNacaScRBatatctRatcctaNatWgRtcDcSaWSgtt +RtKaRtMtKaatgttBHcYaaBtgatSgaSWaScMgatNtctcctatttctYtatMatMt +RRtSaattaMtagaaaaStcgVgRttSVaScagtgDtttatcatcatacRcatatDctta +tcatVRtttataaHtattcYtcaaaatactttgVctagtaaYttagatagtSYacKaaac +gaaKtaaatagataatSatatgaaatSgKtaatVtttatcctgKHaatHattagaaccgt +YaaHactRcggSBNgtgctaaBagBttgtRttaaattYtVRaaaattgtaatVatttctc +ttcatgBcVgtgKgaHaaatattYatagWacNctgaaMcgaattStagWaSgtaaKagtt +ttaagaDgatKcctgtaHtcatggKttVDatcaaggtYcgccagNgtgcVttttagagat +gctaccacggggtNttttaSHaNtatNcctcatSaaVgtactgBHtagcaYggYVKNgta +KBcRttgaWatgaatVtagtcgattYgatgtaatttacDacSctgctaaaStttaWMagD +aaatcaVYctccgggcgaVtaaWtStaKMgDtttcaaMtVgBaatccagNaaatcYRMBg +gttWtaaScKttMWtYataRaDBMaDataatHBcacDaaKDactaMgagttDattaHatH +taYatDtattDcRNStgaatattSDttggtattaaNSYacttcDMgYgBatWtaMagact +VWttctttgYMaYaacRgHWaattgRtaagcattctMKVStatactacHVtatgatcBtV +NataaBttYtSttacKgggWgYDtgaVtYgatDaacattYgatggtRDaVDttNactaSa +MtgNttaacaaSaBStcDctaccacagacgcaHatMataWKYtaYattMcaMtgSttDag +cHacgatcaHttYaKHggagttccgatYcaatgatRaVRcaagatcagtatggScctata +ttaNtagcgacgtgKaaWaactSgagtMYtcttccaKtStaacggMtaagNttattatcg +tctaRcactctctDtaacWYtgaYaSaagaWtNtatttRacatgNaatgttattgWDDcN +aHcctgaaHacSgaataaRaataMHttatMtgaSDSKatatHHaNtacagtccaYatWtc +actaactatKDacSaStcggataHgYatagKtaatKagStaNgtatactatggRHacttg +tattatgtDVagDVaRctacMYattDgtttYgtctatggtKaRSttRccRtaaccttaga +gRatagSaaMaacgcaNtatgaaatcaRaagataatagatactcHaaYKBctccaagaRa +BaStNagataggcgaatgaMtagaatgtcaKttaaatgtaWcaBttaatRcggtgNcaca +aKtttScRtWtgcatagtttWYaagBttDKgcctttatMggNttattBtctagVtacata +aaYttacacaaRttcYtWttgHcaYYtaMgBaBatctNgcDtNttacgacDcgataaSat +YaSttWtcctatKaatgcagHaVaacgctgcatDtgttaSataaaaYSNttatagtaNYt +aDaaaNtggggacttaBggcHgcgtNtaaMcctggtVtaKcgNacNtatVaSWctWtgaW +cggNaBagctctgaYataMgaagatBSttctatacttgtgtKtaattttRagtDtacata +tatatgatNHVgBMtKtaKaNttDHaagatactHaccHtcatttaaagttVaMcNgHata +tKtaNtgYMccttatcaaNagctggacStttcNtggcaVtattactHaSttatgNMVatt +MMDtMactattattgWMSgtHBttStStgatatRaDaagattttctatMtaaaaaggtac +taaVttaSacNaatactgMttgacHaHRttgMacaaaatagttaatatWKRgacDgaRta +tatttattatcYttaWtgtBRtWatgHaaattHataagtVaDtWaVaWtgStcgtMSgaS +RgMKtaaataVacataatgtaSaatttagtcgaaHtaKaatgcacatcggRaggSKctDc +agtcSttcccStYtccRtctctYtcaaKcgagtaMttttcRaYDttgttatctaatcata +NctctgctatcaMatactataggDaHaaSttMtaDtcNatataattctMcStaaBYtaNa +gatgtaatHagagSttgWHVcttatKaYgDctcttggtgttMcRaVgSgggtagacaata +aDtaattSaDaNaHaBctattgNtaccaaRgaVtKNtaaYggHtaKKgHcatctWtctDt +ttctttggSDtNtaStagttataaacaattgcaBaBWggHgcaaaBtYgctaatgaaatW +cDcttHtcMtWWattBHatcatcaaatctKMagtDNatttWaBtHaaaNgMttaaStagt +tctctaatDtcRVaYttgttMtRtgtcaSaaYVgSWDRtaatagctcagDgcWWaaaBaa +RaBctgVgggNgDWStNaNBKcBctaaKtttDcttBaaggBttgaccatgaaaNgttttt +tttatctatgttataccaaDRaaSagtaVtDtcaWatBtacattaWacttaSgtattggD +gKaaatScaattacgWcagKHaaccaYcRcaRttaDttRtttHgaHVggcttBaRgtccc +tDatKaVtKtcRgYtaKttacgtatBtStaagcaattaagaRgBagSaattccSWYttta +ttVaataNctgHgttaaNBgcVYgtRtcccagWNaaaacaDNaBcaaaaRVtcWMgBagM +tttattacgDacttBtactatcattggaaatVccggttRttcatagttVYcatYaSHaHc +ttaaagcNWaHataaaRWtctVtRYtagHtaaaYMataHYtNBctNtKaatattStgaMc +BtRgctaKtgcScSttDgYatcVtggaaKtaagatWccHccgKYctaNNctacaWctttt +gcRtgtVcgaKttcMRHgctaHtVaataaDtatgKDcttatBtDttggNtacttttMtga +acRattaaNagaactcaaaBBVtcDtcgaStaDctgaaaSgttMaDtcgttcaccaaaag +gWtcKcgSMtcDtatgtttStaaBtatagDcatYatWtaaaBacaKgcaDatgRggaaYc +taRtccagattDaWtttggacBaVcHtHtaacDacYgtaatataMagaatgHMatcttat +acgtatttttatattacHactgttataMgStYaattYaccaattgagtcaaattaYtgta +tcatgMcaDcgggtcttDtKgcatgWRtataatatRacacNRBttcHtBgcRttgtgcgt +catacMtttBctatctBaatcattMttMYgattaaVYatgDaatVagtattDacaacDMa +tcMtHcccataagatgBggaccattVWtRtSacatgctcaaggggYtttDtaaNgNtaaB +atggaatgtctRtaBgBtcNYatatNRtagaacMgagSaSDDSaDcctRagtVWSHtVSR +ggaacaBVaccgtttaStagaacaMtactccagtttVctaaRaaHttNcttagcaattta +ttaatRtaaaatctaacDaBttggSagagctacHtaaRWgattcaaBtctRtSHaNtgta +cattVcaHaNaagtataccacaWtaRtaaVKgMYaWgttaKggKMtKcgWatcaDatYtK +SttgtacgaccNctSaattcDcatcttcaaaDKttacHtggttHggRRaRcaWacaMtBW +VHSHgaaMcKattgtaRWttScNattBBatYtaNRgcggaagacHSaattRtttcYgacc +BRccMacccKgatgaacttcgDgHcaaaaaRtatatDtatYVtttttHgSHaSaatagct +NYtaHYaVYttattNtttgaaaYtaKttWtctaNtgagaaaNctNDctaaHgttagDcRt +tatagccBaacgcaRBtRctRtggtaMYYttWtgataatcgaataattattataVaaaaa +ttacNRVYcaaMacNatRttcKatMctgaagactaattataaYgcKcaSYaatMNctcaa +cgtgatttttBacNtgatDccaattattKWWcattttatatatgatBcDtaaaagttgaa +VtaHtaHHtBtataRBgtgDtaataMttRtDgDcttattNtggtctatctaaBcatctaR +atgNacWtaatgaagtcMNaacNgHttatactaWgcNtaStaRgttaaHacccgaYStac +aaaatWggaYaWgaattattcMaactcBKaaaRVNcaNRDcYcgaBctKaacaaaaaSgc +tccYBBHYaVagaatagaaaacagYtctVccaMtcgtttVatcaatttDRtgWctagtac +RttMctgtDctttcKtWttttataaatgVttgBKtgtKWDaWagMtaaagaaattDVtag +gttacatcatttatgtcgMHaVcttaBtVRtcgtaYgBRHatttHgaBcKaYWaatcNSc +tagtaaaaatttacaatcactSWacgtaatgKttWattagttttNaggtctcaagtcact +attcttctaagKggaataMgtttcataagataaaaatagattatDgcBVHWgaBKttDgc +atRHaagcaYcRaattattatgtMatatattgHDtcaDtcaaaHctStattaatHaccga +cNattgatatattttgtgtDtRatagSacaMtcRtcattcccgacacSattgttKaWatt +NHcaacttccgtttSRtgtctgDcgctcaaMagVtBctBMcMcWtgtaacgactctcttR +ggRKSttgYtYatDccagttDgaKccacgVatWcataVaaagaataMgtgataaKYaaat +cHDaacgataYctRtcYatcgcaMgtNttaBttttgatttaRtStgcaacaaaataccVg +aaDgtVgDcStctatatttattaaaaRKDatagaaagaKaaYYcaYSgKStctccSttac +agtcNactttDVttagaaagMHttRaNcSaRaMgBttattggtttaRMggatggcKDgWR +tNaataataWKKacttcKWaaagNaBttaBatMHtccattaacttccccYtcBcYRtaga +ttaagctaaYBDttaNtgaaaccHcaRMtKtaaHMcNBttaNaNcVcgVttWNtDaBatg +ataaVtcWKcttRggWatcattgaRagHgaattNtatttctctattaattaatgaDaaMa +tacgttgggcHaYVaaNaDDttHtcaaHtcVVDgBVagcMacgtgttaaBRNtatRtcag +taagaggtttaagacaVaaggttaWatctccgtVtaDtcDatttccVatgtacNtttccg +tHttatKgScBatgtVgHtYcWagcaKtaMYaaHgtaattaSaHcgcagtWNaatNccNN +YcacgVaagaRacttctcattcccRtgtgtaattagcSttaaStWaMtctNNcSMacatt +ataaactaDgtatWgtagtttaagaaaattgtagtNagtcaataaatttgatMMYactaa +tatcggBWDtVcYttcDHtVttatacYaRgaMaacaStaatcRttttVtagaDtcacWat +ttWtgaaaagaaagNRacDtttStVatBaDNtaactatatcBSMcccaSttccggaMatg +attaaWatKMaBaBatttgataNctgttKtVaagtcagScgaaaDggaWgtgttttKtWt +atttHaatgtagttcactaaKMagttSYBtKtaYgaactcagagRtatagtVtatcaaaW +YagcgNtaDagtacNSaaYDgatBgtcgataacYDtaaactacagWDcYKaagtttatta +gcatcgagttKcatDaattgattatDtcagRtWSKtcgNtMaaaaacaMttKcaWcaaSV +MaaaccagMVtaMaDtMaHaBgaacataBBVtaatVYaNSWcSgNtDNaaKacacBttta +tKtgtttcaaHaMctcagtaacgtcgYtactDcgcctaNgagagcYgatattttaaattt +ccattttacatttDaaRctattttWctttacgtDatYtttcagacgcaaVttagtaaKaa +aRtgVtccataBggacttatttgtttaWNtgttVWtaWNVDaattgtatttBaagcBtaa +BttaaVatcHcaVgacattccNggtcgacKttaaaRtagRtctWagaYggtgMtataatM +tgaaRttattttgWcttNtDRRgMDKacagaaaaggaaaRStcccagtYccVattaNaaK +StNWtgacaVtagaagcttSaaDtcacaacgDYacWDYtgtttKatcVtgcMaDaSKStV +cgtagaaWaKaagtttcHaHgMgMtctataagBtKaaaKKcactggagRRttaagaBaaN +atVVcgRcKSttDaactagtSttSattgttgaaRYatggttVttaataaHttccaagDtg +atNWtaagHtgcYtaactRgcaatgMgtgtRaatRaNaacHKtagactactggaatttcg +ccataacgMctRgatgttaccctaHgtgWaYcactcacYaattcttaBtgacttaaacct +gYgaWatgBttcttVttcgttWttMcNYgtaaaatctYgMgaaattacNgaHgaacDVVM +tttggtHtctaaRgtacagacgHtVtaBMNBgattagcttaRcttacaHcRctgttcaaD +BggttKaacatgKtttYataVaNattccgMcgcgtagtRaVVaattaKaatggttRgaMc +agtatcWBttNtHagctaatctagaaNaaacaYBctatcgcVctBtgcaaagDgttVtga +HtactSNYtaaNccatgtgDacgaVtDcgKaRtacDcttgctaagggcagMDagggtBWR +tttSgccttttttaacgtcHctaVtVDtagatcaNMaVtcVacatHctDWNaataRgcgt +aVHaggtaaaaSgtttMtattDgBtctgatSgtRagagYtctSaKWaataMgattRKtaa +catttYcgtaacacattRWtBtcggtaaatMtaaacBatttctKagtcDtttgcBtKYYB +aKttctVttgttaDtgattttcttccacttgSaaacggaaaNDaattcYNNaWcgaaYat +tttMgcBtcatRtgtaaagatgaWtgaccaYBHgaatagataVVtHtttVgYBtMctaMt +cctgaDcYttgtccaaaRNtacagcMctKaaaggatttacatgtttaaWSaYaKttBtag +DacactagctMtttNaKtctttcNcSattNacttggaacaatDagtattRtgSHaataat +gccVgacccgatactatccctgtRctttgagaSgatcatatcgDcagWaaHSgctYYWta +tHttggttctttatVattatcgactaagtgtagcatVgtgHMtttgtttcgttaKattcM +atttgtttWcaaStNatgtHcaaaDtaagBaKBtRgaBgDtSagtatMtaacYaatYtVc +KatgtgcaacVaaaatactKcRgtaYtgtNgBBNcKtcttaccttKgaRaYcaNKtactt +tgagSBtgtRagaNgcaaaNcacagtVtttHWatgttaNatBgtttaatNgVtctgaata +tcaRtattcttttttttRaaKcRStctcggDgKagattaMaaaKtcaHacttaataataK +taRgDtKVBttttcgtKaggHHcatgttagHggttNctcgtatKKagVagRaaaggaaBt +NatttVKcRttaHctaHtcaaatgtaggHccaBataNaNaggttgcWaatctgatYcaaa +HaatWtaVgaaBttagtaagaKKtaaaKtRHatMaDBtBctagcatWtatttgWttVaaa +ScMNattRactttgtYtttaaaagtaagtMtaMaSttMBtatgaBtttaKtgaatgagYg +tNNacMtcNRacMMHcttWtgtRtctttaacaacattattcYaMagBaacYttMatcttK +cRMtgMNccattaRttNatHaHNaSaaHMacacaVaatacaKaSttHatattMtVatWga +ttttttaYctttKttHgScWaacgHtttcaVaaMgaacagNatcgttaacaaaaagtaca +HBNaattgttKtcttVttaaBtctgctacgBgcWtttcaggacacatMgacatcccagcg +gMgaVKaBattgacttaatgacacacaaaaaatRKaaBctacgtRaDcgtagcVBaacDS +BHaaaaSacatatacagacRNatcttNaaVtaaaataHattagtaaaaSWccgtatWatg +gDttaactattgcccatcttHaSgYataBttBaactattBtcHtgatcaataSttaBtat +KSHYttWggtcYtttBttaataccRgVatStaHaKagaatNtagRMNgtcttYaaSaact +cagDSgagaaYtMttDtMRVgWKWtgMaKtKaDttttgactatacataatcNtatNaHat +tVagacgYgatatatttttgtStWaaatctWaMgagaRttRatacgStgattcttaagaD +taWccaaatRcagcagaaNKagtaaDggcgccBtYtagSBMtactaaataMataBSacRM +gDgattMMgtcHtcaYDtRaDaacggttDaggcMtttatgttaNctaattaVacgaaMMt +aatDccSgtattgaRtWWaccaccgagtactMcgVNgctDctaMScatagcgtcaactat +acRacgHRttgctatttaatgaattataYKttgtaagWgtYttgcHgMtaMattWaWVta +RgcttgYgttBHtYataSccStBtgtagMgtDtggcVaaSBaatagDttgBgtctttctc +attttaNagtHKtaMWcYactVcgcgtatMVtttRacVagDaatcttgctBBcRDgcaac +KttgatSKtYtagBMagaRtcgBattHcBWcaactgatttaatttWDccatttatcgagS +KaWttataHactaHMttaatHtggaHtHagaatgtKtaaRactgtttMatacgatcaagD +gatKaDctataMggtHDtggHacctttRtatcttYattttgacttgaaSaataaatYcgB +aaaaccgNatVBttMacHaKaataagtatKgtcaagactcttaHttcggaattgttDtct +aaccHttttWaaatgaaatataaaWattccYDtKtaaaacggtgaggWVtctattagtga +ctattaagtMgtttaagcatttgSgaaatatccHaaggMaaaattttcWtatKctagDtY +tMcctagagHcactttactatacaaacattaacttaHatcVMYattYgVgtMttaaRtga +aataaDatcaHgtHHatKcDYaatcttMtNcgatYatgSaMaNtcttKcWataScKggta +tcttacgcttWaaagNatgMgHtctttNtaacVtgttcMaaRatccggggactcMtttaY +MtcWRgNctgNccKatcttgYDcMgattNYaRagatHaaHgKctcataRDttacatBatc +cattgDWttatttaWgtcggagaaaaatacaatacSNtgggtttccttacSMaagBatta +caMaNcactMttatgaRBacYcYtcaaaWtagctSaacttWgDMHgaggatgBVgcHaDt +ggaactttggtcNatNgtaKaBcccaNtaagttBaacagtatacDYttcctNgWgcgSMc +acatStctHatgRcNcgtacacaatRttMggaNKKggataaaSaYcMVcMgtaMaHtgat +tYMatYcggtcttcctHtcDccgtgRatcattgcgccgatatMaaYaataaYSggatagc +gcBtNtaaaScaKgttBgagVagttaKagagtatVaactaSacWactSaKatWccaKaaa +atBKgaaKtDMattttgtaaatcRctMatcaaMagMttDgVatggMaaWgttcgaWatga +aatttgRtYtattaWHKcRgctacatKttctaccaaHttRatctaYattaaWatVNccat +NgagtcKttKataStRaatatattcctRWatDctVagttYDgSBaatYgttttgtVaatt +taatagcagMatRaacttBctattgtMagagattaaactaMatVtHtaaatctRgaaaaa +aaatttWacaacaYccYDSaattMatgaccKtaBKWBattgtcaagcHKaagttMMtaat +ttcKcMagNaaKagattggMagaggtaatttYacatcWaaDgatMgKHacMacgcVaaca +DtaDatatYggttBcgtatgWgaSatttgtagaHYRVacaRtctHaaRtatgaactaata +tctSSBgggaaHMWtcaagatKgagtDaSatagttgattVRatNtctMtcSaagaSHaat +aNataataRaaRgattctttaataaagWaRHcYgcatgtWRcttgaaggaMcaataBRaa +ccagStaaacNtttcaatataYtaatatgHaDgcStcWttaacctaRgtYaRtataKtgM +ttttatgactaaaatttacYatcccRWtttHRtattaaatgtttatatttgttYaatMca +RcSVaaDatcgtaYMcatgtagacatgaaattgRtcaaYaaYtRBatKacttataccaNa +aattVaBtctggacaagKaaYaaatatWtMtatcYaaVNtcgHaactBaagKcHgtctac +aatWtaDtSgtaHcataHtactgataNctRgttMtDcDttatHtcgtacatcccaggStt +aBgtcacacWtccNMcNatMVaVgtccDYStatMaccDatggYaRKaaagataRatttHK +tSaaatDgataaacttaHgttgVBtcttVttHgDacgaKatgtatatNYataactctSat +atatattgcHRRYttStggaactHgttttYtttaWtatMcttttctatctDtagVHYgMR +BgtHttcctaatYRttKtaagatggaVRataKDctaMtKBNtMtHNtWtttYcVtattMc +gRaacMcctNSctcatttaaagDcaHtYccSgatgcaatYaaaaDcttcgtaWtaattct +cgttttScttggtaatctttYgtctaactKataHacctMctcttacHtKataacacagcN +RatgKatttttSaaatRYcgDttaMRcgaaattactMtgcgtaagcgttatBtttttaat +taagtNacatHgttcRgacKcBBtVgatKttcgaBaatactDRgtRtgaNacWtcacYtt +aaKcgttctHaKttaNaMgWgWaggtctRgaKgWttSttBtDcNtgtttacaaatYcDRt +gVtgcctattcNtctaaaDMNttttNtggctgagaVctDaacVtWccaagtaacacaNct +gaScattccDHcVBatcgatgtMtaatBgHaatDctMYgagaatgYWKcctaatNaStHa +aaKccgHgcgtYaaYtattgtStgtgcaaRtattaKatattagaWVtcaMtBagttatta +gNaWHcVgcaattttDcMtgtaRHVYtHtctgtaaaaHVtMKacatcgNaatttMatatg +ttgttactagWYtaRacgataKagYNKcattataNaRtgaacKaYgcaaYYacaNccHat +MatDcNgtHttRaWttagaaDcaaaaaatagggtKDtStaDaRtaVtHWKNtgtattVct +SVgRgataDaRaWataBgaagaaKtaataaYgDcaStaNgtaDaaggtattHaRaWMYaY +aWtggttHYgagVtgtgcttttcaaDKcagVcgttagacNaaWtagtaataDttctggtt +VcatcataaagtgKaaaNaMtaBBaattaatWaattgctHaVKaSgDaaVKaHtatatat +HatcatSBagNgHtatcHYMHgttDgtaHtBttWatcgtttaRaattgStKgSKNWKatc +agDtctcagatttctRtYtBatBgHHtKaWtgYBgacVVWaKtacKcDttKMaKaVcggt +gttataagaataaHaatattagtataatMHgttYgaRttagtaRtcaaVatacggtcMcg +agtaaRttacWgactKRYataaaagSattYaWgagatYagKagatgSaagKgttaatMgg +tataatgttWYttatgagaaacctNVataatHcccKtDctcctaatactggctHggaSag +gRtKHaWaattcgSatMatttagaggcYtctaMcgctcataSatatgRagacNaaDagga +VBagaYttKtacNaKgtSYtagttggaWcatcWttaatctatgaVtcgtgtMtatcaYcg +tRccaaYgDctgcMgtgtWgacWtgataacacgcgctBtgttaKtYDtatDcatcagKaV +MctaatcttgVcaaRgcRMtDcgattaHttcaNatgaatMtactacVgtRgatggaWttt +actaaKatgagSaaKggtaNtactVaYtaaKRagaacccacaMtaaMtKtatBcttgtaa +WBtMctaataaVcDaaYtcRHBtcgttNtaaHatttBNgRStVDattBatVtaagttaYa +tVattaagaBcacggtSgtVtatttaRattgatgtaHDKgcaatattKtggcctatgaWD +KRYcggattgRctatNgatacaatMNttctgtcRBYRaaaHctNYattcHtaWcaattct +BtMKtVgYataatMgYtcagcttMDataVtggRtKtgaatgccNcRttcaMtRgattaac +attRcagcctHtWMtgtDRagaKaBtgDttYaaaaKatKgatctVaaYaacWcgcatagB +VtaNtRtYRaggBaaBtgKgttacataagagcatgtRattccacttaccatRaaatgWgD +aMHaYVgVtaSctatcgKaatatattaDgacccYagtgtaYNaaatKcagtBRgagtcca +tgKgaaaccBgaagBtgSttWtacgatWHaYatcgatttRaaNRgcaNaKVacaNtDgat +tgHVaatcDaagcgtatgcNttaDataatcSataaKcaataaHWataBtttatBtcaKtK +tatagttaDgSaYctacaRatNtaWctSaatatttYaKaKtaccWtatcRagacttaYtt +VcKgSDcgagaagatccHtaattctSttatggtKYgtMaHagVaBRatttctgtRgtcta +tgggtaHKgtHacHtSYacgtacacHatacKaaBaVaccaDtatcSaataaHaagagaat +ScagactataaRttagcaaVcaHataKgDacatWccccaagcaBgagWatctaYttgaaa +tctVNcYtttWagHcgcgcDcVaaatgttKcHtNtcaatagtgtNRaactttttcaatgg +WgBcgDtgVgtttctacMtaaataaaRggaaacWaHttaRtNtgctaaRRtVBctYtVta +tDcattDtgaccYatagatYRKatNYKttNgcctagtaWtgaactaMVaacctgaStttc +tgaKVtaaVaRKDttVtVctaDNtataaaDtccccaagtWtcgatcactDgYaBcatcct +MtVtacDaaBtYtMaKNatNtcaNacgDatYcatcgcaRatWBgaacWttKttagYtaat +tcggttgSWttttDWctttacYtatatWtcatDtMgtBttgRtVDggttaacYtacgtac +atgaattgaaWcttMStaDgtatattgaDtcRBcattSgaaVBRgagccaaKtttcDgcg +aSMtatgWattaKttWtgDBMaggBBttBaatWttRtgcNtHcgttttHtKtcWtagHSt +aacagttgatatBtaWSaWggtaataaMttaKacDaatactcBttcaatatHttcBaaSa +aatYggtaRtatNtHcaatcaHtagVtgtattataNggaMtcttHtNagctaaaggtaga +YctMattNaMVNtcKtactBKcaHHcBttaSagaKacataYgctaKaYgttYcgacWVtt +WtSagcaacatcccHaccKtcttaacgaKttcacKtNtacHtatatRtaaatacactaBt +ttgaHaRttggttWtatYagcatYDatcggagagcWBataagRtacctataRKgtBgatg +aDatataSttagBaHtaatNtaDWcWtgtaattacagKttcNtMagtattaNgtctcgtc +ctcttBaHaKcKccgtRcaaYagSattaagtKataDatatatagtcDtaacaWHcaKttD +gaaRcgtgYttgtcatatNtatttttatggccHtgDtYHtWgttatYaacaattcaWtat +NgctcaaaSttRgctaatcaaatNatcgtttaBtNNVtgttataagcaaagattBacgtD +atttNatttaaaDcBgtaSKgacgtagataatttcHMVNttgttBtDtgtaWKaaRMcKM +tHtaVtagataWctccNNaSWtVaHatctcMgggDgtNHtDaDttatatVWttgttattt +aacctttcacaaggaSaDcggttttttatatVtctgVtaacaStDVaKactaMtttaSNa +gtgaaattaNacttSKctattcctctaSagKcaVttaagNaVcttaVaaRNaHaaHttat +gtHttgtgatMccaggtaDcgaccgtWgtWMtttaHcRtattgScctatttKtaaccaag +tYagaHgtWcHaatgccKNRtttagtMYSgaDatctgtgaWDtccMNcgHgcaaacNDaa +aRaStDWtcaaaaHKtaNBctagBtgtattaactaattttVctagaatggcWSatMaccc +ttHttaSgSgtgMRcatRVKtatctgaaaccDNatYgaaVHNgatMgHRtacttaaaRta +tStRtDtatDttYatattHggaBcttHgcgattgaKcKtttcRataMtcgaVttWacatN +catacctRataDDatVaWNcggttgaHtgtMacVtttaBHtgagVttMaataattatgtt +cttagtttgtgcDtSatttgBtcaacHattaaBagVWcgcaSYttMgcttacYKtVtatc +aYaKctgBatgcgggcYcaaaaacgNtctagKBtattatctttKtaVttatagtaYtRag +NtaYataaVtgaatatcHgcaaRataHtacacatgtaNtgtcgYatWMatttgaactacR +ctaWtWtatacaatctBatatgYtaagtatgtgtatSttactVatcttYtaBcKgRaSgg +RaaaaatgcagtaaaWgtaRgcgataatcBaataccgtatttttccatcNHtatWYgatH +SaaaDHttgctgtccHtggggcctaataatttttctatattYWtcattBtgBRcVttaVM +RSgctaatMagtYtttaaaaatBRtcBttcaaVtaacagctccSaaSttKNtHtKYcagc +agaaaccccRtttttaaDcDtaStatccaagcgctHtatcttaDRYgatDHtWcaaaBcW +gKWHttHataagHacgMNKttMKHccaYcatMVaacgttaKgYcaVaaBtacgcaacttt +MctaaHaatgtBatgagaSatgtatgSRgHgWaVWgataaatatttccKagVgataattW +aHNcYggaaatgctHtKtaDtctaaagtMaatVDVactWtSaaWaaMtaHtaSKtcBRaN +cttStggtBttacNagcatagRgtKtgcgaacaacBcgKaatgataagatgaaaattgta +ctgcgggtccHHWHaaNacaBttNKtKtcaaBatatgctaHNgtKcDWgtttatNgVDHg +accaacWctKaaggHttgaRgYaatHcaBacaatgagcaaattactgtaVaaYaDtagat +tgagNKggtggtgKtWKaatacagDRtatRaMRtgattDggtcaaYRtatttNtagaDtc +acaaSDctDtataatcgtactaHttatacaatYaacaaHttHatHtgcgatRRttNgcat +SVtacWWgaaggagtatVMaVaaattScDDKNcaYBYaDatHgtctatBagcaacaagaa +tgagaaRcataaKNaRtBDatcaaacgcattttttaaBtcSgtacaRggatgtMNaattg +gatatWtgagtattaaaVctgcaYMtatgatttttYgaHtgtcttaagWBttHttgtctt +attDtcgtatWtataataSgctaHagcDVcNtaatcaagtaBDaWaDgtttagYctaNcc +DtaKtaHcttaataacccaRKtacaVaatNgcWRaMgaattatgaBaaagattVYaHMDc +aDHtcRcgYtcttaaaWaaaVKgatacRtttRRKYgaatacaWVacVcRtatMacaBtac +tggMataaattttHggNagSctacHgtBagcgtcgtgattNtttgatSaaggMttctttc +ttNtYNagBtaaacaaatttMgaccttacataattgYtcgacBtVMctgStgMDtagtaR +ctHtatgttcatatVRNWataDKatWcgaaaaagttaaaagcacgHNacgtaatctttMR +tgacttttDacctataaacgaaatatgattagaactccSYtaBctttaataacWgaaaYa +tagatgWttcatKtNgatttttcaagHtaYgaaRaDaagtaggagcttatVtagtctttc +attaaaatcgKtattaRttacagVaDatgcatVgattgggtctttHVtagKaaRBtaHta +aggccccaaaaKatggtttaMWgtBtaaacttcactttKHtcgatctccctaYaBacMgt +cttBaBaNgcgaaacaatctagtHccHtKttcRtRVttccVctttcatacYagMVtMcag +aMaaacaataBctgYtaatRaaagattaaccatVRatHtaRagcgcaBcgDttStttttc +VtttaDtKgcaaWaaaaatSccMcVatgtKgtaKgcgatatgtagtSaaaDttatacaaa +catYaRRcVRHctKtcgacKttaaVctaDaatgttMggRcWaacttttHaDaKaDaBctg +taggcgtttaHBccatccattcNHtDaYtaataMttacggctNVaacDattgatatttta +cVttSaattacaaRtataNDgacVtgaacataVRttttaDtcaaacataYDBtttaatBa +DtttYDaDaMccMttNBttatatgagaaMgaNtattHccNataattcaHagtgaaggDga +tgtatatatgYatgaStcataaBStWacgtcccataRMaaDattggttaaattcMKtctM +acaBSactcggaatDDgatDgcWctaacaccgggaVcacWKVacggtaNatatacctMta +tgatagtgcaKagggVaDtgtaacttggagtcKatatcgMcttRaMagcattaBRaStct +YSggaHYtacaactMBaagDcaBDRaaacMYacaHaattagcattaaaHgcgctaaggSc +cKtgaaKtNaBtatDDcKBSaVtgatVYaagVtctSgMctacgttaacWaaattctSgtD +actaaStaaattgcagBBRVctaatatacctNttMcRggctttMttagacRaHcaBaacV +KgaataHttttMgYgattcYaNRgttMgcVaaacaVVcDHaatttgKtMYgtatBtVVct +WgVtatHtacaaHttcacgatagcagtaaNattBatatatttcVgaDagcggttMaagtc +ScHagaaatgcYNggcgtttttMtStggtRatctacttaaatVVtBacttHNttttaRca +aatcacagHgagagtMgatcSWaNRacagDtatactaaDKaSRtgattctccatSaaRtt +aaYctacacNtaRtaactggatgaccYtacactttaattaattgattYgttcagDtNKtt +agDttaaaaaaaBtttaaNaYWKMBaaaacVcBMtatWtgBatatgaacVtattMtYatM +NYDKNcKgDttDaVtaaaatgggatttctgtaaatWtctcWgtVVagtcgRgacttcccc +taDcacagcRcagagtgtWSatgtacatgttaaSttgtaaHcgatgggMagtgaacttat +RtttaVcaccaWaMgtactaatSSaHtcMgaaYtatcgaaggYgggcgtgaNDtgttMNg +aNDMtaattcgVttttaacatgVatgtWVMatatcaKgaaattcaBcctccWcttgaaWH +tWgHtcgNWgaRgctcBgSgaattgcaaHtgattgtgNagtDttHHgBttaaWcaaWagc +aSaHHtaaaVctRaaMagtaDaatHtDMtcVaWMtagSagcttHSattaacaaagtRacM +tRtctgttagcMtcaBatVKtKtKacgagaSNatSactgtatatcBctgagVtYactgta +aattaaaggcYgDHgtaacatSRDatMMccHatKgttaacgactKtgKagtcttcaaHRV +tccttKgtSataatttacaactggatDNgaacttcaRtVaagDcaWatcBctctHYatHa +DaaatttagYatSatccaWtttagaaatVaacBatHcatcgtacaatatcgcNYRcaata +YaRaYtgattVttgaatgaVaactcRcaNStgtgtattMtgaggtNttBaDRcgaaaagc +tNgBcWaWgtSaDcVtgVaatMKBtttcgtttctaaHctaaagYactgMtatBDtcStga +ccgtSDattYaataHctgggaYYttcggttaWaatctggtRagWMaDagtaacBccacta +cgHWMKaatgatWatcctgHcaBaSctVtcMtgtDttacctaVgatYcWaDRaaaaRtag +atcgaMagtggaRaWctctgMgcWttaagKBRtaaDaaWtctgtaagYMttactaHtaat +cttcataacggcacBtSgcgttNHtgtHccatgttttaaagtatcgaKtMttVcataYBB +aKtaMVaVgtattNDSataHcagtWMtaggtaSaaKgttgBtVtttgttatcatKcgHac +acRtctHatNVagSBgatgHtgaRaSgttRcctaacaaattDNttgacctaaYtBgaaaa +tagttattactcttttgatgtNNtVtgtatMgtcttRttcatttgatgacacttcHSaaa +ccaWWDtWagtaRDDVNacVaRatgttBccttaatHtgtaaacStcVNtcacaSRttcYa +gacagaMMttttgMcNttBcgWBtactgVtaRttctccaaYHBtaaagaBattaYacgat +ttacatctgtaaMKaRYtttttactaaVatWgctBtttDVttctggcDaHaggDaagtcg +aWcaagtagtWttHtgKtVataStccaMcWcaagataagatcactctHatgtcYgaKcat +cagatactaagNSStHcctRRNtattgtccttagttagMVgtatagactaactctVcaat +MctgtttgtgttgccttatWgtaBVtttctggMcaaKgDWtcgtaaYStgSactatttHg +atctgKagtagBtVacRaagRtMctatgggcaaaKaaaatacttcHctaRtgtDcttDat +taggaaatttcYHaRaaBttaatggcacKtgctHVcaDcaaaVDaaaVcgMttgtNagcg +taDWgtcgttaatDgKgagcSatatcSHtagtagttggtgtHaWtaHKtatagctgtVga +ttaBVaatgaataagtaatVatSttaHctttKtttgtagttaccttaatcgtagtcctgB +cgactatttVcMacHaaaggaatgDatggKtaHtgStatattaaSagctWcctccRtata +BaDYcgttgcNaagaggatRaaaYtaWgNtSMcaatttactaacatttaaWttHtatBat +tgtcgacaatNgattgcNgtMaaaKaBDattHacttggtRtttaYaacgVactBtaBaKt +gBttatgVttgtVttcaatcWcNctDBaaBgaDHacBttattNtgtDtatttVSaaacag +gatgcRatSgtaSaNtgBatagttcHBgcBBaaattaHgtDattatDaKaatBaaYaaMa +ataaataKtttYtagtBgMatNcatgtttgaNagtgttgtgKaNaSagtttgaSMaYBca +aaacDStagttVacaaaaactaaWttBaagtctgtgcgtMgtaattctcctacctcaNtt +taaccaaaaVtBcacataacaccccBcWMtatVtggaatgaWtcaaWaaaaaaaaWtDta +atatRcctDWtcctaccMtVVatKttaWaaKaaatataaagScHBagaggBaSMtaWaVt +atattactSaaaKNaactatNatccttgaYctattcaaaVgatttYHcRagattttaSat +aggttattcVtaaagaKgtattattKtRttNcggcRgtgtgtWYtaacHgKatKgatYta +cYagDtWcHBDctctgRaYKaYagcactKcacSaRtBttttBHKcMtNtcBatttatttt +tgSatVgaaagaWtcDtagDatatgMacaacRgatatatgtttgtKtNRaatatNatgYc +aHtgHataacKtgagtagtaacYttaNccaaatHcacaacaVDtagtaYtccagcattNt +acKtBtactaaagaBatVtKaaHBctgStgtBgtatgaSNtgDataaccctgtagcaBgt +gatcttaDataStgaMaccaSBBgWagtacKcgattgaDgNNaaaacacagtSatBacKD +gcgtataBKcatacactaSaatYtYcDaactHttcatRtttaatcaattataRtttgtaa +gMcgNttcatcBtYBagtNWNMtSHcattcRctttttRWgaKacKttgggagBcgttcgc +MaWHtaatactgtctctatttataVgtttaBScttttaBMaNaatMacactYtBMggtHa +cMagtaRtctgcatttaHtcaaaatttgagKtgNtactBacaHtcgtatttctMaSRagc +agttaatgtNtaaattgagagWcKtaNttagVtacgatttgaatttcgRtgtWcVatcgt +taaDVctgtttBWgaccagaaagtcSgtVtatagaBccttttcctaaattgHtatcggRa +ttttcaaggcYSKaagWaWtRactaaaacccBatMtttBaatYtaagaactSttcgaaSc +aatagtattgaccaagtgttttctaacatgtttNVaatcaaagagaaaNattaaRtttta +VaaaccgcaggNMtatattVctcaagaggaacgBgtttaacaagttcKcYaatatactaa +ccBaaaSggttcNtattctagttRtBacgScVctcaatttaatYtaaaaaaatgSaatga +tagaMBRatgRcMcgttgaWHtcaVYgaatYtaatctttYttatRaWtctgBtDcgatNa +tcKaBaDgatgtaNatWKctccgatattaacattNaaacDatgBgttctgtDtaaaMggt +gaBaSHataacgccSctaBtttaRBtcNHcDatcDcctagagtcRtaBgWttDRVHagat +tYatgtatcWtaHtttYcattWtaaagtctNgtStggRNcgcggagSSaaagaaaatYcH +DtcgctttaatgYcKBVSgtattRaYBaDaaatBgtatgaHtaaRaRgcaSWNtagatHa +acttNctBtcaccatctMcatattccaSatttgcgaDagDgtatYtaaaVDtaagtttWV +aagtagYatRttaagDcNgacKBcScagHtattatcDaDactaaaaaYgHttBcgaDttg +gataaaKSRcBMaBcgaBSttcWtgNBatRaccgattcatttataacggHVtaattcaca +agagVttaaRaatVVRKcgWtVgacctgDgYaaHaWtctttcacMagggatVgactagMa +aataKaaNWagKatagNaaWtaaaatttgaattttatttgctaaVgaHatBatcaaBWcB +gttcMatcgBaaNgttcgSNaggSaRtttgHtRtattaNttcDcatSaVttttcgaaaaa +ttgHatctaRaggSaNatMDaaatDcacgattttagaHgHaWtYgattaatHNSttatMS +gggNtcKtYatRggtttgtMWVtttaYtagcagBagHaYagttatatggtBacYcattaR +SataBatMtttaaatctHcaaaSaaaagttNSaaWcWRccRtKaagtBWtcaaattSttM +tattggaaaccttaacgttBtWatttatatWcDaatagattcctScacctaagggRaaYt +aNaatgVtBcttaaBaacaMVaaattatStYgRcctgtactatcMcVKatttcgSgatRH +MaaaHtagtaaHtVgcaaataatatcgKKtgccaatBNgaaWcVttgagttaKatagttc +aggKDatDtattgaKaVcaKtaataDataataHSaHcattagttaatRVYcNaHtaRcaa +ggtNHcgtcaaccaBaaagYtHWaaaRcKgaYaaDttgcWYtataRgaatatgtYtgcKt +aNttWacatYHctRaDtYtattcBttttatcSataYaYgttWaRagcacHMgtttHtYtt +YaatcggtatStttcgtRSattaaDaKMaatatactaNBaWgctacacYtgaYVgtgHta +aaRaaRgHtagtWattataaaSDaaWtgMattatcgaaaagtaYRSaWtSgNtBgagcRY +aMDtactaacttaWgtatctagacaagNtattHggataatYttYatcataDcgHgttBtt +ctttVttgccgaaWtaaaacgKgtatctaaaaaNtccDtaDatBMaMggaatNKtatBaa +atVtccRaHtaSacataHattgtttKVYattcataVaattWtcgtgMttcttKtgtctaa +cVtatctatatBRataactcgKatStatattcatHHRttKtccaacgtgggtgRgtgaMt +attattggctatcgtgacMtRcBDtcttgtactaatRHttttaagatcgVMDStattatY +BtttDttgtBtNttgRcMtYtgBacHaWaBaatDKctaagtgaaactaatgRaaKgatcc +aagNaaaatattaggWNtaagtatacttttKcgtcggSYtcttgRctataYcttatataa +agtatattaatttataVaacacaDHatctatttttKYVatHRactttaBHccaWagtact +BtcacgaVgcgttRtttttttSVgtSagtBaaattctgaHgactcttgMcattttagVta +agaattHctHtcaDaaNtaacRggWatagttcgtSttgaDatcNgNagctagDgatcNtt +KgttgtaDtctttRaaYStRatDtgMggactSttaDtagSaVtBDttgtDgccatcacaM +attaaaMtNacaVcgSWcVaaDatcaHaatgaattaMtatccVtctBtaattgtWattat +BRcWcaatgNNtactWYtDaKttaaatcactcagtRaaRgatggtKgcgccaaHgaggat +StattYcaNMtcaBttacttatgagDaNtaMgaaWtgtttcttctaHtMNgttatctaWW +atMtBtaaatagDVatgtBYtatcggcttaagacMRtaHScgatatYgRDtcattatSDa +HggaaataNgaWSRRaaaBaatagBattaDctttgHWNttacaataaaaaaatacggttt +gHgVtaHtWMttNtBtctagtMcgKMgHgYtataHaNagWtcaacYattaataYRgtaWK +gaBctataaccgatttaHaNBRaRaMtccggtNgacMtctcatttgcaattcWgMactta +caaDaaNtactWatVtttagccttMaatcagVaagtctVaaDaBtattaattaYtNaYtg +gattaKtaKctYaMtattYgatattataatKtVgDcttatatNBtcgttgtStttttMag +aggttaHYSttcKgtcKtDNtataagttataagSgttatDtRttattgttttSNggRtca +aKMNatgaatattgtBWtaMacctgggYgaSgaagYataagattacgagaatBtggtRcV +HtgYggaDgaYaKagWagctatagacgaaHgtWaNgacttHRatVaWacKYtgRVNgVcS +gRWctacatcKSactctgWYtBggtataagcttNRttVtgRcaWaaatDMatYattaact +ttcgaagRatSctgccttgcRKaccHtttSNVagtagHagBagttagaccaRtataBcca +taatSHatRtcHagacBWatagcaMtacaRtgtgaaBatctKRtScttccaNaatcNgta +atatWtcaMgactctBtWtaaNactHaaaaRctcgcatggctMcaaNtcagaaaaacaca +gtggggWttRttagtaagaVctVMtcgaatcttcMaaaHcaHBttcgattatgtcaDagc +YRtBtYcgacMgtDcagcgaNgttaataatagcagKYYtcgtaBtYctMaRtaRtDagaa +aacacatgYaBttgattattcgaaNttBctSataaMataWRgaHtttccgtDgaYtatgg +tDgHKgMtatttVtMtVagttaRatMattRagataaccctKctMtSttgaHagtcStcta +tttccSagatgttccacgaggYNttHRacgattcDatatDcataaaatBBttatcgaHtN +HaaatatDNaggctgaNcaaggagttBttMgRagVatBcRtaWgatgBtSgaKtcgHttt +gaatcaaDaHttcSBgHcagtVaaSttDcagccgttNBtgttHagYtattctttRWaaVt +SttcatatKaaRaaaNacaVtVctMtSDtDtRHRcgtaatgctcttaaatSacacaatcg +HattcaWcttaaaatHaaatcNctWttaNMcMtaKctVtcctaagYgatgatcYaaaRac +tctaRDaYagtaacgtDgaggaaatctcaaacatcaScttcKttNtaccatNtaNataca +tttHaaDHgcaDatMWaaBttcRggctMaagctVYcacgatcaDttatYtaatcKatWat +caatVYtNagatttgattgaYttttYgacttVtcKaRagaaaHVgDtaMatKYagagttN +atWttaccNtYtcDWgSatgaRgtMatgKtcgacaagWtacttaagtcgKtgatccttNc +ttatagMatHVggtagcgHctatagccctYttggtaattKNaacgaaYatatVctaataM +aaaYtgVtcKaYtaataacagaatHcacVagatYWHttagaaSMaatWtYtgtaaagNaa +acaVgaWtcacNWgataNttcaSagctMDaRttgNactaccgataMaaatgtttattDtc +aagacgctDHYYatggttcaagccNctccttcMctttagacBtaaWtaWVHggaaaaNat +ttaDtDtgctaaHHtMtatNtMtagtcatttgcaaaRatacagRHtatDNtgtDgaatVg +tVNtcaaatYBMaaaagcaKgtgatgatMgWWMaHttttMgMagatDtataaattaacca +actMtacataaattgRataatacgBtKtaataattRgtatDagDtcRDacctatRcagag +cSHatNtcaScNtttggacNtaaggaccgtgKNttgttNcttgaaRgYgRtNtcagttBc +ttttcHtKtgcttYaaNgYagtaaatgaatggWaMattBHtatctatSgtcYtgcHtaat +tHgaaMtHcagaaSatggtatgccaHBtYtcNattWtgtNgctttaggtttgtWatNtgH +tgcDttactttttttgcNtactKtWRaVcttcatagtgSNKaNccgaataaBttataata +YtSagctttaaatSttggctaaKSaatRccgWHgagDttaaatcatgagMtcgagtVtaD +ggaBtatttgDacataaacgtagYRagBWtgDStKDgatgaagttcattatttaKWcata +aatWRgatataRgttRacaaNKttNtKagaaYaStaactScattattaacgatttaaatg +DtaattagatHgaYataaactatggggatVHtgccgtNgatNYcaStRtagaccacWcaM +tatRagHgVactYtWHtcttcatgatWgagaKggagtatgaWtDtVtNaNtcgYYgtaaa +ctttaDtBactagtaDctatagtaatatttatatataacgHaaaRagKattSagttYtSt +>THREE Homo sapiens frequency +agagagacgatgaaaattaatcgtcaatacgctggcgaacactgagggggacccaatgct +cttctcggtctaaaaaggaatgtgtcagaaattggtcagttcaaaagtagaccggatctt +tgcggagaacaattcacggaacgtagcgttgggaaatatcctttctaccacacatcggat +tttcgccctctcccattatttattgtgttctcacatagaattattgtttagacatccctc +gttgtatggagagttgcccgagcgtaaaggcataatccatataccgccgggtgagtgacc +tgaaattgtttttagttgggatttcgctatggattagcttacacgaagagattctaatgg +tactataggataattataatgctgcgtggcgcagtacaccgttacaaacgtcgttcgcat +atgtggctaacacggtgaaaatacctacatcgtatttgcaatttcggtcgtttcatagag +cgcattgaattactcaaaaattatatatgttgattatttgattagactgcgtggaaagaa +ggggtactcaagccatttgtaaaagctgcatctcgcttaagtttgagagcttacattagt +ctatttcagtcttctaggaaatgtctgtgtgagtggttgtcgtccataggtcactggcat +atgcgattcatgacatgctaaactaagaaagtagattactattaccggcatgcctaatgc +gattgcactgctatgaaggtgcggacgtcgcgcccatgtagccctgataataccaatact +tacatttggtcagcaattctgacattatacctagcacccataaatttactcagacttgag +gacaggctcttggagtcgatcttctgtttgtatgcatgtgatcatatagatgaataagcg +atgcgactagttagggcatagtatagatctgtgtatacagttcagctgaacgtccgcgag +tggaagtacagctgagatctatcctaaaatgcaaccatatcgttcacacatgatatgaac +ccagggggaaacattgagttcagttaaattggcagcgaatcccccaagaagaaggcggag +tgacgttgaacgggcttatggtttttcagtacttcctccgtataagttgagcgaaatgta +aacagaataatcgttgtgttaacaacattaaaatcgcggaatatgatgagaatacacagt +gtgagcatttcacttgtaaaatatctttggtagaacttactttgctttaaatatgttaaa +ccgatctaataatctacaaaacggtagattttgcctagcacattgcgtccttctctattc +agatagaggcaatactcagaaggttttatccaaagcactgtgttgactaacctaagtttt +agtctaataatcatgattgattataggtgccgtggactacatgactcgtccacaaataat +acttagcagatcagcaattggccaagcacccgacttttatttaatggttgtgcaatagtc +cagattcgtattcgggactctttcaaataatagtttcctggcatctaagtaagaaaagct +cataaggaagcgatattatgacacgctcttccgccgctgttttgaaacttgagtattgct +cgtccgaaattgagggtcacttcaaaatttactgagaagacgaagatcgactaaagttaa +aatgctagtccacagttggtcaagttgaattcatccacgagttatatagctattttaatt +tatagtcgagtgtacaaaaaacatccacaataagatttatcttagaataacaacccccgt +atcatcgaaatcctccgttatggcctgactcctcgagcttatagcatttgtgctggcgct +cttgccaggaacttgctcgcgaggtggtgacgagtgagatgatcagtttcattatgatga +tacgattttatcgcgactagttaatcatcatagcaagtaaaatttgaattatgtcattat +catgctccattaacaggttatttaattgatactgacgaaattttttcacaatgggttttc +tagaatttaatatcagtaattgaagccttcataggggtcctactagtatcctacacgacg +caggtccgcagtatcctggagggacgtgttactgattaaaagggtcaaaggaatgaaggc +tcacaatgttacctgcttcaccatagtgagccgatgagttttacattagtactaaatccc +aaatcatactttacgatgaggcttgctagcgctaaagagaatacatacaccaccacatag +aattgttagcgatgatatcaaatagactcctggaagtgtcagggggaaactgttcaatat +ttcgtccacaggactgaccaggcatggaaaagactgacgttggaaactataccatctcac +gcccgacgcttcactaattgatgatccaaaaaatatagcccggattcctgattagcaaag +ggttcacagagaaagatattatcgacgtatatcccaaaaaacagacgtaatgtgcatctt +cgaatcgggatgaatacttgtatcataaaaatgtgacctctagtatacaggttaatgtta +gtgatacacaatactcgtgggccatgggttctcaaataaaatgtaatattgcgtcgatca +ctcacccacgtatttggtctaattatgttttatttagtgacaatccaatagataaccggt +cctattaagggctatatttttagcgaccacgcgtttaaacaaaggattgtatgtagatgg +taccagtttaattgccagtgggcaatcctaagcaaaatgagattctatcctaaagtttgg +gcttgatataagatttcggatgtatgggttttataatcgttggagagctcaatcatgagc +taatacatggatttcgctacctcaccgagagaccttgcatgaagaattctaaccaaaagt +ttaataggccggattggattgagttaattaagaccttgttcagtcatagtaaaaaccctt +aaattttaccgattgacaaagtgagcagtcgcaataccctatgcgaaacgcctcgatagt +gactaggtatacaaggtttttgagttcctttgaaatagttaactaatttaaaattaatta +acgacatggaaatcacagaacctaatgctttgtaggagttatttatgctgtttactgcct +ctacaaccctaataaagcagtcctaagaatgaaacgcatcttttagttcagaaagtggta +tccagggtggtcaatttaataaattcaacatcgggtctcaggatattcggtcatataatt +tattaagggctcttcgagtcttactctgagtgaaattggaaacagtcatccttttcgttg +tgaggcatcttacaccgctatcgatatacaatgcattccaccgcggtgtcccgtacacaa +ggaaacttgttaccttggggatataagaaaactcacacgtctcattattaaactgagtac +aatttttgcacgagaaagtaatgcaatacaatatgatgaaagccagctaatgaaaaggga +tggaacgcacctcggatctgttgcactggattaaaatccgattatttttaaaaatattca +gtgctagagcatatcaggtctacttttttatctggtatgtaaagcccacggagcgatagt +gagatccttacgactcaacgaaaagttataacataactcccgttagccaaagcccaatcc +cgattactgccctaccctaacgtctgccatctaaatatcgaacttgttatgatcaatgtg +actacctcccaccctttccccttcatttgttccactggggataagctagcgttttcagaa +tcaatgcaataagaatagccaattgtctcacttcatcagagctcttggcaattccaggcg +ctacgtggttctggaatatattcatttttcaaatagtaatacgtttagtgttgctattgt +ctacacgtttggatattacgttatgtgagcggacatcaatagttgtctaactctttagta +agccagagatagcactcttagcgaatggataccatcttccataagtttagttaatagtcc +gaaacaactgcttcgagcatatttgaacctccttgtaggcaaatagcctcttcaaagcaa +tcttactaatagatagagtttgttttaagggactactagaaatgggacaatcttaatagt +atgacctaaactgacatttaaagatatatccaggtggcaagcataaagatcattgcgcca +cctccaccgtgggattacttatcagtcgatatcctatatgctaagtttgcgacggcagaa +tacaaactaagctgagttgatgctaaccttacctatgataccccattggaccggttaaca +gccctacttattccaaataaaagaacttttatgctgtagaagctattatagtgatgcctg +gtaacttcagtatattaaaatgacacacatacgccatatagagctcctggaactttgaat +aatgagcgaacttcgaagttgaagagcaagaaaccatatgtcacggttgcctaaagcccg +gtaaccagacatgtgctatcattgatcattatcgaggttttcataaccttgacccattat +cggctgtgcgcggacaagtacttaaatcactagtttcttcacctgcttatcggtaagaaa +taaggttggcaaagaatcgcataagacggacgtagagccgcagcgttgtgcgagtccagg +tgcatgcgcagcaataggattttaaattttgttccatttttaatttagccgtaaggatgt +ccgtaaatgattgaaaattggattcaatctttgggcctatgctactggaacctgatcgac +aaaatttcaaacatacgttaactccgaaagaccgtatttttgcggctagaatagtcagtc +gcttggagccatataccttaccacttaaacgacgtgctcctgtagttgaaatataaacag +aacacaaagactaccgatcatatcaactgaagatctttgtaactttgaggcgaagcaccc +tcttcgagacaactaagagtaaagtaccgggcgccgcaaggagtcgattgggaccctaaa +tcttgacgaattgctaagaggctcagagctaccactgtaatttctctagagcccataata +aatgaacgatacatccgtaggtagcacctaagggattataatggaagccaaatgcagtta +ataatattatatactggcgtacacgattcgacggatctctcacatagtgattcacgaccc +ccccctttgattgacacagcgtcagcattttgcaagaacgatcttctgcatagggtgcgc +caccgtaaggatgacgtcgaagctacaactgggtataatttaccatgcttccctgatgct +gagtgcaatacactaagaatgagtttttaccccatatcaccagtatttgttctgttattg +cgaagaaatggctatgctgagttggcgactaaagtcacccatcctttttattaggtaacc +ccctcccttaaactaactgatttgctggagctgccctgcatacatatactttatcattta +tggacgtccgtgacgcttattatccaccatagtcgatatgctacacggattcattaatgg +atcgtaggagtttaagttatatttactaagatcggtctcggctactatcccgccttaccc +ggcgctatttacggccatttttaatatattgacggtaattattcctatggtttcgaccgc +acgtccttggacaagaaagaatggcaaaaaaaatgtaaaagaaaaaaaatattgagtccc +taccatcatataaaaaatatgtgatgagtaacttgacgaaatgttagtggttattaaaga +ctatctattacaccttttgttttctgtcgtagtatattaaagtctagaagccttacagga +aaatcagggttatacagccgatactccgcagcatgaatcatcgaggaggtgtcctaccat +cgcgccttgtaatcttgtctgtgtatactgtatttagaccttttatacaaagtaaatatc +tcggctttatgtgattgggaggggcctactcaaacatgatgacttgacctaataatcact +gtgcgggcgtcttatgactagctattccttgaaatccaccaccaaatggttaatatgtaa +aaactttgacgatgaaacaaggtgaatgtgtagttactttgtgtaattagctgcgtcgag +cattgcttgtaaaaccgtcaatcgcacacgttacttccataaaatttctacgaatacacc +cttcttaaaaaaaacgtaggaattcacgagtttaacaaacgataactgtataaagtggaa +gtccgaagaaagcagatgcccgaactactcgaagatgtttcgttttcttaaccatagggg +cttcttaatggcccactacgcacattttgttcaagcccgagagggacatccccattacgg +gagtattactaaaactgttccgtaatacgttcagcaagggatgaaaaaggccactgctca +agttattgacgtgggagtattacatcggaagcctgaatcccacactatgatggtctgtac +aggcctagggactgcgtctagacggtattaccggcttctaatcatacgatcgtgagtctt +aacgggaagtaaggctcacacctaccccaaaccatttatctatgtaagtataaaattgtg +cgtaagtgttcaaagtggacaataaagacgtggcaaaaacccccgcacataagccgcttt +agatttcacaaataccaatgcggttaaaaacatccttgagtcgtacatacaccatactcg +cgttaaacggatataacagaagataataaatccggatgtggagtcggtgtaactatagaa +agccaagtgaaataatgcttaccagtcatttagctatacggctttcatttcatgtcaaga +gggtggagtttgacctgtacagttgatatatcaccgatacttagaactcacctaaagcta +aaattgctcgcagcgtgtaatccgcatattacaaacaatagatgggattcattatacata +agacacgatgatctgctttttcaggttgcgagatgttgcctatcgtcaatcgagtcctgc +cttacaccacttaaacaaaagtattgacagggaacctattttcgaggtattatatagtcc +agcttgaatatcaatttgacagttaacctagtgaaaatcagtaagaggaaatacgccaca +ttctccagtgaaattctacgggttatcgtctagtccaactatcaattataactcacgaga +tataagtaaattctcgtacttggcctgatttttattatactttggatccttagtaaacag +gaagggagaaaccttcaacgaaaaacactggattttgttttactctcaaagctcttatat +gacggaaataccctgtcaagtcttaactttattactagactaatgaaatgggcttggggt +ggccagaatcatagtacaatttagcggatacactattcggactttcctatcggctgtctg +gttggataagtatggggactaataggctagacatacctatacttaaactatacaggcgtc +atctatctctgcaactttggagttccctgatgttctcccgccctttgggttcacatcttc +tataccgacacccctaataacgattagtttgtgggttagagtaaattaatacggttaata +ttaatgtatcgttgaaaagctggtgtcgccaataaggtaaccggctaggcagagtatatg +tcacgaagtataactaccctaatgataagctgtaggaataaaattaatgctgtctctaag +cgaagagatatttccgactctgttttaatgacgaatctcattacttctgacttgcaaatg +ttcaatatggcacggtttcacggcacctttgtgacgcatataatgaacttagaagattat +aacgacggaactttatatgataatccgttacgattaaagaatctgttaaatatcataatg +gcattcagttctagaccgtgcatcatggtaaacttactttctctgcatggcgacatacat +ttcgctattcaaattcgcgtgtggttacacccactcgcacctttggaatattaagagaag +atgatcagaaaatccattcgctcaatttttctgacgtacgtctaatttatcctaggagac +aaatcgttttatgtctctcacatttttgaagaaaggttcgagagacaatactcaggtcct +gaactgctagaagatactcggtggagcgtggcaacaatgaaaaactcgtgacataaatga +atgatacttttccaagttcagttaagtgaatatgtttaacatacccggcttttcgatctt +aagctgacgctggacgtgcgagtaatgtcagtctcttacatacactagtgactccaagtt +tcgtcaaaaacgccccctcccttctcgagcccactcacgctatgtattgacgcgaacttg +ttcgggatcagacttttcaggagttcggtcgcgtgtccctatgtgctaatatataagtta +gatcgcattagatgctaatctgaatacttatagacgaccttcaacgagaacgggtaccac +cttgaggctagagttaggtgtgaaacgacaggtagggacatataaaatttgagtgcggct +ttagttaagggtttaattacctactcaaacatcacgctcgcgcccttcgtacgtaatcga +ccatctagaggctaaggggactgtactaggtagtgattaatgatatcctagacgcacgtg +ccttagatcttcagactctgatggtccgcgatcaccgtaattgtagtcctccaactcgat +cactttgttggcgtcaaagaaattacgatatctaaatacttataatacaataaccaagga +tgagaatgactcatcgcgttggagttatattgcttgaagttctatggaatgaaagcacgt +tatctgccgtcccaatatctccagtgagctaattcattggacggtccactttgatcaatc +cccgaggagatgttcggacactttagtctgtaacacttagcgttgagaccacgaacaatt +gattactcagtcttgaaggtgttttccaaagttcattttaaataagactacgataggcct +ttcctattgatataaactacccggctctgttgttcgtgtgagtcgtacttctctgtgttt +ttctgattatagcaagattcgattcttagtgtaaacagcgatttttatttgacccgtcaa +tgagaagcgcataggatctaagcaaaattatcaagttgtgccacaaggtaagatctttcc +agttattgcaggtaggatgtatcccacgttgatagtatgaggtctgacgtcaactgtcta +ggagagttgaccgcgtgcgggtacaccggatttgcatcgatgttgagaacgcagaactcc +cactgtcgtggcggcgttcctgatatttagcaagaggcgttgataaagccctcatcatct +agatctcgacctcatctgccctcttgctccatcattttctacacagactactttcctatc +tacgttagtataattgctttctatcttagtatcatttagagcttctccgtcaacaggttc +gtgctattaaagttagtacgaaagggacaacttgtagcaacgcatttaatcggttttcga +ctacttcgcacaaaatcagataaagaagtttgtcattctattagacattgaattgcgcaa +ttgacttgtaccacttatgatcgaacactgaatcaagactgtgattaactaaaatagaca +agccactatatcaactaataaaaacgcccctggtggtcgaacatagttgactacaggata +attaattggactggagccattacattctctacaatcgtatcacttcccaagtagacaact +ttgaccttgtagtttcatgtacaaaaaaatgctttcgcaggagcacattggtagttcaat +agtttcatgggaacctcttgagccgtcttctgtgggtgtgttcggatagtaggtactgat +aaagtcgtgtcgctttcgatgagagggaattcaccggaaaacaccttggttaacaggata +gtctatgtaaacttcgagacatgtttaagagttaccagcttaatccacggtgctctacta +gtatcatcagctgtcttgcctcgcctagaaatatgcattctatcgttatcctatcaacgg +ttgccgtactgagcagccttattgtggaagagtaatatataaatgtagtcttgtctttac +gaagcagacgtaagtaataatgacttggaataccaaaactaaacatagtggattatcata +ctcaagaactctccagataaataacagtttttacgatacgtcaccaatgagcttaaagat +taggatcctcaaaactgatacaaacgctaattcatttgttattggatccagtatcagtta +aactgaatggagtgaagattgtagaatgttgttctggcctcgcatggggtctaggtgata +tacaatttctcatacttacacggtagtggaaatctgattctagcttcgtagctgactata +ctcaaggaaccactgctcaaggtaggagactagttccgaccctacagtcaaagtggccga +agcttaaactatagactagttgttaaatgctgatttcaagatatcatctatatacagttt +ggacaattatgtgtgcgaaactaaaattcatgctattcagatggatttcacttatgcctt +agaaacagatattgcccgagctcaatcaacagttttagccggaaacaatcgaagcatagg +gacaatgtatcttttcctaaattgccatgtgcagatttctgagtgtcacgaagcgcataa +tagaatcttgtgttgcctcaactcgttgaaaagtttaaaacaatcgcagcagtctttttg +gggtctactgtgtgtttgcaaaataactgaaagaaacgcttgaacaactctgaagtagct +cgagtactcattaaagtgtaacacattagtgaatatcggccaatgaaccaaacgcttccc +ggtacgctatctctctcatcgggaggcgatgtgcaggttatctacgaaagcatcccttta +cgttgagagtgtcgatgcatgaacctcattgtaacaatagcccagcaaattctcatacgt +gcctcagggtccgggcgtactcctccatggaagggcgcgcatctagtgttataccaactc +gctttttaactactatgctgtagttctacaggcatagtggccagtattttctaacttctc +tggatagatgctctcactcctcatccatcacggcttcagtttacgtcttacttgcttgtt +cagcaacggatggaggcattaagtatcttcactgttccctaaaattgctgttcaatatca +aagtaaggacgatacagggaaagctcaagcacactcattgaatactgccccagttgcaac +ctcacttaatctgacaaaaataatgactactctaagtgttgcggaagcagtctcttccac +gagcttgtctgtatcacttcgtataggcatgtaactcgatagacacgaacaccgagtgag +aaactatattcttgcttccgtgtgtgtgacaccaggtaattgatgcggatataagctgga +gatcactcacgcccacacaaggcgctgctacctctttattccaatgtgtaagaatttgct +aacttcatttctagaccgcagctttgcggtcataatttcacggtacggacccttgggtta +gagacttgataacacacttcgcagtttccaccgcgcacatgttttagtggcttctaacat +agaatttttgttgtgacataaagagtgcgtgggagacttgcccgaccgttaagccataat +caattgaaagccccgtgagtcacatctaattggttgtactgcgcatttagctatccttta +gctgactcgaagagattcgattcctaatataggttaattagatggctgccgcgcgaagta +aaacgtgaaaaacgtagtgcgcagatctgcataactcgcgcttaattacttatgagtagt +tccaagttcgctacgttatgagagagattggaattaagcaaatatgttttatggtgattt +tgggatgagaaggactgctaagtacggctactaaacaaatttctaaaaccgccatctacc +ttatcttggagacatttaagttgtatatgtcactagtctagcttttgtctgtgggacgcg +ttctcggaatgagggaaatgcaagagccgattcatcaaatgcttatctaagaaagtagtg +gactattacaccaagcacgaatgccagggaactgctttcttgctcaggacctcgcgacaa +ggtaccccgcataagtcctagaattacatttggtcagcaatgctgacatttgaccgtgaa +aacataattttaatcagaaggcagctcacccgcttgctctagatcttatctttgtatgaa +tgtcagaatttactgcaatatccgttccgaatagtgagggcttagtatagttctctgtat +acaggtcacatcaaactccccctgtcctagtacagctctgagctttaattaattgcatac +atttccttcaatcatcagatgaaaacaccgcgaatcatgctcttctcgtatagggcaaga +gaagcaacaaacaactagcccgactcacgttcatccgccgtatccttgttcagttcttac +tccgtattaggtcagcgaaatctaatcagaataatcggtcgcgtatcaaaattaaaatcc +cgcttgaggttgacaattaaaacgctgagcagttatcggctattagatagtggggtgaaa +gtaattggctggaattatgttaaaacgtgatattaagctaaaatacgctacttgttgccg +acctaattcagtcattcgatattcagttagagccaagaataacaagcttgtataaattga +acggggtgcactaaacgatgtgttactctaatattcagcttggagtatacctgaaggcga +attcatgtatcggccaataataagacgttgaagatcacaatttggactagcaaaagaagg +tgatttatgcgtggggattgagtccactgtacgagtacggtctctggaaaattataggtt +cagggaatataaggaagtaaagataattaccaagagatttttggtatcgctatgacccag +aggtgttctaacgtctgttttgatccgcagaatttctgcctcaatgcatatttgacggac +ttgaactagagcctctaaagttaaatggcgacgcaactgttcctaaacttcaattattac +tactctttttttcctagggtattgtagaggccagtggacaaaataaatcaaatttaagat +gtttcggacattaacatcccccgtagcatagaaatcatcagttatccaatctctcatcga +gcttttacaatttctgctggcgctatggacagcatatgccgcgagacctccgcaagactc +acttgatcactgtaagtatcttcattagaggttagagcctatagttaagctgctgaccta +gtaaaattggtattttctaattttattgctcaagttaaaggttagtgaagggataatgac +gttatttttgaacaatgggttgtattcaattttatatcacgaatggaacccttcattccc +ggcataatactagacgacacgaacaagctccgatctatcagccaggcacgtgttaaggtt +taattccggcaaaccaatgaagcatcaaaaggtgacctgatgcaacttagggtcacgatg +agtttttcaggactacttattacctattaataagttaacatgagccttcataccccgtaa +gacaatacatactccaccaattagaattctgagccatcttatctttttgtatcatcgaag +ggtatggccgaataggttaattagttactcctaacgtctctacaggcatgcatttgacgc +accttcgaaaatagtcaatctctcgccacacgcgtctagtatgcagcatcaaaaatatag +tccacggtttccggattaccaaacgcggcaaagagaaacattgtatcgacggagataact +taatacagaaggaaggggcatcttcgaatacggatgaataattctatctgtttattctga +catcttgttttcaggttaatcttacgcattcaaatgacgcctgccccatgcgtgcgcaat +tattttctaatattgacgagagcaatctcactccttttgggtctatttatgttttattga +ggcacaagcctatacagaacaggtactattaaggccgtgagtgtgagactcaaaccgtgg +aaacaaaggatgggttgttcttggtacaagttttagtgcatgtgggcaatccttaccaaa +atcagatgctatccttaactttgggctgcatttaagatggcggttggaggcctgtgagaa +tcctgcgtgtcatctttaatgaccgaattcatccatgtagattcagatcacacactcatt +ccttgatgttgtctaaacaaaagttgttgtggacgcattggagggagttaagtaacaact +tgggatcgcatacttataaaaattatatgttaaactttcacaaacgctgaagtccaaagt +aactagcccaaacgcctcgagagtcactaggtattaatggtgtttgagttcctgtgaaat +agtgttcgaaggtaaaatttatgtaccaaatcgaaagaacacttaataaggcttgcttgc +acggaggtatgatgtttactgactctacaaccctaattttccagtacgtacattcattcc +aataggttagttctcaaagtgctatacaggctcctcaattgatgatatgcttcagccgct +ctatggatattagctcattttatttaggaagcccgcttagaggcttactatgagggaaat +gccaaaatgtcatacttttcggtgtgtcccatatgacaccgctttacatagaatttgaat +taaaacgcgctctcccgttcactaccatacttggtaccgtgcgcatattacatatagata +taggatcattttttaaagctgtactaggtttgatcgacaatcttatgctatactatatga +tgtaaccctcataatcaataccgatcgtacgatcctagcataggtggcaagcgattttat +gccgattattgtgttaaatagtctgtgagtgtgattatcagggctacgttggtagagggg +ttgtatagacctcgcacacattgtgacatacttaacaatatacgaaaactgatataataa +atccccttacccaaacaccaatcccgttgaatcaactaccataacgtctcccatataaat +tgcctacttgtttgcataaatctgaatacataacaccattgcaccttcttgtgttccaat +cccgttaagattgccttgtcagatgatatgcaagaacaatagcatttgctagcaattatt +aacagctcttcgaattgcctccacataacgcgggagggtatattttaatttggcaaatac +taagtactgttggcgtcatatgctattaacggttggatattaagttatgtcagccgtaag +caagagtgggcgaaatattttgttacccagtgagagcactcttagagtttggatacaata +ggccatatgttgacttaagaggacgtaactacgccgtacaccattgttcaaccgacttct +tggcaaatagaatcgtattagcaatcttaagaatagagacacgttcgtgttagggtatac +tacaaatccgaaaatcttaagaggatcacctaaactgaaatttatacatatttcaacgtg +gatagatttaacataattcagccacctccaacctgggagtaattttcagtagatttacta +gatgattagtggcccaacgcacttgactatataagatctggggatcctaacctgacctat +gagacaaaattggaaacgttaacagcccttatgtgtacaaagaaaagtaagttgttgctg +ttcaacagatgatagtcatgacgcgtaacttcactatagtaaattgaaacaaatacgcaa +tttagacagaatggtacggtcatgaatgacagtaattcgaagtgctagaccaacttaaaa +taggtaaacgtgcccgaaaccccccttaacagaaagctgctatcatggtgcagtatcgac +gtgttcagaaacttgtaacttttgagcaggtccgagcacatggaagtatatcacgtgttt +ctgaaccggcttatccctaagatatatccgtcgcaaactttcgatttagtcccacgtaga +gcccaagcgttgtgcgactccacgtgcatgcccagaaatacgagtttaaatttggttaca +tggttaattttgaccgaagcatcgcactttatgattgataattggattcaatatgtcgcc +ctatgcgaatgcaacatgatccacaatttggctataagacgtttaatccgtatcacactt +tgtttgcggctagtatagtaacgcccgtgcaccaagagtcagtaacaattataagtactc +cgcaggtacttcaaatataaaaactaatcaaacacgacccatatgatcatctgaagatat +ttggaactttctcgacaaccaccctcgtactcaatacttacactaatcgacaggcacacg +caacgtgtacagtcgcaccatattgagtcaagatttgcttagtggcgatgagcgtacacg +cttatttctctagtcacaattagttatctacgagacatcacgagggagcaaataagcgat +gttatggctacacataggcacgtatgaatatgatataagccagttaaacagtcgaaccat +cgagcaaattctcatgcaccaacccacacgttgaggcacaaagagtaagctgtttgaatg +taacttcttctgctgagcgggccccaacgtaaggatcaactagaagagaaaactcggtat +tagtttaaatgcgtcacggagcatgagtgcatttcactaagaatgtctgtgtaaccaata +taacatctatttgttatctgattgcctacttatggctttgcggtcgtggcgactaatgtc +tccaatccttttgaggtcggtaccaactccctttaaattacgctgtgcaggctcatgcac +tgcatacatatacggtagcaggtagggacctcacgcacccttattataatcaatagtagt +tatcagtcaacgaggcaggaatgctgaggtcgaggtgttggtatattttctatgtgccgt +ctaggcgactatcacgcattaccaggcgagatttaagccaattttgaatatagtcaacgt +aatttttactatgggttccaccgaaacgccttgcacaactaagaatcccataaaatatcg +atatcaaataaaagattgtgtcaataccttcatatatattttttcggttgactaacgtga +actaaggttaggggttttgtatgtctatataggaaacagtttcttttctgtcctacttta +gtaaagtcttcaagccttactccaaaatcacggtgattaagccgttactcagcagcatga +ttctgcctgctcgggtcctaaaatccagccttgtaagagtcgctgtgtattagctaggga +gacctttgttaaaaaggatatatcgcggcgggatgtgagtgcgtggcgcatactcaatct +tcagctcgtgtcattataatatctctcccccacgcttttcactagatatgccgtgtaagc +aaacaccttatgcttaatttcgaaaatattggtacttgaaaaaagctgtaggggtactta +atgtctggtaggagatcaggagagaattgagtgtaaaaccgtaaagccctcacctgactt +catgtaaatggcttagaagactccatgatttaataaatactacgaaggaaagactggatc +taaagataactctagtaaggccaactcccttcaatgctgttgccagttataatccaagag +ctgtccttttctgaaccatagcggcttctgaagcgaactagaagcaaagttggttctagc +cagacagccacataccctgtacgggtgtattactaaaactggtccggtattagttcacca +agggaggaattaggcaaaggatctaggtatgcaagtcggagtattacatccctaccctga +atccatcaataggttcctctgtactggccttcgcaatgagtattcaaggttgtacagccg +tataataataagatagtgactatgaacgggaagtaacccgctcaccttccccaaaacatt +gttatatctaagtattaaagtctgccgtagtgttaatactcgaaaataaacaactggcaa +attacaccgcacttaagccgcttttgatttatatttttccaatgcgcttttaaaaataat +tcagtcctacatactaattaagacccttaaacggagatatcacaagttaagttttaacca +tctcgactaggtggaactatagatacccaactcaatttatcattacctgtaatgttccta +gaaggattgcatttcatgtcaagacggtggagtttcacagcgaaacttcagtgtgaacag +attctgagaaatcacctaaacctattagtcagagcacccggttagaaccagttgtcaaaa +aatagagcggttgcatgagacagaagtaacgatgagatccgttgtaacgttgagacatct +ggcctatcgtcaatacagtcctcccttaaaaatatttttaaatactaggcaaacccaaca +taggttagtcctatgtgatacgccacatggtatatcattttgtaacgttacctagggata +atcaggaagtggaattacgcaaaagtagacagtgaaatgcttagggttatagtctagtcc +aaagataaaggataaagcacgtcagagaactatattagccgaatgggaatcattgttagg +agactgtggatcatgtctaaaaagcaacgcagaaacagtcatcgaaaaaatctcgttttt +gtttgaatctaaaagagctttgatgaccgatagtacctgtatactagttactgtattacg +tgtctaatgatttcggattggggtccccagaatcagacgtcattgtagacgattcaagtt +taccaatttaatttcccagctctccttggagaactatcgccaataattgcagtcactttc +cttttctgaaacgataaagccgtcagagttctctgcaacgttggacttacctgaggttct +aacccactttcggttctaatagtagttaacgacacaacgaataacctttactgtggggct +ttcacgatattttttcgcttattattaatggttacgtcataagctggtgtccaaattaag +gttaccggcttcgcagagtagttgtatccaagtataacttccctaatcataagatcgagg +tagaaaattaatgctgtctctaaccgaacagatatgtcccactatgtggtatggacgttg +ctaattacttctgaagggaaattggtcattatggatacgtgtctaccatcaggtcggacg +cagatatggttctgtcttcagttgatccaccgttctttataggataataactgacgatta +aagattatggtaaatagattaagccaattctcttcttgtcagtgaagcatccttaactga +cttgctctgcagcccctcatacatttagctattcaaagtaccggctcgtttcaaactctc +ccacctttggaagaggttgtcaacttgataagtatatcatttacagcattttttcggacg +tacctctaatgtttcattgcagaaaattagttttttctatcgcacattttgcaagtaacg +ttagagacacaattatctgcgaatgaactgctagatctgacgaccgggagcctcgcaaat +atcaaaaaagactgacatatatcaaggagtcgttgacaagtgctggtaagtcaattggtt +tatctgtcccggcgtttcgatcttaagctgaccatgcacggcagagtaatgtcactctcg +ttcttacaagtctgtctccaagggtcggcaaaaaagacccctccattctcgagcccactc +acgatatgtagggacgacaacttgtgcggcttatgaattgtctggactgcgggcgagggt +ccatatctccgaagttagaagggacatacctttagatgataagatcaattcttattgacg +aaattcatccacaacggggaacaacttcaccctagacttacgtctgaaaagacacctagc +gtcttataaaaggtcagtgccccgtttcgtaaggctggaattacctacgcaaacttaaac +ctcgcgcccttccttacgtatcgacaagatagaggctatcgcgaatgtactacggaggca +tgaatcatatactagaaccaagtgcctgtgatattaacaagatgatccgacgcgagcacc +gtaattctaggcataaaactccagcaatttgggggccgaaaacaaatgacgttagctaat +taattatatgacatgatcaaaggaggtcaatcacgcatcgagttcgacgtatattcattg +aacttcgtgcgtttgaaagaaacttttatgaaggcaaaattgatcctgtctcctatttca +tgcgtacctcctagttgataattccccgagcagtggttaggacacttttgtcggtatcaa +gttccggtctcaaaacgtaaaattctgtaatctgtatggatggtctgtgaattagttaat +ttttatgaagtcgtcgagacgcagttcctattgatttattctaaacggagatgtgcttcg +tgggactcggaagtagatctgtgtttatgattattgctactttagatgctgactgttaac +tccgtgttgtttttcaaccgtatatcacaaccgaattggatagaacctatagtttcaagt +tctgccacaaggtatcatatttacagttagtgctggttgcttctttcaaacgtggtgagt +ttgtgctatcacgtcaacggtagagctcagtggaccgagtgcgcgttcaaccctgttcca +gagagggtgtgatagcacatataccacgctcgtcgaggcgttcatgatagtttgcaagag +ccggtgttaaacacatattattattgttatccaactaatcggacctatgcataaagcatt +gtctaaacagaataattgcctatatacggtagttttagtgatttatatcttagtatcagt +tagagcttcgaactcttcaggttcctcatatttaacgttcttcgaaagcgaaaacttcta +caaacgaatgtaagcggttttccaagtagtacctataaatcacagaaagatctgtctcag +tatagttgaaatggtattcagctagtgacgtgtaccaattatcatagttcactcaagcaa +gacgctcattaacgaatatagacaagacactatatcatataataaaaaagaacatggtgc +tcgaacatagttgaattcaccatattgaaggggaatgctgacatgtaattcgctactaga +cgatcaattccctacttgtcaaagttgaactggtacgttcttggaattaaatatgattgc +gctggaccaaattgcgacttcttgagtttcagggcaaacgattgagccggaggatgtccg +tctcttacctttcttgcttatgataaacgacggtccctgtacatcactgggaattctcag +caaaaataattgggtaaatcgagactcgatgtattcggccacaaaggtgttagacgttaa +agattattcaacggggcgataataggatcataaccggtatgcaagcgcattgaaagagcc +atgagatccttatccgataaacgctgcacggtatgtgcagccttattgtcgatcacgaat +ttataaatgtagtctgggctgtaagttgaagacctaagttataatgaagtgcaataccaa +atcgattcatagtggattatcagactcaagatatctcctgataaattacagttgttaaga +tacggataaaatgagatttaagattagcagcctctaatctgtttcaatcccgttggaatg +tggtatgcgatcaaggttaagttaaaatcaagcctgtcttcagtcttgattcttgttctg +ccatcgcatgcggtctacgtgagttaatatgtagcttacgttctagcttgtgctaatctg +agtatagattcgtagaggaatattatcaagcttccacgcctcaacgtacgtgtattggtc +acacaagacactaaaagtggaagtagcgtaaactatagtctagttgttaaatgctcagtt +cttgttatattcgatatactcttggctaatttatgtctgagtatataaaattaatgatat +taacttgcatttcacggatcccttagaaaaagattttgaccgagcgcattataaacggtt +acaccgaatcaatagaagcatacccaatagctttctttgaatttattgcctgcgcaactt +ggctgactctctagatccgaataattctatatggtcgtgacgaaactagttcattactgt +ttaaaatgccaacatgtcttttgggccgataatggctctttgcaaaattactcaatgata +cgattgatcaaagcggtagttgctagtggtagcatgtaagtctatcaaatgtctgattat +ccgaaaatcttccaaaagagtccacgtaccatatctatctcatagcgacgcgaggggaac +cttatctaactatcattccatttaccgggtgactctcgatgcaggatccgattgggataa +attgcccagaaatggctcattcctgactaagggtaaggccgttctcagcaagggaacccc +gcgaatctaggcttataccatctagattgttaactacttgcctgtagttctacagccata +ctggacagttgtttctaaatgatcgggattcatgctagcactcctctgaatgcaccgcgt +aagtttaactattacgtccgtgggcagataaggatggaggctgtatgtatcttaactgtt +acctaatatggctggtaattatcaaagtaaggaccttaatgccatagcgctagcaatcgc +tttgtatactgaccatgtgccaacctctcttaatctgtaaaatataatgtcttagctaac +tgtggacgatcatgtctctgcctagagcttcgctgtatcaattcctatagccagcgtact +agtgacacaacaacaccgtgtgagaaaagatattagtccttacgtctgtctctctacagc +ttattgatgaggattgaacatggacatatagctccccctcaaaagcagatgctacctctt +tattccattctcgaacatttgccgaacttaatttcgacaaacctgaggtcacgtcttaat +ttatcggtaacgtcacgtccctttgagactggataaatatattaccaggggccaacgagc +aattgttggaggcgcttctataatacaaggtgtcttgtcaaagaaagacggcgtgcgtct +cgtgcaactcacttaaccaatattaatgtgaaacccccctctctcacatcttatgcggtg +tactgccctggtacatttcctgtacaggactccaacagtgtagattcctaagatagctgt +tggagttgcctcacgccagatcgaaaaactgaataaactagtgagctgagctgcagaaat +accgcttaattacttatgactagttcaaagggacctacgtgatgtcagacattgcaagga +agaaattaggtttgtgcgtcattttggctggactagcactccttacttcccctactattc +aaatgtcgtaaacagcatgagacaggatcgtgctgacatttaaggtctattgggaacgag +gctacctttggtcgcgcgctcgcgttctccgaatgaccgaaatgcatgagcacagtatgc +aattgcttatagatctaaggtctggtcgttgaaaccaagcacgtaggcctgggaaatcag +ttcttcctcagcaactacacaaaagcgtccaagcattagtacttgtagtaaatgtccgaa +cctatgcgctcatttgaaagtcaaaaaatatttttaagcagtaggcacctaacccgattc +ctctacttagtagctttctttgattctcagaattgactgcaatatcactgcacaattctg +tgccattactagacttctctgtattaacgtctcatcttactaacactcgcctaggacaca +tctgagagtgaagtatttcaatacatttactgaaatcttcagttctaaaatccccgaata +aggctcttatcggtttggccaacacaagaaaaaaacttcttgcaccactcaccttcatac +gcaggagcctggggaacttagtaataactatttcggcagacaaagcttataacaagttgc +cggcgcgtataatatttaaaagaccccttgagctgctcaattaaaacgctcacctggtat +aggctattagatagtgccgtcttagtaaggggcgggaattatcggataaactgatatttt +gataaaataaccgacttgttcacgacataagtcactaaggagattttatctttctccaaa +gtatatcttccttggataatttcaaagcgctgcaatttaagttctgttactagtttatgc +tgctgggaggtgaccggaaggcgtagtaatctagaggcaaattataagaagttcatcata +tcattttcgactacaaaaacaaggtgttgtatgccggcgcattgtgtaaactggacgagt +accctagatggaaaattatacgttaagccaagatttcgatgtaatgataattacctacac +atttttgctatccataggaacaagagctgttctataggctcgtggcatacgaacatttgc +tgccgctatgaatattggaagctcttcaactacagactctattcttaattgccgtcgaaa +atgggccgaatcggctattattaatactcggtttttccgaggggattgttgtcgacagtc +gtaattattattaatattgatgttggtgaggtcatttaaatacaaccttgcagacaatga +ataagggatccaatctctcatactccttttacaattgctcatgcccctatgcaaacctta +tgccgccacacctccgcaactctctcttctgaactgtaagtagcttcattactggtttga +gactatactgaagctgatgacattctaaaatggctattttcgaatgtgattcataatgtt +tatcgtttgggatggcagaatcacgttatttttgatatagcccgggtattctattgtata +gaacgtatgctacaagtcattccccgaagaagactagaagtaaacaacatgcgaccatcg +ttaagccacgcaaggctgtagctttatttcccgataacctatcttccataaatagcggac +agcaggatactgacgctcaacatcagtggttatggtctaatttttaacttttaataaggt +aacttcagcaggcatacacagtaactctttaatttataatcaaattagaagtctgacact +tcttatatttttctatcatccaacgcgatcgcccattagcttattgtgttactaataacg +tatctaaaccaatccttttcaagctactgcctatattgtcaatatatacaaacaacagga +tagtaggctgcttaaaaaatattgtcaaccgtgtacgctttacaatacccggaaatcaca +aactttgtagacaacgagtgaaatttatacactacgaagggccagcgtacaagacccatg +aattaggcgatatgtttattctgacatattggtttatccttaatctgtcgctgtaaaatg +aagccgcccccatccctgcgaattttttttcgaagattcacgactgaaatataaatacgt +ttggctatatttatgttggagggaggcaatagcctttactgttaaccgaagatttagcca +gtgagtgtgacactaaaacactggaataaatgcaggcgttcttctgggtaaaaggtttag +tcaatctcgcctataagttcatatagctctggatataattatctggcccatgcatttatc +atggcgcttggtgccctgtgtgaagccggcctctcatattgaaggtccgaagtattccat +gtacattaagatcactctctcattcatgcatcttggcttaacaaatctggttgtccaagc +tttccaggcacgtatggtacaaattcggatcgaatacttataaaaatgatatgttaaact +gtctaaaacgctcatctacaaagtaaagtgcactaaccaatagagtctcaagaccgtgta +atgctggtgcactgaatgtgtaatacggttagaagggattagttatgttacaaatccatt +gaaaacttaagaagcattgcgtgctcggagggtgcatcttttatcaagagactaacatta +ttttcaacgacgtacatgctttacaatagggtacttatcaaacgccgagaaacgcgccta +tagtgatgttatgattatgacccgatatccattggaccgaattttatgtaggttcccagc +gtactcgcgtaatatctcggtattgccataatgtaatacttgtcggtctctcccagatga +aaaagcgttacagagtatttcaatgaaaaacagcgcgcaacgtcaatacctttaggggta +acggccgctgatttcatatagatatacgataagttggtatagctctactaggtggcatcc +acaatcgttgcatttactatagctggttacaatcataatctataccgttccttacatact +accatagcgggatagcgtttttttgccgttgattgggtttaagaggatgtcagtctcatt +atatccgattcggtgggagagccgttgttttcaaatcgcacactttgtgacataatgtac +aagataacaaaactgatataagatataaactgtcaatatcaccttgacacttgaatcaaa +gtaaattaactcgcaaatataatttgactaattgggtgcagatttctcaattaataaaaa +aatggcaccggatgggcttacaagccccttatcattcacttgtatcatgatttccaagaa +caatagaatttgctagcaagtatgaacagagattcgaattgcatccacagtacgccggag +cgtttattttaatgtggatatgacgatgtactgttggcggcatttgctagtaaccggtcc +ttatttacgtagcgcacacgtaagcatgtctgggagaaatatggtggtacaatctcagag +aaagattacagtttggtttaaataggacttatcgggtcggaagtggaacttaataagcag +tacacaattgggcaacagacgtcttgcctattacaataggattacaatgcgttagatttc +agacacgttcgtgtttggctattcgtcaattccctaaatagttagacgatcaactattat +caaagtgattctttgttcatcctccattcatgtaacagatggcacactacgcataacgcc +gaggaattttaacgagatttaagagagcagttcgggcacaacccacttgactttataaca +gctcggcagcataaacggtaatatgtgacaaatttccaaacgttataagaacgtatgtgt +acttagaaaactaagtggttcatgttcaacagatgtgacgcagcaagcctaacttatcta +ttggttttgctataaaagaacaaagttacacagaatcctaagggcttgtttcacacttat +gcctagtgcttcaccatcttaaaatagcgaaaccggcacgaatcaaaccttaaaacaatg +cgcagatattggtgatggtgactccgggtatgataatggtaactgttgaccagcgcccac +ctcatcgaagtatagaaagtggttaggataaggatgagaccgaacttatttccggccata +actttagattttctacctagtacacaacatcagggcggacacgaaaccgccatcacatca +tataccaggtttaatttgcttaatgggggaagtgtcaacgaaccttcgaactttagcagg +catatggccattatatatggccccagagcagaatgctacagcagacaaaatttggattta +tgtagtttaatacctatcaaacttggtgtgaccatacttgtctaacgacagtgcacaaag +tgtaagttacaattattactactcagcagcttctgcaatgataaaatcttatcatacacg +tcacatatgataatatctacttagggggaacgggctccacaacctacatagtactcaata +cttacactattcgacaggcacaccaaacctgtacagtcccaaaagattgagtcaactttg +cagtactgcagatcacagtaatagcttagttagcgagtcaaaattagttttctacgagac +tgcacgaccgtgcaaatttccgatgtgttggctacaaatagcaacgtatgaatttgtttg +aagccacgtaaactgtacaaccttagagataagtctcaggctactaaaaacacgttgtgg +cactaacaggatcatggttgattcttacttattcggctgaccggcccaataagtaacctt +caactagaacagaataatcgggagtagtttaattcagtcaaggtgcaggtctcattgtaa +ctaacaagctctgtgtaaccaagttaaaatcgttttcttagcggattccctacttatgga +tttgagctcgtccacaatattcgatacaagaagtttgtggtccgtaacaacgaaatttta +attacgctgtgcagcctcatccaaggaattaatagaaggttgatggtaggctccgaacgc +tccatgattataatcaagtggactgtgcagtaaacgaggaaggtatcctgacgtcgtggt +gttcgtttttgttatttgtgccctatacgagtagataaaccatgaacagcacagtgtgaa +cccatggttgattttaggctaccttatttttaatttccgttacacagaaacgaattccac +aactaacatgccattaatttttcgatatcttataaaagatggtcgaaattcattcattta +ttttttttcggttctcgaaagtcaactaagctgtcgcgttttgtttctctttagaggtaa +aagtggctttgatctcctacgtttggatactagtcaaccattactccatttgatccgtga +gtatcacctgtctaacatccagcattatgactcctcggcgaagaaaagacacacttctta +gagtcgatgtgtattagctagggacacagttgtttaatacgatagtgagcccagggaggg +cagtgcgtcccccagtagatttattcagctagtgtaagtataagatatctcacccacgag +gttcaagtgatatgcagtcttagaataatacttatcctgaatttcgatattatgggtact +tcaataatccgctagcgctactttatgtctcgttggacagcaggacacatggcagtctta +aacactaaagacatcacctgaatgaatgtaatgggattacaagaatcaatgaggtattat +atacgacgtaggaaactctggatatatacagtaatctagttacgccatcgcacttcattc +ctctggaaacttagaagacatcagctgtacgtggaggaaccagacccccgtatgtagcca +aatagaaccaaagttgcttatacaaacacacccaatgacaatggaccgctggagttcgta +aactcggaacgtagtactgcacaaacccagcatttagcaataggagctacgtatgcaact +cccacgtggtaataccttcaagctatcaatatataggtgcctagctaatcgcattcgcaa +gcagtattcaagcttgtaaaccagtataataattacagaggctctatgaaacccaacttt +ccagctaaaagtcccaattaaatggttatttcgtacttttaaagtcgcccgttctgttat +tacgcgaattgattctactccaaaattaaacacaaattatcaaccgtttcatttatattt +gtcaatgcagctgtttaaaataaggctctactaaattataattaagacacttattaccag +atttctctagttaagtttgaaccagctcgactaccgcgaaagatacattcccttctctat +ttttcagttcatctatgggtcagagaagcattgaatttattctattcaccctcgtcgttc +acagcgaatcgtcagtgtgatcagtgtatgagaaatatcctaaaccgtttagtcagacca +cacgcttagaacaagtggtctaaaaagactgccctggaaggagtaagaagtatacagctg +atccggtgtatccttcagtcatctgccctatactaattacacgacgcaaggaaaaatagg +tttattttctaggcaaacccttcataggtgactccgatgtgttacgaatcatgcttgaga +atgtgctatcgttaccgacggataataacgatctccaatgaaccaaatgtagaatgtcta +ttgattacccttttactattcgacttagagataggagatagaacctcagtgtactttttt +agccgaatgggaatctttgggaggtgaatggccataaggtcgtaaatccaaccctcttaa +agtcttccatattatatcgttgttcgtggaatcgataacagatttgttgacccatagtaa +atgtatactagtttatgttgtaagtgtagattgttttccgattgccgtccaaactttatg +tcgtaattgtagaccagtaaagttgaccaaggtaagtgcccagcgatcctgcgagatcga +tcgccaatttttccagtcactgtaagtgtaggtttagataaagccgtatgagttatatca +taagggcctcggaaagcagcttcgaaccaaagttcccttataatagtagtttaactataa +aagtatatactggtctgtcgccctttcacgatttgttttaccggtttatgaagcgttacg +tcattagagcggctccaatttaaggttaacggcttccatgtgtagttgtatacaaggata +acttaaagtatctgttcagcgagctagttaagttatcctcgatagaacacaactcagagg +tcccaagatcgggtttgcaacttgctaatttattctcaaggcaaattgggaattatcgat +acctgtataccataaggtcgctcgatgtgatgcttatgtcttctggtgatcctaccttag +ttagtgctgattaacggaacattaatgtttatcgttttgagatttagccaattctctgat +tctaactcaagatgccttatctgacgtgctatgcagcccctaagtattttacattgtaat +aggacacgctcctttaaaactcgccaaaaggtcgttgtggttctctactggttaactata +taatttacagctttgttgagctagttcctctttggtttaagtcctcaatattagttggtt +cgagcgataagttggctagttaccttagtcactatattagatccgaatgttatgcttcat +ctgaagaccgccaccctccaaaatttcttttaagactcacttattgcaaggtgtaggtga +attcggctcgtttctcaagtggtgtatctgtacacgagtttccatattttcatcaacagc +caccgcacacttatgtcactctaggtattaaaagtcgctctacaaggggacgcaattaag +aaacagacatgctagtcaaaaataaacatagcgaggcaccactaattcggccgcttatca +atgggatgctctgcgcgagacgcgccagagctcagtagttagttcggacatacatttact +tcagatgatcaattagttttctacaaatgcttactctaccccgaaaaaagtcaccagact +cttacgtctctttagtatccttccgtcttatataaggtcagtcccccgtttcggtaccct +ggaatttactaagaataatgaaacagcccccaaggacgtacgtttacaaatgatagacca +gatcgcctagcttattccgacgcatgttgcatagaattgaaccaacggaatgtgagagta +actagatgagccgaccacagcacccgtttgcgtcgcagaatacgcctgatagttcggcca +cgaaatcatatgtcctttgagtattaagtatttgtaatgatcaatcgagctcaagcaagc +ttacacttcctcggatattcagggaacttagtgcctttgaaagatacgttgatcaacgaa +aaattgataatggctcatatggaatgcctacctcatagtgctgaattaacacagcactgc +ggacctaacttttcgaggtttcaagttcacgtctcaaaacctaataggctggaatatgta +gggatcctcggtgaatttgtgattgggtttgttgtagtactgaccaagtgaatattcttt +ttttctaaaagcagatctgctgccgggcactacgaaggagatctctgtgtatcattattg +cttcttgacatgatgactcttaaatcactgtgggtgtgcaaaacgatagcacaacccaat +tcgatagtacatattgttgatacttcgcactaaaccgttcatatttaaaggttgtgctcc +ttccttcgttaaatactggtgacttggtcctatctactattagctagacctctggggaac +cacgcccccgtaaaacctgtgcaagagagggggtcatacatcttagacatcgcgcctcca +ccagggaagcattgggtgattgaccaggtgtgtaacaaatatgattattcttatactaat +attagcaaagatgcataatgatttgtattaaatgtataattgaattgataagggtctttt +agtcagtgatagagtagtataaggtagacattagaactcttaaccggacgcagatttttc +ggtcttagtaagccaattagtcgacaaaacaaggtaagagcggttactagtagtacctat +aatgcactgaatcttcggtcgaagtatagttctaatgctatgcagattgtgacggcgaca +aatgttcagacttatatcatgaaacaagctcttgtaagtattgacaaatgaaaagattga +atatttttaaatacaaaatgcgcctacttattaggggaattaaccagattgaaggccaat +cctcacatgtaatgagataatagacgataaatgaaattcttgtaatagttgaactgctac +gtgatgggtattatatatgattgagatcctccaattgccgacgtcttgtcttgatgccca +aaagattgtcaacgaggagctccctcgcgtacctgtcgtccgtatcataaacgacgcgac +atgtacagcactccgaagtataagcaataataatgcgggtaatccagactagatcttttc +ggactcaatgcggtttcacggtaaacatgattaataccggagagtagtcgagcttatcag +cgatgcaagcgaattcattgtgccaggagatacgttgcagataaaaccggcaacgtatgt +caacaagttttggcgatctcgttgtttgtattcgacgaggcgcgggaacttcaagaacta +tcgtatattcaagtccattaccttttagtttcagactggtggagctgactaaagttatat +catcattttgtacactggtttagttaacgataatttcagatttaacatgaccagacgata +atcgctgtatatccagttggaatgtggtttgccagaaaggttaacttataatcaagcctc +tcttcagtcttgattcgtcgtatcccatccattgcgctatacctcagtgtatttggagct +gtagttataccgtgtgctaagatcagtagacatgacgagagcaatattatctaccttaca +agcatcaacggacgtctagtcggaacaaaagactctaaaactcgaacttcaggttaatat +actatagttctgtattcagcagttattcttatattcgatattatcttgcctattggatgt +ctgactttagtatattaatcatagtatctgccatgtaaaggtgccagtactaaatctgtt +tcacagtgcgaattataaacggttacaaccattaaagacaacaagaccctatagctttat +ttgaattttgtcaatgcgcaacttggagctcgcgatacatcccaattagtctatagggtc +gggacgattctacggcatttctggttataatgacaacatggattgtggcccgagaatcgc +tctttcattaattaagcaatcattacagtcttataagcgctacttccgagtggtagcagg +taactcgatataaggtcgcatgagccgaatagcttaaaaaacaggccaccgaacattgat +agagaataccgaccacagcgcaacctttgattactttcattaaattgtacggctcactcg +acatcaagcttaagattgcgataatgtgaactcaaatggatcagtactgaagaaccgtaa +cccacttcgcagaaagcgtacccagagaagatacgctgttacaatatacagggtgaaatt +attgcctgttcttcgtaaccatttcgccaaacttggttagaaatgatagccattcatgat +agaaataagctgaatgataccagtatctttaactatgtagtcagggggaagataacgatg +gtccatgtatgtttctgatatgtgacagtattggccgcgtaatttgctaacgaagctact +taatgcctttgagcttcatatagatttctttaatcaaaatcggcaaaaagatagtatgag +ctataatatatgctagtagagaactctggaccatcatctatatgaatactgattcgagcg +tgcaattactttagcctgcgtactactgactctacaaaacactctgagataagtttgtag +tcagtaagtcgctctctataaaccttttggatgaccattgtacagccacttatagatccc +aataaatagcacaggagacagagtttttcaatgctcgatcatttgccgatagtattttcg +tctaacctcagggcacctattatttgatacctaacctaacggccctttcacaatggagaa +atatatgacatcgggacaaacacaaatggtgggtggccaggagatatgacatggtggcgt +ctctaagaaacacggactccctctaggcaaactcacgtaaccaattttaatgtcaaacaa +aacgctcgaaaagattttgccgtgtaatgacctggtacattgactggtcaggaatacatc +actgtagttgccgtagtgtcctgttggtgttccatcaagacacatcgtataacgcaattt +acgacggacatcagatcaagttatacagattatttaagtatcacgtgtgcattgggacat +aagggatctcacacatgccttggaacatttttgctttgtgccgctttttcgctgcactac +caatccttacttaccagtatattcaaaggtcgttaacagaatgagaaaggttagggctct +aagttatcgtcgattgggatagacgagacatttgcgagcgccctccacggatacgaatct +cccatatcaatgtgaactggatgctatgcagtttagttcttacgtctcctagtggtaaaa +atcaaagtagcactcgcatagcagttattcagaacctaatacacaaaaccgtcaaacatt +ttctaattctaggtatgggccgatcataggagctaaggtgaaactcataaatgttttgtt +agatctagcatcctaaaaagatgcatatactgagtagctggcgtgcattctctcaattgt +atcctttttaactgaactagtcggtcccatttcgtgactgagatctattaaccgataaga +ttaataacactcgcattcgtatcagctcagagtgaagtttttcaataatttgactgatat +attaacttctaaaataaccctttaagcctcggatccgtttcccaatcacatcaaaaattc +ttattccaactatctacggattaacaacgtgcatggggatcgtagtaagaacttgttccg +atcactttgagtatatcaagttgacggcccggttattattgaatagaaacattcacctgc +taaattaaataccgcacatcggatacccgatttcagagggccgtcttactaagggcaggc +tttgttcggtttaactgagatgttcattattttacagtatgcttcaactaatatgtaacg +aaggacagtggatctgtctccatagtagatcttcagtcgtgaatttcataccgctcctat +ttaagttcgcgttcgagttgttgatcatggcacgtgaaagcaacccctagtattctagac +gaaaattttttctagttcatctgataatttgccaattcaaaaacaaccgctggtttcccg +gcgcattctctaaaatggaagtcgaacctagagccattatttgtcggtaacccatgagtt +ccttcttttcagaagttaatacactgtggtcctatacagaggaaaaacagcggttatata +cgatcgtggcataacaacattggatcaagatagcaatttggctacctattctaattctca +ctagattcggtattccactacaatatcggcagattaggattggatgaataatcggtgttt +aagtccggttgcgtctccaatctcctaatttttattaatattgatcttggtgacctattg +taaataaaaacttcaagactttgaataacggtgaaaagatagaagactcatttgaaaatg +gatcatccacagatccaaacattagcaagacactaatccccaactagctattctgatcgc +gatcgtgctgcagtactcctgtcacaatagtctgttcatgatctaattctttttgggctt +tgttcgatggtgattcagaatctttatccggtcgcttccctgtagctactttgtggggat +attgcccggggattatagggttgagatcgtttcctaaaagtatttaaaccaagtagactt +caactaaactacatcagaacatcgtgaagacaccatacgcggtacctttatttaccgata +acatttcttcaagaaataccggtaagcagcataatgaccctaaacagctcggggtatcgt +cgtagttttaaattttatttaggttactgctcaaggaataaaaactaactatttaattta +taataatattacaaggctcacactgattagatttgtctataagacttcgcgatcccccat +taccggattgtcttaagaataaactagataaaccatgcattttctagataaggcctttag +tctaattagatacaaaaaacacgatagttgcatccttaatttattgtgtcaaacctggaa +ccttttaattacccgcaaatcactttatgtcgagactacctctgaaatttattatctacc +taccgcatgaggacttgaaccatcttgtaggagttatgtttattagctaagattcgttta +tcctgtagcggtccatgtatattcaacaagcaaaaagcactcagaattgtttttagttga +gtcaagactgatatataaataagtttccctagttttttcgtggtgggacgatattgaatt +gaatcttaaccgaagagtttcccactctgtcgcacaataatacacgccaatatttccagc +cctgcttatgccttaatcggttactcaatctcccattgaagttcattttgatctgcatag +aagtttcgggcccagccttttttctgccaccttcctccaagctctgtagacgcactctaa +gattgatgctcacatgtattaattctacattaacataaatatataagtcatgcatcttcg +agtaaaatatctggttctccaacatgtcctggcacgtatcgttataatgcccatacatgt +agtattaaaatgattgggttaactggatattaagatcatcgaaattgtaaagtcaaatta +acaatactgtctcaagaccgtgtattcctcgtgctcggaagggctattacgcttacttcc +gttttggtatcttaatatgactttcaaaaattaagttgcagtgagtcctacctgcgtgca +tcggttagcaagagtataaaagttgtttaaacgaactacttgctttacaataccggtcgt +atatatcgccgtgaatccagaagattgtcttctttggattatcaaccgagatcctgtgga +ccgatgttttgggaccttcacagaggactccaggtagagctcgcttttgcattaatctaa +gaattgtacctctctaaaagatctaaaacagtgaatgtgtatttcatggaaaaacacaga +gaaacgtaaattactttaggccgaaaggcacatgagttattatacatatacgagatggtg +gtatacatcgaattcggggcatacactatagttgcattgtatttagctgctttaaataat +atgatattaccttccttacataagacattaccggcataccctggttttcaacttgtgggg +ctttttgacgatcgcactctcatttgatccgagtagggcggtgacccctgcttttcaaat +acaaaaatttcgctatgaaggtaatagattacttttcgctgttatgatagaaacggtaaa +tttaaaattgaaacttctagaaaagtaaagtaacgagaaatgattttgtgaataatgcgg +tcatgattgcgcaagtaagaaaaaaaggcaaaaggatgcgcggaatagaaacttatcagt +cacgggtatcttgatttcattcttcttgtcaattgccgacataggatgaaatcagattcc +aatgcaatacacagtaacccccacccttgattgtaatgtcgatttgaagttgtacgcgtc +gacgaagtggatagtatacgggccttttgtacggtgcgatcaactatgaatctcggcgag +ttagatggtcgtacaatctcacacatagaggtcacttgcctgtaatgacgaattttcggc +taggtactcgaactttattagaagtaaaaatgtgggcaaaagaaggattccattttacaa +gacgattacaatgagttacatgtctctcaacgtagtctttccctagtagtctttgaacta +tttaggtactccagaaaattttagcaaagggtttctgtgtgaatccgccattcatgttta +tgatggaacaataagaataacgccctcgtatgttatcgacagtgaagtcagcagttcggc +caaaaacatattcaatttagtacagatccccagaagttaagctaagtgctctaaaatggc +ctaaacggttatcaaagtaggtctaattactatactaacgggtgcatcgtaataactgct +gtcgatgcaacactatatgatagtgtcgttttgctatatatgtacaatgtgacaaagaag +ccttagcgattcttgcaaacttaggacttcggattctcaatcttaaatgtccgaaaacgc +aaagattcaaaaatttaatctatgagcagatatgcctgatggtgactacgcgtatgttaa +ggctaaatgttgacaaccgcacacataatcgaactattgatagtcgggagcataaccagg +tgaacgtactttgttcacgacatttattgacatgttctaaatacgtctcaaaatcacggc +gcactagaaaacgcaatcaaatcattgtcctggtttaagggccgtaatgccggtagtgtc +aaacttcatgagaactttagctggcttttggccagtatttagggaccaagagcactagcc +ttaagctgaatattttgccatttatctactgttataactttaaaacttggtggcaccaga +cttgtcgatacacacgcatcaatctgtaacgtaaaaggtttactaagaacaagcgtagga +attgagtttatattatatttaaactaaaagatgatattagcttctgagggcgatagggct +ccaaatcataaagaggaatatattattacacgattagaaacccacaacatacctcgaatc +gcccaaaagtttgacgaaacttggcagtactccacatctcagtaatacagttgggagagt +ctcaaatgttgttttattactcaatgaaccaccctcataatttcactgctgttccattaa +atttgcaaacgatcatttgctttgaagaaacgtaaaatcgacaaaattacagataagtag +atgcataataaaaaaaactgctcgctataacacgatcatcgtgcattcttacttaggagc +atcacccgcacaataacgtaccttaaactacaacactattagaccgagtactgtaattca +cgaaagctcaagctcgcattgtaaagaacttgctctctcgtaaaatgtgataatagtttg +cggagaggattcaattattttccattgcacctactccactagattcgataaaagaaggtg +gtcctcccttaaaaagaaatgttaagtaacatcggaaccataagcaaagcatgtaagtga +accgtcatccttccctaagaaacataaaggtttttaataatgtcgactgtgaactataac +tgcatcctttcctgacctactccggttccttgttgttatttctgaacgagaccagtagat +aaacaatgtaaaccacagtgggtaccaatggtgcatgtgacgctaccgttgttttaagtg +cccgtacaaacataagaagtcataatcttacttgaaattaattttgccttttattttttt +tcaggctcgaaattaatgatttgttttttttgaccttctagttacgctaatatgcggtcg +cctgtggtttctattgagtcctataacgggatgggatctaatacgtttggttactagtaa +acaaggtataaatttgataccggagtatcaactgtataacatcaagctttatgactcata +cgcgaagtaatgacacaaggctttcaggagatcgcgagtacagagccactaaggggtgta +ttacgatagtgacaccaccgagcgcactcactccccaagtagatttatgatcctacgcta +agtattagatatataaccaaagaggttctagtcagtgcaactcttagaataataattagc +cggttttgcctttttaggcctaatgcaatattcagctagcccttatgtatctcgcgttcc +acagcaccactcatggcacgcgtttaaactaatcaaatataatctatgaatgttatgcca +gtacttgaataaatcaggttttttataagtccttgcatactctcgttatatactgttaga +gtcttaccccatagaaattctttcatctgcaaacttagaagaattctcagctacggggag +cataaagtccccaggatgttgacaaatacaacaaatgtggcttatacaaacactccatat +gaaaatcgaaccctcgtggtagttttagccgaaccttgtacggataaatccctccatttt +ccaatagcagatacctatcctactacctcgtggtattaaattaaagcttgaaatatagag +ctgcatagcttatccaattcccaagcacgagtctaccgtcgtaaccacgatttgatttac +agacgctagagcaaacccatctttaaacatataagtaaaaattaaagggtgagtgcgtac +gtgtttactagcaacttcgcttattaagacaattgtttataagccataattaaaaacata +tgttcaacaggttcattgatatttgtaattgcacaggtttttaataaggatctacgtaag +tataatgaacaaactttttaccagagttatattctgtactttgaaaatgctcctctaccg +ccttagagactttcaattagattttttgcagttaatctatgcgtaagtgaaccatgcaag +ggatgcgattcaaccgcctcgtgctaaccctatcgtctgtctcataactgtaggtctaat +ataattttcagttttcgaacacataaccctttgaaaatctgctatttaatgtctcacctg +catgcactatcttctatactgctcagaacggctatacgtcactatgctccaagtgacgat +ttaaacgaagcaaggaataataggtttattttagtgcaaaacaattaagtgcggactacg +tgctctttacaataagccttgtgattgggctataggttaagtcccatattaacgatctcc +aatgtacaaaatcgacaatcgctttgcattacccggttactagtcgaattacagatagct +gttagatactcactctaattttggacaacaatcccaatcttggggtcgtctatcgcctga +agctcgtaaatccttccatcttaaacgattacatattatagacttgttcggggtagagat +atcacagttgtgcaaacattgtaaatcgatactagtttatgttggtagtctagttgcttt +taccattccccgaaaaacttgatctactatttcgacaacagtaaacttgaactaggtaag +tgaaaacagagaatgcctcatagtgccactatttgtccactatatgtaagtgtagcttta +cataatccactatgactgagatcattacggcctaggaaagcagcgtagaaaaaaagggcc +cggatattacgactgtaactataaaactagttactggtagcgcgccatgtatagatttgt +tttaccggttgtggttgcgttaacgaatttcagccgcgaaaattgatccgttaaccagtc +catctcgacttctataaaacgataaagtaaagttgatgttcagcctccttcttatggttg +catcgagagtacactactcagtgggaaatagatcggggttcctacttcagattgtattat +ctaggcaattgccgattgtgccatacctggataaaataagctacctacatgtgatgctta +tctattatcgtcatactaccttagggtgtcctgttgaacgctacattaatctttagccgt +ttgagatgttccaatggataggagtctaacgcatgatgaagtttaggaaggcagagcatc +ccactaagtatgtgacagtgtatttcgaaacgagacgttataaatagaaaaaaggtcctt +ctggttctattctgctgaactattgaatggaaagattggttgacctacgtactatttgct +tgaagtcatcaatttgacggggtgagagacatatggtgcatactttacggactctatatt +ttagatcagaagcttagcagtcttctctacaccccctcacgacataattgcttttaagaa +tctatgtttgattcctctacgggaattcggatccgttcgcatgtgcggtttatctaaacc +aggggacatatgttcagctaaagcatacgaacactttgctaactagacgtatgtatagta +gctataaatcccgacgatatttacaaaaagaaatgagactcaaatatatacatagcgacc +ctacacttattcgcaccctgatctaggcgatcctagcacccacacccgaaagtgagcact +agtgtcttccgtattaaatttactgcagttgagattttagttgtctactaaggattactc +taacccgtaataaggatcaagactcggtactagctttactatcattccctatgtgttttc +ctaactcacaagggtacgtaccagcctatgtaattacaataatgataaagacacaaagga +agtaactttacaaatgagtctccagttacactagcttagtccctcccatcttgctttgaa +gtctaaatacgcaatctctgaggatatacagcagaagaacactcataacgttggagtcca +agaattagactcatagggcccccaacatttaatatgtactgtgagtttgaaggtgttcta +ttgttaattcctgctcttgatacatgacacgtactccgtgtttaaggcttcggactgact +ttctttcataagttgagcaacgaaaatttcagaatcgataagttggattcactaactaat +acggctgattgaaaactccactccggacctatatggtcgacctttatacgtaaccgatat +aaaacttataggctggtatatcgagccttcctagcgcaatttcggatggggtttcttcta +ctactcaacaacggaatagtctttgtttagtaaaccagagctcaggacgcccaatacgta +ggagagcgctgtggagcatgtgtcattatggactggagcactcttaaatcactctgcgtg +tgctaaacgatagatcataacatgtcctgagtaaattttcttgatacgtcgcaatatacc +gttattagttaaacgttctcatccgtcatgcgtgaaatacggctgtcgtgctcagatata +ctattagcgactcatctcgcctaacacgcacacgtataaactcggaatgactgccgctct +tacatattagaaatacagactacaccacggaagcattgggtcattctcaaccgctgtata +aaagatgattagtcttataataagattaccaaagaggcagaatcatgggtagtaaatcta +ttattcaagtgattaccgtcgtgtaggcagggagtgaggacgagatggtactcaggacaa +atattaaccggacgaagtggtttacgtcgtactttcactattagtagtaaatacaaggta +acaccggggaatagtactaaatataatgatatctatcttcgggagaacgagtcgtctatt +gctttgaacattctcaaggcgtaaaatgtgctgacttatagcatgatacaaccgattgtt +acttttgtctattcaaaagattgaatagttttttatacaaaagccgcatacttatgacgg +ctagtatacagtttcatcccctagcatcaatgctatggacagtattgaacttataggaaa +ttcttctaatagggcaaatccgtcgtgatgcctattttttttcagtcacatcctcaaatg +gcactagtattgtcgggatcccattaacaggctcaaccacgagctcacgcgaggacatgt +agtccgtatctttaacgaagcgacagcgacagaactcccatggataaccaattataaggc +ccgtaatcctctagacatcgtttaccaataaatccgctttctccgtaatcatgttgaata +ccccagagtagtccagatgataaccgatgaaacacaagtctttctcaatgcacttacggt +gaacttattaccgccaacgtagctcatcaaggttgcgacatctagttgtgtgtttgcgac +gagcccagcgaacttcatcaactttcgtatattcaacgccttgtaattttactttaagac +gcctggtgatgtagattcttagataatcagtttgttatcggctgtactttaccataattt +cacaggtttcaggtcaagaagattatagctgtatatacagttccatgctcggtgcacaga +aacgtgatcggataataatcaatcgcttatgtcgtctttaggcgtatccaatacatgccc +cgataccgcagtgtatttcgacatgtaggtataccgtcgcatttgagctcgagtcaggac +gtcagctagattagattccttaatagaatataccgacctctagtccgaactaaactatag +ataacgccaacttcaggttaattgtctagtcgtctgtttgcagatgggattcttagatga +gtgagtatcggccatattggttcgagcactttagtttttgatgcataggatatgcaatgt +atagctgaaagtactttatctgtttcaaactcacattgattaaaccggtaaacctttaaa +gactacaagaaaatattcagtgagggcaattttgtcaatcacaatcttccagctagagat +acttcacaatttgtcttgaggctacgcaacattagacggattttcgcgttttattgaaat +aatcgaggggcccaagagtatccatagttcattttgtaagatttctttacaggcttatta +cagcttcttcagactcctacatgcttacgagttatatgctagcatgtgaacaatagatta +atatacaggaaaacgtacattgagagagatgaccctacacagcgcaaccgttgagtactt +tcattaaagggtaacgctctcgagacagcatccttaagatggccttattgtcaaatcatt +tgcagaagtacgcaagatccctaaccaacgtagaagaatccctacaaacacatgagacgc +ggtgaaaatagacagggtgttagtattcaatcttcggagtatcaatttcgccaatcttgg +tgagaaagcataccctttcttcagagaaagaagatcaatcataacactatctttaacgag +gtacgcacgcgcatcattacctgcctccatggatctttaggatagcggaaagtattggca +gcgtattgtgatttcgttcctactttatcaatttcacattcatatacatgtcttttatca +aaatcgccaataagataggatgagctatattagatgctagtagagttcgcgccaacatca +tcgataggaatactcaggacagcgtgataggacttttcaatccctaatactctctataat +tataactctctcttaagtttggaggcagtaacgcgctctatataatcagtttgctgcacc +attcttcagcctctgatacatacaaataaattccacagcagtaagagggtttaattgaga +catcttgggaacttaggattttactctaacatcaccgaaacgattattggataccgtacc +taaacgaactttctcaaggcagtaatataggacatccgcaataacacaaatgctgcctcc +ccaggagttatgtcttcctggaggctatatcttacacccactcactataggcaaactaaa +gtttaaatgttgattgtctaaaaaaaagatagataagagttggccggcgtagcacatgcg +aaagtgaatcgtaagctataattctctggacttgaagttctgtcctgttcctctgcaaga +aacaaacttcctttaaagctatttacgacgcacatctcagcaagttataaacatgttgga +agtttctagtcggaattcccaaagaacggatctatctaatgcattcctacatttttcctg +tctgccgatggtgccatcctattcaaagaatttcttaaaagtagattaaatgggactttt +aacaatgagtaaccttacgcctctaagggttcctcgagtgccatacaccagtcaggtccg +agccacatacacggagaacattctaacatagcattctcaactcgatcatttgcaggttac +ttctttcctatcctagtgctaaaaatcatacttgcaatcccatagcacggattaagaacc +taagaaacaattcagtaaaacatgttcgaattcttggtatgggaacatcattgcagctat +ggtctaacgcattaatgtttgggtacatcttccatcatataaacaggaagagtctgacga +cagggagtgcttgcgatcatgtctatcattgtgaaatcaaattgtagctcacatgtcgtc +tatgagagcgtgtatccgataagatttagaaaaatagaagtcgtataagatctcactgaa +cttttgaatgaatgtgaagcatatatgatctgctttaataaaactttatccataggatac +gtttccaaatcaattcaataattattagtcaaaatagataaggatgaacaacctgaaggc +cgatcggacgtagaaagtggtcccatcactttgagttgatattgttgaaccacacgttat +tatggttttcaaacagtctcaggatattgtatatacagataatccgataccagttgtctg +acgcccctcttacgtaccccaccctttgtgacgtttaaagcagttgttcagtattttaaa +ctaggcggcaactaatttggaaagaagcacagtggatatgtctaaattcttgttattcag +gcctgaatttaatacaccgcatagttaacttcgcggtagagttgttcatcatgcctcctc +taagctaccacttctatgatacaccaatagttgttctacggaatctgataattggccaag +tcataaacttccgctgcgttcaacccccttgctcgaatatccaactcgaaaagacagcct +tttggtgtccggaacaaatcagttacttcttttctgatgttaattctctgtggtcagata +cagaccaaaaactccgcggatttaccatcctccaagaacaaatttgcatcaacatagcat +tttggctacatattctaagtctcaatagtttaggttttcaactacattatcccaacatta +ggattggaggaataatagctgggtaagtccccttgcgtctacaatcgactattttttatg +aatatgcttctgccgcacctatggttattaaaaaagtcatgactttgaagaaccctgaaa +agatagatgaatcaggtgtaatggcagcagccaaagagcatataattagcaacactctaa +gaacattatagatatgatgatagcgatcgtcatgatgttatccggtcacaatagtagctt +catcagctaattcgttttgccagtggtgacttgcgctggaagaatcgttatacggtccct +tccctcttgatacggtgggggcttattcaaccgcgtggattgggttgtcatacttgcatt +aaacgatgtaaaccatctagtagtcaactatactaaatcacaaaatagtgatcaatacat +acccgcttcatggttttaaccatttaattgattaaagatattccgctaagaaccattatc +tacctaaactgatcgccgtatcctagtagtttgaaatttgatgtaccgtaatgatcaacg +aagtaaaacgttatattgtatgtagaataataggtcttggagctaaatgatgtgattggt +agtgaagacttacccttacaactttaccggtttctcggaagaatatactagagaatcaat +gcatgggctacataagcactttagtctaatgagataaaaaatacacgagtcttccatcat +gaattttttgtcgaaaaactcgaacctggtaatttaaaccatatatctttatgtcgtcaa +taactctcatatgttttatataacttcccaatcacgacttgtaactgcttgttcgactga +gctgtttgagctatgaggccgggatccggttgagctacatctatttgctacaagaaaaat +gaaagcacatttgttgggagttctggctacactcatagagaaataagtggcccgagtggg +tgcggcctgcctccatattcaagtgtatcttaaaccaagtggttccaacgctcgcgctaa +agaattaaagcctttatttcctccacggagtagcccgtaatccggttcgaaagagaccat +tgaagttaattttcatatccagtgaagtttaggcacaagcatgtgttctgccacatgcct +caaagcgctcttcaaccaagatatgattcatcctaacttcgatgaatgcgtctgtaacat +aaatatagaaggaatgattcggcgagttaattttcgccttctccaacatggcatccctac +gttcgttataaggaccatacatgtaggttttaaaggtttgcggttaatcgatatttacat +catagaaattctatagtcaaatttacaagactctagatactcactcgttgcagccggcta +ggaagcgctttgtaccttacttcccttttcgttgcgtaatatgaatttcatatagtaagt +tcaaggcactcatacctccgtgaagagggtagatagactattaaagttgtttaatagtac +gtattgatggaaatgacccgtaggagatttaccactcaatccacaagattcgctgctgtg +cattatcaaaacagtgcatgtcgaaacatgggttgggtccttcaaacacgaatccaggta +gagatacctttgcaattttt diff --git a/deps/regex-0.1.38/examples/regexdna-output.txt b/deps/regex-0.1.38/examples/regexdna-output.txt new file mode 100644 index 000000000..d36baa5be --- /dev/null +++ b/deps/regex-0.1.38/examples/regexdna-output.txt @@ -0,0 +1,13 @@ +agggtaaa|tttaccct 0 +[cgt]gggtaaa|tttaccc[acg] 3 +a[act]ggtaaa|tttacc[agt]t 9 +ag[act]gtaaa|tttac[agt]ct 8 +agg[act]taaa|ttta[agt]cct 10 +aggg[acg]aaa|ttt[cgt]ccct 3 +agggt[cgt]aa|tt[acg]accct 4 +agggta[cgt]a|t[acg]taccct 3 +agggtaa[cgt]|[acg]ttaccct 5 + +101745 +100000 +133640 diff --git a/deps/regex-0.1.38/examples/shootout-regex-dna.rs b/deps/regex-0.1.38/examples/shootout-regex-dna.rs new file mode 100644 index 000000000..586962402 --- /dev/null +++ b/deps/regex-0.1.38/examples/shootout-regex-dna.rs @@ -0,0 +1,71 @@ +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ +// +// contributed by the Rust Project Developers +// contributed by TeXitoi +// contributed by BurntSushi + +extern crate regex; + +use std::io::{self, Read}; +use std::sync::Arc; +use std::thread; + +macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } + +fn main() { + let mut seq = String::with_capacity(50 * (1 << 20)); + io::stdin().read_to_string(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, ""); + let clen = seq.len(); + let seq_arc = Arc::new(seq.clone()); + + let variants = vec![ + regex!("agggtaaa|tttaccct"), + regex!("[cgt]gggtaaa|tttaccc[acg]"), + regex!("a[act]ggtaaa|tttacc[agt]t"), + regex!("ag[act]gtaaa|tttac[agt]ct"), + regex!("agg[act]taaa|ttta[agt]cct"), + regex!("aggg[acg]aaa|ttt[cgt]ccct"), + regex!("agggt[cgt]aa|tt[acg]accct"), + regex!("agggta[cgt]a|t[acg]taccct"), + regex!("agggtaa[cgt]|[acg]ttaccct"), + ]; + let mut count_promises = vec![]; + for i in 0..3 { + let seq = seq_arc.clone(); + let res = variants[i * 3..i * 3 + 3].to_vec(); + count_promises.push(thread::spawn(move || { + res.into_iter() + .map(|re| (re.to_string(), re.find_iter(&seq).count())) + .collect::>() + })); + } + + let substs = vec![ + (regex!("B"), "(c|g|t)"), + (regex!("D"), "(a|g|t)"), + (regex!("H"), "(a|c|t)"), + (regex!("K"), "(g|t)"), + (regex!("M"), "(a|c)"), + (regex!("N"), "(a|c|g|t)"), + (regex!("R"), "(a|g)"), + (regex!("S"), "(c|g)"), + (regex!("V"), "(a|c|g)"), + (regex!("W"), "(a|t)"), + (regex!("Y"), "(c|t)"), + ]; + let mut seq = seq; + for (re, replacement) in substs.into_iter() { + seq = re.replace_all(&seq, replacement); + } + + for promise in count_promises { + for (re, count) in promise.join().unwrap() { + println!("{} {}", re, count); + } + } + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); +} diff --git a/deps/regex-0.1.38/examples/tiny.rs b/deps/regex-0.1.38/examples/tiny.rs new file mode 100644 index 000000000..c40abcb06 --- /dev/null +++ b/deps/regex-0.1.38/examples/tiny.rs @@ -0,0 +1,28 @@ +extern crate aho_corasick; +extern crate regex; + +macro_rules! regex { + ($re:expr) => { regex::Regex::new($re).unwrap() } +} + +fn main() { + // let mut input = String::with_capacity(10 * 1024 * 1024); + // io::stdin().read_to_string(&mut input).unwrap(); + // let input = include_str!("/tmp/regex-dna-input"); + let input = include_str!("/home/andrew/tmp/regex-dna.fasta"); + // let re = r">[^\n]*\n|\n"; + // let re = r"[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$"; + // let re = "H"; + // let re = "agggtaaa|tttaccct"; + // let re = "[cgt]gggtaaa|tttaccc[acg]"; + // let re = "a[act]ggtaaa|tttacc[agt]t"; + // let re = regex::Regex::new(re).unwrap(); + // re.replace_all(&input, ::regex::NoExpand("(a|c|t)")); + // re.replace_all(&input, ::regex::NoExpand("")); + // println!("{}", re.find_iter(&input).count()); + + let input = regex!(">[^\n]*\n|\n").replace_all(input, ""); + // let mut input = regex!(">[^\n]*\n").replace_all(input, ""); + // input = regex!("\n").replace_all(&input, ""); + println!("{}", input.len()); +} diff --git a/deps/regex-0.1.38/run-shootout-test b/deps/regex-0.1.38/run-shootout-test new file mode 100755 index 000000000..8fef4e3a5 --- /dev/null +++ b/deps/regex-0.1.38/run-shootout-test @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cargo build --example shootout-regex-dna +exec diff \ + ./examples/regexdna-output.txt \ + <(./target/debug/examples/shootout-regex-dna < ./examples/regexdna-input.txt) diff --git a/deps/regex-0.1.38/scripts/regex-match-tests.py b/deps/regex-0.1.38/scripts/regex-match-tests.py new file mode 100755 index 000000000..24635e779 --- /dev/null +++ b/deps/regex-0.1.38/scripts/regex-match-tests.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python2 + +# Copyright 2014 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +from __future__ import absolute_import, division, print_function +import argparse +import datetime +import os.path as path + + +def print_tests(tests): + print('\n'.join([test_tostr(t) for t in tests])) + + +def read_tests(f): + basename, _ = path.splitext(path.basename(f)) + tests = [] + for lineno, line in enumerate(open(f), 1): + fields = filter(None, map(str.strip, line.split('\t'))) + if not (4 <= len(fields) <= 5) \ + or 'E' not in fields[0] or fields[0][0] == '#': + continue + + opts, pat, text, sgroups = fields[0:4] + groups = [] # groups as integer ranges + if sgroups == 'NOMATCH': + groups = [None] + elif ',' in sgroups: + noparen = map(lambda s: s.strip('()'), sgroups.split(')(')) + for g in noparen: + s, e = map(str.strip, g.split(',')) + if s == '?' and e == '?': + groups.append(None) + else: + groups.append((int(s), int(e))) + else: + # This skips tests that should result in an error. + # There aren't many, so I think we can just capture those + # manually. Possibly fix this in future. + continue + + if pat == 'SAME': + pat = tests[-1][1] + if '$' in opts: + pat = pat.decode('string_escape') + text = text.decode('string_escape') + if 'i' in opts: + pat = '(?i)%s' % pat + + name = '%s_%d' % (basename, lineno) + tests.append((name, pat, text, groups)) + return tests + + +def test_tostr(t): + lineno, pat, text, groups = t + options = map(group_tostr, groups) + return 'mat!(match_%s, r"%s", r"%s", %s);' \ + % (lineno, pat, '' if text == "NULL" else text, ', '.join(options)) + + +def group_tostr(g): + if g is None: + return 'None' + else: + return 'Some((%d, %d))' % (g[0], g[1]) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='Generate match tests from an AT&T POSIX test file.') + aa = parser.add_argument + aa('files', nargs='+', + help='A list of dat AT&T POSIX test files. See src/testdata') + args = parser.parse_args() + + tests = [] + for f in args.files: + tests += read_tests(f) + + tpl = '''// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// DO NOT EDIT. Automatically generated by 'scripts/regex-match-tests.py' +// on {date}. +''' + print(tpl.format(date=str(datetime.datetime.now()))) + + for f in args.files: + print('// Tests from %s' % path.basename(f)) + print_tests(read_tests(f)) + print('') diff --git a/deps/regex-0.1.38/scripts/unicode.py b/deps/regex-0.1.38/scripts/unicode.py new file mode 100755 index 000000000..05bf78c9d --- /dev/null +++ b/deps/regex-0.1.38/scripts/unicode.py @@ -0,0 +1,297 @@ +#!/usr/bin/env python +# +# Copyright 2011-2013 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# This script uses the following Unicode tables: +# - DerivedCoreProperties.txt +# - EastAsianWidth.txt +# - PropList.txt +# - Scripts.txt +# - UnicodeData.txt +# +# Since this should not require frequent updates, we just store this +# out-of-line and check the unicode.rs file into git. + +import fileinput, re, os, sys + +preamble = '''// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// NOTE: The following code was generated by "scripts/unicode.py", do not edit +// directly + +#![allow(warnings)] +''' + +# Mapping taken from Table 12 from: +# http://www.unicode.org/reports/tr44/#General_Category_Values +expanded_categories = { + 'Lu': ['LC', 'L'], 'Ll': ['LC', 'L'], 'Lt': ['LC', 'L'], + 'Lm': ['L'], 'Lo': ['L'], + 'Mn': ['M'], 'Mc': ['M'], 'Me': ['M'], + 'Nd': ['N'], 'Nl': ['N'], 'No': ['No'], + 'Pc': ['P'], 'Pd': ['P'], 'Ps': ['P'], 'Pe': ['P'], + 'Pi': ['P'], 'Pf': ['P'], 'Po': ['P'], + 'Sm': ['S'], 'Sc': ['S'], 'Sk': ['S'], 'So': ['S'], + 'Zs': ['Z'], 'Zl': ['Z'], 'Zp': ['Z'], + 'Cc': ['C'], 'Cf': ['C'], 'Cs': ['C'], 'Co': ['C'], 'Cn': ['C'], +} + +def fetch(f): + if not os.path.exists(f): + os.system("curl -O http://www.unicode.org/Public/UNIDATA/%s" + % f) + + if not os.path.exists(f): + sys.stderr.write("cannot load %s" % f) + exit(1) + +def is_surrogate(n): + return 0xD800 <= n <= 0xDFFF + +def load_unicode_data(f): + fetch(f) + gencats = {} + + udict = {}; + range_start = -1; + for line in fileinput.input(f): + data = line.split(';'); + if len(data) != 15: + continue + cp = int(data[0], 16); + if is_surrogate(cp): + continue + if range_start >= 0: + for i in xrange(range_start, cp): + udict[i] = data; + range_start = -1; + if data[1].endswith(", First>"): + range_start = cp; + continue; + udict[cp] = data; + + for code in udict: + [code_org, name, gencat, combine, bidi, + decomp, deci, digit, num, mirror, + old, iso, upcase, lowcase, titlecase ] = udict[code]; + + # place letter in categories as appropriate + for cat in [gencat, "Assigned"] + expanded_categories.get(gencat, []): + if cat not in gencats: + gencats[cat] = [] + gencats[cat].append(code) + + # generate Not_Assigned from Assigned + gencats["Cn"] = gen_unassigned(gencats["Assigned"]) + # Assigned is not a real category + del(gencats["Assigned"]) + # Other contains Not_Assigned + gencats["C"].extend(gencats["Cn"]) + gencats = group_cats(gencats) + + return gencats + +def group_cats(cats): + cats_out = {} + for cat in cats: + cats_out[cat] = group_cat(cats[cat]) + return cats_out + +def group_cat(cat): + cat_out = [] + letters = sorted(set(cat)) + cur_start = letters.pop(0) + cur_end = cur_start + for letter in letters: + assert letter > cur_end, \ + "cur_end: %s, letter: %s" % (hex(cur_end), hex(letter)) + if letter == cur_end + 1: + cur_end = letter + else: + cat_out.append((cur_start, cur_end)) + cur_start = cur_end = letter + cat_out.append((cur_start, cur_end)) + return cat_out + +def ungroup_cat(cat): + cat_out = [] + for (lo, hi) in cat: + while lo <= hi: + cat_out.append(lo) + lo += 1 + return cat_out + +def gen_unassigned(assigned): + assigned = set(assigned) + return ([i for i in range(0, 0xd800) if i not in assigned] + + [i for i in range(0xe000, 0x110000) if i not in assigned]) + +def format_table_content(f, content, indent): + line = " "*indent + first = True + for chunk in content.split(","): + if len(line) + len(chunk) < 78: + if first: + line += chunk + else: + line += ", " + chunk + first = False + else: + f.write(line + ",\n") + line = " "*indent + chunk + f.write(line) + +def load_properties(f, interestingprops): + fetch(f) + props = {} + re1 = re.compile("^ *([0-9A-F]+) *; *(\w+)") + re2 = re.compile("^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+)") + + for line in fileinput.input(f): + prop = None + d_lo = 0 + d_hi = 0 + m = re1.match(line) + if m: + d_lo = m.group(1) + d_hi = m.group(1) + prop = m.group(2) + else: + m = re2.match(line) + if m: + d_lo = m.group(1) + d_hi = m.group(2) + prop = m.group(3) + else: + continue + if interestingprops and prop not in interestingprops: + continue + d_lo = int(d_lo, 16) + d_hi = int(d_hi, 16) + if prop not in props: + props[prop] = [] + props[prop].append((d_lo, d_hi)) + + # optimize props if possible + for prop in props: + props[prop] = group_cat(ungroup_cat(props[prop])) + + return props + +def load_case_folding(f): + fetch(f) + re1 = re.compile("^ *([0-9A-F]+) *; *[CS] *; *([0-9A-F]+) *;") + c_plus_s = [] + for line in fileinput.input(f): + m = re1.match(line) + if m: + a = int(m.group(1), 16) + b = int(m.group(2), 16) + c_plus_s.append((a, b)) + + return {"C_plus_S": c_plus_s} + +def escape_char(c): + return "'\\u{%x}'" % c + +def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True, + pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1]))): + pub_string = "" + if is_pub: + pub_string = "pub " + f.write(" %sconst %s: %s = &[\n" % (pub_string, name, t_type)) + data = "" + first = True + for dat in t_data: + if not first: + data += "," + first = False + data += pfun(dat) + format_table_content(f, data, 8) + f.write("\n ];\n\n") + +def emit_property_module(f, mod, tbl): + f.write("pub mod %s {\n" % mod) + keys = tbl.keys() + keys.sort() + for cat in keys: + emit_table(f, "%s_table" % cat, tbl[cat]) + f.write("}\n\n") + +def emit_regex_module(f, cats, w_data): + f.write("pub mod regex {\n") + regex_class = "&'static [(char, char)]" + class_table = "&'static [(&'static str, %s)]" % regex_class + + emit_table(f, "UNICODE_CLASSES", cats, class_table, + pfun=lambda x: "(\"%s\",super::%s::%s_table)" % (x[0], x[1], x[0])) + + f.write(" pub const PERLD: %s = super::general_category::Nd_table;\n\n" + % regex_class) + f.write(" pub const PERLS: %s = super::property::White_Space_table;\n\n" + % regex_class) + + emit_table(f, "PERLW", w_data, regex_class) + + f.write("}\n\n") + +if __name__ == "__main__": + r = "unicode.rs" + if os.path.exists(r): + os.remove(r) + with open(r, "w") as rf: + # write the file's preamble + rf.write(preamble) + + # download and parse all the data + fetch("ReadMe.txt") + with open("ReadMe.txt") as readme: + pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode" + unicode_version = re.search(pattern, readme.read()).groups() + gencats = load_unicode_data("UnicodeData.txt") + want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"] + other_derived = ["Default_Ignorable_Code_Point", "Grapheme_Extend"] + derived = load_properties("DerivedCoreProperties.txt", want_derived + other_derived) + scripts = load_properties("Scripts.txt", []) + props = load_properties("PropList.txt", + ["White_Space", "Join_Control", "Noncharacter_Code_Point"]) + case_folding = load_case_folding("CaseFolding.txt") + + # all of these categories will also be available as \p{} in libregex + allcats = [] + for (name, cat) in ("general_category", gencats), \ + ("derived_property", derived), \ + ("script", scripts), \ + ("property", props): + emit_property_module(rf, name, cat) + allcats.extend(map(lambda x: (x, name), cat)) + allcats.sort(key=lambda c: c[0]) + + # the \w regex corresponds to Alphabetic + Mark + Decimal_Number + + # Connector_Punctuation + Join-Control according to UTS#18 + # http://www.unicode.org/reports/tr18/#Compatibility_Properties + perl_words = [] + for cat in derived["Alphabetic"], gencats["M"], gencats["Nd"], \ + gencats["Pc"], props["Join_Control"]: + perl_words.extend(ungroup_cat(cat)) + perl_words = group_cat(perl_words) + + # emit lookup tables for \p{}, along with \d, \w, and \s for libregex + emit_regex_module(rf, allcats, perl_words) + emit_property_module(rf, "case_folding", case_folding) diff --git a/deps/regex-0.1.38/src/backtrack.rs b/deps/regex-0.1.38/src/backtrack.rs new file mode 100644 index 000000000..e397b2ebf --- /dev/null +++ b/deps/regex-0.1.38/src/backtrack.rs @@ -0,0 +1,269 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is the backtracking matching engine. It has the same exact capability +// as the full NFA simulation, except it is artificially restricted to small +// regexes on small inputs because of its memory requirements. +// +// In particular, this is a *bounded* backtracking engine. It retains worst +// case linear time by keeping track of the states that is has visited (using a +// bitmap). Namely, once a state is visited, it is never visited again. Since a +// state is keyed by `(instruction index, input index)`, we have that its time +// complexity is `O(mn)`. +// +// The backtracking engine can beat out the NFA simulation on small +// regexes/inputs because it doesn't have to keep track of multiple copies of +// the capture groups. In benchmarks, the backtracking engine is roughly twice +// as fast as the full NFA simulation. + +use input::{Input, InputAt, CharInput}; +use program::{Inst, InstIdx, Program}; +use re::CaptureIdxs; + +type Bits = u32; +const BIT_SIZE: usize = 32; +const MAX_PROG_SIZE: usize = 100; +const MAX_INPUT_SIZE: usize = 256 * (1 << 10); + +// Total memory usage in bytes is determined by: +// +// ((len(insts) * (len(input) + 1) + bits - 1) / bits) / (bits / 8) +// +// With the above settings, this comes out to ~3.2MB. Mostly these numbers +// were picked empirically with suspicious benchmarks. + +/// A backtracking matching engine. +#[derive(Debug)] +pub struct Backtrack<'r, 't, 'c> { + prog: &'r Program, + input: CharInput<'t>, + caps: &'c mut CaptureIdxs, + m: BackMachine, +} + +/// Shared cached state between multiple invocations of a backtracking engine +/// in the same thread. +/// +/// It is exported so that it can be cached by `program::Program`. +#[derive(Debug)] +pub struct BackMachine { + jobs: Vec, + visited: Vec, +} + +impl BackMachine { + /// Create new empty state for the backtracking engine. + pub fn new() -> BackMachine { + BackMachine { + jobs: vec![], + visited: vec![], + } + } +} + +/// A job is an explicit unit of stack space in the backtracking engine. +/// +/// The "normal" representation is a single state transition, which corresponds +/// to an NFA state and a character in the input. However, the backtracking +/// engine must keep track of old capture group values. We use the explicit +/// stack to do it. +#[derive(Clone, Copy, Debug)] +enum Job { + Inst { pc: InstIdx, at: InputAt }, + SaveRestore { slot: usize, old_pos: Option }, +} + +impl<'r, 't, 'c> Backtrack<'r, 't, 'c> { + /// Execute the backtracking matching engine. + /// + /// If there's a match, `exec` returns `true` and populates the given + /// captures accordingly. + pub fn exec( + prog: &'r Program, + mut caps: &mut CaptureIdxs, + text: &'t str, + start: usize, + ) -> bool { + let input = CharInput::new(text); + let start = input.at(start); + let m = prog.backtrack.get(); + let mut b = Backtrack { + prog: prog, + input: input, + caps: caps, + m: m, + }; + let matched = b.exec_(start); + prog.backtrack.put(b.m); + matched + } + + /// Returns true iff the given regex and input can be executed by this + /// engine with reasonable memory usage. + pub fn should_exec(prog: &'r Program, input: &str) -> bool { + prog.insts.len() <= MAX_PROG_SIZE && input.len() <= MAX_INPUT_SIZE + } + + fn clear(&mut self) { + // Reset the job memory so that we start fresh. + self.m.jobs.truncate(0); + + // Now we need to clear the bit state set. + // We do this by figuring out how much space we need to keep track + // of the states we've visited. + // Then we reset all existing allocated space to 0. + // Finally, we request more space if we need it. + // + // This is all a little circuitous, but doing this unsafely + // doesn't seem to have a measurable impact on performance. + // (Probably because backtracking is limited to such small + // inputs/regexes in the first place.) + let visited_len = + (self.prog.insts.len() * (self.input.len() + 1) + BIT_SIZE - 1) + / + BIT_SIZE; + for v in &mut self.m.visited { + *v = 0; + } + let cur_visited_cap = self.m.visited.capacity(); + if visited_len > cur_visited_cap { + self.m.visited.reserve_exact(visited_len - cur_visited_cap); + for _ in 0..(visited_len - cur_visited_cap) { + self.m.visited.push(0); + } + } + } + + fn exec_(&mut self, mut at: InputAt) -> bool { + self.clear(); + if self.prog.anchored_begin { + return if !at.is_beginning() { + false + } else { + match self.input.prefix_at(&self.prog.prefixes, at) { + None => false, + Some(at) => self.backtrack(at), + } + }; + } + loop { + if !self.prog.prefixes.is_empty() { + at = match self.input.prefix_at(&self.prog.prefixes, at) { + None => return false, + Some(at) => at, + }; + } + if self.backtrack(at) { + return true; + } + if at.char().is_none() { + return false; + } + at = self.input.at(at.next_pos()); + } + } + + // This `inline(always)` seems to result in about a 10-15% increase in + // throughput on the `hard` benchmarks (over a standard `inline`). ---AG + #[inline(always)] + fn backtrack(&mut self, start: InputAt) -> bool { + self.push(0, start); + while let Some(job) = self.m.jobs.pop() { + match job { + Job::Inst { pc, at } => { + if self.step(pc, at) { + return true; + } + } + Job::SaveRestore { slot, old_pos } => { + self.caps[slot] = old_pos; + } + } + } + false + } + + fn step(&mut self, mut pc: InstIdx, mut at: InputAt) -> bool { + use program::Inst::*; + loop { + // This loop is an optimization to avoid constantly pushing/popping + // from the stack. Namely, if we're pushing a job only to run it + // next, avoid the push and just mutate `pc` (and possibly `at`) + // in place. + match self.prog.insts[pc] { + Match => return true, + Save(slot) => { + if slot < self.caps.len() { + // If this path doesn't work out, then we save the old + // capture index (if one exists) in an alternate + // job. If the next path fails, then the alternate + // job is popped and the old capture index is restored. + let old_pos = self.caps[slot]; + self.push_save_restore(slot, old_pos); + self.caps[slot] = Some(at.pos()); + } + pc += 1; + } + Jump(pc2) => pc = pc2, + Split(x, y) => { + self.push(y, at); + pc = x; + } + EmptyLook(ref inst) => { + let prev = self.input.previous_at(at.pos()); + if inst.matches(prev.char(), at.char()) { + pc += 1; + } else { + return false; + } + } + Char(ref inst) => { + if inst.matches(at.char()) { + pc += 1; + at = self.input.at(at.next_pos()); + } else { + return false; + } + } + Ranges(ref inst) => { + if inst.matches(at.char()).is_some() { + pc += 1; + at = self.input.at(at.next_pos()); + } else { + return false; + } + } + } + if self.has_visited(pc, at) { + return false; + } + } + } + + fn push(&mut self, pc: InstIdx, at: InputAt) { + self.m.jobs.push(Job::Inst { pc: pc, at: at }); + } + + fn push_save_restore(&mut self, slot: usize, old_pos: Option) { + self.m.jobs.push(Job::SaveRestore { slot: slot, old_pos: old_pos }); + } + + fn has_visited(&mut self, pc: InstIdx, at: InputAt) -> bool { + let k = pc * (self.input.len() + 1) + at.pos(); + let k1 = k / BIT_SIZE; + let k2 = (1 << (k & (BIT_SIZE - 1))) as Bits; + if self.m.visited[k1] & k2 == 0 { + self.m.visited[k1] |= k2; + false + } else { + true + } + } +} diff --git a/deps/regex-0.1.38/src/char.rs b/deps/regex-0.1.38/src/char.rs new file mode 100644 index 000000000..43661717c --- /dev/null +++ b/deps/regex-0.1.38/src/char.rs @@ -0,0 +1,107 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::char; +use std::cmp::Ordering; +use std::fmt; +use std::u32; + +use syntax; + +/// An inline representation of `Option`. +/// +/// This eliminates the need to do case analysis on `Option` to determine +/// ordinality with other characters. +/// +/// (The `Option` is not related to encoding. Instead, it is used in the +/// matching engines to represent the beginning and ending boundaries of the +/// search text.) +#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct Char(u32); + +impl fmt::Debug for Char { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match char::from_u32(self.0) { + None => write!(f, "Empty"), + Some(c) => write!(f, "{:?}", c), + } + } +} + +impl Char { + /// Returns true iff the character is absent. + #[inline] + pub fn is_none(self) -> bool { self.0 == u32::MAX } + + /// Returns the length of the character's UTF-8 encoding. + /// + /// If the character is absent, then `0` is returned. + #[inline] + pub fn len_utf8(self) -> usize { + char::from_u32(self.0).map(|c| c.len_utf8()).unwrap_or(0) + } + + /// Returns the simple case folding of this character. + /// + /// If the character is absent, then absence is returned. + pub fn case_fold(self) -> Char { + char::from_u32(self.0).map(syntax::simple_case_fold).into() + } + + /// Returns true iff the character is a word character. + /// + /// If the character is absent, then false is returned. + pub fn is_word_char(self) -> bool { + char::from_u32(self.0).map(syntax::is_word_char).unwrap_or(false) + } + + /// Converts the character to a real primitive `char`. + /// + /// If the character is absent, then `None` is returned. + pub fn as_char(self) -> Option { + // This is only used in the `regex!` macro because it expands char + // classes into `match` expressions (instead of binary search). + char::from_u32(self.0) + } +} + +impl From for Char { + fn from(c: char) -> Char { Char(c as u32) } +} + +impl From> for Char { + fn from(c: Option) -> Char { + c.map(|c| c.into()).unwrap_or(Char(u32::MAX)) + } +} + +impl PartialEq for Char { + #[inline] + fn eq(&self, other: &char) -> bool { self.0 == *other as u32 } +} + +impl PartialEq for char { + #[inline] + fn eq(&self, other: &Char) -> bool { *self as u32 == other.0 } +} + +impl PartialOrd for Char { + #[inline] + fn partial_cmp(&self, other: &char) -> Option { + self.0.partial_cmp(&(*other as u32)) + } +} + +impl PartialOrd for char { + #[inline] + fn partial_cmp(&self, other: &Char) -> Option { + (*self as u32).partial_cmp(&other.0) + } +} diff --git a/deps/regex-0.1.38/src/compile.rs b/deps/regex-0.1.38/src/compile.rs new file mode 100644 index 000000000..012328c6a --- /dev/null +++ b/deps/regex-0.1.38/src/compile.rs @@ -0,0 +1,249 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use syntax::{self, Expr, Repeater}; + +use Error; +use program::{CharRanges, Inst, InstIdx, OneChar}; + +type Compiled = (Vec, Vec>); + +/// A regex compiler. +/// +/// A regex compiler is responsible for turning a regex's AST into a sequence +/// of instructions. +pub struct Compiler { + size_limit: usize, + insts: Vec, + cap_names: Vec>, +} + +impl Compiler { + /// Creates a new compiler that limits the size of the regex program + /// to the size given (in bytes). + pub fn new(size_limit: usize) -> Compiler { + Compiler { + size_limit: size_limit, + insts: vec![], + cap_names: vec![None], + } + } + + /// Compiles the given regex AST into a tuple of a sequence of + /// instructions and a sequence of capture groups, optionally named. + pub fn compile(mut self, ast: Expr) -> Result { + self.insts.push(Inst::Save(0)); + try!(self.c(ast)); + self.insts.push(Inst::Save(1)); + self.insts.push(Inst::Match); + Ok((self.insts, self.cap_names)) + } + + fn c(&mut self, ast: Expr) -> Result<(), Error> { + use program::Inst::*; + use program::LookInst::*; + + match ast { + Expr::Empty => {}, + Expr::Literal { chars, casei } => { + for mut c in chars { + if casei { + c = syntax::simple_case_fold(c); + } + self.push(Char(OneChar { c: c, casei: casei })); + } + } + Expr::AnyChar => self.push(Ranges(CharRanges::any())), + Expr::AnyCharNoNL => self.push(Ranges(CharRanges::any_nonl())), + Expr::Class(cls) => { + if cls.len() == 1 && cls[0].start == cls[0].end { + self.push(Char(OneChar { + c: cls[0].start, + casei: cls.is_case_insensitive(), + })); + } else { + self.push(Ranges(CharRanges::from_class(cls))); + } + } + Expr::StartLine => self.push(EmptyLook(StartLine)), + Expr::EndLine => self.push(EmptyLook(EndLine)), + Expr::StartText => self.push(EmptyLook(StartText)), + Expr::EndText => self.push(EmptyLook(EndText)), + Expr::WordBoundary => self.push(EmptyLook(WordBoundary)), + Expr::NotWordBoundary => self.push(EmptyLook(NotWordBoundary)), + Expr::Group { e, i: None, name: None } => try!(self.c(*e)), + Expr::Group { e, i, name } => { + let i = i.expect("capture index"); + self.cap_names.push(name); + self.push(Save(2 * i)); + try!(self.c(*e)); + self.push(Save(2 * i + 1)); + } + Expr::Concat(es) => { + for e in es { + try!(self.c(e)); + } + } + Expr::Alternate(mut es) => { + // TODO: Don't use recursion here. ---AG + if es.len() == 0 { + return Ok(()); + } + let e1 = es.remove(0); + if es.len() == 0 { + try!(self.c(e1)); + return Ok(()); + } + let e2 = Expr::Alternate(es); // this causes recursion + + let split = self.empty_split(); + let j1 = self.insts.len(); + try!(self.c(e1)); + let jmp = self.empty_jump(); + let j2 = self.insts.len(); + try!(self.c(e2)); + let j3 = self.insts.len(); + + self.set_split(split, j1, j2); + self.set_jump(jmp, j3); + } + Expr::Repeat { e, r: Repeater::ZeroOrOne, greedy } => { + let split = self.empty_split(); + let j1 = self.insts.len(); + try!(self.c(*e)); + let j2 = self.insts.len(); + + if greedy { + self.set_split(split, j1, j2); + } else { + self.set_split(split, j2, j1); + } + } + Expr::Repeat { e, r: Repeater::ZeroOrMore, greedy } => { + let j1 = self.insts.len(); + let split = self.empty_split(); + let j2 = self.insts.len(); + try!(self.c(*e)); + let jmp = self.empty_jump(); + let j3 = self.insts.len(); + + self.set_jump(jmp, j1); + if greedy { + self.set_split(split, j2, j3); + } else { + self.set_split(split, j3, j2); + } + } + Expr::Repeat { e, r: Repeater::OneOrMore, greedy } => { + let j1 = self.insts.len(); + try!(self.c(*e)); + let split = self.empty_split(); + let j2 = self.insts.len(); + + if greedy { + self.set_split(split, j1, j2); + } else { + self.set_split(split, j2, j1); + } + } + Expr::Repeat { + e, + r: Repeater::Range { min, max: None }, + greedy, + } => { + let e = *e; + for _ in 0..min { + try!(self.c(e.clone())); + } + try!(self.c(Expr::Repeat { + e: Box::new(e), + r: Repeater::ZeroOrMore, + greedy: greedy, + })); + } + Expr::Repeat { + e, + r: Repeater::Range { min, max: Some(max) }, + greedy, + } => { + let e = *e; + for _ in 0..min { + try!(self.c(e.clone())); + } + for _ in min..max { + try!(self.c(Expr::Repeat { + e: Box::new(e.clone()), + r: Repeater::ZeroOrOne, + greedy: greedy, + })); + } + } + } + self.check_size() + } + + fn check_size(&self) -> Result<(), Error> { + use std::mem::size_of; + + if self.insts.len() * size_of::() > self.size_limit { + Err(Error::CompiledTooBig(self.size_limit)) + } else { + Ok(()) + } + } + + /// Appends the given instruction to the program. + #[inline] + fn push(&mut self, x: Inst) { + self.insts.push(x) + } + + /// Appends an *empty* `Split` instruction to the program and returns + /// the index of that instruction. (The index can then be used to "patch" + /// the actual locations of the split in later.) + #[inline] + fn empty_split(&mut self) -> InstIdx { + self.insts.push(Inst::Split(0, 0)); + self.insts.len() - 1 + } + + /// Sets the left and right locations of a `Split` instruction at index + /// `i` to `pc1` and `pc2`, respectively. + /// If the instruction at index `i` isn't a `Split` instruction, then + /// `panic!` is called. + #[inline] + fn set_split(&mut self, i: InstIdx, pc1: InstIdx, pc2: InstIdx) { + let split = &mut self.insts[i]; + match *split { + Inst::Split(_, _) => *split = Inst::Split(pc1, pc2), + _ => panic!("BUG: Invalid split index."), + } + } + + /// Appends an *empty* `Jump` instruction to the program and returns the + /// index of that instruction. + #[inline] + fn empty_jump(&mut self) -> InstIdx { + self.insts.push(Inst::Jump(0)); + self.insts.len() - 1 + } + + /// Sets the location of a `Jump` instruction at index `i` to `pc`. + /// If the instruction at index `i` isn't a `Jump` instruction, then + /// `panic!` is called. + #[inline] + fn set_jump(&mut self, i: InstIdx, pc: InstIdx) { + let jmp = &mut self.insts[i]; + match *jmp { + Inst::Jump(_) => *jmp = Inst::Jump(pc), + _ => panic!("BUG: Invalid jump index."), + } + } +} diff --git a/deps/regex-0.1.38/src/input.rs b/deps/regex-0.1.38/src/input.rs new file mode 100644 index 000000000..446872bb4 --- /dev/null +++ b/deps/regex-0.1.38/src/input.rs @@ -0,0 +1,114 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops; + +use char::Char; +use prefix::Prefix; + +/// Represents a location in the input. +#[derive(Clone, Copy, Debug)] +pub struct InputAt { + pos: usize, + c: Char, + len: usize, +} + +impl InputAt { + /// Returns true iff this position is at the beginning of the input. + pub fn is_beginning(&self) -> bool { + self.pos == 0 + } + + /// Returns the character at this position. + /// + /// If this position is just before or after the input, then an absent + /// character is returned. + pub fn char(&self) -> Char { + self.c + } + + /// Returns the UTF-8 width of the character at this position. + pub fn len(&self) -> usize { + self.len + } + + /// Returns the byte offset of this position. + pub fn pos(&self) -> usize { + self.pos + } + + /// Returns the byte offset of the next position in the input. + pub fn next_pos(&self) -> usize { + self.pos + self.len + } +} + +/// An abstraction over input used in the matching engines. +pub trait Input { + /// Return an encoding of the position at byte offset `i`. + fn at(&self, i: usize) -> InputAt; + /// Return an encoding of the char position just prior to byte offset `i`. + fn previous_at(&self, i: usize) -> InputAt; + /// Scan the input for a matching prefix. + fn prefix_at(&self, prefixes: &Prefix, at: InputAt) -> Option; +} + +/// An input reader over characters. +/// +/// (This is the only implementation of `Input` at the moment.) +#[derive(Debug)] +pub struct CharInput<'t>(&'t str); + +impl<'t> CharInput<'t> { + /// Return a new character input reader for the given string. + pub fn new(s: &'t str) -> CharInput<'t> { + CharInput(s) + } +} + +impl<'t> ops::Deref for CharInput<'t> { + type Target = str; + + fn deref(&self) -> &str { + self.0 + } +} + +impl<'t> Input for CharInput<'t> { + // This `inline(always)` increases throughput by almost 25% on the `hard` + // benchmarks over a normal `inline` annotation. + // + // I'm not sure why `#[inline]` isn't enough to convince LLVM, but it is + // used *a lot* in the guts of the matching engines. + #[inline(always)] + fn at(&self, i: usize) -> InputAt { + let c = self[i..].chars().next().into(); + InputAt { + pos: i, + c: c, + len: c.len_utf8(), + } + } + + fn previous_at(&self, i: usize) -> InputAt { + let c: Char = self[..i].chars().rev().next().into(); + let len = c.len_utf8(); + InputAt { + pos: i - len, + c: c, + len: len, + } + } + + fn prefix_at(&self, prefixes: &Prefix, at: InputAt) -> Option { + prefixes.find(&self[at.pos()..]).map(|(s, _)| self.at(at.pos() + s)) + } +} diff --git a/deps/regex-0.1.38/src/lib.rs b/deps/regex-0.1.38/src/lib.rs new file mode 100644 index 000000000..35601bd27 --- /dev/null +++ b/deps/regex-0.1.38/src/lib.rs @@ -0,0 +1,431 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! This crate provides a native implementation of regular expressions that is +//! heavily based on RE2 both in syntax and in implementation. Notably, +//! backreferences and arbitrary lookahead/lookbehind assertions are not +//! provided. In return, regular expression searching provided by this package +//! has excellent worst-case performance. The specific syntax supported is +//! documented further down. +//! +//! This crate's documentation provides some simple examples, describes Unicode +//! support and exhaustively lists the supported syntax. For more specific +//! details on the API, please see the documentation for the `Regex` type. +//! +//! # Usage +//! +//! This crate is [on crates.io](https://crates.io/crates/regex) and can be +//! used by adding `regex` to your dependencies in your project's `Cargo.toml`. +//! +//! ```toml +//! [dependencies] +//! regex = "0.1.8" +//! ``` +//! +//! and this to your crate root: +//! +//! ```rust +//! extern crate regex; +//! ``` +//! +//! # First example: find a date +//! +//! General use of regular expressions in this package involves compiling an +//! expression and then using it to search, split or replace text. For example, +//! to confirm that some text resembles a date: +//! +//! ```rust +//! use regex::Regex; +//! let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); +//! assert!(re.is_match("2014-01-01")); +//! ``` +//! +//! Notice the use of the `^` and `$` anchors. In this crate, every expression +//! is executed with an implicit `.*?` at the beginning and end, which allows +//! it to match anywhere in the text. Anchors can be used to ensure that the +//! full text matches an expression. +//! +//! This example also demonstrates the utility of +//! [raw strings](http://doc.rust-lang.org/stable/reference.html#raw-byte-string-literals) +//! in Rust, which +//! are just like regular strings except they are prefixed with an `r` and do +//! not process any escape sequences. For example, `"\\d"` is the same +//! expression as `r"\d"`. +//! +//! # The `regex!` macro +//! +//! Rust's compile-time meta-programming facilities provide a way to write a +//! `regex!` macro which compiles regular expressions *when your program +//! compiles*. Said differently, if you only use `regex!` to build regular +//! expressions in your program, then your program cannot compile with an +//! invalid regular expression. Moreover, the `regex!` macro compiles the +//! given expression to native Rust code, which ideally makes it faster. +//! Unfortunately (or fortunately), the dynamic implementation has had a lot +//! more optimization work put it into it currently, so it is faster than +//! the `regex!` macro in most cases. +//! +//! To use the `regex!` macro, you must enable the `plugin` feature and import +//! the `regex_macros` crate as a syntax extension: +//! +//! ```ignore +//! #![feature(plugin)] +//! #![plugin(regex_macros)] +//! extern crate regex; +//! +//! fn main() { +//! let re = regex!(r"^\d{4}-\d{2}-\d{2}$"); +//! assert!(re.is_match("2014-01-01")); +//! } +//! ``` +//! +//! There are a few things worth mentioning about using the `regex!` macro. +//! Firstly, the `regex!` macro *only* accepts string *literals*. +//! Secondly, the `regex` crate *must* be linked with the name `regex` since +//! the generated code depends on finding symbols in the `regex` crate. +//! +//! One downside of using the `regex!` macro is that it can increase the +//! size of your program's binary since it generates specialized Rust code. +//! The extra size probably won't be significant for a small number of +//! expressions, but 100+ calls to `regex!` will probably result in a +//! noticeably bigger binary. +//! +//! **NOTE**: This is implemented using a compiler plugin, which is not +//! available on the Rust 1.0 beta/stable channels. Therefore, you'll only +//! be able to use `regex!` on the nightlies. +//! +//! # Example: iterating over capture groups +//! +//! This crate provides convenient iterators for matching an expression +//! repeatedly against a search string to find successive non-overlapping +//! matches. For example, to find all dates in a string and be able to access +//! them by their component pieces: +//! +//! ```rust +//! # extern crate regex; use regex::Regex; +//! # fn main() { +//! let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap(); +//! let text = "2012-03-14, 2013-01-01 and 2014-07-05"; +//! for cap in re.captures_iter(text) { +//! println!("Month: {} Day: {} Year: {}", +//! cap.at(2).unwrap_or(""), cap.at(3).unwrap_or(""), +//! cap.at(1).unwrap_or("")); +//! } +//! // Output: +//! // Month: 03 Day: 14 Year: 2012 +//! // Month: 01 Day: 01 Year: 2013 +//! // Month: 07 Day: 05 Year: 2014 +//! # } +//! ``` +//! +//! Notice that the year is in the capture group indexed at `1`. This is +//! because the *entire match* is stored in the capture group at index `0`. +//! +//! # Example: replacement with named capture groups +//! +//! Building on the previous example, perhaps we'd like to rearrange the date +//! formats. This can be done with text replacement. But to make the code +//! clearer, we can *name* our capture groups and use those names as variables +//! in our replacement text: +//! +//! ```rust +//! # extern crate regex; use regex::Regex; +//! # fn main() { +//! let re = Regex::new(r"(?P\d{4})-(?P\d{2})-(?P\d{2})").unwrap(); +//! let before = "2012-03-14, 2013-01-01 and 2014-07-05"; +//! let after = re.replace_all(before, "$m/$d/$y"); +//! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); +//! # } +//! ``` +//! +//! The `replace` methods are actually polymorphic in the replacement, which +//! provides more flexibility than is seen here. (See the documentation for +//! `Regex::replace` for more details.) +//! +//! Note that if your regex gets complicated, you can use the `x` flag to +//! enable insigificant whitespace mode, which also lets you write comments: +//! +//! ```rust +//! # extern crate regex; use regex::Regex; +//! # fn main() { +//! let re = Regex::new(r"(?x) +//! (?P\d{4}) # the year +//! - +//! (?P\d{2}) # the month +//! - +//! (?P\d{2}) # the day +//! ").unwrap(); +//! let before = "2012-03-14, 2013-01-01 and 2014-07-05"; +//! let after = re.replace_all(before, "$m/$d/$y"); +//! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); +//! # } +//! ``` +//! +//! # Pay for what you use +//! +//! With respect to searching text with a regular expression, there are three +//! questions that can be asked: +//! +//! 1. Does the text match this expression? +//! 2. If so, where does it match? +//! 3. Where are the submatches? +//! +//! Generally speaking, this crate could provide a function to answer only #3, +//! which would subsume #1 and #2 automatically. However, it can be +//! significantly more expensive to compute the location of submatches, so it's +//! best not to do it if you don't need to. +//! +//! Therefore, only use what you need. For example, don't use `find` if you +//! only need to test if an expression matches a string. (Use `is_match` +//! instead.) +//! +//! # Unicode +//! +//! This implementation executes regular expressions **only** on sequences of +//! Unicode scalar values while exposing match locations as byte indices into +//! the search string. +//! +//! Currently, only simple case folding is supported. Namely, when matching +//! case-insensitively, the characters are first mapped using the +//! [simple case folding](ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt) +//! mapping. +//! +//! Regular expressions themselves are also **only** interpreted as a sequence +//! of Unicode scalar values. This means you can use Unicode characters +//! directly in your expression: +//! +//! ```rust +//! # extern crate regex; use regex::Regex; +//! # fn main() { +//! let re = Regex::new(r"(?i)Δ+").unwrap(); +//! assert_eq!(re.find("ΔδΔ"), Some((0, 6))); +//! # } +//! ``` +//! +//! Finally, Unicode general categories and scripts are available as character +//! classes. For example, you can match a sequence of numerals, Greek or +//! Cherokee letters: +//! +//! ```rust +//! # extern crate regex; use regex::Regex; +//! # fn main() { +//! let re = Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+").unwrap(); +//! assert_eq!(re.find("abcΔᎠβⅠᏴγδⅡxyz"), Some((3, 23))); +//! # } +//! ``` +//! +//! # Syntax +//! +//! The syntax supported in this crate is almost in an exact correspondence +//! with the syntax supported by RE2. It is documented below. +//! +//! Note that the regular expression parser and abstract syntax are exposed in +//! a separate crate, +//! [`regex-syntax`](../regex_syntax/index.html). +//! +//! ## Matching one character +//! +//!
+//! .           any character except new line (includes new line with s flag)
+//! [xyz]       A character class matching either x, y or z.
+//! [^xyz]      A character class matching any character except x, y and z.
+//! [a-z]       A character class matching any character in range a-z.
+//! \d          digit (\p{Nd})
+//! \D          not digit
+//! [:alpha:]   ASCII character class ([A-Za-z])
+//! [:^alpha:]  Negated ASCII character class ([^A-Za-z])
+//! \pN         One-letter name Unicode character class
+//! \p{Greek}   Unicode character class (general category or script)
+//! \PN         Negated one-letter name Unicode character class
+//! \P{Greek}   negated Unicode character class (general category or script)
+//! 
+//! +//! Any named character class may appear inside a bracketed `[...]` character +//! class. For example, `[\p{Greek}\pN]` matches any Greek or numeral +//! character. +//! +//! ## Composites +//! +//!
+//! xy    concatenation (x followed by y)
+//! x|y   alternation (x or y, prefer x)
+//! 
+//! +//! ## Repetitions +//! +//!
+//! x*        zero or more of x (greedy)
+//! x+        one or more of x (greedy)
+//! x?        zero or one of x (greedy)
+//! x*?       zero or more of x (ungreedy)
+//! x+?       one or more of x (ungreedy)
+//! x??       zero or one of x (ungreedy)
+//! x{n,m}    at least n x and at most m x (greedy)
+//! x{n,}     at least n x (greedy)
+//! x{n}      exactly n x
+//! x{n,m}?   at least n x and at most m x (ungreedy)
+//! x{n,}?    at least n x (ungreedy)
+//! x{n}?     exactly n x
+//! 
+//! +//! ## Empty matches +//! +//!
+//! ^     the beginning of text (or start-of-line with multi-line mode)
+//! $     the end of text (or end-of-line with multi-line mode)
+//! \A    only the beginning of text (even with multi-line mode enabled)
+//! \z    only the end of text (even with multi-line mode enabled)
+//! \b    a Unicode word boundary (\w on one side and \W, \A, or \z on other)
+//! \B    not a Unicode word boundary
+//! 
+//! +//! ## Grouping and flags +//! +//!
+//! (exp)          numbered capture group (indexed by opening parenthesis)
+//! (?P<name>exp)  named (also numbered) capture group (allowed chars: [_0-9a-zA-Z])
+//! (?:exp)        non-capturing group
+//! (?flags)       set flags within current group
+//! (?flags:exp)   set flags for exp (non-capturing)
+//! 
+//! +//! Flags are each a single character. For example, `(?x)` sets the flag `x` +//! and `(?-x)` clears the flag `x`. Multiple flags can be set or cleared at +//! the same time: `(?xy)` sets both the `x` and `y` flags and `(?x-y)` sets +//! the `x` flag and clears the `y` flag. +//! +//! All flags are by default disabled. They are: +//! +//!
+//! i     case-insensitive
+//! m     multi-line mode: ^ and $ match begin/end of line
+//! s     allow . to match \n
+//! U     swap the meaning of x* and x*?
+//! x     ignore whitespace and allow line comments (starting with `#`)
+//! 
+//! +//! Here's an example that matches case-insensitively for only part of the +//! expression: +//! +//! ```rust +//! # extern crate regex; use regex::Regex; +//! # fn main() { +//! let re = Regex::new(r"(?i)a+(?-i)b+").unwrap(); +//! let cap = re.captures("AaAaAbbBBBb").unwrap(); +//! assert_eq!(cap.at(0), Some("AaAaAbb")); +//! # } +//! ``` +//! +//! Notice that the `a+` matches either `a` or `A`, but the `b+` only matches +//! `b`. +//! +//! ## Escape sequences +//! +//!
+//! \*         literal *, works for any punctuation character: \.+*?()|[]{}^$
+//! \a         bell (\x07)
+//! \f         form feed (\x0C)
+//! \t         horizontal tab
+//! \n         new line
+//! \r         carriage return
+//! \v         vertical tab (\x0B)
+//! \123       octal character code (up to three digits)
+//! \x7F       hex character code (exactly two digits)
+//! \x{10FFFF} any hex character code corresponding to a Unicode code point
+//! 
+//! +//! ## Perl character classes (Unicode friendly) +//! +//! These classes are based on the definitions provided in +//! [UTS#18](http://www.unicode.org/reports/tr18/#Compatibility_Properties): +//! +//!
+//! \d     digit (\p{Nd})
+//! \D     not digit
+//! \s     whitespace (\p{White_Space})
+//! \S     not whitespace
+//! \w     word character (\p{Alphabetic} + \p{M} + \d + \p{Pc} + \p{Join_Control})
+//! \W     not word character
+//! 
+//! +//! ## ASCII character classes +//! +//!
+//! [:alnum:]    alphanumeric ([0-9A-Za-z])
+//! [:alpha:]    alphabetic ([A-Za-z])
+//! [:ascii:]    ASCII ([\x00-\x7F])
+//! [:blank:]    blank ([\t ])
+//! [:cntrl:]    control ([\x00-\x1F\x7F])
+//! [:digit:]    digits ([0-9])
+//! [:graph:]    graphical ([!-~])
+//! [:lower:]    lower case ([a-z])
+//! [:print:]    printable ([ -~])
+//! [:punct:]    punctuation ([!-/:-@[-`{-~])
+//! [:space:]    whitespace ([\t\n\v\f\r ])
+//! [:upper:]    upper case ([A-Z])
+//! [:word:]     word characters ([0-9A-Za-z_])
+//! [:xdigit:]   hex digit ([0-9A-Fa-f])
+//! 
+//! +//! # Untrusted input +//! +//! This crate can handle both untrusted regular expressions and untrusted +//! search text. +//! +//! Untrusted regular expressions are handled by capping the size of a compiled +//! regular expression. (See `Regex::with_size_limit`.) Without this, it would +//! be trivial for an attacker to exhaust your system's memory with expressions +//! like `a{100}{100}{100}`. +//! +//! Untrusted search text is allowed because the matching engine(s) in this +//! crate have time complexity `O(mn)` (with `m ~ regex` and `n ~ search +//! text`), which means there's no way to cause exponential blow-up like with +//! some other regular expression engines. (We pay for this by disallowing +//! features like arbitrary look-ahead and back-references.) + +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] +#![cfg_attr(feature = "pattern", feature(pattern))] +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/regex/")] + +extern crate aho_corasick; +extern crate memchr; +extern crate regex_syntax as syntax; + +pub use re::{ + Regex, Error, Captures, SubCaptures, SubCapturesPos, SubCapturesNamed, + FindCaptures, FindMatches, + Replacer, NoExpand, RegexSplits, RegexSplitsN, + quote, is_match, +}; + +mod backtrack; +mod char; +mod compile; +mod input; +mod pool; +mod prefix; +mod program; +mod nfa; +mod re; + +/// The `internal` module exists to support the `regex!` macro and other +/// suspicious activity, such as testing different matching engines. +#[doc(hidden)] +pub mod internal { + pub use char::Char; + pub use input::{Input, CharInput, InputAt}; + pub use program::{ + Program, MatchEngine, CharRanges, Inst, LookInst, OneChar, + }; + pub use re::ExNative; + pub use re::Regex::{Dynamic, Native}; +} diff --git a/deps/regex-0.1.38/src/nfa.rs b/deps/regex-0.1.38/src/nfa.rs new file mode 100644 index 000000000..408a150ae --- /dev/null +++ b/deps/regex-0.1.38/src/nfa.rs @@ -0,0 +1,300 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// FIXME: Currently, the VM simulates an NFA. It would be nice to have another +// VM that simulates a DFA. +// +// According to Russ Cox[1], a DFA performs better than an NFA, principally +// because it reuses states previously computed by the machine *and* doesn't +// keep track of capture groups. The drawback of a DFA (aside from its +// complexity) is that it can't accurately return the locations of submatches. +// The NFA *can* do that. (This is my understanding anyway.) +// +// Cox suggests that a DFA ought to be used to answer "does this match" and +// "where does it match" questions. (In the latter, the starting position of +// the match is computed by executing the regex backwards.) Cox also suggests +// that a DFA should be run when asking "where are the submatches", which can +// 1) quickly answer "no" is there's no match and 2) discover the substring +// that matches, which means running the NFA on smaller input. +// +// Currently, the NFA simulation implemented below does some dirty tricks to +// avoid tracking capture groups when they aren't needed (which only works +// for 'is_match', not 'find'). This is a half-measure, but does provide some +// perf improvement. +// +// AFAIK, the DFA/NFA approach is implemented in RE2/C++ but *not* in RE2/Go. +// +// UPDATE: We now have a backtracking matching engine and a DFA for prefix +// matching. The prefix DFA is used in both the NFA simulation below and the +// backtracking engine to skip along the input quickly. +// +// [1] - http://swtch.com/~rsc/regex/regex3.html + +use input::{Input, InputAt, CharInput}; +use program::Program; +use re::CaptureIdxs; + +/// An NFA simulation matching engine. +#[derive(Debug)] +pub struct Nfa<'r, 't> { + prog: &'r Program, + input: CharInput<'t>, +} + +impl<'r, 't> Nfa<'r, 't> { + /// Execute the NFA matching engine. + /// + /// If there's a match, `exec` returns `true` and populates the given + /// captures accordingly. + pub fn exec( + prog: &'r Program, + mut caps: &mut CaptureIdxs, + text: &'t str, + start: usize, + ) -> bool { + let mut q = prog.nfa_threads.get(); + let input = CharInput::new(text); + let at = input.at(start); + let matched = Nfa { + prog: prog, + input: input, + }.exec_(&mut q, &mut caps, at); + prog.nfa_threads.put(q); + matched + } + + fn exec_( + &mut self, + mut q: &mut NfaThreads, + mut caps: &mut CaptureIdxs, + mut at: InputAt, + ) -> bool { + let mut matched = false; + q.clist.empty(); q.nlist.empty(); +'LOOP: loop { + if q.clist.size == 0 { + // Three ways to bail out when our current set of threads is + // empty. + // + // 1. We have a match---so we're done exploring any possible + // alternatives. Time to quit. + // + // 2. If the expression starts with a '^' we can terminate as + // soon as the last thread dies. + if matched + || (!at.is_beginning() && self.prog.anchored_begin) { + break; + } + + // 3. If there's a literal prefix for the program, try to + // jump ahead quickly. If it can't be found, then we can + // bail out early. + if !self.prog.prefixes.is_empty() { + at = match self.input.prefix_at(&self.prog.prefixes, at) { + None => break, + Some(at) => at, + }; + } + } + + // This simulates a preceding '.*?' for every regex by adding + // a state starting at the current position in the input for the + // beginning of the program only if we don't already have a match. + if q.clist.size == 0 || (!self.prog.anchored_begin && !matched) { + self.add(&mut q.clist, &mut caps, 0, at) + } + // The previous call to "add" actually inspects the position just + // before the current character. For stepping through the machine, + // we can to look at the current character, so we advance the + // input. + let at_next = self.input.at(at.next_pos()); + for i in 0..q.clist.size { + let pc = q.clist.pc(i); + let tcaps = q.clist.caps(i); + if self.step(&mut q.nlist, caps, tcaps, pc, at, at_next) { + matched = true; + if caps.len() == 0 { + // If we only care if a match occurs (not its + // position), then we can quit right now. + break 'LOOP; + } + // We don't need to check the rest of the threads in this + // set because we've matched something ("leftmost-first"). + // However, we still need to check threads in the next set + // to support things like greedy matching. + break; + } + } + if at.char().is_none() { + break; + } + at = at_next; + q.swap(); + q.nlist.empty(); + } + matched + } + + fn step( + &self, + nlist: &mut Threads, + caps: &mut [Option], + thread_caps: &mut [Option], + pc: usize, + at: InputAt, + at_next: InputAt, + ) -> bool { + use program::Inst::*; + match self.prog.insts[pc] { + Match => { + for (slot, val) in caps.iter_mut().zip(thread_caps.iter()) { + *slot = *val; + } + true + } + Char(ref inst) => { + if inst.matches(at.char()) { + self.add(nlist, thread_caps, pc+1, at_next); + } + false + } + Ranges(ref inst) => { + if inst.matches(at.char()).is_some() { + self.add(nlist, thread_caps, pc+1, at_next); + } + false + } + EmptyLook(_) | Save(_) | Jump(_) | Split(_, _) => false, + } + } + + fn add( + &self, + nlist: &mut Threads, + thread_caps: &mut [Option], + pc: usize, + at: InputAt, + ) { + use program::Inst::*; + + if nlist.contains(pc) { + return + } + let ti = nlist.add(pc); + match self.prog.insts[pc] { + EmptyLook(ref inst) => { + let prev = self.input.previous_at(at.pos()); + if inst.matches(prev.char(), at.char()) { + self.add(nlist, thread_caps, pc+1, at); + } + } + Save(slot) => { + if slot >= thread_caps.len() { + self.add(nlist, thread_caps, pc+1, at); + } else { + let old = thread_caps[slot]; + thread_caps[slot] = Some(at.pos()); + self.add(nlist, thread_caps, pc+1, at); + thread_caps[slot] = old; + } + } + Jump(to) => { + self.add(nlist, thread_caps, to, at) + } + Split(x, y) => { + self.add(nlist, thread_caps, x, at); + self.add(nlist, thread_caps, y, at); + } + Match | Char(_) | Ranges(_) => { + let mut t = &mut nlist.thread(ti); + for (slot, val) in t.caps.iter_mut().zip(thread_caps.iter()) { + *slot = *val; + } + } + } + } +} + +/// Shared cached state between multiple invocations of a NFA engine +/// in the same thread. +/// +/// It is exported so that it can be cached by `program::Program`. +#[derive(Debug)] +pub struct NfaThreads { + clist: Threads, + nlist: Threads, +} + +#[derive(Debug)] +struct Threads { + dense: Vec, + sparse: Vec, + size: usize, +} + +#[derive(Clone, Debug)] +struct Thread { + pc: usize, + caps: Vec>, +} + +impl NfaThreads { + /// Create new empty state for the NFA engine. + pub fn new(num_insts: usize, ncaps: usize) -> NfaThreads { + NfaThreads { + clist: Threads::new(num_insts, ncaps), + nlist: Threads::new(num_insts, ncaps), + } + } + + fn swap(&mut self) { + ::std::mem::swap(&mut self.clist, &mut self.nlist); + } +} + +impl Threads { + fn new(num_insts: usize, ncaps: usize) -> Threads { + let t = Thread { pc: 0, caps: vec![None; ncaps * 2] }; + Threads { + dense: vec![t; num_insts], + sparse: vec![0; num_insts], + size: 0, + } + } + + fn add(&mut self, pc: usize) -> usize { + let i = self.size; + self.dense[i].pc = pc; + self.sparse[pc] = i; + self.size += 1; + i + } + + fn thread(&mut self, i: usize) -> &mut Thread { + &mut self.dense[i] + } + + fn contains(&self, pc: usize) -> bool { + let s = self.sparse[pc]; + s < self.size && self.dense[s].pc == pc + } + + fn empty(&mut self) { + self.size = 0; + } + + fn pc(&self, i: usize) -> usize { + self.dense[i].pc + } + + fn caps(&mut self, i: usize) -> &mut [Option] { + &mut self.dense[i].caps + } +} diff --git a/deps/regex-0.1.38/src/pool.rs b/deps/regex-0.1.38/src/pool.rs new file mode 100644 index 000000000..cb29fb034 --- /dev/null +++ b/deps/regex-0.1.38/src/pool.rs @@ -0,0 +1,93 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cell::RefCell; +use std::fmt; +use std::sync::Mutex; + +/// A very simple memory pool for managing cached state. +/// +/// This was motivated by a singular purpose: reduce the allocation overhead +/// of matching engines. +/// +/// With a pool, the matching engines need to allocate state each time they +/// are invoked. If a regex is used once to check for a match and never again, +/// then this is OK. But if a regex is used many times over, then not +/// re-allocating the engine's state is a huge win. (A regex is commonly +/// used many times, for example, with `find_iter`, `captures_iter` or +/// `replace_all`.) +/// +/// We use inherited mutability and ensure that each thread gets its own +/// state. There is no limit on the number of states that are created. If a +/// thread requests one and one isn't available, a new one is created. +/// +/// (N.B. It seems like there exists a way to implement this with stronger +/// guarantees, e.g., with a guard of some sort that puts the resource back +/// in the pool when it is dropped. However, the use case for this pool is so +/// simple and localized that it doesn't seem worth it.) +pub struct Pool { + stack: Mutex>>, + create: CreateFn, +} + +/// The type of the function used to create resources if none exist. +pub type CreateFn = Box T + Send + Sync>; + +impl Pool { + /// Create a new pool. + /// + /// When a caller requests a resource from the pool and one does not + /// exist, then `create` is called to allocate a new resource for the + /// caller. + /// + /// It is up to the caller to put the resource back into the pool for + /// future reuse. + /// + /// All resources are created lazily/on-demand. + pub fn new(create: CreateFn) -> Pool { + Pool { + stack: Mutex::new(RefCell::new(vec![])), + create: create, + } + } + + /// Request a resource from the pool. + /// + /// If no resources are available, a new one is created. + /// + /// The caller must return the resource to the pool, otherwise the pool + /// will not be able to reuse the resource. + pub fn get(&self) -> T { + let stack = self.stack.lock(); + let stack = stack.unwrap(); + let mut stack = stack.borrow_mut(); + match stack.pop() { + None => (self.create)(), + Some(v) => v, + } + } + + /// Add a resource to the pool. + /// + /// This makes the resource available for use with `get`. + pub fn put(&self, v: T) { + let stack = self.stack.lock(); + let stack = stack.unwrap(); + stack.borrow_mut().push(v); + } +} + +impl fmt::Debug for Pool { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let stack = self.stack.lock(); + let stack = stack.unwrap(); + stack.fmt(f) + } +} diff --git a/deps/regex-0.1.38/src/prefix.rs b/deps/regex-0.1.38/src/prefix.rs new file mode 100644 index 000000000..c19a74e55 --- /dev/null +++ b/deps/regex-0.1.38/src/prefix.rs @@ -0,0 +1,157 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt; + +use aho_corasick::{Automaton, AcAutomaton, FullAcAutomaton}; +use memchr::memchr; + +/// A prefix extracted from a compiled regular expression. +/// +/// A regex prefix is a set of literal strings that *must* be matched at the +/// beginning of a regex in order for the entire regex to match. +/// +/// There are a variety of ways to efficiently scan the search text for a +/// prefix. Currently, there are three implemented: +/// +/// 1. The prefix is a single byte. Just use memchr. +/// 2. If the prefix is a set of two or more single byte prefixes, then +/// a single sparse map is created. Checking if there is a match is a lookup +/// in this map for each byte in the search text. +/// 3. In all other cases, build an Aho-Corasick automaton. +/// +/// It's possible that there's room here for other substring algorithms, +/// such as Boyer-Moore for single-set prefixes greater than 1, or Rabin-Karp +/// for small sets of same-length prefixes. +#[derive(Clone)] +pub enum Prefix { + /// No prefixes. (Never advances through the input.) + Empty, + /// A single byte prefix. + Single(u8), + /// A set of two or more single byte prefixes. + /// This could be reduced to a bitset, which would use only 8 bytes, + /// but I don't think we care. + Singles { + chars: Vec, + sparse: Vec, + }, + /// A full Aho-Corasick DFA automaton. + Automaton(FullAcAutomaton), +} + +impl Prefix { + /// Create a new prefix matching machine. + pub fn new(pfxs: Vec) -> Prefix { + if pfxs.len() == 0 || pfxs[0].len() == 0 { + Prefix::Empty + } else if pfxs.len() == 1 && pfxs[0].len() == 1 { + Prefix::Single(pfxs[0].as_bytes()[0]) + } else if pfxs.len() >= 2 && pfxs.iter().all(|s| s.len() == 1) { + let mut set = vec![false; 256]; + let mut chars = vec![]; + for p in pfxs { + chars.push(p.as_bytes()[0]); + set[p.as_bytes()[0] as usize] = true; + } + Prefix::Singles { chars: chars, sparse: set } + } else { + Prefix::Automaton(AcAutomaton::new(pfxs).into_full()) + } + } + + /// Find the position of a prefix in `haystack` if it exists. + /// + /// In the matching engines, we only actually need the starting index + /// because the prefix is used to only skip ahead---the matching engine + /// still needs to run over the prefix input. However, we return the ending + /// location as well in case the prefix corresponds to the entire regex, + /// in which case, you need the end of the match. + pub fn find(&self, haystack: &str) -> Option<(usize, usize)> { + use self::Prefix::*; + match *self { + Empty => Some((0, 0)), + Single(b) => memchr(b, haystack.as_bytes()).map(|i| (i, i+1)), + Singles { ref sparse, .. } => { + find_singles(sparse, haystack.as_bytes()) + } + Automaton(ref aut) => { + aut.find(haystack).next().map(|m| (m.start, m.end)) + } + } + } + + /// Returns true iff this prefix is empty. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns the number of prefixes in this machine. + pub fn len(&self) -> usize { + match *self { + Prefix::Empty => 0, + Prefix::Single(_) => 1, + Prefix::Singles { ref chars, .. } => chars.len(), + Prefix::Automaton(ref aut) => aut.len(), + } + } + + /// Returns true iff the prefix match preserves priority. + /// + /// For example, given the alternation `ab|a` and the target string `ab`, + /// does the prefix machine guarantee that `ab` will match? (A full + /// Aho-Corasick automaton does not!) + pub fn preserves_priority(&self) -> bool { + match *self { + Prefix::Empty => true, + Prefix::Single(_) => true, + Prefix::Singles{..} => true, + Prefix::Automaton(ref aut) => { + // Okay, so the automaton can respect priority in one + // particular case: when every pattern is of the same length. + // The trick is that the automaton will report the leftmost + // match, which in this case, corresponds to the correct + // match for the regex engine. If any other alternate matches + // at the same position, then they must be exactly equivalent. + + // Guaranteed at least one prefix by construction, so use + // that for the length. + aut.patterns().iter().all(|p| p.len() == aut.pattern(0).len()) + } + } + } +} + +/// A very quick scan for multiple single byte prefixes using a sparse map. +fn find_singles(sparse: &[bool], haystack: &[u8]) -> Option<(usize, usize)> { + for (hi, &b) in haystack.iter().enumerate() { + if sparse[b as usize] { + return Some((hi, hi+1)); + } + } + None +} + +impl fmt::Debug for Prefix { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Prefix::Empty => write!(f, "Empty"), + Prefix::Single(b) => write!(f, "{:?}", b as char), + Prefix::Singles { ref chars, .. } => { + let chars: Vec = + chars.iter() + .map(|&c| format!("{:?}", c as char)) + .collect(); + write!(f, "{}", chars.connect(", ")) + } + Prefix::Automaton(ref aut) => write!(f, "{:?}", aut), + } + } +} diff --git a/deps/regex-0.1.38/src/program.rs b/deps/regex-0.1.38/src/program.rs new file mode 100644 index 000000000..a4043b52e --- /dev/null +++ b/deps/regex-0.1.38/src/program.rs @@ -0,0 +1,480 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cmp::{self, Ordering}; + +use syntax; + +use Error; +use backtrack::{Backtrack, BackMachine}; +use char::Char; +use compile::Compiler; +use nfa::{Nfa, NfaThreads}; +use pool::Pool; +use prefix::Prefix; +use re::CaptureIdxs; + +const NUM_PREFIX_LIMIT: usize = 30; +const PREFIX_LENGTH_LIMIT: usize = 15; + +pub type InstIdx = usize; + +/// An instruction, the underlying unit of a compiled regular expression +#[derive(Clone, Debug)] +pub enum Inst { + /// A match has occurred. + /// This is always the last instruction and only occurs in a single spot. + /// We could special case this in the code, but it is much clearer to + /// handle it as a proper instruction. + Match, + /// Save the current location in the input into the given capture location. + Save(usize), + /// Jump to the instruction given. + Jump(InstIdx), + /// Match either instruction, preferring the first. + Split(InstIdx, InstIdx), + /// A zero-width instruction. When this instruction matches, the input + /// is not advanced. + EmptyLook(LookInst), + /// Match a single possibly case insensitive character. + Char(OneChar), + /// Match one or more possibly case insensitive character ranges. + Ranges(CharRanges), +} + +/// A single character instruction. +#[derive(Clone, Debug)] +pub struct OneChar { + /// The character. + pub c: char, + /// True if the character should be matched case insensitively. + /// (i.e., The input character will need to be case folded.) + pub casei: bool, +} + +/// A multi-range character class instruction. +#[derive(Clone, Debug)] +pub struct CharRanges { + /// Sorted sequence of non-overlapping ranges. + pub ranges: Vec<(char, char)>, + /// Whether to match case insensitively. + pub casei: bool, +} + +/// The set of zero-width match instructions. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum LookInst { + /// Start of line or input. + StartLine, + /// End of line or input. + EndLine, + /// Start of input. + StartText, + /// End of input. + EndText, + /// Word character on one side and non-word character on other. + WordBoundary, + /// Word character on both sides or non-word character on both sides. + NotWordBoundary, +} + +impl OneChar { + /// Tests whether the given input character matches this instruction. + #[inline(always)] // About ~5-15% more throughput then `#[inline]` + pub fn matches(&self, c: Char) -> bool { + self.c == c || (self.casei && self.c == c.case_fold()) + } +} + +impl CharRanges { + /// Emits a range specifically for the `.` expression. + pub fn any() -> CharRanges { + CharRanges { + ranges: vec![('\x00', '\u{10ffff}')], + casei: false, + } + } + + /// Emits a range specifically for the `(?s).` expression. + pub fn any_nonl() -> CharRanges { + CharRanges { + ranges: vec![('\x00', '\x09'), ('\x0B', '\u{10ffff}')], + casei: false, + } + } + + /// Emits a range from the AST character class. + pub fn from_class(cls: syntax::CharClass) -> CharRanges { + let casei = cls.is_case_insensitive(); + CharRanges { + ranges: cls.into_iter().map(|r| (r.start, r.end)).collect(), + casei: casei, + } + } + + /// Tests whether the given input character matches this instruction. + #[inline(always)] // About ~5-15% more throughput then `#[inline]` + pub fn matches(&self, mut c: Char) -> Option { + if self.casei { + c = c.case_fold(); + } + // This speeds up the `match_class_unicode` benchmark by checking + // some common cases quickly without binary search. e.g., Matching + // a Unicode class on predominantly ASCII text. + for i in 0..cmp::min(self.ranges.len(), 4) { + let r = self.ranges[i]; + if c < r.0 { + return None; + } + if c <= r.1 { + return Some(i); + } + } + self.ranges.binary_search_by(|r| { + if r.1 < c { + Ordering::Less + } else if r.0 > c { + Ordering::Greater + } else { + Ordering::Equal + } + }).ok() + } +} + +impl LookInst { + /// Tests whether the pair of characters matches this zero-width + /// instruction. + pub fn matches(&self, c1: Char, c2: Char) -> bool { + use self::LookInst::*; + match *self { + StartLine => c1.is_none() || c1 == '\n', + EndLine => c2.is_none() || c2 == '\n', + StartText => c1.is_none(), + EndText => c2.is_none(), + ref wbty => { + let (w1, w2) = (c1.is_word_char(), c2.is_word_char()); + (*wbty == WordBoundary && w1 ^ w2) + || (*wbty == NotWordBoundary && !(w1 ^ w2)) + } + } + } +} + +/// The matching engines offered by this regex implementation. +/// +/// N.B. This is exported for use in testing. +#[doc(hidden)] +#[derive(Clone, Copy, Debug)] +pub enum MatchEngine { + /// A bounded backtracking implementation. About twice as fast as the + /// NFA, but can only work on small regexes and small input. + Backtrack, + /// A full NFA simulation. Can always be employed but almost always the + /// slowest choice. + Nfa, + /// If the entire regex is a literal and no capture groups have been + /// requested, then we can degrade to a simple substring match. + Literals, +} + +/// Program represents a compiled regular expression. Once an expression is +/// compiled, its representation is immutable and will never change. +/// (Well, almost. In fact, the matching engines cache state that can be +/// reused on subsequent searches. But this is interior mutability that +/// shouldn't be observable by the caller.) +#[derive(Debug)] +pub struct Program { + /// The original regular expression string. + pub original: String, + /// A sequence of instructions. + pub insts: Vec, + /// The sequence of capture group names. There is an entry for each capture + /// group index and a name exists only if the capture group is named. + pub cap_names: Vec>, + /// If the regular expression requires a literal prefix in order to have a + /// match, that prefix is stored here as a DFA. + pub prefixes: Prefix, + /// True iff matching any literal prefix indicates a match. + pub prefixes_complete: bool, + /// True iff program is anchored at the beginning. + pub anchored_begin: bool, + /// True iff program is anchored at the end. + pub anchored_end: bool, + /// The type of matching engine to use. + /// When `None` (the default), pick an engine automatically. + pub engine: Option, + /// Cached NFA threads. + pub nfa_threads: Pool, + /// Cached backtracking memory. + pub backtrack: Pool, +} + +impl Program { + /// Compiles a Regex. + pub fn new( + engine: Option, + size_limit: usize, + re: &str, + ) -> Result { + let expr = try!(syntax::Expr::parse(re)); + let (insts, cap_names) = try!(Compiler::new(size_limit).compile(expr)); + let (insts_len, ncaps) = (insts.len(), num_captures(&insts)); + let create_threads = move || NfaThreads::new(insts_len, ncaps); + let create_backtrack = move || BackMachine::new(); + let mut prog = Program { + original: re.into(), + insts: insts, + cap_names: cap_names, + prefixes: Prefix::Empty, + prefixes_complete: false, + anchored_begin: false, + anchored_end: false, + engine: engine, + nfa_threads: Pool::new(Box::new(create_threads)), + backtrack: Pool::new(Box::new(create_backtrack)), + }; + + prog.find_prefixes(); + prog.anchored_begin = match prog.insts[1] { + Inst::EmptyLook(LookInst::StartText) => true, + _ => false, + }; + prog.anchored_end = match prog.insts[prog.insts.len() - 3] { + Inst::EmptyLook(LookInst::EndText) => true, + _ => false, + }; + Ok(prog) + } + + /// Executes a compiled regex program. + pub fn exec( + &self, + caps: &mut CaptureIdxs, + text: &str, + start: usize, + ) -> bool { + match self.choose_engine(caps.len(), text) { + MatchEngine::Backtrack => Backtrack::exec(self, caps, text, start), + MatchEngine::Nfa => Nfa::exec(self, caps, text, start), + MatchEngine::Literals => { + match self.prefixes.find(&text[start..]) { + None => false, + Some((s, e)) => { + if caps.len() == 2 { + caps[0] = Some(start + s); + caps[1] = Some(start + e); + } + true + } + } + } + } + } + + fn choose_engine(&self, cap_len: usize, text: &str) -> MatchEngine { + // If the engine is already chosen, then we use it. + // But that might not be a good idea. e.g., What if `Literals` is + // chosen and it can't work? I guess we should probably check whether + // the chosen engine is appropriate or not. + self.engine.unwrap_or_else(|| { + if cap_len <= 2 + && self.prefixes.preserves_priority() + && self.prefixes_complete { + MatchEngine::Literals + } else if Backtrack::should_exec(self, text) { + // We're only here if the input and regex combined are small. + MatchEngine::Backtrack + } else { + MatchEngine::Nfa + } + }) + } + + /// Returns the total number of capture groups in the regular expression. + /// This includes the zeroth capture. + pub fn num_captures(&self) -> usize { + num_captures(&self.insts) + } + + /// Allocate new capture groups. + pub fn alloc_captures(&self) -> Vec> { + vec![None; 2 * self.num_captures()] + } + + /// Find and store a prefix machine for the current program. + pub fn find_prefixes(&mut self) { + use self::Inst::*; + + let (ps, complete) = self.prefixes_from_insts(1); + if ps.len() > 0 { + self.prefixes = Prefix::new(ps); + self.prefixes_complete = complete; + return; + } + let mut pc = 1; + let mut prefixes = vec![]; + let mut pcomplete = true; + while let Split(x, y) = self.insts[pc] { + let (xps, xcomplete) = self.prefixes_from_insts(x); + let (yps, ycomplete) = self.prefixes_from_insts(y); + let mut done = false; + match (&self.insts[x], &self.insts[y]) { + // We should be able to support this. Add explicit stack. ---AG + (&Split(_, _), &Split(_, _)) => return, + (_, &Split(_, _)) if xps.len() == 0 => return, + (_, &Split(_, _)) => { + pcomplete = pcomplete && xcomplete; + prefixes.extend(xps); + pc = y; + } + (&Split(_, _), _) if yps.len() == 0 => return, + (&Split(_, _), _) => { + pcomplete = pcomplete && ycomplete; + prefixes.extend(yps); + pc = x; + } + _ if xps.len() == 0 || yps.len() == 0 => return, + // This is our base case. We've followed splits the whole + // way, which means both instructions lead to a match. + _ => { + pcomplete = pcomplete && xcomplete && ycomplete; + prefixes.extend(xps); + prefixes.extend(yps); + done = true; + } + } + // Arg. We've over-extended ourselves, quit with nothing to + // show for it. + if prefixes.len() > NUM_PREFIX_LIMIT { + return; + } + if done { break; } + } + self.prefixes = Prefix::new(prefixes); + self.prefixes_complete = pcomplete && self.prefixes.len() > 0; + } + + /// Find a prefix starting at the given instruction. + /// + /// Returns `true` in the tuple if the end of the prefix leads trivially + /// to a match. (This may report false negatives, but being conservative + /// is OK.) + fn prefixes_from_insts(&self, mut pc: usize) -> (Vec, bool) { + use self::Inst::*; + + let mut complete = true; + let mut alts = vec![String::new()]; + while pc < self.insts.len() { + let inst = &self.insts[pc]; + + // Each iteration adds one character to every alternate prefix *or* + // it stops. Thus, the prefix alternates grow in lock step, and it + // suffices to check one of them to see if the prefix limit has been + // exceeded. + if alts[0].len() > PREFIX_LENGTH_LIMIT { + complete = false; + break; + } + match *inst { + Save(_) => { pc += 1; continue } // completely ignore it + Char(OneChar { c, casei: false }) => { + for alt in &mut alts { + alt.push(c); + } + pc += 1; + } + Ranges(CharRanges { ref ranges, casei: false }) => { + let nchars = num_chars_in_ranges(ranges); + if alts.len() * nchars > NUM_PREFIX_LIMIT { + complete = false; + break; + } + + let orig = alts; + alts = Vec::with_capacity(orig.len()); + for &(s, e) in ranges { + for c in (s as u32)..(e as u32 + 1){ + for alt in &orig { + let mut alt = alt.clone(); + alt.push(::std::char::from_u32(c).unwrap()); + alts.push(alt); + } + } + } + pc += 1; + } + Jump(pc2) => pc = pc2, + _ => { complete = self.leads_to_match(pc); break } + } + } + if alts[0].len() == 0 { + (vec![], false) + } else { + (alts, complete) + } + } + + fn leads_to_match(&self, mut pc: usize) -> bool { + // I'm pretty sure this is conservative, so it might have some + // false negatives. + loop { + match self.insts[pc] { + Inst::Match => return true, + Inst::Save(_) => pc += 1, + Inst::Jump(pc2) => pc = pc2, + _ => return false, + } + } + } +} + +impl Clone for Program { + fn clone(&self) -> Program { + let (insts_len, ncaps) = (self.insts.len(), self.num_captures()); + let create_threads = move || NfaThreads::new(insts_len, ncaps); + let create_backtrack = move || BackMachine::new(); + Program { + original: self.original.clone(), + insts: self.insts.clone(), + cap_names: self.cap_names.clone(), + prefixes: self.prefixes.clone(), + prefixes_complete: self.prefixes_complete, + anchored_begin: self.anchored_begin, + anchored_end: self.anchored_end, + engine: self.engine, + nfa_threads: Pool::new(Box::new(create_threads)), + backtrack: Pool::new(Box::new(create_backtrack)), + } + } +} + +/// Return the number of captures in the given sequence of instructions. +fn num_captures(insts: &[Inst]) -> usize { + let mut n = 0; + for inst in insts { + match *inst { + Inst::Save(c) => n = cmp::max(n, c+1), + _ => {} + } + } + // There's exactly 2 Save slots for every capture. + n / 2 +} + +/// Count the number of characters in the given range. +/// +/// This is useful for pre-emptively limiting the number of prefix literals +/// we extract from a regex program. +fn num_chars_in_ranges(ranges: &[(char, char)]) -> usize { + ranges.iter() + .map(|&(s, e)| (e as u32) - (s as u32)) + .fold(0, |acc, len| acc + len) as usize +} diff --git a/deps/regex-0.1.38/src/re.rs b/deps/regex-0.1.38/src/re.rs new file mode 100644 index 000000000..1367f486a --- /dev/null +++ b/deps/regex-0.1.38/src/re.rs @@ -0,0 +1,1148 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::borrow::Cow; +use std::collections::HashMap; +use std::collections::hash_map::Iter; +use std::fmt; +#[cfg(feature = "pattern")] +use std::str::pattern::{Pattern, Searcher, SearchStep}; +use std::str::FromStr; + +use program::{Program, MatchEngine}; +use syntax; + +const REPLACE_EXPAND: &'static str = r"(?x) + (?P^|\b|[^$]) # Ignore `$$name`. + \$ + (?P # Match the actual capture name. Can be... + [0-9]+ # A sequence of digits (for indexed captures), or... + | + [_a-zA-Z][_0-9a-zA-Z]* # A name for named captures. + ) +"; + +/// Type alias for representing capture indices. +pub type CaptureIdxs = [Option]; + +/// Escapes all regular expression meta characters in `text`. +/// +/// The string returned may be safely used as a literal in a regular +/// expression. +pub fn quote(text: &str) -> String { + let mut quoted = String::with_capacity(text.len()); + for c in text.chars() { + if syntax::is_punct(c) { + quoted.push('\\') + } + quoted.push(c); + } + quoted +} + +/// Tests if the given regular expression matches somewhere in the text given. +/// +/// If there was a problem compiling the regular expression, an error is +/// returned. +/// +/// To find submatches, split or replace text, you'll need to compile an +/// expression first. +pub fn is_match(regex: &str, text: &str) -> Result { + Regex::new(regex).map(|r| r.is_match(text)) +} + +/// An error that occurred during parsing or compiling a regular expression. +#[derive(Debug)] +pub enum Error { + /// A syntax error. + Syntax(syntax::Error), + /// The compiled program exceeded the set size limit. + /// The argument is the size limit imposed. + CompiledTooBig(usize), + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl ::std::error::Error for Error { + fn description(&self) -> &str { + match *self { + Error::Syntax(ref err) => err.description(), + Error::CompiledTooBig(_) => "compiled program too big", + Error::__Nonexhaustive => unreachable!(), + } + } + + fn cause(&self) -> Option<&::std::error::Error> { + match *self { + Error::Syntax(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Syntax(ref err) => err.fmt(f), + Error::CompiledTooBig(limit) => { + write!(f, "Compiled regex exceeds size limit of {} bytes.", + limit) + } + Error::__Nonexhaustive => unreachable!(), + } + } +} + +impl From for Error { + fn from(err: syntax::Error) -> Error { + Error::Syntax(err) + } +} + +/// A compiled regular expression +/// +/// It is represented as either a sequence of bytecode instructions (dynamic) +/// or as a specialized Rust function (native). It can be used to search, split +/// or replace text. All searching is done with an implicit `.*?` at the +/// beginning and end of an expression. To force an expression to match the +/// whole string (or a prefix or a suffix), you must use an anchor like `^` or +/// `$` (or `\A` and `\z`). +/// +/// While this crate will handle Unicode strings (whether in the regular +/// expression or in the search text), all positions returned are **byte +/// indices**. Every byte index is guaranteed to be at a Unicode code point +/// boundary. +/// +/// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a +/// compiled regular expression and text to search, respectively. +/// +/// The only methods that allocate new strings are the string replacement +/// methods. All other methods (searching and splitting) return borrowed +/// pointers into the string given. +/// +/// # Examples +/// +/// Find the location of a US phone number: +/// +/// ```rust +/// # use regex::Regex; +/// let re = Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}").unwrap(); +/// assert_eq!(re.find("phone: 111-222-3333"), Some((7, 19))); +/// ``` +/// +/// # Using the `std::str::StrExt` methods with `Regex` +/// +/// > **Note**: This section requires that this crate is currently compiled with +/// > the `pattern` Cargo feature enabled. +/// +/// Since `Regex` implements `Pattern`, you can use regexes with methods +/// defined on `std::str::StrExt`. For example, `is_match`, `find`, `find_iter` +/// and `split` can be replaced with `StrExt::contains`, `StrExt::find`, +/// `StrExt::match_indices` and `StrExt::split`. +/// +/// Here are some examples: +/// +/// ```rust,ignore +/// # use regex::Regex; +/// let re = Regex::new(r"\d+").unwrap(); +/// let haystack = "a111b222c"; +/// +/// assert!(haystack.contains(&re)); +/// assert_eq!(haystack.find(&re), Some(1)); +/// assert_eq!(haystack.match_indices(&re).collect::>(), +/// vec![(1, 4), (5, 8)]); +/// assert_eq!(haystack.split(&re).collect::>(), vec!["a", "b", "c"]); +/// ``` +#[derive(Clone)] +pub enum Regex { + // The representation of `Regex` is exported to support the `regex!` + // syntax extension. Do not rely on it. + // + // See the comments for the `program` module in `lib.rs` for a more + // detailed explanation for what `regex!` requires. + #[doc(hidden)] + Dynamic(Program), + #[doc(hidden)] + Native(ExNative), +} + +#[doc(hidden)] +pub struct ExNative { + #[doc(hidden)] + pub original: &'static str, + #[doc(hidden)] + pub names: &'static &'static [Option<&'static str>], + #[doc(hidden)] + pub prog: fn(&mut CaptureIdxs, &str, usize) -> bool, +} + +impl Copy for ExNative {} + +impl Clone for ExNative { + fn clone(&self) -> ExNative { + *self + } +} + +impl fmt::Display for Regex { + /// Shows the original regular expression. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +impl fmt::Debug for Regex { + /// Shows the original regular expression. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/// Equality comparison is based on the original string. It is possible that +/// different regular expressions have the same matching behavior, but are +/// still compared unequal. For example, `\d+` and `\d\d*` match the same set +/// of strings, but are not considered equal. +impl PartialEq for Regex { + fn eq(&self, other: &Regex) -> bool { + self.as_str() == other.as_str() + } +} + +impl Eq for Regex {} + +impl FromStr for Regex { + type Err = Error; + + /// Attempts to parse a string into a regular expression + fn from_str(s: &str) -> Result { + Regex::new(s) + } +} + +impl Regex { + /// Compiles a dynamic regular expression. Once compiled, it can be + /// used repeatedly to search, split or replace text in a string. + /// + /// If an invalid expression is given, then an error is returned. + pub fn new(re: &str) -> Result { + Regex::with_size_limit(10 * (1 << 20), re) + } + + /// Compiles a dynamic regular expression with the given size limit. + /// + /// The size limit is applied to the size of the *compiled* data structure. + /// If the data structure exceeds the size given, then an error is + /// returned. + /// + /// The default size limit used in `new` is 10MB. + pub fn with_size_limit(size: usize, re: &str) -> Result { + Regex::with_engine(None, size, re) + } + + /// Compiles a dynamic regular expression and uses given matching engine. + /// + /// This is exposed for use in testing and shouldn't be used by clients. + /// Instead, the regex program should choose the correct matching engine + /// to use automatically. (Based on the regex, the size of the input and + /// the type of search.) + /// + /// A value of `None` means that the engine is automatically selected, + /// which is the default behavior. + /// + /// **WARNING**: Passing an unsuitable engine for the given regex/input + /// could lead to bad things. (Not unsafe things, but panics, incorrect + /// matches and large memory use are all things that could happen.) + #[doc(hidden)] + pub fn with_engine( + engine: Option, + size: usize, + re: &str, + ) -> Result { + Program::new(engine, size, re).map(Regex::Dynamic) + } + + + /// Returns true if and only if the regex matches the string given. + /// + /// # Example + /// + /// Test if some text contains at least one word with exactly 13 + /// characters: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "I categorically deny having triskaidekaphobia."; + /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text)); + /// # } + /// ``` + pub fn is_match(&self, text: &str) -> bool { + exec(self, &mut [], text, 0) + } + + /// Returns the start and end byte range of the leftmost-first match in + /// `text`. If no match exists, then `None` is returned. + /// + /// Note that this should only be used if you want to discover the position + /// of the match. Testing the existence of a match is faster if you use + /// `is_match`. + /// + /// # Example + /// + /// Find the start and end location of the first word with exactly 13 + /// characters: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "I categorically deny having triskaidekaphobia."; + /// let pos = Regex::new(r"\b\w{13}\b").unwrap().find(text); + /// assert_eq!(pos, Some((2, 15))); + /// # } + /// ``` + pub fn find(&self, text: &str) -> Option<(usize, usize)> { + let mut caps = [None, None]; + if exec(self, &mut caps, text, 0) { + Some((caps[0].unwrap(), caps[1].unwrap())) + } else { + None + } + } + + /// Returns an iterator for each successive non-overlapping match in + /// `text`, returning the start and end byte indices with respect to + /// `text`. + /// + /// # Example + /// + /// Find the start and end location of every word with exactly 13 + /// characters: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "Retroactively relinquishing remunerations is reprehensible."; + /// for pos in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) { + /// println!("{:?}", pos); + /// } + /// // Output: + /// // (0, 13) + /// // (14, 27) + /// // (28, 41) + /// // (45, 58) + /// # } + /// ``` + pub fn find_iter<'r, 't>(&'r self, text: &'t str) -> FindMatches<'r, 't> { + FindMatches { + re: self, + search: text, + last_end: 0, + last_match: None, + } + } + + /// Returns the capture groups corresponding to the leftmost-first + /// match in `text`. Capture group `0` always corresponds to the entire + /// match. If no match is found, then `None` is returned. + /// + /// You should only use `captures` if you need access to submatches. + /// Otherwise, `find` is faster for discovering the location of the overall + /// match. + /// + /// # Examples + /// + /// Say you have some text with movie names and their release years, + /// like "'Citizen Kane' (1941)". It'd be nice if we could search for text + /// looking like that, while also extracting the movie name and its release + /// year separately. + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap(); + /// let text = "Not my favorite movie: 'Citizen Kane' (1941)."; + /// let caps = re.captures(text).unwrap(); + /// assert_eq!(caps.at(1), Some("Citizen Kane")); + /// assert_eq!(caps.at(2), Some("1941")); + /// assert_eq!(caps.at(0), Some("'Citizen Kane' (1941)")); + /// # } + /// ``` + /// + /// Note that the full match is at capture group `0`. Each subsequent + /// capture group is indexed by the order of its opening `(`. + /// + /// We can make this example a bit clearer by using *named* capture groups: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"'(?P[^']+)'\s+\((?P<year>\d{4})\)") + /// .unwrap(); + /// let text = "Not my favorite movie: 'Citizen Kane' (1941)."; + /// let caps = re.captures(text).unwrap(); + /// assert_eq!(caps.name("title"), Some("Citizen Kane")); + /// assert_eq!(caps.name("year"), Some("1941")); + /// assert_eq!(caps.at(0), Some("'Citizen Kane' (1941)")); + /// # } + /// ``` + /// + /// Here we name the capture groups, which we can access with the `name` + /// method. Note that the named capture groups are still accessible with + /// `at`. + /// + /// The `0`th capture group is always unnamed, so it must always be + /// accessed with `at(0)`. + pub fn captures<'t>(&self, text: &'t str) -> Option<Captures<'t>> { + let mut caps = self.alloc_captures(); + if exec(self, &mut caps, text, 0) { + Some(Captures::new(self, text, caps)) + } else { + None + } + } + + /// Returns an iterator over all the non-overlapping capture groups matched + /// in `text`. This is operationally the same as `find_iter` (except it + /// yields information about submatches). + /// + /// # Example + /// + /// We can use this to find all movie titles and their release years in + /// some text, where the movie is formatted like "'Title' (xxxx)": + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)") + /// .unwrap(); + /// let text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."; + /// for caps in re.captures_iter(text) { + /// println!("Movie: {:?}, Released: {:?}", caps.name("title"), caps.name("year")); + /// } + /// // Output: + /// // Movie: Citizen Kane, Released: 1941 + /// // Movie: The Wizard of Oz, Released: 1939 + /// // Movie: M, Released: 1931 + /// # } + /// ``` + pub fn captures_iter<'r, 't>(&'r self, text: &'t str) + -> FindCaptures<'r, 't> { + FindCaptures { + re: self, + search: text, + last_match: None, + last_end: 0, + } + } + + /// Returns an iterator of substrings of `text` delimited by a match + /// of the regular expression. + /// Namely, each element of the iterator corresponds to text that *isn't* + /// matched by the regular expression. + /// + /// This method will *not* copy the text given. + /// + /// # Example + /// + /// To split a string delimited by arbitrary amounts of spaces or tabs: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"[ \t]+").unwrap(); + /// let fields: Vec<&str> = re.split("a b \t c\td e").collect(); + /// assert_eq!(fields, vec!("a", "b", "c", "d", "e")); + /// # } + /// ``` + pub fn split<'r, 't>(&'r self, text: &'t str) -> RegexSplits<'r, 't> { + RegexSplits { + finder: self.find_iter(text), + last: 0, + } + } + + /// Returns an iterator of at most `limit` substrings of `text` delimited + /// by a match of the regular expression. (A `limit` of `0` will return no + /// substrings.) + /// Namely, each element of the iterator corresponds to text that *isn't* + /// matched by the regular expression. + /// The remainder of the string that is not split will be the last element + /// in the iterator. + /// + /// This method will *not* copy the text given. + /// + /// # Example + /// + /// Get the first two words in some text: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"\W+").unwrap(); + /// let fields: Vec<&str> = re.splitn("Hey! How are you?", 3).collect(); + /// assert_eq!(fields, vec!("Hey", "How", "are you?")); + /// # } + /// ``` + pub fn splitn<'r, 't>(&'r self, text: &'t str, limit: usize) + -> RegexSplitsN<'r, 't> { + RegexSplitsN { + splits: self.split(text), + cur: 0, + limit: limit, + } + } + + /// Replaces the leftmost-first match with the replacement provided. + /// The replacement can be a regular string (where `$N` and `$name` are + /// expanded to match capture groups) or a function that takes the matches' + /// `Captures` and returns the replaced string. + /// + /// If no match is found, then a copy of the string is returned unchanged. + /// + /// # Examples + /// + /// Note that this function is polymorphic with respect to the replacement. + /// In typical usage, this can just be a normal string: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new("[^01]+").unwrap(); + /// assert_eq!(re.replace("1078910", ""), "1010"); + /// # } + /// ``` + /// + /// But anything satisfying the `Replacer` trait will work. For example, + /// a closure of type `|&Captures| -> String` provides direct access to the + /// captures corresponding to a match. This allows one to access + /// submatches easily: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # use regex::Captures; fn main() { + /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap(); + /// let result = re.replace("Springsteen, Bruce", |caps: &Captures| { + /// format!("{} {}", caps.at(2).unwrap_or(""), caps.at(1).unwrap_or("")) + /// }); + /// assert_eq!(result, "Bruce Springsteen"); + /// # } + /// ``` + /// + /// But this is a bit cumbersome to use all the time. Instead, a simple + /// syntax is supported that expands `$name` into the corresponding capture + /// group. Here's the last example, but using this expansion technique + /// with named capture groups: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap(); + /// let result = re.replace("Springsteen, Bruce", "$first $last"); + /// assert_eq!(result, "Bruce Springsteen"); + /// # } + /// ``` + /// + /// Note that using `$2` instead of `$first` or `$1` instead of `$last` + /// would produce the same result. To write a literal `$` use `$$`. + /// + /// Finally, sometimes you just want to replace a literal string with no + /// submatch expansion. This can be done by wrapping a string with + /// `NoExpand`: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// use regex::NoExpand; + /// + /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(\S+)").unwrap(); + /// let result = re.replace("Springsteen, Bruce", NoExpand("$2 $last")); + /// assert_eq!(result, "$2 $last"); + /// # } + /// ``` + pub fn replace<R: Replacer>(&self, text: &str, rep: R) -> String { + self.replacen(text, 1, rep) + } + + /// Replaces all non-overlapping matches in `text` with the + /// replacement provided. This is the same as calling `replacen` with + /// `limit` set to `0`. + /// + /// See the documentation for `replace` for details on how to access + /// submatches in the replacement string. + pub fn replace_all<R: Replacer>(&self, text: &str, rep: R) -> String { + self.replacen(text, 0, rep) + } + + /// Replaces at most `limit` non-overlapping matches in `text` with the + /// replacement provided. If `limit` is 0, then all non-overlapping matches + /// are replaced. + /// + /// See the documentation for `replace` for details on how to access + /// submatches in the replacement string. + pub fn replacen<R: Replacer> + (&self, text: &str, limit: usize, mut rep: R) -> String { + let mut new = String::with_capacity(text.len()); + let mut last_match = 0; + + if rep.no_expand().is_some() { + // borrow checker pains. `rep` is borrowed mutably in the `else` + // branch below. + let rep = rep.no_expand().unwrap(); + for (i, (s, e)) in self.find_iter(text).enumerate() { + if limit > 0 && i >= limit { + break + } + new.push_str(&text[last_match..s]); + new.push_str(&rep); + last_match = e; + } + } else { + for (i, cap) in self.captures_iter(text).enumerate() { + if limit > 0 && i >= limit { + break + } + // unwrap on 0 is OK because captures only reports matches + let (s, e) = cap.pos(0).unwrap(); + new.push_str(&text[last_match..s]); + new.push_str(&rep.reg_replace(&cap)); + last_match = e; + } + } + new.push_str(&text[last_match..]); + new + } + + /// Returns the original string of this regex. + pub fn as_str<'a>(&'a self) -> &'a str { + match *self { + Regex::Dynamic(Program { ref original, .. }) => original, + Regex::Native(ExNative { ref original, .. }) => original, + } + } + + #[doc(hidden)] + pub fn names_iter<'a>(&'a self) -> NamesIter<'a> { + match *self { + Regex::Native(ref n) => NamesIter::Native(n.names.iter()), + Regex::Dynamic(ref d) => NamesIter::Dynamic(d.cap_names.iter()) + } + } + + fn names_len(&self) -> usize { + match *self { + Regex::Native(ref n) => n.names.len(), + Regex::Dynamic(ref d) => d.cap_names.len() + } + } + + fn alloc_captures(&self) -> Vec<Option<usize>> { + match *self { + Regex::Native(ref n) => vec![None; 2 * n.names.len()], + Regex::Dynamic(ref d) => d.alloc_captures(), + } + } +} + +pub enum NamesIter<'a> { + Native(::std::slice::Iter<'a, Option<&'static str>>), + Dynamic(::std::slice::Iter<'a, Option<String>>) +} + +impl<'a> Iterator for NamesIter<'a> { + type Item=Option<String>; + + fn next(&mut self) -> Option<Option<String>> { + match *self { + NamesIter::Native(ref mut i) => + i.next().map(|x| x.map(|s| s.to_owned())), + NamesIter::Dynamic(ref mut i) => + i.next().map(|x| x.as_ref().map(|s| s.to_owned())), + } + } +} + +/// NoExpand indicates literal string replacement. +/// +/// It can be used with `replace` and `replace_all` to do a literal +/// string replacement without expanding `$name` to their corresponding +/// capture groups. +/// +/// `'r` is the lifetime of the literal text. +pub struct NoExpand<'t>(pub &'t str); + +/// Replacer describes types that can be used to replace matches in a string. +pub trait Replacer { + /// Returns a possibly owned string that is used to replace the match + /// corresponding to the `caps` capture group. + /// + /// The `'a` lifetime refers to the lifetime of a borrowed string when + /// a new owned string isn't needed (e.g., for `NoExpand`). + fn reg_replace<'a>(&'a mut self, caps: &Captures) -> Cow<'a, str>; + + /// Returns a possibly owned string that never needs expansion. + fn no_expand<'a>(&'a mut self) -> Option<Cow<'a, str>> { None } +} + +impl<'t> Replacer for NoExpand<'t> { + fn reg_replace<'a>(&'a mut self, _: &Captures) -> Cow<'a, str> { + self.0.into() + } + + fn no_expand<'a>(&'a mut self) -> Option<Cow<'a, str>> { + Some(self.0.into()) + } +} + +impl<'t> Replacer for &'t str { + fn reg_replace<'a>(&'a mut self, caps: &Captures) -> Cow<'a, str> { + caps.expand(*self).into() + } + + fn no_expand<'a>(&'a mut self) -> Option<Cow<'a, str>> { + let re = Regex::new(REPLACE_EXPAND).unwrap(); + if !re.is_match(self) { + Some((*self).into()) + } else { + None + } + } +} + +impl<F> Replacer for F where F: FnMut(&Captures) -> String { + fn reg_replace<'a>(&'a mut self, caps: &Captures) -> Cow<'a, str> { + (*self)(caps).into() + } +} + +/// Yields all substrings delimited by a regular expression match. +/// +/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime +/// of the string being split. +pub struct RegexSplits<'r, 't> { + finder: FindMatches<'r, 't>, + last: usize, +} + +impl<'r, 't> Iterator for RegexSplits<'r, 't> { + type Item = &'t str; + + fn next(&mut self) -> Option<&'t str> { + let text = self.finder.search; + match self.finder.next() { + None => { + if self.last >= text.len() { + None + } else { + let s = &text[self.last..]; + self.last = text.len(); + Some(s) + } + } + Some((s, e)) => { + let matched = &text[self.last..s]; + self.last = e; + Some(matched) + } + } + } +} + +/// Yields at most `N` substrings delimited by a regular expression match. +/// +/// The last substring will be whatever remains after splitting. +/// +/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime +/// of the string being split. +pub struct RegexSplitsN<'r, 't> { + splits: RegexSplits<'r, 't>, + cur: usize, + limit: usize, +} + +impl<'r, 't> Iterator for RegexSplitsN<'r, 't> { + type Item = &'t str; + + fn next(&mut self) -> Option<&'t str> { + let text = self.splits.finder.search; + if self.cur >= self.limit { + None + } else { + self.cur += 1; + if self.cur >= self.limit { + Some(&text[self.splits.last..]) + } else { + self.splits.next() + } + } + } +} + +/// Captures represents a group of captured strings for a single match. +/// +/// The 0th capture always corresponds to the entire match. Each subsequent +/// index corresponds to the next capture group in the regex. +/// If a capture group is named, then the matched string is *also* available +/// via the `name` method. (Note that the 0th capture is always unnamed and so +/// must be accessed with the `at` method.) +/// +/// Positions returned from a capture group are always byte indices. +/// +/// `'t` is the lifetime of the matched text. +pub struct Captures<'t> { + text: &'t str, + locs: Vec<Option<usize>>, + named: Option<HashMap<String, usize>>, +} + +impl<'t> Captures<'t> { + fn new( + re: &Regex, + search: &'t str, + locs: Vec<Option<usize>>, + ) -> Captures<'t> { + let named = + if re.names_len() == 0 { + None + } else { + let mut named = HashMap::new(); + for (i, name) in re.names_iter().enumerate() { + if let Some(name) = name { + named.insert(name, i); + } + } + Some(named) + }; + Captures { + text: search, + locs: locs, + named: named, + } + } + + /// Returns the start and end positions of the Nth capture group. + /// Returns `None` if `i` is not a valid capture group or if the capture + /// group did not match anything. + /// The positions returned are *always* byte indices with respect to the + /// original string matched. + pub fn pos(&self, i: usize) -> Option<(usize, usize)> { + let (s, e) = (i * 2, i * 2 + 1); + if e >= self.locs.len() || self.locs[s].is_none() { + // VM guarantees that each pair of locations are both Some or None. + return None + } + Some((self.locs[s].unwrap(), self.locs[e].unwrap())) + } + + /// Returns the matched string for the capture group `i`. If `i` isn't + /// a valid capture group or didn't match anything, then `None` is + /// returned. + pub fn at(&self, i: usize) -> Option<&'t str> { + match self.pos(i) { + None => None, + Some((s, e)) => Some(&self.text[s..e]) + } + } + + /// Returns the matched string for the capture group named `name`. If + /// `name` isn't a valid capture group or didn't match anything, then + /// `None` is returned. + pub fn name(&self, name: &str) -> Option<&'t str> { + match self.named { + None => None, + Some(ref h) => { + match h.get(name) { + None => None, + Some(i) => self.at(*i), + } + } + } + } + + /// Creates an iterator of all the capture groups in order of appearance + /// in the regular expression. + pub fn iter(&'t self) -> SubCaptures<'t> { + SubCaptures { idx: 0, caps: self, } + } + + /// Creates an iterator of all the capture group positions in order of + /// appearance in the regular expression. Positions are byte indices + /// in terms of the original string matched. + pub fn iter_pos(&'t self) -> SubCapturesPos<'t> { + SubCapturesPos { idx: 0, caps: self, } + } + + /// Creates an iterator of all named groups as an tuple with the group + /// name and the value. The iterator returns these values in arbitrary + /// order. + pub fn iter_named(&'t self) -> SubCapturesNamed<'t> { + SubCapturesNamed { caps: self, inner: self.named.as_ref().map(|n| n.iter()) } + } + + /// Expands all instances of `$name` in `text` to the corresponding capture + /// group `name`. + /// + /// `name` may be an integer corresponding to the index of the + /// capture group (counted by order of opening parenthesis where `0` is the + /// entire match) or it can be a name (consisting of letters, digits or + /// underscores) corresponding to a named capture group. + /// + /// If `name` isn't a valid capture group (whether the name doesn't exist or + /// isn't a valid index), then it is replaced with the empty string. + /// + /// To write a literal `$` use `$$`. + pub fn expand(&self, text: &str) -> String { + // How evil can you get? + let re = Regex::new(REPLACE_EXPAND).unwrap(); + let text = re.replace_all(text, |refs: &Captures| -> String { + let before = refs.name("before").unwrap_or(""); + let name = refs.name("name").unwrap_or(""); + format!("{}{}", before, match name.parse::<usize>() { + Err(_) => self.name(name).unwrap_or("").to_string(), + Ok(i) => self.at(i).unwrap_or("").to_string(), + }) + }); + let re = Regex::new(r"\$\$").unwrap(); + re.replace_all(&text, NoExpand("$")) + } + + /// Returns the number of captured groups. + #[inline] + pub fn len(&self) -> usize { self.locs.len() / 2 } + + /// Returns true if and only if there are no captured groups. + #[inline] + pub fn is_empty(&self) -> bool { self.len() == 0 } +} + +/// An iterator over capture groups for a particular match of a regular +/// expression. +/// +/// `'t` is the lifetime of the matched text. +pub struct SubCaptures<'t> { + idx: usize, + caps: &'t Captures<'t>, +} + +impl<'t> Iterator for SubCaptures<'t> { + type Item = Option<&'t str>; + + fn next(&mut self) -> Option<Option<&'t str>> { + if self.idx < self.caps.len() { + self.idx += 1; + Some(self.caps.at(self.idx - 1)) + } else { + None + } + } +} + +/// An iterator over capture group positions for a particular match of a +/// regular expression. +/// +/// Positions are byte indices in terms of the original string matched. +/// +/// `'t` is the lifetime of the matched text. +pub struct SubCapturesPos<'t> { + idx: usize, + caps: &'t Captures<'t>, +} + +impl<'t> Iterator for SubCapturesPos<'t> { + type Item = Option<(usize, usize)>; + + fn next(&mut self) -> Option<Option<(usize, usize)>> { + if self.idx < self.caps.len() { + self.idx += 1; + Some(self.caps.pos(self.idx - 1)) + } else { + None + } + } +} + +/// An Iterator over named capture groups as a tuple with the group +/// name and the value. +/// +/// `'t` is the lifetime of the matched text. +pub struct SubCapturesNamed<'t>{ + caps: &'t Captures<'t>, + inner: Option<Iter<'t, String, usize>>, +} + +impl<'t> Iterator for SubCapturesNamed<'t> { + type Item = (&'t str, Option<&'t str>); + + fn next(&mut self) -> Option<(&'t str, Option<&'t str>)> { + match self.inner.as_mut().map(|it| it.next()).unwrap_or(None) { + Some((name, pos)) => Some((name, self.caps.at(*pos))), + None => None + } + } +} + +/// An iterator that yields all non-overlapping capture groups matching a +/// particular regular expression. +/// +/// The iterator stops when no more matches can be found. +/// +/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime +/// of the matched string. +pub struct FindCaptures<'r, 't> { + re: &'r Regex, + search: &'t str, + last_match: Option<usize>, + last_end: usize, +} + +impl<'r, 't> Iterator for FindCaptures<'r, 't> { + type Item = Captures<'t>; + + fn next(&mut self) -> Option<Captures<'t>> { + if self.last_end > self.search.len() { + return None + } + + let mut caps = self.re.alloc_captures(); + if !exec(self.re, &mut caps, self.search, self.last_end) { + return None + } + let (s, e) = (caps[0].unwrap(), caps[1].unwrap()); + + // Don't accept empty matches immediately following a match. + // i.e., no infinite loops please. + if e == s && Some(self.last_end) == self.last_match { + if self.last_end >= self.search.len() { + return None; + } + self.last_end += self.search[self.last_end..].chars() + .next().unwrap().len_utf8(); + return self.next() + } + self.last_end = e; + self.last_match = Some(self.last_end); + Some(Captures::new(self.re, self.search, caps)) + } +} + +/// An iterator over all non-overlapping matches for a particular string. +/// +/// The iterator yields a tuple of integers corresponding to the start and end +/// of the match. The indices are byte offsets. The iterator stops when no more +/// matches can be found. +/// +/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime +/// of the matched string. +pub struct FindMatches<'r, 't> { + re: &'r Regex, + search: &'t str, + last_match: Option<usize>, + last_end: usize, +} + +impl<'r, 't> Iterator for FindMatches<'r, 't> { + type Item = (usize, usize); + + fn next(&mut self) -> Option<(usize, usize)> { + if self.last_end > self.search.len() { + return None + } + + let mut caps = [None, None]; + if !exec(self.re, &mut caps, self.search, self.last_end) { + return None; + } + let (s, e) = (caps[0].unwrap(), caps[1].unwrap()); + + // Don't accept empty matches immediately following a match. + // i.e., no infinite loops please. + if e == s && Some(self.last_end) == self.last_match { + if self.last_end >= self.search.len() { + return None; + } + self.last_end += self.search[self.last_end..].chars() + .next().unwrap().len_utf8(); + return self.next() + } + self.last_end = e; + self.last_match = Some(self.last_end); + Some((s, e)) + } +} + +#[cfg(feature = "pattern")] +pub struct RegexSearcher<'r, 't> { + it: FindMatches<'r, 't>, + last_step_end: usize, + next_match: Option<(usize, usize)>, +} + +#[cfg(feature = "pattern")] +impl<'r, 't> Pattern<'t> for &'r Regex { + type Searcher = RegexSearcher<'r, 't>; + + fn into_searcher(self, haystack: &'t str) -> RegexSearcher<'r, 't> { + RegexSearcher { + it: self.find_iter(haystack), + last_step_end: 0, + next_match: None, + } + } +} + +#[cfg(feature = "pattern")] +unsafe impl<'r, 't> Searcher<'t> for RegexSearcher<'r, 't> { + #[inline] + fn haystack(&self) -> &'t str { + self.it.search + } + + #[inline] + fn next(&mut self) -> SearchStep { + if let Some((s, e)) = self.next_match { + self.next_match = None; + self.last_step_end = e; + return SearchStep::Match(s, e); + } + match self.it.next() { + None => { + if self.last_step_end < self.haystack().len() { + let last = self.last_step_end; + self.last_step_end = self.haystack().len(); + SearchStep::Reject(last, self.haystack().len()) + } else { + SearchStep::Done + } + } + Some((s, e)) => { + if s == self.last_step_end { + self.last_step_end = e; + SearchStep::Match(s, e) + } else { + self.next_match = Some((s, e)); + let last = self.last_step_end; + self.last_step_end = s; + SearchStep::Reject(last, s) + } + } + } + } +} + +fn exec(re: &Regex, caps: &mut CaptureIdxs, text: &str, start: usize) -> bool { + match *re { + Regex::Native(ExNative { ref prog, .. }) => (*prog)(caps, text, start), + Regex::Dynamic(ref prog) => prog.exec(caps, text, start), + } +} diff --git a/deps/regex-0.1.38/src/testdata/LICENSE b/deps/regex-0.1.38/src/testdata/LICENSE new file mode 100644 index 000000000..f47dbf4c4 --- /dev/null +++ b/deps/regex-0.1.38/src/testdata/LICENSE @@ -0,0 +1,19 @@ +The following license covers testregex.c and all associated test data. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of THIS SOFTWARE FILE (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do +so, subject to the following disclaimer: + +THIS SOFTWARE IS PROVIDED BY AT&T ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL AT&T BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/regex-0.1.38/src/testdata/README b/deps/regex-0.1.38/src/testdata/README new file mode 100644 index 000000000..6efc2dad3 --- /dev/null +++ b/deps/regex-0.1.38/src/testdata/README @@ -0,0 +1,17 @@ +Test data was taken from the Go distribution, which was in turn taken from the +testregex test suite: + + http://www2.research.att.com/~astopen/testregex/testregex.html + +The LICENSE in this directory corresponds to the LICENSE that the data was +released under. + +The tests themselves were modified for RE2/Go. A couple were modified further +by me (Andrew Gallant) (only in repetition.dat) so that RE2/Go would pass them. +(Yes, it seems like RE2/Go includes failing test cases.) This may or may not +have been a bad idea, but I think being consistent with an established Regex +library is worth something. + +Note that these files are read by 'scripts/regex-match-tests.py' and turned +into Rust tests found in 'regex_macros/tests/matches.rs'. + diff --git a/deps/regex-0.1.38/src/testdata/basic.dat b/deps/regex-0.1.38/src/testdata/basic.dat new file mode 100644 index 000000000..e55efaeec --- /dev/null +++ b/deps/regex-0.1.38/src/testdata/basic.dat @@ -0,0 +1,221 @@ +NOTE all standard compliant implementations should pass these : 2002-05-31 + +BE abracadabra$ abracadabracadabra (7,18) +BE a...b abababbb (2,7) +BE XXXXXX ..XXXXXX (2,8) +E \) () (1,2) +BE a] a]a (0,2) +B } } (0,1) +E \} } (0,1) +BE \] ] (0,1) +B ] ] (0,1) +E ] ] (0,1) +B { { (0,1) +B } } (0,1) +BE ^a ax (0,1) +BE \^a a^a (1,3) +BE a\^ a^ (0,2) +BE a$ aa (1,2) +BE a\$ a$ (0,2) +BE ^$ NULL (0,0) +E $^ NULL (0,0) +E a($) aa (1,2)(2,2) +E a*(^a) aa (0,1)(0,1) +E (..)*(...)* a (0,0) +E (..)*(...)* abcd (0,4)(2,4) +E (ab|a)(bc|c) abc (0,3)(0,2)(2,3) +E (ab)c|abc abc (0,3)(0,2) +E a{0}b ab (1,2) +E (a*)(b?)(b+)b{3} aaabbbbbbb (0,10)(0,3)(3,4)(4,7) +E (a*)(b{0,1})(b{1,})b{3} aaabbbbbbb (0,10)(0,3)(3,4)(4,7) +E a{9876543210} NULL BADBR +E ((a|a)|a) a (0,1)(0,1)(0,1) +E (a*)(a|aa) aaaa (0,4)(0,3)(3,4) +E a*(a.|aa) aaaa (0,4)(2,4) +E a(b)|c(d)|a(e)f aef (0,3)(?,?)(?,?)(1,2) +E (a|b)?.* b (0,1)(0,1) +E (a|b)c|a(b|c) ac (0,2)(0,1) +E (a|b)c|a(b|c) ab (0,2)(?,?)(1,2) +E (a|b)*c|(a|ab)*c abc (0,3)(1,2) +E (a|b)*c|(a|ab)*c xc (1,2) +E (.a|.b).*|.*(.a|.b) xa (0,2)(0,2) +E a?(ab|ba)ab abab (0,4)(0,2) +E a?(ac{0}b|ba)ab abab (0,4)(0,2) +E ab|abab abbabab (0,2) +E aba|bab|bba baaabbbaba (5,8) +E aba|bab baaabbbaba (6,9) +E (aa|aaa)*|(a|aaaaa) aa (0,2)(0,2) +E (a.|.a.)*|(a|.a...) aa (0,2)(0,2) +E ab|a xabc (1,3) +E ab|a xxabc (2,4) +Ei (Ab|cD)* aBcD (0,4)(2,4) +BE [^-] --a (2,3) +BE [a-]* --a (0,3) +BE [a-m-]* --amoma-- (0,4) +E :::1:::0:|:::1:1:0: :::0:::1:::1:::0: (8,17) +E :::1:::0:|:::1:1:1: :::0:::1:::1:::0: (8,17) +{E [[:upper:]] A (0,1) [[<element>]] not supported +E [[:lower:]]+ `az{ (1,3) +E [[:upper:]]+ @AZ[ (1,3) +# No collation in Go +#BE [[-]] [[-]] (2,4) +#BE [[.NIL.]] NULL ECOLLATE +#BE [[=aleph=]] NULL ECOLLATE +} +BE$ \n \n (0,1) +BEn$ \n \n (0,1) +BE$ [^a] \n (0,1) +BE$ \na \na (0,2) +E (a)(b)(c) abc (0,3)(0,1)(1,2)(2,3) +BE xxx xxx (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 6, (0,6) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) 2/7 (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 1,Feb 6 (5,11) +E3 ((((((((((((((((((((((((((((((x)))))))))))))))))))))))))))))) x (0,1)(0,1)(0,1) +E3 ((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))* xx (0,2)(1,2)(1,2) +E a?(ab|ba)* ababababababababababababababababababababababababababababababababababababababababa (0,81)(79,81) +E abaa|abbaa|abbbaa|abbbbaa ababbabbbabbbabbbbabbbbaa (18,25) +E abaa|abbaa|abbbaa|abbbbaa ababbabbbabbbabbbbabaa (18,22) +E aaac|aabc|abac|abbc|baac|babc|bbac|bbbc baaabbbabac (7,11) +BE$ .* \x01\x7f (0,2) +E aaaa|bbbb|cccc|ddddd|eeeeee|fffffff|gggg|hhhh|iiiii|jjjjj|kkkkk|llll XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa (53,57) +L aaaa\nbbbb\ncccc\nddddd\neeeeee\nfffffff\ngggg\nhhhh\niiiii\njjjjj\nkkkkk\nllll XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa NOMATCH +E a*a*a*a*a*b aaaaaaaaab (0,10) +BE ^ NULL (0,0) +BE $ NULL (0,0) +BE ^$ NULL (0,0) +BE ^a$ a (0,1) +BE abc abc (0,3) +BE abc xabcy (1,4) +BE abc ababc (2,5) +BE ab*c abc (0,3) +BE ab*bc abc (0,3) +BE ab*bc abbc (0,4) +BE ab*bc abbbbc (0,6) +E ab+bc abbc (0,4) +E ab+bc abbbbc (0,6) +E ab?bc abbc (0,4) +E ab?bc abc (0,3) +E ab?c abc (0,3) +BE ^abc$ abc (0,3) +BE ^abc abcc (0,3) +BE abc$ aabc (1,4) +BE ^ abc (0,0) +BE $ abc (3,3) +BE a.c abc (0,3) +BE a.c axc (0,3) +BE a.*c axyzc (0,5) +BE a[bc]d abd (0,3) +BE a[b-d]e ace (0,3) +BE a[b-d] aac (1,3) +BE a[-b] a- (0,2) +BE a[b-] a- (0,2) +BE a] a] (0,2) +BE a[]]b a]b (0,3) +BE a[^bc]d aed (0,3) +BE a[^-b]c adc (0,3) +BE a[^]b]c adc (0,3) +E ab|cd abc (0,2) +E ab|cd abcd (0,2) +E a\(b a(b (0,3) +E a\(*b ab (0,2) +E a\(*b a((b (0,4) +E ((a)) abc (0,1)(0,1)(0,1) +E (a)b(c) abc (0,3)(0,1)(2,3) +E a+b+c aabbabc (4,7) +E a* aaa (0,3) +#E (a*)* - (0,0)(0,0) +E (a*)* - (0,0)(?,?) RE2/Go +E (a*)+ - (0,0)(0,0) +#E (a*|b)* - (0,0)(0,0) +E (a*|b)* - (0,0)(?,?) RE2/Go +E (a+|b)* ab (0,2)(1,2) +E (a+|b)+ ab (0,2)(1,2) +E (a+|b)? ab (0,1)(0,1) +BE [^ab]* cde (0,3) +#E (^)* - (0,0)(0,0) +E (^)* - (0,0)(?,?) RE2/Go +BE a* NULL (0,0) +E ([abc])*d abbbcd (0,6)(4,5) +E ([abc])*bcd abcd (0,4)(0,1) +E a|b|c|d|e e (0,1) +E (a|b|c|d|e)f ef (0,2)(0,1) +#E ((a*|b))* - (0,0)(0,0)(0,0) +E ((a*|b))* - (0,0)(?,?)(?,?) RE2/Go +BE abcd*efg abcdefg (0,7) +BE ab* xabyabbbz (1,3) +BE ab* xayabbbz (1,2) +E (ab|cd)e abcde (2,5)(2,4) +BE [abhgefdc]ij hij (0,3) +E (a|b)c*d abcd (1,4)(1,2) +E (ab|ab*)bc abc (0,3)(0,1) +E a([bc]*)c* abc (0,3)(1,3) +E a([bc]*)(c*d) abcd (0,4)(1,3)(3,4) +E a([bc]+)(c*d) abcd (0,4)(1,3)(3,4) +E a([bc]*)(c+d) abcd (0,4)(1,2)(2,4) +E a[bcd]*dcdcde adcdcde (0,7) +E (ab|a)b*c abc (0,3)(0,2) +E ((a)(b)c)(d) abcd (0,4)(0,3)(0,1)(1,2)(3,4) +BE [A-Za-z_][A-Za-z0-9_]* alpha (0,5) +E ^a(bc+|b[eh])g|.h$ abh (1,3) +E (bc+d$|ef*g.|h?i(j|k)) effgz (0,5)(0,5) +E (bc+d$|ef*g.|h?i(j|k)) ij (0,2)(0,2)(1,2) +E (bc+d$|ef*g.|h?i(j|k)) reffgz (1,6)(1,6) +E (((((((((a))))))))) a (0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1) +BE multiple words multiple words yeah (0,14) +E (.*)c(.*) abcde (0,5)(0,2)(3,5) +BE abcd abcd (0,4) +E a(bc)d abcd (0,4)(1,3) +E a[-]?c ac (0,3) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Qaddafi (0,15)(?,?)(10,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mo'ammar Gadhafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Kaddafi (0,15)(?,?)(10,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Qadhafi (0,15)(?,?)(10,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Gadafi (0,14)(?,?)(10,11) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mu'ammar Qadafi (0,15)(?,?)(11,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moamar Gaddafi (0,14)(?,?)(9,11) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mu'ammar Qadhdhafi (0,18)(?,?)(13,15) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Khaddafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghaddafy (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghadafi (0,15)(?,?)(11,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghaddafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muamar Kaddafi (0,14)(?,?)(9,11) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Quathafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Gheddafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moammar Khadafy (0,15)(?,?)(11,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moammar Qudhafi (0,15)(?,?)(10,12) +E a+(b|c)*d+ aabcdd (0,6)(3,4) +E ^.+$ vivi (0,4) +E ^(.+)$ vivi (0,4)(0,4) +E ^([^!.]+).att.com!(.+)$ gryphon.att.com!eby (0,19)(0,7)(16,19) +E ^([^!]+!)?([^!]+)$ bas (0,3)(?,?)(0,3) +E ^([^!]+!)?([^!]+)$ bar!bas (0,7)(0,4)(4,7) +E ^([^!]+!)?([^!]+)$ foo!bas (0,7)(0,4)(4,7) +E ^.+!([^!]+!)([^!]+)$ foo!bar!bas (0,11)(4,8)(8,11) +E ((foo)|(bar))!bas bar!bas (0,7)(0,3)(?,?)(0,3) +E ((foo)|(bar))!bas foo!bar!bas (4,11)(4,7)(?,?)(4,7) +E ((foo)|(bar))!bas foo!bas (0,7)(0,3)(0,3) +E ((foo)|bar)!bas bar!bas (0,7)(0,3) +E ((foo)|bar)!bas foo!bar!bas (4,11)(4,7) +E ((foo)|bar)!bas foo!bas (0,7)(0,3)(0,3) +E (foo|(bar))!bas bar!bas (0,7)(0,3)(0,3) +E (foo|(bar))!bas foo!bar!bas (4,11)(4,7)(4,7) +E (foo|(bar))!bas foo!bas (0,7)(0,3) +E (foo|bar)!bas bar!bas (0,7)(0,3) +E (foo|bar)!bas foo!bar!bas (4,11)(4,7) +E (foo|bar)!bas foo!bas (0,7)(0,3) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bar!bas (0,11)(0,11)(?,?)(?,?)(4,8)(8,11) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ bas (0,3)(?,?)(0,3) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ bar!bas (0,7)(0,4)(4,7) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ foo!bar!bas (0,11)(?,?)(?,?)(4,8)(8,11) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ foo!bas (0,7)(0,4)(4,7) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ bas (0,3)(0,3)(?,?)(0,3) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ bar!bas (0,7)(0,7)(0,4)(4,7) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bar!bas (0,11)(0,11)(?,?)(?,?)(4,8)(8,11) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bas (0,7)(0,7)(0,4)(4,7) +E .*(/XXX).* /XXX (0,4)(0,4) +E .*(\\XXX).* \XXX (0,4)(0,4) +E \\XXX \XXX (0,4) +E .*(/000).* /000 (0,4)(0,4) +E .*(\\000).* \000 (0,4)(0,4) +E \\000 \000 (0,4) diff --git a/deps/regex-0.1.38/src/testdata/nullsubexpr.dat b/deps/regex-0.1.38/src/testdata/nullsubexpr.dat new file mode 100644 index 000000000..2e18fbb91 --- /dev/null +++ b/deps/regex-0.1.38/src/testdata/nullsubexpr.dat @@ -0,0 +1,79 @@ +NOTE null subexpression matches : 2002-06-06 + +E (a*)* a (0,1)(0,1) +#E SAME x (0,0)(0,0) +E SAME x (0,0)(?,?) RE2/Go +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E (a*)+ a (0,1)(0,1) +E SAME x (0,0)(0,0) +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E (a+)* a (0,1)(0,1) +E SAME x (0,0) +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E (a+)+ a (0,1)(0,1) +E SAME x NOMATCH +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) + +E ([a]*)* a (0,1)(0,1) +#E SAME x (0,0)(0,0) +E SAME x (0,0)(?,?) RE2/Go +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E ([a]*)+ a (0,1)(0,1) +E SAME x (0,0)(0,0) +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E ([^b]*)* a (0,1)(0,1) +#E SAME b (0,0)(0,0) +E SAME b (0,0)(?,?) RE2/Go +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaab (0,6)(0,6) +E ([ab]*)* a (0,1)(0,1) +E SAME aaaaaa (0,6)(0,6) +E SAME ababab (0,6)(0,6) +E SAME bababa (0,6)(0,6) +E SAME b (0,1)(0,1) +E SAME bbbbbb (0,6)(0,6) +E SAME aaaabcde (0,5)(0,5) +E ([^a]*)* b (0,1)(0,1) +E SAME bbbbbb (0,6)(0,6) +#E SAME aaaaaa (0,0)(0,0) +E SAME aaaaaa (0,0)(?,?) RE2/Go +E ([^ab]*)* ccccxx (0,6)(0,6) +#E SAME ababab (0,0)(0,0) +E SAME ababab (0,0)(?,?) RE2/Go + +E ((z)+|a)* zabcde (0,2)(1,2) + +#{E a+? aaaaaa (0,1) no *? +? mimimal match ops +#E (a) aaa (0,1)(0,1) +#E (a*?) aaa (0,0)(0,0) +#E (a)*? aaa (0,0) +#E (a*?)*? aaa (0,0) +#} + +B \(a*\)*\(x\) x (0,1)(0,0)(0,1) +B \(a*\)*\(x\) ax (0,2)(0,1)(1,2) +B \(a*\)*\(x\) axa (0,2)(0,1)(1,2) +B \(a*\)*\(x\)\(\1\) x (0,1)(0,0)(0,1)(1,1) +B \(a*\)*\(x\)\(\1\) ax (0,2)(1,1)(1,2)(2,2) +B \(a*\)*\(x\)\(\1\) axa (0,3)(0,1)(1,2)(2,3) +B \(a*\)*\(x\)\(\1\)\(x\) axax (0,4)(0,1)(1,2)(2,3)(3,4) +B \(a*\)*\(x\)\(\1\)\(x\) axxa (0,3)(1,1)(1,2)(2,2)(2,3) + +#E (a*)*(x) x (0,1)(0,0)(0,1) +E (a*)*(x) x (0,1)(?,?)(0,1) RE2/Go +E (a*)*(x) ax (0,2)(0,1)(1,2) +E (a*)*(x) axa (0,2)(0,1)(1,2) + +E (a*)+(x) x (0,1)(0,0)(0,1) +E (a*)+(x) ax (0,2)(0,1)(1,2) +E (a*)+(x) axa (0,2)(0,1)(1,2) + +E (a*){2}(x) x (0,1)(0,0)(0,1) +E (a*){2}(x) ax (0,2)(1,1)(1,2) +E (a*){2}(x) axa (0,2)(1,1)(1,2) diff --git a/deps/regex-0.1.38/src/testdata/repetition.dat b/deps/regex-0.1.38/src/testdata/repetition.dat new file mode 100644 index 000000000..3bb212118 --- /dev/null +++ b/deps/regex-0.1.38/src/testdata/repetition.dat @@ -0,0 +1,163 @@ +NOTE implicit vs. explicit repetitions : 2009-02-02 + +# Glenn Fowler <gsf@research.att.com> +# conforming matches (column 4) must match one of the following BREs +# NOMATCH +# (0,.)\((\(.\),\(.\))(?,?)(\2,\3)\)* +# (0,.)\((\(.\),\(.\))(\2,\3)(?,?)\)* +# i.e., each 3-tuple has two identical elements and one (?,?) + +E ((..)|(.)) NULL NOMATCH +E ((..)|(.))((..)|(.)) NULL NOMATCH +E ((..)|(.))((..)|(.))((..)|(.)) NULL NOMATCH + +E ((..)|(.)){1} NULL NOMATCH +E ((..)|(.)){2} NULL NOMATCH +E ((..)|(.)){3} NULL NOMATCH + +E ((..)|(.))* NULL (0,0) + +E ((..)|(.)) a (0,1)(0,1)(?,?)(0,1) +E ((..)|(.))((..)|(.)) a NOMATCH +E ((..)|(.))((..)|(.))((..)|(.)) a NOMATCH + +E ((..)|(.)){1} a (0,1)(0,1)(?,?)(0,1) +E ((..)|(.)){2} a NOMATCH +E ((..)|(.)){3} a NOMATCH + +E ((..)|(.))* a (0,1)(0,1)(?,?)(0,1) + +E ((..)|(.)) aa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aa (0,2)(0,1)(?,?)(0,1)(1,2)(?,?)(1,2) +E ((..)|(.))((..)|(.))((..)|(.)) aa NOMATCH + +E ((..)|(.)){1} aa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aa (0,2)(1,2)(?,?)(1,2) +E ((..)|(.)){3} aa NOMATCH + +E ((..)|(.))* aa (0,2)(0,2)(0,2)(?,?) + +E ((..)|(.)) aaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaa (0,3)(0,2)(0,2)(?,?)(2,3)(?,?)(2,3) +E ((..)|(.))((..)|(.))((..)|(.)) aaa (0,3)(0,1)(?,?)(0,1)(1,2)(?,?)(1,2)(2,3)(?,?)(2,3) + +E ((..)|(.)){1} aaa (0,2)(0,2)(0,2)(?,?) +#E ((..)|(.)){2} aaa (0,3)(2,3)(?,?)(2,3) +E ((..)|(.)){2} aaa (0,3)(2,3)(0,2)(2,3) RE2/Go +E ((..)|(.)){3} aaa (0,3)(2,3)(?,?)(2,3) + +#E ((..)|(.))* aaa (0,3)(2,3)(?,?)(2,3) +E ((..)|(.))* aaa (0,3)(2,3)(0,2)(2,3) RE2/Go + +E ((..)|(.)) aaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) +E ((..)|(.))((..)|(.))((..)|(.)) aaaa (0,4)(0,2)(0,2)(?,?)(2,3)(?,?)(2,3)(3,4)(?,?)(3,4) + +E ((..)|(.)){1} aaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aaaa (0,4)(2,4)(2,4)(?,?) +#E ((..)|(.)){3} aaaa (0,4)(3,4)(?,?)(3,4) +E ((..)|(.)){3} aaaa (0,4)(3,4)(0,2)(3,4) RE2/Go + +E ((..)|(.))* aaaa (0,4)(2,4)(2,4)(?,?) + +E ((..)|(.)) aaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) +E ((..)|(.))((..)|(.))((..)|(.)) aaaaa (0,5)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?)(4,5)(?,?)(4,5) + +E ((..)|(.)){1} aaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aaaaa (0,4)(2,4)(2,4)(?,?) +#E ((..)|(.)){3} aaaaa (0,5)(4,5)(?,?)(4,5) +E ((..)|(.)){3} aaaaa (0,5)(4,5)(2,4)(4,5) RE2/Go + +#E ((..)|(.))* aaaaa (0,5)(4,5)(?,?)(4,5) +E ((..)|(.))* aaaaa (0,5)(4,5)(2,4)(4,5) RE2/Go + +E ((..)|(.)) aaaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaaaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) +E ((..)|(.))((..)|(.))((..)|(.)) aaaaaa (0,6)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?)(4,6)(4,6)(?,?) + +E ((..)|(.)){1} aaaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aaaaaa (0,4)(2,4)(2,4)(?,?) +E ((..)|(.)){3} aaaaaa (0,6)(4,6)(4,6)(?,?) + +E ((..)|(.))* aaaaaa (0,6)(4,6)(4,6)(?,?) + +NOTE additional repetition tests graciously provided by Chris Kuklewicz www.haskell.org 2009-02-02 + +# These test a bug in OS X / FreeBSD / NetBSD, and libtree. +# Linux/GLIBC gets the {8,} and {8,8} wrong. + +:HA#100:E X(.?){0,}Y X1234567Y (0,9)(7,8) +:HA#101:E X(.?){1,}Y X1234567Y (0,9)(7,8) +:HA#102:E X(.?){2,}Y X1234567Y (0,9)(7,8) +:HA#103:E X(.?){3,}Y X1234567Y (0,9)(7,8) +:HA#104:E X(.?){4,}Y X1234567Y (0,9)(7,8) +:HA#105:E X(.?){5,}Y X1234567Y (0,9)(7,8) +:HA#106:E X(.?){6,}Y X1234567Y (0,9)(7,8) +:HA#107:E X(.?){7,}Y X1234567Y (0,9)(7,8) +:HA#108:E X(.?){8,}Y X1234567Y (0,9)(8,8) +#:HA#110:E X(.?){0,8}Y X1234567Y (0,9)(7,8) +:HA#110:E X(.?){0,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#111:E X(.?){1,8}Y X1234567Y (0,9)(7,8) +:HA#111:E X(.?){1,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#112:E X(.?){2,8}Y X1234567Y (0,9)(7,8) +:HA#112:E X(.?){2,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#113:E X(.?){3,8}Y X1234567Y (0,9)(7,8) +:HA#113:E X(.?){3,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#114:E X(.?){4,8}Y X1234567Y (0,9)(7,8) +:HA#114:E X(.?){4,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#115:E X(.?){5,8}Y X1234567Y (0,9)(7,8) +:HA#115:E X(.?){5,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#116:E X(.?){6,8}Y X1234567Y (0,9)(7,8) +:HA#116:E X(.?){6,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#117:E X(.?){7,8}Y X1234567Y (0,9)(7,8) +:HA#117:E X(.?){7,8}Y X1234567Y (0,9)(8,8) RE2/Go +:HA#118:E X(.?){8,8}Y X1234567Y (0,9)(8,8) + +# These test a fixed bug in my regex-tdfa that did not keep the expanded +# form properly grouped, so right association did the wrong thing with +# these ambiguous patterns (crafted just to test my code when I became +# suspicious of my implementation). The first subexpression should use +# "ab" then "a" then "bcd". + +# OS X / FreeBSD / NetBSD badly fail many of these, with impossible +# results like (0,6)(4,5)(6,6). + +:HA#260:E (a|ab|c|bcd){0,}(d*) ababcd (0,1)(0,1)(1,1) +:HA#261:E (a|ab|c|bcd){1,}(d*) ababcd (0,1)(0,1)(1,1) +:HA#262:E (a|ab|c|bcd){2,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#263:E (a|ab|c|bcd){3,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#264:E (a|ab|c|bcd){4,}(d*) ababcd NOMATCH +:HA#265:E (a|ab|c|bcd){0,10}(d*) ababcd (0,1)(0,1)(1,1) +:HA#266:E (a|ab|c|bcd){1,10}(d*) ababcd (0,1)(0,1)(1,1) +:HA#267:E (a|ab|c|bcd){2,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#268:E (a|ab|c|bcd){3,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#269:E (a|ab|c|bcd){4,10}(d*) ababcd NOMATCH +:HA#270:E (a|ab|c|bcd)*(d*) ababcd (0,1)(0,1)(1,1) +:HA#271:E (a|ab|c|bcd)+(d*) ababcd (0,1)(0,1)(1,1) + +# The above worked on Linux/GLIBC but the following often fail. +# They also trip up OS X / FreeBSD / NetBSD: + +#:HA#280:E (ab|a|c|bcd){0,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#280:E (ab|a|c|bcd){0,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#281:E (ab|a|c|bcd){1,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#281:E (ab|a|c|bcd){1,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#282:E (ab|a|c|bcd){2,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#282:E (ab|a|c|bcd){2,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#283:E (ab|a|c|bcd){3,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#283:E (ab|a|c|bcd){3,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +:HA#284:E (ab|a|c|bcd){4,}(d*) ababcd NOMATCH +#:HA#285:E (ab|a|c|bcd){0,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#285:E (ab|a|c|bcd){0,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#286:E (ab|a|c|bcd){1,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#286:E (ab|a|c|bcd){1,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#287:E (ab|a|c|bcd){2,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#287:E (ab|a|c|bcd){2,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#288:E (ab|a|c|bcd){3,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#288:E (ab|a|c|bcd){3,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +:HA#289:E (ab|a|c|bcd){4,10}(d*) ababcd NOMATCH +#:HA#290:E (ab|a|c|bcd)*(d*) ababcd (0,6)(3,6)(6,6) +:HA#290:E (ab|a|c|bcd)*(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#291:E (ab|a|c|bcd)+(d*) ababcd (0,6)(3,6)(6,6) +:HA#291:E (ab|a|c|bcd)+(d*) ababcd (0,6)(4,5)(5,6) RE2/Go diff --git a/deps/regex-syntax-0.1.2/Cargo.toml b/deps/regex-syntax-0.1.2/Cargo.toml new file mode 100644 index 000000000..dc1f06fc5 --- /dev/null +++ b/deps/regex-syntax-0.1.2/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "regex-syntax" +version = "0.1.2" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang/regex" +documentation = "http://doc.rust-lang.org/regex" +homepage = "https://github.com/rust-lang/regex" +description = "A regular expression parser." + +[dev-dependencies] +quickcheck = "0.2" +rand = "0.3" diff --git a/deps/regex-syntax-0.1.2/src/lib.rs b/deps/regex-syntax-0.1.2/src/lib.rs new file mode 100644 index 000000000..ddbe7d6e9 --- /dev/null +++ b/deps/regex-syntax-0.1.2/src/lib.rs @@ -0,0 +1,1184 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! +This crate provides a regular expression parser and an abstract syntax for +regular expressions. The abstract syntax is defined by the `Expr` type. The +concrete syntax is enumerated in the +[`regex`](../regex/index.html#syntax) +crate documentation. + +Note that since this crate is first and foremost an implementation detail for +the `regex` crate, it may experience more frequent breaking changes. It is +exposed as a separate crate so that others may use it to do analysis on regular +expressions or even build their own matching engine. + +# Example: parsing an expression + +Parsing a regular expression can be done with the `Expr::parse` function. + +```rust +use regex_syntax::Expr; + +assert_eq!(Expr::parse(r"ab|yz").unwrap(), Expr::Alternate(vec![ + Expr::Literal { chars: vec!['a', 'b'], casei: false }, + Expr::Literal { chars: vec!['y', 'z'], casei: false }, +])); +``` + +# Example: inspecting an error + +The parser in this crate provides very detailed error values. For example, +if an invalid character class range is given: + +```rust +use regex_syntax::{Expr, ErrorKind}; + +let err = Expr::parse(r"[z-a]").unwrap_err(); +assert_eq!(err.position(), 4); +assert_eq!(err.kind(), &ErrorKind::InvalidClassRange { + start: 'z', + end: 'a', +}); +``` + +Or unbalanced parentheses: + +```rust +use regex_syntax::{Expr, ErrorKind}; + +let err = Expr::parse(r"ab(cd").unwrap_err(); +assert_eq!(err.position(), 2); +assert_eq!(err.kind(), &ErrorKind::UnclosedParen); +``` +*/ + +#![deny(missing_docs)] + +#[cfg(test)] extern crate quickcheck; +#[cfg(test)] extern crate rand; + +mod parser; +mod unicode; + +use std::char; +use std::cmp::{Ordering, max, min}; +use std::fmt; +use std::iter::IntoIterator; +use std::ops::Deref; +use std::slice; +use std::vec; + +use unicode::case_folding; + +use self::Expr::*; +use self::Repeater::*; + +pub use parser::is_punct; + +/// A regular expression abstract syntax tree. +/// +/// An `Expr` represents the abstract syntax of a regular expression. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Expr { + /// An empty regex (which never matches any text). + Empty, + /// A sequence of one or more literal characters to be matched. + Literal { + /// The characters. + chars: Vec<char>, + /// Whether to match case insensitively. + casei: bool, + }, + /// Match any character, excluding new line. + AnyChar, + /// Match any character. + AnyCharNoNL, + /// A character class. + Class(CharClass), + /// Match the start of a line or beginning of input. + StartLine, + /// Match the end of a line or end of input. + EndLine, + /// Match the beginning of input. + StartText, + /// Match the end of input. + EndText, + /// Match a word boundary (word character on one side and a non-word + /// character on the other). + WordBoundary, + /// Match a position that is not a word boundary (word or non-word + /// characters on both sides). + NotWordBoundary, + /// A group, possibly non-capturing. + Group { + /// The expression inside the group. + e: Box<Expr>, + /// The capture index (starting at `1`) only for capturing groups. + i: Option<usize>, + /// The capture name, only for capturing named groups. + name: Option<String>, + }, + /// A repeat operator (`?`, `*`, `+` or `{m,n}`). + Repeat { + /// The expression to be repeated. Limited to literals, `.`, classes + /// or grouped expressions. + e: Box<Expr>, + /// The type of repeat operator used. + r: Repeater, + /// Whether the repeat is greedy (match the most) or not (match the + /// least). + greedy: bool, + }, + /// A concatenation of expressions. Must be matched one after the other. + /// + /// N.B. A concat expression can only appear at the top-level or + /// immediately inside a group expression. + Concat(Vec<Expr>), + /// An alternation of expressions. Only one must match. + /// + /// N.B. An alternate expression can only appear at the top-level or + /// immediately inside a group expression. + Alternate(Vec<Expr>), +} + +type CaptureIndex = Option<usize>; + +type CaptureName = Option<String>; + +/// The type of a repeat operator expression. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Repeater { + /// Match zero or one (`?`). + ZeroOrOne, + /// Match zero or more (`*`). + ZeroOrMore, + /// Match one or more (`+`). + OneOrMore, + /// Match for at least `min` and at most `max` (`{m,n}`). + /// + /// When `max` is `None`, there is no upper bound on the number of matches. + Range { + /// Lower bound on the number of matches. + min: u32, + /// Optional upper bound on the number of matches. + max: Option<u32>, + }, +} + +/// A character class. +/// +/// A character class has a canonical format that the parser guarantees. Its +/// canonical format is defined by the following invariants: +/// +/// 1. Given any Unicode scalar value, it is matched by *at most* one character +/// range in a canonical character class. +/// 2. Every adjacent character range is separated by at least one Unicode +/// scalar value. +/// 3. Given any pair of character ranges `r1` and `r2`, if +/// `r1.end < r2.start`, then `r1` comes before `r2` in a canonical +/// character class. +/// +/// In sum, any `CharClass` produced by this crate's parser is a sorted +/// sequence of non-overlapping ranges. This makes it possible to test whether +/// a character is matched by a class with a binary search. +/// +/// Additionally, a character class may be marked *case insensitive*. If it's +/// case insensitive, then: +/// +/// 1. Simple case folding has been applied to all ranges. +/// 2. Simple case folding must be applied to a character before testing +/// whether it matches the character class. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct CharClass { + ranges: Vec<ClassRange>, + casei: bool, +} + +/// A single inclusive range in a character class. +/// +/// Since range boundaries are defined by Unicode scalar values, the boundaries +/// can never be in the open interval `(0xD7FF, 0xE000)`. However, a range may +/// *cover* codepoints that are not scalar values. +/// +/// Note that this has a few convenient impls on `PartialEq` and `PartialOrd` +/// for testing whether a character is contained inside a given range. +#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)] +pub struct ClassRange { + /// The start character of the range. + /// + /// This must be less than or equal to `end`. + pub start: char, + + /// The end character of the range. + /// + /// This must be greater than or equal to `end`. + pub end: char, +} + +impl Expr { + /// Parses a string in a regular expression syntax tree. + pub fn parse(s: &str) -> Result<Expr> { + parser::Parser::parse(s).map(|e| e.simplify()) + } + + /// Returns true iff the expression can be repeated by a quantifier. + fn can_repeat(&self) -> bool { + match *self { + Literal{..} + | AnyChar + | AnyCharNoNL + | Class(_) + | StartLine | EndLine | StartText | EndText + | WordBoundary | NotWordBoundary + | Group{..} + => true, + _ => false, + } + } + + fn simplify(self) -> Expr { + fn combine_literals(es: &mut Vec<Expr>, e: Expr) { + match (es.pop(), e) { + (None, e) => es.push(e), + (Some(Literal { chars: mut chars1, casei: casei1 }), + Literal { chars: chars2, casei: casei2 }) => { + if casei1 == casei2 { + chars1.extend(chars2); + es.push(Literal { chars: chars1, casei: casei1 }); + } else { + es.push(Literal { chars: chars1, casei: casei1 }); + es.push(Literal { chars: chars2, casei: casei2 }); + } + } + (Some(e1), e2) => { + es.push(e1); + es.push(e2); + } + } + } + match self { + Repeat { e, r, greedy } => Repeat { + e: Box::new(e.simplify()), + r: r, + greedy: greedy, + }, + Group { e, i, name } => { + let e = e.simplify(); + if i.is_none() && name.is_none() && e.can_repeat() { + e + } else { + Group { e: Box::new(e), i: i, name: name } + } + } + Concat(es) => { + let mut new_es = Vec::with_capacity(es.len()); + for e in es { + combine_literals(&mut new_es, e.simplify()); + } + if new_es.len() == 1 { + new_es.pop().unwrap() + } else { + Concat(new_es) + } + } + Alternate(es) => Alternate(es.into_iter() + .map(|e| e.simplify()) + .collect()), + e => e, + } + } +} + +impl Deref for CharClass { + type Target = Vec<ClassRange>; + fn deref(&self) -> &Vec<ClassRange> { &self.ranges } +} + +impl IntoIterator for CharClass { + type Item = ClassRange; + type IntoIter = vec::IntoIter<ClassRange>; + fn into_iter(self) -> vec::IntoIter<ClassRange> { self.ranges.into_iter() } +} + +impl<'a> IntoIterator for &'a CharClass { + type Item = &'a ClassRange; + type IntoIter = slice::Iter<'a, ClassRange>; + fn into_iter(self) -> slice::Iter<'a, ClassRange> { self.iter() } +} + +impl CharClass { + /// Create a new class from an existing set of ranges. + fn new(ranges: Vec<ClassRange>) -> CharClass { + CharClass { ranges: ranges, casei: false } + } + + /// Create an empty class. + fn empty() -> CharClass { + CharClass::new(Vec::new()) + } + + /// Returns true if `c` is matched by this character class. + /// + /// If this character class is case insensitive, then simple case folding + /// is applied to `c` before checking for a match. + pub fn matches(&self, mut c: char) -> bool { + if self.is_case_insensitive() { + c = simple_case_fold(c) + } + self.binary_search_by(|range| c.partial_cmp(range).unwrap()).is_ok() + } + + /// Returns true if this character class should be matched case + /// insensitively. + /// + /// When `true`, simple case folding has already been applied to the + /// class. + pub fn is_case_insensitive(&self) -> bool { + self.casei + } + + /// Create a new empty class from this one. + /// + /// Namely, its capacity and case insensitive setting will be the same. + fn to_empty(&self) -> CharClass { + CharClass { ranges: Vec::with_capacity(self.len()), casei: self.casei } + } + + /// Merge two classes and canonicalize them. + #[cfg(test)] + fn merge(mut self, other: CharClass) -> CharClass { + self.ranges.extend(other); + self.canonicalize() + } + + /// Canonicalze any sequence of ranges. + /// + /// This is responsible for enforcing the canonical format invariants + /// as described on the docs for the `CharClass` type. + fn canonicalize(mut self) -> CharClass { + // TODO: Save some cycles here by checking if already canonicalized. + self.ranges.sort(); + let mut ordered = self.to_empty(); // TODO: Do this in place? + for candidate in self { + // If the candidate overlaps with an existing range, then it must + // be the most recent range added because we process the candidates + // in order. + if let Some(or) = ordered.ranges.last_mut() { + if or.overlapping(candidate) { + *or = or.merge(candidate); + continue; + } + } + ordered.ranges.push(candidate); + } + ordered + } + + /// Negates the character class. + /// + /// For all `c` where `c` is a Unicode scalar value, `c` matches `self` + /// if and only if `c` does not match `self.negate()`. + /// + /// Note that this cannot be called on a character class that has had + /// case folding applied to it. (Because case folding turns on a flag + /// and doesn't store every possible matching character. Therefore, + /// its negation is tricky to get right. Turns out, we don't need it + /// anyway!) + fn negate(mut self) -> CharClass { + fn range(s: char, e: char) -> ClassRange { ClassRange::new(s, e) } + + // Never allow negating of a class that has been case folded! + assert!(!self.casei); + + if self.is_empty() { return self; } + self = self.canonicalize(); + let mut inv = self.to_empty(); + if self[0].start > '\x00' { + inv.ranges.push(range('\x00', dec_char(self[0].start))); + } + for win in self.windows(2) { + inv.ranges.push(range(inc_char(win[0].end), + dec_char(win[1].start))); + } + if self[self.len() - 1].end < char::MAX { + inv.ranges.push(range(inc_char(self[self.len() - 1].end), + char::MAX)); + } + inv + } + + /// Apply case folding to this character class. + /// + /// One a class had been case folded, it cannot be negated. + fn case_fold(self) -> CharClass { + let mut folded = self.to_empty(); + folded.casei = true; + for r in self { + // Applying case folding to a range is expensive because *every* + // character needed to be examined. Thus, we avoid that drudgery + // if no character in the current range is in our case folding + // table. + if r.needs_case_folding() { + folded.ranges.extend(r.case_fold()); + } else { + folded.ranges.push(r); + } + } + folded.canonicalize() + } +} + +impl ClassRange { + /// Create a new class range. + /// + /// If `end < start`, then the two values are swapped so that + /// the invariant `start <= end` is preserved. + fn new(start: char, end: char) -> ClassRange { + if start <= end { + ClassRange { start: start, end: end } + } else { + ClassRange { start: end, end: start } + } + } + + /// Create a range of one character. + fn one(c: char) -> ClassRange { + ClassRange { start: c, end: c } + } + + /// Returns true if and only if the two ranges are overlapping. Note that + /// since ranges are inclusive, `a-c` and `d-f` are overlapping! + fn overlapping(self, other: ClassRange) -> bool { + max(self.start, other.start) <= inc_char(min(self.end, other.end)) + } + + /// Creates a new range representing the union of `self` and `other. + fn merge(self, other: ClassRange) -> ClassRange { + ClassRange { + start: min(self.start, other.start), + end: max(self.end, other.end), + } + } + + /// Returns true if and only if this range contains a character that is + /// in the case folding table. + fn needs_case_folding(self) -> bool { + case_folding::C_plus_S_table + .binary_search_by(|&(c, _)| self.partial_cmp(&c).unwrap()).is_ok() + } + + /// Apply case folding to this range. + /// + /// Since case folding might add characters such that the range is no + /// longer contiguous, this returns multiple class ranges. They are in + /// canonical order. + fn case_fold(self) -> Vec<ClassRange> { + let (s, e) = (self.start as u32, self.end as u32 + 1); + let mut start = simple_case_fold(self.start); + let mut end = start; + let mut next_case_fold = self.start; + let mut ranges = Vec::with_capacity(100); + for mut c in (s+1..e).filter_map(char::from_u32) { + if c >= next_case_fold { + c = match simple_case_fold_result(c) { + Ok(i) => case_folding::C_plus_S_table[i].1, + Err(i) => { + if i < case_folding::C_plus_S_table.len() { + next_case_fold = case_folding::C_plus_S_table[i].0; + } else { + next_case_fold = '\u{10FFFF}' + } + c + } + }; + } + if c != inc_char(end) { + ranges.push(ClassRange::new(start, end)); + start = c; + } + end = c; + } + ranges.push(ClassRange::new(start, end)); + ranges + } +} + +impl PartialEq<char> for ClassRange { + #[inline] + fn eq(&self, other: &char) -> bool { + self.start <= *other && *other <= self.end + } +} + +impl PartialEq<ClassRange> for char { + #[inline] + fn eq(&self, other: &ClassRange) -> bool { + other.eq(self) + } +} + +impl PartialOrd<char> for ClassRange { + #[inline] + fn partial_cmp(&self, other: &char) -> Option<Ordering> { + Some(if self == other { + Ordering::Equal + } else if *other > self.end { + Ordering::Greater + } else { + Ordering::Less + }) + } +} + +impl PartialOrd<ClassRange> for char { + #[inline] + fn partial_cmp(&self, other: &ClassRange) -> Option<Ordering> { + other.partial_cmp(self).map(|o| o.reverse()) + } +} + +/// This implementation of `Display` will write a regular expression from the +/// syntax tree. It does not write the original string parsed. +impl fmt::Display for Expr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Empty => write!(f, ""), + Literal { ref chars, casei } => { + if casei { try!(write!(f, "(?i:")); } + for &c in chars { + try!(write!(f, "{}", quote_char(c))); + } + if casei { try!(write!(f, ")")); } + Ok(()) + } + AnyChar => write!(f, "(?s:.)"), + AnyCharNoNL => write!(f, "."), + Class(ref cls) => write!(f, "{}", cls), + StartLine => write!(f, "(?m:^)"), + EndLine => write!(f, "(?m:$)"), + StartText => write!(f, r"^"), + EndText => write!(f, r"$"), + WordBoundary => write!(f, r"\b"), + NotWordBoundary => write!(f, r"\B"), + Group { ref e, i: None, name: None } => write!(f, "(?:{})", e), + Group { ref e, name: None, .. } => write!(f, "({})", e), + Group { ref e, name: Some(ref n), .. } => { + write!(f, "(?P<{}>{})", n, e) + } + Repeat { ref e, r, greedy } => { + match &**e { + &Literal { ref chars, .. } if chars.len() > 1 => { + try!(write!(f, "(?:{}){}", e, r)) + } + _ => try!(write!(f, "{}{}", e, r)), + } + if !greedy { try!(write!(f, "?")); } + Ok(()) + } + Concat(ref es) => { + for e in es { + try!(write!(f, "{}", e)); + } + Ok(()) + } + Alternate(ref es) => { + for (i, e) in es.iter().enumerate() { + if i > 0 { try!(write!(f, "|")); } + try!(write!(f, "{}", e)); + } + Ok(()) + } + } + } +} + +impl fmt::Display for Repeater { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + ZeroOrOne => write!(f, "?"), + ZeroOrMore => write!(f, "*"), + OneOrMore => write!(f, "+"), + Range { min: s, max: None } => write!(f, "{{{},}}", s), + Range { min: s, max: Some(e) } if s == e => write!(f, "{{{}}}", s), + Range { min: s, max: Some(e) } => write!(f, "{{{}, {}}}", s, e), + } + } +} + +impl fmt::Display for CharClass { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.casei { + try!(write!(f, "(?i:")); + } + try!(write!(f, "[")); + for range in self.iter() { + try!(write!(f, "{}", range)); + } + try!(write!(f, "]")); + if self.casei { + try!(write!(f, ")")); + } + Ok(()) + } +} + +impl fmt::Display for ClassRange { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}-{}", quote_char(self.start), quote_char(self.end)) + } +} + +/// An alias for computations that can return a `Error`. +pub type Result<T> = ::std::result::Result<T, Error>; + +/// A parse error. +/// +/// This includes details about the specific type of error and a rough +/// approximation of where it occurred. +#[derive(Clone, Debug, PartialEq)] +pub struct Error { + pos: usize, + surround: String, + kind: ErrorKind, +} + +/// The specific type of parse error that can occur. +#[derive(Clone, Debug, PartialEq)] +pub enum ErrorKind { + /// A negation symbol is used twice in flag settings. + /// e.g., `(?-i-s)`. + DoubleFlagNegation, + /// The same capture name was used more than once. + /// e.g., `(?P<a>.)(?P<a>.)`. + DuplicateCaptureName(String), + /// An alternate is empty. e.g., `(|a)`. + EmptyAlternate, + /// A capture group name is empty. e.g., `(?P<>a)`. + EmptyCaptureName, + /// A negation symbol was not proceded by any flags. e.g., `(?i-)`. + EmptyFlagNegation, + /// A group is empty. e.g., `()`. + EmptyGroup, + /// An invalid number was used in a counted repetition. e.g., `a{b}`. + InvalidBase10(String), + /// An invalid hexadecimal number was used in an escape sequence. + /// e.g., `\xAG`. + InvalidBase16(String), + /// An invalid capture name was used. e.g., `(?P<0a>b)`. + InvalidCaptureName(String), + /// An invalid class range was givien. Specifically, when the start of the + /// range is greater than the end. e.g., `[z-a]`. + InvalidClassRange { + /// The first character specified in the range. + start: char, + /// The second character specified in the range. + end: char, + }, + /// An escape sequence was used in a character class where it is not + /// allowed. e.g., `[a-\pN]` or `[\A]`. + InvalidClassEscape(Expr), + /// An invalid counted repetition min/max was given. e.g., `a{2,1}`. + InvalidRepeatRange { + /// The first number specified in the repetition. + min: u32, + /// The second number specified in the repetition. + max: u32, + }, + /// An invalid Unicode scalar value was used in a long hexadecimal + /// sequence. e.g., `\x{D800}`. + InvalidScalarValue(u32), + /// An empty counted repetition operator. e.g., `a{}`. + MissingBase10, + /// A repetition operator was not applied to an expression. e.g., `*`. + RepeaterExpectsExpr, + /// A repetition operator was applied to an expression that cannot be + /// repeated. e.g., `a+*` or `a|*`. + RepeaterUnexpectedExpr(Expr), + /// A capture group name that is never closed. e.g., `(?P<a`. + UnclosedCaptureName(String), + /// An unclosed hexadecimal literal. e.g., `\x{a`. + UnclosedHex, + /// An unclosed parenthesis. e.g., `(a`. + UnclosedParen, + /// An unclosed counted repetition operator. e.g., `a{2`. + UnclosedRepeat, + /// An unclosed named Unicode class. e.g., `\p{Yi`. + UnclosedUnicodeName, + /// Saw end of regex before class was closed. e.g., `[a`. + UnexpectedClassEof, + /// Saw end of regex before escape sequence was closed. e.g., `\`. + UnexpectedEscapeEof, + /// Saw end of regex before flags were closed. e.g., `(?i`. + UnexpectedFlagEof, + /// Saw end of regex before two hexadecimal digits were seen. e.g., `\xA`. + UnexpectedTwoDigitHexEof, + /// Unopened parenthesis. e.g., `)`. + UnopenedParen, + /// Unrecognized escape sequence. e.g., `\q`. + UnrecognizedEscape(char), + /// Unrecognized flag. e.g., `(?a)`. + UnrecognizedFlag(char), + /// Unrecognized named Unicode class. e.g., `\p{Foo}`. + UnrecognizedUnicodeClass(String), + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl Error { + /// Returns an approximate *character* offset at which the error occurred. + /// + /// The character offset may be equal to the number of characters in the + /// string, in which case it should be interpreted as pointing to the end + /// of the regex. + pub fn position(&self) -> usize { + self.pos + } + + /// Returns the type of the regex parse error. + pub fn kind(&self) -> &ErrorKind { + &self.kind + } +} + +impl ErrorKind { + fn description(&self) -> &str { + use ErrorKind::*; + match *self { + DoubleFlagNegation => "double flag negation", + DuplicateCaptureName(_) => "duplicate capture name", + EmptyAlternate => "empty alternate", + EmptyCaptureName => "empty capture name", + EmptyFlagNegation => "flag negation without any flags", + EmptyGroup => "empty group (e.g., '()')", + InvalidBase10(_) => "invalid base 10 number", + InvalidBase16(_) => "invalid base 16 number", + InvalidCaptureName(_) => "invalid capture name", + InvalidClassRange{..} => "invalid character class range", + InvalidClassEscape(_) => "invalid escape sequence in class", + InvalidRepeatRange{..} => "invalid counted repetition range", + InvalidScalarValue(_) => "invalid Unicode scalar value", + MissingBase10 => "missing count in repetition operator", + RepeaterExpectsExpr => "repetition operator missing expression", + RepeaterUnexpectedExpr(_) => "expression cannot be repeated", + UnclosedCaptureName(_) => "unclosed capture group name", + UnclosedHex => "unclosed hexadecimal literal", + UnclosedParen => "unclosed parenthesis", + UnclosedRepeat => "unclosed counted repetition operator", + UnclosedUnicodeName => "unclosed Unicode class literal", + UnexpectedClassEof => "unexpected EOF in character class", + UnexpectedEscapeEof => "unexpected EOF in escape sequence", + UnexpectedFlagEof => "unexpected EOF in flags", + UnexpectedTwoDigitHexEof => "unexpected EOF in hex literal", + UnopenedParen => "unopened parenthesis", + UnrecognizedEscape(_) => "unrecognized escape sequence", + UnrecognizedFlag(_) => "unrecognized flag", + UnrecognizedUnicodeClass(_) => "unrecognized Unicode class name", + __Nonexhaustive => unreachable!(), + } + } +} + +impl ::std::error::Error for Error { + fn description(&self) -> &str { + self.kind.description() + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Error parsing regex near '{}' at character offset {}: {}", + self.surround, self.pos, self.kind) + } +} + +impl fmt::Display for ErrorKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ErrorKind::*; + match *self { + DoubleFlagNegation => + write!(f, "Only one negation symbol is allowed in flags."), + DuplicateCaptureName(ref s) => + write!(f, "Capture name '{}' is used more than once.", s), + EmptyAlternate => + write!(f, "Alternations cannot be empty."), + EmptyCaptureName => + write!(f, "Capture names cannot be empty."), + EmptyFlagNegation => + write!(f, "Flag negation requires setting at least one flag."), + EmptyGroup => + write!(f, "Empty regex groups (e.g., '()') are not allowed."), + InvalidBase10(ref s) => + write!(f, "Not a valid base 10 number: '{}'", s), + InvalidBase16(ref s) => + write!(f, "Not a valid base 16 number: '{}'", s), + InvalidCaptureName(ref s) => + write!(f, "Invalid capture name: '{}'. Capture names must \ + consist of [_a-zA-Z0-9] and are not allowed to \ + start with with a number.", s), + InvalidClassRange { start, end } => + write!(f, "Invalid character class range '{}-{}'. \ + Character class ranges must start with the smaller \ + character, but {} > {}", start, end, start, end), + InvalidClassEscape(ref e) => + write!(f, "Invalid escape sequence in character \ + class: '{}'.", e), + InvalidRepeatRange { min, max } => + write!(f, "Invalid counted repetition range: {{{}, {}}}. \ + Counted repetition ranges must start with the \ + minimum, but {} > {}", min, max, min, max), + InvalidScalarValue(c) => + write!(f, "Number does not correspond to a Unicode scalar \ + value: '{}'.", c), + MissingBase10 => + write!(f, "Missing maximum in counted reptition operator."), + RepeaterExpectsExpr => + write!(f, "Missing expression for reptition operator."), + RepeaterUnexpectedExpr(ref e) => + write!(f, "Invalid application of reptition operator to: \ + '{}'.", e), + UnclosedCaptureName(ref s) => + write!(f, "Capture name group for '{}' is not closed. \ + (Missing a '>'.)", s), + UnclosedHex => + write!(f, "Unclosed hexadecimal literal (missing a '}}')."), + UnclosedParen => + write!(f, "Unclosed parenthesis."), + UnclosedRepeat => + write!(f, "Unclosed counted repetition (missing a '}}')."), + UnclosedUnicodeName => + write!(f, "Unclosed Unicode literal (missing a '}}')."), + UnexpectedClassEof => + write!(f, "Character class was not closed before the end of \ + the regex (missing a ']')."), + UnexpectedEscapeEof => + write!(f, "Started an escape sequence that didn't finish \ + before the end of the regex."), + UnexpectedFlagEof => + write!(f, "Inline flag settings was not closed before the end \ + of the regex (missing a ')' or ':')."), + UnexpectedTwoDigitHexEof => + write!(f, "Unexpected end of two digit hexadecimal literal."), + UnopenedParen => + write!(f, "Unopened parenthesis."), + UnrecognizedEscape(c) => + write!(f, "Unrecognized escape sequence: '\\{}'.", c), + UnrecognizedFlag(c) => + write!(f, "Unrecognized flag: '{}'. \ + (Allowed flags: i, s, m, U, x.)", c), + UnrecognizedUnicodeClass(ref s) => + write!(f, "Unrecognized Unicode class name: '{}'.", s), + __Nonexhaustive => unreachable!(), + } + } +} + +/// Returns the Unicode *simple* case folding of `c`. +/// +/// N.B. This is hidden because it really isn't the responsibility of this +/// crate to do simple case folding. One hopes that either another crate or +/// the standard library will be able to do this for us. In any case, we still +/// expose it because it is used inside the various Regex engines. +#[doc(hidden)] +pub fn simple_case_fold(c: char) -> char { + simple_case_fold_result(c) + .map(|i| case_folding::C_plus_S_table[i].1) + .unwrap_or(c) +} + +/// The result of binary search on the simple case folding table. +/// +/// This level of detail is exposed so that we can do case folding on a +/// range of characters efficiently. +fn simple_case_fold_result(c: char) -> ::std::result::Result<usize, usize> { + case_folding::C_plus_S_table.binary_search_by(|&(x, _)| x.cmp(&c)) +} + +/// Escapes all regular expression meta characters in `text`. +/// +/// The string returned may be safely used as a literal in a regular +/// expression. +pub fn quote(text: &str) -> String { + let mut quoted = String::with_capacity(text.len()); + for c in text.chars() { + if parser::is_punct(c) { + quoted.push('\\'); + } + quoted.push(c); + } + quoted +} + +fn quote_char(c: char) -> String { + let mut s = String::new(); + if parser::is_punct(c) { + s.push('\\'); + } + s.push(c); + s +} + +fn inc_char(c: char) -> char { + match c { + char::MAX => char::MAX, + '\u{D7FF}' => '\u{E000}', + c => char::from_u32(c as u32 + 1).unwrap(), + } +} + +fn dec_char(c: char) -> char { + match c { + '\x00' => '\x00', + '\u{E000}' => '\u{D7FF}', + c => char::from_u32(c as u32 - 1).unwrap(), + } +} + +/// Returns true if and only if `c` is a word character. +#[doc(hidden)] +pub fn is_word_char(c: char) -> bool { + match c { + '_' | '0' ... '9' | 'a' ... 'z' | 'A' ... 'Z' => true, + _ => ::unicode::regex::PERLW.binary_search_by(|&(start, end)| { + if c >= start && c <= end { + Ordering::Equal + } else if start > c { + Ordering::Greater + } else { + Ordering::Less + } + }).is_ok(), + } +} + +#[cfg(test)] +mod properties; + +#[cfg(test)] +mod tests { + use {CharClass, ClassRange}; + + fn class(ranges: &[(char, char)]) -> CharClass { + let ranges = ranges.iter().cloned() + .map(|(c1, c2)| ClassRange::new(c1, c2)).collect(); + CharClass::new(ranges) + } + + fn classi(ranges: &[(char, char)]) -> CharClass { + let mut cls = class(ranges); + cls.casei = true; + cls + } + + #[test] + fn class_canon_no_change() { + let cls = class(&[('a', 'c'), ('x', 'z')]); + assert_eq!(cls.clone().canonicalize(), cls); + } + + #[test] + fn class_canon_unordered() { + let cls = class(&[('x', 'z'), ('a', 'c')]); + assert_eq!(cls.canonicalize(), class(&[ + ('a', 'c'), ('x', 'z'), + ])); + } + + #[test] + fn class_canon_overlap() { + let cls = class(&[('x', 'z'), ('w', 'y')]); + assert_eq!(cls.canonicalize(), class(&[ + ('w', 'z'), + ])); + } + + #[test] + fn class_canon_overlap_many() { + let cls = class(&[ + ('c', 'f'), ('a', 'g'), ('d', 'j'), ('a', 'c'), + ('m', 'p'), ('l', 's'), + ]); + assert_eq!(cls.clone().canonicalize(), class(&[ + ('a', 'j'), ('l', 's'), + ])); + } + + #[test] + fn class_canon_overlap_many_case_fold() { + let cls = class(&[ + ('C', 'F'), ('A', 'G'), ('D', 'J'), ('A', 'C'), + ('M', 'P'), ('L', 'S'), ('c', 'f'), + ]); + assert_eq!(cls.case_fold(), classi(&[ + ('a', 'j'), ('l', 's'), + ])); + } + + #[test] + fn class_canon_overlap_boundary() { + let cls = class(&[('x', 'z'), ('u', 'w')]); + assert_eq!(cls.canonicalize(), class(&[ + ('u', 'z'), + ])); + } + + #[test] + fn class_canon_extreme_edge_case() { + let cls = class(&[('\x00', '\u{10FFFF}'), ('\x00', '\u{10FFFF}')]); + assert_eq!(cls.canonicalize(), class(&[ + ('\x00', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_canon_singles() { + let cls = class(&[('a', 'a'), ('b', 'b')]); + assert_eq!(cls.canonicalize(), class(&[('a', 'b')])); + } + + #[test] + fn class_negate_single() { + let cls = class(&[('a', 'a')]); + assert_eq!(cls.negate(), class(&[ + ('\x00', '\x60'), ('\x62', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_negate_singles() { + let cls = class(&[('a', 'a'), ('b', 'b')]); + assert_eq!(cls.negate(), class(&[ + ('\x00', '\x60'), ('\x63', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_negate_multiples() { + let cls = class(&[('a', 'c'), ('x', 'z')]); + assert_eq!(cls.negate(), class(&[ + ('\x00', '\x60'), ('\x64', '\x77'), ('\x7b', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_negate_min_scalar() { + let cls = class(&[('\x00', 'a')]); + assert_eq!(cls.negate(), class(&[ + ('\x62', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_negate_max_scalar() { + let cls = class(&[('a', '\u{10FFFF}')]); + assert_eq!(cls.negate(), class(&[ + ('\x00', '\x60'), + ])); + } + + #[test] + fn class_negate_everything() { + let cls = class(&[('\x00', '\u{10FFFF}')]); + assert_eq!(cls.negate(), class(&[])); + } + + #[test] + fn class_negate_everything_sans_one() { + let cls = class(&[ + ('\x00', '\u{10FFFD}'), ('\u{10FFFF}', '\u{10FFFF}') + ]); + assert_eq!(cls.negate(), class(&[ + ('\u{10FFFE}', '\u{10FFFE}'), + ])); + } + + #[test] + fn class_negate_surrogates_min() { + let cls = class(&[('\x00', '\u{D7FF}')]); + assert_eq!(cls.negate(), class(&[ + ('\u{E000}', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_negate_surrogates_min_edge() { + let cls = class(&[('\x00', '\u{D7FE}')]); + assert_eq!(cls.negate(), class(&[ + ('\u{D7FF}', '\u{10FFFF}'), + ])); + } + + #[test] + fn class_negate_surrogates_max() { + let cls = class(&[('\u{E000}', '\u{10FFFF}')]); + assert_eq!(cls.negate(), class(&[ + ('\x00', '\u{D7FF}'), + ])); + } + + #[test] + fn class_negate_surrogates_max_edge() { + let cls = class(&[('\u{E001}', '\u{10FFFF}')]); + assert_eq!(cls.negate(), class(&[ + ('\x00', '\u{E000}'), + ])); + } + + #[test] + fn class_fold_retain_only_needed() { + let cls = class(&[('A', 'Z'), ('a', 'z')]); + assert_eq!(cls.case_fold(), classi(&[ + ('a', 'z'), + ])); + } + + #[test] + fn class_fold_az() { + let cls = class(&[('A', 'Z')]); + assert_eq!(cls.case_fold(), classi(&[ + ('a', 'z'), + ])); + } + + #[test] + fn class_fold_a_underscore() { + let cls = class(&[('A', 'A'), ('_', '_')]); + assert_eq!(cls.clone().canonicalize(), class(&[ + ('A', 'A'), ('_', '_'), + ])); + assert_eq!(cls.case_fold(), classi(&[ + ('_', '_'), ('a', 'a'), + ])); + } + + #[test] + fn class_fold_a_equals() { + let cls = class(&[('A', 'A'), ('=', '=')]); + assert_eq!(cls.clone().canonicalize(), class(&[ + ('=', '='), ('A', 'A'), + ])); + assert_eq!(cls.case_fold(), classi(&[ + ('=', '='), ('a', 'a'), + ])); + } + + #[test] + fn class_fold_no_folding_needed() { + let cls = class(&[('\x00', '\x10')]); + assert_eq!(cls.case_fold(), classi(&[ + ('\x00', '\x10'), + ])); + } +} diff --git a/deps/regex-syntax-0.1.2/src/parser.rs b/deps/regex-syntax-0.1.2/src/parser.rs new file mode 100644 index 000000000..f4c22285c --- /dev/null +++ b/deps/regex-syntax-0.1.2/src/parser.rs @@ -0,0 +1,2327 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cmp::{max, min}; + +use unicode::regex::UNICODE_CLASSES; + +use { + Expr, Repeater, CharClass, ClassRange, CaptureIndex, CaptureName, + Error, ErrorKind, Result, +}; + +/// Parser state. +/// +/// Keeps the entire input in memory and maintains a cursor (char offset). +/// +/// It also keeps an expression stack, which is responsible for managing +/// grouped expressions and flag state. +#[derive(Debug)] +pub struct Parser { + chars: Vec<char>, + chari: usize, + stack: Vec<Build>, + caps: usize, + names: Vec<String>, // to check for duplicates + flags: Flags, +} + +/// An empheral type for representing the expression stack. +/// +/// Everything on the stack is either a regular expression or a marker +/// indicating the opening of a group (possibly non-capturing). The opening +/// of a group copies the current flag state, which is reset on the parser +/// state once the group closes. +#[derive(Debug)] +enum Build { + Expr(Expr), + LeftParen { + i: CaptureIndex, + name: CaptureName, + chari: usize, + old_flags: Flags, + }, +} + +/// Flag state. +#[derive(Clone, Copy, Debug)] +struct Flags { + casei: bool, + multi: bool, + dotnl: bool, + swap_greed: bool, + ignore_space: bool, +} + +// Primary expression parsing routines. +impl Parser { + pub fn parse(s: &str) -> Result<Expr> { + Parser { + chars: s.chars().collect(), + chari: 0, + stack: vec![], + caps: 0, + names: vec![], + flags: Flags { + casei: false, + multi: false, + dotnl: false, + swap_greed: false, + ignore_space: false, + }, + }.parse_expr() + } + + // Top-level expression parser. + // + // Starts at the beginning of the input and consumes until either the end + // of input or an error. + fn parse_expr(mut self) -> Result<Expr> { + while !self.eof() { + let build_expr = match self.cur() { + '\\' => try!(self.parse_escape()), + '|' => { let e = try!(self.alternate()); self.bump(); e } + '?' => try!(self.parse_simple_repeat(Repeater::ZeroOrOne)), + '*' => try!(self.parse_simple_repeat(Repeater::ZeroOrMore)), + '+' => try!(self.parse_simple_repeat(Repeater::OneOrMore)), + '{' => try!(self.parse_counted_repeat()), + '[' => match self.maybe_parse_ascii() { + None => try!(self.parse_class()), + Some(cls) => Build::Expr(Expr::Class(cls)), + }, + '^' => { + if self.flags.multi { + self.parse_one(Expr::StartLine) + } else { + self.parse_one(Expr::StartText) + } + } + '$' => { + if self.flags.multi { + self.parse_one(Expr::EndLine) + } else { + self.parse_one(Expr::EndText) + } + } + '.' => { + if self.flags.dotnl { + self.parse_one(Expr::AnyChar) + } else { + self.parse_one(Expr::AnyCharNoNL) + } + } + '(' => try!(self.parse_group()), + ')' => { + let (old_flags, e) = try!(self.close_paren()); + self.bump(); + self.flags = old_flags; + e + } + _ => Build::Expr(Expr::Literal { + chars: vec![self.bump()], + casei: self.flags.casei, + }), + }; + if !build_expr.is_empty() { + let build_expr = self.maybe_class_case_fold(build_expr); + self.stack.push(build_expr); + } + } + self.finish_concat() + } + + // Parses an escape sequence, e.g., \Ax + // + // Start: `\` + // End: `x` + fn parse_escape(&mut self) -> Result<Build> { + self.bump(); + if self.eof() { + return Err(self.err(ErrorKind::UnexpectedEscapeEof)); + } + let c = self.cur(); + if is_punct(c) { + return Ok(Build::Expr(Expr::Literal { + chars: vec![self.bump()], + casei: self.flags.casei, + })); + } + + fn lit(c: char) -> Build { + Build::Expr(Expr::Literal { chars: vec![c], casei: false }) + } + match c { + 'a' => { self.bump(); Ok(lit('\x07')) } + 'f' => { self.bump(); Ok(lit('\x0C')) } + 't' => { self.bump(); Ok(lit('\t')) } + 'n' => { self.bump(); Ok(lit('\n')) } + 'r' => { self.bump(); Ok(lit('\r')) } + 'v' => { self.bump(); Ok(lit('\x0B')) } + 'A' => { self.bump(); Ok(Build::Expr(Expr::StartText)) } + 'z' => { self.bump(); Ok(Build::Expr(Expr::EndText)) } + 'b' => { self.bump(); Ok(Build::Expr(Expr::WordBoundary)) } + 'B' => { self.bump(); Ok(Build::Expr(Expr::NotWordBoundary)) } + '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7' => self.parse_octal(), + 'x' => { self.bump(); self.parse_hex() } + 'p'|'P' => { + self.bump(); + self.parse_unicode_class(c == 'P') + .map(|cls| Build::Expr(Expr::Class(cls))) + } + 'd'|'s'|'w'|'D'|'S'|'W' => { + self.bump(); + Ok(Build::Expr(Expr::Class(self.parse_perl_class(c)))) + } + c => Err(self.err(ErrorKind::UnrecognizedEscape(c))), + } + } + + // Parses a group, e.g., `(abc)`. + // + // Start: `(` + // End: `a` + // + // A more interesting example, `(?P<foo>abc)`. + // + // Start: `(` + // End: `a` + fn parse_group(&mut self) -> Result<Build> { + let chari = self.chari; + let mut name: CaptureName = None; + self.bump(); + if self.bump_if("?P<") { + let n = try!(self.parse_group_name()); + if self.names.iter().any(|n2| n2 == &n) { + return Err(self.err(ErrorKind::DuplicateCaptureName(n))); + } + self.names.push(n.clone()); + name = Some(n); + } else if self.bump_if("?") { + // This can never be capturing. It's either setting flags for + // the current group, or it's opening a non-capturing group or + // it's opening a group with a specific set of flags (which is + // also non-capturing). + // Anything else is an error. + return self.parse_group_flags(chari); + } + self.caps = checkadd(self.caps, 1); + Ok(Build::LeftParen { + i: Some(self.caps), + name: name, + chari: chari, + old_flags: self.flags, // no flags changed if we're here + }) + } + + // Parses flags (inline or grouped), e.g., `(?s-i:abc)`. + // + // Start: `s` + // End: `a` + // + // Another example, `(?s-i)a`. + // + // Start: `s` + // End: `a` + fn parse_group_flags(&mut self, opening_chari: usize) -> Result<Build> { + let old_flags = self.flags; + let mut sign = true; + let mut saw_flag = false; + loop { + if self.eof() { + // e.g., (?i + return Err(self.err(ErrorKind::UnexpectedFlagEof)); + } + match self.cur() { + 'i' => { self.flags.casei = sign; saw_flag = true } + 'm' => { self.flags.multi = sign; saw_flag = true } + 's' => { self.flags.dotnl = sign; saw_flag = true } + 'U' => { self.flags.swap_greed = sign; saw_flag = true } + 'x' => { self.flags.ignore_space = sign; saw_flag = true } + '-' => { + if !sign { + // e.g., (?-i-s) + return Err(self.err(ErrorKind::DoubleFlagNegation)); + } + sign = false; + saw_flag = false; + } + ')' => { + if !saw_flag { + // e.g., (?) + return Err(self.err(ErrorKind::EmptyFlagNegation)); + } + // At this point, we're just changing the flags inside + // the current group, which means the old flags have + // been saved elsewhere. Our modifications in place are + // okey dokey! + // + // This particular flag expression only has a stateful + // impact on a regex's AST, so nothing gets explicitly + // added. + self.bump(); + return Ok(Build::Expr(Expr::Empty)); + } + ':' => { + if !sign && !saw_flag { + // e.g., (?i-:a) + // Note that if there's no negation, it's OK not + // to see flag, because you end up with a regular + // non-capturing group: `(?:a)`. + return Err(self.err(ErrorKind::EmptyFlagNegation)); + } + self.bump(); + return Ok(Build::LeftParen { + i: None, + name: None, + chari: opening_chari, + old_flags: old_flags, + }); + } + // e.g., (?z:a) + c => return Err(self.err(ErrorKind::UnrecognizedFlag(c))), + } + self.bump(); + } + } + + // Parses a group name, e.g., `foo` in `(?P<foo>abc)`. + // + // Start: `f` + // End: `a` + fn parse_group_name(&mut self) -> Result<String> { + let mut name = String::new(); + while !self.eof() && !self.peek_is('>') { + name.push(self.bump()); + } + if self.eof() { + // e.g., (?P<a + return Err(self.err(ErrorKind::UnclosedCaptureName(name))); + } + let all_valid = name.chars().all(is_valid_capture_char); + match name.chars().next() { + // e.g., (?P<>a) + None => Err(self.err(ErrorKind::EmptyCaptureName)), + Some(c) if (c >= '0' && c <= '9') || !all_valid => { + // e.g., (?P<a#>x) + // e.g., (?P<1a>x) + Err(self.err(ErrorKind::InvalidCaptureName(name))) + } + _ => { + self.bump(); // for `>` + Ok(name) + } + } + } + + // Parses a counted repeition operator, e.g., `a{2,4}?z`. + // + // Start: `{` + // End: `z` + fn parse_counted_repeat(&mut self) -> Result<Build> { + let e = try!(self.pop(ErrorKind::RepeaterExpectsExpr)); // e.g., ({5} + if !e.can_repeat() { + // e.g., a*{5} + return Err(self.err(ErrorKind::RepeaterUnexpectedExpr(e))); + } + self.bump(); + let min = try!(self.parse_decimal(|c| c != ',' && c != '}')); + let mut max_opt = Some(min); + if self.bump_if(',') { + if self.peek_is('}') { + max_opt = None; + } else { + let max = try!(self.parse_decimal(|c| c != '}')); + if min > max { + // e.g., a{2,1} + return Err(self.err(ErrorKind::InvalidRepeatRange { + min: min, + max: max, + })); + } + max_opt = Some(max); + } + } + if !self.bump_if('}') { + Err(self.err(ErrorKind::UnclosedRepeat)) + } else { + Ok(Build::Expr(Expr::Repeat { + e: Box::new(e), + r: Repeater::Range { min: min, max: max_opt }, + greedy: !self.bump_if('?') ^ self.flags.swap_greed, + })) + } + } + + // Parses a simple repetition operator, e.g., `a+?z`. + // + // Start: `+` + // End: `z` + // + // N.B. "simple" in this context means "not min/max repetition", + // e.g., `a{1,2}`. + fn parse_simple_repeat(&mut self, rep: Repeater) -> Result<Build> { + let e = try!(self.pop(ErrorKind::RepeaterExpectsExpr)); // e.g., (* + if !e.can_repeat() { + // e.g., a** + return Err(self.err(ErrorKind::RepeaterUnexpectedExpr(e))); + } + self.bump(); + Ok(Build::Expr(Expr::Repeat { + e: Box::new(e), + r: rep, + greedy: !self.bump_if('?') ^ self.flags.swap_greed, + })) + } + + // Parses a decimal number until the given character, e.g., `a{123,456}`. + // + // Start: `1` + // End: `,` (where `until == ','`) + fn parse_decimal<B: Bumpable>(&mut self, until: B) -> Result<u32> { + match self.bump_get(until) { + // e.g., a{} + None => Err(self.err(ErrorKind::MissingBase10)), + Some(n) => { + // e.g., a{xyz + // e.g., a{9999999999} + let n = n.trim(); + u32::from_str_radix(n, 10) + .map_err(|_| self.err(ErrorKind::InvalidBase10(n.into()))) + } + } + } + + // Parses an octal number, up to 3 digits, e.g., `a\123b` + // + // Start: `1` + // End: `b` + fn parse_octal(&mut self) -> Result<Build> { + use std::char; + let mut i = 0; // counter for limiting octal to 3 digits. + let n = self.bump_get(|c| { i += 1; i <= 3 && c >= '0' && c <= '7' }) + .expect("octal string"); // guaranteed at least 1 digit + // I think both of the following unwraps are impossible to fail. + // We limit it to a three digit octal number, which maxes out at + // `0777` or `511` in decimal. Since all digits are in `0...7`, we'll + // always have a valid `u32` number. Moreover, since all numbers in + // the range `0...511` are valid Unicode scalar values, it will always + // be a valid `char`. + // + // Hence, we `unwrap` with reckless abandon. + let n = u32::from_str_radix(&n, 8).ok().expect("valid octal number"); + Ok(Build::Expr(Expr::Literal { + chars: vec![char::from_u32(n).expect("Unicode scalar value")], + casei: self.flags.casei, + })) + } + + // Parses a hex number, e.g., `a\x5ab`. + // + // Start: `5` + // End: `b` + // + // And also, `a\x{2603}b`. + // + // Start: `{` + // End: `b` + fn parse_hex(&mut self) -> Result<Build> { + if self.bump_if('{') { + self.parse_hex_many_digits() + } else { + self.parse_hex_two_digits() + } + } + + // Parses a many-digit hex number, e.g., `a\x{2603}b`. + // + // Start: `2` + // End: `b` + fn parse_hex_many_digits(&mut self) -> Result<Build> { + use std::char; + + let s = self.bump_get(|c| c != '}').unwrap_or("".into()); + let n = try!(u32::from_str_radix(&s, 16) + .map_err(|_| self.err(ErrorKind::InvalidBase16(s)))); + let c = try!(char::from_u32(n) + .ok_or(self.err(ErrorKind::InvalidScalarValue(n)))); + if !self.bump_if('}') { + // e.g., a\x{d + return Err(self.err(ErrorKind::UnclosedHex)); + } + Ok(Build::Expr(Expr::Literal { + chars: vec![c], + casei: self.flags.casei, + })) + } + + // Parses a two-digit hex number, e.g., `a\x5ab`. + // + // Start: `5` + // End: `b` + fn parse_hex_two_digits(&mut self) -> Result<Build> { + use std::char; + + let mut i = 0; + let s = self.bump_get(|_| { i += 1; i <= 2 }).unwrap_or("".into()); + if s.len() < 2 { + // e.g., a\x + // e.g., a\xf + return Err(self.err(ErrorKind::UnexpectedTwoDigitHexEof)); + } + let n = try!(u32::from_str_radix(&s, 16) + .map_err(|_| self.err(ErrorKind::InvalidBase16(s)))); + Ok(Build::Expr(Expr::Literal { + // Because 0...255 are all valid Unicode scalar values. + chars: vec![char::from_u32(n).expect("Unicode scalar value")], + casei: self.flags.casei, + })) + } + + // Parses a character class, e.g., `[^a-zA-Z0-9]+`. + // + // Start: `[` + // End: `+` + fn parse_class(&mut self) -> Result<Build> { + self.bump(); + let negated = self.bump_if('^'); + let mut class = CharClass::empty(); + while self.bump_if('-') { + class.ranges.push(ClassRange::one('-')); + } + loop { + if self.eof() { + // e.g., [a + return Err(self.err(ErrorKind::UnexpectedClassEof)); + } + match self.cur() { + // If no ranges have been added, then `]` is the first + // character (sans, perhaps, the `^` symbol), so it should + // be interpreted as a `]` instead of a closing class bracket. + ']' if class.len() > 0 => { self.bump(); break } + '[' => match self.maybe_parse_ascii() { + Some(class2) => class.ranges.extend(class2), + None => { + self.bump(); + try!(self.parse_class_range(&mut class, '[')) + } + }, + '\\' => match try!(self.parse_escape()) { + Build::Expr(Expr::Class(class2)) => { + class.ranges.extend(class2); + } + Build::Expr(Expr::Literal { chars, .. }) => { + try!(self.parse_class_range(&mut class, chars[0])); + } + Build::Expr(e) => { + let err = ErrorKind::InvalidClassEscape(e); + return Err(self.err(err)); + } + // Because `parse_escape` can never return `LeftParen`. + _ => unreachable!(), + }, + start => { + self.bump(); + try!(self.parse_class_range(&mut class, start)); + } + } + } + if negated { + class = class.negate(); + } + Ok(Build::Expr(Expr::Class(class.canonicalize()))) + } + + // Parses a single range in a character class. + // + // Since this is a helper for `parse_class`, its signature sticks out. + // Namely, it requires the start character of the range and the char + // class to mutate. + // + // e.g., `[a-z]` + // + // Start: `-` (with start == `a`) + // End: `]` + fn parse_class_range(&mut self, class: &mut CharClass, start: char) + -> Result<()> { + if !self.bump_if('-') { + // Not a range, so just push a singleton range. + class.ranges.push(ClassRange::one(start)); + return Ok(()); + } + if self.eof() { + // e.g., [a- + return Err(self.err(ErrorKind::UnexpectedClassEof)); + } + if self.peek_is(']') { + // This is the end of the class, so we permit use of `-` as a + // regular char (just like we do in the beginning). + class.ranges.push(ClassRange::one(start)); + class.ranges.push(ClassRange::one('-')); + return Ok(()); + } + + // We have a real range. Just need to check to parse literal and + // make sure it's a valid range. + let end = match self.cur() { + '\\' => match try!(self.parse_escape()) { + Build::Expr(Expr::Literal { chars, .. }) => chars[0], + Build::Expr(e) => { + return Err(self.err(ErrorKind::InvalidClassEscape(e))); + } + // Because `parse_escape` can never return `LeftParen`. + _ => unreachable!(), + }, + _ => self.bump(), + }; + if end < start { + // e.g., [z-a] + return Err(self.err(ErrorKind::InvalidClassRange { + start: start, + end: end, + })); + } + class.ranges.push(ClassRange::new(start, end)); + Ok(()) + } + + // Parses an ASCII class, e.g., `[:alnum:]+`. + // + // Start: `[` + // End: `+` + // + // Also supports negation, e.g., `[:^alnum:]`. + // + // This parsing routine is distinct from the others in that it doesn't + // actually report any errors. Namely, if it fails, then the parser should + // fall back to parsing a regular class. + // + // This method will only make progress in the parser if it succeeds. + // Otherwise, the input remains where it started. + fn maybe_parse_ascii(&mut self) -> Option<CharClass> { + fn parse(p: &mut Parser) -> Option<CharClass> { + p.bump(); // the `[` + if !p.bump_if(':') { return None; } + let negate = p.bump_if('^'); + let name = match p.bump_get(|c| c != ':') { + None => return None, + Some(name) => name, + }; + if !p.bump_if(":]") { return None; } + ascii_class(&name).map(|c| if !negate { c } else { c.negate() }) + } + let start = self.chari; + match parse(self) { + None => { self.chari = start; None } + result => result, + } + } + + // Parses a Uncode class name, e.g., `a\pLb`. + // + // Start: `L` + // End: `b` + // + // And also, `a\p{Greek}b`. + // + // Start: `{` + // End: `b` + // + // `negate` is true when the class name is used with `\P`. + fn parse_unicode_class(&mut self, neg: bool) -> Result<CharClass> { + let name = + if self.bump_if('{') { + let n = self.bump_get(|c| c != '}').unwrap_or("".into()); + if n.is_empty() || !self.bump_if('}') { + // e.g., \p{Greek + return Err(self.err(ErrorKind::UnclosedUnicodeName)); + } + n + } else { + if self.eof() { + // e.g., \p + return Err(self.err(ErrorKind::UnexpectedEscapeEof)); + } + self.bump().to_string() + }; + match unicode_class(&name) { + None => Err(self.err(ErrorKind::UnrecognizedUnicodeClass(name))), + Some(cls) => if neg { Ok(cls.negate()) } else { Ok(cls) }, + } + } + + // Parses a perl character class with Unicode support. + // + // `name` must be one of d, s, w, D, S, W. If not, this function panics. + // + // No parser state is changed. + fn parse_perl_class(&mut self, name: char) -> CharClass { + use unicode::regex::{PERLD, PERLS, PERLW}; + match name { + 'd' => raw_class_to_expr(PERLD), + 'D' => raw_class_to_expr(PERLD).negate(), + 's' => raw_class_to_expr(PERLS), + 'S' => raw_class_to_expr(PERLS).negate(), + 'w' => raw_class_to_expr(PERLW), + 'W' => raw_class_to_expr(PERLW).negate(), + _ => unreachable!(), + } + } + + // Always bump to the next input and return the given expression as a + // `Build`. + // + // This is mostly for convenience when the surrounding context implies + // that the next character corresponds to the given expression. + fn parse_one(&mut self, e: Expr) -> Build { + self.bump(); + Build::Expr(e) + } +} + +// Auxiliary helper methods. +impl Parser { + fn chars(&self) -> Chars { + Chars::new(&self.chars[self.chari..], self.flags.ignore_space) + } + + fn bump(&mut self) -> char { + let c = self.cur(); + self.chari = checkadd(self.chari, self.chars().next_count()); + c + } + + fn cur(&self) -> char { self.chars().next().unwrap() } + + fn eof(&self) -> bool { self.chars().next().is_none() } + + fn bump_get<B: Bumpable>(&mut self, s: B) -> Option<String> { + let n = s.match_end(self); + if n == 0 { + None + } else { + let end = checkadd(self.chari, n); + let s = self.chars[self.chari..end] + .iter().cloned().collect::<String>(); + self.chari = end; + Some(s) + } + } + + fn bump_if<B: Bumpable>(&mut self, s: B) -> bool { + let n = s.match_end(self); + if n == 0 { + false + } else { + self.chari = checkadd(self.chari, n); + true + } + } + + fn peek_is<B: Bumpable>(&self, s: B) -> bool { + s.match_end(self) > 0 + } + + fn err(&self, kind: ErrorKind) -> Error { + self.errat(self.chari, kind) + } + + fn errat(&self, pos: usize, kind: ErrorKind) -> Error { + Error { pos: pos, surround: self.windowat(pos), kind: kind } + } + + fn windowat(&self, pos: usize) -> String { + let s = max(5, pos) - 5; + let e = min(self.chars.len(), checkadd(pos, 5)); + self.chars[s..e].iter().cloned().collect() + } + + fn pop(&mut self, expected: ErrorKind) -> Result<Expr> { + match self.stack.pop() { + None | Some(Build::LeftParen{..}) => Err(self.err(expected)), + Some(Build::Expr(e)) => Ok(e), + } + } + + // If the current contexts calls for case insensitivity and if the expr + // given is a character class, do case folding on it and return the new + // class. + // + // Otherwise, return the expression unchanged. + fn maybe_class_case_fold(&mut self, bexpr: Build) -> Build { + match bexpr { + Build::Expr(Expr::Class(cls)) => { + Build::Expr(Expr::Class( + if self.flags.casei && !cls.casei { + cls.case_fold() + } else { + cls + } + )) + } + bexpr => bexpr, + } + } +} + +struct Chars<'a> { + chars: &'a [char], + cur: usize, + ignore_space: bool, + in_comment: bool, +} + +impl<'a> Iterator for Chars<'a> { + type Item = char; + fn next(&mut self) -> Option<char> { + self.skip(); + if self.cur < self.chars.len() { + let c = self.chars[self.cur]; + self.cur = checkadd(self.cur, 1); + Some(c) + } else { + None + } + } +} + +impl<'a> Chars<'a> { + fn new(chars: &[char], ignore_space: bool) -> Chars { + Chars { + chars: chars, + cur: 0, + ignore_space: ignore_space, + in_comment: false, + } + } + + /// Skip line comments and whitespace + fn skip(&mut self) { + if !self.ignore_space { return; } + while self.cur < self.chars.len() { + // Handle escaping of `#`, i.e. don't start a comment with `\#`. + let next_cur = checkadd(self.cur, 1); + if !self.in_comment && self.c() == '\\' + && next_cur < self.chars.len() + && self.chars[next_cur] == '#' + { + self.cur = next_cur; + break; + } + + if !self.in_comment && self.c() == '#' { + self.in_comment = true; + } else if self.in_comment && self.c() == '\n' { + self.in_comment = false; + } + + if self.in_comment || self.c().is_whitespace() { + self.cur = next_cur; + } else { + break; + } + } + } + + fn c(&self) -> char { + self.chars[self.cur] + } + + fn next_count(&mut self) -> usize { + self.next(); + self.cur + } +} + +// Auxiliary methods for manipulating the expression stack. +impl Parser { + // Called whenever an alternate (`|`) is found. + // + // This pops the expression stack until: + // + // 1. The stack is empty. Pushes an alternation with one arm. + // 2. An opening parenthesis is found. Leave the parenthesis + // on the stack and push an alternation with one arm. + // 3. An alternate (`|`) is found. Pop the existing alternation, + // add an arm and push the modified alternation. + // + // Each "arm" in the above corresponds to the concatenation of all + // popped expressions. + // + // In the first two cases, the stack is left in an invalid state + // because an alternation with one arm is not allowed. This + // particular state will be detected by `finish_concat` and an + // error will be reported. + // + // In none of the cases is an empty arm allowed. If an empty arm + // is found, an error is reported. + fn alternate(&mut self) -> Result<Build> { + let mut concat = vec![]; + let alts = |es| Ok(Build::Expr(Expr::Alternate(es))); + loop { + match self.stack.pop() { + None => { + if concat.is_empty() { + // e.g., |a + return Err(self.err(ErrorKind::EmptyAlternate)); + } + return alts(vec![rev_concat(concat)]); + } + Some(e @ Build::LeftParen{..}) => { + if concat.is_empty() { + // e.g., (|a) + return Err(self.err(ErrorKind::EmptyAlternate)); + } + self.stack.push(e); + return alts(vec![rev_concat(concat)]); + } + Some(Build::Expr(Expr::Alternate(mut es))) => { + if concat.is_empty() { + // e.g., a|| + return Err(self.err(ErrorKind::EmptyAlternate)); + } + es.push(rev_concat(concat)); + return alts(es); + } + Some(Build::Expr(e)) => { concat.push(e); } + } + } + } + + // Called whenever a closing parenthesis (`)`) is found. + // + // This pops the expression stack until: + // + // 1. The stack is empty. An error is reported because this + // indicates an unopened parenthesis. + // 2. An opening parenthesis is found. Pop the opening parenthesis + // and push a `Group` expression. + // 3. An alternate (`|`) is found. Pop the existing alternation + // and an arm to it in place. Pop one more item from the stack. + // If the stack was empty, then report an unopened parenthesis + // error, otherwise assume it is an opening parenthesis and + // push a `Group` expression with the popped alternation. + // (We can assume this is an opening parenthesis because an + // alternation either corresponds to the entire Regex or it + // corresponds to an entire group. This is guaranteed by the + // `alternate` method.) + // + // Each "arm" in the above corresponds to the concatenation of all + // popped expressions. + // + // Empty arms nor empty groups are allowed. + fn close_paren(&mut self) -> Result<(Flags, Build)> { + let mut concat = vec![]; + loop { + match self.stack.pop() { + // e.g., ) + None => return Err(self.err(ErrorKind::UnopenedParen)), + Some(Build::LeftParen { i, name, old_flags, .. }) => { + if concat.is_empty() { + // e.g., () + return Err(self.err(ErrorKind::EmptyGroup)); + } + return Ok((old_flags, Build::Expr(Expr::Group { + e: Box::new(rev_concat(concat)), + i: i, + name: name, + }))); + } + Some(Build::Expr(Expr::Alternate(mut es))) => { + if concat.is_empty() { + // e.g., (a|) + return Err(self.err(ErrorKind::EmptyAlternate)); + } + es.push(rev_concat(concat)); + match self.stack.pop() { + // e.g., a|b) + None => return Err(self.err(ErrorKind::UnopenedParen)), + Some(Build::Expr(_)) => unreachable!(), + Some(Build::LeftParen { i, name, old_flags, .. }) => { + return Ok((old_flags, Build::Expr(Expr::Group { + e: Box::new(Expr::Alternate(es)), + i: i, + name: name, + }))); + } + } + } + Some(Build::Expr(e)) => { concat.push(e); } + } + } + } + + // Called only when the parser reaches the end of input. + // + // This pops the expression stack until: + // + // 1. The stack is empty. Return concatenation of popped + // expressions. This concatenation may be empty! + // 2. An alternation is found. Pop the alternation and push + // a new arm. Return the alternation as the entire Regex. + // + // If an opening parenthesis is popped, then an error is + // returned since it indicates an unclosed parenthesis. + fn finish_concat(&mut self) -> Result<Expr> { + let mut concat = vec![]; + loop { + match self.stack.pop() { + None => { return Ok(rev_concat(concat)); } + Some(Build::LeftParen{ chari, ..}) => { + // e.g., a(b + return Err(self.errat(chari, ErrorKind::UnclosedParen)); + } + Some(Build::Expr(Expr::Alternate(mut es))) => { + if concat.is_empty() { + // e.g., a| + return Err(self.err(ErrorKind::EmptyAlternate)); + } + es.push(rev_concat(concat)); + return Ok(Expr::Alternate(es)); + } + Some(Build::Expr(e)) => { concat.push(e); } + } + } + } +} + +impl Build { + fn is_empty(&self) -> bool { + match *self { + Build::Expr(Expr::Empty) => true, + _ => false, + } + } +} + +// Make it ergonomic to conditionally bump the parser. +// i.e., `bump_if('a')` or `bump_if("abc")`. +trait Bumpable { + fn match_end(self, p: &Parser) -> usize; +} + +impl Bumpable for char { + fn match_end(self, p: &Parser) -> usize { + let mut chars = p.chars(); + if chars.next().map(|c| c == self).unwrap_or(false) { + chars.cur + } else { + 0 + } + } +} + +impl<'a> Bumpable for &'a str { + fn match_end(self, p: &Parser) -> usize { + let mut search = self.chars(); + let mut rest = p.chars(); + let mut count = 0; + loop { + match (rest.next(), search.next()) { + (Some(c1), Some(c2)) if c1 == c2 => count = rest.cur, + (_, None) => return count, + _ => return 0, + } + } + } +} + +impl<F: FnMut(char) -> bool> Bumpable for F { + fn match_end(mut self, p: &Parser) -> usize { + let mut chars = p.chars(); + let mut count = 0; + while let Some(c) = chars.next() { + if !self(c) { + break + } + count = chars.cur; + } + count + } +} + +// Turn a sequence of expressions into a concatenation. +// This only uses `Concat` if there are 2 or more expressions. +fn rev_concat(mut exprs: Vec<Expr>) -> Expr { + if exprs.len() == 0 { + Expr::Empty + } else if exprs.len() == 1 { + exprs.pop().unwrap() + } else { + exprs.reverse(); + Expr::Concat(exprs) + } +} + +// Returns true if and only if the given character is allowed in a capture +// name. Note that the first char of a capture name must not be numeric. +fn is_valid_capture_char(c: char) -> bool { + c == '_' || (c >= '0' && c <= '9') + || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') +} + +/// Returns true if the give character has significance in a regex. +#[doc(hidden)] +pub fn is_punct(c: char) -> bool { + match c { + '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | + '[' | ']' | '{' | '}' | '^' | '$' | '#' => true, + _ => false, + } +} + +fn checkadd(x: usize, y: usize) -> usize { + x.checked_add(y).expect("regex length overflow") +} + +fn unicode_class(name: &str) -> Option<CharClass> { + UNICODE_CLASSES.binary_search_by(|&(s, _)| s.cmp(name)).ok().map(|i| { + raw_class_to_expr(UNICODE_CLASSES[i].1) + }) +} + +fn ascii_class(name: &str) -> Option<CharClass> { + ASCII_CLASSES.binary_search_by(|&(s, _)| s.cmp(name)).ok().map(|i| { + raw_class_to_expr(ASCII_CLASSES[i].1) + }) +} + +fn raw_class_to_expr(raw: &[(char, char)]) -> CharClass { + let range = |&(s, e)| ClassRange { start: s, end: e }; + CharClass::new(raw.iter().map(range).collect()) +} + +type Class = &'static [(char, char)]; +type NamedClasses = &'static [(&'static str, Class)]; + +const ASCII_CLASSES: NamedClasses = &[ + // Classes must be in alphabetical order so that bsearch works. + // [:alnum:] alphanumeric (== [0-9A-Za-z]) + // [:alpha:] alphabetic (== [A-Za-z]) + // [:ascii:] ASCII (== [\x00-\x7F]) + // [:blank:] blank (== [\t ]) + // [:cntrl:] control (== [\x00-\x1F\x7F]) + // [:digit:] digits (== [0-9]) + // [:graph:] graphical (== [!-~]) + // [:lower:] lower case (== [a-z]) + // [:print:] printable (== [ -~] == [ [:graph:]]) + // [:punct:] punctuation (== [!-/:-@[-`{-~]) + // [:space:] whitespace (== [\t\n\v\f\r ]) + // [:upper:] upper case (== [A-Z]) + // [:word:] word characters (== [0-9A-Za-z_]) + // [:xdigit:] hex digit (== [0-9A-Fa-f]) + // Taken from: http://golang.org/pkg/regex/syntax/ + ("alnum", &ALNUM), + ("alpha", &ALPHA), + ("ascii", &ASCII), + ("blank", &BLANK), + ("cntrl", &CNTRL), + ("digit", &DIGIT), + ("graph", &GRAPH), + ("lower", &LOWER), + ("print", &PRINT), + ("punct", &PUNCT), + ("space", &SPACE), + ("upper", &UPPER), + ("word", &WORD), + ("xdigit", &XDIGIT), +]; + +const ALNUM: Class = &[('0', '9'), ('A', 'Z'), ('a', 'z')]; +const ALPHA: Class = &[('A', 'Z'), ('a', 'z')]; +const ASCII: Class = &[('\x00', '\x7F')]; +const BLANK: Class = &[(' ', ' '), ('\t', '\t')]; +const CNTRL: Class = &[('\x00', '\x1F'), ('\x7F', '\x7F')]; +const DIGIT: Class = &[('0', '9')]; +const GRAPH: Class = &[('!', '~')]; +const LOWER: Class = &[('a', 'z')]; +const PRINT: Class = &[(' ', '~')]; +const PUNCT: Class = &[('!', '/'), (':', '@'), ('[', '`'), ('{', '~')]; +const SPACE: Class = &[('\t', '\t'), ('\n', '\n'), ('\x0B', '\x0B'), + ('\x0C', '\x0C'), ('\r', '\r'), (' ', ' ')]; +const UPPER: Class = &[('A', 'Z')]; +const WORD: Class = &[('0', '9'), ('A', 'Z'), ('a', 'z'), ('_', '_')]; +const XDIGIT: Class = &[('0', '9'), ('A', 'F'), ('a', 'f')]; + +#[cfg(test)] +mod tests { + use { CharClass, ClassRange, Expr, Repeater, ErrorKind }; + use unicode::regex::{PERLD, PERLS, PERLW}; + use super::Parser; + use super::{LOWER, UPPER}; + + static YI: &'static [(char, char)] = &[ + ('\u{a000}', '\u{a48c}'), ('\u{a490}', '\u{a4c6}'), + ]; + + fn p(s: &str) -> Expr { Parser::parse(s).unwrap() } + fn lit(c: char) -> Expr { Expr::Literal { chars: vec![c], casei: false } } + fn liti(c: char) -> Expr { Expr::Literal { chars: vec![c], casei: true } } + fn b<T>(v: T) -> Box<T> { Box::new(v) } + fn c(es: &[Expr]) -> Expr { Expr::Concat(es.to_vec()) } + + fn class(ranges: &[(char, char)]) -> CharClass { + let ranges = ranges.iter().cloned() + .map(|(c1, c2)| ClassRange::new(c1, c2)).collect(); + CharClass::new(ranges) + } + + fn classes(classes: &[&[(char, char)]]) -> CharClass { + let mut cls = CharClass::empty(); + for &ranges in classes { + cls.ranges.extend(class(ranges)); + } + cls.canonicalize() + } + + #[test] + fn empty() { + assert_eq!(p(""), Expr::Empty); + } + + #[test] + fn literal() { + assert_eq!(p("a"), lit('a')); + } + + #[test] + fn literal_string() { + assert_eq!(p("ab"), Expr::Concat(vec![lit('a'), lit('b')])); + } + + #[test] + fn start_literal() { + assert_eq!(p("^a"), Expr::Concat(vec![ + Expr::StartText, + Expr::Literal { chars: vec!['a'], casei: false }, + ])); + } + + #[test] + fn repeat_zero_or_one_greedy() { + assert_eq!(p("a?"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrOne, + greedy: true, + }); + } + + #[test] + fn repeat_zero_or_one_greedy_concat() { + assert_eq!(p("ab?"), Expr::Concat(vec![ + lit('a'), + Expr::Repeat { + e: b(lit('b')), + r: Repeater::ZeroOrOne, + greedy: true, + }, + ])); + } + + #[test] + fn repeat_zero_or_one_nongreedy() { + assert_eq!(p("a??"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrOne, + greedy: false, + }); + } + + #[test] + fn repeat_one_or_more_greedy() { + assert_eq!(p("a+"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::OneOrMore, + greedy: true, + }); + } + + #[test] + fn repeat_one_or_more_nongreedy() { + assert_eq!(p("a+?"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::OneOrMore, + greedy: false, + }); + } + + #[test] + fn repeat_zero_or_more_greedy() { + assert_eq!(p("a*"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrMore, + greedy: true, + }); + } + + #[test] + fn repeat_zero_or_more_nongreedy() { + assert_eq!(p("a*?"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrMore, + greedy: false, + }); + } + + #[test] + fn repeat_counted_exact() { + assert_eq!(p("a{5}"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: Some(5) }, + greedy: true, + }); + } + + #[test] + fn repeat_counted_min() { + assert_eq!(p("a{5,}"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: None }, + greedy: true, + }); + } + + #[test] + fn repeat_counted_min_max() { + assert_eq!(p("a{5,10}"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: Some(10) }, + greedy: true, + }); + } + + #[test] + fn repeat_counted_exact_nongreedy() { + assert_eq!(p("a{5}?"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: Some(5) }, + greedy: false, + }); + } + + #[test] + fn repeat_counted_min_nongreedy() { + assert_eq!(p("a{5,}?"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: None }, + greedy: false, + }); + } + + #[test] + fn repeat_counted_min_max_nongreedy() { + assert_eq!(p("a{5,10}?"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: Some(10) }, + greedy: false, + }); + } + + #[test] + fn repeat_counted_whitespace() { + assert_eq!(p("a{ 5 }"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: Some(5) }, + greedy: true, + }); + assert_eq!(p("a{ 5 , 10 }"), Expr::Repeat { + e: b(lit('a')), + r: Repeater::Range { min: 5, max: Some(10) }, + greedy: true, + }); + } + + #[test] + fn group_literal() { + assert_eq!(p("(a)"), Expr::Group { + e: b(lit('a')), + i: Some(1), + name: None, + }); + } + + #[test] + fn group_literal_concat() { + assert_eq!(p("(ab)"), Expr::Group { + e: b(c(&[lit('a'), lit('b')])), + i: Some(1), + name: None, + }); + } + + #[test] + fn alt_two() { + assert_eq!(p("a|b"), Expr::Alternate(vec![lit('a'), lit('b')])); + } + + #[test] + fn alt_many() { + assert_eq!(p("a|b|c"), Expr::Alternate(vec![ + lit('a'), lit('b'), lit('c'), + ])); + } + + #[test] + fn alt_many_concat() { + assert_eq!(p("ab|bc|cd"), Expr::Alternate(vec![ + c(&[lit('a'), lit('b')]), + c(&[lit('b'), lit('c')]), + c(&[lit('c'), lit('d')]), + ])); + } + + #[test] + fn alt_group_two() { + assert_eq!(p("(a|b)"), Expr::Group { + e: b(Expr::Alternate(vec![lit('a'), lit('b')])), + i: Some(1), + name: None, + }); + } + + #[test] + fn alt_group_many() { + assert_eq!(p("(a|b|c)"), Expr::Group { + e: b(Expr::Alternate(vec![lit('a'), lit('b'), lit('c')])), + i: Some(1), + name: None, + }); + } + + #[test] + fn alt_group_many_concat() { + assert_eq!(p("(ab|bc|cd)"), Expr::Group { + e: b(Expr::Alternate(vec![ + c(&[lit('a'), lit('b')]), + c(&[lit('b'), lit('c')]), + c(&[lit('c'), lit('d')]), + ])), + i: Some(1), + name: None, + }); + } + + #[test] + fn alt_group_nested() { + assert_eq!(p("(ab|(bc|(cd)))"), Expr::Group { + e: b(Expr::Alternate(vec![ + c(&[lit('a'), lit('b')]), + Expr::Group { + e: b(Expr::Alternate(vec![ + c(&[lit('b'), lit('c')]), + Expr::Group { + e: b(c(&[lit('c'), lit('d')])), + i: Some(3), + name: None, + } + ])), + i: Some(2), + name: None, + }, + ])), + i: Some(1), + name: None, + }); + } + + #[test] + fn group_name() { + assert_eq!(p("(?P<foo>a)"), Expr::Group { + e: b(lit('a')), + i: Some(1), + name: Some("foo".into()), + }); + } + + #[test] + fn group_no_capture() { + assert_eq!(p("(?:a)"), Expr::Group { + e: b(lit('a')), + i: None, + name: None, + }); + } + + #[test] + fn group_flags() { + assert_eq!(p("(?i:a)"), Expr::Group { + e: b(liti('a')), + i: None, + name: None, + }); + } + + #[test] + fn group_flags_returned() { + assert_eq!(p("(?i:a)a"), c(&[ + Expr::Group { + e: b(liti('a')), + i: None, + name: None, + }, + lit('a'), + ])); + } + + #[test] + fn group_flags_retained() { + assert_eq!(p("(?i)(?-i:a)a"), c(&[ + Expr::Group { + e: b(lit('a')), + i: None, + name: None, + }, + liti('a'), + ])); + } + + #[test] + fn flags_inline() { + assert_eq!(p("(?i)a"), liti('a')); + } + + #[test] + fn flags_inline_multiple() { + assert_eq!(p("(?is)a."), c(&[liti('a'), Expr::AnyChar])); + } + + #[test] + fn flags_inline_multiline() { + assert_eq!(p("(?m)^(?-m)$"), c(&[Expr::StartLine, Expr::EndText])); + } + + #[test] + fn flags_inline_swap_greed() { + assert_eq!(p("(?U)a*a*?(?i-U)a*a*?"), c(&[ + Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrMore, + greedy: false, + }, + Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrMore, + greedy: true, + }, + Expr::Repeat { + e: b(liti('a')), + r: Repeater::ZeroOrMore, + greedy: true, + }, + Expr::Repeat { + e: b(liti('a')), + r: Repeater::ZeroOrMore, + greedy: false, + }, + ])); + } + + #[test] + fn flags_inline_multiple_negate_one() { + assert_eq!(p("(?is)a.(?i-s)a."), c(&[ + liti('a'), Expr::AnyChar, liti('a'), Expr::AnyCharNoNL, + ])); + } + + #[test] + fn flags_inline_negate() { + assert_eq!(p("(?i)a(?-i)a"), c(&[liti('a'), lit('a')])); + } + + #[test] + fn flags_group_inline() { + assert_eq!(p("(a(?i)a)a"), c(&[ + Expr::Group { + e: b(c(&[lit('a'), liti('a')])), + i: Some(1), + name: None, + }, + lit('a'), + ])); + } + + #[test] + fn flags_group_inline_retain() { + assert_eq!(p("(?i)((?-i)a)a"), c(&[ + Expr::Group { + e: b(lit('a')), + i: Some(1), + name: None, + }, + liti('a'), + ])); + } + + #[test] + fn escape_simple() { + assert_eq!(p(r"\a\f\t\n\r\v"), c(&[ + lit('\x07'), lit('\x0C'), lit('\t'), + lit('\n'), lit('\r'), lit('\x0B'), + ])); + } + + #[test] + fn escape_boundaries() { + assert_eq!(p(r"\A\z\b\B"), c(&[ + Expr::StartText, Expr::EndText, + Expr::WordBoundary, Expr::NotWordBoundary, + ])); + } + + #[test] + fn escape_punctuation() { + assert_eq!(p(r"\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"), c(&[ + lit('\\'), lit('.'), lit('+'), lit('*'), lit('?'), + lit('('), lit(')'), lit('|'), lit('['), lit(']'), + lit('{'), lit('}'), lit('^'), lit('$'), lit('#'), + ])); + } + + #[test] + fn escape_octal() { + assert_eq!(p(r"\123"), lit('S')); + assert_eq!(p(r"\1234"), c(&[lit('S'), lit('4')])); + } + + #[test] + fn escape_hex2() { + assert_eq!(p(r"\x53"), lit('S')); + assert_eq!(p(r"\x534"), c(&[lit('S'), lit('4')])); + } + + #[test] + fn escape_hex() { + assert_eq!(p(r"\x{53}"), lit('S')); + assert_eq!(p(r"\x{53}4"), c(&[lit('S'), lit('4')])); + assert_eq!(p(r"\x{2603}"), lit('\u{2603}')); + } + + #[test] + fn escape_unicode_name() { + assert_eq!(p(r"\p{Yi}"), Expr::Class(class(YI))); + } + + #[test] + fn escape_unicode_letter() { + assert_eq!(p(r"\pZ"), Expr::Class(class(&[ + ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), + ]))); + } + + #[test] + fn escape_unicode_name_case_fold() { + assert_eq!(p(r"(?i)\p{Yi}"), Expr::Class(class(YI).case_fold())); + } + + #[test] + fn escape_unicode_letter_case_fold() { + assert_eq!(p(r"(?i)\pZ"), Expr::Class(class(&[ + ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), + ]).case_fold())); + } + + #[test] + fn escape_unicode_name_negate() { + assert_eq!(p(r"\P{Yi}"), Expr::Class(class(YI).negate())); + } + + #[test] + fn escape_unicode_letter_negate() { + assert_eq!(p(r"\PZ"), Expr::Class(class(&[ + ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), + ]).negate())); + } + + #[test] + fn escape_unicode_name_negate_case_fold() { + assert_eq!(p(r"(?i)\P{Yi}"), + Expr::Class(class(YI).negate().case_fold())); + } + + #[test] + fn escape_unicode_letter_negate_case_fold() { + assert_eq!(p(r"(?i)\PZ"), Expr::Class(class(&[ + ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), + ]).negate().case_fold())); + } + + #[test] + fn escape_perl_d() { + assert_eq!(p(r"\d"), Expr::Class(class(PERLD))); + } + + #[test] + fn escape_perl_s() { + assert_eq!(p(r"\s"), Expr::Class(class(PERLS))); + } + + #[test] + fn escape_perl_w() { + assert_eq!(p(r"\w"), Expr::Class(class(PERLW))); + } + + #[test] + fn escape_perl_d_negate() { + assert_eq!(p(r"\D"), Expr::Class(class(PERLD).negate())); + } + + #[test] + fn escape_perl_s_negate() { + assert_eq!(p(r"\S"), Expr::Class(class(PERLS).negate())); + } + + #[test] + fn escape_perl_w_negate() { + assert_eq!(p(r"\W"), Expr::Class(class(PERLW).negate())); + } + + #[test] + fn escape_perl_d_case_fold() { + assert_eq!(p(r"(?i)\d"), Expr::Class(class(PERLD).case_fold())); + } + + #[test] + fn escape_perl_s_case_fold() { + assert_eq!(p(r"(?i)\s"), Expr::Class(class(PERLS).case_fold())); + } + + #[test] + fn escape_perl_w_case_fold() { + assert_eq!(p(r"(?i)\w"), Expr::Class(class(PERLW).case_fold())); + } + + #[test] + fn escape_perl_d_case_fold_negate() { + assert_eq!(p(r"(?i)\D"), + Expr::Class(class(PERLD).negate().case_fold())); + } + + #[test] + fn escape_perl_s_case_fold_negate() { + assert_eq!(p(r"(?i)\S"), + Expr::Class(class(PERLS).negate().case_fold())); + } + + #[test] + fn escape_perl_w_case_fold_negate() { + assert_eq!(p(r"(?i)\W"), + Expr::Class(class(PERLW).negate().case_fold())); + } + + #[test] + fn class_singleton() { + assert_eq!(p(r"[a]"), Expr::Class(class(&[('a', 'a')]))); + assert_eq!(p(r"[\x00]"), Expr::Class(class(&[('\x00', '\x00')]))); + assert_eq!(p(r"[\n]"), Expr::Class(class(&[('\n', '\n')]))); + assert_eq!(p("[\n]"), Expr::Class(class(&[('\n', '\n')]))); + } + + #[test] + fn class_singleton_negate() { + assert_eq!(p(r"[^a]"), Expr::Class(class(&[ + ('\x00', '\x60'), ('\x62', '\u{10FFFF}'), + ]))); + assert_eq!(p(r"[^\x00]"), Expr::Class(class(&[ + ('\x01', '\u{10FFFF}'), + ]))); + assert_eq!(p(r"[^\n]"), Expr::Class(class(&[ + ('\x00', '\x09'), ('\x0b', '\u{10FFFF}'), + ]))); + assert_eq!(p("[^\n]"), Expr::Class(class(&[ + ('\x00', '\x09'), ('\x0b', '\u{10FFFF}'), + ]))); + } + + #[test] + fn class_singleton_class() { + assert_eq!(p(r"[\d]"), Expr::Class(class(PERLD))); + assert_eq!(p(r"[\p{Yi}]"), Expr::Class(class(YI))); + } + + #[test] + fn class_singleton_class_negate() { + assert_eq!(p(r"[^\d]"), Expr::Class(class(PERLD).negate())); + assert_eq!(p(r"[^\w]"), Expr::Class(class(PERLW).negate())); + assert_eq!(p(r"[^\s]"), Expr::Class(class(PERLS).negate())); + } + + #[test] + fn class_singleton_class_negate_negate() { + assert_eq!(p(r"[^\D]"), Expr::Class(class(PERLD))); + assert_eq!(p(r"[^\W]"), Expr::Class(class(PERLW))); + assert_eq!(p(r"[^\S]"), Expr::Class(class(PERLS))); + } + + #[test] + fn class_singleton_class_casei() { + assert_eq!(p(r"(?i)[\d]"), Expr::Class(class(PERLD).case_fold())); + assert_eq!(p(r"(?i)[\p{Yi}]"), Expr::Class(class(YI).case_fold())); + } + + #[test] + fn class_singleton_class_negate_casei() { + assert_eq!(p(r"(?i)[^\d]"), + Expr::Class(class(PERLD).negate().case_fold())); + assert_eq!(p(r"(?i)[^\w]"), + Expr::Class(class(PERLW).negate().case_fold())); + assert_eq!(p(r"(?i)[^\s]"), + Expr::Class(class(PERLS).negate().case_fold())); + } + + #[test] + fn class_singleton_class_negate_negate_casei() { + assert_eq!(p(r"(?i)[^\D]"), Expr::Class(class(PERLD).case_fold())); + assert_eq!(p(r"(?i)[^\W]"), Expr::Class(class(PERLW).case_fold())); + assert_eq!(p(r"(?i)[^\S]"), Expr::Class(class(PERLS).case_fold())); + } + + #[test] + fn class_multiple_class() { + assert_eq!(p(r"[\d\p{Yi}]"), Expr::Class(classes(&[ + PERLD, YI, + ]))); + } + + #[test] + fn class_multiple_class_negate() { + assert_eq!(p(r"[^\d\p{Yi}]"), Expr::Class(classes(&[ + PERLD, YI, + ]).negate())); + } + + #[test] + fn class_multiple_class_negate_negate() { + let nperld = class(PERLD).negate(); + let nyi = class(YI).negate(); + let cls = CharClass::empty().merge(nperld).merge(nyi); + assert_eq!(p(r"[^\D\P{Yi}]"), Expr::Class(cls.negate())); + } + + #[test] + fn class_multiple_class_casei() { + assert_eq!(p(r"(?i)[\d\p{Yi}]"), Expr::Class(classes(&[ + PERLD, YI, + ]).case_fold())); + } + + #[test] + fn class_multiple_class_negate_casei() { + assert_eq!(p(r"(?i)[^\d\p{Yi}]"), Expr::Class(classes(&[ + PERLD, YI, + ]).negate().case_fold())); + } + + #[test] + fn class_multiple_class_negate_negate_casei() { + let nperld = class(PERLD).negate(); + let nyi = class(YI).negate(); + let class = CharClass::empty().merge(nperld).merge(nyi); + assert_eq!(p(r"(?i)[^\D\P{Yi}]"), + Expr::Class(class.negate().case_fold())); + } + + #[test] + fn class_class_hypen() { + assert_eq!(p(r"[\p{Yi}-]"), Expr::Class(classes(&[ + &[('-', '-')], YI, + ]))); + assert_eq!(p(r"[\p{Yi}-a]"), Expr::Class(classes(&[ + &[('-', '-')], &[('a', 'a')], YI, + ]))); + } + + #[test] + fn class_brackets() { + assert_eq!(p("[]]"), Expr::Class(class(&[(']', ']')]))); + assert_eq!(p("[][]"), Expr::Class(class(&[('[', '['), (']', ']')]))); + assert_eq!(p("[[]]"), Expr::Concat(vec![ + Expr::Class(class(&[('[', '[')])), + lit(']'), + ])); + } + + #[test] + fn class_brackets_hypen() { + assert_eq!(p("[]-]"), Expr::Class(class(&[('-', '-'), (']', ']')]))); + assert_eq!(p("[-]]"), Expr::Concat(vec![ + Expr::Class(class(&[('-', '-')])), + lit(']'), + ])); + } + + #[test] + fn class_overlapping() { + assert_eq!(p("[a-fd-h]"), Expr::Class(class(&[('a', 'h')]))); + assert_eq!(p("[a-fg-m]"), Expr::Class(class(&[('a', 'm')]))); + } + + #[test] + fn ascii_class() { + assert_eq!(p("[:upper:]"), Expr::Class(class(UPPER))); + assert_eq!(p("[[:upper:]]"), Expr::Class(class(UPPER))); + } + + #[test] + fn ascii_class_not() { + assert_eq!(p("[:abc:]"), + Expr::Class(class(&[(':', ':'), ('a', 'c')]))); + } + + #[test] + fn ascii_class_multiple() { + assert_eq!(p("[[:lower:][:upper:]]"), + Expr::Class(classes(&[UPPER, LOWER]))); + } + + #[test] + fn ascii_class_negate() { + assert_eq!(p("[[:^upper:]]"), Expr::Class(class(UPPER).negate())); + assert_eq!(p("[^[:^upper:]]"), Expr::Class(class(UPPER))); + } + + #[test] + fn ascii_class_negate_multiple() { + let (nlower, nupper) = (class(LOWER).negate(), class(UPPER).negate()); + let cls = CharClass::empty().merge(nlower).merge(nupper); + assert_eq!(p("[[:^lower:][:^upper:]]"), Expr::Class(cls.clone())); + assert_eq!(p("[^[:^lower:][:^upper:]]"), Expr::Class(cls.negate())); + } + + #[test] + fn ascii_class_case_fold() { + assert_eq!(p("(?i)[:upper:]"), Expr::Class(class(UPPER).case_fold())); + assert_eq!(p("(?i)[[:upper:]]"), + Expr::Class(class(UPPER).case_fold())); + } + + #[test] + fn ascii_class_negate_case_fold() { + assert_eq!(p("(?i)[[:^upper:]]"), + Expr::Class(class(UPPER).negate().case_fold())); + assert_eq!(p("(?i)[^[:^upper:]]"), + Expr::Class(class(UPPER).case_fold())); + } + + #[test] + fn ignore_space_literal() { + assert_eq!(p("(?x) a b c"), Expr::Concat(vec![ + lit('a'), lit('b'), lit('c'), + ])); + } + + #[test] + fn ignore_space_literal_off() { + assert_eq!(p("(?x) a b c(?-x) a"), Expr::Concat(vec![ + lit('a'), lit('b'), lit('c'), lit(' '), lit('a'), + ])); + } + + #[test] + fn ignore_space_class() { + assert_eq!(p("(?x)[a + - z +]"), Expr::Class(class(&[('a', 'z')]))); + assert_eq!(p("(?x)[ ^ a + - z +]"), Expr::Class(class(&[('a', 'z')]).negate())); + } + + #[test] + fn ignore_space_escape() { + assert_eq!(p(r"(?x)\ d"), Expr::Class(class(PERLD))); + assert_eq!(p(r"(?x)\ + D"), Expr::Class(class(PERLD).negate())); + } + + #[test] + fn ignore_space_comments() { + assert_eq!(p(r"(?x)(?P<foo> + a # comment 1 +)(?P<bar> + z # comment 2 +)"), Expr::Concat(vec![ + Expr::Group { + e: Box::new(lit('a')), + i: Some(1), + name: Some("foo".into()), + }, + Expr::Group { + e: Box::new(lit('z')), + i: Some(2), + name: Some("bar".into()), + }, + ])); + } + + #[test] + fn ignore_space_comments_re_enable() { + assert_eq!(p(r"(?x)a # hi +(?-x:#) # sweet"), Expr::Concat(vec![ + lit('a'), + Expr::Group { + e: Box::new(lit('#')), + i: None, + name: None, + }, + ])); + } + + #[test] + fn ignore_space_escape_punctuation() { + assert_eq!(p(r"(?x)\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"), c(&[ + lit('\\'), lit('.'), lit('+'), lit('*'), lit('?'), + lit('('), lit(')'), lit('|'), lit('['), lit(']'), + lit('{'), lit('}'), lit('^'), lit('$'), lit('#'), + ])); + } + + #[test] + fn ignore_space_escape_hash() { + assert_eq!(p(r"(?x)a\# # hi there"), Expr::Concat(vec![ + lit('a'), + lit('#'), + ])); + } + + // Test every single possible error case. + + macro_rules! test_err { + ($re:expr, $pos:expr, $kind:expr) => {{ + let err = Parser::parse($re).unwrap_err(); + assert_eq!($pos, err.pos); + assert_eq!($kind, err.kind); + assert!($re.contains(&err.surround)); + }} + } + + #[test] + fn error_repeat_no_expr_simple() { + test_err!("(*", 1, ErrorKind::RepeaterExpectsExpr); + } + + #[test] + fn error_repeat_no_expr_counted() { + test_err!("({5}", 1, ErrorKind::RepeaterExpectsExpr); + } + + #[test] + fn error_repeat_beginning_counted() { + test_err!("{5}", 0, ErrorKind::RepeaterExpectsExpr); + } + + #[test] + fn error_repeat_illegal_exprs_simple() { + test_err!("a**", 2, ErrorKind::RepeaterUnexpectedExpr(Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrMore, + greedy: true, + })); + test_err!("a|*", 2, + ErrorKind::RepeaterUnexpectedExpr(Expr::Alternate(vec![lit('a')])) + ); + } + + #[test] + fn error_repeat_illegal_exprs_counted() { + test_err!("a*{5}", 2, ErrorKind::RepeaterUnexpectedExpr(Expr::Repeat { + e: b(lit('a')), + r: Repeater::ZeroOrMore, + greedy: true, + })); + test_err!("a|{5}", 2, + ErrorKind::RepeaterUnexpectedExpr(Expr::Alternate(vec![lit('a')])) + ); + } + + #[test] + fn error_repeat_empty_number() { + test_err!("a{}", 2, ErrorKind::MissingBase10); + } + + #[test] + fn error_repeat_eof() { + test_err!("a{5", 3, ErrorKind::UnclosedRepeat); + } + + #[test] + fn error_repeat_empty_number_eof() { + test_err!("a{xyz", 5, ErrorKind::InvalidBase10("xyz".into())); + test_err!("a{12,xyz", 8, ErrorKind::InvalidBase10("xyz".into())); + } + + #[test] + fn error_repeat_invalid_number() { + test_err!("a{9999999999}", 12, + ErrorKind::InvalidBase10("9999999999".into())); + test_err!("a{1,9999999999}", 14, + ErrorKind::InvalidBase10("9999999999".into())); + } + + #[test] + fn error_repeat_invalid_number_extra() { + test_err!("a{12x}", 5, ErrorKind::InvalidBase10("12x".into())); + test_err!("a{1,12x}", 7, ErrorKind::InvalidBase10("12x".into())); + } + + #[test] + fn error_repeat_invalid_range() { + test_err!("a{2,1}", 5, + ErrorKind::InvalidRepeatRange { min: 2, max: 1 }); + } + + #[test] + fn error_alternate_empty() { + test_err!("|a", 0, ErrorKind::EmptyAlternate); + } + + #[test] + fn error_alternate_empty_with_group() { + test_err!("(|a)", 1, ErrorKind::EmptyAlternate); + } + + #[test] + fn error_alternate_empty_with_alternate() { + test_err!("a||", 2, ErrorKind::EmptyAlternate); + } + + #[test] + fn error_close_paren_unopened_empty() { + test_err!(")", 0, ErrorKind::UnopenedParen); + } + + #[test] + fn error_close_paren_unopened() { + test_err!("ab)", 2, ErrorKind::UnopenedParen); + } + + #[test] + fn error_close_paren_unopened_with_alt() { + test_err!("a|b)", 3, ErrorKind::UnopenedParen); + } + + #[test] + fn error_close_paren_empty_alt() { + test_err!("(a|)", 3, ErrorKind::EmptyAlternate); + } + + #[test] + fn error_close_paren_empty_group() { + test_err!("()", 1, ErrorKind::EmptyGroup); + } + + #[test] + fn error_close_paren_empty_group_with_name() { + test_err!("(?P<foo>)", 8, ErrorKind::EmptyGroup); + } + + #[test] + fn error_finish_concat_unclosed() { + test_err!("ab(xy", 2, ErrorKind::UnclosedParen); + } + + #[test] + fn error_finish_concat_empty_alt() { + test_err!("a|", 2, ErrorKind::EmptyAlternate); + } + + #[test] + fn error_group_name_invalid() { + test_err!("(?P<a#>x)", 6, ErrorKind::InvalidCaptureName("a#".into())); + } + + #[test] + fn error_group_name_invalid_leading() { + test_err!("(?P<1a>a)", 6, ErrorKind::InvalidCaptureName("1a".into())); + } + + #[test] + fn error_group_name_unexpected_eof() { + test_err!("(?P<a", 5, ErrorKind::UnclosedCaptureName("a".into())); + } + + #[test] + fn error_group_name_empty() { + test_err!("(?P<>a)", 4, ErrorKind::EmptyCaptureName); + } + + #[test] + fn error_group_opts_unrecognized_flag() { + test_err!("(?z:a)", 2, ErrorKind::UnrecognizedFlag('z')); + } + + #[test] + fn error_group_opts_unexpected_eof() { + test_err!("(?i", 3, ErrorKind::UnexpectedFlagEof); + } + + #[test] + fn error_group_opts_double_negation() { + test_err!("(?-i-s:a)", 4, ErrorKind::DoubleFlagNegation); + } + + #[test] + fn error_group_opts_empty_negation() { + test_err!("(?i-:a)", 4, ErrorKind::EmptyFlagNegation); + } + + #[test] + fn error_group_opts_empty() { + test_err!("(?)", 2, ErrorKind::EmptyFlagNegation); + } + + #[test] + fn error_escape_unexpected_eof() { + test_err!(r"\", 1, ErrorKind::UnexpectedEscapeEof); + } + + #[test] + fn error_escape_unrecognized() { + test_err!(r"\m", 1, ErrorKind::UnrecognizedEscape('m')); + } + + #[test] + fn error_escape_hex2_eof0() { + test_err!(r"\x", 2, ErrorKind::UnexpectedTwoDigitHexEof); + } + + #[test] + fn error_escape_hex2_eof1() { + test_err!(r"\xA", 3, ErrorKind::UnexpectedTwoDigitHexEof); + } + + #[test] + fn error_escape_hex2_invalid() { + test_err!(r"\xAG", 4, ErrorKind::InvalidBase16("AG".into())); + } + + #[test] + fn error_escape_hex_eof0() { + test_err!(r"\x{", 3, ErrorKind::InvalidBase16("".into())); + } + + #[test] + fn error_escape_hex_eof1() { + test_err!(r"\x{A", 4, ErrorKind::UnclosedHex); + } + + #[test] + fn error_escape_hex_invalid() { + test_err!(r"\x{AG}", 5, ErrorKind::InvalidBase16("AG".into())); + } + + #[test] + fn error_escape_hex_invalid_scalar_value_surrogate() { + test_err!(r"\x{D800}", 7, ErrorKind::InvalidScalarValue(0xD800)); + } + + #[test] + fn error_escape_hex_invalid_scalar_value_high() { + test_err!(r"\x{110000}", 9, ErrorKind::InvalidScalarValue(0x110000)); + } + + #[test] + fn error_escape_hex_invalid_u32() { + test_err!(r"\x{9999999999}", 13, + ErrorKind::InvalidBase16("9999999999".into())); + } + + #[test] + fn error_unicode_unclosed() { + test_err!(r"\p{", 3, ErrorKind::UnclosedUnicodeName); + test_err!(r"\p{Greek", 8, ErrorKind::UnclosedUnicodeName); + } + + #[test] + fn error_unicode_no_letter() { + test_err!(r"\p", 2, ErrorKind::UnexpectedEscapeEof); + } + + #[test] + fn error_unicode_unknown_letter() { + test_err!(r"\pA", 3, ErrorKind::UnrecognizedUnicodeClass("A".into())); + } + + #[test] + fn error_unicode_unknown_name() { + test_err!(r"\p{Yii}", 7, + ErrorKind::UnrecognizedUnicodeClass("Yii".into())); + } + + #[test] + fn error_class_eof_empty() { + test_err!("[", 1, ErrorKind::UnexpectedClassEof); + test_err!("[^", 2, ErrorKind::UnexpectedClassEof); + } + + #[test] + fn error_class_eof_non_empty() { + test_err!("[a", 2, ErrorKind::UnexpectedClassEof); + test_err!("[^a", 3, ErrorKind::UnexpectedClassEof); + } + + #[test] + fn error_class_eof_range() { + test_err!("[a-", 3, ErrorKind::UnexpectedClassEof); + test_err!("[^a-", 4, ErrorKind::UnexpectedClassEof); + test_err!("[---", 4, ErrorKind::UnexpectedClassEof); + } + + #[test] + fn error_class_invalid_escape() { + test_err!(r"[\pA]", 4, + ErrorKind::UnrecognizedUnicodeClass("A".into())); + } + + #[test] + fn error_class_valid_escape_not_allowed() { + test_err!(r"[\A]", 3, ErrorKind::InvalidClassEscape(Expr::StartText)); + } + + #[test] + fn error_class_range_valid_escape_not_allowed() { + test_err!(r"[a-\d]", 5, + ErrorKind::InvalidClassEscape(Expr::Class(class(PERLD)))); + test_err!(r"[a-\A]", 5, + ErrorKind::InvalidClassEscape(Expr::StartText)); + test_err!(r"[\A-a]", 3, + ErrorKind::InvalidClassEscape(Expr::StartText)); + } + + #[test] + fn error_class_invalid_range() { + test_err!("[z-a]", 4, ErrorKind::InvalidClassRange { + start: 'z', + end: 'a', + }); + } + + #[test] + fn error_class_empty_range() { + test_err!("[]", 2, ErrorKind::UnexpectedClassEof); + test_err!("[^]", 3, ErrorKind::UnexpectedClassEof); + } + + #[test] + fn error_duplicate_capture_name() { + test_err!("(?P<a>.)(?P<a>.)", 14, + ErrorKind::DuplicateCaptureName("a".into())); + } +} diff --git a/deps/regex-syntax-0.1.2/src/properties.rs b/deps/regex-syntax-0.1.2/src/properties.rs new file mode 100644 index 000000000..38cbb02e7 --- /dev/null +++ b/deps/regex-syntax-0.1.2/src/properties.rs @@ -0,0 +1,407 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use quickcheck::{Arbitrary, Gen, Testable, QuickCheck, StdGen}; +use rand::Rng; + +use {Expr, CharClass, ClassRange, Repeater, dec_char}; + +fn qc<T: Testable>(t: T) { + QuickCheck::new() + .tests(10_000) + .max_tests(20_000) + .quickcheck(t); +} + +fn class(ranges: &[(char, char)]) -> CharClass { + let ranges = ranges.iter().cloned() + .map(|(c1, c2)| ClassRange::new(c1, c2)).collect(); + CharClass::new(ranges) +} + +// Test invariants for canonicalizing character classes. + +#[test] +fn negate() { + fn prop(ranges: Vec<(char, char)>) -> bool { + class(&ranges).canonicalize() == class(&ranges).negate().negate() + } + qc(prop as fn(Vec<(char, char)>) -> bool); +} + +#[test] +fn classes_are_sorted_and_nonoverlapping() { + fn prop(ranges: Vec<(char, char)>) -> bool { + class(&ranges) + .canonicalize() + .windows(2) + .all(|w| w[0].end < dec_char(w[1].start)) + } + qc(prop as fn(Vec<(char, char)>) -> bool); +} + +#[test] +fn valid_class_ranges() { + fn prop(ranges: Vec<(char, char)>) -> bool { + class(&ranges).canonicalize().into_iter().all(|r| r.start <= r.end) + } + qc(prop as fn(Vec<(char, char)>) -> bool); +} + +/// A wrapper type for generating "regex-like" Unicode strings. +/// +/// In particular, this type's `Arbitrary` impl specifically biases toward +/// special regex characters to make test cases more interesting. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +struct RegexLikeString(String); + +impl Arbitrary for RegexLikeString { + fn arbitrary<G: Gen>(g: &mut G) -> RegexLikeString { + const SPECIAL: &'static [char] = &[ + '\\', '.', '+', '*', '?', '(', ')', '|', '[', ']', '{', '}', + '^', '$', + ]; + // Generating random Unicode strings results in mostly uninteresting + // regexes. Namely, they'll mostly just be literals. + // To make properties using regex strings more interesting, we bias + // toward selecting characters of significance to a regex. + let size = { let s = g.size(); g.gen_range(0, s) }; + RegexLikeString((0..size).map(|_| { + if g.gen_weighted_bool(3) { + *g.choose(SPECIAL).unwrap() + } else { + g.gen() + } + }).collect()) + } + + fn shrink(&self) -> Box<Iterator<Item=RegexLikeString>> { + // The regular `String` shrinker is good enough. + Box::new(self.0.shrink().map(RegexLikeString)) + } +} + +/// A special type for generating small non-zero sized ASCII strings. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +struct SmallAscii(String); + +impl Arbitrary for SmallAscii { + fn arbitrary<G: Gen>(g: &mut G) -> SmallAscii { + use std::char::from_u32; + let size = g.gen_range(1, 5); + SmallAscii((0..size) + .map(|_| from_u32(g.gen_range(97, 123)).unwrap()) + .collect()) + } + + fn shrink(&self) -> Box<Iterator<Item=SmallAscii>> { + Box::new(self.0.shrink().map(SmallAscii)) + } +} + +#[test] +fn parser_never_panics() { + fn prop(s: RegexLikeString) -> bool { + let _ = Expr::parse(&s.0); true + } + qc(prop as fn(RegexLikeString) -> bool); +} + +// Testing entire expressions. +// +// We only have one test at the moment, but the machinery could be useful +// for other things. +// +// In particular, Russ Cox writes about testing regexes by comparing the +// strings they match with other regex implementations. A fuzzer/shrinker +// (which is what's implemented below) would be a great way to drive that +// process. ---AG + +impl Arbitrary for Expr { + fn arbitrary<G: Gen>(g: &mut G) -> Expr { + fix_capture_indices(gen_expr(g, 0, ExprType::Anything)).simplify() + } + + fn shrink(&self) -> Box<Iterator<Item=Expr>> { + use Expr::*; + + let nada = || Box::new(None.into_iter()); + let es: Box<Iterator<Item=Expr>> = match *self { + Empty | AnyChar | AnyCharNoNL + | StartLine | EndLine | StartText | EndText + | WordBoundary | NotWordBoundary => nada(), + Literal { ref chars, .. } if chars.len() == 1 => nada(), + Literal { ref chars, casei } => { + Box::new((chars.clone(), casei) + .shrink() + .filter(|&(ref chars, _)| chars.len() > 0) + .map(|(chars, casei)| { + Literal { chars: chars, casei: casei } + })) + } + Class(ref cls) => Box::new(cls.shrink().map(Class)), + Group { ref e, ref i, ref name } => { + let (i, name) = (i.clone(), name.clone()); + Box::new(e.clone().shrink() + .chain(e.clone().shrink() + .map(move |e| Group { + e: Box::new(e), + i: i.clone(), + name: name.clone(), + }))) + } + Repeat { ref e, ref r, greedy } => { + Box::new((*e.clone(), r.clone()) + .shrink() + .filter(|&(ref e, _)| e.can_repeat()) + .map(move |(e, r)| Repeat { + e: Box::new(e), + r: r, + greedy: greedy, + })) + } + // Concat(ref es) if es.len() <= 2 => nada(), + Concat(ref es) => { + Box::new(es.clone() + .shrink() + .filter(|es| es.len() > 0) + .map(|mut es| if es.len() == 1 { + es.pop().unwrap() + } else { + Concat(es) + })) + } + // Alternate(ref es) if es.len() <= 2 => nada(), + Alternate(ref es) => { + Box::new(es.clone() + .shrink() + .filter(|es| es.len() > 0) + .map(|mut es| if es.len() == 1 { + es.pop().unwrap() + } else { + Alternate(es) + })) + } + }; + Box::new(es.map(|e| fix_capture_indices(e).simplify())) + } +} + +enum ExprType { + NoSequences, // disallow concat/alternate + Anything, +} + +fn gen_expr<G: Gen>(g: &mut G, depth: u32, ty: ExprType) -> Expr { + use Expr::*; + let ub = match (depth as usize >= g.size(), ty) { + (true, _) => 11, + (false, ExprType::NoSequences) => 13, + (false, ExprType::Anything) => 15, + }; + match g.gen_range(1, ub) { + 0 => Empty, + 1 => Literal { + chars: SmallAscii::arbitrary(g).0.chars().collect(), + casei: g.gen(), + }, + 2 => AnyChar, + 3 => AnyCharNoNL, + 4 => Class(CharClass::arbitrary(g)), + 5 => StartLine, + 6 => EndLine, + 7 => StartText, + 8 => EndText, + 9 => WordBoundary, + 10 => NotWordBoundary, + 11 => gen_group_expr(g, depth + 1), + 12 => Repeat { + e: Box::new(gen_repeatable_expr(g, depth + 1)), + r: Repeater::arbitrary(g), + greedy: bool::arbitrary(g), + }, + 13 => { + let size = { let s = g.size(); g.gen_range(2, s) }; + Concat((0..size) + .map(|_| { + gen_expr(g, depth + 1, ExprType::NoSequences) + }) + .collect()) + } + 14 => { + let size = { let s = g.size(); g.gen_range(2, s) }; + Alternate((0..size) + .map(|_| { + gen_expr(g, depth + 1, ExprType::NoSequences) + }) + .collect()) + } + _ => unreachable!() + } +} + +fn gen_repeatable_expr<G: Gen>(g: &mut G, depth: u32) -> Expr { + use Expr::*; + match g.gen_range(1, 6) { + 0 => Empty, + 1 => Literal { + chars: vec![Arbitrary::arbitrary(g)], + casei: g.gen(), + }, + 2 => AnyChar, + 3 => AnyCharNoNL, + 4 => Class(CharClass::arbitrary(g)), + 5 => gen_group_expr(g, depth + 1), + _ => unreachable!(), + } +} + +fn gen_group_expr<G: Gen>(g: &mut G, depth: u32) -> Expr { + let (i, name) = if g.gen() { + (None, None) + } else { + (Some(0), if g.gen() { + Some(SmallAscii::arbitrary(g).0) + } else { + None + }) + }; + Expr::Group { + e: Box::new(gen_expr(g, depth + 1, ExprType::Anything)), + i: i, + name: name, + } +} + +fn fix_capture_indices(e: Expr) -> Expr { + fn bx(e: Expr) -> Box<Expr> { Box::new(e) } + fn fix(e: Expr, capi: &mut usize, names: &mut Vec<String>) -> Expr { + use Expr::*; + match e { + Group { e, i: Some(_), mut name } => { + *capi += 1; + let i = *capi; + let mut dupe_name = false; + if let Some(ref n1) = name { + if names.iter().any(|n2| n1 == n2) { + dupe_name = true; + } else { + names.push(n1.clone()); + } + } + if dupe_name { name = None; } + Group { e: bx(fix(*e, capi, names)), i: Some(i), name: name } + } + Group { e, i, name } => { + Group { e: bx(fix(*e, capi, names)), i: i, name: name } + } + Repeat { e, r, greedy } => { + Repeat { e: bx(fix(*e, capi, names)), r: r, greedy: greedy } + } + Concat(es) => + Concat(es.into_iter().map(|e| fix(e, capi, names)).collect()), + Alternate(es) => + Alternate(es.into_iter().map(|e| fix(e, capi, names)).collect()), + e => e, + } + } + fix(e, &mut 0, &mut vec![]) +} + +impl Arbitrary for Repeater { + fn arbitrary<G: Gen>(g: &mut G) -> Repeater { + use Repeater::*; + match g.gen_range(0, 4) { + 0 => ZeroOrOne, + 1 => ZeroOrMore, + 2 => OneOrMore, + 3 => { + use std::cmp::{max, min}; + let n1 = Arbitrary::arbitrary(g); + let n2 = Arbitrary::arbitrary(g); + Range { + min: min(n1, n2), + max: if g.gen() { None } else { Some(max(n1, n2)) }, + } + }, + _ => unreachable!(), + } + } + + fn shrink(&self) -> Box<Iterator<Item=Repeater>> { + use Repeater::*; + match *self { + ZeroOrOne | ZeroOrMore | OneOrMore => Box::new(None.into_iter()), + Range { min, max } => { + Box::new((min, max) + .shrink() + .map(|(min, max)| Range { min: min, max: max })) + } + } + } +} + +impl Arbitrary for CharClass { + fn arbitrary<G: Gen>(g: &mut G) -> CharClass { + let mut ranges: Vec<ClassRange> = Arbitrary::arbitrary(g); + if ranges.is_empty() { + ranges.push(Arbitrary::arbitrary(g)); + } + let cls = CharClass { + ranges: ranges, + casei: false, + }.canonicalize(); + if g.gen() { cls.case_fold() } else { cls } + } + + fn shrink(&self) -> Box<Iterator<Item=CharClass>> { + Box::new((self.ranges.clone(), self.casei) + .shrink() + .filter(|&(ref ranges, _)| ranges.len() > 0) + .map(|(ranges, casei)| { + let cls = CharClass { + ranges: ranges, + casei: casei, + }.canonicalize(); + if casei { cls.case_fold() } else { cls } + })) + } +} + +impl Arbitrary for ClassRange { + fn arbitrary<G: Gen>(g: &mut G) -> ClassRange { + use std::char::from_u32; + ClassRange::new( + from_u32(g.gen_range(97, 123)).unwrap(), + from_u32(g.gen_range(97, 123)).unwrap(), + ) + } + + fn shrink(&self) -> Box<Iterator<Item=ClassRange>> { + Box::new((self.start, self.end) + .shrink().map(|(s, e)| ClassRange::new(s, e))) + } +} + +#[test] +fn display_regex_roundtrips() { + // Given an AST, if we print it as a regex and then re-parse it, do we + // get back the same AST? + // A lot of this relies crucially on regex simplification. So this is + // testing `Expr::simplify` as much as it is testing the `Display` impl. + fn prop(e: Expr) -> bool { + e == Expr::parse(&e.to_string()).unwrap() + } + QuickCheck::new() + .tests(10_000) + .max_tests(20_000) + .gen(StdGen::new(::rand::thread_rng(), 50)) + .quickcheck(prop as fn(Expr) -> bool); +} diff --git a/deps/regex-syntax-0.1.2/src/unicode.rs b/deps/regex-syntax-0.1.2/src/unicode.rs new file mode 100644 index 000000000..c583438c0 --- /dev/null +++ b/deps/regex-syntax-0.1.2/src/unicode.rs @@ -0,0 +1,5053 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// NOTE: The following code was generated by "scripts/unicode.py", do not edit +// directly + +#![allow(warnings)] +pub mod general_category { + pub const C_table: &'static [(char, char)] = &[ + ('\u{0}', '\u{1f}'), ('\u{7f}', '\u{9f}'), ('\u{ad}', '\u{ad}'), + ('\u{378}', '\u{379}'), ('\u{380}', '\u{383}'), ('\u{38b}', '\u{38b}'), + ('\u{38d}', '\u{38d}'), ('\u{3a2}', '\u{3a2}'), ('\u{530}', '\u{530}'), + ('\u{557}', '\u{558}'), ('\u{560}', '\u{560}'), ('\u{588}', '\u{588}'), + ('\u{58b}', '\u{58c}'), ('\u{590}', '\u{590}'), ('\u{5c8}', '\u{5cf}'), + ('\u{5eb}', '\u{5ef}'), ('\u{5f5}', '\u{605}'), ('\u{61c}', '\u{61d}'), + ('\u{6dd}', '\u{6dd}'), ('\u{70e}', '\u{70f}'), ('\u{74b}', '\u{74c}'), + ('\u{7b2}', '\u{7bf}'), ('\u{7fb}', '\u{7ff}'), ('\u{82e}', '\u{82f}'), + ('\u{83f}', '\u{83f}'), ('\u{85c}', '\u{85d}'), ('\u{85f}', '\u{89f}'), + ('\u{8b3}', '\u{8e3}'), ('\u{984}', '\u{984}'), ('\u{98d}', '\u{98e}'), + ('\u{991}', '\u{992}'), ('\u{9a9}', '\u{9a9}'), ('\u{9b1}', '\u{9b1}'), + ('\u{9b3}', '\u{9b5}'), ('\u{9ba}', '\u{9bb}'), ('\u{9c5}', '\u{9c6}'), + ('\u{9c9}', '\u{9ca}'), ('\u{9cf}', '\u{9d6}'), ('\u{9d8}', '\u{9db}'), + ('\u{9de}', '\u{9de}'), ('\u{9e4}', '\u{9e5}'), ('\u{9fc}', '\u{a00}'), + ('\u{a04}', '\u{a04}'), ('\u{a0b}', '\u{a0e}'), ('\u{a11}', '\u{a12}'), + ('\u{a29}', '\u{a29}'), ('\u{a31}', '\u{a31}'), ('\u{a34}', '\u{a34}'), + ('\u{a37}', '\u{a37}'), ('\u{a3a}', '\u{a3b}'), ('\u{a3d}', '\u{a3d}'), + ('\u{a43}', '\u{a46}'), ('\u{a49}', '\u{a4a}'), ('\u{a4e}', '\u{a50}'), + ('\u{a52}', '\u{a58}'), ('\u{a5d}', '\u{a5d}'), ('\u{a5f}', '\u{a65}'), + ('\u{a76}', '\u{a80}'), ('\u{a84}', '\u{a84}'), ('\u{a8e}', '\u{a8e}'), + ('\u{a92}', '\u{a92}'), ('\u{aa9}', '\u{aa9}'), ('\u{ab1}', '\u{ab1}'), + ('\u{ab4}', '\u{ab4}'), ('\u{aba}', '\u{abb}'), ('\u{ac6}', '\u{ac6}'), + ('\u{aca}', '\u{aca}'), ('\u{ace}', '\u{acf}'), ('\u{ad1}', '\u{adf}'), + ('\u{ae4}', '\u{ae5}'), ('\u{af2}', '\u{b00}'), ('\u{b04}', '\u{b04}'), + ('\u{b0d}', '\u{b0e}'), ('\u{b11}', '\u{b12}'), ('\u{b29}', '\u{b29}'), + ('\u{b31}', '\u{b31}'), ('\u{b34}', '\u{b34}'), ('\u{b3a}', '\u{b3b}'), + ('\u{b45}', '\u{b46}'), ('\u{b49}', '\u{b4a}'), ('\u{b4e}', '\u{b55}'), + ('\u{b58}', '\u{b5b}'), ('\u{b5e}', '\u{b5e}'), ('\u{b64}', '\u{b65}'), + ('\u{b78}', '\u{b81}'), ('\u{b84}', '\u{b84}'), ('\u{b8b}', '\u{b8d}'), + ('\u{b91}', '\u{b91}'), ('\u{b96}', '\u{b98}'), ('\u{b9b}', '\u{b9b}'), + ('\u{b9d}', '\u{b9d}'), ('\u{ba0}', '\u{ba2}'), ('\u{ba5}', '\u{ba7}'), + ('\u{bab}', '\u{bad}'), ('\u{bba}', '\u{bbd}'), ('\u{bc3}', '\u{bc5}'), + ('\u{bc9}', '\u{bc9}'), ('\u{bce}', '\u{bcf}'), ('\u{bd1}', '\u{bd6}'), + ('\u{bd8}', '\u{be5}'), ('\u{bfb}', '\u{bff}'), ('\u{c04}', '\u{c04}'), + ('\u{c0d}', '\u{c0d}'), ('\u{c11}', '\u{c11}'), ('\u{c29}', '\u{c29}'), + ('\u{c3a}', '\u{c3c}'), ('\u{c45}', '\u{c45}'), ('\u{c49}', '\u{c49}'), + ('\u{c4e}', '\u{c54}'), ('\u{c57}', '\u{c57}'), ('\u{c5a}', '\u{c5f}'), + ('\u{c64}', '\u{c65}'), ('\u{c70}', '\u{c77}'), ('\u{c80}', '\u{c80}'), + ('\u{c84}', '\u{c84}'), ('\u{c8d}', '\u{c8d}'), ('\u{c91}', '\u{c91}'), + ('\u{ca9}', '\u{ca9}'), ('\u{cb4}', '\u{cb4}'), ('\u{cba}', '\u{cbb}'), + ('\u{cc5}', '\u{cc5}'), ('\u{cc9}', '\u{cc9}'), ('\u{cce}', '\u{cd4}'), + ('\u{cd7}', '\u{cdd}'), ('\u{cdf}', '\u{cdf}'), ('\u{ce4}', '\u{ce5}'), + ('\u{cf0}', '\u{cf0}'), ('\u{cf3}', '\u{d00}'), ('\u{d04}', '\u{d04}'), + ('\u{d0d}', '\u{d0d}'), ('\u{d11}', '\u{d11}'), ('\u{d3b}', '\u{d3c}'), + ('\u{d45}', '\u{d45}'), ('\u{d49}', '\u{d49}'), ('\u{d4f}', '\u{d56}'), + ('\u{d58}', '\u{d5f}'), ('\u{d64}', '\u{d65}'), ('\u{d76}', '\u{d78}'), + ('\u{d80}', '\u{d81}'), ('\u{d84}', '\u{d84}'), ('\u{d97}', '\u{d99}'), + ('\u{db2}', '\u{db2}'), ('\u{dbc}', '\u{dbc}'), ('\u{dbe}', '\u{dbf}'), + ('\u{dc7}', '\u{dc9}'), ('\u{dcb}', '\u{dce}'), ('\u{dd5}', '\u{dd5}'), + ('\u{dd7}', '\u{dd7}'), ('\u{de0}', '\u{de5}'), ('\u{df0}', '\u{df1}'), + ('\u{df5}', '\u{e00}'), ('\u{e3b}', '\u{e3e}'), ('\u{e5c}', '\u{e80}'), + ('\u{e83}', '\u{e83}'), ('\u{e85}', '\u{e86}'), ('\u{e89}', '\u{e89}'), + ('\u{e8b}', '\u{e8c}'), ('\u{e8e}', '\u{e93}'), ('\u{e98}', '\u{e98}'), + ('\u{ea0}', '\u{ea0}'), ('\u{ea4}', '\u{ea4}'), ('\u{ea6}', '\u{ea6}'), + ('\u{ea8}', '\u{ea9}'), ('\u{eac}', '\u{eac}'), ('\u{eba}', '\u{eba}'), + ('\u{ebe}', '\u{ebf}'), ('\u{ec5}', '\u{ec5}'), ('\u{ec7}', '\u{ec7}'), + ('\u{ece}', '\u{ecf}'), ('\u{eda}', '\u{edb}'), ('\u{ee0}', '\u{eff}'), + ('\u{f48}', '\u{f48}'), ('\u{f6d}', '\u{f70}'), ('\u{f98}', '\u{f98}'), + ('\u{fbd}', '\u{fbd}'), ('\u{fcd}', '\u{fcd}'), ('\u{fdb}', '\u{fff}'), + ('\u{10c6}', '\u{10c6}'), ('\u{10c8}', '\u{10cc}'), ('\u{10ce}', + '\u{10cf}'), ('\u{1249}', '\u{1249}'), ('\u{124e}', '\u{124f}'), + ('\u{1257}', '\u{1257}'), ('\u{1259}', '\u{1259}'), ('\u{125e}', + '\u{125f}'), ('\u{1289}', '\u{1289}'), ('\u{128e}', '\u{128f}'), + ('\u{12b1}', '\u{12b1}'), ('\u{12b6}', '\u{12b7}'), ('\u{12bf}', + '\u{12bf}'), ('\u{12c1}', '\u{12c1}'), ('\u{12c6}', '\u{12c7}'), + ('\u{12d7}', '\u{12d7}'), ('\u{1311}', '\u{1311}'), ('\u{1316}', + '\u{1317}'), ('\u{135b}', '\u{135c}'), ('\u{137d}', '\u{137f}'), + ('\u{139a}', '\u{139f}'), ('\u{13f5}', '\u{13ff}'), ('\u{169d}', + '\u{169f}'), ('\u{16f9}', '\u{16ff}'), ('\u{170d}', '\u{170d}'), + ('\u{1715}', '\u{171f}'), ('\u{1737}', '\u{173f}'), ('\u{1754}', + '\u{175f}'), ('\u{176d}', '\u{176d}'), ('\u{1771}', '\u{1771}'), + ('\u{1774}', '\u{177f}'), ('\u{17de}', '\u{17df}'), ('\u{17ea}', + '\u{17ef}'), ('\u{17fa}', '\u{17ff}'), ('\u{180e}', '\u{180f}'), + ('\u{181a}', '\u{181f}'), ('\u{1878}', '\u{187f}'), ('\u{18ab}', + '\u{18af}'), ('\u{18f6}', '\u{18ff}'), ('\u{191f}', '\u{191f}'), + ('\u{192c}', '\u{192f}'), ('\u{193c}', '\u{193f}'), ('\u{1941}', + '\u{1943}'), ('\u{196e}', '\u{196f}'), ('\u{1975}', '\u{197f}'), + ('\u{19ac}', '\u{19af}'), ('\u{19ca}', '\u{19cf}'), ('\u{19db}', + '\u{19dd}'), ('\u{1a1c}', '\u{1a1d}'), ('\u{1a5f}', '\u{1a5f}'), + ('\u{1a7d}', '\u{1a7e}'), ('\u{1a8a}', '\u{1a8f}'), ('\u{1a9a}', + '\u{1a9f}'), ('\u{1aae}', '\u{1aaf}'), ('\u{1abf}', '\u{1aff}'), + ('\u{1b4c}', '\u{1b4f}'), ('\u{1b7d}', '\u{1b7f}'), ('\u{1bf4}', + '\u{1bfb}'), ('\u{1c38}', '\u{1c3a}'), ('\u{1c4a}', '\u{1c4c}'), + ('\u{1c80}', '\u{1cbf}'), ('\u{1cc8}', '\u{1ccf}'), ('\u{1cf7}', + '\u{1cf7}'), ('\u{1cfa}', '\u{1cff}'), ('\u{1df6}', '\u{1dfb}'), + ('\u{1f16}', '\u{1f17}'), ('\u{1f1e}', '\u{1f1f}'), ('\u{1f46}', + '\u{1f47}'), ('\u{1f4e}', '\u{1f4f}'), ('\u{1f58}', '\u{1f58}'), + ('\u{1f5a}', '\u{1f5a}'), ('\u{1f5c}', '\u{1f5c}'), ('\u{1f5e}', + '\u{1f5e}'), ('\u{1f7e}', '\u{1f7f}'), ('\u{1fb5}', '\u{1fb5}'), + ('\u{1fc5}', '\u{1fc5}'), ('\u{1fd4}', '\u{1fd5}'), ('\u{1fdc}', + '\u{1fdc}'), ('\u{1ff0}', '\u{1ff1}'), ('\u{1ff5}', '\u{1ff5}'), + ('\u{1fff}', '\u{1fff}'), ('\u{200b}', '\u{200f}'), ('\u{202a}', + '\u{202e}'), ('\u{2060}', '\u{206f}'), ('\u{2072}', '\u{2073}'), + ('\u{208f}', '\u{208f}'), ('\u{209d}', '\u{209f}'), ('\u{20be}', + '\u{20cf}'), ('\u{20f1}', '\u{20ff}'), ('\u{218a}', '\u{218f}'), + ('\u{23fb}', '\u{23ff}'), ('\u{2427}', '\u{243f}'), ('\u{244b}', + '\u{245f}'), ('\u{2b74}', '\u{2b75}'), ('\u{2b96}', '\u{2b97}'), + ('\u{2bba}', '\u{2bbc}'), ('\u{2bc9}', '\u{2bc9}'), ('\u{2bd2}', + '\u{2bff}'), ('\u{2c2f}', '\u{2c2f}'), ('\u{2c5f}', '\u{2c5f}'), + ('\u{2cf4}', '\u{2cf8}'), ('\u{2d26}', '\u{2d26}'), ('\u{2d28}', + '\u{2d2c}'), ('\u{2d2e}', '\u{2d2f}'), ('\u{2d68}', '\u{2d6e}'), + ('\u{2d71}', '\u{2d7e}'), ('\u{2d97}', '\u{2d9f}'), ('\u{2da7}', + '\u{2da7}'), ('\u{2daf}', '\u{2daf}'), ('\u{2db7}', '\u{2db7}'), + ('\u{2dbf}', '\u{2dbf}'), ('\u{2dc7}', '\u{2dc7}'), ('\u{2dcf}', + '\u{2dcf}'), ('\u{2dd7}', '\u{2dd7}'), ('\u{2ddf}', '\u{2ddf}'), + ('\u{2e43}', '\u{2e7f}'), ('\u{2e9a}', '\u{2e9a}'), ('\u{2ef4}', + '\u{2eff}'), ('\u{2fd6}', '\u{2fef}'), ('\u{2ffc}', '\u{2fff}'), + ('\u{3040}', '\u{3040}'), ('\u{3097}', '\u{3098}'), ('\u{3100}', + '\u{3104}'), ('\u{312e}', '\u{3130}'), ('\u{318f}', '\u{318f}'), + ('\u{31bb}', '\u{31bf}'), ('\u{31e4}', '\u{31ef}'), ('\u{321f}', + '\u{321f}'), ('\u{32ff}', '\u{32ff}'), ('\u{4db6}', '\u{4dbf}'), + ('\u{9fcd}', '\u{9fff}'), ('\u{a48d}', '\u{a48f}'), ('\u{a4c7}', + '\u{a4cf}'), ('\u{a62c}', '\u{a63f}'), ('\u{a69e}', '\u{a69e}'), + ('\u{a6f8}', '\u{a6ff}'), ('\u{a78f}', '\u{a78f}'), ('\u{a7ae}', + '\u{a7af}'), ('\u{a7b2}', '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), + ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'), ('\u{a8c5}', + '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'), ('\u{a8fc}', '\u{a8ff}'), + ('\u{a954}', '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}', + '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'), ('\u{a9ff}', '\u{a9ff}'), + ('\u{aa37}', '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}', + '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}', '\u{ab00}'), + ('\u{ab07}', '\u{ab08}'), ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', + '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}', '\u{ab2f}'), + ('\u{ab60}', '\u{ab63}'), ('\u{ab66}', '\u{abbf}'), ('\u{abee}', + '\u{abef}'), ('\u{abfa}', '\u{abff}'), ('\u{d7a4}', '\u{d7af}'), + ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'), ('\u{e000}', + '\u{f8ff}'), ('\u{fa6e}', '\u{fa6f}'), ('\u{fada}', '\u{faff}'), + ('\u{fb07}', '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', + '\u{fb37}'), ('\u{fb3d}', '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), + ('\u{fb42}', '\u{fb42}'), ('\u{fb45}', '\u{fb45}'), ('\u{fbc2}', + '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'), + ('\u{fdc8}', '\u{fdef}'), ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', + '\u{fe1f}'), ('\u{fe2e}', '\u{fe2f}'), ('\u{fe53}', '\u{fe53}'), + ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}', '\u{fe6f}'), ('\u{fe75}', + '\u{fe75}'), ('\u{fefd}', '\u{ff00}'), ('\u{ffbf}', '\u{ffc1}'), + ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}', + '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'), + ('\u{ffef}', '\u{fffb}'), ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', + '\u{1000c}'), ('\u{10027}', '\u{10027}'), ('\u{1003b}', '\u{1003b}'), + ('\u{1003e}', '\u{1003e}'), ('\u{1004e}', '\u{1004f}'), ('\u{1005e}', + '\u{1007f}'), ('\u{100fb}', '\u{100ff}'), ('\u{10103}', '\u{10106}'), + ('\u{10134}', '\u{10136}'), ('\u{1018d}', '\u{1018f}'), ('\u{1019c}', + '\u{1019f}'), ('\u{101a1}', '\u{101cf}'), ('\u{101fe}', '\u{1027f}'), + ('\u{1029d}', '\u{1029f}'), ('\u{102d1}', '\u{102df}'), ('\u{102fc}', + '\u{102ff}'), ('\u{10324}', '\u{1032f}'), ('\u{1034b}', '\u{1034f}'), + ('\u{1037b}', '\u{1037f}'), ('\u{1039e}', '\u{1039e}'), ('\u{103c4}', + '\u{103c7}'), ('\u{103d6}', '\u{103ff}'), ('\u{1049e}', '\u{1049f}'), + ('\u{104aa}', '\u{104ff}'), ('\u{10528}', '\u{1052f}'), ('\u{10564}', + '\u{1056e}'), ('\u{10570}', '\u{105ff}'), ('\u{10737}', '\u{1073f}'), + ('\u{10756}', '\u{1075f}'), ('\u{10768}', '\u{107ff}'), ('\u{10806}', + '\u{10807}'), ('\u{10809}', '\u{10809}'), ('\u{10836}', '\u{10836}'), + ('\u{10839}', '\u{1083b}'), ('\u{1083d}', '\u{1083e}'), ('\u{10856}', + '\u{10856}'), ('\u{1089f}', '\u{108a6}'), ('\u{108b0}', '\u{108ff}'), + ('\u{1091c}', '\u{1091e}'), ('\u{1093a}', '\u{1093e}'), ('\u{10940}', + '\u{1097f}'), ('\u{109b8}', '\u{109bd}'), ('\u{109c0}', '\u{109ff}'), + ('\u{10a04}', '\u{10a04}'), ('\u{10a07}', '\u{10a0b}'), ('\u{10a14}', + '\u{10a14}'), ('\u{10a18}', '\u{10a18}'), ('\u{10a34}', '\u{10a37}'), + ('\u{10a3b}', '\u{10a3e}'), ('\u{10a48}', '\u{10a4f}'), ('\u{10a59}', + '\u{10a5f}'), ('\u{10aa0}', '\u{10abf}'), ('\u{10ae7}', '\u{10aea}'), + ('\u{10af7}', '\u{10aff}'), ('\u{10b36}', '\u{10b38}'), ('\u{10b56}', + '\u{10b57}'), ('\u{10b73}', '\u{10b77}'), ('\u{10b92}', '\u{10b98}'), + ('\u{10b9d}', '\u{10ba8}'), ('\u{10bb0}', '\u{10bff}'), ('\u{10c49}', + '\u{10e5f}'), ('\u{10e7f}', '\u{10fff}'), ('\u{1104e}', '\u{11051}'), + ('\u{11070}', '\u{1107e}'), ('\u{110bd}', '\u{110bd}'), ('\u{110c2}', + '\u{110cf}'), ('\u{110e9}', '\u{110ef}'), ('\u{110fa}', '\u{110ff}'), + ('\u{11135}', '\u{11135}'), ('\u{11144}', '\u{1114f}'), ('\u{11177}', + '\u{1117f}'), ('\u{111c9}', '\u{111cc}'), ('\u{111ce}', '\u{111cf}'), + ('\u{111db}', '\u{111e0}'), ('\u{111f5}', '\u{111ff}'), ('\u{11212}', + '\u{11212}'), ('\u{1123e}', '\u{112af}'), ('\u{112eb}', '\u{112ef}'), + ('\u{112fa}', '\u{11300}'), ('\u{11304}', '\u{11304}'), ('\u{1130d}', + '\u{1130e}'), ('\u{11311}', '\u{11312}'), ('\u{11329}', '\u{11329}'), + ('\u{11331}', '\u{11331}'), ('\u{11334}', '\u{11334}'), ('\u{1133a}', + '\u{1133b}'), ('\u{11345}', '\u{11346}'), ('\u{11349}', '\u{1134a}'), + ('\u{1134e}', '\u{11356}'), ('\u{11358}', '\u{1135c}'), ('\u{11364}', + '\u{11365}'), ('\u{1136d}', '\u{1136f}'), ('\u{11375}', '\u{1147f}'), + ('\u{114c8}', '\u{114cf}'), ('\u{114da}', '\u{1157f}'), ('\u{115b6}', + '\u{115b7}'), ('\u{115ca}', '\u{115ff}'), ('\u{11645}', '\u{1164f}'), + ('\u{1165a}', '\u{1167f}'), ('\u{116b8}', '\u{116bf}'), ('\u{116ca}', + '\u{1189f}'), ('\u{118f3}', '\u{118fe}'), ('\u{11900}', '\u{11abf}'), + ('\u{11af9}', '\u{11fff}'), ('\u{12399}', '\u{123ff}'), ('\u{1246f}', + '\u{1246f}'), ('\u{12475}', '\u{12fff}'), ('\u{1342f}', '\u{167ff}'), + ('\u{16a39}', '\u{16a3f}'), ('\u{16a5f}', '\u{16a5f}'), ('\u{16a6a}', + '\u{16a6d}'), ('\u{16a70}', '\u{16acf}'), ('\u{16aee}', '\u{16aef}'), + ('\u{16af6}', '\u{16aff}'), ('\u{16b46}', '\u{16b4f}'), ('\u{16b5a}', + '\u{16b5a}'), ('\u{16b62}', '\u{16b62}'), ('\u{16b78}', '\u{16b7c}'), + ('\u{16b90}', '\u{16eff}'), ('\u{16f45}', '\u{16f4f}'), ('\u{16f7f}', + '\u{16f8e}'), ('\u{16fa0}', '\u{1afff}'), ('\u{1b002}', '\u{1bbff}'), + ('\u{1bc6b}', '\u{1bc6f}'), ('\u{1bc7d}', '\u{1bc7f}'), ('\u{1bc89}', + '\u{1bc8f}'), ('\u{1bc9a}', '\u{1bc9b}'), ('\u{1bca0}', '\u{1cfff}'), + ('\u{1d0f6}', '\u{1d0ff}'), ('\u{1d127}', '\u{1d128}'), ('\u{1d173}', + '\u{1d17a}'), ('\u{1d1de}', '\u{1d1ff}'), ('\u{1d246}', '\u{1d2ff}'), + ('\u{1d357}', '\u{1d35f}'), ('\u{1d372}', '\u{1d3ff}'), ('\u{1d455}', + '\u{1d455}'), ('\u{1d49d}', '\u{1d49d}'), ('\u{1d4a0}', '\u{1d4a1}'), + ('\u{1d4a3}', '\u{1d4a4}'), ('\u{1d4a7}', '\u{1d4a8}'), ('\u{1d4ad}', + '\u{1d4ad}'), ('\u{1d4ba}', '\u{1d4ba}'), ('\u{1d4bc}', '\u{1d4bc}'), + ('\u{1d4c4}', '\u{1d4c4}'), ('\u{1d506}', '\u{1d506}'), ('\u{1d50b}', + '\u{1d50c}'), ('\u{1d515}', '\u{1d515}'), ('\u{1d51d}', '\u{1d51d}'), + ('\u{1d53a}', '\u{1d53a}'), ('\u{1d53f}', '\u{1d53f}'), ('\u{1d545}', + '\u{1d545}'), ('\u{1d547}', '\u{1d549}'), ('\u{1d551}', '\u{1d551}'), + ('\u{1d6a6}', '\u{1d6a7}'), ('\u{1d7cc}', '\u{1d7cd}'), ('\u{1d800}', + '\u{1e7ff}'), ('\u{1e8c5}', '\u{1e8c6}'), ('\u{1e8d7}', '\u{1edff}'), + ('\u{1ee04}', '\u{1ee04}'), ('\u{1ee20}', '\u{1ee20}'), ('\u{1ee23}', + '\u{1ee23}'), ('\u{1ee25}', '\u{1ee26}'), ('\u{1ee28}', '\u{1ee28}'), + ('\u{1ee33}', '\u{1ee33}'), ('\u{1ee38}', '\u{1ee38}'), ('\u{1ee3a}', + '\u{1ee3a}'), ('\u{1ee3c}', '\u{1ee41}'), ('\u{1ee43}', '\u{1ee46}'), + ('\u{1ee48}', '\u{1ee48}'), ('\u{1ee4a}', '\u{1ee4a}'), ('\u{1ee4c}', + '\u{1ee4c}'), ('\u{1ee50}', '\u{1ee50}'), ('\u{1ee53}', '\u{1ee53}'), + ('\u{1ee55}', '\u{1ee56}'), ('\u{1ee58}', '\u{1ee58}'), ('\u{1ee5a}', + '\u{1ee5a}'), ('\u{1ee5c}', '\u{1ee5c}'), ('\u{1ee5e}', '\u{1ee5e}'), + ('\u{1ee60}', '\u{1ee60}'), ('\u{1ee63}', '\u{1ee63}'), ('\u{1ee65}', + '\u{1ee66}'), ('\u{1ee6b}', '\u{1ee6b}'), ('\u{1ee73}', '\u{1ee73}'), + ('\u{1ee78}', '\u{1ee78}'), ('\u{1ee7d}', '\u{1ee7d}'), ('\u{1ee7f}', + '\u{1ee7f}'), ('\u{1ee8a}', '\u{1ee8a}'), ('\u{1ee9c}', '\u{1eea0}'), + ('\u{1eea4}', '\u{1eea4}'), ('\u{1eeaa}', '\u{1eeaa}'), ('\u{1eebc}', + '\u{1eeef}'), ('\u{1eef2}', '\u{1efff}'), ('\u{1f02c}', '\u{1f02f}'), + ('\u{1f094}', '\u{1f09f}'), ('\u{1f0af}', '\u{1f0b0}'), ('\u{1f0c0}', + '\u{1f0c0}'), ('\u{1f0d0}', '\u{1f0d0}'), ('\u{1f0f6}', '\u{1f0ff}'), + ('\u{1f10d}', '\u{1f10f}'), ('\u{1f12f}', '\u{1f12f}'), ('\u{1f16c}', + '\u{1f16f}'), ('\u{1f19b}', '\u{1f1e5}'), ('\u{1f203}', '\u{1f20f}'), + ('\u{1f23b}', '\u{1f23f}'), ('\u{1f249}', '\u{1f24f}'), ('\u{1f252}', + '\u{1f2ff}'), ('\u{1f32d}', '\u{1f32f}'), ('\u{1f37e}', '\u{1f37f}'), + ('\u{1f3cf}', '\u{1f3d3}'), ('\u{1f3f8}', '\u{1f3ff}'), ('\u{1f4ff}', + '\u{1f4ff}'), ('\u{1f54b}', '\u{1f54f}'), ('\u{1f57a}', '\u{1f57a}'), + ('\u{1f5a4}', '\u{1f5a4}'), ('\u{1f643}', '\u{1f644}'), ('\u{1f6d0}', + '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'), ('\u{1f6f4}', '\u{1f6ff}'), + ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'), ('\u{1f80c}', + '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', '\u{1f85f}'), + ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1ffff}'), ('\u{2a6d7}', + '\u{2a6ff}'), ('\u{2b735}', '\u{2b73f}'), ('\u{2b81e}', '\u{2f7ff}'), + ('\u{2fa1e}', '\u{e00ff}'), ('\u{e01f0}', '\u{10ffff}') + ]; + + pub const Cc_table: &'static [(char, char)] = &[ + ('\u{0}', '\u{1f}'), ('\u{7f}', '\u{9f}') + ]; + + pub const Cf_table: &'static [(char, char)] = &[ + ('\u{ad}', '\u{ad}'), ('\u{600}', '\u{605}'), ('\u{61c}', '\u{61c}'), + ('\u{6dd}', '\u{6dd}'), ('\u{70f}', '\u{70f}'), ('\u{180e}', + '\u{180e}'), ('\u{200b}', '\u{200f}'), ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{2064}'), ('\u{2066}', '\u{206f}'), ('\u{feff}', + '\u{feff}'), ('\u{fff9}', '\u{fffb}'), ('\u{110bd}', '\u{110bd}'), + ('\u{1bca0}', '\u{1bca3}'), ('\u{1d173}', '\u{1d17a}'), ('\u{e0001}', + '\u{e0001}'), ('\u{e0020}', '\u{e007f}') + ]; + + pub const Cn_table: &'static [(char, char)] = &[ + ('\u{378}', '\u{379}'), ('\u{380}', '\u{383}'), ('\u{38b}', '\u{38b}'), + ('\u{38d}', '\u{38d}'), ('\u{3a2}', '\u{3a2}'), ('\u{530}', '\u{530}'), + ('\u{557}', '\u{558}'), ('\u{560}', '\u{560}'), ('\u{588}', '\u{588}'), + ('\u{58b}', '\u{58c}'), ('\u{590}', '\u{590}'), ('\u{5c8}', '\u{5cf}'), + ('\u{5eb}', '\u{5ef}'), ('\u{5f5}', '\u{5ff}'), ('\u{61d}', '\u{61d}'), + ('\u{70e}', '\u{70e}'), ('\u{74b}', '\u{74c}'), ('\u{7b2}', '\u{7bf}'), + ('\u{7fb}', '\u{7ff}'), ('\u{82e}', '\u{82f}'), ('\u{83f}', '\u{83f}'), + ('\u{85c}', '\u{85d}'), ('\u{85f}', '\u{89f}'), ('\u{8b3}', '\u{8e3}'), + ('\u{984}', '\u{984}'), ('\u{98d}', '\u{98e}'), ('\u{991}', '\u{992}'), + ('\u{9a9}', '\u{9a9}'), ('\u{9b1}', '\u{9b1}'), ('\u{9b3}', '\u{9b5}'), + ('\u{9ba}', '\u{9bb}'), ('\u{9c5}', '\u{9c6}'), ('\u{9c9}', '\u{9ca}'), + ('\u{9cf}', '\u{9d6}'), ('\u{9d8}', '\u{9db}'), ('\u{9de}', '\u{9de}'), + ('\u{9e4}', '\u{9e5}'), ('\u{9fc}', '\u{a00}'), ('\u{a04}', '\u{a04}'), + ('\u{a0b}', '\u{a0e}'), ('\u{a11}', '\u{a12}'), ('\u{a29}', '\u{a29}'), + ('\u{a31}', '\u{a31}'), ('\u{a34}', '\u{a34}'), ('\u{a37}', '\u{a37}'), + ('\u{a3a}', '\u{a3b}'), ('\u{a3d}', '\u{a3d}'), ('\u{a43}', '\u{a46}'), + ('\u{a49}', '\u{a4a}'), ('\u{a4e}', '\u{a50}'), ('\u{a52}', '\u{a58}'), + ('\u{a5d}', '\u{a5d}'), ('\u{a5f}', '\u{a65}'), ('\u{a76}', '\u{a80}'), + ('\u{a84}', '\u{a84}'), ('\u{a8e}', '\u{a8e}'), ('\u{a92}', '\u{a92}'), + ('\u{aa9}', '\u{aa9}'), ('\u{ab1}', '\u{ab1}'), ('\u{ab4}', '\u{ab4}'), + ('\u{aba}', '\u{abb}'), ('\u{ac6}', '\u{ac6}'), ('\u{aca}', '\u{aca}'), + ('\u{ace}', '\u{acf}'), ('\u{ad1}', '\u{adf}'), ('\u{ae4}', '\u{ae5}'), + ('\u{af2}', '\u{b00}'), ('\u{b04}', '\u{b04}'), ('\u{b0d}', '\u{b0e}'), + ('\u{b11}', '\u{b12}'), ('\u{b29}', '\u{b29}'), ('\u{b31}', '\u{b31}'), + ('\u{b34}', '\u{b34}'), ('\u{b3a}', '\u{b3b}'), ('\u{b45}', '\u{b46}'), + ('\u{b49}', '\u{b4a}'), ('\u{b4e}', '\u{b55}'), ('\u{b58}', '\u{b5b}'), + ('\u{b5e}', '\u{b5e}'), ('\u{b64}', '\u{b65}'), ('\u{b78}', '\u{b81}'), + ('\u{b84}', '\u{b84}'), ('\u{b8b}', '\u{b8d}'), ('\u{b91}', '\u{b91}'), + ('\u{b96}', '\u{b98}'), ('\u{b9b}', '\u{b9b}'), ('\u{b9d}', '\u{b9d}'), + ('\u{ba0}', '\u{ba2}'), ('\u{ba5}', '\u{ba7}'), ('\u{bab}', '\u{bad}'), + ('\u{bba}', '\u{bbd}'), ('\u{bc3}', '\u{bc5}'), ('\u{bc9}', '\u{bc9}'), + ('\u{bce}', '\u{bcf}'), ('\u{bd1}', '\u{bd6}'), ('\u{bd8}', '\u{be5}'), + ('\u{bfb}', '\u{bff}'), ('\u{c04}', '\u{c04}'), ('\u{c0d}', '\u{c0d}'), + ('\u{c11}', '\u{c11}'), ('\u{c29}', '\u{c29}'), ('\u{c3a}', '\u{c3c}'), + ('\u{c45}', '\u{c45}'), ('\u{c49}', '\u{c49}'), ('\u{c4e}', '\u{c54}'), + ('\u{c57}', '\u{c57}'), ('\u{c5a}', '\u{c5f}'), ('\u{c64}', '\u{c65}'), + ('\u{c70}', '\u{c77}'), ('\u{c80}', '\u{c80}'), ('\u{c84}', '\u{c84}'), + ('\u{c8d}', '\u{c8d}'), ('\u{c91}', '\u{c91}'), ('\u{ca9}', '\u{ca9}'), + ('\u{cb4}', '\u{cb4}'), ('\u{cba}', '\u{cbb}'), ('\u{cc5}', '\u{cc5}'), + ('\u{cc9}', '\u{cc9}'), ('\u{cce}', '\u{cd4}'), ('\u{cd7}', '\u{cdd}'), + ('\u{cdf}', '\u{cdf}'), ('\u{ce4}', '\u{ce5}'), ('\u{cf0}', '\u{cf0}'), + ('\u{cf3}', '\u{d00}'), ('\u{d04}', '\u{d04}'), ('\u{d0d}', '\u{d0d}'), + ('\u{d11}', '\u{d11}'), ('\u{d3b}', '\u{d3c}'), ('\u{d45}', '\u{d45}'), + ('\u{d49}', '\u{d49}'), ('\u{d4f}', '\u{d56}'), ('\u{d58}', '\u{d5f}'), + ('\u{d64}', '\u{d65}'), ('\u{d76}', '\u{d78}'), ('\u{d80}', '\u{d81}'), + ('\u{d84}', '\u{d84}'), ('\u{d97}', '\u{d99}'), ('\u{db2}', '\u{db2}'), + ('\u{dbc}', '\u{dbc}'), ('\u{dbe}', '\u{dbf}'), ('\u{dc7}', '\u{dc9}'), + ('\u{dcb}', '\u{dce}'), ('\u{dd5}', '\u{dd5}'), ('\u{dd7}', '\u{dd7}'), + ('\u{de0}', '\u{de5}'), ('\u{df0}', '\u{df1}'), ('\u{df5}', '\u{e00}'), + ('\u{e3b}', '\u{e3e}'), ('\u{e5c}', '\u{e80}'), ('\u{e83}', '\u{e83}'), + ('\u{e85}', '\u{e86}'), ('\u{e89}', '\u{e89}'), ('\u{e8b}', '\u{e8c}'), + ('\u{e8e}', '\u{e93}'), ('\u{e98}', '\u{e98}'), ('\u{ea0}', '\u{ea0}'), + ('\u{ea4}', '\u{ea4}'), ('\u{ea6}', '\u{ea6}'), ('\u{ea8}', '\u{ea9}'), + ('\u{eac}', '\u{eac}'), ('\u{eba}', '\u{eba}'), ('\u{ebe}', '\u{ebf}'), + ('\u{ec5}', '\u{ec5}'), ('\u{ec7}', '\u{ec7}'), ('\u{ece}', '\u{ecf}'), + ('\u{eda}', '\u{edb}'), ('\u{ee0}', '\u{eff}'), ('\u{f48}', '\u{f48}'), + ('\u{f6d}', '\u{f70}'), ('\u{f98}', '\u{f98}'), ('\u{fbd}', '\u{fbd}'), + ('\u{fcd}', '\u{fcd}'), ('\u{fdb}', '\u{fff}'), ('\u{10c6}', + '\u{10c6}'), ('\u{10c8}', '\u{10cc}'), ('\u{10ce}', '\u{10cf}'), + ('\u{1249}', '\u{1249}'), ('\u{124e}', '\u{124f}'), ('\u{1257}', + '\u{1257}'), ('\u{1259}', '\u{1259}'), ('\u{125e}', '\u{125f}'), + ('\u{1289}', '\u{1289}'), ('\u{128e}', '\u{128f}'), ('\u{12b1}', + '\u{12b1}'), ('\u{12b6}', '\u{12b7}'), ('\u{12bf}', '\u{12bf}'), + ('\u{12c1}', '\u{12c1}'), ('\u{12c6}', '\u{12c7}'), ('\u{12d7}', + '\u{12d7}'), ('\u{1311}', '\u{1311}'), ('\u{1316}', '\u{1317}'), + ('\u{135b}', '\u{135c}'), ('\u{137d}', '\u{137f}'), ('\u{139a}', + '\u{139f}'), ('\u{13f5}', '\u{13ff}'), ('\u{169d}', '\u{169f}'), + ('\u{16f9}', '\u{16ff}'), ('\u{170d}', '\u{170d}'), ('\u{1715}', + '\u{171f}'), ('\u{1737}', '\u{173f}'), ('\u{1754}', '\u{175f}'), + ('\u{176d}', '\u{176d}'), ('\u{1771}', '\u{1771}'), ('\u{1774}', + '\u{177f}'), ('\u{17de}', '\u{17df}'), ('\u{17ea}', '\u{17ef}'), + ('\u{17fa}', '\u{17ff}'), ('\u{180f}', '\u{180f}'), ('\u{181a}', + '\u{181f}'), ('\u{1878}', '\u{187f}'), ('\u{18ab}', '\u{18af}'), + ('\u{18f6}', '\u{18ff}'), ('\u{191f}', '\u{191f}'), ('\u{192c}', + '\u{192f}'), ('\u{193c}', '\u{193f}'), ('\u{1941}', '\u{1943}'), + ('\u{196e}', '\u{196f}'), ('\u{1975}', '\u{197f}'), ('\u{19ac}', + '\u{19af}'), ('\u{19ca}', '\u{19cf}'), ('\u{19db}', '\u{19dd}'), + ('\u{1a1c}', '\u{1a1d}'), ('\u{1a5f}', '\u{1a5f}'), ('\u{1a7d}', + '\u{1a7e}'), ('\u{1a8a}', '\u{1a8f}'), ('\u{1a9a}', '\u{1a9f}'), + ('\u{1aae}', '\u{1aaf}'), ('\u{1abf}', '\u{1aff}'), ('\u{1b4c}', + '\u{1b4f}'), ('\u{1b7d}', '\u{1b7f}'), ('\u{1bf4}', '\u{1bfb}'), + ('\u{1c38}', '\u{1c3a}'), ('\u{1c4a}', '\u{1c4c}'), ('\u{1c80}', + '\u{1cbf}'), ('\u{1cc8}', '\u{1ccf}'), ('\u{1cf7}', '\u{1cf7}'), + ('\u{1cfa}', '\u{1cff}'), ('\u{1df6}', '\u{1dfb}'), ('\u{1f16}', + '\u{1f17}'), ('\u{1f1e}', '\u{1f1f}'), ('\u{1f46}', '\u{1f47}'), + ('\u{1f4e}', '\u{1f4f}'), ('\u{1f58}', '\u{1f58}'), ('\u{1f5a}', + '\u{1f5a}'), ('\u{1f5c}', '\u{1f5c}'), ('\u{1f5e}', '\u{1f5e}'), + ('\u{1f7e}', '\u{1f7f}'), ('\u{1fb5}', '\u{1fb5}'), ('\u{1fc5}', + '\u{1fc5}'), ('\u{1fd4}', '\u{1fd5}'), ('\u{1fdc}', '\u{1fdc}'), + ('\u{1ff0}', '\u{1ff1}'), ('\u{1ff5}', '\u{1ff5}'), ('\u{1fff}', + '\u{1fff}'), ('\u{2065}', '\u{2065}'), ('\u{2072}', '\u{2073}'), + ('\u{208f}', '\u{208f}'), ('\u{209d}', '\u{209f}'), ('\u{20be}', + '\u{20cf}'), ('\u{20f1}', '\u{20ff}'), ('\u{218a}', '\u{218f}'), + ('\u{23fb}', '\u{23ff}'), ('\u{2427}', '\u{243f}'), ('\u{244b}', + '\u{245f}'), ('\u{2b74}', '\u{2b75}'), ('\u{2b96}', '\u{2b97}'), + ('\u{2bba}', '\u{2bbc}'), ('\u{2bc9}', '\u{2bc9}'), ('\u{2bd2}', + '\u{2bff}'), ('\u{2c2f}', '\u{2c2f}'), ('\u{2c5f}', '\u{2c5f}'), + ('\u{2cf4}', '\u{2cf8}'), ('\u{2d26}', '\u{2d26}'), ('\u{2d28}', + '\u{2d2c}'), ('\u{2d2e}', '\u{2d2f}'), ('\u{2d68}', '\u{2d6e}'), + ('\u{2d71}', '\u{2d7e}'), ('\u{2d97}', '\u{2d9f}'), ('\u{2da7}', + '\u{2da7}'), ('\u{2daf}', '\u{2daf}'), ('\u{2db7}', '\u{2db7}'), + ('\u{2dbf}', '\u{2dbf}'), ('\u{2dc7}', '\u{2dc7}'), ('\u{2dcf}', + '\u{2dcf}'), ('\u{2dd7}', '\u{2dd7}'), ('\u{2ddf}', '\u{2ddf}'), + ('\u{2e43}', '\u{2e7f}'), ('\u{2e9a}', '\u{2e9a}'), ('\u{2ef4}', + '\u{2eff}'), ('\u{2fd6}', '\u{2fef}'), ('\u{2ffc}', '\u{2fff}'), + ('\u{3040}', '\u{3040}'), ('\u{3097}', '\u{3098}'), ('\u{3100}', + '\u{3104}'), ('\u{312e}', '\u{3130}'), ('\u{318f}', '\u{318f}'), + ('\u{31bb}', '\u{31bf}'), ('\u{31e4}', '\u{31ef}'), ('\u{321f}', + '\u{321f}'), ('\u{32ff}', '\u{32ff}'), ('\u{4db6}', '\u{4dbf}'), + ('\u{9fcd}', '\u{9fff}'), ('\u{a48d}', '\u{a48f}'), ('\u{a4c7}', + '\u{a4cf}'), ('\u{a62c}', '\u{a63f}'), ('\u{a69e}', '\u{a69e}'), + ('\u{a6f8}', '\u{a6ff}'), ('\u{a78f}', '\u{a78f}'), ('\u{a7ae}', + '\u{a7af}'), ('\u{a7b2}', '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), + ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'), ('\u{a8c5}', + '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'), ('\u{a8fc}', '\u{a8ff}'), + ('\u{a954}', '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}', + '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'), ('\u{a9ff}', '\u{a9ff}'), + ('\u{aa37}', '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}', + '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}', '\u{ab00}'), + ('\u{ab07}', '\u{ab08}'), ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', + '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}', '\u{ab2f}'), + ('\u{ab60}', '\u{ab63}'), ('\u{ab66}', '\u{abbf}'), ('\u{abee}', + '\u{abef}'), ('\u{abfa}', '\u{abff}'), ('\u{d7a4}', '\u{d7af}'), + ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'), ('\u{fa6e}', + '\u{fa6f}'), ('\u{fada}', '\u{faff}'), ('\u{fb07}', '\u{fb12}'), + ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', '\u{fb37}'), ('\u{fb3d}', + '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'), + ('\u{fb45}', '\u{fb45}'), ('\u{fbc2}', '\u{fbd2}'), ('\u{fd40}', + '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'), ('\u{fdc8}', '\u{fdef}'), + ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'), ('\u{fe2e}', + '\u{fe2f}'), ('\u{fe53}', '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), + ('\u{fe6c}', '\u{fe6f}'), ('\u{fe75}', '\u{fe75}'), ('\u{fefd}', + '\u{fefe}'), ('\u{ff00}', '\u{ff00}'), ('\u{ffbf}', '\u{ffc1}'), + ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}', + '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'), + ('\u{ffef}', '\u{fff8}'), ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', + '\u{1000c}'), ('\u{10027}', '\u{10027}'), ('\u{1003b}', '\u{1003b}'), + ('\u{1003e}', '\u{1003e}'), ('\u{1004e}', '\u{1004f}'), ('\u{1005e}', + '\u{1007f}'), ('\u{100fb}', '\u{100ff}'), ('\u{10103}', '\u{10106}'), + ('\u{10134}', '\u{10136}'), ('\u{1018d}', '\u{1018f}'), ('\u{1019c}', + '\u{1019f}'), ('\u{101a1}', '\u{101cf}'), ('\u{101fe}', '\u{1027f}'), + ('\u{1029d}', '\u{1029f}'), ('\u{102d1}', '\u{102df}'), ('\u{102fc}', + '\u{102ff}'), ('\u{10324}', '\u{1032f}'), ('\u{1034b}', '\u{1034f}'), + ('\u{1037b}', '\u{1037f}'), ('\u{1039e}', '\u{1039e}'), ('\u{103c4}', + '\u{103c7}'), ('\u{103d6}', '\u{103ff}'), ('\u{1049e}', '\u{1049f}'), + ('\u{104aa}', '\u{104ff}'), ('\u{10528}', '\u{1052f}'), ('\u{10564}', + '\u{1056e}'), ('\u{10570}', '\u{105ff}'), ('\u{10737}', '\u{1073f}'), + ('\u{10756}', '\u{1075f}'), ('\u{10768}', '\u{107ff}'), ('\u{10806}', + '\u{10807}'), ('\u{10809}', '\u{10809}'), ('\u{10836}', '\u{10836}'), + ('\u{10839}', '\u{1083b}'), ('\u{1083d}', '\u{1083e}'), ('\u{10856}', + '\u{10856}'), ('\u{1089f}', '\u{108a6}'), ('\u{108b0}', '\u{108ff}'), + ('\u{1091c}', '\u{1091e}'), ('\u{1093a}', '\u{1093e}'), ('\u{10940}', + '\u{1097f}'), ('\u{109b8}', '\u{109bd}'), ('\u{109c0}', '\u{109ff}'), + ('\u{10a04}', '\u{10a04}'), ('\u{10a07}', '\u{10a0b}'), ('\u{10a14}', + '\u{10a14}'), ('\u{10a18}', '\u{10a18}'), ('\u{10a34}', '\u{10a37}'), + ('\u{10a3b}', '\u{10a3e}'), ('\u{10a48}', '\u{10a4f}'), ('\u{10a59}', + '\u{10a5f}'), ('\u{10aa0}', '\u{10abf}'), ('\u{10ae7}', '\u{10aea}'), + ('\u{10af7}', '\u{10aff}'), ('\u{10b36}', '\u{10b38}'), ('\u{10b56}', + '\u{10b57}'), ('\u{10b73}', '\u{10b77}'), ('\u{10b92}', '\u{10b98}'), + ('\u{10b9d}', '\u{10ba8}'), ('\u{10bb0}', '\u{10bff}'), ('\u{10c49}', + '\u{10e5f}'), ('\u{10e7f}', '\u{10fff}'), ('\u{1104e}', '\u{11051}'), + ('\u{11070}', '\u{1107e}'), ('\u{110c2}', '\u{110cf}'), ('\u{110e9}', + '\u{110ef}'), ('\u{110fa}', '\u{110ff}'), ('\u{11135}', '\u{11135}'), + ('\u{11144}', '\u{1114f}'), ('\u{11177}', '\u{1117f}'), ('\u{111c9}', + '\u{111cc}'), ('\u{111ce}', '\u{111cf}'), ('\u{111db}', '\u{111e0}'), + ('\u{111f5}', '\u{111ff}'), ('\u{11212}', '\u{11212}'), ('\u{1123e}', + '\u{112af}'), ('\u{112eb}', '\u{112ef}'), ('\u{112fa}', '\u{11300}'), + ('\u{11304}', '\u{11304}'), ('\u{1130d}', '\u{1130e}'), ('\u{11311}', + '\u{11312}'), ('\u{11329}', '\u{11329}'), ('\u{11331}', '\u{11331}'), + ('\u{11334}', '\u{11334}'), ('\u{1133a}', '\u{1133b}'), ('\u{11345}', + '\u{11346}'), ('\u{11349}', '\u{1134a}'), ('\u{1134e}', '\u{11356}'), + ('\u{11358}', '\u{1135c}'), ('\u{11364}', '\u{11365}'), ('\u{1136d}', + '\u{1136f}'), ('\u{11375}', '\u{1147f}'), ('\u{114c8}', '\u{114cf}'), + ('\u{114da}', '\u{1157f}'), ('\u{115b6}', '\u{115b7}'), ('\u{115ca}', + '\u{115ff}'), ('\u{11645}', '\u{1164f}'), ('\u{1165a}', '\u{1167f}'), + ('\u{116b8}', '\u{116bf}'), ('\u{116ca}', '\u{1189f}'), ('\u{118f3}', + '\u{118fe}'), ('\u{11900}', '\u{11abf}'), ('\u{11af9}', '\u{11fff}'), + ('\u{12399}', '\u{123ff}'), ('\u{1246f}', '\u{1246f}'), ('\u{12475}', + '\u{12fff}'), ('\u{1342f}', '\u{167ff}'), ('\u{16a39}', '\u{16a3f}'), + ('\u{16a5f}', '\u{16a5f}'), ('\u{16a6a}', '\u{16a6d}'), ('\u{16a70}', + '\u{16acf}'), ('\u{16aee}', '\u{16aef}'), ('\u{16af6}', '\u{16aff}'), + ('\u{16b46}', '\u{16b4f}'), ('\u{16b5a}', '\u{16b5a}'), ('\u{16b62}', + '\u{16b62}'), ('\u{16b78}', '\u{16b7c}'), ('\u{16b90}', '\u{16eff}'), + ('\u{16f45}', '\u{16f4f}'), ('\u{16f7f}', '\u{16f8e}'), ('\u{16fa0}', + '\u{1afff}'), ('\u{1b002}', '\u{1bbff}'), ('\u{1bc6b}', '\u{1bc6f}'), + ('\u{1bc7d}', '\u{1bc7f}'), ('\u{1bc89}', '\u{1bc8f}'), ('\u{1bc9a}', + '\u{1bc9b}'), ('\u{1bca4}', '\u{1cfff}'), ('\u{1d0f6}', '\u{1d0ff}'), + ('\u{1d127}', '\u{1d128}'), ('\u{1d1de}', '\u{1d1ff}'), ('\u{1d246}', + '\u{1d2ff}'), ('\u{1d357}', '\u{1d35f}'), ('\u{1d372}', '\u{1d3ff}'), + ('\u{1d455}', '\u{1d455}'), ('\u{1d49d}', '\u{1d49d}'), ('\u{1d4a0}', + '\u{1d4a1}'), ('\u{1d4a3}', '\u{1d4a4}'), ('\u{1d4a7}', '\u{1d4a8}'), + ('\u{1d4ad}', '\u{1d4ad}'), ('\u{1d4ba}', '\u{1d4ba}'), ('\u{1d4bc}', + '\u{1d4bc}'), ('\u{1d4c4}', '\u{1d4c4}'), ('\u{1d506}', '\u{1d506}'), + ('\u{1d50b}', '\u{1d50c}'), ('\u{1d515}', '\u{1d515}'), ('\u{1d51d}', + '\u{1d51d}'), ('\u{1d53a}', '\u{1d53a}'), ('\u{1d53f}', '\u{1d53f}'), + ('\u{1d545}', '\u{1d545}'), ('\u{1d547}', '\u{1d549}'), ('\u{1d551}', + '\u{1d551}'), ('\u{1d6a6}', '\u{1d6a7}'), ('\u{1d7cc}', '\u{1d7cd}'), + ('\u{1d800}', '\u{1e7ff}'), ('\u{1e8c5}', '\u{1e8c6}'), ('\u{1e8d7}', + '\u{1edff}'), ('\u{1ee04}', '\u{1ee04}'), ('\u{1ee20}', '\u{1ee20}'), + ('\u{1ee23}', '\u{1ee23}'), ('\u{1ee25}', '\u{1ee26}'), ('\u{1ee28}', + '\u{1ee28}'), ('\u{1ee33}', '\u{1ee33}'), ('\u{1ee38}', '\u{1ee38}'), + ('\u{1ee3a}', '\u{1ee3a}'), ('\u{1ee3c}', '\u{1ee41}'), ('\u{1ee43}', + '\u{1ee46}'), ('\u{1ee48}', '\u{1ee48}'), ('\u{1ee4a}', '\u{1ee4a}'), + ('\u{1ee4c}', '\u{1ee4c}'), ('\u{1ee50}', '\u{1ee50}'), ('\u{1ee53}', + '\u{1ee53}'), ('\u{1ee55}', '\u{1ee56}'), ('\u{1ee58}', '\u{1ee58}'), + ('\u{1ee5a}', '\u{1ee5a}'), ('\u{1ee5c}', '\u{1ee5c}'), ('\u{1ee5e}', + '\u{1ee5e}'), ('\u{1ee60}', '\u{1ee60}'), ('\u{1ee63}', '\u{1ee63}'), + ('\u{1ee65}', '\u{1ee66}'), ('\u{1ee6b}', '\u{1ee6b}'), ('\u{1ee73}', + '\u{1ee73}'), ('\u{1ee78}', '\u{1ee78}'), ('\u{1ee7d}', '\u{1ee7d}'), + ('\u{1ee7f}', '\u{1ee7f}'), ('\u{1ee8a}', '\u{1ee8a}'), ('\u{1ee9c}', + '\u{1eea0}'), ('\u{1eea4}', '\u{1eea4}'), ('\u{1eeaa}', '\u{1eeaa}'), + ('\u{1eebc}', '\u{1eeef}'), ('\u{1eef2}', '\u{1efff}'), ('\u{1f02c}', + '\u{1f02f}'), ('\u{1f094}', '\u{1f09f}'), ('\u{1f0af}', '\u{1f0b0}'), + ('\u{1f0c0}', '\u{1f0c0}'), ('\u{1f0d0}', '\u{1f0d0}'), ('\u{1f0f6}', + '\u{1f0ff}'), ('\u{1f10d}', '\u{1f10f}'), ('\u{1f12f}', '\u{1f12f}'), + ('\u{1f16c}', '\u{1f16f}'), ('\u{1f19b}', '\u{1f1e5}'), ('\u{1f203}', + '\u{1f20f}'), ('\u{1f23b}', '\u{1f23f}'), ('\u{1f249}', '\u{1f24f}'), + ('\u{1f252}', '\u{1f2ff}'), ('\u{1f32d}', '\u{1f32f}'), ('\u{1f37e}', + '\u{1f37f}'), ('\u{1f3cf}', '\u{1f3d3}'), ('\u{1f3f8}', '\u{1f3ff}'), + ('\u{1f4ff}', '\u{1f4ff}'), ('\u{1f54b}', '\u{1f54f}'), ('\u{1f57a}', + '\u{1f57a}'), ('\u{1f5a4}', '\u{1f5a4}'), ('\u{1f643}', '\u{1f644}'), + ('\u{1f6d0}', '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'), ('\u{1f6f4}', + '\u{1f6ff}'), ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'), + ('\u{1f80c}', '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', + '\u{1f85f}'), ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1ffff}'), + ('\u{2a6d7}', '\u{2a6ff}'), ('\u{2b735}', '\u{2b73f}'), ('\u{2b81e}', + '\u{2f7ff}'), ('\u{2fa1e}', '\u{e0000}'), ('\u{e0002}', '\u{e001f}'), + ('\u{e0080}', '\u{e00ff}'), ('\u{e01f0}', '\u{effff}'), ('\u{ffffe}', + '\u{fffff}'), ('\u{10fffe}', '\u{10ffff}') + ]; + + pub const Co_table: &'static [(char, char)] = &[ + ('\u{e000}', '\u{f8ff}'), ('\u{f0000}', '\u{ffffd}'), ('\u{100000}', + '\u{10fffd}') + ]; + + pub const L_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), + ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), + ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), + ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), + ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37a}', '\u{37d}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), + ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), + ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), + ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{5d0}', '\u{5ea}'), + ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{64a}'), ('\u{66e}', '\u{66f}'), + ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6e5}', '\u{6e6}'), + ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), + ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), + ('\u{7b1}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), + ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{815}'), ('\u{81a}', '\u{81a}'), + ('\u{824}', '\u{824}'), ('\u{828}', '\u{828}'), ('\u{840}', '\u{858}'), + ('\u{8a0}', '\u{8b2}'), ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), + ('\u{950}', '\u{950}'), ('\u{958}', '\u{961}'), ('\u{971}', '\u{980}'), + ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), + ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), + ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), ('\u{9dc}', '\u{9dd}'), + ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{a05}', '\u{a0a}'), + ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), + ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), + ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a72}', '\u{a74}'), + ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), + ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), + ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), + ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), + ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), + ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b61}'), + ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), + ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), + ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), + ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bd0}', '\u{bd0}'), + ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), + ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c59}'), + ('\u{c60}', '\u{c61}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), + ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), + ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce1}'), + ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), + ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), ('\u{d4e}', '\u{d4e}'), + ('\u{d60}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'), ('\u{d85}', '\u{d96}'), + ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), + ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), ('\u{e32}', '\u{e33}'), + ('\u{e40}', '\u{e46}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), + ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), + ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), + ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), + ('\u{ead}', '\u{eb0}'), ('\u{eb2}', '\u{eb3}'), ('\u{ebd}', '\u{ebd}'), + ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{edc}', '\u{edf}'), + ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), + ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}', + '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), + ('\u{1061}', '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', + '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}', '\u{108e}'), + ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', + '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), + ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', + '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), + ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', + '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), + ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', + '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), + ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f4}'), ('\u{1401}', + '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), + ('\u{16a0}', '\u{16ea}'), ('\u{16f1}', '\u{16f8}'), ('\u{1700}', + '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'), + ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', + '\u{1770}'), ('\u{1780}', '\u{17b3}'), ('\u{17d7}', '\u{17d7}'), + ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', + '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), + ('\u{1900}', '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', + '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19c1}', '\u{19c7}'), + ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1aa7}', + '\u{1aa7}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), + ('\u{1b83}', '\u{1ba0}'), ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', + '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), ('\u{1c4d}', '\u{1c4f}'), + ('\u{1c5a}', '\u{1c7d}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', + '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1d00}', '\u{1dbf}'), + ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', + '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), + ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', + '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), + ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', + '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), + ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', + '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), + ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', + '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), + ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', + '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), + ('\u{212a}', '\u{212d}'), ('\u{212f}', '\u{2139}'), ('\u{213c}', + '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), + ('\u{2183}', '\u{2184}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', + '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), + ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', + '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), + ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', + '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), + ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', + '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), + ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3006}'), ('\u{3031}', + '\u{3035}'), ('\u{303b}', '\u{303c}'), ('\u{3041}', '\u{3096}'), + ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', + '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), + ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', + '\u{4db5}'), ('\u{4e00}', '\u{9fcc}'), ('\u{a000}', '\u{a48c}'), + ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', + '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), + ('\u{a67f}', '\u{a69d}'), ('\u{a6a0}', '\u{a6e5}'), ('\u{a717}', + '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a78e}'), + ('\u{a790}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', + '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), + ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', + '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), + ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', + '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), + ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', + '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), + ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', + '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), + ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', + '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), + ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', + '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), + ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', + '\u{ab5a}'), ('\u{ab5c}', '\u{ab5f}'), ('\u{ab64}', '\u{ab65}'), + ('\u{abc0}', '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', + '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), + ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', + '\u{fb17}'), ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), + ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', + '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), + ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', + '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), + ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}', + '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), + ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', + '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), + ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', + '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), + ('\u{10080}', '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', + '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{10340}'), + ('\u{10342}', '\u{10349}'), ('\u{10350}', '\u{10375}'), ('\u{10380}', + '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), + ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', + '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), + ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', + '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), + ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', + '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{10900}', '\u{10915}'), + ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', + '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), + ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', + '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), + ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', + '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), + ('\u{10c00}', '\u{10c48}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', + '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), + ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', + '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), + ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{112b0}', + '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), + ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', + '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), + ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', + '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), + ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', + '\u{116aa}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'), + ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{13000}', + '\u{1342e}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), + ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), ('\u{16b40}', + '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), + ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{16f93}', + '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), + ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', + '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), + ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', + '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), + ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', + '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), + ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', + '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), + ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', + '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), + ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', + '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), + ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', + '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), + ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', + '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), + ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', + '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), + ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', + '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), + ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', + '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), + ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', + '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), + ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', + '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), + ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', + '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), + ('\u{2f800}', '\u{2fa1d}') + ]; + + pub const LC_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{b5}', '\u{b5}'), + ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{1ba}'), + ('\u{1bc}', '\u{1bf}'), ('\u{1c4}', '\u{293}'), ('\u{295}', '\u{2af}'), + ('\u{370}', '\u{373}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), + ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), + ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), + ('\u{561}', '\u{587}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', + '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{1d00}', '\u{1d2b}'), + ('\u{1d6b}', '\u{1d77}'), ('\u{1d79}', '\u{1d9a}'), ('\u{1e00}', + '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), + ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', + '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), + ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', + '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), + ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', + '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), + ('\u{1ff6}', '\u{1ffc}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', + '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), + ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', + '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), + ('\u{212f}', '\u{2134}'), ('\u{2139}', '\u{2139}'), ('\u{213c}', + '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), + ('\u{2183}', '\u{2184}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', + '\u{2c5e}'), ('\u{2c60}', '\u{2c7b}'), ('\u{2c7e}', '\u{2ce4}'), + ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', + '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), + ('\u{a640}', '\u{a66d}'), ('\u{a680}', '\u{a69b}'), ('\u{a722}', + '\u{a76f}'), ('\u{a771}', '\u{a787}'), ('\u{a78b}', '\u{a78e}'), + ('\u{a790}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b1}'), ('\u{a7fa}', + '\u{a7fa}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab64}', '\u{ab65}'), + ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{ff21}', + '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{10400}', '\u{1044f}'), + ('\u{118a0}', '\u{118df}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', + '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), + ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', + '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), + ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', + '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), + ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', + '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), + ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', + '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), + ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', + '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), + ('\u{1d7c4}', '\u{1d7cb}') + ]; + + pub const Ll_table: &'static [(char, char)] = &[ + ('\u{61}', '\u{7a}'), ('\u{b5}', '\u{b5}'), ('\u{df}', '\u{f6}'), + ('\u{f8}', '\u{ff}'), ('\u{101}', '\u{101}'), ('\u{103}', '\u{103}'), + ('\u{105}', '\u{105}'), ('\u{107}', '\u{107}'), ('\u{109}', '\u{109}'), + ('\u{10b}', '\u{10b}'), ('\u{10d}', '\u{10d}'), ('\u{10f}', '\u{10f}'), + ('\u{111}', '\u{111}'), ('\u{113}', '\u{113}'), ('\u{115}', '\u{115}'), + ('\u{117}', '\u{117}'), ('\u{119}', '\u{119}'), ('\u{11b}', '\u{11b}'), + ('\u{11d}', '\u{11d}'), ('\u{11f}', '\u{11f}'), ('\u{121}', '\u{121}'), + ('\u{123}', '\u{123}'), ('\u{125}', '\u{125}'), ('\u{127}', '\u{127}'), + ('\u{129}', '\u{129}'), ('\u{12b}', '\u{12b}'), ('\u{12d}', '\u{12d}'), + ('\u{12f}', '\u{12f}'), ('\u{131}', '\u{131}'), ('\u{133}', '\u{133}'), + ('\u{135}', '\u{135}'), ('\u{137}', '\u{138}'), ('\u{13a}', '\u{13a}'), + ('\u{13c}', '\u{13c}'), ('\u{13e}', '\u{13e}'), ('\u{140}', '\u{140}'), + ('\u{142}', '\u{142}'), ('\u{144}', '\u{144}'), ('\u{146}', '\u{146}'), + ('\u{148}', '\u{149}'), ('\u{14b}', '\u{14b}'), ('\u{14d}', '\u{14d}'), + ('\u{14f}', '\u{14f}'), ('\u{151}', '\u{151}'), ('\u{153}', '\u{153}'), + ('\u{155}', '\u{155}'), ('\u{157}', '\u{157}'), ('\u{159}', '\u{159}'), + ('\u{15b}', '\u{15b}'), ('\u{15d}', '\u{15d}'), ('\u{15f}', '\u{15f}'), + ('\u{161}', '\u{161}'), ('\u{163}', '\u{163}'), ('\u{165}', '\u{165}'), + ('\u{167}', '\u{167}'), ('\u{169}', '\u{169}'), ('\u{16b}', '\u{16b}'), + ('\u{16d}', '\u{16d}'), ('\u{16f}', '\u{16f}'), ('\u{171}', '\u{171}'), + ('\u{173}', '\u{173}'), ('\u{175}', '\u{175}'), ('\u{177}', '\u{177}'), + ('\u{17a}', '\u{17a}'), ('\u{17c}', '\u{17c}'), ('\u{17e}', '\u{180}'), + ('\u{183}', '\u{183}'), ('\u{185}', '\u{185}'), ('\u{188}', '\u{188}'), + ('\u{18c}', '\u{18d}'), ('\u{192}', '\u{192}'), ('\u{195}', '\u{195}'), + ('\u{199}', '\u{19b}'), ('\u{19e}', '\u{19e}'), ('\u{1a1}', '\u{1a1}'), + ('\u{1a3}', '\u{1a3}'), ('\u{1a5}', '\u{1a5}'), ('\u{1a8}', '\u{1a8}'), + ('\u{1aa}', '\u{1ab}'), ('\u{1ad}', '\u{1ad}'), ('\u{1b0}', '\u{1b0}'), + ('\u{1b4}', '\u{1b4}'), ('\u{1b6}', '\u{1b6}'), ('\u{1b9}', '\u{1ba}'), + ('\u{1bd}', '\u{1bf}'), ('\u{1c6}', '\u{1c6}'), ('\u{1c9}', '\u{1c9}'), + ('\u{1cc}', '\u{1cc}'), ('\u{1ce}', '\u{1ce}'), ('\u{1d0}', '\u{1d0}'), + ('\u{1d2}', '\u{1d2}'), ('\u{1d4}', '\u{1d4}'), ('\u{1d6}', '\u{1d6}'), + ('\u{1d8}', '\u{1d8}'), ('\u{1da}', '\u{1da}'), ('\u{1dc}', '\u{1dd}'), + ('\u{1df}', '\u{1df}'), ('\u{1e1}', '\u{1e1}'), ('\u{1e3}', '\u{1e3}'), + ('\u{1e5}', '\u{1e5}'), ('\u{1e7}', '\u{1e7}'), ('\u{1e9}', '\u{1e9}'), + ('\u{1eb}', '\u{1eb}'), ('\u{1ed}', '\u{1ed}'), ('\u{1ef}', '\u{1f0}'), + ('\u{1f3}', '\u{1f3}'), ('\u{1f5}', '\u{1f5}'), ('\u{1f9}', '\u{1f9}'), + ('\u{1fb}', '\u{1fb}'), ('\u{1fd}', '\u{1fd}'), ('\u{1ff}', '\u{1ff}'), + ('\u{201}', '\u{201}'), ('\u{203}', '\u{203}'), ('\u{205}', '\u{205}'), + ('\u{207}', '\u{207}'), ('\u{209}', '\u{209}'), ('\u{20b}', '\u{20b}'), + ('\u{20d}', '\u{20d}'), ('\u{20f}', '\u{20f}'), ('\u{211}', '\u{211}'), + ('\u{213}', '\u{213}'), ('\u{215}', '\u{215}'), ('\u{217}', '\u{217}'), + ('\u{219}', '\u{219}'), ('\u{21b}', '\u{21b}'), ('\u{21d}', '\u{21d}'), + ('\u{21f}', '\u{21f}'), ('\u{221}', '\u{221}'), ('\u{223}', '\u{223}'), + ('\u{225}', '\u{225}'), ('\u{227}', '\u{227}'), ('\u{229}', '\u{229}'), + ('\u{22b}', '\u{22b}'), ('\u{22d}', '\u{22d}'), ('\u{22f}', '\u{22f}'), + ('\u{231}', '\u{231}'), ('\u{233}', '\u{239}'), ('\u{23c}', '\u{23c}'), + ('\u{23f}', '\u{240}'), ('\u{242}', '\u{242}'), ('\u{247}', '\u{247}'), + ('\u{249}', '\u{249}'), ('\u{24b}', '\u{24b}'), ('\u{24d}', '\u{24d}'), + ('\u{24f}', '\u{293}'), ('\u{295}', '\u{2af}'), ('\u{371}', '\u{371}'), + ('\u{373}', '\u{373}'), ('\u{377}', '\u{377}'), ('\u{37b}', '\u{37d}'), + ('\u{390}', '\u{390}'), ('\u{3ac}', '\u{3ce}'), ('\u{3d0}', '\u{3d1}'), + ('\u{3d5}', '\u{3d7}'), ('\u{3d9}', '\u{3d9}'), ('\u{3db}', '\u{3db}'), + ('\u{3dd}', '\u{3dd}'), ('\u{3df}', '\u{3df}'), ('\u{3e1}', '\u{3e1}'), + ('\u{3e3}', '\u{3e3}'), ('\u{3e5}', '\u{3e5}'), ('\u{3e7}', '\u{3e7}'), + ('\u{3e9}', '\u{3e9}'), ('\u{3eb}', '\u{3eb}'), ('\u{3ed}', '\u{3ed}'), + ('\u{3ef}', '\u{3f3}'), ('\u{3f5}', '\u{3f5}'), ('\u{3f8}', '\u{3f8}'), + ('\u{3fb}', '\u{3fc}'), ('\u{430}', '\u{45f}'), ('\u{461}', '\u{461}'), + ('\u{463}', '\u{463}'), ('\u{465}', '\u{465}'), ('\u{467}', '\u{467}'), + ('\u{469}', '\u{469}'), ('\u{46b}', '\u{46b}'), ('\u{46d}', '\u{46d}'), + ('\u{46f}', '\u{46f}'), ('\u{471}', '\u{471}'), ('\u{473}', '\u{473}'), + ('\u{475}', '\u{475}'), ('\u{477}', '\u{477}'), ('\u{479}', '\u{479}'), + ('\u{47b}', '\u{47b}'), ('\u{47d}', '\u{47d}'), ('\u{47f}', '\u{47f}'), + ('\u{481}', '\u{481}'), ('\u{48b}', '\u{48b}'), ('\u{48d}', '\u{48d}'), + ('\u{48f}', '\u{48f}'), ('\u{491}', '\u{491}'), ('\u{493}', '\u{493}'), + ('\u{495}', '\u{495}'), ('\u{497}', '\u{497}'), ('\u{499}', '\u{499}'), + ('\u{49b}', '\u{49b}'), ('\u{49d}', '\u{49d}'), ('\u{49f}', '\u{49f}'), + ('\u{4a1}', '\u{4a1}'), ('\u{4a3}', '\u{4a3}'), ('\u{4a5}', '\u{4a5}'), + ('\u{4a7}', '\u{4a7}'), ('\u{4a9}', '\u{4a9}'), ('\u{4ab}', '\u{4ab}'), + ('\u{4ad}', '\u{4ad}'), ('\u{4af}', '\u{4af}'), ('\u{4b1}', '\u{4b1}'), + ('\u{4b3}', '\u{4b3}'), ('\u{4b5}', '\u{4b5}'), ('\u{4b7}', '\u{4b7}'), + ('\u{4b9}', '\u{4b9}'), ('\u{4bb}', '\u{4bb}'), ('\u{4bd}', '\u{4bd}'), + ('\u{4bf}', '\u{4bf}'), ('\u{4c2}', '\u{4c2}'), ('\u{4c4}', '\u{4c4}'), + ('\u{4c6}', '\u{4c6}'), ('\u{4c8}', '\u{4c8}'), ('\u{4ca}', '\u{4ca}'), + ('\u{4cc}', '\u{4cc}'), ('\u{4ce}', '\u{4cf}'), ('\u{4d1}', '\u{4d1}'), + ('\u{4d3}', '\u{4d3}'), ('\u{4d5}', '\u{4d5}'), ('\u{4d7}', '\u{4d7}'), + ('\u{4d9}', '\u{4d9}'), ('\u{4db}', '\u{4db}'), ('\u{4dd}', '\u{4dd}'), + ('\u{4df}', '\u{4df}'), ('\u{4e1}', '\u{4e1}'), ('\u{4e3}', '\u{4e3}'), + ('\u{4e5}', '\u{4e5}'), ('\u{4e7}', '\u{4e7}'), ('\u{4e9}', '\u{4e9}'), + ('\u{4eb}', '\u{4eb}'), ('\u{4ed}', '\u{4ed}'), ('\u{4ef}', '\u{4ef}'), + ('\u{4f1}', '\u{4f1}'), ('\u{4f3}', '\u{4f3}'), ('\u{4f5}', '\u{4f5}'), + ('\u{4f7}', '\u{4f7}'), ('\u{4f9}', '\u{4f9}'), ('\u{4fb}', '\u{4fb}'), + ('\u{4fd}', '\u{4fd}'), ('\u{4ff}', '\u{4ff}'), ('\u{501}', '\u{501}'), + ('\u{503}', '\u{503}'), ('\u{505}', '\u{505}'), ('\u{507}', '\u{507}'), + ('\u{509}', '\u{509}'), ('\u{50b}', '\u{50b}'), ('\u{50d}', '\u{50d}'), + ('\u{50f}', '\u{50f}'), ('\u{511}', '\u{511}'), ('\u{513}', '\u{513}'), + ('\u{515}', '\u{515}'), ('\u{517}', '\u{517}'), ('\u{519}', '\u{519}'), + ('\u{51b}', '\u{51b}'), ('\u{51d}', '\u{51d}'), ('\u{51f}', '\u{51f}'), + ('\u{521}', '\u{521}'), ('\u{523}', '\u{523}'), ('\u{525}', '\u{525}'), + ('\u{527}', '\u{527}'), ('\u{529}', '\u{529}'), ('\u{52b}', '\u{52b}'), + ('\u{52d}', '\u{52d}'), ('\u{52f}', '\u{52f}'), ('\u{561}', '\u{587}'), + ('\u{1d00}', '\u{1d2b}'), ('\u{1d6b}', '\u{1d77}'), ('\u{1d79}', + '\u{1d9a}'), ('\u{1e01}', '\u{1e01}'), ('\u{1e03}', '\u{1e03}'), + ('\u{1e05}', '\u{1e05}'), ('\u{1e07}', '\u{1e07}'), ('\u{1e09}', + '\u{1e09}'), ('\u{1e0b}', '\u{1e0b}'), ('\u{1e0d}', '\u{1e0d}'), + ('\u{1e0f}', '\u{1e0f}'), ('\u{1e11}', '\u{1e11}'), ('\u{1e13}', + '\u{1e13}'), ('\u{1e15}', '\u{1e15}'), ('\u{1e17}', '\u{1e17}'), + ('\u{1e19}', '\u{1e19}'), ('\u{1e1b}', '\u{1e1b}'), ('\u{1e1d}', + '\u{1e1d}'), ('\u{1e1f}', '\u{1e1f}'), ('\u{1e21}', '\u{1e21}'), + ('\u{1e23}', '\u{1e23}'), ('\u{1e25}', '\u{1e25}'), ('\u{1e27}', + '\u{1e27}'), ('\u{1e29}', '\u{1e29}'), ('\u{1e2b}', '\u{1e2b}'), + ('\u{1e2d}', '\u{1e2d}'), ('\u{1e2f}', '\u{1e2f}'), ('\u{1e31}', + '\u{1e31}'), ('\u{1e33}', '\u{1e33}'), ('\u{1e35}', '\u{1e35}'), + ('\u{1e37}', '\u{1e37}'), ('\u{1e39}', '\u{1e39}'), ('\u{1e3b}', + '\u{1e3b}'), ('\u{1e3d}', '\u{1e3d}'), ('\u{1e3f}', '\u{1e3f}'), + ('\u{1e41}', '\u{1e41}'), ('\u{1e43}', '\u{1e43}'), ('\u{1e45}', + '\u{1e45}'), ('\u{1e47}', '\u{1e47}'), ('\u{1e49}', '\u{1e49}'), + ('\u{1e4b}', '\u{1e4b}'), ('\u{1e4d}', '\u{1e4d}'), ('\u{1e4f}', + '\u{1e4f}'), ('\u{1e51}', '\u{1e51}'), ('\u{1e53}', '\u{1e53}'), + ('\u{1e55}', '\u{1e55}'), ('\u{1e57}', '\u{1e57}'), ('\u{1e59}', + '\u{1e59}'), ('\u{1e5b}', '\u{1e5b}'), ('\u{1e5d}', '\u{1e5d}'), + ('\u{1e5f}', '\u{1e5f}'), ('\u{1e61}', '\u{1e61}'), ('\u{1e63}', + '\u{1e63}'), ('\u{1e65}', '\u{1e65}'), ('\u{1e67}', '\u{1e67}'), + ('\u{1e69}', '\u{1e69}'), ('\u{1e6b}', '\u{1e6b}'), ('\u{1e6d}', + '\u{1e6d}'), ('\u{1e6f}', '\u{1e6f}'), ('\u{1e71}', '\u{1e71}'), + ('\u{1e73}', '\u{1e73}'), ('\u{1e75}', '\u{1e75}'), ('\u{1e77}', + '\u{1e77}'), ('\u{1e79}', '\u{1e79}'), ('\u{1e7b}', '\u{1e7b}'), + ('\u{1e7d}', '\u{1e7d}'), ('\u{1e7f}', '\u{1e7f}'), ('\u{1e81}', + '\u{1e81}'), ('\u{1e83}', '\u{1e83}'), ('\u{1e85}', '\u{1e85}'), + ('\u{1e87}', '\u{1e87}'), ('\u{1e89}', '\u{1e89}'), ('\u{1e8b}', + '\u{1e8b}'), ('\u{1e8d}', '\u{1e8d}'), ('\u{1e8f}', '\u{1e8f}'), + ('\u{1e91}', '\u{1e91}'), ('\u{1e93}', '\u{1e93}'), ('\u{1e95}', + '\u{1e9d}'), ('\u{1e9f}', '\u{1e9f}'), ('\u{1ea1}', '\u{1ea1}'), + ('\u{1ea3}', '\u{1ea3}'), ('\u{1ea5}', '\u{1ea5}'), ('\u{1ea7}', + '\u{1ea7}'), ('\u{1ea9}', '\u{1ea9}'), ('\u{1eab}', '\u{1eab}'), + ('\u{1ead}', '\u{1ead}'), ('\u{1eaf}', '\u{1eaf}'), ('\u{1eb1}', + '\u{1eb1}'), ('\u{1eb3}', '\u{1eb3}'), ('\u{1eb5}', '\u{1eb5}'), + ('\u{1eb7}', '\u{1eb7}'), ('\u{1eb9}', '\u{1eb9}'), ('\u{1ebb}', + '\u{1ebb}'), ('\u{1ebd}', '\u{1ebd}'), ('\u{1ebf}', '\u{1ebf}'), + ('\u{1ec1}', '\u{1ec1}'), ('\u{1ec3}', '\u{1ec3}'), ('\u{1ec5}', + '\u{1ec5}'), ('\u{1ec7}', '\u{1ec7}'), ('\u{1ec9}', '\u{1ec9}'), + ('\u{1ecb}', '\u{1ecb}'), ('\u{1ecd}', '\u{1ecd}'), ('\u{1ecf}', + '\u{1ecf}'), ('\u{1ed1}', '\u{1ed1}'), ('\u{1ed3}', '\u{1ed3}'), + ('\u{1ed5}', '\u{1ed5}'), ('\u{1ed7}', '\u{1ed7}'), ('\u{1ed9}', + '\u{1ed9}'), ('\u{1edb}', '\u{1edb}'), ('\u{1edd}', '\u{1edd}'), + ('\u{1edf}', '\u{1edf}'), ('\u{1ee1}', '\u{1ee1}'), ('\u{1ee3}', + '\u{1ee3}'), ('\u{1ee5}', '\u{1ee5}'), ('\u{1ee7}', '\u{1ee7}'), + ('\u{1ee9}', '\u{1ee9}'), ('\u{1eeb}', '\u{1eeb}'), ('\u{1eed}', + '\u{1eed}'), ('\u{1eef}', '\u{1eef}'), ('\u{1ef1}', '\u{1ef1}'), + ('\u{1ef3}', '\u{1ef3}'), ('\u{1ef5}', '\u{1ef5}'), ('\u{1ef7}', + '\u{1ef7}'), ('\u{1ef9}', '\u{1ef9}'), ('\u{1efb}', '\u{1efb}'), + ('\u{1efd}', '\u{1efd}'), ('\u{1eff}', '\u{1f07}'), ('\u{1f10}', + '\u{1f15}'), ('\u{1f20}', '\u{1f27}'), ('\u{1f30}', '\u{1f37}'), + ('\u{1f40}', '\u{1f45}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f60}', + '\u{1f67}'), ('\u{1f70}', '\u{1f7d}'), ('\u{1f80}', '\u{1f87}'), + ('\u{1f90}', '\u{1f97}'), ('\u{1fa0}', '\u{1fa7}'), ('\u{1fb0}', + '\u{1fb4}'), ('\u{1fb6}', '\u{1fb7}'), ('\u{1fbe}', '\u{1fbe}'), + ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fc7}'), ('\u{1fd0}', + '\u{1fd3}'), ('\u{1fd6}', '\u{1fd7}'), ('\u{1fe0}', '\u{1fe7}'), + ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ff7}'), ('\u{210a}', + '\u{210a}'), ('\u{210e}', '\u{210f}'), ('\u{2113}', '\u{2113}'), + ('\u{212f}', '\u{212f}'), ('\u{2134}', '\u{2134}'), ('\u{2139}', + '\u{2139}'), ('\u{213c}', '\u{213d}'), ('\u{2146}', '\u{2149}'), + ('\u{214e}', '\u{214e}'), ('\u{2184}', '\u{2184}'), ('\u{2c30}', + '\u{2c5e}'), ('\u{2c61}', '\u{2c61}'), ('\u{2c65}', '\u{2c66}'), + ('\u{2c68}', '\u{2c68}'), ('\u{2c6a}', '\u{2c6a}'), ('\u{2c6c}', + '\u{2c6c}'), ('\u{2c71}', '\u{2c71}'), ('\u{2c73}', '\u{2c74}'), + ('\u{2c76}', '\u{2c7b}'), ('\u{2c81}', '\u{2c81}'), ('\u{2c83}', + '\u{2c83}'), ('\u{2c85}', '\u{2c85}'), ('\u{2c87}', '\u{2c87}'), + ('\u{2c89}', '\u{2c89}'), ('\u{2c8b}', '\u{2c8b}'), ('\u{2c8d}', + '\u{2c8d}'), ('\u{2c8f}', '\u{2c8f}'), ('\u{2c91}', '\u{2c91}'), + ('\u{2c93}', '\u{2c93}'), ('\u{2c95}', '\u{2c95}'), ('\u{2c97}', + '\u{2c97}'), ('\u{2c99}', '\u{2c99}'), ('\u{2c9b}', '\u{2c9b}'), + ('\u{2c9d}', '\u{2c9d}'), ('\u{2c9f}', '\u{2c9f}'), ('\u{2ca1}', + '\u{2ca1}'), ('\u{2ca3}', '\u{2ca3}'), ('\u{2ca5}', '\u{2ca5}'), + ('\u{2ca7}', '\u{2ca7}'), ('\u{2ca9}', '\u{2ca9}'), ('\u{2cab}', + '\u{2cab}'), ('\u{2cad}', '\u{2cad}'), ('\u{2caf}', '\u{2caf}'), + ('\u{2cb1}', '\u{2cb1}'), ('\u{2cb3}', '\u{2cb3}'), ('\u{2cb5}', + '\u{2cb5}'), ('\u{2cb7}', '\u{2cb7}'), ('\u{2cb9}', '\u{2cb9}'), + ('\u{2cbb}', '\u{2cbb}'), ('\u{2cbd}', '\u{2cbd}'), ('\u{2cbf}', + '\u{2cbf}'), ('\u{2cc1}', '\u{2cc1}'), ('\u{2cc3}', '\u{2cc3}'), + ('\u{2cc5}', '\u{2cc5}'), ('\u{2cc7}', '\u{2cc7}'), ('\u{2cc9}', + '\u{2cc9}'), ('\u{2ccb}', '\u{2ccb}'), ('\u{2ccd}', '\u{2ccd}'), + ('\u{2ccf}', '\u{2ccf}'), ('\u{2cd1}', '\u{2cd1}'), ('\u{2cd3}', + '\u{2cd3}'), ('\u{2cd5}', '\u{2cd5}'), ('\u{2cd7}', '\u{2cd7}'), + ('\u{2cd9}', '\u{2cd9}'), ('\u{2cdb}', '\u{2cdb}'), ('\u{2cdd}', + '\u{2cdd}'), ('\u{2cdf}', '\u{2cdf}'), ('\u{2ce1}', '\u{2ce1}'), + ('\u{2ce3}', '\u{2ce4}'), ('\u{2cec}', '\u{2cec}'), ('\u{2cee}', + '\u{2cee}'), ('\u{2cf3}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), + ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{a641}', + '\u{a641}'), ('\u{a643}', '\u{a643}'), ('\u{a645}', '\u{a645}'), + ('\u{a647}', '\u{a647}'), ('\u{a649}', '\u{a649}'), ('\u{a64b}', + '\u{a64b}'), ('\u{a64d}', '\u{a64d}'), ('\u{a64f}', '\u{a64f}'), + ('\u{a651}', '\u{a651}'), ('\u{a653}', '\u{a653}'), ('\u{a655}', + '\u{a655}'), ('\u{a657}', '\u{a657}'), ('\u{a659}', '\u{a659}'), + ('\u{a65b}', '\u{a65b}'), ('\u{a65d}', '\u{a65d}'), ('\u{a65f}', + '\u{a65f}'), ('\u{a661}', '\u{a661}'), ('\u{a663}', '\u{a663}'), + ('\u{a665}', '\u{a665}'), ('\u{a667}', '\u{a667}'), ('\u{a669}', + '\u{a669}'), ('\u{a66b}', '\u{a66b}'), ('\u{a66d}', '\u{a66d}'), + ('\u{a681}', '\u{a681}'), ('\u{a683}', '\u{a683}'), ('\u{a685}', + '\u{a685}'), ('\u{a687}', '\u{a687}'), ('\u{a689}', '\u{a689}'), + ('\u{a68b}', '\u{a68b}'), ('\u{a68d}', '\u{a68d}'), ('\u{a68f}', + '\u{a68f}'), ('\u{a691}', '\u{a691}'), ('\u{a693}', '\u{a693}'), + ('\u{a695}', '\u{a695}'), ('\u{a697}', '\u{a697}'), ('\u{a699}', + '\u{a699}'), ('\u{a69b}', '\u{a69b}'), ('\u{a723}', '\u{a723}'), + ('\u{a725}', '\u{a725}'), ('\u{a727}', '\u{a727}'), ('\u{a729}', + '\u{a729}'), ('\u{a72b}', '\u{a72b}'), ('\u{a72d}', '\u{a72d}'), + ('\u{a72f}', '\u{a731}'), ('\u{a733}', '\u{a733}'), ('\u{a735}', + '\u{a735}'), ('\u{a737}', '\u{a737}'), ('\u{a739}', '\u{a739}'), + ('\u{a73b}', '\u{a73b}'), ('\u{a73d}', '\u{a73d}'), ('\u{a73f}', + '\u{a73f}'), ('\u{a741}', '\u{a741}'), ('\u{a743}', '\u{a743}'), + ('\u{a745}', '\u{a745}'), ('\u{a747}', '\u{a747}'), ('\u{a749}', + '\u{a749}'), ('\u{a74b}', '\u{a74b}'), ('\u{a74d}', '\u{a74d}'), + ('\u{a74f}', '\u{a74f}'), ('\u{a751}', '\u{a751}'), ('\u{a753}', + '\u{a753}'), ('\u{a755}', '\u{a755}'), ('\u{a757}', '\u{a757}'), + ('\u{a759}', '\u{a759}'), ('\u{a75b}', '\u{a75b}'), ('\u{a75d}', + '\u{a75d}'), ('\u{a75f}', '\u{a75f}'), ('\u{a761}', '\u{a761}'), + ('\u{a763}', '\u{a763}'), ('\u{a765}', '\u{a765}'), ('\u{a767}', + '\u{a767}'), ('\u{a769}', '\u{a769}'), ('\u{a76b}', '\u{a76b}'), + ('\u{a76d}', '\u{a76d}'), ('\u{a76f}', '\u{a76f}'), ('\u{a771}', + '\u{a778}'), ('\u{a77a}', '\u{a77a}'), ('\u{a77c}', '\u{a77c}'), + ('\u{a77f}', '\u{a77f}'), ('\u{a781}', '\u{a781}'), ('\u{a783}', + '\u{a783}'), ('\u{a785}', '\u{a785}'), ('\u{a787}', '\u{a787}'), + ('\u{a78c}', '\u{a78c}'), ('\u{a78e}', '\u{a78e}'), ('\u{a791}', + '\u{a791}'), ('\u{a793}', '\u{a795}'), ('\u{a797}', '\u{a797}'), + ('\u{a799}', '\u{a799}'), ('\u{a79b}', '\u{a79b}'), ('\u{a79d}', + '\u{a79d}'), ('\u{a79f}', '\u{a79f}'), ('\u{a7a1}', '\u{a7a1}'), + ('\u{a7a3}', '\u{a7a3}'), ('\u{a7a5}', '\u{a7a5}'), ('\u{a7a7}', + '\u{a7a7}'), ('\u{a7a9}', '\u{a7a9}'), ('\u{a7fa}', '\u{a7fa}'), + ('\u{ab30}', '\u{ab5a}'), ('\u{ab64}', '\u{ab65}'), ('\u{fb00}', + '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{ff41}', '\u{ff5a}'), + ('\u{10428}', '\u{1044f}'), ('\u{118c0}', '\u{118df}'), ('\u{1d41a}', + '\u{1d433}'), ('\u{1d44e}', '\u{1d454}'), ('\u{1d456}', '\u{1d467}'), + ('\u{1d482}', '\u{1d49b}'), ('\u{1d4b6}', '\u{1d4b9}'), ('\u{1d4bb}', + '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d4cf}'), + ('\u{1d4ea}', '\u{1d503}'), ('\u{1d51e}', '\u{1d537}'), ('\u{1d552}', + '\u{1d56b}'), ('\u{1d586}', '\u{1d59f}'), ('\u{1d5ba}', '\u{1d5d3}'), + ('\u{1d5ee}', '\u{1d607}'), ('\u{1d622}', '\u{1d63b}'), ('\u{1d656}', + '\u{1d66f}'), ('\u{1d68a}', '\u{1d6a5}'), ('\u{1d6c2}', '\u{1d6da}'), + ('\u{1d6dc}', '\u{1d6e1}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', + '\u{1d71b}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d755}'), + ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d78f}'), ('\u{1d7aa}', + '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7c9}'), ('\u{1d7cb}', '\u{1d7cb}') + ]; + + pub const Lm_table: &'static [(char, char)] = &[ + ('\u{2b0}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), + ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{374}', '\u{374}'), + ('\u{37a}', '\u{37a}'), ('\u{559}', '\u{559}'), ('\u{640}', '\u{640}'), + ('\u{6e5}', '\u{6e6}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), + ('\u{81a}', '\u{81a}'), ('\u{824}', '\u{824}'), ('\u{828}', '\u{828}'), + ('\u{971}', '\u{971}'), ('\u{e46}', '\u{e46}'), ('\u{ec6}', '\u{ec6}'), + ('\u{10fc}', '\u{10fc}'), ('\u{17d7}', '\u{17d7}'), ('\u{1843}', + '\u{1843}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1c78}', '\u{1c7d}'), + ('\u{1d2c}', '\u{1d6a}'), ('\u{1d78}', '\u{1d78}'), ('\u{1d9b}', + '\u{1dbf}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), + ('\u{2090}', '\u{209c}'), ('\u{2c7c}', '\u{2c7d}'), ('\u{2d6f}', + '\u{2d6f}'), ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3005}'), + ('\u{3031}', '\u{3035}'), ('\u{303b}', '\u{303b}'), ('\u{309d}', + '\u{309e}'), ('\u{30fc}', '\u{30fe}'), ('\u{a015}', '\u{a015}'), + ('\u{a4f8}', '\u{a4fd}'), ('\u{a60c}', '\u{a60c}'), ('\u{a67f}', + '\u{a67f}'), ('\u{a69c}', '\u{a69d}'), ('\u{a717}', '\u{a71f}'), + ('\u{a770}', '\u{a770}'), ('\u{a788}', '\u{a788}'), ('\u{a7f8}', + '\u{a7f9}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e6}', '\u{a9e6}'), + ('\u{aa70}', '\u{aa70}'), ('\u{aadd}', '\u{aadd}'), ('\u{aaf3}', + '\u{aaf4}'), ('\u{ab5c}', '\u{ab5f}'), ('\u{ff70}', '\u{ff70}'), + ('\u{ff9e}', '\u{ff9f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16f93}', + '\u{16f9f}') + ]; + + pub const Lo_table: &'static [(char, char)] = &[ + ('\u{aa}', '\u{aa}'), ('\u{ba}', '\u{ba}'), ('\u{1bb}', '\u{1bb}'), + ('\u{1c0}', '\u{1c3}'), ('\u{294}', '\u{294}'), ('\u{5d0}', '\u{5ea}'), + ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{63f}'), ('\u{641}', '\u{64a}'), + ('\u{66e}', '\u{66f}'), ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), + ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), + ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), + ('\u{7b1}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{800}', '\u{815}'), + ('\u{840}', '\u{858}'), ('\u{8a0}', '\u{8b2}'), ('\u{904}', '\u{939}'), + ('\u{93d}', '\u{93d}'), ('\u{950}', '\u{950}'), ('\u{958}', '\u{961}'), + ('\u{972}', '\u{980}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), + ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), + ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), + ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), + ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), + ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), + ('\u{a38}', '\u{a39}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), + ('\u{a72}', '\u{a74}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), + ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), + ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), + ('\u{ae0}', '\u{ae1}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), + ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), + ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), + ('\u{b5f}', '\u{b61}'), ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'), + ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), + ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), + ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), + ('\u{bd0}', '\u{bd0}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), + ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), + ('\u{c58}', '\u{c59}'), ('\u{c60}', '\u{c61}'), ('\u{c85}', '\u{c8c}'), + ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), + ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), + ('\u{ce0}', '\u{ce1}'), ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'), + ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), + ('\u{d4e}', '\u{d4e}'), ('\u{d60}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'), + ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), + ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), + ('\u{e32}', '\u{e33}'), ('\u{e40}', '\u{e45}'), ('\u{e81}', '\u{e82}'), + ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), + ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), + ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), + ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb0}'), ('\u{eb2}', '\u{eb3}'), + ('\u{ebd}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{edc}', '\u{edf}'), + ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), + ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}', + '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), + ('\u{1061}', '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', + '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}', '\u{108e}'), + ('\u{10d0}', '\u{10fa}'), ('\u{10fd}', '\u{1248}'), ('\u{124a}', + '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), + ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', + '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), + ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', + '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), + ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{1380}', + '\u{138f}'), ('\u{13a0}', '\u{13f4}'), ('\u{1401}', '\u{166c}'), + ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', + '\u{16ea}'), ('\u{16f1}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), + ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'), ('\u{1740}', + '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), + ('\u{1780}', '\u{17b3}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', + '\u{1842}'), ('\u{1844}', '\u{1877}'), ('\u{1880}', '\u{18a8}'), + ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', + '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), + ('\u{1980}', '\u{19ab}'), ('\u{19c1}', '\u{19c7}'), ('\u{1a00}', + '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1b05}', '\u{1b33}'), + ('\u{1b45}', '\u{1b4b}'), ('\u{1b83}', '\u{1ba0}'), ('\u{1bae}', + '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), + ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c77}'), ('\u{1ce9}', + '\u{1cec}'), ('\u{1cee}', '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), + ('\u{2135}', '\u{2138}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d80}', + '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), + ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', + '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), + ('\u{2dd8}', '\u{2dde}'), ('\u{3006}', '\u{3006}'), ('\u{303c}', + '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309f}', '\u{309f}'), + ('\u{30a1}', '\u{30fa}'), ('\u{30ff}', '\u{30ff}'), ('\u{3105}', + '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), + ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', + '\u{9fcc}'), ('\u{a000}', '\u{a014}'), ('\u{a016}', '\u{a48c}'), + ('\u{a4d0}', '\u{a4f7}'), ('\u{a500}', '\u{a60b}'), ('\u{a610}', + '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a66e}', '\u{a66e}'), + ('\u{a6a0}', '\u{a6e5}'), ('\u{a7f7}', '\u{a7f7}'), ('\u{a7fb}', + '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), + ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', + '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), + ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', + '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9e0}', '\u{a9e4}'), + ('\u{a9e7}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', + '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), + ('\u{aa60}', '\u{aa6f}'), ('\u{aa71}', '\u{aa76}'), ('\u{aa7a}', + '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), + ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', + '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadc}'), + ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf2}'), ('\u{ab01}', + '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), + ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{abc0}', + '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), + ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', + '\u{fad9}'), ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), + ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', + '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), + ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', + '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), + ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff66}', + '\u{ff6f}'), ('\u{ff71}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'), + ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', + '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), + ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', + '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), + ('\u{10080}', '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', + '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{10340}'), + ('\u{10342}', '\u{10349}'), ('\u{10350}', '\u{10375}'), ('\u{10380}', + '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), + ('\u{10450}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', + '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), + ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', + '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), + ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', + '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{10900}', '\u{10915}'), + ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', + '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), + ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', + '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), + ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', + '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), + ('\u{10c00}', '\u{10c48}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', + '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), + ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', + '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), + ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{112b0}', + '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), + ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', + '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), + ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', + '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), + ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', + '\u{116aa}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), + ('\u{12000}', '\u{12398}'), ('\u{13000}', '\u{1342e}'), ('\u{16800}', + '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), + ('\u{16b00}', '\u{16b2f}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', + '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), + ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', + '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), + ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', + '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), + ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', + '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), + ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', + '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), + ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', + '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), + ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', + '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), + ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', + '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), + ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', + '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), + ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}', + '\u{2fa1d}') + ]; + + pub const Lt_table: &'static [(char, char)] = &[ + ('\u{1c5}', '\u{1c5}'), ('\u{1c8}', '\u{1c8}'), ('\u{1cb}', '\u{1cb}'), + ('\u{1f2}', '\u{1f2}'), ('\u{1f88}', '\u{1f8f}'), ('\u{1f98}', + '\u{1f9f}'), ('\u{1fa8}', '\u{1faf}'), ('\u{1fbc}', '\u{1fbc}'), + ('\u{1fcc}', '\u{1fcc}'), ('\u{1ffc}', '\u{1ffc}') + ]; + + pub const Lu_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{de}'), + ('\u{100}', '\u{100}'), ('\u{102}', '\u{102}'), ('\u{104}', '\u{104}'), + ('\u{106}', '\u{106}'), ('\u{108}', '\u{108}'), ('\u{10a}', '\u{10a}'), + ('\u{10c}', '\u{10c}'), ('\u{10e}', '\u{10e}'), ('\u{110}', '\u{110}'), + ('\u{112}', '\u{112}'), ('\u{114}', '\u{114}'), ('\u{116}', '\u{116}'), + ('\u{118}', '\u{118}'), ('\u{11a}', '\u{11a}'), ('\u{11c}', '\u{11c}'), + ('\u{11e}', '\u{11e}'), ('\u{120}', '\u{120}'), ('\u{122}', '\u{122}'), + ('\u{124}', '\u{124}'), ('\u{126}', '\u{126}'), ('\u{128}', '\u{128}'), + ('\u{12a}', '\u{12a}'), ('\u{12c}', '\u{12c}'), ('\u{12e}', '\u{12e}'), + ('\u{130}', '\u{130}'), ('\u{132}', '\u{132}'), ('\u{134}', '\u{134}'), + ('\u{136}', '\u{136}'), ('\u{139}', '\u{139}'), ('\u{13b}', '\u{13b}'), + ('\u{13d}', '\u{13d}'), ('\u{13f}', '\u{13f}'), ('\u{141}', '\u{141}'), + ('\u{143}', '\u{143}'), ('\u{145}', '\u{145}'), ('\u{147}', '\u{147}'), + ('\u{14a}', '\u{14a}'), ('\u{14c}', '\u{14c}'), ('\u{14e}', '\u{14e}'), + ('\u{150}', '\u{150}'), ('\u{152}', '\u{152}'), ('\u{154}', '\u{154}'), + ('\u{156}', '\u{156}'), ('\u{158}', '\u{158}'), ('\u{15a}', '\u{15a}'), + ('\u{15c}', '\u{15c}'), ('\u{15e}', '\u{15e}'), ('\u{160}', '\u{160}'), + ('\u{162}', '\u{162}'), ('\u{164}', '\u{164}'), ('\u{166}', '\u{166}'), + ('\u{168}', '\u{168}'), ('\u{16a}', '\u{16a}'), ('\u{16c}', '\u{16c}'), + ('\u{16e}', '\u{16e}'), ('\u{170}', '\u{170}'), ('\u{172}', '\u{172}'), + ('\u{174}', '\u{174}'), ('\u{176}', '\u{176}'), ('\u{178}', '\u{179}'), + ('\u{17b}', '\u{17b}'), ('\u{17d}', '\u{17d}'), ('\u{181}', '\u{182}'), + ('\u{184}', '\u{184}'), ('\u{186}', '\u{187}'), ('\u{189}', '\u{18b}'), + ('\u{18e}', '\u{191}'), ('\u{193}', '\u{194}'), ('\u{196}', '\u{198}'), + ('\u{19c}', '\u{19d}'), ('\u{19f}', '\u{1a0}'), ('\u{1a2}', '\u{1a2}'), + ('\u{1a4}', '\u{1a4}'), ('\u{1a6}', '\u{1a7}'), ('\u{1a9}', '\u{1a9}'), + ('\u{1ac}', '\u{1ac}'), ('\u{1ae}', '\u{1af}'), ('\u{1b1}', '\u{1b3}'), + ('\u{1b5}', '\u{1b5}'), ('\u{1b7}', '\u{1b8}'), ('\u{1bc}', '\u{1bc}'), + ('\u{1c4}', '\u{1c4}'), ('\u{1c7}', '\u{1c7}'), ('\u{1ca}', '\u{1ca}'), + ('\u{1cd}', '\u{1cd}'), ('\u{1cf}', '\u{1cf}'), ('\u{1d1}', '\u{1d1}'), + ('\u{1d3}', '\u{1d3}'), ('\u{1d5}', '\u{1d5}'), ('\u{1d7}', '\u{1d7}'), + ('\u{1d9}', '\u{1d9}'), ('\u{1db}', '\u{1db}'), ('\u{1de}', '\u{1de}'), + ('\u{1e0}', '\u{1e0}'), ('\u{1e2}', '\u{1e2}'), ('\u{1e4}', '\u{1e4}'), + ('\u{1e6}', '\u{1e6}'), ('\u{1e8}', '\u{1e8}'), ('\u{1ea}', '\u{1ea}'), + ('\u{1ec}', '\u{1ec}'), ('\u{1ee}', '\u{1ee}'), ('\u{1f1}', '\u{1f1}'), + ('\u{1f4}', '\u{1f4}'), ('\u{1f6}', '\u{1f8}'), ('\u{1fa}', '\u{1fa}'), + ('\u{1fc}', '\u{1fc}'), ('\u{1fe}', '\u{1fe}'), ('\u{200}', '\u{200}'), + ('\u{202}', '\u{202}'), ('\u{204}', '\u{204}'), ('\u{206}', '\u{206}'), + ('\u{208}', '\u{208}'), ('\u{20a}', '\u{20a}'), ('\u{20c}', '\u{20c}'), + ('\u{20e}', '\u{20e}'), ('\u{210}', '\u{210}'), ('\u{212}', '\u{212}'), + ('\u{214}', '\u{214}'), ('\u{216}', '\u{216}'), ('\u{218}', '\u{218}'), + ('\u{21a}', '\u{21a}'), ('\u{21c}', '\u{21c}'), ('\u{21e}', '\u{21e}'), + ('\u{220}', '\u{220}'), ('\u{222}', '\u{222}'), ('\u{224}', '\u{224}'), + ('\u{226}', '\u{226}'), ('\u{228}', '\u{228}'), ('\u{22a}', '\u{22a}'), + ('\u{22c}', '\u{22c}'), ('\u{22e}', '\u{22e}'), ('\u{230}', '\u{230}'), + ('\u{232}', '\u{232}'), ('\u{23a}', '\u{23b}'), ('\u{23d}', '\u{23e}'), + ('\u{241}', '\u{241}'), ('\u{243}', '\u{246}'), ('\u{248}', '\u{248}'), + ('\u{24a}', '\u{24a}'), ('\u{24c}', '\u{24c}'), ('\u{24e}', '\u{24e}'), + ('\u{370}', '\u{370}'), ('\u{372}', '\u{372}'), ('\u{376}', '\u{376}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), + ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{38f}'), ('\u{391}', '\u{3a1}'), + ('\u{3a3}', '\u{3ab}'), ('\u{3cf}', '\u{3cf}'), ('\u{3d2}', '\u{3d4}'), + ('\u{3d8}', '\u{3d8}'), ('\u{3da}', '\u{3da}'), ('\u{3dc}', '\u{3dc}'), + ('\u{3de}', '\u{3de}'), ('\u{3e0}', '\u{3e0}'), ('\u{3e2}', '\u{3e2}'), + ('\u{3e4}', '\u{3e4}'), ('\u{3e6}', '\u{3e6}'), ('\u{3e8}', '\u{3e8}'), + ('\u{3ea}', '\u{3ea}'), ('\u{3ec}', '\u{3ec}'), ('\u{3ee}', '\u{3ee}'), + ('\u{3f4}', '\u{3f4}'), ('\u{3f7}', '\u{3f7}'), ('\u{3f9}', '\u{3fa}'), + ('\u{3fd}', '\u{42f}'), ('\u{460}', '\u{460}'), ('\u{462}', '\u{462}'), + ('\u{464}', '\u{464}'), ('\u{466}', '\u{466}'), ('\u{468}', '\u{468}'), + ('\u{46a}', '\u{46a}'), ('\u{46c}', '\u{46c}'), ('\u{46e}', '\u{46e}'), + ('\u{470}', '\u{470}'), ('\u{472}', '\u{472}'), ('\u{474}', '\u{474}'), + ('\u{476}', '\u{476}'), ('\u{478}', '\u{478}'), ('\u{47a}', '\u{47a}'), + ('\u{47c}', '\u{47c}'), ('\u{47e}', '\u{47e}'), ('\u{480}', '\u{480}'), + ('\u{48a}', '\u{48a}'), ('\u{48c}', '\u{48c}'), ('\u{48e}', '\u{48e}'), + ('\u{490}', '\u{490}'), ('\u{492}', '\u{492}'), ('\u{494}', '\u{494}'), + ('\u{496}', '\u{496}'), ('\u{498}', '\u{498}'), ('\u{49a}', '\u{49a}'), + ('\u{49c}', '\u{49c}'), ('\u{49e}', '\u{49e}'), ('\u{4a0}', '\u{4a0}'), + ('\u{4a2}', '\u{4a2}'), ('\u{4a4}', '\u{4a4}'), ('\u{4a6}', '\u{4a6}'), + ('\u{4a8}', '\u{4a8}'), ('\u{4aa}', '\u{4aa}'), ('\u{4ac}', '\u{4ac}'), + ('\u{4ae}', '\u{4ae}'), ('\u{4b0}', '\u{4b0}'), ('\u{4b2}', '\u{4b2}'), + ('\u{4b4}', '\u{4b4}'), ('\u{4b6}', '\u{4b6}'), ('\u{4b8}', '\u{4b8}'), + ('\u{4ba}', '\u{4ba}'), ('\u{4bc}', '\u{4bc}'), ('\u{4be}', '\u{4be}'), + ('\u{4c0}', '\u{4c1}'), ('\u{4c3}', '\u{4c3}'), ('\u{4c5}', '\u{4c5}'), + ('\u{4c7}', '\u{4c7}'), ('\u{4c9}', '\u{4c9}'), ('\u{4cb}', '\u{4cb}'), + ('\u{4cd}', '\u{4cd}'), ('\u{4d0}', '\u{4d0}'), ('\u{4d2}', '\u{4d2}'), + ('\u{4d4}', '\u{4d4}'), ('\u{4d6}', '\u{4d6}'), ('\u{4d8}', '\u{4d8}'), + ('\u{4da}', '\u{4da}'), ('\u{4dc}', '\u{4dc}'), ('\u{4de}', '\u{4de}'), + ('\u{4e0}', '\u{4e0}'), ('\u{4e2}', '\u{4e2}'), ('\u{4e4}', '\u{4e4}'), + ('\u{4e6}', '\u{4e6}'), ('\u{4e8}', '\u{4e8}'), ('\u{4ea}', '\u{4ea}'), + ('\u{4ec}', '\u{4ec}'), ('\u{4ee}', '\u{4ee}'), ('\u{4f0}', '\u{4f0}'), + ('\u{4f2}', '\u{4f2}'), ('\u{4f4}', '\u{4f4}'), ('\u{4f6}', '\u{4f6}'), + ('\u{4f8}', '\u{4f8}'), ('\u{4fa}', '\u{4fa}'), ('\u{4fc}', '\u{4fc}'), + ('\u{4fe}', '\u{4fe}'), ('\u{500}', '\u{500}'), ('\u{502}', '\u{502}'), + ('\u{504}', '\u{504}'), ('\u{506}', '\u{506}'), ('\u{508}', '\u{508}'), + ('\u{50a}', '\u{50a}'), ('\u{50c}', '\u{50c}'), ('\u{50e}', '\u{50e}'), + ('\u{510}', '\u{510}'), ('\u{512}', '\u{512}'), ('\u{514}', '\u{514}'), + ('\u{516}', '\u{516}'), ('\u{518}', '\u{518}'), ('\u{51a}', '\u{51a}'), + ('\u{51c}', '\u{51c}'), ('\u{51e}', '\u{51e}'), ('\u{520}', '\u{520}'), + ('\u{522}', '\u{522}'), ('\u{524}', '\u{524}'), ('\u{526}', '\u{526}'), + ('\u{528}', '\u{528}'), ('\u{52a}', '\u{52a}'), ('\u{52c}', '\u{52c}'), + ('\u{52e}', '\u{52e}'), ('\u{531}', '\u{556}'), ('\u{10a0}', + '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), + ('\u{1e00}', '\u{1e00}'), ('\u{1e02}', '\u{1e02}'), ('\u{1e04}', + '\u{1e04}'), ('\u{1e06}', '\u{1e06}'), ('\u{1e08}', '\u{1e08}'), + ('\u{1e0a}', '\u{1e0a}'), ('\u{1e0c}', '\u{1e0c}'), ('\u{1e0e}', + '\u{1e0e}'), ('\u{1e10}', '\u{1e10}'), ('\u{1e12}', '\u{1e12}'), + ('\u{1e14}', '\u{1e14}'), ('\u{1e16}', '\u{1e16}'), ('\u{1e18}', + '\u{1e18}'), ('\u{1e1a}', '\u{1e1a}'), ('\u{1e1c}', '\u{1e1c}'), + ('\u{1e1e}', '\u{1e1e}'), ('\u{1e20}', '\u{1e20}'), ('\u{1e22}', + '\u{1e22}'), ('\u{1e24}', '\u{1e24}'), ('\u{1e26}', '\u{1e26}'), + ('\u{1e28}', '\u{1e28}'), ('\u{1e2a}', '\u{1e2a}'), ('\u{1e2c}', + '\u{1e2c}'), ('\u{1e2e}', '\u{1e2e}'), ('\u{1e30}', '\u{1e30}'), + ('\u{1e32}', '\u{1e32}'), ('\u{1e34}', '\u{1e34}'), ('\u{1e36}', + '\u{1e36}'), ('\u{1e38}', '\u{1e38}'), ('\u{1e3a}', '\u{1e3a}'), + ('\u{1e3c}', '\u{1e3c}'), ('\u{1e3e}', '\u{1e3e}'), ('\u{1e40}', + '\u{1e40}'), ('\u{1e42}', '\u{1e42}'), ('\u{1e44}', '\u{1e44}'), + ('\u{1e46}', '\u{1e46}'), ('\u{1e48}', '\u{1e48}'), ('\u{1e4a}', + '\u{1e4a}'), ('\u{1e4c}', '\u{1e4c}'), ('\u{1e4e}', '\u{1e4e}'), + ('\u{1e50}', '\u{1e50}'), ('\u{1e52}', '\u{1e52}'), ('\u{1e54}', + '\u{1e54}'), ('\u{1e56}', '\u{1e56}'), ('\u{1e58}', '\u{1e58}'), + ('\u{1e5a}', '\u{1e5a}'), ('\u{1e5c}', '\u{1e5c}'), ('\u{1e5e}', + '\u{1e5e}'), ('\u{1e60}', '\u{1e60}'), ('\u{1e62}', '\u{1e62}'), + ('\u{1e64}', '\u{1e64}'), ('\u{1e66}', '\u{1e66}'), ('\u{1e68}', + '\u{1e68}'), ('\u{1e6a}', '\u{1e6a}'), ('\u{1e6c}', '\u{1e6c}'), + ('\u{1e6e}', '\u{1e6e}'), ('\u{1e70}', '\u{1e70}'), ('\u{1e72}', + '\u{1e72}'), ('\u{1e74}', '\u{1e74}'), ('\u{1e76}', '\u{1e76}'), + ('\u{1e78}', '\u{1e78}'), ('\u{1e7a}', '\u{1e7a}'), ('\u{1e7c}', + '\u{1e7c}'), ('\u{1e7e}', '\u{1e7e}'), ('\u{1e80}', '\u{1e80}'), + ('\u{1e82}', '\u{1e82}'), ('\u{1e84}', '\u{1e84}'), ('\u{1e86}', + '\u{1e86}'), ('\u{1e88}', '\u{1e88}'), ('\u{1e8a}', '\u{1e8a}'), + ('\u{1e8c}', '\u{1e8c}'), ('\u{1e8e}', '\u{1e8e}'), ('\u{1e90}', + '\u{1e90}'), ('\u{1e92}', '\u{1e92}'), ('\u{1e94}', '\u{1e94}'), + ('\u{1e9e}', '\u{1e9e}'), ('\u{1ea0}', '\u{1ea0}'), ('\u{1ea2}', + '\u{1ea2}'), ('\u{1ea4}', '\u{1ea4}'), ('\u{1ea6}', '\u{1ea6}'), + ('\u{1ea8}', '\u{1ea8}'), ('\u{1eaa}', '\u{1eaa}'), ('\u{1eac}', + '\u{1eac}'), ('\u{1eae}', '\u{1eae}'), ('\u{1eb0}', '\u{1eb0}'), + ('\u{1eb2}', '\u{1eb2}'), ('\u{1eb4}', '\u{1eb4}'), ('\u{1eb6}', + '\u{1eb6}'), ('\u{1eb8}', '\u{1eb8}'), ('\u{1eba}', '\u{1eba}'), + ('\u{1ebc}', '\u{1ebc}'), ('\u{1ebe}', '\u{1ebe}'), ('\u{1ec0}', + '\u{1ec0}'), ('\u{1ec2}', '\u{1ec2}'), ('\u{1ec4}', '\u{1ec4}'), + ('\u{1ec6}', '\u{1ec6}'), ('\u{1ec8}', '\u{1ec8}'), ('\u{1eca}', + '\u{1eca}'), ('\u{1ecc}', '\u{1ecc}'), ('\u{1ece}', '\u{1ece}'), + ('\u{1ed0}', '\u{1ed0}'), ('\u{1ed2}', '\u{1ed2}'), ('\u{1ed4}', + '\u{1ed4}'), ('\u{1ed6}', '\u{1ed6}'), ('\u{1ed8}', '\u{1ed8}'), + ('\u{1eda}', '\u{1eda}'), ('\u{1edc}', '\u{1edc}'), ('\u{1ede}', + '\u{1ede}'), ('\u{1ee0}', '\u{1ee0}'), ('\u{1ee2}', '\u{1ee2}'), + ('\u{1ee4}', '\u{1ee4}'), ('\u{1ee6}', '\u{1ee6}'), ('\u{1ee8}', + '\u{1ee8}'), ('\u{1eea}', '\u{1eea}'), ('\u{1eec}', '\u{1eec}'), + ('\u{1eee}', '\u{1eee}'), ('\u{1ef0}', '\u{1ef0}'), ('\u{1ef2}', + '\u{1ef2}'), ('\u{1ef4}', '\u{1ef4}'), ('\u{1ef6}', '\u{1ef6}'), + ('\u{1ef8}', '\u{1ef8}'), ('\u{1efa}', '\u{1efa}'), ('\u{1efc}', + '\u{1efc}'), ('\u{1efe}', '\u{1efe}'), ('\u{1f08}', '\u{1f0f}'), + ('\u{1f18}', '\u{1f1d}'), ('\u{1f28}', '\u{1f2f}'), ('\u{1f38}', + '\u{1f3f}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f59}', '\u{1f59}'), + ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', + '\u{1f5f}'), ('\u{1f68}', '\u{1f6f}'), ('\u{1fb8}', '\u{1fbb}'), + ('\u{1fc8}', '\u{1fcb}'), ('\u{1fd8}', '\u{1fdb}'), ('\u{1fe8}', + '\u{1fec}'), ('\u{1ff8}', '\u{1ffb}'), ('\u{2102}', '\u{2102}'), + ('\u{2107}', '\u{2107}'), ('\u{210b}', '\u{210d}'), ('\u{2110}', + '\u{2112}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), + ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', + '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{2130}', '\u{2133}'), + ('\u{213e}', '\u{213f}'), ('\u{2145}', '\u{2145}'), ('\u{2183}', + '\u{2183}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c60}', '\u{2c60}'), + ('\u{2c62}', '\u{2c64}'), ('\u{2c67}', '\u{2c67}'), ('\u{2c69}', + '\u{2c69}'), ('\u{2c6b}', '\u{2c6b}'), ('\u{2c6d}', '\u{2c70}'), + ('\u{2c72}', '\u{2c72}'), ('\u{2c75}', '\u{2c75}'), ('\u{2c7e}', + '\u{2c80}'), ('\u{2c82}', '\u{2c82}'), ('\u{2c84}', '\u{2c84}'), + ('\u{2c86}', '\u{2c86}'), ('\u{2c88}', '\u{2c88}'), ('\u{2c8a}', + '\u{2c8a}'), ('\u{2c8c}', '\u{2c8c}'), ('\u{2c8e}', '\u{2c8e}'), + ('\u{2c90}', '\u{2c90}'), ('\u{2c92}', '\u{2c92}'), ('\u{2c94}', + '\u{2c94}'), ('\u{2c96}', '\u{2c96}'), ('\u{2c98}', '\u{2c98}'), + ('\u{2c9a}', '\u{2c9a}'), ('\u{2c9c}', '\u{2c9c}'), ('\u{2c9e}', + '\u{2c9e}'), ('\u{2ca0}', '\u{2ca0}'), ('\u{2ca2}', '\u{2ca2}'), + ('\u{2ca4}', '\u{2ca4}'), ('\u{2ca6}', '\u{2ca6}'), ('\u{2ca8}', + '\u{2ca8}'), ('\u{2caa}', '\u{2caa}'), ('\u{2cac}', '\u{2cac}'), + ('\u{2cae}', '\u{2cae}'), ('\u{2cb0}', '\u{2cb0}'), ('\u{2cb2}', + '\u{2cb2}'), ('\u{2cb4}', '\u{2cb4}'), ('\u{2cb6}', '\u{2cb6}'), + ('\u{2cb8}', '\u{2cb8}'), ('\u{2cba}', '\u{2cba}'), ('\u{2cbc}', + '\u{2cbc}'), ('\u{2cbe}', '\u{2cbe}'), ('\u{2cc0}', '\u{2cc0}'), + ('\u{2cc2}', '\u{2cc2}'), ('\u{2cc4}', '\u{2cc4}'), ('\u{2cc6}', + '\u{2cc6}'), ('\u{2cc8}', '\u{2cc8}'), ('\u{2cca}', '\u{2cca}'), + ('\u{2ccc}', '\u{2ccc}'), ('\u{2cce}', '\u{2cce}'), ('\u{2cd0}', + '\u{2cd0}'), ('\u{2cd2}', '\u{2cd2}'), ('\u{2cd4}', '\u{2cd4}'), + ('\u{2cd6}', '\u{2cd6}'), ('\u{2cd8}', '\u{2cd8}'), ('\u{2cda}', + '\u{2cda}'), ('\u{2cdc}', '\u{2cdc}'), ('\u{2cde}', '\u{2cde}'), + ('\u{2ce0}', '\u{2ce0}'), ('\u{2ce2}', '\u{2ce2}'), ('\u{2ceb}', + '\u{2ceb}'), ('\u{2ced}', '\u{2ced}'), ('\u{2cf2}', '\u{2cf2}'), + ('\u{a640}', '\u{a640}'), ('\u{a642}', '\u{a642}'), ('\u{a644}', + '\u{a644}'), ('\u{a646}', '\u{a646}'), ('\u{a648}', '\u{a648}'), + ('\u{a64a}', '\u{a64a}'), ('\u{a64c}', '\u{a64c}'), ('\u{a64e}', + '\u{a64e}'), ('\u{a650}', '\u{a650}'), ('\u{a652}', '\u{a652}'), + ('\u{a654}', '\u{a654}'), ('\u{a656}', '\u{a656}'), ('\u{a658}', + '\u{a658}'), ('\u{a65a}', '\u{a65a}'), ('\u{a65c}', '\u{a65c}'), + ('\u{a65e}', '\u{a65e}'), ('\u{a660}', '\u{a660}'), ('\u{a662}', + '\u{a662}'), ('\u{a664}', '\u{a664}'), ('\u{a666}', '\u{a666}'), + ('\u{a668}', '\u{a668}'), ('\u{a66a}', '\u{a66a}'), ('\u{a66c}', + '\u{a66c}'), ('\u{a680}', '\u{a680}'), ('\u{a682}', '\u{a682}'), + ('\u{a684}', '\u{a684}'), ('\u{a686}', '\u{a686}'), ('\u{a688}', + '\u{a688}'), ('\u{a68a}', '\u{a68a}'), ('\u{a68c}', '\u{a68c}'), + ('\u{a68e}', '\u{a68e}'), ('\u{a690}', '\u{a690}'), ('\u{a692}', + '\u{a692}'), ('\u{a694}', '\u{a694}'), ('\u{a696}', '\u{a696}'), + ('\u{a698}', '\u{a698}'), ('\u{a69a}', '\u{a69a}'), ('\u{a722}', + '\u{a722}'), ('\u{a724}', '\u{a724}'), ('\u{a726}', '\u{a726}'), + ('\u{a728}', '\u{a728}'), ('\u{a72a}', '\u{a72a}'), ('\u{a72c}', + '\u{a72c}'), ('\u{a72e}', '\u{a72e}'), ('\u{a732}', '\u{a732}'), + ('\u{a734}', '\u{a734}'), ('\u{a736}', '\u{a736}'), ('\u{a738}', + '\u{a738}'), ('\u{a73a}', '\u{a73a}'), ('\u{a73c}', '\u{a73c}'), + ('\u{a73e}', '\u{a73e}'), ('\u{a740}', '\u{a740}'), ('\u{a742}', + '\u{a742}'), ('\u{a744}', '\u{a744}'), ('\u{a746}', '\u{a746}'), + ('\u{a748}', '\u{a748}'), ('\u{a74a}', '\u{a74a}'), ('\u{a74c}', + '\u{a74c}'), ('\u{a74e}', '\u{a74e}'), ('\u{a750}', '\u{a750}'), + ('\u{a752}', '\u{a752}'), ('\u{a754}', '\u{a754}'), ('\u{a756}', + '\u{a756}'), ('\u{a758}', '\u{a758}'), ('\u{a75a}', '\u{a75a}'), + ('\u{a75c}', '\u{a75c}'), ('\u{a75e}', '\u{a75e}'), ('\u{a760}', + '\u{a760}'), ('\u{a762}', '\u{a762}'), ('\u{a764}', '\u{a764}'), + ('\u{a766}', '\u{a766}'), ('\u{a768}', '\u{a768}'), ('\u{a76a}', + '\u{a76a}'), ('\u{a76c}', '\u{a76c}'), ('\u{a76e}', '\u{a76e}'), + ('\u{a779}', '\u{a779}'), ('\u{a77b}', '\u{a77b}'), ('\u{a77d}', + '\u{a77e}'), ('\u{a780}', '\u{a780}'), ('\u{a782}', '\u{a782}'), + ('\u{a784}', '\u{a784}'), ('\u{a786}', '\u{a786}'), ('\u{a78b}', + '\u{a78b}'), ('\u{a78d}', '\u{a78d}'), ('\u{a790}', '\u{a790}'), + ('\u{a792}', '\u{a792}'), ('\u{a796}', '\u{a796}'), ('\u{a798}', + '\u{a798}'), ('\u{a79a}', '\u{a79a}'), ('\u{a79c}', '\u{a79c}'), + ('\u{a79e}', '\u{a79e}'), ('\u{a7a0}', '\u{a7a0}'), ('\u{a7a2}', + '\u{a7a2}'), ('\u{a7a4}', '\u{a7a4}'), ('\u{a7a6}', '\u{a7a6}'), + ('\u{a7a8}', '\u{a7a8}'), ('\u{a7aa}', '\u{a7ad}'), ('\u{a7b0}', + '\u{a7b1}'), ('\u{ff21}', '\u{ff3a}'), ('\u{10400}', '\u{10427}'), + ('\u{118a0}', '\u{118bf}'), ('\u{1d400}', '\u{1d419}'), ('\u{1d434}', + '\u{1d44d}'), ('\u{1d468}', '\u{1d481}'), ('\u{1d49c}', '\u{1d49c}'), + ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', + '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b5}'), + ('\u{1d4d0}', '\u{1d4e9}'), ('\u{1d504}', '\u{1d505}'), ('\u{1d507}', + '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), + ('\u{1d538}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', + '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), + ('\u{1d56c}', '\u{1d585}'), ('\u{1d5a0}', '\u{1d5b9}'), ('\u{1d5d4}', + '\u{1d5ed}'), ('\u{1d608}', '\u{1d621}'), ('\u{1d63c}', '\u{1d655}'), + ('\u{1d670}', '\u{1d689}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6e2}', + '\u{1d6fa}'), ('\u{1d71c}', '\u{1d734}'), ('\u{1d756}', '\u{1d76e}'), + ('\u{1d790}', '\u{1d7a8}'), ('\u{1d7ca}', '\u{1d7ca}') + ]; + + pub const M_table: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), ('\u{483}', '\u{489}'), ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), ('\u{610}', '\u{61a}'), ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), ('\u{6d6}', '\u{6dc}'), ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), ('\u{6ea}', '\u{6ed}'), ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), ('\u{7a6}', '\u{7b0}'), ('\u{7eb}', '\u{7f3}'), + ('\u{816}', '\u{819}'), ('\u{81b}', '\u{823}'), ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), ('\u{859}', '\u{85b}'), ('\u{8e4}', '\u{903}'), + ('\u{93a}', '\u{93c}'), ('\u{93e}', '\u{94f}'), ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), ('\u{981}', '\u{983}'), ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), ('\u{9e2}', '\u{9e3}'), ('\u{a01}', '\u{a03}'), + ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{abc}', '\u{abc}'), + ('\u{abe}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), ('\u{b01}', '\u{b03}'), ('\u{b3c}', '\u{b3c}'), + ('\u{b3e}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), ('\u{b62}', '\u{b63}'), ('\u{b82}', '\u{b82}'), + ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), ('\u{c00}', '\u{c03}'), ('\u{c3e}', '\u{c44}'), + ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), ('\u{c81}', '\u{c83}'), ('\u{cbc}', '\u{cbc}'), + ('\u{cbe}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), ('\u{ce2}', '\u{ce3}'), ('\u{d01}', '\u{d03}'), + ('\u{d3e}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), ('\u{d62}', '\u{d63}'), ('\u{d82}', '\u{d83}'), + ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), + ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), ('\u{e47}', '\u{e4e}'), ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{eb9}'), ('\u{ebb}', '\u{ebc}'), ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), ('\u{f3e}', '\u{f3f}'), ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), ('\u{f8d}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), ('\u{102b}', '\u{103e}'), ('\u{1056}', + '\u{1059}'), ('\u{105e}', '\u{1060}'), ('\u{1062}', '\u{1064}'), + ('\u{1067}', '\u{106d}'), ('\u{1071}', '\u{1074}'), ('\u{1082}', + '\u{108d}'), ('\u{108f}', '\u{108f}'), ('\u{109a}', '\u{109d}'), + ('\u{135d}', '\u{135f}'), ('\u{1712}', '\u{1714}'), ('\u{1732}', + '\u{1734}'), ('\u{1752}', '\u{1753}'), ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17d3}'), ('\u{17dd}', '\u{17dd}'), ('\u{180b}', + '\u{180d}'), ('\u{18a9}', '\u{18a9}'), ('\u{1920}', '\u{192b}'), + ('\u{1930}', '\u{193b}'), ('\u{19b0}', '\u{19c0}'), ('\u{19c8}', + '\u{19c9}'), ('\u{1a17}', '\u{1a1b}'), ('\u{1a55}', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a7f}'), ('\u{1ab0}', + '\u{1abe}'), ('\u{1b00}', '\u{1b04}'), ('\u{1b34}', '\u{1b44}'), + ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1b82}'), ('\u{1ba1}', + '\u{1bad}'), ('\u{1be6}', '\u{1bf3}'), ('\u{1c24}', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce8}'), ('\u{1ced}', + '\u{1ced}'), ('\u{1cf2}', '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df5}'), ('\u{1dfc}', '\u{1dff}'), ('\u{20d0}', + '\u{20f0}'), ('\u{2cef}', '\u{2cf1}'), ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), ('\u{302a}', '\u{302f}'), ('\u{3099}', + '\u{309a}'), ('\u{a66f}', '\u{a672}'), ('\u{a674}', '\u{a67d}'), + ('\u{a69f}', '\u{a69f}'), ('\u{a6f0}', '\u{a6f1}'), ('\u{a802}', + '\u{a802}'), ('\u{a806}', '\u{a806}'), ('\u{a80b}', '\u{a80b}'), + ('\u{a823}', '\u{a827}'), ('\u{a880}', '\u{a881}'), ('\u{a8b4}', + '\u{a8c4}'), ('\u{a8e0}', '\u{a8f1}'), ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '\u{a953}'), ('\u{a980}', '\u{a983}'), ('\u{a9b3}', + '\u{a9c0}'), ('\u{a9e5}', '\u{a9e5}'), ('\u{aa29}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), ('\u{aa4c}', '\u{aa4d}'), ('\u{aa7b}', + '\u{aa7d}'), ('\u{aab0}', '\u{aab0}'), ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), ('\u{aabe}', '\u{aabf}'), ('\u{aac1}', + '\u{aac1}'), ('\u{aaeb}', '\u{aaef}'), ('\u{aaf5}', '\u{aaf6}'), + ('\u{abe3}', '\u{abea}'), ('\u{abec}', '\u{abed}'), ('\u{fb1e}', + '\u{fb1e}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2d}'), + ('\u{101fd}', '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{10376}', + '\u{1037a}'), ('\u{10a01}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', + '\u{10a3f}'), ('\u{10ae5}', '\u{10ae6}'), ('\u{11000}', '\u{11002}'), + ('\u{11038}', '\u{11046}'), ('\u{1107f}', '\u{11082}'), ('\u{110b0}', + '\u{110ba}'), ('\u{11100}', '\u{11102}'), ('\u{11127}', '\u{11134}'), + ('\u{11173}', '\u{11173}'), ('\u{11180}', '\u{11182}'), ('\u{111b3}', + '\u{111c0}'), ('\u{1122c}', '\u{11237}'), ('\u{112df}', '\u{112ea}'), + ('\u{11301}', '\u{11303}'), ('\u{1133c}', '\u{1133c}'), ('\u{1133e}', + '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), + ('\u{11357}', '\u{11357}'), ('\u{11362}', '\u{11363}'), ('\u{11366}', + '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{114b0}', '\u{114c3}'), + ('\u{115af}', '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{11630}', + '\u{11640}'), ('\u{116ab}', '\u{116b7}'), ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), ('\u{16f51}', '\u{16f7e}'), ('\u{16f8f}', + '\u{16f92}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), + ('\u{1d16d}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', + '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), + ('\u{1e8d0}', '\u{1e8d6}'), ('\u{e0100}', '\u{e01ef}') + ]; + + pub const Mc_table: &'static [(char, char)] = &[ + ('\u{903}', '\u{903}'), ('\u{93b}', '\u{93b}'), ('\u{93e}', '\u{940}'), + ('\u{949}', '\u{94c}'), ('\u{94e}', '\u{94f}'), ('\u{982}', '\u{983}'), + ('\u{9be}', '\u{9c0}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9cc}'), + ('\u{9d7}', '\u{9d7}'), ('\u{a03}', '\u{a03}'), ('\u{a3e}', '\u{a40}'), + ('\u{a83}', '\u{a83}'), ('\u{abe}', '\u{ac0}'), ('\u{ac9}', '\u{ac9}'), + ('\u{acb}', '\u{acc}'), ('\u{b02}', '\u{b03}'), ('\u{b3e}', '\u{b3e}'), + ('\u{b40}', '\u{b40}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4c}'), + ('\u{b57}', '\u{b57}'), ('\u{bbe}', '\u{bbf}'), ('\u{bc1}', '\u{bc2}'), + ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcc}'), ('\u{bd7}', '\u{bd7}'), + ('\u{c01}', '\u{c03}'), ('\u{c41}', '\u{c44}'), ('\u{c82}', '\u{c83}'), + ('\u{cbe}', '\u{cbe}'), ('\u{cc0}', '\u{cc4}'), ('\u{cc7}', '\u{cc8}'), + ('\u{cca}', '\u{ccb}'), ('\u{cd5}', '\u{cd6}'), ('\u{d02}', '\u{d03}'), + ('\u{d3e}', '\u{d40}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4c}'), + ('\u{d57}', '\u{d57}'), ('\u{d82}', '\u{d83}'), ('\u{dcf}', '\u{dd1}'), + ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{f3e}', '\u{f3f}'), + ('\u{f7f}', '\u{f7f}'), ('\u{102b}', '\u{102c}'), ('\u{1031}', + '\u{1031}'), ('\u{1038}', '\u{1038}'), ('\u{103b}', '\u{103c}'), + ('\u{1056}', '\u{1057}'), ('\u{1062}', '\u{1064}'), ('\u{1067}', + '\u{106d}'), ('\u{1083}', '\u{1084}'), ('\u{1087}', '\u{108c}'), + ('\u{108f}', '\u{108f}'), ('\u{109a}', '\u{109c}'), ('\u{17b6}', + '\u{17b6}'), ('\u{17be}', '\u{17c5}'), ('\u{17c7}', '\u{17c8}'), + ('\u{1923}', '\u{1926}'), ('\u{1929}', '\u{192b}'), ('\u{1930}', + '\u{1931}'), ('\u{1933}', '\u{1938}'), ('\u{19b0}', '\u{19c0}'), + ('\u{19c8}', '\u{19c9}'), ('\u{1a19}', '\u{1a1a}'), ('\u{1a55}', + '\u{1a55}'), ('\u{1a57}', '\u{1a57}'), ('\u{1a61}', '\u{1a61}'), + ('\u{1a63}', '\u{1a64}'), ('\u{1a6d}', '\u{1a72}'), ('\u{1b04}', + '\u{1b04}'), ('\u{1b35}', '\u{1b35}'), ('\u{1b3b}', '\u{1b3b}'), + ('\u{1b3d}', '\u{1b41}'), ('\u{1b43}', '\u{1b44}'), ('\u{1b82}', + '\u{1b82}'), ('\u{1ba1}', '\u{1ba1}'), ('\u{1ba6}', '\u{1ba7}'), + ('\u{1baa}', '\u{1baa}'), ('\u{1be7}', '\u{1be7}'), ('\u{1bea}', + '\u{1bec}'), ('\u{1bee}', '\u{1bee}'), ('\u{1bf2}', '\u{1bf3}'), + ('\u{1c24}', '\u{1c2b}'), ('\u{1c34}', '\u{1c35}'), ('\u{1ce1}', + '\u{1ce1}'), ('\u{1cf2}', '\u{1cf3}'), ('\u{302e}', '\u{302f}'), + ('\u{a823}', '\u{a824}'), ('\u{a827}', '\u{a827}'), ('\u{a880}', + '\u{a881}'), ('\u{a8b4}', '\u{a8c3}'), ('\u{a952}', '\u{a953}'), + ('\u{a983}', '\u{a983}'), ('\u{a9b4}', '\u{a9b5}'), ('\u{a9ba}', + '\u{a9bb}'), ('\u{a9bd}', '\u{a9c0}'), ('\u{aa2f}', '\u{aa30}'), + ('\u{aa33}', '\u{aa34}'), ('\u{aa4d}', '\u{aa4d}'), ('\u{aa7b}', + '\u{aa7b}'), ('\u{aa7d}', '\u{aa7d}'), ('\u{aaeb}', '\u{aaeb}'), + ('\u{aaee}', '\u{aaef}'), ('\u{aaf5}', '\u{aaf5}'), ('\u{abe3}', + '\u{abe4}'), ('\u{abe6}', '\u{abe7}'), ('\u{abe9}', '\u{abea}'), + ('\u{abec}', '\u{abec}'), ('\u{11000}', '\u{11000}'), ('\u{11002}', + '\u{11002}'), ('\u{11082}', '\u{11082}'), ('\u{110b0}', '\u{110b2}'), + ('\u{110b7}', '\u{110b8}'), ('\u{1112c}', '\u{1112c}'), ('\u{11182}', + '\u{11182}'), ('\u{111b3}', '\u{111b5}'), ('\u{111bf}', '\u{111c0}'), + ('\u{1122c}', '\u{1122e}'), ('\u{11232}', '\u{11233}'), ('\u{11235}', + '\u{11235}'), ('\u{112e0}', '\u{112e2}'), ('\u{11302}', '\u{11303}'), + ('\u{1133e}', '\u{1133f}'), ('\u{11341}', '\u{11344}'), ('\u{11347}', + '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11357}', '\u{11357}'), + ('\u{11362}', '\u{11363}'), ('\u{114b0}', '\u{114b2}'), ('\u{114b9}', + '\u{114b9}'), ('\u{114bb}', '\u{114be}'), ('\u{114c1}', '\u{114c1}'), + ('\u{115af}', '\u{115b1}'), ('\u{115b8}', '\u{115bb}'), ('\u{115be}', + '\u{115be}'), ('\u{11630}', '\u{11632}'), ('\u{1163b}', '\u{1163c}'), + ('\u{1163e}', '\u{1163e}'), ('\u{116ac}', '\u{116ac}'), ('\u{116ae}', + '\u{116af}'), ('\u{116b6}', '\u{116b6}'), ('\u{16f51}', '\u{16f7e}'), + ('\u{1d165}', '\u{1d166}'), ('\u{1d16d}', '\u{1d172}') + ]; + + pub const Me_table: &'static [(char, char)] = &[ + ('\u{488}', '\u{489}'), ('\u{1abe}', '\u{1abe}'), ('\u{20dd}', + '\u{20e0}'), ('\u{20e2}', '\u{20e4}'), ('\u{a670}', '\u{a672}') + ]; + + pub const Mn_table: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), ('\u{483}', '\u{487}'), ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), ('\u{610}', '\u{61a}'), ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), ('\u{6d6}', '\u{6dc}'), ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), ('\u{6ea}', '\u{6ed}'), ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), ('\u{7a6}', '\u{7b0}'), ('\u{7eb}', '\u{7f3}'), + ('\u{816}', '\u{819}'), ('\u{81b}', '\u{823}'), ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), ('\u{859}', '\u{85b}'), ('\u{8e4}', '\u{902}'), + ('\u{93a}', '\u{93a}'), ('\u{93c}', '\u{93c}'), ('\u{941}', '\u{948}'), + ('\u{94d}', '\u{94d}'), ('\u{951}', '\u{957}'), ('\u{962}', '\u{963}'), + ('\u{981}', '\u{981}'), ('\u{9bc}', '\u{9bc}'), ('\u{9c1}', '\u{9c4}'), + ('\u{9cd}', '\u{9cd}'), ('\u{9e2}', '\u{9e3}'), ('\u{a01}', '\u{a02}'), + ('\u{a3c}', '\u{a3c}'), ('\u{a41}', '\u{a42}'), ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), ('\u{a81}', '\u{a82}'), ('\u{abc}', '\u{abc}'), + ('\u{ac1}', '\u{ac5}'), ('\u{ac7}', '\u{ac8}'), ('\u{acd}', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), ('\u{b01}', '\u{b01}'), ('\u{b3c}', '\u{b3c}'), + ('\u{b3f}', '\u{b3f}'), ('\u{b41}', '\u{b44}'), ('\u{b4d}', '\u{b4d}'), + ('\u{b56}', '\u{b56}'), ('\u{b62}', '\u{b63}'), ('\u{b82}', '\u{b82}'), + ('\u{bc0}', '\u{bc0}'), ('\u{bcd}', '\u{bcd}'), ('\u{c00}', '\u{c00}'), + ('\u{c3e}', '\u{c40}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), ('\u{c62}', '\u{c63}'), ('\u{c81}', '\u{c81}'), + ('\u{cbc}', '\u{cbc}'), ('\u{cbf}', '\u{cbf}'), ('\u{cc6}', '\u{cc6}'), + ('\u{ccc}', '\u{ccd}'), ('\u{ce2}', '\u{ce3}'), ('\u{d01}', '\u{d01}'), + ('\u{d41}', '\u{d44}'), ('\u{d4d}', '\u{d4d}'), ('\u{d62}', '\u{d63}'), + ('\u{dca}', '\u{dca}'), ('\u{dd2}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), + ('\u{e31}', '\u{e31}'), ('\u{e34}', '\u{e3a}'), ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), ('\u{eb4}', '\u{eb9}'), ('\u{ebb}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), ('\u{f18}', '\u{f19}'), ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f71}', '\u{f7e}'), + ('\u{f80}', '\u{f84}'), ('\u{f86}', '\u{f87}'), ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{102d}', + '\u{1030}'), ('\u{1032}', '\u{1037}'), ('\u{1039}', '\u{103a}'), + ('\u{103d}', '\u{103e}'), ('\u{1058}', '\u{1059}'), ('\u{105e}', + '\u{1060}'), ('\u{1071}', '\u{1074}'), ('\u{1082}', '\u{1082}'), + ('\u{1085}', '\u{1086}'), ('\u{108d}', '\u{108d}'), ('\u{109d}', + '\u{109d}'), ('\u{135d}', '\u{135f}'), ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), ('\u{1752}', '\u{1753}'), ('\u{1772}', + '\u{1773}'), ('\u{17b4}', '\u{17b5}'), ('\u{17b7}', '\u{17bd}'), + ('\u{17c6}', '\u{17c6}'), ('\u{17c9}', '\u{17d3}'), ('\u{17dd}', + '\u{17dd}'), ('\u{180b}', '\u{180d}'), ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', '\u{1922}'), ('\u{1927}', '\u{1928}'), ('\u{1932}', + '\u{1932}'), ('\u{1939}', '\u{193b}'), ('\u{1a17}', '\u{1a18}'), + ('\u{1a1b}', '\u{1a1b}'), ('\u{1a56}', '\u{1a56}'), ('\u{1a58}', + '\u{1a5e}'), ('\u{1a60}', '\u{1a60}'), ('\u{1a62}', '\u{1a62}'), + ('\u{1a65}', '\u{1a6c}'), ('\u{1a73}', '\u{1a7c}'), ('\u{1a7f}', + '\u{1a7f}'), ('\u{1ab0}', '\u{1abd}'), ('\u{1b00}', '\u{1b03}'), + ('\u{1b34}', '\u{1b34}'), ('\u{1b36}', '\u{1b3a}'), ('\u{1b3c}', + '\u{1b3c}'), ('\u{1b42}', '\u{1b42}'), ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '\u{1b81}'), ('\u{1ba2}', '\u{1ba5}'), ('\u{1ba8}', + '\u{1ba9}'), ('\u{1bab}', '\u{1bad}'), ('\u{1be6}', '\u{1be6}'), + ('\u{1be8}', '\u{1be9}'), ('\u{1bed}', '\u{1bed}'), ('\u{1bef}', + '\u{1bf1}'), ('\u{1c2c}', '\u{1c33}'), ('\u{1c36}', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce0}'), ('\u{1ce2}', + '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf4}', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), ('\u{1dfc}', + '\u{1dff}'), ('\u{20d0}', '\u{20dc}'), ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20f0}'), ('\u{2cef}', '\u{2cf1}'), ('\u{2d7f}', + '\u{2d7f}'), ('\u{2de0}', '\u{2dff}'), ('\u{302a}', '\u{302d}'), + ('\u{3099}', '\u{309a}'), ('\u{a66f}', '\u{a66f}'), ('\u{a674}', + '\u{a67d}'), ('\u{a69f}', '\u{a69f}'), ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), ('\u{a806}', '\u{a806}'), ('\u{a80b}', + '\u{a80b}'), ('\u{a825}', '\u{a826}'), ('\u{a8c4}', '\u{a8c4}'), + ('\u{a8e0}', '\u{a8f1}'), ('\u{a926}', '\u{a92d}'), ('\u{a947}', + '\u{a951}'), ('\u{a980}', '\u{a982}'), ('\u{a9b3}', '\u{a9b3}'), + ('\u{a9b6}', '\u{a9b9}'), ('\u{a9bc}', '\u{a9bc}'), ('\u{a9e5}', + '\u{a9e5}'), ('\u{aa29}', '\u{aa2e}'), ('\u{aa31}', '\u{aa32}'), + ('\u{aa35}', '\u{aa36}'), ('\u{aa43}', '\u{aa43}'), ('\u{aa4c}', + '\u{aa4c}'), ('\u{aa7c}', '\u{aa7c}'), ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), ('\u{aab7}', '\u{aab8}'), ('\u{aabe}', + '\u{aabf}'), ('\u{aac1}', '\u{aac1}'), ('\u{aaec}', '\u{aaed}'), + ('\u{aaf6}', '\u{aaf6}'), ('\u{abe5}', '\u{abe5}'), ('\u{abe8}', + '\u{abe8}'), ('\u{abed}', '\u{abed}'), ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2d}'), ('\u{101fd}', + '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', + '\u{10a0f}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), ('\u{11001}', '\u{11001}'), ('\u{11038}', + '\u{11046}'), ('\u{1107f}', '\u{11081}'), ('\u{110b3}', '\u{110b6}'), + ('\u{110b9}', '\u{110ba}'), ('\u{11100}', '\u{11102}'), ('\u{11127}', + '\u{1112b}'), ('\u{1112d}', '\u{11134}'), ('\u{11173}', '\u{11173}'), + ('\u{11180}', '\u{11181}'), ('\u{111b6}', '\u{111be}'), ('\u{1122f}', + '\u{11231}'), ('\u{11234}', '\u{11234}'), ('\u{11236}', '\u{11237}'), + ('\u{112df}', '\u{112df}'), ('\u{112e3}', '\u{112ea}'), ('\u{11301}', + '\u{11301}'), ('\u{1133c}', '\u{1133c}'), ('\u{11340}', '\u{11340}'), + ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{114b3}', + '\u{114b8}'), ('\u{114ba}', '\u{114ba}'), ('\u{114bf}', '\u{114c0}'), + ('\u{114c2}', '\u{114c3}'), ('\u{115b2}', '\u{115b5}'), ('\u{115bc}', + '\u{115bd}'), ('\u{115bf}', '\u{115c0}'), ('\u{11633}', '\u{1163a}'), + ('\u{1163d}', '\u{1163d}'), ('\u{1163f}', '\u{11640}'), ('\u{116ab}', + '\u{116ab}'), ('\u{116ad}', '\u{116ad}'), ('\u{116b0}', '\u{116b5}'), + ('\u{116b7}', '\u{116b7}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b30}', + '\u{16b36}'), ('\u{16f8f}', '\u{16f92}'), ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d167}', '\u{1d169}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', + '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), + ('\u{1e8d0}', '\u{1e8d6}'), ('\u{e0100}', '\u{e01ef}') + ]; + + pub const N_table: &'static [(char, char)] = &[ + ('\u{30}', '\u{39}'), ('\u{660}', '\u{669}'), ('\u{6f0}', '\u{6f9}'), + ('\u{7c0}', '\u{7c9}'), ('\u{966}', '\u{96f}'), ('\u{9e6}', '\u{9ef}'), + ('\u{a66}', '\u{a6f}'), ('\u{ae6}', '\u{aef}'), ('\u{b66}', '\u{b6f}'), + ('\u{be6}', '\u{bef}'), ('\u{c66}', '\u{c6f}'), ('\u{ce6}', '\u{cef}'), + ('\u{d66}', '\u{d6f}'), ('\u{de6}', '\u{def}'), ('\u{e50}', '\u{e59}'), + ('\u{ed0}', '\u{ed9}'), ('\u{f20}', '\u{f29}'), ('\u{1040}', + '\u{1049}'), ('\u{1090}', '\u{1099}'), ('\u{16ee}', '\u{16f0}'), + ('\u{17e0}', '\u{17e9}'), ('\u{1810}', '\u{1819}'), ('\u{1946}', + '\u{194f}'), ('\u{19d0}', '\u{19d9}'), ('\u{1a80}', '\u{1a89}'), + ('\u{1a90}', '\u{1a99}'), ('\u{1b50}', '\u{1b59}'), ('\u{1bb0}', + '\u{1bb9}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c50}', '\u{1c59}'), + ('\u{2160}', '\u{2182}'), ('\u{2185}', '\u{2188}'), ('\u{3007}', + '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3038}', '\u{303a}'), + ('\u{a620}', '\u{a629}'), ('\u{a6e6}', '\u{a6ef}'), ('\u{a8d0}', + '\u{a8d9}'), ('\u{a900}', '\u{a909}'), ('\u{a9d0}', '\u{a9d9}'), + ('\u{a9f0}', '\u{a9f9}'), ('\u{aa50}', '\u{aa59}'), ('\u{abf0}', + '\u{abf9}'), ('\u{ff10}', '\u{ff19}'), ('\u{10140}', '\u{10174}'), + ('\u{10341}', '\u{10341}'), ('\u{1034a}', '\u{1034a}'), ('\u{103d1}', + '\u{103d5}'), ('\u{104a0}', '\u{104a9}'), ('\u{11066}', '\u{1106f}'), + ('\u{110f0}', '\u{110f9}'), ('\u{11136}', '\u{1113f}'), ('\u{111d0}', + '\u{111d9}'), ('\u{112f0}', '\u{112f9}'), ('\u{114d0}', '\u{114d9}'), + ('\u{11650}', '\u{11659}'), ('\u{116c0}', '\u{116c9}'), ('\u{118e0}', + '\u{118e9}'), ('\u{12400}', '\u{1246e}'), ('\u{16a60}', '\u{16a69}'), + ('\u{16b50}', '\u{16b59}'), ('\u{1d7ce}', '\u{1d7ff}') + ]; + + pub const Nd_table: &'static [(char, char)] = &[ + ('\u{30}', '\u{39}'), ('\u{660}', '\u{669}'), ('\u{6f0}', '\u{6f9}'), + ('\u{7c0}', '\u{7c9}'), ('\u{966}', '\u{96f}'), ('\u{9e6}', '\u{9ef}'), + ('\u{a66}', '\u{a6f}'), ('\u{ae6}', '\u{aef}'), ('\u{b66}', '\u{b6f}'), + ('\u{be6}', '\u{bef}'), ('\u{c66}', '\u{c6f}'), ('\u{ce6}', '\u{cef}'), + ('\u{d66}', '\u{d6f}'), ('\u{de6}', '\u{def}'), ('\u{e50}', '\u{e59}'), + ('\u{ed0}', '\u{ed9}'), ('\u{f20}', '\u{f29}'), ('\u{1040}', + '\u{1049}'), ('\u{1090}', '\u{1099}'), ('\u{17e0}', '\u{17e9}'), + ('\u{1810}', '\u{1819}'), ('\u{1946}', '\u{194f}'), ('\u{19d0}', + '\u{19d9}'), ('\u{1a80}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), + ('\u{1b50}', '\u{1b59}'), ('\u{1bb0}', '\u{1bb9}'), ('\u{1c40}', + '\u{1c49}'), ('\u{1c50}', '\u{1c59}'), ('\u{a620}', '\u{a629}'), + ('\u{a8d0}', '\u{a8d9}'), ('\u{a900}', '\u{a909}'), ('\u{a9d0}', + '\u{a9d9}'), ('\u{a9f0}', '\u{a9f9}'), ('\u{aa50}', '\u{aa59}'), + ('\u{abf0}', '\u{abf9}'), ('\u{ff10}', '\u{ff19}'), ('\u{104a0}', + '\u{104a9}'), ('\u{11066}', '\u{1106f}'), ('\u{110f0}', '\u{110f9}'), + ('\u{11136}', '\u{1113f}'), ('\u{111d0}', '\u{111d9}'), ('\u{112f0}', + '\u{112f9}'), ('\u{114d0}', '\u{114d9}'), ('\u{11650}', '\u{11659}'), + ('\u{116c0}', '\u{116c9}'), ('\u{118e0}', '\u{118e9}'), ('\u{16a60}', + '\u{16a69}'), ('\u{16b50}', '\u{16b59}'), ('\u{1d7ce}', '\u{1d7ff}') + ]; + + pub const Nl_table: &'static [(char, char)] = &[ + ('\u{16ee}', '\u{16f0}'), ('\u{2160}', '\u{2182}'), ('\u{2185}', + '\u{2188}'), ('\u{3007}', '\u{3007}'), ('\u{3021}', '\u{3029}'), + ('\u{3038}', '\u{303a}'), ('\u{a6e6}', '\u{a6ef}'), ('\u{10140}', + '\u{10174}'), ('\u{10341}', '\u{10341}'), ('\u{1034a}', '\u{1034a}'), + ('\u{103d1}', '\u{103d5}'), ('\u{12400}', '\u{1246e}') + ]; + + pub const No_table: &'static [(char, char)] = &[ + ('\u{b2}', '\u{b3}'), ('\u{b9}', '\u{b9}'), ('\u{bc}', '\u{be}'), + ('\u{9f4}', '\u{9f9}'), ('\u{b72}', '\u{b77}'), ('\u{bf0}', '\u{bf2}'), + ('\u{c78}', '\u{c7e}'), ('\u{d70}', '\u{d75}'), ('\u{f2a}', '\u{f33}'), + ('\u{1369}', '\u{137c}'), ('\u{17f0}', '\u{17f9}'), ('\u{19da}', + '\u{19da}'), ('\u{2070}', '\u{2070}'), ('\u{2074}', '\u{2079}'), + ('\u{2080}', '\u{2089}'), ('\u{2150}', '\u{215f}'), ('\u{2189}', + '\u{2189}'), ('\u{2460}', '\u{249b}'), ('\u{24ea}', '\u{24ff}'), + ('\u{2776}', '\u{2793}'), ('\u{2cfd}', '\u{2cfd}'), ('\u{3192}', + '\u{3195}'), ('\u{3220}', '\u{3229}'), ('\u{3248}', '\u{324f}'), + ('\u{3251}', '\u{325f}'), ('\u{3280}', '\u{3289}'), ('\u{32b1}', + '\u{32bf}'), ('\u{a830}', '\u{a835}'), ('\u{10107}', '\u{10133}'), + ('\u{10175}', '\u{10178}'), ('\u{1018a}', '\u{1018b}'), ('\u{102e1}', + '\u{102fb}'), ('\u{10320}', '\u{10323}'), ('\u{10858}', '\u{1085f}'), + ('\u{10879}', '\u{1087f}'), ('\u{108a7}', '\u{108af}'), ('\u{10916}', + '\u{1091b}'), ('\u{10a40}', '\u{10a47}'), ('\u{10a7d}', '\u{10a7e}'), + ('\u{10a9d}', '\u{10a9f}'), ('\u{10aeb}', '\u{10aef}'), ('\u{10b58}', + '\u{10b5f}'), ('\u{10b78}', '\u{10b7f}'), ('\u{10ba9}', '\u{10baf}'), + ('\u{10e60}', '\u{10e7e}'), ('\u{11052}', '\u{11065}'), ('\u{111e1}', + '\u{111f4}'), ('\u{118ea}', '\u{118f2}'), ('\u{16b5b}', '\u{16b61}'), + ('\u{1d360}', '\u{1d371}'), ('\u{1e8c7}', '\u{1e8cf}'), ('\u{1f100}', + '\u{1f10c}') + ]; + + pub const P_table: &'static [(char, char)] = &[ + ('\u{21}', '\u{23}'), ('\u{25}', '\u{2a}'), ('\u{2c}', '\u{2f}'), + ('\u{3a}', '\u{3b}'), ('\u{3f}', '\u{40}'), ('\u{5b}', '\u{5d}'), + ('\u{5f}', '\u{5f}'), ('\u{7b}', '\u{7b}'), ('\u{7d}', '\u{7d}'), + ('\u{a1}', '\u{a1}'), ('\u{a7}', '\u{a7}'), ('\u{ab}', '\u{ab}'), + ('\u{b6}', '\u{b7}'), ('\u{bb}', '\u{bb}'), ('\u{bf}', '\u{bf}'), + ('\u{37e}', '\u{37e}'), ('\u{387}', '\u{387}'), ('\u{55a}', '\u{55f}'), + ('\u{589}', '\u{58a}'), ('\u{5be}', '\u{5be}'), ('\u{5c0}', '\u{5c0}'), + ('\u{5c3}', '\u{5c3}'), ('\u{5c6}', '\u{5c6}'), ('\u{5f3}', '\u{5f4}'), + ('\u{609}', '\u{60a}'), ('\u{60c}', '\u{60d}'), ('\u{61b}', '\u{61b}'), + ('\u{61e}', '\u{61f}'), ('\u{66a}', '\u{66d}'), ('\u{6d4}', '\u{6d4}'), + ('\u{700}', '\u{70d}'), ('\u{7f7}', '\u{7f9}'), ('\u{830}', '\u{83e}'), + ('\u{85e}', '\u{85e}'), ('\u{964}', '\u{965}'), ('\u{970}', '\u{970}'), + ('\u{af0}', '\u{af0}'), ('\u{df4}', '\u{df4}'), ('\u{e4f}', '\u{e4f}'), + ('\u{e5a}', '\u{e5b}'), ('\u{f04}', '\u{f12}'), ('\u{f14}', '\u{f14}'), + ('\u{f3a}', '\u{f3d}'), ('\u{f85}', '\u{f85}'), ('\u{fd0}', '\u{fd4}'), + ('\u{fd9}', '\u{fda}'), ('\u{104a}', '\u{104f}'), ('\u{10fb}', + '\u{10fb}'), ('\u{1360}', '\u{1368}'), ('\u{1400}', '\u{1400}'), + ('\u{166d}', '\u{166e}'), ('\u{169b}', '\u{169c}'), ('\u{16eb}', + '\u{16ed}'), ('\u{1735}', '\u{1736}'), ('\u{17d4}', '\u{17d6}'), + ('\u{17d8}', '\u{17da}'), ('\u{1800}', '\u{180a}'), ('\u{1944}', + '\u{1945}'), ('\u{1a1e}', '\u{1a1f}'), ('\u{1aa0}', '\u{1aa6}'), + ('\u{1aa8}', '\u{1aad}'), ('\u{1b5a}', '\u{1b60}'), ('\u{1bfc}', + '\u{1bff}'), ('\u{1c3b}', '\u{1c3f}'), ('\u{1c7e}', '\u{1c7f}'), + ('\u{1cc0}', '\u{1cc7}'), ('\u{1cd3}', '\u{1cd3}'), ('\u{2010}', + '\u{2027}'), ('\u{2030}', '\u{2043}'), ('\u{2045}', '\u{2051}'), + ('\u{2053}', '\u{205e}'), ('\u{207d}', '\u{207e}'), ('\u{208d}', + '\u{208e}'), ('\u{2308}', '\u{230b}'), ('\u{2329}', '\u{232a}'), + ('\u{2768}', '\u{2775}'), ('\u{27c5}', '\u{27c6}'), ('\u{27e6}', + '\u{27ef}'), ('\u{2983}', '\u{2998}'), ('\u{29d8}', '\u{29db}'), + ('\u{29fc}', '\u{29fd}'), ('\u{2cf9}', '\u{2cfc}'), ('\u{2cfe}', + '\u{2cff}'), ('\u{2d70}', '\u{2d70}'), ('\u{2e00}', '\u{2e2e}'), + ('\u{2e30}', '\u{2e42}'), ('\u{3001}', '\u{3003}'), ('\u{3008}', + '\u{3011}'), ('\u{3014}', '\u{301f}'), ('\u{3030}', '\u{3030}'), + ('\u{303d}', '\u{303d}'), ('\u{30a0}', '\u{30a0}'), ('\u{30fb}', + '\u{30fb}'), ('\u{a4fe}', '\u{a4ff}'), ('\u{a60d}', '\u{a60f}'), + ('\u{a673}', '\u{a673}'), ('\u{a67e}', '\u{a67e}'), ('\u{a6f2}', + '\u{a6f7}'), ('\u{a874}', '\u{a877}'), ('\u{a8ce}', '\u{a8cf}'), + ('\u{a8f8}', '\u{a8fa}'), ('\u{a92e}', '\u{a92f}'), ('\u{a95f}', + '\u{a95f}'), ('\u{a9c1}', '\u{a9cd}'), ('\u{a9de}', '\u{a9df}'), + ('\u{aa5c}', '\u{aa5f}'), ('\u{aade}', '\u{aadf}'), ('\u{aaf0}', + '\u{aaf1}'), ('\u{abeb}', '\u{abeb}'), ('\u{fd3e}', '\u{fd3f}'), + ('\u{fe10}', '\u{fe19}'), ('\u{fe30}', '\u{fe52}'), ('\u{fe54}', + '\u{fe61}'), ('\u{fe63}', '\u{fe63}'), ('\u{fe68}', '\u{fe68}'), + ('\u{fe6a}', '\u{fe6b}'), ('\u{ff01}', '\u{ff03}'), ('\u{ff05}', + '\u{ff0a}'), ('\u{ff0c}', '\u{ff0f}'), ('\u{ff1a}', '\u{ff1b}'), + ('\u{ff1f}', '\u{ff20}'), ('\u{ff3b}', '\u{ff3d}'), ('\u{ff3f}', + '\u{ff3f}'), ('\u{ff5b}', '\u{ff5b}'), ('\u{ff5d}', '\u{ff5d}'), + ('\u{ff5f}', '\u{ff65}'), ('\u{10100}', '\u{10102}'), ('\u{1039f}', + '\u{1039f}'), ('\u{103d0}', '\u{103d0}'), ('\u{1056f}', '\u{1056f}'), + ('\u{10857}', '\u{10857}'), ('\u{1091f}', '\u{1091f}'), ('\u{1093f}', + '\u{1093f}'), ('\u{10a50}', '\u{10a58}'), ('\u{10a7f}', '\u{10a7f}'), + ('\u{10af0}', '\u{10af6}'), ('\u{10b39}', '\u{10b3f}'), ('\u{10b99}', + '\u{10b9c}'), ('\u{11047}', '\u{1104d}'), ('\u{110bb}', '\u{110bc}'), + ('\u{110be}', '\u{110c1}'), ('\u{11140}', '\u{11143}'), ('\u{11174}', + '\u{11175}'), ('\u{111c5}', '\u{111c8}'), ('\u{111cd}', '\u{111cd}'), + ('\u{11238}', '\u{1123d}'), ('\u{114c6}', '\u{114c6}'), ('\u{115c1}', + '\u{115c9}'), ('\u{11641}', '\u{11643}'), ('\u{12470}', '\u{12474}'), + ('\u{16a6e}', '\u{16a6f}'), ('\u{16af5}', '\u{16af5}'), ('\u{16b37}', + '\u{16b3b}'), ('\u{16b44}', '\u{16b44}'), ('\u{1bc9f}', '\u{1bc9f}') + ]; + + pub const Pc_table: &'static [(char, char)] = &[ + ('\u{5f}', '\u{5f}'), ('\u{203f}', '\u{2040}'), ('\u{2054}', + '\u{2054}'), ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), + ('\u{ff3f}', '\u{ff3f}') + ]; + + pub const Pd_table: &'static [(char, char)] = &[ + ('\u{2d}', '\u{2d}'), ('\u{58a}', '\u{58a}'), ('\u{5be}', '\u{5be}'), + ('\u{1400}', '\u{1400}'), ('\u{1806}', '\u{1806}'), ('\u{2010}', + '\u{2015}'), ('\u{2e17}', '\u{2e17}'), ('\u{2e1a}', '\u{2e1a}'), + ('\u{2e3a}', '\u{2e3b}'), ('\u{2e40}', '\u{2e40}'), ('\u{301c}', + '\u{301c}'), ('\u{3030}', '\u{3030}'), ('\u{30a0}', '\u{30a0}'), + ('\u{fe31}', '\u{fe32}'), ('\u{fe58}', '\u{fe58}'), ('\u{fe63}', + '\u{fe63}'), ('\u{ff0d}', '\u{ff0d}') + ]; + + pub const Pe_table: &'static [(char, char)] = &[ + ('\u{29}', '\u{29}'), ('\u{5d}', '\u{5d}'), ('\u{7d}', '\u{7d}'), + ('\u{f3b}', '\u{f3b}'), ('\u{f3d}', '\u{f3d}'), ('\u{169c}', + '\u{169c}'), ('\u{2046}', '\u{2046}'), ('\u{207e}', '\u{207e}'), + ('\u{208e}', '\u{208e}'), ('\u{2309}', '\u{2309}'), ('\u{230b}', + '\u{230b}'), ('\u{232a}', '\u{232a}'), ('\u{2769}', '\u{2769}'), + ('\u{276b}', '\u{276b}'), ('\u{276d}', '\u{276d}'), ('\u{276f}', + '\u{276f}'), ('\u{2771}', '\u{2771}'), ('\u{2773}', '\u{2773}'), + ('\u{2775}', '\u{2775}'), ('\u{27c6}', '\u{27c6}'), ('\u{27e7}', + '\u{27e7}'), ('\u{27e9}', '\u{27e9}'), ('\u{27eb}', '\u{27eb}'), + ('\u{27ed}', '\u{27ed}'), ('\u{27ef}', '\u{27ef}'), ('\u{2984}', + '\u{2984}'), ('\u{2986}', '\u{2986}'), ('\u{2988}', '\u{2988}'), + ('\u{298a}', '\u{298a}'), ('\u{298c}', '\u{298c}'), ('\u{298e}', + '\u{298e}'), ('\u{2990}', '\u{2990}'), ('\u{2992}', '\u{2992}'), + ('\u{2994}', '\u{2994}'), ('\u{2996}', '\u{2996}'), ('\u{2998}', + '\u{2998}'), ('\u{29d9}', '\u{29d9}'), ('\u{29db}', '\u{29db}'), + ('\u{29fd}', '\u{29fd}'), ('\u{2e23}', '\u{2e23}'), ('\u{2e25}', + '\u{2e25}'), ('\u{2e27}', '\u{2e27}'), ('\u{2e29}', '\u{2e29}'), + ('\u{3009}', '\u{3009}'), ('\u{300b}', '\u{300b}'), ('\u{300d}', + '\u{300d}'), ('\u{300f}', '\u{300f}'), ('\u{3011}', '\u{3011}'), + ('\u{3015}', '\u{3015}'), ('\u{3017}', '\u{3017}'), ('\u{3019}', + '\u{3019}'), ('\u{301b}', '\u{301b}'), ('\u{301e}', '\u{301f}'), + ('\u{fd3e}', '\u{fd3e}'), ('\u{fe18}', '\u{fe18}'), ('\u{fe36}', + '\u{fe36}'), ('\u{fe38}', '\u{fe38}'), ('\u{fe3a}', '\u{fe3a}'), + ('\u{fe3c}', '\u{fe3c}'), ('\u{fe3e}', '\u{fe3e}'), ('\u{fe40}', + '\u{fe40}'), ('\u{fe42}', '\u{fe42}'), ('\u{fe44}', '\u{fe44}'), + ('\u{fe48}', '\u{fe48}'), ('\u{fe5a}', '\u{fe5a}'), ('\u{fe5c}', + '\u{fe5c}'), ('\u{fe5e}', '\u{fe5e}'), ('\u{ff09}', '\u{ff09}'), + ('\u{ff3d}', '\u{ff3d}'), ('\u{ff5d}', '\u{ff5d}'), ('\u{ff60}', + '\u{ff60}'), ('\u{ff63}', '\u{ff63}') + ]; + + pub const Pf_table: &'static [(char, char)] = &[ + ('\u{bb}', '\u{bb}'), ('\u{2019}', '\u{2019}'), ('\u{201d}', + '\u{201d}'), ('\u{203a}', '\u{203a}'), ('\u{2e03}', '\u{2e03}'), + ('\u{2e05}', '\u{2e05}'), ('\u{2e0a}', '\u{2e0a}'), ('\u{2e0d}', + '\u{2e0d}'), ('\u{2e1d}', '\u{2e1d}'), ('\u{2e21}', '\u{2e21}') + ]; + + pub const Pi_table: &'static [(char, char)] = &[ + ('\u{ab}', '\u{ab}'), ('\u{2018}', '\u{2018}'), ('\u{201b}', + '\u{201c}'), ('\u{201f}', '\u{201f}'), ('\u{2039}', '\u{2039}'), + ('\u{2e02}', '\u{2e02}'), ('\u{2e04}', '\u{2e04}'), ('\u{2e09}', + '\u{2e09}'), ('\u{2e0c}', '\u{2e0c}'), ('\u{2e1c}', '\u{2e1c}'), + ('\u{2e20}', '\u{2e20}') + ]; + + pub const Po_table: &'static [(char, char)] = &[ + ('\u{21}', '\u{23}'), ('\u{25}', '\u{27}'), ('\u{2a}', '\u{2a}'), + ('\u{2c}', '\u{2c}'), ('\u{2e}', '\u{2f}'), ('\u{3a}', '\u{3b}'), + ('\u{3f}', '\u{40}'), ('\u{5c}', '\u{5c}'), ('\u{a1}', '\u{a1}'), + ('\u{a7}', '\u{a7}'), ('\u{b6}', '\u{b7}'), ('\u{bf}', '\u{bf}'), + ('\u{37e}', '\u{37e}'), ('\u{387}', '\u{387}'), ('\u{55a}', '\u{55f}'), + ('\u{589}', '\u{589}'), ('\u{5c0}', '\u{5c0}'), ('\u{5c3}', '\u{5c3}'), + ('\u{5c6}', '\u{5c6}'), ('\u{5f3}', '\u{5f4}'), ('\u{609}', '\u{60a}'), + ('\u{60c}', '\u{60d}'), ('\u{61b}', '\u{61b}'), ('\u{61e}', '\u{61f}'), + ('\u{66a}', '\u{66d}'), ('\u{6d4}', '\u{6d4}'), ('\u{700}', '\u{70d}'), + ('\u{7f7}', '\u{7f9}'), ('\u{830}', '\u{83e}'), ('\u{85e}', '\u{85e}'), + ('\u{964}', '\u{965}'), ('\u{970}', '\u{970}'), ('\u{af0}', '\u{af0}'), + ('\u{df4}', '\u{df4}'), ('\u{e4f}', '\u{e4f}'), ('\u{e5a}', '\u{e5b}'), + ('\u{f04}', '\u{f12}'), ('\u{f14}', '\u{f14}'), ('\u{f85}', '\u{f85}'), + ('\u{fd0}', '\u{fd4}'), ('\u{fd9}', '\u{fda}'), ('\u{104a}', + '\u{104f}'), ('\u{10fb}', '\u{10fb}'), ('\u{1360}', '\u{1368}'), + ('\u{166d}', '\u{166e}'), ('\u{16eb}', '\u{16ed}'), ('\u{1735}', + '\u{1736}'), ('\u{17d4}', '\u{17d6}'), ('\u{17d8}', '\u{17da}'), + ('\u{1800}', '\u{1805}'), ('\u{1807}', '\u{180a}'), ('\u{1944}', + '\u{1945}'), ('\u{1a1e}', '\u{1a1f}'), ('\u{1aa0}', '\u{1aa6}'), + ('\u{1aa8}', '\u{1aad}'), ('\u{1b5a}', '\u{1b60}'), ('\u{1bfc}', + '\u{1bff}'), ('\u{1c3b}', '\u{1c3f}'), ('\u{1c7e}', '\u{1c7f}'), + ('\u{1cc0}', '\u{1cc7}'), ('\u{1cd3}', '\u{1cd3}'), ('\u{2016}', + '\u{2017}'), ('\u{2020}', '\u{2027}'), ('\u{2030}', '\u{2038}'), + ('\u{203b}', '\u{203e}'), ('\u{2041}', '\u{2043}'), ('\u{2047}', + '\u{2051}'), ('\u{2053}', '\u{2053}'), ('\u{2055}', '\u{205e}'), + ('\u{2cf9}', '\u{2cfc}'), ('\u{2cfe}', '\u{2cff}'), ('\u{2d70}', + '\u{2d70}'), ('\u{2e00}', '\u{2e01}'), ('\u{2e06}', '\u{2e08}'), + ('\u{2e0b}', '\u{2e0b}'), ('\u{2e0e}', '\u{2e16}'), ('\u{2e18}', + '\u{2e19}'), ('\u{2e1b}', '\u{2e1b}'), ('\u{2e1e}', '\u{2e1f}'), + ('\u{2e2a}', '\u{2e2e}'), ('\u{2e30}', '\u{2e39}'), ('\u{2e3c}', + '\u{2e3f}'), ('\u{2e41}', '\u{2e41}'), ('\u{3001}', '\u{3003}'), + ('\u{303d}', '\u{303d}'), ('\u{30fb}', '\u{30fb}'), ('\u{a4fe}', + '\u{a4ff}'), ('\u{a60d}', '\u{a60f}'), ('\u{a673}', '\u{a673}'), + ('\u{a67e}', '\u{a67e}'), ('\u{a6f2}', '\u{a6f7}'), ('\u{a874}', + '\u{a877}'), ('\u{a8ce}', '\u{a8cf}'), ('\u{a8f8}', '\u{a8fa}'), + ('\u{a92e}', '\u{a92f}'), ('\u{a95f}', '\u{a95f}'), ('\u{a9c1}', + '\u{a9cd}'), ('\u{a9de}', '\u{a9df}'), ('\u{aa5c}', '\u{aa5f}'), + ('\u{aade}', '\u{aadf}'), ('\u{aaf0}', '\u{aaf1}'), ('\u{abeb}', + '\u{abeb}'), ('\u{fe10}', '\u{fe16}'), ('\u{fe19}', '\u{fe19}'), + ('\u{fe30}', '\u{fe30}'), ('\u{fe45}', '\u{fe46}'), ('\u{fe49}', + '\u{fe4c}'), ('\u{fe50}', '\u{fe52}'), ('\u{fe54}', '\u{fe57}'), + ('\u{fe5f}', '\u{fe61}'), ('\u{fe68}', '\u{fe68}'), ('\u{fe6a}', + '\u{fe6b}'), ('\u{ff01}', '\u{ff03}'), ('\u{ff05}', '\u{ff07}'), + ('\u{ff0a}', '\u{ff0a}'), ('\u{ff0c}', '\u{ff0c}'), ('\u{ff0e}', + '\u{ff0f}'), ('\u{ff1a}', '\u{ff1b}'), ('\u{ff1f}', '\u{ff20}'), + ('\u{ff3c}', '\u{ff3c}'), ('\u{ff61}', '\u{ff61}'), ('\u{ff64}', + '\u{ff65}'), ('\u{10100}', '\u{10102}'), ('\u{1039f}', '\u{1039f}'), + ('\u{103d0}', '\u{103d0}'), ('\u{1056f}', '\u{1056f}'), ('\u{10857}', + '\u{10857}'), ('\u{1091f}', '\u{1091f}'), ('\u{1093f}', '\u{1093f}'), + ('\u{10a50}', '\u{10a58}'), ('\u{10a7f}', '\u{10a7f}'), ('\u{10af0}', + '\u{10af6}'), ('\u{10b39}', '\u{10b3f}'), ('\u{10b99}', '\u{10b9c}'), + ('\u{11047}', '\u{1104d}'), ('\u{110bb}', '\u{110bc}'), ('\u{110be}', + '\u{110c1}'), ('\u{11140}', '\u{11143}'), ('\u{11174}', '\u{11175}'), + ('\u{111c5}', '\u{111c8}'), ('\u{111cd}', '\u{111cd}'), ('\u{11238}', + '\u{1123d}'), ('\u{114c6}', '\u{114c6}'), ('\u{115c1}', '\u{115c9}'), + ('\u{11641}', '\u{11643}'), ('\u{12470}', '\u{12474}'), ('\u{16a6e}', + '\u{16a6f}'), ('\u{16af5}', '\u{16af5}'), ('\u{16b37}', '\u{16b3b}'), + ('\u{16b44}', '\u{16b44}'), ('\u{1bc9f}', '\u{1bc9f}') + ]; + + pub const Ps_table: &'static [(char, char)] = &[ + ('\u{28}', '\u{28}'), ('\u{5b}', '\u{5b}'), ('\u{7b}', '\u{7b}'), + ('\u{f3a}', '\u{f3a}'), ('\u{f3c}', '\u{f3c}'), ('\u{169b}', + '\u{169b}'), ('\u{201a}', '\u{201a}'), ('\u{201e}', '\u{201e}'), + ('\u{2045}', '\u{2045}'), ('\u{207d}', '\u{207d}'), ('\u{208d}', + '\u{208d}'), ('\u{2308}', '\u{2308}'), ('\u{230a}', '\u{230a}'), + ('\u{2329}', '\u{2329}'), ('\u{2768}', '\u{2768}'), ('\u{276a}', + '\u{276a}'), ('\u{276c}', '\u{276c}'), ('\u{276e}', '\u{276e}'), + ('\u{2770}', '\u{2770}'), ('\u{2772}', '\u{2772}'), ('\u{2774}', + '\u{2774}'), ('\u{27c5}', '\u{27c5}'), ('\u{27e6}', '\u{27e6}'), + ('\u{27e8}', '\u{27e8}'), ('\u{27ea}', '\u{27ea}'), ('\u{27ec}', + '\u{27ec}'), ('\u{27ee}', '\u{27ee}'), ('\u{2983}', '\u{2983}'), + ('\u{2985}', '\u{2985}'), ('\u{2987}', '\u{2987}'), ('\u{2989}', + '\u{2989}'), ('\u{298b}', '\u{298b}'), ('\u{298d}', '\u{298d}'), + ('\u{298f}', '\u{298f}'), ('\u{2991}', '\u{2991}'), ('\u{2993}', + '\u{2993}'), ('\u{2995}', '\u{2995}'), ('\u{2997}', '\u{2997}'), + ('\u{29d8}', '\u{29d8}'), ('\u{29da}', '\u{29da}'), ('\u{29fc}', + '\u{29fc}'), ('\u{2e22}', '\u{2e22}'), ('\u{2e24}', '\u{2e24}'), + ('\u{2e26}', '\u{2e26}'), ('\u{2e28}', '\u{2e28}'), ('\u{2e42}', + '\u{2e42}'), ('\u{3008}', '\u{3008}'), ('\u{300a}', '\u{300a}'), + ('\u{300c}', '\u{300c}'), ('\u{300e}', '\u{300e}'), ('\u{3010}', + '\u{3010}'), ('\u{3014}', '\u{3014}'), ('\u{3016}', '\u{3016}'), + ('\u{3018}', '\u{3018}'), ('\u{301a}', '\u{301a}'), ('\u{301d}', + '\u{301d}'), ('\u{fd3f}', '\u{fd3f}'), ('\u{fe17}', '\u{fe17}'), + ('\u{fe35}', '\u{fe35}'), ('\u{fe37}', '\u{fe37}'), ('\u{fe39}', + '\u{fe39}'), ('\u{fe3b}', '\u{fe3b}'), ('\u{fe3d}', '\u{fe3d}'), + ('\u{fe3f}', '\u{fe3f}'), ('\u{fe41}', '\u{fe41}'), ('\u{fe43}', + '\u{fe43}'), ('\u{fe47}', '\u{fe47}'), ('\u{fe59}', '\u{fe59}'), + ('\u{fe5b}', '\u{fe5b}'), ('\u{fe5d}', '\u{fe5d}'), ('\u{ff08}', + '\u{ff08}'), ('\u{ff3b}', '\u{ff3b}'), ('\u{ff5b}', '\u{ff5b}'), + ('\u{ff5f}', '\u{ff5f}'), ('\u{ff62}', '\u{ff62}') + ]; + + pub const S_table: &'static [(char, char)] = &[ + ('\u{24}', '\u{24}'), ('\u{2b}', '\u{2b}'), ('\u{3c}', '\u{3e}'), + ('\u{5e}', '\u{5e}'), ('\u{60}', '\u{60}'), ('\u{7c}', '\u{7c}'), + ('\u{7e}', '\u{7e}'), ('\u{a2}', '\u{a6}'), ('\u{a8}', '\u{a9}'), + ('\u{ac}', '\u{ac}'), ('\u{ae}', '\u{b1}'), ('\u{b4}', '\u{b4}'), + ('\u{b8}', '\u{b8}'), ('\u{d7}', '\u{d7}'), ('\u{f7}', '\u{f7}'), + ('\u{2c2}', '\u{2c5}'), ('\u{2d2}', '\u{2df}'), ('\u{2e5}', '\u{2eb}'), + ('\u{2ed}', '\u{2ed}'), ('\u{2ef}', '\u{2ff}'), ('\u{375}', '\u{375}'), + ('\u{384}', '\u{385}'), ('\u{3f6}', '\u{3f6}'), ('\u{482}', '\u{482}'), + ('\u{58d}', '\u{58f}'), ('\u{606}', '\u{608}'), ('\u{60b}', '\u{60b}'), + ('\u{60e}', '\u{60f}'), ('\u{6de}', '\u{6de}'), ('\u{6e9}', '\u{6e9}'), + ('\u{6fd}', '\u{6fe}'), ('\u{7f6}', '\u{7f6}'), ('\u{9f2}', '\u{9f3}'), + ('\u{9fa}', '\u{9fb}'), ('\u{af1}', '\u{af1}'), ('\u{b70}', '\u{b70}'), + ('\u{bf3}', '\u{bfa}'), ('\u{c7f}', '\u{c7f}'), ('\u{d79}', '\u{d79}'), + ('\u{e3f}', '\u{e3f}'), ('\u{f01}', '\u{f03}'), ('\u{f13}', '\u{f13}'), + ('\u{f15}', '\u{f17}'), ('\u{f1a}', '\u{f1f}'), ('\u{f34}', '\u{f34}'), + ('\u{f36}', '\u{f36}'), ('\u{f38}', '\u{f38}'), ('\u{fbe}', '\u{fc5}'), + ('\u{fc7}', '\u{fcc}'), ('\u{fce}', '\u{fcf}'), ('\u{fd5}', '\u{fd8}'), + ('\u{109e}', '\u{109f}'), ('\u{1390}', '\u{1399}'), ('\u{17db}', + '\u{17db}'), ('\u{1940}', '\u{1940}'), ('\u{19de}', '\u{19ff}'), + ('\u{1b61}', '\u{1b6a}'), ('\u{1b74}', '\u{1b7c}'), ('\u{1fbd}', + '\u{1fbd}'), ('\u{1fbf}', '\u{1fc1}'), ('\u{1fcd}', '\u{1fcf}'), + ('\u{1fdd}', '\u{1fdf}'), ('\u{1fed}', '\u{1fef}'), ('\u{1ffd}', + '\u{1ffe}'), ('\u{2044}', '\u{2044}'), ('\u{2052}', '\u{2052}'), + ('\u{207a}', '\u{207c}'), ('\u{208a}', '\u{208c}'), ('\u{20a0}', + '\u{20bd}'), ('\u{2100}', '\u{2101}'), ('\u{2103}', '\u{2106}'), + ('\u{2108}', '\u{2109}'), ('\u{2114}', '\u{2114}'), ('\u{2116}', + '\u{2118}'), ('\u{211e}', '\u{2123}'), ('\u{2125}', '\u{2125}'), + ('\u{2127}', '\u{2127}'), ('\u{2129}', '\u{2129}'), ('\u{212e}', + '\u{212e}'), ('\u{213a}', '\u{213b}'), ('\u{2140}', '\u{2144}'), + ('\u{214a}', '\u{214d}'), ('\u{214f}', '\u{214f}'), ('\u{2190}', + '\u{2307}'), ('\u{230c}', '\u{2328}'), ('\u{232b}', '\u{23fa}'), + ('\u{2400}', '\u{2426}'), ('\u{2440}', '\u{244a}'), ('\u{249c}', + '\u{24e9}'), ('\u{2500}', '\u{2767}'), ('\u{2794}', '\u{27c4}'), + ('\u{27c7}', '\u{27e5}'), ('\u{27f0}', '\u{2982}'), ('\u{2999}', + '\u{29d7}'), ('\u{29dc}', '\u{29fb}'), ('\u{29fe}', '\u{2b73}'), + ('\u{2b76}', '\u{2b95}'), ('\u{2b98}', '\u{2bb9}'), ('\u{2bbd}', + '\u{2bc8}'), ('\u{2bca}', '\u{2bd1}'), ('\u{2ce5}', '\u{2cea}'), + ('\u{2e80}', '\u{2e99}'), ('\u{2e9b}', '\u{2ef3}'), ('\u{2f00}', + '\u{2fd5}'), ('\u{2ff0}', '\u{2ffb}'), ('\u{3004}', '\u{3004}'), + ('\u{3012}', '\u{3013}'), ('\u{3020}', '\u{3020}'), ('\u{3036}', + '\u{3037}'), ('\u{303e}', '\u{303f}'), ('\u{309b}', '\u{309c}'), + ('\u{3190}', '\u{3191}'), ('\u{3196}', '\u{319f}'), ('\u{31c0}', + '\u{31e3}'), ('\u{3200}', '\u{321e}'), ('\u{322a}', '\u{3247}'), + ('\u{3250}', '\u{3250}'), ('\u{3260}', '\u{327f}'), ('\u{328a}', + '\u{32b0}'), ('\u{32c0}', '\u{32fe}'), ('\u{3300}', '\u{33ff}'), + ('\u{4dc0}', '\u{4dff}'), ('\u{a490}', '\u{a4c6}'), ('\u{a700}', + '\u{a716}'), ('\u{a720}', '\u{a721}'), ('\u{a789}', '\u{a78a}'), + ('\u{a828}', '\u{a82b}'), ('\u{a836}', '\u{a839}'), ('\u{aa77}', + '\u{aa79}'), ('\u{ab5b}', '\u{ab5b}'), ('\u{fb29}', '\u{fb29}'), + ('\u{fbb2}', '\u{fbc1}'), ('\u{fdfc}', '\u{fdfd}'), ('\u{fe62}', + '\u{fe62}'), ('\u{fe64}', '\u{fe66}'), ('\u{fe69}', '\u{fe69}'), + ('\u{ff04}', '\u{ff04}'), ('\u{ff0b}', '\u{ff0b}'), ('\u{ff1c}', + '\u{ff1e}'), ('\u{ff3e}', '\u{ff3e}'), ('\u{ff40}', '\u{ff40}'), + ('\u{ff5c}', '\u{ff5c}'), ('\u{ff5e}', '\u{ff5e}'), ('\u{ffe0}', + '\u{ffe6}'), ('\u{ffe8}', '\u{ffee}'), ('\u{fffc}', '\u{fffd}'), + ('\u{10137}', '\u{1013f}'), ('\u{10179}', '\u{10189}'), ('\u{1018c}', + '\u{1018c}'), ('\u{10190}', '\u{1019b}'), ('\u{101a0}', '\u{101a0}'), + ('\u{101d0}', '\u{101fc}'), ('\u{10877}', '\u{10878}'), ('\u{10ac8}', + '\u{10ac8}'), ('\u{16b3c}', '\u{16b3f}'), ('\u{16b45}', '\u{16b45}'), + ('\u{1bc9c}', '\u{1bc9c}'), ('\u{1d000}', '\u{1d0f5}'), ('\u{1d100}', + '\u{1d126}'), ('\u{1d129}', '\u{1d164}'), ('\u{1d16a}', '\u{1d16c}'), + ('\u{1d183}', '\u{1d184}'), ('\u{1d18c}', '\u{1d1a9}'), ('\u{1d1ae}', + '\u{1d1dd}'), ('\u{1d200}', '\u{1d241}'), ('\u{1d245}', '\u{1d245}'), + ('\u{1d300}', '\u{1d356}'), ('\u{1d6c1}', '\u{1d6c1}'), ('\u{1d6db}', + '\u{1d6db}'), ('\u{1d6fb}', '\u{1d6fb}'), ('\u{1d715}', '\u{1d715}'), + ('\u{1d735}', '\u{1d735}'), ('\u{1d74f}', '\u{1d74f}'), ('\u{1d76f}', + '\u{1d76f}'), ('\u{1d789}', '\u{1d789}'), ('\u{1d7a9}', '\u{1d7a9}'), + ('\u{1d7c3}', '\u{1d7c3}'), ('\u{1eef0}', '\u{1eef1}'), ('\u{1f000}', + '\u{1f02b}'), ('\u{1f030}', '\u{1f093}'), ('\u{1f0a0}', '\u{1f0ae}'), + ('\u{1f0b1}', '\u{1f0bf}'), ('\u{1f0c1}', '\u{1f0cf}'), ('\u{1f0d1}', + '\u{1f0f5}'), ('\u{1f110}', '\u{1f12e}'), ('\u{1f130}', '\u{1f16b}'), + ('\u{1f170}', '\u{1f19a}'), ('\u{1f1e6}', '\u{1f202}'), ('\u{1f210}', + '\u{1f23a}'), ('\u{1f240}', '\u{1f248}'), ('\u{1f250}', '\u{1f251}'), + ('\u{1f300}', '\u{1f32c}'), ('\u{1f330}', '\u{1f37d}'), ('\u{1f380}', + '\u{1f3ce}'), ('\u{1f3d4}', '\u{1f3f7}'), ('\u{1f400}', '\u{1f4fe}'), + ('\u{1f500}', '\u{1f54a}'), ('\u{1f550}', '\u{1f579}'), ('\u{1f57b}', + '\u{1f5a3}'), ('\u{1f5a5}', '\u{1f642}'), ('\u{1f645}', '\u{1f6cf}'), + ('\u{1f6e0}', '\u{1f6ec}'), ('\u{1f6f0}', '\u{1f6f3}'), ('\u{1f700}', + '\u{1f773}'), ('\u{1f780}', '\u{1f7d4}'), ('\u{1f800}', '\u{1f80b}'), + ('\u{1f810}', '\u{1f847}'), ('\u{1f850}', '\u{1f859}'), ('\u{1f860}', + '\u{1f887}'), ('\u{1f890}', '\u{1f8ad}') + ]; + + pub const Sc_table: &'static [(char, char)] = &[ + ('\u{24}', '\u{24}'), ('\u{a2}', '\u{a5}'), ('\u{58f}', '\u{58f}'), + ('\u{60b}', '\u{60b}'), ('\u{9f2}', '\u{9f3}'), ('\u{9fb}', '\u{9fb}'), + ('\u{af1}', '\u{af1}'), ('\u{bf9}', '\u{bf9}'), ('\u{e3f}', '\u{e3f}'), + ('\u{17db}', '\u{17db}'), ('\u{20a0}', '\u{20bd}'), ('\u{a838}', + '\u{a838}'), ('\u{fdfc}', '\u{fdfc}'), ('\u{fe69}', '\u{fe69}'), + ('\u{ff04}', '\u{ff04}'), ('\u{ffe0}', '\u{ffe1}'), ('\u{ffe5}', + '\u{ffe6}') + ]; + + pub const Sk_table: &'static [(char, char)] = &[ + ('\u{5e}', '\u{5e}'), ('\u{60}', '\u{60}'), ('\u{a8}', '\u{a8}'), + ('\u{af}', '\u{af}'), ('\u{b4}', '\u{b4}'), ('\u{b8}', '\u{b8}'), + ('\u{2c2}', '\u{2c5}'), ('\u{2d2}', '\u{2df}'), ('\u{2e5}', '\u{2eb}'), + ('\u{2ed}', '\u{2ed}'), ('\u{2ef}', '\u{2ff}'), ('\u{375}', '\u{375}'), + ('\u{384}', '\u{385}'), ('\u{1fbd}', '\u{1fbd}'), ('\u{1fbf}', + '\u{1fc1}'), ('\u{1fcd}', '\u{1fcf}'), ('\u{1fdd}', '\u{1fdf}'), + ('\u{1fed}', '\u{1fef}'), ('\u{1ffd}', '\u{1ffe}'), ('\u{309b}', + '\u{309c}'), ('\u{a700}', '\u{a716}'), ('\u{a720}', '\u{a721}'), + ('\u{a789}', '\u{a78a}'), ('\u{ab5b}', '\u{ab5b}'), ('\u{fbb2}', + '\u{fbc1}'), ('\u{ff3e}', '\u{ff3e}'), ('\u{ff40}', '\u{ff40}'), + ('\u{ffe3}', '\u{ffe3}') + ]; + + pub const Sm_table: &'static [(char, char)] = &[ + ('\u{2b}', '\u{2b}'), ('\u{3c}', '\u{3e}'), ('\u{7c}', '\u{7c}'), + ('\u{7e}', '\u{7e}'), ('\u{ac}', '\u{ac}'), ('\u{b1}', '\u{b1}'), + ('\u{d7}', '\u{d7}'), ('\u{f7}', '\u{f7}'), ('\u{3f6}', '\u{3f6}'), + ('\u{606}', '\u{608}'), ('\u{2044}', '\u{2044}'), ('\u{2052}', + '\u{2052}'), ('\u{207a}', '\u{207c}'), ('\u{208a}', '\u{208c}'), + ('\u{2118}', '\u{2118}'), ('\u{2140}', '\u{2144}'), ('\u{214b}', + '\u{214b}'), ('\u{2190}', '\u{2194}'), ('\u{219a}', '\u{219b}'), + ('\u{21a0}', '\u{21a0}'), ('\u{21a3}', '\u{21a3}'), ('\u{21a6}', + '\u{21a6}'), ('\u{21ae}', '\u{21ae}'), ('\u{21ce}', '\u{21cf}'), + ('\u{21d2}', '\u{21d2}'), ('\u{21d4}', '\u{21d4}'), ('\u{21f4}', + '\u{22ff}'), ('\u{2320}', '\u{2321}'), ('\u{237c}', '\u{237c}'), + ('\u{239b}', '\u{23b3}'), ('\u{23dc}', '\u{23e1}'), ('\u{25b7}', + '\u{25b7}'), ('\u{25c1}', '\u{25c1}'), ('\u{25f8}', '\u{25ff}'), + ('\u{266f}', '\u{266f}'), ('\u{27c0}', '\u{27c4}'), ('\u{27c7}', + '\u{27e5}'), ('\u{27f0}', '\u{27ff}'), ('\u{2900}', '\u{2982}'), + ('\u{2999}', '\u{29d7}'), ('\u{29dc}', '\u{29fb}'), ('\u{29fe}', + '\u{2aff}'), ('\u{2b30}', '\u{2b44}'), ('\u{2b47}', '\u{2b4c}'), + ('\u{fb29}', '\u{fb29}'), ('\u{fe62}', '\u{fe62}'), ('\u{fe64}', + '\u{fe66}'), ('\u{ff0b}', '\u{ff0b}'), ('\u{ff1c}', '\u{ff1e}'), + ('\u{ff5c}', '\u{ff5c}'), ('\u{ff5e}', '\u{ff5e}'), ('\u{ffe2}', + '\u{ffe2}'), ('\u{ffe9}', '\u{ffec}'), ('\u{1d6c1}', '\u{1d6c1}'), + ('\u{1d6db}', '\u{1d6db}'), ('\u{1d6fb}', '\u{1d6fb}'), ('\u{1d715}', + '\u{1d715}'), ('\u{1d735}', '\u{1d735}'), ('\u{1d74f}', '\u{1d74f}'), + ('\u{1d76f}', '\u{1d76f}'), ('\u{1d789}', '\u{1d789}'), ('\u{1d7a9}', + '\u{1d7a9}'), ('\u{1d7c3}', '\u{1d7c3}'), ('\u{1eef0}', '\u{1eef1}') + ]; + + pub const So_table: &'static [(char, char)] = &[ + ('\u{a6}', '\u{a6}'), ('\u{a9}', '\u{a9}'), ('\u{ae}', '\u{ae}'), + ('\u{b0}', '\u{b0}'), ('\u{482}', '\u{482}'), ('\u{58d}', '\u{58e}'), + ('\u{60e}', '\u{60f}'), ('\u{6de}', '\u{6de}'), ('\u{6e9}', '\u{6e9}'), + ('\u{6fd}', '\u{6fe}'), ('\u{7f6}', '\u{7f6}'), ('\u{9fa}', '\u{9fa}'), + ('\u{b70}', '\u{b70}'), ('\u{bf3}', '\u{bf8}'), ('\u{bfa}', '\u{bfa}'), + ('\u{c7f}', '\u{c7f}'), ('\u{d79}', '\u{d79}'), ('\u{f01}', '\u{f03}'), + ('\u{f13}', '\u{f13}'), ('\u{f15}', '\u{f17}'), ('\u{f1a}', '\u{f1f}'), + ('\u{f34}', '\u{f34}'), ('\u{f36}', '\u{f36}'), ('\u{f38}', '\u{f38}'), + ('\u{fbe}', '\u{fc5}'), ('\u{fc7}', '\u{fcc}'), ('\u{fce}', '\u{fcf}'), + ('\u{fd5}', '\u{fd8}'), ('\u{109e}', '\u{109f}'), ('\u{1390}', + '\u{1399}'), ('\u{1940}', '\u{1940}'), ('\u{19de}', '\u{19ff}'), + ('\u{1b61}', '\u{1b6a}'), ('\u{1b74}', '\u{1b7c}'), ('\u{2100}', + '\u{2101}'), ('\u{2103}', '\u{2106}'), ('\u{2108}', '\u{2109}'), + ('\u{2114}', '\u{2114}'), ('\u{2116}', '\u{2117}'), ('\u{211e}', + '\u{2123}'), ('\u{2125}', '\u{2125}'), ('\u{2127}', '\u{2127}'), + ('\u{2129}', '\u{2129}'), ('\u{212e}', '\u{212e}'), ('\u{213a}', + '\u{213b}'), ('\u{214a}', '\u{214a}'), ('\u{214c}', '\u{214d}'), + ('\u{214f}', '\u{214f}'), ('\u{2195}', '\u{2199}'), ('\u{219c}', + '\u{219f}'), ('\u{21a1}', '\u{21a2}'), ('\u{21a4}', '\u{21a5}'), + ('\u{21a7}', '\u{21ad}'), ('\u{21af}', '\u{21cd}'), ('\u{21d0}', + '\u{21d1}'), ('\u{21d3}', '\u{21d3}'), ('\u{21d5}', '\u{21f3}'), + ('\u{2300}', '\u{2307}'), ('\u{230c}', '\u{231f}'), ('\u{2322}', + '\u{2328}'), ('\u{232b}', '\u{237b}'), ('\u{237d}', '\u{239a}'), + ('\u{23b4}', '\u{23db}'), ('\u{23e2}', '\u{23fa}'), ('\u{2400}', + '\u{2426}'), ('\u{2440}', '\u{244a}'), ('\u{249c}', '\u{24e9}'), + ('\u{2500}', '\u{25b6}'), ('\u{25b8}', '\u{25c0}'), ('\u{25c2}', + '\u{25f7}'), ('\u{2600}', '\u{266e}'), ('\u{2670}', '\u{2767}'), + ('\u{2794}', '\u{27bf}'), ('\u{2800}', '\u{28ff}'), ('\u{2b00}', + '\u{2b2f}'), ('\u{2b45}', '\u{2b46}'), ('\u{2b4d}', '\u{2b73}'), + ('\u{2b76}', '\u{2b95}'), ('\u{2b98}', '\u{2bb9}'), ('\u{2bbd}', + '\u{2bc8}'), ('\u{2bca}', '\u{2bd1}'), ('\u{2ce5}', '\u{2cea}'), + ('\u{2e80}', '\u{2e99}'), ('\u{2e9b}', '\u{2ef3}'), ('\u{2f00}', + '\u{2fd5}'), ('\u{2ff0}', '\u{2ffb}'), ('\u{3004}', '\u{3004}'), + ('\u{3012}', '\u{3013}'), ('\u{3020}', '\u{3020}'), ('\u{3036}', + '\u{3037}'), ('\u{303e}', '\u{303f}'), ('\u{3190}', '\u{3191}'), + ('\u{3196}', '\u{319f}'), ('\u{31c0}', '\u{31e3}'), ('\u{3200}', + '\u{321e}'), ('\u{322a}', '\u{3247}'), ('\u{3250}', '\u{3250}'), + ('\u{3260}', '\u{327f}'), ('\u{328a}', '\u{32b0}'), ('\u{32c0}', + '\u{32fe}'), ('\u{3300}', '\u{33ff}'), ('\u{4dc0}', '\u{4dff}'), + ('\u{a490}', '\u{a4c6}'), ('\u{a828}', '\u{a82b}'), ('\u{a836}', + '\u{a837}'), ('\u{a839}', '\u{a839}'), ('\u{aa77}', '\u{aa79}'), + ('\u{fdfd}', '\u{fdfd}'), ('\u{ffe4}', '\u{ffe4}'), ('\u{ffe8}', + '\u{ffe8}'), ('\u{ffed}', '\u{ffee}'), ('\u{fffc}', '\u{fffd}'), + ('\u{10137}', '\u{1013f}'), ('\u{10179}', '\u{10189}'), ('\u{1018c}', + '\u{1018c}'), ('\u{10190}', '\u{1019b}'), ('\u{101a0}', '\u{101a0}'), + ('\u{101d0}', '\u{101fc}'), ('\u{10877}', '\u{10878}'), ('\u{10ac8}', + '\u{10ac8}'), ('\u{16b3c}', '\u{16b3f}'), ('\u{16b45}', '\u{16b45}'), + ('\u{1bc9c}', '\u{1bc9c}'), ('\u{1d000}', '\u{1d0f5}'), ('\u{1d100}', + '\u{1d126}'), ('\u{1d129}', '\u{1d164}'), ('\u{1d16a}', '\u{1d16c}'), + ('\u{1d183}', '\u{1d184}'), ('\u{1d18c}', '\u{1d1a9}'), ('\u{1d1ae}', + '\u{1d1dd}'), ('\u{1d200}', '\u{1d241}'), ('\u{1d245}', '\u{1d245}'), + ('\u{1d300}', '\u{1d356}'), ('\u{1f000}', '\u{1f02b}'), ('\u{1f030}', + '\u{1f093}'), ('\u{1f0a0}', '\u{1f0ae}'), ('\u{1f0b1}', '\u{1f0bf}'), + ('\u{1f0c1}', '\u{1f0cf}'), ('\u{1f0d1}', '\u{1f0f5}'), ('\u{1f110}', + '\u{1f12e}'), ('\u{1f130}', '\u{1f16b}'), ('\u{1f170}', '\u{1f19a}'), + ('\u{1f1e6}', '\u{1f202}'), ('\u{1f210}', '\u{1f23a}'), ('\u{1f240}', + '\u{1f248}'), ('\u{1f250}', '\u{1f251}'), ('\u{1f300}', '\u{1f32c}'), + ('\u{1f330}', '\u{1f37d}'), ('\u{1f380}', '\u{1f3ce}'), ('\u{1f3d4}', + '\u{1f3f7}'), ('\u{1f400}', '\u{1f4fe}'), ('\u{1f500}', '\u{1f54a}'), + ('\u{1f550}', '\u{1f579}'), ('\u{1f57b}', '\u{1f5a3}'), ('\u{1f5a5}', + '\u{1f642}'), ('\u{1f645}', '\u{1f6cf}'), ('\u{1f6e0}', '\u{1f6ec}'), + ('\u{1f6f0}', '\u{1f6f3}'), ('\u{1f700}', '\u{1f773}'), ('\u{1f780}', + '\u{1f7d4}'), ('\u{1f800}', '\u{1f80b}'), ('\u{1f810}', '\u{1f847}'), + ('\u{1f850}', '\u{1f859}'), ('\u{1f860}', '\u{1f887}'), ('\u{1f890}', + '\u{1f8ad}') + ]; + + pub const Z_table: &'static [(char, char)] = &[ + ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', + '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}') + ]; + + pub const Zl_table: &'static [(char, char)] = &[ + ('\u{2028}', '\u{2028}') + ]; + + pub const Zp_table: &'static [(char, char)] = &[ + ('\u{2029}', '\u{2029}') + ]; + + pub const Zs_table: &'static [(char, char)] = &[ + ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', + '\u{205f}'), ('\u{3000}', '\u{3000}') + ]; + +} + +pub mod derived_property { + pub const Alphabetic_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), + ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), + ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), + ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), + ('\u{345}', '\u{345}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), + ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), + ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), + ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), + ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), + ('\u{5b0}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), + ('\u{5f0}', '\u{5f2}'), ('\u{610}', '\u{61a}'), ('\u{620}', '\u{657}'), + ('\u{659}', '\u{65f}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), + ('\u{6e1}', '\u{6e8}'), ('\u{6ed}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), + ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{73f}'), ('\u{74d}', '\u{7b1}'), + ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), + ('\u{800}', '\u{817}'), ('\u{81a}', '\u{82c}'), ('\u{840}', '\u{858}'), + ('\u{8a0}', '\u{8b2}'), ('\u{8e4}', '\u{8e9}'), ('\u{8f0}', '\u{93b}'), + ('\u{93d}', '\u{94c}'), ('\u{94e}', '\u{950}'), ('\u{955}', '\u{963}'), + ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), + ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), + ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), + ('\u{9cb}', '\u{9cc}'), ('\u{9ce}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), + ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9f0}', '\u{9f1}'), + ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), + ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), + ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3e}', '\u{a42}'), + ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4c}'), ('\u{a51}', '\u{a51}'), + ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a70}', '\u{a75}'), + ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), + ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), + ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), + ('\u{acb}', '\u{acc}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), + ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), + ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), + ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b44}'), ('\u{b47}', '\u{b48}'), + ('\u{b4b}', '\u{b4c}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), + ('\u{b5f}', '\u{b63}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), + ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), + ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), + ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), + ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcc}'), + ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{c00}', '\u{c03}'), + ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), + ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4c}'), ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c59}'), + ('\u{c60}', '\u{c63}'), ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), + ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), + ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), + ('\u{cca}', '\u{ccc}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), + ('\u{ce0}', '\u{ce3}'), ('\u{cf1}', '\u{cf2}'), ('\u{d01}', '\u{d03}'), + ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), + ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4c}'), + ('\u{d4e}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), ('\u{d60}', '\u{d63}'), + ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), + ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), + ('\u{dc0}', '\u{dc6}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), + ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), + ('\u{e40}', '\u{e46}'), ('\u{e4d}', '\u{e4d}'), ('\u{e81}', '\u{e82}'), + ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), + ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), + ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), + ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), + ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{ecd}', '\u{ecd}'), + ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), + ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f81}'), ('\u{f88}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), ('\u{1000}', '\u{1036}'), ('\u{1038}', + '\u{1038}'), ('\u{103b}', '\u{103f}'), ('\u{1050}', '\u{1062}'), + ('\u{1065}', '\u{1068}'), ('\u{106e}', '\u{1086}'), ('\u{108e}', + '\u{108e}'), ('\u{109c}', '\u{109d}'), ('\u{10a0}', '\u{10c5}'), + ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', + '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), + ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', + '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), + ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', + '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), + ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', + '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135f}', '\u{135f}'), + ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f4}'), ('\u{1401}', + '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), + ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', + '\u{170c}'), ('\u{170e}', '\u{1713}'), ('\u{1720}', '\u{1733}'), + ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', + '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17b3}'), + ('\u{17b6}', '\u{17c8}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', + '\u{17dc}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}'), + ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', + '\u{192b}'), ('\u{1930}', '\u{1938}'), ('\u{1950}', '\u{196d}'), + ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', + '\u{19c9}'), ('\u{1a00}', '\u{1a1b}'), ('\u{1a20}', '\u{1a5e}'), + ('\u{1a61}', '\u{1a74}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1b00}', + '\u{1b33}'), ('\u{1b35}', '\u{1b43}'), ('\u{1b45}', '\u{1b4b}'), + ('\u{1b80}', '\u{1ba9}'), ('\u{1bac}', '\u{1baf}'), ('\u{1bba}', + '\u{1be5}'), ('\u{1be7}', '\u{1bf1}'), ('\u{1c00}', '\u{1c35}'), + ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1ce9}', + '\u{1cec}'), ('\u{1cee}', '\u{1cf3}'), ('\u{1cf5}', '\u{1cf6}'), + ('\u{1d00}', '\u{1dbf}'), ('\u{1de7}', '\u{1df4}'), ('\u{1e00}', + '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), + ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', + '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), + ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', + '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), + ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', + '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), + ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', + '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', '\u{2102}'), + ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', + '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), + ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', + '\u{212d}'), ('\u{212f}', '\u{2139}'), ('\u{213c}', '\u{213f}'), + ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', + '\u{2188}'), ('\u{24b6}', '\u{24e9}'), ('\u{2c00}', '\u{2c2e}'), + ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', + '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), + ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', + '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'), + ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', + '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), + ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', + '\u{2dde}'), ('\u{2de0}', '\u{2dff}'), ('\u{2e2f}', '\u{2e2f}'), + ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3031}', + '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), + ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', + '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), + ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', + '\u{4db5}'), ('\u{4e00}', '\u{9fcc}'), ('\u{a000}', '\u{a48c}'), + ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', + '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), + ('\u{a674}', '\u{a67b}'), ('\u{a67f}', '\u{a69d}'), ('\u{a69f}', + '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), + ('\u{a78b}', '\u{a78e}'), ('\u{a790}', '\u{a7ad}'), ('\u{a7b0}', + '\u{a7b1}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}', '\u{a805}'), + ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a827}'), ('\u{a840}', + '\u{a873}'), ('\u{a880}', '\u{a8c3}'), ('\u{a8f2}', '\u{a8f7}'), + ('\u{a8fb}', '\u{a8fb}'), ('\u{a90a}', '\u{a92a}'), ('\u{a930}', + '\u{a952}'), ('\u{a960}', '\u{a97c}'), ('\u{a980}', '\u{a9b2}'), + ('\u{a9b4}', '\u{a9bf}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', + '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), + ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa60}', + '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aabe}'), + ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', + '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), ('\u{aaf2}', '\u{aaf5}'), + ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', + '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), + ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab5f}'), ('\u{ab64}', + '\u{ab65}'), ('\u{abc0}', '\u{abea}'), ('\u{ac00}', '\u{d7a3}'), + ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', + '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), + ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), ('\u{fb2a}', + '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), + ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', + '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), + ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', + '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), + ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', + '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), + ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', + '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), + ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', + '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{10280}', '\u{1029c}'), + ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', + '\u{1034a}'), ('\u{10350}', '\u{1037a}'), ('\u{10380}', '\u{1039d}'), + ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', + '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), + ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', + '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), + ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', + '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), + ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{10900}', + '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), + ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', + '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), + ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', + '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), + ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', + '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), + ('\u{11000}', '\u{11045}'), ('\u{11082}', '\u{110b8}'), ('\u{110d0}', + '\u{110e8}'), ('\u{11100}', '\u{11132}'), ('\u{11150}', '\u{11172}'), + ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111bf}'), ('\u{111c1}', + '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{11200}', '\u{11211}'), + ('\u{11213}', '\u{11234}'), ('\u{11237}', '\u{11237}'), ('\u{112b0}', + '\u{112e8}'), ('\u{11301}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), + ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', + '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), + ('\u{1133d}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', + '\u{1134c}'), ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), + ('\u{11480}', '\u{114c1}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', + '\u{114c7}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115be}'), + ('\u{11600}', '\u{1163e}'), ('\u{11640}', '\u{11640}'), ('\u{11644}', + '\u{11644}'), ('\u{11680}', '\u{116b5}'), ('\u{118a0}', '\u{118df}'), + ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', + '\u{12398}'), ('\u{12400}', '\u{1246e}'), ('\u{13000}', '\u{1342e}'), + ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', + '\u{16aed}'), ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), + ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', + '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f93}', '\u{16f9f}'), + ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', + '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), + ('\u{1bc9e}', '\u{1bc9e}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', + '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), + ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', + '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), + ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', + '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), + ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', + '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), + ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', + '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), + ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', + '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), + ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', + '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), + ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', + '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), + ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', + '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), + ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', + '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), + ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', + '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), + ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', + '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), + ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', + '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), + ('\u{1f130}', '\u{1f149}'), ('\u{1f150}', '\u{1f169}'), ('\u{1f170}', + '\u{1f189}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), + ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}') + ]; + + pub const Default_Ignorable_Code_Point_table: &'static [(char, char)] = &[ + ('\u{ad}', '\u{ad}'), ('\u{34f}', '\u{34f}'), ('\u{61c}', '\u{61c}'), + ('\u{115f}', '\u{1160}'), ('\u{17b4}', '\u{17b5}'), ('\u{180b}', + '\u{180e}'), ('\u{200b}', '\u{200f}'), ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{206f}'), ('\u{3164}', '\u{3164}'), ('\u{fe00}', + '\u{fe0f}'), ('\u{feff}', '\u{feff}'), ('\u{ffa0}', '\u{ffa0}'), + ('\u{fff0}', '\u{fff8}'), ('\u{1bca0}', '\u{1bca3}'), ('\u{1d173}', + '\u{1d17a}'), ('\u{e0000}', '\u{e0fff}') + ]; + + pub const Grapheme_Extend_table: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), ('\u{483}', '\u{489}'), ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), ('\u{610}', '\u{61a}'), ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), ('\u{6d6}', '\u{6dc}'), ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), ('\u{6ea}', '\u{6ed}'), ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), ('\u{7a6}', '\u{7b0}'), ('\u{7eb}', '\u{7f3}'), + ('\u{816}', '\u{819}'), ('\u{81b}', '\u{823}'), ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), ('\u{859}', '\u{85b}'), ('\u{8e4}', '\u{902}'), + ('\u{93a}', '\u{93a}'), ('\u{93c}', '\u{93c}'), ('\u{941}', '\u{948}'), + ('\u{94d}', '\u{94d}'), ('\u{951}', '\u{957}'), ('\u{962}', '\u{963}'), + ('\u{981}', '\u{981}'), ('\u{9bc}', '\u{9bc}'), ('\u{9be}', '\u{9be}'), + ('\u{9c1}', '\u{9c4}'), ('\u{9cd}', '\u{9cd}'), ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), ('\u{a01}', '\u{a02}'), ('\u{a3c}', '\u{a3c}'), + ('\u{a41}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), ('\u{a70}', '\u{a71}'), ('\u{a75}', '\u{a75}'), + ('\u{a81}', '\u{a82}'), ('\u{abc}', '\u{abc}'), ('\u{ac1}', '\u{ac5}'), + ('\u{ac7}', '\u{ac8}'), ('\u{acd}', '\u{acd}'), ('\u{ae2}', '\u{ae3}'), + ('\u{b01}', '\u{b01}'), ('\u{b3c}', '\u{b3c}'), ('\u{b3e}', '\u{b3f}'), + ('\u{b41}', '\u{b44}'), ('\u{b4d}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), ('\u{b82}', '\u{b82}'), ('\u{bbe}', '\u{bbe}'), + ('\u{bc0}', '\u{bc0}'), ('\u{bcd}', '\u{bcd}'), ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', '\u{c00}'), ('\u{c3e}', '\u{c40}'), ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c62}', '\u{c63}'), + ('\u{c81}', '\u{c81}'), ('\u{cbc}', '\u{cbc}'), ('\u{cbf}', '\u{cbf}'), + ('\u{cc2}', '\u{cc2}'), ('\u{cc6}', '\u{cc6}'), ('\u{ccc}', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), ('\u{ce2}', '\u{ce3}'), ('\u{d01}', '\u{d01}'), + ('\u{d3e}', '\u{d3e}'), ('\u{d41}', '\u{d44}'), ('\u{d4d}', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), ('\u{d62}', '\u{d63}'), ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dcf}'), ('\u{dd2}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), + ('\u{ddf}', '\u{ddf}'), ('\u{e31}', '\u{e31}'), ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), ('\u{eb1}', '\u{eb1}'), ('\u{eb4}', '\u{eb9}'), + ('\u{ebb}', '\u{ebc}'), ('\u{ec8}', '\u{ecd}'), ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), + ('\u{f71}', '\u{f7e}'), ('\u{f80}', '\u{f84}'), ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), + ('\u{102d}', '\u{1030}'), ('\u{1032}', '\u{1037}'), ('\u{1039}', + '\u{103a}'), ('\u{103d}', '\u{103e}'), ('\u{1058}', '\u{1059}'), + ('\u{105e}', '\u{1060}'), ('\u{1071}', '\u{1074}'), ('\u{1082}', + '\u{1082}'), ('\u{1085}', '\u{1086}'), ('\u{108d}', '\u{108d}'), + ('\u{109d}', '\u{109d}'), ('\u{135d}', '\u{135f}'), ('\u{1712}', + '\u{1714}'), ('\u{1732}', '\u{1734}'), ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), ('\u{17b4}', '\u{17b5}'), ('\u{17b7}', + '\u{17bd}'), ('\u{17c6}', '\u{17c6}'), ('\u{17c9}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), ('\u{180b}', '\u{180d}'), ('\u{18a9}', + '\u{18a9}'), ('\u{1920}', '\u{1922}'), ('\u{1927}', '\u{1928}'), + ('\u{1932}', '\u{1932}'), ('\u{1939}', '\u{193b}'), ('\u{1a17}', + '\u{1a18}'), ('\u{1a1b}', '\u{1a1b}'), ('\u{1a56}', '\u{1a56}'), + ('\u{1a58}', '\u{1a5e}'), ('\u{1a60}', '\u{1a60}'), ('\u{1a62}', + '\u{1a62}'), ('\u{1a65}', '\u{1a6c}'), ('\u{1a73}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), ('\u{1ab0}', '\u{1abe}'), ('\u{1b00}', + '\u{1b03}'), ('\u{1b34}', '\u{1b34}'), ('\u{1b36}', '\u{1b3a}'), + ('\u{1b3c}', '\u{1b3c}'), ('\u{1b42}', '\u{1b42}'), ('\u{1b6b}', + '\u{1b73}'), ('\u{1b80}', '\u{1b81}'), ('\u{1ba2}', '\u{1ba5}'), + ('\u{1ba8}', '\u{1ba9}'), ('\u{1bab}', '\u{1bad}'), ('\u{1be6}', + '\u{1be6}'), ('\u{1be8}', '\u{1be9}'), ('\u{1bed}', '\u{1bed}'), + ('\u{1bef}', '\u{1bf1}'), ('\u{1c2c}', '\u{1c33}'), ('\u{1c36}', + '\u{1c37}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf4}', + '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), + ('\u{1dfc}', '\u{1dff}'), ('\u{200c}', '\u{200d}'), ('\u{20d0}', + '\u{20f0}'), ('\u{2cef}', '\u{2cf1}'), ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), ('\u{302a}', '\u{302f}'), ('\u{3099}', + '\u{309a}'), ('\u{a66f}', '\u{a672}'), ('\u{a674}', '\u{a67d}'), + ('\u{a69f}', '\u{a69f}'), ('\u{a6f0}', '\u{a6f1}'), ('\u{a802}', + '\u{a802}'), ('\u{a806}', '\u{a806}'), ('\u{a80b}', '\u{a80b}'), + ('\u{a825}', '\u{a826}'), ('\u{a8c4}', '\u{a8c4}'), ('\u{a8e0}', + '\u{a8f1}'), ('\u{a926}', '\u{a92d}'), ('\u{a947}', '\u{a951}'), + ('\u{a980}', '\u{a982}'), ('\u{a9b3}', '\u{a9b3}'), ('\u{a9b6}', + '\u{a9b9}'), ('\u{a9bc}', '\u{a9bc}'), ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa2e}'), ('\u{aa31}', '\u{aa32}'), ('\u{aa35}', + '\u{aa36}'), ('\u{aa43}', '\u{aa43}'), ('\u{aa4c}', '\u{aa4c}'), + ('\u{aa7c}', '\u{aa7c}'), ('\u{aab0}', '\u{aab0}'), ('\u{aab2}', + '\u{aab4}'), ('\u{aab7}', '\u{aab8}'), ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), ('\u{aaec}', '\u{aaed}'), ('\u{aaf6}', + '\u{aaf6}'), ('\u{abe5}', '\u{abe5}'), ('\u{abe8}', '\u{abe8}'), + ('\u{abed}', '\u{abed}'), ('\u{fb1e}', '\u{fb1e}'), ('\u{fe00}', + '\u{fe0f}'), ('\u{fe20}', '\u{fe2d}'), ('\u{ff9e}', '\u{ff9f}'), + ('\u{101fd}', '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{10376}', + '\u{1037a}'), ('\u{10a01}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', + '\u{10a3f}'), ('\u{10ae5}', '\u{10ae6}'), ('\u{11001}', '\u{11001}'), + ('\u{11038}', '\u{11046}'), ('\u{1107f}', '\u{11081}'), ('\u{110b3}', + '\u{110b6}'), ('\u{110b9}', '\u{110ba}'), ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{1112b}'), ('\u{1112d}', '\u{11134}'), ('\u{11173}', + '\u{11173}'), ('\u{11180}', '\u{11181}'), ('\u{111b6}', '\u{111be}'), + ('\u{1122f}', '\u{11231}'), ('\u{11234}', '\u{11234}'), ('\u{11236}', + '\u{11237}'), ('\u{112df}', '\u{112df}'), ('\u{112e3}', '\u{112ea}'), + ('\u{11301}', '\u{11301}'), ('\u{1133c}', '\u{1133c}'), ('\u{1133e}', + '\u{1133e}'), ('\u{11340}', '\u{11340}'), ('\u{11357}', '\u{11357}'), + ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{114b0}', + '\u{114b0}'), ('\u{114b3}', '\u{114b8}'), ('\u{114ba}', '\u{114ba}'), + ('\u{114bd}', '\u{114bd}'), ('\u{114bf}', '\u{114c0}'), ('\u{114c2}', + '\u{114c3}'), ('\u{115af}', '\u{115af}'), ('\u{115b2}', '\u{115b5}'), + ('\u{115bc}', '\u{115bd}'), ('\u{115bf}', '\u{115c0}'), ('\u{11633}', + '\u{1163a}'), ('\u{1163d}', '\u{1163d}'), ('\u{1163f}', '\u{11640}'), + ('\u{116ab}', '\u{116ab}'), ('\u{116ad}', '\u{116ad}'), ('\u{116b0}', + '\u{116b5}'), ('\u{116b7}', '\u{116b7}'), ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), ('\u{16f8f}', '\u{16f92}'), ('\u{1bc9d}', + '\u{1bc9e}'), ('\u{1d165}', '\u{1d165}'), ('\u{1d167}', '\u{1d169}'), + ('\u{1d16e}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', + '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), + ('\u{1e8d0}', '\u{1e8d6}'), ('\u{e0100}', '\u{e01ef}') + ]; + + pub const Lowercase_table: &'static [(char, char)] = &[ + ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), + ('\u{ba}', '\u{ba}'), ('\u{df}', '\u{f6}'), ('\u{f8}', '\u{ff}'), + ('\u{101}', '\u{101}'), ('\u{103}', '\u{103}'), ('\u{105}', '\u{105}'), + ('\u{107}', '\u{107}'), ('\u{109}', '\u{109}'), ('\u{10b}', '\u{10b}'), + ('\u{10d}', '\u{10d}'), ('\u{10f}', '\u{10f}'), ('\u{111}', '\u{111}'), + ('\u{113}', '\u{113}'), ('\u{115}', '\u{115}'), ('\u{117}', '\u{117}'), + ('\u{119}', '\u{119}'), ('\u{11b}', '\u{11b}'), ('\u{11d}', '\u{11d}'), + ('\u{11f}', '\u{11f}'), ('\u{121}', '\u{121}'), ('\u{123}', '\u{123}'), + ('\u{125}', '\u{125}'), ('\u{127}', '\u{127}'), ('\u{129}', '\u{129}'), + ('\u{12b}', '\u{12b}'), ('\u{12d}', '\u{12d}'), ('\u{12f}', '\u{12f}'), + ('\u{131}', '\u{131}'), ('\u{133}', '\u{133}'), ('\u{135}', '\u{135}'), + ('\u{137}', '\u{138}'), ('\u{13a}', '\u{13a}'), ('\u{13c}', '\u{13c}'), + ('\u{13e}', '\u{13e}'), ('\u{140}', '\u{140}'), ('\u{142}', '\u{142}'), + ('\u{144}', '\u{144}'), ('\u{146}', '\u{146}'), ('\u{148}', '\u{149}'), + ('\u{14b}', '\u{14b}'), ('\u{14d}', '\u{14d}'), ('\u{14f}', '\u{14f}'), + ('\u{151}', '\u{151}'), ('\u{153}', '\u{153}'), ('\u{155}', '\u{155}'), + ('\u{157}', '\u{157}'), ('\u{159}', '\u{159}'), ('\u{15b}', '\u{15b}'), + ('\u{15d}', '\u{15d}'), ('\u{15f}', '\u{15f}'), ('\u{161}', '\u{161}'), + ('\u{163}', '\u{163}'), ('\u{165}', '\u{165}'), ('\u{167}', '\u{167}'), + ('\u{169}', '\u{169}'), ('\u{16b}', '\u{16b}'), ('\u{16d}', '\u{16d}'), + ('\u{16f}', '\u{16f}'), ('\u{171}', '\u{171}'), ('\u{173}', '\u{173}'), + ('\u{175}', '\u{175}'), ('\u{177}', '\u{177}'), ('\u{17a}', '\u{17a}'), + ('\u{17c}', '\u{17c}'), ('\u{17e}', '\u{180}'), ('\u{183}', '\u{183}'), + ('\u{185}', '\u{185}'), ('\u{188}', '\u{188}'), ('\u{18c}', '\u{18d}'), + ('\u{192}', '\u{192}'), ('\u{195}', '\u{195}'), ('\u{199}', '\u{19b}'), + ('\u{19e}', '\u{19e}'), ('\u{1a1}', '\u{1a1}'), ('\u{1a3}', '\u{1a3}'), + ('\u{1a5}', '\u{1a5}'), ('\u{1a8}', '\u{1a8}'), ('\u{1aa}', '\u{1ab}'), + ('\u{1ad}', '\u{1ad}'), ('\u{1b0}', '\u{1b0}'), ('\u{1b4}', '\u{1b4}'), + ('\u{1b6}', '\u{1b6}'), ('\u{1b9}', '\u{1ba}'), ('\u{1bd}', '\u{1bf}'), + ('\u{1c6}', '\u{1c6}'), ('\u{1c9}', '\u{1c9}'), ('\u{1cc}', '\u{1cc}'), + ('\u{1ce}', '\u{1ce}'), ('\u{1d0}', '\u{1d0}'), ('\u{1d2}', '\u{1d2}'), + ('\u{1d4}', '\u{1d4}'), ('\u{1d6}', '\u{1d6}'), ('\u{1d8}', '\u{1d8}'), + ('\u{1da}', '\u{1da}'), ('\u{1dc}', '\u{1dd}'), ('\u{1df}', '\u{1df}'), + ('\u{1e1}', '\u{1e1}'), ('\u{1e3}', '\u{1e3}'), ('\u{1e5}', '\u{1e5}'), + ('\u{1e7}', '\u{1e7}'), ('\u{1e9}', '\u{1e9}'), ('\u{1eb}', '\u{1eb}'), + ('\u{1ed}', '\u{1ed}'), ('\u{1ef}', '\u{1f0}'), ('\u{1f3}', '\u{1f3}'), + ('\u{1f5}', '\u{1f5}'), ('\u{1f9}', '\u{1f9}'), ('\u{1fb}', '\u{1fb}'), + ('\u{1fd}', '\u{1fd}'), ('\u{1ff}', '\u{1ff}'), ('\u{201}', '\u{201}'), + ('\u{203}', '\u{203}'), ('\u{205}', '\u{205}'), ('\u{207}', '\u{207}'), + ('\u{209}', '\u{209}'), ('\u{20b}', '\u{20b}'), ('\u{20d}', '\u{20d}'), + ('\u{20f}', '\u{20f}'), ('\u{211}', '\u{211}'), ('\u{213}', '\u{213}'), + ('\u{215}', '\u{215}'), ('\u{217}', '\u{217}'), ('\u{219}', '\u{219}'), + ('\u{21b}', '\u{21b}'), ('\u{21d}', '\u{21d}'), ('\u{21f}', '\u{21f}'), + ('\u{221}', '\u{221}'), ('\u{223}', '\u{223}'), ('\u{225}', '\u{225}'), + ('\u{227}', '\u{227}'), ('\u{229}', '\u{229}'), ('\u{22b}', '\u{22b}'), + ('\u{22d}', '\u{22d}'), ('\u{22f}', '\u{22f}'), ('\u{231}', '\u{231}'), + ('\u{233}', '\u{239}'), ('\u{23c}', '\u{23c}'), ('\u{23f}', '\u{240}'), + ('\u{242}', '\u{242}'), ('\u{247}', '\u{247}'), ('\u{249}', '\u{249}'), + ('\u{24b}', '\u{24b}'), ('\u{24d}', '\u{24d}'), ('\u{24f}', '\u{293}'), + ('\u{295}', '\u{2b8}'), ('\u{2c0}', '\u{2c1}'), ('\u{2e0}', '\u{2e4}'), + ('\u{345}', '\u{345}'), ('\u{371}', '\u{371}'), ('\u{373}', '\u{373}'), + ('\u{377}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{390}', '\u{390}'), + ('\u{3ac}', '\u{3ce}'), ('\u{3d0}', '\u{3d1}'), ('\u{3d5}', '\u{3d7}'), + ('\u{3d9}', '\u{3d9}'), ('\u{3db}', '\u{3db}'), ('\u{3dd}', '\u{3dd}'), + ('\u{3df}', '\u{3df}'), ('\u{3e1}', '\u{3e1}'), ('\u{3e3}', '\u{3e3}'), + ('\u{3e5}', '\u{3e5}'), ('\u{3e7}', '\u{3e7}'), ('\u{3e9}', '\u{3e9}'), + ('\u{3eb}', '\u{3eb}'), ('\u{3ed}', '\u{3ed}'), ('\u{3ef}', '\u{3f3}'), + ('\u{3f5}', '\u{3f5}'), ('\u{3f8}', '\u{3f8}'), ('\u{3fb}', '\u{3fc}'), + ('\u{430}', '\u{45f}'), ('\u{461}', '\u{461}'), ('\u{463}', '\u{463}'), + ('\u{465}', '\u{465}'), ('\u{467}', '\u{467}'), ('\u{469}', '\u{469}'), + ('\u{46b}', '\u{46b}'), ('\u{46d}', '\u{46d}'), ('\u{46f}', '\u{46f}'), + ('\u{471}', '\u{471}'), ('\u{473}', '\u{473}'), ('\u{475}', '\u{475}'), + ('\u{477}', '\u{477}'), ('\u{479}', '\u{479}'), ('\u{47b}', '\u{47b}'), + ('\u{47d}', '\u{47d}'), ('\u{47f}', '\u{47f}'), ('\u{481}', '\u{481}'), + ('\u{48b}', '\u{48b}'), ('\u{48d}', '\u{48d}'), ('\u{48f}', '\u{48f}'), + ('\u{491}', '\u{491}'), ('\u{493}', '\u{493}'), ('\u{495}', '\u{495}'), + ('\u{497}', '\u{497}'), ('\u{499}', '\u{499}'), ('\u{49b}', '\u{49b}'), + ('\u{49d}', '\u{49d}'), ('\u{49f}', '\u{49f}'), ('\u{4a1}', '\u{4a1}'), + ('\u{4a3}', '\u{4a3}'), ('\u{4a5}', '\u{4a5}'), ('\u{4a7}', '\u{4a7}'), + ('\u{4a9}', '\u{4a9}'), ('\u{4ab}', '\u{4ab}'), ('\u{4ad}', '\u{4ad}'), + ('\u{4af}', '\u{4af}'), ('\u{4b1}', '\u{4b1}'), ('\u{4b3}', '\u{4b3}'), + ('\u{4b5}', '\u{4b5}'), ('\u{4b7}', '\u{4b7}'), ('\u{4b9}', '\u{4b9}'), + ('\u{4bb}', '\u{4bb}'), ('\u{4bd}', '\u{4bd}'), ('\u{4bf}', '\u{4bf}'), + ('\u{4c2}', '\u{4c2}'), ('\u{4c4}', '\u{4c4}'), ('\u{4c6}', '\u{4c6}'), + ('\u{4c8}', '\u{4c8}'), ('\u{4ca}', '\u{4ca}'), ('\u{4cc}', '\u{4cc}'), + ('\u{4ce}', '\u{4cf}'), ('\u{4d1}', '\u{4d1}'), ('\u{4d3}', '\u{4d3}'), + ('\u{4d5}', '\u{4d5}'), ('\u{4d7}', '\u{4d7}'), ('\u{4d9}', '\u{4d9}'), + ('\u{4db}', '\u{4db}'), ('\u{4dd}', '\u{4dd}'), ('\u{4df}', '\u{4df}'), + ('\u{4e1}', '\u{4e1}'), ('\u{4e3}', '\u{4e3}'), ('\u{4e5}', '\u{4e5}'), + ('\u{4e7}', '\u{4e7}'), ('\u{4e9}', '\u{4e9}'), ('\u{4eb}', '\u{4eb}'), + ('\u{4ed}', '\u{4ed}'), ('\u{4ef}', '\u{4ef}'), ('\u{4f1}', '\u{4f1}'), + ('\u{4f3}', '\u{4f3}'), ('\u{4f5}', '\u{4f5}'), ('\u{4f7}', '\u{4f7}'), + ('\u{4f9}', '\u{4f9}'), ('\u{4fb}', '\u{4fb}'), ('\u{4fd}', '\u{4fd}'), + ('\u{4ff}', '\u{4ff}'), ('\u{501}', '\u{501}'), ('\u{503}', '\u{503}'), + ('\u{505}', '\u{505}'), ('\u{507}', '\u{507}'), ('\u{509}', '\u{509}'), + ('\u{50b}', '\u{50b}'), ('\u{50d}', '\u{50d}'), ('\u{50f}', '\u{50f}'), + ('\u{511}', '\u{511}'), ('\u{513}', '\u{513}'), ('\u{515}', '\u{515}'), + ('\u{517}', '\u{517}'), ('\u{519}', '\u{519}'), ('\u{51b}', '\u{51b}'), + ('\u{51d}', '\u{51d}'), ('\u{51f}', '\u{51f}'), ('\u{521}', '\u{521}'), + ('\u{523}', '\u{523}'), ('\u{525}', '\u{525}'), ('\u{527}', '\u{527}'), + ('\u{529}', '\u{529}'), ('\u{52b}', '\u{52b}'), ('\u{52d}', '\u{52d}'), + ('\u{52f}', '\u{52f}'), ('\u{561}', '\u{587}'), ('\u{1d00}', + '\u{1dbf}'), ('\u{1e01}', '\u{1e01}'), ('\u{1e03}', '\u{1e03}'), + ('\u{1e05}', '\u{1e05}'), ('\u{1e07}', '\u{1e07}'), ('\u{1e09}', + '\u{1e09}'), ('\u{1e0b}', '\u{1e0b}'), ('\u{1e0d}', '\u{1e0d}'), + ('\u{1e0f}', '\u{1e0f}'), ('\u{1e11}', '\u{1e11}'), ('\u{1e13}', + '\u{1e13}'), ('\u{1e15}', '\u{1e15}'), ('\u{1e17}', '\u{1e17}'), + ('\u{1e19}', '\u{1e19}'), ('\u{1e1b}', '\u{1e1b}'), ('\u{1e1d}', + '\u{1e1d}'), ('\u{1e1f}', '\u{1e1f}'), ('\u{1e21}', '\u{1e21}'), + ('\u{1e23}', '\u{1e23}'), ('\u{1e25}', '\u{1e25}'), ('\u{1e27}', + '\u{1e27}'), ('\u{1e29}', '\u{1e29}'), ('\u{1e2b}', '\u{1e2b}'), + ('\u{1e2d}', '\u{1e2d}'), ('\u{1e2f}', '\u{1e2f}'), ('\u{1e31}', + '\u{1e31}'), ('\u{1e33}', '\u{1e33}'), ('\u{1e35}', '\u{1e35}'), + ('\u{1e37}', '\u{1e37}'), ('\u{1e39}', '\u{1e39}'), ('\u{1e3b}', + '\u{1e3b}'), ('\u{1e3d}', '\u{1e3d}'), ('\u{1e3f}', '\u{1e3f}'), + ('\u{1e41}', '\u{1e41}'), ('\u{1e43}', '\u{1e43}'), ('\u{1e45}', + '\u{1e45}'), ('\u{1e47}', '\u{1e47}'), ('\u{1e49}', '\u{1e49}'), + ('\u{1e4b}', '\u{1e4b}'), ('\u{1e4d}', '\u{1e4d}'), ('\u{1e4f}', + '\u{1e4f}'), ('\u{1e51}', '\u{1e51}'), ('\u{1e53}', '\u{1e53}'), + ('\u{1e55}', '\u{1e55}'), ('\u{1e57}', '\u{1e57}'), ('\u{1e59}', + '\u{1e59}'), ('\u{1e5b}', '\u{1e5b}'), ('\u{1e5d}', '\u{1e5d}'), + ('\u{1e5f}', '\u{1e5f}'), ('\u{1e61}', '\u{1e61}'), ('\u{1e63}', + '\u{1e63}'), ('\u{1e65}', '\u{1e65}'), ('\u{1e67}', '\u{1e67}'), + ('\u{1e69}', '\u{1e69}'), ('\u{1e6b}', '\u{1e6b}'), ('\u{1e6d}', + '\u{1e6d}'), ('\u{1e6f}', '\u{1e6f}'), ('\u{1e71}', '\u{1e71}'), + ('\u{1e73}', '\u{1e73}'), ('\u{1e75}', '\u{1e75}'), ('\u{1e77}', + '\u{1e77}'), ('\u{1e79}', '\u{1e79}'), ('\u{1e7b}', '\u{1e7b}'), + ('\u{1e7d}', '\u{1e7d}'), ('\u{1e7f}', '\u{1e7f}'), ('\u{1e81}', + '\u{1e81}'), ('\u{1e83}', '\u{1e83}'), ('\u{1e85}', '\u{1e85}'), + ('\u{1e87}', '\u{1e87}'), ('\u{1e89}', '\u{1e89}'), ('\u{1e8b}', + '\u{1e8b}'), ('\u{1e8d}', '\u{1e8d}'), ('\u{1e8f}', '\u{1e8f}'), + ('\u{1e91}', '\u{1e91}'), ('\u{1e93}', '\u{1e93}'), ('\u{1e95}', + '\u{1e9d}'), ('\u{1e9f}', '\u{1e9f}'), ('\u{1ea1}', '\u{1ea1}'), + ('\u{1ea3}', '\u{1ea3}'), ('\u{1ea5}', '\u{1ea5}'), ('\u{1ea7}', + '\u{1ea7}'), ('\u{1ea9}', '\u{1ea9}'), ('\u{1eab}', '\u{1eab}'), + ('\u{1ead}', '\u{1ead}'), ('\u{1eaf}', '\u{1eaf}'), ('\u{1eb1}', + '\u{1eb1}'), ('\u{1eb3}', '\u{1eb3}'), ('\u{1eb5}', '\u{1eb5}'), + ('\u{1eb7}', '\u{1eb7}'), ('\u{1eb9}', '\u{1eb9}'), ('\u{1ebb}', + '\u{1ebb}'), ('\u{1ebd}', '\u{1ebd}'), ('\u{1ebf}', '\u{1ebf}'), + ('\u{1ec1}', '\u{1ec1}'), ('\u{1ec3}', '\u{1ec3}'), ('\u{1ec5}', + '\u{1ec5}'), ('\u{1ec7}', '\u{1ec7}'), ('\u{1ec9}', '\u{1ec9}'), + ('\u{1ecb}', '\u{1ecb}'), ('\u{1ecd}', '\u{1ecd}'), ('\u{1ecf}', + '\u{1ecf}'), ('\u{1ed1}', '\u{1ed1}'), ('\u{1ed3}', '\u{1ed3}'), + ('\u{1ed5}', '\u{1ed5}'), ('\u{1ed7}', '\u{1ed7}'), ('\u{1ed9}', + '\u{1ed9}'), ('\u{1edb}', '\u{1edb}'), ('\u{1edd}', '\u{1edd}'), + ('\u{1edf}', '\u{1edf}'), ('\u{1ee1}', '\u{1ee1}'), ('\u{1ee3}', + '\u{1ee3}'), ('\u{1ee5}', '\u{1ee5}'), ('\u{1ee7}', '\u{1ee7}'), + ('\u{1ee9}', '\u{1ee9}'), ('\u{1eeb}', '\u{1eeb}'), ('\u{1eed}', + '\u{1eed}'), ('\u{1eef}', '\u{1eef}'), ('\u{1ef1}', '\u{1ef1}'), + ('\u{1ef3}', '\u{1ef3}'), ('\u{1ef5}', '\u{1ef5}'), ('\u{1ef7}', + '\u{1ef7}'), ('\u{1ef9}', '\u{1ef9}'), ('\u{1efb}', '\u{1efb}'), + ('\u{1efd}', '\u{1efd}'), ('\u{1eff}', '\u{1f07}'), ('\u{1f10}', + '\u{1f15}'), ('\u{1f20}', '\u{1f27}'), ('\u{1f30}', '\u{1f37}'), + ('\u{1f40}', '\u{1f45}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f60}', + '\u{1f67}'), ('\u{1f70}', '\u{1f7d}'), ('\u{1f80}', '\u{1f87}'), + ('\u{1f90}', '\u{1f97}'), ('\u{1fa0}', '\u{1fa7}'), ('\u{1fb0}', + '\u{1fb4}'), ('\u{1fb6}', '\u{1fb7}'), ('\u{1fbe}', '\u{1fbe}'), + ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fc7}'), ('\u{1fd0}', + '\u{1fd3}'), ('\u{1fd6}', '\u{1fd7}'), ('\u{1fe0}', '\u{1fe7}'), + ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ff7}'), ('\u{2071}', + '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), + ('\u{210a}', '\u{210a}'), ('\u{210e}', '\u{210f}'), ('\u{2113}', + '\u{2113}'), ('\u{212f}', '\u{212f}'), ('\u{2134}', '\u{2134}'), + ('\u{2139}', '\u{2139}'), ('\u{213c}', '\u{213d}'), ('\u{2146}', + '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2170}', '\u{217f}'), + ('\u{2184}', '\u{2184}'), ('\u{24d0}', '\u{24e9}'), ('\u{2c30}', + '\u{2c5e}'), ('\u{2c61}', '\u{2c61}'), ('\u{2c65}', '\u{2c66}'), + ('\u{2c68}', '\u{2c68}'), ('\u{2c6a}', '\u{2c6a}'), ('\u{2c6c}', + '\u{2c6c}'), ('\u{2c71}', '\u{2c71}'), ('\u{2c73}', '\u{2c74}'), + ('\u{2c76}', '\u{2c7d}'), ('\u{2c81}', '\u{2c81}'), ('\u{2c83}', + '\u{2c83}'), ('\u{2c85}', '\u{2c85}'), ('\u{2c87}', '\u{2c87}'), + ('\u{2c89}', '\u{2c89}'), ('\u{2c8b}', '\u{2c8b}'), ('\u{2c8d}', + '\u{2c8d}'), ('\u{2c8f}', '\u{2c8f}'), ('\u{2c91}', '\u{2c91}'), + ('\u{2c93}', '\u{2c93}'), ('\u{2c95}', '\u{2c95}'), ('\u{2c97}', + '\u{2c97}'), ('\u{2c99}', '\u{2c99}'), ('\u{2c9b}', '\u{2c9b}'), + ('\u{2c9d}', '\u{2c9d}'), ('\u{2c9f}', '\u{2c9f}'), ('\u{2ca1}', + '\u{2ca1}'), ('\u{2ca3}', '\u{2ca3}'), ('\u{2ca5}', '\u{2ca5}'), + ('\u{2ca7}', '\u{2ca7}'), ('\u{2ca9}', '\u{2ca9}'), ('\u{2cab}', + '\u{2cab}'), ('\u{2cad}', '\u{2cad}'), ('\u{2caf}', '\u{2caf}'), + ('\u{2cb1}', '\u{2cb1}'), ('\u{2cb3}', '\u{2cb3}'), ('\u{2cb5}', + '\u{2cb5}'), ('\u{2cb7}', '\u{2cb7}'), ('\u{2cb9}', '\u{2cb9}'), + ('\u{2cbb}', '\u{2cbb}'), ('\u{2cbd}', '\u{2cbd}'), ('\u{2cbf}', + '\u{2cbf}'), ('\u{2cc1}', '\u{2cc1}'), ('\u{2cc3}', '\u{2cc3}'), + ('\u{2cc5}', '\u{2cc5}'), ('\u{2cc7}', '\u{2cc7}'), ('\u{2cc9}', + '\u{2cc9}'), ('\u{2ccb}', '\u{2ccb}'), ('\u{2ccd}', '\u{2ccd}'), + ('\u{2ccf}', '\u{2ccf}'), ('\u{2cd1}', '\u{2cd1}'), ('\u{2cd3}', + '\u{2cd3}'), ('\u{2cd5}', '\u{2cd5}'), ('\u{2cd7}', '\u{2cd7}'), + ('\u{2cd9}', '\u{2cd9}'), ('\u{2cdb}', '\u{2cdb}'), ('\u{2cdd}', + '\u{2cdd}'), ('\u{2cdf}', '\u{2cdf}'), ('\u{2ce1}', '\u{2ce1}'), + ('\u{2ce3}', '\u{2ce4}'), ('\u{2cec}', '\u{2cec}'), ('\u{2cee}', + '\u{2cee}'), ('\u{2cf3}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), + ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{a641}', + '\u{a641}'), ('\u{a643}', '\u{a643}'), ('\u{a645}', '\u{a645}'), + ('\u{a647}', '\u{a647}'), ('\u{a649}', '\u{a649}'), ('\u{a64b}', + '\u{a64b}'), ('\u{a64d}', '\u{a64d}'), ('\u{a64f}', '\u{a64f}'), + ('\u{a651}', '\u{a651}'), ('\u{a653}', '\u{a653}'), ('\u{a655}', + '\u{a655}'), ('\u{a657}', '\u{a657}'), ('\u{a659}', '\u{a659}'), + ('\u{a65b}', '\u{a65b}'), ('\u{a65d}', '\u{a65d}'), ('\u{a65f}', + '\u{a65f}'), ('\u{a661}', '\u{a661}'), ('\u{a663}', '\u{a663}'), + ('\u{a665}', '\u{a665}'), ('\u{a667}', '\u{a667}'), ('\u{a669}', + '\u{a669}'), ('\u{a66b}', '\u{a66b}'), ('\u{a66d}', '\u{a66d}'), + ('\u{a681}', '\u{a681}'), ('\u{a683}', '\u{a683}'), ('\u{a685}', + '\u{a685}'), ('\u{a687}', '\u{a687}'), ('\u{a689}', '\u{a689}'), + ('\u{a68b}', '\u{a68b}'), ('\u{a68d}', '\u{a68d}'), ('\u{a68f}', + '\u{a68f}'), ('\u{a691}', '\u{a691}'), ('\u{a693}', '\u{a693}'), + ('\u{a695}', '\u{a695}'), ('\u{a697}', '\u{a697}'), ('\u{a699}', + '\u{a699}'), ('\u{a69b}', '\u{a69d}'), ('\u{a723}', '\u{a723}'), + ('\u{a725}', '\u{a725}'), ('\u{a727}', '\u{a727}'), ('\u{a729}', + '\u{a729}'), ('\u{a72b}', '\u{a72b}'), ('\u{a72d}', '\u{a72d}'), + ('\u{a72f}', '\u{a731}'), ('\u{a733}', '\u{a733}'), ('\u{a735}', + '\u{a735}'), ('\u{a737}', '\u{a737}'), ('\u{a739}', '\u{a739}'), + ('\u{a73b}', '\u{a73b}'), ('\u{a73d}', '\u{a73d}'), ('\u{a73f}', + '\u{a73f}'), ('\u{a741}', '\u{a741}'), ('\u{a743}', '\u{a743}'), + ('\u{a745}', '\u{a745}'), ('\u{a747}', '\u{a747}'), ('\u{a749}', + '\u{a749}'), ('\u{a74b}', '\u{a74b}'), ('\u{a74d}', '\u{a74d}'), + ('\u{a74f}', '\u{a74f}'), ('\u{a751}', '\u{a751}'), ('\u{a753}', + '\u{a753}'), ('\u{a755}', '\u{a755}'), ('\u{a757}', '\u{a757}'), + ('\u{a759}', '\u{a759}'), ('\u{a75b}', '\u{a75b}'), ('\u{a75d}', + '\u{a75d}'), ('\u{a75f}', '\u{a75f}'), ('\u{a761}', '\u{a761}'), + ('\u{a763}', '\u{a763}'), ('\u{a765}', '\u{a765}'), ('\u{a767}', + '\u{a767}'), ('\u{a769}', '\u{a769}'), ('\u{a76b}', '\u{a76b}'), + ('\u{a76d}', '\u{a76d}'), ('\u{a76f}', '\u{a778}'), ('\u{a77a}', + '\u{a77a}'), ('\u{a77c}', '\u{a77c}'), ('\u{a77f}', '\u{a77f}'), + ('\u{a781}', '\u{a781}'), ('\u{a783}', '\u{a783}'), ('\u{a785}', + '\u{a785}'), ('\u{a787}', '\u{a787}'), ('\u{a78c}', '\u{a78c}'), + ('\u{a78e}', '\u{a78e}'), ('\u{a791}', '\u{a791}'), ('\u{a793}', + '\u{a795}'), ('\u{a797}', '\u{a797}'), ('\u{a799}', '\u{a799}'), + ('\u{a79b}', '\u{a79b}'), ('\u{a79d}', '\u{a79d}'), ('\u{a79f}', + '\u{a79f}'), ('\u{a7a1}', '\u{a7a1}'), ('\u{a7a3}', '\u{a7a3}'), + ('\u{a7a5}', '\u{a7a5}'), ('\u{a7a7}', '\u{a7a7}'), ('\u{a7a9}', + '\u{a7a9}'), ('\u{a7f8}', '\u{a7fa}'), ('\u{ab30}', '\u{ab5a}'), + ('\u{ab5c}', '\u{ab5f}'), ('\u{ab64}', '\u{ab65}'), ('\u{fb00}', + '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{ff41}', '\u{ff5a}'), + ('\u{10428}', '\u{1044f}'), ('\u{118c0}', '\u{118df}'), ('\u{1d41a}', + '\u{1d433}'), ('\u{1d44e}', '\u{1d454}'), ('\u{1d456}', '\u{1d467}'), + ('\u{1d482}', '\u{1d49b}'), ('\u{1d4b6}', '\u{1d4b9}'), ('\u{1d4bb}', + '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d4cf}'), + ('\u{1d4ea}', '\u{1d503}'), ('\u{1d51e}', '\u{1d537}'), ('\u{1d552}', + '\u{1d56b}'), ('\u{1d586}', '\u{1d59f}'), ('\u{1d5ba}', '\u{1d5d3}'), + ('\u{1d5ee}', '\u{1d607}'), ('\u{1d622}', '\u{1d63b}'), ('\u{1d656}', + '\u{1d66f}'), ('\u{1d68a}', '\u{1d6a5}'), ('\u{1d6c2}', '\u{1d6da}'), + ('\u{1d6dc}', '\u{1d6e1}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', + '\u{1d71b}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d755}'), + ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d78f}'), ('\u{1d7aa}', + '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7c9}'), ('\u{1d7cb}', '\u{1d7cb}') + ]; + + pub const Uppercase_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{de}'), + ('\u{100}', '\u{100}'), ('\u{102}', '\u{102}'), ('\u{104}', '\u{104}'), + ('\u{106}', '\u{106}'), ('\u{108}', '\u{108}'), ('\u{10a}', '\u{10a}'), + ('\u{10c}', '\u{10c}'), ('\u{10e}', '\u{10e}'), ('\u{110}', '\u{110}'), + ('\u{112}', '\u{112}'), ('\u{114}', '\u{114}'), ('\u{116}', '\u{116}'), + ('\u{118}', '\u{118}'), ('\u{11a}', '\u{11a}'), ('\u{11c}', '\u{11c}'), + ('\u{11e}', '\u{11e}'), ('\u{120}', '\u{120}'), ('\u{122}', '\u{122}'), + ('\u{124}', '\u{124}'), ('\u{126}', '\u{126}'), ('\u{128}', '\u{128}'), + ('\u{12a}', '\u{12a}'), ('\u{12c}', '\u{12c}'), ('\u{12e}', '\u{12e}'), + ('\u{130}', '\u{130}'), ('\u{132}', '\u{132}'), ('\u{134}', '\u{134}'), + ('\u{136}', '\u{136}'), ('\u{139}', '\u{139}'), ('\u{13b}', '\u{13b}'), + ('\u{13d}', '\u{13d}'), ('\u{13f}', '\u{13f}'), ('\u{141}', '\u{141}'), + ('\u{143}', '\u{143}'), ('\u{145}', '\u{145}'), ('\u{147}', '\u{147}'), + ('\u{14a}', '\u{14a}'), ('\u{14c}', '\u{14c}'), ('\u{14e}', '\u{14e}'), + ('\u{150}', '\u{150}'), ('\u{152}', '\u{152}'), ('\u{154}', '\u{154}'), + ('\u{156}', '\u{156}'), ('\u{158}', '\u{158}'), ('\u{15a}', '\u{15a}'), + ('\u{15c}', '\u{15c}'), ('\u{15e}', '\u{15e}'), ('\u{160}', '\u{160}'), + ('\u{162}', '\u{162}'), ('\u{164}', '\u{164}'), ('\u{166}', '\u{166}'), + ('\u{168}', '\u{168}'), ('\u{16a}', '\u{16a}'), ('\u{16c}', '\u{16c}'), + ('\u{16e}', '\u{16e}'), ('\u{170}', '\u{170}'), ('\u{172}', '\u{172}'), + ('\u{174}', '\u{174}'), ('\u{176}', '\u{176}'), ('\u{178}', '\u{179}'), + ('\u{17b}', '\u{17b}'), ('\u{17d}', '\u{17d}'), ('\u{181}', '\u{182}'), + ('\u{184}', '\u{184}'), ('\u{186}', '\u{187}'), ('\u{189}', '\u{18b}'), + ('\u{18e}', '\u{191}'), ('\u{193}', '\u{194}'), ('\u{196}', '\u{198}'), + ('\u{19c}', '\u{19d}'), ('\u{19f}', '\u{1a0}'), ('\u{1a2}', '\u{1a2}'), + ('\u{1a4}', '\u{1a4}'), ('\u{1a6}', '\u{1a7}'), ('\u{1a9}', '\u{1a9}'), + ('\u{1ac}', '\u{1ac}'), ('\u{1ae}', '\u{1af}'), ('\u{1b1}', '\u{1b3}'), + ('\u{1b5}', '\u{1b5}'), ('\u{1b7}', '\u{1b8}'), ('\u{1bc}', '\u{1bc}'), + ('\u{1c4}', '\u{1c4}'), ('\u{1c7}', '\u{1c7}'), ('\u{1ca}', '\u{1ca}'), + ('\u{1cd}', '\u{1cd}'), ('\u{1cf}', '\u{1cf}'), ('\u{1d1}', '\u{1d1}'), + ('\u{1d3}', '\u{1d3}'), ('\u{1d5}', '\u{1d5}'), ('\u{1d7}', '\u{1d7}'), + ('\u{1d9}', '\u{1d9}'), ('\u{1db}', '\u{1db}'), ('\u{1de}', '\u{1de}'), + ('\u{1e0}', '\u{1e0}'), ('\u{1e2}', '\u{1e2}'), ('\u{1e4}', '\u{1e4}'), + ('\u{1e6}', '\u{1e6}'), ('\u{1e8}', '\u{1e8}'), ('\u{1ea}', '\u{1ea}'), + ('\u{1ec}', '\u{1ec}'), ('\u{1ee}', '\u{1ee}'), ('\u{1f1}', '\u{1f1}'), + ('\u{1f4}', '\u{1f4}'), ('\u{1f6}', '\u{1f8}'), ('\u{1fa}', '\u{1fa}'), + ('\u{1fc}', '\u{1fc}'), ('\u{1fe}', '\u{1fe}'), ('\u{200}', '\u{200}'), + ('\u{202}', '\u{202}'), ('\u{204}', '\u{204}'), ('\u{206}', '\u{206}'), + ('\u{208}', '\u{208}'), ('\u{20a}', '\u{20a}'), ('\u{20c}', '\u{20c}'), + ('\u{20e}', '\u{20e}'), ('\u{210}', '\u{210}'), ('\u{212}', '\u{212}'), + ('\u{214}', '\u{214}'), ('\u{216}', '\u{216}'), ('\u{218}', '\u{218}'), + ('\u{21a}', '\u{21a}'), ('\u{21c}', '\u{21c}'), ('\u{21e}', '\u{21e}'), + ('\u{220}', '\u{220}'), ('\u{222}', '\u{222}'), ('\u{224}', '\u{224}'), + ('\u{226}', '\u{226}'), ('\u{228}', '\u{228}'), ('\u{22a}', '\u{22a}'), + ('\u{22c}', '\u{22c}'), ('\u{22e}', '\u{22e}'), ('\u{230}', '\u{230}'), + ('\u{232}', '\u{232}'), ('\u{23a}', '\u{23b}'), ('\u{23d}', '\u{23e}'), + ('\u{241}', '\u{241}'), ('\u{243}', '\u{246}'), ('\u{248}', '\u{248}'), + ('\u{24a}', '\u{24a}'), ('\u{24c}', '\u{24c}'), ('\u{24e}', '\u{24e}'), + ('\u{370}', '\u{370}'), ('\u{372}', '\u{372}'), ('\u{376}', '\u{376}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), + ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{38f}'), ('\u{391}', '\u{3a1}'), + ('\u{3a3}', '\u{3ab}'), ('\u{3cf}', '\u{3cf}'), ('\u{3d2}', '\u{3d4}'), + ('\u{3d8}', '\u{3d8}'), ('\u{3da}', '\u{3da}'), ('\u{3dc}', '\u{3dc}'), + ('\u{3de}', '\u{3de}'), ('\u{3e0}', '\u{3e0}'), ('\u{3e2}', '\u{3e2}'), + ('\u{3e4}', '\u{3e4}'), ('\u{3e6}', '\u{3e6}'), ('\u{3e8}', '\u{3e8}'), + ('\u{3ea}', '\u{3ea}'), ('\u{3ec}', '\u{3ec}'), ('\u{3ee}', '\u{3ee}'), + ('\u{3f4}', '\u{3f4}'), ('\u{3f7}', '\u{3f7}'), ('\u{3f9}', '\u{3fa}'), + ('\u{3fd}', '\u{42f}'), ('\u{460}', '\u{460}'), ('\u{462}', '\u{462}'), + ('\u{464}', '\u{464}'), ('\u{466}', '\u{466}'), ('\u{468}', '\u{468}'), + ('\u{46a}', '\u{46a}'), ('\u{46c}', '\u{46c}'), ('\u{46e}', '\u{46e}'), + ('\u{470}', '\u{470}'), ('\u{472}', '\u{472}'), ('\u{474}', '\u{474}'), + ('\u{476}', '\u{476}'), ('\u{478}', '\u{478}'), ('\u{47a}', '\u{47a}'), + ('\u{47c}', '\u{47c}'), ('\u{47e}', '\u{47e}'), ('\u{480}', '\u{480}'), + ('\u{48a}', '\u{48a}'), ('\u{48c}', '\u{48c}'), ('\u{48e}', '\u{48e}'), + ('\u{490}', '\u{490}'), ('\u{492}', '\u{492}'), ('\u{494}', '\u{494}'), + ('\u{496}', '\u{496}'), ('\u{498}', '\u{498}'), ('\u{49a}', '\u{49a}'), + ('\u{49c}', '\u{49c}'), ('\u{49e}', '\u{49e}'), ('\u{4a0}', '\u{4a0}'), + ('\u{4a2}', '\u{4a2}'), ('\u{4a4}', '\u{4a4}'), ('\u{4a6}', '\u{4a6}'), + ('\u{4a8}', '\u{4a8}'), ('\u{4aa}', '\u{4aa}'), ('\u{4ac}', '\u{4ac}'), + ('\u{4ae}', '\u{4ae}'), ('\u{4b0}', '\u{4b0}'), ('\u{4b2}', '\u{4b2}'), + ('\u{4b4}', '\u{4b4}'), ('\u{4b6}', '\u{4b6}'), ('\u{4b8}', '\u{4b8}'), + ('\u{4ba}', '\u{4ba}'), ('\u{4bc}', '\u{4bc}'), ('\u{4be}', '\u{4be}'), + ('\u{4c0}', '\u{4c1}'), ('\u{4c3}', '\u{4c3}'), ('\u{4c5}', '\u{4c5}'), + ('\u{4c7}', '\u{4c7}'), ('\u{4c9}', '\u{4c9}'), ('\u{4cb}', '\u{4cb}'), + ('\u{4cd}', '\u{4cd}'), ('\u{4d0}', '\u{4d0}'), ('\u{4d2}', '\u{4d2}'), + ('\u{4d4}', '\u{4d4}'), ('\u{4d6}', '\u{4d6}'), ('\u{4d8}', '\u{4d8}'), + ('\u{4da}', '\u{4da}'), ('\u{4dc}', '\u{4dc}'), ('\u{4de}', '\u{4de}'), + ('\u{4e0}', '\u{4e0}'), ('\u{4e2}', '\u{4e2}'), ('\u{4e4}', '\u{4e4}'), + ('\u{4e6}', '\u{4e6}'), ('\u{4e8}', '\u{4e8}'), ('\u{4ea}', '\u{4ea}'), + ('\u{4ec}', '\u{4ec}'), ('\u{4ee}', '\u{4ee}'), ('\u{4f0}', '\u{4f0}'), + ('\u{4f2}', '\u{4f2}'), ('\u{4f4}', '\u{4f4}'), ('\u{4f6}', '\u{4f6}'), + ('\u{4f8}', '\u{4f8}'), ('\u{4fa}', '\u{4fa}'), ('\u{4fc}', '\u{4fc}'), + ('\u{4fe}', '\u{4fe}'), ('\u{500}', '\u{500}'), ('\u{502}', '\u{502}'), + ('\u{504}', '\u{504}'), ('\u{506}', '\u{506}'), ('\u{508}', '\u{508}'), + ('\u{50a}', '\u{50a}'), ('\u{50c}', '\u{50c}'), ('\u{50e}', '\u{50e}'), + ('\u{510}', '\u{510}'), ('\u{512}', '\u{512}'), ('\u{514}', '\u{514}'), + ('\u{516}', '\u{516}'), ('\u{518}', '\u{518}'), ('\u{51a}', '\u{51a}'), + ('\u{51c}', '\u{51c}'), ('\u{51e}', '\u{51e}'), ('\u{520}', '\u{520}'), + ('\u{522}', '\u{522}'), ('\u{524}', '\u{524}'), ('\u{526}', '\u{526}'), + ('\u{528}', '\u{528}'), ('\u{52a}', '\u{52a}'), ('\u{52c}', '\u{52c}'), + ('\u{52e}', '\u{52e}'), ('\u{531}', '\u{556}'), ('\u{10a0}', + '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), + ('\u{1e00}', '\u{1e00}'), ('\u{1e02}', '\u{1e02}'), ('\u{1e04}', + '\u{1e04}'), ('\u{1e06}', '\u{1e06}'), ('\u{1e08}', '\u{1e08}'), + ('\u{1e0a}', '\u{1e0a}'), ('\u{1e0c}', '\u{1e0c}'), ('\u{1e0e}', + '\u{1e0e}'), ('\u{1e10}', '\u{1e10}'), ('\u{1e12}', '\u{1e12}'), + ('\u{1e14}', '\u{1e14}'), ('\u{1e16}', '\u{1e16}'), ('\u{1e18}', + '\u{1e18}'), ('\u{1e1a}', '\u{1e1a}'), ('\u{1e1c}', '\u{1e1c}'), + ('\u{1e1e}', '\u{1e1e}'), ('\u{1e20}', '\u{1e20}'), ('\u{1e22}', + '\u{1e22}'), ('\u{1e24}', '\u{1e24}'), ('\u{1e26}', '\u{1e26}'), + ('\u{1e28}', '\u{1e28}'), ('\u{1e2a}', '\u{1e2a}'), ('\u{1e2c}', + '\u{1e2c}'), ('\u{1e2e}', '\u{1e2e}'), ('\u{1e30}', '\u{1e30}'), + ('\u{1e32}', '\u{1e32}'), ('\u{1e34}', '\u{1e34}'), ('\u{1e36}', + '\u{1e36}'), ('\u{1e38}', '\u{1e38}'), ('\u{1e3a}', '\u{1e3a}'), + ('\u{1e3c}', '\u{1e3c}'), ('\u{1e3e}', '\u{1e3e}'), ('\u{1e40}', + '\u{1e40}'), ('\u{1e42}', '\u{1e42}'), ('\u{1e44}', '\u{1e44}'), + ('\u{1e46}', '\u{1e46}'), ('\u{1e48}', '\u{1e48}'), ('\u{1e4a}', + '\u{1e4a}'), ('\u{1e4c}', '\u{1e4c}'), ('\u{1e4e}', '\u{1e4e}'), + ('\u{1e50}', '\u{1e50}'), ('\u{1e52}', '\u{1e52}'), ('\u{1e54}', + '\u{1e54}'), ('\u{1e56}', '\u{1e56}'), ('\u{1e58}', '\u{1e58}'), + ('\u{1e5a}', '\u{1e5a}'), ('\u{1e5c}', '\u{1e5c}'), ('\u{1e5e}', + '\u{1e5e}'), ('\u{1e60}', '\u{1e60}'), ('\u{1e62}', '\u{1e62}'), + ('\u{1e64}', '\u{1e64}'), ('\u{1e66}', '\u{1e66}'), ('\u{1e68}', + '\u{1e68}'), ('\u{1e6a}', '\u{1e6a}'), ('\u{1e6c}', '\u{1e6c}'), + ('\u{1e6e}', '\u{1e6e}'), ('\u{1e70}', '\u{1e70}'), ('\u{1e72}', + '\u{1e72}'), ('\u{1e74}', '\u{1e74}'), ('\u{1e76}', '\u{1e76}'), + ('\u{1e78}', '\u{1e78}'), ('\u{1e7a}', '\u{1e7a}'), ('\u{1e7c}', + '\u{1e7c}'), ('\u{1e7e}', '\u{1e7e}'), ('\u{1e80}', '\u{1e80}'), + ('\u{1e82}', '\u{1e82}'), ('\u{1e84}', '\u{1e84}'), ('\u{1e86}', + '\u{1e86}'), ('\u{1e88}', '\u{1e88}'), ('\u{1e8a}', '\u{1e8a}'), + ('\u{1e8c}', '\u{1e8c}'), ('\u{1e8e}', '\u{1e8e}'), ('\u{1e90}', + '\u{1e90}'), ('\u{1e92}', '\u{1e92}'), ('\u{1e94}', '\u{1e94}'), + ('\u{1e9e}', '\u{1e9e}'), ('\u{1ea0}', '\u{1ea0}'), ('\u{1ea2}', + '\u{1ea2}'), ('\u{1ea4}', '\u{1ea4}'), ('\u{1ea6}', '\u{1ea6}'), + ('\u{1ea8}', '\u{1ea8}'), ('\u{1eaa}', '\u{1eaa}'), ('\u{1eac}', + '\u{1eac}'), ('\u{1eae}', '\u{1eae}'), ('\u{1eb0}', '\u{1eb0}'), + ('\u{1eb2}', '\u{1eb2}'), ('\u{1eb4}', '\u{1eb4}'), ('\u{1eb6}', + '\u{1eb6}'), ('\u{1eb8}', '\u{1eb8}'), ('\u{1eba}', '\u{1eba}'), + ('\u{1ebc}', '\u{1ebc}'), ('\u{1ebe}', '\u{1ebe}'), ('\u{1ec0}', + '\u{1ec0}'), ('\u{1ec2}', '\u{1ec2}'), ('\u{1ec4}', '\u{1ec4}'), + ('\u{1ec6}', '\u{1ec6}'), ('\u{1ec8}', '\u{1ec8}'), ('\u{1eca}', + '\u{1eca}'), ('\u{1ecc}', '\u{1ecc}'), ('\u{1ece}', '\u{1ece}'), + ('\u{1ed0}', '\u{1ed0}'), ('\u{1ed2}', '\u{1ed2}'), ('\u{1ed4}', + '\u{1ed4}'), ('\u{1ed6}', '\u{1ed6}'), ('\u{1ed8}', '\u{1ed8}'), + ('\u{1eda}', '\u{1eda}'), ('\u{1edc}', '\u{1edc}'), ('\u{1ede}', + '\u{1ede}'), ('\u{1ee0}', '\u{1ee0}'), ('\u{1ee2}', '\u{1ee2}'), + ('\u{1ee4}', '\u{1ee4}'), ('\u{1ee6}', '\u{1ee6}'), ('\u{1ee8}', + '\u{1ee8}'), ('\u{1eea}', '\u{1eea}'), ('\u{1eec}', '\u{1eec}'), + ('\u{1eee}', '\u{1eee}'), ('\u{1ef0}', '\u{1ef0}'), ('\u{1ef2}', + '\u{1ef2}'), ('\u{1ef4}', '\u{1ef4}'), ('\u{1ef6}', '\u{1ef6}'), + ('\u{1ef8}', '\u{1ef8}'), ('\u{1efa}', '\u{1efa}'), ('\u{1efc}', + '\u{1efc}'), ('\u{1efe}', '\u{1efe}'), ('\u{1f08}', '\u{1f0f}'), + ('\u{1f18}', '\u{1f1d}'), ('\u{1f28}', '\u{1f2f}'), ('\u{1f38}', + '\u{1f3f}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f59}', '\u{1f59}'), + ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', + '\u{1f5f}'), ('\u{1f68}', '\u{1f6f}'), ('\u{1fb8}', '\u{1fbb}'), + ('\u{1fc8}', '\u{1fcb}'), ('\u{1fd8}', '\u{1fdb}'), ('\u{1fe8}', + '\u{1fec}'), ('\u{1ff8}', '\u{1ffb}'), ('\u{2102}', '\u{2102}'), + ('\u{2107}', '\u{2107}'), ('\u{210b}', '\u{210d}'), ('\u{2110}', + '\u{2112}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), + ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', + '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{2130}', '\u{2133}'), + ('\u{213e}', '\u{213f}'), ('\u{2145}', '\u{2145}'), ('\u{2160}', + '\u{216f}'), ('\u{2183}', '\u{2183}'), ('\u{24b6}', '\u{24cf}'), + ('\u{2c00}', '\u{2c2e}'), ('\u{2c60}', '\u{2c60}'), ('\u{2c62}', + '\u{2c64}'), ('\u{2c67}', '\u{2c67}'), ('\u{2c69}', '\u{2c69}'), + ('\u{2c6b}', '\u{2c6b}'), ('\u{2c6d}', '\u{2c70}'), ('\u{2c72}', + '\u{2c72}'), ('\u{2c75}', '\u{2c75}'), ('\u{2c7e}', '\u{2c80}'), + ('\u{2c82}', '\u{2c82}'), ('\u{2c84}', '\u{2c84}'), ('\u{2c86}', + '\u{2c86}'), ('\u{2c88}', '\u{2c88}'), ('\u{2c8a}', '\u{2c8a}'), + ('\u{2c8c}', '\u{2c8c}'), ('\u{2c8e}', '\u{2c8e}'), ('\u{2c90}', + '\u{2c90}'), ('\u{2c92}', '\u{2c92}'), ('\u{2c94}', '\u{2c94}'), + ('\u{2c96}', '\u{2c96}'), ('\u{2c98}', '\u{2c98}'), ('\u{2c9a}', + '\u{2c9a}'), ('\u{2c9c}', '\u{2c9c}'), ('\u{2c9e}', '\u{2c9e}'), + ('\u{2ca0}', '\u{2ca0}'), ('\u{2ca2}', '\u{2ca2}'), ('\u{2ca4}', + '\u{2ca4}'), ('\u{2ca6}', '\u{2ca6}'), ('\u{2ca8}', '\u{2ca8}'), + ('\u{2caa}', '\u{2caa}'), ('\u{2cac}', '\u{2cac}'), ('\u{2cae}', + '\u{2cae}'), ('\u{2cb0}', '\u{2cb0}'), ('\u{2cb2}', '\u{2cb2}'), + ('\u{2cb4}', '\u{2cb4}'), ('\u{2cb6}', '\u{2cb6}'), ('\u{2cb8}', + '\u{2cb8}'), ('\u{2cba}', '\u{2cba}'), ('\u{2cbc}', '\u{2cbc}'), + ('\u{2cbe}', '\u{2cbe}'), ('\u{2cc0}', '\u{2cc0}'), ('\u{2cc2}', + '\u{2cc2}'), ('\u{2cc4}', '\u{2cc4}'), ('\u{2cc6}', '\u{2cc6}'), + ('\u{2cc8}', '\u{2cc8}'), ('\u{2cca}', '\u{2cca}'), ('\u{2ccc}', + '\u{2ccc}'), ('\u{2cce}', '\u{2cce}'), ('\u{2cd0}', '\u{2cd0}'), + ('\u{2cd2}', '\u{2cd2}'), ('\u{2cd4}', '\u{2cd4}'), ('\u{2cd6}', + '\u{2cd6}'), ('\u{2cd8}', '\u{2cd8}'), ('\u{2cda}', '\u{2cda}'), + ('\u{2cdc}', '\u{2cdc}'), ('\u{2cde}', '\u{2cde}'), ('\u{2ce0}', + '\u{2ce0}'), ('\u{2ce2}', '\u{2ce2}'), ('\u{2ceb}', '\u{2ceb}'), + ('\u{2ced}', '\u{2ced}'), ('\u{2cf2}', '\u{2cf2}'), ('\u{a640}', + '\u{a640}'), ('\u{a642}', '\u{a642}'), ('\u{a644}', '\u{a644}'), + ('\u{a646}', '\u{a646}'), ('\u{a648}', '\u{a648}'), ('\u{a64a}', + '\u{a64a}'), ('\u{a64c}', '\u{a64c}'), ('\u{a64e}', '\u{a64e}'), + ('\u{a650}', '\u{a650}'), ('\u{a652}', '\u{a652}'), ('\u{a654}', + '\u{a654}'), ('\u{a656}', '\u{a656}'), ('\u{a658}', '\u{a658}'), + ('\u{a65a}', '\u{a65a}'), ('\u{a65c}', '\u{a65c}'), ('\u{a65e}', + '\u{a65e}'), ('\u{a660}', '\u{a660}'), ('\u{a662}', '\u{a662}'), + ('\u{a664}', '\u{a664}'), ('\u{a666}', '\u{a666}'), ('\u{a668}', + '\u{a668}'), ('\u{a66a}', '\u{a66a}'), ('\u{a66c}', '\u{a66c}'), + ('\u{a680}', '\u{a680}'), ('\u{a682}', '\u{a682}'), ('\u{a684}', + '\u{a684}'), ('\u{a686}', '\u{a686}'), ('\u{a688}', '\u{a688}'), + ('\u{a68a}', '\u{a68a}'), ('\u{a68c}', '\u{a68c}'), ('\u{a68e}', + '\u{a68e}'), ('\u{a690}', '\u{a690}'), ('\u{a692}', '\u{a692}'), + ('\u{a694}', '\u{a694}'), ('\u{a696}', '\u{a696}'), ('\u{a698}', + '\u{a698}'), ('\u{a69a}', '\u{a69a}'), ('\u{a722}', '\u{a722}'), + ('\u{a724}', '\u{a724}'), ('\u{a726}', '\u{a726}'), ('\u{a728}', + '\u{a728}'), ('\u{a72a}', '\u{a72a}'), ('\u{a72c}', '\u{a72c}'), + ('\u{a72e}', '\u{a72e}'), ('\u{a732}', '\u{a732}'), ('\u{a734}', + '\u{a734}'), ('\u{a736}', '\u{a736}'), ('\u{a738}', '\u{a738}'), + ('\u{a73a}', '\u{a73a}'), ('\u{a73c}', '\u{a73c}'), ('\u{a73e}', + '\u{a73e}'), ('\u{a740}', '\u{a740}'), ('\u{a742}', '\u{a742}'), + ('\u{a744}', '\u{a744}'), ('\u{a746}', '\u{a746}'), ('\u{a748}', + '\u{a748}'), ('\u{a74a}', '\u{a74a}'), ('\u{a74c}', '\u{a74c}'), + ('\u{a74e}', '\u{a74e}'), ('\u{a750}', '\u{a750}'), ('\u{a752}', + '\u{a752}'), ('\u{a754}', '\u{a754}'), ('\u{a756}', '\u{a756}'), + ('\u{a758}', '\u{a758}'), ('\u{a75a}', '\u{a75a}'), ('\u{a75c}', + '\u{a75c}'), ('\u{a75e}', '\u{a75e}'), ('\u{a760}', '\u{a760}'), + ('\u{a762}', '\u{a762}'), ('\u{a764}', '\u{a764}'), ('\u{a766}', + '\u{a766}'), ('\u{a768}', '\u{a768}'), ('\u{a76a}', '\u{a76a}'), + ('\u{a76c}', '\u{a76c}'), ('\u{a76e}', '\u{a76e}'), ('\u{a779}', + '\u{a779}'), ('\u{a77b}', '\u{a77b}'), ('\u{a77d}', '\u{a77e}'), + ('\u{a780}', '\u{a780}'), ('\u{a782}', '\u{a782}'), ('\u{a784}', + '\u{a784}'), ('\u{a786}', '\u{a786}'), ('\u{a78b}', '\u{a78b}'), + ('\u{a78d}', '\u{a78d}'), ('\u{a790}', '\u{a790}'), ('\u{a792}', + '\u{a792}'), ('\u{a796}', '\u{a796}'), ('\u{a798}', '\u{a798}'), + ('\u{a79a}', '\u{a79a}'), ('\u{a79c}', '\u{a79c}'), ('\u{a79e}', + '\u{a79e}'), ('\u{a7a0}', '\u{a7a0}'), ('\u{a7a2}', '\u{a7a2}'), + ('\u{a7a4}', '\u{a7a4}'), ('\u{a7a6}', '\u{a7a6}'), ('\u{a7a8}', + '\u{a7a8}'), ('\u{a7aa}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b1}'), + ('\u{ff21}', '\u{ff3a}'), ('\u{10400}', '\u{10427}'), ('\u{118a0}', + '\u{118bf}'), ('\u{1d400}', '\u{1d419}'), ('\u{1d434}', '\u{1d44d}'), + ('\u{1d468}', '\u{1d481}'), ('\u{1d49c}', '\u{1d49c}'), ('\u{1d49e}', + '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), + ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b5}'), ('\u{1d4d0}', + '\u{1d4e9}'), ('\u{1d504}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), + ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d538}', + '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), + ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d56c}', + '\u{1d585}'), ('\u{1d5a0}', '\u{1d5b9}'), ('\u{1d5d4}', '\u{1d5ed}'), + ('\u{1d608}', '\u{1d621}'), ('\u{1d63c}', '\u{1d655}'), ('\u{1d670}', + '\u{1d689}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6e2}', '\u{1d6fa}'), + ('\u{1d71c}', '\u{1d734}'), ('\u{1d756}', '\u{1d76e}'), ('\u{1d790}', + '\u{1d7a8}'), ('\u{1d7ca}', '\u{1d7ca}'), ('\u{1f130}', '\u{1f149}'), + ('\u{1f150}', '\u{1f169}'), ('\u{1f170}', '\u{1f189}') + ]; + + pub const XID_Continue_table: &'static [(char, char)] = &[ + ('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), + ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), + ('\u{b7}', '\u{b7}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), + ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), + ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), + ('\u{300}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{38a}'), ('\u{38c}', '\u{38c}'), + ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), + ('\u{483}', '\u{487}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), + ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), + ('\u{610}', '\u{61a}'), ('\u{620}', '\u{669}'), ('\u{66e}', '\u{6d3}'), + ('\u{6d5}', '\u{6dc}'), ('\u{6df}', '\u{6e8}'), ('\u{6ea}', '\u{6fc}'), + ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{74a}'), ('\u{74d}', '\u{7b1}'), + ('\u{7c0}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{82d}'), + ('\u{840}', '\u{85b}'), ('\u{8a0}', '\u{8b2}'), ('\u{8e4}', '\u{963}'), + ('\u{966}', '\u{96f}'), ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), + ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), + ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), + ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), + ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9f1}'), + ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), + ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), + ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), + ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), + ('\u{a66}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), + ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), + ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), + ('\u{ae0}', '\u{ae3}'), ('\u{ae6}', '\u{aef}'), ('\u{b01}', '\u{b03}'), + ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), + ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), + ('\u{b3c}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b63}'), + ('\u{b66}', '\u{b6f}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), + ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), + ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), + ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), + ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), + ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{be6}', '\u{bef}'), + ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), + ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), + ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), + ('\u{c58}', '\u{c59}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), + ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), + ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), + ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), + ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}'), ('\u{d01}', '\u{d03}'), + ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), + ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4e}'), + ('\u{d57}', '\u{d57}'), ('\u{d60}', '\u{d63}'), ('\u{d66}', '\u{d6f}'), + ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), + ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), + ('\u{dc0}', '\u{dc6}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), + ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e4e}'), + ('\u{e50}', '\u{e59}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), + ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), + ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), + ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), + ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), + ('\u{ec6}', '\u{ec6}'), ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), + ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f18}', '\u{f19}'), + ('\u{f20}', '\u{f29}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), ('\u{f3e}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), + ('\u{f71}', '\u{f84}'), ('\u{f86}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), ('\u{1000}', '\u{1049}'), ('\u{1050}', + '\u{109d}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), + ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', + '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), + ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', + '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), + ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', + '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), + ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', + '\u{135a}'), ('\u{135d}', '\u{135f}'), ('\u{1369}', '\u{1371}'), + ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f4}'), ('\u{1401}', + '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), + ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', + '\u{170c}'), ('\u{170e}', '\u{1714}'), ('\u{1720}', '\u{1734}'), + ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', + '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17d3}'), + ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dd}'), ('\u{17e0}', + '\u{17e9}'), ('\u{180b}', '\u{180d}'), ('\u{1810}', '\u{1819}'), + ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}'), ('\u{18b0}', + '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), + ('\u{1930}', '\u{193b}'), ('\u{1946}', '\u{196d}'), ('\u{1970}', + '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), + ('\u{19d0}', '\u{19da}'), ('\u{1a00}', '\u{1a1b}'), ('\u{1a20}', + '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a89}'), + ('\u{1a90}', '\u{1a99}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1ab0}', + '\u{1abd}'), ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', '\u{1b59}'), + ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1bf3}'), ('\u{1c00}', + '\u{1c37}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c4d}', '\u{1c7d}'), + ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1cf6}'), ('\u{1cf8}', + '\u{1cf9}'), ('\u{1d00}', '\u{1df5}'), ('\u{1dfc}', '\u{1f15}'), + ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', + '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), + ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', + '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), + ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', + '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), + ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', + '\u{1ffc}'), ('\u{203f}', '\u{2040}'), ('\u{2054}', '\u{2054}'), + ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', + '\u{209c}'), ('\u{20d0}', '\u{20dc}'), ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20f0}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', + '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), + ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', + '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{2139}'), + ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', + '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c00}', '\u{2c2e}'), + ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', + '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), + ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', + '\u{2d6f}'), ('\u{2d7f}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), + ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', + '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), + ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', + '\u{2dff}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{302f}'), + ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', + '\u{3096}'), ('\u{3099}', '\u{309a}'), ('\u{309d}', '\u{309f}'), + ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', + '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), + ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', + '\u{9fcc}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), + ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a62b}'), ('\u{a640}', + '\u{a66f}'), ('\u{a674}', '\u{a67d}'), ('\u{a67f}', '\u{a69d}'), + ('\u{a69f}', '\u{a6f1}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', + '\u{a788}'), ('\u{a78b}', '\u{a78e}'), ('\u{a790}', '\u{a7ad}'), + ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', '\u{a827}'), ('\u{a840}', + '\u{a873}'), ('\u{a880}', '\u{a8c4}'), ('\u{a8d0}', '\u{a8d9}'), + ('\u{a8e0}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a900}', + '\u{a92d}'), ('\u{a930}', '\u{a953}'), ('\u{a960}', '\u{a97c}'), + ('\u{a980}', '\u{a9c0}'), ('\u{a9cf}', '\u{a9d9}'), ('\u{a9e0}', + '\u{a9fe}'), ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), + ('\u{aa50}', '\u{aa59}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', + '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), + ('\u{aaf2}', '\u{aaf6}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', + '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), + ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', + '\u{ab5f}'), ('\u{ab64}', '\u{ab65}'), ('\u{abc0}', '\u{abea}'), + ('\u{abec}', '\u{abed}'), ('\u{abf0}', '\u{abf9}'), ('\u{ac00}', + '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), + ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', + '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), + ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', + '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), + ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', + '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), + ('\u{fdf0}', '\u{fdf9}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', + '\u{fe2d}'), ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), + ('\u{fe71}', '\u{fe71}'), ('\u{fe73}', '\u{fe73}'), ('\u{fe77}', + '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'), + ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff10}', + '\u{ff19}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff3f}', '\u{ff3f}'), + ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', + '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), + ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', + '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), + ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', + '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{101fd}', '\u{101fd}'), + ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{102e0}', + '\u{102e0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), + ('\u{10350}', '\u{1037a}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', + '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), + ('\u{10400}', '\u{1049d}'), ('\u{104a0}', '\u{104a9}'), ('\u{10500}', + '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), + ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', + '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), + ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', + '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), + ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', + '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', + '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', + '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae6}'), + ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', + '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), + ('\u{11000}', '\u{11046}'), ('\u{11066}', '\u{1106f}'), ('\u{1107f}', + '\u{110ba}'), ('\u{110d0}', '\u{110e8}'), ('\u{110f0}', '\u{110f9}'), + ('\u{11100}', '\u{11134}'), ('\u{11136}', '\u{1113f}'), ('\u{11150}', + '\u{11173}'), ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111c4}'), + ('\u{111d0}', '\u{111da}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', + '\u{11237}'), ('\u{112b0}', '\u{112ea}'), ('\u{112f0}', '\u{112f9}'), + ('\u{11301}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', + '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), + ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133c}', + '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), + ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', + '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{11480}', '\u{114c5}'), + ('\u{114c7}', '\u{114c7}'), ('\u{114d0}', '\u{114d9}'), ('\u{11580}', + '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{11600}', '\u{11640}'), + ('\u{11644}', '\u{11644}'), ('\u{11650}', '\u{11659}'), ('\u{11680}', + '\u{116b7}'), ('\u{116c0}', '\u{116c9}'), ('\u{118a0}', '\u{118e9}'), + ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', + '\u{12398}'), ('\u{12400}', '\u{1246e}'), ('\u{13000}', '\u{1342e}'), + ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', + '\u{16a69}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16af0}', '\u{16af4}'), + ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b50}', + '\u{16b59}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), + ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', + '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), + ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', + '\u{1bc99}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), + ('\u{1d16d}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', + '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), + ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', + '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), + ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', + '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), + ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', + '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), + ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', + '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), + ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', + '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), + ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', + '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), + ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8d0}', + '\u{1e8d6}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), + ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', + '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), + ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', + '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), + ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', + '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), + ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', + '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), + ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', + '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), + ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', + '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), + ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', + '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}'), + ('\u{e0100}', '\u{e01ef}') + ]; + + pub const XID_Start_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), + ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), + ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), + ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), + ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), + ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), + ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), + ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{5d0}', '\u{5ea}'), + ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{64a}'), ('\u{66e}', '\u{66f}'), + ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6e5}', '\u{6e6}'), + ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), + ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), + ('\u{7b1}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), + ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{815}'), ('\u{81a}', '\u{81a}'), + ('\u{824}', '\u{824}'), ('\u{828}', '\u{828}'), ('\u{840}', '\u{858}'), + ('\u{8a0}', '\u{8b2}'), ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), + ('\u{950}', '\u{950}'), ('\u{958}', '\u{961}'), ('\u{971}', '\u{980}'), + ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), + ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), + ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), ('\u{9dc}', '\u{9dd}'), + ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{a05}', '\u{a0a}'), + ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), + ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), + ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a72}', '\u{a74}'), + ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), + ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), + ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), + ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), + ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), + ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b61}'), + ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), + ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), + ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), + ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bd0}', '\u{bd0}'), + ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), + ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c59}'), + ('\u{c60}', '\u{c61}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), + ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), + ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce1}'), + ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), + ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), ('\u{d4e}', '\u{d4e}'), + ('\u{d60}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'), ('\u{d85}', '\u{d96}'), + ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), + ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), ('\u{e32}', '\u{e32}'), + ('\u{e40}', '\u{e46}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), + ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), + ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), + ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), + ('\u{ead}', '\u{eb0}'), ('\u{eb2}', '\u{eb2}'), ('\u{ebd}', '\u{ebd}'), + ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{edc}', '\u{edf}'), + ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), + ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}', + '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), + ('\u{1061}', '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', + '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}', '\u{108e}'), + ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', + '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), + ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', + '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), + ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', + '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), + ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', + '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), + ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f4}'), ('\u{1401}', + '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), + ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', + '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'), + ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', + '\u{1770}'), ('\u{1780}', '\u{17b3}'), ('\u{17d7}', '\u{17d7}'), + ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', + '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), + ('\u{1900}', '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', + '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19c1}', '\u{19c7}'), + ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1aa7}', + '\u{1aa7}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), + ('\u{1b83}', '\u{1ba0}'), ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', + '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), ('\u{1c4d}', '\u{1c4f}'), + ('\u{1c5a}', '\u{1c7d}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', + '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1d00}', '\u{1dbf}'), + ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', + '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), + ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', + '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), + ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', + '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), + ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', + '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), + ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', + '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), + ('\u{2115}', '\u{2115}'), ('\u{2118}', '\u{211d}'), ('\u{2124}', + '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), + ('\u{212a}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', + '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), + ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', + '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), + ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', + '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), + ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', + '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), + ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', + '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{3005}', '\u{3007}'), + ('\u{3021}', '\u{3029}'), ('\u{3031}', '\u{3035}'), ('\u{3038}', + '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), + ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', + '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), + ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', + '\u{9fcc}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), + ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', + '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a67f}', '\u{a69d}'), + ('\u{a6a0}', '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', + '\u{a788}'), ('\u{a78b}', '\u{a78e}'), ('\u{a790}', '\u{a7ad}'), + ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}', + '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), + ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', + '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a90a}', '\u{a925}'), + ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}', + '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9e4}'), + ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', + '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), + ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', + '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), + ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', + '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaea}'), + ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', + '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), + ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', + '\u{ab5f}'), ('\u{ab64}', '\u{ab65}'), ('\u{abc0}', '\u{abe2}'), + ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', + '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), + ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', + '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), + ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', + '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), + ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), ('\u{fd50}', + '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), + ('\u{fe71}', '\u{fe71}'), ('\u{fe73}', '\u{fe73}'), ('\u{fe77}', + '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'), + ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff21}', + '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ff9d}'), + ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', + '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), + ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', + '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), + ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', + '\u{10174}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), + ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), ('\u{10350}', + '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), + ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', + '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), + ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', + '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), + ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', + '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), + ('\u{10880}', '\u{1089e}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', + '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), + ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', + '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), + ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', + '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), + ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', + '\u{10c48}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'), + ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11150}', + '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'), + ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{11200}', + '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{112b0}', '\u{112de}'), + ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', + '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), + ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), ('\u{1135d}', + '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'), + ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{11600}', + '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116aa}'), + ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', + '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{12400}', '\u{1246e}'), + ('\u{13000}', '\u{1342e}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', + '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), + ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', + '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), + ('\u{16f93}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', + '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), + ('\u{1bc90}', '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', + '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), + ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', + '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), + ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', + '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), + ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', + '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), + ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', + '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), + ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', + '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), + ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', + '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), + ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', + '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), + ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', + '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), + ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', + '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), + ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', + '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), + ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', + '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), + ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', + '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), + ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', + '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}') + ]; + +} + +pub mod script { + pub const Arabic_table: &'static [(char, char)] = &[ + ('\u{600}', '\u{604}'), ('\u{606}', '\u{60b}'), ('\u{60d}', '\u{61a}'), + ('\u{61e}', '\u{61e}'), ('\u{620}', '\u{63f}'), ('\u{641}', '\u{64a}'), + ('\u{656}', '\u{65f}'), ('\u{66a}', '\u{66f}'), ('\u{671}', '\u{6dc}'), + ('\u{6de}', '\u{6ff}'), ('\u{750}', '\u{77f}'), ('\u{8a0}', '\u{8b2}'), + ('\u{8e4}', '\u{8ff}'), ('\u{fb50}', '\u{fbc1}'), ('\u{fbd3}', + '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), + ('\u{fdf0}', '\u{fdfd}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', + '\u{fefc}'), ('\u{10e60}', '\u{10e7e}'), ('\u{1ee00}', '\u{1ee03}'), + ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', + '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), + ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', + '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), + ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', + '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), + ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', + '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), + ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', + '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), + ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', + '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), + ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{1eef0}', + '\u{1eef1}') + ]; + + pub const Armenian_table: &'static [(char, char)] = &[ + ('\u{531}', '\u{556}'), ('\u{559}', '\u{55f}'), ('\u{561}', '\u{587}'), + ('\u{58a}', '\u{58a}'), ('\u{58d}', '\u{58f}'), ('\u{fb13}', + '\u{fb17}') + ]; + + pub const Avestan_table: &'static [(char, char)] = &[ + ('\u{10b00}', '\u{10b35}'), ('\u{10b39}', '\u{10b3f}') + ]; + + pub const Balinese_table: &'static [(char, char)] = &[ + ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', '\u{1b7c}') + ]; + + pub const Bamum_table: &'static [(char, char)] = &[ + ('\u{a6a0}', '\u{a6f7}'), ('\u{16800}', '\u{16a38}') + ]; + + pub const Bassa_Vah_table: &'static [(char, char)] = &[ + ('\u{16ad0}', '\u{16aed}'), ('\u{16af0}', '\u{16af5}') + ]; + + pub const Batak_table: &'static [(char, char)] = &[ + ('\u{1bc0}', '\u{1bf3}'), ('\u{1bfc}', '\u{1bff}') + ]; + + pub const Bengali_table: &'static [(char, char)] = &[ + ('\u{980}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), + ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), + ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), + ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), + ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9fb}') + ]; + + pub const Bopomofo_table: &'static [(char, char)] = &[ + ('\u{2ea}', '\u{2eb}'), ('\u{3105}', '\u{312d}'), ('\u{31a0}', + '\u{31ba}') + ]; + + pub const Brahmi_table: &'static [(char, char)] = &[ + ('\u{11000}', '\u{1104d}'), ('\u{11052}', '\u{1106f}'), ('\u{1107f}', + '\u{1107f}') + ]; + + pub const Braille_table: &'static [(char, char)] = &[ + ('\u{2800}', '\u{28ff}') + ]; + + pub const Buginese_table: &'static [(char, char)] = &[ + ('\u{1a00}', '\u{1a1b}'), ('\u{1a1e}', '\u{1a1f}') + ]; + + pub const Buhid_table: &'static [(char, char)] = &[ + ('\u{1740}', '\u{1753}') + ]; + + pub const Canadian_Aboriginal_table: &'static [(char, char)] = &[ + ('\u{1400}', '\u{167f}'), ('\u{18b0}', '\u{18f5}') + ]; + + pub const Carian_table: &'static [(char, char)] = &[ + ('\u{102a0}', '\u{102d0}') + ]; + + pub const Caucasian_Albanian_table: &'static [(char, char)] = &[ + ('\u{10530}', '\u{10563}'), ('\u{1056f}', '\u{1056f}') + ]; + + pub const Chakma_table: &'static [(char, char)] = &[ + ('\u{11100}', '\u{11134}'), ('\u{11136}', '\u{11143}') + ]; + + pub const Cham_table: &'static [(char, char)] = &[ + ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa50}', + '\u{aa59}'), ('\u{aa5c}', '\u{aa5f}') + ]; + + pub const Cherokee_table: &'static [(char, char)] = &[ + ('\u{13a0}', '\u{13f4}') + ]; + + pub const Common_table: &'static [(char, char)] = &[ + ('\u{0}', '\u{40}'), ('\u{5b}', '\u{60}'), ('\u{7b}', '\u{a9}'), + ('\u{ab}', '\u{b9}'), ('\u{bb}', '\u{bf}'), ('\u{d7}', '\u{d7}'), + ('\u{f7}', '\u{f7}'), ('\u{2b9}', '\u{2df}'), ('\u{2e5}', '\u{2e9}'), + ('\u{2ec}', '\u{2ff}'), ('\u{374}', '\u{374}'), ('\u{37e}', '\u{37e}'), + ('\u{385}', '\u{385}'), ('\u{387}', '\u{387}'), ('\u{589}', '\u{589}'), + ('\u{605}', '\u{605}'), ('\u{60c}', '\u{60c}'), ('\u{61b}', '\u{61c}'), + ('\u{61f}', '\u{61f}'), ('\u{640}', '\u{640}'), ('\u{660}', '\u{669}'), + ('\u{6dd}', '\u{6dd}'), ('\u{964}', '\u{965}'), ('\u{e3f}', '\u{e3f}'), + ('\u{fd5}', '\u{fd8}'), ('\u{10fb}', '\u{10fb}'), ('\u{16eb}', + '\u{16ed}'), ('\u{1735}', '\u{1736}'), ('\u{1802}', '\u{1803}'), + ('\u{1805}', '\u{1805}'), ('\u{1cd3}', '\u{1cd3}'), ('\u{1ce1}', + '\u{1ce1}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf3}'), + ('\u{1cf5}', '\u{1cf6}'), ('\u{2000}', '\u{200b}'), ('\u{200e}', + '\u{2064}'), ('\u{2066}', '\u{2070}'), ('\u{2074}', '\u{207e}'), + ('\u{2080}', '\u{208e}'), ('\u{20a0}', '\u{20bd}'), ('\u{2100}', + '\u{2125}'), ('\u{2127}', '\u{2129}'), ('\u{212c}', '\u{2131}'), + ('\u{2133}', '\u{214d}'), ('\u{214f}', '\u{215f}'), ('\u{2189}', + '\u{2189}'), ('\u{2190}', '\u{23fa}'), ('\u{2400}', '\u{2426}'), + ('\u{2440}', '\u{244a}'), ('\u{2460}', '\u{27ff}'), ('\u{2900}', + '\u{2b73}'), ('\u{2b76}', '\u{2b95}'), ('\u{2b98}', '\u{2bb9}'), + ('\u{2bbd}', '\u{2bc8}'), ('\u{2bca}', '\u{2bd1}'), ('\u{2e00}', + '\u{2e42}'), ('\u{2ff0}', '\u{2ffb}'), ('\u{3000}', '\u{3004}'), + ('\u{3006}', '\u{3006}'), ('\u{3008}', '\u{3020}'), ('\u{3030}', + '\u{3037}'), ('\u{303c}', '\u{303f}'), ('\u{309b}', '\u{309c}'), + ('\u{30a0}', '\u{30a0}'), ('\u{30fb}', '\u{30fc}'), ('\u{3190}', + '\u{319f}'), ('\u{31c0}', '\u{31e3}'), ('\u{3220}', '\u{325f}'), + ('\u{327f}', '\u{32cf}'), ('\u{3358}', '\u{33ff}'), ('\u{4dc0}', + '\u{4dff}'), ('\u{a700}', '\u{a721}'), ('\u{a788}', '\u{a78a}'), + ('\u{a830}', '\u{a839}'), ('\u{a92e}', '\u{a92e}'), ('\u{a9cf}', + '\u{a9cf}'), ('\u{ab5b}', '\u{ab5b}'), ('\u{fd3e}', '\u{fd3f}'), + ('\u{fe10}', '\u{fe19}'), ('\u{fe30}', '\u{fe52}'), ('\u{fe54}', + '\u{fe66}'), ('\u{fe68}', '\u{fe6b}'), ('\u{feff}', '\u{feff}'), + ('\u{ff01}', '\u{ff20}'), ('\u{ff3b}', '\u{ff40}'), ('\u{ff5b}', + '\u{ff65}'), ('\u{ff70}', '\u{ff70}'), ('\u{ff9e}', '\u{ff9f}'), + ('\u{ffe0}', '\u{ffe6}'), ('\u{ffe8}', '\u{ffee}'), ('\u{fff9}', + '\u{fffd}'), ('\u{10100}', '\u{10102}'), ('\u{10107}', '\u{10133}'), + ('\u{10137}', '\u{1013f}'), ('\u{10190}', '\u{1019b}'), ('\u{101d0}', + '\u{101fc}'), ('\u{102e1}', '\u{102fb}'), ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d000}', '\u{1d0f5}'), ('\u{1d100}', '\u{1d126}'), ('\u{1d129}', + '\u{1d166}'), ('\u{1d16a}', '\u{1d17a}'), ('\u{1d183}', '\u{1d184}'), + ('\u{1d18c}', '\u{1d1a9}'), ('\u{1d1ae}', '\u{1d1dd}'), ('\u{1d300}', + '\u{1d356}'), ('\u{1d360}', '\u{1d371}'), ('\u{1d400}', '\u{1d454}'), + ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', + '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), + ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', + '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), + ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', + '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), + ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', + '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d7cb}'), ('\u{1d7ce}', '\u{1d7ff}'), + ('\u{1f000}', '\u{1f02b}'), ('\u{1f030}', '\u{1f093}'), ('\u{1f0a0}', + '\u{1f0ae}'), ('\u{1f0b1}', '\u{1f0bf}'), ('\u{1f0c1}', '\u{1f0cf}'), + ('\u{1f0d1}', '\u{1f0f5}'), ('\u{1f100}', '\u{1f10c}'), ('\u{1f110}', + '\u{1f12e}'), ('\u{1f130}', '\u{1f16b}'), ('\u{1f170}', '\u{1f19a}'), + ('\u{1f1e6}', '\u{1f1ff}'), ('\u{1f201}', '\u{1f202}'), ('\u{1f210}', + '\u{1f23a}'), ('\u{1f240}', '\u{1f248}'), ('\u{1f250}', '\u{1f251}'), + ('\u{1f300}', '\u{1f32c}'), ('\u{1f330}', '\u{1f37d}'), ('\u{1f380}', + '\u{1f3ce}'), ('\u{1f3d4}', '\u{1f3f7}'), ('\u{1f400}', '\u{1f4fe}'), + ('\u{1f500}', '\u{1f54a}'), ('\u{1f550}', '\u{1f579}'), ('\u{1f57b}', + '\u{1f5a3}'), ('\u{1f5a5}', '\u{1f642}'), ('\u{1f645}', '\u{1f6cf}'), + ('\u{1f6e0}', '\u{1f6ec}'), ('\u{1f6f0}', '\u{1f6f3}'), ('\u{1f700}', + '\u{1f773}'), ('\u{1f780}', '\u{1f7d4}'), ('\u{1f800}', '\u{1f80b}'), + ('\u{1f810}', '\u{1f847}'), ('\u{1f850}', '\u{1f859}'), ('\u{1f860}', + '\u{1f887}'), ('\u{1f890}', '\u{1f8ad}'), ('\u{e0001}', '\u{e0001}'), + ('\u{e0020}', '\u{e007f}') + ]; + + pub const Coptic_table: &'static [(char, char)] = &[ + ('\u{3e2}', '\u{3ef}'), ('\u{2c80}', '\u{2cf3}'), ('\u{2cf9}', + '\u{2cff}') + ]; + + pub const Cuneiform_table: &'static [(char, char)] = &[ + ('\u{12000}', '\u{12398}'), ('\u{12400}', '\u{1246e}'), ('\u{12470}', + '\u{12474}') + ]; + + pub const Cypriot_table: &'static [(char, char)] = &[ + ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', + '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), + ('\u{1083f}', '\u{1083f}') + ]; + + pub const Cyrillic_table: &'static [(char, char)] = &[ + ('\u{400}', '\u{484}'), ('\u{487}', '\u{52f}'), ('\u{1d2b}', + '\u{1d2b}'), ('\u{1d78}', '\u{1d78}'), ('\u{2de0}', '\u{2dff}'), + ('\u{a640}', '\u{a69d}'), ('\u{a69f}', '\u{a69f}') + ]; + + pub const Deseret_table: &'static [(char, char)] = &[ + ('\u{10400}', '\u{1044f}') + ]; + + pub const Devanagari_table: &'static [(char, char)] = &[ + ('\u{900}', '\u{950}'), ('\u{953}', '\u{963}'), ('\u{966}', '\u{97f}'), + ('\u{a8e0}', '\u{a8fb}') + ]; + + pub const Duployan_table: &'static [(char, char)] = &[ + ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', + '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9c}', '\u{1bc9f}') + ]; + + pub const Egyptian_Hieroglyphs_table: &'static [(char, char)] = &[ + ('\u{13000}', '\u{1342e}') + ]; + + pub const Elbasan_table: &'static [(char, char)] = &[ + ('\u{10500}', '\u{10527}') + ]; + + pub const Ethiopic_table: &'static [(char, char)] = &[ + ('\u{1200}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', + '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), + ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', + '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), + ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', + '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), + ('\u{1318}', '\u{135a}'), ('\u{135d}', '\u{137c}'), ('\u{1380}', + '\u{1399}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), + ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', + '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), + ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{ab01}', + '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), + ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}') + ]; + + pub const Georgian_table: &'static [(char, char)] = &[ + ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', + '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{10ff}'), + ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', + '\u{2d2d}') + ]; + + pub const Glagolitic_table: &'static [(char, char)] = &[ + ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}') + ]; + + pub const Gothic_table: &'static [(char, char)] = &[ + ('\u{10330}', '\u{1034a}') + ]; + + pub const Grantha_table: &'static [(char, char)] = &[ + ('\u{11301}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', + '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), + ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133c}', + '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), + ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', + '\u{1136c}'), ('\u{11370}', '\u{11374}') + ]; + + pub const Greek_table: &'static [(char, char)] = &[ + ('\u{370}', '\u{373}'), ('\u{375}', '\u{377}'), ('\u{37a}', '\u{37d}'), + ('\u{37f}', '\u{37f}'), ('\u{384}', '\u{384}'), ('\u{386}', '\u{386}'), + ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), + ('\u{3a3}', '\u{3e1}'), ('\u{3f0}', '\u{3ff}'), ('\u{1d26}', + '\u{1d2a}'), ('\u{1d5d}', '\u{1d61}'), ('\u{1d66}', '\u{1d6a}'), + ('\u{1dbf}', '\u{1dbf}'), ('\u{1f00}', '\u{1f15}'), ('\u{1f18}', + '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), + ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', + '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), + ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fc4}'), ('\u{1fc6}', + '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fdd}', '\u{1fef}'), + ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffe}'), ('\u{2126}', + '\u{2126}'), ('\u{ab65}', '\u{ab65}'), ('\u{10140}', '\u{1018c}'), + ('\u{101a0}', '\u{101a0}'), ('\u{1d200}', '\u{1d245}') + ]; + + pub const Gujarati_table: &'static [(char, char)] = &[ + ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), + ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), + ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), + ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), + ('\u{ae6}', '\u{af1}') + ]; + + pub const Gurmukhi_table: &'static [(char, char)] = &[ + ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), + ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), + ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), + ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), + ('\u{a66}', '\u{a75}') + ]; + + pub const Han_table: &'static [(char, char)] = &[ + ('\u{2e80}', '\u{2e99}'), ('\u{2e9b}', '\u{2ef3}'), ('\u{2f00}', + '\u{2fd5}'), ('\u{3005}', '\u{3005}'), ('\u{3007}', '\u{3007}'), + ('\u{3021}', '\u{3029}'), ('\u{3038}', '\u{303b}'), ('\u{3400}', + '\u{4db5}'), ('\u{4e00}', '\u{9fcc}'), ('\u{f900}', '\u{fa6d}'), + ('\u{fa70}', '\u{fad9}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', + '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}') + ]; + + pub const Hangul_table: &'static [(char, char)] = &[ + ('\u{1100}', '\u{11ff}'), ('\u{302e}', '\u{302f}'), ('\u{3131}', + '\u{318e}'), ('\u{3200}', '\u{321e}'), ('\u{3260}', '\u{327e}'), + ('\u{a960}', '\u{a97c}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', + '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{ffa0}', '\u{ffbe}'), + ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', + '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}') + ]; + + pub const Hanunoo_table: &'static [(char, char)] = &[ + ('\u{1720}', '\u{1734}') + ]; + + pub const Hebrew_table: &'static [(char, char)] = &[ + ('\u{591}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f4}'), + ('\u{fb1d}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', + '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), + ('\u{fb46}', '\u{fb4f}') + ]; + + pub const Hiragana_table: &'static [(char, char)] = &[ + ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{1b001}', + '\u{1b001}'), ('\u{1f200}', '\u{1f200}') + ]; + + pub const Imperial_Aramaic_table: &'static [(char, char)] = &[ + ('\u{10840}', '\u{10855}'), ('\u{10857}', '\u{1085f}') + ]; + + pub const Inherited_table: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), ('\u{485}', '\u{486}'), ('\u{64b}', '\u{655}'), + ('\u{670}', '\u{670}'), ('\u{951}', '\u{952}'), ('\u{1ab0}', + '\u{1abe}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf4}', + '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), + ('\u{1dfc}', '\u{1dff}'), ('\u{200c}', '\u{200d}'), ('\u{20d0}', + '\u{20f0}'), ('\u{302a}', '\u{302d}'), ('\u{3099}', '\u{309a}'), + ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2d}'), ('\u{101fd}', + '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{1d167}', '\u{1d169}'), + ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', + '\u{1d1ad}'), ('\u{e0100}', '\u{e01ef}') + ]; + + pub const Inscriptional_Pahlavi_table: &'static [(char, char)] = &[ + ('\u{10b60}', '\u{10b72}'), ('\u{10b78}', '\u{10b7f}') + ]; + + pub const Inscriptional_Parthian_table: &'static [(char, char)] = &[ + ('\u{10b40}', '\u{10b55}'), ('\u{10b58}', '\u{10b5f}') + ]; + + pub const Javanese_table: &'static [(char, char)] = &[ + ('\u{a980}', '\u{a9cd}'), ('\u{a9d0}', '\u{a9d9}'), ('\u{a9de}', + '\u{a9df}') + ]; + + pub const Kaithi_table: &'static [(char, char)] = &[ + ('\u{11080}', '\u{110c1}') + ]; + + pub const Kannada_table: &'static [(char, char)] = &[ + ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), + ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), + ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), + ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}') + ]; + + pub const Katakana_table: &'static [(char, char)] = &[ + ('\u{30a1}', '\u{30fa}'), ('\u{30fd}', '\u{30ff}'), ('\u{31f0}', + '\u{31ff}'), ('\u{32d0}', '\u{32fe}'), ('\u{3300}', '\u{3357}'), + ('\u{ff66}', '\u{ff6f}'), ('\u{ff71}', '\u{ff9d}'), ('\u{1b000}', + '\u{1b000}') + ]; + + pub const Kayah_Li_table: &'static [(char, char)] = &[ + ('\u{a900}', '\u{a92d}'), ('\u{a92f}', '\u{a92f}') + ]; + + pub const Kharoshthi_table: &'static [(char, char)] = &[ + ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', + '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), + ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a47}'), ('\u{10a50}', + '\u{10a58}') + ]; + + pub const Khmer_table: &'static [(char, char)] = &[ + ('\u{1780}', '\u{17dd}'), ('\u{17e0}', '\u{17e9}'), ('\u{17f0}', + '\u{17f9}'), ('\u{19e0}', '\u{19ff}') + ]; + + pub const Khojki_table: &'static [(char, char)] = &[ + ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1123d}') + ]; + + pub const Khudawadi_table: &'static [(char, char)] = &[ + ('\u{112b0}', '\u{112ea}'), ('\u{112f0}', '\u{112f9}') + ]; + + pub const Lao_table: &'static [(char, char)] = &[ + ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), + ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), + ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), + ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), + ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), + ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), ('\u{edc}', '\u{edf}') + ]; + + pub const Latin_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), + ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), + ('\u{f8}', '\u{2b8}'), ('\u{2e0}', '\u{2e4}'), ('\u{1d00}', '\u{1d25}'), + ('\u{1d2c}', '\u{1d5c}'), ('\u{1d62}', '\u{1d65}'), ('\u{1d6b}', + '\u{1d77}'), ('\u{1d79}', '\u{1dbe}'), ('\u{1e00}', '\u{1eff}'), + ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', + '\u{209c}'), ('\u{212a}', '\u{212b}'), ('\u{2132}', '\u{2132}'), + ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c60}', + '\u{2c7f}'), ('\u{a722}', '\u{a787}'), ('\u{a78b}', '\u{a78e}'), + ('\u{a790}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', + '\u{a7ff}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab5f}'), + ('\u{ab64}', '\u{ab64}'), ('\u{fb00}', '\u{fb06}'), ('\u{ff21}', + '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}') + ]; + + pub const Lepcha_table: &'static [(char, char)] = &[ + ('\u{1c00}', '\u{1c37}'), ('\u{1c3b}', '\u{1c49}'), ('\u{1c4d}', + '\u{1c4f}') + ]; + + pub const Limbu_table: &'static [(char, char)] = &[ + ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', + '\u{193b}'), ('\u{1940}', '\u{1940}'), ('\u{1944}', '\u{194f}') + ]; + + pub const Linear_A_table: &'static [(char, char)] = &[ + ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', + '\u{10767}') + ]; + + pub const Linear_B_table: &'static [(char, char)] = &[ + ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', + '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), + ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}') + ]; + + pub const Lisu_table: &'static [(char, char)] = &[ + ('\u{a4d0}', '\u{a4ff}') + ]; + + pub const Lycian_table: &'static [(char, char)] = &[ + ('\u{10280}', '\u{1029c}') + ]; + + pub const Lydian_table: &'static [(char, char)] = &[ + ('\u{10920}', '\u{10939}'), ('\u{1093f}', '\u{1093f}') + ]; + + pub const Mahajani_table: &'static [(char, char)] = &[ + ('\u{11150}', '\u{11176}') + ]; + + pub const Malayalam_table: &'static [(char, char)] = &[ + ('\u{d01}', '\u{d03}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), + ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), + ('\u{d4a}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), ('\u{d60}', '\u{d63}'), + ('\u{d66}', '\u{d75}'), ('\u{d79}', '\u{d7f}') + ]; + + pub const Mandaic_table: &'static [(char, char)] = &[ + ('\u{840}', '\u{85b}'), ('\u{85e}', '\u{85e}') + ]; + + pub const Manichaean_table: &'static [(char, char)] = &[ + ('\u{10ac0}', '\u{10ae6}'), ('\u{10aeb}', '\u{10af6}') + ]; + + pub const Meetei_Mayek_table: &'static [(char, char)] = &[ + ('\u{aae0}', '\u{aaf6}'), ('\u{abc0}', '\u{abed}'), ('\u{abf0}', + '\u{abf9}') + ]; + + pub const Mende_Kikakui_table: &'static [(char, char)] = &[ + ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8c7}', '\u{1e8d6}') + ]; + + pub const Meroitic_Cursive_table: &'static [(char, char)] = &[ + ('\u{109a0}', '\u{109b7}'), ('\u{109be}', '\u{109bf}') + ]; + + pub const Meroitic_Hieroglyphs_table: &'static [(char, char)] = &[ + ('\u{10980}', '\u{1099f}') + ]; + + pub const Miao_table: &'static [(char, char)] = &[ + ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', + '\u{16f9f}') + ]; + + pub const Modi_table: &'static [(char, char)] = &[ + ('\u{11600}', '\u{11644}'), ('\u{11650}', '\u{11659}') + ]; + + pub const Mongolian_table: &'static [(char, char)] = &[ + ('\u{1800}', '\u{1801}'), ('\u{1804}', '\u{1804}'), ('\u{1806}', + '\u{180e}'), ('\u{1810}', '\u{1819}'), ('\u{1820}', '\u{1877}'), + ('\u{1880}', '\u{18aa}') + ]; + + pub const Mro_table: &'static [(char, char)] = &[ + ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16a6e}', + '\u{16a6f}') + ]; + + pub const Myanmar_table: &'static [(char, char)] = &[ + ('\u{1000}', '\u{109f}'), ('\u{a9e0}', '\u{a9fe}'), ('\u{aa60}', + '\u{aa7f}') + ]; + + pub const Nabataean_table: &'static [(char, char)] = &[ + ('\u{10880}', '\u{1089e}'), ('\u{108a7}', '\u{108af}') + ]; + + pub const New_Tai_Lue_table: &'static [(char, char)] = &[ + ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{19d0}', + '\u{19da}'), ('\u{19de}', '\u{19df}') + ]; + + pub const Nko_table: &'static [(char, char)] = &[ + ('\u{7c0}', '\u{7fa}') + ]; + + pub const Ogham_table: &'static [(char, char)] = &[ + ('\u{1680}', '\u{169c}') + ]; + + pub const Ol_Chiki_table: &'static [(char, char)] = &[ + ('\u{1c50}', '\u{1c7f}') + ]; + + pub const Old_Italic_table: &'static [(char, char)] = &[ + ('\u{10300}', '\u{10323}') + ]; + + pub const Old_North_Arabian_table: &'static [(char, char)] = &[ + ('\u{10a80}', '\u{10a9f}') + ]; + + pub const Old_Permic_table: &'static [(char, char)] = &[ + ('\u{10350}', '\u{1037a}') + ]; + + pub const Old_Persian_table: &'static [(char, char)] = &[ + ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103d5}') + ]; + + pub const Old_South_Arabian_table: &'static [(char, char)] = &[ + ('\u{10a60}', '\u{10a7f}') + ]; + + pub const Old_Turkic_table: &'static [(char, char)] = &[ + ('\u{10c00}', '\u{10c48}') + ]; + + pub const Oriya_table: &'static [(char, char)] = &[ + ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), + ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), + ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'), ('\u{b47}', '\u{b48}'), + ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), + ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b77}') + ]; + + pub const Osmanya_table: &'static [(char, char)] = &[ + ('\u{10480}', '\u{1049d}'), ('\u{104a0}', '\u{104a9}') + ]; + + pub const Pahawh_Hmong_table: &'static [(char, char)] = &[ + ('\u{16b00}', '\u{16b45}'), ('\u{16b50}', '\u{16b59}'), ('\u{16b5b}', + '\u{16b61}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}') + ]; + + pub const Palmyrene_table: &'static [(char, char)] = &[ + ('\u{10860}', '\u{1087f}') + ]; + + pub const Pau_Cin_Hau_table: &'static [(char, char)] = &[ + ('\u{11ac0}', '\u{11af8}') + ]; + + pub const Phags_Pa_table: &'static [(char, char)] = &[ + ('\u{a840}', '\u{a877}') + ]; + + pub const Phoenician_table: &'static [(char, char)] = &[ + ('\u{10900}', '\u{1091b}'), ('\u{1091f}', '\u{1091f}') + ]; + + pub const Psalter_Pahlavi_table: &'static [(char, char)] = &[ + ('\u{10b80}', '\u{10b91}'), ('\u{10b99}', '\u{10b9c}'), ('\u{10ba9}', + '\u{10baf}') + ]; + + pub const Rejang_table: &'static [(char, char)] = &[ + ('\u{a930}', '\u{a953}'), ('\u{a95f}', '\u{a95f}') + ]; + + pub const Runic_table: &'static [(char, char)] = &[ + ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}') + ]; + + pub const Samaritan_table: &'static [(char, char)] = &[ + ('\u{800}', '\u{82d}'), ('\u{830}', '\u{83e}') + ]; + + pub const Saurashtra_table: &'static [(char, char)] = &[ + ('\u{a880}', '\u{a8c4}'), ('\u{a8ce}', '\u{a8d9}') + ]; + + pub const Sharada_table: &'static [(char, char)] = &[ + ('\u{11180}', '\u{111c8}'), ('\u{111cd}', '\u{111cd}'), ('\u{111d0}', + '\u{111da}') + ]; + + pub const Shavian_table: &'static [(char, char)] = &[ + ('\u{10450}', '\u{1047f}') + ]; + + pub const Siddham_table: &'static [(char, char)] = &[ + ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115c9}') + ]; + + pub const Sinhala_table: &'static [(char, char)] = &[ + ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), + ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), + ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), + ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), ('\u{df2}', '\u{df4}'), + ('\u{111e1}', '\u{111f4}') + ]; + + pub const Sora_Sompeng_table: &'static [(char, char)] = &[ + ('\u{110d0}', '\u{110e8}'), ('\u{110f0}', '\u{110f9}') + ]; + + pub const Sundanese_table: &'static [(char, char)] = &[ + ('\u{1b80}', '\u{1bbf}'), ('\u{1cc0}', '\u{1cc7}') + ]; + + pub const Syloti_Nagri_table: &'static [(char, char)] = &[ + ('\u{a800}', '\u{a82b}') + ]; + + pub const Syriac_table: &'static [(char, char)] = &[ + ('\u{700}', '\u{70d}'), ('\u{70f}', '\u{74a}'), ('\u{74d}', '\u{74f}') + ]; + + pub const Tagalog_table: &'static [(char, char)] = &[ + ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1714}') + ]; + + pub const Tagbanwa_table: &'static [(char, char)] = &[ + ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', + '\u{1773}') + ]; + + pub const Tai_Le_table: &'static [(char, char)] = &[ + ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}') + ]; + + pub const Tai_Tham_table: &'static [(char, char)] = &[ + ('\u{1a20}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', + '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1aa0}', '\u{1aad}') + ]; + + pub const Tai_Viet_table: &'static [(char, char)] = &[ + ('\u{aa80}', '\u{aac2}'), ('\u{aadb}', '\u{aadf}') + ]; + + pub const Takri_table: &'static [(char, char)] = &[ + ('\u{11680}', '\u{116b7}'), ('\u{116c0}', '\u{116c9}') + ]; + + pub const Tamil_table: &'static [(char, char)] = &[ + ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), + ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), + ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), + ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), + ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), + ('\u{be6}', '\u{bfa}') + ]; + + pub const Telugu_table: &'static [(char, char)] = &[ + ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), + ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), + ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), + ('\u{c58}', '\u{c59}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), + ('\u{c78}', '\u{c7f}') + ]; + + pub const Thaana_table: &'static [(char, char)] = &[ + ('\u{780}', '\u{7b1}') + ]; + + pub const Thai_table: &'static [(char, char)] = &[ + ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e5b}') + ]; + + pub const Tibetan_table: &'static [(char, char)] = &[ + ('\u{f00}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), ('\u{fbe}', '\u{fcc}'), ('\u{fce}', '\u{fd4}'), + ('\u{fd9}', '\u{fda}') + ]; + + pub const Tifinagh_table: &'static [(char, char)] = &[ + ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d70}'), ('\u{2d7f}', + '\u{2d7f}') + ]; + + pub const Tirhuta_table: &'static [(char, char)] = &[ + ('\u{11480}', '\u{114c7}'), ('\u{114d0}', '\u{114d9}') + ]; + + pub const Ugaritic_table: &'static [(char, char)] = &[ + ('\u{10380}', '\u{1039d}'), ('\u{1039f}', '\u{1039f}') + ]; + + pub const Vai_table: &'static [(char, char)] = &[ + ('\u{a500}', '\u{a62b}') + ]; + + pub const Warang_Citi_table: &'static [(char, char)] = &[ + ('\u{118a0}', '\u{118f2}'), ('\u{118ff}', '\u{118ff}') + ]; + + pub const Yi_table: &'static [(char, char)] = &[ + ('\u{a000}', '\u{a48c}'), ('\u{a490}', '\u{a4c6}') + ]; + +} + +pub mod property { + pub const Join_Control_table: &'static [(char, char)] = &[ + ('\u{200c}', '\u{200d}') + ]; + + pub const Noncharacter_Code_Point_table: &'static [(char, char)] = &[ + ('\u{fdd0}', '\u{fdef}'), ('\u{fffe}', '\u{ffff}'), ('\u{1fffe}', + '\u{1ffff}'), ('\u{2fffe}', '\u{2ffff}'), ('\u{3fffe}', '\u{3ffff}'), + ('\u{4fffe}', '\u{4ffff}'), ('\u{5fffe}', '\u{5ffff}'), ('\u{6fffe}', + '\u{6ffff}'), ('\u{7fffe}', '\u{7ffff}'), ('\u{8fffe}', '\u{8ffff}'), + ('\u{9fffe}', '\u{9ffff}'), ('\u{afffe}', '\u{affff}'), ('\u{bfffe}', + '\u{bffff}'), ('\u{cfffe}', '\u{cffff}'), ('\u{dfffe}', '\u{dffff}'), + ('\u{efffe}', '\u{effff}'), ('\u{ffffe}', '\u{fffff}'), ('\u{10fffe}', + '\u{10ffff}') + ]; + + pub const White_Space_table: &'static [(char, char)] = &[ + ('\u{9}', '\u{d}'), ('\u{20}', '\u{20}'), ('\u{85}', '\u{85}'), + ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', + '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}') + ]; + +} + +pub mod regex { + pub const UNICODE_CLASSES: &'static [(&'static str, &'static [(char, char)])] = &[ + ("Alphabetic", super::derived_property::Alphabetic_table), ("Arabic", + super::script::Arabic_table), ("Armenian", + super::script::Armenian_table), ("Avestan", + super::script::Avestan_table), ("Balinese", + super::script::Balinese_table), ("Bamum", super::script::Bamum_table), + ("Bassa_Vah", super::script::Bassa_Vah_table), ("Batak", + super::script::Batak_table), ("Bengali", super::script::Bengali_table), + ("Bopomofo", super::script::Bopomofo_table), ("Brahmi", + super::script::Brahmi_table), ("Braille", super::script::Braille_table), + ("Buginese", super::script::Buginese_table), ("Buhid", + super::script::Buhid_table), ("C", super::general_category::C_table), + ("Canadian_Aboriginal", super::script::Canadian_Aboriginal_table), + ("Carian", super::script::Carian_table), ("Caucasian_Albanian", + super::script::Caucasian_Albanian_table), ("Cc", + super::general_category::Cc_table), ("Cf", + super::general_category::Cf_table), ("Chakma", + super::script::Chakma_table), ("Cham", super::script::Cham_table), + ("Cherokee", super::script::Cherokee_table), ("Cn", + super::general_category::Cn_table), ("Co", + super::general_category::Co_table), ("Common", + super::script::Common_table), ("Coptic", super::script::Coptic_table), + ("Cuneiform", super::script::Cuneiform_table), ("Cypriot", + super::script::Cypriot_table), ("Cyrillic", + super::script::Cyrillic_table), ("Default_Ignorable_Code_Point", + super::derived_property::Default_Ignorable_Code_Point_table), + ("Deseret", super::script::Deseret_table), ("Devanagari", + super::script::Devanagari_table), ("Duployan", + super::script::Duployan_table), ("Egyptian_Hieroglyphs", + super::script::Egyptian_Hieroglyphs_table), ("Elbasan", + super::script::Elbasan_table), ("Ethiopic", + super::script::Ethiopic_table), ("Georgian", + super::script::Georgian_table), ("Glagolitic", + super::script::Glagolitic_table), ("Gothic", + super::script::Gothic_table), ("Grantha", super::script::Grantha_table), + ("Grapheme_Extend", super::derived_property::Grapheme_Extend_table), + ("Greek", super::script::Greek_table), ("Gujarati", + super::script::Gujarati_table), ("Gurmukhi", + super::script::Gurmukhi_table), ("Han", super::script::Han_table), + ("Hangul", super::script::Hangul_table), ("Hanunoo", + super::script::Hanunoo_table), ("Hebrew", super::script::Hebrew_table), + ("Hiragana", super::script::Hiragana_table), ("Imperial_Aramaic", + super::script::Imperial_Aramaic_table), ("Inherited", + super::script::Inherited_table), ("Inscriptional_Pahlavi", + super::script::Inscriptional_Pahlavi_table), ("Inscriptional_Parthian", + super::script::Inscriptional_Parthian_table), ("Javanese", + super::script::Javanese_table), ("Join_Control", + super::property::Join_Control_table), ("Kaithi", + super::script::Kaithi_table), ("Kannada", super::script::Kannada_table), + ("Katakana", super::script::Katakana_table), ("Kayah_Li", + super::script::Kayah_Li_table), ("Kharoshthi", + super::script::Kharoshthi_table), ("Khmer", super::script::Khmer_table), + ("Khojki", super::script::Khojki_table), ("Khudawadi", + super::script::Khudawadi_table), ("L", + super::general_category::L_table), ("LC", + super::general_category::LC_table), ("Lao", super::script::Lao_table), + ("Latin", super::script::Latin_table), ("Lepcha", + super::script::Lepcha_table), ("Limbu", super::script::Limbu_table), + ("Linear_A", super::script::Linear_A_table), ("Linear_B", + super::script::Linear_B_table), ("Lisu", super::script::Lisu_table), + ("Ll", super::general_category::Ll_table), ("Lm", + super::general_category::Lm_table), ("Lo", + super::general_category::Lo_table), ("Lowercase", + super::derived_property::Lowercase_table), ("Lt", + super::general_category::Lt_table), ("Lu", + super::general_category::Lu_table), ("Lycian", + super::script::Lycian_table), ("Lydian", super::script::Lydian_table), + ("M", super::general_category::M_table), ("Mahajani", + super::script::Mahajani_table), ("Malayalam", + super::script::Malayalam_table), ("Mandaic", + super::script::Mandaic_table), ("Manichaean", + super::script::Manichaean_table), ("Mc", + super::general_category::Mc_table), ("Me", + super::general_category::Me_table), ("Meetei_Mayek", + super::script::Meetei_Mayek_table), ("Mende_Kikakui", + super::script::Mende_Kikakui_table), ("Meroitic_Cursive", + super::script::Meroitic_Cursive_table), ("Meroitic_Hieroglyphs", + super::script::Meroitic_Hieroglyphs_table), ("Miao", + super::script::Miao_table), ("Mn", super::general_category::Mn_table), + ("Modi", super::script::Modi_table), ("Mongolian", + super::script::Mongolian_table), ("Mro", super::script::Mro_table), + ("Myanmar", super::script::Myanmar_table), ("N", + super::general_category::N_table), ("Nabataean", + super::script::Nabataean_table), ("Nd", + super::general_category::Nd_table), ("New_Tai_Lue", + super::script::New_Tai_Lue_table), ("Nko", super::script::Nko_table), + ("Nl", super::general_category::Nl_table), ("No", + super::general_category::No_table), ("Noncharacter_Code_Point", + super::property::Noncharacter_Code_Point_table), ("Ogham", + super::script::Ogham_table), ("Ol_Chiki", + super::script::Ol_Chiki_table), ("Old_Italic", + super::script::Old_Italic_table), ("Old_North_Arabian", + super::script::Old_North_Arabian_table), ("Old_Permic", + super::script::Old_Permic_table), ("Old_Persian", + super::script::Old_Persian_table), ("Old_South_Arabian", + super::script::Old_South_Arabian_table), ("Old_Turkic", + super::script::Old_Turkic_table), ("Oriya", super::script::Oriya_table), + ("Osmanya", super::script::Osmanya_table), ("P", + super::general_category::P_table), ("Pahawh_Hmong", + super::script::Pahawh_Hmong_table), ("Palmyrene", + super::script::Palmyrene_table), ("Pau_Cin_Hau", + super::script::Pau_Cin_Hau_table), ("Pc", + super::general_category::Pc_table), ("Pd", + super::general_category::Pd_table), ("Pe", + super::general_category::Pe_table), ("Pf", + super::general_category::Pf_table), ("Phags_Pa", + super::script::Phags_Pa_table), ("Phoenician", + super::script::Phoenician_table), ("Pi", + super::general_category::Pi_table), ("Po", + super::general_category::Po_table), ("Ps", + super::general_category::Ps_table), ("Psalter_Pahlavi", + super::script::Psalter_Pahlavi_table), ("Rejang", + super::script::Rejang_table), ("Runic", super::script::Runic_table), + ("S", super::general_category::S_table), ("Samaritan", + super::script::Samaritan_table), ("Saurashtra", + super::script::Saurashtra_table), ("Sc", + super::general_category::Sc_table), ("Sharada", + super::script::Sharada_table), ("Shavian", + super::script::Shavian_table), ("Siddham", + super::script::Siddham_table), ("Sinhala", + super::script::Sinhala_table), ("Sk", + super::general_category::Sk_table), ("Sm", + super::general_category::Sm_table), ("So", + super::general_category::So_table), ("Sora_Sompeng", + super::script::Sora_Sompeng_table), ("Sundanese", + super::script::Sundanese_table), ("Syloti_Nagri", + super::script::Syloti_Nagri_table), ("Syriac", + super::script::Syriac_table), ("Tagalog", super::script::Tagalog_table), + ("Tagbanwa", super::script::Tagbanwa_table), ("Tai_Le", + super::script::Tai_Le_table), ("Tai_Tham", + super::script::Tai_Tham_table), ("Tai_Viet", + super::script::Tai_Viet_table), ("Takri", super::script::Takri_table), + ("Tamil", super::script::Tamil_table), ("Telugu", + super::script::Telugu_table), ("Thaana", super::script::Thaana_table), + ("Thai", super::script::Thai_table), ("Tibetan", + super::script::Tibetan_table), ("Tifinagh", + super::script::Tifinagh_table), ("Tirhuta", + super::script::Tirhuta_table), ("Ugaritic", + super::script::Ugaritic_table), ("Uppercase", + super::derived_property::Uppercase_table), ("Vai", + super::script::Vai_table), ("Warang_Citi", + super::script::Warang_Citi_table), ("White_Space", + super::property::White_Space_table), ("XID_Continue", + super::derived_property::XID_Continue_table), ("XID_Start", + super::derived_property::XID_Start_table), ("Yi", + super::script::Yi_table), ("Z", super::general_category::Z_table), + ("Zl", super::general_category::Zl_table), ("Zp", + super::general_category::Zp_table), ("Zs", + super::general_category::Zs_table) + ]; + + pub const PERLD: &'static [(char, char)] = super::general_category::Nd_table; + + pub const PERLS: &'static [(char, char)] = super::property::White_Space_table; + + pub const PERLW: &'static [(char, char)] = &[ + ('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), + ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), + ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), + ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), + ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{300}', '\u{374}'), + ('\u{376}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), + ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), + ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), + ('\u{483}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), + ('\u{561}', '\u{587}'), ('\u{591}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), + ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{610}', '\u{61a}'), + ('\u{620}', '\u{669}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), + ('\u{6df}', '\u{6e8}'), ('\u{6ea}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), + ('\u{710}', '\u{74a}'), ('\u{74d}', '\u{7b1}'), ('\u{7c0}', '\u{7f5}'), + ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{82d}'), ('\u{840}', '\u{85b}'), + ('\u{8a0}', '\u{8b2}'), ('\u{8e4}', '\u{963}'), ('\u{966}', '\u{96f}'), + ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), + ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), + ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), + ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), + ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9f1}'), ('\u{a01}', '\u{a03}'), + ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), + ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), + ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), + ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), + ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a66}', '\u{a75}'), + ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), + ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), + ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), + ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), + ('\u{ae6}', '\u{aef}'), ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), + ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), + ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'), + ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), + ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b6f}'), + ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), + ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), + ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), + ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), + ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'), + ('\u{bd7}', '\u{bd7}'), ('\u{be6}', '\u{bef}'), ('\u{c00}', '\u{c03}'), + ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), + ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c59}'), + ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), ('\u{c81}', '\u{c83}'), + ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), + ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbc}', '\u{cc4}'), + ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), + ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), ('\u{ce6}', '\u{cef}'), + ('\u{cf1}', '\u{cf2}'), ('\u{d01}', '\u{d03}'), ('\u{d05}', '\u{d0c}'), + ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'), + ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), + ('\u{d60}', '\u{d63}'), ('\u{d66}', '\u{d6f}'), ('\u{d7a}', '\u{d7f}'), + ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), + ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), + ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), + ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), ('\u{df2}', '\u{df3}'), + ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e4e}'), ('\u{e50}', '\u{e59}'), + ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), + ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), + ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), + ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), + ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), + ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), ('\u{edc}', '\u{edf}'), + ('\u{f00}', '\u{f00}'), ('\u{f18}', '\u{f19}'), ('\u{f20}', '\u{f29}'), + ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), + ('\u{f3e}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), + ('\u{1000}', '\u{1049}'), ('\u{1050}', '\u{109d}'), ('\u{10a0}', + '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), + ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', + '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), + ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', + '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), + ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', + '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), + ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135d}', + '\u{135f}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f4}'), + ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', + '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), + ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1714}'), ('\u{1720}', + '\u{1734}'), ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'), + ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', + '\u{17d3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dd}'), + ('\u{17e0}', '\u{17e9}'), ('\u{180b}', '\u{180d}'), ('\u{1810}', + '\u{1819}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}'), + ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', + '\u{192b}'), ('\u{1930}', '\u{193b}'), ('\u{1946}', '\u{196d}'), + ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', + '\u{19c9}'), ('\u{19d0}', '\u{19d9}'), ('\u{1a00}', '\u{1a1b}'), + ('\u{1a20}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', + '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1aa7}', '\u{1aa7}'), + ('\u{1ab0}', '\u{1abe}'), ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', + '\u{1b59}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1bf3}'), + ('\u{1c00}', '\u{1c37}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c4d}', + '\u{1c7d}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1cf6}'), + ('\u{1cf8}', '\u{1cf9}'), ('\u{1d00}', '\u{1df5}'), ('\u{1dfc}', + '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), + ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', + '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), + ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', + '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), + ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', + '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), + ('\u{1ff6}', '\u{1ffc}'), ('\u{200c}', '\u{200d}'), ('\u{203f}', + '\u{2040}'), ('\u{2054}', '\u{2054}'), ('\u{2071}', '\u{2071}'), + ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{20d0}', + '\u{20f0}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), + ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', + '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), + ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{212f}', + '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), + ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{24b6}', + '\u{24e9}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), + ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cf3}'), ('\u{2d00}', + '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), + ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d7f}', + '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), + ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', + '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), + ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', '\u{2dff}'), ('\u{2e2f}', + '\u{2e2f}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{302f}'), + ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', + '\u{3096}'), ('\u{3099}', '\u{309a}'), ('\u{309d}', '\u{309f}'), + ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', + '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), + ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', + '\u{9fcc}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), + ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a62b}'), ('\u{a640}', + '\u{a672}'), ('\u{a674}', '\u{a67d}'), ('\u{a67f}', '\u{a69d}'), + ('\u{a69f}', '\u{a6f1}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', + '\u{a788}'), ('\u{a78b}', '\u{a78e}'), ('\u{a790}', '\u{a7ad}'), + ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', '\u{a827}'), ('\u{a840}', + '\u{a873}'), ('\u{a880}', '\u{a8c4}'), ('\u{a8d0}', '\u{a8d9}'), + ('\u{a8e0}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a900}', + '\u{a92d}'), ('\u{a930}', '\u{a953}'), ('\u{a960}', '\u{a97c}'), + ('\u{a980}', '\u{a9c0}'), ('\u{a9cf}', '\u{a9d9}'), ('\u{a9e0}', + '\u{a9fe}'), ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), + ('\u{aa50}', '\u{aa59}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', + '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), + ('\u{aaf2}', '\u{aaf6}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', + '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), + ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', + '\u{ab5f}'), ('\u{ab64}', '\u{ab65}'), ('\u{abc0}', '\u{abea}'), + ('\u{abec}', '\u{abed}'), ('\u{abf0}', '\u{abf9}'), ('\u{ac00}', + '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), + ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', + '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), + ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', + '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), + ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', + '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), + ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2d}'), ('\u{fe33}', + '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), ('\u{fe70}', '\u{fe74}'), + ('\u{fe76}', '\u{fefc}'), ('\u{ff10}', '\u{ff19}'), ('\u{ff21}', + '\u{ff3a}'), ('\u{ff3f}', '\u{ff3f}'), ('\u{ff41}', '\u{ff5a}'), + ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', + '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), + ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', + '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), + ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', + '\u{10174}'), ('\u{101fd}', '\u{101fd}'), ('\u{10280}', '\u{1029c}'), + ('\u{102a0}', '\u{102d0}'), ('\u{102e0}', '\u{102e0}'), ('\u{10300}', + '\u{1031f}'), ('\u{10330}', '\u{1034a}'), ('\u{10350}', '\u{1037a}'), + ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', + '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), + ('\u{104a0}', '\u{104a9}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', + '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), + ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', + '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), + ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', + '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{10900}', '\u{10915}'), + ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', + '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', + '\u{10a33}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), + ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', + '\u{10ac7}'), ('\u{10ac9}', '\u{10ae6}'), ('\u{10b00}', '\u{10b35}'), + ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', + '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{11000}', '\u{11046}'), + ('\u{11066}', '\u{1106f}'), ('\u{1107f}', '\u{110ba}'), ('\u{110d0}', + '\u{110e8}'), ('\u{110f0}', '\u{110f9}'), ('\u{11100}', '\u{11134}'), + ('\u{11136}', '\u{1113f}'), ('\u{11150}', '\u{11173}'), ('\u{11176}', + '\u{11176}'), ('\u{11180}', '\u{111c4}'), ('\u{111d0}', '\u{111da}'), + ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{11237}'), ('\u{112b0}', + '\u{112ea}'), ('\u{112f0}', '\u{112f9}'), ('\u{11301}', '\u{11303}'), + ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', + '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), + ('\u{11335}', '\u{11339}'), ('\u{1133c}', '\u{11344}'), ('\u{11347}', + '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11357}', '\u{11357}'), + ('\u{1135d}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', + '\u{11374}'), ('\u{11480}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), + ('\u{114d0}', '\u{114d9}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', + '\u{115c0}'), ('\u{11600}', '\u{11640}'), ('\u{11644}', '\u{11644}'), + ('\u{11650}', '\u{11659}'), ('\u{11680}', '\u{116b7}'), ('\u{116c0}', + '\u{116c9}'), ('\u{118a0}', '\u{118e9}'), ('\u{118ff}', '\u{118ff}'), + ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{12400}', + '\u{1246e}'), ('\u{13000}', '\u{1342e}'), ('\u{16800}', '\u{16a38}'), + ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16ad0}', + '\u{16aed}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b00}', '\u{16b36}'), + ('\u{16b40}', '\u{16b43}'), ('\u{16b50}', '\u{16b59}'), ('\u{16b63}', + '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), + ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', '\u{16f9f}'), ('\u{1b000}', + '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), + ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9d}', + '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), ('\u{1d16d}', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', + '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1d400}', '\u{1d454}'), + ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', + '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), + ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', + '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), + ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', + '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), + ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', + '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), + ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', + '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), + ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', + '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1d7ce}', '\u{1d7ff}'), + ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{1ee00}', + '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), + ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', + '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), + ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', + '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), + ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', + '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), + ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', + '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), + ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', + '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), + ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', + '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), + ('\u{1f130}', '\u{1f149}'), ('\u{1f150}', '\u{1f169}'), ('\u{1f170}', + '\u{1f189}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), + ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}'), ('\u{e0100}', + '\u{e01ef}') + ]; + +} + +pub mod case_folding { + pub const C_plus_S_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{61}'), ('\u{42}', '\u{62}'), ('\u{43}', '\u{63}'), + ('\u{44}', '\u{64}'), ('\u{45}', '\u{65}'), ('\u{46}', '\u{66}'), + ('\u{47}', '\u{67}'), ('\u{48}', '\u{68}'), ('\u{49}', '\u{69}'), + ('\u{4a}', '\u{6a}'), ('\u{4b}', '\u{6b}'), ('\u{4c}', '\u{6c}'), + ('\u{4d}', '\u{6d}'), ('\u{4e}', '\u{6e}'), ('\u{4f}', '\u{6f}'), + ('\u{50}', '\u{70}'), ('\u{51}', '\u{71}'), ('\u{52}', '\u{72}'), + ('\u{53}', '\u{73}'), ('\u{54}', '\u{74}'), ('\u{55}', '\u{75}'), + ('\u{56}', '\u{76}'), ('\u{57}', '\u{77}'), ('\u{58}', '\u{78}'), + ('\u{59}', '\u{79}'), ('\u{5a}', '\u{7a}'), ('\u{b5}', '\u{3bc}'), + ('\u{c0}', '\u{e0}'), ('\u{c1}', '\u{e1}'), ('\u{c2}', '\u{e2}'), + ('\u{c3}', '\u{e3}'), ('\u{c4}', '\u{e4}'), ('\u{c5}', '\u{e5}'), + ('\u{c6}', '\u{e6}'), ('\u{c7}', '\u{e7}'), ('\u{c8}', '\u{e8}'), + ('\u{c9}', '\u{e9}'), ('\u{ca}', '\u{ea}'), ('\u{cb}', '\u{eb}'), + ('\u{cc}', '\u{ec}'), ('\u{cd}', '\u{ed}'), ('\u{ce}', '\u{ee}'), + ('\u{cf}', '\u{ef}'), ('\u{d0}', '\u{f0}'), ('\u{d1}', '\u{f1}'), + ('\u{d2}', '\u{f2}'), ('\u{d3}', '\u{f3}'), ('\u{d4}', '\u{f4}'), + ('\u{d5}', '\u{f5}'), ('\u{d6}', '\u{f6}'), ('\u{d8}', '\u{f8}'), + ('\u{d9}', '\u{f9}'), ('\u{da}', '\u{fa}'), ('\u{db}', '\u{fb}'), + ('\u{dc}', '\u{fc}'), ('\u{dd}', '\u{fd}'), ('\u{de}', '\u{fe}'), + ('\u{100}', '\u{101}'), ('\u{102}', '\u{103}'), ('\u{104}', '\u{105}'), + ('\u{106}', '\u{107}'), ('\u{108}', '\u{109}'), ('\u{10a}', '\u{10b}'), + ('\u{10c}', '\u{10d}'), ('\u{10e}', '\u{10f}'), ('\u{110}', '\u{111}'), + ('\u{112}', '\u{113}'), ('\u{114}', '\u{115}'), ('\u{116}', '\u{117}'), + ('\u{118}', '\u{119}'), ('\u{11a}', '\u{11b}'), ('\u{11c}', '\u{11d}'), + ('\u{11e}', '\u{11f}'), ('\u{120}', '\u{121}'), ('\u{122}', '\u{123}'), + ('\u{124}', '\u{125}'), ('\u{126}', '\u{127}'), ('\u{128}', '\u{129}'), + ('\u{12a}', '\u{12b}'), ('\u{12c}', '\u{12d}'), ('\u{12e}', '\u{12f}'), + ('\u{132}', '\u{133}'), ('\u{134}', '\u{135}'), ('\u{136}', '\u{137}'), + ('\u{139}', '\u{13a}'), ('\u{13b}', '\u{13c}'), ('\u{13d}', '\u{13e}'), + ('\u{13f}', '\u{140}'), ('\u{141}', '\u{142}'), ('\u{143}', '\u{144}'), + ('\u{145}', '\u{146}'), ('\u{147}', '\u{148}'), ('\u{14a}', '\u{14b}'), + ('\u{14c}', '\u{14d}'), ('\u{14e}', '\u{14f}'), ('\u{150}', '\u{151}'), + ('\u{152}', '\u{153}'), ('\u{154}', '\u{155}'), ('\u{156}', '\u{157}'), + ('\u{158}', '\u{159}'), ('\u{15a}', '\u{15b}'), ('\u{15c}', '\u{15d}'), + ('\u{15e}', '\u{15f}'), ('\u{160}', '\u{161}'), ('\u{162}', '\u{163}'), + ('\u{164}', '\u{165}'), ('\u{166}', '\u{167}'), ('\u{168}', '\u{169}'), + ('\u{16a}', '\u{16b}'), ('\u{16c}', '\u{16d}'), ('\u{16e}', '\u{16f}'), + ('\u{170}', '\u{171}'), ('\u{172}', '\u{173}'), ('\u{174}', '\u{175}'), + ('\u{176}', '\u{177}'), ('\u{178}', '\u{ff}'), ('\u{179}', '\u{17a}'), + ('\u{17b}', '\u{17c}'), ('\u{17d}', '\u{17e}'), ('\u{17f}', '\u{73}'), + ('\u{181}', '\u{253}'), ('\u{182}', '\u{183}'), ('\u{184}', '\u{185}'), + ('\u{186}', '\u{254}'), ('\u{187}', '\u{188}'), ('\u{189}', '\u{256}'), + ('\u{18a}', '\u{257}'), ('\u{18b}', '\u{18c}'), ('\u{18e}', '\u{1dd}'), + ('\u{18f}', '\u{259}'), ('\u{190}', '\u{25b}'), ('\u{191}', '\u{192}'), + ('\u{193}', '\u{260}'), ('\u{194}', '\u{263}'), ('\u{196}', '\u{269}'), + ('\u{197}', '\u{268}'), ('\u{198}', '\u{199}'), ('\u{19c}', '\u{26f}'), + ('\u{19d}', '\u{272}'), ('\u{19f}', '\u{275}'), ('\u{1a0}', '\u{1a1}'), + ('\u{1a2}', '\u{1a3}'), ('\u{1a4}', '\u{1a5}'), ('\u{1a6}', '\u{280}'), + ('\u{1a7}', '\u{1a8}'), ('\u{1a9}', '\u{283}'), ('\u{1ac}', '\u{1ad}'), + ('\u{1ae}', '\u{288}'), ('\u{1af}', '\u{1b0}'), ('\u{1b1}', '\u{28a}'), + ('\u{1b2}', '\u{28b}'), ('\u{1b3}', '\u{1b4}'), ('\u{1b5}', '\u{1b6}'), + ('\u{1b7}', '\u{292}'), ('\u{1b8}', '\u{1b9}'), ('\u{1bc}', '\u{1bd}'), + ('\u{1c4}', '\u{1c6}'), ('\u{1c5}', '\u{1c6}'), ('\u{1c7}', '\u{1c9}'), + ('\u{1c8}', '\u{1c9}'), ('\u{1ca}', '\u{1cc}'), ('\u{1cb}', '\u{1cc}'), + ('\u{1cd}', '\u{1ce}'), ('\u{1cf}', '\u{1d0}'), ('\u{1d1}', '\u{1d2}'), + ('\u{1d3}', '\u{1d4}'), ('\u{1d5}', '\u{1d6}'), ('\u{1d7}', '\u{1d8}'), + ('\u{1d9}', '\u{1da}'), ('\u{1db}', '\u{1dc}'), ('\u{1de}', '\u{1df}'), + ('\u{1e0}', '\u{1e1}'), ('\u{1e2}', '\u{1e3}'), ('\u{1e4}', '\u{1e5}'), + ('\u{1e6}', '\u{1e7}'), ('\u{1e8}', '\u{1e9}'), ('\u{1ea}', '\u{1eb}'), + ('\u{1ec}', '\u{1ed}'), ('\u{1ee}', '\u{1ef}'), ('\u{1f1}', '\u{1f3}'), + ('\u{1f2}', '\u{1f3}'), ('\u{1f4}', '\u{1f5}'), ('\u{1f6}', '\u{195}'), + ('\u{1f7}', '\u{1bf}'), ('\u{1f8}', '\u{1f9}'), ('\u{1fa}', '\u{1fb}'), + ('\u{1fc}', '\u{1fd}'), ('\u{1fe}', '\u{1ff}'), ('\u{200}', '\u{201}'), + ('\u{202}', '\u{203}'), ('\u{204}', '\u{205}'), ('\u{206}', '\u{207}'), + ('\u{208}', '\u{209}'), ('\u{20a}', '\u{20b}'), ('\u{20c}', '\u{20d}'), + ('\u{20e}', '\u{20f}'), ('\u{210}', '\u{211}'), ('\u{212}', '\u{213}'), + ('\u{214}', '\u{215}'), ('\u{216}', '\u{217}'), ('\u{218}', '\u{219}'), + ('\u{21a}', '\u{21b}'), ('\u{21c}', '\u{21d}'), ('\u{21e}', '\u{21f}'), + ('\u{220}', '\u{19e}'), ('\u{222}', '\u{223}'), ('\u{224}', '\u{225}'), + ('\u{226}', '\u{227}'), ('\u{228}', '\u{229}'), ('\u{22a}', '\u{22b}'), + ('\u{22c}', '\u{22d}'), ('\u{22e}', '\u{22f}'), ('\u{230}', '\u{231}'), + ('\u{232}', '\u{233}'), ('\u{23a}', '\u{2c65}'), ('\u{23b}', '\u{23c}'), + ('\u{23d}', '\u{19a}'), ('\u{23e}', '\u{2c66}'), ('\u{241}', '\u{242}'), + ('\u{243}', '\u{180}'), ('\u{244}', '\u{289}'), ('\u{245}', '\u{28c}'), + ('\u{246}', '\u{247}'), ('\u{248}', '\u{249}'), ('\u{24a}', '\u{24b}'), + ('\u{24c}', '\u{24d}'), ('\u{24e}', '\u{24f}'), ('\u{345}', '\u{3b9}'), + ('\u{370}', '\u{371}'), ('\u{372}', '\u{373}'), ('\u{376}', '\u{377}'), + ('\u{37f}', '\u{3f3}'), ('\u{386}', '\u{3ac}'), ('\u{388}', '\u{3ad}'), + ('\u{389}', '\u{3ae}'), ('\u{38a}', '\u{3af}'), ('\u{38c}', '\u{3cc}'), + ('\u{38e}', '\u{3cd}'), ('\u{38f}', '\u{3ce}'), ('\u{391}', '\u{3b1}'), + ('\u{392}', '\u{3b2}'), ('\u{393}', '\u{3b3}'), ('\u{394}', '\u{3b4}'), + ('\u{395}', '\u{3b5}'), ('\u{396}', '\u{3b6}'), ('\u{397}', '\u{3b7}'), + ('\u{398}', '\u{3b8}'), ('\u{399}', '\u{3b9}'), ('\u{39a}', '\u{3ba}'), + ('\u{39b}', '\u{3bb}'), ('\u{39c}', '\u{3bc}'), ('\u{39d}', '\u{3bd}'), + ('\u{39e}', '\u{3be}'), ('\u{39f}', '\u{3bf}'), ('\u{3a0}', '\u{3c0}'), + ('\u{3a1}', '\u{3c1}'), ('\u{3a3}', '\u{3c3}'), ('\u{3a4}', '\u{3c4}'), + ('\u{3a5}', '\u{3c5}'), ('\u{3a6}', '\u{3c6}'), ('\u{3a7}', '\u{3c7}'), + ('\u{3a8}', '\u{3c8}'), ('\u{3a9}', '\u{3c9}'), ('\u{3aa}', '\u{3ca}'), + ('\u{3ab}', '\u{3cb}'), ('\u{3c2}', '\u{3c3}'), ('\u{3cf}', '\u{3d7}'), + ('\u{3d0}', '\u{3b2}'), ('\u{3d1}', '\u{3b8}'), ('\u{3d5}', '\u{3c6}'), + ('\u{3d6}', '\u{3c0}'), ('\u{3d8}', '\u{3d9}'), ('\u{3da}', '\u{3db}'), + ('\u{3dc}', '\u{3dd}'), ('\u{3de}', '\u{3df}'), ('\u{3e0}', '\u{3e1}'), + ('\u{3e2}', '\u{3e3}'), ('\u{3e4}', '\u{3e5}'), ('\u{3e6}', '\u{3e7}'), + ('\u{3e8}', '\u{3e9}'), ('\u{3ea}', '\u{3eb}'), ('\u{3ec}', '\u{3ed}'), + ('\u{3ee}', '\u{3ef}'), ('\u{3f0}', '\u{3ba}'), ('\u{3f1}', '\u{3c1}'), + ('\u{3f4}', '\u{3b8}'), ('\u{3f5}', '\u{3b5}'), ('\u{3f7}', '\u{3f8}'), + ('\u{3f9}', '\u{3f2}'), ('\u{3fa}', '\u{3fb}'), ('\u{3fd}', '\u{37b}'), + ('\u{3fe}', '\u{37c}'), ('\u{3ff}', '\u{37d}'), ('\u{400}', '\u{450}'), + ('\u{401}', '\u{451}'), ('\u{402}', '\u{452}'), ('\u{403}', '\u{453}'), + ('\u{404}', '\u{454}'), ('\u{405}', '\u{455}'), ('\u{406}', '\u{456}'), + ('\u{407}', '\u{457}'), ('\u{408}', '\u{458}'), ('\u{409}', '\u{459}'), + ('\u{40a}', '\u{45a}'), ('\u{40b}', '\u{45b}'), ('\u{40c}', '\u{45c}'), + ('\u{40d}', '\u{45d}'), ('\u{40e}', '\u{45e}'), ('\u{40f}', '\u{45f}'), + ('\u{410}', '\u{430}'), ('\u{411}', '\u{431}'), ('\u{412}', '\u{432}'), + ('\u{413}', '\u{433}'), ('\u{414}', '\u{434}'), ('\u{415}', '\u{435}'), + ('\u{416}', '\u{436}'), ('\u{417}', '\u{437}'), ('\u{418}', '\u{438}'), + ('\u{419}', '\u{439}'), ('\u{41a}', '\u{43a}'), ('\u{41b}', '\u{43b}'), + ('\u{41c}', '\u{43c}'), ('\u{41d}', '\u{43d}'), ('\u{41e}', '\u{43e}'), + ('\u{41f}', '\u{43f}'), ('\u{420}', '\u{440}'), ('\u{421}', '\u{441}'), + ('\u{422}', '\u{442}'), ('\u{423}', '\u{443}'), ('\u{424}', '\u{444}'), + ('\u{425}', '\u{445}'), ('\u{426}', '\u{446}'), ('\u{427}', '\u{447}'), + ('\u{428}', '\u{448}'), ('\u{429}', '\u{449}'), ('\u{42a}', '\u{44a}'), + ('\u{42b}', '\u{44b}'), ('\u{42c}', '\u{44c}'), ('\u{42d}', '\u{44d}'), + ('\u{42e}', '\u{44e}'), ('\u{42f}', '\u{44f}'), ('\u{460}', '\u{461}'), + ('\u{462}', '\u{463}'), ('\u{464}', '\u{465}'), ('\u{466}', '\u{467}'), + ('\u{468}', '\u{469}'), ('\u{46a}', '\u{46b}'), ('\u{46c}', '\u{46d}'), + ('\u{46e}', '\u{46f}'), ('\u{470}', '\u{471}'), ('\u{472}', '\u{473}'), + ('\u{474}', '\u{475}'), ('\u{476}', '\u{477}'), ('\u{478}', '\u{479}'), + ('\u{47a}', '\u{47b}'), ('\u{47c}', '\u{47d}'), ('\u{47e}', '\u{47f}'), + ('\u{480}', '\u{481}'), ('\u{48a}', '\u{48b}'), ('\u{48c}', '\u{48d}'), + ('\u{48e}', '\u{48f}'), ('\u{490}', '\u{491}'), ('\u{492}', '\u{493}'), + ('\u{494}', '\u{495}'), ('\u{496}', '\u{497}'), ('\u{498}', '\u{499}'), + ('\u{49a}', '\u{49b}'), ('\u{49c}', '\u{49d}'), ('\u{49e}', '\u{49f}'), + ('\u{4a0}', '\u{4a1}'), ('\u{4a2}', '\u{4a3}'), ('\u{4a4}', '\u{4a5}'), + ('\u{4a6}', '\u{4a7}'), ('\u{4a8}', '\u{4a9}'), ('\u{4aa}', '\u{4ab}'), + ('\u{4ac}', '\u{4ad}'), ('\u{4ae}', '\u{4af}'), ('\u{4b0}', '\u{4b1}'), + ('\u{4b2}', '\u{4b3}'), ('\u{4b4}', '\u{4b5}'), ('\u{4b6}', '\u{4b7}'), + ('\u{4b8}', '\u{4b9}'), ('\u{4ba}', '\u{4bb}'), ('\u{4bc}', '\u{4bd}'), + ('\u{4be}', '\u{4bf}'), ('\u{4c0}', '\u{4cf}'), ('\u{4c1}', '\u{4c2}'), + ('\u{4c3}', '\u{4c4}'), ('\u{4c5}', '\u{4c6}'), ('\u{4c7}', '\u{4c8}'), + ('\u{4c9}', '\u{4ca}'), ('\u{4cb}', '\u{4cc}'), ('\u{4cd}', '\u{4ce}'), + ('\u{4d0}', '\u{4d1}'), ('\u{4d2}', '\u{4d3}'), ('\u{4d4}', '\u{4d5}'), + ('\u{4d6}', '\u{4d7}'), ('\u{4d8}', '\u{4d9}'), ('\u{4da}', '\u{4db}'), + ('\u{4dc}', '\u{4dd}'), ('\u{4de}', '\u{4df}'), ('\u{4e0}', '\u{4e1}'), + ('\u{4e2}', '\u{4e3}'), ('\u{4e4}', '\u{4e5}'), ('\u{4e6}', '\u{4e7}'), + ('\u{4e8}', '\u{4e9}'), ('\u{4ea}', '\u{4eb}'), ('\u{4ec}', '\u{4ed}'), + ('\u{4ee}', '\u{4ef}'), ('\u{4f0}', '\u{4f1}'), ('\u{4f2}', '\u{4f3}'), + ('\u{4f4}', '\u{4f5}'), ('\u{4f6}', '\u{4f7}'), ('\u{4f8}', '\u{4f9}'), + ('\u{4fa}', '\u{4fb}'), ('\u{4fc}', '\u{4fd}'), ('\u{4fe}', '\u{4ff}'), + ('\u{500}', '\u{501}'), ('\u{502}', '\u{503}'), ('\u{504}', '\u{505}'), + ('\u{506}', '\u{507}'), ('\u{508}', '\u{509}'), ('\u{50a}', '\u{50b}'), + ('\u{50c}', '\u{50d}'), ('\u{50e}', '\u{50f}'), ('\u{510}', '\u{511}'), + ('\u{512}', '\u{513}'), ('\u{514}', '\u{515}'), ('\u{516}', '\u{517}'), + ('\u{518}', '\u{519}'), ('\u{51a}', '\u{51b}'), ('\u{51c}', '\u{51d}'), + ('\u{51e}', '\u{51f}'), ('\u{520}', '\u{521}'), ('\u{522}', '\u{523}'), + ('\u{524}', '\u{525}'), ('\u{526}', '\u{527}'), ('\u{528}', '\u{529}'), + ('\u{52a}', '\u{52b}'), ('\u{52c}', '\u{52d}'), ('\u{52e}', '\u{52f}'), + ('\u{531}', '\u{561}'), ('\u{532}', '\u{562}'), ('\u{533}', '\u{563}'), + ('\u{534}', '\u{564}'), ('\u{535}', '\u{565}'), ('\u{536}', '\u{566}'), + ('\u{537}', '\u{567}'), ('\u{538}', '\u{568}'), ('\u{539}', '\u{569}'), + ('\u{53a}', '\u{56a}'), ('\u{53b}', '\u{56b}'), ('\u{53c}', '\u{56c}'), + ('\u{53d}', '\u{56d}'), ('\u{53e}', '\u{56e}'), ('\u{53f}', '\u{56f}'), + ('\u{540}', '\u{570}'), ('\u{541}', '\u{571}'), ('\u{542}', '\u{572}'), + ('\u{543}', '\u{573}'), ('\u{544}', '\u{574}'), ('\u{545}', '\u{575}'), + ('\u{546}', '\u{576}'), ('\u{547}', '\u{577}'), ('\u{548}', '\u{578}'), + ('\u{549}', '\u{579}'), ('\u{54a}', '\u{57a}'), ('\u{54b}', '\u{57b}'), + ('\u{54c}', '\u{57c}'), ('\u{54d}', '\u{57d}'), ('\u{54e}', '\u{57e}'), + ('\u{54f}', '\u{57f}'), ('\u{550}', '\u{580}'), ('\u{551}', '\u{581}'), + ('\u{552}', '\u{582}'), ('\u{553}', '\u{583}'), ('\u{554}', '\u{584}'), + ('\u{555}', '\u{585}'), ('\u{556}', '\u{586}'), ('\u{10a0}', + '\u{2d00}'), ('\u{10a1}', '\u{2d01}'), ('\u{10a2}', '\u{2d02}'), + ('\u{10a3}', '\u{2d03}'), ('\u{10a4}', '\u{2d04}'), ('\u{10a5}', + '\u{2d05}'), ('\u{10a6}', '\u{2d06}'), ('\u{10a7}', '\u{2d07}'), + ('\u{10a8}', '\u{2d08}'), ('\u{10a9}', '\u{2d09}'), ('\u{10aa}', + '\u{2d0a}'), ('\u{10ab}', '\u{2d0b}'), ('\u{10ac}', '\u{2d0c}'), + ('\u{10ad}', '\u{2d0d}'), ('\u{10ae}', '\u{2d0e}'), ('\u{10af}', + '\u{2d0f}'), ('\u{10b0}', '\u{2d10}'), ('\u{10b1}', '\u{2d11}'), + ('\u{10b2}', '\u{2d12}'), ('\u{10b3}', '\u{2d13}'), ('\u{10b4}', + '\u{2d14}'), ('\u{10b5}', '\u{2d15}'), ('\u{10b6}', '\u{2d16}'), + ('\u{10b7}', '\u{2d17}'), ('\u{10b8}', '\u{2d18}'), ('\u{10b9}', + '\u{2d19}'), ('\u{10ba}', '\u{2d1a}'), ('\u{10bb}', '\u{2d1b}'), + ('\u{10bc}', '\u{2d1c}'), ('\u{10bd}', '\u{2d1d}'), ('\u{10be}', + '\u{2d1e}'), ('\u{10bf}', '\u{2d1f}'), ('\u{10c0}', '\u{2d20}'), + ('\u{10c1}', '\u{2d21}'), ('\u{10c2}', '\u{2d22}'), ('\u{10c3}', + '\u{2d23}'), ('\u{10c4}', '\u{2d24}'), ('\u{10c5}', '\u{2d25}'), + ('\u{10c7}', '\u{2d27}'), ('\u{10cd}', '\u{2d2d}'), ('\u{1e00}', + '\u{1e01}'), ('\u{1e02}', '\u{1e03}'), ('\u{1e04}', '\u{1e05}'), + ('\u{1e06}', '\u{1e07}'), ('\u{1e08}', '\u{1e09}'), ('\u{1e0a}', + '\u{1e0b}'), ('\u{1e0c}', '\u{1e0d}'), ('\u{1e0e}', '\u{1e0f}'), + ('\u{1e10}', '\u{1e11}'), ('\u{1e12}', '\u{1e13}'), ('\u{1e14}', + '\u{1e15}'), ('\u{1e16}', '\u{1e17}'), ('\u{1e18}', '\u{1e19}'), + ('\u{1e1a}', '\u{1e1b}'), ('\u{1e1c}', '\u{1e1d}'), ('\u{1e1e}', + '\u{1e1f}'), ('\u{1e20}', '\u{1e21}'), ('\u{1e22}', '\u{1e23}'), + ('\u{1e24}', '\u{1e25}'), ('\u{1e26}', '\u{1e27}'), ('\u{1e28}', + '\u{1e29}'), ('\u{1e2a}', '\u{1e2b}'), ('\u{1e2c}', '\u{1e2d}'), + ('\u{1e2e}', '\u{1e2f}'), ('\u{1e30}', '\u{1e31}'), ('\u{1e32}', + '\u{1e33}'), ('\u{1e34}', '\u{1e35}'), ('\u{1e36}', '\u{1e37}'), + ('\u{1e38}', '\u{1e39}'), ('\u{1e3a}', '\u{1e3b}'), ('\u{1e3c}', + '\u{1e3d}'), ('\u{1e3e}', '\u{1e3f}'), ('\u{1e40}', '\u{1e41}'), + ('\u{1e42}', '\u{1e43}'), ('\u{1e44}', '\u{1e45}'), ('\u{1e46}', + '\u{1e47}'), ('\u{1e48}', '\u{1e49}'), ('\u{1e4a}', '\u{1e4b}'), + ('\u{1e4c}', '\u{1e4d}'), ('\u{1e4e}', '\u{1e4f}'), ('\u{1e50}', + '\u{1e51}'), ('\u{1e52}', '\u{1e53}'), ('\u{1e54}', '\u{1e55}'), + ('\u{1e56}', '\u{1e57}'), ('\u{1e58}', '\u{1e59}'), ('\u{1e5a}', + '\u{1e5b}'), ('\u{1e5c}', '\u{1e5d}'), ('\u{1e5e}', '\u{1e5f}'), + ('\u{1e60}', '\u{1e61}'), ('\u{1e62}', '\u{1e63}'), ('\u{1e64}', + '\u{1e65}'), ('\u{1e66}', '\u{1e67}'), ('\u{1e68}', '\u{1e69}'), + ('\u{1e6a}', '\u{1e6b}'), ('\u{1e6c}', '\u{1e6d}'), ('\u{1e6e}', + '\u{1e6f}'), ('\u{1e70}', '\u{1e71}'), ('\u{1e72}', '\u{1e73}'), + ('\u{1e74}', '\u{1e75}'), ('\u{1e76}', '\u{1e77}'), ('\u{1e78}', + '\u{1e79}'), ('\u{1e7a}', '\u{1e7b}'), ('\u{1e7c}', '\u{1e7d}'), + ('\u{1e7e}', '\u{1e7f}'), ('\u{1e80}', '\u{1e81}'), ('\u{1e82}', + '\u{1e83}'), ('\u{1e84}', '\u{1e85}'), ('\u{1e86}', '\u{1e87}'), + ('\u{1e88}', '\u{1e89}'), ('\u{1e8a}', '\u{1e8b}'), ('\u{1e8c}', + '\u{1e8d}'), ('\u{1e8e}', '\u{1e8f}'), ('\u{1e90}', '\u{1e91}'), + ('\u{1e92}', '\u{1e93}'), ('\u{1e94}', '\u{1e95}'), ('\u{1e9b}', + '\u{1e61}'), ('\u{1e9e}', '\u{df}'), ('\u{1ea0}', '\u{1ea1}'), + ('\u{1ea2}', '\u{1ea3}'), ('\u{1ea4}', '\u{1ea5}'), ('\u{1ea6}', + '\u{1ea7}'), ('\u{1ea8}', '\u{1ea9}'), ('\u{1eaa}', '\u{1eab}'), + ('\u{1eac}', '\u{1ead}'), ('\u{1eae}', '\u{1eaf}'), ('\u{1eb0}', + '\u{1eb1}'), ('\u{1eb2}', '\u{1eb3}'), ('\u{1eb4}', '\u{1eb5}'), + ('\u{1eb6}', '\u{1eb7}'), ('\u{1eb8}', '\u{1eb9}'), ('\u{1eba}', + '\u{1ebb}'), ('\u{1ebc}', '\u{1ebd}'), ('\u{1ebe}', '\u{1ebf}'), + ('\u{1ec0}', '\u{1ec1}'), ('\u{1ec2}', '\u{1ec3}'), ('\u{1ec4}', + '\u{1ec5}'), ('\u{1ec6}', '\u{1ec7}'), ('\u{1ec8}', '\u{1ec9}'), + ('\u{1eca}', '\u{1ecb}'), ('\u{1ecc}', '\u{1ecd}'), ('\u{1ece}', + '\u{1ecf}'), ('\u{1ed0}', '\u{1ed1}'), ('\u{1ed2}', '\u{1ed3}'), + ('\u{1ed4}', '\u{1ed5}'), ('\u{1ed6}', '\u{1ed7}'), ('\u{1ed8}', + '\u{1ed9}'), ('\u{1eda}', '\u{1edb}'), ('\u{1edc}', '\u{1edd}'), + ('\u{1ede}', '\u{1edf}'), ('\u{1ee0}', '\u{1ee1}'), ('\u{1ee2}', + '\u{1ee3}'), ('\u{1ee4}', '\u{1ee5}'), ('\u{1ee6}', '\u{1ee7}'), + ('\u{1ee8}', '\u{1ee9}'), ('\u{1eea}', '\u{1eeb}'), ('\u{1eec}', + '\u{1eed}'), ('\u{1eee}', '\u{1eef}'), ('\u{1ef0}', '\u{1ef1}'), + ('\u{1ef2}', '\u{1ef3}'), ('\u{1ef4}', '\u{1ef5}'), ('\u{1ef6}', + '\u{1ef7}'), ('\u{1ef8}', '\u{1ef9}'), ('\u{1efa}', '\u{1efb}'), + ('\u{1efc}', '\u{1efd}'), ('\u{1efe}', '\u{1eff}'), ('\u{1f08}', + '\u{1f00}'), ('\u{1f09}', '\u{1f01}'), ('\u{1f0a}', '\u{1f02}'), + ('\u{1f0b}', '\u{1f03}'), ('\u{1f0c}', '\u{1f04}'), ('\u{1f0d}', + '\u{1f05}'), ('\u{1f0e}', '\u{1f06}'), ('\u{1f0f}', '\u{1f07}'), + ('\u{1f18}', '\u{1f10}'), ('\u{1f19}', '\u{1f11}'), ('\u{1f1a}', + '\u{1f12}'), ('\u{1f1b}', '\u{1f13}'), ('\u{1f1c}', '\u{1f14}'), + ('\u{1f1d}', '\u{1f15}'), ('\u{1f28}', '\u{1f20}'), ('\u{1f29}', + '\u{1f21}'), ('\u{1f2a}', '\u{1f22}'), ('\u{1f2b}', '\u{1f23}'), + ('\u{1f2c}', '\u{1f24}'), ('\u{1f2d}', '\u{1f25}'), ('\u{1f2e}', + '\u{1f26}'), ('\u{1f2f}', '\u{1f27}'), ('\u{1f38}', '\u{1f30}'), + ('\u{1f39}', '\u{1f31}'), ('\u{1f3a}', '\u{1f32}'), ('\u{1f3b}', + '\u{1f33}'), ('\u{1f3c}', '\u{1f34}'), ('\u{1f3d}', '\u{1f35}'), + ('\u{1f3e}', '\u{1f36}'), ('\u{1f3f}', '\u{1f37}'), ('\u{1f48}', + '\u{1f40}'), ('\u{1f49}', '\u{1f41}'), ('\u{1f4a}', '\u{1f42}'), + ('\u{1f4b}', '\u{1f43}'), ('\u{1f4c}', '\u{1f44}'), ('\u{1f4d}', + '\u{1f45}'), ('\u{1f59}', '\u{1f51}'), ('\u{1f5b}', '\u{1f53}'), + ('\u{1f5d}', '\u{1f55}'), ('\u{1f5f}', '\u{1f57}'), ('\u{1f68}', + '\u{1f60}'), ('\u{1f69}', '\u{1f61}'), ('\u{1f6a}', '\u{1f62}'), + ('\u{1f6b}', '\u{1f63}'), ('\u{1f6c}', '\u{1f64}'), ('\u{1f6d}', + '\u{1f65}'), ('\u{1f6e}', '\u{1f66}'), ('\u{1f6f}', '\u{1f67}'), + ('\u{1f88}', '\u{1f80}'), ('\u{1f89}', '\u{1f81}'), ('\u{1f8a}', + '\u{1f82}'), ('\u{1f8b}', '\u{1f83}'), ('\u{1f8c}', '\u{1f84}'), + ('\u{1f8d}', '\u{1f85}'), ('\u{1f8e}', '\u{1f86}'), ('\u{1f8f}', + '\u{1f87}'), ('\u{1f98}', '\u{1f90}'), ('\u{1f99}', '\u{1f91}'), + ('\u{1f9a}', '\u{1f92}'), ('\u{1f9b}', '\u{1f93}'), ('\u{1f9c}', + '\u{1f94}'), ('\u{1f9d}', '\u{1f95}'), ('\u{1f9e}', '\u{1f96}'), + ('\u{1f9f}', '\u{1f97}'), ('\u{1fa8}', '\u{1fa0}'), ('\u{1fa9}', + '\u{1fa1}'), ('\u{1faa}', '\u{1fa2}'), ('\u{1fab}', '\u{1fa3}'), + ('\u{1fac}', '\u{1fa4}'), ('\u{1fad}', '\u{1fa5}'), ('\u{1fae}', + '\u{1fa6}'), ('\u{1faf}', '\u{1fa7}'), ('\u{1fb8}', '\u{1fb0}'), + ('\u{1fb9}', '\u{1fb1}'), ('\u{1fba}', '\u{1f70}'), ('\u{1fbb}', + '\u{1f71}'), ('\u{1fbc}', '\u{1fb3}'), ('\u{1fbe}', '\u{3b9}'), + ('\u{1fc8}', '\u{1f72}'), ('\u{1fc9}', '\u{1f73}'), ('\u{1fca}', + '\u{1f74}'), ('\u{1fcb}', '\u{1f75}'), ('\u{1fcc}', '\u{1fc3}'), + ('\u{1fd8}', '\u{1fd0}'), ('\u{1fd9}', '\u{1fd1}'), ('\u{1fda}', + '\u{1f76}'), ('\u{1fdb}', '\u{1f77}'), ('\u{1fe8}', '\u{1fe0}'), + ('\u{1fe9}', '\u{1fe1}'), ('\u{1fea}', '\u{1f7a}'), ('\u{1feb}', + '\u{1f7b}'), ('\u{1fec}', '\u{1fe5}'), ('\u{1ff8}', '\u{1f78}'), + ('\u{1ff9}', '\u{1f79}'), ('\u{1ffa}', '\u{1f7c}'), ('\u{1ffb}', + '\u{1f7d}'), ('\u{1ffc}', '\u{1ff3}'), ('\u{2126}', '\u{3c9}'), + ('\u{212a}', '\u{6b}'), ('\u{212b}', '\u{e5}'), ('\u{2132}', + '\u{214e}'), ('\u{2160}', '\u{2170}'), ('\u{2161}', '\u{2171}'), + ('\u{2162}', '\u{2172}'), ('\u{2163}', '\u{2173}'), ('\u{2164}', + '\u{2174}'), ('\u{2165}', '\u{2175}'), ('\u{2166}', '\u{2176}'), + ('\u{2167}', '\u{2177}'), ('\u{2168}', '\u{2178}'), ('\u{2169}', + '\u{2179}'), ('\u{216a}', '\u{217a}'), ('\u{216b}', '\u{217b}'), + ('\u{216c}', '\u{217c}'), ('\u{216d}', '\u{217d}'), ('\u{216e}', + '\u{217e}'), ('\u{216f}', '\u{217f}'), ('\u{2183}', '\u{2184}'), + ('\u{24b6}', '\u{24d0}'), ('\u{24b7}', '\u{24d1}'), ('\u{24b8}', + '\u{24d2}'), ('\u{24b9}', '\u{24d3}'), ('\u{24ba}', '\u{24d4}'), + ('\u{24bb}', '\u{24d5}'), ('\u{24bc}', '\u{24d6}'), ('\u{24bd}', + '\u{24d7}'), ('\u{24be}', '\u{24d8}'), ('\u{24bf}', '\u{24d9}'), + ('\u{24c0}', '\u{24da}'), ('\u{24c1}', '\u{24db}'), ('\u{24c2}', + '\u{24dc}'), ('\u{24c3}', '\u{24dd}'), ('\u{24c4}', '\u{24de}'), + ('\u{24c5}', '\u{24df}'), ('\u{24c6}', '\u{24e0}'), ('\u{24c7}', + '\u{24e1}'), ('\u{24c8}', '\u{24e2}'), ('\u{24c9}', '\u{24e3}'), + ('\u{24ca}', '\u{24e4}'), ('\u{24cb}', '\u{24e5}'), ('\u{24cc}', + '\u{24e6}'), ('\u{24cd}', '\u{24e7}'), ('\u{24ce}', '\u{24e8}'), + ('\u{24cf}', '\u{24e9}'), ('\u{2c00}', '\u{2c30}'), ('\u{2c01}', + '\u{2c31}'), ('\u{2c02}', '\u{2c32}'), ('\u{2c03}', '\u{2c33}'), + ('\u{2c04}', '\u{2c34}'), ('\u{2c05}', '\u{2c35}'), ('\u{2c06}', + '\u{2c36}'), ('\u{2c07}', '\u{2c37}'), ('\u{2c08}', '\u{2c38}'), + ('\u{2c09}', '\u{2c39}'), ('\u{2c0a}', '\u{2c3a}'), ('\u{2c0b}', + '\u{2c3b}'), ('\u{2c0c}', '\u{2c3c}'), ('\u{2c0d}', '\u{2c3d}'), + ('\u{2c0e}', '\u{2c3e}'), ('\u{2c0f}', '\u{2c3f}'), ('\u{2c10}', + '\u{2c40}'), ('\u{2c11}', '\u{2c41}'), ('\u{2c12}', '\u{2c42}'), + ('\u{2c13}', '\u{2c43}'), ('\u{2c14}', '\u{2c44}'), ('\u{2c15}', + '\u{2c45}'), ('\u{2c16}', '\u{2c46}'), ('\u{2c17}', '\u{2c47}'), + ('\u{2c18}', '\u{2c48}'), ('\u{2c19}', '\u{2c49}'), ('\u{2c1a}', + '\u{2c4a}'), ('\u{2c1b}', '\u{2c4b}'), ('\u{2c1c}', '\u{2c4c}'), + ('\u{2c1d}', '\u{2c4d}'), ('\u{2c1e}', '\u{2c4e}'), ('\u{2c1f}', + '\u{2c4f}'), ('\u{2c20}', '\u{2c50}'), ('\u{2c21}', '\u{2c51}'), + ('\u{2c22}', '\u{2c52}'), ('\u{2c23}', '\u{2c53}'), ('\u{2c24}', + '\u{2c54}'), ('\u{2c25}', '\u{2c55}'), ('\u{2c26}', '\u{2c56}'), + ('\u{2c27}', '\u{2c57}'), ('\u{2c28}', '\u{2c58}'), ('\u{2c29}', + '\u{2c59}'), ('\u{2c2a}', '\u{2c5a}'), ('\u{2c2b}', '\u{2c5b}'), + ('\u{2c2c}', '\u{2c5c}'), ('\u{2c2d}', '\u{2c5d}'), ('\u{2c2e}', + '\u{2c5e}'), ('\u{2c60}', '\u{2c61}'), ('\u{2c62}', '\u{26b}'), + ('\u{2c63}', '\u{1d7d}'), ('\u{2c64}', '\u{27d}'), ('\u{2c67}', + '\u{2c68}'), ('\u{2c69}', '\u{2c6a}'), ('\u{2c6b}', '\u{2c6c}'), + ('\u{2c6d}', '\u{251}'), ('\u{2c6e}', '\u{271}'), ('\u{2c6f}', + '\u{250}'), ('\u{2c70}', '\u{252}'), ('\u{2c72}', '\u{2c73}'), + ('\u{2c75}', '\u{2c76}'), ('\u{2c7e}', '\u{23f}'), ('\u{2c7f}', + '\u{240}'), ('\u{2c80}', '\u{2c81}'), ('\u{2c82}', '\u{2c83}'), + ('\u{2c84}', '\u{2c85}'), ('\u{2c86}', '\u{2c87}'), ('\u{2c88}', + '\u{2c89}'), ('\u{2c8a}', '\u{2c8b}'), ('\u{2c8c}', '\u{2c8d}'), + ('\u{2c8e}', '\u{2c8f}'), ('\u{2c90}', '\u{2c91}'), ('\u{2c92}', + '\u{2c93}'), ('\u{2c94}', '\u{2c95}'), ('\u{2c96}', '\u{2c97}'), + ('\u{2c98}', '\u{2c99}'), ('\u{2c9a}', '\u{2c9b}'), ('\u{2c9c}', + '\u{2c9d}'), ('\u{2c9e}', '\u{2c9f}'), ('\u{2ca0}', '\u{2ca1}'), + ('\u{2ca2}', '\u{2ca3}'), ('\u{2ca4}', '\u{2ca5}'), ('\u{2ca6}', + '\u{2ca7}'), ('\u{2ca8}', '\u{2ca9}'), ('\u{2caa}', '\u{2cab}'), + ('\u{2cac}', '\u{2cad}'), ('\u{2cae}', '\u{2caf}'), ('\u{2cb0}', + '\u{2cb1}'), ('\u{2cb2}', '\u{2cb3}'), ('\u{2cb4}', '\u{2cb5}'), + ('\u{2cb6}', '\u{2cb7}'), ('\u{2cb8}', '\u{2cb9}'), ('\u{2cba}', + '\u{2cbb}'), ('\u{2cbc}', '\u{2cbd}'), ('\u{2cbe}', '\u{2cbf}'), + ('\u{2cc0}', '\u{2cc1}'), ('\u{2cc2}', '\u{2cc3}'), ('\u{2cc4}', + '\u{2cc5}'), ('\u{2cc6}', '\u{2cc7}'), ('\u{2cc8}', '\u{2cc9}'), + ('\u{2cca}', '\u{2ccb}'), ('\u{2ccc}', '\u{2ccd}'), ('\u{2cce}', + '\u{2ccf}'), ('\u{2cd0}', '\u{2cd1}'), ('\u{2cd2}', '\u{2cd3}'), + ('\u{2cd4}', '\u{2cd5}'), ('\u{2cd6}', '\u{2cd7}'), ('\u{2cd8}', + '\u{2cd9}'), ('\u{2cda}', '\u{2cdb}'), ('\u{2cdc}', '\u{2cdd}'), + ('\u{2cde}', '\u{2cdf}'), ('\u{2ce0}', '\u{2ce1}'), ('\u{2ce2}', + '\u{2ce3}'), ('\u{2ceb}', '\u{2cec}'), ('\u{2ced}', '\u{2cee}'), + ('\u{2cf2}', '\u{2cf3}'), ('\u{a640}', '\u{a641}'), ('\u{a642}', + '\u{a643}'), ('\u{a644}', '\u{a645}'), ('\u{a646}', '\u{a647}'), + ('\u{a648}', '\u{a649}'), ('\u{a64a}', '\u{a64b}'), ('\u{a64c}', + '\u{a64d}'), ('\u{a64e}', '\u{a64f}'), ('\u{a650}', '\u{a651}'), + ('\u{a652}', '\u{a653}'), ('\u{a654}', '\u{a655}'), ('\u{a656}', + '\u{a657}'), ('\u{a658}', '\u{a659}'), ('\u{a65a}', '\u{a65b}'), + ('\u{a65c}', '\u{a65d}'), ('\u{a65e}', '\u{a65f}'), ('\u{a660}', + '\u{a661}'), ('\u{a662}', '\u{a663}'), ('\u{a664}', '\u{a665}'), + ('\u{a666}', '\u{a667}'), ('\u{a668}', '\u{a669}'), ('\u{a66a}', + '\u{a66b}'), ('\u{a66c}', '\u{a66d}'), ('\u{a680}', '\u{a681}'), + ('\u{a682}', '\u{a683}'), ('\u{a684}', '\u{a685}'), ('\u{a686}', + '\u{a687}'), ('\u{a688}', '\u{a689}'), ('\u{a68a}', '\u{a68b}'), + ('\u{a68c}', '\u{a68d}'), ('\u{a68e}', '\u{a68f}'), ('\u{a690}', + '\u{a691}'), ('\u{a692}', '\u{a693}'), ('\u{a694}', '\u{a695}'), + ('\u{a696}', '\u{a697}'), ('\u{a698}', '\u{a699}'), ('\u{a69a}', + '\u{a69b}'), ('\u{a722}', '\u{a723}'), ('\u{a724}', '\u{a725}'), + ('\u{a726}', '\u{a727}'), ('\u{a728}', '\u{a729}'), ('\u{a72a}', + '\u{a72b}'), ('\u{a72c}', '\u{a72d}'), ('\u{a72e}', '\u{a72f}'), + ('\u{a732}', '\u{a733}'), ('\u{a734}', '\u{a735}'), ('\u{a736}', + '\u{a737}'), ('\u{a738}', '\u{a739}'), ('\u{a73a}', '\u{a73b}'), + ('\u{a73c}', '\u{a73d}'), ('\u{a73e}', '\u{a73f}'), ('\u{a740}', + '\u{a741}'), ('\u{a742}', '\u{a743}'), ('\u{a744}', '\u{a745}'), + ('\u{a746}', '\u{a747}'), ('\u{a748}', '\u{a749}'), ('\u{a74a}', + '\u{a74b}'), ('\u{a74c}', '\u{a74d}'), ('\u{a74e}', '\u{a74f}'), + ('\u{a750}', '\u{a751}'), ('\u{a752}', '\u{a753}'), ('\u{a754}', + '\u{a755}'), ('\u{a756}', '\u{a757}'), ('\u{a758}', '\u{a759}'), + ('\u{a75a}', '\u{a75b}'), ('\u{a75c}', '\u{a75d}'), ('\u{a75e}', + '\u{a75f}'), ('\u{a760}', '\u{a761}'), ('\u{a762}', '\u{a763}'), + ('\u{a764}', '\u{a765}'), ('\u{a766}', '\u{a767}'), ('\u{a768}', + '\u{a769}'), ('\u{a76a}', '\u{a76b}'), ('\u{a76c}', '\u{a76d}'), + ('\u{a76e}', '\u{a76f}'), ('\u{a779}', '\u{a77a}'), ('\u{a77b}', + '\u{a77c}'), ('\u{a77d}', '\u{1d79}'), ('\u{a77e}', '\u{a77f}'), + ('\u{a780}', '\u{a781}'), ('\u{a782}', '\u{a783}'), ('\u{a784}', + '\u{a785}'), ('\u{a786}', '\u{a787}'), ('\u{a78b}', '\u{a78c}'), + ('\u{a78d}', '\u{265}'), ('\u{a790}', '\u{a791}'), ('\u{a792}', + '\u{a793}'), ('\u{a796}', '\u{a797}'), ('\u{a798}', '\u{a799}'), + ('\u{a79a}', '\u{a79b}'), ('\u{a79c}', '\u{a79d}'), ('\u{a79e}', + '\u{a79f}'), ('\u{a7a0}', '\u{a7a1}'), ('\u{a7a2}', '\u{a7a3}'), + ('\u{a7a4}', '\u{a7a5}'), ('\u{a7a6}', '\u{a7a7}'), ('\u{a7a8}', + '\u{a7a9}'), ('\u{a7aa}', '\u{266}'), ('\u{a7ab}', '\u{25c}'), + ('\u{a7ac}', '\u{261}'), ('\u{a7ad}', '\u{26c}'), ('\u{a7b0}', + '\u{29e}'), ('\u{a7b1}', '\u{287}'), ('\u{ff21}', '\u{ff41}'), + ('\u{ff22}', '\u{ff42}'), ('\u{ff23}', '\u{ff43}'), ('\u{ff24}', + '\u{ff44}'), ('\u{ff25}', '\u{ff45}'), ('\u{ff26}', '\u{ff46}'), + ('\u{ff27}', '\u{ff47}'), ('\u{ff28}', '\u{ff48}'), ('\u{ff29}', + '\u{ff49}'), ('\u{ff2a}', '\u{ff4a}'), ('\u{ff2b}', '\u{ff4b}'), + ('\u{ff2c}', '\u{ff4c}'), ('\u{ff2d}', '\u{ff4d}'), ('\u{ff2e}', + '\u{ff4e}'), ('\u{ff2f}', '\u{ff4f}'), ('\u{ff30}', '\u{ff50}'), + ('\u{ff31}', '\u{ff51}'), ('\u{ff32}', '\u{ff52}'), ('\u{ff33}', + '\u{ff53}'), ('\u{ff34}', '\u{ff54}'), ('\u{ff35}', '\u{ff55}'), + ('\u{ff36}', '\u{ff56}'), ('\u{ff37}', '\u{ff57}'), ('\u{ff38}', + '\u{ff58}'), ('\u{ff39}', '\u{ff59}'), ('\u{ff3a}', '\u{ff5a}'), + ('\u{10400}', '\u{10428}'), ('\u{10401}', '\u{10429}'), ('\u{10402}', + '\u{1042a}'), ('\u{10403}', '\u{1042b}'), ('\u{10404}', '\u{1042c}'), + ('\u{10405}', '\u{1042d}'), ('\u{10406}', '\u{1042e}'), ('\u{10407}', + '\u{1042f}'), ('\u{10408}', '\u{10430}'), ('\u{10409}', '\u{10431}'), + ('\u{1040a}', '\u{10432}'), ('\u{1040b}', '\u{10433}'), ('\u{1040c}', + '\u{10434}'), ('\u{1040d}', '\u{10435}'), ('\u{1040e}', '\u{10436}'), + ('\u{1040f}', '\u{10437}'), ('\u{10410}', '\u{10438}'), ('\u{10411}', + '\u{10439}'), ('\u{10412}', '\u{1043a}'), ('\u{10413}', '\u{1043b}'), + ('\u{10414}', '\u{1043c}'), ('\u{10415}', '\u{1043d}'), ('\u{10416}', + '\u{1043e}'), ('\u{10417}', '\u{1043f}'), ('\u{10418}', '\u{10440}'), + ('\u{10419}', '\u{10441}'), ('\u{1041a}', '\u{10442}'), ('\u{1041b}', + '\u{10443}'), ('\u{1041c}', '\u{10444}'), ('\u{1041d}', '\u{10445}'), + ('\u{1041e}', '\u{10446}'), ('\u{1041f}', '\u{10447}'), ('\u{10420}', + '\u{10448}'), ('\u{10421}', '\u{10449}'), ('\u{10422}', '\u{1044a}'), + ('\u{10423}', '\u{1044b}'), ('\u{10424}', '\u{1044c}'), ('\u{10425}', + '\u{1044d}'), ('\u{10426}', '\u{1044e}'), ('\u{10427}', '\u{1044f}'), + ('\u{118a0}', '\u{118c0}'), ('\u{118a1}', '\u{118c1}'), ('\u{118a2}', + '\u{118c2}'), ('\u{118a3}', '\u{118c3}'), ('\u{118a4}', '\u{118c4}'), + ('\u{118a5}', '\u{118c5}'), ('\u{118a6}', '\u{118c6}'), ('\u{118a7}', + '\u{118c7}'), ('\u{118a8}', '\u{118c8}'), ('\u{118a9}', '\u{118c9}'), + ('\u{118aa}', '\u{118ca}'), ('\u{118ab}', '\u{118cb}'), ('\u{118ac}', + '\u{118cc}'), ('\u{118ad}', '\u{118cd}'), ('\u{118ae}', '\u{118ce}'), + ('\u{118af}', '\u{118cf}'), ('\u{118b0}', '\u{118d0}'), ('\u{118b1}', + '\u{118d1}'), ('\u{118b2}', '\u{118d2}'), ('\u{118b3}', '\u{118d3}'), + ('\u{118b4}', '\u{118d4}'), ('\u{118b5}', '\u{118d5}'), ('\u{118b6}', + '\u{118d6}'), ('\u{118b7}', '\u{118d7}'), ('\u{118b8}', '\u{118d8}'), + ('\u{118b9}', '\u{118d9}'), ('\u{118ba}', '\u{118da}'), ('\u{118bb}', + '\u{118db}'), ('\u{118bc}', '\u{118dc}'), ('\u{118bd}', '\u{118dd}'), + ('\u{118be}', '\u{118de}'), ('\u{118bf}', '\u{118df}') + ]; + +} + diff --git a/deps/rustc-serialize-0.3.15/.gitignore b/deps/rustc-serialize-0.3.15/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/rustc-serialize-0.3.15/.travis.yml b/deps/rustc-serialize-0.3.15/.travis.yml new file mode 100644 index 000000000..eb446b23f --- /dev/null +++ b/deps/rustc-serialize-0.3.15/.travis.yml @@ -0,0 +1,26 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - | + [ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '<meta http-equiv=refresh content=0;url=/rustc-serialize/rustc_serialize/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: f0CwX+CnvRbEqK3H6zhBQe4u0t14OQvyd6nUhq/oXkJ6LdtrSx+qQtLSmAU7L8p1IXyP8csxv37bTdEB7/U1c6bJcN2OXHrw9nD0NDvZEs1zSZvFQBm+YBwV7EaposPHCeqee3X9b00g7+bObywMYtEkk7yD2NiOY9SjMRcjTLQ= +notifications: + email: + on_success: never diff --git a/deps/rustc-serialize-0.3.15/Cargo.toml b/deps/rustc-serialize-0.3.15/Cargo.toml new file mode 100644 index 000000000..e39acdfc1 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/Cargo.toml @@ -0,0 +1,18 @@ +[package] + +name = "rustc-serialize" +version = "0.3.15" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/rustc-serialize" +homepage = "https://github.com/rust-lang/rustc-serialize" +documentation = "http://doc.rust-lang.org/rustc-serialize" +description = """ +Generic serialization/deserialization support corresponding to the +`derive(RustcEncodable, RustcDecodable)` mode in the compiler. Also includes +support for hex, base64, and json encoding and decoding. +""" + +[dev-dependencies] +rand = "0.3" diff --git a/deps/rustc-serialize-0.3.15/LICENSE-APACHE b/deps/rustc-serialize-0.3.15/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/rustc-serialize-0.3.15/LICENSE-MIT b/deps/rustc-serialize-0.3.15/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/rustc-serialize-0.3.15/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/rustc-serialize-0.3.15/README.md b/deps/rustc-serialize-0.3.15/README.md new file mode 100644 index 000000000..e8db8b91e --- /dev/null +++ b/deps/rustc-serialize-0.3.15/README.md @@ -0,0 +1,24 @@ +# rustc-serialize + +Serialization and deserialization support provided by the compiler in the form +of `derive(RustcEncodable, RustcDecodable)`. + +[![Linux Build Status](https://travis-ci.org/rust-lang/rustc-serialize.svg?branch=master)](https://travis-ci.org/rust-lang/rustc-serialize) +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/ka194de75aapwpft?svg=true)](https://ci.appveyor.com/project/alexcrichton/rustc-serialize) + +[Documentation](http://doc.rust-lang.org/rustc-serialize) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +rustc-serialize = "0.3" +``` + +and this to your crate root: + +```rust +extern crate rustc_serialize; +``` diff --git a/deps/rustc-serialize-0.3.15/appveyor.yml b/deps/rustc-serialize-0.3.15/appveyor.yml new file mode 100644 index 000000000..f74c851ad --- /dev/null +++ b/deps/rustc-serialize-0.3.15/appveyor.yml @@ -0,0 +1,11 @@ +install: + - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' + - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/rustc-serialize-0.3.15/benches/base64.rs b/deps/rustc-serialize-0.3.15/benches/base64.rs new file mode 100644 index 000000000..6a6565bc1 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/benches/base64.rs @@ -0,0 +1,48 @@ +#![feature(test)] + +extern crate test; +extern crate rustc_serialize; + +use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD}; +use test::Bencher; + +#[bench] +fn bench_to_base64(b: &mut Bencher) { + let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ + ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; + b.iter(|| { + s.as_bytes().to_base64(STANDARD); + }); + b.bytes = s.len() as u64; +} + +#[bench] +fn bench_from_base64(b: &mut Bencher) { + let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ + ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; + let sb = s.as_bytes().to_base64(STANDARD); + b.iter(|| { + sb.from_base64().unwrap(); + }); + b.bytes = sb.len() as u64; +} + + +#[bench] +fn bench_to_base64_large(b: &mut Bencher) { + let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect(); + b.iter(|| { + s.to_base64(STANDARD); + }); + b.bytes = s.len() as u64; +} + +#[bench] +fn bench_from_base64_large(b: &mut Bencher) { + let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect(); + let sb = s.to_base64(STANDARD); + b.iter(|| { + sb.from_base64().unwrap(); + }); + b.bytes = sb.len() as u64; +} diff --git a/deps/rustc-serialize-0.3.15/benches/hex.rs b/deps/rustc-serialize-0.3.15/benches/hex.rs new file mode 100644 index 000000000..97a7735e8 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/benches/hex.rs @@ -0,0 +1,28 @@ +#![feature(test)] + +extern crate test; +extern crate rustc_serialize; + +use test::Bencher; +use rustc_serialize::hex::{FromHex, ToHex}; + +#[bench] +fn bench_to_hex(b: &mut Bencher) { + let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ + ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; + b.iter(|| { + s.as_bytes().to_hex(); + }); + b.bytes = s.len() as u64; +} + +#[bench] +fn bench_from_hex(b: &mut Bencher) { + let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ + ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; + let sb = s.as_bytes().to_hex(); + b.iter(|| { + sb.from_hex().unwrap(); + }); + b.bytes = sb.len() as u64; +} diff --git a/deps/rustc-serialize-0.3.15/benches/json.rs b/deps/rustc-serialize-0.3.15/benches/json.rs new file mode 100644 index 000000000..20768e116 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/benches/json.rs @@ -0,0 +1,84 @@ +#![feature(test)] + +extern crate test; +extern crate rustc_serialize; + +use std::string; +use rustc_serialize::json::{Json, Parser}; +use test::Bencher; + +#[bench] +fn bench_streaming_small(b: &mut Bencher) { + b.iter( || { + let mut parser = Parser::new( + r#"{ + "a": 1.0, + "b": [ + true, + "foo\nbar", + { "c": {"d": null} } + ] + }"#.chars() + ); + loop { + match parser.next() { + None => return, + _ => {} + } + } + }); +} +#[bench] +fn bench_small(b: &mut Bencher) { + b.iter( || { + let _ = Json::from_str(r#"{ + "a": 1.0, + "b": [ + true, + "foo\nbar", + { "c": {"d": null} } + ] + }"#); + }); +} + +#[bench] +fn bench_decode_hex_escape(b: &mut Bencher) { + let mut src = "\"".to_string(); + for _ in 0..10 { + src.push_str("\\uF975\\uf9bc\\uF9A0\\uF9C4\\uF975\\uf9bc\\uF9A0\\uF9C4"); + } + src.push_str("\""); + b.iter( || { + let _ = Json::from_str(&src); + }); +} + +fn big_json() -> string::String { + let mut src = "[\n".to_string(); + for _ in 0..500 { + src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \ + [1,2,3]},"#); + } + src.push_str("{}]"); + return src; +} + +#[bench] +fn bench_streaming_large(b: &mut Bencher) { + let src = big_json(); + b.iter( || { + let mut parser = Parser::new(src.chars()); + loop { + match parser.next() { + None => return, + _ => {} + } + } + }); +} +#[bench] +fn bench_large(b: &mut Bencher) { + let src = big_json(); + b.iter( || { let _ = Json::from_str(&src); }); +} diff --git a/deps/rustc-serialize-0.3.15/src/base64.rs b/deps/rustc-serialize-0.3.15/src/base64.rs new file mode 100644 index 000000000..1567bc0a8 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/src/base64.rs @@ -0,0 +1,468 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// ignore-lexer-test FIXME #15679 + +//! Base64 binary-to-text encoding + +pub use self::FromBase64Error::*; +pub use self::CharacterSet::*; + +use std::fmt; +use std::error; + +/// Available encoding character sets +#[derive(Clone, Copy)] +pub enum CharacterSet { + /// The standard character set (uses `+` and `/`) + Standard, + /// The URL safe character set (uses `-` and `_`) + UrlSafe +} + +/// Available newline types +#[derive(Clone, Copy)] +pub enum Newline { + /// A linefeed (i.e. Unix-style newline) + LF, + /// A carriage return and a linefeed (i.e. Windows-style newline) + CRLF +} + +/// Contains configuration parameters for `to_base64`. +#[derive(Clone, Copy)] +pub struct Config { + /// Character set to use + pub char_set: CharacterSet, + /// Newline to use + pub newline: Newline, + /// True to pad output with `=` characters + pub pad: bool, + /// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping + pub line_length: Option<usize> +} + +/// Configuration for RFC 4648 standard base64 encoding +pub static STANDARD: Config = + Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: None}; + +/// Configuration for RFC 4648 base64url encoding +pub static URL_SAFE: Config = + Config {char_set: UrlSafe, newline: Newline::CRLF, pad: false, line_length: None}; + +/// Configuration for RFC 2045 MIME base64 encoding +pub static MIME: Config = + Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: Some(76)}; + +static STANDARD_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + abcdefghijklmnopqrstuvwxyz\ + 0123456789+/"; + +static URLSAFE_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + abcdefghijklmnopqrstuvwxyz\ + 0123456789-_"; + +/// A trait for converting a value to base64 encoding. +pub trait ToBase64 { + /// Converts the value of `self` to a base64 value following the specified + /// format configuration, returning the owned string. + fn to_base64(&self, config: Config) -> String; +} + +impl ToBase64 for [u8] { + /// Turn a vector of `u8` bytes into a base64 string. + /// + /// # Example + /// + /// ```rust + /// extern crate rustc_serialize; + /// use rustc_serialize::base64::{ToBase64, STANDARD}; + /// + /// fn main () { + /// let str = [52,32].to_base64(STANDARD); + /// println!("base 64 output: {:?}", str); + /// } + /// ``` + fn to_base64(&self, config: Config) -> String { + let bytes = match config.char_set { + Standard => STANDARD_CHARS, + UrlSafe => URLSAFE_CHARS + }; + + let len = self.len(); + let newline = match config.newline { + Newline::LF => "\n", + Newline::CRLF => "\r\n", + }; + + // Preallocate memory. + let mut prealloc_len = (len + 2) / 3 * 4; + if let Some(line_length) = config.line_length { + let num_lines = (prealloc_len - 1) / line_length; + prealloc_len += num_lines * newline.bytes().count(); + } + + let mut out_bytes = vec![b'='; prealloc_len]; + + // Deal with padding bytes + let mod_len = len % 3; + + // Use iterators to reduce branching + { + let mut cur_length = 0; + + let mut s_in = self[..len - mod_len].iter().map(|&x| x as u32); + let mut s_out = out_bytes.iter_mut(); + + // Convenient shorthand + let enc = |val| bytes[val as usize]; + let mut write = |val| *s_out.next().unwrap() = val; + + // Iterate though blocks of 4 + while let (Some(first), Some(second), Some(third)) = + (s_in.next(), s_in.next(), s_in.next()) { + + // Line break if needed + if let Some(line_length) = config.line_length { + if cur_length >= line_length { + for b in newline.bytes() { write(b) }; + cur_length = 0; + } + } + + let n = first << 16 | second << 8 | third; + + // This 24-bit number gets separated into four 6-bit numbers. + write(enc((n >> 18) & 63)); + write(enc((n >> 12) & 63)); + write(enc((n >> 6 ) & 63)); + write(enc((n >> 0 ) & 63)); + + cur_length += 4; + } + + // Line break only needed if padding is required + if mod_len != 0 { + if let Some(line_length) = config.line_length { + if cur_length >= line_length { + for b in newline.bytes() { write(b) }; + } + } + } + + // Heh, would be cool if we knew this was exhaustive + // (the dream of bounded integer types) + match mod_len { + 0 => (), + 1 => { + let n = (self[len-1] as u32) << 16; + write(enc((n >> 18) & 63)); + write(enc((n >> 12) & 63)); + } + 2 => { + let n = (self[len-2] as u32) << 16 | + (self[len-1] as u32) << 8; + write(enc((n >> 18) & 63)); + write(enc((n >> 12) & 63)); + write(enc((n >> 6 ) & 63)); + } + _ => panic!("Algebra is broken, please alert the math police") + } + } + + // We get padding for "free", so only have to drop it if unwanted. + if !config.pad { + while let Some(&b'=') = out_bytes.last() { + out_bytes.pop(); + } + } + + unsafe { String::from_utf8_unchecked(out_bytes) } + } +} + +/// A trait for converting from base64 encoded values. +pub trait FromBase64 { + /// Converts the value of `self`, interpreted as base64 encoded data, into + /// an owned vector of bytes, returning the vector. + fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>; +} + +/// Errors that can occur when decoding a base64 encoded string +#[derive(Clone, Copy)] +pub enum FromBase64Error { + /// The input contained a character not part of the base64 format + InvalidBase64Byte(u8, usize), + /// The input had an invalid length + InvalidBase64Length, +} + +impl fmt::Debug for FromBase64Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + InvalidBase64Byte(ch, idx) => + write!(f, "Invalid character '{}' at position {}", ch, idx), + InvalidBase64Length => write!(f, "Invalid length"), + } + } +} + +impl error::Error for FromBase64Error { + fn description(&self) -> &str { + match *self { + InvalidBase64Byte(_, _) => "invalid character", + InvalidBase64Length => "invalid length", + } + } +} + +impl fmt::Display for FromBase64Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self, f) + } +} + +impl FromBase64 for str { + /// Convert any base64 encoded string (literal, `@`, `&`, or `~`) + /// to the byte values it encodes. + /// + /// You can use the `String::from_utf8` function to turn a `Vec<u8>` into a + /// string with characters corresponding to those values. + /// + /// # Example + /// + /// This converts a string literal to base64 and back. + /// + /// ```rust + /// extern crate rustc_serialize; + /// use rustc_serialize::base64::{ToBase64, FromBase64, STANDARD}; + /// + /// fn main () { + /// let hello_str = b"Hello, World".to_base64(STANDARD); + /// println!("base64 output: {}", hello_str); + /// let res = hello_str.from_base64(); + /// if res.is_ok() { + /// let opt_bytes = String::from_utf8(res.unwrap()); + /// if opt_bytes.is_ok() { + /// println!("decoded from base64: {:?}", opt_bytes.unwrap()); + /// } + /// } + /// } + /// ``` + #[inline] + fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> { + self.as_bytes().from_base64() + } +} + +impl FromBase64 for [u8] { + fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> { + let mut r = Vec::with_capacity(self.len()); + let mut buf: u32 = 0; + let mut modulus = 0; + + let mut it = self.iter(); + for byte in it.by_ref() { + let code = DECODE_TABLE[*byte as usize]; + if code >= SPECIAL_CODES_START { + match code { + NEWLINE_CODE => continue, + EQUALS_CODE => break, + INVALID_CODE => return Err(InvalidBase64Byte( + *byte, (byte as *const _ as usize) - self.as_ptr() as usize)), + _ => unreachable!(), + } + } + buf = (buf | code as u32) << 6; + modulus += 1; + if modulus == 4 { + modulus = 0; + r.push((buf >> 22) as u8); + r.push((buf >> 14) as u8); + r.push((buf >> 6 ) as u8); + } + } + + for byte in it { + match *byte { + b'=' | b'\r' | b'\n' => continue, + _ => return Err(InvalidBase64Byte( + *byte, (byte as *const _ as usize) - self.as_ptr() as usize)), + } + } + + match modulus { + 2 => { + r.push((buf >> 10) as u8); + } + 3 => { + r.push((buf >> 16) as u8); + r.push((buf >> 8 ) as u8); + } + 0 => (), + _ => return Err(InvalidBase64Length), + } + + Ok(r) + } +} + +/// Base64 decoding lookup table, generated using: +/// ```rust +/// let mut ch = 0u8; +/// loop { +/// let code = match ch { +/// b'A'...b'Z' => ch - 0x41, +/// b'a'...b'z' => ch - 0x47, +/// b'0'...b'9' => ch + 0x04, +/// b'+' | b'-' => 0x3E, +/// b'/' | b'_' => 0x3F, +/// b'=' => 0xFE, +/// b'\r' | b'\n' => 0xFD, +/// _ => 0xFF, +/// }; +/// print!("0x{:02X}, ", code); +/// if ch % 16 == 15 { println!(""); } +/// else if ch == 0xFF { break; } +/// ch += 1; +/// } +/// println!(""); +/// } +/// ``` +const DECODE_TABLE: [u8; 256] = [ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0x3E, 0xFF, 0x3F, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, + 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, + 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +]; +const INVALID_CODE: u8 = 0xFF; +const EQUALS_CODE: u8 = 0xFE; +const NEWLINE_CODE: u8 = 0xFD; +const SPECIAL_CODES_START: u8 = NEWLINE_CODE; + +#[cfg(test)] +mod tests { + use base64::{Config, Newline, FromBase64, ToBase64, STANDARD, URL_SAFE}; + + #[test] + fn test_to_base64_basic() { + assert_eq!("".as_bytes().to_base64(STANDARD), ""); + assert_eq!("f".as_bytes().to_base64(STANDARD), "Zg=="); + assert_eq!("fo".as_bytes().to_base64(STANDARD), "Zm8="); + assert_eq!("foo".as_bytes().to_base64(STANDARD), "Zm9v"); + assert_eq!("foob".as_bytes().to_base64(STANDARD), "Zm9vYg=="); + assert_eq!("fooba".as_bytes().to_base64(STANDARD), "Zm9vYmE="); + assert_eq!("foobar".as_bytes().to_base64(STANDARD), "Zm9vYmFy"); + } + + #[test] + fn test_to_base64_crlf_line_break() { + assert!(![08; 1000].to_base64(Config {line_length: None, ..STANDARD}) + .contains("\r\n")); + assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), + ..STANDARD}), + "Zm9v\r\nYmFy"); + } + + #[test] + fn test_to_base64_lf_line_break() { + assert!(![08; 1000].to_base64(Config {line_length: None, + newline: Newline::LF, + ..STANDARD}) + .contains("\n")); + assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), + newline: Newline::LF, + ..STANDARD}), + "Zm9v\nYmFy"); + } + + #[test] + fn test_to_base64_padding() { + assert_eq!("f".as_bytes().to_base64(Config {pad: false, ..STANDARD}), "Zg"); + assert_eq!("fo".as_bytes().to_base64(Config {pad: false, ..STANDARD}), "Zm8"); + } + + #[test] + fn test_to_base64_url_safe() { + assert_eq!([251, 255].to_base64(URL_SAFE), "-_8"); + assert_eq!([251, 255].to_base64(STANDARD), "+/8="); + } + + #[test] + fn test_from_base64_basic() { + assert_eq!("".from_base64().unwrap(), b""); + assert_eq!("Zg==".from_base64().unwrap(), b"f"); + assert_eq!("Zm8=".from_base64().unwrap(), b"fo"); + assert_eq!("Zm9v".from_base64().unwrap(), b"foo"); + assert_eq!("Zm9vYg==".from_base64().unwrap(), b"foob"); + assert_eq!("Zm9vYmE=".from_base64().unwrap(), b"fooba"); + assert_eq!("Zm9vYmFy".from_base64().unwrap(), b"foobar"); + } + + #[test] + fn test_from_base64_bytes() { + assert_eq!(b"Zm9vYmFy".from_base64().unwrap(), b"foobar"); + } + + #[test] + fn test_from_base64_newlines() { + assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(), + b"foobar"); + assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(), + b"foob"); + assert_eq!("Zm9v\nYmFy".from_base64().unwrap(), + b"foobar"); + assert_eq!("Zm9vYg==\n".from_base64().unwrap(), + b"foob"); + } + + #[test] + fn test_from_base64_urlsafe() { + assert_eq!("-_8".from_base64().unwrap(), "+/8=".from_base64().unwrap()); + } + + #[test] + fn test_from_base64_invalid_char() { + assert!("Zm$=".from_base64().is_err()); + assert!("Zg==$".from_base64().is_err()); + } + + #[test] + fn test_from_base64_invalid_padding() { + assert!("Z===".from_base64().is_err()); + } + + #[test] + fn test_base64_random() { + use rand::{thread_rng, Rng}; + + for _ in 0..1000 { + let times = thread_rng().gen_range(1, 100); + let v = thread_rng().gen_iter::<u8>().take(times) + .collect::<Vec<_>>(); + assert_eq!(v.to_base64(STANDARD) + .from_base64() + .unwrap(), + v); + } + } +} diff --git a/deps/rustc-serialize-0.3.15/src/collection_impls.rs b/deps/rustc-serialize-0.3.15/src/collection_impls.rs new file mode 100644 index 000000000..6ab4b7cef --- /dev/null +++ b/deps/rustc-serialize-0.3.15/src/collection_impls.rs @@ -0,0 +1,186 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementations of serialization for structures found in libcollections + +use std::hash::Hash; + +use {Decodable, Encodable, Decoder, Encoder}; +use std::collections::{LinkedList, VecDeque, BTreeMap, BTreeSet, HashMap, HashSet}; + +impl< + T: Encodable +> Encodable for LinkedList<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_seq(self.len(), |s| { + for (i, e) in self.iter().enumerate() { + try!(s.emit_seq_elt(i, |s| e.encode(s))); + } + Ok(()) + }) + } +} + +impl<T:Decodable> Decodable for LinkedList<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<LinkedList<T>, D::Error> { + d.read_seq(|d, len| { + let mut list = LinkedList::new(); + for i in 0..len { + list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); + } + Ok(list) + }) + } +} + +impl<T: Encodable> Encodable for VecDeque<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_seq(self.len(), |s| { + for (i, e) in self.iter().enumerate() { + try!(s.emit_seq_elt(i, |s| e.encode(s))); + } + Ok(()) + }) + } +} + +impl<T:Decodable> Decodable for VecDeque<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<VecDeque<T>, D::Error> { + d.read_seq(|d, len| { + let mut deque: VecDeque<T> = VecDeque::new(); + for i in 0..len { + deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); + } + Ok(deque) + }) + } +} + +impl< + K: Encodable + PartialEq + Ord, + V: Encodable + PartialEq +> Encodable for BTreeMap<K, V> { + fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { + e.emit_map(self.len(), |e| { + let mut i = 0; + for (key, val) in self.iter() { + try!(e.emit_map_elt_key(i, |e| key.encode(e))); + try!(e.emit_map_elt_val(i, |e| val.encode(e))); + i += 1; + } + Ok(()) + }) + } +} + +impl< + K: Decodable + PartialEq + Ord, + V: Decodable + PartialEq +> Decodable for BTreeMap<K, V> { + fn decode<D: Decoder>(d: &mut D) -> Result<BTreeMap<K, V>, D::Error> { + d.read_map(|d, len| { + let mut map = BTreeMap::new(); + for i in 0..len { + let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d))); + let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d))); + map.insert(key, val); + } + Ok(map) + }) + } +} + +impl< + T: Encodable + PartialEq + Ord +> Encodable for BTreeSet<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_seq(self.len(), |s| { + let mut i = 0; + for e in self.iter() { + try!(s.emit_seq_elt(i, |s| e.encode(s))); + i += 1; + } + Ok(()) + }) + } +} + +impl< + T: Decodable + PartialEq + Ord +> Decodable for BTreeSet<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<BTreeSet<T>, D::Error> { + d.read_seq(|d, len| { + let mut set = BTreeSet::new(); + for i in 0..len { + set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); + } + Ok(set) + }) + } +} + +impl<K, V> Encodable for HashMap<K, V> + where K: Encodable + Hash + Eq, + V: Encodable, +{ + fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> { + e.emit_map(self.len(), |e| { + let mut i = 0; + for (key, val) in self.iter() { + try!(e.emit_map_elt_key(i, |e| key.encode(e))); + try!(e.emit_map_elt_val(i, |e| val.encode(e))); + i += 1; + } + Ok(()) + }) + } +} + +impl<K, V> Decodable for HashMap<K, V> + where K: Decodable + Hash + Eq, + V: Decodable, +{ + fn decode<D: Decoder>(d: &mut D) -> Result<HashMap<K, V>, D::Error> { + d.read_map(|d, len| { + let mut map = HashMap::with_capacity(len); + for i in 0..len { + let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d))); + let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d))); + map.insert(key, val); + } + Ok(map) + }) + } +} + +impl<T> Encodable for HashSet<T> where T: Encodable + Hash + Eq { + fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> { + s.emit_seq(self.len(), |s| { + let mut i = 0; + for e in self.iter() { + try!(s.emit_seq_elt(i, |s| e.encode(s))); + i += 1; + } + Ok(()) + }) + } +} + +impl<T> Decodable for HashSet<T> where T: Decodable + Hash + Eq, { + fn decode<D: Decoder>(d: &mut D) -> Result<HashSet<T>, D::Error> { + d.read_seq(|d, len| { + let mut set = HashSet::with_capacity(len); + for i in 0..len { + set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); + } + Ok(set) + }) + } +} diff --git a/deps/rustc-serialize-0.3.15/src/hex.rs b/deps/rustc-serialize-0.3.15/src/hex.rs new file mode 100644 index 000000000..08d25fdf2 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/src/hex.rs @@ -0,0 +1,209 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// ignore-lexer-test FIXME #15679 + +//! Hex binary-to-text encoding + +pub use self::FromHexError::*; + +use std::fmt; +use std::error; + +/// A trait for converting a value to hexadecimal encoding +pub trait ToHex { + /// Converts the value of `self` to a hex value, returning the owned + /// string. + fn to_hex(&self) -> String; +} + +static CHARS: &'static[u8] = b"0123456789abcdef"; + +impl ToHex for [u8] { + /// Turn a vector of `u8` bytes into a hexadecimal string. + /// + /// # Example + /// + /// ```rust + /// extern crate rustc_serialize; + /// use rustc_serialize::hex::ToHex; + /// + /// fn main () { + /// let str = [52,32].to_hex(); + /// println!("{}", str); + /// } + /// ``` + fn to_hex(&self) -> String { + let mut v = Vec::with_capacity(self.len() * 2); + for &byte in self.iter() { + v.push(CHARS[(byte >> 4) as usize]); + v.push(CHARS[(byte & 0xf) as usize]); + } + + unsafe { + String::from_utf8_unchecked(v) + } + } +} + +/// A trait for converting hexadecimal encoded values +pub trait FromHex { + /// Converts the value of `self`, interpreted as hexadecimal encoded data, + /// into an owned vector of bytes, returning the vector. + fn from_hex(&self) -> Result<Vec<u8>, FromHexError>; +} + +/// Errors that can occur when decoding a hex encoded string +#[derive(Clone, Copy)] +pub enum FromHexError { + /// The input contained a character not part of the hex format + InvalidHexCharacter(char, usize), + /// The input had an invalid length + InvalidHexLength, +} + +impl fmt::Debug for FromHexError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + InvalidHexCharacter(ch, idx) => + write!(f, "Invalid character '{}' at position {}", ch, idx), + InvalidHexLength => write!(f, "Invalid input length"), + } + } +} + +impl error::Error for FromHexError { + fn description(&self) -> &str { + match *self { + InvalidHexCharacter(_, _) => "invalid character", + InvalidHexLength => "invalid length", + } + } +} + +impl fmt::Display for FromHexError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self, f) + } +} + +impl FromHex for str { + /// Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) + /// to the byte values it encodes. + /// + /// You can use the `String::from_utf8` function to turn a + /// `Vec<u8>` into a string with characters corresponding to those values. + /// + /// # Example + /// + /// This converts a string literal to hexadecimal and back. + /// + /// ```rust + /// extern crate rustc_serialize; + /// use rustc_serialize::hex::{FromHex, ToHex}; + /// + /// fn main () { + /// let hello_str = "Hello, World".as_bytes().to_hex(); + /// println!("{}", hello_str); + /// let bytes = hello_str.from_hex().unwrap(); + /// println!("{:?}", bytes); + /// let result_str = String::from_utf8(bytes).unwrap(); + /// println!("{}", result_str); + /// } + /// ``` + fn from_hex(&self) -> Result<Vec<u8>, FromHexError> { + // This may be an overestimate if there is any whitespace + let mut b = Vec::with_capacity(self.len() / 2); + let mut modulus = 0; + let mut buf = 08; + + for (idx, byte) in self.bytes().enumerate() { + buf <<= 4; + + match byte { + b'A'...b'F' => buf |= byte - b'A' + 10, + b'a'...b'f' => buf |= byte - b'a' + 10, + b'0'...b'9' => buf |= byte - b'0', + b' '|b'\r'|b'\n'|b'\t' => { + buf >>= 4; + continue + } + _ => { + let ch = self[idx..].chars().next().unwrap(); + return Err(InvalidHexCharacter(ch, idx)) + } + } + + modulus += 1; + if modulus == 2 { + modulus = 0; + b.push(buf); + } + } + + match modulus { + 0 => Ok(b.into_iter().collect()), + _ => Err(InvalidHexLength), + } + } +} + +#[cfg(test)] +mod tests { + use hex::{FromHex, ToHex}; + + #[test] + pub fn test_to_hex() { + assert_eq!("foobar".as_bytes().to_hex(), "666f6f626172"); + } + + #[test] + pub fn test_from_hex_okay() { + assert_eq!("666f6f626172".from_hex().unwrap(), + b"foobar"); + assert_eq!("666F6F626172".from_hex().unwrap(), + b"foobar"); + } + + #[test] + pub fn test_from_hex_odd_len() { + assert!("666".from_hex().is_err()); + assert!("66 6".from_hex().is_err()); + } + + #[test] + pub fn test_from_hex_invalid_char() { + assert!("66y6".from_hex().is_err()); + } + + #[test] + pub fn test_from_hex_ignores_whitespace() { + assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(), + b"foobar"); + } + + #[test] + pub fn test_to_hex_all_bytes() { + for i in 0..256 { + assert_eq!([i as u8].to_hex(), format!("{:02x}", i)); + } + } + + #[test] + pub fn test_from_hex_all_bytes() { + for i in 0..256 { + let ii: &[u8] = &[i as u8]; + assert_eq!(format!("{:02x}", i).from_hex().unwrap(), + ii); + assert_eq!(format!("{:02X}", i).from_hex().unwrap(), + ii); + } + } +} diff --git a/deps/rustc-serialize-0.3.15/src/json.rs b/deps/rustc-serialize-0.3.15/src/json.rs new file mode 100644 index 000000000..1fd4c430c --- /dev/null +++ b/deps/rustc-serialize-0.3.15/src/json.rs @@ -0,0 +1,3906 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Rust JSON serialization library +// Copyright (c) 2011 Google Inc. + +//! JSON parsing and serialization +//! +//! # What is JSON? +//! +//! JSON (JavaScript Object Notation) is a way to write data in Javascript. +//! Like XML, it allows to encode structured data in a text format that can be +//! easily read by humans Its simple syntax and native compatibility with +//! JavaScript have made it a widely used format. +//! +//! Data types that can be encoded are JavaScript types (see the `Json` enum +//! for more details): +//! +//! * `I64`: equivalent to rust's `i64` +//! * `U64`: equivalent to rust's `u64` +//! * `F64`: equivalent to rust's `f64` +//! * `Boolean`: equivalent to rust's `bool` +//! * `String`: equivalent to rust's `String` +//! * `Array`: equivalent to rust's `Vec<T>`, but also allowing objects of +//! different types in the +//! same array +//! * `Object`: equivalent to rust's `BTreeMap<String, json::Json>` +//! * `Null` +//! +//! An object is a series of string keys mapping to values, in `"key": value` +//! format. Arrays are enclosed in square brackets ([ ... ]) and objects in +//! curly brackets ({ ... }). A simple JSON document encoding a person, +//! their age, address and phone numbers could look like +//! +//! ```ignore +//! { +//! "FirstName": "John", +//! "LastName": "Doe", +//! "Age": 43, +//! "Address": { +//! "Street": "Downing Street 10", +//! "City": "London", +//! "Country": "Great Britain" +//! }, +//! "PhoneNumbers": [ +//! "+44 1234567", +//! "+44 2345678" +//! ] +//! } +//! ``` +//! +//! # Rust Type-based Encoding and Decoding +//! +//! Rust provides a mechanism for low boilerplate encoding & decoding of values +//! to and from JSON via the serialization API. To be able to encode a piece +//! of data, it must implement the `rustc_serialize::Encodable` trait. To be +//! able to decode a piece of data, it must implement the +//! `rustc_serialize::Decodable` trait. The Rust compiler provides an +//! annotation to automatically generate the code for these traits: +//! `#[derive(RustcDecodable, RustcEncodable)]` +//! +//! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode +//! objects. The `ToJson` trait provides a `to_json` method to convert an +//! object into a `json::Json` value. A `json::Json` value can be encoded as a +//! string or buffer using the functions described above. You can also use the +//! `json::Encoder` object, which implements the `Encoder` trait. +//! +//! When using `ToJson` the `Encodable` trait implementation is not +//! mandatory. +//! +//! # Examples of use +//! +//! ## Using Autoserialization +//! +//! Create a struct called `TestStruct` and serialize and deserialize it to and +//! from JSON using the serialization API, using the derived serialization code. +//! +//! ```rust +//! extern crate rustc_serialize; +//! use rustc_serialize::json; +//! +//! // Automatically generate `RustcDecodable` and `RustcEncodable` trait +//! // implementations +//! #[derive(RustcDecodable, RustcEncodable)] +//! pub struct TestStruct { +//! data_int: u8, +//! data_str: String, +//! data_vector: Vec<u8>, +//! } +//! +//! fn main() { +//! let object = TestStruct { +//! data_int: 1, +//! data_str: "homura".to_string(), +//! data_vector: vec![2,3,4,5], +//! }; +//! +//! // Serialize using `json::encode` +//! let encoded = json::encode(&object).unwrap(); +//! +//! // Deserialize using `json::decode` +//! let decoded: TestStruct = json::decode(&encoded).unwrap(); +//! } +//! ``` +//! +//! ## Using the `ToJson` trait +//! +//! The examples above use the `ToJson` trait to generate the JSON string, +//! which is required for custom mappings. +//! +//! ### Simple example of `ToJson` usage +//! +//! ```rust +//! extern crate rustc_serialize; +//! use rustc_serialize::json::{self, ToJson, Json}; +//! +//! // A custom data structure +//! struct ComplexNum { +//! a: f64, +//! b: f64, +//! } +//! +//! // JSON value representation +//! impl ToJson for ComplexNum { +//! fn to_json(&self) -> Json { +//! Json::String(format!("{}+{}i", self.a, self.b)) +//! } +//! } +//! +//! // Only generate `RustcEncodable` trait implementation +//! #[derive(RustcEncodable)] +//! pub struct ComplexNumRecord { +//! uid: u8, +//! dsc: String, +//! val: Json, +//! } +//! +//! fn main() { +//! let num = ComplexNum { a: 0.0001, b: 12.539 }; +//! let data: String = json::encode(&ComplexNumRecord{ +//! uid: 1, +//! dsc: "test".to_string(), +//! val: num.to_json(), +//! }).unwrap(); +//! println!("data: {}", data); +//! // data: {"uid":1,"dsc":"test","val":"0.0001+12.539i"}; +//! } +//! ``` +//! +//! ### Verbose example of `ToJson` usage +//! +//! ```rust +//! extern crate rustc_serialize; +//! use std::collections::BTreeMap; +//! use rustc_serialize::json::{self, Json, ToJson}; +//! +//! // Only generate `Decodable` trait implementation +//! #[derive(RustcDecodable)] +//! pub struct TestStruct { +//! data_int: u8, +//! data_str: String, +//! data_vector: Vec<u8>, +//! } +//! +//! // Specify encoding method manually +//! impl ToJson for TestStruct { +//! fn to_json(&self) -> Json { +//! let mut d = BTreeMap::new(); +//! // All standard types implement `to_json()`, so use it +//! d.insert("data_int".to_string(), self.data_int.to_json()); +//! d.insert("data_str".to_string(), self.data_str.to_json()); +//! d.insert("data_vector".to_string(), self.data_vector.to_json()); +//! Json::Object(d) +//! } +//! } +//! +//! fn main() { +//! // Serialize using `ToJson` +//! let input_data = TestStruct { +//! data_int: 1, +//! data_str: "madoka".to_string(), +//! data_vector: vec![2,3,4,5], +//! }; +//! let json_obj: Json = input_data.to_json(); +//! let json_str: String = json_obj.to_string(); +//! +//! // Deserialize like before +//! let decoded: TestStruct = json::decode(&json_str).unwrap(); +//! } +//! ``` +//! +//! ## Parsing a `str` to `Json` and reading the result +//! +//! ```rust +//! extern crate rustc_serialize; +//! use rustc_serialize::json::Json; +//! +//! fn main() { +//! let data = Json::from_str("{\"foo\": 13, \"bar\": \"baz\"}").unwrap(); +//! println!("data: {}", data); +//! // data: {"bar":"baz","foo":13} +//! println!("object? {}", data.is_object()); +//! // object? true +//! +//! let obj = data.as_object().unwrap(); +//! let foo = obj.get("foo").unwrap(); +//! +//! println!("array? {:?}", foo.as_array()); +//! // array? None +//! println!("u64? {:?}", foo.as_u64()); +//! // u64? Some(13u64) +//! +//! for (key, value) in obj.iter() { +//! println!("{}: {}", key, match *value { +//! Json::U64(v) => format!("{} (u64)", v), +//! Json::String(ref v) => format!("{} (string)", v), +//! _ => format!("other") +//! }); +//! } +//! // bar: baz (string) +//! // foo: 13 (u64) +//! } +//! ``` + +use self::JsonEvent::*; +use self::ErrorCode::*; +use self::ParserError::*; +use self::DecoderError::*; +use self::ParserState::*; +use self::InternalStackElement::*; + +use std::collections::{HashMap, BTreeMap}; +use std::error::Error as StdError; +use std::i64; +use std::io::prelude::*; +use std::mem::swap; +use std::ops::Index; +use std::str::FromStr; +use std::string; +use std::{char, f64, fmt, io, str}; + +use Encodable; + +/// Represents a json value +#[derive(Clone, PartialEq, PartialOrd, Debug)] +pub enum Json { + I64(i64), + U64(u64), + F64(f64), + String(string::String), + Boolean(bool), + Array(self::Array), + Object(self::Object), + Null, +} + +pub type Array = Vec<Json>; +pub type Object = BTreeMap<string::String, Json>; + +pub struct PrettyJson<'a> { inner: &'a Json } + +pub struct AsJson<'a, T: 'a> { inner: &'a T } +pub struct AsPrettyJson<'a, T: 'a> { inner: &'a T, indent: Option<u32> } + +/// The errors that can arise while parsing a JSON stream. +#[derive(Clone, Copy, PartialEq)] +pub enum ErrorCode { + InvalidSyntax, + InvalidNumber, + EOFWhileParsingObject, + EOFWhileParsingArray, + EOFWhileParsingValue, + EOFWhileParsingString, + KeyMustBeAString, + ExpectedColon, + TrailingCharacters, + TrailingComma, + InvalidEscape, + InvalidUnicodeCodePoint, + LoneLeadingSurrogateInHexEscape, + UnexpectedEndOfHexEscape, + UnrecognizedHex, + NotFourDigit, + ControlCharacterInString, + NotUtf8, +} + +#[derive(Debug)] +pub enum ParserError { + /// msg, line, col + SyntaxError(ErrorCode, usize, usize), + IoError(io::Error), +} + +impl PartialEq for ParserError { + fn eq(&self, other: &ParserError) -> bool { + match (self, other) { + (&SyntaxError(msg0, line0, col0), &SyntaxError(msg1, line1, col1)) => + msg0 == msg1 && line0 == line1 && col0 == col1, + (&IoError(_), _) => false, + (_, &IoError(_)) => false, + } + } +} + +// Builder and Parser have the same errors. +pub type BuilderError = ParserError; + +#[derive(PartialEq, Debug)] +pub enum DecoderError { + ParseError(ParserError), + ExpectedError(string::String, string::String), + MissingFieldError(string::String), + UnknownVariantError(string::String), + ApplicationError(string::String), + EOF, +} + +#[derive(Copy, Debug)] +pub enum EncoderError { + FmtError(fmt::Error), + BadHashmapKey, +} + +impl Clone for EncoderError { + fn clone(&self) -> Self { *self } +} + +/// Returns a readable error string for a given error code. +pub fn error_str(error: ErrorCode) -> &'static str { + match error { + InvalidSyntax => "invalid syntax", + InvalidNumber => "invalid number", + EOFWhileParsingObject => "EOF While parsing object", + EOFWhileParsingArray => "EOF While parsing array", + EOFWhileParsingValue => "EOF While parsing value", + EOFWhileParsingString => "EOF While parsing string", + KeyMustBeAString => "key must be a string", + ExpectedColon => "expected `:`", + TrailingCharacters => "trailing characters", + TrailingComma => "trailing comma", + InvalidEscape => "invalid escape", + UnrecognizedHex => "invalid \\u{ esc}ape (unrecognized hex)", + NotFourDigit => "invalid \\u{ esc}ape (not four digits)", + ControlCharacterInString => "unescaped control character in string", + NotUtf8 => "contents not utf-8", + InvalidUnicodeCodePoint => "invalid Unicode code point", + LoneLeadingSurrogateInHexEscape => "lone leading surrogate in hex escape", + UnexpectedEndOfHexEscape => "unexpected end of hex escape", + } +} + +/// Shortcut function to decode a JSON `&str` into an object +pub fn decode<T: ::Decodable>(s: &str) -> DecodeResult<T> { + let json = match Json::from_str(s) { + Ok(x) => x, + Err(e) => return Err(ParseError(e)) + }; + + let mut decoder = Decoder::new(json); + ::Decodable::decode(&mut decoder) +} + +/// Shortcut function to encode a `T` into a JSON `String` +pub fn encode<T: ::Encodable>(object: &T) -> EncodeResult<string::String> { + let mut s = String::new(); + { + let mut encoder = Encoder::new(&mut s); + try!(object.encode(&mut encoder)); + } + Ok(s) +} + +impl fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + error_str(*self).fmt(f) + } +} + +impl StdError for DecoderError { + fn description(&self) -> &str { "decoder error" } + fn cause(&self) -> Option<&StdError> { + match *self { + DecoderError::ParseError(ref e) => Some(e), + _ => None, + } + } +} + +impl fmt::Display for DecoderError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self, f) + } +} + +impl From<ParserError> for DecoderError { + fn from(err: ParserError) -> DecoderError { + ParseError(From::from(err)) + } +} + +impl StdError for ParserError { + fn description(&self) -> &str { "failed to parse json" } +} + +impl fmt::Display for ParserError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self, f) + } +} + +impl From<io::Error> for ParserError { + fn from(err: io::Error) -> ParserError { + IoError(err) + } +} + +impl StdError for EncoderError { + fn description(&self) -> &str { "encoder error" } +} + +impl fmt::Display for EncoderError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self, f) + } +} + +impl From<fmt::Error> for EncoderError { + fn from(err: fmt::Error) -> EncoderError { EncoderError::FmtError(err) } +} + +pub type EncodeResult<T> = Result<T, EncoderError>; +pub type DecodeResult<T> = Result<T, DecoderError>; + +fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult<()> { + try!(wr.write_str("\"")); + + let mut start = 0; + + for (i, byte) in v.bytes().enumerate() { + let escaped = match byte { + b'"' => "\\\"", + b'\\' => "\\\\", + b'\x00' => "\\u0000", + b'\x01' => "\\u0001", + b'\x02' => "\\u0002", + b'\x03' => "\\u0003", + b'\x04' => "\\u0004", + b'\x05' => "\\u0005", + b'\x06' => "\\u0006", + b'\x07' => "\\u0007", + b'\x08' => "\\b", + b'\t' => "\\t", + b'\n' => "\\n", + b'\x0b' => "\\u000b", + b'\x0c' => "\\f", + b'\r' => "\\r", + b'\x0e' => "\\u000e", + b'\x0f' => "\\u000f", + b'\x10' => "\\u0010", + b'\x11' => "\\u0011", + b'\x12' => "\\u0012", + b'\x13' => "\\u0013", + b'\x14' => "\\u0014", + b'\x15' => "\\u0015", + b'\x16' => "\\u0016", + b'\x17' => "\\u0017", + b'\x18' => "\\u0018", + b'\x19' => "\\u0019", + b'\x1a' => "\\u001a", + b'\x1b' => "\\u001b", + b'\x1c' => "\\u001c", + b'\x1d' => "\\u001d", + b'\x1e' => "\\u001e", + b'\x1f' => "\\u001f", + b'\x7f' => "\\u007f", + _ => { continue; } + }; + + if start < i { + try!(wr.write_str(&v[start..i])); + } + + try!(wr.write_str(escaped)); + + start = i + 1; + } + + if start != v.len() { + try!(wr.write_str(&v[start..])); + } + + try!(wr.write_str("\"")); + Ok(()) +} + +fn escape_char(writer: &mut fmt::Write, v: char) -> EncodeResult<()> { + let mut buf = [0; 4]; + let _ = write!(&mut &mut buf[..], "{}", v); + let buf = unsafe { str::from_utf8_unchecked(&buf[..v.len_utf8()]) }; + escape_str(writer, buf) +} + +fn spaces(wr: &mut fmt::Write, n: u32) -> EncodeResult<()> { + let mut n = n as usize; + const BUF: &'static str = " "; + + while n >= BUF.len() { + try!(wr.write_str(BUF)); + n -= BUF.len(); + } + + if n > 0 { + try!(wr.write_str(&BUF[..n])); + } + Ok(()) +} + +fn fmt_number_or_null(v: f64) -> string::String { + use std::num::FpCategory::{Nan, Infinite}; + + match v.classify() { + Nan | Infinite => "null".to_string(), + _ => { + let s = v.to_string(); + if s.contains(".") {s} else {s + ".0"} + } + } +} + +macro_rules! emit_enquoted_if_mapkey { + ($enc:ident,$e:expr) => { + if $enc.is_emitting_map_key { + try!(write!($enc.writer, "\"{}\"", $e)); + Ok(()) + } else { + try!(write!($enc.writer, "{}", $e)); + Ok(()) + } + } +} + +enum EncodingFormat { + Compact, + Pretty { + curr_indent: u32, + indent: u32 + } +} + +/// A structure for implementing serialization to JSON. +pub struct Encoder<'a> { + writer: &'a mut (fmt::Write+'a), + format : EncodingFormat, + is_emitting_map_key: bool, +} + +impl<'a> Encoder<'a> { + /// Creates a new encoder whose output will be written in human-readable + /// JSON to the specified writer + pub fn new_pretty(writer: &'a mut fmt::Write) -> Encoder<'a> { + Encoder { + writer: writer, + format: EncodingFormat::Pretty { + curr_indent: 0, + indent: 2, + }, + is_emitting_map_key: false, + } + } + + /// Creates a new encoder whose output will be written in compact + /// JSON to the specified writer + pub fn new(writer: &'a mut fmt::Write) -> Encoder<'a> { + Encoder { + writer: writer, + format: EncodingFormat::Compact, + is_emitting_map_key: false, + } + } + + /// Set the number of spaces to indent for each level. + /// This is safe to set during encoding. + pub fn set_indent(&mut self, new_indent: u32) -> Result<(), ()> { + if let EncodingFormat::Pretty{ref mut curr_indent, ref mut indent} = self.format { + // self.indent very well could be 0 so we need to use checked division. + let level = curr_indent.checked_div(*indent).unwrap_or(0); + *indent = new_indent; + *curr_indent = level * *indent; + Ok(()) + } else { + Err(()) + } + } +} + +impl<'a> ::Encoder for Encoder<'a> { + type Error = EncoderError; + + fn emit_nil(&mut self) -> EncodeResult<()> { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + try!(write!(self.writer, "null")); + Ok(()) + } + + fn emit_usize(&mut self, v: usize) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_u64(&mut self, v: u64) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_u32(&mut self, v: u32) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_u16(&mut self, v: u16) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_u8(&mut self, v: u8) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + + fn emit_isize(&mut self, v: isize) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_i64(&mut self, v: i64) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_i32(&mut self, v: i32) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_i16(&mut self, v: i16) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + fn emit_i8(&mut self, v: i8) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } + + fn emit_bool(&mut self, v: bool) -> EncodeResult<()> { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if v { + try!(write!(self.writer, "true")); + } else { + try!(write!(self.writer, "false")); + } + Ok(()) + } + + fn emit_f64(&mut self, v: f64) -> EncodeResult<()> { + emit_enquoted_if_mapkey!(self, fmt_number_or_null(v)) + } + fn emit_f32(&mut self, v: f32) -> EncodeResult<()> { + self.emit_f64(v as f64) + } + + fn emit_char(&mut self, v: char) -> EncodeResult<()> { + escape_char(self.writer, v) + } + fn emit_str(&mut self, v: &str) -> EncodeResult<()> { + escape_str(self.writer, v) + } + + fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + f(self) + } + + fn emit_enum_variant<F>(&mut self, + name: &str, + _id: usize, + cnt: usize, + f: F) + -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + // enums are encoded as strings or objects + // Bunny => "Bunny" + // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]} + if cnt == 0 { + escape_str(self.writer, name) + } else { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + try!(write!(self.writer, "{{\n")); + *curr_indent += indent; + try!(spaces(self.writer, *curr_indent)); + try!(write!(self.writer, "\"variant\": ")); + try!(escape_str(self.writer, name)); + try!(write!(self.writer, ",\n")); + try!(spaces(self.writer, *curr_indent)); + try!(write!(self.writer, "\"fields\": [\n")); + *curr_indent += indent; + } else { + try!(write!(self.writer, "{{\"variant\":")); + try!(escape_str(self.writer, name)); + try!(write!(self.writer, ",\"fields\":[")); + } + try!(f(self)); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent -= indent; + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, *curr_indent)); + *curr_indent -= indent; + try!(write!(self.writer, "]\n")); + try!(spaces(self.writer, *curr_indent)); + try!(write!(self.writer, "}}")); + } else { + try!(write!(self.writer, "]}}")); + } + Ok(()) + } + } + + fn emit_enum_variant_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if idx != 0 { + try!(write!(self.writer, ",")); + if let EncodingFormat::Pretty{..} = self.format { + try!(write!(self.writer, "\n")); + } + } + if let EncodingFormat::Pretty{curr_indent, ..} = self.format { + try!(spaces(self.writer, curr_indent)); + } + f(self) + } + + fn emit_enum_struct_variant<F>(&mut self, + name: &str, + id: usize, + cnt: usize, + f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_enum_variant(name, id, cnt, f) + } + + fn emit_enum_struct_variant_field<F>(&mut self, + _: &str, + idx: usize, + f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_enum_variant_arg(idx, f) + } + + + fn emit_struct<F>(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if len == 0 { + try!(write!(self.writer, "{{}}")); + } else { + try!(write!(self.writer, "{{")); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent += indent; + } + try!(f(self)); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent -= indent; + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, *curr_indent)); + } + try!(write!(self.writer, "}}")); + } + Ok(()) + } + + fn emit_struct_field<F>(&mut self, name: &str, idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if idx != 0 { + try!(write!(self.writer, ",")); + } + if let EncodingFormat::Pretty{curr_indent, ..} = self.format { + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, curr_indent)); + } + try!(escape_str(self.writer, name)); + if let EncodingFormat::Pretty{..} = self.format { + try!(write!(self.writer, ": ")); + } else { + try!(write!(self.writer, ":")); + } + f(self) + } + + fn emit_tuple<F>(&mut self, len: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_seq(len, f) + } + fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct<F>(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_seq_elt(idx, f) + } + + fn emit_option<F>(&mut self, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + f(self) + } + fn emit_option_none(&mut self) -> EncodeResult<()> { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + self.emit_nil() + } + fn emit_option_some<F>(&mut self, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + f(self) + } + + fn emit_seq<F>(&mut self, len: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if len == 0 { + try!(write!(self.writer, "[]")); + } else { + try!(write!(self.writer, "[")); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent += indent; + } + try!(f(self)); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent -= indent; + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, *curr_indent)); + } + try!(write!(self.writer, "]")); + } + Ok(()) + } + + fn emit_seq_elt<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if idx != 0 { + try!(write!(self.writer, ",")); + } + if let EncodingFormat::Pretty{ref mut curr_indent, ..} = self.format { + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, *curr_indent)); + } + f(self) + } + + fn emit_map<F>(&mut self, len: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if len == 0 { + try!(write!(self.writer, "{{}}")); + } else { + try!(write!(self.writer, "{{")); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent += indent; + } + try!(f(self)); + if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { + *curr_indent -= indent; + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, *curr_indent)); + } + try!(write!(self.writer, "}}")); + } + Ok(()) + } + + fn emit_map_elt_key<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if idx != 0 { + try!(write!(self.writer, ",")); + } + if let EncodingFormat::Pretty{curr_indent, ..} = self.format { + try!(write!(self.writer, "\n")); + try!(spaces(self.writer, curr_indent)); + } + self.is_emitting_map_key = true; + try!(f(self)); + self.is_emitting_map_key = false; + Ok(()) + } + + fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> EncodeResult<()> where + F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, + { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } + if let EncodingFormat::Pretty{..} = self.format { + try!(write!(self.writer, ": ")); + } else { + try!(write!(self.writer, ":")); + } + f(self) + } +} + +impl Encodable for Json { + fn encode<S: ::Encoder>(&self, e: &mut S) -> Result<(), S::Error> { + match *self { + Json::I64(v) => v.encode(e), + Json::U64(v) => v.encode(e), + Json::F64(v) => v.encode(e), + Json::String(ref v) => v.encode(e), + Json::Boolean(v) => v.encode(e), + Json::Array(ref v) => v.encode(e), + Json::Object(ref v) => v.encode(e), + Json::Null => e.emit_nil(), + } + } +} + +/// Create an `AsJson` wrapper which can be used to print a value as JSON +/// on-the-fly via `write!` +pub fn as_json<T: Encodable>(t: &T) -> AsJson<T> { + AsJson { inner: t } +} + +/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON +/// on-the-fly via `write!` +pub fn as_pretty_json<T: Encodable>(t: &T) -> AsPrettyJson<T> { + AsPrettyJson { inner: t, indent: None } +} + +impl Json { + /// Decodes a json value from an `&mut io::Read` + pub fn from_reader(rdr: &mut io::Read) -> Result<Self, BuilderError> { + let contents = { + let mut c = Vec::new(); + try!(rdr.read_to_end(&mut c)); + c + }; + let s = match str::from_utf8(&contents).ok() { + Some(s) => s, + _ => return Err(SyntaxError(NotUtf8, 0, 0)) + }; + let mut builder = Builder::new(s.chars()); + builder.build() + } + + /// Decodes a json value from a string + pub fn from_str(s: &str) -> Result<Self, BuilderError> { + let mut builder = Builder::new(s.chars()); + builder.build() + } + + /// Borrow this json object as a pretty object to generate a pretty + /// representation for it via `Display`. + pub fn pretty(&self) -> PrettyJson { + PrettyJson { inner: self } + } + + /// If the Json value is an Object, returns the value associated with the provided key. + /// Otherwise, returns None. + pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{ + match self { + &Json::Object(ref map) => map.get(key), + _ => None + } + } + + /// Attempts to get a nested Json Object for each key in `keys`. + /// If any key is found not to exist, find_path will return None. + /// Otherwise, it will return the Json value associated with the final key. + pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{ + let mut target = self; + for key in keys.iter() { + match target.find(*key) { + Some(t) => { target = t; }, + None => return None + } + } + Some(target) + } + + /// If the Json value is an Object, performs a depth-first search until + /// a value associated with the provided key is found. If no value is found + /// or the Json value is not an Object, returns None. + pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> { + match self { + &Json::Object(ref map) => { + match map.get(key) { + Some(json_value) => Some(json_value), + None => { + for (_, v) in map.iter() { + match v.search(key) { + x if x.is_some() => return x, + _ => () + } + } + None + } + } + }, + _ => None + } + } + + /// Returns true if the Json value is an Object. Returns false otherwise. + pub fn is_object<'a>(&'a self) -> bool { + self.as_object().is_some() + } + + /// If the Json value is an Object, returns the associated BTreeMap. + /// Returns None otherwise. + pub fn as_object<'a>(&'a self) -> Option<&'a Object> { + match self { + &Json::Object(ref map) => Some(map), + _ => None + } + } + + /// If the Json value is an Object, returns the associated mutable BTreeMap. + /// Returns None otherwise. + pub fn as_object_mut<'a>(&'a mut self) -> Option<&'a mut Object> { + match self { + &mut Json::Object(ref mut map) => Some(map), + _ => None + } + } + + /// Returns true if the Json value is an Array. Returns false otherwise. + pub fn is_array<'a>(&'a self) -> bool { + self.as_array().is_some() + } + + /// If the Json value is an Array, returns the associated vector. + /// Returns None otherwise. + pub fn as_array<'a>(&'a self) -> Option<&'a Array> { + match self { + &Json::Array(ref array) => Some(&*array), + _ => None + } + } + + /// If the Json value is an Array, returns the associated mutable vector. + /// Returns None otherwise. + pub fn as_array_mut<'a>(&'a mut self) -> Option<&'a mut Array> { + match self { + &mut Json::Array(ref mut list) => Some(list), + _ => None + } + } + + /// Returns true if the Json value is a String. Returns false otherwise. + pub fn is_string<'a>(&'a self) -> bool { + self.as_string().is_some() + } + + /// If the Json value is a String, returns the associated str. + /// Returns None otherwise. + pub fn as_string<'a>(&'a self) -> Option<&'a str> { + match *self { + Json::String(ref s) => Some(&s), + _ => None + } + } + + /// Returns true if the Json value is a Number. Returns false otherwise. + pub fn is_number(&self) -> bool { + match *self { + Json::I64(_) | Json::U64(_) | Json::F64(_) => true, + _ => false, + } + } + + /// Returns true if the Json value is a i64. Returns false otherwise. + pub fn is_i64(&self) -> bool { + match *self { + Json::I64(_) => true, + _ => false, + } + } + + /// Returns true if the Json value is a u64. Returns false otherwise. + pub fn is_u64(&self) -> bool { + match *self { + Json::U64(_) => true, + _ => false, + } + } + + /// Returns true if the Json value is a f64. Returns false otherwise. + pub fn is_f64(&self) -> bool { + match *self { + Json::F64(_) => true, + _ => false, + } + } + + /// If the Json value is a number, return or cast it to a i64. + /// Returns None otherwise. + pub fn as_i64(&self) -> Option<i64> { + match *self { + Json::I64(n) => Some(n), + Json::U64(n) if n >= i64::MAX as u64 => None, + Json::U64(n) => Some(n as i64), + _ => None + } + } + + /// If the Json value is a number, return or cast it to a u64. + /// Returns None otherwise. + pub fn as_u64(&self) -> Option<u64> { + match *self { + Json::I64(n) if n >= 0 => Some(n as u64), + Json::U64(n) => Some(n), + _ => None + } + } + + /// If the Json value is a number, return or cast it to a f64. + /// Returns None otherwise. + pub fn as_f64(&self) -> Option<f64> { + match *self { + Json::I64(n) => Some(n as f64), + Json::U64(n) => Some(n as f64), + Json::F64(n) => Some(n), + _ => None + } + } + + /// Returns true if the Json value is a Boolean. Returns false otherwise. + pub fn is_boolean(&self) -> bool { + self.as_boolean().is_some() + } + + /// If the Json value is a Boolean, returns the associated bool. + /// Returns None otherwise. + pub fn as_boolean(&self) -> Option<bool> { + match self { + &Json::Boolean(b) => Some(b), + _ => None + } + } + + /// Returns true if the Json value is a Null. Returns false otherwise. + pub fn is_null(&self) -> bool { + self.as_null().is_some() + } + + /// If the Json value is a Null, returns (). + /// Returns None otherwise. + pub fn as_null(&self) -> Option<()> { + match self { + &Json::Null => Some(()), + _ => None + } + } +} + +impl<'a> Index<&'a str> for Json { + type Output = Json; + + fn index(&self, idx: &str) -> &Json { + self.find(idx).unwrap() + } +} + +impl Index<usize> for Json { + type Output = Json; + + fn index<'a>(&'a self, idx: usize) -> &'a Json { + match self { + &Json::Array(ref v) => &v[idx], + _ => panic!("can only index Json with usize if it is an array") + } + } +} + +/// The output of the streaming parser. +#[derive(PartialEq, Debug)] +pub enum JsonEvent { + ObjectStart, + ObjectEnd, + ArrayStart, + ArrayEnd, + BooleanValue(bool), + I64Value(i64), + U64Value(u64), + F64Value(f64), + StringValue(string::String), + NullValue, + Error(ParserError), +} + +#[derive(PartialEq, Debug)] +enum ParserState { + // Parse a value in an array, true means first element. + ParseArray(bool), + // Parse ',' or ']' after an element in an array. + ParseArrayComma, + // Parse a key:value in an object, true means first element. + ParseObject(bool), + // Parse ',' or ']' after an element in an object. + ParseObjectComma, + // Initial state. + ParseStart, + // Expecting the stream to end. + ParseBeforeFinish, + // Parsing can't continue. + ParseFinished, +} + +/// A Stack represents the current position of the parser in the logical +/// structure of the JSON stream. +/// For example foo.bar[3].x +pub struct Stack { + stack: Vec<InternalStackElement>, + str_buffer: Vec<u8>, +} + +/// StackElements compose a Stack. +/// For example, Key("foo"), Key("bar"), Index(3) and Key("x") are the +/// StackElements compositing the stack that represents foo.bar[3].x +#[derive(PartialEq, Clone, Debug)] +pub enum StackElement<'l> { + Index(u32), + Key(&'l str), +} + +// Internally, Key elements are stored as indices in a buffer to avoid +// allocating a string for every member of an object. +#[derive(PartialEq, Clone, Debug)] +enum InternalStackElement { + InternalIndex(u32), + InternalKey(u16, u16), // start, size +} + +impl Stack { + pub fn new() -> Stack { + Stack { stack: Vec::new(), str_buffer: Vec::new() } + } + + /// Returns The number of elements in the Stack. + pub fn len(&self) -> usize { self.stack.len() } + + /// Returns true if the stack is empty. + pub fn is_empty(&self) -> bool { self.stack.is_empty() } + + /// Provides access to the StackElement at a given index. + /// lower indices are at the bottom of the stack while higher indices are + /// at the top. + pub fn get<'l>(&'l self, idx: usize) -> StackElement<'l> { + match self.stack[idx] { + InternalIndex(i) => StackElement::Index(i), + InternalKey(start, size) => { + StackElement::Key(str::from_utf8( + &self.str_buffer[start as usize .. start as usize + size as usize]).unwrap()) + } + } + } + + /// Compares this stack with an array of StackElements. + pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool { + if self.stack.len() != rhs.len() { return false; } + for i in 0..rhs.len() { + if self.get(i) != rhs[i] { return false; } + } + return true; + } + + /// Returns true if the bottom-most elements of this stack are the same as + /// the ones passed as parameter. + pub fn starts_with(&self, rhs: &[StackElement]) -> bool { + if self.stack.len() < rhs.len() { return false; } + for i in 0..rhs.len() { + if self.get(i) != rhs[i] { return false; } + } + return true; + } + + /// Returns true if the top-most elements of this stack are the same as + /// the ones passed as parameter. + pub fn ends_with(&self, rhs: &[StackElement]) -> bool { + if self.stack.len() < rhs.len() { return false; } + let offset = self.stack.len() - rhs.len(); + for i in 0..rhs.len() { + if self.get(i + offset) != rhs[i] { return false; } + } + return true; + } + + /// Returns the top-most element (if any). + pub fn top<'l>(&'l self) -> Option<StackElement<'l>> { + return match self.stack.last() { + None => None, + Some(&InternalIndex(i)) => Some(StackElement::Index(i)), + Some(&InternalKey(start, size)) => { + Some(StackElement::Key(str::from_utf8( + &self.str_buffer[start as usize .. (start+size) as usize] + ).unwrap())) + } + } + } + + // Used by Parser to insert Key elements at the top of the stack. + fn push_key(&mut self, key: string::String) { + self.stack.push(InternalKey(self.str_buffer.len() as u16, key.len() as u16)); + for c in key.as_bytes().iter() { + self.str_buffer.push(*c); + } + } + + // Used by Parser to insert Index elements at the top of the stack. + fn push_index(&mut self, index: u32) { + self.stack.push(InternalIndex(index)); + } + + // Used by Parser to remove the top-most element of the stack. + fn pop(&mut self) { + assert!(!self.is_empty()); + match *self.stack.last().unwrap() { + InternalKey(_, sz) => { + let new_size = self.str_buffer.len() - sz as usize; + self.str_buffer.truncate(new_size); + } + InternalIndex(_) => {} + } + self.stack.pop(); + } + + // Used by Parser to test whether the top-most element is an index. + fn last_is_index(&self) -> bool { + if self.is_empty() { return false; } + return match *self.stack.last().unwrap() { + InternalIndex(_) => true, + _ => false, + } + } + + // Used by Parser to increment the index of the top-most element. + fn bump_index(&mut self) { + let len = self.stack.len(); + let idx = match *self.stack.last().unwrap() { + InternalIndex(i) => { i + 1 } + _ => { panic!(); } + }; + self.stack[len - 1] = InternalIndex(idx); + } +} + +/// A streaming JSON parser implemented as an iterator of JsonEvent, consuming +/// an iterator of char. +pub struct Parser<T> { + rdr: T, + ch: Option<char>, + line: usize, + col: usize, + // We maintain a stack representing where we are in the logical structure + // of the JSON stream. + stack: Stack, + // A state machine is kept to make it possible to interrupt and resume parsing. + state: ParserState, +} + +impl<T: Iterator<Item = char>> Iterator for Parser<T> { + type Item = JsonEvent; + + fn next(&mut self) -> Option<JsonEvent> { + if self.state == ParseFinished { + return None; + } + + if self.state == ParseBeforeFinish { + self.parse_whitespace(); + // Make sure there is no trailing characters. + if self.eof() { + self.state = ParseFinished; + return None; + } else { + return Some(self.error_event(TrailingCharacters)); + } + } + + return Some(self.parse()); + } +} + +impl<T: Iterator<Item = char>> Parser<T> { + /// Creates the JSON parser. + pub fn new(rdr: T) -> Parser<T> { + let mut p = Parser { + rdr: rdr, + ch: Some('\x00'), + line: 1, + col: 0, + stack: Stack::new(), + state: ParseStart, + }; + p.bump(); + return p; + } + + /// Provides access to the current position in the logical structure of the + /// JSON stream. + pub fn stack<'l>(&'l self) -> &'l Stack { + return &self.stack; + } + + fn eof(&self) -> bool { self.ch.is_none() } + fn ch_or_null(&self) -> char { self.ch.unwrap_or('\x00') } + fn bump(&mut self) { + self.ch = self.rdr.next(); + + if self.ch_is('\n') { + self.line += 1; + self.col = 1; + } else { + self.col += 1; + } + } + + fn next_char(&mut self) -> Option<char> { + self.bump(); + self.ch + } + fn ch_is(&self, c: char) -> bool { + self.ch == Some(c) + } + + fn error<E>(&self, reason: ErrorCode) -> Result<E, ParserError> { + Err(SyntaxError(reason, self.line, self.col)) + } + + fn parse_whitespace(&mut self) { + while self.ch_is(' ') || + self.ch_is('\n') || + self.ch_is('\t') || + self.ch_is('\r') { self.bump(); } + } + + fn parse_number(&mut self) -> JsonEvent { + let mut neg = false; + + if self.ch_is('-') { + self.bump(); + neg = true; + } + + let res = match self.parse_u64() { + Ok(res) => res, + Err(e) => { return Error(e); } + }; + + if self.ch_is('.') || self.ch_is('e') || self.ch_is('E') { + let mut res = res as f64; + + if self.ch_is('.') { + res = match self.parse_decimal(res) { + Ok(res) => res, + Err(e) => { return Error(e); } + }; + } + + if self.ch_is('e') || self.ch_is('E') { + res = match self.parse_exponent(res) { + Ok(res) => res, + Err(e) => { return Error(e); } + }; + } + + if neg { + res *= -1.0; + } + + F64Value(res) + } else { + if neg { + // Make sure we don't underflow. + if res > (i64::MAX as u64) + 1 { + Error(SyntaxError(InvalidNumber, self.line, self.col)) + } else { + I64Value((!res + 1) as i64) + } + } else { + U64Value(res) + } + } + } + + fn parse_u64(&mut self) -> Result<u64, ParserError> { + let mut accum: u64 = 0; + + match self.ch_or_null() { + '0' => { + self.bump(); + + // A leading '0' must be the only digit before the decimal point. + match self.ch_or_null() { + '0' ... '9' => return self.error(InvalidNumber), + _ => () + } + }, + '1' ... '9' => { + while !self.eof() { + match self.ch_or_null() { + c @ '0' ... '9' => { + macro_rules! try_or_invalid { + ($e: expr) => { + match $e { + Some(v) => v, + None => return self.error(InvalidNumber) + } + } + } + accum = try_or_invalid!(accum.checked_mul(10)); + accum = try_or_invalid!(accum.checked_add((c as u64) - ('0' as u64))); + + self.bump(); + } + _ => break, + } + } + } + _ => return self.error(InvalidNumber), + } + + Ok(accum) + } + + fn parse_decimal(&mut self, mut res: f64) -> Result<f64, ParserError> { + self.bump(); + + // Make sure a digit follows the decimal place. + match self.ch_or_null() { + '0' ... '9' => (), + _ => return self.error(InvalidNumber) + } + + let mut dec = 1.0; + while !self.eof() { + match self.ch_or_null() { + c @ '0' ... '9' => { + dec /= 10.0; + res += (((c as isize) - ('0' as isize)) as f64) * dec; + self.bump(); + } + _ => break, + } + } + + Ok(res) + } + + fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> { + self.bump(); + + let mut exp = 0; + let mut neg_exp = false; + + if self.ch_is('+') { + self.bump(); + } else if self.ch_is('-') { + self.bump(); + neg_exp = true; + } + + // Make sure a digit follows the exponent place. + match self.ch_or_null() { + '0' ... '9' => (), + _ => return self.error(InvalidNumber) + } + while !self.eof() { + match self.ch_or_null() { + c @ '0' ... '9' => { + exp *= 10; + exp += (c as usize) - ('0' as usize); + + self.bump(); + } + _ => break + } + } + + let exp = 10_f64.powi(exp as i32); + if neg_exp { + res /= exp; + } else { + res *= exp; + } + + Ok(res) + } + + fn decode_hex_escape(&mut self) -> Result<u16, ParserError> { + let mut i = 0; + let mut n = 0; + while i < 4 { + self.bump(); + n = match self.ch_or_null() { + c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)), + c @ 'a' ... 'f' => n * 16 + (10 + (c as u16) - ('a' as u16)), + c @ 'A' ... 'F' => n * 16 + (10 + (c as u16) - ('A' as u16)), + _ => return self.error(InvalidEscape) + }; + + i += 1; + } + + Ok(n) + } + + fn parse_str(&mut self) -> Result<string::String, ParserError> { + let mut escape = false; + let mut res = string::String::new(); + + loop { + self.bump(); + if self.eof() { + return self.error(EOFWhileParsingString); + } + + if escape { + match self.ch_or_null() { + '"' => res.push('"'), + '\\' => res.push('\\'), + '/' => res.push('/'), + 'b' => res.push('\x08'), + 'f' => res.push('\x0c'), + 'n' => res.push('\n'), + 'r' => res.push('\r'), + 't' => res.push('\t'), + 'u' => match try!(self.decode_hex_escape()) { + 0xDC00 ... 0xDFFF => { + return self.error(LoneLeadingSurrogateInHexEscape) + } + + // Non-BMP characters are encoded as a sequence of + // two hex escapes, representing UTF-16 surrogates. + n1 @ 0xD800 ... 0xDBFF => { + match (self.next_char(), self.next_char()) { + (Some('\\'), Some('u')) => (), + _ => return self.error(UnexpectedEndOfHexEscape), + } + + let n2 = try!(self.decode_hex_escape()); + if n2 < 0xDC00 || n2 > 0xDFFF { + return self.error(LoneLeadingSurrogateInHexEscape) + } + let c = (((n1 - 0xD800) as u32) << 10 | + (n2 - 0xDC00) as u32) + 0x1_0000; + res.push(char::from_u32(c).unwrap()); + } + + n => match char::from_u32(n as u32) { + Some(c) => res.push(c), + None => return self.error(InvalidUnicodeCodePoint), + }, + }, + _ => return self.error(InvalidEscape), + } + escape = false; + } else if self.ch_is('\\') { + escape = true; + } else { + match self.ch { + Some('"') => { + self.bump(); + return Ok(res); + }, + Some(c) if c.is_control() => + return self.error(ControlCharacterInString), + Some(c) => res.push(c), + None => unreachable!() + } + } + } + } + + // Invoked at each iteration, consumes the stream until it has enough + // information to return a JsonEvent. + // Manages an internal state so that parsing can be interrupted and resumed. + // Also keeps track of the position in the logical structure of the json + // stream int the form of a stack that can be queried by the user using the + // stack() method. + fn parse(&mut self) -> JsonEvent { + loop { + // The only paths where the loop can spin a new iteration + // are in the cases ParseArrayComma and ParseObjectComma if ',' + // is parsed. In these cases the state is set to (respectively) + // ParseArray(false) and ParseObject(false), which always return, + // so there is no risk of getting stuck in an infinite loop. + // All other paths return before the end of the loop's iteration. + self.parse_whitespace(); + + match self.state { + ParseStart => { + return self.parse_start(); + } + ParseArray(first) => { + return self.parse_array(first); + } + ParseArrayComma => { + match self.parse_array_comma_or_end() { + Some(evt) => { return evt; } + None => {} + } + } + ParseObject(first) => { + return self.parse_object(first); + } + ParseObjectComma => { + self.stack.pop(); + if self.ch_is(',') { + self.state = ParseObject(false); + self.bump(); + } else { + return self.parse_object_end(); + } + } + _ => { + return self.error_event(InvalidSyntax); + } + } + } + } + + fn parse_start(&mut self) -> JsonEvent { + let val = self.parse_value(); + self.state = match val { + Error(_) => ParseFinished, + ArrayStart => ParseArray(true), + ObjectStart => ParseObject(true), + _ => ParseBeforeFinish, + }; + return val; + } + + fn parse_array(&mut self, first: bool) -> JsonEvent { + if self.ch_is(']') { + if !first { + self.error_event(InvalidSyntax) + } else { + self.state = if self.stack.is_empty() { + ParseBeforeFinish + } else if self.stack.last_is_index() { + ParseArrayComma + } else { + ParseObjectComma + }; + self.bump(); + ArrayEnd + } + } else { + if first { + self.stack.push_index(0); + } + let val = self.parse_value(); + self.state = match val { + Error(_) => ParseFinished, + ArrayStart => ParseArray(true), + ObjectStart => ParseObject(true), + _ => ParseArrayComma, + }; + val + } + } + + fn parse_array_comma_or_end(&mut self) -> Option<JsonEvent> { + if self.ch_is(',') { + self.stack.bump_index(); + self.state = ParseArray(false); + self.bump(); + None + } else if self.ch_is(']') { + self.stack.pop(); + self.state = if self.stack.is_empty() { + ParseBeforeFinish + } else if self.stack.last_is_index() { + ParseArrayComma + } else { + ParseObjectComma + }; + self.bump(); + Some(ArrayEnd) + } else if self.eof() { + Some(self.error_event(EOFWhileParsingArray)) + } else { + Some(self.error_event(InvalidSyntax)) + } + } + + fn parse_object(&mut self, first: bool) -> JsonEvent { + if self.ch_is('}') { + if !first { + if self.stack.is_empty() { + return self.error_event(TrailingComma); + } else { + self.stack.pop(); + } + } + self.state = if self.stack.is_empty() { + ParseBeforeFinish + } else if self.stack.last_is_index() { + ParseArrayComma + } else { + ParseObjectComma + }; + self.bump(); + return ObjectEnd; + } + if self.eof() { + return self.error_event(EOFWhileParsingObject); + } + if !self.ch_is('"') { + return self.error_event(KeyMustBeAString); + } + let s = match self.parse_str() { + Ok(s) => s, + Err(e) => { + self.state = ParseFinished; + return Error(e); + } + }; + self.parse_whitespace(); + if self.eof() { + return self.error_event(EOFWhileParsingObject); + } else if self.ch_or_null() != ':' { + return self.error_event(ExpectedColon); + } + self.stack.push_key(s); + self.bump(); + self.parse_whitespace(); + + let val = self.parse_value(); + + self.state = match val { + Error(_) => ParseFinished, + ArrayStart => ParseArray(true), + ObjectStart => ParseObject(true), + _ => ParseObjectComma, + }; + return val; + } + + fn parse_object_end(&mut self) -> JsonEvent { + if self.ch_is('}') { + self.state = if self.stack.is_empty() { + ParseBeforeFinish + } else if self.stack.last_is_index() { + ParseArrayComma + } else { + ParseObjectComma + }; + self.bump(); + ObjectEnd + } else if self.eof() { + self.error_event(EOFWhileParsingObject) + } else { + self.error_event(InvalidSyntax) + } + } + + fn parse_value(&mut self) -> JsonEvent { + if self.eof() { return self.error_event(EOFWhileParsingValue); } + match self.ch_or_null() { + 'n' => { self.parse_ident("ull", NullValue) } + 't' => { self.parse_ident("rue", BooleanValue(true)) } + 'f' => { self.parse_ident("alse", BooleanValue(false)) } + '0' ... '9' | '-' => self.parse_number(), + '"' => match self.parse_str() { + Ok(s) => StringValue(s), + Err(e) => Error(e), + }, + '[' => { + self.bump(); + ArrayStart + } + '{' => { + self.bump(); + ObjectStart + } + _ => { self.error_event(InvalidSyntax) } + } + } + + fn parse_ident(&mut self, ident: &str, value: JsonEvent) -> JsonEvent { + if ident.chars().all(|c| Some(c) == self.next_char()) { + self.bump(); + value + } else { + Error(SyntaxError(InvalidSyntax, self.line, self.col)) + } + } + + fn error_event(&mut self, reason: ErrorCode) -> JsonEvent { + self.state = ParseFinished; + Error(SyntaxError(reason, self.line, self.col)) + } +} + +/// A Builder consumes a json::Parser to create a generic Json structure. +pub struct Builder<T> { + parser: Parser<T>, + token: Option<JsonEvent>, +} + +impl<T: Iterator<Item = char>> Builder<T> { + /// Create a JSON Builder. + pub fn new(src: T) -> Builder<T> { + Builder { parser: Parser::new(src), token: None, } + } + + // Decode a Json value from a Parser. + pub fn build(&mut self) -> Result<Json, BuilderError> { + self.bump(); + let result = self.build_value(); + self.bump(); + match self.token.take() { + None => {} + Some(Error(e)) => { return Err(e); } + ref tok => { panic!("unexpected token {:?}", tok); } + } + result + } + + fn bump(&mut self) { + self.token = self.parser.next(); + } + + fn build_value(&mut self) -> Result<Json, BuilderError> { + return match self.token.take() { + Some(NullValue) => Ok(Json::Null), + Some(I64Value(n)) => Ok(Json::I64(n)), + Some(U64Value(n)) => Ok(Json::U64(n)), + Some(F64Value(n)) => Ok(Json::F64(n)), + Some(BooleanValue(b)) => Ok(Json::Boolean(b)), + Some(StringValue(ref mut s)) => { + let mut temp = string::String::new(); + swap(s, &mut temp); + Ok(Json::String(temp)) + } + Some(Error(e)) => Err(e), + Some(ArrayStart) => self.build_array(), + Some(ObjectStart) => self.build_object(), + Some(ObjectEnd) => self.parser.error(InvalidSyntax), + Some(ArrayEnd) => self.parser.error(InvalidSyntax), + None => self.parser.error(EOFWhileParsingValue), + } + } + + fn build_array(&mut self) -> Result<Json, BuilderError> { + self.bump(); + let mut values = Vec::new(); + + loop { + if let Some(ArrayEnd) = self.token { + return Ok(Json::Array(values.into_iter().collect())); + } + match self.build_value() { + Ok(v) => values.push(v), + Err(e) => { return Err(e) } + } + self.bump(); + } + } + + fn build_object(&mut self) -> Result<Json, BuilderError> { + self.bump(); + + let mut values = BTreeMap::new(); + + loop { + match self.token.take() { + Some(ObjectEnd) => { return Ok(Json::Object(values)); } + Some(Error(e)) => { return Err(e); } + None => { break; } + token => { self.token = token; } + } + let key = match self.parser.stack().top() { + Some(StackElement::Key(k)) => { k.to_string() } + _ => { panic!("invalid state"); } + }; + match self.build_value() { + Ok(value) => { values.insert(key, value); } + Err(e) => { return Err(e); } + } + self.bump(); + } + return self.parser.error(EOFWhileParsingObject); + } +} + +/// A structure to decode JSON to values in rust. +pub struct Decoder { + stack: Vec<Json>, +} + +impl Decoder { + /// Creates a new decoder instance for decoding the specified JSON value. + pub fn new(json: Json) -> Decoder { + Decoder { stack: vec![json] } + } +} + +impl Decoder { + fn pop(&mut self) -> DecodeResult<Json> { + match self.stack.pop() { + Some(s) => Ok(s), + None => Err(EOF), + } + } +} + +macro_rules! expect { + ($e:expr, Null) => ({ + match try!($e) { + Json::Null => Ok(()), + other => Err(ExpectedError("Null".to_string(), + format!("{}", other))) + } + }); + ($e:expr, $t:ident) => ({ + match try!($e) { + Json::$t(v) => Ok(v), + other => { + Err(ExpectedError(stringify!($t).to_string(), + format!("{}", other))) + } + } + }) +} + +macro_rules! read_primitive { + ($name:ident, $ty:ident) => { + #[allow(unused_comparisons)] + fn $name(&mut self) -> DecodeResult<$ty> { + match try!(self.pop()) { + Json::I64(i) => { + let other = i as $ty; + if i == other as i64 && (other > 0) == (i > 0) { + Ok(other) + } else { + Err(ExpectedError("Number".to_string(), i.to_string())) + } + } + Json::U64(u) => { + let other = u as $ty; + if u == other as u64 && other >= 0 { + Ok(other) + } else { + Err(ExpectedError("Number".to_string(), u.to_string())) + } + } + Json::F64(f) => { + Err(ExpectedError("Integer".to_string(), f.to_string())) + } + // re: #12967.. a type w/ numeric keys (ie HashMap<usize, V> etc) + // is going to have a string here, as per JSON spec. + Json::String(s) => match s.parse() { + Ok(f) => Ok(f), + Err(_) => Err(ExpectedError("Number".to_string(), s)), + }, + value => { + Err(ExpectedError("Number".to_string(), value.to_string())) + } + } + } + } +} + +impl ::Decoder for Decoder { + type Error = DecoderError; + + fn read_nil(&mut self) -> DecodeResult<()> { + expect!(self.pop(), Null) + } + + read_primitive! { read_usize, usize } + read_primitive! { read_u8, u8 } + read_primitive! { read_u16, u16 } + read_primitive! { read_u32, u32 } + read_primitive! { read_u64, u64 } + read_primitive! { read_isize, isize } + read_primitive! { read_i8, i8 } + read_primitive! { read_i16, i16 } + read_primitive! { read_i32, i32 } + read_primitive! { read_i64, i64 } + + fn read_f32(&mut self) -> DecodeResult<f32> { + self.read_f64().map(|x| x as f32) + } + + fn read_f64(&mut self) -> DecodeResult<f64> { + match try!(self.pop()) { + Json::I64(f) => Ok(f as f64), + Json::U64(f) => Ok(f as f64), + Json::F64(f) => Ok(f), + Json::String(s) => { + // re: #12967.. a type w/ numeric keys (ie HashMap<usize, V> etc) + // is going to have a string here, as per JSON spec. + match s.parse() { + Ok(f) => Ok(f), + Err(_) => Err(ExpectedError("Number".to_string(), s)), + } + }, + Json::Null => Ok(f64::NAN), + value => Err(ExpectedError("Number".to_string(), format!("{}", value))) + } + } + + fn read_bool(&mut self) -> DecodeResult<bool> { + expect!(self.pop(), Boolean) + } + + fn read_char(&mut self) -> DecodeResult<char> { + let s = try!(self.read_str()); + { + let mut it = s.chars(); + match (it.next(), it.next()) { + // exactly one character + (Some(c), None) => return Ok(c), + _ => () + } + } + Err(ExpectedError("single character string".to_string(), format!("{}", s))) + } + + fn read_str(&mut self) -> DecodeResult<string::String> { + expect!(self.pop(), String) + } + + fn read_enum<T, F>(&mut self, _name: &str, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + f(self) + } + + fn read_enum_variant<T, F>(&mut self, names: &[&str], + mut f: F) -> DecodeResult<T> + where F: FnMut(&mut Decoder, usize) -> DecodeResult<T>, + { + let name = match try!(self.pop()) { + Json::String(s) => s, + Json::Object(mut o) => { + let n = match o.remove(&"variant".to_string()) { + Some(Json::String(s)) => s, + Some(val) => { + return Err(ExpectedError("String".to_string(), format!("{}", val))) + } + None => { + return Err(MissingFieldError("variant".to_string())) + } + }; + match o.remove(&"fields".to_string()) { + Some(Json::Array(l)) => { + for field in l.into_iter().rev() { + self.stack.push(field); + } + }, + Some(val) => { + return Err(ExpectedError("Array".to_string(), format!("{}", val))) + } + None => { + return Err(MissingFieldError("fields".to_string())) + } + } + n + } + json => { + return Err(ExpectedError("String or Object".to_string(), format!("{}", json))) + } + }; + let idx = match names.iter().position(|n| *n == name) { + Some(idx) => idx, + None => return Err(UnknownVariantError(name)) + }; + f(self, idx) + } + + fn read_enum_variant_arg<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + f(self) + } + + fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> DecodeResult<T> where + F: FnMut(&mut Decoder, usize) -> DecodeResult<T>, + { + self.read_enum_variant(names, f) + } + + + fn read_enum_struct_variant_field<T, F>(&mut self, + _name: &str, + idx: usize, + f: F) + -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + self.read_enum_variant_arg(idx, f) + } + + fn read_struct<T, F>(&mut self, _name: &str, _len: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + let value = try!(f(self)); + try!(self.pop()); + Ok(value) + } + + fn read_struct_field<T, F>(&mut self, + name: &str, + _idx: usize, + f: F) + -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + let mut obj = try!(expect!(self.pop(), Object)); + + let value = match obj.remove(&name.to_string()) { + None => { + // Add a Null and try to parse it as an Option<_> + // to get None as a default value. + self.stack.push(Json::Null); + match f(self) { + Ok(x) => x, + Err(_) => return Err(MissingFieldError(name.to_string())), + } + }, + Some(json) => { + self.stack.push(json); + try!(f(self)) + } + }; + self.stack.push(Json::Object(obj)); + Ok(value) + } + + fn read_tuple<T, F>(&mut self, tuple_len: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + self.read_seq(move |d, len| { + if len == tuple_len { + f(d) + } else { + Err(ExpectedError(format!("Tuple{}", tuple_len), format!("Tuple{}", len))) + } + }) + } + + fn read_tuple_arg<T, F>(&mut self, idx: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + self.read_seq_elt(idx, f) + } + + fn read_tuple_struct<T, F>(&mut self, + _name: &str, + len: usize, + f: F) + -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + self.read_tuple(len, f) + } + + fn read_tuple_struct_arg<T, F>(&mut self, + idx: usize, + f: F) + -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + self.read_tuple_arg(idx, f) + } + + fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where + F: FnMut(&mut Decoder, bool) -> DecodeResult<T>, + { + match try!(self.pop()) { + Json::Null => f(self, false), + value => { self.stack.push(value); f(self, true) } + } + } + + fn read_seq<T, F>(&mut self, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder, usize) -> DecodeResult<T>, + { + let array = try!(expect!(self.pop(), Array)); + let len = array.len(); + for v in array.into_iter().rev() { + self.stack.push(v); + } + f(self, len) + } + + fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + f(self) + } + + fn read_map<T, F>(&mut self, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder, usize) -> DecodeResult<T>, + { + let obj = try!(expect!(self.pop(), Object)); + let len = obj.len(); + for (key, value) in obj.into_iter() { + self.stack.push(value); + self.stack.push(Json::String(key)); + } + f(self, len) + } + + fn read_map_elt_key<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + f(self) + } + + fn read_map_elt_val<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where + F: FnOnce(&mut Decoder) -> DecodeResult<T>, + { + f(self) + } + + fn error(&mut self, err: &str) -> DecoderError { + ApplicationError(err.to_string()) + } +} + +/// A trait for converting values to JSON +pub trait ToJson { + /// Converts the value of `self` to an instance of JSON + fn to_json(&self) -> Json; +} + +macro_rules! to_json_impl_i64 { + ($($t:ty), +) => ( + $(impl ToJson for $t { + fn to_json(&self) -> Json { Json::I64(*self as i64) } + })+ + ) +} + +to_json_impl_i64! { isize, i8, i16, i32, i64 } + +macro_rules! to_json_impl_u64 { + ($($t:ty), +) => ( + $(impl ToJson for $t { + fn to_json(&self) -> Json { Json::U64(*self as u64) } + })+ + ) +} + +to_json_impl_u64! { usize, u8, u16, u32, u64 } + +impl ToJson for Json { + fn to_json(&self) -> Json { self.clone() } +} + +impl ToJson for f32 { + fn to_json(&self) -> Json { (*self as f64).to_json() } +} + +impl ToJson for f64 { + fn to_json(&self) -> Json { + use std::num::FpCategory::{Nan, Infinite}; + + match self.classify() { + Nan | Infinite => Json::Null, + _ => Json::F64(*self) + } + } +} + +impl ToJson for () { + fn to_json(&self) -> Json { Json::Null } +} + +impl ToJson for bool { + fn to_json(&self) -> Json { Json::Boolean(*self) } +} + +impl ToJson for str { + fn to_json(&self) -> Json { Json::String(self.to_string()) } +} + +impl ToJson for string::String { + fn to_json(&self) -> Json { Json::String((*self).clone()) } +} + +macro_rules! tuple_impl { + // use variables to indicate the arity of the tuple + ($($tyvar:ident),* ) => { + // the trailing commas are for the 1 tuple + impl< + $( $tyvar : ToJson ),* + > ToJson for ( $( $tyvar ),* , ) { + + #[inline] + #[allow(non_snake_case)] + fn to_json(&self) -> Json { + match *self { + ($(ref $tyvar),*,) => Json::Array(vec![$($tyvar.to_json()),*]) + } + } + } + } +} + +tuple_impl!{A} +tuple_impl!{A, B} +tuple_impl!{A, B, C} +tuple_impl!{A, B, C, D} +tuple_impl!{A, B, C, D, E} +tuple_impl!{A, B, C, D, E, F} +tuple_impl!{A, B, C, D, E, F, G} +tuple_impl!{A, B, C, D, E, F, G, H} +tuple_impl!{A, B, C, D, E, F, G, H, I} +tuple_impl!{A, B, C, D, E, F, G, H, I, J} +tuple_impl!{A, B, C, D, E, F, G, H, I, J, K} +tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L} + +impl<A: ToJson> ToJson for [A] { + fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) } +} + +impl<A: ToJson> ToJson for Vec<A> { + fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) } +} + +impl<A: ToJson> ToJson for BTreeMap<string::String, A> { + fn to_json(&self) -> Json { + let mut d = BTreeMap::new(); + for (key, value) in self.iter() { + d.insert((*key).clone(), value.to_json()); + } + Json::Object(d) + } +} + +impl<A: ToJson> ToJson for HashMap<string::String, A> { + fn to_json(&self) -> Json { + let mut d = BTreeMap::new(); + for (key, value) in self.iter() { + d.insert((*key).clone(), value.to_json()); + } + Json::Object(d) + } +} + +impl<A:ToJson> ToJson for Option<A> { + fn to_json(&self) -> Json { + match *self { + None => Json::Null, + Some(ref value) => value.to_json() + } + } +} + +struct FormatShim<'a, 'b: 'a> { + inner: &'a mut fmt::Formatter<'b>, +} + +impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> { + fn write_str(&mut self, s: &str) -> fmt::Result { + match self.inner.write_str(s) { + Ok(_) => Ok(()), + Err(_) => Err(fmt::Error) + } + } +} + +impl fmt::Display for Json { + /// Encodes a json value into a string + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut shim = FormatShim { inner: f }; + let mut encoder = Encoder::new(&mut shim); + match self.encode(&mut encoder) { + Ok(_) => Ok(()), + Err(_) => Err(fmt::Error) + } + } +} + +impl<'a> fmt::Display for PrettyJson<'a> { + /// Encodes a json value into a string + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut shim = FormatShim { inner: f }; + let mut encoder = Encoder::new_pretty(&mut shim); + match self.inner.encode(&mut encoder) { + Ok(_) => Ok(()), + Err(_) => Err(fmt::Error) + } + } +} + +impl<'a, T: Encodable> fmt::Display for AsJson<'a, T> { + /// Encodes a json value into a string + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut shim = FormatShim { inner: f }; + let mut encoder = Encoder::new(&mut shim); + match self.inner.encode(&mut encoder) { + Ok(_) => Ok(()), + Err(_) => Err(fmt::Error) + } + } +} + +impl<'a, T> AsPrettyJson<'a, T> { + /// Set the indentation level for the emitted JSON + pub fn indent(mut self, indent: u32) -> AsPrettyJson<'a, T> { + self.indent = Some(indent); + self + } +} + +impl<'a, T: Encodable> fmt::Display for AsPrettyJson<'a, T> { + /// Encodes a json value into a string + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut shim = FormatShim { inner: f }; + let mut encoder = Encoder::new_pretty(&mut shim); + if let Some(n) = self.indent { + // unwrap cannot panic for pretty encoders + let _ = encoder.set_indent(n); + } + match self.inner.encode(&mut encoder) { + Ok(_) => Ok(()), + Err(_) => Err(fmt::Error) + } + } +} + +impl FromStr for Json { + type Err = ParserError; + fn from_str(s: &str) -> Result<Json, ParserError> { + Json::from_str(s) + } +} + +#[cfg(test)] +mod tests { + use self::Animal::*; + use self::DecodeEnum::*; + use {Encodable, Decodable}; + use super::Json::*; + use super::ErrorCode::*; + use super::ParserError::*; + use super::DecoderError::*; + use super::JsonEvent::*; + use super::StackElement::*; + use super::{Json, DecodeResult, DecoderError, JsonEvent, Parser, + StackElement, Stack, Decoder, Encoder, EncoderError}; + use std::{i64, u64, f32, f64}; + use std::collections::BTreeMap; + use std::string; + + #[derive(RustcDecodable, Eq, PartialEq, Debug)] + struct OptionData { + opt: Option<usize>, + } + + #[test] + fn test_decode_option_none() { + let s ="{}"; + let obj: OptionData = super::decode(s).unwrap(); + assert_eq!(obj, OptionData { opt: None }); + } + + #[test] + fn test_decode_option_some() { + let s = "{ \"opt\": 10 }"; + let obj: OptionData = super::decode(s).unwrap(); + assert_eq!(obj, OptionData { opt: Some(10) }); + } + + #[test] + fn test_decode_option_malformed() { + check_err::<OptionData>("{ \"opt\": [] }", + ExpectedError("Number".to_string(), "[]".to_string())); + check_err::<OptionData>("{ \"opt\": false }", + ExpectedError("Number".to_string(), "false".to_string())); + } + + #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)] + enum Animal { + Dog, + Frog(string::String, isize) + } + + #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)] + struct Inner { + a: (), + b: usize, + c: Vec<string::String>, + } + + #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)] + struct Outer { + inner: Vec<Inner>, + } + + fn mk_object(items: &[(string::String, Json)]) -> Json { + let mut d = BTreeMap::new(); + + for item in items.iter() { + match *item { + (ref key, ref value) => { d.insert((*key).clone(), (*value).clone()); }, + } + }; + + Object(d) + } + + #[test] + fn test_from_str_trait() { + let s = "null"; + assert!(s.parse::<Json>().unwrap() == s.parse().unwrap()); + } + + #[test] + fn test_write_null() { + assert_eq!(Null.to_string(), "null"); + assert_eq!(Null.pretty().to_string(), "null"); + } + + #[test] + fn test_write_i64() { + assert_eq!(U64(0).to_string(), "0"); + assert_eq!(U64(0).pretty().to_string(), "0"); + + assert_eq!(U64(1234).to_string(), "1234"); + assert_eq!(U64(1234).pretty().to_string(), "1234"); + + assert_eq!(I64(-5678).to_string(), "-5678"); + assert_eq!(I64(-5678).pretty().to_string(), "-5678"); + + assert_eq!(U64(7650007200025252000).to_string(), "7650007200025252000"); + assert_eq!(U64(7650007200025252000).pretty().to_string(), "7650007200025252000"); + } + + #[test] + fn test_write_f64() { + assert_eq!(F64(3.0).to_string(), "3.0"); + assert_eq!(F64(3.0).pretty().to_string(), "3.0"); + + assert_eq!(F64(3.1).to_string(), "3.1"); + assert_eq!(F64(3.1).pretty().to_string(), "3.1"); + + assert_eq!(F64(-1.5).to_string(), "-1.5"); + assert_eq!(F64(-1.5).pretty().to_string(), "-1.5"); + + assert_eq!(F64(0.5).to_string(), "0.5"); + assert_eq!(F64(0.5).pretty().to_string(), "0.5"); + + assert_eq!(F64(f64::NAN).to_string(), "null"); + assert_eq!(F64(f64::NAN).pretty().to_string(), "null"); + + assert_eq!(F64(f64::INFINITY).to_string(), "null"); + assert_eq!(F64(f64::INFINITY).pretty().to_string(), "null"); + + assert_eq!(F64(f64::NEG_INFINITY).to_string(), "null"); + assert_eq!(F64(f64::NEG_INFINITY).pretty().to_string(), "null"); + } + + #[test] + fn test_write_str() { + assert_eq!(String("".to_string()).to_string(), "\"\""); + assert_eq!(String("".to_string()).pretty().to_string(), "\"\""); + + assert_eq!(String("homura".to_string()).to_string(), "\"homura\""); + assert_eq!(String("madoka".to_string()).pretty().to_string(), "\"madoka\""); + } + + #[test] + fn test_write_bool() { + assert_eq!(Boolean(true).to_string(), "true"); + assert_eq!(Boolean(true).pretty().to_string(), "true"); + + assert_eq!(Boolean(false).to_string(), "false"); + assert_eq!(Boolean(false).pretty().to_string(), "false"); + } + + #[test] + fn test_write_array() { + assert_eq!(Array(vec![]).to_string(), "[]"); + assert_eq!(Array(vec![]).pretty().to_string(), "[]"); + + assert_eq!(Array(vec![Boolean(true)]).to_string(), "[true]"); + assert_eq!( + Array(vec![Boolean(true)]).pretty().to_string(), + "\ + [\n \ + true\n\ + ]" + ); + + let long_test_array = Array(vec![ + Boolean(false), + Null, + Array(vec![String("foo\nbar".to_string()), F64(3.5)])]); + + assert_eq!(long_test_array.to_string(), + "[false,null,[\"foo\\nbar\",3.5]]"); + assert_eq!( + long_test_array.pretty().to_string(), + "\ + [\n \ + false,\n \ + null,\n \ + [\n \ + \"foo\\nbar\",\n \ + 3.5\n \ + ]\n\ + ]" + ); + } + + #[test] + fn test_write_object() { + assert_eq!(mk_object(&[]).to_string(), "{}"); + assert_eq!(mk_object(&[]).pretty().to_string(), "{}"); + + assert_eq!( + mk_object(&[ + ("a".to_string(), Boolean(true)) + ]).to_string(), + "{\"a\":true}" + ); + assert_eq!( + mk_object(&[("a".to_string(), Boolean(true))]).pretty().to_string(), + "\ + {\n \ + \"a\": true\n\ + }" + ); + + let complex_obj = mk_object(&[ + ("b".to_string(), Array(vec![ + mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]), + mk_object(&[("d".to_string(), String("".to_string()))]) + ])) + ]); + + assert_eq!( + complex_obj.to_string(), + "{\ + \"b\":[\ + {\"c\":\"\\f\\r\"},\ + {\"d\":\"\"}\ + ]\ + }" + ); + assert_eq!( + complex_obj.pretty().to_string(), + "\ + {\n \ + \"b\": [\n \ + {\n \ + \"c\": \"\\f\\r\"\n \ + },\n \ + {\n \ + \"d\": \"\"\n \ + }\n \ + ]\n\ + }" + ); + + let a = mk_object(&[ + ("a".to_string(), Boolean(true)), + ("b".to_string(), Array(vec![ + mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]), + mk_object(&[("d".to_string(), String("".to_string()))]) + ])) + ]); + + // We can't compare the strings directly because the object fields be + // printed in a different order. + assert_eq!(a.clone(), a.to_string().parse().unwrap()); + assert_eq!(a.clone(), a.pretty().to_string().parse().unwrap()); + } + + #[test] + fn test_write_enum() { + let animal = Dog; + assert_eq!( + format!("{}", super::as_json(&animal)), + "\"Dog\"" + ); + assert_eq!( + format!("{}", super::as_pretty_json(&animal)), + "\"Dog\"" + ); + + let animal = Frog("Henry".to_string(), 349); + assert_eq!( + format!("{}", super::as_json(&animal)), + "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}" + ); + assert_eq!( + format!("{}", super::as_pretty_json(&animal)), + "{\n \ + \"variant\": \"Frog\",\n \ + \"fields\": [\n \ + \"Henry\",\n \ + 349\n \ + ]\n\ + }" + ); + } + + macro_rules! check_encoder_for_simple { + ($value:expr, $expected:expr) => ({ + let s = format!("{}", super::as_json(&$value)); + assert_eq!(s, $expected); + + let s = format!("{}", super::as_pretty_json(&$value)); + assert_eq!(s, $expected); + }) + } + + #[test] + fn test_write_some() { + check_encoder_for_simple!(Some("jodhpurs".to_string()), "\"jodhpurs\""); + } + + #[test] + fn test_write_none() { + check_encoder_for_simple!(None::<string::String>, "null"); + } + + #[test] + fn test_write_char() { + check_encoder_for_simple!('a', "\"a\""); + check_encoder_for_simple!('\t', "\"\\t\""); + check_encoder_for_simple!('\u{0000}', "\"\\u0000\""); + check_encoder_for_simple!('\u{001b}', "\"\\u001b\""); + check_encoder_for_simple!('\u{007f}', "\"\\u007f\""); + check_encoder_for_simple!('\u{00a0}', "\"\u{00a0}\""); + check_encoder_for_simple!('\u{abcd}', "\"\u{abcd}\""); + check_encoder_for_simple!('\u{10ffff}', "\"\u{10ffff}\""); + } + + #[test] + fn test_trailing_characters() { + assert_eq!(Json::from_str("nulla"), Err(SyntaxError(TrailingCharacters, 1, 5))); + assert_eq!(Json::from_str("truea"), Err(SyntaxError(TrailingCharacters, 1, 5))); + assert_eq!(Json::from_str("falsea"), Err(SyntaxError(TrailingCharacters, 1, 6))); + assert_eq!(Json::from_str("1a"), Err(SyntaxError(TrailingCharacters, 1, 2))); + assert_eq!(Json::from_str("[]a"), Err(SyntaxError(TrailingCharacters, 1, 3))); + assert_eq!(Json::from_str("{}a"), Err(SyntaxError(TrailingCharacters, 1, 3))); + } + + #[test] + fn test_read_identifiers() { + assert_eq!(Json::from_str("n"), Err(SyntaxError(InvalidSyntax, 1, 2))); + assert_eq!(Json::from_str("nul"), Err(SyntaxError(InvalidSyntax, 1, 4))); + assert_eq!(Json::from_str("t"), Err(SyntaxError(InvalidSyntax, 1, 2))); + assert_eq!(Json::from_str("truz"), Err(SyntaxError(InvalidSyntax, 1, 4))); + assert_eq!(Json::from_str("f"), Err(SyntaxError(InvalidSyntax, 1, 2))); + assert_eq!(Json::from_str("faz"), Err(SyntaxError(InvalidSyntax, 1, 3))); + + assert_eq!(Json::from_str("null"), Ok(Null)); + assert_eq!(Json::from_str("true"), Ok(Boolean(true))); + assert_eq!(Json::from_str("false"), Ok(Boolean(false))); + assert_eq!(Json::from_str(" null "), Ok(Null)); + assert_eq!(Json::from_str(" true "), Ok(Boolean(true))); + assert_eq!(Json::from_str(" false "), Ok(Boolean(false))); + } + + #[test] + fn test_decode_identifiers() { + let v: () = super::decode("null").unwrap(); + assert_eq!(v, ()); + + let v: bool = super::decode("true").unwrap(); + assert_eq!(v, true); + + let v: bool = super::decode("false").unwrap(); + assert_eq!(v, false); + } + + #[test] + fn test_read_number() { + assert_eq!(Json::from_str("+"), Err(SyntaxError(InvalidSyntax, 1, 1))); + assert_eq!(Json::from_str("."), Err(SyntaxError(InvalidSyntax, 1, 1))); + assert_eq!(Json::from_str("NaN"), Err(SyntaxError(InvalidSyntax, 1, 1))); + assert_eq!(Json::from_str("-"), Err(SyntaxError(InvalidNumber, 1, 2))); + assert_eq!(Json::from_str("00"), Err(SyntaxError(InvalidNumber, 1, 2))); + assert_eq!(Json::from_str("1."), Err(SyntaxError(InvalidNumber, 1, 3))); + assert_eq!(Json::from_str("1e"), Err(SyntaxError(InvalidNumber, 1, 3))); + assert_eq!(Json::from_str("1e+"), Err(SyntaxError(InvalidNumber, 1, 4))); + + assert_eq!(Json::from_str("18446744073709551616"), Err(SyntaxError(InvalidNumber, 1, 20))); + assert_eq!(Json::from_str("18446744073709551617"), Err(SyntaxError(InvalidNumber, 1, 20))); + assert_eq!(Json::from_str("-9223372036854775809"), Err(SyntaxError(InvalidNumber, 1, 21))); + + assert_eq!(Json::from_str("3"), Ok(U64(3))); + assert_eq!(Json::from_str("3.1"), Ok(F64(3.1))); + assert_eq!(Json::from_str("-1.2"), Ok(F64(-1.2))); + assert_eq!(Json::from_str("0.4"), Ok(F64(0.4))); + assert_eq!(Json::from_str("0.4e5"), Ok(F64(0.4e5))); + assert_eq!(Json::from_str("0.4e+15"), Ok(F64(0.4e15))); + assert_eq!(Json::from_str("0.4e-01"), Ok(F64(0.4e-01))); + assert_eq!(Json::from_str(" 3 "), Ok(U64(3))); + + assert_eq!(Json::from_str("-9223372036854775808"), Ok(I64(i64::MIN))); + assert_eq!(Json::from_str("9223372036854775807"), Ok(U64(i64::MAX as u64))); + assert_eq!(Json::from_str("18446744073709551615"), Ok(U64(u64::MAX))); + } + + #[test] + fn test_decode_numbers() { + let v: f64 = super::decode("3").unwrap(); + assert_eq!(v, 3.0); + + let v: f64 = super::decode("3.1").unwrap(); + assert_eq!(v, 3.1); + + let v: f64 = super::decode("-1.2").unwrap(); + assert_eq!(v, -1.2); + + let v: f64 = super::decode("0.4").unwrap(); + assert_eq!(v, 0.4); + + let v: f64 = super::decode("0.4e5").unwrap(); + assert_eq!(v, 0.4e5); + + let v: f64 = super::decode("0.4e15").unwrap(); + assert_eq!(v, 0.4e15); + + let v: f64 = super::decode("0.4e-01").unwrap(); + assert_eq!(v, 0.4e-01); + + let v: u64 = super::decode("0").unwrap(); + assert_eq!(v, 0); + + let v: u64 = super::decode("18446744073709551615").unwrap(); + assert_eq!(v, u64::MAX); + + let v: i64 = super::decode("-9223372036854775808").unwrap(); + assert_eq!(v, i64::MIN); + + let v: i64 = super::decode("9223372036854775807").unwrap(); + assert_eq!(v, i64::MAX); + + let res: DecodeResult<i64> = super::decode("765.25252"); + match res { + Ok(..) => panic!("expected an error"), + Err(ExpectedError(ref s, _)) => assert_eq!(s, "Integer"), + Err(..) => panic!("expected an 'expected integer' error"), + } + } + + #[test] + fn test_read_str() { + assert_eq!(Json::from_str("\""), Err(SyntaxError(EOFWhileParsingString, 1, 2))); + assert_eq!(Json::from_str("\"lol"), Err(SyntaxError(EOFWhileParsingString, 1, 5))); + assert_eq!(Json::from_str("\"\n\""), Err(SyntaxError(ControlCharacterInString, 2, 1))); + + assert_eq!(Json::from_str("\"\""), Ok(String("".to_string()))); + assert_eq!(Json::from_str("\"foo\""), Ok(String("foo".to_string()))); + assert_eq!(Json::from_str("\"\\\"\""), Ok(String("\"".to_string()))); + assert_eq!(Json::from_str("\"\\b\""), Ok(String("\x08".to_string()))); + assert_eq!(Json::from_str("\"\\n\""), Ok(String("\n".to_string()))); + assert_eq!(Json::from_str("\"\\r\""), Ok(String("\r".to_string()))); + assert_eq!(Json::from_str("\"\\t\""), Ok(String("\t".to_string()))); + assert_eq!(Json::from_str(" \"foo\" "), Ok(String("foo".to_string()))); + assert_eq!(Json::from_str("\"\\u12ab\""), Ok(String("\u{12ab}".to_string()))); + assert_eq!(Json::from_str("\"\\uAB12\""), Ok(String("\u{AB12}".to_string()))); + } + + #[test] + fn test_decode_str() { + let s = [("\"\"", ""), + ("\"foo\"", "foo"), + ("\"\\\"\"", "\""), + ("\"\\b\"", "\x08"), + ("\"\\n\"", "\n"), + ("\"\\r\"", "\r"), + ("\"\\t\"", "\t"), + ("\"\\u12ab\"", "\u{12ab}"), + ("\"\\uAB12\"", "\u{AB12}")]; + + for &(i, o) in s.iter() { + let v: string::String = super::decode(i).unwrap(); + assert_eq!(v, o); + } + } + + #[test] + fn test_read_array() { + assert_eq!(Json::from_str("["), Err(SyntaxError(EOFWhileParsingValue, 1, 2))); + assert_eq!(Json::from_str("[1"), Err(SyntaxError(EOFWhileParsingArray, 1, 3))); + assert_eq!(Json::from_str("[1,"), Err(SyntaxError(EOFWhileParsingValue, 1, 4))); + assert_eq!(Json::from_str("[1,]"), Err(SyntaxError(InvalidSyntax, 1, 4))); + assert_eq!(Json::from_str("[6 7]"), Err(SyntaxError(InvalidSyntax, 1, 4))); + + assert_eq!(Json::from_str("[]"), Ok(Array(vec![]))); + assert_eq!(Json::from_str("[ ]"), Ok(Array(vec![]))); + assert_eq!(Json::from_str("[true]"), Ok(Array(vec![Boolean(true)]))); + assert_eq!(Json::from_str("[ false ]"), Ok(Array(vec![Boolean(false)]))); + assert_eq!(Json::from_str("[null]"), Ok(Array(vec![Null]))); + assert_eq!(Json::from_str("[3, 1]"), + Ok(Array(vec![U64(3), U64(1)]))); + assert_eq!(Json::from_str("\n[3, 2]\n"), + Ok(Array(vec![U64(3), U64(2)]))); + assert_eq!(Json::from_str("[2, [4, 1]]"), + Ok(Array(vec![U64(2), Array(vec![U64(4), U64(1)])]))); + } + + #[test] + fn test_decode_array() { + let v: Vec<()> = super::decode("[]").unwrap(); + assert_eq!(v, vec![]); + + let v: Vec<()> = super::decode("[null]").unwrap(); + assert_eq!(v, vec![()]); + + let v: Vec<bool> = super::decode("[true]").unwrap(); + assert_eq!(v, vec![true]); + + let v: Vec<isize> = super::decode("[3, 1]").unwrap(); + assert_eq!(v, vec![3, 1]); + + let v: Vec<Vec<usize>> = super::decode("[[3], [1, 2]]").unwrap(); + assert_eq!(v, vec![vec![3], vec![1, 2]]); + } + + #[test] + fn test_decode_tuple() { + let t: (usize, usize, usize) = super::decode("[1, 2, 3]").unwrap(); + assert_eq!(t, (1, 2, 3)); + + let t: (usize, string::String) = super::decode("[1, \"two\"]").unwrap(); + assert_eq!(t, (1, "two".to_string())); + } + + #[test] + fn test_decode_tuple_malformed_types() { + assert!(super::decode::<(usize, string::String)>("[1, 2]").is_err()); + } + + #[test] + fn test_decode_tuple_malformed_length() { + assert!(super::decode::<(usize, usize)>("[1, 2, 3]").is_err()); + } + + #[test] + fn test_read_object() { + assert_eq!(Json::from_str("{"), Err(SyntaxError(EOFWhileParsingObject, 1, 2))); + assert_eq!(Json::from_str("{ "), Err(SyntaxError(EOFWhileParsingObject, 1, 3))); + assert_eq!(Json::from_str("{1"), Err(SyntaxError(KeyMustBeAString, 1, 2))); + assert_eq!(Json::from_str("{ \"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 6))); + assert_eq!(Json::from_str("{\"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 5))); + assert_eq!(Json::from_str("{\"a\" "), Err(SyntaxError(EOFWhileParsingObject, 1, 6))); + + assert_eq!(Json::from_str("{\"a\" 1"), Err(SyntaxError(ExpectedColon, 1, 6))); + assert_eq!(Json::from_str("{\"a\":"), Err(SyntaxError(EOFWhileParsingValue, 1, 6))); + assert_eq!(Json::from_str("{\"a\":1"), Err(SyntaxError(EOFWhileParsingObject, 1, 7))); + assert_eq!(Json::from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax, 1, 8))); + assert_eq!(Json::from_str("{\"a\":1,"), Err(SyntaxError(EOFWhileParsingObject, 1, 8))); + + assert_eq!(Json::from_str("{}").unwrap(), mk_object(&[])); + assert_eq!(Json::from_str("{\"a\": 3}").unwrap(), + mk_object(&[("a".to_string(), U64(3))])); + + assert_eq!(Json::from_str( + "{ \"a\": null, \"b\" : true }").unwrap(), + mk_object(&[ + ("a".to_string(), Null), + ("b".to_string(), Boolean(true))])); + assert_eq!(Json::from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(), + mk_object(&[ + ("a".to_string(), Null), + ("b".to_string(), Boolean(true))])); + assert_eq!(Json::from_str( + "{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(), + mk_object(&[ + ("a".to_string(), F64(1.0)), + ("b".to_string(), Array(vec![Boolean(true)])) + ])); + assert_eq!(Json::from_str( + "{\ + \"a\": 1.0, \ + \"b\": [\ + true,\ + \"foo\\nbar\", \ + { \"c\": {\"d\": null} } \ + ]\ + }").unwrap(), + mk_object(&[ + ("a".to_string(), F64(1.0)), + ("b".to_string(), Array(vec![ + Boolean(true), + String("foo\nbar".to_string()), + mk_object(&[ + ("c".to_string(), mk_object(&[("d".to_string(), Null)])) + ]) + ])) + ])); + } + + #[test] + fn test_decode_struct() { + let s = "{ + \"inner\": [ + { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] } + ] + }"; + + let v: Outer = super::decode(s).unwrap(); + assert_eq!( + v, + Outer { + inner: vec![ + Inner { a: (), b: 2, c: vec!["abc".to_string(), "xyz".to_string()] } + ] + } + ); + } + + #[derive(RustcDecodable)] + struct FloatStruct { + f: f64, + a: Vec<f64> + } + #[test] + fn test_decode_struct_with_nan() { + let s = "{\"f\":null,\"a\":[null,123]}"; + let obj: FloatStruct = super::decode(s).unwrap(); + assert!(obj.f.is_nan()); + assert!(obj.a[0].is_nan()); + assert_eq!(obj.a[1], 123f64); + } + + #[test] + fn test_decode_option() { + let value: Option<string::String> = super::decode("null").unwrap(); + assert_eq!(value, None); + + let value: Option<string::String> = super::decode("\"jodhpurs\"").unwrap(); + assert_eq!(value, Some("jodhpurs".to_string())); + } + + #[test] + fn test_decode_enum() { + let value: Animal = super::decode("\"Dog\"").unwrap(); + assert_eq!(value, Dog); + + let s = "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}"; + let value: Animal = super::decode(s).unwrap(); + assert_eq!(value, Frog("Henry".to_string(), 349)); + } + + #[test] + fn test_decode_map() { + let s = "{\"a\": \"Dog\", \"b\": {\"variant\":\"Frog\",\ + \"fields\":[\"Henry\", 349]}}"; + let mut map: BTreeMap<string::String, Animal> = super::decode(s).unwrap(); + + assert_eq!(map.remove(&"a".to_string()), Some(Dog)); + assert_eq!(map.remove(&"b".to_string()), Some(Frog("Henry".to_string(), 349))); + } + + #[test] + fn test_multiline_errors() { + assert_eq!(Json::from_str("{\n \"foo\":\n \"bar\""), + Err(SyntaxError(EOFWhileParsingObject, 3, 8))); + } + + #[derive(RustcDecodable)] + #[allow(dead_code)] + struct DecodeStruct { + x: f64, + y: bool, + z: string::String, + w: Vec<DecodeStruct> + } + #[derive(RustcDecodable)] + enum DecodeEnum { + A(f64), + B(string::String) + } + fn check_err<T: Decodable>(to_parse: &'static str, expected: DecoderError) { + let res: DecodeResult<T> = match Json::from_str(to_parse) { + Err(e) => Err(ParseError(e)), + Ok(json) => Decodable::decode(&mut Decoder::new(json)) + }; + match res { + Ok(_) => panic!("`{:?}` parsed & decoded ok, expecting error `{:?}`", + to_parse, expected), + Err(ParseError(e)) => panic!("`{}` is not valid json: {:?}", + to_parse, e), + Err(e) => { + assert_eq!(e, expected); + } + } + } + #[test] + fn test_decode_errors_struct() { + check_err::<DecodeStruct>("[]", ExpectedError("Object".to_string(), "[]".to_string())); + check_err::<DecodeStruct>("{\"x\": true, \"y\": true, \"z\": \"\", \"w\": []}", + ExpectedError("Number".to_string(), "true".to_string())); + check_err::<DecodeStruct>("{\"x\": 1, \"y\": [], \"z\": \"\", \"w\": []}", + ExpectedError("Boolean".to_string(), "[]".to_string())); + check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": {}, \"w\": []}", + ExpectedError("String".to_string(), "{}".to_string())); + check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": \"\", \"w\": null}", + ExpectedError("Array".to_string(), "null".to_string())); + check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": \"\"}", + MissingFieldError("w".to_string())); + } + #[test] + fn test_decode_errors_enum() { + check_err::<DecodeEnum>("{}", + MissingFieldError("variant".to_string())); + check_err::<DecodeEnum>("{\"variant\": 1}", + ExpectedError("String".to_string(), "1".to_string())); + check_err::<DecodeEnum>("{\"variant\": \"A\"}", + MissingFieldError("fields".to_string())); + check_err::<DecodeEnum>("{\"variant\": \"A\", \"fields\": null}", + ExpectedError("Array".to_string(), "null".to_string())); + check_err::<DecodeEnum>("{\"variant\": \"C\", \"fields\": []}", + UnknownVariantError("C".to_string())); + } + + #[test] + fn test_find(){ + let json_value = Json::from_str("{\"dog\" : \"cat\"}").unwrap(); + let found_str = json_value.find("dog"); + assert!(found_str.unwrap().as_string().unwrap() == "cat"); + } + + #[test] + fn test_find_path(){ + let json_value = Json::from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap(); + let found_str = json_value.find_path(&["dog", "cat", "mouse"]); + assert!(found_str.unwrap().as_string().unwrap() == "cheese"); + } + + #[test] + fn test_search(){ + let json_value = Json::from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap(); + let found_str = json_value.search("mouse").and_then(|j| j.as_string()); + assert!(found_str.unwrap() == "cheese"); + } + + #[test] + fn test_index(){ + let json_value = Json::from_str("{\"animals\":[\"dog\",\"cat\",\"mouse\"]}").unwrap(); + let ref array = json_value["animals"]; + assert_eq!(array[0].as_string().unwrap(), "dog"); + assert_eq!(array[1].as_string().unwrap(), "cat"); + assert_eq!(array[2].as_string().unwrap(), "mouse"); + } + + #[test] + fn test_is_object(){ + let json_value = Json::from_str("{}").unwrap(); + assert!(json_value.is_object()); + } + + #[test] + fn test_as_object(){ + let json_value = Json::from_str("{}").unwrap(); + let json_object = json_value.as_object(); + assert!(json_object.is_some()); + } + + #[test] + fn test_is_array(){ + let json_value = Json::from_str("[1, 2, 3]").unwrap(); + assert!(json_value.is_array()); + } + + #[test] + fn test_as_array(){ + let json_value = Json::from_str("[1, 2, 3]").unwrap(); + let json_array = json_value.as_array(); + let expected_length = 3; + assert!(json_array.is_some() && json_array.unwrap().len() == expected_length); + } + + #[test] + fn test_is_string(){ + let json_value = Json::from_str("\"dog\"").unwrap(); + assert!(json_value.is_string()); + } + + #[test] + fn test_as_string(){ + let json_value = Json::from_str("\"dog\"").unwrap(); + let json_str = json_value.as_string(); + let expected_str = "dog"; + assert_eq!(json_str, Some(expected_str)); + } + + #[test] + fn test_is_number(){ + let json_value = Json::from_str("12").unwrap(); + assert!(json_value.is_number()); + } + + #[test] + fn test_is_i64(){ + let json_value = Json::from_str("-12").unwrap(); + assert!(json_value.is_i64()); + + let json_value = Json::from_str("12").unwrap(); + assert!(!json_value.is_i64()); + + let json_value = Json::from_str("12.0").unwrap(); + assert!(!json_value.is_i64()); + } + + #[test] + fn test_is_u64(){ + let json_value = Json::from_str("12").unwrap(); + assert!(json_value.is_u64()); + + let json_value = Json::from_str("-12").unwrap(); + assert!(!json_value.is_u64()); + + let json_value = Json::from_str("12.0").unwrap(); + assert!(!json_value.is_u64()); + } + + #[test] + fn test_is_f64(){ + let json_value = Json::from_str("12").unwrap(); + assert!(!json_value.is_f64()); + + let json_value = Json::from_str("-12").unwrap(); + assert!(!json_value.is_f64()); + + let json_value = Json::from_str("12.0").unwrap(); + assert!(json_value.is_f64()); + + let json_value = Json::from_str("-12.0").unwrap(); + assert!(json_value.is_f64()); + } + + #[test] + fn test_as_i64(){ + let json_value = Json::from_str("-12").unwrap(); + let json_num = json_value.as_i64(); + assert_eq!(json_num, Some(-12)); + } + + #[test] + fn test_as_u64(){ + let json_value = Json::from_str("12").unwrap(); + let json_num = json_value.as_u64(); + assert_eq!(json_num, Some(12)); + } + + #[test] + fn test_as_f64(){ + let json_value = Json::from_str("12.0").unwrap(); + let json_num = json_value.as_f64(); + assert_eq!(json_num, Some(12f64)); + } + + #[test] + fn test_is_boolean(){ + let json_value = Json::from_str("false").unwrap(); + assert!(json_value.is_boolean()); + } + + #[test] + fn test_as_boolean(){ + let json_value = Json::from_str("false").unwrap(); + let json_bool = json_value.as_boolean(); + let expected_bool = false; + assert!(json_bool.is_some() && json_bool.unwrap() == expected_bool); + } + + #[test] + fn test_is_null(){ + let json_value = Json::from_str("null").unwrap(); + assert!(json_value.is_null()); + } + + #[test] + fn test_as_null(){ + let json_value = Json::from_str("null").unwrap(); + let json_null = json_value.as_null(); + let expected_null = (); + assert!(json_null.is_some() && json_null.unwrap() == expected_null); + } + + #[test] + fn test_encode_hashmap_with_numeric_key() { + use std::collections::HashMap; + let mut hm: HashMap<usize, bool> = HashMap::new(); + hm.insert(1, true); + let json_str = super::as_pretty_json(&hm).to_string(); + match Json::from_str(&json_str) { + Err(_) => panic!("Unable to parse json_str: {}", json_str), + _ => {} // it parsed and we are good to go + } + } + + #[test] + fn test_prettyencode_hashmap_with_numeric_key() { + use std::collections::HashMap; + let mut hm: HashMap<usize, bool> = HashMap::new(); + hm.insert(1, true); + let json_str = super::as_pretty_json(&hm).to_string(); + match Json::from_str(&json_str) { + Err(_) => panic!("Unable to parse json_str: {}", json_str), + _ => {} // it parsed and we are good to go + } + } + + #[test] + fn test_prettyencoder_indent_level_param() { + use std::collections::BTreeMap; + + let mut tree = BTreeMap::new(); + + tree.insert("hello".to_string(), String("guten tag".to_string())); + tree.insert("goodbye".to_string(), String("sayonara".to_string())); + + let json = Array( + // The following layout below should look a lot like + // the pretty-printed JSON (indent * x) + vec! + ( // 0x + String("greetings".to_string()), // 1x + Object(tree), // 1x + 2x + 2x + 1x + ) // 0x + // End JSON array (7 lines) + ); + + // Helper function for counting indents + fn indents(source: &str) -> usize { + let trimmed = source.trim_left_matches(' '); + source.len() - trimmed.len() + } + + // Test up to 4 spaces of indents (more?) + for i in 0..4 { + let printed = super::as_pretty_json(&json).indent(i as u32) + .to_string(); + + // Check for indents at each line + let lines: Vec<&str> = printed.lines().collect(); + assert_eq!(lines.len(), 7); // JSON should be 7 lines + + assert_eq!(indents(lines[0]), 0 * i); // [ + assert_eq!(indents(lines[1]), 1 * i); // "greetings", + assert_eq!(indents(lines[2]), 1 * i); // { + assert_eq!(indents(lines[3]), 2 * i); // "hello": "guten tag", + assert_eq!(indents(lines[4]), 2 * i); // "goodbye": "sayonara" + assert_eq!(indents(lines[5]), 1 * i); // }, + assert_eq!(indents(lines[6]), 0 * i); // ] + + // Finally, test that the pretty-printed JSON is valid + Json::from_str(&printed).ok() + .expect("Pretty-printed JSON is invalid!"); + } + } + + #[test] + fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() { + use std::collections::HashMap; + use Decodable; + let json_str = "{\"1\":true}"; + let json_obj = match Json::from_str(json_str) { + Err(_) => panic!("Unable to parse json_str: {}", json_str), + Ok(o) => o + }; + let mut decoder = Decoder::new(json_obj); + let _hm: HashMap<usize, bool> = Decodable::decode(&mut decoder).unwrap(); + } + + #[test] + fn test_hashmap_with_enum_key() { + use std::collections::HashMap; + use json; + #[derive(RustcEncodable, Eq, Hash, PartialEq, RustcDecodable, Debug)] + enum Enum { + Foo, + #[allow(dead_code)] + Bar, + } + let mut map = HashMap::new(); + map.insert(Enum::Foo, 0); + let result = json::encode(&map).unwrap(); + assert_eq!(result, r#"{"Foo":0}"#); + let decoded: HashMap<Enum, _> = json::decode(&result).unwrap(); + assert_eq!(map, decoded); + } + + #[test] + fn test_hashmap_with_numeric_key_will_error_with_string_keys() { + use std::collections::HashMap; + use Decodable; + let json_str = "{\"a\":true}"; + let json_obj = match Json::from_str(json_str) { + Err(_) => panic!("Unable to parse json_str: {}", json_str), + Ok(o) => o + }; + let mut decoder = Decoder::new(json_obj); + let result: Result<HashMap<usize, bool>, DecoderError> = Decodable::decode(&mut decoder); + assert_eq!(result, Err(ExpectedError("Number".to_string(), "a".to_string()))); + } + + fn assert_stream_equal(src: &str, + expected: Vec<(JsonEvent, Vec<StackElement>)>) { + let mut parser = Parser::new(src.chars()); + let mut i = 0; + loop { + let evt = match parser.next() { + Some(e) => e, + None => { break; } + }; + let (ref expected_evt, ref expected_stack) = expected[i]; + if !parser.stack().is_equal_to(&expected_stack) { + panic!("Parser stack is not equal to {:?}", expected_stack); + } + assert_eq!(&evt, expected_evt); + i+=1; + } + } + #[test] + #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064) + fn test_streaming_parser() { + assert_stream_equal( + r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#, + vec![ + (ObjectStart, vec![]), + (StringValue("bar".to_string()), vec![Key("foo")]), + (ArrayStart, vec![Key("array")]), + (U64Value(0), vec![Key("array"), Index(0)]), + (U64Value(1), vec![Key("array"), Index(1)]), + (U64Value(2), vec![Key("array"), Index(2)]), + (U64Value(3), vec![Key("array"), Index(3)]), + (U64Value(4), vec![Key("array"), Index(4)]), + (U64Value(5), vec![Key("array"), Index(5)]), + (ArrayEnd, vec![Key("array")]), + (ArrayStart, vec![Key("idents")]), + (NullValue, vec![Key("idents"), Index(0)]), + (BooleanValue(true), vec![Key("idents"), Index(1)]), + (BooleanValue(false), vec![Key("idents"), Index(2)]), + (ArrayEnd, vec![Key("idents")]), + (ObjectEnd, vec![]), + ] + ); + } + fn last_event(src: &str) -> JsonEvent { + let mut parser = Parser::new(src.chars()); + let mut evt = NullValue; + loop { + evt = match parser.next() { + Some(e) => e, + None => return evt, + } + } + } + + #[test] + #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064) + fn test_read_object_streaming() { + assert_eq!(last_event("{ "), Error(SyntaxError(EOFWhileParsingObject, 1, 3))); + assert_eq!(last_event("{1"), Error(SyntaxError(KeyMustBeAString, 1, 2))); + assert_eq!(last_event("{ \"a\""), Error(SyntaxError(EOFWhileParsingObject, 1, 6))); + assert_eq!(last_event("{\"a\""), Error(SyntaxError(EOFWhileParsingObject, 1, 5))); + assert_eq!(last_event("{\"a\" "), Error(SyntaxError(EOFWhileParsingObject, 1, 6))); + + assert_eq!(last_event("{\"a\" 1"), Error(SyntaxError(ExpectedColon, 1, 6))); + assert_eq!(last_event("{\"a\":"), Error(SyntaxError(EOFWhileParsingValue, 1, 6))); + assert_eq!(last_event("{\"a\":1"), Error(SyntaxError(EOFWhileParsingObject, 1, 7))); + assert_eq!(last_event("{\"a\":1 1"), Error(SyntaxError(InvalidSyntax, 1, 8))); + assert_eq!(last_event("{\"a\":1,"), Error(SyntaxError(EOFWhileParsingObject, 1, 8))); + assert_eq!(last_event("{\"a\":1,}"), Error(SyntaxError(TrailingComma, 1, 8))); + + assert_stream_equal( + "{}", + vec![(ObjectStart, vec![]), (ObjectEnd, vec![])] + ); + assert_stream_equal( + "{\"a\": 3}", + vec![ + (ObjectStart, vec![]), + (U64Value(3), vec![Key("a")]), + (ObjectEnd, vec![]), + ] + ); + assert_stream_equal( + "{ \"a\": null, \"b\" : true }", + vec![ + (ObjectStart, vec![]), + (NullValue, vec![Key("a")]), + (BooleanValue(true), vec![Key("b")]), + (ObjectEnd, vec![]), + ] + ); + assert_stream_equal( + "{\"a\" : 1.0 ,\"b\": [ true ]}", + vec![ + (ObjectStart, vec![]), + (F64Value(1.0), vec![Key("a")]), + (ArrayStart, vec![Key("b")]), + (BooleanValue(true),vec![Key("b"), Index(0)]), + (ArrayEnd, vec![Key("b")]), + (ObjectEnd, vec![]), + ] + ); + assert_stream_equal( + r#"{ + "a": 1.0, + "b": [ + true, + "foo\nbar", + { "c": {"d": null} }, + "\uD834\uDF06" + ] + }"#, + vec![ + (ObjectStart, vec![]), + (F64Value(1.0), vec![Key("a")]), + (ArrayStart, vec![Key("b")]), + (BooleanValue(true), vec![Key("b"), Index(0)]), + (StringValue("foo\nbar".to_string()), vec![Key("b"), Index(1)]), + (ObjectStart, vec![Key("b"), Index(2)]), + (ObjectStart, vec![Key("b"), Index(2), Key("c")]), + (NullValue, vec![Key("b"), Index(2), Key("c"), Key("d")]), + (ObjectEnd, vec![Key("b"), Index(2), Key("c")]), + (ObjectEnd, vec![Key("b"), Index(2)]), + (StringValue("\u{1D306}".to_string()), vec![Key("b"), Index(3)]), + (ArrayEnd, vec![Key("b")]), + (ObjectEnd, vec![]), + ] + ); + } + #[test] + #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064) + fn test_read_array_streaming() { + assert_stream_equal( + "[]", + vec![ + (ArrayStart, vec![]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "[ ]", + vec![ + (ArrayStart, vec![]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "[true]", + vec![ + (ArrayStart, vec![]), + (BooleanValue(true), vec![Index(0)]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "[ false ]", + vec![ + (ArrayStart, vec![]), + (BooleanValue(false), vec![Index(0)]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "[null]", + vec![ + (ArrayStart, vec![]), + (NullValue, vec![Index(0)]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "[3, 1]", + vec![ + (ArrayStart, vec![]), + (U64Value(3), vec![Index(0)]), + (U64Value(1), vec![Index(1)]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "\n[3, 2]\n", + vec![ + (ArrayStart, vec![]), + (U64Value(3), vec![Index(0)]), + (U64Value(2), vec![Index(1)]), + (ArrayEnd, vec![]), + ] + ); + assert_stream_equal( + "[2, [4, 1]]", + vec![ + (ArrayStart, vec![]), + (U64Value(2), vec![Index(0)]), + (ArrayStart, vec![Index(1)]), + (U64Value(4), vec![Index(1), Index(0)]), + (U64Value(1), vec![Index(1), Index(1)]), + (ArrayEnd, vec![Index(1)]), + (ArrayEnd, vec![]), + ] + ); + + assert_eq!(last_event("["), Error(SyntaxError(EOFWhileParsingValue, 1, 2))); + + assert_eq!(Json::from_str("["), Err(SyntaxError(EOFWhileParsingValue, 1, 2))); + assert_eq!(Json::from_str("[1"), Err(SyntaxError(EOFWhileParsingArray, 1, 3))); + assert_eq!(Json::from_str("[1,"), Err(SyntaxError(EOFWhileParsingValue, 1, 4))); + assert_eq!(Json::from_str("[1,]"), Err(SyntaxError(InvalidSyntax, 1, 4))); + assert_eq!(Json::from_str("[6 7]"), Err(SyntaxError(InvalidSyntax, 1, 4))); + + } + #[test] + fn test_trailing_characters_streaming() { + assert_eq!(last_event("nulla"), Error(SyntaxError(TrailingCharacters, 1, 5))); + assert_eq!(last_event("truea"), Error(SyntaxError(TrailingCharacters, 1, 5))); + assert_eq!(last_event("falsea"), Error(SyntaxError(TrailingCharacters, 1, 6))); + assert_eq!(last_event("1a"), Error(SyntaxError(TrailingCharacters, 1, 2))); + assert_eq!(last_event("[]a"), Error(SyntaxError(TrailingCharacters, 1, 3))); + assert_eq!(last_event("{}a"), Error(SyntaxError(TrailingCharacters, 1, 3))); + } + #[test] + fn test_read_identifiers_streaming() { + assert_eq!(Parser::new("null".chars()).next(), Some(NullValue)); + assert_eq!(Parser::new("true".chars()).next(), Some(BooleanValue(true))); + assert_eq!(Parser::new("false".chars()).next(), Some(BooleanValue(false))); + + assert_eq!(last_event("n"), Error(SyntaxError(InvalidSyntax, 1, 2))); + assert_eq!(last_event("nul"), Error(SyntaxError(InvalidSyntax, 1, 4))); + assert_eq!(last_event("t"), Error(SyntaxError(InvalidSyntax, 1, 2))); + assert_eq!(last_event("truz"), Error(SyntaxError(InvalidSyntax, 1, 4))); + assert_eq!(last_event("f"), Error(SyntaxError(InvalidSyntax, 1, 2))); + assert_eq!(last_event("faz"), Error(SyntaxError(InvalidSyntax, 1, 3))); + } + + #[test] + fn test_stack() { + let mut stack = Stack::new(); + + assert!(stack.is_empty()); + assert!(stack.len() == 0); + assert!(!stack.last_is_index()); + + stack.push_index(0); + stack.bump_index(); + + assert!(stack.len() == 1); + assert!(stack.is_equal_to(&[Index(1)])); + assert!(stack.starts_with(&[Index(1)])); + assert!(stack.ends_with(&[Index(1)])); + assert!(stack.last_is_index()); + assert!(stack.get(0) == Index(1)); + + stack.push_key("foo".to_string()); + + assert!(stack.len() == 2); + assert!(stack.is_equal_to(&[Index(1), Key("foo")])); + assert!(stack.starts_with(&[Index(1), Key("foo")])); + assert!(stack.starts_with(&[Index(1)])); + assert!(stack.ends_with(&[Index(1), Key("foo")])); + assert!(stack.ends_with(&[Key("foo")])); + assert!(!stack.last_is_index()); + assert!(stack.get(0) == Index(1)); + assert!(stack.get(1) == Key("foo")); + + stack.push_key("bar".to_string()); + + assert!(stack.len() == 3); + assert!(stack.is_equal_to(&[Index(1), Key("foo"), Key("bar")])); + assert!(stack.starts_with(&[Index(1)])); + assert!(stack.starts_with(&[Index(1), Key("foo")])); + assert!(stack.starts_with(&[Index(1), Key("foo"), Key("bar")])); + assert!(stack.ends_with(&[Key("bar")])); + assert!(stack.ends_with(&[Key("foo"), Key("bar")])); + assert!(stack.ends_with(&[Index(1), Key("foo"), Key("bar")])); + assert!(!stack.last_is_index()); + assert!(stack.get(0) == Index(1)); + assert!(stack.get(1) == Key("foo")); + assert!(stack.get(2) == Key("bar")); + + stack.pop(); + + assert!(stack.len() == 2); + assert!(stack.is_equal_to(&[Index(1), Key("foo")])); + assert!(stack.starts_with(&[Index(1), Key("foo")])); + assert!(stack.starts_with(&[Index(1)])); + assert!(stack.ends_with(&[Index(1), Key("foo")])); + assert!(stack.ends_with(&[Key("foo")])); + assert!(!stack.last_is_index()); + assert!(stack.get(0) == Index(1)); + assert!(stack.get(1) == Key("foo")); + } + + #[test] + fn test_to_json() { + use std::collections::{HashMap,BTreeMap}; + use super::ToJson; + + let array2 = Array(vec!(I64(1), I64(2))); + let array3 = Array(vec!(I64(1), I64(2), I64(3))); + let object = { + let mut tree_map = BTreeMap::new(); + tree_map.insert("a".to_string(), U64(1)); + tree_map.insert("b".to_string(), U64(2)); + Object(tree_map) + }; + + assert_eq!(array2.to_json(), array2); + assert_eq!(object.to_json(), object); + assert_eq!(3_isize.to_json(), I64(3)); + assert_eq!(4_i8.to_json(), I64(4)); + assert_eq!(5_i16.to_json(), I64(5)); + assert_eq!(6_i32.to_json(), I64(6)); + assert_eq!(7_i64.to_json(), I64(7)); + assert_eq!(8_usize.to_json(), U64(8)); + assert_eq!(9_u8.to_json(), U64(9)); + assert_eq!(10_u16.to_json(), U64(10)); + assert_eq!(11_u32.to_json(), U64(11)); + assert_eq!(12_u64.to_json(), U64(12)); + assert_eq!(13.0_f32.to_json(), F64(13.0_f64)); + assert_eq!(14.0_f64.to_json(), F64(14.0_f64)); + assert_eq!(().to_json(), Null); + assert_eq!(f32::INFINITY.to_json(), Null); + assert_eq!(f64::NAN.to_json(), Null); + assert_eq!(true.to_json(), Boolean(true)); + assert_eq!(false.to_json(), Boolean(false)); + assert_eq!("abc".to_json(), String("abc".to_string())); + assert_eq!("abc".to_string().to_json(), String("abc".to_string())); + assert_eq!((1, 2).to_json(), array2); + assert_eq!((1, 2, 3).to_json(), array3); + assert_eq!([1, 2].to_json(), array2); + assert_eq!((&[1, 2, 3]).to_json(), array3); + assert_eq!((vec![1, 2]).to_json(), array2); + assert_eq!(vec!(1, 2, 3).to_json(), array3); + let mut tree_map = BTreeMap::new(); + tree_map.insert("a".to_string(), 1 as u32); + tree_map.insert("b".to_string(), 2); + assert_eq!(tree_map.to_json(), object); + let mut hash_map = HashMap::new(); + hash_map.insert("a".to_string(), 1 as u32); + hash_map.insert("b".to_string(), 2); + assert_eq!(hash_map.to_json(), object); + assert_eq!(Some(15).to_json(), I64(15)); + assert_eq!(Some(15 as u32).to_json(), U64(15)); + assert_eq!(None::<isize>.to_json(), Null); + } + + #[test] + fn test_encode_hashmap_with_arbitrary_key() { + use std::collections::HashMap; + #[derive(PartialEq, Eq, Hash, RustcEncodable)] + struct ArbitraryType(u32); + let mut hm: HashMap<ArbitraryType, bool> = HashMap::new(); + hm.insert(ArbitraryType(1), true); + let mut mem_buf = string::String::new(); + let mut encoder = Encoder::new(&mut mem_buf); + let result = hm.encode(&mut encoder); + match result.err().unwrap() { + EncoderError::BadHashmapKey => (), + _ => panic!("expected bad hash map key") + } + } + + #[test] + fn test_bad_json_stack_depleted() { + use json; + #[derive(Debug, RustcDecodable)] + enum ChatEvent { + Variant(i32) + } + let serialized = "{\"variant\": \"Variant\", \"fields\": []}"; + let r: Result<ChatEvent, _> = json::decode(serialized); + assert!(r.unwrap_err() == EOF); + } + + #[test] + fn fixed_length_array() { + #[derive(Debug, RustcDecodable, RustcEncodable, Eq, PartialEq)] + struct Foo { + a: [u8; 1], + b: [i32; 2], + c: [u64; 3], + } + let f = Foo { + a: [0], + b: [1, 2], + c: [3, 4, 5], + }; + let s = super::encode(&f).unwrap(); + let d = super::decode(&s).unwrap(); + assert_eq!(f, d); + } +} diff --git a/deps/rustc-serialize-0.3.15/src/lib.rs b/deps/rustc-serialize-0.3.15/src/lib.rs new file mode 100644 index 000000000..b1ebbd94b --- /dev/null +++ b/deps/rustc-serialize-0.3.15/src/lib.rs @@ -0,0 +1,55 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Support code for encoding and decoding types. +//! +//! # Usage +//! +//! This crate is [on crates.io](https://crates.io/crates/rustc-serialize) and +//! can be used by adding `rustc-serialize` to the dependencies in your +//! project's `Cargo.toml`. +//! +//! ```toml +//! [dependencies] +//! rustc-serialize = "0.3" +//! ``` +//! +//! and this to your crate root: +//! +//! ```rust +//! extern crate rustc_serialize; +//! ``` + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/rustc-serialize/")] +#![cfg_attr(test, deny(warnings))] +#![allow(trivial_numeric_casts)] +#![cfg_attr(rust_build, feature(staged_api))] +#![cfg_attr(rust_build, staged_api)] +#![cfg_attr(rust_build, + unstable(feature = "rustc_private", + reason = "use the crates.io `rustc-serialize` library instead"))] + +#[cfg(test)] extern crate rand; + +pub use self::serialize::{Decoder, Encoder, Decodable, Encodable, + DecoderHelpers, EncoderHelpers}; + +mod serialize; +mod collection_impls; + +pub mod base64; +pub mod hex; +pub mod json; + +mod rustc_serialize { + pub use serialize::*; +} diff --git a/deps/rustc-serialize-0.3.15/src/serialize.rs b/deps/rustc-serialize-0.3.15/src/serialize.rs new file mode 100644 index 000000000..436226c28 --- /dev/null +++ b/deps/rustc-serialize-0.3.15/src/serialize.rs @@ -0,0 +1,732 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Support code for encoding and decoding types. + +/* +Core encoding and decoding interfaces. +*/ + +use std::cell::{Cell, RefCell}; +use std::ffi::OsString; +use std::path; +use std::rc::Rc; +use std::sync::Arc; +use std::marker::PhantomData; +use std::borrow::Cow; + +pub trait Encoder { + type Error; + + // Primitive types: + fn emit_nil(&mut self) -> Result<(), Self::Error>; + fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>; + fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>; + fn emit_u32(&mut self, v: u32) -> Result<(), Self::Error>; + fn emit_u16(&mut self, v: u16) -> Result<(), Self::Error>; + fn emit_u8(&mut self, v: u8) -> Result<(), Self::Error>; + fn emit_isize(&mut self, v: isize) -> Result<(), Self::Error>; + fn emit_i64(&mut self, v: i64) -> Result<(), Self::Error>; + fn emit_i32(&mut self, v: i32) -> Result<(), Self::Error>; + fn emit_i16(&mut self, v: i16) -> Result<(), Self::Error>; + fn emit_i8(&mut self, v: i8) -> Result<(), Self::Error>; + fn emit_bool(&mut self, v: bool) -> Result<(), Self::Error>; + fn emit_f64(&mut self, v: f64) -> Result<(), Self::Error>; + fn emit_f32(&mut self, v: f32) -> Result<(), Self::Error>; + fn emit_char(&mut self, v: char) -> Result<(), Self::Error>; + fn emit_str(&mut self, v: &str) -> Result<(), Self::Error>; + + // Compound types: + fn emit_enum<F>(&mut self, name: &str, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_enum_variant<F>(&mut self, v_name: &str, + v_id: usize, + len: usize, + f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_enum_variant_arg<F>(&mut self, a_idx: usize, f: F) + -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_enum_struct_variant<F>(&mut self, v_name: &str, + v_id: usize, + len: usize, + f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_enum_struct_variant_field<F>(&mut self, + f_name: &str, + f_idx: usize, + f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_struct<F>(&mut self, name: &str, len: usize, f: F) + -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_struct_field<F>(&mut self, f_name: &str, f_idx: usize, f: F) + -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_tuple<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_tuple_struct<F>(&mut self, name: &str, len: usize, f: F) + -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_tuple_struct_arg<F>(&mut self, f_idx: usize, f: F) + -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + // Specialized types: + fn emit_option<F>(&mut self, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_option_none(&mut self) -> Result<(), Self::Error>; + fn emit_option_some<F>(&mut self, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_seq_elt<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + + fn emit_map<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_map_elt_key<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; + fn emit_map_elt_val<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> + where F: FnOnce(&mut Self) -> Result<(), Self::Error>; +} + +pub trait Decoder { + type Error; + + // Primitive types: + fn read_nil(&mut self) -> Result<(), Self::Error>; + fn read_usize(&mut self) -> Result<usize, Self::Error>; + fn read_u64(&mut self) -> Result<u64, Self::Error>; + fn read_u32(&mut self) -> Result<u32, Self::Error>; + fn read_u16(&mut self) -> Result<u16, Self::Error>; + fn read_u8(&mut self) -> Result<u8, Self::Error>; + fn read_isize(&mut self) -> Result<isize, Self::Error>; + fn read_i64(&mut self) -> Result<i64, Self::Error>; + fn read_i32(&mut self) -> Result<i32, Self::Error>; + fn read_i16(&mut self) -> Result<i16, Self::Error>; + fn read_i8(&mut self) -> Result<i8, Self::Error>; + fn read_bool(&mut self) -> Result<bool, Self::Error>; + fn read_f64(&mut self) -> Result<f64, Self::Error>; + fn read_f32(&mut self) -> Result<f32, Self::Error>; + fn read_char(&mut self) -> Result<char, Self::Error>; + fn read_str(&mut self) -> Result<String, Self::Error>; + + // Compound types: + fn read_enum<T, F>(&mut self, name: &str, f: F) -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) + -> Result<T, Self::Error> + where F: FnMut(&mut Self, usize) -> Result<T, Self::Error>; + fn read_enum_variant_arg<T, F>(&mut self, a_idx: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) + -> Result<T, Self::Error> + where F: FnMut(&mut Self, usize) -> Result<T, Self::Error>; + fn read_enum_struct_variant_field<T, F>(&mut self, + &f_name: &str, + f_idx: usize, + f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + fn read_struct_field<T, F>(&mut self, + f_name: &str, + f_idx: usize, + f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + fn read_tuple<T, F>(&mut self, len: usize, f: F) -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + fn read_tuple_arg<T, F>(&mut self, a_idx: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + fn read_tuple_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + fn read_tuple_struct_arg<T, F>(&mut self, a_idx: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + // Specialized types: + fn read_option<T, F>(&mut self, f: F) -> Result<T, Self::Error> + where F: FnMut(&mut Self, bool) -> Result<T, Self::Error>; + + fn read_seq<T, F>(&mut self, f: F) -> Result<T, Self::Error> + where F: FnOnce(&mut Self, usize) -> Result<T, Self::Error>; + fn read_seq_elt<T, F>(&mut self, idx: usize, f: F) -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + fn read_map<T, F>(&mut self, f: F) -> Result<T, Self::Error> + where F: FnOnce(&mut Self, usize) -> Result<T, Self::Error>; + fn read_map_elt_key<T, F>(&mut self, idx: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + fn read_map_elt_val<T, F>(&mut self, idx: usize, f: F) + -> Result<T, Self::Error> + where F: FnOnce(&mut Self) -> Result<T, Self::Error>; + + // Failure + fn error(&mut self, err: &str) -> Self::Error; +} + +pub trait Encodable { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>; +} + +pub trait Decodable { + fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>; +} + +impl Encodable for usize { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_usize(*self) + } +} + +impl Decodable for usize { + fn decode<D: Decoder>(d: &mut D) -> Result<usize, D::Error> { + d.read_usize() + } +} + +impl Encodable for u8 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_u8(*self) + } +} + +impl Decodable for u8 { + fn decode<D: Decoder>(d: &mut D) -> Result<u8, D::Error> { + d.read_u8() + } +} + +impl Encodable for u16 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_u16(*self) + } +} + +impl Decodable for u16 { + fn decode<D: Decoder>(d: &mut D) -> Result<u16, D::Error> { + d.read_u16() + } +} + +impl Encodable for u32 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_u32(*self) + } +} + +impl Decodable for u32 { + fn decode<D: Decoder>(d: &mut D) -> Result<u32, D::Error> { + d.read_u32() + } +} + +impl Encodable for u64 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_u64(*self) + } +} + +impl Decodable for u64 { + fn decode<D: Decoder>(d: &mut D) -> Result<u64, D::Error> { + d.read_u64() + } +} + +impl Encodable for isize { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_isize(*self) + } +} + +impl Decodable for isize { + fn decode<D: Decoder>(d: &mut D) -> Result<isize, D::Error> { + d.read_isize() + } +} + +impl Encodable for i8 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_i8(*self) + } +} + +impl Decodable for i8 { + fn decode<D: Decoder>(d: &mut D) -> Result<i8, D::Error> { + d.read_i8() + } +} + +impl Encodable for i16 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_i16(*self) + } +} + +impl Decodable for i16 { + fn decode<D: Decoder>(d: &mut D) -> Result<i16, D::Error> { + d.read_i16() + } +} + +impl Encodable for i32 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_i32(*self) + } +} + +impl Decodable for i32 { + fn decode<D: Decoder>(d: &mut D) -> Result<i32, D::Error> { + d.read_i32() + } +} + +impl Encodable for i64 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_i64(*self) + } +} + +impl Decodable for i64 { + fn decode<D: Decoder>(d: &mut D) -> Result<i64, D::Error> { + d.read_i64() + } +} + +impl Encodable for str { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_str(self) + } +} + +impl Encodable for String { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_str(self) + } +} + +impl Decodable for String { + fn decode<D: Decoder>(d: &mut D) -> Result<String, D::Error> { + d.read_str() + } +} + +impl Encodable for f32 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_f32(*self) + } +} + +impl Decodable for f32 { + fn decode<D: Decoder>(d: &mut D) -> Result<f32, D::Error> { + d.read_f32() + } +} + +impl Encodable for f64 { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_f64(*self) + } +} + +impl Decodable for f64 { + fn decode<D: Decoder>(d: &mut D) -> Result<f64, D::Error> { + d.read_f64() + } +} + +impl Encodable for bool { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_bool(*self) + } +} + +impl Decodable for bool { + fn decode<D: Decoder>(d: &mut D) -> Result<bool, D::Error> { + d.read_bool() + } +} + +impl Encodable for char { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_char(*self) + } +} + +impl Decodable for char { + fn decode<D: Decoder>(d: &mut D) -> Result<char, D::Error> { + d.read_char() + } +} + +impl Encodable for () { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_nil() + } +} + +impl Decodable for () { + fn decode<D: Decoder>(d: &mut D) -> Result<(), D::Error> { + d.read_nil() + } +} + +impl<'a, T: ?Sized + Encodable> Encodable for &'a T { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + (**self).encode(s) + } +} + +impl<T: ?Sized + Encodable> Encodable for Box<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + (**self).encode(s) + } +} + +impl< T: Decodable> Decodable for Box<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<Box<T>, D::Error> { + Ok(Box::new(try!(Decodable::decode(d)))) + } +} + +impl< T: Decodable> Decodable for Box<[T]> { + fn decode<D: Decoder>(d: &mut D) -> Result<Box<[T]>, D::Error> { + let v: Vec<T> = try!(Decodable::decode(d)); + Ok(v.into_boxed_slice()) + } +} + +impl<T:Encodable> Encodable for Rc<T> { + #[inline] + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + (**self).encode(s) + } +} + +impl<T:Decodable> Decodable for Rc<T> { + #[inline] + fn decode<D: Decoder>(d: &mut D) -> Result<Rc<T>, D::Error> { + Ok(Rc::new(try!(Decodable::decode(d)))) + } +} + +impl<'a, T:Encodable + ToOwned + ?Sized> Encodable for Cow<'a, T> { + #[inline] + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + (**self).encode(s) + } +} + +impl<'a, T: ?Sized> Decodable for Cow<'a, T> + where T: ToOwned, T::Owned: Decodable +{ + #[inline] + fn decode<D: Decoder>(d: &mut D) -> Result<Cow<'static, T>, D::Error> { + Ok(Cow::Owned(try!(Decodable::decode(d)))) + } +} + +impl<T:Encodable> Encodable for [T] { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_seq(self.len(), |s| { + for (i, e) in self.iter().enumerate() { + try!(s.emit_seq_elt(i, |s| e.encode(s))) + } + Ok(()) + }) + } +} + +impl<T:Encodable> Encodable for Vec<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_seq(self.len(), |s| { + for (i, e) in self.iter().enumerate() { + try!(s.emit_seq_elt(i, |s| e.encode(s))) + } + Ok(()) + }) + } +} + +impl<T:Decodable> Decodable for Vec<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<Vec<T>, D::Error> { + d.read_seq(|d, len| { + let mut v = Vec::with_capacity(len); + for i in 0..len { + v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); + } + Ok(v) + }) + } +} + +impl<T:Encodable> Encodable for Option<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_option(|s| { + match *self { + None => s.emit_option_none(), + Some(ref v) => s.emit_option_some(|s| v.encode(s)), + } + }) + } +} + +impl<T:Decodable> Decodable for Option<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<Option<T>, D::Error> { + d.read_option(|d, b| { + if b { + Ok(Some(try!(Decodable::decode(d)))) + } else { + Ok(None) + } + }) + } +} + +impl<T> Encodable for PhantomData<T> { + fn encode<S: Encoder>(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +impl<T> Decodable for PhantomData<T> { + fn decode<D: Decoder>(_d: &mut D) -> Result<PhantomData<T>, D::Error> { + Ok(PhantomData) + } +} + +macro_rules! peel { + ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* }) +} + +/// Evaluates to the number of identifiers passed to it, for example: +/// `count_idents!(a, b, c) == 3 +macro_rules! count_idents { + () => { 0 }; + ($_i:ident, $($rest:ident,)*) => { 1 + count_idents!($($rest,)*) } +} + +macro_rules! tuple { + () => (); + ( $($name:ident,)+ ) => ( + impl<$($name:Decodable),*> Decodable for ($($name,)*) { + fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)*), D::Error> { + let len: usize = count_idents!($($name,)*); + d.read_tuple(len, |d| { + let mut i = 0; + let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 }, + |d| -> Result<$name,D::Error> { + Decodable::decode(d) + })),)*); + return Ok(ret); + }) + } + } + impl<$($name:Encodable),*> Encodable for ($($name,)*) { + #[allow(non_snake_case)] + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + let ($(ref $name,)*) = *self; + let mut n = 0; + $(let $name = $name; n += 1;)* + s.emit_tuple(n, |s| { + let mut i = 0; + $(try!(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s)));)* + Ok(()) + }) + } + } + peel! { $($name,)* } + ) +} + +tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } + +macro_rules! array { + ($zero:expr) => (); + ($len:expr, $($idx:expr),*) => { + impl<T:Decodable> Decodable for [T; $len] { + fn decode<D: Decoder>(d: &mut D) -> Result<[T; $len], D::Error> { + d.read_seq(|d, len| { + if len != $len { + return Err(d.error("wrong array length")); + } + Ok([$( + try!(d.read_seq_elt($len - $idx - 1, + |d| Decodable::decode(d))) + ),+]) + }) + } + } + + impl<T:Encodable> Encodable for [T; $len] { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_seq($len, |s| { + for i in 0..$len { + try!(s.emit_seq_elt(i, |s| self[i].encode(s))); + } + Ok(()) + }) + } + } + array! { $($idx),* } + } +} + +array! { + 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 +} + +impl Encodable for path::Path { + #[cfg(unix)] + fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { + use std::os::unix::prelude::*; + self.as_os_str().as_bytes().encode(e) + } + #[cfg(windows)] + fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { + use std::os::windows::prelude::*; + let v = self.as_os_str().encode_wide().collect::<Vec<_>>(); + v.encode(e) + } +} + +impl Encodable for path::PathBuf { + fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { + (**self).encode(e) + } +} + +impl Decodable for path::PathBuf { + #[cfg(unix)] + fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> { + use std::os::unix::prelude::*; + let bytes: Vec<u8> = try!(Decodable::decode(d)); + let s: OsString = OsStringExt::from_vec(bytes); + let mut p = path::PathBuf::new(); + p.push(s); + Ok(p) + } + #[cfg(windows)] + fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> { + use std::os::windows::prelude::*; + let bytes: Vec<u16> = try!(Decodable::decode(d)); + let s: OsString = OsStringExt::from_wide(&bytes); + let mut p = path::PathBuf::new(); + p.push(s); + Ok(p) + } +} + +impl<T: Encodable + Copy> Encodable for Cell<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + self.get().encode(s) + } +} + +impl<T: Decodable + Copy> Decodable for Cell<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<Cell<T>, D::Error> { + Ok(Cell::new(try!(Decodable::decode(d)))) + } +} + +// FIXME: #15036 +// Should use `try_borrow`, returning a +// `encoder.error("attempting to Encode borrowed RefCell")` +// from `encode` when `try_borrow` returns `None`. + +impl<T: Encodable> Encodable for RefCell<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + self.borrow().encode(s) + } +} + +impl<T: Decodable> Decodable for RefCell<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<RefCell<T>, D::Error> { + Ok(RefCell::new(try!(Decodable::decode(d)))) + } +} + +impl<T:Encodable> Encodable for Arc<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + (**self).encode(s) + } +} + +impl<T:Decodable+Send+Sync> Decodable for Arc<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<Arc<T>, D::Error> { + Ok(Arc::new(try!(Decodable::decode(d)))) + } +} + +// ___________________________________________________________________________ +// Helper routines + +pub trait EncoderHelpers: Encoder { + fn emit_from_vec<T, F>(&mut self, v: &[T], f: F) + -> Result<(), <Self as Encoder>::Error> + where F: FnMut(&mut Self, &T) -> Result<(), <Self as Encoder>::Error>; +} + +impl<S:Encoder> EncoderHelpers for S { + fn emit_from_vec<T, F>(&mut self, v: &[T], mut f: F) -> Result<(), S::Error> where + F: FnMut(&mut S, &T) -> Result<(), S::Error>, + { + self.emit_seq(v.len(), |this| { + for (i, e) in v.iter().enumerate() { + try!(this.emit_seq_elt(i, |this| { + f(this, e) + })); + } + Ok(()) + }) + } +} + +pub trait DecoderHelpers: Decoder { + fn read_to_vec<T, F>(&mut self, f: F) + -> Result<Vec<T>, <Self as Decoder>::Error> where + F: FnMut(&mut Self) -> Result<T, <Self as Decoder>::Error>; +} + +impl<D: Decoder> DecoderHelpers for D { + fn read_to_vec<T, F>(&mut self, mut f: F) -> Result<Vec<T>, D::Error> where F: + FnMut(&mut D) -> Result<T, D::Error>, + { + self.read_seq(|this, len| { + let mut v = Vec::with_capacity(len); + for i in 0..len { + v.push(try!(this.read_seq_elt(i, |this| f(this)))); + } + Ok(v) + }) + } +} diff --git a/deps/semver-0.1.19/.gitignore b/deps/semver-0.1.19/.gitignore new file mode 100644 index 000000000..cc3b58977 --- /dev/null +++ b/deps/semver-0.1.19/.gitignore @@ -0,0 +1,3 @@ +target/ +*.sw? +Cargo.lock diff --git a/deps/semver-0.1.19/.travis.yml b/deps/semver-0.1.19/.travis.yml new file mode 100644 index 000000000..9758314f7 --- /dev/null +++ b/deps/semver-0.1.19/.travis.yml @@ -0,0 +1,20 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '<meta http-equiv=refresh content=0;url=semver/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +language: rust +env: + global: + secure: fFDquImTSjxHvuQw3QEZbOVfFMrtg9Ek0t7baAAVW29wf74IIrppBrUX8SPrWb4cuD5mI1gC7AZnaeq2FDAJ0EKKax/XrAtDL2Q42tnoIWpDJxOUBJ+js2v2l+hMpUBlX42vBcFJcOS56w8Nm7ru4bThP1ZL7BogoiBmi1Q7HYs= +notifications: + email: + on_success: never diff --git a/deps/semver-0.1.19/Cargo.toml b/deps/semver-0.1.19/Cargo.toml new file mode 100644 index 000000000..1dc7212eb --- /dev/null +++ b/deps/semver-0.1.19/Cargo.toml @@ -0,0 +1,12 @@ +[package] + +name = "semver" +version = "0.1.19" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang/semver" +homepage = "https://github.com/rust-lang/semver" +documentation = "http://doc.rust-lang.org/semver" +description = """ +Semantic version parsing and comparison. +""" diff --git a/deps/semver-0.1.19/LICENSE-APACHE b/deps/semver-0.1.19/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/semver-0.1.19/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/semver-0.1.19/LICENSE-MIT b/deps/semver-0.1.19/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/semver-0.1.19/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/semver-0.1.19/README.md b/deps/semver-0.1.19/README.md new file mode 100644 index 000000000..8724625ec --- /dev/null +++ b/deps/semver-0.1.19/README.md @@ -0,0 +1,104 @@ +semver +====== + +Semantic version parsing and comparison. + +[![Build Status](https://travis-ci.org/rust-lang/semver.svg?branch=master)](https://travis-ci.org/rust-lang/semver) + +[Documentation](http://doc.rust-lang.org/semver) + +Semantic versioning (see http://semver.org/) is a set of rules for +assigning version numbers. + +## SemVer and the Rust ecosystem + +Rust itself follows the SemVer specification, as does its standard libraries. The two are +not tied together. + +[Cargo](http://crates.io), Rust's package manager, uses SemVer to determine which versions of +packages you need installed. + +## Installation + +To use `semver`, add these lines to your `Cargo.toml`: + +```toml +[dependencies] +semver = "*" +``` + +And this to your crate root: + +```rust +extern crate semver; +``` + +## Versions + +At its simplest, the `semver` crate allows you to construct `Version` objects using the `parse` +method: + +```{rust} +use semver::Version; + +assert!(Version::parse("1.2.3") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(), +})); +``` + +If you have multiple `Version`s, you can use the usual comparison operators to compare them: + +```{rust} +use semver::Version; + +assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); +assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); +``` + +## Requirements + +The `semver` crate also provides the ability to compare requirements, which are more complex +comparisons. + +For example, creating a requirement that only matches versions greater than or +equal to 1.0.0: + +```{rust} +use semver::Version; +use semver::VersionReq; + +let r = VersionReq::parse(">= 1.0.0").unwrap(); +let v = Version::parse("1.0.0").unwrap(); + +assert!(r.to_string() == ">= 1.0.0".to_string()); +assert!(r.matches(&v)) +``` + +It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at +https://www.npmjs.org/doc/misc/semver.html + +**Tilde requirements** specify a minimal version with some updates: + +```notrust +~1.2.3 := >=1.2.3 <1.3.0 +~1.2 := >=1.2.0 <1.3.0 +~1 := >=1.0.0 <2.0.0 +``` + +**Caret requirements** allow SemVer compatible updates to a specified version, +`0.x` and `0.x+1` are not considered compatible, but `1.x` and `1.x+1` are. + +`0.0.x` is not considered compatible with any other version. +Missing minor and patch versions are desugared to `0` but allow flexibility for that value. + +```notrust +^1.2.3 := >=1.2.3 <2.0.0 +^0.2.3 := >=0.2.3 <0.3.0 +^0.0.3 := >=0.0.3 <0.0.4 +^0.0 := >=0.0.0 <0.1.0 +^0 := >=0.0.0 <1.0.0 +``` diff --git a/deps/semver-0.1.19/src/lib.rs b/deps/semver-0.1.19/src/lib.rs new file mode 100644 index 000000000..5fe146090 --- /dev/null +++ b/deps/semver-0.1.19/src/lib.rs @@ -0,0 +1,138 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Semantic version parsing and comparison. +//! +//! Semantic versioning (see http://semver.org/) is a set of rules for +//! assigning version numbers. +//! +//! ## SemVer overview +//! +//! Given a version number MAJOR.MINOR.PATCH, increment the: +//! +//! 1. MAJOR version when you make incompatible API changes, +//! 2. MINOR version when you add functionality in a backwards-compatible +//! manner, and +//! 3. PATCH version when you make backwards-compatible bug fixes. +//! +//! Additional labels for pre-release and build metadata are available as +//! extensions to the MAJOR.MINOR.PATCH format. +//! +//! Any references to 'the spec' in this documentation refer to [version 2.0 of +//! the SemVer spec](http://semver.org/spec/v2.0.0.html). +//! +//! ## SemVer and the Rust ecosystem +//! +//! Rust itself follows the SemVer specification, as does its standard +//! libraries. The two are not tied together. +//! +//! [Cargo](http://crates.io), Rust's package manager, uses SemVer to determine +//! which versions of packages you need installed. +//! +//! ## Versions +//! +//! At its simplest, the `semver` crate allows you to construct `Version` +//! objects using the `parse` method: +//! +//! ```{rust} +//! use semver::Version; +//! +//! assert!(Version::parse("1.2.3") == Ok(Version { +//! major: 1, +//! minor: 2, +//! patch: 3, +//! pre: vec!(), +//! build: vec!(), +//! })); +//! ``` +//! +//! If you have multiple `Version`s, you can use the usual comparison operators +//! to compare them: +//! +//! ```{rust} +//! use semver::Version; +//! +//! assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); +//! assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); +//! ``` +//! +//! ## Requirements +//! +//! The `semver` crate also provides the ability to compare requirements, which +//! are more complex comparisons. +//! +//! For example, creating a requirement that only matches versions greater than +//! or equal to 1.0.0: +//! +//! ```{rust} +//! # #![allow(unstable)] +//! use semver::Version; +//! use semver::VersionReq; +//! +//! let r = VersionReq::parse(">= 1.0.0").unwrap(); +//! let v = Version::parse("1.0.0").unwrap(); +//! +//! assert!(r.to_string() == ">= 1.0.0".to_string()); +//! assert!(r.matches(&v)) +//! ``` +//! +//! It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at +//! https://www.npmjs.org/doc/misc/semver.html +//! +//! **Tilde requirements** specify a minimal version with some updates: +//! +//! ```notrust +//! ~1.2.3 := >=1.2.3 <1.3.0 +//! ~1.2 := >=1.2.0 <1.3.0 +//! ~1 := >=1.0.0 <2.0.0 +//! ``` +//! +//! **Caret requirements** allow SemVer compatible updates to a specified +//! verion, `0.x` and `0.x+1` are not considered compatible, but `1.x` and +//! `1.x+1` are. +//! +//! `0.0.x` is not considered compatible with any other version. +//! Missing minor and patch versions are desugared to `0` but allow flexibility +//! for that value. +//! +//! ```notrust +//! ^1.2.3 := >=1.2.3 <2.0.0 +//! ^0.2.3 := >=0.2.3 <0.3.0 +//! ^0.0.3 := >=0.0.3 <0.0.4 +//! ^0.0 := >=0.0.0 <0.1.0 +//! ^0 := >=0.0.0 <1.0.0 +//! ``` +//! +//! **Wildcard requirements** allows parsing of version requirements of the +//! formats `*`, `x.*` and `x.y.*`. +//! +//! ```notrust +//! * := >=0.0.0 +//! 1.* := >=1.0.0 <2.0.0 +//! 1.2.* := >=1.2.0 <1.3.0 +//! ``` + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico")] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] + +// We take the common approach of keeping our own module system private, and +// just re-exporting the interface that we want. + +pub use version::{Version, Identifier, ParseError}; +pub use version::Identifier::{Numeric, AlphaNumeric}; +pub use version_req::{VersionReq, ReqParseError}; + +// SemVer-compliant versions. +mod version; + +// advanced version comparisons +mod version_req; diff --git a/deps/semver-0.1.19/src/version.rs b/deps/semver-0.1.19/src/version.rs new file mode 100644 index 000000000..090c5ae77 --- /dev/null +++ b/deps/semver-0.1.19/src/version.rs @@ -0,0 +1,491 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `version` module gives you tools to create and compare SemVer-compliant versions. + +use std::ascii::AsciiExt; +use std::cmp::{self, Ordering}; +use std::fmt; +use std::hash; + +use self::Identifier::{Numeric, AlphaNumeric}; +use self::ParseError::{GenericFailure, IncorrectParse, NonAsciiIdentifier}; + +/// An identifier in the pre-release or build metadata. +/// +/// See sections 9 and 10 of the spec for more about pre-release identifers and build metadata. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +pub enum Identifier { + /// An identifier that's solely numbers. + Numeric(u64), + /// An identifier with letters and numbers. + AlphaNumeric(String) +} + +impl fmt::Display for Identifier { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Numeric(ref n) => fmt::Display::fmt(n, f), + AlphaNumeric(ref s) => fmt::Display::fmt(s, f), + } + } +} + + +/// Represents a version number conforming to the semantic versioning scheme. +#[derive(Clone, Eq, Debug)] +pub struct Version { + /// The major version, to be incremented on incompatible changes. + pub major: u64, + /// The minor version, to be incremented when functionality is added in a + /// backwards-compatible manner. + pub minor: u64, + /// The patch version, to be incremented when backwards-compatible bug + /// fixes are made. + pub patch: u64, + /// The pre-release version identifier, if one exists. + pub pre: Vec<Identifier>, + /// The build metadata, ignored when determining version precedence. + pub build: Vec<Identifier>, +} + +/// A `ParseError` is returned as the `Err` side of a `Result` when a version is attempted +/// to be parsed. +#[derive(Clone,PartialEq,Debug,PartialOrd)] +pub enum ParseError { + /// All identifiers must be ASCII. + NonAsciiIdentifier, + /// The version was mis-parsed. + IncorrectParse(Version, String), + /// Any other failure. + GenericFailure, +} + +impl Version { + /// Parse a string into a semver object. + pub fn parse(s: &str) -> Result<Version, ParseError> { + if !s.is_ascii() { + return Err(NonAsciiIdentifier) + } + let s = s.trim(); + let v = parse_iter(&mut s.chars()); + match v { + Some(v) => { + if v.to_string() == s { + Ok(v) + } else { + Err(IncorrectParse(v, s.to_string())) + } + } + None => Err(GenericFailure) + } + } +} + + +impl fmt::Display for Version { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch)); + if !self.pre.is_empty() { + try!(write!(f, "-")); + for (i, x) in self.pre.iter().enumerate() { + if i != 0 { try!(write!(f, ".")) }; + try!(write!(f, "{}", x)); + } + } + if !self.build.is_empty() { + try!(write!(f, "+")); + for (i, x) in self.build.iter().enumerate() { + if i != 0 { try!(write!(f, ".")) }; + try!(write!(f, "{}", x)); + } + } + Ok(()) + } +} + +impl cmp::PartialEq for Version { + #[inline] + fn eq(&self, other: &Version) -> bool { + // We should ignore build metadata here, otherwise versions v1 and v2 + // can exist such that !(v1 < v2) && !(v1 > v2) && v1 != v2, which + // violate strict total ordering rules. + self.major == other.major && + self.minor == other.minor && + self.patch == other.patch && + self.pre == other.pre + } +} + +impl cmp::PartialOrd for Version { + fn partial_cmp(&self, other: &Version) -> Option<Ordering> { + Some(self.cmp(other)) + } +} + +impl cmp::Ord for Version { + fn cmp(&self, other: &Version) -> Ordering { + match self.major.cmp(&other.major) { + Ordering::Equal => {} + r => return r, + } + + match self.minor.cmp(&other.minor) { + Ordering::Equal => {} + r => return r, + } + + match self.patch.cmp(&other.patch) { + Ordering::Equal => {} + r => return r, + } + + // NB: semver spec says 0.0.0-pre < 0.0.0 + // but the version of ord defined for vec + // says that [] < [pre] so we alter it here + match (self.pre.len(), other.pre.len()) { + (0, 0) => Ordering::Equal, + (0, _) => Ordering::Greater, + (_, 0) => Ordering::Less, + (_, _) => self.pre.cmp(&other.pre) + } + } +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + ParseError::NonAsciiIdentifier => { + write!(f, "identifiers can only contain ascii characters") + } + ParseError::GenericFailure => { + write!(f, "failed to parse semver from string") + } + ParseError::IncorrectParse(ref a, ref b) => { + write!(f, "semver `{}` was not correctly parsed from {:?}", a, b) + } + } + } +} + +impl hash::Hash for Version { + fn hash<H: hash::Hasher>(&self, into: &mut H) { + self.major.hash(into); + self.minor.hash(into); + self.patch.hash(into); + self.pre.hash(into); + } +} + +fn take_nonempty_prefix<T, F>(rdr: &mut T, pred: F) -> (String, Option<char>) where + T: Iterator<Item = char>, + F: Fn(char) -> bool +{ + let mut buf = String::new(); + let mut ch = rdr.next(); + loop { + match ch { + None => break, + Some(c) if !pred(c) => break, + Some(c) => { + buf.push(c); + ch = rdr.next(); + } + } + } + (buf, ch) +} + +fn take_num<T: Iterator<Item=char>>(rdr: &mut T) -> Option<(u64, Option<char>)> { + let (s, ch) = take_nonempty_prefix(rdr, |c| c.is_digit(10)); + match s.parse::<u64>().ok() { + None => None, + Some(i) => Some((i, ch)) + } +} + +fn take_ident<T: Iterator<Item=char>>(rdr: &mut T) -> Option<(Identifier, Option<char>)> { + let (s,ch) = take_nonempty_prefix(rdr, |c| c.is_alphanumeric()); + + if s.len() == 0 { + None + } else if s.chars().all(|c| c.is_digit(10)) && s.chars().next() != Some('0') { + match s.parse::<u64>().ok() { + None => None, + Some(i) => Some((Numeric(i), ch)) + } + } else { + Some((AlphaNumeric(s), ch)) + } +} + +fn expect(ch: Option<char>, c: char) -> Option<()> { + if ch != Some(c) { + None + } else { + Some(()) + } +} + +fn parse_iter<T: Iterator<Item=char>>(rdr: &mut T) -> Option<Version> { + let maybe_vers = take_num(rdr).and_then(|(major, ch)| { + expect(ch, '.').and_then(|_| Some(major)) + }).and_then(|major| { + take_num(rdr).and_then(|(minor, ch)| { + expect(ch, '.').and_then(|_| Some((major, minor))) + }) + }).and_then(|(major, minor)| { + take_num(rdr).and_then(|(patch, ch)| { + Some((major, minor, patch, ch)) + }) + }); + + let (major, minor, patch, ch) = match maybe_vers { + Some((a, b, c, d)) => (a, b, c, d), + None => return None + }; + + let mut pre = vec!(); + let mut build = vec!(); + + let mut ch = ch; + if ch == Some('-') { + loop { + let (id, c) = match take_ident(rdr) { + Some((id, c)) => (id, c), + None => return None + }; + pre.push(id); + ch = c; + if ch != Some('.') { break; } + } + } + + if ch == Some('+') { + loop { + let (id, c) = match take_ident(rdr) { + Some((id, c)) => (id, c), + None => return None + }; + build.push(id); + ch = c; + if ch != Some('.') { break; } + } + } + + Some(Version { + major: major, + minor: minor, + patch: patch, + pre: pre, + build: build, + }) +} + +#[cfg(test)] +mod test { + use super::{Version}; + use super::ParseError::{IncorrectParse, GenericFailure}; + use super::Identifier::{AlphaNumeric, Numeric}; + + #[test] + fn test_parse() { + assert_eq!(Version::parse(""), Err(GenericFailure)); + assert_eq!(Version::parse(" "), Err(GenericFailure)); + assert_eq!(Version::parse("1"), Err(GenericFailure)); + assert_eq!(Version::parse("1.2"), Err(GenericFailure)); + assert_eq!(Version::parse("1.2.3-"), Err(GenericFailure)); + assert_eq!(Version::parse("a.b.c"), Err(GenericFailure)); + + let version = Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(), + }; + let error = Err(IncorrectParse(version, "1.2.3 abc".to_string())); + assert_eq!(Version::parse("1.2.3 abc"), error); + + assert!(Version::parse("1.2.3") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(), + })); + assert!(Version::parse(" 1.2.3 ") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(), + })); + assert!(Version::parse("1.2.3-alpha1") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(AlphaNumeric("alpha1".to_string())), + build: vec!(), + })); + assert!(Version::parse(" 1.2.3-alpha1 ") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(AlphaNumeric("alpha1".to_string())), + build: vec!() + })); + assert!(Version::parse("1.2.3+build5") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(AlphaNumeric("build5".to_string())) + })); + assert!(Version::parse(" 1.2.3+build5 ") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(AlphaNumeric("build5".to_string())) + })); + assert!(Version::parse("1.2.3-alpha1+build5") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(AlphaNumeric("alpha1".to_string())), + build: vec!(AlphaNumeric("build5".to_string())) + })); + assert!(Version::parse(" 1.2.3-alpha1+build5 ") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(AlphaNumeric("alpha1".to_string())), + build: vec!(AlphaNumeric("build5".to_string())) + })); + assert!(Version::parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(Numeric(1),AlphaNumeric("alpha1".to_string()),Numeric(9)), + build: vec!(AlphaNumeric("build5".to_string()), + Numeric(7), + AlphaNumeric("3aedf".to_string())) + })); + assert_eq!(Version::parse("0.4.0-beta.1+0851523"), Ok(Version { + major: 0, + minor: 4, + patch: 0, + pre: vec![AlphaNumeric("beta".to_string()), Numeric(1)], + build: vec![AlphaNumeric("0851523".to_string())], + })); + + } + + #[test] + fn test_eq() { + assert_eq!(Version::parse("1.2.3"), Version::parse("1.2.3")); + assert_eq!(Version::parse("1.2.3-alpha1"), Version::parse("1.2.3-alpha1")); + assert_eq!(Version::parse("1.2.3+build.42"), Version::parse("1.2.3+build.42")); + assert_eq!(Version::parse("1.2.3-alpha1+42"), Version::parse("1.2.3-alpha1+42")); + assert_eq!(Version::parse("1.2.3+23"), Version::parse("1.2.3+42")); + } + + #[test] + fn test_ne() { + assert!(Version::parse("0.0.0") != Version::parse("0.0.1")); + assert!(Version::parse("0.0.0") != Version::parse("0.1.0")); + assert!(Version::parse("0.0.0") != Version::parse("1.0.0")); + assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); + } + + #[test] + fn test_show() { + assert_eq!(format!("{}", Version::parse("1.2.3").unwrap()), + "1.2.3".to_string()); + assert_eq!(format!("{}", Version::parse("1.2.3-alpha1").unwrap()), + "1.2.3-alpha1".to_string()); + assert_eq!(format!("{}", Version::parse("1.2.3+build.42").unwrap()), + "1.2.3+build.42".to_string()); + assert_eq!(format!("{}", Version::parse("1.2.3-alpha1+42").unwrap()), + "1.2.3-alpha1+42".to_string()); + } + + #[test] + fn test_to_string() { + assert_eq!(Version::parse("1.2.3").unwrap().to_string(), "1.2.3".to_string()); + assert_eq!(Version::parse("1.2.3-alpha1").unwrap().to_string(), "1.2.3-alpha1".to_string()); + assert_eq!(Version::parse("1.2.3+build.42").unwrap().to_string(), "1.2.3+build.42".to_string()); + assert_eq!(Version::parse("1.2.3-alpha1+42").unwrap().to_string(), "1.2.3-alpha1+42".to_string()); + } + + #[test] + fn test_lt() { + assert!(Version::parse("0.0.0") < Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.0.0") < Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.0") < Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3")); + assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3-alpha2")); + assert!(!(Version::parse("1.2.3-alpha2") < Version::parse("1.2.3-alpha2"))); + assert!(!(Version::parse("1.2.3+23") < Version::parse("1.2.3+42"))); + } + + #[test] + fn test_le() { + assert!(Version::parse("0.0.0") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.0.0") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.0") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3-alpha1") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3-alpha2") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3+23") <= Version::parse("1.2.3+42")); + } + + #[test] + fn test_gt() { + assert!(Version::parse("1.2.3-alpha2") > Version::parse("0.0.0")); + assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.0.0")); + assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); + assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha1")); + assert!(Version::parse("1.2.3") > Version::parse("1.2.3-alpha2")); + assert!(!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha2"))); + assert!(!(Version::parse("1.2.3+23") > Version::parse("1.2.3+42"))); + } + + #[test] + fn test_ge() { + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("0.0.0")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.0.0")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.0")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha1")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3+23") >= Version::parse("1.2.3+42")); + } + + #[test] + fn test_spec_order() { + let vs = ["1.0.0-alpha", + "1.0.0-alpha.1", + "1.0.0-alpha.beta", + "1.0.0-beta", + "1.0.0-beta.2", + "1.0.0-beta.11", + "1.0.0-rc.1", + "1.0.0"]; + let mut i = 1; + while i < vs.len() { + let a = Version::parse(vs[i-1]).unwrap(); + let b = Version::parse(vs[i]).unwrap(); + assert!(a < b); + i += 1; + } + } +} diff --git a/deps/semver-0.1.19/src/version_req.rs b/deps/semver-0.1.19/src/version_req.rs new file mode 100644 index 000000000..02311289c --- /dev/null +++ b/deps/semver-0.1.19/src/version_req.rs @@ -0,0 +1,877 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::error::Error; +use std::fmt; +use std::str::CharIndices; + +use super::version::Version; + +use self::VersionComponent::{NumericVersionComponent, WildcardVersionComponent}; +use self::Op::{Ex, Gt, GtEq, Lt, LtEq, Tilde, Compatible, Wildcard}; +use self::LexState::{LexInit, LexStart, LexVersionComponent, LexSigil, LexErr}; +use self::Token::{Sigil, AlphaNum, Comma, Dot}; +use self::WildcardVersion::{Major, Minor, Patch}; +use self::ReqParseError::{ + InvalidVersionRequirement, + OpAlreadySet, + InvalidSigil, + VersionComponentsMustBeNumeric, + MajorVersionRequired, + UnimplementedVersionRequirement +}; + +/// A `VersionReq` is a struct containing a list of predicates that can apply to ranges of version +/// numbers. Matching operations can then be done with the `VersionReq` against a particular +/// version to see if it satisfies some or all of the constraints. +#[derive(PartialEq,Clone,Debug)] +pub struct VersionReq { + predicates: Vec<Predicate> +} + +enum VersionComponent { + NumericVersionComponent(u64), + WildcardVersionComponent +} + +#[derive(Clone, PartialEq, Debug)] +enum WildcardVersion { + Major, + Minor, + Patch +} + +#[derive(PartialEq,Clone,Debug)] +enum Op { + Ex, // Exact + Gt, // Greater than + GtEq, // Greater than or equal to + Lt, // Less than + LtEq, // Less than or equal to + Tilde, // e.g. ~1.0.0 + Compatible, // compatible by definition of semver, indicated by ^ + Wildcard(WildcardVersion), // x.y.*, x.*, * +} + +#[derive(PartialEq,Clone,Debug)] +struct Predicate { + op: Op, + major: u64, + minor: Option<u64>, + patch: Option<u64> +} + +struct PredBuilder { + op: Option<Op>, + major: Option<u64>, + minor: Option<u64>, + patch: Option<u64> +} + +/// A `ReqParseError` is returned from methods which parse a string into a `VersionReq`. Each +/// enumeration is one of the possible errors that can occur. +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum ReqParseError { + /// The given version requirement is invalid. + InvalidVersionRequirement, + /// You have already provided an operation, such as `=`, `~`, or `^`. Only use one. + OpAlreadySet, + /// The sigil you have written is not correct. + InvalidSigil, + /// All components of a version must be numeric. + VersionComponentsMustBeNumeric, + /// At least a major version is required. + MajorVersionRequired, + /// An unimplemented version requirement. + UnimplementedVersionRequirement, +} + +impl fmt::Display for ReqParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.description().fmt(f) + } +} + +impl Error for ReqParseError { + fn description(&self) -> &str { + match *self { + InvalidVersionRequirement => "the given version requirement is invalid", + OpAlreadySet => "you have already provided an operation, such as =, ~, or ^; only use one", + InvalidSigil => "the sigil you have written is not correct", + VersionComponentsMustBeNumeric => "version components must be numeric", + MajorVersionRequired => "at least a major version number is required", + UnimplementedVersionRequirement => "the given version requirement is not implemented, yet", + } + } +} + +impl VersionReq { + /// `any()` is a factory method which creates a `VersionReq` with no constraints. In other + /// words, any version will match against it. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// + /// let anything = VersionReq::any(); + /// ``` + pub fn any() -> VersionReq { + VersionReq { predicates: vec!() } + } + + /// `parse()` is the main constructor of a `VersionReq`. It turns a string like `"^1.2.3"` + /// and turns it into a `VersionReq` that matches that particular constraint. + /// + /// A `Result` is returned which contains a `ReqParseError` if there was a problem parsing the + /// `VersionReq`. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// + /// let version = VersionReq::parse("=1.2.3"); + /// let version = VersionReq::parse(">1.2.3"); + /// let version = VersionReq::parse("<1.2.3"); + /// let version = VersionReq::parse("~1.2.3"); + /// let version = VersionReq::parse("^1.2.3"); + /// let version = VersionReq::parse("<=1.2.3"); + /// let version = VersionReq::parse(">=1.2.3"); + /// ``` + /// + /// This example demonstrates error handling, and will panic. + /// + /// ```should-panic + /// use semver::VersionReq; + /// + /// let version = match VersionReq::parse("not a version") { + /// Ok(version) => version, + /// Err(e) => panic!("There was a problem parsing: {}", e), + /// } + /// ``` + pub fn parse(input: &str) -> Result<VersionReq, ReqParseError> { + let mut lexer = Lexer::new(input); + let mut builder = PredBuilder::new(); + let mut predicates = Vec::new(); + + for token in lexer.by_ref() { + let result = match token { + Sigil(x) => builder.set_sigil(x), + AlphaNum(x) => builder.set_version_part(x), + Dot => Ok(()), // Nothing to do for now + Comma => { + let result = builder.build().map(|p| predicates.push(p)); + builder = PredBuilder::new(); + result + } + }; + + match result { + Ok(_) => (), + Err(e) => return Err(e), + } + } + + if lexer.is_error() { + return Err(InvalidVersionRequirement); + } + + match builder.build() { + Ok(e) => predicates.push(e), + Err(e) => return Err(e), + } + + Ok(VersionReq { predicates: predicates }) + } + + /// `exact()` is a factory method which creates a `VersionReq` with one exact constraint. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// use semver::Version; + /// + /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; + /// let exact = VersionReq::exact(&version); + /// ``` + pub fn exact(version: &Version) -> VersionReq { + VersionReq { predicates: vec!(Predicate::exact(version)) } + } + + /// `matches()` matches a given `Version` against this `VersionReq`. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// use semver::Version; + /// + /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; + /// let exact = VersionReq::exact(&version); + /// + /// assert!(exact.matches(&version)); + /// ``` + pub fn matches(&self, version: &Version) -> bool { + self.predicates.iter().all(|p| p.matches(version)) + } +} + +impl Predicate { + fn exact(version: &Version) -> Predicate { + Predicate { + op: Ex, + major: version.major, + minor: Some(version.minor), + patch: Some(version.patch) + } + } + + /// `matches()` takes a `Version` and determines if it matches this particular `Predicate`. + pub fn matches(&self, ver: &Version) -> bool { + match self.op { + Ex => self.is_exact(ver), + Gt => self.is_greater(ver), + GtEq => self.is_exact(ver) || self.is_greater(ver), + Lt => !self.is_exact(ver) && !self.is_greater(ver), + LtEq => !self.is_greater(ver), + Tilde => self.matches_tilde(ver), + Compatible => self.is_compatible(ver), + Wildcard(_) => self.matches_wildcard(ver) + } + } + + fn is_exact(&self, ver: &Version) -> bool { + if self.major != ver.major { + return false; + } + + match self.minor { + Some(minor) => { + if minor != ver.minor { + return false; + } + } + None => return true + } + + match self.patch { + Some(patch) => { + if patch != ver.patch { + return false; + } + } + None => return true + } + + true + } + + fn is_greater(&self, ver: &Version) -> bool { + if self.major != ver.major { + return ver.major > self.major; + } + + match self.minor { + Some(minor) => { + if minor != ver.minor { + return ver.minor > minor + } + } + None => return false + } + + match self.patch { + Some(patch) => { + if patch != ver.patch { + return ver.patch > patch + } + } + None => return false + } + + false + } + + // see https://www.npmjs.org/doc/misc/semver.html for behavior + fn matches_tilde(&self, ver: &Version) -> bool { + let minor = match self.minor { + Some(n) => n, + None => return self.major == ver.major + }; + + match self.patch { + Some(patch) => { + self.major == ver.major && minor == ver.minor && ver.patch >= patch + } + None => { + self.major == ver.major && minor == ver.minor + } + } + } + + // see https://www.npmjs.org/doc/misc/semver.html for behavior + fn is_compatible(&self, ver: &Version) -> bool { + if self.major != ver.major { + return false; + } + + let minor = match self.minor { + Some(n) => n, + None => return self.major == ver.major + }; + + match self.patch { + Some(patch) => if self.major == 0 { + if minor == 0 { + ver.minor == minor && ver.patch == patch + } else { + ver.minor == minor && ver.patch >= patch + } + } else { + ver.minor > minor || (ver.minor == minor && ver.patch >= patch) + }, + None => if self.major == 0 { + ver.minor == minor + } else { + ver.minor >= minor + } + } + } + + // see https://www.npmjs.org/doc/misc/semver.html for behavior + fn matches_wildcard(&self, ver: &Version) -> bool { + match self.op { + Wildcard(Major) => true, + Wildcard(Minor) => self.major == ver.major, + Wildcard(Patch) => { + match self.minor { + Some(minor) => self.major == ver.major && minor == ver.minor, + None => false // unreachable + } + } + _ => false // unreachable + } + } +} + +impl PredBuilder { + fn new() -> PredBuilder { + PredBuilder { + op: None, + major: None, + minor: None, + patch: None + } + } + + fn set_sigil(&mut self, sigil: &str) -> Result<(), ReqParseError> { + if self.op.is_some() { + return Err(OpAlreadySet); + } + + match Op::from_sigil(sigil) { + Some(op) => self.op = Some(op), + _ => return Err(InvalidSigil), + } + + Ok(()) + } + + fn set_version_part(&mut self, part: &str) -> Result<(), ReqParseError> { + if self.op.is_none() { + // If no op is specified, then the predicate is an exact match on + // the version + self.op = Some(Compatible); + } + + if self.major.is_none() { + match parse_version_part(part) { + Ok(NumericVersionComponent(e)) => self.major = Some(e), + Ok(WildcardVersionComponent) => { + self.major = Some(0); + self.op = Some(Wildcard(Major)) + } + Err(e) => return Err(e), + } + } else if self.minor.is_none() { + match parse_version_part(part) { + Ok(NumericVersionComponent(e)) => self.minor = Some(e), + Ok(WildcardVersionComponent) => self.op = Some(Wildcard(Minor)), + Err(e) => return Err(e), + } + } + else if self.patch.is_none() { + match parse_version_part(part) { + Ok(NumericVersionComponent(e)) => self.patch = Some(e), + Ok(WildcardVersionComponent) => self.op = Some(Wildcard(Patch)), + Err(e) => return Err(e), + } + } + + Ok(()) + } + + /// Validates that a version predicate can be created given the present + /// information. + fn build(&self) -> Result<Predicate, ReqParseError> { + let op = match self.op { + Some(ref x) => x.clone(), + None => return Err(InvalidVersionRequirement), + }; + + let major = match self.major { + Some(x) => x, + None => return Err(MajorVersionRequired), + }; + + Ok(Predicate { + op: op, + major: major, + minor: self.minor, + patch: self.patch + }) + } +} + +struct Lexer<'a> { + c: char, + idx: usize, + iter: CharIndices<'a>, + mark: Option<usize>, + input: &'a str, + state: LexState +} + +#[derive(Copy, Clone, Debug, PartialEq)] +enum LexState { + LexInit, + LexStart, + LexVersionComponent, + LexSigil, + LexErr, +} + +#[derive(Debug)] +enum Token<'a> { + Sigil(&'a str), + AlphaNum(&'a str), + Comma, + Dot +} + +impl<'a> Lexer<'a> { + fn new(input: &'a str) -> Lexer<'a> { + Lexer { + c: '\0', + idx: 0, + iter: input.char_indices(), + mark: None, + input: input, + state: LexInit + } + } + + fn is_error(&self) -> bool { + self.state == LexErr + } + + fn mark(&mut self, at: usize) { + self.mark = Some(at) + } + + fn flush(&mut self, to: usize, kind: LexState) -> Option<Token<'a>> { + match self.mark { + Some(mark) => { + if to <= mark { + return None; + } + + let s = &self.input[mark..to]; + + self.mark = None; + + match kind { + LexVersionComponent => Some(AlphaNum(s)), + LexSigil => Some(Sigil(s)), + _ => None // bug + } + } + None => None + } + } +} + +impl<'a> Iterator for Lexer<'a> { + type Item = Token<'a>; + + fn next(&mut self) -> Option<Token<'a>> { + let mut c; + let mut idx = 0; + + macro_rules! next { + () => ( + match self.iter.next() { + Some((n_idx, n_char)) => { + c = n_char; + idx = n_idx; + } + _ => { + let s = self.state; + return self.flush(idx + 1, s) + } + } + ) + } + + macro_rules! flush { + ($s:expr) => ({ + self.c = c; + self.idx = idx; + self.flush(idx, $s) + }) + } + + + if self.state == LexInit { + self.state = LexStart; + next!(); + } else { + c = self.c; + idx = self.idx; + } + + loop { + match self.state { + LexStart => { + if c.is_whitespace() { + next!(); // Ignore + } + else if c.is_alphanumeric() || c == '*' { + self.mark(idx); + self.state = LexVersionComponent; + next!(); + } + else if is_sigil(c) { + self.mark(idx); + self.state = LexSigil; + next!(); + } + else if c == '.' { + self.state = LexInit; + return Some(Dot); + } + else if c == ',' { + self.state = LexInit; + return Some(Comma); + } else { + self.state = LexErr; + return None; + } + } + LexVersionComponent => { + if c.is_alphanumeric() { + next!(); + } else { + self.state = LexStart; + return flush!(LexVersionComponent); + } + } + LexSigil => { + if is_sigil(c) { + next!(); + } else { + self.state = LexStart; + return flush!(LexSigil); + } + } + LexErr => return None, + LexInit => return None // bug + } + } + } +} + +impl Op { + fn from_sigil(sigil: &str) -> Option<Op> { + match sigil { + "=" => Some(Ex), + ">" => Some(Gt), + ">=" => Some(GtEq), + "<" => Some(Lt), + "<=" => Some(LtEq), + "~" => Some(Tilde), + "^" => Some(Compatible), + _ => None + } + } +} + +fn parse_version_part(s: &str) -> Result<VersionComponent, ReqParseError> { + let mut ret = 0; + + if s == "*" { + return Ok(WildcardVersionComponent) + } + + for c in s.chars() { + let n = (c as u64) - ('0' as u64); + + if n > 9 { + return Err(VersionComponentsMustBeNumeric); + } + + ret *= 10; + ret += n; + } + + Ok(NumericVersionComponent(ret)) +} + +fn is_sigil(c: char) -> bool { + match c { + '>' | '<' | '=' | '~' | '^' => true, + _ => false + } +} + +impl fmt::Display for VersionReq { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + if self.predicates.is_empty() { + try!(write!(fmt, "*")); + } else { + for (i, ref pred) in self.predicates.iter().enumerate() { + if i == 0 { + try!(write!(fmt, "{}", pred)); + } else { + try!(write!(fmt, ", {}", pred)); + } + } + } + + Ok(()) + } +} + +impl fmt::Display for Predicate { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.op { + Wildcard(Major) => try!(write!(fmt, "*")), + Wildcard(Minor) => try!(write!(fmt, "{}.*", self.major)), + Wildcard(Patch) => try!(write!(fmt, "{}.{}.*", self.major, self.minor.unwrap())), + _ => { + try!(write!(fmt, "{}{}", self.op, self.major)); + + match self.minor { + Some(v) => try!(write!(fmt, ".{}", v)), + None => () + } + + match self.patch { + Some(v) => try!(write!(fmt, ".{}", v)), + None => () + } + }, + } + + Ok(()) + } +} + +impl fmt::Display for Op { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Ex => try!(write!(fmt, "= ")), + Gt => try!(write!(fmt, "> ")), + GtEq => try!(write!(fmt, ">= ")), + Lt => try!(write!(fmt, "< ")), + LtEq => try!(write!(fmt, "<= ")), + Tilde => try!(write!(fmt, "~")), + Compatible => try!(write!(fmt, "^")), + // gets handled specially in Predicate::fmt + Wildcard(_) => try!(write!(fmt, "")), + } + Ok(()) + } +} + +#[cfg(test)] +mod test { + use super::VersionReq; + use super::super::version::Version; + use super::ReqParseError::{ + InvalidVersionRequirement, + OpAlreadySet, + InvalidSigil, + VersionComponentsMustBeNumeric, + MajorVersionRequired, + }; + + fn req(s: &str) -> VersionReq { + VersionReq::parse(s).unwrap() + } + + fn version(s: &str) -> Version { + match Version::parse(s) { + Ok(v) => v, + Err(e) => panic!("`{}` is not a valid version. Reason: {}", s, e) + } + } + + fn assert_match(req: &VersionReq, vers: &[&str]) { + for ver in vers.iter() { + assert!(req.matches(&version(*ver)), "did not match {}", ver); + } + } + + fn assert_not_match(req: &VersionReq, vers: &[&str]) { + for ver in vers.iter() { + assert!(!req.matches(&version(*ver)), "matched {}", ver); + } + } + + #[test] + fn test_parsing_default() { + let r = req("1.0.0"); + + assert_eq!(r.to_string(), "^1.0.0".to_string()); + + assert_match(&r, &["1.0.0", "1.0.1"]); + assert_not_match(&r, &["0.9.9", "0.10.0", "0.1.0"]); + } + + #[test] + fn test_parsing_exact() { + let r = req("=1.0.0"); + + assert!(r.to_string() == "= 1.0.0".to_string()); + assert_eq!(r.to_string(), "= 1.0.0".to_string()); + + assert_match(&r, &["1.0.0"]); + assert_not_match(&r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0"]); + + let r = req("=0.9.0"); + + assert_eq!(r.to_string(), "= 0.9.0".to_string()); + + assert_match(&r, &["0.9.0"]); + assert_not_match(&r, &["0.9.1", "1.9.0", "0.0.9"]); + } + + #[test] + pub fn test_parsing_greater_than() { + let r = req(">= 1.0.0"); + + assert_eq!(r.to_string(), ">= 1.0.0".to_string()); + + assert_match(&r, &["1.0.0"]); + } + + #[test] + pub fn test_multiple() { + let r = req("> 0.0.9, <= 2.5.3"); + assert_eq!(r.to_string(), "> 0.0.9, <= 2.5.3".to_string()); + assert_match(&r, &["0.0.10", "1.0.0", "2.5.3"]); + assert_not_match(&r, &["0.0.8", "2.5.4"]); + + let r = req("0.3.0, 0.4.0"); + assert_eq!(r.to_string(), "^0.3.0, ^0.4.0".to_string()); + assert_not_match(&r, &["0.0.8", "0.3.0", "0.4.0"]); + + let r = req("<= 0.2.0, >= 0.5.0"); + assert_eq!(r.to_string(), "<= 0.2.0, >= 0.5.0".to_string()); + assert_not_match(&r, &["0.0.8", "0.3.0", "0.5.1"]); + + let r = req("0.1.0, 0.1.4, 0.1.6"); + assert_eq!(r.to_string(), "^0.1.0, ^0.1.4, ^0.1.6".to_string()); + assert_match(&r, &["0.1.6", "0.1.9"]); + assert_not_match(&r, &["0.1.0", "0.1.4", "0.2.0"]); + + assert!(VersionReq::parse("> 0.1.0,").is_err()); + assert!(VersionReq::parse("> 0.3.0, ,").is_err()); + } + + #[test] + pub fn test_parsing_tilde() { + let r = req("~1"); + assert_match(&r, &["1.0.0", "1.0.1", "1.1.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "0.0.9"]); + + let r = req("~1.2"); + assert_match(&r, &["1.2.0", "1.2.1"]); + assert_not_match(&r, &["1.1.1", "1.3.0", "0.0.9"]); + + let r = req("~1.2.2"); + assert_match(&r, &["1.2.2", "1.2.4"]); + assert_not_match(&r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]); + } + + #[test] + pub fn test_parsing_compatible() { + let r = req("^1"); + assert_match(&r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "0.1.4"]); + + let r = req("^1.1"); + assert_match(&r, &["1.1.2", "1.1.0", "1.2.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]); + + let r = req("^1.1.2"); + assert_match(&r, &["1.1.2", "1.1.4", "1.2.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); + + let r = req("^0.1.2"); + assert_match(&r, &["0.1.2", "0.1.4"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); + + let r = req("^0.0.2"); + assert_match(&r, &["0.0.2"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]); + + let r = req("^0.0"); + assert_match(&r, &["0.0.2", "0.0.0"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]); + + let r = req("^0"); + assert_match(&r, &["0.9.1", "0.0.2", "0.0.0"]); + assert_not_match(&r, &["2.9.0", "1.1.1"]); + } + + #[test] + pub fn test_parsing_wildcard() { + let r = req("*"); + assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); + assert_not_match(&r, &[]); + + let r = req("1.*"); + assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); + assert_not_match(&r, &["0.0.9"]); + + let r = req("1.2.*"); + assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); + assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); + } + + + #[test] + pub fn test_parse_errors() { + assert_eq!(Err(InvalidVersionRequirement), VersionReq::parse("0-0.1")); + assert_eq!(Err(OpAlreadySet), VersionReq::parse(">= >= 0.0.2")); + assert_eq!(Err(InvalidSigil), VersionReq::parse(">== 0.0.2")); + assert_eq!(Err(VersionComponentsMustBeNumeric), VersionReq::parse("a.0.0")); + assert_eq!(Err(MajorVersionRequired), VersionReq::parse(">=")); + } + + + /* TODO: + * - Handle pre releases + */ +} diff --git a/deps/strsim-0.3.0/.gitignore b/deps/strsim-0.3.0/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/strsim-0.3.0/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/strsim-0.3.0/.travis.yml b/deps/strsim-0.3.0/.travis.yml new file mode 100644 index 000000000..4d7a3efda --- /dev/null +++ b/deps/strsim-0.3.0/.travis.yml @@ -0,0 +1,5 @@ +language: rust + +rust: + - nightly + - beta diff --git a/deps/strsim-0.3.0/Cargo.toml b/deps/strsim-0.3.0/Cargo.toml new file mode 100644 index 000000000..91219ef6d --- /dev/null +++ b/deps/strsim-0.3.0/Cargo.toml @@ -0,0 +1,15 @@ +[package] + +name = "strsim" +version = "0.3.0" +authors = ["Danny Guo <dannyguo91@gmail.com>"] +description = """ +Implementations of string similarity metrics. +Includes Hamming, Levenshtein, Damerau-Levenshtein, Jaro, and Jaro-Winkler. +""" +license = "MIT" +readme = "README.md" +keywords = ["string", "similarity", "Hamming", + "Levenshtein", "Jaro"] +homepage = "https://github.com/dguo/strsim-rs" +repository = "https://github.com/dguo/strsim-rs" diff --git a/deps/strsim-0.3.0/LICENSE b/deps/strsim-0.3.0/LICENSE new file mode 100644 index 000000000..d35e62c38 --- /dev/null +++ b/deps/strsim-0.3.0/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Danny Guo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/deps/strsim-0.3.0/README.md b/deps/strsim-0.3.0/README.md new file mode 100644 index 000000000..a66f27e38 --- /dev/null +++ b/deps/strsim-0.3.0/README.md @@ -0,0 +1,49 @@ +# strsim-rs [![Build Status](https://travis-ci.org/dguo/strsim-rs.svg?branch=master)](https://travis-ci.org/dguo/strsim-rs) + +Rust implementations of [string similarity metrics]. Should compile cleanly on both the nightly and beta versions of Rust. Includes: + - [Hamming] + - [Levenshtein] and [Damerau-Levenshtein] + - [Jaro and Jaro-Winkler] - this implementation of Jaro-Winkler does not limit the common prefix length + +### Installation + +```toml +# Cargo.toml +[dependencies] +strsim = "0.3.0" +``` + +### Usage + +```rust +extern crate strsim; + +use strsim::{hamming, levenshtein, damerau_levenshtein, jaro, jaro_winkler}; + +fn main() { + match hamming("hamming", "hammers") { + Ok(distance) => assert_eq!(3, distance), + Err(why) => panic!("{:?}", why) + } + + assert_eq!(3, levenshtein("kitten", "sitting")); + + assert_eq!(1, damerau_levenshtein("specter", "spectre")); + + assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < + 0.001); + + assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < + 0.001); +} +``` + +### License + +MIT + +[string similarity metrics]:http://en.wikipedia.org/wiki/String_metric +[Damerau-Levenshtein]:http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance +[Jaro and Jaro-Winkler]:http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance +[Levenshtein]:http://en.wikipedia.org/wiki/Levenshtein_distance +[Hamming]:http://en.wikipedia.org/wiki/Hamming_distance diff --git a/deps/strsim-0.3.0/src/lib.rs b/deps/strsim-0.3.0/src/lib.rs new file mode 100644 index 000000000..d7d5e6044 --- /dev/null +++ b/deps/strsim-0.3.0/src/lib.rs @@ -0,0 +1,470 @@ + +//! This library implements string similarity metrics. Currently includes +//! Hamming, Levenshtein, Jaro, and Jaro-Winkler. + +use std::char; +use std::cmp::{max, min}; + +#[derive(Debug, PartialEq)] +pub enum StrSimError { + DifferentLengthArgs +} + +pub type HammingResult = Result<usize, StrSimError>; + +/// Calculates the number of positions in the two strings where the characters +/// differ. Returns an error if the strings have different lengths. +/// +/// ``` +/// use strsim::hamming; +/// +/// match hamming("hamming", "hammers") { +/// Ok(distance) => assert_eq!(3, distance), +/// Err(why) => panic!("{:?}", why) +/// } +/// ``` +pub fn hamming(a: &str, b: &str) -> HammingResult { + if a.len() != b.len() { + Err(StrSimError::DifferentLengthArgs) + } else { + Ok(a.chars() + .zip(b.chars()) + .filter(|&(a_char, b_char)| a_char != b_char) + .count()) + } +} + +/// Calculates the Jaro similarity between two strings. The returned value +/// is between 0.0 and 1.0 (higher value means more similar). +/// +/// ``` +/// use strsim::jaro; +/// +/// assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < +/// 0.001); +/// ``` +pub fn jaro(a: &str, b: &str) -> f64 { + if a == b { return 1.0; } + if a.len() == 0 || b.len() == 0 { return 0.0; } + + let search_range = max(0, (max(a.len(), b.len()) / 2) - 1); + + let mut b_consumed = Vec::with_capacity(b.len()); + for _ in 0..b.len() { + b_consumed.push(false); + } + let mut matches = 0.0; + + let mut transpositions = 0.0; + let mut b_match_index = 0; + + for (i, a_char) in a.chars().enumerate() { + let min_bound = + // prevent integer wrapping + if i > search_range { + max(0, i - search_range) + } else { + 0 + }; + + let max_bound = min(b.len() - 1, i + search_range); + + if min_bound > max_bound { + continue; + } + + for (j, b_char) in b.chars().enumerate() { + if min_bound <= j && j <= max_bound { + if a_char == b_char && !b_consumed[j] { + b_consumed[j] = true; + matches += 1.0; + + if j < b_match_index { + transpositions += 1.0; + } + b_match_index = j; + + break; + } + } + } + } + + if matches == 0.0 { + 0.0 + } else { + (1.0 / 3.0) * ((matches / a.len() as f64) + + (matches / b.len() as f64) + + ((matches - transpositions) / matches)) + } +} + +/// Like Jaro but gives a boost to strings that have a common prefix. +/// +/// ``` +/// use strsim::jaro_winkler; +/// +/// assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < +/// 0.001); +/// ``` +pub fn jaro_winkler(a: &str, b: &str) -> f64 { + let jaro_distance = jaro(a, b); + + // Don't limit the length of the common prefix + let prefix_length = a.chars() + .zip(b.chars()) + .take_while(|&(a_char, b_char)| a_char == b_char) + .count(); + + let jaro_winkler_distance = + jaro_distance + (0.1 * prefix_length as f64 * (1.0 - jaro_distance)); + + if jaro_winkler_distance <= 1.0 { + jaro_winkler_distance + } else { + 1.0 + } +} + +/// Calculates the minimum number of insertions, deletions, and substitutions +/// required to change one string into the other. +/// +/// ``` +/// use strsim::levenshtein; +/// +/// assert_eq!(3, levenshtein("kitten", "sitting")); +/// ``` +pub fn levenshtein(a: &str, b: &str) -> usize { + if a == b { return 0; } + else if a.len() == 0 { return b.len(); } + else if b.len() == 0 { return a.len(); } + + let mut prev_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); + let mut curr_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); + + for i in 0..(b.len() + 1) { + prev_distances.push(i); + curr_distances.push(0); + } + + for (i, a_char) in a.chars().enumerate() { + curr_distances[0] = i + 1; + + for (j, b_char) in b.chars().enumerate() { + let cost = if a_char == b_char { 0 } else { 1 }; + curr_distances[j + 1] = min(curr_distances[j] + 1, + min(prev_distances[j + 1] + 1, + prev_distances[j] + cost)); + } + + prev_distances.clone_from(&curr_distances); + } + + curr_distances[b.len()] +} + +/// Same as Levenshtein but allows for adjacent transpositions. +/// +/// ``` +/// use strsim::damerau_levenshtein; +/// +/// assert_eq!(3, damerau_levenshtein("damerau", "aderua")); +/// ``` +pub fn damerau_levenshtein(a: &str, b: &str) -> usize { + if a == b { return 0; } + else if a.len() == 0 { return b.len(); } + else if b.len() == 0 { return a.len(); } + + let mut prev_two_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); + let mut prev_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); + let mut curr_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); + + let mut prev_a_char = char::MAX; + let mut prev_b_char = char::MAX; + + for i in 0..(b.len() + 1) { + prev_two_distances.push(i); + prev_distances.push(i); + curr_distances.push(0); + } + + for (i, a_char) in a.chars().enumerate() { + curr_distances[0] = i + 1; + + for (j, b_char) in b.chars().enumerate() { + let cost = if a_char == b_char { 0 } else { 1 }; + curr_distances[j + 1] = min(curr_distances[j] + 1, + min(prev_distances[j + 1] + 1, + prev_distances[j] + cost)); + if i > 0 && j > 0 && a_char != b_char && + a_char == prev_b_char && b_char == prev_a_char { + curr_distances[j + 1] = min(curr_distances[j + 1], + prev_two_distances[j - 1] + 1); + } + + prev_b_char = b_char; + } + + prev_two_distances.clone_from(&prev_distances); + prev_distances.clone_from(&curr_distances); + prev_a_char = a_char; + } + + curr_distances[b.len()] + } + +#[cfg(test)] +mod tests { + use super::*; + // use test::Bencher; + + #[test] + fn hamming_empty() { + match hamming("", "") { + Ok(distance) => { assert_eq!(0, distance); }, + Err(why) => { panic!("{:?}", why); } + } + } + + #[test] + fn hamming_same() { + match hamming("hamming", "hamming") { + Ok(distance) => { assert_eq!(0, distance); }, + Err(why) => { panic!("{:?}", why); } + } + } + + #[test] + fn hamming_diff() { + match hamming("hamming", "hammers") { + Ok(distance) => { assert_eq!(3, distance); }, + Err(why) => { panic!("{:?}", why); } + } + } + + #[test] + fn hamming_unequal_length() { + match hamming("ham", "hamming") { + Ok(_) => { panic!(); }, + Err(why) => { assert_eq!(why, StrSimError::DifferentLengthArgs); } + } + } + + #[test] + fn hamming_names() { + match hamming("Friedrich Nietzs", "Jean-Paul Sartre") { + Ok(distance) => { assert_eq!(14, distance); }, + Err(why) => { panic!("{:?}", why); } + } + } + + #[test] + fn jaro_both_empty() { + assert_eq!(1.0, jaro("", "")); + } + + #[test] + fn jaro_first_empty() { + assert_eq!(0.0, jaro("", "jaro")); + } + + #[test] + fn jaro_second_empty() { + assert_eq!(0.0, jaro("distance", "")); + } + + #[test] + fn jaro_same() { + assert_eq!(1.0, jaro("jaro", "jaro")); + } + + #[test] + fn jaro_diff_short() { + assert!((0.767 - jaro("dixon", "dicksonx")).abs() < 0.001); + } + + #[test] + fn jaro_diff_no_transposition() { + assert!((0.822 - jaro("dwayne", "duane")).abs() < 0.001); + } + + #[test] + fn jaro_diff_with_transposition() { + assert!((0.944 - jaro("martha", "marhta")).abs() < 0.001); + } + + #[test] + fn jaro_names() { + assert!((0.392 - jaro("Friedrich Nietzsche", + "Jean-Paul Sartre")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_both_empty() { + assert_eq!(1.0, jaro_winkler("", "")); + } + + #[test] + fn jaro_winkler_first_empty() { + assert_eq!(0.0, jaro_winkler("", "jaro-winkler")); + } + + #[test] + fn jaro_winkler_second_empty() { + assert_eq!(0.0, jaro_winkler("distance", "")); + } + + #[test] + fn jaro_winkler_same() { + assert_eq!(1.0, jaro_winkler("Jaro-Winkler", "Jaro-Winkler")); + } + + #[test] + fn jaro_winkler_diff_short() { + assert!((0.813 - jaro_winkler("dixon", "dicksonx")).abs() < 0.001); + assert!((0.813 - jaro_winkler("dicksonx", "dixon")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_diff_no_transposition() { + assert!((0.840 - jaro_winkler("dwayne", "duane")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_diff_with_transposition() { + assert!((0.961 - jaro_winkler("martha", "marhta")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_names() { + assert!((0.562 - jaro_winkler("Friedrich Nietzsche", + "Fran-Paul Sartre")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_long_prefix() { + assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < + 0.001); + } + + #[test] + fn jaro_winkler_more_names() { + assert!((0.868 - jaro_winkler("Thorkel", "Thorgier")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_length_of_one() { + assert!((0.738 - jaro_winkler("Dinsdale", "D")).abs() < 0.001); + } + + #[test] + fn jaro_winkler_very_long_prefix() { + assert!((1.0 - jaro_winkler("thequickbrownfoxjumpedoverx", + "thequickbrownfoxjumpedovery")).abs() < + 0.001); + } + + #[test] + fn levenshtein_empty() { + assert_eq!(0, levenshtein("", "")); + } + + #[test] + fn levenshtein_same() { + assert_eq!(0, levenshtein("levenshtein", "levenshtein")); + } + + #[test] + fn levenshtein_diff_short() { + assert_eq!(3, levenshtein("kitten", "sitting")); + } + + #[test] + fn levenshtein_diff_with_space() { + assert_eq!(5, levenshtein("hello, world", "bye, world")); + } + + #[test] + fn levenshtein_diff_longer() { + let a = "The quick brown fox jumped over the angry dog."; + let b = "Lorem ipsum dolor sit amet, dicta latine an eam."; + assert_eq!(37, levenshtein(a, b)); + } + + #[test] + fn levenshtein_first_empty() { + assert_eq!(7, levenshtein("", "sitting")); + } + + #[test] + fn levenshtein_second_empty() { + assert_eq!(6, levenshtein("kitten", "")); + } + + #[test] + fn damerau_levenshtein_empty() { + assert_eq!(0, damerau_levenshtein("", "")); + } + + #[test] + fn damerau_levenshtein_same() { + assert_eq!(0, damerau_levenshtein("damerau", "damerau")); + } + + #[test] + fn damerau_levenshtein_first_empty() { + assert_eq!(7, damerau_levenshtein("", "damerau")); + } + + #[test] + fn damerau_levenshtein_second_empty() { + assert_eq!(7, damerau_levenshtein("damerau", "")); + } + + #[test] + fn damerau_levenshtein_diff_short() { + assert_eq!(3, damerau_levenshtein("damerau", "aderua")); + } + + #[test] + fn damerau_levenshtein_diff_reversed() { + assert_eq!(3, damerau_levenshtein("aderua", "damerau")); + } + + #[test] + fn damerau_levenshtein_diff_unequal_length() { + assert_eq!(6, damerau_levenshtein("damerau", "aderuaxyz")); + } + + #[test] + fn damerau_levenshtein_diff_unequal_length_reversed() { + assert_eq!(6, damerau_levenshtein("aderuaxyz", "damerau")); + } + + #[test] + fn damerau_levenshtein_diff_comedians() { + assert_eq!(5, damerau_levenshtein("Stewart", "Colbert")); + } + + #[test] + fn damerau_levenshtein_many_transpositions() { + assert_eq!(4, damerau_levenshtein("abcdefghijkl", "bacedfgihjlk")); + } + + #[test] + fn damerau_levenshtein_diff_longer() { + let a = "The quick brown fox jumped over the angry dog."; + let b = "Lehem ipsum dolor sit amet, dicta latine an eam."; + assert_eq!(36, damerau_levenshtein(a, b)); + } + + #[test] + fn damerau_levenshtein_beginning_transposition() { + assert_eq!(1, damerau_levenshtein("foobar", "ofobar")); + } + + #[test] + fn damerau_levenshtein_end_transposition() { + assert_eq!(1, damerau_levenshtein("specter", "spectre")); + } +} diff --git a/deps/strsim-0.3.0/tests/lib.rs b/deps/strsim-0.3.0/tests/lib.rs new file mode 100644 index 000000000..04729ad2e --- /dev/null +++ b/deps/strsim-0.3.0/tests/lib.rs @@ -0,0 +1,33 @@ +extern crate strsim; + +use strsim::{hamming, levenshtein, damerau_levenshtein, jaro, jaro_winkler}; + +#[test] +fn hamming_works() { + match hamming("hamming", "hammers") { + Ok(distance) => assert_eq!(3, distance), + Err(why) => panic!("{:?}", why) + } +} + +#[test] +fn levenshtein_works() { + assert_eq!(3, levenshtein("kitten", "sitting")); +} + +#[test] +fn damerau_levenshtein_works() { + assert_eq!(3, damerau_levenshtein("damerau", "aderua")); +} + +#[test] +fn jaro_works() { + assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < + 0.001); +} + +#[test] +fn jaro_winkler_works() { + assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < + 0.001); +} diff --git a/deps/tar-0.2.14/.gitignore b/deps/tar-0.2.14/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/tar-0.2.14/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/tar-0.2.14/.travis.yml b/deps/tar-0.2.14/.travis.yml new file mode 100644 index 000000000..1357105dc --- /dev/null +++ b/deps/tar-0.2.14/.travis.yml @@ -0,0 +1,28 @@ +language: rust +rust: + - nightly + - beta + - 1.0.0 +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - | + [ $TRAVIS_RUST_VERSION != nightly ] || cargo test --features nightly + - rustdoc --test README.md -L target/debug -L target/debug/deps + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '<meta http-equiv=refresh content=0;url=tar/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + - secure: hz4IbWiy1A9i2a3IThcyqdTS0QBVEcWuZYR9MU+YqBJZ1v4puNsFQxAtes77J7d/gzaJQmIMJ5uiNDLIozHkKTXlvi7blmpDSrMcBQoablqRMRtWlGjbcsgGqQVuBVg8WzVz44FoacRGnI75InNDTVXu/duJTXDGud0b9b28Kro= + - secure: ZPYVRKWbPMX1Guo2pOLovbnLNeOMtI0MIqC/4kI+6tG8OMnEixkvuVBHp7++FN3nEHlm1tLJqgaSg5qvcyMl6vfVQnsYzHj8SYwsY3SSZmQomsoc0DByhvfrD8oxat6w8R9J2fk0DtUZ6ihCGFdA15mCZ+1vNhcNmRSv/OfQVz0= +notifications: + email: + on_success: never diff --git a/deps/tar-0.2.14/Cargo.toml b/deps/tar-0.2.14/Cargo.toml new file mode 100644 index 000000000..d10d1eab1 --- /dev/null +++ b/deps/tar-0.2.14/Cargo.toml @@ -0,0 +1,27 @@ +[package] + +name = "tar" +version = "0.2.14" +authors = ["Alex Crichton <alex@alexcrichton.com>"] +homepage = "https://github.com/alexcrichton/tar-rs" +repository = "https://github.com/alexcrichton/tar-rs" +documentation = "http://alexcrichton.com/tar-rs" +license = "MIT/Apache-2.0" +keywords = ["tar", "tarfile", "encoding"] +readme = "README.md" + +description = """ +A Rust implementation of a TAR file reader and writer. This library does not +currently handle compression, but it is abstract over all I/O readers and +writers. Additionally, great lengths are taken to ensure that the entire +contents are never required to be entirely resident in memory all at once. +""" + +[dependencies] +libc = "0.1" + +[features] +nightly = [] + +[dev-dependencies] +tempdir = "0.3" diff --git a/deps/tar-0.2.14/LICENSE-APACHE b/deps/tar-0.2.14/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/tar-0.2.14/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/tar-0.2.14/LICENSE-MIT b/deps/tar-0.2.14/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/tar-0.2.14/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/tar-0.2.14/README.md b/deps/tar-0.2.14/README.md new file mode 100644 index 000000000..415784ee6 --- /dev/null +++ b/deps/tar-0.2.14/README.md @@ -0,0 +1,76 @@ +# tar-rs + +[![Build Status](https://travis-ci.org/alexcrichton/tar-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/tar-rs) +[![Build status](https://ci.appveyor.com/api/projects/status/0udgokm2fc6ljorj?svg=true)](https://ci.appveyor.com/project/alexcrichton/tar-rs) + +[Documentation](http://alexcrichton.com/tar-rs/tar/index.html) + +A tar archive reading/writing library for Rust. + +```toml +# Cargo.toml +[dependencies.tar] +git = "https://github.com/alexcrichton/tar-rs" +``` + +## Reading an archive + +```rust,no_run +extern crate tar; + +use std::io::prelude::*; +use std::io::SeekFrom; +use std::fs::File; +use tar::Archive; + +fn main() { + let file = File::open("foo.tar").unwrap(); + let a = Archive::new(file); + + for file in a.files().unwrap() { + // Make sure there wasn't an I/O error + let mut file = file.unwrap(); + + // Inspect metadata about the file + println!("{:?}", file.filename()); + println!("{}", file.size()); + + // files implement the Read trait + let mut s = String::new(); + file.read_to_string(&mut s).unwrap(); + println!("{}", s); + + // files also implement the Seek trait + file.seek(SeekFrom::Current(0)).unwrap(); + } +} + +``` + +## Writing an archive + +```rust,no_run +# #![allow(unused_must_use, unstable)] +extern crate tar; + +use std::io::prelude::*; +use std::fs::File; +use tar::Archive; + +fn main() { + let file = File::create("foo.tar").unwrap(); + let a = Archive::new(file); + + a.append("file1.txt", &mut File::open("file1.txt").unwrap()); + a.append("file2.txt", &mut File::open("file2.txt").unwrap()); + a.finish(); +} +``` + +# License + +`tar-rs` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/tar-0.2.14/appveyor.yml b/deps/tar-0.2.14/appveyor.yml new file mode 100644 index 000000000..fc72b1e24 --- /dev/null +++ b/deps/tar-0.2.14/appveyor.yml @@ -0,0 +1,13 @@ +install: + - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' + - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + - git submodule update --init --recursive + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/tar-0.2.14/src/lib.rs b/deps/tar-0.2.14/src/lib.rs new file mode 100644 index 000000000..d0148f71d --- /dev/null +++ b/deps/tar-0.2.14/src/lib.rs @@ -0,0 +1,992 @@ +//! A library for reading and writing TAR archives +//! +//! This library provides utilities necessary to manage TAR archives [1] +//! abstracted over a reader or writer. Great strides are taken to ensure that +//! an archive is never required to be fully resident in memory, all objects +//! provide largely a streaming interface to read bytes from. +//! +//! [1]: http://en.wikipedia.org/wiki/Tar_%28computing%29 + +#![doc(html_root_url = "http://alexcrichton.com/tar-rs")] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] + +extern crate libc; + +use std::cell::{RefCell, Cell}; +use std::cmp; +use std::ffi::CString; +use std::fmt; +use std::fs; +use std::io::prelude::*; +use std::io::{self, Error, ErrorKind, SeekFrom}; +use std::iter::repeat; +use std::mem; +use std::path::{Path, PathBuf}; +use std::str; + +macro_rules! try_iter{ ($me:expr, $e:expr) => ( + match $e { + Ok(e) => e, + Err(e) => { $me.done = true; return Some(Err(e)) } + } +) } + +/// A top-level representation of an archive file. +/// +/// This archive can have a file added to it and it can be iterated over. +pub struct Archive<R> { + obj: RefCell<R>, + pos: Cell<u64>, +} + +/// An iterator over the files of an archive. +/// +/// Requires that `R` implement `Seek`. +pub struct Files<'a, R:'a> { + archive: &'a Archive<R>, + done: bool, + offset: u64, +} + +/// An iterator over the files of an archive. +/// +/// Does not require that `R` implements `Seek`, but each file must be processed +/// before the next. +pub struct FilesMut<'a, R:'a> { + archive: &'a Archive<R>, + next: u64, + done: bool, +} + +/// A read-only view into a file of an archive. +/// +/// This structure is a windows into a portion of a borrowed archive which can +/// be inspected. It acts as a file handle by implementing the Reader and Seek +/// traits. A file cannot be rewritten once inserted into an archive. +pub struct File<'a, R: 'a> { + header: Header, + archive: &'a Archive<R>, + pos: u64, + size: u64, + filename: Vec<u8>, + + // Used in read() to make sure we're positioned at the next byte. For a + // `Files` iterator these are meaningful while for a `FilesMut` iterator + // these are both unused/noops. + seek: fn(&File<R>) -> io::Result<()>, + tar_offset: u64, +} + +/// Representation of the header of a file in an archive +#[repr(C)] +#[allow(missing_docs)] +pub struct Header { + pub name: [u8; 100], + pub mode: [u8; 8], + pub owner_id: [u8; 8], + pub group_id: [u8; 8], + pub size: [u8; 12], + pub mtime: [u8; 12], + pub cksum: [u8; 8], + pub link: [u8; 1], + pub linkname: [u8; 100], + + // UStar format + pub ustar: [u8; 6], + pub ustar_version: [u8; 2], + pub owner_name: [u8; 32], + pub group_name: [u8; 32], + pub dev_major: [u8; 8], + pub dev_minor: [u8; 8], + pub prefix: [u8; 155], + _rest: [u8; 12], +} + +impl<O> Archive<O> { + /// Create a new archive with the underlying object as the reader/writer. + /// + /// Different methods are available on an archive depending on the traits + /// that the underlying object implements. + pub fn new(obj: O) -> Archive<O> { + Archive { obj: RefCell::new(obj), pos: Cell::new(0) } + } + + /// Unwrap this archive, returning the underlying object. + pub fn into_inner(self) -> O { + self.obj.into_inner() + } +} + +impl<R: Seek + Read> Archive<R> { + /// Construct an iterator over the files of this archive. + /// + /// This function can return an error if any underlying I/O operation files + /// while attempting to construct the iterator. + /// + /// Additionally, the iterator yields `io::Result<File>` instead of `File` to + /// handle invalid tar archives as well as any intermittent I/O error that + /// occurs. + pub fn files(&self) -> io::Result<Files<R>> { + try!(self.seek(0)); + Ok(Files { archive: self, done: false, offset: 0 }) + } + + fn seek(&self, pos: u64) -> io::Result<()> { + if self.pos.get() == pos { return Ok(()) } + try!(self.obj.borrow_mut().seek(SeekFrom::Start(pos))); + self.pos.set(pos); + Ok(()) + } +} + +impl<R: Read> Archive<R> { + /// Construct an iterator over the files in this archive. + /// + /// While similar to the `files` iterator, this iterator does not require + /// that `R` implement `Seek` and restricts the iterator to processing only + /// one file at a time in a streaming fashion. + /// + /// Note that care must be taken to consider each file within an archive in + /// sequence. If files are processed out of sequence (from what the iterator + /// returns), then the contents read for each file may be corrupted. + pub fn files_mut(&mut self) -> io::Result<FilesMut<R>> { + Ok(FilesMut { archive: self, done: false, next: 0 }) + } + + /// Unpacks this tarball into the specified path + pub fn unpack(&mut self, into: &Path) -> io::Result<()> { + 'outer: for file in try!(self.files_mut()) { + let mut file = try!(file); + let bytes = file.filename_bytes().iter().map(|&b| { + if b == b'\\' {b'/'} else {b} + }).collect::<Vec<_>>(); + if bytes.len() == 0 { + continue + } + let is_directory = bytes[bytes.len() - 1] == b'/'; + + // Notes regarding bsdtar 2.8.3 / libarchive 2.8.3: + // * Leading '/'s are trimmed. For example, `///test` is treated as + // `test`. + // * If the filename contains '..', then the file is skipped when + // extracting the tarball. + // * '//' within a filename is effectively skipped. An error is + // logged, but otherwise the effect is as if any two or more + // adjacent '/'s within the filename were consolidated into one + // '/'. + + let mut dst = into.to_path_buf(); + let mut seen_non_empty_part = false; + for part in bytes.split(|x| *x == b'/') { + // If any part of the filename is '..', then skip over unpacking + // the file to prevent directory traversal security issues. + // See, e.g.: CVE-2001-1267, CVE-2002-0399, CVE-2005-1918, + // CVE-2007-4131 + if part == b".." { + continue 'outer + } + + // If empty or '.', skip this part. This effectively results in + // trimming leading '/'s as well as merging adjacent '/'s. + if part.len() == 0 || part == b"." { + continue + } + + seen_non_empty_part = true; + push(&mut dst, part); + } + + // Skip cases where only slashes or '.' parts were seen, because this + // is effectively an empty filename. + if !seen_non_empty_part { + continue + } + + if is_directory { + try!(fs::create_dir_all(&dst)); + } else { + try!(fs::create_dir_all(&dst.parent().unwrap())); + { + let mut dst = try!(fs::File::create(&dst)); + try!(io::copy(&mut file, &mut dst)); + } + + try!(set_perms(&dst, try!(file.mode()))); + } + } + return Ok(()); + + #[cfg(all(unix, feature = "nightly"))] + fn set_perms(dst: &PathBuf, mode: i32) -> io::Result<()> { + use std::os::unix::prelude::*; + use std::os::unix::raw; + let perm = fs::Permissions::from_mode(mode as raw::mode_t); + fs::set_permissions(dst, perm) + } + #[cfg(all(unix, not(feature = "nightly")))] + fn set_perms(dst: &PathBuf, mode: i32) -> io::Result<()> { + use std::ffi::CString; + use std::os::unix::prelude::*; + let dst_cstring = try!(CString::new(dst.as_os_str().as_bytes())); + unsafe { + if libc::chmod(dst_cstring.as_ptr(), mode as libc::mode_t) != 0 { + Err(io::Error::last_os_error()) + } else { + Ok(()) + } + } + } + #[cfg(all(windows, feature = "nightly"))] + fn set_perms(dst: &PathBuf, mode: i32) -> io::Result<()> { + let mut perm = try!(fs::metadata(dst)).permissions(); + perm.set_readonly(mode & 0o200 != 0o200); + fs::set_permissions(dst, perm) + } + #[cfg(all(windows, not(feature = "nightly")))] + fn set_perms(_dst: &PathBuf, _mode: i32) -> io::Result<()> { + Ok(()) + } + + #[cfg(unix)] + fn push(path: &mut PathBuf, bytes: &[u8]) { + use std::os::unix::prelude::*; + use std::ffi::OsStr; + path.push(OsStr::from_bytes(bytes)); + } + #[cfg(windows)] + fn push(path: &mut PathBuf, bytes: &[u8]) { + use std::str; + let s = str::from_utf8(bytes).ok().expect("only unicode paths are \ + supported on windows"); + path.push(s); + } + } + + fn skip(&self, mut amt: u64) -> io::Result<()> { + let mut buf = [0u8; 4096 * 8]; + let mut me = self; + while amt > 0 { + let n = cmp::min(amt, buf.len() as u64); + let n = try!(Read::read(&mut me, &mut buf[..n as usize])); + amt -= n as u64; + } + Ok(()) + } + + // Assumes that the underlying reader is positioned at the start of a valid + // header to parse. + fn next_file(&self, offset: &mut u64, seek: fn(&File<R>) -> io::Result<()>) + -> io::Result<Option<File<R>>> { + // If we have 2 or more sections of 0s, then we're done! + let mut chunk = [0; 512]; + let mut cnt = 0; + let mut me = self; + loop { + try!(read_all(&mut me, &mut chunk)); + *offset += 512; + if chunk.iter().any(|i| *i != 0) { break } + cnt += 1; + if cnt > 1 { return Ok(None) } + } + + let sum = chunk[..148].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + + chunk[156..].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + + 32 * 8; + + let mut ret = File { + archive: self, + header: unsafe { mem::transmute(chunk) }, + pos: 0, + size: 0, + tar_offset: *offset, + filename: Vec::new(), + seek: seek, + }; + + // Make sure the checksum is ok + let cksum = try!(ret.header.cksum()); + if sum != cksum { return Err(bad_archive()) } + + // Figure out where the next file is + let size = try!(ret.header.size()); + ret.size = size; + let size = (size + 511) & !(512 - 1); + *offset += size; + + if ret.header.is_ustar() && ret.header.prefix[0] != 0 { + ret.filename.extend(truncate(&ret.header.prefix).iter().map(|x| *x)); + ret.filename.push(b'/'); + } + ret.filename.extend(truncate(&ret.header.name).iter().map(|x| *x)); + + return Ok(Some(ret)); + } +} + +impl<W: Write> Archive<W> { + /// Add the file at the specified path to this archive. + /// + /// This function will insert the file into the archive with the appropriate + /// metadata set, returning any I/O error which occurs while writing. + /// + /// Note that this will not attempt to seek the archive to a valid position, + /// so if the archive is in the middle of a read or some other similar + /// operation then this may corrupt the archive. + pub fn append(&self, path: &str, file: &mut fs::File) -> io::Result<()> { + let stat = try!(file.metadata()); + + // Prepare the header, flagging it as a UStar archive + let mut header: Header = unsafe { mem::zeroed() }; + header.ustar = *b"ustar\0"; + header.ustar_version = *b"00"; + + // Prepare the filename + let cstr = try!(CString::new(path.replace(r"\", "/"))); + let path = cstr.as_bytes(); + let (namelen, prefixlen) = (header.name.len(), header.prefix.len()); + if path.len() < namelen { + copy_memory(&mut header.name, path); + } else if path.len() < namelen + prefixlen { + let prefix = &path[..cmp::min(path.len(), prefixlen)]; + let pos = match prefix.iter().rposition(|&b| b == b'/' || b == b'\\') { + Some(i) => i, + None => return Err(Error::new(ErrorKind::Other, + "path cannot be split to be \ + inserted into archive")), + }; + copy_memory(&mut header.name, &path[pos + 1..]); + copy_memory(&mut header.prefix, &path[..pos]); + } else { + return Err(Error::new(ErrorKind::Other, + "path is too long to insert into archive")) + } + + header.fill_from(&stat); + + // Final step, calculate the checksum + let cksum = { + let bytes = header.as_bytes(); + bytes[..148].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + + bytes[156..].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + + 32 * (header.cksum.len() as u32) + }; + octal_into(&mut header.cksum, cksum); + + // Write out the header, the entire file, then pad with zeroes. + let mut obj = self.obj.borrow_mut(); + try!(obj.write_all(header.as_bytes())); + try!(io::copy(file, &mut *obj)); + let buf = [0; 512]; + let remaining = 512 - (stat.len() % 512); + if remaining < 512 { + try!(obj.write_all(&buf[..remaining as usize])); + } + + // And we're done! + return Ok(()); + } + + /// Finish writing this archive, emitting the termination sections. + /// + /// This function is required to be called to complete the archive, it will + /// be invalid if this is not called. + pub fn finish(&self) -> io::Result<()> { + let b = [0; 1024]; + self.obj.borrow_mut().write_all(&b) + } +} + +fn copy_memory(dst: &mut [u8], src: &[u8]) { + for (slot, val) in dst.iter_mut().zip(src.iter()) { + *slot = *val; + } +} + +impl<'a, R: Seek + Read> Iterator for Files<'a, R> { + type Item = io::Result<File<'a, R>>; + + fn next(&mut self) -> Option<io::Result<File<'a, R>>> { + // If we hit a previous error, or we reached the end, we're done here + if self.done { return None } + + // Seek to the start of the next header in the archive + try_iter!(self, self.archive.seek(self.offset)); + + fn doseek<R: Seek + Read>(file: &File<R>) -> io::Result<()> { + file.archive.seek(file.tar_offset + file.pos) + } + + // Parse the next file header + match try_iter!(self, self.archive.next_file(&mut self.offset, doseek)) { + None => { self.done = true; None } + Some(f) => Some(Ok(f)), + } + } +} + + +impl<'a, R: Read> Iterator for FilesMut<'a, R> { + type Item = io::Result<File<'a, R>>; + + fn next(&mut self) -> Option<io::Result<File<'a, R>>> { + // If we hit a previous error, or we reached the end, we're done here + if self.done { return None } + + // Seek to the start of the next header in the archive + let delta = self.next - self.archive.pos.get(); + try_iter!(self, self.archive.skip(delta)); + + // no-op because this reader can't seek + fn doseek<R>(_: &File<R>) -> io::Result<()> { Ok(()) } + + // Parse the next file header + match try_iter!(self, self.archive.next_file(&mut self.next, doseek)) { + None => { self.done = true; None } + Some(f) => Some(Ok(f)), + } + } +} + +impl Header { + fn size(&self) -> io::Result<u64> { octal_from(&self.size) } + fn cksum(&self) -> io::Result<u32> { octal_from(&self.cksum).map(|u| u as u32) } + fn is_ustar(&self) -> bool { + &self.ustar[..5] == b"ustar" + } + fn as_bytes(&self) -> &[u8; 512] { + unsafe { &*(self as *const _ as *const [u8; 512]) } + } + + #[cfg(not(feature = "nightly"))] + fn fill_from(&mut self, meta: &fs::Metadata) { + let perms = meta.permissions(); + let is_dir = meta.is_dir(); + octal_into(&mut self.mode, if is_dir { + 0o755 + } else if perms.readonly() { + 0o444 + } else { + 0o644 + }); + octal_into(&mut self.mtime, 0); + octal_into(&mut self.owner_id, 0); + octal_into(&mut self.group_id, 0); + octal_into(&mut self.size, meta.len()); + octal_into(&mut self.dev_minor, 0); + octal_into(&mut self.dev_major, 0); + } + + #[cfg(all(unix, feature = "nightly"))] + fn fill_from(&mut self, meta: &fs::Metadata) { + use std::os::unix::prelude::*; + // Prepare the metadata fields. + octal_into(&mut self.mode, meta.mode() & 0o3777); + octal_into(&mut self.mtime, meta.mtime()); + octal_into(&mut self.owner_id, meta.uid()); + octal_into(&mut self.group_id, meta.gid()); + octal_into(&mut self.size, meta.size()); + octal_into(&mut self.dev_minor, 0); + octal_into(&mut self.dev_major, 0); + + // TODO: need to bind more file types + self.link[0] = match meta.mode() & libc::S_IFMT { + libc::S_IFREG => b'0', + libc::S_IFLNK => b'2', + libc::S_IFCHR => b'3', + libc::S_IFBLK => b'4', + libc::S_IFDIR => b'5', + libc::S_IFIFO => b'6', + _ => b' ', + }; + } + + #[cfg(all(windows, feature = "nightly"))] + fn fill_from(&mut self, meta: &fs::Metadata) { + use std::os::windows::prelude::*; + + let readonly = meta.file_attributes() & libc::FILE_ATTRIBUTE_READONLY; + + // There's no concept of a mode on windows, so do a best approximation + // here. + let mode = match (meta.is_dir(), readonly != 0) { + (true, false) => 0o755, + (true, true) => 0o555, + (false, false) => 0o644, + (false, true) => 0o444, + }; + octal_into(&mut self.mode, mode); + octal_into(&mut self.owner_id, 0); + octal_into(&mut self.group_id, 0); + octal_into(&mut self.size, meta.len()); + octal_into(&mut self.dev_minor, 0); + octal_into(&mut self.dev_major, 0); + + let ft = meta.file_type(); + self.link[0] = if ft.is_dir() { + b'5' + } else if ft.is_file() { + b'0' + } else if ft.is_symlink() { + b'2' + } else { + b' ' + }; + + // The dates listed in tarballs are always seconds relative to + // January 1, 1970. On Windows, however, the timestamps are returned as + // dates relative to January 1, 1601 (in 100ns intervals), so we need to + // add in some offset for those dates. + let mtime = (meta.last_write_time() / (1_000_000_000 / 100)) - 11644473600; + octal_into(&mut self.mtime, mtime); + } +} + +impl<'a, R> File<'a, R> { + /// Returns the filename of this archive as a byte array + pub fn filename_bytes(&self) -> &[u8] { + &self.filename + } + + /// Returns the filename of this archive as a utf8 string. + /// + /// If `None` is returned, then the filename is not valid utf8 + pub fn filename(&self) -> Option<&str> { + str::from_utf8(self.filename_bytes()).ok() + } + + /// Returns the value of the owner's user ID field + pub fn uid(&self) -> io::Result<u32> { + octal_from(&self.header.owner_id).map(|u| u as u32) + } + /// Returns the value of the group's user ID field + pub fn gid(&self) -> io::Result<u32> { + octal_from(&self.header.group_id).map(|u| u as u32) + } + /// Returns the last modification time in Unix time format + pub fn mtime(&self) -> io::Result<u64> { + octal_from(&self.header.mtime) + } + /// Returns the mode bits for this file + pub fn mode(&self) -> io::Result<i32> { + octal_from(&self.header.mode).map(|u| u as i32) + } + + // /// Classify the type of file that this entry represents + // pub fn classify(&self) -> old_io::FileType { + // match (self.header.is_ustar(), self.header.link[0]) { + // (_, b'0') => old_io::FileType::RegularFile, + // (_, b'1') => old_io::FileType::Unknown, // need a hard link enum? + // (_, b'2') => old_io::FileType::Symlink, + // (false, _) => old_io::FileType::Unknown, // not technically valid... + // + // (_, b'3') => old_io::FileType::Unknown, // character special... + // (_, b'4') => old_io::FileType::BlockSpecial, + // (_, b'5') => old_io::FileType::Directory, + // (_, b'6') => old_io::FileType::NamedPipe, + // (_, _) => old_io::FileType::Unknown, // not technically valid... + // } + // } + + /// Returns the username of the owner of this file, if present + pub fn username_bytes(&self) -> Option<&[u8]> { + if self.header.is_ustar() { + Some(truncate(&self.header.owner_name)) + } else { + None + } + } + /// Returns the group name of the owner of this file, if present + pub fn groupname_bytes(&self) -> Option<&[u8]> { + if self.header.is_ustar() { + Some(truncate(&self.header.group_name)) + } else { + None + } + } + /// Return the username of the owner of this file, if present and if valid + /// utf8 + pub fn username(&self) -> Option<&str> { + self.username_bytes().and_then(|s| str::from_utf8(s).ok()) + } + /// Return the group name of the owner of this file, if present and if valid + /// utf8 + pub fn groupname(&self) -> Option<&str> { + self.groupname_bytes().and_then(|s| str::from_utf8(s).ok()) + } + + /// Returns the device major number, if present. + /// + /// This field is only present in UStar archives. A value of `None` means + /// that this archive is not a UStar archive, while a value of `Some` + /// represents the attempt to decode the field in the header. + pub fn device_major(&self) -> Option<io::Result<u32>> { + if self.header.is_ustar() { + Some(octal_from(&self.header.dev_major).map(|u| u as u32)) + } else { + None + } + } + /// Returns the device minor number, if present. + /// + /// This field is only present in UStar archives. A value of `None` means + /// that this archive is not a UStar archive, while a value of `Some` + /// represents the attempt to decode the field in the header. + pub fn device_minor(&self) -> Option<io::Result<u32>> { + if self.header.is_ustar() { + Some(octal_from(&self.header.dev_minor).map(|u| u as u32)) + } else { + None + } + } + + /// Returns raw access to the header of this file in the archive. + pub fn raw_header(&self) -> &Header { &self.header } + + /// Returns the size of the file in the archive. + pub fn size(&self) -> u64 { self.size } +} + +impl<'a, R: Read> Read for &'a Archive<R> { + fn read(&mut self, into: &mut [u8]) -> io::Result<usize> { + self.obj.borrow_mut().read(into).map(|i| { + self.pos.set(self.pos.get() + i as u64); + i + }) + } +} + +impl<'a, R: Read> Read for File<'a, R> { + fn read(&mut self, into: &mut [u8]) -> io::Result<usize> { + if self.size == self.pos { return Ok(0) } + + try!((self.seek)(self)); + let amt = cmp::min((self.size - self.pos) as usize, into.len()); + let amt = try!(Read::read(&mut self.archive, &mut into[..amt])); + self.pos += amt as u64; + Ok(amt) + } +} + +impl<'a, R: Read + Seek> Seek for File<'a, R> { + fn seek(&mut self, how: SeekFrom) -> io::Result<u64> { + let next = match how { + SeekFrom::Start(pos) => pos as i64, + SeekFrom::Current(pos) => self.pos as i64 + pos, + SeekFrom::End(pos) => self.size as i64 + pos, + }; + if next < 0 { + Err(Error::new(ErrorKind::Other, "cannot seek before position 0")) + } else if next as u64 > self.size { + Err(Error::new(ErrorKind::Other, "cannot seek past end of file")) + } else { + self.pos = next as u64; + Ok(self.pos) + } + } +} + +fn bad_archive() -> Error { + Error::new(ErrorKind::Other, "invalid tar archive") +} + +fn octal_from(slice: &[u8]) -> io::Result<u64> { + let num = match str::from_utf8(truncate(slice)) { + Ok(n) => n, + Err(_) => return Err(bad_archive()), + }; + match u64::from_str_radix(num.trim(), 8) { + Ok(n) => Ok(n), + Err(_) => Err(bad_archive()) + } +} + +fn octal_into<T: fmt::Octal>(dst: &mut [u8], val: T) { + let o = format!("{:o}", val); + let value = o.bytes().rev().chain(repeat(b'0')); + for (slot, value) in dst.iter_mut().rev().skip(1).zip(value) { + *slot = value; + } +} + +fn truncate<'a>(slice: &'a [u8]) -> &'a [u8] { + match slice.iter().position(|i| *i == 0) { + Some(i) => &slice[..i], + None => slice, + } +} + +fn read_all<R: Read>(r: &mut R, buf: &mut [u8]) -> io::Result<()> { + let mut read = 0; + while read < buf.len() { + match try!(r.read(&mut buf[read..])) { + 0 => return Err(bad_archive()), + n => read += n, + } + } + Ok(()) +} + +#[cfg(test)] +mod tests { + extern crate tempdir; + use std::io::prelude::*; + use std::io::{Cursor, SeekFrom}; + use std::iter::repeat; + use std::fs::File; + + use self::tempdir::TempDir; + use super::Archive; + + macro_rules! t { + ($e:expr) => (match $e { + Ok(v) => v, + Err(e) => panic!("{} returned {}", stringify!($e), e), + }) + } + + #[test] + fn simple() { + let ar = Archive::new(Cursor::new(&include_bytes!("tests/simple.tar")[..])); + for file in t!(ar.files()) { + t!(file); + } + } + + #[test] + fn reading_files() { + let rdr = Cursor::new(&include_bytes!("tests/reading_files.tar")[..]); + let ar = Archive::new(rdr); + let mut files = t!(ar.files()); + let mut a = t!(files.next().unwrap()); + let mut b = t!(files.next().unwrap()); + assert!(files.next().is_none()); + + assert_eq!(a.filename(), Some("a")); + assert_eq!(b.filename(), Some("b")); + let mut s = String::new(); + t!(a.read_to_string(&mut s)); + assert_eq!(s, "a\na\na\na\na\na\na\na\na\na\na\n"); + s.truncate(0); + t!(b.read_to_string(&mut s)); + assert_eq!(s, "b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"); + t!(a.seek(SeekFrom::Start(0))); + s.truncate(0); + t!(a.read_to_string(&mut s)); + assert_eq!(s, "a\na\na\na\na\na\na\na\na\na\na\n"); + } + + #[test] + fn writing_files() { + let wr = Cursor::new(Vec::new()); + let ar = Archive::new(wr); + let td = t!(TempDir::new("tar-rs")); + + let path = td.path().join("test"); + t!(t!(File::create(&path)).write_all(b"test")); + + t!(ar.append("test2", &mut t!(File::open(&path)))); + t!(ar.finish()); + + let rd = Cursor::new(ar.into_inner().into_inner()); + let ar = Archive::new(rd); + let mut files = t!(ar.files()); + let mut f = t!(files.next().unwrap()); + assert!(files.next().is_none()); + + assert_eq!(f.filename(), Some("test2")); + assert_eq!(f.size(), 4); + let mut s = String::new(); + t!(f.read_to_string(&mut s)); + assert_eq!(s, "test"); + } + + #[test] + fn large_filename() { + let ar = Archive::new(Cursor::new(Vec::new())); + let td = t!(TempDir::new("tar-rs")); + + let path = td.path().join("test"); + t!(t!(File::create(&path)).write_all(b"test")); + + let filename = repeat("abcd/").take(50).collect::<String>(); + t!(ar.append(&filename, &mut t!(File::open(&path)))); + t!(ar.finish()); + + let too_long = repeat("abcd").take(200).collect::<String>(); + assert!(ar.append(&too_long, &mut t!(File::open(&path))).is_err()); + + let rd = Cursor::new(ar.into_inner().into_inner()); + let ar = Archive::new(rd); + let mut files = t!(ar.files()); + let mut f = files.next().unwrap().unwrap(); + assert!(files.next().is_none()); + + assert_eq!(f.filename(), Some(&filename[..])); + assert_eq!(f.size(), 4); + let mut s = String::new(); + t!(f.read_to_string(&mut s)); + assert_eq!(s, "test"); + } + + #[test] + fn reading_files_mut() { + let rdr = Cursor::new(&include_bytes!("tests/reading_files.tar")[..]); + let mut ar = Archive::new(rdr); + let mut files = t!(ar.files_mut()); + let mut a = t!(files.next().unwrap()); + assert_eq!(a.filename(), Some("a")); + let mut s = String::new(); + t!(a.read_to_string(&mut s)); + assert_eq!(s, "a\na\na\na\na\na\na\na\na\na\na\n"); + s.truncate(0); + t!(a.read_to_string(&mut s)); + assert_eq!(s, ""); + let mut b = t!(files.next().unwrap()); + + assert_eq!(b.filename(), Some("b")); + s.truncate(0); + t!(b.read_to_string(&mut s)); + assert_eq!(s, "b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"); + assert!(files.next().is_none()); + } + + #[test] + fn extracting_directories() { + use std::fs; + + let td = t!(TempDir::new("tar-rs")); + let rdr = Cursor::new(&include_bytes!("tests/directory.tar")[..]); + let mut ar = Archive::new(rdr); + t!(ar.unpack(td.path())); + + let dir_a = td.path().join("a"); + let dir_b = td.path().join("a/b"); + let file_c = td.path().join("a/c"); + assert!(fs::metadata(&dir_a).map(|m| m.is_dir()).unwrap_or(false)); + assert!(fs::metadata(&dir_b).map(|m| m.is_dir()).unwrap_or(false)); + assert!(fs::metadata(&file_c).map(|m| m.is_file()).unwrap_or(false)); + } + + #[test] + fn extracting_duplicate_dirs() { + use std::fs; + + let td = t!(TempDir::new("tar-rs")); + let rdr = Cursor::new(&include_bytes!("tests/duplicate_dirs.tar")[..]); + let mut ar = Archive::new(rdr); + t!(ar.unpack(td.path())); + + let some_dir = td.path().join("some_dir"); + assert!(fs::metadata(&some_dir).map(|m| m.is_dir()).unwrap_or(false)); + } + + #[test] + fn extracting_malicious_tarball() { + use std::fs; + use std::fs::OpenOptions; + use std::io::{Seek, Write}; + + let td = t!(TempDir::new("tar-rs")); + + let mut evil_tar = Cursor::new(Vec::new()); + + { + let a = Archive::new(&mut evil_tar); + let mut evil_txt_f = t!(OpenOptions::new().read(true).write(true) + .create(true) + .open(td.path().join("evil.txt"))); + t!(writeln!(evil_txt_f, "This is an evil file.")); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("/tmp/abs_evil.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("//tmp/abs_evil2.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("///tmp/abs_evil3.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("/./tmp/abs_evil4.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("//./tmp/abs_evil5.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("///./tmp/abs_evil6.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("/../tmp/rel_evil.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("../rel_evil2.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("./../rel_evil3.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("some/../../rel_evil4.txt", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append("././//./", &mut evil_txt_f)); + t!(evil_txt_f.seek(SeekFrom::Start(0))); + t!(a.append(".", &mut evil_txt_f)); + t!(a.finish()); + } + + t!(evil_tar.seek(SeekFrom::Start(0))); + let mut ar = Archive::new(&mut evil_tar); + t!(ar.unpack(td.path())); + + assert!(fs::metadata("/tmp/abs_evil.txt").is_err()); + assert!(fs::metadata("/tmp/abs_evil.txt2").is_err()); + assert!(fs::metadata("/tmp/abs_evil.txt3").is_err()); + assert!(fs::metadata("/tmp/abs_evil.txt4").is_err()); + assert!(fs::metadata("/tmp/abs_evil.txt5").is_err()); + assert!(fs::metadata("/tmp/abs_evil.txt6").is_err()); + assert!(fs::metadata("/tmp/rel_evil.txt").is_err()); + assert!(fs::metadata("/tmp/rel_evil.txt").is_err()); + assert!(fs::metadata(td.path().join("../tmp/rel_evil.txt")).is_err()); + assert!(fs::metadata(td.path().join("../rel_evil2.txt")).is_err()); + assert!(fs::metadata(td.path().join("../rel_evil3.txt")).is_err()); + assert!(fs::metadata(td.path().join("../rel_evil4.txt")).is_err()); + + // The `some` subdirectory should not be created because the only + // filename that references this has '..'. + assert!(fs::metadata(td.path().join("some")).is_err()); + + // The `tmp` subdirectory should be created and within this + // subdirectory, there should be files named `abs_evil.txt` through + // `abs_evil6.txt`. + assert!(fs::metadata(td.path().join("tmp")).map(|m| m.is_dir()) + .unwrap_or(false)); + assert!(fs::metadata(td.path().join("tmp/abs_evil.txt")) + .map(|m| m.is_file()).unwrap_or(false)); + assert!(fs::metadata(td.path().join("tmp/abs_evil2.txt")) + .map(|m| m.is_file()).unwrap_or(false)); + assert!(fs::metadata(td.path().join("tmp/abs_evil3.txt")) + .map(|m| m.is_file()).unwrap_or(false)); + assert!(fs::metadata(td.path().join("tmp/abs_evil4.txt")) + .map(|m| m.is_file()).unwrap_or(false)); + assert!(fs::metadata(td.path().join("tmp/abs_evil5.txt")) + .map(|m| m.is_file()).unwrap_or(false)); + assert!(fs::metadata(td.path().join("tmp/abs_evil6.txt")) + .map(|m| m.is_file()).unwrap_or(false)); + } + + #[test] + fn octal_spaces() { + let rdr = Cursor::new(&include_bytes!("tests/spaces.tar")[..]); + let ar = Archive::new(rdr); + + let file = ar.files().unwrap().next().unwrap().unwrap(); + assert_eq!(file.mode().unwrap() & 0o777, 0o777); + assert_eq!(file.uid().unwrap(), 0); + assert_eq!(file.gid().unwrap(), 0); + assert_eq!(file.size, 2); + assert_eq!(file.mtime().unwrap(), 0o12440016664); + assert_eq!(file.header.cksum().unwrap(), 0o4253); + } + + #[test] + #[cfg(feature = "nightly")] + fn empty_filename() + { + let td = t!(TempDir::new("tar-rs")); + let rdr = Cursor::new(&include_bytes!("tests/empty_filename.tar")[..]); + let mut ar = Archive::new(rdr); + assert!(ar.unpack(td.path()).is_err()); + } +} diff --git a/deps/tar-0.2.14/src/tests/directory.tar b/deps/tar-0.2.14/src/tests/directory.tar new file mode 100644 index 0000000000000000000000000000000000000000..ec6867a4be3a84766e2b4d9dc8903abc66187359 GIT binary patch literal 10240 zcmeIxJq|)448ZZuo`M_DA|L0$r=t!&_58wOT!=2bnE3C~p&=!|w$;n@&=w^nX~{~` z_uNZ8#6pa!!BUB$ra2aIY5LDvgZp}`SLfvXI9^WcxZ|h#_~lPmsy|HMfIi@_=O5ah zSYH6<zs2HIzf5n_=bvM{>*4)}*Zt?c_4_X+i__^pYYqPV{+Hbr$n-z}0R#|0009IL lKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q3`d@C27|H#z_S literal 0 HcmV?d00001 diff --git a/deps/tar-0.2.14/src/tests/duplicate_dirs.tar b/deps/tar-0.2.14/src/tests/duplicate_dirs.tar new file mode 100644 index 0000000000000000000000000000000000000000..fc19b9d01a7cd6a3134b649faceb634e605ec22c GIT binary patch literal 2048 zcmeHFZ3=)e2;EV<K{j(8Cq@|reZW@tZ>yl_{~&1Z&vPo{`P46yG~M6|l@5qlGlPn3 z%)zLulS3{7O3k_^B1Qr%nb0WUbdv6$H@{jJq_wt_xs}N}FT*&>-El^tt?%E-$NQQi b4jBNC%BMr0_y6ntfBHDHxa>f7AgKd8zT`G5 literal 0 HcmV?d00001 diff --git a/deps/tar-0.2.14/src/tests/empty_filename.tar b/deps/tar-0.2.14/src/tests/empty_filename.tar new file mode 100644 index 0000000000000000000000000000000000000000..dd1c8a9fd5611c88405a307af267a15b302b8970 GIT binary patch literal 512 zcmZQzU|=XME=ep>Pyn)M0}Oz`+|-l-NEw=&8X(gkDG*>VG%_(UFfcMSH8)`}Ff=eT iF=tRPrHyk?O@(<rw=BiP$kZ5B5{XAgCn4ENb0z@&7ZLgZ literal 0 HcmV?d00001 diff --git a/deps/tar-0.2.14/src/tests/reading_files.tar b/deps/tar-0.2.14/src/tests/reading_files.tar new file mode 100644 index 0000000000000000000000000000000000000000..67e79ffdfe2d85519305dff62a70a9950058a1d1 GIT binary patch literal 10240 zcmeIxJqpAi5QgEYa|(|zX3flb45Zs?e_)Tl+NF>rg+hu~3&9V^;ep9AerZ`|Ny-s@ z(fwH?)!8J@4=Z6x9!u`#E<wk)Ch~oM@+$<%&+T{g-&ub2_QqMBTKmQg(^^-7wQIF@ zu{z?{=ilo5yDrRsTeI)&I<<D+Kd6QP0tg_000IagfB*srAb<b@2q1s}0tg_000Iag RfB*srAb<b@2p}*{;1AnQDR2M) literal 0 HcmV?d00001 diff --git a/deps/tar-0.2.14/src/tests/simple.tar b/deps/tar-0.2.14/src/tests/simple.tar new file mode 100644 index 0000000000000000000000000000000000000000..747ddf9d585753b8e6acf36086270a3523c56ab8 GIT binary patch literal 10240 zcmeIvJqmy@42IzxrAKJ1rst{R=Hw4}eA~^bqF_;YLm@*b3C|bh{j#Z4TS?7@&YpW7 z<r3!`b()_~^Ps9??E9yQY|9#FV<b-FUfOpxFa7=Stgmoe4)}Kdf&42(BSVEHPx23z z{3}Gm3Iq^9009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~fu9Q;-KH=t literal 0 HcmV?d00001 diff --git a/deps/tar-0.2.14/src/tests/spaces.tar b/deps/tar-0.2.14/src/tests/spaces.tar new file mode 100755 index 0000000000000000000000000000000000000000..68e2a519eebd0d751f17106db3a5722cfc76f223 GIT binary patch literal 2048 zcmYdfpgk}&FfcbaS71;80RuD|ENG-)Xk=nyU|?uwW@Z8uF)=bVR$wroz0*d#4T)SM UJ_tqwU^E0qLtr!nMq~&801;dXMF0Q* literal 0 HcmV?d00001 diff --git a/deps/term-0.2.9/.gitignore b/deps/term-0.2.9/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/term-0.2.9/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/term-0.2.9/.travis.yml b/deps/term-0.2.9/.travis.yml new file mode 100644 index 000000000..3a2aef7a0 --- /dev/null +++ b/deps/term-0.2.9/.travis.yml @@ -0,0 +1,25 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '<meta http-equiv=refresh content=0;url=term/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages + +env: + global: + secure: Na+sfNSVDR8SdK5lFIbhvPj6zU+0NBTbHgugcCzhDEkvkaO0GLMYdhD3g+yAOR2DjIgn2Jdv1TGJkfD3KTPut52mmxftLkeA9528zqsiLD00JbPj8S71BcHIytOyGth84u+GdpNBZRvt5Fd3Pz1OgoEEeP/3O6uMe52+3Um/oPw= +notifications: + email: + on_success: never diff --git a/deps/term-0.2.9/Cargo.toml b/deps/term-0.2.9/Cargo.toml new file mode 100644 index 000000000..df21e097b --- /dev/null +++ b/deps/term-0.2.9/Cargo.toml @@ -0,0 +1,20 @@ +[package] + +name = "term" +version = "0.2.9" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/term" +homepage = "https://github.com/rust-lang/term" +documentation = "http://doc.rust-lang.org/term" +description = """ +A terminal formatting library +""" + +[target.i686-pc-windows-gnu] +dependencies = { winapi = "0.1", kernel32-sys = "0.1" } +[target.x86_64-pc-windows-gnu] +dependencies = { winapi = "0.1", kernel32-sys = "0.1" } +[target.x86_64-pc-windows-msvc] +dependencies = { winapi = "0.1", kernel32-sys = "0.1" } diff --git a/deps/term-0.2.9/LICENSE-APACHE b/deps/term-0.2.9/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/term-0.2.9/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/term-0.2.9/LICENSE-MIT b/deps/term-0.2.9/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/term-0.2.9/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/term-0.2.9/README.md b/deps/term-0.2.9/README.md new file mode 100644 index 000000000..1453c197d --- /dev/null +++ b/deps/term-0.2.9/README.md @@ -0,0 +1,25 @@ +term +==== + +A Rust library for terminfo parsing and terminal colors. + +[![Build Status](https://travis-ci.org/rust-lang/term.svg?branch=master)](https://travis-ci.org/rust-lang/term) +[![Build status](https://ci.appveyor.com/api/projects/status/422c2ovagestqw89?svg=true)](https://ci.appveyor.com/project/alexcrichton/term) + +[Documentation](http://doc.rust-lang.org/term) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] + +term = "*" +``` + +and this to your crate root: + +```rust +extern crate term; +``` diff --git a/deps/term-0.2.9/appveyor.yml b/deps/term-0.2.9/appveyor.yml new file mode 100644 index 000000000..b3ec520a2 --- /dev/null +++ b/deps/term-0.2.9/appveyor.yml @@ -0,0 +1,23 @@ +environment: + CARGO_TARGET: x86_64-pc-windows-gnu + matrix: + - TARGET: x86_64-pc-windows-msvc + - TARGET: i686-pc-windows-gnu +install: + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rustc-nightly-${env:TARGET}.tar.gz" + - ps: Start-FileDownload "https://static.rust-lang.org/cargo-dist/cargo-nightly-${env:CARGO_TARGET}.tar.gz" + - 7z x rustc-nightly-%TARGET%.tar.gz > nul + - 7z x rustc-nightly-%TARGET%.tar > nul + - 7z x cargo-nightly-%CARGO_TARGET%.tar.gz > nul + - 7z x cargo-nightly-%CARGO_TARGET%.tar > nul + - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 + - set PATH=%PATH%;%cd%/rustc-nightly-%TARGET%/rustc/bin + - set PATH=%PATH%;%cd%/cargo-nightly-%CARGO_TARGET%/cargo/bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/term-0.2.9/src/lib.rs b/deps/term-0.2.9/src/lib.rs new file mode 100644 index 000000000..ea4a10bcb --- /dev/null +++ b/deps/term-0.2.9/src/lib.rs @@ -0,0 +1,247 @@ +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Terminal formatting library. +//! +//! This crate provides the `Terminal` trait, which abstracts over an [ANSI +//! Terminal][ansi] to provide color printing, among other things. There are two +//! implementations, the `TerminfoTerminal`, which uses control characters from +//! a [terminfo][ti] database, and `WinConsole`, which uses the [Win32 Console +//! API][win]. +//! +//! # Usage +//! +//! This crate is [on crates.io](https://crates.io/crates/term) and can be +//! used by adding `term` to the dependencies in your project's `Cargo.toml`. +//! +//! ```toml +//! [dependencies] +//! +//! term = "0.2" +//! ``` +//! +//! and this to your crate root: +//! +//! ```rust +//! extern crate term; +//! ``` +//! +//! # Examples +//! +//! ```no_run +//! extern crate term; +//! use std::io::prelude::*; +//! +//! fn main() { +//! let mut t = term::stdout().unwrap(); +//! +//! t.fg(term::color::GREEN).unwrap(); +//! (write!(t, "hello, ")).unwrap(); +//! +//! t.fg(term::color::RED).unwrap(); +//! (writeln!(t, "world!")).unwrap(); +//! +//! assert!(t.reset().unwrap()); +//! } +//! ``` +//! +//! [ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code +//! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx +//! [ti]: https://en.wikipedia.org/wiki/Terminfo + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/nightly/", + html_playground_url = "http://play.rust-lang.org/")] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] +#![cfg_attr(rust_build, feature(staged_api))] +#![cfg_attr(rust_build, staged_api)] +#![cfg_attr(rust_build, + unstable(feature = "rustc_private", + reason = "use the crates.io `term` library instead"))] + +use std::io::prelude::*; + +pub use terminfo::TerminfoTerminal; +#[cfg(windows)] +pub use win::WinConsole; + +use std::io::{self, Stdout, Stderr}; + +pub mod terminfo; + +#[cfg(windows)] +mod win; + +/// Alias for stdout terminals. +pub type StdoutTerminal = Terminal<Output=Stdout> + Send; +/// Alias for stderr terminals. +pub type StderrTerminal = Terminal<Output=Stderr> + Send; + +#[cfg(not(windows))] +/// Return a Terminal wrapping stdout, or None if a terminal couldn't be +/// opened. +pub fn stdout() -> Option<Box<StdoutTerminal>> { + TerminfoTerminal::new(io::stdout()).map(|t| { + Box::new(t) as Box<StdoutTerminal> + }) +} + +#[cfg(windows)] +/// Return a Terminal wrapping stdout, or None if a terminal couldn't be +/// opened. +pub fn stdout() -> Option<Box<StdoutTerminal>> { + TerminfoTerminal::new(io::stdout()).map(|t| { + Box::new(t) as Box<StdoutTerminal> + }).or_else(|| WinConsole::new(io::stdout()).ok().map(|t| { + Box::new(t) as Box<StdoutTerminal> + })) +} + +#[cfg(not(windows))] +/// Return a Terminal wrapping stderr, or None if a terminal couldn't be +/// opened. +pub fn stderr() -> Option<Box<StderrTerminal>> { + TerminfoTerminal::new(io::stderr()).map(|t| { + Box::new(t) as Box<StderrTerminal> + }) +} + +#[cfg(windows)] +/// Return a Terminal wrapping stderr, or None if a terminal couldn't be +/// opened. +pub fn stderr() -> Option<Box<StderrTerminal>> { + TerminfoTerminal::new(io::stderr()).map(|t| { + Box::new(t) as Box<StderrTerminal> + }).or_else(|| WinConsole::new(io::stderr()).ok().map(|t| { + Box::new(t) as Box<StderrTerminal> + })) +} + + +/// Terminal color definitions +pub mod color { + /// Number for a terminal color + pub type Color = u16; + + pub const BLACK: Color = 0; + pub const RED: Color = 1; + pub const GREEN: Color = 2; + pub const YELLOW: Color = 3; + pub const BLUE: Color = 4; + pub const MAGENTA: Color = 5; + pub const CYAN: Color = 6; + pub const WHITE: Color = 7; + + pub const BRIGHT_BLACK: Color = 8; + pub const BRIGHT_RED: Color = 9; + pub const BRIGHT_GREEN: Color = 10; + pub const BRIGHT_YELLOW: Color = 11; + pub const BRIGHT_BLUE: Color = 12; + pub const BRIGHT_MAGENTA: Color = 13; + pub const BRIGHT_CYAN: Color = 14; + pub const BRIGHT_WHITE: Color = 15; +} + +/// Terminal attributes for use with term.attr(). +/// +/// Most attributes can only be turned on and must be turned off with term.reset(). +/// The ones that can be turned off explicitly take a boolean value. +/// Color is also represented as an attribute for convenience. +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub enum Attr { + /// Bold (or possibly bright) mode + Bold, + /// Dim mode, also called faint or half-bright. Often not supported + Dim, + /// Italics mode. Often not supported + Italic(bool), + /// Underline mode + Underline(bool), + /// Blink mode + Blink, + /// Standout mode. Often implemented as Reverse, sometimes coupled with Bold + Standout(bool), + /// Reverse mode, inverts the foreground and background colors + Reverse, + /// Secure mode, also called invis mode. Hides the printed text + Secure, + /// Convenience attribute to set the foreground color + ForegroundColor(color::Color), + /// Convenience attribute to set the background color + BackgroundColor(color::Color) +} + +/// A terminal with similar capabilities to an ANSI Terminal +/// (foreground/background colors etc). +pub trait Terminal: Write { + /// The terminal's output writer type. + type Output: Write; + + /// Sets the foreground color to the given color. + /// + /// If the color is a bright color, but the terminal only supports 8 colors, + /// the corresponding normal color will be used instead. + /// + /// Returns `Ok(true)` if the color was set, `Ok(false)` otherwise, and `Err(e)` + /// if there was an I/O error. + fn fg(&mut self, color: color::Color) -> io::Result<bool>; + + /// Sets the background color to the given color. + /// + /// If the color is a bright color, but the terminal only supports 8 colors, + /// the corresponding normal color will be used instead. + /// + /// Returns `Ok(true)` if the color was set, `Ok(false)` otherwise, and `Err(e)` + /// if there was an I/O error. + fn bg(&mut self, color: color::Color) -> io::Result<bool>; + + /// Sets the given terminal attribute, if supported. Returns `Ok(true)` + /// if the attribute was supported, `Ok(false)` otherwise, and `Err(e)` if + /// there was an I/O error. + fn attr(&mut self, attr: Attr) -> io::Result<bool>; + + /// Returns whether the given terminal attribute is supported. + fn supports_attr(&self, attr: Attr) -> bool; + + /// Resets all terminal attributes and color to the default. + /// + /// Returns `Ok(true)` if the terminal was reset, `Ok(false)` otherwise, and `Err(e)` if there + /// was an I/O error. + fn reset(&mut self) -> io::Result<bool>; + + /// Moves the cursor up one line. + /// + /// Returns `Ok(true)` if the cursor was moved, `Ok(false)` otherwise, and `Err(e)` + /// if there was an I/O error. + fn cursor_up(&mut self) -> io::Result<bool>; + + /// Deletes the text from the cursor location to the end of the line. + /// + /// Returns `Ok(true)` if the text was deleted, `Ok(false)` otherwise, and `Err(e)` + /// if there was an I/O error. + fn delete_line(&mut self) -> io::Result<bool>; + + /// Moves the cursor to the left edge of the current line. + /// + /// Returns `Ok(true)` if the text was deleted, `Ok(false)` otherwise, and `Err(e)` + /// if there was an I/O error. + fn carriage_return(&mut self) -> io::Result<bool>; + + /// Gets an immutable reference to the stream inside + fn get_ref<'a>(&'a self) -> &'a Self::Output; + + /// Gets a mutable reference to the stream inside + fn get_mut<'a>(&'a mut self) -> &'a mut Self::Output; + + /// Returns the contained stream, destroying the `Terminal` + fn into_inner(self) -> Self::Output where Self: Sized; +} diff --git a/deps/term-0.2.9/src/terminfo/mod.rs b/deps/term-0.2.9/src/terminfo/mod.rs new file mode 100644 index 000000000..36289fd32 --- /dev/null +++ b/deps/term-0.2.9/src/terminfo/mod.rs @@ -0,0 +1,275 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Terminfo database interface. + +use std::collections::HashMap; +use std::env; +use std::error; +use std::fmt; +use std::fs::File; +use std::io::prelude::*; +use std::io; +use std::path::Path; + +use Attr; +use color; +use Terminal; +use self::searcher::get_dbpath_for_term; +use self::parser::compiled::{parse, msys_terminfo}; +use self::parm::{expand, Variables, Param}; + + +/// A parsed terminfo database entry. +#[derive(Debug)] +pub struct TermInfo { + /// Names for the terminal + pub names: Vec<String> , + /// Map of capability name to boolean value + pub bools: HashMap<String, bool>, + /// Map of capability name to numeric value + pub numbers: HashMap<String, u16>, + /// Map of capability name to raw (unexpanded) string + pub strings: HashMap<String, Vec<u8> > +} + +/// A terminfo creation error. +#[derive(Debug)] +pub enum Error { + /// TermUnset Indicates that the environment doesn't include enough information to find + /// the terminfo entry. + TermUnset, + /// MalformedTerminfo indicates that parsing the terminfo entry failed. + MalformedTerminfo(String), + /// io::Error forwards any io::Errors encountered when finding or reading the terminfo entry. + IoError(io::Error), +} + +impl error::Error for Error { + fn description(&self) -> &str { "failed to create TermInfo" } + + fn cause(&self) -> Option<&error::Error> { + use self::Error::*; + match self { + &IoError(ref e) => Some(e), + _ => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::Error::*; + match self { + &TermUnset => Ok(()), + &MalformedTerminfo(ref e) => e.fmt(f), + &IoError(ref e) => e.fmt(f), + } + } +} + +impl TermInfo { + /// Create a TermInfo based on current environment. + pub fn from_env() -> Result<TermInfo, Error> { + let term = match env::var("TERM") { + Ok(name) => TermInfo::from_name(&name), + Err(..) => return Err(Error::TermUnset), + }; + + if term.is_err() && env::var("MSYSCON").ok().map_or(false, |s| "mintty.exe" == s) { + // msys terminal + Ok(msys_terminfo()) + } else { + term + } + } + + /// Create a TermInfo for the named terminal. + pub fn from_name(name: &str) -> Result<TermInfo, Error> { + get_dbpath_for_term(name).ok_or_else(|| { + Error::IoError(io::Error::new(io::ErrorKind::NotFound, + "terminfo file not found")) + }).and_then(|p| { + TermInfo::from_path(&p) + }) + } + + /// Parse the given TermInfo. + pub fn from_path(path: &Path) -> Result<TermInfo, Error> { + File::open(path).map_err(|e| { + Error::IoError(e) + }).and_then(|ref mut file| { + parse(file, false).map_err(|e| { + Error::MalformedTerminfo(e) + }) + }) + } +} + +pub mod searcher; + +/// TermInfo format parsing. +pub mod parser { + //! ncurses-compatible compiled terminfo format parsing (term(5)) + pub mod compiled; +} +pub mod parm; + + +fn cap_for_attr(attr: Attr) -> &'static str { + match attr { + Attr::Bold => "bold", + Attr::Dim => "dim", + Attr::Italic(true) => "sitm", + Attr::Italic(false) => "ritm", + Attr::Underline(true) => "smul", + Attr::Underline(false) => "rmul", + Attr::Blink => "blink", + Attr::Standout(true) => "smso", + Attr::Standout(false) => "rmso", + Attr::Reverse => "rev", + Attr::Secure => "invis", + Attr::ForegroundColor(_) => "setaf", + Attr::BackgroundColor(_) => "setab" + } +} + +/// A Terminal that knows how many colors it supports, with a reference to its +/// parsed Terminfo database record. +pub struct TerminfoTerminal<T> { + num_colors: u16, + out: T, + ti: TermInfo, +} + +impl<T: Write+Send> Terminal for TerminfoTerminal<T> { + type Output = T; + fn fg(&mut self, color: color::Color) -> io::Result<bool> { + let color = self.dim_if_necessary(color); + if self.num_colors > color { + return self.apply_cap("setaf", &[Param::Number(color as i16)]); + } + Ok(false) + } + + fn bg(&mut self, color: color::Color) -> io::Result<bool> { + let color = self.dim_if_necessary(color); + if self.num_colors > color { + return self.apply_cap("setab", &[Param::Number(color as i16)]); + } + Ok(false) + } + + fn attr(&mut self, attr: Attr) -> io::Result<bool> { + match attr { + Attr::ForegroundColor(c) => self.fg(c), + Attr::BackgroundColor(c) => self.bg(c), + _ => self.apply_cap(cap_for_attr(attr), &[]), + } + } + + fn supports_attr(&self, attr: Attr) -> bool { + match attr { + Attr::ForegroundColor(_) | Attr::BackgroundColor(_) => { + self.num_colors > 0 + } + _ => { + let cap = cap_for_attr(attr); + self.ti.strings.get(cap).is_some() + } + } + } + + fn reset(&mut self) -> io::Result<bool> { + // are there any terminals that have color/attrs and not sgr0? + // Try falling back to sgr, then op + let cmd = match [ + "sg0", "sgr", "op" + ].iter().filter_map(|cap| { + self.ti.strings.get(*cap) + }).next() { + Some(op) => match expand(&op, &[], &mut Variables::new()) { + Ok(cmd) => cmd, + Err(_) => return Ok(false), + }, + None => return Ok(false), + }; + + self.out.write_all(&cmd).map(|_|true) + } + + fn cursor_up(&mut self) -> io::Result<bool> { + self.apply_cap("cuu1", &[]) + } + + fn delete_line(&mut self) -> io::Result<bool> { + self.apply_cap("dl", &[]) + } + + fn carriage_return(&mut self) -> io::Result<bool> { + self.apply_cap("cr", &[]) + } + + fn get_ref<'a>(&'a self) -> &'a T { &self.out } + + fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.out } + + fn into_inner(self) -> T where Self: Sized { self.out } +} + +impl<T: Write+Send> TerminfoTerminal<T> { + /// Create a new TerminfoTerminal with the given TermInfo and Write. + pub fn new_with_terminfo(out: T, terminfo: TermInfo) -> TerminfoTerminal<T> { + let nc = if terminfo.strings.contains_key("setaf") + && terminfo.strings.contains_key("setab") { + terminfo.numbers.get("colors").map_or(0, |&n| n) + } else { 0 }; + + TerminfoTerminal { + out: out, + ti: terminfo, + num_colors: nc, + } + } + + /// Create a new TerminfoTerminal for the current environment with the given Write. + /// + /// Returns `None` when the terminfo cannot be found or parsed. + pub fn new(out: T) -> Option<TerminfoTerminal<T>> { + TermInfo::from_env().map(move |ti| TerminfoTerminal::new_with_terminfo(out, ti)).ok() + } + + fn dim_if_necessary(&self, color: color::Color) -> color::Color { + if color >= self.num_colors && color >= 8 && color < 16 { + color-8 + } else { color } + } + + fn apply_cap(&mut self, cmd: &str, params: &[Param]) -> io::Result<bool> { + if let Some(cmd) = self.ti.strings.get(cmd) { + if let Ok(s) = expand(&cmd, params, &mut Variables::new()) { + try!(self.out.write_all(&s)); + return Ok(true) + } + } + Ok(false) + } +} + + +impl<T: Write> Write for TerminfoTerminal<T> { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.out.write(buf) + } + + fn flush(&mut self) -> io::Result<()> { + self.out.flush() + } +} diff --git a/deps/term-0.2.9/src/terminfo/parm.rs b/deps/term-0.2.9/src/terminfo/parm.rs new file mode 100644 index 000000000..170611133 --- /dev/null +++ b/deps/term-0.2.9/src/terminfo/parm.rs @@ -0,0 +1,707 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Parameterized string expansion + +use self::Param::*; +use self::States::*; +use self::FormatState::*; +use self::FormatOp::*; + +use std::ascii::AsciiExt; +use std::iter::repeat; +use std::mem::replace; + +#[derive(Clone, Copy, PartialEq)] +enum States { + Nothing, + Percent, + SetVar, + GetVar, + PushParam, + CharConstant, + CharClose, + IntConstant(i16), + FormatPattern(Flags, FormatState), + SeekIfElse(usize), + SeekIfElsePercent(usize), + SeekIfEnd(usize), + SeekIfEndPercent(usize) +} + +#[derive(Copy, PartialEq, Clone)] +enum FormatState { + FormatStateFlags, + FormatStateWidth, + FormatStatePrecision +} + +/// Types of parameters a capability can use +#[allow(missing_docs)] +#[derive(Clone)] +pub enum Param { + Words(String), + Number(i16) +} + +/// Container for static and dynamic variable arrays +pub struct Variables { + /// Static variables A-Z + sta: [Param; 26], + /// Dynamic variables a-z + dyn: [Param; 26] +} + +impl Variables { + /// Return a new zero-initialized Variables + pub fn new() -> Variables { + Variables { + sta: [ + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), + ], + dyn: [ + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), + ], + } + } +} + +/// Expand a parameterized capability +/// +/// # Arguments +/// * `cap` - string to expand +/// * `params` - vector of params for %p1 etc +/// * `vars` - Variables struct for %Pa etc +/// +/// To be compatible with ncurses, `vars` should be the same between calls to `expand` for +/// multiple capabilities for the same terminal. +pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) + -> Result<Vec<u8> , String> { + let mut state = Nothing; + + // expanded cap will only rarely be larger than the cap itself + let mut output = Vec::with_capacity(cap.len()); + + let mut stack: Vec<Param> = Vec::new(); + + // Copy parameters into a local vector for mutability + let mut mparams = [ + Number(0), Number(0), Number(0), Number(0), Number(0), + Number(0), Number(0), Number(0), Number(0), + ]; + for (dst, src) in mparams.iter_mut().zip(params.iter()) { + *dst = (*src).clone(); + } + + for &c in cap.iter() { + let cur = c as char; + let mut old_state = state; + match state { + Nothing => { + if cur == '%' { + state = Percent; + } else { + output.push(c); + } + }, + Percent => { + match cur { + '%' => { output.push(c); state = Nothing }, + 'c' => if stack.len() > 0 { + match stack.pop().unwrap() { + // if c is 0, use 0200 (128) for ncurses compatibility + Number(c) => { + output.push(if c == 0 { + 128u8 + } else { + c as u8 + }) + } + _ => return Err("a non-char was used with %c".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + 'p' => state = PushParam, + 'P' => state = SetVar, + 'g' => state = GetVar, + '\'' => state = CharConstant, + '{' => state = IntConstant(0), + 'l' => if stack.len() > 0 { + match stack.pop().unwrap() { + Words(s) => stack.push(Number(s.len() as i16)), + _ => return Err("a non-str was used with %l".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '+' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x + y)), + _ => return Err("non-numbers on stack with +".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '-' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x - y)), + _ => return Err("non-numbers on stack with -".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '*' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x * y)), + _ => return Err("non-numbers on stack with *".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '/' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x / y)), + _ => return Err("non-numbers on stack with /".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + 'm' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x % y)), + _ => return Err("non-numbers on stack with %".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '&' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x & y)), + _ => return Err("non-numbers on stack with &".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '|' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x | y)), + _ => return Err("non-numbers on stack with |".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '^' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(x ^ y)), + _ => return Err("non-numbers on stack with ^".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '=' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(if x == y { 1 } + else { 0 })), + _ => return Err("non-numbers on stack with =".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '>' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(if x > y { 1 } + else { 0 })), + _ => return Err("non-numbers on stack with >".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '<' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(y), Number(x)) => stack.push(Number(if x < y { 1 } + else { 0 })), + _ => return Err("non-numbers on stack with <".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + 'A' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(0), Number(_)) => stack.push(Number(0)), + (Number(_), Number(0)) => stack.push(Number(0)), + (Number(_), Number(_)) => stack.push(Number(1)), + _ => return Err("non-numbers on stack with logical and".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + 'O' => if stack.len() > 1 { + match (stack.pop().unwrap(), stack.pop().unwrap()) { + (Number(0), Number(0)) => stack.push(Number(0)), + (Number(_), Number(_)) => stack.push(Number(1)), + _ => return Err("non-numbers on stack with logical or".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '!' => if stack.len() > 0 { + match stack.pop().unwrap() { + Number(0) => stack.push(Number(1)), + Number(_) => stack.push(Number(0)), + _ => return Err("non-number on stack with logical not".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + '~' => if stack.len() > 0 { + match stack.pop().unwrap() { + Number(x) => stack.push(Number(!x)), + _ => return Err("non-number on stack with %~".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + 'i' => match (mparams[0].clone(), mparams[1].clone()) { + (Number(x), Number(y)) => { + mparams[0] = Number(x+1); + mparams[1] = Number(y+1); + }, + (_, _) => return Err("first two params not numbers with %i".to_string()) + }, + + // printf-style support for %doxXs + 'd'|'o'|'x'|'X'|'s' => if stack.len() > 0 { + let flags = Flags::new(); + let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), flags); + if res.is_err() { return res } + output.extend(res.unwrap().iter().map(|x| *x)) + } else { return Err("stack is empty".to_string()) }, + ':'|'#'|' '|'.'|'0'...'9' => { + let mut flags = Flags::new(); + let mut fstate = FormatStateFlags; + match cur { + ':' => (), + '#' => flags.alternate = true, + ' ' => flags.space = true, + '.' => fstate = FormatStatePrecision, + '0'...'9' => { + flags.width = cur as usize - '0' as usize; + fstate = FormatStateWidth; + } + _ => unreachable!() + } + state = FormatPattern(flags, fstate); + } + + // conditionals + '?' => (), + 't' => if stack.len() > 0 { + match stack.pop().unwrap() { + Number(0) => state = SeekIfElse(0), + Number(_) => (), + _ => return Err("non-number on stack \ + with conditional".to_string()) + } + } else { return Err("stack is empty".to_string()) }, + 'e' => state = SeekIfEnd(0), + ';' => (), + + _ => { + return Err(format!("unrecognized format option {}", cur)) + } + } + }, + PushParam => { + // params are 1-indexed + stack.push(mparams[match cur.to_digit(10) { + Some(d) => d as usize - 1, + None => return Err("bad param number".to_string()) + }].clone()); + }, + SetVar => { + if cur >= 'A' && cur <= 'Z' { + if stack.len() > 0 { + let idx = (cur as u8) - b'A'; + vars.sta[idx as usize] = stack.pop().unwrap(); + } else { return Err("stack is empty".to_string()) } + } else if cur >= 'a' && cur <= 'z' { + if stack.len() > 0 { + let idx = (cur as u8) - b'a'; + vars.dyn[idx as usize] = stack.pop().unwrap(); + } else { return Err("stack is empty".to_string()) } + } else { + return Err("bad variable name in %P".to_string()); + } + }, + GetVar => { + if cur >= 'A' && cur <= 'Z' { + let idx = (cur as u8) - b'A'; + stack.push(vars.sta[idx as usize].clone()); + } else if cur >= 'a' && cur <= 'z' { + let idx = (cur as u8) - b'a'; + stack.push(vars.dyn[idx as usize].clone()); + } else { + return Err("bad variable name in %g".to_string()); + } + }, + CharConstant => { + stack.push(Number(c as i16)); + state = CharClose; + }, + CharClose => { + if cur != '\'' { + return Err("malformed character constant".to_string()); + } + }, + IntConstant(i) => { + if cur == '}' { + stack.push(Number(i)); + state = Nothing; + } else if let Some(digit) = cur.to_digit(10) { + match i.checked_mul(10).and_then(|i_ten|i_ten.checked_add(digit as i16)) { + Some(i) => { + state = IntConstant(i); + old_state = Nothing; + } + None => return Err("int constant too large".to_string()) + } + } else { + return Err("bad int constant".to_string()); + } + } + FormatPattern(ref mut flags, ref mut fstate) => { + old_state = Nothing; + match (*fstate, cur) { + (_,'d')|(_,'o')|(_,'x')|(_,'X')|(_,'s') => if stack.len() > 0 { + let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), *flags); + if res.is_err() { return res } + output.extend(res.unwrap().iter().map(|x| *x)); + // will cause state to go to Nothing + old_state = FormatPattern(*flags, *fstate); + } else { return Err("stack is empty".to_string()) }, + (FormatStateFlags,'#') => { + flags.alternate = true; + } + (FormatStateFlags,'-') => { + flags.left = true; + } + (FormatStateFlags,'+') => { + flags.sign = true; + } + (FormatStateFlags,' ') => { + flags.space = true; + } + (FormatStateFlags,'0'...'9') => { + flags.width = cur as usize - '0' as usize; + *fstate = FormatStateWidth; + } + (FormatStateFlags,'.') => { + *fstate = FormatStatePrecision; + } + (FormatStateWidth,'0'...'9') => { + let old = flags.width; + flags.width = flags.width * 10 + (cur as usize - '0' as usize); + if flags.width < old { return Err("format width overflow".to_string()) } + } + (FormatStateWidth,'.') => { + *fstate = FormatStatePrecision; + } + (FormatStatePrecision,'0'...'9') => { + let old = flags.precision; + flags.precision = flags.precision * 10 + (cur as usize - '0' as usize); + if flags.precision < old { + return Err("format precision overflow".to_string()) + } + } + _ => return Err("invalid format specifier".to_string()) + } + } + SeekIfElse(level) => { + if cur == '%' { + state = SeekIfElsePercent(level); + } + old_state = Nothing; + } + SeekIfElsePercent(level) => { + if cur == ';' { + if level == 0 { + state = Nothing; + } else { + state = SeekIfElse(level-1); + } + } else if cur == 'e' && level == 0 { + state = Nothing; + } else if cur == '?' { + state = SeekIfElse(level+1); + } else { + state = SeekIfElse(level); + } + } + SeekIfEnd(level) => { + if cur == '%' { + state = SeekIfEndPercent(level); + } + old_state = Nothing; + } + SeekIfEndPercent(level) => { + if cur == ';' { + if level == 0 { + state = Nothing; + } else { + state = SeekIfEnd(level-1); + } + } else if cur == '?' { + state = SeekIfEnd(level+1); + } else { + state = SeekIfEnd(level); + } + } + } + if state == old_state { + state = Nothing; + } + } + Ok(output) +} + +#[derive(Copy, PartialEq, Clone)] +struct Flags { + width: usize, + precision: usize, + alternate: bool, + left: bool, + sign: bool, + space: bool +} + +impl Flags { + fn new() -> Flags { + Flags{ width: 0, precision: 0, alternate: false, + left: false, sign: false, space: false } + } +} + +#[derive(Copy, Clone)] +enum FormatOp { + FormatDigit, + FormatOctal, + FormatHex, + FormatHEX, + FormatString +} + +impl FormatOp { + fn from_char(c: char) -> FormatOp { + match c { + 'd' => FormatDigit, + 'o' => FormatOctal, + 'x' => FormatHex, + 'X' => FormatHEX, + 's' => FormatString, + _ => panic!("bad FormatOp char") + } + } + fn to_char(self) -> char { + match self { + FormatDigit => 'd', + FormatOctal => 'o', + FormatHex => 'x', + FormatHEX => 'X', + FormatString => 's' + } + } +} + +fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> { + let mut s = match val { + Number(d) => { + let s = match (op, flags.sign) { + (FormatDigit, true) => format!("{:+}", d), + (FormatDigit, false) => format!("{}", d), + (FormatOctal, _) => format!("{:o}", d), + (FormatHex, _) => format!("{:x}", d), + (FormatHEX, _) => format!("{:X}", d), + (FormatString, _) => return Err("non-number on stack with %s".to_string()) + }; + + let mut s: Vec<u8> = s.into_bytes().into_iter().collect(); + if flags.precision > s.len() { + let mut s_ = Vec::with_capacity(flags.precision); + let n = flags.precision - s.len(); + s_.extend(repeat(b'0').take(n)); + s_.extend(s.into_iter()); + s = s_; + } + assert!(!s.is_empty(), "string conversion produced empty result"); + match op { + FormatDigit => { + if flags.space && !(s[0] == b'-' || s[0] == b'+' ) { + s.insert(0, b' '); + } + } + FormatOctal => { + if flags.alternate && s[0] != b'0' { + s.insert(0, b'0'); + } + } + FormatHex => { + if flags.alternate { + let s_ = replace(&mut s, vec!(b'0', b'x')); + s.extend(s_.into_iter()); + } + } + FormatHEX => { + s = s.to_ascii_uppercase(); + if flags.alternate { + let s_ = replace(&mut s, vec!(b'0', b'X')); + s.extend(s_.into_iter()); + } + } + FormatString => unreachable!() + } + s + } + Words(s) => { + match op { + FormatString => { + let mut s = s.as_bytes().to_vec(); + if flags.precision > 0 && flags.precision < s.len() { + s.truncate(flags.precision); + } + s + } + _ => { + return Err(format!("non-string on stack with %{}", + op.to_char())) + } + } + } + }; + if flags.width > s.len() { + let n = flags.width - s.len(); + if flags.left { + s.extend(repeat(b' ').take(n)); + } else { + let mut s_ = Vec::with_capacity(flags.width); + s_.extend(repeat(b' ').take(n)); + s_.extend(s.into_iter()); + s = s_; + } + } + Ok(s) +} + +#[cfg(test)] +mod test { + use super::{expand, Variables}; + use super::Param::{self, Words, Number}; + use std::result::Result::Ok; + + #[test] + fn test_basic_setabf() { + let s = b"\\E[48;5;%p1%dm"; + assert_eq!(expand(s, &[Number(1)], &mut Variables::new()).unwrap(), + "\\E[48;5;1m".bytes().collect::<Vec<_>>()); + } + + #[test] + fn test_multiple_int_constants() { + assert_eq!(expand(b"%{1}%{2}%d%d", &[], &mut Variables::new()).unwrap(), + "21".bytes().collect::<Vec<_>>()); + } + + #[test] + fn test_op_i() { + let mut vars = Variables::new(); + assert_eq!(expand(b"%p1%d%p2%d%p3%d%i%p1%d%p2%d%p3%d", + &[Number(1),Number(2),Number(3)], &mut vars), + Ok("123233".bytes().collect::<Vec<_>>())); + assert_eq!(expand(b"%p1%d%p2%d%i%p1%d%p2%d", &[], &mut vars), + Ok("0011".bytes().collect::<Vec<_>>())); + } + + #[test] + fn test_param_stack_failure_conditions() { + let mut varstruct = Variables::new(); + let vars = &mut varstruct; + fn get_res(fmt: &str, cap: &str, params: &[Param], vars: &mut Variables) -> + Result<Vec<u8>, String> + { + let mut u8v: Vec<_> = fmt.bytes().collect(); + u8v.extend(cap.as_bytes().iter().map(|&b| b)); + expand(&u8v, params, vars) + } + + let caps = ["%d", "%c", "%s", "%Pa", "%l", "%!", "%~"]; + for &cap in caps.iter() { + let res = get_res("", cap, &[], vars); + assert!(res.is_err(), + "Op {} succeeded incorrectly with 0 stack entries", cap); + let p = if cap == "%s" || cap == "%l" { + Words("foo".to_string()) + } else { + Number(97) + }; + let res = get_res("%p1", cap, &[p], vars); + assert!(res.is_ok(), + "Op {} failed with 1 stack entry: {}", cap, res.err().unwrap()); + } + let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"]; + for &cap in caps.iter() { + let res = expand(cap.as_bytes(), &[], vars); + assert!(res.is_err(), + "Binop {} succeeded incorrectly with 0 stack entries", cap); + let res = get_res("%{1}", cap, &[], vars); + assert!(res.is_err(), + "Binop {} succeeded incorrectly with 1 stack entry", cap); + let res = get_res("%{1}%{2}", cap, &[], vars); + assert!(res.is_ok(), + "Binop {} failed with 2 stack entries: {}", cap, res.err().unwrap()); + } + } + + #[test] + fn test_push_bad_param() { + assert!(expand(b"%pa", &[], &mut Variables::new()).is_err()); + } + + #[test] + fn test_comparison_ops() { + let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])]; + for &(op, bs) in v.iter() { + let s = format!("%{{1}}%{{2}}%{}%d", op); + let res = expand(s.as_bytes(), &[], &mut Variables::new()); + assert!(res.is_ok(), res.err().unwrap()); + assert_eq!(res.unwrap(), vec!(b'0' + bs[0])); + let s = format!("%{{1}}%{{1}}%{}%d", op); + let res = expand(s.as_bytes(), &[], &mut Variables::new()); + assert!(res.is_ok(), res.err().unwrap()); + assert_eq!(res.unwrap(), vec!(b'0' + bs[1])); + let s = format!("%{{2}}%{{1}}%{}%d", op); + let res = expand(s.as_bytes(), &[], &mut Variables::new()); + assert!(res.is_ok(), res.err().unwrap()); + assert_eq!(res.unwrap(), vec!(b'0' + bs[2])); + } + } + + #[test] + fn test_conditionals() { + let mut vars = Variables::new(); + let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"; + let res = expand(s, &[Number(1)], &mut vars); + assert!(res.is_ok(), res.err().unwrap()); + assert_eq!(res.unwrap(), + "\\E[31m".bytes().collect::<Vec<_>>()); + let res = expand(s, &[Number(8)], &mut vars); + assert!(res.is_ok(), res.err().unwrap()); + assert_eq!(res.unwrap(), + "\\E[90m".bytes().collect::<Vec<_>>()); + let res = expand(s, &[Number(42)], &mut vars); + assert!(res.is_ok(), res.err().unwrap()); + assert_eq!(res.unwrap(), + "\\E[38;5;42m".bytes().collect::<Vec<_>>()); + } + + #[test] + fn test_format() { + let mut varstruct = Variables::new(); + let vars = &mut varstruct; + assert_eq!(expand(b"%p1%s%p2%2s%p3%2s%p4%.2s", + &[Words("foo".to_string()), + Words("foo".to_string()), + Words("f".to_string()), + Words("foo".to_string())], vars), + Ok("foofoo ffo".bytes().collect::<Vec<_>>())); + assert_eq!(expand(b"%p1%:-4.2s", &[Words("foo".to_string())], vars), + Ok("fo ".bytes().collect::<Vec<_>>())); + + assert_eq!(expand(b"%p1%d%p1%.3d%p1%5d%p1%:+d", &[Number(1)], vars), + Ok("1001 1+1".bytes().collect::<Vec<_>>())); + assert_eq!(expand(b"%p1%o%p1%#o%p2%6.4x%p2%#6.4X", &[Number(15), Number(27)], vars), + Ok("17017 001b0X001B".bytes().collect::<Vec<_>>())); + } +} diff --git a/deps/term-0.2.9/src/terminfo/parser/compiled.rs b/deps/term-0.2.9/src/terminfo/parser/compiled.rs new file mode 100644 index 000000000..2cf4a4ecb --- /dev/null +++ b/deps/term-0.2.9/src/terminfo/parser/compiled.rs @@ -0,0 +1,359 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +//! ncurses-compatible compiled terminfo format parsing (term(5)) + +use std::collections::HashMap; +use std::io::prelude::*; +use std::io; +use super::super::TermInfo; + +// These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable. + +pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_right_margin", + "no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type", + "hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above", + "memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok", + "dest_tabs_magic_smso", "tilde_glitch", "transparent_underline", "xon_xoff", "needs_xon_xoff", + "prtr_silent", "hard_cursor", "non_rev_rmcup", "no_pad_char", "non_dest_scroll_region", + "can_change", "back_color_erase", "hue_lightness_saturation", "col_addr_glitch", + "cr_cancels_micro_mode", "has_print_wheel", "row_addr_glitch", "semi_auto_right_margin", + "cpi_changes_res", "lpi_changes_res", "backspaces_with_bs", "crt_no_scrolling", + "no_correctly_working_cr", "gnu_has_meta_key", "linefeed_is_newline", "has_hardware_tabs", + "return_does_clr_eol"]; + +pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo", + "gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon", + "nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy", + "xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"]; + +pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines", + "lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal", + "width_status_line", "num_labels", "label_height", "label_width", "max_attributes", + "maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity", + "dot_vert_spacing", "dot_horz_spacing", "max_micro_address", "max_micro_jump", "micro_col_size", + "micro_line_size", "number_of_pins", "output_res_char", "output_res_line", + "output_res_horz_inch", "output_res_vert_inch", "print_rate", "wide_char_size", "buttons", + "bit_image_entwining", "bit_image_type", "magic_cookie_glitch_ul", "carriage_return_delay", + "new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys"]; + +pub static numnames: &'static[&'static str] = &[ "cols", "it", "lines", "lm", "xmc", "pb", + "vt", "wsl", "nlab", "lh", "lw", "ma", "wnum", "colors", "pairs", "ncv", "bufsz", "spinv", + "spinh", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orl", "orhi", "orvi", "cps", "widcs", + "btns", "bitwin", "bitype", "UTug", "OTdC", "OTdN", "OTdB", "OTdT", "OTkn"]; + +pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carriage_return", + "change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos", + "column_address", "command_character", "cursor_address", "cursor_down", "cursor_home", + "cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right", + "cursor_to_ll", "cursor_up", "cursor_visible", "delete_character", "delete_line", + "dis_status_line", "down_half_line", "enter_alt_charset_mode", "enter_blink_mode", + "enter_bold_mode", "enter_ca_mode", "enter_delete_mode", "enter_dim_mode", "enter_insert_mode", + "enter_secure_mode", "enter_protected_mode", "enter_reverse_mode", "enter_standout_mode", + "enter_underline_mode", "erase_chars", "exit_alt_charset_mode", "exit_attribute_mode", + "exit_ca_mode", "exit_delete_mode", "exit_insert_mode", "exit_standout_mode", + "exit_underline_mode", "flash_screen", "form_feed", "from_status_line", "init_1string", + "init_2string", "init_3string", "init_file", "insert_character", "insert_line", + "insert_padding", "key_backspace", "key_catab", "key_clear", "key_ctab", "key_dc", "key_dl", + "key_down", "key_eic", "key_eol", "key_eos", "key_f0", "key_f1", "key_f10", "key_f2", "key_f3", + "key_f4", "key_f5", "key_f6", "key_f7", "key_f8", "key_f9", "key_home", "key_ic", "key_il", + "key_left", "key_ll", "key_npage", "key_ppage", "key_right", "key_sf", "key_sr", "key_stab", + "key_up", "keypad_local", "keypad_xmit", "lab_f0", "lab_f1", "lab_f10", "lab_f2", "lab_f3", + "lab_f4", "lab_f5", "lab_f6", "lab_f7", "lab_f8", "lab_f9", "meta_off", "meta_on", "newline", + "pad_char", "parm_dch", "parm_delete_line", "parm_down_cursor", "parm_ich", "parm_index", + "parm_insert_line", "parm_left_cursor", "parm_right_cursor", "parm_rindex", "parm_up_cursor", + "pkey_key", "pkey_local", "pkey_xmit", "print_screen", "prtr_off", "prtr_on", "repeat_char", + "reset_1string", "reset_2string", "reset_3string", "reset_file", "restore_cursor", + "row_address", "save_cursor", "scroll_forward", "scroll_reverse", "set_attributes", "set_tab", + "set_window", "tab", "to_status_line", "underline_char", "up_half_line", "init_prog", "key_a1", + "key_a3", "key_b2", "key_c1", "key_c3", "prtr_non", "char_padding", "acs_chars", "plab_norm", + "key_btab", "enter_xon_mode", "exit_xon_mode", "enter_am_mode", "exit_am_mode", "xon_character", + "xoff_character", "ena_acs", "label_on", "label_off", "key_beg", "key_cancel", "key_close", + "key_command", "key_copy", "key_create", "key_end", "key_enter", "key_exit", "key_find", + "key_help", "key_mark", "key_message", "key_move", "key_next", "key_open", "key_options", + "key_previous", "key_print", "key_redo", "key_reference", "key_refresh", "key_replace", + "key_restart", "key_resume", "key_save", "key_suspend", "key_undo", "key_sbeg", "key_scancel", + "key_scommand", "key_scopy", "key_screate", "key_sdc", "key_sdl", "key_select", "key_send", + "key_seol", "key_sexit", "key_sfind", "key_shelp", "key_shome", "key_sic", "key_sleft", + "key_smessage", "key_smove", "key_snext", "key_soptions", "key_sprevious", "key_sprint", + "key_sredo", "key_sreplace", "key_sright", "key_srsume", "key_ssave", "key_ssuspend", + "key_sundo", "req_for_input", "key_f11", "key_f12", "key_f13", "key_f14", "key_f15", "key_f16", + "key_f17", "key_f18", "key_f19", "key_f20", "key_f21", "key_f22", "key_f23", "key_f24", + "key_f25", "key_f26", "key_f27", "key_f28", "key_f29", "key_f30", "key_f31", "key_f32", + "key_f33", "key_f34", "key_f35", "key_f36", "key_f37", "key_f38", "key_f39", "key_f40", + "key_f41", "key_f42", "key_f43", "key_f44", "key_f45", "key_f46", "key_f47", "key_f48", + "key_f49", "key_f50", "key_f51", "key_f52", "key_f53", "key_f54", "key_f55", "key_f56", + "key_f57", "key_f58", "key_f59", "key_f60", "key_f61", "key_f62", "key_f63", "clr_bol", + "clear_margins", "set_left_margin", "set_right_margin", "label_format", "set_clock", + "display_clock", "remove_clock", "create_window", "goto_window", "hangup", "dial_phone", + "quick_dial", "tone", "pulse", "flash_hook", "fixed_pause", "wait_tone", "user0", "user1", + "user2", "user3", "user4", "user5", "user6", "user7", "user8", "user9", "orig_pair", + "orig_colors", "initialize_color", "initialize_pair", "set_color_pair", "set_foreground", + "set_background", "change_char_pitch", "change_line_pitch", "change_res_horz", + "change_res_vert", "define_char", "enter_doublewide_mode", "enter_draft_quality", + "enter_italics_mode", "enter_leftward_mode", "enter_micro_mode", "enter_near_letter_quality", + "enter_normal_quality", "enter_shadow_mode", "enter_subscript_mode", "enter_superscript_mode", + "enter_upward_mode", "exit_doublewide_mode", "exit_italics_mode", "exit_leftward_mode", + "exit_micro_mode", "exit_shadow_mode", "exit_subscript_mode", "exit_superscript_mode", + "exit_upward_mode", "micro_column_address", "micro_down", "micro_left", "micro_right", + "micro_row_address", "micro_up", "order_of_pins", "parm_down_micro", "parm_left_micro", + "parm_right_micro", "parm_up_micro", "select_char_set", "set_bottom_margin", + "set_bottom_margin_parm", "set_left_margin_parm", "set_right_margin_parm", "set_top_margin", + "set_top_margin_parm", "start_bit_image", "start_char_set_def", "stop_bit_image", + "stop_char_set_def", "subscript_characters", "superscript_characters", "these_cause_cr", + "zero_motion", "char_set_names", "key_mouse", "mouse_info", "req_mouse_pos", "get_mouse", + "set_a_foreground", "set_a_background", "pkey_plab", "device_type", "code_set_init", + "set0_des_seq", "set1_des_seq", "set2_des_seq", "set3_des_seq", "set_lr_margin", + "set_tb_margin", "bit_image_repeat", "bit_image_newline", "bit_image_carriage_return", + "color_names", "define_bit_image_region", "end_bit_image_region", "set_color_band", + "set_page_length", "display_pc_char", "enter_pc_charset_mode", "exit_pc_charset_mode", + "enter_scancode_mode", "exit_scancode_mode", "pc_term_options", "scancode_escape", + "alt_scancode_esc", "enter_horizontal_hl_mode", "enter_left_hl_mode", "enter_low_hl_mode", + "enter_right_hl_mode", "enter_top_hl_mode", "enter_vertical_hl_mode", "set_a_attributes", + "set_pglen_inch", "termcap_init2", "termcap_reset", "linefeed_if_not_lf", "backspace_if_not_bs", + "other_non_function_keys", "arrow_key_map", "acs_ulcorner", "acs_llcorner", "acs_urcorner", + "acs_lrcorner", "acs_ltee", "acs_rtee", "acs_btee", "acs_ttee", "acs_hline", "acs_vline", + "acs_plus", "memory_lock", "memory_unlock", "box_chars_1"]; + +pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear", + "_", "_", "hpa", "cmdch", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1", + "ll", "cuu1", "cvvis", "dch1", "dl1", "dsl", "hd", "smacs", "blink", "bold", "smcup", "smdc", + "dim", "smir", "invis", "prot", "rev", "smso", "smul", "ech", "rmacs", "sgr0", "rmcup", "rmdc", + "rmir", "rmso", "rmul", "flash", "ff", "fsl", "is1", "is2", "is3", "if", "ich1", "il1", "ip", + "kbs", "ktbc", "kclr", "kctab", "_", "_", "kcud1", "_", "_", "_", "_", "_", "_", "_", "_", "_", + "_", "_", "_", "_", "_", "khome", "_", "_", "kcub1", "_", "knp", "kpp", "kcuf1", "_", "_", + "khts", "_", "rmkx", "smkx", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "rmm", "_", + "_", "pad", "dch", "dl", "cud", "ich", "indn", "il", "cub", "cuf", "rin", "cuu", "pfkey", + "pfloc", "pfx", "mc0", "mc4", "_", "rep", "rs1", "rs2", "rs3", "rf", "rc", "vpa", "sc", "ind", + "ri", "sgr", "_", "wind", "_", "tsl", "uc", "hu", "iprog", "_", "_", "_", "_", "_", "mc5p", + "rmp", "acsc", "pln", "kcbt", "smxon", "rmxon", "smam", "rmam", "xonc", "xoffc", "_", "smln", + "rmln", "_", "kcan", "kclo", "kcmd", "kcpy", "kcrt", "_", "kent", "kext", "kfnd", "khlp", + "kmrk", "kmsg", "kmov", "knxt", "kopn", "kopt", "kprv", "kprt", "krdo", "kref", "krfr", "krpl", + "krst", "kres", "ksav", "kspd", "kund", "kBEG", "kCAN", "kCMD", "kCPY", "kCRT", "_", "_", + "kslt", "kEND", "kEOL", "kEXT", "kFND", "kHLP", "kHOM", "_", "kLFT", "kMSG", "kMOV", "kNXT", + "kOPT", "kPRV", "kPRT", "kRDO", "kRPL", "kRIT", "kRES", "kSAV", "kSPD", "kUND", "rfi", "_", "_", + "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", + "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", + "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", + "dclk", "rmclk", "cwin", "wingo", "_", "dial", "qdial", "_", "_", "hook", "pause", "wait", "_", + "_", "_", "_", "_", "_", "_", "_", "_", "_", "op", "oc", "initc", "initp", "scp", "setf", + "setb", "cpi", "lpi", "chr", "cvr", "defc", "swidm", "sdrfq", "sitm", "slm", "smicm", "snlq", + "snrmq", "sshm", "ssubm", "ssupm", "sum", "rwidm", "ritm", "rlm", "rmicm", "rshm", "rsubm", + "rsupm", "rum", "mhpa", "mcud1", "mcub1", "mcuf1", "mvpa", "mcuu1", "porder", "mcud", "mcub", + "mcuf", "mcuu", "scs", "smgb", "smgbp", "smglp", "smgrp", "smgt", "smgtp", "sbim", "scsd", + "rbim", "rcsd", "subcs", "supcs", "docr", "zerom", "csnm", "kmous", "minfo", "reqmp", "getm", + "setaf", "setab", "pfxl", "devt", "csin", "s0ds", "s1ds", "s2ds", "s3ds", "smglr", "smgtb", + "birep", "binel", "bicr", "colornm", "defbi", "endbi", "setcolor", "slines", "dispc", "smpch", + "rmpch", "smsc", "rmsc", "pctrm", "scesc", "scesa", "ehhlm", "elhlm", "elohlm", "erhlm", + "ethlm", "evhlm", "sgr1", "slength", "OTi2", "OTrs", "OTnl", "OTbs", "OTko", "OTma", "OTG2", + "OTG3", "OTG1", "OTG4", "OTGR", "OTGL", "OTGU", "OTGD", "OTGH", "OTGV", "OTGC", "meml", "memu", + "box1"]; + +fn read_le_u16(r: &mut io::Read) -> io::Result<u16> { + let mut b = [0; 2]; + let mut amt = 0; + while amt < b.len() { + match try!(r.read(&mut b[amt..])) { + 0 => return Err(io::Error::new(io::ErrorKind::Other, "end of file")), + n => amt += n, + } + } + Ok((b[0] as u16) | ((b[1] as u16) << 8)) +} + +fn read_byte(r: &mut io::Read) -> io::Result<u8> { + match r.bytes().next() { + Some(s) => s, + None => Err(io::Error::new(io::ErrorKind::Other, "end of file")) + } +} + +/// Parse a compiled terminfo entry, using long capability names if `longnames` +/// is true +pub fn parse(file: &mut io::Read, longnames: bool) -> Result<TermInfo, String> { + macro_rules! try( ($e:expr) => ( + match $e { + Ok(e) => e, + Err(e) => return Err(format!("{}", e)) + } + ) ); + + let (bnames, snames, nnames) = if longnames { + (boolfnames, stringfnames, numfnames) + } else { + (boolnames, stringnames, numnames) + }; + + // Check magic number + let magic = try!(read_le_u16(file)); + if magic != 0x011A { + return Err(format!("invalid magic number: expected {:x}, found {:x}", + 0x011A, magic)); + } + + // According to the spec, these fields must be >= -1 where -1 means that the feature is not + // supported. Using 0 instead of -1 works because we skip sections with length 0. + macro_rules! read_nonneg { + () => {{ + match try!(read_le_u16(file)) as i16 { + n if n >= 0 => n as usize, + -1 => 0, + _ => return Err("incompatible file: length fields must be >= -1".to_string()), + } + }} + } + + let names_bytes = read_nonneg!(); + let bools_bytes = read_nonneg!(); + let numbers_count = read_nonneg!(); + let string_offsets_count = read_nonneg!(); + let string_table_bytes = read_nonneg!(); + + if names_bytes == 0 { + return Err("incompatible file: names field must be \ + at least 1 byte wide".to_string()); + } + + if bools_bytes > boolnames.len() { + return Err("incompatible file: more booleans than \ + expected".to_string()); + } + + if numbers_count > numnames.len() { + return Err("incompatible file: more numbers than \ + expected".to_string()); + } + + if string_offsets_count > stringnames.len() { + return Err("incompatible file: more string offsets than \ + expected".to_string()); + } + + // don't read NUL + let mut bytes = Vec::new(); + try!(file.take((names_bytes - 1) as u64).read_to_end(&mut bytes)); + let names_str = match String::from_utf8(bytes) { + Ok(s) => s, + Err(_) => return Err("input not utf-8".to_string()), + }; + + let term_names: Vec<String> = names_str.split('|') + .map(|s| s.to_string()) + .collect(); + // consume NUL + if try!(read_byte(file)) != b'\0' { + return Err("incompatible file: missing null terminator \ + for names section".to_string()); + } + + let bools_map: HashMap<String, bool> = try!( + (0..bools_bytes).filter_map(|i| match read_byte(file) { + Err(e) => Some(Err(e)), + Ok(1) => Some(Ok((bnames[i].to_string(), true))), + Ok(_) => None + }).collect()); + + if (bools_bytes + names_bytes) % 2 == 1 { + try!(read_byte(file)); // compensate for padding + } + + let numbers_map: HashMap<String, u16> = try!( + (0..numbers_count).filter_map(|i| match read_le_u16(file) { + Ok(0xFFFF) => None, + Ok(n) => Some(Ok((nnames[i].to_string(), n))), + Err(e) => Some(Err(e)) + }).collect()); + + let string_map: HashMap<String, Vec<u8>> = if string_offsets_count > 0 { + let string_offsets: Vec<u16> = try!((0..string_offsets_count).map(|_| { + read_le_u16(file) + }).collect()); + + let mut string_table = Vec::new(); + try!(file.take(string_table_bytes as u64).read_to_end(&mut string_table)); + + try!(string_offsets.into_iter().enumerate().filter(|&(_, offset)| { + // non-entry + offset != 0xFFFF + }).map(|(i, offset)| { + let offset = offset as usize; + + let name = if snames[i] == "_" { + stringfnames[i] + } else { + snames[i] + }; + + if offset == 0xFFFE { + // undocumented: FFFE indicates cap@, which means the capability is not present + // unsure if the handling for this is correct + return Ok((name.to_string(), Vec::new())); + } + + // Find the offset of the NUL we want to go to + let nulpos = string_table[offset..string_table_bytes].iter().position(|&b| b == 0); + match nulpos { + Some(len) => Ok((name.to_string(), string_table[offset..offset + len].to_vec())), + None => Err("invalid file: missing NUL in string_table".to_string()), + } + }).collect()) + } else { + HashMap::new() + }; + + // And that's all there is to it + Ok(TermInfo { + names: term_names, + bools: bools_map, + numbers: numbers_map, + strings: string_map + }) +} + +/// Create a dummy TermInfo struct for msys terminals +pub fn msys_terminfo() -> TermInfo { + let mut strings = HashMap::new(); + strings.insert("sgr0".to_string(), b"\x1B[0m".to_vec()); + strings.insert("bold".to_string(), b"\x1B[1m".to_vec()); + strings.insert("setaf".to_string(), b"\x1B[3%p1%dm".to_vec()); + strings.insert("setab".to_string(), b"\x1B[4%p1%dm".to_vec()); + + let mut numbers = HashMap::new(); + numbers.insert("colors".to_string(), 8u16); + + TermInfo { + names: vec!("cygwin".to_string()), // msys is a fork of an older cygwin version + bools: HashMap::new(), + numbers: numbers, + strings: strings + } +} + +#[cfg(test)] +mod test { + + use super::{boolnames, boolfnames, numnames, numfnames, stringnames, stringfnames}; + + #[test] + fn test_veclens() { + assert_eq!(boolfnames.len(), boolnames.len()); + assert_eq!(numfnames.len(), numnames.len()); + assert_eq!(stringfnames.len(), stringnames.len()); + } + + #[test] + #[ignore(reason = "no ncurses on buildbots, needs a bundled terminfo file to test against")] + fn test_parse() { + // FIXME #6870: Distribute a compiled file in src/tests and test there + // parse(io::fs_reader(&p("/usr/share/terminfo/r/rxvt-256color")).unwrap(), false); + } +} diff --git a/deps/term-0.2.9/src/terminfo/searcher.rs b/deps/term-0.2.9/src/terminfo/searcher.rs new file mode 100644 index 000000000..207d5e0b2 --- /dev/null +++ b/deps/term-0.2.9/src/terminfo/searcher.rs @@ -0,0 +1,79 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! ncurses-compatible database discovery +//! +//! Does not support hashed database, only filesystem! + +use std::env; +use std::fs; +use std::path::PathBuf; + +/// Return path to database entry for `term` +pub fn get_dbpath_for_term(term: &str) -> Option<PathBuf> { + if term.len() == 0 { + return None; + } + + let mut dirs_to_search = Vec::new(); + let first_char = term.chars().next().unwrap(); + + // Find search directory + match env::var_os("TERMINFO") { + Some(dir) => dirs_to_search.push(PathBuf::from(dir)), + None => { + if let Some(mut homedir) = env::home_dir() { + // ncurses compatibility; + homedir.push(".terminfo"); + dirs_to_search.push(homedir) + } + match env::var("TERMINFO_DIRS") { + Ok(dirs) => for i in dirs.split(':') { + if i == "" { + dirs_to_search.push(PathBuf::from("/usr/share/terminfo")); + } else { + dirs_to_search.push(PathBuf::from(i)); + } + }, + // Found nothing in TERMINFO_DIRS, use the default paths: + // According to /etc/terminfo/README, after looking at + // ~/.terminfo, ncurses will search /etc/terminfo, then + // /lib/terminfo, and eventually /usr/share/terminfo. + Err(..) => { + dirs_to_search.push(PathBuf::from("/etc/terminfo")); + dirs_to_search.push(PathBuf::from("/lib/terminfo")); + dirs_to_search.push(PathBuf::from("/usr/share/terminfo")); + } + } + } + }; + + // Look for the terminal in all of the search directories + for mut p in dirs_to_search { + if fs::metadata(&p).is_ok() { + p.push(&first_char.to_string()); + p.push(&term); + if fs::metadata(&p).is_ok() { + return Some(p); + } + p.pop(); + p.pop(); + + // on some installations the dir is named after the hex of the char + // (e.g. OS X) + p.push(&format!("{:x}", first_char as usize)); + p.push(term); + if fs::metadata(&p).is_ok() { + return Some(p); + } + } + } + None +} diff --git a/deps/term-0.2.9/src/win.rs b/deps/term-0.2.9/src/win.rs new file mode 100644 index 000000000..694d794ad --- /dev/null +++ b/deps/term-0.2.9/src/win.rs @@ -0,0 +1,274 @@ +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Windows console handling + +// FIXME (#13400): this is only a tiny fraction of the Windows console api + +extern crate kernel32; +extern crate winapi; + +use std::ffi::OsStr; +use std::io::prelude::*; +use std::io; +use std::os::windows::ffi::OsStrExt; +use std::ptr; + +use Attr; +use color; +use Terminal; + +/// A Terminal implementation which uses the Win32 Console API. +pub struct WinConsole<T> { + buf: T, + def_foreground: color::Color, + def_background: color::Color, + foreground: color::Color, + background: color::Color, +} + +fn color_to_bits(color: color::Color) -> u16 { + // magic numbers from mingw-w64's wincon.h + + let bits = match color % 8 { + color::BLACK => 0, + color::BLUE => 0x1, + color::GREEN => 0x2, + color::RED => 0x4, + color::YELLOW => 0x2 | 0x4, + color::MAGENTA => 0x1 | 0x4, + color::CYAN => 0x1 | 0x2, + color::WHITE => 0x1 | 0x2 | 0x4, + _ => unreachable!() + }; + + if color >= 8 { + bits | 0x8 + } else { + bits + } +} + +fn bits_to_color(bits: u16) -> color::Color { + let color = match bits & 0x7 { + 0 => color::BLACK, + 0x1 => color::BLUE, + 0x2 => color::GREEN, + 0x4 => color::RED, + 0x6 => color::YELLOW, + 0x5 => color::MAGENTA, + 0x3 => color::CYAN, + 0x7 => color::WHITE, + _ => unreachable!() + }; + + color | (bits & 0x8) // copy the hi-intensity bit +} + +// Just get a handle to the current console buffer whatever it is +fn conout() -> io::Result<winapi::HANDLE> { + let name: &OsStr = "CONOUT$\0".as_ref(); + let name: Vec<u16> = name.encode_wide().collect(); + let handle = unsafe { + kernel32::CreateFileW( + name.as_ptr(), + winapi::GENERIC_READ | winapi::GENERIC_WRITE, + winapi::FILE_SHARE_WRITE, + ptr::null_mut(), + winapi::OPEN_EXISTING, + 0, + ptr::null_mut(), + ) + }; + if handle == winapi::INVALID_HANDLE_VALUE { + Err(io::Error::last_os_error()) + } else { + Ok(handle) + } +} + +// This test will only pass if it is running in an actual console, probably +#[test] +fn test_conout() { + assert!(conout().is_ok()) +} + +impl<T: Write+Send> WinConsole<T> { + fn apply(&mut self) -> io::Result<()> { + let out = try!(conout()); + let _unused = self.buf.flush(); + let mut accum: winapi::WORD = 0; + accum |= color_to_bits(self.foreground); + accum |= color_to_bits(self.background) << 4; + unsafe { + kernel32::SetConsoleTextAttribute(out, accum); + } + Ok(()) + } + + /// Returns `None` whenever the terminal cannot be created for some + /// reason. + pub fn new(out: T) -> io::Result<WinConsole<T>> { + let fg; + let bg; + let handle = try!(conout()); + unsafe { + let mut buffer_info = ::std::mem::uninitialized(); + if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) != 0 { + fg = bits_to_color(buffer_info.wAttributes); + bg = bits_to_color(buffer_info.wAttributes >> 4); + } else { + return Err(io::Error::last_os_error()) + } + } + Ok(WinConsole { + buf: out, + def_foreground: fg, + def_background: bg, + foreground: fg, + background: bg, + }) + } +} + +impl<T: Write> Write for WinConsole<T> { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.buf.write(buf) + } + + fn flush(&mut self) -> io::Result<()> { + self.buf.flush() + } +} + +impl<T: Write+Send> Terminal for WinConsole<T> { + type Output = T; + + fn fg(&mut self, color: color::Color) -> io::Result<bool> { + self.foreground = color; + try!(self.apply()); + + Ok(true) + } + + fn bg(&mut self, color: color::Color) -> io::Result<bool> { + self.background = color; + try!(self.apply()); + + Ok(true) + } + + fn attr(&mut self, attr: Attr) -> io::Result<bool> { + match attr { + Attr::ForegroundColor(f) => { + self.foreground = f; + try!(self.apply()); + Ok(true) + }, + Attr::BackgroundColor(b) => { + self.background = b; + try!(self.apply()); + Ok(true) + }, + _ => Ok(false) + } + } + + fn supports_attr(&self, attr: Attr) -> bool { + // it claims support for underscore and reverse video, but I can't get + // it to do anything -cmr + match attr { + Attr::ForegroundColor(_) | Attr::BackgroundColor(_) => true, + _ => false + } + } + + fn reset(&mut self) -> io::Result<bool> { + self.foreground = self.def_foreground; + self.background = self.def_background; + try!(self.apply()); + + Ok(true) + } + + fn cursor_up(&mut self) -> io::Result<bool> { + let _unused = self.buf.flush(); + let handle = try!(conout()); + unsafe { + let mut buffer_info = ::std::mem::uninitialized(); + if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) != 0 { + let (x, y) = (buffer_info.dwCursorPosition.X, buffer_info.dwCursorPosition.Y); + if y == 0 { + Ok(false) + } else { + let pos = winapi::COORD { X: x, Y: y - 1 }; + if kernel32::SetConsoleCursorPosition(handle, pos) != 0 { + Ok(true) + } else { + Err(io::Error::last_os_error()) + } + } + } else { + Err(io::Error::last_os_error()) + } + } + } + + fn delete_line(&mut self) -> io::Result<bool> { + let _unused = self.buf.flush(); + let handle = try!(conout()); + unsafe { + let mut buffer_info = ::std::mem::uninitialized(); + if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) == 0 { + return Err(io::Error::last_os_error()) + } + let pos = buffer_info.dwCursorPosition; + let size = buffer_info.dwSize; + let num = (size.X - pos.X) as winapi::DWORD; + let mut written = 0; + if kernel32::FillConsoleOutputCharacterW(handle, 0, num, pos, &mut written) == 0 { + return Err(io::Error::last_os_error()) + } + if kernel32::FillConsoleOutputAttribute(handle, 0, num, pos, &mut written) == 0 { + return Err(io::Error::last_os_error()) + } + Ok(written != 0) + } + } + + fn carriage_return(&mut self) -> io::Result<bool> { + let _unused = self.buf.flush(); + let handle = try!(conout()); + unsafe { + let mut buffer_info = ::std::mem::uninitialized(); + if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) != 0 { + let (x, y) = (buffer_info.dwCursorPosition.X, buffer_info.dwCursorPosition.Y); + if x == 0 { + Ok(false) + } else { + let pos = winapi::COORD { X: 0, Y: y }; + if kernel32::SetConsoleCursorPosition(handle, pos) != 0 { + Ok(true) + } else { + Err(io::Error::last_os_error()) + } + } + } else { + Err(io::Error::last_os_error()) + } + } + } + + fn get_ref<'a>(&'a self) -> &'a T { &self.buf } + + fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.buf } + + fn into_inner(self) -> T where Self: Sized { self.buf } +} diff --git a/deps/threadpool-0.1.4/.gitignore b/deps/threadpool-0.1.4/.gitignore new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/deps/threadpool-0.1.4/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/deps/threadpool-0.1.4/.travis.yml b/deps/threadpool-0.1.4/.travis.yml new file mode 100644 index 000000000..dcca7bee2 --- /dev/null +++ b/deps/threadpool-0.1.4/.travis.yml @@ -0,0 +1,20 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo test --verbose --features scoped-pool + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + echo '<meta http-equiv=refresh content=0;url=threadpool/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: hXTqnR2C6ODEq8Q8DZrV4nYNSNWlbcT+PLXRGdjD70Bp5EzRwLzcZMTYm0m6aUylsT+sPwl9Pn3JqT/uMItBXlYp0OzfQ3fDgVL4TFbBIb9zEyPLQukSKg5yxxQjHQzhdRcQBMliyG79nOuo3l1g11mflDXayABa414ZS4htsMs= +notifications: + email: + on_success: never diff --git a/deps/threadpool-0.1.4/Cargo.toml b/deps/threadpool-0.1.4/Cargo.toml new file mode 100644 index 000000000..51b132cc0 --- /dev/null +++ b/deps/threadpool-0.1.4/Cargo.toml @@ -0,0 +1,16 @@ +[package] + +name = "threadpool" +version = "0.1.4" +authors = ["The Rust Project Developers"] +license = "MIT/Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/threadpool" +homepage = "https://github.com/rust-lang/threadpool" +documentation = "http://doc.rust-lang.org/threadpool" +description = """ +A thread pool for running a number of jobs on a fixed set of worker threads. +""" + +[features] +scoped-pool = [] diff --git a/deps/threadpool-0.1.4/LICENSE-APACHE b/deps/threadpool-0.1.4/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/threadpool-0.1.4/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/threadpool-0.1.4/LICENSE-MIT b/deps/threadpool-0.1.4/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/threadpool-0.1.4/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/threadpool-0.1.4/README.md b/deps/threadpool-0.1.4/README.md new file mode 100644 index 000000000..6edba9354 --- /dev/null +++ b/deps/threadpool-0.1.4/README.md @@ -0,0 +1,24 @@ +threadpool +========== + +A thread pool for running a number of jobs on a fixed set of worker threads. + +[![Build Status](https://travis-ci.org/rust-lang/threadpool.svg?branch=master)](https://travis-ci.org/rust-lang/threadpool) + +[Documentation](http://doc.rust-lang.org/threadpool) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] + +threadpool = "0.1" +``` + +and this to your crate root: + +```rust +extern crate threadpool; +``` diff --git a/deps/threadpool-0.1.4/src/lib.rs b/deps/threadpool-0.1.4/src/lib.rs new file mode 100644 index 000000000..56b8f1ea5 --- /dev/null +++ b/deps/threadpool-0.1.4/src/lib.rs @@ -0,0 +1,363 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Abstraction of a thread pool for basic parallelism. + +#![cfg_attr(feature = "scoped-pool", feature(scoped))] + +#[cfg(feature = "scoped-pool")] +use std::mem; +use std::sync::mpsc::{channel, Sender, Receiver}; +use std::sync::{Arc, Mutex}; +use std::thread; +#[cfg(feature = "scoped-pool")] +use std::thread::JoinGuard; + +trait FnBox { + fn call_box(self: Box<Self>); +} + +impl<F: FnOnce()> FnBox for F { + fn call_box(self: Box<F>) { + (*self)() + } +} + +type Thunk<'a> = Box<FnBox + Send + 'a>; + +struct Sentinel<'a> { + jobs: &'a Arc<Mutex<Receiver<Thunk<'static>>>>, + active: bool +} + +impl<'a> Sentinel<'a> { + fn new(jobs: &'a Arc<Mutex<Receiver<Thunk<'static>>>>) -> Sentinel<'a> { + Sentinel { + jobs: jobs, + active: true + } + } + + // Cancel and destroy this sentinel. + fn cancel(mut self) { + self.active = false; + } +} + +impl<'a> Drop for Sentinel<'a> { + fn drop(&mut self) { + if self.active { + spawn_in_pool(self.jobs.clone()) + } + } +} + +/// A thread pool used to execute functions in parallel. +/// +/// Spawns `n` worker threads and replenishes the pool if any worker threads +/// panic. +/// +/// # Example +/// +/// ```rust +/// use threadpool::ThreadPool; +/// use std::sync::mpsc::channel; +/// +/// let pool = ThreadPool::new(4); +/// +/// let (tx, rx) = channel(); +/// for i in 0..8 { +/// let tx = tx.clone(); +/// pool.execute(move|| { +/// tx.send(i).unwrap(); +/// }); +/// } +/// +/// assert_eq!(rx.iter().take(8).fold(0, |a, b| a + b), 28); +/// ``` +pub struct ThreadPool { + // How the threadpool communicates with subthreads. + // + // This is the only such Sender, so when it is dropped all subthreads will + // quit. + jobs: Sender<Thunk<'static>> +} + +impl ThreadPool { + /// Spawns a new thread pool with `threads` threads. + /// + /// # Panics + /// + /// This function will panic if `threads` is 0. + pub fn new(threads: usize) -> ThreadPool { + assert!(threads >= 1); + + let (tx, rx) = channel::<Thunk<'static>>(); + let rx = Arc::new(Mutex::new(rx)); + + // Threadpool threads + for _ in 0..threads { + spawn_in_pool(rx.clone()); + } + + ThreadPool { jobs: tx } + } + + /// Executes the function `job` on a thread in the pool. + pub fn execute<F>(&self, job: F) + where F : FnOnce() + Send + 'static + { + self.jobs.send(Box::new(move || job())).unwrap(); + } +} + +fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk<'static>>>>) { + thread::spawn(move || { + // Will spawn a new thread on panic unless it is cancelled. + let sentinel = Sentinel::new(&jobs); + + loop { + let message = { + // Only lock jobs for the time it takes + // to get a job, not run it. + let lock = jobs.lock().unwrap(); + lock.recv() + }; + + match message { + Ok(job) => job.call_box(), + + // The Threadpool was dropped. + Err(..) => break + } + } + + sentinel.cancel(); + }); +} + +/// A scoped thread pool used to execute functions in parallel. +/// +/// `ScopedPool` is different from `ThreadPool` in that: +/// +/// * When dropped, it propagates panics that occur in the worker threads. +/// * It doesn't require the `'static` bound on the functions that are executed. +/// * Worker threads are joined when the `ScopedPool` is dropped. +/// +/// # Example +/// +/// ```rust +/// use threadpool::ScopedPool; +/// +/// let mut numbers: &mut [u32] = &mut [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +/// +/// // We need an extra scope to shorten the lifetime of the pool +/// { +/// let pool = ScopedPool::new(4); +/// for x in &mut numbers[..] { +/// pool.execute(move|| { +/// *x += 1; +/// }); +/// } +/// } +/// +/// assert_eq!(numbers, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); +/// ``` +#[cfg(feature = "scoped-pool")] +pub struct ScopedPool<'pool> { + sender: Option<Sender<Thunk<'pool>>>, + _guards: Vec<JoinGuard<'pool, ()>> +} + +#[cfg(feature = "scoped-pool")] +impl<'pool> ScopedPool<'pool> { + /// Spawns a new thread pool with `threads` threads. + /// + /// # Panics + /// + /// This function will panic if `threads` is 0. + pub fn new(threads: u32) -> ScopedPool<'pool> { + assert!(threads >= 1); + + let (sender, receiver) = channel(); + let receiver = Arc::new(Mutex::new(receiver)); + + let mut guards = Vec::with_capacity(threads as usize); + for _ in 0..threads { + guards.push(spawn_scoped_in_pool(receiver.clone())); + } + + ScopedPool { sender: Some(sender), _guards: guards } + } + + /// Executes the function `job` on a thread in the pool. + pub fn execute<F>(&self, job: F) + where F: FnOnce() + Send + 'pool + { + self.sender.as_ref().unwrap().send(Box::new(job)).unwrap(); + } +} + +#[cfg(feature = "scoped-pool")] +impl<'a> Drop for ScopedPool<'a> { + fn drop(&mut self) { + // We need to ensure that the sender is dropped before the JoinGuards + // Otherwise the threads will be joined and wait forever in the loop + mem::replace(&mut self.sender, None); + } +} + +#[cfg(feature = "scoped-pool")] +fn spawn_scoped_in_pool<'a>(jobs: Arc<Mutex<Receiver<Thunk<'a>>>>) -> JoinGuard<'a, ()> +{ + thread::scoped(move || { + loop { + let message = { + // Only lock jobs for the time it takes + // to get a job, not run it. + let lock = jobs.lock().unwrap(); + lock.recv() + }; + + match message { + Ok(job) => job.call_box(), + + // The pool was dropped. + Err(..) => break + } + } + }) +} + +#[cfg(test)] +mod test { + use super::ThreadPool; + use std::sync::mpsc::channel; + use std::sync::{Arc, Barrier}; + + const TEST_TASKS: usize = 4; + + #[test] + fn test_works() { + let pool = ThreadPool::new(TEST_TASKS); + + let (tx, rx) = channel(); + for _ in 0..TEST_TASKS { + let tx = tx.clone(); + pool.execute(move|| { + tx.send(1).unwrap(); + }); + } + + assert_eq!(rx.iter().take(TEST_TASKS).fold(0, |a, b| a + b), TEST_TASKS); + } + + #[test] + #[should_panic] + fn test_zero_tasks_panic() { + ThreadPool::new(0); + } + + #[test] + fn test_recovery_from_subtask_panic() { + let pool = ThreadPool::new(TEST_TASKS); + + // Panic all the existing threads. + for _ in 0..TEST_TASKS { + pool.execute(move|| -> () { panic!() }); + } + + // Ensure new threads were spawned to compensate. + let (tx, rx) = channel(); + for _ in 0..TEST_TASKS { + let tx = tx.clone(); + pool.execute(move|| { + tx.send(1).unwrap(); + }); + } + + assert_eq!(rx.iter().take(TEST_TASKS).fold(0, |a, b| a + b), TEST_TASKS); + } + + #[test] + fn test_should_not_panic_on_drop_if_subtasks_panic_after_drop() { + + let pool = ThreadPool::new(TEST_TASKS); + let waiter = Arc::new(Barrier::new(TEST_TASKS + 1)); + + // Panic all the existing threads in a bit. + for _ in 0..TEST_TASKS { + let waiter = waiter.clone(); + pool.execute(move|| { + waiter.wait(); + panic!(); + }); + } + + drop(pool); + + // Kick off the failure. + waiter.wait(); + } +} + +#[cfg(all(test, feature = "scoped-pool"))] +mod test_scoped { + use super::ScopedPool; + use std::sync::mpsc::channel; + + const TEST_TASKS: u32 = 4; + + #[test] + fn test_works_1() { + let pool = ScopedPool::new(TEST_TASKS); + + let (tx, rx) = channel(); + for _ in 0..TEST_TASKS { + let tx = tx.clone(); + pool.execute(move|| { + tx.send(1).unwrap(); + }); + } + + assert_eq!(rx.iter().take(TEST_TASKS as usize).fold(0, |a, b| a + b), TEST_TASKS); + } + + #[test] + fn test_works_2() { + let mut numbers: &mut [u32] = &mut [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + { + let pool = ScopedPool::new(TEST_TASKS); + for x in numbers.iter_mut() { + pool.execute(move || { + *x += 1; + }); + } + } + assert_eq!(numbers, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); + } + + #[test] + #[should_panic] + fn test_zero_tasks_panic() { + ScopedPool::new(0); + } + + #[test] + #[should_panic] + fn test_panic_propagation() { + let pool = ScopedPool::new(TEST_TASKS); + + // Panic all the existing threads. + for _ in 0..TEST_TASKS { + pool.execute(move|| -> () { panic!() }); + } + } +} diff --git a/deps/time-0.1.26/.gitignore b/deps/time-0.1.26/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/time-0.1.26/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/time-0.1.26/.travis.yml b/deps/time-0.1.26/.travis.yml new file mode 100644 index 000000000..f8dfd7f29 --- /dev/null +++ b/deps/time-0.1.26/.travis.yml @@ -0,0 +1,27 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo test --verbose --features rustc-serialize + - | + [ $TRAVIS_RUST_VERSION != nightly ] || cargo bench + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '<meta http-equiv=refresh content=0;url=time/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + secure: qxCB/4AUtX5cQPDfmAccpxRkxkdoZtkjiYW5tbaThzFEJJ1SpkIJzS+IdhCPxDGhwF+aiLLky9KDZi1bXbtjkDS8n/bFaGc/k2vRNgLKuaLdztZ1dGHlBNN2J7j0bLGUm0MAy62OHLNXbPmvS0uGvv0q4pQ6sQB2+YItwqHPuyQ= +notifications: + email: + on_success: never diff --git a/deps/time-0.1.26/Cargo.toml b/deps/time-0.1.26/Cargo.toml new file mode 100644 index 000000000..84ed4bbfa --- /dev/null +++ b/deps/time-0.1.26/Cargo.toml @@ -0,0 +1,23 @@ +[package] + +name = "time" +version = "0.1.26" +authors = ["The Rust Project Developers"] +build = "build.rs" +license = "MIT/Apache-2.0" +homepage = "https://github.com/rust-lang/time" +repository = "https://github.com/rust-lang/time" +documentation = "http://doc.rust-lang.org/time" +description = """ +Utilities for working with time-related functions in Rust. +""" + +[dependencies] +libc = "0.1" +rustc-serialize = { version = "0.3", optional = true } + +[build-dependencies] +gcc = "0.3" + +[dev-dependencies] +log = "0.3" diff --git a/deps/time-0.1.26/LICENSE-APACHE b/deps/time-0.1.26/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/time-0.1.26/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/time-0.1.26/LICENSE-MIT b/deps/time-0.1.26/LICENSE-MIT new file mode 100644 index 000000000..39d4bdb5a --- /dev/null +++ b/deps/time-0.1.26/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/time-0.1.26/README.md b/deps/time-0.1.26/README.md new file mode 100644 index 000000000..b35302d6d --- /dev/null +++ b/deps/time-0.1.26/README.md @@ -0,0 +1,24 @@ +time +==== + +Utilities for working with time-related functions in Rust + +[![Build Status](https://travis-ci.org/rust-lang/time.svg?branch=master)](https://travis-ci.org/rust-lang/time) +[![Build status](https://ci.appveyor.com/api/projects/status/55m7rbaj9a5v3ad7?svg=true)](https://ci.appveyor.com/project/alexcrichton/time) + +[Documentation](http://doc.rust-lang.org/time) + +## Usage + +Put this in your `Cargo.toml`: + +```toml +[dependencies] +time = "0.1" +``` + +And this in your crate root: + +```rust +extern crate time; +``` diff --git a/deps/time-0.1.26/appveyor.yml b/deps/time-0.1.26/appveyor.yml new file mode 100644 index 000000000..fc72b1e24 --- /dev/null +++ b/deps/time-0.1.26/appveyor.yml @@ -0,0 +1,13 @@ +install: + - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' + - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + - git submodule update --init --recursive + +build: false + +test_script: + - cargo test --verbose diff --git a/deps/time-0.1.26/benches/precise_time_ns.rs b/deps/time-0.1.26/benches/precise_time_ns.rs new file mode 100644 index 000000000..d9170ea26 --- /dev/null +++ b/deps/time-0.1.26/benches/precise_time_ns.rs @@ -0,0 +1,11 @@ +#![feature(test)] + +extern crate test; +extern crate time; + +use test::Bencher; + +#[bench] +fn bench_precise_time_ns(b: &mut Bencher) { + b.iter(|| time::precise_time_ns()) +} diff --git a/deps/time-0.1.26/build.rs b/deps/time-0.1.26/build.rs new file mode 100644 index 000000000..fc5a12554 --- /dev/null +++ b/deps/time-0.1.26/build.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate gcc; + +fn main() { + gcc::compile_library("libtime_helpers.a", + &["src/time_helpers.c"]); +} diff --git a/deps/time-0.1.26/src/display.rs b/deps/time-0.1.26/src/display.rs new file mode 100644 index 000000000..6c74afa10 --- /dev/null +++ b/deps/time-0.1.26/src/display.rs @@ -0,0 +1,260 @@ +use std::fmt::{self, Display}; + +use super::{TmFmt, Tm, Fmt}; + +impl<'a> fmt::Display for TmFmt<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.format { + Fmt::Str(ref s) => { + let mut chars = s.chars(); + while let Some(ch) = chars.next() { + if ch == '%' { + // we've already validated that % always precedes + // another char + try!(parse_type(fmt, chars.next().unwrap(), self.tm)); + } else { + try!(write!(fmt, "{}", ch)); + } + } + + Ok(()) + } + Fmt::Ctime => self.tm.to_local().asctime().fmt(fmt), + Fmt::Rfc3339 => { + if self.tm.tm_utcoff == 0 { + TmFmt { + tm: self.tm, + format: Fmt::Str("%Y-%m-%dT%H:%M:%SZ"), + }.fmt(fmt) + } else { + let s = TmFmt { + tm: self.tm, + format: Fmt::Str("%Y-%m-%dT%H:%M:%S"), + }; + let sign = if self.tm.tm_utcoff > 0 { '+' } else { '-' }; + let mut m = abs(self.tm.tm_utcoff) / 60; + let h = m / 60; + m -= h * 60; + write!(fmt, "{}{}{:02}:{:02}", s, sign, h, m) + } + } + } + } +} + +fn is_leap_year(year: i32) -> bool { + (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) +} + +fn days_in_year(year: i32) -> i32 { + if is_leap_year(year) { 366 } + else { 365 } +} + +fn iso_week_days(yday: i32, wday: i32) -> i32 { + /* The number of days from the first day of the first ISO week of this + * year to the year day YDAY with week day WDAY. + * ISO weeks start on Monday. The first ISO week has the year's first + * Thursday. + * YDAY may be as small as yday_minimum. + */ + let iso_week_start_wday: i32 = 1; /* Monday */ + let iso_week1_wday: i32 = 4; /* Thursday */ + let yday_minimum: i32 = 366; + /* Add enough to the first operand of % to make it nonnegative. */ + let big_enough_multiple_of_7: i32 = (yday_minimum / 7 + 2) * 7; + + yday - (yday - wday + iso_week1_wday + big_enough_multiple_of_7) % 7 + + iso_week1_wday - iso_week_start_wday +} + +fn iso_week(fmt: &mut fmt::Formatter, ch:char, tm: &Tm) -> fmt::Result { + let mut year = tm.tm_year + 1900; + let mut days = iso_week_days(tm.tm_yday, tm.tm_wday); + + if days < 0 { + /* This ISO week belongs to the previous year. */ + year -= 1; + days = iso_week_days(tm.tm_yday + (days_in_year(year)), tm.tm_wday); + } else { + let d = iso_week_days(tm.tm_yday - (days_in_year(year)), + tm.tm_wday); + if 0 <= d { + /* This ISO week belongs to the next year. */ + year += 1; + days = d; + } + } + + match ch { + 'G' => write!(fmt, "{}", year), + 'g' => write!(fmt, "{:02}", (year % 100 + 100) % 100), + 'V' => write!(fmt, "{:02}", days / 7 + 1), + _ => Ok(()) + } +} + +fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result { + match ch { + 'A' => write!(fmt, "{}", match tm.tm_wday { + 0 => "Sunday", + 1 => "Monday", + 2 => "Tuesday", + 3 => "Wednesday", + 4 => "Thursday", + 5 => "Friday", + 6 => "Saturday", + _ => unreachable!(), + }), + 'a' => write!(fmt, "{}", match tm.tm_wday { + 0 => "Sun", + 1 => "Mon", + 2 => "Tue", + 3 => "Wed", + 4 => "Thu", + 5 => "Fri", + 6 => "Sat", + _ => unreachable!(), + }), + 'B' => write!(fmt, "{}", match tm.tm_mon { + 0 => "January", + 1 => "February", + 2 => "March", + 3 => "April", + 4 => "May", + 5 => "June", + 6 => "July", + 7 => "August", + 8 => "September", + 9 => "October", + 10 => "November", + 11 => "December", + _ => unreachable!(), + }), + 'b' | 'h' => write!(fmt, "{}", match tm.tm_mon { + 0 => "Jan", + 1 => "Feb", + 2 => "Mar", + 3 => "Apr", + 4 => "May", + 5 => "Jun", + 6 => "Jul", + 7 => "Aug", + 8 => "Sep", + 9 => "Oct", + 10 => "Nov", + 11 => "Dec", + _ => unreachable!(), + }), + 'C' => write!(fmt, "{:02}", (tm.tm_year + 1900) / 100), + 'c' => { + try!(parse_type(fmt, 'a', tm)); + try!(write!(fmt, " ")); + try!(parse_type(fmt, 'b', tm)); + try!(write!(fmt, " ")); + try!(parse_type(fmt, 'e', tm)); + try!(write!(fmt, " ")); + try!(parse_type(fmt, 'T', tm)); + try!(write!(fmt, " ")); + parse_type(fmt, 'Y', tm) + } + 'D' | 'x' => { + try!(parse_type(fmt, 'm', tm)); + try!(write!(fmt, "/")); + try!(parse_type(fmt, 'd', tm)); + try!(write!(fmt, "/")); + parse_type(fmt, 'y', tm) + } + 'd' => write!(fmt, "{:02}", tm.tm_mday), + 'e' => write!(fmt, "{:2}", tm.tm_mday), + 'f' => write!(fmt, "{:09}", tm.tm_nsec), + 'F' => { + try!(parse_type(fmt, 'Y', tm)); + try!(write!(fmt, "-")); + try!(parse_type(fmt, 'm', tm)); + try!(write!(fmt, "-")); + parse_type(fmt, 'd', tm) + } + 'G' => iso_week(fmt, 'G', tm), + 'g' => iso_week(fmt, 'g', tm), + 'H' => write!(fmt, "{:02}", tm.tm_hour), + 'I' => { + let mut h = tm.tm_hour; + if h == 0 { h = 12 } + if h > 12 { h -= 12 } + write!(fmt, "{:02}", h) + } + 'j' => write!(fmt, "{:03}", tm.tm_yday + 1), + 'k' => write!(fmt, "{:2}", tm.tm_hour), + 'l' => { + let mut h = tm.tm_hour; + if h == 0 { h = 12 } + if h > 12 { h -= 12 } + write!(fmt, "{:2}", h) + } + 'M' => write!(fmt, "{:02}", tm.tm_min), + 'm' => write!(fmt, "{:02}", tm.tm_mon + 1), + 'n' => write!(fmt, "\n"), + 'P' => write!(fmt, "{}", if tm.tm_hour < 12 { "am" } else { "pm" }), + 'p' => write!(fmt, "{}", if (tm.tm_hour) < 12 { "AM" } else { "PM" }), + 'R' => { + try!(parse_type(fmt, 'H', tm)); + try!(write!(fmt, ":")); + parse_type(fmt, 'M', tm) + } + 'r' => { + try!(parse_type(fmt, 'I', tm)); + try!(write!(fmt, ":")); + try!(parse_type(fmt, 'M', tm)); + try!(write!(fmt, ":")); + try!(parse_type(fmt, 'S', tm)); + try!(write!(fmt, " ")); + parse_type(fmt, 'p', tm) + } + 'S' => write!(fmt, "{:02}", tm.tm_sec), + 's' => write!(fmt, "{}", tm.to_timespec().sec), + 'T' | 'X' => { + try!(parse_type(fmt, 'H', tm)); + try!(write!(fmt, ":")); + try!(parse_type(fmt, 'M', tm)); + try!(write!(fmt, ":")); + parse_type(fmt, 'S', tm) + } + 't' => write!(fmt, "\t"), + 'U' => write!(fmt, "{:02}", (tm.tm_yday - tm.tm_wday + 7) / 7), + 'u' => { + let i = tm.tm_wday; + write!(fmt, "{}", (if i == 0 { 7 } else { i })) + } + 'V' => iso_week(fmt, 'V', tm), + 'v' => { + try!(parse_type(fmt, 'e', tm)); + try!(write!(fmt, "-")); + try!(parse_type(fmt, 'b', tm)); + try!(write!(fmt, "-")); + parse_type(fmt, 'Y', tm) + } + 'W' => { + write!(fmt, "{:02}", (tm.tm_yday - (tm.tm_wday - 1 + 7) % 7 + 7) / 7) + } + 'w' => write!(fmt, "{}", tm.tm_wday), + 'Y' => write!(fmt, "{}", tm.tm_year + 1900), + 'y' => write!(fmt, "{:02}", (tm.tm_year + 1900) % 100), + // FIXME (#2350): support locale + 'Z' => write!(fmt, "{}", if tm.tm_utcoff == 0 { "UTC"} else { "" }), + 'z' => { + let sign = if tm.tm_utcoff > 0 { '+' } else { '-' }; + let mut m = abs(tm.tm_utcoff) / 60; + let h = m / 60; + m -= h * 60; + write!(fmt, "{}{:02}{:02}", sign, h, m) + } + '+' => write!(fmt, "{}", tm.rfc3339()), + '%' => write!(fmt, "{}", "%"), + _ => unreachable!(), + } +} + +fn abs(i: i32) -> i32 { + if i < 0 {-i} else {i} +} diff --git a/deps/time-0.1.26/src/duration.rs b/deps/time-0.1.26/src/duration.rs new file mode 100644 index 000000000..ebfaf4385 --- /dev/null +++ b/deps/time-0.1.26/src/duration.rs @@ -0,0 +1,560 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Temporal quantification + +use std::{fmt, i64}; +use std::ops::{Add, Sub, Mul, Div, Neg, FnOnce}; + +/// The number of nanoseconds in a microsecond. +const NANOS_PER_MICRO: i32 = 1000; +/// The number of nanoseconds in a millisecond. +const NANOS_PER_MILLI: i32 = 1000_000; +/// The number of nanoseconds in seconds. +const NANOS_PER_SEC: i32 = 1_000_000_000; +/// The number of microseconds per second. +const MICROS_PER_SEC: i64 = 1000_000; +/// The number of milliseconds per second. +const MILLIS_PER_SEC: i64 = 1000; +/// The number of seconds in a minute. +const SECS_PER_MINUTE: i64 = 60; +/// The number of seconds in an hour. +const SECS_PER_HOUR: i64 = 3600; +/// The number of (non-leap) seconds in days. +const SECS_PER_DAY: i64 = 86400; +/// The number of (non-leap) seconds in a week. +const SECS_PER_WEEK: i64 = 604800; + +macro_rules! try_opt { + ($e:expr) => (match $e { Some(v) => v, None => return None }) +} + + +/// ISO 8601 time duration with nanosecond precision. +/// This also allows for the negative duration; see individual methods for details. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +pub struct Duration { + secs: i64, + nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC +} + +/// The minimum possible `Duration`: `i64::MIN` milliseconds. +pub const MIN: Duration = Duration { + secs: i64::MIN / MILLIS_PER_SEC - 1, + nanos: NANOS_PER_SEC + (i64::MIN % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI +}; + +/// The maximum possible `Duration`: `i64::MAX` milliseconds. +pub const MAX: Duration = Duration { + secs: i64::MAX / MILLIS_PER_SEC, + nanos: (i64::MAX % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI +}; + +impl Duration { + /// Makes a new `Duration` with given number of weeks. + /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60)` with overflow checks. + /// Panics when the duration is out of bounds. + #[inline] + pub fn weeks(weeks: i64) -> Duration { + let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds"); + Duration::seconds(secs) + } + + /// Makes a new `Duration` with given number of days. + /// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks. + /// Panics when the duration is out of bounds. + #[inline] + pub fn days(days: i64) -> Duration { + let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds"); + Duration::seconds(secs) + } + + /// Makes a new `Duration` with given number of hours. + /// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks. + /// Panics when the duration is out of bounds. + #[inline] + pub fn hours(hours: i64) -> Duration { + let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds"); + Duration::seconds(secs) + } + + /// Makes a new `Duration` with given number of minutes. + /// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks. + /// Panics when the duration is out of bounds. + #[inline] + pub fn minutes(minutes: i64) -> Duration { + let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds"); + Duration::seconds(secs) + } + + /// Makes a new `Duration` with given number of seconds. + /// Panics when the duration is more than `i64::MAX` milliseconds + /// or less than `i64::MIN` milliseconds. + #[inline] + pub fn seconds(seconds: i64) -> Duration { + let d = Duration { secs: seconds, nanos: 0 }; + if d < MIN || d > MAX { + panic!("Duration::seconds out of bounds"); + } + d + } + + /// Makes a new `Duration` with given number of milliseconds. + #[inline] + pub fn milliseconds(milliseconds: i64) -> Duration { + let (secs, millis) = div_mod_floor_64(milliseconds, MILLIS_PER_SEC); + let nanos = millis as i32 * NANOS_PER_MILLI; + Duration { secs: secs, nanos: nanos } + } + + /// Makes a new `Duration` with given number of microseconds. + #[inline] + pub fn microseconds(microseconds: i64) -> Duration { + let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC); + let nanos = micros as i32 * NANOS_PER_MICRO; + Duration { secs: secs, nanos: nanos } + } + + /// Makes a new `Duration` with given number of nanoseconds. + #[inline] + pub fn nanoseconds(nanos: i64) -> Duration { + let (secs, nanos) = div_mod_floor_64(nanos, NANOS_PER_SEC as i64); + Duration { secs: secs, nanos: nanos as i32 } + } + + /// Runs a closure, returning the duration of time it took to run the + /// closure. + pub fn span<F>(f: F) -> Duration where F: FnOnce() { + let before = super::precise_time_ns(); + f(); + Duration::nanoseconds((super::precise_time_ns() - before) as i64) + } + + /// Returns the total number of whole weeks in the duration. + #[inline] + pub fn num_weeks(&self) -> i64 { + self.num_days() / 7 + } + + /// Returns the total number of whole days in the duration. + pub fn num_days(&self) -> i64 { + self.num_seconds() / SECS_PER_DAY + } + + /// Returns the total number of whole hours in the duration. + #[inline] + pub fn num_hours(&self) -> i64 { + self.num_seconds() / SECS_PER_HOUR + } + + /// Returns the total number of whole minutes in the duration. + #[inline] + pub fn num_minutes(&self) -> i64 { + self.num_seconds() / SECS_PER_MINUTE + } + + /// Returns the total number of whole seconds in the duration. + pub fn num_seconds(&self) -> i64 { + // If secs is negative, nanos should be subtracted from the duration. + if self.secs < 0 && self.nanos > 0 { + self.secs + 1 + } else { + self.secs + } + } + + /// Returns the number of nanoseconds such that + /// `nanos_mod_sec() + num_seconds() * NANOS_PER_SEC` is the total number of + /// nanoseconds in the duration. + fn nanos_mod_sec(&self) -> i32 { + if self.secs < 0 && self.nanos > 0 { + self.nanos - NANOS_PER_SEC + } else { + self.nanos + } + } + + /// Returns the total number of whole milliseconds in the duration, + pub fn num_milliseconds(&self) -> i64 { + // A proper Duration will not overflow, because MIN and MAX are defined + // such that the range is exactly i64 milliseconds. + let secs_part = self.num_seconds() * MILLIS_PER_SEC; + let nanos_part = self.nanos_mod_sec() / NANOS_PER_MILLI; + secs_part + nanos_part as i64 + } + + /// Returns the total number of whole microseconds in the duration, + /// or `None` on overflow (exceeding 2^63 microseconds in either direction). + pub fn num_microseconds(&self) -> Option<i64> { + let secs_part = try_opt!(self.num_seconds().checked_mul(MICROS_PER_SEC)); + let nanos_part = self.nanos_mod_sec() / NANOS_PER_MICRO; + secs_part.checked_add(nanos_part as i64) + } + + /// Returns the total number of whole nanoseconds in the duration, + /// or `None` on overflow (exceeding 2^63 nanoseconds in either direction). + pub fn num_nanoseconds(&self) -> Option<i64> { + let secs_part = try_opt!(self.num_seconds().checked_mul(NANOS_PER_SEC as i64)); + let nanos_part = self.nanos_mod_sec(); + secs_part.checked_add(nanos_part as i64) + } + + /// Add two durations, returning `None` if overflow occurred. + pub fn checked_add(&self, rhs: &Duration) -> Option<Duration> { + let mut secs = try_opt!(self.secs.checked_add(rhs.secs)); + let mut nanos = self.nanos + rhs.nanos; + if nanos >= NANOS_PER_SEC { + nanos -= NANOS_PER_SEC; + secs = try_opt!(secs.checked_add(1)); + } + let d = Duration { secs: secs, nanos: nanos }; + // Even if d is within the bounds of i64 seconds, + // it might still overflow i64 milliseconds. + if d < MIN || d > MAX { None } else { Some(d) } + } + + /// Subtract two durations, returning `None` if overflow occurred. + pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration> { + let mut secs = try_opt!(self.secs.checked_sub(rhs.secs)); + let mut nanos = self.nanos - rhs.nanos; + if nanos < 0 { + nanos += NANOS_PER_SEC; + secs = try_opt!(secs.checked_sub(1)); + } + let d = Duration { secs: secs, nanos: nanos }; + // Even if d is within the bounds of i64 seconds, + // it might still overflow i64 milliseconds. + if d < MIN || d > MAX { None } else { Some(d) } + } + + /// The minimum possible `Duration`: `i64::MIN` milliseconds. + #[inline] + pub fn min_value() -> Duration { MIN } + + /// The maximum possible `Duration`: `i64::MAX` milliseconds. + #[inline] + pub fn max_value() -> Duration { MAX } + + /// A duration where the stored seconds and nanoseconds are equal to zero. + #[inline] + pub fn zero() -> Duration { + Duration { secs: 0, nanos: 0 } + } + + /// Returns `true` if the duration equals `Duration::zero()`. + #[inline] + pub fn is_zero(&self) -> bool { + self.secs == 0 && self.nanos == 0 + } +} + +impl Neg for Duration { + type Output = Duration; + + #[inline] + fn neg(self) -> Duration { + if self.nanos == 0 { + Duration { secs: -self.secs, nanos: 0 } + } else { + Duration { secs: -self.secs - 1, nanos: NANOS_PER_SEC - self.nanos } + } + } +} + +impl Add for Duration { + type Output = Duration; + + fn add(self, rhs: Duration) -> Duration { + let mut secs = self.secs + rhs.secs; + let mut nanos = self.nanos + rhs.nanos; + if nanos >= NANOS_PER_SEC { + nanos -= NANOS_PER_SEC; + secs += 1; + } + Duration { secs: secs, nanos: nanos } + } +} + +impl Sub for Duration { + type Output = Duration; + + fn sub(self, rhs: Duration) -> Duration { + let mut secs = self.secs - rhs.secs; + let mut nanos = self.nanos - rhs.nanos; + if nanos < 0 { + nanos += NANOS_PER_SEC; + secs -= 1; + } + Duration { secs: secs, nanos: nanos } + } +} + +impl Mul<i32> for Duration { + type Output = Duration; + + fn mul(self, rhs: i32) -> Duration { + // Multiply nanoseconds as i64, because it cannot overflow that way. + let total_nanos = self.nanos as i64 * rhs as i64; + let (extra_secs, nanos) = div_mod_floor_64(total_nanos, NANOS_PER_SEC as i64); + let secs = self.secs * rhs as i64 + extra_secs; + Duration { secs: secs, nanos: nanos as i32 } + } +} + +impl Div<i32> for Duration { + type Output = Duration; + + fn div(self, rhs: i32) -> Duration { + let mut secs = self.secs / rhs as i64; + let carry = self.secs - secs * rhs as i64; + let extra_nanos = carry * NANOS_PER_SEC as i64 / rhs as i64; + let mut nanos = self.nanos / rhs + extra_nanos as i32; + if nanos >= NANOS_PER_SEC { + nanos -= NANOS_PER_SEC; + secs += 1; + } + if nanos < 0 { + nanos += NANOS_PER_SEC; + secs -= 1; + } + Duration { secs: secs, nanos: nanos } + } +} + +impl fmt::Display for Duration { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // technically speaking, negative duration is not valid ISO 8601, + // but we need to print it anyway. + let (abs, sign) = if self.secs < 0 { (-*self, "-") } else { (*self, "") }; + + let days = abs.secs / SECS_PER_DAY; + let secs = abs.secs - days * SECS_PER_DAY; + let hasdate = days != 0; + let hastime = (secs != 0 || abs.nanos != 0) || !hasdate; + + try!(write!(f, "{}P", sign)); + + if hasdate { + try!(write!(f, "{}D", days)); + } + if hastime { + if abs.nanos == 0 { + try!(write!(f, "T{}S", secs)); + } else if abs.nanos % NANOS_PER_MILLI == 0 { + try!(write!(f, "T{}.{:03}S", secs, abs.nanos / NANOS_PER_MILLI)); + } else if abs.nanos % NANOS_PER_MICRO == 0 { + try!(write!(f, "T{}.{:06}S", secs, abs.nanos / NANOS_PER_MICRO)); + } else { + try!(write!(f, "T{}.{:09}S", secs, abs.nanos)); + } + } + Ok(()) + } +} + +// Copied from libnum +#[inline] +fn div_mod_floor_64(this: i64, other: i64) -> (i64, i64) { + (div_floor_64(this, other), mod_floor_64(this, other)) +} + +#[inline] +fn div_floor_64(this: i64, other: i64) -> i64 { + match div_rem_64(this, other) { + (d, r) if (r > 0 && other < 0) + || (r < 0 && other > 0) => d - 1, + (d, _) => d, + } +} + +#[inline] +fn mod_floor_64(this: i64, other: i64) -> i64 { + match this % other { + r if (r > 0 && other < 0) + || (r < 0 && other > 0) => r + other, + r => r, + } +} + +#[inline] +fn div_rem_64(this: i64, other: i64) -> (i64, i64) { + (this / other, this % other) +} + +#[cfg(test)] +mod tests { + use super::{Duration, MIN, MAX}; + use std::{i32, i64}; + + #[test] + fn test_duration() { + assert!(Duration::seconds(1) != Duration::zero()); + assert_eq!(Duration::seconds(1) + Duration::seconds(2), Duration::seconds(3)); + assert_eq!(Duration::seconds(86399) + Duration::seconds(4), + Duration::days(1) + Duration::seconds(3)); + assert_eq!(Duration::days(10) - Duration::seconds(1000), Duration::seconds(863000)); + assert_eq!(Duration::days(10) - Duration::seconds(1000000), Duration::seconds(-136000)); + assert_eq!(Duration::days(2) + Duration::seconds(86399) + + Duration::nanoseconds(1234567890), + Duration::days(3) + Duration::nanoseconds(234567890)); + assert_eq!(-Duration::days(3), Duration::days(-3)); + assert_eq!(-(Duration::days(3) + Duration::seconds(70)), + Duration::days(-4) + Duration::seconds(86400-70)); + } + + #[test] + fn test_duration_num_days() { + assert_eq!(Duration::zero().num_days(), 0); + assert_eq!(Duration::days(1).num_days(), 1); + assert_eq!(Duration::days(-1).num_days(), -1); + assert_eq!(Duration::seconds(86399).num_days(), 0); + assert_eq!(Duration::seconds(86401).num_days(), 1); + assert_eq!(Duration::seconds(-86399).num_days(), 0); + assert_eq!(Duration::seconds(-86401).num_days(), -1); + assert_eq!(Duration::days(i32::MAX as i64).num_days(), i32::MAX as i64); + assert_eq!(Duration::days(i32::MIN as i64).num_days(), i32::MIN as i64); + } + + #[test] + fn test_duration_num_seconds() { + assert_eq!(Duration::zero().num_seconds(), 0); + assert_eq!(Duration::seconds(1).num_seconds(), 1); + assert_eq!(Duration::seconds(-1).num_seconds(), -1); + assert_eq!(Duration::milliseconds(999).num_seconds(), 0); + assert_eq!(Duration::milliseconds(1001).num_seconds(), 1); + assert_eq!(Duration::milliseconds(-999).num_seconds(), 0); + assert_eq!(Duration::milliseconds(-1001).num_seconds(), -1); + } + + #[test] + fn test_duration_num_milliseconds() { + assert_eq!(Duration::zero().num_milliseconds(), 0); + assert_eq!(Duration::milliseconds(1).num_milliseconds(), 1); + assert_eq!(Duration::milliseconds(-1).num_milliseconds(), -1); + assert_eq!(Duration::microseconds(999).num_milliseconds(), 0); + assert_eq!(Duration::microseconds(1001).num_milliseconds(), 1); + assert_eq!(Duration::microseconds(-999).num_milliseconds(), 0); + assert_eq!(Duration::microseconds(-1001).num_milliseconds(), -1); + assert_eq!(Duration::milliseconds(i64::MAX).num_milliseconds(), i64::MAX); + assert_eq!(Duration::milliseconds(i64::MIN).num_milliseconds(), i64::MIN); + assert_eq!(MAX.num_milliseconds(), i64::MAX); + assert_eq!(MIN.num_milliseconds(), i64::MIN); + } + + #[test] + fn test_duration_num_microseconds() { + assert_eq!(Duration::zero().num_microseconds(), Some(0)); + assert_eq!(Duration::microseconds(1).num_microseconds(), Some(1)); + assert_eq!(Duration::microseconds(-1).num_microseconds(), Some(-1)); + assert_eq!(Duration::nanoseconds(999).num_microseconds(), Some(0)); + assert_eq!(Duration::nanoseconds(1001).num_microseconds(), Some(1)); + assert_eq!(Duration::nanoseconds(-999).num_microseconds(), Some(0)); + assert_eq!(Duration::nanoseconds(-1001).num_microseconds(), Some(-1)); + assert_eq!(Duration::microseconds(i64::MAX).num_microseconds(), Some(i64::MAX)); + assert_eq!(Duration::microseconds(i64::MIN).num_microseconds(), Some(i64::MIN)); + assert_eq!(MAX.num_microseconds(), None); + assert_eq!(MIN.num_microseconds(), None); + + // overflow checks + const MICROS_PER_DAY: i64 = 86400_000_000; + assert_eq!(Duration::days(i64::MAX / MICROS_PER_DAY).num_microseconds(), + Some(i64::MAX / MICROS_PER_DAY * MICROS_PER_DAY)); + assert_eq!(Duration::days(i64::MIN / MICROS_PER_DAY).num_microseconds(), + Some(i64::MIN / MICROS_PER_DAY * MICROS_PER_DAY)); + assert_eq!(Duration::days(i64::MAX / MICROS_PER_DAY + 1).num_microseconds(), None); + assert_eq!(Duration::days(i64::MIN / MICROS_PER_DAY - 1).num_microseconds(), None); + } + + #[test] + fn test_duration_num_nanoseconds() { + assert_eq!(Duration::zero().num_nanoseconds(), Some(0)); + assert_eq!(Duration::nanoseconds(1).num_nanoseconds(), Some(1)); + assert_eq!(Duration::nanoseconds(-1).num_nanoseconds(), Some(-1)); + assert_eq!(Duration::nanoseconds(i64::MAX).num_nanoseconds(), Some(i64::MAX)); + assert_eq!(Duration::nanoseconds(i64::MIN).num_nanoseconds(), Some(i64::MIN)); + assert_eq!(MAX.num_nanoseconds(), None); + assert_eq!(MIN.num_nanoseconds(), None); + + // overflow checks + const NANOS_PER_DAY: i64 = 86400_000_000_000; + assert_eq!(Duration::days(i64::MAX / NANOS_PER_DAY).num_nanoseconds(), + Some(i64::MAX / NANOS_PER_DAY * NANOS_PER_DAY)); + assert_eq!(Duration::days(i64::MIN / NANOS_PER_DAY).num_nanoseconds(), + Some(i64::MIN / NANOS_PER_DAY * NANOS_PER_DAY)); + assert_eq!(Duration::days(i64::MAX / NANOS_PER_DAY + 1).num_nanoseconds(), None); + assert_eq!(Duration::days(i64::MIN / NANOS_PER_DAY - 1).num_nanoseconds(), None); + } + + #[test] + fn test_duration_checked_ops() { + assert_eq!(Duration::milliseconds(i64::MAX - 1).checked_add(&Duration::microseconds(999)), + Some(Duration::milliseconds(i64::MAX - 2) + Duration::microseconds(1999))); + assert!(Duration::milliseconds(i64::MAX).checked_add(&Duration::microseconds(1000)) + .is_none()); + + assert_eq!(Duration::milliseconds(i64::MIN).checked_sub(&Duration::milliseconds(0)), + Some(Duration::milliseconds(i64::MIN))); + assert!(Duration::milliseconds(i64::MIN).checked_sub(&Duration::milliseconds(1)) + .is_none()); + } + + #[test] + fn test_duration_mul() { + assert_eq!(Duration::zero() * i32::MAX, Duration::zero()); + assert_eq!(Duration::zero() * i32::MIN, Duration::zero()); + assert_eq!(Duration::nanoseconds(1) * 0, Duration::zero()); + assert_eq!(Duration::nanoseconds(1) * 1, Duration::nanoseconds(1)); + assert_eq!(Duration::nanoseconds(1) * 1_000_000_000, Duration::seconds(1)); + assert_eq!(Duration::nanoseconds(1) * -1_000_000_000, -Duration::seconds(1)); + assert_eq!(-Duration::nanoseconds(1) * 1_000_000_000, -Duration::seconds(1)); + assert_eq!(Duration::nanoseconds(30) * 333_333_333, + Duration::seconds(10) - Duration::nanoseconds(10)); + assert_eq!((Duration::nanoseconds(1) + Duration::seconds(1) + Duration::days(1)) * 3, + Duration::nanoseconds(3) + Duration::seconds(3) + Duration::days(3)); + assert_eq!(Duration::milliseconds(1500) * -2, Duration::seconds(-3)); + assert_eq!(Duration::milliseconds(-1500) * 2, Duration::seconds(-3)); + } + + #[test] + fn test_duration_div() { + assert_eq!(Duration::zero() / i32::MAX, Duration::zero()); + assert_eq!(Duration::zero() / i32::MIN, Duration::zero()); + assert_eq!(Duration::nanoseconds(123_456_789) / 1, Duration::nanoseconds(123_456_789)); + assert_eq!(Duration::nanoseconds(123_456_789) / -1, -Duration::nanoseconds(123_456_789)); + assert_eq!(-Duration::nanoseconds(123_456_789) / -1, Duration::nanoseconds(123_456_789)); + assert_eq!(-Duration::nanoseconds(123_456_789) / 1, -Duration::nanoseconds(123_456_789)); + assert_eq!(Duration::seconds(1) / 3, Duration::nanoseconds(333_333_333)); + assert_eq!(Duration::seconds(4) / 3, Duration::nanoseconds(1_333_333_333)); + assert_eq!(Duration::seconds(-1) / 2, Duration::milliseconds(-500)); + assert_eq!(Duration::seconds(1) / -2, Duration::milliseconds(-500)); + assert_eq!(Duration::seconds(-1) / -2, Duration::milliseconds(500)); + assert_eq!(Duration::seconds(-4) / 3, Duration::nanoseconds(-1_333_333_333)); + assert_eq!(Duration::seconds(-4) / -3, Duration::nanoseconds(1_333_333_333)); + } + + #[test] + fn test_duration_fmt() { + assert_eq!(Duration::zero().to_string(), "PT0S"); + assert_eq!(Duration::days(42).to_string(), "P42D"); + assert_eq!(Duration::days(-42).to_string(), "-P42D"); + assert_eq!(Duration::seconds(42).to_string(), "PT42S"); + assert_eq!(Duration::milliseconds(42).to_string(), "PT0.042S"); + assert_eq!(Duration::microseconds(42).to_string(), "PT0.000042S"); + assert_eq!(Duration::nanoseconds(42).to_string(), "PT0.000000042S"); + assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_string(), + "P7DT6.543S"); + assert_eq!(Duration::seconds(-86401).to_string(), "-P1DT1S"); + assert_eq!(Duration::nanoseconds(-1).to_string(), "-PT0.000000001S"); + + // the format specifier should have no effect on `Duration` + assert_eq!(format!("{:30}", Duration::days(1) + Duration::milliseconds(2345)), + "P1DT2.345S"); + } +} diff --git a/deps/time-0.1.26/src/lib.rs b/deps/time-0.1.26/src/lib.rs new file mode 100644 index 000000000..c704f9921 --- /dev/null +++ b/deps/time-0.1.26/src/lib.rs @@ -0,0 +1,1553 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Simple time handling. +//! +//! # Usage +//! +//! This crate is [on crates.io](https://crates.io/crates/time) and can be +//! used by adding `time` to the dependencies in your project's `Cargo.toml`. +//! +//! ```toml +//! [dependencies] +//! time = "0.1" +//! ``` +//! +//! And this in your crate root: +//! +//! ```rust +//! extern crate time; +//! ``` + +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/time/")] +#![allow(trivial_numeric_casts)] +#![cfg_attr(test, deny(warnings))] + +#[cfg(test)] #[macro_use] extern crate log; + +extern crate libc; +#[cfg(feature = "rustc-serialize")] +extern crate rustc_serialize; + +use std::cmp::Ordering; +use std::fmt; +use std::ops::{Add, Sub}; +use std::io; + +pub use duration::Duration; + +use self::ParseError::{InvalidDay, InvalidDayOfMonth, InvalidDayOfWeek, + InvalidDayOfYear, InvalidFormatSpecifier, InvalidHour, + InvalidMinute, InvalidMonth, InvalidSecond, InvalidTime, + InvalidYear, InvalidZoneOffset, InvalidSecondsSinceEpoch, + MissingFormatConverter, UnexpectedCharacter}; + +pub use parse::strptime; + +mod display; +mod parse; +mod duration; + +static NSEC_PER_SEC: i32 = 1_000_000_000; + +mod rustrt { + use super::Tm; + + extern { + pub fn rust_time_gmtime(sec: i64, nsec: i32, result: &mut Tm); + pub fn rust_time_localtime(sec: i64, nsec: i32, result: &mut Tm) -> i32; + pub fn rust_time_timegm(tm: &Tm) -> i64; + pub fn rust_time_mktime(tm: &Tm) -> i64; + } +} + +#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios")))] +mod imp { + use libc::{c_int, timespec}; + + #[cfg(all(not(target_os = "android"), + not(target_os = "bitrig"), + not(target_os = "nacl"), + not(target_os = "openbsd")))] + #[link(name = "rt")] + extern {} + + extern { + pub fn clock_gettime(clk_id: c_int, tp: *mut timespec) -> c_int; + } + +} +#[cfg(any(target_os = "macos", target_os = "ios"))] +mod imp { + use libc::{timeval, timezone, c_int, mach_timebase_info}; + use std::sync::{Once, ONCE_INIT}; + + extern { + pub fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int; + pub fn mach_absolute_time() -> u64; + pub fn mach_timebase_info(info: *mut mach_timebase_info) -> c_int; + } + + pub fn info() -> &'static mach_timebase_info { + static mut INFO: mach_timebase_info = mach_timebase_info { + numer: 0, + denom: 0, + }; + static ONCE: Once = ONCE_INIT; + + unsafe { + ONCE.call_once(|| { + mach_timebase_info(&mut INFO); + }); + &INFO + } + } +} + +#[cfg(windows)] +mod imp { + use libc; + use std::sync::{Once, ONCE_INIT}; + + pub fn frequency() -> libc::LARGE_INTEGER { + static mut FREQUENCY: libc::LARGE_INTEGER = 0; + static ONCE: Once = ONCE_INIT; + + unsafe { + ONCE.call_once(|| { + libc::QueryPerformanceFrequency(&mut FREQUENCY); + }); + FREQUENCY + } + } +} + +/// A record specifying a time value in seconds and nanoseconds, where +/// nanoseconds represent the offset from the given second. +/// +/// For example a timespec of 1.2 seconds after the beginning of the epoch would +/// be represented as {sec: 1, nsec: 200000000}. +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] +#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] +pub struct Timespec { pub sec: i64, pub nsec: i32 } +/* + * Timespec assumes that pre-epoch Timespecs have negative sec and positive + * nsec fields. Darwin's and Linux's struct timespec functions handle pre- + * epoch timestamps using a "two steps back, one step forward" representation, + * though the man pages do not actually document this. For example, the time + * -1.2 seconds before the epoch is represented by `Timespec { sec: -2_i64, + * nsec: 800_000_000 }`. + */ +impl Timespec { + pub fn new(sec: i64, nsec: i32) -> Timespec { + assert!(nsec >= 0 && nsec < NSEC_PER_SEC); + Timespec { sec: sec, nsec: nsec } + } +} + +impl Add<Duration> for Timespec { + type Output = Timespec; + + fn add(self, other: Duration) -> Timespec { + let d_sec = other.num_seconds(); + // It is safe to unwrap the nanoseconds, because there cannot be + // more than one second left, which fits in i64 and in i32. + let d_nsec = (other - Duration::seconds(d_sec)) + .num_nanoseconds().unwrap() as i32; + let mut sec = self.sec + d_sec; + let mut nsec = self.nsec + d_nsec; + if nsec >= NSEC_PER_SEC { + nsec -= NSEC_PER_SEC; + sec += 1; + } else if nsec < 0 { + nsec += NSEC_PER_SEC; + sec -= 1; + } + Timespec::new(sec, nsec) + } +} + +impl Sub<Duration> for Timespec { + type Output = Timespec; + + fn sub(self, other: Duration) -> Timespec { + let d_sec = other.num_seconds(); + // It is safe to unwrap the nanoseconds, because there cannot be + // more than one second left, which fits in i64 and in i32. + let d_nsec = (other - Duration::seconds(d_sec)) + .num_nanoseconds().unwrap() as i32; + let mut sec = self.sec - d_sec; + let mut nsec = self.nsec - d_nsec; + if nsec >= NSEC_PER_SEC { + nsec -= NSEC_PER_SEC; + sec += 1; + } else if nsec < 0 { + nsec += NSEC_PER_SEC; + sec -= 1; + } + Timespec::new(sec, nsec) + } +} + +impl Sub<Timespec> for Timespec { + type Output = Duration; + + fn sub(self, other: Timespec) -> Duration { + let sec = self.sec - other.sec; + let nsec = self.nsec - other.nsec; + Duration::seconds(sec) + Duration::nanoseconds(nsec as i64) + } +} + +/** + * Returns the current time as a `timespec` containing the seconds and + * nanoseconds since 1970-01-01T00:00:00Z. + */ +pub fn get_time() -> Timespec { + unsafe { + let (sec, nsec) = os_get_time(); + return Timespec::new(sec, nsec); + } + + #[cfg(windows)] + unsafe fn os_get_time() -> (i64, i32) { + static MICROSECONDS_FROM_1601_TO_1970: u64 = 11644473600000000; + + let mut time = libc::FILETIME { + dwLowDateTime: 0, + dwHighDateTime: 0, + }; + libc::GetSystemTimeAsFileTime(&mut time); + + // A FILETIME contains a 64-bit value representing the number of + // hectonanosecond (100-nanosecond) intervals since 1601-01-01T00:00:00Z. + // http://support.microsoft.com/kb/167296/en-us + let us_since_1601 = (((time.dwHighDateTime as u64) << 32) | + ((time.dwLowDateTime as u64) << 0)) / 10; + let us_since_1970 = us_since_1601 - MICROSECONDS_FROM_1601_TO_1970; + + ((us_since_1970 / 1000000) as i64, + ((us_since_1970 % 1000000) * 1000) as i32) + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + unsafe fn os_get_time() -> (i64, i32) { + use std::ptr; + let mut tv = libc::timeval { tv_sec: 0, tv_usec: 0 }; + imp::gettimeofday(&mut tv, ptr::null_mut()); + (tv.tv_sec as i64, tv.tv_usec * 1000) + } + + #[cfg(not(any(target_os = "macos", target_os = "ios", windows)))] + unsafe fn os_get_time() -> (i64, i32) { + let mut tv = libc::timespec { tv_sec: 0, tv_nsec: 0 }; + imp::clock_gettime(libc::CLOCK_REALTIME, &mut tv); + (tv.tv_sec as i64, tv.tv_nsec as i32) + } +} + + +/** + * Returns the current value of a high-resolution performance counter + * in nanoseconds since an unspecified epoch. + */ +pub fn precise_time_ns() -> u64 { + return os_precise_time_ns(); + + #[cfg(windows)] + fn os_precise_time_ns() -> u64 { + let mut ticks = 0; + assert_eq!(unsafe { + libc::QueryPerformanceCounter(&mut ticks) + }, 1); + + mul_div_i64(ticks as i64, 1000000000, imp::frequency() as i64) as u64 + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + fn os_precise_time_ns() -> u64 { + unsafe { + let time = imp::mach_absolute_time(); + let info = imp::info(); + time * info.numer as u64 / info.denom as u64 + } + } + + #[cfg(not(any(windows, target_os = "macos", target_os = "ios")))] + fn os_precise_time_ns() -> u64 { + let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 }; + unsafe { + imp::clock_gettime(libc::CLOCK_MONOTONIC, &mut ts); + } + return (ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64) + } +} + + +/** + * Returns the current value of a high-resolution performance counter + * in seconds since an unspecified epoch. + */ +pub fn precise_time_s() -> f64 { + return (precise_time_ns() as f64) / 1000000000.; +} + +/// An opaque structure representing a moment in time. +/// +/// The only operation that can be performed on a `PreciseTime` is the +/// calculation of the `Duration` of time that lies between them. +/// +/// # Examples +/// +/// Repeatedly call a function for 1 second: +/// +/// ```rust +/// use time::{Duration, PreciseTime}; +/// # fn do_some_work() {} +/// +/// let start = PreciseTime::now(); +/// +/// while start.to(PreciseTime::now()) < Duration::seconds(1) { +/// do_some_work(); +/// } +/// ``` +#[derive(Copy, Clone)] +pub struct PreciseTime(u64); + +impl PreciseTime { + /// Returns a `PreciseTime` representing the current moment in time. + pub fn now() -> PreciseTime { + PreciseTime(precise_time_ns()) + } + + /// Returns a `Duration` representing the span of time from the value of + /// `self` to the value of `later`. + /// + /// # Notes + /// + /// If `later` represents a time before `self`, the result of this method + /// is unspecified. + /// + /// If `later` represents a time more than 293 years after `self`, the + /// result of this method is unspecified. + #[inline] + pub fn to(&self, later: PreciseTime) -> Duration { + // NB: even if later is less than self due to overflow, this will work + // since the subtraction will underflow properly as well. + // + // We could deal with the overflow when casting to an i64, but all that + // gets us is the ability to handle intervals of up to 584 years, which + // seems not very useful :) + Duration::nanoseconds((later.0 - self.0) as i64) + } +} + +/// A structure representing a moment in time. +/// +/// `SteadyTime`s are generated by a "steady" clock, that is, a clock which +/// never experiences discontinuous jumps and for which time always flows at +/// the same rate. +/// +/// # Examples +/// +/// Repeatedly call a function for 1 second: +/// +/// ```rust +/// # use time::{Duration, SteadyTime}; +/// # fn do_some_work() {} +/// let start = SteadyTime::now(); +/// +/// while SteadyTime::now() - start < Duration::seconds(1) { +/// do_some_work(); +/// } +/// ``` +#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)] +pub struct SteadyTime(steady::SteadyTime); + +impl SteadyTime { + /// Returns a `SteadyTime` representing the current moment in time. + pub fn now() -> SteadyTime { + SteadyTime(steady::SteadyTime::now()) + } +} + +impl fmt::Display for SteadyTime { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + // TODO: needs a display customization + fmt::Debug::fmt(self, fmt) + } +} + +impl Sub for SteadyTime { + type Output = Duration; + + fn sub(self, other: SteadyTime) -> Duration { + self.0 - other.0 + } +} + +impl Sub<Duration> for SteadyTime { + type Output = SteadyTime; + + fn sub(self, other: Duration) -> SteadyTime { + SteadyTime(self.0 - other) + } +} + +impl Add<Duration> for SteadyTime { + type Output = SteadyTime; + + fn add(self, other: Duration) -> SteadyTime { + SteadyTime(self.0 + other) + } +} + +#[cfg(any(target_os = "macos", target_os = "ios"))] +mod steady { + use imp; + use Duration; + use std::ops::{Sub, Add}; + + #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)] + pub struct SteadyTime { + t: u64, + } + + impl SteadyTime { + pub fn now() -> SteadyTime { + SteadyTime { + t: unsafe { imp::mach_absolute_time() }, + } + } + } + + impl Sub for SteadyTime { + type Output = Duration; + + fn sub(self, other: SteadyTime) -> Duration { + let info = imp::info(); + let diff = self.t as i64 - other.t as i64; + Duration::nanoseconds(diff * info.numer as i64 / info.denom as i64) + } + } + + impl Sub<Duration> for SteadyTime { + type Output = SteadyTime; + + fn sub(self, other: Duration) -> SteadyTime { + self + -other + } + } + + impl Add<Duration> for SteadyTime { + type Output = SteadyTime; + + fn add(self, other: Duration) -> SteadyTime { + let info = imp::info(); + let delta = other.num_nanoseconds().unwrap() * info.denom as i64 / info.numer as i64; + SteadyTime { + t: (self.t as i64 + delta) as u64 + } + } + } +} + +#[cfg(not(any(windows, target_os = "macos", target_os = "ios")))] +mod steady { + use {imp, NSEC_PER_SEC, Duration}; + use libc; + use std::cmp::{PartialOrd, Ord, Ordering, PartialEq, Eq}; + use std::ops::{Sub, Add}; + use std::fmt; + + #[derive(Copy)] + pub struct SteadyTime { + t: libc::timespec, + } + + impl fmt::Debug for SteadyTime { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "SteadyTime {{ tv_sec: {:?}, tv_nsec: {:?} }}", + self.t.tv_sec, self.t.tv_nsec) + } + } + + impl Clone for SteadyTime { + fn clone(&self) -> SteadyTime { + SteadyTime { t: self.t } + } + } + + impl SteadyTime { + pub fn now() -> SteadyTime { + let mut t = SteadyTime { + t: libc::timespec { + tv_sec: 0, + tv_nsec: 0, + } + }; + unsafe { + assert_eq!(0, imp::clock_gettime(libc::CLOCK_MONOTONIC, &mut t.t)); + } + t + } + } + + impl Sub for SteadyTime { + type Output = Duration; + + fn sub(self, other: SteadyTime) -> Duration { + if self.t.tv_nsec >= other.t.tv_nsec { + Duration::seconds(self.t.tv_sec as i64 - other.t.tv_sec as i64) + + Duration::nanoseconds(self.t.tv_nsec as i64 - other.t.tv_nsec as i64) + } else { + Duration::seconds(self.t.tv_sec as i64 - 1 - other.t.tv_sec as i64) + + Duration::nanoseconds(self.t.tv_nsec as i64 + NSEC_PER_SEC as i64 - + other.t.tv_nsec as i64) + } + } + } + + impl Sub<Duration> for SteadyTime { + type Output = SteadyTime; + + fn sub(self, other: Duration) -> SteadyTime { + self + -other + } + } + + impl Add<Duration> for SteadyTime { + type Output = SteadyTime; + + fn add(mut self, other: Duration) -> SteadyTime { + let seconds = other.num_seconds(); + let nanoseconds = (other - Duration::seconds(seconds)).num_nanoseconds().unwrap(); + self.t.tv_sec += seconds as libc::time_t; + self.t.tv_nsec += nanoseconds as libc::c_long; + if self.t.tv_nsec >= NSEC_PER_SEC as libc::c_long { + self.t.tv_nsec -= NSEC_PER_SEC as libc::c_long; + self.t.tv_sec += 1; + } else if self.t.tv_nsec < 0 { + self.t.tv_sec -= 1; + self.t.tv_nsec += NSEC_PER_SEC as libc::c_long; + } + self + } + } + + impl PartialOrd for SteadyTime { + fn partial_cmp(&self, other: &SteadyTime) -> Option<Ordering> { + Some(self.cmp(other)) + } + } + + impl Ord for SteadyTime { + fn cmp(&self, other: &SteadyTime) -> Ordering { + match self.t.tv_sec.cmp(&other.t.tv_sec) { + Ordering::Equal => self.t.tv_nsec.cmp(&other.t.tv_nsec), + ord => ord + } + } + } + + impl PartialEq for SteadyTime { + fn eq(&self, other: &SteadyTime) -> bool { + self.t.tv_sec == other.t.tv_sec && self.t.tv_nsec == other.t.tv_nsec + } + } + + impl Eq for SteadyTime {} +} + +#[cfg(windows)] +mod steady { + use {imp, Duration}; + use libc; + use std::ops::{Sub, Add}; + + #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)] + pub struct SteadyTime { + t: libc::LARGE_INTEGER, + } + + impl SteadyTime { + pub fn now() -> SteadyTime { + let mut t = SteadyTime { t: 0 }; + unsafe { libc::QueryPerformanceCounter(&mut t.t); } + t + } + } + + impl Sub for SteadyTime { + type Output = Duration; + + fn sub(self, other: SteadyTime) -> Duration { + let diff = self.t as i64 - other.t as i64; + Duration::nanoseconds(::mul_div_i64(diff, 1000000000, + imp::frequency() as i64)) + } + } + + impl Sub<Duration> for SteadyTime { + type Output = SteadyTime; + + fn sub(self, other: Duration) -> SteadyTime { + self + -other + } + } + + impl Add<Duration> for SteadyTime { + type Output = SteadyTime; + + fn add(mut self, other: Duration) -> SteadyTime { + self.t += (other.num_microseconds().unwrap() * imp::frequency() as i64 / 1_000_000) + as libc::LARGE_INTEGER; + self + } + } +} + +pub fn tzset() { + #[cfg(windows)] extern { #[link_name = "_tzset"] fn tzset(); } + #[cfg(not(windows))] extern { fn tzset(); } + unsafe { tzset() } +} + +/// Holds a calendar date and time broken down into its components (year, month, +/// day, and so on), also called a broken-down time value. +// FIXME: use c_int instead of i32? +#[repr(C)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub struct Tm { + /// Seconds after the minute - [0, 60] + pub tm_sec: i32, + + /// Minutes after the hour - [0, 59] + pub tm_min: i32, + + /// Hours after midnight - [0, 23] + pub tm_hour: i32, + + /// Day of the month - [1, 31] + pub tm_mday: i32, + + /// Months since January - [0, 11] + pub tm_mon: i32, + + /// Years since 1900 + pub tm_year: i32, + + /// Days since Sunday - [0, 6]. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. + pub tm_wday: i32, + + /// Days since January 1 - [0, 365] + pub tm_yday: i32, + + /// Daylight Saving Time flag. + /// + /// This value is positive if Daylight Saving Time is in effect, zero if + /// Daylight Saving Time is not in effect, and negative if this information + /// is not available. + pub tm_isdst: i32, + + /// Identifies the time zone that was used to compute this broken-down time + /// value, including any adjustment for Daylight Saving Time. This is the + /// number of seconds east of UTC. For example, for U.S. Pacific Daylight + /// Time, the value is -7*60*60 = -25200. + pub tm_utcoff: i32, + + /// Nanoseconds after the second - [0, 10<sup>9</sup> - 1] + pub tm_nsec: i32, +} + +impl Add<Duration> for Tm { + type Output = Tm; + + /// The resulting Tm is in UTC. + // FIXME: The resulting Tm should have the same timezone as `self`; + // however, we need a function such as `at_tm(clock: Timespec, offset: i32)` + // for this. + fn add(self, other: Duration) -> Tm { + at_utc(self.to_timespec() + other) + } +} + +impl Sub<Duration> for Tm { + type Output = Tm; + + /// The resulting Tm is in UTC. + // FIXME: The resulting Tm should have the same timezone as `self`; + // however, we need a function such as `at_tm(clock: Timespec, offset: i32)` + // for this. + fn sub(self, other: Duration) -> Tm { + at_utc(self.to_timespec() - other) + } +} + +impl Sub<Tm> for Tm { + type Output = Duration; + + fn sub(self, other: Tm) -> Duration { + self.to_timespec() - other.to_timespec() + } +} + +impl PartialOrd for Tm { + fn partial_cmp(&self, other: &Tm) -> Option<Ordering> { + self.to_timespec().partial_cmp(&other.to_timespec()) + } +} + +impl Ord for Tm { + fn cmp(&self, other: &Tm) -> Ordering { + self.to_timespec().cmp(&other.to_timespec()) + } +} + +pub fn empty_tm() -> Tm { + Tm { + tm_sec: 0, + tm_min: 0, + tm_hour: 0, + tm_mday: 0, + tm_mon: 0, + tm_year: 0, + tm_wday: 0, + tm_yday: 0, + tm_isdst: 0, + tm_utcoff: 0, + tm_nsec: 0, + } +} + +/// Returns the specified time in UTC +pub fn at_utc(clock: Timespec) -> Tm { + unsafe { + let Timespec { sec, nsec } = clock; + let mut tm = empty_tm(); + rustrt::rust_time_gmtime(sec, nsec, &mut tm); + tm + } +} + +/// Returns the current time in UTC +pub fn now_utc() -> Tm { + at_utc(get_time()) +} + +/// Returns the specified time in the local timezone +pub fn at(clock: Timespec) -> Tm { + unsafe { + let Timespec { sec, nsec } = clock; + let mut tm = empty_tm(); + if rustrt::rust_time_localtime(sec, nsec, &mut tm) == 0 { + panic!("failed to call localtime: {}", + io::Error::last_os_error()); + } + tm + } +} + +/// Returns the current time in the local timezone +pub fn now() -> Tm { + at(get_time()) +} + +impl Tm { + /// Convert time to the seconds from January 1, 1970 + pub fn to_timespec(&self) -> Timespec { + unsafe { + let sec = match self.tm_utcoff { + 0 => rustrt::rust_time_timegm(self), + _ => rustrt::rust_time_mktime(self) + }; + + Timespec::new(sec, self.tm_nsec) + } + } + + /// Convert time to the local timezone + pub fn to_local(&self) -> Tm { + at(self.to_timespec()) + } + + /// Convert time to the UTC + pub fn to_utc(&self) -> Tm { + match self.tm_utcoff { + 0 => *self, + _ => at_utc(self.to_timespec()) + } + } + + /** + * Returns a TmFmt that outputs according to the `asctime` format in ISO + * C, in the local timezone. + * + * Example: "Thu Jan 1 00:00:00 1970" + */ + pub fn ctime(&self) -> TmFmt { + TmFmt { + tm: self, + format: Fmt::Ctime, + } + } + + /** + * Returns a TmFmt that outputs according to the `asctime` format in ISO + * C. + * + * Example: "Thu Jan 1 00:00:00 1970" + */ + pub fn asctime(&self) -> TmFmt { + TmFmt { + tm: self, + format: Fmt::Str("%c"), + } + } + + /// Formats the time according to the format string. + pub fn strftime<'a>(&'a self, format: &'a str) -> Result<TmFmt<'a>, ParseError> { + validate_format(TmFmt { + tm: self, + format: Fmt::Str(format), + }) + } + + /** + * Returns a TmFmt that outputs according to RFC 822. + * + * local: "Thu, 22 Mar 2012 07:53:18 PST" + * utc: "Thu, 22 Mar 2012 14:53:18 GMT" + */ + pub fn rfc822(&self) -> TmFmt { + let fmt = if self.tm_utcoff == 0 { + "%a, %d %b %Y %T GMT" + } else { + "%a, %d %b %Y %T %Z" + }; + TmFmt { + tm: self, + format: Fmt::Str(fmt), + } + } + + /** + * Returns a TmFmt that outputs according to RFC 822 with Zulu time. + * + * local: "Thu, 22 Mar 2012 07:53:18 -0700" + * utc: "Thu, 22 Mar 2012 14:53:18 -0000" + */ + pub fn rfc822z(&self) -> TmFmt { + TmFmt { + tm: self, + format: Fmt::Str("%a, %d %b %Y %T %z"), + } + } + + /** + * Returns a TmFmt that outputs according to RFC 3339. RFC 3339 is + * compatible with ISO 8601. + * + * local: "2012-02-22T07:53:18-07:00" + * utc: "2012-02-22T14:53:18Z" + */ + pub fn rfc3339<'a>(&'a self) -> TmFmt { + TmFmt { + tm: self, + format: Fmt::Rfc3339, + } + } +} + +#[derive(Copy, PartialEq, Debug, Clone)] +pub enum ParseError { + InvalidSecond, + InvalidMinute, + InvalidHour, + InvalidDay, + InvalidMonth, + InvalidYear, + InvalidDayOfWeek, + InvalidDayOfMonth, + InvalidDayOfYear, + InvalidZoneOffset, + InvalidTime, + InvalidSecondsSinceEpoch, + MissingFormatConverter, + InvalidFormatSpecifier(char), + UnexpectedCharacter(char, char), +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + InvalidSecond => write!(f, "Invalid second."), + InvalidMinute => write!(f, "Invalid minute."), + InvalidHour => write!(f, "Invalid hour."), + InvalidDay => write!(f, "Invalid day."), + InvalidMonth => write!(f, "Invalid month."), + InvalidYear => write!(f, "Invalid year."), + InvalidDayOfWeek => write!(f, "Invalid day of the week."), + InvalidDayOfMonth => write!(f, "Invalid day of the month."), + InvalidDayOfYear => write!(f, "Invalid day of the year."), + InvalidZoneOffset => write!(f, "Invalid zone offset."), + InvalidTime => write!(f, "Invalid time."), + InvalidSecondsSinceEpoch => write!(f, "Invalid seconds since epoch."), + MissingFormatConverter => { + write!(f, "missing format converter after `%`") + } + InvalidFormatSpecifier(ch) => { + write!(f, "invalid format specifier: %{}", ch) + } + UnexpectedCharacter(a, b) => { + write!(f, "expected: `{}`, found: `{}`", a, b) + } + } + } +} + +/// A wrapper around a `Tm` and format string that implements Display. +#[derive(Debug)] +pub struct TmFmt<'a> { + tm: &'a Tm, + format: Fmt<'a> +} + +#[derive(Debug)] +enum Fmt<'a> { + Str(&'a str), + Rfc3339, + Ctime, +} + +fn validate_format<'a>(fmt: TmFmt<'a>) -> Result<TmFmt<'a>, ParseError> { + + match (fmt.tm.tm_wday, fmt.tm.tm_mon) { + (0...6, 0...11) => (), + (_wday, 0...11) => return Err(InvalidDayOfWeek), + (0...6, _mon) => return Err(InvalidMonth), + _ => return Err(InvalidDay) + } + match fmt.format { + Fmt::Str(ref s) => { + let mut chars = s.chars(); + loop { + match chars.next() { + Some('%') => { + match chars.next() { + Some('A') | Some('a') | Some('B') | Some('b') | + Some('C') | Some('c') | Some('D') | Some('d') | + Some('e') | Some('F') | Some('f') | Some('G') | + Some('g') | Some('H') | Some('h') | Some('I') | + Some('j') | Some('k') | Some('l') | Some('M') | + Some('m') | Some('n') | Some('P') | Some('p') | + Some('R') | Some('r') | Some('S') | Some('s') | + Some('T') | Some('t') | Some('U') | Some('u') | + Some('V') | Some('v') | Some('W') | Some('w') | + Some('X') | Some('x') | Some('Y') | Some('y') | + Some('Z') | Some('z') | Some('+') | Some('%') => (), + + Some(c) => return Err(InvalidFormatSpecifier(c)), + None => return Err(MissingFormatConverter), + } + }, + None => break, + _ => () + } + } + }, + _ => () + } + Ok(fmt) +} + +/// Formats the time according to the format string. +pub fn strftime(format: &str, tm: &Tm) -> Result<String, ParseError> { + tm.strftime(format).map(|fmt| fmt.to_string()) +} + +// Computes (value*numer)/denom without overflow, as long as both +// (numer*denom) and the overall result fit into i64 (which is the case +// for our time conversions). +#[allow(dead_code)] +fn mul_div_i64(value: i64, numer: i64, denom: i64) -> i64 { + let q = value / denom; + let r = value % denom; + // Decompose value as (value/denom*denom + value%denom), + // substitute into (value*numer)/denom and simplify. + // r < denom, so (denom*numer) is the upper bound of (r*numer) + q * numer + r * numer / denom +} + +#[cfg(test)] +mod tests { + use super::{Timespec, get_time, precise_time_ns, precise_time_s, tzset, + at_utc, at, strptime, PreciseTime, ParseError, Duration}; + use super::mul_div_i64; + use super::ParseError::{InvalidTime, InvalidYear, MissingFormatConverter, + InvalidFormatSpecifier}; + + + #[test] + fn test_muldiv() { + assert_eq!(mul_div_i64( 1_000_000_000_001, 1_000_000_000, 1_000_000), + 1_000_000_000_001_000); + assert_eq!(mul_div_i64(-1_000_000_000_001, 1_000_000_000, 1_000_000), + -1_000_000_000_001_000); + assert_eq!(mul_div_i64(-1_000_000_000_001,-1_000_000_000, 1_000_000), + 1_000_000_000_001_000); + assert_eq!(mul_div_i64( 1_000_000_000_001, 1_000_000_000,-1_000_000), + -1_000_000_000_001_000); + assert_eq!(mul_div_i64( 1_000_000_000_001,-1_000_000_000,-1_000_000), + 1_000_000_000_001_000); + } + + #[cfg(windows)] + fn set_time_zone() { + use libc; + use std::ffi::CString; + // Windows crt doesn't see any environment variable set by + // `SetEnvironmentVariable`, which `os::setenv` internally uses. + // It is why we use `putenv` here. + extern { + fn _putenv(envstring: *const libc::c_char) -> libc::c_int; + } + + unsafe { + // Windows does not understand "America/Los_Angeles". + // PST+08 may look wrong, but not! "PST" indicates + // the name of timezone. "+08" means UTC = local + 08. + let c = CString::new("TZ=PST+08").unwrap(); + _putenv(c.as_ptr()); + } + tzset(); + } + #[cfg(not(windows))] + fn set_time_zone() { + use std::env; + env::set_var("TZ", "America/Los_Angeles"); + tzset(); + } + + fn test_get_time() { + static SOME_RECENT_DATE: i64 = 1325376000i64; // 2012-01-01T00:00:00Z + static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z + + let tv1 = get_time(); + debug!("tv1={} sec + {} nsec", tv1.sec, tv1.nsec); + + assert!(tv1.sec > SOME_RECENT_DATE); + assert!(tv1.nsec < 1000000000i32); + + let tv2 = get_time(); + debug!("tv2={} sec + {} nsec", tv2.sec, tv2.nsec); + + assert!(tv2.sec >= tv1.sec); + assert!(tv2.sec < SOME_FUTURE_DATE); + assert!(tv2.nsec < 1000000000i32); + if tv2.sec == tv1.sec { + assert!(tv2.nsec >= tv1.nsec); + } + } + + fn test_precise_time() { + let s0 = precise_time_s(); + debug!("s0={} sec", s0); + assert!(s0 > 0.); + + let ns0 = precise_time_ns(); + let ns1 = precise_time_ns(); + debug!("ns0={} ns", ns0); + debug!("ns1={} ns", ns1); + assert!(ns1 >= ns0); + + let ns2 = precise_time_ns(); + debug!("ns2={} ns", ns2); + assert!(ns2 >= ns1); + } + + fn test_precise_time_to() { + let t0 = PreciseTime(1000); + let t1 = PreciseTime(1023); + assert_eq!(Duration::nanoseconds(23), t0.to(t1)); + } + + fn test_at_utc() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let utc = at_utc(time); + + assert_eq!(utc.tm_sec, 30); + assert_eq!(utc.tm_min, 31); + assert_eq!(utc.tm_hour, 23); + assert_eq!(utc.tm_mday, 13); + assert_eq!(utc.tm_mon, 1); + assert_eq!(utc.tm_year, 109); + assert_eq!(utc.tm_wday, 5); + assert_eq!(utc.tm_yday, 43); + assert_eq!(utc.tm_isdst, 0); + assert_eq!(utc.tm_utcoff, 0); + assert_eq!(utc.tm_nsec, 54321); + } + + fn test_at() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let local = at(time); + + debug!("time_at: {:?}", local); + + assert_eq!(local.tm_sec, 30); + assert_eq!(local.tm_min, 31); + assert_eq!(local.tm_hour, 15); + assert_eq!(local.tm_mday, 13); + assert_eq!(local.tm_mon, 1); + assert_eq!(local.tm_year, 109); + assert_eq!(local.tm_wday, 5); + assert_eq!(local.tm_yday, 43); + assert_eq!(local.tm_isdst, 0); + assert_eq!(local.tm_utcoff, -28800); + assert_eq!(local.tm_nsec, 54321); + } + + fn test_to_timespec() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let utc = at_utc(time); + + assert_eq!(utc.to_timespec(), time); + assert_eq!(utc.to_local().to_timespec(), time); + } + + fn test_conversions() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let utc = at_utc(time); + let local = at(time); + + assert!(local.to_local() == local); + assert!(local.to_utc() == utc); + assert!(local.to_utc().to_local() == local); + assert!(utc.to_utc() == utc); + assert!(utc.to_local() == local); + assert!(utc.to_local().to_utc() == utc); + } + + fn test_strptime() { + set_time_zone(); + + match strptime("", "") { + Ok(ref tm) => { + assert!(tm.tm_sec == 0); + assert!(tm.tm_min == 0); + assert!(tm.tm_hour == 0); + assert!(tm.tm_mday == 0); + assert!(tm.tm_mon == 0); + assert!(tm.tm_year == 0); + assert!(tm.tm_wday == 0); + assert!(tm.tm_isdst == 0); + assert!(tm.tm_utcoff == 0); + assert!(tm.tm_nsec == 0); + } + Err(_) => () + } + + let format = "%a %b %e %T.%f %Y"; + assert_eq!(strptime("", format), Err(ParseError::InvalidDay)); + assert_eq!(strptime("Fri Feb 13 15:31:30", format), + Err(InvalidTime)); + + match strptime("Fri Feb 13 15:31:30.01234 2009", format) { + Err(e) => panic!("{}", e), + Ok(ref tm) => { + assert_eq!(tm.tm_sec, 30); + assert_eq!(tm.tm_min, 31); + assert_eq!(tm.tm_hour, 15); + assert_eq!(tm.tm_mday, 13); + assert_eq!(tm.tm_mon, 1); + assert_eq!(tm.tm_year, 109); + assert_eq!(tm.tm_wday, 5); + assert_eq!(tm.tm_yday, 0); + assert_eq!(tm.tm_isdst, 0); + assert_eq!(tm.tm_utcoff, 0); + assert_eq!(tm.tm_nsec, 12340000); + } + } + + fn test(s: &str, format: &str) -> bool { + match strptime(s, format) { + Ok(tm) => { + tm.strftime(format).unwrap().to_string() == s.to_string() + }, + Err(e) => panic!("{:?}, s={:?}, format={:?}", e, s, format) + } + } + + fn test_oneway(s : &str, format : &str) -> bool { + match strptime(s, format) { + Ok(_) => { + // oneway tests are used when reformatting the parsed Tm + // back into a string can generate a different string + // from the original (i.e. leading zeroes) + true + }, + Err(e) => panic!("{:?}, s={:?}, format={:?}", e, s, format) + } + } + + let days = [ + "Sunday".to_string(), + "Monday".to_string(), + "Tuesday".to_string(), + "Wednesday".to_string(), + "Thursday".to_string(), + "Friday".to_string(), + "Saturday".to_string() + ]; + for day in days.iter() { + assert!(test(&day, "%A")); + } + + let days = [ + "Sun".to_string(), + "Mon".to_string(), + "Tue".to_string(), + "Wed".to_string(), + "Thu".to_string(), + "Fri".to_string(), + "Sat".to_string() + ]; + for day in days.iter() { + assert!(test(&day, "%a")); + } + + let months = [ + "January".to_string(), + "February".to_string(), + "March".to_string(), + "April".to_string(), + "May".to_string(), + "June".to_string(), + "July".to_string(), + "August".to_string(), + "September".to_string(), + "October".to_string(), + "November".to_string(), + "December".to_string() + ]; + for day in months.iter() { + assert!(test(&day, "%B")); + } + + let months = [ + "Jan".to_string(), + "Feb".to_string(), + "Mar".to_string(), + "Apr".to_string(), + "May".to_string(), + "Jun".to_string(), + "Jul".to_string(), + "Aug".to_string(), + "Sep".to_string(), + "Oct".to_string(), + "Nov".to_string(), + "Dec".to_string() + ]; + for day in months.iter() { + assert!(test(&day, "%b")); + } + + assert!(test("19", "%C")); + assert!(test("Fri Feb 3 23:31:30 2009", "%c")); + assert!(test("Fri Feb 13 23:31:30 2009", "%c")); + assert!(test("02/13/09", "%D")); + assert!(test("03", "%d")); + assert!(test("13", "%d")); + assert!(test(" 3", "%e")); + assert!(test("13", "%e")); + assert!(test("2009-02-13", "%F")); + assert!(test("03", "%H")); + assert!(test("13", "%H")); + assert!(test("03", "%I")); // FIXME (#2350): flesh out + assert!(test("11", "%I")); // FIXME (#2350): flesh out + assert!(test("044", "%j")); + assert!(test(" 3", "%k")); + assert!(test("13", "%k")); + assert!(test(" 1", "%l")); + assert!(test("11", "%l")); + assert!(test("03", "%M")); + assert!(test("13", "%M")); + assert!(test("\n", "%n")); + assert!(test("am", "%P")); + assert!(test("pm", "%P")); + assert!(test("AM", "%p")); + assert!(test("PM", "%p")); + assert!(test("23:31", "%R")); + assert!(test("11:31:30 AM", "%r")); + assert!(test("11:31:30 PM", "%r")); + assert!(test("03", "%S")); + assert!(test("13", "%S")); + assert!(test("15:31:30", "%T")); + assert!(test("\t", "%t")); + assert!(test("1", "%u")); + assert!(test("7", "%u")); + assert!(test("13-Feb-2009", "%v")); + assert!(test("0", "%w")); + assert!(test("6", "%w")); + assert!(test("2009", "%Y")); + assert!(test("09", "%y")); + + assert!(test_oneway("3", "%d")); + assert!(test_oneway("3", "%H")); + assert!(test_oneway("3", "%e")); + assert!(test_oneway("3", "%M")); + assert!(test_oneway("3", "%S")); + + assert!(strptime("-0000", "%z").unwrap().tm_utcoff == 0); + assert!(strptime("-00:00", "%z").unwrap().tm_utcoff == 0); + assert_eq!(-28800, strptime("-0800", "%z").unwrap().tm_utcoff); + assert_eq!(-28800, strptime("-08:00", "%z").unwrap().tm_utcoff); + assert_eq!(28800, strptime("+0800", "%z").unwrap().tm_utcoff); + assert_eq!(28800, strptime("+08:00", "%z").unwrap().tm_utcoff); + assert_eq!(5400, strptime("+0130", "%z").unwrap().tm_utcoff); + assert_eq!(5400, strptime("+01:30", "%z").unwrap().tm_utcoff); + assert!(test("%", "%%")); + + // Test for #7256 + assert_eq!(strptime("360", "%Y-%m-%d"), Err(InvalidYear)); + + // Test for epoch seconds parsing + { + assert!(test("1428035610", "%s")); + let tm = strptime("1428035610", "%s").unwrap(); + assert_eq!(tm.tm_utcoff, 0); + assert_eq!(tm.tm_isdst, 0); + assert_eq!(tm.tm_yday, 92); + assert_eq!(tm.tm_wday, 5); + assert_eq!(tm.tm_year, 115); + assert_eq!(tm.tm_mon, 3); + assert_eq!(tm.tm_mday, 3); + assert_eq!(tm.tm_hour, 4); + } + } + + fn test_asctime() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let utc = at_utc(time); + let local = at(time); + + debug!("test_ctime: {} {}", utc.asctime(), local.asctime()); + + assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009".to_string()); + assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); + } + + fn test_ctime() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let utc = at_utc(time); + let local = at(time); + + debug!("test_ctime: {} {}", utc.ctime(), local.ctime()); + + assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); + assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); + } + + fn test_strftime() { + set_time_zone(); + + let time = Timespec::new(1234567890, 54321); + let utc = at_utc(time); + let local = at(time); + + assert_eq!(local.strftime("").unwrap().to_string(), "".to_string()); + assert_eq!(local.strftime("%A").unwrap().to_string(), "Friday".to_string()); + assert_eq!(local.strftime("%a").unwrap().to_string(), "Fri".to_string()); + assert_eq!(local.strftime("%B").unwrap().to_string(), "February".to_string()); + assert_eq!(local.strftime("%b").unwrap().to_string(), "Feb".to_string()); + assert_eq!(local.strftime("%C").unwrap().to_string(), "20".to_string()); + assert_eq!(local.strftime("%c").unwrap().to_string(), + "Fri Feb 13 15:31:30 2009".to_string()); + assert_eq!(local.strftime("%D").unwrap().to_string(), "02/13/09".to_string()); + assert_eq!(local.strftime("%d").unwrap().to_string(), "13".to_string()); + assert_eq!(local.strftime("%e").unwrap().to_string(), "13".to_string()); + assert_eq!(local.strftime("%F").unwrap().to_string(), "2009-02-13".to_string()); + assert_eq!(local.strftime("%f").unwrap().to_string(), "000054321".to_string()); + assert_eq!(local.strftime("%G").unwrap().to_string(), "2009".to_string()); + assert_eq!(local.strftime("%g").unwrap().to_string(), "09".to_string()); + assert_eq!(local.strftime("%H").unwrap().to_string(), "15".to_string()); + assert_eq!(local.strftime("%h").unwrap().to_string(), "Feb".to_string()); + assert_eq!(local.strftime("%I").unwrap().to_string(), "03".to_string()); + assert_eq!(local.strftime("%j").unwrap().to_string(), "044".to_string()); + assert_eq!(local.strftime("%k").unwrap().to_string(), "15".to_string()); + assert_eq!(local.strftime("%l").unwrap().to_string(), " 3".to_string()); + assert_eq!(local.strftime("%M").unwrap().to_string(), "31".to_string()); + assert_eq!(local.strftime("%m").unwrap().to_string(), "02".to_string()); + assert_eq!(local.strftime("%n").unwrap().to_string(), "\n".to_string()); + assert_eq!(local.strftime("%P").unwrap().to_string(), "pm".to_string()); + assert_eq!(local.strftime("%p").unwrap().to_string(), "PM".to_string()); + assert_eq!(local.strftime("%R").unwrap().to_string(), "15:31".to_string()); + assert_eq!(local.strftime("%r").unwrap().to_string(), "03:31:30 PM".to_string()); + assert_eq!(local.strftime("%S").unwrap().to_string(), "30".to_string()); + assert_eq!(local.strftime("%s").unwrap().to_string(), "1234567890".to_string()); + assert_eq!(local.strftime("%T").unwrap().to_string(), "15:31:30".to_string()); + assert_eq!(local.strftime("%t").unwrap().to_string(), "\t".to_string()); + assert_eq!(local.strftime("%U").unwrap().to_string(), "06".to_string()); + assert_eq!(local.strftime("%u").unwrap().to_string(), "5".to_string()); + assert_eq!(local.strftime("%V").unwrap().to_string(), "07".to_string()); + assert_eq!(local.strftime("%v").unwrap().to_string(), "13-Feb-2009".to_string()); + assert_eq!(local.strftime("%W").unwrap().to_string(), "06".to_string()); + assert_eq!(local.strftime("%w").unwrap().to_string(), "5".to_string()); + // FIXME (#2350): support locale + assert_eq!(local.strftime("%X").unwrap().to_string(), "15:31:30".to_string()); + // FIXME (#2350): support locale + assert_eq!(local.strftime("%x").unwrap().to_string(), "02/13/09".to_string()); + assert_eq!(local.strftime("%Y").unwrap().to_string(), "2009".to_string()); + assert_eq!(local.strftime("%y").unwrap().to_string(), "09".to_string()); + // FIXME (#2350): support locale + assert_eq!(local.strftime("%Z").unwrap().to_string(), "".to_string()); + assert_eq!(local.strftime("%z").unwrap().to_string(), "-0800".to_string()); + assert_eq!(local.strftime("%+").unwrap().to_string(), + "2009-02-13T15:31:30-08:00".to_string()); + assert_eq!(local.strftime("%%").unwrap().to_string(), "%".to_string()); + + let invalid_specifiers = ["%E", "%J", "%K", "%L", "%N", "%O", "%o", "%Q", "%q"]; + for &sp in invalid_specifiers.iter() { + assert_eq!(local.strftime(sp).unwrap_err(), + InvalidFormatSpecifier(sp[1..].chars().next().unwrap())); + } + assert_eq!(local.strftime("%").unwrap_err(), MissingFormatConverter); + assert_eq!(local.strftime("%A %").unwrap_err(), MissingFormatConverter); + + assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); + assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); + assert_eq!(local.rfc822z().to_string(), "Fri, 13 Feb 2009 15:31:30 -0800".to_string()); + assert_eq!(local.rfc3339().to_string(), "2009-02-13T15:31:30-08:00".to_string()); + + assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009".to_string()); + assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); + assert_eq!(utc.rfc822().to_string(), "Fri, 13 Feb 2009 23:31:30 GMT".to_string()); + assert_eq!(utc.rfc822z().to_string(), "Fri, 13 Feb 2009 23:31:30 -0000".to_string()); + assert_eq!(utc.rfc3339().to_string(), "2009-02-13T23:31:30Z".to_string()); + } + + fn test_timespec_eq_ord() { + let a = &Timespec::new(-2, 1); + let b = &Timespec::new(-1, 2); + let c = &Timespec::new(1, 2); + let d = &Timespec::new(2, 1); + let e = &Timespec::new(2, 1); + + assert!(d.eq(e)); + assert!(c.ne(e)); + + assert!(a.lt(b)); + assert!(b.lt(c)); + assert!(c.lt(d)); + + assert!(a.le(b)); + assert!(b.le(c)); + assert!(c.le(d)); + assert!(d.le(e)); + assert!(e.le(d)); + + assert!(b.ge(a)); + assert!(c.ge(b)); + assert!(d.ge(c)); + assert!(e.ge(d)); + assert!(d.ge(e)); + + assert!(b.gt(a)); + assert!(c.gt(b)); + assert!(d.gt(c)); + } + + fn test_timespec_add() { + let a = Timespec::new(1, 2); + let b = Duration::seconds(2) + Duration::nanoseconds(3); + let c = a + b; + assert_eq!(c.sec, 3); + assert_eq!(c.nsec, 5); + + let p = Timespec::new(1, super::NSEC_PER_SEC - 2); + let q = Duration::seconds(2) + Duration::nanoseconds(2); + let r = p + q; + assert_eq!(r.sec, 4); + assert_eq!(r.nsec, 0); + + let u = Timespec::new(1, super::NSEC_PER_SEC - 2); + let v = Duration::seconds(2) + Duration::nanoseconds(3); + let w = u + v; + assert_eq!(w.sec, 4); + assert_eq!(w.nsec, 1); + + let k = Timespec::new(1, 0); + let l = Duration::nanoseconds(-1); + let m = k + l; + assert_eq!(m.sec, 0); + assert_eq!(m.nsec, 999_999_999); + } + + fn test_timespec_sub() { + let a = Timespec::new(2, 3); + let b = Timespec::new(1, 2); + let c = a - b; + assert_eq!(c.num_nanoseconds(), Some(super::NSEC_PER_SEC as i64 + 1)); + + let p = Timespec::new(2, 0); + let q = Timespec::new(1, 2); + let r = p - q; + assert_eq!(r.num_nanoseconds(), Some(super::NSEC_PER_SEC as i64 - 2)); + + let u = Timespec::new(1, 2); + let v = Timespec::new(2, 3); + let w = u - v; + assert_eq!(w.num_nanoseconds(), Some(-super::NSEC_PER_SEC as i64 - 1)); + } + + fn test_time_sub() { + let a = ::now(); + let b = at(a.to_timespec() + Duration::seconds(5)); + let c = b - a; + assert_eq!(c.num_nanoseconds(), Some(super::NSEC_PER_SEC as i64 * 5)); + } + + #[test] + #[cfg_attr(target_os = "android", ignore)] // FIXME #10958 + fn run_tests() { + // The tests race on tzset. So instead of having many independent + // tests, we will just call the functions now. + test_get_time(); + test_precise_time(); + test_precise_time_to(); + test_at_utc(); + test_at(); + test_to_timespec(); + test_conversions(); + test_strptime(); + test_asctime(); + test_ctime(); + test_strftime(); + test_timespec_eq_ord(); + test_timespec_add(); + test_timespec_sub(); + test_time_sub(); + } +} diff --git a/deps/time-0.1.26/src/parse.rs b/deps/time-0.1.26/src/parse.rs new file mode 100644 index 000000000..d7754adb2 --- /dev/null +++ b/deps/time-0.1.26/src/parse.rs @@ -0,0 +1,390 @@ +use super::{Timespec, Tm, at_utc, ParseError, NSEC_PER_SEC}; +use super::ParseError::*; + +/// Parses the time from the string according to the format string. +pub fn strptime(mut s: &str, format: &str) -> Result<Tm, ParseError> { + let mut tm = Tm { + tm_sec: 0, + tm_min: 0, + tm_hour: 0, + tm_mday: 0, + tm_mon: 0, + tm_year: 0, + tm_wday: 0, + tm_yday: 0, + tm_isdst: 0, + tm_utcoff: 0, + tm_nsec: 0, + }; + let mut chars = format.chars(); + + while let Some(ch) = chars.next() { + if ch == '%' { + if let Some(ch) = chars.next() { + try!(parse_type(&mut s, ch, &mut tm)); + } + } else { + try!(parse_char(&mut s, ch)); + } + } + + Ok(tm) +} + +fn parse_type(s: &mut &str, ch: char, tm: &mut Tm) -> Result<(), ParseError> { + match ch { + 'A' => match match_strs(s, &[("Sunday", 0), + ("Monday", 1), + ("Tuesday", 2), + ("Wednesday", 3), + ("Thursday", 4), + ("Friday", 5), + ("Saturday", 6)]) { + Some(v) => { tm.tm_wday = v; Ok(()) } + None => Err(ParseError::InvalidDay) + }, + 'a' => match match_strs(s, &[("Sun", 0), + ("Mon", 1), + ("Tue", 2), + ("Wed", 3), + ("Thu", 4), + ("Fri", 5), + ("Sat", 6)]) { + Some(v) => { tm.tm_wday = v; Ok(()) } + None => Err(ParseError::InvalidDay) + }, + 'B' => match match_strs(s, &[("January", 0), + ("February", 1), + ("March", 2), + ("April", 3), + ("May", 4), + ("June", 5), + ("July", 6), + ("August", 7), + ("September", 8), + ("October", 9), + ("November", 10), + ("December", 11)]) { + Some(v) => { tm.tm_mon = v; Ok(()) } + None => Err(ParseError::InvalidMonth) + }, + 'b' | 'h' => match match_strs(s, &[("Jan", 0), + ("Feb", 1), + ("Mar", 2), + ("Apr", 3), + ("May", 4), + ("Jun", 5), + ("Jul", 6), + ("Aug", 7), + ("Sep", 8), + ("Oct", 9), + ("Nov", 10), + ("Dec", 11)]) { + Some(v) => { tm.tm_mon = v; Ok(()) } + None => Err(ParseError::InvalidMonth) + }, + 'C' => match match_digits_in_range(s, 1, 2, false, 0, 99) { + Some(v) => { tm.tm_year += (v * 100) - 1900; Ok(()) } + None => Err(ParseError::InvalidYear) + }, + 'c' => { + parse_type(s, 'a', tm) + .and_then(|()| parse_char(s, ' ')) + .and_then(|()| parse_type(s, 'b', tm)) + .and_then(|()| parse_char(s, ' ')) + .and_then(|()| parse_type(s, 'e', tm)) + .and_then(|()| parse_char(s, ' ')) + .and_then(|()| parse_type(s, 'T', tm)) + .and_then(|()| parse_char(s, ' ')) + .and_then(|()| parse_type(s, 'Y', tm)) + } + 'D' | 'x' => { + parse_type(s, 'm', tm) + .and_then(|()| parse_char(s, '/')) + .and_then(|()| parse_type(s, 'd', tm)) + .and_then(|()| parse_char(s, '/')) + .and_then(|()| parse_type(s, 'y', tm)) + } + 'd' => match match_digits_in_range(s, 1, 2, false, 1, 31) { + Some(v) => { tm.tm_mday = v; Ok(()) } + None => Err(ParseError::InvalidDayOfMonth) + }, + 'e' => match match_digits_in_range(s, 1, 2, true, 1, 31) { + Some(v) => { tm.tm_mday = v; Ok(()) } + None => Err(ParseError::InvalidDayOfMonth) + }, + 'f' => { + tm.tm_nsec = match_fractional_seconds(s); + Ok(()) + } + 'F' => { + parse_type(s, 'Y', tm) + .and_then(|()| parse_char(s, '-')) + .and_then(|()| parse_type(s, 'm', tm)) + .and_then(|()| parse_char(s, '-')) + .and_then(|()| parse_type(s, 'd', tm)) + } + 'H' => { + match match_digits_in_range(s, 1, 2, false, 0, 23) { + Some(v) => { tm.tm_hour = v; Ok(()) } + None => Err(ParseError::InvalidHour) + } + } + 'I' => { + match match_digits_in_range(s, 1, 2, false, 1, 12) { + Some(v) => { tm.tm_hour = if v == 12 { 0 } else { v }; Ok(()) } + None => Err(ParseError::InvalidHour) + } + } + 'j' => { + match match_digits_in_range(s, 1, 3, false, 1, 366) { + Some(v) => { tm.tm_yday = v - 1; Ok(()) } + None => Err(ParseError::InvalidDayOfYear) + } + } + 'k' => { + match match_digits_in_range(s, 1, 2, true, 0, 23) { + Some(v) => { tm.tm_hour = v; Ok(()) } + None => Err(ParseError::InvalidHour) + } + } + 'l' => { + match match_digits_in_range(s, 1, 2, true, 1, 12) { + Some(v) => { tm.tm_hour = if v == 12 { 0 } else { v }; Ok(()) } + None => Err(ParseError::InvalidHour) + } + } + 'M' => { + match match_digits_in_range(s, 1, 2, false, 0, 59) { + Some(v) => { tm.tm_min = v; Ok(()) } + None => Err(ParseError::InvalidMinute) + } + } + 'm' => { + match match_digits_in_range(s, 1, 2, false, 1, 12) { + Some(v) => { tm.tm_mon = v - 1; Ok(()) } + None => Err(ParseError::InvalidMonth) + } + } + 'n' => parse_char(s, '\n'), + 'P' => match match_strs(s, &[("am", 0), ("pm", 12)]) { + Some(v) => { tm.tm_hour += v; Ok(()) } + None => Err(ParseError::InvalidHour) + }, + 'p' => match match_strs(s, &[("AM", 0), ("PM", 12)]) { + Some(v) => { tm.tm_hour += v; Ok(()) } + None => Err(ParseError::InvalidHour) + }, + 'R' => { + parse_type(s, 'H', tm) + .and_then(|()| parse_char(s, ':')) + .and_then(|()| parse_type(s, 'M', tm)) + } + 'r' => { + parse_type(s, 'I', tm) + .and_then(|()| parse_char(s, ':')) + .and_then(|()| parse_type(s, 'M', tm)) + .and_then(|()| parse_char(s, ':')) + .and_then(|()| parse_type(s, 'S', tm)) + .and_then(|()| parse_char(s, ' ')) + .and_then(|()| parse_type(s, 'p', tm)) + } + 's' => { + match match_digits_i64(s, 1, 18, false) { + Some(v) => { + *tm = at_utc(Timespec::new(v, 0)); + Ok(()) + }, + None => Err(ParseError::InvalidSecondsSinceEpoch) + } + } + 'S' => { + match match_digits_in_range(s, 1, 2, false, 0, 60) { + Some(v) => { tm.tm_sec = v; Ok(()) } + None => Err(ParseError::InvalidSecond) + } + } + //'s' {} + 'T' | 'X' => { + parse_type(s, 'H', tm) + .and_then(|()| parse_char(s, ':')) + .and_then(|()| parse_type(s, 'M', tm)) + .and_then(|()| parse_char(s, ':')) + .and_then(|()| parse_type(s, 'S', tm)) + } + 't' => parse_char(s, '\t'), + 'u' => { + match match_digits_in_range(s, 1, 1, false, 1, 7) { + Some(v) => { tm.tm_wday = if v == 7 { 0 } else { v }; Ok(()) } + None => Err(ParseError::InvalidDayOfWeek) + } + } + 'v' => { + parse_type(s, 'e', tm) + .and_then(|()| parse_char(s, '-')) + .and_then(|()| parse_type(s, 'b', tm)) + .and_then(|()| parse_char(s, '-')) + .and_then(|()| parse_type(s, 'Y', tm)) + } + //'W' {} + 'w' => { + match match_digits_in_range(s, 1, 1, false, 0, 6) { + Some(v) => { tm.tm_wday = v; Ok(()) } + None => Err(ParseError::InvalidDayOfWeek) + } + } + 'Y' => { + match match_digits(s, 4, 4, false) { + Some(v) => { tm.tm_year = v - 1900; Ok(()) } + None => Err(ParseError::InvalidYear) + } + } + 'y' => { + match match_digits_in_range(s, 1, 2, false, 0, 99) { + Some(v) => { tm.tm_year = v; Ok(()) } + None => Err(ParseError::InvalidYear) + } + } + 'Z' => { + if match_str(s, "UTC") || match_str(s, "GMT") { + tm.tm_utcoff = 0; + Ok(()) + } else { + // It's odd, but to maintain compatibility with c's + // strptime we ignore the timezone. + for (i, ch) in s.char_indices() { + if ch == ' ' { + *s = &s[i..]; + return Ok(()) + } + } + *s = ""; + Ok(()) + } + } + 'z' => { + let sign = if parse_char(s, '+').is_ok() {1} + else if parse_char(s, '-').is_ok() {-1} + else { return Err(ParseError::InvalidZoneOffset) }; + + let hours; + let minutes; + + match match_digits(s, 2, 2, false) { + Some(h) => hours = h, + None => return Err(ParseError::InvalidZoneOffset) + } + + // consume the colon if its present, + // just ignore it otherwise + let _ = parse_char(s, ':'); + + match match_digits(s, 2, 2, false) { + Some(m) => minutes = m, + None => return Err(ParseError::InvalidZoneOffset) + } + + tm.tm_utcoff = sign * (hours * 60 * 60 + minutes * 60); + Ok(()) + } + '%' => parse_char(s, '%'), + ch => Err(ParseError::InvalidFormatSpecifier(ch)) + } +} + + +fn match_str(s: &mut &str, needle: &str) -> bool { + if s.starts_with(needle) { + *s = &s[needle.len()..]; + true + } else { + false + } +} + +fn match_strs(ss: &mut &str, strs: &[(&str, i32)]) -> Option<i32> { + for &(needle, value) in strs.iter() { + if match_str(ss, needle) { + return Some(value) + } + } + None +} + +fn match_digits(ss: &mut &str, min_digits : usize, max_digits: usize, ws: bool) -> Option<i32> { + match match_digits_i64(ss, min_digits, max_digits, ws) { + Some(v) => Some(v as i32), + None => None + } +} + +fn match_digits_i64(ss: &mut &str, min_digits : usize, max_digits: usize, ws: bool) -> Option<i64> { + let mut value : i64 = 0; + let mut n = 0; + if ws { + let s2 = ss.trim_left_matches(" "); + n = ss.len() - s2.len(); + if n > max_digits { return None } + } + let chars = ss[n..].char_indices(); + for (_, ch) in chars.take(max_digits - n) { + match ch { + '0' ... '9' => value = value * 10 + (ch as i64 - '0' as i64), + _ => break, + } + n += 1; + } + + if n >= min_digits && n <= max_digits { + *ss = &ss[n..]; + Some(value) + } else { + None + } +} + +fn match_fractional_seconds(ss: &mut &str) -> i32 { + let mut value = 0; + let mut multiplier = NSEC_PER_SEC / 10; + + let mut chars = ss.char_indices(); + let orig = *ss; + for (i, ch) in &mut chars { + *ss = &orig[i..]; + match ch { + '0' ... '9' => { + // This will drop digits after the nanoseconds place + let digit = ch as i32 - '0' as i32; + value += digit * multiplier; + multiplier /= 10; + } + _ => break + } + } + + value +} + +fn match_digits_in_range(ss: &mut &str, + min_digits : usize, max_digits : usize, + ws: bool, min: i32, max: i32) -> Option<i32> { + let before = *ss; + match match_digits(ss, min_digits, max_digits, ws) { + Some(val) if val >= min && val <= max => Some(val), + _ => { *ss = before; None } + } +} + +fn parse_char(s: &mut &str, c: char) -> Result<(), ParseError> { + match s.char_indices().next() { + Some((i, c2)) => { + if c == c2 { + *s = &s[i + c2.len_utf8()..]; + Ok(()) + } else { + Err(ParseError::UnexpectedCharacter(c, c2)) + } + } + None => Err(ParseError::InvalidTime), + } +} diff --git a/deps/time-0.1.26/src/time_helpers.c b/deps/time-0.1.26/src/time_helpers.c new file mode 100644 index 000000000..c3baa7312 --- /dev/null +++ b/deps/time-0.1.26/src/time_helpers.c @@ -0,0 +1,183 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include <stdint.h> +#include <time.h> +#include <string.h> +#include <assert.h> +#include <stdlib.h> + +#if !defined(_WIN32) +#include <sys/time.h> +#include <sys/types.h> +#include <dirent.h> +#include <signal.h> +#include <unistd.h> +#include <pthread.h> +#else +#include <windows.h> +#include <wincrypt.h> +#include <stdio.h> +#endif + +#ifdef __APPLE__ +#include <TargetConditionals.h> +#include <mach/mach_time.h> + +#if !(TARGET_OS_IPHONE) +#include <crt_externs.h> +#endif +#endif + +// Gonk has this symbol, but Android doesn't +#ifndef TARGET_OS_GONK +#ifdef __ANDROID__ + +#include <android/api-level.h> +#if __ANDROID_API__ < 21 +static time_t timegm(struct tm *tm) { + time_t ret; + char *tz; + + tz = getenv("TZ"); + if (tz) + tz = strdup(tz); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if (tz) { + setenv("TZ", tz, 1); + free(tz); + } else + unsetenv("TZ"); + tzset(); + return ret; +} +#endif +#endif +#endif + +typedef struct { + int32_t tm_sec; + int32_t tm_min; + int32_t tm_hour; + int32_t tm_mday; + int32_t tm_mon; + int32_t tm_year; + int32_t tm_wday; + int32_t tm_yday; + int32_t tm_isdst; + int32_t tm_utcoff; + int32_t tm_nsec; +} rust_time_tm; + +static void rust_time_tm_to_tm(rust_time_tm* in_tm, struct tm* out_tm) { + memset(out_tm, 0, sizeof(struct tm)); + out_tm->tm_sec = in_tm->tm_sec; + out_tm->tm_min = in_tm->tm_min; + out_tm->tm_hour = in_tm->tm_hour; + out_tm->tm_mday = in_tm->tm_mday; + out_tm->tm_mon = in_tm->tm_mon; + out_tm->tm_year = in_tm->tm_year; + out_tm->tm_wday = in_tm->tm_wday; + out_tm->tm_yday = in_tm->tm_yday; + out_tm->tm_isdst = in_tm->tm_isdst; +} + +static void tm_to_rust_tm(struct tm* in_tm, + rust_time_tm* out_tm, + int32_t utcoff, + int32_t nsec) { + out_tm->tm_sec = in_tm->tm_sec; + out_tm->tm_min = in_tm->tm_min; + out_tm->tm_hour = in_tm->tm_hour; + out_tm->tm_mday = in_tm->tm_mday; + out_tm->tm_mon = in_tm->tm_mon; + out_tm->tm_year = in_tm->tm_year; + out_tm->tm_wday = in_tm->tm_wday; + out_tm->tm_yday = in_tm->tm_yday; + out_tm->tm_isdst = in_tm->tm_isdst; + out_tm->tm_utcoff = utcoff; + out_tm->tm_nsec = nsec; +} + +#if defined(_WIN32) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#define GMTIME(clock, result) gmtime_s((result), (clock)) +#define LOCALTIME(clock, result) localtime_s((result), (clock)) +#define TIMEGM(result) _mkgmtime64(result) +#else +static struct tm* GMTIME(const time_t *clock, struct tm *result) { + struct tm* t = gmtime(clock); + if (t == NULL || result == NULL) { return NULL; } + *result = *t; + return result; +} +static struct tm* LOCALTIME(const time_t *clock, struct tm *result) { + struct tm* t = localtime(clock); + if (t == NULL || result == NULL) { return NULL; } + *result = *t; + return result; +} +#define TIMEGM(result) mktime((result)) - _timezone +#endif +#else + +#ifdef __native_client__ +#define TIMEGM(result) mktime((result)) - _timezone +#else +#define TIMEGM(result) timegm(result) +#endif + +#define GMTIME(clock, result) gmtime_r((clock), (result)) +#define LOCALTIME(clock, result) localtime_r((clock), (result)) + +#endif + +void +rust_time_gmtime(int64_t sec, int32_t nsec, rust_time_tm *timeptr) { + struct tm tm; + time_t s = sec; + GMTIME(&s, &tm); + + tm_to_rust_tm(&tm, timeptr, 0, nsec); +} + +int32_t +rust_time_localtime(int64_t sec, int32_t nsec, rust_time_tm *timeptr) { + struct tm tm; + time_t s = sec; + if (LOCALTIME(&s, &tm) == NULL) { return 0; } + +#if defined(_WIN32) + int32_t utcoff = -timezone; +#elif defined(__native_client__) + int32_t utcoff = _timezone; +#else + int32_t utcoff = tm.tm_gmtoff; +#endif + + tm_to_rust_tm(&tm, timeptr, utcoff, nsec); + return 1; +} + +int64_t +rust_time_timegm(rust_time_tm* timeptr) { + struct tm t; + rust_time_tm_to_tm(timeptr, &t); + return TIMEGM(&t); +} + +int64_t +rust_time_mktime(rust_time_tm* timeptr) { + struct tm t; + rust_time_tm_to_tm(timeptr, &t); + return mktime(&t); +} diff --git a/deps/toml-0.1.21/.gitignore b/deps/toml-0.1.21/.gitignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/deps/toml-0.1.21/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/deps/toml-0.1.21/.travis.yml b/deps/toml-0.1.21/.travis.yml new file mode 100644 index 000000000..76e3afec3 --- /dev/null +++ b/deps/toml-0.1.21/.travis.yml @@ -0,0 +1,28 @@ +language: rust +rust: + - 1.0.0 + - beta + - nightly +sudo: false +script: + - cargo build --verbose + - cargo build --verbose --no-default-features + - cargo test --verbose + - cargo test --verbose --no-default-features + - rustdoc --test README.md -L target + - cargo doc --no-deps +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $TRAVIS_RUST_VERSION = nightly ] && + echo '<meta http-equiv=refresh content=0;url=toml/index.html>' > target/doc/index.html && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + - secure: FO8GVrtHAn5GTj4LOz2BApC3tAEsMbNzvH5UVmCIeNKPuVcKcI3oWNJC/KMCvuJZhu96J3okfRLBxBJrhxsp/YT4fS4kibhZDm6AzbCqxz6AmvHJo2d0jztoRyuLwLSkhwW8vM4VeHH+Tf4PeC56YmnpUGkccHMMidxytJzx8qI= + - secure: WVCzGVsthRub6ezJU15xzo+ahlUoZEwvZDeMPmjIMf1G28ObE9Y4BeUNW0j9CxCjyQ+5S0mrp1l0TESN326XTDosigabDiGnKyr5wfncnreN3PCUi3gx7NI+bRTy9B3eV318BhuCDgLgRWLWufCyPtkgAdT6cl+u6p+bEh+vyxo= +notifications: + email: + on_success: never diff --git a/deps/toml-0.1.21/Cargo.toml b/deps/toml-0.1.21/Cargo.toml new file mode 100644 index 000000000..c3ce3b723 --- /dev/null +++ b/deps/toml-0.1.21/Cargo.toml @@ -0,0 +1,25 @@ +[package] + +name = "toml" +version = "0.1.21" +authors = ["Alex Crichton <alex@alexcrichton.com>"] +license = "MIT/Apache-2.0" +readme = "README.md" +keywords = ["encoding"] +repository = "https://github.com/alexcrichton/toml-rs" +homepage = "https://github.com/alexcrichton/toml-rs" +documentation = "http://alexcrichton.com/toml-rs" +description = """ +A native Rust encoder and decoder of TOML-formatted files and streams. Provides +implementations of the standard Encodable/Decodable traits for TOML data to +facilitate deserializing and serializing Rust structures. +""" + +[dependencies] +rustc-serialize = { optional = true, version = "0.3.0" } + +[features] +default = ["rustc-serialize"] + +[dev-dependencies] +rustc-serialize = "0.3" diff --git a/deps/toml-0.1.21/LICENSE-APACHE b/deps/toml-0.1.21/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/toml-0.1.21/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/toml-0.1.21/LICENSE-MIT b/deps/toml-0.1.21/LICENSE-MIT new file mode 100644 index 000000000..39e0ed660 --- /dev/null +++ b/deps/toml-0.1.21/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/toml-0.1.21/README.md b/deps/toml-0.1.21/README.md new file mode 100644 index 000000000..09b715265 --- /dev/null +++ b/deps/toml-0.1.21/README.md @@ -0,0 +1,25 @@ +# toml-rs + +[![Build Status](https://travis-ci.org/alexcrichton/toml-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/toml-rs) + +[Documentation](http://alexcrichton.com/toml-rs) + +A [TOML][toml] decoder and encoder for Rust. This library is currently compliant with +the v0.4.0 version of TOML. This library will also likely continue to stay up to +date with the TOML specification as changes happen. + +[toml]: https://github.com/toml-lang/toml + +```toml +# Cargo.toml +[dependencies] +toml = "0.1" +``` + +# License + +`toml-rs` is primarily distributed under the terms of both the MIT license and +the Apache License (Version 2.0), with portions covered by various BSD-like +licenses. + +See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/deps/toml-0.1.21/examples/toml2json.rs b/deps/toml-0.1.21/examples/toml2json.rs new file mode 100644 index 000000000..0d406804a --- /dev/null +++ b/deps/toml-0.1.21/examples/toml2json.rs @@ -0,0 +1,57 @@ +#![deny(warnings)] + +extern crate toml; +extern crate rustc_serialize; + +use std::fs::File; +use std::env; +use std::io; +use std::io::prelude::*; + +use toml::Value; +use rustc_serialize::json::Json; + +fn main() { + let mut args = env::args(); + let mut input = String::new(); + let filename = if args.len() > 1 { + let name = args.nth(1).unwrap(); + File::open(&name).and_then(|mut f| { + f.read_to_string(&mut input) + }).unwrap(); + name + } else { + io::stdin().read_to_string(&mut input).unwrap(); + "<stdin>".to_string() + }; + + let mut parser = toml::Parser::new(&input); + let toml = match parser.parse() { + Some(toml) => toml, + None => { + for err in &parser.errors { + let (loline, locol) = parser.to_linecol(err.lo); + let (hiline, hicol) = parser.to_linecol(err.hi); + println!("{}:{}:{}-{}:{} error: {}", + filename, loline, locol, hiline, hicol, err.desc); + } + return + } + }; + let json = convert(Value::Table(toml)); + println!("{}", json.pretty()); +} + +fn convert(toml: Value) -> Json { + match toml { + Value::String(s) => Json::String(s), + Value::Integer(i) => Json::I64(i), + Value::Float(f) => Json::F64(f), + Value::Boolean(b) => Json::Boolean(b), + Value::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()), + Value::Table(table) => Json::Object(table.into_iter().map(|(k, v)| { + (k, convert(v)) + }).collect()), + Value::Datetime(dt) => Json::String(dt), + } +} diff --git a/deps/toml-0.1.21/src/decoder/mod.rs b/deps/toml-0.1.21/src/decoder/mod.rs new file mode 100644 index 000000000..675e0ca71 --- /dev/null +++ b/deps/toml-0.1.21/src/decoder/mod.rs @@ -0,0 +1,205 @@ +use std::error; +use std::fmt; + +use Value; +use self::DecodeErrorKind::*; + +#[cfg(feature = "rustc-serialize")] mod rustc_serialize; + +/// A structure to transform TOML values into Rust values. +/// +/// This decoder implements the serialization `Decoder` interface, allowing +/// `Decodable` types to be generated by this decoder. The input is any +/// arbitrary TOML value. +pub struct Decoder { + /// The TOML value left over after decoding. This can be used to inspect + /// whether fields were decoded or not. + pub toml: Option<Value>, + cur_field: Option<String>, +} + +/// Description for errors which can occur while decoding a type. +#[derive(PartialEq, Debug)] +pub struct DecodeError { + /// Field that this error applies to. + pub field: Option<String>, + /// The type of error which occurred while decoding, + pub kind: DecodeErrorKind, +} + +/// Enumeration of possible errors which can occur while decoding a structure. +#[derive(PartialEq, Debug)] +pub enum DecodeErrorKind { + /// An error flagged by the application, e.g. value out of range + ApplicationError(String), + /// A field was expected, but none was found. + ExpectedField(/* type */ Option<&'static str>), + /// A field was found, but it had the wrong type. + ExpectedType(/* expected */ &'static str, /* found */ &'static str), + /// The nth map key was expected, but none was found. + ExpectedMapKey(usize), + /// The nth map element was expected, but none was found. + ExpectedMapElement(usize), + /// An enum decoding was requested, but no variants were supplied + NoEnumVariants, + /// The unit type was being decoded, but a non-zero length string was found + NilTooLong, + /// There was an error with the syntactical structure of the TOML. + SyntaxError, + /// The end of the TOML input was reached too soon + EndOfStream, +} + +/// Decodes a TOML value into a decodable type. +/// +/// This function will consume the given TOML value and attempt to decode it +/// into the type specified. If decoding fails, `None` will be returned. If a +/// finer-grained error is desired, then it is recommended to use `Decodable` +/// directly. +#[cfg(feature = "rustc-serialize")] +pub fn decode<T: ::rustc_serialize::Decodable>(toml: Value) -> Option<T> { + ::rustc_serialize::Decodable::decode(&mut Decoder::new(toml)).ok() +} + +/// Decodes a TOML value into a decodable type. +/// +/// This function will consume the given TOML value and attempt to decode it +/// into the type specified. If decoding fails, `None` will be returned. If a +/// finer-grained error is desired, then it is recommended to use `Decodable` +/// directly. +#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] +pub fn decode<T: ::serde::Deserialize>(toml: Value) -> Option<T> { + ::serde::Deserialize::deserialize(&mut Decoder::new(toml)).ok() +} + +/// Decodes a string into a toml-encoded value. +/// +/// This function will parse the given string into a TOML value, and then parse +/// the TOML value into the desired type. If any error occurs `None` is return. +/// +/// If more fine-grained errors are desired, these steps should be driven +/// manually. +#[cfg(feature = "rustc-serialize")] +pub fn decode_str<T: ::rustc_serialize::Decodable>(s: &str) -> Option<T> { + ::Parser::new(s).parse().and_then(|t| decode(Value::Table(t))) +} + +/// Decodes a string into a toml-encoded value. +/// +/// This function will parse the given string into a TOML value, and then parse +/// the TOML value into the desired type. If any error occurs `None` is return. +/// +/// If more fine-grained errors are desired, these steps should be driven +/// manually. +#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] +pub fn decode_str<T: ::serde::Deserialize>(s: &str) -> Option<T> { + ::Parser::new(s).parse().and_then(|t| decode(Value::Table(t))) +} + +impl Decoder { + /// Creates a new decoder, consuming the TOML value to decode. + /// + /// This decoder can be passed to the `Decodable` methods or driven + /// manually. + pub fn new(toml: Value) -> Decoder { + Decoder { toml: Some(toml), cur_field: None } + } + + fn sub_decoder(&self, toml: Option<Value>, field: &str) -> Decoder { + Decoder { + toml: toml, + cur_field: if field.len() == 0 { + self.cur_field.clone() + } else { + match self.cur_field { + None => Some(format!("{}", field)), + Some(ref s) => Some(format!("{}.{}", s, field)) + } + } + } + } + + fn err(&self, kind: DecodeErrorKind) -> DecodeError { + DecodeError { + field: self.cur_field.clone(), + kind: kind, + } + } + + fn mismatch(&self, expected: &'static str, + found: &Option<Value>) -> DecodeError{ + match *found { + Some(ref val) => self.err(ExpectedType(expected, val.type_str())), + None => self.err(ExpectedField(Some(expected))), + } + } +} + +impl fmt::Display for DecodeError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(match self.kind { + ApplicationError(ref err) => { + write!(f, "{}", err) + } + ExpectedField(expected_type) => { + match expected_type { + Some("table") => write!(f, "expected a section"), + Some(e) => write!(f, "expected a value of type `{}`", e), + None => write!(f, "expected a value"), + } + } + ExpectedType(expected, found) => { + fn humanize(s: &str) -> String { + if s == "section" { + format!("a section") + } else { + format!("a value of type `{}`", s) + } + } + write!(f, "expected {}, but found {}", + humanize(expected), + humanize(found)) + } + ExpectedMapKey(idx) => { + write!(f, "expected at least {} keys", idx + 1) + } + ExpectedMapElement(idx) => { + write!(f, "expected at least {} elements", idx + 1) + } + NoEnumVariants => { + write!(f, "expected an enum variant to decode to") + } + NilTooLong => { + write!(f, "expected 0-length string") + } + SyntaxError => { + write!(f, "syntax error") + } + EndOfStream => { + write!(f, "end of stream") + } + }); + match self.field { + Some(ref s) => { + write!(f, " for the key `{}`", s) + } + None => Ok(()) + } + } +} + +impl error::Error for DecodeError { + fn description(&self) -> &str { + match self.kind { + ApplicationError(ref s) => &**s, + ExpectedField(..) => "expected a field", + ExpectedType(..) => "expected a type", + ExpectedMapKey(..) => "expected a map key", + ExpectedMapElement(..) => "expected a map element", + NoEnumVariants => "no enum variants to decode to", + NilTooLong => "nonzero length string representing nil", + SyntaxError => "syntax error", + EndOfStream => "end of stream", + } + } +} diff --git a/deps/toml-0.1.21/src/decoder/rustc_serialize.rs b/deps/toml-0.1.21/src/decoder/rustc_serialize.rs new file mode 100644 index 000000000..534154d18 --- /dev/null +++ b/deps/toml-0.1.21/src/decoder/rustc_serialize.rs @@ -0,0 +1,368 @@ +use rustc_serialize; +use std::mem; + +use super::{Decoder, DecodeError}; +use super::DecodeErrorKind::*; +use Value; + +impl rustc_serialize::Decoder for Decoder { + type Error = DecodeError; + fn read_nil(&mut self) -> Result<(), DecodeError> { + match self.toml { + Some(Value::String(ref s)) if s.len() == 0 => {} + Some(Value::String(..)) => return Err(self.err(NilTooLong)), + ref found => return Err(self.mismatch("string", found)), + } + self.toml.take(); + Ok(()) + } + fn read_usize(&mut self) -> Result<usize, DecodeError> { + self.read_i64().map(|i| i as usize) + } + fn read_u64(&mut self) -> Result<u64, DecodeError> { + self.read_i64().map(|i| i as u64) + } + fn read_u32(&mut self) -> Result<u32, DecodeError> { + self.read_i64().map(|i| i as u32) + } + fn read_u16(&mut self) -> Result<u16, DecodeError> { + self.read_i64().map(|i| i as u16) + } + fn read_u8(&mut self) -> Result<u8, DecodeError> { + self.read_i64().map(|i| i as u8) + } + fn read_isize(&mut self) -> Result<isize, DecodeError> { + self.read_i64().map(|i| i as isize) + } + fn read_i64(&mut self) -> Result<i64, DecodeError> { + match self.toml { + Some(Value::Integer(i)) => { self.toml.take(); Ok(i) } + ref found => Err(self.mismatch("integer", found)), + } + } + fn read_i32(&mut self) -> Result<i32, DecodeError> { + self.read_i64().map(|i| i as i32) + } + fn read_i16(&mut self) -> Result<i16, DecodeError> { + self.read_i64().map(|i| i as i16) + } + fn read_i8(&mut self) -> Result<i8, DecodeError> { + self.read_i64().map(|i| i as i8) + } + fn read_bool(&mut self) -> Result<bool, DecodeError> { + match self.toml { + Some(Value::Boolean(b)) => { self.toml.take(); Ok(b) } + ref found => Err(self.mismatch("bool", found)), + } + } + fn read_f64(&mut self) -> Result<f64, DecodeError> { + match self.toml { + Some(Value::Float(f)) => Ok(f), + ref found => Err(self.mismatch("float", found)), + } + } + fn read_f32(&mut self) -> Result<f32, DecodeError> { + self.read_f64().map(|f| f as f32) + } + fn read_char(&mut self) -> Result<char, DecodeError> { + let ch = match self.toml { + Some(Value::String(ref s)) if s.chars().count() == 1 => + s.chars().next().unwrap(), + ref found => return Err(self.mismatch("string", found)), + }; + self.toml.take(); + Ok(ch) + } + fn read_str(&mut self) -> Result<String, DecodeError> { + match self.toml.take() { + Some(Value::String(s)) => Ok(s), + found => { + let err = Err(self.mismatch("string", &found)); + self.toml = found; + err + } + } + } + + // Compound types: + fn read_enum<T, F>(&mut self, _name: &str, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + f(self) + } + + fn read_enum_variant<T, F>(&mut self, names: &[&str], mut f: F) + -> Result<T, DecodeError> + where F: FnMut(&mut Decoder, usize) -> Result<T, DecodeError> + { + // When decoding enums, this crate takes the strategy of trying to + // decode the current TOML as all of the possible variants, returning + // success on the first one that succeeds. + // + // Note that fidelity of the errors returned here is a little nebulous, + // but we try to return the error that had the relevant field as the + // longest field. This way we hopefully match an error against what was + // most likely being written down without losing too much info. + let mut first_error = None::<DecodeError>; + for i in 0..names.len() { + let mut d = self.sub_decoder(self.toml.clone(), ""); + match f(&mut d, i) { + Ok(t) => { + self.toml = d.toml; + return Ok(t) + } + Err(e) => { + if let Some(ref first) = first_error { + let my_len = e.field.as_ref().map(|s| s.len()); + let first_len = first.field.as_ref().map(|s| s.len()); + if my_len <= first_len { + continue + } + } + first_error = Some(e); + } + } + } + Err(first_error.unwrap_or_else(|| self.err(NoEnumVariants))) + } + fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + f(self) + } + + fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) + -> Result<T, DecodeError> + where F: FnMut(&mut Decoder, usize) -> Result<T, DecodeError> + { + panic!() + } + fn read_enum_struct_variant_field<T, F>(&mut self, + _f_name: &str, + _f_idx: usize, + _f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + panic!() + } + + fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + match self.toml { + Some(Value::Table(..)) => { + let ret = try!(f(self)); + match self.toml { + Some(Value::Table(ref t)) if t.len() == 0 => {} + _ => return Ok(ret) + } + self.toml.take(); + Ok(ret) + } + ref found => Err(self.mismatch("table", found)), + } + } + fn read_struct_field<T, F>(&mut self, f_name: &str, _f_idx: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + let field = format!("{}", f_name); + let toml = match self.toml { + Some(Value::Table(ref mut table)) => { + table.remove(&field) + .or_else(|| table.remove(&f_name.replace("_", "-"))) + }, + ref found => return Err(self.mismatch("table", found)), + }; + let mut d = self.sub_decoder(toml, f_name); + let ret = try!(f(&mut d)); + if let Some(value) = d.toml { + if let Some(Value::Table(ref mut table)) = self.toml { + table.insert(field, value); + } + } + Ok(ret) + } + + fn read_tuple<T, F>(&mut self, tuple_len: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + self.read_seq(move |d, len| { + assert!(len == tuple_len, + "expected tuple of length `{}`, found tuple \ + of length `{}`", tuple_len, len); + f(d) + }) + } + fn read_tuple_arg<T, F>(&mut self, a_idx: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + self.read_seq_elt(a_idx, f) + } + + fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + panic!() + } + fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + panic!() + } + + // Specialized types: + fn read_option<T, F>(&mut self, mut f: F) + -> Result<T, DecodeError> + where F: FnMut(&mut Decoder, bool) -> Result<T, DecodeError> + { + match self.toml { + Some(..) => f(self, true), + None => f(self, false), + } + } + + fn read_seq<T, F>(&mut self, f: F) -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder, usize) -> Result<T, DecodeError> + { + let len = match self.toml { + Some(Value::Array(ref arr)) => arr.len(), + None => 0, + ref found => return Err(self.mismatch("array", found)), + }; + let ret = try!(f(self, len)); + match self.toml { + Some(Value::Array(ref mut arr)) => { + arr.retain(|slot| slot.as_integer() != Some(0)); + if arr.len() != 0 { return Ok(ret) } + } + _ => return Ok(ret) + } + self.toml.take(); + Ok(ret) + } + fn read_seq_elt<T, F>(&mut self, idx: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + let toml = match self.toml { + Some(Value::Array(ref mut arr)) => { + mem::replace(&mut arr[idx], Value::Integer(0)) + } + ref found => return Err(self.mismatch("array", found)), + }; + let mut d = self.sub_decoder(Some(toml), ""); + let ret = try!(f(&mut d)); + match d.toml { + Some(toml) => match self.toml { + Some(Value::Array(ref mut arr)) => arr[idx] = toml, + _ => {} + }, + _ => {} + } + Ok(ret) + } + + fn read_map<T, F>(&mut self, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder, usize) -> Result<T, DecodeError> + { + let len = match self.toml { + Some(Value::Table(ref table)) => table.len(), + ref found => return Err(self.mismatch("table", found)), + }; + let ret = try!(f(self, len)); + self.toml.take(); + Ok(ret) + } + fn read_map_elt_key<T, F>(&mut self, idx: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + match self.toml { + Some(Value::Table(ref table)) => { + match table.iter().skip(idx).next() { + Some((key, _)) => { + let val = Value::String(key.to_string()); + f(&mut self.sub_decoder(Some(val), key)) + } + None => Err(self.err(ExpectedMapKey(idx))), + } + } + ref found => Err(self.mismatch("table", found)), + } + } + fn read_map_elt_val<T, F>(&mut self, idx: usize, f: F) + -> Result<T, DecodeError> + where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> + { + match self.toml { + Some(Value::Table(ref table)) => { + match table.iter().skip(idx).next() { + Some((key, value)) => { + // XXX: this shouldn't clone + f(&mut self.sub_decoder(Some(value.clone()), key)) + } + None => Err(self.err(ExpectedMapElement(idx))), + } + } + ref found => Err(self.mismatch("table", found)), + } + } + + fn error(&mut self, err: &str) -> DecodeError { + DecodeError { + field: self.cur_field.clone(), + kind: ApplicationError(format!("{}", err)) + } + } +} + +#[cfg(test)] +mod tests { + use rustc_serialize::Decodable; + use std::collections::HashMap; + + use {Parser, Decoder, Value}; + + #[test] + fn bad_enum_chooses_longest_error() { + #[derive(RustcDecodable)] + #[allow(dead_code)] + struct Foo { + wut: HashMap<String, Bar>, + } + + #[derive(RustcDecodable)] + enum Bar { + Simple(String), + Detailed(Baz), + } + + #[derive(RustcDecodable, Debug)] + struct Baz { + features: Vec<String>, + } + + let s = r#" + [wut] + a = { features = "" } + "#; + let v = Parser::new(s).parse().unwrap(); + let mut d = Decoder::new(Value::Table(v)); + let err = match Foo::decode(&mut d) { + Ok(_) => panic!("expected error"), + Err(e) => e, + }; + assert_eq!(err.field.as_ref().unwrap(), "wut.a.features"); + + } +} diff --git a/deps/toml-0.1.21/src/display.rs b/deps/toml-0.1.21/src/display.rs new file mode 100644 index 000000000..0c561e857 --- /dev/null +++ b/deps/toml-0.1.21/src/display.rs @@ -0,0 +1,202 @@ +use std::fmt; + +use Table as TomlTable; +use Value::{self, String, Integer, Float, Boolean, Datetime, Array, Table}; + +struct Printer<'a, 'b:'a> { + output: &'a mut fmt::Formatter<'b>, + stack: Vec<&'a str>, +} + +struct Key<'a>(&'a [&'a str]); + +impl fmt::Display for Value { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + String(ref s) => write_str(f, s), + Integer(i) => write!(f, "{}", i), + Float(fp) => { + try!(write!(f, "{}", fp)); + if fp % 1.0 == 0.0 { try!(write!(f, ".0")) } + Ok(()) + } + Boolean(b) => write!(f, "{}", b), + Datetime(ref s) => write!(f, "{}", s), + Table(ref t) => { + let mut p = Printer { output: f, stack: Vec::new() }; + p.print(t) + } + Array(ref a) => { + try!(write!(f, "[")); + for (i, v) in a.iter().enumerate() { + if i != 0 { try!(write!(f, ", ")); } + try!(write!(f, "{}", v)); + } + write!(f, "]") + } + } + } +} + +fn write_str(f: &mut fmt::Formatter, s: &str) -> fmt::Result { + try!(write!(f, "\"")); + for ch in s.chars() { + match ch { + '\u{8}' => try!(write!(f, "\\b")), + '\u{9}' => try!(write!(f, "\\t")), + '\u{a}' => try!(write!(f, "\\n")), + '\u{c}' => try!(write!(f, "\\f")), + '\u{d}' => try!(write!(f, "\\r")), + '\u{22}' => try!(write!(f, "\\\"")), + '\u{5c}' => try!(write!(f, "\\\\")), + ch => try!(write!(f, "{}", ch)), + } + } + write!(f, "\"") +} + +impl<'a, 'b> Printer<'a, 'b> { + fn print(&mut self, table: &'a TomlTable) -> fmt::Result { + for (k, v) in table.iter() { + match *v { + Table(..) => continue, + Array(ref a) => { + match a.first() { + Some(&Table(..)) => continue, + _ => {} + } + } + _ => {} + } + try!(writeln!(self.output, "{} = {}", Key(&[k]), v)); + } + for (k, v) in table.iter() { + match *v { + Table(ref inner) => { + self.stack.push(k); + try!(writeln!(self.output, "\n[{}]", Key(&self.stack))); + try!(self.print(inner)); + self.stack.pop(); + } + Array(ref inner) => { + match inner.first() { + Some(&Table(..)) => {} + _ => continue + } + self.stack.push(k); + for inner in inner.iter() { + try!(writeln!(self.output, "\n[[{}]]", Key(&self.stack))); + match *inner { + Table(ref inner) => try!(self.print(inner)), + _ => panic!("non-heterogeneous toml array"), + } + } + self.stack.pop(); + } + _ => {}, + } + } + Ok(()) + } +} + +impl<'a> fmt::Display for Key<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for (i, part) in self.0.iter().enumerate() { + if i != 0 { try!(write!(f, ".")); } + let ok = part.chars().all(|c| { + match c { + 'a' ... 'z' | + 'A' ... 'Z' | + '0' ... '9' | + '-' | '_' => true, + _ => false, + } + }); + if ok { + try!(write!(f, "{}", part)); + } else { + try!(write_str(f, part)); + } + } + Ok(()) + } +} + +#[cfg(test)] +#[allow(warnings)] +mod tests { + use Value; + use Value::{String, Integer, Float, Boolean, Datetime, Array, Table}; + use std::collections::BTreeMap; + + macro_rules! map( ($($k:expr => $v:expr),*) => ({ + let mut _m = BTreeMap::new(); + $(_m.insert($k.to_string(), $v);)* + _m + }) ); + + #[test] + fn simple_show() { + assert_eq!(String("foo".to_string()).to_string(), + "\"foo\""); + assert_eq!(Integer(10).to_string(), + "10"); + assert_eq!(Float(10.0).to_string(), + "10.0"); + assert_eq!(Float(2.4).to_string(), + "2.4"); + assert_eq!(Boolean(true).to_string(), + "true"); + assert_eq!(Datetime("test".to_string()).to_string(), + "test"); + assert_eq!(Array(vec![]).to_string(), + "[]"); + assert_eq!(Array(vec![Integer(1), Integer(2)]).to_string(), + "[1, 2]"); + } + + #[test] + fn table() { + assert_eq!(Table(map! { }).to_string(), + ""); + assert_eq!(Table(map! { "test" => Integer(2) }).to_string(), + "test = 2\n"); + assert_eq!(Table(map! { + "test" => Integer(2), + "test2" => Table(map! { + "test" => String("wut".to_string()) + }) + }).to_string(), + "test = 2\n\ + \n\ + [test2]\n\ + test = \"wut\"\n"); + assert_eq!(Table(map! { + "test" => Integer(2), + "test2" => Table(map! { + "test" => String("wut".to_string()) + }) + }).to_string(), + "test = 2\n\ + \n\ + [test2]\n\ + test = \"wut\"\n"); + assert_eq!(Table(map! { + "test" => Integer(2), + "test2" => Array(vec![Table(map! { + "test" => String("wut".to_string()) + })]) + }).to_string(), + "test = 2\n\ + \n\ + [[test2]]\n\ + test = \"wut\"\n"); + assert_eq!(Table(map! { + "foo.bar" => Integer(2), + "foo\"bar" => Integer(2) + }).to_string(), + "\"foo\\\"bar\" = 2\n\ + \"foo.bar\" = 2\n"); + } +} diff --git a/deps/toml-0.1.21/src/encoder/mod.rs b/deps/toml-0.1.21/src/encoder/mod.rs new file mode 100644 index 000000000..21185f433 --- /dev/null +++ b/deps/toml-0.1.21/src/encoder/mod.rs @@ -0,0 +1,210 @@ +use std::collections::BTreeMap; +use std::error; +use std::fmt; +use std::mem; + +use {Value, Table}; + +#[cfg(feature = "rustc-serialize")] mod rustc_serialize; + +/// A structure to transform Rust values into TOML values. +/// +/// This encoder implements the serialization `Encoder` interface, allowing +/// `Encodable` rust types to be fed into the encoder. The output of this +/// encoder is a TOML `Table` structure. The resulting TOML can be stringified +/// if necessary. +/// +/// # Example +/// +/// ``` +/// extern crate rustc_serialize; +/// extern crate toml; +/// +/// # fn main() { +/// use toml::{Encoder, Value}; +/// use rustc_serialize::Encodable; +/// +/// #[derive(RustcEncodable)] +/// struct MyStruct { foo: isize, bar: String } +/// let my_struct = MyStruct { foo: 4, bar: "hello!".to_string() }; +/// +/// let mut e = Encoder::new(); +/// my_struct.encode(&mut e).unwrap(); +/// +/// assert_eq!(e.toml.get(&"foo".to_string()), Some(&Value::Integer(4))) +/// # } +/// ``` +pub struct Encoder { + /// Output TOML that is emitted. The current version of this encoder forces + /// the top-level representation of a structure to be a table. + /// + /// This field can be used to extract the return value after feeding a value + /// into this `Encoder`. + pub toml: Table, + state: State, +} + +/// Enumeration of errors which can occur while encoding a rust value into a +/// TOML value. +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub enum Error { + /// Indication that a key was needed when a value was emitted, but no key + /// was previously emitted. + NeedsKey, + /// Indication that a key was emitted, but not value was emitted. + NoValue, + /// Indicates that a map key was attempted to be emitted at an invalid + /// location. + InvalidMapKeyLocation, + /// Indicates that a type other than a string was attempted to be used as a + /// map key type. + InvalidMapKeyType, +} + +#[derive(PartialEq)] +enum State { + Start, + NextKey(String), + NextArray(Vec<Value>), + NextMapKey, +} + +impl Encoder { + /// Constructs a new encoder which will emit to the given output stream. + pub fn new() -> Encoder { + Encoder { state: State::Start, toml: BTreeMap::new() } + } + + fn emit_value(&mut self, v: Value) -> Result<(), Error> { + match mem::replace(&mut self.state, State::Start) { + State::NextKey(key) => { self.toml.insert(key, v); Ok(()) } + State::NextArray(mut vec) => { + // TODO: validate types + vec.push(v); + self.state = State::NextArray(vec); + Ok(()) + } + State::NextMapKey => { + match v { + Value::String(s) => { self.state = State::NextKey(s); Ok(()) } + _ => Err(Error::InvalidMapKeyType) + } + } + _ => Err(Error::NeedsKey) + } + } + + fn emit_none(&mut self) -> Result<(), Error> { + match mem::replace(&mut self.state, State::Start) { + State::Start => unreachable!(), + State::NextKey(_) => Ok(()), + State::NextArray(..) => panic!("how to encode None in an array?"), + State::NextMapKey => Err(Error::InvalidMapKeyLocation), + } + } + + fn seq<F>(&mut self, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + let old = mem::replace(&mut self.state, State::NextArray(Vec::new())); + try!(f(self)); + match mem::replace(&mut self.state, old) { + State::NextArray(v) => self.emit_value(Value::Array(v)), + _ => unreachable!(), + } + } + + fn table<F>(&mut self, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + match mem::replace(&mut self.state, State::Start) { + State::NextKey(key) => { + let mut nested = Encoder::new(); + try!(f(&mut nested)); + self.toml.insert(key, Value::Table(nested.toml)); + Ok(()) + } + State::NextArray(mut arr) => { + let mut nested = Encoder::new(); + try!(f(&mut nested)); + arr.push(Value::Table(nested.toml)); + self.state = State::NextArray(arr); + Ok(()) + } + State::Start => f(self), + State::NextMapKey => Err(Error::InvalidMapKeyLocation), + } + } + + fn table_key<F>(&mut self, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + match mem::replace(&mut self.state, State::NextMapKey) { + State::Start => {} + _ => return Err(Error::InvalidMapKeyLocation), + } + try!(f(self)); + match self.state { + State::NextKey(_) => Ok(()), + _ => Err(Error::InvalidMapKeyLocation), + } + } +} + +/// Encodes an encodable value into a TOML value. +/// +/// This function expects the type given to represent a TOML table in some form. +/// If encoding encounters an error, then this function will fail the task. +#[cfg(feature = "rustc-serialize")] +pub fn encode<T: ::rustc_serialize::Encodable>(t: &T) -> Value { + let mut e = Encoder::new(); + t.encode(&mut e).unwrap(); + Value::Table(e.toml) +} + +/// Encodes an encodable value into a TOML value. +/// +/// This function expects the type given to represent a TOML table in some form. +/// If encoding encounters an error, then this function will fail the task. +#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] +pub fn encode<T: ::serde::Serialize>(t: &T) -> Value { + let mut e = Encoder::new(); + t.deserialize(&mut e).unwrap(); + Value::Table(e.toml) +} + +/// Encodes an encodable value into a TOML string. +/// +/// This function expects the type given to represent a TOML table in some form. +/// If encoding encounters an error, then this function will fail the task. +#[cfg(feature = "rustc-serialize")] +pub fn encode_str<T: ::rustc_serialize::Encodable>(t: &T) -> String { + encode(t).to_string() +} + +/// Encodes an encodable value into a TOML string. +/// +/// This function expects the type given to represent a TOML table in some form. +/// If encoding encounters an error, then this function will fail the task. +#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] +pub fn encode_str<T: ::serde::Serialize>(t: &T) -> String { + encode(t).to_string() +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::NeedsKey => write!(f, "need a key to encode"), + Error::NoValue => write!(f, "not value to emit for a previous key"), + Error::InvalidMapKeyLocation => write!(f, "a map cannot be emitted \ + at this location"), + Error::InvalidMapKeyType => write!(f, "only strings can be used as \ + key types"), + } + } +} + +impl error::Error for Error { + fn description(&self) -> &str { "TOML encoding error" } +} diff --git a/deps/toml-0.1.21/src/encoder/rustc_serialize.rs b/deps/toml-0.1.21/src/encoder/rustc_serialize.rs new file mode 100644 index 000000000..ab5e90f30 --- /dev/null +++ b/deps/toml-0.1.21/src/encoder/rustc_serialize.rs @@ -0,0 +1,689 @@ +use std::mem; + +use rustc_serialize; +use Value; +use super::{Encoder, Error, State}; +use super::Error::*; + +impl rustc_serialize::Encoder for Encoder { + type Error = Error; + + fn emit_nil(&mut self) -> Result<(), Error> { Ok(()) } + fn emit_usize(&mut self, v: usize) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_u8(&mut self, v: u8) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_u16(&mut self, v: u16) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_u32(&mut self, v: u32) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_u64(&mut self, v: u64) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_isize(&mut self, v: isize) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_i8(&mut self, v: i8) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_i16(&mut self, v: i16) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_i32(&mut self, v: i32) -> Result<(), Error> { + self.emit_i64(v as i64) + } + fn emit_i64(&mut self, v: i64) -> Result<(), Error> { + self.emit_value(Value::Integer(v)) + } + fn emit_bool(&mut self, v: bool) -> Result<(), Error> { + self.emit_value(Value::Boolean(v)) + } + fn emit_f32(&mut self, v: f32) -> Result<(), Error> { self.emit_f64(v as f64) } + fn emit_f64(&mut self, v: f64) -> Result<(), Error> { + self.emit_value(Value::Float(v)) + } + fn emit_char(&mut self, v: char) -> Result<(), Error> { + self.emit_str(&*format!("{}", v)) + } + fn emit_str(&mut self, v: &str) -> Result<(), Error> { + self.emit_value(Value::String(format!("{}", v))) + } + fn emit_enum<F>(&mut self, _name: &str, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } + fn emit_enum_variant<F>(&mut self, _v_name: &str, _v_id: usize, + _len: usize, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } + fn emit_enum_variant_arg<F>(&mut self, _a_idx: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } + fn emit_enum_struct_variant<F>(&mut self, _v_name: &str, _v_id: usize, + _len: usize, + _f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + panic!() + } + fn emit_enum_struct_variant_field<F>(&mut self, + _f_name: &str, + _f_idx: usize, + _f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + panic!() + } + fn emit_struct<F>(&mut self, _name: &str, _len: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + self.table(f) + } + fn emit_struct_field<F>(&mut self, f_name: &str, _f_idx: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + let old = mem::replace(&mut self.state, + State::NextKey(format!("{}", f_name))); + try!(f(self)); + if self.state != State::Start { + return Err(NoValue) + } + self.state = old; + Ok(()) + } + fn emit_tuple<F>(&mut self, len: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + self.emit_seq(len, f) + } + fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + self.emit_seq_elt(idx, f) + } + fn emit_tuple_struct<F>(&mut self, _name: &str, _len: usize, _f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + unimplemented!() + } + fn emit_tuple_struct_arg<F>(&mut self, _f_idx: usize, _f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + unimplemented!() + } + fn emit_option<F>(&mut self, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } + fn emit_option_none(&mut self) -> Result<(), Error> { + self.emit_none() + } + fn emit_option_some<F>(&mut self, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } + fn emit_seq<F>(&mut self, _len: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + self.seq(f) + } + fn emit_seq_elt<F>(&mut self, _idx: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } + fn emit_map<F>(&mut self, len: usize, f: F) + -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + self.emit_struct("foo", len, f) + } + fn emit_map_elt_key<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + self.table_key(f) + } + fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> + where F: FnOnce(&mut Encoder) -> Result<(), Error> + { + f(self) + } +} + +impl rustc_serialize::Encodable for Value { + fn encode<E>(&self, e: &mut E) -> Result<(), E::Error> + where E: rustc_serialize::Encoder + { + match *self { + Value::String(ref s) => e.emit_str(s), + Value::Integer(i) => e.emit_i64(i), + Value::Float(f) => e.emit_f64(f), + Value::Boolean(b) => e.emit_bool(b), + Value::Datetime(ref s) => e.emit_str(s), + Value::Array(ref a) => { + e.emit_seq(a.len(), |e| { + for item in a { + try!(item.encode(e)); + } + Ok(()) + }) + } + Value::Table(ref t) => { + e.emit_map(t.len(), |e| { + for (i, (key, value)) in t.iter().enumerate() { + try!(e.emit_map_elt_key(i, |e| e.emit_str(key))); + try!(e.emit_map_elt_val(i, |e| value.encode(e))); + } + Ok(()) + }) + } + } + } +} + +#[cfg(test)] +mod tests { + use std::collections::{BTreeMap, HashSet}; + use rustc_serialize::{self, Encodable, Decodable}; + + use {Encoder, Decoder, DecodeError}; + use Value; + use Value::{Table, Integer, Array, Float}; + + macro_rules! encode( ($t:expr) => ({ + let mut e = Encoder::new(); + $t.encode(&mut e).unwrap(); + e.toml + }) ); + + macro_rules! decode( ($t:expr) => ({ + let mut d = Decoder::new($t); + Decodable::decode(&mut d).unwrap() + }) ); + + macro_rules! map( ($($k:ident, $v:expr),*) => ({ + let mut _m = BTreeMap::new(); + $(_m.insert(stringify!($k).to_string(), $v);)* + _m + }) ); + + #[test] + fn smoke() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: isize } + + let v = Foo { a: 2 }; + assert_eq!(encode!(v), map! { a, Integer(2) }); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn smoke_hyphen() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a_b: isize } + + let v = Foo { a_b: 2 }; + assert_eq!(encode!(v), map! { a_b, Integer(2) }); + assert_eq!(v, decode!(Table(encode!(v)))); + + let mut m = BTreeMap::new(); + m.insert("a-b".to_string(), Integer(2)); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn nested() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: isize, b: Bar } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { a: String } + + let v = Foo { a: 2, b: Bar { a: "test".to_string() } }; + assert_eq!(encode!(v), + map! { + a, Integer(2), + b, Table(map! { + a, Value::String("test".to_string()) + }) + }); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn application_decode_error() { + #[derive(PartialEq, Debug)] + struct Range10(usize); + impl Decodable for Range10 { + fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<Range10, D::Error> { + let x: usize = try!(Decodable::decode(d)); + if x > 10 { + Err(d.error("Value out of range!")) + } else { + Ok(Range10(x)) + } + } + } + let mut d_good = Decoder::new(Integer(5)); + let mut d_bad1 = Decoder::new(Value::String("not an isize".to_string())); + let mut d_bad2 = Decoder::new(Integer(11)); + + assert_eq!(Ok(Range10(5)), Decodable::decode(&mut d_good)); + + let err1: Result<Range10, _> = Decodable::decode(&mut d_bad1); + assert!(err1.is_err()); + let err2: Result<Range10, _> = Decodable::decode(&mut d_bad2); + assert!(err2.is_err()); + } + + #[test] + fn array() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Vec<isize> } + + let v = Foo { a: vec![1, 2, 3, 4] }; + assert_eq!(encode!(v), + map! { + a, Array(vec![ + Integer(1), + Integer(2), + Integer(3), + Integer(4) + ]) + }); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn tuple() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: (isize, isize, isize, isize) } + + let v = Foo { a: (1, 2, 3, 4) }; + assert_eq!(encode!(v), + map! { + a, Array(vec![ + Integer(1), + Integer(2), + Integer(3), + Integer(4) + ]) + }); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn inner_structs_with_options() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { + a: Option<Box<Foo>>, + b: Bar, + } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { + a: String, + b: f64, + } + + let v = Foo { + a: Some(Box::new(Foo { + a: None, + b: Bar { a: "foo".to_string(), b: 4.5 }, + })), + b: Bar { a: "bar".to_string(), b: 1.0 }, + }; + assert_eq!(encode!(v), + map! { + a, Table(map! { + b, Table(map! { + a, Value::String("foo".to_string()), + b, Float(4.5) + }) + }), + b, Table(map! { + a, Value::String("bar".to_string()), + b, Float(1.0) + }) + }); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn hashmap() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { + map: BTreeMap<String, isize>, + set: HashSet<char>, + } + + let v = Foo { + map: { + let mut m = BTreeMap::new(); + m.insert("foo".to_string(), 10); + m.insert("bar".to_string(), 4); + m + }, + set: { + let mut s = HashSet::new(); + s.insert('a'); + s + }, + }; + assert_eq!(encode!(v), + map! { + map, Table(map! { + foo, Integer(10), + bar, Integer(4) + }), + set, Array(vec![Value::String("a".to_string())]) + } + ); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn tuple_struct() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo(isize, String, f64); + + let v = Foo(1, "foo".to_string(), 4.5); + assert_eq!( + encode!(v), + map! { + _field0, Integer(1), + _field1, Value::String("foo".to_string()), + _field2, Float(4.5) + } + ); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn table_array() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Vec<Bar>, } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { a: isize } + + let v = Foo { a: vec![Bar { a: 1 }, Bar { a: 2 }] }; + assert_eq!( + encode!(v), + map! { + a, Array(vec![ + Table(map!{ a, Integer(1) }), + Table(map!{ a, Integer(2) }), + ]) + } + ); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn type_errors() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { bar: isize } + + let mut d = Decoder::new(Table(map! { + bar, Float(1.0) + })); + let a: Result<Foo, DecodeError> = Decodable::decode(&mut d); + match a { + Ok(..) => panic!("should not have decoded"), + Err(e) => { + assert_eq!(format!("{}", e), + "expected a value of type `integer`, but \ + found a value of type `float` for the key `bar`"); + } + } + } + + #[test] + fn missing_errors() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { bar: isize } + + let mut d = Decoder::new(Table(map! { + })); + let a: Result<Foo, DecodeError> = Decodable::decode(&mut d); + match a { + Ok(..) => panic!("should not have decoded"), + Err(e) => { + assert_eq!(format!("{}", e), + "expected a value of type `integer` for the key `bar`"); + } + } + } + + #[test] + fn parse_enum() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: E } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + enum E { + Bar(isize), + Baz(f64), + Last(Foo2), + } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo2 { + test: String, + } + + let v = Foo { a: E::Bar(10) }; + assert_eq!( + encode!(v), + map! { a, Integer(10) } + ); + assert_eq!(v, decode!(Table(encode!(v)))); + + let v = Foo { a: E::Baz(10.2) }; + assert_eq!( + encode!(v), + map! { a, Float(10.2) } + ); + assert_eq!(v, decode!(Table(encode!(v)))); + + let v = Foo { a: E::Last(Foo2 { test: "test".to_string() }) }; + assert_eq!( + encode!(v), + map! { a, Table(map! { test, Value::String("test".to_string()) }) } + ); + assert_eq!(v, decode!(Table(encode!(v)))); + } + + #[test] + fn unused_fields() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: isize } + + let v = Foo { a: 2 }; + let mut d = Decoder::new(Table(map! { + a, Integer(2), + b, Integer(5) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, Some(Table(map! { + b, Integer(5) + }))); + } + + #[test] + fn unused_fields2() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Bar } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { a: isize } + + let v = Foo { a: Bar { a: 2 } }; + let mut d = Decoder::new(Table(map! { + a, Table(map! { + a, Integer(2), + b, Integer(5) + }) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, Some(Table(map! { + a, Table(map! { + b, Integer(5) + }) + }))); + } + + #[test] + fn unused_fields3() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Bar } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { a: isize } + + let v = Foo { a: Bar { a: 2 } }; + let mut d = Decoder::new(Table(map! { + a, Table(map! { + a, Integer(2) + }) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, None); + } + + #[test] + fn unused_fields4() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: BTreeMap<String, String> } + + let v = Foo { a: map! { a, "foo".to_string() } }; + let mut d = Decoder::new(Table(map! { + a, Table(map! { + a, Value::String("foo".to_string()) + }) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, None); + } + + #[test] + fn unused_fields5() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Vec<String> } + + let v = Foo { a: vec!["a".to_string()] }; + let mut d = Decoder::new(Table(map! { + a, Array(vec![Value::String("a".to_string())]) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, None); + } + + #[test] + fn unused_fields6() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Option<Vec<String>> } + + let v = Foo { a: Some(vec![]) }; + let mut d = Decoder::new(Table(map! { + a, Array(vec![]) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, None); + } + + #[test] + fn unused_fields7() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Vec<Bar> } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { a: isize } + + let v = Foo { a: vec![Bar { a: 1 }] }; + let mut d = Decoder::new(Table(map! { + a, Array(vec![Table(map! { + a, Integer(1), + b, Integer(2) + })]) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, Some(Table(map! { + a, Array(vec![Table(map! { + b, Integer(2) + })]) + }))); + } + + #[test] + fn empty_arrays() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Vec<Bar> } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar; + + let v = Foo { a: vec![] }; + let mut d = Decoder::new(Table(map! {})); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + } + + #[test] + fn empty_arrays2() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: Option<Vec<Bar>> } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar; + + let v = Foo { a: None }; + let mut d = Decoder::new(Table(map! {})); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + let v = Foo { a: Some(vec![]) }; + let mut d = Decoder::new(Table(map! { + a, Array(vec![]) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + } + + #[test] + fn round_trip() { + let toml = r#" + [test] + foo = "bar" + + [[values]] + foo = "baz" + + [[values]] + foo = "qux" + "#; + + let value: Value = toml.parse().unwrap(); + let val2 = ::encode_str(&value).parse().unwrap(); + assert_eq!(value, val2); + } +} diff --git a/deps/toml-0.1.21/src/lib.rs b/deps/toml-0.1.21/src/lib.rs new file mode 100644 index 000000000..0196fbc3b --- /dev/null +++ b/deps/toml-0.1.21/src/lib.rs @@ -0,0 +1,263 @@ +//! A TOML-parsing library +//! +//! This library is an implementation in Rust of a parser for TOML configuration +//! files [1]. It is focused around high quality errors including specific spans +//! and detailed error messages when things go wrong. +//! +//! This implementation currently passes the language agnostic [test suite][2]. +//! +//! # Example +//! +//! ``` +//! let toml = r#" +//! [test] +//! foo = "bar" +//! "#; +//! +//! let value = toml::Parser::new(toml).parse().unwrap(); +//! println!("{:?}", value); +//! ``` +//! +//! # Conversions +//! +//! This library also supports using the standard `Encodable` and `Decodable` +//! traits with TOML values. This library provides the following conversion +//! capabilities: +//! +//! * `String` => `toml::Value` - via `Parser` +//! * `toml::Value` => `String` - via `Display` +//! * `toml::Value` => rust object - via `Decoder` +//! * rust object => `toml::Value` - via `Encoder` +//! +//! Convenience functions for performing multiple conversions at a time are also +//! provided. +//! +//! [1]: https://github.com/mojombo/toml +//! [2]: https://github.com/BurntSushi/toml-test + +#![doc(html_root_url = "http://alexcrichton.com/toml-rs")] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] + +#[cfg(feature = "rustc-serialize")] extern crate rustc_serialize; + +use std::collections::BTreeMap; +use std::str::FromStr; +use std::string; + +pub use parser::{Parser, ParserError}; + +#[cfg(any(feature = "rustc-serialize", feature = "serde"))] +pub use self::encoder::{Encoder, Error, encode, encode_str}; +#[cfg(any(feature = "rustc-serialize", feature = "serde"))] +pub use self::decoder::{Decoder, DecodeError, DecodeErrorKind, decode, decode_str}; + +mod parser; +mod display; +#[cfg(any(feature = "rustc-serialize", feature = "serde"))] +mod encoder; +#[cfg(any(feature = "rustc-serialize", feature = "serde"))] +mod decoder; + +/// Representation of a TOML value. +#[derive(PartialEq, Clone, Debug)] +#[allow(missing_docs)] +pub enum Value { + String(String), + Integer(i64), + Float(f64), + Boolean(bool), + Datetime(String), + Array(Array), + Table(Table), +} + +/// Type representing a TOML array, payload of the Value::Array variant +pub type Array = Vec<Value>; + +/// Type representing a TOML table, payload of the Value::Table variant +pub type Table = BTreeMap<string::String, Value>; + +impl Value { + /// Tests whether this and another value have the same type. + pub fn same_type(&self, other: &Value) -> bool { + match (self, other) { + (&Value::String(..), &Value::String(..)) | + (&Value::Integer(..), &Value::Integer(..)) | + (&Value::Float(..), &Value::Float(..)) | + (&Value::Boolean(..), &Value::Boolean(..)) | + (&Value::Datetime(..), &Value::Datetime(..)) | + (&Value::Array(..), &Value::Array(..)) | + (&Value::Table(..), &Value::Table(..)) => true, + + _ => false, + } + } + + /// Returns a human-readable representation of the type of this value. + pub fn type_str(&self) -> &'static str { + match *self { + Value::String(..) => "string", + Value::Integer(..) => "integer", + Value::Float(..) => "float", + Value::Boolean(..) => "boolean", + Value::Datetime(..) => "datetime", + Value::Array(..) => "array", + Value::Table(..) => "table", + } + } + + /// Extracts the string of this value if it is a string. + pub fn as_str<'a>(&'a self) -> Option<&'a str> { + match *self { Value::String(ref s) => Some(&**s), _ => None } + } + + /// Extracts the integer value if it is an integer. + pub fn as_integer(&self) -> Option<i64> { + match *self { Value::Integer(i) => Some(i), _ => None } + } + + /// Extracts the float value if it is a float. + pub fn as_float(&self) -> Option<f64> { + match *self { Value::Float(f) => Some(f), _ => None } + } + + /// Extracts the boolean value if it is a boolean. + pub fn as_bool(&self) -> Option<bool> { + match *self { Value::Boolean(b) => Some(b), _ => None } + } + + /// Extracts the datetime value if it is a datetime. + /// + /// Note that a parsed TOML value will only contain ISO 8601 dates. An + /// example date is: + /// + /// ```notrust + /// 1979-05-27T07:32:00Z + /// ``` + pub fn as_datetime<'a>(&'a self) -> Option<&'a str> { + match *self { Value::Datetime(ref s) => Some(&**s), _ => None } + } + + /// Extracts the array value if it is an array. + pub fn as_slice<'a>(&'a self) -> Option<&'a [Value]> { + match *self { Value::Array(ref s) => Some(&**s), _ => None } + } + + /// Extracts the table value if it is a table. + pub fn as_table<'a>(&'a self) -> Option<&'a Table> { + match *self { Value::Table(ref s) => Some(s), _ => None } + } + + /// Lookups for value at specified path. + /// + /// Uses '.' as a path separator. + /// + /// Note: arrays have zero-based indexes. + /// + /// ``` + /// # #![allow(unstable)] + /// let toml = r#" + /// [test] + /// foo = "bar" + /// + /// [[values]] + /// foo = "baz" + /// + /// [[values]] + /// foo = "qux" + /// "#; + /// let value: toml::Value = toml.parse().unwrap(); + /// + /// let foo = value.lookup("test.foo").unwrap(); + /// assert_eq!(foo.as_str().unwrap(), "bar"); + /// + /// let foo = value.lookup("values.1.foo").unwrap(); + /// assert_eq!(foo.as_str().unwrap(), "qux"); + /// + /// let no_bar = value.lookup("test.bar"); + /// assert_eq!(no_bar.is_none(), true); + /// ``` + pub fn lookup<'a>(&'a self, path: &'a str) -> Option<&'a Value> { + let mut cur_value = self; + for key in path.split('.') { + match cur_value { + &Value::Table(ref hm) => { + match hm.get(key) { + Some(v) => cur_value = v, + None => return None + } + }, + &Value::Array(ref v) => { + match key.parse::<usize>().ok() { + Some(idx) if idx < v.len() => cur_value = &v[idx], + _ => return None + } + }, + _ => return None + } + }; + + Some(cur_value) + } +} + +impl FromStr for Value { + type Err = Vec<ParserError>; + fn from_str(s: &str) -> Result<Value, Vec<ParserError>> { + let mut p = Parser::new(s); + match p.parse().map(Value::Table) { + Some(n) => Ok(n), + None => Err(p.errors), + } + } +} + +#[cfg(test)] +mod tests { + use super::Value; + + #[test] + fn lookup_valid() { + let toml = r#" + [test] + foo = "bar" + + [[values]] + foo = "baz" + + [[values]] + foo = "qux" + "#; + + let value: Value = toml.parse().unwrap(); + + let test_foo = value.lookup("test.foo").unwrap(); + assert_eq!(test_foo.as_str().unwrap(), "bar"); + + let foo1 = value.lookup("values.1.foo").unwrap(); + assert_eq!(foo1.as_str().unwrap(), "qux"); + + assert!(value.lookup("test.bar").is_none()); + assert!(value.lookup("test.foo.bar").is_none()); + } + + #[test] + fn lookup_invalid_index() { + let toml = r#" + [[values]] + foo = "baz" + "#; + + let value: Value = toml.parse().unwrap(); + + let foo = value.lookup("test.foo"); + assert!(foo.is_none()); + + let foo = value.lookup("values.100.foo"); + assert!(foo.is_none()); + + let foo = value.lookup("values.str.foo"); + assert!(foo.is_none()); + } +} diff --git a/deps/toml-0.1.21/src/parser.rs b/deps/toml-0.1.21/src/parser.rs new file mode 100644 index 000000000..b7a810f69 --- /dev/null +++ b/deps/toml-0.1.21/src/parser.rs @@ -0,0 +1,1418 @@ +use std::ascii::AsciiExt; +use std::char; +use std::collections::BTreeMap; +use std::error::Error; +use std::fmt; +use std::str; + +macro_rules! try { + ($e:expr) => (match $e { Some(s) => s, None => return None }) +} + +// We redefine Value because we need to keep track of encountered table +// definitions, eg when parsing: +// +// [a] +// [a.b] +// [a] +// +// we have to error out on redefinition of [a]. This bit of data is difficult to +// track in a side table so we just have a "stripped down" AST to work with +// which has the relevant metadata fields in it. +struct TomlTable { + values: BTreeMap<String, Value>, + defined: bool, +} + +impl TomlTable { + fn convert(self) -> super::Table { + self.values.into_iter().map(|(k,v)| (k, v.convert())).collect() + } +} + +enum Value { + String(String), + Integer(i64), + Float(f64), + Boolean(bool), + Datetime(String), + Array(Vec<Value>), + Table(TomlTable), +} + +impl Value { + fn type_str(&self) -> &'static str { + match *self { + Value::String(..) => "string", + Value::Integer(..) => "integer", + Value::Float(..) => "float", + Value::Boolean(..) => "boolean", + Value::Datetime(..) => "datetime", + Value::Array(..) => "array", + Value::Table(..) => "table", + } + } + + fn same_type(&self, other: &Value) -> bool { + match (self, other) { + (&Value::String(..), &Value::String(..)) | + (&Value::Integer(..), &Value::Integer(..)) | + (&Value::Float(..), &Value::Float(..)) | + (&Value::Boolean(..), &Value::Boolean(..)) | + (&Value::Datetime(..), &Value::Datetime(..)) | + (&Value::Array(..), &Value::Array(..)) | + (&Value::Table(..), &Value::Table(..)) => true, + + _ => false, + } + } + + fn convert(self) -> super::Value { + match self { + Value::String(x) => super::Value::String(x), + Value::Integer(x) => super::Value::Integer(x), + Value::Float(x) => super::Value::Float(x), + Value::Boolean(x) => super::Value::Boolean(x), + Value::Datetime(x) => super::Value::Datetime(x), + Value::Array(v) => + super::Value::Array( + v.into_iter().map(|x| x.convert()).collect() + ), + Value::Table(t) => super::Value::Table(t.convert()) + } + } +} + +/// Parser for converting a string to a TOML `Value` instance. +/// +/// This parser contains the string slice that is being parsed, and exports the +/// list of errors which have occurred during parsing. +pub struct Parser<'a> { + input: &'a str, + cur: str::CharIndices<'a>, + + /// A list of all errors which have occurred during parsing. + /// + /// Not all parse errors are fatal, so this list is added to as much as + /// possible without aborting parsing. If `None` is returned by `parse`, it + /// is guaranteed that this list is not empty. + pub errors: Vec<ParserError>, +} + +/// A structure representing a parse error. +/// +/// The data in this structure can be used to trace back to the original cause +/// of the error in order to provide diagnostics about parse errors. +#[derive(Debug)] +pub struct ParserError { + /// The low byte at which this error is pointing at. + pub lo: usize, + /// One byte beyond the last character at which this error is pointing at. + pub hi: usize, + /// A human-readable description explaining what the error is. + pub desc: String, +} + +impl<'a> Parser<'a> { + /// Creates a new parser for a string. + /// + /// The parser can be executed by invoking the `parse` method. + /// + /// # Example + /// + /// ``` + /// let toml = r#" + /// [test] + /// foo = "bar" + /// "#; + /// + /// let mut parser = toml::Parser::new(toml); + /// match parser.parse() { + /// Some(value) => println!("found toml: {:?}", value), + /// None => { + /// println!("parse errors: {:?}", parser.errors); + /// } + /// } + /// ``` + pub fn new(s: &'a str) -> Parser<'a> { + Parser { + input: s, + cur: s.char_indices(), + errors: Vec::new(), + } + } + + /// Converts a byte offset from an error message to a (line, column) pair + /// + /// All indexes are 0-based. + pub fn to_linecol(&self, offset: usize) -> (usize, usize) { + let mut cur = 0; + for (i, line) in self.input.lines().enumerate() { + if cur + line.len() > offset { + return (i, offset - cur) + } + cur += line.len() + 1; + } + return (self.input.lines().count(), 0) + } + + fn next_pos(&self) -> usize { + self.cur.clone().next().map(|p| p.0).unwrap_or(self.input.len()) + } + + // Returns true and consumes the next character if it matches `ch`, + // otherwise do nothing and return false + fn eat(&mut self, ch: char) -> bool { + match self.peek(0) { + Some((_, c)) if c == ch => { self.cur.next(); true } + Some(_) | None => false, + } + } + + // Peeks ahead `n` characters + fn peek(&self, n: usize) -> Option<(usize, char)> { + self.cur.clone().skip(n).next() + } + + fn expect(&mut self, ch: char) -> bool { + if self.eat(ch) { return true } + let mut it = self.cur.clone(); + let lo = it.next().map(|p| p.0).unwrap_or(self.input.len()); + let hi = it.next().map(|p| p.0).unwrap_or(self.input.len()); + self.errors.push(ParserError { + lo: lo, + hi: hi, + desc: match self.cur.clone().next() { + Some((_, c)) => format!("expected `{}`, but found `{}`", ch, c), + None => format!("expected `{}`, but found eof", ch) + } + }); + false + } + + // Consumes whitespace ('\t' and ' ') until another character (or EOF) is + // reached. Returns if any whitespace was consumed + fn ws(&mut self) -> bool { + let mut ret = false; + loop { + match self.peek(0) { + Some((_, '\t')) | + Some((_, ' ')) => { self.cur.next(); ret = true; } + _ => break, + } + } + ret + } + + // Consumes the rest of the line after a comment character + fn comment(&mut self) -> bool { + if !self.eat('#') { return false } + for (_, ch) in self.cur.by_ref() { + if ch == '\n' { break } + } + true + } + + // Consumes a newline if one is next + fn newline(&mut self) -> bool { + match self.peek(0) { + Some((_, '\n')) => { self.cur.next(); true } + Some((_, '\r')) if self.peek(1).map(|c| c.1) == Some('\n') => { + self.cur.next(); self.cur.next(); true + } + _ => false + } + } + + /// Executes the parser, parsing the string contained within. + /// + /// This function will return the `TomlTable` instance if parsing is + /// successful, or it will return `None` if any parse error or invalid TOML + /// error occurs. + /// + /// If an error occurs, the `errors` field of this parser can be consulted + /// to determine the cause of the parse failure. + pub fn parse(&mut self) -> Option<super::Table> { + let mut ret = TomlTable { values: BTreeMap::new(), defined: false }; + while self.peek(0).is_some() { + self.ws(); + if self.newline() { continue } + if self.comment() { continue } + if self.eat('[') { + let array = self.eat('['); + let start = self.next_pos(); + + // Parse the name of the section + let mut keys = Vec::new(); + loop { + self.ws(); + if let Some(s) = self.key_name() { + keys.push(s); + } + self.ws(); + if self.eat(']') { + if array && !self.expect(']') { return None } + break + } + if !self.expect('.') { return None } + } + if keys.len() == 0 { return None } + + // Build the section table + let mut table = TomlTable { + values: BTreeMap::new(), + defined: true, + }; + if !self.values(&mut table) { return None } + if array { + self.insert_array(&mut ret, &keys, Value::Table(table), + start) + } else { + self.insert_table(&mut ret, &keys, table, start) + } + } else { + if !self.values(&mut ret) { return None } + } + } + if self.errors.len() > 0 { + None + } else { + Some(ret.convert()) + } + } + + // Parse a single key name starting at `start` + fn key_name(&mut self) -> Option<String> { + let start = self.next_pos(); + let key = if self.eat('"') { + self.finish_string(start, false) + } else { + let mut ret = String::new(); + while let Some((_, ch)) = self.cur.clone().next() { + match ch { + 'a' ... 'z' | + 'A' ... 'Z' | + '0' ... '9' | + '_' | '-' => { self.cur.next(); ret.push(ch) } + _ => break, + } + } + Some(ret) + }; + match key { + Some(ref name) if name.len() == 0 => { + self.errors.push(ParserError { + lo: start, + hi: start, + desc: format!("expected a key but found an empty string"), + }); + None + } + Some(name) => Some(name), + None => None, + } + } + + // Parses the values into the given TomlTable. Returns true in case of success + // and false in case of error. + fn values(&mut self, into: &mut TomlTable) -> bool { + loop { + self.ws(); + if self.newline() { continue } + if self.comment() { continue } + match self.peek(0) { + Some((_, '[')) => break, + Some(..) => {} + None => break, + } + let key_lo = self.next_pos(); + let key = match self.key_name() { + Some(s) => s, + None => return false + }; + if !self.keyval_sep() { return false } + let value = match self.value() { + Some(value) => value, + None => return false, + }; + self.insert(into, key, value, key_lo); + self.ws(); + self.comment(); + self.newline(); + } + return true + } + + fn keyval_sep(&mut self) -> bool { + self.ws(); + if !self.expect('=') { return false } + self.ws(); + true + } + + // Parses a value + fn value(&mut self) -> Option<Value> { + self.ws(); + match self.cur.clone().next() { + Some((pos, '"')) => self.string(pos), + Some((pos, '\'')) => self.literal_string(pos), + Some((pos, 't')) | + Some((pos, 'f')) => self.boolean(pos), + Some((pos, '[')) => self.array(pos), + Some((pos, '{')) => self.inline_table(pos), + Some((pos, '-')) | + Some((pos, '+')) => self.number_or_datetime(pos), + Some((pos, ch)) if is_digit(ch) => self.number_or_datetime(pos), + _ => { + let mut it = self.cur.clone(); + let lo = it.next().map(|p| p.0).unwrap_or(self.input.len()); + let hi = it.next().map(|p| p.0).unwrap_or(self.input.len()); + self.errors.push(ParserError { + lo: lo, + hi: hi, + desc: format!("expected a value"), + }); + return None + } + } + } + + // Parses a single or multi-line string + fn string(&mut self, start: usize) -> Option<Value> { + if !self.expect('"') { return None } + let mut multiline = false; + + // detect multiline literals, but be careful about empty "" + // strings + if self.eat('"') { + if self.eat('"') { + multiline = true; + self.newline(); + } else { + // empty + return Some(Value::String(String::new())) + } + } + + self.finish_string(start, multiline).map(Value::String) + } + + // Finish parsing a basic string after the opening quote has been seen + fn finish_string(&mut self, + start: usize, + multiline: bool) -> Option<String> { + let mut ret = String::new(); + loop { + while multiline && self.newline() { ret.push('\n') } + match self.cur.next() { + Some((_, '"')) => { + if multiline { + if !self.eat('"') { ret.push_str("\""); continue } + if !self.eat('"') { ret.push_str("\"\""); continue } + } + return Some(ret) + } + Some((pos, '\\')) => { + if let Some(c) = escape(self, pos, multiline) { + ret.push(c); + } + } + Some((pos, ch)) if ch < '\u{1f}' => { + self.errors.push(ParserError { + lo: pos, + hi: pos + 1, + desc: format!("control character `{}` must be escaped", + ch.escape_default().collect::<String>()) + }); + } + Some((_, ch)) => ret.push(ch), + None => { + self.errors.push(ParserError { + lo: start, + hi: self.input.len(), + desc: format!("unterminated string literal"), + }); + return None + } + } + } + + fn escape(me: &mut Parser, pos: usize, multiline: bool) -> Option<char> { + if multiline && me.newline() { + while me.ws() || me.newline() { /* ... */ } + return None + } + match me.cur.next() { + Some((_, 'b')) => Some('\u{8}'), + Some((_, 't')) => Some('\u{9}'), + Some((_, 'n')) => Some('\u{a}'), + Some((_, 'f')) => Some('\u{c}'), + Some((_, 'r')) => Some('\u{d}'), + Some((_, '"')) => Some('\u{22}'), + Some((_, '\\')) => Some('\u{5c}'), + Some((pos, c @ 'u')) | + Some((pos, c @ 'U')) => { + let len = if c == 'u' {4} else {8}; + let num = &me.input[pos+1..]; + let num = if num.len() >= len && num.is_ascii() { + &num[..len] + } else { + "invalid" + }; + if let Some(n) = u32::from_str_radix(num, 16).ok() { + if let Some(c) = char::from_u32(n) { + me.cur.by_ref().skip(len - 1).next(); + return Some(c) + } else { + me.errors.push(ParserError { + lo: pos + 1, + hi: pos + 5, + desc: format!("codepoint `{:x}` is \ + not a valid unicode \ + codepoint", n), + }) + } + } else { + me.errors.push(ParserError { + lo: pos, + hi: pos + 1, + desc: format!("expected {} hex digits \ + after a `{}` escape", len, c), + }) + } + None + } + Some((pos, ch)) => { + let next_pos = me.next_pos(); + me.errors.push(ParserError { + lo: pos, + hi: next_pos, + desc: format!("unknown string escape: `{}`", + ch.escape_default().collect::<String>()), + }); + None + } + None => { + me.errors.push(ParserError { + lo: pos, + hi: pos + 1, + desc: format!("unterminated escape sequence"), + }); + None + } + } + } + } + + fn literal_string(&mut self, start: usize) -> Option<Value> { + if !self.expect('\'') { return None } + let mut multiline = false; + let mut ret = String::new(); + + // detect multiline literals + if self.eat('\'') { + if self.eat('\'') { + multiline = true; + self.newline(); + } else { + return Some(Value::String(ret)) // empty + } + } + + loop { + if !multiline && self.newline() { + let next = self.next_pos(); + self.errors.push(ParserError { + lo: start, + hi: next, + desc: format!("literal strings cannot contain newlines"), + }); + return None + } + match self.cur.next() { + Some((_, '\'')) => { + if multiline { + if !self.eat('\'') { ret.push_str("'"); continue } + if !self.eat('\'') { ret.push_str("''"); continue } + } + break + } + Some((_, ch)) => ret.push(ch), + None => { + self.errors.push(ParserError { + lo: start, + hi: self.input.len(), + desc: format!("unterminated string literal"), + }); + return None + } + } + } + + return Some(Value::String(ret)); + } + + fn number_or_datetime(&mut self, start: usize) -> Option<Value> { + let mut is_float = false; + let prefix = try!(self.integer(start, false, true)); + let decimal = if self.eat('.') { + is_float = true; + Some(try!(self.integer(start, true, false))) + } else { + None + }; + let exponent = if self.eat('e') || self.eat('E') { + is_float = true; + Some(try!(self.integer(start, false, true))) + } else { + None + }; + let end = self.next_pos(); + let input = &self.input[start..end]; + let ret = if !is_float && !input.starts_with("+") && + !input.starts_with("-") && self.eat('-') { + self.datetime(start, end + 1) + } else { + let input = match (decimal, exponent) { + (None, None) => prefix, + (Some(ref d), None) => prefix + "." + d, + (None, Some(ref e)) => prefix + "E" + e, + (Some(ref d), Some(ref e)) => prefix + "." + d + "E" + e, + }; + let input = input.trim_left_matches('+'); + if is_float { + input.parse().ok().map(Value::Float) + } else { + input.parse().ok().map(Value::Integer) + } + }; + if ret.is_none() { + self.errors.push(ParserError { + lo: start, + hi: end, + desc: format!("invalid numeric literal"), + }); + } + return ret; + } + + fn integer(&mut self, start: usize, allow_leading_zeros: bool, + allow_sign: bool) -> Option<String> { + let mut s = String::new(); + if allow_sign { + if self.eat('-') { s.push('-'); } + else if self.eat('+') { s.push('+'); } + } + match self.cur.next() { + Some((_, '0')) if !allow_leading_zeros => { + s.push('0'); + match self.peek(0) { + Some((pos, c)) if '0' <= c && c <= '9' => { + self.errors.push(ParserError { + lo: start, + hi: pos, + desc: format!("leading zeroes are not allowed"), + }); + return None + } + _ => {} + } + } + Some((_, ch)) if '0' <= ch && ch <= '9' => { + s.push(ch); + } + _ => { + let pos = self.next_pos(); + self.errors.push(ParserError { + lo: pos, + hi: pos, + desc: format!("expected start of a numeric literal"), + }); + return None; + } + } + let mut underscore = false; + loop { + match self.cur.clone().next() { + Some((_, ch)) if '0' <= ch && ch <= '9' => { + s.push(ch); + self.cur.next(); + underscore = false; + } + Some((_, '_')) if !underscore => { + self.cur.next(); + underscore = true; + } + Some(_) | None => break, + } + } + if underscore { + let pos = self.next_pos(); + self.errors.push(ParserError { + lo: pos, + hi: pos, + desc: format!("numeral cannot end with an underscore"), + }); + return None + } else { + Some(s) + } + } + + fn boolean(&mut self, start: usize) -> Option<Value> { + let rest = &self.input[start..]; + if rest.starts_with("true") { + for _ in 0..4 { + self.cur.next(); + } + Some(Value::Boolean(true)) + } else if rest.starts_with("false") { + for _ in 0..5 { + self.cur.next(); + } + Some(Value::Boolean(false)) + } else { + let next = self.next_pos(); + self.errors.push(ParserError { + lo: start, + hi: next, + desc: format!("unexpected character: `{}`", + rest.chars().next().unwrap()), + }); + None + } + } + + fn datetime(&mut self, start: usize, end_so_far: usize) -> Option<Value> { + let mut date = format!("{}", &self.input[start..end_so_far]); + for _ in 0..15 { + match self.cur.next() { + Some((_, ch)) => date.push(ch), + None => { + self.errors.push(ParserError { + lo: start, + hi: end_so_far, + desc: format!("malformed date literal"), + }); + return None + } + } + } + let mut it = date.chars(); + let mut valid = true; + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(|c| c == '-').unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(|c| c == '-').unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(|c| c == 'T').unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(|c| c == ':').unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(|c| c == ':').unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(is_digit).unwrap_or(false); + valid = valid && it.next().map(|c| c == 'Z').unwrap_or(false); + if valid { + Some(Value::Datetime(date.clone())) + } else { + self.errors.push(ParserError { + lo: start, + hi: start + date.len(), + desc: format!("malformed date literal"), + }); + None + } + } + + fn array(&mut self, _start: usize) -> Option<Value> { + if !self.expect('[') { return None } + let mut ret = Vec::new(); + fn consume(me: &mut Parser) { + loop { + me.ws(); + if !me.newline() && !me.comment() { break } + } + } + let mut type_str = None; + loop { + // Break out early if we see the closing bracket + consume(self); + if self.eat(']') { return Some(Value::Array(ret)) } + + // Attempt to parse a value, triggering an error if it's the wrong + // type. + let start = self.next_pos(); + let value = try!(self.value()); + let end = self.next_pos(); + let expected = type_str.unwrap_or(value.type_str()); + if value.type_str() != expected { + self.errors.push(ParserError { + lo: start, + hi: end, + desc: format!("expected type `{}`, found type `{}`", + expected, value.type_str()), + }); + } else { + type_str = Some(expected); + ret.push(value); + } + + // Look for a comma. If we don't find one we're done + consume(self); + if !self.eat(',') { break } + } + consume(self); + if !self.expect(']') { return None } + return Some(Value::Array(ret)) + } + + fn inline_table(&mut self, _start: usize) -> Option<Value> { + if !self.expect('{') { return None } + self.ws(); + let mut ret = TomlTable { values: BTreeMap::new(), defined: true }; + if self.eat('}') { return Some(Value::Table(ret)) } + loop { + let lo = self.next_pos(); + let key = try!(self.key_name()); + if !self.keyval_sep() { return None } + let value = try!(self.value()); + self.insert(&mut ret, key, value, lo); + + self.ws(); + if self.eat('}') { break } + if !self.expect(',') { return None } + self.ws(); + } + return Some(Value::Table(ret)) + } + + fn insert(&mut self, into: &mut TomlTable, key: String, value: Value, + key_lo: usize) { + if into.values.contains_key(&key) { + self.errors.push(ParserError { + lo: key_lo, + hi: key_lo + key.len(), + desc: format!("duplicate key: `{}`", key), + }) + } else { + into.values.insert(key, value); + } + } + + fn recurse<'b>(&mut self, mut cur: &'b mut TomlTable, keys: &'b [String], + key_lo: usize) -> Option<(&'b mut TomlTable, &'b str)> { + let key_hi = keys.iter().fold(0, |a, b| a + b.len()); + for part in keys[..keys.len() - 1].iter() { + let tmp = cur; + + if tmp.values.contains_key(part) { + match *tmp.values.get_mut(part).unwrap() { + Value::Table(ref mut table) => cur = table, + Value::Array(ref mut array) => { + match array.last_mut() { + Some(&mut Value::Table(ref mut table)) => cur = table, + _ => { + self.errors.push(ParserError { + lo: key_lo, + hi: key_hi, + desc: format!("array `{}` does not contain \ + tables", part) + }); + return None + } + } + } + _ => { + self.errors.push(ParserError { + lo: key_lo, + hi: key_hi, + desc: format!("key `{}` was not previously a table", + part) + }); + return None + } + } + continue + } + + // Initialize an empty table as part of this sub-key + tmp.values.insert(part.clone(), Value::Table(TomlTable { + values: BTreeMap::new(), + defined: false, + })); + match *tmp.values.get_mut(part).unwrap() { + Value::Table(ref mut inner) => cur = inner, + _ => unreachable!(), + } + } + Some((cur, &**keys.last().unwrap())) + } + + fn insert_table(&mut self, into: &mut TomlTable, keys: &[String], + table: TomlTable, key_lo: usize) { + let (into, key) = match self.recurse(into, keys, key_lo) { + Some(pair) => pair, + None => return, + }; + if !into.values.contains_key(key) { + into.values.insert(key.to_owned(), Value::Table(table)); + return + } + if let Value::Table(ref mut into) = *into.values.get_mut(key).unwrap() { + if into.defined { + self.errors.push(ParserError { + lo: key_lo, + hi: key_lo + key.len(), + desc: format!("redefinition of table `{}`", key), + }); + } + for (k, v) in table.values { + if into.values.insert(k.clone(), v).is_some() { + self.errors.push(ParserError { + lo: key_lo, + hi: key_lo + key.len(), + desc: format!("duplicate key `{}` in table", k), + }); + } + } + } else { + self.errors.push(ParserError { + lo: key_lo, + hi: key_lo + key.len(), + desc: format!("duplicate key `{}` in table", key), + }); + } + } + + fn insert_array(&mut self, into: &mut TomlTable, + keys: &[String], value: Value, key_lo: usize) { + let (into, key) = match self.recurse(into, keys, key_lo) { + Some(pair) => pair, + None => return, + }; + if !into.values.contains_key(key) { + into.values.insert(key.to_owned(), Value::Array(Vec::new())); + } + match *into.values.get_mut(key).unwrap() { + Value::Array(ref mut vec) => { + match vec.first() { + Some(ref v) if !v.same_type(&value) => { + self.errors.push(ParserError { + lo: key_lo, + hi: key_lo + key.len(), + desc: format!("expected type `{}`, found type `{}`", + v.type_str(), value.type_str()), + }) + } + Some(..) | None => {} + } + vec.push(value); + } + _ => { + self.errors.push(ParserError { + lo: key_lo, + hi: key_lo + key.len(), + desc: format!("key `{}` was previously not an array", key), + }); + } + } + } +} + +impl Error for ParserError { + fn description(&self) -> &str { "TOML parse error" } +} + +impl fmt::Display for ParserError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.desc.fmt(f) + } +} + +fn is_digit(c: char) -> bool { + match c { '0' ... '9' => true, _ => false } +} + +#[cfg(test)] +mod tests { + use Value::Table; + use Parser; + + macro_rules! bad { + ($s:expr, $msg:expr) => ({ + let mut p = Parser::new($s); + assert!(p.parse().is_none()); + assert!(p.errors.iter().any(|e| e.desc.contains($msg)), + "errors: {:?}", p.errors); + }) + } + + #[test] + fn crlf() { + let mut p = Parser::new("\ +[project]\r\n\ +\r\n\ +name = \"splay\"\r\n\ +version = \"0.1.0\"\r\n\ +authors = [\"alex@crichton.co\"]\r\n\ +\r\n\ +[[lib]]\r\n\ +\r\n\ +path = \"lib.rs\"\r\n\ +name = \"splay\"\r\n\ +description = \"\"\"\ +A Rust implementation of a TAR file reader and writer. This library does not\r\n\ +currently handle compression, but it is abstract over all I/O readers and\r\n\ +writers. Additionally, great lengths are taken to ensure that the entire\r\n\ +contents are never required to be entirely resident in memory all at once.\r\n\ +\"\"\"\ +"); + assert!(p.parse().is_some()); + } + + #[test] + fn linecol() { + let p = Parser::new("ab\ncde\nf"); + assert_eq!(p.to_linecol(0), (0, 0)); + assert_eq!(p.to_linecol(1), (0, 1)); + assert_eq!(p.to_linecol(3), (1, 0)); + assert_eq!(p.to_linecol(4), (1, 1)); + assert_eq!(p.to_linecol(7), (2, 0)); + } + + #[test] + fn fun_with_strings() { + let mut p = Parser::new(r#" +bar = "\U00000000" +key1 = "One\nTwo" +key2 = """One\nTwo""" +key3 = """ +One +Two""" + +key4 = "The quick brown fox jumps over the lazy dog." +key5 = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" +key6 = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ +# What you see is what you get. +winpath = 'C:\Users\nodejs\templates' +winpath2 = '\\ServerX\admin$\system32\' +quoted = 'Tom "Dubs" Preston-Werner' +regex = '<\i\c*\s*>' + +regex2 = '''I [dw]on't need \d{2} apples''' +lines = ''' +The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +''' +"#); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("bar").and_then(|k| k.as_str()), Some("\0")); + assert_eq!(table.lookup("key1").and_then(|k| k.as_str()), + Some("One\nTwo")); + assert_eq!(table.lookup("key2").and_then(|k| k.as_str()), + Some("One\nTwo")); + assert_eq!(table.lookup("key3").and_then(|k| k.as_str()), + Some("One\nTwo")); + + let msg = "The quick brown fox jumps over the lazy dog."; + assert_eq!(table.lookup("key4").and_then(|k| k.as_str()), Some(msg)); + assert_eq!(table.lookup("key5").and_then(|k| k.as_str()), Some(msg)); + assert_eq!(table.lookup("key6").and_then(|k| k.as_str()), Some(msg)); + + assert_eq!(table.lookup("winpath").and_then(|k| k.as_str()), + Some(r"C:\Users\nodejs\templates")); + assert_eq!(table.lookup("winpath2").and_then(|k| k.as_str()), + Some(r"\\ServerX\admin$\system32\")); + assert_eq!(table.lookup("quoted").and_then(|k| k.as_str()), + Some(r#"Tom "Dubs" Preston-Werner"#)); + assert_eq!(table.lookup("regex").and_then(|k| k.as_str()), + Some(r"<\i\c*\s*>")); + assert_eq!(table.lookup("regex2").and_then(|k| k.as_str()), + Some(r"I [dw]on't need \d{2} apples")); + assert_eq!(table.lookup("lines").and_then(|k| k.as_str()), + Some("The first newline is\n\ + trimmed in raw strings.\n \ + All other whitespace\n \ + is preserved.\n")); + } + + #[test] + fn tables_in_arrays() { + let mut p = Parser::new(r#" +[[foo]] + #… + [foo.bar] + #… + +[[foo]] + #… + [foo.bar] + #... +"#); + let table = Table(p.parse().unwrap()); + table.lookup("foo.0.bar").unwrap().as_table().unwrap(); + table.lookup("foo.1.bar").unwrap().as_table().unwrap(); + } + + #[test] + fn fruit() { + let mut p = Parser::new(r#" +[[fruit]] + name = "apple" + + [fruit.physical] + color = "red" + shape = "round" + + [[fruit.variety]] + name = "red delicious" + + [[fruit.variety]] + name = "granny smith" + +[[fruit]] + name = "banana" + + [[fruit.variety]] + name = "plantain" +"#); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("fruit.0.name").and_then(|k| k.as_str()), + Some("apple")); + assert_eq!(table.lookup("fruit.0.physical.color").and_then(|k| k.as_str()), + Some("red")); + assert_eq!(table.lookup("fruit.0.physical.shape").and_then(|k| k.as_str()), + Some("round")); + assert_eq!(table.lookup("fruit.0.variety.0.name").and_then(|k| k.as_str()), + Some("red delicious")); + assert_eq!(table.lookup("fruit.0.variety.1.name").and_then(|k| k.as_str()), + Some("granny smith")); + assert_eq!(table.lookup("fruit.1.name").and_then(|k| k.as_str()), + Some("banana")); + assert_eq!(table.lookup("fruit.1.variety.0.name").and_then(|k| k.as_str()), + Some("plantain")); + } + + #[test] + fn stray_cr() { + assert!(Parser::new("\r").parse().is_none()); + assert!(Parser::new("a = [ \r ]").parse().is_none()); + assert!(Parser::new("a = \"\"\"\r\"\"\"").parse().is_none()); + assert!(Parser::new("a = \"\"\"\\ \r \"\"\"").parse().is_none()); + + let mut p = Parser::new("foo = '''\r'''"); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\r")); + + let mut p = Parser::new("foo = '\r'"); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\r")); + } + + #[test] + fn blank_literal_string() { + let mut p = Parser::new("foo = ''"); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("")); + } + + #[test] + fn many_blank() { + let mut p = Parser::new("foo = \"\"\"\n\n\n\"\"\""); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\n\n")); + } + + #[test] + fn literal_eats_crlf() { + let mut p = Parser::new(" + foo = \"\"\"\\\r\n\"\"\" + bar = \"\"\"\\\r\n \r\n \r\n a\"\"\" + "); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("")); + assert_eq!(table.lookup("bar").and_then(|k| k.as_str()), Some("a")); + } + + #[test] + fn string_no_newline() { + assert!(Parser::new("a = \"\n\"").parse().is_none()); + assert!(Parser::new("a = '\n'").parse().is_none()); + } + + #[test] + fn bad_leading_zeros() { + assert!(Parser::new("a = 00").parse().is_none()); + assert!(Parser::new("a = -00").parse().is_none()); + assert!(Parser::new("a = +00").parse().is_none()); + assert!(Parser::new("a = 00.0").parse().is_none()); + assert!(Parser::new("a = -00.0").parse().is_none()); + assert!(Parser::new("a = +00.0").parse().is_none()); + assert!(Parser::new("a = 9223372036854775808").parse().is_none()); + assert!(Parser::new("a = -9223372036854775809").parse().is_none()); + } + + #[test] + fn bad_floats() { + assert!(Parser::new("a = 0.").parse().is_none()); + assert!(Parser::new("a = 0.e").parse().is_none()); + assert!(Parser::new("a = 0.E").parse().is_none()); + assert!(Parser::new("a = 0.0E").parse().is_none()); + assert!(Parser::new("a = 0.0e").parse().is_none()); + assert!(Parser::new("a = 0.0e-").parse().is_none()); + assert!(Parser::new("a = 0.0e+").parse().is_none()); + assert!(Parser::new("a = 0.0e+00").parse().is_none()); + } + + #[test] + fn floats() { + macro_rules! t { + ($actual:expr, $expected:expr) => ({ + let f = format!("foo = {}", $actual); + let mut p = Parser::new(&f); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_float()), + Some($expected)); + }) + } + + t!("1.0", 1.0); + t!("1.0e0", 1.0); + t!("1.0e+0", 1.0); + t!("1.0e-0", 1.0); + t!("1.001e-0", 1.001); + t!("2e10", 2e10); + t!("2e+10", 2e10); + t!("2e-10", 2e-10); + t!("2_0.0", 20.0); + t!("2_0.0_0e0_0", 20.0); + t!("2_0.1_0e1_0", 20.1e10); + } + + #[test] + fn bare_key_names() { + let mut p = Parser::new(" + foo = 3 + foo_3 = 3 + foo_-2--3--r23f--4-f2-4 = 3 + _ = 3 + - = 3 + 8 = 8 + \"a\" = 3 + \"!\" = 3 + \"a^b\" = 3 + \"\\\"\" = 3 + \"character encoding\" = \"value\" + \"ʎǝʞ\" = \"value\" + "); + let table = Table(p.parse().unwrap()); + assert!(table.lookup("foo").is_some()); + assert!(table.lookup("-").is_some()); + assert!(table.lookup("_").is_some()); + assert!(table.lookup("8").is_some()); + assert!(table.lookup("foo_3").is_some()); + assert!(table.lookup("foo_-2--3--r23f--4-f2-4").is_some()); + assert!(table.lookup("a").is_some()); + assert!(table.lookup("!").is_some()); + assert!(table.lookup("\"").is_some()); + assert!(table.lookup("character encoding").is_some()); + assert!(table.lookup("ʎǝʞ").is_some()); + } + + #[test] + fn bad_keys() { + assert!(Parser::new("key\n=3").parse().is_none()); + assert!(Parser::new("key=\n3").parse().is_none()); + assert!(Parser::new("key|=3").parse().is_none()); + assert!(Parser::new("\"\"=3").parse().is_none()); + assert!(Parser::new("=3").parse().is_none()); + assert!(Parser::new("\"\"|=3").parse().is_none()); + assert!(Parser::new("\"\n\"|=3").parse().is_none()); + assert!(Parser::new("\"\r\"|=3").parse().is_none()); + } + + #[test] + fn bad_table_names() { + assert!(Parser::new("[]").parse().is_none()); + assert!(Parser::new("[.]").parse().is_none()); + assert!(Parser::new("[\"\".\"\"]").parse().is_none()); + assert!(Parser::new("[a.]").parse().is_none()); + assert!(Parser::new("[\"\"]").parse().is_none()); + assert!(Parser::new("[!]").parse().is_none()); + assert!(Parser::new("[\"\n\"]").parse().is_none()); + assert!(Parser::new("[a.b]\n[a.\"b\"]").parse().is_none()); + } + + #[test] + fn table_names() { + let mut p = Parser::new(" + [a.\"b\"] + [\"f f\"] + [\"f.f\"] + [\"\\\"\"] + "); + let table = Table(p.parse().unwrap()); + assert!(table.lookup("a.b").is_some()); + assert!(table.lookup("f f").is_some()); + assert!(table.lookup("\"").is_some()); + } + + #[test] + fn invalid_bare_numeral() { + assert!(Parser::new("4").parse().is_none()); + } + + #[test] + fn inline_tables() { + assert!(Parser::new("a = {}").parse().is_some()); + assert!(Parser::new("a = {b=1}").parse().is_some()); + assert!(Parser::new("a = { b = 1 }").parse().is_some()); + assert!(Parser::new("a = {a=1,b=2}").parse().is_some()); + assert!(Parser::new("a = {a=1,b=2,c={}}").parse().is_some()); + assert!(Parser::new("a = {a=1,}").parse().is_none()); + assert!(Parser::new("a = {,}").parse().is_none()); + assert!(Parser::new("a = {a=1,a=1}").parse().is_none()); + assert!(Parser::new("a = {\n}").parse().is_none()); + assert!(Parser::new("a = {").parse().is_none()); + assert!(Parser::new("a = {a=[\n]}").parse().is_some()); + assert!(Parser::new("a = {\"a\"=[\n]}").parse().is_some()); + assert!(Parser::new("a = [\n{},\n{},\n]").parse().is_some()); + } + + #[test] + fn number_underscores() { + macro_rules! t { + ($actual:expr, $expected:expr) => ({ + let f = format!("foo = {}", $actual); + let mut p = Parser::new(&f); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").and_then(|k| k.as_integer()), + Some($expected)); + }) + } + + t!("1_0", 10); + t!("1_0_0", 100); + t!("1_000", 1000); + t!("+1_000", 1000); + t!("-1_000", -1000); + } + + #[test] + fn bad_underscores() { + assert!(Parser::new("foo = 0_").parse().is_none()); + assert!(Parser::new("foo = 0__0").parse().is_none()); + assert!(Parser::new("foo = __0").parse().is_none()); + assert!(Parser::new("foo = 1_0_").parse().is_none()); + } + + #[test] + fn bad_unicode_codepoint() { + bad!("foo = \"\\uD800\"", "not a valid unicode codepoint"); + } + + #[test] + fn bad_strings() { + bad!("foo = \"\\uxx\"", "expected 4 hex digits"); + bad!("foo = \"\\u\"", "expected 4 hex digits"); + bad!("foo = \"\\", "unterminated"); + bad!("foo = '", "unterminated"); + } + + #[test] + fn empty_string() { + let mut p = Parser::new("foo = \"\""); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").unwrap().as_str(), Some("")); + } + + #[test] + fn booleans() { + let mut p = Parser::new("foo = true"); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").unwrap().as_bool(), Some(true)); + + let mut p = Parser::new("foo = false"); + let table = Table(p.parse().unwrap()); + assert_eq!(table.lookup("foo").unwrap().as_bool(), Some(false)); + + assert!(Parser::new("foo = true2").parse().is_none()); + assert!(Parser::new("foo = false2").parse().is_none()); + assert!(Parser::new("foo = t1").parse().is_none()); + assert!(Parser::new("foo = f2").parse().is_none()); + } + + #[test] + fn bad_nesting() { + bad!(" + a = [2] + [[a]] + b = 5 + ", "expected type `integer`, found type `table`"); + bad!(" + a = 1 + [a.b] + ", "key `a` was not previously a table"); + bad!(" + a = [] + [a.b] + ", "array `a` does not contain tables"); + bad!(" + a = [] + [[a.b]] + ", "array `a` does not contain tables"); + bad!(" + [a] + b = { c = 2, d = {} } + [a.b] + c = 2 + ", "duplicate key `c` in table"); + } + + #[test] + fn bad_table_redefine() { + bad!(" + [a] + foo=\"bar\" + [a.b] + foo=\"bar\" + [a] + ", "redefinition of table `a`"); + bad!(" + [a] + foo=\"bar\" + b = { foo = \"bar\" } + [a] + ", "redefinition of table `a`"); + bad!(" + [a] + b = {} + [a.b] + ", "redefinition of table `b`"); + + bad!(" + [a] + b = {} + [a] + ", "redefinition of table `a`"); + } +} diff --git a/deps/toml-0.1.21/tests/README.md b/deps/toml-0.1.21/tests/README.md new file mode 100644 index 000000000..ebbc01ccf --- /dev/null +++ b/deps/toml-0.1.21/tests/README.md @@ -0,0 +1 @@ +Tests are from https://github.com/BurntSushi/toml-test diff --git a/deps/toml-0.1.21/tests/invalid-encoder/array-mixed-types-ints-and-floats.json b/deps/toml-0.1.21/tests/invalid-encoder/array-mixed-types-ints-and-floats.json new file mode 100644 index 000000000..b7920a07f --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid-encoder/array-mixed-types-ints-and-floats.json @@ -0,0 +1,15 @@ +{ + "ints-and-floats": { + "type": "array", + "value": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "float", + "value": "1.0" + } + ] + } +} diff --git a/deps/toml-0.1.21/tests/invalid.rs b/deps/toml-0.1.21/tests/invalid.rs new file mode 100644 index 000000000..3df4d022b --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid.rs @@ -0,0 +1,78 @@ +extern crate toml; + +use toml::{Parser}; + +fn run(toml: &str) { + let mut p = Parser::new(toml); + let table = p.parse(); + assert!(table.is_none()); + assert!(p.errors.len() > 0); +} + +macro_rules! test( ($name:ident, $toml:expr) => ( + #[test] + fn $name() { run($toml); } +) ); + +test!(array_mixed_types_arrays_and_ints, + include_str!("invalid/array-mixed-types-arrays-and-ints.toml")); +test!(array_mixed_types_ints_and_floats, + include_str!("invalid/array-mixed-types-ints-and-floats.toml")); +test!(array_mixed_types_strings_and_ints, + include_str!("invalid/array-mixed-types-strings-and-ints.toml")); +test!(datetime_malformed_no_leads, + include_str!("invalid/datetime-malformed-no-leads.toml")); +test!(datetime_malformed_no_secs, + include_str!("invalid/datetime-malformed-no-secs.toml")); +test!(datetime_malformed_no_t, + include_str!("invalid/datetime-malformed-no-t.toml")); +test!(datetime_malformed_no_z, + include_str!("invalid/datetime-malformed-no-z.toml")); +test!(datetime_malformed_with_milli, + include_str!("invalid/datetime-malformed-with-milli.toml")); +test!(duplicate_keys, + include_str!("invalid/duplicate-keys.toml")); +test!(duplicate_key_table, + include_str!("invalid/duplicate-key-table.toml")); +test!(duplicate_tables, + include_str!("invalid/duplicate-tables.toml")); +test!(empty_implicit_table, + include_str!("invalid/empty-implicit-table.toml")); +test!(empty_table, + include_str!("invalid/empty-table.toml")); +test!(float_no_leading_zero, + include_str!("invalid/float-no-leading-zero.toml")); +test!(float_no_trailing_digits, + include_str!("invalid/float-no-trailing-digits.toml")); +test!(key_two_equals, + include_str!("invalid/key-two-equals.toml")); +test!(string_bad_byte_escape, + include_str!("invalid/string-bad-byte-escape.toml")); +test!(string_bad_escape, + include_str!("invalid/string-bad-escape.toml")); +test!(string_byte_escapes, + include_str!("invalid/string-byte-escapes.toml")); +test!(string_no_close, + include_str!("invalid/string-no-close.toml")); +test!(table_array_implicit, + include_str!("invalid/table-array-implicit.toml")); +test!(table_array_malformed_bracket, + include_str!("invalid/table-array-malformed-bracket.toml")); +test!(table_array_malformed_empty, + include_str!("invalid/table-array-malformed-empty.toml")); +test!(table_nested_brackets_close, + include_str!("invalid/table-nested-brackets-close.toml")); +test!(table_nested_brackets_open, + include_str!("invalid/table-nested-brackets-open.toml")); +test!(text_after_array_entries, + include_str!("invalid/text-after-array-entries.toml")); +test!(text_after_integer, + include_str!("invalid/text-after-integer.toml")); +test!(text_after_string, + include_str!("invalid/text-after-string.toml")); +test!(text_after_table, + include_str!("invalid/text-after-table.toml")); +test!(text_before_array_separator, + include_str!("invalid/text-before-array-separator.toml")); +test!(text_in_array, + include_str!("invalid/text-in-array.toml")); diff --git a/deps/toml-0.1.21/tests/invalid/array-mixed-types-arrays-and-ints.toml b/deps/toml-0.1.21/tests/invalid/array-mixed-types-arrays-and-ints.toml new file mode 100644 index 000000000..051ec7313 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/array-mixed-types-arrays-and-ints.toml @@ -0,0 +1 @@ +arrays-and-ints = [1, ["Arrays are not integers."]] diff --git a/deps/toml-0.1.21/tests/invalid/array-mixed-types-ints-and-floats.toml b/deps/toml-0.1.21/tests/invalid/array-mixed-types-ints-and-floats.toml new file mode 100644 index 000000000..51ebe80bd --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/array-mixed-types-ints-and-floats.toml @@ -0,0 +1 @@ +ints-and-floats = [1, 1.0] diff --git a/deps/toml-0.1.21/tests/invalid/array-mixed-types-strings-and-ints.toml b/deps/toml-0.1.21/tests/invalid/array-mixed-types-strings-and-ints.toml new file mode 100644 index 000000000..f34830805 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/array-mixed-types-strings-and-ints.toml @@ -0,0 +1 @@ +strings-and-ints = ["hi", 42] diff --git a/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-leads.toml b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-leads.toml new file mode 100644 index 000000000..123f173be --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-leads.toml @@ -0,0 +1 @@ +no-leads = 1987-7-05T17:45:00Z diff --git a/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-secs.toml b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-secs.toml new file mode 100644 index 000000000..ba9390076 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-secs.toml @@ -0,0 +1 @@ +no-secs = 1987-07-05T17:45Z diff --git a/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-t.toml b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-t.toml new file mode 100644 index 000000000..617e3c56d --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-t.toml @@ -0,0 +1 @@ +no-t = 1987-07-0517:45:00Z diff --git a/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-z.toml b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-z.toml new file mode 100644 index 000000000..cf66b1ea6 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/datetime-malformed-no-z.toml @@ -0,0 +1 @@ +no-z = 1987-07-05T17:45:00 diff --git a/deps/toml-0.1.21/tests/invalid/datetime-malformed-with-milli.toml b/deps/toml-0.1.21/tests/invalid/datetime-malformed-with-milli.toml new file mode 100644 index 000000000..eef792f34 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/datetime-malformed-with-milli.toml @@ -0,0 +1 @@ +with-milli = 1987-07-5T17:45:00.12Z diff --git a/deps/toml-0.1.21/tests/invalid/duplicate-key-table.toml b/deps/toml-0.1.21/tests/invalid/duplicate-key-table.toml new file mode 100644 index 000000000..cedf05fc5 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/duplicate-key-table.toml @@ -0,0 +1,5 @@ +[fruit] +type = "apple" + +[fruit.type] +apple = "yes" diff --git a/deps/toml-0.1.21/tests/invalid/duplicate-keys.toml b/deps/toml-0.1.21/tests/invalid/duplicate-keys.toml new file mode 100644 index 000000000..9b5aee0e5 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/duplicate-keys.toml @@ -0,0 +1,2 @@ +dupe = false +dupe = true diff --git a/deps/toml-0.1.21/tests/invalid/duplicate-tables.toml b/deps/toml-0.1.21/tests/invalid/duplicate-tables.toml new file mode 100644 index 000000000..8ddf49b4e --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/duplicate-tables.toml @@ -0,0 +1,2 @@ +[a] +[a] diff --git a/deps/toml-0.1.21/tests/invalid/empty-implicit-table.toml b/deps/toml-0.1.21/tests/invalid/empty-implicit-table.toml new file mode 100644 index 000000000..0cc36d0d2 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/empty-implicit-table.toml @@ -0,0 +1 @@ +[naughty..naughty] diff --git a/deps/toml-0.1.21/tests/invalid/empty-table.toml b/deps/toml-0.1.21/tests/invalid/empty-table.toml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/empty-table.toml @@ -0,0 +1 @@ +[] diff --git a/deps/toml-0.1.21/tests/invalid/float-no-leading-zero.toml b/deps/toml-0.1.21/tests/invalid/float-no-leading-zero.toml new file mode 100644 index 000000000..cab76bfd1 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/float-no-leading-zero.toml @@ -0,0 +1,2 @@ +answer = .12345 +neganswer = -.12345 diff --git a/deps/toml-0.1.21/tests/invalid/float-no-trailing-digits.toml b/deps/toml-0.1.21/tests/invalid/float-no-trailing-digits.toml new file mode 100644 index 000000000..cbff2d06f --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/float-no-trailing-digits.toml @@ -0,0 +1,2 @@ +answer = 1. +neganswer = -1. diff --git a/deps/toml-0.1.21/tests/invalid/key-two-equals.toml b/deps/toml-0.1.21/tests/invalid/key-two-equals.toml new file mode 100644 index 000000000..25a037894 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/key-two-equals.toml @@ -0,0 +1 @@ +key= = 1 diff --git a/deps/toml-0.1.21/tests/invalid/string-bad-byte-escape.toml b/deps/toml-0.1.21/tests/invalid/string-bad-byte-escape.toml new file mode 100644 index 000000000..4c7be59f4 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/string-bad-byte-escape.toml @@ -0,0 +1 @@ +naughty = "\xAg" diff --git a/deps/toml-0.1.21/tests/invalid/string-bad-escape.toml b/deps/toml-0.1.21/tests/invalid/string-bad-escape.toml new file mode 100644 index 000000000..60acb0ccc --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/string-bad-escape.toml @@ -0,0 +1 @@ +invalid-escape = "This string has a bad \a escape character." diff --git a/deps/toml-0.1.21/tests/invalid/string-byte-escapes.toml b/deps/toml-0.1.21/tests/invalid/string-byte-escapes.toml new file mode 100644 index 000000000..e94452a8d --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/string-byte-escapes.toml @@ -0,0 +1 @@ +answer = "\x33" diff --git a/deps/toml-0.1.21/tests/invalid/string-no-close.toml b/deps/toml-0.1.21/tests/invalid/string-no-close.toml new file mode 100644 index 000000000..0c292fcab --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/string-no-close.toml @@ -0,0 +1 @@ +no-ending-quote = "One time, at band camp diff --git a/deps/toml-0.1.21/tests/invalid/table-array-implicit.toml b/deps/toml-0.1.21/tests/invalid/table-array-implicit.toml new file mode 100644 index 000000000..05f2507ec --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/table-array-implicit.toml @@ -0,0 +1,14 @@ +# This test is a bit tricky. It should fail because the first use of +# `[[albums.songs]]` without first declaring `albums` implies that `albums` +# must be a table. The alternative would be quite weird. Namely, it wouldn't +# comply with the TOML spec: "Each double-bracketed sub-table will belong to +# the most *recently* defined table element *above* it." +# +# This is in contrast to the *valid* test, table-array-implicit where +# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared +# later. (Although, `[albums]` could be.) +[[albums.songs]] +name = "Glory Days" + +[[albums]] +name = "Born in the USA" diff --git a/deps/toml-0.1.21/tests/invalid/table-array-malformed-bracket.toml b/deps/toml-0.1.21/tests/invalid/table-array-malformed-bracket.toml new file mode 100644 index 000000000..39c73b05c --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/table-array-malformed-bracket.toml @@ -0,0 +1,2 @@ +[[albums] +name = "Born to Run" diff --git a/deps/toml-0.1.21/tests/invalid/table-array-malformed-empty.toml b/deps/toml-0.1.21/tests/invalid/table-array-malformed-empty.toml new file mode 100644 index 000000000..a470ca332 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/table-array-malformed-empty.toml @@ -0,0 +1,2 @@ +[[]] +name = "Born to Run" diff --git a/deps/toml-0.1.21/tests/invalid/table-nested-brackets-close.toml b/deps/toml-0.1.21/tests/invalid/table-nested-brackets-close.toml new file mode 100644 index 000000000..c8b5a6785 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/table-nested-brackets-close.toml @@ -0,0 +1,2 @@ +[a]b] +zyx = 42 diff --git a/deps/toml-0.1.21/tests/invalid/table-nested-brackets-open.toml b/deps/toml-0.1.21/tests/invalid/table-nested-brackets-open.toml new file mode 100644 index 000000000..246d7e91f --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/table-nested-brackets-open.toml @@ -0,0 +1,2 @@ +[a[b] +zyx = 42 diff --git a/deps/toml-0.1.21/tests/invalid/text-after-array-entries.toml b/deps/toml-0.1.21/tests/invalid/text-after-array-entries.toml new file mode 100644 index 000000000..1a7289074 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/text-after-array-entries.toml @@ -0,0 +1,4 @@ +array = [ + "Is there life after an array separator?", No + "Entry" +] diff --git a/deps/toml-0.1.21/tests/invalid/text-after-integer.toml b/deps/toml-0.1.21/tests/invalid/text-after-integer.toml new file mode 100644 index 000000000..42de7aff4 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/text-after-integer.toml @@ -0,0 +1 @@ +answer = 42 the ultimate answer? diff --git a/deps/toml-0.1.21/tests/invalid/text-after-string.toml b/deps/toml-0.1.21/tests/invalid/text-after-string.toml new file mode 100644 index 000000000..c92a6f11d --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/text-after-string.toml @@ -0,0 +1 @@ +string = "Is there life after strings?" No. diff --git a/deps/toml-0.1.21/tests/invalid/text-after-table.toml b/deps/toml-0.1.21/tests/invalid/text-after-table.toml new file mode 100644 index 000000000..87da9db26 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/text-after-table.toml @@ -0,0 +1 @@ +[error] this shouldn't be here diff --git a/deps/toml-0.1.21/tests/invalid/text-before-array-separator.toml b/deps/toml-0.1.21/tests/invalid/text-before-array-separator.toml new file mode 100644 index 000000000..9b06a3924 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/text-before-array-separator.toml @@ -0,0 +1,4 @@ +array = [ + "Is there life before an array separator?" No, + "Entry" +] diff --git a/deps/toml-0.1.21/tests/invalid/text-in-array.toml b/deps/toml-0.1.21/tests/invalid/text-in-array.toml new file mode 100644 index 000000000..a6a6c4207 --- /dev/null +++ b/deps/toml-0.1.21/tests/invalid/text-in-array.toml @@ -0,0 +1,5 @@ +array = [ + "Entry 1", + I don't belong, + "Entry 2", +] diff --git a/deps/toml-0.1.21/tests/valid.rs b/deps/toml-0.1.21/tests/valid.rs new file mode 100644 index 000000000..568518bb7 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid.rs @@ -0,0 +1,180 @@ +extern crate rustc_serialize; +extern crate toml; + +use std::collections::BTreeMap; +use rustc_serialize::json::Json; + +use toml::{Parser, Value}; +use toml::Value::{Table, Integer, Float, Boolean, Datetime, Array}; + +fn to_json(toml: Value) -> Json { + fn doit(s: &str, json: Json) -> Json { + let mut map = BTreeMap::new(); + map.insert(format!("{}", "type"), Json::String(format!("{}", s))); + map.insert(format!("{}", "value"), json); + Json::Object(map) + } + match toml { + Value::String(s) => doit("string", Json::String(s)), + Integer(i) => doit("integer", Json::String(format!("{}", i))), + Float(f) => doit("float", Json::String({ + let s = format!("{:.15}", f); + let s = format!("{}", s.trim_right_matches('0')); + if s.ends_with(".") {format!("{}0", s)} else {s} + })), + Boolean(b) => doit("bool", Json::String(format!("{}", b))), + Datetime(s) => doit("datetime", Json::String(s)), + Array(arr) => { + let is_table = match arr.first() { + Some(&Table(..)) => true, + _ => false, + }; + let json = Json::Array(arr.into_iter().map(to_json).collect()); + if is_table {json} else {doit("array", json)} + } + Table(table) => Json::Object(table.into_iter().map(|(k, v)| { + (k, to_json(v)) + }).collect()), + } +} + +fn run(toml: &str, json: &str) { + let mut p = Parser::new(toml); + let table = p.parse(); + assert!(p.errors.len() == 0, "had_errors: {:?}", + p.errors.iter().map(|e| { + (e.desc.clone(), &toml[e.lo - 5..e.hi + 5]) + }).collect::<Vec<(String, &str)>>()); + assert!(table.is_some()); + let toml = Table(table.unwrap()); + let toml_string = format!("{}", toml); + + let json = Json::from_str(json).unwrap(); + let toml_json = to_json(toml.clone()); + assert!(json == toml_json, + "expected\n{}\ngot\n{}\n", + json.pretty(), + toml_json.pretty()); + + let table2 = Parser::new(&toml_string).parse().unwrap(); + // floats are a little lossy + if table2.values().any(|v| v.as_float().is_some()) { return } + assert_eq!(toml, Table(table2)); +} + +macro_rules! test( ($name:ident, $toml:expr, $json:expr) => ( + #[test] + fn $name() { run($toml, $json); } +) ); + +test!(array_empty, + include_str!("valid/array-empty.toml"), + include_str!("valid/array-empty.json")); +test!(array_nospaces, + include_str!("valid/array-nospaces.toml"), + include_str!("valid/array-nospaces.json")); +test!(arrays_hetergeneous, + include_str!("valid/arrays-hetergeneous.toml"), + include_str!("valid/arrays-hetergeneous.json")); +test!(arrays, + include_str!("valid/arrays.toml"), + include_str!("valid/arrays.json")); +test!(arrays_nested, + include_str!("valid/arrays-nested.toml"), + include_str!("valid/arrays-nested.json")); +test!(empty, + include_str!("valid/empty.toml"), + include_str!("valid/empty.json")); +test!(bool, + include_str!("valid/bool.toml"), + include_str!("valid/bool.json")); +test!(datetime, + include_str!("valid/datetime.toml"), + include_str!("valid/datetime.json")); +test!(example, + include_str!("valid/example.toml"), + include_str!("valid/example.json")); +test!(float, + include_str!("valid/float.toml"), + include_str!("valid/float.json")); +test!(implicit_and_explicit_after, + include_str!("valid/implicit-and-explicit-after.toml"), + include_str!("valid/implicit-and-explicit-after.json")); +test!(implicit_and_explicit_before, + include_str!("valid/implicit-and-explicit-before.toml"), + include_str!("valid/implicit-and-explicit-before.json")); +test!(implicit_groups, + include_str!("valid/implicit-groups.toml"), + include_str!("valid/implicit-groups.json")); +test!(integer, + include_str!("valid/integer.toml"), + include_str!("valid/integer.json")); +test!(key_equals_nospace, + include_str!("valid/key-equals-nospace.toml"), + include_str!("valid/key-equals-nospace.json")); +test!(key_special_chars, + include_str!("valid/key-special-chars.toml"), + include_str!("valid/key-special-chars.json")); +test!(key_with_pound, + include_str!("valid/key-with-pound.toml"), + include_str!("valid/key-with-pound.json")); +test!(long_float, + include_str!("valid/long-float.toml"), + include_str!("valid/long-float.json")); +test!(long_integer, + include_str!("valid/long-integer.toml"), + include_str!("valid/long-integer.json")); +test!(string_empty, + include_str!("valid/string-empty.toml"), + include_str!("valid/string-empty.json")); +test!(string_escapes, + include_str!("valid/string-escapes.toml"), + include_str!("valid/string-escapes.json")); +test!(string_simple, + include_str!("valid/string-simple.toml"), + include_str!("valid/string-simple.json")); +test!(string_with_pound, + include_str!("valid/string-with-pound.toml"), + include_str!("valid/string-with-pound.json")); +test!(table_array_implicit, + include_str!("valid/table-array-implicit.toml"), + include_str!("valid/table-array-implicit.json")); +test!(table_array_many, + include_str!("valid/table-array-many.toml"), + include_str!("valid/table-array-many.json")); +test!(table_array_nest, + include_str!("valid/table-array-nest.toml"), + include_str!("valid/table-array-nest.json")); +test!(table_array_one, + include_str!("valid/table-array-one.toml"), + include_str!("valid/table-array-one.json")); +test!(table_empty, + include_str!("valid/table-empty.toml"), + include_str!("valid/table-empty.json")); +test!(table_sub_empty, + include_str!("valid/table-sub-empty.toml"), + include_str!("valid/table-sub-empty.json")); +test!(table_whitespace, + include_str!("valid/table-whitespace.toml"), + include_str!("valid/table-whitespace.json")); +test!(table_with_pound, + include_str!("valid/table-with-pound.toml"), + include_str!("valid/table-with-pound.json")); +test!(unicode_escape, + include_str!("valid/unicode-escape.toml"), + include_str!("valid/unicode-escape.json")); +test!(unicode_literal, + include_str!("valid/unicode-literal.toml"), + include_str!("valid/unicode-literal.json")); +test!(hard_example, + include_str!("valid/hard_example.toml"), + include_str!("valid/hard_example.json")); +test!(example2, + include_str!("valid/example2.toml"), + include_str!("valid/example2.json")); +test!(example3, + include_str!("valid/example-v0.3.0.toml"), + include_str!("valid/example-v0.3.0.json")); +test!(example4, + include_str!("valid/example-v0.4.0.toml"), + include_str!("valid/example-v0.4.0.json")); diff --git a/deps/toml-0.1.21/tests/valid/array-empty.json b/deps/toml-0.1.21/tests/valid/array-empty.json new file mode 100644 index 000000000..2fbf2567f --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/array-empty.json @@ -0,0 +1,11 @@ +{ + "thevoid": { "type": "array", "value": [ + {"type": "array", "value": [ + {"type": "array", "value": [ + {"type": "array", "value": [ + {"type": "array", "value": []} + ]} + ]} + ]} + ]} +} diff --git a/deps/toml-0.1.21/tests/valid/array-empty.toml b/deps/toml-0.1.21/tests/valid/array-empty.toml new file mode 100644 index 000000000..fa58dc63d --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/array-empty.toml @@ -0,0 +1 @@ +thevoid = [[[[[]]]]] diff --git a/deps/toml-0.1.21/tests/valid/array-nospaces.json b/deps/toml-0.1.21/tests/valid/array-nospaces.json new file mode 100644 index 000000000..1833d61c5 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/array-nospaces.json @@ -0,0 +1,10 @@ +{ + "ints": { + "type": "array", + "value": [ + {"type": "integer", "value": "1"}, + {"type": "integer", "value": "2"}, + {"type": "integer", "value": "3"} + ] + } +} diff --git a/deps/toml-0.1.21/tests/valid/array-nospaces.toml b/deps/toml-0.1.21/tests/valid/array-nospaces.toml new file mode 100644 index 000000000..66189367f --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/array-nospaces.toml @@ -0,0 +1 @@ +ints = [1,2,3] diff --git a/deps/toml-0.1.21/tests/valid/arrays-hetergeneous.json b/deps/toml-0.1.21/tests/valid/arrays-hetergeneous.json new file mode 100644 index 000000000..e70373929 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/arrays-hetergeneous.json @@ -0,0 +1,19 @@ +{ + "mixed": { + "type": "array", + "value": [ + {"type": "array", "value": [ + {"type": "integer", "value": "1"}, + {"type": "integer", "value": "2"} + ]}, + {"type": "array", "value": [ + {"type": "string", "value": "a"}, + {"type": "string", "value": "b"} + ]}, + {"type": "array", "value": [ + {"type": "float", "value": "1.0"}, + {"type": "float", "value": "2.0"} + ]} + ] + } +} diff --git a/deps/toml-0.1.21/tests/valid/arrays-hetergeneous.toml b/deps/toml-0.1.21/tests/valid/arrays-hetergeneous.toml new file mode 100644 index 000000000..91fcbdfe7 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/arrays-hetergeneous.toml @@ -0,0 +1 @@ +mixed = [[1, 2], ["a", "b"], [1.0, 2.0]] diff --git a/deps/toml-0.1.21/tests/valid/arrays-nested.json b/deps/toml-0.1.21/tests/valid/arrays-nested.json new file mode 100644 index 000000000..d21920cc3 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/arrays-nested.json @@ -0,0 +1,13 @@ +{ + "nest": { + "type": "array", + "value": [ + {"type": "array", "value": [ + {"type": "string", "value": "a"} + ]}, + {"type": "array", "value": [ + {"type": "string", "value": "b"} + ]} + ] + } +} diff --git a/deps/toml-0.1.21/tests/valid/arrays-nested.toml b/deps/toml-0.1.21/tests/valid/arrays-nested.toml new file mode 100644 index 000000000..ce3302249 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/arrays-nested.toml @@ -0,0 +1 @@ +nest = [["a"], ["b"]] diff --git a/deps/toml-0.1.21/tests/valid/arrays.json b/deps/toml-0.1.21/tests/valid/arrays.json new file mode 100644 index 000000000..4d16d8ae1 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/arrays.json @@ -0,0 +1,34 @@ +{ + "ints": { + "type": "array", + "value": [ + {"type": "integer", "value": "1"}, + {"type": "integer", "value": "2"}, + {"type": "integer", "value": "3"} + ] + }, + "floats": { + "type": "array", + "value": [ + {"type": "float", "value": "1.0"}, + {"type": "float", "value": "2.0"}, + {"type": "float", "value": "3.0"} + ] + }, + "strings": { + "type": "array", + "value": [ + {"type": "string", "value": "a"}, + {"type": "string", "value": "b"}, + {"type": "string", "value": "c"} + ] + }, + "dates": { + "type": "array", + "value": [ + {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, + {"type": "datetime", "value": "1979-05-27T07:32:00Z"}, + {"type": "datetime", "value": "2006-06-01T11:00:00Z"} + ] + } +} diff --git a/deps/toml-0.1.21/tests/valid/arrays.toml b/deps/toml-0.1.21/tests/valid/arrays.toml new file mode 100644 index 000000000..6d6440d47 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/arrays.toml @@ -0,0 +1,9 @@ +ints = [1, 2, 3] +floats = [1.0, 2.0, 3.0] +strings = ["a", "b", "c"] +dates = [ + 1987-07-05T17:45:00Z, + 1979-05-27T07:32:00Z, + 2006-06-01T11:00:00Z, +] + diff --git a/deps/toml-0.1.21/tests/valid/bool.json b/deps/toml-0.1.21/tests/valid/bool.json new file mode 100644 index 000000000..ae368e949 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/bool.json @@ -0,0 +1,4 @@ +{ + "f": {"type": "bool", "value": "false"}, + "t": {"type": "bool", "value": "true"} +} diff --git a/deps/toml-0.1.21/tests/valid/bool.toml b/deps/toml-0.1.21/tests/valid/bool.toml new file mode 100644 index 000000000..a8a829b34 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/bool.toml @@ -0,0 +1,2 @@ +t = true +f = false diff --git a/deps/toml-0.1.21/tests/valid/comments-everywhere.json b/deps/toml-0.1.21/tests/valid/comments-everywhere.json new file mode 100644 index 000000000..e69a2e958 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/comments-everywhere.json @@ -0,0 +1,12 @@ +{ + "group": { + "answer": {"type": "integer", "value": "42"}, + "more": { + "type": "array", + "value": [ + {"type": "integer", "value": "42"}, + {"type": "integer", "value": "42"} + ] + } + } +} diff --git a/deps/toml-0.1.21/tests/valid/comments-everywhere.toml b/deps/toml-0.1.21/tests/valid/comments-everywhere.toml new file mode 100644 index 000000000..3dca74cad --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/comments-everywhere.toml @@ -0,0 +1,24 @@ +# Top comment. + # Top comment. +# Top comment. + +# [no-extraneous-groups-please] + +[group] # Comment +answer = 42 # Comment +# no-extraneous-keys-please = 999 +# Inbetween comment. +more = [ # Comment + # What about multiple # comments? + # Can you handle it? + # + # Evil. +# Evil. + 42, 42, # Comments within arrays are fun. + # What about multiple # comments? + # Can you handle it? + # + # Evil. +# Evil. +# ] Did I fool you? +] # Hopefully not. diff --git a/deps/toml-0.1.21/tests/valid/datetime.json b/deps/toml-0.1.21/tests/valid/datetime.json new file mode 100644 index 000000000..2ca93ce96 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/datetime.json @@ -0,0 +1,3 @@ +{ + "bestdayever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"} +} diff --git a/deps/toml-0.1.21/tests/valid/datetime.toml b/deps/toml-0.1.21/tests/valid/datetime.toml new file mode 100644 index 000000000..2e993407d --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/datetime.toml @@ -0,0 +1 @@ +bestdayever = 1987-07-05T17:45:00Z diff --git a/deps/toml-0.1.21/tests/valid/empty.json b/deps/toml-0.1.21/tests/valid/empty.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/empty.json @@ -0,0 +1 @@ +{} diff --git a/deps/toml-0.1.21/tests/valid/empty.toml b/deps/toml-0.1.21/tests/valid/empty.toml new file mode 100644 index 000000000..e69de29bb diff --git a/deps/toml-0.1.21/tests/valid/example-v0.3.0.json b/deps/toml-0.1.21/tests/valid/example-v0.3.0.json new file mode 100644 index 000000000..1d9dcb581 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example-v0.3.0.json @@ -0,0 +1 @@ +{"Array":{"key1":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key2":{"type":"array","value":[{"type":"string","value":"red"},{"type":"string","value":"yellow"},{"type":"string","value":"green"}]},"key3":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"integer","value":"3"},{"type":"integer","value":"4"},{"type":"integer","value":"5"}]}]},"key4":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"string","value":"a"},{"type":"string","value":"b"},{"type":"string","value":"c"}]}]},"key5":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key6":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}},"Booleans":{"False":{"type":"bool","value":"false"},"True":{"type":"bool","value":"true"}},"Datetime":{"key1":{"type":"datetime","value":"1979-05-27T07:32:00Z"}},"Float":{"both":{},"exponent":{},"fractional":{"key1":{"type":"float","value":"1.0"},"key2":{"type":"float","value":"3.1415"},"key3":{"type":"float","value":"-0.01"}}},"Integer":{"key1":{"type":"integer","value":"99"},"key2":{"type":"integer","value":"42"},"key3":{"type":"integer","value":"0"},"key4":{"type":"integer","value":"-17"}},"String":{"Literal":{"Multiline":{"lines":{"type":"string","value":"The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"},"regex2":{"type":"string","value":"I [dw]on't need \\d{2} apples"}},"quoted":{"type":"string","value":"Tom \"Dubs\" Preston-Werner"},"regex":{"type":"string","value":"\u003c\\i\\c*\\s*\u003e"},"winpath":{"type":"string","value":"C:\\Users\\nodejs\\templates"},"winpath2":{"type":"string","value":"\\\\ServerX\\admin$\\system32\\"}},"Multiline":{"key1":{"type":"string","value":"One\nTwo"},"key2":{"type":"string","value":"One\nTwo"},"key3":{"type":"string","value":"One\nTwo"}},"Multilined":{"Singleline":{"key1":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key2":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key3":{"type":"string","value":"The quick brown fox jumps over the lazy dog."}}},"basic":{"type":"string","value":"I'm a string. \"You can quote me\". Name\u0009José\nLocation\u0009SF."}},"Table":{"key":{"type":"string","value":"value"}},"dog":{"tater":{"type":{"type":"string","value":"pug"}}},"fruit":[{"name":{"type":"string","value":"apple"},"physical":{"color":{"type":"string","value":"red"},"shape":{"type":"string","value":"round"}},"variety":[{"name":{"type":"string","value":"red delicious"}},{"name":{"type":"string","value":"granny smith"}}]},{"name":{"type":"string","value":"banana"},"variety":[{"name":{"type":"string","value":"plantain"}}]}],"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"x":{"y":{"z":{"w":{}}}}} diff --git a/deps/toml-0.1.21/tests/valid/example-v0.3.0.toml b/deps/toml-0.1.21/tests/valid/example-v0.3.0.toml new file mode 100644 index 000000000..76aacc31a --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example-v0.3.0.toml @@ -0,0 +1,182 @@ +# Comment +# I am a comment. Hear me roar. Roar. + +# Table +# Tables (also known as hash tables or dictionaries) are collections of key/value pairs. +# They appear in square brackets on a line by themselves. + +[Table] + +key = "value" # Yeah, you can do this. + +# Nested tables are denoted by table names with dots in them. Name your tables whatever crap you please, just don't use #, ., [ or ]. + +[dog.tater] +type = "pug" + +# You don't need to specify all the super-tables if you don't want to. TOML knows how to do it for you. + +# [x] you +# [x.y] don't +# [x.y.z] need these +[x.y.z.w] # for this to work + +# String +# There are four ways to express strings: basic, multi-line basic, literal, and multi-line literal. +# All strings must contain only valid UTF-8 characters. + +[String] +basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." + +[String.Multiline] + +# The following strings are byte-for-byte equivalent: +key1 = "One\nTwo" +key2 = """One\nTwo""" +key3 = """ +One +Two""" + +[String.Multilined.Singleline] + +# The following strings are byte-for-byte equivalent: +key1 = "The quick brown fox jumps over the lazy dog." + +key2 = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" + +key3 = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ + +[String.Literal] + +# What you see is what you get. +winpath = 'C:\Users\nodejs\templates' +winpath2 = '\\ServerX\admin$\system32\' +quoted = 'Tom "Dubs" Preston-Werner' +regex = '<\i\c*\s*>' + + +[String.Literal.Multiline] + +regex2 = '''I [dw]on't need \d{2} apples''' +lines = ''' +The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +''' + +# Integer +# Integers are whole numbers. Positive numbers may be prefixed with a plus sign. +# Negative numbers are prefixed with a minus sign. + +[Integer] +key1 = +99 +key2 = 42 +key3 = 0 +key4 = -17 + +# Float +# A float consists of an integer part (which may be prefixed with a plus or minus sign) +# followed by a fractional part and/or an exponent part. + +[Float.fractional] + +# fractional +key1 = +1.0 +key2 = 3.1415 +key3 = -0.01 + +[Float.exponent] + +# exponent +#key1 = 5e+22 +#key2 = 1e6 +#key3 = -2E-2 + +[Float.both] + +# both +#key = 6.626e-34 + +# Boolean +# Booleans are just the tokens you're used to. Always lowercase. + +[Booleans] +True = true +False = false + +# Datetime +# Datetimes are RFC 3339 dates. + +[Datetime] +key1 = 1979-05-27T07:32:00Z +#key2 = 1979-05-27T00:32:00-07:00 +#key3 = 1979-05-27T00:32:00.999999-07:00 + +# Array +# Arrays are square brackets with other primitives inside. Whitespace is ignored. Elements are separated by commas. Data types may not be mixed. + +[Array] +key1 = [ 1, 2, 3 ] +key2 = [ "red", "yellow", "green" ] +key3 = [ [ 1, 2 ], [3, 4, 5] ] +key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok + +#Arrays can also be multiline. So in addition to ignoring whitespace, arrays also ignore newlines between the brackets. +# Terminating commas are ok before the closing bracket. + +key5 = [ + 1, 2, 3 +] +key6 = [ + 1, + 2, # this is ok +] + +# Array of Tables +# These can be expressed by using a table name in double brackets. +# Each table with the same double bracketed name will be an element in the array. +# The tables are inserted in the order encountered. + +[[products]] +name = "Hammer" +sku = 738594937 + +[[products]] + +[[products]] +name = "Nail" +sku = 284758393 +color = "gray" + + +# You can create nested arrays of tables as well. + +[[fruit]] + name = "apple" + + [fruit.physical] + color = "red" + shape = "round" + + [[fruit.variety]] + name = "red delicious" + + [[fruit.variety]] + name = "granny smith" + +[[fruit]] + name = "banana" + + [[fruit.variety]] + name = "plantain" + diff --git a/deps/toml-0.1.21/tests/valid/example-v0.4.0.json b/deps/toml-0.1.21/tests/valid/example-v0.4.0.json new file mode 100644 index 000000000..d5cac343a --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example-v0.4.0.json @@ -0,0 +1 @@ +{"array":{"key1":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key2":{"type":"array","value":[{"type":"string","value":"red"},{"type":"string","value":"yellow"},{"type":"string","value":"green"}]},"key3":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"integer","value":"3"},{"type":"integer","value":"4"},{"type":"integer","value":"5"}]}]},"key4":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"string","value":"a"},{"type":"string","value":"b"},{"type":"string","value":"c"}]}]},"key5":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key6":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}},"boolean":{"False":{"type":"bool","value":"false"},"True":{"type":"bool","value":"true"}},"datetime":{},"float":{"both":{},"exponent":{},"fractional":{"key1":{"type":"float","value":"1.0"},"key2":{"type":"float","value":"3.1415"},"key3":{"type":"float","value":"-0.01"}},"underscores":{}},"fruit":[{"name":{"type":"string","value":"apple"},"physical":{"color":{"type":"string","value":"red"},"shape":{"type":"string","value":"round"}},"variety":[{"name":{"type":"string","value":"red delicious"}},{"name":{"type":"string","value":"granny smith"}}]},{"name":{"type":"string","value":"banana"},"variety":[{"name":{"type":"string","value":"plantain"}}]}],"integer":{"key1":{"type":"integer","value":"99"},"key2":{"type":"integer","value":"42"},"key3":{"type":"integer","value":"0"},"key4":{"type":"integer","value":"-17"},"underscores":{"key1":{"type":"integer","value":"1000"},"key2":{"type":"integer","value":"5349221"},"key3":{"type":"integer","value":"12345"}}},"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"string":{"basic":{"basic":{"type":"string","value":"I'm a string. \"You can quote me\". Name\u0009José\nLocation\u0009SF."}},"literal":{"multiline":{"lines":{"type":"string","value":"The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"},"regex2":{"type":"string","value":"I [dw]on't need \\d{2} apples"}},"quoted":{"type":"string","value":"Tom \"Dubs\" Preston-Werner"},"regex":{"type":"string","value":"\u003c\\i\\c*\\s*\u003e"},"winpath":{"type":"string","value":"C:\\Users\\nodejs\\templates"},"winpath2":{"type":"string","value":"\\\\ServerX\\admin$\\system32\\"}},"multiline":{"continued":{"key1":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key2":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key3":{"type":"string","value":"The quick brown fox jumps over the lazy dog."}},"key1":{"type":"string","value":"One\nTwo"},"key2":{"type":"string","value":"One\nTwo"},"key3":{"type":"string","value":"One\nTwo"}}},"table":{"inline":{"name":{"first":{"type":"string","value":"Tom"},"last":{"type":"string","value":"Preston-Werner"}},"point":{"x":{"type":"integer","value":"1"},"y":{"type":"integer","value":"2"}}},"key":{"type":"string","value":"value"},"subtable":{"key":{"type":"string","value":"another value"}}},"x":{"y":{"z":{"w":{}}}}} diff --git a/deps/toml-0.1.21/tests/valid/example-v0.4.0.toml b/deps/toml-0.1.21/tests/valid/example-v0.4.0.toml new file mode 100644 index 000000000..ffbcce0d9 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example-v0.4.0.toml @@ -0,0 +1,235 @@ +################################################################################ +## Comment + +# Speak your mind with the hash symbol. They go from the symbol to the end of +# the line. + + +################################################################################ +## Table + +# Tables (also known as hash tables or dictionaries) are collections of +# key/value pairs. They appear in square brackets on a line by themselves. + +[table] + +key = "value" # Yeah, you can do this. + +# Nested tables are denoted by table names with dots in them. Name your tables +# whatever crap you please, just don't use #, ., [ or ]. + +[table.subtable] + +key = "another value" + +# You don't need to specify all the super-tables if you don't want to. TOML +# knows how to do it for you. + +# [x] you +# [x.y] don't +# [x.y.z] need these +[x.y.z.w] # for this to work + + +################################################################################ +## Inline Table + +# Inline tables provide a more compact syntax for expressing tables. They are +# especially useful for grouped data that can otherwise quickly become verbose. +# Inline tables are enclosed in curly braces `{` and `}`. No newlines are +# allowed between the curly braces unless they are valid within a value. + +[table.inline] + +name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } + + +################################################################################ +## String + +# There are four ways to express strings: basic, multi-line basic, literal, and +# multi-line literal. All strings must contain only valid UTF-8 characters. + +[string.basic] + +basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." + +[string.multiline] + +# The following strings are byte-for-byte equivalent: +key1 = "One\nTwo" +key2 = """One\nTwo""" +key3 = """ +One +Two""" + +[string.multiline.continued] + +# The following strings are byte-for-byte equivalent: +key1 = "The quick brown fox jumps over the lazy dog." + +key2 = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" + +key3 = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ + +[string.literal] + +# What you see is what you get. +winpath = 'C:\Users\nodejs\templates' +winpath2 = '\\ServerX\admin$\system32\' +quoted = 'Tom "Dubs" Preston-Werner' +regex = '<\i\c*\s*>' + + +[string.literal.multiline] + +regex2 = '''I [dw]on't need \d{2} apples''' +lines = ''' +The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +''' + + +################################################################################ +## Integer + +# Integers are whole numbers. Positive numbers may be prefixed with a plus sign. +# Negative numbers are prefixed with a minus sign. + +[integer] + +key1 = +99 +key2 = 42 +key3 = 0 +key4 = -17 + +[integer.underscores] + +# For large numbers, you may use underscores to enhance readability. Each +# underscore must be surrounded by at least one digit. +key1 = 1_000 +key2 = 5_349_221 +key3 = 1_2_3_4_5 # valid but inadvisable + + +################################################################################ +## Float + +# A float consists of an integer part (which may be prefixed with a plus or +# minus sign) followed by a fractional part and/or an exponent part. + +[float.fractional] + +key1 = +1.0 +key2 = 3.1415 +key3 = -0.01 + +[float.exponent] + +[float.both] + +[float.underscores] + + +################################################################################ +## Boolean + +# Booleans are just the tokens you're used to. Always lowercase. + +[boolean] + +True = true +False = false + + +################################################################################ +## Datetime + +# Datetimes are RFC 3339 dates. + +[datetime] + +#key1 = 1979-05-27T07:32:00Z +#key2 = 1979-05-27T00:32:00-07:00 +#key3 = 1979-05-27T00:32:00.999999-07:00 + + +################################################################################ +## Array + +# Arrays are square brackets with other primitives inside. Whitespace is +# ignored. Elements are separated by commas. Data types may not be mixed. + +[array] + +key1 = [ 1, 2, 3 ] +key2 = [ "red", "yellow", "green" ] +key3 = [ [ 1, 2 ], [3, 4, 5] ] +key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok + +# Arrays can also be multiline. So in addition to ignoring whitespace, arrays +# also ignore newlines between the brackets. Terminating commas are ok before +# the closing bracket. + +key5 = [ + 1, 2, 3 +] +key6 = [ + 1, + 2, # this is ok +] + + +################################################################################ +## Array of Tables + +# These can be expressed by using a table name in double brackets. Each table +# with the same double bracketed name will be an element in the array. The +# tables are inserted in the order encountered. + +[[products]] + +name = "Hammer" +sku = 738594937 + +[[products]] + +[[products]] + +name = "Nail" +sku = 284758393 +color = "gray" + + +# You can create nested arrays of tables as well. + +[[fruit]] + name = "apple" + + [fruit.physical] + color = "red" + shape = "round" + + [[fruit.variety]] + name = "red delicious" + + [[fruit.variety]] + name = "granny smith" + +[[fruit]] + name = "banana" + + [[fruit.variety]] + name = "plantain" diff --git a/deps/toml-0.1.21/tests/valid/example.json b/deps/toml-0.1.21/tests/valid/example.json new file mode 100644 index 000000000..48aa90784 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example.json @@ -0,0 +1,14 @@ +{ + "best-day-ever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, + "numtheory": { + "boring": {"type": "bool", "value": "false"}, + "perfection": { + "type": "array", + "value": [ + {"type": "integer", "value": "6"}, + {"type": "integer", "value": "28"}, + {"type": "integer", "value": "496"} + ] + } + } +} diff --git a/deps/toml-0.1.21/tests/valid/example.toml b/deps/toml-0.1.21/tests/valid/example.toml new file mode 100644 index 000000000..8cb02e01b --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example.toml @@ -0,0 +1,5 @@ +best-day-ever = 1987-07-05T17:45:00Z + +[numtheory] +boring = false +perfection = [6, 28, 496] diff --git a/deps/toml-0.1.21/tests/valid/example2.json b/deps/toml-0.1.21/tests/valid/example2.json new file mode 100644 index 000000000..3249a974f --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example2.json @@ -0,0 +1 @@ +{"clients":{"data":{"type":"array","value":[{"type":"array","value":[{"type":"string","value":"gamma"},{"type":"string","value":"delta"}]},{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}]},"hosts":{"type":"array","value":[{"type":"string","value":"alpha"},{"type":"string","value":"omega"}]}},"database":{"connection_max":{"type":"integer","value":"5000"},"enabled":{"type":"bool","value":"true"},"ports":{"type":"array","value":[{"type":"integer","value":"8001"},{"type":"integer","value":"8001"},{"type":"integer","value":"8002"}]},"server":{"type":"string","value":"192.168.1.1"}},"owner":{"bio":{"type":"string","value":"GitHub Cofounder \u0026 CEO\nLikes tater tots and beer."},"dob":{"type":"datetime","value":"1979-05-27T07:32:00Z"},"name":{"type":"string","value":"Tom Preston-Werner"},"organization":{"type":"string","value":"GitHub"}},"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"servers":{"alpha":{"dc":{"type":"string","value":"eqdc10"},"ip":{"type":"string","value":"10.0.0.1"}},"beta":{"country":{"type":"string","value":"中国"},"dc":{"type":"string","value":"eqdc10"},"ip":{"type":"string","value":"10.0.0.2"}}},"title":{"type":"string","value":"TOML Example"}} diff --git a/deps/toml-0.1.21/tests/valid/example2.toml b/deps/toml-0.1.21/tests/valid/example2.toml new file mode 100644 index 000000000..bc12c9901 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/example2.toml @@ -0,0 +1,47 @@ +# This is a TOML document. Boom. + +title = "TOML Example" + +[owner] +name = "Tom Preston-Werner" +organization = "GitHub" +bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." +dob = 1979-05-27T07:32:00Z # First class dates? Why not? + +[database] +server = "192.168.1.1" +ports = [ 8001, 8001, 8002 ] +connection_max = 5000 +enabled = true + +[servers] + + # You can indent as you please. Tabs or spaces. TOML don't care. + [servers.alpha] + ip = "10.0.0.1" + dc = "eqdc10" + + [servers.beta] + ip = "10.0.0.2" + dc = "eqdc10" + country = "中国" # This should be parsed as UTF-8 + +[clients] +data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it + +# Line breaks are OK when inside arrays +hosts = [ + "alpha", + "omega" +] + +# Products + + [[products]] + name = "Hammer" + sku = 738594937 + + [[products]] + name = "Nail" + sku = 284758393 + color = "gray" diff --git a/deps/toml-0.1.21/tests/valid/float.json b/deps/toml-0.1.21/tests/valid/float.json new file mode 100644 index 000000000..b8a2e9758 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/float.json @@ -0,0 +1,4 @@ +{ + "pi": {"type": "float", "value": "3.14"}, + "negpi": {"type": "float", "value": "-3.14"} +} diff --git a/deps/toml-0.1.21/tests/valid/float.toml b/deps/toml-0.1.21/tests/valid/float.toml new file mode 100644 index 000000000..7c528d200 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/float.toml @@ -0,0 +1,2 @@ +pi = 3.14 +negpi = -3.14 diff --git a/deps/toml-0.1.21/tests/valid/hard_example.json b/deps/toml-0.1.21/tests/valid/hard_example.json new file mode 100644 index 000000000..9762e58ef --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/hard_example.json @@ -0,0 +1 @@ +{"the":{"hard":{"another_test_string":{"type":"string","value":" Same thing, but with a string #"},"bit#":{"multi_line_array":{"type":"array","value":[{"type":"string","value":"]"}]},"what?":{"type":"string","value":"You don't think some user won't do that?"}},"harder_test_string":{"type":"string","value":" And when \"'s are in the string, along with # \""},"test_array":{"type":"array","value":[{"type":"string","value":"] "},{"type":"string","value":" # "}]},"test_array2":{"type":"array","value":[{"type":"string","value":"Test #11 ]proved that"},{"type":"string","value":"Experiment #9 was a success"}]}},"test_string":{"type":"string","value":"You'll hate me after this - #"}}} diff --git a/deps/toml-0.1.21/tests/valid/hard_example.toml b/deps/toml-0.1.21/tests/valid/hard_example.toml new file mode 100644 index 000000000..38856c873 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/hard_example.toml @@ -0,0 +1,33 @@ +# Test file for TOML +# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate +# This part you'll really hate + +[the] +test_string = "You'll hate me after this - #" # " Annoying, isn't it? + + [the.hard] + test_array = [ "] ", " # "] # ] There you go, parse this! + test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] + # You didn't think it'd as easy as chucking out the last #, did you? + another_test_string = " Same thing, but with a string #" + harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" + # Things will get harder + + [the.hard."bit#"] + "what?" = "You don't think some user won't do that?" + multi_line_array = [ + "]", + # ] Oh yes I did + ] + +# Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test + +#[error] if you didn't catch this, your parser is broken +#string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this +#array = [ +# "This might most likely happen in multiline arrays", +# Like here, +# "or here, +# and here" +# ] End of array comment, forgot the # +#number = 3.14 pi <--again forgot the # diff --git a/deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.json b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.json new file mode 100644 index 000000000..374bd0934 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.json @@ -0,0 +1,10 @@ +{ + "a": { + "better": {"type": "integer", "value": "43"}, + "b": { + "c": { + "answer": {"type": "integer", "value": "42"} + } + } + } +} diff --git a/deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.toml b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.toml new file mode 100644 index 000000000..c0e8865b3 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-after.toml @@ -0,0 +1,5 @@ +[a.b.c] +answer = 42 + +[a] +better = 43 diff --git a/deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.json b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.json new file mode 100644 index 000000000..374bd0934 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.json @@ -0,0 +1,10 @@ +{ + "a": { + "better": {"type": "integer", "value": "43"}, + "b": { + "c": { + "answer": {"type": "integer", "value": "42"} + } + } + } +} diff --git a/deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.toml b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.toml new file mode 100644 index 000000000..eee68ff51 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/implicit-and-explicit-before.toml @@ -0,0 +1,5 @@ +[a] +better = 43 + +[a.b.c] +answer = 42 diff --git a/deps/toml-0.1.21/tests/valid/implicit-groups.json b/deps/toml-0.1.21/tests/valid/implicit-groups.json new file mode 100644 index 000000000..fbae7fc71 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/implicit-groups.json @@ -0,0 +1,9 @@ +{ + "a": { + "b": { + "c": { + "answer": {"type": "integer", "value": "42"} + } + } + } +} diff --git a/deps/toml-0.1.21/tests/valid/implicit-groups.toml b/deps/toml-0.1.21/tests/valid/implicit-groups.toml new file mode 100644 index 000000000..b6333e49d --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/implicit-groups.toml @@ -0,0 +1,2 @@ +[a.b.c] +answer = 42 diff --git a/deps/toml-0.1.21/tests/valid/integer.json b/deps/toml-0.1.21/tests/valid/integer.json new file mode 100644 index 000000000..61985a1e9 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/integer.json @@ -0,0 +1,4 @@ +{ + "answer": {"type": "integer", "value": "42"}, + "neganswer": {"type": "integer", "value": "-42"} +} diff --git a/deps/toml-0.1.21/tests/valid/integer.toml b/deps/toml-0.1.21/tests/valid/integer.toml new file mode 100644 index 000000000..c4f62972c --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/integer.toml @@ -0,0 +1,2 @@ +answer = 42 +neganswer = -42 diff --git a/deps/toml-0.1.21/tests/valid/key-equals-nospace.json b/deps/toml-0.1.21/tests/valid/key-equals-nospace.json new file mode 100644 index 000000000..1f8709ab9 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/key-equals-nospace.json @@ -0,0 +1,3 @@ +{ + "answer": {"type": "integer", "value": "42"} +} diff --git a/deps/toml-0.1.21/tests/valid/key-equals-nospace.toml b/deps/toml-0.1.21/tests/valid/key-equals-nospace.toml new file mode 100644 index 000000000..560901c5a --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/key-equals-nospace.toml @@ -0,0 +1 @@ +answer=42 diff --git a/deps/toml-0.1.21/tests/valid/key-special-chars.json b/deps/toml-0.1.21/tests/valid/key-special-chars.json new file mode 100644 index 000000000..6550ebda2 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/key-special-chars.json @@ -0,0 +1,5 @@ +{ + "~!@#$^&*()_+-`1234567890[]\\|/?><.,;:'": { + "type": "integer", "value": "1" + } +} diff --git a/deps/toml-0.1.21/tests/valid/key-special-chars.toml b/deps/toml-0.1.21/tests/valid/key-special-chars.toml new file mode 100644 index 000000000..dc43625d2 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/key-special-chars.toml @@ -0,0 +1 @@ +"~!@#$^&*()_+-`1234567890[]\\|/?><.,;:'" = 1 diff --git a/deps/toml-0.1.21/tests/valid/key-with-pound.json b/deps/toml-0.1.21/tests/valid/key-with-pound.json new file mode 100644 index 000000000..ee39e1de4 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/key-with-pound.json @@ -0,0 +1,3 @@ +{ + "key#name": {"type": "integer", "value": "5"} +} diff --git a/deps/toml-0.1.21/tests/valid/key-with-pound.toml b/deps/toml-0.1.21/tests/valid/key-with-pound.toml new file mode 100644 index 000000000..65b766fd1 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/key-with-pound.toml @@ -0,0 +1 @@ +"key#name" = 5 diff --git a/deps/toml-0.1.21/tests/valid/long-float.json b/deps/toml-0.1.21/tests/valid/long-float.json new file mode 100644 index 000000000..8ceed4797 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/long-float.json @@ -0,0 +1,4 @@ +{ + "longpi": {"type": "float", "value": "3.141592653589793"}, + "neglongpi": {"type": "float", "value": "-3.141592653589793"} +} diff --git a/deps/toml-0.1.21/tests/valid/long-float.toml b/deps/toml-0.1.21/tests/valid/long-float.toml new file mode 100644 index 000000000..9558ae47c --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/long-float.toml @@ -0,0 +1,2 @@ +longpi = 3.141592653589793 +neglongpi = -3.141592653589793 diff --git a/deps/toml-0.1.21/tests/valid/long-integer.json b/deps/toml-0.1.21/tests/valid/long-integer.json new file mode 100644 index 000000000..16c331ed3 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/long-integer.json @@ -0,0 +1,4 @@ +{ + "answer": {"type": "integer", "value": "9223372036854775807"}, + "neganswer": {"type": "integer", "value": "-9223372036854775808"} +} diff --git a/deps/toml-0.1.21/tests/valid/long-integer.toml b/deps/toml-0.1.21/tests/valid/long-integer.toml new file mode 100644 index 000000000..424a13ac2 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/long-integer.toml @@ -0,0 +1,2 @@ +answer = 9223372036854775807 +neganswer = -9223372036854775808 diff --git a/deps/toml-0.1.21/tests/valid/string-empty.json b/deps/toml-0.1.21/tests/valid/string-empty.json new file mode 100644 index 000000000..6c26d695b --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-empty.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "string", + "value": "" + } +} diff --git a/deps/toml-0.1.21/tests/valid/string-empty.toml b/deps/toml-0.1.21/tests/valid/string-empty.toml new file mode 100644 index 000000000..e37e6815b --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-empty.toml @@ -0,0 +1 @@ +answer = "" diff --git a/deps/toml-0.1.21/tests/valid/string-escapes.json b/deps/toml-0.1.21/tests/valid/string-escapes.json new file mode 100644 index 000000000..ca71d3055 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-escapes.json @@ -0,0 +1,34 @@ +{ + "backspace": { + "type": "string", + "value": "This string has a \u0008 backspace character." + }, + "tab": { + "type": "string", + "value": "This string has a \u0009 tab character." + }, + "newline": { + "type": "string", + "value": "This string has a \u000A new line character." + }, + "formfeed": { + "type": "string", + "value": "This string has a \u000C form feed character." + }, + "carriage": { + "type": "string", + "value": "This string has a \u000D carriage return character." + }, + "quote": { + "type": "string", + "value": "This string has a \u0022 quote character." + }, + "slash": { + "type": "string", + "value": "This string has a \u002F slash character." + }, + "backslash": { + "type": "string", + "value": "This string has a \u005C backslash character." + } +} diff --git a/deps/toml-0.1.21/tests/valid/string-escapes.toml b/deps/toml-0.1.21/tests/valid/string-escapes.toml new file mode 100644 index 000000000..9f9a8c09c --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-escapes.toml @@ -0,0 +1,8 @@ +backspace = "This string has a \b backspace character." +tab = "This string has a \t tab character." +newline = "This string has a \n new line character." +formfeed = "This string has a \f form feed character." +carriage = "This string has a \r carriage return character." +quote = "This string has a \" quote character." +slash = "This string has a / slash character." +backslash = "This string has a \\ backslash character." diff --git a/deps/toml-0.1.21/tests/valid/string-simple.json b/deps/toml-0.1.21/tests/valid/string-simple.json new file mode 100644 index 000000000..2e05f99b4 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-simple.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "string", + "value": "You are not drinking enough whisky." + } +} diff --git a/deps/toml-0.1.21/tests/valid/string-simple.toml b/deps/toml-0.1.21/tests/valid/string-simple.toml new file mode 100644 index 000000000..e17ade623 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-simple.toml @@ -0,0 +1 @@ +answer = "You are not drinking enough whisky." diff --git a/deps/toml-0.1.21/tests/valid/string-with-pound.json b/deps/toml-0.1.21/tests/valid/string-with-pound.json new file mode 100644 index 000000000..33cdc9c4b --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-with-pound.json @@ -0,0 +1,7 @@ +{ + "pound": {"type": "string", "value": "We see no # comments here."}, + "poundcomment": { + "type": "string", + "value": "But there are # some comments here." + } +} diff --git a/deps/toml-0.1.21/tests/valid/string-with-pound.toml b/deps/toml-0.1.21/tests/valid/string-with-pound.toml new file mode 100644 index 000000000..5fd87466d --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/string-with-pound.toml @@ -0,0 +1,2 @@ +pound = "We see no # comments here." +poundcomment = "But there are # some comments here." # Did I # mess you up? diff --git a/deps/toml-0.1.21/tests/valid/table-array-implicit.json b/deps/toml-0.1.21/tests/valid/table-array-implicit.json new file mode 100644 index 000000000..32e464012 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-implicit.json @@ -0,0 +1,7 @@ +{ + "albums": { + "songs": [ + {"name": {"type": "string", "value": "Glory Days"}} + ] + } +} diff --git a/deps/toml-0.1.21/tests/valid/table-array-implicit.toml b/deps/toml-0.1.21/tests/valid/table-array-implicit.toml new file mode 100644 index 000000000..3157ac981 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-implicit.toml @@ -0,0 +1,2 @@ +[[albums.songs]] +name = "Glory Days" diff --git a/deps/toml-0.1.21/tests/valid/table-array-many.json b/deps/toml-0.1.21/tests/valid/table-array-many.json new file mode 100644 index 000000000..84df2dabb --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-many.json @@ -0,0 +1,16 @@ +{ + "people": [ + { + "first_name": {"type": "string", "value": "Bruce"}, + "last_name": {"type": "string", "value": "Springsteen"} + }, + { + "first_name": {"type": "string", "value": "Eric"}, + "last_name": {"type": "string", "value": "Clapton"} + }, + { + "first_name": {"type": "string", "value": "Bob"}, + "last_name": {"type": "string", "value": "Seger"} + } + ] +} diff --git a/deps/toml-0.1.21/tests/valid/table-array-many.toml b/deps/toml-0.1.21/tests/valid/table-array-many.toml new file mode 100644 index 000000000..46062beb8 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-many.toml @@ -0,0 +1,11 @@ +[[people]] +first_name = "Bruce" +last_name = "Springsteen" + +[[people]] +first_name = "Eric" +last_name = "Clapton" + +[[people]] +first_name = "Bob" +last_name = "Seger" diff --git a/deps/toml-0.1.21/tests/valid/table-array-nest.json b/deps/toml-0.1.21/tests/valid/table-array-nest.json new file mode 100644 index 000000000..c117afa40 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-nest.json @@ -0,0 +1,18 @@ +{ + "albums": [ + { + "name": {"type": "string", "value": "Born to Run"}, + "songs": [ + {"name": {"type": "string", "value": "Jungleland"}}, + {"name": {"type": "string", "value": "Meeting Across the River"}} + ] + }, + { + "name": {"type": "string", "value": "Born in the USA"}, + "songs": [ + {"name": {"type": "string", "value": "Glory Days"}}, + {"name": {"type": "string", "value": "Dancing in the Dark"}} + ] + } + ] +} diff --git a/deps/toml-0.1.21/tests/valid/table-array-nest.toml b/deps/toml-0.1.21/tests/valid/table-array-nest.toml new file mode 100644 index 000000000..d659a3d94 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-nest.toml @@ -0,0 +1,17 @@ +[[albums]] +name = "Born to Run" + + [[albums.songs]] + name = "Jungleland" + + [[albums.songs]] + name = "Meeting Across the River" + +[[albums]] +name = "Born in the USA" + + [[albums.songs]] + name = "Glory Days" + + [[albums.songs]] + name = "Dancing in the Dark" diff --git a/deps/toml-0.1.21/tests/valid/table-array-one.json b/deps/toml-0.1.21/tests/valid/table-array-one.json new file mode 100644 index 000000000..d75faaeb2 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-one.json @@ -0,0 +1,8 @@ +{ + "people": [ + { + "first_name": {"type": "string", "value": "Bruce"}, + "last_name": {"type": "string", "value": "Springsteen"} + } + ] +} diff --git a/deps/toml-0.1.21/tests/valid/table-array-one.toml b/deps/toml-0.1.21/tests/valid/table-array-one.toml new file mode 100644 index 000000000..cd7e1b690 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-array-one.toml @@ -0,0 +1,3 @@ +[[people]] +first_name = "Bruce" +last_name = "Springsteen" diff --git a/deps/toml-0.1.21/tests/valid/table-empty.json b/deps/toml-0.1.21/tests/valid/table-empty.json new file mode 100644 index 000000000..6f3873af6 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-empty.json @@ -0,0 +1,3 @@ +{ + "a": {} +} diff --git a/deps/toml-0.1.21/tests/valid/table-empty.toml b/deps/toml-0.1.21/tests/valid/table-empty.toml new file mode 100644 index 000000000..8bb6a0aa0 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-empty.toml @@ -0,0 +1 @@ +[a] diff --git a/deps/toml-0.1.21/tests/valid/table-sub-empty.json b/deps/toml-0.1.21/tests/valid/table-sub-empty.json new file mode 100644 index 000000000..97877708e --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-sub-empty.json @@ -0,0 +1,3 @@ +{ + "a": { "b": {} } +} diff --git a/deps/toml-0.1.21/tests/valid/table-sub-empty.toml b/deps/toml-0.1.21/tests/valid/table-sub-empty.toml new file mode 100644 index 000000000..70b7fe11c --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-sub-empty.toml @@ -0,0 +1,2 @@ +[a] +[a.b] diff --git a/deps/toml-0.1.21/tests/valid/table-whitespace.json b/deps/toml-0.1.21/tests/valid/table-whitespace.json new file mode 100644 index 000000000..3a73ec864 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-whitespace.json @@ -0,0 +1,3 @@ +{ + "valid key": {} +} diff --git a/deps/toml-0.1.21/tests/valid/table-whitespace.toml b/deps/toml-0.1.21/tests/valid/table-whitespace.toml new file mode 100644 index 000000000..daf881d13 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-whitespace.toml @@ -0,0 +1 @@ +["valid key"] diff --git a/deps/toml-0.1.21/tests/valid/table-with-pound.json b/deps/toml-0.1.21/tests/valid/table-with-pound.json new file mode 100644 index 000000000..5e594e419 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-with-pound.json @@ -0,0 +1,5 @@ +{ + "key#group": { + "answer": {"type": "integer", "value": "42"} + } +} diff --git a/deps/toml-0.1.21/tests/valid/table-with-pound.toml b/deps/toml-0.1.21/tests/valid/table-with-pound.toml new file mode 100644 index 000000000..33f2c4fd6 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/table-with-pound.toml @@ -0,0 +1,2 @@ +["key#group"] +answer = 42 diff --git a/deps/toml-0.1.21/tests/valid/unicode-escape.json b/deps/toml-0.1.21/tests/valid/unicode-escape.json new file mode 100644 index 000000000..deda62c44 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/unicode-escape.json @@ -0,0 +1,3 @@ +{ + "answer": {"type": "string", "value": "\u03B4"} +} diff --git a/deps/toml-0.1.21/tests/valid/unicode-escape.toml b/deps/toml-0.1.21/tests/valid/unicode-escape.toml new file mode 100644 index 000000000..057ce158b --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/unicode-escape.toml @@ -0,0 +1 @@ +answer = "\u03B4" diff --git a/deps/toml-0.1.21/tests/valid/unicode-literal.json b/deps/toml-0.1.21/tests/valid/unicode-literal.json new file mode 100644 index 000000000..00aa2f832 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/unicode-literal.json @@ -0,0 +1,3 @@ +{ + "answer": {"type": "string", "value": "δ"} +} diff --git a/deps/toml-0.1.21/tests/valid/unicode-literal.toml b/deps/toml-0.1.21/tests/valid/unicode-literal.toml new file mode 100644 index 000000000..c65723ca1 --- /dev/null +++ b/deps/toml-0.1.21/tests/valid/unicode-literal.toml @@ -0,0 +1 @@ +answer = "δ" diff --git a/deps/url-0.2.35/.gitignore b/deps/url-0.2.35/.gitignore new file mode 100644 index 000000000..7cbe84a5e --- /dev/null +++ b/deps/url-0.2.35/.gitignore @@ -0,0 +1,3 @@ +/target +/Cargo.lock +/.cargo/config diff --git a/deps/url-0.2.35/.travis.yml b/deps/url-0.2.35/.travis.yml new file mode 100644 index 000000000..7d4b7f8fc --- /dev/null +++ b/deps/url-0.2.35/.travis.yml @@ -0,0 +1,9 @@ +language: rust +rust: + - nightly + - beta + - stable +script: make test +after_success: [ $TRAVIS_RUST_VERSION == master ] && make upload-doc +env: + - secure: Q5eFkWSv20gCxMXrF1BPBSY67qAi9XYKsGHbOc6c1hOf933AX9Wr2CqL8mBhgAZfe4TWEnazjMNHmVIs75W+DPRkxVjImDmPLlQSDNuQFKBGATL5rnx7UzgT7t6CZhG+aPr50VVuC/3IL1+Ok85DjT/LnOKaao3r+Wd+HMFVViM= diff --git a/deps/url-0.2.35/Cargo.toml b/deps/url-0.2.35/Cargo.toml new file mode 100644 index 000000000..dd0a86380 --- /dev/null +++ b/deps/url-0.2.35/Cargo.toml @@ -0,0 +1,25 @@ +[package] + +name = "url" +version = "0.2.35" +authors = [ "Simon Sapin <simon.sapin@exyr.org>" ] + +description = "URL parser for Rust" +documentation = "http://servo.github.io/rust-url/url/index.html" +repository = "https://github.com/servo/rust-url" +readme = "README.md" +keywords = ["url", "parser"] +license = "MIT/Apache-2.0" + +[features] + +query_encoding = ["encoding"] + +[dependencies.encoding] + +version = "0.2" +optional = true + +[dependencies] +rustc-serialize = "0.3" +matches = "0.1" diff --git a/deps/url-0.2.35/LICENSE-APACHE b/deps/url-0.2.35/LICENSE-APACHE new file mode 100644 index 000000000..16fe87b06 --- /dev/null +++ b/deps/url-0.2.35/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/deps/url-0.2.35/LICENSE-MIT b/deps/url-0.2.35/LICENSE-MIT new file mode 100644 index 000000000..1da3a5f6d --- /dev/null +++ b/deps/url-0.2.35/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright (c) 2006-2009 Graydon Hoare +Copyright (c) 2009-2013 Mozilla Foundation + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/deps/url-0.2.35/Makefile b/deps/url-0.2.35/Makefile new file mode 100644 index 000000000..827cf175d --- /dev/null +++ b/deps/url-0.2.35/Makefile @@ -0,0 +1,17 @@ +test: + cargo test --features query_encoding + cargo test + +doc: + cargo doc --features query_encoding + @echo '<meta http-equiv=refresh content=0;url=url/index.html>' > target/doc/index.html + @cp github.png target/doc/ + +upload-doc: doc + test "$(TRAVIS_BRANCH)" = master + test "$(TRAVIS_PULL_REQUEST)" = false + sudo pip install ghp-import + ghp-import -n target/doc + git push -qf https://$(TOKEN)@github.com/$(TRAVIS_REPO_SLUG).git gh-pages + +.PHONY: test doc upload-doc diff --git a/deps/url-0.2.35/README.md b/deps/url-0.2.35/README.md new file mode 100644 index 000000000..9df514646 --- /dev/null +++ b/deps/url-0.2.35/README.md @@ -0,0 +1,24 @@ +rust-url +======== + +[![Travis build Status](https://travis-ci.org/servo/rust-url.svg?branch=master)](https://travis-ci.org/servo/rust-url) [![Appveyor build status](https://ci.appveyor.com/api/projects/status/ulkqx2xcemyod6xa?svg=true)](https://ci.appveyor.com/project/Manishearth/rust-url) + +Rust implementation of the [URL Standard](http://url.spec.whatwg.org/). + +[Documentation](http://servo.github.io/rust-url/url/index.html) + + +To do +----- + +Not necessarily in the given order: + +* Deprecate and later remove rustc’s old liburl +* Add `data:` URL parsing. +* Add [IDNA support](http://url.spec.whatwg.org/#idna). + Non-ASCII domains are a parse error for now. + [Punycode](http://tools.ietf.org/html/rfc3492) is done, + [Nameprep](http://tools.ietf.org/html/rfc3491) is the other big part. +* Add lots of tests. + Contribute them to [web-platform-tests](https://github.com/w3c/web-platform-tests/tree/master/url). +* Consider switching the spec from a state machine to functional style, like this code. diff --git a/deps/url-0.2.35/appveyor.yml b/deps/url-0.2.35/appveyor.yml new file mode 100644 index 000000000..5819d38b1 --- /dev/null +++ b/deps/url-0.2.35/appveyor.yml @@ -0,0 +1,13 @@ +install: + - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' + - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - rustc -V + - cargo -V + - git submodule update --init --recursive + +build: false + +test_script: + - cargo build + - cargo test --verbose diff --git a/deps/url-0.2.35/github.png b/deps/url-0.2.35/github.png new file mode 100644 index 0000000000000000000000000000000000000000..b2c327097e33667628759b5b8194cbe364f471fc GIT binary patch literal 7786 zcmV-w9+lyVP)<h;3K|Lk000e1NJLTq005N$005N;1^@s6QKGm{0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBV53`s;mRCwC#T?tfFXO_Mcn+q<08h5b@ zl(?d}#WgA<YSbhun4V73S+VDwnRL3RyJ5P|%$eykJq_LIbmExw6ah?POj@wBk4c0W zw?q>GcSR6n6-Bh%aKnOm-+fg@)#JUYf<h?Zzd7#|7A3x-zTD-z_kO=mV`C!;Ynk~- zX8qD~=`5G8bonVRf4(9pG;~eqdlQFG3=i}Rq~eRkbh`GmSG=ErK?7;t=y}vDpcfsj zK1zqr9R3r%LBEr}WtOf6%VVSEYqESTf1!dOKLL?@0w{ln%RmEZ32lrHiw+;ydmwE+ zvXyS%z3nyc>7g+X(U87F=*{omq#IXmyh?wiKiIv$7MlRoy#Z8!?NLty`>*c5(J<Ix z=o{FV4pbcQ8bF2i4y8#$CQ(SQ5c<04Yr0{&@j4kP#nYcFK-IQ@3a|rJ0F9<Wy5+jG z`D5oB%nfG#;I7=d;uY`5SLaKsCa$8p4R>kFp)F*pF})!H>J__}G}>JbA<vcR1YGV3 zpaL0CD|Bg5VNu}&dJmw3RR_s*(?ku84PF7L`TF@ZwC_;bRlJL8s%qY>|KIvoEIE@a zAh`sWk4V(p6i|Wubr=omAKyQHhGB*tf3fgFA(dV#^@{fs+%uS#-oKO+>_cY{(aD07 zM%qY!mcE6Ud`G(KE!SPUM7=@9b7>~(!c*M?K+y_%YtqO`dU%4}#k;)*P_PAt1*8wv z(<jG2p_3<1z9j+bbp?2|K;*Xf5jj;G11e-~NP5JO2z~#a{b^s>KDu@Hme<e*Q-)0; zgyL-{x6zGrH`3^BT5s`4ckMirSplfVmH<kC>K=HgIb-JN{dNAdy>L6#-Kq1M_w?xa zN6FvUpWe@ZpRQM5&yWE1KPsWltm3VxrQS+}zcvC?&s9A+DevE-KPTnaZ(k>G$X7vV zA}NQ5LQ;OE>PotKqj|k0f4XA_Dm7rW*h`5-y^R1Bv?eHR!Po_c`i6QsR(*`BuT^^m zp!x*%q1BUC(;f32+F!Px%1)PMSO9ffBQd{AjtsiXoJu6>_bB8|7%{;BM*91*@9FH- zv*a!Rqs|#Uhr&X_X#1({R8m-y-qwH;p6VU|YQPf%((fOBzdk4+h<kaU4!pqz1r4HE zqh=9`1@!U`9yyp!?{E&)=718tzc%(z)AiH!{d)GJkB@%rHB}yLN#qg=?G;L?`%|f| zy6&C<N>qPs2&lesebWtt4f?)4`chs+o+F@I@-g_d?fZdeiW(Zly}TW#cXSA#x^?(# zEuaD(3rJfsafzYcT+hwnOE)gbt(TS*-##j!@(^GFz5(>~w5K^K&o0cS+Va|r`i%N} zo<oU5y$wR%#E}yX$XW8M@~O72wmG00?TYaRyN^wcvu<b$zaZP((Q|2d|KYT=cqdh# zsZMV#pc>o2%XB+W)mlIWuMJM08a7prW-Ny5N-mZ-hCFANny1p)-GPsW_j1F)KP`$_ zM1DFyI&$_19Xo!k)gjLcsHR_$@KpEILrobqML(?HFeVTk0Ojx-Zt_sk!=sx#l(G@h zVE5RnMo5z_3|~lwPy>B*^rJQbR9l!%0LpbQPpb05QRRJK{(bWSJ0&Qjk1Sz!0_7&= zQo@`B+eaA_5krZwiF^eI1Z(rwjqZD>m@zRtX!q5rujuBvn_dB^Zd3hv;-Th_nXAWN z$ABGLFWPaS>B=k3Bhw8N8J{%rM_6*cgtC8`ZF_0L`~-?O##3Hpo@2;sbU*w(KJjsW z%siAy*Unzc@D@OIi=4`nDsS9~aR!v=D9_7H<=SAfdK;_vxhsdi?0?Co;NHQMcP5YY zgY>j6V;x10j;6%riDarXk>R%nGTkvX-Hnc1PKIM?V#dfB+|SE8oJEBNg>CMkL{4>& zc&J6=7IBrQ3Mgkuc|()8icN`S@Bm0T$8soZUlt|(Es0V-Phqen%u8?#cP{?_?$@Iq z#ZQi>;r)g)piZAUo$gH@s>_4Q!(JW_*zGIb*90gn04eDM%ayn^kv&xGf6Ks%n;Az5 zi)0XG{gA~!GG<&%i*hOS@-SfcMZp*Bp&H(9@H#+s*__IgUf!6YWAqrg{kHU5x_0|o za}Pz@-pK~2C5e<Am&^cI_trX!{e3KD|2CV9FBnOGpPnyR&WRkis04V-=_97|pxtLD zKBLQ(m%Y+Mb=jQC6A$&sq({OrfAsl@&*^6UP3>?;imI)_ktPW45lq>?%I2__`gJM; zD_S4Tz(UxA=gP{JLg7bAa!%!Icb6(T)icwdA+&@te#oHfXRqILK#82HjdG|dVN;kk z$gj+I4yZ;uhTKdJqix2gj9l57uA3+}IhMm;!r}xnzG#$ltYkS9mRu;Ib(_|a>6Xc9 zVvZaNGv%NScAnnZE`SoAsto|uV^xo|*zvL4%LAZntrv2VLrItMAB_Cmx_8#`W6b?A z?44i$PtMUC_Db3RYVla#NFM8L$zvI!sid}qOt($)9oc&*T@%21`uC(CPyI1Bt3kM) zD?OLdUac45sXPpM6Gu!m+!u5ob4E4SYa9VZ>LCuKBPus|C3q)%oH<8wm@;7Q=$|tw zW<m^mrKBxMGB>p_ffMz-@;n((zSO*3qe#lp%iB@3gDQ$EI<%M9?L3tyO!?$dll52z zK-;C6SVp4?2W8h{0jP}682P2CJ5nj@`z-cO01gszSjuN96f-e~^aJ&jv^9xR_og~> zQp!BaN8Wl_pkKgz6b9^$96QqPA<t7!)u}<{iHDLxUO1{MRk4glbq|FWOUnPH*ua&r zKmyS7M%!NleE>cRK+1e6lfxejfJ*r)r8$_CO=ZcRnDPXT>_3t=e7k{eRNv^39LiHr z`E@ryVcI|{>3P5|w=&leP>m`qxiyFSk(`9<Lu6(gA7g4xD#gu+V-Uf>MFCVf$8*T= zD+B)-`BToR9Qm$%HNfN}_wpc?fr-tWqMQx`RJRR(tp${BrS7felb44hZ`yliFI~NL zRXvANnTO)G%P(X~0O1Za0lZW~Oag~JE3o)`QbO(kA}8Svm(E8=&(D0G#WFx=T&}pB zQNOVR=b^e=qTX6S`9J2LCgo7!D9;a79iq!OFE<U?HM%A=nH{&ZU63~wzh2CMg0}*> zxh_pk(mAJk&gghoP5_0R4t>1AeFpQ2{DsmB=^Y8EZs(~y5zClqn5hSdu<=r6Ds#<{ z+h2BbP|+hLkM$ebV`2Kh@RGrH7tBdLC+Aq}-djhh-=;bR6qx%*#yvui8Nvc;!HI%& zdbi_4Ubpd79*zL(hxQxFA&&v2)xT2%6iCgdjWQ3Fn9Z+&XM)E<yTzDbwB1GO?o{Tj z@TdwX1${72KacnF(0cI}Ky@2W<w-9ud`P$+WjZ|6shU&T-pO(y5zkG^rJR#F6#r&C z#Y8rdn(Tq3Tneoh`?d=coA0RPQND^hw!8yWoygI!fC@RE{6qO(1*k6XsXXye4@5k` z(*__A9Tq)ZguCEg!R(pvJydfgHS+i{yc2ROnEeC-h)v_ODtVN~{Q2^6%h^ML&Ny`V zP?zygodQ&?1yrxqy=-C`@B~m_;orZrgxvBq`f`Tf7--smPUHLu(*~&MaB<s3@=owl zxEm<r#r{zS7T=w(MyRt~y#so4$b;uZQhv4aYI?&v4P6RQULF2C0o20Ch3aA%jq3SR z%-9%8ek@rgFkg-3hA^JT2yo2!7?~!Jsyi!N4iI6`4jwAyixkQ!ki6NY675P)vY;M8 zv}V#8LXYvgGv85pae0RMZL?Qad0mqH^t6|UT;=aa{?4AH8B<P<fMWjXXW2YcjszQ_ z&vebiuZe#np7SXlu0uX$p$!16<h3#g@ozW<l;xew4x3G*Lq^jZd*7g%vYIXz^1Rwp zc`BBH5QAQxs#u1~GH3Dcin%uj4+SP%85#jHRDC>Y0FSj%o{d7o82?Vz!7QhMLQ?)f z*aHN)Yj{o;%kXkQb*bK;Cm!nI2@i)uL*V0MA3M%NIRRC0U@%>J^%CWk<#7(BOyZGG zA<V&Sz}hJR>)myZ6`scU3Lc+~ev*M@{LUzA8*~B>)n%$bPl(N_qo?wKU2a9LHlS2K z5`;Wh^r&dL`D^zvCO(qLTQAv3*?c!h$T4UaH$6@s2X+CdklrEmpy5GTETd>grvX%# z34flnUY1T=YCz8ni=F_9rcSxqDwXt@{c<+b2PxZ9C@C|^!CPhiQzkczd1~{OSiUm= z3Q8}|0OjxJPd}OV6Hdy%D)@>nR$R>JOs$tr@2Oe~D4&%+kd-!Ah3_xcT~r5@3!MX0 zZ?ME=iIni5-O7}7CsvRl=RzpN_^$(?l)%D+&WFV^tSj>8O3!urUS6l-sXPgJi^nbI z=I}SCzoF`@)y_kn7B5BeMhmmysOp}Ps=D}O3Jwakc_kRPUpA{S<_aDvG$@qTMy=)M z@YcgyskErH+k`x?2!Ea=<qt+a7!F4IgM%MvA0DJN%A&Ea#{+jiF*Y&hQu2<yJcQI~ z|20jf4O|S^L9{h;U?lxz_h00Bs7?x~PFekVG6IZV9(bsNngY3(r}=I*0A*J3T$a}Z zL<obt<ViBS9-kU7hdd{M0z;1Vc<@jt7V;10cWMvS=|JU)hguo6G8_YK5X(U8#c5Km zF>HqhG1@P9K6O{Btpc>&5pt+OdRYUZJWo9tSFq(T%zS}-eSG;eDu`uxD^uPjLFLIB zRphWp!{nipdH>Be59JP^%#MJ<^rnqckiuN-pJO@HIZP5LLz~7tR1d!%ES7=9{KLZ^ zQb9r27+>i$plU6k`mE`bK5y(iJ!pdy=T1=7)hcbBa%EVv-+q}ZuT-Iu!?-V3bW&1o z16D;|bMUCC-C5p6-=2Nx@d=N!#^w)YKhT+?GhL=R+$nm0o(|X{hl0upX3AZ9DCH=N zSzbd=UY*P#4dNJBr?QftsQA!0j{QrltQVy<Wk8OPbHnCx4)yx(*U40A>XubrhfxZi z^z!D8nHvrn=RGBR+y|5ju+Sj3j;MglWIhU1!A^O&4*k94Rmo1rR&2ezJ`&c)t>EPR zlcS#qK&hCYw|Xedl=lwoO`jeAOuO~sET1yVy}h{TI38um+Mh+Se~9HZbe<#kk@+WF zxSOm)S?c+dy@!%)S>!T8ODJt$8r7Yv6M$+@p2}0<`^Z6&tW(}>bJ(30jCG~z<!swR zCnhzmqbt_M1)eA0o7zNbI$1^U7ub)YhDGtu%_+>0H;20@pu93sZ!Mq#9}i4>Xu?B= zyXL!`-#Cb6w4~ZYPw%B{ZWLow1x;WqcCsYm&kdv>tmml%EP5iBa*#+=Ny-C#1L>)0 zPtl#bcepuxzU+KPS8ly{UGL9R;d_W>U~||(EW@1~O3{J=feG>wiFy2nc-uH|@{f|4 ze?rB_fVyqcWXP@m77O3^lf^PBODelvFRw$xpC?Rt)Tk)EpRXSk*B0}MR8BpUtK{4| zeINk~o(kJ8u-xC}GL;bWQiysVPcaKMpw|G_DaR2V5WYWp>}Wb|>iRj9*H8+cc&MqP zr|O6F8A6$dGqrnpYCxjq9?JSWL@}Taj4c;l{FJ;F0L7AsYAqK9pzw1RM=WOAVEvx; zaxZU_NXpyIQ+XnmfutNNC&$kpcdwV{WD`dDeK6>m|JbCy0$vJZ!^}si%|qFFD6scq z29Du_A-R{=jR4i*iMpq~yhiDFZ{?xf&Y=`z!RX~#We=5MlBK2RC-9wR<z+RWHc;eI zcsuCj;rD`b{H|18$*6z3d*x6a3Mx+~HgQBOO7!eg*;IL@(!Kmig(*ib4^<v4>p&LI zkMkCdk2Zm+1t^GR%pNtH<{9SEmV;ZUsGz7@hP)2TsXXDKW=G7{LzDv32CW5@Rn5*y z8(=>VY&k+4L|Qec3N(6oVD7OwjQau++Fb$F7N%=YKq2Ho5)rHD&?$F%G>3**hP@gv zX3IJ3oiAZfVU|28D~Z)qY<H*AxO|!tav0=%pnLxLvCrw$$x{MQ?FlMRdU+2-JP-~U zX8`KPog40ZC^M<bOhe~@SJ9KQS?>V)QA{2DdoD$XMLYLSmUn?(-qOgWtYim3U8}w( z0Og_iwU>vQ6+TOk`6C>GfdRV~g*>Y^)bMDQ^+5xe^$jfYh}g%o3T5EWpbog=^U<IT z><l3f^3t0QY@+Mc*9D;3lTz?R+hFX_v4(N?jiY^K`?L>WBvPM;vOAfoI7Qwjwi+w1 z{63a4UzR1Nt%jT`^}AH{exBv+1_cDs)ZtTU)~H#u?Zh_u07e0*_N)F{3#gu}dZsNN zx0r?R51&2ky!E0aGVQ`0G^23d3r1FO3KjIBlAlOs<vIpdax8DY1osJM%7AGDKMkf_ zvflo^Y3-D?JYct{cn?}H8RmD)qV>{V)t@IJ4|{p{^|_CaV#TTG&hJjW1q0e3_uq1D z1SUcqpR|xJS9lQ5z&Hz*Jxym#&Bex)2Q)Uy!uKPCN77&S{uRw(;i1|yr}88z$MI$m zn8!k;1E3n+XUwBVMDyvM02EG6VA^1294{tdHVRY%?uzp$Y!0h2<#z92Q13y^LG|?O z$us5WOC><PCjixMIhChk8Cdj$oR6kXxf;L}`IJ?=92WA^5FWO}fE^#lfw1?dSl$|j z_j1~LvDlN-p5#T(4SP1wt#h{opzcxl)3qg_usJM!z~OxY`_O^%1KNO6>($xwQI^-T z!tXA5!T_`ZawhB40e}Rp1Kd$FK<OOA9ss^5ViEIK5Xu*TYUl9RT0r?e>igFGvGZ+A z`ITE&+zN53-plTJX2(h1AjV)Fyc1e609eYGDeCGg)bxmPnpKllQT^R|+LFHoGvyfq zQ0+*5dUBG2l$3{C#WK))bExt(CJds7MLV+OcjdWqdvAri0EpnRKxk(FTJl(ZgXPWP zsywHF!s6*%{agZr4~<PI*ww!y2JG4mRGx}uV7mlj8E3DabzR}%td}Q@^2qP-CSVzV zY~<uz2`bzL1TwIs0G`UG52e!v6m+5Dqv8p3T3ZiorINxD5%Ss-R36d>ddTKreC5og zGtL2J$3>w}$I^!{%fJE`g{0gDss_bf0$3lcquBMaO&-cu9Z)dz@(iH{`t<0hbo}^n z0jTx_l_w*>GYm7r0gU}+``ufkvirCY&Uohzy}Ms#GauEA09AM^T(*TzjWsHG%-Aup z{P^X`FXc5V0jTz^9!Y)D$fbu`5w#-RPv^($O4sjPcfE?PJnO}hN3n#@v$Bk|)i4)@ z6BlqfEGB3zC)k1Nxf#z<fL{RpE$?q=4riF(6-;?YPzo&;%Yg7b%5$7Xb?x@G=0Dik ziB#sMKj;2OuFQ_7$sWsk5<1#37z4hv{t{&-WXeN$Dia3wk2s}$-spJ*27mYI-E_I? za=HLi$59Gy11e}uP}=;l^I2mP>q-#I&?GUPcq)Xt%%5g*HOEK6ejv*rLZ2MK!Uzj0 zJTU0EJDYfh2B5%;F>PS3r_6(yES4ccUdM(%e{z3(C49o*2`rYuJX9mOX3Lc$EI2lH zNg^e$k;UypUJS8?K0ey)d1I3jOJ!bj9!imr<L5sd`7mphZ`i$oYAb35pu8abxh<A~ zkhkZ|9!EeqlRs3*`B<NWHo0{dk5|y4v8l5NW^9y0A^Lf)bPdqUTQPnGVF49Yo&c2h zc&c8mJk-*OOT%&I@TbQ=ZL0EIsQx;<#_j+{i~vK*r{r9TV;>KyEH~w(9J5ijbBDEn zCH>r|r$5bn6vQ%kz)k?lYdn<|Q2v%Hfb5nOri4vl;rsl`{N}WQO79Mgcw$Uq)5mD3 z@-S_HF<(eW7r#=>!uLqfF~NyG9$GMHy#PoKfKsXQa5~m}!+bu(dS}s20Vpp_)cqX5 z1TQ54D&Vnzv;~n1^bpHHFAqB9POCdh0&W$?;4rr>MPBNZyb~%qggkg992SHjI~b3z z;HX&X`|wZ>XT1=qie;>xyqbG?NXl!<YD6#33mJ7sFEyG5+KXl6SLM@%>la)udNQDX zCIbq@CZFkIUG}u><zZ0)o(YqhNX7vyv|P~J!{)F9pfn_XW{;jtBl?eE?a!)`s`UDI zMK8~rK?Oh!3W*QNunOPrIK6|;Upw!TB}W2p1r#rI!uwb}7xJjQ68SVwggjRLEzOf( zBU#+6xTcWjBr!*`8ofLgzCW~;%1@W4(`MnJycJZkm(oifYB{AreFa^8Ol&$`Qm`{D zaI(TL$r3&Q68H6foh|D?)s!^lPD$Au=B$efV9iyJh*ea2P+!4b-p5BirenvB2|#&y zPUTMq8W<WEx={*61|;P_RQ%vveMMP6k~~m{kIg#w1Rz<@$b-fKpYwv5@`dvEVVF9w zo%N#RpX_>h5X*q)++MJqZl1d-0Oj?RLIlmECA4W})XE4vv9nmJrfy$%z4fB8?1?H5 zz=Bx?$7~=0T`)dI-qX8jqSQU9jvFu3yyAOt){6uY56qN9EW^A>v|hZOQt%1*c|hU# z;o~FV4Uj`=uA-{}OJ$vkXQiH!fyK=DA1&hd_Q|(S!H_EfCH>4m|3I2Kawab-Ab~F| zC=?#5vw&)8>e5E^@^IEm#pMe3|79ma_|1TYmP>h_`m}*c>!p9M{<L!ZO2XmV_<I6S zos9g1@I5w%TLdU2f23?l`!-E#TIZ!WG1qB$D#d$%#%5S(7;QVgO#rGhCh8E&Kn~T) zjLb27DcUIO-nT4#&P(83Jt`vY@fFE1wlZzxG#U^ji)BbTlmJwxOw@ltp8fKjX>VG- z2bo0Xp_E{<Y8zM{pPl(E1qBAt#{C=R){6jCrwo67Z2-$AVCYD-shm@k<G8n@09W6@ zzASu?ULMXI7J%yfJQcMGu+)Io*xVZ_Jyb9MUKAG<$GjMNc~xhsG6bMHx3#S}zgqIH zR^chcGSJKW`qbA{UR<6ocqrkioO>-bPi3)zy$AC63WU%=Y*v?6i;yQk<wo-EqYbQ> zu`%qSFapfN_wNfp2~fFH4XQkc9^T|(lPRQU2xS*!3qT1_c?KwG8({0jDl2WOFl7ip ziA25CfWqP_a;U+52lEJUO=(Sf{U$MBCp?wAfKohSwrbh^%Xsnu&0!YH5FSc+s@4Ju z2C<CMp`&??s^CO{0F>}ltqXTB2;WZ`HiZZ6&>XI-t`mR~plUs!U|96T0gRguY?fOu z0#G9SwH8p&DM!e|vcj&SU3B&A)%1qV4FXWYQ?(#}vilk*Da1{Q<3p@7^E1(U5wwBu zRINzJ?Y^F)pF?3GVYL0^c2-|8zbATm!c(=f!W$Gch?Q5Mx$x29kLW`A1(8DuP_;fG zx61jT$}{dY%2nP60#E`}tpQY{Ol+c;#~aOsI|QJFX@JU2K;g_`7RxZ#)0Vs~R9jw~ zApj*z=T`ot@*L)vv6Bb6YxMG}&s3+^zbATm!jzuMjfC7fzJhruo%A2XGRlg|M934S z0F^u1opxVCECa&#ukCzIo`({E66OG^7F2llVi{ka_)-8$nCG7A(TR`ppdFa<t7or@ zq+FOrqV5KudieL?0Xu9EqnBr@G^Lw23#MF{JDy4fU|`4}oA{V4e4m#|#f8Np<Oy@r zQ>l3@$>!<j@qpbI$G@PWQ$^_w?~7>zVXe%m(94@KY6h>Oe|qFoKI=tzC}AzD{uE(w z*|=rYuSY*h-<K{A*a<)hYpthZv5etSOdDV?PXJ1oN1h5R=xd_Z$VqvACY>ug2SBa2 z07(E!n45{ZUFgGr-KdaJ^iAP6R8d^<R{f^>*Mx@>)+$d0rhGy80t)mCqz?~$NR_3P zM#)3HZUIic;u3%o<~pZZ6tRdkHaG0rKy?@D-lWa+8rjZZw_O5I!rTMZ!ia^eu?hLa zx{Gxi=so%~Ii7Z`1eXAmFz28GvAHFG3tg$bvYy_hKT-1|AkB8b5`Yrs8dQ5u@1fcY zwXaeJr8K4Nn&*lNKnZhcKJ)_pk<#c7cF);^N(nGWnb;TX2niSM9=E=B^*vXwclMkx zb^E}xzpi@XgLDOvqZ%iXqj+@#H5aoMADu8wQ2ALrkUgl}Jsnw?FilFKK_zf#9kDF{ zCCn{QnVn=Mjc#N)!h|&gRclgcVZz)Fe<W%tVQm2_0U}}dH2et@=CSF-uRxdpl`yY2 wAJMuKCOnle0V-hvRKkP_Pzm!s`+orj0DmM6pw6$!i~s-t07*qoM6N<$f>-V9>Hq)$ literal 0 HcmV?d00001 diff --git a/deps/url-0.2.35/make_encode_sets.py b/deps/url-0.2.35/make_encode_sets.py new file mode 100644 index 000000000..017abbe1e --- /dev/null +++ b/deps/url-0.2.35/make_encode_sets.py @@ -0,0 +1,41 @@ +# Copyright 2013-2014 Simon Sapin. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + + +# Run as: python make_encode_sets.py > src/encode_sets.rs + + +print('''\ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Generated by make_encode_sets.py +''') +for name, encoded in [ + ('SIMPLE', ''), + ('QUERY', r''' "#<>`'''), + ('DEFAULT', r''' "#<>`?'''), + ('USERINFO', r''' "#<>`?@'''), + ('PASSWORD', r''' "#<>`?@\/'''), + ('USERNAME', r''' "#<>`?@\/:'''), + ('FORM_URLENCODED', r''' !"#$%&\'()+,/:;<=>?@[\]^`{|}~'''), +]: + print( + "pub static %s: [&'static str; 256] = [\n%s\n];\n\n" + % (name, '\n'.join( + ' ' + ' '.join( + '"%s%s",' % ("\\" if chr(b) in '\\"' else "", chr(b)) + if 0x20 <= b <= 0x7E and chr(b) not in encoded + else '"%%%02X",' % b + for b in range(s, s + 8) + ) for s in range(0, 256, 8)))) diff --git a/deps/url-0.2.35/src/encode_sets.rs b/deps/url-0.2.35/src/encode_sets.rs new file mode 100644 index 000000000..587de629a --- /dev/null +++ b/deps/url-0.2.35/src/encode_sets.rs @@ -0,0 +1,260 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Generated by make_encode_sets.py + +pub static SIMPLE: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + " ", "!", "\"", "#", "$", "%", "&", "'", + "(", ")", "*", "+", ",", "-", ".", "/", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", ":", ";", "<", "=", ">", "?", + "@", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "\\", "]", "^", "_", + "`", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "{", "|", "}", "~", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; + + +pub static QUERY: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + "%20", "!", "%22", "%23", "$", "%", "&", "'", + "(", ")", "*", "+", ",", "-", ".", "/", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", ":", ";", "%3C", "=", "%3E", "?", + "@", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "\\", "]", "^", "_", + "%60", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "{", "|", "}", "~", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; + + +pub static DEFAULT: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + "%20", "!", "%22", "%23", "$", "%", "&", "'", + "(", ")", "*", "+", ",", "-", ".", "/", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", ":", ";", "%3C", "=", "%3E", "%3F", + "@", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "\\", "]", "^", "_", + "%60", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "{", "|", "}", "~", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; + + +pub static USERINFO: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + "%20", "!", "%22", "%23", "$", "%", "&", "'", + "(", ")", "*", "+", ",", "-", ".", "/", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", ":", ";", "%3C", "=", "%3E", "%3F", + "%40", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "\\", "]", "^", "_", + "%60", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "{", "|", "}", "~", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; + + +pub static PASSWORD: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + "%20", "!", "%22", "%23", "$", "%", "&", "'", + "(", ")", "*", "+", ",", "-", ".", "%2F", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", ":", ";", "%3C", "=", "%3E", "%3F", + "%40", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "%5C", "]", "^", "_", + "%60", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "{", "|", "}", "~", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; + + +pub static USERNAME: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + "%20", "!", "%22", "%23", "$", "%", "&", "'", + "(", ")", "*", "+", ",", "-", ".", "%2F", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "%3A", ";", "%3C", "=", "%3E", "%3F", + "%40", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "%5C", "]", "^", "_", + "%60", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "{", "|", "}", "~", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; + + +pub static FORM_URLENCODED: [&'static str; 256] = [ + "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", + "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", + "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", + "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", + "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", + "%28", "%29", "*", "%2B", "%2C", "-", ".", "%2F", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "%3A", "%3B", "%3C", "%3D", "%3E", "%3F", + "%40", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "%5B", "%5C", "%5D", "%5E", "_", + "%60", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "%7B", "%7C", "%7D", "%7E", "%7F", + "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", + "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", + "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", + "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", + "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", + "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", + "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", + "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", + "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", + "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", + "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", + "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", + "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", + "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", + "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", + "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", +]; diff --git a/deps/url-0.2.35/src/encoding.rs b/deps/url-0.2.35/src/encoding.rs new file mode 100644 index 000000000..5cdd71d3e --- /dev/null +++ b/deps/url-0.2.35/src/encoding.rs @@ -0,0 +1,97 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +//! Abstraction that conditionally compiles either to rust-encoding, +//! or to only support UTF-8. + +#[cfg(feature = "query_encoding")] extern crate encoding; + +use std::borrow::Cow; + +#[cfg(feature = "query_encoding")] use self::encoding::types::{DecoderTrap, EncoderTrap}; +#[cfg(feature = "query_encoding")] use self::encoding::label::encoding_from_whatwg_label; +#[cfg(feature = "query_encoding")] pub use self::encoding::types::EncodingRef; + +#[cfg(feature = "query_encoding")] +#[derive(Copy, Clone)] +pub struct EncodingOverride { + /// `None` means UTF-8. + encoding: Option<EncodingRef> +} + +#[cfg(feature = "query_encoding")] +impl EncodingOverride { + pub fn from_opt_encoding(encoding: Option<EncodingRef>) -> EncodingOverride { + encoding.map(EncodingOverride::from_encoding).unwrap_or_else(EncodingOverride::utf8) + } + + pub fn from_encoding(encoding: EncodingRef) -> EncodingOverride { + EncodingOverride { + encoding: if encoding.name() == "utf-8" { None } else { Some(encoding) } + } + } + + pub fn utf8() -> EncodingOverride { + EncodingOverride { encoding: None } + } + + pub fn lookup(label: &[u8]) -> Option<EncodingOverride> { + ::std::str::from_utf8(label) + .ok() + .and_then(encoding_from_whatwg_label) + .map(EncodingOverride::from_encoding) + } + + pub fn is_utf8(&self) -> bool { + self.encoding.is_none() + } + + pub fn decode(&self, input: &[u8]) -> String { + match self.encoding { + Some(encoding) => encoding.decode(input, DecoderTrap::Replace).unwrap(), + None => String::from_utf8_lossy(input).to_string(), + } + } + + pub fn encode<'a>(&self, input: &'a str) -> Cow<'a, [u8]> { + match self.encoding { + Some(encoding) => Cow::Owned( + encoding.encode(input, EncoderTrap::NcrEscape).unwrap()), + None => Cow::Borrowed(input.as_bytes()), // UTF-8 + } + } +} + + +#[cfg(not(feature = "query_encoding"))] +#[derive(Copy, Clone)] +pub struct EncodingOverride; + +#[cfg(not(feature = "query_encoding"))] +impl EncodingOverride { + pub fn utf8() -> EncodingOverride { + EncodingOverride + } + + pub fn lookup(_label: &[u8]) -> Option<EncodingOverride> { + None + } + + pub fn is_utf8(&self) -> bool { + true + } + + pub fn decode(&self, input: &[u8]) -> String { + String::from_utf8_lossy(input).into_owned() + } + + pub fn encode<'a>(&self, input: &'a str) -> Cow<'a, [u8]> { + Cow::Borrowed(input.as_bytes()) + } +} diff --git a/deps/url-0.2.35/src/form_urlencoded.rs b/deps/url-0.2.35/src/form_urlencoded.rs new file mode 100644 index 000000000..257164fc1 --- /dev/null +++ b/deps/url-0.2.35/src/form_urlencoded.rs @@ -0,0 +1,174 @@ +// Copyright 2013-2015 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Parser and serializer for the [`application/x-www-form-urlencoded` format]( +//! http://url.spec.whatwg.org/#application/x-www-form-urlencoded), +//! as used by HTML forms. +//! +//! Converts between a string (such as an URL’s query string) +//! and a sequence of (name, value) pairs. + +use std::borrow::Borrow; +use std::ascii::AsciiExt; +use encoding::EncodingOverride; +use percent_encoding::{percent_encode_to, percent_decode, FORM_URLENCODED_ENCODE_SET}; + + +/// Convert a byte string in the `application/x-www-form-urlencoded` format +/// into a vector of (name, value) pairs. +/// +/// Use `parse(input.as_bytes())` to parse a `&str` string. +#[inline] +pub fn parse(input: &[u8]) -> Vec<(String, String)> { + parse_internal(input, EncodingOverride::utf8(), false).unwrap() +} + + +/// Convert a byte string in the `application/x-www-form-urlencoded` format +/// into a vector of (name, value) pairs. +/// +/// Use `parse(input.as_bytes())` to parse a `&str` string. +/// +/// This function is only available if the `query_encoding` Cargo feature is enabled. +/// +/// Arguments: +/// +/// * `encoding_override`: The character encoding each name and values is decoded as +/// after percent-decoding. Defaults to UTF-8. +/// * `use_charset`: The *use _charset_ flag*. If in doubt, set to `false`. +#[cfg(feature = "query_encoding")] +#[inline] +pub fn parse_with_encoding(input: &[u8], encoding_override: Option<::encoding::EncodingRef>, + use_charset: bool) + -> Option<Vec<(String, String)>> { + parse_internal(input, EncodingOverride::from_opt_encoding(encoding_override), use_charset) +} + + +fn parse_internal(input: &[u8], mut encoding_override: EncodingOverride, mut use_charset: bool) + -> Option<Vec<(String, String)>> { + let mut pairs = Vec::new(); + for piece in input.split(|&b| b == b'&') { + if !piece.is_empty() { + let (name, value) = match piece.iter().position(|b| *b == b'=') { + Some(position) => (&piece[..position], &piece[position + 1..]), + None => (piece, &[][..]) + }; + + #[inline] + fn replace_plus(input: &[u8]) -> Vec<u8> { + input.iter().map(|&b| if b == b'+' { b' ' } else { b }).collect() + } + + let name = replace_plus(name); + let value = replace_plus(value); + if use_charset && name == b"_charset_" { + if let Some(encoding) = EncodingOverride::lookup(&value) { + encoding_override = encoding; + } + use_charset = false; + } + pairs.push((name, value)); + } + } + if !(encoding_override.is_utf8() || input.is_ascii()) { + return None + } + + Some(pairs.into_iter().map(|(name, value)| ( + encoding_override.decode(&percent_decode(&name)), + encoding_override.decode(&percent_decode(&value)) + )).collect()) +} + + +/// Convert an iterator of (name, value) pairs +/// into a string in the `application/x-www-form-urlencoded` format. +#[inline] +pub fn serialize<I, K, V>(pairs: I) -> String +where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef<str>, V: AsRef<str> { + serialize_internal(pairs, EncodingOverride::utf8()) +} + +/// Convert an iterator of (name, value) pairs +/// into a string in the `application/x-www-form-urlencoded` format. +/// +/// This function is only available if the `query_encoding` Cargo feature is enabled. +/// +/// Arguments: +/// +/// * `encoding_override`: The character encoding each name and values is encoded as +/// before percent-encoding. Defaults to UTF-8. +#[cfg(feature = "query_encoding")] +#[inline] +pub fn serialize_with_encoding<I, K, V>(pairs: I, + encoding_override: Option<::encoding::EncodingRef>) + -> String +where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef<str>, V: AsRef<str> { + serialize_internal(pairs, EncodingOverride::from_opt_encoding(encoding_override)) +} + +fn serialize_internal<I, K, V>(pairs: I, encoding_override: EncodingOverride) -> String +where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef<str>, V: AsRef<str> { + #[inline] + fn byte_serialize(input: &str, output: &mut String, + encoding_override: EncodingOverride) { + for &byte in encoding_override.encode(input).iter() { + if byte == b' ' { + output.push_str("+") + } else { + percent_encode_to(&[byte], FORM_URLENCODED_ENCODE_SET, output) + } + } + } + + let mut output = String::new(); + for pair in pairs { + let &(ref name, ref value) = pair.borrow(); + if output.len() > 0 { + output.push_str("&"); + } + byte_serialize(name.as_ref(), &mut output, encoding_override); + output.push_str("="); + byte_serialize(value.as_ref(), &mut output, encoding_override); + } + output +} + + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_form_urlencoded() { + let pairs = &[ + ("foo".to_string(), "é&".to_string()), + ("bar".to_string(), "".to_string()), + ("foo".to_string(), "#".to_string()) + ]; + let encoded = serialize(pairs); + assert_eq!(encoded, "foo=%C3%A9%26&bar=&foo=%23"); + assert_eq!(parse(encoded.as_bytes()), pairs.to_vec()); + } + + #[test] + fn test_form_serialize() { + let pairs = [("foo", "é&"), + ("bar", ""), + ("foo", "#")]; + + let want = "foo=%C3%A9%26&bar=&foo=%23"; + // Works with referenced tuples + assert_eq!(serialize(pairs.iter()), want); + // Works with owned tuples + assert_eq!(serialize(pairs.iter().map(|p| (p.0, p.1))), want); + + } +} diff --git a/deps/url-0.2.35/src/format.rs b/deps/url-0.2.35/src/format.rs new file mode 100644 index 000000000..c448bd539 --- /dev/null +++ b/deps/url-0.2.35/src/format.rs @@ -0,0 +1,141 @@ +// Copyright 2013-2015 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Formatting utilities for URLs. +//! +//! These formatters can be used to coerce various URL parts into strings. +//! +//! You can use `<formatter>.to_string()`, as the formatters implement `fmt::Display`. + +use std::fmt::{self, Formatter}; +use super::Url; + +/// Formatter and serializer for URL path data. +pub struct PathFormatter<'a, T:'a> { + /// The path as a slice of string-like objects (String or &str). + pub path: &'a [T] +} + +impl<'a, T: fmt::Display> fmt::Display for PathFormatter<'a, T> { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + if self.path.is_empty() { + formatter.write_str("/") + } else { + for path_part in self.path { + try!("/".fmt(formatter)); + try!(path_part.fmt(formatter)); + } + Ok(()) + } + } +} + + +/// Formatter and serializer for URL username and password data. +pub struct UserInfoFormatter<'a> { + /// URL username as a string slice. + pub username: &'a str, + + /// URL password as an optional string slice. + /// + /// You can convert an `Option<String>` with `.as_ref().map(|s| s)`. + pub password: Option<&'a str> +} + +impl<'a> fmt::Display for UserInfoFormatter<'a> { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + if !self.username.is_empty() || self.password.is_some() { + try!(formatter.write_str(self.username)); + if let Some(password) = self.password { + try!(formatter.write_str(":")); + try!(formatter.write_str(password)); + } + try!(formatter.write_str("@")); + } + Ok(()) + } +} + + +/// Formatter for URLs which ignores the fragment field. +pub struct UrlNoFragmentFormatter<'a> { + pub url: &'a Url +} + +impl<'a> fmt::Display for UrlNoFragmentFormatter<'a> { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + try!(formatter.write_str(&self.url.scheme)); + try!(formatter.write_str(":")); + try!(self.url.scheme_data.fmt(formatter)); + if let Some(ref query) = self.url.query { + try!(formatter.write_str("?")); + try!(formatter.write_str(query)); + } + Ok(()) + } +} + + +/// Formatting Tests +#[cfg(test)] +mod tests { + use super::super::Url; + use super::{PathFormatter, UserInfoFormatter}; + + #[test] + fn path_formatting() { + let data = [ + (vec![], "/"), + (vec![""], "/"), + (vec!["test", "path"], "/test/path"), + (vec!["test", "path", ""], "/test/path/") + ]; + for &(ref path, result) in &data { + assert_eq!(PathFormatter { + path: path + }.to_string(), result.to_string()); + } + } + + #[test] + fn userinfo_formatting() { + // Test data as (username, password, result) tuples. + let data = [ + ("", None, ""), + ("", Some(""), ":@"), + ("", Some("password"), ":password@"), + ("username", None, "username@"), + ("username", Some(""), "username:@"), + ("username", Some("password"), "username:password@") + ]; + for &(username, password, result) in &data { + assert_eq!(UserInfoFormatter { + username: username, + password: password + }.to_string(), result.to_string()); + } + } + + #[test] + fn relative_scheme_url_formatting() { + let data = [ + ("http://example.com/", "http://example.com/"), + ("http://addslash.com", "http://addslash.com/"), + ("http://@emptyuser.com/", "http://emptyuser.com/"), + ("http://:@emptypass.com/", "http://:@emptypass.com/"), + ("http://user@user.com/", "http://user@user.com/"), + ("http://user:pass@userpass.com/", "http://user:pass@userpass.com/"), + ("http://slashquery.com/path/?q=something", "http://slashquery.com/path/?q=something"), + ("http://noslashquery.com/path?q=something", "http://noslashquery.com/path?q=something") + ]; + for &(input, result) in &data { + let url = Url::parse(input).unwrap(); + assert_eq!(url.to_string(), result.to_string()); + } + } +} diff --git a/deps/url-0.2.35/src/host.rs b/deps/url-0.2.35/src/host.rs new file mode 100644 index 000000000..7c71460e6 --- /dev/null +++ b/deps/url-0.2.35/src/host.rs @@ -0,0 +1,280 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ascii::AsciiExt; +use std::cmp; +use std::fmt::{self, Formatter}; +use parser::{ParseResult, ParseError}; +use percent_encoding::{from_hex, percent_decode}; + + +/// The host name of an URL. +#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] +pub enum Host { + /// A (DNS) domain name or an IPv4 address. + /// + /// FIXME: IPv4 probably should be a separate variant. + /// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=26431 + Domain(String), + + /// An IPv6 address, represented inside `[...]` square brackets + /// so that `:` colon characters in the address are not ambiguous + /// with the port number delimiter. + Ipv6(Ipv6Address), +} + + +/// A 128 bit IPv6 address +#[derive(Clone, Eq, PartialEq, Copy, Debug, Hash, PartialOrd, Ord)] +pub struct Ipv6Address { + pub pieces: [u16; 8] +} + + +impl Host { + /// Parse a host: either an IPv6 address in [] square brackets, or a domain. + /// + /// Returns `Err` for an empty host, an invalid IPv6 address, + /// or a or invalid non-ASCII domain. + /// + /// FIXME: Add IDNA support for non-ASCII domains. + pub fn parse(input: &str) -> ParseResult<Host> { + if input.len() == 0 { + Err(ParseError::EmptyHost) + } else if input.starts_with("[") { + if input.ends_with("]") { + Ipv6Address::parse(&input[1..input.len() - 1]).map(Host::Ipv6) + } else { + Err(ParseError::InvalidIpv6Address) + } + } else { + let decoded = percent_decode(input.as_bytes()); + let domain = String::from_utf8_lossy(&decoded); + // TODO: Remove this check and use IDNA "domain to ASCII" + if !domain.is_ascii() { + Err(ParseError::NonAsciiDomainsNotSupportedYet) + } else if domain.find(&[ + '\0', '\t', '\n', '\r', ' ', '#', '%', '/', ':', '?', '@', '[', '\\', ']' + ][..]).is_some() { + Err(ParseError::InvalidDomainCharacter) + } else { + Ok(Host::Domain(domain.to_ascii_lowercase())) + } + } + } + + /// Serialize the host as a string. + /// + /// A domain a returned as-is, an IPv6 address between [] square brackets. + pub fn serialize(&self) -> String { + self.to_string() + } +} + + +impl fmt::Display for Host { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + match *self { + Host::Domain(ref domain) => domain.fmt(formatter), + Host::Ipv6(ref address) => { + try!(formatter.write_str("[")); + try!(address.fmt(formatter)); + formatter.write_str("]") + } + } + } +} + + +impl Ipv6Address { + /// Parse an IPv6 address, without the [] square brackets. + pub fn parse(input: &str) -> ParseResult<Ipv6Address> { + let input = input.as_bytes(); + let len = input.len(); + let mut is_ip_v4 = false; + let mut pieces = [0, 0, 0, 0, 0, 0, 0, 0]; + let mut piece_pointer = 0; + let mut compress_pointer = None; + let mut i = 0; + + if len < 2 { + return Err(ParseError::InvalidIpv6Address) + } + + if input[0] == b':' { + if input[1] != b':' { + return Err(ParseError::InvalidIpv6Address) + } + i = 2; + piece_pointer = 1; + compress_pointer = Some(1); + } + + while i < len { + if piece_pointer == 8 { + return Err(ParseError::InvalidIpv6Address) + } + if input[i] == b':' { + if compress_pointer.is_some() { + return Err(ParseError::InvalidIpv6Address) + } + i += 1; + piece_pointer += 1; + compress_pointer = Some(piece_pointer); + continue + } + let start = i; + let end = cmp::min(len, start + 4); + let mut value = 0u16; + while i < end { + match from_hex(input[i]) { + Some(digit) => { + value = value * 0x10 + digit as u16; + i += 1; + }, + None => break + } + } + if i < len { + match input[i] { + b'.' => { + if i == start { + return Err(ParseError::InvalidIpv6Address) + } + i = start; + is_ip_v4 = true; + }, + b':' => { + i += 1; + if i == len { + return Err(ParseError::InvalidIpv6Address) + } + }, + _ => return Err(ParseError::InvalidIpv6Address) + } + } + if is_ip_v4 { + break + } + pieces[piece_pointer] = value; + piece_pointer += 1; + } + + if is_ip_v4 { + if piece_pointer > 6 { + return Err(ParseError::InvalidIpv6Address) + } + let mut dots_seen = 0; + while i < len { + // FIXME: https://github.com/whatwg/url/commit/1c22aa119c354e0020117e02571cec53f7c01064 + let mut value = 0u16; + while i < len { + let digit = match input[i] { + c @ b'0' ... b'9' => c - b'0', + _ => break + }; + value = value * 10 + digit as u16; + if value == 0 || value > 255 { + return Err(ParseError::InvalidIpv6Address) + } + } + if dots_seen < 3 && !(i < len && input[i] == b'.') { + return Err(ParseError::InvalidIpv6Address) + } + pieces[piece_pointer] = pieces[piece_pointer] * 0x100 + value; + if dots_seen == 0 || dots_seen == 2 { + piece_pointer += 1; + } + i += 1; + if dots_seen == 3 && i < len { + return Err(ParseError::InvalidIpv6Address) + } + dots_seen += 1; + } + } + + match compress_pointer { + Some(compress_pointer) => { + let mut swaps = piece_pointer - compress_pointer; + piece_pointer = 7; + while swaps > 0 { + pieces[piece_pointer] = pieces[compress_pointer + swaps - 1]; + pieces[compress_pointer + swaps - 1] = 0; + swaps -= 1; + piece_pointer -= 1; + } + } + _ => if piece_pointer != 8 { + return Err(ParseError::InvalidIpv6Address) + } + } + Ok(Ipv6Address { pieces: pieces }) + } + + /// Serialize the IPv6 address to a string. + pub fn serialize(&self) -> String { + self.to_string() + } +} + + +impl fmt::Display for Ipv6Address { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + let (compress_start, compress_end) = longest_zero_sequence(&self.pieces); + let mut i = 0; + while i < 8 { + if i == compress_start { + try!(formatter.write_str(":")); + if i == 0 { + try!(formatter.write_str(":")); + } + if compress_end < 8 { + i = compress_end; + } else { + break; + } + } + try!(write!(formatter, "{:x}", self.pieces[i as usize])); + if i < 7 { + try!(formatter.write_str(":")); + } + i += 1; + } + Ok(()) + } +} + + +fn longest_zero_sequence(pieces: &[u16; 8]) -> (isize, isize) { + let mut longest = -1; + let mut longest_length = -1; + let mut start = -1; + macro_rules! finish_sequence( + ($end: expr) => { + if start >= 0 { + let length = $end - start; + if length > longest_length { + longest = start; + longest_length = length; + } + } + }; + ); + for i in 0..8 { + if pieces[i as usize] == 0 { + if start < 0 { + start = i; + } + } else { + finish_sequence!(i); + start = -1; + } + } + finish_sequence!(8); + (longest, longest + longest_length) +} diff --git a/deps/url-0.2.35/src/lib.rs b/deps/url-0.2.35/src/lib.rs new file mode 100644 index 000000000..a0fcc1519 --- /dev/null +++ b/deps/url-0.2.35/src/lib.rs @@ -0,0 +1,1024 @@ +// Copyright 2013-2015 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! + +<a href="https://github.com/servo/rust-url"><img style="position: absolute; top: 0; left: 0; border: 0;" src="../github.png" alt="Fork me on GitHub"></a> +<style>.sidebar { margin-top: 53px }</style> + +rust-url is an implementation of the [URL Standard](http://url.spec.whatwg.org/) +for the [Rust](http://rust-lang.org/) programming language. + +It builds with [Cargo](http://crates.io/). +To use it in your project, add this to your `Cargo.toml` file: + +```Cargo +[dependencies.url] +git = "https://github.com/servo/rust-url" +``` + +Supporting encodings other than UTF-8 in query strings is an optional feature +that requires [rust-encoding](https://github.com/lifthrasiir/rust-encoding) +and is off by default. +You can enable it with +[Cargo’s *features* mechanism](http://doc.crates.io/manifest.html#the-[features]-section): + +```Cargo +[dependencies.url] +git = "https://github.com/servo/rust-url" +features = ["query_encoding"] +``` + +… or by passing `--cfg 'feature="query_encoding"'` to rustc. + + +# URL parsing and data structures + +First, URL parsing may fail for various reasons and therefore returns a `Result`. + +``` +use url::{Url, ParseError}; + +assert!(Url::parse("http://[:::1]") == Err(ParseError::InvalidIpv6Address)) +``` + +Let’s parse a valid URL and look at its components. + +``` +use url::{Url, SchemeData}; + +let issue_list_url = Url::parse( + "https://github.com/rust-lang/rust/issues?labels=E-easy&state=open" +).unwrap(); + + +assert!(issue_list_url.scheme == "https".to_string()); +assert!(issue_list_url.domain() == Some("github.com")); +assert!(issue_list_url.port() == None); +assert!(issue_list_url.path() == Some(&["rust-lang".to_string(), + "rust".to_string(), + "issues".to_string()][..])); +assert!(issue_list_url.query == Some("labels=E-easy&state=open".to_string())); +assert!(issue_list_url.fragment == None); +match issue_list_url.scheme_data { + SchemeData::Relative(..) => {}, // Expected + SchemeData::NonRelative(..) => panic!(), +} +``` + +The `scheme`, `query`, and `fragment` are directly fields of the `Url` struct: +they apply to all URLs. +Every other components has accessors because they only apply to URLs said to be +“in a relative scheme”. `https` is a relative scheme, but `data` is not: + +``` +use url::{Url, SchemeData}; + +let data_url = Url::parse("data:text/plain,Hello#").unwrap(); + +assert!(data_url.scheme == "data".to_string()); +assert!(data_url.scheme_data == SchemeData::NonRelative("text/plain,Hello".to_string())); +assert!(data_url.non_relative_scheme_data() == Some("text/plain,Hello")); +assert!(data_url.query == None); +assert!(data_url.fragment == Some("".to_string())); +``` + + +# Base URL + +Many contexts allow URL *references* that can be relative to a *base URL*: + +```html +<link rel="stylesheet" href="../main.css"> +``` + +Since parsed URL are absolute, giving a base is required: + +``` +use url::{Url, ParseError}; + +assert!(Url::parse("../main.css") == Err(ParseError::RelativeUrlWithoutBase)) +``` + +`UrlParser` is a method-chaining API to provide various optional parameters +to URL parsing, including a base URL. + +``` +use url::{Url, UrlParser}; + +let this_document = Url::parse("http://servo.github.io/rust-url/url/index.html").unwrap(); +let css_url = UrlParser::new().base_url(&this_document).parse("../main.css").unwrap(); +assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_string()); +``` + +*/ + +extern crate rustc_serialize; + +#[macro_use] +extern crate matches; + +use std::fmt::{self, Formatter}; +use std::str; +use std::path::{Path, PathBuf}; + +pub use host::{Host, Ipv6Address}; +pub use parser::{ErrorHandler, ParseResult, ParseError}; + +use percent_encoding::{percent_encode, lossy_utf8_percent_decode, DEFAULT_ENCODE_SET}; + +use format::{PathFormatter, UserInfoFormatter, UrlNoFragmentFormatter}; +use encoding::EncodingOverride; + +mod encoding; +mod host; +mod parser; +pub mod urlutils; +pub mod percent_encoding; +pub mod form_urlencoded; +pub mod punycode; +pub mod format; + +#[cfg(test)] +mod tests; + + +/// The parsed representation of an absolute URL. +#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] +pub struct Url { + /// The scheme (a.k.a. protocol) of the URL, in ASCII lower case. + pub scheme: String, + + /// The components of the URL whose representation depends on where the scheme is *relative*. + pub scheme_data: SchemeData, + + /// The query string of the URL. + /// + /// `None` if the `?` delimiter character was not part of the parsed input, + /// otherwise a possibly empty, percent-encoded string. + /// + /// Percent encoded strings are within the ASCII range. + /// + /// See also the `query_pairs`, `set_query_from_pairs`, + /// and `lossy_percent_decode_query` methods. + pub query: Option<String>, + + /// The fragment identifier of the URL. + /// + /// `None` if the `#` delimiter character was not part of the parsed input, + /// otherwise a possibly empty, percent-encoded string. + /// + /// Percent encoded strings are within the ASCII range. + /// + /// See also the `lossy_percent_decode_fragment` method. + pub fragment: Option<String>, +} + +/// The components of the URL whose representation depends on where the scheme is *relative*. +#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] +pub enum SchemeData { + /// Components for URLs in a *relative* scheme such as HTTP. + Relative(RelativeSchemeData), + + /// No further structure is assumed for *non-relative* schemes such as `data` and `mailto`. + /// + /// This is a single percent-encoded string, whose interpretation depends on the scheme. + /// + /// Percent encoded strings are within the ASCII range. + NonRelative(String), +} + +/// Components for URLs in a *relative* scheme such as HTTP. +#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] +pub struct RelativeSchemeData { + /// The username of the URL, as a possibly empty, percent-encoded string. + /// + /// Percent encoded strings are within the ASCII range. + /// + /// See also the `lossy_percent_decode_username` method. + pub username: String, + + /// The password of the URL. + /// + /// `None` if the `:` delimiter character was not part of the parsed input, + /// otherwise a possibly empty, percent-encoded string. + /// + /// Percent encoded strings are within the ASCII range. + /// + /// See also the `lossy_percent_decode_password` method. + pub password: Option<String>, + + /// The host of the URL, either a domain name or an IPv4 address + pub host: Host, + + /// The port number of the URL. + /// `None` for file-like schemes, or to indicate the default port number. + pub port: Option<u16>, + + /// The default port number for the URL’s scheme. + /// `None` for file-like schemes. + pub default_port: Option<u16>, + + /// The path of the URL, as vector of percent-encoded strings. + /// + /// Percent encoded strings are within the ASCII range. + /// + /// See also the `serialize_path` method and, + /// for URLs in the `file` scheme, the `to_file_path` method. + pub path: Vec<String>, +} + + +impl str::FromStr for Url { + type Err = ParseError; + + fn from_str(url: &str) -> ParseResult<Url> { + Url::parse(url) + } +} + +/// A set of optional parameters for URL parsing. +pub struct UrlParser<'a> { + base_url: Option<&'a Url>, + query_encoding_override: EncodingOverride, + error_handler: ErrorHandler, + scheme_type_mapper: fn(scheme: &str) -> SchemeType, +} + + +/// A method-chaining API to provide a set of optional parameters for URL parsing. +impl<'a> UrlParser<'a> { + /// Return a new UrlParser with default parameters. + #[inline] + pub fn new() -> UrlParser<'a> { + fn silent_handler(_reason: ParseError) -> ParseResult<()> { Ok(()) } + UrlParser { + base_url: None, + query_encoding_override: EncodingOverride::utf8(), + error_handler: silent_handler, + scheme_type_mapper: whatwg_scheme_type_mapper, + } + } + + /// Set the base URL used for resolving relative URL references, and return the `UrlParser`. + /// The default is no base URL, so that relative URLs references fail to parse. + #[inline] + pub fn base_url<'b>(&'b mut self, value: &'a Url) -> &'b mut UrlParser<'a> { + self.base_url = Some(value); + self + } + + /// Set the character encoding the query string is encoded as before percent-encoding, + /// and return the `UrlParser`. + /// + /// This legacy quirk is only relevant to HTML. + /// + /// This method is only available if the `query_encoding` Cargo feature is enabled. + #[cfg(feature = "query_encoding")] + #[inline] + pub fn query_encoding_override<'b>(&'b mut self, value: encoding::EncodingRef) + -> &'b mut UrlParser<'a> { + self.query_encoding_override = EncodingOverride::from_encoding(value); + self + } + + /// Set an error handler for non-fatal parse errors, and return the `UrlParser`. + /// + /// Non-fatal parse errors are normally ignored by the parser, + /// but indicate violations of authoring requirements. + /// An error handler can be used, for example, to log these errors in the console + /// of a browser’s developer tools. + /// + /// The error handler can choose to make the error fatal by returning `Err(..)` + #[inline] + pub fn error_handler<'b>(&'b mut self, value: ErrorHandler) -> &'b mut UrlParser<'a> { + self.error_handler = value; + self + } + + /// Set a *scheme type mapper*, and return the `UrlParser`. + /// + /// The URL parser behaves differently based on the `SchemeType` of the URL. + /// See the documentation for `SchemeType` for more details. + /// A *scheme type mapper* returns a `SchemeType` + /// based on the scheme as an ASCII lower case string, + /// as found in the `scheme` field of an `Url` struct. + /// + /// The default scheme type mapper is as follows: + /// + /// ```ignore + /// fn whatwg_scheme_type_mapper(scheme: &str) -> SchemeType { + /// match scheme { + /// "file" => SchemeType::FileLike, + /// "ftp" => SchemeType::Relative(21), + /// "gopher" => SchemeType::Relative(70), + /// "http" => SchemeType::Relative(80), + /// "https" => SchemeType::Relative(443), + /// "ws" => SchemeType::Relative(80), + /// "wss" => SchemeType::Relative(443), + /// _ => NonRelative, + /// } + /// } + /// ``` + /// + /// Note that unknown schemes default to non-relative. + /// Overriding the scheme type mapper can allow, for example, + /// parsing URLs in the `git` or `irc` scheme as relative. + #[inline] + pub fn scheme_type_mapper<'b>(&'b mut self, value: fn(scheme: &str) -> SchemeType) + -> &'b mut UrlParser<'a> { + self.scheme_type_mapper = value; + self + } + + /// Parse `input` as an URL, with all the parameters previously set in the `UrlParser`. + #[inline] + pub fn parse(&self, input: &str) -> ParseResult<Url> { + parser::parse_url(input, self) + } + + /// Parse `input` as a “standalone” URL path, + /// with an optional query string and fragment identifier. + /// + /// This is typically found in the start line of an HTTP header. + /// + /// Note that while the start line has no fragment identifier in the HTTP RFC, + /// servers typically parse it and ignore it + /// (rather than having it be part of the path or query string.) + /// + /// On success, return `(path, query_string, fragment_identifier)` + #[inline] + pub fn parse_path(&self, input: &str) + -> ParseResult<(Vec<String>, Option<String>, Option<String>)> { + parser::parse_standalone_path(input, self) + } +} + + +/// Parse `input` as a “standalone” URL path, +/// with an optional query string and fragment identifier. +/// +/// This is typically found in the start line of an HTTP header. +/// +/// Note that while the start line has no fragment identifier in the HTTP RFC, +/// servers typically parse it and ignore it +/// (rather than having it be part of the path or query string.) +/// +/// On success, return `(path, query_string, fragment_identifier)` +/// +/// ```rust +/// let (path, query, fragment) = url::parse_path("/foo/bar/../baz?q=42").unwrap(); +/// assert_eq!(path, vec!["foo".to_string(), "baz".to_string()]); +/// assert_eq!(query, Some("q=42".to_string())); +/// assert_eq!(fragment, None); +/// ``` +#[inline] +pub fn parse_path(input: &str) + -> ParseResult<(Vec<String>, Option<String>, Option<String>)> { + UrlParser::new().parse_path(input) +} + + +/// Private convenience methods for use in parser.rs +impl<'a> UrlParser<'a> { + #[inline] + fn parse_error(&self, error: ParseError) -> ParseResult<()> { + (self.error_handler)(error) + } + + #[inline] + fn get_scheme_type(&self, scheme: &str) -> SchemeType { + (self.scheme_type_mapper)(scheme) + } +} + + +/// Determines the behavior of the URL parser for a given scheme. +#[derive(PartialEq, Eq, Copy, Debug, Clone, Hash, PartialOrd, Ord)] +pub enum SchemeType { + /// Indicate that the scheme is *non-relative*. + /// + /// The *scheme data* of the URL + /// (everything other than the scheme, query string, and fragment identifier) + /// is parsed as a single percent-encoded string of which no structure is assumed. + /// That string may need to be parsed further, per a scheme-specific format. + NonRelative, + + /// Indicate that the scheme is *relative*, and what the default port number is. + /// + /// The *scheme data* is structured as + /// *username*, *password*, *host*, *port number*, and *path*. + /// Relative URL references are supported, if a base URL was given. + /// The string value indicates the default port number as a string of ASCII digits, + /// or the empty string to indicate no default port number. + Relative(u16), + + /// Indicate a *relative* scheme similar to the *file* scheme. + /// + /// For example, you might want to have distinct `git+file` and `hg+file` URL schemes. + /// + /// This is like `Relative` except the host can be empty, there is no port number, + /// and path parsing has (platform-independent) quirks to support Windows filenames. + FileLike, +} + +impl SchemeType { + pub fn default_port(&self) -> Option<u16> { + match self { + &SchemeType::Relative(default_port) => Some(default_port), + _ => None, + } + } + pub fn same_as(&self, other: SchemeType) -> bool { + match (self, other) { + (&SchemeType::NonRelative, SchemeType::NonRelative) => true, + (&SchemeType::Relative(_), SchemeType::Relative(_)) => true, + (&SchemeType::FileLike, SchemeType::FileLike) => true, + _ => false + } + } +} + +/// http://url.spec.whatwg.org/#relative-scheme +pub fn whatwg_scheme_type_mapper(scheme: &str) -> SchemeType { + match scheme { + "file" => SchemeType::FileLike, + "ftp" => SchemeType::Relative(21), + "gopher" => SchemeType::Relative(70), + "http" => SchemeType::Relative(80), + "https" => SchemeType::Relative(443), + "ws" => SchemeType::Relative(80), + "wss" => SchemeType::Relative(443), + _ => SchemeType::NonRelative, + } +} + + +impl Url { + /// Parse an URL with the default `UrlParser` parameters. + /// + /// In particular, relative URL references are parse errors since no base URL is provided. + #[inline] + pub fn parse(input: &str) -> ParseResult<Url> { + UrlParser::new().parse(input) + } + + /// Convert a file name as `std::path::Path` into an URL in the `file` scheme. + /// + /// This returns `Err` if the given path is not absolute + /// or, with a Windows path, if the prefix is not a disk prefix (e.g. `C:`). + pub fn from_file_path<P: AsRef<Path>>(path: P) -> Result<Url, ()> { + let path = try!(path_to_file_url_path(path.as_ref())); + Ok(Url::from_path_common(path)) + } + + /// Convert a directory name as `std::path::Path` into an URL in the `file` scheme. + /// + /// This returns `Err` if the given path is not absolute + /// or, with a Windows path, if the prefix is not a disk prefix (e.g. `C:`). + /// + /// Compared to `from_file_path`, this adds an empty component to the path + /// (or, in terms of URL syntax, adds a trailing slash) + /// so that the entire path is considered when using this URL as a base URL. + /// + /// For example: + /// + /// * `"index.html"` parsed with `Url::from_directory_path(Path::new("/var/www"))` + /// as the base URL is `file:///var/www/index.html` + /// * `"index.html"` parsed with `Url::from_file_path(Path::new("/var/www/"))` + /// as the base URL is `file:///var/index.html`, which might not be what was intended. + /// + /// (Note that `Path::new` removes any trailing slash.) + pub fn from_directory_path<P: AsRef<Path>>(path: P) -> Result<Url, ()> { + let mut path = try!(path_to_file_url_path(path.as_ref())); + // Add an empty path component (i.e. a trailing slash in serialization) + // so that the entire path is used as a base URL. + path.push("".to_string()); + Ok(Url::from_path_common(path)) + } + + fn from_path_common(path: Vec<String>) -> Url { + Url { + scheme: "file".to_string(), + scheme_data: SchemeData::Relative(RelativeSchemeData { + username: "".to_string(), + password: None, + port: None, + default_port: None, + host: Host::Domain("".to_string()), + path: path, + }), + query: None, + fragment: None, + } + } + + /// Assuming the URL is in the `file` scheme or similar, + /// convert its path to an absolute `std::path::Path`. + /// + /// **Note:** This does not actually check the URL’s `scheme`, + /// and may give nonsensical results for other schemes. + /// It is the user’s responsibility to check the URL’s scheme before calling this. + /// + /// The return type (when `Ok()`) is generic and can be either `std::path::posix::Path` + /// or `std::path::windows::Path`. + /// (Use `std::path::Path` to pick one of them depending on the local system.) + /// If the compiler can not infer the desired type from context, you may have to specify it: + /// + /// ```ignore + /// let path = url.to_file_path::<std::path::posix::Path>(); + /// ``` + /// + /// Returns `Err` if the host is neither empty nor `"localhost"`, + /// or if `Path::new_opt()` returns `None`. + /// (That is, if the percent-decoded path contains a NUL byte or, + /// for a Windows path, is not UTF-8.) + #[inline] + pub fn to_file_path(&self) -> Result<PathBuf, ()> { + match self.scheme_data { + SchemeData::Relative(ref scheme_data) => scheme_data.to_file_path(), + SchemeData::NonRelative(..) => Err(()), + } + } + + /// Return the serialization of this URL as a string. + pub fn serialize(&self) -> String { + self.to_string() + } + + /// Return the serialization of this URL, without the fragment identifier, as a string + pub fn serialize_no_fragment(&self) -> String { + UrlNoFragmentFormatter{ url: self }.to_string() + } + + /// If the URL is *non-relative*, return the string scheme data. + #[inline] + pub fn non_relative_scheme_data<'a>(&'a self) -> Option<&'a str> { + match self.scheme_data { + SchemeData::Relative(..) => None, + SchemeData::NonRelative(ref scheme_data) => Some(scheme_data), + } + } + + /// If the URL is *non-relative*, return a mutable reference to the string scheme data. + #[inline] + pub fn non_relative_scheme_data_mut<'a>(&'a mut self) -> Option<&'a mut String> { + match self.scheme_data { + SchemeData::Relative(..) => None, + SchemeData::NonRelative(ref mut scheme_data) => Some(scheme_data), + } + } + + /// If the URL is in a *relative scheme*, return the structured scheme data. + #[inline] + pub fn relative_scheme_data<'a>(&'a self) -> Option<&'a RelativeSchemeData> { + match self.scheme_data { + SchemeData::Relative(ref scheme_data) => Some(scheme_data), + SchemeData::NonRelative(..) => None, + } + } + + /// If the URL is in a *relative scheme*, + /// return a mutable reference to the structured scheme data. + #[inline] + pub fn relative_scheme_data_mut<'a>(&'a mut self) -> Option<&'a mut RelativeSchemeData> { + match self.scheme_data { + SchemeData::Relative(ref mut scheme_data) => Some(scheme_data), + SchemeData::NonRelative(..) => None, + } + } + + /// If the URL is in a *relative scheme*, return its username. + #[inline] + pub fn username<'a>(&'a self) -> Option<&'a str> { + self.relative_scheme_data().map(|scheme_data| &*scheme_data.username) + } + + /// If the URL is in a *relative scheme*, return a mutable reference to its username. + #[inline] + pub fn username_mut<'a>(&'a mut self) -> Option<&'a mut String> { + self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.username) + } + + /// Percent-decode the URL’s username, if any. + /// + /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences + /// will be replaced � U+FFFD, the replacement character. + #[inline] + pub fn lossy_percent_decode_username(&self) -> Option<String> { + self.relative_scheme_data().map(|scheme_data| scheme_data.lossy_percent_decode_username()) + } + + /// If the URL is in a *relative scheme*, return its password, if any. + #[inline] + pub fn password<'a>(&'a self) -> Option<&'a str> { + self.relative_scheme_data().and_then(|scheme_data| + scheme_data.password.as_ref().map(|password| password as &str)) + } + + /// If the URL is in a *relative scheme*, return a mutable reference to its password, if any. + #[inline] + pub fn password_mut<'a>(&'a mut self) -> Option<&'a mut String> { + self.relative_scheme_data_mut().and_then(|scheme_data| scheme_data.password.as_mut()) + } + + /// Percent-decode the URL’s password, if any. + /// + /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences + /// will be replaced � U+FFFD, the replacement character. + #[inline] + pub fn lossy_percent_decode_password(&self) -> Option<String> { + self.relative_scheme_data().and_then(|scheme_data| + scheme_data.lossy_percent_decode_password()) + } + + /// Serialize the URL's username and password, if any. + /// + /// Format: "<username>:<password>@" + #[inline] + pub fn serialize_userinfo<'a>(&'a mut self) -> Option<String> { + self.relative_scheme_data().map(|scheme_data| scheme_data.serialize_userinfo()) + } + + /// If the URL is in a *relative scheme*, return its structured host. + #[inline] + pub fn host<'a>(&'a self) -> Option<&'a Host> { + self.relative_scheme_data().map(|scheme_data| &scheme_data.host) + } + + /// If the URL is in a *relative scheme*, return a mutable reference to its structured host. + #[inline] + pub fn host_mut<'a>(&'a mut self) -> Option<&'a mut Host> { + self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.host) + } + + /// If the URL is in a *relative scheme* and its host is a domain, + /// return the domain as a string. + #[inline] + pub fn domain<'a>(&'a self) -> Option<&'a str> { + self.relative_scheme_data().and_then(|scheme_data| scheme_data.domain()) + } + + /// If the URL is in a *relative scheme* and its host is a domain, + /// return a mutable reference to the domain string. + #[inline] + pub fn domain_mut<'a>(&'a mut self) -> Option<&'a mut String> { + self.relative_scheme_data_mut().and_then(|scheme_data| scheme_data.domain_mut()) + } + + /// If the URL is in a *relative scheme*, serialize its host as a string. + /// + /// A domain a returned as-is, an IPv6 address between [] square brackets. + #[inline] + pub fn serialize_host(&self) -> Option<String> { + self.relative_scheme_data().map(|scheme_data| scheme_data.host.serialize()) + } + + /// If the URL is in a *relative scheme* and has a port number, return it. + #[inline] + pub fn port<'a>(&'a self) -> Option<u16> { + self.relative_scheme_data().and_then(|scheme_data| scheme_data.port) + } + + /// If the URL is in a *relative scheme*, return a mutable reference to its port. + #[inline] + pub fn port_mut<'a>(&'a mut self) -> Option<&'a mut Option<u16>> { + self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.port) + } + + /// If the URL is in a *relative scheme* that is not a file-like, + /// return its port number, even if it is the default. + #[inline] + pub fn port_or_default(&self) -> Option<u16> { + self.relative_scheme_data().and_then(|scheme_data| scheme_data.port_or_default()) + } + + /// If the URL is in a *relative scheme*, return its path components. + #[inline] + pub fn path<'a>(&'a self) -> Option<&'a [String]> { + self.relative_scheme_data().map(|scheme_data| &*scheme_data.path) + } + + /// If the URL is in a *relative scheme*, return a mutable reference to its path components. + #[inline] + pub fn path_mut<'a>(&'a mut self) -> Option<&'a mut Vec<String>> { + self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.path) + } + + /// If the URL is in a *relative scheme*, serialize its path as a string. + /// + /// The returned string starts with a "/" slash, and components are separated by slashes. + /// A trailing slash represents an empty last component. + #[inline] + pub fn serialize_path(&self) -> Option<String> { + self.relative_scheme_data().map(|scheme_data| scheme_data.serialize_path()) + } + + /// Parse the URL’s query string, if any, as `application/x-www-form-urlencoded` + /// and return a vector of (key, value) pairs. + #[inline] + pub fn query_pairs(&self) -> Option<Vec<(String, String)>> { + self.query.as_ref().map(|query| form_urlencoded::parse(query.as_bytes())) + } + + /// Serialize an iterator of (key, value) pairs as `application/x-www-form-urlencoded` + /// and set it as the URL’s query string. + #[inline] + pub fn set_query_from_pairs<'a, I: Iterator<Item = (&'a str, &'a str)>>(&mut self, pairs: I) { + self.query = Some(form_urlencoded::serialize(pairs)); + } + + /// Percent-decode the URL’s query string, if any. + /// + /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences + /// will be replaced � U+FFFD, the replacement character. + #[inline] + pub fn lossy_percent_decode_query(&self) -> Option<String> { + self.query.as_ref().map(|value| lossy_utf8_percent_decode(value.as_bytes())) + } + + /// Percent-decode the URL’s fragment identifier, if any. + /// + /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences + /// will be replaced � U+FFFD, the replacement character. + #[inline] + pub fn lossy_percent_decode_fragment(&self) -> Option<String> { + self.fragment.as_ref().map(|value| lossy_utf8_percent_decode(value.as_bytes())) + } +} + + +impl rustc_serialize::Encodable for Url { + fn encode<S: rustc_serialize::Encoder>(&self, encoder: &mut S) -> Result<(), S::Error> { + encoder.emit_str(&self.to_string()) + } +} + + +impl rustc_serialize::Decodable for Url { + fn decode<D: rustc_serialize::Decoder>(decoder: &mut D) -> Result<Url, D::Error> { + Url::parse(&*try!(decoder.read_str())).map_err(|error| { + decoder.error(&format!("URL parsing error: {}", error)) + }) + } +} + + +impl fmt::Display for Url { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + try!(UrlNoFragmentFormatter{ url: self }.fmt(formatter)); + if let Some(ref fragment) = self.fragment { + try!(formatter.write_str("#")); + try!(formatter.write_str(fragment)); + } + Ok(()) + } +} + + +impl fmt::Display for SchemeData { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + match *self { + SchemeData::Relative(ref scheme_data) => scheme_data.fmt(formatter), + SchemeData::NonRelative(ref scheme_data) => scheme_data.fmt(formatter), + } + } +} + + +impl RelativeSchemeData { + /// Percent-decode the URL’s username. + /// + /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences + /// will be replaced � U+FFFD, the replacement character. + #[inline] + pub fn lossy_percent_decode_username(&self) -> String { + lossy_utf8_percent_decode(self.username.as_bytes()) + } + + /// Percent-decode the URL’s password, if any. + /// + /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences + /// will be replaced � U+FFFD, the replacement character. + #[inline] + pub fn lossy_percent_decode_password(&self) -> Option<String> { + self.password.as_ref().map(|value| lossy_utf8_percent_decode(value.as_bytes())) + } + + /// Assuming the URL is in the `file` scheme or similar, + /// convert its path to an absolute `std::path::Path`. + /// + /// **Note:** This does not actually check the URL’s `scheme`, + /// and may give nonsensical results for other schemes. + /// It is the user’s responsibility to check the URL’s scheme before calling this. + /// + /// The return type (when `Ok()`) is generic and can be either `std::path::posix::Path` + /// or `std::path::windows::Path`. + /// (Use `std::path::Path` to pick one of them depending on the local system.) + /// If the compiler can not infer the desired type from context, you may have to specifiy it: + /// + /// ```ignore + /// let path = url.to_file_path::<std::path::posix::Path>(); + /// ``` + /// + /// Returns `Err` if the host is neither empty nor `"localhost"`, + /// or if `Path::new_opt()` returns `None`. + /// (That is, if the percent-decoded path contains a NUL byte or, + /// for a Windows path, is not UTF-8.) + #[inline] + pub fn to_file_path(&self) -> Result<PathBuf, ()> { + // FIXME: Figure out what to do w.r.t host. + if !matches!(self.domain(), Some("") | Some("localhost")) { + return Err(()) + } + file_url_path_to_pathbuf(&self.path) + } + + /// If the host is a domain, return the domain as a string. + #[inline] + pub fn domain<'a>(&'a self) -> Option<&'a str> { + match self.host { + Host::Domain(ref domain) => Some(domain), + _ => None, + } + } + + /// If the host is a domain, return a mutable reference to the domain string. + #[inline] + pub fn domain_mut<'a>(&'a mut self) -> Option<&'a mut String> { + match self.host { + Host::Domain(ref mut domain) => Some(domain), + _ => None, + } + } + + /// Return the port number of the URL, even if it is the default. + /// Return `None` for file-like URLs. + #[inline] + pub fn port_or_default(&self) -> Option<u16> { + self.port.or(self.default_port) + } + + /// Serialize the path as a string. + /// + /// The returned string starts with a "/" slash, and components are separated by slashes. + /// A trailing slash represents an empty last component. + pub fn serialize_path(&self) -> String { + PathFormatter { + path: &self.path + }.to_string() + } + + /// Serialize the userinfo as a string. + /// + /// Format: "<username>:<password>@". + pub fn serialize_userinfo(&self) -> String { + UserInfoFormatter { + username: &self.username, + password: self.password.as_ref().map(|s| s as &str) + }.to_string() + } +} + + +impl fmt::Display for RelativeSchemeData { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + // Write the scheme-trailing double slashes. + try!(formatter.write_str("//")); + + // Write the user info. + try!(UserInfoFormatter { + username: &self.username, + password: self.password.as_ref().map(|s| s as &str) + }.fmt(formatter)); + + // Write the host. + try!(self.host.fmt(formatter)); + + // Write the port. + match self.port { + Some(port) => { + try!(write!(formatter, ":{}", port)); + }, + None => {} + } + + // Write the path. + PathFormatter { + path: &self.path + }.fmt(formatter) + } +} + + +#[cfg(unix)] +fn path_to_file_url_path(path: &Path) -> Result<Vec<String>, ()> { + use std::os::unix::prelude::OsStrExt; + if !path.is_absolute() { + return Err(()) + } + // skip the root component + Ok(path.components().skip(1).map(|c| { + percent_encode(c.as_os_str().as_bytes(), DEFAULT_ENCODE_SET) + }).collect()) +} + +#[cfg(windows)] +fn path_to_file_url_path(path: &Path) -> Result<Vec<String>, ()> { + path_to_file_url_path_windows(path) +} + +// Build this unconditionally to alleviate https://github.com/servo/rust-url/issues/102 +#[cfg_attr(not(windows), allow(dead_code))] +fn path_to_file_url_path_windows(path: &Path) -> Result<Vec<String>, ()> { + use std::path::{Prefix, Component}; + if !path.is_absolute() { + return Err(()) + } + let mut components = path.components(); + let disk = match components.next() { + Some(Component::Prefix(ref p)) => match p.kind() { + Prefix::Disk(byte) => byte, + _ => return Err(()), + }, + + // FIXME: do something with UNC and other prefixes? + _ => return Err(()) + }; + + // Start with the prefix, e.g. "C:" + let mut path = vec![format!("{}:", disk as char)]; + + for component in components { + if component == Component::RootDir { continue } + // FIXME: somehow work with non-unicode? + let part = match component.as_os_str().to_str() { + Some(s) => s, + None => return Err(()), + }; + path.push(percent_encode(part.as_bytes(), DEFAULT_ENCODE_SET)); + } + Ok(path) +} + +#[cfg(unix)] +fn file_url_path_to_pathbuf(path: &[String]) -> Result<PathBuf, ()> { + use std::ffi::OsStr; + use std::os::unix::prelude::OsStrExt; + use std::path::PathBuf; + + use percent_encoding::percent_decode_to; + + if path.is_empty() { + return Ok(PathBuf::from("/")) + } + let mut bytes = Vec::new(); + for path_part in path { + bytes.push(b'/'); + percent_decode_to(path_part.as_bytes(), &mut bytes); + } + let os_str = OsStr::from_bytes(&bytes); + let path = PathBuf::from(os_str); + debug_assert!(path.is_absolute(), + "to_file_path() failed to produce an absolute Path"); + Ok(path) +} + +#[cfg(windows)] +fn file_url_path_to_pathbuf(path: &[String]) -> Result<PathBuf, ()> { + file_url_path_to_pathbuf_windows(path) +} + +// Build this unconditionally to alleviate https://github.com/servo/rust-url/issues/102 +#[cfg_attr(not(windows), allow(dead_code))] +fn file_url_path_to_pathbuf_windows(path: &[String]) -> Result<PathBuf, ()> { + use percent_encoding::percent_decode; + + if path.is_empty() { + return Err(()) + } + let prefix = &*path[0]; + if prefix.len() != 2 || !parser::starts_with_ascii_alpha(prefix) + || prefix.as_bytes()[1] != b':' { + return Err(()) + } + let mut string = prefix.to_string(); + for path_part in &path[1..] { + string.push('\\'); + + // Currently non-unicode windows paths cannot be represented + match String::from_utf8(percent_decode(path_part.as_bytes())) { + Ok(s) => string.push_str(&s), + Err(..) => return Err(()), + } + } + let path = PathBuf::from(string); + debug_assert!(path.is_absolute(), + "to_file_path() failed to produce an absolute Path"); + Ok(path) +} diff --git a/deps/url-0.2.35/src/parser.rs b/deps/url-0.2.35/src/parser.rs new file mode 100644 index 000000000..3c4d15126 --- /dev/null +++ b/deps/url-0.2.35/src/parser.rs @@ -0,0 +1,747 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ascii::AsciiExt; +use std::error::Error; +use std::fmt::{self, Formatter}; + +use super::{UrlParser, Url, SchemeData, RelativeSchemeData, Host, SchemeType}; +use percent_encoding::{ + utf8_percent_encode_to, percent_encode, + SIMPLE_ENCODE_SET, DEFAULT_ENCODE_SET, USERINFO_ENCODE_SET, QUERY_ENCODE_SET +}; + + +pub type ParseResult<T> = Result<T, ParseError>; + + +macro_rules! simple_enum_error { + ($($name: ident => $description: expr,)+) => { + /// Errors that can occur during parsing. + #[derive(PartialEq, Eq, Clone, Copy, Debug)] + pub enum ParseError { + $( + $name, + )+ + } + + impl Error for ParseError { + fn description(&self) -> &str { + match *self { + $( + ParseError::$name => $description, + )+ + } + } + } + } +} + +simple_enum_error! { + EmptyHost => "empty host", + InvalidScheme => "invalid scheme", + InvalidPort => "invalid port number", + InvalidIpv6Address => "invalid IPv6 address", + InvalidDomainCharacter => "invalid domain character", + InvalidCharacter => "invalid character", + InvalidBackslash => "invalid backslash", + InvalidPercentEncoded => "invalid percent-encoded sequence", + InvalidAtSymbolInUser => "invalid @-symbol in user", + ExpectedTwoSlashes => "expected two slashes (//)", + ExpectedInitialSlash => "expected the input to start with a slash", + NonUrlCodePoint => "non URL code point", + RelativeUrlWithScheme => "relative URL with scheme", + RelativeUrlWithoutBase => "relative URL without a base", + RelativeUrlWithNonRelativeBase => "relative URL with a non-relative base", + NonAsciiDomainsNotSupportedYet => "non-ASCII domains are not supported yet", + CannotSetJavascriptFragment => "cannot set fragment on javascript: URL", + CannotSetPortWithFileLikeScheme => "cannot set port with file-like scheme", + CannotSetUsernameWithNonRelativeScheme => "cannot set username with non-relative scheme", + CannotSetPasswordWithNonRelativeScheme => "cannot set password with non-relative scheme", + CannotSetHostPortWithNonRelativeScheme => "cannot set host and port with non-relative scheme", + CannotSetHostWithNonRelativeScheme => "cannot set host with non-relative scheme", + CannotSetPortWithNonRelativeScheme => "cannot set port with non-relative scheme", + CannotSetPathWithNonRelativeScheme => "cannot set path with non-relative scheme", +} + +impl fmt::Display for ParseError { + fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + self.description().fmt(fmt) + } +} + +/// This is called on non-fatal parse errors. +/// +/// The handler can choose to continue or abort parsing by returning Ok() or Err(), respectively. +/// See the `UrlParser::error_handler` method. +/// +/// FIXME: make this a by-ref closure when that’s supported. +pub type ErrorHandler = fn(reason: ParseError) -> ParseResult<()>; + + +#[derive(PartialEq, Eq)] +pub enum Context { + UrlParser, + Setter, +} + + +pub fn parse_url(input: &str, parser: &UrlParser) -> ParseResult<Url> { + let input = input.trim_matches(&[' ', '\t', '\n', '\r', '\x0C'][..]); + let (scheme, remaining) = match parse_scheme(input, Context::UrlParser) { + Some((scheme, remaining)) => (scheme, remaining), + // No-scheme state + None => return match parser.base_url { + Some(&Url { ref scheme, scheme_data: SchemeData::Relative(ref base), + ref query, .. }) => { + let scheme_type = parser.get_scheme_type(&scheme); + parse_relative_url(input, scheme.clone(), scheme_type, base, query, parser) + }, + Some(_) => Err(ParseError::RelativeUrlWithNonRelativeBase), + None => Err(ParseError::RelativeUrlWithoutBase), + }, + }; + let scheme_type = parser.get_scheme_type(&scheme); + match scheme_type { + SchemeType::FileLike => { + // Relative state? + match parser.base_url { + Some(&Url { scheme: ref base_scheme, scheme_data: SchemeData::Relative(ref base), + ref query, .. }) + if scheme == *base_scheme => { + parse_relative_url(remaining, scheme, scheme_type, base, query, parser) + }, + // FIXME: Should not have to use a made-up base URL. + _ => parse_relative_url(remaining, scheme, scheme_type, &RelativeSchemeData { + username: String::new(), password: None, host: Host::Domain(String::new()), + port: None, default_port: None, path: Vec::new() + }, &None, parser) + } + }, + SchemeType::Relative(..) => { + match parser.base_url { + Some(&Url { scheme: ref base_scheme, scheme_data: SchemeData::Relative(ref base), + ref query, .. }) + if scheme == *base_scheme && !remaining.starts_with("//") => { + try!(parser.parse_error(ParseError::RelativeUrlWithScheme)); + parse_relative_url(remaining, scheme, scheme_type, base, query, parser) + }, + _ => parse_absolute_url(scheme, scheme_type, remaining, parser), + } + }, + SchemeType::NonRelative => { + // Scheme data state + let (scheme_data, remaining) = try!(parse_scheme_data(remaining, parser)); + let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); + Ok(Url { scheme: scheme, scheme_data: SchemeData::NonRelative(scheme_data), + query: query, fragment: fragment }) + } + } +} + + +pub fn parse_scheme<'a>(input: &'a str, context: Context) -> Option<(String, &'a str)> { + if input.is_empty() || !starts_with_ascii_alpha(input) { + return None + } + for (i, c) in input.char_indices() { + match c { + 'a'...'z' | 'A'...'Z' | '0'...'9' | '+' | '-' | '.' => (), + ':' => return Some(( + input[..i].to_ascii_lowercase(), + &input[i + 1..], + )), + _ => return None, + } + } + // EOF before ':' + match context { + Context::Setter => Some((input.to_ascii_lowercase(), "")), + Context::UrlParser => None + } +} + + +fn parse_absolute_url<'a>(scheme: String, scheme_type: SchemeType, + input: &'a str, parser: &UrlParser) -> ParseResult<Url> { + // Authority first slash state + let remaining = try!(skip_slashes(input, parser)); + // Authority state + let (username, password, remaining) = try!(parse_userinfo(remaining, parser)); + // Host state + let (host, port, default_port, remaining) = try!(parse_host(remaining, scheme_type, parser)); + let (path, remaining) = try!(parse_path_start( + remaining, Context::UrlParser, scheme_type, parser)); + let scheme_data = SchemeData::Relative(RelativeSchemeData { + username: username, password: password, + host: host, port: port, default_port: default_port, + path: path }); + let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); + Ok(Url { scheme: scheme, scheme_data: scheme_data, query: query, fragment: fragment }) +} + + +fn parse_relative_url<'a>(input: &'a str, scheme: String, scheme_type: SchemeType, + base: &RelativeSchemeData, base_query: &Option<String>, + parser: &UrlParser) + -> ParseResult<Url> { + let mut chars = input.chars(); + match chars.next() { + Some('/') | Some('\\') => { + let ch = chars.next(); + // Relative slash state + if matches!(ch, Some('/') | Some('\\')) { + if ch == Some('\\') { + try!(parser.parse_error(ParseError::InvalidBackslash)) + } + if scheme_type == SchemeType::FileLike { + // File host state + let remaining = &input[2..]; + let (host, remaining) = if remaining.len() >= 2 + && starts_with_ascii_alpha(remaining) + && matches!(remaining.as_bytes()[1], b':' | b'|') + && (remaining.len() == 2 + || matches!(remaining.as_bytes()[2], + b'/' | b'\\' | b'?' | b'#')) + { + // Windows drive letter quirk + (Host::Domain(String::new()), remaining) + } else { + try!(parse_file_host(remaining, parser)) + }; + let (path, remaining) = try!(parse_path_start( + remaining, Context::UrlParser, scheme_type, parser)); + let scheme_data = SchemeData::Relative(RelativeSchemeData { + username: String::new(), password: None, + host: host, port: None, default_port: None, path: path + }); + let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); + Ok(Url { scheme: scheme, scheme_data: scheme_data, + query: query, fragment: fragment }) + } else { + parse_absolute_url(scheme, scheme_type, input, parser) + } + } else { + // Relative path state + let (path, remaining) = try!(parse_path( + &[], &input[1..], Context::UrlParser, scheme_type, parser)); + let scheme_data = SchemeData::Relative(if scheme_type == SchemeType::FileLike { + RelativeSchemeData { + username: String::new(), password: None, host: + Host::Domain(String::new()), port: None, default_port: None, path: path + } + } else { + RelativeSchemeData { + username: base.username.clone(), + password: base.password.clone(), + host: base.host.clone(), + port: base.port.clone(), + default_port: base.default_port.clone(), + path: path + } + }); + let (query, fragment) = try!( + parse_query_and_fragment(remaining, parser)); + Ok(Url { scheme: scheme, scheme_data: scheme_data, + query: query, fragment: fragment }) + } + }, + Some('?') => { + let (query, fragment) = try!(parse_query_and_fragment(input, parser)); + Ok(Url { scheme: scheme, scheme_data: SchemeData::Relative(base.clone()), + query: query, fragment: fragment }) + }, + Some('#') => { + let fragment = Some(try!(parse_fragment(&input[1..], parser))); + Ok(Url { scheme: scheme, scheme_data: SchemeData::Relative(base.clone()), + query: base_query.clone(), fragment: fragment }) + } + None => { + Ok(Url { scheme: scheme, scheme_data: SchemeData::Relative(base.clone()), + query: base_query.clone(), fragment: None }) + } + _ => { + let (scheme_data, remaining) = if scheme_type == SchemeType::FileLike + && input.len() >= 2 + && starts_with_ascii_alpha(input) + && matches!(input.as_bytes()[1], b':' | b'|') + && (input.len() == 2 + || matches!(input.as_bytes()[2], b'/' | b'\\' | b'?' | b'#')) + { + // Windows drive letter quirk + let (path, remaining) = try!(parse_path( + &[], input, Context::UrlParser, scheme_type, parser)); + (SchemeData::Relative(RelativeSchemeData { + username: String::new(), password: None, + host: Host::Domain(String::new()), + port: None, + default_port: None, + path: path + }), remaining) + } else { + let base_path = &base.path[..base.path.len() - 1]; + // Relative path state + let (path, remaining) = try!(parse_path( + base_path, input, Context::UrlParser, scheme_type, parser)); + (SchemeData::Relative(RelativeSchemeData { + username: base.username.clone(), + password: base.password.clone(), + host: base.host.clone(), + port: base.port.clone(), + default_port: base.default_port.clone(), + path: path + }), remaining) + }; + let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); + Ok(Url { scheme: scheme, scheme_data: scheme_data, + query: query, fragment: fragment }) + } + } +} + + +fn skip_slashes<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<&'a str> { + let first_non_slash = input.find(|c| !matches!(c, '/' | '\\')).unwrap_or(input.len()); + if &input[..first_non_slash] != "//" { + try!(parser.parse_error(ParseError::ExpectedTwoSlashes)); + } + Ok(&input[first_non_slash..]) +} + + +fn parse_userinfo<'a>(input: &'a str, parser: &UrlParser) + -> ParseResult<(String, Option<String>, &'a str)> { + let mut last_at = None; + for (i, c) in input.char_indices() { + match c { + '@' => { + if last_at.is_some() { + try!(parser.parse_error(ParseError::InvalidAtSymbolInUser)) + } + last_at = Some(i) + }, + '/' | '\\' | '?' | '#' => break, + _ => (), + } + } + let (input, remaining) = match last_at { + Some(at) => (&input[..at], &input[at + 1..]), + None => return Ok((String::new(), None, input)), + }; + + let mut username = String::new(); + let mut password = None; + for (i, c, next_i) in input.char_ranges() { + match c { + ':' => { + password = Some(try!(parse_password(&input[i + 1..], parser))); + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => { + try!(check_url_code_point(input, i, c, parser)); + // The spec says to use the default encode set, + // but also replaces '@' by '%40' in an earlier step. + utf8_percent_encode_to(&input[i..next_i], + USERINFO_ENCODE_SET, &mut username); + } + } + } + Ok((username, password, remaining)) +} + + +fn parse_password(input: &str, parser: &UrlParser) -> ParseResult<String> { + let mut password = String::new(); + for (i, c, next_i) in input.char_ranges() { + match c { + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => { + try!(check_url_code_point(input, i, c, parser)); + // The spec says to use the default encode set, + // but also replaces '@' by '%40' in an earlier step. + utf8_percent_encode_to(&input[i..next_i], + USERINFO_ENCODE_SET, &mut password); + } + } + } + Ok(password) +} + + +pub fn parse_host<'a>(input: &'a str, scheme_type: SchemeType, parser: &UrlParser) + -> ParseResult<(Host, Option<u16>, Option<u16>, &'a str)> { + let (host, remaining) = try!(parse_hostname(input, parser)); + let (port, default_port, remaining) = if remaining.starts_with(":") { + try!(parse_port(&remaining[1..], scheme_type, parser)) + } else { + (None, scheme_type.default_port(), remaining) + }; + Ok((host, port, default_port, remaining)) +} + + +pub fn parse_hostname<'a>(input: &'a str, parser: &UrlParser) + -> ParseResult<(Host, &'a str)> { + let mut inside_square_brackets = false; + let mut host_input = String::new(); + let mut end = input.len(); + for (i, c) in input.char_indices() { + match c { + ':' if !inside_square_brackets => { + end = i; + break + }, + '/' | '\\' | '?' | '#' => { + end = i; + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + c => { + match c { + '[' => inside_square_brackets = true, + ']' => inside_square_brackets = false, + _ => (), + } + host_input.push(c) + } + } + } + let host = try!(Host::parse(&host_input)); + Ok((host, &input[end..])) +} + + +pub fn parse_port<'a>(input: &'a str, scheme_type: SchemeType, parser: &UrlParser) + -> ParseResult<(Option<u16>, Option<u16>, &'a str)> { + let mut port = 0; + let mut has_any_digit = false; + let mut end = input.len(); + for (i, c) in input.char_indices() { + match c { + '0'...'9' => { + port = port * 10 + (c as u32 - '0' as u32); + if port > ::std::u16::MAX as u32 { + return Err(ParseError::InvalidPort) + } + has_any_digit = true; + }, + '/' | '\\' | '?' | '#' => { + end = i; + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => return Err(ParseError::InvalidPort) + } + } + let default_port = scheme_type.default_port(); + let mut port = Some(port as u16); + if !has_any_digit || port == default_port { + port = None; + } + return Ok((port, default_port, &input[end..])) +} + + +fn parse_file_host<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<(Host, &'a str)> { + let mut host_input = String::new(); + let mut end = input.len(); + for (i, c) in input.char_indices() { + match c { + '/' | '\\' | '?' | '#' => { + end = i; + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => host_input.push(c) + } + } + let host = if host_input.is_empty() { + Host::Domain(String::new()) + } else { + try!(Host::parse(&host_input)) + }; + Ok((host, &input[end..])) +} + + +pub fn parse_standalone_path(input: &str, parser: &UrlParser) + -> ParseResult<(Vec<String>, Option<String>, Option<String>)> { + if !input.starts_with("/") { + if input.starts_with("\\") { + try!(parser.parse_error(ParseError::InvalidBackslash)); + } else { + return Err(ParseError::ExpectedInitialSlash) + } + } + let (path, remaining) = try!(parse_path( + &[], &input[1..], Context::UrlParser, SchemeType::Relative(0), parser)); + let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); + Ok((path, query, fragment)) +} + + +pub fn parse_path_start<'a>(input: &'a str, context: Context, scheme_type: SchemeType, + parser: &UrlParser) + -> ParseResult<(Vec<String>, &'a str)> { + let mut i = 0; + // Relative path start state + match input.chars().next() { + Some('/') => i = 1, + Some('\\') => { + try!(parser.parse_error(ParseError::InvalidBackslash)); + i = 1; + }, + _ => () + } + parse_path(&[], &input[i..], context, scheme_type, parser) +} + + +fn parse_path<'a>(base_path: &[String], input: &'a str, context: Context, + scheme_type: SchemeType, parser: &UrlParser) + -> ParseResult<(Vec<String>, &'a str)> { + // Relative path state + let mut path = base_path.to_vec(); + let mut iter = input.char_ranges(); + let mut end; + loop { + let mut path_part = String::new(); + let mut ends_with_slash = false; + end = input.len(); + while let Some((i, c, next_i)) = iter.next() { + match c { + '/' => { + ends_with_slash = true; + end = i; + break + }, + '\\' => { + try!(parser.parse_error(ParseError::InvalidBackslash)); + ends_with_slash = true; + end = i; + break + }, + '?' | '#' if context == Context::UrlParser => { + end = i; + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => { + try!(check_url_code_point(input, i, c, parser)); + utf8_percent_encode_to(&input[i..next_i], + DEFAULT_ENCODE_SET, &mut path_part); + } + } + } + match &*path_part { + ".." | ".%2e" | ".%2E" | "%2e." | "%2E." | + "%2e%2e" | "%2E%2e" | "%2e%2E" | "%2E%2E" => { + path.pop(); + if !ends_with_slash { + path.push(String::new()); + } + }, + "." | "%2e" | "%2E" => { + if !ends_with_slash { + path.push(String::new()); + } + }, + _ => { + if scheme_type == SchemeType::FileLike + && path.is_empty() + && path_part.len() == 2 + && starts_with_ascii_alpha(&path_part) + && path_part.as_bytes()[1] == b'|' { + // Windows drive letter quirk + unsafe { + path_part.as_mut_vec()[1] = b':' + } + } + path.push(path_part) + } + } + if !ends_with_slash { + break + } + } + Ok((path, &input[end..])) +} + + +fn parse_scheme_data<'a>(input: &'a str, parser: &UrlParser) + -> ParseResult<(String, &'a str)> { + let mut scheme_data = String::new(); + let mut end = input.len(); + for (i, c, next_i) in input.char_ranges() { + match c { + '?' | '#' => { + end = i; + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => { + try!(check_url_code_point(input, i, c, parser)); + utf8_percent_encode_to(&input[i..next_i], + SIMPLE_ENCODE_SET, &mut scheme_data); + } + } + } + Ok((scheme_data, &input[end..])) +} + + +fn parse_query_and_fragment(input: &str, parser: &UrlParser) + -> ParseResult<(Option<String>, Option<String>)> { + match input.chars().next() { + Some('#') => Ok((None, Some(try!(parse_fragment(&input[1..], parser))))), + Some('?') => { + let (query, remaining) = try!(parse_query( + &input[1..], Context::UrlParser, parser)); + let fragment = match remaining { + Some(remaining) => Some(try!(parse_fragment(remaining, parser))), + None => None + }; + Ok((Some(query), fragment)) + }, + None => Ok((None, None)), + _ => panic!("Programming error. parse_query_and_fragment() should not \ + have been called with input \"{}\"", input) + } +} + + +pub fn parse_query<'a>(input: &'a str, context: Context, parser: &UrlParser) + -> ParseResult<(String, Option<&'a str>)> { + let mut query = String::new(); + let mut remaining = None; + for (i, c) in input.char_indices() { + match c { + '#' if context == Context::UrlParser => { + remaining = Some(&input[i + 1..]); + break + }, + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => { + try!(check_url_code_point(input, i, c, parser)); + query.push(c); + } + } + } + + let query_bytes = parser.query_encoding_override.encode(&query); + Ok((percent_encode(&query_bytes, QUERY_ENCODE_SET), remaining)) +} + + +pub fn parse_fragment<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<String> { + let mut fragment = String::new(); + for (i, c, next_i) in input.char_ranges() { + match c { + '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), + _ => { + try!(check_url_code_point(input, i, c, parser)); + utf8_percent_encode_to(&input[i..next_i], + SIMPLE_ENCODE_SET, &mut fragment); + } + } + } + Ok(fragment) +} + + +#[inline] +pub fn starts_with_ascii_alpha(string: &str) -> bool { + matches!(string.as_bytes()[0], b'a'...b'z' | b'A'...b'Z') +} + +#[inline] +fn is_ascii_hex_digit(byte: u8) -> bool { + matches!(byte, b'a'...b'f' | b'A'...b'F' | b'0'...b'9') +} + +#[inline] +fn starts_with_2_hex(input: &str) -> bool { + input.len() >= 2 + && is_ascii_hex_digit(input.as_bytes()[0]) + && is_ascii_hex_digit(input.as_bytes()[1]) +} + +#[inline] +fn is_url_code_point(c: char) -> bool { + matches!(c, + 'a'...'z' | + 'A'...'Z' | + '0'...'9' | + '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | + '.' | '/' | ':' | ';' | '=' | '?' | '@' | '_' | '~' | + '\u{A0}'...'\u{D7FF}' | '\u{E000}'...'\u{FDCF}' | '\u{FDF0}'...'\u{FFFD}' | + '\u{10000}'...'\u{1FFFD}' | '\u{20000}'...'\u{2FFFD}' | + '\u{30000}'...'\u{3FFFD}' | '\u{40000}'...'\u{4FFFD}' | + '\u{50000}'...'\u{5FFFD}' | '\u{60000}'...'\u{6FFFD}' | + '\u{70000}'...'\u{7FFFD}' | '\u{80000}'...'\u{8FFFD}' | + '\u{90000}'...'\u{9FFFD}' | '\u{A0000}'...'\u{AFFFD}' | + '\u{B0000}'...'\u{BFFFD}' | '\u{C0000}'...'\u{CFFFD}' | + '\u{D0000}'...'\u{DFFFD}' | '\u{E1000}'...'\u{EFFFD}' | + '\u{F0000}'...'\u{FFFFD}' | '\u{100000}'...'\u{10FFFD}') +} + +// Non URL code points: +// U+0000 to U+0020 (space) +// " # % < > [ \ ] ^ ` { | } +// U+007F to U+009F +// surrogates +// U+FDD0 to U+FDEF +// Last two of each plane: U+__FFFE to U+__FFFF for __ in 00 to 10 hex + + +pub trait StrCharRanges<'a> { + fn char_ranges(&self) -> CharRanges<'a>; +} + + +impl<'a> StrCharRanges<'a> for &'a str { + #[inline] + fn char_ranges(&self) -> CharRanges<'a> { + CharRanges { slice: *self, position: 0 } + } +} + +pub struct CharRanges<'a> { + slice: &'a str, + position: usize, +} + +impl<'a> Iterator for CharRanges<'a> { + type Item = (usize, char, usize); + + #[inline] + fn next(&mut self) -> Option<(usize, char, usize)> { + match self.slice[self.position..].chars().next() { + Some(ch) => { + let position = self.position; + self.position = position + ch.len_utf8(); + Some((position, ch, position + ch.len_utf8())) + } + None => None, + } + } +} + +#[inline] +fn check_url_code_point(input: &str, i: usize, c: char, parser: &UrlParser) + -> ParseResult<()> { + if c == '%' { + if !starts_with_2_hex(&input[i + 1..]) { + try!(parser.parse_error(ParseError::InvalidPercentEncoded)); + } + } else if !is_url_code_point(c) { + try!(parser.parse_error(ParseError::NonUrlCodePoint)); + } + Ok(()) +} diff --git a/deps/url-0.2.35/src/percent_encoding.rs b/deps/url-0.2.35/src/percent_encoding.rs new file mode 100644 index 000000000..90b8f90f6 --- /dev/null +++ b/deps/url-0.2.35/src/percent_encoding.rs @@ -0,0 +1,146 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#[path = "encode_sets.rs"] +mod encode_sets; + +/// Represents a set of characters / bytes that should be percent-encoded. +/// +/// See [encode sets specification](http://url.spec.whatwg.org/#simple-encode-set). +/// +/// Different characters need to be encoded in different parts of an URL. +/// For example, a literal `?` question mark in an URL’s path would indicate +/// the start of the query string. +/// A question mark meant to be part of the path therefore needs to be percent-encoded. +/// In the query string however, a question mark does not have any special meaning +/// and does not need to be percent-encoded. +/// +/// Since the implementation details of `EncodeSet` are private, +/// the set of available encode sets is not extensible beyond the ones +/// provided here. +/// If you need a different encode set, +/// please [file a bug](https://github.com/servo/rust-url/issues) +/// explaining the use case. +#[derive(Copy, Clone)] +pub struct EncodeSet { + map: &'static [&'static str; 256], +} + +/// This encode set is used for fragment identifier and non-relative scheme data. +pub static SIMPLE_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::SIMPLE }; + +/// This encode set is used in the URL parser for query strings. +pub static QUERY_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::QUERY }; + +/// This encode set is used for path components. +pub static DEFAULT_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::DEFAULT }; + +/// This encode set is used in the URL parser for usernames and passwords. +pub static USERINFO_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::USERINFO }; + +/// This encode set should be used when setting the password field of a parsed URL. +pub static PASSWORD_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::PASSWORD }; + +/// This encode set should be used when setting the username field of a parsed URL. +pub static USERNAME_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::USERNAME }; + +/// This encode set is used in `application/x-www-form-urlencoded` serialization. +pub static FORM_URLENCODED_ENCODE_SET: EncodeSet = EncodeSet { + map: &encode_sets::FORM_URLENCODED, +}; + + +/// Percent-encode the given bytes, and push the result to `output`. +/// +/// The pushed strings are within the ASCII range. +#[inline] +pub fn percent_encode_to(input: &[u8], encode_set: EncodeSet, output: &mut String) { + for &byte in input { + output.push_str(encode_set.map[byte as usize]) + } +} + + +/// Percent-encode the given bytes. +/// +/// The returned string is within the ASCII range. +#[inline] +pub fn percent_encode(input: &[u8], encode_set: EncodeSet) -> String { + let mut output = String::new(); + percent_encode_to(input, encode_set, &mut output); + output +} + + +/// Percent-encode the UTF-8 encoding of the given string, and push the result to `output`. +/// +/// The pushed strings are within the ASCII range. +#[inline] +pub fn utf8_percent_encode_to(input: &str, encode_set: EncodeSet, output: &mut String) { + percent_encode_to(input.as_bytes(), encode_set, output) +} + + +/// Percent-encode the UTF-8 encoding of the given string. +/// +/// The returned string is within the ASCII range. +#[inline] +pub fn utf8_percent_encode(input: &str, encode_set: EncodeSet) -> String { + let mut output = String::new(); + utf8_percent_encode_to(input, encode_set, &mut output); + output +} + + +/// Percent-decode the given bytes, and push the result to `output`. +pub fn percent_decode_to(input: &[u8], output: &mut Vec<u8>) { + let mut i = 0; + while i < input.len() { + let c = input[i]; + if c == b'%' && i + 2 < input.len() { + if let (Some(h), Some(l)) = (from_hex(input[i + 1]), from_hex(input[i + 2])) { + output.push(h * 0x10 + l); + i += 3; + continue + } + } + + output.push(c); + i += 1; + } +} + + +/// Percent-decode the given bytes. +#[inline] +pub fn percent_decode(input: &[u8]) -> Vec<u8> { + let mut output = Vec::new(); + percent_decode_to(input, &mut output); + output +} + + +/// Percent-decode the given bytes, and decode the result as UTF-8. +/// +/// This is “lossy”: invalid UTF-8 percent-encoded byte sequences +/// will be replaced � U+FFFD, the replacement character. +#[inline] +pub fn lossy_utf8_percent_decode(input: &[u8]) -> String { + String::from_utf8_lossy(&percent_decode(input)).to_string() +} + +#[inline] +pub fn from_hex(byte: u8) -> Option<u8> { + match byte { + b'0' ... b'9' => Some(byte - b'0'), // 0..9 + b'A' ... b'F' => Some(byte + 10 - b'A'), // A..F + b'a' ... b'f' => Some(byte + 10 - b'a'), // a..f + _ => None + } +} diff --git a/deps/url-0.2.35/src/punycode.rs b/deps/url-0.2.35/src/punycode.rs new file mode 100644 index 000000000..3ca7f4b26 --- /dev/null +++ b/deps/url-0.2.35/src/punycode.rs @@ -0,0 +1,267 @@ +// Copyright 2013 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Punycode ([RFC 3492](http://tools.ietf.org/html/rfc3492)) implementation. +//! +//! Since Punycode fundamentally works on unicode code points, +//! `encode` and `decode` take and return slices and vectors of `char`. +//! `encode_str` and `decode_to_string` provide convenience wrappers +//! that convert from and to Rust’s UTF-8 based `str` and `String` types. + +use std::u32; +use std::char; +use std::ascii::AsciiExt; + +// Bootstring parameters for Punycode +static BASE: u32 = 36; +static T_MIN: u32 = 1; +static T_MAX: u32 = 26; +static SKEW: u32 = 38; +static DAMP: u32 = 700; +static INITIAL_BIAS: u32 = 72; +static INITIAL_N: u32 = 0x80; +static DELIMITER: char = '-'; + + +#[inline] +fn adapt(mut delta: u32, num_points: u32, first_time: bool) -> u32 { + delta /= if first_time { DAMP } else { 2 }; + delta += delta / num_points; + let mut k = 0; + while delta > ((BASE - T_MIN) * T_MAX) / 2 { + delta /= BASE - T_MIN; + k += BASE; + } + k + (((BASE - T_MIN + 1) * delta) / (delta + SKEW)) +} + + +/// Convert Punycode to an Unicode `String`. +/// +/// This is a convenience wrapper around `decode`. +#[inline] +pub fn decode_to_string(input: &str) -> Option<String> { + decode(input).map(|chars| chars.into_iter().collect()) +} + + +/// Convert Punycode to Unicode. +/// +/// Return None on malformed input or overflow. +/// Overflow can only happen on inputs that take more than +/// 63 encoded bytes, the DNS limit on domain name labels. +pub fn decode(input: &str) -> Option<Vec<char>> { + // Handle "basic" (ASCII) code points. + // They are encoded as-is before the last delimiter, if any. + let (mut output, input) = match input.rfind(DELIMITER) { + None => (Vec::new(), input), + Some(position) => ( + input[..position].chars().collect(), + if position > 0 { &input[position + 1..] } else { input } + ) + }; + let mut code_point = INITIAL_N; + let mut bias = INITIAL_BIAS; + let mut i = 0; + let mut iter = input.bytes(); + loop { + let previous_i = i; + let mut weight = 1; + let mut k = BASE; + let mut byte = match iter.next() { + None => break, + Some(byte) => byte, + }; + // Decode a generalized variable-length integer into delta, + // which gets added to i. + loop { + let digit = match byte { + byte @ b'0' ... b'9' => byte - b'0' + 26, + byte @ b'A' ... b'Z' => byte - b'A', + byte @ b'a' ... b'z' => byte - b'a', + _ => return None + } as u32; + if digit > (u32::MAX - i) / weight { + return None // Overflow + } + i += digit * weight; + let t = if k <= bias { T_MIN } + else if k >= bias + T_MAX { T_MAX } + else { k - bias }; + if digit < t { + break + } + if weight > u32::MAX / (BASE - t) { + return None // Overflow + } + weight *= BASE - t; + k += BASE; + byte = match iter.next() { + None => return None, // End of input before the end of this delta + Some(byte) => byte, + }; + } + let length = output.len() as u32; + bias = adapt(i - previous_i, length + 1, previous_i == 0); + if i / (length + 1) > u32::MAX - code_point { + return None // Overflow + } + // i was supposed to wrap around from length+1 to 0, + // incrementing code_point each time. + code_point += i / (length + 1); + i %= length + 1; + let c = match char::from_u32(code_point) { + Some(c) => c, + None => return None + }; + output.insert(i as usize, c); + i += 1; + } + Some(output) +} + + +/// Convert an Unicode `str` to Punycode. +/// +/// This is a convenience wrapper around `encode`. +#[inline] +pub fn encode_str(input: &str) -> Option<String> { + encode(&input.chars().collect::<Vec<char>>()) +} + + +/// Convert Unicode to Punycode. +/// +/// Return None on overflow, which can only happen on inputs that would take more than +/// 63 encoded bytes, the DNS limit on domain name labels. +pub fn encode(input: &[char]) -> Option<String> { + // Handle "basic" (ASCII) code points. They are encoded as-is. + let output_bytes = input.iter().filter_map(|&c| + if c.is_ascii() { Some(c as u8) } else { None } + ).collect(); + let mut output = unsafe { String::from_utf8_unchecked(output_bytes) }; + let basic_length = output.len() as u32; + if basic_length > 0 { + output.push_str("-") + } + let mut code_point = INITIAL_N; + let mut delta = 0; + let mut bias = INITIAL_BIAS; + let mut processed = basic_length; + let input_length = input.len() as u32; + while processed < input_length { + // All code points < code_point have been handled already. + // Find the next larger one. + let min_code_point = input.iter().map(|&c| c as u32) + .filter(|&c| c >= code_point).min().unwrap(); + if min_code_point - code_point > (u32::MAX - delta) / (processed + 1) { + return None // Overflow + } + // Increase delta to advance the decoder’s <code_point,i> state to <min_code_point,0> + delta += (min_code_point - code_point) * (processed + 1); + code_point = min_code_point; + for &c in input { + let c = c as u32; + if c < code_point { + delta += 1; + if delta == 0 { + return None // Overflow + } + } + if c == code_point { + // Represent delta as a generalized variable-length integer: + let mut q = delta; + let mut k = BASE; + loop { + let t = if k <= bias { T_MIN } + else if k >= bias + T_MAX { T_MAX } + else { k - bias }; + if q < t { + break + } + let value = t + ((q - t) % (BASE - t)); + value_to_digit(value, &mut output); + q = (q - t) / (BASE - t); + k += BASE; + } + value_to_digit(q, &mut output); + bias = adapt(delta, processed + 1, processed == basic_length); + delta = 0; + processed += 1; + } + } + delta += 1; + code_point += 1; + } + Some(output) +} + + +#[inline] +fn value_to_digit(value: u32, output: &mut String) { + let code_point = match value { + 0 ... 25 => value + 0x61, // a..z + 26 ... 35 => value - 26 + 0x30, // 0..9 + _ => panic!() + }; + unsafe { output.as_mut_vec().push(code_point as u8) } +} + + +#[cfg(test)] +mod tests { + use super::{decode, encode_str}; + use rustc_serialize::json::{Json, Object}; + + fn one_test(description: &str, decoded: &str, encoded: &str) { + match decode(encoded) { + None => panic!("Decoding {} failed.", encoded), + Some(result) => { + let result = result.into_iter().collect::<String>(); + assert!(result == decoded, + format!("Incorrect decoding of {}:\n {}\n!= {}\n{}", + encoded, result, decoded, description)) + } + } + + match encode_str(decoded) { + None => panic!("Encoding {} failed.", decoded), + Some(result) => { + assert!(result == encoded, + format!("Incorrect encoding of {}:\n {}\n!= {}\n{}", + decoded, result, encoded, description)) + } + } + } + + fn get_string<'a>(map: &'a Object, key: &str) -> &'a str { + match map.get(&key.to_string()) { + Some(&Json::String(ref s)) => s, + None => "", + _ => panic!(), + } + } + + #[test] + fn test_punycode() { + + match Json::from_str(include_str!("punycode_tests.json")) { + Ok(Json::Array(tests)) => for test in &tests { + match test { + &Json::Object(ref o) => one_test( + get_string(o, "description"), + get_string(o, "decoded"), + get_string(o, "encoded") + ), + _ => panic!(), + } + }, + other => panic!("{:?}", other) + } + } +} diff --git a/deps/url-0.2.35/src/punycode_tests.json b/deps/url-0.2.35/src/punycode_tests.json new file mode 100644 index 000000000..86785b124 --- /dev/null +++ b/deps/url-0.2.35/src/punycode_tests.json @@ -0,0 +1,120 @@ +[ +{ + "description": "These tests are copied from https://github.com/bestiejs/punycode.js/blob/master/tests/tests.js , used under the MIT license.", + "decoded": "", + "encoded": "" +}, +{ + "description": "a single basic code point", + "decoded": "Bach", + "encoded": "Bach-" +}, +{ + "description": "a single non-ASCII character", + "decoded": "\u00FC", + "encoded": "tda" +}, +{ + "description": "multiple non-ASCII characters", + "decoded": "\u00FC\u00EB\u00E4\u00F6\u2665", + "encoded": "4can8av2009b" +}, +{ + "description": "mix of ASCII and non-ASCII characters", + "decoded": "b\u00FCcher", + "encoded": "bcher-kva" +}, +{ + "description": "long string with both ASCII and non-ASCII characters", + "decoded": "Willst du die Bl\u00FCthe des fr\u00FChen, die Fr\u00FCchte des sp\u00E4teren Jahres", + "encoded": "Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal" +}, +{ + "description": "Arabic (Egyptian)", + "decoded": "\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F", + "encoded": "egbpdaj6bu4bxfgehfvwxn" +}, +{ + "description": "Chinese (simplified)", + "decoded": "\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2d\u6587", + "encoded": "ihqwcrb4cv8a8dqg056pqjye" +}, +{ + "description": "Chinese (traditional)", + "decoded": "\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587", + "encoded": "ihqwctvzc91f659drss3x8bo0yb" +}, +{ + "description": "Czech", + "decoded": "Pro\u010Dprost\u011Bnemluv\u00ED\u010Desky", + "encoded": "Proprostnemluvesky-uyb24dma41a" +}, +{ + "description": "Hebrew", + "decoded": "\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA", + "encoded": "4dbcagdahymbxekheh6e0a7fei0b" +}, +{ + "description": "Hindi (Devanagari)", + "decoded": "\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902", + "encoded": "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd" +}, +{ + "description": "Japanese (kanji and hiragana)", + "decoded": "\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B", + "encoded": "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa" +}, +{ + "description": "Korean (Hangul syllables)", + "decoded": "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C", + "encoded": "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c" +}, +{ + "description": "Russian (Cyrillic)", + "decoded": "\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A\u0438", + "encoded": "b1abfaaepdrnnbgefbadotcwatmq2g4l" +}, +{ + "description": "Spanish", + "decoded": "Porqu\u00E9nopuedensimplementehablarenEspa\u00F1ol", + "encoded": "PorqunopuedensimplementehablarenEspaol-fmd56a" +}, +{ + "description": "Vietnamese", + "decoded": "T\u1EA1isaoh\u1ECDkh\u00F4ngth\u1EC3ch\u1EC9n\u00F3iti\u1EBFngVi\u1EC7t", + "encoded": "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g" +}, +{ + "decoded": "3\u5E74B\u7D44\u91D1\u516B\u5148\u751F", + "encoded": "3B-ww4c5e180e575a65lsy2b" +}, +{ + "decoded": "\u5B89\u5BA4\u5948\u7F8E\u6075-with-SUPER-MONKEYS", + "encoded": "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n" +}, +{ + "decoded": "Hello-Another-Way-\u305D\u308C\u305E\u308C\u306E\u5834\u6240", + "encoded": "Hello-Another-Way--fc4qua05auwb3674vfr0b" +}, +{ + "decoded": "\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B2", + "encoded": "2-u9tlzr9756bt3uc0v" +}, +{ + "decoded": "Maji\u3067Koi\u3059\u308B5\u79D2\u524D", + "encoded": "MajiKoi5-783gue6qz075azm5e" +}, +{ + "decoded": "\u30D1\u30D5\u30A3\u30FCde\u30EB\u30F3\u30D0", + "encoded": "de-jg4avhby1noc0d" +}, +{ + "decoded": "\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067", + "encoded": "d9juau41awczczp" +}, +{ + "description": "ASCII string that breaks the existing rules for host-name labels (It's not a realistic example for IDNA, because IDNA never encodes pure ASCII labels.)", + "decoded": "-> $1.00 <-", + "encoded": "-> $1.00 <--" +} +] diff --git a/deps/url-0.2.35/src/tests.rs b/deps/url-0.2.35/src/tests.rs new file mode 100644 index 000000000..873619740 --- /dev/null +++ b/deps/url-0.2.35/src/tests.rs @@ -0,0 +1,287 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +use std::char; +use super::{UrlParser, Url, SchemeData, RelativeSchemeData, Host}; + + +#[test] +fn url_parsing() { + for test in parse_test_data(include_str!("urltestdata.txt")) { + let Test { + input, + base, + scheme: expected_scheme, + username: expected_username, + password: expected_password, + host: expected_host, + port: expected_port, + path: expected_path, + query: expected_query, + fragment: expected_fragment, + expected_failure, + } = test; + let base = match Url::parse(&base) { + Ok(base) => base, + Err(message) => panic!("Error parsing base {}: {}", base, message) + }; + let url = UrlParser::new().base_url(&base).parse(&input); + if expected_scheme.is_none() { + if url.is_ok() && !expected_failure { + panic!("Expected a parse error for URL {}", input); + } + continue + } + let Url { scheme, scheme_data, query, fragment, .. } = match url { + Ok(url) => url, + Err(message) => { + if expected_failure { + continue + } else { + panic!("Error parsing URL {}: {}", input, message) + } + } + }; + + macro_rules! assert_eq { + ($a: expr, $b: expr) => { + { + let a = $a; + let b = $b; + if a != b { + if expected_failure { + continue + } else { + panic!("{:?} != {:?}", a, b) + } + } + } + } + } + + assert_eq!(Some(scheme), expected_scheme); + match scheme_data { + SchemeData::Relative(RelativeSchemeData { + username, password, host, port, default_port: _, path, + }) => { + assert_eq!(username, expected_username); + assert_eq!(password, expected_password); + let host = host.serialize(); + assert_eq!(host, expected_host); + assert_eq!(port, expected_port); + assert_eq!(Some(format!("/{}", path.connect("/"))), expected_path); + }, + SchemeData::NonRelative(scheme_data) => { + assert_eq!(Some(scheme_data), expected_path); + assert_eq!(String::new(), expected_username); + assert_eq!(None, expected_password); + assert_eq!(String::new(), expected_host); + assert_eq!(None, expected_port); + }, + } + fn opt_prepend(prefix: &str, opt_s: Option<String>) -> Option<String> { + opt_s.map(|s| format!("{}{}", prefix, s)) + } + assert_eq!(opt_prepend("?", query), expected_query); + assert_eq!(opt_prepend("#", fragment), expected_fragment); + + assert!(!expected_failure, "Unexpected success for {}", input); + } +} + +struct Test { + input: String, + base: String, + scheme: Option<String>, + username: String, + password: Option<String>, + host: String, + port: Option<u16>, + path: Option<String>, + query: Option<String>, + fragment: Option<String>, + expected_failure: bool, +} + +fn parse_test_data(input: &str) -> Vec<Test> { + let mut tests: Vec<Test> = Vec::new(); + for line in input.lines() { + if line == "" || line.starts_with("#") { + continue + } + let mut pieces = line.split(' ').collect::<Vec<&str>>(); + let expected_failure = pieces[0] == "XFAIL"; + if expected_failure { + pieces.remove(0); + } + let input = unescape(pieces.remove(0)); + let mut test = Test { + input: input, + base: if pieces.is_empty() || pieces[0] == "" { + tests.last().unwrap().base.clone() + } else { + unescape(pieces.remove(0)) + }, + scheme: None, + username: String::new(), + password: None, + host: String::new(), + port: None, + path: None, + query: None, + fragment: None, + expected_failure: expected_failure, + }; + for piece in pieces { + if piece == "" || piece.starts_with("#") { + continue + } + let colon = piece.find(':').unwrap(); + let value = unescape(&piece[colon + 1..]); + match &piece[..colon] { + "s" => test.scheme = Some(value), + "u" => test.username = value, + "pass" => test.password = Some(value), + "h" => test.host = value, + "port" => test.port = Some(value.parse().unwrap()), + "p" => test.path = Some(value), + "q" => test.query = Some(value), + "f" => test.fragment = Some(value), + _ => panic!("Invalid token") + } + } + tests.push(test) + } + tests +} + +fn unescape(input: &str) -> String { + let mut output = String::new(); + let mut chars = input.chars(); + loop { + match chars.next() { + None => return output, + Some(c) => output.push( + if c == '\\' { + match chars.next().unwrap() { + '\\' => '\\', + 'n' => '\n', + 'r' => '\r', + 's' => ' ', + 't' => '\t', + 'f' => '\x0C', + 'u' => { + char::from_u32(((( + chars.next().unwrap().to_digit(16).unwrap()) * 16 + + chars.next().unwrap().to_digit(16).unwrap()) * 16 + + chars.next().unwrap().to_digit(16).unwrap()) * 16 + + chars.next().unwrap().to_digit(16).unwrap()).unwrap() + } + _ => panic!("Invalid test data input"), + } + } else { + c + } + ) + } + } +} + + +#[test] +fn new_file_paths() { + use std::path::{Path, PathBuf}; + if cfg!(unix) { + assert_eq!(Url::from_file_path(Path::new("relative")), Err(())); + assert_eq!(Url::from_file_path(Path::new("../relative")), Err(())); + } else { + assert_eq!(Url::from_file_path(Path::new("relative")), Err(())); + assert_eq!(Url::from_file_path(Path::new(r"..\relative")), Err(())); + assert_eq!(Url::from_file_path(Path::new(r"\drive-relative")), Err(())); + assert_eq!(Url::from_file_path(Path::new(r"\\ucn\")), Err(())); + } + + if cfg!(unix) { + let mut url = Url::from_file_path(Path::new("/foo/bar")).unwrap(); + assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); + assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string()][..])); + assert!(url.to_file_path() == Ok(PathBuf::from("/foo/bar"))); + + url.path_mut().unwrap()[1] = "ba\0r".to_string(); + url.to_file_path().is_ok(); + + url.path_mut().unwrap()[1] = "ba%00r".to_string(); + url.to_file_path().is_ok(); + } +} + +#[test] +#[cfg(unix)] +fn new_path_bad_utf8() { + use std::ffi::OsStr; + use std::os::unix::prelude::*; + use std::path::{Path, PathBuf}; + + let url = Url::from_file_path(Path::new("/foo/ba%80r")).unwrap(); + let os_str = OsStr::from_bytes(b"/foo/ba\x80r"); + assert_eq!(url.to_file_path(), Ok(PathBuf::from(os_str))); +} + +#[test] +fn new_path_windows_fun() { + if cfg!(windows) { + use std::path::{Path, PathBuf}; + let mut url = Url::from_file_path(Path::new(r"C:\foo\bar")).unwrap(); + assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); + assert_eq!(url.path(), Some(&["C:".to_string(), "foo".to_string(), "bar".to_string()][..])); + assert_eq!(url.to_file_path(), + Ok(PathBuf::from(r"C:\foo\bar"))); + + url.path_mut().unwrap()[2] = "ba\0r".to_string(); + assert!(url.to_file_path().is_ok()); + + url.path_mut().unwrap()[2] = "ba%00r".to_string(); + assert!(url.to_file_path().is_ok()); + + // Invalid UTF-8 + url.path_mut().unwrap()[2] = "ba%80r".to_string(); + assert!(url.to_file_path().is_err()); + } +} + + +#[test] +fn new_directory_paths() { + use std::path::Path; + + if cfg!(unix) { + assert_eq!(Url::from_directory_path(Path::new("relative")), Err(())); + assert_eq!(Url::from_directory_path(Path::new("../relative")), Err(())); + + let url = Url::from_directory_path(Path::new("/foo/bar")).unwrap(); + assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); + assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string(), + "".to_string()][..])); + } else { + assert_eq!(Url::from_directory_path(Path::new("relative")), Err(())); + assert_eq!(Url::from_directory_path(Path::new(r"..\relative")), Err(())); + assert_eq!(Url::from_directory_path(Path::new(r"\drive-relative")), Err(())); + assert_eq!(Url::from_directory_path(Path::new(r"\\ucn\")), Err(())); + + let url = Url::from_directory_path(Path::new(r"C:\foo\bar")).unwrap(); + assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); + assert_eq!(url.path(), Some(&["C:".to_string(), "foo".to_string(), + "bar".to_string(), "".to_string()][..])); + } +} + +#[test] +fn from_str() { + assert!("http://testing.com/this".parse::<Url>().is_ok()); +} diff --git a/deps/url-0.2.35/src/urltestdata.txt b/deps/url-0.2.35/src/urltestdata.txt new file mode 100644 index 000000000..ece4e7131 --- /dev/null +++ b/deps/url-0.2.35/src/urltestdata.txt @@ -0,0 +1,329 @@ +# This file is from https://github.com/w3c/web-platform-tests/blob/master/url/urltestdata.txt +# and used under a 3-clause BSD license. + +# FORMAT NOT DOCUMENTED YET (parser is urltestparser.js) +# https://github.com/w3c/web-platform-tests/blob/master/url/urltestparser.js + +# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/segments.js +http://example\t.\norg http://example.org/foo/bar s:http h:example.org p:/ +http://user:pass@foo:21/bar;par?b#c s:http u:user pass:pass h:foo port:21 p:/bar;par q:?b f:#c +http:foo.com s:http h:example.org p:/foo/foo.com +\t\s\s\s:foo.com\s\s\s\n s:http h:example.org p:/foo/:foo.com +\sfoo.com\s\s s:http h:example.org p:/foo/foo.com +a:\t\sfoo.com s:a p:\sfoo.com +http://f:21/\sb\s?\sd\s#\se\s s:http h:f port:21 p:/%20b%20 q:?%20d%20 f:#\se +http://f:/c s:http h:f p:/c +http://f:0/c s:http h:f port:0 p:/c +http://f:00000000000000/c s:http h:f port:0 p:/c +http://f:00000000000000000000080/c s:http h:f p:/c +http://f:b/c +http://f:\s/c +http://f:\n/c s:http h:f p:/c +http://f:fifty-two/c +http://f:9999/c s:http h:f port:9999 p:/c +http://f:\s21\s/\sb\s?\sd\s#\se\s + s:http h:example.org p:/foo/bar +\s\s\t s:http h:example.org p:/foo/bar +:foo.com/ s:http h:example.org p:/foo/:foo.com/ +:foo.com\\ s:http h:example.org p:/foo/:foo.com/ +: s:http h:example.org p:/foo/: +:a s:http h:example.org p:/foo/:a +:/ s:http h:example.org p:/foo/:/ +:\\ s:http h:example.org p:/foo/:/ +:# s:http h:example.org p:/foo/: f:# +# s:http h:example.org p:/foo/bar f:# +#/ s:http h:example.org p:/foo/bar f:#/ +#\\ s:http h:example.org p:/foo/bar f:#\\ +#;? s:http h:example.org p:/foo/bar f:#;? +? s:http h:example.org p:/foo/bar q:? +/ s:http h:example.org p:/ +:23 s:http h:example.org p:/foo/:23 +/:23 s:http h:example.org p:/:23 +:: s:http h:example.org p:/foo/:: +::23 s:http h:example.org p:/foo/::23 +foo:// s:foo p:// +http://a:b@c:29/d s:http u:a pass:b h:c port:29 p:/d +http::@c:29 s:http h:example.org p:/foo/:@c:29 +http://&a:foo(b]c@d:2/ s:http u:&a pass:foo(b]c h:d port:2 p:/ +http://::@c@d:2 s:http pass::%40c h:d port:2 p:/ +http://foo.com:b@d/ s:http u:foo.com pass:b h:d p:/ +http://foo.com/\\@ s:http h:foo.com p://@ +http:\\\\foo.com\\ s:http h:foo.com p:/ +http:\\\\a\\b:c\\d@foo.com\\ s:http h:a p:/b:c/d@foo.com/ +foo:/ s:foo p:/ +foo:/bar.com/ s:foo p:/bar.com/ +foo:///////// s:foo p:///////// +foo://///////bar.com/ s:foo p://///////bar.com/ +foo:////:///// s:foo p:////:///// +c:/foo s:c p:/foo +//foo/bar s:http h:foo p:/bar +http://foo/path;a??e#f#g s:http h:foo p:/path;a q:??e f:#f#g +http://foo/abcd?efgh?ijkl s:http h:foo p:/abcd q:?efgh?ijkl +http://foo/abcd#foo?bar s:http h:foo p:/abcd f:#foo?bar +[61:24:74]:98 s:http h:example.org p:/foo/[61:24:74]:98 +http:[61:27]/:foo s:http h:example.org p:/foo/[61:27]/:foo +http://[1::2]:3:4 +http://2001::1 +http://2001::1] +http://2001::1]:80 +http://[2001::1] s:http h:[2001::1] p:/ +http://[2001::1]:80 s:http h:[2001::1] p:/ +http:/example.com/ s:http h:example.org p:/example.com/ +ftp:/example.com/ s:ftp h:example.com p:/ +https:/example.com/ s:https h:example.com p:/ +madeupscheme:/example.com/ s:madeupscheme p:/example.com/ +file:/example.com/ s:file p:/example.com/ +ftps:/example.com/ s:ftps p:/example.com/ +gopher:/example.com/ s:gopher h:example.com p:/ +ws:/example.com/ s:ws h:example.com p:/ +wss:/example.com/ s:wss h:example.com p:/ +data:/example.com/ s:data p:/example.com/ +javascript:/example.com/ s:javascript p:/example.com/ +mailto:/example.com/ s:mailto p:/example.com/ +http:example.com/ s:http h:example.org p:/foo/example.com/ +ftp:example.com/ s:ftp h:example.com p:/ +https:example.com/ s:https h:example.com p:/ +madeupscheme:example.com/ s:madeupscheme p:example.com/ +ftps:example.com/ s:ftps p:example.com/ +gopher:example.com/ s:gopher h:example.com p:/ +ws:example.com/ s:ws h:example.com p:/ +wss:example.com/ s:wss h:example.com p:/ +data:example.com/ s:data p:example.com/ +javascript:example.com/ s:javascript p:example.com/ +mailto:example.com/ s:mailto p:example.com/ +/a/b/c s:http h:example.org p:/a/b/c +/a/\s/c s:http h:example.org p:/a/%20/c +/a%2fc s:http h:example.org p:/a%2fc +/a/%2f/c s:http h:example.org p:/a/%2f/c +#\u03B2 s:http h:example.org p:/foo/bar f:#\u03B2 +data:text/html,test#test s:data p:text/html,test f:#test + +# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/file.html +file:c:\\foo\\bar.html file:///tmp/mock/path s:file p:/c:/foo/bar.html +\s\sFile:c|////foo\\bar.html s:file p:/c:////foo/bar.html +C|/foo/bar s:file p:/C:/foo/bar +/C|\\foo\\bar s:file p:/C:/foo/bar +//C|/foo/bar s:file p:/C:/foo/bar +//server/file s:file h:server p:/file +\\\\server\\file s:file h:server p:/file +/\\server/file s:file h:server p:/file +file:///foo/bar.txt s:file p:/foo/bar.txt +file:///home/me s:file p:/home/me +// s:file p:/ +/// s:file p:/ +///test s:file p:/test +file://test s:file h:test p:/ +file://localhost s:file h:localhost p:/ +file://localhost/ s:file h:localhost p:/ +file://localhost/test s:file h:localhost p:/test +test s:file p:/tmp/mock/test +file:test s:file p:/tmp/mock/test + +# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/path.js +http://example.com/././foo about:blank s:http h:example.com p:/foo +http://example.com/./.foo s:http h:example.com p:/.foo +http://example.com/foo/. s:http h:example.com p:/foo/ +http://example.com/foo/./ s:http h:example.com p:/foo/ +http://example.com/foo/bar/.. s:http h:example.com p:/foo/ +http://example.com/foo/bar/../ s:http h:example.com p:/foo/ +http://example.com/foo/..bar s:http h:example.com p:/foo/..bar +http://example.com/foo/bar/../ton s:http h:example.com p:/foo/ton +http://example.com/foo/bar/../ton/../../a s:http h:example.com p:/a +http://example.com/foo/../../.. s:http h:example.com p:/ +http://example.com/foo/../../../ton s:http h:example.com p:/ton +http://example.com/foo/%2e s:http h:example.com p:/foo/ +http://example.com/foo/%2e%2 s:http h:example.com p:/foo/%2e%2 +http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar s:http h:example.com p:/%2e.bar +http://example.com////../.. s:http h:example.com p:// +http://example.com/foo/bar//../.. s:http h:example.com p:/foo/ +http://example.com/foo/bar//.. s:http h:example.com p:/foo/bar/ +http://example.com/foo s:http h:example.com p:/foo +http://example.com/%20foo s:http h:example.com p:/%20foo +http://example.com/foo% s:http h:example.com p:/foo% +http://example.com/foo%2 s:http h:example.com p:/foo%2 +http://example.com/foo%2zbar s:http h:example.com p:/foo%2zbar +http://example.com/foo%2\u00C2\u00A9zbar s:http h:example.com p:/foo%2%C3%82%C2%A9zbar +http://example.com/foo%41%7a s:http h:example.com p:/foo%41%7a +http://example.com/foo\t\u0091%91 s:http h:example.com p:/foo%C2%91%91 +http://example.com/foo%00%51 s:http h:example.com p:/foo%00%51 +http://example.com/(%28:%3A%29) s:http h:example.com p:/(%28:%3A%29) +http://example.com/%3A%3a%3C%3c s:http h:example.com p:/%3A%3a%3C%3c +http://example.com/foo\tbar s:http h:example.com p:/foobar +http://example.com\\\\foo\\\\bar s:http h:example.com p://foo//bar +http://example.com/%7Ffp3%3Eju%3Dduvgw%3Dd s:http h:example.com p:/%7Ffp3%3Eju%3Dduvgw%3Dd +http://example.com/@asdf%40 s:http h:example.com p:/@asdf%40 +http://example.com/\u4F60\u597D\u4F60\u597D s:http h:example.com p:/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD +http://example.com/\u2025/foo s:http h:example.com p:/%E2%80%A5/foo +http://example.com/\uFEFF/foo s:http h:example.com p:/%EF%BB%BF/foo +http://example.com/\u202E/foo/\u202D/bar s:http h:example.com p:/%E2%80%AE/foo/%E2%80%AD/bar + +# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/relative.js +http://www.google.com/foo?bar=baz# about:blank s:http h:www.google.com p:/foo q:?bar=baz f:# +http://www.google.com/foo?bar=baz#\s\u00BB s:http h:www.google.com p:/foo q:?bar=baz f:#\s%C2%BB +http://[www.google.com]/ +http://www.google.com s:http h:www.google.com p:/ +http://192.0x00A80001 s:http h:192.0x00a80001 p:/ +http://www/foo%2Ehtml s:http h:www p:/foo%2Ehtml +http://www/foo/%2E/html s:http h:www p:/foo/html +http://user:pass@/ +http://%25DOMAIN:foobar@foodomain.com/ s:http u:%25DOMAIN pass:foobar h:foodomain.com p:/ +http:\\\\www.google.com\\foo s:http h:www.google.com p:/foo +http://foo:80/ s:http h:foo p:/ +http://foo:81/ s:http h:foo port:81 p:/ +httpa://foo:80/ s:httpa p://foo:80/ +http://foo:-80/ +https://foo:443/ s:https h:foo p:/ +https://foo:80/ s:https h:foo port:80 p:/ +ftp://foo:21/ s:ftp h:foo p:/ +ftp://foo:80/ s:ftp h:foo port:80 p:/ +gopher://foo:70/ s:gopher h:foo p:/ +gopher://foo:443/ s:gopher h:foo port:443 p:/ +ws://foo:80/ s:ws h:foo p:/ +ws://foo:81/ s:ws h:foo port:81 p:/ +ws://foo:443/ s:ws h:foo port:443 p:/ +ws://foo:815/ s:ws h:foo port:815 p:/ +wss://foo:80/ s:wss h:foo port:80 p:/ +wss://foo:81/ s:wss h:foo port:81 p:/ +wss://foo:443/ s:wss h:foo p:/ +wss://foo:815/ s:wss h:foo port:815 p:/ +http:/example.com/ s:http h:example.com p:/ +ftp:/example.com/ s:ftp h:example.com p:/ +https:/example.com/ s:https h:example.com p:/ +madeupscheme:/example.com/ s:madeupscheme p:/example.com/ +file:/example.com/ s:file p:/example.com/ +ftps:/example.com/ s:ftps p:/example.com/ +gopher:/example.com/ s:gopher h:example.com p:/ +ws:/example.com/ s:ws h:example.com p:/ +wss:/example.com/ s:wss h:example.com p:/ +data:/example.com/ s:data p:/example.com/ +javascript:/example.com/ s:javascript p:/example.com/ +mailto:/example.com/ s:mailto p:/example.com/ +http:example.com/ s:http h:example.com p:/ +ftp:example.com/ s:ftp h:example.com p:/ +https:example.com/ s:https h:example.com p:/ +madeupscheme:example.com/ s:madeupscheme p:example.com/ +ftps:example.com/ s:ftps p:example.com/ +gopher:example.com/ s:gopher h:example.com p:/ +ws:example.com/ s:ws h:example.com p:/ +wss:example.com/ s:wss h:example.com p:/ +data:example.com/ s:data p:example.com/ +javascript:example.com/ s:javascript p:example.com/ +mailto:example.com/ s:mailto p:example.com/ + +# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/segments-userinfo-vs-host.html +http:@www.example.com about:blank s:http h:www.example.com p:/ +http:/@www.example.com s:http h:www.example.com p:/ +http://@www.example.com s:http h:www.example.com p:/ +http:a:b@www.example.com s:http u:a pass:b h:www.example.com p:/ +http:/a:b@www.example.com s:http u:a pass:b h:www.example.com p:/ +http://a:b@www.example.com s:http u:a pass:b h:www.example.com p:/ +http://@pple.com s:http h:pple.com p:/ +http::b@www.example.com s:http pass:b h:www.example.com p:/ +http:/:b@www.example.com s:http pass:b h:www.example.com p:/ +http://:b@www.example.com s:http pass:b h:www.example.com p:/ +http:/:@/www.example.com +http://user@/www.example.com +http:@/www.example.com +http:/@/www.example.com +http://@/www.example.com +https:@/www.example.com +http:a:b@/www.example.com +http:/a:b@/www.example.com +http://a:b@/www.example.com +http::@/www.example.com +http:a:@www.example.com s:http u:a pass: h:www.example.com p:/ +http:/a:@www.example.com s:http u:a pass: h:www.example.com p:/ +http://a:@www.example.com s:http u:a pass: h:www.example.com p:/ +http://www.@pple.com s:http u:www. h:pple.com p:/ +http:@:www.example.com +http:/@:www.example.com +http://@:www.example.com +http://:@www.example.com s:http pass: h:www.example.com p:/ + +#Others +/ http://www.example.com/test s:http h:www.example.com p:/ +/test.txt s:http h:www.example.com p:/test.txt +. s:http h:www.example.com p:/ +.. s:http h:www.example.com p:/ +test.txt s:http h:www.example.com p:/test.txt +./test.txt s:http h:www.example.com p:/test.txt +../test.txt s:http h:www.example.com p:/test.txt +../aaa/test.txt s:http h:www.example.com p:/aaa/test.txt +../../test.txt s:http h:www.example.com p:/test.txt +\u4E2D/test.txt s:http h:www.example.com p:/%E4%B8%AD/test.txt +http://www.example2.com s:http h:www.example2.com p:/ + +# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/host.html + +# Basic canonicalization, uppercase should be converted to lowercase +http://ExAmPlE.CoM http://other.com/ s:http p:/ h:example.com + +# Spaces should fail +http://example\sexample.com + +# This should fail +http://Goo%20\sgoo%7C|.com + +# This should fail +http://GOO\u00a0\u3000goo.com + +# This should fail +http://[] +http://[:] + +# Other types of space (no-break, zero-width, zero-width-no-break) are +# name-prepped away to nothing. +XFAIL http://GOO\u200b\u2060\ufeffgoo.com s:http p:/ h:googoo.com + +# Ideographic full stop (full-width period for Chinese, etc.) should be +# treated as a dot. +XFAIL http://www.foo\u3002bar.com s:http p:/ h:www.foo.bar.com + +# Invalid unicode characters should fail... +http://\ufdd0zyx.com + +# ...This is the same as previous but with with escaped. +http://%ef%b7%90zyx.com + +# Test name prepping, fullwidth input should be converted to ASCII and NOT +# IDN-ized. This is "Go" in fullwidth UTF-8/UTF-16. +XFAIL http://\uff27\uff4f.com s:http p:/ h:go.com + +# URL spec forbids the following. +# https://www.w3.org/Bugs/Public/show_bug.cgi?id=24257 +http://\uff05\uff14\uff11.com +http://%ef%bc%85%ef%bc%94%ef%bc%91.com + +# ...%00 in fullwidth should fail (also as escaped UTF-8 input) +http://\uff05\uff10\uff10.com +http://%ef%bc%85%ef%bc%90%ef%bc%90.com + +# Basic IDN support, UTF-8 and UTF-16 input should be converted to IDN +XFAIL http://\u4f60\u597d\u4f60\u597d s:http p:/ h:xn--6qqa088eba + +# Invalid escaped characters should fail and the percents should be +# escaped. https://www.w3.org/Bugs/Public/show_bug.cgi?id=24191 +http://%zz%66%a.com + +# If we get an invalid character that has been escaped. +http://%25 +http://hello%00 + +# Escaped numbers should be treated like IP addresses if they are. +XFAIL http://%30%78%63%30%2e%30%32%35%30.01 s:http p:/ h:127.0.0.1 +XFAIL http://%30%78%63%30%2e%30%32%35%30.01%2e + +# Invalid escaping should trigger the regular host error handling. +http://%3g%78%63%30%2e%30%32%35%30%2E.01 + +# Something that isn't exactly an IP should get treated as a host and +# spaces escaped. +http://192.168.0.1\shello + +# Fullwidth and escaped UTF-8 fullwidth should still be treated as IP. +# These are "0Xc0.0250.01" in fullwidth. +XFAIL http://\uff10\uff38\uff43\uff10\uff0e\uff10\uff12\uff15\uff10\uff0e\uff10\uff11 s:http p:/ h:192.168.0.1 + +# Broken IP addresses. +XFAIL http://192.168.0.257 +http://[google.com] diff --git a/deps/url-0.2.35/src/urlutils.rs b/deps/url-0.2.35/src/urlutils.rs new file mode 100644 index 000000000..cd57b501b --- /dev/null +++ b/deps/url-0.2.35/src/urlutils.rs @@ -0,0 +1,169 @@ +// Copyright 2013-2014 Simon Sapin. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +//! These methods are not meant for use in Rust code, +//! only to help implement the JavaScript URLUtils API: http://url.spec.whatwg.org/#urlutils + +use super::{Url, UrlParser, SchemeType, SchemeData, RelativeSchemeData}; +use parser::{ParseError, ParseResult, Context}; +use percent_encoding::{utf8_percent_encode_to, USERNAME_ENCODE_SET, PASSWORD_ENCODE_SET}; + + +#[allow(dead_code)] +pub struct UrlUtilsWrapper<'a> { + pub url: &'a mut Url, + pub parser: &'a UrlParser<'a>, +} + +#[doc(hidden)] +pub trait UrlUtils { + fn set_scheme(&mut self, input: &str) -> ParseResult<()>; + fn set_username(&mut self, input: &str) -> ParseResult<()>; + fn set_password(&mut self, input: &str) -> ParseResult<()>; + fn set_host_and_port(&mut self, input: &str) -> ParseResult<()>; + fn set_host(&mut self, input: &str) -> ParseResult<()>; + fn set_port(&mut self, input: &str) -> ParseResult<()>; + fn set_path(&mut self, input: &str) -> ParseResult<()>; + fn set_query(&mut self, input: &str) -> ParseResult<()>; + fn set_fragment(&mut self, input: &str) -> ParseResult<()>; +} + +impl<'a> UrlUtils for UrlUtilsWrapper<'a> { + /// `URLUtils.protocol` setter + fn set_scheme(&mut self, input: &str) -> ParseResult<()> { + match ::parser::parse_scheme(input, Context::Setter) { + Some((scheme, _)) => { + if self.parser.get_scheme_type(&self.url.scheme).same_as(self.parser.get_scheme_type(&scheme)) { + return Err(ParseError::InvalidScheme); + } + self.url.scheme = scheme; + Ok(()) + }, + None => Err(ParseError::InvalidScheme), + } + } + + /// `URLUtils.username` setter + fn set_username(&mut self, input: &str) -> ParseResult<()> { + match self.url.scheme_data { + SchemeData::Relative(RelativeSchemeData { ref mut username, .. }) => { + username.truncate(0); + utf8_percent_encode_to(input, USERNAME_ENCODE_SET, username); + Ok(()) + }, + SchemeData::NonRelative(_) => Err(ParseError::CannotSetUsernameWithNonRelativeScheme) + } + } + + /// `URLUtils.password` setter + fn set_password(&mut self, input: &str) -> ParseResult<()> { + match self.url.scheme_data { + SchemeData::Relative(RelativeSchemeData { ref mut password, .. }) => { + if input.len() == 0 { + *password = None; + return Ok(()); + } + let mut new_password = String::new(); + utf8_percent_encode_to(input, PASSWORD_ENCODE_SET, &mut new_password); + *password = Some(new_password); + Ok(()) + }, + SchemeData::NonRelative(_) => Err(ParseError::CannotSetPasswordWithNonRelativeScheme) + } + } + + /// `URLUtils.host` setter + fn set_host_and_port(&mut self, input: &str) -> ParseResult<()> { + match self.url.scheme_data { + SchemeData::Relative(RelativeSchemeData { + ref mut host, ref mut port, ref mut default_port, .. + }) => { + let scheme_type = self.parser.get_scheme_type(&self.url.scheme); + let (new_host, new_port, new_default_port, _) = try!(::parser::parse_host( + input, scheme_type, self.parser)); + *host = new_host; + *port = new_port; + *default_port = new_default_port; + Ok(()) + }, + SchemeData::NonRelative(_) => Err(ParseError::CannotSetHostPortWithNonRelativeScheme) + } + } + + /// `URLUtils.hostname` setter + fn set_host(&mut self, input: &str) -> ParseResult<()> { + match self.url.scheme_data { + SchemeData::Relative(RelativeSchemeData { ref mut host, .. }) => { + let (new_host, _) = try!(::parser::parse_hostname(input, self.parser)); + *host = new_host; + Ok(()) + }, + SchemeData::NonRelative(_) => Err(ParseError::CannotSetHostWithNonRelativeScheme) + } + } + + /// `URLUtils.port` setter + fn set_port(&mut self, input: &str) -> ParseResult<()> { + match self.url.scheme_data { + SchemeData::Relative(RelativeSchemeData { ref mut port, ref mut default_port, .. }) => { + let scheme_type = self.parser.get_scheme_type(&self.url.scheme); + if scheme_type == SchemeType::FileLike { + return Err(ParseError::CannotSetPortWithFileLikeScheme); + } + let (new_port, new_default_port, _) = try!(::parser::parse_port( + input, scheme_type, self.parser)); + *port = new_port; + *default_port = new_default_port; + Ok(()) + }, + SchemeData::NonRelative(_) => Err(ParseError::CannotSetPortWithNonRelativeScheme) + } + } + + /// `URLUtils.pathname` setter + fn set_path(&mut self, input: &str) -> ParseResult<()> { + match self.url.scheme_data { + SchemeData::Relative(RelativeSchemeData { ref mut path, .. }) => { + let scheme_type = self.parser.get_scheme_type(&self.url.scheme); + let (new_path, _) = try!(::parser::parse_path_start( + input, Context::Setter, scheme_type, self.parser)); + *path = new_path; + Ok(()) + }, + SchemeData::NonRelative(_) => Err(ParseError::CannotSetPathWithNonRelativeScheme) + } + } + + /// `URLUtils.search` setter + fn set_query(&mut self, input: &str) -> ParseResult<()> { + self.url.query = if input.is_empty() { + None + } else { + let input = if input.starts_with("?") { &input[1..] } else { input }; + let (new_query, _) = try!(::parser::parse_query( + input, Context::Setter, self.parser)); + Some(new_query) + }; + Ok(()) + } + + /// `URLUtils.hash` setter + fn set_fragment(&mut self, input: &str) -> ParseResult<()> { + if self.url.scheme == "javascript" { + return Err(ParseError::CannotSetJavascriptFragment) + } + self.url.fragment = if input.is_empty() { + None + } else { + let input = if input.starts_with("#") { &input[1..] } else { input }; + Some(try!(::parser::parse_fragment(input, self.parser))) + }; + Ok(()) + } +} diff --git a/deps/winapi-0.1.23/.gitignore b/deps/winapi-0.1.23/.gitignore new file mode 100644 index 000000000..2c96eb1b6 --- /dev/null +++ b/deps/winapi-0.1.23/.gitignore @@ -0,0 +1,2 @@ +target/ +Cargo.lock diff --git a/deps/winapi-0.1.23/.travis.yml b/deps/winapi-0.1.23/.travis.yml new file mode 100644 index 000000000..6d41540ad --- /dev/null +++ b/deps/winapi-0.1.23/.travis.yml @@ -0,0 +1,16 @@ +language: rust +sudo: false +script: + - cargo build --verbose + - cargo test --verbose + - cargo doc --verbose +notifications: + email: false + webhooks: + - https://webhooks.gitter.im/e/295a1e640ebd30d63457 + irc: + channels: + - "irc.fyrechat.net#vana-commits" + template: + - "%{repository_slug}/%{branch} (%{commit} - %{author}): %{message}" + skip_join: true diff --git a/deps/winapi-0.1.23/CONTRIBUTING.md b/deps/winapi-0.1.23/CONTRIBUTING.md new file mode 100644 index 000000000..6fd73cdab --- /dev/null +++ b/deps/winapi-0.1.23/CONTRIBUTING.md @@ -0,0 +1,14 @@ +## Guidelines ## +* Column limit is a strict 99. Avoid newlines it is possible to fit within 99, and when it isn't + add newlines as late as possible. +* Multiline functions and structs should have commas after every field and parameter. +* When doing multiline functions, use this style: +```rust + pub fn QueryInformationJobObject( + hJob: HANDLE, JobObjectInformationClass: JOBOBJECTINFOCLASS, + lpJobObjectInformation: LPVOID, cbJobObjectInformationLength: DWORD, + lpReturnLength: LPDWORD, + ) -> BOOL; +``` +* Functions go into the respective `-sys` crate inside `lib`. All types and constants go into the + main crate. diff --git a/deps/winapi-0.1.23/Cargo.toml b/deps/winapi-0.1.23/Cargo.toml new file mode 100644 index 000000000..fa42ac4c3 --- /dev/null +++ b/deps/winapi-0.1.23/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "winapi" +version = "0.1.23" +authors = ["Peter Atashian <retep998@gmail.com>"] +description = "Types and constants for WinAPI bindings. See README for list of crates providing function bindings." +documentation = "https://retep998.github.io/doc/winapi/" +repository = "https://github.com/retep998/winapi-rs" +readme = "README.md" +keywords = ["Windows", "FFI", "WinSDK"] +license = "MIT" + +[dependencies] +libc = "*" + +[dev-dependencies] +advapi32-sys = { version = "*", path = "lib/advapi32-sys" } +crypt32-sys = { version = "*", path = "lib/crypt32-sys" } +d3d9-sys = { version = "*", path = "lib/d3d9-sys" } +dbghelp-sys = { version = "*", path = "lib/dbghelp-sys" } +dwmapi-sys = { version = "*", path = "lib/dwmapi-sys" } +gdi32-sys = { version = "*", path = "lib/gdi32-sys" } +kernel32-sys = { version = "*", path = "lib/kernel32-sys" } +ktmw32-sys = { version = "*", path = "lib/ktmw32-sys" } +mpr-sys = { version = "*", path = "lib/mpr-sys" } +ole32-sys = { version = "*", path = "lib/ole32-sys" } +opengl32-sys = { version = "*", path = "lib/opengl32-sys" } +psapi-sys = { version = "*", path = "lib/psapi-sys" } +secur32-sys = { version = "*", path = "lib/secur32-sys" } +shell32-sys = { version = "*", path = "lib/shell32-sys" } +user32-sys = { version = "*", path = "lib/user32-sys" } +uuid-sys = { version = "*", path = "lib/uuid-sys" } +winhttp-sys = { version = "*", path = "lib/winhttp-sys" } +winmm-sys = { version = "*", path = "lib/winmm-sys" } diff --git a/deps/winapi-0.1.23/LICENSE.md b/deps/winapi-0.1.23/LICENSE.md new file mode 100644 index 000000000..60d12ac7b --- /dev/null +++ b/deps/winapi-0.1.23/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Peter Atashian + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/winapi-0.1.23/README.md b/deps/winapi-0.1.23/README.md new file mode 100644 index 000000000..de4f8cfb4 --- /dev/null +++ b/deps/winapi-0.1.23/README.md @@ -0,0 +1,454 @@ +# winapi-rs [![Build status](https://ci.appveyor.com/api/projects/status/i47oonf5e7qm5utq/branch/master?svg=true)](https://ci.appveyor.com/project/retep998/winapi-rs/branch/master) [![Build Status](https://travis-ci.org/retep998/winapi-rs.svg?branch=master)](https://travis-ci.org/retep998/winapi-rs) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retep998/winapi-rs) [![Crates.io](https://img.shields.io/crates/v/winapi.svg)](https://crates.io/crates/winapi) # + +[Documentation](https://retep998.github.io/doc/winapi/) + +This crate provides types and constants for WinAPI FFI bindings. They are gathered by hand using the very latest official SDK from Microsoft. I aim to replace all existing Windows FFI in other crates with this set of crates through the "[Embrace, extend, and extinguish](http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish)" technique. + +If this crate is missing something you need, feel free to create an issue, open a pull request, or contact me via [other means](http://www.rustaceans.org/retep998). + +## Example ## + +Cargo.toml: +```toml +[dependencies] +winapi = "*" +winmm-sys = "*" +``` +example.rs: +```Rust +extern crate winapi; +extern crate winmm; +fn func() { + winmm::PlaySoundA(...); +} +``` + +## Functions ## + +Bindings to library functions are in separate crates. The source to each crate is in the relevant subdirectory under the `lib` directory. + +### Usable crates ### +These are the ones that actually have functions in them: +* [advapi32-sys ![Crates.io](https://img.shields.io/crates/v/advapi32-sys.svg)](https://crates.io/crates/advapi32-sys) +* [d3d9-sys ![Crates.io](https://img.shields.io/crates/v/d3d9-sys.svg)](https://crates.io/crates/d3d9-sys) +* [dbghelp-sys ![Crates.io](https://img.shields.io/crates/v/dbghelp-sys.svg)](https://crates.io/crates/dbghelp-sys) +* [dwmapi-sys ![Crates.io](https://img.shields.io/crates/v/dwmapi-sys.svg)](https://crates.io/crates/dwmapi-sys) +* [gdi32-sys ![Crates.io](https://img.shields.io/crates/v/gdi32-sys.svg)](https://crates.io/crates/gdi32-sys) +* [kernel32-sys ![Crates.io](https://img.shields.io/crates/v/kernel32-sys.svg)](https://crates.io/crates/kernel32-sys) +* [ktmw32-sys ![Crates.io](https://img.shields.io/crates/v/ktmw32-sys.svg)](https://crates.io/crates/ktmw32-sys) +* [mpr-sys ![Crates.io](https://img.shields.io/crates/v/mpr-sys.svg)](https://crates.io/crates/mpr-sys) +* [ole32-sys ![Crates.io](https://img.shields.io/crates/v/ole32-sys.svg)](https://crates.io/crates/ole32-sys) +* [opengl32-sys ![Crates.io](https://img.shields.io/crates/v/opengl32-sys.svg)](https://crates.io/crates/opengl32-sys) +* [psapi-sys ![Crates.io](https://img.shields.io/crates/v/psapi-sys.svg)](https://crates.io/crates/psapi-sys) +* [shell32-sys ![Crates.io](https://img.shields.io/crates/v/shell32-sys.svg)](https://crates.io/crates/shell32-sys) +* [user32-sys ![Crates.io](https://img.shields.io/crates/v/user32-sys.svg)](https://crates.io/crates/user32-sys) +* [uuid-sys ![Crates.io](https://img.shields.io/crates/v/uuid-sys.svg)](https://crates.io/crates/uuid-sys) +* [winmm-sys ![Crates.io](https://img.shields.io/crates/v/winmm-sys.svg)](https://crates.io/crates/winmm-sys) + +### Reserved crates ### +These are the ones that are reserved for future use: +* [aclui-sys ![Crates.io](https://img.shields.io/crates/v/aclui-sys.svg)](https://crates.io/crates/aclui-sys) +* [activeds-sys ![Crates.io](https://img.shields.io/crates/v/activeds-sys.svg)](https://crates.io/crates/activeds-sys) +* [adsiid-sys ![Crates.io](https://img.shields.io/crates/v/adsiid-sys.svg)](https://crates.io/crates/adsiid-sys) +* [advpack-sys ![Crates.io](https://img.shields.io/crates/v/advpack-sys.svg)](https://crates.io/crates/advpack-sys) +* [ahadmin-sys ![Crates.io](https://img.shields.io/crates/v/ahadmin-sys.svg)](https://crates.io/crates/ahadmin-sys) +* [alink-sys ![Crates.io](https://img.shields.io/crates/v/alink-sys.svg)](https://crates.io/crates/alink-sys) +* [amstrmid-sys ![Crates.io](https://img.shields.io/crates/v/amstrmid-sys.svg)](https://crates.io/crates/amstrmid-sys) +* [api-ms-win-net-isolation-l1-1-0-sys ![Crates.io](https://img.shields.io/crates/v/api-ms-win-net-isolation-l1-1-0-sys.svg)](https://crates.io/crates/api-ms-win-net-isolation-l1-1-0-sys) +* [apidll-sys ![Crates.io](https://img.shields.io/crates/v/apidll-sys.svg)](https://crates.io/crates/apidll-sys) +* [appmgmts-sys ![Crates.io](https://img.shields.io/crates/v/appmgmts-sys.svg)](https://crates.io/crates/appmgmts-sys) +* [appmgr-sys ![Crates.io](https://img.shields.io/crates/v/appmgr-sys.svg)](https://crates.io/crates/appmgr-sys) +* [appnotify-sys ![Crates.io](https://img.shields.io/crates/v/appnotify-sys.svg)](https://crates.io/crates/appnotify-sys) +* [asycfilt-sys ![Crates.io](https://img.shields.io/crates/v/asycfilt-sys.svg)](https://crates.io/crates/asycfilt-sys) +* [audiobaseprocessingobject-sys ![Crates.io](https://img.shields.io/crates/v/audiobaseprocessingobject-sys.svg)](https://crates.io/crates/audiobaseprocessingobject-sys) +* [audioeng-sys ![Crates.io](https://img.shields.io/crates/v/audioeng-sys.svg)](https://crates.io/crates/audioeng-sys) +* [audiomediatypecrt-sys ![Crates.io](https://img.shields.io/crates/v/audiomediatypecrt-sys.svg)](https://crates.io/crates/audiomediatypecrt-sys) +* [authz-sys ![Crates.io](https://img.shields.io/crates/v/authz-sys.svg)](https://crates.io/crates/authz-sys) +* [aux_ulib-sys ![Crates.io](https://img.shields.io/crates/v/aux_ulib-sys.svg)](https://crates.io/crates/aux_ulib-sys) +* [avifil32-sys ![Crates.io](https://img.shields.io/crates/v/avifil32-sys.svg)](https://crates.io/crates/avifil32-sys) +* [avrt-sys ![Crates.io](https://img.shields.io/crates/v/avrt-sys.svg)](https://crates.io/crates/avrt-sys) +* [basesrv-sys ![Crates.io](https://img.shields.io/crates/v/basesrv-sys.svg)](https://crates.io/crates/basesrv-sys) +* [bcrypt-sys ![Crates.io](https://img.shields.io/crates/v/bcrypt-sys.svg)](https://crates.io/crates/bcrypt-sys) +* [bits-sys ![Crates.io](https://img.shields.io/crates/v/bits-sys.svg)](https://crates.io/crates/bits-sys) +* [bluetoothapis-sys ![Crates.io](https://img.shields.io/crates/v/bluetoothapis-sys.svg)](https://crates.io/crates/bluetoothapis-sys) +* [bthprops-sys ![Crates.io](https://img.shields.io/crates/v/bthprops-sys.svg)](https://crates.io/crates/bthprops-sys) +* [bufferoverflow-sys ![Crates.io](https://img.shields.io/crates/v/bufferoverflow-sys.svg)](https://crates.io/crates/bufferoverflow-sys) +* [bufferoverflowu-sys ![Crates.io](https://img.shields.io/crates/v/bufferoverflowu-sys.svg)](https://crates.io/crates/bufferoverflowu-sys) +* [cabinet-sys ![Crates.io](https://img.shields.io/crates/v/cabinet-sys.svg)](https://crates.io/crates/cabinet-sys) +* [certadm-sys ![Crates.io](https://img.shields.io/crates/v/certadm-sys.svg)](https://crates.io/crates/certadm-sys) +* [certca-sys ![Crates.io](https://img.shields.io/crates/v/certca-sys.svg)](https://crates.io/crates/certca-sys) +* [certcli-sys ![Crates.io](https://img.shields.io/crates/v/certcli-sys.svg)](https://crates.io/crates/certcli-sys) +* [certidl-sys ![Crates.io](https://img.shields.io/crates/v/certidl-sys.svg)](https://crates.io/crates/certidl-sys) +* [certpoleng-sys ![Crates.io](https://img.shields.io/crates/v/certpoleng-sys.svg)](https://crates.io/crates/certpoleng-sys) +* [cfgmgr32-sys ![Crates.io](https://img.shields.io/crates/v/cfgmgr32-sys.svg)](https://crates.io/crates/cfgmgr32-sys) +* [clfsmgmt-sys ![Crates.io](https://img.shields.io/crates/v/clfsmgmt-sys.svg)](https://crates.io/crates/clfsmgmt-sys) +* [clfsw32-sys ![Crates.io](https://img.shields.io/crates/v/clfsw32-sys.svg)](https://crates.io/crates/clfsw32-sys) +* [clusapi-sys ![Crates.io](https://img.shields.io/crates/v/clusapi-sys.svg)](https://crates.io/crates/clusapi-sys) +* [comctl32-sys ![Crates.io](https://img.shields.io/crates/v/comctl32-sys.svg)](https://crates.io/crates/comctl32-sys) +* [comdlg32-sys ![Crates.io](https://img.shields.io/crates/v/comdlg32-sys.svg)](https://crates.io/crates/comdlg32-sys) +* [comppkgsup-sys ![Crates.io](https://img.shields.io/crates/v/comppkgsup-sys.svg)](https://crates.io/crates/comppkgsup-sys) +* [compstui-sys ![Crates.io](https://img.shields.io/crates/v/compstui-sys.svg)](https://crates.io/crates/compstui-sys) +* [comsvcs-sys ![Crates.io](https://img.shields.io/crates/v/comsvcs-sys.svg)](https://crates.io/crates/comsvcs-sys) +* [corguids-sys ![Crates.io](https://img.shields.io/crates/v/corguids-sys.svg)](https://crates.io/crates/corguids-sys) +* [correngine-sys ![Crates.io](https://img.shields.io/crates/v/correngine-sys.svg)](https://crates.io/crates/correngine-sys) +* [credui-sys ![Crates.io](https://img.shields.io/crates/v/credui-sys.svg)](https://crates.io/crates/credui-sys) +* [crypt32-sys ![Crates.io](https://img.shields.io/crates/v/crypt32-sys.svg)](https://crates.io/crates/crypt32-sys) +* [cryptdll-sys ![Crates.io](https://img.shields.io/crates/v/cryptdll-sys.svg)](https://crates.io/crates/cryptdll-sys) +* [cryptnet-sys ![Crates.io](https://img.shields.io/crates/v/cryptnet-sys.svg)](https://crates.io/crates/cryptnet-sys) +* [cryptui-sys ![Crates.io](https://img.shields.io/crates/v/cryptui-sys.svg)](https://crates.io/crates/cryptui-sys) +* [cryptxml-sys ![Crates.io](https://img.shields.io/crates/v/cryptxml-sys.svg)](https://crates.io/crates/cryptxml-sys) +* [cscapi-sys ![Crates.io](https://img.shields.io/crates/v/cscapi-sys.svg)](https://crates.io/crates/cscapi-sys) +* [cscdll-sys ![Crates.io](https://img.shields.io/crates/v/cscdll-sys.svg)](https://crates.io/crates/cscdll-sys) +* [d2d1-sys ![Crates.io](https://img.shields.io/crates/v/d2d1-sys.svg)](https://crates.io/crates/d2d1-sys) +* [d3d10-sys ![Crates.io](https://img.shields.io/crates/v/d3d10-sys.svg)](https://crates.io/crates/d3d10-sys) +* [d3d10_1-sys ![Crates.io](https://img.shields.io/crates/v/d3d10_1-sys.svg)](https://crates.io/crates/d3d10_1-sys) +* [d3d11-sys ![Crates.io](https://img.shields.io/crates/v/d3d11-sys.svg)](https://crates.io/crates/d3d11-sys) +* [d3dcompiler-sys ![Crates.io](https://img.shields.io/crates/v/d3dcompiler-sys.svg)](https://crates.io/crates/d3dcompiler-sys) +* [d3dcsx-sys ![Crates.io](https://img.shields.io/crates/v/d3dcsx-sys.svg)](https://crates.io/crates/d3dcsx-sys) +* [d3dcsxd-sys ![Crates.io](https://img.shields.io/crates/v/d3dcsxd-sys.svg)](https://crates.io/crates/d3dcsxd-sys) +* [davclnt-sys ![Crates.io](https://img.shields.io/crates/v/davclnt-sys.svg)](https://crates.io/crates/davclnt-sys) +* [dbgeng-sys ![Crates.io](https://img.shields.io/crates/v/dbgeng-sys.svg)](https://crates.io/crates/dbgeng-sys) +* [dciman32-sys ![Crates.io](https://img.shields.io/crates/v/dciman32-sys.svg)](https://crates.io/crates/dciman32-sys) +* [dcomp-sys ![Crates.io](https://img.shields.io/crates/v/dcomp-sys.svg)](https://crates.io/crates/dcomp-sys) +* [ddraw-sys ![Crates.io](https://img.shields.io/crates/v/ddraw-sys.svg)](https://crates.io/crates/ddraw-sys) +* [devenum-sys ![Crates.io](https://img.shields.io/crates/v/devenum-sys.svg)](https://crates.io/crates/devenum-sys) +* [deviceaccess-sys ![Crates.io](https://img.shields.io/crates/v/deviceaccess-sys.svg)](https://crates.io/crates/deviceaccess-sys) +* [devmgr-sys ![Crates.io](https://img.shields.io/crates/v/devmgr-sys.svg)](https://crates.io/crates/devmgr-sys) +* [dflayout-sys ![Crates.io](https://img.shields.io/crates/v/dflayout-sys.svg)](https://crates.io/crates/dflayout-sys) +* [dhcpcsvc-sys ![Crates.io](https://img.shields.io/crates/v/dhcpcsvc-sys.svg)](https://crates.io/crates/dhcpcsvc-sys) +* [dhcpcsvc6-sys ![Crates.io](https://img.shields.io/crates/v/dhcpcsvc6-sys.svg)](https://crates.io/crates/dhcpcsvc6-sys) +* [dhcpsapi-sys ![Crates.io](https://img.shields.io/crates/v/dhcpsapi-sys.svg)](https://crates.io/crates/dhcpsapi-sys) +* [difxapi-sys ![Crates.io](https://img.shields.io/crates/v/difxapi-sys.svg)](https://crates.io/crates/difxapi-sys) +* [dinput8-sys ![Crates.io](https://img.shields.io/crates/v/dinput8-sys.svg)](https://crates.io/crates/dinput8-sys) +* [dloadhelper-sys ![Crates.io](https://img.shields.io/crates/v/dloadhelper-sys.svg)](https://crates.io/crates/dloadhelper-sys) +* [dmoguids-sys ![Crates.io](https://img.shields.io/crates/v/dmoguids-sys.svg)](https://crates.io/crates/dmoguids-sys) +* [dnsapi-sys ![Crates.io](https://img.shields.io/crates/v/dnsapi-sys.svg)](https://crates.io/crates/dnsapi-sys) +* [dnscrcli-sys ![Crates.io](https://img.shields.io/crates/v/dnscrcli-sys.svg)](https://crates.io/crates/dnscrcli-sys) +* [dnslib-sys ![Crates.io](https://img.shields.io/crates/v/dnslib-sys.svg)](https://crates.io/crates/dnslib-sys) +* [dnsperf-sys ![Crates.io](https://img.shields.io/crates/v/dnsperf-sys.svg)](https://crates.io/crates/dnsperf-sys) +* [dnsrpc-sys ![Crates.io](https://img.shields.io/crates/v/dnsrpc-sys.svg)](https://crates.io/crates/dnsrpc-sys) +* [dnsrslvr-sys ![Crates.io](https://img.shields.io/crates/v/dnsrslvr-sys.svg)](https://crates.io/crates/dnsrslvr-sys) +* [dpx-sys ![Crates.io](https://img.shields.io/crates/v/dpx-sys.svg)](https://crates.io/crates/dpx-sys) +* [drt-sys ![Crates.io](https://img.shields.io/crates/v/drt-sys.svg)](https://crates.io/crates/drt-sys) +* [drtprov-sys ![Crates.io](https://img.shields.io/crates/v/drtprov-sys.svg)](https://crates.io/crates/drtprov-sys) +* [drttransport-sys ![Crates.io](https://img.shields.io/crates/v/drttransport-sys.svg)](https://crates.io/crates/drttransport-sys) +* [dsound-sys ![Crates.io](https://img.shields.io/crates/v/dsound-sys.svg)](https://crates.io/crates/dsound-sys) +* [dsprop-sys ![Crates.io](https://img.shields.io/crates/v/dsprop-sys.svg)](https://crates.io/crates/dsprop-sys) +* [dssec-sys ![Crates.io](https://img.shields.io/crates/v/dssec-sys.svg)](https://crates.io/crates/dssec-sys) +* [dststlog-sys ![Crates.io](https://img.shields.io/crates/v/dststlog-sys.svg)](https://crates.io/crates/dststlog-sys) +* [dsuiext-sys ![Crates.io](https://img.shields.io/crates/v/dsuiext-sys.svg)](https://crates.io/crates/dsuiext-sys) +* [dtchelp-sys ![Crates.io](https://img.shields.io/crates/v/dtchelp-sys.svg)](https://crates.io/crates/dtchelp-sys) +* [dwrite-sys ![Crates.io](https://img.shields.io/crates/v/dwrite-sys.svg)](https://crates.io/crates/dwrite-sys) +* [dxgi-sys ![Crates.io](https://img.shields.io/crates/v/dxgi-sys.svg)](https://crates.io/crates/dxgi-sys) +* [dxguid-sys ![Crates.io](https://img.shields.io/crates/v/dxguid-sys.svg)](https://crates.io/crates/dxguid-sys) +* [dxtmsft-sys ![Crates.io](https://img.shields.io/crates/v/dxtmsft-sys.svg)](https://crates.io/crates/dxtmsft-sys) +* [dxtrans-sys ![Crates.io](https://img.shields.io/crates/v/dxtrans-sys.svg)](https://crates.io/crates/dxtrans-sys) +* [dxva2-sys ![Crates.io](https://img.shields.io/crates/v/dxva2-sys.svg)](https://crates.io/crates/dxva2-sys) +* [eappcfg-sys ![Crates.io](https://img.shields.io/crates/v/eappcfg-sys.svg)](https://crates.io/crates/eappcfg-sys) +* [eappprxy-sys ![Crates.io](https://img.shields.io/crates/v/eappprxy-sys.svg)](https://crates.io/crates/eappprxy-sys) +* [easregprov-sys ![Crates.io](https://img.shields.io/crates/v/easregprov-sys.svg)](https://crates.io/crates/easregprov-sys) +* [efswrt-sys ![Crates.io](https://img.shields.io/crates/v/efswrt-sys.svg)](https://crates.io/crates/efswrt-sys) +* [ehstorguids-sys ![Crates.io](https://img.shields.io/crates/v/ehstorguids-sys.svg)](https://crates.io/crates/ehstorguids-sys) +* [elfapi-sys ![Crates.io](https://img.shields.io/crates/v/elfapi-sys.svg)](https://crates.io/crates/elfapi-sys) +* [els-sys ![Crates.io](https://img.shields.io/crates/v/els-sys.svg)](https://crates.io/crates/els-sys) +* [elscore-sys ![Crates.io](https://img.shields.io/crates/v/elscore-sys.svg)](https://crates.io/crates/elscore-sys) +* [esent-sys ![Crates.io](https://img.shields.io/crates/v/esent-sys.svg)](https://crates.io/crates/esent-sys) +* [evr-sys ![Crates.io](https://img.shields.io/crates/v/evr-sys.svg)](https://crates.io/crates/evr-sys) +* [evr_vista-sys ![Crates.io](https://img.shields.io/crates/v/evr_vista-sys.svg)](https://crates.io/crates/evr_vista-sys) +* [faultrep-sys ![Crates.io](https://img.shields.io/crates/v/faultrep-sys.svg)](https://crates.io/crates/faultrep-sys) +* [feclient-sys ![Crates.io](https://img.shields.io/crates/v/feclient-sys.svg)](https://crates.io/crates/feclient-sys) +* [fhsvcctl-sys ![Crates.io](https://img.shields.io/crates/v/fhsvcctl-sys.svg)](https://crates.io/crates/fhsvcctl-sys) +* [fileextd-sys ![Crates.io](https://img.shields.io/crates/v/fileextd-sys.svg)](https://crates.io/crates/fileextd-sys) +* [fltlib-sys ![Crates.io](https://img.shields.io/crates/v/fltlib-sys.svg)](https://crates.io/crates/fltlib-sys) +* [fontsub-sys ![Crates.io](https://img.shields.io/crates/v/fontsub-sys.svg)](https://crates.io/crates/fontsub-sys) +* [format-sys ![Crates.io](https://img.shields.io/crates/v/format-sys.svg)](https://crates.io/crates/format-sys) +* [framedyd-sys ![Crates.io](https://img.shields.io/crates/v/framedyd-sys.svg)](https://crates.io/crates/framedyd-sys) +* [framedyn-sys ![Crates.io](https://img.shields.io/crates/v/framedyn-sys.svg)](https://crates.io/crates/framedyn-sys) +* [fwpuclnt-sys ![Crates.io](https://img.shields.io/crates/v/fwpuclnt-sys.svg)](https://crates.io/crates/fwpuclnt-sys) +* [fxsutility-sys ![Crates.io](https://img.shields.io/crates/v/fxsutility-sys.svg)](https://crates.io/crates/fxsutility-sys) +* [gdiplus-sys ![Crates.io](https://img.shields.io/crates/v/gdiplus-sys.svg)](https://crates.io/crates/gdiplus-sys) +* [glmf32-sys ![Crates.io](https://img.shields.io/crates/v/glmf32-sys.svg)](https://crates.io/crates/glmf32-sys) +* [glu32-sys ![Crates.io](https://img.shields.io/crates/v/glu32-sys.svg)](https://crates.io/crates/glu32-sys) +* [gpedit-sys ![Crates.io](https://img.shields.io/crates/v/gpedit-sys.svg)](https://crates.io/crates/gpedit-sys) +* [gpmuuid-sys ![Crates.io](https://img.shields.io/crates/v/gpmuuid-sys.svg)](https://crates.io/crates/gpmuuid-sys) +* [hbaapi-sys ![Crates.io](https://img.shields.io/crates/v/hbaapi-sys.svg)](https://crates.io/crates/hbaapi-sys) +* [hhsetup-sys ![Crates.io](https://img.shields.io/crates/v/hhsetup-sys.svg)](https://crates.io/crates/hhsetup-sys) +* [hid-sys ![Crates.io](https://img.shields.io/crates/v/hid-sys.svg)](https://crates.io/crates/hid-sys) +* [hlink-sys ![Crates.io](https://img.shields.io/crates/v/hlink-sys.svg)](https://crates.io/crates/hlink-sys) +* [htmlhelp-sys ![Crates.io](https://img.shields.io/crates/v/htmlhelp-sys.svg)](https://crates.io/crates/htmlhelp-sys) +* [httpapi-sys ![Crates.io](https://img.shields.io/crates/v/httpapi-sys.svg)](https://crates.io/crates/httpapi-sys) +* [iashlpr-sys ![Crates.io](https://img.shields.io/crates/v/iashlpr-sys.svg)](https://crates.io/crates/iashlpr-sys) +* [icm32-sys ![Crates.io](https://img.shields.io/crates/v/icm32-sys.svg)](https://crates.io/crates/icm32-sys) +* [icmui-sys ![Crates.io](https://img.shields.io/crates/v/icmui-sys.svg)](https://crates.io/crates/icmui-sys) +* [iepmapi-sys ![Crates.io](https://img.shields.io/crates/v/iepmapi-sys.svg)](https://crates.io/crates/iepmapi-sys) +* [iesetup-sys ![Crates.io](https://img.shields.io/crates/v/iesetup-sys.svg)](https://crates.io/crates/iesetup-sys) +* [imagehlp-sys ![Crates.io](https://img.shields.io/crates/v/imagehlp-sys.svg)](https://crates.io/crates/imagehlp-sys) +* [imgutil-sys ![Crates.io](https://img.shields.io/crates/v/imgutil-sys.svg)](https://crates.io/crates/imgutil-sys) +* [imm32-sys ![Crates.io](https://img.shields.io/crates/v/imm32-sys.svg)](https://crates.io/crates/imm32-sys) +* [infocardapi-sys ![Crates.io](https://img.shields.io/crates/v/infocardapi-sys.svg)](https://crates.io/crates/infocardapi-sys) +* [inseng-sys ![Crates.io](https://img.shields.io/crates/v/inseng-sys.svg)](https://crates.io/crates/inseng-sys) +* [int64-sys ![Crates.io](https://img.shields.io/crates/v/int64-sys.svg)](https://crates.io/crates/int64-sys) +* [iphlpapi-sys ![Crates.io](https://img.shields.io/crates/v/iphlpapi-sys.svg)](https://crates.io/crates/iphlpapi-sys) +* [iprop-sys ![Crates.io](https://img.shields.io/crates/v/iprop-sys.svg)](https://crates.io/crates/iprop-sys) +* [irprops-sys ![Crates.io](https://img.shields.io/crates/v/irprops-sys.svg)](https://crates.io/crates/irprops-sys) +* [iscsidsc-sys ![Crates.io](https://img.shields.io/crates/v/iscsidsc-sys.svg)](https://crates.io/crates/iscsidsc-sys) +* [jetoledb-sys ![Crates.io](https://img.shields.io/crates/v/jetoledb-sys.svg)](https://crates.io/crates/jetoledb-sys) +* [jsrt-sys ![Crates.io](https://img.shields.io/crates/v/jsrt-sys.svg)](https://crates.io/crates/jsrt-sys) +* [kerbcli-sys ![Crates.io](https://img.shields.io/crates/v/kerbcli-sys.svg)](https://crates.io/crates/kerbcli-sys) +* [ksproxy-sys ![Crates.io](https://img.shields.io/crates/v/ksproxy-sys.svg)](https://crates.io/crates/ksproxy-sys) +* [ksuser-sys ![Crates.io](https://img.shields.io/crates/v/ksuser-sys.svg)](https://crates.io/crates/ksuser-sys) +* [loadperf-sys ![Crates.io](https://img.shields.io/crates/v/loadperf-sys.svg)](https://crates.io/crates/loadperf-sys) +* [locationapi-sys ![Crates.io](https://img.shields.io/crates/v/locationapi-sys.svg)](https://crates.io/crates/locationapi-sys) +* [lz32-sys ![Crates.io](https://img.shields.io/crates/v/lz32-sys.svg)](https://crates.io/crates/lz32-sys) +* [magnification-sys ![Crates.io](https://img.shields.io/crates/v/magnification-sys.svg)](https://crates.io/crates/magnification-sys) +* [mapi32-sys ![Crates.io](https://img.shields.io/crates/v/mapi32-sys.svg)](https://crates.io/crates/mapi32-sys) +* [mbnapi_uuid-sys ![Crates.io](https://img.shields.io/crates/v/mbnapi_uuid-sys.svg)](https://crates.io/crates/mbnapi_uuid-sys) +* [mciole32-sys ![Crates.io](https://img.shields.io/crates/v/mciole32-sys.svg)](https://crates.io/crates/mciole32-sys) +* [mdmregistration-sys ![Crates.io](https://img.shields.io/crates/v/mdmregistration-sys.svg)](https://crates.io/crates/mdmregistration-sys) +* [mf-sys ![Crates.io](https://img.shields.io/crates/v/mf-sys.svg)](https://crates.io/crates/mf-sys) +* [mf_vista-sys ![Crates.io](https://img.shields.io/crates/v/mf_vista-sys.svg)](https://crates.io/crates/mf_vista-sys) +* [mfcore-sys ![Crates.io](https://img.shields.io/crates/v/mfcore-sys.svg)](https://crates.io/crates/mfcore-sys) +* [mfplat-sys ![Crates.io](https://img.shields.io/crates/v/mfplat-sys.svg)](https://crates.io/crates/mfplat-sys) +* [mfplat_vista-sys ![Crates.io](https://img.shields.io/crates/v/mfplat_vista-sys.svg)](https://crates.io/crates/mfplat_vista-sys) +* [mfplay-sys ![Crates.io](https://img.shields.io/crates/v/mfplay-sys.svg)](https://crates.io/crates/mfplay-sys) +* [mfreadwrite-sys ![Crates.io](https://img.shields.io/crates/v/mfreadwrite-sys.svg)](https://crates.io/crates/mfreadwrite-sys) +* [mfsrcsnk-sys ![Crates.io](https://img.shields.io/crates/v/mfsrcsnk-sys.svg)](https://crates.io/crates/mfsrcsnk-sys) +* [mfuuid-sys ![Crates.io](https://img.shields.io/crates/v/mfuuid-sys.svg)](https://crates.io/crates/mfuuid-sys) +* [mgmtapi-sys ![Crates.io](https://img.shields.io/crates/v/mgmtapi-sys.svg)](https://crates.io/crates/mgmtapi-sys) +* [mi-sys ![Crates.io](https://img.shields.io/crates/v/mi-sys.svg)](https://crates.io/crates/mi-sys) +* [mincore-sys ![Crates.io](https://img.shields.io/crates/v/mincore-sys.svg)](https://crates.io/crates/mincore-sys) +* [mincore_downlevel-sys ![Crates.io](https://img.shields.io/crates/v/mincore_downlevel-sys.svg)](https://crates.io/crates/mincore_downlevel-sys) +* [mmc-sys ![Crates.io](https://img.shields.io/crates/v/mmc-sys.svg)](https://crates.io/crates/mmc-sys) +* [mmdevapi-sys ![Crates.io](https://img.shields.io/crates/v/mmdevapi-sys.svg)](https://crates.io/crates/mmdevapi-sys) +* [mprapi-sys ![Crates.io](https://img.shields.io/crates/v/mprapi-sys.svg)](https://crates.io/crates/mprapi-sys) +* [mprsnap-sys ![Crates.io](https://img.shields.io/crates/v/mprsnap-sys.svg)](https://crates.io/crates/mprsnap-sys) +* [mqoa-sys ![Crates.io](https://img.shields.io/crates/v/mqoa-sys.svg)](https://crates.io/crates/mqoa-sys) +* [mqrt-sys ![Crates.io](https://img.shields.io/crates/v/mqrt-sys.svg)](https://crates.io/crates/mqrt-sys) +* [msaatext-sys ![Crates.io](https://img.shields.io/crates/v/msaatext-sys.svg)](https://crates.io/crates/msaatext-sys) +* [msacm32-sys ![Crates.io](https://img.shields.io/crates/v/msacm32-sys.svg)](https://crates.io/crates/msacm32-sys) +* [mscms-sys ![Crates.io](https://img.shields.io/crates/v/mscms-sys.svg)](https://crates.io/crates/mscms-sys) +* [mscoree-sys ![Crates.io](https://img.shields.io/crates/v/mscoree-sys.svg)](https://crates.io/crates/mscoree-sys) +* [mscorsn-sys ![Crates.io](https://img.shields.io/crates/v/mscorsn-sys.svg)](https://crates.io/crates/mscorsn-sys) +* [msctfmonitor-sys ![Crates.io](https://img.shields.io/crates/v/msctfmonitor-sys.svg)](https://crates.io/crates/msctfmonitor-sys) +* [msdasc-sys ![Crates.io](https://img.shields.io/crates/v/msdasc-sys.svg)](https://crates.io/crates/msdasc-sys) +* [msdelta-sys ![Crates.io](https://img.shields.io/crates/v/msdelta-sys.svg)](https://crates.io/crates/msdelta-sys) +* [msdmo-sys ![Crates.io](https://img.shields.io/crates/v/msdmo-sys.svg)](https://crates.io/crates/msdmo-sys) +* [msdrm-sys ![Crates.io](https://img.shields.io/crates/v/msdrm-sys.svg)](https://crates.io/crates/msdrm-sys) +* [msi-sys ![Crates.io](https://img.shields.io/crates/v/msi-sys.svg)](https://crates.io/crates/msi-sys) +* [msimg32-sys ![Crates.io](https://img.shields.io/crates/v/msimg32-sys.svg)](https://crates.io/crates/msimg32-sys) +* [mspatcha-sys ![Crates.io](https://img.shields.io/crates/v/mspatcha-sys.svg)](https://crates.io/crates/mspatcha-sys) +* [mspatchc-sys ![Crates.io](https://img.shields.io/crates/v/mspatchc-sys.svg)](https://crates.io/crates/mspatchc-sys) +* [mspbase-sys ![Crates.io](https://img.shields.io/crates/v/mspbase-sys.svg)](https://crates.io/crates/mspbase-sys) +* [msports-sys ![Crates.io](https://img.shields.io/crates/v/msports-sys.svg)](https://crates.io/crates/msports-sys) +* [msrating-sys ![Crates.io](https://img.shields.io/crates/v/msrating-sys.svg)](https://crates.io/crates/msrating-sys) +* [mstask-sys ![Crates.io](https://img.shields.io/crates/v/mstask-sys.svg)](https://crates.io/crates/mstask-sys) +* [msv1_0-sys ![Crates.io](https://img.shields.io/crates/v/msv1_0-sys.svg)](https://crates.io/crates/msv1_0-sys) +* [msvfw32-sys ![Crates.io](https://img.shields.io/crates/v/msvfw32-sys.svg)](https://crates.io/crates/msvfw32-sys) +* [mswsock-sys ![Crates.io](https://img.shields.io/crates/v/mswsock-sys.svg)](https://crates.io/crates/mswsock-sys) +* [msxml2-sys ![Crates.io](https://img.shields.io/crates/v/msxml2-sys.svg)](https://crates.io/crates/msxml2-sys) +* [msxml6-sys ![Crates.io](https://img.shields.io/crates/v/msxml6-sys.svg)](https://crates.io/crates/msxml6-sys) +* [mtx-sys ![Crates.io](https://img.shields.io/crates/v/mtx-sys.svg)](https://crates.io/crates/mtx-sys) +* [mtxdm-sys ![Crates.io](https://img.shields.io/crates/v/mtxdm-sys.svg)](https://crates.io/crates/mtxdm-sys) +* [muiload-sys ![Crates.io](https://img.shields.io/crates/v/muiload-sys.svg)](https://crates.io/crates/muiload-sys) +* [ncrypt-sys ![Crates.io](https://img.shields.io/crates/v/ncrypt-sys.svg)](https://crates.io/crates/ncrypt-sys) +* [nddeapi-sys ![Crates.io](https://img.shields.io/crates/v/nddeapi-sys.svg)](https://crates.io/crates/nddeapi-sys) +* [ndfapi-sys ![Crates.io](https://img.shields.io/crates/v/ndfapi-sys.svg)](https://crates.io/crates/ndfapi-sys) +* [ndproxystub-sys ![Crates.io](https://img.shields.io/crates/v/ndproxystub-sys.svg)](https://crates.io/crates/ndproxystub-sys) +* [netapi32-sys ![Crates.io](https://img.shields.io/crates/v/netapi32-sys.svg)](https://crates.io/crates/netapi32-sys) +* [netlib-sys ![Crates.io](https://img.shields.io/crates/v/netlib-sys.svg)](https://crates.io/crates/netlib-sys) +* [netsh-sys ![Crates.io](https://img.shields.io/crates/v/netsh-sys.svg)](https://crates.io/crates/netsh-sys) +* [newdev-sys ![Crates.io](https://img.shields.io/crates/v/newdev-sys.svg)](https://crates.io/crates/newdev-sys) +* [ninput-sys ![Crates.io](https://img.shields.io/crates/v/ninput-sys.svg)](https://crates.io/crates/ninput-sys) +* [normaliz-sys ![Crates.io](https://img.shields.io/crates/v/normaliz-sys.svg)](https://crates.io/crates/normaliz-sys) +* [nt-sys ![Crates.io](https://img.shields.io/crates/v/nt-sys.svg)](https://crates.io/crates/nt-sys) +* [ntdll-sys ![Crates.io](https://img.shields.io/crates/v/ntdll-sys.svg)](https://crates.io/crates/ntdll-sys) +* [ntdsa-sys ![Crates.io](https://img.shields.io/crates/v/ntdsa-sys.svg)](https://crates.io/crates/ntdsa-sys) +* [ntdsapi-sys ![Crates.io](https://img.shields.io/crates/v/ntdsapi-sys.svg)](https://crates.io/crates/ntdsapi-sys) +* [ntdsatq-sys ![Crates.io](https://img.shields.io/crates/v/ntdsatq-sys.svg)](https://crates.io/crates/ntdsatq-sys) +* [ntdsetup-sys ![Crates.io](https://img.shields.io/crates/v/ntdsetup-sys.svg)](https://crates.io/crates/ntdsetup-sys) +* [ntfrsapi-sys ![Crates.io](https://img.shields.io/crates/v/ntfrsapi-sys.svg)](https://crates.io/crates/ntfrsapi-sys) +* [ntlanman-sys ![Crates.io](https://img.shields.io/crates/v/ntlanman-sys.svg)](https://crates.io/crates/ntlanman-sys) +* [ntmarta-sys ![Crates.io](https://img.shields.io/crates/v/ntmarta-sys.svg)](https://crates.io/crates/ntmarta-sys) +* [ntquery-sys ![Crates.io](https://img.shields.io/crates/v/ntquery-sys.svg)](https://crates.io/crates/ntquery-sys) +* [ntstc_libcmt-sys ![Crates.io](https://img.shields.io/crates/v/ntstc_libcmt-sys.svg)](https://crates.io/crates/ntstc_libcmt-sys) +* [ntstc_msvcrt-sys ![Crates.io](https://img.shields.io/crates/v/ntstc_msvcrt-sys.svg)](https://crates.io/crates/ntstc_msvcrt-sys) +* [ntvdm-sys ![Crates.io](https://img.shields.io/crates/v/ntvdm-sys.svg)](https://crates.io/crates/ntvdm-sys) +* [objsel-sys ![Crates.io](https://img.shields.io/crates/v/objsel-sys.svg)](https://crates.io/crates/objsel-sys) +* [odbc32-sys ![Crates.io](https://img.shields.io/crates/v/odbc32-sys.svg)](https://crates.io/crates/odbc32-sys) +* [odbcbcp-sys ![Crates.io](https://img.shields.io/crates/v/odbcbcp-sys.svg)](https://crates.io/crates/odbcbcp-sys) +* [odbccp32-sys ![Crates.io](https://img.shields.io/crates/v/odbccp32-sys.svg)](https://crates.io/crates/odbccp32-sys) +* [oemlicense-sys ![Crates.io](https://img.shields.io/crates/v/oemlicense-sys.svg)](https://crates.io/crates/oemlicense-sys) +* [oleacc-sys ![Crates.io](https://img.shields.io/crates/v/oleacc-sys.svg)](https://crates.io/crates/oleacc-sys) +* [oleaut32-sys ![Crates.io](https://img.shields.io/crates/v/oleaut32-sys.svg)](https://crates.io/crates/oleaut32-sys) +* [olecli32-sys ![Crates.io](https://img.shields.io/crates/v/olecli32-sys.svg)](https://crates.io/crates/olecli32-sys) +* [oledb-sys ![Crates.io](https://img.shields.io/crates/v/oledb-sys.svg)](https://crates.io/crates/oledb-sys) +* [oledlg-sys ![Crates.io](https://img.shields.io/crates/v/oledlg-sys.svg)](https://crates.io/crates/oledlg-sys) +* [olepro32-sys ![Crates.io](https://img.shields.io/crates/v/olepro32-sys.svg)](https://crates.io/crates/olepro32-sys) +* [olesvr32-sys ![Crates.io](https://img.shields.io/crates/v/olesvr32-sys.svg)](https://crates.io/crates/olesvr32-sys) +* [ondemandconnroutehelper-sys ![Crates.io](https://img.shields.io/crates/v/ondemandconnroutehelper-sys.svg)](https://crates.io/crates/ondemandconnroutehelper-sys) +* [osptk-sys ![Crates.io](https://img.shields.io/crates/v/osptk-sys.svg)](https://crates.io/crates/osptk-sys) +* [p2p-sys ![Crates.io](https://img.shields.io/crates/v/p2p-sys.svg)](https://crates.io/crates/p2p-sys) +* [p2pgraph-sys ![Crates.io](https://img.shields.io/crates/v/p2pgraph-sys.svg)](https://crates.io/crates/p2pgraph-sys) +* [patchwiz-sys ![Crates.io](https://img.shields.io/crates/v/patchwiz-sys.svg)](https://crates.io/crates/patchwiz-sys) +* [pathcch-sys ![Crates.io](https://img.shields.io/crates/v/pathcch-sys.svg)](https://crates.io/crates/pathcch-sys) +* [pdh-sys ![Crates.io](https://img.shields.io/crates/v/pdh-sys.svg)](https://crates.io/crates/pdh-sys) +* [peerdist-sys ![Crates.io](https://img.shields.io/crates/v/peerdist-sys.svg)](https://crates.io/crates/peerdist-sys) +* [photoacquireuid-sys ![Crates.io](https://img.shields.io/crates/v/photoacquireuid-sys.svg)](https://crates.io/crates/photoacquireuid-sys) +* [portabledeviceguids-sys ![Crates.io](https://img.shields.io/crates/v/portabledeviceguids-sys.svg)](https://crates.io/crates/portabledeviceguids-sys) +* [powrprof-sys ![Crates.io](https://img.shields.io/crates/v/powrprof-sys.svg)](https://crates.io/crates/powrprof-sys) +* [prntvpt-sys ![Crates.io](https://img.shields.io/crates/v/prntvpt-sys.svg)](https://crates.io/crates/prntvpt-sys) +* [propsys-sys ![Crates.io](https://img.shields.io/crates/v/propsys-sys.svg)](https://crates.io/crates/propsys-sys) +* [quartz-sys ![Crates.io](https://img.shields.io/crates/v/quartz-sys.svg)](https://crates.io/crates/quartz-sys) +* [query-sys ![Crates.io](https://img.shields.io/crates/v/query-sys.svg)](https://crates.io/crates/query-sys) +* [qutil-sys ![Crates.io](https://img.shields.io/crates/v/qutil-sys.svg)](https://crates.io/crates/qutil-sys) +* [qwave-sys ![Crates.io](https://img.shields.io/crates/v/qwave-sys.svg)](https://crates.io/crates/qwave-sys) +* [rasapi32-sys ![Crates.io](https://img.shields.io/crates/v/rasapi32-sys.svg)](https://crates.io/crates/rasapi32-sys) +* [rasdlg-sys ![Crates.io](https://img.shields.io/crates/v/rasdlg-sys.svg)](https://crates.io/crates/rasdlg-sys) +* [rasuser-sys ![Crates.io](https://img.shields.io/crates/v/rasuser-sys.svg)](https://crates.io/crates/rasuser-sys) +* [resutils-sys ![Crates.io](https://img.shields.io/crates/v/resutils-sys.svg)](https://crates.io/crates/resutils-sys) +* [rometadata-sys ![Crates.io](https://img.shields.io/crates/v/rometadata-sys.svg)](https://crates.io/crates/rometadata-sys) +* [rpcexts-sys ![Crates.io](https://img.shields.io/crates/v/rpcexts-sys.svg)](https://crates.io/crates/rpcexts-sys) +* [rpcns4-sys ![Crates.io](https://img.shields.io/crates/v/rpcns4-sys.svg)](https://crates.io/crates/rpcns4-sys) +* [rpcproxy-sys ![Crates.io](https://img.shields.io/crates/v/rpcproxy-sys.svg)](https://crates.io/crates/rpcproxy-sys) +* [rpcrt4-sys ![Crates.io](https://img.shields.io/crates/v/rpcrt4-sys.svg)](https://crates.io/crates/rpcrt4-sys) +* [rpcutil-sys ![Crates.io](https://img.shields.io/crates/v/rpcutil-sys.svg)](https://crates.io/crates/rpcutil-sys) +* [rstrtmgr-sys ![Crates.io](https://img.shields.io/crates/v/rstrtmgr-sys.svg)](https://crates.io/crates/rstrtmgr-sys) +* [rtm-sys ![Crates.io](https://img.shields.io/crates/v/rtm-sys.svg)](https://crates.io/crates/rtm-sys) +* [rtutils-sys ![Crates.io](https://img.shields.io/crates/v/rtutils-sys.svg)](https://crates.io/crates/rtutils-sys) +* [rtworkq-sys ![Crates.io](https://img.shields.io/crates/v/rtworkq-sys.svg)](https://crates.io/crates/rtworkq-sys) +* [runtimeobject-sys ![Crates.io](https://img.shields.io/crates/v/runtimeobject-sys.svg)](https://crates.io/crates/runtimeobject-sys) +* [samlib-sys ![Crates.io](https://img.shields.io/crates/v/samlib-sys.svg)](https://crates.io/crates/samlib-sys) +* [samsrv-sys ![Crates.io](https://img.shields.io/crates/v/samsrv-sys.svg)](https://crates.io/crates/samsrv-sys) +* [sapi-sys ![Crates.io](https://img.shields.io/crates/v/sapi-sys.svg)](https://crates.io/crates/sapi-sys) +* [sas-sys ![Crates.io](https://img.shields.io/crates/v/sas-sys.svg)](https://crates.io/crates/sas-sys) +* [sbtsv-sys ![Crates.io](https://img.shields.io/crates/v/sbtsv-sys.svg)](https://crates.io/crates/sbtsv-sys) +* [scarddlg-sys ![Crates.io](https://img.shields.io/crates/v/scarddlg-sys.svg)](https://crates.io/crates/scarddlg-sys) +* [scecli-sys ![Crates.io](https://img.shields.io/crates/v/scecli-sys.svg)](https://crates.io/crates/scecli-sys) +* [scesrv-sys ![Crates.io](https://img.shields.io/crates/v/scesrv-sys.svg)](https://crates.io/crates/scesrv-sys) +* [schannel-sys ![Crates.io](https://img.shields.io/crates/v/schannel-sys.svg)](https://crates.io/crates/schannel-sys) +* [scrnsave-sys ![Crates.io](https://img.shields.io/crates/v/scrnsave-sys.svg)](https://crates.io/crates/scrnsave-sys) +* [scrnsavw-sys ![Crates.io](https://img.shields.io/crates/v/scrnsavw-sys.svg)](https://crates.io/crates/scrnsavw-sys) +* [searchsdk-sys ![Crates.io](https://img.shields.io/crates/v/searchsdk-sys.svg)](https://crates.io/crates/searchsdk-sys) +* [secur32-sys ![Crates.io](https://img.shields.io/crates/v/secur32-sys.svg)](https://crates.io/crates/secur32-sys) +* [security-sys ![Crates.io](https://img.shields.io/crates/v/security-sys.svg)](https://crates.io/crates/security-sys) +* [sens-sys ![Crates.io](https://img.shields.io/crates/v/sens-sys.svg)](https://crates.io/crates/sens-sys) +* [sensapi-sys ![Crates.io](https://img.shields.io/crates/v/sensapi-sys.svg)](https://crates.io/crates/sensapi-sys) +* [sensorsapi-sys ![Crates.io](https://img.shields.io/crates/v/sensorsapi-sys.svg)](https://crates.io/crates/sensorsapi-sys) +* [setupapi-sys ![Crates.io](https://img.shields.io/crates/v/setupapi-sys.svg)](https://crates.io/crates/setupapi-sys) +* [sfc-sys ![Crates.io](https://img.shields.io/crates/v/sfc-sys.svg)](https://crates.io/crates/sfc-sys) +* [shcore-sys ![Crates.io](https://img.shields.io/crates/v/shcore-sys.svg)](https://crates.io/crates/shcore-sys) +* [shdocvw-sys ![Crates.io](https://img.shields.io/crates/v/shdocvw-sys.svg)](https://crates.io/crates/shdocvw-sys) +* [shfolder-sys ![Crates.io](https://img.shields.io/crates/v/shfolder-sys.svg)](https://crates.io/crates/shfolder-sys) +* [shlwapi-sys ![Crates.io](https://img.shields.io/crates/v/shlwapi-sys.svg)](https://crates.io/crates/shlwapi-sys) +* [sisbkup-sys ![Crates.io](https://img.shields.io/crates/v/sisbkup-sys.svg)](https://crates.io/crates/sisbkup-sys) +* [slc-sys ![Crates.io](https://img.shields.io/crates/v/slc-sys.svg)](https://crates.io/crates/slc-sys) +* [slcext-sys ![Crates.io](https://img.shields.io/crates/v/slcext-sys.svg)](https://crates.io/crates/slcext-sys) +* [slwga-sys ![Crates.io](https://img.shields.io/crates/v/slwga-sys.svg)](https://crates.io/crates/slwga-sys) +* [snmpapi-sys ![Crates.io](https://img.shields.io/crates/v/snmpapi-sys.svg)](https://crates.io/crates/snmpapi-sys) +* [spoolss-sys ![Crates.io](https://img.shields.io/crates/v/spoolss-sys.svg)](https://crates.io/crates/spoolss-sys) +* [sporder-sys ![Crates.io](https://img.shields.io/crates/v/sporder-sys.svg)](https://crates.io/crates/sporder-sys) +* [srclient-sys ![Crates.io](https://img.shields.io/crates/v/srclient-sys.svg)](https://crates.io/crates/srclient-sys) +* [ssdpapi-sys ![Crates.io](https://img.shields.io/crates/v/ssdpapi-sys.svg)](https://crates.io/crates/ssdpapi-sys) +* [sti-sys ![Crates.io](https://img.shields.io/crates/v/sti-sys.svg)](https://crates.io/crates/sti-sys) +* [strmbase-sys ![Crates.io](https://img.shields.io/crates/v/strmbase-sys.svg)](https://crates.io/crates/strmbase-sys) +* [strmiids-sys ![Crates.io](https://img.shields.io/crates/v/strmiids-sys.svg)](https://crates.io/crates/strmiids-sys) +* [strsafe-sys ![Crates.io](https://img.shields.io/crates/v/strsafe-sys.svg)](https://crates.io/crates/strsafe-sys) +* [structuredquery-sys ![Crates.io](https://img.shields.io/crates/v/structuredquery-sys.svg)](https://crates.io/crates/structuredquery-sys) +* [svcguid-sys ![Crates.io](https://img.shields.io/crates/v/svcguid-sys.svg)](https://crates.io/crates/svcguid-sys) +* [swdevice-sys ![Crates.io](https://img.shields.io/crates/v/swdevice-sys.svg)](https://crates.io/crates/swdevice-sys) +* [synchronization-sys ![Crates.io](https://img.shields.io/crates/v/synchronization-sys.svg)](https://crates.io/crates/synchronization-sys) +* [t2embed-sys ![Crates.io](https://img.shields.io/crates/v/t2embed-sys.svg)](https://crates.io/crates/t2embed-sys) +* [tapi32-sys ![Crates.io](https://img.shields.io/crates/v/tapi32-sys.svg)](https://crates.io/crates/tapi32-sys) +* [tapi32l-sys ![Crates.io](https://img.shields.io/crates/v/tapi32l-sys.svg)](https://crates.io/crates/tapi32l-sys) +* [taskschd-sys ![Crates.io](https://img.shields.io/crates/v/taskschd-sys.svg)](https://crates.io/crates/taskschd-sys) +* [tbs-sys ![Crates.io](https://img.shields.io/crates/v/tbs-sys.svg)](https://crates.io/crates/tbs-sys) +* [tdh-sys ![Crates.io](https://img.shields.io/crates/v/tdh-sys.svg)](https://crates.io/crates/tdh-sys) +* [thunk32-sys ![Crates.io](https://img.shields.io/crates/v/thunk32-sys.svg)](https://crates.io/crates/thunk32-sys) +* [tlbref-sys ![Crates.io](https://img.shields.io/crates/v/tlbref-sys.svg)](https://crates.io/crates/tlbref-sys) +* [traffic-sys ![Crates.io](https://img.shields.io/crates/v/traffic-sys.svg)](https://crates.io/crates/traffic-sys) +* [transcodeimageuid-sys ![Crates.io](https://img.shields.io/crates/v/transcodeimageuid-sys.svg)](https://crates.io/crates/transcodeimageuid-sys) +* [tsec-sys ![Crates.io](https://img.shields.io/crates/v/tsec-sys.svg)](https://crates.io/crates/tsec-sys) +* [tspubplugincom-sys ![Crates.io](https://img.shields.io/crates/v/tspubplugincom-sys.svg)](https://crates.io/crates/tspubplugincom-sys) +* [twain_32-sys ![Crates.io](https://img.shields.io/crates/v/twain_32-sys.svg)](https://crates.io/crates/twain_32-sys) +* [twinapi-sys ![Crates.io](https://img.shields.io/crates/v/twinapi-sys.svg)](https://crates.io/crates/twinapi-sys) +* [txfw32-sys ![Crates.io](https://img.shields.io/crates/v/txfw32-sys.svg)](https://crates.io/crates/txfw32-sys) +* [ualapi-sys ![Crates.io](https://img.shields.io/crates/v/ualapi-sys.svg)](https://crates.io/crates/ualapi-sys) +* [uiautomationcore-sys ![Crates.io](https://img.shields.io/crates/v/uiautomationcore-sys.svg)](https://crates.io/crates/uiautomationcore-sys) +* [umpdddi-sys ![Crates.io](https://img.shields.io/crates/v/umpdddi-sys.svg)](https://crates.io/crates/umpdddi-sys) +* [unicows-sys ![Crates.io](https://img.shields.io/crates/v/unicows-sys.svg)](https://crates.io/crates/unicows-sys) +* [urlmon-sys ![Crates.io](https://img.shields.io/crates/v/urlmon-sys.svg)](https://crates.io/crates/urlmon-sys) +* [userenv-sys ![Crates.io](https://img.shields.io/crates/v/userenv-sys.svg)](https://crates.io/crates/userenv-sys) +* [usp10-sys ![Crates.io](https://img.shields.io/crates/v/usp10-sys.svg)](https://crates.io/crates/usp10-sys) +* [uxtheme-sys ![Crates.io](https://img.shields.io/crates/v/uxtheme-sys.svg)](https://crates.io/crates/uxtheme-sys) +* [vccomsup-sys ![Crates.io](https://img.shields.io/crates/v/vccomsup-sys.svg)](https://crates.io/crates/vccomsup-sys) +* [vdmdbg-sys ![Crates.io](https://img.shields.io/crates/v/vdmdbg-sys.svg)](https://crates.io/crates/vdmdbg-sys) +* [vds_uuid-sys ![Crates.io](https://img.shields.io/crates/v/vds_uuid-sys.svg)](https://crates.io/crates/vds_uuid-sys) +* [version-sys ![Crates.io](https://img.shields.io/crates/v/version-sys.svg)](https://crates.io/crates/version-sys) +* [vfw32-sys ![Crates.io](https://img.shields.io/crates/v/vfw32-sys.svg)](https://crates.io/crates/vfw32-sys) +* [virtdisk-sys ![Crates.io](https://img.shields.io/crates/v/virtdisk-sys.svg)](https://crates.io/crates/virtdisk-sys) +* [vscmgr-sys ![Crates.io](https://img.shields.io/crates/v/vscmgr-sys.svg)](https://crates.io/crates/vscmgr-sys) +* [vss_uuid-sys ![Crates.io](https://img.shields.io/crates/v/vss_uuid-sys.svg)](https://crates.io/crates/vss_uuid-sys) +* [vssapi-sys ![Crates.io](https://img.shields.io/crates/v/vssapi-sys.svg)](https://crates.io/crates/vssapi-sys) +* [vstorinterface-sys ![Crates.io](https://img.shields.io/crates/v/vstorinterface-sys.svg)](https://crates.io/crates/vstorinterface-sys) +* [wbemuuid-sys ![Crates.io](https://img.shields.io/crates/v/wbemuuid-sys.svg)](https://crates.io/crates/wbemuuid-sys) +* [wcmapi-sys ![Crates.io](https://img.shields.io/crates/v/wcmapi-sys.svg)](https://crates.io/crates/wcmapi-sys) +* [wcmguid-sys ![Crates.io](https://img.shields.io/crates/v/wcmguid-sys.svg)](https://crates.io/crates/wcmguid-sys) +* [wdsbp-sys ![Crates.io](https://img.shields.io/crates/v/wdsbp-sys.svg)](https://crates.io/crates/wdsbp-sys) +* [wdsclientapi-sys ![Crates.io](https://img.shields.io/crates/v/wdsclientapi-sys.svg)](https://crates.io/crates/wdsclientapi-sys) +* [wdsmc-sys ![Crates.io](https://img.shields.io/crates/v/wdsmc-sys.svg)](https://crates.io/crates/wdsmc-sys) +* [wdspxe-sys ![Crates.io](https://img.shields.io/crates/v/wdspxe-sys.svg)](https://crates.io/crates/wdspxe-sys) +* [wdstptc-sys ![Crates.io](https://img.shields.io/crates/v/wdstptc-sys.svg)](https://crates.io/crates/wdstptc-sys) +* [webservices-sys ![Crates.io](https://img.shields.io/crates/v/webservices-sys.svg)](https://crates.io/crates/webservices-sys) +* [websocket-sys ![Crates.io](https://img.shields.io/crates/v/websocket-sys.svg)](https://crates.io/crates/websocket-sys) +* [wecapi-sys ![Crates.io](https://img.shields.io/crates/v/wecapi-sys.svg)](https://crates.io/crates/wecapi-sys) +* [wer-sys ![Crates.io](https://img.shields.io/crates/v/wer-sys.svg)](https://crates.io/crates/wer-sys) +* [wevtapi-sys ![Crates.io](https://img.shields.io/crates/v/wevtapi-sys.svg)](https://crates.io/crates/wevtapi-sys) +* [wiaguid-sys ![Crates.io](https://img.shields.io/crates/v/wiaguid-sys.svg)](https://crates.io/crates/wiaguid-sys) +* [wiaservc-sys ![Crates.io](https://img.shields.io/crates/v/wiaservc-sys.svg)](https://crates.io/crates/wiaservc-sys) +* [wiautil-sys ![Crates.io](https://img.shields.io/crates/v/wiautil-sys.svg)](https://crates.io/crates/wiautil-sys) +* [winbio-sys ![Crates.io](https://img.shields.io/crates/v/winbio-sys.svg)](https://crates.io/crates/winbio-sys) +* [windows-data-pdf-sys ![Crates.io](https://img.shields.io/crates/v/windows-data-pdf-sys.svg)](https://crates.io/crates/windows-data-pdf-sys) +* [windows-networking-sys ![Crates.io](https://img.shields.io/crates/v/windows-networking-sys.svg)](https://crates.io/crates/windows-networking-sys) +* [windows-ui-sys ![Crates.io](https://img.shields.io/crates/v/windows-ui-sys.svg)](https://crates.io/crates/windows-ui-sys) +* [windowscodecs-sys ![Crates.io](https://img.shields.io/crates/v/windowscodecs-sys.svg)](https://crates.io/crates/windowscodecs-sys) +* [windowssideshowguids-sys ![Crates.io](https://img.shields.io/crates/v/windowssideshowguids-sys.svg)](https://crates.io/crates/windowssideshowguids-sys) +* [winfax-sys ![Crates.io](https://img.shields.io/crates/v/winfax-sys.svg)](https://crates.io/crates/winfax-sys) +* [winhttp-sys ![Crates.io](https://img.shields.io/crates/v/winhttp-sys.svg)](https://crates.io/crates/winhttp-sys) +* [wininet-sys ![Crates.io](https://img.shields.io/crates/v/wininet-sys.svg)](https://crates.io/crates/wininet-sys) +* [winsatapi-sys ![Crates.io](https://img.shields.io/crates/v/winsatapi-sys.svg)](https://crates.io/crates/winsatapi-sys) +* [winscard-sys ![Crates.io](https://img.shields.io/crates/v/winscard-sys.svg)](https://crates.io/crates/winscard-sys) +* [winspool-sys ![Crates.io](https://img.shields.io/crates/v/winspool-sys.svg)](https://crates.io/crates/winspool-sys) +* [winsta-sys ![Crates.io](https://img.shields.io/crates/v/winsta-sys.svg)](https://crates.io/crates/winsta-sys) +* [winstrm-sys ![Crates.io](https://img.shields.io/crates/v/winstrm-sys.svg)](https://crates.io/crates/winstrm-sys) +* [wintrust-sys ![Crates.io](https://img.shields.io/crates/v/wintrust-sys.svg)](https://crates.io/crates/wintrust-sys) +* [winusb-sys ![Crates.io](https://img.shields.io/crates/v/winusb-sys.svg)](https://crates.io/crates/winusb-sys) +* [wlanapi-sys ![Crates.io](https://img.shields.io/crates/v/wlanapi-sys.svg)](https://crates.io/crates/wlanapi-sys) +* [wlanui-sys ![Crates.io](https://img.shields.io/crates/v/wlanui-sys.svg)](https://crates.io/crates/wlanui-sys) +* [wldap32-sys ![Crates.io](https://img.shields.io/crates/v/wldap32-sys.svg)](https://crates.io/crates/wldap32-sys) +* [wmcodecdspuuid-sys ![Crates.io](https://img.shields.io/crates/v/wmcodecdspuuid-sys.svg)](https://crates.io/crates/wmcodecdspuuid-sys) +* [wmdrmsdk-sys ![Crates.io](https://img.shields.io/crates/v/wmdrmsdk-sys.svg)](https://crates.io/crates/wmdrmsdk-sys) +* [wmip-sys ![Crates.io](https://img.shields.io/crates/v/wmip-sys.svg)](https://crates.io/crates/wmip-sys) +* [wmiutils-sys ![Crates.io](https://img.shields.io/crates/v/wmiutils-sys.svg)](https://crates.io/crates/wmiutils-sys) +* [wmvcore-sys ![Crates.io](https://img.shields.io/crates/v/wmvcore-sys.svg)](https://crates.io/crates/wmvcore-sys) +* [wnvapi-sys ![Crates.io](https://img.shields.io/crates/v/wnvapi-sys.svg)](https://crates.io/crates/wnvapi-sys) +* [workspaceax-sys ![Crates.io](https://img.shields.io/crates/v/workspaceax-sys.svg)](https://crates.io/crates/workspaceax-sys) +* [wow32-sys ![Crates.io](https://img.shields.io/crates/v/wow32-sys.svg)](https://crates.io/crates/wow32-sys) +* [ws2_32-sys ![Crates.io](https://img.shields.io/crates/v/ws2_32-sys.svg)](https://crates.io/crates/ws2_32-sys) +* [wsbapp_uuid-sys ![Crates.io](https://img.shields.io/crates/v/wsbapp_uuid-sys.svg)](https://crates.io/crates/wsbapp_uuid-sys) +* [wsbonline-sys ![Crates.io](https://img.shields.io/crates/v/wsbonline-sys.svg)](https://crates.io/crates/wsbonline-sys) +* [wscapi-sys ![Crates.io](https://img.shields.io/crates/v/wscapi-sys.svg)](https://crates.io/crates/wscapi-sys) +* [wsclient-sys ![Crates.io](https://img.shields.io/crates/v/wsclient-sys.svg)](https://crates.io/crates/wsclient-sys) +* [wsdapi-sys ![Crates.io](https://img.shields.io/crates/v/wsdapi-sys.svg)](https://crates.io/crates/wsdapi-sys) +* [wsmsvc-sys ![Crates.io](https://img.shields.io/crates/v/wsmsvc-sys.svg)](https://crates.io/crates/wsmsvc-sys) +* [wsnmp32-sys ![Crates.io](https://img.shields.io/crates/v/wsnmp32-sys.svg)](https://crates.io/crates/wsnmp32-sys) +* [wsock32-sys ![Crates.io](https://img.shields.io/crates/v/wsock32-sys.svg)](https://crates.io/crates/wsock32-sys) +* [wtsapi32-sys ![Crates.io](https://img.shields.io/crates/v/wtsapi32-sys.svg)](https://crates.io/crates/wtsapi32-sys) +* [wuguid-sys ![Crates.io](https://img.shields.io/crates/v/wuguid-sys.svg)](https://crates.io/crates/wuguid-sys) +* [xapobase-sys ![Crates.io](https://img.shields.io/crates/v/xapobase-sys.svg)](https://crates.io/crates/xapobase-sys) +* [xaswitch-sys ![Crates.io](https://img.shields.io/crates/v/xaswitch-sys.svg)](https://crates.io/crates/xaswitch-sys) +* [xaudio2-sys ![Crates.io](https://img.shields.io/crates/v/xaudio2-sys.svg)](https://crates.io/crates/xaudio2-sys) +* [xinput-sys ![Crates.io](https://img.shields.io/crates/v/xinput-sys.svg)](https://crates.io/crates/xinput-sys) +* [xinput9_1_0-sys ![Crates.io](https://img.shields.io/crates/v/xinput9_1_0-sys.svg)](https://crates.io/crates/xinput9_1_0-sys) +* [xmllite-sys ![Crates.io](https://img.shields.io/crates/v/xmllite-sys.svg)](https://crates.io/crates/xmllite-sys) +* [xolehlp-sys ![Crates.io](https://img.shields.io/crates/v/xolehlp-sys.svg)](https://crates.io/crates/xolehlp-sys) +* [xpsprint-sys ![Crates.io](https://img.shields.io/crates/v/xpsprint-sys.svg)](https://crates.io/crates/xpsprint-sys) diff --git a/deps/winapi-0.1.23/src/audioclient.rs b/deps/winapi-0.1.23/src/audioclient.rs new file mode 100644 index 000000000..3ae8b8bb2 --- /dev/null +++ b/deps/winapi-0.1.23/src/audioclient.rs @@ -0,0 +1,120 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +//1627 +macro_rules! AUDCLNT_ERR { + ($n:expr) => { + MAKE_HRESULT!(::SEVERITY_ERROR, ::FACILITY_AUDCLNT, $n) + }; +} +macro_rules! AUDCLNT_SUCCESS { + ($n:expr) => { + MAKE_SCODE!(::SEVERITY_SUCCESS, ::FACILITY_AUDCLNT, $n) + }; +} +pub const AUDCLNT_E_NOT_INITIALIZED: ::HRESULT = AUDCLNT_ERR!(0x001); +pub const AUDCLNT_E_ALREADY_INITIALIZED: ::HRESULT = AUDCLNT_ERR!(0x002); +pub const AUDCLNT_E_WRONG_ENDPOINT_TYPE: ::HRESULT = AUDCLNT_ERR!(0x003); +pub const AUDCLNT_E_DEVICE_INVALIDATED: ::HRESULT = AUDCLNT_ERR!(0x004); +pub const AUDCLNT_E_NOT_STOPPED: ::HRESULT = AUDCLNT_ERR!(0x005); +pub const AUDCLNT_E_BUFFER_TOO_LARGE: ::HRESULT = AUDCLNT_ERR!(0x006); +pub const AUDCLNT_E_OUT_OF_ORDER: ::HRESULT = AUDCLNT_ERR!(0x007); +pub const AUDCLNT_E_UNSUPPORTED_FORMAT: ::HRESULT = AUDCLNT_ERR!(0x008); +pub const AUDCLNT_E_INVALID_SIZE: ::HRESULT = AUDCLNT_ERR!(0x009); +pub const AUDCLNT_E_DEVICE_IN_USE: ::HRESULT = AUDCLNT_ERR!(0x00a); +pub const AUDCLNT_E_BUFFER_OPERATION_PENDING: ::HRESULT = AUDCLNT_ERR!(0x00b); +pub const AUDCLNT_E_THREAD_NOT_REGISTERED: ::HRESULT = AUDCLNT_ERR!(0x00c); +pub const AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED: ::HRESULT = AUDCLNT_ERR!(0x00e); +pub const AUDCLNT_E_ENDPOINT_CREATE_FAILED: ::HRESULT = AUDCLNT_ERR!(0x00f); +pub const AUDCLNT_E_SERVICE_NOT_RUNNING: ::HRESULT = AUDCLNT_ERR!(0x010); +pub const AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED: ::HRESULT = AUDCLNT_ERR!(0x011); +pub const AUDCLNT_E_EXCLUSIVE_MODE_ONLY: ::HRESULT = AUDCLNT_ERR!(0x012); +pub const AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: ::HRESULT = AUDCLNT_ERR!(0x013); +pub const AUDCLNT_E_EVENTHANDLE_NOT_SET: ::HRESULT = AUDCLNT_ERR!(0x014); +pub const AUDCLNT_E_INCORRECT_BUFFER_SIZE: ::HRESULT = AUDCLNT_ERR!(0x015); +pub const AUDCLNT_E_BUFFER_SIZE_ERROR: ::HRESULT = AUDCLNT_ERR!(0x016); +pub const AUDCLNT_E_CPUUSAGE_EXCEEDED: ::HRESULT = AUDCLNT_ERR!(0x017); +pub const AUDCLNT_E_BUFFER_ERROR: ::HRESULT = AUDCLNT_ERR!(0x018); +pub const AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED: ::HRESULT = AUDCLNT_ERR!(0x019); +pub const AUDCLNT_E_INVALID_DEVICE_PERIOD: ::HRESULT = AUDCLNT_ERR!(0x020); +pub const AUDCLNT_E_INVALID_STREAM_FLAG: ::HRESULT = AUDCLNT_ERR!(0x021); +pub const AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE: ::HRESULT = AUDCLNT_ERR!(0x022); +pub const AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES: ::HRESULT = AUDCLNT_ERR!(0x023); +pub const AUDCLNT_E_OFFLOAD_MODE_ONLY: ::HRESULT = AUDCLNT_ERR!(0x024); +pub const AUDCLNT_E_NONOFFLOAD_MODE_ONLY: ::HRESULT = AUDCLNT_ERR!(0x025); +pub const AUDCLNT_E_RESOURCES_INVALIDATED: ::HRESULT = AUDCLNT_ERR!(0x026); +pub const AUDCLNT_E_RAW_MODE_UNSUPPORTED: ::HRESULT = AUDCLNT_ERR!(0x027); +pub const AUDCLNT_S_BUFFER_EMPTY: ::SCODE = AUDCLNT_SUCCESS!(0x001); +pub const AUDCLNT_S_THREAD_ALREADY_REGISTERED: ::SCODE = AUDCLNT_SUCCESS!(0x002); +pub const AUDCLNT_S_POSITION_STALLED: ::SCODE = AUDCLNT_SUCCESS!(0x003); + +pub const IID_IAudioClient: ::IID = ::GUID { + Data1: 0x1CB9AD4C, + Data2: 0xDBFA, + Data3: 0x4c32, + Data4: [0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2], +}; + +pub const IID_IAudioRenderClient: ::IID = ::GUID { + Data1: 0xF294ACFC, + Data2: 0x3146, + Data3: 0x4483, + Data4: [0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2], +}; + +RIDL!( +interface IAudioClient(IAudioClientVtbl): IUnknown(IUnknownVtbl) { + fn Initialize( + &mut self, + ShareMode: ::AUDCLNT_SHAREMODE, + StreamFlags: ::DWORD, + hnsBufferDuration: ::REFERENCE_TIME, + hnsPeriodicity: ::REFERENCE_TIME, + pFormat: *const ::WAVEFORMATEX, + AudioSessionGuid: ::LPCGUID + ) -> ::HRESULT, + fn GetBufferSize( + &mut self, + pNumBufferFrames: *mut ::UINT32 + ) -> ::HRESULT, + fn GetStreamLatency( + &mut self, + phnsLatency: *mut ::REFERENCE_TIME + ) -> ::HRESULT, + fn GetCurrentPadding(&mut self, pNumPaddingFrames: *mut ::UINT32) -> ::HRESULT, + fn IsFormatSupported( + &mut self, + ShareMode: ::AUDCLNT_SHAREMODE, + pFormat: *const ::WAVEFORMATEX, + ppClosestMatch: *mut *mut ::WAVEFORMATEX + ) -> ::HRESULT, + fn GetMixFormat( + &mut self, + ppDeviceFormat: *mut *mut ::WAVEFORMATEX + ) -> ::HRESULT, + fn GetDevicePeriod( + &mut self, + phnsDefaultDevicePeriod: *mut ::REFERENCE_TIME, + phnsMinimumDevicePeriod: *mut ::REFERENCE_TIME + ) -> ::HRESULT, + fn Start(&mut self) -> ::HRESULT, + fn Stop(&mut self) -> ::HRESULT, + fn Reset(&mut self) -> ::HRESULT, + fn SetEventHandle(&mut self, eventHandle: ::HANDLE) -> ::HRESULT, + fn GetService(&mut self, riid: ::REFIID, ppv: *mut ::LPVOID) -> ::HRESULT +} +); +RIDL!( +interface IAudioRenderClient(IAudioRenderClientVtbl): IUnknown(IUnknownVtbl) { + fn GetBuffer( + &mut self, + NumFramesRequested: ::UINT32, + ppData: *mut *mut ::BYTE + ) -> ::HRESULT, + fn ReleaseBuffer( + &mut self, + NumFramesWritten: ::UINT32, + dwFlags: ::DWORD + ) -> ::HRESULT +} +); diff --git a/deps/winapi-0.1.23/src/basetsd.rs b/deps/winapi-0.1.23/src/basetsd.rs new file mode 100644 index 000000000..6bf20fc96 --- /dev/null +++ b/deps/winapi-0.1.23/src/basetsd.rs @@ -0,0 +1,99 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Type definitions for the basic sized types. +#[cfg(target_arch = "x86")] +pub type POINTER_64_INT = ::c_ulong; +#[cfg(target_arch = "x86_64")] +pub type POINTER_64_INT = ::__uint64; +pub type INT8 = ::c_schar; +pub type PINT8 = *mut ::c_schar; +pub type INT16 = ::c_short; +pub type PINT16 = *mut ::c_short; +pub type INT32 = ::c_int; +pub type PINT32 = *mut ::c_int; +pub type INT64 = ::__int64; +pub type PINT64 = *mut ::__int64; +pub type UINT8 = ::c_uchar; +pub type PUINT8 = *mut ::c_uchar; +pub type UINT16 = ::c_ushort; +pub type PUINT16 = *mut ::c_ushort; +pub type UINT32 = ::c_uint; +pub type PUINT32 = *mut ::c_uint; +pub type UINT64 = ::__uint64; +pub type PUINT64 = *mut ::__uint64; +pub type LONG32 = ::c_int; +pub type PLONG32 = *mut ::c_int; +pub type ULONG32 = ::c_uint; +pub type PULONG32 = *mut ::c_uint; +pub type DWORD32 = ::c_uint; +pub type PDWORD32 = *mut ::c_uint; +#[cfg(target_arch = "x86")] +pub type INT_PTR = ::c_int; +#[cfg(target_arch = "x86_64")] +pub type INT_PTR = ::__int64; +#[cfg(target_arch = "x86")] +pub type PINT_PTR = *mut ::c_int; +#[cfg(target_arch = "x86_64")] +pub type PINT_PTR = *mut ::__int64; +#[cfg(target_arch = "x86")] +pub type UINT_PTR = ::c_uint; +#[cfg(target_arch = "x86_64")] +pub type UINT_PTR = ::__uint64; +#[cfg(target_arch = "x86")] +pub type PUINT_PTR = *mut ::c_uint; +#[cfg(target_arch = "x86_64")] +pub type PUINT_PTR = *mut ::__uint64; +#[cfg(target_arch = "x86")] +pub type LONG_PTR = ::c_long; +#[cfg(target_arch = "x86_64")] +pub type LONG_PTR = ::__int64; +#[cfg(target_arch = "x86")] +pub type PLONG_PTR = *mut ::c_long; +#[cfg(target_arch = "x86_64")] +pub type PLONG_PTR = *mut ::__int64; +#[cfg(target_arch = "x86")] +pub type ULONG_PTR = ::c_ulong; +#[cfg(target_arch = "x86_64")] +pub type ULONG_PTR = ::__uint64; +#[cfg(target_arch = "x86")] +pub type PULONG_PTR = *mut ::c_ulong; +#[cfg(target_arch = "x86_64")] +pub type PULONG_PTR = *mut ::__uint64; +#[cfg(target_arch = "x86_64")] +pub type SHANDLE_PTR = ::__int64; +#[cfg(target_arch = "x86_64")] +pub type HANDLE_PTR = ::__uint64; +#[cfg(target_arch = "x86_64")] +pub type UHALF_PTR = ::c_uint; +#[cfg(target_arch = "x86_64")] +pub type PUHALF_PTR = *mut ::c_uint; +#[cfg(target_arch = "x86_64")] +pub type HALF_PTR = ::c_int; +#[cfg(target_arch = "x86_64")] +pub type PHALF_PTR = *mut ::c_int; +#[cfg(target_arch = "x86")] +pub type SHANDLE_PTR = ::c_long; +#[cfg(target_arch = "x86")] +pub type HANDLE_PTR = ::c_ulong; +#[cfg(target_arch = "x86")] +pub type UHALF_PTR = ::c_ushort; +#[cfg(target_arch = "x86")] +pub type PUHALF_PTR = *mut ::c_ushort; +#[cfg(target_arch = "x86")] +pub type HALF_PTR = ::c_short; +#[cfg(target_arch = "x86")] +pub type PHALF_PTR = *mut ::c_short; +pub type SIZE_T = ULONG_PTR; +pub type PSIZE_T = *mut ULONG_PTR; +pub type SSIZE_T = LONG_PTR; +pub type PSSIZE_T = *mut LONG_PTR; +pub type DWORD_PTR = ULONG_PTR; +pub type PDWORD_PTR = *mut ULONG_PTR; +pub type LONG64 = ::__int64; +pub type PLONG64 = *mut ::__int64; +pub type ULONG64 = ::__uint64; +pub type PULONG64 = *mut ::__uint64; +pub type DWORD64 = ::__uint64; +pub type PDWORD64 = *mut ::__uint64; +pub type KAFFINITY = ULONG_PTR; +pub type PKAFFINITY = *mut KAFFINITY; diff --git a/deps/winapi-0.1.23/src/bcrypt.rs b/deps/winapi-0.1.23/src/bcrypt.rs new file mode 100644 index 000000000..54b27af0b --- /dev/null +++ b/deps/winapi-0.1.23/src/bcrypt.rs @@ -0,0 +1,4 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Cryptographic Primitive API Prototypes and Definitions +pub type NTSTATUS = ::LONG; \ No newline at end of file diff --git a/deps/winapi-0.1.23/src/commctrl.rs b/deps/winapi-0.1.23/src/commctrl.rs new file mode 100644 index 000000000..eb01ba39d --- /dev/null +++ b/deps/winapi-0.1.23/src/commctrl.rs @@ -0,0 +1,26 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//138 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INITCOMMONCONTROLSEX { + pub dwSize: ::DWORD, + pub dwICC: ::DWORD, +} +pub type LPINITCOMMONCONTROLSEX = *mut INITCOMMONCONTROLSEX; +pub const ICC_LISTVIEW_CLASSES: ::DWORD = 0x1; +pub const ICC_TREEVIEW_CLASSES: ::DWORD = 0x2; +pub const ICC_BAR_CLASSES: ::DWORD = 0x4; +pub const ICC_TAB_CLASSES: ::DWORD = 0x8; +pub const ICC_UPDOWN_CLASS: ::DWORD = 0x10; +pub const ICC_PROGRESS_CLASS: ::DWORD = 0x20; +pub const ICC_HOTKEY_CLASS: ::DWORD = 0x40; +pub const ICC_ANIMATE_CLASS: ::DWORD = 0x80; +pub const ICC_WIN95_CLASSES: ::DWORD = 0xFF; +pub const ICC_DATE_CLASSES: ::DWORD = 0x100; +pub const ICC_USEREX_CLASSES: ::DWORD = 0x200; +pub const ICC_COOL_CLASSES: ::DWORD = 0x400; +pub const ICC_INTERNET_CLASSES: ::DWORD = 0x800; +pub const ICC_PAGESCROLLER_CLASS: ::DWORD = 0x1000; +pub const ICC_NATIVEFNTCTL_CLASS: ::DWORD = 0x2000; +pub const ICC_STANDARD_CLASSES: ::DWORD = 0x4000; +pub const ICC_LINK_CLASS: ::DWORD = 0x8000; diff --git a/deps/winapi-0.1.23/src/d3d9.rs b/deps/winapi-0.1.23/src/d3d9.rs new file mode 100644 index 000000000..527ebf569 --- /dev/null +++ b/deps/winapi-0.1.23/src/d3d9.rs @@ -0,0 +1,718 @@ +// Copyright © 2015, Corey Richardson +// Licensed under the MIT License <LICENSE.md> +//! Direct3D include file + +pub const D3D_SDK_VERSION: ::DWORD = 32; +pub const D3D9b_SDK_VERSION: ::DWORD = 31; + +RIDL!( +interface IDirect3D9(IDirect3D9Vtbl): IUnknown(IUnknownVtbl) { + fn RegisterSoftwareDevice(&mut self, pInitializeFunction: *mut ::VOID) -> ::HRESULT, + fn GetAdapterCount(&mut self) -> ::UINT, + fn GetAdapterIdentifier( + &mut self, Adapter: ::UINT, Flags: ::DWORD, pIdentifier: *mut ::D3DADAPTER_IDENTIFIER9 + ) -> ::HRESULT, + fn GetAdapterModeCount(&mut self, Adapter: ::UINT, Format: ::D3DFORMAT) -> ::UINT, + fn EnumAdapterModes( + &mut self, Adapter: ::UINT, Format: ::D3DFORMAT, Mode: ::UINT, pMode: *mut ::D3DDISPLAYMODE + ) -> ::HRESULT, + fn GetAdapterDisplayMode( + &mut self, Adapter: ::UINT, pMode: *mut ::D3DDISPLAYMODE + ) -> ::HRESULT, + fn CheckDeviceType( + &mut self, Adapter: ::UINT, DevType: ::D3DDEVTYPE, AdapterFormat: ::D3DFORMAT, + BackBufferFormat: ::D3DFORMAT, bWindowed: ::BOOL + ) -> ::HRESULT, + fn CheckDeviceFormat( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, AdapterFormat: ::D3DFORMAT, + Usage: ::DWORD, RType: ::D3DRESOURCETYPE, CheckFormat: ::D3DFORMAT + ) -> ::HRESULT, + fn CheckDeviceMultiSampleType( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, SurfaceFormat: ::D3DFORMAT, + Windowed: ::BOOL, MultiSampleType: ::D3DMULTISAMPLE_TYPE, pQualityLevels: *mut ::DWORD + ) -> ::HRESULT, + fn CheckDepthStencilMatch( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, AdapterFormat: ::D3DFORMAT, + RenderTargetFormat: ::D3DFORMAT, DepthStencilFormat: ::D3DFORMAT + ) -> ::HRESULT, + fn CheckDeviceFormatConversion( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, SourceFormat: ::D3DFORMAT, + TargetFormat: ::D3DFORMAT + ) -> ::HRESULT, + fn GetDeviceCaps( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, pCaps: *mut ::D3DCAPS9 + ) -> ::HRESULT, + fn GetAdapterMonitor(&mut self, Adapter: ::UINT) -> ::HMONITOR, + fn CreateDevice( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, hFocusWindow: ::HWND, + BehaviorFlags: ::DWORD, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, + ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9 + ) -> ::HRESULT +} +); +pub type LPDIRECT3D9 = *mut IDirect3D9; +pub type PDIRECT3D9 = *mut IDirect3D9; +RIDL!( +interface IDirect3DDevice9(IDirect3DDevice9Vtbl): IUnknown(IUnknownVtbl) { + fn TestCooperativeLevel(&mut self) -> ::HRESULT, + fn GetAvailableTextureMem(&mut self) -> ::UINT, + fn EvictManagedResources(&mut self) -> ::HRESULT, + fn GetDirect3D(&mut self, ppD3D9: *mut *mut IDirect3D9) -> ::HRESULT, + fn GetDeviceCaps(&mut self, pCaps: *mut ::D3DCAPS9) -> ::HRESULT, + fn GetDisplayMode(&mut self, iSwapChain: ::UINT, pMode: *mut ::D3DDISPLAYMODE) -> ::HRESULT, + fn GetCreationParameters( + &mut self, pParameters: *mut ::D3DDEVICE_CREATION_PARAMETERS + ) -> ::HRESULT, + fn SetCursorProperties( + &mut self, XHotSpot: ::UINT, YHotSpot: ::UINT, pCursorBitmap: *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn SetCursorPosition(&mut self, X: ::INT, Y: ::INT, Flags: ::DWORD) -> (), + fn ShowCursor(&mut self, bShow: ::BOOL) -> ::BOOL, + fn CreateAdditionalSwapChain( + &mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, + pSwapChain: *mut *mut IDirect3DSwapChain9 + ) -> ::HRESULT, + fn GetSwapChain( + &mut self, iSwapChain: ::UINT, pSwapChain: *mut *mut IDirect3DSwapChain9 + ) -> ::HRESULT, + fn GetNumberOfSwapChains(&mut self) -> ::UINT, + fn Reset(&mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS) -> ::HRESULT, + fn Present( + &mut self, pSourceRect: *const ::RECT, pDestRect: *const ::RECT, + hDestWindowOverride: ::HWND, pDirtyRegion: *const ::RGNDATA + ) -> ::HRESULT, + fn GetBackBuffer( + &mut self, iSwapChain: ::UINT, iBackBuffer: ::UINT, Type: ::D3DBACKBUFFER_TYPE, + ppBackBuffer: *mut *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn GetRasterStatus( + &mut self, iSwapChain: ::UINT, pRasterStatus: *mut ::D3DRASTER_STATUS + ) -> ::HRESULT, + fn SetDialogBoxMode(&mut self, bEnableDialogs: ::BOOL) -> ::HRESULT, + fn SetGammaRamp( + &mut self, iSwapChain: ::UINT, Flags: ::DWORD, pRamp: *const ::D3DGAMMARAMP + ) -> (), + fn GetGammaRamp(&mut self, iSwapChain: ::UINT, pRamp: *mut ::D3DGAMMARAMP) -> (), + fn CreateTexture( + &mut self, Width: ::UINT, Height: ::UINT, Levels: ::UINT, Usage: ::DWORD, + Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppTexture: *mut *mut IDirect3DTexture9, + pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateVolumeTexture( + &mut self, Width: ::UINT, Height: ::UINT, Depth: ::UINT, Levels: ::UINT, Usage: ::DWORD, + Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppVolumeTexture: *mut *mut IDirect3DVolumeTexture9, + pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateCubeTexture( + &mut self, EdgeLength: ::UINT, Levels: ::UINT, Usage: ::DWORD, Format: ::D3DFORMAT, + Pool: ::D3DPOOL, ppCubeTexture: *mut *mut IDirect3DCubeTexture9, + pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateVertexBuffer( + &mut self, Length: ::UINT, Usage: ::DWORD, FVF: ::DWORD, Pool: ::D3DPOOL, + ppVertexBuffer: *mut *mut IDirect3DVertexBuffer9, pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateIndexBuffer( + &mut self, Length: ::UINT, Usage: ::DWORD, Format: ::D3DFORMAT, Pool: ::D3DPOOL, + ppIndexBuffer: *mut *mut IDirect3DIndexBuffer9, pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateRenderTarget( + &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, + MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Lockable: ::BOOL, + ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateDepthStencilSurface( + &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, + MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Discard: ::BOOL, + ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn UpdateSurface( + &mut self, pSourceSurface: *mut IDirect3DSurface9, pSourceRect: *const ::RECT, + pDestinationSurface: *mut IDirect3DSurface9, pDestPoint: *const ::POINT + ) -> ::HRESULT, + fn UpdateTexture( + &mut self, pSourceTexture: *mut IDirect3DBaseTexture9, + pDestinationTexture: *mut IDirect3DBaseTexture9 + ) -> ::HRESULT, + fn GetRenderTargetData( + &mut self, pRenderTarget: *mut IDirect3DSurface9, pDestSurface: *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn GetFrontBufferData( + &mut self, iSwapChain: ::UINT, pDestSurface: *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn StretchRect( + &mut self, pSourceSurface: *mut IDirect3DSurface9, pSourceRect: *const ::RECT, + pDestSurface: *mut IDirect3DSurface9, pDestRect: *const ::RECT, + Filter: ::D3DTEXTUREFILTERTYPE + ) -> ::HRESULT, + fn ColorFill( + &mut self, pSurface: *mut IDirect3DSurface9, pRect: *const ::RECT, color: ::D3DCOLOR + ) -> ::HRESULT, + fn CreateOffscreenPlainSurface( + &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, Pool: ::D3DPOOL, + ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn SetRenderTarget( + &mut self, RenderTargetIndex: ::DWORD, pRenderTarget: *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn GetRenderTarget( + &mut self, RenderTargetIndex: ::DWORD, ppRenderTarget: *mut *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn SetDepthStencilSurface(&mut self, pNewZStencil: *mut IDirect3DSurface9) -> ::HRESULT, + fn GetDepthStencilSurface( + &mut self, ppZStencilSurface: *mut *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn BeginScene(&mut self) -> ::HRESULT, + fn EndScene(&mut self) -> ::HRESULT, + fn Clear( + &mut self, Count: ::DWORD, pRects: *const ::D3DRECT, Flags: ::DWORD, Color: ::D3DCOLOR, + Z: ::FLOAT, Stencil: ::DWORD + ) -> ::HRESULT, + fn SetTransform( + &mut self, State: ::D3DTRANSFORMSTATETYPE, pMatrix: *const ::D3DMATRIX + ) -> ::HRESULT, + fn GetTransform( + &mut self, State: ::D3DTRANSFORMSTATETYPE, pMatrix: *mut ::D3DMATRIX + ) -> ::HRESULT, + fn MultiplyTransform( + &mut self, arg1: ::D3DTRANSFORMSTATETYPE, arg2: *const ::D3DMATRIX + ) -> ::HRESULT, + fn SetViewport(&mut self, pViewport: *const ::D3DVIEWPORT9) -> ::HRESULT, + fn GetViewport(&mut self, pViewport: *mut ::D3DVIEWPORT9) -> ::HRESULT, + fn SetMaterial(&mut self, pMaterial: *const ::D3DMATERIAL9) -> ::HRESULT, + fn GetMaterial(&mut self, pMaterial: *mut ::D3DMATERIAL9) -> ::HRESULT, + fn SetLight(&mut self, Index: ::DWORD, arg1: *const ::D3DLIGHT9) -> ::HRESULT, + fn GetLight(&mut self, Index: ::DWORD, arg1: *mut ::D3DLIGHT9) -> ::HRESULT, + fn LightEnable(&mut self, Index: ::DWORD, Enable: ::BOOL) -> ::HRESULT, + fn GetLightEnable(&mut self, Index: ::DWORD, pEnable: *mut ::BOOL) -> ::HRESULT, + fn SetClipPlane(&mut self, Index: ::DWORD, pPlane: *const ::FLOAT) -> ::HRESULT, + fn GetClipPlane(&mut self, Index: ::DWORD, pPlane: *mut ::FLOAT) -> ::HRESULT, + fn SetRenderState(&mut self, State: ::D3DRENDERSTATETYPE, Value: ::DWORD) -> ::HRESULT, + fn GetRenderState(&mut self, State: ::D3DRENDERSTATETYPE, pValue: *mut ::DWORD) -> ::HRESULT, + fn CreateStateBlock( + &mut self, Type: ::D3DSTATEBLOCKTYPE, ppSB: *mut *mut IDirect3DStateBlock9 + ) -> ::HRESULT, + fn BeginStateBlock(&mut self) -> ::HRESULT, + fn EndStateBlock(&mut self, ppSB: *mut *mut IDirect3DStateBlock9) -> ::HRESULT, + fn SetClipStatus(&mut self, pClipStatus: *const ::D3DCLIPSTATUS9) -> ::HRESULT, + fn GetClipStatus(&mut self, pClipStatus: *mut ::D3DCLIPSTATUS9) -> ::HRESULT, + fn GetTexture( + &mut self, Stage: ::DWORD, ppTexture: *mut *mut IDirect3DBaseTexture9 + ) -> ::HRESULT, + fn SetTexture(&mut self, Stage: ::DWORD, pTexture: *mut IDirect3DBaseTexture9) -> ::HRESULT, + fn GetTextureStageState( + &mut self, Stage: ::DWORD, Type: ::D3DTEXTURESTAGESTATETYPE, pValue: *mut ::DWORD + ) -> ::HRESULT, + fn SetTextureStageState( + &mut self, Stage: ::DWORD, Type: ::D3DTEXTURESTAGESTATETYPE, Value: ::DWORD + ) -> ::HRESULT, + fn GetSamplerState( + &mut self, Sampler: ::DWORD, Type: ::D3DSAMPLERSTATETYPE, pValue: *mut ::DWORD + ) -> ::HRESULT, + fn SetSamplerState( + &mut self, Sampler: ::DWORD, Type: ::D3DSAMPLERSTATETYPE, Value: ::DWORD + ) -> ::HRESULT, + fn ValidateDevice(&mut self, pNumPasses: *mut ::DWORD) -> ::HRESULT, + fn SetPaletteEntries( + &mut self, PaletteNumber: ::UINT, pEntries: *const ::PALETTEENTRY + ) -> ::HRESULT, + fn GetPaletteEntries( + &mut self, PaletteNumber: ::UINT, pEntries: *mut ::PALETTEENTRY + ) -> ::HRESULT, + fn SetCurrentTexturePalette(&mut self, PaletteNumber: ::UINT) -> ::HRESULT, + fn GetCurrentTexturePalette(&mut self, PaletteNumber: *mut ::UINT) -> ::HRESULT, + fn SetScissorRect(&mut self, pRect: *const ::RECT) -> ::HRESULT, + fn GetScissorRect(&mut self, pRect: *mut ::RECT) -> ::HRESULT, + fn SetSoftwareVertexProcessing(&mut self, bSoftware: ::BOOL) -> ::HRESULT, + fn GetSoftwareVertexProcessing(&mut self) -> ::BOOL, + fn SetNPatchMode(&mut self, nSegments: ::FLOAT) -> ::HRESULT, + fn GetNPatchMode(&mut self) -> ::FLOAT, + fn DrawPrimitive( + &mut self, PrimitiveType: ::D3DPRIMITIVETYPE, StartVertex: ::UINT, PrimitiveCount: ::UINT + ) -> ::HRESULT, + fn DrawIndexedPrimitive( + &mut self, arg1: ::D3DPRIMITIVETYPE, BaseVertexIndex: ::INT, MinVertexIndex: ::UINT, + NumVertices: ::UINT, startIndex: ::UINT, primCount: ::UINT + ) -> ::HRESULT, + fn DrawPrimitiveUP( + &mut self, PrimitiveType: ::D3DPRIMITIVETYPE, PrimitiveCount: ::UINT, + pVertexStreamZeroData: *const ::VOID, VertexStreamZeroStride: ::UINT + ) -> ::HRESULT, + fn DrawIndexedPrimitiveUP( + &mut self, PrimitiveType: ::D3DPRIMITIVETYPE, MinVertexIndex: ::UINT, NumVertices: ::UINT, + PrimitiveCount: ::UINT, pIndexData: *const ::VOID, IndexDataFormat: ::D3DFORMAT, + pVertexStreamZeroData: *const ::VOID, VertexStreamZeroStride: ::UINT + ) -> ::HRESULT, + fn ProcessVertices( + &mut self, SrcStartIndex: ::UINT, DestIndex: ::UINT, VertexCount: ::UINT, + pDestBuffer: *mut IDirect3DVertexBuffer9, pVertexDecl: *mut IDirect3DVertexDeclaration9, + Flags: ::DWORD + ) -> ::HRESULT, + fn CreateVertexDeclaration( + &mut self, pVertexElements: *const ::D3DVERTEXELEMENT9, + ppDecl: *mut *mut IDirect3DVertexDeclaration9 + ) -> ::HRESULT, + fn SetVertexDeclaration(&mut self, pDecl: *mut IDirect3DVertexDeclaration9) -> ::HRESULT, + fn GetVertexDeclaration(&mut self, ppDecl: *mut *mut IDirect3DVertexDeclaration9) -> ::HRESULT, + fn SetFVF(&mut self, FVF: ::DWORD) -> ::HRESULT, + fn GetFVF(&mut self, pFVF: *mut ::DWORD) -> ::HRESULT, + fn CreateVertexShader( + &mut self, pFunction: *const ::DWORD, ppShader: *mut *mut IDirect3DVertexShader9 + ) -> ::HRESULT, + fn SetVertexShader(&mut self, pShader: *mut IDirect3DVertexShader9) -> ::HRESULT, + fn GetVertexShader(&mut self, ppShader: *mut *mut IDirect3DVertexShader9) -> ::HRESULT, + fn SetVertexShaderConstantF( + &mut self, StartRegister: ::UINT, pConstantData: *const ::FLOAT, Vector4fCount: ::UINT + ) -> ::HRESULT, + fn GetVertexShaderConstantF( + &mut self, StartRegister: ::UINT, pConstantData: *mut ::FLOAT, Vector4fCount: ::UINT + ) -> ::HRESULT, + fn SetVertexShaderConstantI( + &mut self, StartRegister: ::UINT, pConstantData: *const ::INT, Vector4iCount: ::UINT + ) -> ::HRESULT, + fn GetVertexShaderConstantI( + &mut self, StartRegister: ::UINT, pConstantData: *mut ::INT, Vector4iCount: ::UINT + ) -> ::HRESULT, + fn SetVertexShaderConstantB( + &mut self, StartRegister: ::UINT, pConstantData: *const ::BOOL, BoolCount: ::UINT + ) -> ::HRESULT, + fn GetVertexShaderConstantB( + &mut self, StartRegister: ::UINT, pConstantData: *mut ::BOOL, BoolCount: ::UINT + ) -> ::HRESULT, + fn SetStreamSource( + &mut self, StreamNumber: ::UINT, pStreamData: *mut IDirect3DVertexBuffer9, + OffsetInBytes: ::UINT, Stride: ::UINT + ) -> ::HRESULT, + fn GetStreamSource( + &mut self, StreamNumber: ::UINT, ppStreamData: *mut *mut IDirect3DVertexBuffer9, + pOffsetInBytes: *mut ::UINT, pStride: *mut ::UINT + ) -> ::HRESULT, + fn SetStreamSourceFreq(&mut self, StreamNumber: ::UINT, Setting: ::UINT) -> ::HRESULT, + fn GetStreamSourceFreq(&mut self, StreamNumber: ::UINT, pSetting: *mut ::UINT) -> ::HRESULT, + fn SetIndices(&mut self, pIndexData: *mut IDirect3DIndexBuffer9) -> ::HRESULT, + fn GetIndices(&mut self, ppIndexData: *mut *mut IDirect3DIndexBuffer9) -> ::HRESULT, + fn CreatePixelShader( + &mut self, pFunction: *const ::DWORD, ppShader: *mut *mut IDirect3DPixelShader9 + ) -> ::HRESULT, + fn SetPixelShader(&mut self, pShader: *mut IDirect3DPixelShader9) -> ::HRESULT, + fn GetPixelShader(&mut self, ppShader: *mut *mut IDirect3DPixelShader9) -> ::HRESULT, + fn SetPixelShaderConstantF( + &mut self, StartRegister: ::UINT, pConstantData: *const ::FLOAT, Vector4fCount: ::UINT + ) -> ::HRESULT, + fn GetPixelShaderConstantF( + &mut self, StartRegister: ::UINT, pConstantData: *mut ::FLOAT, Vector4fCount: ::UINT + ) -> ::HRESULT, + fn SetPixelShaderConstantI( + &mut self, StartRegister: ::UINT, pConstantData: *const ::INT, Vector4iCount: ::UINT + ) -> ::HRESULT, + fn GetPixelShaderConstantI( + &mut self, StartRegister: ::UINT, pConstantData: *mut ::INT, Vector4iCount: ::UINT + ) -> ::HRESULT, + fn SetPixelShaderConstantB( + &mut self, StartRegister: ::UINT, pConstantData: *const ::BOOL, BoolCount: ::UINT + ) -> ::HRESULT, + fn GetPixelShaderConstantB( + &mut self, StartRegister: ::UINT, pConstantData: *mut ::BOOL, BoolCount: ::UINT + ) -> ::HRESULT, + fn DrawRectPatch( + &mut self, Handle: ::UINT, pNumSegs: *const ::FLOAT, + pRectPatchInfo: *const ::D3DRECTPATCH_INFO + ) -> ::HRESULT, + fn DrawTriPatch( + &mut self, Handle: ::UINT, pNumSegs: *const ::FLOAT, + pTriPatchInfo: *const ::D3DTRIPATCH_INFO + ) -> ::HRESULT, + fn DeletePatch(&mut self, Handle: ::UINT) -> ::HRESULT, + fn CreateQuery( + &mut self, Type: ::D3DQUERYTYPE, ppQuery: *mut *mut IDirect3DQuery9 + ) -> ::HRESULT +} +); +pub type LPDIRECT3DDEVICE9 = *mut IDirect3DDevice9; +pub type PDIRECT3DDEVICE9 = *mut IDirect3DDevice9; +RIDL!( +interface IDirect3DStateBlock9(IDirect3DStateBlock9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn Capture(&mut self) -> ::HRESULT, + fn Apply(&mut self) -> ::HRESULT +} +); +pub type LPDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; +pub type PDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; +RIDL!( +interface IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl): IUnknown(IUnknownVtbl) { + fn Present( + &mut self, pSourceRect: *const ::RECT, pDestRect: *const ::RECT, + hDestWindowOverride: ::HWND, pDirtyRegion: *const ::RGNDATA, dwFlags: ::DWORD + ) -> ::HRESULT, + fn GetFrontBufferData(&mut self, pDestSurface: *mut IDirect3DSurface9) -> ::HRESULT, + fn GetBackBuffer( + &mut self, iBackBuffer: ::UINT, Type: ::D3DBACKBUFFER_TYPE, + ppBackBuffer: *mut *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn GetRasterStatus(&mut self, pRasterStatus: *mut ::D3DRASTER_STATUS) -> ::HRESULT, + fn GetDisplayMode(&mut self, pMode: *mut ::D3DDISPLAYMODE) -> ::HRESULT, + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn GetPresentParameters( + &mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS + ) -> ::HRESULT +} +); +pub type LPDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; +pub type PDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; +RIDL!( +interface IDirect3DResource9(IDirect3DResource9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn SetPrivateData( + &mut self, refguid: *const ::GUID, pData: *const ::VOID, SizeOfData: ::DWORD, + Flags: ::DWORD + ) -> ::HRESULT, + fn GetPrivateData( + &mut self, refguid: *const ::GUID, pData: *mut ::VOID, pSizeOfData: *mut ::DWORD + ) -> ::HRESULT, + fn FreePrivateData(&mut self, refguid: *const ::GUID) -> ::HRESULT, + fn SetPriority(&mut self, PriorityNew: ::DWORD) -> ::DWORD, + fn GetPriority(&mut self) -> ::DWORD, + fn PreLoad(&mut self) -> (), + fn GetType(&mut self) -> ::D3DRESOURCETYPE +} +); +pub type LPDIRECT3DRESOURCE9 = *mut IDirect3DResource9; +pub type PDIRECT3DRESOURCE9 = *mut IDirect3DResource9; +RIDL!( +interface IDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn GetDeclaration( + &mut self, pElement: *mut ::D3DVERTEXELEMENT9, pNumElements: *mut ::UINT + ) -> ::HRESULT +} +); +pub type LPDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; +pub type PDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; +RIDL!( +interface IDirect3DVertexShader9(IDirect3DVertexShader9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn GetFunction(&mut self, arg1: *mut ::VOID, pSizeOfData: *mut ::UINT) -> ::HRESULT +} +); +pub type LPDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; +pub type PDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; +RIDL!( +interface IDirect3DPixelShader9(IDirect3DPixelShader9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn GetFunction(&mut self, arg1: *mut ::VOID, pSizeOfData: *mut ::UINT) -> ::HRESULT +} +); +pub type LPDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; +pub type PDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; +RIDL!( +interface IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { + fn SetLOD(&mut self, LODNew: ::DWORD) -> ::DWORD, + fn GetLOD(&mut self) -> ::DWORD, + fn GetLevelCount(&mut self) -> ::DWORD, + fn SetAutoGenFilterType(&mut self, FilterType: ::D3DTEXTUREFILTERTYPE) -> ::HRESULT, + fn GetAutoGenFilterType(&mut self) -> ::D3DTEXTUREFILTERTYPE, + fn GenerateMipSubLevels(&mut self) -> () +} +); +pub type LPDIRECT3DBASETEXTURE9 = *mut IDirect3DBaseTexture9; +pub type PDIRECT3DBASETEXTURE9 = *mut IDirect3DBaseTexture9; +RIDL!( +interface IDirect3DTexture9(IDirect3DTexture9Vtbl): IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { + fn GetLevelDesc(&mut self, Level: ::UINT, pDesc: *mut ::D3DSURFACE_DESC) -> ::HRESULT, + fn GetSurfaceLevel( + &mut self, Level: ::UINT, ppSurfaceLevel: *mut *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn LockRect( + &mut self, Level: ::UINT, pLockedRect: *mut ::D3DLOCKED_RECT, pRect: *const ::RECT, + Flags: ::DWORD + ) -> ::HRESULT, + fn UnlockRect(&mut self, Level: ::UINT) -> ::HRESULT, + fn AddDirtyRect(&mut self, pDirtyRect: *const ::RECT) -> ::HRESULT +} +); +pub type LPDIRECT3DTEXTURE9 = *mut IDirect3DTexture9; +pub type PDIRECT3DTEXTURE9 = *mut IDirect3DTexture9; +RIDL!( +interface IDirect3DVolumeTexture9(IDirect3DVolumeTexture9Vtbl): IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { + fn GetLevelDesc(&mut self, Level: ::UINT, pDesc: *mut ::D3DVOLUME_DESC) -> ::HRESULT, + fn GetVolumeLevel( + &mut self, Level: ::UINT, ppVolumeLevel: *mut *mut IDirect3DVolume9 + ) -> ::HRESULT, + fn LockBox( + &mut self, Level: ::UINT, pLockedVolume: *mut ::D3DLOCKED_BOX, pBox: *const ::D3DBOX, + Flags: ::DWORD + ) -> ::HRESULT, + fn UnlockBox(&mut self, Level: ::UINT) -> ::HRESULT, + fn AddDirtyBox(&mut self, pDirtyBox: *const ::D3DBOX) -> ::HRESULT +} +); +pub type LPDIRECT3DVOLUMETEXTURE9 = *mut IDirect3DVolumeTexture9; +pub type PDIRECT3DVOLUMETEXTURE9 = *mut IDirect3DVolumeTexture9; +RIDL!( +interface IDirect3DCubeTexture9(IDirect3DCubeTexture9Vtbl): IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { + fn GetLevelDesc(&mut self, Level: ::UINT, pDesc: *mut ::D3DSURFACE_DESC) -> ::HRESULT, + fn GetCubeMapSurface( + &mut self, FaceType: ::D3DCUBEMAP_FACES, Level: ::UINT, + ppCubeMapSurface: *mut *mut IDirect3DSurface9 + ) -> ::HRESULT, + fn LockRect( + &mut self, FaceType: ::D3DCUBEMAP_FACES, Level: ::UINT, pLockedRect: *mut ::D3DLOCKED_RECT, + pRect: *const ::RECT, Flags: ::DWORD + ) -> ::HRESULT, + fn UnlockRect(&mut self, FaceType: ::D3DCUBEMAP_FACES, Level: ::UINT) -> ::HRESULT, + fn AddDirtyRect( + &mut self, FaceType: ::D3DCUBEMAP_FACES, pDirtyRect: *const ::RECT + ) -> ::HRESULT +} +); +pub type LPDIRECT3DCUBETEXTURE9 = *mut IDirect3DCubeTexture9; +pub type PDIRECT3DCUBETEXTURE9 = *mut IDirect3DCubeTexture9; +RIDL!( +interface IDirect3DVertexBuffer9(IDirect3DVertexBuffer9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { + fn Lock( + &mut self, OffsetToLock: ::UINT, SizeToLock: ::UINT, ppbData: *mut *mut ::VOID, + Flags: ::DWORD + ) -> ::HRESULT, + fn Unlock(&mut self) -> ::HRESULT, + fn GetDesc(&mut self, pDesc: *mut ::D3DVERTEXBUFFER_DESC) -> ::HRESULT +} +); +pub type LPDIRECT3DVERTEXBUFFER9 = *mut IDirect3DVertexBuffer9; +pub type PDIRECT3DVERTEXBUFFER9 = *mut IDirect3DVertexBuffer9; +RIDL!( +interface IDirect3DIndexBuffer9(IDirect3DIndexBuffer9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { + fn Lock( + &mut self, OffsetToLock: ::UINT, SizeToLock: ::UINT, ppbData: *mut *mut ::VOID, + Flags: ::DWORD + ) -> ::HRESULT, + fn Unlock(&mut self) -> ::HRESULT, + fn GetDesc(&mut self, pDesc: *mut ::D3DINDEXBUFFER_DESC) -> ::HRESULT +} +); +pub type LPDIRECT3DINDEXBUFFER9 = *mut IDirect3DIndexBuffer9; +pub type PDIRECT3DINDEXBUFFER9 = *mut IDirect3DIndexBuffer9; +RIDL!( +interface IDirect3DSurface9(IDirect3DSurface9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { + fn GetContainer(&mut self, riid: *const ::IID, ppContainer: *mut *mut ::VOID) -> ::HRESULT, + fn GetDesc(&mut self, pDesc: *mut ::D3DSURFACE_DESC) -> ::HRESULT, + fn LockRect( + &mut self, pLockedRect: *mut ::D3DLOCKED_RECT, pRect: *const ::RECT, Flags: ::DWORD + ) -> ::HRESULT, + fn UnlockRect(&mut self) -> ::HRESULT, + fn GetDC(&mut self, phdc: *mut ::HDC) -> ::HRESULT, + fn ReleaseDC(&mut self, hdc: ::HDC) -> ::HRESULT +} +); +pub type LPDIRECT3DSURFACE9 = *mut IDirect3DSurface9; +pub type PDIRECT3DSURFACE9 = *mut IDirect3DSurface9; +RIDL!( +interface IDirect3DVolume9(IDirect3DVolume9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn SetPrivateData( + &mut self, refguid: *const ::GUID, pData: *const ::VOID, SizeOfData: ::DWORD, + Flags: ::DWORD + ) -> ::HRESULT, + fn GetPrivateData( + &mut self, refguid: *const ::GUID, pData: *mut ::VOID, pSizeOfData: *mut ::DWORD + ) -> ::HRESULT, + fn FreePrivateData(&mut self, refguid: *const ::GUID) -> ::HRESULT, + fn GetContainer(&mut self, riid: *const ::IID, ppContainer: *mut *mut ::VOID) -> ::HRESULT, + fn GetDesc(&mut self, pDesc: *mut ::D3DVOLUME_DESC) -> ::HRESULT, + fn LockBox( + &mut self, pLockedVolume: *mut ::D3DLOCKED_BOX, pBox: *const ::D3DBOX, Flags: ::DWORD + ) -> ::HRESULT, + fn UnlockBox(&mut self) -> ::HRESULT +} +); +pub type LPDIRECT3DVOLUME9 = *mut IDirect3DVolume9; +pub type PDIRECT3DVOLUME9 = *mut IDirect3DVolume9; +RIDL!( +interface IDirect3DQuery9(IDirect3DQuery9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, + fn GetType(&mut self) -> ::D3DRESOURCETYPE, + fn GetDataSize(&mut self) -> ::DWORD, + fn Issue(&mut self, dwIssueFlags: ::DWORD) -> ::HRESULT, + fn GetData( + &mut self, pData: *mut ::VOID, dwSize: ::DWORD, dwGetDataFlags: ::DWORD + ) -> ::HRESULT +} +); +pub type LPDIRECT3DQUERY9 = *mut IDirect3DQuery9; +pub type PDIRECT3DQUERY9 = *mut IDirect3DQuery9; + +pub const D3DCREATE_FPU_PRESERVE: ::DWORD = 0x2; +pub const D3DCREATE_MULTITHREADED: ::DWORD = 0x4; +pub const D3DCREATE_PUREDEVICE: ::DWORD = 0x10; +pub const D3DCREATE_SOFTWARE_VERTEXPROCESSING: ::DWORD = 0x20; +pub const D3DCREATE_HARDWARE_VERTEXPROCESSING: ::DWORD = 0x40; +pub const D3DCREATE_MIXED_VERTEXPROCESSING: ::DWORD = 0x80; +pub const D3DCREATE_DISABLE_DRIVER_MANAGEMENT: ::DWORD = 0x100; +pub const D3DCREATE_ADAPTERGROUP_DEVICE: ::DWORD = 0x200; +pub const D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX: ::DWORD = 0x400; +pub const D3DCREATE_NOWINDOWCHANGES: ::DWORD = 0x800; +pub const D3DCREATE_DISABLE_PSGP_THREADING: ::DWORD = 0x2000; +pub const D3DCREATE_ENABLE_PRESENTSTATS: ::DWORD = 0x4000; +pub const D3DCREATE_DISABLE_PRESENTSTATS: ::DWORD = 0x8000; +pub const D3DCREATE_SCREENSAVER: ::DWORD = 0x10000000; + +pub const D3DADAPTER_DEFAULT: ::DWORD = 0; + +RIDL!( +interface IDirect3D9Ex(IDirect3D9ExVtbl): IDirect3D9(IDirect3D9Vtbl) { + fn GetAdapterModeCountEx( + &mut self, Adapter: ::UINT, pFilter: *const ::D3DDISPLAYMODEFILTER + ) -> ::UINT, + fn EnumAdapterModesEx( + &mut self, Adapter: ::UINT, pFilter: *const ::D3DDISPLAYMODEFILTER, Mode: ::UINT, + pMode: *mut ::D3DDISPLAYMODEEX + ) -> ::HRESULT, + fn GetAdapterDisplayModeEx( + &mut self, Adapter: ::UINT, pMode: *mut ::D3DDISPLAYMODEEX, + pRotation: *mut ::D3DDISPLAYROTATION + ) -> ::HRESULT, + fn CreateDeviceEx( + &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, hFocusWindow: ::HWND, + BehaviorFlags: ::DWORD, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, + pFullscreenDisplayMode: *mut ::D3DDISPLAYMODEEX, + ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9Ex + ) -> ::HRESULT, + fn GetAdapterLUID(&mut self, Adapter: ::UINT, pLUID: *mut ::LUID) -> ::HRESULT +} +); +pub type LPDIRECT3D9EX = *mut IDirect3D9Ex; +pub type PDIRECT3D9EX = *mut IDirect3D9Ex; +RIDL!( +interface IDirect3DDevice9Ex(IDirect3DDevice9ExVtbl): IDirect3DDevice9(IDirect3DDevice9Vtbl) { + fn SetConvolutionMonoKernel( + &mut self, width: ::UINT, height: ::UINT, rows: *mut ::FLOAT, columns: *mut ::FLOAT + ) -> ::HRESULT, + fn ComposeRects( + &mut self, pSrc: *mut IDirect3DSurface9, pDst: *mut IDirect3DSurface9, + pSrcRectDescs: *mut IDirect3DVertexBuffer9, NumRects: ::UINT, + pDstRectDescs: *mut IDirect3DVertexBuffer9, Operation: ::D3DCOMPOSERECTSOP, Xoffset: ::INT, + Yoffset: ::INT + ) -> ::HRESULT, + fn PresentEx( + &mut self, pSourceRect: *const ::RECT, pDestRect: *const ::RECT, + hDestWindowOverride: ::HWND, pDirtyRegion: *const ::RGNDATA, dwFlags: ::DWORD + ) -> ::HRESULT, + fn GetGPUThreadPriority(&mut self, pPriority: *mut ::INT) -> ::HRESULT, + fn SetGPUThreadPriority(&mut self, Priority: ::INT) -> ::HRESULT, + fn WaitForVBlank(&mut self, iSwapChain: ::UINT) -> ::HRESULT, + fn CheckResourceResidency( + &mut self, pResourceArray: *mut *mut IDirect3DResource9, NumResources: ::UINT32 + ) -> ::HRESULT, + fn SetMaximumFrameLatency(&mut self, MaxLatency: ::UINT) -> ::HRESULT, + fn GetMaximumFrameLatency(&mut self, pMaxLatency: *mut ::UINT) -> ::HRESULT, + fn CheckDeviceState(&mut self, hDestinationWindow: ::HWND) -> ::HRESULT, + fn CreateRenderTargetEx( + &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, + MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Lockable: ::BOOL, + ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE, Usage: ::DWORD + ) -> ::HRESULT, + fn CreateOffscreenPlainSurfaceEx( + &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, Pool: ::D3DPOOL, + ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE, Usage: ::DWORD + ) -> ::HRESULT, + fn CreateDepthStencilSurfaceEx( + &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, + MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Discard: ::BOOL, + ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE, Usage: ::DWORD + ) -> ::HRESULT, + fn ResetEx( + &mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, + pFullscreenDisplayMode: *mut ::D3DDISPLAYMODEEX + ) -> ::HRESULT, + fn GetDisplayModeEx( + &mut self, iSwapChain: ::UINT, pMode: *mut ::D3DDISPLAYMODEEX, + pRotation: *mut ::D3DDISPLAYROTATION + ) -> ::HRESULT +} +); +pub type LPDIRECT3DDEVICE9EX = *mut IDirect3DDevice9Ex; +pub type PDIRECT3DDEVICE9EX = *mut IDirect3DDevice9Ex; +RIDL!( +interface IDirect3DSwapChain9Ex(IDirect3DSwapChain9ExVtbl): IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl) { + fn GetLastPresentCount(&mut self, pLastPresentCount: *mut ::UINT) -> ::HRESULT, + fn GetPresentStats(&mut self, pPresentationStatistics: *mut ::D3DPRESENTSTATS) -> ::HRESULT, + fn GetDisplayModeEx( + &mut self, pMode: *mut ::D3DDISPLAYMODEEX, pRotation: *mut ::D3DDISPLAYROTATION + ) -> ::HRESULT +} +); +pub type LPDIRECT3DSWAPCHAIN9EX = *mut IDirect3DSwapChain9Ex; +pub type PDIRECT3DSWAPCHAIN9EX = *mut IDirect3DSwapChain9Ex; +RIDL!( +interface IDirect3D9ExOverlayExtension(IDirect3D9ExOverlayExtensionVtbl): IUnknown(IUnknownVtbl) { + fn CheckDeviceOverlayType( + &mut self, Adapter: ::UINT, DevType: ::D3DDEVTYPE, OverlayWidth: ::UINT, + OverlayHeight: ::UINT, OverlayFormat: ::D3DFORMAT, pDisplayMode: *mut ::D3DDISPLAYMODEEX, + DisplayRotation: ::D3DDISPLAYROTATION, pOverlayCaps: *mut ::D3DOVERLAYCAPS + ) -> ::HRESULT +} +); +pub type LPDIRECT3D9EXOVERLAYEXTENSION = *mut IDirect3D9ExOverlayExtension; +pub type PDIRECT3D9EXOVERLAYEXTENSION = *mut IDirect3D9ExOverlayExtension; +RIDL!( +interface IDirect3DDevice9Video(IDirect3DDevice9VideoVtbl): IUnknown(IUnknownVtbl) { + fn GetContentProtectionCaps( + &mut self, pCryptoType: *const ::GUID, pDecodeProfile: *const ::GUID, + pCaps: *mut ::D3DCONTENTPROTECTIONCAPS + ) -> ::HRESULT, + fn CreateAuthenticatedChannel( + &mut self, ChannelType: ::D3DAUTHENTICATEDCHANNELTYPE, + ppAuthenticatedChannel: *mut *mut IDirect3DAuthenticatedChannel9, + pChannelHandle: *mut ::HANDLE + ) -> ::HRESULT, + fn CreateCryptoSession( + &mut self, pCryptoType: *const ::GUID, pDecodeProfile: *const ::GUID, + ppCryptoSession: *mut *mut IDirect3DCryptoSession9, pCryptoHandle: *mut ::HANDLE + ) -> ::HRESULT +} +); +pub type LPDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; +pub type PDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; +RIDL!( +interface IDirect3DAuthenticatedChannel9(IDirect3DAuthenticatedChannel9Vtbl): IUnknown(IUnknownVtbl) { + fn GetCertificateSize(&mut self, pCertificateSize: *mut ::UINT) -> ::HRESULT, + fn GetCertificate(&mut self, CertifacteSize: ::UINT, ppCertificate: *mut ::BYTE) -> ::HRESULT, + fn NegotiateKeyExchange(&mut self, DataSize: ::UINT, pData: *mut ::VOID) -> ::HRESULT, + fn Query( + &mut self, InputSize: ::UINT, pInput: *const ::VOID, OutputSize: ::UINT, + pOutput: *mut ::VOID + ) -> ::HRESULT, + fn Configure( + &mut self, InputSize: ::UINT, pInput: *const ::VOID, + pOutput: *mut ::D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT + ) -> ::HRESULT +} +); +pub type LPDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; +pub type PDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; +RIDL!( +interface IDirect3DCryptoSession9(IDirect3DCryptoSession9Vtbl): IUnknown(IUnknownVtbl) { + fn GetCertificateSize(&mut self, pCertificateSize: *mut ::UINT) -> ::HRESULT, + fn GetCertificate(&mut self, CertifacteSize: ::UINT, ppCertificate: *mut ::BYTE) -> ::HRESULT, + fn NegotiateKeyExchange(&mut self, DataSize: ::UINT, pData: *mut ::VOID) -> ::HRESULT, + fn EncryptionBlt( + &mut self, pSrcSurface: *mut IDirect3DSurface9, pDstSurface: *mut IDirect3DSurface9, + DstSurfaceSize: ::UINT, pIV: *mut ::VOID + ) -> ::HRESULT, + fn DecryptionBlt( + &mut self, pSrcSurface: *mut IDirect3DSurface9, pDstSurface: *mut IDirect3DSurface9, + SrcSurfaceSize: ::UINT, pEncryptedBlockInfo: *mut ::D3DENCRYPTED_BLOCK_INFO, + pContentKey: *mut ::VOID, pIV: *mut ::VOID + ) -> ::HRESULT, + fn GetSurfacePitch( + &mut self, pSrcSurface: *mut IDirect3DSurface9, pSurfacePitch: *mut ::UINT + ) -> ::HRESULT, + fn StartSessionKeyRefresh( + &mut self, pRandomNumber: *mut ::VOID, RandomNumberSize: ::UINT + ) -> ::HRESULT, + fn FinishSessionKeyRefresh(&mut self) -> ::HRESULT, + fn GetEncryptionBltKey(&mut self, pReadbackKey: *mut ::VOID, KeySize: ::UINT) -> ::HRESULT +} +); +pub type LPDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; +pub type PDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; diff --git a/deps/winapi-0.1.23/src/d3d9caps.rs b/deps/winapi-0.1.23/src/d3d9caps.rs new file mode 100644 index 000000000..274c02106 --- /dev/null +++ b/deps/winapi-0.1.23/src/d3d9caps.rs @@ -0,0 +1,362 @@ +// Copyright © 2015, Corey Richardson +// Licensed under the MIT License <LICENSE.md> +//! Direct3D capabilities include file +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DVSHADERCAPS2_0 { + pub Caps: ::DWORD, + pub DynamicFlowControlDepth: ::INT, + pub NumTemps: ::INT, + pub StaticFlowControlDepth: ::INT, +} +pub const D3DVS20CAPS_PREDICATION: ::DWORD = 1 << 0; +pub const D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 24; +pub const D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 0; +pub const D3DVS20_MAX_NUMTEMPS: ::DWORD = 32; +pub const D3DVS20_MIN_NUMTEMPS: ::DWORD = 12; +pub const D3DVS20_MAX_STATICFLOWCONTROLDEPTH: ::DWORD = 4; +pub const D3DVS20_MIN_STATICFLOWCONTROLDEPTH: ::DWORD = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DPSHADERCAPS2_0 { + pub Caps: ::DWORD, + pub DynamicFlowControlDepth: ::INT, + pub NumTemps: ::INT, + pub StaticFlowControlDepth: ::INT, + pub NumInstructionSlots: ::INT, +} +pub const D3DPS20CAPS_ARBITRARYSWIZZLE: ::DWORD = 1 << 0; +pub const D3DPS20CAPS_GRADIENTINSTRUCTIONS: ::DWORD = 1 << 1; +pub const D3DPS20CAPS_PREDICATION: ::DWORD = 1 << 2; +pub const D3DPS20CAPS_NODEPENDENTREADLIMIT: ::DWORD = 1 << 3; +pub const D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT: ::DWORD = 1 << 4; +pub const D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 24; +pub const D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 0; +pub const D3DPS20_MAX_NUMTEMPS: ::DWORD = 32; +pub const D3DPS20_MIN_NUMTEMPS: ::DWORD = 12; +pub const D3DPS20_MAX_STATICFLOWCONTROLDEPTH: ::DWORD = 4; +pub const D3DPS20_MIN_STATICFLOWCONTROLDEPTH: ::DWORD = 0; +pub const D3DPS20_MAX_NUMINSTRUCTIONSLOTS: ::DWORD = 512; +pub const D3DPS20_MIN_NUMINSTRUCTIONSLOTS: ::DWORD = 96; +pub const D3DMIN30SHADERINSTRUCTIONS: ::DWORD = 512; +pub const D3DMAX30SHADERINSTRUCTIONS: ::DWORD = 32768; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DOVERLAYCAPS { + pub Caps: ::UINT, + pub MaxOverlayDisplayWidth: ::UINT, + pub MaxOverlayDisplayHeight: ::UINT, +} +pub const D3DOVERLAYCAPS_FULLRANGERGB: ::DWORD = 0x00000001; +pub const D3DOVERLAYCAPS_LIMITEDRANGERGB: ::DWORD = 0x00000002; +pub const D3DOVERLAYCAPS_YCbCr_BT601: ::DWORD = 0x00000004; +pub const D3DOVERLAYCAPS_YCbCr_BT709: ::DWORD = 0x00000008; +pub const D3DOVERLAYCAPS_YCbCr_BT601_xvYCC: ::DWORD = 0x00000010; +pub const D3DOVERLAYCAPS_YCbCr_BT709_xvYCC: ::DWORD = 0x00000020; +pub const D3DOVERLAYCAPS_STRETCHX: ::DWORD = 0x00000040; +pub const D3DOVERLAYCAPS_STRETCHY: ::DWORD = 0x00000080; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DCONTENTPROTECTIONCAPS { + pub Caps: ::DWORD, + pub KeyExchangeType: ::GUID, + pub BufferAlignmentStart: ::UINT, + pub BlockAlignmentSize: ::UINT, + pub ProtectedMemorySize: ::ULONGLONG, +} +pub const D3DCPCAPS_SOFTWARE: ::DWORD = 0x00000001; +pub const D3DCPCAPS_HARDWARE: ::DWORD = 0x00000002; +pub const D3DCPCAPS_PROTECTIONALWAYSON: ::DWORD = 0x00000004; +pub const D3DCPCAPS_PARTIALDECRYPTION: ::DWORD = 0x00000008; +pub const D3DCPCAPS_CONTENTKEY: ::DWORD = 0x00000010; +pub const D3DCPCAPS_FRESHENSESSIONKEY: ::DWORD = 0x00000020; +pub const D3DCPCAPS_ENCRYPTEDREADBACK: ::DWORD = 0x00000040; +pub const D3DCPCAPS_ENCRYPTEDREADBACKKEY: ::DWORD = 0x00000080; +pub const D3DCPCAPS_SEQUENTIAL_CTR_IV: ::DWORD = 0x00000100; +pub const D3DCPCAPS_ENCRYPTSLICEDATAONLY: ::DWORD = 0x00000200; +DEFINE_GUID!(D3DCRYPTOTYPE_AES128_CTR, 0x9b6bd711, 0x4f74, 0x41c9, + 0x9e, 0x7b, 0xb, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f); +DEFINE_GUID!(D3DCRYPTOTYPE_PROPRIETARY, 0xab4e9afd, 0x1d1c, 0x46e6, + 0xa7, 0x2f, 0x8, 0x69, 0x91, 0x7b, 0xd, 0xe8); +DEFINE_GUID!(D3DKEYEXCHANGE_RSAES_OAEP, 0xc1949895, 0xd72a, 0x4a1d, + 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20); +DEFINE_GUID!(D3DKEYEXCHANGE_DXVA, 0x43d3775c, 0x38e5, 0x4924, 0x8d, + 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DCAPS9 { + pub DeviceType: ::D3DDEVTYPE, + pub AdapterOrdinal: ::UINT, + pub Caps: ::DWORD, + pub Caps2: ::DWORD, + pub Caps3: ::DWORD, + pub PresentationIntervals: ::DWORD, + pub CursorCaps: ::DWORD, + pub DevCaps: ::DWORD, + pub PrimitiveMiscCaps: ::DWORD, + pub RasterCaps: ::DWORD, + pub ZCmpCaps: ::DWORD, + pub SrcBlendCaps: ::DWORD, + pub DestBlendCaps: ::DWORD, + pub AlphaCmpCaps: ::DWORD, + pub ShadeCaps: ::DWORD, + pub TextureCaps: ::DWORD, + pub TextureFilterCaps: ::DWORD, + pub CubeTextureFilterCaps: ::DWORD, + pub VolumeTextureFilterCaps: ::DWORD, + pub TextureAddressCaps: ::DWORD, + pub VolumeTextureAddressCaps: ::DWORD, + pub LineCaps: ::DWORD, + pub MaxTextureWidth: ::DWORD, + pub MaxTextureHeight: ::DWORD, + pub MaxVolumeExtent: ::DWORD, + pub MaxTextureRepeat: ::DWORD, + pub MaxTextureAspectRatio: ::DWORD, + pub MaxAnisotropy: ::DWORD, + pub MaxVertexW: ::c_float, + pub GuardBandLeft: ::c_float, + pub GuardBandTop: ::c_float, + pub GuardBandRight: ::c_float, + pub GuardBandBottom: ::c_float, + pub ExtentsAdjust: ::c_float, + pub StencilCaps: ::DWORD, + pub FVFCaps: ::DWORD, + pub TextureOpCaps: ::DWORD, + pub MaxTextureBlendStages: ::DWORD, + pub MaxSimultaneousTextures: ::DWORD, + pub VertexProcessingCaps: ::DWORD, + pub MaxActiveLights: ::DWORD, + pub MaxUserClipPlanes: ::DWORD, + pub MaxVertexBlendMatrices: ::DWORD, + pub MaxVertexBlendMatrixIndex: ::DWORD, + pub MaxPointSize: ::c_float, + pub MaxPrimitiveCount: ::DWORD, + pub MaxVertexIndex: ::DWORD, + pub MaxStreams: ::DWORD, + pub MaxStreamStride: ::DWORD, + pub VertexShaderVersion: ::DWORD, + pub MaxVertexShaderConst: ::DWORD, + pub PixelShaderVersion: ::DWORD, + pub PixelShader1xMaxValue: ::c_float, + pub DevCaps2: ::DWORD, + pub MaxNpatchTessellationLevel: ::c_float, + pub Reserved5: ::DWORD, + pub MasterAdapterOrdinal: ::UINT, + pub AdapterOrdinalInGroup: ::UINT, + pub NumberOfAdaptersInGroup: ::UINT, + pub DeclTypes: ::DWORD, + pub NumSimultaneousRTs: ::DWORD, + pub StretchRectFilterCaps: ::DWORD, + pub VS20Caps: ::D3DVSHADERCAPS2_0, + pub PS20Caps: ::D3DPSHADERCAPS2_0, + pub VertexTextureFilterCaps: ::DWORD, + pub MaxVShaderInstructionsExecuted: ::DWORD, + pub MaxPShaderInstructionsExecuted: ::DWORD, + pub MaxVertexShader30InstructionSlots: ::DWORD, + pub MaxPixelShader30InstructionSlots: ::DWORD, +} +pub const D3DCAPS_OVERLAY: ::DWORD = 0x00000800; +pub const D3DCAPS_READ_SCANLINE: ::DWORD = 0x00020000; +pub const D3DCAPS2_FULLSCREENGAMMA: ::DWORD = 0x00020000; +pub const D3DCAPS2_CANCALIBRATEGAMMA: ::DWORD = 0x00100000; +pub const D3DCAPS2_RESERVED: ::DWORD = 0x02000000; +pub const D3DCAPS2_CANMANAGERESOURCE: ::DWORD = 0x10000000; +pub const D3DCAPS2_DYNAMICTEXTURES: ::DWORD = 0x20000000; +pub const D3DCAPS2_CANAUTOGENMIPMAP: ::DWORD = 0x40000000; +pub const D3DCAPS2_CANSHARERESOURCE: ::DWORD = 0x80000000; +pub const D3DCAPS3_RESERVED: ::DWORD = 0x8000001f; +pub const D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD: ::DWORD = 0x00000020; +pub const D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION: ::DWORD = 0x00000080; +pub const D3DCAPS3_COPY_TO_VIDMEM: ::DWORD = 0x00000100; +pub const D3DCAPS3_COPY_TO_SYSTEMMEM: ::DWORD = 0x00000200; +pub const D3DCAPS3_DXVAHD: ::DWORD = 0x00000400; +pub const D3DCAPS3_DXVAHD_LIMITED: ::DWORD = 0x00000800; +pub const D3DPRESENT_INTERVAL_DEFAULT: ::DWORD = 0x00000000; +pub const D3DPRESENT_INTERVAL_ONE: ::DWORD = 0x00000001; +pub const D3DPRESENT_INTERVAL_TWO: ::DWORD = 0x00000002; +pub const D3DPRESENT_INTERVAL_THREE: ::DWORD = 0x00000004; +pub const D3DPRESENT_INTERVAL_FOUR: ::DWORD = 0x00000008; +pub const D3DPRESENT_INTERVAL_IMMEDIATE: ::DWORD = 0x80000000; +pub const D3DCURSORCAPS_COLOR: ::DWORD = 0x00000001; +pub const D3DCURSORCAPS_LOWRES: ::DWORD = 0x00000002; +pub const D3DDEVCAPS_EXECUTESYSTEMMEMORY: ::DWORD = 0x00000010; +pub const D3DDEVCAPS_EXECUTEVIDEOMEMORY: ::DWORD = 0x00000020; +pub const D3DDEVCAPS_TLVERTEXSYSTEMMEMORY: ::DWORD = 0x00000040; +pub const D3DDEVCAPS_TLVERTEXVIDEOMEMORY: ::DWORD = 0x00000080; +pub const D3DDEVCAPS_TEXTURESYSTEMMEMORY: ::DWORD = 0x00000100; +pub const D3DDEVCAPS_TEXTUREVIDEOMEMORY: ::DWORD = 0x00000200; +pub const D3DDEVCAPS_DRAWPRIMTLVERTEX: ::DWORD = 0x00000400; +pub const D3DDEVCAPS_CANRENDERAFTERFLIP: ::DWORD = 0x00000800; +pub const D3DDEVCAPS_TEXTURENONLOCALVIDMEM: ::DWORD = 0x00001000; +pub const D3DDEVCAPS_DRAWPRIMITIVES2: ::DWORD = 0x00002000; +pub const D3DDEVCAPS_SEPARATETEXTUREMEMORIES: ::DWORD = 0x00004000; +pub const D3DDEVCAPS_DRAWPRIMITIVES2EX: ::DWORD = 0x00008000; +pub const D3DDEVCAPS_HWTRANSFORMANDLIGHT: ::DWORD = 0x00010000; +pub const D3DDEVCAPS_CANBLTSYSTONONLOCAL: ::DWORD = 0x00020000; +pub const D3DDEVCAPS_HWRASTERIZATION: ::DWORD = 0x00080000; +pub const D3DDEVCAPS_PUREDEVICE: ::DWORD = 0x00100000; +pub const D3DDEVCAPS_QUINTICRTPATCHES: ::DWORD = 0x00200000; +pub const D3DDEVCAPS_RTPATCHES: ::DWORD = 0x00400000; +pub const D3DDEVCAPS_RTPATCHHANDLEZERO: ::DWORD = 0x00800000; +pub const D3DDEVCAPS_NPATCHES: ::DWORD = 0x01000000; +pub const D3DPMISCCAPS_MASKZ: ::DWORD = 0x00000002; +pub const D3DPMISCCAPS_CULLNONE: ::DWORD = 0x00000010; +pub const D3DPMISCCAPS_CULLCW: ::DWORD = 0x00000020; +pub const D3DPMISCCAPS_CULLCCW: ::DWORD = 0x00000040; +pub const D3DPMISCCAPS_COLORWRITEENABLE: ::DWORD = 0x00000080; +pub const D3DPMISCCAPS_CLIPPLANESCALEDPOINTS: ::DWORD = 0x00000100; +pub const D3DPMISCCAPS_CLIPTLVERTS: ::DWORD = 0x00000200; +pub const D3DPMISCCAPS_TSSARGTEMP: ::DWORD = 0x00000400; +pub const D3DPMISCCAPS_BLENDOP: ::DWORD = 0x00000800; +pub const D3DPMISCCAPS_NULLREFERENCE: ::DWORD = 0x00001000; +pub const D3DPMISCCAPS_INDEPENDENTWRITEMASKS: ::DWORD = 0x00004000; +pub const D3DPMISCCAPS_PERSTAGECONSTANT: ::DWORD = 0x00008000; +pub const D3DPMISCCAPS_FOGANDSPECULARALPHA: ::DWORD = 0x00010000; +pub const D3DPMISCCAPS_SEPARATEALPHABLEND: ::DWORD = 0x00020000; +pub const D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS: ::DWORD = 0x00040000; +pub const D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING: ::DWORD = 0x00080000; +pub const D3DPMISCCAPS_FOGVERTEXCLAMPED: ::DWORD = 0x00100000; +pub const D3DPMISCCAPS_POSTBLENDSRGBCONVERT: ::DWORD = 0x00200000; +pub const D3DLINECAPS_TEXTURE: ::DWORD = 0x00000001; +pub const D3DLINECAPS_ZTEST: ::DWORD = 0x00000002; +pub const D3DLINECAPS_BLEND: ::DWORD = 0x00000004; +pub const D3DLINECAPS_ALPHACMP: ::DWORD = 0x00000008; +pub const D3DLINECAPS_FOG: ::DWORD = 0x00000010; +pub const D3DLINECAPS_ANTIALIAS: ::DWORD = 0x00000020; +pub const D3DPRASTERCAPS_DITHER: ::DWORD = 0x00000001; +pub const D3DPRASTERCAPS_ZTEST: ::DWORD = 0x00000010; +pub const D3DPRASTERCAPS_FOGVERTEX: ::DWORD = 0x00000080; +pub const D3DPRASTERCAPS_FOGTABLE: ::DWORD = 0x00000100; +pub const D3DPRASTERCAPS_MIPMAPLODBIAS: ::DWORD = 0x00002000; +pub const D3DPRASTERCAPS_ZBUFFERLESSHSR: ::DWORD = 0x00008000; +pub const D3DPRASTERCAPS_FOGRANGE: ::DWORD = 0x00010000; +pub const D3DPRASTERCAPS_ANISOTROPY: ::DWORD = 0x00020000; +pub const D3DPRASTERCAPS_WBUFFER: ::DWORD = 0x00040000; +pub const D3DPRASTERCAPS_WFOG: ::DWORD = 0x00100000; +pub const D3DPRASTERCAPS_ZFOG: ::DWORD = 0x00200000; +pub const D3DPRASTERCAPS_COLORPERSPECTIVE: ::DWORD = 0x00400000; +pub const D3DPRASTERCAPS_SCISSORTEST: ::DWORD = 0x01000000; +pub const D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS: ::DWORD = 0x02000000; +pub const D3DPRASTERCAPS_DEPTHBIAS: ::DWORD = 0x04000000; +pub const D3DPRASTERCAPS_MULTISAMPLE_TOGGLE: ::DWORD = 0x08000000; +pub const D3DPCMPCAPS_NEVER: ::DWORD = 0x00000001; +pub const D3DPCMPCAPS_LESS: ::DWORD = 0x00000002; +pub const D3DPCMPCAPS_EQUAL: ::DWORD = 0x00000004; +pub const D3DPCMPCAPS_LESSEQUAL: ::DWORD = 0x00000008; +pub const D3DPCMPCAPS_GREATER: ::DWORD = 0x00000010; +pub const D3DPCMPCAPS_NOTEQUAL: ::DWORD = 0x00000020; +pub const D3DPCMPCAPS_GREATEREQUAL: ::DWORD = 0x00000040; +pub const D3DPCMPCAPS_ALWAYS: ::DWORD = 0x00000080; +pub const D3DPBLENDCAPS_ZERO: ::DWORD = 0x00000001; +pub const D3DPBLENDCAPS_ONE: ::DWORD = 0x00000002; +pub const D3DPBLENDCAPS_SRCCOLOR: ::DWORD = 0x00000004; +pub const D3DPBLENDCAPS_INVSRCCOLOR: ::DWORD = 0x00000008; +pub const D3DPBLENDCAPS_SRCALPHA: ::DWORD = 0x00000010; +pub const D3DPBLENDCAPS_INVSRCALPHA: ::DWORD = 0x00000020; +pub const D3DPBLENDCAPS_DESTALPHA: ::DWORD = 0x00000040; +pub const D3DPBLENDCAPS_INVDESTALPHA: ::DWORD = 0x00000080; +pub const D3DPBLENDCAPS_DESTCOLOR: ::DWORD = 0x00000100; +pub const D3DPBLENDCAPS_INVDESTCOLOR: ::DWORD = 0x00000200; +pub const D3DPBLENDCAPS_SRCALPHASAT: ::DWORD = 0x00000400; +pub const D3DPBLENDCAPS_BOTHSRCALPHA: ::DWORD = 0x00000800; +pub const D3DPBLENDCAPS_BOTHINVSRCALPHA: ::DWORD = 0x00001000; +pub const D3DPBLENDCAPS_BLENDFACTOR: ::DWORD = 0x00002000; +pub const D3DPBLENDCAPS_SRCCOLOR2: ::DWORD = 0x00004000; +pub const D3DPBLENDCAPS_INVSRCCOLOR2: ::DWORD = 0x00008000; +pub const D3DPSHADECAPS_COLORGOURAUDRGB: ::DWORD = 0x00000008; +pub const D3DPSHADECAPS_SPECULARGOURAUDRGB: ::DWORD = 0x00000200; +pub const D3DPSHADECAPS_ALPHAGOURAUDBLEND: ::DWORD = 0x00004000; +pub const D3DPSHADECAPS_FOGGOURAUD: ::DWORD = 0x00080000; +pub const D3DPTEXTURECAPS_PERSPECTIVE: ::DWORD = 0x00000001; +pub const D3DPTEXTURECAPS_POW2: ::DWORD = 0x00000002; +pub const D3DPTEXTURECAPS_ALPHA: ::DWORD = 0x00000004; +pub const D3DPTEXTURECAPS_SQUAREONLY: ::DWORD = 0x00000020; +pub const D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE: ::DWORD = 0x00000040; +pub const D3DPTEXTURECAPS_ALPHAPALETTE: ::DWORD = 0x00000080; +pub const D3DPTEXTURECAPS_NONPOW2CONDITIONAL: ::DWORD = 0x00000100; +pub const D3DPTEXTURECAPS_PROJECTED: ::DWORD = 0x00000400; +pub const D3DPTEXTURECAPS_CUBEMAP: ::DWORD = 0x00000800; +pub const D3DPTEXTURECAPS_VOLUMEMAP: ::DWORD = 0x00002000; +pub const D3DPTEXTURECAPS_MIPMAP: ::DWORD = 0x00004000; +pub const D3DPTEXTURECAPS_MIPVOLUMEMAP: ::DWORD = 0x00008000; +pub const D3DPTEXTURECAPS_MIPCUBEMAP: ::DWORD = 0x00010000; +pub const D3DPTEXTURECAPS_CUBEMAP_POW2: ::DWORD = 0x00020000; +pub const D3DPTEXTURECAPS_VOLUMEMAP_POW2: ::DWORD = 0x00040000; +pub const D3DPTEXTURECAPS_NOPROJECTEDBUMPENV: ::DWORD = 0x00200000; +pub const D3DPTFILTERCAPS_MINFPOINT: ::DWORD = 0x00000100; +pub const D3DPTFILTERCAPS_MINFLINEAR: ::DWORD = 0x00000200; +pub const D3DPTFILTERCAPS_MINFANISOTROPIC: ::DWORD = 0x00000400; +pub const D3DPTFILTERCAPS_MINFPYRAMIDALQUAD: ::DWORD = 0x00000800; +pub const D3DPTFILTERCAPS_MINFGAUSSIANQUAD: ::DWORD = 0x00001000; +pub const D3DPTFILTERCAPS_MIPFPOINT: ::DWORD = 0x00010000; +pub const D3DPTFILTERCAPS_MIPFLINEAR: ::DWORD = 0x00020000; +pub const D3DPTFILTERCAPS_CONVOLUTIONMONO: ::DWORD = 0x00040000; +pub const D3DPTFILTERCAPS_MAGFPOINT: ::DWORD = 0x01000000; +pub const D3DPTFILTERCAPS_MAGFLINEAR: ::DWORD = 0x02000000; +pub const D3DPTFILTERCAPS_MAGFANISOTROPIC: ::DWORD = 0x04000000; +pub const D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD: ::DWORD = 0x08000000; +pub const D3DPTFILTERCAPS_MAGFGAUSSIANQUAD: ::DWORD = 0x10000000; +pub const D3DPTADDRESSCAPS_WRAP: ::DWORD = 0x00000001; +pub const D3DPTADDRESSCAPS_MIRROR: ::DWORD = 0x00000002; +pub const D3DPTADDRESSCAPS_CLAMP: ::DWORD = 0x00000004; +pub const D3DPTADDRESSCAPS_BORDER: ::DWORD = 0x00000008; +pub const D3DPTADDRESSCAPS_INDEPENDENTUV: ::DWORD = 0x00000010; +pub const D3DPTADDRESSCAPS_MIRRORONCE: ::DWORD = 0x00000020; +pub const D3DSTENCILCAPS_KEEP: ::DWORD = 0x00000001; +pub const D3DSTENCILCAPS_ZERO: ::DWORD = 0x00000002; +pub const D3DSTENCILCAPS_REPLACE: ::DWORD = 0x00000004; +pub const D3DSTENCILCAPS_INCRSAT: ::DWORD = 0x00000008; +pub const D3DSTENCILCAPS_DECRSAT: ::DWORD = 0x00000010; +pub const D3DSTENCILCAPS_INVERT: ::DWORD = 0x00000020; +pub const D3DSTENCILCAPS_INCR: ::DWORD = 0x00000040; +pub const D3DSTENCILCAPS_DECR: ::DWORD = 0x00000080; +pub const D3DSTENCILCAPS_TWOSIDED: ::DWORD = 0x00000100; +pub const D3DTEXOPCAPS_DISABLE: ::DWORD = 0x00000001; +pub const D3DTEXOPCAPS_SELECTARG1: ::DWORD = 0x00000002; +pub const D3DTEXOPCAPS_SELECTARG2: ::DWORD = 0x00000004; +pub const D3DTEXOPCAPS_MODULATE: ::DWORD = 0x00000008; +pub const D3DTEXOPCAPS_MODULATE2X: ::DWORD = 0x00000010; +pub const D3DTEXOPCAPS_MODULATE4X: ::DWORD = 0x00000020; +pub const D3DTEXOPCAPS_ADD: ::DWORD = 0x00000040; +pub const D3DTEXOPCAPS_ADDSIGNED: ::DWORD = 0x00000080; +pub const D3DTEXOPCAPS_ADDSIGNED2X: ::DWORD = 0x00000100; +pub const D3DTEXOPCAPS_SUBTRACT: ::DWORD = 0x00000200; +pub const D3DTEXOPCAPS_ADDSMOOTH: ::DWORD = 0x00000400; +pub const D3DTEXOPCAPS_BLENDDIFFUSEALPHA: ::DWORD = 0x00000800; +pub const D3DTEXOPCAPS_BLENDTEXTUREALPHA: ::DWORD = 0x00001000; +pub const D3DTEXOPCAPS_BLENDFACTORALPHA: ::DWORD = 0x00002000; +pub const D3DTEXOPCAPS_BLENDTEXTUREALPHAPM: ::DWORD = 0x00004000; +pub const D3DTEXOPCAPS_BLENDCURRENTALPHA: ::DWORD = 0x00008000; +pub const D3DTEXOPCAPS_PREMODULATE: ::DWORD = 0x00010000; +pub const D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR: ::DWORD = 0x00020000; +pub const D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA: ::DWORD = 0x00040000; +pub const D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR: ::DWORD = 0x00080000; +pub const D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA: ::DWORD = 0x00100000; +pub const D3DTEXOPCAPS_BUMPENVMAP: ::DWORD = 0x00200000; +pub const D3DTEXOPCAPS_BUMPENVMAPLUMINANCE: ::DWORD = 0x00400000; +pub const D3DTEXOPCAPS_DOTPRODUCT3: ::DWORD = 0x00800000; +pub const D3DTEXOPCAPS_MULTIPLYADD: ::DWORD = 0x01000000; +pub const D3DTEXOPCAPS_LERP: ::DWORD = 0x02000000; +pub const D3DFVFCAPS_TEXCOORDCOUNTMASK: ::DWORD = 0x0000ffff; +pub const D3DFVFCAPS_DONOTSTRIPELEMENTS: ::DWORD = 0x00080000; +pub const D3DFVFCAPS_PSIZE: ::DWORD = 0x00100000; +pub const D3DVTXPCAPS_TEXGEN: ::DWORD = 0x00000001; +pub const D3DVTXPCAPS_MATERIALSOURCE7: ::DWORD = 0x00000002; +pub const D3DVTXPCAPS_DIRECTIONALLIGHTS: ::DWORD = 0x00000008; +pub const D3DVTXPCAPS_POSITIONALLIGHTS: ::DWORD = 0x00000010; +pub const D3DVTXPCAPS_LOCALVIEWER: ::DWORD = 0x00000020; +pub const D3DVTXPCAPS_TWEENING: ::DWORD = 0x00000040; +pub const D3DVTXPCAPS_TEXGEN_SPHEREMAP: ::DWORD = 0x00000100; +pub const D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER: ::DWORD = 0x00000200; +pub const D3DDEVCAPS2_STREAMOFFSET: ::DWORD = 0x00000001; +pub const D3DDEVCAPS2_DMAPNPATCH: ::DWORD = 0x00000002; +pub const D3DDEVCAPS2_ADAPTIVETESSRTPATCH: ::DWORD = 0x00000004; +pub const D3DDEVCAPS2_ADAPTIVETESSNPATCH: ::DWORD = 0x00000008; +pub const D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES: ::DWORD = 0x00000010; +pub const D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH: ::DWORD = 0x00000020; +pub const D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET: ::DWORD = 0x00000040; +pub const D3DDTCAPS_UBYTE4: ::DWORD = 0x00000001; +pub const D3DDTCAPS_UBYTE4N: ::DWORD = 0x00000002; +pub const D3DDTCAPS_SHORT2N: ::DWORD = 0x00000004; +pub const D3DDTCAPS_SHORT4N: ::DWORD = 0x00000008; +pub const D3DDTCAPS_USHORT2N: ::DWORD = 0x00000010; +pub const D3DDTCAPS_USHORT4N: ::DWORD = 0x00000020; +pub const D3DDTCAPS_UDEC3: ::DWORD = 0x00000040; +pub const D3DDTCAPS_DEC3N: ::DWORD = 0x00000080; +pub const D3DDTCAPS_FLOAT16_2: ::DWORD = 0x00000100; +pub const D3DDTCAPS_FLOAT16_4: ::DWORD = 0x00000200; diff --git a/deps/winapi-0.1.23/src/d3d9types.rs b/deps/winapi-0.1.23/src/d3d9types.rs new file mode 100644 index 000000000..cda979e04 --- /dev/null +++ b/deps/winapi-0.1.23/src/d3d9types.rs @@ -0,0 +1,1562 @@ +// Copyright © 2015, Corey Richardson +// Licensed under the MIT License <LICENSE.md> +//! Direct3D capabilities include file +pub type D3DCOLOR = ::DWORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DVECTOR { + pub x: ::c_float, + pub y: ::c_float, + pub z: ::c_float, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DCOLORVALUE { + pub r: ::c_float, + pub g: ::c_float, + pub b: ::c_float, + pub a: ::c_float, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DRECT { + pub x1: ::LONG, + pub y1: ::LONG, + pub x2: ::LONG, + pub y2: ::LONG, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DMATRIX { + pub m: [[::c_float; 4]; 4], +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DVIEWPORT9 { + pub X: ::DWORD, + pub Y: ::DWORD, + pub Width: ::DWORD, + pub Height: ::DWORD, + pub MinZ: ::c_float, + pub MaxZ: ::c_float, +} +pub const D3DMAXUSERCLIPPLANES: ::DWORD = 32; +pub const D3DCLIPPLANE0: ::DWORD = (1 << 0); +pub const D3DCLIPPLANE1: ::DWORD = (1 << 1); +pub const D3DCLIPPLANE2: ::DWORD = (1 << 2); +pub const D3DCLIPPLANE3: ::DWORD = (1 << 3); +pub const D3DCLIPPLANE4: ::DWORD = (1 << 4); +pub const D3DCLIPPLANE5: ::DWORD = (1 << 5); +pub const D3DCS_LEFT: ::DWORD = 0x00000001; +pub const D3DCS_RIGHT: ::DWORD = 0x00000002; +pub const D3DCS_TOP: ::DWORD = 0x00000004; +pub const D3DCS_BOTTOM: ::DWORD = 0x00000008; +pub const D3DCS_FRONT: ::DWORD = 0x00000010; +pub const D3DCS_BACK: ::DWORD = 0x00000020; +pub const D3DCS_PLANE0: ::DWORD = 0x00000040; +pub const D3DCS_PLANE1: ::DWORD = 0x00000080; +pub const D3DCS_PLANE2: ::DWORD = 0x00000100; +pub const D3DCS_PLANE3: ::DWORD = 0x00000200; +pub const D3DCS_PLANE4: ::DWORD = 0x00000400; +pub const D3DCS_PLANE5: ::DWORD = 0x00000800; +pub const D3DCS_ALL: ::DWORD = D3DCS_LEFT | D3DCS_RIGHT | D3DCS_TOP | D3DCS_BOTTOM | D3DCS_FRONT + | D3DCS_BACK | D3DCS_PLANE0 | D3DCS_PLANE1 | D3DCS_PLANE2 | D3DCS_PLANE3 | D3DCS_PLANE4 + | D3DCS_PLANE5; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DCLIPSTATUS9 { + pub ClipUnion: ::DWORD, + pub ClipIntersection: ::DWORD, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DMATERIAL9 { + pub Diffuse: D3DCOLORVALUE, + pub Ambient: D3DCOLORVALUE, + pub Specular: D3DCOLORVALUE, + pub Emissive: D3DCOLORVALUE, + pub Power: ::c_float, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DLIGHTTYPE { + POINT = 1, + SPOT = 2, + DIRECTIONAL = 3, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DLIGHT9 { + pub Type: D3DLIGHTTYPE, + pub Diffuse: D3DCOLORVALUE, + pub Specular: D3DCOLORVALUE, + pub Ambient: D3DCOLORVALUE, + pub Position: D3DVECTOR, + pub Direction: D3DVECTOR, + pub Range: ::c_float, + pub Falloff: ::c_float, + pub Attenuation0: ::c_float, + pub Attenuation1: ::c_float, + pub Attenuation2: ::c_float, + pub Theta: ::c_float, + pub Phi: ::c_float, +} +pub const D3DCLEAR_TARGET: ::DWORD = 0; +pub const D3DCLEAR_ZBUFFER: ::DWORD = 0; +pub const D3DCLEAR_STENCIL: ::DWORD = 0; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADEMODE { + FLAT = 1, + GOURAUD = 2, + PHONG = 3, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DFILLMODE { + POINT = 1, + WIREFRAME = 2, + SOLID = 3, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DBLEND { + ZERO = 1, + ONE = 2, + SRCCOLOR = 3, + INVSRCCOLOR = 4, + SRCALPHA = 5, + INVSRCALPHA = 6, + DESTALPHA = 7, + INVDESTALPHA = 8, + DESTCOLOR = 9, + INVDESTCOLOR = 10, + SRCALPHASAT = 11, + BOTHSRCALPHA = 12, + BOTHINVSRCALPHA = 13, + BLENDFACTOR = 14, + INVBLENDFACTOR = 15, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DBLENDOP { + ADD = 1, + SUBTRACT = 2, + REVSUBTRACT = 3, + MIN = 4, + MAX = 5, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DTEXTUREADDRESS { + WRAP = 1, + MIRROR = 2, + CLAMP = 3, + BORDER = 4, + MIRRORONCE = 5, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DCULL { + NONE = 1, + CW = 2, + CCW = 3, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DCMPFUNC { + NEVER = 1, + LESS = 2, + EQUAL = 3, + LESSEQUAL = 4, + GREATER = 5, + NOTEQUAL = 6, + GREATEREQUAL = 7, + ALWAYS = 8, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSTENCILOP { + KEEP = 1, + ZERO = 2, + REPLACE = 3, + INCRSAT = 4, + DECRSAT = 5, + INVERT = 6, + INCR = 7, + DECR = 8, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DFOGMODE { + NONE = 0, + EXP = 1, + EXP2 = 2, + LINEAR = 3, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DZBUFFERTYPE { + FALSE = 0, + TRUE = 1, + USEW = 2, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DPRIMITIVETYPE { + POINTLIST = 1, + LINELIST = 2, + LINESTRIP = 3, + TRIANGLELIST = 4, + TRIANGLESTRIP = 5, + TRIANGLEFAN = 6, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DTRANSFORMSTATETYPE { + VIEW = 2, + PROJECTION = 3, + TEXTURE0 = 16, + TEXTURE1 = 17, + TEXTURE2 = 18, + TEXTURE3 = 19, + TEXTURE4 = 20, + TEXTURE5 = 21, + TEXTURE6 = 22, + TEXTURE7 = 23, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DRENDERSTATETYPE { + ZENABLE = 7, + FILLMODE = 8, + SHADEMODE = 9, + ZWRITEENABLE = 14, + ALPHATESTENABLE = 15, + LASTPIXEL = 16, + SRCBLEND = 19, + DESTBLEND = 20, + CULLMODE = 22, + ZFUNC = 23, + ALPHAREF = 24, + ALPHAFUNC = 25, + DITHERENABLE = 26, + ALPHABLENDENABLE = 27, + FOGENABLE = 28, + SPECULARENABLE = 29, + FOGCOLOR = 34, + FOGTABLEMODE = 35, + FOGSTART = 36, + FOGEND = 37, + FOGDENSITY = 38, + RANGEFOGENABLE = 48, + STENCILENABLE = 52, + STENCILFAIL = 53, + STENCILZFAIL = 54, + STENCILPASS = 55, + STENCILFUNC = 56, + STENCILREF = 57, + STENCILMASK = 58, + STENCILWRITEMASK = 59, + TEXTUREFACTOR = 60, + WRAP0 = 128, + WRAP1 = 129, + WRAP2 = 130, + WRAP3 = 131, + WRAP4 = 132, + WRAP5 = 133, + WRAP6 = 134, + WRAP7 = 135, + CLIPPING = 136, + LIGHTING = 137, + AMBIENT = 139, + FOGVERTEXMODE = 140, + COLORVERTEX = 141, + LOCALVIEWER = 142, + NORMALIZENORMALS = 143, + DIFFUSEMATERIALSOURCE = 145, + SPECULARMATERIALSOURCE = 146, + AMBIENTMATERIALSOURCE = 147, + EMISSIVEMATERIALSOURCE = 148, + VERTEXBLEND = 151, + CLIPPLANEENABLE = 152, + POINTSIZE = 154, + POINTSIZE_MIN = 155, + POINTSPRITEENABLE = 156, + POINTSCALEENABLE = 157, + POINTSCALE_A = 158, + POINTSCALE_B = 159, + POINTSCALE_C = 160, + MULTISAMPLEANTIALIAS = 161, + MULTISAMPLEMASK = 162, + PATCHEDGESTYLE = 163, + DEBUGMONITORTOKEN = 165, + POINTSIZE_MAX = 166, + INDEXEDVERTEXBLENDENABLE = 167, + COLORWRITEENABLE = 168, + TWEENFACTOR = 170, + BLENDOP = 171, + POSITIONDEGREE = 172, + NORMALDEGREE = 173, + SCISSORTESTENABLE = 174, + SLOPESCALEDEPTHBIAS = 175, + ANTIALIASEDLINEENABLE = 176, + MINTESSELLATIONLEVEL = 178, + MAXTESSELLATIONLEVEL = 179, + ADAPTIVETESS_X = 180, + ADAPTIVETESS_Y = 181, + ADAPTIVETESS_Z = 182, + ADAPTIVETESS_W = 183, + ENABLEADAPTIVETESSELLATION = 184, + TWOSIDEDSTENCILMODE = 185, + CCW_STENCILFAIL = 186, + CCW_STENCILZFAIL = 187, + CCW_STENCILPASS = 188, + CCW_STENCILFUNC = 189, + COLORWRITEENABLE1 = 190, + COLORWRITEENABLE2 = 191, + COLORWRITEENABLE3 = 192, + BLENDFACTOR = 193, + SRGBWRITEENABLE = 194, + DEPTHBIAS = 195, + WRAP8 = 198, + WRAP9 = 199, + WRAP10 = 200, + WRAP11 = 201, + WRAP12 = 202, + WRAP13 = 203, + WRAP14 = 204, + WRAP15 = 205, + SEPARATEALPHABLENDENABLE = 206, + SRCBLENDALPHA = 207, + DESTBLENDALPHA = 208, + BLENDOPALPHA = 209, +} +pub const D3D_MAX_SIMULTANEOUS_RENDERTARGETS: ::DWORD = 4; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DMATERIALCOLORSOURCE { + MATERIAL = 0, + COLOR1 = 1, + COLOR2 = 2, +} +pub const D3DRENDERSTATE_WRAPBIAS: ::DWORD = 128; +pub const D3DWRAP_U: ::DWORD = 0x00000001; +pub const D3DWRAP_V: ::DWORD = 0x00000002; +pub const D3DWRAP_W: ::DWORD = 0x00000004; +pub const D3DWRAPCOORD_0: ::DWORD = 0x00000001; +pub const D3DWRAPCOORD_1: ::DWORD = 0x00000002; +pub const D3DWRAPCOORD_2: ::DWORD = 0x00000004; +pub const D3DWRAPCOORD_3: ::DWORD = 0x00000008; +pub const D3DCOLORWRITEENABLE_RED: ::DWORD = 1 << 0; +pub const D3DCOLORWRITEENABLE_GREEN: ::DWORD = 1 << 1; +pub const D3DCOLORWRITEENABLE_BLUE: ::DWORD = 1 << 2; +pub const D3DCOLORWRITEENABLE_ALPHA: ::DWORD = 1 << 3; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DTEXTURESTAGESTATETYPE { + COLOROP = 1, + COLORARG1 = 2, + COLORARG2 = 3, + ALPHAOP = 4, + ALPHAARG1 = 5, + ALPHAARG2 = 6, + BUMPENVMAT00 = 7, + BUMPENVMAT01 = 8, + BUMPENVMAT10 = 9, + BUMPENVMAT11 = 10, + TEXCOORDINDEX = 11, + BUMPENVLSCALE = 22, + BUMPENVLOFFSET = 23, + TEXTURETRANSFORMFLAGS = 24, + COLORARG0 = 26, + ALPHAARG0 = 27, + RESULTARG = 28, + CONSTANT = 32, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSAMPLERSTATETYPE { + ADDRESSU = 1, + ADDRESSV = 2, + ADDRESSW = 3, + BORDERCOLOR = 4, + MAGFILTER = 5, + MINFILTER = 6, + MIPFILTER = 7, + MIPMAPLODBIAS = 8, + MAXMIPLEVEL = 9, + MAXANISOTROPY = 10, + SRGBTEXTURE = 11, + ELEMENTINDEX = 12, + DMAPOFFSET = 13, +} +pub const D3DDMAPSAMPLER: ::DWORD = 256; +pub const D3DVERTEXTEXTURESAMPLER0: ::DWORD = D3DDMAPSAMPLER + 1; +pub const D3DVERTEXTEXTURESAMPLER1: ::DWORD = D3DDMAPSAMPLER + 2; +pub const D3DVERTEXTEXTURESAMPLER2: ::DWORD = D3DDMAPSAMPLER + 3; +pub const D3DVERTEXTEXTURESAMPLER3: ::DWORD = D3DDMAPSAMPLER + 4; +pub const D3DTSS_TCI_PASSTHRU: ::DWORD = 0x00000000; +pub const D3DTSS_TCI_CAMERASPACENORMAL: ::DWORD = 0x00010000; +pub const D3DTSS_TCI_CAMERASPACEPOSITION: ::DWORD = 0x00020000; +pub const D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR: ::DWORD = 0x00030000; +pub const D3DTSS_TCI_SPHEREMAP: ::DWORD = 0x00040000; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DTEXTUREOP { + DISABLE = 1, + SELECTARG1 = 2, + SELECTARG2 = 3, + MODULATE = 4, + MODULATE2X = 5, + MODULATE4X = 6, + ADD = 7, + ADDSIGNED = 8, + ADDSIGNED2X = 9, + SUBTRACT = 10, + ADDSMOOTH = 11, + BLENDDIFFUSEALPHA = 12, + BLENDTEXTUREALPHA = 13, + BLENDFACTORALPHA = 14, + BLENDTEXTUREALPHAPM = 15, + BLENDCURRENTALPHA = 16, + PREMODULATE = 17, + MODULATEALPHA_ADDCOLOR = 18, + MODULATECOLOR_ADDALPHA = 19, + MODULATEINVALPHA_ADDCOLOR = 20, + MODULATEINVCOLOR_ADDALPHA = 21, + BUMPENVMAP = 22, + BUMPENVMAPLUMINANCE = 23, + DOTPRODUCT3 = 24, + MULTIPLYADD = 25, + LERP = 26, +} +pub const D3DTA_SELECTMASK: ::DWORD = 0x0000000f; +pub const D3DTA_DIFFUSE: ::DWORD = 0x00000000; +pub const D3DTA_CURRENT: ::DWORD = 0x00000001; +pub const D3DTA_TEXTURE: ::DWORD = 0x00000002; +pub const D3DTA_TFACTOR: ::DWORD = 0x00000003; +pub const D3DTA_SPECULAR: ::DWORD = 0x00000004; +pub const D3DTA_TEMP: ::DWORD = 0x00000005; +pub const D3DTA_CONSTANT: ::DWORD = 0x00000006; +pub const D3DTA_COMPLEMENT: ::DWORD = 0x00000010; +pub const D3DTA_ALPHAREPLICATE: ::DWORD = 0x00000020; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DTEXTUREFILTERTYPE { + NONE = 0, + POINT = 1, + LINEAR = 2, + ANISOTROPIC = 3, + PYRAMIDALQUAD = 6, + GAUSSIANQUAD = 7, + CONVOLUTIONMONO = 8, +} +pub const D3DPV_DONOTCOPYDATA: ::DWORD = 1 << 0; +pub const D3DFVF_RESERVED0: ::DWORD = 0x001; +pub const D3DFVF_POSITION_MASK: ::DWORD = 0x400E; +pub const D3DFVF_XYZ: ::DWORD = 0x002; +pub const D3DFVF_XYZRHW: ::DWORD = 0x004; +pub const D3DFVF_XYZB1: ::DWORD = 0x006; +pub const D3DFVF_XYZB2: ::DWORD = 0x008; +pub const D3DFVF_XYZB3: ::DWORD = 0x00a; +pub const D3DFVF_XYZB4: ::DWORD = 0x00c; +pub const D3DFVF_XYZB5: ::DWORD = 0x00e; +pub const D3DFVF_XYZW: ::DWORD = 0x4002; +pub const D3DFVF_NORMAL: ::DWORD = 0x010; +pub const D3DFVF_PSIZE: ::DWORD = 0x020; +pub const D3DFVF_DIFFUSE: ::DWORD = 0x040; +pub const D3DFVF_SPECULAR: ::DWORD = 0x080; +pub const D3DFVF_TEXCOUNT_MASK: ::DWORD = 0xf00; +pub const D3DFVF_TEXCOUNT_SHIFT: ::DWORD = 8; +pub const D3DFVF_TEX0: ::DWORD = 0x000; +pub const D3DFVF_TEX1: ::DWORD = 0x100; +pub const D3DFVF_TEX2: ::DWORD = 0x200; +pub const D3DFVF_TEX3: ::DWORD = 0x300; +pub const D3DFVF_TEX4: ::DWORD = 0x400; +pub const D3DFVF_TEX5: ::DWORD = 0x500; +pub const D3DFVF_TEX6: ::DWORD = 0x600; +pub const D3DFVF_TEX7: ::DWORD = 0x700; +pub const D3DFVF_TEX8: ::DWORD = 0x800; +pub const D3DFVF_LASTBETA_UBYTE4: ::DWORD = 0x1000; +pub const D3DFVF_LASTBETA_D3DCOLOR: ::DWORD = 0x8000; +pub const D3DFVF_RESERVED2: ::DWORD = 0x6000; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDECLUSAGE { + POSITION = 0, + BLENDWEIGHT, + BLENDINDICES, + NORMAL, + PSIZE, + TEXCOORD, + TANGENT, + BINORMAL, + TESSFACTOR, + POSITIONT, + COLOR, + FOG, + DEPTH, + SAMPLE, +} +pub const MAXD3DDECLUSAGE: D3DDECLUSAGE = D3DDECLUSAGE::SAMPLE; +pub const MAXD3DDECLUSAGEINDEX: ::DWORD = 15; +pub const MAXD3DDECLLENGTH: ::DWORD = 64; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDECLMETHOD { + DEFAULT = 0, + PARTIALU, + PARTIALV, + CROSSUV, + UV, + LOOKUP, + LOOKUPPRESAMPLED, +} +pub const MAXD3DDECLMETHOD: D3DDECLMETHOD = D3DDECLMETHOD::LOOKUPPRESAMPLED; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDECLTYPE { + FLOAT1 = 0, + FLOAT2 = 1, + FLOAT3 = 2, + FLOAT4 = 3, + D3DCOLOR = 4, + UBYTE4 = 5, + SHORT2 = 6, + SHORT4 = 7, + UBYTE4N = 8, + SHORT2N = 9, + SHORT4N = 10, + USHORT2N = 11, + USHORT4N = 12, + UDEC3 = 13, + DEC3N = 14, + FLOAT16_2 = 15, + FLOAT16_4 = 16, + UNUSED = 17, +} +pub const MAXD3DDECLTYPE: D3DDECLTYPE = D3DDECLTYPE::UNUSED; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DVERTEXELEMENT9 { + pub Stream: ::WORD, + pub Offset: ::WORD, + pub Type: ::BYTE, + pub Method: ::BYTE, + pub Usage: ::BYTE, + pub UsageIndex: ::BYTE, +} +pub type LPD3DVERTEXELEMENT9 = *mut D3DVERTEXELEMENT9; +pub const D3DDECL_END: D3DVERTEXELEMENT9 = D3DVERTEXELEMENT9 { + Stream: 0xFF, + Offset: 0, + Type: D3DDECLTYPE::UNUSED as ::BYTE, + Method: 0, + Usage: 0, + UsageIndex: 0, +}; +pub const D3DDP_MAXTEXCOORD: ::DWORD = 8; +pub const D3DSTREAMSOURCE_INDEXEDDATA: ::DWORD = 1 << 30; +pub const D3DSTREAMSOURCE_INSTANCEDATA: ::DWORD = 2 << 30; +pub const D3DSI_OPCODE_MASK: ::DWORD = 0x0000FFFF; +pub const D3DSI_INSTLENGTH_MASK: ::DWORD = 0x0F000000; +pub const D3DSI_INSTLENGTH_SHIFT: ::DWORD = 24; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_INSTRUCTION_OPCODE_TYPE { + NOP = 0, + MOV, + ADD, + SUB, + MAD, + MUL, + RCP, + RSQ, + DP3, + DP4, + MIN, + MAX, + SLT, + SGE, + EXP, + LOG, + LIT, + DST, + LRP, + FRC, + M4x4, + M4x3, + M3x4, + M3x3, + M3x2, + CALL, + CALLNZ, + LOOP, + RET, + ENDLOOP, + LABEL, + DCL, + POW, + CRS, + SGN, + ABS, + NRM, + SINCOS, + REP, + ENDREP, + IF, + IFC, + ELSE, + ENDIF, + BREAK, + BREAKC, + MOVA, + DEFB, + DEFI, + TEXCOORD = 64, + TEXKILL, + TEX, + TEXBEM, + TEXBEML, + TEXREG2AR, + TEXREG2GB, + TEXM3x2PAD, + TEXM3x2TEX, + TEXM3x3PAD, + TEXM3x3TEX, + RESERVED0, + TEXM3x3SPEC, + TEXM3x3VSPEC, + EXPP, + LOGP, + CND, + DEF, + TEXREG2RGB, + TEXDP3TEX, + TEXM3x2DEPTH, + TEXDP3, + TEXM3x3, + TEXDEPTH, + CMP, + BEM, + DP2ADD, + DSX, + DSY, + TEXLDD, + SETP, + TEXLDL, + BREAKP, + PHASE = 0xFFFD, + COMMENT = 0xFFFE, + END = 0xFFFF, +} +pub const D3DSI_COISSUE: ::DWORD = 0x40000000; +pub const D3DSP_OPCODESPECIFICCONTROL_MASK: ::DWORD = 0x00ff0000; +pub const D3DSP_OPCODESPECIFICCONTROL_SHIFT: ::DWORD = 16; +pub const D3DSI_TEXLD_PROJECT: ::DWORD = 0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT; +pub const D3DSI_TEXLD_BIAS: ::DWORD = 0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_COMPARISON { + RESERVED0 = 0, + GT = 1, + EQ = 2, + GE = 3, + LT = 4, + NE = 5, + LE = 6, + RESERVED1 = 7, +} +pub const D3DSHADER_COMPARISON_SHIFT: ::DWORD = D3DSP_OPCODESPECIFICCONTROL_SHIFT; +pub const D3DSHADER_COMPARISON_MASK: ::DWORD = 0x7 << D3DSHADER_COMPARISON_SHIFT; +pub const D3DSHADER_INSTRUCTION_PREDICATED: ::DWORD = 0x1 << 28; +pub const D3DSP_DCL_USAGE_SHIFT: ::DWORD = 0; +pub const D3DSP_DCL_USAGE_MASK: ::DWORD = 0x0000000f; +pub const D3DSP_DCL_USAGEINDEX_SHIFT: ::DWORD = 16; +pub const D3DSP_DCL_USAGEINDEX_MASK: ::DWORD = 0x000f0000; +pub const D3DSP_TEXTURETYPE_SHIFT: ::DWORD = 27; +pub const D3DSP_TEXTURETYPE_MASK: ::DWORD = 0x78000000; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSAMPLER_TEXTURE_TYPE { + UNKNOWN = 0 << D3DSP_TEXTURETYPE_SHIFT, + _2D = 2 << D3DSP_TEXTURETYPE_SHIFT, + CUBE = 3 << D3DSP_TEXTURETYPE_SHIFT, + VOLUME = 4 << D3DSP_TEXTURETYPE_SHIFT, +} +pub const D3DSP_REGNUM_MASK: ::DWORD = 0x000007FF; +pub const D3DSP_WRITEMASK_0: ::DWORD = 0x00010000; +pub const D3DSP_WRITEMASK_1: ::DWORD = 0x00020000; +pub const D3DSP_WRITEMASK_2: ::DWORD = 0x00040000; +pub const D3DSP_WRITEMASK_3: ::DWORD = 0x00080000; +pub const D3DSP_WRITEMASK_ALL: ::DWORD = 0x000F0000; +pub const D3DSP_DSTMOD_SHIFT: ::DWORD = 20; +pub const D3DSP_DSTMOD_MASK: ::DWORD = 0x00F00000; +pub const D3DSPDM_NONE: ::DWORD = 0 << D3DSP_DSTMOD_SHIFT; +pub const D3DSPDM_SATURATE: ::DWORD = 1 << D3DSP_DSTMOD_SHIFT; +pub const D3DSPDM_PARTIALPRECISION: ::DWORD = 2 << D3DSP_DSTMOD_SHIFT; +pub const D3DSPDM_MSAMPCENTROID: ::DWORD = 4 << D3DSP_DSTMOD_SHIFT; +pub const D3DSP_DSTSHIFT_SHIFT: ::DWORD = 24; +pub const D3DSP_DSTSHIFT_MASK: ::DWORD = 0x0F000000; +pub const D3DSP_REGTYPE_SHIFT: ::DWORD = 28; +pub const D3DSP_REGTYPE_SHIFT2: ::DWORD = 8; +pub const D3DSP_REGTYPE_MASK: ::DWORD = 0x70000000; +pub const D3DSP_REGTYPE_MASK2: ::DWORD = 0x00001800; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_PARAM_REGISTER_TYPE { + TEMP = 0, + INPUT = 1, + CONST = 2, + ADDR = 3, + // D3DSPR_TEXTURE = 3, // Why Rust? + RASTOUT = 4, + ATTROUT = 5, + TEXCRDOUT = 6, + // D3DSPR_OUTPUT = 6, // Why are you doing this to me? + CONSTINT = 7, + COLOROUT = 8, + DEPTHOUT = 9, + SAMPLER = 10, + CONST2 = 11, + CONST3 = 12, + CONST4 = 13, + CONSTBOOL = 14, + LOOP = 15, + TEMPFLOAT16 = 16, + MISCTYPE = 17, + LABEL = 18, + PREDICATE = 19, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_MISCTYPE_OFFSETS { + POSITION = 0, + FACE = 1, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DVS_RASTOUT_OFFSETS { + POSITION = 0, + FOG, + POINT_SIZE, +} +pub const D3DVS_ADDRESSMODE_SHIFT: ::DWORD = 13; +pub const D3DVS_ADDRESSMODE_MASK: ::DWORD = 1 << D3DVS_ADDRESSMODE_SHIFT; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DVS_ADDRESSMODE_TYPE { + ADDRMODE_ABSOLUTE = 0 << D3DVS_ADDRESSMODE_SHIFT, + ADDRMODE_RELATIVE = 1 << D3DVS_ADDRESSMODE_SHIFT, +} +pub const D3DSHADER_ADDRESSMODE_SHIFT: ::DWORD = 13; +pub const D3DSHADER_ADDRESSMODE_MASK: ::DWORD = 1 << D3DSHADER_ADDRESSMODE_SHIFT; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_ADDRESSMODE_TYPE { + ABSOLUTE = 0 << D3DSHADER_ADDRESSMODE_SHIFT, + RELATIVE = 1 << D3DSHADER_ADDRESSMODE_SHIFT, +} +pub const D3DVS_SWIZZLE_SHIFT: ::DWORD = 16; +pub const D3DVS_SWIZZLE_MASK: ::DWORD = 0x00FF0000; +pub const D3DVS_X_X: ::DWORD = 0 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_X_Y: ::DWORD = 1 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_X_Z: ::DWORD = 2 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_X_W: ::DWORD = 3 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_Y_X: ::DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Y_Y: ::DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Y_Z: ::DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Y_W: ::DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Z_X: ::DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_Z_Y: ::DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_Z_Z: ::DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_Z_W: ::DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_W_X: ::DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_W_Y: ::DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_W_Z: ::DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_W_W: ::DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_NOSWIZZLE: ::DWORD = D3DVS_X_X | D3DVS_Y_Y | D3DVS_Z_Z | D3DVS_W_W; +pub const D3DSP_SWIZZLE_SHIFT: ::DWORD = 16; +pub const D3DSP_SWIZZLE_MASK: ::DWORD = 0x00FF0000; +pub const D3DSP_NOSWIZZLE: ::DWORD = (0 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (3 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATERED: ::DWORD = (0 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (0 << (D3DSP_SWIZZLE_SHIFT + 2)) | (0 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (0 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATEGREEN: ::DWORD = (1 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (1 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (1 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATEBLUE: ::DWORD = (2 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (2 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (2 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATEALPHA: ::DWORD = (3 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (3 << (D3DSP_SWIZZLE_SHIFT + 2)) | (3 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (3 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_SRCMOD_SHIFT: ::DWORD = 24; +pub const D3DSP_SRCMOD_MASK: ::DWORD = 0x0F000000; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_PARAM_SRCMOD_TYPE { + NONE = 0 << D3DSP_SRCMOD_SHIFT, + NEG = 1 << D3DSP_SRCMOD_SHIFT, + BIAS = 2 << D3DSP_SRCMOD_SHIFT, + BIASNEG = 3 << D3DSP_SRCMOD_SHIFT, + SIGN = 4 << D3DSP_SRCMOD_SHIFT, + SIGNNEG = 5 << D3DSP_SRCMOD_SHIFT, + COMP = 6 << D3DSP_SRCMOD_SHIFT, + X2 = 7 << D3DSP_SRCMOD_SHIFT, + X2NEG = 8 << D3DSP_SRCMOD_SHIFT, + DZ = 9 << D3DSP_SRCMOD_SHIFT, + DW = 10 << D3DSP_SRCMOD_SHIFT, + ABS = 11 << D3DSP_SRCMOD_SHIFT, + ABSNEG = 12 << D3DSP_SRCMOD_SHIFT, + NOT = 13 << D3DSP_SRCMOD_SHIFT, +} +pub const D3DSP_MIN_PRECISION_SHIFT: ::DWORD = 14; +pub const D3DSP_MIN_PRECISION_MASK: ::DWORD = 0x0000C000; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSHADER_MIN_PRECISION { + DEFAULT = 0, + _16 = 1, + _2_8 = 2, +} +pub const D3DSI_COMMENTSIZE_SHIFT: ::DWORD = 16; +pub const D3DSI_COMMENTSIZE_MASK: ::DWORD = 0x7FFF0000; +pub const D3DPS_END: ::DWORD = 0x0000FFFF; +pub const D3DVS_END: ::DWORD = 0x0000FFFF; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DBASISTYPE { + BEZIER = 0, + BSPLINE = 1, + CATMULL_ROM = 2, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDEGREETYPE { + LINEAR = 1, + QUADRATIC = 2, + CUBIC = 3, + QUINTIC = 5, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DPATCHEDGESTYLE { + DISCRETE = 0, + CONTINUOUS = 1, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSTATEBLOCKTYPE { + ALL = 1, + PIXELSTATE = 2, + VERTEXSTATE = 3, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DVERTEXBLENDFLAGS { + DISABLE = 0, + _1WEIGHTS = 1, + _2WEIGHTS = 2, + _3WEIGHTS = 3, + _TWEENING = 255, + _0WEIGHTS = 256, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DTEXTURETRANSFORMFLAGS { + DISABLE = 0, + COUNT1 = 1, + COUNT2 = 2, + COUNT3 = 3, + COUNT4 = 4, + PROJECTED = 256, +} +pub const D3DFVF_TEXTUREFORMAT2: ::DWORD = 0; +pub const D3DFVF_TEXTUREFORMAT1: ::DWORD = 3; +pub const D3DFVF_TEXTUREFORMAT3: ::DWORD = 1; +pub const D3DFVF_TEXTUREFORMAT4: ::DWORD = 2; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDEVTYPE { + HAL = 1, + REF = 2, + SW = 3, + NULLREF = 4, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DMULTISAMPLE_TYPE { + NONE = 0, + NONMASKABLE = 1, + _2_SAMPLES = 2, + _3_SAMPLES = 3, + _4_SAMPLES = 4, + _5_SAMPLES = 5, + _6_SAMPLES = 6, + _7_SAMPLES = 7, + _8_SAMPLES = 8, + _9_SAMPLES = 9, + _10_SAMPLES = 10, + _11_SAMPLES = 11, + _12_SAMPLES = 12, + _13_SAMPLES = 13, + _14_SAMPLES = 14, + _15_SAMPLES = 15, + _16_SAMPLES = 16, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DFORMAT { + UNKNOWN = 0, + R8G8B8 = 20, + A8R8G8B8 = 21, + X8R8G8B8 = 22, + R5G6B5 = 23, + X1R5G5B5 = 24, + A1R5G5B5 = 25, + A4R4G4B4 = 26, + R3G3B2 = 27, + A8 = 28, + A8R3G3B2 = 29, + X4R4G4B4 = 30, + A2B10G10R10 = 31, + A8B8G8R8 = 32, + X8B8G8R8 = 33, + G16R16 = 34, + A2R10G10B10 = 35, + A16B16G16R16 = 36, + A8P8 = 40, + P8 = 41, + L8 = 50, + A8L8 = 51, + A4L4 = 52, + V8U8 = 60, + L6V5U5 = 61, + X8L8V8U8 = 62, + Q8W8V8U8 = 63, + V16U16 = 64, + A2W10V10U10 = 67, + UYVY = MAKEFOURCC!(b'U', b'Y', b'V', b'Y'), + R8G8_B8G8 = MAKEFOURCC!(b'R', b'G', b'B', b'G'), + YUY2 = MAKEFOURCC!(b'Y', b'U', b'Y', b'2'), + G8R8_G8B8 = MAKEFOURCC!(b'G', b'R', b'G', b'B'), + DXT1 = MAKEFOURCC!(b'D', b'X', b'T', b'1'), + DXT2 = MAKEFOURCC!(b'D', b'X', b'T', b'2'), + DXT3 = MAKEFOURCC!(b'D', b'X', b'T', b'3'), + DXT4 = MAKEFOURCC!(b'D', b'X', b'T', b'4'), + DXT5 = MAKEFOURCC!(b'D', b'X', b'T', b'5'), + D16_LOCKABLE = 70, + D32 = 71, + D15S1 = 73, + D24S8 = 75, + D24X8 = 77, + D24X4S4 = 79, + D16 = 80, + D32F_LOCKABLE = 82, + D24FS8 = 83, + D32_LOCKABLE = 84, + S8_LOCKABLE = 85, + L16 = 81, + VERTEXDATA = 100, + INDEX16 = 101, + INDEX32 = 102, + Q16W16V16U16 = 110, + MULTI2_ARGB8 = MAKEFOURCC!(b'M', b'E', b'T', b'1'), + R16F = 111, + G16R16F = 112, + A16B16G16R16F = 113, + R32F = 114, + G32R32F = 115, + A32B32G32R32F = 116, + CxV8U8 = 117, + A1 = 118, + A2B10G10R10_XR_BIAS = 119, + BINARYBUFFER = 199, +} +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct D3DDISPLAYMODE { + pub Width: ::UINT, + pub Height: ::UINT, + pub RefreshRate: ::UINT, + pub Format: D3DFORMAT, +} +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub struct D3DDEVICE_CREATION_PARAMETERS { + pub AdapterOrdinal: ::UINT, + pub DeviceType: D3DDEVTYPE, + pub hFocusWindow: ::HWND, + pub BehaviorFlags: ::DWORD, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSWAPEFFECT { + DISCARD = 1, + FLIP = 2, + COPY = 3, + OVERLAY = 4, + FLIPEX = 5, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DPOOL { + DEFAULT = 0, + MANAGED = 1, + SYSTEMMEM = 2, + SCRATCH = 3, +} +pub const D3DPRESENT_RATE_DEFAULT: ::DWORD = 0x00000000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DPRESENT_PARAMETERS { + pub BackBufferWidth: ::UINT, + pub BackBufferHeight: ::UINT, + pub BackBufferFormat: D3DFORMAT, + pub BackBufferCount: ::UINT, + pub MultiSampleType: D3DMULTISAMPLE_TYPE, + pub MultiSampleQuality: ::DWORD, + pub SwapEffect: D3DSWAPEFFECT, + pub hDeviceWindow: ::HWND, + pub Windowed: ::BOOL, + pub EnableAutoDepthStencil: ::BOOL, + pub AutoDepthStencilFormat: D3DFORMAT, + pub Flags: ::DWORD, + pub FullScreen_RefreshRateInHz: ::UINT, + pub PresentationInterval: ::UINT, +} +pub const D3DPRESENTFLAG_LOCKABLE_BACKBUFFER: ::DWORD = 0x00000001; +pub const D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL: ::DWORD = 0x00000002; +pub const D3DPRESENTFLAG_DEVICECLIP: ::DWORD = 0x00000004; +pub const D3DPRESENTFLAG_VIDEO: ::DWORD = 0x00000010; +pub const D3DPRESENTFLAG_NOAUTOROTATE: ::DWORD = 0x00000020; +pub const D3DPRESENTFLAG_UNPRUNEDMODE: ::DWORD = 0x00000040; +pub const D3DPRESENTFLAG_OVERLAY_LIMITEDRGB: ::DWORD = 0x00000080; +pub const D3DPRESENTFLAG_OVERLAY_YCbCr_BT709: ::DWORD = 0x00000100; +pub const D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC: ::DWORD = 0x00000200; +pub const D3DPRESENTFLAG_RESTRICTED_CONTENT: ::DWORD = 0x00000400; +pub const D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER: ::DWORD = 0x00000800; +#[repr(C)] #[derive(Copy)] +pub struct D3DGAMMARAMP { + pub red: [::WORD; 256], + pub green: [::WORD; 256], + pub blue: [::WORD; 256], +} +impl Clone for D3DGAMMARAMP { fn clone(&self) -> D3DGAMMARAMP { *self } } +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DBACKBUFFER_TYPE { + TYPE_MONO = 0, + TYPE_LEFT = 1, + TYPE_RIGHT = 2, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DRESOURCETYPE { + SURFACE = 1, + VOLUME = 2, + TEXTURE = 3, + VOLUMETEXTURE = 4, + CUBETEXTURE = 5, + VERTEXBUFFER = 6, + INDEXBUFFER = 7, +} +pub const D3DUSAGE_RENDERTARGET: ::DWORD = 0x00000001; +pub const D3DUSAGE_DEPTHSTENCIL: ::DWORD = 0x00000002; +pub const D3DUSAGE_DYNAMIC: ::DWORD = 0x00000200; +pub const D3DUSAGE_NONSECURE: ::DWORD = 0x00800000; +pub const D3DUSAGE_AUTOGENMIPMAP: ::DWORD = 0x00000400; +pub const D3DUSAGE_DMAP: ::DWORD = 0x00004000; +pub const D3DUSAGE_QUERY_LEGACYBUMPMAP: ::DWORD = 0x00008000; +pub const D3DUSAGE_QUERY_SRGBREAD: ::DWORD = 0x00010000; +pub const D3DUSAGE_QUERY_FILTER: ::DWORD = 0x00020000; +pub const D3DUSAGE_QUERY_SRGBWRITE: ::DWORD = 0x00040000; +pub const D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING: ::DWORD = 0x00080000; +pub const D3DUSAGE_QUERY_VERTEXTEXTURE: ::DWORD = 0x00100000; +pub const D3DUSAGE_QUERY_WRAPANDMIP : ::DWORD = 0x00200000; +pub const D3DUSAGE_WRITEONLY: ::DWORD = 0x00000008; +pub const D3DUSAGE_SOFTWAREPROCESSING: ::DWORD = 0x00000010; +pub const D3DUSAGE_DONOTCLIP: ::DWORD = 0x00000020; +pub const D3DUSAGE_POINTS: ::DWORD = 0x00000040; +pub const D3DUSAGE_RTPATCHES: ::DWORD = 0x00000080; +pub const D3DUSAGE_NPATCHES: ::DWORD = 0x00000100; +pub const D3DUSAGE_TEXTAPI: ::DWORD = 0x10000000; +pub const D3DUSAGE_RESTRICTED_CONTENT: ::DWORD = 0x00000800; +pub const D3DUSAGE_RESTRICT_SHARED_RESOURCE: ::DWORD = 0x00002000; +pub const D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER: ::DWORD = 0x00001000; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DCUBEMAP_FACES { + POSITIVE_X = 0, + NEGATIVE_X = 1, + POSITIVE_Y = 2, + NEGATIVE_Y = 3, + POSITIVE_Z = 4, + NEGATIVE_Z = 5, +} +pub const D3DLOCK_READONLY: ::DWORD = 0x00000010; +pub const D3DLOCK_DISCARD: ::DWORD = 0x00002000; +pub const D3DLOCK_NOOVERWRITE: ::DWORD = 0x00001000; +pub const D3DLOCK_NOSYSLOCK: ::DWORD = 0x00000800; +pub const D3DLOCK_DONOTWAIT: ::DWORD = 0x00004000; +pub const D3DLOCK_NO_DIRTY_UPDATE: ::DWORD = 0x00008000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DVERTEXBUFFER_DESC { + pub Format: D3DFORMAT, + pub Type: D3DRESOURCETYPE, + pub Usage: ::DWORD, + pub Pool: D3DPOOL, + pub Size: ::UINT, + pub FVF: ::DWORD, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DINDEXBUFFER_DESC { + pub Format: D3DFORMAT, + pub Type: D3DRESOURCETYPE, + pub Usage: ::DWORD, + pub Pool: D3DPOOL, + pub Size: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DSURFACE_DESC { + pub Format: D3DFORMAT, + pub Type: D3DRESOURCETYPE, + pub Usage: ::DWORD, + pub Pool: D3DPOOL, + pub MultiSampleType: D3DMULTISAMPLE_TYPE, + pub MultiSampleQuality: ::DWORD, + pub Width: ::UINT, + pub Height: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DVOLUME_DESC { + pub Format: D3DFORMAT, + pub Type: D3DRESOURCETYPE, + pub Usage: ::DWORD, + pub Pool: D3DPOOL, + pub Width: ::UINT, + pub Height: ::UINT, + pub Depth: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DLOCKED_RECT { + pub Pitch: ::INT, + pub pBits: *mut ::libc::c_void, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DBOX { + pub Left: ::UINT, + pub Top: ::UINT, + pub Right: ::UINT, + pub Bottom: ::UINT, + pub Front: ::UINT, + pub Back: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DLOCKED_BOX { + pub RowPitch: ::INT, + pub SlicePitch: ::INT, + pub pBits: *mut ::libc::c_void, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DRANGE { + pub Offset: ::UINT, + pub Size: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DRECTPATCH_INFO { + pub StartVertexOffsetWidth: ::UINT, + pub StartVertexOffsetHeight: ::UINT, + pub Width: ::UINT, + pub Height: ::UINT, + pub Stride: ::UINT, + pub Basis: D3DBASISTYPE, + pub Degree: D3DDEGREETYPE, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DTRIPATCH_INFO { + pub StartVertexOffset: ::UINT, + pub NumVertices: ::UINT, + pub Basis: D3DBASISTYPE, + pub Degree: D3DDEGREETYPE, +} +pub const MAX_DEVICE_IDENTIFIER_STRING: usize = 512; +#[repr(C)] #[derive(Copy)] +pub struct D3DADAPTER_IDENTIFIER9 { + pub Driver: [::c_char; MAX_DEVICE_IDENTIFIER_STRING], + pub Description: [::c_char; MAX_DEVICE_IDENTIFIER_STRING], + pub DeviceName: [::c_char; 32], + pub DriverVersion: ::LARGE_INTEGER, + pub VendorId: ::DWORD, + pub DeviceId: ::DWORD, + pub SubSysId: ::DWORD, + pub Revision: ::DWORD, + pub DeviceIdentifier: ::GUID, + pub WHQLLevel: ::DWORD, +} +impl Clone for D3DADAPTER_IDENTIFIER9 { fn clone(&self) -> D3DADAPTER_IDENTIFIER9 { *self } } +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DRASTER_STATUS { + pub InVBlank: ::BOOL, + pub ScanLine: ::UINT, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDEBUGMONITORTOKENS { + ENABLE = 0, + DISABLE = 1, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DQUERYTYPE { + VCACHE = 4, + RESOURCEMANAGER = 5, + VERTEXSTATS = 6, + EVENT = 8, + OCCLUSION = 9, + TIMESTAMP = 10, + TIMESTAMPDISJOINT = 11, + TIMESTAMPFREQ = 12, + PIPELINETIMINGS = 13, + INTERFACETIMINGS = 14, + VERTEXTIMINGS = 15, + PIXELTIMINGS = 16, + BANDWIDTHTIMINGS = 17, + CACHEUTILIZATION = 18, + MEMORYPRESSURE = 19, +} +pub const D3DISSUE_END: ::DWORD = 1 << 0; +pub const D3DISSUE_BEGIN: ::DWORD = 1 << 1; +pub const D3DGETDATA_FLUSH: ::DWORD = 1 << 0; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DRESOURCESTATS { + pub bThrashing: ::BOOL, + pub ApproxBytesDownloaded: ::DWORD, + pub NumEvicts: ::DWORD, + pub NumVidCreates: ::DWORD, + pub LastPri: ::DWORD, + pub NumUsed: ::DWORD, + pub NumUsedInVidMem: ::DWORD, + pub WorkingSet: ::DWORD, + pub WorkingSetBytes: ::DWORD, + pub TotalManaged: ::DWORD, + pub TotalBytes: ::DWORD, +} +pub const D3DRTYPECOUNT: usize = 8; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_RESOURCEMANAGER { + pub stats: [D3DRESOURCESTATS; 8 /*D3DRTYPECOUNT, rust bug?*/], +} +pub type LPD3DDEVINFO_RESOURCEMANAGER = *mut D3DDEVINFO_RESOURCEMANAGER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_D3DVERTEXSTATS { + pub NumRenderedTriangles: ::DWORD, + pub NumExtraClippingTriangles: ::DWORD, +} +pub type LPD3DDEVINFO_D3DVERTEXSTATS = *mut D3DDEVINFO_D3DVERTEXSTATS; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_VCACHE { + pub Pattern: ::DWORD, + pub OptMethod: ::DWORD, + pub CacheSize: ::DWORD, + pub MagicNumber: ::DWORD, +} +pub type LPD3DDEVINFO_VCACHE = *mut D3DDEVINFO_VCACHE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_D3D9PIPELINETIMINGS { + pub VertexProcessingTimePercent: ::FLOAT, + pub PixelProcessingTimePercent: ::FLOAT, + pub OtherGPUProcessingTimePercent: ::FLOAT, + pub GPUIdleTimePercent: ::FLOAT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_D3D9INTERFACETIMINGS { + pub WaitingForGPUToUseApplicationResourceTimePercent: ::FLOAT, + pub WaitingForGPUToAcceptMoreCommandsTimePercent: ::FLOAT, + pub WaitingForGPUToStayWithinLatencyTimePercent: ::FLOAT, + pub WaitingForGPUExclusiveResourceTimePercent: ::FLOAT, + pub WaitingForGPUOtherTimePercent: ::FLOAT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_D3D9STAGETIMINGS { + pub MemoryProcessingPercent: ::FLOAT, + pub ComputationProcessingPercent: ::FLOAT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_D3D9BANDWIDTHTIMINGS { + pub MaxBandwidthUtilized: ::FLOAT, + pub FrontEndUploadMemoryUtilizedPercent: ::FLOAT, + pub VertexRateUtilizedPercent: ::FLOAT, + pub TriangleSetupRateUtilizedPercent: ::FLOAT, + pub FillRateUtilizedPercent: ::FLOAT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDEVINFO_D3D9CACHEUTILIZATION { + pub TextureCacheHitRate: ::FLOAT, + pub PostTransformVertexCacheHitRate: ::FLOAT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DMEMORYPRESSURE { + pub BytesEvictedFromProcess: ::UINT64, + pub SizeOfInefficientAllocation: ::UINT64, + pub LevelOfEfficiency: ::DWORD, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DCOMPOSERECTSOP { + COPY = 1, + OR = 2, + AND = 3, + NEG = 4, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DCOMPOSERECTDESC { + pub X: ::USHORT, + pub Y: ::USHORT, + pub Width: ::USHORT, + pub Height: ::USHORT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DCOMPOSERECTDESTINATION { + pub SrcRectIndex: ::USHORT, + pub Reserved: ::USHORT, + pub X: ::SHORT, + pub Y: ::SHORT, +} +pub const D3DCOMPOSERECTS_MAXNUMRECTS: ::DWORD = 0xFFFF; +pub const D3DCONVOLUTIONMONO_MAXWIDTH: ::DWORD = 7; +pub const D3DCONVOLUTIONMONO_MAXHEIGHT: ::DWORD = D3DCONVOLUTIONMONO_MAXWIDTH; +pub const D3DFMT_A1_SURFACE_MAXWIDTH: ::DWORD = 8192; +pub const D3DFMT_A1_SURFACE_MAXHEIGHT: ::DWORD = 2048; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DPRESENTSTATS { + pub PresentCount: ::UINT, + pub PresentRefreshCount: ::UINT, + pub SyncRefreshCount: ::UINT, + pub SyncQPCTime: ::LARGE_INTEGER, + pub SyncGPUTime: ::LARGE_INTEGER, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DSCANLINEORDERING { + UNKNOWN = 0, + PROGRESSIVE = 1, + INTERLACED = 2, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDISPLAYMODEEX { + pub Size: ::UINT, + pub Width: ::UINT, + pub Height: ::UINT, + pub RefreshRate: ::UINT, + pub Format: D3DFORMAT, + pub ScanLineOrdering: D3DSCANLINEORDERING, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DDISPLAYMODEFILTER { + pub Size: ::UINT, + pub Format: D3DFORMAT, + pub ScanLineOrdering: D3DSCANLINEORDERING, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DDISPLAYROTATION { + IDENTITY = 1, + _90 = 2, + _180 = 3, + _270 = 4, +} +pub const D3D9_RESOURCE_PRIORITY_MINIMUM: ::DWORD = 0x28000000; +pub const D3D9_RESOURCE_PRIORITY_LOW: ::DWORD = 0x50000000; +pub const D3D9_RESOURCE_PRIORITY_NORMAL: ::DWORD = 0x78000000; +pub const D3D9_RESOURCE_PRIORITY_HIGH: ::DWORD = 0xa0000000; +pub const D3D9_RESOURCE_PRIORITY_MAXIMUM: ::DWORD = 0xc8000000; +pub const D3D_OMAC_SIZE: usize = 16; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3D_OMAC { + pub Omac: [::BYTE; D3D_OMAC_SIZE], +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DAUTHENTICATEDCHANNELTYPE { + D3D9 = 1, + DRIVER_SOFTWARE = 2, + DRIVER_HARDWARE = 3, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERY_INPUT { + pub QueryType: ::GUID, + pub hChannel: ::HANDLE, + pub SequenceNumber: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT { + pub omac: D3D_OMAC, + pub QueryType: ::GUID, + pub hChannel: ::HANDLE, + pub SequenceNumber: ::UINT, + pub ReturnCode: ::HRESULT, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_PROTECTION, 0xa84eb584, 0xc495, 0x48aa, + 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS { + pub Value: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub ProtectionFlags: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_CHANNELTYPE, 0xbc1b18a5, 0xb1fb, 0x42ab, + 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub ChannelType: D3DAUTHENTICATEDCHANNELTYPE, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_DEVICEHANDLE, 0xec1c539d, 0x8cff, 0x4e2a, + 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub DeviceHandle: ::HANDLE, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_CRYPTOSESSION, 0x2634499e, 0xd018, 0x4d74, + 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT { + pub Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + pub DXVA2DecodeHandle: ::HANDLE, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub DXVA2DecodeHandle: ::HANDLE, + pub CryptoSessionHandle: ::HANDLE, + pub DeviceHandle: ::HANDLE, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, 0xdb207b3, 0x9450, 0x46a6, + 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub NumRestrictedSharedResourceProcesses: ::UINT, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, 0x649bbadb, 0xf0f4, 0x4639, + 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT { + pub Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + pub ProcessIndex: ::UINT, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE { + UNKNOWN = 0, + DWM = 1, + HANDLE = 2, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub ProcessIndex: ::UINT, + pub ProcessIdentifer: D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE, + pub ProcessHandle: ::HANDLE, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, + 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub NumUnrestrictedProtectedSharedResources: ::UINT, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, 0x2c042b5e, 0x8c07, 0x46d5, + 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT { + pub Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + pub DeviceHandle: ::HANDLE, + pub CryptoSessionHandle: ::HANDLE, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub DeviceHandle: ::HANDLE, + pub CryptoSessionHandle: ::HANDLE, + pub NumOutputIDs: ::UINT, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_OUTPUTID, 0x839ddca3, 0x9b4e, 0x41e4, + 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT { + pub Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + pub DeviceHandle: ::HANDLE, + pub CryptoSessionHandle: ::HANDLE, + pub OutputIDIndex: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub DeviceHandle: ::HANDLE, + pub CryptoSessionHandle: ::HANDLE, + pub OutputIDIndex: ::UINT, + pub OutputID: ::UINT64, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, 0x6214d9d2, 0x432c, 0x4abb, + 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b); +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum D3DBUSTYPE { + OTHER = 0x00000000, + PCI = 0x00000001, + PCIX = 0x00000002, + PCIEXPRESS = 0x00000003, + AGP = 0x00000004, + MODIFIER_INSIDE_OF_CHIPSET = 0x00010000, + MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000, + MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000, + MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000, + MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, + MODIFIER_NON_STANDARD = 0x80000000u32 as i32, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub BusType: D3DBUSTYPE, + pub bAccessibleInContiguousBlocks: ::BOOL, + pub bAccessibleInNonContiguousBlocks: ::BOOL, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, 0xb30f7066, 0x203c, 0x4b07, + 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub NumEncryptionGuids: ::UINT, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, 0xf83a5958, 0xe986, 0x4bda, + 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT { + pub Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + pub EncryptionGuidIndex: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub EncryptionGuidIndex: ::UINT, + pub EncryptionGuid: ::GUID, +} +DEFINE_GUID!(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, 0xec1791c7, 0xdad3, 0x4f15, + 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT { + pub Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + pub EncryptionGuid: ::GUID, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT { + pub omac: D3D_OMAC, + pub ConfigureType: ::GUID, + pub hChannel: ::HANDLE, + pub SequenceNumber: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT { + pub omac: D3D_OMAC, + pub ConfigureType: ::GUID, + pub hChannel: ::HANDLE, + pub SequenceNumber: ::UINT, + pub ReturnCode: ::HRESULT, +} +DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_INITIALIZE, 0x6114bdb, 0x3523, 0x470a, + 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE { + pub Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + pub StartSequenceQuery: ::UINT, + pub StartSequenceConfigure: ::UINT, +} +DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_PROTECTION, 0x50455658, 0x3f47, 0x4362, + 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION { + pub Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + pub Protections: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, +} +DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, 0x6346cc54, 0x2cfc, 0x4ad4, + 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION { + pub Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + pub DXVA2DecodeHandle: ::HANDLE, + pub CryptoSessionHandle: ::HANDLE, + pub DeviceHandle: ::HANDLE, +} +DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, 0x772d047, 0x1b40, 0x48e8, + 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE { + pub Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + pub ProcessIdentiferType: D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE, + pub ProcessHandle: ::HANDLE, + pub AllowAccess: ::BOOL, +} +DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, 0x41fff286, 0x6ae0, 0x4d43, + 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION { + pub Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + pub EncryptionGuid: ::GUID, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DENCRYPTED_BLOCK_INFO { + pub NumEncryptedBytesAtBeginning: ::UINT, + pub NumBytesInSkipPattern: ::UINT, + pub NumBytesInEncryptPattern: ::UINT, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct D3DAES_CTR_IV { + pub IV: ::UINT64, + pub Count: ::UINT64, +} diff --git a/deps/winapi-0.1.23/src/dbghelp.rs b/deps/winapi-0.1.23/src/dbghelp.rs new file mode 100644 index 000000000..adc632913 --- /dev/null +++ b/deps/winapi-0.1.23/src/dbghelp.rs @@ -0,0 +1,346 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! DbgHelp include file +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct LOADED_IMAGE { + pub ModuleName: ::PSTR, + pub hFile: ::HANDLE, + pub MappedAddress: ::PUCHAR, + #[cfg(target_arch = "x86_64")] + pub FileHeader: ::PIMAGE_NT_HEADERS64, + #[cfg(not(target_arch = "x86_64"))] + pub FileHeader: ::PIMAGE_NT_HEADERS32, + pub LastRvaSection: ::PIMAGE_SECTION_HEADER, + pub NumberOfSections: ::ULONG, + pub Sections: ::PIMAGE_SECTION_HEADER, + pub Characteristics: ::ULONG, + pub fSystemImage: ::BOOLEAN, + pub fDOSImage: ::BOOLEAN, + pub fReadOnly: ::BOOLEAN, + pub Version: ::UCHAR, + pub Links: ::LIST_ENTRY, + pub SizeOfImage: ::ULONG, +} +pub const MAX_SYM_NAME: usize = 2000; +pub const ERROR_IMAGE_NOT_STRIPPED: ::DWORD = 0x8800; +pub const ERROR_NO_DBG_POINTER: ::DWORD = 0x8801; +pub const ERROR_NO_PDB_POINTER: ::DWORD = 0x8802; +pub type PFIND_DEBUG_FILE_CALLBACK = Option<unsafe extern "system" fn( + FileHandle: ::HANDLE, FileName: ::PCSTR, CallerData: ::PVOID, +) -> ::BOOL>; +pub type PFIND_DEBUG_FILE_CALLBACKW = Option<unsafe extern "system" fn( + FileHandle: ::HANDLE, FileName: ::PCWSTR, CallerData: ::PVOID, +) -> ::BOOL>; +pub type PFINDFILEINPATHCALLBACK = Option<unsafe extern "system" fn( + filename: ::PCSTR, context: ::PVOID, +) -> ::BOOL>; +pub type PFINDFILEINPATHCALLBACKW = Option<unsafe extern "system" fn( + filename: ::PCWSTR, context: ::PVOID, +) -> ::BOOL>; +pub type PFIND_EXE_FILE_CALLBACK = Option<unsafe extern "system" fn( + FileHandle: ::HANDLE, FileName: ::PCSTR, CallerData: ::PVOID, +) -> ::BOOL>; +pub type PFIND_EXE_FILE_CALLBACKW = Option<unsafe extern "system" fn( + FileHandle: ::HANDLE, FileName: ::PCWSTR, CallerData: ::PVOID, +) -> ::BOOL>; +#[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] +pub struct IMAGE_DEBUG_INFORMATION { + pub List: ::LIST_ENTRY, + pub ReservedSize: ::DWORD, + pub ReservedMappedBase: ::PVOID, + pub ReservedMachine: ::USHORT, + pub ReservedCharacteristics: ::USHORT, + pub ReservedCheckSum: ::DWORD, + pub ImageBase: ::DWORD, + pub SizeOfImage: ::DWORD, + pub ReservedNumberOfSections: ::DWORD, + pub ReservedSections: ::PIMAGE_SECTION_HEADER, + pub ReservedExportedNamesSize: ::DWORD, + pub ReservedExportedNames: ::PSTR, + pub ReservedNumberOfFunctionTableEntries: ::DWORD, + pub ReservedFunctionTableEntries: ::PIMAGE_FUNCTION_ENTRY, + pub ReservedLowestFunctionStartingAddress: ::DWORD, + pub ReservedHighestFunctionEndingAddress: ::DWORD, + pub ReservedNumberOfFpoTableEntries: ::DWORD, + pub ReservedFpoTableEntries: ::PFPO_DATA, + pub SizeOfCoffSymbols: ::DWORD, + pub CoffSymbols: ::PIMAGE_COFF_SYMBOLS_HEADER, + pub ReservedSizeOfCodeViewSymbols: ::DWORD, + pub ReservedCodeViewSymbols: ::PVOID, + pub ImageFilePath: ::PSTR, + pub ImageFileName: ::PSTR, + pub ReservedDebugFilePath: ::PSTR, + pub ReservedTimeDateStamp: ::DWORD, + pub ReservedRomImage: ::BOOL, + pub ReservedDebugDirectory: ::PIMAGE_DEBUG_DIRECTORY, + pub ReservedNumberOfDebugDirectories: ::DWORD, + pub ReservedOriginalFunctionTableBaseAddress: ::DWORD, + pub Reserved: [::DWORD; 2], +} +#[cfg(target_arch = "x86")] +pub type PIMAGE_DEBUG_INFORMATION = *mut IMAGE_DEBUG_INFORMATION; +pub type PENUMDIRTREE_CALLBACK = Option<unsafe extern "system" fn( + FilePath: ::PCSTR, CallerData: ::PVOID, +) -> ::BOOL>; +pub type PENUMDIRTREE_CALLBACKW = Option<unsafe extern "system" fn( + FilePath: ::PCWSTR, CallerData: ::PVOID, +) -> ::BOOL>; +pub const UNDNAME_COMPLETE: ::DWORD = 0x0000; +pub const UNDNAME_NO_LEADING_UNDERSCORES: ::DWORD = 0x0001; +pub const UNDNAME_NO_MS_KEYWORDS: ::DWORD = 0x0002; +pub const UNDNAME_NO_FUNCTION_RETURNS: ::DWORD = 0x0004; +pub const UNDNAME_NO_ALLOCATION_MODEL: ::DWORD = 0x0008; +pub const UNDNAME_NO_ALLOCATION_LANGUAGE: ::DWORD = 0x0010; +pub const UNDNAME_NO_MS_THISTYPE: ::DWORD = 0x0020; +pub const UNDNAME_NO_CV_THISTYPE: ::DWORD = 0x0040; +pub const UNDNAME_NO_THISTYPE: ::DWORD = 0x0060; +pub const UNDNAME_NO_ACCESS_SPECIFIERS: ::DWORD = 0x0080; +pub const UNDNAME_NO_THROW_SIGNATURES: ::DWORD = 0x0100; +pub const UNDNAME_NO_MEMBER_TYPE: ::DWORD = 0x0200; +pub const UNDNAME_NO_RETURN_UDT_MODEL: ::DWORD = 0x0400; +pub const UNDNAME_32_BIT_DECODE: ::DWORD = 0x0800; +pub const UNDNAME_NAME_ONLY: ::DWORD = 0x1000; +pub const UNDNAME_NO_ARGUMENTS: ::DWORD = 0x2000; +pub const UNDNAME_NO_SPECIAL_SYMS: ::DWORD = 0x4000; +pub const DBHHEADER_DEBUGDIRS: ::DWORD = 0x1; +pub const DBHHEADER_CVMISC: ::DWORD = 0x2; +pub const DBHHEADER_PDBGUID: ::DWORD = 0x3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MODLOAD_DATA { + pub ssize: ::DWORD, + pub ssig: ::DWORD, + pub data: ::PVOID, + pub size: ::DWORD, + pub flags: ::DWORD, +} +pub type PMODLOAD_DATA = *mut MODLOAD_DATA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MODLOAD_CVMISC { + pub oCV: ::DWORD, + pub cCV: ::size_t, + pub oMisc: ::DWORD, + pub cMisc: ::size_t, + pub dtImage: ::DWORD, + pub cImage: ::DWORD, +} +pub type PMODLOAD_CVMISC = *mut MODLOAD_CVMISC; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MODLOAD_PDBGUID_PDBAGE { + pub PdbGuid: ::GUID, + pub PdbAge: ::DWORD, +} +pub type PMODLOAD_PDBGUID_PDBAGE = *mut MODLOAD_PDBGUID_PDBAGE; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum ADDRESS_MODE { + AddrMode1616, + AddrMode1632, + AddrModeReal, + AddrModeFlat, +} +pub use self::ADDRESS_MODE::*; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ADDRESS64 { + pub Offset: ::DWORD64, + pub Segment: ::WORD, + pub Mode: ::ADDRESS_MODE, +} +pub type LPADDRESS64 = *mut ADDRESS64; +#[cfg(target_arch = "x86_64")] +pub type ADDRESS = ADDRESS64; +#[cfg(target_arch = "x86_64")] +pub type LPADDRESS = LPADDRESS64; +#[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] +pub struct ADDRESS { + pub Offset: ::DWORD, + pub Segment: ::WORD, + pub Mode: ::ADDRESS_MODE, +} +#[cfg(target_arch = "x86")] +pub type LPADDRESS = *mut ADDRESS; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct KDHELP64 { + pub Thread: ::DWORD64, + pub ThCallbackStack: ::DWORD, + pub ThCallbackBStore: ::DWORD, + pub NextCallback: ::DWORD, + pub FramePointer: ::DWORD, + pub KiCallUserMode: ::DWORD64, + pub KeUserCallbackDispatcher: ::DWORD64, + pub SystemRangeStart: ::DWORD64, + pub KiUserExceptionDispatcher: ::DWORD64, + pub StackBase: ::DWORD64, + pub StackLimit: ::DWORD64, + pub BuildVersion: ::DWORD, + pub Reserved0: ::DWORD, + pub Reserved1: [::DWORD64; 4], +} +pub type PKDHELP64 = *mut KDHELP64; +#[cfg(target_arch = "x86_64")] +pub type KDHELP = KDHELP64; +#[cfg(target_arch = "x86_64")] +pub type PKDHELP = PKDHELP64; +#[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] +pub struct KDHELP { + pub Thread: ::DWORD, + pub ThCallbackStack: ::DWORD, + pub NextCallback: ::DWORD, + pub FramePointer: ::DWORD, + pub KiCallUserMode: ::DWORD, + pub KeUserCallbackDispatcher: ::DWORD, + pub SystemRangeStart: ::DWORD, + pub ThCallbackBStore: ::DWORD, + pub KiUserExceptionDispatcher: ::DWORD, + pub StackBase: ::DWORD, + pub StackLimit: ::DWORD, + pub Reserved: [::DWORD; 5], +} +#[cfg(target_arch = "x86")] +pub type PKDHELP = *mut KDHELP; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct STACKFRAME64 { + pub AddrPC: ::ADDRESS64, + pub AddrReturn: ::ADDRESS64, + pub AddrFrame: ::ADDRESS64, + pub AddrStack: ::ADDRESS64, + pub AddrBStore: ::ADDRESS64, + pub FuncTableEntry: ::PVOID, + pub Params: [::DWORD64; 4], + pub Far: ::BOOL, + pub Virtual: ::BOOL, + pub Reserved: [::DWORD64; 3], + pub KdHelp: ::KDHELP64, +} +pub type LPSTACKFRAME64 = *mut STACKFRAME64; +pub const INLINE_FRAME_CONTEXT_INIT: ::DWORD = 0; +pub const INLINE_FRAME_CONTEXT_IGNORE: ::DWORD = 0xFFFFFFFF; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct STACKFRAME_EX { + pub AddrPC: ::ADDRESS64, + pub AddrReturn: ::ADDRESS64, + pub AddrFrame: ::ADDRESS64, + pub AddrStack: ::ADDRESS64, + pub AddrBStore: ::ADDRESS64, + pub FuncTableEntry: ::PVOID, + pub Params: [::DWORD64; 4], + pub Far: ::BOOL, + pub Virtual: ::BOOL, + pub Reserved: [::DWORD64; 3], + pub KdHelp: ::KDHELP64, + pub StackFrameSize: ::DWORD, + pub InlineFrameContext: ::DWORD, +} +pub type LPSTACKFRAME_EX = *mut STACKFRAME_EX; +#[cfg(target_arch = "x86_64")] +pub type STACKFRAME = STACKFRAME64; +#[cfg(target_arch = "x86_64")] +pub type LPSTACKFRAME = LPSTACKFRAME64; +#[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] +pub struct STACKFRAME { + pub AddrPC: ::ADDRESS, + pub AddrReturn: ::ADDRESS, + pub AddrFrame: ::ADDRESS, + pub AddrStack: ::ADDRESS, + pub FuncTableEntry: ::PVOID, + pub Params: [::DWORD; 4], + pub Far: ::BOOL, + pub Virtual: ::BOOL, + pub Reserved: [::DWORD; 3], + pub KdHelp: ::KDHELP, + pub AddrBStore: ::ADDRESS, +} +#[cfg(target_arch = "x86")] +pub type LPSTACKFRAME = *mut STACKFRAME; +pub type PREAD_PROCESS_MEMORY_ROUTINE64 = Option<unsafe extern "system" fn( + hProcess: ::HANDLE, qwBaseAddress: ::DWORD64, lpBuffer: ::PVOID, nSize: ::DWORD, + lpNumberOfBytesRead: ::LPDWORD, +) -> ::BOOL>; +pub type PFUNCTION_TABLE_ACCESS_ROUTINE64 = Option<unsafe extern "system" fn( + ahProcess: ::HANDLE, AddrBase: ::DWORD64, +) -> ::PVOID>; +pub type PGET_MODULE_BASE_ROUTINE64 = Option<unsafe extern "system" fn( + hProcess: ::HANDLE, Address: ::DWORD64, +) -> ::DWORD64>; +pub type PTRANSLATE_ADDRESS_ROUTINE64 = Option<unsafe extern "system" fn( + hProcess: ::HANDLE, hThread: ::HANDLE, lpaddr: LPADDRESS64, +) -> ::DWORD64>; +pub const SYM_STKWALK_DEFAULT: ::DWORD = 0x00000000; +pub const SYM_STKWALK_FORCE_FRAMEPTR: ::DWORD = 0x00000001; +#[cfg(target_arch = "x86_64")] +pub type PREAD_PROCESS_MEMORY_ROUTINE = PREAD_PROCESS_MEMORY_ROUTINE64; +#[cfg(target_arch = "x86_64")] +pub type PFUNCTION_TABLE_ACCESS_ROUTINE = PFUNCTION_TABLE_ACCESS_ROUTINE64; +#[cfg(target_arch = "x86_64")] +pub type PGET_MODULE_BASE_ROUTINE = PGET_MODULE_BASE_ROUTINE64; +#[cfg(target_arch = "x86_64")] +pub type PTRANSLATE_ADDRESS_ROUTINE = PTRANSLATE_ADDRESS_ROUTINE64; +#[cfg(target_arch = "x86")] +pub type PREAD_PROCESS_MEMORY_ROUTINE = Option<unsafe extern "system" fn( + hProcess: ::HANDLE, qwBaseAddress: ::DWORD, lpBuffer: ::PVOID, nSize: ::DWORD, + lpNumberOfBytesRead: ::PDWORD, +) -> ::BOOL>; +#[cfg(target_arch = "x86")] +pub type PFUNCTION_TABLE_ACCESS_ROUTINE = Option<unsafe extern "system" fn( + ahProcess: ::HANDLE, AddrBase: ::DWORD, +) -> ::PVOID>; +#[cfg(target_arch = "x86")] +pub type PGET_MODULE_BASE_ROUTINE = Option<unsafe extern "system" fn( + hProcess: ::HANDLE, Address: ::DWORD, +) -> ::DWORD>; +#[cfg(target_arch = "x86")] +pub type PTRANSLATE_ADDRESS_ROUTINE = Option<unsafe extern "system" fn( + hProcess: ::HANDLE, hThread: ::HANDLE, lpaddr: LPADDRESS, +) -> ::DWORD>; +pub const API_VERSION_NUMBER: ::USHORT = 12; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct API_VERSION { + pub MajorVersion: ::USHORT, + pub MinorVersion: ::USHORT, + pub Revision: ::USHORT, + pub Reserved: ::USHORT, +} +pub type LPAPI_VERSION = *mut API_VERSION; + + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SYMBOL_INFOW { + pub SizeOfStruct: ::ULONG, + pub TypeIndex: ::ULONG, + pub Reserved: [::ULONG64; 2], + pub Index: ::ULONG, + pub Size: ::ULONG, + pub ModBase: ::ULONG64, + pub Flags: ::ULONG, + pub Value: ::ULONG64, + pub Address: ::ULONG64, + pub Register: ::ULONG, + pub Scope: ::ULONG, + pub Tag: ::ULONG, + pub NameLen: ::ULONG, + pub MaxNameLen: ::ULONG, + pub Name: [::WCHAR; 1], +} + +pub type PSYMBOL_INFOW = *mut SYMBOL_INFOW; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGEHLP_SYMBOL64 { + pub SizeOfStruct: ::DWORD, + pub Address: ::DWORD64, + pub Size: ::DWORD, + pub Flags: ::DWORD, + pub MaxNameLength: ::DWORD, + pub Name: [::CHAR; 1], +} + +pub type PIMAGEHLP_SYMBOL64 = *mut IMAGEHLP_SYMBOL64; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGEHLP_LINEW64 { + pub SizeOfStruct: ::DWORD, + pub Key: ::PVOID, + pub LineNumber: ::DWORD, + pub FileName: ::PWSTR, + pub Address: ::DWORD64, +} + +pub type PIMAGEHLP_LINEW64 = *mut IMAGEHLP_LINEW64; diff --git a/deps/winapi-0.1.23/src/dwmapi.rs b/deps/winapi-0.1.23/src/dwmapi.rs new file mode 100644 index 000000000..1f5f8b06b --- /dev/null +++ b/deps/winapi-0.1.23/src/dwmapi.rs @@ -0,0 +1,10 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Procedure declarations, constant definitions, and macros for the NLS component. +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DWM_BLURBEHIND { + pub dwFlags: ::DWORD, + pub fEnable: ::BOOL, + pub hRgnBlur: ::HRGN, + pub fTransitionOnMaximized: ::BOOL, +} diff --git a/deps/winapi-0.1.23/src/fileapi.rs b/deps/winapi-0.1.23/src/fileapi.rs new file mode 100644 index 000000000..ee8d6ba59 --- /dev/null +++ b/deps/winapi-0.1.23/src/fileapi.rs @@ -0,0 +1,47 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! ApiSet Contract for api-ms-win-core-file-l1 +pub const CREATE_NEW: ::DWORD = 1; +pub const CREATE_ALWAYS: ::DWORD = 2; +pub const OPEN_EXISTING: ::DWORD = 3; +pub const OPEN_ALWAYS: ::DWORD = 4; +pub const TRUNCATE_EXISTING: ::DWORD = 5; +pub const INVALID_FILE_SIZE: ::DWORD = 0xFFFFFFFF; +pub const INVALID_SET_FILE_POINTER: ::DWORD = 0xFFFFFFFF; +pub const INVALID_FILE_ATTRIBUTES: ::DWORD = 0xFFFFFFFF; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WIN32_FILE_ATTRIBUTE_DATA { + pub dwFileAttributes: ::DWORD, + pub ftCreationTime: ::FILETIME, + pub ftLastAccessTime: ::FILETIME, + pub ftLastWriteTime: ::FILETIME, + pub nFileSizeHigh: ::DWORD, + pub nFileSizeLow: ::DWORD, +} +pub type LPWIN32_FILE_ATTRIBUTE_DATA = *mut WIN32_FILE_ATTRIBUTE_DATA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct BY_HANDLE_FILE_INFORMATION { + pub dwFileAttributes: ::DWORD, + pub ftCreationTime: ::FILETIME, + pub ftLastAccessTime: ::FILETIME, + pub ftLastWriteTime: ::FILETIME, + pub dwVolumeSerialNumber: ::DWORD, + pub nFileSizeHigh: ::DWORD, + pub nFileSizeLow: ::DWORD, + pub nNumberOfLinks: ::DWORD, + pub nFileIndexHigh: ::DWORD, + pub nFileIndexLow: ::DWORD, +} +pub type PBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION; +pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREATEFILE2_EXTENDED_PARAMETERS { + pub dwSize: ::DWORD, + pub dwFileAttributes: ::DWORD, + pub dwFileFlags: ::DWORD, + pub dwSecurityQosFlags: ::DWORD, + pub lpSecurityAttributes: ::LPSECURITY_ATTRIBUTES, + pub hTemplateFile: ::HANDLE, +} +pub type PCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFILE2_EXTENDED_PARAMETERS; +pub type LPCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFILE2_EXTENDED_PARAMETERS; diff --git a/deps/winapi-0.1.23/src/heapapi.rs b/deps/winapi-0.1.23/src/heapapi.rs new file mode 100644 index 000000000..c215425ee --- /dev/null +++ b/deps/winapi-0.1.23/src/heapapi.rs @@ -0,0 +1,13 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! ApiSet Contract for api-ms-win-core-heap-l1 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HEAP_SUMMARY { + pub cb: ::DWORD, + pub cbAllocated: ::SIZE_T, + pub cbCommitted: ::SIZE_T, + pub cbReserved: ::SIZE_T, + pub cbMaxReserve: ::SIZE_T, +} +pub type PHEAP_SUMMARY = *mut HEAP_SUMMARY; +pub type LPHEAP_SUMMARY = PHEAP_SUMMARY; diff --git a/deps/winapi-0.1.23/src/inaddr.rs b/deps/winapi-0.1.23/src/inaddr.rs new file mode 100644 index 000000000..fbac5a53d --- /dev/null +++ b/deps/winapi-0.1.23/src/inaddr.rs @@ -0,0 +1,7 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! IPv4 Internet address +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IN_ADDR(pub ::ULONG); +pub type PIN_ADDR = *mut IN_ADDR; +pub type LPIN_ADDR = *mut IN_ADDR; diff --git a/deps/winapi-0.1.23/src/lib.rs b/deps/winapi-0.1.23/src/lib.rs new file mode 100644 index 000000000..f03b6ff5c --- /dev/null +++ b/deps/winapi-0.1.23/src/lib.rs @@ -0,0 +1,1976 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Types and constants for WinAPI bindings. +#![allow(bad_style, raw_pointer_derive)] +#![warn(missing_copy_implementations, trivial_casts, trivial_numeric_casts)] +#![warn(unused_qualifications, unused)] +#![cfg(windows)] +//------------------------------------------------------------------------------------------------- +// External crates +//------------------------------------------------------------------------------------------------- +extern crate libc; +//------------------------------------------------------------------------------------------------- +// Imports +//------------------------------------------------------------------------------------------------- +pub use libc::{ + c_void, + c_char, + c_schar, + c_uchar, + c_short, + c_ushort, + c_int, + c_uint, + c_long, + c_ulong, + c_longlong, + c_ulonglong, + wchar_t, + c_float, + c_double, + size_t, +}; +pub use audioclient::*; +pub use basetsd::*; +pub use commctrl::*; +pub use d3d9::*; +pub use d3d9caps::*; +pub use d3d9types::*; +pub use dbghelp::*; +pub use dwmapi::*; +pub use fileapi::*; +pub use heapapi::*; +pub use inaddr::*; +pub use libloaderapi::*; +pub use minwinbase::*; +pub use minwindef::*; +pub use mmdeviceapi::*; +pub use mmreg::*; +pub use mmsystem::*; +pub use objidl::*; +pub use objidlbase::*; +pub use processthreadsapi::*; +pub use propsys::*; +pub use schannel::*; +pub use shellapi::*; +pub use shobjidl::*; +pub use shtypes::*; +pub use sspi::*; +pub use synchapi::*; +pub use timezoneapi::*; +pub use unknwnbase::*; +pub use vadefs::*; +pub use winbase::*; +pub use wincon::*; +pub use wincred::*; +pub use wincrypt::*; +pub use windowsx::*; +pub use windef::*; +pub use winerror::*; +pub use wingdi::*; +pub use winioctl::*; +pub use winnetwk::*; +pub use winnls::*; +pub use winnt::*; +pub use winsock2::*; +pub use winsvc::*; +pub use winuser::*; +pub use ws2def::*; +pub use wtypesbase::*; +//------------------------------------------------------------------------------------------------- +// Macros +//------------------------------------------------------------------------------------------------- +macro_rules! DECLARE_HANDLE { + ($name:ident, $inner:ident) => { + #[repr(C)] #[allow(missing_copy_implementations)] struct $inner { unused: () } + pub type $name = *mut $inner; + }; +} +macro_rules! MAKE_HRESULT { + ($sev:expr, $fac:expr, $code:expr) => { + ($sev << 31) | ($fac << 16) | $code + } +} +macro_rules! MAKE_SCODE { + ($sev:expr, $fac:expr, $code:expr) => { + ($sev << 31) | ($fac << 16) | $code + } +} +macro_rules! MAKEFOURCC { + ($a:expr, $b:expr, $c:expr, $d:expr) => { + ($a as i32) | (($b as i32) << 8) | (($c as i32) << 16) | (($d as i32) << 24) + } +} +macro_rules! DEFINE_GUID { + ( + $name:ident, $l:expr, $w1:expr, $w2:expr, $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, + $b6:expr, $b7:expr, $b8:expr + ) => { + pub const $name: ::GUID = ::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + }; + } +} +macro_rules! CTL_CODE { + ($DeviceType:expr, $Function:expr, $Method:expr, $Access:expr) => { + ($DeviceType << 16) | ($Access << 14) | ($Function << 2) | $Method + } +} +macro_rules! RIDL { + (interface $interface:ident ($vtbl:ident) + {$( + fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty + ),+} + ) => { + #[repr(C)] #[allow(missing_copy_implementations)] + pub struct $vtbl { + $(pub $method: unsafe extern "system" fn( + This: *mut $interface + $(,$p: $t)* + ) -> $rtr),+ + } + #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] + pub struct $interface { + pub lpVtbl: *const $vtbl + } + impl $interface { + #[inline] + $(pub unsafe fn $method(&mut self $(,$p: $t)*) -> $rtr { + ((*self.lpVtbl).$method)(self $(,$p)*) + })+ + } + }; + (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) + {$( + fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty + ),+} + ) => { + #[repr(C)] #[allow(missing_copy_implementations)] + pub struct $vtbl { + pub parent: ::$pvtbl + $(,pub $method: unsafe extern "system" fn( + This: *mut $interface + $(,$p: $t)* + ) -> $rtr)+ + } + #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] + pub struct $interface { + pub lpVtbl: *const $vtbl + } + impl $interface { + #[inline] + $(pub unsafe fn $method(&mut self $(,$p: $t)*) -> $rtr { + ((*self.lpVtbl).$method)(self $(,$p)*) + })+ + } + impl ::std::ops::Deref for $interface { + type Target = ::$pinterface; + #[inline] + fn deref(&self) -> &::$pinterface { + unsafe { ::std::mem::transmute(self) } + } + } + impl ::std::ops::DerefMut for $interface { + #[inline] + fn deref_mut(&mut self) -> &mut ::$pinterface { + unsafe { ::std::mem::transmute(self) } + } + } + }; +} +macro_rules! UNION { + ($base:ident, $field:ident, $variant:ident, $variantmut: ident, $fieldtype:ty) => { + impl $base { + #[inline] + pub unsafe fn $variant(&self) -> &$fieldtype { + ::std::mem::transmute(&self.$field) + } + #[inline] + pub unsafe fn $variantmut(&mut self) -> &mut $fieldtype { + ::std::mem::transmute(&mut self.$field) + } + } + } +} +//------------------------------------------------------------------------------------------------- +// Modules +//------------------------------------------------------------------------------------------------- +pub mod audioclient; +pub mod basetsd; +pub mod commctrl; +pub mod d3d9; +pub mod d3d9caps; +pub mod d3d9types; +pub mod dbghelp; +pub mod dwmapi; +pub mod fileapi; +pub mod heapapi; +pub mod inaddr; +pub mod libloaderapi; +pub mod minwinbase; +pub mod minwindef; +pub mod mmdeviceapi; +pub mod mmreg; +pub mod mmsystem; +pub mod objidl; +pub mod objidlbase; +pub mod processthreadsapi; +pub mod propsys; +pub mod schannel; +pub mod shellapi; +pub mod shobjidl; +pub mod shtypes; +pub mod sspi; +pub mod synchapi; +pub mod timezoneapi; +pub mod unknwnbase; +pub mod vadefs; +pub mod winbase; +pub mod wincon; +pub mod wincred; +pub mod wincrypt; +pub mod windef; +pub mod windowsx; +pub mod winerror; +pub mod wingdi; +pub mod winioctl; +pub mod winnetwk; +pub mod winnls; +pub mod winnt; +pub mod winsock2; +pub mod winsvc; +pub mod winuser; +pub mod ws2def; +pub mod wtypesbase; +//------------------------------------------------------------------------------------------------- +// Primitive types not defined by libc +//------------------------------------------------------------------------------------------------- +pub type __int8 = i8; +pub type __uint8 = u8; +pub type __int16 = i16; +pub type __uint16 = u16; +pub type __int32 = i32; +pub type __uint32 = u32; +pub type __int64 = i64; +pub type __uint64 = u64; + +// guiddef.h +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct GUID { + pub Data1: c_ulong, + pub Data2: c_ushort, + pub Data3: c_ushort, + pub Data4: [c_uchar; 8], +} +pub type LPGUID = *mut GUID; +pub type LPCGUID = *const GUID; +pub type IID = GUID; +pub type LPIID = *mut IID; +pub type CLSID = GUID; +pub type LPCLSID = *mut CLSID; +pub type FMTID = GUID; +pub type LPFMTID = *mut FMTID; +pub type REFGUID = *const GUID; +pub type REFIID = *const IID; +pub type REFCLSID = *const IID; +pub type REFFMTID = *const IID; +// excpt.h +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum EXCEPTION_DISPOSITION { + ExceptionContinueExecution = 0, + ExceptionContinueSearch = 1, + ExceptionNestedException = 2, + ExceptionCollidedUnwind = 3, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct _EXCEPTION_RECORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct _CONTEXT; +#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct _DISPATCHER_CONTEXT; +// shlobj.h +pub type GPFIDL_FLAGS = c_int; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum KNOWN_FOLDER_FLAG { + KF_FLAG_DEFAULT = 0x00000000, + KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000, + KF_FLAG_CREATE = 0x00008000, + KF_FLAG_DONT_VERIFY = 0x00004000, + KF_FLAG_DONT_UNEXPAND = 0x00002000, + KF_FLAG_NO_ALIAS = 0x00001000, + KF_FLAG_INIT = 0x00000800, + KF_FLAG_DEFAULT_PATH = 0x00000400, + KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200, + KF_FLAG_SIMPLE_IDLIST = 0x00000100, + KF_FLAG_ALIAS_ONLY = 0x80000000u32 as i32, +} +pub const IDO_SHGIOI_SHARE: c_int = 0x0FFFFFFF; +pub const IDO_SHGIOI_LINK: c_int = 0x0FFFFFFE; +// Yes, these values are supposed to overflow. Blame Microsoft. +pub const IDO_SHGIOI_SLOWFILE: c_int = 0xFFFFFFFDu32 as c_int; +pub const IDO_SHGIOI_DEFAULT: c_int = 0xFFFFFFFCu32 as c_int; +pub const GPFIDL_DEFAULT: GPFIDL_FLAGS = 0x0000; +pub const GPFIDL_ALTNAME: GPFIDL_FLAGS = 0x0001; +pub const GPFIDL_UNCPRINTER: GPFIDL_FLAGS = 0x0002; +pub const OFASI_EDIT: DWORD = 0x0001; +pub const OFASI_OPENDESKTOP: DWORD = 0x0002; +// winddef.h +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HWND__; +pub type HWND = *mut HWND__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HHOOK__; +pub type HHOOK = *mut HHOOK__; +pub type HGDIOBJ = *mut c_void; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HACCEL__; +pub type HACCEL = *mut HACCEL__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HBITMAP__; +pub type HBITMAP = *mut HBITMAP__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HBRUSH__; +pub type HBRUSH = *mut HBRUSH__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HCOLORSPACE__; +pub type HCOLORSPACE = *mut HCOLORSPACE__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HDC__; +pub type HDC = *mut HDC__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HGLRC__; +pub type HGLRC = *mut HGLRC__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HDESK__; +pub type HDESK = *mut HDESK__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HENHMETAFILE__; +pub type HENHMETAFILE = *mut HENHMETAFILE__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HFONT__; +pub type HFONT = *mut HFONT__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HICON__; +pub type HICON = *mut HICON__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HMENU__; +pub type HMENU = *mut HMENU__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HPALETTE__; +pub type HPALETTE = *mut HPALETTE__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HPEN__; +pub type HPEN = *mut HPEN__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HWINEVENTHOOK__; +pub type HWINEVENTHOOK = *mut HWINEVENTHOOK__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HMONITOR__; +pub type HMONITOR = *mut HMONITOR__; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HUMPD__; +pub type HUMPD = *mut HUMPD__; +pub type HCURSOR = HICON; +pub type COLORREF = DWORD; +pub type LPCOLORREF = *mut DWORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RECT { + pub left: LONG, + pub top: LONG, + pub right: LONG, + pub bottom: LONG, +} +pub type PRECT = *mut RECT; +pub type NPRECT = *mut RECT; +pub type LPRECT = *mut RECT; +pub type LPCRECT = *const RECT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct POINT { + pub x: LONG, + pub y: LONG, +} +pub type PPOINT = *mut POINT; +pub type NPPOINT = *mut POINT; +pub type LPPOINT = *mut POINT; + +// shlobjdl.h +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IContextMenu; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IContextMenu2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IContextMenu3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExecuteCommand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPersistFolder; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IRunnableTask; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellTaskScheduler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IQueryCodePage; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPersistFolder2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPersistFolder3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPersistIDList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumIDList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumFullIDList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFileSyncMergeHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectWithFolderEnumMode; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IParseAndCreateItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellFolder; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumExtraSearch; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellFolder2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderViewOptions; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellView; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellView2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellView3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderView; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ISearchBoxInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderView2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderViewSettings; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPreviewHandlerVisuals; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IVisualProperties; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICommDlgBrowser; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICommDlgBrowser2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICommDlgBrowser3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IColumnManager; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderFilterSite; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderFilter; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInputObjectSite; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInputObject; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInputObject2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellIcon; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellBrowser; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IProfferService; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellItem2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellItemImageFactory; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IUserAccountChangeCallback; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumShellItems; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITransferAdviseSink; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITransferSource; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumResources; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellItemResources; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITransferDestination; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IStreamAsync; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IStreamUnbufferedInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInitializeWithItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectWithSelection; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectWithBackReferences; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPropertyUI; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICategoryProvider; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICategorizer; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDropTargetHelper; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDragSourceHelper; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDragSourceHelper2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellLinkA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellLinkW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellLinkDataList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IResolveShellLink; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IActionProgressDialog; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IHWEventHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IHWEventHandler2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IQueryCancelAutoPlay; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDynamicHWHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IActionProgress; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellExtInit; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellPropSheetExt; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IRemoteComputer; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IQueryContinue; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectWithCancelEvent; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IUserNotification; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IUserNotificationCallback; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IUserNotification2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IItemNameLimits; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ISearchFolderItemFactory; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExtractImage; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExtractImage2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IThumbnailHandlerFactory; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IParentAndItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDockingWindow; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDeskBand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDeskBandInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDeskBand2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITaskbarList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITaskbarList2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITaskbarList3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITaskbarList4; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IStartMenuPinnedList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICDBurn; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IWizardSite; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IWizardExtension; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IWebWizardExtension; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPublishingWizard; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderViewHost; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExplorerBrowserEvents; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExplorerBrowser; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAccessibleObject; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IResultsFolder; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumObjects; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IOperationsProgressDialog; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IIOCancelInformation; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFileOperation; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectProvider; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INamespaceWalkCB; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INamespaceWalkCB2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INamespaceWalk; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAutoCompleteDropDown; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IBandSite; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICDBurnExt; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IContextMenuSite; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumReadyCallback; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumerableView; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInsertItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMenuBand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFolderBandPriv; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IRegTreeItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IImageRecompress; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDeskBar; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMenuPopup; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFileIsInUse; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationAssociationRegistration; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationAssociationRegistrationUI; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDelegateFolder; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IBrowserFrameOptions; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INewWindowManager; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAttachmentExecute; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellMenuCallback; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellMenu; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellRunDll; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IKnownFolder; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IKnownFolderManager; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ISharingConfigurationManager; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPreviousVersionsInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IRelatedItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IIdentityName; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDelegateItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICurrentItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITransferMediumItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IUseToBrowseItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDisplayItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IViewStateIdentityItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPreviewItem; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDestinationStreamFactory; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INewMenuClient; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInitializeWithBindCtx; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeControl; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeControl2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeControlEvents; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeControlDropHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeAccessible; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeControlCustomDraw; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INameSpaceTreeControlFolderCapabilities; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPreviewHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPreviewHandlerFrame; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ITrayDeskBand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IBandHost; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExplorerPaneVisibility; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IContextMenuCB; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDefaultExtractIconInit; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExplorerCommand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExplorerCommandState; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInitializeCommand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumExplorerCommand; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExplorerCommandProvider; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMarkupCallback; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IControlMarkup; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInitializeNetworkFolder; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IOpenControlPanel; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IComputerInfoChangeNotify; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFileSystemBindData; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFileSystemBindData2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICustomDestinationList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationDestinations; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationDocumentLists; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectWithAppUserModelID; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IObjectWithProgID; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IUpdateIDList; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDesktopGadget; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDesktopWallpaper; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IHomeGroup; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInitializeWithPropertyStore; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IOpenSearchSource; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IShellLibrary; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDefaultFolderMenuInitialize; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationActivationManager; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAssocHandlerInvoker; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAssocHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IEnumAssocHandlers; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDataObjectProvider; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IDataTransferManagerInterop; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFrameworkInputPaneHandler; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IFrameworkInputPane; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAccessibilityDockingServiceCallback; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAccessibilityDockingService; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAppVisibilityEvents; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IAppVisibility; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPackageExecutionStateChangeNotification; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IPackageDebugSettings; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ISuspensionDependencyManager; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExecuteCommandApplicationHostEnvironment; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IExecuteCommandHost; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationDesignModeSettings; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IApplicationDesignModeSettings2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ILaunchTargetMonitor; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ILaunchSourceViewSizePreference; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ILaunchTargetViewSizePreference; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ILaunchSourceAppUserModelId; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IInitializeWithWindow; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IHandlerInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IHandlerActivationHost; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IContactManagerInterop; + +//------------------------------------------------------------------------------------------------- +// wtypes.h +//------------------------------------------------------------------------------------------------- +pub const CLSCTX_INPROC_SERVER: DWORD = 0x1; +pub const CLSCTX_INPROC_HANDLER: DWORD = 0x2; +pub const CLSCTX_LOCAL_SERVER: DWORD = 0x4; +pub const CLSCTX_REMOTE_SERVER: DWORD = 0x10; +pub const CLSCTX_SERVER: DWORD = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | + CLSCTX_REMOTE_SERVER; +pub const CLSCTX_ALL: DWORD = CLSCTX_INPROC_HANDLER | CLSCTX_SERVER; + +pub type VARTYPE = c_ushort; + +//------------------------------------------------------------------------------------------------- +// audiosessiontypes.h +//------------------------------------------------------------------------------------------------- +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum AUDCLNT_SHAREMODE { + AUDCLNT_SHAREMODE_SHARED, + AUDCLNT_SHAREMODE_EXCLUSIVE, +} + +//------------------------------------------------------------------------------------------------- +// strmif.h +//------------------------------------------------------------------------------------------------- +pub type REFERENCE_TIME = LONGLONG; + +//------------------------------------------------------------------------------------------------- +// mmreg.h +//------------------------------------------------------------------------------------------------- +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WAVEFORMATEX { + pub wFormatTag: WORD, + pub nChannels: WORD, + pub nSamplesPerSec: DWORD, + pub nAvgBytesPerSec: DWORD, + pub nBlockAlign: WORD, + pub wBitsPerSample: WORD, + pub cbSize: WORD, +} + +//------------------------------------------------------------------------------------------------- +// propidl.h +//------------------------------------------------------------------------------------------------- +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROPVARIANT { + pub vt: VARTYPE, + pub wReserved1: WORD, + pub wReserved2: WORD, + pub wReserved3: WORD, + pub data: [u8; 16], +} + +//------------------------------------------------------------------------------------------------- +// combaseapi.h +// Base Component Object Model defintions. +//------------------------------------------------------------------------------------------------- +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ServerInformation { + pub dwServerPid: DWORD, + pub dwServerTid: DWORD, + pub ui64ServerAddress: UINT64, +} +pub type PServerInformation = *mut ServerInformation; +DECLARE_HANDLE!(CO_MTA_USAGE_COOKIE, CO_MTA_USAGE_COOKIE__); + +//------------------------------------------------------------------------------------------------- +// playsoundapi.h +// ApiSet Contract for api-ms-win-mm-playsound-l1-1-0 +//------------------------------------------------------------------------------------------------- +pub const SND_SYNC: DWORD = 0x0000; +pub const SND_ASYNC: DWORD = 0x0001; +pub const SND_NODEFAULT: DWORD = 0x0002; +pub const SND_MEMORY: DWORD = 0x0004; +pub const SND_LOOP: DWORD = 0x0008; +pub const SND_NOSTOP: DWORD = 0x0010; +pub const SND_NOWAIT: DWORD = 0x00002000; +pub const SND_ALIAS: DWORD = 0x00010000; +pub const SND_ALIAS_ID: DWORD = 0x00110000; +pub const SND_FILENAME: DWORD = 0x00020000; +pub const SND_RESOURCE: DWORD = 0x00040004; +pub const SND_PURGE: DWORD = 0x0040; +pub const SND_APPLICATION: DWORD = 0x0080; +pub const SND_SENTRY: DWORD = 0x00080000; +pub const SND_RING: DWORD = 0x00100000; +pub const SND_SYSTEM: DWORD = 0x00200000; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROCESS_MEMORY_COUNTERS { + pub cb: DWORD, + pub PageFaultCount: DWORD, + pub PeakWorkingSetSize: SIZE_T, + pub WorkingSetSize: SIZE_T, + pub QuotaPeakPagedPoolUsage: SIZE_T, + pub QuotaPagedPoolUsage: SIZE_T, + pub QuotaPeakNonPagedPoolUsage: SIZE_T, + pub QuotaNonPagedPoolUsage: SIZE_T, + pub PagefileUsage: SIZE_T, + pub PeakPagefileUsage: SIZE_T, +} +pub type PPROCESS_MEMORY_COUNTERS = *mut PROCESS_MEMORY_COUNTERS; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROCESS_MEMORY_COUNTERS_EX { + pub cb: DWORD, + pub PageFaultCount: DWORD, + pub PeakWorkingSetSize: SIZE_T, + pub WorkingSetSize: SIZE_T, + pub QuotaPeakPagedPoolUsage: SIZE_T, + pub QuotaPagedPoolUsage: SIZE_T, + pub QuotaPeakNonPagedPoolUsage: SIZE_T, + pub QuotaNonPagedPoolUsage: SIZE_T, + pub PagefileUsage: SIZE_T, + pub PeakPagefileUsage: SIZE_T, + pub PrivateUsage: SIZE_T, +} + +//------------------------------------------------------------------------------------------------- +// winreg.h +// Registry API procedure declarations, constant definitions and macros +//------------------------------------------------------------------------------------------------- + +pub type REGSAM = ACCESS_MASK; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct VALENTA { + pub ve_valuename: LPSTR, + pub ve_valuelen: DWORD, + pub ve_valueptr: DWORD_PTR, + pub ve_type: DWORD, +} +pub type PVALENTA = *mut VALENTA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct VALENTW { + pub ve_valuename: LPWSTR, + pub ve_valuelen: DWORD, + pub ve_valueptr: DWORD_PTR, + pub ve_type: DWORD, +} +pub type PVALENTW = *mut VALENTW; + +pub const HKEY_CLASSES_ROOT: HKEY = 0x80000000 as HKEY; +pub const HKEY_CURRENT_USER: HKEY = 0x80000001 as HKEY; +pub const HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY; +pub const HKEY_USERS: HKEY = 0x80000003 as HKEY; +pub const HKEY_PERFORMANCE_DATA: HKEY = 0x80000004 as HKEY; +pub const HKEY_PERFORMANCE_TEXT: HKEY = 0x80000050 as HKEY; +pub const HKEY_PERFORMANCE_NLSTEXT: HKEY = 0x80000060 as HKEY; +pub const HKEY_CURRENT_CONFIG: HKEY = 0x80000005 as HKEY; +pub const HKEY_DYN_DATA: HKEY = 0x80000006 as HKEY; +pub const HKEY_CURRENT_USER_LOCAL_SETTINGS: HKEY = 0x80000007 as HKEY; + +pub const REG_MUI_STRING_TRUNCATE: DWORD = 0x00000001; + +pub const RRF_RT_REG_NONE: DWORD = 0x00000001; +pub const RRF_RT_REG_SZ: DWORD = 0x00000002; +pub const RRF_RT_REG_EXPAND_SZ: DWORD = 0x00000004; +pub const RRF_RT_REG_BINARY: DWORD = 0x00000008; +pub const RRF_RT_REG_DWORD: DWORD = 0x00000010; +pub const RRF_RT_REG_MULTI_SZ: DWORD = 0x00000020; +pub const RRF_RT_REG_QWORD: DWORD = 0x00000040; + +pub const RRF_RT_DWORD: DWORD = RRF_RT_REG_BINARY|RRF_RT_REG_DWORD; +pub const RRF_RT_QWORD: DWORD = RRF_RT_REG_BINARY|RRF_RT_REG_QWORD; +pub const RRF_RT_ANY: DWORD = 0x0000ffff; + +pub const RRF_NOEXPAND: DWORD = 0x10000000; +pub const RRF_ZEROONFAILURE: DWORD = 0x20000000; + +//------------------------------------------------------------------------------------------------- +// winuser.h +// USER procedure declarations, constant definitions and macros +//------------------------------------------------------------------------------------------------- +pub const BN_CLICKED: WORD = 0; +pub const BN_PAINT: WORD = 1; +pub const BN_HILITE: WORD = 2; +pub const BN_UNHILITE: WORD = 3; +pub const BN_DISABLE: WORD = 4; +pub const BN_DOUBLECLICKED: WORD = 5; +pub const BN_PUSHED: WORD = BN_HILITE; +pub const BN_UNPUSHED: WORD = BN_UNHILITE; +pub const BN_DBLCLK: WORD = BN_DOUBLECLICKED; +pub const BN_SETFOCUS: WORD = 6; +pub const BN_KILLFOCUS: WORD = 7; + +pub const BS_PUSHBUTTON: DWORD = 0x00000000; +pub const BS_DEFPUSHBUTTON: DWORD = 0x00000001; +pub const BS_CHECKBOX: DWORD = 0x00000002; +pub const BS_AUTOCHECKBOX: DWORD = 0x00000003; +pub const BS_RADIOBUTTON: DWORD = 0x00000004; +pub const BS_3STATE: DWORD = 0x00000005; +pub const BS_AUTO3STATE: DWORD = 0x00000006; +pub const BS_GROUPBOX: DWORD = 0x00000007; +pub const BS_USERBUTTON: DWORD = 0x00000008; +pub const BS_AUTORADIOBUTTON: DWORD = 0x00000009; +pub const BS_PUSHBOX: DWORD = 0x0000000A; +pub const BS_OWNERDRAW: DWORD = 0x0000000B; +pub const BS_TYPEMASK: DWORD = 0x0000000F; +pub const BS_LEFTTEXT: DWORD = 0x00000020; +pub const BS_TEXT: DWORD = 0x00000000; +pub const BS_ICON: DWORD = 0x00000040; +pub const BS_BITMAP: DWORD = 0x00000080; +pub const BS_LEFT: DWORD = 0x00000100; +pub const BS_RIGHT: DWORD = 0x00000200; +pub const BS_CENTER: DWORD = 0x00000300; +pub const BS_TOP: DWORD = 0x00000400; +pub const BS_BOTTOM: DWORD = 0x00000800; +pub const BS_VCENTER: DWORD = 0x00000C00; +pub const BS_PUSHLIKE: DWORD = 0x00001000; +pub const BS_MULTILINE: DWORD = 0x00002000; +pub const BS_NOTIFY: DWORD = 0x00004000; +pub const BS_FLAT: DWORD = 0x00008000; +pub const BS_RIGHTBUTTON: DWORD = BS_LEFTTEXT; + +pub const CCHILDREN_SCROLLBAR: usize = 5; + +pub const CDS_UPDATEREGISTRY: DWORD = 0x00000001; +pub const CDS_TEST: DWORD = 0x00000002; +pub const CDS_FULLSCREEN: DWORD = 0x00000004; +pub const CDS_GLOBAL: DWORD = 0x00000008; +pub const CDS_SET_PRIMARY: DWORD = 0x00000010; +pub const CDS_VIDEOPARAMETERS: DWORD = 0x00000020; +pub const CDS_ENABLE_UNSAFE_MODES: DWORD = 0x00000100; +pub const CDS_DISABLE_UNSAFE_MODES: DWORD = 0x00000200; +pub const CDS_RESET: DWORD = 0x40000000; +pub const CDS_RESET_EX: DWORD = 0x20000000; +pub const CDS_NORESET: DWORD = 0x10000000; + +pub const CS_VREDRAW: DWORD = 0x0001; +pub const CS_HREDRAW: DWORD = 0x0002; +pub const CS_DBLCLKS: DWORD = 0x0008; +pub const CS_OWNDC: DWORD = 0x0020; +pub const CS_CLASSDC: DWORD = 0x0040; +pub const CS_PARENTDC: DWORD = 0x0080; +pub const CS_NOCLOSE: DWORD = 0x0200; +pub const CS_SAVEBITS: DWORD = 0x0800; +pub const CS_BYTEALIGNCLIENT: DWORD = 0x1000; +pub const CS_BYTEALIGNWINDOW: DWORD = 0x2000; +pub const CS_GLOBALCLASS: DWORD = 0x4000; +pub const CS_IME: DWORD = 0x00010000; +pub const CS_DROPSHADOW: DWORD = 0x00020000; + +pub const CW_USEDEFAULT: c_int = 0x80000000u32 as c_int; + +pub const DISP_CHANGE_SUCCESSFUL: LONG = 0; +pub const DISP_CHANGE_RESTART: LONG = 1; +pub const DISP_CHANGE_FAILED: LONG = -1; +pub const DISP_CHANGE_BADMODE: LONG = -2; +pub const DISP_CHANGE_NOTUPDATED: LONG = -3; +pub const DISP_CHANGE_BADFLAGS: LONG = -4; +pub const DISP_CHANGE_BADPARAM: LONG = -5; +pub const DISP_CHANGE_BADDUALVIEW: LONG = -6; + +pub const EDD_GET_DEVICE_INTERFACE_NAME: DWORD = 0x00000001; + +pub const ENUM_CURRENT_SETTINGS: DWORD = 0xFFFFFFFF; +pub const ENUM_REGISTRY_SETTINGS: DWORD = 0xFFFFFFFE; + +pub const GW_HWNDFIRST: UINT = 0; +pub const GW_HWNDLAST: UINT = 1; +pub const GW_HWNDNEXT: UINT = 2; +pub const GW_HWNDPREV: UINT = 3; +pub const GW_OWNER: UINT = 4; +pub const GW_CHILD: UINT = 5; +pub const GW_ENABLEDPOPUP: UINT = 6; +pub const GW_MAX: UINT = 6; + +pub const LSFW_LOCK: UINT = 1; +pub const LSFW_UNLOCK: UINT = 2; + +pub const MDITILE_VERTICAL: UINT = 0x0000; +pub const MDITILE_HORIZONTAL: UINT = 0x0001; +pub const MDITILE_SKIPDISABLED: UINT = 0x0002; +pub const MDITILE_ZORDER: UINT = 0x0004; + +pub const MB_OK: DWORD = 0x00000000; +pub const MB_OKCANCEL: DWORD = 0x00000001; +pub const MB_ABORTRETRYIGNORE: DWORD = 0x00000002; +pub const MB_YESNOCANCEL: DWORD = 0x00000003; +pub const MB_YESNO: DWORD = 0x00000004; +pub const MB_RETRYCANCEL: DWORD = 0x00000005; +pub const MB_CANCELTRYCONTINUE: DWORD = 0x00000006; +pub const MB_ICONHAND: DWORD = 0x00000010; +pub const MB_ICONQUESTION: DWORD = 0x00000020; +pub const MB_ICONEXCLAMATION: DWORD = 0x00000030; +pub const MB_ICONASTERISK: DWORD = 0x00000040; +pub const MB_USERICON: DWORD = 0x00000080; +pub const MB_ICONWARNING: DWORD = MB_ICONEXCLAMATION; +pub const MB_ICONERROR: DWORD = MB_ICONHAND; +pub const MB_ICONINFORMATION: DWORD = MB_ICONASTERISK; +pub const MB_ICONSTOP: DWORD = MB_ICONHAND; +pub const MB_DEFBUTTON1: DWORD = 0x00000000; +pub const MB_DEFBUTTON2: DWORD = 0x00000100; +pub const MB_DEFBUTTON3: DWORD = 0x00000200; +pub const MB_DEFBUTTON4: DWORD = 0x00000300; +pub const MB_APPLMODAL: DWORD = 0x00000000; +pub const MB_SYSTEMMODAL: DWORD = 0x00001000; +pub const MB_TASKMODAL: DWORD = 0x00002000; +pub const MB_HELP: DWORD = 0x00004000; +pub const MB_NOFOCUS: DWORD = 0x00008000; +pub const MB_SETFOREGROUND: DWORD = 0x00010000; +pub const MB_DEFAULT_DESKTOP_ONLY: DWORD = 0x00020000; +pub const MB_TOPMOST: DWORD = 0x00040000; +pub const MB_RIGHT: DWORD = 0x00080000; +pub const MB_RTLREADING: DWORD = 0x00100000; +pub const MB_SERVICE_NOTIFICATION: DWORD = 0x00200000; +pub const MB_SERVICE_NOTIFICATION_NT3X: DWORD = 0x00040000; +pub const MB_TYPEMASK: DWORD = 0x0000000F; +pub const MB_ICONMASK: DWORD = 0x000000F0; +pub const MB_DEFMASK: DWORD = 0x00000F00; +pub const MB_MODEMASK: DWORD = 0x00003000; +pub const MB_MISCMASK: DWORD = 0x0000C000; + +pub const SB_HORZ: c_int = 0; +pub const SB_VERT: c_int = 1; +pub const SB_CTL: c_int = 2; +pub const SB_BOTH: c_int = 3; + +pub const SW_HIDE: c_int = 0; +pub const SW_SHOWNORMAL: c_int = 1; +pub const SW_NORMAL: c_int = 1; +pub const SW_SHOWMINIMIZED: c_int = 2; +pub const SW_SHOWMAXIMIZED: c_int = 3; +pub const SW_MAXIMIZE: c_int = 3; +pub const SW_SHOWNOACTIVATE: c_int = 4; +pub const SW_SHOW: c_int = 5; +pub const SW_MINIMIZE: c_int = 6; +pub const SW_SHOWMINNOACTIVE: c_int = 7; +pub const SW_SHOWNA: c_int = 8; +pub const SW_RESTORE: c_int = 9; +pub const SW_SHOWDEFAULT: c_int = 10; +pub const SW_FORCEMINIMIZE: c_int = 11; +pub const SW_MAX: c_int = 11; + +pub const SWP_NOSIZE: UINT = 0x0001; +pub const SWP_NOMOVE: UINT = 0x0002; +pub const SWP_NOZORDER: UINT = 0x0004; +pub const SWP_NOREDRAW: UINT = 0x0008; +pub const SWP_NOACTIVATE: UINT = 0x0010; +pub const SWP_FRAMECHANGED: UINT = 0x0020; +pub const SWP_SHOWWINDOW: UINT = 0x0040; +pub const SWP_HIDEWINDOW: UINT = 0x0080; +pub const SWP_NOCOPYBITS: UINT = 0x0100; +pub const SWP_NOOWNERZORDER: UINT = 0x0200; +pub const SWP_NOSENDCHANGING: UINT = 0x0400; +pub const SWP_DRAWFRAME: UINT = SWP_FRAMECHANGED; +pub const SWP_NOREPOSITION: UINT = SWP_NOOWNERZORDER; +pub const SWP_DEFERERASE: UINT = 0x2000; +pub const SWP_ASYNCWINDOWPOS: UINT = 0x4000; + +pub const VK_LBUTTON: WPARAM = 0x01; +pub const VK_RBUTTON: WPARAM = 0x02; +pub const VK_CANCEL: WPARAM = 0x03; +pub const VK_MBUTTON: WPARAM = 0x04; +pub const VK_XBUTTON1: WPARAM = 0x05; +pub const VK_XBUTTON2: WPARAM = 0x06; +pub const VK_BACK: WPARAM = 0x08; +pub const VK_TAB: WPARAM = 0x09; +pub const VK_CLEAR: WPARAM = 0x0C; +pub const VK_RETURN: WPARAM = 0x0D; +pub const VK_SHIFT: WPARAM = 0x10; +pub const VK_CONTROL: WPARAM = 0x11; +pub const VK_MENU: WPARAM = 0x12; +pub const VK_PAUSE: WPARAM = 0x13; +pub const VK_CAPITAL: WPARAM = 0x14; +pub const VK_KANA: WPARAM = 0x15; +pub const VK_HANGUEL: WPARAM = 0x15; +pub const VK_HANGUL: WPARAM = 0x15; +pub const VK_JUNJA: WPARAM = 0x17; +pub const VK_FINAL: WPARAM = 0x18; +pub const VK_HANJA: WPARAM = 0x19; +pub const VK_KANJI: WPARAM = 0x19; +pub const VK_ESCAPE: WPARAM = 0x1B; +pub const VK_CONVERT: WPARAM = 0x1C; +pub const VK_NONCONVERT: WPARAM = 0x1D; +pub const VK_ACCEPT: WPARAM = 0x1E; +pub const VK_MODECHANGE: WPARAM = 0x1F; +pub const VK_SPACE: WPARAM = 0x20; +pub const VK_PRIOR: WPARAM = 0x21; +pub const VK_NEXT: WPARAM = 0x22; +pub const VK_END: WPARAM = 0x23; +pub const VK_HOME: WPARAM = 0x24; +pub const VK_LEFT: WPARAM = 0x25; +pub const VK_UP: WPARAM = 0x26; +pub const VK_RIGHT: WPARAM = 0x27; +pub const VK_DOWN: WPARAM = 0x28; +pub const VK_SELECT: WPARAM = 0x29; +pub const VK_PRINT: WPARAM = 0x2A; +pub const VK_EXECUTE: WPARAM = 0x2B; +pub const VK_SNAPSHOT: WPARAM = 0x2C; +pub const VK_INSERT: WPARAM = 0x2D; +pub const VK_DELETE: WPARAM = 0x2E; +pub const VK_HELP: WPARAM = 0x2F; +pub const VK_LWIN: WPARAM = 0x5B; +pub const VK_RWIN: WPARAM = 0x5C; +pub const VK_APPS: WPARAM = 0x5D; +pub const VK_SLEEP: WPARAM = 0x5F; +pub const VK_NUMPAD0: WPARAM = 0x60; +pub const VK_NUMPAD1: WPARAM = 0x61; +pub const VK_NUMPAD2: WPARAM = 0x62; +pub const VK_NUMPAD3: WPARAM = 0x63; +pub const VK_NUMPAD4: WPARAM = 0x64; +pub const VK_NUMPAD5: WPARAM = 0x65; +pub const VK_NUMPAD6: WPARAM = 0x66; +pub const VK_NUMPAD7: WPARAM = 0x67; +pub const VK_NUMPAD8: WPARAM = 0x68; +pub const VK_NUMPAD9: WPARAM = 0x69; +pub const VK_MULTIPLY: WPARAM = 0x6A; +pub const VK_ADD: WPARAM = 0x6B; +pub const VK_SEPARATOR: WPARAM = 0x6C; +pub const VK_SUBTRACT: WPARAM = 0x6D; +pub const VK_DECIMAL: WPARAM = 0x6E; +pub const VK_DIVIDE: WPARAM = 0x6F; +pub const VK_F1: WPARAM = 0x70; +pub const VK_F2: WPARAM = 0x71; +pub const VK_F3: WPARAM = 0x72; +pub const VK_F4: WPARAM = 0x73; +pub const VK_F5: WPARAM = 0x74; +pub const VK_F6: WPARAM = 0x75; +pub const VK_F7: WPARAM = 0x76; +pub const VK_F8: WPARAM = 0x77; +pub const VK_F9: WPARAM = 0x78; +pub const VK_F10: WPARAM = 0x79; +pub const VK_F11: WPARAM = 0x7A; +pub const VK_F12: WPARAM = 0x7B; +pub const VK_F13: WPARAM = 0x7C; +pub const VK_F14: WPARAM = 0x7D; +pub const VK_F15: WPARAM = 0x7E; +pub const VK_F16: WPARAM = 0x7F; +pub const VK_F17: WPARAM = 0x80; +pub const VK_F18: WPARAM = 0x81; +pub const VK_F19: WPARAM = 0x82; +pub const VK_F20: WPARAM = 0x83; +pub const VK_F21: WPARAM = 0x84; +pub const VK_F22: WPARAM = 0x85; +pub const VK_F23: WPARAM = 0x86; +pub const VK_F24: WPARAM = 0x87; +pub const VK_NUMLOCK: WPARAM = 0x90; +pub const VK_SCROLL: WPARAM = 0x91; +pub const VK_OEM_NEC_EQUAL: WPARAM = 0x92; +pub const VK_OEM_FJ_JISHO: WPARAM = 0x92; +pub const VK_OEM_FJ_MASSHOU: WPARAM = 0x93; +pub const VK_OEM_FJ_TOUROKU: WPARAM = 0x94; +pub const VK_OEM_FJ_LOYA: WPARAM = 0x95; +pub const VK_OEM_FJ_ROYA: WPARAM = 0x96; +pub const VK_LSHIFT: WPARAM = 0xA0; +pub const VK_RSHIFT: WPARAM = 0xA1; +pub const VK_LCONTROL: WPARAM = 0xA2; +pub const VK_RCONTROL: WPARAM = 0xA3; +pub const VK_LMENU: WPARAM = 0xA4; +pub const VK_RMENU: WPARAM = 0xA5; +pub const VK_BROWSER_BACK: WPARAM = 0xA6; +pub const VK_BROWSER_FORWARD: WPARAM = 0xA7; +pub const VK_BROWSER_REFRESH: WPARAM = 0xA8; +pub const VK_BROWSER_STOP: WPARAM = 0xA9; +pub const VK_BROWSER_SEARCH: WPARAM = 0xAA; +pub const VK_BROWSER_FAVORITES: WPARAM = 0xAB; +pub const VK_BROWSER_HOME: WPARAM = 0xAC; +pub const VK_VOLUME_MUTE: WPARAM = 0xAD; +pub const VK_VOLUME_DOWN: WPARAM = 0xAE; +pub const VK_VOLUME_UP: WPARAM = 0xAF; +pub const VK_MEDIA_NEXT_TRACK: WPARAM = 0xB0; +pub const VK_MEDIA_PREV_TRACK: WPARAM = 0xB1; +pub const VK_MEDIA_STOP: WPARAM = 0xB2; +pub const VK_MEDIA_PLAY_PAUSE: WPARAM = 0xB3; +pub const VK_LAUNCH_MAIL: WPARAM = 0xB4; +pub const VK_LAUNCH_MEDIA_SELECT: WPARAM = 0xB5; +pub const VK_LAUNCH_APP1: WPARAM = 0xB6; +pub const VK_LAUNCH_APP2: WPARAM = 0xB7; +pub const VK_OEM_1: WPARAM = 0xBA; +pub const VK_OEM_PLUS: WPARAM = 0xBB; +pub const VK_OEM_COMMA: WPARAM = 0xBC; +pub const VK_OEM_MINUS: WPARAM = 0xBD; +pub const VK_OEM_PERIOD: WPARAM = 0xBE; +pub const VK_OEM_2: WPARAM = 0xBF; +pub const VK_OEM_3: WPARAM = 0xC0; +pub const VK_OEM_4: WPARAM = 0xDB; +pub const VK_OEM_5: WPARAM = 0xDC; +pub const VK_OEM_6: WPARAM = 0xDD; +pub const VK_OEM_7: WPARAM = 0xDE; +pub const VK_OEM_8: WPARAM = 0xDF; +pub const VK_OEM_AX: WPARAM = 0xE1; +pub const VK_OEM_102: WPARAM = 0xE2; +pub const VK_ICO_HELP: WPARAM = 0xE3; +pub const VK_ICO_00: WPARAM = 0xE4; +pub const VK_PROCESSKEY: WPARAM = 0xE5; +pub const VK_ICO_CLEAR: WPARAM = 0xE6; +pub const VK_PACKET: WPARAM = 0xE7; +pub const VK_OEM_RESET: WPARAM = 0xE9; +pub const VK_OEM_JUMP: WPARAM = 0xEA; +pub const VK_OEM_PA1: WPARAM = 0xEB; +pub const VK_OEM_PA2: WPARAM = 0xEC; +pub const VK_OEM_PA3: WPARAM = 0xED; +pub const VK_OEM_WSCTRL: WPARAM = 0xEE; +pub const VK_OEM_CUSEL: WPARAM = 0xEF; +pub const VK_OEM_ATTN: WPARAM = 0xF0; +pub const VK_OEM_FINISH: WPARAM = 0xF1; +pub const VK_OEM_COPY: WPARAM = 0xF2; +pub const VK_OEM_AUTO: WPARAM = 0xF3; +pub const VK_OEM_ENLW: WPARAM = 0xF4; +pub const VK_OEM_BACKTAB: WPARAM = 0xF5; +pub const VK_ATTN: WPARAM = 0xF6; +pub const VK_CRSEL: WPARAM = 0xF7; +pub const VK_EXSEL: WPARAM = 0xF8; +pub const VK_EREOF: WPARAM = 0xF9; +pub const VK_PLAY: WPARAM = 0xFA; +pub const VK_ZOOM: WPARAM = 0xFB; +pub const VK_NONAME: WPARAM = 0xFC; +pub const VK_PA1: WPARAM = 0xFD; +pub const VK_OEM_CLEAR: WPARAM = 0xFE; + +pub const WM_NULL: UINT = 0x0000; +pub const WM_CREATE: UINT = 0x0001; +pub const WM_DESTROY: UINT = 0x0002; +pub const WM_MOVE: UINT = 0x0003; +pub const WM_SIZE: UINT = 0x0005; +pub const WM_ACTIVATE: UINT = 0x0006; +pub const WM_SETFOCUS: UINT = 0x0007; +pub const WM_KILLFOCUS: UINT = 0x0008; +pub const WM_ENABLE: UINT = 0x000A; +pub const WM_SETREDRAW: UINT = 0x000B; +pub const WM_SETTEXT: UINT = 0x000C; +pub const WM_GETTEXT: UINT = 0x000D; +pub const WM_GETTEXTLENGTH: UINT = 0x000E; +pub const WM_PAINT: UINT = 0x000F; +pub const WM_CLOSE: UINT = 0x0010; +pub const WM_QUERYENDSESSION: UINT = 0x0011; +pub const WM_QUERYOPEN: UINT = 0x0013; +pub const WM_ENDSESSION: UINT = 0x0016; +pub const WM_QUIT: UINT = 0x0012; +pub const WM_ERASEBKGND: UINT = 0x0014; +pub const WM_SYSCOLORCHANGE: UINT = 0x0015; +pub const WM_SHOWWINDOW: UINT = 0x0018; +pub const WM_WININICHANGE: UINT = 0x001A; +pub const WM_SETTINGCHANGE: UINT = WM_WININICHANGE; +pub const WM_DEVMODECHANGE: UINT = 0x001B; +pub const WM_ACTIVATEAPP: UINT = 0x001C; +pub const WM_FONTCHANGE: UINT = 0x001D; +pub const WM_TIMECHANGE: UINT = 0x001E; +pub const WM_CANCELMODE: UINT = 0x001F; +pub const WM_SETCURSOR: UINT = 0x0020; +pub const WM_MOUSEACTIVATE: UINT = 0x0021; +pub const WM_CHILDACTIVATE: UINT = 0x0022; +pub const WM_QUEUESYNC: UINT = 0x0023; +pub const WM_GETMINMAXINFO: UINT = 0x0024; +pub const WM_PAINTICON: UINT = 0x0026; +pub const WM_ICONERASEBKGND: UINT = 0x0027; +pub const WM_NEXTDLGCTL: UINT = 0x0028; +pub const WM_SPOOLERSTATUS: UINT = 0x002A; +pub const WM_DRAWITEM: UINT = 0x002B; +pub const WM_MEASUREITEM: UINT = 0x002C; +pub const WM_DELETEITEM: UINT = 0x002D; +pub const WM_VKEYTOITEM: UINT = 0x002E; +pub const WM_CHARTOITEM: UINT = 0x002F; +pub const WM_SETFONT: UINT = 0x0030; +pub const WM_GETFONT: UINT = 0x0031; +pub const WM_SETHOTKEY: UINT = 0x0032; +pub const WM_GETHOTKEY: UINT = 0x0033; +pub const WM_QUERYDRAGICON: UINT = 0x0037; +pub const WM_COMPAREITEM: UINT = 0x0039; +pub const WM_GETOBJECT: UINT = 0x003D; +pub const WM_COMPACTING: UINT = 0x0041; +pub const WM_COMMNOTIFY: UINT = 0x0044; +pub const WM_WINDOWPOSCHANGING: UINT = 0x0046; +pub const WM_WINDOWPOSCHANGED: UINT = 0x0047; +pub const WM_POWER: UINT = 0x0048; +pub const WM_COPYDATA: UINT = 0x004A; +pub const WM_CANCELJOURNAL: UINT = 0x004B; +pub const WM_NOTIFY: UINT = 0x004E; +pub const WM_INPUTLANGCHANGEREQUEST: UINT = 0x0050; +pub const WM_INPUTLANGCHANGE: UINT = 0x0051; +pub const WM_TCARD: UINT = 0x0052; +pub const WM_HELP: UINT = 0x0053; +pub const WM_USERCHANGED: UINT = 0x0054; +pub const WM_NOTIFYFORMAT: UINT = 0x0055; +pub const WM_CONTEXTMENU: UINT = 0x007B; +pub const WM_STYLECHANGING: UINT = 0x007C; +pub const WM_STYLECHANGED: UINT = 0x007D; +pub const WM_DISPLAYCHANGE: UINT = 0x007E; +pub const WM_GETICON: UINT = 0x007F; +pub const WM_SETICON: UINT = 0x0080; +pub const WM_NCCREATE: UINT = 0x0081; +pub const WM_NCDESTROY: UINT = 0x0082; +pub const WM_NCCALCSIZE: UINT = 0x0083; +pub const WM_NCHITTEST: UINT = 0x0084; +pub const WM_NCPAINT: UINT = 0x0085; +pub const WM_NCACTIVATE: UINT = 0x0086; +pub const WM_GETDLGCODE: UINT = 0x0087; +pub const WM_SYNCPAINT: UINT = 0x0088; +pub const WM_NCMOUSEMOVE: UINT = 0x00A0; +pub const WM_NCLBUTTONDOWN: UINT = 0x00A1; +pub const WM_NCLBUTTONUP: UINT = 0x00A2; +pub const WM_NCLBUTTONDBLCLK: UINT = 0x00A3; +pub const WM_NCRBUTTONDOWN: UINT = 0x00A4; +pub const WM_NCRBUTTONUP: UINT = 0x00A5; +pub const WM_NCRBUTTONDBLCLK: UINT = 0x00A6; +pub const WM_NCMBUTTONDOWN: UINT = 0x00A7; +pub const WM_NCMBUTTONUP: UINT = 0x00A8; +pub const WM_NCMBUTTONDBLCLK: UINT = 0x00A9; +pub const WM_NCXBUTTONDOWN: UINT = 0x00AB; +pub const WM_NCXBUTTONUP: UINT = 0x00AC; +pub const WM_NCXBUTTONDBLCLK: UINT = 0x00AD; +pub const WM_INPUT_DEVICE_CHANGE: UINT = 0x00FE; +pub const WM_INPUT: UINT = 0x00FF; +pub const WM_KEYFIRST: UINT = 0x0100; +pub const WM_KEYDOWN: UINT = 0x0100; +pub const WM_KEYUP: UINT = 0x0101; +pub const WM_CHAR: UINT = 0x0102; +pub const WM_DEADCHAR: UINT = 0x0103; +pub const WM_SYSKEYDOWN: UINT = 0x0104; +pub const WM_SYSKEYUP: UINT = 0x0105; +pub const WM_SYSCHAR: UINT = 0x0106; +pub const WM_SYSDEADCHAR: UINT = 0x0107; +pub const WM_UNICHAR: UINT = 0x0109; +pub const WM_KEYLAST: UINT = 0x0109; +pub const WM_IME_STARTCOMPOSITION: UINT = 0x010D; +pub const WM_IME_ENDCOMPOSITION: UINT = 0x010E; +pub const WM_IME_COMPOSITION: UINT = 0x010F; +pub const WM_IME_KEYLAST: UINT = 0x010F; +pub const WM_INITDIALOG: UINT = 0x0110; +pub const WM_COMMAND: UINT = 0x0111; +pub const WM_SYSCOMMAND: UINT = 0x0112; +pub const WM_TIMER: UINT = 0x0113; +pub const WM_HSCROLL: UINT = 0x0114; +pub const WM_VSCROLL: UINT = 0x0115; +pub const WM_INITMENU: UINT = 0x0116; +pub const WM_INITMENUPOPUP: UINT = 0x0117; +pub const WM_GESTURE: UINT = 0x0119; +pub const WM_GESTURENOTIFY: UINT = 0x011A; +pub const WM_MENUSELECT: UINT = 0x011F; +pub const WM_MENUCHAR: UINT = 0x0120; +pub const WM_ENTERIDLE: UINT = 0x0121; +pub const WM_MENURBUTTONUP: UINT = 0x0122; +pub const WM_MENUDRAG: UINT = 0x0123; +pub const WM_MENUGETOBJECT: UINT = 0x0124; +pub const WM_UNINITMENUPOPUP: UINT = 0x0125; +pub const WM_MENUCOMMAND: UINT = 0x0126; +pub const WM_CHANGEUISTATE: UINT = 0x0127; +pub const WM_UPDATEUISTATE: UINT = 0x0128; +pub const WM_QUERYUISTATE: UINT = 0x0129; +pub const WM_CTLCOLORMSGBOX: UINT = 0x0132; +pub const WM_CTLCOLOREDIT: UINT = 0x0133; +pub const WM_CTLCOLORLISTBOX: UINT = 0x0134; +pub const WM_CTLCOLORBTN: UINT = 0x0135; +pub const WM_CTLCOLORDLG: UINT = 0x0136; +pub const WM_CTLCOLORSCROLLBAR: UINT = 0x0137; +pub const WM_CTLCOLORSTATIC: UINT = 0x0138; +pub const WM_MOUSEFIRST: UINT = 0x0200; +pub const WM_MOUSEMOVE: UINT = 0x0200; +pub const WM_LBUTTONDOWN: UINT = 0x0201; +pub const WM_LBUTTONUP: UINT = 0x0202; +pub const WM_LBUTTONDBLCLK: UINT = 0x0203; +pub const WM_RBUTTONDOWN: UINT = 0x0204; +pub const WM_RBUTTONUP: UINT = 0x0205; +pub const WM_RBUTTONDBLCLK: UINT = 0x0206; +pub const WM_MBUTTONDOWN: UINT = 0x0207; +pub const WM_MBUTTONUP: UINT = 0x0208; +pub const WM_MBUTTONDBLCLK: UINT = 0x0209; +pub const WM_MOUSEWHEEL: UINT = 0x020A; +pub const WM_XBUTTONDOWN: UINT = 0x020B; +pub const WM_XBUTTONUP: UINT = 0x020C; +pub const WM_XBUTTONDBLCLK: UINT = 0x020D; +pub const WM_MOUSEHWHEEL: UINT = 0x020E; +pub const WM_MOUSELAST: UINT = 0x020E; +pub const WM_PARENTNOTIFY: UINT = 0x0210; +pub const WM_ENTERMENULOOP: UINT = 0x0211; +pub const WM_EXITMENULOOP: UINT = 0x0212; +pub const WM_NEXTMENU: UINT = 0x0213; +pub const WM_SIZING: UINT = 0x0214; +pub const WM_CAPTURECHANGED: UINT = 0x0215; +pub const WM_MOVING: UINT = 0x0216; +pub const WM_POWERBROADCAST: UINT = 0x0218; +pub const WM_DEVICECHANGE: UINT = 0x0219; +pub const WM_MDICREATE: UINT = 0x0220; +pub const WM_MDIDESTROY: UINT = 0x0221; +pub const WM_MDIACTIVATE: UINT = 0x0222; +pub const WM_MDIRESTORE: UINT = 0x0223; +pub const WM_MDINEXT: UINT = 0x0224; +pub const WM_MDIMAXIMIZE: UINT = 0x0225; +pub const WM_MDITILE: UINT = 0x0226; +pub const WM_MDICASCADE: UINT = 0x0227; +pub const WM_MDIICONARRANGE: UINT = 0x0228; +pub const WM_MDIGETACTIVE: UINT = 0x0229; +pub const WM_MDISETMENU: UINT = 0x0230; +pub const WM_ENTERSIZEMOVE: UINT = 0x0231; +pub const WM_EXITSIZEMOVE: UINT = 0x0232; +pub const WM_DROPFILES: UINT = 0x0233; +pub const WM_MDIREFRESHMENU: UINT = 0x0234; +pub const WM_POINTERDEVICECHANGE: UINT = 0x238; +pub const WM_POINTERDEVICEINRANGE: UINT = 0x239; +pub const WM_POINTERDEVICEOUTOFRANGE: UINT = 0x23A; +pub const WM_TOUCH: UINT = 0x0240; +pub const WM_NCPOINTERUPDATE: UINT = 0x0241; +pub const WM_NCPOINTERDOWN: UINT = 0x0242; +pub const WM_NCPOINTERUP: UINT = 0x0243; +pub const WM_POINTERUPDATE: UINT = 0x0245; +pub const WM_POINTERDOWN: UINT = 0x0246; +pub const WM_POINTERUP: UINT = 0x0247; +pub const WM_POINTERENTER: UINT = 0x0249; +pub const WM_POINTERLEAVE: UINT = 0x024A; +pub const WM_POINTERACTIVATE: UINT = 0x024B; +pub const WM_POINTERCAPTURECHANGED: UINT = 0x024C; +pub const WM_TOUCHHITTESTING: UINT = 0x024D; +pub const WM_POINTERWHEEL: UINT = 0x024E; +pub const WM_POINTERHWHEEL: UINT = 0x024F; +pub const WM_IME_SETCONTEXT: UINT = 0x0281; +pub const WM_IME_NOTIFY: UINT = 0x0282; +pub const WM_IME_CONTROL: UINT = 0x0283; +pub const WM_IME_COMPOSITIONFULL: UINT = 0x0284; +pub const WM_IME_SELECT: UINT = 0x0285; +pub const WM_IME_CHAR: UINT = 0x0286; +pub const WM_IME_REQUEST: UINT = 0x0288; +pub const WM_IME_KEYDOWN: UINT = 0x0290; +pub const WM_IME_KEYUP: UINT = 0x0291; +pub const WM_MOUSEHOVER: UINT = 0x02A1; +pub const WM_MOUSELEAVE: UINT = 0x02A3; +pub const WM_NCMOUSEHOVER: UINT = 0x02A0; +pub const WM_NCMOUSELEAVE: UINT = 0x02A2; +pub const WM_WTSSESSION_CHANGE: UINT = 0x02B1; +pub const WM_TABLET_FIRST: UINT = 0x02c0; +pub const WM_TABLET_LAST: UINT = 0x02df; +pub const WM_DPICHANGED: UINT = 0x02E0; +pub const WM_CUT: UINT = 0x0300; +pub const WM_COPY: UINT = 0x0301; +pub const WM_PASTE: UINT = 0x0302; +pub const WM_CLEAR: UINT = 0x0303; +pub const WM_UNDO: UINT = 0x0304; +pub const WM_RENDERFORMAT: UINT = 0x0305; +pub const WM_RENDERALLFORMATS: UINT = 0x0306; +pub const WM_DESTROYCLIPBOARD: UINT = 0x0307; +pub const WM_DRAWCLIPBOARD: UINT = 0x0308; +pub const WM_PAINTCLIPBOARD: UINT = 0x0309; +pub const WM_VSCROLLCLIPBOARD: UINT = 0x030A; +pub const WM_SIZECLIPBOARD: UINT = 0x030B; +pub const WM_ASKCBFORMATNAME: UINT = 0x030C; +pub const WM_CHANGECBCHAIN: UINT = 0x030D; +pub const WM_HSCROLLCLIPBOARD: UINT = 0x030E; +pub const WM_QUERYNEWPALETTE: UINT = 0x030F; +pub const WM_PALETTEISCHANGING: UINT = 0x0310; +pub const WM_PALETTECHANGED: UINT = 0x0311; +pub const WM_HOTKEY: UINT = 0x0312; +pub const WM_PRINT: UINT = 0x0317; +pub const WM_PRINTCLIENT: UINT = 0x0318; +pub const WM_APPCOMMAND: UINT = 0x0319; +pub const WM_THEMECHANGED: UINT = 0x031A; +pub const WM_CLIPBOARDUPDATE: UINT = 0x031D; +pub const WM_DWMCOMPOSITIONCHANGED: UINT = 0x031E; +pub const WM_DWMNCRENDERINGCHANGED: UINT = 0x031F; +pub const WM_DWMCOLORIZATIONCOLORCHANGED: UINT = 0x0320; +pub const WM_DWMWINDOWMAXIMIZEDCHANGE: UINT = 0x0321; +pub const WM_DWMSENDICONICTHUMBNAIL: UINT = 0x0323; +pub const WM_DWMSENDICONICLIVEPREVIEWBITMAP: UINT = 0x0326; +pub const WM_GETTITLEBARINFOEX: UINT = 0x033F; +pub const WM_HANDHELDFIRST: UINT = 0x0358; +pub const WM_HANDHELDLAST: UINT = 0x035F; +pub const WM_AFXFIRST: UINT = 0x0360; +pub const WM_AFXLAST: UINT = 0x037F; +pub const WM_PENWINFIRST: UINT = 0x0380; +pub const WM_PENWINLAST: UINT = 0x038F; +pub const WM_APP: UINT = 0x8000; +pub const WM_USER: UINT = 0x0400; + +pub const WS_OVERLAPPED: DWORD = 0x00000000; +pub const WS_POPUP: DWORD = 0x80000000; +pub const WS_CHILD: DWORD = 0x40000000; +pub const WS_MINIMIZE: DWORD = 0x20000000; +pub const WS_VISIBLE: DWORD = 0x10000000; +pub const WS_DISABLED: DWORD = 0x08000000; +pub const WS_CLIPSIBLINGS: DWORD = 0x04000000; +pub const WS_CLIPCHILDREN: DWORD = 0x02000000; +pub const WS_MAXIMIZE: DWORD = 0x01000000; +pub const WS_CAPTION: DWORD = 0x00C00000; +pub const WS_BORDER: DWORD = 0x00800000; +pub const WS_DLGFRAME: DWORD = 0x00400000; +pub const WS_VSCROLL: DWORD = 0x00200000; +pub const WS_HSCROLL: DWORD = 0x00100000; +pub const WS_SYSMENU: DWORD = 0x00080000; +pub const WS_THICKFRAME: DWORD = 0x00040000; +pub const WS_GROUP: DWORD = 0x00020000; +pub const WS_TABSTOP: DWORD = 0x00010000; +pub const WS_MINIMIZEBOX: DWORD = 0x00020000; +pub const WS_MAXIMIZEBOX: DWORD = 0x00010000; +pub const WS_TILED: DWORD = WS_OVERLAPPED; +pub const WS_ICONIC: DWORD = WS_MINIMIZE; +pub const WS_SIZEBOX: DWORD = WS_THICKFRAME; +pub const WS_TILEDWINDOW: DWORD = WS_OVERLAPPEDWINDOW; +pub const WS_OVERLAPPEDWINDOW: DWORD = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; +pub const WS_POPUPWINDOW: DWORD = WS_POPUP | WS_BORDER | WS_SYSMENU; +pub const WS_CHILDWINDOW: DWORD = WS_CHILD; + +pub const WS_EX_DLGMODALFRAME: DWORD = 0x00000001; +pub const WS_EX_NOPARENTNOTIFY: DWORD = 0x00000004; +pub const WS_EX_TOPMOST: DWORD = 0x00000008; +pub const WS_EX_ACCEPTFILES: DWORD = 0x00000010; +pub const WS_EX_TRANSPARENT: DWORD = 0x00000020; +pub const WS_EX_MDICHILD: DWORD = 0x00000040; +pub const WS_EX_TOOLWINDOW: DWORD = 0x00000080; +pub const WS_EX_WINDOWEDGE: DWORD = 0x00000100; +pub const WS_EX_CLIENTEDGE: DWORD = 0x00000200; +pub const WS_EX_CONTEXTHELP: DWORD = 0x00000400; +pub const WS_EX_RIGHT: DWORD = 0x00001000; +pub const WS_EX_LEFT: DWORD = 0x00000000; +pub const WS_EX_RTLREADING: DWORD = 0x00002000; +pub const WS_EX_LTRREADING: DWORD = 0x00000000; +pub const WS_EX_LEFTSCROLLBAR: DWORD = 0x00004000; +pub const WS_EX_RIGHTSCROLLBAR: DWORD = 0x00000000; +pub const WS_EX_CONTROLPARENT: DWORD = 0x00010000; +pub const WS_EX_STATICEDGE: DWORD = 0x00020000; +pub const WS_EX_APPWINDOW: DWORD = 0x00040000; +pub const WS_EX_OVERLAPPEDWINDOW: DWORD = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE; +pub const WS_EX_PALETTEWINDOW: DWORD = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST; +pub const WS_EX_LAYERED: DWORD = 0x00080000; +pub const WS_EX_NOINHERITLAYOUT: DWORD = 0x00100000; +pub const WS_EX_NOREDIRECTIONBITMAP: DWORD = 0x00200000; +pub const WS_EX_LAYOUTRTL: DWORD = 0x00400000; +pub const WS_EX_COMPOSITED: DWORD = 0x02000000; +pub const WS_EX_NOACTIVATE: DWORD = 0x08000000; +pub type DESKTOPENUMPROCA = Option<unsafe extern "system" fn(LPSTR, LPARAM) -> BOOL>; +pub type DESKTOPENUMPROCW = Option<unsafe extern "system" fn(LPWSTR, LPARAM) -> BOOL>; +pub type NAMEENUMPROCA = DESKTOPENUMPROCA; +pub type NAMEENUMPROCW = DESKTOPENUMPROCW; +pub type WNDENUMPROC = Option<unsafe extern "system" fn(HWND, LPARAM) -> BOOL>; +pub type WNDPROC = Option<unsafe extern "system" fn(HWND, UINT, WPARAM, LPARAM) -> LRESULT>; +pub type HOOKPROC = Option<unsafe extern "system" fn( + code: c_int, wParam: WPARAM, lParam: LPARAM, +) -> LRESULT>; +pub type TimerProc = Option<unsafe extern "system" fn( + hwnd: HWND, uMsg: UINT, idEvent: UINT_PTR, dwTime: DWORD, +)>; + +pub type HDEVNOTIFY = PVOID; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MSG { + pub hwnd: HWND, + pub message: UINT, + pub wParam: WPARAM, + pub lParam: LPARAM, + pub time: DWORD, + pub pt: POINT, +} +pub type PMSG = *mut MSG; +pub type NPMSG = *mut MSG; +pub type LPMSG = *mut MSG; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PAINTSTRUCT { + pub hdc: HDC, + pub fErase: BOOL, + pub rcPaint: RECT, + pub fRestore: BOOL, + pub fIncUpdate: BOOL, + pub rgbReserved: [BYTE; 32], +} +pub type PPAINTSTRUCT = *mut PAINTSTRUCT; +pub type NPPAINTSTRUCT = *mut PAINTSTRUCT; +pub type LPPAINTSTRUCT = *mut PAINTSTRUCT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WINDOWPLACEMENT { + pub length: UINT, + pub flags: UINT, + pub showCmd: UINT, + pub ptMinPosition: POINT, + pub ptMaxPosition: POINT, + pub rcNormalPosition: RECT, +} +pub type PWINDOWPLACEMENT = *mut WINDOWPLACEMENT; +pub type LPWINDOWPLACEMENT = *mut WINDOWPLACEMENT; +#[repr(C)] #[derive(Copy)] +pub struct WNDCLASSEXW { + pub cbSize: UINT, + pub style: UINT, + pub lpfnWndProc: WNDPROC, + pub cbClsExtra: c_int, + pub cbWndExtra: c_int, + pub hInstance: HINSTANCE, + pub hIcon: HICON, + pub hCursor: HCURSOR, + pub hbrBackground: HBRUSH, + pub lpszMenuName: LPCWSTR, + pub lpszClassName: LPCWSTR, + pub hIconSm: HICON, +} +impl Clone for WNDCLASSEXW { fn clone(&self) -> WNDCLASSEXW { *self } } +pub type PWNDCLASSEXW = *mut WNDCLASSEXW; +pub type NPWNDCLASSEXW = *mut WNDCLASSEXW; +pub type LPWNDCLASSEXW = *mut WNDCLASSEXW; +#[repr(C)] #[derive(Copy)] +pub struct WNDCLASSW { + pub style: UINT, + pub lpfnWndProc: WNDPROC, + pub cbClsExtra: c_int, + pub cbWndExtra: c_int, + pub hInstance: HINSTANCE, + pub hIcon: HICON, + pub hCursor: HCURSOR, + pub hbrBackground: HBRUSH, + pub lpszMenuName: LPCWSTR, + pub lpszClassName: LPCWSTR +} +impl Clone for WNDCLASSW { fn clone(&self) -> WNDCLASSW { *self } } +pub type PWNDCLASSW = *mut WNDCLASSW; +pub type NPWNDCLASSW = *mut WNDCLASSW; +pub type LPWNDCLASSW = *mut WNDCLASSW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCROLLBARINFO { + pub cbSize: DWORD, + pub rcScrollBar: RECT, + pub dxyLineButton: c_int, + pub xyThumbTop: c_int, + pub xyThumbBottom: c_int, + pub reserved: c_int, + pub rgstate: [DWORD; CCHILDREN_SCROLLBAR + 1] +} +pub type PSCROLLBARINFO = *mut SCROLLBARINFO; +pub type LPSCROLLBARINFO = *mut SCROLLBARINFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCROLLINFO { + pub cbSize: UINT, + pub fMask: UINT, + pub nMin: c_int, + pub nMax: c_int, + pub nPage: UINT, + pub nPos: c_int, + pub nTrackPos: c_int +} +pub type LPSCROLLINFO = *mut SCROLLINFO; +pub type LPCSCROLLINFO = *const SCROLLINFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SIZE { + pub cx: LONG, + pub cy: LONG +} +pub type PSIZE = *mut SIZE; + +//------------------------------------------------------------------------------------------------- +// wingdi.h +// GDI procedure declarations, constant definitions and macros +//------------------------------------------------------------------------------------------------- +pub const DISPLAY_DEVICE_ATTACHED_TO_DESKTOP: DWORD = 0x00000001; +pub const DISPLAY_DEVICE_MULTI_DRIVER: DWORD = 0x00000002; +pub const DISPLAY_DEVICE_PRIMARY_DEVICE: DWORD = 0x00000004; +pub const DISPLAY_DEVICE_MIRRORING_DRIVER: DWORD = 0x00000008; +pub const DISPLAY_DEVICE_VGA_COMPATIBLE: DWORD = 0x00000010; +pub const DISPLAY_DEVICE_REMOVABLE: DWORD = 0x00000020; +pub const DISPLAY_DEVICE_ACC_DRIVER: DWORD = 0x00000040; +pub const DISPLAY_DEVICE_MODESPRUNED: DWORD = 0x08000000; +pub const DISPLAY_DEVICE_REMOTE: DWORD = 0x04000000; +pub const DISPLAY_DEVICE_DISCONNECT: DWORD = 0x02000000; +pub const DISPLAY_DEVICE_TS_COMPATIBLE: DWORD = 0x00200000; +pub const DISPLAY_DEVICE_UNSAFE_MODES_ON: DWORD = 0x00080000; +pub const DISPLAY_DEVICE_ACTIVE: DWORD = 0x00000001; +pub const DISPLAY_DEVICE_ATTACHED: DWORD = 0x00000002; + +pub const DM_ORIENTATION: DWORD = 0x00000001; +pub const DM_PAPERSIZE: DWORD = 0x00000002; +pub const DM_PAPERLENGTH: DWORD = 0x00000004; +pub const DM_PAPERWIDTH: DWORD = 0x00000008; +pub const DM_SCALE: DWORD = 0x00000010; +pub const DM_POSITION: DWORD = 0x00000020; +pub const DM_NUP: DWORD = 0x00000040; +pub const DM_DISPLAYORIENTATION: DWORD = 0x00000080; +pub const DM_COPIES: DWORD = 0x00000100; +pub const DM_DEFAULTSOURCE: DWORD = 0x00000200; +pub const DM_PRINTQUALITY: DWORD = 0x00000400; +pub const DM_COLOR: DWORD = 0x00000800; +pub const DM_DUPLEX: DWORD = 0x00001000; +pub const DM_YRESOLUTION: DWORD = 0x00002000; +pub const DM_TTOPTION: DWORD = 0x00004000; +pub const DM_COLLATE: DWORD = 0x00008000; +pub const DM_FORMNAME: DWORD = 0x00010000; +pub const DM_LOGPIXELS: DWORD = 0x00020000; +pub const DM_BITSPERPEL: DWORD = 0x00040000; +pub const DM_PELSWIDTH: DWORD = 0x00080000; +pub const DM_PELSHEIGHT: DWORD = 0x00100000; +pub const DM_DISPLAYFLAGS: DWORD = 0x00200000; +pub const DM_DISPLAYFREQUENCY: DWORD = 0x00400000; +pub const DM_ICMMETHOD: DWORD = 0x00800000; +pub const DM_ICMINTENT: DWORD = 0x01000000; +pub const DM_MEDIATYPE: DWORD = 0x02000000; +pub const DM_DITHERTYPE: DWORD = 0x04000000; +pub const DM_PANNINGWIDTH: DWORD = 0x08000000; +pub const DM_PANNINGHEIGHT: DWORD = 0x10000000; +pub const DM_DISPLAYFIXEDOUTPUT: DWORD = 0x20000000; + +pub const PFD_TYPE_RGBA: BYTE = 0; +pub const PFD_TYPE_COLORINDEX: BYTE = 1; +pub const PFD_MAIN_PLANE: BYTE = 0; +pub const PFD_OVERLAY_PLANE: BYTE = 1; +pub const PFD_UNDERLAY_PLANE: BYTE = 0xFF; +pub const PFD_DOUBLEBUFFER: DWORD = 0x00000001; +pub const PFD_STEREO: DWORD = 0x00000002; +pub const PFD_DRAW_TO_WINDOW: DWORD = 0x00000004; +pub const PFD_DRAW_TO_BITMAP: DWORD = 0x00000008; +pub const PFD_SUPPORT_GDI: DWORD = 0x00000010; +pub const PFD_SUPPORT_OPENGL: DWORD = 0x00000020; +pub const PFD_GENERIC_FORMAT: DWORD = 0x00000040; +pub const PFD_NEED_PALETTE: DWORD = 0x00000080; +pub const PFD_NEED_SYSTEM_PALETTE: DWORD = 0x00000100; +pub const PFD_SWAP_EXCHANGE: DWORD = 0x00000200; +pub const PFD_SWAP_COPY: DWORD = 0x00000400; +pub const PFD_SWAP_LAYER_BUFFERS: DWORD = 0x00000800; +pub const PFD_GENERIC_ACCELERATED: DWORD = 0x00001000; +pub const PFD_SUPPORT_DIRECTDRAW: DWORD = 0x00002000; +pub const PFD_DIRECT3D_ACCELERATED: DWORD = 0x00004000; +pub const PFD_SUPPORT_COMPOSITION: DWORD = 0x00008000; +pub const PFD_DEPTH_DONTCARE: DWORD = 0x20000000; +pub const PFD_DOUBLEBUFFER_DONTCARE: DWORD = 0x40000000; +pub const PFD_STEREO_DONTCARE: DWORD = 0x80000000; + +pub const CCHFORMNAME: usize = 32; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DEVMODEA { + pub dmDeviceName: [CHAR; CCHDEVICENAME], + pub dmSpecVersion: WORD, + pub dmDriverVersion: WORD, + pub dmSize: WORD, + pub dmDriverExtra: WORD, + pub dmFields: DWORD, + pub union1: [u8; 16], + pub dmColor: c_short, + pub dmDuplex: c_short, + pub dmYResolution: c_short, + pub dmTTOption: c_short, + pub dmCollate: c_short, + pub dmFormName: [CHAR; CCHFORMNAME], + pub dmLogPixels: WORD, + pub dmBitsPerPel: DWORD, + pub dmPelsWidth: DWORD, + pub dmPelsHeight: DWORD, + pub dmDisplayFlags: DWORD, + pub dmDisplayFrequency: DWORD, + pub dmICMMethod: DWORD, + pub dmICMIntent: DWORD, + pub dmMediaType: DWORD, + pub dmDitherType: DWORD, + pub dmReserved1: DWORD, + pub dmReserved2: DWORD, + pub dmPanningWidth: DWORD, + pub dmPanningHeight: DWORD, +} +pub type PDEVMODEA = *mut DEVMODEA; +pub type NPDEVMODEA = *mut DEVMODEA; +pub type LPDEVMODEA = *mut DEVMODEA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DEVMODEW { + pub dmDeviceName: [WCHAR; CCHDEVICENAME], + pub dmSpecVersion: WORD, + pub dmDriverVersion: WORD, + pub dmSize: WORD, + pub dmDriverExtra: WORD, + pub dmFields: DWORD, + pub union1: [u8; 16], + pub dmColor: c_short, + pub dmDuplex: c_short, + pub dmYResolution: c_short, + pub dmTTOption: c_short, + pub dmCollate: c_short, + pub dmFormName: [WCHAR; CCHFORMNAME], + pub dmLogPixels: WORD, + pub dmBitsPerPel: DWORD, + pub dmPelsWidth: DWORD, + pub dmPelsHeight: DWORD, + pub dmDisplayFlags: DWORD, + pub dmDisplayFrequency: DWORD, + pub dmICMMethod: DWORD, + pub dmICMIntent: DWORD, + pub dmMediaType: DWORD, + pub dmDitherType: DWORD, + pub dmReserved1: DWORD, + pub dmReserved2: DWORD, + pub dmPanningWidth: DWORD, + pub dmPanningHeight: DWORD, +} +pub type PDEVMODEW = *mut DEVMODEW; +pub type NPDEVMODEW = *mut DEVMODEW; +pub type LPDEVMODEW = *mut DEVMODEW; +#[repr(C)] #[derive(Copy)] +pub struct DISPLAY_DEVICEW { + pub cb: DWORD, + pub DeviceName: [WCHAR; 32], + pub DeviceString: [WCHAR; 128], + pub StateFlags: DWORD, + pub DeviceID: [WCHAR; 128], + pub DeviceKey: [WCHAR; 128], +} +impl Clone for DISPLAY_DEVICEW { fn clone(&self) -> DISPLAY_DEVICEW { *self } } +pub type PDISPLAY_DEVICEW = *mut DISPLAY_DEVICEW; +pub type LPDISPLAY_DEVICEW = *mut DISPLAY_DEVICEW; +#[repr(C)] #[derive(Copy)] +pub struct DISPLAY_DEVICEA { + pub cb: DWORD, + pub DeviceName: [CHAR; 32], + pub DeviceString: [CHAR; 128], + pub StateFlags: DWORD, + pub DeviceID: [CHAR; 128], + pub DeviceKey: [CHAR; 128], +} +impl Clone for DISPLAY_DEVICEA { fn clone(&self) -> DISPLAY_DEVICEA { *self } } +pub type PDISPLAY_DEVICEA = *mut DISPLAY_DEVICEA; +pub type LPDISPLAY_DEVICEA = *mut DISPLAY_DEVICEA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PIXELFORMATDESCRIPTOR { + pub nSize: WORD, + pub nVersion: WORD, + pub dwFlags: DWORD, + pub iPixelType: BYTE, + pub cColorBits: BYTE, + pub cRedBits: BYTE, + pub cRedShift: BYTE, + pub cGreenBits: BYTE, + pub cGreenShift: BYTE, + pub cBlueBits: BYTE, + pub cBlueShift: BYTE, + pub cAlphaBits: BYTE, + pub cAlphaShift: BYTE, + pub cAccumBits: BYTE, + pub cAccumRedBits: BYTE, + pub cAccumGreenBits: BYTE, + pub cAccumBlueBits: BYTE, + pub cAccumAlphaBits: BYTE, + pub cDepthBits: BYTE, + pub cStencilBits: BYTE, + pub cAuxBuffers: BYTE, + pub iLayerType: BYTE, + pub bReserved: BYTE, + pub dwLayerMask: DWORD, + pub dwVisibleMask: DWORD, + pub dwDamageMask: DWORD, +} +pub type PPIXELFORMATDESCRIPTOR = *mut PIXELFORMATDESCRIPTOR; +pub type LPPIXELFORMATDESCRIPTOR = *mut PIXELFORMATDESCRIPTOR; + +//------------------------------------------------------------------------------------------------- +// Constants +//------------------------------------------------------------------------------------------------- + +// shlobj.h +// constants +#[cfg(target_arch = "x86")] +pub const INVALID_HANDLE_VALUE: HANDLE = 0xFFFFFFFF as HANDLE; +#[cfg(target_arch = "x86_64")] +pub const INVALID_HANDLE_VALUE: HANDLE = 0xFFFFFFFFFFFFFFFF as HANDLE; diff --git a/deps/winapi-0.1.23/src/libloaderapi.rs b/deps/winapi-0.1.23/src/libloaderapi.rs new file mode 100644 index 000000000..1efcf480d --- /dev/null +++ b/deps/winapi-0.1.23/src/libloaderapi.rs @@ -0,0 +1,5 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! ApiSet Contract for api-ms-win-core-libraryloader-l1 +pub type DLL_DIRECTORY_COOKIE = ::PVOID; +pub type PDLL_DIRECTORY_COOKIE = *mut ::PVOID; diff --git a/deps/winapi-0.1.23/src/minwinbase.rs b/deps/winapi-0.1.23/src/minwinbase.rs new file mode 100644 index 000000000..5a1c5b09d --- /dev/null +++ b/deps/winapi-0.1.23/src/minwinbase.rs @@ -0,0 +1,165 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! This module defines the 32-Bit Windows Base APIs +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SECURITY_ATTRIBUTES { + pub nLength: ::DWORD, + pub lpSecurityDescriptor: ::LPVOID, + pub bInheritHandle: ::BOOL, +} +pub type PSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; +pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct OVERLAPPED { + pub Internal: ::ULONG_PTR, + pub InternalHigh: ::ULONG_PTR, + pub Offset: ::DWORD, + pub OffsetHigh: ::DWORD, + pub hEvent: ::HANDLE, +} +UNION!(OVERLAPPED, Offset, Pointer, Pointer_mut, ::PVOID); +pub type LPOVERLAPPED = *mut OVERLAPPED; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct OVERLAPPED_ENTRY { + pub lpCompletionKey: ::ULONG_PTR, + pub lpOverlapped: LPOVERLAPPED, + pub Internal: ::ULONG_PTR, + pub dwNumberOfBytesTransferred: ::DWORD, +} +pub type LPOVERLAPPED_ENTRY = *mut OVERLAPPED_ENTRY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SYSTEMTIME { + pub wYear: ::WORD, + pub wMonth: ::WORD, + pub wDayOfWeek: ::WORD, + pub wDay: ::WORD, + pub wHour: ::WORD, + pub wMinute: ::WORD, + pub wSecond: ::WORD, + pub wMilliseconds: ::WORD, +} +pub type PSYSTEMTIME = *mut SYSTEMTIME; +pub type LPSYSTEMTIME = *mut SYSTEMTIME; +#[repr(C)] #[derive(Copy)] +pub struct WIN32_FIND_DATAA { + pub dwFileAttributes: ::DWORD, + pub ftCreationTime: ::FILETIME, + pub ftLastAccessTime: ::FILETIME, + pub ftLastWriteTime: ::FILETIME, + pub nFileSizeHigh: ::DWORD, + pub nFileSizeLow: ::DWORD, + pub dwReserved0: ::DWORD, + pub dwReserved1: ::DWORD, + pub cFileName: [::CHAR; ::MAX_PATH], + pub cAlternateFileName: [::CHAR; 14], +} +impl Clone for WIN32_FIND_DATAA { fn clone(&self) -> WIN32_FIND_DATAA { *self } } +pub type PWIN32_FIND_DATAA = *mut WIN32_FIND_DATAA; +pub type LPWIN32_FIND_DATAA = *mut WIN32_FIND_DATAA; +#[repr(C)] #[derive(Copy)] +pub struct WIN32_FIND_DATAW { + pub dwFileAttributes: ::DWORD, + pub ftCreationTime: ::FILETIME, + pub ftLastAccessTime: ::FILETIME, + pub ftLastWriteTime: ::FILETIME, + pub nFileSizeHigh: ::DWORD, + pub nFileSizeLow: ::DWORD, + pub dwReserved0: ::DWORD, + pub dwReserved1: ::DWORD, + pub cFileName: [::WCHAR; ::MAX_PATH], + pub cAlternateFileName: [::WCHAR; 14], +} +impl Clone for WIN32_FIND_DATAW { fn clone(&self) -> WIN32_FIND_DATAW { *self } } +pub type PWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; +pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum FINDEX_INFO_LEVELS { + FindExInfoStandard, + FindExInfoBasic, + FindExInfoMaxInfoLevel, +} +pub use self::FINDEX_INFO_LEVELS::*; +pub const FIND_FIRST_EX_CASE_SENSITIVE: ::DWORD = 0x00000001; +pub const FIND_FIRST_EX_LARGE_FETCH: ::DWORD = 0x00000002; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum FINDEX_SEARCH_OPS { + FindExSearchNameMatch, + FindExSearchLimitToDirectories, + FindExSearchLimitToDevices, + FindExSearchMaxSearchOp, +} +pub use self::FINDEX_SEARCH_OPS::*; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum GET_FILEEX_INFO_LEVELS { + GetFileExInfoStandard, + GetFileExMaxInfoLevel, +} +pub use self::GET_FILEEX_INFO_LEVELS::*; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum FILE_INFO_BY_HANDLE_CLASS { + FileBasicInfo, + FileStandardInfo, + FileNameInfo, + FileRenameInfo, + FileDispositionInfo, + FileAllocationInfo, + FileEndOfFileInfo, + FileStreamInfo, + FileCompressionInfo, + FileAttributeTagInfo, + FileIdBothDirectoryInfo, + FileIdBothDirectoryRestartInfo, + FileIoPriorityHintInfo, + FileRemoteProtocolInfo, + FileFullDirectoryInfo, + FileFullDirectoryRestartInfo, + FileStorageInfo, + FileAlignmentInfo, + FileIdInfo, + FileIdExtdDirectoryInfo, + FileIdExtdDirectoryRestartInfo, + MaximumFileInfoByHandleClass, +} +pub use self::FILE_INFO_BY_HANDLE_CLASS::*; +pub type PFILE_INFO_BY_HANDLE_CLASS = *mut FILE_INFO_BY_HANDLE_CLASS; +pub type CRITICAL_SECTION = ::RTL_CRITICAL_SECTION; +pub type PCRITICAL_SECTION = ::PRTL_CRITICAL_SECTION; +pub type LPCRITICAL_SECTION = ::PRTL_CRITICAL_SECTION; +pub type CRITICAL_SECTION_DEBUG = ::RTL_CRITICAL_SECTION_DEBUG; +pub type PCRITICAL_SECTION_DEBUG = ::PRTL_CRITICAL_SECTION_DEBUG; +pub type LPCRITICAL_SECTION_DEBUG = ::PRTL_CRITICAL_SECTION_DEBUG; +pub type LPOVERLAPPED_COMPLETION_ROUTINE = Option<unsafe extern "system" fn( + dwErrorCode: ::DWORD, dwNumberOfBytesTransfered: ::DWORD, lpOverlapped: LPOVERLAPPED, +)>; +pub const LOCKFILE_FAIL_IMMEDIATELY: ::DWORD = 0x00000001; +pub const LOCKFILE_EXCLUSIVE_LOCK: ::DWORD = 0x00000002; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROCESS_HEAP_ENTRY_Block { + pub hMem: ::HANDLE, + pub dwReserved: [::DWORD; 3], +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROCESS_HEAP_ENTRY_Region { + pub dwCommittedSize: ::DWORD, + pub dwUnCommittedSize: ::DWORD, + pub lpFirstBlock: ::LPVOID, + pub lpLastBlock: ::LPVOID, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROCESS_HEAP_ENTRY { + pub lpData: ::PVOID, + pub cbData: ::DWORD, + pub cbOverhead: ::BYTE, + pub iRegionIndex: ::BYTE, + pub wFlags: ::WORD, + pub Region: PROCESS_HEAP_ENTRY_Region, +} +UNION!(PROCESS_HEAP_ENTRY, Region, Block, Block_mut, PROCESS_HEAP_ENTRY_Block); +pub type LPPROCESS_HEAP_ENTRY = *mut PROCESS_HEAP_ENTRY; +pub type PPROCESS_HEAP_ENTRY = *mut PROCESS_HEAP_ENTRY; +pub const PROCESS_HEAP_REGION: ::WORD = 0x0001; +pub const PROCESS_HEAP_UNCOMMITTED_RANGE: ::WORD = 0x0002; +pub const PROCESS_HEAP_ENTRY_BUSY: ::WORD = 0x0004; +pub const PROCESS_HEAP_SEG_ALLOC: ::WORD = 0x0008; +pub const PROCESS_HEAP_ENTRY_MOVEABLE: ::WORD = 0x0010; +pub const PROCESS_HEAP_ENTRY_DDESHARE: ::WORD = 0x0020; diff --git a/deps/winapi-0.1.23/src/minwindef.rs b/deps/winapi-0.1.23/src/minwindef.rs new file mode 100644 index 000000000..53ac6c6aa --- /dev/null +++ b/deps/winapi-0.1.23/src/minwindef.rs @@ -0,0 +1,90 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Basic Windows Type Definitions for minwin partition +pub type ULONG = ::c_ulong; +pub type PULONG = *mut ULONG; +pub type USHORT = ::c_ushort; +pub type PUSHORT = *mut USHORT; +pub type UCHAR = ::c_uchar; +pub type PUCHAR = *mut UCHAR; +pub type PSZ = *mut ::c_char; +pub const MAX_PATH: usize = 260; +pub const FALSE: BOOL = 0; +pub const TRUE: BOOL = 1; +pub type DWORD = ::c_ulong; +pub type BOOL = ::c_int; +pub type BYTE = ::c_uchar; +pub type WORD = ::c_ushort; +pub type FLOAT = ::c_float; +pub type PFLOAT = *mut FLOAT; +pub type PBOOL = *mut BOOL; +pub type LPBOOL = *mut BOOL; +pub type PBYTE = *mut BYTE; +pub type LPBYTE = *mut BYTE; +pub type PINT = *mut ::c_int; +pub type LPINT = *mut ::c_int; +pub type PWORD = *mut WORD; +pub type LPWORD = *mut WORD; +pub type LPLONG = *mut ::c_long; +pub type PDWORD = *mut DWORD; +pub type LPDWORD = *mut DWORD; +pub type LPVOID = *mut ::c_void; +pub type LPCVOID = *const ::c_void; +pub type INT = ::c_int; +pub type UINT = ::c_uint; +pub type PUINT = *mut ::c_uint; +pub type WPARAM = ::UINT_PTR; +pub type LPARAM = ::LONG_PTR; +pub type LRESULT = ::LONG_PTR; +pub fn MAKEWORD(a: BYTE, b: BYTE) -> WORD { + (a as WORD) | ((b as WORD) << 8) +} +pub fn MAKELONG(a: WORD, b: WORD) -> ::LONG { + ((a as DWORD) | ((b as DWORD) << 16)) as ::LONG +} +pub fn LOWORD(l: DWORD) -> WORD { + (l & 0xffff) as WORD +} +pub fn HIWORD(l: DWORD) -> WORD { + ((l >> 16) & 0xffff) as WORD +} +pub fn LOBYTE(l: WORD) -> BYTE { + (l & 0xff) as BYTE +} +pub fn HIBYTE(l: WORD) -> BYTE { + ((l >> 8) & 0xff) as BYTE +} +pub type SPHANDLE = *mut ::HANDLE; +pub type LPHANDLE = *mut ::HANDLE; +pub type HGLOBAL = ::HANDLE; +pub type HLOCAL = ::HANDLE; +pub type GLOBALHANDLE = ::HANDLE; +pub type LOCALHANDLE = ::HANDLE; +/// Pointer to probably a function with unknown type signature. +pub type FARPROC = *const ::c_void; +/// Pointer to probably a function with unknown type signature. +pub type NEARPROC = *const ::c_void; +/// Pointer to probably a function with unknown type signature. +pub type PROC = *const ::c_void; +pub type ATOM = WORD; +DECLARE_HANDLE!(HKEY, HKEY__); +pub type PHKEY = *mut HKEY; +DECLARE_HANDLE!(HMETAFILE, HMETAFILE__); +DECLARE_HANDLE!(HINSTANCE, HINSTANCE__); +pub type HMODULE = HINSTANCE; +DECLARE_HANDLE!(HRGN, HRGN__); +DECLARE_HANDLE!(HRSRC, HRSRC__); +DECLARE_HANDLE!(HSPRITE, HSPRITE__); +DECLARE_HANDLE!(HLSURF, HLSURF__); +DECLARE_HANDLE!(HSTR, HSTR__); +DECLARE_HANDLE!(HTASK, HTASK__); +DECLARE_HANDLE!(HWINSTA, HWINSTA__); +DECLARE_HANDLE!(HKL, HKL__); +pub type HFILE = ::c_int; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, +} +pub type PFILETIME = *mut FILETIME; +pub type LPFILETIME = *mut FILETIME; diff --git a/deps/winapi-0.1.23/src/mmdeviceapi.rs b/deps/winapi-0.1.23/src/mmdeviceapi.rs new file mode 100644 index 000000000..1501e6212 --- /dev/null +++ b/deps/winapi-0.1.23/src/mmdeviceapi.rs @@ -0,0 +1,86 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum EDataFlow { + eRender, + eCapture, + eAll, + EDataFlow_enum_count, +} + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum ERole { + eConsole, + eMultimedia, + eCommunications, + ERole_enum_count, +} + +pub const CLSID_MMDeviceEnumerator: ::CLSID = ::GUID { + Data1: 0xBCDE0395, + Data2: 0xE52F, + Data3: 0x467C, + Data4: [0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E], +}; + +pub const IID_IMMDeviceEnumerator: ::IID = ::GUID { + Data1: 0xA95664D2, + Data2: 0x9614, + Data3: 0x4F35, + Data4: [0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6], +}; + +RIDL!( +interface IMMDevice(IMMDeviceVtbl): IUnknown(IUnknownVtbl) { + fn Activate( + &mut self, + iid: ::REFIID, + dwClsCtx: ::DWORD, + pActivationParams: *mut ::PROPVARIANT, + ppInterface: *mut ::LPVOID + ) -> ::HRESULT, + fn OpenPropertyStore( + &mut self, + stgmAccess: ::DWORD, + ppProperties: *mut *mut ::IPropertyStore + ) -> ::HRESULT, + fn GetId(&mut self, ppstrId: *mut ::LPWSTR) -> ::HRESULT, + fn GetState(&mut self, pdwState: *mut ::DWORD) -> ::HRESULT +} +); + +RIDL!( +interface IMMDeviceEnumerator(IMMDeviceEnumeratorVtbl): IUnknown(IUnknownVtbl) { + fn EnumAudioEndpoints( + &mut self, + dataFlow: EDataFlow, + dwStateMask: ::DWORD, + ppDevices: *mut *mut IMMDeviceCollection + ) -> ::HRESULT, + fn GetDefaultAudioEndpoint( + &mut self, + dataFlow: EDataFlow, + role: ERole, + ppEndpoint: *mut *mut IMMDevice + ) -> ::HRESULT, + fn GetDevice( + &mut self, + pwstrId: ::LPCWSTR, + ppDevices: *mut *mut IMMDevice + ) -> ::HRESULT, + fn RegisterEndpointNotificationCallback( + &mut self, + pClient: *mut IMMNotificationClient + ) -> ::HRESULT, + fn UnregisterEndpointNotificationCallback( + &mut self, + pClient: *mut IMMNotificationClient + ) -> ::HRESULT +} +); + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMMDeviceCollection; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMMNotificationClient; diff --git a/deps/winapi-0.1.23/src/mmreg.rs b/deps/winapi-0.1.23/src/mmreg.rs new file mode 100644 index 000000000..da79d25b3 --- /dev/null +++ b/deps/winapi-0.1.23/src/mmreg.rs @@ -0,0 +1,268 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +pub const WAVE_FORMAT_UNKNOWN: ::WORD = 0x0000; +pub const WAVE_FORMAT_PCM: ::WORD = 0x0001; +pub const WAVE_FORMAT_ADPCM: ::WORD = 0x0002; +pub const WAVE_FORMAT_IEEE_FLOAT: ::WORD = 0x0003; +pub const WAVE_FORMAT_VSELP: ::WORD = 0x0004; +pub const WAVE_FORMAT_IBM_CVSD: ::WORD = 0x0005; +pub const WAVE_FORMAT_ALAW: ::WORD = 0x0006; +pub const WAVE_FORMAT_MULAW: ::WORD = 0x0007; +pub const WAVE_FORMAT_DTS: ::WORD = 0x0008; +pub const WAVE_FORMAT_DRM: ::WORD = 0x0009; +pub const WAVE_FORMAT_WMAVOICE9: ::WORD = 0x000A; +pub const WAVE_FORMAT_WMAVOICE10: ::WORD = 0x000B; +pub const WAVE_FORMAT_OKI_ADPCM: ::WORD = 0x0010; +pub const WAVE_FORMAT_DVI_ADPCM: ::WORD = 0x0011; +pub const WAVE_FORMAT_IMA_ADPCM: ::WORD = WAVE_FORMAT_DVI_ADPCM; +pub const WAVE_FORMAT_MEDIASPACE_ADPCM: ::WORD = 0x0012; +pub const WAVE_FORMAT_SIERRA_ADPCM: ::WORD = 0x0013; +pub const WAVE_FORMAT_G723_ADPCM: ::WORD = 0x0014; +pub const WAVE_FORMAT_DIGISTD: ::WORD = 0x0015; +pub const WAVE_FORMAT_DIGIFIX: ::WORD = 0x0016; +pub const WAVE_FORMAT_DIALOGIC_OKI_ADPCM: ::WORD = 0x0017; +pub const WAVE_FORMAT_MEDIAVISION_ADPCM: ::WORD = 0x0018; +pub const WAVE_FORMAT_CU_CODEC: ::WORD = 0x0019; +pub const WAVE_FORMAT_HP_DYN_VOICE: ::WORD = 0x001A; +pub const WAVE_FORMAT_YAMAHA_ADPCM: ::WORD = 0x0020; +pub const WAVE_FORMAT_SONARC: ::WORD = 0x0021; +pub const WAVE_FORMAT_DSPGROUP_TRUESPEECH: ::WORD = 0x0022; +pub const WAVE_FORMAT_ECHOSC1: ::WORD = 0x0023; +pub const WAVE_FORMAT_AUDIOFILE_AF36: ::WORD = 0x0024; +pub const WAVE_FORMAT_APTX: ::WORD = 0x0025; +pub const WAVE_FORMAT_AUDIOFILE_AF10: ::WORD = 0x0026; +pub const WAVE_FORMAT_PROSODY_1612: ::WORD = 0x0027; +pub const WAVE_FORMAT_LRC: ::WORD = 0x0028; +pub const WAVE_FORMAT_DOLBY_AC2: ::WORD = 0x0030; +pub const WAVE_FORMAT_GSM610: ::WORD = 0x0031; +pub const WAVE_FORMAT_MSNAUDIO: ::WORD = 0x0032; +pub const WAVE_FORMAT_ANTEX_ADPCME: ::WORD = 0x0033; +pub const WAVE_FORMAT_CONTROL_RES_VQLPC: ::WORD = 0x0034; +pub const WAVE_FORMAT_DIGIREAL: ::WORD = 0x0035; +pub const WAVE_FORMAT_DIGIADPCM: ::WORD = 0x0036; +pub const WAVE_FORMAT_CONTROL_RES_CR10: ::WORD = 0x0037; +pub const WAVE_FORMAT_NMS_VBXADPCM: ::WORD = 0x0038; +pub const WAVE_FORMAT_CS_IMAADPCM: ::WORD = 0x0039; +pub const WAVE_FORMAT_ECHOSC3: ::WORD = 0x003A; +pub const WAVE_FORMAT_ROCKWELL_ADPCM: ::WORD = 0x003B; +pub const WAVE_FORMAT_ROCKWELL_DIGITALK: ::WORD = 0x003C; +pub const WAVE_FORMAT_XEBEC: ::WORD = 0x003D; +pub const WAVE_FORMAT_G721_ADPCM: ::WORD = 0x0040; +pub const WAVE_FORMAT_G728_CELP: ::WORD = 0x0041; +pub const WAVE_FORMAT_MSG723: ::WORD = 0x0042; +pub const WAVE_FORMAT_INTEL_G723_1: ::WORD = 0x0043; +pub const WAVE_FORMAT_INTEL_G729: ::WORD = 0x0044; +pub const WAVE_FORMAT_SHARP_G726: ::WORD = 0x0045; +pub const WAVE_FORMAT_MPEG: ::WORD = 0x0050; +pub const WAVE_FORMAT_RT24: ::WORD = 0x0052; +pub const WAVE_FORMAT_PAC: ::WORD = 0x0053; +pub const WAVE_FORMAT_MPEGLAYER3: ::WORD = 0x0055; +pub const WAVE_FORMAT_LUCENT_G723: ::WORD = 0x0059; +pub const WAVE_FORMAT_CIRRUS: ::WORD = 0x0060; +pub const WAVE_FORMAT_ESPCM: ::WORD = 0x0061; +pub const WAVE_FORMAT_VOXWARE: ::WORD = 0x0062; +pub const WAVE_FORMAT_CANOPUS_ATRAC: ::WORD = 0x0063; +pub const WAVE_FORMAT_G726_ADPCM: ::WORD = 0x0064; +pub const WAVE_FORMAT_G722_ADPCM: ::WORD = 0x0065; +pub const WAVE_FORMAT_DSAT: ::WORD = 0x0066; +pub const WAVE_FORMAT_DSAT_DISPLAY: ::WORD = 0x0067; +pub const WAVE_FORMAT_VOXWARE_BYTE_ALIGNED: ::WORD = 0x0069; +pub const WAVE_FORMAT_VOXWARE_AC8: ::WORD = 0x0070; +pub const WAVE_FORMAT_VOXWARE_AC10: ::WORD = 0x0071; +pub const WAVE_FORMAT_VOXWARE_AC16: ::WORD = 0x0072; +pub const WAVE_FORMAT_VOXWARE_AC20: ::WORD = 0x0073; +pub const WAVE_FORMAT_VOXWARE_RT24: ::WORD = 0x0074; +pub const WAVE_FORMAT_VOXWARE_RT29: ::WORD = 0x0075; +pub const WAVE_FORMAT_VOXWARE_RT29HW: ::WORD = 0x0076; +pub const WAVE_FORMAT_VOXWARE_VR12: ::WORD = 0x0077; +pub const WAVE_FORMAT_VOXWARE_VR18: ::WORD = 0x0078; +pub const WAVE_FORMAT_VOXWARE_TQ40: ::WORD = 0x0079; +pub const WAVE_FORMAT_VOXWARE_SC3: ::WORD = 0x007A; +pub const WAVE_FORMAT_VOXWARE_SC3_1: ::WORD = 0x007B; +pub const WAVE_FORMAT_SOFTSOUND: ::WORD = 0x0080; +pub const WAVE_FORMAT_VOXWARE_TQ60: ::WORD = 0x0081; +pub const WAVE_FORMAT_MSRT24: ::WORD = 0x0082; +pub const WAVE_FORMAT_G729A: ::WORD = 0x0083; +pub const WAVE_FORMAT_MVI_MVI2: ::WORD = 0x0084; +pub const WAVE_FORMAT_DF_G726: ::WORD = 0x0085; +pub const WAVE_FORMAT_DF_GSM610: ::WORD = 0x0086; +pub const WAVE_FORMAT_ISIAUDIO: ::WORD = 0x0088; +pub const WAVE_FORMAT_ONLIVE: ::WORD = 0x0089; +pub const WAVE_FORMAT_MULTITUDE_FT_SX20: ::WORD = 0x008A; +pub const WAVE_FORMAT_INFOCOM_ITS_G721_ADPCM: ::WORD = 0x008B; +pub const WAVE_FORMAT_CONVEDIA_G729: ::WORD = 0x008C; +pub const WAVE_FORMAT_CONGRUENCY: ::WORD = 0x008D; +pub const WAVE_FORMAT_SBC24: ::WORD = 0x0091; +pub const WAVE_FORMAT_DOLBY_AC3_SPDIF: ::WORD = 0x0092; +pub const WAVE_FORMAT_MEDIASONIC_G723: ::WORD = 0x0093; +pub const WAVE_FORMAT_PROSODY_8KBPS: ::WORD = 0x0094; +pub const WAVE_FORMAT_ZYXEL_ADPCM: ::WORD = 0x0097; +pub const WAVE_FORMAT_PHILIPS_LPCBB: ::WORD = 0x0098; +pub const WAVE_FORMAT_PACKED: ::WORD = 0x0099; +pub const WAVE_FORMAT_MALDEN_PHONYTALK: ::WORD = 0x00A0; +pub const WAVE_FORMAT_RACAL_RECORDER_GSM: ::WORD = 0x00A1; +pub const WAVE_FORMAT_RACAL_RECORDER_G720_A: ::WORD = 0x00A2; +pub const WAVE_FORMAT_RACAL_RECORDER_G723_1: ::WORD = 0x00A3; +pub const WAVE_FORMAT_RACAL_RECORDER_TETRA_ACELP: ::WORD = 0x00A4; +pub const WAVE_FORMAT_NEC_AAC: ::WORD = 0x00B0; +pub const WAVE_FORMAT_RAW_AAC1: ::WORD = 0x00FF; +pub const WAVE_FORMAT_RHETOREX_ADPCM: ::WORD = 0x0100; +pub const WAVE_FORMAT_IRAT: ::WORD = 0x0101; +pub const WAVE_FORMAT_VIVO_G723: ::WORD = 0x0111; +pub const WAVE_FORMAT_VIVO_SIREN: ::WORD = 0x0112; +pub const WAVE_FORMAT_PHILIPS_CELP: ::WORD = 0x0120; +pub const WAVE_FORMAT_PHILIPS_GRUNDIG: ::WORD = 0x0121; +pub const WAVE_FORMAT_DIGITAL_G723: ::WORD = 0x0123; +pub const WAVE_FORMAT_SANYO_LD_ADPCM: ::WORD = 0x0125; +pub const WAVE_FORMAT_SIPROLAB_ACEPLNET: ::WORD = 0x0130; +pub const WAVE_FORMAT_SIPROLAB_ACELP4800: ::WORD = 0x0131; +pub const WAVE_FORMAT_SIPROLAB_ACELP8V3: ::WORD = 0x0132; +pub const WAVE_FORMAT_SIPROLAB_G729: ::WORD = 0x0133; +pub const WAVE_FORMAT_SIPROLAB_G729A: ::WORD = 0x0134; +pub const WAVE_FORMAT_SIPROLAB_KELVIN: ::WORD = 0x0135; +pub const WAVE_FORMAT_VOICEAGE_AMR: ::WORD = 0x0136; +pub const WAVE_FORMAT_G726ADPCM: ::WORD = 0x0140; +pub const WAVE_FORMAT_DICTAPHONE_CELP68: ::WORD = 0x0141; +pub const WAVE_FORMAT_DICTAPHONE_CELP54: ::WORD = 0x0142; +pub const WAVE_FORMAT_QUALCOMM_PUREVOICE: ::WORD = 0x0150; +pub const WAVE_FORMAT_QUALCOMM_HALFRATE: ::WORD = 0x0151; +pub const WAVE_FORMAT_TUBGSM: ::WORD = 0x0155; +pub const WAVE_FORMAT_MSAUDIO1: ::WORD = 0x0160; +pub const WAVE_FORMAT_WMAUDIO2: ::WORD = 0x0161; +pub const WAVE_FORMAT_WMAUDIO3: ::WORD = 0x0162; +pub const WAVE_FORMAT_WMAUDIO_LOSSLESS: ::WORD = 0x0163; +pub const WAVE_FORMAT_WMASPDIF: ::WORD = 0x0164; +pub const WAVE_FORMAT_UNISYS_NAP_ADPCM: ::WORD = 0x0170; +pub const WAVE_FORMAT_UNISYS_NAP_ULAW: ::WORD = 0x0171; +pub const WAVE_FORMAT_UNISYS_NAP_ALAW: ::WORD = 0x0172; +pub const WAVE_FORMAT_UNISYS_NAP_16K: ::WORD = 0x0173; +pub const WAVE_FORMAT_SYCOM_ACM_SYC008: ::WORD = 0x0174; +pub const WAVE_FORMAT_SYCOM_ACM_SYC701_G726L: ::WORD = 0x0175; +pub const WAVE_FORMAT_SYCOM_ACM_SYC701_CELP54: ::WORD = 0x0176; +pub const WAVE_FORMAT_SYCOM_ACM_SYC701_CELP68: ::WORD = 0x0177; +pub const WAVE_FORMAT_KNOWLEDGE_ADVENTURE_ADPCM: ::WORD = 0x0178; +pub const WAVE_FORMAT_FRAUNHOFER_IIS_MPEG2_AAC: ::WORD = 0x0180; +pub const WAVE_FORMAT_DTS_DS: ::WORD = 0x0190; +pub const WAVE_FORMAT_CREATIVE_ADPCM: ::WORD = 0x0200; +pub const WAVE_FORMAT_CREATIVE_FASTSPEECH8: ::WORD = 0x0202; +pub const WAVE_FORMAT_CREATIVE_FASTSPEECH10: ::WORD = 0x0203; +pub const WAVE_FORMAT_UHER_ADPCM: ::WORD = 0x0210; +pub const WAVE_FORMAT_ULEAD_DV_AUDIO: ::WORD = 0x0215; +pub const WAVE_FORMAT_ULEAD_DV_AUDIO_1: ::WORD = 0x0216; +pub const WAVE_FORMAT_QUARTERDECK: ::WORD = 0x0220; +pub const WAVE_FORMAT_ILINK_VC: ::WORD = 0x0230; +pub const WAVE_FORMAT_RAW_SPORT: ::WORD = 0x0240; +pub const WAVE_FORMAT_ESST_AC3: ::WORD = 0x0241; +pub const WAVE_FORMAT_GENERIC_PASSTHRU: ::WORD = 0x0249; +pub const WAVE_FORMAT_IPI_HSX: ::WORD = 0x0250; +pub const WAVE_FORMAT_IPI_RPELP: ::WORD = 0x0251; +pub const WAVE_FORMAT_CS2: ::WORD = 0x0260; +pub const WAVE_FORMAT_SONY_SCX: ::WORD = 0x0270; +pub const WAVE_FORMAT_SONY_SCY: ::WORD = 0x0271; +pub const WAVE_FORMAT_SONY_ATRAC3: ::WORD = 0x0272; +pub const WAVE_FORMAT_SONY_SPC: ::WORD = 0x0273; +pub const WAVE_FORMAT_TELUM_AUDIO: ::WORD = 0x0280; +pub const WAVE_FORMAT_TELUM_IA_AUDIO: ::WORD = 0x0281; +pub const WAVE_FORMAT_NORCOM_VOICE_SYSTEMS_ADPCM: ::WORD = 0x0285; +pub const WAVE_FORMAT_FM_TOWNS_SND: ::WORD = 0x0300; +pub const WAVE_FORMAT_MICRONAS: ::WORD = 0x0350; +pub const WAVE_FORMAT_MICRONAS_CELP833: ::WORD = 0x0351; +pub const WAVE_FORMAT_BTV_DIGITAL: ::WORD = 0x0400; +pub const WAVE_FORMAT_INTEL_MUSIC_CODER: ::WORD = 0x0401; +pub const WAVE_FORMAT_INDEO_AUDIO: ::WORD = 0x0402; +pub const WAVE_FORMAT_QDESIGN_MUSIC: ::WORD = 0x0450; +pub const WAVE_FORMAT_ON2_VP7_AUDIO: ::WORD = 0x0500; +pub const WAVE_FORMAT_ON2_VP6_AUDIO: ::WORD = 0x0501; +pub const WAVE_FORMAT_VME_VMPCM: ::WORD = 0x0680; +pub const WAVE_FORMAT_TPC: ::WORD = 0x0681; +pub const WAVE_FORMAT_LIGHTWAVE_LOSSLESS: ::WORD = 0x08AE; +pub const WAVE_FORMAT_OLIGSM: ::WORD = 0x1000; +pub const WAVE_FORMAT_OLIADPCM: ::WORD = 0x1001; +pub const WAVE_FORMAT_OLICELP: ::WORD = 0x1002; +pub const WAVE_FORMAT_OLISBC: ::WORD = 0x1003; +pub const WAVE_FORMAT_OLIOPR: ::WORD = 0x1004; +pub const WAVE_FORMAT_LH_CODEC: ::WORD = 0x1100; +pub const WAVE_FORMAT_LH_CODEC_CELP: ::WORD = 0x1101; +pub const WAVE_FORMAT_LH_CODEC_SBC8: ::WORD = 0x1102; +pub const WAVE_FORMAT_LH_CODEC_SBC12: ::WORD = 0x1103; +pub const WAVE_FORMAT_LH_CODEC_SBC16: ::WORD = 0x1104; +pub const WAVE_FORMAT_NORRIS: ::WORD = 0x1400; +pub const WAVE_FORMAT_ISIAUDIO_2: ::WORD = 0x1401; +pub const WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS: ::WORD = 0x1500; +pub const WAVE_FORMAT_MPEG_ADTS_AAC: ::WORD = 0x1600; +pub const WAVE_FORMAT_MPEG_RAW_AAC: ::WORD = 0x1601; +pub const WAVE_FORMAT_MPEG_LOAS: ::WORD = 0x1602; +pub const WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC: ::WORD = 0x1608; +pub const WAVE_FORMAT_NOKIA_MPEG_RAW_AAC: ::WORD = 0x1609; +pub const WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC: ::WORD = 0x160A; +pub const WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC: ::WORD = 0x160B; +pub const WAVE_FORMAT_MPEG_HEAAC: ::WORD = 0x1610; +pub const WAVE_FORMAT_VOXWARE_RT24_SPEECH: ::WORD = 0x181C; +pub const WAVE_FORMAT_SONICFOUNDRY_LOSSLESS: ::WORD = 0x1971; +pub const WAVE_FORMAT_INNINGS_TELECOM_ADPCM: ::WORD = 0x1979; +pub const WAVE_FORMAT_LUCENT_SX8300P: ::WORD = 0x1C07; +pub const WAVE_FORMAT_LUCENT_SX5363S: ::WORD = 0x1C0C; +pub const WAVE_FORMAT_CUSEEME: ::WORD = 0x1F03; +pub const WAVE_FORMAT_NTCSOFT_ALF2CM_ACM: ::WORD = 0x1FC4; +pub const WAVE_FORMAT_DVM: ::WORD = 0x2000; +pub const WAVE_FORMAT_DTS2: ::WORD = 0x2001; +pub const WAVE_FORMAT_MAKEAVIS: ::WORD = 0x3313; +pub const WAVE_FORMAT_DIVIO_MPEG4_AAC: ::WORD = 0x4143; +pub const WAVE_FORMAT_NOKIA_ADAPTIVE_MULTIRATE: ::WORD = 0x4201; +pub const WAVE_FORMAT_DIVIO_G726: ::WORD = 0x4243; +pub const WAVE_FORMAT_LEAD_SPEECH: ::WORD = 0x434C; +pub const WAVE_FORMAT_LEAD_VORBIS: ::WORD = 0x564C; +pub const WAVE_FORMAT_WAVPACK_AUDIO: ::WORD = 0x5756; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_1: ::WORD = 0x674F; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_2: ::WORD = 0x6750; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_3: ::WORD = 0x6751; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_1_PLUS: ::WORD = 0x676F; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_2_PLUS: ::WORD = 0x6770; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_3_PLUS: ::WORD = 0x6771; +pub const WAVE_FORMAT_3COM_NBX: ::WORD = 0x7000; +pub const WAVE_FORMAT_FAAD_AAC: ::WORD = 0x706D; +pub const WAVE_FORMAT_AMR_NB: ::WORD = 0x7361; +pub const WAVE_FORMAT_AMR_WB: ::WORD = 0x7362; +pub const WAVE_FORMAT_AMR_WP: ::WORD = 0x7363; +pub const WAVE_FORMAT_GSM_AMR_CBR: ::WORD = 0x7A21; +pub const WAVE_FORMAT_GSM_AMR_VBR_SID: ::WORD = 0x7A22; +pub const WAVE_FORMAT_COMVERSE_INFOSYS_G723_1: ::WORD = 0xA100; +pub const WAVE_FORMAT_COMVERSE_INFOSYS_AVQSBC: ::WORD = 0xA101; +pub const WAVE_FORMAT_COMVERSE_INFOSYS_SBC: ::WORD = 0xA102; +pub const WAVE_FORMAT_SYMBOL_G729_A: ::WORD = 0xA103; +pub const WAVE_FORMAT_VOICEAGE_AMR_WB: ::WORD = 0xA104; +pub const WAVE_FORMAT_INGENIENT_G726: ::WORD = 0xA105; +pub const WAVE_FORMAT_MPEG4_AAC: ::WORD = 0xA106; +pub const WAVE_FORMAT_ENCORE_G726: ::WORD = 0xA107; +pub const WAVE_FORMAT_ZOLL_ASAO: ::WORD = 0xA108; +pub const WAVE_FORMAT_SPEEX_VOICE: ::WORD = 0xA109; +pub const WAVE_FORMAT_VIANIX_MASC: ::WORD = 0xA10A; +pub const WAVE_FORMAT_WM9_SPECTRUM_ANALYZER: ::WORD = 0xA10B; +pub const WAVE_FORMAT_WMF_SPECTRUM_ANAYZER: ::WORD = 0xA10C; +pub const WAVE_FORMAT_GSM_610: ::WORD = 0xA10D; +pub const WAVE_FORMAT_GSM_620: ::WORD = 0xA10E; +pub const WAVE_FORMAT_GSM_660: ::WORD = 0xA10F; +pub const WAVE_FORMAT_GSM_690: ::WORD = 0xA110; +pub const WAVE_FORMAT_GSM_ADAPTIVE_MULTIRATE_WB: ::WORD = 0xA111; +pub const WAVE_FORMAT_POLYCOM_G722: ::WORD = 0xA112; +pub const WAVE_FORMAT_POLYCOM_G728: ::WORD = 0xA113; +pub const WAVE_FORMAT_POLYCOM_G729_A: ::WORD = 0xA114; +pub const WAVE_FORMAT_POLYCOM_SIREN: ::WORD = 0xA115; +pub const WAVE_FORMAT_GLOBAL_IP_ILBC: ::WORD = 0xA116; +pub const WAVE_FORMAT_RADIOTIME_TIME_SHIFT_RADIO: ::WORD = 0xA117; +pub const WAVE_FORMAT_NICE_ACA: ::WORD = 0xA118; +pub const WAVE_FORMAT_NICE_ADPCM: ::WORD = 0xA119; +pub const WAVE_FORMAT_VOCORD_G721: ::WORD = 0xA11A; +pub const WAVE_FORMAT_VOCORD_G726: ::WORD = 0xA11B; +pub const WAVE_FORMAT_VOCORD_G722_1: ::WORD = 0xA11C; +pub const WAVE_FORMAT_VOCORD_G728: ::WORD = 0xA11D; +pub const WAVE_FORMAT_VOCORD_G729: ::WORD = 0xA11E; +pub const WAVE_FORMAT_VOCORD_G729_A: ::WORD = 0xA11F; +pub const WAVE_FORMAT_VOCORD_G723_1: ::WORD = 0xA120; +pub const WAVE_FORMAT_VOCORD_LBC: ::WORD = 0xA121; +pub const WAVE_FORMAT_NICE_G728: ::WORD = 0xA122; +pub const WAVE_FORMAT_FRACE_TELECOM_G729: ::WORD = 0xA123; +pub const WAVE_FORMAT_CODIAN: ::WORD = 0xA124; +pub const WAVE_FORMAT_FLAC: ::WORD = 0xF1AC; +pub const WAVE_FORMAT_EXTENSIBLE: ::WORD = 0xFFFE; +pub const WAVE_FORMAT_DEVELOPMENT: ::WORD = 0xFFFF; diff --git a/deps/winapi-0.1.23/src/mmsystem.rs b/deps/winapi-0.1.23/src/mmsystem.rs new file mode 100644 index 000000000..f855e333c --- /dev/null +++ b/deps/winapi-0.1.23/src/mmsystem.rs @@ -0,0 +1,212 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! MM procedure declarations, constant definitions and macros +//109 (Win 7 SDK) +pub type MMVERSION = ::UINT; +pub type MMRESULT = ::UINT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MMTIME { + wType: ::UINT, + u: MMTIME_u, +} +pub type PMMTIME = *mut MMTIME; +pub type NPMMTIME = *mut MMTIME; +pub type LPMMTIME = *mut MMTIME; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MMTIME_u { + data: [u8; 8], +} +UNION!(MMTIME_u, data, ms, ms_mut, ::DWORD); +UNION!(MMTIME_u, data, sample, sample_mut, ::DWORD); +UNION!(MMTIME_u, data, cb, cb_mut, ::DWORD); +UNION!(MMTIME_u, data, ticks, ticks_mut, ::DWORD); +UNION!(MMTIME_u, data, smpte, smpte_mut, MMTIME_smpte); +UNION!(MMTIME_u, data, midi, midi_mut, MMTIME_midi); +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MMTIME_smpte { + pub hour: ::BYTE, + pub min: ::BYTE, + pub sec: ::BYTE, + pub frame: ::BYTE, + pub fps: ::BYTE, + pub dummy: ::BYTE, + pub pad: [::BYTE; 2], +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MMTIME_midi { + pub songptrpos: ::DWORD, +} +pub const TIME_MS: ::UINT = 0x0001; +pub const TIME_SAMPLES: ::UINT = 0x0002; +pub const TIME_BYTES: ::UINT = 0x0004; +pub const TIME_SMPTE: ::UINT = 0x0008; +pub const TIME_MIDI: ::UINT = 0x0010; +pub const TIME_TICKS: ::UINT = 0x0020; +pub const MM_JOY1MOVE: ::UINT = 0x3A0; +pub const MM_JOY2MOVE: ::UINT = 0x3A1; +pub const MM_JOY1ZMOVE: ::UINT = 0x3A2; +pub const MM_JOY2ZMOVE: ::UINT = 0x3A3; +pub const MM_JOY1BUTTONDOWN: ::UINT = 0x3B5; +pub const MM_JOY2BUTTONDOWN: ::UINT = 0x3B6; +pub const MM_JOY1BUTTONUP: ::UINT = 0x3B7; +pub const MM_JOY2BUTTONUP: ::UINT = 0x3B8; +pub const MM_MCINOTIFY: ::UINT = 0x3B9; +pub const MM_WOM_OPEN: ::UINT = 0x3BB; +pub const MM_WOM_CLOSE: ::UINT = 0x3BC; +pub const MM_WOM_DONE: ::UINT = 0x3BD; +pub const MM_WIM_OPEN: ::UINT = 0x3BE; +pub const MM_WIM_CLOSE: ::UINT = 0x3BF; +pub const MM_WIM_DATA: ::UINT = 0x3C0; +pub const MM_MIM_OPEN: ::UINT = 0x3C1; +pub const MM_MIM_CLOSE: ::UINT = 0x3C2; +pub const MM_MIM_DATA: ::UINT = 0x3C3; +pub const MM_MIM_LONGDATA: ::UINT = 0x3C4; +pub const MM_MIM_ERROR: ::UINT = 0x3C5; +pub const MM_MIM_LONGERROR: ::UINT = 0x3C6; +pub const MM_MOM_OPEN: ::UINT = 0x3C7; +pub const MM_MOM_CLOSE: ::UINT = 0x3C8; +pub const MM_MOM_DONE: ::UINT = 0x3C9; +pub const MMSYSERR_BASE: MMRESULT = 0; +pub const WAVERR_BASE: MMRESULT = 32; +pub const MIDIERR_BASE: MMRESULT = 64; +pub const TIMERR_BASE: MMRESULT = 96; +pub const JOYERR_BASE: MMRESULT = 160; +pub const MCIERR_BASE: MMRESULT = 256; +pub const MIXERR_BASE: MMRESULT = 1024; +pub const MMSYSERR_NOERROR: MMRESULT = 0; +pub const MMSYSERR_ERROR: MMRESULT = MMSYSERR_BASE + 1; +pub const MMSYSERR_BADDEVICEID: MMRESULT = MMSYSERR_BASE + 2; +pub const MMSYSERR_NOTENABLED: MMRESULT = MMSYSERR_BASE + 3; +pub const MMSYSERR_ALLOCATED: MMRESULT = MMSYSERR_BASE + 4; +pub const MMSYSERR_INVALHANDLE: MMRESULT = MMSYSERR_BASE + 5; +pub const MMSYSERR_NODRIVER: MMRESULT = MMSYSERR_BASE + 6; +pub const MMSYSERR_NOMEM: MMRESULT = MMSYSERR_BASE + 7; +pub const MMSYSERR_NOTSUPPORTED: MMRESULT = MMSYSERR_BASE + 8; +pub const MMSYSERR_BADERRNUM: MMRESULT = MMSYSERR_BASE + 9; +pub const MMSYSERR_INVALFLAG: MMRESULT = MMSYSERR_BASE + 10; +pub const MMSYSERR_INVALPARAM: MMRESULT = MMSYSERR_BASE + 11; +pub const MMSYSERR_HANDLEBUSY: MMRESULT = MMSYSERR_BASE + 12; +pub const MMSYSERR_INVALIDALIAS: MMRESULT = MMSYSERR_BASE + 13; +pub const MMSYSERR_BADDB: MMRESULT = MMSYSERR_BASE + 14; +pub const MMSYSERR_KEYNOTFOUND: MMRESULT = MMSYSERR_BASE + 15; +pub const MMSYSERR_READERROR: MMRESULT = MMSYSERR_BASE + 16; +pub const MMSYSERR_WRITEERROR: MMRESULT = MMSYSERR_BASE + 17; +pub const MMSYSERR_DELETEERROR: MMRESULT = MMSYSERR_BASE + 18; +pub const MMSYSERR_VALNOTFOUND: MMRESULT = MMSYSERR_BASE + 19; +pub const MMSYSERR_NODRIVERCB: MMRESULT = MMSYSERR_BASE + 20; +pub const MMSYSERR_MOREDATA: MMRESULT = MMSYSERR_BASE + 21; +pub const MMSYSERR_LASTERROR: MMRESULT = MMSYSERR_BASE + 21; +pub const CALLBACK_TYPEMASK: ::DWORD = 0x00070000; +pub const CALLBACK_NULL: ::DWORD = 0x00000000; +pub const CALLBACK_WINDOW: ::DWORD = 0x00010000; +pub const CALLBACK_TASK: ::DWORD = 0x00020000; +pub const CALLBACK_FUNCTION: ::DWORD = 0x00030000; +pub const CALLBACK_THREAD: ::DWORD = CALLBACK_TASK; +pub const CALLBACK_EVENT: ::DWORD = 0x00050000; +//497 (Win 7 SDK) +pub const WAVERR_BADFORMAT: MMRESULT = WAVERR_BASE + 0; +pub const WAVERR_STILLPLAYING: MMRESULT = WAVERR_BASE + 1; +pub const WAVERR_UNPREPARED: MMRESULT = WAVERR_BASE + 2; +pub const WAVERR_SYNC: MMRESULT = WAVERR_BASE + 3; +pub const WAVERR_LASTERROR: MMRESULT = WAVERR_BASE + 3; +DECLARE_HANDLE!(HWAVEIN, HWAVEIN__); +DECLARE_HANDLE!(HWAVEOUT, HWAVEOUT__); +pub type LPHWAVEIN = *mut HWAVEIN; +pub type LPHWAVEOUT = *mut HWAVEOUT; +pub const WOM_OPEN: ::UINT = MM_WOM_OPEN; +pub const WOM_CLOSE: ::UINT = MM_WOM_CLOSE; +pub const WOM_DONE: ::UINT = MM_WOM_DONE; +pub const WIM_OPEN: ::UINT = MM_WIM_OPEN; +pub const WIM_CLOSE: ::UINT = MM_WIM_CLOSE; +pub const WIM_DATA: ::UINT = MM_WIM_DATA; +pub const WAVE_MAPPER: ::UINT = 0xFFFFFFFF; +pub const WAVE_FORMAT_QUERY: ::DWORD = 0x0001; +pub const WAVE_ALLOWSYNC: ::DWORD = 0x0002; +pub const WAVE_MAPPED: ::DWORD = 0x0004; +pub const WAVE_FORMAT_DIRECT: ::DWORD = 0x0008; +pub const WAVE_FORMAT_DIRECT_QUERY: ::DWORD = WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT; +pub const WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE: ::DWORD = 0x0010; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WAVEHDR { + pub lpData: ::LPSTR, + pub dwBufferLength: ::DWORD, + pub dwBytesRecorded: ::DWORD, + pub dwUser: ::DWORD_PTR, + pub dwFlags: ::DWORD, + pub dwLoops: ::DWORD, + pub lpNext: *mut WAVEHDR, + pub reserved: ::DWORD_PTR, +} +pub type PWAVEHDR = *mut WAVEHDR; +pub type NPWAVEHDR = *mut WAVEHDR; +pub type LPWAVEHDR = *mut WAVEHDR; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WAVEOUTCAPSW { + pub wMid: ::WORD, + pub wPid: ::WORD, + pub vDriverVersion: MMVERSION, + pub szPname: [::WCHAR; 32], + pub dwFormats: ::DWORD, + pub wChannels: ::WORD, + pub wReserved1: ::WORD, + pub dwSupport: ::DWORD, +} +pub type PWAVEOUTCAPSW = *mut WAVEOUTCAPSW; +pub type NPWAVEOUTCAPSW = *mut WAVEOUTCAPSW; +pub type LPWAVEOUTCAPSW = *mut WAVEOUTCAPSW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WAVEINCAPSW { + pub wMid: ::WORD, + pub wPid: ::WORD, + pub vDriverVersion: MMVERSION, + pub szPname: [::WCHAR; 32], + pub dwFormats: ::DWORD, + pub wChannels: ::WORD, + pub wReserved1: ::WORD, +} +pub type PWAVEINCAPSW = *mut WAVEINCAPSW; +pub type NPWAVEINCAPSW = *mut WAVEINCAPSW; +pub type LPWAVEINCAPSW = *mut WAVEINCAPSW; +pub const WAVE_INVALIDFORMAT: ::DWORD = 0x00000000; +pub const WAVE_FORMAT_1M08: ::DWORD = 0x00000001; +pub const WAVE_FORMAT_1S08: ::DWORD = 0x00000002; +pub const WAVE_FORMAT_1M16: ::DWORD = 0x00000004; +pub const WAVE_FORMAT_1S16: ::DWORD = 0x00000008; +pub const WAVE_FORMAT_2M08: ::DWORD = 0x00000010; +pub const WAVE_FORMAT_2S08: ::DWORD = 0x00000020; +pub const WAVE_FORMAT_2M16: ::DWORD = 0x00000040; +pub const WAVE_FORMAT_2S16: ::DWORD = 0x00000080; +pub const WAVE_FORMAT_4M08: ::DWORD = 0x00000100; +pub const WAVE_FORMAT_4S08: ::DWORD = 0x00000200; +pub const WAVE_FORMAT_4M16: ::DWORD = 0x00000400; +pub const WAVE_FORMAT_4S16: ::DWORD = 0x00000800; +pub const WAVE_FORMAT_44M08: ::DWORD = 0x00000100; +pub const WAVE_FORMAT_44S08: ::DWORD = 0x00000200; +pub const WAVE_FORMAT_44M16: ::DWORD = 0x00000400; +pub const WAVE_FORMAT_44S16: ::DWORD = 0x00000800; +pub const WAVE_FORMAT_48M08: ::DWORD = 0x00001000; +pub const WAVE_FORMAT_48S08: ::DWORD = 0x00002000; +pub const WAVE_FORMAT_48M16: ::DWORD = 0x00004000; +pub const WAVE_FORMAT_48S16: ::DWORD = 0x00008000; +pub const WAVE_FORMAT_96M08: ::DWORD = 0x00010000; +pub const WAVE_FORMAT_96S08: ::DWORD = 0x00020000; +pub const WAVE_FORMAT_96M16: ::DWORD = 0x00040000; +pub const WAVE_FORMAT_96S16: ::DWORD = 0x00080000; +//782 (Win 7 SDK) +pub type PWAVEFORMATEX = *mut ::WAVEFORMATEX; +pub type NPWAVEFORMATEX = *mut ::WAVEFORMATEX; +pub type LPWAVEFORMATEX = *mut ::WAVEFORMATEX; +pub type LPCWAVEFORMATEX = *const ::WAVEFORMATEX; +//2170 (Win 7 SDK) +pub const TIMERR_NOERROR: ::MMRESULT = 0; +pub const TIMERR_NOCANDO: ::MMRESULT = TIMERR_BASE + 1; +pub const TIMERR_STRUCT: ::MMRESULT = TIMERR_BASE + 33; +//2198 (Win 7 SDK) +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct TIMECAPS { + pub wPeriodMin: ::UINT, + pub wPeriodMax: ::UINT, +} +pub type PTIMECAPS = *mut TIMECAPS; +pub type NPTIMECAPS = *mut TIMECAPS; +pub type LPTIMECAPS = *mut TIMECAPS; diff --git a/deps/winapi-0.1.23/src/objidl.rs b/deps/winapi-0.1.23/src/objidl.rs new file mode 100644 index 000000000..2252130e1 --- /dev/null +++ b/deps/winapi-0.1.23/src/objidl.rs @@ -0,0 +1,50 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +//8402 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct BIND_OPTS { + pub cbStruct: ::DWORD, + pub grfFlags: ::DWORD, + pub grfMode: ::DWORD, + pub dwTickCountDeadline: ::DWORD, +} +pub type LPBIND_OPTS = *mut BIND_OPTS; +//8479 +RIDL!( +interface IBindCtx(IBindCtxVtbl): IUnknown(IUnknownVtbl) { + fn RegisterObjectBound(&mut self, punk: *mut ::IUnknown) -> ::HRESULT, + fn RevokeObjectBound(&mut self, punk: *mut ::IUnknown) -> ::HRESULT, + fn ReleaseBoundObjects(&mut self) -> ::HRESULT, + fn SetBindOptions(&mut self, pbindopts: *mut BIND_OPTS) -> ::HRESULT, + fn GetBindOptions(&mut self, pbindopts: *mut BIND_OPTS) -> ::HRESULT, + fn GetRunningObjectTable(&mut self, pprot: *mut *mut IRunningObjectTable) -> ::HRESULT, + fn RegisterObjectParam(&mut self, pszKey: ::LPOLESTR, punk: *mut ::IUnknown) -> ::HRESULT, + fn GetObjectParam(&mut self, pszKey: ::LPOLESTR, ppunk: *mut *mut ::IUnknown) -> ::HRESULT, + fn EnumObjectParam(&mut self, ppenum: *mut *mut ::IEnumString) -> ::HRESULT, + fn RevokeObjectParam(&mut self, pszKey: ::LPOLESTR) -> ::HRESULT +} +); +//8681 +pub type IEnumMoniker = ::IUnknown; // TODO +//8958 +RIDL!( +interface IRunningObjectTable(IRunningObjectTableVtbl): IUnknown(IUnknownVtbl) { + fn Register( + &mut self, grfFlags: ::DWORD, punkObject: *mut ::IUnknown, pmkObjectName: *mut IMoniker, + pdwRegister: *mut ::DWORD + ) -> ::HRESULT, + fn Revoke(&mut self, dwRegister: ::DWORD) -> ::HRESULT, + fn IsRunning(&mut self, pmkObjectName: *mut IMoniker) -> ::HRESULT, + fn GetObject( + &mut self, pmkObjectName: *mut IMoniker, ppunkObject: *mut *mut ::IUnknown + ) -> ::HRESULT, + fn NoteChangeTime(&mut self, dwRegister: ::DWORD, pfiletime: *mut ::FILETIME) -> ::HRESULT, + fn GetTimeOfLastChange( + &mut self, pmkObjectName: *mut IMoniker, pfiletime: *mut ::FILETIME + ) -> ::HRESULT, + fn EnumRunning(&mut self, ppenumMoniker: *mut *mut IEnumMoniker) -> ::HRESULT +} +); +//9350 +pub type IMoniker = ::IUnknown; // TODO diff --git a/deps/winapi-0.1.23/src/objidlbase.rs b/deps/winapi-0.1.23/src/objidlbase.rs new file mode 100644 index 000000000..0b9302809 --- /dev/null +++ b/deps/winapi-0.1.23/src/objidlbase.rs @@ -0,0 +1,80 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +RIDL!( +interface IMalloc(IMallocVtbl): IUnknown(IUnknownVtbl) { + fn Alloc(&mut self, cb: ::SIZE_T) -> *mut ::c_void, + fn Realloc(&mut self, pv: *mut ::c_void, cb: ::SIZE_T) -> *mut ::c_void, + fn Free(&mut self, pv: *mut ::c_void) -> (), + fn GetSize(&mut self, pv: *mut ::c_void) -> ::SIZE_T, + fn DidAlloc(&mut self, pv: *mut ::c_void) -> ::c_int, + fn HeapMinimize(&mut self) -> () +} +); +pub type LPMALLOC = *mut IMalloc; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct STATSTG { + pub pwcsName: ::LPOLESTR, + pub type_: ::DWORD, + pub cbSize: ::ULARGE_INTEGER, + pub mtime: ::FILETIME, + pub ctime: ::FILETIME, + pub atime: ::FILETIME, + pub grfMode: ::DWORD, + pub grfLocksSupported: ::DWORD, + pub clsid: ::CLSID, + pub grfStateBits: ::DWORD, + pub reserved: ::DWORD, +} +//1945 +pub type IEnumString = ::IUnknown; // TODO +//2075 +RIDL!( +interface ISequentialStream(ISequentialStreamVtbl): IUnknown(IUnknownVtbl) { + fn Read(&mut self, pv: *mut ::c_void, cb: ::ULONG, pcbRead: *mut ::ULONG) -> ::HRESULT, + fn Write(&mut self, pv: *const ::c_void, cb: ::ULONG, pcbWritten: *mut ::ULONG) -> ::HRESULT +} +); +//2255 +RIDL!( +interface IStream(IStreamVtbl): ISequentialStream(ISequentialStreamVtbl) { + fn Seek( + &mut self, dlibMove: ::LARGE_INTEGER, dwOrigin: ::DWORD, + plibNewPosition: *mut ::ULARGE_INTEGER + ) -> ::HRESULT, + fn SetSize(&mut self, libNewSize: ::ULARGE_INTEGER) -> ::HRESULT, + fn CopyTo( + &mut self, pstm: *mut IStream, cb: ::ULARGE_INTEGER, pcbRead: *mut ::ULARGE_INTEGER, + pcbWritten: *mut ::ULARGE_INTEGER + ) -> ::HRESULT, + fn Commit(&mut self, grfCommitFlags: ::DWORD) -> ::HRESULT, + fn Revert(&mut self) -> ::HRESULT, + fn LockRegion( + &mut self, libOffset: ::ULARGE_INTEGER, cb: ::ULARGE_INTEGER, dwLockType: ::DWORD + ) -> ::HRESULT, + fn UnlockRegion( + &mut self, libOffset: ::ULARGE_INTEGER, cb: ::ULARGE_INTEGER, dwLockType: ::DWORD + ) -> ::HRESULT, + fn Stat(&mut self, pstatstg: *mut STATSTG, grfStatFlag: ::DWORD) -> ::HRESULT, + fn Clone(&mut self, ppstm: *mut *mut IStream) -> ::HRESULT +} +); +pub type LPSTREAM = *mut IStream; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum APTTYPEQUALIFIER { + APTTYPEQUALIFIER_NONE = 0, + APTTYPEQUALIFIER_IMPLICIT_MTA = 1, + APTTYPEQUALIFIER_NA_ON_MTA = 2, + APTTYPEQUALIFIER_NA_ON_STA = 3, + APTTYPEQUALIFIER_NA_ON_IMPLICIT_MTA = 4, + APTTYPEQUALIFIER_NA_ON_MAINSTA = 5, + APTTYPEQUALIFIER_APPLICATION_STA= 6, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum APTTYPE { + APTTYPE_CURRENT = -1, + APTTYPE_STA = 0, + APTTYPE_MTA = 1, + APTTYPE_NA = 2, + APTTYPE_MAINSTA = 3, +} diff --git a/deps/winapi-0.1.23/src/processthreadsapi.rs b/deps/winapi-0.1.23/src/processthreadsapi.rs new file mode 100644 index 000000000..033501f7c --- /dev/null +++ b/deps/winapi-0.1.23/src/processthreadsapi.rs @@ -0,0 +1,46 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct STARTUPINFOA { + pub cb: ::DWORD, + pub lpReserved: ::LPSTR, + pub lpDesktop: ::LPSTR, + pub lpTitle: ::LPSTR, + pub dwX: ::DWORD, + pub dwY: ::DWORD, + pub dwXSize: ::DWORD, + pub dwYSize: ::DWORD, + pub dwXCountChars: ::DWORD, + pub dwYCountChars: ::DWORD, + pub dwFillAttribute: ::DWORD, + pub dwFlags: ::DWORD, + pub wShowWindow: ::WORD, + pub cbReserved2: ::WORD, + pub lpReserved2: ::LPBYTE, + pub hStdInput: ::HANDLE, + pub hStdOutput: ::HANDLE, + pub hStdError: ::HANDLE, +} +pub type LPSTARTUPINFOA = *mut STARTUPINFOA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct STARTUPINFOW { + pub cb: ::DWORD, + pub lpReserved: ::LPWSTR, + pub lpDesktop: ::LPWSTR, + pub lpTitle: ::LPWSTR, + pub dwX: ::DWORD, + pub dwY: ::DWORD, + pub dwXSize: ::DWORD, + pub dwYSize: ::DWORD, + pub dwXCountChars: ::DWORD, + pub dwYCountChars: ::DWORD, + pub dwFillAttribute: ::DWORD, + pub dwFlags: ::DWORD, + pub wShowWindow: ::WORD, + pub cbReserved2: ::WORD, + pub lpReserved2: ::LPBYTE, + pub hStdInput: ::HANDLE, + pub hStdOutput: ::HANDLE, + pub hStdError: ::HANDLE, +} +pub type LPSTARTUPINFOW = *mut STARTUPINFOW; diff --git a/deps/winapi-0.1.23/src/propsys.rs b/deps/winapi-0.1.23/src/propsys.rs new file mode 100644 index 000000000..0666fbd48 --- /dev/null +++ b/deps/winapi-0.1.23/src/propsys.rs @@ -0,0 +1,4 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +pub type IPropertyDescriptionList = ::IUnknown; // TODO +pub type IPropertyStore = ::IUnknown; // TODO diff --git a/deps/winapi-0.1.23/src/schannel.rs b/deps/winapi-0.1.23/src/schannel.rs new file mode 100644 index 000000000..871661771 --- /dev/null +++ b/deps/winapi-0.1.23/src/schannel.rs @@ -0,0 +1,365 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Public Definitions for SCHANNEL Security Provider +pub const UNISP_NAME: &'static str = "Microsoft Unified Security Protocol Provider"; +pub const SSL2SP_NAME: &'static str = "Microsoft SSL 2.0"; +pub const SSL3SP_NAME: &'static str = "Microsoft SSL 3.0"; +pub const TLS1SP_NAME: &'static str = "Microsoft TLS 1.0"; +pub const PCT1SP_NAME: &'static str = "Microsoft PCT 1.0"; +pub const SCHANNEL_NAME: &'static str = "Schannel"; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum eTlsSignatureAlgorithm { + TlsSignatureAlgorithm_Anonymous = 0, + TlsSignatureAlgorithm_Rsa = 1, + TlsSignatureAlgorithm_Dsa = 2, + TlsSignatureAlgorithm_Ecdsa = 3, +} +pub use self::eTlsSignatureAlgorithm::*; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum eTlsHashAlgorithm { + TlsHashAlgorithm_None = 0, + TlsHashAlgorithm_Md5 = 1, + TlsHashAlgorithm_Sha1 = 2, + TlsHashAlgorithm_Sha224 = 3, + TlsHashAlgorithm_Sha256 = 4, + TlsHashAlgorithm_Sha384 = 5, + TlsHashAlgorithm_Sha512 = 6, +} +pub use self::eTlsHashAlgorithm::*; +pub const UNISP_RPC_ID: ::DWORD = 14; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_RemoteCredentialInfo { + pub cbCertificateChain: ::DWORD, + pub pbCertificateChain: ::PBYTE, + pub cCertificates: ::DWORD, + pub fFlags: ::DWORD, + pub dwBits: ::DWORD, +} +pub type PSecPkgContext_RemoteCredentialInfo = *mut SecPkgContext_RemoteCredentialInfo; +pub type SecPkgContext_RemoteCredenitalInfo = SecPkgContext_RemoteCredentialInfo; +pub type PSecPkgContext_RemoteCredenitalInfo = *mut SecPkgContext_RemoteCredentialInfo; +pub const RCRED_STATUS_NOCRED: ::DWORD = 0x00000000; +pub const RCRED_CRED_EXISTS: ::DWORD = 0x00000001; +pub const RCRED_STATUS_UNKNOWN_ISSUER: ::DWORD = 0x00000002; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_LocalCredentialInfo { + pub cbCertificateChain: ::DWORD, + pub pbCertificateChain: ::PBYTE, + pub cCertificates: ::DWORD, + pub fFlags: ::DWORD, + pub dwBits: ::DWORD, +} +pub type PSecPkgContext_LocalCredentialInfo = *mut SecPkgContext_LocalCredentialInfo; +pub type SecPkgContext_LocalCredenitalInfo = SecPkgContext_LocalCredentialInfo; +pub type PSecPkgContext_LocalCredenitalInfo = *mut SecPkgContext_LocalCredentialInfo; +pub const LCRED_STATUS_NOCRED: ::DWORD = 0x00000000; +pub const LCRED_CRED_EXISTS: ::DWORD = 0x00000001; +pub const LCRED_STATUS_UNKNOWN_ISSUER: ::DWORD = 0x00000002; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_ClientCertPolicyResult { + pub dwPolicyResult: ::HRESULT, + pub guidPolicyId: ::GUID, +} +pub type PSecPkgContext_ClientCertPolicyResult = *mut SecPkgContext_ClientCertPolicyResult; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_IssuerListInfoEx { + pub aIssuers: ::PCERT_NAME_BLOB, + pub cIssuers: ::DWORD, +} +pub type PSecPkgContext_IssuerListInfoEx = *mut SecPkgContext_IssuerListInfoEx; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_ConnectionInfo { + pub dwProtocol: ::DWORD, + pub aiCipher: ::ALG_ID, + pub dwCipherStrength: ::DWORD, + pub aiHash: ::ALG_ID, + pub dwHashStrength: ::DWORD, + pub aiExch: ::ALG_ID, + pub dwExchStrength: ::DWORD, +} +pub type PSecPkgContext_ConnectionInfo = *mut SecPkgContext_ConnectionInfo; +pub const SZ_ALG_MAX_SIZE: usize = 64; +pub const SECPKGCONTEXT_CIPHERINFO_V1: ::DWORD = 1; +#[repr(C)] #[derive(Copy)] +pub struct SecPkgContext_CipherInfo { + pub dwVersion: ::DWORD, + pub dwProtocol: ::DWORD, + pub dwCipherSuite: ::DWORD, + pub dwBaseCipherSuite: ::DWORD, + pub szCipherSuite: [::WCHAR; SZ_ALG_MAX_SIZE], + pub szCipher: [::WCHAR; SZ_ALG_MAX_SIZE], + pub dwCipherLen: ::DWORD, + pub dwCipherBlockLen: ::DWORD, + pub szHash: [::WCHAR; SZ_ALG_MAX_SIZE], + pub dwHashLen: ::DWORD, + pub szExchange: [::WCHAR; SZ_ALG_MAX_SIZE], + pub dwMinExchangeLen: ::DWORD, + pub dwMaxExchangeLen: ::DWORD, + pub szCertificate: [::WCHAR; SZ_ALG_MAX_SIZE], + pub dwKeyType: ::DWORD, +} +impl Clone for SecPkgContext_CipherInfo { fn clone(&self) -> SecPkgContext_CipherInfo { *self } } +pub type PSecPkgContext_CipherInfo = *mut SecPkgContext_CipherInfo; +#[repr(C)] #[derive(Copy)] +pub struct SecPkgContext_EapKeyBlock { + pub rgbKeys: [::BYTE; 128], + pub rgbIVs: [::BYTE; 64], +} +impl Clone for SecPkgContext_EapKeyBlock { fn clone(&self) -> SecPkgContext_EapKeyBlock { *self } } +pub type PSecPkgContext_EapKeyBlock = *mut SecPkgContext_EapKeyBlock; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_MappedCredAttr { + pub dwAttribute: ::DWORD, + pub pvBuffer: ::PVOID, +} +pub type PSecPkgContext_MappedCredAttr = *mut SecPkgContext_MappedCredAttr; +pub const SSL_SESSION_RECONNECT: ::DWORD = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_SessionInfo { + pub dwFlags: ::DWORD, + pub cbSessionId: ::DWORD, + pub rgbSessionId: [::BYTE; 32], +} +pub type PSecPkgContext_SessionInfo = *mut SecPkgContext_SessionInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_SessionAppData { + pub dwFlags: ::DWORD, + pub cbAppData: ::DWORD, + pub pbAppData: ::PBYTE, +} +pub type PSecPkgContext_SessionAppData = *mut SecPkgContext_SessionAppData; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_EapPrfInfo { + pub dwVersion: ::DWORD, + pub cbPrfData: ::DWORD, + pub pbPrfData: ::PBYTE, +} +pub type PSecPkgContext_EapPrfInfo = *mut SecPkgContext_EapPrfInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_SupportedSignatures { + pub cSignatureAndHashAlgorithms: ::WORD, + pub pSignatureAndHashAlgorithms: *mut ::WORD, +} +pub type PSecPkgContext_SupportedSignatures = *mut SecPkgContext_SupportedSignatures; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_Certificates { + pub cCertificates: ::DWORD, + pub cbCertificateChain: ::DWORD, + pub pbCertificateChain: ::PBYTE, +} +pub type PSecPkgContext_Certificates = *mut SecPkgContext_Certificates; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_CertInfo { + pub dwVersion: ::DWORD, + pub cbSubjectName: ::DWORD, + pub pwszSubjectName: ::LPWSTR, + pub cbIssuerName: ::DWORD, + pub pwszIssuerName: ::LPWSTR, + pub dwKeySize: ::DWORD, +} +pub type PSecPkgContext_CertInfo = *mut SecPkgContext_CertInfo; +pub const KERN_CONTEXT_CERT_INFO_V1: ::DWORD = 0x00000000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_UiInfo { + pub hParentWindow: ::HWND, +} +pub type PSecPkgContext_UiInfo = *mut SecPkgContext_UiInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_EarlyStart { + pub dwEarlyStartFlags: ::DWORD, +} +pub type PSecPkgContext_EarlyStart = *mut SecPkgContext_EarlyStart; +pub const ENABLE_TLS_CLIENT_EARLY_START: ::DWORD = 0x00000001; +pub const SCH_CRED_V1: ::DWORD = 0x00000001; +pub const SCH_CRED_V2: ::DWORD = 0x00000002; +pub const SCH_CRED_VERSION: ::DWORD = 0x00000002; +pub const SCH_CRED_V3: ::DWORD = 0x00000003; +pub const SCHANNEL_CRED_VERSION: ::DWORD = 0x00000004; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct _HMAPPER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCHANNEL_CRED { + pub dwVersion: ::DWORD, + pub cCreds: ::DWORD, + pub paCred: *mut ::PCCERT_CONTEXT, + pub hRootStore: ::HCERTSTORE, + pub cMappers: ::DWORD, + pub aphMappers: *mut *mut _HMAPPER, + pub cSupportedAlgs: ::DWORD, + pub palgSupportedAlgs: *mut ::ALG_ID, + pub grbitEnabledProtocols: ::DWORD, + pub dwMinimumCipherStrength: ::DWORD, + pub dwMaximumCipherStrength: ::DWORD, + pub dwSessionLifespan: ::DWORD, + pub dwFlags: ::DWORD, + pub dwCredFormat: ::DWORD, +} +pub type PSCHANNEL_CRED = *mut SCHANNEL_CRED; +pub const SCH_CRED_FORMAT_CERT_CONTEXT: ::DWORD = 0x00000000; +pub const SCH_CRED_FORMAT_CERT_HASH: ::DWORD = 0x00000001; +pub const SCH_CRED_FORMAT_CERT_HASH_STORE: ::DWORD = 0x00000002; + +pub const SCH_CRED_MAX_STORE_NAME_SIZE: usize = 128; +pub const SCH_CRED_MAX_SUPPORTED_ALGS: ::DWORD = 256; +pub const SCH_CRED_MAX_SUPPORTED_CERTS: ::DWORD = 100; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCHANNEL_CERT_HASH { + pub dwLength: ::DWORD, + pub dwFlags: ::DWORD, + pub hProv: ::HCRYPTPROV, + pub ShaHash: [::BYTE; 20], +} +pub type PSCHANNEL_CERT_HASH = *mut SCHANNEL_CERT_HASH; +#[repr(C)] #[derive(Copy)] +pub struct SCHANNEL_CERT_HASH_STORE { + pub dwLength: ::DWORD, + pub dwFlags: ::DWORD, + pub hProv: ::HCRYPTPROV, + pub ShaHash: [::BYTE; 20], + pub pwszStoreName: [::WCHAR; SCH_CRED_MAX_STORE_NAME_SIZE], +} +impl Clone for SCHANNEL_CERT_HASH_STORE { fn clone(&self) -> SCHANNEL_CERT_HASH_STORE { *self } } +pub type PSCHANNEL_CERT_HASH_STORE = *mut SCHANNEL_CERT_HASH_STORE; +pub const SCH_MACHINE_CERT_HASH: ::DWORD = 0x00000001; +pub const SCH_CRED_NO_SYSTEM_MAPPER: ::DWORD = 0x00000002; +pub const SCH_CRED_NO_SERVERNAME_CHECK: ::DWORD = 0x00000004; +pub const SCH_CRED_MANUAL_CRED_VALIDATION: ::DWORD = 0x00000008; +pub const SCH_CRED_NO_DEFAULT_CREDS: ::DWORD = 0x00000010; +pub const SCH_CRED_AUTO_CRED_VALIDATION: ::DWORD = 0x00000020; +pub const SCH_CRED_USE_DEFAULT_CREDS: ::DWORD = 0x00000040; +pub const SCH_CRED_DISABLE_RECONNECTS: ::DWORD = 0x00000080; +pub const SCH_CRED_REVOCATION_CHECK_END_CERT: ::DWORD = 0x00000100; +pub const SCH_CRED_REVOCATION_CHECK_CHAIN: ::DWORD = 0x00000200; +pub const SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT: ::DWORD = 0x00000400; +pub const SCH_CRED_IGNORE_NO_REVOCATION_CHECK: ::DWORD = 0x00000800; +pub const SCH_CRED_IGNORE_REVOCATION_OFFLINE: ::DWORD = 0x00001000; +pub const SCH_CRED_RESTRICTED_ROOTS: ::DWORD = 0x00002000; +pub const SCH_CRED_REVOCATION_CHECK_CACHE_ONLY: ::DWORD = 0x00004000; +pub const SCH_CRED_CACHE_ONLY_URL_RETRIEVAL: ::DWORD = 0x00008000; +pub const SCH_CRED_MEMORY_STORE_CERT: ::DWORD = 0x00010000; +pub const SCH_CRED_CACHE_ONLY_URL_RETRIEVAL_ON_CREATE: ::DWORD = 0x00020000; +pub const SCH_SEND_ROOT_CERT: ::DWORD = 0x00040000; +pub const SCH_CRED_SNI_CREDENTIAL: ::DWORD = 0x00080000; +pub const SCH_CRED_SNI_ENABLE_OCSP: ::DWORD = 0x00100000; +pub const SCH_SEND_AUX_RECORD: ::DWORD = 0x00200000; +pub const SCH_USE_STRONG_CRYPTO: ::DWORD = 0x00400000; +pub const SCHANNEL_RENEGOTIATE: ::DWORD = 0; +pub const SCHANNEL_SHUTDOWN: ::DWORD = 1; +pub const SCHANNEL_ALERT: ::DWORD = 2; +pub const SCHANNEL_SESSION: ::DWORD = 3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCHANNEL_ALERT_TOKEN { + pub dwTokenType: ::DWORD, + pub dwAlertType: ::DWORD, + pub dwAlertNumber: ::DWORD, +} +pub const TLS1_ALERT_WARNING: ::DWORD = 1; +pub const TLS1_ALERT_FATAL: ::DWORD = 2; +pub const TLS1_ALERT_CLOSE_NOTIFY: ::DWORD = 0; +pub const TLS1_ALERT_UNEXPECTED_MESSAGE: ::DWORD = 10; +pub const TLS1_ALERT_BAD_RECORD_MAC: ::DWORD = 20; +pub const TLS1_ALERT_DECRYPTION_FAILED: ::DWORD = 21; +pub const TLS1_ALERT_RECORD_OVERFLOW: ::DWORD = 22; +pub const TLS1_ALERT_DECOMPRESSION_FAIL: ::DWORD = 30; +pub const TLS1_ALERT_HANDSHAKE_FAILURE: ::DWORD = 40; +pub const TLS1_ALERT_BAD_CERTIFICATE: ::DWORD = 42; +pub const TLS1_ALERT_UNSUPPORTED_CERT: ::DWORD = 43; +pub const TLS1_ALERT_CERTIFICATE_REVOKED: ::DWORD = 44; +pub const TLS1_ALERT_CERTIFICATE_EXPIRED: ::DWORD = 45; +pub const TLS1_ALERT_CERTIFICATE_UNKNOWN: ::DWORD = 46; +pub const TLS1_ALERT_ILLEGAL_PARAMETER: ::DWORD = 47; +pub const TLS1_ALERT_UNKNOWN_CA: ::DWORD = 48; +pub const TLS1_ALERT_ACCESS_DENIED: ::DWORD = 49; +pub const TLS1_ALERT_DECODE_ERROR: ::DWORD = 50; +pub const TLS1_ALERT_DECRYPT_ERROR: ::DWORD = 51; +pub const TLS1_ALERT_EXPORT_RESTRICTION: ::DWORD = 60; +pub const TLS1_ALERT_PROTOCOL_VERSION: ::DWORD = 70; +pub const TLS1_ALERT_INSUFFIENT_SECURITY: ::DWORD = 71; +pub const TLS1_ALERT_INTERNAL_ERROR: ::DWORD = 80; +pub const TLS1_ALERT_USER_CANCELED: ::DWORD = 90; +pub const TLS1_ALERT_NO_RENEGOTIATION: ::DWORD = 100; +pub const TLS1_ALERT_UNSUPPORTED_EXT: ::DWORD = 110; +pub const TLS1_ALERT_NO_APP_PROTOCOL: ::DWORD = 120; +pub const SSL_SESSION_ENABLE_RECONNECTS: ::DWORD = 1; +pub const SSL_SESSION_DISABLE_RECONNECTS: ::DWORD = 2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCHANNEL_SESSION_TOKEN { + pub dwTokenType: ::DWORD, + pub dwFlags: ::DWORD, +} +#[repr(C)] #[derive(Copy)] +pub struct SCHANNEL_CLIENT_SIGNATURE { + pub cbLength: ::DWORD, + pub aiHash: ::ALG_ID, + pub cbHash: ::DWORD, + pub HashValue: [::BYTE; 36], + pub CertThumbprint: [::BYTE; 20], +} +impl Clone for SCHANNEL_CLIENT_SIGNATURE { fn clone(&self) -> SCHANNEL_CLIENT_SIGNATURE { *self } } +pub type PSCHANNEL_CLIENT_SIGNATURE = *mut SCHANNEL_CLIENT_SIGNATURE; +pub const SP_PROT_PCT1_SERVER: ::DWORD = 0x00000001; +pub const SP_PROT_PCT1_CLIENT: ::DWORD = 0x00000002; +pub const SP_PROT_PCT1: ::DWORD = SP_PROT_PCT1_SERVER | SP_PROT_PCT1_CLIENT; +pub const SP_PROT_SSL2_SERVER: ::DWORD = 0x00000004; +pub const SP_PROT_SSL2_CLIENT: ::DWORD = 0x00000008; +pub const SP_PROT_SSL2: ::DWORD = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT; +pub const SP_PROT_SSL3_SERVER: ::DWORD = 0x00000010; +pub const SP_PROT_SSL3_CLIENT: ::DWORD = 0x00000020; +pub const SP_PROT_SSL3: ::DWORD = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT; +pub const SP_PROT_TLS1_SERVER: ::DWORD = 0x00000040; +pub const SP_PROT_TLS1_CLIENT: ::DWORD = 0x00000080; +pub const SP_PROT_TLS1: ::DWORD = SP_PROT_TLS1_SERVER | SP_PROT_TLS1_CLIENT; +pub const SP_PROT_SSL3TLS1_CLIENTS: ::DWORD = SP_PROT_TLS1_CLIENT | SP_PROT_SSL3_CLIENT; +pub const SP_PROT_SSL3TLS1_SERVERS: ::DWORD = SP_PROT_TLS1_SERVER | SP_PROT_SSL3_SERVER; +pub const SP_PROT_SSL3TLS1: ::DWORD = SP_PROT_SSL3 | SP_PROT_TLS1; +pub const SP_PROT_UNI_SERVER: ::DWORD = 0x40000000; +pub const SP_PROT_UNI_CLIENT: ::DWORD = 0x80000000; +pub const SP_PROT_UNI: ::DWORD = SP_PROT_UNI_SERVER | SP_PROT_UNI_CLIENT; +pub const SP_PROT_ALL: ::DWORD = 0xffffffff; +pub const SP_PROT_NONE: ::DWORD = 0; +pub const SP_PROT_CLIENTS: ::DWORD = SP_PROT_PCT1_CLIENT | SP_PROT_SSL2_CLIENT + | SP_PROT_SSL3_CLIENT | SP_PROT_UNI_CLIENT | SP_PROT_TLS1_CLIENT; +pub const SP_PROT_SERVERS: ::DWORD = SP_PROT_PCT1_SERVER | SP_PROT_SSL2_SERVER + | SP_PROT_SSL3_SERVER | SP_PROT_UNI_SERVER | SP_PROT_TLS1_SERVER; +pub const SP_PROT_TLS1_0_SERVER: ::DWORD = SP_PROT_TLS1_SERVER; +pub const SP_PROT_TLS1_0_CLIENT: ::DWORD = SP_PROT_TLS1_CLIENT; +pub const SP_PROT_TLS1_0: ::DWORD = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT; +pub const SP_PROT_TLS1_1_SERVER: ::DWORD = 0x00000100; +pub const SP_PROT_TLS1_1_CLIENT: ::DWORD = 0x00000200; +pub const SP_PROT_TLS1_1: ::DWORD = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT; +pub const SP_PROT_TLS1_2_SERVER: ::DWORD = 0x00000400; +pub const SP_PROT_TLS1_2_CLIENT: ::DWORD = 0x00000800; +pub const SP_PROT_TLS1_2: ::DWORD = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT; +pub const SP_PROT_DTLS_SERVER: ::DWORD = 0x00010000; +pub const SP_PROT_DTLS_CLIENT: ::DWORD = 0x00020000; +pub const SP_PROT_DTLS: ::DWORD = SP_PROT_DTLS_SERVER | SP_PROT_DTLS_CLIENT; +pub const SP_PROT_DTLS1_0_SERVER: ::DWORD = SP_PROT_DTLS_SERVER; +pub const SP_PROT_DTLS1_0_CLIENT: ::DWORD = SP_PROT_DTLS_CLIENT; +pub const SP_PROT_DTLS1_0: ::DWORD = SP_PROT_DTLS1_0_SERVER | SP_PROT_DTLS1_0_CLIENT; +pub const SP_PROT_DTLS1_X_SERVER: ::DWORD = SP_PROT_DTLS1_0_SERVER; +pub const SP_PROT_DTLS1_X_CLIENT: ::DWORD = SP_PROT_DTLS1_0_CLIENT; +pub const SP_PROT_DTLS1_X: ::DWORD = SP_PROT_DTLS1_X_SERVER | SP_PROT_DTLS1_X_CLIENT; +pub const SP_PROT_TLS1_1PLUS_SERVER: ::DWORD = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_2_SERVER; +pub const SP_PROT_TLS1_1PLUS_CLIENT: ::DWORD = SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT; +pub const SP_PROT_TLS1_1PLUS: ::DWORD = SP_PROT_TLS1_1PLUS_SERVER | SP_PROT_TLS1_1PLUS_CLIENT; +pub const SP_PROT_TLS1_X_SERVER: ::DWORD = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_1_SERVER + | SP_PROT_TLS1_2_SERVER; +pub const SP_PROT_TLS1_X_CLIENT: ::DWORD = SP_PROT_TLS1_0_CLIENT | SP_PROT_TLS1_1_CLIENT + | SP_PROT_TLS1_2_CLIENT; +pub const SP_PROT_TLS1_X: ::DWORD = SP_PROT_TLS1_X_SERVER | SP_PROT_TLS1_X_CLIENT; +pub const SP_PROT_SSL3TLS1_X_CLIENTS: ::DWORD = SP_PROT_TLS1_X_CLIENT | SP_PROT_SSL3_CLIENT; +pub const SP_PROT_SSL3TLS1_X_SERVERS: ::DWORD = SP_PROT_TLS1_X_SERVER | SP_PROT_SSL3_SERVER; +pub const SP_PROT_SSL3TLS1_X: ::DWORD = SP_PROT_SSL3 | SP_PROT_TLS1_X; +pub const SP_PROT_X_CLIENTS: ::DWORD = SP_PROT_CLIENTS | SP_PROT_TLS1_X_CLIENT + | SP_PROT_DTLS1_X_CLIENT; +pub const SP_PROT_X_SERVERS: ::DWORD = SP_PROT_SERVERS | SP_PROT_TLS1_X_SERVER + | SP_PROT_DTLS1_X_SERVER; +//716 +pub const SCHANNEL_SECRET_TYPE_CAPI: ::DWORD = 0x00000001; +pub const SCHANNEL_SECRET_PRIVKEY: ::DWORD = 0x00000002; +pub const SCH_CRED_X509_CERTCHAIN: ::DWORD = 0x00000001; +pub const SCH_CRED_X509_CAPI: ::DWORD = 0x00000002; +pub const SCH_CRED_CERT_CONTEXT: ::DWORD = 0x00000003; +//838 +pub const SSL_CRACK_CERTIFICATE_NAME: &'static str = "SslCrackCertificate"; +pub const SSL_FREE_CERTIFICATE_NAME: &'static str = "SslFreeCertificate"; diff --git a/deps/winapi-0.1.23/src/shellapi.rs b/deps/winapi-0.1.23/src/shellapi.rs new file mode 100644 index 000000000..d1b752850 --- /dev/null +++ b/deps/winapi-0.1.23/src/shellapi.rs @@ -0,0 +1,6 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> + +// STUB + +DECLARE_HANDLE!(HDROP, HDROP__); diff --git a/deps/winapi-0.1.23/src/shobjidl.rs b/deps/winapi-0.1.23/src/shobjidl.rs new file mode 100644 index 000000000..8840a5187 --- /dev/null +++ b/deps/winapi-0.1.23/src/shobjidl.rs @@ -0,0 +1,224 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +//4498 +pub type SFGAOF = ::ULONG; +//9466 +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum SIGDN { + NORMALDISPLAY = 0, + PARENTRELATIVEPARSING = 0x80018001u32 as i32, + DESKTOPABSOLUTEPARSING = 0x80028000u32 as i32, + PARENTRELATIVEEDITING = 0x80031001u32 as i32, + DESKTOPABSOLUTEEDITING = 0x8004c000u32 as i32, + FILESYSPATH = 0x80058000u32 as i32, + URL = 0x80068000u32 as i32, + PARENTRELATIVEFORADDRESSBAR = 0x8007c001u32 as i32, + PARENTRELATIVE = 0x80080001u32 as i32, + PARENTRELATIVEFORUI = 0x80094001u32 as i32, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum SICHINTF { + DISPLAY = 0, + ALLFIELDS = 0x80000000u32 as i32, + CANONICAL = 0x10000000, + TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000, +} +//9498 +RIDL!( +interface IShellItem(IShellItemVtbl): IUnknown(IUnknownVtbl) { + fn BindToHandler( + &mut self, pbc: *mut ::IBindCtx, bhid: ::REFGUID, riid: ::REFIID, ppv: *mut *mut ::c_void + ) -> ::HRESULT, + fn GetParent(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, + fn GetDisplayName(&mut self, sigdnName: SIGDN, ppszName: *mut ::LPWSTR) -> ::HRESULT, + fn GetAttributes(&mut self, sfgaoMask: SFGAOF, psfgaoAttribs: *mut SFGAOF) -> ::HRESULT, + fn Compare(&mut self, psi: *mut IShellItem, hint: SICHINTF, piOrder: *mut ::c_int) -> ::HRESULT +} +); +//11963 +pub type IFileOperationProgressSink = ::IUnknown; // TODO +pub type IShellItemArray = ::IUnknown; // TODO +//20869 +RIDL!( +interface IModalWindow(IModalWindowVtbl): IUnknown(IUnknownVtbl) { + fn Show(&mut self, hwndOwner: ::HWND) -> ::HRESULT +} +); +//22307 +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum FDE_OVERWRITE_RESPONSE { + DEFAULT = 0, + ACCEPT = 1, + REFUSE = 2, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum FDE_SHAREVIOLATION_RESPONSE { + DEFAULT = 0, + ACCEPT = 1, + REFUSE = 2, +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum FDAP { + BOTTOM = 0, + TOP = 1, +} +RIDL!( +interface IFileDialogEvents(IFileDialogEventsVtbl): IUnknown(IUnknownVtbl) { + fn OnFileOk(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, + fn OnFolderChanging(&mut self, pfd: *mut IFileDialog, psiFolder: *mut IShellItem) -> ::HRESULT, + fn OnFolderChange(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, + fn OnSelectionChange(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, + fn OnShareViolation( + &mut self, pfd: *mut IFileDialog, psi: *mut IShellItem, + pResponse: *mut FDE_SHAREVIOLATION_RESPONSE + ) -> ::HRESULT, + fn OnTypeChange(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, + fn OnOverwrite( + &mut self, pfd: *mut IFileDialog, psi: *mut IShellItem, + pResponse: *mut FDE_OVERWRITE_RESPONSE + ) -> ::HRESULT +} +); +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum FILEOPENDIALOGOPTIONS { + OVERWRITEPROMPT = 0x2, + STRICTFILETYPES = 0x4, + NOCHANGEDIR = 0x8, + PICKFOLDERS = 0x20, + FORCEFILESYSTEM = 0x40, + ALLNONSTORAGEITEMS = 0x80, + NOVALIDATE = 0x100, + ALLOWMULTISELECT = 0x200, + PATHMUSTEXIST = 0x800, + FILEMUSTEXIST = 0x1000, + CREATEPROMPT = 0x2000, + SHAREAWARE = 0x4000, + NOREADONLYRETURN = 0x8000, + NOTESTFILECREATE = 0x10000, + HIDEMRUPLACES = 0x20000, + HIDEPINNEDPLACES = 0x40000, + NODEREFERENCELINKS = 0x100000, + DONTADDTORECENT = 0x2000000, + FORCESHOWHIDDEN = 0x10000000, + DEFAULTNOMINIMODE = 0x20000000, + FORCEPREVIEWPANEON = 0x40000000, + SUPPORTSTREAMABLEITEMS = 0x80000000u32 as i32, +} +RIDL!( +interface IFileDialog(IFileDialogVtbl): IModalWindow(IModalWindowVtbl) { + fn SetFileTypes( + &mut self, cFileTypes: ::UINT, rgFilterSpec: *const ::COMDLG_FILTERSPEC + ) -> ::HRESULT, + fn SetFileTypeIndex(&mut self, iFileType: ::UINT) -> ::HRESULT, + fn GetFileTypeIndex(&mut self, piFileType: *mut ::UINT) -> ::HRESULT, + fn Advise(&mut self, pfde: *mut IFileDialogEvents, pdwCookie: *mut ::DWORD) -> ::HRESULT, + fn Unadvise(&mut self, dwCookie: ::DWORD) -> ::HRESULT, + fn SetOptions(&mut self, fos: FILEOPENDIALOGOPTIONS) -> ::HRESULT, + fn GetOptions(&mut self, pfos: *mut FILEOPENDIALOGOPTIONS) -> ::HRESULT, + fn SetDefaultFolder(&mut self, psi: *mut IShellItem) -> ::HRESULT, + fn SetFolder(&mut self, psi: *mut IShellItem) -> ::HRESULT, + fn GetFolder(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, + fn GetCurrentSelection(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, + fn SetFileName(&mut self, pszName: ::LPCWSTR) -> ::HRESULT, + fn GetFileName(&mut self, pszName: *mut ::LPWSTR) -> ::HRESULT, + fn SetTitle(&mut self, pszTitle: ::LPCWSTR) -> ::HRESULT, + fn SetOkButtonLabel(&mut self, pszText: ::LPCWSTR) -> ::HRESULT, + fn SetFileNameLabel(&mut self, pszLabel: ::LPCWSTR) -> ::HRESULT, + fn GetResult(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, + fn AddPlace(&mut self, psi: *mut IShellItem, fdap: FDAP) -> ::HRESULT, + fn SetDefaultExtension(&mut self, pszDefaultExtension: ::LPCWSTR) -> ::HRESULT, + fn Close(&mut self, hr: ::HRESULT) -> ::HRESULT, + fn SetClientGuid(&mut self, guid: ::REFGUID) -> ::HRESULT, + fn ClearClientData(&mut self) -> ::HRESULT, + fn SetFilter(&mut self, pFilter: *mut IShellItemFilter) -> ::HRESULT +} +); +RIDL!( +interface IFileSaveDialog(IFileSaveDialogVtbl): IFileDialog(IFileDialogVtbl) { + fn SetSaveAsItem(&mut self, psi: *mut IShellItem) -> ::HRESULT, + fn SetProperties(&mut self, pStore: *mut ::IPropertyStore) -> ::HRESULT, + fn SetCollectedProperties( + &mut self, pList: *mut ::IPropertyDescriptionList, fAppendDefault: ::BOOL + ) -> ::HRESULT, + fn GetProperties(&mut self, ppStore: *mut *mut ::IPropertyStore) -> ::HRESULT, + fn ApplyProperties( + &mut self, psi: *mut IShellItem, pStore: *mut ::IPropertyStore, hwnd: ::HWND, + pSink: *mut IFileOperationProgressSink + ) -> ::HRESULT +} +); +RIDL!( +interface IFileOpenDialog(IFileOpenDialogVtbl): IFileDialog(IFileDialogVtbl) { + fn GetResults(&mut self, ppenum: *mut *mut IShellItemArray) -> ::HRESULT, + fn GetSelectedItems(&mut self, ppsai: *mut *mut IShellItemArray) -> ::HRESULT +} +); +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum CDCONTROLSTATEF { + INACTIVE = 0x00000000, + ENABLED = 0x00000001, + VISIBLE = 0x00000002, + ENABLEDVISIBLE = 0x00000003, +} +RIDL!( +interface IFileDialogCustomize(IFileDialogCustomizeVtbl): IUnknown(IUnknownVtbl) { + fn EnableOpenDropDown(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, + fn AddMenu(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, + fn AddPushButton(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, + fn AddComboBox(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, + fn AddRadioButtonList(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, + fn AddCheckButton( + &mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR, bChecked: ::BOOL + ) -> ::HRESULT, + fn AddEditBox(&mut self, dwIDCtl: ::DWORD, pszText: ::LPCWSTR) -> ::HRESULT, + fn AddSeparator(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, + fn AddText(&mut self, dwIDCtl: ::DWORD, pszText: ::LPCWSTR) -> ::HRESULT, + fn SetControlLabel(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, + fn GetControlState(&mut self, dwIDCtl: ::DWORD, pdwState: *mut CDCONTROLSTATEF) -> ::HRESULT, + fn SetControlState(&mut self, dwIDCtl: ::DWORD, dwState: CDCONTROLSTATEF) -> ::HRESULT, + fn GetEditBoxText(&mut self, dwIDCtl: ::DWORD, ppszText: *mut *mut ::WCHAR) -> ::HRESULT, + fn SetEditBoxText(&mut self, dwIDCtl: ::DWORD, pszText: ::LPCWSTR) -> ::HRESULT, + fn GetCheckButtonState(&mut self, dwIDCtl: ::DWORD, pbChecked: *mut ::BOOL) -> ::HRESULT, + fn SetCheckButtonState(&mut self, dwIDCtl: ::DWORD, bChecked: ::BOOL) -> ::HRESULT, + fn AddControlItem( + &mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, pszLabel: ::LPCWSTR + ) -> ::HRESULT, + fn RemoveControlItem(&mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD) -> ::HRESULT, + fn RemoveAllControlItems(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, + fn GetControlItemState( + &mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, pdwState: *mut CDCONTROLSTATEF + ) -> ::HRESULT, + fn SetControlItemState( + &mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, dwState: CDCONTROLSTATEF + ) -> ::HRESULT, + fn GetSelectedControlItem(&mut self, dwIDCtl: ::DWORD, pdwIDItem: *mut ::DWORD) -> ::HRESULT, + fn SetSelectedControlItem(&mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD) -> ::HRESULT, + fn StartVisualGroup(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, + fn EndVisualGroup(&mut self) -> ::HRESULT, + fn MakeProminent(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, + fn SetControlItemText(&mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT +} +); +RIDL!( +interface IFileDialogControlEvents(IFileDialogControlEventsVtbl): IUnknown(IUnknownVtbl) { + fn OnItemSelected( + &mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD, dwIDItem: ::DWORD + ) -> ::HRESULT, + fn OnButtonClicked(&mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD) -> ::HRESULT, + fn OnCheckButtonToggled( + &mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD, bChecked: ::BOOL + ) -> ::HRESULT, + fn OnControlActivating( + &mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD + ) -> ::HRESULT +} +); +RIDL!( +interface IFileDialog2(IFileDialog2Vtbl): IFileDialog(IFileDialogVtbl) { + fn SetCancelButtonLabel(&mut self, pszLabel: ::LPCWSTR) -> ::HRESULT, + fn SetNavigationRoot(&mut self, psi: IShellItem) -> ::HRESULT +} +); +//27457 +pub type IShellItemFilter = ::IUnknown; // TODO diff --git a/deps/winapi-0.1.23/src/shtypes.rs b/deps/winapi-0.1.23/src/shtypes.rs new file mode 100644 index 000000000..400929813 --- /dev/null +++ b/deps/winapi-0.1.23/src/shtypes.rs @@ -0,0 +1,41 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct SHITEMID { + pub cb: ::USHORT, + pub abID: [::BYTE; 0], +} +pub type LPSHITEMID = *mut SHITEMID; +pub type LPCSHITEMID = *const SHITEMID; +#[repr(C)] #[derive(Debug)] +pub struct ITEMIDLIST { + pub mkid: SHITEMID, +} +pub type ITEMIDLIST_RELATIVE = ITEMIDLIST; +pub type ITEMID_CHILD = ITEMIDLIST; +pub type ITEMIDLIST_ABSOLUTE = ITEMIDLIST; +pub type LPITEMIDLIST = *mut ITEMIDLIST; +pub type LPCITEMIDLIST = *const ITEMIDLIST; +pub type PIDLIST_ABSOLUTE = *mut ITEMIDLIST_ABSOLUTE; +pub type PCIDLIST_ABSOLUTE = *const ITEMIDLIST_ABSOLUTE; +pub type PCUIDLIST_ABSOLUTE = *const ITEMIDLIST_ABSOLUTE; +pub type PIDLIST_RELATIVE = *mut ITEMIDLIST_RELATIVE; +pub type PCIDLIST_RELATIVE = *const ITEMIDLIST_RELATIVE; +pub type PUIDLIST_RELATIVE = *mut ITEMIDLIST_RELATIVE; +pub type PCUIDLIST_RELATIVE = *const ITEMIDLIST_RELATIVE; +pub type PITEMID_CHILD = *mut ITEMID_CHILD; +pub type PCITEMID_CHILD = *const ITEMID_CHILD; +pub type PUITEMID_CHILD = *mut ITEMID_CHILD; +pub type PCUITEMID_CHILD = *const ITEMID_CHILD; +pub type PCUITEMID_CHILD_ARRAY = *const PCUITEMID_CHILD; +pub type PCUIDLIST_RELATIVE_ARRAY = *const PCUIDLIST_RELATIVE; +pub type PCIDLIST_ABSOLUTE_ARRAY = *const PCIDLIST_ABSOLUTE; +pub type PCUIDLIST_ABSOLUTE_ARRAY = *const PCUIDLIST_ABSOLUTE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct COMDLG_FILTERSPEC { + pub pszName: ::LPCWSTR, + pub pszSpec: ::LPCWSTR, +} +pub type KNOWNFOLDERID = ::GUID; +pub type REFKNOWNFOLDERID = *const KNOWNFOLDERID; diff --git a/deps/winapi-0.1.23/src/sspi.rs b/deps/winapi-0.1.23/src/sspi.rs new file mode 100644 index 000000000..5f17f940f --- /dev/null +++ b/deps/winapi-0.1.23/src/sspi.rs @@ -0,0 +1,663 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Security Support Provider Interface Prototypes and structure definitions +pub type SEC_WCHAR = ::WCHAR; +pub type SEC_CHAR = ::CHAR; +pub type SECURITY_STATUS = ::LONG; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecHandle { + pub dwLower: ::ULONG_PTR, + pub dwUpper: ::ULONG_PTR, +} +pub type PSecHandle = *mut SecHandle; +pub const SEC_DELETED_HANDLE: ::ULONG_PTR = 2; +pub type CredHandle = SecHandle; +pub type PCredHandle = PSecHandle; +pub type CtxtHandle = SecHandle; +pub type PCtxtHandle = PSecHandle; +pub type SECURITY_INTEGER = ::LARGE_INTEGER; +pub type PSECURITY_INTEGER = *mut ::LARGE_INTEGER; +pub type TimeStamp = SECURITY_INTEGER; +pub type PTimeStamp = *mut SECURITY_INTEGER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SECURITY_STRING { + pub Length: ::c_ushort, + pub MaximumLength: ::c_ushort, + pub Buffer: *mut ::c_ushort, +} +pub type PSECURITY_STRING = *mut SECURITY_STRING; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgInfoW { + pub fCapabilities: ::c_ulong, + pub wVersion: ::c_ushort, + pub wRPCID: ::c_ushort, + pub cbMaxToken: ::c_ulong, + pub Name: *mut SEC_WCHAR, + pub Comment: *mut SEC_WCHAR, +} +pub type PSecPkgInfoW = *mut SecPkgInfoW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgInfoA { + pub fCapabilities: ::c_ulong, + pub wVersion: ::c_ushort, + pub wRPCID: ::c_ushort, + pub cbMaxToken: ::c_ulong, + pub Name: *mut SEC_CHAR, + pub Comment: *mut SEC_CHAR, +} +pub type PSecPkgInfoA = *mut SecPkgInfoA; +pub const SECPKG_FLAG_INTEGRITY: ::c_ulong = 0x00000001; +pub const SECPKG_FLAG_PRIVACY: ::c_ulong = 0x00000002; +pub const SECPKG_FLAG_TOKEN_ONLY: ::c_ulong = 0x00000004; +pub const SECPKG_FLAG_DATAGRAM: ::c_ulong = 0x00000008; +pub const SECPKG_FLAG_CONNECTION: ::c_ulong = 0x00000010; +pub const SECPKG_FLAG_MULTI_REQUIRED: ::c_ulong = 0x00000020; +pub const SECPKG_FLAG_CLIENT_ONLY: ::c_ulong = 0x00000040; +pub const SECPKG_FLAG_EXTENDED_ERROR: ::c_ulong = 0x00000080; +pub const SECPKG_FLAG_IMPERSONATION: ::c_ulong = 0x00000100; +pub const SECPKG_FLAG_ACCEPT_WIN32_NAME: ::c_ulong = 0x00000200; +pub const SECPKG_FLAG_STREAM: ::c_ulong = 0x00000400; +pub const SECPKG_FLAG_NEGOTIABLE: ::c_ulong = 0x00000800; +pub const SECPKG_FLAG_GSS_COMPATIBLE: ::c_ulong = 0x00001000; +pub const SECPKG_FLAG_LOGON: ::c_ulong = 0x00002000; +pub const SECPKG_FLAG_ASCII_BUFFERS: ::c_ulong = 0x00004000; +pub const SECPKG_FLAG_FRAGMENT: ::c_ulong = 0x00008000; +pub const SECPKG_FLAG_MUTUAL_AUTH: ::c_ulong = 0x00010000; +pub const SECPKG_FLAG_DELEGATION: ::c_ulong = 0x00020000; +pub const SECPKG_FLAG_READONLY_WITH_CHECKSUM: ::c_ulong = 0x00040000; +pub const SECPKG_FLAG_RESTRICTED_TOKENS: ::c_ulong = 0x00080000; +pub const SECPKG_FLAG_NEGO_EXTENDER: ::c_ulong = 0x00100000; +pub const SECPKG_FLAG_NEGOTIABLE2: ::c_ulong = 0x00200000; +pub const SECPKG_FLAG_APPCONTAINER_PASSTHROUGH: ::c_ulong = 0x00400000; +pub const SECPKG_FLAG_APPCONTAINER_CHECKS: ::c_ulong = 0x00800000; +pub const SECPKG_ID_NONE: ::c_ulong = 0xFFFF; +pub const SECPKG_CALLFLAGS_APPCONTAINER: ::c_ulong = 0x00000001; +pub const SECPKG_CALLFLAGS_APPCONTAINER_AUTHCAPABLE: ::c_ulong = 0x00000002; +pub const SECPKG_CALLFLAGS_FORCE_SUPPLIED: ::c_ulong = 0x00000004; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecBuffer { + pub cbBuffer: ::c_ulong, + pub BufferType: ::c_ulong, + pub pvBuffer: *mut ::c_void, +} +pub type PSecBuffer = *mut SecBuffer; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecBufferDesc { + pub ulVersion: ::c_ulong, + pub cBuffers: ::c_ulong, + pub pBuffers: PSecBuffer, +} +pub type PSecBufferDesc = *mut SecBufferDesc; +pub const SECBUFFER_VERSION: ::c_ulong = 0; +pub const SECBUFFER_EMPTY: ::c_ulong = 0; +pub const SECBUFFER_DATA: ::c_ulong = 1; +pub const SECBUFFER_TOKEN: ::c_ulong = 2; +pub const SECBUFFER_PKG_PARAMS: ::c_ulong = 3; +pub const SECBUFFER_MISSING: ::c_ulong = 4; +pub const SECBUFFER_EXTRA: ::c_ulong = 5; +pub const SECBUFFER_STREAM_TRAILER: ::c_ulong = 6; +pub const SECBUFFER_STREAM_HEADER: ::c_ulong = 7; +pub const SECBUFFER_NEGOTIATION_INFO: ::c_ulong = 8; +pub const SECBUFFER_PADDING: ::c_ulong = 9; +pub const SECBUFFER_STREAM: ::c_ulong = 10; +pub const SECBUFFER_MECHLIST: ::c_ulong = 11; +pub const SECBUFFER_MECHLIST_SIGNATURE: ::c_ulong = 12; +pub const SECBUFFER_TARGET: ::c_ulong = 13; +pub const SECBUFFER_CHANNEL_BINDINGS: ::c_ulong = 14; +pub const SECBUFFER_CHANGE_PASS_RESPONSE: ::c_ulong = 15; +pub const SECBUFFER_TARGET_HOST: ::c_ulong = 16; +pub const SECBUFFER_ALERT: ::c_ulong = 17; +pub const SECBUFFER_APPLICATION_PROTOCOLS: ::c_ulong = 18; +pub const SECBUFFER_ATTRMASK: ::c_ulong = 0xF0000000; +pub const SECBUFFER_READONLY: ::c_ulong = 0x80000000; +pub const SECBUFFER_READONLY_WITH_CHECKSUM: ::c_ulong = 0x10000000; +pub const SECBUFFER_RESERVED: ::c_ulong = 0x60000000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SEC_NEGOTIATION_INFO { + pub Size: ::c_ulong, + pub NameLength: ::c_ulong, + pub Name: *mut SEC_WCHAR, + pub Reserved: *mut ::c_void, +} +pub type PSEC_NEGOTIATION_INFO = *mut SEC_NEGOTIATION_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SEC_CHANNEL_BINDINGS { + pub dwInitiatorAddrType: ::c_ulong, + pub cbInitiatorLength: ::c_ulong, + pub dwInitiatorOffset: ::c_ulong, + pub dwAcceptorAddrType: ::c_ulong, + pub cbAcceptorLength: ::c_ulong, + pub dwAcceptorOffset: ::c_ulong, + pub cbApplicationDataLength: ::c_ulong, + pub dwApplicationDataOffset: ::c_ulong, +} +pub type PSEC_CHANNEL_BINDINGS = *mut SEC_CHANNEL_BINDINGS; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT { + SecApplicationProtocolNegotiationExt_None, + SecApplicationProtocolNegotiationExt_NPN, + SecApplicationProtocolNegotiationExt_ALPN, +} +pub use self::SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT::*; +pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT = *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SEC_APPLICATION_PROTOCOL_LIST { + pub ProtoNegoExt: ::SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT, + pub ProtocolListSize: ::c_ushort, + pub ProtocolList: [::c_uchar; 0], +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SEC_APPLICATION_PROTOCOLS { + pub ProtocolListsSize: ::c_ulong, + pub ProtocolLists: [SEC_APPLICATION_PROTOCOL_LIST; 0], +} +pub type PSEC_APPLICATION_PROTOCOLS = *mut SEC_APPLICATION_PROTOCOLS; +pub const SECURITY_NATIVE_DREP: ::c_ulong = 0x00000010; +pub const SECURITY_NETWORK_DREP: ::c_ulong = 0x00000000; +pub const SECPKG_CRED_INBOUND: ::c_ulong = 0x00000001; +pub const SECPKG_CRED_OUTBOUND: ::c_ulong = 0x00000002; +pub const SECPKG_CRED_BOTH: ::c_ulong = 0x00000003; +pub const SECPKG_CRED_DEFAULT: ::c_ulong = 0x00000004; +pub const SECPKG_CRED_RESERVED: ::c_ulong = 0xF0000000; +pub const SECPKG_CRED_AUTOLOGON_RESTRICTED: ::c_ulong = 0x00000010; +pub const SECPKG_CRED_PROCESS_POLICY_ONLY: ::c_ulong = 0x00000020; +pub const ISC_REQ_DELEGATE: ::c_ulong = 0x00000001; +pub const ISC_REQ_MUTUAL_AUTH: ::c_ulong = 0x00000002; +pub const ISC_REQ_REPLAY_DETECT: ::c_ulong = 0x00000004; +pub const ISC_REQ_SEQUENCE_DETECT: ::c_ulong = 0x00000008; +pub const ISC_REQ_CONFIDENTIALITY: ::c_ulong = 0x00000010; +pub const ISC_REQ_USE_SESSION_KEY: ::c_ulong = 0x00000020; +pub const ISC_REQ_PROMPT_FOR_CREDS: ::c_ulong = 0x00000040; +pub const ISC_REQ_USE_SUPPLIED_CREDS: ::c_ulong = 0x00000080; +pub const ISC_REQ_ALLOCATE_MEMORY: ::c_ulong = 0x00000100; +pub const ISC_REQ_USE_DCE_STYLE: ::c_ulong = 0x00000200; +pub const ISC_REQ_DATAGRAM: ::c_ulong = 0x00000400; +pub const ISC_REQ_CONNECTION: ::c_ulong = 0x00000800; +pub const ISC_REQ_CALL_LEVEL: ::c_ulong = 0x00001000; +pub const ISC_REQ_FRAGMENT_SUPPLIED: ::c_ulong = 0x00002000; +pub const ISC_REQ_EXTENDED_ERROR: ::c_ulong = 0x00004000; +pub const ISC_REQ_STREAM: ::c_ulong = 0x00008000; +pub const ISC_REQ_INTEGRITY: ::c_ulong = 0x00010000; +pub const ISC_REQ_IDENTIFY: ::c_ulong = 0x00020000; +pub const ISC_REQ_NULL_SESSION: ::c_ulong = 0x00040000; +pub const ISC_REQ_MANUAL_CRED_VALIDATION: ::c_ulong = 0x00080000; +pub const ISC_REQ_RESERVED1: ::c_ulong = 0x00100000; +pub const ISC_REQ_FRAGMENT_TO_FIT: ::c_ulong = 0x00200000; +pub const ISC_REQ_FORWARD_CREDENTIALS: ::c_ulong = 0x00400000; +pub const ISC_REQ_NO_INTEGRITY: ::c_ulong = 0x00800000; +pub const ISC_REQ_USE_HTTP_STYLE: ::c_ulong = 0x01000000; +pub const ISC_REQ_UNVERIFIED_TARGET_NAME: ::c_ulong = 0x20000000; +pub const ISC_REQ_CONFIDENTIALITY_ONLY: ::c_ulong = 0x40000000; +pub const ISC_RET_DELEGATE: ::c_ulong = 0x00000001; +pub const ISC_RET_MUTUAL_AUTH: ::c_ulong = 0x00000002; +pub const ISC_RET_REPLAY_DETECT: ::c_ulong = 0x00000004; +pub const ISC_RET_SEQUENCE_DETECT: ::c_ulong = 0x00000008; +pub const ISC_RET_CONFIDENTIALITY: ::c_ulong = 0x00000010; +pub const ISC_RET_USE_SESSION_KEY: ::c_ulong = 0x00000020; +pub const ISC_RET_USED_COLLECTED_CREDS: ::c_ulong = 0x00000040; +pub const ISC_RET_USED_SUPPLIED_CREDS: ::c_ulong = 0x00000080; +pub const ISC_RET_ALLOCATED_MEMORY: ::c_ulong = 0x00000100; +pub const ISC_RET_USED_DCE_STYLE: ::c_ulong = 0x00000200; +pub const ISC_RET_DATAGRAM: ::c_ulong = 0x00000400; +pub const ISC_RET_CONNECTION: ::c_ulong = 0x00000800; +pub const ISC_RET_INTERMEDIATE_RETURN: ::c_ulong = 0x00001000; +pub const ISC_RET_CALL_LEVEL: ::c_ulong = 0x00002000; +pub const ISC_RET_EXTENDED_ERROR: ::c_ulong = 0x00004000; +pub const ISC_RET_STREAM: ::c_ulong = 0x00008000; +pub const ISC_RET_INTEGRITY: ::c_ulong = 0x00010000; +pub const ISC_RET_IDENTIFY: ::c_ulong = 0x00020000; +pub const ISC_RET_NULL_SESSION: ::c_ulong = 0x00040000; +pub const ISC_RET_MANUAL_CRED_VALIDATION: ::c_ulong = 0x00080000; +pub const ISC_RET_RESERVED1: ::c_ulong = 0x00100000; +pub const ISC_RET_FRAGMENT_ONLY: ::c_ulong = 0x00200000; +pub const ISC_RET_FORWARD_CREDENTIALS: ::c_ulong = 0x00400000; +pub const ISC_RET_USED_HTTP_STYLE: ::c_ulong = 0x01000000; +pub const ISC_RET_NO_ADDITIONAL_TOKEN: ::c_ulong = 0x02000000; +pub const ISC_RET_REAUTHENTICATION: ::c_ulong = 0x08000000; +pub const ISC_RET_CONFIDENTIALITY_ONLY: ::c_ulong = 0x40000000; +pub const ASC_REQ_DELEGATE: ::c_ulong = 0x00000001; +pub const ASC_REQ_MUTUAL_AUTH: ::c_ulong = 0x00000002; +pub const ASC_REQ_REPLAY_DETECT: ::c_ulong = 0x00000004; +pub const ASC_REQ_SEQUENCE_DETECT: ::c_ulong = 0x00000008; +pub const ASC_REQ_CONFIDENTIALITY: ::c_ulong = 0x00000010; +pub const ASC_REQ_USE_SESSION_KEY: ::c_ulong = 0x00000020; +pub const ASC_REQ_SESSION_TICKET: ::c_ulong = 0x00000040; +pub const ASC_REQ_ALLOCATE_MEMORY: ::c_ulong = 0x00000100; +pub const ASC_REQ_USE_DCE_STYLE: ::c_ulong = 0x00000200; +pub const ASC_REQ_DATAGRAM: ::c_ulong = 0x00000400; +pub const ASC_REQ_CONNECTION: ::c_ulong = 0x00000800; +pub const ASC_REQ_CALL_LEVEL: ::c_ulong = 0x00001000; +pub const ASC_REQ_EXTENDED_ERROR: ::c_ulong = 0x00008000; +pub const ASC_REQ_STREAM: ::c_ulong = 0x00010000; +pub const ASC_REQ_INTEGRITY: ::c_ulong = 0x00020000; +pub const ASC_REQ_LICENSING: ::c_ulong = 0x00040000; +pub const ASC_REQ_IDENTIFY: ::c_ulong = 0x00080000; +pub const ASC_REQ_ALLOW_NULL_SESSION: ::c_ulong = 0x00100000; +pub const ASC_REQ_ALLOW_NON_USER_LOGONS: ::c_ulong = 0x00200000; +pub const ASC_REQ_ALLOW_CONTEXT_REPLAY: ::c_ulong = 0x00400000; +pub const ASC_REQ_FRAGMENT_TO_FIT: ::c_ulong = 0x00800000; +pub const ASC_REQ_FRAGMENT_SUPPLIED: ::c_ulong = 0x00002000; +pub const ASC_REQ_NO_TOKEN: ::c_ulong = 0x01000000; +pub const ASC_REQ_PROXY_BINDINGS: ::c_ulong = 0x04000000; +pub const ASC_REQ_ALLOW_MISSING_BINDINGS: ::c_ulong = 0x10000000; +pub const ASC_RET_DELEGATE: ::c_ulong = 0x00000001; +pub const ASC_RET_MUTUAL_AUTH: ::c_ulong = 0x00000002; +pub const ASC_RET_REPLAY_DETECT: ::c_ulong = 0x00000004; +pub const ASC_RET_SEQUENCE_DETECT: ::c_ulong = 0x00000008; +pub const ASC_RET_CONFIDENTIALITY: ::c_ulong = 0x00000010; +pub const ASC_RET_USE_SESSION_KEY: ::c_ulong = 0x00000020; +pub const ASC_RET_SESSION_TICKET: ::c_ulong = 0x00000040; +pub const ASC_RET_ALLOCATED_MEMORY: ::c_ulong = 0x00000100; +pub const ASC_RET_USED_DCE_STYLE: ::c_ulong = 0x00000200; +pub const ASC_RET_DATAGRAM: ::c_ulong = 0x00000400; +pub const ASC_RET_CONNECTION: ::c_ulong = 0x00000800; +pub const ASC_RET_CALL_LEVEL: ::c_ulong = 0x00002000; +pub const ASC_RET_THIRD_LEG_FAILED: ::c_ulong = 0x00004000; +pub const ASC_RET_EXTENDED_ERROR: ::c_ulong = 0x00008000; +pub const ASC_RET_STREAM: ::c_ulong = 0x00010000; +pub const ASC_RET_INTEGRITY: ::c_ulong = 0x00020000; +pub const ASC_RET_LICENSING: ::c_ulong = 0x00040000; +pub const ASC_RET_IDENTIFY: ::c_ulong = 0x00080000; +pub const ASC_RET_NULL_SESSION: ::c_ulong = 0x00100000; +pub const ASC_RET_ALLOW_NON_USER_LOGONS: ::c_ulong = 0x00200000; +pub const ASC_RET_ALLOW_CONTEXT_REPLAY: ::c_ulong = 0x00400000; +pub const ASC_RET_FRAGMENT_ONLY: ::c_ulong = 0x00800000; +pub const ASC_RET_NO_TOKEN: ::c_ulong = 0x01000000; +pub const ASC_RET_NO_ADDITIONAL_TOKEN: ::c_ulong = 0x02000000; +pub const SECPKG_CRED_ATTR_NAMES: ::c_ulong = 1; +pub const SECPKG_CRED_ATTR_SSI_PROVIDER: ::c_ulong = 2; +pub const SECPKG_CRED_ATTR_KDC_PROXY_SETTINGS: ::c_ulong = 3; +pub const SECPKG_CRED_ATTR_CERT: ::c_ulong = 4; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgCredentials_NamesW { + pub sUserName: *mut SEC_WCHAR, +} +pub type PSecPkgCredentials_NamesW = *mut SecPkgCredentials_NamesW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgCredentials_NamesA { + pub sUserName: *mut SEC_CHAR, +} +pub type PSecPkgCredentials_NamesA = *mut SecPkgCredentials_NamesA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgCredentials_SSIProviderW { + pub sProviderName: *mut SEC_WCHAR, + pub ProviderInfoLength: ::c_ulong, + pub ProviderInfo: *mut ::c_char, +} +pub type PSecPkgCredentials_SSIProviderW = *mut SecPkgCredentials_SSIProviderW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgCredentials_SSIProviderA { + pub sProviderName: *mut SEC_CHAR, + pub ProviderInfoLength: ::c_ulong, + pub ProviderInfo: *mut ::c_char, +} +pub type PSecPkgCredentials_SSIProviderA = *mut SecPkgCredentials_SSIProviderA; +pub const KDC_PROXY_SETTINGS_V1: ::ULONG = 1; +pub const KDC_PROXY_SETTINGS_FLAGS_FORCEPROXY: ::ULONG = 0x1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgCredentials_KdcProxySettingsW { + pub Version: ::ULONG, + pub Flags: ::ULONG, + pub ProxyServerOffset: ::USHORT, + pub ProxyServerLength: ::USHORT, + pub ClientTlsCredOffset: ::USHORT, + pub ClientTlsCredLength: ::USHORT, +} +pub type PSecPkgCredentials_KdcProxySettingsW = *mut SecPkgCredentials_KdcProxySettingsW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgCredentials_Cert { + pub EncodedCertSize: ::c_ulong, + pub EncodedCert: *mut ::c_uchar, +} +pub type PSecPkgCredentials_Cert = *mut SecPkgCredentials_Cert; +pub const SECPKG_ATTR_SIZES: ::c_ulong = 0; +pub const SECPKG_ATTR_NAMES: ::c_ulong = 1; +pub const SECPKG_ATTR_LIFESPAN: ::c_ulong = 2; +pub const SECPKG_ATTR_DCE_INFO: ::c_ulong = 3; +pub const SECPKG_ATTR_STREAM_SIZES: ::c_ulong = 4; +pub const SECPKG_ATTR_KEY_INFO: ::c_ulong = 5; +pub const SECPKG_ATTR_AUTHORITY: ::c_ulong = 6; +pub const SECPKG_ATTR_PROTO_INFO: ::c_ulong = 7; +pub const SECPKG_ATTR_PASSWORD_EXPIRY: ::c_ulong = 8; +pub const SECPKG_ATTR_SESSION_KEY: ::c_ulong = 9; +pub const SECPKG_ATTR_PACKAGE_INFO: ::c_ulong = 10; +pub const SECPKG_ATTR_USER_FLAGS: ::c_ulong = 11; +pub const SECPKG_ATTR_NEGOTIATION_INFO: ::c_ulong = 12; +pub const SECPKG_ATTR_NATIVE_NAMES: ::c_ulong = 13; +pub const SECPKG_ATTR_FLAGS: ::c_ulong = 14; +pub const SECPKG_ATTR_USE_VALIDATED: ::c_ulong = 15; +pub const SECPKG_ATTR_CREDENTIAL_NAME: ::c_ulong = 16; +pub const SECPKG_ATTR_TARGET_INFORMATION: ::c_ulong = 17; +pub const SECPKG_ATTR_ACCESS_TOKEN: ::c_ulong = 18; +pub const SECPKG_ATTR_TARGET: ::c_ulong = 19; +pub const SECPKG_ATTR_AUTHENTICATION_ID: ::c_ulong = 20; +pub const SECPKG_ATTR_LOGOFF_TIME: ::c_ulong = 21; +pub const SECPKG_ATTR_NEGO_KEYS: ::c_ulong = 22; +pub const SECPKG_ATTR_PROMPTING_NEEDED: ::c_ulong = 24; +pub const SECPKG_ATTR_UNIQUE_BINDINGS: ::c_ulong = 25; +pub const SECPKG_ATTR_ENDPOINT_BINDINGS: ::c_ulong = 26; +pub const SECPKG_ATTR_CLIENT_SPECIFIED_TARGET: ::c_ulong = 27; +pub const SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS: ::c_ulong = 30; +pub const SECPKG_ATTR_NEGO_PKG_INFO: ::c_ulong = 31; +pub const SECPKG_ATTR_NEGO_STATUS: ::c_ulong = 32; +pub const SECPKG_ATTR_CONTEXT_DELETED: ::c_ulong = 33; +pub const SECPKG_ATTR_DTLS_MTU: ::c_ulong = 34; +pub const SECPKG_ATTR_DATAGRAM_SIZES: ::c_ulong = SECPKG_ATTR_STREAM_SIZES; +pub const SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES: ::c_ulong = 128; +pub const SECPKG_ATTR_APPLICATION_PROTOCOL: ::c_ulong = 35; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_SubjectAttributes { + pub AttributeInfo: *mut ::c_void, +} +pub type PSecPkgContext_SubjectAttributes = *mut SecPkgContext_SubjectAttributes; +pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_KERBEROS: ::c_ulong = 0x1; +pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_NTLM: ::c_ulong = 0x2; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum SECPKG_CRED_CLASS { + SecPkgCredClass_None = 0, + SecPkgCredClass_Ephemeral = 10, + SecPkgCredClass_PersistedGeneric = 20, + SecPkgCredClass_PersistedSpecific = 30, + SecPkgCredClass_Explicit = 40, +} +pub use self::SECPKG_CRED_CLASS::*; +pub type PSECPKG_CRED_CLASS = *mut SECPKG_CRED_CLASS; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_CredInfo { + pub CredClass: SECPKG_CRED_CLASS, + pub IsPromptingNeeded: ::c_ulong, +} +pub type PSecPkgContext_CredInfo = *mut SecPkgContext_CredInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NegoPackageInfo { + pub PackageMask: ::c_ulong, +} +pub type PSecPkgContext_NegoPackageInfo = *mut SecPkgContext_NegoPackageInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NegoStatus { + pub LastStatus: ::c_ulong, +} +pub type PSecPkgContext_NegoStatus = *mut SecPkgContext_NegoStatus; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_Sizes { + pub cbMaxToken: ::c_ulong, + pub cbMaxSignature: ::c_ulong, + pub cbBlockSize: ::c_ulong, + pub cbSecurityTrailer: ::c_ulong, +} +pub type PSecPkgContext_Sizes = *mut SecPkgContext_Sizes; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_StreamSizes { + pub cbHeader: ::c_ulong, + pub cbTrailer: ::c_ulong, + pub cbMaximumMessage: ::c_ulong, + pub cBuffers: ::c_ulong, + pub cbBlockSize: ::c_ulong, +} +pub type PSecPkgContext_StreamSizes = *mut SecPkgContext_StreamSizes; +pub type SecPkgContext_DatagramSizes = SecPkgContext_StreamSizes; +pub type PSecPkgContext_DatagramSizes = PSecPkgContext_StreamSizes; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NamesW { + pub sUserName: *mut SEC_WCHAR, +} +pub type PSecPkgContext_NamesW = *mut SecPkgContext_NamesW; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum SECPKG_ATTR_LCT_STATUS { + SecPkgAttrLastClientTokenYes, + SecPkgAttrLastClientTokenNo, + SecPkgAttrLastClientTokenMaybe, +} +pub use self::SECPKG_ATTR_LCT_STATUS::*; +pub type PSECPKG_ATTR_LCT_STATUS = *mut SECPKG_ATTR_LCT_STATUS; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_LastClientTokenStatus { + pub LastClientTokenStatus: SECPKG_ATTR_LCT_STATUS, +} +pub type PSecPkgContext_LastClientTokenStatus = *mut SecPkgContext_LastClientTokenStatus; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NamesA { + pub sUserName: *mut SEC_CHAR, +} +pub type PSecPkgContext_NamesA = *mut SecPkgContext_NamesA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_Lifespan { + pub tsStart: TimeStamp, + pub tsExpiry: TimeStamp, +} +pub type PSecPkgContext_Lifespan = *mut SecPkgContext_Lifespan; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_DceInfo { + pub AuthzSvc: ::c_ulong, + pub pPac: *mut ::c_void, +} +pub type PSecPkgContext_DceInfo = *mut SecPkgContext_DceInfo; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_KeyInfoA { + pub sSignatureAlgorithmName: *mut ::SEC_CHAR, + pub sEncryptAlgorithmName: *mut ::SEC_CHAR, + pub KeySize: ::c_ulong, + pub SignatureAlgorithm: ::c_ulong, + pub EncryptAlgorithm: ::c_ulong, +} +pub type PSecPkgContext_KeyInfoA = *mut SecPkgContext_KeyInfoA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_KeyInfoW { + pub sSignatureAlgorithmName: *mut ::SEC_WCHAR, + pub sEncryptAlgorithmName: *mut ::SEC_WCHAR, + pub KeySize: ::c_ulong, + pub SignatureAlgorithm: ::c_ulong, + pub EncryptAlgorithm: ::c_ulong, +} +pub type PSecPkgContext_KeyInfoW = *mut SecPkgContext_KeyInfoW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_AuthorityA { + pub sAuthorityName: *mut SEC_CHAR, +} +pub type PSecPkgContext_AuthorityA = *mut SecPkgContext_AuthorityA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_AuthorityW { + pub sAuthorityName: *mut SEC_WCHAR, +} +pub type PSecPkgContext_AuthorityW = *mut SecPkgContext_AuthorityW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_ProtoInfoA { + pub sProtocolName: *mut SEC_CHAR, + pub majorVersion: ::c_ulong, + pub minorVersion: ::c_ulong, +} +pub type PSecPkgContext_ProtoInfoA = *mut SecPkgContext_ProtoInfoA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_ProtoInfoW { + pub sProtocolName: *mut SEC_WCHAR, + pub majorVersion: ::c_ulong, + pub minorVersion: ::c_ulong, +} +pub type PSecPkgContext_ProtoInfoW = *mut SecPkgContext_ProtoInfoW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_PasswordExpiry { + pub tsPasswordExpires: TimeStamp, +} +pub type PSecPkgContext_PasswordExpiry = *mut SecPkgContext_PasswordExpiry; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_LogoffTime { + pub tsLogoffTime: TimeStamp, +} +pub type PSecPkgContext_LogoffTime = *mut SecPkgContext_LogoffTime; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_SessionKey { + pub SessionKeyLength: ::c_ulong, + pub SessionKey: *mut ::c_uchar, +} +pub type PSecPkgContext_SessionKey = *mut SecPkgContext_SessionKey; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NegoKeys { + pub KeyType: ::c_ulong, + pub KeyLength: ::c_ushort, + pub KeyValue: *mut ::c_uchar, + pub VerifyKeyType: ::c_ulong, + pub VerifyKeyLength: ::c_ushort, + pub VerifyKeyValue: *mut ::c_uchar, +} +pub type PSecPkgContext_NegoKeys = *mut SecPkgContext_NegoKeys; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_PackageInfoW { + pub PackageInfo: PSecPkgInfoW, +} +pub type PSecPkgContext_PackageInfoW = *mut SecPkgContext_PackageInfoW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_PackageInfoA { + pub PackageInfo: PSecPkgInfoA, +} +pub type PSecPkgContext_PackageInfoA = *mut SecPkgContext_PackageInfoA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_UserFlags { + pub UserFlags: ::c_ulong, +} +pub type PSecPkgContext_UserFlags = *mut SecPkgContext_UserFlags; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_Flags { + pub Flags: ::c_ulong, +} +pub type PSecPkgContext_Flags = *mut SecPkgContext_Flags; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NegotiationInfoA { + pub PackageInfo: PSecPkgInfoA, + pub NegotiationState: ::c_ulong, +} +pub type PSecPkgContext_NegotiationInfoA = *mut SecPkgContext_NegotiationInfoA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NegotiationInfoW { + pub PackageInfo: PSecPkgInfoW, + pub NegotiationState: ::c_ulong, +} +pub type PSecPkgContext_NegotiationInfoW = *mut SecPkgContext_NegotiationInfoW; +pub const SECPKG_NEGOTIATION_COMPLETE: ::c_ulong = 0; +pub const SECPKG_NEGOTIATION_OPTIMISTIC: ::c_ulong = 1; +pub const SECPKG_NEGOTIATION_IN_PROGRESS: ::c_ulong = 2; +pub const SECPKG_NEGOTIATION_DIRECT: ::c_ulong = 3; +pub const SECPKG_NEGOTIATION_TRY_MULTICRED: ::c_ulong = 4; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NativeNamesW { + pub sClientName: SEC_WCHAR, + pub sServerName: SEC_WCHAR, +} +pub type PSecPkgContext_NativeNamesW = *mut SecPkgContext_NativeNamesW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_NativeNamesA { + pub sClientName: SEC_CHAR, + pub sServerName: SEC_CHAR, +} +pub type PSecPkgContext_NativeNamesA = *mut SecPkgContext_NativeNamesA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_CredentialNameW { + pub CredentialType: ::c_ulong, + pub sCredentialName: *mut SEC_WCHAR, +} +pub type PSecPkgContext_CredentialNameW = *mut SecPkgContext_CredentialNameW; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_CredentialNameA { + pub CredentialType: ::c_ulong, + pub sCredentialName: *mut SEC_CHAR, +} +pub type PSecPkgContext_CredentialNameA = *mut SecPkgContext_CredentialNameA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_AccessToken { + pub AccessToken: *mut ::c_void, +} +pub type PSecPkgContext_AccessToken = *mut SecPkgContext_AccessToken; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_TargetInformation { + pub MarshalledTargetInfoLength: ::c_ulong, + pub MarshalledTargetInfo: *mut ::c_uchar, +} +pub type PSecPkgContext_TargetInformation = *mut SecPkgContext_TargetInformation; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_AuthzID { + pub AuthzIDLength: ::c_ulong, + pub AuthzID: *mut ::c_char, +} +pub type PSecPkgContext_AuthzID = *mut SecPkgContext_AuthzID; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_Target { + pub TargetLength: ::c_ulong, + pub Target: *mut ::c_char, +} +pub type PSecPkgContext_Target = *mut SecPkgContext_Target; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_ClientSpecifiedTarget { + pub sTargetName: *mut SEC_WCHAR, +} +pub type PSecPkgContext_ClientSpecifiedTarget = *mut SecPkgContext_ClientSpecifiedTarget; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SecPkgContext_Bindings { + pub BindingsLength: ::c_ulong, + pub Bindings: *mut SEC_CHANNEL_BINDINGS, +} +pub type PSecPkgContext_Bindings = *mut SecPkgContext_Bindings; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS { + SecApplicationProtocolNegotiationStatus_None, + SecApplicationProtocolNegotiationStatus_Success, + SecApplicationProtocolNegotiationStatus_SelectedClientOnly, +} +pub use self::SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS::*; +pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS = + *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS; +pub const MAX_PROTOCOL_ID_SIZE: usize = 0xff; +#[repr(C)] #[derive(Copy)] +pub struct SecPkgContext_ApplicationProtocol { + pub ProtoNegoStatus: SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS, + pub ProtoNegoExt: SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT, + pub ProtocolIdSize: ::c_uchar, + pub ProtocolId: [::c_uchar; MAX_PROTOCOL_ID_SIZE], +} +impl Clone for SecPkgContext_ApplicationProtocol { + fn clone(&self) -> SecPkgContext_ApplicationProtocol { *self } +} +pub type PSecPkgContext_ApplicationProtocol = *mut SecPkgContext_ApplicationProtocol; +pub type SEC_GET_KEY_FN = Option<unsafe extern "system" fn( + Arg: *mut ::c_void, Principal: *mut ::c_void, KeyVer: ::c_ulong, Key: *mut *mut ::c_void, + Status: *mut SECURITY_STATUS, +)>; +pub const SECPKG_CONTEXT_EXPORT_RESET_NEW: ::c_ulong = 0x00000001; +pub const SECPKG_CONTEXT_EXPORT_DELETE_OLD: ::c_ulong = 0x00000002; +pub const SECPKG_CONTEXT_EXPORT_TO_KERNEL: ::c_ulong = 0x00000004; +pub type ACQUIRE_CREDENTIALS_HANDLE_FN_W = Option<unsafe extern "system" fn( + *mut SEC_WCHAR, *mut SEC_WCHAR, ::c_ulong, *mut ::c_void, *mut ::c_void, SEC_GET_KEY_FN, + *mut ::c_void, PCredHandle, PTimeStamp, +) -> SECURITY_STATUS>; +pub type ACQUIRE_CREDENTIALS_HANDLE_FN_A = Option<unsafe extern "system" fn( + *mut SEC_CHAR, *mut SEC_CHAR, ::c_ulong, *mut ::c_void, *mut ::c_void, SEC_GET_KEY_FN, + *mut ::c_void, PCredHandle, PTimeStamp, +) -> SECURITY_STATUS>; +pub type FREE_CREDENTIALS_HANDLE_FN = Option<unsafe extern "system" fn( + PCredHandle, +) -> SECURITY_STATUS>; +pub type ADD_CREDENTIALS_FN_W = Option<unsafe extern "system" fn( + PCredHandle, *mut SEC_WCHAR, *mut SEC_WCHAR, ::c_ulong, *mut ::c_void, SEC_GET_KEY_FN, + *mut ::c_void, PTimeStamp, +) -> SECURITY_STATUS>; +pub type ADD_CREDENTIALS_FN_A = Option<unsafe extern "system" fn( + PCredHandle, *mut SEC_CHAR, *mut SEC_CHAR, ::c_ulong, *mut ::c_void, SEC_GET_KEY_FN, + *mut ::c_void, PTimeStamp, +) -> SECURITY_STATUS>; +pub type CHANGE_PASSWORD_FN_W = Option<unsafe extern "system" fn( + *mut SEC_WCHAR, *mut SEC_WCHAR, *mut SEC_WCHAR, *mut SEC_WCHAR, *mut SEC_WCHAR, ::BOOLEAN, + ::c_ulong, PSecBufferDesc, +) -> SECURITY_STATUS>; +pub type CHANGE_PASSWORD_FN_A = Option<unsafe extern "system" fn( + *mut SEC_CHAR, *mut SEC_CHAR, *mut SEC_CHAR, *mut SEC_CHAR, *mut SEC_CHAR, ::BOOLEAN, + ::c_ulong, PSecBufferDesc, +) -> SECURITY_STATUS>; +//1844 +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum SecDelegationType { + SecFull, + SecService, + SecTree, + SecDirectory, + SecObject, +} +pub use self::SecDelegationType::*; +pub type PSecDelegationType = *mut SecDelegationType; diff --git a/deps/winapi-0.1.23/src/synchapi.rs b/deps/winapi-0.1.23/src/synchapi.rs new file mode 100644 index 000000000..80e0b0b02 --- /dev/null +++ b/deps/winapi-0.1.23/src/synchapi.rs @@ -0,0 +1,5 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! ApiSet Contract for api-ms-win-core-synch-l1 +pub type SRWLOCK = ::RTL_SRWLOCK; +pub type PSRWLOCK = *mut ::RTL_SRWLOCK; diff --git a/deps/winapi-0.1.23/src/timezoneapi.rs b/deps/winapi-0.1.23/src/timezoneapi.rs new file mode 100644 index 000000000..109573e1e --- /dev/null +++ b/deps/winapi-0.1.23/src/timezoneapi.rs @@ -0,0 +1,32 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! ApiSet Contract for api-ms-win-core-timezone-l1 +pub const TIME_ZONE_ID_INVALID: ::DWORD = 0xFFFFFFFF; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct TIME_ZONE_INFORMATION { + pub Bias: ::LONG, + pub StandardName: [::WCHAR; 32], + pub StandardDate: ::SYSTEMTIME, + pub StandardBias: ::LONG, + pub DaylightName: [::WCHAR; 32], + pub DaylightDate: ::SYSTEMTIME, + pub DaylightBias: ::LONG, +} +pub type PTIME_ZONE_INFORMATION = *mut TIME_ZONE_INFORMATION; +pub type LPTIME_ZONE_INFORMATION = *mut TIME_ZONE_INFORMATION; +#[repr(C)] #[derive(Copy)] +pub struct DYNAMIC_TIME_ZONE_INFORMATION { + pub Bias: ::LONG, + pub StandardName: [::WCHAR; 32], + pub StandardDate: ::SYSTEMTIME, + pub StandardBias: ::LONG, + pub DaylightName: [::WCHAR; 32], + pub DaylightDate: ::SYSTEMTIME, + pub DaylightBias: ::LONG, + pub TimeZoneKeyName: [::WCHAR; 128], + pub DynamicDaylightTimeDisabled: ::BOOLEAN, +} +impl Clone for DYNAMIC_TIME_ZONE_INFORMATION { + fn clone(&self) -> DYNAMIC_TIME_ZONE_INFORMATION { *self } +} +pub type PDYNAMIC_TIME_ZONE_INFORMATION = *mut DYNAMIC_TIME_ZONE_INFORMATION; diff --git a/deps/winapi-0.1.23/src/unknwnbase.rs b/deps/winapi-0.1.23/src/unknwnbase.rs new file mode 100644 index 000000000..2d6502413 --- /dev/null +++ b/deps/winapi-0.1.23/src/unknwnbase.rs @@ -0,0 +1,21 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! this ALWAYS GENERATED file contains the definitions for the interfaces +RIDL!( +interface IUnknown(IUnknownVtbl) { + fn QueryInterface(&mut self, riid: ::REFIID, ppvObject: *mut *mut ::c_void) -> ::HRESULT, + fn AddRef(&mut self) -> ::ULONG, + fn Release(&mut self) -> ::ULONG +} +); +pub type LPUNKNOWN = *mut IUnknown; +RIDL!( +interface AsyncIUnknown(AsyncIUnknownVtbl): IUnknown(IUnknownVtbl) { + fn Begin_QueryInterface(&mut self, riid: ::REFIID) -> ::HRESULT, + fn Finish_QueryInterface(&mut self, ppvObject: *mut *mut ::c_void) -> ::HRESULT, + fn Begin_AddRef(&mut self) -> ::HRESULT, + fn Finish_AddRef(&mut self) -> ::ULONG, + fn Begin_Release(&mut self) -> ::HRESULT, + fn Finish_Release(&mut self) -> ::ULONG +} +); diff --git a/deps/winapi-0.1.23/src/vadefs.rs b/deps/winapi-0.1.23/src/vadefs.rs new file mode 100644 index 000000000..c482026f0 --- /dev/null +++ b/deps/winapi-0.1.23/src/vadefs.rs @@ -0,0 +1,7 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Definitions of macro helpers used by <stdarg.h>. This is the topmost header in the CRT header +//! lattice, and is always the first CRT header to be included, explicitly or implicitly. +//! Therefore, this header also has several definitions that are used throughout the CRT. +//39 +pub type va_list = *mut ::c_char; diff --git a/deps/winapi-0.1.23/src/winbase.rs b/deps/winapi-0.1.23/src/winbase.rs new file mode 100644 index 000000000..84deb96ab --- /dev/null +++ b/deps/winapi-0.1.23/src/winbase.rs @@ -0,0 +1,158 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! This module defines the 32-Bit Windows Base APIs +//99 +pub const FILE_BEGIN: ::DWORD = 0; +pub const FILE_CURRENT: ::DWORD = 1; +pub const FILE_END: ::DWORD = 2; +//123 +pub const FILE_FLAG_WRITE_THROUGH: ::DWORD = 0x80000000; +pub const FILE_FLAG_OVERLAPPED: ::DWORD = 0x40000000; +pub const FILE_FLAG_NO_BUFFERING: ::DWORD = 0x20000000; +pub const FILE_FLAG_RANDOM_ACCESS: ::DWORD = 0x10000000; +pub const FILE_FLAG_SEQUENTIAL_SCAN: ::DWORD = 0x08000000; +pub const FILE_FLAG_DELETE_ON_CLOSE: ::DWORD = 0x04000000; +pub const FILE_FLAG_BACKUP_SEMANTICS: ::DWORD = 0x02000000; +pub const FILE_FLAG_POSIX_SEMANTICS: ::DWORD = 0x01000000; +pub const FILE_FLAG_SESSION_AWARE: ::DWORD = 0x00800000; +pub const FILE_FLAG_OPEN_REPARSE_POINT: ::DWORD = 0x00200000; +pub const FILE_FLAG_OPEN_NO_RECALL: ::DWORD = 0x00100000; +pub const FILE_FLAG_FIRST_PIPE_INSTANCE: ::DWORD = 0x00080000; +pub const FILE_FLAG_OPEN_REQUIRING_OPLOCK: ::DWORD = 0x00040000; +pub const PROGRESS_CONTINUE: ::DWORD = 0; +pub const PROGRESS_CANCEL: ::DWORD = 1; +pub const PROGRESS_STOP: ::DWORD = 2; +pub const PROGRESS_QUIET: ::DWORD = 3; +pub const CALLBACK_CHUNK_FINISHED: ::DWORD = 0x00000000; +pub const CALLBACK_STREAM_SWITCH: ::DWORD = 0x00000001; +pub const COPY_FILE_FAIL_IF_EXISTS: ::DWORD = 0x00000001; +pub const COPY_FILE_RESTARTABLE: ::DWORD = 0x00000002; +pub const COPY_FILE_OPEN_SOURCE_FOR_WRITE: ::DWORD = 0x00000004; +pub const COPY_FILE_ALLOW_DECRYPTED_DESTINATION: ::DWORD = 0x00000008; +pub const COPY_FILE_COPY_SYMLINK: ::DWORD = 0x00000800; +pub const COPY_FILE_NO_BUFFERING: ::DWORD = 0x00001000; +pub const COPY_FILE_REQUEST_SECURITY_PRIVILEGES: ::DWORD = 0x00002000; +pub const COPY_FILE_RESUME_FROM_PAUSE: ::DWORD = 0x00004000; +pub const COPY_FILE_NO_OFFLOAD: ::DWORD = 0x00040000; +pub const REPLACEFILE_WRITE_THROUGH: ::DWORD = 0x00000001; +pub const REPLACEFILE_IGNORE_MERGE_ERRORS: ::DWORD = 0x00000002; +pub const REPLACEFILE_IGNORE_ACL_ERRORS: ::DWORD = 0x00000004; +pub const PIPE_ACCESS_INBOUND: ::DWORD = 0x00000001; +pub const PIPE_ACCESS_OUTBOUND: ::DWORD = 0x00000002; +pub const PIPE_ACCESS_DUPLEX: ::DWORD = 0x00000003; +pub const PIPE_CLIENT_END: ::DWORD = 0x00000000; +pub const PIPE_SERVER_END: ::DWORD = 0x00000001; +pub const PIPE_WAIT: ::DWORD = 0x00000000; +pub const PIPE_NOWAIT: ::DWORD = 0x00000001; +pub const PIPE_READMODE_BYTE: ::DWORD = 0x00000000; +pub const PIPE_READMODE_MESSAGE: ::DWORD = 0x00000002; +pub const PIPE_TYPE_BYTE: ::DWORD = 0x00000000; +pub const PIPE_TYPE_MESSAGE: ::DWORD = 0x00000004; +pub const PIPE_ACCEPT_REMOTE_CLIENTS: ::DWORD = 0x00000000; +pub const PIPE_REJECT_REMOTE_CLIENTS: ::DWORD = 0x00000008; +pub const PIPE_UNLIMITED_INSTANCES: ::DWORD = 255; +//268 +pub const SECURITY_CONTEXT_TRACKING: ::DWORD = 0x00040000; +pub const SECURITY_EFFECTIVE_ONLY: ::DWORD = 0x00080000; +pub const SECURITY_SQOS_PRESENT: ::DWORD = 0x00100000; +pub const SECURITY_VALID_SQOS_FLAGS: ::DWORD = 0x001F0000; +//687 +pub const STD_INPUT_HANDLE: ::DWORD = 0xFFFFFFF6; +pub const STD_OUTPUT_HANDLE: ::DWORD = 0xFFFFFFF5; +pub const STD_ERROR_HANDLE: ::DWORD = 0xFFFFFFF4; +pub const NOPARITY: ::DWORD = 0; +pub const ODDPARITY: ::DWORD = 1; +pub const EVENPARITY: ::DWORD = 2; +pub const MARKPARITY: ::DWORD = 3; +pub const SPACEPARITY: ::DWORD = 4; +pub const ONESTOPBIT: ::DWORD = 0; +pub const ONE5STOPBITS: ::DWORD = 1; +pub const TWOSTOPBITS: ::DWORD = 2; +pub const IGNORE: ::DWORD = 0; +pub const INFINITE: ::DWORD = 0xFFFFFFFF; +//2939 +// startup flags STARTUPINFOW::dwFlags +pub const STARTF_USESHOWWINDOW: ::DWORD = 0x00000001; +pub const STARTF_USESIZE: ::DWORD = 0x00000002; +pub const STARTF_USEPOSITION: ::DWORD = 0x00000004; +pub const STARTF_USECOUNTCHARS: ::DWORD = 0x00000008; +pub const STARTF_USEFILLATTRIBUTE: ::DWORD = 0x00000010; +pub const STARTF_RUNFULLSCREEN: ::DWORD = 0x00000020; +pub const STARTF_FORCEONFEEDBACK: ::DWORD = 0x00000040; +pub const STARTF_FORCEOFFFEEDBACK: ::DWORD = 0x00000080; +pub const STARTF_USESTDHANDLES: ::DWORD = 0x00000100; +pub const STARTF_USEHOTKEY: ::DWORD = 0x00000200; +pub const STARTF_TITLEISLINKNAME: ::DWORD = 0x00000800; +pub const STARTF_TITLEISAPPID: ::DWORD = 0x00001000; +pub const STARTF_PREVENTPINNING: ::DWORD = 0x00002000; +//5454 +pub const MOVEFILE_REPLACE_EXISTING: ::DWORD = 0x00000001; +pub const MOVEFILE_COPY_ALLOWED: ::DWORD = 0x00000002; +pub const MOVEFILE_DELAY_UNTIL_REBOOT: ::DWORD = 0x00000004; +pub const MOVEFILE_WRITE_THROUGH: ::DWORD = 0x00000008; +pub const MOVEFILE_CREATE_HARDLINK: ::DWORD = 0x00000010; +pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: ::DWORD = 0x00000020; + +pub const FORMAT_MESSAGE_IGNORE_INSERTS: ::DWORD = 0x00000200; +pub const FORMAT_MESSAGE_FROM_STRING: ::DWORD = 0x00000400; +pub const FORMAT_MESSAGE_FROM_HMODULE: ::DWORD = 0x00000800; +pub const FORMAT_MESSAGE_FROM_SYSTEM: ::DWORD = 0x00001000; +pub const FORMAT_MESSAGE_ARGUMENT_ARRAY: ::DWORD = 0x00002000; +pub const FORMAT_MESSAGE_MAX_WIDTH_MASK: ::DWORD = 0x000000FF; +pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: ::DWORD = 0x00000100; + +pub const DEBUG_PROCESS: ::DWORD = 0x00000001; +pub const DEBUG_ONLY_THIS_PROCESS: ::DWORD = 0x00000002; +pub const CREATE_SUSPENDED: ::DWORD = 0x00000004; +pub const DETACHED_PROCESS: ::DWORD = 0x00000008; + +pub const CREATE_NEW_CONSOLE: ::DWORD = 0x00000010; +pub const NORMAL_PRIORITY_CLASS: ::DWORD = 0x00000020; +pub const IDLE_PRIORITY_CLASS: ::DWORD = 0x00000040; +pub const HIGH_PRIORITY_CLASS: ::DWORD = 0x00000080; + +pub const REALTIME_PRIORITY_CLASS: ::DWORD = 0x00000100; +pub const CREATE_NEW_PROCESS_GROUP: ::DWORD = 0x00000200; +pub const CREATE_UNICODE_ENVIRONMENT: ::DWORD = 0x00000400; +pub const CREATE_SEPARATE_WOW_VDM: ::DWORD = 0x00000800; + +pub const CREATE_SHARED_WOW_VDM: ::DWORD = 0x00001000; +pub const CREATE_FORCEDOS: ::DWORD = 0x00002000; +pub const BELOW_NORMAL_PRIORITY_CLASS: ::DWORD = 0x00004000; +pub const ABOVE_NORMAL_PRIORITY_CLASS: ::DWORD = 0x00008000; + +pub const INHERIT_PARENT_AFFINITY: ::DWORD = 0x00010000; +pub const INHERIT_CALLER_PRIORITY: ::DWORD = 0x00020000; +pub const CREATE_PROTECTED_PROCESS: ::DWORD = 0x00040000; +pub const EXTENDED_STARTUPINFO_PRESENT: ::DWORD = 0x00080000; + +pub const PROCESS_MODE_BACKGROUND_BEGIN: ::DWORD = 0x00100000; +pub const PROCESS_MODE_BACKGROUND_END: ::DWORD = 0x00200000; + +pub const CREATE_BREAKAWAY_FROM_JOB: ::DWORD = 0x01000000; +pub const CREATE_PRESERVE_CODE_AUTHZ_LEVEL: ::DWORD = 0x02000000; +pub const CREATE_DEFAULT_ERROR_MODE: ::DWORD = 0x04000000; +pub const CREATE_NO_WINDOW: ::DWORD = 0x08000000; + +pub const PROFILE_USER: ::DWORD = 0x10000000; +pub const PROFILE_KERNEL: ::DWORD = 0x20000000; +pub const PROFILE_SERVER: ::DWORD = 0x40000000; +pub const CREATE_IGNORE_SYSTEM_DEFAULT: ::DWORD = 0x80000000; + +pub const THREAD_BASE_PRIORITY_LOWRT: ::DWORD = 15; +pub const THREAD_BASE_PRIORITY_MAX: ::DWORD = 2; +pub const THREAD_BASE_PRIORITY_MIN: ::DWORD = -2i32 as ::DWORD; +pub const THREAD_BASE_PRIORITY_IDLE: ::DWORD = -15i32 as ::DWORD; + +pub const THREAD_PRIORITY_LOWEST: ::DWORD = THREAD_BASE_PRIORITY_MIN; +pub const THREAD_PRIORITY_BELOW_NORMAL: ::DWORD = THREAD_PRIORITY_LOWEST + 1; +pub const THREAD_PRIORITY_NORMAL: ::DWORD = 0; +pub const THREAD_PRIORITY_HIGHEST: ::DWORD = THREAD_BASE_PRIORITY_MAX; +pub const THREAD_PRIORITY_ABOVE_NORMAL: ::DWORD = THREAD_PRIORITY_HIGHEST - 1; +pub const THREAD_PRIORITY_ERROR_RETURN: ::DWORD = 0x7fffffff; + +pub const THREAD_PRIORITY_TIME_CRITICAL: ::DWORD = THREAD_BASE_PRIORITY_LOWRT; +pub const THREAD_PRIORITY_IDLE: ::DWORD = THREAD_BASE_PRIORITY_IDLE; + +pub const THREAD_MODE_BACKGROUND_BEGIN: ::DWORD = 0x00010000; +pub const THREAD_MODE_BACKGROUND_END: ::DWORD = 0x00020000; diff --git a/deps/winapi-0.1.23/src/wincon.rs b/deps/winapi-0.1.23/src/wincon.rs new file mode 100644 index 000000000..df42c575b --- /dev/null +++ b/deps/winapi-0.1.23/src/wincon.rs @@ -0,0 +1,231 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! This module contains the public data structures, data types, and procedures exported by the NT +//! console subsystem. +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct COORD { + pub X: ::SHORT, + pub Y: ::SHORT, +} +pub type PCOORD = *mut COORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SMALL_RECT { + pub Left: ::SHORT, + pub Top: ::SHORT, + pub Right: ::SHORT, + pub Bottom: ::SHORT, +} +pub type PSMALL_RECT = *mut SMALL_RECT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct KEY_EVENT_RECORD { + pub bKeyDown: ::BOOL, + pub wRepeatCount: ::WORD, + pub wVirtualKeyCode: ::WORD, + pub wVirtualScanCode: ::WORD, + pub uChar: ::WCHAR, //FIXME - untagged union + pub dwControlKeyState: ::DWORD, +} +pub type PKEY_EVENT_RECORD = *mut KEY_EVENT_RECORD; +pub const RIGHT_ALT_PRESSED: ::DWORD = 0x0001; +pub const LEFT_ALT_PRESSED: ::DWORD = 0x0002; +pub const RIGHT_CTRL_PRESSED: ::DWORD = 0x0004; +pub const LEFT_CTRL_PRESSED: ::DWORD = 0x0008; +pub const SHIFT_PRESSED: ::DWORD = 0x0010; +pub const NUMLOCK_ON: ::DWORD = 0x0020; +pub const SCROLLLOCK_ON: ::DWORD = 0x0040; +pub const CAPSLOCK_ON: ::DWORD = 0x0080; +pub const ENHANCED_KEY: ::DWORD = 0x0100; +pub const NLS_DBCSCHAR: ::DWORD = 0x00010000; +pub const NLS_ALPHANUMERIC: ::DWORD = 0x00000000; +pub const NLS_KATAKANA: ::DWORD = 0x00020000; +pub const NLS_HIRAGANA: ::DWORD = 0x00040000; +pub const NLS_ROMAN: ::DWORD = 0x00400000; +pub const NLS_IME_CONVERSION: ::DWORD = 0x00800000; +pub const NLS_IME_DISABLE: ::DWORD = 0x20000000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MOUSE_EVENT_RECORD { + pub dwMousePosition: COORD, + pub dwButtonState: ::DWORD, + pub dwControlKeyState: ::DWORD, + pub dwEventFlags: ::DWORD, +} +pub type PMOUSE_EVENT_RECORD = *mut MOUSE_EVENT_RECORD; +pub const FROM_LEFT_1ST_BUTTON_PRESSED: ::DWORD = 0x0001; +pub const RIGHTMOST_BUTTON_PRESSED: ::DWORD = 0x0002; +pub const FROM_LEFT_2ND_BUTTON_PRESSED: ::DWORD = 0x0004; +pub const FROM_LEFT_3RD_BUTTON_PRESSED: ::DWORD = 0x0008; +pub const FROM_LEFT_4TH_BUTTON_PRESSED: ::DWORD = 0x0010; +pub const MOUSE_MOVED: ::DWORD = 0x0001; +pub const DOUBLE_CLICK: ::DWORD = 0x0002; +pub const MOUSE_WHEELED: ::DWORD = 0x0004; +pub const MOUSE_HWHEELED: ::DWORD = 0x0008; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WINDOW_BUFFER_SIZE_RECORD { + pub dwSize: COORD, +} +pub type PWINDOW_BUFFER_SIZE_RECORD = *mut WINDOW_BUFFER_SIZE_RECORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MENU_EVENT_RECORD { + pub dwCommandId: ::UINT, +} +pub type PMENU_EVENT_RECORD = *mut MENU_EVENT_RECORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FOCUS_EVENT_RECORD { + pub bSetFocus: ::BOOL, +} +pub type PFOCUS_EVENT_RECORD = *mut FOCUS_EVENT_RECORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INPUT_RECORD { + pub EventType: ::WORD, + pub Event: MOUSE_EVENT_RECORD, //FIXME - untagged union +} +#[test] +fn test_INPUT_RECORD() { + use std::mem::{size_of, min_align_of}; + assert!(size_of::<MOUSE_EVENT_RECORD>() >= size_of::<KEY_EVENT_RECORD>()); + assert!(size_of::<MOUSE_EVENT_RECORD>() >= size_of::<WINDOW_BUFFER_SIZE_RECORD>()); + assert!(size_of::<MOUSE_EVENT_RECORD>() >= size_of::<MENU_EVENT_RECORD>()); + assert!(size_of::<MOUSE_EVENT_RECORD>() >= size_of::<FOCUS_EVENT_RECORD>()); + assert!(min_align_of::<MOUSE_EVENT_RECORD>() >= min_align_of::<KEY_EVENT_RECORD>()); + assert!(min_align_of::<MOUSE_EVENT_RECORD>() >= min_align_of::<WINDOW_BUFFER_SIZE_RECORD>()); + assert!(min_align_of::<MOUSE_EVENT_RECORD>() >= min_align_of::<MENU_EVENT_RECORD>()); + assert!(min_align_of::<MOUSE_EVENT_RECORD>() >= min_align_of::<FOCUS_EVENT_RECORD>()); +} +pub type PINPUT_RECORD = *mut INPUT_RECORD; +pub const KEY_EVENT: ::DWORD = 0x0001; +pub const MOUSE_EVENT: ::DWORD = 0x0002; +pub const WINDOW_BUFFER_SIZE_EVENT: ::DWORD = 0x0004; +pub const MENU_EVENT: ::DWORD = 0x0008; +pub const FOCUS_EVENT: ::DWORD = 0x0010; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CHAR_INFO { + pub Char: ::WCHAR, //FIXME - untagged union + pub Attributes: ::WORD, +} +#[test] +fn test_CHAR_INFO() { + use std::mem::{size_of, min_align_of}; + assert!(size_of::<::WCHAR>() >= size_of::<::CHAR>()); + assert!(min_align_of::<::WCHAR>() >= min_align_of::<::CHAR>()); +} +pub type PCHAR_INFO = *mut CHAR_INFO; +pub const FOREGROUND_BLUE: ::DWORD = 0x0001; +pub const FOREGROUND_GREEN: ::DWORD = 0x0002; +pub const FOREGROUND_RED: ::DWORD = 0x0004; +pub const FOREGROUND_INTENSITY: ::DWORD = 0x0008; +pub const BACKGROUND_BLUE: ::DWORD = 0x0010; +pub const BACKGROUND_GREEN: ::DWORD = 0x0020; +pub const BACKGROUND_RED: ::DWORD = 0x0040; +pub const BACKGROUND_INTENSITY: ::DWORD = 0x0080; +pub const COMMON_LVB_LEADING_BYTE: ::DWORD = 0x0100; +pub const COMMON_LVB_TRAILING_BYTE: ::DWORD = 0x0200; +pub const COMMON_LVB_GRID_HORIZONTAL: ::DWORD = 0x0400; +pub const COMMON_LVB_GRID_LVERTICAL: ::DWORD = 0x0800; +pub const COMMON_LVB_GRID_RVERTICAL: ::DWORD = 0x1000; +pub const COMMON_LVB_REVERSE_VIDEO: ::DWORD = 0x4000; +pub const COMMON_LVB_UNDERSCORE: ::DWORD = 0x8000; +pub const COMMON_LVB_SBCSDBCS: ::DWORD = 0x0300; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_SCREEN_BUFFER_INFO { + pub dwSize: COORD, + pub dwCursorPosition: COORD, + pub wAttributes: ::WORD, + pub srWindow: SMALL_RECT, + pub dwMaximumWindowSize: COORD, +} +pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_SCREEN_BUFFER_INFOEX { + pub cbSize: ::ULONG, + pub dwSize: COORD, + pub dwCursorPosition: COORD, + pub wAttributes: ::WORD, + pub srWindow: SMALL_RECT, + pub dwMaximumWindowSize: COORD, + pub wPopupAttributes: ::WORD, + pub bFullscreenSupported: ::BOOL, + pub ColorTable: [::COLORREF; 16], +} +pub type PCONSOLE_SCREEN_BUFFER_INFOEX = *mut CONSOLE_SCREEN_BUFFER_INFOEX; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_CURSOR_INFO { + pub dwSize: ::DWORD, + pub bVisible: ::BOOL, +} +pub type PCONSOLE_CURSOR_INFO = *mut CONSOLE_CURSOR_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_FONT_INFO { + pub nFont: ::DWORD, + pub dwFontSize: ::COORD, +} +pub type PCONSOLE_FONT_INFO = *mut CONSOLE_FONT_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_FONT_INFOEX { + pub cbSize: ::ULONG, + pub nFont: ::DWORD, + pub dwFontSize: COORD, + pub FontFamily: ::UINT, + pub FontWeight: ::UINT, + pub FaceName: [::WCHAR; ::LF_FACESIZE], +} +pub type PCONSOLE_FONT_INFOEX = *mut CONSOLE_FONT_INFOEX; +pub const HISTORY_NO_DUP_FLAG: ::DWORD = 0x1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_HISTORY_INFO { + pub cbSize: ::UINT, + pub HistoryBufferSize: ::UINT, + pub NumberOfHistoryBuffers: ::UINT, + pub dwFlags: ::DWORD, +} +pub type PCONSOLE_HISTORY_INFO = *mut CONSOLE_HISTORY_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_SELECTION_INFO { + pub dwFlags: ::DWORD, + pub dwSelectionAnchor: COORD, + pub srSelection: SMALL_RECT, +} +pub type PCONSOLE_SELECTION_INFO = *mut CONSOLE_SELECTION_INFO; +pub const CONSOLE_NO_SELECTION: ::DWORD = 0x0000; +pub const CONSOLE_SELECTION_IN_PROGRESS: ::DWORD = 0x0001; +pub const CONSOLE_SELECTION_NOT_EMPTY: ::DWORD = 0x0002; +pub const CONSOLE_MOUSE_SELECTION: ::DWORD = 0x0004; +pub const CONSOLE_MOUSE_DOWN: ::DWORD = 0x0008; +pub type PHANDLER_ROUTINE = Option<unsafe extern "system" fn(CtrlType: ::DWORD) -> ::BOOL>; +pub const CTRL_C_EVENT: ::DWORD = 0; +pub const CTRL_BREAK_EVENT: ::DWORD = 1; +pub const CTRL_CLOSE_EVENT: ::DWORD = 2; +pub const CTRL_LOGOFF_EVENT: ::DWORD = 5; +pub const CTRL_SHUTDOWN_EVENT: ::DWORD = 6; +pub const ENABLE_PROCESSED_INPUT: ::DWORD = 0x0001; +pub const ENABLE_LINE_INPUT: ::DWORD = 0x0002; +pub const ENABLE_ECHO_INPUT: ::DWORD = 0x0004; +pub const ENABLE_WINDOW_INPUT: ::DWORD = 0x0008; +pub const ENABLE_MOUSE_INPUT: ::DWORD = 0x0010; +pub const ENABLE_INSERT_MODE: ::DWORD = 0x0020; +pub const ENABLE_QUICK_EDIT_MODE: ::DWORD = 0x0040; +pub const ENABLE_EXTENDED_FLAGS: ::DWORD = 0x0080; +pub const ENABLE_AUTO_POSITION: ::DWORD = 0x0100; +pub const ENABLE_PROCESSED_OUTPUT: ::DWORD = 0x0001; +pub const ENABLE_WRAP_AT_EOL_OUTPUT: ::DWORD = 0x0002; +#[cfg(target_arch = "x86")] +pub const CONSOLE_REAL_OUTPUT_HANDLE: *mut ::c_void = 0xFFFFFFFE as *mut ::c_void; +#[cfg(target_arch = "x86_64")] +pub const CONSOLE_REAL_OUTPUT_HANDLE: *mut ::c_void = 0xFFFFFFFFFFFFFFFE as *mut ::c_void; +#[cfg(target_arch = "x86")] +pub const CONSOLE_REAL_INPUT_HANDLE: *mut ::c_void = 0xFFFFFFFD as *mut ::c_void; +#[cfg(target_arch = "x86_64")] +pub const CONSOLE_REAL_INPUT_HANDLE: *mut ::c_void = 0xFFFFFFFFFFFFFFFD as *mut ::c_void; +pub const ATTACH_PARENT_PROCESS: ::DWORD = 0xFFFFFFFF; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONSOLE_READCONSOLE_CONTROL { + pub nLength: ::ULONG, + pub nInitialChars: ::ULONG, + pub dwCtrlWakeupMask: ::ULONG, + pub dwControlKeyState: ::ULONG, +} +pub type PCONSOLE_READCONSOLE_CONTROL = *mut CONSOLE_READCONSOLE_CONTROL; +pub const CONSOLE_TEXTMODE_BUFFER: ::DWORD = 1; +pub const CONSOLE_FULLSCREEN: ::DWORD = 1; +pub const CONSOLE_FULLSCREEN_HARDWARE: ::DWORD = 2; +pub const CONSOLE_FULLSCREEN_MODE: ::DWORD = 1; +pub const CONSOLE_WINDOWED_MODE: ::DWORD = 2; diff --git a/deps/winapi-0.1.23/src/wincred.rs b/deps/winapi-0.1.23/src/wincred.rs new file mode 100644 index 000000000..7ed7418a5 --- /dev/null +++ b/deps/winapi-0.1.23/src/wincred.rs @@ -0,0 +1,79 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Authentication API Prototypes and Definitions +pub const CRED_MAX_STRING_LENGTH: ::DWORD = 256; +pub const CRED_MAX_USERNAME_LENGTH: ::DWORD = 256+1+256; +pub const CRED_MAX_GENERIC_TARGET_NAME_LENGTH: ::DWORD = 32767; +pub const CRED_MAX_DOMAIN_TARGET_NAME_LENGTH: ::DWORD = 256+1+80; +pub const CRED_MAX_TARGETNAME_NAMESPACE_LENGTH: ::DWORD = 256; +pub const CRED_MAX_TARGETNAME_ATTRIBUTE_LENGTH: ::DWORD = 256; +pub const CRED_MAX_VALUE_SIZE: ::DWORD = 256; +pub const CRED_MAX_ATTRIBUTES: ::DWORD = 64; + +pub const CRED_TYPE_GENERIC: ::DWORD = 1; +pub const CRED_TYPE_DOMAIN_PASSWORD: ::DWORD = 2; +pub const CRED_TYPE_DOMAIN_CERTIFICATE: ::DWORD = 3; +pub const CRED_TYPE_DOMAIN_VISIBLE_PASSWORD: ::DWORD = 4; +pub const CRED_TYPE_GENERIC_CERTIFICATE: ::DWORD = 5; +pub const CRED_TYPE_DOMAIN_EXTENDED: ::DWORD = 6; +pub const CRED_TYPE_MAXIMUM: ::DWORD = 7; +pub const CRED_TYPE_MAXIMUM_EX: ::DWORD = CRED_TYPE_MAXIMUM+1000; + +pub const CRED_MAX_CREDENTIAL_BLOB_SIZE: ::DWORD = 5*512; + +pub const CRED_PERSIST_NONE: ::DWORD = 0; +pub const CRED_PERSIST_SESSION: ::DWORD = 1; +pub const CRED_PERSIST_LOCAL_MACHINE: ::DWORD = 2; +pub const CRED_PERSIST_ENTERPRISE: ::DWORD = 3; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREDENTIAL_ATTRIBUTEA { + pub Keyword: ::LPSTR, + pub Flags: ::DWORD, + pub ValueSize: ::DWORD, + pub Value: ::LPBYTE, +} +pub type PCREDENTIAL_ATTRIBUTEA = *mut CREDENTIAL_ATTRIBUTEA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREDENTIAL_ATTRIBUTEW { + pub Keyword: ::LPWSTR, + pub Flags: ::DWORD, + pub ValueSize: ::DWORD, + pub Value: ::LPBYTE, +} +pub type PCREDENTIAL_ATTRIBUTEW = *mut CREDENTIAL_ATTRIBUTEW; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREDENTIALA { + pub Flags: ::DWORD, + pub Type: ::DWORD, + pub TargetName: ::LPSTR, + pub Comment: ::LPSTR, + pub LastWritten: ::FILETIME, + pub CredentialBlobSize: ::DWORD, + pub CredentialBlob: ::LPBYTE, + pub Persist: ::DWORD, + pub AttributeCount: ::DWORD, + pub Attributes: PCREDENTIAL_ATTRIBUTEA, + pub TargetAlias: ::LPSTR, + pub UserName: ::LPSTR, +} +pub type PCREDENTIALA = *mut CREDENTIALA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREDENTIALW { + pub Flags: ::DWORD, + pub Type: ::DWORD, + pub TargetName: ::LPWSTR, + pub Comment: ::LPWSTR, + pub LastWritten: ::FILETIME, + pub CredentialBlobSize: ::DWORD, + pub CredentialBlob: ::LPBYTE, + pub Persist: ::DWORD, + pub AttributeCount: ::DWORD, + pub Attributes: PCREDENTIAL_ATTRIBUTEW, + pub TargetAlias: ::LPWSTR, + pub UserName: ::LPWSTR, +} +pub type PCREDENTIALW = *mut CREDENTIALW; diff --git a/deps/winapi-0.1.23/src/wincrypt.rs b/deps/winapi-0.1.23/src/wincrypt.rs new file mode 100644 index 000000000..7aa9c8e83 --- /dev/null +++ b/deps/winapi-0.1.23/src/wincrypt.rs @@ -0,0 +1,1394 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Cryptographic API Prototypes and Definitions +//108 +pub const ALG_CLASS_ANY: ALG_ID = 0; +pub const ALG_CLASS_SIGNATURE: ALG_ID = 1 << 13; +pub const ALG_CLASS_MSG_ENCRYPT: ALG_ID = 2 << 13; +pub const ALG_CLASS_DATA_ENCRYPT: ALG_ID = 3 << 13; +pub const ALG_CLASS_HASH: ALG_ID = 4 << 13; +pub const ALG_CLASS_KEY_EXCHANGE: ALG_ID = 5 << 13; +pub const ALG_CLASS_ALL: ALG_ID = 7 << 13; +pub const ALG_TYPE_ANY: ALG_ID = 0; +pub const ALG_TYPE_DSS: ALG_ID = 1 << 9; +pub const ALG_TYPE_RSA: ALG_ID = 2 << 9; +pub const ALG_TYPE_BLOCK: ALG_ID = 3 << 9; +pub const ALG_TYPE_STREAM: ALG_ID = 4 << 9; +pub const ALG_TYPE_DH: ALG_ID = 5 << 9; +pub const ALG_TYPE_SECURECHANNEL: ALG_ID = 6 << 9; +pub const ALG_SID_ANY: ALG_ID = 0; +pub const ALG_SID_RSA_ANY: ALG_ID = 0; +pub const ALG_SID_RSA_PKCS: ALG_ID = 1; +pub const ALG_SID_RSA_MSATWORK: ALG_ID = 2; +pub const ALG_SID_RSA_ENTRUST: ALG_ID = 3; +pub const ALG_SID_RSA_PGP: ALG_ID = 4; +pub const ALG_SID_DSS_ANY: ALG_ID = 0; +pub const ALG_SID_DSS_PKCS: ALG_ID = 1; +pub const ALG_SID_DSS_DMS: ALG_ID = 2; +pub const ALG_SID_ECDSA: ALG_ID = 3; +pub const ALG_SID_DES: ALG_ID = 1; +pub const ALG_SID_3DES: ALG_ID = 3; +pub const ALG_SID_DESX: ALG_ID = 4; +pub const ALG_SID_IDEA: ALG_ID = 5; +pub const ALG_SID_CAST: ALG_ID = 6; +pub const ALG_SID_SAFERSK64: ALG_ID = 7; +pub const ALG_SID_SAFERSK128: ALG_ID = 8; +pub const ALG_SID_3DES_112: ALG_ID = 9; +pub const ALG_SID_CYLINK_MEK: ALG_ID = 12; +pub const ALG_SID_RC5: ALG_ID = 13; +pub const ALG_SID_AES_128: ALG_ID = 14; +pub const ALG_SID_AES_192: ALG_ID = 15; +pub const ALG_SID_AES_256: ALG_ID = 16; +pub const ALG_SID_AES: ALG_ID = 17; +pub const ALG_SID_SKIPJACK: ALG_ID = 10; +pub const ALG_SID_TEK: ALG_ID = 11; +pub const CRYPT_MODE_CBCI: ALG_ID = 6; +pub const CRYPT_MODE_CFBP: ALG_ID = 7; +pub const CRYPT_MODE_OFBP: ALG_ID = 8; +pub const CRYPT_MODE_CBCOFM: ALG_ID = 9; +pub const CRYPT_MODE_CBCOFMI: ALG_ID = 10; +pub const ALG_SID_RC2: ALG_ID = 2; +pub const ALG_SID_RC4: ALG_ID = 1; +pub const ALG_SID_SEAL: ALG_ID = 2; +pub const ALG_SID_DH_SANDF: ALG_ID = 1; +pub const ALG_SID_DH_EPHEM: ALG_ID = 2; +pub const ALG_SID_AGREED_KEY_ANY: ALG_ID = 3; +pub const ALG_SID_KEA: ALG_ID = 4; +pub const ALG_SID_ECDH: ALG_ID = 5; +pub const ALG_SID_MD2: ALG_ID = 1; +pub const ALG_SID_MD4: ALG_ID = 2; +pub const ALG_SID_MD5: ALG_ID = 3; +pub const ALG_SID_SHA: ALG_ID = 4; +pub const ALG_SID_SHA1: ALG_ID = 4; +pub const ALG_SID_MAC: ALG_ID = 5; +pub const ALG_SID_RIPEMD: ALG_ID = 6; +pub const ALG_SID_RIPEMD160: ALG_ID = 7; +pub const ALG_SID_SSL3SHAMD5: ALG_ID = 8; +pub const ALG_SID_HMAC: ALG_ID = 9; +pub const ALG_SID_TLS1PRF: ALG_ID = 10; +pub const ALG_SID_HASH_REPLACE_OWF: ALG_ID = 11; +pub const ALG_SID_SHA_256: ALG_ID = 12; +pub const ALG_SID_SHA_384: ALG_ID = 13; +pub const ALG_SID_SHA_512: ALG_ID = 14; +pub const ALG_SID_SSL3_MASTER: ALG_ID = 1; +pub const ALG_SID_SCHANNEL_MASTER_HASH: ALG_ID = 2; +pub const ALG_SID_SCHANNEL_MAC_KEY: ALG_ID = 3; +pub const ALG_SID_PCT1_MASTER: ALG_ID = 4; +pub const ALG_SID_SSL2_MASTER: ALG_ID = 5; +pub const ALG_SID_TLS1_MASTER: ALG_ID = 6; +pub const ALG_SID_SCHANNEL_ENC_KEY: ALG_ID = 7; +pub const ALG_SID_ECMQV: ALG_ID = 1; +pub const ALG_SID_EXAMPLE: ALG_ID = 80; +pub type ALG_ID = ::c_uint; +pub const CALG_MD2: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2; +pub const CALG_MD4: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4; +pub const CALG_MD5: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5; +pub const CALG_SHA: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA; +pub const CALG_SHA1: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1; +pub const CALG_MAC: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC; +pub const CALG_RSA_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; +pub const CALG_DSS_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY; +pub const CALG_NO_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | ALG_SID_ANY; +pub const CALG_RSA_KEYX: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; +pub const CALG_DES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES; +pub const CALG_3DES_112: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES_112; +pub const CALG_3DES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES; +pub const CALG_DESX: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX; +pub const CALG_RC2: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2; +pub const CALG_RC4: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4; +pub const CALG_SEAL: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL; +pub const CALG_DH_SF: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_SANDF; +pub const CALG_DH_EPHEM: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_EPHEM; +pub const CALG_AGREEDKEY_ANY: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH + | ALG_SID_AGREED_KEY_ANY; +pub const CALG_KEA_KEYX: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_KEA; +pub const CALG_HUGHES_MD5: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_MD5; +pub const CALG_SKIPJACK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_SKIPJACK; +pub const CALG_TEK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_TEK; +pub const CALG_CYLINK_MEK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_CYLINK_MEK; +pub const CALG_SSL3_SHAMD5: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SSL3SHAMD5; +pub const CALG_SSL3_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SSL3_MASTER; +pub const CALG_SCHANNEL_MASTER_HASH: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SCHANNEL_MASTER_HASH; +pub const CALG_SCHANNEL_MAC_KEY: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SCHANNEL_MAC_KEY; +pub const CALG_SCHANNEL_ENC_KEY: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SCHANNEL_ENC_KEY; +pub const CALG_PCT1_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_PCT1_MASTER; +pub const CALG_SSL2_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SSL2_MASTER; +pub const CALG_TLS1_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_TLS1_MASTER; +pub const CALG_RC5: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC5; +pub const CALG_HMAC: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HMAC; +pub const CALG_TLS1PRF: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF; +pub const CALG_HASH_REPLACE_OWF: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HASH_REPLACE_OWF; +pub const CALG_AES_128: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128; +pub const CALG_AES_192: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192; +pub const CALG_AES_256: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256; +pub const CALG_AES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES; +pub const CALG_SHA_256: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256; +pub const CALG_SHA_384: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384; +pub const CALG_SHA_512: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512; +pub const CALG_ECDH: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH; +pub const CALG_ECMQV: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV; +pub const CALG_ECDSA: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA; +pub type HCRYPTPROV = ::ULONG_PTR; +pub type HCRYPTKEY = ::ULONG_PTR; +pub type HCRYPTHASH = ::ULONG_PTR; +pub const CRYPT_VERIFYCONTEXT: ::DWORD = 0xF0000000; +pub const CRYPT_NEWKEYSET: ::DWORD = 0x00000008; +pub const CRYPT_DELETEKEYSET: ::DWORD = 0x00000010; +pub const CRYPT_MACHINE_KEYSET: ::DWORD = 0x00000020; +pub const CRYPT_SILENT: ::DWORD = 0x00000040; +pub const CRYPT_DEFAULT_CONTAINER_OPTIONAL: ::DWORD = 0x00000080; +pub const CRYPT_EXPORTABLE: ::DWORD = 0x00000001; +pub const CRYPT_USER_PROTECTED: ::DWORD = 0x00000002; +pub const CRYPT_CREATE_SALT: ::DWORD = 0x00000004; +pub const CRYPT_UPDATE_KEY: ::DWORD = 0x00000008; +pub const CRYPT_NO_SALT: ::DWORD = 0x00000010; +pub const CRYPT_PREGEN: ::DWORD = 0x00000040; +pub const CRYPT_RECIPIENT: ::DWORD = 0x00000010; +pub const CRYPT_INITIATOR: ::DWORD = 0x00000040; +pub const CRYPT_ONLINE: ::DWORD = 0x00000080; +pub const CRYPT_SF: ::DWORD = 0x00000100; +pub const CRYPT_CREATE_IV: ::DWORD = 0x00000200; +pub const CRYPT_KEK: ::DWORD = 0x00000400; +pub const CRYPT_DATA_KEY: ::DWORD = 0x00000800; +pub const CRYPT_VOLATILE: ::DWORD = 0x00001000; +pub const CRYPT_SGCKEY: ::DWORD = 0x00002000; +pub const CRYPT_USER_PROTECTED_STRONG: ::DWORD = 0x00100000; +pub const CRYPT_ARCHIVABLE: ::DWORD = 0x00004000; +pub const CRYPT_FORCE_KEY_PROTECTION_HIGH: ::DWORD = 0x00008000; +pub const RSA1024BIT_KEY: ::DWORD = 0x04000000; +pub const CRYPT_SERVER: ::DWORD = 0x00000400; +pub const KEY_LENGTH_MASK: ::DWORD = 0xFFFF0000; +pub const CRYPT_Y_ONLY: ::DWORD = 0x00000001; +pub const CRYPT_SSL2_FALLBACK: ::DWORD = 0x00000002; +pub const CRYPT_DESTROYKEY: ::DWORD = 0x00000004; +pub const CRYPT_OAEP: ::DWORD = 0x00000040; +pub const CRYPT_BLOB_VER3: ::DWORD = 0x00000080; +pub const CRYPT_IPSEC_HMAC_KEY: ::DWORD = 0x00000100; +pub const CRYPT_DECRYPT_RSA_NO_PADDING_CHECK: ::DWORD = 0x00000020; +pub const CRYPT_SECRETDIGEST: ::DWORD = 0x00000001; +pub const CRYPT_OWF_REPL_LM_HASH: ::DWORD = 0x00000001; +pub const CRYPT_LITTLE_ENDIAN: ::DWORD = 0x00000001; +pub const CRYPT_NOHASHOID: ::DWORD = 0x00000001; +pub const CRYPT_TYPE2_FORMAT: ::DWORD = 0x00000002; +pub const CRYPT_X931_FORMAT: ::DWORD = 0x00000004; +pub const CRYPT_MACHINE_DEFAULT: ::DWORD = 0x00000001; +pub const CRYPT_USER_DEFAULT: ::DWORD = 0x00000002; +pub const CRYPT_DELETE_DEFAULT: ::DWORD = 0x00000004; +pub const SIMPLEBLOB: ::DWORD = 0x1; +pub const PUBLICKEYBLOB: ::DWORD = 0x6; +pub const PRIVATEKEYBLOB: ::DWORD = 0x7; +pub const PLAINTEXTKEYBLOB: ::DWORD = 0x8; +pub const OPAQUEKEYBLOB: ::DWORD = 0x9; +pub const PUBLICKEYBLOBEX: ::DWORD = 0xA; +pub const SYMMETRICWRAPKEYBLOB: ::DWORD = 0xB; +pub const KEYSTATEBLOB: ::DWORD = 0xC; +pub const AT_KEYEXCHANGE: ::DWORD = 1; +pub const AT_SIGNATURE: ::DWORD = 2; +pub const CRYPT_USERDATA: ::DWORD = 1; +pub const KP_IV: ::DWORD = 1; +pub const KP_SALT: ::DWORD = 2; +pub const KP_PADDING: ::DWORD = 3; +pub const KP_MODE: ::DWORD = 4; +pub const KP_MODE_BITS: ::DWORD = 5; +pub const KP_PERMISSIONS: ::DWORD = 6; +pub const KP_ALGID: ::DWORD = 7; +pub const KP_BLOCKLEN: ::DWORD = 8; +pub const KP_KEYLEN: ::DWORD = 9; +pub const KP_SALT_EX: ::DWORD = 10; +pub const KP_P: ::DWORD = 11; +pub const KP_G: ::DWORD = 12; +pub const KP_Q: ::DWORD = 13; +pub const KP_X: ::DWORD = 14; +pub const KP_Y: ::DWORD = 15; +pub const KP_RA: ::DWORD = 16; +pub const KP_RB: ::DWORD = 17; +pub const KP_INFO: ::DWORD = 18; +pub const KP_EFFECTIVE_KEYLEN: ::DWORD = 19; +pub const KP_SCHANNEL_ALG: ::DWORD = 20; +pub const KP_CLIENT_RANDOM: ::DWORD = 21; +pub const KP_SERVER_RANDOM: ::DWORD = 22; +pub const KP_RP: ::DWORD = 23; +pub const KP_PRECOMP_MD5: ::DWORD = 24; +pub const KP_PRECOMP_SHA: ::DWORD = 25; +pub const KP_CERTIFICATE: ::DWORD = 26; +pub const KP_CLEAR_KEY: ::DWORD = 27; +pub const KP_PUB_EX_LEN: ::DWORD = 28; +pub const KP_PUB_EX_VAL: ::DWORD = 29; +pub const KP_KEYVAL: ::DWORD = 30; +pub const KP_ADMIN_PIN: ::DWORD = 31; +pub const KP_KEYEXCHANGE_PIN: ::DWORD = 32; +pub const KP_SIGNATURE_PIN: ::DWORD = 33; +pub const KP_PREHASH: ::DWORD = 34; +pub const KP_ROUNDS: ::DWORD = 35; +pub const KP_OAEP_PARAMS: ::DWORD = 36; +pub const KP_CMS_KEY_INFO: ::DWORD = 37; +pub const KP_CMS_DH_KEY_INFO: ::DWORD = 38; +pub const KP_PUB_PARAMS: ::DWORD = 39; +pub const KP_VERIFY_PARAMS: ::DWORD = 40; +pub const KP_HIGHEST_VERSION: ::DWORD = 41; +pub const KP_GET_USE_COUNT: ::DWORD = 42; +pub const KP_PIN_ID: ::DWORD = 43; +pub const KP_PIN_INFO: ::DWORD = 44; +pub const PKCS5_PADDING: ::DWORD = 1; +pub const RANDOM_PADDING: ::DWORD = 2; +pub const ZERO_PADDING: ::DWORD = 3; +pub const CRYPT_MODE_CBC: ::DWORD = 1; +pub const CRYPT_MODE_ECB: ::DWORD = 2; +pub const CRYPT_MODE_OFB: ::DWORD = 3; +pub const CRYPT_MODE_CFB: ::DWORD = 4; +pub const CRYPT_MODE_CTS: ::DWORD = 5; +pub const CRYPT_ENCRYPT: ::DWORD = 0x0001; +pub const CRYPT_DECRYPT: ::DWORD = 0x0002; +pub const CRYPT_EXPORT: ::DWORD = 0x0004; +pub const CRYPT_READ: ::DWORD = 0x0008; +pub const CRYPT_WRITE: ::DWORD = 0x0010; +pub const CRYPT_MAC: ::DWORD = 0x0020; +pub const CRYPT_EXPORT_KEY: ::DWORD = 0x0040; +pub const CRYPT_IMPORT_KEY: ::DWORD = 0x0080; +pub const CRYPT_ARCHIVE: ::DWORD = 0x0100; +pub const HP_ALGID: ::DWORD = 0x0001; +pub const HP_HASHVAL: ::DWORD = 0x0002; +pub const HP_HASHSIZE: ::DWORD = 0x0004; +pub const HP_HMAC_INFO: ::DWORD = 0x0005; +pub const HP_TLS1PRF_LABEL: ::DWORD = 0x0006; +pub const HP_TLS1PRF_SEED: ::DWORD = 0x0007; +pub const CRYPT_FAILED: ::BOOL = ::FALSE; +pub const CRYPT_SUCCEED: ::BOOL = ::TRUE; +pub const PP_ENUMALGS: ::DWORD = 1; +pub const PP_ENUMCONTAINERS: ::DWORD = 2; +pub const PP_IMPTYPE: ::DWORD = 3; +pub const PP_NAME: ::DWORD = 4; +pub const PP_VERSION: ::DWORD = 5; +pub const PP_CONTAINER: ::DWORD = 6; +pub const PP_CHANGE_PASSWORD: ::DWORD = 7; +pub const PP_KEYSET_SEC_DESCR: ::DWORD = 8; +pub const PP_CERTCHAIN: ::DWORD = 9; +pub const PP_KEY_TYPE_SUBTYPE: ::DWORD = 10; +pub const PP_PROVTYPE: ::DWORD = 16; +pub const PP_KEYSTORAGE: ::DWORD = 17; +pub const PP_APPLI_CERT: ::DWORD = 18; +pub const PP_SYM_KEYSIZE: ::DWORD = 19; +pub const PP_SESSION_KEYSIZE: ::DWORD = 20; +pub const PP_UI_PROMPT: ::DWORD = 21; +pub const PP_ENUMALGS_EX: ::DWORD = 22; +pub const PP_ENUMMANDROOTS: ::DWORD = 25; +pub const PP_ENUMELECTROOTS: ::DWORD = 26; +pub const PP_KEYSET_TYPE: ::DWORD = 27; +pub const PP_ADMIN_PIN: ::DWORD = 31; +pub const PP_KEYEXCHANGE_PIN: ::DWORD = 32; +pub const PP_SIGNATURE_PIN: ::DWORD = 33; +pub const PP_SIG_KEYSIZE_INC: ::DWORD = 34; +pub const PP_KEYX_KEYSIZE_INC: ::DWORD = 35; +pub const PP_UNIQUE_CONTAINER: ::DWORD = 36; +pub const PP_SGC_INFO: ::DWORD = 37; +pub const PP_USE_HARDWARE_RNG: ::DWORD = 38; +pub const PP_KEYSPEC: ::DWORD = 39; +pub const PP_ENUMEX_SIGNING_PROT: ::DWORD = 40; +pub const PP_CRYPT_COUNT_KEY_USE: ::DWORD = 41; +pub const PP_USER_CERTSTORE: ::DWORD = 42; +pub const PP_SMARTCARD_READER: ::DWORD = 43; +pub const PP_SMARTCARD_GUID: ::DWORD = 45; +pub const PP_ROOT_CERTSTORE: ::DWORD = 46; +pub const PP_SMARTCARD_READER_ICON: ::DWORD = 47; +pub const CRYPT_FIRST: ::DWORD = 1; +pub const CRYPT_NEXT: ::DWORD = 2; +pub const CRYPT_SGC_ENUM: ::DWORD = 4; +pub const CRYPT_IMPL_HARDWARE: ::DWORD = 1; +pub const CRYPT_IMPL_SOFTWARE: ::DWORD = 2; +pub const CRYPT_IMPL_MIXED: ::DWORD = 3; +pub const CRYPT_IMPL_UNKNOWN: ::DWORD = 4; +pub const CRYPT_IMPL_REMOVABLE: ::DWORD = 8; +pub const CRYPT_SEC_DESCR: ::DWORD = 0x00000001; +pub const CRYPT_PSTORE: ::DWORD = 0x00000002; +pub const CRYPT_UI_PROMPT: ::DWORD = 0x00000004; +pub const CRYPT_FLAG_PCT1: ::DWORD = 0x0001; +pub const CRYPT_FLAG_SSL2: ::DWORD = 0x0002; +pub const CRYPT_FLAG_SSL3: ::DWORD = 0x0004; +pub const CRYPT_FLAG_TLS1: ::DWORD = 0x0008; +pub const CRYPT_FLAG_IPSEC: ::DWORD = 0x0010; +pub const CRYPT_FLAG_SIGNING: ::DWORD = 0x0020; +pub const CRYPT_SGC: ::DWORD = 0x0001; +pub const CRYPT_FASTSGC: ::DWORD = 0x0002; +pub const PP_CLIENT_HWND: ::DWORD = 1; +pub const PP_CONTEXT_INFO: ::DWORD = 11; +pub const PP_KEYEXCHANGE_KEYSIZE: ::DWORD = 12; +pub const PP_SIGNATURE_KEYSIZE: ::DWORD = 13; +pub const PP_KEYEXCHANGE_ALG: ::DWORD = 14; +pub const PP_SIGNATURE_ALG: ::DWORD = 15; +pub const PP_DELETEKEY: ::DWORD = 24; +pub const PP_PIN_PROMPT_STRING: ::DWORD = 44; +pub const PP_SECURE_KEYEXCHANGE_PIN: ::DWORD = 47; +pub const PP_SECURE_SIGNATURE_PIN: ::DWORD = 48; +pub const PROV_RSA_FULL: ::DWORD = 1; +pub const PROV_RSA_SIG: ::DWORD = 2; +pub const PROV_DSS: ::DWORD = 3; +pub const PROV_FORTEZZA: ::DWORD = 4; +pub const PROV_MS_EXCHANGE: ::DWORD = 5; +pub const PROV_SSL: ::DWORD = 6; +pub const PROV_RSA_SCHANNEL: ::DWORD = 12; +pub const PROV_DSS_DH: ::DWORD = 13; +pub const PROV_EC_ECDSA_SIG: ::DWORD = 14; +pub const PROV_EC_ECNRA_SIG: ::DWORD = 15; +pub const PROV_EC_ECDSA_FULL: ::DWORD = 16; +pub const PROV_EC_ECNRA_FULL: ::DWORD = 17; +pub const PROV_DH_SCHANNEL: ::DWORD = 18; +pub const PROV_SPYRUS_LYNKS: ::DWORD = 20; +pub const PROV_RNG: ::DWORD = 21; +pub const PROV_INTEL_SEC: ::DWORD = 22; +pub const PROV_REPLACE_OWF: ::DWORD = 23; +pub const PROV_RSA_AES: ::DWORD = 24; +pub const MS_DEF_PROV: &'static str = "Microsoft Base Cryptographic Provider v1.0"; +pub const MS_ENHANCED_PROV: &'static str = "Microsoft Enhanced Cryptographic Provider v1.0"; +pub const MS_STRONG_PROV: &'static str = "Microsoft Strong Cryptographic Provider"; +pub const MS_DEF_RSA_SIG_PROV: &'static str = "Microsoft RSA Signature Cryptographic Provider"; +pub const MS_DEF_RSA_SCHANNEL_PROV: &'static str = "Microsoft RSA SChannel Cryptographic Provider"; +pub const MS_DEF_DSS_PROV: &'static str = "Microsoft Base DSS Cryptographic Provider"; +pub const MS_DEF_DSS_DH_PROV: &'static str = + "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"; +pub const MS_ENH_DSS_DH_PROV: &'static str = + "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"; +pub const MS_DEF_DH_SCHANNEL_PROV: &'static str = "Microsoft DH SChannel Cryptographic Provider"; +pub const MS_SCARD_PROV: &'static str = "Microsoft Base Smart Card Crypto Provider"; +pub const MS_ENH_RSA_AES_PROV: &'static str = + "Microsoft Enhanced RSA and AES Cryptographic Provider"; +pub const MS_ENH_RSA_AES_PROV_XP: &'static str = + "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)"; +pub const MAXUIDLEN: usize = 64; +pub const EXPO_OFFLOAD_REG_VALUE: &'static str = "ExpoOffload"; +pub const EXPO_OFFLOAD_FUNC_NAME: &'static str = "OffloadModExpo"; +pub const szKEY_CRYPTOAPI_PRIVATE_KEY_OPTIONS: &'static str = + "Software\\Policies\\Microsoft\\Cryptography"; +pub const szKEY_CACHE_ENABLED: &'static str = "CachePrivateKeys"; +pub const szKEY_CACHE_SECONDS: &'static str = "PrivateKeyLifetimeSeconds"; +pub const szPRIV_KEY_CACHE_MAX_ITEMS: &'static str = "PrivKeyCacheMaxItems"; +pub const cPRIV_KEY_CACHE_MAX_ITEMS_DEFAULT: ::DWORD = 20; +pub const szPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS: &'static str = + "PrivKeyCachePurgeIntervalSeconds"; +pub const cPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS_DEFAULT: ::DWORD = 86400; +pub const CUR_BLOB_VERSION: ::DWORD = 2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CMS_KEY_INFO { + pub dwVersion: ::DWORD, + pub Algid: ALG_ID, + pub pbOID: *mut ::BYTE, + pub cbOID: ::DWORD, +} +pub type PCMS_KEY_INFO = *mut CMS_KEY_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HMAC_INFO { + pub HashAlgid: ALG_ID, + pub pbInnerString: *mut ::BYTE, + pub cbInnerString: ::DWORD, + pub pbOuterString: *mut ::BYTE, + pub cbOuterString: ::DWORD, +} +pub type PHMAC_INFO = *mut HMAC_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SCHANNEL_ALG { + pub dwUse: ::DWORD, + pub Algid: ALG_ID, + pub cBits: ::DWORD, + pub dwFlags: ::DWORD, + pub dwReserved: ::DWORD, +} +pub type PSCHANNEL_ALG = *mut SCHANNEL_ALG; +pub const SCHANNEL_MAC_KEY: ::DWORD = 0x00000000; +pub const SCHANNEL_ENC_KEY: ::DWORD = 0x00000001; +pub const INTERNATIONAL_USAGE: ::DWORD = 0x00000001; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROV_ENUMALGS { + pub aiAlgid: ALG_ID, + pub dwBitLen: ::DWORD, + pub dwNameLen: ::DWORD, + pub szName: [::CHAR; 20], +} +#[repr(C)] #[derive(Copy)] +pub struct PROV_ENUMALGS_EX { + pub aiAlgid: ALG_ID, + pub dwDefaultLen: ::DWORD, + pub dwMinLen: ::DWORD, + pub dwMaxLen: ::DWORD, + pub dwProtocols: ::DWORD, + pub dwNameLen: ::DWORD, + pub szName: [::CHAR; 20], + pub dwLongNameLen: ::DWORD, + pub szLongName: [::CHAR; 40], +} +impl Clone for PROV_ENUMALGS_EX { fn clone(&self) -> PROV_ENUMALGS_EX { *self } } +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct BLOBHEADER { + pub bType: ::BYTE, + pub bVersion: ::BYTE, + pub reserved: ::WORD, + pub aiKeyAlg: ::ALG_ID, +} +pub type PUBLICKEYSTRUC = BLOBHEADER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RSAPUBKEY { + pub magic: ::DWORD, + pub bitlen: ::DWORD, + pub pubexp: ::DWORD, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DHPUBKEY { + pub magic: ::DWORD, + pub bitlen: ::DWORD, +} +pub type DSSPUBKEY = DHPUBKEY; +pub type KEAPUBKEY = DHPUBKEY; +pub type TEKPUBKEY = DHPUBKEY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DSSSEED { + pub counter: ::DWORD, + pub seed: [::BYTE; 20], +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DHPUBKEY_VER3 { + pub magic: ::DWORD, + pub bitlenP: ::DWORD, + pub bitlenQ: ::DWORD, + pub bitlenJ: ::DWORD, + pub DSSSeed: DSSSEED, +} +pub type DSSPUBKEY_VER3 = DHPUBKEY_VER3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DHPRIVKEY_VER3 { + pub magic: ::DWORD, + pub bitlenP: ::DWORD, + pub bitlenQ: ::DWORD, + pub bitlenJ: ::DWORD, + pub bitlenX: ::DWORD, + pub DSSSeed: DSSSEED, +} +pub type DSSPRIVKEY_VER3 = DHPRIVKEY_VER3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct KEY_TYPE_SUBTYPE { + pub dwKeySpec: ::DWORD, + pub Type: ::GUID, + pub Subtype: ::GUID, +} +pub type PKEY_TYPE_SUBTYPE = *mut KEY_TYPE_SUBTYPE; +#[repr(C)] #[derive(Copy)] +pub struct CERT_FORTEZZA_DATA_PROP { + pub SerialNumber: [::c_uchar; 8], + pub CertIndex: ::c_int, + pub CertLabel: [::c_uchar; 36], +} +impl Clone for CERT_FORTEZZA_DATA_PROP { fn clone(&self) -> CERT_FORTEZZA_DATA_PROP { *self } } +#[repr(C)] #[derive(Copy)] +pub struct CRYPT_RC4_KEY_STATE { + pub Key: [::c_uchar; 16], + pub SBox: [::c_uchar; 256], + pub i: ::c_uchar, + pub j: ::c_uchar, +} +impl Clone for CRYPT_RC4_KEY_STATE { fn clone(&self) -> CRYPT_RC4_KEY_STATE { *self } } +pub type PCRYPT_RC4_KEY_STATE = *mut CRYPT_RC4_KEY_STATE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_DES_KEY_STATE { + pub Key: [::c_uchar; 8], + pub IV: [::c_uchar; 8], + pub Feedback: [::c_uchar; 8], +} +pub type PCRYPT_DES_KEY_STATE = *mut CRYPT_DES_KEY_STATE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_3DES_KEY_STATE { + pub Key: [::c_uchar; 24], + pub IV: [::c_uchar; 8], + pub Feedback: [::c_uchar; 8], +} +pub type PCRYPT_3DES_KEY_STATE = *mut CRYPT_3DES_KEY_STATE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_AES_128_KEY_STATE { + pub Key: [::c_uchar; 16], + pub IV: [::c_uchar; 16], + pub EncryptionState: [[::c_uchar; 16]; 11], + pub DecryptionState: [[::c_uchar; 16]; 11], + pub Feedback: [::c_uchar; 16], +} +pub type PCRYPT_AES_128_KEY_STATE = *mut CRYPT_AES_128_KEY_STATE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_AES_256_KEY_STATE { + pub Key: [::c_uchar; 32], + pub IV: [::c_uchar; 16], + pub EncryptionState: [[::c_uchar; 16]; 15], + pub DecryptionState: [[::c_uchar; 16]; 15], + pub Feedback: [::c_uchar; 16], +} +pub type PCRYPT_AES_256_KEY_STATE = *mut CRYPT_AES_256_KEY_STATE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPTOAPI_BLOB { + pub cbData: ::DWORD, + pub pbData: *mut ::BYTE, +} +pub type CRYPT_INTEGER_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_INTEGER_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_UINT_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_UINT_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_OBJID_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_OBJID_BLOB = *mut CRYPTOAPI_BLOB; +pub type CERT_NAME_BLOB = CRYPTOAPI_BLOB; +pub type PCERT_NAME_BLOB = *mut CRYPTOAPI_BLOB; +pub type CERT_RDN_VALUE_BLOB = CRYPTOAPI_BLOB; +pub type PCERT_RDN_VALUE_BLOB = *mut CRYPTOAPI_BLOB; +pub type CERT_BLOB = CRYPTOAPI_BLOB; +pub type PCERT_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRL_BLOB = CRYPTOAPI_BLOB; +pub type PCRL_BLOB = *mut CRYPTOAPI_BLOB; +pub type DATA_BLOB = CRYPTOAPI_BLOB; +pub type PDATA_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_DATA_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_DATA_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_HASH_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_HASH_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_DIGEST_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_DIGEST_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_DER_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_DER_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_ATTR_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_ATTR_BLOB = *mut CRYPTOAPI_BLOB; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CMS_DH_KEY_INFO { + pub dwVersion: ::DWORD, + pub Algid: ALG_ID, + pub pszContentEncObjId: ::LPSTR, + pub PubInfo: CRYPT_DATA_BLOB, + pub pReserved: *mut ::c_void, +} +pub type PCMS_DH_KEY_INFO = *mut CMS_DH_KEY_INFO; +pub type HCRYPTPROV_OR_NCRYPT_KEY_HANDLE = ::ULONG_PTR; +pub type HCRYPTPROV_LEGACY = ::ULONG_PTR; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_BIT_BLOB { + pub cbData: ::DWORD, + pub pbData: *mut ::BYTE, + pub cUnusedBits: ::DWORD, +} +pub type PCRYPT_BIT_BLOB = *mut CRYPT_BIT_BLOB; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ALGORITHM_IDENTIFIER { + pub pszObjId: ::LPSTR, + pub Parameters: CRYPT_OBJID_BLOB, +} +pub type PCRYPT_ALGORITHM_IDENTIFIER = *mut CRYPT_ALGORITHM_IDENTIFIER; +pub const szOID_RSA: &'static str = "1.2.840.113549"; +pub const szOID_PKCS: &'static str = "1.2.840.113549.1"; +pub const szOID_RSA_HASH: &'static str = "1.2.840.113549.2"; +pub const szOID_RSA_ENCRYPT: &'static str = "1.2.840.113549.3"; +pub const szOID_PKCS_1: &'static str = "1.2.840.113549.1.1"; +pub const szOID_PKCS_2: &'static str = "1.2.840.113549.1.2"; +pub const szOID_PKCS_3: &'static str = "1.2.840.113549.1.3"; +pub const szOID_PKCS_4: &'static str = "1.2.840.113549.1.4"; +pub const szOID_PKCS_5: &'static str = "1.2.840.113549.1.5"; +pub const szOID_PKCS_6: &'static str = "1.2.840.113549.1.6"; +pub const szOID_PKCS_7: &'static str = "1.2.840.113549.1.7"; +pub const szOID_PKCS_8: &'static str = "1.2.840.113549.1.8"; +pub const szOID_PKCS_9: &'static str = "1.2.840.113549.1.9"; +pub const szOID_PKCS_10: &'static str = "1.2.840.113549.1.10"; +pub const szOID_PKCS_12: &'static str = "1.2.840.113549.1.12"; +pub const szOID_RSA_RSA: &'static str = "1.2.840.113549.1.1.1"; +pub const szOID_RSA_MD2RSA: &'static str = "1.2.840.113549.1.1.2"; +pub const szOID_RSA_MD4RSA: &'static str = "1.2.840.113549.1.1.3"; +pub const szOID_RSA_MD5RSA: &'static str = "1.2.840.113549.1.1.4"; +pub const szOID_RSA_SHA1RSA: &'static str = "1.2.840.113549.1.1.5"; +pub const szOID_RSA_SETOAEP_RSA: &'static str = "1.2.840.113549.1.1.6"; +pub const szOID_RSAES_OAEP: &'static str = "1.2.840.113549.1.1.7"; +pub const szOID_RSA_MGF1: &'static str = "1.2.840.113549.1.1.8"; +pub const szOID_RSA_PSPECIFIED: &'static str = "1.2.840.113549.1.1.9"; +pub const szOID_RSA_SSA_PSS: &'static str = "1.2.840.113549.1.1.10"; +pub const szOID_RSA_SHA256RSA: &'static str = "1.2.840.113549.1.1.11"; +pub const szOID_RSA_SHA384RSA: &'static str = "1.2.840.113549.1.1.12"; +pub const szOID_RSA_SHA512RSA: &'static str = "1.2.840.113549.1.1.13"; +pub const szOID_RSA_DH: &'static str = "1.2.840.113549.1.3.1"; +pub const szOID_RSA_data: &'static str = "1.2.840.113549.1.7.1"; +pub const szOID_RSA_signedData: &'static str = "1.2.840.113549.1.7.2"; +pub const szOID_RSA_envelopedData: &'static str = "1.2.840.113549.1.7.3"; +pub const szOID_RSA_signEnvData: &'static str = "1.2.840.113549.1.7.4"; +pub const szOID_RSA_digestedData: &'static str = "1.2.840.113549.1.7.5"; +pub const szOID_RSA_hashedData: &'static str = "1.2.840.113549.1.7.5"; +pub const szOID_RSA_encryptedData: &'static str = "1.2.840.113549.1.7.6"; +pub const szOID_RSA_emailAddr: &'static str = "1.2.840.113549.1.9.1"; +pub const szOID_RSA_unstructName: &'static str = "1.2.840.113549.1.9.2"; +pub const szOID_RSA_contentType: &'static str = "1.2.840.113549.1.9.3"; +pub const szOID_RSA_messageDigest: &'static str = "1.2.840.113549.1.9.4"; +pub const szOID_RSA_signingTime: &'static str = "1.2.840.113549.1.9.5"; +pub const szOID_RSA_counterSign: &'static str = "1.2.840.113549.1.9.6"; +pub const szOID_RSA_challengePwd: &'static str = "1.2.840.113549.1.9.7"; +pub const szOID_RSA_unstructAddr: &'static str = "1.2.840.113549.1.9.8"; +pub const szOID_RSA_extCertAttrs: &'static str = "1.2.840.113549.1.9.9"; +pub const szOID_RSA_certExtensions: &'static str = "1.2.840.113549.1.9.14"; +pub const szOID_RSA_SMIMECapabilities: &'static str = "1.2.840.113549.1.9.15"; +pub const szOID_RSA_preferSignedData: &'static str = "1.2.840.113549.1.9.15.1"; +pub const szOID_TIMESTAMP_TOKEN: &'static str = "1.2.840.113549.1.9.16.1.4"; +pub const szOID_RFC3161_counterSign: &'static str = "1.3.6.1.4.1.311.3.3.1"; +pub const szOID_RSA_SMIMEalg: &'static str = "1.2.840.113549.1.9.16.3"; +pub const szOID_RSA_SMIMEalgESDH: &'static str = "1.2.840.113549.1.9.16.3.5"; +pub const szOID_RSA_SMIMEalgCMS3DESwrap: &'static str = "1.2.840.113549.1.9.16.3.6"; +pub const szOID_RSA_SMIMEalgCMSRC2wrap: &'static str = "1.2.840.113549.1.9.16.3.7"; +pub const szOID_RSA_MD2: &'static str = "1.2.840.113549.2.2"; +pub const szOID_RSA_MD4: &'static str = "1.2.840.113549.2.4"; +pub const szOID_RSA_MD5: &'static str = "1.2.840.113549.2.5"; +pub const szOID_RSA_RC2CBC: &'static str = "1.2.840.113549.3.2"; +pub const szOID_RSA_RC4: &'static str = "1.2.840.113549.3.4"; +pub const szOID_RSA_DES_EDE3_CBC: &'static str = "1.2.840.113549.3.7"; +pub const szOID_RSA_RC5_CBCPad: &'static str = "1.2.840.113549.3.9"; +pub const szOID_ANSI_X942: &'static str = "1.2.840.10046"; +pub const szOID_ANSI_X942_DH: &'static str = "1.2.840.10046.2.1"; +pub const szOID_X957: &'static str = "1.2.840.10040"; +pub const szOID_X957_DSA: &'static str = "1.2.840.10040.4.1"; +pub const szOID_X957_SHA1DSA: &'static str = "1.2.840.10040.4.3"; +pub const szOID_ECC_PUBLIC_KEY: &'static str = "1.2.840.10045.2.1"; +pub const szOID_ECC_CURVE_P256: &'static str = "1.2.840.10045.3.1.7"; +pub const szOID_ECC_CURVE_P384: &'static str = "1.3.132.0.34"; +pub const szOID_ECC_CURVE_P521: &'static str = "1.3.132.0.35"; +pub const szOID_ECDSA_SHA1: &'static str = "1.2.840.10045.4.1"; +pub const szOID_ECDSA_SPECIFIED: &'static str = "1.2.840.10045.4.3"; +pub const szOID_ECDSA_SHA256: &'static str = "1.2.840.10045.4.3.2"; +pub const szOID_ECDSA_SHA384: &'static str = "1.2.840.10045.4.3.3"; +pub const szOID_ECDSA_SHA512: &'static str = "1.2.840.10045.4.3.4"; +pub const szOID_NIST_AES128_CBC: &'static str = "2.16.840.1.101.3.4.1.2"; +pub const szOID_NIST_AES192_CBC: &'static str = "2.16.840.1.101.3.4.1.22"; +pub const szOID_NIST_AES256_CBC: &'static str = "2.16.840.1.101.3.4.1.42"; +pub const szOID_NIST_AES128_WRAP: &'static str = "2.16.840.1.101.3.4.1.5"; +pub const szOID_NIST_AES192_WRAP: &'static str = "2.16.840.1.101.3.4.1.25"; +pub const szOID_NIST_AES256_WRAP: &'static str = "2.16.840.1.101.3.4.1.45"; +pub const szOID_DH_SINGLE_PASS_STDDH_SHA1_KDF: &'static str = "1.3.133.16.840.63.0.2"; +pub const szOID_DH_SINGLE_PASS_STDDH_SHA256_KDF: &'static str = "1.3.132.1.11.1"; +pub const szOID_DH_SINGLE_PASS_STDDH_SHA384_KDF: &'static str = "1.3.132.1.11.2"; +pub const szOID_DS: &'static str = "2.5"; +pub const szOID_DSALG: &'static str = "2.5.8"; +pub const szOID_DSALG_CRPT: &'static str = "2.5.8.1"; +pub const szOID_DSALG_HASH: &'static str = "2.5.8.2"; +pub const szOID_DSALG_SIGN: &'static str = "2.5.8.3"; +pub const szOID_DSALG_RSA: &'static str = "2.5.8.1.1"; +pub const szOID_OIW: &'static str = "1.3.14"; +pub const szOID_OIWSEC: &'static str = "1.3.14.3.2"; +pub const szOID_OIWSEC_md4RSA: &'static str = "1.3.14.3.2.2"; +pub const szOID_OIWSEC_md5RSA: &'static str = "1.3.14.3.2.3"; +pub const szOID_OIWSEC_md4RSA2: &'static str = "1.3.14.3.2.4"; +pub const szOID_OIWSEC_desECB: &'static str = "1.3.14.3.2.6"; +pub const szOID_OIWSEC_desCBC: &'static str = "1.3.14.3.2.7"; +pub const szOID_OIWSEC_desOFB: &'static str = "1.3.14.3.2.8"; +pub const szOID_OIWSEC_desCFB: &'static str = "1.3.14.3.2.9"; +pub const szOID_OIWSEC_desMAC: &'static str = "1.3.14.3.2.10"; +pub const szOID_OIWSEC_rsaSign: &'static str = "1.3.14.3.2.11"; +pub const szOID_OIWSEC_dsa: &'static str = "1.3.14.3.2.12"; +pub const szOID_OIWSEC_shaDSA: &'static str = "1.3.14.3.2.13"; +pub const szOID_OIWSEC_mdc2RSA: &'static str = "1.3.14.3.2.14"; +pub const szOID_OIWSEC_shaRSA: &'static str = "1.3.14.3.2.15"; +pub const szOID_OIWSEC_dhCommMod: &'static str = "1.3.14.3.2.16"; +pub const szOID_OIWSEC_desEDE: &'static str = "1.3.14.3.2.17"; +pub const szOID_OIWSEC_sha: &'static str = "1.3.14.3.2.18"; +pub const szOID_OIWSEC_mdc2: &'static str = "1.3.14.3.2.19"; +pub const szOID_OIWSEC_dsaComm: &'static str = "1.3.14.3.2.20"; +pub const szOID_OIWSEC_dsaCommSHA: &'static str = "1.3.14.3.2.21"; +pub const szOID_OIWSEC_rsaXchg: &'static str = "1.3.14.3.2.22"; +pub const szOID_OIWSEC_keyHashSeal: &'static str = "1.3.14.3.2.23"; +pub const szOID_OIWSEC_md2RSASign: &'static str = "1.3.14.3.2.24"; +pub const szOID_OIWSEC_md5RSASign: &'static str = "1.3.14.3.2.25"; +pub const szOID_OIWSEC_sha1: &'static str = "1.3.14.3.2.26"; +pub const szOID_OIWSEC_dsaSHA1: &'static str = "1.3.14.3.2.27"; +pub const szOID_OIWSEC_dsaCommSHA1: &'static str = "1.3.14.3.2.28"; +pub const szOID_OIWSEC_sha1RSASign: &'static str = "1.3.14.3.2.29"; +pub const szOID_OIWDIR: &'static str = "1.3.14.7.2"; +pub const szOID_OIWDIR_CRPT: &'static str = "1.3.14.7.2.1"; +pub const szOID_OIWDIR_HASH: &'static str = "1.3.14.7.2.2"; +pub const szOID_OIWDIR_SIGN: &'static str = "1.3.14.7.2.3"; +pub const szOID_OIWDIR_md2: &'static str = "1.3.14.7.2.2.1"; +pub const szOID_OIWDIR_md2RSA: &'static str = "1.3.14.7.2.3.1"; +pub const szOID_INFOSEC: &'static str = "2.16.840.1.101.2.1"; +pub const szOID_INFOSEC_sdnsSignature: &'static str = "2.16.840.1.101.2.1.1.1"; +pub const szOID_INFOSEC_mosaicSignature: &'static str = "2.16.840.1.101.2.1.1.2"; +pub const szOID_INFOSEC_sdnsConfidentiality: &'static str = "2.16.840.1.101.2.1.1.3"; +pub const szOID_INFOSEC_mosaicConfidentiality: &'static str = "2.16.840.1.101.2.1.1.4"; +pub const szOID_INFOSEC_sdnsIntegrity: &'static str = "2.16.840.1.101.2.1.1.5"; +pub const szOID_INFOSEC_mosaicIntegrity: &'static str = "2.16.840.1.101.2.1.1.6"; +pub const szOID_INFOSEC_sdnsTokenProtection: &'static str = "2.16.840.1.101.2.1.1.7"; +pub const szOID_INFOSEC_mosaicTokenProtection: &'static str = "2.16.840.1.101.2.1.1.8"; +pub const szOID_INFOSEC_sdnsKeyManagement: &'static str = "2.16.840.1.101.2.1.1.9"; +pub const szOID_INFOSEC_mosaicKeyManagement: &'static str = "2.16.840.1.101.2.1.1.10"; +pub const szOID_INFOSEC_sdnsKMandSig: &'static str = "2.16.840.1.101.2.1.1.11"; +pub const szOID_INFOSEC_mosaicKMandSig: &'static str = "2.16.840.1.101.2.1.1.12"; +pub const szOID_INFOSEC_SuiteASignature: &'static str = "2.16.840.1.101.2.1.1.13"; +pub const szOID_INFOSEC_SuiteAConfidentiality: &'static str = "2.16.840.1.101.2.1.1.14"; +pub const szOID_INFOSEC_SuiteAIntegrity: &'static str = "2.16.840.1.101.2.1.1.15"; +pub const szOID_INFOSEC_SuiteATokenProtection: &'static str = "2.16.840.1.101.2.1.1.16"; +pub const szOID_INFOSEC_SuiteAKeyManagement: &'static str = "2.16.840.1.101.2.1.1.17"; +pub const szOID_INFOSEC_SuiteAKMandSig: &'static str = "2.16.840.1.101.2.1.1.18"; +pub const szOID_INFOSEC_mosaicUpdatedSig: &'static str = "2.16.840.1.101.2.1.1.19"; +pub const szOID_INFOSEC_mosaicKMandUpdSig: &'static str = "2.16.840.1.101.2.1.1.20"; +pub const szOID_INFOSEC_mosaicUpdatedInteg: &'static str = "2.16.840.1.101.2.1.1.21"; +pub const szOID_NIST_sha256: &'static str = "2.16.840.1.101.3.4.2.1"; +pub const szOID_NIST_sha384: &'static str = "2.16.840.1.101.3.4.2.2"; +pub const szOID_NIST_sha512: &'static str = "2.16.840.1.101.3.4.2.3"; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_OBJID_TABLE { + pub dwAlgId: ::DWORD, + pub pszObjId: ::LPCSTR, +} +pub type PCRYPT_OBJID_TABLE = *mut CRYPT_OBJID_TABLE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_HASH_INFO { + pub HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub Hash: CRYPT_HASH_BLOB, +} +pub type PCRYPT_HASH_INFO = *mut CRYPT_HASH_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_EXTENSION { + pub pszObjId: ::LPSTR, + pub fCritical: ::BOOL, + pub Value: CRYPT_OBJID_BLOB, +} +pub type PCERT_EXTENSION = *mut CERT_EXTENSION; +pub type PCCERT_EXTENSION = *const CERT_EXTENSION; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ATTRIBUTE_TYPE_VALUE { + pub pszObjId: ::LPSTR, + pub Value: CRYPT_OBJID_BLOB, +} +pub type PCRYPT_ATTRIBUTE_TYPE_VALUE = *mut CRYPT_ATTRIBUTE_TYPE_VALUE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ATTRIBUTE { + pub pszObjId: ::LPSTR, + pub cValue: ::DWORD, + pub rgValue: PCRYPT_ATTR_BLOB, +} +pub type PCRYPT_ATTRIBUTE = *mut CRYPT_ATTRIBUTE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ATTRIBUTES { + pub cAttr: ::DWORD, + pub rgAttr: PCRYPT_ATTRIBUTE, +} +pub type PCRYPT_ATTRIBUTES = *mut CRYPT_ATTRIBUTES; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_RDN_ATTR { + pub pszObjId: ::LPSTR, + pub dwValueType: ::DWORD, + pub Value: CERT_RDN_VALUE_BLOB, +} +pub type PCERT_RDN_ATTR = *mut CERT_RDN_ATTR; +pub const szOID_COMMON_NAME: &'static str = "2.5.4.3"; +pub const szOID_SUR_NAME: &'static str = "2.5.4.4"; +pub const szOID_DEVICE_SERIAL_NUMBER: &'static str = "2.5.4.5"; +pub const szOID_COUNTRY_NAME: &'static str = "2.5.4.6"; +pub const szOID_LOCALITY_NAME: &'static str = "2.5.4.7"; +pub const szOID_STATE_OR_PROVINCE_NAME: &'static str = "2.5.4.8"; +pub const szOID_STREET_ADDRESS: &'static str = "2.5.4.9"; +pub const szOID_ORGANIZATION_NAME: &'static str = "2.5.4.10"; +pub const szOID_ORGANIZATIONAL_UNIT_NAME: &'static str = "2.5.4.11"; +pub const szOID_TITLE: &'static str = "2.5.4.12"; +pub const szOID_DESCRIPTION: &'static str = "2.5.4.13"; +pub const szOID_SEARCH_GUIDE: &'static str = "2.5.4.14"; +pub const szOID_BUSINESS_CATEGORY: &'static str = "2.5.4.15"; +pub const szOID_POSTAL_ADDRESS: &'static str = "2.5.4.16"; +pub const szOID_POSTAL_CODE: &'static str = "2.5.4.17"; +pub const szOID_POST_OFFICE_BOX: &'static str = "2.5.4.18"; +pub const szOID_PHYSICAL_DELIVERY_OFFICE_NAME: &'static str = "2.5.4.19"; +pub const szOID_TELEPHONE_NUMBER: &'static str = "2.5.4.20"; +pub const szOID_TELEX_NUMBER: &'static str = "2.5.4.21"; +pub const szOID_TELETEXT_TERMINAL_IDENTIFIER: &'static str = "2.5.4.22"; +pub const szOID_FACSIMILE_TELEPHONE_NUMBER: &'static str = "2.5.4.23"; +pub const szOID_X21_ADDRESS: &'static str = "2.5.4.24"; +pub const szOID_INTERNATIONAL_ISDN_NUMBER: &'static str = "2.5.4.25"; +pub const szOID_REGISTERED_ADDRESS: &'static str = "2.5.4.26"; +pub const szOID_DESTINATION_INDICATOR: &'static str = "2.5.4.27"; +pub const szOID_PREFERRED_DELIVERY_METHOD: &'static str = "2.5.4.28"; +pub const szOID_PRESENTATION_ADDRESS: &'static str = "2.5.4.29"; +pub const szOID_SUPPORTED_APPLICATION_CONTEXT: &'static str = "2.5.4.30"; +pub const szOID_MEMBER: &'static str = "2.5.4.31"; +pub const szOID_OWNER: &'static str = "2.5.4.32"; +pub const szOID_ROLE_OCCUPANT: &'static str = "2.5.4.33"; +pub const szOID_SEE_ALSO: &'static str = "2.5.4.34"; +pub const szOID_USER_PASSWORD: &'static str = "2.5.4.35"; +pub const szOID_USER_CERTIFICATE: &'static str = "2.5.4.36"; +pub const szOID_CA_CERTIFICATE: &'static str = "2.5.4.37"; +pub const szOID_AUTHORITY_REVOCATION_LIST: &'static str = "2.5.4.38"; +pub const szOID_CERTIFICATE_REVOCATION_LIST: &'static str = "2.5.4.39"; +pub const szOID_CROSS_CERTIFICATE_PAIR: &'static str = "2.5.4.40"; +pub const szOID_GIVEN_NAME: &'static str = "2.5.4.42"; +pub const szOID_INITIALS: &'static str = "2.5.4.43"; +pub const szOID_DN_QUALIFIER: &'static str = "2.5.4.46"; +pub const szOID_DOMAIN_COMPONENT: &'static str = "0.9.2342.19200300.100.1.25"; +pub const szOID_PKCS_12_FRIENDLY_NAME_ATTR: &'static str = "1.2.840.113549.1.9.20"; +pub const szOID_PKCS_12_LOCAL_KEY_ID: &'static str = "1.2.840.113549.1.9.21"; +pub const szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR: &'static str = "1.3.6.1.4.1.311.17.1"; +pub const szOID_LOCAL_MACHINE_KEYSET: &'static str = "1.3.6.1.4.1.311.17.2"; +pub const szOID_PKCS_12_EXTENDED_ATTRIBUTES: &'static str = "1.3.6.1.4.1.311.17.3"; +pub const szOID_PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID: &'static str = + "1.3.6.1.4.1.311.17.4"; +pub const szOID_KEYID_RDN: &'static str = "1.3.6.1.4.1.311.10.7.1"; +pub const szOID_EV_RDN_LOCALE: &'static str = "1.3.6.1.4.1.311.60.2.1.1"; +pub const szOID_EV_RDN_STATE_OR_PROVINCE: &'static str = "1.3.6.1.4.1.311.60.2.1.2"; +pub const szOID_EV_RDN_COUNTRY: &'static str = "1.3.6.1.4.1.311.60.2.1.3"; +pub const CERT_RDN_ANY_TYPE: ::DWORD = 0; +pub const CERT_RDN_ENCODED_BLOB: ::DWORD = 1; +pub const CERT_RDN_OCTET_STRING: ::DWORD = 2; +pub const CERT_RDN_NUMERIC_STRING: ::DWORD = 3; +pub const CERT_RDN_PRINTABLE_STRING: ::DWORD = 4; +pub const CERT_RDN_TELETEX_STRING: ::DWORD = 5; +pub const CERT_RDN_T61_STRING: ::DWORD = 5; +pub const CERT_RDN_VIDEOTEX_STRING: ::DWORD = 6; +pub const CERT_RDN_IA5_STRING: ::DWORD = 7; +pub const CERT_RDN_GRAPHIC_STRING: ::DWORD = 8; +pub const CERT_RDN_VISIBLE_STRING: ::DWORD = 9; +pub const CERT_RDN_ISO646_STRING: ::DWORD = 9; +pub const CERT_RDN_GENERAL_STRING: ::DWORD = 10; +pub const CERT_RDN_UNIVERSAL_STRING: ::DWORD = 11; +pub const CERT_RDN_INT4_STRING: ::DWORD = 11; +pub const CERT_RDN_BMP_STRING: ::DWORD = 12; +pub const CERT_RDN_UNICODE_STRING: ::DWORD = 12; +pub const CERT_RDN_UTF8_STRING: ::DWORD = 13; +pub const CERT_RDN_TYPE_MASK: ::DWORD = 0x000000FF; +pub const CERT_RDN_FLAGS_MASK: ::DWORD = 0xFF000000; +pub const CERT_RDN_ENABLE_T61_UNICODE_FLAG: ::DWORD = 0x80000000; +pub const CERT_RDN_ENABLE_UTF8_UNICODE_FLAG: ::DWORD = 0x20000000; +pub const CERT_RDN_FORCE_UTF8_UNICODE_FLAG: ::DWORD = 0x10000000; +pub const CERT_RDN_DISABLE_CHECK_TYPE_FLAG: ::DWORD = 0x40000000; +pub const CERT_RDN_DISABLE_IE4_UTF8_FLAG: ::DWORD = 0x01000000; +pub const CERT_RDN_ENABLE_PUNYCODE_FLAG: ::DWORD = 0x02000000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_RDN { + pub cRDNAttr: ::DWORD, + pub rgRDNAttr: PCERT_RDN_ATTR, +} +pub type PCERT_RDN = *mut CERT_RDN; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_NAME_INFO { + pub cRDN: ::DWORD, + pub rgRDN: PCERT_RDN, +} +pub type PCERT_NAME_INFO = *mut CERT_NAME_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_NAME_VALUE { + pub dwValueType: ::DWORD, + pub Value: CERT_RDN_VALUE_BLOB, +} +pub type PCERT_NAME_VALUE = *mut CERT_NAME_VALUE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_PUBLIC_KEY_INFO { + pub Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub PublicKey: CRYPT_BIT_BLOB, +} +pub type PCERT_PUBLIC_KEY_INFO = *mut CERT_PUBLIC_KEY_INFO; +pub const CERT_RSA_PUBLIC_KEY_OBJID: &'static str = szOID_RSA_RSA; +pub const CERT_DEFAULT_OID_PUBLIC_KEY_SIGN: &'static str = szOID_RSA_RSA; +pub const CERT_DEFAULT_OID_PUBLIC_KEY_XCHG: &'static str = szOID_RSA_RSA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ECC_PRIVATE_KEY_INFO { + pub dwVersion: ::DWORD, + pub PrivateKey: CRYPT_DER_BLOB, + pub szCurveOid: ::LPSTR, + pub PublicKey: CRYPT_BIT_BLOB, +} +pub type PCRYPT_ECC_PRIVATE_KEY_INFO = *mut CRYPT_ECC_PRIVATE_KEY_INFO; +pub const CRYPT_ECC_PRIVATE_KEY_INFO_v1: ::DWORD = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_PRIVATE_KEY_INFO { + pub Version: ::DWORD, + pub Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub PrivateKey: CRYPT_DER_BLOB, + pub pAttributes: PCRYPT_ATTRIBUTES, +} +pub type PCRYPT_PRIVATE_KEY_INFO = *mut CRYPT_PRIVATE_KEY_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ENCRYPTED_PRIVATE_KEY_INFO { + pub EncryptionAlgorithm: ::CRYPT_ALGORITHM_IDENTIFIER, + pub EncryptedPrivateKey: ::CRYPT_DATA_BLOB, +} +pub type PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO = *mut CRYPT_ENCRYPTED_PRIVATE_KEY_INFO; +pub type PCRYPT_DECRYPT_PRIVATE_KEY_FUNC = Option<unsafe extern "system" fn( + Algorithm: CRYPT_ALGORITHM_IDENTIFIER, EncryptedPrivateKey: CRYPT_DATA_BLOB, + pbClearTextKey: *mut ::BYTE, pcbClearTextKey: *mut ::DWORD, pVoidDecryptFunc: ::LPVOID, +) -> ::BOOL>; +pub type PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC = Option<unsafe extern "system" fn( + Algorithm: *mut CRYPT_ALGORITHM_IDENTIFIER, pClearTextPrivateKey: *mut CRYPT_DATA_BLOB, + pbEncryptedKey: *mut ::BYTE, pcbEncryptedKey: *mut ::DWORD, pVoidEncryptFunc: ::LPVOID, +) -> ::BOOL>; +pub type PCRYPT_RESOLVE_HCRYPTPROV_FUNC = Option<unsafe extern "system" fn( + pPrivateKeyInfo: *mut CRYPT_PRIVATE_KEY_INFO, phCryptProv: *mut HCRYPTPROV, + pVoidResolveFunc: ::LPVOID, +) -> ::BOOL>; +#[repr(C)] #[derive(Copy)] +pub struct CRYPT_PKCS8_IMPORT_PARAMS { + pub PrivateKey: CRYPT_DIGEST_BLOB, + pub pResolvehCryptProvFunc: PCRYPT_RESOLVE_HCRYPTPROV_FUNC, + pub pVoidResolveFunc: ::LPVOID, + pub pDecryptPrivateKeyFunc: PCRYPT_DECRYPT_PRIVATE_KEY_FUNC, + pub pVoidDecryptFunc: ::LPVOID, +} +impl Clone for CRYPT_PKCS8_IMPORT_PARAMS { fn clone(&self) -> CRYPT_PKCS8_IMPORT_PARAMS { *self } } +pub type PCRYPT_PKCS8_IMPORT_PARAMS = *mut CRYPT_PKCS8_IMPORT_PARAMS; +pub type CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = CRYPT_PKCS8_IMPORT_PARAMS; +pub type PPCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = *mut CRYPT_PKCS8_IMPORT_PARAMS; +#[repr(C)] #[derive(Copy)] +pub struct CRYPT_PKCS8_EXPORT_PARAMS { + pub hCryptProv: HCRYPTPROV, + pub dwKeySpec: ::DWORD, + pub pszPrivateKeyObjId: ::LPSTR, + pub pEncryptPrivateKeyFunc: PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC, + pub pVoidEncryptFunc: ::LPVOID, +} +impl Clone for CRYPT_PKCS8_EXPORT_PARAMS { fn clone(&self) -> CRYPT_PKCS8_EXPORT_PARAMS { *self } } +pub type PCRYPT_PKCS8_EXPORT_PARAMS = *mut CRYPT_PKCS8_EXPORT_PARAMS; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_INFO { + pub dwVersion: ::DWORD, + pub SerialNumber: CRYPT_INTEGER_BLOB, + pub SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub Issuer: CERT_NAME_BLOB, + pub NotBefore: ::FILETIME, + pub NotAfter: ::FILETIME, + pub Subject: CERT_NAME_BLOB, + pub SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, + pub IssuerUniqueId: CRYPT_BIT_BLOB, + pub SubjectUniqueId: CRYPT_BIT_BLOB, + pub cExtension: ::DWORD, + pub rgExtension: PCERT_EXTENSION, +} +pub type PCERT_INFO = *mut CERT_INFO; +pub const CERT_V1: ::DWORD = 0; +pub const CERT_V2: ::DWORD = 1; +pub const CERT_V3: ::DWORD = 2; +pub const CERT_INFO_VERSION_FLAG: ::DWORD = 1; +pub const CERT_INFO_SERIAL_NUMBER_FLAG: ::DWORD = 2; +pub const CERT_INFO_SIGNATURE_ALGORITHM_FLAG: ::DWORD = 3; +pub const CERT_INFO_ISSUER_FLAG: ::DWORD = 4; +pub const CERT_INFO_NOT_BEFORE_FLAG: ::DWORD = 5; +pub const CERT_INFO_NOT_AFTER_FLAG: ::DWORD = 6; +pub const CERT_INFO_SUBJECT_FLAG: ::DWORD = 7; +pub const CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG: ::DWORD = 8; +pub const CERT_INFO_ISSUER_UNIQUE_ID_FLAG: ::DWORD = 9; +pub const CERT_INFO_SUBJECT_UNIQUE_ID_FLAG: ::DWORD = 10; +pub const CERT_INFO_EXTENSION_FLAG: ::DWORD = 11; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRL_ENTRY { + pub SerialNumber: CRYPT_INTEGER_BLOB, + pub RevocationDate: ::FILETIME, + pub cExtension: ::DWORD, + pub rgExtension: PCERT_EXTENSION, +} +pub type PCRL_ENTRY = *mut CRL_ENTRY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRL_INFO { + pub dwVersion: ::DWORD, + pub SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub Issuer: CERT_NAME_BLOB, + pub ThisUpdate: ::FILETIME, + pub NextUpdate: ::FILETIME, + pub cCRLEntry: ::DWORD, + pub rgCRLEntry: PCRL_ENTRY, + pub cExtension: ::DWORD, + pub rgExtension: PCERT_EXTENSION, +} +pub type PCRL_INFO = *mut CRL_INFO; +pub const CRL_V1: ::DWORD = 0; +pub const CRL_V2: ::DWORD = 1; +pub const CERT_BUNDLE_CERTIFICATE: ::DWORD = 0; +pub const CERT_BUNDLE_CRL: ::DWORD = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_OR_CRL_BLOB { + pub dwChoice: ::DWORD, + pub cbEncoded: ::DWORD, + pub pbEncoded: *mut ::BYTE, +} +pub type PCERT_OR_CRL_BLOB = *mut CERT_OR_CRL_BLOB; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_OR_CRL_BUNDLE { + pub cItem: ::DWORD, + pub rgItem: PCERT_OR_CRL_BLOB, +} +pub type PCERT_OR_CRL_BUNDLE = *mut CERT_OR_CRL_BUNDLE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_REQUEST_INFO { + pub dwVersion: ::DWORD, + pub Subject: CERT_NAME_BLOB, + pub SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, + pub cAttribute: ::DWORD, + pub rgAttribute: PCRYPT_ATTRIBUTE, +} +pub type PCERT_REQUEST_INFO = *mut CERT_REQUEST_INFO; +pub const CERT_REQUEST_V1: ::DWORD = 0; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_KEYGEN_REQUEST_INFO { + pub dwVersion: ::DWORD, + pub SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, + pub pwszChallengeString: ::LPWSTR, +} +pub type PCERT_KEYGEN_REQUEST_INFO = *mut CERT_KEYGEN_REQUEST_INFO; +pub const CERT_KEYGEN_REQUEST_V1: ::DWORD = 0; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_SIGNED_CONTENT_INFO { + pub ToBeSigned: CRYPT_DER_BLOB, + pub SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub Signature: CRYPT_BIT_BLOB, +} +pub type PCERT_SIGNED_CONTENT_INFO = *mut CERT_SIGNED_CONTENT_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CTL_USAGE { + pub cUsageIdentifier: ::DWORD, + pub rgpszUsageIdentifier: *mut ::LPSTR, +} +pub type PCTL_USAGE = *mut CTL_USAGE; +pub type CERT_ENHKEY_USAGE = CTL_USAGE; +pub type PCERT_ENHKEY_USAGE = *mut CERT_ENHKEY_USAGE; +pub type PCCTL_USAGE = *const CTL_USAGE; +pub type PCCERT_ENHKEY_USAGE = *const CERT_ENHKEY_USAGE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CTL_ENTRY { + pub SubjectIdentifier: CRYPT_DATA_BLOB, + pub cAttribute: ::DWORD, + pub rgAttribute: PCRYPT_ATTRIBUTE, +} +pub type PCTL_ENTRY = *mut CTL_ENTRY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CTL_INFO { + pub dwVersion: ::DWORD, + pub SubjectUsage: CTL_USAGE, + pub ListIdentifier: CRYPT_DATA_BLOB, + pub SequenceNumber: CRYPT_INTEGER_BLOB, + pub ThisUpdate: ::FILETIME, + pub NextUpdate: ::FILETIME, + pub SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pub cCTLEntry: ::DWORD, + pub rgCTLEntry: PCTL_ENTRY, + pub cExtension: ::DWORD, + pub rgExtension: PCERT_EXTENSION, +} +pub type PCTL_INFO = *mut CTL_INFO; +pub const CTL_V1: ::DWORD = 0; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_TIME_STAMP_REQUEST_INFO { + pub pszTimeStampAlgorithm: ::LPSTR, + pub pszContentType: ::LPSTR, + pub Content: CRYPT_OBJID_BLOB, + pub cAttribute: ::DWORD, + pub rgAttribute: PCRYPT_ATTRIBUTE, +} +pub type PCRYPT_TIME_STAMP_REQUEST_INFO = *mut CRYPT_TIME_STAMP_REQUEST_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_ENROLLMENT_NAME_VALUE_PAIR { + pub pwszName: ::LPWSTR, + pub pwszValue: ::LPWSTR, +} +pub type PCRYPT_ENROLLMENT_NAME_VALUE_PAIR = *mut CRYPT_ENROLLMENT_NAME_VALUE_PAIR; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CRYPT_CSP_PROVIDER { + pub dwKeySpec: ::DWORD, + pub pwszProviderName: ::LPWSTR, + pub Signature: CRYPT_BIT_BLOB, +} +pub type PCRYPT_CSP_PROVIDER = *mut CRYPT_CSP_PROVIDER; +pub const CERT_ENCODING_TYPE_MASK: ::DWORD = 0x0000FFFF; +pub const CMSG_ENCODING_TYPE_MASK: ::DWORD = 0xFFFF0000; +pub const CRYPT_ASN_ENCODING: ::DWORD = 0x00000001; +pub const CRYPT_NDR_ENCODING: ::DWORD = 0x00000002; +pub const X509_ASN_ENCODING: ::DWORD = 0x00000001; +pub const X509_NDR_ENCODING: ::DWORD = 0x00000002; +pub const PKCS_7_ASN_ENCODING: ::DWORD = 0x00010000; +pub const PKCS_7_NDR_ENCODING: ::DWORD = 0x00020000; +pub const CRYPT_FORMAT_STR_MULTI_LINE: ::DWORD = 0x0001; +pub const CRYPT_FORMAT_STR_NO_HEX: ::DWORD = 0x0010; +pub const CRYPT_FORMAT_SIMPLE: ::DWORD = 0x0001; +pub const CRYPT_FORMAT_X509: ::DWORD = 0x0002; +pub const CRYPT_FORMAT_OID: ::DWORD = 0x0004; +pub const CRYPT_FORMAT_RDN_SEMICOLON: ::DWORD = 0x0100; +pub const CRYPT_FORMAT_RDN_CRLF: ::DWORD = 0x0200; +pub const CRYPT_FORMAT_RDN_UNQUOTE: ::DWORD = 0x0400; +pub const CRYPT_FORMAT_RDN_REVERSE: ::DWORD = 0x0800; +pub const CRYPT_FORMAT_COMMA: ::DWORD = 0x1000; +pub const CRYPT_FORMAT_SEMICOLON: ::DWORD = CRYPT_FORMAT_RDN_SEMICOLON; +pub const CRYPT_FORMAT_CRLF: ::DWORD = CRYPT_FORMAT_RDN_CRLF; +pub type PFN_CRYPT_ALLOC = Option<unsafe extern "system" fn(cbSize: ::size_t)>; +pub type PFN_CRYPT_FREE = Option<unsafe extern "system" fn(pv: ::LPVOID)>; +#[repr(C)] #[derive(Copy)] +pub struct CRYPT_ENCODE_PARA { + pub cbSize: ::DWORD, + pub pfnAlloc: PFN_CRYPT_ALLOC, + pub pfnFree: PFN_CRYPT_FREE, +} +impl Clone for CRYPT_ENCODE_PARA { fn clone(&self) -> CRYPT_ENCODE_PARA { *self } } +pub type PCRYPT_ENCODE_PARA = *mut CRYPT_ENCODE_PARA; +pub const CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG: ::DWORD = 0x8; +pub const CRYPT_ENCODE_ALLOC_FLAG: ::DWORD = 0x8000; +pub const CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG: ::DWORD = + CERT_RDN_ENABLE_T61_UNICODE_FLAG; +pub const CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG: ::DWORD = + CERT_RDN_ENABLE_UTF8_UNICODE_FLAG; +pub const CRYPT_UNICODE_NAME_ENCODE_FORCE_UTF8_UNICODE_FLAG: ::DWORD = + CERT_RDN_FORCE_UTF8_UNICODE_FLAG; +pub const CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG: ::DWORD = + CERT_RDN_DISABLE_CHECK_TYPE_FLAG; +pub const CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG: ::DWORD = 0x10000; +pub const CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG: ::DWORD = 0x20000; +pub const CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG: ::DWORD = 0x40000; +pub const CRYPT_ENCODE_ENABLE_IA5CONVERSION_FLAG: ::DWORD = CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG + | CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG; +#[repr(C)] #[derive(Copy)] +pub struct CRYPT_DECODE_PARA { + pub cbSize: ::DWORD, + pub pfnAlloc: PFN_CRYPT_ALLOC, + pub pfnFree: PFN_CRYPT_FREE, +} +impl Clone for CRYPT_DECODE_PARA { fn clone(&self) -> CRYPT_DECODE_PARA { *self } } +pub type PCRYPT_DECODE_PARA = *mut CRYPT_DECODE_PARA; +pub const CRYPT_DECODE_NOCOPY_FLAG: ::DWORD = 0x1; +pub const CRYPT_DECODE_TO_BE_SIGNED_FLAG: ::DWORD = 0x2; +pub const CRYPT_DECODE_SHARE_OID_STRING_FLAG: ::DWORD = 0x4; +pub const CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG: ::DWORD = 0x8; +pub const CRYPT_DECODE_ALLOC_FLAG: ::DWORD = 0x8000; +pub const CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG: ::DWORD = + CERT_RDN_DISABLE_IE4_UTF8_FLAG; +pub const CRYPT_DECODE_ENABLE_PUNYCODE_FLAG: ::DWORD = 0x02000000; +pub const CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG: ::DWORD = 0x04000000; +pub const CRYPT_DECODE_ENABLE_IA5CONVERSION_FLAG: ::DWORD = CRYPT_DECODE_ENABLE_PUNYCODE_FLAG + | CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG; +pub const CRYPT_ENCODE_DECODE_NONE: ::LPCSTR = 0 as ::LPCSTR; +pub const X509_CERT: ::LPCSTR = 1 as ::LPCSTR; +pub const X509_CERT_TO_BE_SIGNED: ::LPCSTR = 2 as ::LPCSTR; +pub const X509_CERT_CRL_TO_BE_SIGNED: ::LPCSTR = 3 as ::LPCSTR; +pub const X509_CERT_REQUEST_TO_BE_SIGNED: ::LPCSTR = 4 as ::LPCSTR; +pub const X509_EXTENSIONS: ::LPCSTR = 5 as ::LPCSTR; +pub const X509_NAME_VALUE: ::LPCSTR = 6 as ::LPCSTR; +pub const X509_NAME: ::LPCSTR = 7 as ::LPCSTR; +pub const X509_PUBLIC_KEY_INFO: ::LPCSTR = 8 as ::LPCSTR; +pub const X509_AUTHORITY_KEY_ID: ::LPCSTR = 9 as ::LPCSTR; +pub const X509_KEY_ATTRIBUTES: ::LPCSTR = 10 as ::LPCSTR; +pub const X509_KEY_USAGE_RESTRICTION: ::LPCSTR = 11 as ::LPCSTR; +pub const X509_ALTERNATE_NAME: ::LPCSTR = 12 as ::LPCSTR; +pub const X509_BASIC_CONSTRAINTS: ::LPCSTR = 13 as ::LPCSTR; +pub const X509_KEY_USAGE: ::LPCSTR = 14 as ::LPCSTR; +pub const X509_BASIC_CONSTRAINTS2: ::LPCSTR = 15 as ::LPCSTR; +pub const X509_CERT_POLICIES: ::LPCSTR = 16 as ::LPCSTR; +pub const PKCS_UTC_TIME: ::LPCSTR = 17 as ::LPCSTR; +pub const PKCS_TIME_REQUEST: ::LPCSTR = 18 as ::LPCSTR; +pub const RSA_CSP_PUBLICKEYBLOB: ::LPCSTR = 19 as ::LPCSTR; +pub const X509_UNICODE_NAME: ::LPCSTR = 20 as ::LPCSTR; +pub const X509_KEYGEN_REQUEST_TO_BE_SIGNED: ::LPCSTR = 21 as ::LPCSTR; +pub const PKCS_ATTRIBUTE: ::LPCSTR = 22 as ::LPCSTR; +pub const PKCS_CONTENT_INFO_SEQUENCE_OF_ANY: ::LPCSTR = 23 as ::LPCSTR; +pub const X509_UNICODE_NAME_VALUE: ::LPCSTR = 24 as ::LPCSTR; +pub const X509_ANY_STRING: ::LPCSTR = X509_NAME_VALUE; +pub const X509_UNICODE_ANY_STRING: ::LPCSTR = X509_UNICODE_NAME_VALUE; +pub const X509_OCTET_STRING: ::LPCSTR = 25 as ::LPCSTR; +pub const X509_BITS: ::LPCSTR = 26 as ::LPCSTR; +pub const X509_INTEGER: ::LPCSTR = 27 as ::LPCSTR; +pub const X509_MULTI_BYTE_INTEGER: ::LPCSTR = 28 as ::LPCSTR; +pub const X509_ENUMERATED: ::LPCSTR = 29 as ::LPCSTR; +pub const X509_CHOICE_OF_TIME: ::LPCSTR = 30 as ::LPCSTR; +pub const X509_AUTHORITY_KEY_ID2: ::LPCSTR = 31 as ::LPCSTR; +pub const X509_AUTHORITY_INFO_ACCESS: ::LPCSTR = 32 as ::LPCSTR; +pub const X509_SUBJECT_INFO_ACCESS: ::LPCSTR = X509_AUTHORITY_INFO_ACCESS; +pub const X509_CRL_REASON_CODE: ::LPCSTR = X509_ENUMERATED; +pub const PKCS_CONTENT_INFO: ::LPCSTR = 33 as ::LPCSTR; +pub const X509_SEQUENCE_OF_ANY: ::LPCSTR = 34 as ::LPCSTR; +pub const X509_CRL_DIST_POINTS: ::LPCSTR = 35 as ::LPCSTR; +pub const X509_ENHANCED_KEY_USAGE: ::LPCSTR = 36 as ::LPCSTR; +pub const PKCS_CTL: ::LPCSTR = 37 as ::LPCSTR; +pub const X509_MULTI_BYTE_UINT: ::LPCSTR = 38 as ::LPCSTR; +pub const X509_DSS_PUBLICKEY: ::LPCSTR = X509_MULTI_BYTE_UINT; +pub const X509_DSS_PARAMETERS: ::LPCSTR = 39 as ::LPCSTR; +pub const X509_DSS_SIGNATURE: ::LPCSTR = 40 as ::LPCSTR; +pub const PKCS_RC2_CBC_PARAMETERS: ::LPCSTR = 41 as ::LPCSTR; +pub const PKCS_SMIME_CAPABILITIES: ::LPCSTR = 42 as ::LPCSTR; +pub const X509_QC_STATEMENTS_EXT: ::LPCSTR = 42 as ::LPCSTR; +pub const PKCS_RSA_PRIVATE_KEY: ::LPCSTR = 43 as ::LPCSTR; +pub const PKCS_PRIVATE_KEY_INFO: ::LPCSTR = 44 as ::LPCSTR; +pub const PKCS_ENCRYPTED_PRIVATE_KEY_INFO: ::LPCSTR = 45 as ::LPCSTR; +pub const X509_PKIX_POLICY_QUALIFIER_USERNOTICE: ::LPCSTR = 46 as ::LPCSTR; +pub const X509_DH_PUBLICKEY: ::LPCSTR = X509_MULTI_BYTE_UINT; +pub const X509_DH_PARAMETERS: ::LPCSTR = 47 as ::LPCSTR; +pub const PKCS_ATTRIBUTES: ::LPCSTR = 48 as ::LPCSTR; +pub const PKCS_SORTED_CTL: ::LPCSTR = 49 as ::LPCSTR; +pub const X509_ECC_SIGNATURE: ::LPCSTR = 47 as ::LPCSTR; +pub const X942_DH_PARAMETERS: ::LPCSTR = 50 as ::LPCSTR; +pub const X509_BITS_WITHOUT_TRAILING_ZEROES: ::LPCSTR = 51 as ::LPCSTR; +pub const X942_OTHER_INFO: ::LPCSTR = 52 as ::LPCSTR; +pub const X509_CERT_PAIR: ::LPCSTR = 53 as ::LPCSTR; +pub const X509_ISSUING_DIST_POINT: ::LPCSTR = 54 as ::LPCSTR; +pub const X509_NAME_CONSTRAINTS: ::LPCSTR = 55 as ::LPCSTR; +pub const X509_POLICY_MAPPINGS: ::LPCSTR = 56 as ::LPCSTR; +pub const X509_POLICY_CONSTRAINTS: ::LPCSTR = 57 as ::LPCSTR; +pub const X509_CROSS_CERT_DIST_POINTS: ::LPCSTR = 58 as ::LPCSTR; +pub const CMC_DATA: ::LPCSTR = 59 as ::LPCSTR; +pub const CMC_RESPONSE: ::LPCSTR = 60 as ::LPCSTR; +pub const CMC_STATUS: ::LPCSTR = 61 as ::LPCSTR; +pub const CMC_ADD_EXTENSIONS: ::LPCSTR = 62 as ::LPCSTR; +pub const CMC_ADD_ATTRIBUTES: ::LPCSTR = 63 as ::LPCSTR; +pub const X509_CERTIFICATE_TEMPLATE: ::LPCSTR = 64 as ::LPCSTR; +pub const OCSP_SIGNED_REQUEST: ::LPCSTR = 65 as ::LPCSTR; +pub const OCSP_REQUEST: ::LPCSTR = 66 as ::LPCSTR; +pub const OCSP_RESPONSE: ::LPCSTR = 67 as ::LPCSTR; +pub const OCSP_BASIC_SIGNED_RESPONSE: ::LPCSTR = 68 as ::LPCSTR; +pub const OCSP_BASIC_RESPONSE: ::LPCSTR = 69 as ::LPCSTR; +pub const X509_LOGOTYPE_EXT: ::LPCSTR = 70 as ::LPCSTR; +pub const X509_BIOMETRIC_EXT: ::LPCSTR = 71 as ::LPCSTR; +pub const CNG_RSA_PUBLIC_KEY_BLOB: ::LPCSTR = 72 as ::LPCSTR; +pub const X509_OBJECT_IDENTIFIER: ::LPCSTR = 73 as ::LPCSTR; +pub const X509_ALGORITHM_IDENTIFIER: ::LPCSTR = 74 as ::LPCSTR; +pub const PKCS_RSA_SSA_PSS_PARAMETERS: ::LPCSTR = 75 as ::LPCSTR; +pub const PKCS_RSAES_OAEP_PARAMETERS: ::LPCSTR = 76 as ::LPCSTR; +pub const ECC_CMS_SHARED_INFO: ::LPCSTR = 77 as ::LPCSTR; +pub const TIMESTAMP_REQUEST: ::LPCSTR = 78 as ::LPCSTR; +pub const TIMESTAMP_RESPONSE: ::LPCSTR = 79 as ::LPCSTR; +pub const TIMESTAMP_INFO: ::LPCSTR = 80 as ::LPCSTR; +pub const X509_CERT_BUNDLE: ::LPCSTR = 81 as ::LPCSTR; +pub const X509_ECC_PRIVATE_KEY: ::LPCSTR = 82 as ::LPCSTR; +pub const CNG_RSA_PRIVATE_KEY_BLOB: ::LPCSTR = 83 as ::LPCSTR; +pub const X509_SUBJECT_DIR_ATTRS: ::LPCSTR = 84 as ::LPCSTR; +pub const PKCS7_SIGNER_INFO: ::LPCSTR = 500 as ::LPCSTR; +pub const CMS_SIGNER_INFO: ::LPCSTR = 501 as ::LPCSTR; +pub const szOID_AUTHORITY_KEY_IDENTIFIER: &'static str = "2.5.29.1"; +pub const szOID_KEY_ATTRIBUTES: &'static str = "2.5.29.2"; +pub const szOID_CERT_POLICIES_95: &'static str = "2.5.29.3"; +pub const szOID_KEY_USAGE_RESTRICTION: &'static str = "2.5.29.4"; +pub const szOID_SUBJECT_ALT_NAME: &'static str = "2.5.29.7"; +pub const szOID_ISSUER_ALT_NAME: &'static str = "2.5.29.8"; +pub const szOID_BASIC_CONSTRAINTS: &'static str = "2.5.29.10"; +pub const szOID_KEY_USAGE: &'static str = "2.5.29.15"; +pub const szOID_PRIVATEKEY_USAGE_PERIOD: &'static str = "2.5.29.16"; +pub const szOID_BASIC_CONSTRAINTS2: &'static str = "2.5.29.19"; +pub const szOID_CERT_POLICIES: &'static str = "2.5.29.32"; +pub const szOID_ANY_CERT_POLICY: &'static str = "2.5.29.32.0"; +pub const szOID_INHIBIT_ANY_POLICY: &'static str = "2.5.29.54"; +pub const szOID_AUTHORITY_KEY_IDENTIFIER2: &'static str = "2.5.29.35"; +pub const szOID_SUBJECT_KEY_IDENTIFIER: &'static str = "2.5.29.14"; +pub const szOID_SUBJECT_ALT_NAME2: &'static str = "2.5.29.17"; +pub const szOID_ISSUER_ALT_NAME2: &'static str = "2.5.29.18"; +pub const szOID_CRL_REASON_CODE: &'static str = "2.5.29.21"; +pub const szOID_REASON_CODE_HOLD: &'static str = "2.5.29.23"; +pub const szOID_CRL_DIST_POINTS: &'static str = "2.5.29.31"; +pub const szOID_ENHANCED_KEY_USAGE: &'static str = "2.5.29.37"; +pub const szOID_ANY_ENHANCED_KEY_USAGE: &'static str = "2.5.29.37.0"; +pub const szOID_CRL_NUMBER: &'static str = "2.5.29.20"; +pub const szOID_DELTA_CRL_INDICATOR: &'static str = "2.5.29.27"; +pub const szOID_ISSUING_DIST_POINT: &'static str = "2.5.29.28"; +pub const szOID_FRESHEST_CRL: &'static str = "2.5.29.46"; +pub const szOID_NAME_CONSTRAINTS: &'static str = "2.5.29.30"; +pub const szOID_POLICY_MAPPINGS: &'static str = "2.5.29.33"; +pub const szOID_LEGACY_POLICY_MAPPINGS: &'static str = "2.5.29.5"; +pub const szOID_POLICY_CONSTRAINTS: &'static str = "2.5.29.36"; +pub const szOID_RENEWAL_CERTIFICATE: &'static str = "1.3.6.1.4.1.311.13.1"; +pub const szOID_ENROLLMENT_NAME_VALUE_PAIR: &'static str = "1.3.6.1.4.1.311.13.2.1"; +pub const szOID_ENROLLMENT_CSP_PROVIDER: &'static str = "1.3.6.1.4.1.311.13.2.2"; +pub const szOID_OS_VERSION: &'static str = "1.3.6.1.4.1.311.13.2.3"; +pub const szOID_ENROLLMENT_AGENT: &'static str = "1.3.6.1.4.1.311.20.2.1"; +pub const szOID_PKIX: &'static str = "1.3.6.1.5.5.7"; +pub const szOID_PKIX_PE: &'static str = "1.3.6.1.5.5.7.1"; +pub const szOID_AUTHORITY_INFO_ACCESS: &'static str = "1.3.6.1.5.5.7.1.1"; +pub const szOID_SUBJECT_INFO_ACCESS: &'static str = "1.3.6.1.5.5.7.1.11"; +pub const szOID_BIOMETRIC_EXT: &'static str = "1.3.6.1.5.5.7.1.2"; +pub const szOID_QC_STATEMENTS_EXT: &'static str = "1.3.6.1.5.5.7.1.3"; +pub const szOID_LOGOTYPE_EXT: &'static str = "1.3.6.1.5.5.7.1.12"; +pub const szOID_CERT_EXTENSIONS: &'static str = "1.3.6.1.4.1.311.2.1.14"; +pub const szOID_NEXT_UPDATE_LOCATION: &'static str = "1.3.6.1.4.1.311.10.2"; +pub const szOID_REMOVE_CERTIFICATE: &'static str = "1.3.6.1.4.1.311.10.8.1"; +pub const szOID_CROSS_CERT_DIST_POINTS: &'static str = "1.3.6.1.4.1.311.10.9.1"; +pub const szOID_CTL: &'static str = "1.3.6.1.4.1.311.10.1"; +pub const szOID_SORTED_CTL: &'static str = "1.3.6.1.4.1.311.10.1.1"; +pub const szOID_SERIALIZED: &'static str = "1.3.6.1.4.1.311.10.3.3.1"; +pub const szOID_NT_PRINCIPAL_NAME: &'static str = "1.3.6.1.4.1.311.20.2.3"; +pub const szOID_INTERNATIONALIZED_EMAIL_ADDRESS: &'static str = "1.3.6.1.4.1.311.20.2.4"; +pub const szOID_PRODUCT_UPDATE: &'static str = "1.3.6.1.4.1.311.31.1"; +pub const szOID_ANY_APPLICATION_POLICY: &'static str = "1.3.6.1.4.1.311.10.12.1"; +pub const szOID_AUTO_ENROLL_CTL_USAGE: &'static str = "1.3.6.1.4.1.311.20.1"; +pub const szOID_ENROLL_CERTTYPE_EXTENSION: &'static str = "1.3.6.1.4.1.311.20.2"; +pub const szOID_CERT_MANIFOLD: &'static str = "1.3.6.1.4.1.311.20.3"; +pub const szOID_CERTSRV_CA_VERSION: &'static str = "1.3.6.1.4.1.311.21.1"; +pub const szOID_CERTSRV_PREVIOUS_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.2"; +pub const szOID_CRL_VIRTUAL_BASE: &'static str = "1.3.6.1.4.1.311.21.3"; +pub const szOID_CRL_NEXT_PUBLISH: &'static str = "1.3.6.1.4.1.311.21.4"; +pub const szOID_KP_CA_EXCHANGE: &'static str = "1.3.6.1.4.1.311.21.5"; +pub const szOID_KP_KEY_RECOVERY_AGENT: &'static str = "1.3.6.1.4.1.311.21.6"; +pub const szOID_CERTIFICATE_TEMPLATE: &'static str = "1.3.6.1.4.1.311.21.7"; +pub const szOID_ENTERPRISE_OID_ROOT: &'static str = "1.3.6.1.4.1.311.21.8"; +pub const szOID_RDN_DUMMY_SIGNER: &'static str = "1.3.6.1.4.1.311.21.9"; +pub const szOID_APPLICATION_CERT_POLICIES: &'static str = "1.3.6.1.4.1.311.21.10"; +pub const szOID_APPLICATION_POLICY_MAPPINGS: &'static str = "1.3.6.1.4.1.311.21.11"; +pub const szOID_APPLICATION_POLICY_CONSTRAINTS: &'static str = "1.3.6.1.4.1.311.21.12"; +pub const szOID_ARCHIVED_KEY_ATTR: &'static str = "1.3.6.1.4.1.311.21.13"; +pub const szOID_CRL_SELF_CDP: &'static str = "1.3.6.1.4.1.311.21.14"; +pub const szOID_REQUIRE_CERT_CHAIN_POLICY: &'static str = "1.3.6.1.4.1.311.21.15"; +pub const szOID_ARCHIVED_KEY_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.16"; +pub const szOID_ISSUED_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.17"; +pub const szOID_DS_EMAIL_REPLICATION: &'static str = "1.3.6.1.4.1.311.21.19"; +pub const szOID_REQUEST_CLIENT_INFO: &'static str = "1.3.6.1.4.1.311.21.20"; +pub const szOID_ENCRYPTED_KEY_HASH: &'static str = "1.3.6.1.4.1.311.21.21"; +pub const szOID_CERTSRV_CROSSCA_VERSION: &'static str = "1.3.6.1.4.1.311.21.22"; +pub const szOID_NTDS_REPLICATION: &'static str = "1.3.6.1.4.1.311.25.1"; +pub const szOID_SUBJECT_DIR_ATTRS: &'static str = "2.5.29.9"; +pub const szOID_PKIX_KP: &'static str = "1.3.6.1.5.5.7.3"; +pub const szOID_PKIX_KP_SERVER_AUTH: &'static str = "1.3.6.1.5.5.7.3.1"; +pub const szOID_PKIX_KP_CLIENT_AUTH: &'static str = "1.3.6.1.5.5.7.3.2"; +pub const szOID_PKIX_KP_CODE_SIGNING: &'static str = "1.3.6.1.5.5.7.3.3"; +pub const szOID_PKIX_KP_EMAIL_PROTECTION: &'static str = "1.3.6.1.5.5.7.3.4"; +pub const szOID_PKIX_KP_IPSEC_END_SYSTEM: &'static str = "1.3.6.1.5.5.7.3.5"; +pub const szOID_PKIX_KP_IPSEC_TUNNEL: &'static str = "1.3.6.1.5.5.7.3.6"; +pub const szOID_PKIX_KP_IPSEC_USER: &'static str = "1.3.6.1.5.5.7.3.7"; +pub const szOID_PKIX_KP_TIMESTAMP_SIGNING: &'static str = "1.3.6.1.5.5.7.3.8"; +pub const szOID_PKIX_KP_OCSP_SIGNING: &'static str = "1.3.6.1.5.5.7.3.9"; +pub const szOID_PKIX_OCSP_NOCHECK: &'static str = "1.3.6.1.5.5.7.48.1.5"; +pub const szOID_PKIX_OCSP_NONCE: &'static str = "1.3.6.1.5.5.7.48.1.2"; +pub const szOID_IPSEC_KP_IKE_INTERMEDIATE: &'static str = "1.3.6.1.5.5.8.2.2"; +pub const szOID_PKINIT_KP_KDC: &'static str = "1.3.6.1.5.2.3.5"; +pub const szOID_KP_CTL_USAGE_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.1"; +pub const szOID_KP_TIME_STAMP_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.2"; +pub const szOID_SERVER_GATED_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.3"; +pub const szOID_SGC_NETSCAPE: &'static str = "2.16.840.1.113730.4.1"; +pub const szOID_KP_EFS: &'static str = "1.3.6.1.4.1.311.10.3.4"; +pub const szOID_EFS_RECOVERY: &'static str = "1.3.6.1.4.1.311.10.3.4.1"; +pub const szOID_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.5"; +pub const szOID_NT5_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.6"; +pub const szOID_OEM_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.7"; +pub const szOID_EMBEDDED_NT_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.8"; +pub const szOID_ROOT_LIST_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.9"; +pub const szOID_KP_QUALIFIED_SUBORDINATION: &'static str = "1.3.6.1.4.1.311.10.3.10"; +pub const szOID_KP_KEY_RECOVERY: &'static str = "1.3.6.1.4.1.311.10.3.11"; +pub const szOID_KP_DOCUMENT_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.12"; +pub const szOID_KP_LIFETIME_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.13"; +pub const szOID_KP_MOBILE_DEVICE_SOFTWARE: &'static str = "1.3.6.1.4.1.311.10.3.14"; +pub const szOID_KP_SMART_DISPLAY: &'static str = "1.3.6.1.4.1.311.10.3.15"; +pub const szOID_KP_CSP_SIGNATURE: &'static str = "1.3.6.1.4.1.311.10.3.16"; +pub const szOID_DRM: &'static str = "1.3.6.1.4.1.311.10.5.1"; +pub const szOID_DRM_INDIVIDUALIZATION: &'static str = "1.3.6.1.4.1.311.10.5.2"; +pub const szOID_LICENSES: &'static str = "1.3.6.1.4.1.311.10.6.1"; +pub const szOID_LICENSE_SERVER: &'static str = "1.3.6.1.4.1.311.10.6.2"; +pub const szOID_KP_SMARTCARD_LOGON: &'static str = "1.3.6.1.4.1.311.20.2.2"; +pub const szOID_KP_KERNEL_MODE_CODE_SIGNING: &'static str = "1.3.6.1.4.1.311.61.1.1"; +pub const szOID_KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING: &'static str = "1.3.6.1.4.1.311.61.4.1"; +pub const szOID_REVOKED_LIST_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.19"; +pub const szOID_WINDOWS_KITS_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.20"; +pub const szOID_WINDOWS_RT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.21"; +pub const szOID_PROTECTED_PROCESS_LIGHT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.22"; +pub const szOID_WINDOWS_TCB_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.23"; +pub const szOID_PROTECTED_PROCESS_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.24"; +pub const szOID_WINDOWS_THIRD_PARTY_COMPONENT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.25"; +pub const szOID_WINDOWS_SOFTWARE_EXTENSION_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.26"; +pub const szOID_DISALLOWED_LIST: &'static str = "1.3.6.1.4.1.311.10.3.30"; +pub const szOID_SYNC_ROOT_CTL_EXT: &'static str = "1.3.6.1.4.1.311.10.3.50"; +pub const szOID_KP_KERNEL_MODE_HAL_EXTENSION_SIGNING: &'static str = "1.3.6.1.4.1.311.61.5.1"; +pub const szOID_WINDOWS_STORE_SIGNER: &'static str = "1.3.6.1.4.1.311.76.3.1"; +pub const szOID_DYNAMIC_CODE_GEN_SIGNER: &'static str = "1.3.6.1.4.1.311.76.5.1"; +pub const szOID_MICROSOFT_PUBLISHER_SIGNER: &'static str = "1.3.6.1.4.1.311.76.8.1"; +pub const szOID_YESNO_TRUST_ATTR: &'static str = "1.3.6.1.4.1.311.10.4.1"; +pub const szOID_PKIX_POLICY_QUALIFIER_CPS: &'static str = "1.3.6.1.5.5.7.2.1"; +pub const szOID_PKIX_POLICY_QUALIFIER_USERNOTICE: &'static str = "1.3.6.1.5.5.7.2.2"; +pub const szOID_ROOT_PROGRAM_FLAGS: &'static str = "1.3.6.1.4.1.311.60.1.1"; +//9221 +pub type HCERTSTORE = *mut ::c_void; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CERT_CONTEXT { + pub dwCertEncodingType: ::DWORD, + pub pbCertEncoded: *mut ::BYTE, + pub cbCertEncoded: ::DWORD, + pub pCertInfo: ::PCERT_INFO, + pub hCertStore: HCERTSTORE, +} +pub type PCERT_CONTEXT = *mut CERT_CONTEXT; +pub type PCCERT_CONTEXT = *const CERT_CONTEXT; diff --git a/deps/winapi-0.1.23/src/windef.rs b/deps/winapi-0.1.23/src/windef.rs new file mode 100644 index 000000000..19eb48d2d --- /dev/null +++ b/deps/winapi-0.1.23/src/windef.rs @@ -0,0 +1,9 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Basic Windows Type Definitions +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct POINTL { + pub x: ::LONG, + pub y: ::LONG, +} +pub type PPOINTL = *mut POINTL; diff --git a/deps/winapi-0.1.23/src/windowsx.rs b/deps/winapi-0.1.23/src/windowsx.rs new file mode 100644 index 000000000..b1b95ccba --- /dev/null +++ b/deps/winapi-0.1.23/src/windowsx.rs @@ -0,0 +1,22 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Macro APIs, window message crackers, and control APIs +//1233 +pub fn GET_X_LPARAM(lp: ::LPARAM) -> ::c_int { + ::LOWORD(lp as ::DWORD) as ::c_short as ::c_int +} +pub fn GET_Y_LPARAM(lp: ::LPARAM) -> ::c_int { + ::HIWORD(lp as ::DWORD) as ::c_short as ::c_int +} +#[test] +fn test_get_x_lparam() { + assert_eq!(GET_X_LPARAM(0xDEAD1234u32 as ::LPARAM), 0x1234); + assert_eq!(GET_X_LPARAM(0xBEEFffffu32 as ::LPARAM), -1); + assert_eq!(GET_X_LPARAM(0xCAFEFB2Eu32 as ::LPARAM), -1234); +} +#[test] +fn test_get_y_lparam() { + assert_eq!(GET_Y_LPARAM(0x1234DEADu32 as ::LPARAM), 0x1234); + assert_eq!(GET_Y_LPARAM(0xffffBEEFu32 as ::LPARAM), -1); + assert_eq!(GET_Y_LPARAM(0xFB2ECAFEu32 as ::LPARAM), -1234); +} diff --git a/deps/winapi-0.1.23/src/winerror.rs b/deps/winapi-0.1.23/src/winerror.rs new file mode 100644 index 000000000..ecff8f5b0 --- /dev/null +++ b/deps/winapi-0.1.23/src/winerror.rs @@ -0,0 +1,6057 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! error code definitions for the Win32 API functions +pub const FACILITY_XPS: HRESULT = 82; +pub const FACILITY_XAML: HRESULT = 43; +pub const FACILITY_USN: HRESULT = 129; +pub const FACILITY_BLBUI: HRESULT = 128; +pub const FACILITY_SPP: HRESULT = 256; +pub const FACILITY_WSB_ONLINE: HRESULT = 133; +pub const FACILITY_DLS: HRESULT = 153; +pub const FACILITY_BLB_CLI: HRESULT = 121; +pub const FACILITY_BLB: HRESULT = 120; +pub const FACILITY_WSBAPP: HRESULT = 122; +pub const FACILITY_WPN: HRESULT = 62; +pub const FACILITY_WMAAECMA: HRESULT = 1996; +pub const FACILITY_WINRM: HRESULT = 51; +pub const FACILITY_WINPE: HRESULT = 61; +pub const FACILITY_WINDOWSUPDATE: HRESULT = 36; +pub const FACILITY_WINDOWS_STORE: HRESULT = 63; +pub const FACILITY_WINDOWS_SETUP: HRESULT = 48; +pub const FACILITY_WINDOWS_DEFENDER: HRESULT = 80; +pub const FACILITY_WINDOWS_CE: HRESULT = 24; +pub const FACILITY_WINDOWS: HRESULT = 8; +pub const FACILITY_WINCODEC_DWRITE_DWM: HRESULT = 2200; +pub const FACILITY_WIA: HRESULT = 33; +pub const FACILITY_WER: HRESULT = 27; +pub const FACILITY_WEP: HRESULT = 2049; +pub const FACILITY_WEB_SOCKET: HRESULT = 886; +pub const FACILITY_WEB: HRESULT = 885; +pub const FACILITY_USERMODE_VOLSNAP: HRESULT = 130; +pub const FACILITY_USERMODE_VOLMGR: HRESULT = 56; +pub const FACILITY_VISUALCPP: HRESULT = 109; +pub const FACILITY_USERMODE_VIRTUALIZATION: HRESULT = 55; +pub const FACILITY_USERMODE_VHD: HRESULT = 58; +pub const FACILITY_URT: HRESULT = 19; +pub const FACILITY_UMI: HRESULT = 22; +pub const FACILITY_UI: HRESULT = 42; +pub const FACILITY_TPM_SOFTWARE: HRESULT = 41; +pub const FACILITY_TPM_SERVICES: HRESULT = 40; +pub const FACILITY_TIERING: HRESULT = 131; +pub const FACILITY_SYNCENGINE: HRESULT = 2050; +pub const FACILITY_SXS: HRESULT = 23; +pub const FACILITY_STORAGE: HRESULT = 3; +pub const FACILITY_STATE_MANAGEMENT: HRESULT = 34; +pub const FACILITY_SSPI: HRESULT = 9; +pub const FACILITY_USERMODE_SPACES: HRESULT = 231; +pub const FACILITY_SOS: HRESULT = 160; +pub const FACILITY_SCARD: HRESULT = 16; +pub const FACILITY_SHELL: HRESULT = 39; +pub const FACILITY_SETUPAPI: HRESULT = 15; +pub const FACILITY_SECURITY: HRESULT = 9; +pub const FACILITY_SDIAG: HRESULT = 60; +pub const FACILITY_USERMODE_SDBUS: HRESULT = 2305; +pub const FACILITY_RPC: HRESULT = 1; +pub const FACILITY_RESTORE: HRESULT = 256; +pub const FACILITY_SCRIPT: HRESULT = 112; +pub const FACILITY_PARSE: HRESULT = 113; +pub const FACILITY_RAS: HRESULT = 83; +pub const FACILITY_POWERSHELL: HRESULT = 84; +pub const FACILITY_PLA: HRESULT = 48; +pub const FACILITY_PIDGENX: HRESULT = 2561; +pub const FACILITY_P2P_INT: HRESULT = 98; +pub const FACILITY_P2P: HRESULT = 99; +pub const FACILITY_OPC: HRESULT = 81; +pub const FACILITY_ONLINE_ID: HRESULT = 134; +pub const FACILITY_WIN32: HRESULT = 7; +pub const FACILITY_CONTROL: HRESULT = 10; +pub const FACILITY_WEBSERVICES: HRESULT = 61; +pub const FACILITY_NULL: HRESULT = 0; +pub const FACILITY_NDIS: HRESULT = 52; +pub const FACILITY_NAP: HRESULT = 39; +pub const FACILITY_MOBILE: HRESULT = 1793; +pub const FACILITY_METADIRECTORY: HRESULT = 35; +pub const FACILITY_MSMQ: HRESULT = 14; +pub const FACILITY_MEDIASERVER: HRESULT = 13; +pub const FACILITY_MBN: HRESULT = 84; +pub const FACILITY_LINGUISTIC_SERVICES: HRESULT = 305; +pub const FACILITY_LEAP: HRESULT = 2184; +pub const FACILITY_JSCRIPT: HRESULT = 2306; +pub const FACILITY_INTERNET: HRESULT = 12; +pub const FACILITY_ITF: HRESULT = 4; +pub const FACILITY_INPUT: HRESULT = 64; +pub const FACILITY_USERMODE_HYPERVISOR: HRESULT = 53; +pub const FACILITY_ACCELERATOR: HRESULT = 1536; +pub const FACILITY_HTTP: HRESULT = 25; +pub const FACILITY_GRAPHICS: HRESULT = 38; +pub const FACILITY_FWP: HRESULT = 50; +pub const FACILITY_FVE: HRESULT = 49; +pub const FACILITY_USERMODE_FILTER_MANAGER: HRESULT = 31; +pub const FACILITY_EAS: HRESULT = 85; +pub const FACILITY_EAP: HRESULT = 66; +pub const FACILITY_DXGI_DDI: HRESULT = 2171; +pub const FACILITY_DXGI: HRESULT = 2170; +pub const FACILITY_DPLAY: HRESULT = 21; +pub const FACILITY_DMSERVER: HRESULT = 256; +pub const FACILITY_DISPATCH: HRESULT = 2; +pub const FACILITY_DIRECTORYSERVICE: HRESULT = 37; +pub const FACILITY_DIRECTMUSIC: HRESULT = 2168; +pub const FACILITY_DIRECT3D11: HRESULT = 2172; +pub const FACILITY_DIRECT3D10: HRESULT = 2169; +pub const FACILITY_DIRECT2D: HRESULT = 2201; +pub const FACILITY_DAF: HRESULT = 100; +pub const FACILITY_DEPLOYMENT_SERVICES_UTIL: HRESULT = 260; +pub const FACILITY_DEPLOYMENT_SERVICES_TRANSPORT_MANAGEMENT: HRESULT = 272; +pub const FACILITY_DEPLOYMENT_SERVICES_TFTP: HRESULT = 264; +pub const FACILITY_DEPLOYMENT_SERVICES_PXE: HRESULT = 263; +pub const FACILITY_DEPLOYMENT_SERVICES_MULTICAST_SERVER: HRESULT = 289; +pub const FACILITY_DEPLOYMENT_SERVICES_MULTICAST_CLIENT: HRESULT = 290; +pub const FACILITY_DEPLOYMENT_SERVICES_MANAGEMENT: HRESULT = 259; +pub const FACILITY_DEPLOYMENT_SERVICES_IMAGING: HRESULT = 258; +pub const FACILITY_DEPLOYMENT_SERVICES_DRIVER_PROVISIONING: HRESULT = 278; +pub const FACILITY_DEPLOYMENT_SERVICES_SERVER: HRESULT = 257; +pub const FACILITY_DEPLOYMENT_SERVICES_CONTENT_PROVIDER: HRESULT = 293; +pub const FACILITY_DEPLOYMENT_SERVICES_BINLSVC: HRESULT = 261; +pub const FACILITY_DEFRAG: HRESULT = 2304; +pub const FACILITY_DEBUGGERS: HRESULT = 176; +pub const FACILITY_CONFIGURATION: HRESULT = 33; +pub const FACILITY_COMPLUS: HRESULT = 17; +pub const FACILITY_USERMODE_COMMONLOG: HRESULT = 26; +pub const FACILITY_CMI: HRESULT = 54; +pub const FACILITY_CERT: HRESULT = 11; +pub const FACILITY_BLUETOOTH_ATT: HRESULT = 101; +pub const FACILITY_BCD: HRESULT = 57; +pub const FACILITY_BACKGROUNDCOPY: HRESULT = 32; +pub const FACILITY_AUDIOSTREAMING: HRESULT = 1094; +pub const FACILITY_AUDCLNT: HRESULT = 2185; +pub const FACILITY_AUDIO: HRESULT = 102; +pub const FACILITY_ACTION_QUEUE: HRESULT = 44; +pub const FACILITY_ACS: HRESULT = 20; +pub const FACILITY_AAF: HRESULT = 18; +pub const ERROR_SUCCESS: ::DWORD = 0; +pub const NO_ERROR: ::DWORD = 0; +pub const SEC_E_OK: HRESULT = 0; +pub const ERROR_INVALID_FUNCTION: ::DWORD = 1; +pub const ERROR_FILE_NOT_FOUND: ::DWORD = 2; +pub const ERROR_PATH_NOT_FOUND: ::DWORD = 3; +pub const ERROR_TOO_MANY_OPEN_FILES: ::DWORD = 4; +pub const ERROR_ACCESS_DENIED: ::DWORD = 5; +pub const ERROR_INVALID_HANDLE: ::DWORD = 6; +pub const ERROR_ARENA_TRASHED: ::DWORD = 7; +pub const ERROR_NOT_ENOUGH_MEMORY: ::DWORD = 8; +pub const ERROR_INVALID_BLOCK: ::DWORD = 9; +pub const ERROR_BAD_ENVIRONMENT: ::DWORD = 10; +pub const ERROR_BAD_FORMAT: ::DWORD = 11; +pub const ERROR_INVALID_ACCESS: ::DWORD = 12; +pub const ERROR_INVALID_DATA: ::DWORD = 13; +pub const ERROR_OUTOFMEMORY: ::DWORD = 14; +pub const ERROR_INVALID_DRIVE: ::DWORD = 15; +pub const ERROR_CURRENT_DIRECTORY: ::DWORD = 16; +pub const ERROR_NOT_SAME_DEVICE: ::DWORD = 17; +pub const ERROR_NO_MORE_FILES: ::DWORD = 18; +pub const ERROR_WRITE_PROTECT: ::DWORD = 19; +pub const ERROR_BAD_UNIT: ::DWORD = 20; +pub const ERROR_NOT_READY: ::DWORD = 21; +pub const ERROR_BAD_COMMAND: ::DWORD = 22; +pub const ERROR_CRC: ::DWORD = 23; +pub const ERROR_BAD_LENGTH: ::DWORD = 24; +pub const ERROR_SEEK: ::DWORD = 25; +pub const ERROR_NOT_DOS_DISK: ::DWORD = 26; +pub const ERROR_SECTOR_NOT_FOUND: ::DWORD = 27; +pub const ERROR_OUT_OF_PAPER: ::DWORD = 28; +pub const ERROR_WRITE_FAULT: ::DWORD = 29; +pub const ERROR_READ_FAULT: ::DWORD = 30; +pub const ERROR_GEN_FAILURE: ::DWORD = 31; +pub const ERROR_SHARING_VIOLATION: ::DWORD = 32; +pub const ERROR_LOCK_VIOLATION: ::DWORD = 33; +pub const ERROR_WRONG_DISK: ::DWORD = 34; +pub const ERROR_SHARING_BUFFER_EXCEEDED: ::DWORD = 36; +pub const ERROR_HANDLE_EOF: ::DWORD = 38; +pub const ERROR_HANDLE_DISK_FULL: ::DWORD = 39; +pub const ERROR_NOT_SUPPORTED: ::DWORD = 50; +pub const ERROR_REM_NOT_LIST: ::DWORD = 51; +pub const ERROR_DUP_NAME: ::DWORD = 52; +pub const ERROR_BAD_NETPATH: ::DWORD = 53; +pub const ERROR_NETWORK_BUSY: ::DWORD = 54; +pub const ERROR_DEV_NOT_EXIST: ::DWORD = 55; +pub const ERROR_TOO_MANY_CMDS: ::DWORD = 56; +pub const ERROR_ADAP_HDW_ERR: ::DWORD = 57; +pub const ERROR_BAD_NET_RESP: ::DWORD = 58; +pub const ERROR_UNEXP_NET_ERR: ::DWORD = 59; +pub const ERROR_BAD_REM_ADAP: ::DWORD = 60; +pub const ERROR_PRINTQ_FULL: ::DWORD = 61; +pub const ERROR_NO_SPOOL_SPACE: ::DWORD = 62; +pub const ERROR_PRINT_CANCELLED: ::DWORD = 63; +pub const ERROR_NETNAME_DELETED: ::DWORD = 64; +pub const ERROR_NETWORK_ACCESS_DENIED: ::DWORD = 65; +pub const ERROR_BAD_DEV_TYPE: ::DWORD = 66; +pub const ERROR_BAD_NET_NAME: ::DWORD = 67; +pub const ERROR_TOO_MANY_NAMES: ::DWORD = 68; +pub const ERROR_TOO_MANY_SESS: ::DWORD = 69; +pub const ERROR_SHARING_PAUSED: ::DWORD = 70; +pub const ERROR_REQ_NOT_ACCEP: ::DWORD = 71; +pub const ERROR_REDIR_PAUSED: ::DWORD = 72; +pub const ERROR_FILE_EXISTS: ::DWORD = 80; +pub const ERROR_CANNOT_MAKE: ::DWORD = 82; +pub const ERROR_FAIL_I24: ::DWORD = 83; +pub const ERROR_OUT_OF_STRUCTURES: ::DWORD = 84; +pub const ERROR_ALREADY_ASSIGNED: ::DWORD = 85; +pub const ERROR_INVALID_PASSWORD: ::DWORD = 86; +pub const ERROR_INVALID_PARAMETER: ::DWORD = 87; +pub const ERROR_NET_WRITE_FAULT: ::DWORD = 88; +pub const ERROR_NO_PROC_SLOTS: ::DWORD = 89; +pub const ERROR_TOO_MANY_SEMAPHORES: ::DWORD = 100; +pub const ERROR_EXCL_SEM_ALREADY_OWNED: ::DWORD = 101; +pub const ERROR_SEM_IS_SET: ::DWORD = 102; +pub const ERROR_TOO_MANY_SEM_REQUESTS: ::DWORD = 103; +pub const ERROR_INVALID_AT_INTERRUPT_TIME: ::DWORD = 104; +pub const ERROR_SEM_OWNER_DIED: ::DWORD = 105; +pub const ERROR_SEM_USER_LIMIT: ::DWORD = 106; +pub const ERROR_DISK_CHANGE: ::DWORD = 107; +pub const ERROR_DRIVE_LOCKED: ::DWORD = 108; +pub const ERROR_BROKEN_PIPE: ::DWORD = 109; +pub const ERROR_OPEN_FAILED: ::DWORD = 110; +pub const ERROR_BUFFER_OVERFLOW: ::DWORD = 111; +pub const ERROR_DISK_FULL: ::DWORD = 112; +pub const ERROR_NO_MORE_SEARCH_HANDLES: ::DWORD = 113; +pub const ERROR_INVALID_TARGET_HANDLE: ::DWORD = 114; +pub const ERROR_INVALID_CATEGORY: ::DWORD = 117; +pub const ERROR_INVALID_VERIFY_SWITCH: ::DWORD = 118; +pub const ERROR_BAD_DRIVER_LEVEL: ::DWORD = 119; +pub const ERROR_CALL_NOT_IMPLEMENTED: ::DWORD = 120; +pub const ERROR_SEM_TIMEOUT: ::DWORD = 121; +pub const ERROR_INSUFFICIENT_BUFFER: ::DWORD = 122; +pub const ERROR_INVALID_NAME: ::DWORD = 123; +pub const ERROR_INVALID_LEVEL: ::DWORD = 124; +pub const ERROR_NO_VOLUME_LABEL: ::DWORD = 125; +pub const ERROR_MOD_NOT_FOUND: ::DWORD = 126; +pub const ERROR_PROC_NOT_FOUND: ::DWORD = 127; +pub const ERROR_WAIT_NO_CHILDREN: ::DWORD = 128; +pub const ERROR_CHILD_NOT_COMPLETE: ::DWORD = 129; +pub const ERROR_DIRECT_ACCESS_HANDLE: ::DWORD = 130; +pub const ERROR_NEGATIVE_SEEK: ::DWORD = 131; +pub const ERROR_SEEK_ON_DEVICE: ::DWORD = 132; +pub const ERROR_IS_JOIN_TARGET: ::DWORD = 133; +pub const ERROR_IS_JOINED: ::DWORD = 134; +pub const ERROR_IS_SUBSTED: ::DWORD = 135; +pub const ERROR_NOT_JOINED: ::DWORD = 136; +pub const ERROR_NOT_SUBSTED: ::DWORD = 137; +pub const ERROR_JOIN_TO_JOIN: ::DWORD = 138; +pub const ERROR_SUBST_TO_SUBST: ::DWORD = 139; +pub const ERROR_JOIN_TO_SUBST: ::DWORD = 140; +pub const ERROR_SUBST_TO_JOIN: ::DWORD = 141; +pub const ERROR_BUSY_DRIVE: ::DWORD = 142; +pub const ERROR_SAME_DRIVE: ::DWORD = 143; +pub const ERROR_DIR_NOT_ROOT: ::DWORD = 144; +pub const ERROR_DIR_NOT_EMPTY: ::DWORD = 145; +pub const ERROR_IS_SUBST_PATH: ::DWORD = 146; +pub const ERROR_IS_JOIN_PATH: ::DWORD = 147; +pub const ERROR_PATH_BUSY: ::DWORD = 148; +pub const ERROR_IS_SUBST_TARGET: ::DWORD = 149; +pub const ERROR_SYSTEM_TRACE: ::DWORD = 150; +pub const ERROR_INVALID_EVENT_COUNT: ::DWORD = 151; +pub const ERROR_TOO_MANY_MUXWAITERS: ::DWORD = 152; +pub const ERROR_INVALID_LIST_FORMAT: ::DWORD = 153; +pub const ERROR_LABEL_TOO_LONG: ::DWORD = 154; +pub const ERROR_TOO_MANY_TCBS: ::DWORD = 155; +pub const ERROR_SIGNAL_REFUSED: ::DWORD = 156; +pub const ERROR_DISCARDED: ::DWORD = 157; +pub const ERROR_NOT_LOCKED: ::DWORD = 158; +pub const ERROR_BAD_THREADID_ADDR: ::DWORD = 159; +pub const ERROR_BAD_ARGUMENTS: ::DWORD = 160; +pub const ERROR_BAD_PATHNAME: ::DWORD = 161; +pub const ERROR_SIGNAL_PENDING: ::DWORD = 162; +pub const ERROR_MAX_THRDS_REACHED: ::DWORD = 164; +pub const ERROR_LOCK_FAILED: ::DWORD = 167; +pub const ERROR_BUSY: ::DWORD = 170; +pub const ERROR_DEVICE_SUPPORT_IN_PROGRESS: ::DWORD = 171; +pub const ERROR_CANCEL_VIOLATION: ::DWORD = 173; +pub const ERROR_ATOMIC_LOCKS_NOT_SUPPORTED: ::DWORD = 174; +pub const ERROR_INVALID_SEGMENT_NUMBER: ::DWORD = 180; +pub const ERROR_INVALID_ORDINAL: ::DWORD = 182; +pub const ERROR_ALREADY_EXISTS: ::DWORD = 183; +pub const ERROR_INVALID_FLAG_NUMBER: ::DWORD = 186; +pub const ERROR_SEM_NOT_FOUND: ::DWORD = 187; +pub const ERROR_INVALID_STARTING_CODESEG: ::DWORD = 188; +pub const ERROR_INVALID_STACKSEG: ::DWORD = 189; +pub const ERROR_INVALID_MODULETYPE: ::DWORD = 190; +pub const ERROR_INVALID_EXE_SIGNATURE: ::DWORD = 191; +pub const ERROR_EXE_MARKED_INVALID: ::DWORD = 192; +pub const ERROR_BAD_EXE_FORMAT: ::DWORD = 193; +pub const ERROR_ITERATED_DATA_EXCEEDS_64k: ::DWORD = 194; +pub const ERROR_INVALID_MINALLOCSIZE: ::DWORD = 195; +pub const ERROR_DYNLINK_FROM_INVALID_RING: ::DWORD = 196; +pub const ERROR_IOPL_NOT_ENABLED: ::DWORD = 197; +pub const ERROR_INVALID_SEGDPL: ::DWORD = 198; +pub const ERROR_AUTODATASEG_EXCEEDS_64k: ::DWORD = 199; +pub const ERROR_RING2SEG_MUST_BE_MOVABLE: ::DWORD = 200; +pub const ERROR_RELOC_CHAIN_XEEDS_SEGLIM: ::DWORD = 201; +pub const ERROR_INFLOOP_IN_RELOC_CHAIN: ::DWORD = 202; +pub const ERROR_ENVVAR_NOT_FOUND: ::DWORD = 203; +pub const ERROR_NO_SIGNAL_SENT: ::DWORD = 205; +pub const ERROR_FILENAME_EXCED_RANGE: ::DWORD = 206; +pub const ERROR_RING2_STACK_IN_USE: ::DWORD = 207; +pub const ERROR_META_EXPANSION_TOO_LONG: ::DWORD = 208; +pub const ERROR_INVALID_SIGNAL_NUMBER: ::DWORD = 209; +pub const ERROR_THREAD_1_INACTIVE: ::DWORD = 210; +pub const ERROR_LOCKED: ::DWORD = 212; +pub const ERROR_TOO_MANY_MODULES: ::DWORD = 214; +pub const ERROR_NESTING_NOT_ALLOWED: ::DWORD = 215; +pub const ERROR_EXE_MACHINE_TYPE_MISMATCH: ::DWORD = 216; +pub const ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY: ::DWORD = 217; +pub const ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY: ::DWORD = 218; +pub const ERROR_FILE_CHECKED_OUT: ::DWORD = 220; +pub const ERROR_CHECKOUT_REQUIRED: ::DWORD = 221; +pub const ERROR_BAD_FILE_TYPE: ::DWORD = 222; +pub const ERROR_FILE_TOO_LARGE: ::DWORD = 223; +pub const ERROR_FORMS_AUTH_REQUIRED: ::DWORD = 224; +pub const ERROR_VIRUS_INFECTED: ::DWORD = 225; +pub const ERROR_VIRUS_DELETED: ::DWORD = 226; +pub const ERROR_PIPE_LOCAL: ::DWORD = 229; +pub const ERROR_BAD_PIPE: ::DWORD = 230; +pub const ERROR_PIPE_BUSY: ::DWORD = 231; +pub const ERROR_NO_DATA: ::DWORD = 232; +pub const ERROR_PIPE_NOT_CONNECTED: ::DWORD = 233; +pub const ERROR_MORE_DATA: ::DWORD = 234; +pub const ERROR_VC_DISCONNECTED: ::DWORD = 240; +pub const ERROR_INVALID_EA_NAME: ::DWORD = 254; +pub const ERROR_EA_LIST_INCONSISTENT: ::DWORD = 255; +pub const WAIT_TIMEOUT: ::DWORD = 258; +pub const ERROR_NO_MORE_ITEMS: ::DWORD = 259; +pub const ERROR_CANNOT_COPY: ::DWORD = 266; +pub const ERROR_DIRECTORY: ::DWORD = 267; +pub const ERROR_EAS_DIDNT_FIT: ::DWORD = 275; +pub const ERROR_EA_FILE_CORRUPT: ::DWORD = 276; +pub const ERROR_EA_TABLE_FULL: ::DWORD = 277; +pub const ERROR_INVALID_EA_HANDLE: ::DWORD = 278; +pub const ERROR_EAS_NOT_SUPPORTED: ::DWORD = 282; +pub const ERROR_NOT_OWNER: ::DWORD = 288; +pub const ERROR_TOO_MANY_POSTS: ::DWORD = 298; +pub const ERROR_PARTIAL_COPY: ::DWORD = 299; +pub const ERROR_OPLOCK_NOT_GRANTED: ::DWORD = 300; +pub const ERROR_INVALID_OPLOCK_PROTOCOL: ::DWORD = 301; +pub const ERROR_DISK_TOO_FRAGMENTED: ::DWORD = 302; +pub const ERROR_DELETE_PENDING: ::DWORD = 303; +pub const ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: ::DWORD = 304; +pub const ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: ::DWORD = 305; +pub const ERROR_SECURITY_STREAM_IS_INCONSISTENT: ::DWORD = 306; +pub const ERROR_INVALID_LOCK_RANGE: ::DWORD = 307; +pub const ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT: ::DWORD = 308; +pub const ERROR_NOTIFICATION_GUID_ALREADY_DEFINED: ::DWORD = 309; +pub const ERROR_INVALID_EXCEPTION_HANDLER: ::DWORD = 310; +pub const ERROR_DUPLICATE_PRIVILEGES: ::DWORD = 311; +pub const ERROR_NO_RANGES_PROCESSED: ::DWORD = 312; +pub const ERROR_NOT_ALLOWED_ON_SYSTEM_FILE: ::DWORD = 313; +pub const ERROR_DISK_RESOURCES_EXHAUSTED: ::DWORD = 314; +pub const ERROR_INVALID_TOKEN: ::DWORD = 315; +pub const ERROR_DEVICE_FEATURE_NOT_SUPPORTED: ::DWORD = 316; +pub const ERROR_MR_MID_NOT_FOUND: ::DWORD = 317; +pub const ERROR_SCOPE_NOT_FOUND: ::DWORD = 318; +pub const ERROR_UNDEFINED_SCOPE: ::DWORD = 319; +pub const ERROR_INVALID_CAP: ::DWORD = 320; +pub const ERROR_DEVICE_UNREACHABLE: ::DWORD = 321; +pub const ERROR_DEVICE_NO_RESOURCES: ::DWORD = 322; +pub const ERROR_DATA_CHECKSUM_ERROR: ::DWORD = 323; +pub const ERROR_INTERMIXED_KERNEL_EA_OPERATION: ::DWORD = 324; +pub const ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED: ::DWORD = 326; +pub const ERROR_OFFSET_ALIGNMENT_VIOLATION: ::DWORD = 327; +pub const ERROR_INVALID_FIELD_IN_PARAMETER_LIST: ::DWORD = 328; +pub const ERROR_OPERATION_IN_PROGRESS: ::DWORD = 329; +pub const ERROR_BAD_DEVICE_PATH: ::DWORD = 330; +pub const ERROR_TOO_MANY_DESCRIPTORS: ::DWORD = 331; +pub const ERROR_SCRUB_DATA_DISABLED: ::DWORD = 332; +pub const ERROR_NOT_REDUNDANT_STORAGE: ::DWORD = 333; +pub const ERROR_RESIDENT_FILE_NOT_SUPPORTED: ::DWORD = 334; +pub const ERROR_COMPRESSED_FILE_NOT_SUPPORTED: ::DWORD = 335; +pub const ERROR_DIRECTORY_NOT_SUPPORTED: ::DWORD = 336; +pub const ERROR_NOT_READ_FROM_COPY: ::DWORD = 337; +pub const ERROR_FT_WRITE_FAILURE: ::DWORD = 338; +pub const ERROR_FT_DI_SCAN_REQUIRED: ::DWORD = 339; +pub const ERROR_INVALID_KERNEL_INFO_VERSION: ::DWORD = 340; +pub const ERROR_INVALID_PEP_INFO_VERSION: ::DWORD = 341; +pub const ERROR_OBJECT_NOT_EXTERNALLY_BACKED: ::DWORD = 342; +pub const ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN: ::DWORD = 343; +pub const ERROR_FAIL_NOACTION_REBOOT: ::DWORD = 350; +pub const ERROR_FAIL_SHUTDOWN: ::DWORD = 351; +pub const ERROR_FAIL_RESTART: ::DWORD = 352; +pub const ERROR_MAX_SESSIONS_REACHED: ::DWORD = 353; +pub const ERROR_THREAD_MODE_ALREADY_BACKGROUND: ::DWORD = 400; +pub const ERROR_THREAD_MODE_NOT_BACKGROUND: ::DWORD = 401; +pub const ERROR_PROCESS_MODE_ALREADY_BACKGROUND: ::DWORD = 402; +pub const ERROR_PROCESS_MODE_NOT_BACKGROUND: ::DWORD = 403; +pub const ERROR_DEVICE_HARDWARE_ERROR: ::DWORD = 483; +pub const ERROR_INVALID_ADDRESS: ::DWORD = 487; +pub const ERROR_USER_PROFILE_LOAD: ::DWORD = 500; +pub const ERROR_ARITHMETIC_OVERFLOW: ::DWORD = 534; +pub const ERROR_PIPE_CONNECTED: ::DWORD = 535; +pub const ERROR_PIPE_LISTENING: ::DWORD = 536; +pub const ERROR_VERIFIER_STOP: ::DWORD = 537; +pub const ERROR_ABIOS_ERROR: ::DWORD = 538; +pub const ERROR_WX86_WARNING: ::DWORD = 539; +pub const ERROR_WX86_ERROR: ::DWORD = 540; +pub const ERROR_TIMER_NOT_CANCELED: ::DWORD = 541; +pub const ERROR_UNWIND: ::DWORD = 542; +pub const ERROR_BAD_STACK: ::DWORD = 543; +pub const ERROR_INVALID_UNWIND_TARGET: ::DWORD = 544; +pub const ERROR_INVALID_PORT_ATTRIBUTES: ::DWORD = 545; +pub const ERROR_PORT_MESSAGE_TOO_LONG: ::DWORD = 546; +pub const ERROR_INVALID_QUOTA_LOWER: ::DWORD = 547; +pub const ERROR_DEVICE_ALREADY_ATTACHED: ::DWORD = 548; +pub const ERROR_INSTRUCTION_MISALIGNMENT: ::DWORD = 549; +pub const ERROR_PROFILING_NOT_STARTED: ::DWORD = 550; +pub const ERROR_PROFILING_NOT_STOPPED: ::DWORD = 551; +pub const ERROR_COULD_NOT_INTERPRET: ::DWORD = 552; +pub const ERROR_PROFILING_AT_LIMIT: ::DWORD = 553; +pub const ERROR_CANT_WAIT: ::DWORD = 554; +pub const ERROR_CANT_TERMINATE_SELF: ::DWORD = 555; +pub const ERROR_UNEXPECTED_MM_CREATE_ERR: ::DWORD = 556; +pub const ERROR_UNEXPECTED_MM_MAP_ERROR: ::DWORD = 557; +pub const ERROR_UNEXPECTED_MM_EXTEND_ERR: ::DWORD = 558; +pub const ERROR_BAD_FUNCTION_TABLE: ::DWORD = 559; +pub const ERROR_NO_GUID_TRANSLATION: ::DWORD = 560; +pub const ERROR_INVALID_LDT_SIZE: ::DWORD = 561; +pub const ERROR_INVALID_LDT_OFFSET: ::DWORD = 563; +pub const ERROR_INVALID_LDT_DESCRIPTOR: ::DWORD = 564; +pub const ERROR_TOO_MANY_THREADS: ::DWORD = 565; +pub const ERROR_THREAD_NOT_IN_PROCESS: ::DWORD = 566; +pub const ERROR_PAGEFILE_QUOTA_EXCEEDED: ::DWORD = 567; +pub const ERROR_LOGON_SERVER_CONFLICT: ::DWORD = 568; +pub const ERROR_SYNCHRONIZATION_REQUIRED: ::DWORD = 569; +pub const ERROR_NET_OPEN_FAILED: ::DWORD = 570; +pub const ERROR_IO_PRIVILEGE_FAILED: ::DWORD = 571; +pub const ERROR_CONTROL_C_EXIT: ::DWORD = 572; +pub const ERROR_MISSING_SYSTEMFILE: ::DWORD = 573; +pub const ERROR_UNHANDLED_EXCEPTION: ::DWORD = 574; +pub const ERROR_APP_INIT_FAILURE: ::DWORD = 575; +pub const ERROR_PAGEFILE_CREATE_FAILED: ::DWORD = 576; +pub const ERROR_INVALID_IMAGE_HASH: ::DWORD = 577; +pub const ERROR_NO_PAGEFILE: ::DWORD = 578; +pub const ERROR_ILLEGAL_FLOAT_CONTEXT: ::DWORD = 579; +pub const ERROR_NO_EVENT_PAIR: ::DWORD = 580; +pub const ERROR_DOMAIN_CTRLR_CONFIG_ERROR: ::DWORD = 581; +pub const ERROR_ILLEGAL_CHARACTER: ::DWORD = 582; +pub const ERROR_UNDEFINED_CHARACTER: ::DWORD = 583; +pub const ERROR_FLOPPY_VOLUME: ::DWORD = 584; +pub const ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT: ::DWORD = 585; +pub const ERROR_BACKUP_CONTROLLER: ::DWORD = 586; +pub const ERROR_MUTANT_LIMIT_EXCEEDED: ::DWORD = 587; +pub const ERROR_FS_DRIVER_REQUIRED: ::DWORD = 588; +pub const ERROR_CANNOT_LOAD_REGISTRY_FILE: ::DWORD = 589; +pub const ERROR_DEBUG_ATTACH_FAILED: ::DWORD = 590; +pub const ERROR_SYSTEM_PROCESS_TERMINATED: ::DWORD = 591; +pub const ERROR_DATA_NOT_ACCEPTED: ::DWORD = 592; +pub const ERROR_VDM_HARD_ERROR: ::DWORD = 593; +pub const ERROR_DRIVER_CANCEL_TIMEOUT: ::DWORD = 594; +pub const ERROR_REPLY_MESSAGE_MISMATCH: ::DWORD = 595; +pub const ERROR_LOST_WRITEBEHIND_DATA: ::DWORD = 596; +pub const ERROR_CLIENT_SERVER_PARAMETERS_INVALID: ::DWORD = 597; +pub const ERROR_NOT_TINY_STREAM: ::DWORD = 598; +pub const ERROR_STACK_OVERFLOW_READ: ::DWORD = 599; +pub const ERROR_CONVERT_TO_LARGE: ::DWORD = 600; +pub const ERROR_FOUND_OUT_OF_SCOPE: ::DWORD = 601; +pub const ERROR_ALLOCATE_BUCKET: ::DWORD = 602; +pub const ERROR_MARSHALL_OVERFLOW: ::DWORD = 603; +pub const ERROR_INVALID_VARIANT: ::DWORD = 604; +pub const ERROR_BAD_COMPRESSION_BUFFER: ::DWORD = 605; +pub const ERROR_AUDIT_FAILED: ::DWORD = 606; +pub const ERROR_TIMER_RESOLUTION_NOT_SET: ::DWORD = 607; +pub const ERROR_INSUFFICIENT_LOGON_INFO: ::DWORD = 608; +pub const ERROR_BAD_DLL_ENTRYPOINT: ::DWORD = 609; +pub const ERROR_BAD_SERVICE_ENTRYPOINT: ::DWORD = 610; +pub const ERROR_IP_ADDRESS_CONFLICT1: ::DWORD = 611; +pub const ERROR_IP_ADDRESS_CONFLICT2: ::DWORD = 612; +pub const ERROR_REGISTRY_QUOTA_LIMIT: ::DWORD = 613; +pub const ERROR_NO_CALLBACK_ACTIVE: ::DWORD = 614; +pub const ERROR_PWD_TOO_SHORT: ::DWORD = 615; +pub const ERROR_PWD_TOO_RECENT: ::DWORD = 616; +pub const ERROR_PWD_HISTORY_CONFLICT: ::DWORD = 617; +pub const ERROR_UNSUPPORTED_COMPRESSION: ::DWORD = 618; +pub const ERROR_INVALID_HW_PROFILE: ::DWORD = 619; +pub const ERROR_INVALID_PLUGPLAY_DEVICE_PATH: ::DWORD = 620; +pub const ERROR_QUOTA_LIST_INCONSISTENT: ::DWORD = 621; +pub const ERROR_EVALUATION_EXPIRATION: ::DWORD = 622; +pub const ERROR_ILLEGAL_DLL_RELOCATION: ::DWORD = 623; +pub const ERROR_DLL_INIT_FAILED_LOGOFF: ::DWORD = 624; +pub const ERROR_VALIDATE_CONTINUE: ::DWORD = 625; +pub const ERROR_NO_MORE_MATCHES: ::DWORD = 626; +pub const ERROR_RANGE_LIST_CONFLICT: ::DWORD = 627; +pub const ERROR_SERVER_SID_MISMATCH: ::DWORD = 628; +pub const ERROR_CANT_ENABLE_DENY_ONLY: ::DWORD = 629; +pub const ERROR_FLOAT_MULTIPLE_FAULTS: ::DWORD = 630; +pub const ERROR_FLOAT_MULTIPLE_TRAPS: ::DWORD = 631; +pub const ERROR_NOINTERFACE: ::DWORD = 632; +pub const ERROR_DRIVER_FAILED_SLEEP: ::DWORD = 633; +pub const ERROR_CORRUPT_SYSTEM_FILE: ::DWORD = 634; +pub const ERROR_COMMITMENT_MINIMUM: ::DWORD = 635; +pub const ERROR_PNP_RESTART_ENUMERATION: ::DWORD = 636; +pub const ERROR_SYSTEM_IMAGE_BAD_SIGNATURE: ::DWORD = 637; +pub const ERROR_PNP_REBOOT_REQUIRED: ::DWORD = 638; +pub const ERROR_INSUFFICIENT_POWER: ::DWORD = 639; +pub const ERROR_MULTIPLE_FAULT_VIOLATION: ::DWORD = 640; +pub const ERROR_SYSTEM_SHUTDOWN: ::DWORD = 641; +pub const ERROR_PORT_NOT_SET: ::DWORD = 642; +pub const ERROR_DS_VERSION_CHECK_FAILURE: ::DWORD = 643; +pub const ERROR_RANGE_NOT_FOUND: ::DWORD = 644; +pub const ERROR_NOT_SAFE_MODE_DRIVER: ::DWORD = 646; +pub const ERROR_FAILED_DRIVER_ENTRY: ::DWORD = 647; +pub const ERROR_DEVICE_ENUMERATION_ERROR: ::DWORD = 648; +pub const ERROR_MOUNT_POINT_NOT_RESOLVED: ::DWORD = 649; +pub const ERROR_INVALID_DEVICE_OBJECT_PARAMETER: ::DWORD = 650; +pub const ERROR_MCA_OCCURED: ::DWORD = 651; +pub const ERROR_DRIVER_DATABASE_ERROR: ::DWORD = 652; +pub const ERROR_SYSTEM_HIVE_TOO_LARGE: ::DWORD = 653; +pub const ERROR_DRIVER_FAILED_PRIOR_UNLOAD: ::DWORD = 654; +pub const ERROR_VOLSNAP_PREPARE_HIBERNATE: ::DWORD = 655; +pub const ERROR_HIBERNATION_FAILURE: ::DWORD = 656; +pub const ERROR_PWD_TOO_LONG: ::DWORD = 657; +pub const ERROR_FILE_SYSTEM_LIMITATION: ::DWORD = 665; +pub const ERROR_ASSERTION_FAILURE: ::DWORD = 668; +pub const ERROR_ACPI_ERROR: ::DWORD = 669; +pub const ERROR_WOW_ASSERTION: ::DWORD = 670; +pub const ERROR_PNP_BAD_MPS_TABLE: ::DWORD = 671; +pub const ERROR_PNP_TRANSLATION_FAILED: ::DWORD = 672; +pub const ERROR_PNP_IRQ_TRANSLATION_FAILED: ::DWORD = 673; +pub const ERROR_PNP_INVALID_ID: ::DWORD = 674; +pub const ERROR_WAKE_SYSTEM_DEBUGGER: ::DWORD = 675; +pub const ERROR_HANDLES_CLOSED: ::DWORD = 676; +pub const ERROR_EXTRANEOUS_INFORMATION: ::DWORD = 677; +pub const ERROR_RXACT_COMMIT_NECESSARY: ::DWORD = 678; +pub const ERROR_MEDIA_CHECK: ::DWORD = 679; +pub const ERROR_GUID_SUBSTITUTION_MADE: ::DWORD = 680; +pub const ERROR_STOPPED_ON_SYMLINK: ::DWORD = 681; +pub const ERROR_LONGJUMP: ::DWORD = 682; +pub const ERROR_PLUGPLAY_QUERY_VETOED: ::DWORD = 683; +pub const ERROR_UNWIND_CONSOLIDATE: ::DWORD = 684; +pub const ERROR_REGISTRY_HIVE_RECOVERED: ::DWORD = 685; +pub const ERROR_DLL_MIGHT_BE_INSECURE: ::DWORD = 686; +pub const ERROR_DLL_MIGHT_BE_INCOMPATIBLE: ::DWORD = 687; +pub const ERROR_DBG_EXCEPTION_NOT_HANDLED: ::DWORD = 688; +pub const ERROR_DBG_REPLY_LATER: ::DWORD = 689; +pub const ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE: ::DWORD = 690; +pub const ERROR_DBG_TERMINATE_THREAD: ::DWORD = 691; +pub const ERROR_DBG_TERMINATE_PROCESS: ::DWORD = 692; +pub const ERROR_DBG_CONTROL_C: ::DWORD = 693; +pub const ERROR_DBG_PRINTEXCEPTION_C: ::DWORD = 694; +pub const ERROR_DBG_RIPEXCEPTION: ::DWORD = 695; +pub const ERROR_DBG_CONTROL_BREAK: ::DWORD = 696; +pub const ERROR_DBG_COMMAND_EXCEPTION: ::DWORD = 697; +pub const ERROR_OBJECT_NAME_EXISTS: ::DWORD = 698; +pub const ERROR_THREAD_WAS_SUSPENDED: ::DWORD = 699; +pub const ERROR_IMAGE_NOT_AT_BASE: ::DWORD = 700; +pub const ERROR_RXACT_STATE_CREATED: ::DWORD = 701; +pub const ERROR_SEGMENT_NOTIFICATION: ::DWORD = 702; +pub const ERROR_BAD_CURRENT_DIRECTORY: ::DWORD = 703; +pub const ERROR_FT_READ_RECOVERY_FROM_BACKUP: ::DWORD = 704; +pub const ERROR_FT_WRITE_RECOVERY: ::DWORD = 705; +pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH: ::DWORD = 706; +pub const ERROR_RECEIVE_PARTIAL: ::DWORD = 707; +pub const ERROR_RECEIVE_EXPEDITED: ::DWORD = 708; +pub const ERROR_RECEIVE_PARTIAL_EXPEDITED: ::DWORD = 709; +pub const ERROR_EVENT_DONE: ::DWORD = 710; +pub const ERROR_EVENT_PENDING: ::DWORD = 711; +pub const ERROR_CHECKING_FILE_SYSTEM: ::DWORD = 712; +pub const ERROR_FATAL_APP_EXIT: ::DWORD = 713; +pub const ERROR_PREDEFINED_HANDLE: ::DWORD = 714; +pub const ERROR_WAS_UNLOCKED: ::DWORD = 715; +pub const ERROR_SERVICE_NOTIFICATION: ::DWORD = 716; +pub const ERROR_WAS_LOCKED: ::DWORD = 717; +pub const ERROR_LOG_HARD_ERROR: ::DWORD = 718; +pub const ERROR_ALREADY_WIN32: ::DWORD = 719; +pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE: ::DWORD = 720; +pub const ERROR_NO_YIELD_PERFORMED: ::DWORD = 721; +pub const ERROR_TIMER_RESUME_IGNORED: ::DWORD = 722; +pub const ERROR_ARBITRATION_UNHANDLED: ::DWORD = 723; +pub const ERROR_CARDBUS_NOT_SUPPORTED: ::DWORD = 724; +pub const ERROR_MP_PROCESSOR_MISMATCH: ::DWORD = 725; +pub const ERROR_HIBERNATED: ::DWORD = 726; +pub const ERROR_RESUME_HIBERNATION: ::DWORD = 727; +pub const ERROR_FIRMWARE_UPDATED: ::DWORD = 728; +pub const ERROR_DRIVERS_LEAKING_LOCKED_PAGES: ::DWORD = 729; +pub const ERROR_WAKE_SYSTEM: ::DWORD = 730; +pub const ERROR_WAIT_1: ::DWORD = 731; +pub const ERROR_WAIT_2: ::DWORD = 732; +pub const ERROR_WAIT_3: ::DWORD = 733; +pub const ERROR_WAIT_63: ::DWORD = 734; +pub const ERROR_ABANDONED_WAIT_0: ::DWORD = 735; +pub const ERROR_ABANDONED_WAIT_63: ::DWORD = 736; +pub const ERROR_USER_APC: ::DWORD = 737; +pub const ERROR_KERNEL_APC: ::DWORD = 738; +pub const ERROR_ALERTED: ::DWORD = 739; +pub const ERROR_ELEVATION_REQUIRED: ::DWORD = 740; +pub const ERROR_REPARSE: ::DWORD = 741; +pub const ERROR_OPLOCK_BREAK_IN_PROGRESS: ::DWORD = 742; +pub const ERROR_VOLUME_MOUNTED: ::DWORD = 743; +pub const ERROR_RXACT_COMMITTED: ::DWORD = 744; +pub const ERROR_NOTIFY_CLEANUP: ::DWORD = 745; +pub const ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED: ::DWORD = 746; +pub const ERROR_PAGE_FAULT_TRANSITION: ::DWORD = 747; +pub const ERROR_PAGE_FAULT_DEMAND_ZERO: ::DWORD = 748; +pub const ERROR_PAGE_FAULT_COPY_ON_WRITE: ::DWORD = 749; +pub const ERROR_PAGE_FAULT_GUARD_PAGE: ::DWORD = 750; +pub const ERROR_PAGE_FAULT_PAGING_FILE: ::DWORD = 751; +pub const ERROR_CACHE_PAGE_LOCKED: ::DWORD = 752; +pub const ERROR_CRASH_DUMP: ::DWORD = 753; +pub const ERROR_BUFFER_ALL_ZEROS: ::DWORD = 754; +pub const ERROR_REPARSE_OBJECT: ::DWORD = 755; +pub const ERROR_RESOURCE_REQUIREMENTS_CHANGED: ::DWORD = 756; +pub const ERROR_TRANSLATION_COMPLETE: ::DWORD = 757; +pub const ERROR_NOTHING_TO_TERMINATE: ::DWORD = 758; +pub const ERROR_PROCESS_NOT_IN_JOB: ::DWORD = 759; +pub const ERROR_PROCESS_IN_JOB: ::DWORD = 760; +pub const ERROR_VOLSNAP_HIBERNATE_READY: ::DWORD = 761; +pub const ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY: ::DWORD = 762; +pub const ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED: ::DWORD = 763; +pub const ERROR_INTERRUPT_STILL_CONNECTED: ::DWORD = 764; +pub const ERROR_WAIT_FOR_OPLOCK: ::DWORD = 765; +pub const ERROR_DBG_EXCEPTION_HANDLED: ::DWORD = 766; +pub const ERROR_DBG_CONTINUE: ::DWORD = 767; +pub const ERROR_CALLBACK_POP_STACK: ::DWORD = 768; +pub const ERROR_COMPRESSION_DISABLED: ::DWORD = 769; +pub const ERROR_CANTFETCHBACKWARDS: ::DWORD = 770; +pub const ERROR_CANTSCROLLBACKWARDS: ::DWORD = 771; +pub const ERROR_ROWSNOTRELEASED: ::DWORD = 772; +pub const ERROR_BAD_ACCESSOR_FLAGS: ::DWORD = 773; +pub const ERROR_ERRORS_ENCOUNTERED: ::DWORD = 774; +pub const ERROR_NOT_CAPABLE: ::DWORD = 775; +pub const ERROR_REQUEST_OUT_OF_SEQUENCE: ::DWORD = 776; +pub const ERROR_VERSION_PARSE_ERROR: ::DWORD = 777; +pub const ERROR_BADSTARTPOSITION: ::DWORD = 778; +pub const ERROR_MEMORY_HARDWARE: ::DWORD = 779; +pub const ERROR_DISK_REPAIR_DISABLED: ::DWORD = 780; +pub const ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: ::DWORD = 781; +pub const ERROR_SYSTEM_POWERSTATE_TRANSITION: ::DWORD = 782; +pub const ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: ::DWORD = 783; +pub const ERROR_MCA_EXCEPTION: ::DWORD = 784; +pub const ERROR_ACCESS_AUDIT_BY_POLICY: ::DWORD = 785; +pub const ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: ::DWORD = 786; +pub const ERROR_ABANDON_HIBERFILE: ::DWORD = 787; +pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: ::DWORD = 788; +pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: ::DWORD = 789; +pub const ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: ::DWORD = 790; +pub const ERROR_BAD_MCFG_TABLE: ::DWORD = 791; +pub const ERROR_DISK_REPAIR_REDIRECTED: ::DWORD = 792; +pub const ERROR_DISK_REPAIR_UNSUCCESSFUL: ::DWORD = 793; +pub const ERROR_CORRUPT_LOG_OVERFULL: ::DWORD = 794; +pub const ERROR_CORRUPT_LOG_CORRUPTED: ::DWORD = 795; +pub const ERROR_CORRUPT_LOG_UNAVAILABLE: ::DWORD = 796; +pub const ERROR_CORRUPT_LOG_DELETED_FULL: ::DWORD = 797; +pub const ERROR_CORRUPT_LOG_CLEARED: ::DWORD = 798; +pub const ERROR_ORPHAN_NAME_EXHAUSTED: ::DWORD = 799; +pub const ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE: ::DWORD = 800; +pub const ERROR_CANNOT_GRANT_REQUESTED_OPLOCK: ::DWORD = 801; +pub const ERROR_CANNOT_BREAK_OPLOCK: ::DWORD = 802; +pub const ERROR_OPLOCK_HANDLE_CLOSED: ::DWORD = 803; +pub const ERROR_NO_ACE_CONDITION: ::DWORD = 804; +pub const ERROR_INVALID_ACE_CONDITION: ::DWORD = 805; +pub const ERROR_FILE_HANDLE_REVOKED: ::DWORD = 806; +pub const ERROR_IMAGE_AT_DIFFERENT_BASE: ::DWORD = 807; +pub const ERROR_ENCRYPTED_IO_NOT_POSSIBLE: ::DWORD = 808; +pub const ERROR_EA_ACCESS_DENIED: ::DWORD = 994; +pub const ERROR_OPERATION_ABORTED: ::DWORD = 995; +pub const ERROR_IO_INCOMPLETE: ::DWORD = 996; +pub const ERROR_IO_PENDING: ::DWORD = 997; +pub const ERROR_NOACCESS: ::DWORD = 998; +pub const ERROR_SWAPERROR: ::DWORD = 999; +pub const ERROR_STACK_OVERFLOW: ::DWORD = 1001; +pub const ERROR_INVALID_MESSAGE: ::DWORD = 1002; +pub const ERROR_CAN_NOT_COMPLETE: ::DWORD = 1003; +pub const ERROR_INVALID_FLAGS: ::DWORD = 1004; +pub const ERROR_UNRECOGNIZED_VOLUME: ::DWORD = 1005; +pub const ERROR_FILE_INVALID: ::DWORD = 1006; +pub const ERROR_FULLSCREEN_MODE: ::DWORD = 1007; +pub const ERROR_NO_TOKEN: ::DWORD = 1008; +pub const ERROR_BADDB: ::DWORD = 1009; +pub const ERROR_BADKEY: ::DWORD = 1010; +pub const ERROR_CANTOPEN: ::DWORD = 1011; +pub const ERROR_CANTREAD: ::DWORD = 1012; +pub const ERROR_CANTWRITE: ::DWORD = 1013; +pub const ERROR_REGISTRY_RECOVERED: ::DWORD = 1014; +pub const ERROR_REGISTRY_CORRUPT: ::DWORD = 1015; +pub const ERROR_REGISTRY_IO_FAILED: ::DWORD = 1016; +pub const ERROR_NOT_REGISTRY_FILE: ::DWORD = 1017; +pub const ERROR_KEY_DELETED: ::DWORD = 1018; +pub const ERROR_NO_LOG_SPACE: ::DWORD = 1019; +pub const ERROR_KEY_HAS_CHILDREN: ::DWORD = 1020; +pub const ERROR_CHILD_MUST_BE_VOLATILE: ::DWORD = 1021; +pub const ERROR_NOTIFY_ENUM_DIR: ::DWORD = 1022; +pub const ERROR_DEPENDENT_SERVICES_RUNNING: ::DWORD = 1051; +pub const ERROR_INVALID_SERVICE_CONTROL: ::DWORD = 1052; +pub const ERROR_SERVICE_REQUEST_TIMEOUT: ::DWORD = 1053; +pub const ERROR_SERVICE_NO_THREAD: ::DWORD = 1054; +pub const ERROR_SERVICE_DATABASE_LOCKED: ::DWORD = 1055; +pub const ERROR_SERVICE_ALREADY_RUNNING: ::DWORD = 1056; +pub const ERROR_INVALID_SERVICE_ACCOUNT: ::DWORD = 1057; +pub const ERROR_SERVICE_DISABLED: ::DWORD = 1058; +pub const ERROR_CIRCULAR_DEPENDENCY: ::DWORD = 1059; +pub const ERROR_SERVICE_DOES_NOT_EXIST: ::DWORD = 1060; +pub const ERROR_SERVICE_CANNOT_ACCEPT_CTRL: ::DWORD = 1061; +pub const ERROR_SERVICE_NOT_ACTIVE: ::DWORD = 1062; +pub const ERROR_FAILED_SERVICE_CONTROLLER_CONNECT: ::DWORD = 1063; +pub const ERROR_EXCEPTION_IN_SERVICE: ::DWORD = 1064; +pub const ERROR_DATABASE_DOES_NOT_EXIST: ::DWORD = 1065; +pub const ERROR_SERVICE_SPECIFIC_ERROR: ::DWORD = 1066; +pub const ERROR_PROCESS_ABORTED: ::DWORD = 1067; +pub const ERROR_SERVICE_DEPENDENCY_FAIL: ::DWORD = 1068; +pub const ERROR_SERVICE_LOGON_FAILED: ::DWORD = 1069; +pub const ERROR_SERVICE_START_HANG: ::DWORD = 1070; +pub const ERROR_INVALID_SERVICE_LOCK: ::DWORD = 1071; +pub const ERROR_SERVICE_MARKED_FOR_DELETE: ::DWORD = 1072; +pub const ERROR_SERVICE_EXISTS: ::DWORD = 1073; +pub const ERROR_ALREADY_RUNNING_LKG: ::DWORD = 1074; +pub const ERROR_SERVICE_DEPENDENCY_DELETED: ::DWORD = 1075; +pub const ERROR_BOOT_ALREADY_ACCEPTED: ::DWORD = 1076; +pub const ERROR_SERVICE_NEVER_STARTED: ::DWORD = 1077; +pub const ERROR_DUPLICATE_SERVICE_NAME: ::DWORD = 1078; +pub const ERROR_DIFFERENT_SERVICE_ACCOUNT: ::DWORD = 1079; +pub const ERROR_CANNOT_DETECT_DRIVER_FAILURE: ::DWORD = 1080; +pub const ERROR_CANNOT_DETECT_PROCESS_ABORT: ::DWORD = 1081; +pub const ERROR_NO_RECOVERY_PROGRAM: ::DWORD = 1082; +pub const ERROR_SERVICE_NOT_IN_EXE: ::DWORD = 1083; +pub const ERROR_NOT_SAFEBOOT_SERVICE: ::DWORD = 1084; +pub const ERROR_END_OF_MEDIA: ::DWORD = 1100; +pub const ERROR_FILEMARK_DETECTED: ::DWORD = 1101; +pub const ERROR_BEGINNING_OF_MEDIA: ::DWORD = 1102; +pub const ERROR_SETMARK_DETECTED: ::DWORD = 1103; +pub const ERROR_NO_DATA_DETECTED: ::DWORD = 1104; +pub const ERROR_PARTITION_FAILURE: ::DWORD = 1105; +pub const ERROR_INVALID_BLOCK_LENGTH: ::DWORD = 1106; +pub const ERROR_DEVICE_NOT_PARTITIONED: ::DWORD = 1107; +pub const ERROR_UNABLE_TO_LOCK_MEDIA: ::DWORD = 1108; +pub const ERROR_UNABLE_TO_UNLOAD_MEDIA: ::DWORD = 1109; +pub const ERROR_MEDIA_CHANGED: ::DWORD = 1110; +pub const ERROR_BUS_RESET: ::DWORD = 1111; +pub const ERROR_NO_MEDIA_IN_DRIVE: ::DWORD = 1112; +pub const ERROR_NO_UNICODE_TRANSLATION: ::DWORD = 1113; +pub const ERROR_DLL_INIT_FAILED: ::DWORD = 1114; +pub const ERROR_SHUTDOWN_IN_PROGRESS: ::DWORD = 1115; +pub const ERROR_NO_SHUTDOWN_IN_PROGRESS: ::DWORD = 1116; +pub const ERROR_IO_DEVICE: ::DWORD = 1117; +pub const ERROR_SERIAL_NO_DEVICE: ::DWORD = 1118; +pub const ERROR_IRQ_BUSY: ::DWORD = 1119; +pub const ERROR_MORE_WRITES: ::DWORD = 1120; +pub const ERROR_COUNTER_TIMEOUT: ::DWORD = 1121; +pub const ERROR_FLOPPY_ID_MARK_NOT_FOUND: ::DWORD = 1122; +pub const ERROR_FLOPPY_WRONG_CYLINDER: ::DWORD = 1123; +pub const ERROR_FLOPPY_UNKNOWN_ERROR: ::DWORD = 1124; +pub const ERROR_FLOPPY_BAD_REGISTERS: ::DWORD = 1125; +pub const ERROR_DISK_RECALIBRATE_FAILED: ::DWORD = 1126; +pub const ERROR_DISK_OPERATION_FAILED: ::DWORD = 1127; +pub const ERROR_DISK_RESET_FAILED: ::DWORD = 1128; +pub const ERROR_EOM_OVERFLOW: ::DWORD = 1129; +pub const ERROR_NOT_ENOUGH_SERVER_MEMORY: ::DWORD = 1130; +pub const ERROR_POSSIBLE_DEADLOCK: ::DWORD = 1131; +pub const ERROR_MAPPED_ALIGNMENT: ::DWORD = 1132; +pub const ERROR_SET_POWER_STATE_VETOED: ::DWORD = 1140; +pub const ERROR_SET_POWER_STATE_FAILED: ::DWORD = 1141; +pub const ERROR_TOO_MANY_LINKS: ::DWORD = 1142; +pub const ERROR_OLD_WIN_VERSION: ::DWORD = 1150; +pub const ERROR_APP_WRONG_OS: ::DWORD = 1151; +pub const ERROR_SINGLE_INSTANCE_APP: ::DWORD = 1152; +pub const ERROR_RMODE_APP: ::DWORD = 1153; +pub const ERROR_INVALID_DLL: ::DWORD = 1154; +pub const ERROR_NO_ASSOCIATION: ::DWORD = 1155; +pub const ERROR_DDE_FAIL: ::DWORD = 1156; +pub const ERROR_DLL_NOT_FOUND: ::DWORD = 1157; +pub const ERROR_NO_MORE_USER_HANDLES: ::DWORD = 1158; +pub const ERROR_MESSAGE_SYNC_ONLY: ::DWORD = 1159; +pub const ERROR_SOURCE_ELEMENT_EMPTY: ::DWORD = 1160; +pub const ERROR_DESTINATION_ELEMENT_FULL: ::DWORD = 1161; +pub const ERROR_ILLEGAL_ELEMENT_ADDRESS: ::DWORD = 1162; +pub const ERROR_MAGAZINE_NOT_PRESENT: ::DWORD = 1163; +pub const ERROR_DEVICE_REINITIALIZATION_NEEDED: ::DWORD = 1164; +pub const ERROR_DEVICE_REQUIRES_CLEANING: ::DWORD = 1165; +pub const ERROR_DEVICE_DOOR_OPEN: ::DWORD = 1166; +pub const ERROR_DEVICE_NOT_CONNECTED: ::DWORD = 1167; +pub const ERROR_NOT_FOUND: ::DWORD = 1168; +pub const ERROR_NO_MATCH: ::DWORD = 1169; +pub const ERROR_SET_NOT_FOUND: ::DWORD = 1170; +pub const ERROR_POINT_NOT_FOUND: ::DWORD = 1171; +pub const ERROR_NO_TRACKING_SERVICE: ::DWORD = 1172; +pub const ERROR_NO_VOLUME_ID: ::DWORD = 1173; +pub const ERROR_UNABLE_TO_REMOVE_REPLACED: ::DWORD = 1175; +pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT: ::DWORD = 1176; +pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT_2: ::DWORD = 1177; +pub const ERROR_JOURNAL_DELETE_IN_PROGRESS: ::DWORD = 1178; +pub const ERROR_JOURNAL_NOT_ACTIVE: ::DWORD = 1179; +pub const ERROR_POTENTIAL_FILE_FOUND: ::DWORD = 1180; +pub const ERROR_JOURNAL_ENTRY_DELETED: ::DWORD = 1181; +pub const ERROR_SHUTDOWN_IS_SCHEDULED: ::DWORD = 1190; +pub const ERROR_SHUTDOWN_USERS_LOGGED_ON: ::DWORD = 1191; +pub const ERROR_BAD_DEVICE: ::DWORD = 1200; +pub const ERROR_CONNECTION_UNAVAIL: ::DWORD = 1201; +pub const ERROR_DEVICE_ALREADY_REMEMBERED: ::DWORD = 1202; +pub const ERROR_NO_NET_OR_BAD_PATH: ::DWORD = 1203; +pub const ERROR_BAD_PROVIDER: ::DWORD = 1204; +pub const ERROR_CANNOT_OPEN_PROFILE: ::DWORD = 1205; +pub const ERROR_BAD_PROFILE: ::DWORD = 1206; +pub const ERROR_NOT_CONTAINER: ::DWORD = 1207; +pub const ERROR_EXTENDED_ERROR: ::DWORD = 1208; +pub const ERROR_INVALID_GROUPNAME: ::DWORD = 1209; +pub const ERROR_INVALID_COMPUTERNAME: ::DWORD = 1210; +pub const ERROR_INVALID_EVENTNAME: ::DWORD = 1211; +pub const ERROR_INVALID_DOMAINNAME: ::DWORD = 1212; +pub const ERROR_INVALID_SERVICENAME: ::DWORD = 1213; +pub const ERROR_INVALID_NETNAME: ::DWORD = 1214; +pub const ERROR_INVALID_SHARENAME: ::DWORD = 1215; +pub const ERROR_INVALID_PASSWORDNAME: ::DWORD = 1216; +pub const ERROR_INVALID_MESSAGENAME: ::DWORD = 1217; +pub const ERROR_INVALID_MESSAGEDEST: ::DWORD = 1218; +pub const ERROR_SESSION_CREDENTIAL_CONFLICT: ::DWORD = 1219; +pub const ERROR_REMOTE_SESSION_LIMIT_EXCEEDED: ::DWORD = 1220; +pub const ERROR_DUP_DOMAINNAME: ::DWORD = 1221; +pub const ERROR_NO_NETWORK: ::DWORD = 1222; +pub const ERROR_CANCELLED: ::DWORD = 1223; +pub const ERROR_USER_MAPPED_FILE: ::DWORD = 1224; +pub const ERROR_CONNECTION_REFUSED: ::DWORD = 1225; +pub const ERROR_GRACEFUL_DISCONNECT: ::DWORD = 1226; +pub const ERROR_ADDRESS_ALREADY_ASSOCIATED: ::DWORD = 1227; +pub const ERROR_ADDRESS_NOT_ASSOCIATED: ::DWORD = 1228; +pub const ERROR_CONNECTION_INVALID: ::DWORD = 1229; +pub const ERROR_CONNECTION_ACTIVE: ::DWORD = 1230; +pub const ERROR_NETWORK_UNREACHABLE: ::DWORD = 1231; +pub const ERROR_HOST_UNREACHABLE: ::DWORD = 1232; +pub const ERROR_PROTOCOL_UNREACHABLE: ::DWORD = 1233; +pub const ERROR_PORT_UNREACHABLE: ::DWORD = 1234; +pub const ERROR_REQUEST_ABORTED: ::DWORD = 1235; +pub const ERROR_CONNECTION_ABORTED: ::DWORD = 1236; +pub const ERROR_RETRY: ::DWORD = 1237; +pub const ERROR_CONNECTION_COUNT_LIMIT: ::DWORD = 1238; +pub const ERROR_LOGIN_TIME_RESTRICTION: ::DWORD = 1239; +pub const ERROR_LOGIN_WKSTA_RESTRICTION: ::DWORD = 1240; +pub const ERROR_INCORRECT_ADDRESS: ::DWORD = 1241; +pub const ERROR_ALREADY_REGISTERED: ::DWORD = 1242; +pub const ERROR_SERVICE_NOT_FOUND: ::DWORD = 1243; +pub const ERROR_NOT_AUTHENTICATED: ::DWORD = 1244; +pub const ERROR_NOT_LOGGED_ON: ::DWORD = 1245; +pub const ERROR_CONTINUE: ::DWORD = 1246; +pub const ERROR_ALREADY_INITIALIZED: ::DWORD = 1247; +pub const ERROR_NO_MORE_DEVICES: ::DWORD = 1248; +pub const ERROR_NO_SUCH_SITE: ::DWORD = 1249; +pub const ERROR_DOMAIN_CONTROLLER_EXISTS: ::DWORD = 1250; +pub const ERROR_ONLY_IF_CONNECTED: ::DWORD = 1251; +pub const ERROR_OVERRIDE_NOCHANGES: ::DWORD = 1252; +pub const ERROR_BAD_USER_PROFILE: ::DWORD = 1253; +pub const ERROR_NOT_SUPPORTED_ON_SBS: ::DWORD = 1254; +pub const ERROR_SERVER_SHUTDOWN_IN_PROGRESS: ::DWORD = 1255; +pub const ERROR_HOST_DOWN: ::DWORD = 1256; +pub const ERROR_NON_ACCOUNT_SID: ::DWORD = 1257; +pub const ERROR_NON_DOMAIN_SID: ::DWORD = 1258; +pub const ERROR_APPHELP_BLOCK: ::DWORD = 1259; +pub const ERROR_ACCESS_DISABLED_BY_POLICY: ::DWORD = 1260; +pub const ERROR_REG_NAT_CONSUMPTION: ::DWORD = 1261; +pub const ERROR_CSCSHARE_OFFLINE: ::DWORD = 1262; +pub const ERROR_PKINIT_FAILURE: ::DWORD = 1263; +pub const ERROR_SMARTCARD_SUBSYSTEM_FAILURE: ::DWORD = 1264; +pub const ERROR_DOWNGRADE_DETECTED: ::DWORD = 1265; +pub const ERROR_MACHINE_LOCKED: ::DWORD = 1271; +pub const ERROR_CALLBACK_SUPPLIED_INVALID_DATA: ::DWORD = 1273; +pub const ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED: ::DWORD = 1274; +pub const ERROR_DRIVER_BLOCKED: ::DWORD = 1275; +pub const ERROR_INVALID_IMPORT_OF_NON_DLL: ::DWORD = 1276; +pub const ERROR_ACCESS_DISABLED_WEBBLADE: ::DWORD = 1277; +pub const ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER: ::DWORD = 1278; +pub const ERROR_RECOVERY_FAILURE: ::DWORD = 1279; +pub const ERROR_ALREADY_FIBER: ::DWORD = 1280; +pub const ERROR_ALREADY_THREAD: ::DWORD = 1281; +pub const ERROR_STACK_BUFFER_OVERRUN: ::DWORD = 1282; +pub const ERROR_PARAMETER_QUOTA_EXCEEDED: ::DWORD = 1283; +pub const ERROR_DEBUGGER_INACTIVE: ::DWORD = 1284; +pub const ERROR_DELAY_LOAD_FAILED: ::DWORD = 1285; +pub const ERROR_VDM_DISALLOWED: ::DWORD = 1286; +pub const ERROR_UNIDENTIFIED_ERROR: ::DWORD = 1287; +pub const ERROR_INVALID_CRUNTIME_PARAMETER: ::DWORD = 1288; +pub const ERROR_BEYOND_VDL: ::DWORD = 1289; +pub const ERROR_INCOMPATIBLE_SERVICE_SID_TYPE: ::DWORD = 1290; +pub const ERROR_DRIVER_PROCESS_TERMINATED: ::DWORD = 1291; +pub const ERROR_IMPLEMENTATION_LIMIT: ::DWORD = 1292; +pub const ERROR_PROCESS_IS_PROTECTED: ::DWORD = 1293; +pub const ERROR_SERVICE_NOTIFY_CLIENT_LAGGING: ::DWORD = 1294; +pub const ERROR_DISK_QUOTA_EXCEEDED: ::DWORD = 1295; +pub const ERROR_CONTENT_BLOCKED: ::DWORD = 1296; +pub const ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE: ::DWORD = 1297; +pub const ERROR_APP_HANG: ::DWORD = 1298; +pub const ERROR_INVALID_LABEL: ::DWORD = 1299; +pub const ERROR_NOT_ALL_ASSIGNED: ::DWORD = 1300; +pub const ERROR_SOME_NOT_MAPPED: ::DWORD = 1301; +pub const ERROR_NO_QUOTAS_FOR_ACCOUNT: ::DWORD = 1302; +pub const ERROR_LOCAL_USER_SESSION_KEY: ::DWORD = 1303; +pub const ERROR_NULL_LM_PASSWORD: ::DWORD = 1304; +pub const ERROR_UNKNOWN_REVISION: ::DWORD = 1305; +pub const ERROR_REVISION_MISMATCH: ::DWORD = 1306; +pub const ERROR_INVALID_OWNER: ::DWORD = 1307; +pub const ERROR_INVALID_PRIMARY_GROUP: ::DWORD = 1308; +pub const ERROR_NO_IMPERSONATION_TOKEN: ::DWORD = 1309; +pub const ERROR_CANT_DISABLE_MANDATORY: ::DWORD = 1310; +pub const ERROR_NO_LOGON_SERVERS: ::DWORD = 1311; +pub const ERROR_NO_SUCH_LOGON_SESSION: ::DWORD = 1312; +pub const ERROR_NO_SUCH_PRIVILEGE: ::DWORD = 1313; +pub const ERROR_PRIVILEGE_NOT_HELD: ::DWORD = 1314; +pub const ERROR_INVALID_ACCOUNT_NAME: ::DWORD = 1315; +pub const ERROR_USER_EXISTS: ::DWORD = 1316; +pub const ERROR_NO_SUCH_USER: ::DWORD = 1317; +pub const ERROR_GROUP_EXISTS: ::DWORD = 1318; +pub const ERROR_NO_SUCH_GROUP: ::DWORD = 1319; +pub const ERROR_MEMBER_IN_GROUP: ::DWORD = 1320; +pub const ERROR_MEMBER_NOT_IN_GROUP: ::DWORD = 1321; +pub const ERROR_LAST_ADMIN: ::DWORD = 1322; +pub const ERROR_WRONG_PASSWORD: ::DWORD = 1323; +pub const ERROR_ILL_FORMED_PASSWORD: ::DWORD = 1324; +pub const ERROR_PASSWORD_RESTRICTION: ::DWORD = 1325; +pub const ERROR_LOGON_FAILURE: ::DWORD = 1326; +pub const ERROR_ACCOUNT_RESTRICTION: ::DWORD = 1327; +pub const ERROR_INVALID_LOGON_HOURS: ::DWORD = 1328; +pub const ERROR_INVALID_WORKSTATION: ::DWORD = 1329; +pub const ERROR_PASSWORD_EXPIRED: ::DWORD = 1330; +pub const ERROR_ACCOUNT_DISABLED: ::DWORD = 1331; +pub const ERROR_NONE_MAPPED: ::DWORD = 1332; +pub const ERROR_TOO_MANY_LUIDS_REQUESTED: ::DWORD = 1333; +pub const ERROR_LUIDS_EXHAUSTED: ::DWORD = 1334; +pub const ERROR_INVALID_SUB_AUTHORITY: ::DWORD = 1335; +pub const ERROR_INVALID_ACL: ::DWORD = 1336; +pub const ERROR_INVALID_SID: ::DWORD = 1337; +pub const ERROR_INVALID_SECURITY_DESCR: ::DWORD = 1338; +pub const ERROR_BAD_INHERITANCE_ACL: ::DWORD = 1340; +pub const ERROR_SERVER_DISABLED: ::DWORD = 1341; +pub const ERROR_SERVER_NOT_DISABLED: ::DWORD = 1342; +pub const ERROR_INVALID_ID_AUTHORITY: ::DWORD = 1343; +pub const ERROR_ALLOTTED_SPACE_EXCEEDED: ::DWORD = 1344; +pub const ERROR_INVALID_GROUP_ATTRIBUTES: ::DWORD = 1345; +pub const ERROR_BAD_IMPERSONATION_LEVEL: ::DWORD = 1346; +pub const ERROR_CANT_OPEN_ANONYMOUS: ::DWORD = 1347; +pub const ERROR_BAD_VALIDATION_CLASS: ::DWORD = 1348; +pub const ERROR_BAD_TOKEN_TYPE: ::DWORD = 1349; +pub const ERROR_NO_SECURITY_ON_OBJECT: ::DWORD = 1350; +pub const ERROR_CANT_ACCESS_DOMAIN_INFO: ::DWORD = 1351; +pub const ERROR_INVALID_SERVER_STATE: ::DWORD = 1352; +pub const ERROR_INVALID_DOMAIN_STATE: ::DWORD = 1353; +pub const ERROR_INVALID_DOMAIN_ROLE: ::DWORD = 1354; +pub const ERROR_NO_SUCH_DOMAIN: ::DWORD = 1355; +pub const ERROR_DOMAIN_EXISTS: ::DWORD = 1356; +pub const ERROR_DOMAIN_LIMIT_EXCEEDED: ::DWORD = 1357; +pub const ERROR_INTERNAL_DB_CORRUPTION: ::DWORD = 1358; +pub const ERROR_INTERNAL_ERROR: ::DWORD = 1359; +pub const ERROR_GENERIC_NOT_MAPPED: ::DWORD = 1360; +pub const ERROR_BAD_DESCRIPTOR_FORMAT: ::DWORD = 1361; +pub const ERROR_NOT_LOGON_PROCESS: ::DWORD = 1362; +pub const ERROR_LOGON_SESSION_EXISTS: ::DWORD = 1363; +pub const ERROR_NO_SUCH_PACKAGE: ::DWORD = 1364; +pub const ERROR_BAD_LOGON_SESSION_STATE: ::DWORD = 1365; +pub const ERROR_LOGON_SESSION_COLLISION: ::DWORD = 1366; +pub const ERROR_INVALID_LOGON_TYPE: ::DWORD = 1367; +pub const ERROR_CANNOT_IMPERSONATE: ::DWORD = 1368; +pub const ERROR_RXACT_INVALID_STATE: ::DWORD = 1369; +pub const ERROR_RXACT_COMMIT_FAILURE: ::DWORD = 1370; +pub const ERROR_SPECIAL_ACCOUNT: ::DWORD = 1371; +pub const ERROR_SPECIAL_GROUP: ::DWORD = 1372; +pub const ERROR_SPECIAL_USER: ::DWORD = 1373; +pub const ERROR_MEMBERS_PRIMARY_GROUP: ::DWORD = 1374; +pub const ERROR_TOKEN_ALREADY_IN_USE: ::DWORD = 1375; +pub const ERROR_NO_SUCH_ALIAS: ::DWORD = 1376; +pub const ERROR_MEMBER_NOT_IN_ALIAS: ::DWORD = 1377; +pub const ERROR_MEMBER_IN_ALIAS: ::DWORD = 1378; +pub const ERROR_ALIAS_EXISTS: ::DWORD = 1379; +pub const ERROR_LOGON_NOT_GRANTED: ::DWORD = 1380; +pub const ERROR_TOO_MANY_SECRETS: ::DWORD = 1381; +pub const ERROR_SECRET_TOO_LONG: ::DWORD = 1382; +pub const ERROR_INTERNAL_DB_ERROR: ::DWORD = 1383; +pub const ERROR_TOO_MANY_CONTEXT_IDS: ::DWORD = 1384; +pub const ERROR_LOGON_TYPE_NOT_GRANTED: ::DWORD = 1385; +pub const ERROR_NT_CROSS_ENCRYPTION_REQUIRED: ::DWORD = 1386; +pub const ERROR_NO_SUCH_MEMBER: ::DWORD = 1387; +pub const ERROR_INVALID_MEMBER: ::DWORD = 1388; +pub const ERROR_TOO_MANY_SIDS: ::DWORD = 1389; +pub const ERROR_LM_CROSS_ENCRYPTION_REQUIRED: ::DWORD = 1390; +pub const ERROR_NO_INHERITANCE: ::DWORD = 1391; +pub const ERROR_FILE_CORRUPT: ::DWORD = 1392; +pub const ERROR_DISK_CORRUPT: ::DWORD = 1393; +pub const ERROR_NO_USER_SESSION_KEY: ::DWORD = 1394; +pub const ERROR_LICENSE_QUOTA_EXCEEDED: ::DWORD = 1395; +pub const ERROR_WRONG_TARGET_NAME: ::DWORD = 1396; +pub const ERROR_MUTUAL_AUTH_FAILED: ::DWORD = 1397; +pub const ERROR_TIME_SKEW: ::DWORD = 1398; +pub const ERROR_CURRENT_DOMAIN_NOT_ALLOWED: ::DWORD = 1399; +pub const ERROR_INVALID_WINDOW_HANDLE: ::DWORD = 1400; +pub const ERROR_INVALID_MENU_HANDLE: ::DWORD = 1401; +pub const ERROR_INVALID_CURSOR_HANDLE: ::DWORD = 1402; +pub const ERROR_INVALID_ACCEL_HANDLE: ::DWORD = 1403; +pub const ERROR_INVALID_HOOK_HANDLE: ::DWORD = 1404; +pub const ERROR_INVALID_DWP_HANDLE: ::DWORD = 1405; +pub const ERROR_TLW_WITH_WSCHILD: ::DWORD = 1406; +pub const ERROR_CANNOT_FIND_WND_CLASS: ::DWORD = 1407; +pub const ERROR_WINDOW_OF_OTHER_THREAD: ::DWORD = 1408; +pub const ERROR_HOTKEY_ALREADY_REGISTERED: ::DWORD = 1409; +pub const ERROR_CLASS_ALREADY_EXISTS: ::DWORD = 1410; +pub const ERROR_CLASS_DOES_NOT_EXIST: ::DWORD = 1411; +pub const ERROR_CLASS_HAS_WINDOWS: ::DWORD = 1412; +pub const ERROR_INVALID_INDEX: ::DWORD = 1413; +pub const ERROR_INVALID_ICON_HANDLE: ::DWORD = 1414; +pub const ERROR_PRIVATE_DIALOG_INDEX: ::DWORD = 1415; +pub const ERROR_LISTBOX_ID_NOT_FOUND: ::DWORD = 1416; +pub const ERROR_NO_WILDCARD_CHARACTERS: ::DWORD = 1417; +pub const ERROR_CLIPBOARD_NOT_OPEN: ::DWORD = 1418; +pub const ERROR_HOTKEY_NOT_REGISTERED: ::DWORD = 1419; +pub const ERROR_WINDOW_NOT_DIALOG: ::DWORD = 1420; +pub const ERROR_CONTROL_ID_NOT_FOUND: ::DWORD = 1421; +pub const ERROR_INVALID_COMBOBOX_MESSAGE: ::DWORD = 1422; +pub const ERROR_WINDOW_NOT_COMBOBOX: ::DWORD = 1423; +pub const ERROR_INVALID_EDIT_HEIGHT: ::DWORD = 1424; +pub const ERROR_DC_NOT_FOUND: ::DWORD = 1425; +pub const ERROR_INVALID_HOOK_FILTER: ::DWORD = 1426; +pub const ERROR_INVALID_FILTER_PROC: ::DWORD = 1427; +pub const ERROR_HOOK_NEEDS_HMOD: ::DWORD = 1428; +pub const ERROR_GLOBAL_ONLY_HOOK: ::DWORD = 1429; +pub const ERROR_JOURNAL_HOOK_SET: ::DWORD = 1430; +pub const ERROR_HOOK_NOT_INSTALLED: ::DWORD = 1431; +pub const ERROR_INVALID_LB_MESSAGE: ::DWORD = 1432; +pub const ERROR_SETCOUNT_ON_BAD_LB: ::DWORD = 1433; +pub const ERROR_LB_WITHOUT_TABSTOPS: ::DWORD = 1434; +pub const ERROR_DESTROY_OBJECT_OF_OTHER_THREAD: ::DWORD = 1435; +pub const ERROR_CHILD_WINDOW_MENU: ::DWORD = 1436; +pub const ERROR_NO_SYSTEM_MENU: ::DWORD = 1437; +pub const ERROR_INVALID_MSGBOX_STYLE: ::DWORD = 1438; +pub const ERROR_INVALID_SPI_VALUE: ::DWORD = 1439; +pub const ERROR_SCREEN_ALREADY_LOCKED: ::DWORD = 1440; +pub const ERROR_HWNDS_HAVE_DIFF_PARENT: ::DWORD = 1441; +pub const ERROR_NOT_CHILD_WINDOW: ::DWORD = 1442; +pub const ERROR_INVALID_GW_COMMAND: ::DWORD = 1443; +pub const ERROR_INVALID_THREAD_ID: ::DWORD = 1444; +pub const ERROR_NON_MDICHILD_WINDOW: ::DWORD = 1445; +pub const ERROR_POPUP_ALREADY_ACTIVE: ::DWORD = 1446; +pub const ERROR_NO_SCROLLBARS: ::DWORD = 1447; +pub const ERROR_INVALID_SCROLLBAR_RANGE: ::DWORD = 1448; +pub const ERROR_INVALID_SHOWWIN_COMMAND: ::DWORD = 1449; +pub const ERROR_NO_SYSTEM_RESOURCES: ::DWORD = 1450; +pub const ERROR_NONPAGED_SYSTEM_RESOURCES: ::DWORD = 1451; +pub const ERROR_PAGED_SYSTEM_RESOURCES: ::DWORD = 1452; +pub const ERROR_WORKING_SET_QUOTA: ::DWORD = 1453; +pub const ERROR_PAGEFILE_QUOTA: ::DWORD = 1454; +pub const ERROR_COMMITMENT_LIMIT: ::DWORD = 1455; +pub const ERROR_MENU_ITEM_NOT_FOUND: ::DWORD = 1456; +pub const ERROR_INVALID_KEYBOARD_HANDLE: ::DWORD = 1457; +pub const ERROR_HOOK_TYPE_NOT_ALLOWED: ::DWORD = 1458; +pub const ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION: ::DWORD = 1459; +pub const ERROR_TIMEOUT: ::DWORD = 1460; +pub const ERROR_INVALID_MONITOR_HANDLE: ::DWORD = 1461; +pub const ERROR_INCORRECT_SIZE: ::DWORD = 1462; +pub const ERROR_SYMLINK_CLASS_DISABLED: ::DWORD = 1463; +pub const ERROR_SYMLINK_NOT_SUPPORTED: ::DWORD = 1464; +pub const ERROR_XML_PARSE_ERROR: ::DWORD = 1465; +pub const ERROR_XMLDSIG_ERROR: ::DWORD = 1466; +pub const ERROR_RESTART_APPLICATION: ::DWORD = 1467; +pub const ERROR_WRONG_COMPARTMENT: ::DWORD = 1468; +pub const ERROR_AUTHIP_FAILURE: ::DWORD = 1469; +pub const ERROR_NO_NVRAM_RESOURCES: ::DWORD = 1470; +pub const ERROR_NOT_GUI_PROCESS: ::DWORD = 1471; +pub const ERROR_EVENTLOG_FILE_CORRUPT: ::DWORD = 1500; +pub const ERROR_EVENTLOG_CANT_START: ::DWORD = 1501; +pub const ERROR_LOG_FILE_FULL: ::DWORD = 1502; +pub const ERROR_EVENTLOG_FILE_CHANGED: ::DWORD = 1503; +pub const ERROR_INVALID_TASK_NAME: ::DWORD = 1550; +pub const ERROR_INVALID_TASK_INDEX: ::DWORD = 1551; +pub const ERROR_THREAD_ALREADY_IN_TASK: ::DWORD = 1552; +pub const ERROR_INSTALL_SERVICE_FAILURE: ::DWORD = 1601; +pub const ERROR_INSTALL_USEREXIT: ::DWORD = 1602; +pub const ERROR_INSTALL_FAILURE: ::DWORD = 1603; +pub const ERROR_INSTALL_SUSPEND: ::DWORD = 1604; +pub const ERROR_UNKNOWN_PRODUCT: ::DWORD = 1605; +pub const ERROR_UNKNOWN_FEATURE: ::DWORD = 1606; +pub const ERROR_UNKNOWN_COMPONENT: ::DWORD = 1607; +pub const ERROR_UNKNOWN_PROPERTY: ::DWORD = 1608; +pub const ERROR_INVALID_HANDLE_STATE: ::DWORD = 1609; +pub const ERROR_BAD_CONFIGURATION: ::DWORD = 1610; +pub const ERROR_INDEX_ABSENT: ::DWORD = 1611; +pub const ERROR_INSTALL_SOURCE_ABSENT: ::DWORD = 1612; +pub const ERROR_INSTALL_PACKAGE_VERSION: ::DWORD = 1613; +pub const ERROR_PRODUCT_UNINSTALLED: ::DWORD = 1614; +pub const ERROR_BAD_QUERY_SYNTAX: ::DWORD = 1615; +pub const ERROR_INVALID_FIELD: ::DWORD = 1616; +pub const ERROR_DEVICE_REMOVED: ::DWORD = 1617; +pub const ERROR_INSTALL_ALREADY_RUNNING: ::DWORD = 1618; +pub const ERROR_INSTALL_PACKAGE_OPEN_FAILED: ::DWORD = 1619; +pub const ERROR_INSTALL_PACKAGE_INVALID: ::DWORD = 1620; +pub const ERROR_INSTALL_UI_FAILURE: ::DWORD = 1621; +pub const ERROR_INSTALL_LOG_FAILURE: ::DWORD = 1622; +pub const ERROR_INSTALL_LANGUAGE_UNSUPPORTED: ::DWORD = 1623; +pub const ERROR_INSTALL_TRANSFORM_FAILURE: ::DWORD = 1624; +pub const ERROR_INSTALL_PACKAGE_REJECTED: ::DWORD = 1625; +pub const ERROR_FUNCTION_NOT_CALLED: ::DWORD = 1626; +pub const ERROR_FUNCTION_FAILED: ::DWORD = 1627; +pub const ERROR_INVALID_TABLE: ::DWORD = 1628; +pub const ERROR_DATATYPE_MISMATCH: ::DWORD = 1629; +pub const ERROR_UNSUPPORTED_TYPE: ::DWORD = 1630; +pub const ERROR_CREATE_FAILED: ::DWORD = 1631; +pub const ERROR_INSTALL_TEMP_UNWRITABLE: ::DWORD = 1632; +pub const ERROR_INSTALL_PLATFORM_UNSUPPORTED: ::DWORD = 1633; +pub const ERROR_INSTALL_NOTUSED: ::DWORD = 1634; +pub const ERROR_PATCH_PACKAGE_OPEN_FAILED: ::DWORD = 1635; +pub const ERROR_PATCH_PACKAGE_INVALID: ::DWORD = 1636; +pub const ERROR_PATCH_PACKAGE_UNSUPPORTED: ::DWORD = 1637; +pub const ERROR_PRODUCT_VERSION: ::DWORD = 1638; +pub const ERROR_INVALID_COMMAND_LINE: ::DWORD = 1639; +pub const ERROR_INSTALL_REMOTE_DISALLOWED: ::DWORD = 1640; +pub const ERROR_SUCCESS_REBOOT_INITIATED: ::DWORD = 1641; +pub const ERROR_PATCH_TARGET_NOT_FOUND: ::DWORD = 1642; +pub const ERROR_PATCH_PACKAGE_REJECTED: ::DWORD = 1643; +pub const ERROR_INSTALL_TRANSFORM_REJECTED: ::DWORD = 1644; +pub const ERROR_INSTALL_REMOTE_PROHIBITED: ::DWORD = 1645; +pub const ERROR_PATCH_REMOVAL_UNSUPPORTED: ::DWORD = 1646; +pub const ERROR_UNKNOWN_PATCH: ::DWORD = 1647; +pub const ERROR_PATCH_NO_SEQUENCE: ::DWORD = 1648; +pub const ERROR_PATCH_REMOVAL_DISALLOWED: ::DWORD = 1649; +pub const ERROR_INVALID_PATCH_XML: ::DWORD = 1650; +pub const ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT: ::DWORD = 1651; +pub const ERROR_INSTALL_SERVICE_SAFEBOOT: ::DWORD = 1652; +pub const ERROR_FAIL_FAST_EXCEPTION: ::DWORD = 1653; +pub const ERROR_INSTALL_REJECTED: ::DWORD = 1654; +pub const ERROR_DYNAMIC_CODE_BLOCKED: ::DWORD = 1655; +pub const RPC_S_INVALID_STRING_BINDING: ::DWORD = 1700; +pub const RPC_S_WRONG_KIND_OF_BINDING: ::DWORD = 1701; +pub const RPC_S_INVALID_BINDING: ::DWORD = 1702; +pub const RPC_S_PROTSEQ_NOT_SUPPORTED: ::DWORD = 1703; +pub const RPC_S_INVALID_RPC_PROTSEQ: ::DWORD = 1704; +pub const RPC_S_INVALID_STRING_UUID: ::DWORD = 1705; +pub const RPC_S_INVALID_ENDPOINT_FORMAT: ::DWORD = 1706; +pub const RPC_S_INVALID_NET_ADDR: ::DWORD = 1707; +pub const RPC_S_NO_ENDPOINT_FOUND: ::DWORD = 1708; +pub const RPC_S_INVALID_TIMEOUT: ::DWORD = 1709; +pub const RPC_S_OBJECT_NOT_FOUND: ::DWORD = 1710; +pub const RPC_S_ALREADY_REGISTERED: ::DWORD = 1711; +pub const RPC_S_TYPE_ALREADY_REGISTERED: ::DWORD = 1712; +pub const RPC_S_ALREADY_LISTENING: ::DWORD = 1713; +pub const RPC_S_NO_PROTSEQS_REGISTERED: ::DWORD = 1714; +pub const RPC_S_NOT_LISTENING: ::DWORD = 1715; +pub const RPC_S_UNKNOWN_MGR_TYPE: ::DWORD = 1716; +pub const RPC_S_UNKNOWN_IF: ::DWORD = 1717; +pub const RPC_S_NO_BINDINGS: ::DWORD = 1718; +pub const RPC_S_NO_PROTSEQS: ::DWORD = 1719; +pub const RPC_S_CANT_CREATE_ENDPOINT: ::DWORD = 1720; +pub const RPC_S_OUT_OF_RESOURCES: ::DWORD = 1721; +pub const RPC_S_SERVER_UNAVAILABLE: ::DWORD = 1722; +pub const RPC_S_SERVER_TOO_BUSY: ::DWORD = 1723; +pub const RPC_S_INVALID_NETWORK_OPTIONS: ::DWORD = 1724; +pub const RPC_S_NO_CALL_ACTIVE: ::DWORD = 1725; +pub const RPC_S_CALL_FAILED: ::DWORD = 1726; +pub const RPC_S_CALL_FAILED_DNE: ::DWORD = 1727; +pub const RPC_S_PROTOCOL_ERROR: ::DWORD = 1728; +pub const RPC_S_PROXY_ACCESS_DENIED: ::DWORD = 1729; +pub const RPC_S_UNSUPPORTED_TRANS_SYN: ::DWORD = 1730; +pub const RPC_S_UNSUPPORTED_TYPE: ::DWORD = 1732; +pub const RPC_S_INVALID_TAG: ::DWORD = 1733; +pub const RPC_S_INVALID_BOUND: ::DWORD = 1734; +pub const RPC_S_NO_ENTRY_NAME: ::DWORD = 1735; +pub const RPC_S_INVALID_NAME_SYNTAX: ::DWORD = 1736; +pub const RPC_S_UNSUPPORTED_NAME_SYNTAX: ::DWORD = 1737; +pub const RPC_S_UUID_NO_ADDRESS: ::DWORD = 1739; +pub const RPC_S_DUPLICATE_ENDPOINT: ::DWORD = 1740; +pub const RPC_S_UNKNOWN_AUTHN_TYPE: ::DWORD = 1741; +pub const RPC_S_MAX_CALLS_TOO_SMALL: ::DWORD = 1742; +pub const RPC_S_STRING_TOO_LONG: ::DWORD = 1743; +pub const RPC_S_PROTSEQ_NOT_FOUND: ::DWORD = 1744; +pub const RPC_S_PROCNUM_OUT_OF_RANGE: ::DWORD = 1745; +pub const RPC_S_BINDING_HAS_NO_AUTH: ::DWORD = 1746; +pub const RPC_S_UNKNOWN_AUTHN_SERVICE: ::DWORD = 1747; +pub const RPC_S_UNKNOWN_AUTHN_LEVEL: ::DWORD = 1748; +pub const RPC_S_INVALID_AUTH_IDENTITY: ::DWORD = 1749; +pub const RPC_S_UNKNOWN_AUTHZ_SERVICE: ::DWORD = 1750; +pub const EPT_S_INVALID_ENTRY: ::DWORD = 1751; +pub const EPT_S_CANT_PERFORM_OP: ::DWORD = 1752; +pub const EPT_S_NOT_REGISTERED: ::DWORD = 1753; +pub const RPC_S_NOTHING_TO_EXPORT: ::DWORD = 1754; +pub const RPC_S_INCOMPLETE_NAME: ::DWORD = 1755; +pub const RPC_S_INVALID_VERS_OPTION: ::DWORD = 1756; +pub const RPC_S_NO_MORE_MEMBERS: ::DWORD = 1757; +pub const RPC_S_NOT_ALL_OBJS_UNEXPORTED: ::DWORD = 1758; +pub const RPC_S_INTERFACE_NOT_FOUND: ::DWORD = 1759; +pub const RPC_S_ENTRY_ALREADY_EXISTS: ::DWORD = 1760; +pub const RPC_S_ENTRY_NOT_FOUND: ::DWORD = 1761; +pub const RPC_S_NAME_SERVICE_UNAVAILABLE: ::DWORD = 1762; +pub const RPC_S_INVALID_NAF_ID: ::DWORD = 1763; +pub const RPC_S_CANNOT_SUPPORT: ::DWORD = 1764; +pub const RPC_S_NO_CONTEXT_AVAILABLE: ::DWORD = 1765; +pub const RPC_S_INTERNAL_ERROR: ::DWORD = 1766; +pub const RPC_S_ZERO_DIVIDE: ::DWORD = 1767; +pub const RPC_S_ADDRESS_ERROR: ::DWORD = 1768; +pub const RPC_S_FP_DIV_ZERO: ::DWORD = 1769; +pub const RPC_S_FP_UNDERFLOW: ::DWORD = 1770; +pub const RPC_S_FP_OVERFLOW: ::DWORD = 1771; +pub const RPC_X_NO_MORE_ENTRIES: ::DWORD = 1772; +pub const RPC_X_SS_CHAR_TRANS_OPEN_FAIL: ::DWORD = 1773; +pub const RPC_X_SS_CHAR_TRANS_SHORT_FILE: ::DWORD = 1774; +pub const RPC_X_SS_IN_NULL_CONTEXT: ::DWORD = 1775; +pub const RPC_X_SS_CONTEXT_DAMAGED: ::DWORD = 1777; +pub const RPC_X_SS_HANDLES_MISMATCH: ::DWORD = 1778; +pub const RPC_X_SS_CANNOT_GET_CALL_HANDLE: ::DWORD = 1779; +pub const RPC_X_NULL_REF_POINTER: ::DWORD = 1780; +pub const RPC_X_ENUM_VALUE_OUT_OF_RANGE: ::DWORD = 1781; +pub const RPC_X_BYTE_COUNT_TOO_SMALL: ::DWORD = 1782; +pub const RPC_X_BAD_STUB_DATA: ::DWORD = 1783; +pub const ERROR_INVALID_USER_BUFFER: ::DWORD = 1784; +pub const ERROR_UNRECOGNIZED_MEDIA: ::DWORD = 1785; +pub const ERROR_NO_TRUST_LSA_SECRET: ::DWORD = 1786; +pub const ERROR_NO_TRUST_SAM_ACCOUNT: ::DWORD = 1787; +pub const ERROR_TRUSTED_DOMAIN_FAILURE: ::DWORD = 1788; +pub const ERROR_TRUSTED_RELATIONSHIP_FAILURE: ::DWORD = 1789; +pub const ERROR_TRUST_FAILURE: ::DWORD = 1790; +pub const RPC_S_CALL_IN_PROGRESS: ::DWORD = 1791; +pub const ERROR_NETLOGON_NOT_STARTED: ::DWORD = 1792; +pub const ERROR_ACCOUNT_EXPIRED: ::DWORD = 1793; +pub const ERROR_REDIRECTOR_HAS_OPEN_HANDLES: ::DWORD = 1794; +pub const ERROR_PRINTER_DRIVER_ALREADY_INSTALLED: ::DWORD = 1795; +pub const ERROR_UNKNOWN_PORT: ::DWORD = 1796; +pub const ERROR_UNKNOWN_PRINTER_DRIVER: ::DWORD = 1797; +pub const ERROR_UNKNOWN_PRINTPROCESSOR: ::DWORD = 1798; +pub const ERROR_INVALID_SEPARATOR_FILE: ::DWORD = 1799; +pub const ERROR_INVALID_PRIORITY: ::DWORD = 1800; +pub const ERROR_INVALID_PRINTER_NAME: ::DWORD = 1801; +pub const ERROR_PRINTER_ALREADY_EXISTS: ::DWORD = 1802; +pub const ERROR_INVALID_PRINTER_COMMAND: ::DWORD = 1803; +pub const ERROR_INVALID_DATATYPE: ::DWORD = 1804; +pub const ERROR_INVALID_ENVIRONMENT: ::DWORD = 1805; +pub const RPC_S_NO_MORE_BINDINGS: ::DWORD = 1806; +pub const ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: ::DWORD = 1807; +pub const ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT: ::DWORD = 1808; +pub const ERROR_NOLOGON_SERVER_TRUST_ACCOUNT: ::DWORD = 1809; +pub const ERROR_DOMAIN_TRUST_INCONSISTENT: ::DWORD = 1810; +pub const ERROR_SERVER_HAS_OPEN_HANDLES: ::DWORD = 1811; +pub const ERROR_RESOURCE_DATA_NOT_FOUND: ::DWORD = 1812; +pub const ERROR_RESOURCE_TYPE_NOT_FOUND: ::DWORD = 1813; +pub const ERROR_RESOURCE_NAME_NOT_FOUND: ::DWORD = 1814; +pub const ERROR_RESOURCE_LANG_NOT_FOUND: ::DWORD = 1815; +pub const ERROR_NOT_ENOUGH_QUOTA: ::DWORD = 1816; +pub const RPC_S_NO_INTERFACES: ::DWORD = 1817; +pub const RPC_S_CALL_CANCELLED: ::DWORD = 1818; +pub const RPC_S_BINDING_INCOMPLETE: ::DWORD = 1819; +pub const RPC_S_COMM_FAILURE: ::DWORD = 1820; +pub const RPC_S_UNSUPPORTED_AUTHN_LEVEL: ::DWORD = 1821; +pub const RPC_S_NO_PRINC_NAME: ::DWORD = 1822; +pub const RPC_S_NOT_RPC_ERROR: ::DWORD = 1823; +pub const RPC_S_UUID_LOCAL_ONLY: ::DWORD = 1824; +pub const RPC_S_SEC_PKG_ERROR: ::DWORD = 1825; +pub const RPC_S_NOT_CANCELLED: ::DWORD = 1826; +pub const RPC_X_INVALID_ES_ACTION: ::DWORD = 1827; +pub const RPC_X_WRONG_ES_VERSION: ::DWORD = 1828; +pub const RPC_X_WRONG_STUB_VERSION: ::DWORD = 1829; +pub const RPC_X_INVALID_PIPE_OBJECT: ::DWORD = 1830; +pub const RPC_X_WRONG_PIPE_ORDER: ::DWORD = 1831; +pub const RPC_X_WRONG_PIPE_VERSION: ::DWORD = 1832; +pub const RPC_S_COOKIE_AUTH_FAILED: ::DWORD = 1833; +pub const RPC_S_GROUP_MEMBER_NOT_FOUND: ::DWORD = 1898; +pub const EPT_S_CANT_CREATE: ::DWORD = 1899; +pub const RPC_S_INVALID_OBJECT: ::DWORD = 1900; +pub const ERROR_INVALID_TIME: ::DWORD = 1901; +pub const ERROR_INVALID_FORM_NAME: ::DWORD = 1902; +pub const ERROR_INVALID_FORM_SIZE: ::DWORD = 1903; +pub const ERROR_ALREADY_WAITING: ::DWORD = 1904; +pub const ERROR_PRINTER_DELETED: ::DWORD = 1905; +pub const ERROR_INVALID_PRINTER_STATE: ::DWORD = 1906; +pub const ERROR_PASSWORD_MUST_CHANGE: ::DWORD = 1907; +pub const ERROR_DOMAIN_CONTROLLER_NOT_FOUND: ::DWORD = 1908; +pub const ERROR_ACCOUNT_LOCKED_OUT: ::DWORD = 1909; +pub const OR_INVALID_OXID: ::DWORD = 1910; +pub const OR_INVALID_OID: ::DWORD = 1911; +pub const OR_INVALID_SET: ::DWORD = 1912; +pub const RPC_S_SEND_INCOMPLETE: ::DWORD = 1913; +pub const RPC_S_INVALID_ASYNC_HANDLE: ::DWORD = 1914; +pub const RPC_S_INVALID_ASYNC_CALL: ::DWORD = 1915; +pub const RPC_X_PIPE_CLOSED: ::DWORD = 1916; +pub const RPC_X_PIPE_DISCIPLINE_ERROR: ::DWORD = 1917; +pub const RPC_X_PIPE_EMPTY: ::DWORD = 1918; +pub const ERROR_NO_SITENAME: ::DWORD = 1919; +pub const ERROR_CANT_ACCESS_FILE: ::DWORD = 1920; +pub const ERROR_CANT_RESOLVE_FILENAME: ::DWORD = 1921; +pub const RPC_S_ENTRY_TYPE_MISMATCH: ::DWORD = 1922; +pub const RPC_S_NOT_ALL_OBJS_EXPORTED: ::DWORD = 1923; +pub const RPC_S_INTERFACE_NOT_EXPORTED: ::DWORD = 1924; +pub const RPC_S_PROFILE_NOT_ADDED: ::DWORD = 1925; +pub const RPC_S_PRF_ELT_NOT_ADDED: ::DWORD = 1926; +pub const RPC_S_PRF_ELT_NOT_REMOVED: ::DWORD = 1927; +pub const RPC_S_GRP_ELT_NOT_ADDED: ::DWORD = 1928; +pub const RPC_S_GRP_ELT_NOT_REMOVED: ::DWORD = 1929; +pub const ERROR_KM_DRIVER_BLOCKED: ::DWORD = 1930; +pub const ERROR_CONTEXT_EXPIRED: ::DWORD = 1931; +pub const ERROR_PER_USER_TRUST_QUOTA_EXCEEDED: ::DWORD = 1932; +pub const ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED: ::DWORD = 1933; +pub const ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED: ::DWORD = 1934; +pub const ERROR_AUTHENTICATION_FIREWALL_FAILED: ::DWORD = 1935; +pub const ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED: ::DWORD = 1936; +pub const ERROR_NTLM_BLOCKED: ::DWORD = 1937; +pub const ERROR_PASSWORD_CHANGE_REQUIRED: ::DWORD = 1938; +pub const ERROR_INVALID_PIXEL_FORMAT: ::DWORD = 2000; +pub const ERROR_BAD_DRIVER: ::DWORD = 2001; +pub const ERROR_INVALID_WINDOW_STYLE: ::DWORD = 2002; +pub const ERROR_METAFILE_NOT_SUPPORTED: ::DWORD = 2003; +pub const ERROR_TRANSFORM_NOT_SUPPORTED: ::DWORD = 2004; +pub const ERROR_CLIPPING_NOT_SUPPORTED: ::DWORD = 2005; +pub const ERROR_INVALID_CMM: ::DWORD = 2010; +pub const ERROR_INVALID_PROFILE: ::DWORD = 2011; +pub const ERROR_TAG_NOT_FOUND: ::DWORD = 2012; +pub const ERROR_TAG_NOT_PRESENT: ::DWORD = 2013; +pub const ERROR_DUPLICATE_TAG: ::DWORD = 2014; +pub const ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE: ::DWORD = 2015; +pub const ERROR_PROFILE_NOT_FOUND: ::DWORD = 2016; +pub const ERROR_INVALID_COLORSPACE: ::DWORD = 2017; +pub const ERROR_ICM_NOT_ENABLED: ::DWORD = 2018; +pub const ERROR_DELETING_ICM_XFORM: ::DWORD = 2019; +pub const ERROR_INVALID_TRANSFORM: ::DWORD = 2020; +pub const ERROR_COLORSPACE_MISMATCH: ::DWORD = 2021; +pub const ERROR_INVALID_COLORINDEX: ::DWORD = 2022; +pub const ERROR_PROFILE_DOES_NOT_MATCH_DEVICE: ::DWORD = 2023; +pub const ERROR_CONNECTED_OTHER_PASSWORD: ::DWORD = 2108; +pub const ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT: ::DWORD = 2109; +pub const ERROR_BAD_USERNAME: ::DWORD = 2202; +pub const ERROR_NOT_CONNECTED: ::DWORD = 2250; +pub const ERROR_OPEN_FILES: ::DWORD = 2401; +pub const ERROR_ACTIVE_CONNECTIONS: ::DWORD = 2402; +pub const ERROR_DEVICE_IN_USE: ::DWORD = 2404; +pub const ERROR_UNKNOWN_PRINT_MONITOR: ::DWORD = 3000; +pub const ERROR_PRINTER_DRIVER_IN_USE: ::DWORD = 3001; +pub const ERROR_SPOOL_FILE_NOT_FOUND: ::DWORD = 3002; +pub const ERROR_SPL_NO_STARTDOC: ::DWORD = 3003; +pub const ERROR_SPL_NO_ADDJOB: ::DWORD = 3004; +pub const ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED: ::DWORD = 3005; +pub const ERROR_PRINT_MONITOR_ALREADY_INSTALLED: ::DWORD = 3006; +pub const ERROR_INVALID_PRINT_MONITOR: ::DWORD = 3007; +pub const ERROR_PRINT_MONITOR_IN_USE: ::DWORD = 3008; +pub const ERROR_PRINTER_HAS_JOBS_QUEUED: ::DWORD = 3009; +pub const ERROR_SUCCESS_REBOOT_REQUIRED: ::DWORD = 3010; +pub const ERROR_SUCCESS_RESTART_REQUIRED: ::DWORD = 3011; +pub const ERROR_PRINTER_NOT_FOUND: ::DWORD = 3012; +pub const ERROR_PRINTER_DRIVER_WARNED: ::DWORD = 3013; +pub const ERROR_PRINTER_DRIVER_BLOCKED: ::DWORD = 3014; +pub const ERROR_PRINTER_DRIVER_PACKAGE_IN_USE: ::DWORD = 3015; +pub const ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND: ::DWORD = 3016; +pub const ERROR_FAIL_REBOOT_REQUIRED: ::DWORD = 3017; +pub const ERROR_FAIL_REBOOT_INITIATED: ::DWORD = 3018; +pub const ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED: ::DWORD = 3019; +pub const ERROR_PRINT_JOB_RESTART_REQUIRED: ::DWORD = 3020; +pub const ERROR_INVALID_PRINTER_DRIVER_MANIFEST: ::DWORD = 3021; +pub const ERROR_PRINTER_NOT_SHAREABLE: ::DWORD = 3022; +pub const ERROR_REQUEST_PAUSED: ::DWORD = 3050; +pub const ERROR_IO_REISSUE_AS_CACHED: ::DWORD = 3950; +pub const ERROR_WINS_INTERNAL: ::DWORD = 4000; +pub const ERROR_CAN_NOT_DEL_LOCAL_WINS: ::DWORD = 4001; +pub const ERROR_STATIC_INIT: ::DWORD = 4002; +pub const ERROR_INC_BACKUP: ::DWORD = 4003; +pub const ERROR_FULL_BACKUP: ::DWORD = 4004; +pub const ERROR_REC_NON_EXISTENT: ::DWORD = 4005; +pub const ERROR_RPL_NOT_ALLOWED: ::DWORD = 4006; +pub const PEERDIST_ERROR_CONTENTINFO_VERSION_UNSUPPORTED: ::DWORD = 4050; +pub const PEERDIST_ERROR_CANNOT_PARSE_CONTENTINFO: ::DWORD = 4051; +pub const PEERDIST_ERROR_MISSING_DATA: ::DWORD = 4052; +pub const PEERDIST_ERROR_NO_MORE: ::DWORD = 4053; +pub const PEERDIST_ERROR_NOT_INITIALIZED: ::DWORD = 4054; +pub const PEERDIST_ERROR_ALREADY_INITIALIZED: ::DWORD = 4055; +pub const PEERDIST_ERROR_SHUTDOWN_IN_PROGRESS: ::DWORD = 4056; +pub const PEERDIST_ERROR_INVALIDATED: ::DWORD = 4057; +pub const PEERDIST_ERROR_ALREADY_EXISTS: ::DWORD = 4058; +pub const PEERDIST_ERROR_OPERATION_NOTFOUND: ::DWORD = 4059; +pub const PEERDIST_ERROR_ALREADY_COMPLETED: ::DWORD = 4060; +pub const PEERDIST_ERROR_OUT_OF_BOUNDS: ::DWORD = 4061; +pub const PEERDIST_ERROR_VERSION_UNSUPPORTED: ::DWORD = 4062; +pub const PEERDIST_ERROR_INVALID_CONFIGURATION: ::DWORD = 4063; +pub const PEERDIST_ERROR_NOT_LICENSED: ::DWORD = 4064; +pub const PEERDIST_ERROR_SERVICE_UNAVAILABLE: ::DWORD = 4065; +pub const PEERDIST_ERROR_TRUST_FAILURE: ::DWORD = 4066; +pub const ERROR_DHCP_ADDRESS_CONFLICT: ::DWORD = 4100; +pub const ERROR_WMI_GUID_NOT_FOUND: ::DWORD = 4200; +pub const ERROR_WMI_INSTANCE_NOT_FOUND: ::DWORD = 4201; +pub const ERROR_WMI_ITEMID_NOT_FOUND: ::DWORD = 4202; +pub const ERROR_WMI_TRY_AGAIN: ::DWORD = 4203; +pub const ERROR_WMI_DP_NOT_FOUND: ::DWORD = 4204; +pub const ERROR_WMI_UNRESOLVED_INSTANCE_REF: ::DWORD = 4205; +pub const ERROR_WMI_ALREADY_ENABLED: ::DWORD = 4206; +pub const ERROR_WMI_GUID_DISCONNECTED: ::DWORD = 4207; +pub const ERROR_WMI_SERVER_UNAVAILABLE: ::DWORD = 4208; +pub const ERROR_WMI_DP_FAILED: ::DWORD = 4209; +pub const ERROR_WMI_INVALID_MOF: ::DWORD = 4210; +pub const ERROR_WMI_INVALID_REGINFO: ::DWORD = 4211; +pub const ERROR_WMI_ALREADY_DISABLED: ::DWORD = 4212; +pub const ERROR_WMI_READ_ONLY: ::DWORD = 4213; +pub const ERROR_WMI_SET_FAILURE: ::DWORD = 4214; +pub const ERROR_NOT_APPCONTAINER: ::DWORD = 4250; +pub const ERROR_APPCONTAINER_REQUIRED: ::DWORD = 4251; +pub const ERROR_NOT_SUPPORTED_IN_APPCONTAINER: ::DWORD = 4252; +pub const ERROR_INVALID_PACKAGE_SID_LENGTH: ::DWORD = 4253; +pub const ERROR_INVALID_MEDIA: ::DWORD = 4300; +pub const ERROR_INVALID_LIBRARY: ::DWORD = 4301; +pub const ERROR_INVALID_MEDIA_POOL: ::DWORD = 4302; +pub const ERROR_DRIVE_MEDIA_MISMATCH: ::DWORD = 4303; +pub const ERROR_MEDIA_OFFLINE: ::DWORD = 4304; +pub const ERROR_LIBRARY_OFFLINE: ::DWORD = 4305; +pub const ERROR_EMPTY: ::DWORD = 4306; +pub const ERROR_NOT_EMPTY: ::DWORD = 4307; +pub const ERROR_MEDIA_UNAVAILABLE: ::DWORD = 4308; +pub const ERROR_RESOURCE_DISABLED: ::DWORD = 4309; +pub const ERROR_INVALID_CLEANER: ::DWORD = 4310; +pub const ERROR_UNABLE_TO_CLEAN: ::DWORD = 4311; +pub const ERROR_OBJECT_NOT_FOUND: ::DWORD = 4312; +pub const ERROR_DATABASE_FAILURE: ::DWORD = 4313; +pub const ERROR_DATABASE_FULL: ::DWORD = 4314; +pub const ERROR_MEDIA_INCOMPATIBLE: ::DWORD = 4315; +pub const ERROR_RESOURCE_NOT_PRESENT: ::DWORD = 4316; +pub const ERROR_INVALID_OPERATION: ::DWORD = 4317; +pub const ERROR_MEDIA_NOT_AVAILABLE: ::DWORD = 4318; +pub const ERROR_DEVICE_NOT_AVAILABLE: ::DWORD = 4319; +pub const ERROR_REQUEST_REFUSED: ::DWORD = 4320; +pub const ERROR_INVALID_DRIVE_OBJECT: ::DWORD = 4321; +pub const ERROR_LIBRARY_FULL: ::DWORD = 4322; +pub const ERROR_MEDIUM_NOT_ACCESSIBLE: ::DWORD = 4323; +pub const ERROR_UNABLE_TO_LOAD_MEDIUM: ::DWORD = 4324; +pub const ERROR_UNABLE_TO_INVENTORY_DRIVE: ::DWORD = 4325; +pub const ERROR_UNABLE_TO_INVENTORY_SLOT: ::DWORD = 4326; +pub const ERROR_UNABLE_TO_INVENTORY_TRANSPORT: ::DWORD = 4327; +pub const ERROR_TRANSPORT_FULL: ::DWORD = 4328; +pub const ERROR_CONTROLLING_IEPORT: ::DWORD = 4329; +pub const ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA: ::DWORD = 4330; +pub const ERROR_CLEANER_SLOT_SET: ::DWORD = 4331; +pub const ERROR_CLEANER_SLOT_NOT_SET: ::DWORD = 4332; +pub const ERROR_CLEANER_CARTRIDGE_SPENT: ::DWORD = 4333; +pub const ERROR_UNEXPECTED_OMID: ::DWORD = 4334; +pub const ERROR_CANT_DELETE_LAST_ITEM: ::DWORD = 4335; +pub const ERROR_MESSAGE_EXCEEDS_MAX_SIZE: ::DWORD = 4336; +pub const ERROR_VOLUME_CONTAINS_SYS_FILES: ::DWORD = 4337; +pub const ERROR_INDIGENOUS_TYPE: ::DWORD = 4338; +pub const ERROR_NO_SUPPORTING_DRIVES: ::DWORD = 4339; +pub const ERROR_CLEANER_CARTRIDGE_INSTALLED: ::DWORD = 4340; +pub const ERROR_IEPORT_FULL: ::DWORD = 4341; +pub const ERROR_FILE_OFFLINE: ::DWORD = 4350; +pub const ERROR_REMOTE_STORAGE_NOT_ACTIVE: ::DWORD = 4351; +pub const ERROR_REMOTE_STORAGE_MEDIA_ERROR: ::DWORD = 4352; +pub const ERROR_NOT_A_REPARSE_POINT: ::DWORD = 4390; +pub const ERROR_REPARSE_ATTRIBUTE_CONFLICT: ::DWORD = 4391; +pub const ERROR_INVALID_REPARSE_DATA: ::DWORD = 4392; +pub const ERROR_REPARSE_TAG_INVALID: ::DWORD = 4393; +pub const ERROR_REPARSE_TAG_MISMATCH: ::DWORD = 4394; +pub const ERROR_APP_DATA_NOT_FOUND: ::DWORD = 4400; +pub const ERROR_APP_DATA_EXPIRED: ::DWORD = 4401; +pub const ERROR_APP_DATA_CORRUPT: ::DWORD = 4402; +pub const ERROR_APP_DATA_LIMIT_EXCEEDED: ::DWORD = 4403; +pub const ERROR_APP_DATA_REBOOT_REQUIRED: ::DWORD = 4404; +pub const ERROR_SECUREBOOT_ROLLBACK_DETECTED: ::DWORD = 4420; +pub const ERROR_SECUREBOOT_POLICY_VIOLATION: ::DWORD = 4421; +pub const ERROR_SECUREBOOT_INVALID_POLICY: ::DWORD = 4422; +pub const ERROR_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: ::DWORD = 4423; +pub const ERROR_SECUREBOOT_POLICY_NOT_SIGNED: ::DWORD = 4424; +pub const ERROR_SECUREBOOT_NOT_ENABLED: ::DWORD = 4425; +pub const ERROR_SECUREBOOT_FILE_REPLACED: ::DWORD = 4426; +pub const ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED: ::DWORD = 4440; +pub const ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: ::DWORD = 4441; +pub const ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED: ::DWORD = 4442; +pub const ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: ::DWORD = 4443; +pub const ERROR_VOLUME_NOT_SIS_ENABLED: ::DWORD = 4500; +pub const ERROR_DEPENDENT_RESOURCE_EXISTS: ::DWORD = 5001; +pub const ERROR_DEPENDENCY_NOT_FOUND: ::DWORD = 5002; +pub const ERROR_DEPENDENCY_ALREADY_EXISTS: ::DWORD = 5003; +pub const ERROR_RESOURCE_NOT_ONLINE: ::DWORD = 5004; +pub const ERROR_HOST_NODE_NOT_AVAILABLE: ::DWORD = 5005; +pub const ERROR_RESOURCE_NOT_AVAILABLE: ::DWORD = 5006; +pub const ERROR_RESOURCE_NOT_FOUND: ::DWORD = 5007; +pub const ERROR_SHUTDOWN_CLUSTER: ::DWORD = 5008; +pub const ERROR_CANT_EVICT_ACTIVE_NODE: ::DWORD = 5009; +pub const ERROR_OBJECT_ALREADY_EXISTS: ::DWORD = 5010; +pub const ERROR_OBJECT_IN_LIST: ::DWORD = 5011; +pub const ERROR_GROUP_NOT_AVAILABLE: ::DWORD = 5012; +pub const ERROR_GROUP_NOT_FOUND: ::DWORD = 5013; +pub const ERROR_GROUP_NOT_ONLINE: ::DWORD = 5014; +pub const ERROR_HOST_NODE_NOT_RESOURCE_OWNER: ::DWORD = 5015; +pub const ERROR_HOST_NODE_NOT_GROUP_OWNER: ::DWORD = 5016; +pub const ERROR_RESMON_CREATE_FAILED: ::DWORD = 5017; +pub const ERROR_RESMON_ONLINE_FAILED: ::DWORD = 5018; +pub const ERROR_RESOURCE_ONLINE: ::DWORD = 5019; +pub const ERROR_QUORUM_RESOURCE: ::DWORD = 5020; +pub const ERROR_NOT_QUORUM_CAPABLE: ::DWORD = 5021; +pub const ERROR_CLUSTER_SHUTTING_DOWN: ::DWORD = 5022; +pub const ERROR_INVALID_STATE: ::DWORD = 5023; +pub const ERROR_RESOURCE_PROPERTIES_STORED: ::DWORD = 5024; +pub const ERROR_NOT_QUORUM_CLASS: ::DWORD = 5025; +pub const ERROR_CORE_RESOURCE: ::DWORD = 5026; +pub const ERROR_QUORUM_RESOURCE_ONLINE_FAILED: ::DWORD = 5027; +pub const ERROR_QUORUMLOG_OPEN_FAILED: ::DWORD = 5028; +pub const ERROR_CLUSTERLOG_CORRUPT: ::DWORD = 5029; +pub const ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE: ::DWORD = 5030; +pub const ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE: ::DWORD = 5031; +pub const ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND: ::DWORD = 5032; +pub const ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE: ::DWORD = 5033; +pub const ERROR_QUORUM_OWNER_ALIVE: ::DWORD = 5034; +pub const ERROR_NETWORK_NOT_AVAILABLE: ::DWORD = 5035; +pub const ERROR_NODE_NOT_AVAILABLE: ::DWORD = 5036; +pub const ERROR_ALL_NODES_NOT_AVAILABLE: ::DWORD = 5037; +pub const ERROR_RESOURCE_FAILED: ::DWORD = 5038; +pub const ERROR_CLUSTER_INVALID_NODE: ::DWORD = 5039; +pub const ERROR_CLUSTER_NODE_EXISTS: ::DWORD = 5040; +pub const ERROR_CLUSTER_JOIN_IN_PROGRESS: ::DWORD = 5041; +pub const ERROR_CLUSTER_NODE_NOT_FOUND: ::DWORD = 5042; +pub const ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND: ::DWORD = 5043; +pub const ERROR_CLUSTER_NETWORK_EXISTS: ::DWORD = 5044; +pub const ERROR_CLUSTER_NETWORK_NOT_FOUND: ::DWORD = 5045; +pub const ERROR_CLUSTER_NETINTERFACE_EXISTS: ::DWORD = 5046; +pub const ERROR_CLUSTER_NETINTERFACE_NOT_FOUND: ::DWORD = 5047; +pub const ERROR_CLUSTER_INVALID_REQUEST: ::DWORD = 5048; +pub const ERROR_CLUSTER_INVALID_NETWORK_PROVIDER: ::DWORD = 5049; +pub const ERROR_CLUSTER_NODE_DOWN: ::DWORD = 5050; +pub const ERROR_CLUSTER_NODE_UNREACHABLE: ::DWORD = 5051; +pub const ERROR_CLUSTER_NODE_NOT_MEMBER: ::DWORD = 5052; +pub const ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS: ::DWORD = 5053; +pub const ERROR_CLUSTER_INVALID_NETWORK: ::DWORD = 5054; +pub const ERROR_CLUSTER_NODE_UP: ::DWORD = 5056; +pub const ERROR_CLUSTER_IPADDR_IN_USE: ::DWORD = 5057; +pub const ERROR_CLUSTER_NODE_NOT_PAUSED: ::DWORD = 5058; +pub const ERROR_CLUSTER_NO_SECURITY_CONTEXT: ::DWORD = 5059; +pub const ERROR_CLUSTER_NETWORK_NOT_INTERNAL: ::DWORD = 5060; +pub const ERROR_CLUSTER_NODE_ALREADY_UP: ::DWORD = 5061; +pub const ERROR_CLUSTER_NODE_ALREADY_DOWN: ::DWORD = 5062; +pub const ERROR_CLUSTER_NETWORK_ALREADY_ONLINE: ::DWORD = 5063; +pub const ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE: ::DWORD = 5064; +pub const ERROR_CLUSTER_NODE_ALREADY_MEMBER: ::DWORD = 5065; +pub const ERROR_CLUSTER_LAST_INTERNAL_NETWORK: ::DWORD = 5066; +pub const ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS: ::DWORD = 5067; +pub const ERROR_INVALID_OPERATION_ON_QUORUM: ::DWORD = 5068; +pub const ERROR_DEPENDENCY_NOT_ALLOWED: ::DWORD = 5069; +pub const ERROR_CLUSTER_NODE_PAUSED: ::DWORD = 5070; +pub const ERROR_NODE_CANT_HOST_RESOURCE: ::DWORD = 5071; +pub const ERROR_CLUSTER_NODE_NOT_READY: ::DWORD = 5072; +pub const ERROR_CLUSTER_NODE_SHUTTING_DOWN: ::DWORD = 5073; +pub const ERROR_CLUSTER_JOIN_ABORTED: ::DWORD = 5074; +pub const ERROR_CLUSTER_INCOMPATIBLE_VERSIONS: ::DWORD = 5075; +pub const ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED: ::DWORD = 5076; +pub const ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED: ::DWORD = 5077; +pub const ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND: ::DWORD = 5078; +pub const ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED: ::DWORD = 5079; +pub const ERROR_CLUSTER_RESNAME_NOT_FOUND: ::DWORD = 5080; +pub const ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED: ::DWORD = 5081; +pub const ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST: ::DWORD = 5082; +pub const ERROR_CLUSTER_DATABASE_SEQMISMATCH: ::DWORD = 5083; +pub const ERROR_RESMON_INVALID_STATE: ::DWORD = 5084; +pub const ERROR_CLUSTER_GUM_NOT_LOCKER: ::DWORD = 5085; +pub const ERROR_QUORUM_DISK_NOT_FOUND: ::DWORD = 5086; +pub const ERROR_DATABASE_BACKUP_CORRUPT: ::DWORD = 5087; +pub const ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT: ::DWORD = 5088; +pub const ERROR_RESOURCE_PROPERTY_UNCHANGEABLE: ::DWORD = 5089; +pub const ERROR_NO_ADMIN_ACCESS_POINT: ::DWORD = 5090; +pub const ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE: ::DWORD = 5890; +pub const ERROR_CLUSTER_QUORUMLOG_NOT_FOUND: ::DWORD = 5891; +pub const ERROR_CLUSTER_MEMBERSHIP_HALT: ::DWORD = 5892; +pub const ERROR_CLUSTER_INSTANCE_ID_MISMATCH: ::DWORD = 5893; +pub const ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP: ::DWORD = 5894; +pub const ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH: ::DWORD = 5895; +pub const ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP: ::DWORD = 5896; +pub const ERROR_CLUSTER_PARAMETER_MISMATCH: ::DWORD = 5897; +pub const ERROR_NODE_CANNOT_BE_CLUSTERED: ::DWORD = 5898; +pub const ERROR_CLUSTER_WRONG_OS_VERSION: ::DWORD = 5899; +pub const ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME: ::DWORD = 5900; +pub const ERROR_CLUSCFG_ALREADY_COMMITTED: ::DWORD = 5901; +pub const ERROR_CLUSCFG_ROLLBACK_FAILED: ::DWORD = 5902; +pub const ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT: ::DWORD = 5903; +pub const ERROR_CLUSTER_OLD_VERSION: ::DWORD = 5904; +pub const ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME: ::DWORD = 5905; +pub const ERROR_CLUSTER_NO_NET_ADAPTERS: ::DWORD = 5906; +pub const ERROR_CLUSTER_POISONED: ::DWORD = 5907; +pub const ERROR_CLUSTER_GROUP_MOVING: ::DWORD = 5908; +pub const ERROR_CLUSTER_RESOURCE_TYPE_BUSY: ::DWORD = 5909; +pub const ERROR_RESOURCE_CALL_TIMED_OUT: ::DWORD = 5910; +pub const ERROR_INVALID_CLUSTER_IPV6_ADDRESS: ::DWORD = 5911; +pub const ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION: ::DWORD = 5912; +pub const ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS: ::DWORD = 5913; +pub const ERROR_CLUSTER_PARTIAL_SEND: ::DWORD = 5914; +pub const ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION: ::DWORD = 5915; +pub const ERROR_CLUSTER_INVALID_STRING_TERMINATION: ::DWORD = 5916; +pub const ERROR_CLUSTER_INVALID_STRING_FORMAT: ::DWORD = 5917; +pub const ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS: ::DWORD = 5918; +pub const ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS: ::DWORD = 5919; +pub const ERROR_CLUSTER_NULL_DATA: ::DWORD = 5920; +pub const ERROR_CLUSTER_PARTIAL_READ: ::DWORD = 5921; +pub const ERROR_CLUSTER_PARTIAL_WRITE: ::DWORD = 5922; +pub const ERROR_CLUSTER_CANT_DESERIALIZE_DATA: ::DWORD = 5923; +pub const ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT: ::DWORD = 5924; +pub const ERROR_CLUSTER_NO_QUORUM: ::DWORD = 5925; +pub const ERROR_CLUSTER_INVALID_IPV6_NETWORK: ::DWORD = 5926; +pub const ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK: ::DWORD = 5927; +pub const ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP: ::DWORD = 5928; +pub const ERROR_DEPENDENCY_TREE_TOO_COMPLEX: ::DWORD = 5929; +pub const ERROR_EXCEPTION_IN_RESOURCE_CALL: ::DWORD = 5930; +pub const ERROR_CLUSTER_RHS_FAILED_INITIALIZATION: ::DWORD = 5931; +pub const ERROR_CLUSTER_NOT_INSTALLED: ::DWORD = 5932; +pub const ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE: ::DWORD = 5933; +pub const ERROR_CLUSTER_MAX_NODES_IN_CLUSTER: ::DWORD = 5934; +pub const ERROR_CLUSTER_TOO_MANY_NODES: ::DWORD = 5935; +pub const ERROR_CLUSTER_OBJECT_ALREADY_USED: ::DWORD = 5936; +pub const ERROR_NONCORE_GROUPS_FOUND: ::DWORD = 5937; +pub const ERROR_FILE_SHARE_RESOURCE_CONFLICT: ::DWORD = 5938; +pub const ERROR_CLUSTER_EVICT_INVALID_REQUEST: ::DWORD = 5939; +pub const ERROR_CLUSTER_SINGLETON_RESOURCE: ::DWORD = 5940; +pub const ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE: ::DWORD = 5941; +pub const ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED: ::DWORD = 5942; +pub const ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR: ::DWORD = 5943; +pub const ERROR_CLUSTER_GROUP_BUSY: ::DWORD = 5944; +pub const ERROR_CLUSTER_NOT_SHARED_VOLUME: ::DWORD = 5945; +pub const ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR: ::DWORD = 5946; +pub const ERROR_CLUSTER_SHARED_VOLUMES_IN_USE: ::DWORD = 5947; +pub const ERROR_CLUSTER_USE_SHARED_VOLUMES_API: ::DWORD = 5948; +pub const ERROR_CLUSTER_BACKUP_IN_PROGRESS: ::DWORD = 5949; +pub const ERROR_NON_CSV_PATH: ::DWORD = 5950; +pub const ERROR_CSV_VOLUME_NOT_LOCAL: ::DWORD = 5951; +pub const ERROR_CLUSTER_WATCHDOG_TERMINATING: ::DWORD = 5952; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_INCOMPATIBLE_NODES: ::DWORD = 5953; +pub const ERROR_CLUSTER_INVALID_NODE_WEIGHT: ::DWORD = 5954; +pub const ERROR_CLUSTER_RESOURCE_VETOED_CALL: ::DWORD = 5955; +pub const ERROR_RESMON_SYSTEM_RESOURCES_LACKING: ::DWORD = 5956; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_DESTINATION: ::DWORD = 5957; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_SOURCE: ::DWORD = 5958; +pub const ERROR_CLUSTER_GROUP_QUEUED: ::DWORD = 5959; +pub const ERROR_CLUSTER_RESOURCE_LOCKED_STATUS: ::DWORD = 5960; +pub const ERROR_CLUSTER_SHARED_VOLUME_FAILOVER_NOT_ALLOWED: ::DWORD = 5961; +pub const ERROR_CLUSTER_NODE_DRAIN_IN_PROGRESS: ::DWORD = 5962; +pub const ERROR_CLUSTER_DISK_NOT_CONNECTED: ::DWORD = 5963; +pub const ERROR_DISK_NOT_CSV_CAPABLE: ::DWORD = 5964; +pub const ERROR_RESOURCE_NOT_IN_AVAILABLE_STORAGE: ::DWORD = 5965; +pub const ERROR_CLUSTER_SHARED_VOLUME_REDIRECTED: ::DWORD = 5966; +pub const ERROR_CLUSTER_SHARED_VOLUME_NOT_REDIRECTED: ::DWORD = 5967; +pub const ERROR_CLUSTER_CANNOT_RETURN_PROPERTIES: ::DWORD = 5968; +pub const ERROR_CLUSTER_RESOURCE_CONTAINS_UNSUPPORTED_DIFF_AREA_FOR_SHARED_VOLUMES: ::DWORD = 5969; +pub const ERROR_CLUSTER_RESOURCE_IS_IN_MAINTENANCE_MODE: ::DWORD = 5970; +pub const ERROR_CLUSTER_AFFINITY_CONFLICT: ::DWORD = 5971; +pub const ERROR_CLUSTER_RESOURCE_IS_REPLICA_VIRTUAL_MACHINE: ::DWORD = 5972; +pub const ERROR_ENCRYPTION_FAILED: ::DWORD = 6000; +pub const ERROR_DECRYPTION_FAILED: ::DWORD = 6001; +pub const ERROR_FILE_ENCRYPTED: ::DWORD = 6002; +pub const ERROR_NO_RECOVERY_POLICY: ::DWORD = 6003; +pub const ERROR_NO_EFS: ::DWORD = 6004; +pub const ERROR_WRONG_EFS: ::DWORD = 6005; +pub const ERROR_NO_USER_KEYS: ::DWORD = 6006; +pub const ERROR_FILE_NOT_ENCRYPTED: ::DWORD = 6007; +pub const ERROR_NOT_EXPORT_FORMAT: ::DWORD = 6008; +pub const ERROR_FILE_READ_ONLY: ::DWORD = 6009; +pub const ERROR_DIR_EFS_DISALLOWED: ::DWORD = 6010; +pub const ERROR_EFS_SERVER_NOT_TRUSTED: ::DWORD = 6011; +pub const ERROR_BAD_RECOVERY_POLICY: ::DWORD = 6012; +pub const ERROR_EFS_ALG_BLOB_TOO_BIG: ::DWORD = 6013; +pub const ERROR_VOLUME_NOT_SUPPORT_EFS: ::DWORD = 6014; +pub const ERROR_EFS_DISABLED: ::DWORD = 6015; +pub const ERROR_EFS_VERSION_NOT_SUPPORT: ::DWORD = 6016; +pub const ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: ::DWORD = 6017; +pub const ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER: ::DWORD = 6018; +pub const ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: ::DWORD = 6019; +pub const ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: ::DWORD = 6020; +pub const ERROR_CS_ENCRYPTION_FILE_NOT_CSE: ::DWORD = 6021; +pub const ERROR_ENCRYPTION_POLICY_DENIES_OPERATION: ::DWORD = 6022; +pub const ERROR_NO_BROWSER_SERVERS_FOUND: ::DWORD = 6118; +pub const SCHED_E_SERVICE_NOT_LOCALSYSTEM: ::DWORD = 6200; +pub const ERROR_LOG_SECTOR_INVALID: ::DWORD = 6600; +pub const ERROR_LOG_SECTOR_PARITY_INVALID: ::DWORD = 6601; +pub const ERROR_LOG_SECTOR_REMAPPED: ::DWORD = 6602; +pub const ERROR_LOG_BLOCK_INCOMPLETE: ::DWORD = 6603; +pub const ERROR_LOG_INVALID_RANGE: ::DWORD = 6604; +pub const ERROR_LOG_BLOCKS_EXHAUSTED: ::DWORD = 6605; +pub const ERROR_LOG_READ_CONTEXT_INVALID: ::DWORD = 6606; +pub const ERROR_LOG_RESTART_INVALID: ::DWORD = 6607; +pub const ERROR_LOG_BLOCK_VERSION: ::DWORD = 6608; +pub const ERROR_LOG_BLOCK_INVALID: ::DWORD = 6609; +pub const ERROR_LOG_READ_MODE_INVALID: ::DWORD = 6610; +pub const ERROR_LOG_NO_RESTART: ::DWORD = 6611; +pub const ERROR_LOG_METADATA_CORRUPT: ::DWORD = 6612; +pub const ERROR_LOG_METADATA_INVALID: ::DWORD = 6613; +pub const ERROR_LOG_METADATA_INCONSISTENT: ::DWORD = 6614; +pub const ERROR_LOG_RESERVATION_INVALID: ::DWORD = 6615; +pub const ERROR_LOG_CANT_DELETE: ::DWORD = 6616; +pub const ERROR_LOG_CONTAINER_LIMIT_EXCEEDED: ::DWORD = 6617; +pub const ERROR_LOG_START_OF_LOG: ::DWORD = 6618; +pub const ERROR_LOG_POLICY_ALREADY_INSTALLED: ::DWORD = 6619; +pub const ERROR_LOG_POLICY_NOT_INSTALLED: ::DWORD = 6620; +pub const ERROR_LOG_POLICY_INVALID: ::DWORD = 6621; +pub const ERROR_LOG_POLICY_CONFLICT: ::DWORD = 6622; +pub const ERROR_LOG_PINNED_ARCHIVE_TAIL: ::DWORD = 6623; +pub const ERROR_LOG_RECORD_NONEXISTENT: ::DWORD = 6624; +pub const ERROR_LOG_RECORDS_RESERVED_INVALID: ::DWORD = 6625; +pub const ERROR_LOG_SPACE_RESERVED_INVALID: ::DWORD = 6626; +pub const ERROR_LOG_TAIL_INVALID: ::DWORD = 6627; +pub const ERROR_LOG_FULL: ::DWORD = 6628; +pub const ERROR_COULD_NOT_RESIZE_LOG: ::DWORD = 6629; +pub const ERROR_LOG_MULTIPLEXED: ::DWORD = 6630; +pub const ERROR_LOG_DEDICATED: ::DWORD = 6631; +pub const ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS: ::DWORD = 6632; +pub const ERROR_LOG_ARCHIVE_IN_PROGRESS: ::DWORD = 6633; +pub const ERROR_LOG_EPHEMERAL: ::DWORD = 6634; +pub const ERROR_LOG_NOT_ENOUGH_CONTAINERS: ::DWORD = 6635; +pub const ERROR_LOG_CLIENT_ALREADY_REGISTERED: ::DWORD = 6636; +pub const ERROR_LOG_CLIENT_NOT_REGISTERED: ::DWORD = 6637; +pub const ERROR_LOG_FULL_HANDLER_IN_PROGRESS: ::DWORD = 6638; +pub const ERROR_LOG_CONTAINER_READ_FAILED: ::DWORD = 6639; +pub const ERROR_LOG_CONTAINER_WRITE_FAILED: ::DWORD = 6640; +pub const ERROR_LOG_CONTAINER_OPEN_FAILED: ::DWORD = 6641; +pub const ERROR_LOG_CONTAINER_STATE_INVALID: ::DWORD = 6642; +pub const ERROR_LOG_STATE_INVALID: ::DWORD = 6643; +pub const ERROR_LOG_PINNED: ::DWORD = 6644; +pub const ERROR_LOG_METADATA_FLUSH_FAILED: ::DWORD = 6645; +pub const ERROR_LOG_INCONSISTENT_SECURITY: ::DWORD = 6646; +pub const ERROR_LOG_APPENDED_FLUSH_FAILED: ::DWORD = 6647; +pub const ERROR_LOG_PINNED_RESERVATION: ::DWORD = 6648; +pub const ERROR_INVALID_TRANSACTION: ::DWORD = 6700; +pub const ERROR_TRANSACTION_NOT_ACTIVE: ::DWORD = 6701; +pub const ERROR_TRANSACTION_REQUEST_NOT_VALID: ::DWORD = 6702; +pub const ERROR_TRANSACTION_NOT_REQUESTED: ::DWORD = 6703; +pub const ERROR_TRANSACTION_ALREADY_ABORTED: ::DWORD = 6704; +pub const ERROR_TRANSACTION_ALREADY_COMMITTED: ::DWORD = 6705; +pub const ERROR_TM_INITIALIZATION_FAILED: ::DWORD = 6706; +pub const ERROR_RESOURCEMANAGER_READ_ONLY: ::DWORD = 6707; +pub const ERROR_TRANSACTION_NOT_JOINED: ::DWORD = 6708; +pub const ERROR_TRANSACTION_SUPERIOR_EXISTS: ::DWORD = 6709; +pub const ERROR_CRM_PROTOCOL_ALREADY_EXISTS: ::DWORD = 6710; +pub const ERROR_TRANSACTION_PROPAGATION_FAILED: ::DWORD = 6711; +pub const ERROR_CRM_PROTOCOL_NOT_FOUND: ::DWORD = 6712; +pub const ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER: ::DWORD = 6713; +pub const ERROR_CURRENT_TRANSACTION_NOT_VALID: ::DWORD = 6714; +pub const ERROR_TRANSACTION_NOT_FOUND: ::DWORD = 6715; +pub const ERROR_RESOURCEMANAGER_NOT_FOUND: ::DWORD = 6716; +pub const ERROR_ENLISTMENT_NOT_FOUND: ::DWORD = 6717; +pub const ERROR_TRANSACTIONMANAGER_NOT_FOUND: ::DWORD = 6718; +pub const ERROR_TRANSACTIONMANAGER_NOT_ONLINE: ::DWORD = 6719; +pub const ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: ::DWORD = 6720; +pub const ERROR_TRANSACTION_NOT_ROOT: ::DWORD = 6721; +pub const ERROR_TRANSACTION_OBJECT_EXPIRED: ::DWORD = 6722; +pub const ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED: ::DWORD = 6723; +pub const ERROR_TRANSACTION_RECORD_TOO_LONG: ::DWORD = 6724; +pub const ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED: ::DWORD = 6725; +pub const ERROR_TRANSACTION_INTEGRITY_VIOLATED: ::DWORD = 6726; +pub const ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH: ::DWORD = 6727; +pub const ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: ::DWORD = 6728; +pub const ERROR_TRANSACTION_MUST_WRITETHROUGH: ::DWORD = 6729; +pub const ERROR_TRANSACTION_NO_SUPERIOR: ::DWORD = 6730; +pub const ERROR_HEURISTIC_DAMAGE_POSSIBLE: ::DWORD = 6731; +pub const ERROR_TRANSACTIONAL_CONFLICT: ::DWORD = 6800; +pub const ERROR_RM_NOT_ACTIVE: ::DWORD = 6801; +pub const ERROR_RM_METADATA_CORRUPT: ::DWORD = 6802; +pub const ERROR_DIRECTORY_NOT_RM: ::DWORD = 6803; +pub const ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE: ::DWORD = 6805; +pub const ERROR_LOG_RESIZE_INVALID_SIZE: ::DWORD = 6806; +pub const ERROR_OBJECT_NO_LONGER_EXISTS: ::DWORD = 6807; +pub const ERROR_STREAM_MINIVERSION_NOT_FOUND: ::DWORD = 6808; +pub const ERROR_STREAM_MINIVERSION_NOT_VALID: ::DWORD = 6809; +pub const ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: ::DWORD = 6810; +pub const ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: ::DWORD = 6811; +pub const ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS: ::DWORD = 6812; +pub const ERROR_REMOTE_FILE_VERSION_MISMATCH: ::DWORD = 6814; +pub const ERROR_HANDLE_NO_LONGER_VALID: ::DWORD = 6815; +pub const ERROR_NO_TXF_METADATA: ::DWORD = 6816; +pub const ERROR_LOG_CORRUPTION_DETECTED: ::DWORD = 6817; +pub const ERROR_CANT_RECOVER_WITH_HANDLE_OPEN: ::DWORD = 6818; +pub const ERROR_RM_DISCONNECTED: ::DWORD = 6819; +pub const ERROR_ENLISTMENT_NOT_SUPERIOR: ::DWORD = 6820; +pub const ERROR_RECOVERY_NOT_NEEDED: ::DWORD = 6821; +pub const ERROR_RM_ALREADY_STARTED: ::DWORD = 6822; +pub const ERROR_FILE_IDENTITY_NOT_PERSISTENT: ::DWORD = 6823; +pub const ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: ::DWORD = 6824; +pub const ERROR_CANT_CROSS_RM_BOUNDARY: ::DWORD = 6825; +pub const ERROR_TXF_DIR_NOT_EMPTY: ::DWORD = 6826; +pub const ERROR_INDOUBT_TRANSACTIONS_EXIST: ::DWORD = 6827; +pub const ERROR_TM_VOLATILE: ::DWORD = 6828; +pub const ERROR_ROLLBACK_TIMER_EXPIRED: ::DWORD = 6829; +pub const ERROR_TXF_ATTRIBUTE_CORRUPT: ::DWORD = 6830; +pub const ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION: ::DWORD = 6831; +pub const ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED: ::DWORD = 6832; +pub const ERROR_LOG_GROWTH_FAILED: ::DWORD = 6833; +pub const ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: ::DWORD = 6834; +pub const ERROR_TXF_METADATA_ALREADY_PRESENT: ::DWORD = 6835; +pub const ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: ::DWORD = 6836; +pub const ERROR_TRANSACTION_REQUIRED_PROMOTION: ::DWORD = 6837; +pub const ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION: ::DWORD = 6838; +pub const ERROR_TRANSACTIONS_NOT_FROZEN: ::DWORD = 6839; +pub const ERROR_TRANSACTION_FREEZE_IN_PROGRESS: ::DWORD = 6840; +pub const ERROR_NOT_SNAPSHOT_VOLUME: ::DWORD = 6841; +pub const ERROR_NO_SAVEPOINT_WITH_OPEN_FILES: ::DWORD = 6842; +pub const ERROR_DATA_LOST_REPAIR: ::DWORD = 6843; +pub const ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION: ::DWORD = 6844; +pub const ERROR_TM_IDENTITY_MISMATCH: ::DWORD = 6845; +pub const ERROR_FLOATED_SECTION: ::DWORD = 6846; +pub const ERROR_CANNOT_ACCEPT_TRANSACTED_WORK: ::DWORD = 6847; +pub const ERROR_CANNOT_ABORT_TRANSACTIONS: ::DWORD = 6848; +pub const ERROR_BAD_CLUSTERS: ::DWORD = 6849; +pub const ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: ::DWORD = 6850; +pub const ERROR_VOLUME_DIRTY: ::DWORD = 6851; +pub const ERROR_NO_LINK_TRACKING_IN_TRANSACTION: ::DWORD = 6852; +pub const ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: ::DWORD = 6853; +pub const ERROR_EXPIRED_HANDLE: ::DWORD = 6854; +pub const ERROR_TRANSACTION_NOT_ENLISTED: ::DWORD = 6855; +pub const ERROR_CTX_WINSTATION_NAME_INVALID: ::DWORD = 7001; +pub const ERROR_CTX_INVALID_PD: ::DWORD = 7002; +pub const ERROR_CTX_PD_NOT_FOUND: ::DWORD = 7003; +pub const ERROR_CTX_WD_NOT_FOUND: ::DWORD = 7004; +pub const ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY: ::DWORD = 7005; +pub const ERROR_CTX_SERVICE_NAME_COLLISION: ::DWORD = 7006; +pub const ERROR_CTX_CLOSE_PENDING: ::DWORD = 7007; +pub const ERROR_CTX_NO_OUTBUF: ::DWORD = 7008; +pub const ERROR_CTX_MODEM_INF_NOT_FOUND: ::DWORD = 7009; +pub const ERROR_CTX_INVALID_MODEMNAME: ::DWORD = 7010; +pub const ERROR_CTX_MODEM_RESPONSE_ERROR: ::DWORD = 7011; +pub const ERROR_CTX_MODEM_RESPONSE_TIMEOUT: ::DWORD = 7012; +pub const ERROR_CTX_MODEM_RESPONSE_NO_CARRIER: ::DWORD = 7013; +pub const ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE: ::DWORD = 7014; +pub const ERROR_CTX_MODEM_RESPONSE_BUSY: ::DWORD = 7015; +pub const ERROR_CTX_MODEM_RESPONSE_VOICE: ::DWORD = 7016; +pub const ERROR_CTX_TD_ERROR: ::DWORD = 7017; +pub const ERROR_CTX_WINSTATION_NOT_FOUND: ::DWORD = 7022; +pub const ERROR_CTX_WINSTATION_ALREADY_EXISTS: ::DWORD = 7023; +pub const ERROR_CTX_WINSTATION_BUSY: ::DWORD = 7024; +pub const ERROR_CTX_BAD_VIDEO_MODE: ::DWORD = 7025; +pub const ERROR_CTX_GRAPHICS_INVALID: ::DWORD = 7035; +pub const ERROR_CTX_LOGON_DISABLED: ::DWORD = 7037; +pub const ERROR_CTX_NOT_CONSOLE: ::DWORD = 7038; +pub const ERROR_CTX_CLIENT_QUERY_TIMEOUT: ::DWORD = 7040; +pub const ERROR_CTX_CONSOLE_DISCONNECT: ::DWORD = 7041; +pub const ERROR_CTX_CONSOLE_CONNECT: ::DWORD = 7042; +pub const ERROR_CTX_SHADOW_DENIED: ::DWORD = 7044; +pub const ERROR_CTX_WINSTATION_ACCESS_DENIED: ::DWORD = 7045; +pub const ERROR_CTX_INVALID_WD: ::DWORD = 7049; +pub const ERROR_CTX_SHADOW_INVALID: ::DWORD = 7050; +pub const ERROR_CTX_SHADOW_DISABLED: ::DWORD = 7051; +pub const ERROR_CTX_CLIENT_LICENSE_IN_USE: ::DWORD = 7052; +pub const ERROR_CTX_CLIENT_LICENSE_NOT_SET: ::DWORD = 7053; +pub const ERROR_CTX_LICENSE_NOT_AVAILABLE: ::DWORD = 7054; +pub const ERROR_CTX_LICENSE_CLIENT_INVALID: ::DWORD = 7055; +pub const ERROR_CTX_LICENSE_EXPIRED: ::DWORD = 7056; +pub const ERROR_CTX_SHADOW_NOT_RUNNING: ::DWORD = 7057; +pub const ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE: ::DWORD = 7058; +pub const ERROR_ACTIVATION_COUNT_EXCEEDED: ::DWORD = 7059; +pub const ERROR_CTX_WINSTATIONS_DISABLED: ::DWORD = 7060; +pub const ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED: ::DWORD = 7061; +pub const ERROR_CTX_SESSION_IN_USE: ::DWORD = 7062; +pub const ERROR_CTX_NO_FORCE_LOGOFF: ::DWORD = 7063; +pub const ERROR_CTX_ACCOUNT_RESTRICTION: ::DWORD = 7064; +pub const ERROR_RDP_PROTOCOL_ERROR: ::DWORD = 7065; +pub const ERROR_CTX_CDM_CONNECT: ::DWORD = 7066; +pub const ERROR_CTX_CDM_DISCONNECT: ::DWORD = 7067; +pub const ERROR_CTX_SECURITY_LAYER_ERROR: ::DWORD = 7068; +pub const ERROR_TS_INCOMPATIBLE_SESSIONS: ::DWORD = 7069; +pub const ERROR_TS_VIDEO_SUBSYSTEM_ERROR: ::DWORD = 7070; +pub const FRS_ERR_INVALID_API_SEQUENCE: ::DWORD = 8001; +pub const FRS_ERR_STARTING_SERVICE: ::DWORD = 8002; +pub const FRS_ERR_STOPPING_SERVICE: ::DWORD = 8003; +pub const FRS_ERR_INTERNAL_API: ::DWORD = 8004; +pub const FRS_ERR_INTERNAL: ::DWORD = 8005; +pub const FRS_ERR_SERVICE_COMM: ::DWORD = 8006; +pub const FRS_ERR_INSUFFICIENT_PRIV: ::DWORD = 8007; +pub const FRS_ERR_AUTHENTICATION: ::DWORD = 8008; +pub const FRS_ERR_PARENT_INSUFFICIENT_PRIV: ::DWORD = 8009; +pub const FRS_ERR_PARENT_AUTHENTICATION: ::DWORD = 8010; +pub const FRS_ERR_CHILD_TO_PARENT_COMM: ::DWORD = 8011; +pub const FRS_ERR_PARENT_TO_CHILD_COMM: ::DWORD = 8012; +pub const FRS_ERR_SYSVOL_POPULATE: ::DWORD = 8013; +pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: ::DWORD = 8014; +pub const FRS_ERR_SYSVOL_IS_BUSY: ::DWORD = 8015; +pub const FRS_ERR_SYSVOL_DEMOTE: ::DWORD = 8016; +pub const FRS_ERR_INVALID_SERVICE_PARAMETER: ::DWORD = 8017; +pub const DS_S_SUCCESS: ::DWORD = NO_ERROR; +pub const ERROR_DS_NOT_INSTALLED: ::DWORD = 8200; +pub const ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY: ::DWORD = 8201; +pub const ERROR_DS_NO_ATTRIBUTE_OR_VALUE: ::DWORD = 8202; +pub const ERROR_DS_INVALID_ATTRIBUTE_SYNTAX: ::DWORD = 8203; +pub const ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED: ::DWORD = 8204; +pub const ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS: ::DWORD = 8205; +pub const ERROR_DS_BUSY: ::DWORD = 8206; +pub const ERROR_DS_UNAVAILABLE: ::DWORD = 8207; +pub const ERROR_DS_NO_RIDS_ALLOCATED: ::DWORD = 8208; +pub const ERROR_DS_NO_MORE_RIDS: ::DWORD = 8209; +pub const ERROR_DS_INCORRECT_ROLE_OWNER: ::DWORD = 8210; +pub const ERROR_DS_RIDMGR_INIT_ERROR: ::DWORD = 8211; +pub const ERROR_DS_OBJ_CLASS_VIOLATION: ::DWORD = 8212; +pub const ERROR_DS_CANT_ON_NON_LEAF: ::DWORD = 8213; +pub const ERROR_DS_CANT_ON_RDN: ::DWORD = 8214; +pub const ERROR_DS_CANT_MOD_OBJ_CLASS: ::DWORD = 8215; +pub const ERROR_DS_CROSS_DOM_MOVE_ERROR: ::DWORD = 8216; +pub const ERROR_DS_GC_NOT_AVAILABLE: ::DWORD = 8217; +pub const ERROR_SHARED_POLICY: ::DWORD = 8218; +pub const ERROR_POLICY_OBJECT_NOT_FOUND: ::DWORD = 8219; +pub const ERROR_POLICY_ONLY_IN_DS: ::DWORD = 8220; +pub const ERROR_PROMOTION_ACTIVE: ::DWORD = 8221; +pub const ERROR_NO_PROMOTION_ACTIVE: ::DWORD = 8222; +pub const ERROR_DS_OPERATIONS_ERROR: ::DWORD = 8224; +pub const ERROR_DS_PROTOCOL_ERROR: ::DWORD = 8225; +pub const ERROR_DS_TIMELIMIT_EXCEEDED: ::DWORD = 8226; +pub const ERROR_DS_SIZELIMIT_EXCEEDED: ::DWORD = 8227; +pub const ERROR_DS_ADMIN_LIMIT_EXCEEDED: ::DWORD = 8228; +pub const ERROR_DS_COMPARE_FALSE: ::DWORD = 8229; +pub const ERROR_DS_COMPARE_TRUE: ::DWORD = 8230; +pub const ERROR_DS_AUTH_METHOD_NOT_SUPPORTED: ::DWORD = 8231; +pub const ERROR_DS_STRONG_AUTH_REQUIRED: ::DWORD = 8232; +pub const ERROR_DS_INAPPROPRIATE_AUTH: ::DWORD = 8233; +pub const ERROR_DS_AUTH_UNKNOWN: ::DWORD = 8234; +pub const ERROR_DS_REFERRAL: ::DWORD = 8235; +pub const ERROR_DS_UNAVAILABLE_CRIT_EXTENSION: ::DWORD = 8236; +pub const ERROR_DS_CONFIDENTIALITY_REQUIRED: ::DWORD = 8237; +pub const ERROR_DS_INAPPROPRIATE_MATCHING: ::DWORD = 8238; +pub const ERROR_DS_CONSTRAINT_VIOLATION: ::DWORD = 8239; +pub const ERROR_DS_NO_SUCH_OBJECT: ::DWORD = 8240; +pub const ERROR_DS_ALIAS_PROBLEM: ::DWORD = 8241; +pub const ERROR_DS_INVALID_DN_SYNTAX: ::DWORD = 8242; +pub const ERROR_DS_IS_LEAF: ::DWORD = 8243; +pub const ERROR_DS_ALIAS_DEREF_PROBLEM: ::DWORD = 8244; +pub const ERROR_DS_UNWILLING_TO_PERFORM: ::DWORD = 8245; +pub const ERROR_DS_LOOP_DETECT: ::DWORD = 8246; +pub const ERROR_DS_NAMING_VIOLATION: ::DWORD = 8247; +pub const ERROR_DS_OBJECT_RESULTS_TOO_LARGE: ::DWORD = 8248; +pub const ERROR_DS_AFFECTS_MULTIPLE_DSAS: ::DWORD = 8249; +pub const ERROR_DS_SERVER_DOWN: ::DWORD = 8250; +pub const ERROR_DS_LOCAL_ERROR: ::DWORD = 8251; +pub const ERROR_DS_ENCODING_ERROR: ::DWORD = 8252; +pub const ERROR_DS_DECODING_ERROR: ::DWORD = 8253; +pub const ERROR_DS_FILTER_UNKNOWN: ::DWORD = 8254; +pub const ERROR_DS_PARAM_ERROR: ::DWORD = 8255; +pub const ERROR_DS_NOT_SUPPORTED: ::DWORD = 8256; +pub const ERROR_DS_NO_RESULTS_RETURNED: ::DWORD = 8257; +pub const ERROR_DS_CONTROL_NOT_FOUND: ::DWORD = 8258; +pub const ERROR_DS_CLIENT_LOOP: ::DWORD = 8259; +pub const ERROR_DS_REFERRAL_LIMIT_EXCEEDED: ::DWORD = 8260; +pub const ERROR_DS_SORT_CONTROL_MISSING: ::DWORD = 8261; +pub const ERROR_DS_OFFSET_RANGE_ERROR: ::DWORD = 8262; +pub const ERROR_DS_RIDMGR_DISABLED: ::DWORD = 8263; +pub const ERROR_DS_ROOT_MUST_BE_NC: ::DWORD = 8301; +pub const ERROR_DS_ADD_REPLICA_INHIBITED: ::DWORD = 8302; +pub const ERROR_DS_ATT_NOT_DEF_IN_SCHEMA: ::DWORD = 8303; +pub const ERROR_DS_MAX_OBJ_SIZE_EXCEEDED: ::DWORD = 8304; +pub const ERROR_DS_OBJ_STRING_NAME_EXISTS: ::DWORD = 8305; +pub const ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA: ::DWORD = 8306; +pub const ERROR_DS_RDN_DOESNT_MATCH_SCHEMA: ::DWORD = 8307; +pub const ERROR_DS_NO_REQUESTED_ATTS_FOUND: ::DWORD = 8308; +pub const ERROR_DS_USER_BUFFER_TO_SMALL: ::DWORD = 8309; +pub const ERROR_DS_ATT_IS_NOT_ON_OBJ: ::DWORD = 8310; +pub const ERROR_DS_ILLEGAL_MOD_OPERATION: ::DWORD = 8311; +pub const ERROR_DS_OBJ_TOO_LARGE: ::DWORD = 8312; +pub const ERROR_DS_BAD_INSTANCE_TYPE: ::DWORD = 8313; +pub const ERROR_DS_MASTERDSA_REQUIRED: ::DWORD = 8314; +pub const ERROR_DS_OBJECT_CLASS_REQUIRED: ::DWORD = 8315; +pub const ERROR_DS_MISSING_REQUIRED_ATT: ::DWORD = 8316; +pub const ERROR_DS_ATT_NOT_DEF_FOR_CLASS: ::DWORD = 8317; +pub const ERROR_DS_ATT_ALREADY_EXISTS: ::DWORD = 8318; +pub const ERROR_DS_CANT_ADD_ATT_VALUES: ::DWORD = 8320; +pub const ERROR_DS_SINGLE_VALUE_CONSTRAINT: ::DWORD = 8321; +pub const ERROR_DS_RANGE_CONSTRAINT: ::DWORD = 8322; +pub const ERROR_DS_ATT_VAL_ALREADY_EXISTS: ::DWORD = 8323; +pub const ERROR_DS_CANT_REM_MISSING_ATT: ::DWORD = 8324; +pub const ERROR_DS_CANT_REM_MISSING_ATT_VAL: ::DWORD = 8325; +pub const ERROR_DS_ROOT_CANT_BE_SUBREF: ::DWORD = 8326; +pub const ERROR_DS_NO_CHAINING: ::DWORD = 8327; +pub const ERROR_DS_NO_CHAINED_EVAL: ::DWORD = 8328; +pub const ERROR_DS_NO_PARENT_OBJECT: ::DWORD = 8329; +pub const ERROR_DS_PARENT_IS_AN_ALIAS: ::DWORD = 8330; +pub const ERROR_DS_CANT_MIX_MASTER_AND_REPS: ::DWORD = 8331; +pub const ERROR_DS_CHILDREN_EXIST: ::DWORD = 8332; +pub const ERROR_DS_OBJ_NOT_FOUND: ::DWORD = 8333; +pub const ERROR_DS_ALIASED_OBJ_MISSING: ::DWORD = 8334; +pub const ERROR_DS_BAD_NAME_SYNTAX: ::DWORD = 8335; +pub const ERROR_DS_ALIAS_POINTS_TO_ALIAS: ::DWORD = 8336; +pub const ERROR_DS_CANT_DEREF_ALIAS: ::DWORD = 8337; +pub const ERROR_DS_OUT_OF_SCOPE: ::DWORD = 8338; +pub const ERROR_DS_OBJECT_BEING_REMOVED: ::DWORD = 8339; +pub const ERROR_DS_CANT_DELETE_DSA_OBJ: ::DWORD = 8340; +pub const ERROR_DS_GENERIC_ERROR: ::DWORD = 8341; +pub const ERROR_DS_DSA_MUST_BE_INT_MASTER: ::DWORD = 8342; +pub const ERROR_DS_CLASS_NOT_DSA: ::DWORD = 8343; +pub const ERROR_DS_INSUFF_ACCESS_RIGHTS: ::DWORD = 8344; +pub const ERROR_DS_ILLEGAL_SUPERIOR: ::DWORD = 8345; +pub const ERROR_DS_ATTRIBUTE_OWNED_BY_SAM: ::DWORD = 8346; +pub const ERROR_DS_NAME_TOO_MANY_PARTS: ::DWORD = 8347; +pub const ERROR_DS_NAME_TOO_LONG: ::DWORD = 8348; +pub const ERROR_DS_NAME_VALUE_TOO_LONG: ::DWORD = 8349; +pub const ERROR_DS_NAME_UNPARSEABLE: ::DWORD = 8350; +pub const ERROR_DS_NAME_TYPE_UNKNOWN: ::DWORD = 8351; +pub const ERROR_DS_NOT_AN_OBJECT: ::DWORD = 8352; +pub const ERROR_DS_SEC_DESC_TOO_SHORT: ::DWORD = 8353; +pub const ERROR_DS_SEC_DESC_INVALID: ::DWORD = 8354; +pub const ERROR_DS_NO_DELETED_NAME: ::DWORD = 8355; +pub const ERROR_DS_SUBREF_MUST_HAVE_PARENT: ::DWORD = 8356; +pub const ERROR_DS_NCNAME_MUST_BE_NC: ::DWORD = 8357; +pub const ERROR_DS_CANT_ADD_SYSTEM_ONLY: ::DWORD = 8358; +pub const ERROR_DS_CLASS_MUST_BE_CONCRETE: ::DWORD = 8359; +pub const ERROR_DS_INVALID_DMD: ::DWORD = 8360; +pub const ERROR_DS_OBJ_GUID_EXISTS: ::DWORD = 8361; +pub const ERROR_DS_NOT_ON_BACKLINK: ::DWORD = 8362; +pub const ERROR_DS_NO_CROSSREF_FOR_NC: ::DWORD = 8363; +pub const ERROR_DS_SHUTTING_DOWN: ::DWORD = 8364; +pub const ERROR_DS_UNKNOWN_OPERATION: ::DWORD = 8365; +pub const ERROR_DS_INVALID_ROLE_OWNER: ::DWORD = 8366; +pub const ERROR_DS_COULDNT_CONTACT_FSMO: ::DWORD = 8367; +pub const ERROR_DS_CROSS_NC_DN_RENAME: ::DWORD = 8368; +pub const ERROR_DS_CANT_MOD_SYSTEM_ONLY: ::DWORD = 8369; +pub const ERROR_DS_REPLICATOR_ONLY: ::DWORD = 8370; +pub const ERROR_DS_OBJ_CLASS_NOT_DEFINED: ::DWORD = 8371; +pub const ERROR_DS_OBJ_CLASS_NOT_SUBCLASS: ::DWORD = 8372; +pub const ERROR_DS_NAME_REFERENCE_INVALID: ::DWORD = 8373; +pub const ERROR_DS_CROSS_REF_EXISTS: ::DWORD = 8374; +pub const ERROR_DS_CANT_DEL_MASTER_CROSSREF: ::DWORD = 8375; +pub const ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD: ::DWORD = 8376; +pub const ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX: ::DWORD = 8377; +pub const ERROR_DS_DUP_RDN: ::DWORD = 8378; +pub const ERROR_DS_DUP_OID: ::DWORD = 8379; +pub const ERROR_DS_DUP_MAPI_ID: ::DWORD = 8380; +pub const ERROR_DS_DUP_SCHEMA_ID_GUID: ::DWORD = 8381; +pub const ERROR_DS_DUP_LDAP_DISPLAY_NAME: ::DWORD = 8382; +pub const ERROR_DS_SEMANTIC_ATT_TEST: ::DWORD = 8383; +pub const ERROR_DS_SYNTAX_MISMATCH: ::DWORD = 8384; +pub const ERROR_DS_EXISTS_IN_MUST_HAVE: ::DWORD = 8385; +pub const ERROR_DS_EXISTS_IN_MAY_HAVE: ::DWORD = 8386; +pub const ERROR_DS_NONEXISTENT_MAY_HAVE: ::DWORD = 8387; +pub const ERROR_DS_NONEXISTENT_MUST_HAVE: ::DWORD = 8388; +pub const ERROR_DS_AUX_CLS_TEST_FAIL: ::DWORD = 8389; +pub const ERROR_DS_NONEXISTENT_POSS_SUP: ::DWORD = 8390; +pub const ERROR_DS_SUB_CLS_TEST_FAIL: ::DWORD = 8391; +pub const ERROR_DS_BAD_RDN_ATT_ID_SYNTAX: ::DWORD = 8392; +pub const ERROR_DS_EXISTS_IN_AUX_CLS: ::DWORD = 8393; +pub const ERROR_DS_EXISTS_IN_SUB_CLS: ::DWORD = 8394; +pub const ERROR_DS_EXISTS_IN_POSS_SUP: ::DWORD = 8395; +pub const ERROR_DS_RECALCSCHEMA_FAILED: ::DWORD = 8396; +pub const ERROR_DS_TREE_DELETE_NOT_FINISHED: ::DWORD = 8397; +pub const ERROR_DS_CANT_DELETE: ::DWORD = 8398; +pub const ERROR_DS_ATT_SCHEMA_REQ_ID: ::DWORD = 8399; +pub const ERROR_DS_BAD_ATT_SCHEMA_SYNTAX: ::DWORD = 8400; +pub const ERROR_DS_CANT_CACHE_ATT: ::DWORD = 8401; +pub const ERROR_DS_CANT_CACHE_CLASS: ::DWORD = 8402; +pub const ERROR_DS_CANT_REMOVE_ATT_CACHE: ::DWORD = 8403; +pub const ERROR_DS_CANT_REMOVE_CLASS_CACHE: ::DWORD = 8404; +pub const ERROR_DS_CANT_RETRIEVE_DN: ::DWORD = 8405; +pub const ERROR_DS_MISSING_SUPREF: ::DWORD = 8406; +pub const ERROR_DS_CANT_RETRIEVE_INSTANCE: ::DWORD = 8407; +pub const ERROR_DS_CODE_INCONSISTENCY: ::DWORD = 8408; +pub const ERROR_DS_DATABASE_ERROR: ::DWORD = 8409; +pub const ERROR_DS_GOVERNSID_MISSING: ::DWORD = 8410; +pub const ERROR_DS_MISSING_EXPECTED_ATT: ::DWORD = 8411; +pub const ERROR_DS_NCNAME_MISSING_CR_REF: ::DWORD = 8412; +pub const ERROR_DS_SECURITY_CHECKING_ERROR: ::DWORD = 8413; +pub const ERROR_DS_SCHEMA_NOT_LOADED: ::DWORD = 8414; +pub const ERROR_DS_SCHEMA_ALLOC_FAILED: ::DWORD = 8415; +pub const ERROR_DS_ATT_SCHEMA_REQ_SYNTAX: ::DWORD = 8416; +pub const ERROR_DS_GCVERIFY_ERROR: ::DWORD = 8417; +pub const ERROR_DS_DRA_SCHEMA_MISMATCH: ::DWORD = 8418; +pub const ERROR_DS_CANT_FIND_DSA_OBJ: ::DWORD = 8419; +pub const ERROR_DS_CANT_FIND_EXPECTED_NC: ::DWORD = 8420; +pub const ERROR_DS_CANT_FIND_NC_IN_CACHE: ::DWORD = 8421; +pub const ERROR_DS_CANT_RETRIEVE_CHILD: ::DWORD = 8422; +pub const ERROR_DS_SECURITY_ILLEGAL_MODIFY: ::DWORD = 8423; +pub const ERROR_DS_CANT_REPLACE_HIDDEN_REC: ::DWORD = 8424; +pub const ERROR_DS_BAD_HIERARCHY_FILE: ::DWORD = 8425; +pub const ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED: ::DWORD = 8426; +pub const ERROR_DS_CONFIG_PARAM_MISSING: ::DWORD = 8427; +pub const ERROR_DS_COUNTING_AB_INDICES_FAILED: ::DWORD = 8428; +pub const ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED: ::DWORD = 8429; +pub const ERROR_DS_INTERNAL_FAILURE: ::DWORD = 8430; +pub const ERROR_DS_UNKNOWN_ERROR: ::DWORD = 8431; +pub const ERROR_DS_ROOT_REQUIRES_CLASS_TOP: ::DWORD = 8432; +pub const ERROR_DS_REFUSING_FSMO_ROLES: ::DWORD = 8433; +pub const ERROR_DS_MISSING_FSMO_SETTINGS: ::DWORD = 8434; +pub const ERROR_DS_UNABLE_TO_SURRENDER_ROLES: ::DWORD = 8435; +pub const ERROR_DS_DRA_GENERIC: ::DWORD = 8436; +pub const ERROR_DS_DRA_INVALID_PARAMETER: ::DWORD = 8437; +pub const ERROR_DS_DRA_BUSY: ::DWORD = 8438; +pub const ERROR_DS_DRA_BAD_DN: ::DWORD = 8439; +pub const ERROR_DS_DRA_BAD_NC: ::DWORD = 8440; +pub const ERROR_DS_DRA_DN_EXISTS: ::DWORD = 8441; +pub const ERROR_DS_DRA_INTERNAL_ERROR: ::DWORD = 8442; +pub const ERROR_DS_DRA_INCONSISTENT_DIT: ::DWORD = 8443; +pub const ERROR_DS_DRA_CONNECTION_FAILED: ::DWORD = 8444; +pub const ERROR_DS_DRA_BAD_INSTANCE_TYPE: ::DWORD = 8445; +pub const ERROR_DS_DRA_OUT_OF_MEM: ::DWORD = 8446; +pub const ERROR_DS_DRA_MAIL_PROBLEM: ::DWORD = 8447; +pub const ERROR_DS_DRA_REF_ALREADY_EXISTS: ::DWORD = 8448; +pub const ERROR_DS_DRA_REF_NOT_FOUND: ::DWORD = 8449; +pub const ERROR_DS_DRA_OBJ_IS_REP_SOURCE: ::DWORD = 8450; +pub const ERROR_DS_DRA_DB_ERROR: ::DWORD = 8451; +pub const ERROR_DS_DRA_NO_REPLICA: ::DWORD = 8452; +pub const ERROR_DS_DRA_ACCESS_DENIED: ::DWORD = 8453; +pub const ERROR_DS_DRA_NOT_SUPPORTED: ::DWORD = 8454; +pub const ERROR_DS_DRA_RPC_CANCELLED: ::DWORD = 8455; +pub const ERROR_DS_DRA_SOURCE_DISABLED: ::DWORD = 8456; +pub const ERROR_DS_DRA_SINK_DISABLED: ::DWORD = 8457; +pub const ERROR_DS_DRA_NAME_COLLISION: ::DWORD = 8458; +pub const ERROR_DS_DRA_SOURCE_REINSTALLED: ::DWORD = 8459; +pub const ERROR_DS_DRA_MISSING_PARENT: ::DWORD = 8460; +pub const ERROR_DS_DRA_PREEMPTED: ::DWORD = 8461; +pub const ERROR_DS_DRA_ABANDON_SYNC: ::DWORD = 8462; +pub const ERROR_DS_DRA_SHUTDOWN: ::DWORD = 8463; +pub const ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET: ::DWORD = 8464; +pub const ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA: ::DWORD = 8465; +pub const ERROR_DS_DRA_EXTN_CONNECTION_FAILED: ::DWORD = 8466; +pub const ERROR_DS_INSTALL_SCHEMA_MISMATCH: ::DWORD = 8467; +pub const ERROR_DS_DUP_LINK_ID: ::DWORD = 8468; +pub const ERROR_DS_NAME_ERROR_RESOLVING: ::DWORD = 8469; +pub const ERROR_DS_NAME_ERROR_NOT_FOUND: ::DWORD = 8470; +pub const ERROR_DS_NAME_ERROR_NOT_UNIQUE: ::DWORD = 8471; +pub const ERROR_DS_NAME_ERROR_NO_MAPPING: ::DWORD = 8472; +pub const ERROR_DS_NAME_ERROR_DOMAIN_ONLY: ::DWORD = 8473; +pub const ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING: ::DWORD = 8474; +pub const ERROR_DS_CONSTRUCTED_ATT_MOD: ::DWORD = 8475; +pub const ERROR_DS_WRONG_OM_OBJ_CLASS: ::DWORD = 8476; +pub const ERROR_DS_DRA_REPL_PENDING: ::DWORD = 8477; +pub const ERROR_DS_DS_REQUIRED: ::DWORD = 8478; +pub const ERROR_DS_INVALID_LDAP_DISPLAY_NAME: ::DWORD = 8479; +pub const ERROR_DS_NON_BASE_SEARCH: ::DWORD = 8480; +pub const ERROR_DS_CANT_RETRIEVE_ATTS: ::DWORD = 8481; +pub const ERROR_DS_BACKLINK_WITHOUT_LINK: ::DWORD = 8482; +pub const ERROR_DS_EPOCH_MISMATCH: ::DWORD = 8483; +pub const ERROR_DS_SRC_NAME_MISMATCH: ::DWORD = 8484; +pub const ERROR_DS_SRC_AND_DST_NC_IDENTICAL: ::DWORD = 8485; +pub const ERROR_DS_DST_NC_MISMATCH: ::DWORD = 8486; +pub const ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC: ::DWORD = 8487; +pub const ERROR_DS_SRC_GUID_MISMATCH: ::DWORD = 8488; +pub const ERROR_DS_CANT_MOVE_DELETED_OBJECT: ::DWORD = 8489; +pub const ERROR_DS_PDC_OPERATION_IN_PROGRESS: ::DWORD = 8490; +pub const ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD: ::DWORD = 8491; +pub const ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION: ::DWORD = 8492; +pub const ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS: ::DWORD = 8493; +pub const ERROR_DS_NC_MUST_HAVE_NC_PARENT: ::DWORD = 8494; +pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE: ::DWORD = 8495; +pub const ERROR_DS_DST_DOMAIN_NOT_NATIVE: ::DWORD = 8496; +pub const ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER: ::DWORD = 8497; +pub const ERROR_DS_CANT_MOVE_ACCOUNT_GROUP: ::DWORD = 8498; +pub const ERROR_DS_CANT_MOVE_RESOURCE_GROUP: ::DWORD = 8499; +pub const ERROR_DS_INVALID_SEARCH_FLAG: ::DWORD = 8500; +pub const ERROR_DS_NO_TREE_DELETE_ABOVE_NC: ::DWORD = 8501; +pub const ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE: ::DWORD = 8502; +pub const ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE: ::DWORD = 8503; +pub const ERROR_DS_SAM_INIT_FAILURE: ::DWORD = 8504; +pub const ERROR_DS_SENSITIVE_GROUP_VIOLATION: ::DWORD = 8505; +pub const ERROR_DS_CANT_MOD_PRIMARYGROUPID: ::DWORD = 8506; +pub const ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD: ::DWORD = 8507; +pub const ERROR_DS_NONSAFE_SCHEMA_CHANGE: ::DWORD = 8508; +pub const ERROR_DS_SCHEMA_UPDATE_DISALLOWED: ::DWORD = 8509; +pub const ERROR_DS_CANT_CREATE_UNDER_SCHEMA: ::DWORD = 8510; +pub const ERROR_DS_INSTALL_NO_SRC_SCH_VERSION: ::DWORD = 8511; +pub const ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE: ::DWORD = 8512; +pub const ERROR_DS_INVALID_GROUP_TYPE: ::DWORD = 8513; +pub const ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: ::DWORD = 8514; +pub const ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: ::DWORD = 8515; +pub const ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: ::DWORD = 8516; +pub const ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: ::DWORD = 8517; +pub const ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: ::DWORD = 8518; +pub const ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: ::DWORD = 8519; +pub const ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: ::DWORD = 8520; +pub const ERROR_DS_HAVE_PRIMARY_MEMBERS: ::DWORD = 8521; +pub const ERROR_DS_STRING_SD_CONVERSION_FAILED: ::DWORD = 8522; +pub const ERROR_DS_NAMING_MASTER_GC: ::DWORD = 8523; +pub const ERROR_DS_DNS_LOOKUP_FAILURE: ::DWORD = 8524; +pub const ERROR_DS_COULDNT_UPDATE_SPNS: ::DWORD = 8525; +pub const ERROR_DS_CANT_RETRIEVE_SD: ::DWORD = 8526; +pub const ERROR_DS_KEY_NOT_UNIQUE: ::DWORD = 8527; +pub const ERROR_DS_WRONG_LINKED_ATT_SYNTAX: ::DWORD = 8528; +pub const ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD: ::DWORD = 8529; +pub const ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY: ::DWORD = 8530; +pub const ERROR_DS_CANT_START: ::DWORD = 8531; +pub const ERROR_DS_INIT_FAILURE: ::DWORD = 8532; +pub const ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION: ::DWORD = 8533; +pub const ERROR_DS_SOURCE_DOMAIN_IN_FOREST: ::DWORD = 8534; +pub const ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST: ::DWORD = 8535; +pub const ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED: ::DWORD = 8536; +pub const ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN: ::DWORD = 8537; +pub const ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER: ::DWORD = 8538; +pub const ERROR_DS_SRC_SID_EXISTS_IN_FOREST: ::DWORD = 8539; +pub const ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH: ::DWORD = 8540; +pub const ERROR_SAM_INIT_FAILURE: ::DWORD = 8541; +pub const ERROR_DS_DRA_SCHEMA_INFO_SHIP: ::DWORD = 8542; +pub const ERROR_DS_DRA_SCHEMA_CONFLICT: ::DWORD = 8543; +pub const ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT: ::DWORD = 8544; +pub const ERROR_DS_DRA_OBJ_NC_MISMATCH: ::DWORD = 8545; +pub const ERROR_DS_NC_STILL_HAS_DSAS: ::DWORD = 8546; +pub const ERROR_DS_GC_REQUIRED: ::DWORD = 8547; +pub const ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: ::DWORD = 8548; +pub const ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS: ::DWORD = 8549; +pub const ERROR_DS_CANT_ADD_TO_GC: ::DWORD = 8550; +pub const ERROR_DS_NO_CHECKPOINT_WITH_PDC: ::DWORD = 8551; +pub const ERROR_DS_SOURCE_AUDITING_NOT_ENABLED: ::DWORD = 8552; +pub const ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC: ::DWORD = 8553; +pub const ERROR_DS_INVALID_NAME_FOR_SPN: ::DWORD = 8554; +pub const ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS: ::DWORD = 8555; +pub const ERROR_DS_UNICODEPWD_NOT_IN_QUOTES: ::DWORD = 8556; +pub const ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: ::DWORD = 8557; +pub const ERROR_DS_MUST_BE_RUN_ON_DST_DC: ::DWORD = 8558; +pub const ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER: ::DWORD = 8559; +pub const ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ: ::DWORD = 8560; +pub const ERROR_DS_INIT_FAILURE_CONSOLE: ::DWORD = 8561; +pub const ERROR_DS_SAM_INIT_FAILURE_CONSOLE: ::DWORD = 8562; +pub const ERROR_DS_FOREST_VERSION_TOO_HIGH: ::DWORD = 8563; +pub const ERROR_DS_DOMAIN_VERSION_TOO_HIGH: ::DWORD = 8564; +pub const ERROR_DS_FOREST_VERSION_TOO_LOW: ::DWORD = 8565; +pub const ERROR_DS_DOMAIN_VERSION_TOO_LOW: ::DWORD = 8566; +pub const ERROR_DS_INCOMPATIBLE_VERSION: ::DWORD = 8567; +pub const ERROR_DS_LOW_DSA_VERSION: ::DWORD = 8568; +pub const ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN: ::DWORD = 8569; +pub const ERROR_DS_NOT_SUPPORTED_SORT_ORDER: ::DWORD = 8570; +pub const ERROR_DS_NAME_NOT_UNIQUE: ::DWORD = 8571; +pub const ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4: ::DWORD = 8572; +pub const ERROR_DS_OUT_OF_VERSION_STORE: ::DWORD = 8573; +pub const ERROR_DS_INCOMPATIBLE_CONTROLS_USED: ::DWORD = 8574; +pub const ERROR_DS_NO_REF_DOMAIN: ::DWORD = 8575; +pub const ERROR_DS_RESERVED_LINK_ID: ::DWORD = 8576; +pub const ERROR_DS_LINK_ID_NOT_AVAILABLE: ::DWORD = 8577; +pub const ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: ::DWORD = 8578; +pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE: ::DWORD = 8579; +pub const ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC: ::DWORD = 8580; +pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG: ::DWORD = 8581; +pub const ERROR_DS_MODIFYDN_WRONG_GRANDPARENT: ::DWORD = 8582; +pub const ERROR_DS_NAME_ERROR_TRUST_REFERRAL: ::DWORD = 8583; +pub const ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER: ::DWORD = 8584; +pub const ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD: ::DWORD = 8585; +pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2: ::DWORD = 8586; +pub const ERROR_DS_THREAD_LIMIT_EXCEEDED: ::DWORD = 8587; +pub const ERROR_DS_NOT_CLOSEST: ::DWORD = 8588; +pub const ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF: ::DWORD = 8589; +pub const ERROR_DS_SINGLE_USER_MODE_FAILED: ::DWORD = 8590; +pub const ERROR_DS_NTDSCRIPT_SYNTAX_ERROR: ::DWORD = 8591; +pub const ERROR_DS_NTDSCRIPT_PROCESS_ERROR: ::DWORD = 8592; +pub const ERROR_DS_DIFFERENT_REPL_EPOCHS: ::DWORD = 8593; +pub const ERROR_DS_DRS_EXTENSIONS_CHANGED: ::DWORD = 8594; +pub const ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR: ::DWORD = 8595; +pub const ERROR_DS_NO_MSDS_INTID: ::DWORD = 8596; +pub const ERROR_DS_DUP_MSDS_INTID: ::DWORD = 8597; +pub const ERROR_DS_EXISTS_IN_RDNATTID: ::DWORD = 8598; +pub const ERROR_DS_AUTHORIZATION_FAILED: ::DWORD = 8599; +pub const ERROR_DS_INVALID_SCRIPT: ::DWORD = 8600; +pub const ERROR_DS_REMOTE_CROSSREF_OP_FAILED: ::DWORD = 8601; +pub const ERROR_DS_CROSS_REF_BUSY: ::DWORD = 8602; +pub const ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN: ::DWORD = 8603; +pub const ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC: ::DWORD = 8604; +pub const ERROR_DS_DUPLICATE_ID_FOUND: ::DWORD = 8605; +pub const ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT: ::DWORD = 8606; +pub const ERROR_DS_GROUP_CONVERSION_ERROR: ::DWORD = 8607; +pub const ERROR_DS_CANT_MOVE_APP_BASIC_GROUP: ::DWORD = 8608; +pub const ERROR_DS_CANT_MOVE_APP_QUERY_GROUP: ::DWORD = 8609; +pub const ERROR_DS_ROLE_NOT_VERIFIED: ::DWORD = 8610; +pub const ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL: ::DWORD = 8611; +pub const ERROR_DS_DOMAIN_RENAME_IN_PROGRESS: ::DWORD = 8612; +pub const ERROR_DS_EXISTING_AD_CHILD_NC: ::DWORD = 8613; +pub const ERROR_DS_REPL_LIFETIME_EXCEEDED: ::DWORD = 8614; +pub const ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER: ::DWORD = 8615; +pub const ERROR_DS_LDAP_SEND_QUEUE_FULL: ::DWORD = 8616; +pub const ERROR_DS_DRA_OUT_SCHEDULE_WINDOW: ::DWORD = 8617; +pub const ERROR_DS_POLICY_NOT_KNOWN: ::DWORD = 8618; +pub const ERROR_NO_SITE_SETTINGS_OBJECT: ::DWORD = 8619; +pub const ERROR_NO_SECRETS: ::DWORD = 8620; +pub const ERROR_NO_WRITABLE_DC_FOUND: ::DWORD = 8621; +pub const ERROR_DS_NO_SERVER_OBJECT: ::DWORD = 8622; +pub const ERROR_DS_NO_NTDSA_OBJECT: ::DWORD = 8623; +pub const ERROR_DS_NON_ASQ_SEARCH: ::DWORD = 8624; +pub const ERROR_DS_AUDIT_FAILURE: ::DWORD = 8625; +pub const ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE: ::DWORD = 8626; +pub const ERROR_DS_INVALID_SEARCH_FLAG_TUPLE: ::DWORD = 8627; +pub const ERROR_DS_HIERARCHY_TABLE_TOO_DEEP: ::DWORD = 8628; +pub const ERROR_DS_DRA_CORRUPT_UTD_VECTOR: ::DWORD = 8629; +pub const ERROR_DS_DRA_SECRETS_DENIED: ::DWORD = 8630; +pub const ERROR_DS_RESERVED_MAPI_ID: ::DWORD = 8631; +pub const ERROR_DS_MAPI_ID_NOT_AVAILABLE: ::DWORD = 8632; +pub const ERROR_DS_DRA_MISSING_KRBTGT_SECRET: ::DWORD = 8633; +pub const ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST: ::DWORD = 8634; +pub const ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST: ::DWORD = 8635; +pub const ERROR_INVALID_USER_PRINCIPAL_NAME: ::DWORD = 8636; +pub const ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: ::DWORD = 8637; +pub const ERROR_DS_OID_NOT_FOUND: ::DWORD = 8638; +pub const ERROR_DS_DRA_RECYCLED_TARGET: ::DWORD = 8639; +pub const ERROR_DS_DISALLOWED_NC_REDIRECT: ::DWORD = 8640; +pub const ERROR_DS_HIGH_ADLDS_FFL: ::DWORD = 8641; +pub const ERROR_DS_HIGH_DSA_VERSION: ::DWORD = 8642; +pub const ERROR_DS_LOW_ADLDS_FFL: ::DWORD = 8643; +pub const ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION: ::DWORD = 8644; +pub const ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED: ::DWORD = 8645; +pub const ERROR_INCORRECT_ACCOUNT_TYPE: ::DWORD = 8646; +pub const ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST: ::DWORD = 8647; +pub const ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST: ::DWORD = 8648; +pub const DNS_ERROR_RESPONSE_CODES_BASE: ::DWORD = 9000; +pub const DNS_ERROR_RCODE_NO_ERROR: ::DWORD = NO_ERROR; +pub const DNS_ERROR_MASK: ::DWORD = 0x00002328; +pub const DNS_ERROR_RCODE_FORMAT_ERROR: ::DWORD = 9001; +pub const DNS_ERROR_RCODE_SERVER_FAILURE: ::DWORD = 9002; +pub const DNS_ERROR_RCODE_NAME_ERROR: ::DWORD = 9003; +pub const DNS_ERROR_RCODE_NOT_IMPLEMENTED: ::DWORD = 9004; +pub const DNS_ERROR_RCODE_REFUSED: ::DWORD = 9005; +pub const DNS_ERROR_RCODE_YXDOMAIN: ::DWORD = 9006; +pub const DNS_ERROR_RCODE_YXRRSET: ::DWORD = 9007; +pub const DNS_ERROR_RCODE_NXRRSET: ::DWORD = 9008; +pub const DNS_ERROR_RCODE_NOTAUTH: ::DWORD = 9009; +pub const DNS_ERROR_RCODE_NOTZONE: ::DWORD = 9010; +pub const DNS_ERROR_RCODE_BADSIG: ::DWORD = 9016; +pub const DNS_ERROR_RCODE_BADKEY: ::DWORD = 9017; +pub const DNS_ERROR_RCODE_BADTIME: ::DWORD = 9018; +pub const DNS_ERROR_RCODE_LAST: ::DWORD = DNS_ERROR_RCODE_BADTIME; +pub const DNS_ERROR_DNSSEC_BASE: ::DWORD = 9100; +pub const DNS_ERROR_KEYMASTER_REQUIRED: ::DWORD = 9101; +pub const DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE: ::DWORD = 9102; +pub const DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1: ::DWORD = 9103; +pub const DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS: ::DWORD = 9104; +pub const DNS_ERROR_UNSUPPORTED_ALGORITHM: ::DWORD = 9105; +pub const DNS_ERROR_INVALID_KEY_SIZE: ::DWORD = 9106; +pub const DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE: ::DWORD = 9107; +pub const DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION: ::DWORD = 9108; +pub const DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR: ::DWORD = 9109; +pub const DNS_ERROR_UNEXPECTED_CNG_ERROR: ::DWORD = 9110; +pub const DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION: ::DWORD = 9111; +pub const DNS_ERROR_KSP_NOT_ACCESSIBLE: ::DWORD = 9112; +pub const DNS_ERROR_TOO_MANY_SKDS: ::DWORD = 9113; +pub const DNS_ERROR_INVALID_ROLLOVER_PERIOD: ::DWORD = 9114; +pub const DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET: ::DWORD = 9115; +pub const DNS_ERROR_ROLLOVER_IN_PROGRESS: ::DWORD = 9116; +pub const DNS_ERROR_STANDBY_KEY_NOT_PRESENT: ::DWORD = 9117; +pub const DNS_ERROR_NOT_ALLOWED_ON_ZSK: ::DWORD = 9118; +pub const DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD: ::DWORD = 9119; +pub const DNS_ERROR_ROLLOVER_ALREADY_QUEUED: ::DWORD = 9120; +pub const DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE: ::DWORD = 9121; +pub const DNS_ERROR_BAD_KEYMASTER: ::DWORD = 9122; +pub const DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD: ::DWORD = 9123; +pub const DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT: ::DWORD = 9124; +pub const DNS_ERROR_DNSSEC_IS_DISABLED: ::DWORD = 9125; +pub const DNS_ERROR_INVALID_XML: ::DWORD = 9126; +pub const DNS_ERROR_NO_VALID_TRUST_ANCHORS: ::DWORD = 9127; +pub const DNS_ERROR_ROLLOVER_NOT_POKEABLE: ::DWORD = 9128; +pub const DNS_ERROR_NSEC3_NAME_COLLISION: ::DWORD = 9129; +pub const DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1: ::DWORD = 9130; +pub const DNS_ERROR_PACKET_FMT_BASE: ::DWORD = 9500; +pub const DNS_INFO_NO_RECORDS: ::DWORD = 9501; +pub const DNS_ERROR_BAD_PACKET: ::DWORD = 9502; +pub const DNS_ERROR_NO_PACKET: ::DWORD = 9503; +pub const DNS_ERROR_RCODE: ::DWORD = 9504; +pub const DNS_ERROR_UNSECURE_PACKET: ::DWORD = 9505; +pub const DNS_STATUS_PACKET_UNSECURE: ::DWORD = DNS_ERROR_UNSECURE_PACKET; +pub const DNS_REQUEST_PENDING: ::DWORD = 9506; +pub const DNS_ERROR_NO_MEMORY: ::DWORD = ERROR_OUTOFMEMORY; +pub const DNS_ERROR_INVALID_NAME: ::DWORD = ERROR_INVALID_NAME; +pub const DNS_ERROR_INVALID_DATA: ::DWORD = ERROR_INVALID_DATA; +pub const DNS_ERROR_GENERAL_API_BASE: ::DWORD = 9550; +pub const DNS_ERROR_INVALID_TYPE: ::DWORD = 9551; +pub const DNS_ERROR_INVALID_IP_ADDRESS: ::DWORD = 9552; +pub const DNS_ERROR_INVALID_PROPERTY: ::DWORD = 9553; +pub const DNS_ERROR_TRY_AGAIN_LATER: ::DWORD = 9554; +pub const DNS_ERROR_NOT_UNIQUE: ::DWORD = 9555; +pub const DNS_ERROR_NON_RFC_NAME: ::DWORD = 9556; +pub const DNS_STATUS_FQDN: ::DWORD = 9557; +pub const DNS_STATUS_DOTTED_NAME: ::DWORD = 9558; +pub const DNS_STATUS_SINGLE_PART_NAME: ::DWORD = 9559; +pub const DNS_ERROR_INVALID_NAME_CHAR: ::DWORD = 9560; +pub const DNS_ERROR_NUMERIC_NAME: ::DWORD = 9561; +pub const DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER: ::DWORD = 9562; +pub const DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION: ::DWORD = 9563; +pub const DNS_ERROR_CANNOT_FIND_ROOT_HINTS: ::DWORD = 9564; +pub const DNS_ERROR_INCONSISTENT_ROOT_HINTS: ::DWORD = 9565; +pub const DNS_ERROR_DWORD_VALUE_TOO_SMALL: ::DWORD = 9566; +pub const DNS_ERROR_DWORD_VALUE_TOO_LARGE: ::DWORD = 9567; +pub const DNS_ERROR_BACKGROUND_LOADING: ::DWORD = 9568; +pub const DNS_ERROR_NOT_ALLOWED_ON_RODC: ::DWORD = 9569; +pub const DNS_ERROR_NOT_ALLOWED_UNDER_DNAME: ::DWORD = 9570; +pub const DNS_ERROR_DELEGATION_REQUIRED: ::DWORD = 9571; +pub const DNS_ERROR_INVALID_POLICY_TABLE: ::DWORD = 9572; +pub const DNS_ERROR_ZONE_BASE: ::DWORD = 9600; +pub const DNS_ERROR_ZONE_DOES_NOT_EXIST: ::DWORD = 9601; +pub const DNS_ERROR_NO_ZONE_INFO: ::DWORD = 9602; +pub const DNS_ERROR_INVALID_ZONE_OPERATION: ::DWORD = 9603; +pub const DNS_ERROR_ZONE_CONFIGURATION_ERROR: ::DWORD = 9604; +pub const DNS_ERROR_ZONE_HAS_NO_SOA_RECORD: ::DWORD = 9605; +pub const DNS_ERROR_ZONE_HAS_NO_NS_RECORDS: ::DWORD = 9606; +pub const DNS_ERROR_ZONE_LOCKED: ::DWORD = 9607; +pub const DNS_ERROR_ZONE_CREATION_FAILED: ::DWORD = 9608; +pub const DNS_ERROR_ZONE_ALREADY_EXISTS: ::DWORD = 9609; +pub const DNS_ERROR_AUTOZONE_ALREADY_EXISTS: ::DWORD = 9610; +pub const DNS_ERROR_INVALID_ZONE_TYPE: ::DWORD = 9611; +pub const DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP: ::DWORD = 9612; +pub const DNS_ERROR_ZONE_NOT_SECONDARY: ::DWORD = 9613; +pub const DNS_ERROR_NEED_SECONDARY_ADDRESSES: ::DWORD = 9614; +pub const DNS_ERROR_WINS_INIT_FAILED: ::DWORD = 9615; +pub const DNS_ERROR_NEED_WINS_SERVERS: ::DWORD = 9616; +pub const DNS_ERROR_NBSTAT_INIT_FAILED: ::DWORD = 9617; +pub const DNS_ERROR_SOA_DELETE_INVALID: ::DWORD = 9618; +pub const DNS_ERROR_FORWARDER_ALREADY_EXISTS: ::DWORD = 9619; +pub const DNS_ERROR_ZONE_REQUIRES_MASTER_IP: ::DWORD = 9620; +pub const DNS_ERROR_ZONE_IS_SHUTDOWN: ::DWORD = 9621; +pub const DNS_ERROR_ZONE_LOCKED_FOR_SIGNING: ::DWORD = 9622; +pub const DNS_ERROR_DATAFILE_BASE: ::DWORD = 9650; +pub const DNS_ERROR_PRIMARY_REQUIRES_DATAFILE: ::DWORD = 9651; +pub const DNS_ERROR_INVALID_DATAFILE_NAME: ::DWORD = 9652; +pub const DNS_ERROR_DATAFILE_OPEN_FAILURE: ::DWORD = 9653; +pub const DNS_ERROR_FILE_WRITEBACK_FAILED: ::DWORD = 9654; +pub const DNS_ERROR_DATAFILE_PARSING: ::DWORD = 9655; +pub const DNS_ERROR_DATABASE_BASE: ::DWORD = 9700; +pub const DNS_ERROR_RECORD_DOES_NOT_EXIST: ::DWORD = 9701; +pub const DNS_ERROR_RECORD_FORMAT: ::DWORD = 9702; +pub const DNS_ERROR_NODE_CREATION_FAILED: ::DWORD = 9703; +pub const DNS_ERROR_UNKNOWN_RECORD_TYPE: ::DWORD = 9704; +pub const DNS_ERROR_RECORD_TIMED_OUT: ::DWORD = 9705; +pub const DNS_ERROR_NAME_NOT_IN_ZONE: ::DWORD = 9706; +pub const DNS_ERROR_CNAME_LOOP: ::DWORD = 9707; +pub const DNS_ERROR_NODE_IS_CNAME: ::DWORD = 9708; +pub const DNS_ERROR_CNAME_COLLISION: ::DWORD = 9709; +pub const DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT: ::DWORD = 9710; +pub const DNS_ERROR_RECORD_ALREADY_EXISTS: ::DWORD = 9711; +pub const DNS_ERROR_SECONDARY_DATA: ::DWORD = 9712; +pub const DNS_ERROR_NO_CREATE_CACHE_DATA: ::DWORD = 9713; +pub const DNS_ERROR_NAME_DOES_NOT_EXIST: ::DWORD = 9714; +pub const DNS_WARNING_PTR_CREATE_FAILED: ::DWORD = 9715; +pub const DNS_WARNING_DOMAIN_UNDELETED: ::DWORD = 9716; +pub const DNS_ERROR_DS_UNAVAILABLE: ::DWORD = 9717; +pub const DNS_ERROR_DS_ZONE_ALREADY_EXISTS: ::DWORD = 9718; +pub const DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE: ::DWORD = 9719; +pub const DNS_ERROR_NODE_IS_DNAME: ::DWORD = 9720; +pub const DNS_ERROR_DNAME_COLLISION: ::DWORD = 9721; +pub const DNS_ERROR_ALIAS_LOOP: ::DWORD = 9722; +pub const DNS_ERROR_OPERATION_BASE: ::DWORD = 9750; +pub const DNS_INFO_AXFR_COMPLETE: ::DWORD = 9751; +pub const DNS_ERROR_AXFR: ::DWORD = 9752; +pub const DNS_INFO_ADDED_LOCAL_WINS: ::DWORD = 9753; +pub const DNS_ERROR_SECURE_BASE: ::DWORD = 9800; +pub const DNS_STATUS_CONTINUE_NEEDED: ::DWORD = 9801; +pub const DNS_ERROR_SETUP_BASE: ::DWORD = 9850; +pub const DNS_ERROR_NO_TCPIP: ::DWORD = 9851; +pub const DNS_ERROR_NO_DNS_SERVERS: ::DWORD = 9852; +pub const DNS_ERROR_DP_BASE: ::DWORD = 9900; +pub const DNS_ERROR_DP_DOES_NOT_EXIST: ::DWORD = 9901; +pub const DNS_ERROR_DP_ALREADY_EXISTS: ::DWORD = 9902; +pub const DNS_ERROR_DP_NOT_ENLISTED: ::DWORD = 9903; +pub const DNS_ERROR_DP_ALREADY_ENLISTED: ::DWORD = 9904; +pub const DNS_ERROR_DP_NOT_AVAILABLE: ::DWORD = 9905; +pub const DNS_ERROR_DP_FSMO_ERROR: ::DWORD = 9906; +pub const DNS_ERROR_ZONESCOPE_ALREADY_EXISTS: ::DWORD = 9951; +pub const DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST: ::DWORD = 9952; +pub const DNS_ERROR_DEFAULT_ZONESCOPE: ::DWORD = 9953; +pub const DNS_ERROR_INVALID_ZONESCOPE_NAME: ::DWORD = 9954; +pub const DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES: ::DWORD = 9955; +pub const DNS_ERROR_LOAD_ZONESCOPE_FAILED: ::DWORD = 9956; +pub const DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED: ::DWORD = 9957; +pub const DNS_ERROR_INVALID_SCOPE_NAME: ::DWORD = 9958; +pub const DNS_ERROR_SCOPE_DOES_NOT_EXIST: ::DWORD = 9959; +pub const DNS_ERROR_DEFAULT_SCOPE: ::DWORD = 9960; +pub const DNS_ERROR_INVALID_SCOPE_OPERATION: ::DWORD = 9961; +pub const DNS_ERROR_SCOPE_LOCKED: ::DWORD = 9962; +pub const DNS_ERROR_SCOPE_ALREADY_EXISTS: ::DWORD = 9963; +pub const WSABASEERR: ::DWORD = 10000; +pub const WSAEINTR: ::DWORD = 10004; +pub const WSAEBADF: ::DWORD = 10009; +pub const WSAEACCES: ::DWORD = 10013; +pub const WSAEFAULT: ::DWORD = 10014; +pub const WSAEINVAL: ::DWORD = 10022; +pub const WSAEMFILE: ::DWORD = 10024; +pub const WSAEWOULDBLOCK: ::DWORD = 10035; +pub const WSAEINPROGRESS: ::DWORD = 10036; +pub const WSAEALREADY: ::DWORD = 10037; +pub const WSAENOTSOCK: ::DWORD = 10038; +pub const WSAEDESTADDRREQ: ::DWORD = 10039; +pub const WSAEMSGSIZE: ::DWORD = 10040; +pub const WSAEPROTOTYPE: ::DWORD = 10041; +pub const WSAENOPROTOOPT: ::DWORD = 10042; +pub const WSAEPROTONOSUPPORT: ::DWORD = 10043; +pub const WSAESOCKTNOSUPPORT: ::DWORD = 10044; +pub const WSAEOPNOTSUPP: ::DWORD = 10045; +pub const WSAEPFNOSUPPORT: ::DWORD = 10046; +pub const WSAEAFNOSUPPORT: ::DWORD = 10047; +pub const WSAEADDRINUSE: ::DWORD = 10048; +pub const WSAEADDRNOTAVAIL: ::DWORD = 10049; +pub const WSAENETDOWN: ::DWORD = 10050; +pub const WSAENETUNREACH: ::DWORD = 10051; +pub const WSAENETRESET: ::DWORD = 10052; +pub const WSAECONNABORTED: ::DWORD = 10053; +pub const WSAECONNRESET: ::DWORD = 10054; +pub const WSAENOBUFS: ::DWORD = 10055; +pub const WSAEISCONN: ::DWORD = 10056; +pub const WSAENOTCONN: ::DWORD = 10057; +pub const WSAESHUTDOWN: ::DWORD = 10058; +pub const WSAETOOMANYREFS: ::DWORD = 10059; +pub const WSAETIMEDOUT: ::DWORD = 10060; +pub const WSAECONNREFUSED: ::DWORD = 10061; +pub const WSAELOOP: ::DWORD = 10062; +pub const WSAENAMETOOLONG: ::DWORD = 10063; +pub const WSAEHOSTDOWN: ::DWORD = 10064; +pub const WSAEHOSTUNREACH: ::DWORD = 10065; +pub const WSAENOTEMPTY: ::DWORD = 10066; +pub const WSAEPROCLIM: ::DWORD = 10067; +pub const WSAEUSERS: ::DWORD = 10068; +pub const WSAEDQUOT: ::DWORD = 10069; +pub const WSAESTALE: ::DWORD = 10070; +pub const WSAEREMOTE: ::DWORD = 10071; +pub const WSASYSNOTREADY: ::DWORD = 10091; +pub const WSAVERNOTSUPPORTED: ::DWORD = 10092; +pub const WSANOTINITIALISED: ::DWORD = 10093; +pub const WSAEDISCON: ::DWORD = 10101; +pub const WSAENOMORE: ::DWORD = 10102; +pub const WSAECANCELLED: ::DWORD = 10103; +pub const WSAEINVALIDPROCTABLE: ::DWORD = 10104; +pub const WSAEINVALIDPROVIDER: ::DWORD = 10105; +pub const WSAEPROVIDERFAILEDINIT: ::DWORD = 10106; +pub const WSASYSCALLFAILURE: ::DWORD = 10107; +pub const WSASERVICE_NOT_FOUND: ::DWORD = 10108; +pub const WSATYPE_NOT_FOUND: ::DWORD = 10109; +pub const WSA_E_NO_MORE: ::DWORD = 10110; +pub const WSA_E_CANCELLED: ::DWORD = 10111; +pub const WSAEREFUSED: ::DWORD = 10112; +pub const WSAHOST_NOT_FOUND: ::DWORD = 11001; +pub const WSATRY_AGAIN: ::DWORD = 11002; +pub const WSANO_RECOVERY: ::DWORD = 11003; +pub const WSANO_DATA: ::DWORD = 11004; +pub const WSA_QOS_RECEIVERS: ::DWORD = 11005; +pub const WSA_QOS_SENDERS: ::DWORD = 11006; +pub const WSA_QOS_NO_SENDERS: ::DWORD = 11007; +pub const WSA_QOS_NO_RECEIVERS: ::DWORD = 11008; +pub const WSA_QOS_REQUEST_CONFIRMED: ::DWORD = 11009; +pub const WSA_QOS_ADMISSION_FAILURE: ::DWORD = 11010; +pub const WSA_QOS_POLICY_FAILURE: ::DWORD = 11011; +pub const WSA_QOS_BAD_STYLE: ::DWORD = 11012; +pub const WSA_QOS_BAD_OBJECT: ::DWORD = 11013; +pub const WSA_QOS_TRAFFIC_CTRL_ERROR: ::DWORD = 11014; +pub const WSA_QOS_GENERIC_ERROR: ::DWORD = 11015; +pub const WSA_QOS_ESERVICETYPE: ::DWORD = 11016; +pub const WSA_QOS_EFLOWSPEC: ::DWORD = 11017; +pub const WSA_QOS_EPROVSPECBUF: ::DWORD = 11018; +pub const WSA_QOS_EFILTERSTYLE: ::DWORD = 11019; +pub const WSA_QOS_EFILTERTYPE: ::DWORD = 11020; +pub const WSA_QOS_EFILTERCOUNT: ::DWORD = 11021; +pub const WSA_QOS_EOBJLENGTH: ::DWORD = 11022; +pub const WSA_QOS_EFLOWCOUNT: ::DWORD = 11023; +pub const WSA_QOS_EUNKOWNPSOBJ: ::DWORD = 11024; +pub const WSA_QOS_EPOLICYOBJ: ::DWORD = 11025; +pub const WSA_QOS_EFLOWDESC: ::DWORD = 11026; +pub const WSA_QOS_EPSFLOWSPEC: ::DWORD = 11027; +pub const WSA_QOS_EPSFILTERSPEC: ::DWORD = 11028; +pub const WSA_QOS_ESDMODEOBJ: ::DWORD = 11029; +pub const WSA_QOS_ESHAPERATEOBJ: ::DWORD = 11030; +pub const WSA_QOS_RESERVED_PETYPE: ::DWORD = 11031; +pub const WSA_SECURE_HOST_NOT_FOUND: ::DWORD = 11032; +pub const WSA_IPSEC_NAME_POLICY_ERROR: ::DWORD = 11033; +pub const ERROR_IPSEC_QM_POLICY_EXISTS: ::DWORD = 13000; +pub const ERROR_IPSEC_QM_POLICY_NOT_FOUND: ::DWORD = 13001; +pub const ERROR_IPSEC_QM_POLICY_IN_USE: ::DWORD = 13002; +pub const ERROR_IPSEC_MM_POLICY_EXISTS: ::DWORD = 13003; +pub const ERROR_IPSEC_MM_POLICY_NOT_FOUND: ::DWORD = 13004; +pub const ERROR_IPSEC_MM_POLICY_IN_USE: ::DWORD = 13005; +pub const ERROR_IPSEC_MM_FILTER_EXISTS: ::DWORD = 13006; +pub const ERROR_IPSEC_MM_FILTER_NOT_FOUND: ::DWORD = 13007; +pub const ERROR_IPSEC_TRANSPORT_FILTER_EXISTS: ::DWORD = 13008; +pub const ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND: ::DWORD = 13009; +pub const ERROR_IPSEC_MM_AUTH_EXISTS: ::DWORD = 13010; +pub const ERROR_IPSEC_MM_AUTH_NOT_FOUND: ::DWORD = 13011; +pub const ERROR_IPSEC_MM_AUTH_IN_USE: ::DWORD = 13012; +pub const ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND: ::DWORD = 13013; +pub const ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND: ::DWORD = 13014; +pub const ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND: ::DWORD = 13015; +pub const ERROR_IPSEC_TUNNEL_FILTER_EXISTS: ::DWORD = 13016; +pub const ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND: ::DWORD = 13017; +pub const ERROR_IPSEC_MM_FILTER_PENDING_DELETION: ::DWORD = 13018; +pub const ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION: ::DWORD = 13019; +pub const ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION: ::DWORD = 13020; +pub const ERROR_IPSEC_MM_POLICY_PENDING_DELETION: ::DWORD = 13021; +pub const ERROR_IPSEC_MM_AUTH_PENDING_DELETION: ::DWORD = 13022; +pub const ERROR_IPSEC_QM_POLICY_PENDING_DELETION: ::DWORD = 13023; +pub const WARNING_IPSEC_MM_POLICY_PRUNED: ::DWORD = 13024; +pub const WARNING_IPSEC_QM_POLICY_PRUNED: ::DWORD = 13025; +pub const ERROR_IPSEC_IKE_NEG_STATUS_BEGIN: ::DWORD = 13800; +pub const ERROR_IPSEC_IKE_AUTH_FAIL: ::DWORD = 13801; +pub const ERROR_IPSEC_IKE_ATTRIB_FAIL: ::DWORD = 13802; +pub const ERROR_IPSEC_IKE_NEGOTIATION_PENDING: ::DWORD = 13803; +pub const ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR: ::DWORD = 13804; +pub const ERROR_IPSEC_IKE_TIMED_OUT: ::DWORD = 13805; +pub const ERROR_IPSEC_IKE_NO_CERT: ::DWORD = 13806; +pub const ERROR_IPSEC_IKE_SA_DELETED: ::DWORD = 13807; +pub const ERROR_IPSEC_IKE_SA_REAPED: ::DWORD = 13808; +pub const ERROR_IPSEC_IKE_MM_ACQUIRE_DROP: ::DWORD = 13809; +pub const ERROR_IPSEC_IKE_QM_ACQUIRE_DROP: ::DWORD = 13810; +pub const ERROR_IPSEC_IKE_QUEUE_DROP_MM: ::DWORD = 13811; +pub const ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM: ::DWORD = 13812; +pub const ERROR_IPSEC_IKE_DROP_NO_RESPONSE: ::DWORD = 13813; +pub const ERROR_IPSEC_IKE_MM_DELAY_DROP: ::DWORD = 13814; +pub const ERROR_IPSEC_IKE_QM_DELAY_DROP: ::DWORD = 13815; +pub const ERROR_IPSEC_IKE_ERROR: ::DWORD = 13816; +pub const ERROR_IPSEC_IKE_CRL_FAILED: ::DWORD = 13817; +pub const ERROR_IPSEC_IKE_INVALID_KEY_USAGE: ::DWORD = 13818; +pub const ERROR_IPSEC_IKE_INVALID_CERT_TYPE: ::DWORD = 13819; +pub const ERROR_IPSEC_IKE_NO_PRIVATE_KEY: ::DWORD = 13820; +pub const ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY: ::DWORD = 13821; +pub const ERROR_IPSEC_IKE_DH_FAIL: ::DWORD = 13822; +pub const ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED: ::DWORD = 13823; +pub const ERROR_IPSEC_IKE_INVALID_HEADER: ::DWORD = 13824; +pub const ERROR_IPSEC_IKE_NO_POLICY: ::DWORD = 13825; +pub const ERROR_IPSEC_IKE_INVALID_SIGNATURE: ::DWORD = 13826; +pub const ERROR_IPSEC_IKE_KERBEROS_ERROR: ::DWORD = 13827; +pub const ERROR_IPSEC_IKE_NO_PUBLIC_KEY: ::DWORD = 13828; +pub const ERROR_IPSEC_IKE_PROCESS_ERR: ::DWORD = 13829; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_SA: ::DWORD = 13830; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_PROP: ::DWORD = 13831; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_TRANS: ::DWORD = 13832; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_KE: ::DWORD = 13833; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_ID: ::DWORD = 13834; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT: ::DWORD = 13835; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ: ::DWORD = 13836; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_HASH: ::DWORD = 13837; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_SIG: ::DWORD = 13838; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NONCE: ::DWORD = 13839; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY: ::DWORD = 13840; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_DELETE: ::DWORD = 13841; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR: ::DWORD = 13842; +pub const ERROR_IPSEC_IKE_INVALID_PAYLOAD: ::DWORD = 13843; +pub const ERROR_IPSEC_IKE_LOAD_SOFT_SA: ::DWORD = 13844; +pub const ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN: ::DWORD = 13845; +pub const ERROR_IPSEC_IKE_INVALID_COOKIE: ::DWORD = 13846; +pub const ERROR_IPSEC_IKE_NO_PEER_CERT: ::DWORD = 13847; +pub const ERROR_IPSEC_IKE_PEER_CRL_FAILED: ::DWORD = 13848; +pub const ERROR_IPSEC_IKE_POLICY_CHANGE: ::DWORD = 13849; +pub const ERROR_IPSEC_IKE_NO_MM_POLICY: ::DWORD = 13850; +pub const ERROR_IPSEC_IKE_NOTCBPRIV: ::DWORD = 13851; +pub const ERROR_IPSEC_IKE_SECLOADFAIL: ::DWORD = 13852; +pub const ERROR_IPSEC_IKE_FAILSSPINIT: ::DWORD = 13853; +pub const ERROR_IPSEC_IKE_FAILQUERYSSP: ::DWORD = 13854; +pub const ERROR_IPSEC_IKE_SRVACQFAIL: ::DWORD = 13855; +pub const ERROR_IPSEC_IKE_SRVQUERYCRED: ::DWORD = 13856; +pub const ERROR_IPSEC_IKE_GETSPIFAIL: ::DWORD = 13857; +pub const ERROR_IPSEC_IKE_INVALID_FILTER: ::DWORD = 13858; +pub const ERROR_IPSEC_IKE_OUT_OF_MEMORY: ::DWORD = 13859; +pub const ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED: ::DWORD = 13860; +pub const ERROR_IPSEC_IKE_INVALID_POLICY: ::DWORD = 13861; +pub const ERROR_IPSEC_IKE_UNKNOWN_DOI: ::DWORD = 13862; +pub const ERROR_IPSEC_IKE_INVALID_SITUATION: ::DWORD = 13863; +pub const ERROR_IPSEC_IKE_DH_FAILURE: ::DWORD = 13864; +pub const ERROR_IPSEC_IKE_INVALID_GROUP: ::DWORD = 13865; +pub const ERROR_IPSEC_IKE_ENCRYPT: ::DWORD = 13866; +pub const ERROR_IPSEC_IKE_DECRYPT: ::DWORD = 13867; +pub const ERROR_IPSEC_IKE_POLICY_MATCH: ::DWORD = 13868; +pub const ERROR_IPSEC_IKE_UNSUPPORTED_ID: ::DWORD = 13869; +pub const ERROR_IPSEC_IKE_INVALID_HASH: ::DWORD = 13870; +pub const ERROR_IPSEC_IKE_INVALID_HASH_ALG: ::DWORD = 13871; +pub const ERROR_IPSEC_IKE_INVALID_HASH_SIZE: ::DWORD = 13872; +pub const ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG: ::DWORD = 13873; +pub const ERROR_IPSEC_IKE_INVALID_AUTH_ALG: ::DWORD = 13874; +pub const ERROR_IPSEC_IKE_INVALID_SIG: ::DWORD = 13875; +pub const ERROR_IPSEC_IKE_LOAD_FAILED: ::DWORD = 13876; +pub const ERROR_IPSEC_IKE_RPC_DELETE: ::DWORD = 13877; +pub const ERROR_IPSEC_IKE_BENIGN_REINIT: ::DWORD = 13878; +pub const ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY: ::DWORD = 13879; +pub const ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION: ::DWORD = 13880; +pub const ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN: ::DWORD = 13881; +pub const ERROR_IPSEC_IKE_MM_LIMIT: ::DWORD = 13882; +pub const ERROR_IPSEC_IKE_NEGOTIATION_DISABLED: ::DWORD = 13883; +pub const ERROR_IPSEC_IKE_QM_LIMIT: ::DWORD = 13884; +pub const ERROR_IPSEC_IKE_MM_EXPIRED: ::DWORD = 13885; +pub const ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID: ::DWORD = 13886; +pub const ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH: ::DWORD = 13887; +pub const ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID: ::DWORD = 13888; +pub const ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD: ::DWORD = 13889; +pub const ERROR_IPSEC_IKE_DOS_COOKIE_SENT: ::DWORD = 13890; +pub const ERROR_IPSEC_IKE_SHUTTING_DOWN: ::DWORD = 13891; +pub const ERROR_IPSEC_IKE_CGA_AUTH_FAILED: ::DWORD = 13892; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NATOA: ::DWORD = 13893; +pub const ERROR_IPSEC_IKE_INVALID_MM_FOR_QM: ::DWORD = 13894; +pub const ERROR_IPSEC_IKE_QM_EXPIRED: ::DWORD = 13895; +pub const ERROR_IPSEC_IKE_TOO_MANY_FILTERS: ::DWORD = 13896; +pub const ERROR_IPSEC_IKE_NEG_STATUS_END: ::DWORD = 13897; +pub const ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL: ::DWORD = 13898; +pub const ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE: ::DWORD = 13899; +pub const ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING: ::DWORD = 13900; +pub const ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING: ::DWORD = 13901; +pub const ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS: ::DWORD = 13902; +pub const ERROR_IPSEC_IKE_RATELIMIT_DROP: ::DWORD = 13903; +pub const ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE: ::DWORD = 13904; +pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE: ::DWORD = 13905; +pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE: ::DWORD = 13906; +pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY: ::DWORD = 13907; +pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE: ::DWORD = 13908; +pub const ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END: ::DWORD = 13909; +pub const ERROR_IPSEC_BAD_SPI: ::DWORD = 13910; +pub const ERROR_IPSEC_SA_LIFETIME_EXPIRED: ::DWORD = 13911; +pub const ERROR_IPSEC_WRONG_SA: ::DWORD = 13912; +pub const ERROR_IPSEC_REPLAY_CHECK_FAILED: ::DWORD = 13913; +pub const ERROR_IPSEC_INVALID_PACKET: ::DWORD = 13914; +pub const ERROR_IPSEC_INTEGRITY_CHECK_FAILED: ::DWORD = 13915; +pub const ERROR_IPSEC_CLEAR_TEXT_DROP: ::DWORD = 13916; +pub const ERROR_IPSEC_AUTH_FIREWALL_DROP: ::DWORD = 13917; +pub const ERROR_IPSEC_THROTTLE_DROP: ::DWORD = 13918; +pub const ERROR_IPSEC_DOSP_BLOCK: ::DWORD = 13925; +pub const ERROR_IPSEC_DOSP_RECEIVED_MULTICAST: ::DWORD = 13926; +pub const ERROR_IPSEC_DOSP_INVALID_PACKET: ::DWORD = 13927; +pub const ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED: ::DWORD = 13928; +pub const ERROR_IPSEC_DOSP_MAX_ENTRIES: ::DWORD = 13929; +pub const ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: ::DWORD = 13930; +pub const ERROR_IPSEC_DOSP_NOT_INSTALLED: ::DWORD = 13931; +pub const ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: ::DWORD = 13932; +pub const ERROR_SXS_SECTION_NOT_FOUND: ::DWORD = 14000; +pub const ERROR_SXS_CANT_GEN_ACTCTX: ::DWORD = 14001; +pub const ERROR_SXS_INVALID_ACTCTXDATA_FORMAT: ::DWORD = 14002; +pub const ERROR_SXS_ASSEMBLY_NOT_FOUND: ::DWORD = 14003; +pub const ERROR_SXS_MANIFEST_FORMAT_ERROR: ::DWORD = 14004; +pub const ERROR_SXS_MANIFEST_PARSE_ERROR: ::DWORD = 14005; +pub const ERROR_SXS_ACTIVATION_CONTEXT_DISABLED: ::DWORD = 14006; +pub const ERROR_SXS_KEY_NOT_FOUND: ::DWORD = 14007; +pub const ERROR_SXS_VERSION_CONFLICT: ::DWORD = 14008; +pub const ERROR_SXS_WRONG_SECTION_TYPE: ::DWORD = 14009; +pub const ERROR_SXS_THREAD_QUERIES_DISABLED: ::DWORD = 14010; +pub const ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET: ::DWORD = 14011; +pub const ERROR_SXS_UNKNOWN_ENCODING_GROUP: ::DWORD = 14012; +pub const ERROR_SXS_UNKNOWN_ENCODING: ::DWORD = 14013; +pub const ERROR_SXS_INVALID_XML_NAMESPACE_URI: ::DWORD = 14014; +pub const ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED: ::DWORD = 14015; +pub const ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED: ::DWORD = 14016; +pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE: ::DWORD = 14017; +pub const ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE: ::DWORD = 14018; +pub const ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE: ::DWORD = 14019; +pub const ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT: ::DWORD = 14020; +pub const ERROR_SXS_DUPLICATE_DLL_NAME: ::DWORD = 14021; +pub const ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME: ::DWORD = 14022; +pub const ERROR_SXS_DUPLICATE_CLSID: ::DWORD = 14023; +pub const ERROR_SXS_DUPLICATE_IID: ::DWORD = 14024; +pub const ERROR_SXS_DUPLICATE_TLBID: ::DWORD = 14025; +pub const ERROR_SXS_DUPLICATE_PROGID: ::DWORD = 14026; +pub const ERROR_SXS_DUPLICATE_ASSEMBLY_NAME: ::DWORD = 14027; +pub const ERROR_SXS_FILE_HASH_MISMATCH: ::DWORD = 14028; +pub const ERROR_SXS_POLICY_PARSE_ERROR: ::DWORD = 14029; +pub const ERROR_SXS_XML_E_MISSINGQUOTE: ::DWORD = 14030; +pub const ERROR_SXS_XML_E_COMMENTSYNTAX: ::DWORD = 14031; +pub const ERROR_SXS_XML_E_BADSTARTNAMECHAR: ::DWORD = 14032; +pub const ERROR_SXS_XML_E_BADNAMECHAR: ::DWORD = 14033; +pub const ERROR_SXS_XML_E_BADCHARINSTRING: ::DWORD = 14034; +pub const ERROR_SXS_XML_E_XMLDECLSYNTAX: ::DWORD = 14035; +pub const ERROR_SXS_XML_E_BADCHARDATA: ::DWORD = 14036; +pub const ERROR_SXS_XML_E_MISSINGWHITESPACE: ::DWORD = 14037; +pub const ERROR_SXS_XML_E_EXPECTINGTAGEND: ::DWORD = 14038; +pub const ERROR_SXS_XML_E_MISSINGSEMICOLON: ::DWORD = 14039; +pub const ERROR_SXS_XML_E_UNBALANCEDPAREN: ::DWORD = 14040; +pub const ERROR_SXS_XML_E_INTERNALERROR: ::DWORD = 14041; +pub const ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE: ::DWORD = 14042; +pub const ERROR_SXS_XML_E_INCOMPLETE_ENCODING: ::DWORD = 14043; +pub const ERROR_SXS_XML_E_MISSING_PAREN: ::DWORD = 14044; +pub const ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE: ::DWORD = 14045; +pub const ERROR_SXS_XML_E_MULTIPLE_COLONS: ::DWORD = 14046; +pub const ERROR_SXS_XML_E_INVALID_DECIMAL: ::DWORD = 14047; +pub const ERROR_SXS_XML_E_INVALID_HEXIDECIMAL: ::DWORD = 14048; +pub const ERROR_SXS_XML_E_INVALID_UNICODE: ::DWORD = 14049; +pub const ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK: ::DWORD = 14050; +pub const ERROR_SXS_XML_E_UNEXPECTEDENDTAG: ::DWORD = 14051; +pub const ERROR_SXS_XML_E_UNCLOSEDTAG: ::DWORD = 14052; +pub const ERROR_SXS_XML_E_DUPLICATEATTRIBUTE: ::DWORD = 14053; +pub const ERROR_SXS_XML_E_MULTIPLEROOTS: ::DWORD = 14054; +pub const ERROR_SXS_XML_E_INVALIDATROOTLEVEL: ::DWORD = 14055; +pub const ERROR_SXS_XML_E_BADXMLDECL: ::DWORD = 14056; +pub const ERROR_SXS_XML_E_MISSINGROOT: ::DWORD = 14057; +pub const ERROR_SXS_XML_E_UNEXPECTEDEOF: ::DWORD = 14058; +pub const ERROR_SXS_XML_E_BADPEREFINSUBSET: ::DWORD = 14059; +pub const ERROR_SXS_XML_E_UNCLOSEDSTARTTAG: ::DWORD = 14060; +pub const ERROR_SXS_XML_E_UNCLOSEDENDTAG: ::DWORD = 14061; +pub const ERROR_SXS_XML_E_UNCLOSEDSTRING: ::DWORD = 14062; +pub const ERROR_SXS_XML_E_UNCLOSEDCOMMENT: ::DWORD = 14063; +pub const ERROR_SXS_XML_E_UNCLOSEDDECL: ::DWORD = 14064; +pub const ERROR_SXS_XML_E_UNCLOSEDCDATA: ::DWORD = 14065; +pub const ERROR_SXS_XML_E_RESERVEDNAMESPACE: ::DWORD = 14066; +pub const ERROR_SXS_XML_E_INVALIDENCODING: ::DWORD = 14067; +pub const ERROR_SXS_XML_E_INVALIDSWITCH: ::DWORD = 14068; +pub const ERROR_SXS_XML_E_BADXMLCASE: ::DWORD = 14069; +pub const ERROR_SXS_XML_E_INVALID_STANDALONE: ::DWORD = 14070; +pub const ERROR_SXS_XML_E_UNEXPECTED_STANDALONE: ::DWORD = 14071; +pub const ERROR_SXS_XML_E_INVALID_VERSION: ::DWORD = 14072; +pub const ERROR_SXS_XML_E_MISSINGEQUALS: ::DWORD = 14073; +pub const ERROR_SXS_PROTECTION_RECOVERY_FAILED: ::DWORD = 14074; +pub const ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT: ::DWORD = 14075; +pub const ERROR_SXS_PROTECTION_CATALOG_NOT_VALID: ::DWORD = 14076; +pub const ERROR_SXS_UNTRANSLATABLE_HRESULT: ::DWORD = 14077; +pub const ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING: ::DWORD = 14078; +pub const ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE: ::DWORD = 14079; +pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME: ::DWORD = 14080; +pub const ERROR_SXS_ASSEMBLY_MISSING: ::DWORD = 14081; +pub const ERROR_SXS_CORRUPT_ACTIVATION_STACK: ::DWORD = 14082; +pub const ERROR_SXS_CORRUPTION: ::DWORD = 14083; +pub const ERROR_SXS_EARLY_DEACTIVATION: ::DWORD = 14084; +pub const ERROR_SXS_INVALID_DEACTIVATION: ::DWORD = 14085; +pub const ERROR_SXS_MULTIPLE_DEACTIVATION: ::DWORD = 14086; +pub const ERROR_SXS_PROCESS_TERMINATION_REQUESTED: ::DWORD = 14087; +pub const ERROR_SXS_RELEASE_ACTIVATION_CONTEXT: ::DWORD = 14088; +pub const ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: ::DWORD = 14089; +pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: ::DWORD = 14090; +pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: ::DWORD = 14091; +pub const ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: ::DWORD = 14092; +pub const ERROR_SXS_IDENTITY_PARSE_ERROR: ::DWORD = 14093; +pub const ERROR_MALFORMED_SUBSTITUTION_STRING: ::DWORD = 14094; +pub const ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN: ::DWORD = 14095; +pub const ERROR_UNMAPPED_SUBSTITUTION_STRING: ::DWORD = 14096; +pub const ERROR_SXS_ASSEMBLY_NOT_LOCKED: ::DWORD = 14097; +pub const ERROR_SXS_COMPONENT_STORE_CORRUPT: ::DWORD = 14098; +pub const ERROR_ADVANCED_INSTALLER_FAILED: ::DWORD = 14099; +pub const ERROR_XML_ENCODING_MISMATCH: ::DWORD = 14100; +pub const ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: ::DWORD = 14101; +pub const ERROR_SXS_IDENTITIES_DIFFERENT: ::DWORD = 14102; +pub const ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: ::DWORD = 14103; +pub const ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY: ::DWORD = 14104; +pub const ERROR_SXS_MANIFEST_TOO_BIG: ::DWORD = 14105; +pub const ERROR_SXS_SETTING_NOT_REGISTERED: ::DWORD = 14106; +pub const ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE: ::DWORD = 14107; +pub const ERROR_SMI_PRIMITIVE_INSTALLER_FAILED: ::DWORD = 14108; +pub const ERROR_GENERIC_COMMAND_FAILED: ::DWORD = 14109; +pub const ERROR_SXS_FILE_HASH_MISSING: ::DWORD = 14110; +pub const ERROR_EVT_INVALID_CHANNEL_PATH: ::DWORD = 15000; +pub const ERROR_EVT_INVALID_QUERY: ::DWORD = 15001; +pub const ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND: ::DWORD = 15002; +pub const ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND: ::DWORD = 15003; +pub const ERROR_EVT_INVALID_PUBLISHER_NAME: ::DWORD = 15004; +pub const ERROR_EVT_INVALID_EVENT_DATA: ::DWORD = 15005; +pub const ERROR_EVT_CHANNEL_NOT_FOUND: ::DWORD = 15007; +pub const ERROR_EVT_MALFORMED_XML_TEXT: ::DWORD = 15008; +pub const ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL: ::DWORD = 15009; +pub const ERROR_EVT_CONFIGURATION_ERROR: ::DWORD = 15010; +pub const ERROR_EVT_QUERY_RESULT_STALE: ::DWORD = 15011; +pub const ERROR_EVT_QUERY_RESULT_INVALID_POSITION: ::DWORD = 15012; +pub const ERROR_EVT_NON_VALIDATING_MSXML: ::DWORD = 15013; +pub const ERROR_EVT_FILTER_ALREADYSCOPED: ::DWORD = 15014; +pub const ERROR_EVT_FILTER_NOTELTSET: ::DWORD = 15015; +pub const ERROR_EVT_FILTER_INVARG: ::DWORD = 15016; +pub const ERROR_EVT_FILTER_INVTEST: ::DWORD = 15017; +pub const ERROR_EVT_FILTER_INVTYPE: ::DWORD = 15018; +pub const ERROR_EVT_FILTER_PARSEERR: ::DWORD = 15019; +pub const ERROR_EVT_FILTER_UNSUPPORTEDOP: ::DWORD = 15020; +pub const ERROR_EVT_FILTER_UNEXPECTEDTOKEN: ::DWORD = 15021; +pub const ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL: ::DWORD = 15022; +pub const ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE: ::DWORD = 15023; +pub const ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE: ::DWORD = 15024; +pub const ERROR_EVT_CHANNEL_CANNOT_ACTIVATE: ::DWORD = 15025; +pub const ERROR_EVT_FILTER_TOO_COMPLEX: ::DWORD = 15026; +pub const ERROR_EVT_MESSAGE_NOT_FOUND: ::DWORD = 15027; +pub const ERROR_EVT_MESSAGE_ID_NOT_FOUND: ::DWORD = 15028; +pub const ERROR_EVT_UNRESOLVED_VALUE_INSERT: ::DWORD = 15029; +pub const ERROR_EVT_UNRESOLVED_PARAMETER_INSERT: ::DWORD = 15030; +pub const ERROR_EVT_MAX_INSERTS_REACHED: ::DWORD = 15031; +pub const ERROR_EVT_EVENT_DEFINITION_NOT_FOUND: ::DWORD = 15032; +pub const ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND: ::DWORD = 15033; +pub const ERROR_EVT_VERSION_TOO_OLD: ::DWORD = 15034; +pub const ERROR_EVT_VERSION_TOO_NEW: ::DWORD = 15035; +pub const ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY: ::DWORD = 15036; +pub const ERROR_EVT_PUBLISHER_DISABLED: ::DWORD = 15037; +pub const ERROR_EVT_FILTER_OUT_OF_RANGE: ::DWORD = 15038; +pub const ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE: ::DWORD = 15080; +pub const ERROR_EC_LOG_DISABLED: ::DWORD = 15081; +pub const ERROR_EC_CIRCULAR_FORWARDING: ::DWORD = 15082; +pub const ERROR_EC_CREDSTORE_FULL: ::DWORD = 15083; +pub const ERROR_EC_CRED_NOT_FOUND: ::DWORD = 15084; +pub const ERROR_EC_NO_ACTIVE_CHANNEL: ::DWORD = 15085; +pub const ERROR_MUI_FILE_NOT_FOUND: ::DWORD = 15100; +pub const ERROR_MUI_INVALID_FILE: ::DWORD = 15101; +pub const ERROR_MUI_INVALID_RC_CONFIG: ::DWORD = 15102; +pub const ERROR_MUI_INVALID_LOCALE_NAME: ::DWORD = 15103; +pub const ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME: ::DWORD = 15104; +pub const ERROR_MUI_FILE_NOT_LOADED: ::DWORD = 15105; +pub const ERROR_RESOURCE_ENUM_USER_STOP: ::DWORD = 15106; +pub const ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED: ::DWORD = 15107; +pub const ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME: ::DWORD = 15108; +pub const ERROR_MRM_RUNTIME_NO_DEFAULT_OR_NEUTRAL_RESOURCE: ::DWORD = 15110; +pub const ERROR_MRM_INVALID_PRICONFIG: ::DWORD = 15111; +pub const ERROR_MRM_INVALID_FILE_TYPE: ::DWORD = 15112; +pub const ERROR_MRM_UNKNOWN_QUALIFIER: ::DWORD = 15113; +pub const ERROR_MRM_INVALID_QUALIFIER_VALUE: ::DWORD = 15114; +pub const ERROR_MRM_NO_CANDIDATE: ::DWORD = 15115; +pub const ERROR_MRM_NO_MATCH_OR_DEFAULT_CANDIDATE: ::DWORD = 15116; +pub const ERROR_MRM_RESOURCE_TYPE_MISMATCH: ::DWORD = 15117; +pub const ERROR_MRM_DUPLICATE_MAP_NAME: ::DWORD = 15118; +pub const ERROR_MRM_DUPLICATE_ENTRY: ::DWORD = 15119; +pub const ERROR_MRM_INVALID_RESOURCE_IDENTIFIER: ::DWORD = 15120; +pub const ERROR_MRM_FILEPATH_TOO_LONG: ::DWORD = 15121; +pub const ERROR_MRM_UNSUPPORTED_DIRECTORY_TYPE: ::DWORD = 15122; +pub const ERROR_MRM_INVALID_PRI_FILE: ::DWORD = 15126; +pub const ERROR_MRM_NAMED_RESOURCE_NOT_FOUND: ::DWORD = 15127; +pub const ERROR_MRM_MAP_NOT_FOUND: ::DWORD = 15135; +pub const ERROR_MRM_UNSUPPORTED_PROFILE_TYPE: ::DWORD = 15136; +pub const ERROR_MRM_INVALID_QUALIFIER_OPERATOR: ::DWORD = 15137; +pub const ERROR_MRM_INDETERMINATE_QUALIFIER_VALUE: ::DWORD = 15138; +pub const ERROR_MRM_AUTOMERGE_ENABLED: ::DWORD = 15139; +pub const ERROR_MRM_TOO_MANY_RESOURCES: ::DWORD = 15140; +pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_MERGE: ::DWORD = 15141; +pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_LOAD_UNLOAD_PRI_FILE: ::DWORD = 15142; +pub const ERROR_MRM_NO_CURRENT_VIEW_ON_THREAD: ::DWORD = 15143; +pub const ERROR_DIFFERENT_PROFILE_RESOURCE_MANAGER_EXIST: ::DWORD = 15144; +pub const ERROR_OPERATION_NOT_ALLOWED_FROM_SYSTEM_COMPONENT: ::DWORD = 15145; +pub const ERROR_MRM_DIRECT_REF_TO_NON_DEFAULT_RESOURCE: ::DWORD = 15146; +pub const ERROR_MRM_GENERATION_COUNT_MISMATCH: ::DWORD = 15147; +pub const ERROR_MCA_INVALID_CAPABILITIES_STRING: ::DWORD = 15200; +pub const ERROR_MCA_INVALID_VCP_VERSION: ::DWORD = 15201; +pub const ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: ::DWORD = 15202; +pub const ERROR_MCA_MCCS_VERSION_MISMATCH: ::DWORD = 15203; +pub const ERROR_MCA_UNSUPPORTED_MCCS_VERSION: ::DWORD = 15204; +pub const ERROR_MCA_INTERNAL_ERROR: ::DWORD = 15205; +pub const ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: ::DWORD = 15206; +pub const ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE: ::DWORD = 15207; +pub const ERROR_AMBIGUOUS_SYSTEM_DEVICE: ::DWORD = 15250; +pub const ERROR_SYSTEM_DEVICE_NOT_FOUND: ::DWORD = 15299; +pub const ERROR_HASH_NOT_SUPPORTED: ::DWORD = 15300; +pub const ERROR_HASH_NOT_PRESENT: ::DWORD = 15301; +pub const ERROR_SECONDARY_IC_PROVIDER_NOT_REGISTERED: ::DWORD = 15321; +pub const ERROR_GPIO_CLIENT_INFORMATION_INVALID: ::DWORD = 15322; +pub const ERROR_GPIO_VERSION_NOT_SUPPORTED: ::DWORD = 15323; +pub const ERROR_GPIO_INVALID_REGISTRATION_PACKET: ::DWORD = 15324; +pub const ERROR_GPIO_OPERATION_DENIED: ::DWORD = 15325; +pub const ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE: ::DWORD = 15326; +pub const ERROR_GPIO_INTERRUPT_ALREADY_UNMASKED: ::DWORD = 15327; +pub const ERROR_CANNOT_SWITCH_RUNLEVEL: ::DWORD = 15400; +pub const ERROR_INVALID_RUNLEVEL_SETTING: ::DWORD = 15401; +pub const ERROR_RUNLEVEL_SWITCH_TIMEOUT: ::DWORD = 15402; +pub const ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT: ::DWORD = 15403; +pub const ERROR_RUNLEVEL_SWITCH_IN_PROGRESS: ::DWORD = 15404; +pub const ERROR_SERVICES_FAILED_AUTOSTART: ::DWORD = 15405; +pub const ERROR_COM_TASK_STOP_PENDING: ::DWORD = 15501; +pub const ERROR_INSTALL_OPEN_PACKAGE_FAILED: ::DWORD = 15600; +pub const ERROR_INSTALL_PACKAGE_NOT_FOUND: ::DWORD = 15601; +pub const ERROR_INSTALL_INVALID_PACKAGE: ::DWORD = 15602; +pub const ERROR_INSTALL_RESOLVE_DEPENDENCY_FAILED: ::DWORD = 15603; +pub const ERROR_INSTALL_OUT_OF_DISK_SPACE: ::DWORD = 15604; +pub const ERROR_INSTALL_NETWORK_FAILURE: ::DWORD = 15605; +pub const ERROR_INSTALL_REGISTRATION_FAILURE: ::DWORD = 15606; +pub const ERROR_INSTALL_DEREGISTRATION_FAILURE: ::DWORD = 15607; +pub const ERROR_INSTALL_CANCEL: ::DWORD = 15608; +pub const ERROR_INSTALL_FAILED: ::DWORD = 15609; +pub const ERROR_REMOVE_FAILED: ::DWORD = 15610; +pub const ERROR_PACKAGE_ALREADY_EXISTS: ::DWORD = 15611; +pub const ERROR_NEEDS_REMEDIATION: ::DWORD = 15612; +pub const ERROR_INSTALL_PREREQUISITE_FAILED: ::DWORD = 15613; +pub const ERROR_PACKAGE_REPOSITORY_CORRUPTED: ::DWORD = 15614; +pub const ERROR_INSTALL_POLICY_FAILURE: ::DWORD = 15615; +pub const ERROR_PACKAGE_UPDATING: ::DWORD = 15616; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_POLICY: ::DWORD = 15617; +pub const ERROR_PACKAGES_IN_USE: ::DWORD = 15618; +pub const ERROR_RECOVERY_FILE_CORRUPT: ::DWORD = 15619; +pub const ERROR_INVALID_STAGED_SIGNATURE: ::DWORD = 15620; +pub const ERROR_DELETING_EXISTING_APPLICATIONDATA_STORE_FAILED: ::DWORD = 15621; +pub const ERROR_INSTALL_PACKAGE_DOWNGRADE: ::DWORD = 15622; +pub const ERROR_SYSTEM_NEEDS_REMEDIATION: ::DWORD = 15623; +pub const ERROR_APPX_INTEGRITY_FAILURE_CLR_NGEN: ::DWORD = 15624; +pub const ERROR_RESILIENCY_FILE_CORRUPT: ::DWORD = 15625; +pub const ERROR_INSTALL_FIREWALL_SERVICE_NOT_RUNNING: ::DWORD = 15626; +pub const APPMODEL_ERROR_NO_PACKAGE: ::DWORD = 15700; +pub const APPMODEL_ERROR_PACKAGE_RUNTIME_CORRUPT: ::DWORD = 15701; +pub const APPMODEL_ERROR_PACKAGE_IDENTITY_CORRUPT: ::DWORD = 15702; +pub const APPMODEL_ERROR_NO_APPLICATION: ::DWORD = 15703; +pub const APPMODEL_ERROR_DYNAMIC_PROPERTY_READ_FAILED: ::DWORD = 15704; +pub const APPMODEL_ERROR_DYNAMIC_PROPERTY_INVALID: ::DWORD = 15705; +pub const ERROR_STATE_LOAD_STORE_FAILED: ::DWORD = 15800; +pub const ERROR_STATE_GET_VERSION_FAILED: ::DWORD = 15801; +pub const ERROR_STATE_SET_VERSION_FAILED: ::DWORD = 15802; +pub const ERROR_STATE_STRUCTURED_RESET_FAILED: ::DWORD = 15803; +pub const ERROR_STATE_OPEN_CONTAINER_FAILED: ::DWORD = 15804; +pub const ERROR_STATE_CREATE_CONTAINER_FAILED: ::DWORD = 15805; +pub const ERROR_STATE_DELETE_CONTAINER_FAILED: ::DWORD = 15806; +pub const ERROR_STATE_READ_SETTING_FAILED: ::DWORD = 15807; +pub const ERROR_STATE_WRITE_SETTING_FAILED: ::DWORD = 15808; +pub const ERROR_STATE_DELETE_SETTING_FAILED: ::DWORD = 15809; +pub const ERROR_STATE_QUERY_SETTING_FAILED: ::DWORD = 15810; +pub const ERROR_STATE_READ_COMPOSITE_SETTING_FAILED: ::DWORD = 15811; +pub const ERROR_STATE_WRITE_COMPOSITE_SETTING_FAILED: ::DWORD = 15812; +pub const ERROR_STATE_ENUMERATE_CONTAINER_FAILED: ::DWORD = 15813; +pub const ERROR_STATE_ENUMERATE_SETTINGS_FAILED: ::DWORD = 15814; +pub const ERROR_STATE_COMPOSITE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: ::DWORD = 15815; +pub const ERROR_STATE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: ::DWORD = 15816; +pub const ERROR_STATE_SETTING_NAME_SIZE_LIMIT_EXCEEDED: ::DWORD = 15817; +pub const ERROR_STATE_CONTAINER_NAME_SIZE_LIMIT_EXCEEDED: ::DWORD = 15818; +pub const ERROR_API_UNAVAILABLE: ::DWORD = 15841; +pub const STORE_ERROR_UNLICENSED: ::DWORD = 15861; +pub const STORE_ERROR_UNLICENSED_USER: ::DWORD = 15862; +pub const STORE_ERROR_PENDING_COM_TRANSACTION: ::DWORD = 15863; +pub const STORE_ERROR_LICENSE_REVOKED: ::DWORD = 15864; +pub const SEVERITY_SUCCESS: HRESULT = 0; +pub const SEVERITY_ERROR: HRESULT = 1; +pub type HRESULT = ::c_long; +pub const NOERROR: HRESULT = 0; +pub const E_UNEXPECTED: HRESULT = 0x8000FFFFu32 as HRESULT; +pub const E_NOTIMPL: HRESULT = 0x80004001u32 as HRESULT; +pub const E_OUTOFMEMORY: HRESULT = 0x8007000Eu32 as HRESULT; +pub const E_INVALIDARG: HRESULT = 0x80070057u32 as HRESULT; +pub const E_NOINTERFACE: HRESULT = 0x80004002u32 as HRESULT; +pub const E_POINTER: HRESULT = 0x80004003u32 as HRESULT; +pub const E_HANDLE: HRESULT = 0x80070006u32 as HRESULT; +pub const E_ABORT: HRESULT = 0x80004004u32 as HRESULT; +pub const E_FAIL: HRESULT = 0x80004005u32 as HRESULT; +pub const E_ACCESSDENIED: HRESULT = 0x80070005u32 as HRESULT; +pub const E_PENDING: HRESULT = 0x8000000Au32 as HRESULT; +pub const E_BOUNDS: HRESULT = 0x8000000Bu32 as HRESULT; +pub const E_CHANGED_STATE: HRESULT = 0x8000000Cu32 as HRESULT; +pub const E_ILLEGAL_STATE_CHANGE: HRESULT = 0x8000000Du32 as HRESULT; +pub const E_ILLEGAL_METHOD_CALL: HRESULT = 0x8000000Eu32 as HRESULT; +pub const RO_E_METADATA_NAME_NOT_FOUND: HRESULT = 0x8000000Fu32 as HRESULT; +pub const RO_E_METADATA_NAME_IS_NAMESPACE: HRESULT = 0x80000010u32 as HRESULT; +pub const RO_E_METADATA_INVALID_TYPE_FORMAT: HRESULT = 0x80000011u32 as HRESULT; +pub const RO_E_INVALID_METADATA_FILE: HRESULT = 0x80000012u32 as HRESULT; +pub const RO_E_CLOSED: HRESULT = 0x80000013u32 as HRESULT; +pub const RO_E_EXCLUSIVE_WRITE: HRESULT = 0x80000014u32 as HRESULT; +pub const RO_E_CHANGE_NOTIFICATION_IN_PROGRESS: HRESULT = 0x80000015u32 as HRESULT; +pub const RO_E_ERROR_STRING_NOT_FOUND: HRESULT = 0x80000016u32 as HRESULT; +pub const E_STRING_NOT_NULL_TERMINATED: HRESULT = 0x80000017u32 as HRESULT; +pub const E_ILLEGAL_DELEGATE_ASSIGNMENT: HRESULT = 0x80000018u32 as HRESULT; +pub const E_ASYNC_OPERATION_NOT_STARTED: HRESULT = 0x80000019u32 as HRESULT; +pub const E_APPLICATION_EXITING: HRESULT = 0x8000001Au32 as HRESULT; +pub const E_APPLICATION_VIEW_EXITING: HRESULT = 0x8000001Bu32 as HRESULT; +pub const RO_E_MUST_BE_AGILE: HRESULT = 0x8000001Cu32 as HRESULT; +pub const RO_E_UNSUPPORTED_FROM_MTA: HRESULT = 0x8000001Du32 as HRESULT; +pub const RO_E_COMMITTED: HRESULT = 0x8000001Eu32 as HRESULT; +pub const RO_E_BLOCKED_CROSS_ASTA_CALL: HRESULT = 0x8000001Fu32 as HRESULT; +pub const CO_E_INIT_TLS: HRESULT = 0x80004006u32 as HRESULT; +pub const CO_E_INIT_SHARED_ALLOCATOR: HRESULT = 0x80004007u32 as HRESULT; +pub const CO_E_INIT_MEMORY_ALLOCATOR: HRESULT = 0x80004008u32 as HRESULT; +pub const CO_E_INIT_CLASS_CACHE: HRESULT = 0x80004009u32 as HRESULT; +pub const CO_E_INIT_RPC_CHANNEL: HRESULT = 0x8000400Au32 as HRESULT; +pub const CO_E_INIT_TLS_SET_CHANNEL_CONTROL: HRESULT = 0x8000400Bu32 as HRESULT; +pub const CO_E_INIT_TLS_CHANNEL_CONTROL: HRESULT = 0x8000400Cu32 as HRESULT; +pub const CO_E_INIT_UNACCEPTED_USER_ALLOCATOR: HRESULT = 0x8000400Du32 as HRESULT; +pub const CO_E_INIT_SCM_MUTEX_EXISTS: HRESULT = 0x8000400Eu32 as HRESULT; +pub const CO_E_INIT_SCM_FILE_MAPPING_EXISTS: HRESULT = 0x8000400Fu32 as HRESULT; +pub const CO_E_INIT_SCM_MAP_VIEW_OF_FILE: HRESULT = 0x80004010u32 as HRESULT; +pub const CO_E_INIT_SCM_EXEC_FAILURE: HRESULT = 0x80004011u32 as HRESULT; +pub const CO_E_INIT_ONLY_SINGLE_THREADED: HRESULT = 0x80004012u32 as HRESULT; +pub const CO_E_CANT_REMOTE: HRESULT = 0x80004013u32 as HRESULT; +pub const CO_E_BAD_SERVER_NAME: HRESULT = 0x80004014u32 as HRESULT; +pub const CO_E_WRONG_SERVER_IDENTITY: HRESULT = 0x80004015u32 as HRESULT; +pub const CO_E_OLE1DDE_DISABLED: HRESULT = 0x80004016u32 as HRESULT; +pub const CO_E_RUNAS_SYNTAX: HRESULT = 0x80004017u32 as HRESULT; +pub const CO_E_CREATEPROCESS_FAILURE: HRESULT = 0x80004018u32 as HRESULT; +pub const CO_E_RUNAS_CREATEPROCESS_FAILURE: HRESULT = 0x80004019u32 as HRESULT; +pub const CO_E_RUNAS_LOGON_FAILURE: HRESULT = 0x8000401Au32 as HRESULT; +pub const CO_E_LAUNCH_PERMSSION_DENIED: HRESULT = 0x8000401Bu32 as HRESULT; +pub const CO_E_START_SERVICE_FAILURE: HRESULT = 0x8000401Cu32 as HRESULT; +pub const CO_E_REMOTE_COMMUNICATION_FAILURE: HRESULT = 0x8000401Du32 as HRESULT; +pub const CO_E_SERVER_START_TIMEOUT: HRESULT = 0x8000401Eu32 as HRESULT; +pub const CO_E_CLSREG_INCONSISTENT: HRESULT = 0x8000401Fu32 as HRESULT; +pub const CO_E_IIDREG_INCONSISTENT: HRESULT = 0x80004020u32 as HRESULT; +pub const CO_E_NOT_SUPPORTED: HRESULT = 0x80004021u32 as HRESULT; +pub const CO_E_RELOAD_DLL: HRESULT = 0x80004022u32 as HRESULT; +pub const CO_E_MSI_ERROR: HRESULT = 0x80004023u32 as HRESULT; +pub const CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT: HRESULT = 0x80004024u32 as HRESULT; +pub const CO_E_SERVER_PAUSED: HRESULT = 0x80004025u32 as HRESULT; +pub const CO_E_SERVER_NOT_PAUSED: HRESULT = 0x80004026u32 as HRESULT; +pub const CO_E_CLASS_DISABLED: HRESULT = 0x80004027u32 as HRESULT; +pub const CO_E_CLRNOTAVAILABLE: HRESULT = 0x80004028u32 as HRESULT; +pub const CO_E_ASYNC_WORK_REJECTED: HRESULT = 0x80004029u32 as HRESULT; +pub const CO_E_SERVER_INIT_TIMEOUT: HRESULT = 0x8000402Au32 as HRESULT; +pub const CO_E_NO_SECCTX_IN_ACTIVATE: HRESULT = 0x8000402Bu32 as HRESULT; +pub const CO_E_TRACKER_CONFIG: HRESULT = 0x80004030u32 as HRESULT; +pub const CO_E_THREADPOOL_CONFIG: HRESULT = 0x80004031u32 as HRESULT; +pub const CO_E_SXS_CONFIG: HRESULT = 0x80004032u32 as HRESULT; +pub const CO_E_MALFORMED_SPN: HRESULT = 0x80004033u32 as HRESULT; +pub const CO_E_UNREVOKED_REGISTRATION_ON_APARTMENT_SHUTDOWN: HRESULT = 0x80004034u32 as HRESULT; +pub const CO_E_PREMATURE_STUB_RUNDOWN: HRESULT = 0x80004035u32 as HRESULT; +pub const S_OK: HRESULT = 0; +pub const S_FALSE: HRESULT = 1; +pub const OLE_E_FIRST: HRESULT = 0x80040000u32 as HRESULT; +pub const OLE_E_LAST: HRESULT = 0x800400FFu32 as HRESULT; +pub const OLE_S_FIRST: HRESULT = 0x00040000; +pub const OLE_S_LAST: HRESULT = 0x000400FF; +pub const OLE_E_OLEVERB: HRESULT = 0x80040000u32 as HRESULT; +pub const OLE_E_ADVF: HRESULT = 0x80040001u32 as HRESULT; +pub const OLE_E_ENUM_NOMORE: HRESULT = 0x80040002u32 as HRESULT; +pub const OLE_E_ADVISENOTSUPPORTED: HRESULT = 0x80040003u32 as HRESULT; +pub const OLE_E_NOCONNECTION: HRESULT = 0x80040004u32 as HRESULT; +pub const OLE_E_NOTRUNNING: HRESULT = 0x80040005u32 as HRESULT; +pub const OLE_E_NOCACHE: HRESULT = 0x80040006u32 as HRESULT; +pub const OLE_E_BLANK: HRESULT = 0x80040007u32 as HRESULT; +pub const OLE_E_CLASSDIFF: HRESULT = 0x80040008u32 as HRESULT; +pub const OLE_E_CANT_GETMONIKER: HRESULT = 0x80040009u32 as HRESULT; +pub const OLE_E_CANT_BINDTOSOURCE: HRESULT = 0x8004000Au32 as HRESULT; +pub const OLE_E_STATIC: HRESULT = 0x8004000Bu32 as HRESULT; +pub const OLE_E_PROMPTSAVECANCELLED: HRESULT = 0x8004000Cu32 as HRESULT; +pub const OLE_E_INVALIDRECT: HRESULT = 0x8004000Du32 as HRESULT; +pub const OLE_E_WRONGCOMPOBJ: HRESULT = 0x8004000Eu32 as HRESULT; +pub const OLE_E_INVALIDHWND: HRESULT = 0x8004000Fu32 as HRESULT; +pub const OLE_E_NOT_INPLACEACTIVE: HRESULT = 0x80040010u32 as HRESULT; +pub const OLE_E_CANTCONVERT: HRESULT = 0x80040011u32 as HRESULT; +pub const OLE_E_NOSTORAGE: HRESULT = 0x80040012u32 as HRESULT; +pub const DV_E_FORMATETC: HRESULT = 0x80040064u32 as HRESULT; +pub const DV_E_DVTARGETDEVICE: HRESULT = 0x80040065u32 as HRESULT; +pub const DV_E_STGMEDIUM: HRESULT = 0x80040066u32 as HRESULT; +pub const DV_E_STATDATA: HRESULT = 0x80040067u32 as HRESULT; +pub const DV_E_LINDEX: HRESULT = 0x80040068u32 as HRESULT; +pub const DV_E_TYMED: HRESULT = 0x80040069u32 as HRESULT; +pub const DV_E_CLIPFORMAT: HRESULT = 0x8004006Au32 as HRESULT; +pub const DV_E_DVASPECT: HRESULT = 0x8004006Bu32 as HRESULT; +pub const DV_E_DVTARGETDEVICE_SIZE: HRESULT = 0x8004006Cu32 as HRESULT; +pub const DV_E_NOIVIEWOBJECT: HRESULT = 0x8004006Du32 as HRESULT; +pub const DRAGDROP_E_FIRST: HRESULT = 0x80040100u32 as HRESULT; +pub const DRAGDROP_E_LAST: HRESULT = 0x8004010Fu32 as HRESULT; +pub const DRAGDROP_S_FIRST: HRESULT = 0x00040100; +pub const DRAGDROP_S_LAST: HRESULT = 0x0004010F; +pub const DRAGDROP_E_NOTREGISTERED: HRESULT = 0x80040100u32 as HRESULT; +pub const DRAGDROP_E_ALREADYREGISTERED: HRESULT = 0x80040101u32 as HRESULT; +pub const DRAGDROP_E_INVALIDHWND: HRESULT = 0x80040102u32 as HRESULT; +pub const DRAGDROP_E_CONCURRENT_DRAG_ATTEMPTED: HRESULT = 0x80040103u32 as HRESULT; +pub const CLASSFACTORY_E_FIRST: HRESULT = 0x80040110u32 as HRESULT; +pub const CLASSFACTORY_E_LAST: HRESULT = 0x8004011Fu32 as HRESULT; +pub const CLASSFACTORY_S_FIRST: HRESULT = 0x00040110; +pub const CLASSFACTORY_S_LAST: HRESULT = 0x0004011F; +pub const CLASS_E_NOAGGREGATION: HRESULT = 0x80040110u32 as HRESULT; +pub const CLASS_E_CLASSNOTAVAILABLE: HRESULT = 0x80040111u32 as HRESULT; +pub const CLASS_E_NOTLICENSED: HRESULT = 0x80040112u32 as HRESULT; +pub const MARSHAL_E_FIRST: HRESULT = 0x80040120u32 as HRESULT; +pub const MARSHAL_E_LAST: HRESULT = 0x8004012Fu32 as HRESULT; +pub const MARSHAL_S_FIRST: HRESULT = 0x00040120; +pub const MARSHAL_S_LAST: HRESULT = 0x0004012F; +pub const DATA_E_FIRST: HRESULT = 0x80040130u32 as HRESULT; +pub const DATA_E_LAST: HRESULT = 0x8004013Fu32 as HRESULT; +pub const DATA_S_FIRST: HRESULT = 0x00040130; +pub const DATA_S_LAST: HRESULT = 0x0004013F; +pub const VIEW_E_FIRST: HRESULT = 0x80040140u32 as HRESULT; +pub const VIEW_E_LAST: HRESULT = 0x8004014Fu32 as HRESULT; +pub const VIEW_S_FIRST: HRESULT = 0x00040140; +pub const VIEW_S_LAST: HRESULT = 0x0004014F; +pub const VIEW_E_DRAW: HRESULT = 0x80040140u32 as HRESULT; +pub const REGDB_E_FIRST: HRESULT = 0x80040150u32 as HRESULT; +pub const REGDB_E_LAST: HRESULT = 0x8004015Fu32 as HRESULT; +pub const REGDB_S_FIRST: HRESULT = 0x00040150; +pub const REGDB_S_LAST: HRESULT = 0x0004015F; +pub const REGDB_E_READREGDB: HRESULT = 0x80040150u32 as HRESULT; +pub const REGDB_E_WRITEREGDB: HRESULT = 0x80040151u32 as HRESULT; +pub const REGDB_E_KEYMISSING: HRESULT = 0x80040152u32 as HRESULT; +pub const REGDB_E_INVALIDVALUE: HRESULT = 0x80040153u32 as HRESULT; +pub const REGDB_E_CLASSNOTREG: HRESULT = 0x80040154u32 as HRESULT; +pub const REGDB_E_IIDNOTREG: HRESULT = 0x80040155u32 as HRESULT; +pub const REGDB_E_BADTHREADINGMODEL: HRESULT = 0x80040156u32 as HRESULT; +pub const CAT_E_FIRST: HRESULT = 0x80040160u32 as HRESULT; +pub const CAT_E_LAST: HRESULT = 0x80040161u32 as HRESULT; +pub const CAT_E_CATIDNOEXIST: HRESULT = 0x80040160u32 as HRESULT; +pub const CAT_E_NODESCRIPTION: HRESULT = 0x80040161u32 as HRESULT; +pub const CS_E_FIRST: HRESULT = 0x80040164u32 as HRESULT; +pub const CS_E_LAST: HRESULT = 0x8004016Fu32 as HRESULT; +pub const CS_E_PACKAGE_NOTFOUND: HRESULT = 0x80040164u32 as HRESULT; +pub const CS_E_NOT_DELETABLE: HRESULT = 0x80040165u32 as HRESULT; +pub const CS_E_CLASS_NOTFOUND: HRESULT = 0x80040166u32 as HRESULT; +pub const CS_E_INVALID_VERSION: HRESULT = 0x80040167u32 as HRESULT; +pub const CS_E_NO_CLASSSTORE: HRESULT = 0x80040168u32 as HRESULT; +pub const CS_E_OBJECT_NOTFOUND: HRESULT = 0x80040169u32 as HRESULT; +pub const CS_E_OBJECT_ALREADY_EXISTS: HRESULT = 0x8004016Au32 as HRESULT; +pub const CS_E_INVALID_PATH: HRESULT = 0x8004016Bu32 as HRESULT; +pub const CS_E_NETWORK_ERROR: HRESULT = 0x8004016Cu32 as HRESULT; +pub const CS_E_ADMIN_LIMIT_EXCEEDED: HRESULT = 0x8004016Du32 as HRESULT; +pub const CS_E_SCHEMA_MISMATCH: HRESULT = 0x8004016Eu32 as HRESULT; +pub const CS_E_INTERNAL_ERROR: HRESULT = 0x8004016Fu32 as HRESULT; +pub const CACHE_E_FIRST: HRESULT = 0x80040170u32 as HRESULT; +pub const CACHE_E_LAST: HRESULT = 0x8004017Fu32 as HRESULT; +pub const CACHE_S_FIRST: HRESULT = 0x00040170; +pub const CACHE_S_LAST: HRESULT = 0x0004017F; +pub const CACHE_E_NOCACHE_UPDATED: HRESULT = 0x80040170u32 as HRESULT; +pub const OLEOBJ_E_FIRST: HRESULT = 0x80040180u32 as HRESULT; +pub const OLEOBJ_E_LAST: HRESULT = 0x8004018Fu32 as HRESULT; +pub const OLEOBJ_S_FIRST: HRESULT = 0x00040180; +pub const OLEOBJ_S_LAST: HRESULT = 0x0004018F; +pub const OLEOBJ_E_NOVERBS: HRESULT = 0x80040180u32 as HRESULT; +pub const OLEOBJ_E_INVALIDVERB: HRESULT = 0x80040181u32 as HRESULT; +pub const CLIENTSITE_E_FIRST: HRESULT = 0x80040190u32 as HRESULT; +pub const CLIENTSITE_E_LAST: HRESULT = 0x8004019Fu32 as HRESULT; +pub const CLIENTSITE_S_FIRST: HRESULT = 0x00040190; +pub const CLIENTSITE_S_LAST: HRESULT = 0x0004019F; +pub const INPLACE_E_NOTUNDOABLE: HRESULT = 0x800401A0u32 as HRESULT; +pub const INPLACE_E_NOTOOLSPACE: HRESULT = 0x800401A1u32 as HRESULT; +pub const INPLACE_E_FIRST: HRESULT = 0x800401A0u32 as HRESULT; +pub const INPLACE_E_LAST: HRESULT = 0x800401AFu32 as HRESULT; +pub const INPLACE_S_FIRST: HRESULT = 0x000401A0; +pub const INPLACE_S_LAST: HRESULT = 0x000401AF; +pub const ENUM_E_FIRST: HRESULT = 0x800401B0u32 as HRESULT; +pub const ENUM_E_LAST: HRESULT = 0x800401BFu32 as HRESULT; +pub const ENUM_S_FIRST: HRESULT = 0x000401B0; +pub const ENUM_S_LAST: HRESULT = 0x000401BF; +pub const CONVERT10_E_FIRST: HRESULT = 0x800401C0u32 as HRESULT; +pub const CONVERT10_E_LAST: HRESULT = 0x800401CFu32 as HRESULT; +pub const CONVERT10_S_FIRST: HRESULT = 0x000401C0; +pub const CONVERT10_S_LAST: HRESULT = 0x000401CF; +pub const CONVERT10_E_OLESTREAM_GET: HRESULT = 0x800401C0u32 as HRESULT; +pub const CONVERT10_E_OLESTREAM_PUT: HRESULT = 0x800401C1u32 as HRESULT; +pub const CONVERT10_E_OLESTREAM_FMT: HRESULT = 0x800401C2u32 as HRESULT; +pub const CONVERT10_E_OLESTREAM_BITMAP_TO_DIB: HRESULT = 0x800401C3u32 as HRESULT; +pub const CONVERT10_E_STG_FMT: HRESULT = 0x800401C4u32 as HRESULT; +pub const CONVERT10_E_STG_NO_STD_STREAM: HRESULT = 0x800401C5u32 as HRESULT; +pub const CONVERT10_E_STG_DIB_TO_BITMAP: HRESULT = 0x800401C6u32 as HRESULT; +pub const CLIPBRD_E_FIRST: HRESULT = 0x800401D0u32 as HRESULT; +pub const CLIPBRD_E_LAST: HRESULT = 0x800401DFu32 as HRESULT; +pub const CLIPBRD_S_FIRST: HRESULT = 0x000401D0; +pub const CLIPBRD_S_LAST: HRESULT = 0x000401DF; +pub const CLIPBRD_E_CANT_OPEN: HRESULT = 0x800401D0u32 as HRESULT; +pub const CLIPBRD_E_CANT_EMPTY: HRESULT = 0x800401D1u32 as HRESULT; +pub const CLIPBRD_E_CANT_SET: HRESULT = 0x800401D2u32 as HRESULT; +pub const CLIPBRD_E_BAD_DATA: HRESULT = 0x800401D3u32 as HRESULT; +pub const CLIPBRD_E_CANT_CLOSE: HRESULT = 0x800401D4u32 as HRESULT; +pub const MK_E_FIRST: HRESULT = 0x800401E0u32 as HRESULT; +pub const MK_E_LAST: HRESULT = 0x800401EFu32 as HRESULT; +pub const MK_S_FIRST: HRESULT = 0x000401E0; +pub const MK_S_LAST: HRESULT = 0x000401EF; +pub const MK_E_CONNECTMANUALLY: HRESULT = 0x800401E0u32 as HRESULT; +pub const MK_E_EXCEEDEDDEADLINE: HRESULT = 0x800401E1u32 as HRESULT; +pub const MK_E_NEEDGENERIC: HRESULT = 0x800401E2u32 as HRESULT; +pub const MK_E_UNAVAILABLE: HRESULT = 0x800401E3u32 as HRESULT; +pub const MK_E_SYNTAX: HRESULT = 0x800401E4u32 as HRESULT; +pub const MK_E_NOOBJECT: HRESULT = 0x800401E5u32 as HRESULT; +pub const MK_E_INVALIDEXTENSION: HRESULT = 0x800401E6u32 as HRESULT; +pub const MK_E_INTERMEDIATEINTERFACENOTSUPPORTED: HRESULT = 0x800401E7u32 as HRESULT; +pub const MK_E_NOTBINDABLE: HRESULT = 0x800401E8u32 as HRESULT; +pub const MK_E_NOTBOUND: HRESULT = 0x800401E9u32 as HRESULT; +pub const MK_E_CANTOPENFILE: HRESULT = 0x800401EAu32 as HRESULT; +pub const MK_E_MUSTBOTHERUSER: HRESULT = 0x800401EBu32 as HRESULT; +pub const MK_E_NOINVERSE: HRESULT = 0x800401ECu32 as HRESULT; +pub const MK_E_NOSTORAGE: HRESULT = 0x800401EDu32 as HRESULT; +pub const MK_E_NOPREFIX: HRESULT = 0x800401EEu32 as HRESULT; +pub const MK_E_ENUMERATION_FAILED: HRESULT = 0x800401EFu32 as HRESULT; +pub const CO_E_FIRST: HRESULT = 0x800401F0u32 as HRESULT; +pub const CO_E_LAST: HRESULT = 0x800401FFu32 as HRESULT; +pub const CO_S_FIRST: HRESULT = 0x000401F0; +pub const CO_S_LAST: HRESULT = 0x000401FF; +pub const CO_E_NOTINITIALIZED: HRESULT = 0x800401F0u32 as HRESULT; +pub const CO_E_ALREADYINITIALIZED: HRESULT = 0x800401F1u32 as HRESULT; +pub const CO_E_CANTDETERMINECLASS: HRESULT = 0x800401F2u32 as HRESULT; +pub const CO_E_CLASSSTRING: HRESULT = 0x800401F3u32 as HRESULT; +pub const CO_E_IIDSTRING: HRESULT = 0x800401F4u32 as HRESULT; +pub const CO_E_APPNOTFOUND: HRESULT = 0x800401F5u32 as HRESULT; +pub const CO_E_APPSINGLEUSE: HRESULT = 0x800401F6u32 as HRESULT; +pub const CO_E_ERRORINAPP: HRESULT = 0x800401F7u32 as HRESULT; +pub const CO_E_DLLNOTFOUND: HRESULT = 0x800401F8u32 as HRESULT; +pub const CO_E_ERRORINDLL: HRESULT = 0x800401F9u32 as HRESULT; +pub const CO_E_WRONGOSFORAPP: HRESULT = 0x800401FAu32 as HRESULT; +pub const CO_E_OBJNOTREG: HRESULT = 0x800401FBu32 as HRESULT; +pub const CO_E_OBJISREG: HRESULT = 0x800401FCu32 as HRESULT; +pub const CO_E_OBJNOTCONNECTED: HRESULT = 0x800401FDu32 as HRESULT; +pub const CO_E_APPDIDNTREG: HRESULT = 0x800401FEu32 as HRESULT; +pub const CO_E_RELEASED: HRESULT = 0x800401FFu32 as HRESULT; +pub const EVENT_E_FIRST: HRESULT = 0x80040200u32 as HRESULT; +pub const EVENT_E_LAST: HRESULT = 0x8004021Fu32 as HRESULT; +pub const EVENT_S_FIRST: HRESULT = 0x00040200; +pub const EVENT_S_LAST: HRESULT = 0x0004021F; +pub const EVENT_S_SOME_SUBSCRIBERS_FAILED: HRESULT = 0x00040200; +pub const EVENT_E_ALL_SUBSCRIBERS_FAILED: HRESULT = 0x80040201u32 as HRESULT; +pub const EVENT_S_NOSUBSCRIBERS: HRESULT = 0x00040202; +pub const EVENT_E_QUERYSYNTAX: HRESULT = 0x80040203u32 as HRESULT; +pub const EVENT_E_QUERYFIELD: HRESULT = 0x80040204u32 as HRESULT; +pub const EVENT_E_INTERNALEXCEPTION: HRESULT = 0x80040205u32 as HRESULT; +pub const EVENT_E_INTERNALERROR: HRESULT = 0x80040206u32 as HRESULT; +pub const EVENT_E_INVALID_PER_USER_SID: HRESULT = 0x80040207u32 as HRESULT; +pub const EVENT_E_USER_EXCEPTION: HRESULT = 0x80040208u32 as HRESULT; +pub const EVENT_E_TOO_MANY_METHODS: HRESULT = 0x80040209u32 as HRESULT; +pub const EVENT_E_MISSING_EVENTCLASS: HRESULT = 0x8004020Au32 as HRESULT; +pub const EVENT_E_NOT_ALL_REMOVED: HRESULT = 0x8004020Bu32 as HRESULT; +pub const EVENT_E_COMPLUS_NOT_INSTALLED: HRESULT = 0x8004020Cu32 as HRESULT; +pub const EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT: HRESULT = 0x8004020Du32 as HRESULT; +pub const EVENT_E_CANT_MODIFY_OR_DELETE_CONFIGURED_OBJECT: HRESULT = 0x8004020Eu32 as HRESULT; +pub const EVENT_E_INVALID_EVENT_CLASS_PARTITION: HRESULT = 0x8004020Fu32 as HRESULT; +pub const EVENT_E_PER_USER_SID_NOT_LOGGED_ON: HRESULT = 0x80040210u32 as HRESULT; +pub const TPC_E_INVALID_PROPERTY: HRESULT = 0x80040241u32 as HRESULT; +pub const TPC_E_NO_DEFAULT_TABLET: HRESULT = 0x80040212u32 as HRESULT; +pub const TPC_E_UNKNOWN_PROPERTY: HRESULT = 0x8004021Bu32 as HRESULT; +pub const TPC_E_INVALID_INPUT_RECT: HRESULT = 0x80040219u32 as HRESULT; +pub const TPC_E_INVALID_STROKE: HRESULT = 0x80040222u32 as HRESULT; +pub const TPC_E_INITIALIZE_FAIL: HRESULT = 0x80040223u32 as HRESULT; +pub const TPC_E_NOT_RELEVANT: HRESULT = 0x80040232u32 as HRESULT; +pub const TPC_E_INVALID_PACKET_DESCRIPTION: HRESULT = 0x80040233u32 as HRESULT; +pub const TPC_E_RECOGNIZER_NOT_REGISTERED: HRESULT = 0x80040235u32 as HRESULT; +pub const TPC_E_INVALID_RIGHTS: HRESULT = 0x80040236u32 as HRESULT; +pub const TPC_E_OUT_OF_ORDER_CALL: HRESULT = 0x80040237u32 as HRESULT; +pub const TPC_E_QUEUE_FULL: HRESULT = 0x80040238u32 as HRESULT; +pub const TPC_E_INVALID_CONFIGURATION: HRESULT = 0x80040239u32 as HRESULT; +pub const TPC_E_INVALID_DATA_FROM_RECOGNIZER: HRESULT = 0x8004023Au32 as HRESULT; +pub const TPC_S_TRUNCATED: HRESULT = 0x00040252; +pub const TPC_S_INTERRUPTED: HRESULT = 0x00040253; +pub const TPC_S_NO_DATA_TO_PROCESS: HRESULT = 0x00040254; +pub const XACT_E_FIRST: HRESULT = 0x8004D000u32 as HRESULT; +pub const XACT_E_LAST: HRESULT = 0x8004D02Bu32 as HRESULT; +pub const XACT_S_FIRST: HRESULT = 0x0004D000; +pub const XACT_S_LAST: HRESULT = 0x0004D010; +pub const XACT_E_ALREADYOTHERSINGLEPHASE: HRESULT = 0x8004D000u32 as HRESULT; +pub const XACT_E_CANTRETAIN: HRESULT = 0x8004D001u32 as HRESULT; +pub const XACT_E_COMMITFAILED: HRESULT = 0x8004D002u32 as HRESULT; +pub const XACT_E_COMMITPREVENTED: HRESULT = 0x8004D003u32 as HRESULT; +pub const XACT_E_HEURISTICABORT: HRESULT = 0x8004D004u32 as HRESULT; +pub const XACT_E_HEURISTICCOMMIT: HRESULT = 0x8004D005u32 as HRESULT; +pub const XACT_E_HEURISTICDAMAGE: HRESULT = 0x8004D006u32 as HRESULT; +pub const XACT_E_HEURISTICDANGER: HRESULT = 0x8004D007u32 as HRESULT; +pub const XACT_E_ISOLATIONLEVEL: HRESULT = 0x8004D008u32 as HRESULT; +pub const XACT_E_NOASYNC: HRESULT = 0x8004D009u32 as HRESULT; +pub const XACT_E_NOENLIST: HRESULT = 0x8004D00Au32 as HRESULT; +pub const XACT_E_NOISORETAIN: HRESULT = 0x8004D00Bu32 as HRESULT; +pub const XACT_E_NORESOURCE: HRESULT = 0x8004D00Cu32 as HRESULT; +pub const XACT_E_NOTCURRENT: HRESULT = 0x8004D00Du32 as HRESULT; +pub const XACT_E_NOTRANSACTION: HRESULT = 0x8004D00Eu32 as HRESULT; +pub const XACT_E_NOTSUPPORTED: HRESULT = 0x8004D00Fu32 as HRESULT; +pub const XACT_E_UNKNOWNRMGRID: HRESULT = 0x8004D010u32 as HRESULT; +pub const XACT_E_WRONGSTATE: HRESULT = 0x8004D011u32 as HRESULT; +pub const XACT_E_WRONGUOW: HRESULT = 0x8004D012u32 as HRESULT; +pub const XACT_E_XTIONEXISTS: HRESULT = 0x8004D013u32 as HRESULT; +pub const XACT_E_NOIMPORTOBJECT: HRESULT = 0x8004D014u32 as HRESULT; +pub const XACT_E_INVALIDCOOKIE: HRESULT = 0x8004D015u32 as HRESULT; +pub const XACT_E_INDOUBT: HRESULT = 0x8004D016u32 as HRESULT; +pub const XACT_E_NOTIMEOUT: HRESULT = 0x8004D017u32 as HRESULT; +pub const XACT_E_ALREADYINPROGRESS: HRESULT = 0x8004D018u32 as HRESULT; +pub const XACT_E_ABORTED: HRESULT = 0x8004D019u32 as HRESULT; +pub const XACT_E_LOGFULL: HRESULT = 0x8004D01Au32 as HRESULT; +pub const XACT_E_TMNOTAVAILABLE: HRESULT = 0x8004D01Bu32 as HRESULT; +pub const XACT_E_CONNECTION_DOWN: HRESULT = 0x8004D01Cu32 as HRESULT; +pub const XACT_E_CONNECTION_DENIED: HRESULT = 0x8004D01Du32 as HRESULT; +pub const XACT_E_REENLISTTIMEOUT: HRESULT = 0x8004D01Eu32 as HRESULT; +pub const XACT_E_TIP_CONNECT_FAILED: HRESULT = 0x8004D01Fu32 as HRESULT; +pub const XACT_E_TIP_PROTOCOL_ERROR: HRESULT = 0x8004D020u32 as HRESULT; +pub const XACT_E_TIP_PULL_FAILED: HRESULT = 0x8004D021u32 as HRESULT; +pub const XACT_E_DEST_TMNOTAVAILABLE: HRESULT = 0x8004D022u32 as HRESULT; +pub const XACT_E_TIP_DISABLED: HRESULT = 0x8004D023u32 as HRESULT; +pub const XACT_E_NETWORK_TX_DISABLED: HRESULT = 0x8004D024u32 as HRESULT; +pub const XACT_E_PARTNER_NETWORK_TX_DISABLED: HRESULT = 0x8004D025u32 as HRESULT; +pub const XACT_E_XA_TX_DISABLED: HRESULT = 0x8004D026u32 as HRESULT; +pub const XACT_E_UNABLE_TO_READ_DTC_CONFIG: HRESULT = 0x8004D027u32 as HRESULT; +pub const XACT_E_UNABLE_TO_LOAD_DTC_PROXY: HRESULT = 0x8004D028u32 as HRESULT; +pub const XACT_E_ABORTING: HRESULT = 0x8004D029u32 as HRESULT; +pub const XACT_E_PUSH_COMM_FAILURE: HRESULT = 0x8004D02Au32 as HRESULT; +pub const XACT_E_PULL_COMM_FAILURE: HRESULT = 0x8004D02Bu32 as HRESULT; +pub const XACT_E_LU_TX_DISABLED: HRESULT = 0x8004D02Cu32 as HRESULT; +pub const XACT_E_CLERKNOTFOUND: HRESULT = 0x8004D080u32 as HRESULT; +pub const XACT_E_CLERKEXISTS: HRESULT = 0x8004D081u32 as HRESULT; +pub const XACT_E_RECOVERYINPROGRESS: HRESULT = 0x8004D082u32 as HRESULT; +pub const XACT_E_TRANSACTIONCLOSED: HRESULT = 0x8004D083u32 as HRESULT; +pub const XACT_E_INVALIDLSN: HRESULT = 0x8004D084u32 as HRESULT; +pub const XACT_E_REPLAYREQUEST: HRESULT = 0x8004D085u32 as HRESULT; +pub const XACT_S_ASYNC: HRESULT = 0x0004D000; +pub const XACT_S_DEFECT: HRESULT = 0x0004D001; +pub const XACT_S_READONLY: HRESULT = 0x0004D002; +pub const XACT_S_SOMENORETAIN: HRESULT = 0x0004D003; +pub const XACT_S_OKINFORM: HRESULT = 0x0004D004; +pub const XACT_S_MADECHANGESCONTENT: HRESULT = 0x0004D005; +pub const XACT_S_MADECHANGESINFORM: HRESULT = 0x0004D006; +pub const XACT_S_ALLNORETAIN: HRESULT = 0x0004D007; +pub const XACT_S_ABORTING: HRESULT = 0x0004D008; +pub const XACT_S_SINGLEPHASE: HRESULT = 0x0004D009; +pub const XACT_S_LOCALLY_OK: HRESULT = 0x0004D00A; +pub const XACT_S_LASTRESOURCEMANAGER: HRESULT = 0x0004D010; +pub const CONTEXT_E_FIRST: HRESULT = 0x8004E000u32 as HRESULT; +pub const CONTEXT_E_LAST: HRESULT = 0x8004E02Fu32 as HRESULT; +pub const CONTEXT_S_FIRST: HRESULT = 0x0004E000; +pub const CONTEXT_S_LAST: HRESULT = 0x0004E02F; +pub const CONTEXT_E_ABORTED: HRESULT = 0x8004E002u32 as HRESULT; +pub const CONTEXT_E_ABORTING: HRESULT = 0x8004E003u32 as HRESULT; +pub const CONTEXT_E_NOCONTEXT: HRESULT = 0x8004E004u32 as HRESULT; +pub const CONTEXT_E_WOULD_DEADLOCK: HRESULT = 0x8004E005u32 as HRESULT; +pub const CONTEXT_E_SYNCH_TIMEOUT: HRESULT = 0x8004E006u32 as HRESULT; +pub const CONTEXT_E_OLDREF: HRESULT = 0x8004E007u32 as HRESULT; +pub const CONTEXT_E_ROLENOTFOUND: HRESULT = 0x8004E00Cu32 as HRESULT; +pub const CONTEXT_E_TMNOTAVAILABLE: HRESULT = 0x8004E00Fu32 as HRESULT; +pub const CO_E_ACTIVATIONFAILED: HRESULT = 0x8004E021u32 as HRESULT; +pub const CO_E_ACTIVATIONFAILED_EVENTLOGGED: HRESULT = 0x8004E022u32 as HRESULT; +pub const CO_E_ACTIVATIONFAILED_CATALOGERROR: HRESULT = 0x8004E023u32 as HRESULT; +pub const CO_E_ACTIVATIONFAILED_TIMEOUT: HRESULT = 0x8004E024u32 as HRESULT; +pub const CO_E_INITIALIZATIONFAILED: HRESULT = 0x8004E025u32 as HRESULT; +pub const CONTEXT_E_NOJIT: HRESULT = 0x8004E026u32 as HRESULT; +pub const CONTEXT_E_NOTRANSACTION: HRESULT = 0x8004E027u32 as HRESULT; +pub const CO_E_THREADINGMODEL_CHANGED: HRESULT = 0x8004E028u32 as HRESULT; +pub const CO_E_NOIISINTRINSICS: HRESULT = 0x8004E029u32 as HRESULT; +pub const CO_E_NOCOOKIES: HRESULT = 0x8004E02Au32 as HRESULT; +pub const CO_E_DBERROR: HRESULT = 0x8004E02Bu32 as HRESULT; +pub const CO_E_NOTPOOLED: HRESULT = 0x8004E02Cu32 as HRESULT; +pub const CO_E_NOTCONSTRUCTED: HRESULT = 0x8004E02Du32 as HRESULT; +pub const CO_E_NOSYNCHRONIZATION: HRESULT = 0x8004E02Eu32 as HRESULT; +pub const CO_E_ISOLEVELMISMATCH: HRESULT = 0x8004E02Fu32 as HRESULT; +pub const CO_E_CALL_OUT_OF_TX_SCOPE_NOT_ALLOWED: HRESULT = 0x8004E030u32 as HRESULT; +pub const CO_E_EXIT_TRANSACTION_SCOPE_NOT_CALLED: HRESULT = 0x8004E031u32 as HRESULT; +pub const OLE_S_USEREG: HRESULT = 0x00040000; +pub const OLE_S_STATIC: HRESULT = 0x00040001; +pub const OLE_S_MAC_CLIPFORMAT: HRESULT = 0x00040002; +pub const DRAGDROP_S_DROP: HRESULT = 0x00040100; +pub const DRAGDROP_S_CANCEL: HRESULT = 0x00040101; +pub const DRAGDROP_S_USEDEFAULTCURSORS: HRESULT = 0x00040102; +pub const DATA_S_SAMEFORMATETC: HRESULT = 0x00040130; +pub const VIEW_S_ALREADY_FROZEN: HRESULT = 0x00040140; +pub const CACHE_S_FORMATETC_NOTSUPPORTED: HRESULT = 0x00040170; +pub const CACHE_S_SAMECACHE: HRESULT = 0x00040171; +pub const CACHE_S_SOMECACHES_NOTUPDATED: HRESULT = 0x00040172; +pub const OLEOBJ_S_INVALIDVERB: HRESULT = 0x00040180; +pub const OLEOBJ_S_CANNOT_DOVERB_NOW: HRESULT = 0x00040181; +pub const OLEOBJ_S_INVALIDHWND: HRESULT = 0x00040182; +pub const INPLACE_S_TRUNCATED: HRESULT = 0x000401A0; +pub const CONVERT10_S_NO_PRESENTATION: HRESULT = 0x000401C0; +pub const MK_S_REDUCED_TO_SELF: HRESULT = 0x000401E2; +pub const MK_S_ME: HRESULT = 0x000401E4; +pub const MK_S_HIM: HRESULT = 0x000401E5; +pub const MK_S_US: HRESULT = 0x000401E6; +pub const MK_S_MONIKERALREADYREGISTERED: HRESULT = 0x000401E7; +pub const SCHED_S_TASK_READY: HRESULT = 0x00041300; +pub const SCHED_S_TASK_RUNNING: HRESULT = 0x00041301; +pub const SCHED_S_TASK_DISABLED: HRESULT = 0x00041302; +pub const SCHED_S_TASK_HAS_NOT_RUN: HRESULT = 0x00041303; +pub const SCHED_S_TASK_NO_MORE_RUNS: HRESULT = 0x00041304; +pub const SCHED_S_TASK_NOT_SCHEDULED: HRESULT = 0x00041305; +pub const SCHED_S_TASK_TERMINATED: HRESULT = 0x00041306; +pub const SCHED_S_TASK_NO_VALID_TRIGGERS: HRESULT = 0x00041307; +pub const SCHED_S_EVENT_TRIGGER: HRESULT = 0x00041308; +pub const SCHED_E_TRIGGER_NOT_FOUND: HRESULT = 0x80041309u32 as HRESULT; +pub const SCHED_E_TASK_NOT_READY: HRESULT = 0x8004130Au32 as HRESULT; +pub const SCHED_E_TASK_NOT_RUNNING: HRESULT = 0x8004130Bu32 as HRESULT; +pub const SCHED_E_SERVICE_NOT_INSTALLED: HRESULT = 0x8004130Cu32 as HRESULT; +pub const SCHED_E_CANNOT_OPEN_TASK: HRESULT = 0x8004130Du32 as HRESULT; +pub const SCHED_E_INVALID_TASK: HRESULT = 0x8004130Eu32 as HRESULT; +pub const SCHED_E_ACCOUNT_INFORMATION_NOT_SET: HRESULT = 0x8004130Fu32 as HRESULT; +pub const SCHED_E_ACCOUNT_NAME_NOT_FOUND: HRESULT = 0x80041310u32 as HRESULT; +pub const SCHED_E_ACCOUNT_DBASE_CORRUPT: HRESULT = 0x80041311u32 as HRESULT; +pub const SCHED_E_NO_SECURITY_SERVICES: HRESULT = 0x80041312u32 as HRESULT; +pub const SCHED_E_UNKNOWN_OBJECT_VERSION: HRESULT = 0x80041313u32 as HRESULT; +pub const SCHED_E_UNSUPPORTED_ACCOUNT_OPTION: HRESULT = 0x80041314u32 as HRESULT; +pub const SCHED_E_SERVICE_NOT_RUNNING: HRESULT = 0x80041315u32 as HRESULT; +pub const SCHED_E_UNEXPECTEDNODE: HRESULT = 0x80041316u32 as HRESULT; +pub const SCHED_E_NAMESPACE: HRESULT = 0x80041317u32 as HRESULT; +pub const SCHED_E_INVALIDVALUE: HRESULT = 0x80041318u32 as HRESULT; +pub const SCHED_E_MISSINGNODE: HRESULT = 0x80041319u32 as HRESULT; +pub const SCHED_E_MALFORMEDXML: HRESULT = 0x8004131Au32 as HRESULT; +pub const SCHED_S_SOME_TRIGGERS_FAILED: HRESULT = 0x0004131B; +pub const SCHED_S_BATCH_LOGON_PROBLEM: HRESULT = 0x0004131C; +pub const SCHED_E_TOO_MANY_NODES: HRESULT = 0x8004131Du32 as HRESULT; +pub const SCHED_E_PAST_END_BOUNDARY: HRESULT = 0x8004131Eu32 as HRESULT; +pub const SCHED_E_ALREADY_RUNNING: HRESULT = 0x8004131Fu32 as HRESULT; +pub const SCHED_E_USER_NOT_LOGGED_ON: HRESULT = 0x80041320u32 as HRESULT; +pub const SCHED_E_INVALID_TASK_HASH: HRESULT = 0x80041321u32 as HRESULT; +pub const SCHED_E_SERVICE_NOT_AVAILABLE: HRESULT = 0x80041322u32 as HRESULT; +pub const SCHED_E_SERVICE_TOO_BUSY: HRESULT = 0x80041323u32 as HRESULT; +pub const SCHED_E_TASK_ATTEMPTED: HRESULT = 0x80041324u32 as HRESULT; +pub const SCHED_S_TASK_QUEUED: HRESULT = 0x00041325; +pub const SCHED_E_TASK_DISABLED: HRESULT = 0x80041326u32 as HRESULT; +pub const SCHED_E_TASK_NOT_V1_COMPAT: HRESULT = 0x80041327u32 as HRESULT; +pub const SCHED_E_START_ON_DEMAND: HRESULT = 0x80041328u32 as HRESULT; +pub const SCHED_E_TASK_NOT_UBPM_COMPAT: HRESULT = 0x80041329u32 as HRESULT; +pub const SCHED_E_DEPRECATED_FEATURE_USED: HRESULT = 0x80041330u32 as HRESULT; +pub const CO_E_CLASS_CREATE_FAILED: HRESULT = 0x80080001u32 as HRESULT; +pub const CO_E_SCM_ERROR: HRESULT = 0x80080002u32 as HRESULT; +pub const CO_E_SCM_RPC_FAILURE: HRESULT = 0x80080003u32 as HRESULT; +pub const CO_E_BAD_PATH: HRESULT = 0x80080004u32 as HRESULT; +pub const CO_E_SERVER_EXEC_FAILURE: HRESULT = 0x80080005u32 as HRESULT; +pub const CO_E_OBJSRV_RPC_FAILURE: HRESULT = 0x80080006u32 as HRESULT; +pub const MK_E_NO_NORMALIZED: HRESULT = 0x80080007u32 as HRESULT; +pub const CO_E_SERVER_STOPPING: HRESULT = 0x80080008u32 as HRESULT; +pub const MEM_E_INVALID_ROOT: HRESULT = 0x80080009u32 as HRESULT; +pub const MEM_E_INVALID_LINK: HRESULT = 0x80080010u32 as HRESULT; +pub const MEM_E_INVALID_SIZE: HRESULT = 0x80080011u32 as HRESULT; +pub const CO_S_NOTALLINTERFACES: HRESULT = 0x00080012; +pub const CO_S_MACHINENAMENOTFOUND: HRESULT = 0x00080013; +pub const CO_E_MISSING_DISPLAYNAME: HRESULT = 0x80080015u32 as HRESULT; +pub const CO_E_RUNAS_VALUE_MUST_BE_AAA: HRESULT = 0x80080016u32 as HRESULT; +pub const CO_E_ELEVATION_DISABLED: HRESULT = 0x80080017u32 as HRESULT; +pub const APPX_E_PACKAGING_INTERNAL: HRESULT = 0x80080200u32 as HRESULT; +pub const APPX_E_INTERLEAVING_NOT_ALLOWED: HRESULT = 0x80080201u32 as HRESULT; +pub const APPX_E_RELATIONSHIPS_NOT_ALLOWED: HRESULT = 0x80080202u32 as HRESULT; +pub const APPX_E_MISSING_REQUIRED_FILE: HRESULT = 0x80080203u32 as HRESULT; +pub const APPX_E_INVALID_MANIFEST: HRESULT = 0x80080204u32 as HRESULT; +pub const APPX_E_INVALID_BLOCKMAP: HRESULT = 0x80080205u32 as HRESULT; +pub const APPX_E_CORRUPT_CONTENT: HRESULT = 0x80080206u32 as HRESULT; +pub const APPX_E_BLOCK_HASH_INVALID: HRESULT = 0x80080207u32 as HRESULT; +pub const APPX_E_REQUESTED_RANGE_TOO_LARGE: HRESULT = 0x80080208u32 as HRESULT; +pub const APPX_E_INVALID_SIP_CLIENT_DATA: HRESULT = 0x80080209u32 as HRESULT; +pub const BT_E_SPURIOUS_ACTIVATION: HRESULT = 0x80080300u32 as HRESULT; +pub const DISP_E_UNKNOWNINTERFACE: HRESULT = 0x80020001u32 as HRESULT; +pub const DISP_E_MEMBERNOTFOUND: HRESULT = 0x80020003u32 as HRESULT; +pub const DISP_E_PARAMNOTFOUND: HRESULT = 0x80020004u32 as HRESULT; +pub const DISP_E_TYPEMISMATCH: HRESULT = 0x80020005u32 as HRESULT; +pub const DISP_E_UNKNOWNNAME: HRESULT = 0x80020006u32 as HRESULT; +pub const DISP_E_NONAMEDARGS: HRESULT = 0x80020007u32 as HRESULT; +pub const DISP_E_BADVARTYPE: HRESULT = 0x80020008u32 as HRESULT; +pub const DISP_E_EXCEPTION: HRESULT = 0x80020009u32 as HRESULT; +pub const DISP_E_OVERFLOW: HRESULT = 0x8002000Au32 as HRESULT; +pub const DISP_E_BADINDEX: HRESULT = 0x8002000Bu32 as HRESULT; +pub const DISP_E_UNKNOWNLCID: HRESULT = 0x8002000Cu32 as HRESULT; +pub const DISP_E_ARRAYISLOCKED: HRESULT = 0x8002000Du32 as HRESULT; +pub const DISP_E_BADPARAMCOUNT: HRESULT = 0x8002000Eu32 as HRESULT; +pub const DISP_E_PARAMNOTOPTIONAL: HRESULT = 0x8002000Fu32 as HRESULT; +pub const DISP_E_BADCALLEE: HRESULT = 0x80020010u32 as HRESULT; +pub const DISP_E_NOTACOLLECTION: HRESULT = 0x80020011u32 as HRESULT; +pub const DISP_E_DIVBYZERO: HRESULT = 0x80020012u32 as HRESULT; +pub const DISP_E_BUFFERTOOSMALL: HRESULT = 0x80020013u32 as HRESULT; +pub const TYPE_E_BUFFERTOOSMALL: HRESULT = 0x80028016u32 as HRESULT; +pub const TYPE_E_FIELDNOTFOUND: HRESULT = 0x80028017u32 as HRESULT; +pub const TYPE_E_INVDATAREAD: HRESULT = 0x80028018u32 as HRESULT; +pub const TYPE_E_UNSUPFORMAT: HRESULT = 0x80028019u32 as HRESULT; +pub const TYPE_E_REGISTRYACCESS: HRESULT = 0x8002801Cu32 as HRESULT; +pub const TYPE_E_LIBNOTREGISTERED: HRESULT = 0x8002801Du32 as HRESULT; +pub const TYPE_E_UNDEFINEDTYPE: HRESULT = 0x80028027u32 as HRESULT; +pub const TYPE_E_QUALIFIEDNAMEDISALLOWED: HRESULT = 0x80028028u32 as HRESULT; +pub const TYPE_E_INVALIDSTATE: HRESULT = 0x80028029u32 as HRESULT; +pub const TYPE_E_WRONGTYPEKIND: HRESULT = 0x8002802Au32 as HRESULT; +pub const TYPE_E_ELEMENTNOTFOUND: HRESULT = 0x8002802Bu32 as HRESULT; +pub const TYPE_E_AMBIGUOUSNAME: HRESULT = 0x8002802Cu32 as HRESULT; +pub const TYPE_E_NAMECONFLICT: HRESULT = 0x8002802Du32 as HRESULT; +pub const TYPE_E_UNKNOWNLCID: HRESULT = 0x8002802Eu32 as HRESULT; +pub const TYPE_E_DLLFUNCTIONNOTFOUND: HRESULT = 0x8002802Fu32 as HRESULT; +pub const TYPE_E_BADMODULEKIND: HRESULT = 0x800288BDu32 as HRESULT; +pub const TYPE_E_SIZETOOBIG: HRESULT = 0x800288C5u32 as HRESULT; +pub const TYPE_E_DUPLICATEID: HRESULT = 0x800288C6u32 as HRESULT; +pub const TYPE_E_INVALIDID: HRESULT = 0x800288CFu32 as HRESULT; +pub const TYPE_E_TYPEMISMATCH: HRESULT = 0x80028CA0u32 as HRESULT; +pub const TYPE_E_OUTOFBOUNDS: HRESULT = 0x80028CA1u32 as HRESULT; +pub const TYPE_E_IOERROR: HRESULT = 0x80028CA2u32 as HRESULT; +pub const TYPE_E_CANTCREATETMPFILE: HRESULT = 0x80028CA3u32 as HRESULT; +pub const TYPE_E_CANTLOADLIBRARY: HRESULT = 0x80029C4Au32 as HRESULT; +pub const TYPE_E_INCONSISTENTPROPFUNCS: HRESULT = 0x80029C83u32 as HRESULT; +pub const TYPE_E_CIRCULARTYPE: HRESULT = 0x80029C84u32 as HRESULT; +pub const STG_E_INVALIDFUNCTION: HRESULT = 0x80030001u32 as HRESULT; +pub const STG_E_FILENOTFOUND: HRESULT = 0x80030002u32 as HRESULT; +pub const STG_E_PATHNOTFOUND: HRESULT = 0x80030003u32 as HRESULT; +pub const STG_E_TOOMANYOPENFILES: HRESULT = 0x80030004u32 as HRESULT; +pub const STG_E_ACCESSDENIED: HRESULT = 0x80030005u32 as HRESULT; +pub const STG_E_INVALIDHANDLE: HRESULT = 0x80030006u32 as HRESULT; +pub const STG_E_INSUFFICIENTMEMORY: HRESULT = 0x80030008u32 as HRESULT; +pub const STG_E_INVALIDPOINTER: HRESULT = 0x80030009u32 as HRESULT; +pub const STG_E_NOMOREFILES: HRESULT = 0x80030012u32 as HRESULT; +pub const STG_E_DISKISWRITEPROTECTED: HRESULT = 0x80030013u32 as HRESULT; +pub const STG_E_SEEKERROR: HRESULT = 0x80030019u32 as HRESULT; +pub const STG_E_WRITEFAULT: HRESULT = 0x8003001Du32 as HRESULT; +pub const STG_E_READFAULT: HRESULT = 0x8003001Eu32 as HRESULT; +pub const STG_E_SHAREVIOLATION: HRESULT = 0x80030020u32 as HRESULT; +pub const STG_E_LOCKVIOLATION: HRESULT = 0x80030021u32 as HRESULT; +pub const STG_E_FILEALREADYEXISTS: HRESULT = 0x80030050u32 as HRESULT; +pub const STG_E_INVALIDPARAMETER: HRESULT = 0x80030057u32 as HRESULT; +pub const STG_E_MEDIUMFULL: HRESULT = 0x80030070u32 as HRESULT; +pub const STG_E_PROPSETMISMATCHED: HRESULT = 0x800300F0u32 as HRESULT; +pub const STG_E_ABNORMALAPIEXIT: HRESULT = 0x800300FAu32 as HRESULT; +pub const STG_E_INVALIDHEADER: HRESULT = 0x800300FBu32 as HRESULT; +pub const STG_E_INVALIDNAME: HRESULT = 0x800300FCu32 as HRESULT; +pub const STG_E_UNKNOWN: HRESULT = 0x800300FDu32 as HRESULT; +pub const STG_E_UNIMPLEMENTEDFUNCTION: HRESULT = 0x800300FEu32 as HRESULT; +pub const STG_E_INVALIDFLAG: HRESULT = 0x800300FFu32 as HRESULT; +pub const STG_E_INUSE: HRESULT = 0x80030100u32 as HRESULT; +pub const STG_E_NOTCURRENT: HRESULT = 0x80030101u32 as HRESULT; +pub const STG_E_REVERTED: HRESULT = 0x80030102u32 as HRESULT; +pub const STG_E_CANTSAVE: HRESULT = 0x80030103u32 as HRESULT; +pub const STG_E_OLDFORMAT: HRESULT = 0x80030104u32 as HRESULT; +pub const STG_E_OLDDLL: HRESULT = 0x80030105u32 as HRESULT; +pub const STG_E_SHAREREQUIRED: HRESULT = 0x80030106u32 as HRESULT; +pub const STG_E_NOTFILEBASEDSTORAGE: HRESULT = 0x80030107u32 as HRESULT; +pub const STG_E_EXTANTMARSHALLINGS: HRESULT = 0x80030108u32 as HRESULT; +pub const STG_E_DOCFILECORRUPT: HRESULT = 0x80030109u32 as HRESULT; +pub const STG_E_BADBASEADDRESS: HRESULT = 0x80030110u32 as HRESULT; +pub const STG_E_DOCFILETOOLARGE: HRESULT = 0x80030111u32 as HRESULT; +pub const STG_E_NOTSIMPLEFORMAT: HRESULT = 0x80030112u32 as HRESULT; +pub const STG_E_INCOMPLETE: HRESULT = 0x80030201u32 as HRESULT; +pub const STG_E_TERMINATED: HRESULT = 0x80030202u32 as HRESULT; +pub const STG_S_CONVERTED: HRESULT = 0x00030200; +pub const STG_S_BLOCK: HRESULT = 0x00030201; +pub const STG_S_RETRYNOW: HRESULT = 0x00030202; +pub const STG_S_MONITORING: HRESULT = 0x00030203; +pub const STG_S_MULTIPLEOPENS: HRESULT = 0x00030204; +pub const STG_S_CONSOLIDATIONFAILED: HRESULT = 0x00030205; +pub const STG_S_CANNOTCONSOLIDATE: HRESULT = 0x00030206; +pub const STG_E_STATUS_COPY_PROTECTION_FAILURE: HRESULT = 0x80030305u32 as HRESULT; +pub const STG_E_CSS_AUTHENTICATION_FAILURE: HRESULT = 0x80030306u32 as HRESULT; +pub const STG_E_CSS_KEY_NOT_PRESENT: HRESULT = 0x80030307u32 as HRESULT; +pub const STG_E_CSS_KEY_NOT_ESTABLISHED: HRESULT = 0x80030308u32 as HRESULT; +pub const STG_E_CSS_SCRAMBLED_SECTOR: HRESULT = 0x80030309u32 as HRESULT; +pub const STG_E_CSS_REGION_MISMATCH: HRESULT = 0x8003030Au32 as HRESULT; +pub const STG_E_RESETS_EXHAUSTED: HRESULT = 0x8003030Bu32 as HRESULT; +pub const RPC_E_CALL_REJECTED: HRESULT = 0x80010001u32 as HRESULT; +pub const RPC_E_CALL_CANCELED: HRESULT = 0x80010002u32 as HRESULT; +pub const RPC_E_CANTPOST_INSENDCALL: HRESULT = 0x80010003u32 as HRESULT; +pub const RPC_E_CANTCALLOUT_INASYNCCALL: HRESULT = 0x80010004u32 as HRESULT; +pub const RPC_E_CANTCALLOUT_INEXTERNALCALL: HRESULT = 0x80010005u32 as HRESULT; +pub const RPC_E_CONNECTION_TERMINATED: HRESULT = 0x80010006u32 as HRESULT; +pub const RPC_E_SERVER_DIED: HRESULT = 0x80010007u32 as HRESULT; +pub const RPC_E_CLIENT_DIED: HRESULT = 0x80010008u32 as HRESULT; +pub const RPC_E_INVALID_DATAPACKET: HRESULT = 0x80010009u32 as HRESULT; +pub const RPC_E_CANTTRANSMIT_CALL: HRESULT = 0x8001000Au32 as HRESULT; +pub const RPC_E_CLIENT_CANTMARSHAL_DATA: HRESULT = 0x8001000Bu32 as HRESULT; +pub const RPC_E_CLIENT_CANTUNMARSHAL_DATA: HRESULT = 0x8001000Cu32 as HRESULT; +pub const RPC_E_SERVER_CANTMARSHAL_DATA: HRESULT = 0x8001000Du32 as HRESULT; +pub const RPC_E_SERVER_CANTUNMARSHAL_DATA: HRESULT = 0x8001000Eu32 as HRESULT; +pub const RPC_E_INVALID_DATA: HRESULT = 0x8001000Fu32 as HRESULT; +pub const RPC_E_INVALID_PARAMETER: HRESULT = 0x80010010u32 as HRESULT; +pub const RPC_E_CANTCALLOUT_AGAIN: HRESULT = 0x80010011u32 as HRESULT; +pub const RPC_E_SERVER_DIED_DNE: HRESULT = 0x80010012u32 as HRESULT; +pub const RPC_E_SYS_CALL_FAILED: HRESULT = 0x80010100u32 as HRESULT; +pub const RPC_E_OUT_OF_RESOURCES: HRESULT = 0x80010101u32 as HRESULT; +pub const RPC_E_ATTEMPTED_MULTITHREAD: HRESULT = 0x80010102u32 as HRESULT; +pub const RPC_E_NOT_REGISTERED: HRESULT = 0x80010103u32 as HRESULT; +pub const RPC_E_FAULT: HRESULT = 0x80010104u32 as HRESULT; +pub const RPC_E_SERVERFAULT: HRESULT = 0x80010105u32 as HRESULT; +pub const RPC_E_CHANGED_MODE: HRESULT = 0x80010106u32 as HRESULT; +pub const RPC_E_INVALIDMETHOD: HRESULT = 0x80010107u32 as HRESULT; +pub const RPC_E_DISCONNECTED: HRESULT = 0x80010108u32 as HRESULT; +pub const RPC_E_RETRY: HRESULT = 0x80010109u32 as HRESULT; +pub const RPC_E_SERVERCALL_RETRYLATER: HRESULT = 0x8001010Au32 as HRESULT; +pub const RPC_E_SERVERCALL_REJECTED: HRESULT = 0x8001010Bu32 as HRESULT; +pub const RPC_E_INVALID_CALLDATA: HRESULT = 0x8001010Cu32 as HRESULT; +pub const RPC_E_CANTCALLOUT_ININPUTSYNCCALL: HRESULT = 0x8001010Du32 as HRESULT; +pub const RPC_E_WRONG_THREAD: HRESULT = 0x8001010Eu32 as HRESULT; +pub const RPC_E_THREAD_NOT_INIT: HRESULT = 0x8001010Fu32 as HRESULT; +pub const RPC_E_VERSION_MISMATCH: HRESULT = 0x80010110u32 as HRESULT; +pub const RPC_E_INVALID_HEADER: HRESULT = 0x80010111u32 as HRESULT; +pub const RPC_E_INVALID_EXTENSION: HRESULT = 0x80010112u32 as HRESULT; +pub const RPC_E_INVALID_IPID: HRESULT = 0x80010113u32 as HRESULT; +pub const RPC_E_INVALID_OBJECT: HRESULT = 0x80010114u32 as HRESULT; +pub const RPC_S_CALLPENDING: HRESULT = 0x80010115u32 as HRESULT; +pub const RPC_S_WAITONTIMER: HRESULT = 0x80010116u32 as HRESULT; +pub const RPC_E_CALL_COMPLETE: HRESULT = 0x80010117u32 as HRESULT; +pub const RPC_E_UNSECURE_CALL: HRESULT = 0x80010118u32 as HRESULT; +pub const RPC_E_TOO_LATE: HRESULT = 0x80010119u32 as HRESULT; +pub const RPC_E_NO_GOOD_SECURITY_PACKAGES: HRESULT = 0x8001011Au32 as HRESULT; +pub const RPC_E_ACCESS_DENIED: HRESULT = 0x8001011Bu32 as HRESULT; +pub const RPC_E_REMOTE_DISABLED: HRESULT = 0x8001011Cu32 as HRESULT; +pub const RPC_E_INVALID_OBJREF: HRESULT = 0x8001011Du32 as HRESULT; +pub const RPC_E_NO_CONTEXT: HRESULT = 0x8001011Eu32 as HRESULT; +pub const RPC_E_TIMEOUT: HRESULT = 0x8001011Fu32 as HRESULT; +pub const RPC_E_NO_SYNC: HRESULT = 0x80010120u32 as HRESULT; +pub const RPC_E_FULLSIC_REQUIRED: HRESULT = 0x80010121u32 as HRESULT; +pub const RPC_E_INVALID_STD_NAME: HRESULT = 0x80010122u32 as HRESULT; +pub const CO_E_FAILEDTOIMPERSONATE: HRESULT = 0x80010123u32 as HRESULT; +pub const CO_E_FAILEDTOGETSECCTX: HRESULT = 0x80010124u32 as HRESULT; +pub const CO_E_FAILEDTOOPENTHREADTOKEN: HRESULT = 0x80010125u32 as HRESULT; +pub const CO_E_FAILEDTOGETTOKENINFO: HRESULT = 0x80010126u32 as HRESULT; +pub const CO_E_TRUSTEEDOESNTMATCHCLIENT: HRESULT = 0x80010127u32 as HRESULT; +pub const CO_E_FAILEDTOQUERYCLIENTBLANKET: HRESULT = 0x80010128u32 as HRESULT; +pub const CO_E_FAILEDTOSETDACL: HRESULT = 0x80010129u32 as HRESULT; +pub const CO_E_ACCESSCHECKFAILED: HRESULT = 0x8001012Au32 as HRESULT; +pub const CO_E_NETACCESSAPIFAILED: HRESULT = 0x8001012Bu32 as HRESULT; +pub const CO_E_WRONGTRUSTEENAMESYNTAX: HRESULT = 0x8001012Cu32 as HRESULT; +pub const CO_E_INVALIDSID: HRESULT = 0x8001012Du32 as HRESULT; +pub const CO_E_CONVERSIONFAILED: HRESULT = 0x8001012Eu32 as HRESULT; +pub const CO_E_NOMATCHINGSIDFOUND: HRESULT = 0x8001012Fu32 as HRESULT; +pub const CO_E_LOOKUPACCSIDFAILED: HRESULT = 0x80010130u32 as HRESULT; +pub const CO_E_NOMATCHINGNAMEFOUND: HRESULT = 0x80010131u32 as HRESULT; +pub const CO_E_LOOKUPACCNAMEFAILED: HRESULT = 0x80010132u32 as HRESULT; +pub const CO_E_SETSERLHNDLFAILED: HRESULT = 0x80010133u32 as HRESULT; +pub const CO_E_FAILEDTOGETWINDIR: HRESULT = 0x80010134u32 as HRESULT; +pub const CO_E_PATHTOOLONG: HRESULT = 0x80010135u32 as HRESULT; +pub const CO_E_FAILEDTOGENUUID: HRESULT = 0x80010136u32 as HRESULT; +pub const CO_E_FAILEDTOCREATEFILE: HRESULT = 0x80010137u32 as HRESULT; +pub const CO_E_FAILEDTOCLOSEHANDLE: HRESULT = 0x80010138u32 as HRESULT; +pub const CO_E_EXCEEDSYSACLLIMIT: HRESULT = 0x80010139u32 as HRESULT; +pub const CO_E_ACESINWRONGORDER: HRESULT = 0x8001013Au32 as HRESULT; +pub const CO_E_INCOMPATIBLESTREAMVERSION: HRESULT = 0x8001013Bu32 as HRESULT; +pub const CO_E_FAILEDTOOPENPROCESSTOKEN: HRESULT = 0x8001013Cu32 as HRESULT; +pub const CO_E_DECODEFAILED: HRESULT = 0x8001013Du32 as HRESULT; +pub const CO_E_ACNOTINITIALIZED: HRESULT = 0x8001013Fu32 as HRESULT; +pub const CO_E_CANCEL_DISABLED: HRESULT = 0x80010140u32 as HRESULT; +pub const RPC_E_UNEXPECTED: HRESULT = 0x8001FFFFu32 as HRESULT; +pub const ERROR_AUDITING_DISABLED: HRESULT = 0xC0090001u32 as HRESULT; +pub const ERROR_ALL_SIDS_FILTERED: HRESULT = 0xC0090002u32 as HRESULT; +pub const ERROR_BIZRULES_NOT_ENABLED: HRESULT = 0xC0090003u32 as HRESULT; +pub const NTE_BAD_UID: HRESULT = 0x80090001u32 as HRESULT; +pub const NTE_BAD_HASH: HRESULT = 0x80090002u32 as HRESULT; +pub const NTE_BAD_KEY: HRESULT = 0x80090003u32 as HRESULT; +pub const NTE_BAD_LEN: HRESULT = 0x80090004u32 as HRESULT; +pub const NTE_BAD_DATA: HRESULT = 0x80090005u32 as HRESULT; +pub const NTE_BAD_SIGNATURE: HRESULT = 0x80090006u32 as HRESULT; +pub const NTE_BAD_VER: HRESULT = 0x80090007u32 as HRESULT; +pub const NTE_BAD_ALGID: HRESULT = 0x80090008u32 as HRESULT; +pub const NTE_BAD_FLAGS: HRESULT = 0x80090009u32 as HRESULT; +pub const NTE_BAD_TYPE: HRESULT = 0x8009000Au32 as HRESULT; +pub const NTE_BAD_KEY_STATE: HRESULT = 0x8009000Bu32 as HRESULT; +pub const NTE_BAD_HASH_STATE: HRESULT = 0x8009000Cu32 as HRESULT; +pub const NTE_NO_KEY: HRESULT = 0x8009000Du32 as HRESULT; +pub const NTE_NO_MEMORY: HRESULT = 0x8009000Eu32 as HRESULT; +pub const NTE_EXISTS: HRESULT = 0x8009000Fu32 as HRESULT; +pub const NTE_PERM: HRESULT = 0x80090010u32 as HRESULT; +pub const NTE_NOT_FOUND: HRESULT = 0x80090011u32 as HRESULT; +pub const NTE_DOUBLE_ENCRYPT: HRESULT = 0x80090012u32 as HRESULT; +pub const NTE_BAD_PROVIDER: HRESULT = 0x80090013u32 as HRESULT; +pub const NTE_BAD_PROV_TYPE: HRESULT = 0x80090014u32 as HRESULT; +pub const NTE_BAD_PUBLIC_KEY: HRESULT = 0x80090015u32 as HRESULT; +pub const NTE_BAD_KEYSET: HRESULT = 0x80090016u32 as HRESULT; +pub const NTE_PROV_TYPE_NOT_DEF: HRESULT = 0x80090017u32 as HRESULT; +pub const NTE_PROV_TYPE_ENTRY_BAD: HRESULT = 0x80090018u32 as HRESULT; +pub const NTE_KEYSET_NOT_DEF: HRESULT = 0x80090019u32 as HRESULT; +pub const NTE_KEYSET_ENTRY_BAD: HRESULT = 0x8009001Au32 as HRESULT; +pub const NTE_PROV_TYPE_NO_MATCH: HRESULT = 0x8009001Bu32 as HRESULT; +pub const NTE_SIGNATURE_FILE_BAD: HRESULT = 0x8009001Cu32 as HRESULT; +pub const NTE_PROVIDER_DLL_FAIL: HRESULT = 0x8009001Du32 as HRESULT; +pub const NTE_PROV_DLL_NOT_FOUND: HRESULT = 0x8009001Eu32 as HRESULT; +pub const NTE_BAD_KEYSET_PARAM: HRESULT = 0x8009001Fu32 as HRESULT; +pub const NTE_FAIL: HRESULT = 0x80090020u32 as HRESULT; +pub const NTE_SYS_ERR: HRESULT = 0x80090021u32 as HRESULT; +pub const NTE_SILENT_CONTEXT: HRESULT = 0x80090022u32 as HRESULT; +pub const NTE_TOKEN_KEYSET_STORAGE_FULL: HRESULT = 0x80090023u32 as HRESULT; +pub const NTE_TEMPORARY_PROFILE: HRESULT = 0x80090024u32 as HRESULT; +pub const NTE_FIXEDPARAMETER: HRESULT = 0x80090025u32 as HRESULT; +pub const NTE_INVALID_HANDLE: HRESULT = 0x80090026u32 as HRESULT; +pub const NTE_INVALID_PARAMETER: HRESULT = 0x80090027u32 as HRESULT; +pub const NTE_BUFFER_TOO_SMALL: HRESULT = 0x80090028u32 as HRESULT; +pub const NTE_NOT_SUPPORTED: HRESULT = 0x80090029u32 as HRESULT; +pub const NTE_NO_MORE_ITEMS: HRESULT = 0x8009002Au32 as HRESULT; +pub const NTE_BUFFERS_OVERLAP: HRESULT = 0x8009002Bu32 as HRESULT; +pub const NTE_DECRYPTION_FAILURE: HRESULT = 0x8009002Cu32 as HRESULT; +pub const NTE_INTERNAL_ERROR: HRESULT = 0x8009002Du32 as HRESULT; +pub const NTE_UI_REQUIRED: HRESULT = 0x8009002Eu32 as HRESULT; +pub const NTE_HMAC_NOT_SUPPORTED: HRESULT = 0x8009002Fu32 as HRESULT; +pub const NTE_DEVICE_NOT_READY: HRESULT = 0x80090030u32 as HRESULT; +pub const NTE_AUTHENTICATION_IGNORED: HRESULT = 0x80090031u32 as HRESULT; +pub const NTE_VALIDATION_FAILED: HRESULT = 0x80090032u32 as HRESULT; +pub const NTE_INCORRECT_PASSWORD: HRESULT = 0x80090033u32 as HRESULT; +pub const NTE_ENCRYPTION_FAILURE: HRESULT = 0x80090034u32 as HRESULT; +pub const NTE_DEVICE_NOT_FOUND: HRESULT = 0x80090035u32 as HRESULT; +pub const SEC_E_INSUFFICIENT_MEMORY: HRESULT = 0x80090300u32 as HRESULT; +pub const SEC_E_INVALID_HANDLE: HRESULT = 0x80090301u32 as HRESULT; +pub const SEC_E_UNSUPPORTED_FUNCTION: HRESULT = 0x80090302u32 as HRESULT; +pub const SEC_E_TARGET_UNKNOWN: HRESULT = 0x80090303u32 as HRESULT; +pub const SEC_E_INTERNAL_ERROR: HRESULT = 0x80090304u32 as HRESULT; +pub const SEC_E_SECPKG_NOT_FOUND: HRESULT = 0x80090305u32 as HRESULT; +pub const SEC_E_NOT_OWNER: HRESULT = 0x80090306u32 as HRESULT; +pub const SEC_E_CANNOT_INSTALL: HRESULT = 0x80090307u32 as HRESULT; +pub const SEC_E_INVALID_TOKEN: HRESULT = 0x80090308u32 as HRESULT; +pub const SEC_E_CANNOT_PACK: HRESULT = 0x80090309u32 as HRESULT; +pub const SEC_E_QOP_NOT_SUPPORTED: HRESULT = 0x8009030Au32 as HRESULT; +pub const SEC_E_NO_IMPERSONATION: HRESULT = 0x8009030Bu32 as HRESULT; +pub const SEC_E_LOGON_DENIED: HRESULT = 0x8009030Cu32 as HRESULT; +pub const SEC_E_UNKNOWN_CREDENTIALS: HRESULT = 0x8009030Du32 as HRESULT; +pub const SEC_E_NO_CREDENTIALS: HRESULT = 0x8009030Eu32 as HRESULT; +pub const SEC_E_MESSAGE_ALTERED: HRESULT = 0x8009030Fu32 as HRESULT; +pub const SEC_E_OUT_OF_SEQUENCE: HRESULT = 0x80090310u32 as HRESULT; +pub const SEC_E_NO_AUTHENTICATING_AUTHORITY: HRESULT = 0x80090311u32 as HRESULT; +pub const SEC_I_CONTINUE_NEEDED: HRESULT = 0x00090312; +pub const SEC_I_COMPLETE_NEEDED: HRESULT = 0x00090313; +pub const SEC_I_COMPLETE_AND_CONTINUE: HRESULT = 0x00090314; +pub const SEC_I_LOCAL_LOGON: HRESULT = 0x00090315; +pub const SEC_E_BAD_PKGID: HRESULT = 0x80090316u32 as HRESULT; +pub const SEC_E_CONTEXT_EXPIRED: HRESULT = 0x80090317u32 as HRESULT; +pub const SEC_I_CONTEXT_EXPIRED: HRESULT = 0x00090317; +pub const SEC_E_INCOMPLETE_MESSAGE: HRESULT = 0x80090318u32 as HRESULT; +pub const SEC_E_INCOMPLETE_CREDENTIALS: HRESULT = 0x80090320u32 as HRESULT; +pub const SEC_E_BUFFER_TOO_SMALL: HRESULT = 0x80090321u32 as HRESULT; +pub const SEC_I_INCOMPLETE_CREDENTIALS: HRESULT = 0x00090320; +pub const SEC_I_RENEGOTIATE: HRESULT = 0x00090321; +pub const SEC_E_WRONG_PRINCIPAL: HRESULT = 0x80090322u32 as HRESULT; +pub const SEC_I_NO_LSA_CONTEXT: HRESULT = 0x00090323; +pub const SEC_E_TIME_SKEW: HRESULT = 0x80090324u32 as HRESULT; +pub const SEC_E_UNTRUSTED_ROOT: HRESULT = 0x80090325u32 as HRESULT; +pub const SEC_E_ILLEGAL_MESSAGE: HRESULT = 0x80090326u32 as HRESULT; +pub const SEC_E_CERT_UNKNOWN: HRESULT = 0x80090327u32 as HRESULT; +pub const SEC_E_CERT_EXPIRED: HRESULT = 0x80090328u32 as HRESULT; +pub const SEC_E_ENCRYPT_FAILURE: HRESULT = 0x80090329u32 as HRESULT; +pub const SEC_E_DECRYPT_FAILURE: HRESULT = 0x80090330u32 as HRESULT; +pub const SEC_E_ALGORITHM_MISMATCH: HRESULT = 0x80090331u32 as HRESULT; +pub const SEC_E_SECURITY_QOS_FAILED: HRESULT = 0x80090332u32 as HRESULT; +pub const SEC_E_UNFINISHED_CONTEXT_DELETED: HRESULT = 0x80090333u32 as HRESULT; +pub const SEC_E_NO_TGT_REPLY: HRESULT = 0x80090334u32 as HRESULT; +pub const SEC_E_NO_IP_ADDRESSES: HRESULT = 0x80090335u32 as HRESULT; +pub const SEC_E_WRONG_CREDENTIAL_HANDLE: HRESULT = 0x80090336u32 as HRESULT; +pub const SEC_E_CRYPTO_SYSTEM_INVALID: HRESULT = 0x80090337u32 as HRESULT; +pub const SEC_E_MAX_REFERRALS_EXCEEDED: HRESULT = 0x80090338u32 as HRESULT; +pub const SEC_E_MUST_BE_KDC: HRESULT = 0x80090339u32 as HRESULT; +pub const SEC_E_STRONG_CRYPTO_NOT_SUPPORTED: HRESULT = 0x8009033Au32 as HRESULT; +pub const SEC_E_TOO_MANY_PRINCIPALS: HRESULT = 0x8009033Bu32 as HRESULT; +pub const SEC_E_NO_PA_DATA: HRESULT = 0x8009033Cu32 as HRESULT; +pub const SEC_E_PKINIT_NAME_MISMATCH: HRESULT = 0x8009033Du32 as HRESULT; +pub const SEC_E_SMARTCARD_LOGON_REQUIRED: HRESULT = 0x8009033Eu32 as HRESULT; +pub const SEC_E_SHUTDOWN_IN_PROGRESS: HRESULT = 0x8009033Fu32 as HRESULT; +pub const SEC_E_KDC_INVALID_REQUEST: HRESULT = 0x80090340u32 as HRESULT; +pub const SEC_E_KDC_UNABLE_TO_REFER: HRESULT = 0x80090341u32 as HRESULT; +pub const SEC_E_KDC_UNKNOWN_ETYPE: HRESULT = 0x80090342u32 as HRESULT; +pub const SEC_E_UNSUPPORTED_PREAUTH: HRESULT = 0x80090343u32 as HRESULT; +pub const SEC_E_DELEGATION_REQUIRED: HRESULT = 0x80090345u32 as HRESULT; +pub const SEC_E_BAD_BINDINGS: HRESULT = 0x80090346u32 as HRESULT; +pub const SEC_E_MULTIPLE_ACCOUNTS: HRESULT = 0x80090347u32 as HRESULT; +pub const SEC_E_NO_KERB_KEY: HRESULT = 0x80090348u32 as HRESULT; +pub const SEC_E_CERT_WRONG_USAGE: HRESULT = 0x80090349u32 as HRESULT; +pub const SEC_E_DOWNGRADE_DETECTED: HRESULT = 0x80090350u32 as HRESULT; +pub const SEC_E_SMARTCARD_CERT_REVOKED: HRESULT = 0x80090351u32 as HRESULT; +pub const SEC_E_ISSUING_CA_UNTRUSTED: HRESULT = 0x80090352u32 as HRESULT; +pub const SEC_E_REVOCATION_OFFLINE_C: HRESULT = 0x80090353u32 as HRESULT; +pub const SEC_E_PKINIT_CLIENT_FAILURE: HRESULT = 0x80090354u32 as HRESULT; +pub const SEC_E_SMARTCARD_CERT_EXPIRED: HRESULT = 0x80090355u32 as HRESULT; +pub const SEC_E_NO_S4U_PROT_SUPPORT: HRESULT = 0x80090356u32 as HRESULT; +pub const SEC_E_CROSSREALM_DELEGATION_FAILURE: HRESULT = 0x80090357u32 as HRESULT; +pub const SEC_E_REVOCATION_OFFLINE_KDC: HRESULT = 0x80090358u32 as HRESULT; +pub const SEC_E_ISSUING_CA_UNTRUSTED_KDC: HRESULT = 0x80090359u32 as HRESULT; +pub const SEC_E_KDC_CERT_EXPIRED: HRESULT = 0x8009035Au32 as HRESULT; +pub const SEC_E_KDC_CERT_REVOKED: HRESULT = 0x8009035Bu32 as HRESULT; +pub const SEC_I_SIGNATURE_NEEDED: HRESULT = 0x0009035C; +pub const SEC_E_INVALID_PARAMETER: HRESULT = 0x8009035Du32 as HRESULT; +pub const SEC_E_DELEGATION_POLICY: HRESULT = 0x8009035Eu32 as HRESULT; +pub const SEC_E_POLICY_NLTM_ONLY: HRESULT = 0x8009035Fu32 as HRESULT; +pub const SEC_I_NO_RENEGOTIATION: HRESULT = 0x00090360; +pub const SEC_E_NO_CONTEXT: HRESULT = 0x80090361u32 as HRESULT; +pub const SEC_E_PKU2U_CERT_FAILURE: HRESULT = 0x80090362u32 as HRESULT; +pub const SEC_E_MUTUAL_AUTH_FAILED: HRESULT = 0x80090363u32 as HRESULT; +pub const SEC_I_MESSAGE_FRAGMENT: HRESULT = 0x00090364; +pub const SEC_E_ONLY_HTTPS_ALLOWED: HRESULT = 0x80090365u32 as HRESULT; +pub const SEC_I_CONTINUE_NEEDED_MESSAGE_OK: HRESULT = 0x00090366; +pub const SEC_E_APPLICATION_PROTOCOL_MISMATCH: HRESULT = 0x80090367u32 as HRESULT; +pub const SEC_E_NO_SPM: HRESULT = SEC_E_INTERNAL_ERROR; +pub const SEC_E_NOT_SUPPORTED: HRESULT = SEC_E_UNSUPPORTED_FUNCTION; +pub const CRYPT_E_MSG_ERROR: HRESULT = 0x80091001u32 as HRESULT; +pub const CRYPT_E_UNKNOWN_ALGO: HRESULT = 0x80091002u32 as HRESULT; +pub const CRYPT_E_OID_FORMAT: HRESULT = 0x80091003u32 as HRESULT; +pub const CRYPT_E_INVALID_MSG_TYPE: HRESULT = 0x80091004u32 as HRESULT; +pub const CRYPT_E_UNEXPECTED_ENCODING: HRESULT = 0x80091005u32 as HRESULT; +pub const CRYPT_E_AUTH_ATTR_MISSING: HRESULT = 0x80091006u32 as HRESULT; +pub const CRYPT_E_HASH_VALUE: HRESULT = 0x80091007u32 as HRESULT; +pub const CRYPT_E_INVALID_INDEX: HRESULT = 0x80091008u32 as HRESULT; +pub const CRYPT_E_ALREADY_DECRYPTED: HRESULT = 0x80091009u32 as HRESULT; +pub const CRYPT_E_NOT_DECRYPTED: HRESULT = 0x8009100Au32 as HRESULT; +pub const CRYPT_E_RECIPIENT_NOT_FOUND: HRESULT = 0x8009100Bu32 as HRESULT; +pub const CRYPT_E_CONTROL_TYPE: HRESULT = 0x8009100Cu32 as HRESULT; +pub const CRYPT_E_ISSUER_SERIALNUMBER: HRESULT = 0x8009100Du32 as HRESULT; +pub const CRYPT_E_SIGNER_NOT_FOUND: HRESULT = 0x8009100Eu32 as HRESULT; +pub const CRYPT_E_ATTRIBUTES_MISSING: HRESULT = 0x8009100Fu32 as HRESULT; +pub const CRYPT_E_STREAM_MSG_NOT_READY: HRESULT = 0x80091010u32 as HRESULT; +pub const CRYPT_E_STREAM_INSUFFICIENT_DATA: HRESULT = 0x80091011u32 as HRESULT; +pub const CRYPT_I_NEW_PROTECTION_REQUIRED: HRESULT = 0x00091012; +pub const CRYPT_E_BAD_LEN: HRESULT = 0x80092001u32 as HRESULT; +pub const CRYPT_E_BAD_ENCODE: HRESULT = 0x80092002u32 as HRESULT; +pub const CRYPT_E_FILE_ERROR: HRESULT = 0x80092003u32 as HRESULT; +pub const CRYPT_E_NOT_FOUND: HRESULT = 0x80092004u32 as HRESULT; +pub const CRYPT_E_EXISTS: HRESULT = 0x80092005u32 as HRESULT; +pub const CRYPT_E_NO_PROVIDER: HRESULT = 0x80092006u32 as HRESULT; +pub const CRYPT_E_SELF_SIGNED: HRESULT = 0x80092007u32 as HRESULT; +pub const CRYPT_E_DELETED_PREV: HRESULT = 0x80092008u32 as HRESULT; +pub const CRYPT_E_NO_MATCH: HRESULT = 0x80092009u32 as HRESULT; +pub const CRYPT_E_UNEXPECTED_MSG_TYPE: HRESULT = 0x8009200Au32 as HRESULT; +pub const CRYPT_E_NO_KEY_PROPERTY: HRESULT = 0x8009200Bu32 as HRESULT; +pub const CRYPT_E_NO_DECRYPT_CERT: HRESULT = 0x8009200Cu32 as HRESULT; +pub const CRYPT_E_BAD_MSG: HRESULT = 0x8009200Du32 as HRESULT; +pub const CRYPT_E_NO_SIGNER: HRESULT = 0x8009200Eu32 as HRESULT; +pub const CRYPT_E_PENDING_CLOSE: HRESULT = 0x8009200Fu32 as HRESULT; +pub const CRYPT_E_REVOKED: HRESULT = 0x80092010u32 as HRESULT; +pub const CRYPT_E_NO_REVOCATION_DLL: HRESULT = 0x80092011u32 as HRESULT; +pub const CRYPT_E_NO_REVOCATION_CHECK: HRESULT = 0x80092012u32 as HRESULT; +pub const CRYPT_E_REVOCATION_OFFLINE: HRESULT = 0x80092013u32 as HRESULT; +pub const CRYPT_E_NOT_IN_REVOCATION_DATABASE: HRESULT = 0x80092014u32 as HRESULT; +pub const CRYPT_E_INVALID_NUMERIC_STRING: HRESULT = 0x80092020u32 as HRESULT; +pub const CRYPT_E_INVALID_PRINTABLE_STRING: HRESULT = 0x80092021u32 as HRESULT; +pub const CRYPT_E_INVALID_IA5_STRING: HRESULT = 0x80092022u32 as HRESULT; +pub const CRYPT_E_INVALID_X500_STRING: HRESULT = 0x80092023u32 as HRESULT; +pub const CRYPT_E_NOT_CHAR_STRING: HRESULT = 0x80092024u32 as HRESULT; +pub const CRYPT_E_FILERESIZED: HRESULT = 0x80092025u32 as HRESULT; +pub const CRYPT_E_SECURITY_SETTINGS: HRESULT = 0x80092026u32 as HRESULT; +pub const CRYPT_E_NO_VERIFY_USAGE_DLL: HRESULT = 0x80092027u32 as HRESULT; +pub const CRYPT_E_NO_VERIFY_USAGE_CHECK: HRESULT = 0x80092028u32 as HRESULT; +pub const CRYPT_E_VERIFY_USAGE_OFFLINE: HRESULT = 0x80092029u32 as HRESULT; +pub const CRYPT_E_NOT_IN_CTL: HRESULT = 0x8009202Au32 as HRESULT; +pub const CRYPT_E_NO_TRUSTED_SIGNER: HRESULT = 0x8009202Bu32 as HRESULT; +pub const CRYPT_E_MISSING_PUBKEY_PARA: HRESULT = 0x8009202Cu32 as HRESULT; +pub const CRYPT_E_OBJECT_LOCATOR_OBJECT_NOT_FOUND: HRESULT = 0x8009202Du32 as HRESULT; +pub const CRYPT_E_OSS_ERROR: HRESULT = 0x80093000u32 as HRESULT; +pub const OSS_MORE_BUF: HRESULT = 0x80093001u32 as HRESULT; +pub const OSS_NEGATIVE_UINTEGER: HRESULT = 0x80093002u32 as HRESULT; +pub const OSS_PDU_RANGE: HRESULT = 0x80093003u32 as HRESULT; +pub const OSS_MORE_INPUT: HRESULT = 0x80093004u32 as HRESULT; +pub const OSS_DATA_ERROR: HRESULT = 0x80093005u32 as HRESULT; +pub const OSS_BAD_ARG: HRESULT = 0x80093006u32 as HRESULT; +pub const OSS_BAD_VERSION: HRESULT = 0x80093007u32 as HRESULT; +pub const OSS_OUT_MEMORY: HRESULT = 0x80093008u32 as HRESULT; +pub const OSS_PDU_MISMATCH: HRESULT = 0x80093009u32 as HRESULT; +pub const OSS_LIMITED: HRESULT = 0x8009300Au32 as HRESULT; +pub const OSS_BAD_PTR: HRESULT = 0x8009300Bu32 as HRESULT; +pub const OSS_BAD_TIME: HRESULT = 0x8009300Cu32 as HRESULT; +pub const OSS_INDEFINITE_NOT_SUPPORTED: HRESULT = 0x8009300Du32 as HRESULT; +pub const OSS_MEM_ERROR: HRESULT = 0x8009300Eu32 as HRESULT; +pub const OSS_BAD_TABLE: HRESULT = 0x8009300Fu32 as HRESULT; +pub const OSS_TOO_LONG: HRESULT = 0x80093010u32 as HRESULT; +pub const OSS_CONSTRAINT_VIOLATED: HRESULT = 0x80093011u32 as HRESULT; +pub const OSS_FATAL_ERROR: HRESULT = 0x80093012u32 as HRESULT; +pub const OSS_ACCESS_SERIALIZATION_ERROR: HRESULT = 0x80093013u32 as HRESULT; +pub const OSS_NULL_TBL: HRESULT = 0x80093014u32 as HRESULT; +pub const OSS_NULL_FCN: HRESULT = 0x80093015u32 as HRESULT; +pub const OSS_BAD_ENCRULES: HRESULT = 0x80093016u32 as HRESULT; +pub const OSS_UNAVAIL_ENCRULES: HRESULT = 0x80093017u32 as HRESULT; +pub const OSS_CANT_OPEN_TRACE_WINDOW: HRESULT = 0x80093018u32 as HRESULT; +pub const OSS_UNIMPLEMENTED: HRESULT = 0x80093019u32 as HRESULT; +pub const OSS_OID_DLL_NOT_LINKED: HRESULT = 0x8009301Au32 as HRESULT; +pub const OSS_CANT_OPEN_TRACE_FILE: HRESULT = 0x8009301Bu32 as HRESULT; +pub const OSS_TRACE_FILE_ALREADY_OPEN: HRESULT = 0x8009301Cu32 as HRESULT; +pub const OSS_TABLE_MISMATCH: HRESULT = 0x8009301Du32 as HRESULT; +pub const OSS_TYPE_NOT_SUPPORTED: HRESULT = 0x8009301Eu32 as HRESULT; +pub const OSS_REAL_DLL_NOT_LINKED: HRESULT = 0x8009301Fu32 as HRESULT; +pub const OSS_REAL_CODE_NOT_LINKED: HRESULT = 0x80093020u32 as HRESULT; +pub const OSS_OUT_OF_RANGE: HRESULT = 0x80093021u32 as HRESULT; +pub const OSS_COPIER_DLL_NOT_LINKED: HRESULT = 0x80093022u32 as HRESULT; +pub const OSS_CONSTRAINT_DLL_NOT_LINKED: HRESULT = 0x80093023u32 as HRESULT; +pub const OSS_COMPARATOR_DLL_NOT_LINKED: HRESULT = 0x80093024u32 as HRESULT; +pub const OSS_COMPARATOR_CODE_NOT_LINKED: HRESULT = 0x80093025u32 as HRESULT; +pub const OSS_MEM_MGR_DLL_NOT_LINKED: HRESULT = 0x80093026u32 as HRESULT; +pub const OSS_PDV_DLL_NOT_LINKED: HRESULT = 0x80093027u32 as HRESULT; +pub const OSS_PDV_CODE_NOT_LINKED: HRESULT = 0x80093028u32 as HRESULT; +pub const OSS_API_DLL_NOT_LINKED: HRESULT = 0x80093029u32 as HRESULT; +pub const OSS_BERDER_DLL_NOT_LINKED: HRESULT = 0x8009302Au32 as HRESULT; +pub const OSS_PER_DLL_NOT_LINKED: HRESULT = 0x8009302Bu32 as HRESULT; +pub const OSS_OPEN_TYPE_ERROR: HRESULT = 0x8009302Cu32 as HRESULT; +pub const OSS_MUTEX_NOT_CREATED: HRESULT = 0x8009302Du32 as HRESULT; +pub const OSS_CANT_CLOSE_TRACE_FILE: HRESULT = 0x8009302Eu32 as HRESULT; +pub const CRYPT_E_ASN1_ERROR: HRESULT = 0x80093100u32 as HRESULT; +pub const CRYPT_E_ASN1_INTERNAL: HRESULT = 0x80093101u32 as HRESULT; +pub const CRYPT_E_ASN1_EOD: HRESULT = 0x80093102u32 as HRESULT; +pub const CRYPT_E_ASN1_CORRUPT: HRESULT = 0x80093103u32 as HRESULT; +pub const CRYPT_E_ASN1_LARGE: HRESULT = 0x80093104u32 as HRESULT; +pub const CRYPT_E_ASN1_CONSTRAINT: HRESULT = 0x80093105u32 as HRESULT; +pub const CRYPT_E_ASN1_MEMORY: HRESULT = 0x80093106u32 as HRESULT; +pub const CRYPT_E_ASN1_OVERFLOW: HRESULT = 0x80093107u32 as HRESULT; +pub const CRYPT_E_ASN1_BADPDU: HRESULT = 0x80093108u32 as HRESULT; +pub const CRYPT_E_ASN1_BADARGS: HRESULT = 0x80093109u32 as HRESULT; +pub const CRYPT_E_ASN1_BADREAL: HRESULT = 0x8009310Au32 as HRESULT; +pub const CRYPT_E_ASN1_BADTAG: HRESULT = 0x8009310Bu32 as HRESULT; +pub const CRYPT_E_ASN1_CHOICE: HRESULT = 0x8009310Cu32 as HRESULT; +pub const CRYPT_E_ASN1_RULE: HRESULT = 0x8009310Du32 as HRESULT; +pub const CRYPT_E_ASN1_UTF8: HRESULT = 0x8009310Eu32 as HRESULT; +pub const CRYPT_E_ASN1_PDU_TYPE: HRESULT = 0x80093133u32 as HRESULT; +pub const CRYPT_E_ASN1_NYI: HRESULT = 0x80093134u32 as HRESULT; +pub const CRYPT_E_ASN1_EXTENDED: HRESULT = 0x80093201u32 as HRESULT; +pub const CRYPT_E_ASN1_NOEOD: HRESULT = 0x80093202u32 as HRESULT; +pub const CERTSRV_E_BAD_REQUESTSUBJECT: HRESULT = 0x80094001u32 as HRESULT; +pub const CERTSRV_E_NO_REQUEST: HRESULT = 0x80094002u32 as HRESULT; +pub const CERTSRV_E_BAD_REQUESTSTATUS: HRESULT = 0x80094003u32 as HRESULT; +pub const CERTSRV_E_PROPERTY_EMPTY: HRESULT = 0x80094004u32 as HRESULT; +pub const CERTSRV_E_INVALID_CA_CERTIFICATE: HRESULT = 0x80094005u32 as HRESULT; +pub const CERTSRV_E_SERVER_SUSPENDED: HRESULT = 0x80094006u32 as HRESULT; +pub const CERTSRV_E_ENCODING_LENGTH: HRESULT = 0x80094007u32 as HRESULT; +pub const CERTSRV_E_ROLECONFLICT: HRESULT = 0x80094008u32 as HRESULT; +pub const CERTSRV_E_RESTRICTEDOFFICER: HRESULT = 0x80094009u32 as HRESULT; +pub const CERTSRV_E_KEY_ARCHIVAL_NOT_CONFIGURED: HRESULT = 0x8009400Au32 as HRESULT; +pub const CERTSRV_E_NO_VALID_KRA: HRESULT = 0x8009400Bu32 as HRESULT; +pub const CERTSRV_E_BAD_REQUEST_KEY_ARCHIVAL: HRESULT = 0x8009400Cu32 as HRESULT; +pub const CERTSRV_E_NO_CAADMIN_DEFINED: HRESULT = 0x8009400Du32 as HRESULT; +pub const CERTSRV_E_BAD_RENEWAL_CERT_ATTRIBUTE: HRESULT = 0x8009400Eu32 as HRESULT; +pub const CERTSRV_E_NO_DB_SESSIONS: HRESULT = 0x8009400Fu32 as HRESULT; +pub const CERTSRV_E_ALIGNMENT_FAULT: HRESULT = 0x80094010u32 as HRESULT; +pub const CERTSRV_E_ENROLL_DENIED: HRESULT = 0x80094011u32 as HRESULT; +pub const CERTSRV_E_TEMPLATE_DENIED: HRESULT = 0x80094012u32 as HRESULT; +pub const CERTSRV_E_DOWNLEVEL_DC_SSL_OR_UPGRADE: HRESULT = 0x80094013u32 as HRESULT; +pub const CERTSRV_E_ADMIN_DENIED_REQUEST: HRESULT = 0x80094014u32 as HRESULT; +pub const CERTSRV_E_NO_POLICY_SERVER: HRESULT = 0x80094015u32 as HRESULT; +pub const CERTSRV_E_WEAK_SIGNATURE_OR_KEY: HRESULT = 0x80094016u32 as HRESULT; +pub const CERTSRV_E_KEY_ATTESTATION_NOT_SUPPORTED: HRESULT = 0x80094017u32 as HRESULT; +pub const CERTSRV_E_ENCRYPTION_CERT_REQUIRED: HRESULT = 0x80094018u32 as HRESULT; +pub const CERTSRV_E_UNSUPPORTED_CERT_TYPE: HRESULT = 0x80094800u32 as HRESULT; +pub const CERTSRV_E_NO_CERT_TYPE: HRESULT = 0x80094801u32 as HRESULT; +pub const CERTSRV_E_TEMPLATE_CONFLICT: HRESULT = 0x80094802u32 as HRESULT; +pub const CERTSRV_E_SUBJECT_ALT_NAME_REQUIRED: HRESULT = 0x80094803u32 as HRESULT; +pub const CERTSRV_E_ARCHIVED_KEY_REQUIRED: HRESULT = 0x80094804u32 as HRESULT; +pub const CERTSRV_E_SMIME_REQUIRED: HRESULT = 0x80094805u32 as HRESULT; +pub const CERTSRV_E_BAD_RENEWAL_SUBJECT: HRESULT = 0x80094806u32 as HRESULT; +pub const CERTSRV_E_BAD_TEMPLATE_VERSION: HRESULT = 0x80094807u32 as HRESULT; +pub const CERTSRV_E_TEMPLATE_POLICY_REQUIRED: HRESULT = 0x80094808u32 as HRESULT; +pub const CERTSRV_E_SIGNATURE_POLICY_REQUIRED: HRESULT = 0x80094809u32 as HRESULT; +pub const CERTSRV_E_SIGNATURE_COUNT: HRESULT = 0x8009480Au32 as HRESULT; +pub const CERTSRV_E_SIGNATURE_REJECTED: HRESULT = 0x8009480Bu32 as HRESULT; +pub const CERTSRV_E_ISSUANCE_POLICY_REQUIRED: HRESULT = 0x8009480Cu32 as HRESULT; +pub const CERTSRV_E_SUBJECT_UPN_REQUIRED: HRESULT = 0x8009480Du32 as HRESULT; +pub const CERTSRV_E_SUBJECT_DIRECTORY_GUID_REQUIRED: HRESULT = 0x8009480Eu32 as HRESULT; +pub const CERTSRV_E_SUBJECT_DNS_REQUIRED: HRESULT = 0x8009480Fu32 as HRESULT; +pub const CERTSRV_E_ARCHIVED_KEY_UNEXPECTED: HRESULT = 0x80094810u32 as HRESULT; +pub const CERTSRV_E_KEY_LENGTH: HRESULT = 0x80094811u32 as HRESULT; +pub const CERTSRV_E_SUBJECT_EMAIL_REQUIRED: HRESULT = 0x80094812u32 as HRESULT; +pub const CERTSRV_E_UNKNOWN_CERT_TYPE: HRESULT = 0x80094813u32 as HRESULT; +pub const CERTSRV_E_CERT_TYPE_OVERLAP: HRESULT = 0x80094814u32 as HRESULT; +pub const CERTSRV_E_TOO_MANY_SIGNATURES: HRESULT = 0x80094815u32 as HRESULT; +pub const CERTSRV_E_RENEWAL_BAD_PUBLIC_KEY: HRESULT = 0x80094816u32 as HRESULT; +pub const CERTSRV_E_INVALID_EK: HRESULT = 0x80094817u32 as HRESULT; +pub const CERTSRV_E_INVALID_IDBINDING: HRESULT = 0x80094818u32 as HRESULT; +pub const CERTSRV_E_INVALID_ATTESTATION: HRESULT = 0x80094819u32 as HRESULT; +pub const CERTSRV_E_KEY_ATTESTATION: HRESULT = 0x8009481Au32 as HRESULT; +pub const CERTSRV_E_CORRUPT_KEY_ATTESTATION: HRESULT = 0x8009481Bu32 as HRESULT; +pub const CERTSRV_E_EXPIRED_CHALLENGE: HRESULT = 0x8009481Cu32 as HRESULT; +pub const CERTSRV_E_INVALID_RESPONSE: HRESULT = 0x8009481Du32 as HRESULT; +pub const CERTSRV_E_INVALID_REQUESTID: HRESULT = 0x8009481Eu32 as HRESULT; +pub const XENROLL_E_KEY_NOT_EXPORTABLE: HRESULT = 0x80095000u32 as HRESULT; +pub const XENROLL_E_CANNOT_ADD_ROOT_CERT: HRESULT = 0x80095001u32 as HRESULT; +pub const XENROLL_E_RESPONSE_KA_HASH_NOT_FOUND: HRESULT = 0x80095002u32 as HRESULT; +pub const XENROLL_E_RESPONSE_UNEXPECTED_KA_HASH: HRESULT = 0x80095003u32 as HRESULT; +pub const XENROLL_E_RESPONSE_KA_HASH_MISMATCH: HRESULT = 0x80095004u32 as HRESULT; +pub const XENROLL_E_KEYSPEC_SMIME_MISMATCH: HRESULT = 0x80095005u32 as HRESULT; +pub const TRUST_E_SYSTEM_ERROR: HRESULT = 0x80096001u32 as HRESULT; +pub const TRUST_E_NO_SIGNER_CERT: HRESULT = 0x80096002u32 as HRESULT; +pub const TRUST_E_COUNTER_SIGNER: HRESULT = 0x80096003u32 as HRESULT; +pub const TRUST_E_CERT_SIGNATURE: HRESULT = 0x80096004u32 as HRESULT; +pub const TRUST_E_TIME_STAMP: HRESULT = 0x80096005u32 as HRESULT; +pub const TRUST_E_BAD_DIGEST: HRESULT = 0x80096010u32 as HRESULT; +pub const TRUST_E_BASIC_CONSTRAINTS: HRESULT = 0x80096019u32 as HRESULT; +pub const TRUST_E_FINANCIAL_CRITERIA: HRESULT = 0x8009601Eu32 as HRESULT; +pub const MSSIPOTF_E_OUTOFMEMRANGE: HRESULT = 0x80097001u32 as HRESULT; +pub const MSSIPOTF_E_CANTGETOBJECT: HRESULT = 0x80097002u32 as HRESULT; +pub const MSSIPOTF_E_NOHEADTABLE: HRESULT = 0x80097003u32 as HRESULT; +pub const MSSIPOTF_E_BAD_MAGICNUMBER: HRESULT = 0x80097004u32 as HRESULT; +pub const MSSIPOTF_E_BAD_OFFSET_TABLE: HRESULT = 0x80097005u32 as HRESULT; +pub const MSSIPOTF_E_TABLE_TAGORDER: HRESULT = 0x80097006u32 as HRESULT; +pub const MSSIPOTF_E_TABLE_LONGWORD: HRESULT = 0x80097007u32 as HRESULT; +pub const MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT: HRESULT = 0x80097008u32 as HRESULT; +pub const MSSIPOTF_E_TABLES_OVERLAP: HRESULT = 0x80097009u32 as HRESULT; +pub const MSSIPOTF_E_TABLE_PADBYTES: HRESULT = 0x8009700Au32 as HRESULT; +pub const MSSIPOTF_E_FILETOOSMALL: HRESULT = 0x8009700Bu32 as HRESULT; +pub const MSSIPOTF_E_TABLE_CHECKSUM: HRESULT = 0x8009700Cu32 as HRESULT; +pub const MSSIPOTF_E_FILE_CHECKSUM: HRESULT = 0x8009700Du32 as HRESULT; +pub const MSSIPOTF_E_FAILED_POLICY: HRESULT = 0x80097010u32 as HRESULT; +pub const MSSIPOTF_E_FAILED_HINTS_CHECK: HRESULT = 0x80097011u32 as HRESULT; +pub const MSSIPOTF_E_NOT_OPENTYPE: HRESULT = 0x80097012u32 as HRESULT; +pub const MSSIPOTF_E_FILE: HRESULT = 0x80097013u32 as HRESULT; +pub const MSSIPOTF_E_CRYPT: HRESULT = 0x80097014u32 as HRESULT; +pub const MSSIPOTF_E_BADVERSION: HRESULT = 0x80097015u32 as HRESULT; +pub const MSSIPOTF_E_DSIG_STRUCTURE: HRESULT = 0x80097016u32 as HRESULT; +pub const MSSIPOTF_E_PCONST_CHECK: HRESULT = 0x80097017u32 as HRESULT; +pub const MSSIPOTF_E_STRUCTURE: HRESULT = 0x80097018u32 as HRESULT; +pub const ERROR_CRED_REQUIRES_CONFIRMATION: HRESULT = 0x80097019u32 as HRESULT; +pub const NTE_OP_OK: HRESULT = 0; +pub const TRUST_E_PROVIDER_UNKNOWN: HRESULT = 0x800B0001u32 as HRESULT; +pub const TRUST_E_ACTION_UNKNOWN: HRESULT = 0x800B0002u32 as HRESULT; +pub const TRUST_E_SUBJECT_FORM_UNKNOWN: HRESULT = 0x800B0003u32 as HRESULT; +pub const TRUST_E_SUBJECT_NOT_TRUSTED: HRESULT = 0x800B0004u32 as HRESULT; +pub const DIGSIG_E_ENCODE: HRESULT = 0x800B0005u32 as HRESULT; +pub const DIGSIG_E_DECODE: HRESULT = 0x800B0006u32 as HRESULT; +pub const DIGSIG_E_EXTENSIBILITY: HRESULT = 0x800B0007u32 as HRESULT; +pub const DIGSIG_E_CRYPTO: HRESULT = 0x800B0008u32 as HRESULT; +pub const PERSIST_E_SIZEDEFINITE: HRESULT = 0x800B0009u32 as HRESULT; +pub const PERSIST_E_SIZEINDEFINITE: HRESULT = 0x800B000Au32 as HRESULT; +pub const PERSIST_E_NOTSELFSIZING: HRESULT = 0x800B000Bu32 as HRESULT; +pub const TRUST_E_NOSIGNATURE: HRESULT = 0x800B0100u32 as HRESULT; +pub const CERT_E_EXPIRED: HRESULT = 0x800B0101u32 as HRESULT; +pub const CERT_E_VALIDITYPERIODNESTING: HRESULT = 0x800B0102u32 as HRESULT; +pub const CERT_E_ROLE: HRESULT = 0x800B0103u32 as HRESULT; +pub const CERT_E_PATHLENCONST: HRESULT = 0x800B0104u32 as HRESULT; +pub const CERT_E_CRITICAL: HRESULT = 0x800B0105u32 as HRESULT; +pub const CERT_E_PURPOSE: HRESULT = 0x800B0106u32 as HRESULT; +pub const CERT_E_ISSUERCHAINING: HRESULT = 0x800B0107u32 as HRESULT; +pub const CERT_E_MALFORMED: HRESULT = 0x800B0108u32 as HRESULT; +pub const CERT_E_UNTRUSTEDROOT: HRESULT = 0x800B0109u32 as HRESULT; +pub const CERT_E_CHAINING: HRESULT = 0x800B010Au32 as HRESULT; +pub const TRUST_E_FAIL: HRESULT = 0x800B010Bu32 as HRESULT; +pub const CERT_E_REVOKED: HRESULT = 0x800B010Cu32 as HRESULT; +pub const CERT_E_UNTRUSTEDTESTROOT: HRESULT = 0x800B010Du32 as HRESULT; +pub const CERT_E_REVOCATION_FAILURE: HRESULT = 0x800B010Eu32 as HRESULT; +pub const CERT_E_CN_NO_MATCH: HRESULT = 0x800B010Fu32 as HRESULT; +pub const CERT_E_WRONG_USAGE: HRESULT = 0x800B0110u32 as HRESULT; +pub const TRUST_E_EXPLICIT_DISTRUST: HRESULT = 0x800B0111u32 as HRESULT; +pub const CERT_E_UNTRUSTEDCA: HRESULT = 0x800B0112u32 as HRESULT; +pub const CERT_E_INVALID_POLICY: HRESULT = 0x800B0113u32 as HRESULT; +pub const CERT_E_INVALID_NAME: HRESULT = 0x800B0114u32 as HRESULT; +pub const SPAPI_E_EXPECTED_SECTION_NAME: HRESULT = 0x800F0000u32 as HRESULT; +pub const SPAPI_E_BAD_SECTION_NAME_LINE: HRESULT = 0x800F0001u32 as HRESULT; +pub const SPAPI_E_SECTION_NAME_TOO_LONG: HRESULT = 0x800F0002u32 as HRESULT; +pub const SPAPI_E_GENERAL_SYNTAX: HRESULT = 0x800F0003u32 as HRESULT; +pub const SPAPI_E_WRONG_INF_STYLE: HRESULT = 0x800F0100u32 as HRESULT; +pub const SPAPI_E_SECTION_NOT_FOUND: HRESULT = 0x800F0101u32 as HRESULT; +pub const SPAPI_E_LINE_NOT_FOUND: HRESULT = 0x800F0102u32 as HRESULT; +pub const SPAPI_E_NO_BACKUP: HRESULT = 0x800F0103u32 as HRESULT; +pub const SPAPI_E_NO_ASSOCIATED_CLASS: HRESULT = 0x800F0200u32 as HRESULT; +pub const SPAPI_E_CLASS_MISMATCH: HRESULT = 0x800F0201u32 as HRESULT; +pub const SPAPI_E_DUPLICATE_FOUND: HRESULT = 0x800F0202u32 as HRESULT; +pub const SPAPI_E_NO_DRIVER_SELECTED: HRESULT = 0x800F0203u32 as HRESULT; +pub const SPAPI_E_KEY_DOES_NOT_EXIST: HRESULT = 0x800F0204u32 as HRESULT; +pub const SPAPI_E_INVALID_DEVINST_NAME: HRESULT = 0x800F0205u32 as HRESULT; +pub const SPAPI_E_INVALID_CLASS: HRESULT = 0x800F0206u32 as HRESULT; +pub const SPAPI_E_DEVINST_ALREADY_EXISTS: HRESULT = 0x800F0207u32 as HRESULT; +pub const SPAPI_E_DEVINFO_NOT_REGISTERED: HRESULT = 0x800F0208u32 as HRESULT; +pub const SPAPI_E_INVALID_REG_PROPERTY: HRESULT = 0x800F0209u32 as HRESULT; +pub const SPAPI_E_NO_INF: HRESULT = 0x800F020Au32 as HRESULT; +pub const SPAPI_E_NO_SUCH_DEVINST: HRESULT = 0x800F020Bu32 as HRESULT; +pub const SPAPI_E_CANT_LOAD_CLASS_ICON: HRESULT = 0x800F020Cu32 as HRESULT; +pub const SPAPI_E_INVALID_CLASS_INSTALLER: HRESULT = 0x800F020Du32 as HRESULT; +pub const SPAPI_E_DI_DO_DEFAULT: HRESULT = 0x800F020Eu32 as HRESULT; +pub const SPAPI_E_DI_NOFILECOPY: HRESULT = 0x800F020Fu32 as HRESULT; +pub const SPAPI_E_INVALID_HWPROFILE: HRESULT = 0x800F0210u32 as HRESULT; +pub const SPAPI_E_NO_DEVICE_SELECTED: HRESULT = 0x800F0211u32 as HRESULT; +pub const SPAPI_E_DEVINFO_LIST_LOCKED: HRESULT = 0x800F0212u32 as HRESULT; +pub const SPAPI_E_DEVINFO_DATA_LOCKED: HRESULT = 0x800F0213u32 as HRESULT; +pub const SPAPI_E_DI_BAD_PATH: HRESULT = 0x800F0214u32 as HRESULT; +pub const SPAPI_E_NO_CLASSINSTALL_PARAMS: HRESULT = 0x800F0215u32 as HRESULT; +pub const SPAPI_E_FILEQUEUE_LOCKED: HRESULT = 0x800F0216u32 as HRESULT; +pub const SPAPI_E_BAD_SERVICE_INSTALLSECT: HRESULT = 0x800F0217u32 as HRESULT; +pub const SPAPI_E_NO_CLASS_DRIVER_LIST: HRESULT = 0x800F0218u32 as HRESULT; +pub const SPAPI_E_NO_ASSOCIATED_SERVICE: HRESULT = 0x800F0219u32 as HRESULT; +pub const SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE: HRESULT = 0x800F021Au32 as HRESULT; +pub const SPAPI_E_DEVICE_INTERFACE_ACTIVE: HRESULT = 0x800F021Bu32 as HRESULT; +pub const SPAPI_E_DEVICE_INTERFACE_REMOVED: HRESULT = 0x800F021Cu32 as HRESULT; +pub const SPAPI_E_BAD_INTERFACE_INSTALLSECT: HRESULT = 0x800F021Du32 as HRESULT; +pub const SPAPI_E_NO_SUCH_INTERFACE_CLASS: HRESULT = 0x800F021Eu32 as HRESULT; +pub const SPAPI_E_INVALID_REFERENCE_STRING: HRESULT = 0x800F021Fu32 as HRESULT; +pub const SPAPI_E_INVALID_MACHINENAME: HRESULT = 0x800F0220u32 as HRESULT; +pub const SPAPI_E_REMOTE_COMM_FAILURE: HRESULT = 0x800F0221u32 as HRESULT; +pub const SPAPI_E_MACHINE_UNAVAILABLE: HRESULT = 0x800F0222u32 as HRESULT; +pub const SPAPI_E_NO_CONFIGMGR_SERVICES: HRESULT = 0x800F0223u32 as HRESULT; +pub const SPAPI_E_INVALID_PROPPAGE_PROVIDER: HRESULT = 0x800F0224u32 as HRESULT; +pub const SPAPI_E_NO_SUCH_DEVICE_INTERFACE: HRESULT = 0x800F0225u32 as HRESULT; +pub const SPAPI_E_DI_POSTPROCESSING_REQUIRED: HRESULT = 0x800F0226u32 as HRESULT; +pub const SPAPI_E_INVALID_COINSTALLER: HRESULT = 0x800F0227u32 as HRESULT; +pub const SPAPI_E_NO_COMPAT_DRIVERS: HRESULT = 0x800F0228u32 as HRESULT; +pub const SPAPI_E_NO_DEVICE_ICON: HRESULT = 0x800F0229u32 as HRESULT; +pub const SPAPI_E_INVALID_INF_LOGCONFIG: HRESULT = 0x800F022Au32 as HRESULT; +pub const SPAPI_E_DI_DONT_INSTALL: HRESULT = 0x800F022Bu32 as HRESULT; +pub const SPAPI_E_INVALID_FILTER_DRIVER: HRESULT = 0x800F022Cu32 as HRESULT; +pub const SPAPI_E_NON_WINDOWS_NT_DRIVER: HRESULT = 0x800F022Du32 as HRESULT; +pub const SPAPI_E_NON_WINDOWS_DRIVER: HRESULT = 0x800F022Eu32 as HRESULT; +pub const SPAPI_E_NO_CATALOG_FOR_OEM_INF: HRESULT = 0x800F022Fu32 as HRESULT; +pub const SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE: HRESULT = 0x800F0230u32 as HRESULT; +pub const SPAPI_E_NOT_DISABLEABLE: HRESULT = 0x800F0231u32 as HRESULT; +pub const SPAPI_E_CANT_REMOVE_DEVINST: HRESULT = 0x800F0232u32 as HRESULT; +pub const SPAPI_E_INVALID_TARGET: HRESULT = 0x800F0233u32 as HRESULT; +pub const SPAPI_E_DRIVER_NONNATIVE: HRESULT = 0x800F0234u32 as HRESULT; +pub const SPAPI_E_IN_WOW64: HRESULT = 0x800F0235u32 as HRESULT; +pub const SPAPI_E_SET_SYSTEM_RESTORE_POINT: HRESULT = 0x800F0236u32 as HRESULT; +pub const SPAPI_E_INCORRECTLY_COPIED_INF: HRESULT = 0x800F0237u32 as HRESULT; +pub const SPAPI_E_SCE_DISABLED: HRESULT = 0x800F0238u32 as HRESULT; +pub const SPAPI_E_UNKNOWN_EXCEPTION: HRESULT = 0x800F0239u32 as HRESULT; +pub const SPAPI_E_PNP_REGISTRY_ERROR: HRESULT = 0x800F023Au32 as HRESULT; +pub const SPAPI_E_REMOTE_REQUEST_UNSUPPORTED: HRESULT = 0x800F023Bu32 as HRESULT; +pub const SPAPI_E_NOT_AN_INSTALLED_OEM_INF: HRESULT = 0x800F023Cu32 as HRESULT; +pub const SPAPI_E_INF_IN_USE_BY_DEVICES: HRESULT = 0x800F023Du32 as HRESULT; +pub const SPAPI_E_DI_FUNCTION_OBSOLETE: HRESULT = 0x800F023Eu32 as HRESULT; +pub const SPAPI_E_NO_AUTHENTICODE_CATALOG: HRESULT = 0x800F023Fu32 as HRESULT; +pub const SPAPI_E_AUTHENTICODE_DISALLOWED: HRESULT = 0x800F0240u32 as HRESULT; +pub const SPAPI_E_AUTHENTICODE_TRUSTED_PUBLISHER: HRESULT = 0x800F0241u32 as HRESULT; +pub const SPAPI_E_AUTHENTICODE_TRUST_NOT_ESTABLISHED: HRESULT = 0x800F0242u32 as HRESULT; +pub const SPAPI_E_AUTHENTICODE_PUBLISHER_NOT_TRUSTED: HRESULT = 0x800F0243u32 as HRESULT; +pub const SPAPI_E_SIGNATURE_OSATTRIBUTE_MISMATCH: HRESULT = 0x800F0244u32 as HRESULT; +pub const SPAPI_E_ONLY_VALIDATE_VIA_AUTHENTICODE: HRESULT = 0x800F0245u32 as HRESULT; +pub const SPAPI_E_DEVICE_INSTALLER_NOT_READY: HRESULT = 0x800F0246u32 as HRESULT; +pub const SPAPI_E_DRIVER_STORE_ADD_FAILED: HRESULT = 0x800F0247u32 as HRESULT; +pub const SPAPI_E_DEVICE_INSTALL_BLOCKED: HRESULT = 0x800F0248u32 as HRESULT; +pub const SPAPI_E_DRIVER_INSTALL_BLOCKED: HRESULT = 0x800F0249u32 as HRESULT; +pub const SPAPI_E_WRONG_INF_TYPE: HRESULT = 0x800F024Au32 as HRESULT; +pub const SPAPI_E_FILE_HASH_NOT_IN_CATALOG: HRESULT = 0x800F024Bu32 as HRESULT; +pub const SPAPI_E_DRIVER_STORE_DELETE_FAILED: HRESULT = 0x800F024Cu32 as HRESULT; +pub const SPAPI_E_UNRECOVERABLE_STACK_OVERFLOW: HRESULT = 0x800F0300u32 as HRESULT; +pub const SPAPI_E_ERROR_NOT_INSTALLED: HRESULT = 0x800F1000u32 as HRESULT; +pub const SCARD_S_SUCCESS: HRESULT = NO_ERROR as HRESULT; +pub const SCARD_F_INTERNAL_ERROR: HRESULT = 0x80100001u32 as HRESULT; +pub const SCARD_E_CANCELLED: HRESULT = 0x80100002u32 as HRESULT; +pub const SCARD_E_INVALID_HANDLE: HRESULT = 0x80100003u32 as HRESULT; +pub const SCARD_E_INVALID_PARAMETER: HRESULT = 0x80100004u32 as HRESULT; +pub const SCARD_E_INVALID_TARGET: HRESULT = 0x80100005u32 as HRESULT; +pub const SCARD_E_NO_MEMORY: HRESULT = 0x80100006u32 as HRESULT; +pub const SCARD_F_WAITED_TOO_LONG: HRESULT = 0x80100007u32 as HRESULT; +pub const SCARD_E_INSUFFICIENT_BUFFER: HRESULT = 0x80100008u32 as HRESULT; +pub const SCARD_E_UNKNOWN_READER: HRESULT = 0x80100009u32 as HRESULT; +pub const SCARD_E_TIMEOUT: HRESULT = 0x8010000Au32 as HRESULT; +pub const SCARD_E_SHARING_VIOLATION: HRESULT = 0x8010000Bu32 as HRESULT; +pub const SCARD_E_NO_SMARTCARD: HRESULT = 0x8010000Cu32 as HRESULT; +pub const SCARD_E_UNKNOWN_CARD: HRESULT = 0x8010000Du32 as HRESULT; +pub const SCARD_E_CANT_DISPOSE: HRESULT = 0x8010000Eu32 as HRESULT; +pub const SCARD_E_PROTO_MISMATCH: HRESULT = 0x8010000Fu32 as HRESULT; +pub const SCARD_E_NOT_READY: HRESULT = 0x80100010u32 as HRESULT; +pub const SCARD_E_INVALID_VALUE: HRESULT = 0x80100011u32 as HRESULT; +pub const SCARD_E_SYSTEM_CANCELLED: HRESULT = 0x80100012u32 as HRESULT; +pub const SCARD_F_COMM_ERROR: HRESULT = 0x80100013u32 as HRESULT; +pub const SCARD_F_UNKNOWN_ERROR: HRESULT = 0x80100014u32 as HRESULT; +pub const SCARD_E_INVALID_ATR: HRESULT = 0x80100015u32 as HRESULT; +pub const SCARD_E_NOT_TRANSACTED: HRESULT = 0x80100016u32 as HRESULT; +pub const SCARD_E_READER_UNAVAILABLE: HRESULT = 0x80100017u32 as HRESULT; +pub const SCARD_P_SHUTDOWN: HRESULT = 0x80100018u32 as HRESULT; +pub const SCARD_E_PCI_TOO_SMALL: HRESULT = 0x80100019u32 as HRESULT; +pub const SCARD_E_READER_UNSUPPORTED: HRESULT = 0x8010001Au32 as HRESULT; +pub const SCARD_E_DUPLICATE_READER: HRESULT = 0x8010001Bu32 as HRESULT; +pub const SCARD_E_CARD_UNSUPPORTED: HRESULT = 0x8010001Cu32 as HRESULT; +pub const SCARD_E_NO_SERVICE: HRESULT = 0x8010001Du32 as HRESULT; +pub const SCARD_E_SERVICE_STOPPED: HRESULT = 0x8010001Eu32 as HRESULT; +pub const SCARD_E_UNEXPECTED: HRESULT = 0x8010001Fu32 as HRESULT; +pub const SCARD_E_ICC_INSTALLATION: HRESULT = 0x80100020u32 as HRESULT; +pub const SCARD_E_ICC_CREATEORDER: HRESULT = 0x80100021u32 as HRESULT; +pub const SCARD_E_UNSUPPORTED_FEATURE: HRESULT = 0x80100022u32 as HRESULT; +pub const SCARD_E_DIR_NOT_FOUND: HRESULT = 0x80100023u32 as HRESULT; +pub const SCARD_E_FILE_NOT_FOUND: HRESULT = 0x80100024u32 as HRESULT; +pub const SCARD_E_NO_DIR: HRESULT = 0x80100025u32 as HRESULT; +pub const SCARD_E_NO_FILE: HRESULT = 0x80100026u32 as HRESULT; +pub const SCARD_E_NO_ACCESS: HRESULT = 0x80100027u32 as HRESULT; +pub const SCARD_E_WRITE_TOO_MANY: HRESULT = 0x80100028u32 as HRESULT; +pub const SCARD_E_BAD_SEEK: HRESULT = 0x80100029u32 as HRESULT; +pub const SCARD_E_INVALID_CHV: HRESULT = 0x8010002Au32 as HRESULT; +pub const SCARD_E_UNKNOWN_RES_MNG: HRESULT = 0x8010002Bu32 as HRESULT; +pub const SCARD_E_NO_SUCH_CERTIFICATE: HRESULT = 0x8010002Cu32 as HRESULT; +pub const SCARD_E_CERTIFICATE_UNAVAILABLE: HRESULT = 0x8010002Du32 as HRESULT; +pub const SCARD_E_NO_READERS_AVAILABLE: HRESULT = 0x8010002Eu32 as HRESULT; +pub const SCARD_E_COMM_DATA_LOST: HRESULT = 0x8010002Fu32 as HRESULT; +pub const SCARD_E_NO_KEY_CONTAINER: HRESULT = 0x80100030u32 as HRESULT; +pub const SCARD_E_SERVER_TOO_BUSY: HRESULT = 0x80100031u32 as HRESULT; +pub const SCARD_E_PIN_CACHE_EXPIRED: HRESULT = 0x80100032u32 as HRESULT; +pub const SCARD_E_NO_PIN_CACHE: HRESULT = 0x80100033u32 as HRESULT; +pub const SCARD_E_READ_ONLY_CARD: HRESULT = 0x80100034u32 as HRESULT; +pub const SCARD_W_UNSUPPORTED_CARD: HRESULT = 0x80100065u32 as HRESULT; +pub const SCARD_W_UNRESPONSIVE_CARD: HRESULT = 0x80100066u32 as HRESULT; +pub const SCARD_W_UNPOWERED_CARD: HRESULT = 0x80100067u32 as HRESULT; +pub const SCARD_W_RESET_CARD: HRESULT = 0x80100068u32 as HRESULT; +pub const SCARD_W_REMOVED_CARD: HRESULT = 0x80100069u32 as HRESULT; +pub const SCARD_W_SECURITY_VIOLATION: HRESULT = 0x8010006Au32 as HRESULT; +pub const SCARD_W_WRONG_CHV: HRESULT = 0x8010006Bu32 as HRESULT; +pub const SCARD_W_CHV_BLOCKED: HRESULT = 0x8010006Cu32 as HRESULT; +pub const SCARD_W_EOF: HRESULT = 0x8010006Du32 as HRESULT; +pub const SCARD_W_CANCELLED_BY_USER: HRESULT = 0x8010006Eu32 as HRESULT; +pub const SCARD_W_CARD_NOT_AUTHENTICATED: HRESULT = 0x8010006Fu32 as HRESULT; +pub const SCARD_W_CACHE_ITEM_NOT_FOUND: HRESULT = 0x80100070u32 as HRESULT; +pub const SCARD_W_CACHE_ITEM_STALE: HRESULT = 0x80100071u32 as HRESULT; +pub const SCARD_W_CACHE_ITEM_TOO_BIG: HRESULT = 0x80100072u32 as HRESULT; +pub const COMADMIN_E_OBJECTERRORS: HRESULT = 0x80110401u32 as HRESULT; +pub const COMADMIN_E_OBJECTINVALID: HRESULT = 0x80110402u32 as HRESULT; +pub const COMADMIN_E_KEYMISSING: HRESULT = 0x80110403u32 as HRESULT; +pub const COMADMIN_E_ALREADYINSTALLED: HRESULT = 0x80110404u32 as HRESULT; +pub const COMADMIN_E_APP_FILE_WRITEFAIL: HRESULT = 0x80110407u32 as HRESULT; +pub const COMADMIN_E_APP_FILE_READFAIL: HRESULT = 0x80110408u32 as HRESULT; +pub const COMADMIN_E_APP_FILE_VERSION: HRESULT = 0x80110409u32 as HRESULT; +pub const COMADMIN_E_BADPATH: HRESULT = 0x8011040Au32 as HRESULT; +pub const COMADMIN_E_APPLICATIONEXISTS: HRESULT = 0x8011040Bu32 as HRESULT; +pub const COMADMIN_E_ROLEEXISTS: HRESULT = 0x8011040Cu32 as HRESULT; +pub const COMADMIN_E_CANTCOPYFILE: HRESULT = 0x8011040Du32 as HRESULT; +pub const COMADMIN_E_NOUSER: HRESULT = 0x8011040Fu32 as HRESULT; +pub const COMADMIN_E_INVALIDUSERIDS: HRESULT = 0x80110410u32 as HRESULT; +pub const COMADMIN_E_NOREGISTRYCLSID: HRESULT = 0x80110411u32 as HRESULT; +pub const COMADMIN_E_BADREGISTRYPROGID: HRESULT = 0x80110412u32 as HRESULT; +pub const COMADMIN_E_AUTHENTICATIONLEVEL: HRESULT = 0x80110413u32 as HRESULT; +pub const COMADMIN_E_USERPASSWDNOTVALID: HRESULT = 0x80110414u32 as HRESULT; +pub const COMADMIN_E_CLSIDORIIDMISMATCH: HRESULT = 0x80110418u32 as HRESULT; +pub const COMADMIN_E_REMOTEINTERFACE: HRESULT = 0x80110419u32 as HRESULT; +pub const COMADMIN_E_DLLREGISTERSERVER: HRESULT = 0x8011041Au32 as HRESULT; +pub const COMADMIN_E_NOSERVERSHARE: HRESULT = 0x8011041Bu32 as HRESULT; +pub const COMADMIN_E_DLLLOADFAILED: HRESULT = 0x8011041Du32 as HRESULT; +pub const COMADMIN_E_BADREGISTRYLIBID: HRESULT = 0x8011041Eu32 as HRESULT; +pub const COMADMIN_E_APPDIRNOTFOUND: HRESULT = 0x8011041Fu32 as HRESULT; +pub const COMADMIN_E_REGISTRARFAILED: HRESULT = 0x80110423u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_DOESNOTEXIST: HRESULT = 0x80110424u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_LOADDLLFAIL: HRESULT = 0x80110425u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_GETCLASSOBJ: HRESULT = 0x80110426u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_CLASSNOTAVAIL: HRESULT = 0x80110427u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_BADTLB: HRESULT = 0x80110428u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_NOTINSTALLABLE: HRESULT = 0x80110429u32 as HRESULT; +pub const COMADMIN_E_NOTCHANGEABLE: HRESULT = 0x8011042Au32 as HRESULT; +pub const COMADMIN_E_NOTDELETEABLE: HRESULT = 0x8011042Bu32 as HRESULT; +pub const COMADMIN_E_SESSION: HRESULT = 0x8011042Cu32 as HRESULT; +pub const COMADMIN_E_COMP_MOVE_LOCKED: HRESULT = 0x8011042Du32 as HRESULT; +pub const COMADMIN_E_COMP_MOVE_BAD_DEST: HRESULT = 0x8011042Eu32 as HRESULT; +pub const COMADMIN_E_REGISTERTLB: HRESULT = 0x80110430u32 as HRESULT; +pub const COMADMIN_E_SYSTEMAPP: HRESULT = 0x80110433u32 as HRESULT; +pub const COMADMIN_E_COMPFILE_NOREGISTRAR: HRESULT = 0x80110434u32 as HRESULT; +pub const COMADMIN_E_COREQCOMPINSTALLED: HRESULT = 0x80110435u32 as HRESULT; +pub const COMADMIN_E_SERVICENOTINSTALLED: HRESULT = 0x80110436u32 as HRESULT; +pub const COMADMIN_E_PROPERTYSAVEFAILED: HRESULT = 0x80110437u32 as HRESULT; +pub const COMADMIN_E_OBJECTEXISTS: HRESULT = 0x80110438u32 as HRESULT; +pub const COMADMIN_E_COMPONENTEXISTS: HRESULT = 0x80110439u32 as HRESULT; +pub const COMADMIN_E_REGFILE_CORRUPT: HRESULT = 0x8011043Bu32 as HRESULT; +pub const COMADMIN_E_PROPERTY_OVERFLOW: HRESULT = 0x8011043Cu32 as HRESULT; +pub const COMADMIN_E_NOTINREGISTRY: HRESULT = 0x8011043Eu32 as HRESULT; +pub const COMADMIN_E_OBJECTNOTPOOLABLE: HRESULT = 0x8011043Fu32 as HRESULT; +pub const COMADMIN_E_APPLID_MATCHES_CLSID: HRESULT = 0x80110446u32 as HRESULT; +pub const COMADMIN_E_ROLE_DOES_NOT_EXIST: HRESULT = 0x80110447u32 as HRESULT; +pub const COMADMIN_E_START_APP_NEEDS_COMPONENTS: HRESULT = 0x80110448u32 as HRESULT; +pub const COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM: HRESULT = 0x80110449u32 as HRESULT; +pub const COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY: HRESULT = 0x8011044Au32 as HRESULT; +pub const COMADMIN_E_CAN_NOT_START_APP: HRESULT = 0x8011044Bu32 as HRESULT; +pub const COMADMIN_E_CAN_NOT_EXPORT_SYS_APP: HRESULT = 0x8011044Cu32 as HRESULT; +pub const COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT: HRESULT = 0x8011044Du32 as HRESULT; +pub const COMADMIN_E_EVENTCLASS_CANT_BE_SUBSCRIBER: HRESULT = 0x8011044Eu32 as HRESULT; +pub const COMADMIN_E_LIB_APP_PROXY_INCOMPATIBLE: HRESULT = 0x8011044Fu32 as HRESULT; +pub const COMADMIN_E_BASE_PARTITION_ONLY: HRESULT = 0x80110450u32 as HRESULT; +pub const COMADMIN_E_START_APP_DISABLED: HRESULT = 0x80110451u32 as HRESULT; +pub const COMADMIN_E_CAT_DUPLICATE_PARTITION_NAME: HRESULT = 0x80110457u32 as HRESULT; +pub const COMADMIN_E_CAT_INVALID_PARTITION_NAME: HRESULT = 0x80110458u32 as HRESULT; +pub const COMADMIN_E_CAT_PARTITION_IN_USE: HRESULT = 0x80110459u32 as HRESULT; +pub const COMADMIN_E_FILE_PARTITION_DUPLICATE_FILES: HRESULT = 0x8011045Au32 as HRESULT; +pub const COMADMIN_E_CAT_IMPORTED_COMPONENTS_NOT_ALLOWED: HRESULT = 0x8011045Bu32 as HRESULT; +pub const COMADMIN_E_AMBIGUOUS_APPLICATION_NAME: HRESULT = 0x8011045Cu32 as HRESULT; +pub const COMADMIN_E_AMBIGUOUS_PARTITION_NAME: HRESULT = 0x8011045Du32 as HRESULT; +pub const COMADMIN_E_REGDB_NOTINITIALIZED: HRESULT = 0x80110472u32 as HRESULT; +pub const COMADMIN_E_REGDB_NOTOPEN: HRESULT = 0x80110473u32 as HRESULT; +pub const COMADMIN_E_REGDB_SYSTEMERR: HRESULT = 0x80110474u32 as HRESULT; +pub const COMADMIN_E_REGDB_ALREADYRUNNING: HRESULT = 0x80110475u32 as HRESULT; +pub const COMADMIN_E_MIG_VERSIONNOTSUPPORTED: HRESULT = 0x80110480u32 as HRESULT; +pub const COMADMIN_E_MIG_SCHEMANOTFOUND: HRESULT = 0x80110481u32 as HRESULT; +pub const COMADMIN_E_CAT_BITNESSMISMATCH: HRESULT = 0x80110482u32 as HRESULT; +pub const COMADMIN_E_CAT_UNACCEPTABLEBITNESS: HRESULT = 0x80110483u32 as HRESULT; +pub const COMADMIN_E_CAT_WRONGAPPBITNESS: HRESULT = 0x80110484u32 as HRESULT; +pub const COMADMIN_E_CAT_PAUSE_RESUME_NOT_SUPPORTED: HRESULT = 0x80110485u32 as HRESULT; +pub const COMADMIN_E_CAT_SERVERFAULT: HRESULT = 0x80110486u32 as HRESULT; +pub const COMQC_E_APPLICATION_NOT_QUEUED: HRESULT = 0x80110600u32 as HRESULT; +pub const COMQC_E_NO_QUEUEABLE_INTERFACES: HRESULT = 0x80110601u32 as HRESULT; +pub const COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE: HRESULT = 0x80110602u32 as HRESULT; +pub const COMQC_E_NO_IPERSISTSTREAM: HRESULT = 0x80110603u32 as HRESULT; +pub const COMQC_E_BAD_MESSAGE: HRESULT = 0x80110604u32 as HRESULT; +pub const COMQC_E_UNAUTHENTICATED: HRESULT = 0x80110605u32 as HRESULT; +pub const COMQC_E_UNTRUSTED_ENQUEUER: HRESULT = 0x80110606u32 as HRESULT; +pub const MSDTC_E_DUPLICATE_RESOURCE: HRESULT = 0x80110701u32 as HRESULT; +pub const COMADMIN_E_OBJECT_PARENT_MISSING: HRESULT = 0x80110808u32 as HRESULT; +pub const COMADMIN_E_OBJECT_DOES_NOT_EXIST: HRESULT = 0x80110809u32 as HRESULT; +pub const COMADMIN_E_APP_NOT_RUNNING: HRESULT = 0x8011080Au32 as HRESULT; +pub const COMADMIN_E_INVALID_PARTITION: HRESULT = 0x8011080Bu32 as HRESULT; +pub const COMADMIN_E_SVCAPP_NOT_POOLABLE_OR_RECYCLABLE: HRESULT = 0x8011080Du32 as HRESULT; +pub const COMADMIN_E_USER_IN_SET: HRESULT = 0x8011080Eu32 as HRESULT; +pub const COMADMIN_E_CANTRECYCLELIBRARYAPPS: HRESULT = 0x8011080Fu32 as HRESULT; +pub const COMADMIN_E_CANTRECYCLESERVICEAPPS: HRESULT = 0x80110811u32 as HRESULT; +pub const COMADMIN_E_PROCESSALREADYRECYCLED: HRESULT = 0x80110812u32 as HRESULT; +pub const COMADMIN_E_PAUSEDPROCESSMAYNOTBERECYCLED: HRESULT = 0x80110813u32 as HRESULT; +pub const COMADMIN_E_CANTMAKEINPROCSERVICE: HRESULT = 0x80110814u32 as HRESULT; +pub const COMADMIN_E_PROGIDINUSEBYCLSID: HRESULT = 0x80110815u32 as HRESULT; +pub const COMADMIN_E_DEFAULT_PARTITION_NOT_IN_SET: HRESULT = 0x80110816u32 as HRESULT; +pub const COMADMIN_E_RECYCLEDPROCESSMAYNOTBEPAUSED: HRESULT = 0x80110817u32 as HRESULT; +pub const COMADMIN_E_PARTITION_ACCESSDENIED: HRESULT = 0x80110818u32 as HRESULT; +pub const COMADMIN_E_PARTITION_MSI_ONLY: HRESULT = 0x80110819u32 as HRESULT; +pub const COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_1_0_FORMAT: HRESULT = 0x8011081Au32 as HRESULT; +pub const COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_NONBASE_PARTITIONS: HRESULT = 0x8011081Bu32 as HRESULT; +pub const COMADMIN_E_COMP_MOVE_SOURCE: HRESULT = 0x8011081Cu32 as HRESULT; +pub const COMADMIN_E_COMP_MOVE_DEST: HRESULT = 0x8011081Du32 as HRESULT; +pub const COMADMIN_E_COMP_MOVE_PRIVATE: HRESULT = 0x8011081Eu32 as HRESULT; +pub const COMADMIN_E_BASEPARTITION_REQUIRED_IN_SET: HRESULT = 0x8011081Fu32 as HRESULT; +pub const COMADMIN_E_CANNOT_ALIAS_EVENTCLASS: HRESULT = 0x80110820u32 as HRESULT; +pub const COMADMIN_E_PRIVATE_ACCESSDENIED: HRESULT = 0x80110821u32 as HRESULT; +pub const COMADMIN_E_SAFERINVALID: HRESULT = 0x80110822u32 as HRESULT; +pub const COMADMIN_E_REGISTRY_ACCESSDENIED: HRESULT = 0x80110823u32 as HRESULT; +pub const COMADMIN_E_PARTITIONS_DISABLED: HRESULT = 0x80110824u32 as HRESULT; +pub const WER_S_REPORT_DEBUG: HRESULT = 0x001B0000; +pub const WER_S_REPORT_UPLOADED: HRESULT = 0x001B0001; +pub const WER_S_REPORT_QUEUED: HRESULT = 0x001B0002; +pub const WER_S_DISABLED: HRESULT = 0x001B0003; +pub const WER_S_SUSPENDED_UPLOAD: HRESULT = 0x001B0004; +pub const WER_S_DISABLED_QUEUE: HRESULT = 0x001B0005; +pub const WER_S_DISABLED_ARCHIVE: HRESULT = 0x001B0006; +pub const WER_S_REPORT_ASYNC: HRESULT = 0x001B0007; +pub const WER_S_IGNORE_ASSERT_INSTANCE: HRESULT = 0x001B0008; +pub const WER_S_IGNORE_ALL_ASSERTS: HRESULT = 0x001B0009; +pub const WER_S_ASSERT_CONTINUE: HRESULT = 0x001B000A; +pub const WER_S_THROTTLED: HRESULT = 0x001B000B; +pub const WER_E_CRASH_FAILURE: HRESULT = 0x801B8000u32 as HRESULT; +pub const WER_E_CANCELED: HRESULT = 0x801B8001u32 as HRESULT; +pub const WER_E_NETWORK_FAILURE: HRESULT = 0x801B8002u32 as HRESULT; +pub const WER_E_NOT_INITIALIZED: HRESULT = 0x801B8003u32 as HRESULT; +pub const WER_E_ALREADY_REPORTING: HRESULT = 0x801B8004u32 as HRESULT; +pub const WER_E_DUMP_THROTTLED: HRESULT = 0x801B8005u32 as HRESULT; +pub const ERROR_FLT_IO_COMPLETE: HRESULT = 0x001F0001; +pub const ERROR_FLT_NO_HANDLER_DEFINED: HRESULT = 0x801F0001u32 as HRESULT; +pub const ERROR_FLT_CONTEXT_ALREADY_DEFINED: HRESULT = 0x801F0002u32 as HRESULT; +pub const ERROR_FLT_INVALID_ASYNCHRONOUS_REQUEST: HRESULT = 0x801F0003u32 as HRESULT; +pub const ERROR_FLT_DISALLOW_FAST_IO: HRESULT = 0x801F0004u32 as HRESULT; +pub const ERROR_FLT_INVALID_NAME_REQUEST: HRESULT = 0x801F0005u32 as HRESULT; +pub const ERROR_FLT_NOT_SAFE_TO_POST_OPERATION: HRESULT = 0x801F0006u32 as HRESULT; +pub const ERROR_FLT_NOT_INITIALIZED: HRESULT = 0x801F0007u32 as HRESULT; +pub const ERROR_FLT_FILTER_NOT_READY: HRESULT = 0x801F0008u32 as HRESULT; +pub const ERROR_FLT_POST_OPERATION_CLEANUP: HRESULT = 0x801F0009u32 as HRESULT; +pub const ERROR_FLT_INTERNAL_ERROR: HRESULT = 0x801F000Au32 as HRESULT; +pub const ERROR_FLT_DELETING_OBJECT: HRESULT = 0x801F000Bu32 as HRESULT; +pub const ERROR_FLT_MUST_BE_NONPAGED_POOL: HRESULT = 0x801F000Cu32 as HRESULT; +pub const ERROR_FLT_DUPLICATE_ENTRY: HRESULT = 0x801F000Du32 as HRESULT; +pub const ERROR_FLT_CBDQ_DISABLED: HRESULT = 0x801F000Eu32 as HRESULT; +pub const ERROR_FLT_DO_NOT_ATTACH: HRESULT = 0x801F000Fu32 as HRESULT; +pub const ERROR_FLT_DO_NOT_DETACH: HRESULT = 0x801F0010u32 as HRESULT; +pub const ERROR_FLT_INSTANCE_ALTITUDE_COLLISION: HRESULT = 0x801F0011u32 as HRESULT; +pub const ERROR_FLT_INSTANCE_NAME_COLLISION: HRESULT = 0x801F0012u32 as HRESULT; +pub const ERROR_FLT_FILTER_NOT_FOUND: HRESULT = 0x801F0013u32 as HRESULT; +pub const ERROR_FLT_VOLUME_NOT_FOUND: HRESULT = 0x801F0014u32 as HRESULT; +pub const ERROR_FLT_INSTANCE_NOT_FOUND: HRESULT = 0x801F0015u32 as HRESULT; +pub const ERROR_FLT_CONTEXT_ALLOCATION_NOT_FOUND: HRESULT = 0x801F0016u32 as HRESULT; +pub const ERROR_FLT_INVALID_CONTEXT_REGISTRATION: HRESULT = 0x801F0017u32 as HRESULT; +pub const ERROR_FLT_NAME_CACHE_MISS: HRESULT = 0x801F0018u32 as HRESULT; +pub const ERROR_FLT_NO_DEVICE_OBJECT: HRESULT = 0x801F0019u32 as HRESULT; +pub const ERROR_FLT_VOLUME_ALREADY_MOUNTED: HRESULT = 0x801F001Au32 as HRESULT; +pub const ERROR_FLT_ALREADY_ENLISTED: HRESULT = 0x801F001Bu32 as HRESULT; +pub const ERROR_FLT_CONTEXT_ALREADY_LINKED: HRESULT = 0x801F001Cu32 as HRESULT; +pub const ERROR_FLT_NO_WAITER_FOR_REPLY: HRESULT = 0x801F0020u32 as HRESULT; +pub const ERROR_FLT_REGISTRATION_BUSY: HRESULT = 0x801F0023u32 as HRESULT; +pub const ERROR_HUNG_DISPLAY_DRIVER_THREAD: HRESULT = 0x80260001u32 as HRESULT; +pub const DWM_E_COMPOSITIONDISABLED: HRESULT = 0x80263001u32 as HRESULT; +pub const DWM_E_REMOTING_NOT_SUPPORTED: HRESULT = 0x80263002u32 as HRESULT; +pub const DWM_E_NO_REDIRECTION_SURFACE_AVAILABLE: HRESULT = 0x80263003u32 as HRESULT; +pub const DWM_E_NOT_QUEUING_PRESENTS: HRESULT = 0x80263004u32 as HRESULT; +pub const DWM_E_ADAPTER_NOT_FOUND: HRESULT = 0x80263005u32 as HRESULT; +pub const DWM_S_GDI_REDIRECTION_SURFACE: HRESULT = 0x00263005; +pub const DWM_E_TEXTURE_TOO_LARGE: HRESULT = 0x80263007u32 as HRESULT; +pub const ERROR_MONITOR_NO_DESCRIPTOR: HRESULT = 0x80261001u32 as HRESULT; +pub const ERROR_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT: HRESULT = 0x80261002u32 as HRESULT; +pub const ERROR_MONITOR_INVALID_DESCRIPTOR_CHECKSUM: HRESULT = 0xC0261003u32 as HRESULT; +pub const ERROR_MONITOR_INVALID_STANDARD_TIMING_BLOCK: HRESULT = 0xC0261004u32 as HRESULT; +pub const ERROR_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED: HRESULT = 0xC0261005u32 as HRESULT; +pub const ERROR_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK: HRESULT = 0xC0261006u32 as HRESULT; +pub const ERROR_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK: HRESULT = 0xC0261007u32 as HRESULT; +pub const ERROR_MONITOR_NO_MORE_DESCRIPTOR_DATA: HRESULT = 0xC0261008u32 as HRESULT; +pub const ERROR_MONITOR_INVALID_DETAILED_TIMING_BLOCK: HRESULT = 0xC0261009u32 as HRESULT; +pub const ERROR_MONITOR_INVALID_MANUFACTURE_DATE: HRESULT = 0xC026100Au32 as HRESULT; +pub const ERROR_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER: HRESULT = 0xC0262000u32 as HRESULT; +pub const ERROR_GRAPHICS_INSUFFICIENT_DMA_BUFFER: HRESULT = 0xC0262001u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_DISPLAY_ADAPTER: HRESULT = 0xC0262002u32 as HRESULT; +pub const ERROR_GRAPHICS_ADAPTER_WAS_RESET: HRESULT = 0xC0262003u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_DRIVER_MODEL: HRESULT = 0xC0262004u32 as HRESULT; +pub const ERROR_GRAPHICS_PRESENT_MODE_CHANGED: HRESULT = 0xC0262005u32 as HRESULT; +pub const ERROR_GRAPHICS_PRESENT_OCCLUDED: HRESULT = 0xC0262006u32 as HRESULT; +pub const ERROR_GRAPHICS_PRESENT_DENIED: HRESULT = 0xC0262007u32 as HRESULT; +pub const ERROR_GRAPHICS_CANNOTCOLORCONVERT: HRESULT = 0xC0262008u32 as HRESULT; +pub const ERROR_GRAPHICS_DRIVER_MISMATCH: HRESULT = 0xC0262009u32 as HRESULT; +pub const ERROR_GRAPHICS_PARTIAL_DATA_POPULATED: HRESULT = 0x4026200A; +pub const ERROR_GRAPHICS_PRESENT_REDIRECTION_DISABLED: HRESULT = 0xC026200Bu32 as HRESULT; +pub const ERROR_GRAPHICS_PRESENT_UNOCCLUDED: HRESULT = 0xC026200Cu32 as HRESULT; +pub const ERROR_GRAPHICS_WINDOWDC_NOT_AVAILABLE: HRESULT = 0xC026200Du32 as HRESULT; +pub const ERROR_GRAPHICS_WINDOWLESS_PRESENT_DISABLED: HRESULT = 0xC026200Eu32 as HRESULT; +pub const ERROR_GRAPHICS_NO_VIDEO_MEMORY: HRESULT = 0xC0262100u32 as HRESULT; +pub const ERROR_GRAPHICS_CANT_LOCK_MEMORY: HRESULT = 0xC0262101u32 as HRESULT; +pub const ERROR_GRAPHICS_ALLOCATION_BUSY: HRESULT = 0xC0262102u32 as HRESULT; +pub const ERROR_GRAPHICS_TOO_MANY_REFERENCES: HRESULT = 0xC0262103u32 as HRESULT; +pub const ERROR_GRAPHICS_TRY_AGAIN_LATER: HRESULT = 0xC0262104u32 as HRESULT; +pub const ERROR_GRAPHICS_TRY_AGAIN_NOW: HRESULT = 0xC0262105u32 as HRESULT; +pub const ERROR_GRAPHICS_ALLOCATION_INVALID: HRESULT = 0xC0262106u32 as HRESULT; +pub const ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE: HRESULT = 0xC0262107u32 as HRESULT; +pub const ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED: HRESULT = 0xC0262108u32 as HRESULT; +pub const ERROR_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION: HRESULT = 0xC0262109u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_ALLOCATION_USAGE: HRESULT = 0xC0262110u32 as HRESULT; +pub const ERROR_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION: HRESULT = 0xC0262111u32 as HRESULT; +pub const ERROR_GRAPHICS_ALLOCATION_CLOSED: HRESULT = 0xC0262112u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_ALLOCATION_INSTANCE: HRESULT = 0xC0262113u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_ALLOCATION_HANDLE: HRESULT = 0xC0262114u32 as HRESULT; +pub const ERROR_GRAPHICS_WRONG_ALLOCATION_DEVICE: HRESULT = 0xC0262115u32 as HRESULT; +pub const ERROR_GRAPHICS_ALLOCATION_CONTENT_LOST: HRESULT = 0xC0262116u32 as HRESULT; +pub const ERROR_GRAPHICS_GPU_EXCEPTION_ON_DEVICE: HRESULT = 0xC0262200u32 as HRESULT; +pub const ERROR_GRAPHICS_SKIP_ALLOCATION_PREPARATION: HRESULT = 0x40262201; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY: HRESULT = 0xC0262300u32 as HRESULT; +pub const ERROR_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED: HRESULT = 0xC0262301u32 as HRESULT; +pub const ERROR_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED: HRESULT = 0xC0262302u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDPN: HRESULT = 0xC0262303u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE: HRESULT = 0xC0262304u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET: HRESULT = 0xC0262305u32 as HRESULT; +pub const ERROR_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED: HRESULT = 0xC0262306u32 as HRESULT; +pub const ERROR_GRAPHICS_MODE_NOT_PINNED: HRESULT = 0x00262307; +pub const ERROR_GRAPHICS_INVALID_VIDPN_SOURCEMODESET: HRESULT = 0xC0262308u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TARGETMODESET: HRESULT = 0xC0262309u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_FREQUENCY: HRESULT = 0xC026230Au32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_ACTIVE_REGION: HRESULT = 0xC026230Bu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_TOTAL_REGION: HRESULT = 0xC026230Cu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE: HRESULT = 0xC0262310u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE: HRESULT = 0xC0262311u32 as HRESULT; +pub const ERROR_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET: HRESULT = 0xC0262312u32 as HRESULT; +pub const ERROR_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY: HRESULT = 0xC0262313u32 as HRESULT; +pub const ERROR_GRAPHICS_MODE_ALREADY_IN_MODESET: HRESULT = 0xC0262314u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET: HRESULT = 0xC0262315u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET: HRESULT = 0xC0262316u32 as HRESULT; +pub const ERROR_GRAPHICS_SOURCE_ALREADY_IN_SET: HRESULT = 0xC0262317u32 as HRESULT; +pub const ERROR_GRAPHICS_TARGET_ALREADY_IN_SET: HRESULT = 0xC0262318u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDPN_PRESENT_PATH: HRESULT = 0xC0262319u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY: HRESULT = 0xC026231Au32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET: HRESULT = 0xC026231Bu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE: HRESULT = 0xC026231Cu32 as HRESULT; +pub const ERROR_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET: HRESULT = 0xC026231Du32 as HRESULT; +pub const ERROR_GRAPHICS_NO_PREFERRED_MODE: HRESULT = 0x0026231E; +pub const ERROR_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET: HRESULT = 0xC026231Fu32 as HRESULT; +pub const ERROR_GRAPHICS_STALE_MODESET: HRESULT = 0xC0262320u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITOR_SOURCEMODESET: HRESULT = 0xC0262321u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITOR_SOURCE_MODE: HRESULT = 0xC0262322u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN: HRESULT = 0xC0262323u32 as HRESULT; +pub const ERROR_GRAPHICS_MODE_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262324u32 as HRESULT; +pub const ERROR_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION: HRESULT = 0xC0262325u32 as HRESULT; +pub const ERROR_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES: HRESULT = 0xC0262326u32 as HRESULT; +pub const ERROR_GRAPHICS_PATH_NOT_IN_TOPOLOGY: HRESULT = 0xC0262327u32 as HRESULT; +pub const ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE: HRESULT = 0xC0262328u32 as HRESULT; +pub const ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET: HRESULT = 0xC0262329u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITORDESCRIPTORSET: HRESULT = 0xC026232Au32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITORDESCRIPTOR: HRESULT = 0xC026232Bu32 as HRESULT; +pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET: HRESULT = 0xC026232Cu32 as HRESULT; +pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET: HRESULT = 0xC026232Du32 as HRESULT; +pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE: HRESULT = 0xC026232Eu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE: HRESULT = 0xC026232Fu32 as HRESULT; +pub const ERROR_GRAPHICS_RESOURCES_NOT_RELATED: HRESULT = 0xC0262330u32 as HRESULT; +pub const ERROR_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262331u32 as HRESULT; +pub const ERROR_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262332u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET: HRESULT = 0xC0262333u32 as HRESULT; +pub const ERROR_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER: HRESULT = 0xC0262334u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_VIDPNMGR: HRESULT = 0xC0262335u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_ACTIVE_VIDPN: HRESULT = 0xC0262336u32 as HRESULT; +pub const ERROR_GRAPHICS_STALE_VIDPN_TOPOLOGY: HRESULT = 0xC0262337u32 as HRESULT; +pub const ERROR_GRAPHICS_MONITOR_NOT_CONNECTED: HRESULT = 0xC0262338u32 as HRESULT; +pub const ERROR_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY: HRESULT = 0xC0262339u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE: HRESULT = 0xC026233Au32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_VISIBLEREGION_SIZE: HRESULT = 0xC026233Bu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_STRIDE: HRESULT = 0xC026233Cu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PIXELFORMAT: HRESULT = 0xC026233Du32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_COLORBASIS: HRESULT = 0xC026233Eu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PIXELVALUEACCESSMODE: HRESULT = 0xC026233Fu32 as HRESULT; +pub const ERROR_GRAPHICS_TARGET_NOT_IN_TOPOLOGY: HRESULT = 0xC0262340u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT: HRESULT = 0xC0262341u32 as HRESULT; +pub const ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0xC0262342u32 as HRESULT; +pub const ERROR_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN: HRESULT = 0xC0262343u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL: HRESULT = 0xC0262344u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION: HRESULT = 0xC0262345u32 as HRESULT; +pub const ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED: HRESULT = 0xC0262346u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_GAMMA_RAMP: HRESULT = 0xC0262347u32 as HRESULT; +pub const ERROR_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED: HRESULT = 0xC0262348u32 as HRESULT; +pub const ERROR_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED: HRESULT = 0xC0262349u32 as HRESULT; +pub const ERROR_GRAPHICS_MODE_NOT_IN_MODESET: HRESULT = 0xC026234Au32 as HRESULT; +pub const ERROR_GRAPHICS_DATASET_IS_EMPTY: HRESULT = 0x0026234B; +pub const ERROR_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET: HRESULT = 0x0026234C; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON: HRESULT = 0xC026234Du32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PATH_CONTENT_TYPE: HRESULT = 0xC026234Eu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_COPYPROTECTION_TYPE: HRESULT = 0xC026234Fu32 as HRESULT; +pub const ERROR_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS: HRESULT = 0xC0262350u32 as HRESULT; +pub const ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED: HRESULT = 0x00262351; +pub const ERROR_GRAPHICS_INVALID_SCANLINE_ORDERING: HRESULT = 0xC0262352u32 as HRESULT; +pub const ERROR_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED: HRESULT = 0xC0262353u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS: HRESULT = 0xC0262354u32 as HRESULT; +pub const ERROR_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT: HRESULT = 0xC0262355u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM: HRESULT = 0xC0262356u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN: HRESULT = 0xC0262357u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT: HRESULT = 0xC0262358u32 as HRESULT; +pub const ERROR_GRAPHICS_MAX_NUM_PATHS_REACHED: HRESULT = 0xC0262359u32 as HRESULT; +pub const ERROR_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION: HRESULT = 0xC026235Au32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_CLIENT_TYPE: HRESULT = 0xC026235Bu32 as HRESULT; +pub const ERROR_GRAPHICS_CLIENTVIDPN_NOT_SET: HRESULT = 0xC026235Cu32 as HRESULT; +pub const ERROR_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED: HRESULT = 0xC0262400u32 as HRESULT; +pub const ERROR_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED: HRESULT = 0xC0262401u32 as HRESULT; +pub const ERROR_GRAPHICS_UNKNOWN_CHILD_STATUS: HRESULT = 0x4026242F; +pub const ERROR_GRAPHICS_NOT_A_LINKED_ADAPTER: HRESULT = 0xC0262430u32 as HRESULT; +pub const ERROR_GRAPHICS_LEADLINK_NOT_ENUMERATED: HRESULT = 0xC0262431u32 as HRESULT; +pub const ERROR_GRAPHICS_CHAINLINKS_NOT_ENUMERATED: HRESULT = 0xC0262432u32 as HRESULT; +pub const ERROR_GRAPHICS_ADAPTER_CHAIN_NOT_READY: HRESULT = 0xC0262433u32 as HRESULT; +pub const ERROR_GRAPHICS_CHAINLINKS_NOT_STARTED: HRESULT = 0xC0262434u32 as HRESULT; +pub const ERROR_GRAPHICS_CHAINLINKS_NOT_POWERED_ON: HRESULT = 0xC0262435u32 as HRESULT; +pub const ERROR_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE: HRESULT = 0xC0262436u32 as HRESULT; +pub const ERROR_GRAPHICS_LEADLINK_START_DEFERRED: HRESULT = 0x40262437; +pub const ERROR_GRAPHICS_NOT_POST_DEVICE_DRIVER: HRESULT = 0xC0262438u32 as HRESULT; +pub const ERROR_GRAPHICS_POLLING_TOO_FREQUENTLY: HRESULT = 0x40262439; +pub const ERROR_GRAPHICS_START_DEFERRED: HRESULT = 0x4026243A; +pub const ERROR_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED: HRESULT = 0xC026243Bu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_NOT_SUPPORTED: HRESULT = 0xC0262500u32 as HRESULT; +pub const ERROR_GRAPHICS_COPP_NOT_SUPPORTED: HRESULT = 0xC0262501u32 as HRESULT; +pub const ERROR_GRAPHICS_UAB_NOT_SUPPORTED: HRESULT = 0xC0262502u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS: HRESULT = 0xC0262503u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_NO_VIDEO_OUTPUTS_EXIST: HRESULT = 0xC0262505u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_INTERNAL_ERROR: HRESULT = 0xC026250Bu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_INVALID_HANDLE: HRESULT = 0xC026250Cu32 as HRESULT; +pub const ERROR_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH: HRESULT = 0xC026250Eu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_SPANNING_MODE_ENABLED: HRESULT = 0xC026250Fu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_THEATER_MODE_ENABLED: HRESULT = 0xC0262510u32 as HRESULT; +pub const ERROR_GRAPHICS_PVP_HFS_FAILED: HRESULT = 0xC0262511u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_INVALID_SRM: HRESULT = 0xC0262512u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP: HRESULT = 0xC0262513u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP: HRESULT = 0xC0262514u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA: HRESULT = 0xC0262515u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_HDCP_SRM_NEVER_SET: HRESULT = 0xC0262516u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_RESOLUTION_TOO_HIGH: HRESULT = 0xC0262517u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE: HRESULT = 0xC0262518u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_NO_LONGER_EXISTS: HRESULT = 0xC026251Au32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_SESSION_TYPE_CHANGE_IN_PROGRESS: HRESULT = 0xC026251Bu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS: HRESULT = 0xC026251Cu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST: HRESULT = 0xC026251Du32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR: HRESULT = 0xC026251Eu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS: HRESULT = 0xC026251Fu32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED: HRESULT = 0xC0262520u32 as HRESULT; +pub const ERROR_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST: HRESULT = 0xC0262521u32 as HRESULT; +pub const ERROR_GRAPHICS_I2C_NOT_SUPPORTED: HRESULT = 0xC0262580u32 as HRESULT; +pub const ERROR_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST: HRESULT = 0xC0262581u32 as HRESULT; +pub const ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA: HRESULT = 0xC0262582u32 as HRESULT; +pub const ERROR_GRAPHICS_I2C_ERROR_RECEIVING_DATA: HRESULT = 0xC0262583u32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED: HRESULT = 0xC0262584u32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_INVALID_DATA: HRESULT = 0xC0262585u32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE: HRESULT = 0xC0262586u32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_INVALID_CAPABILITIES_STRING: HRESULT = 0xC0262587u32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_INTERNAL_ERROR: HRESULT = 0xC0262588u32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND: HRESULT = 0xC0262589u32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH: HRESULT = 0xC026258Au32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM: HRESULT = 0xC026258Bu32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE: HRESULT = 0xC026258Cu32 as HRESULT; +pub const ERROR_GRAPHICS_MONITOR_NO_LONGER_EXISTS: HRESULT = 0xC026258Du32 as HRESULT; +pub const ERROR_GRAPHICS_DDCCI_CURRENT_CURRENT_VALUE_GREATER_THAN_MAXIMUM_VALUE: HRESULT = 0xC02625D8u32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_INVALID_VCP_VERSION: HRESULT = 0xC02625D9u32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: HRESULT = 0xC02625DAu32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_MCCS_VERSION_MISMATCH: HRESULT = 0xC02625DBu32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_UNSUPPORTED_MCCS_VERSION: HRESULT = 0xC02625DCu32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: HRESULT = 0xC02625DEu32 as HRESULT; +pub const ERROR_GRAPHICS_MCA_UNSUPPORTED_COLOR_TEMPERATURE: HRESULT = 0xC02625DFu32 as HRESULT; +pub const ERROR_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED: HRESULT = 0xC02625E0u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME: HRESULT = 0xC02625E1u32 as HRESULT; +pub const ERROR_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP: HRESULT = 0xC02625E2u32 as HRESULT; +pub const ERROR_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED: HRESULT = 0xC02625E3u32 as HRESULT; +pub const ERROR_GRAPHICS_INVALID_POINTER: HRESULT = 0xC02625E4u32 as HRESULT; +pub const ERROR_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE: HRESULT = 0xC02625E5u32 as HRESULT; +pub const ERROR_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL: HRESULT = 0xC02625E6u32 as HRESULT; +pub const ERROR_GRAPHICS_INTERNAL_ERROR: HRESULT = 0xC02625E7u32 as HRESULT; +pub const ERROR_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS: HRESULT = 0xC02605E8u32 as HRESULT; +pub const NAP_E_INVALID_PACKET: HRESULT = 0x80270001u32 as HRESULT; +pub const NAP_E_MISSING_SOH: HRESULT = 0x80270002u32 as HRESULT; +pub const NAP_E_CONFLICTING_ID: HRESULT = 0x80270003u32 as HRESULT; +pub const NAP_E_NO_CACHED_SOH: HRESULT = 0x80270004u32 as HRESULT; +pub const NAP_E_STILL_BOUND: HRESULT = 0x80270005u32 as HRESULT; +pub const NAP_E_NOT_REGISTERED: HRESULT = 0x80270006u32 as HRESULT; +pub const NAP_E_NOT_INITIALIZED: HRESULT = 0x80270007u32 as HRESULT; +pub const NAP_E_MISMATCHED_ID: HRESULT = 0x80270008u32 as HRESULT; +pub const NAP_E_NOT_PENDING: HRESULT = 0x80270009u32 as HRESULT; +pub const NAP_E_ID_NOT_FOUND: HRESULT = 0x8027000Au32 as HRESULT; +pub const NAP_E_MAXSIZE_TOO_SMALL: HRESULT = 0x8027000Bu32 as HRESULT; +pub const NAP_E_SERVICE_NOT_RUNNING: HRESULT = 0x8027000Cu32 as HRESULT; +pub const NAP_S_CERT_ALREADY_PRESENT: HRESULT = 0x0027000D; +pub const NAP_E_ENTITY_DISABLED: HRESULT = 0x8027000Eu32 as HRESULT; +pub const NAP_E_NETSH_GROUPPOLICY_ERROR: HRESULT = 0x8027000Fu32 as HRESULT; +pub const NAP_E_TOO_MANY_CALLS: HRESULT = 0x80270010u32 as HRESULT; +pub const NAP_E_SHV_CONFIG_EXISTED: HRESULT = 0x80270011u32 as HRESULT; +pub const NAP_E_SHV_CONFIG_NOT_FOUND: HRESULT = 0x80270012u32 as HRESULT; +pub const NAP_E_SHV_TIMEOUT: HRESULT = 0x80270013u32 as HRESULT; +pub const TPM_E_ERROR_MASK: HRESULT = 0x80280000u32 as HRESULT; +pub const TPM_E_AUTHFAIL: HRESULT = 0x80280001u32 as HRESULT; +pub const TPM_E_BADINDEX: HRESULT = 0x80280002u32 as HRESULT; +pub const TPM_E_BAD_PARAMETER: HRESULT = 0x80280003u32 as HRESULT; +pub const TPM_E_AUDITFAILURE: HRESULT = 0x80280004u32 as HRESULT; +pub const TPM_E_CLEAR_DISABLED: HRESULT = 0x80280005u32 as HRESULT; +pub const TPM_E_DEACTIVATED: HRESULT = 0x80280006u32 as HRESULT; +pub const TPM_E_DISABLED: HRESULT = 0x80280007u32 as HRESULT; +pub const TPM_E_DISABLED_CMD: HRESULT = 0x80280008u32 as HRESULT; +pub const TPM_E_FAIL: HRESULT = 0x80280009u32 as HRESULT; +pub const TPM_E_BAD_ORDINAL: HRESULT = 0x8028000Au32 as HRESULT; +pub const TPM_E_INSTALL_DISABLED: HRESULT = 0x8028000Bu32 as HRESULT; +pub const TPM_E_INVALID_KEYHANDLE: HRESULT = 0x8028000Cu32 as HRESULT; +pub const TPM_E_KEYNOTFOUND: HRESULT = 0x8028000Du32 as HRESULT; +pub const TPM_E_INAPPROPRIATE_ENC: HRESULT = 0x8028000Eu32 as HRESULT; +pub const TPM_E_MIGRATEFAIL: HRESULT = 0x8028000Fu32 as HRESULT; +pub const TPM_E_INVALID_PCR_INFO: HRESULT = 0x80280010u32 as HRESULT; +pub const TPM_E_NOSPACE: HRESULT = 0x80280011u32 as HRESULT; +pub const TPM_E_NOSRK: HRESULT = 0x80280012u32 as HRESULT; +pub const TPM_E_NOTSEALED_BLOB: HRESULT = 0x80280013u32 as HRESULT; +pub const TPM_E_OWNER_SET: HRESULT = 0x80280014u32 as HRESULT; +pub const TPM_E_RESOURCES: HRESULT = 0x80280015u32 as HRESULT; +pub const TPM_E_SHORTRANDOM: HRESULT = 0x80280016u32 as HRESULT; +pub const TPM_E_SIZE: HRESULT = 0x80280017u32 as HRESULT; +pub const TPM_E_WRONGPCRVAL: HRESULT = 0x80280018u32 as HRESULT; +pub const TPM_E_BAD_PARAM_SIZE: HRESULT = 0x80280019u32 as HRESULT; +pub const TPM_E_SHA_THREAD: HRESULT = 0x8028001Au32 as HRESULT; +pub const TPM_E_SHA_ERROR: HRESULT = 0x8028001Bu32 as HRESULT; +pub const TPM_E_FAILEDSELFTEST: HRESULT = 0x8028001Cu32 as HRESULT; +pub const TPM_E_AUTH2FAIL: HRESULT = 0x8028001Du32 as HRESULT; +pub const TPM_E_BADTAG: HRESULT = 0x8028001Eu32 as HRESULT; +pub const TPM_E_IOERROR: HRESULT = 0x8028001Fu32 as HRESULT; +pub const TPM_E_ENCRYPT_ERROR: HRESULT = 0x80280020u32 as HRESULT; +pub const TPM_E_DECRYPT_ERROR: HRESULT = 0x80280021u32 as HRESULT; +pub const TPM_E_INVALID_AUTHHANDLE: HRESULT = 0x80280022u32 as HRESULT; +pub const TPM_E_NO_ENDORSEMENT: HRESULT = 0x80280023u32 as HRESULT; +pub const TPM_E_INVALID_KEYUSAGE: HRESULT = 0x80280024u32 as HRESULT; +pub const TPM_E_WRONG_ENTITYTYPE: HRESULT = 0x80280025u32 as HRESULT; +pub const TPM_E_INVALID_POSTINIT: HRESULT = 0x80280026u32 as HRESULT; +pub const TPM_E_INAPPROPRIATE_SIG: HRESULT = 0x80280027u32 as HRESULT; +pub const TPM_E_BAD_KEY_PROPERTY: HRESULT = 0x80280028u32 as HRESULT; +pub const TPM_E_BAD_MIGRATION: HRESULT = 0x80280029u32 as HRESULT; +pub const TPM_E_BAD_SCHEME: HRESULT = 0x8028002Au32 as HRESULT; +pub const TPM_E_BAD_DATASIZE: HRESULT = 0x8028002Bu32 as HRESULT; +pub const TPM_E_BAD_MODE: HRESULT = 0x8028002Cu32 as HRESULT; +pub const TPM_E_BAD_PRESENCE: HRESULT = 0x8028002Du32 as HRESULT; +pub const TPM_E_BAD_VERSION: HRESULT = 0x8028002Eu32 as HRESULT; +pub const TPM_E_NO_WRAP_TRANSPORT: HRESULT = 0x8028002Fu32 as HRESULT; +pub const TPM_E_AUDITFAIL_UNSUCCESSFUL: HRESULT = 0x80280030u32 as HRESULT; +pub const TPM_E_AUDITFAIL_SUCCESSFUL: HRESULT = 0x80280031u32 as HRESULT; +pub const TPM_E_NOTRESETABLE: HRESULT = 0x80280032u32 as HRESULT; +pub const TPM_E_NOTLOCAL: HRESULT = 0x80280033u32 as HRESULT; +pub const TPM_E_BAD_TYPE: HRESULT = 0x80280034u32 as HRESULT; +pub const TPM_E_INVALID_RESOURCE: HRESULT = 0x80280035u32 as HRESULT; +pub const TPM_E_NOTFIPS: HRESULT = 0x80280036u32 as HRESULT; +pub const TPM_E_INVALID_FAMILY: HRESULT = 0x80280037u32 as HRESULT; +pub const TPM_E_NO_NV_PERMISSION: HRESULT = 0x80280038u32 as HRESULT; +pub const TPM_E_REQUIRES_SIGN: HRESULT = 0x80280039u32 as HRESULT; +pub const TPM_E_KEY_NOTSUPPORTED: HRESULT = 0x8028003Au32 as HRESULT; +pub const TPM_E_AUTH_CONFLICT: HRESULT = 0x8028003Bu32 as HRESULT; +pub const TPM_E_AREA_LOCKED: HRESULT = 0x8028003Cu32 as HRESULT; +pub const TPM_E_BAD_LOCALITY: HRESULT = 0x8028003Du32 as HRESULT; +pub const TPM_E_READ_ONLY: HRESULT = 0x8028003Eu32 as HRESULT; +pub const TPM_E_PER_NOWRITE: HRESULT = 0x8028003Fu32 as HRESULT; +pub const TPM_E_FAMILYCOUNT: HRESULT = 0x80280040u32 as HRESULT; +pub const TPM_E_WRITE_LOCKED: HRESULT = 0x80280041u32 as HRESULT; +pub const TPM_E_BAD_ATTRIBUTES: HRESULT = 0x80280042u32 as HRESULT; +pub const TPM_E_INVALID_STRUCTURE: HRESULT = 0x80280043u32 as HRESULT; +pub const TPM_E_KEY_OWNER_CONTROL: HRESULT = 0x80280044u32 as HRESULT; +pub const TPM_E_BAD_COUNTER: HRESULT = 0x80280045u32 as HRESULT; +pub const TPM_E_NOT_FULLWRITE: HRESULT = 0x80280046u32 as HRESULT; +pub const TPM_E_CONTEXT_GAP: HRESULT = 0x80280047u32 as HRESULT; +pub const TPM_E_MAXNVWRITES: HRESULT = 0x80280048u32 as HRESULT; +pub const TPM_E_NOOPERATOR: HRESULT = 0x80280049u32 as HRESULT; +pub const TPM_E_RESOURCEMISSING: HRESULT = 0x8028004Au32 as HRESULT; +pub const TPM_E_DELEGATE_LOCK: HRESULT = 0x8028004Bu32 as HRESULT; +pub const TPM_E_DELEGATE_FAMILY: HRESULT = 0x8028004Cu32 as HRESULT; +pub const TPM_E_DELEGATE_ADMIN: HRESULT = 0x8028004Du32 as HRESULT; +pub const TPM_E_TRANSPORT_NOTEXCLUSIVE: HRESULT = 0x8028004Eu32 as HRESULT; +pub const TPM_E_OWNER_CONTROL: HRESULT = 0x8028004Fu32 as HRESULT; +pub const TPM_E_DAA_RESOURCES: HRESULT = 0x80280050u32 as HRESULT; +pub const TPM_E_DAA_INPUT_DATA0: HRESULT = 0x80280051u32 as HRESULT; +pub const TPM_E_DAA_INPUT_DATA1: HRESULT = 0x80280052u32 as HRESULT; +pub const TPM_E_DAA_ISSUER_SETTINGS: HRESULT = 0x80280053u32 as HRESULT; +pub const TPM_E_DAA_TPM_SETTINGS: HRESULT = 0x80280054u32 as HRESULT; +pub const TPM_E_DAA_STAGE: HRESULT = 0x80280055u32 as HRESULT; +pub const TPM_E_DAA_ISSUER_VALIDITY: HRESULT = 0x80280056u32 as HRESULT; +pub const TPM_E_DAA_WRONG_W: HRESULT = 0x80280057u32 as HRESULT; +pub const TPM_E_BAD_HANDLE: HRESULT = 0x80280058u32 as HRESULT; +pub const TPM_E_BAD_DELEGATE: HRESULT = 0x80280059u32 as HRESULT; +pub const TPM_E_BADCONTEXT: HRESULT = 0x8028005Au32 as HRESULT; +pub const TPM_E_TOOMANYCONTEXTS: HRESULT = 0x8028005Bu32 as HRESULT; +pub const TPM_E_MA_TICKET_SIGNATURE: HRESULT = 0x8028005Cu32 as HRESULT; +pub const TPM_E_MA_DESTINATION: HRESULT = 0x8028005Du32 as HRESULT; +pub const TPM_E_MA_SOURCE: HRESULT = 0x8028005Eu32 as HRESULT; +pub const TPM_E_MA_AUTHORITY: HRESULT = 0x8028005Fu32 as HRESULT; +pub const TPM_E_PERMANENTEK: HRESULT = 0x80280061u32 as HRESULT; +pub const TPM_E_BAD_SIGNATURE: HRESULT = 0x80280062u32 as HRESULT; +pub const TPM_E_NOCONTEXTSPACE: HRESULT = 0x80280063u32 as HRESULT; +pub const TPM_E_COMMAND_BLOCKED: HRESULT = 0x80280400u32 as HRESULT; +pub const TPM_E_INVALID_HANDLE: HRESULT = 0x80280401u32 as HRESULT; +pub const TPM_E_DUPLICATE_VHANDLE: HRESULT = 0x80280402u32 as HRESULT; +pub const TPM_E_EMBEDDED_COMMAND_BLOCKED: HRESULT = 0x80280403u32 as HRESULT; +pub const TPM_E_EMBEDDED_COMMAND_UNSUPPORTED: HRESULT = 0x80280404u32 as HRESULT; +pub const TPM_E_RETRY: HRESULT = 0x80280800u32 as HRESULT; +pub const TPM_E_NEEDS_SELFTEST: HRESULT = 0x80280801u32 as HRESULT; +pub const TPM_E_DOING_SELFTEST: HRESULT = 0x80280802u32 as HRESULT; +pub const TPM_E_DEFEND_LOCK_RUNNING: HRESULT = 0x80280803u32 as HRESULT; +pub const TBS_E_INTERNAL_ERROR: HRESULT = 0x80284001u32 as HRESULT; +pub const TBS_E_BAD_PARAMETER: HRESULT = 0x80284002u32 as HRESULT; +pub const TBS_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80284003u32 as HRESULT; +pub const TBS_E_INVALID_CONTEXT: HRESULT = 0x80284004u32 as HRESULT; +pub const TBS_E_INSUFFICIENT_BUFFER: HRESULT = 0x80284005u32 as HRESULT; +pub const TBS_E_IOERROR: HRESULT = 0x80284006u32 as HRESULT; +pub const TBS_E_INVALID_CONTEXT_PARAM: HRESULT = 0x80284007u32 as HRESULT; +pub const TBS_E_SERVICE_NOT_RUNNING: HRESULT = 0x80284008u32 as HRESULT; +pub const TBS_E_TOO_MANY_TBS_CONTEXTS: HRESULT = 0x80284009u32 as HRESULT; +pub const TBS_E_TOO_MANY_RESOURCES: HRESULT = 0x8028400Au32 as HRESULT; +pub const TBS_E_SERVICE_START_PENDING: HRESULT = 0x8028400Bu32 as HRESULT; +pub const TBS_E_PPI_NOT_SUPPORTED: HRESULT = 0x8028400Cu32 as HRESULT; +pub const TBS_E_COMMAND_CANCELED: HRESULT = 0x8028400Du32 as HRESULT; +pub const TBS_E_BUFFER_TOO_LARGE: HRESULT = 0x8028400Eu32 as HRESULT; +pub const TBS_E_TPM_NOT_FOUND: HRESULT = 0x8028400Fu32 as HRESULT; +pub const TBS_E_SERVICE_DISABLED: HRESULT = 0x80284010u32 as HRESULT; +pub const TBS_E_NO_EVENT_LOG: HRESULT = 0x80284011u32 as HRESULT; +pub const TBS_E_ACCESS_DENIED: HRESULT = 0x80284012u32 as HRESULT; +pub const TBS_E_PROVISIONING_NOT_ALLOWED: HRESULT = 0x80284013u32 as HRESULT; +pub const TBS_E_PPI_FUNCTION_UNSUPPORTED: HRESULT = 0x80284014u32 as HRESULT; +pub const TBS_E_OWNERAUTH_NOT_FOUND: HRESULT = 0x80284015u32 as HRESULT; +pub const TBS_E_PROVISIONING_INCOMPLETE: HRESULT = 0x80284016u32 as HRESULT; +pub const TPMAPI_E_INVALID_STATE: HRESULT = 0x80290100u32 as HRESULT; +pub const TPMAPI_E_NOT_ENOUGH_DATA: HRESULT = 0x80290101u32 as HRESULT; +pub const TPMAPI_E_TOO_MUCH_DATA: HRESULT = 0x80290102u32 as HRESULT; +pub const TPMAPI_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80290103u32 as HRESULT; +pub const TPMAPI_E_INVALID_PARAMETER: HRESULT = 0x80290104u32 as HRESULT; +pub const TPMAPI_E_OUT_OF_MEMORY: HRESULT = 0x80290105u32 as HRESULT; +pub const TPMAPI_E_BUFFER_TOO_SMALL: HRESULT = 0x80290106u32 as HRESULT; +pub const TPMAPI_E_INTERNAL_ERROR: HRESULT = 0x80290107u32 as HRESULT; +pub const TPMAPI_E_ACCESS_DENIED: HRESULT = 0x80290108u32 as HRESULT; +pub const TPMAPI_E_AUTHORIZATION_FAILED: HRESULT = 0x80290109u32 as HRESULT; +pub const TPMAPI_E_INVALID_CONTEXT_HANDLE: HRESULT = 0x8029010Au32 as HRESULT; +pub const TPMAPI_E_TBS_COMMUNICATION_ERROR: HRESULT = 0x8029010Bu32 as HRESULT; +pub const TPMAPI_E_TPM_COMMAND_ERROR: HRESULT = 0x8029010Cu32 as HRESULT; +pub const TPMAPI_E_MESSAGE_TOO_LARGE: HRESULT = 0x8029010Du32 as HRESULT; +pub const TPMAPI_E_INVALID_ENCODING: HRESULT = 0x8029010Eu32 as HRESULT; +pub const TPMAPI_E_INVALID_KEY_SIZE: HRESULT = 0x8029010Fu32 as HRESULT; +pub const TPMAPI_E_ENCRYPTION_FAILED: HRESULT = 0x80290110u32 as HRESULT; +pub const TPMAPI_E_INVALID_KEY_PARAMS: HRESULT = 0x80290111u32 as HRESULT; +pub const TPMAPI_E_INVALID_MIGRATION_AUTHORIZATION_BLOB: HRESULT = 0x80290112u32 as HRESULT; +pub const TPMAPI_E_INVALID_PCR_INDEX: HRESULT = 0x80290113u32 as HRESULT; +pub const TPMAPI_E_INVALID_DELEGATE_BLOB: HRESULT = 0x80290114u32 as HRESULT; +pub const TPMAPI_E_INVALID_CONTEXT_PARAMS: HRESULT = 0x80290115u32 as HRESULT; +pub const TPMAPI_E_INVALID_KEY_BLOB: HRESULT = 0x80290116u32 as HRESULT; +pub const TPMAPI_E_INVALID_PCR_DATA: HRESULT = 0x80290117u32 as HRESULT; +pub const TPMAPI_E_INVALID_OWNER_AUTH: HRESULT = 0x80290118u32 as HRESULT; +pub const TPMAPI_E_FIPS_RNG_CHECK_FAILED: HRESULT = 0x80290119u32 as HRESULT; +pub const TPMAPI_E_EMPTY_TCG_LOG: HRESULT = 0x8029011Au32 as HRESULT; +pub const TPMAPI_E_INVALID_TCG_LOG_ENTRY: HRESULT = 0x8029011Bu32 as HRESULT; +pub const TPMAPI_E_TCG_SEPARATOR_ABSENT: HRESULT = 0x8029011Cu32 as HRESULT; +pub const TPMAPI_E_TCG_INVALID_DIGEST_ENTRY: HRESULT = 0x8029011Du32 as HRESULT; +pub const TPMAPI_E_POLICY_DENIES_OPERATION: HRESULT = 0x8029011Eu32 as HRESULT; +pub const TBSIMP_E_BUFFER_TOO_SMALL: HRESULT = 0x80290200u32 as HRESULT; +pub const TBSIMP_E_CLEANUP_FAILED: HRESULT = 0x80290201u32 as HRESULT; +pub const TBSIMP_E_INVALID_CONTEXT_HANDLE: HRESULT = 0x80290202u32 as HRESULT; +pub const TBSIMP_E_INVALID_CONTEXT_PARAM: HRESULT = 0x80290203u32 as HRESULT; +pub const TBSIMP_E_TPM_ERROR: HRESULT = 0x80290204u32 as HRESULT; +pub const TBSIMP_E_HASH_BAD_KEY: HRESULT = 0x80290205u32 as HRESULT; +pub const TBSIMP_E_DUPLICATE_VHANDLE: HRESULT = 0x80290206u32 as HRESULT; +pub const TBSIMP_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80290207u32 as HRESULT; +pub const TBSIMP_E_INVALID_PARAMETER: HRESULT = 0x80290208u32 as HRESULT; +pub const TBSIMP_E_RPC_INIT_FAILED: HRESULT = 0x80290209u32 as HRESULT; +pub const TBSIMP_E_SCHEDULER_NOT_RUNNING: HRESULT = 0x8029020Au32 as HRESULT; +pub const TBSIMP_E_COMMAND_CANCELED: HRESULT = 0x8029020Bu32 as HRESULT; +pub const TBSIMP_E_OUT_OF_MEMORY: HRESULT = 0x8029020Cu32 as HRESULT; +pub const TBSIMP_E_LIST_NO_MORE_ITEMS: HRESULT = 0x8029020Du32 as HRESULT; +pub const TBSIMP_E_LIST_NOT_FOUND: HRESULT = 0x8029020Eu32 as HRESULT; +pub const TBSIMP_E_NOT_ENOUGH_SPACE: HRESULT = 0x8029020Fu32 as HRESULT; +pub const TBSIMP_E_NOT_ENOUGH_TPM_CONTEXTS: HRESULT = 0x80290210u32 as HRESULT; +pub const TBSIMP_E_COMMAND_FAILED: HRESULT = 0x80290211u32 as HRESULT; +pub const TBSIMP_E_UNKNOWN_ORDINAL: HRESULT = 0x80290212u32 as HRESULT; +pub const TBSIMP_E_RESOURCE_EXPIRED: HRESULT = 0x80290213u32 as HRESULT; +pub const TBSIMP_E_INVALID_RESOURCE: HRESULT = 0x80290214u32 as HRESULT; +pub const TBSIMP_E_NOTHING_TO_UNLOAD: HRESULT = 0x80290215u32 as HRESULT; +pub const TBSIMP_E_HASH_TABLE_FULL: HRESULT = 0x80290216u32 as HRESULT; +pub const TBSIMP_E_TOO_MANY_TBS_CONTEXTS: HRESULT = 0x80290217u32 as HRESULT; +pub const TBSIMP_E_TOO_MANY_RESOURCES: HRESULT = 0x80290218u32 as HRESULT; +pub const TBSIMP_E_PPI_NOT_SUPPORTED: HRESULT = 0x80290219u32 as HRESULT; +pub const TBSIMP_E_TPM_INCOMPATIBLE: HRESULT = 0x8029021Au32 as HRESULT; +pub const TBSIMP_E_NO_EVENT_LOG: HRESULT = 0x8029021Bu32 as HRESULT; +pub const TPM_E_PPI_ACPI_FAILURE: HRESULT = 0x80290300u32 as HRESULT; +pub const TPM_E_PPI_USER_ABORT: HRESULT = 0x80290301u32 as HRESULT; +pub const TPM_E_PPI_BIOS_FAILURE: HRESULT = 0x80290302u32 as HRESULT; +pub const TPM_E_PPI_NOT_SUPPORTED: HRESULT = 0x80290303u32 as HRESULT; +pub const TPM_E_PPI_BLOCKED_IN_BIOS: HRESULT = 0x80290304u32 as HRESULT; +pub const TPM_E_PCP_ERROR_MASK: HRESULT = 0x80290400u32 as HRESULT; +pub const TPM_E_PCP_DEVICE_NOT_READY: HRESULT = 0x80290401u32 as HRESULT; +pub const TPM_E_PCP_INVALID_HANDLE: HRESULT = 0x80290402u32 as HRESULT; +pub const TPM_E_PCP_INVALID_PARAMETER: HRESULT = 0x80290403u32 as HRESULT; +pub const TPM_E_PCP_FLAG_NOT_SUPPORTED: HRESULT = 0x80290404u32 as HRESULT; +pub const TPM_E_PCP_NOT_SUPPORTED: HRESULT = 0x80290405u32 as HRESULT; +pub const TPM_E_PCP_BUFFER_TOO_SMALL: HRESULT = 0x80290406u32 as HRESULT; +pub const TPM_E_PCP_INTERNAL_ERROR: HRESULT = 0x80290407u32 as HRESULT; +pub const TPM_E_PCP_AUTHENTICATION_FAILED: HRESULT = 0x80290408u32 as HRESULT; +pub const TPM_E_PCP_AUTHENTICATION_IGNORED: HRESULT = 0x80290409u32 as HRESULT; +pub const TPM_E_PCP_POLICY_NOT_FOUND: HRESULT = 0x8029040Au32 as HRESULT; +pub const TPM_E_PCP_PROFILE_NOT_FOUND: HRESULT = 0x8029040Bu32 as HRESULT; +pub const TPM_E_PCP_VALIDATION_FAILED: HRESULT = 0x8029040Cu32 as HRESULT; +pub const PLA_E_DCS_NOT_FOUND: HRESULT = 0x80300002u32 as HRESULT; +pub const PLA_E_DCS_IN_USE: HRESULT = 0x803000AAu32 as HRESULT; +pub const PLA_E_TOO_MANY_FOLDERS: HRESULT = 0x80300045u32 as HRESULT; +pub const PLA_E_NO_MIN_DISK: HRESULT = 0x80300070u32 as HRESULT; +pub const PLA_E_DCS_ALREADY_EXISTS: HRESULT = 0x803000B7u32 as HRESULT; +pub const PLA_S_PROPERTY_IGNORED: HRESULT = 0x00300100; +pub const PLA_E_PROPERTY_CONFLICT: HRESULT = 0x80300101u32 as HRESULT; +pub const PLA_E_DCS_SINGLETON_REQUIRED: HRESULT = 0x80300102u32 as HRESULT; +pub const PLA_E_CREDENTIALS_REQUIRED: HRESULT = 0x80300103u32 as HRESULT; +pub const PLA_E_DCS_NOT_RUNNING: HRESULT = 0x80300104u32 as HRESULT; +pub const PLA_E_CONFLICT_INCL_EXCL_API: HRESULT = 0x80300105u32 as HRESULT; +pub const PLA_E_NETWORK_EXE_NOT_VALID: HRESULT = 0x80300106u32 as HRESULT; +pub const PLA_E_EXE_ALREADY_CONFIGURED: HRESULT = 0x80300107u32 as HRESULT; +pub const PLA_E_EXE_PATH_NOT_VALID: HRESULT = 0x80300108u32 as HRESULT; +pub const PLA_E_DC_ALREADY_EXISTS: HRESULT = 0x80300109u32 as HRESULT; +pub const PLA_E_DCS_START_WAIT_TIMEOUT: HRESULT = 0x8030010Au32 as HRESULT; +pub const PLA_E_DC_START_WAIT_TIMEOUT: HRESULT = 0x8030010Bu32 as HRESULT; +pub const PLA_E_REPORT_WAIT_TIMEOUT: HRESULT = 0x8030010Cu32 as HRESULT; +pub const PLA_E_NO_DUPLICATES: HRESULT = 0x8030010Du32 as HRESULT; +pub const PLA_E_EXE_FULL_PATH_REQUIRED: HRESULT = 0x8030010Eu32 as HRESULT; +pub const PLA_E_INVALID_SESSION_NAME: HRESULT = 0x8030010Fu32 as HRESULT; +pub const PLA_E_PLA_CHANNEL_NOT_ENABLED: HRESULT = 0x80300110u32 as HRESULT; +pub const PLA_E_TASKSCHED_CHANNEL_NOT_ENABLED: HRESULT = 0x80300111u32 as HRESULT; +pub const PLA_E_RULES_MANAGER_FAILED: HRESULT = 0x80300112u32 as HRESULT; +pub const PLA_E_CABAPI_FAILURE: HRESULT = 0x80300113u32 as HRESULT; +pub const FVE_E_LOCKED_VOLUME: HRESULT = 0x80310000u32 as HRESULT; +pub const FVE_E_NOT_ENCRYPTED: HRESULT = 0x80310001u32 as HRESULT; +pub const FVE_E_NO_TPM_BIOS: HRESULT = 0x80310002u32 as HRESULT; +pub const FVE_E_NO_MBR_METRIC: HRESULT = 0x80310003u32 as HRESULT; +pub const FVE_E_NO_BOOTSECTOR_METRIC: HRESULT = 0x80310004u32 as HRESULT; +pub const FVE_E_NO_BOOTMGR_METRIC: HRESULT = 0x80310005u32 as HRESULT; +pub const FVE_E_WRONG_BOOTMGR: HRESULT = 0x80310006u32 as HRESULT; +pub const FVE_E_SECURE_KEY_REQUIRED: HRESULT = 0x80310007u32 as HRESULT; +pub const FVE_E_NOT_ACTIVATED: HRESULT = 0x80310008u32 as HRESULT; +pub const FVE_E_ACTION_NOT_ALLOWED: HRESULT = 0x80310009u32 as HRESULT; +pub const FVE_E_AD_SCHEMA_NOT_INSTALLED: HRESULT = 0x8031000Au32 as HRESULT; +pub const FVE_E_AD_INVALID_DATATYPE: HRESULT = 0x8031000Bu32 as HRESULT; +pub const FVE_E_AD_INVALID_DATASIZE: HRESULT = 0x8031000Cu32 as HRESULT; +pub const FVE_E_AD_NO_VALUES: HRESULT = 0x8031000Du32 as HRESULT; +pub const FVE_E_AD_ATTR_NOT_SET: HRESULT = 0x8031000Eu32 as HRESULT; +pub const FVE_E_AD_GUID_NOT_FOUND: HRESULT = 0x8031000Fu32 as HRESULT; +pub const FVE_E_BAD_INFORMATION: HRESULT = 0x80310010u32 as HRESULT; +pub const FVE_E_TOO_SMALL: HRESULT = 0x80310011u32 as HRESULT; +pub const FVE_E_SYSTEM_VOLUME: HRESULT = 0x80310012u32 as HRESULT; +pub const FVE_E_FAILED_WRONG_FS: HRESULT = 0x80310013u32 as HRESULT; +pub const FVE_E_BAD_PARTITION_SIZE: HRESULT = 0x80310014u32 as HRESULT; +pub const FVE_E_NOT_SUPPORTED: HRESULT = 0x80310015u32 as HRESULT; +pub const FVE_E_BAD_DATA: HRESULT = 0x80310016u32 as HRESULT; +pub const FVE_E_VOLUME_NOT_BOUND: HRESULT = 0x80310017u32 as HRESULT; +pub const FVE_E_TPM_NOT_OWNED: HRESULT = 0x80310018u32 as HRESULT; +pub const FVE_E_NOT_DATA_VOLUME: HRESULT = 0x80310019u32 as HRESULT; +pub const FVE_E_AD_INSUFFICIENT_BUFFER: HRESULT = 0x8031001Au32 as HRESULT; +pub const FVE_E_CONV_READ: HRESULT = 0x8031001Bu32 as HRESULT; +pub const FVE_E_CONV_WRITE: HRESULT = 0x8031001Cu32 as HRESULT; +pub const FVE_E_KEY_REQUIRED: HRESULT = 0x8031001Du32 as HRESULT; +pub const FVE_E_CLUSTERING_NOT_SUPPORTED: HRESULT = 0x8031001Eu32 as HRESULT; +pub const FVE_E_VOLUME_BOUND_ALREADY: HRESULT = 0x8031001Fu32 as HRESULT; +pub const FVE_E_OS_NOT_PROTECTED: HRESULT = 0x80310020u32 as HRESULT; +pub const FVE_E_PROTECTION_DISABLED: HRESULT = 0x80310021u32 as HRESULT; +pub const FVE_E_RECOVERY_KEY_REQUIRED: HRESULT = 0x80310022u32 as HRESULT; +pub const FVE_E_FOREIGN_VOLUME: HRESULT = 0x80310023u32 as HRESULT; +pub const FVE_E_OVERLAPPED_UPDATE: HRESULT = 0x80310024u32 as HRESULT; +pub const FVE_E_TPM_SRK_AUTH_NOT_ZERO: HRESULT = 0x80310025u32 as HRESULT; +pub const FVE_E_FAILED_SECTOR_SIZE: HRESULT = 0x80310026u32 as HRESULT; +pub const FVE_E_FAILED_AUTHENTICATION: HRESULT = 0x80310027u32 as HRESULT; +pub const FVE_E_NOT_OS_VOLUME: HRESULT = 0x80310028u32 as HRESULT; +pub const FVE_E_AUTOUNLOCK_ENABLED: HRESULT = 0x80310029u32 as HRESULT; +pub const FVE_E_WRONG_BOOTSECTOR: HRESULT = 0x8031002Au32 as HRESULT; +pub const FVE_E_WRONG_SYSTEM_FS: HRESULT = 0x8031002Bu32 as HRESULT; +pub const FVE_E_POLICY_PASSWORD_REQUIRED: HRESULT = 0x8031002Cu32 as HRESULT; +pub const FVE_E_CANNOT_SET_FVEK_ENCRYPTED: HRESULT = 0x8031002Du32 as HRESULT; +pub const FVE_E_CANNOT_ENCRYPT_NO_KEY: HRESULT = 0x8031002Eu32 as HRESULT; +pub const FVE_E_BOOTABLE_CDDVD: HRESULT = 0x80310030u32 as HRESULT; +pub const FVE_E_PROTECTOR_EXISTS: HRESULT = 0x80310031u32 as HRESULT; +pub const FVE_E_RELATIVE_PATH: HRESULT = 0x80310032u32 as HRESULT; +pub const FVE_E_PROTECTOR_NOT_FOUND: HRESULT = 0x80310033u32 as HRESULT; +pub const FVE_E_INVALID_KEY_FORMAT: HRESULT = 0x80310034u32 as HRESULT; +pub const FVE_E_INVALID_PASSWORD_FORMAT: HRESULT = 0x80310035u32 as HRESULT; +pub const FVE_E_FIPS_RNG_CHECK_FAILED: HRESULT = 0x80310036u32 as HRESULT; +pub const FVE_E_FIPS_PREVENTS_RECOVERY_PASSWORD: HRESULT = 0x80310037u32 as HRESULT; +pub const FVE_E_FIPS_PREVENTS_EXTERNAL_KEY_EXPORT: HRESULT = 0x80310038u32 as HRESULT; +pub const FVE_E_NOT_DECRYPTED: HRESULT = 0x80310039u32 as HRESULT; +pub const FVE_E_INVALID_PROTECTOR_TYPE: HRESULT = 0x8031003Au32 as HRESULT; +pub const FVE_E_NO_PROTECTORS_TO_TEST: HRESULT = 0x8031003Bu32 as HRESULT; +pub const FVE_E_KEYFILE_NOT_FOUND: HRESULT = 0x8031003Cu32 as HRESULT; +pub const FVE_E_KEYFILE_INVALID: HRESULT = 0x8031003Du32 as HRESULT; +pub const FVE_E_KEYFILE_NO_VMK: HRESULT = 0x8031003Eu32 as HRESULT; +pub const FVE_E_TPM_DISABLED: HRESULT = 0x8031003Fu32 as HRESULT; +pub const FVE_E_NOT_ALLOWED_IN_SAFE_MODE: HRESULT = 0x80310040u32 as HRESULT; +pub const FVE_E_TPM_INVALID_PCR: HRESULT = 0x80310041u32 as HRESULT; +pub const FVE_E_TPM_NO_VMK: HRESULT = 0x80310042u32 as HRESULT; +pub const FVE_E_PIN_INVALID: HRESULT = 0x80310043u32 as HRESULT; +pub const FVE_E_AUTH_INVALID_APPLICATION: HRESULT = 0x80310044u32 as HRESULT; +pub const FVE_E_AUTH_INVALID_CONFIG: HRESULT = 0x80310045u32 as HRESULT; +pub const FVE_E_FIPS_DISABLE_PROTECTION_NOT_ALLOWED: HRESULT = 0x80310046u32 as HRESULT; +pub const FVE_E_FS_NOT_EXTENDED: HRESULT = 0x80310047u32 as HRESULT; +pub const FVE_E_FIRMWARE_TYPE_NOT_SUPPORTED: HRESULT = 0x80310048u32 as HRESULT; +pub const FVE_E_NO_LICENSE: HRESULT = 0x80310049u32 as HRESULT; +pub const FVE_E_NOT_ON_STACK: HRESULT = 0x8031004Au32 as HRESULT; +pub const FVE_E_FS_MOUNTED: HRESULT = 0x8031004Bu32 as HRESULT; +pub const FVE_E_TOKEN_NOT_IMPERSONATED: HRESULT = 0x8031004Cu32 as HRESULT; +pub const FVE_E_DRY_RUN_FAILED: HRESULT = 0x8031004Du32 as HRESULT; +pub const FVE_E_REBOOT_REQUIRED: HRESULT = 0x8031004Eu32 as HRESULT; +pub const FVE_E_DEBUGGER_ENABLED: HRESULT = 0x8031004Fu32 as HRESULT; +pub const FVE_E_RAW_ACCESS: HRESULT = 0x80310050u32 as HRESULT; +pub const FVE_E_RAW_BLOCKED: HRESULT = 0x80310051u32 as HRESULT; +pub const FVE_E_BCD_APPLICATIONS_PATH_INCORRECT: HRESULT = 0x80310052u32 as HRESULT; +pub const FVE_E_NOT_ALLOWED_IN_VERSION: HRESULT = 0x80310053u32 as HRESULT; +pub const FVE_E_NO_AUTOUNLOCK_MASTER_KEY: HRESULT = 0x80310054u32 as HRESULT; +pub const FVE_E_MOR_FAILED: HRESULT = 0x80310055u32 as HRESULT; +pub const FVE_E_HIDDEN_VOLUME: HRESULT = 0x80310056u32 as HRESULT; +pub const FVE_E_TRANSIENT_STATE: HRESULT = 0x80310057u32 as HRESULT; +pub const FVE_E_PUBKEY_NOT_ALLOWED: HRESULT = 0x80310058u32 as HRESULT; +pub const FVE_E_VOLUME_HANDLE_OPEN: HRESULT = 0x80310059u32 as HRESULT; +pub const FVE_E_NO_FEATURE_LICENSE: HRESULT = 0x8031005Au32 as HRESULT; +pub const FVE_E_INVALID_STARTUP_OPTIONS: HRESULT = 0x8031005Bu32 as HRESULT; +pub const FVE_E_POLICY_RECOVERY_PASSWORD_NOT_ALLOWED: HRESULT = 0x8031005Cu32 as HRESULT; +pub const FVE_E_POLICY_RECOVERY_PASSWORD_REQUIRED: HRESULT = 0x8031005Du32 as HRESULT; +pub const FVE_E_POLICY_RECOVERY_KEY_NOT_ALLOWED: HRESULT = 0x8031005Eu32 as HRESULT; +pub const FVE_E_POLICY_RECOVERY_KEY_REQUIRED: HRESULT = 0x8031005Fu32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_PIN_NOT_ALLOWED: HRESULT = 0x80310060u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_PIN_REQUIRED: HRESULT = 0x80310061u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_KEY_NOT_ALLOWED: HRESULT = 0x80310062u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_KEY_REQUIRED: HRESULT = 0x80310063u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_PIN_KEY_NOT_ALLOWED: HRESULT = 0x80310064u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_PIN_KEY_REQUIRED: HRESULT = 0x80310065u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_TPM_NOT_ALLOWED: HRESULT = 0x80310066u32 as HRESULT; +pub const FVE_E_POLICY_STARTUP_TPM_REQUIRED: HRESULT = 0x80310067u32 as HRESULT; +pub const FVE_E_POLICY_INVALID_PIN_LENGTH: HRESULT = 0x80310068u32 as HRESULT; +pub const FVE_E_KEY_PROTECTOR_NOT_SUPPORTED: HRESULT = 0x80310069u32 as HRESULT; +pub const FVE_E_POLICY_PASSPHRASE_NOT_ALLOWED: HRESULT = 0x8031006Au32 as HRESULT; +pub const FVE_E_POLICY_PASSPHRASE_REQUIRED: HRESULT = 0x8031006Bu32 as HRESULT; +pub const FVE_E_FIPS_PREVENTS_PASSPHRASE: HRESULT = 0x8031006Cu32 as HRESULT; +pub const FVE_E_OS_VOLUME_PASSPHRASE_NOT_ALLOWED: HRESULT = 0x8031006Du32 as HRESULT; +pub const FVE_E_INVALID_BITLOCKER_OID: HRESULT = 0x8031006Eu32 as HRESULT; +pub const FVE_E_VOLUME_TOO_SMALL: HRESULT = 0x8031006Fu32 as HRESULT; +pub const FVE_E_DV_NOT_SUPPORTED_ON_FS: HRESULT = 0x80310070u32 as HRESULT; +pub const FVE_E_DV_NOT_ALLOWED_BY_GP: HRESULT = 0x80310071u32 as HRESULT; +pub const FVE_E_POLICY_USER_CERTIFICATE_NOT_ALLOWED: HRESULT = 0x80310072u32 as HRESULT; +pub const FVE_E_POLICY_USER_CERTIFICATE_REQUIRED: HRESULT = 0x80310073u32 as HRESULT; +pub const FVE_E_POLICY_USER_CERT_MUST_BE_HW: HRESULT = 0x80310074u32 as HRESULT; +pub const FVE_E_POLICY_USER_CONFIGURE_FDV_AUTOUNLOCK_NOT_ALLOWED: HRESULT = 0x80310075u32 as HRESULT; +pub const FVE_E_POLICY_USER_CONFIGURE_RDV_AUTOUNLOCK_NOT_ALLOWED: HRESULT = 0x80310076u32 as HRESULT; +pub const FVE_E_POLICY_USER_CONFIGURE_RDV_NOT_ALLOWED: HRESULT = 0x80310077u32 as HRESULT; +pub const FVE_E_POLICY_USER_ENABLE_RDV_NOT_ALLOWED: HRESULT = 0x80310078u32 as HRESULT; +pub const FVE_E_POLICY_USER_DISABLE_RDV_NOT_ALLOWED: HRESULT = 0x80310079u32 as HRESULT; +pub const FVE_E_POLICY_INVALID_PASSPHRASE_LENGTH: HRESULT = 0x80310080u32 as HRESULT; +pub const FVE_E_POLICY_PASSPHRASE_TOO_SIMPLE: HRESULT = 0x80310081u32 as HRESULT; +pub const FVE_E_RECOVERY_PARTITION: HRESULT = 0x80310082u32 as HRESULT; +pub const FVE_E_POLICY_CONFLICT_FDV_RK_OFF_AUK_ON: HRESULT = 0x80310083u32 as HRESULT; +pub const FVE_E_POLICY_CONFLICT_RDV_RK_OFF_AUK_ON: HRESULT = 0x80310084u32 as HRESULT; +pub const FVE_E_NON_BITLOCKER_OID: HRESULT = 0x80310085u32 as HRESULT; +pub const FVE_E_POLICY_PROHIBITS_SELFSIGNED: HRESULT = 0x80310086u32 as HRESULT; +pub const FVE_E_POLICY_CONFLICT_RO_AND_STARTUP_KEY_REQUIRED: HRESULT = 0x80310087u32 as HRESULT; +pub const FVE_E_CONV_RECOVERY_FAILED: HRESULT = 0x80310088u32 as HRESULT; +pub const FVE_E_VIRTUALIZED_SPACE_TOO_BIG: HRESULT = 0x80310089u32 as HRESULT; +pub const FVE_E_POLICY_CONFLICT_OSV_RP_OFF_ADB_ON: HRESULT = 0x80310090u32 as HRESULT; +pub const FVE_E_POLICY_CONFLICT_FDV_RP_OFF_ADB_ON: HRESULT = 0x80310091u32 as HRESULT; +pub const FVE_E_POLICY_CONFLICT_RDV_RP_OFF_ADB_ON: HRESULT = 0x80310092u32 as HRESULT; +pub const FVE_E_NON_BITLOCKER_KU: HRESULT = 0x80310093u32 as HRESULT; +pub const FVE_E_PRIVATEKEY_AUTH_FAILED: HRESULT = 0x80310094u32 as HRESULT; +pub const FVE_E_REMOVAL_OF_DRA_FAILED: HRESULT = 0x80310095u32 as HRESULT; +pub const FVE_E_OPERATION_NOT_SUPPORTED_ON_VISTA_VOLUME: HRESULT = 0x80310096u32 as HRESULT; +pub const FVE_E_CANT_LOCK_AUTOUNLOCK_ENABLED_VOLUME: HRESULT = 0x80310097u32 as HRESULT; +pub const FVE_E_FIPS_HASH_KDF_NOT_ALLOWED: HRESULT = 0x80310098u32 as HRESULT; +pub const FVE_E_ENH_PIN_INVALID: HRESULT = 0x80310099u32 as HRESULT; +pub const FVE_E_INVALID_PIN_CHARS: HRESULT = 0x8031009Au32 as HRESULT; +pub const FVE_E_INVALID_DATUM_TYPE: HRESULT = 0x8031009Bu32 as HRESULT; +pub const FVE_E_EFI_ONLY: HRESULT = 0x8031009Cu32 as HRESULT; +pub const FVE_E_MULTIPLE_NKP_CERTS: HRESULT = 0x8031009Du32 as HRESULT; +pub const FVE_E_REMOVAL_OF_NKP_FAILED: HRESULT = 0x8031009Eu32 as HRESULT; +pub const FVE_E_INVALID_NKP_CERT: HRESULT = 0x8031009Fu32 as HRESULT; +pub const FVE_E_NO_EXISTING_PIN: HRESULT = 0x803100A0u32 as HRESULT; +pub const FVE_E_PROTECTOR_CHANGE_PIN_MISMATCH: HRESULT = 0x803100A1u32 as HRESULT; +pub const FVE_E_PIN_PROTECTOR_CHANGE_BY_STD_USER_DISALLOWED: HRESULT = 0x803100A2u32 as HRESULT; +pub const FVE_E_PROTECTOR_CHANGE_MAX_PIN_CHANGE_ATTEMPTS_REACHED: HRESULT = 0x803100A3u32 as HRESULT; +pub const FVE_E_POLICY_PASSPHRASE_REQUIRES_ASCII: HRESULT = 0x803100A4u32 as HRESULT; +pub const FVE_E_FULL_ENCRYPTION_NOT_ALLOWED_ON_TP_STORAGE: HRESULT = 0x803100A5u32 as HRESULT; +pub const FVE_E_WIPE_NOT_ALLOWED_ON_TP_STORAGE: HRESULT = 0x803100A6u32 as HRESULT; +pub const FVE_E_KEY_LENGTH_NOT_SUPPORTED_BY_EDRIVE: HRESULT = 0x803100A7u32 as HRESULT; +pub const FVE_E_NO_EXISTING_PASSPHRASE: HRESULT = 0x803100A8u32 as HRESULT; +pub const FVE_E_PROTECTOR_CHANGE_PASSPHRASE_MISMATCH: HRESULT = 0x803100A9u32 as HRESULT; +pub const FVE_E_PASSPHRASE_TOO_LONG: HRESULT = 0x803100AAu32 as HRESULT; +pub const FVE_E_NO_PASSPHRASE_WITH_TPM: HRESULT = 0x803100ABu32 as HRESULT; +pub const FVE_E_NO_TPM_WITH_PASSPHRASE: HRESULT = 0x803100ACu32 as HRESULT; +pub const FVE_E_NOT_ALLOWED_ON_CSV_STACK: HRESULT = 0x803100ADu32 as HRESULT; +pub const FVE_E_NOT_ALLOWED_ON_CLUSTER: HRESULT = 0x803100AEu32 as HRESULT; +pub const FVE_E_EDRIVE_NO_FAILOVER_TO_SW: HRESULT = 0x803100AFu32 as HRESULT; +pub const FVE_E_EDRIVE_BAND_IN_USE: HRESULT = 0x803100B0u32 as HRESULT; +pub const FVE_E_EDRIVE_DISALLOWED_BY_GP: HRESULT = 0x803100B1u32 as HRESULT; +pub const FVE_E_EDRIVE_INCOMPATIBLE_VOLUME: HRESULT = 0x803100B2u32 as HRESULT; +pub const FVE_E_NOT_ALLOWED_TO_UPGRADE_WHILE_CONVERTING: HRESULT = 0x803100B3u32 as HRESULT; +pub const FVE_E_EDRIVE_DV_NOT_SUPPORTED: HRESULT = 0x803100B4u32 as HRESULT; +pub const FVE_E_NO_PREBOOT_KEYBOARD_DETECTED: HRESULT = 0x803100B5u32 as HRESULT; +pub const FVE_E_NO_PREBOOT_KEYBOARD_OR_WINRE_DETECTED: HRESULT = 0x803100B6u32 as HRESULT; +pub const FVE_E_POLICY_REQUIRES_STARTUP_PIN_ON_TOUCH_DEVICE: HRESULT = 0x803100B7u32 as HRESULT; +pub const FVE_E_POLICY_REQUIRES_RECOVERY_PASSWORD_ON_TOUCH_DEVICE: HRESULT = 0x803100B8u32 as HRESULT; +pub const FVE_E_WIPE_CANCEL_NOT_APPLICABLE: HRESULT = 0x803100B9u32 as HRESULT; +pub const FVE_E_SECUREBOOT_DISABLED: HRESULT = 0x803100BAu32 as HRESULT; +pub const FVE_E_SECUREBOOT_CONFIGURATION_INVALID: HRESULT = 0x803100BBu32 as HRESULT; +pub const FVE_E_EDRIVE_DRY_RUN_FAILED: HRESULT = 0x803100BCu32 as HRESULT; +pub const FVE_E_SHADOW_COPY_PRESENT: HRESULT = 0x803100BDu32 as HRESULT; +pub const FVE_E_POLICY_INVALID_ENHANCED_BCD_SETTINGS: HRESULT = 0x803100BEu32 as HRESULT; +pub const FVE_E_EDRIVE_INCOMPATIBLE_FIRMWARE: HRESULT = 0x803100BFu32 as HRESULT; +pub const FVE_E_PROTECTOR_CHANGE_MAX_PASSPHRASE_CHANGE_ATTEMPTS_REACHED: HRESULT = 0x803100C0u32 as HRESULT; +pub const FVE_E_PASSPHRASE_PROTECTOR_CHANGE_BY_STD_USER_DISALLOWED: HRESULT = 0x803100C1u32 as HRESULT; +pub const FVE_E_LIVEID_ACCOUNT_SUSPENDED: HRESULT = 0x803100C2u32 as HRESULT; +pub const FVE_E_LIVEID_ACCOUNT_BLOCKED: HRESULT = 0x803100C3u32 as HRESULT; +pub const FVE_E_NOT_PROVISIONED_ON_ALL_VOLUMES: HRESULT = 0x803100C4u32 as HRESULT; +pub const FVE_E_DE_FIXED_DATA_NOT_SUPPORTED: HRESULT = 0x803100C5u32 as HRESULT; +pub const FVE_E_DE_HARDWARE_NOT_COMPLIANT: HRESULT = 0x803100C6u32 as HRESULT; +pub const FVE_E_DE_WINRE_NOT_CONFIGURED: HRESULT = 0x803100C7u32 as HRESULT; +pub const FVE_E_DE_PROTECTION_SUSPENDED: HRESULT = 0x803100C8u32 as HRESULT; +pub const FVE_E_DE_OS_VOLUME_NOT_PROTECTED: HRESULT = 0x803100C9u32 as HRESULT; +pub const FVE_E_DE_DEVICE_LOCKEDOUT: HRESULT = 0x803100CAu32 as HRESULT; +pub const FVE_E_DE_PROTECTION_NOT_YET_ENABLED: HRESULT = 0x803100CBu32 as HRESULT; +pub const FVE_E_INVALID_PIN_CHARS_DETAILED: HRESULT = 0x803100CCu32 as HRESULT; +pub const FVE_E_DEVICE_LOCKOUT_COUNTER_UNAVAILABLE: HRESULT = 0x803100CDu32 as HRESULT; +pub const FVE_E_DEVICELOCKOUT_COUNTER_MISMATCH: HRESULT = 0x803100CEu32 as HRESULT; +pub const FVE_E_BUFFER_TOO_LARGE: HRESULT = 0x803100CFu32 as HRESULT; +pub const FVE_E_NO_SUCH_CAPABILITY_ON_TARGET: HRESULT = 0x803100D0u32 as HRESULT; +pub const FVE_E_DE_PREVENTED_FOR_OS: HRESULT = 0x803100D1u32 as HRESULT; +pub const FVE_E_DE_VOLUME_OPTED_OUT: HRESULT = 0x803100D2u32 as HRESULT; +pub const FVE_E_DE_VOLUME_NOT_SUPPORTED: HRESULT = 0x803100D3u32 as HRESULT; +pub const FVE_E_EOW_NOT_SUPPORTED_IN_VERSION: HRESULT = 0x803100D4u32 as HRESULT; +pub const FVE_E_ADBACKUP_NOT_ENABLED: HRESULT = 0x803100D5u32 as HRESULT; +pub const FVE_E_VOLUME_EXTEND_PREVENTS_EOW_DECRYPT: HRESULT = 0x803100D6u32 as HRESULT; +pub const FVE_E_NOT_DE_VOLUME: HRESULT = 0x803100D7u32 as HRESULT; +pub const FVE_E_PROTECTION_CANNOT_BE_DISABLED: HRESULT = 0x803100D8u32 as HRESULT; +pub const FWP_E_CALLOUT_NOT_FOUND: HRESULT = 0x80320001u32 as HRESULT; +pub const FWP_E_CONDITION_NOT_FOUND: HRESULT = 0x80320002u32 as HRESULT; +pub const FWP_E_FILTER_NOT_FOUND: HRESULT = 0x80320003u32 as HRESULT; +pub const FWP_E_LAYER_NOT_FOUND: HRESULT = 0x80320004u32 as HRESULT; +pub const FWP_E_PROVIDER_NOT_FOUND: HRESULT = 0x80320005u32 as HRESULT; +pub const FWP_E_PROVIDER_CONTEXT_NOT_FOUND: HRESULT = 0x80320006u32 as HRESULT; +pub const FWP_E_SUBLAYER_NOT_FOUND: HRESULT = 0x80320007u32 as HRESULT; +pub const FWP_E_NOT_FOUND: HRESULT = 0x80320008u32 as HRESULT; +pub const FWP_E_ALREADY_EXISTS: HRESULT = 0x80320009u32 as HRESULT; +pub const FWP_E_IN_USE: HRESULT = 0x8032000Au32 as HRESULT; +pub const FWP_E_DYNAMIC_SESSION_IN_PROGRESS: HRESULT = 0x8032000Bu32 as HRESULT; +pub const FWP_E_WRONG_SESSION: HRESULT = 0x8032000Cu32 as HRESULT; +pub const FWP_E_NO_TXN_IN_PROGRESS: HRESULT = 0x8032000Du32 as HRESULT; +pub const FWP_E_TXN_IN_PROGRESS: HRESULT = 0x8032000Eu32 as HRESULT; +pub const FWP_E_TXN_ABORTED: HRESULT = 0x8032000Fu32 as HRESULT; +pub const FWP_E_SESSION_ABORTED: HRESULT = 0x80320010u32 as HRESULT; +pub const FWP_E_INCOMPATIBLE_TXN: HRESULT = 0x80320011u32 as HRESULT; +pub const FWP_E_TIMEOUT: HRESULT = 0x80320012u32 as HRESULT; +pub const FWP_E_NET_EVENTS_DISABLED: HRESULT = 0x80320013u32 as HRESULT; +pub const FWP_E_INCOMPATIBLE_LAYER: HRESULT = 0x80320014u32 as HRESULT; +pub const FWP_E_KM_CLIENTS_ONLY: HRESULT = 0x80320015u32 as HRESULT; +pub const FWP_E_LIFETIME_MISMATCH: HRESULT = 0x80320016u32 as HRESULT; +pub const FWP_E_BUILTIN_OBJECT: HRESULT = 0x80320017u32 as HRESULT; +pub const FWP_E_TOO_MANY_CALLOUTS: HRESULT = 0x80320018u32 as HRESULT; +pub const FWP_E_NOTIFICATION_DROPPED: HRESULT = 0x80320019u32 as HRESULT; +pub const FWP_E_TRAFFIC_MISMATCH: HRESULT = 0x8032001Au32 as HRESULT; +pub const FWP_E_INCOMPATIBLE_SA_STATE: HRESULT = 0x8032001Bu32 as HRESULT; +pub const FWP_E_NULL_POINTER: HRESULT = 0x8032001Cu32 as HRESULT; +pub const FWP_E_INVALID_ENUMERATOR: HRESULT = 0x8032001Du32 as HRESULT; +pub const FWP_E_INVALID_FLAGS: HRESULT = 0x8032001Eu32 as HRESULT; +pub const FWP_E_INVALID_NET_MASK: HRESULT = 0x8032001Fu32 as HRESULT; +pub const FWP_E_INVALID_RANGE: HRESULT = 0x80320020u32 as HRESULT; +pub const FWP_E_INVALID_INTERVAL: HRESULT = 0x80320021u32 as HRESULT; +pub const FWP_E_ZERO_LENGTH_ARRAY: HRESULT = 0x80320022u32 as HRESULT; +pub const FWP_E_NULL_DISPLAY_NAME: HRESULT = 0x80320023u32 as HRESULT; +pub const FWP_E_INVALID_ACTION_TYPE: HRESULT = 0x80320024u32 as HRESULT; +pub const FWP_E_INVALID_WEIGHT: HRESULT = 0x80320025u32 as HRESULT; +pub const FWP_E_MATCH_TYPE_MISMATCH: HRESULT = 0x80320026u32 as HRESULT; +pub const FWP_E_TYPE_MISMATCH: HRESULT = 0x80320027u32 as HRESULT; +pub const FWP_E_OUT_OF_BOUNDS: HRESULT = 0x80320028u32 as HRESULT; +pub const FWP_E_RESERVED: HRESULT = 0x80320029u32 as HRESULT; +pub const FWP_E_DUPLICATE_CONDITION: HRESULT = 0x8032002Au32 as HRESULT; +pub const FWP_E_DUPLICATE_KEYMOD: HRESULT = 0x8032002Bu32 as HRESULT; +pub const FWP_E_ACTION_INCOMPATIBLE_WITH_LAYER: HRESULT = 0x8032002Cu32 as HRESULT; +pub const FWP_E_ACTION_INCOMPATIBLE_WITH_SUBLAYER: HRESULT = 0x8032002Du32 as HRESULT; +pub const FWP_E_CONTEXT_INCOMPATIBLE_WITH_LAYER: HRESULT = 0x8032002Eu32 as HRESULT; +pub const FWP_E_CONTEXT_INCOMPATIBLE_WITH_CALLOUT: HRESULT = 0x8032002Fu32 as HRESULT; +pub const FWP_E_INCOMPATIBLE_AUTH_METHOD: HRESULT = 0x80320030u32 as HRESULT; +pub const FWP_E_INCOMPATIBLE_DH_GROUP: HRESULT = 0x80320031u32 as HRESULT; +pub const FWP_E_EM_NOT_SUPPORTED: HRESULT = 0x80320032u32 as HRESULT; +pub const FWP_E_NEVER_MATCH: HRESULT = 0x80320033u32 as HRESULT; +pub const FWP_E_PROVIDER_CONTEXT_MISMATCH: HRESULT = 0x80320034u32 as HRESULT; +pub const FWP_E_INVALID_PARAMETER: HRESULT = 0x80320035u32 as HRESULT; +pub const FWP_E_TOO_MANY_SUBLAYERS: HRESULT = 0x80320036u32 as HRESULT; +pub const FWP_E_CALLOUT_NOTIFICATION_FAILED: HRESULT = 0x80320037u32 as HRESULT; +pub const FWP_E_INVALID_AUTH_TRANSFORM: HRESULT = 0x80320038u32 as HRESULT; +pub const FWP_E_INVALID_CIPHER_TRANSFORM: HRESULT = 0x80320039u32 as HRESULT; +pub const FWP_E_INCOMPATIBLE_CIPHER_TRANSFORM: HRESULT = 0x8032003Au32 as HRESULT; +pub const FWP_E_INVALID_TRANSFORM_COMBINATION: HRESULT = 0x8032003Bu32 as HRESULT; +pub const FWP_E_DUPLICATE_AUTH_METHOD: HRESULT = 0x8032003Cu32 as HRESULT; +pub const FWP_E_INVALID_TUNNEL_ENDPOINT: HRESULT = 0x8032003Du32 as HRESULT; +pub const FWP_E_L2_DRIVER_NOT_READY: HRESULT = 0x8032003Eu32 as HRESULT; +pub const FWP_E_KEY_DICTATOR_ALREADY_REGISTERED: HRESULT = 0x8032003Fu32 as HRESULT; +pub const FWP_E_KEY_DICTATION_INVALID_KEYING_MATERIAL: HRESULT = 0x80320040u32 as HRESULT; +pub const FWP_E_CONNECTIONS_DISABLED: HRESULT = 0x80320041u32 as HRESULT; +pub const FWP_E_INVALID_DNS_NAME: HRESULT = 0x80320042u32 as HRESULT; +pub const FWP_E_STILL_ON: HRESULT = 0x80320043u32 as HRESULT; +pub const FWP_E_IKEEXT_NOT_RUNNING: HRESULT = 0x80320044u32 as HRESULT; +pub const FWP_E_DROP_NOICMP: HRESULT = 0x80320104u32 as HRESULT; +pub const WS_S_ASYNC: HRESULT = 0x003D0000; +pub const WS_S_END: HRESULT = 0x003D0001; +pub const WS_E_INVALID_FORMAT: HRESULT = 0x803D0000u32 as HRESULT; +pub const WS_E_OBJECT_FAULTED: HRESULT = 0x803D0001u32 as HRESULT; +pub const WS_E_NUMERIC_OVERFLOW: HRESULT = 0x803D0002u32 as HRESULT; +pub const WS_E_INVALID_OPERATION: HRESULT = 0x803D0003u32 as HRESULT; +pub const WS_E_OPERATION_ABORTED: HRESULT = 0x803D0004u32 as HRESULT; +pub const WS_E_ENDPOINT_ACCESS_DENIED: HRESULT = 0x803D0005u32 as HRESULT; +pub const WS_E_OPERATION_TIMED_OUT: HRESULT = 0x803D0006u32 as HRESULT; +pub const WS_E_OPERATION_ABANDONED: HRESULT = 0x803D0007u32 as HRESULT; +pub const WS_E_QUOTA_EXCEEDED: HRESULT = 0x803D0008u32 as HRESULT; +pub const WS_E_NO_TRANSLATION_AVAILABLE: HRESULT = 0x803D0009u32 as HRESULT; +pub const WS_E_SECURITY_VERIFICATION_FAILURE: HRESULT = 0x803D000Au32 as HRESULT; +pub const WS_E_ADDRESS_IN_USE: HRESULT = 0x803D000Bu32 as HRESULT; +pub const WS_E_ADDRESS_NOT_AVAILABLE: HRESULT = 0x803D000Cu32 as HRESULT; +pub const WS_E_ENDPOINT_NOT_FOUND: HRESULT = 0x803D000Du32 as HRESULT; +pub const WS_E_ENDPOINT_NOT_AVAILABLE: HRESULT = 0x803D000Eu32 as HRESULT; +pub const WS_E_ENDPOINT_FAILURE: HRESULT = 0x803D000Fu32 as HRESULT; +pub const WS_E_ENDPOINT_UNREACHABLE: HRESULT = 0x803D0010u32 as HRESULT; +pub const WS_E_ENDPOINT_ACTION_NOT_SUPPORTED: HRESULT = 0x803D0011u32 as HRESULT; +pub const WS_E_ENDPOINT_TOO_BUSY: HRESULT = 0x803D0012u32 as HRESULT; +pub const WS_E_ENDPOINT_FAULT_RECEIVED: HRESULT = 0x803D0013u32 as HRESULT; +pub const WS_E_ENDPOINT_DISCONNECTED: HRESULT = 0x803D0014u32 as HRESULT; +pub const WS_E_PROXY_FAILURE: HRESULT = 0x803D0015u32 as HRESULT; +pub const WS_E_PROXY_ACCESS_DENIED: HRESULT = 0x803D0016u32 as HRESULT; +pub const WS_E_NOT_SUPPORTED: HRESULT = 0x803D0017u32 as HRESULT; +pub const WS_E_PROXY_REQUIRES_BASIC_AUTH: HRESULT = 0x803D0018u32 as HRESULT; +pub const WS_E_PROXY_REQUIRES_DIGEST_AUTH: HRESULT = 0x803D0019u32 as HRESULT; +pub const WS_E_PROXY_REQUIRES_NTLM_AUTH: HRESULT = 0x803D001Au32 as HRESULT; +pub const WS_E_PROXY_REQUIRES_NEGOTIATE_AUTH: HRESULT = 0x803D001Bu32 as HRESULT; +pub const WS_E_SERVER_REQUIRES_BASIC_AUTH: HRESULT = 0x803D001Cu32 as HRESULT; +pub const WS_E_SERVER_REQUIRES_DIGEST_AUTH: HRESULT = 0x803D001Du32 as HRESULT; +pub const WS_E_SERVER_REQUIRES_NTLM_AUTH: HRESULT = 0x803D001Eu32 as HRESULT; +pub const WS_E_SERVER_REQUIRES_NEGOTIATE_AUTH: HRESULT = 0x803D001Fu32 as HRESULT; +pub const WS_E_INVALID_ENDPOINT_URL: HRESULT = 0x803D0020u32 as HRESULT; +pub const WS_E_OTHER: HRESULT = 0x803D0021u32 as HRESULT; +pub const WS_E_SECURITY_TOKEN_EXPIRED: HRESULT = 0x803D0022u32 as HRESULT; +pub const WS_E_SECURITY_SYSTEM_FAILURE: HRESULT = 0x803D0023u32 as HRESULT; +pub const ERROR_NDIS_INTERFACE_CLOSING: HRESULT = 0x80340002u32 as HRESULT; +pub const ERROR_NDIS_BAD_VERSION: HRESULT = 0x80340004u32 as HRESULT; +pub const ERROR_NDIS_BAD_CHARACTERISTICS: HRESULT = 0x80340005u32 as HRESULT; +pub const ERROR_NDIS_ADAPTER_NOT_FOUND: HRESULT = 0x80340006u32 as HRESULT; +pub const ERROR_NDIS_OPEN_FAILED: HRESULT = 0x80340007u32 as HRESULT; +pub const ERROR_NDIS_DEVICE_FAILED: HRESULT = 0x80340008u32 as HRESULT; +pub const ERROR_NDIS_MULTICAST_FULL: HRESULT = 0x80340009u32 as HRESULT; +pub const ERROR_NDIS_MULTICAST_EXISTS: HRESULT = 0x8034000Au32 as HRESULT; +pub const ERROR_NDIS_MULTICAST_NOT_FOUND: HRESULT = 0x8034000Bu32 as HRESULT; +pub const ERROR_NDIS_REQUEST_ABORTED: HRESULT = 0x8034000Cu32 as HRESULT; +pub const ERROR_NDIS_RESET_IN_PROGRESS: HRESULT = 0x8034000Du32 as HRESULT; +pub const ERROR_NDIS_NOT_SUPPORTED: HRESULT = 0x803400BBu32 as HRESULT; +pub const ERROR_NDIS_INVALID_PACKET: HRESULT = 0x8034000Fu32 as HRESULT; +pub const ERROR_NDIS_ADAPTER_NOT_READY: HRESULT = 0x80340011u32 as HRESULT; +pub const ERROR_NDIS_INVALID_LENGTH: HRESULT = 0x80340014u32 as HRESULT; +pub const ERROR_NDIS_INVALID_DATA: HRESULT = 0x80340015u32 as HRESULT; +pub const ERROR_NDIS_BUFFER_TOO_SHORT: HRESULT = 0x80340016u32 as HRESULT; +pub const ERROR_NDIS_INVALID_OID: HRESULT = 0x80340017u32 as HRESULT; +pub const ERROR_NDIS_ADAPTER_REMOVED: HRESULT = 0x80340018u32 as HRESULT; +pub const ERROR_NDIS_UNSUPPORTED_MEDIA: HRESULT = 0x80340019u32 as HRESULT; +pub const ERROR_NDIS_GROUP_ADDRESS_IN_USE: HRESULT = 0x8034001Au32 as HRESULT; +pub const ERROR_NDIS_FILE_NOT_FOUND: HRESULT = 0x8034001Bu32 as HRESULT; +pub const ERROR_NDIS_ERROR_READING_FILE: HRESULT = 0x8034001Cu32 as HRESULT; +pub const ERROR_NDIS_ALREADY_MAPPED: HRESULT = 0x8034001Du32 as HRESULT; +pub const ERROR_NDIS_RESOURCE_CONFLICT: HRESULT = 0x8034001Eu32 as HRESULT; +pub const ERROR_NDIS_MEDIA_DISCONNECTED: HRESULT = 0x8034001Fu32 as HRESULT; +pub const ERROR_NDIS_INVALID_ADDRESS: HRESULT = 0x80340022u32 as HRESULT; +pub const ERROR_NDIS_INVALID_DEVICE_REQUEST: HRESULT = 0x80340010u32 as HRESULT; +pub const ERROR_NDIS_PAUSED: HRESULT = 0x8034002Au32 as HRESULT; +pub const ERROR_NDIS_INTERFACE_NOT_FOUND: HRESULT = 0x8034002Bu32 as HRESULT; +pub const ERROR_NDIS_UNSUPPORTED_REVISION: HRESULT = 0x8034002Cu32 as HRESULT; +pub const ERROR_NDIS_INVALID_PORT: HRESULT = 0x8034002Du32 as HRESULT; +pub const ERROR_NDIS_INVALID_PORT_STATE: HRESULT = 0x8034002Eu32 as HRESULT; +pub const ERROR_NDIS_LOW_POWER_STATE: HRESULT = 0x8034002Fu32 as HRESULT; +pub const ERROR_NDIS_REINIT_REQUIRED: HRESULT = 0x80340030u32 as HRESULT; +pub const ERROR_NDIS_DOT11_AUTO_CONFIG_ENABLED: HRESULT = 0x80342000u32 as HRESULT; +pub const ERROR_NDIS_DOT11_MEDIA_IN_USE: HRESULT = 0x80342001u32 as HRESULT; +pub const ERROR_NDIS_DOT11_POWER_STATE_INVALID: HRESULT = 0x80342002u32 as HRESULT; +pub const ERROR_NDIS_PM_WOL_PATTERN_LIST_FULL: HRESULT = 0x80342003u32 as HRESULT; +pub const ERROR_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL: HRESULT = 0x80342004u32 as HRESULT; +pub const ERROR_NDIS_INDICATION_REQUIRED: HRESULT = 0x00340001; +pub const ERROR_NDIS_OFFLOAD_POLICY: HRESULT = 0xC034100Fu32 as HRESULT; +pub const ERROR_NDIS_OFFLOAD_CONNECTION_REJECTED: HRESULT = 0xC0341012u32 as HRESULT; +pub const ERROR_NDIS_OFFLOAD_PATH_REJECTED: HRESULT = 0xC0341013u32 as HRESULT; +pub const ERROR_HV_INVALID_HYPERCALL_CODE: HRESULT = 0xC0350002u32 as HRESULT; +pub const ERROR_HV_INVALID_HYPERCALL_INPUT: HRESULT = 0xC0350003u32 as HRESULT; +pub const ERROR_HV_INVALID_ALIGNMENT: HRESULT = 0xC0350004u32 as HRESULT; +pub const ERROR_HV_INVALID_PARAMETER: HRESULT = 0xC0350005u32 as HRESULT; +pub const ERROR_HV_ACCESS_DENIED: HRESULT = 0xC0350006u32 as HRESULT; +pub const ERROR_HV_INVALID_PARTITION_STATE: HRESULT = 0xC0350007u32 as HRESULT; +pub const ERROR_HV_OPERATION_DENIED: HRESULT = 0xC0350008u32 as HRESULT; +pub const ERROR_HV_UNKNOWN_PROPERTY: HRESULT = 0xC0350009u32 as HRESULT; +pub const ERROR_HV_PROPERTY_VALUE_OUT_OF_RANGE: HRESULT = 0xC035000Au32 as HRESULT; +pub const ERROR_HV_INSUFFICIENT_MEMORY: HRESULT = 0xC035000Bu32 as HRESULT; +pub const ERROR_HV_PARTITION_TOO_DEEP: HRESULT = 0xC035000Cu32 as HRESULT; +pub const ERROR_HV_INVALID_PARTITION_ID: HRESULT = 0xC035000Du32 as HRESULT; +pub const ERROR_HV_INVALID_VP_INDEX: HRESULT = 0xC035000Eu32 as HRESULT; +pub const ERROR_HV_INVALID_PORT_ID: HRESULT = 0xC0350011u32 as HRESULT; +pub const ERROR_HV_INVALID_CONNECTION_ID: HRESULT = 0xC0350012u32 as HRESULT; +pub const ERROR_HV_INSUFFICIENT_BUFFERS: HRESULT = 0xC0350013u32 as HRESULT; +pub const ERROR_HV_NOT_ACKNOWLEDGED: HRESULT = 0xC0350014u32 as HRESULT; +pub const ERROR_HV_ACKNOWLEDGED: HRESULT = 0xC0350016u32 as HRESULT; +pub const ERROR_HV_INVALID_SAVE_RESTORE_STATE: HRESULT = 0xC0350017u32 as HRESULT; +pub const ERROR_HV_INVALID_SYNIC_STATE: HRESULT = 0xC0350018u32 as HRESULT; +pub const ERROR_HV_OBJECT_IN_USE: HRESULT = 0xC0350019u32 as HRESULT; +pub const ERROR_HV_INVALID_PROXIMITY_DOMAIN_INFO: HRESULT = 0xC035001Au32 as HRESULT; +pub const ERROR_HV_NO_DATA: HRESULT = 0xC035001Bu32 as HRESULT; +pub const ERROR_HV_INACTIVE: HRESULT = 0xC035001Cu32 as HRESULT; +pub const ERROR_HV_NO_RESOURCES: HRESULT = 0xC035001Du32 as HRESULT; +pub const ERROR_HV_FEATURE_UNAVAILABLE: HRESULT = 0xC035001Eu32 as HRESULT; +pub const ERROR_HV_INSUFFICIENT_BUFFER: HRESULT = 0xC0350033u32 as HRESULT; +pub const ERROR_HV_INSUFFICIENT_DEVICE_DOMAINS: HRESULT = 0xC0350038u32 as HRESULT; +pub const ERROR_HV_INVALID_LP_INDEX: HRESULT = 0xC0350041u32 as HRESULT; +pub const ERROR_HV_NOT_PRESENT: HRESULT = 0xC0351000u32 as HRESULT; +pub const ERROR_VID_DUPLICATE_HANDLER: HRESULT = 0xC0370001u32 as HRESULT; +pub const ERROR_VID_TOO_MANY_HANDLERS: HRESULT = 0xC0370002u32 as HRESULT; +pub const ERROR_VID_QUEUE_FULL: HRESULT = 0xC0370003u32 as HRESULT; +pub const ERROR_VID_HANDLER_NOT_PRESENT: HRESULT = 0xC0370004u32 as HRESULT; +pub const ERROR_VID_INVALID_OBJECT_NAME: HRESULT = 0xC0370005u32 as HRESULT; +pub const ERROR_VID_PARTITION_NAME_TOO_LONG: HRESULT = 0xC0370006u32 as HRESULT; +pub const ERROR_VID_MESSAGE_QUEUE_NAME_TOO_LONG: HRESULT = 0xC0370007u32 as HRESULT; +pub const ERROR_VID_PARTITION_ALREADY_EXISTS: HRESULT = 0xC0370008u32 as HRESULT; +pub const ERROR_VID_PARTITION_DOES_NOT_EXIST: HRESULT = 0xC0370009u32 as HRESULT; +pub const ERROR_VID_PARTITION_NAME_NOT_FOUND: HRESULT = 0xC037000Au32 as HRESULT; +pub const ERROR_VID_MESSAGE_QUEUE_ALREADY_EXISTS: HRESULT = 0xC037000Bu32 as HRESULT; +pub const ERROR_VID_EXCEEDED_MBP_ENTRY_MAP_LIMIT: HRESULT = 0xC037000Cu32 as HRESULT; +pub const ERROR_VID_MB_STILL_REFERENCED: HRESULT = 0xC037000Du32 as HRESULT; +pub const ERROR_VID_CHILD_GPA_PAGE_SET_CORRUPTED: HRESULT = 0xC037000Eu32 as HRESULT; +pub const ERROR_VID_INVALID_NUMA_SETTINGS: HRESULT = 0xC037000Fu32 as HRESULT; +pub const ERROR_VID_INVALID_NUMA_NODE_INDEX: HRESULT = 0xC0370010u32 as HRESULT; +pub const ERROR_VID_NOTIFICATION_QUEUE_ALREADY_ASSOCIATED: HRESULT = 0xC0370011u32 as HRESULT; +pub const ERROR_VID_INVALID_MEMORY_BLOCK_HANDLE: HRESULT = 0xC0370012u32 as HRESULT; +pub const ERROR_VID_PAGE_RANGE_OVERFLOW: HRESULT = 0xC0370013u32 as HRESULT; +pub const ERROR_VID_INVALID_MESSAGE_QUEUE_HANDLE: HRESULT = 0xC0370014u32 as HRESULT; +pub const ERROR_VID_INVALID_GPA_RANGE_HANDLE: HRESULT = 0xC0370015u32 as HRESULT; +pub const ERROR_VID_NO_MEMORY_BLOCK_NOTIFICATION_QUEUE: HRESULT = 0xC0370016u32 as HRESULT; +pub const ERROR_VID_MEMORY_BLOCK_LOCK_COUNT_EXCEEDED: HRESULT = 0xC0370017u32 as HRESULT; +pub const ERROR_VID_INVALID_PPM_HANDLE: HRESULT = 0xC0370018u32 as HRESULT; +pub const ERROR_VID_MBPS_ARE_LOCKED: HRESULT = 0xC0370019u32 as HRESULT; +pub const ERROR_VID_MESSAGE_QUEUE_CLOSED: HRESULT = 0xC037001Au32 as HRESULT; +pub const ERROR_VID_VIRTUAL_PROCESSOR_LIMIT_EXCEEDED: HRESULT = 0xC037001Bu32 as HRESULT; +pub const ERROR_VID_STOP_PENDING: HRESULT = 0xC037001Cu32 as HRESULT; +pub const ERROR_VID_INVALID_PROCESSOR_STATE: HRESULT = 0xC037001Du32 as HRESULT; +pub const ERROR_VID_EXCEEDED_KM_CONTEXT_COUNT_LIMIT: HRESULT = 0xC037001Eu32 as HRESULT; +pub const ERROR_VID_KM_INTERFACE_ALREADY_INITIALIZED: HRESULT = 0xC037001Fu32 as HRESULT; +pub const ERROR_VID_MB_PROPERTY_ALREADY_SET_RESET: HRESULT = 0xC0370020u32 as HRESULT; +pub const ERROR_VID_MMIO_RANGE_DESTROYED: HRESULT = 0xC0370021u32 as HRESULT; +pub const ERROR_VID_INVALID_CHILD_GPA_PAGE_SET: HRESULT = 0xC0370022u32 as HRESULT; +pub const ERROR_VID_RESERVE_PAGE_SET_IS_BEING_USED: HRESULT = 0xC0370023u32 as HRESULT; +pub const ERROR_VID_RESERVE_PAGE_SET_TOO_SMALL: HRESULT = 0xC0370024u32 as HRESULT; +pub const ERROR_VID_MBP_ALREADY_LOCKED_USING_RESERVED_PAGE: HRESULT = 0xC0370025u32 as HRESULT; +pub const ERROR_VID_MBP_COUNT_EXCEEDED_LIMIT: HRESULT = 0xC0370026u32 as HRESULT; +pub const ERROR_VID_SAVED_STATE_CORRUPT: HRESULT = 0xC0370027u32 as HRESULT; +pub const ERROR_VID_SAVED_STATE_UNRECOGNIZED_ITEM: HRESULT = 0xC0370028u32 as HRESULT; +pub const ERROR_VID_SAVED_STATE_INCOMPATIBLE: HRESULT = 0xC0370029u32 as HRESULT; +pub const ERROR_VID_REMOTE_NODE_PARENT_GPA_PAGES_USED: HRESULT = 0x80370001u32 as HRESULT; +pub const ERROR_VOLMGR_INCOMPLETE_REGENERATION: HRESULT = 0x80380001u32 as HRESULT; +pub const ERROR_VOLMGR_INCOMPLETE_DISK_MIGRATION: HRESULT = 0x80380002u32 as HRESULT; +pub const ERROR_VOLMGR_DATABASE_FULL: HRESULT = 0xC0380001u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_CONFIGURATION_CORRUPTED: HRESULT = 0xC0380002u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_CONFIGURATION_NOT_IN_SYNC: HRESULT = 0xC0380003u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_CONFIG_UPDATE_FAILED: HRESULT = 0xC0380004u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_CONTAINS_NON_SIMPLE_VOLUME: HRESULT = 0xC0380005u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_DUPLICATE: HRESULT = 0xC0380006u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_DYNAMIC: HRESULT = 0xC0380007u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_ID_INVALID: HRESULT = 0xC0380008u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_INVALID: HRESULT = 0xC0380009u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAST_VOTER: HRESULT = 0xC038000Au32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAYOUT_INVALID: HRESULT = 0xC038000Bu32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAYOUT_NON_BASIC_BETWEEN_BASIC_PARTITIONS: HRESULT = 0xC038000Cu32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAYOUT_NOT_CYLINDER_ALIGNED: HRESULT = 0xC038000Du32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAYOUT_PARTITIONS_TOO_SMALL: HRESULT = 0xC038000Eu32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAYOUT_PRIMARY_BETWEEN_LOGICAL_PARTITIONS: HRESULT = 0xC038000Fu32 as HRESULT; +pub const ERROR_VOLMGR_DISK_LAYOUT_TOO_MANY_PARTITIONS: HRESULT = 0xC0380010u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_MISSING: HRESULT = 0xC0380011u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_NOT_EMPTY: HRESULT = 0xC0380012u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_NOT_ENOUGH_SPACE: HRESULT = 0xC0380013u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_REVECTORING_FAILED: HRESULT = 0xC0380014u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_SECTOR_SIZE_INVALID: HRESULT = 0xC0380015u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_SET_NOT_CONTAINED: HRESULT = 0xC0380016u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_USED_BY_MULTIPLE_MEMBERS: HRESULT = 0xC0380017u32 as HRESULT; +pub const ERROR_VOLMGR_DISK_USED_BY_MULTIPLE_PLEXES: HRESULT = 0xC0380018u32 as HRESULT; +pub const ERROR_VOLMGR_DYNAMIC_DISK_NOT_SUPPORTED: HRESULT = 0xC0380019u32 as HRESULT; +pub const ERROR_VOLMGR_EXTENT_ALREADY_USED: HRESULT = 0xC038001Au32 as HRESULT; +pub const ERROR_VOLMGR_EXTENT_NOT_CONTIGUOUS: HRESULT = 0xC038001Bu32 as HRESULT; +pub const ERROR_VOLMGR_EXTENT_NOT_IN_PUBLIC_REGION: HRESULT = 0xC038001Cu32 as HRESULT; +pub const ERROR_VOLMGR_EXTENT_NOT_SECTOR_ALIGNED: HRESULT = 0xC038001Du32 as HRESULT; +pub const ERROR_VOLMGR_EXTENT_OVERLAPS_EBR_PARTITION: HRESULT = 0xC038001Eu32 as HRESULT; +pub const ERROR_VOLMGR_EXTENT_VOLUME_LENGTHS_DO_NOT_MATCH: HRESULT = 0xC038001Fu32 as HRESULT; +pub const ERROR_VOLMGR_FAULT_TOLERANT_NOT_SUPPORTED: HRESULT = 0xC0380020u32 as HRESULT; +pub const ERROR_VOLMGR_INTERLEAVE_LENGTH_INVALID: HRESULT = 0xC0380021u32 as HRESULT; +pub const ERROR_VOLMGR_MAXIMUM_REGISTERED_USERS: HRESULT = 0xC0380022u32 as HRESULT; +pub const ERROR_VOLMGR_MEMBER_IN_SYNC: HRESULT = 0xC0380023u32 as HRESULT; +pub const ERROR_VOLMGR_MEMBER_INDEX_DUPLICATE: HRESULT = 0xC0380024u32 as HRESULT; +pub const ERROR_VOLMGR_MEMBER_INDEX_INVALID: HRESULT = 0xC0380025u32 as HRESULT; +pub const ERROR_VOLMGR_MEMBER_MISSING: HRESULT = 0xC0380026u32 as HRESULT; +pub const ERROR_VOLMGR_MEMBER_NOT_DETACHED: HRESULT = 0xC0380027u32 as HRESULT; +pub const ERROR_VOLMGR_MEMBER_REGENERATING: HRESULT = 0xC0380028u32 as HRESULT; +pub const ERROR_VOLMGR_ALL_DISKS_FAILED: HRESULT = 0xC0380029u32 as HRESULT; +pub const ERROR_VOLMGR_NO_REGISTERED_USERS: HRESULT = 0xC038002Au32 as HRESULT; +pub const ERROR_VOLMGR_NO_SUCH_USER: HRESULT = 0xC038002Bu32 as HRESULT; +pub const ERROR_VOLMGR_NOTIFICATION_RESET: HRESULT = 0xC038002Cu32 as HRESULT; +pub const ERROR_VOLMGR_NUMBER_OF_MEMBERS_INVALID: HRESULT = 0xC038002Du32 as HRESULT; +pub const ERROR_VOLMGR_NUMBER_OF_PLEXES_INVALID: HRESULT = 0xC038002Eu32 as HRESULT; +pub const ERROR_VOLMGR_PACK_DUPLICATE: HRESULT = 0xC038002Fu32 as HRESULT; +pub const ERROR_VOLMGR_PACK_ID_INVALID: HRESULT = 0xC0380030u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_INVALID: HRESULT = 0xC0380031u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_NAME_INVALID: HRESULT = 0xC0380032u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_OFFLINE: HRESULT = 0xC0380033u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_HAS_QUORUM: HRESULT = 0xC0380034u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_WITHOUT_QUORUM: HRESULT = 0xC0380035u32 as HRESULT; +pub const ERROR_VOLMGR_PARTITION_STYLE_INVALID: HRESULT = 0xC0380036u32 as HRESULT; +pub const ERROR_VOLMGR_PARTITION_UPDATE_FAILED: HRESULT = 0xC0380037u32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_IN_SYNC: HRESULT = 0xC0380038u32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_INDEX_DUPLICATE: HRESULT = 0xC0380039u32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_INDEX_INVALID: HRESULT = 0xC038003Au32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_LAST_ACTIVE: HRESULT = 0xC038003Bu32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_MISSING: HRESULT = 0xC038003Cu32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_REGENERATING: HRESULT = 0xC038003Du32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_TYPE_INVALID: HRESULT = 0xC038003Eu32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_NOT_RAID5: HRESULT = 0xC038003Fu32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_NOT_SIMPLE: HRESULT = 0xC0380040u32 as HRESULT; +pub const ERROR_VOLMGR_STRUCTURE_SIZE_INVALID: HRESULT = 0xC0380041u32 as HRESULT; +pub const ERROR_VOLMGR_TOO_MANY_NOTIFICATION_REQUESTS: HRESULT = 0xC0380042u32 as HRESULT; +pub const ERROR_VOLMGR_TRANSACTION_IN_PROGRESS: HRESULT = 0xC0380043u32 as HRESULT; +pub const ERROR_VOLMGR_UNEXPECTED_DISK_LAYOUT_CHANGE: HRESULT = 0xC0380044u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_CONTAINS_MISSING_DISK: HRESULT = 0xC0380045u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_ID_INVALID: HRESULT = 0xC0380046u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_LENGTH_INVALID: HRESULT = 0xC0380047u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE: HRESULT = 0xC0380048u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_NOT_MIRRORED: HRESULT = 0xC0380049u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_NOT_RETAINED: HRESULT = 0xC038004Au32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_OFFLINE: HRESULT = 0xC038004Bu32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_RETAINED: HRESULT = 0xC038004Cu32 as HRESULT; +pub const ERROR_VOLMGR_NUMBER_OF_EXTENTS_INVALID: HRESULT = 0xC038004Du32 as HRESULT; +pub const ERROR_VOLMGR_DIFFERENT_SECTOR_SIZE: HRESULT = 0xC038004Eu32 as HRESULT; +pub const ERROR_VOLMGR_BAD_BOOT_DISK: HRESULT = 0xC038004Fu32 as HRESULT; +pub const ERROR_VOLMGR_PACK_CONFIG_OFFLINE: HRESULT = 0xC0380050u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_CONFIG_ONLINE: HRESULT = 0xC0380051u32 as HRESULT; +pub const ERROR_VOLMGR_NOT_PRIMARY_PACK: HRESULT = 0xC0380052u32 as HRESULT; +pub const ERROR_VOLMGR_PACK_LOG_UPDATE_FAILED: HRESULT = 0xC0380053u32 as HRESULT; +pub const ERROR_VOLMGR_NUMBER_OF_DISKS_IN_PLEX_INVALID: HRESULT = 0xC0380054u32 as HRESULT; +pub const ERROR_VOLMGR_NUMBER_OF_DISKS_IN_MEMBER_INVALID: HRESULT = 0xC0380055u32 as HRESULT; +pub const ERROR_VOLMGR_VOLUME_MIRRORED: HRESULT = 0xC0380056u32 as HRESULT; +pub const ERROR_VOLMGR_PLEX_NOT_SIMPLE_SPANNED: HRESULT = 0xC0380057u32 as HRESULT; +pub const ERROR_VOLMGR_NO_VALID_LOG_COPIES: HRESULT = 0xC0380058u32 as HRESULT; +pub const ERROR_VOLMGR_PRIMARY_PACK_PRESENT: HRESULT = 0xC0380059u32 as HRESULT; +pub const ERROR_VOLMGR_NUMBER_OF_DISKS_INVALID: HRESULT = 0xC038005Au32 as HRESULT; +pub const ERROR_VOLMGR_MIRROR_NOT_SUPPORTED: HRESULT = 0xC038005Bu32 as HRESULT; +pub const ERROR_VOLMGR_RAID5_NOT_SUPPORTED: HRESULT = 0xC038005Cu32 as HRESULT; +pub const ERROR_BCD_NOT_ALL_ENTRIES_IMPORTED: HRESULT = 0x80390001u32 as HRESULT; +pub const ERROR_BCD_TOO_MANY_ELEMENTS: HRESULT = 0xC0390002u32 as HRESULT; +pub const ERROR_BCD_NOT_ALL_ENTRIES_SYNCHRONIZED: HRESULT = 0x80390003u32 as HRESULT; +pub const ERROR_VHD_DRIVE_FOOTER_MISSING: HRESULT = 0xC03A0001u32 as HRESULT; +pub const ERROR_VHD_DRIVE_FOOTER_CHECKSUM_MISMATCH: HRESULT = 0xC03A0002u32 as HRESULT; +pub const ERROR_VHD_DRIVE_FOOTER_CORRUPT: HRESULT = 0xC03A0003u32 as HRESULT; +pub const ERROR_VHD_FORMAT_UNKNOWN: HRESULT = 0xC03A0004u32 as HRESULT; +pub const ERROR_VHD_FORMAT_UNSUPPORTED_VERSION: HRESULT = 0xC03A0005u32 as HRESULT; +pub const ERROR_VHD_SPARSE_HEADER_CHECKSUM_MISMATCH: HRESULT = 0xC03A0006u32 as HRESULT; +pub const ERROR_VHD_SPARSE_HEADER_UNSUPPORTED_VERSION: HRESULT = 0xC03A0007u32 as HRESULT; +pub const ERROR_VHD_SPARSE_HEADER_CORRUPT: HRESULT = 0xC03A0008u32 as HRESULT; +pub const ERROR_VHD_BLOCK_ALLOCATION_FAILURE: HRESULT = 0xC03A0009u32 as HRESULT; +pub const ERROR_VHD_BLOCK_ALLOCATION_TABLE_CORRUPT: HRESULT = 0xC03A000Au32 as HRESULT; +pub const ERROR_VHD_INVALID_BLOCK_SIZE: HRESULT = 0xC03A000Bu32 as HRESULT; +pub const ERROR_VHD_BITMAP_MISMATCH: HRESULT = 0xC03A000Cu32 as HRESULT; +pub const ERROR_VHD_PARENT_VHD_NOT_FOUND: HRESULT = 0xC03A000Du32 as HRESULT; +pub const ERROR_VHD_CHILD_PARENT_ID_MISMATCH: HRESULT = 0xC03A000Eu32 as HRESULT; +pub const ERROR_VHD_CHILD_PARENT_TIMESTAMP_MISMATCH: HRESULT = 0xC03A000Fu32 as HRESULT; +pub const ERROR_VHD_METADATA_READ_FAILURE: HRESULT = 0xC03A0010u32 as HRESULT; +pub const ERROR_VHD_METADATA_WRITE_FAILURE: HRESULT = 0xC03A0011u32 as HRESULT; +pub const ERROR_VHD_INVALID_SIZE: HRESULT = 0xC03A0012u32 as HRESULT; +pub const ERROR_VHD_INVALID_FILE_SIZE: HRESULT = 0xC03A0013u32 as HRESULT; +pub const ERROR_VIRTDISK_PROVIDER_NOT_FOUND: HRESULT = 0xC03A0014u32 as HRESULT; +pub const ERROR_VIRTDISK_NOT_VIRTUAL_DISK: HRESULT = 0xC03A0015u32 as HRESULT; +pub const ERROR_VHD_PARENT_VHD_ACCESS_DENIED: HRESULT = 0xC03A0016u32 as HRESULT; +pub const ERROR_VHD_CHILD_PARENT_SIZE_MISMATCH: HRESULT = 0xC03A0017u32 as HRESULT; +pub const ERROR_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED: HRESULT = 0xC03A0018u32 as HRESULT; +pub const ERROR_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT: HRESULT = 0xC03A0019u32 as HRESULT; +pub const ERROR_VIRTUAL_DISK_LIMITATION: HRESULT = 0xC03A001Au32 as HRESULT; +pub const ERROR_VHD_INVALID_TYPE: HRESULT = 0xC03A001Bu32 as HRESULT; +pub const ERROR_VHD_INVALID_STATE: HRESULT = 0xC03A001Cu32 as HRESULT; +pub const ERROR_VIRTDISK_UNSUPPORTED_DISK_SECTOR_SIZE: HRESULT = 0xC03A001Du32 as HRESULT; +pub const ERROR_VIRTDISK_DISK_ALREADY_OWNED: HRESULT = 0xC03A001Eu32 as HRESULT; +pub const ERROR_VIRTDISK_DISK_ONLINE_AND_WRITABLE: HRESULT = 0xC03A001Fu32 as HRESULT; +pub const ERROR_CTLOG_TRACKING_NOT_INITIALIZED: HRESULT = 0xC03A0020u32 as HRESULT; +pub const ERROR_CTLOG_LOGFILE_SIZE_EXCEEDED_MAXSIZE: HRESULT = 0xC03A0021u32 as HRESULT; +pub const ERROR_CTLOG_VHD_CHANGED_OFFLINE: HRESULT = 0xC03A0022u32 as HRESULT; +pub const ERROR_CTLOG_INVALID_TRACKING_STATE: HRESULT = 0xC03A0023u32 as HRESULT; +pub const ERROR_CTLOG_INCONSISTENT_TRACKING_FILE: HRESULT = 0xC03A0024u32 as HRESULT; +pub const ERROR_VHD_RESIZE_WOULD_TRUNCATE_DATA: HRESULT = 0xC03A0025u32 as HRESULT; +pub const ERROR_VHD_COULD_NOT_COMPUTE_MINIMUM_VIRTUAL_SIZE: HRESULT = 0xC03A0026u32 as HRESULT; +pub const ERROR_VHD_ALREADY_AT_OR_BELOW_MINIMUM_VIRTUAL_SIZE: HRESULT = 0xC03A0027u32 as HRESULT; +pub const ERROR_VHD_METADATA_FULL: HRESULT = 0xC03A0028u32 as HRESULT; +pub const ERROR_QUERY_STORAGE_ERROR: HRESULT = 0x803A0001u32 as HRESULT; +pub const SDIAG_E_CANCELLED: HRESULT = 0x803C0100u32 as HRESULT; +pub const SDIAG_E_SCRIPT: HRESULT = 0x803C0101u32 as HRESULT; +pub const SDIAG_E_POWERSHELL: HRESULT = 0x803C0102u32 as HRESULT; +pub const SDIAG_E_MANAGEDHOST: HRESULT = 0x803C0103u32 as HRESULT; +pub const SDIAG_E_NOVERIFIER: HRESULT = 0x803C0104u32 as HRESULT; +pub const SDIAG_S_CANNOTRUN: HRESULT = 0x003C0105; +pub const SDIAG_E_DISABLED: HRESULT = 0x803C0106u32 as HRESULT; +pub const SDIAG_E_TRUST: HRESULT = 0x803C0107u32 as HRESULT; +pub const SDIAG_E_CANNOTRUN: HRESULT = 0x803C0108u32 as HRESULT; +pub const SDIAG_E_VERSION: HRESULT = 0x803C0109u32 as HRESULT; +pub const SDIAG_E_RESOURCE: HRESULT = 0x803C010Au32 as HRESULT; +pub const SDIAG_E_ROOTCAUSE: HRESULT = 0x803C010Bu32 as HRESULT; +pub const WPN_E_CHANNEL_CLOSED: HRESULT = 0x803E0100u32 as HRESULT; +pub const WPN_E_CHANNEL_REQUEST_NOT_COMPLETE: HRESULT = 0x803E0101u32 as HRESULT; +pub const WPN_E_INVALID_APP: HRESULT = 0x803E0102u32 as HRESULT; +pub const WPN_E_OUTSTANDING_CHANNEL_REQUEST: HRESULT = 0x803E0103u32 as HRESULT; +pub const WPN_E_DUPLICATE_CHANNEL: HRESULT = 0x803E0104u32 as HRESULT; +pub const WPN_E_PLATFORM_UNAVAILABLE: HRESULT = 0x803E0105u32 as HRESULT; +pub const WPN_E_NOTIFICATION_POSTED: HRESULT = 0x803E0106u32 as HRESULT; +pub const WPN_E_NOTIFICATION_HIDDEN: HRESULT = 0x803E0107u32 as HRESULT; +pub const WPN_E_NOTIFICATION_NOT_POSTED: HRESULT = 0x803E0108u32 as HRESULT; +pub const WPN_E_CLOUD_DISABLED: HRESULT = 0x803E0109u32 as HRESULT; +pub const WPN_E_CLOUD_INCAPABLE: HRESULT = 0x803E0110u32 as HRESULT; +pub const WPN_E_CLOUD_AUTH_UNAVAILABLE: HRESULT = 0x803E011Au32 as HRESULT; +pub const WPN_E_CLOUD_SERVICE_UNAVAILABLE: HRESULT = 0x803E011Bu32 as HRESULT; +pub const WPN_E_FAILED_LOCK_SCREEN_UPDATE_INTIALIZATION: HRESULT = 0x803E011Cu32 as HRESULT; +pub const WPN_E_NOTIFICATION_DISABLED: HRESULT = 0x803E0111u32 as HRESULT; +pub const WPN_E_NOTIFICATION_INCAPABLE: HRESULT = 0x803E0112u32 as HRESULT; +pub const WPN_E_INTERNET_INCAPABLE: HRESULT = 0x803E0113u32 as HRESULT; +pub const WPN_E_NOTIFICATION_TYPE_DISABLED: HRESULT = 0x803E0114u32 as HRESULT; +pub const WPN_E_NOTIFICATION_SIZE: HRESULT = 0x803E0115u32 as HRESULT; +pub const WPN_E_TAG_SIZE: HRESULT = 0x803E0116u32 as HRESULT; +pub const WPN_E_ACCESS_DENIED: HRESULT = 0x803E0117u32 as HRESULT; +pub const WPN_E_DUPLICATE_REGISTRATION: HRESULT = 0x803E0118u32 as HRESULT; +pub const WPN_E_PUSH_NOTIFICATION_INCAPABLE: HRESULT = 0x803E0119u32 as HRESULT; +pub const WPN_E_DEV_ID_SIZE: HRESULT = 0x803E0120u32 as HRESULT; +pub const WPN_E_TAG_ALPHANUMERIC: HRESULT = 0x803E012Au32 as HRESULT; +pub const WPN_E_INVALID_HTTP_STATUS_CODE: HRESULT = 0x803E012Bu32 as HRESULT; +pub const WPN_E_OUT_OF_SESSION: HRESULT = 0x803E0200u32 as HRESULT; +pub const WPN_E_POWER_SAVE: HRESULT = 0x803E0201u32 as HRESULT; +pub const WPN_E_IMAGE_NOT_FOUND_IN_CACHE: HRESULT = 0x803E0202u32 as HRESULT; +pub const WPN_E_ALL_URL_NOT_COMPLETED: HRESULT = 0x803E0203u32 as HRESULT; +pub const WPN_E_INVALID_CLOUD_IMAGE: HRESULT = 0x803E0204u32 as HRESULT; +pub const WPN_E_NOTIFICATION_ID_MATCHED: HRESULT = 0x803E0205u32 as HRESULT; +pub const WPN_E_CALLBACK_ALREADY_REGISTERED: HRESULT = 0x803E0206u32 as HRESULT; +pub const WPN_E_TOAST_NOTIFICATION_DROPPED: HRESULT = 0x803E0207u32 as HRESULT; +pub const WPN_E_STORAGE_LOCKED: HRESULT = 0x803E0208u32 as HRESULT; +pub const E_MBN_CONTEXT_NOT_ACTIVATED: HRESULT = 0x80548201u32 as HRESULT; +pub const E_MBN_BAD_SIM: HRESULT = 0x80548202u32 as HRESULT; +pub const E_MBN_DATA_CLASS_NOT_AVAILABLE: HRESULT = 0x80548203u32 as HRESULT; +pub const E_MBN_INVALID_ACCESS_STRING: HRESULT = 0x80548204u32 as HRESULT; +pub const E_MBN_MAX_ACTIVATED_CONTEXTS: HRESULT = 0x80548205u32 as HRESULT; +pub const E_MBN_PACKET_SVC_DETACHED: HRESULT = 0x80548206u32 as HRESULT; +pub const E_MBN_PROVIDER_NOT_VISIBLE: HRESULT = 0x80548207u32 as HRESULT; +pub const E_MBN_RADIO_POWER_OFF: HRESULT = 0x80548208u32 as HRESULT; +pub const E_MBN_SERVICE_NOT_ACTIVATED: HRESULT = 0x80548209u32 as HRESULT; +pub const E_MBN_SIM_NOT_INSERTED: HRESULT = 0x8054820Au32 as HRESULT; +pub const E_MBN_VOICE_CALL_IN_PROGRESS: HRESULT = 0x8054820Bu32 as HRESULT; +pub const E_MBN_INVALID_CACHE: HRESULT = 0x8054820Cu32 as HRESULT; +pub const E_MBN_NOT_REGISTERED: HRESULT = 0x8054820Du32 as HRESULT; +pub const E_MBN_PROVIDERS_NOT_FOUND: HRESULT = 0x8054820Eu32 as HRESULT; +pub const E_MBN_PIN_NOT_SUPPORTED: HRESULT = 0x8054820Fu32 as HRESULT; +pub const E_MBN_PIN_REQUIRED: HRESULT = 0x80548210u32 as HRESULT; +pub const E_MBN_PIN_DISABLED: HRESULT = 0x80548211u32 as HRESULT; +pub const E_MBN_FAILURE: HRESULT = 0x80548212u32 as HRESULT; +pub const E_MBN_INVALID_PROFILE: HRESULT = 0x80548218u32 as HRESULT; +pub const E_MBN_DEFAULT_PROFILE_EXIST: HRESULT = 0x80548219u32 as HRESULT; +pub const E_MBN_SMS_ENCODING_NOT_SUPPORTED: HRESULT = 0x80548220u32 as HRESULT; +pub const E_MBN_SMS_FILTER_NOT_SUPPORTED: HRESULT = 0x80548221u32 as HRESULT; +pub const E_MBN_SMS_INVALID_MEMORY_INDEX: HRESULT = 0x80548222u32 as HRESULT; +pub const E_MBN_SMS_LANG_NOT_SUPPORTED: HRESULT = 0x80548223u32 as HRESULT; +pub const E_MBN_SMS_MEMORY_FAILURE: HRESULT = 0x80548224u32 as HRESULT; +pub const E_MBN_SMS_NETWORK_TIMEOUT: HRESULT = 0x80548225u32 as HRESULT; +pub const E_MBN_SMS_UNKNOWN_SMSC_ADDRESS: HRESULT = 0x80548226u32 as HRESULT; +pub const E_MBN_SMS_FORMAT_NOT_SUPPORTED: HRESULT = 0x80548227u32 as HRESULT; +pub const E_MBN_SMS_OPERATION_NOT_ALLOWED: HRESULT = 0x80548228u32 as HRESULT; +pub const E_MBN_SMS_MEMORY_FULL: HRESULT = 0x80548229u32 as HRESULT; +pub const PEER_E_IPV6_NOT_INSTALLED: HRESULT = 0x80630001u32 as HRESULT; +pub const PEER_E_NOT_INITIALIZED: HRESULT = 0x80630002u32 as HRESULT; +pub const PEER_E_CANNOT_START_SERVICE: HRESULT = 0x80630003u32 as HRESULT; +pub const PEER_E_NOT_LICENSED: HRESULT = 0x80630004u32 as HRESULT; +pub const PEER_E_INVALID_GRAPH: HRESULT = 0x80630010u32 as HRESULT; +pub const PEER_E_DBNAME_CHANGED: HRESULT = 0x80630011u32 as HRESULT; +pub const PEER_E_DUPLICATE_GRAPH: HRESULT = 0x80630012u32 as HRESULT; +pub const PEER_E_GRAPH_NOT_READY: HRESULT = 0x80630013u32 as HRESULT; +pub const PEER_E_GRAPH_SHUTTING_DOWN: HRESULT = 0x80630014u32 as HRESULT; +pub const PEER_E_GRAPH_IN_USE: HRESULT = 0x80630015u32 as HRESULT; +pub const PEER_E_INVALID_DATABASE: HRESULT = 0x80630016u32 as HRESULT; +pub const PEER_E_TOO_MANY_ATTRIBUTES: HRESULT = 0x80630017u32 as HRESULT; +pub const PEER_E_CONNECTION_NOT_FOUND: HRESULT = 0x80630103u32 as HRESULT; +pub const PEER_E_CONNECT_SELF: HRESULT = 0x80630106u32 as HRESULT; +pub const PEER_E_ALREADY_LISTENING: HRESULT = 0x80630107u32 as HRESULT; +pub const PEER_E_NODE_NOT_FOUND: HRESULT = 0x80630108u32 as HRESULT; +pub const PEER_E_CONNECTION_FAILED: HRESULT = 0x80630109u32 as HRESULT; +pub const PEER_E_CONNECTION_NOT_AUTHENTICATED: HRESULT = 0x8063010Au32 as HRESULT; +pub const PEER_E_CONNECTION_REFUSED: HRESULT = 0x8063010Bu32 as HRESULT; +pub const PEER_E_CLASSIFIER_TOO_LONG: HRESULT = 0x80630201u32 as HRESULT; +pub const PEER_E_TOO_MANY_IDENTITIES: HRESULT = 0x80630202u32 as HRESULT; +pub const PEER_E_NO_KEY_ACCESS: HRESULT = 0x80630203u32 as HRESULT; +pub const PEER_E_GROUPS_EXIST: HRESULT = 0x80630204u32 as HRESULT; +pub const PEER_E_RECORD_NOT_FOUND: HRESULT = 0x80630301u32 as HRESULT; +pub const PEER_E_DATABASE_ACCESSDENIED: HRESULT = 0x80630302u32 as HRESULT; +pub const PEER_E_DBINITIALIZATION_FAILED: HRESULT = 0x80630303u32 as HRESULT; +pub const PEER_E_MAX_RECORD_SIZE_EXCEEDED: HRESULT = 0x80630304u32 as HRESULT; +pub const PEER_E_DATABASE_ALREADY_PRESENT: HRESULT = 0x80630305u32 as HRESULT; +pub const PEER_E_DATABASE_NOT_PRESENT: HRESULT = 0x80630306u32 as HRESULT; +pub const PEER_E_IDENTITY_NOT_FOUND: HRESULT = 0x80630401u32 as HRESULT; +pub const PEER_E_EVENT_HANDLE_NOT_FOUND: HRESULT = 0x80630501u32 as HRESULT; +pub const PEER_E_INVALID_SEARCH: HRESULT = 0x80630601u32 as HRESULT; +pub const PEER_E_INVALID_ATTRIBUTES: HRESULT = 0x80630602u32 as HRESULT; +pub const PEER_E_INVITATION_NOT_TRUSTED: HRESULT = 0x80630701u32 as HRESULT; +pub const PEER_E_CHAIN_TOO_LONG: HRESULT = 0x80630703u32 as HRESULT; +pub const PEER_E_INVALID_TIME_PERIOD: HRESULT = 0x80630705u32 as HRESULT; +pub const PEER_E_CIRCULAR_CHAIN_DETECTED: HRESULT = 0x80630706u32 as HRESULT; +pub const PEER_E_CERT_STORE_CORRUPTED: HRESULT = 0x80630801u32 as HRESULT; +pub const PEER_E_NO_CLOUD: HRESULT = 0x80631001u32 as HRESULT; +pub const PEER_E_CLOUD_NAME_AMBIGUOUS: HRESULT = 0x80631005u32 as HRESULT; +pub const PEER_E_INVALID_RECORD: HRESULT = 0x80632010u32 as HRESULT; +pub const PEER_E_NOT_AUTHORIZED: HRESULT = 0x80632020u32 as HRESULT; +pub const PEER_E_PASSWORD_DOES_NOT_MEET_POLICY: HRESULT = 0x80632021u32 as HRESULT; +pub const PEER_E_DEFERRED_VALIDATION: HRESULT = 0x80632030u32 as HRESULT; +pub const PEER_E_INVALID_GROUP_PROPERTIES: HRESULT = 0x80632040u32 as HRESULT; +pub const PEER_E_INVALID_PEER_NAME: HRESULT = 0x80632050u32 as HRESULT; +pub const PEER_E_INVALID_CLASSIFIER: HRESULT = 0x80632060u32 as HRESULT; +pub const PEER_E_INVALID_FRIENDLY_NAME: HRESULT = 0x80632070u32 as HRESULT; +pub const PEER_E_INVALID_ROLE_PROPERTY: HRESULT = 0x80632071u32 as HRESULT; +pub const PEER_E_INVALID_CLASSIFIER_PROPERTY: HRESULT = 0x80632072u32 as HRESULT; +pub const PEER_E_INVALID_RECORD_EXPIRATION: HRESULT = 0x80632080u32 as HRESULT; +pub const PEER_E_INVALID_CREDENTIAL_INFO: HRESULT = 0x80632081u32 as HRESULT; +pub const PEER_E_INVALID_CREDENTIAL: HRESULT = 0x80632082u32 as HRESULT; +pub const PEER_E_INVALID_RECORD_SIZE: HRESULT = 0x80632083u32 as HRESULT; +pub const PEER_E_UNSUPPORTED_VERSION: HRESULT = 0x80632090u32 as HRESULT; +pub const PEER_E_GROUP_NOT_READY: HRESULT = 0x80632091u32 as HRESULT; +pub const PEER_E_GROUP_IN_USE: HRESULT = 0x80632092u32 as HRESULT; +pub const PEER_E_INVALID_GROUP: HRESULT = 0x80632093u32 as HRESULT; +pub const PEER_E_NO_MEMBERS_FOUND: HRESULT = 0x80632094u32 as HRESULT; +pub const PEER_E_NO_MEMBER_CONNECTIONS: HRESULT = 0x80632095u32 as HRESULT; +pub const PEER_E_UNABLE_TO_LISTEN: HRESULT = 0x80632096u32 as HRESULT; +pub const PEER_E_IDENTITY_DELETED: HRESULT = 0x806320A0u32 as HRESULT; +pub const PEER_E_SERVICE_NOT_AVAILABLE: HRESULT = 0x806320A1u32 as HRESULT; +pub const PEER_E_CONTACT_NOT_FOUND: HRESULT = 0x80636001u32 as HRESULT; +pub const PEER_S_GRAPH_DATA_CREATED: HRESULT = 0x00630001; +pub const PEER_S_NO_EVENT_DATA: HRESULT = 0x00630002; +pub const PEER_S_ALREADY_CONNECTED: HRESULT = 0x00632000; +pub const PEER_S_SUBSCRIPTION_EXISTS: HRESULT = 0x00636000; +pub const PEER_S_NO_CONNECTIVITY: HRESULT = 0x00630005; +pub const PEER_S_ALREADY_A_MEMBER: HRESULT = 0x00630006; +pub const PEER_E_CANNOT_CONVERT_PEER_NAME: HRESULT = 0x80634001u32 as HRESULT; +pub const PEER_E_INVALID_PEER_HOST_NAME: HRESULT = 0x80634002u32 as HRESULT; +pub const PEER_E_NO_MORE: HRESULT = 0x80634003u32 as HRESULT; +pub const PEER_E_PNRP_DUPLICATE_PEER_NAME: HRESULT = 0x80634005u32 as HRESULT; +pub const PEER_E_INVITE_CANCELLED: HRESULT = 0x80637000u32 as HRESULT; +pub const PEER_E_INVITE_RESPONSE_NOT_AVAILABLE: HRESULT = 0x80637001u32 as HRESULT; +pub const PEER_E_NOT_SIGNED_IN: HRESULT = 0x80637003u32 as HRESULT; +pub const PEER_E_PRIVACY_DECLINED: HRESULT = 0x80637004u32 as HRESULT; +pub const PEER_E_TIMEOUT: HRESULT = 0x80637005u32 as HRESULT; +pub const PEER_E_INVALID_ADDRESS: HRESULT = 0x80637007u32 as HRESULT; +pub const PEER_E_FW_EXCEPTION_DISABLED: HRESULT = 0x80637008u32 as HRESULT; +pub const PEER_E_FW_BLOCKED_BY_POLICY: HRESULT = 0x80637009u32 as HRESULT; +pub const PEER_E_FW_BLOCKED_BY_SHIELDS_UP: HRESULT = 0x8063700Au32 as HRESULT; +pub const PEER_E_FW_DECLINED: HRESULT = 0x8063700Bu32 as HRESULT; +pub const UI_E_CREATE_FAILED: HRESULT = 0x802A0001u32 as HRESULT; +pub const UI_E_SHUTDOWN_CALLED: HRESULT = 0x802A0002u32 as HRESULT; +pub const UI_E_ILLEGAL_REENTRANCY: HRESULT = 0x802A0003u32 as HRESULT; +pub const UI_E_OBJECT_SEALED: HRESULT = 0x802A0004u32 as HRESULT; +pub const UI_E_VALUE_NOT_SET: HRESULT = 0x802A0005u32 as HRESULT; +pub const UI_E_VALUE_NOT_DETERMINED: HRESULT = 0x802A0006u32 as HRESULT; +pub const UI_E_INVALID_OUTPUT: HRESULT = 0x802A0007u32 as HRESULT; +pub const UI_E_BOOLEAN_EXPECTED: HRESULT = 0x802A0008u32 as HRESULT; +pub const UI_E_DIFFERENT_OWNER: HRESULT = 0x802A0009u32 as HRESULT; +pub const UI_E_AMBIGUOUS_MATCH: HRESULT = 0x802A000Au32 as HRESULT; +pub const UI_E_FP_OVERFLOW: HRESULT = 0x802A000Bu32 as HRESULT; +pub const UI_E_WRONG_THREAD: HRESULT = 0x802A000Cu32 as HRESULT; +pub const UI_E_STORYBOARD_ACTIVE: HRESULT = 0x802A0101u32 as HRESULT; +pub const UI_E_STORYBOARD_NOT_PLAYING: HRESULT = 0x802A0102u32 as HRESULT; +pub const UI_E_START_KEYFRAME_AFTER_END: HRESULT = 0x802A0103u32 as HRESULT; +pub const UI_E_END_KEYFRAME_NOT_DETERMINED: HRESULT = 0x802A0104u32 as HRESULT; +pub const UI_E_LOOPS_OVERLAP: HRESULT = 0x802A0105u32 as HRESULT; +pub const UI_E_TRANSITION_ALREADY_USED: HRESULT = 0x802A0106u32 as HRESULT; +pub const UI_E_TRANSITION_NOT_IN_STORYBOARD: HRESULT = 0x802A0107u32 as HRESULT; +pub const UI_E_TRANSITION_ECLIPSED: HRESULT = 0x802A0108u32 as HRESULT; +pub const UI_E_TIME_BEFORE_LAST_UPDATE: HRESULT = 0x802A0109u32 as HRESULT; +pub const UI_E_TIMER_CLIENT_ALREADY_CONNECTED: HRESULT = 0x802A010Au32 as HRESULT; +pub const UI_E_INVALID_DIMENSION: HRESULT = 0x802A010Bu32 as HRESULT; +pub const UI_E_PRIMITIVE_OUT_OF_BOUNDS: HRESULT = 0x802A010Cu32 as HRESULT; +pub const UI_E_WINDOW_CLOSED: HRESULT = 0x802A0201u32 as HRESULT; +pub const E_BLUETOOTH_ATT_INVALID_HANDLE: HRESULT = 0x80650001u32 as HRESULT; +pub const E_BLUETOOTH_ATT_READ_NOT_PERMITTED: HRESULT = 0x80650002u32 as HRESULT; +pub const E_BLUETOOTH_ATT_WRITE_NOT_PERMITTED: HRESULT = 0x80650003u32 as HRESULT; +pub const E_BLUETOOTH_ATT_INVALID_PDU: HRESULT = 0x80650004u32 as HRESULT; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_AUTHENTICATION: HRESULT = 0x80650005u32 as HRESULT; +pub const E_BLUETOOTH_ATT_REQUEST_NOT_SUPPORTED: HRESULT = 0x80650006u32 as HRESULT; +pub const E_BLUETOOTH_ATT_INVALID_OFFSET: HRESULT = 0x80650007u32 as HRESULT; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_AUTHORIZATION: HRESULT = 0x80650008u32 as HRESULT; +pub const E_BLUETOOTH_ATT_PREPARE_QUEUE_FULL: HRESULT = 0x80650009u32 as HRESULT; +pub const E_BLUETOOTH_ATT_ATTRIBUTE_NOT_FOUND: HRESULT = 0x8065000Au32 as HRESULT; +pub const E_BLUETOOTH_ATT_ATTRIBUTE_NOT_LONG: HRESULT = 0x8065000Bu32 as HRESULT; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE: HRESULT = 0x8065000Cu32 as HRESULT; +pub const E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH: HRESULT = 0x8065000Du32 as HRESULT; +pub const E_BLUETOOTH_ATT_UNLIKELY: HRESULT = 0x8065000Eu32 as HRESULT; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_ENCRYPTION: HRESULT = 0x8065000Fu32 as HRESULT; +pub const E_BLUETOOTH_ATT_UNSUPPORTED_GROUP_TYPE: HRESULT = 0x80650010u32 as HRESULT; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_RESOURCES: HRESULT = 0x80650011u32 as HRESULT; +pub const E_BLUETOOTH_ATT_UNKNOWN_ERROR: HRESULT = 0x80651000u32 as HRESULT; +pub const E_AUDIO_ENGINE_NODE_NOT_FOUND: HRESULT = 0x80660001u32 as HRESULT; +pub const E_HDAUDIO_EMPTY_CONNECTION_LIST: HRESULT = 0x80660002u32 as HRESULT; +pub const E_HDAUDIO_CONNECTION_LIST_NOT_SUPPORTED: HRESULT = 0x80660003u32 as HRESULT; +pub const E_HDAUDIO_NO_LOGICAL_DEVICES_CREATED: HRESULT = 0x80660004u32 as HRESULT; +pub const E_HDAUDIO_NULL_LINKED_LIST_ENTRY: HRESULT = 0x80660005u32 as HRESULT; +pub const ERROR_SPACES_POOL_WAS_DELETED: HRESULT = 0x00E70001; +pub const ERROR_SPACES_RESILIENCY_TYPE_INVALID: HRESULT = 0x80E70003u32 as HRESULT; +pub const ERROR_SPACES_DRIVE_SECTOR_SIZE_INVALID: HRESULT = 0x80E70004u32 as HRESULT; +pub const ERROR_SPACES_DRIVE_REDUNDANCY_INVALID: HRESULT = 0x80E70006u32 as HRESULT; +pub const ERROR_SPACES_NUMBER_OF_DATA_COPIES_INVALID: HRESULT = 0x80E70007u32 as HRESULT; +pub const ERROR_SPACES_PARITY_LAYOUT_INVALID: HRESULT = 0x80E70008u32 as HRESULT; +pub const ERROR_SPACES_INTERLEAVE_LENGTH_INVALID: HRESULT = 0x80E70009u32 as HRESULT; +pub const ERROR_SPACES_NUMBER_OF_COLUMNS_INVALID: HRESULT = 0x80E7000Au32 as HRESULT; +pub const ERROR_SPACES_NOT_ENOUGH_DRIVES: HRESULT = 0x80E7000Bu32 as HRESULT; +pub const ERROR_VOLSNAP_BOOTFILE_NOT_VALID: HRESULT = 0x80820001u32 as HRESULT; +pub const ERROR_TIERING_NOT_SUPPORTED_ON_VOLUME: HRESULT = 0x80830001u32 as HRESULT; +pub const ERROR_TIERING_VOLUME_DISMOUNT_IN_PROGRESS: HRESULT = 0x80830002u32 as HRESULT; +pub const ERROR_TIERING_STORAGE_TIER_NOT_FOUND: HRESULT = 0x80830003u32 as HRESULT; +pub const ERROR_TIERING_INVALID_FILE_ID: HRESULT = 0x80830004u32 as HRESULT; +pub const ERROR_TIERING_WRONG_CLUSTER_NODE: HRESULT = 0x80830005u32 as HRESULT; +pub const ERROR_TIERING_ALREADY_PROCESSING: HRESULT = 0x80830006u32 as HRESULT; +pub const ERROR_TIERING_CANNOT_PIN_OBJECT: HRESULT = 0x80830007u32 as HRESULT; +pub const DXGI_STATUS_OCCLUDED: HRESULT = 0x087A0001; +pub const DXGI_STATUS_CLIPPED: HRESULT = 0x087A0002; +pub const DXGI_STATUS_NO_REDIRECTION: HRESULT = 0x087A0004; +pub const DXGI_STATUS_NO_DESKTOP_ACCESS: HRESULT = 0x087A0005; +pub const DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0x087A0006; +pub const DXGI_STATUS_MODE_CHANGED: HRESULT = 0x087A0007; +pub const DXGI_STATUS_MODE_CHANGE_IN_PROGRESS: HRESULT = 0x087A0008; +pub const DXGI_ERROR_INVALID_CALL: HRESULT = 0x887A0001u32 as HRESULT; +pub const DXGI_ERROR_NOT_FOUND: HRESULT = 0x887A0002u32 as HRESULT; +pub const DXGI_ERROR_MORE_DATA: HRESULT = 0x887A0003u32 as HRESULT; +pub const DXGI_ERROR_UNSUPPORTED: HRESULT = 0x887A0004u32 as HRESULT; +pub const DXGI_ERROR_DEVICE_REMOVED: HRESULT = 0x887A0005u32 as HRESULT; +pub const DXGI_ERROR_DEVICE_HUNG: HRESULT = 0x887A0006u32 as HRESULT; +pub const DXGI_ERROR_DEVICE_RESET: HRESULT = 0x887A0007u32 as HRESULT; +pub const DXGI_ERROR_WAS_STILL_DRAWING: HRESULT = 0x887A000Au32 as HRESULT; +pub const DXGI_ERROR_FRAME_STATISTICS_DISJOINT: HRESULT = 0x887A000Bu32 as HRESULT; +pub const DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0x887A000Cu32 as HRESULT; +pub const DXGI_ERROR_DRIVER_INTERNAL_ERROR: HRESULT = 0x887A0020u32 as HRESULT; +pub const DXGI_ERROR_NONEXCLUSIVE: HRESULT = 0x887A0021u32 as HRESULT; +pub const DXGI_ERROR_NOT_CURRENTLY_AVAILABLE: HRESULT = 0x887A0022u32 as HRESULT; +pub const DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED: HRESULT = 0x887A0023u32 as HRESULT; +pub const DXGI_ERROR_REMOTE_OUTOFMEMORY: HRESULT = 0x887A0024u32 as HRESULT; +pub const DXGI_ERROR_ACCESS_LOST: HRESULT = 0x887A0026u32 as HRESULT; +pub const DXGI_ERROR_WAIT_TIMEOUT: HRESULT = 0x887A0027u32 as HRESULT; +pub const DXGI_ERROR_SESSION_DISCONNECTED: HRESULT = 0x887A0028u32 as HRESULT; +pub const DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE: HRESULT = 0x887A0029u32 as HRESULT; +pub const DXGI_ERROR_CANNOT_PROTECT_CONTENT: HRESULT = 0x887A002Au32 as HRESULT; +pub const DXGI_ERROR_ACCESS_DENIED: HRESULT = 0x887A002Bu32 as HRESULT; +pub const DXGI_ERROR_NAME_ALREADY_EXISTS: HRESULT = 0x887A002Cu32 as HRESULT; +pub const DXGI_ERROR_SDK_COMPONENT_MISSING: HRESULT = 0x887A002Du32 as HRESULT; +pub const DXGI_STATUS_UNOCCLUDED: HRESULT = 0x087A0009; +pub const DXGI_STATUS_DDA_WAS_STILL_DRAWING: HRESULT = 0x087A000A; +pub const DXGI_ERROR_MODE_CHANGE_IN_PROGRESS: HRESULT = 0x887A0025u32 as HRESULT; +pub const DXGI_DDI_ERR_WASSTILLDRAWING: HRESULT = 0x887B0001u32 as HRESULT; +pub const DXGI_DDI_ERR_UNSUPPORTED: HRESULT = 0x887B0002u32 as HRESULT; +pub const DXGI_DDI_ERR_NONEXCLUSIVE: HRESULT = 0x887B0003u32 as HRESULT; +pub const D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: HRESULT = 0x88790001u32 as HRESULT; +pub const D3D10_ERROR_FILE_NOT_FOUND: HRESULT = 0x88790002u32 as HRESULT; +pub const D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: HRESULT = 0x887C0001u32 as HRESULT; +pub const D3D11_ERROR_FILE_NOT_FOUND: HRESULT = 0x887C0002u32 as HRESULT; +pub const D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS: HRESULT = 0x887C0003u32 as HRESULT; +pub const D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD: HRESULT = 0x887C0004u32 as HRESULT; +pub const D2DERR_WRONG_STATE: HRESULT = 0x88990001u32 as HRESULT; +pub const D2DERR_NOT_INITIALIZED: HRESULT = 0x88990002u32 as HRESULT; +pub const D2DERR_UNSUPPORTED_OPERATION: HRESULT = 0x88990003u32 as HRESULT; +pub const D2DERR_SCANNER_FAILED: HRESULT = 0x88990004u32 as HRESULT; +pub const D2DERR_SCREEN_ACCESS_DENIED: HRESULT = 0x88990005u32 as HRESULT; +pub const D2DERR_DISPLAY_STATE_INVALID: HRESULT = 0x88990006u32 as HRESULT; +pub const D2DERR_ZERO_VECTOR: HRESULT = 0x88990007u32 as HRESULT; +pub const D2DERR_INTERNAL_ERROR: HRESULT = 0x88990008u32 as HRESULT; +pub const D2DERR_DISPLAY_FORMAT_NOT_SUPPORTED: HRESULT = 0x88990009u32 as HRESULT; +pub const D2DERR_INVALID_CALL: HRESULT = 0x8899000Au32 as HRESULT; +pub const D2DERR_NO_HARDWARE_DEVICE: HRESULT = 0x8899000Bu32 as HRESULT; +pub const D2DERR_RECREATE_TARGET: HRESULT = 0x8899000Cu32 as HRESULT; +pub const D2DERR_TOO_MANY_SHADER_ELEMENTS: HRESULT = 0x8899000Du32 as HRESULT; +pub const D2DERR_SHADER_COMPILE_FAILED: HRESULT = 0x8899000Eu32 as HRESULT; +pub const D2DERR_MAX_TEXTURE_SIZE_EXCEEDED: HRESULT = 0x8899000Fu32 as HRESULT; +pub const D2DERR_UNSUPPORTED_VERSION: HRESULT = 0x88990010u32 as HRESULT; +pub const D2DERR_BAD_NUMBER: HRESULT = 0x88990011u32 as HRESULT; +pub const D2DERR_WRONG_FACTORY: HRESULT = 0x88990012u32 as HRESULT; +pub const D2DERR_LAYER_ALREADY_IN_USE: HRESULT = 0x88990013u32 as HRESULT; +pub const D2DERR_POP_CALL_DID_NOT_MATCH_PUSH: HRESULT = 0x88990014u32 as HRESULT; +pub const D2DERR_WRONG_RESOURCE_DOMAIN: HRESULT = 0x88990015u32 as HRESULT; +pub const D2DERR_PUSH_POP_UNBALANCED: HRESULT = 0x88990016u32 as HRESULT; +pub const D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT: HRESULT = 0x88990017u32 as HRESULT; +pub const D2DERR_INCOMPATIBLE_BRUSH_TYPES: HRESULT = 0x88990018u32 as HRESULT; +pub const D2DERR_WIN32_ERROR: HRESULT = 0x88990019u32 as HRESULT; +pub const D2DERR_TARGET_NOT_GDI_COMPATIBLE: HRESULT = 0x8899001Au32 as HRESULT; +pub const D2DERR_TEXT_EFFECT_IS_WRONG_TYPE: HRESULT = 0x8899001Bu32 as HRESULT; +pub const D2DERR_TEXT_RENDERER_NOT_RELEASED: HRESULT = 0x8899001Cu32 as HRESULT; +pub const D2DERR_EXCEEDS_MAX_BITMAP_SIZE: HRESULT = 0x8899001Du32 as HRESULT; +pub const D2DERR_INVALID_GRAPH_CONFIGURATION: HRESULT = 0x8899001Eu32 as HRESULT; +pub const D2DERR_INVALID_INTERNAL_GRAPH_CONFIGURATION: HRESULT = 0x8899001Fu32 as HRESULT; +pub const D2DERR_CYCLIC_GRAPH: HRESULT = 0x88990020u32 as HRESULT; +pub const D2DERR_BITMAP_CANNOT_DRAW: HRESULT = 0x88990021u32 as HRESULT; +pub const D2DERR_OUTSTANDING_BITMAP_REFERENCES: HRESULT = 0x88990022u32 as HRESULT; +pub const D2DERR_ORIGINAL_TARGET_NOT_BOUND: HRESULT = 0x88990023u32 as HRESULT; +pub const D2DERR_INVALID_TARGET: HRESULT = 0x88990024u32 as HRESULT; +pub const D2DERR_BITMAP_BOUND_AS_TARGET: HRESULT = 0x88990025u32 as HRESULT; +pub const D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES: HRESULT = 0x88990026u32 as HRESULT; +pub const D2DERR_INTERMEDIATE_TOO_LARGE: HRESULT = 0x88990027u32 as HRESULT; +pub const D2DERR_EFFECT_IS_NOT_REGISTERED: HRESULT = 0x88990028u32 as HRESULT; +pub const D2DERR_INVALID_PROPERTY: HRESULT = 0x88990029u32 as HRESULT; +pub const D2DERR_NO_SUBPROPERTIES: HRESULT = 0x8899002Au32 as HRESULT; +pub const D2DERR_PRINT_JOB_CLOSED: HRESULT = 0x8899002Bu32 as HRESULT; +pub const D2DERR_PRINT_FORMAT_NOT_SUPPORTED: HRESULT = 0x8899002Cu32 as HRESULT; +pub const D2DERR_TOO_MANY_TRANSFORM_INPUTS: HRESULT = 0x8899002Du32 as HRESULT; +pub const DWRITE_E_FILEFORMAT: HRESULT = 0x88985000u32 as HRESULT; +pub const DWRITE_E_UNEXPECTED: HRESULT = 0x88985001u32 as HRESULT; +pub const DWRITE_E_NOFONT: HRESULT = 0x88985002u32 as HRESULT; +pub const DWRITE_E_FILENOTFOUND: HRESULT = 0x88985003u32 as HRESULT; +pub const DWRITE_E_FILEACCESS: HRESULT = 0x88985004u32 as HRESULT; +pub const DWRITE_E_FONTCOLLECTIONOBSOLETE: HRESULT = 0x88985005u32 as HRESULT; +pub const DWRITE_E_ALREADYREGISTERED: HRESULT = 0x88985006u32 as HRESULT; +pub const DWRITE_E_CACHEFORMAT: HRESULT = 0x88985007u32 as HRESULT; +pub const DWRITE_E_CACHEVERSION: HRESULT = 0x88985008u32 as HRESULT; +pub const DWRITE_E_UNSUPPORTEDOPERATION: HRESULT = 0x88985009u32 as HRESULT; +pub const DWRITE_E_TEXTRENDERERINCOMPATIBLE: HRESULT = 0x8898500Au32 as HRESULT; +pub const DWRITE_E_FLOWDIRECTIONCONFLICTS: HRESULT = 0x8898500Bu32 as HRESULT; +pub const DWRITE_E_NOCOLOR: HRESULT = 0x8898500Cu32 as HRESULT; +pub const WINCODEC_ERR_WRONGSTATE: HRESULT = 0x88982F04u32 as HRESULT; +pub const WINCODEC_ERR_VALUEOUTOFRANGE: HRESULT = 0x88982F05u32 as HRESULT; +pub const WINCODEC_ERR_UNKNOWNIMAGEFORMAT: HRESULT = 0x88982F07u32 as HRESULT; +pub const WINCODEC_ERR_UNSUPPORTEDVERSION: HRESULT = 0x88982F0Bu32 as HRESULT; +pub const WINCODEC_ERR_NOTINITIALIZED: HRESULT = 0x88982F0Cu32 as HRESULT; +pub const WINCODEC_ERR_ALREADYLOCKED: HRESULT = 0x88982F0Du32 as HRESULT; +pub const WINCODEC_ERR_PROPERTYNOTFOUND: HRESULT = 0x88982F40u32 as HRESULT; +pub const WINCODEC_ERR_PROPERTYNOTSUPPORTED: HRESULT = 0x88982F41u32 as HRESULT; +pub const WINCODEC_ERR_PROPERTYSIZE: HRESULT = 0x88982F42u32 as HRESULT; +pub const WINCODEC_ERR_CODECPRESENT: HRESULT = 0x88982F43u32 as HRESULT; +pub const WINCODEC_ERR_CODECNOTHUMBNAIL: HRESULT = 0x88982F44u32 as HRESULT; +pub const WINCODEC_ERR_PALETTEUNAVAILABLE: HRESULT = 0x88982F45u32 as HRESULT; +pub const WINCODEC_ERR_CODECTOOMANYSCANLINES: HRESULT = 0x88982F46u32 as HRESULT; +pub const WINCODEC_ERR_INTERNALERROR: HRESULT = 0x88982F48u32 as HRESULT; +pub const WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS: HRESULT = 0x88982F49u32 as HRESULT; +pub const WINCODEC_ERR_COMPONENTNOTFOUND: HRESULT = 0x88982F50u32 as HRESULT; +pub const WINCODEC_ERR_IMAGESIZEOUTOFRANGE: HRESULT = 0x88982F51u32 as HRESULT; +pub const WINCODEC_ERR_TOOMUCHMETADATA: HRESULT = 0x88982F52u32 as HRESULT; +pub const WINCODEC_ERR_BADIMAGE: HRESULT = 0x88982F60u32 as HRESULT; +pub const WINCODEC_ERR_BADHEADER: HRESULT = 0x88982F61u32 as HRESULT; +pub const WINCODEC_ERR_FRAMEMISSING: HRESULT = 0x88982F62u32 as HRESULT; +pub const WINCODEC_ERR_BADMETADATAHEADER: HRESULT = 0x88982F63u32 as HRESULT; +pub const WINCODEC_ERR_BADSTREAMDATA: HRESULT = 0x88982F70u32 as HRESULT; +pub const WINCODEC_ERR_STREAMWRITE: HRESULT = 0x88982F71u32 as HRESULT; +pub const WINCODEC_ERR_STREAMREAD: HRESULT = 0x88982F72u32 as HRESULT; +pub const WINCODEC_ERR_STREAMNOTAVAILABLE: HRESULT = 0x88982F73u32 as HRESULT; +pub const WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT: HRESULT = 0x88982F80u32 as HRESULT; +pub const WINCODEC_ERR_UNSUPPORTEDOPERATION: HRESULT = 0x88982F81u32 as HRESULT; +pub const WINCODEC_ERR_INVALIDREGISTRATION: HRESULT = 0x88982F8Au32 as HRESULT; +pub const WINCODEC_ERR_COMPONENTINITIALIZEFAILURE: HRESULT = 0x88982F8Bu32 as HRESULT; +pub const WINCODEC_ERR_INSUFFICIENTBUFFER: HRESULT = 0x88982F8Cu32 as HRESULT; +pub const WINCODEC_ERR_DUPLICATEMETADATAPRESENT: HRESULT = 0x88982F8Du32 as HRESULT; +pub const WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE: HRESULT = 0x88982F8Eu32 as HRESULT; +pub const WINCODEC_ERR_UNEXPECTEDSIZE: HRESULT = 0x88982F8Fu32 as HRESULT; +pub const WINCODEC_ERR_INVALIDQUERYREQUEST: HRESULT = 0x88982F90u32 as HRESULT; +pub const WINCODEC_ERR_UNEXPECTEDMETADATATYPE: HRESULT = 0x88982F91u32 as HRESULT; +pub const WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT: HRESULT = 0x88982F92u32 as HRESULT; +pub const WINCODEC_ERR_INVALIDQUERYCHARACTER: HRESULT = 0x88982F93u32 as HRESULT; +pub const WINCODEC_ERR_WIN32ERROR: HRESULT = 0x88982F94u32 as HRESULT; +pub const WINCODEC_ERR_INVALIDPROGRESSIVELEVEL: HRESULT = 0x88982F95u32 as HRESULT; +pub const MILERR_OBJECTBUSY: HRESULT = 0x88980001u32 as HRESULT; +pub const MILERR_INSUFFICIENTBUFFER: HRESULT = 0x88980002u32 as HRESULT; +pub const MILERR_WIN32ERROR: HRESULT = 0x88980003u32 as HRESULT; +pub const MILERR_SCANNER_FAILED: HRESULT = 0x88980004u32 as HRESULT; +pub const MILERR_SCREENACCESSDENIED: HRESULT = 0x88980005u32 as HRESULT; +pub const MILERR_DISPLAYSTATEINVALID: HRESULT = 0x88980006u32 as HRESULT; +pub const MILERR_NONINVERTIBLEMATRIX: HRESULT = 0x88980007u32 as HRESULT; +pub const MILERR_ZEROVECTOR: HRESULT = 0x88980008u32 as HRESULT; +pub const MILERR_TERMINATED: HRESULT = 0x88980009u32 as HRESULT; +pub const MILERR_BADNUMBER: HRESULT = 0x8898000Au32 as HRESULT; +pub const MILERR_INTERNALERROR: HRESULT = 0x88980080u32 as HRESULT; +pub const MILERR_DISPLAYFORMATNOTSUPPORTED: HRESULT = 0x88980084u32 as HRESULT; +pub const MILERR_INVALIDCALL: HRESULT = 0x88980085u32 as HRESULT; +pub const MILERR_ALREADYLOCKED: HRESULT = 0x88980086u32 as HRESULT; +pub const MILERR_NOTLOCKED: HRESULT = 0x88980087u32 as HRESULT; +pub const MILERR_DEVICECANNOTRENDERTEXT: HRESULT = 0x88980088u32 as HRESULT; +pub const MILERR_GLYPHBITMAPMISSED: HRESULT = 0x88980089u32 as HRESULT; +pub const MILERR_MALFORMEDGLYPHCACHE: HRESULT = 0x8898008Au32 as HRESULT; +pub const MILERR_GENERIC_IGNORE: HRESULT = 0x8898008Bu32 as HRESULT; +pub const MILERR_MALFORMED_GUIDELINE_DATA: HRESULT = 0x8898008Cu32 as HRESULT; +pub const MILERR_NO_HARDWARE_DEVICE: HRESULT = 0x8898008Du32 as HRESULT; +pub const MILERR_NEED_RECREATE_AND_PRESENT: HRESULT = 0x8898008Eu32 as HRESULT; +pub const MILERR_ALREADY_INITIALIZED: HRESULT = 0x8898008Fu32 as HRESULT; +pub const MILERR_MISMATCHED_SIZE: HRESULT = 0x88980090u32 as HRESULT; +pub const MILERR_NO_REDIRECTION_SURFACE_AVAILABLE: HRESULT = 0x88980091u32 as HRESULT; +pub const MILERR_REMOTING_NOT_SUPPORTED: HRESULT = 0x88980092u32 as HRESULT; +pub const MILERR_QUEUED_PRESENT_NOT_SUPPORTED: HRESULT = 0x88980093u32 as HRESULT; +pub const MILERR_NOT_QUEUING_PRESENTS: HRESULT = 0x88980094u32 as HRESULT; +pub const MILERR_NO_REDIRECTION_SURFACE_RETRY_LATER: HRESULT = 0x88980095u32 as HRESULT; +pub const MILERR_TOOMANYSHADERELEMNTS: HRESULT = 0x88980096u32 as HRESULT; +pub const MILERR_MROW_READLOCK_FAILED: HRESULT = 0x88980097u32 as HRESULT; +pub const MILERR_MROW_UPDATE_FAILED: HRESULT = 0x88980098u32 as HRESULT; +pub const MILERR_SHADER_COMPILE_FAILED: HRESULT = 0x88980099u32 as HRESULT; +pub const MILERR_MAX_TEXTURE_SIZE_EXCEEDED: HRESULT = 0x8898009Au32 as HRESULT; +pub const MILERR_QPC_TIME_WENT_BACKWARD: HRESULT = 0x8898009Bu32 as HRESULT; +pub const MILERR_DXGI_ENUMERATION_OUT_OF_SYNC: HRESULT = 0x8898009Du32 as HRESULT; +pub const MILERR_ADAPTER_NOT_FOUND: HRESULT = 0x8898009Eu32 as HRESULT; +pub const MILERR_COLORSPACE_NOT_SUPPORTED: HRESULT = 0x8898009Fu32 as HRESULT; +pub const MILERR_PREFILTER_NOT_SUPPORTED: HRESULT = 0x889800A0u32 as HRESULT; +pub const MILERR_DISPLAYID_ACCESS_DENIED: HRESULT = 0x889800A1u32 as HRESULT; +pub const UCEERR_INVALIDPACKETHEADER: HRESULT = 0x88980400u32 as HRESULT; +pub const UCEERR_UNKNOWNPACKET: HRESULT = 0x88980401u32 as HRESULT; +pub const UCEERR_ILLEGALPACKET: HRESULT = 0x88980402u32 as HRESULT; +pub const UCEERR_MALFORMEDPACKET: HRESULT = 0x88980403u32 as HRESULT; +pub const UCEERR_ILLEGALHANDLE: HRESULT = 0x88980404u32 as HRESULT; +pub const UCEERR_HANDLELOOKUPFAILED: HRESULT = 0x88980405u32 as HRESULT; +pub const UCEERR_RENDERTHREADFAILURE: HRESULT = 0x88980406u32 as HRESULT; +pub const UCEERR_CTXSTACKFRSTTARGETNULL: HRESULT = 0x88980407u32 as HRESULT; +pub const UCEERR_CONNECTIONIDLOOKUPFAILED: HRESULT = 0x88980408u32 as HRESULT; +pub const UCEERR_BLOCKSFULL: HRESULT = 0x88980409u32 as HRESULT; +pub const UCEERR_MEMORYFAILURE: HRESULT = 0x8898040Au32 as HRESULT; +pub const UCEERR_PACKETRECORDOUTOFRANGE: HRESULT = 0x8898040Bu32 as HRESULT; +pub const UCEERR_ILLEGALRECORDTYPE: HRESULT = 0x8898040Cu32 as HRESULT; +pub const UCEERR_OUTOFHANDLES: HRESULT = 0x8898040Du32 as HRESULT; +pub const UCEERR_UNCHANGABLE_UPDATE_ATTEMPTED: HRESULT = 0x8898040Eu32 as HRESULT; +pub const UCEERR_NO_MULTIPLE_WORKER_THREADS: HRESULT = 0x8898040Fu32 as HRESULT; +pub const UCEERR_REMOTINGNOTSUPPORTED: HRESULT = 0x88980410u32 as HRESULT; +pub const UCEERR_MISSINGENDCOMMAND: HRESULT = 0x88980411u32 as HRESULT; +pub const UCEERR_MISSINGBEGINCOMMAND: HRESULT = 0x88980412u32 as HRESULT; +pub const UCEERR_CHANNELSYNCTIMEDOUT: HRESULT = 0x88980413u32 as HRESULT; +pub const UCEERR_CHANNELSYNCABANDONED: HRESULT = 0x88980414u32 as HRESULT; +pub const UCEERR_UNSUPPORTEDTRANSPORTVERSION: HRESULT = 0x88980415u32 as HRESULT; +pub const UCEERR_TRANSPORTUNAVAILABLE: HRESULT = 0x88980416u32 as HRESULT; +pub const UCEERR_FEEDBACK_UNSUPPORTED: HRESULT = 0x88980417u32 as HRESULT; +pub const UCEERR_COMMANDTRANSPORTDENIED: HRESULT = 0x88980418u32 as HRESULT; +pub const UCEERR_GRAPHICSSTREAMUNAVAILABLE: HRESULT = 0x88980419u32 as HRESULT; +pub const UCEERR_GRAPHICSSTREAMALREADYOPEN: HRESULT = 0x88980420u32 as HRESULT; +pub const UCEERR_TRANSPORTDISCONNECTED: HRESULT = 0x88980421u32 as HRESULT; +pub const UCEERR_TRANSPORTOVERLOADED: HRESULT = 0x88980422u32 as HRESULT; +pub const UCEERR_PARTITION_ZOMBIED: HRESULT = 0x88980423u32 as HRESULT; +pub const MILAVERR_NOCLOCK: HRESULT = 0x88980500u32 as HRESULT; +pub const MILAVERR_NOMEDIATYPE: HRESULT = 0x88980501u32 as HRESULT; +pub const MILAVERR_NOVIDEOMIXER: HRESULT = 0x88980502u32 as HRESULT; +pub const MILAVERR_NOVIDEOPRESENTER: HRESULT = 0x88980503u32 as HRESULT; +pub const MILAVERR_NOREADYFRAMES: HRESULT = 0x88980504u32 as HRESULT; +pub const MILAVERR_MODULENOTLOADED: HRESULT = 0x88980505u32 as HRESULT; +pub const MILAVERR_WMPFACTORYNOTREGISTERED: HRESULT = 0x88980506u32 as HRESULT; +pub const MILAVERR_INVALIDWMPVERSION: HRESULT = 0x88980507u32 as HRESULT; +pub const MILAVERR_INSUFFICIENTVIDEORESOURCES: HRESULT = 0x88980508u32 as HRESULT; +pub const MILAVERR_VIDEOACCELERATIONNOTAVAILABLE: HRESULT = 0x88980509u32 as HRESULT; +pub const MILAVERR_REQUESTEDTEXTURETOOBIG: HRESULT = 0x8898050Au32 as HRESULT; +pub const MILAVERR_SEEKFAILED: HRESULT = 0x8898050Bu32 as HRESULT; +pub const MILAVERR_UNEXPECTEDWMPFAILURE: HRESULT = 0x8898050Cu32 as HRESULT; +pub const MILAVERR_MEDIAPLAYERCLOSED: HRESULT = 0x8898050Du32 as HRESULT; +pub const MILAVERR_UNKNOWNHARDWAREERROR: HRESULT = 0x8898050Eu32 as HRESULT; +pub const MILEFFECTSERR_UNKNOWNPROPERTY: HRESULT = 0x8898060Eu32 as HRESULT; +pub const MILEFFECTSERR_EFFECTNOTPARTOFGROUP: HRESULT = 0x8898060Fu32 as HRESULT; +pub const MILEFFECTSERR_NOINPUTSOURCEATTACHED: HRESULT = 0x88980610u32 as HRESULT; +pub const MILEFFECTSERR_CONNECTORNOTCONNECTED: HRESULT = 0x88980611u32 as HRESULT; +pub const MILEFFECTSERR_CONNECTORNOTASSOCIATEDWITHEFFECT: HRESULT = 0x88980612u32 as HRESULT; +pub const MILEFFECTSERR_RESERVED: HRESULT = 0x88980613u32 as HRESULT; +pub const MILEFFECTSERR_CYCLEDETECTED: HRESULT = 0x88980614u32 as HRESULT; +pub const MILEFFECTSERR_EFFECTINMORETHANONEGRAPH: HRESULT = 0x88980615u32 as HRESULT; +pub const MILEFFECTSERR_EFFECTALREADYINAGRAPH: HRESULT = 0x88980616u32 as HRESULT; +pub const MILEFFECTSERR_EFFECTHASNOCHILDREN: HRESULT = 0x88980617u32 as HRESULT; +pub const MILEFFECTSERR_ALREADYATTACHEDTOLISTENER: HRESULT = 0x88980618u32 as HRESULT; +pub const MILEFFECTSERR_NOTAFFINETRANSFORM: HRESULT = 0x88980619u32 as HRESULT; +pub const MILEFFECTSERR_EMPTYBOUNDS: HRESULT = 0x8898061Au32 as HRESULT; +pub const MILEFFECTSERR_OUTPUTSIZETOOLARGE: HRESULT = 0x8898061Bu32 as HRESULT; +pub const DWMERR_STATE_TRANSITION_FAILED: HRESULT = 0x88980700u32 as HRESULT; +pub const DWMERR_THEME_FAILED: HRESULT = 0x88980701u32 as HRESULT; +pub const DWMERR_CATASTROPHIC_FAILURE: HRESULT = 0x88980702u32 as HRESULT; +pub const DCOMPOSITION_ERROR_WINDOW_ALREADY_COMPOSED: HRESULT = 0x88980800u32 as HRESULT; +pub const DCOMPOSITION_ERROR_SURFACE_BEING_RENDERED: HRESULT = 0x88980801u32 as HRESULT; +pub const DCOMPOSITION_ERROR_SURFACE_NOT_BEING_RENDERED: HRESULT = 0x88980802u32 as HRESULT; +pub const ONL_E_INVALID_AUTHENTICATION_TARGET: HRESULT = 0x80860001u32 as HRESULT; +pub const ONL_E_ACCESS_DENIED_BY_TOU: HRESULT = 0x80860002u32 as HRESULT; +pub const ONL_E_INVALID_APPLICATION: HRESULT = 0x80860003u32 as HRESULT; +pub const ONL_E_PASSWORD_UPDATE_REQUIRED: HRESULT = 0x80860004u32 as HRESULT; +pub const ONL_E_ACCOUNT_UPDATE_REQUIRED: HRESULT = 0x80860005u32 as HRESULT; +pub const ONL_E_FORCESIGNIN: HRESULT = 0x80860006u32 as HRESULT; +pub const ONL_E_ACCOUNT_LOCKED: HRESULT = 0x80860007u32 as HRESULT; +pub const ONL_E_PARENTAL_CONSENT_REQUIRED: HRESULT = 0x80860008u32 as HRESULT; +pub const ONL_E_EMAIL_VERIFICATION_REQUIRED: HRESULT = 0x80860009u32 as HRESULT; +pub const ONL_E_ACCOUNT_SUSPENDED_COMPROIMISE: HRESULT = 0x8086000Au32 as HRESULT; +pub const ONL_E_ACCOUNT_SUSPENDED_ABUSE: HRESULT = 0x8086000Bu32 as HRESULT; +pub const ONL_E_ACTION_REQUIRED: HRESULT = 0x8086000Cu32 as HRESULT; +pub const ONL_CONNECTION_COUNT_LIMIT: HRESULT = 0x8086000Du32 as HRESULT; +pub const ONL_E_CONNECTED_ACCOUNT_CAN_NOT_SIGNOUT: HRESULT = 0x8086000Eu32 as HRESULT; +pub const ONL_E_USER_AUTHENTICATION_REQUIRED: HRESULT = 0x8086000Fu32 as HRESULT; +pub const ONL_E_REQUEST_THROTTLED: HRESULT = 0x80860010u32 as HRESULT; +pub const FA_E_MAX_PERSISTED_ITEMS_REACHED: HRESULT = 0x80270220u32 as HRESULT; +pub const FA_E_HOMEGROUP_NOT_AVAILABLE: HRESULT = 0x80270222u32 as HRESULT; +pub const E_MONITOR_RESOLUTION_TOO_LOW: HRESULT = 0x80270250u32 as HRESULT; +pub const E_ELEVATED_ACTIVATION_NOT_SUPPORTED: HRESULT = 0x80270251u32 as HRESULT; +pub const E_UAC_DISABLED: HRESULT = 0x80270252u32 as HRESULT; +pub const E_FULL_ADMIN_NOT_SUPPORTED: HRESULT = 0x80270253u32 as HRESULT; +pub const E_APPLICATION_NOT_REGISTERED: HRESULT = 0x80270254u32 as HRESULT; +pub const E_MULTIPLE_EXTENSIONS_FOR_APPLICATION: HRESULT = 0x80270255u32 as HRESULT; +pub const E_MULTIPLE_PACKAGES_FOR_FAMILY: HRESULT = 0x80270256u32 as HRESULT; +pub const E_APPLICATION_MANAGER_NOT_RUNNING: HRESULT = 0x80270257u32 as HRESULT; +pub const S_STORE_LAUNCHED_FOR_REMEDIATION: HRESULT = 0x00270258; +pub const S_APPLICATION_ACTIVATION_ERROR_HANDLED_BY_DIALOG: HRESULT = 0x00270259; +pub const E_APPLICATION_ACTIVATION_TIMED_OUT: HRESULT = 0x8027025Au32 as HRESULT; +pub const E_APPLICATION_ACTIVATION_EXEC_FAILURE: HRESULT = 0x8027025Bu32 as HRESULT; +pub const E_APPLICATION_TEMPORARY_LICENSE_ERROR: HRESULT = 0x8027025Cu32 as HRESULT; +pub const E_APPLICATION_TRIAL_LICENSE_EXPIRED: HRESULT = 0x8027025Du32 as HRESULT; +pub const E_SKYDRIVE_ROOT_TARGET_FILE_SYSTEM_NOT_SUPPORTED: HRESULT = 0x80270260u32 as HRESULT; +pub const E_SKYDRIVE_ROOT_TARGET_OVERLAP: HRESULT = 0x80270261u32 as HRESULT; +pub const E_SKYDRIVE_ROOT_TARGET_CANNOT_INDEX: HRESULT = 0x80270262u32 as HRESULT; +pub const E_SKYDRIVE_FILE_NOT_UPLOADED: HRESULT = 0x80270263u32 as HRESULT; +pub const E_SKYDRIVE_UPDATE_AVAILABILITY_FAIL: HRESULT = 0x80270264u32 as HRESULT; +pub const E_SKYDRIVE_ROOT_TARGET_VOLUME_ROOT_NOT_SUPPORTED: HRESULT = 0x80270265u32 as HRESULT; +pub const E_SYNCENGINE_FILE_SIZE_OVER_LIMIT: HRESULT = 0x8802B001u32 as HRESULT; +pub const E_SYNCENGINE_FILE_SIZE_EXCEEDS_REMAINING_QUOTA: HRESULT = 0x8802B002u32 as HRESULT; +pub const E_SYNCENGINE_UNSUPPORTED_FILE_NAME: HRESULT = 0x8802B003u32 as HRESULT; +pub const E_SYNCENGINE_FOLDER_ITEM_COUNT_LIMIT_EXCEEDED: HRESULT = 0x8802B004u32 as HRESULT; +pub const E_SYNCENGINE_FILE_SYNC_PARTNER_ERROR: HRESULT = 0x8802B005u32 as HRESULT; +pub const E_SYNCENGINE_SYNC_PAUSED_BY_SERVICE: HRESULT = 0x8802B006u32 as HRESULT; +pub const E_SYNCENGINE_FILE_IDENTIFIER_UNKNOWN: HRESULT = 0x8802C002u32 as HRESULT; +pub const E_SYNCENGINE_SERVICE_AUTHENTICATION_FAILED: HRESULT = 0x8802C003u32 as HRESULT; +pub const E_SYNCENGINE_UNKNOWN_SERVICE_ERROR: HRESULT = 0x8802C004u32 as HRESULT; +pub const E_SYNCENGINE_SERVICE_RETURNED_UNEXPECTED_SIZE: HRESULT = 0x8802C005u32 as HRESULT; +pub const E_SYNCENGINE_REQUEST_BLOCKED_BY_SERVICE: HRESULT = 0x8802C006u32 as HRESULT; +pub const E_SYNCENGINE_REQUEST_BLOCKED_DUE_TO_CLIENT_ERROR: HRESULT = 0x8802C007u32 as HRESULT; +pub const E_SYNCENGINE_FOLDER_INACCESSIBLE: HRESULT = 0x8802D001u32 as HRESULT; +pub const E_SYNCENGINE_UNSUPPORTED_FOLDER_NAME: HRESULT = 0x8802D002u32 as HRESULT; +pub const E_SYNCENGINE_UNSUPPORTED_MARKET: HRESULT = 0x8802D003u32 as HRESULT; +pub const E_SYNCENGINE_PATH_LENGTH_LIMIT_EXCEEDED: HRESULT = 0x8802D004u32 as HRESULT; +pub const E_SYNCENGINE_REMOTE_PATH_LENGTH_LIMIT_EXCEEDED: HRESULT = 0x8802D005u32 as HRESULT; +pub const E_SYNCENGINE_CLIENT_UPDATE_NEEDED: HRESULT = 0x8802D006u32 as HRESULT; +pub const E_SYNCENGINE_PROXY_AUTHENTICATION_REQUIRED: HRESULT = 0x8802D007u32 as HRESULT; +pub const E_SYNCENGINE_STORAGE_SERVICE_PROVISIONING_FAILED: HRESULT = 0x8802D008u32 as HRESULT; +pub const E_SYNCENGINE_UNSUPPORTED_REPARSE_POINT: HRESULT = 0x8802D009u32 as HRESULT; +pub const E_SYNCENGINE_STORAGE_SERVICE_BLOCKED: HRESULT = 0x8802D00Au32 as HRESULT; +pub const E_SYNCENGINE_FOLDER_IN_REDIRECTION: HRESULT = 0x8802D00Bu32 as HRESULT; +pub const EAS_E_POLICY_NOT_MANAGED_BY_OS: HRESULT = 0x80550001u32 as HRESULT; +pub const EAS_E_POLICY_COMPLIANT_WITH_ACTIONS: HRESULT = 0x80550002u32 as HRESULT; +pub const EAS_E_REQUESTED_POLICY_NOT_ENFORCEABLE: HRESULT = 0x80550003u32 as HRESULT; +pub const EAS_E_CURRENT_USER_HAS_BLANK_PASSWORD: HRESULT = 0x80550004u32 as HRESULT; +pub const EAS_E_REQUESTED_POLICY_PASSWORD_EXPIRATION_INCOMPATIBLE: HRESULT = 0x80550005u32 as HRESULT; +pub const EAS_E_USER_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550006u32 as HRESULT; +pub const EAS_E_ADMINS_HAVE_BLANK_PASSWORD: HRESULT = 0x80550007u32 as HRESULT; +pub const EAS_E_ADMINS_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550008u32 as HRESULT; +pub const EAS_E_LOCAL_CONTROLLED_USERS_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550009u32 as HRESULT; +pub const EAS_E_PASSWORD_POLICY_NOT_ENFORCEABLE_FOR_CONNECTED_ADMINS: HRESULT = 0x8055000Au32 as HRESULT; +pub const EAS_E_CONNECTED_ADMINS_NEED_TO_CHANGE_PASSWORD: HRESULT = 0x8055000Bu32 as HRESULT; +pub const EAS_E_PASSWORD_POLICY_NOT_ENFORCEABLE_FOR_CURRENT_CONNECTED_USER: HRESULT = 0x8055000Cu32 as HRESULT; +pub const EAS_E_CURRENT_CONNECTED_USER_NEED_TO_CHANGE_PASSWORD: HRESULT = 0x8055000Du32 as HRESULT; +pub const WEB_E_UNSUPPORTED_FORMAT: HRESULT = 0x83750001u32 as HRESULT; +pub const WEB_E_INVALID_XML: HRESULT = 0x83750002u32 as HRESULT; +pub const WEB_E_MISSING_REQUIRED_ELEMENT: HRESULT = 0x83750003u32 as HRESULT; +pub const WEB_E_MISSING_REQUIRED_ATTRIBUTE: HRESULT = 0x83750004u32 as HRESULT; +pub const WEB_E_UNEXPECTED_CONTENT: HRESULT = 0x83750005u32 as HRESULT; +pub const WEB_E_RESOURCE_TOO_LARGE: HRESULT = 0x83750006u32 as HRESULT; +pub const WEB_E_INVALID_JSON_STRING: HRESULT = 0x83750007u32 as HRESULT; +pub const WEB_E_INVALID_JSON_NUMBER: HRESULT = 0x83750008u32 as HRESULT; +pub const WEB_E_JSON_VALUE_NOT_FOUND: HRESULT = 0x83750009u32 as HRESULT; +pub const HTTP_E_STATUS_UNEXPECTED: HRESULT = 0x80190001u32 as HRESULT; +pub const HTTP_E_STATUS_UNEXPECTED_REDIRECTION: HRESULT = 0x80190003u32 as HRESULT; +pub const HTTP_E_STATUS_UNEXPECTED_CLIENT_ERROR: HRESULT = 0x80190004u32 as HRESULT; +pub const HTTP_E_STATUS_UNEXPECTED_SERVER_ERROR: HRESULT = 0x80190005u32 as HRESULT; +pub const HTTP_E_STATUS_AMBIGUOUS: HRESULT = 0x8019012Cu32 as HRESULT; +pub const HTTP_E_STATUS_MOVED: HRESULT = 0x8019012Du32 as HRESULT; +pub const HTTP_E_STATUS_REDIRECT: HRESULT = 0x8019012Eu32 as HRESULT; +pub const HTTP_E_STATUS_REDIRECT_METHOD: HRESULT = 0x8019012Fu32 as HRESULT; +pub const HTTP_E_STATUS_NOT_MODIFIED: HRESULT = 0x80190130u32 as HRESULT; +pub const HTTP_E_STATUS_USE_PROXY: HRESULT = 0x80190131u32 as HRESULT; +pub const HTTP_E_STATUS_REDIRECT_KEEP_VERB: HRESULT = 0x80190133u32 as HRESULT; +pub const HTTP_E_STATUS_BAD_REQUEST: HRESULT = 0x80190190u32 as HRESULT; +pub const HTTP_E_STATUS_DENIED: HRESULT = 0x80190191u32 as HRESULT; +pub const HTTP_E_STATUS_PAYMENT_REQ: HRESULT = 0x80190192u32 as HRESULT; +pub const HTTP_E_STATUS_FORBIDDEN: HRESULT = 0x80190193u32 as HRESULT; +pub const HTTP_E_STATUS_NOT_FOUND: HRESULT = 0x80190194u32 as HRESULT; +pub const HTTP_E_STATUS_BAD_METHOD: HRESULT = 0x80190195u32 as HRESULT; +pub const HTTP_E_STATUS_NONE_ACCEPTABLE: HRESULT = 0x80190196u32 as HRESULT; +pub const HTTP_E_STATUS_PROXY_AUTH_REQ: HRESULT = 0x80190197u32 as HRESULT; +pub const HTTP_E_STATUS_REQUEST_TIMEOUT: HRESULT = 0x80190198u32 as HRESULT; +pub const HTTP_E_STATUS_CONFLICT: HRESULT = 0x80190199u32 as HRESULT; +pub const HTTP_E_STATUS_GONE: HRESULT = 0x8019019Au32 as HRESULT; +pub const HTTP_E_STATUS_LENGTH_REQUIRED: HRESULT = 0x8019019Bu32 as HRESULT; +pub const HTTP_E_STATUS_PRECOND_FAILED: HRESULT = 0x8019019Cu32 as HRESULT; +pub const HTTP_E_STATUS_REQUEST_TOO_LARGE: HRESULT = 0x8019019Du32 as HRESULT; +pub const HTTP_E_STATUS_URI_TOO_LONG: HRESULT = 0x8019019Eu32 as HRESULT; +pub const HTTP_E_STATUS_UNSUPPORTED_MEDIA: HRESULT = 0x8019019Fu32 as HRESULT; +pub const HTTP_E_STATUS_RANGE_NOT_SATISFIABLE: HRESULT = 0x801901A0u32 as HRESULT; +pub const HTTP_E_STATUS_EXPECTATION_FAILED: HRESULT = 0x801901A1u32 as HRESULT; +pub const HTTP_E_STATUS_SERVER_ERROR: HRESULT = 0x801901F4u32 as HRESULT; +pub const HTTP_E_STATUS_NOT_SUPPORTED: HRESULT = 0x801901F5u32 as HRESULT; +pub const HTTP_E_STATUS_BAD_GATEWAY: HRESULT = 0x801901F6u32 as HRESULT; +pub const HTTP_E_STATUS_SERVICE_UNAVAIL: HRESULT = 0x801901F7u32 as HRESULT; +pub const HTTP_E_STATUS_GATEWAY_TIMEOUT: HRESULT = 0x801901F8u32 as HRESULT; +pub const HTTP_E_STATUS_VERSION_NOT_SUP: HRESULT = 0x801901F9u32 as HRESULT; +pub const E_INVALID_PROTOCOL_OPERATION: HRESULT = 0x83760001u32 as HRESULT; +pub const E_INVALID_PROTOCOL_FORMAT: HRESULT = 0x83760002u32 as HRESULT; +pub const E_PROTOCOL_EXTENSIONS_NOT_SUPPORTED: HRESULT = 0x83760003u32 as HRESULT; +pub const E_SUBPROTOCOL_NOT_SUPPORTED: HRESULT = 0x83760004u32 as HRESULT; +pub const E_PROTOCOL_VERSION_NOT_SUPPORTED: HRESULT = 0x83760005u32 as HRESULT; +pub const INPUT_E_OUT_OF_ORDER: HRESULT = 0x80400000u32 as HRESULT; +pub const INPUT_E_REENTRANCY: HRESULT = 0x80400001u32 as HRESULT; +pub const INPUT_E_MULTIMODAL: HRESULT = 0x80400002u32 as HRESULT; +pub const INPUT_E_PACKET: HRESULT = 0x80400003u32 as HRESULT; +pub const INPUT_E_FRAME: HRESULT = 0x80400004u32 as HRESULT; +pub const INPUT_E_HISTORY: HRESULT = 0x80400005u32 as HRESULT; +pub const INPUT_E_DEVICE_INFO: HRESULT = 0x80400006u32 as HRESULT; +pub const INPUT_E_TRANSFORM: HRESULT = 0x80400007u32 as HRESULT; +pub const INPUT_E_DEVICE_PROPERTY: HRESULT = 0x80400008u32 as HRESULT; +pub const INET_E_INVALID_URL: HRESULT = 0x800C0002u32 as HRESULT; +pub const INET_E_NO_SESSION: HRESULT = 0x800C0003u32 as HRESULT; +pub const INET_E_CANNOT_CONNECT: HRESULT = 0x800C0004u32 as HRESULT; +pub const INET_E_RESOURCE_NOT_FOUND: HRESULT = 0x800C0005u32 as HRESULT; +pub const INET_E_OBJECT_NOT_FOUND: HRESULT = 0x800C0006u32 as HRESULT; +pub const INET_E_DATA_NOT_AVAILABLE: HRESULT = 0x800C0007u32 as HRESULT; +pub const INET_E_DOWNLOAD_FAILURE: HRESULT = 0x800C0008u32 as HRESULT; +pub const INET_E_AUTHENTICATION_REQUIRED: HRESULT = 0x800C0009u32 as HRESULT; +pub const INET_E_NO_VALID_MEDIA: HRESULT = 0x800C000Au32 as HRESULT; +pub const INET_E_CONNECTION_TIMEOUT: HRESULT = 0x800C000Bu32 as HRESULT; +pub const INET_E_INVALID_REQUEST: HRESULT = 0x800C000Cu32 as HRESULT; +pub const INET_E_UNKNOWN_PROTOCOL: HRESULT = 0x800C000Du32 as HRESULT; +pub const INET_E_SECURITY_PROBLEM: HRESULT = 0x800C000Eu32 as HRESULT; +pub const INET_E_CANNOT_LOAD_DATA: HRESULT = 0x800C000Fu32 as HRESULT; +pub const INET_E_CANNOT_INSTANTIATE_OBJECT: HRESULT = 0x800C0010u32 as HRESULT; +pub const INET_E_INVALID_CERTIFICATE: HRESULT = 0x800C0019u32 as HRESULT; +pub const INET_E_REDIRECT_FAILED: HRESULT = 0x800C0014u32 as HRESULT; +pub const INET_E_REDIRECT_TO_DIR: HRESULT = 0x800C0015u32 as HRESULT; +pub const ERROR_DBG_CREATE_PROCESS_FAILURE_LOCKDOWN: HRESULT = 0x80B00001u32 as HRESULT; +pub const ERROR_DBG_ATTACH_PROCESS_FAILURE_LOCKDOWN: HRESULT = 0x80B00002u32 as HRESULT; +pub const ERROR_DBG_CONNECT_SERVER_FAILURE_LOCKDOWN: HRESULT = 0x80B00003u32 as HRESULT; +pub const ERROR_DBG_START_SERVER_FAILURE_LOCKDOWN: HRESULT = 0x80B00004u32 as HRESULT; +pub const ERROR_IO_PREEMPTED: HRESULT = 0x89010001u32 as HRESULT; +pub const JSCRIPT_E_CANTEXECUTE: HRESULT = 0x89020001u32 as HRESULT; +pub const WEP_E_NOT_PROVISIONED_ON_ALL_VOLUMES: HRESULT = 0x88010001u32 as HRESULT; +pub const WEP_E_FIXED_DATA_NOT_SUPPORTED: HRESULT = 0x88010002u32 as HRESULT; +pub const WEP_E_HARDWARE_NOT_COMPLIANT: HRESULT = 0x88010003u32 as HRESULT; +pub const WEP_E_LOCK_NOT_CONFIGURED: HRESULT = 0x88010004u32 as HRESULT; +pub const WEP_E_PROTECTION_SUSPENDED: HRESULT = 0x88010005u32 as HRESULT; +pub const WEP_E_NO_LICENSE: HRESULT = 0x88010006u32 as HRESULT; +pub const WEP_E_OS_NOT_PROTECTED: HRESULT = 0x88010007u32 as HRESULT; +pub const WEP_E_UNEXPECTED_FAIL: HRESULT = 0x88010008u32 as HRESULT; +pub const WEP_E_BUFFER_TOO_LARGE: HRESULT = 0x88010009u32 as HRESULT; +pub const ERROR_SVHDX_ERROR_STORED: HRESULT = 0xC05C0000u32 as HRESULT; +pub const ERROR_SVHDX_ERROR_NOT_AVAILABLE: HRESULT = 0xC05CFF00u32 as HRESULT; +pub const ERROR_SVHDX_UNIT_ATTENTION_AVAILABLE: HRESULT = 0xC05CFF01u32 as HRESULT; +pub const ERROR_SVHDX_UNIT_ATTENTION_CAPACITY_DATA_CHANGED: HRESULT = 0xC05CFF02u32 as HRESULT; +pub const ERROR_SVHDX_UNIT_ATTENTION_RESERVATIONS_PREEMPTED: HRESULT = 0xC05CFF03u32 as HRESULT; +pub const ERROR_SVHDX_UNIT_ATTENTION_RESERVATIONS_RELEASED: HRESULT = 0xC05CFF04u32 as HRESULT; +pub const ERROR_SVHDX_UNIT_ATTENTION_REGISTRATIONS_PREEMPTED: HRESULT = 0xC05CFF05u32 as HRESULT; +pub const ERROR_SVHDX_UNIT_ATTENTION_OPERATING_DEFINITION_CHANGED: HRESULT = 0xC05CFF06u32 as HRESULT; +pub const ERROR_SVHDX_RESERVATION_CONFLICT: HRESULT = 0xC05CFF07u32 as HRESULT; +pub const ERROR_SVHDX_WRONG_FILE_TYPE: HRESULT = 0xC05CFF08u32 as HRESULT; +pub const ERROR_SVHDX_VERSION_MISMATCH: HRESULT = 0xC05CFF09u32 as HRESULT; +pub const ERROR_VHD_SHARED: HRESULT = 0xC05CFF0Au32 as HRESULT; +pub const WININET_E_OUT_OF_HANDLES: HRESULT = 0x80072EE1u32 as HRESULT; +pub const WININET_E_TIMEOUT: HRESULT = 0x80072EE2u32 as HRESULT; +pub const WININET_E_EXTENDED_ERROR: HRESULT = 0x80072EE3u32 as HRESULT; +pub const WININET_E_INTERNAL_ERROR: HRESULT = 0x80072EE4u32 as HRESULT; +pub const WININET_E_INVALID_URL: HRESULT = 0x80072EE5u32 as HRESULT; +pub const WININET_E_UNRECOGNIZED_SCHEME: HRESULT = 0x80072EE6u32 as HRESULT; +pub const WININET_E_NAME_NOT_RESOLVED: HRESULT = 0x80072EE7u32 as HRESULT; +pub const WININET_E_PROTOCOL_NOT_FOUND: HRESULT = 0x80072EE8u32 as HRESULT; +pub const WININET_E_INVALID_OPTION: HRESULT = 0x80072EE9u32 as HRESULT; +pub const WININET_E_BAD_OPTION_LENGTH: HRESULT = 0x80072EEAu32 as HRESULT; +pub const WININET_E_OPTION_NOT_SETTABLE: HRESULT = 0x80072EEBu32 as HRESULT; +pub const WININET_E_SHUTDOWN: HRESULT = 0x80072EECu32 as HRESULT; +pub const WININET_E_INCORRECT_USER_NAME: HRESULT = 0x80072EEDu32 as HRESULT; +pub const WININET_E_INCORRECT_PASSWORD: HRESULT = 0x80072EEEu32 as HRESULT; +pub const WININET_E_LOGIN_FAILURE: HRESULT = 0x80072EEFu32 as HRESULT; +pub const WININET_E_INVALID_OPERATION: HRESULT = 0x80072EF0u32 as HRESULT; +pub const WININET_E_OPERATION_CANCELLED: HRESULT = 0x80072EF1u32 as HRESULT; +pub const WININET_E_INCORRECT_HANDLE_TYPE: HRESULT = 0x80072EF2u32 as HRESULT; +pub const WININET_E_INCORRECT_HANDLE_STATE: HRESULT = 0x80072EF3u32 as HRESULT; +pub const WININET_E_NOT_PROXY_REQUEST: HRESULT = 0x80072EF4u32 as HRESULT; +pub const WININET_E_REGISTRY_VALUE_NOT_FOUND: HRESULT = 0x80072EF5u32 as HRESULT; +pub const WININET_E_BAD_REGISTRY_PARAMETER: HRESULT = 0x80072EF6u32 as HRESULT; +pub const WININET_E_NO_DIRECT_ACCESS: HRESULT = 0x80072EF7u32 as HRESULT; +pub const WININET_E_NO_CONTEXT: HRESULT = 0x80072EF8u32 as HRESULT; +pub const WININET_E_NO_CALLBACK: HRESULT = 0x80072EF9u32 as HRESULT; +pub const WININET_E_REQUEST_PENDING: HRESULT = 0x80072EFAu32 as HRESULT; +pub const WININET_E_INCORRECT_FORMAT: HRESULT = 0x80072EFBu32 as HRESULT; +pub const WININET_E_ITEM_NOT_FOUND: HRESULT = 0x80072EFCu32 as HRESULT; +pub const WININET_E_CANNOT_CONNECT: HRESULT = 0x80072EFDu32 as HRESULT; +pub const WININET_E_CONNECTION_ABORTED: HRESULT = 0x80072EFEu32 as HRESULT; +pub const WININET_E_CONNECTION_RESET: HRESULT = 0x80072EFFu32 as HRESULT; +pub const WININET_E_FORCE_RETRY: HRESULT = 0x80072F00u32 as HRESULT; +pub const WININET_E_INVALID_PROXY_REQUEST: HRESULT = 0x80072F01u32 as HRESULT; +pub const WININET_E_NEED_UI: HRESULT = 0x80072F02u32 as HRESULT; +pub const WININET_E_HANDLE_EXISTS: HRESULT = 0x80072F04u32 as HRESULT; +pub const WININET_E_SEC_CERT_DATE_INVALID: HRESULT = 0x80072F05u32 as HRESULT; +pub const WININET_E_SEC_CERT_CN_INVALID: HRESULT = 0x80072F06u32 as HRESULT; +pub const WININET_E_HTTP_TO_HTTPS_ON_REDIR: HRESULT = 0x80072F07u32 as HRESULT; +pub const WININET_E_HTTPS_TO_HTTP_ON_REDIR: HRESULT = 0x80072F08u32 as HRESULT; +pub const WININET_E_MIXED_SECURITY: HRESULT = 0x80072F09u32 as HRESULT; +pub const WININET_E_CHG_POST_IS_NON_SECURE: HRESULT = 0x80072F0Au32 as HRESULT; +pub const WININET_E_POST_IS_NON_SECURE: HRESULT = 0x80072F0Bu32 as HRESULT; +pub const WININET_E_CLIENT_AUTH_CERT_NEEDED: HRESULT = 0x80072F0Cu32 as HRESULT; +pub const WININET_E_INVALID_CA: HRESULT = 0x80072F0Du32 as HRESULT; +pub const WININET_E_CLIENT_AUTH_NOT_SETUP: HRESULT = 0x80072F0Eu32 as HRESULT; +pub const WININET_E_ASYNC_THREAD_FAILED: HRESULT = 0x80072F0Fu32 as HRESULT; +pub const WININET_E_REDIRECT_SCHEME_CHANGE: HRESULT = 0x80072F10u32 as HRESULT; +pub const WININET_E_DIALOG_PENDING: HRESULT = 0x80072F11u32 as HRESULT; +pub const WININET_E_RETRY_DIALOG: HRESULT = 0x80072F12u32 as HRESULT; +pub const WININET_E_NO_NEW_CONTAINERS: HRESULT = 0x80072F13u32 as HRESULT; +pub const WININET_E_HTTPS_HTTP_SUBMIT_REDIR: HRESULT = 0x80072F14u32 as HRESULT; +pub const WININET_E_SEC_CERT_ERRORS: HRESULT = 0x80072F17u32 as HRESULT; +pub const WININET_E_SEC_CERT_REV_FAILED: HRESULT = 0x80072F19u32 as HRESULT; +pub const WININET_E_HEADER_NOT_FOUND: HRESULT = 0x80072F76u32 as HRESULT; +pub const WININET_E_DOWNLEVEL_SERVER: HRESULT = 0x80072F77u32 as HRESULT; +pub const WININET_E_INVALID_SERVER_RESPONSE: HRESULT = 0x80072F78u32 as HRESULT; +pub const WININET_E_INVALID_HEADER: HRESULT = 0x80072F79u32 as HRESULT; +pub const WININET_E_INVALID_QUERY_REQUEST: HRESULT = 0x80072F7Au32 as HRESULT; +pub const WININET_E_HEADER_ALREADY_EXISTS: HRESULT = 0x80072F7Bu32 as HRESULT; +pub const WININET_E_REDIRECT_FAILED: HRESULT = 0x80072F7Cu32 as HRESULT; +pub const WININET_E_SECURITY_CHANNEL_ERROR: HRESULT = 0x80072F7Du32 as HRESULT; +pub const WININET_E_UNABLE_TO_CACHE_FILE: HRESULT = 0x80072F7Eu32 as HRESULT; +pub const WININET_E_TCPIP_NOT_INSTALLED: HRESULT = 0x80072F7Fu32 as HRESULT; +pub const WININET_E_DISCONNECTED: HRESULT = 0x80072F83u32 as HRESULT; +pub const WININET_E_SERVER_UNREACHABLE: HRESULT = 0x80072F84u32 as HRESULT; +pub const WININET_E_PROXY_SERVER_UNREACHABLE: HRESULT = 0x80072F85u32 as HRESULT; +pub const WININET_E_BAD_AUTO_PROXY_SCRIPT: HRESULT = 0x80072F86u32 as HRESULT; +pub const WININET_E_UNABLE_TO_DOWNLOAD_SCRIPT: HRESULT = 0x80072F87u32 as HRESULT; +pub const WININET_E_SEC_INVALID_CERT: HRESULT = 0x80072F89u32 as HRESULT; +pub const WININET_E_SEC_CERT_REVOKED: HRESULT = 0x80072F8Au32 as HRESULT; +pub const WININET_E_FAILED_DUETOSECURITYCHECK: HRESULT = 0x80072F8Bu32 as HRESULT; +pub const WININET_E_NOT_INITIALIZED: HRESULT = 0x80072F8Cu32 as HRESULT; +pub const WININET_E_LOGIN_FAILURE_DISPLAY_ENTITY_BODY: HRESULT = 0x80072F8Eu32 as HRESULT; +pub const WININET_E_DECODING_FAILED: HRESULT = 0x80072F8Fu32 as HRESULT; +pub const WININET_E_NOT_REDIRECTED: HRESULT = 0x80072F80u32 as HRESULT; +pub const WININET_E_COOKIE_NEEDS_CONFIRMATION: HRESULT = 0x80072F81u32 as HRESULT; +pub const WININET_E_COOKIE_DECLINED: HRESULT = 0x80072F82u32 as HRESULT; +pub const WININET_E_REDIRECT_NEEDS_CONFIRMATION: HRESULT = 0x80072F88u32 as HRESULT; diff --git a/deps/winapi-0.1.23/src/wingdi.rs b/deps/winapi-0.1.23/src/wingdi.rs new file mode 100644 index 000000000..e39d95d2d --- /dev/null +++ b/deps/winapi-0.1.23/src/wingdi.rs @@ -0,0 +1,233 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! GDI procedure declarations, constant definitions and macros +//83 +pub const SRCCOPY: ::DWORD = 0x00CC0020; +pub const SRCPAINT: ::DWORD = 0x00EE0086; +pub const SRCAND: ::DWORD = 0x008800C6; +pub const SRCINVERT: ::DWORD = 0x00660046; +pub const SRCERASE: ::DWORD = 0x00440328; +pub const NOTSRCCOPY: ::DWORD = 0x00330008; +pub const NOTSRCERASE: ::DWORD = 0x001100A6; +pub const MERGECOPY: ::DWORD = 0x00C000CA; +pub const MERGEPAINT: ::DWORD = 0x00BB0226; +pub const PATCOPY: ::DWORD = 0x00F00021; +pub const PATPAINT: ::DWORD = 0x00FB0A09; +pub const PATINVERT: ::DWORD = 0x005A0049; +pub const DSTINVERT: ::DWORD = 0x00550009; +pub const BLACKNESS: ::DWORD = 0x00000042; +pub const WHITENESS: ::DWORD = 0x00FF0062; +//121 +// fnCombineMode values for CombineRgn +pub const RGN_AND: ::c_int = 1; +pub const RGN_OR: ::c_int = 2; +pub const RGN_XOR: ::c_int = 3; +pub const RGN_DIFF: ::c_int = 4; +pub const RGN_COPY: ::c_int = 5; +pub const RGN_MIN: ::c_int = RGN_AND; +pub const RGN_MAX: ::c_int = RGN_COPY; +//572 (Win 7 SDK) +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct BITMAP { + pub bmType: ::LONG, + pub bmWidth: ::LONG, + pub bmHeight: ::LONG, + pub bmWidthBytes: ::LONG, + pub bmPlanes: ::WORD, + pub bmBitsPixel: ::WORD, + pub bmBits: ::LPVOID, +} +pub type PBITMAP = *mut BITMAP; +pub type NPBITMAP = *mut BITMAP; +pub type LPBITMAP = *mut BITMAP; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RGBQUAD { + pub rgbBlue: ::BYTE, + pub rgbGreen: ::BYTE, + pub rgbRed: ::BYTE, + pub rgbReserved: ::BYTE, +} +pub type LPRGBQUAD = *mut RGBQUAD; +pub const CS_ENABLE: ::DWORD = 0x00000001; +pub const CS_DISABLE: ::DWORD = 0x00000002; +pub const CS_DELETE_TRANSFORM: ::DWORD = 0x00000003; +pub const LCS_SIGNATURE: ::DWORD = 0x5053_4F43; // 'PSOC' +pub const LCS_sRGB: LCSCSTYPE = 0x7352_4742; // 'sRGB' +pub const LCS_WINDOWS_COLOR_SPACE: LCSCSTYPE = 0x5769_6E20; // 'Win ' +pub type LCSCSTYPE = ::LONG; +pub const LCS_CALIBRATED_RGB: LCSCSTYPE = 0x00000000; +pub type LCSGAMUTMATCH = ::LONG; +pub const LCS_GM_BUSINESS: LCSGAMUTMATCH = 0x00000001; +pub const LCS_GM_GRAPHICS: LCSGAMUTMATCH = 0x00000002; +pub const LCS_GM_IMAGES: LCSGAMUTMATCH = 0x00000004; +pub const LCS_GM_ABS_COLORIMETRIC: LCSGAMUTMATCH = 0x00000008; +pub const CM_OUT_OF_GAMUT: ::BYTE = 255; +pub const CM_IN_GAMUT: ::BYTE = 0; +pub const ICM_ADDPROFILE: ::UINT = 1; +pub const ICM_DELETEPROFILE: ::UINT = 2; +pub const ICM_QUERYPROFILE: ::UINT = 3; +pub const ICM_SETDEFAULTPROFILE: ::UINT = 4; +pub const ICM_REGISTERICMATCHER: ::UINT = 5; +pub const ICM_UNREGISTERICMATCHER: ::UINT = 6; +pub const ICM_QUERYMATCH: ::UINT = 7; +pub type FXPT16DOT16 = ::c_long; +pub type LPFXPT16DOT16 = *mut ::c_long; +pub type FXPT2DOT30 = ::c_long; +pub type LPFXPT2DOT30 = *mut ::c_long; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CIEXYZ { + pub ciexyzX: FXPT2DOT30, + pub ciexyzY: FXPT2DOT30, + pub ciexyzZ: FXPT2DOT30, +} +pub type LPCIEXYZ = *mut CIEXYZ; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CIEXYZTRIPLE { + pub ciexyzRed: CIEXYZ, + pub ciexyzGreen: CIEXYZ, + pub ciexyzBlue: CIEXYZ, +} +pub type LPCIEXYZTRIPLE = *mut CIEXYZTRIPLE; +//716 (Win 7 SDK) +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct BITMAPINFOHEADER { + pub biSize: ::DWORD, + pub biWidth: ::LONG, + pub biHeight: ::LONG, + pub biPlanes: ::WORD, + pub biBitCount: ::WORD, + pub biCompression: ::DWORD, + pub biSizeImage: ::DWORD, + pub biXPelsPerMeter: ::LONG, + pub biYPelsPerMeter: ::LONG, + pub biClrUsed: ::DWORD, + pub biClrImportant: ::DWORD, +} +pub type LPBITMAPINFOHEADER = *mut BITMAPINFOHEADER; +pub type PBITMAPINFOHEADER = *mut BITMAPINFOHEADER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct BITMAPV5HEADER { + pub bV5Size: ::DWORD, + pub bV5Width: ::LONG, + pub bV5Height: ::LONG, + pub bV5Planes: ::WORD, + pub bV5BitCount: ::WORD, + pub bV5Compression: ::DWORD, + pub bV5SizeImage: ::DWORD, + pub bV5XPelsPerMeter: ::LONG, + pub bV5YPelsPerMeter: ::LONG, + pub bV5ClrUsed: ::DWORD, + pub bV5ClrImportant: ::DWORD, + pub bV5RedMask: ::DWORD, + pub bV5GreenMask: ::DWORD, + pub bV5BlueMask: ::DWORD, + pub bV5AlphaMask: ::DWORD, + pub bV5CSType: ::LONG, // LONG to match LOGCOLORSPACE + pub bV5Endpoints: CIEXYZTRIPLE, + pub bV5GammaRed: ::DWORD, + pub bV5GammaGreen: ::DWORD, + pub bV5GammaBlue: ::DWORD, + pub bV5Intent: ::LONG, // LONG to match LOGCOLORSPACE + pub bV5ProfileData: ::DWORD, + pub bV5ProfileSize: ::DWORD, + pub bV5Reserved: ::DWORD, +} +pub type LPBITMAPV5HEADER = *mut BITMAPV5HEADER; +pub type PBITMAPV5HEADER = *mut BITMAPV5HEADER; +pub const PROFILE_LINKED: ::LONG = 0x4C49_4E4B; // 'LINK' +pub const PROFILE_EMBEDDED: ::LONG = 0x4D42_4544; // 'MBED' +pub const BI_RGB: ::DWORD = 0; +pub const BI_RLE8: ::DWORD = 1; +pub const BI_RLE4: ::DWORD = 2; +pub const BI_BITFIELDS: ::DWORD = 3; +pub const BI_JPEG: ::DWORD = 4; +pub const BI_PNG: ::DWORD = 5; +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct BITMAPINFO { + pub bmiHeader: BITMAPINFOHEADER, + pub bmiColors: [RGBQUAD; 0], +} +pub type LPBITMAPINFO = *mut BITMAPINFO; +pub type PBITMAPINFO = *mut BITMAPINFO; +//1438 +pub const LF_FACESIZE: usize = 32; + +#[repr(C)] #[derive(Copy, Clone)] +pub struct LOGFONTA { + pub lfHeight: ::LONG, + pub lfWidth: ::LONG, + pub lfEscapement: ::LONG, + pub lfOrientation: ::LONG, + pub lfWeight: ::LONG, + pub lfItalic: ::BYTE, + pub lfUnderline: ::BYTE, + pub lfStrikeOut: ::BYTE, + pub lfCharSet: ::BYTE, + pub lfOutPrecision: ::BYTE, + pub lfClipPrecision: ::BYTE, + pub lfQuality: ::BYTE, + pub lfPitchAndFamily: ::BYTE, + pub lfFaceName: [::CHAR; LF_FACESIZE], +} +pub type LPLOGFONTA = *mut LOGFONTA; + +#[repr(C)] #[derive(Copy, Clone)] +pub struct LOGFONTW { + pub lfHeight: ::LONG, + pub lfWidth: ::LONG, + pub lfEscapement: ::LONG, + pub lfOrientation: ::LONG, + pub lfWeight: ::LONG, + pub lfItalic: ::BYTE, + pub lfUnderline: ::BYTE, + pub lfStrikeOut: ::BYTE, + pub lfCharSet: ::BYTE, + pub lfOutPrecision: ::BYTE, + pub lfClipPrecision: ::BYTE, + pub lfQuality: ::BYTE, + pub lfPitchAndFamily: ::BYTE, + pub lfFaceName: [::WCHAR; LF_FACESIZE], +} +pub type LPLOGFONTW = *mut LOGFONTW; + +//1595 +#[inline] +pub fn RGB (r: ::BYTE, g: ::BYTE, b: ::BYTE) -> ::COLORREF { + r as ::COLORREF | ((g as ::COLORREF) << 8) | ((b as ::COLORREF) << 16) +} +//1906 (Win 7 SDK) +pub const DIB_RGB_COLORS: ::UINT = 0; +pub const DIB_PAL_COLORS: ::UINT = 1; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RGNDATAHEADER { + pub dwSize: ::DWORD, + pub iType: ::DWORD, + pub nCount: ::DWORD, + pub nRgnSize: ::DWORD, + pub rcBound: ::RECT, +} +pub type PRGNDATAHEADER = *mut RGNDATAHEADER; +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct RGNDATA { + pub rdh: RGNDATAHEADER, + pub Buffer: [::c_char; 0], +} +pub type PRGNDATA = *mut RGNDATA; +pub type NPRGNDATA = *mut RGNDATA; +pub type LPRGNDATA = *mut RGNDATA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PALETTEENTRY { + pub peRed: ::BYTE, + pub peGreen: ::BYTE, + pub peBlue: ::BYTE, + pub peFlags: ::BYTE +} + +//3581 +pub type LINEDDAPROC = Option<unsafe extern "system" fn(::c_int, ::c_int, ::LPARAM)>; + +pub const COINIT_APARTMENTTHREADED: ::DWORD = 0x2; +pub const COINIT_MULTITHREADED: ::DWORD = 0x0; +pub const COINIT_DISABLE_OLE1DDE: ::DWORD = 0x4; +pub const COINIT_SPEED_OVER_MEMORY: ::DWORD = 0x8; diff --git a/deps/winapi-0.1.23/src/winioctl.rs b/deps/winapi-0.1.23/src/winioctl.rs new file mode 100644 index 000000000..24c4c568c --- /dev/null +++ b/deps/winapi-0.1.23/src/winioctl.rs @@ -0,0 +1,244 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! This module defines the 32-Bit Windows Device I/O control codes. +//123 +pub const FILE_DEVICE_BEEP: ::DWORD = 0x00000001; +pub const FILE_DEVICE_CD_ROM: ::DWORD = 0x00000002; +pub const FILE_DEVICE_CD_ROM_FILE_SYSTEM: ::DWORD = 0x00000003; +pub const FILE_DEVICE_CONTROLLER: ::DWORD = 0x00000004; +pub const FILE_DEVICE_DATALINK: ::DWORD = 0x00000005; +pub const FILE_DEVICE_DFS: ::DWORD = 0x00000006; +pub const FILE_DEVICE_DISK: ::DWORD = 0x00000007; +pub const FILE_DEVICE_DISK_FILE_SYSTEM: ::DWORD = 0x00000008; +pub const FILE_DEVICE_FILE_SYSTEM: ::DWORD = 0x00000009; +pub const FILE_DEVICE_INPORT_PORT: ::DWORD = 0x0000000a; +pub const FILE_DEVICE_KEYBOARD: ::DWORD = 0x0000000b; +pub const FILE_DEVICE_MAILSLOT: ::DWORD = 0x0000000c; +pub const FILE_DEVICE_MIDI_IN: ::DWORD = 0x0000000d; +pub const FILE_DEVICE_MIDI_OUT: ::DWORD = 0x0000000e; +pub const FILE_DEVICE_MOUSE: ::DWORD = 0x0000000f; +pub const FILE_DEVICE_MULTI_UNC_PROVIDER: ::DWORD = 0x00000010; +pub const FILE_DEVICE_NAMED_PIPE: ::DWORD = 0x00000011; +pub const FILE_DEVICE_NETWORK: ::DWORD = 0x00000012; +pub const FILE_DEVICE_NETWORK_BROWSER: ::DWORD = 0x00000013; +pub const FILE_DEVICE_NETWORK_FILE_SYSTEM: ::DWORD = 0x00000014; +pub const FILE_DEVICE_NULL: ::DWORD = 0x00000015; +pub const FILE_DEVICE_PARALLEL_PORT: ::DWORD = 0x00000016; +pub const FILE_DEVICE_PHYSICAL_NETCARD: ::DWORD = 0x00000017; +pub const FILE_DEVICE_PRINTER: ::DWORD = 0x00000018; +pub const FILE_DEVICE_SCANNER: ::DWORD = 0x00000019; +pub const FILE_DEVICE_SERIAL_MOUSE_PORT: ::DWORD = 0x0000001a; +pub const FILE_DEVICE_SERIAL_PORT: ::DWORD = 0x0000001b; +pub const FILE_DEVICE_SCREEN: ::DWORD = 0x0000001c; +pub const FILE_DEVICE_SOUND: ::DWORD = 0x0000001d; +pub const FILE_DEVICE_STREAMS: ::DWORD = 0x0000001e; +pub const FILE_DEVICE_TAPE: ::DWORD = 0x0000001f; +pub const FILE_DEVICE_TAPE_FILE_SYSTEM: ::DWORD = 0x00000020; +pub const FILE_DEVICE_TRANSPORT: ::DWORD = 0x00000021; +pub const FILE_DEVICE_UNKNOWN: ::DWORD = 0x00000022; +pub const FILE_DEVICE_VIDEO: ::DWORD = 0x00000023; +pub const FILE_DEVICE_VIRTUAL_DISK: ::DWORD = 0x00000024; +pub const FILE_DEVICE_WAVE_IN: ::DWORD = 0x00000025; +pub const FILE_DEVICE_WAVE_OUT: ::DWORD = 0x00000026; +pub const FILE_DEVICE_8042_PORT: ::DWORD = 0x00000027; +pub const FILE_DEVICE_NETWORK_REDIRECTOR: ::DWORD = 0x00000028; +pub const FILE_DEVICE_BATTERY: ::DWORD = 0x00000029; +pub const FILE_DEVICE_BUS_EXTENDER: ::DWORD = 0x0000002a; +pub const FILE_DEVICE_MODEM: ::DWORD = 0x0000002b; +pub const FILE_DEVICE_VDM: ::DWORD = 0x0000002c; +pub const FILE_DEVICE_MASS_STORAGE: ::DWORD = 0x0000002d; +pub const FILE_DEVICE_SMB: ::DWORD = 0x0000002e; +pub const FILE_DEVICE_KS: ::DWORD = 0x0000002f; +pub const FILE_DEVICE_CHANGER: ::DWORD = 0x00000030; +pub const FILE_DEVICE_SMARTCARD: ::DWORD = 0x00000031; +pub const FILE_DEVICE_ACPI: ::DWORD = 0x00000032; +pub const FILE_DEVICE_DVD: ::DWORD = 0x00000033; +pub const FILE_DEVICE_FULLSCREEN_VIDEO: ::DWORD = 0x00000034; +pub const FILE_DEVICE_DFS_FILE_SYSTEM: ::DWORD = 0x00000035; +pub const FILE_DEVICE_DFS_VOLUME: ::DWORD = 0x00000036; +pub const FILE_DEVICE_SERENUM: ::DWORD = 0x00000037; +pub const FILE_DEVICE_TERMSRV: ::DWORD = 0x00000038; +pub const FILE_DEVICE_KSEC: ::DWORD = 0x00000039; +pub const FILE_DEVICE_FIPS: ::DWORD = 0x0000003A; +pub const FILE_DEVICE_INFINIBAND: ::DWORD = 0x0000003B; +pub const FILE_DEVICE_VMBUS: ::DWORD = 0x0000003E; +pub const FILE_DEVICE_CRYPT_PROVIDER: ::DWORD = 0x0000003F; +pub const FILE_DEVICE_WPD: ::DWORD = 0x00000040; +pub const FILE_DEVICE_BLUETOOTH: ::DWORD = 0x00000041; +pub const FILE_DEVICE_MT_COMPOSITE: ::DWORD = 0x00000042; +pub const FILE_DEVICE_MT_TRANSPORT: ::DWORD = 0x00000043; +pub const FILE_DEVICE_BIOMETRIC: ::DWORD = 0x00000044; +pub const FILE_DEVICE_PMI: ::DWORD = 0x00000045; +pub const FILE_DEVICE_EHSTOR: ::DWORD = 0x00000046; +pub const FILE_DEVICE_DEVAPI: ::DWORD = 0x00000047; +pub const FILE_DEVICE_GPIO: ::DWORD = 0x00000048; +pub const FILE_DEVICE_USBEX: ::DWORD = 0x00000049; +pub const FILE_DEVICE_CONSOLE: ::DWORD = 0x00000050; +pub const FILE_DEVICE_NFP: ::DWORD = 0x00000051; +pub const FILE_DEVICE_SYSENV: ::DWORD = 0x00000052; +pub const FILE_DEVICE_VIRTUAL_BLOCK: ::DWORD = 0x00000053; +pub const FILE_DEVICE_POINT_OF_SERVICE: ::DWORD = 0x00000054; +//224 +pub const METHOD_BUFFERED: ::DWORD = 0; +pub const METHOD_IN_DIRECT: ::DWORD = 1; +pub const METHOD_OUT_DIRECT: ::DWORD = 2; +pub const METHOD_NEITHER: ::DWORD = 3; +//253 +pub const FILE_ANY_ACCESS: ::DWORD = 0; +pub const FILE_SPECIAL_ACCESS: ::DWORD = FILE_ANY_ACCESS; +pub const FILE_READ_ACCESS: ::DWORD = 0x0001; +pub const FILE_WRITE_ACCESS: ::DWORD = 0x0002; +//4690 +pub const FSCTL_REQUEST_OPLOCK_LEVEL_1: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_OPLOCK_LEVEL_2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_BATCH_OPLOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OPLOCK_BREAK_ACKNOWLEDGE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OPBATCH_ACK_CLOSE_PENDING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OPLOCK_BREAK_NOTIFY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_LOCK_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_UNLOCK_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DISMOUNT_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_VOLUME_MOUNTED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_PATHNAME_VALID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_MARK_VOLUME_DIRTY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_RETRIEVAL_POINTERS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_GET_COMPRESSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_COMPRESSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); +pub const FSCTL_SET_BOOTLOADER_ACCESSED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_MARK_AS_SYSTEM_HIVE: ::DWORD = FSCTL_SET_BOOTLOADER_ACCESSED; +pub const FSCTL_OPLOCK_BREAK_ACK_NO_2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_INVALIDATE_VOLUMES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_FAT_BPB: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_FILTER_OPLOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_FILESYSTEM_GET_STATISTICS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_NTFS_VOLUME_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_NTFS_FILE_RECORD: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_VOLUME_BITMAP: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_GET_RETRIEVAL_POINTERS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_MOVE_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_IS_VOLUME_DIRTY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_ALLOW_EXTENDED_DASD_IO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_FIND_FILES_BY_SID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_SET_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_GET_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_REPARSE_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_GET_REPARSE_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_REPARSE_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_ENUM_USN_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_SECURITY_ID_CHECK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, ::FILE_READ_DATA); +pub const FSCTL_READ_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_SET_OBJECT_ID_EXTENDED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_CREATE_OR_GET_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_SPARSE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_ZERO_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_QUERY_ALLOCATED_RANGES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, ::FILE_READ_DATA); +pub const FSCTL_ENABLE_UPGRADE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_SET_ENCRYPTION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_ENCRYPTION_FSCTL_IO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_WRITE_RAW_ENCRYPTED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS); +pub const FSCTL_READ_RAW_ENCRYPTED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS); +pub const FSCTL_CREATE_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_READ_FILE_USN_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_WRITE_USN_CLOSE_RECORD: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_EXTEND_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_MARK_HANDLE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SIS_COPYFILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SIS_LINK_FILES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); +pub const FSCTL_RECALL_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_READ_FROM_PLEX: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, ::FILE_READ_DATA); +pub const FSCTL_FILE_PREFETCH: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_MAKE_MEDIA_COMPATIBLE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_SET_DEFECT_MANAGEMENT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_QUERY_SPARING_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_ON_DISK_VOLUME_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_VOLUME_COMPRESSION_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_TXFS_MODIFY_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_QUERY_RM_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_TXFS_ROLLFORWARD_REDO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_ROLLFORWARD_UNDO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_START_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_SHUTDOWN_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_READ_BACKUP_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_TXFS_WRITE_BACKUP_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_CREATE_SECONDARY_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_GET_METADATA_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_TXFS_GET_TRANSACTED_VERSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_TXFS_SAVEPOINT_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_CREATE_MINIVERSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_TXFS_TRANSACTION_ACTIVE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_SET_ZERO_ON_DEALLOCATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_WAIT_FOR_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_INITIATE_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSC_INTERNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_SHRINK_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_SHORT_NAME_BEHAVIOR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DFSR_SET_GHOST_HANDLE_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_TXFS_LIST_TRANSACTIONS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, ::FILE_READ_DATA); +pub const FSCTL_QUERY_PAGEFILE_ENCRYPTION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_RESET_VOLUME_ALLOCATION_HINTS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_DEPENDENT_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SD_GLOBAL_CHANGE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_TXFS_READ_BACKUP_INFORMATION2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_LOOKUP_STREAM_FROM_CLUSTER: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_TXFS_WRITE_BACKUP_INFORMATION2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_FILE_TYPE_NOTIFICATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_FILE_LEVEL_TRIM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_GET_BOOT_AREA_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_RETRIEVAL_POINTER_BASE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_PERSISTENT_VOLUME_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_PERSISTENT_VOLUME_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_OPLOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_CSV_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_FILE_SYSTEM_RECOGNITION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_GET_VOLUME_PATH_NAME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 150, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_FILE_ON_CSV_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 151, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CORRUPTION_HANDLING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OFFLOAD_READ: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS); +pub const FSCTL_OFFLOAD_WRITE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS); +pub const FSCTL_CSV_INTERNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 155, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_PURGE_FAILURE_MODE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_FILE_LAYOUT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_IS_VOLUME_OWNED_BYCSVFS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 158, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_INTEGRITY_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_INTEGRITY_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); +pub const FSCTL_QUERY_FILE_REGIONS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DEDUP_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DEDUP_QUERY_FILE_HASHES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 166, METHOD_NEITHER, ::FILE_READ_DATA); +pub const FSCTL_DEDUP_QUERY_RANGE_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 167, METHOD_NEITHER, ::FILE_READ_DATA); +pub const FSCTL_DEDUP_QUERY_REPARSE_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 168, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_RKF_INTERNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_SCRUB_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REPAIR_COPIES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); +pub const FSCTL_DISABLE_LOCAL_BUFFERING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_MGMT_LOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_ADVANCE_FILE_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_SYNC_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_WRITE_USN_REASON: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_CONTROL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_REFS_VOLUME_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_H_BREAKING_SYNC_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 185, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_STORAGE_CLASSES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 187, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_REGION_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 188, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_USN_TRACK_MODIFIED_RANGES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 189, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 192, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SVHDX_SYNC_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 193, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SVHDX_SET_INITIATOR_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 194, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 195, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_GET_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 196, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 197, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_ENUM_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 198, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_ENUM_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 199, METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_ADD_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 204, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_REMOVE_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 205, METHOD_BUFFERED, ::FILE_WRITE_DATA); +pub const FSCTL_UPDATE_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 206, METHOD_BUFFERED, ::FILE_WRITE_DATA); diff --git a/deps/winapi-0.1.23/src/winnetwk.rs b/deps/winapi-0.1.23/src/winnetwk.rs new file mode 100644 index 000000000..8cc62033a --- /dev/null +++ b/deps/winapi-0.1.23/src/winnetwk.rs @@ -0,0 +1,320 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Standard WINNET Header File for WIN32 + +pub const WNNC_NET_MSNET: ::DWORD = 0x00010000; +pub const WNNC_NET_SMB: ::DWORD = 0x00020000; +pub const WNNC_NET_NETWARE: ::DWORD = 0x00030000; +pub const WNNC_NET_VINES: ::DWORD = 0x00040000; +pub const WNNC_NET_10NET: ::DWORD = 0x00050000; +pub const WNNC_NET_LOCUS: ::DWORD = 0x00060000; +pub const WNNC_NET_SUN_PC_NFS: ::DWORD = 0x00070000; +pub const WNNC_NET_LANSTEP: ::DWORD = 0x00080000; +pub const WNNC_NET_9TILES: ::DWORD = 0x00090000; +pub const WNNC_NET_LANTASTIC: ::DWORD = 0x000A0000; +pub const WNNC_NET_AS400: ::DWORD = 0x000B0000; +pub const WNNC_NET_FTP_NFS: ::DWORD = 0x000C0000; +pub const WNNC_NET_PATHWORKS: ::DWORD = 0x000D0000; +pub const WNNC_NET_LIFENET: ::DWORD = 0x000E0000; +pub const WNNC_NET_POWERLAN: ::DWORD = 0x000F0000; +pub const WNNC_NET_BWNFS: ::DWORD = 0x00100000; +pub const WNNC_NET_COGENT: ::DWORD = 0x00110000; +pub const WNNC_NET_FARALLON: ::DWORD = 0x00120000; +pub const WNNC_NET_APPLETALK: ::DWORD = 0x00130000; +pub const WNNC_NET_INTERGRAPH: ::DWORD = 0x00140000; +pub const WNNC_NET_SYMFONET: ::DWORD = 0x00150000; +pub const WNNC_NET_CLEARCASE: ::DWORD = 0x00160000; +pub const WNNC_NET_FRONTIER: ::DWORD = 0x00170000; +pub const WNNC_NET_BMC: ::DWORD = 0x00180000; +pub const WNNC_NET_DCE: ::DWORD = 0x00190000; +pub const WNNC_NET_AVID: ::DWORD = 0x001A0000; +pub const WNNC_NET_DOCUSPACE: ::DWORD = 0x001B0000; +pub const WNNC_NET_MANGOSOFT: ::DWORD = 0x001C0000; +pub const WNNC_NET_SERNET: ::DWORD = 0x001D0000; +pub const WNNC_NET_RIVERFRONT1: ::DWORD = 0x001E0000; +pub const WNNC_NET_RIVERFRONT2: ::DWORD = 0x001F0000; +pub const WNNC_NET_DECORB: ::DWORD = 0x00200000; +pub const WNNC_NET_PROTSTOR: ::DWORD = 0x00210000; +pub const WNNC_NET_FJ_REDIR: ::DWORD = 0x00220000; +pub const WNNC_NET_DISTINCT: ::DWORD = 0x00230000; +pub const WNNC_NET_TWINS: ::DWORD = 0x00240000; +pub const WNNC_NET_RDR2SAMPLE: ::DWORD = 0x00250000; +pub const WNNC_NET_CSC: ::DWORD = 0x00260000; +pub const WNNC_NET_3IN1: ::DWORD = 0x00270000; +pub const WNNC_NET_EXTENDNET: ::DWORD = 0x00290000; +pub const WNNC_NET_STAC: ::DWORD = 0x002A0000; +pub const WNNC_NET_FOXBAT: ::DWORD = 0x002B0000; +pub const WNNC_NET_YAHOO: ::DWORD = 0x002C0000; +pub const WNNC_NET_EXIFS: ::DWORD = 0x002D0000; +pub const WNNC_NET_DAV: ::DWORD = 0x002E0000; +pub const WNNC_NET_KNOWARE: ::DWORD = 0x002F0000; +pub const WNNC_NET_OBJECT_DIRE: ::DWORD = 0x00300000; +pub const WNNC_NET_MASFAX: ::DWORD = 0x00310000; +pub const WNNC_NET_HOB_NFS: ::DWORD = 0x00320000; +pub const WNNC_NET_SHIVA: ::DWORD = 0x00330000; +pub const WNNC_NET_IBMAL: ::DWORD = 0x00340000; +pub const WNNC_NET_LOCK: ::DWORD = 0x00350000; +pub const WNNC_NET_TERMSRV: ::DWORD = 0x00360000; +pub const WNNC_NET_SRT: ::DWORD = 0x00370000; +pub const WNNC_NET_QUINCY: ::DWORD = 0x00380000; +pub const WNNC_NET_OPENAFS: ::DWORD = 0x00390000; +pub const WNNC_NET_AVID1: ::DWORD = 0x003A0000; +pub const WNNC_NET_DFS: ::DWORD = 0x003B0000; +pub const WNNC_NET_KWNP: ::DWORD = 0x003C0000; +pub const WNNC_NET_ZENWORKS: ::DWORD = 0x003D0000; +pub const WNNC_NET_DRIVEONWEB: ::DWORD = 0x003E0000; +pub const WNNC_NET_VMWARE: ::DWORD = 0x003F0000; +pub const WNNC_NET_RSFX: ::DWORD = 0x00400000; +pub const WNNC_NET_MFILES: ::DWORD = 0x00410000; +pub const WNNC_NET_MS_NFS: ::DWORD = 0x00420000; +pub const WNNC_NET_GOOGLE: ::DWORD = 0x00430000; +pub const WNNC_NET_NDFS: ::DWORD = 0x00440000; +pub const WNNC_NET_DOCUSHARE: ::DWORD = 0x00450000; + +pub const WNNC_CRED_MANAGER: ::DWORD = 0xFFFF0000; + +pub const WNNC_NET_LANMAN: ::DWORD = WNNC_NET_SMB; + + +pub const RESOURCE_CONNECTED: ::DWORD = 0x00000001; +pub const RESOURCE_GLOBALNET: ::DWORD = 0x00000002; +pub const RESOURCE_REMEMBERED: ::DWORD = 0x00000003; +pub const RESOURCE_RECENT: ::DWORD = 0x00000004; +pub const RESOURCE_CONTEXT: ::DWORD = 0x00000005; + +pub const RESOURCETYPE_ANY: ::DWORD = 0x00000000; +pub const RESOURCETYPE_DISK: ::DWORD = 0x00000001; +pub const RESOURCETYPE_PRINT: ::DWORD = 0x00000002; +pub const RESOURCETYPE_RESERVED: ::DWORD = 0x00000008; +pub const RESOURCETYPE_UNKNOWN: ::DWORD = 0xFFFFFFFF; + +pub const RESOURCEUSAGE_CONNECTABLE: ::DWORD = 0x00000001; +pub const RESOURCEUSAGE_CONTAINER: ::DWORD = 0x00000002; +pub const RESOURCEUSAGE_NOLOCALDEVICE: ::DWORD = 0x00000004; +pub const RESOURCEUSAGE_SIBLING: ::DWORD = 0x00000008; +pub const RESOURCEUSAGE_ATTACHED: ::DWORD = 0x00000010; +pub const RESOURCEUSAGE_ALL: ::DWORD = RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER + | RESOURCEUSAGE_ATTACHED; +pub const RESOURCEUSAGE_RESERVED: ::DWORD = 0x80000000; + +pub const RESOURCEDISPLAYTYPE_GENERIC: ::DWORD = 0x00000000; +pub const RESOURCEDISPLAYTYPE_DOMAIN: ::DWORD = 0x00000001; +pub const RESOURCEDISPLAYTYPE_SERVER: ::DWORD = 0x00000002; +pub const RESOURCEDISPLAYTYPE_SHARE: ::DWORD = 0x00000003; +pub const RESOURCEDISPLAYTYPE_FILE: ::DWORD = 0x00000004; +pub const RESOURCEDISPLAYTYPE_GROUP: ::DWORD = 0x00000005; +pub const RESOURCEDISPLAYTYPE_NETWORK: ::DWORD = 0x00000006; +pub const RESOURCEDISPLAYTYPE_ROOT: ::DWORD = 0x00000007; +pub const RESOURCEDISPLAYTYPE_SHAREADMIN: ::DWORD = 0x00000008; +pub const RESOURCEDISPLAYTYPE_DIRECTORY: ::DWORD = 0x00000009; +pub const RESOURCEDISPLAYTYPE_TREE: ::DWORD = 0x0000000A; +pub const RESOURCEDISPLAYTYPE_NDSCONTAINER: ::DWORD = 0x0000000B; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct NETRESOURCEA { + pub dwScope: ::DWORD, + pub dwType: ::DWORD, + pub dwDisplayType: ::DWORD, + pub dwUsage: ::DWORD, + pub lpLocalName: ::LPSTR, + pub lpRemoteName: ::LPSTR, + pub lpComment: ::LPSTR, + pub lpProvider: ::LPSTR, +} +pub type LPNETRESOURCEA = *mut NETRESOURCEA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct NETRESOURCEW { + pub dwScope: ::DWORD, + pub dwType: ::DWORD, + pub dwDisplayType: ::DWORD, + pub dwUsage: ::DWORD, + pub lpLocalName: ::LPWSTR, + pub lpRemoteName: ::LPWSTR, + pub lpComment: ::LPWSTR, + pub lpProvider: ::LPWSTR, +} +pub type LPNETRESOURCEW = *mut NETRESOURCEW; + +pub const NETPROPERTY_PERSISTENT: ::DWORD = 1; + +pub const CONNECT_UPDATE_PROFILE: ::DWORD = 0x00000001; +pub const CONNECT_UPDATE_RECENT: ::DWORD = 0x00000002; +pub const CONNECT_TEMPORARY: ::DWORD = 0x00000004; +pub const CONNECT_INTERACTIVE: ::DWORD = 0x00000008; +pub const CONNECT_PROMPT: ::DWORD = 0x00000010; +pub const CONNECT_NEED_DRIVE: ::DWORD = 0x00000020; +pub const CONNECT_REFCOUNT: ::DWORD = 0x00000040; +pub const CONNECT_REDIRECT: ::DWORD = 0x00000080; +pub const CONNECT_LOCALDRIVE: ::DWORD = 0x00000100; +pub const CONNECT_CURRENT_MEDIA: ::DWORD = 0x00000200; +pub const CONNECT_DEFERRED: ::DWORD = 0x00000400; +pub const CONNECT_RESERVED: ::DWORD = 0xFF000000; +pub const CONNECT_COMMANDLINE: ::DWORD = 0x00000800; +pub const CONNECT_CMD_SAVECRED: ::DWORD = 0x00001000; +pub const CONNECT_CRED_RESET: ::DWORD = 0x00002000; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONNECTDLGSTRUCTA { + pub cbStructure: ::DWORD, + pub hwndOwner: ::HWND, + pub lpConnRes: ::LPNETRESOURCEA, + pub dwFlags: ::DWORD, + pub dwDevNum: ::DWORD, +} +pub type LPCONNECTDLGSTRUCTA = *mut CONNECTDLGSTRUCTA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CONNECTDLGSTRUCTW { + pub cbStructure: ::DWORD, + pub hwndOwner: ::HWND, + pub lpConnRes: ::LPNETRESOURCEW, + pub dwFlags: ::DWORD, + pub dwDevNum: ::DWORD, +} +pub type LPCONNECTDLGSTRUCTW = *mut CONNECTDLGSTRUCTW; + +pub const CONNDLG_RO_PATH: ::DWORD = 0x00000001; +pub const CONNDLG_CONN_POINT: ::DWORD = 0x00000002; +pub const CONNDLG_USE_MRU: ::DWORD = 0x00000004; +pub const CONNDLG_HIDE_BOX: ::DWORD = 0x00000008; + +pub const CONNDLG_PERSIST: ::DWORD = 0x00000010; +pub const CONNDLG_NOT_PERSIST: ::DWORD = 0x00000020; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DISCDLGSTRUCTA { + pub cbStructure: ::DWORD, + pub hwndOwner: ::HWND, + pub lpLocalName: ::LPSTR, + pub lpRemoteName: ::LPSTR, + pub dwFlags: ::DWORD, +} +pub type LPDISCDLGSTRUCTA = *mut DISCDLGSTRUCTA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct DISCDLGSTRUCTW { + pub cbStructure: ::DWORD, + pub hwndOwner: ::HWND, + pub lpLocalName: ::LPWSTR, + pub lpRemoteName: ::LPWSTR, + pub dwFlags: ::DWORD, +} +pub type LPDISCDLGSTRUCTW = *mut DISCDLGSTRUCTW; + +pub const DISC_UPDATE_PROFILE: ::DWORD = 0x00000001; +pub const DISC_NO_FORCE: ::DWORD = 0x00000040; + +pub const UNIVERSAL_NAME_INFO_LEVEL: ::DWORD = 0x00000001; +pub const REMOTE_NAME_INFO_LEVEL: ::DWORD = 0x00000002; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct UNIVERSAL_NAME_INFOA { + pub lpUniversalName: ::LPSTR, +} +pub type LPUNIVERSAL_NAME_INFOA = *mut UNIVERSAL_NAME_INFOA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct UNIVERSAL_NAME_INFOW { + pub lpUniversalName: ::LPWSTR, +} +pub type LPUNIVERSAL_NAME_INFOW = *mut UNIVERSAL_NAME_INFOW; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct REMOTE_NAME_INFOA { + pub lpUniversalName: ::LPSTR, + pub lpConnectionName: ::LPSTR, + pub lpRemainingPath: ::LPSTR, +} +pub type LPREMOTE_NAME_INFOA = *mut REMOTE_NAME_INFOA; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct REMOTE_NAME_INFOW { + pub lpUniversalName: ::LPWSTR, + pub lpConnectionName: ::LPWSTR, + pub lpRemainingPath: ::LPWSTR, +} +pub type LPREMOTE_NAME_INFOW = *mut REMOTE_NAME_INFOW; + +pub const WNFMT_MULTILINE: ::DWORD = 0x01; +pub const WNFMT_ABBREVIATED: ::DWORD = 0x02; +pub const WNFMT_INENUM: ::DWORD = 0x10; +pub const WNFMT_CONNECTION: ::DWORD = 0x20; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct NETINFOSTRUCT { + pub cbStructure: ::DWORD, + pub dwProviderVersion: ::DWORD, + pub dwStatus: ::DWORD, + pub dwCharacteristics: ::DWORD, + pub dwHandle: ::ULONG_PTR, + pub wNetType: ::WORD, + pub dwPrinters: ::DWORD, + pub dwDrives: ::DWORD, +} +pub type LPNETINFOSTRUCT = *mut NETINFOSTRUCT; + +pub const NETINFO_DLL16: ::DWORD = 0x00000001; +pub const NETINFO_DISKRED: ::DWORD = 0x00000004; +pub const NETINFO_PRINTERRED: ::DWORD = 0x00000008; + +pub const WN_SUCCESS: ::DWORD = ::NO_ERROR; +pub const WN_NO_ERROR: ::DWORD = ::NO_ERROR; +pub const WN_NOT_SUPPORTED: ::DWORD = ::ERROR_NOT_SUPPORTED; +pub const WN_CANCEL: ::DWORD = ::ERROR_CANCELLED; +pub const WN_RETRY: ::DWORD = ::ERROR_RETRY; +pub const WN_NET_ERROR: ::DWORD = ::ERROR_UNEXP_NET_ERR; +pub const WN_MORE_DATA: ::DWORD = ::ERROR_MORE_DATA; +pub const WN_BAD_POINTER: ::DWORD = ::ERROR_INVALID_ADDRESS; +pub const WN_BAD_VALUE: ::DWORD = ::ERROR_INVALID_PARAMETER; +pub const WN_BAD_USER: ::DWORD = ::ERROR_BAD_USERNAME; +pub const WN_BAD_PASSWORD: ::DWORD = ::ERROR_INVALID_PASSWORD; +pub const WN_ACCESS_DENIED: ::DWORD = ::ERROR_ACCESS_DENIED; +pub const WN_FUNCTION_BUSY: ::DWORD = ::ERROR_BUSY; +pub const WN_WINDOWS_ERROR: ::DWORD = ::ERROR_UNEXP_NET_ERR; +pub const WN_OUT_OF_MEMORY: ::DWORD = ::ERROR_NOT_ENOUGH_MEMORY; +pub const WN_NO_NETWORK: ::DWORD = ::ERROR_NO_NETWORK; +pub const WN_EXTENDED_ERROR: ::DWORD = ::ERROR_EXTENDED_ERROR; +pub const WN_BAD_LEVEL: ::DWORD = ::ERROR_INVALID_LEVEL; +pub const WN_BAD_HANDLE: ::DWORD = ::ERROR_INVALID_HANDLE; +pub const WN_NOT_INITIALIZING: ::DWORD = ::ERROR_ALREADY_INITIALIZED; +pub const WN_NO_MORE_DEVICES: ::DWORD = ::ERROR_NO_MORE_DEVICES; + +pub const WN_NOT_CONNECTED: ::DWORD = ::ERROR_NOT_CONNECTED; +pub const WN_OPEN_FILES: ::DWORD = ::ERROR_OPEN_FILES; +pub const WN_DEVICE_IN_USE: ::DWORD = ::ERROR_DEVICE_IN_USE; +pub const WN_BAD_NETNAME: ::DWORD = ::ERROR_BAD_NET_NAME; +pub const WN_BAD_LOCALNAME: ::DWORD = ::ERROR_BAD_DEVICE; +pub const WN_ALREADY_CONNECTED: ::DWORD = ::ERROR_ALREADY_ASSIGNED; +pub const WN_DEVICE_ERROR: ::DWORD = ::ERROR_GEN_FAILURE; +pub const WN_CONNECTION_CLOSED: ::DWORD = ::ERROR_CONNECTION_UNAVAIL; +pub const WN_NO_NET_OR_BAD_PATH: ::DWORD = ::ERROR_NO_NET_OR_BAD_PATH; +pub const WN_BAD_PROVIDER: ::DWORD = ::ERROR_BAD_PROVIDER; +pub const WN_CANNOT_OPEN_PROFILE: ::DWORD = ::ERROR_CANNOT_OPEN_PROFILE; +pub const WN_BAD_PROFILE: ::DWORD = ::ERROR_BAD_PROFILE; +pub const WN_BAD_DEV_TYPE: ::DWORD = ::ERROR_BAD_DEV_TYPE; +pub const WN_DEVICE_ALREADY_REMEMBERED: ::DWORD = ::ERROR_DEVICE_ALREADY_REMEMBERED; +pub const WN_CONNECTED_OTHER_PASSWORD: ::DWORD = ::ERROR_CONNECTED_OTHER_PASSWORD; +pub const WN_CONNECTED_OTHER_PASSWORD_DEFAULT: ::DWORD = ::ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT; + +pub const WN_NO_MORE_ENTRIES: ::DWORD = ::ERROR_NO_MORE_ITEMS; +pub const WN_NOT_CONTAINER: ::DWORD = ::ERROR_NOT_CONTAINER; + +pub const WN_NOT_AUTHENTICATED: ::DWORD = ::ERROR_NOT_AUTHENTICATED; +pub const WN_NOT_LOGGED_ON: ::DWORD = ::ERROR_NOT_LOGGED_ON; +pub const WN_NOT_VALIDATED: ::DWORD = ::ERROR_NO_LOGON_SERVERS; + +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct NETCONNECTINFOSTRUCT { + pub cbStructure: ::DWORD, + pub dwFlags: ::DWORD, + pub dwSpeed: ::DWORD, + pub dwDelay: ::DWORD, + pub dwOptDataSize: ::DWORD, +} +pub type LPNETCONNECTINFOSTRUCT = *mut NETCONNECTINFOSTRUCT; + +pub const WNCON_FORNETCARD: ::DWORD = 0x00000001; +pub const WNCON_NOTROUTED: ::DWORD = 0x00000002; +pub const WNCON_SLOWLINK: ::DWORD = 0x00000004; +pub const WNCON_DYNAMIC: ::DWORD = 0x00000008; diff --git a/deps/winapi-0.1.23/src/winnls.rs b/deps/winapi-0.1.23/src/winnls.rs new file mode 100644 index 000000000..94841bf6c --- /dev/null +++ b/deps/winapi-0.1.23/src/winnls.rs @@ -0,0 +1,10 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Procedure declarations, constant definitions, and macros for the NLS component. +pub const CP_ACP: ::DWORD = 0; +pub const CP_OEMCP: ::DWORD = 1; +pub const CP_MACCP: ::DWORD = 2; +pub const CP_THREAD_ACP: ::DWORD = 3; +pub const CP_SYMBOL: ::DWORD = 42; +pub const CP_UTF7: ::DWORD = 65000; +pub const CP_UTF8: ::DWORD = 65001; diff --git a/deps/winapi-0.1.23/src/winnt.rs b/deps/winapi-0.1.23/src/winnt.rs new file mode 100644 index 000000000..556d976f7 --- /dev/null +++ b/deps/winapi-0.1.23/src/winnt.rs @@ -0,0 +1,1353 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! This module defines the 32-Bit Windows types and constants that are defined by NT, but exposed +//! through the Win32 API. +//341 +pub type PVOID = *mut ::c_void; +pub type PVOID64 = u64; // This is a 64-bit pointer, even when in 32-bit +//382 +pub type VOID = ::c_void; +pub type CHAR = ::c_char; +pub type SHORT = ::c_short; +pub type LONG = ::c_long; +// pub type INT = ::c_int; // Already defined by minwindef.h +pub type WCHAR = ::wchar_t; +pub type PWCHAR = *mut WCHAR; +pub type LPWCH = *mut WCHAR; +pub type PWCH = *mut WCHAR; +pub type LPCWCH = *const WCHAR; +pub type PCWCH = *const WCHAR; +pub type NWPSTR = *mut WCHAR; +pub type LPWSTR = *mut WCHAR; +pub type PWSTR = *mut WCHAR; +pub type PZPWSTR = *mut PWSTR; +pub type PCZPWSTR = *const PWSTR; +pub type LPUWSTR = *mut WCHAR; +pub type PUWSTR = *mut WCHAR; +pub type LPCWSTR = *const WCHAR; +pub type PCWSTR = *const WCHAR; +pub type PZPCWSTR= *mut PCWSTR; +pub type PCZPCWSTR = *const PCWSTR; +pub type LPCUWSTR = *const WCHAR; +pub type PCUWSTR = *const WCHAR; +pub type PZZWSTR= *mut WCHAR; +pub type PCZZWSTR = *const WCHAR; +pub type PUZZWSTR = *mut WCHAR; +pub type PCUZZWSTR = *const WCHAR; +pub type PNZWCH = *mut WCHAR; +pub type PCNZWCH = *const WCHAR; +pub type PUNZWCH = *mut WCHAR; +pub type PCUNZWCH = *const WCHAR; +pub type LPCWCHAR = *const WCHAR; +pub type PCWCHAR = *const WCHAR; +pub type LPCUWCHAR = *const WCHAR; +pub type PCUWCHAR = *const WCHAR; +pub type UCSCHAR = ::c_ulong; +pub type PUCSCHAR = *mut UCSCHAR; +pub type PCUCSCHAR = *const UCSCHAR; +pub type PUCSSTR = *mut UCSCHAR; +pub type PUUCSSTR = *mut UCSCHAR; +pub type PCUCSSTR = *const UCSCHAR; +pub type PCUUCSSTR = *const UCSCHAR; +pub type PUUCSCHAR = *mut UCSCHAR; +pub type PCUUCSCHAR = *const UCSCHAR; +pub type PCHAR = *mut CHAR; +pub type LPCH = *mut CHAR; +pub type PCH = *mut CHAR; +pub type LPCCH = *const CHAR; +pub type PCCH = *const CHAR; +pub type NPSTR = *mut CHAR; +pub type LPSTR = *mut CHAR; +pub type PSTR = *mut CHAR; +pub type PZPSTR = *mut PSTR; +pub type PCZPSTR = *const PSTR; +pub type LPCSTR = *const CHAR; +pub type PCSTR = *const CHAR; +pub type PZPCSTR = *mut PCSTR; +pub type PCZPCSTR = *const PCSTR; +pub type PZZSTR = *mut CHAR; +pub type PCZZSTR = *const CHAR; +pub type PNZCH = *mut CHAR; +pub type PCNZCH = *const CHAR; +// Skipping TCHAR things +pub type PSHORT = *mut SHORT; +pub type PLONG = *mut LONG; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct PROCESSOR_NUMBER { + pub Group: ::WORD, + pub Number: ::BYTE, + pub Reserved: ::BYTE, +} +pub type PPROCESSOR_NUMBER = *mut PROCESSOR_NUMBER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct GROUP_AFFINITY { + pub Mask: ::KAFFINITY, + pub Group: ::WORD, + pub Reserved: [::WORD; 3], +} +pub type PGROUP_AFFINITY = *mut GROUP_AFFINITY; +pub type HANDLE = *mut ::c_void; +pub type PHANDLE = *mut HANDLE; +pub type FCHAR = ::BYTE; +pub type FSHORT = ::WORD; +pub type FLONG = ::DWORD; +//667 +pub type CCHAR = ::c_char; +pub type LCID = ::DWORD; +pub type PLCID = ::PDWORD; +pub type LANGID = ::WORD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub enum COMPARTMENT_ID { + UNSPECIFIED_COMPARTMENT_ID = 0, + DEFAULT_COMPARTMENT_ID = 1, +} +pub type PCOMPARTMENT_ID = *mut COMPARTMENT_ID; +//710 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FLOAT128 { + pub LowPart: ::__int64, + pub HighPart: ::__int64, +} +pub type PFLOAT128 = *mut FLOAT128; +pub type LONGLONG = ::__int64; +pub type ULONGLONG = ::__uint64; +pub type PLONGLONG = *mut LONGLONG; +pub type PULONGLONG = *mut ULONGLONG; +pub type USN = LONGLONG; +pub type LARGE_INTEGER = LONGLONG; +pub type PLARGE_INTEGER = *mut LARGE_INTEGER; +pub type ULARGE_INTEGER = ULONGLONG; +pub type PULARGE_INTEGER= *mut ULARGE_INTEGER; +pub type RTL_REFERENCE_COUNT = ::LONG_PTR; +pub type PRTL_REFERENCE_COUNT = *mut ::LONG_PTR; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct LUID { + pub LowPart: ::DWORD, + pub HighPart: LONG, +} +pub type PLUID = *mut LUID; +pub type DWORDLONG = ULONGLONG; +pub type PDWORDLONG = *mut DWORDLONG; +//1042 +pub type BOOLEAN = ::BYTE; +pub type PBOOLEAN = *mut BOOLEAN; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct LIST_ENTRY { + pub Flink: *mut LIST_ENTRY, + pub Blink: *mut LIST_ENTRY, +} +pub type PLIST_ENTRY = *mut LIST_ENTRY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SINGLE_LIST_ENTRY { + pub Next: *mut SINGLE_LIST_ENTRY, +} +pub type PSINGLE_LIST_ENTRY = *mut SINGLE_LIST_ENTRY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct LIST_ENTRY32 { + pub Flink: ::DWORD, + pub Blink: ::DWORD, +} +pub type PLIST_ENTRY32 = *mut LIST_ENTRY32; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct LIST_ENTRY64 { + pub Flink: ULONGLONG, + pub Blink: ULONGLONG, +} +pub type PLIST_ENTRY64 = *mut LIST_ENTRY64; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct OBJECTID { + pub Lineage: ::GUID, + pub Uniquifier: ::DWORD, +} +pub const MINCHAR: ::CHAR = 0x80u8 as ::CHAR; +pub const MAXCHAR: ::CHAR = 0x7f; +//1300 +pub type PEXCEPTION_ROUTINE = Option<unsafe extern "system" fn( + ExceptionRecord: *mut EXCEPTION_RECORD, EstablisherFrame: PVOID, ContextRecord: *mut CONTEXT, + DispatcherContext: PVOID, +) -> ::EXCEPTION_DISPOSITION>; +//2273 +pub const MAXIMUM_WAIT_OBJECTS: ::DWORD = 64; +pub const MAXIMUM_SUSPEND_COUNT: ::CHAR = MAXCHAR; +//2277 +pub type KSPIN_LOCK = ::ULONG_PTR; +pub type PKSPIN_LOCK = *mut KSPIN_LOCK; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct M128A { // FIXME align 16 + pub Low: ULONGLONG, + pub High: LONGLONG, +} +pub type PM128A = *mut M128A; +#[cfg(target_arch = "x86")] #[repr(C)] #[derive(Copy)] +pub struct XSAVE_FORMAT { // FIXME align 16 + pub ControlWord: ::WORD, + pub StatusWord: ::WORD, + pub TagWord: ::BYTE, + pub Reserved1: ::BYTE, + pub ErrorOpcode: ::WORD, + pub ErrorOffset: ::DWORD, + pub ErrorSelector: ::WORD, + pub Reserved2: ::WORD, + pub DataOffset: ::DWORD, + pub DataSelector: ::WORD, + pub Reserved3: ::WORD, + pub MxCsr: ::DWORD, + pub MxCsr_Mask: ::DWORD, + pub FloatRegisters: [M128A; 8], + pub XmmRegisters: [M128A; 8], + pub Reserved4: [::BYTE; 224], +} +#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Copy)] +pub struct XSAVE_FORMAT { // FIXME align 16 + pub ControlWord: ::WORD, + pub StatusWord: ::WORD, + pub TagWord: ::BYTE, + pub Reserved1: ::BYTE, + pub ErrorOpcode: ::WORD, + pub ErrorOffset: ::DWORD, + pub ErrorSelector: ::WORD, + pub Reserved2: ::WORD, + pub DataOffset: ::DWORD, + pub DataSelector: ::WORD, + pub Reserved3: ::WORD, + pub MxCsr: ::DWORD, + pub MxCsr_Mask: ::DWORD, + pub FloatRegisters: [M128A; 8], + pub XmmRegisters: [M128A; 16], + pub Reserved4: [::BYTE; 96], +} +impl Clone for XSAVE_FORMAT { fn clone(&self) -> XSAVE_FORMAT { *self } } +//3563 +#[cfg(target_arch = "x86")] +pub const SIZE_OF_80387_REGISTERS: usize = 80; +#[cfg(target_arch = "x86")] #[repr(C)] #[derive(Copy)] +pub struct FLOATING_SAVE_AREA { + pub ControlWord: ::DWORD, + pub StatusWord: ::DWORD, + pub TagWord: ::DWORD, + pub ErrorOffset: ::DWORD, + pub ErrorSelector: ::DWORD, + pub DataOffset: ::DWORD, + pub DataSelector: ::DWORD, + pub RegisterArea: [::BYTE; SIZE_OF_80387_REGISTERS], + pub Spare0: ::DWORD, +} +#[cfg(target_arch = "x86")] +impl Clone for FLOATING_SAVE_AREA { fn clone(&self) -> FLOATING_SAVE_AREA { *self } } +#[cfg(target_arch = "x86")] +pub type PFLOATING_SAVE_AREA = *mut FLOATING_SAVE_AREA; +#[cfg(target_arch = "x86")] +pub const MAXIMUM_SUPPORTED_EXTENSION: usize = 512; +#[cfg(target_arch = "x86")] #[repr(C)] #[derive(Copy)] +pub struct CONTEXT { + pub ContextFlags: ::DWORD, + pub Dr0: ::DWORD, + pub Dr1: ::DWORD, + pub Dr2: ::DWORD, + pub Dr3: ::DWORD, + pub Dr6: ::DWORD, + pub Dr7: ::DWORD, + pub FloatSave: FLOATING_SAVE_AREA, + pub SegGs: ::DWORD, + pub SegFs: ::DWORD, + pub SegEs: ::DWORD, + pub SegDs: ::DWORD, + pub Edi: ::DWORD, + pub Esi: ::DWORD, + pub Ebx: ::DWORD, + pub Edx: ::DWORD, + pub Ecx: ::DWORD, + pub Eax: ::DWORD, + pub Ebp: ::DWORD, + pub Eip: ::DWORD, + pub SegCs: ::DWORD, + pub EFlags: ::DWORD, + pub Esp: ::DWORD, + pub SegSs: ::DWORD, + pub ExtendedRegisters: [::BYTE; MAXIMUM_SUPPORTED_EXTENSION], +} +#[cfg(target_arch = "x86")] +impl Clone for CONTEXT { fn clone(&self) -> CONTEXT { *self } } +#[cfg(target_arch = "x86_64")] +pub type XMM_SAVE_AREA32 = XSAVE_FORMAT; +pub type PXMM_SAVE_AREA32 = *mut XSAVE_FORMAT; +// FIXME - Align 16 +#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Clone, Copy)] +pub struct CONTEXT { + pub P1Home: ::DWORD64, + pub P2Home: ::DWORD64, + pub P3Home: ::DWORD64, + pub P4Home: ::DWORD64, + pub P5Home: ::DWORD64, + pub P6Home: ::DWORD64, + pub ContextFlags: ::DWORD, + pub MxCsr: ::DWORD, + pub SegCs: ::WORD, + pub SegDs: ::WORD, + pub SegEs: ::WORD, + pub SegFs: ::WORD, + pub SegGs: ::WORD, + pub SegSs: ::WORD, + pub EFlags: ::DWORD, + pub Dr0: ::DWORD64, + pub Dr1: ::DWORD64, + pub Dr2: ::DWORD64, + pub Dr3: ::DWORD64, + pub Dr6: ::DWORD64, + pub Dr7: ::DWORD64, + pub Rax: ::DWORD64, + pub Rcx: ::DWORD64, + pub Rdx: ::DWORD64, + pub Rbx: ::DWORD64, + pub Rsp: ::DWORD64, + pub Rbp: ::DWORD64, + pub Rsi: ::DWORD64, + pub Rdi: ::DWORD64, + pub R8: ::DWORD64, + pub R9: ::DWORD64, + pub R10: ::DWORD64, + pub R11: ::DWORD64, + pub R12: ::DWORD64, + pub R13: ::DWORD64, + pub R14: ::DWORD64, + pub R15: ::DWORD64, + pub Rip: ::DWORD64, + pub FltSave: XMM_SAVE_AREA32, + pub VectorRegister: [::M128A; 26], + pub VectorControl: ::DWORD64, + pub DebugControl: ::DWORD64, + pub LastBranchToRip: ::DWORD64, + pub LastBranchFromRip: ::DWORD64, + pub LastExceptionToRip: ::DWORD64, + pub LastExceptionFromRip: ::DWORD64, +} +pub type PCONTEXT = *mut CONTEXT; +#[test] +fn test_CONTEXT_size() { + use std::mem::size_of; + if cfg!(target_arch = "x86_64") { + assert_eq!(size_of::<CONTEXT>(), 1232) + } else if cfg!(target_arch = "x86") { + assert_eq!(size_of::<CONTEXT>(), 716) + } +} +//8983 +pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct EXCEPTION_RECORD { + pub ExceptionCode: ::DWORD, + pub ExceptionFlags: ::DWORD, + pub ExceptionRecord: *mut EXCEPTION_RECORD, + pub ExceptionAddress: ::PVOID, + pub NumberParameters: ::DWORD, + pub ExceptionInformation: [::ULONG_PTR; EXCEPTION_MAXIMUM_PARAMETERS], +} +pub type PEXCEPTION_RECORD = *mut EXCEPTION_RECORD; +//9023 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct EXCEPTION_POINTERS { + pub ExceptionRecord: PEXCEPTION_RECORD, + pub ContextRecord: PCONTEXT, +} +pub type PEXCEPTION_POINTERS = *mut EXCEPTION_POINTERS; +pub type PACCESS_TOKEN = ::PVOID; +pub type PSECURITY_DESCRIPTOR = ::PVOID; +pub type PSID = ::PVOID; +pub type PCLAIMS_BLOB = ::PVOID; +//9091 +pub type ACCESS_MASK = ::DWORD; +pub type PACCESS_MASK = *mut ACCESS_MASK; +pub const DELETE: ::DWORD = 0x00010000; +pub const READ_CONTROL: ::DWORD = 0x00020000; +pub const WRITE_DAC: ::DWORD = 0x00040000; +pub const WRITE_OWNER: ::DWORD = 0x00080000; +pub const SYNCHRONIZE: ::DWORD = 0x00100000; +pub const STANDARD_RIGHTS_REQUIRED: ::DWORD = 0x000F0000; +pub const STANDARD_RIGHTS_READ: ::DWORD = READ_CONTROL; +pub const STANDARD_RIGHTS_WRITE: ::DWORD = READ_CONTROL; +pub const STANDARD_RIGHTS_EXECUTE: ::DWORD = READ_CONTROL; +pub const STANDARD_RIGHTS_ALL: ::DWORD = 0x001F0000; +pub const SPECIFIC_RIGHTS_ALL: ::DWORD = 0x0000FFFF; +pub const ACCESS_SYSTEM_SECURITY: ::DWORD = 0x01000000; +pub const MAXIMUM_ALLOWED: ::DWORD = 0x02000000; +pub const GENERIC_READ: ::DWORD = 0x80000000; +pub const GENERIC_WRITE: ::DWORD = 0x40000000; +pub const GENERIC_EXECUTE: ::DWORD = 0x20000000; +pub const GENERIC_ALL: ::DWORD = 0x10000000; +//9170 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct LUID_AND_ATTRIBUTES { + pub Luid: LUID, + pub Attributes: ::DWORD, +} +pub type PLUID_AND_ATTRIBUTES = *mut LUID_AND_ATTRIBUTES; +//9802 +pub const ACL_REVISION: ::BYTE = 2; +pub const ACL_REVISION_DS: ::BYTE = 4; +pub const ACL_REVISION1: ::BYTE = 1; +pub const MIN_ACL_REVISION: ::BYTE = ACL_REVISION2; +pub const ACL_REVISION2: ::BYTE = 2; +pub const ACL_REVISION3: ::BYTE = 3; +pub const ACL_REVISION4: ::BYTE = 4; +pub const MAX_ACL_REVISION: ::BYTE = ACL_REVISION4; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ACL { + pub AclRevision: ::BYTE, + pub Sbz1: ::BYTE, + pub AclSize: ::WORD, + pub AceCount: ::WORD, + pub Sbz2: ::WORD, +} +pub type PACL = *mut ACL; +//10689 +pub const TOKEN_ASSIGN_PRIMARY: ::DWORD = 0x0001; +pub const TOKEN_DUPLICATE: ::DWORD = 0x0002; +pub const TOKEN_IMPERSONATE: ::DWORD = 0x0004; +pub const TOKEN_QUERY: ::DWORD = 0x0008; +pub const TOKEN_QUERY_SOURCE: ::DWORD = 0x0010; +pub const TOKEN_ADJUST_PRIVILEGES: ::DWORD = 0x0020; +pub const TOKEN_ADJUST_GROUPS: ::DWORD = 0x0040; +pub const TOKEN_ADJUST_DEFAULT: ::DWORD = 0x0080; +pub const TOKEN_ADJUST_SESSIONID: ::DWORD = 0x0100; +pub const TOKEN_ALL_ACCESS_P: ::DWORD = STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY + | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE + | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; +pub const TOKEN_ALL_ACCESS: ::DWORD = TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID; +pub const TOKEN_READ: ::DWORD = STANDARD_RIGHTS_READ | TOKEN_QUERY; +pub const TOKEN_WRITE: ::DWORD = STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES + | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; +pub const TOKEN_EXECUTE: ::DWORD = STANDARD_RIGHTS_EXECUTE; +//10823 +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct TOKEN_PRIVILEGES { + pub PrivilegeCount: ::DWORD, + pub Privileges: [LUID_AND_ATTRIBUTES; 0], +} +pub type PTOKEN_PRIVILEGES = *mut TOKEN_PRIVILEGES; +//10965 +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INVALID: ::WORD = 0x00; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INT64: ::WORD = 0x01; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_UINT64: ::WORD = 0x02; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_STRING: ::WORD = 0x03; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE { + pub Version: ::DWORD64, + pub Name: ::PWSTR, +} +pub type PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE = *mut CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_FQBN: ::WORD = 0x04; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_SID: ::WORD = 0x05; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_BOOLEAN: ::WORD = 0x06; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE { + pub pValue: ::PVOID, + pub ValueLength: ::DWORD, +} +pub type PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE = + *mut CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_OCTET_STRING: ::WORD = 0x10; +pub const CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE: ::DWORD = 0x0001; +pub const CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE: ::DWORD = 0x0002; +pub const CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY: ::DWORD = 0x0004; +pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT: ::DWORD = 0x0008; +pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED: ::DWORD = 0x0010; +pub const CLAIM_SECURITY_ATTRIBUTE_MANDATORY: ::DWORD = 0x0020; +pub const CLAIM_SECURITY_ATTRIBUTE_VALID_FLAGS: ::DWORD = CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE + | CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE | CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY + | CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT | CLAIM_SECURITY_ATTRIBUTE_DISABLED + | CLAIM_SECURITY_ATTRIBUTE_MANDATORY; +pub const CLAIM_SECURITY_ATTRIBUTE_CUSTOM_FLAGS: ::DWORD = 0xFFFF0000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CLAIM_SECURITY_ATTRIBUTE_V1 { + pub Name: ::PWSTR, + pub ValueType: ::WORD, + pub Reserved: ::WORD, + pub Flags: ::DWORD, + pub ValueCount: ::DWORD, + // Put data here +} +pub type PCLAIM_SECURITY_ATTRIBUTE_V1 = *mut CLAIM_SECURITY_ATTRIBUTE_V1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 { + pub Name: ::DWORD, + pub ValueType: ::WORD, + pub Reserved: ::WORD, + pub Flags: ::DWORD, + pub ValueCount: ::DWORD, + // Put array here +} +pub type PCLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 = *mut CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1; +pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1: ::WORD = 1; +pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION: ::WORD = + CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CLAIM_SECURITY_ATTRIBUTES_INFORMATION { + pub Version: ::WORD, + pub Reserved: ::WORD, + pub AttributeCount: ::DWORD, + pub pAttributeV1: PCLAIM_SECURITY_ATTRIBUTE_V1, +} +pub type PCLAIM_SECURITY_ATTRIBUTES_INFORMATION = *mut CLAIM_SECURITY_ATTRIBUTES_INFORMATION; +//11294 +pub const PROCESS_TERMINATE: ::DWORD = 0x0001; +pub const PROCESS_CREATE_THREAD: ::DWORD = 0x0002; +pub const PROCESS_SET_SESSIONID: ::DWORD = 0x0004; +pub const PROCESS_VM_OPERATION: ::DWORD = 0x0008; +pub const PROCESS_VM_READ: ::DWORD = 0x0010; +pub const PROCESS_VM_WRITE: ::DWORD = 0x0020; +pub const PROCESS_DUP_HANDLE: ::DWORD = 0x0040; +pub const PROCESS_CREATE_PROCESS: ::DWORD = 0x0080; +pub const PROCESS_SET_QUOTA: ::DWORD = 0x0100; +pub const PROCESS_SET_INFORMATION: ::DWORD = 0x0200; +pub const PROCESS_QUERY_INFORMATION: ::DWORD = 0x0400; +pub const PROCESS_SUSPEND_RESUME: ::DWORD = 0x0800; +pub const PROCESS_QUERY_LIMITED_INFORMATION: ::DWORD = 0x1000; +pub const PROCESS_SET_LIMITED_INFORMATION: ::DWORD = 0x2000; +pub const PROCESS_ALL_ACCESS: ::DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF; +//11490 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IO_COUNTERS { + pub ReadOperationCount: ::ULONGLONG, + pub WriteOperationCount: ::ULONGLONG, + pub OtherOperationCount: ::ULONGLONG, + pub ReadTransferCount: ::ULONGLONG, + pub WriteTransferCount: ::ULONGLONG, + pub OtherTransferCount: ::ULONGLONG, +} +pub type PIO_COUNTERS = *mut IO_COUNTERS; +//11607 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct JOBOBJECT_BASIC_LIMIT_INFORMATION { + pub PerProcessUserTimeLimit: ::LARGE_INTEGER, + pub PerJobUserTimeLimit: ::LARGE_INTEGER, + pub LimitFlags: ::DWORD, + pub MinimumWorkingSetSize: ::SIZE_T, + pub MaximumWorkingSetSize: ::SIZE_T, + pub ActiveProcessLimit: ::DWORD, + pub Affinity: ::ULONG_PTR, + pub PriorityClass: ::DWORD, + pub SchedulingClass: ::DWORD, +} +pub type PJOBOBJECT_BASIC_LIMIT_INFORMATION = *mut JOBOBJECT_BASIC_LIMIT_INFORMATION; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { + pub BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION, + pub IoInfo: IO_COUNTERS, + pub ProcessMemoryLimit: ::SIZE_T, + pub JobMemoryLimit: ::SIZE_T, + pub PeakProcessMemoryUsed: ::SIZE_T, + pub PeakJobMemoryUsed: ::SIZE_T, +} +pub type PJOBOBJECT_EXTENDED_LIMIT_INFORMATION = *mut JOBOBJECT_EXTENDED_LIMIT_INFORMATION; +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct JOBOBJECT_BASIC_PROCESS_ID_LIST { + pub NumberOfAssignedProcesses: ::DWORD, + pub NumberOfProcessIdsInList: ::DWORD, + pub ProcessIdList: [::ULONG_PTR; 0], +} +pub type PJOBOBJECT_BASIC_PROCESS_ID_LIST = *mut JOBOBJECT_BASIC_PROCESS_ID_LIST; +//11712 +pub const JOB_OBJECT_TERMINATE_AT_END_OF_JOB: ::DWORD = 0; +pub const JOB_OBJECT_POST_AT_END_OF_JOB: ::DWORD = 1; +pub const JOB_OBJECT_MSG_END_OF_JOB_TIME: ::DWORD = 1; +pub const JOB_OBJECT_MSG_END_OF_PROCESS_TIME: ::DWORD = 2; +pub const JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT: ::DWORD = 3; +pub const JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: ::DWORD = 4; +pub const JOB_OBJECT_MSG_NEW_PROCESS: ::DWORD = 6; +pub const JOB_OBJECT_MSG_EXIT_PROCESS: ::DWORD = 7; +pub const JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: ::DWORD = 8; +pub const JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: ::DWORD = 9; +pub const JOB_OBJECT_MSG_JOB_MEMORY_LIMIT: ::DWORD = 10; +pub const JOB_OBJECT_MSG_NOTIFICATION_LIMIT: ::DWORD = 11; +pub const JOB_OBJECT_MSG_JOB_CYCLE_TIME_LIMIT: ::DWORD = 12; +pub const JOB_OBJECT_MSG_MINIMUM: ::DWORD = 1; +pub const JOB_OBJECT_MSG_MAXIMUM: ::DWORD = 12; +pub const JOB_OBJECT_VALID_COMPLETION_FILTER: ::DWORD = ((1 << (JOB_OBJECT_MSG_MAXIMUM + 1)) - 1) + - ((1 << JOB_OBJECT_MSG_MINIMUM) - 1); +pub const JOB_OBJECT_LIMIT_WORKINGSET: ::DWORD = 0x00000001; +pub const JOB_OBJECT_LIMIT_PROCESS_TIME: ::DWORD = 0x00000002; +pub const JOB_OBJECT_LIMIT_JOB_TIME: ::DWORD = 0x00000004; +pub const JOB_OBJECT_LIMIT_ACTIVE_PROCESS: ::DWORD = 0x00000008; +pub const JOB_OBJECT_LIMIT_AFFINITY: ::DWORD = 0x00000010; +pub const JOB_OBJECT_LIMIT_PRIORITY_CLASS: ::DWORD = 0x00000020; +pub const JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME: ::DWORD = 0x00000040; +pub const JOB_OBJECT_LIMIT_SCHEDULING_CLASS: ::DWORD = 0x00000080; +pub const JOB_OBJECT_LIMIT_PROCESS_MEMORY: ::DWORD = 0x00000100; +pub const JOB_OBJECT_LIMIT_JOB_MEMORY: ::DWORD = 0x00000200; +pub const JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION: ::DWORD = 0x00000400; +pub const JOB_OBJECT_LIMIT_BREAKAWAY_OK: ::DWORD = 0x00000800; +pub const JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK: ::DWORD = 0x00001000; +pub const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: ::DWORD = 0x00002000; +pub const JOB_OBJECT_LIMIT_SUBSET_AFFINITY: ::DWORD = 0x00004000; +pub const JOB_OBJECT_LIMIT_JOB_READ_BYTES: ::DWORD = 0x00010000; +pub const JOB_OBJECT_LIMIT_JOB_WRITE_BYTES: ::DWORD = 0x00020000; +pub const JOB_OBJECT_LIMIT_RATE_CONTROL: ::DWORD = 0x00040000; +pub const JOB_OBJECT_LIMIT_RESERVED3: ::DWORD = 0x00008000; +pub const JOB_OBJECT_LIMIT_VALID_FLAGS: ::DWORD = 0x0007ffff; +pub const JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS: ::DWORD = 0x000000ff; +pub const JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS: ::DWORD = 0x00007fff; +pub const JOB_OBJECT_NOTIFICATION_LIMIT_VALID_FLAGS: ::DWORD = 0x00070204; +pub const JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS: ::DWORD = 0x0007ffff; +pub const JOB_OBJECT_UILIMIT_NONE: ::DWORD = 0x00000000; +pub const JOB_OBJECT_UILIMIT_HANDLES: ::DWORD = 0x00000001; +pub const JOB_OBJECT_UILIMIT_READCLIPBOARD: ::DWORD = 0x00000002; +pub const JOB_OBJECT_UILIMIT_WRITECLIPBOARD: ::DWORD = 0x00000004; +pub const JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS: ::DWORD = 0x00000008; +pub const JOB_OBJECT_UILIMIT_DISPLAYSETTINGS: ::DWORD = 0x00000010; +pub const JOB_OBJECT_UILIMIT_GLOBALATOMS: ::DWORD = 0x00000020; +pub const JOB_OBJECT_UILIMIT_DESKTOP: ::DWORD = 0x00000040; +pub const JOB_OBJECT_UILIMIT_EXITWINDOWS: ::DWORD = 0x00000080; +pub const JOB_OBJECT_UILIMIT_ALL: ::DWORD = 0x000000FF; +pub const JOB_OBJECT_UI_VALID_FLAGS: ::DWORD = 0x000000FF; +pub const JOB_OBJECT_SECURITY_NO_ADMIN: ::DWORD = 0x00000001; +pub const JOB_OBJECT_SECURITY_RESTRICTED_TOKEN: ::DWORD = 0x00000002; +pub const JOB_OBJECT_SECURITY_ONLY_TOKEN: ::DWORD = 0x00000004; +pub const JOB_OBJECT_SECURITY_FILTER_TOKENS: ::DWORD = 0x00000008; +pub const JOB_OBJECT_SECURITY_VALID_FLAGS: ::DWORD = 0x0000000f; +pub const JOB_OBJECT_CPU_RATE_CONTROL_ENABLE: ::DWORD = 0x1; +pub const JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED: ::DWORD = 0x2; +pub const JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP: ::DWORD = 0x4; +pub const JOB_OBJECT_CPU_RATE_CONTROL_NOTIFY: ::DWORD = 0x8; +pub const JOB_OBJECT_CPU_RATE_CONTROL_VALID_FLAGS: ::DWORD = 0xf; +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum JOBOBJECTINFOCLASS { + JobObjectBasicAccountingInformation = 1, + JobObjectBasicLimitInformation, + JobObjectBasicProcessIdList, + JobObjectBasicUIRestrictions, + JobObjectSecurityLimitInformation, + JobObjectEndOfJobTimeInformation, + JobObjectAssociateCompletionPortInformation, + JobObjectBasicAndIoAccountingInformation, + JobObjectExtendedLimitInformation, + JobObjectJobSetInformation, + JobObjectGroupInformation, + JobObjectNotificationLimitInformation, + JobObjectLimitViolationInformation, + JobObjectGroupInformationEx, + JobObjectCpuRateControlInformation, + JobObjectCompletionFilter, + JobObjectCompletionCounter, + JobObjectReserved1Information = 18, + JobObjectReserved2Information, + JobObjectReserved3Information, + JobObjectReserved4Information, + JobObjectReserved5Information, + JobObjectReserved6Information, + JobObjectReserved7Information, + JobObjectReserved8Information, + JobObjectReserved9Information, + MaxJobObjectInfoClass, +} +pub const PAGE_NOACCESS: ::DWORD = 0x01; +pub const PAGE_READONLY: ::DWORD = 0x02; +pub const PAGE_READWRITE: ::DWORD = 0x04; +pub const PAGE_WRITECOPY: ::DWORD = 0x08; +pub const PAGE_EXECUTE: ::DWORD = 0x10; +pub const PAGE_EXECUTE_READ: ::DWORD = 0x20; +pub const PAGE_EXECUTE_READWRITE: ::DWORD = 0x40; +pub const PAGE_EXECUTE_WRITECOPY: ::DWORD = 0x80; +pub const PAGE_GUARD: ::DWORD = 0x100; +pub const PAGE_NOCACHE: ::DWORD = 0x200; +pub const PAGE_WRITECOMBINE: ::DWORD = 0x400; +pub const PAGE_REVERT_TO_FILE_MAP: ::DWORD = 0x80000000; +pub const PAGE_TARGETS_NO_UPDATE: ::DWORD = 0x40000000; +pub const PAGE_TARGETS_INVALID: ::DWORD = 0x40000000; +pub const MEM_COMMIT: ::DWORD = 0x1000; +pub const MEM_RESERVE: ::DWORD = 0x2000; +pub const MEM_DECOMMIT: ::DWORD = 0x4000; +pub const MEM_RELEASE: ::DWORD = 0x8000; +pub const MEM_FREE: ::DWORD = 0x10000; +pub const MEM_PRIVATE: ::DWORD = 0x20000; +pub const MEM_MAPPED: ::DWORD = 0x40000; +pub const MEM_RESET: ::DWORD = 0x80000; +pub const MEM_TOP_DOWN: ::DWORD = 0x100000; +pub const MEM_WRITE_WATCH: ::DWORD = 0x200000; +pub const MEM_PHYSICAL: ::DWORD = 0x400000; +pub const MEM_ROTATE: ::DWORD = 0x800000; +pub const MEM_DIFFERENT_IMAGE_BASE_OK: ::DWORD = 0x800000; +pub const MEM_RESET_UNDO: ::DWORD = 0x1000000; +pub const MEM_LARGE_PAGES: ::DWORD = 0x20000000; +pub const MEM_4MB_PAGES: ::DWORD = 0x80000000; +pub const SEC_FILE: ::DWORD = 0x800000; +pub const SEC_IMAGE: ::DWORD = 0x1000000; +pub const SEC_PROTECTED_IMAGE: ::DWORD = 0x2000000; +pub const SEC_RESERVE: ::DWORD = 0x4000000; +pub const SEC_COMMIT: ::DWORD = 0x8000000; +pub const SEC_NOCACHE: ::DWORD = 0x10000000; +pub const SEC_WRITECOMBINE: ::DWORD = 0x40000000; +pub const SEC_LARGE_PAGES: ::DWORD = 0x80000000; +pub const SEC_IMAGE_NO_EXECUTE: ::DWORD = (SEC_IMAGE | SEC_NOCACHE); +pub const MEM_IMAGE: ::DWORD = SEC_IMAGE; +pub const WRITE_WATCH_FLAG_RESET: ::DWORD = 0x01; +pub const MEM_UNMAP_WITH_TRANSIENT_BOOST: ::DWORD = 0x01; +//12217 +pub const FILE_READ_DATA: ::DWORD = 0x0001; +pub const FILE_LIST_DIRECTORY: ::DWORD = 0x0001; +pub const FILE_WRITE_DATA: ::DWORD = 0x0002; +pub const FILE_ADD_FILE: ::DWORD = 0x0002; +pub const FILE_APPEND_DATA: ::DWORD = 0x0004; +pub const FILE_ADD_SUBDIRECTORY: ::DWORD = 0x0004; +pub const FILE_CREATE_PIPE_INSTANCE: ::DWORD = 0x0004; +pub const FILE_READ_EA: ::DWORD = 0x0008; +pub const FILE_WRITE_EA: ::DWORD = 0x0010; +pub const FILE_EXECUTE: ::DWORD = 0x0020; +pub const FILE_TRAVERSE: ::DWORD = 0x0020; +pub const FILE_DELETE_CHILD: ::DWORD = 0x0040; +pub const FILE_READ_ATTRIBUTES: ::DWORD = 0x0080; +pub const FILE_WRITE_ATTRIBUTES: ::DWORD = 0x0100; +pub const FILE_ALL_ACCESS: ::DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF; +pub const FILE_GENERIC_READ: ::DWORD = STANDARD_RIGHTS_READ | FILE_READ_DATA + | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; +pub const FILE_GENERIC_WRITE: ::DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA + | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE; +pub const FILE_GENERIC_EXECUTE: ::DWORD = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES + | FILE_EXECUTE | SYNCHRONIZE; +pub const FILE_SHARE_READ: ::DWORD = 0x00000001; +pub const FILE_SHARE_WRITE: ::DWORD = 0x00000002; +pub const FILE_SHARE_DELETE: ::DWORD = 0x00000004; +pub const FILE_ATTRIBUTE_READONLY: ::DWORD = 0x00000001; +pub const FILE_ATTRIBUTE_HIDDEN: ::DWORD = 0x00000002; +pub const FILE_ATTRIBUTE_SYSTEM: ::DWORD = 0x00000004; +pub const FILE_ATTRIBUTE_DIRECTORY: ::DWORD = 0x00000010; +pub const FILE_ATTRIBUTE_ARCHIVE: ::DWORD = 0x00000020; +pub const FILE_ATTRIBUTE_DEVICE: ::DWORD = 0x00000040; +pub const FILE_ATTRIBUTE_NORMAL: ::DWORD = 0x00000080; +pub const FILE_ATTRIBUTE_TEMPORARY: ::DWORD = 0x00000100; +pub const FILE_ATTRIBUTE_SPARSE_FILE: ::DWORD = 0x00000200; +pub const FILE_ATTRIBUTE_REPARSE_POINT: ::DWORD = 0x00000400; +pub const FILE_ATTRIBUTE_COMPRESSED: ::DWORD = 0x00000800; +pub const FILE_ATTRIBUTE_OFFLINE: ::DWORD = 0x00001000; +pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: ::DWORD = 0x00002000; +pub const FILE_ATTRIBUTE_ENCRYPTED: ::DWORD = 0x00004000; +pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: ::DWORD = 0x00008000; +pub const FILE_ATTRIBUTE_VIRTUAL: ::DWORD = 0x00010000; +pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: ::DWORD = 0x00020000; +pub const FILE_ATTRIBUTE_EA: ::DWORD = 0x00040000; +pub const FILE_NOTIFY_CHANGE_FILE_NAME: ::DWORD = 0x00000001; +pub const FILE_NOTIFY_CHANGE_DIR_NAME: ::DWORD = 0x00000002; +pub const FILE_NOTIFY_CHANGE_ATTRIBUTES: ::DWORD = 0x00000004; +pub const FILE_NOTIFY_CHANGE_SIZE: ::DWORD = 0x00000008; +pub const FILE_NOTIFY_CHANGE_LAST_WRITE: ::DWORD = 0x00000010; +pub const FILE_NOTIFY_CHANGE_LAST_ACCESS: ::DWORD = 0x00000020; +pub const FILE_NOTIFY_CHANGE_CREATION: ::DWORD = 0x00000040; +pub const FILE_NOTIFY_CHANGE_SECURITY: ::DWORD = 0x00000100; +pub const FILE_ACTION_ADDED: ::DWORD = 0x00000001; +pub const FILE_ACTION_REMOVED: ::DWORD = 0x00000002; +pub const FILE_ACTION_MODIFIED: ::DWORD = 0x00000003; +pub const FILE_ACTION_RENAMED_OLD_NAME: ::DWORD = 0x00000004; +pub const FILE_ACTION_RENAMED_NEW_NAME: ::DWORD = 0x00000005; +pub const MAILSLOT_NO_MESSAGE: ::DWORD = 0xFFFFFFFF; +pub const MAILSLOT_WAIT_FOREVER: ::DWORD = 0xFFFFFFFF; +pub const FILE_CASE_SENSITIVE_SEARCH: ::DWORD = 0x00000001; +pub const FILE_CASE_PRESERVED_NAMES: ::DWORD = 0x00000002; +pub const FILE_UNICODE_ON_DISK: ::DWORD = 0x00000004; +pub const FILE_PERSISTENT_ACLS: ::DWORD = 0x00000008; +pub const FILE_FILE_COMPRESSION: ::DWORD = 0x00000010; +pub const FILE_VOLUME_QUOTAS: ::DWORD = 0x00000020; +pub const FILE_SUPPORTS_SPARSE_FILES: ::DWORD = 0x00000040; +pub const FILE_SUPPORTS_REPARSE_POINTS: ::DWORD = 0x00000080; +pub const FILE_SUPPORTS_REMOTE_STORAGE: ::DWORD = 0x00000100; +pub const FILE_VOLUME_IS_COMPRESSED: ::DWORD = 0x00008000; +pub const FILE_SUPPORTS_OBJECT_IDS: ::DWORD = 0x00010000; +pub const FILE_SUPPORTS_ENCRYPTION: ::DWORD = 0x00020000; +pub const FILE_NAMED_STREAMS: ::DWORD = 0x00040000; +pub const FILE_READ_ONLY_VOLUME: ::DWORD = 0x00080000; +pub const FILE_SEQUENTIAL_WRITE_ONCE: ::DWORD = 0x00100000; +pub const FILE_SUPPORTS_TRANSACTIONS: ::DWORD = 0x00200000; +pub const FILE_SUPPORTS_HARD_LINKS: ::DWORD = 0x00400000; +pub const FILE_SUPPORTS_EXTENDED_ATTRIBUTES: ::DWORD = 0x00800000; +pub const FILE_SUPPORTS_OPEN_BY_FILE_ID: ::DWORD = 0x01000000; +pub const FILE_SUPPORTS_USN_JOURNAL: ::DWORD = 0x02000000; +pub const FILE_SUPPORTS_INTEGRITY_STREAMS: ::DWORD = 0x04000000; +pub const FILE_INVALID_FILE_ID: ::LONGLONG = -1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FILE_ID_128 { + pub Identifier: [::BYTE; 16], +} +pub type PFILE_ID_128 = *mut FILE_ID_128; +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct FILE_NOTIFY_INFORMATION { + pub NextEntryOffset: ::DWORD, + pub Action: ::DWORD, + pub FileNameLength: ::DWORD, + pub FileName: [::WCHAR; 0], +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FILE_SEGMENT_ELEMENT { + pub Buffer: ::PVOID64, + pub Alignment: ::ULONGLONG, +} +pub type PFILE_SEGMENT_ELEMENT = *mut FILE_SEGMENT_ELEMENT; +//12475 +pub const IO_REPARSE_TAG_MOUNT_POINT: ::DWORD = 0xA0000003; +pub const IO_REPARSE_TAG_HSM: ::DWORD = 0xC0000004; +pub const IO_REPARSE_TAG_HSM2: ::DWORD = 0x80000006; +pub const IO_REPARSE_TAG_SIS: ::DWORD = 0x80000007; +pub const IO_REPARSE_TAG_WIM: ::DWORD = 0x80000008; +pub const IO_REPARSE_TAG_CSV: ::DWORD = 0x80000009; +pub const IO_REPARSE_TAG_DFS: ::DWORD = 0x8000000A; +pub const IO_REPARSE_TAG_SYMLINK: ::DWORD = 0xA000000C; +pub const IO_REPARSE_TAG_DFSR: ::DWORD = 0x80000012; +pub const IO_REPARSE_TAG_DEDUP: ::DWORD = 0x80000013; +pub const IO_REPARSE_TAG_NFS: ::DWORD = 0x80000014; +pub const IO_REPARSE_TAG_FILE_PLACEHOLDER: ::DWORD = 0x80000015; +pub const IO_REPARSE_TAG_WOF: ::DWORD = 0x80000017; +//15000 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_FILE_HEADER { + pub Machine: ::WORD, + pub NumberOfSections: ::WORD, + pub TimeDateStamp: ::DWORD, + pub PointerToSymbolTable: ::DWORD, + pub NumberOfSymbols: ::DWORD, + pub SizeOfOptionalHeader: ::WORD, + pub Characteristics: ::WORD, +} +pub type PIMAGE_FILE_HEADER = *mut IMAGE_FILE_HEADER; +pub const IMAGE_SIZEOF_FILE_HEADER: usize = 20; +pub const IMAGE_FILE_RELOCS_STRIPPED: ::WORD = 0x0001; +pub const IMAGE_FILE_EXECUTABLE_IMAGE: ::WORD = 0x0002; +pub const IMAGE_FILE_LINE_NUMS_STRIPPED: ::WORD = 0x0004; +pub const IMAGE_FILE_LOCAL_SYMS_STRIPPED: ::WORD = 0x0008; +pub const IMAGE_FILE_AGGRESIVE_WS_TRIM: ::WORD = 0x0010; +pub const IMAGE_FILE_LARGE_ADDRESS_AWARE: ::WORD = 0x0020; +pub const IMAGE_FILE_BYTES_REVERSED_LO: ::WORD = 0x0080; +pub const IMAGE_FILE_32BIT_MACHINE: ::WORD = 0x0100; +pub const IMAGE_FILE_DEBUG_STRIPPED: ::WORD = 0x0200; +pub const IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP: ::WORD = 0x0400; +pub const IMAGE_FILE_NET_RUN_FROM_SWAP: ::WORD = 0x0800; +pub const IMAGE_FILE_SYSTEM: ::WORD = 0x1000; +pub const IMAGE_FILE_DLL: ::WORD = 0x2000; +pub const IMAGE_FILE_UP_SYSTEM_ONLY: ::WORD = 0x4000; +pub const IMAGE_FILE_BYTES_REVERSED_HI: ::WORD = 0x8000; +pub const IMAGE_FILE_MACHINE_UNKNOWN: ::WORD = 0; +pub const IMAGE_FILE_MACHINE_I386: ::WORD = 0x014c; +pub const IMAGE_FILE_MACHINE_R3000: ::WORD = 0x0162; +pub const IMAGE_FILE_MACHINE_R4000: ::WORD = 0x0166; +pub const IMAGE_FILE_MACHINE_R10000: ::WORD = 0x0168; +pub const IMAGE_FILE_MACHINE_WCEMIPSV2: ::WORD = 0x0169; +pub const IMAGE_FILE_MACHINE_ALPHA: ::WORD = 0x0184; +pub const IMAGE_FILE_MACHINE_SH3: ::WORD = 0x01a2; +pub const IMAGE_FILE_MACHINE_SH3DSP: ::WORD = 0x01a3; +pub const IMAGE_FILE_MACHINE_SH3E: ::WORD = 0x01a4; +pub const IMAGE_FILE_MACHINE_SH4: ::WORD = 0x01a6; +pub const IMAGE_FILE_MACHINE_SH5: ::WORD = 0x01a8; +pub const IMAGE_FILE_MACHINE_ARM: ::WORD = 0x01c0; +pub const IMAGE_FILE_MACHINE_THUMB: ::WORD = 0x01c2; +pub const IMAGE_FILE_MACHINE_ARMNT: ::WORD = 0x01c4; +pub const IMAGE_FILE_MACHINE_AM33: ::WORD = 0x01d3; +pub const IMAGE_FILE_MACHINE_POWERPC: ::WORD = 0x01F0; +pub const IMAGE_FILE_MACHINE_POWERPCFP: ::WORD = 0x01f1; +pub const IMAGE_FILE_MACHINE_IA64: ::WORD = 0x0200; +pub const IMAGE_FILE_MACHINE_MIPS16: ::WORD = 0x0266; +pub const IMAGE_FILE_MACHINE_ALPHA64: ::WORD = 0x0284; +pub const IMAGE_FILE_MACHINE_MIPSFPU: ::WORD = 0x0366; +pub const IMAGE_FILE_MACHINE_MIPSFPU16: ::WORD = 0x0466; +pub const IMAGE_FILE_MACHINE_AXP64: ::WORD = IMAGE_FILE_MACHINE_ALPHA64; +pub const IMAGE_FILE_MACHINE_TRICORE: ::WORD = 0x0520; +pub const IMAGE_FILE_MACHINE_CEF: ::WORD = 0x0CEF; +pub const IMAGE_FILE_MACHINE_EBC: ::WORD = 0x0EBC; +pub const IMAGE_FILE_MACHINE_AMD64: ::WORD = 0x8664; +pub const IMAGE_FILE_MACHINE_M32R: ::WORD = 0x9041; +pub const IMAGE_FILE_MACHINE_CEE: ::WORD = 0xC0EE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_DATA_DIRECTORY { + pub VirtualAddress: ::DWORD, + pub Size: ::DWORD, +} +pub type PIMAGE_DATA_DIRECTORY = *mut IMAGE_DATA_DIRECTORY; +pub const IMAGE_NUMBEROF_DIRECTORY_ENTRIES: usize = 16; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_OPTIONAL_HEADER32 { + pub Magic: ::WORD, + pub MajorLinkerVersion: ::BYTE, + pub MinorLinkerVersion: ::BYTE, + pub SizeOfCode: ::DWORD, + pub SizeOfInitializedData: ::DWORD, + pub SizeOfUninitializedData: ::DWORD, + pub AddressOfEntryPoint: ::DWORD, + pub BaseOfCode: ::DWORD, + pub BaseOfData: ::DWORD, + pub ImageBase: ::DWORD, + pub SectionAlignment: ::DWORD, + pub FileAlignment: ::DWORD, + pub MajorOperatingSystemVersion: ::WORD, + pub MinorOperatingSystemVersion: ::WORD, + pub MajorImageVersion: ::WORD, + pub MinorImageVersion: ::WORD, + pub MajorSubsystemVersion: ::WORD, + pub MinorSubsystemVersion: ::WORD, + pub Win32VersionValue: ::DWORD, + pub SizeOfImage: ::DWORD, + pub SizeOfHeaders: ::DWORD, + pub CheckSum: ::DWORD, + pub Subsystem: ::WORD, + pub DllCharacteristics: ::WORD, + pub SizeOfStackReserve: ::DWORD, + pub SizeOfStackCommit: ::DWORD, + pub SizeOfHeapReserve: ::DWORD, + pub SizeOfHeapCommit: ::DWORD, + pub LoaderFlags: ::DWORD, + pub NumberOfRvaAndSizes: ::DWORD, + pub DataDirectory: [IMAGE_DATA_DIRECTORY; IMAGE_NUMBEROF_DIRECTORY_ENTRIES], +} +pub type PIMAGE_OPTIONAL_HEADER32 = *mut IMAGE_OPTIONAL_HEADER32; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_ROM_OPTIONAL_HEADER { + pub Magic: ::WORD, + pub MajorLinkerVersion: ::BYTE, + pub MinorLinkerVersion: ::BYTE, + pub SizeOfCode: ::DWORD, + pub SizeOfInitializedData: ::DWORD, + pub SizeOfUninitializedData: ::DWORD, + pub AddressOfEntryPoint: ::DWORD, + pub BaseOfCode: ::DWORD, + pub BaseOfData: ::DWORD, + pub BaseOfBss: ::DWORD, + pub GprMask: ::DWORD, + pub CprMask: [::DWORD; 4], + pub GpValue: ::DWORD, +} +pub type PIMAGE_ROM_OPTIONAL_HEADER = *mut IMAGE_ROM_OPTIONAL_HEADER; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_OPTIONAL_HEADER64 { + pub Magic: ::WORD, + pub MajorLinkerVersion: ::BYTE, + pub MinorLinkerVersion: ::BYTE, + pub SizeOfCode: ::DWORD, + pub SizeOfInitializedData: ::DWORD, + pub SizeOfUninitializedData: ::DWORD, + pub AddressOfEntryPoint: ::DWORD, + pub BaseOfCode: ::DWORD, + pub ImageBase: ::ULONGLONG, + pub SectionAlignment: ::DWORD, + pub FileAlignment: ::DWORD, + pub MajorOperatingSystemVersion: ::WORD, + pub MinorOperatingSystemVersion: ::WORD, + pub MajorImageVersion: ::WORD, + pub MinorImageVersion: ::WORD, + pub MajorSubsystemVersion: ::WORD, + pub MinorSubsystemVersion: ::WORD, + pub Win32VersionValue: ::DWORD, + pub SizeOfImage: ::DWORD, + pub SizeOfHeaders: ::DWORD, + pub CheckSum: ::DWORD, + pub Subsystem: ::WORD, + pub DllCharacteristics: ::WORD, + pub SizeOfStackReserve: ULONGLONG, + pub SizeOfStackCommit: ULONGLONG, + pub SizeOfHeapReserve: ULONGLONG, + pub SizeOfHeapCommit: ULONGLONG, + pub LoaderFlags: ::DWORD, + pub NumberOfRvaAndSizes: ::DWORD, + pub DataDirectory: [IMAGE_DATA_DIRECTORY; IMAGE_NUMBEROF_DIRECTORY_ENTRIES], +} +pub type PIMAGE_OPTIONAL_HEADER64 = *mut IMAGE_OPTIONAL_HEADER64; +pub const IMAGE_NT_OPTIONAL_HDR32_MAGIC: ::WORD = 0x10b; +pub const IMAGE_NT_OPTIONAL_HDR64_MAGIC: ::WORD = 0x20b; +pub const IMAGE_ROM_OPTIONAL_HDR_MAGIC: ::WORD = 0x107; +#[cfg(target_arch = "x86_64")] +pub type IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER64; +#[cfg(target_arch = "x86_64")] +pub type PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER64; +#[cfg(target_arch = "x86")] +pub type IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER32; +#[cfg(target_arch = "x86")] +pub type PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER32; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_NT_HEADERS64 { + pub Signature: ::DWORD, + pub FileHeader: IMAGE_FILE_HEADER, + pub OptionalHeader: IMAGE_OPTIONAL_HEADER64, +} +pub type PIMAGE_NT_HEADERS64 = *mut IMAGE_NT_HEADERS64; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_NT_HEADERS32 { + pub Signature: ::DWORD, + pub FileHeader: IMAGE_FILE_HEADER, + pub OptionalHeader: IMAGE_OPTIONAL_HEADER32, +} +pub type PIMAGE_NT_HEADERS32 = *mut IMAGE_NT_HEADERS32; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_ROM_HEADERS { + pub FileHeader: IMAGE_FILE_HEADER, + pub OptionalHeader: IMAGE_ROM_OPTIONAL_HEADER, +} +pub type PIMAGE_ROM_HEADERS = *mut IMAGE_ROM_HEADERS; +#[cfg(target_arch = "x86_64")] +pub type IMAGE_NT_HEADERS = IMAGE_NT_HEADERS64; +#[cfg(target_arch = "x86_64")] +pub type PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS64; +#[cfg(target_arch = "x86")] +pub type IMAGE_NT_HEADERS = IMAGE_NT_HEADERS32; +#[cfg(target_arch = "x86")] +pub type PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS32; +pub const IMAGE_SUBSYSTEM_UNKNOWN: ::WORD = 0; +pub const IMAGE_SUBSYSTEM_NATIVE: ::WORD = 1; +pub const IMAGE_SUBSYSTEM_WINDOWS_GUI: ::WORD = 2; +pub const IMAGE_SUBSYSTEM_WINDOWS_CUI: ::WORD = 3; +pub const IMAGE_SUBSYSTEM_OS2_CUI: ::WORD = 5; +pub const IMAGE_SUBSYSTEM_POSIX_CUI: ::WORD = 7; +pub const IMAGE_SUBSYSTEM_NATIVE_WINDOWS: ::WORD = 8; +pub const IMAGE_SUBSYSTEM_WINDOWS_CE_GUI: ::WORD = 9; +pub const IMAGE_SUBSYSTEM_EFI_APPLICATION: ::WORD = 10; +pub const IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER: ::WORD = 11; +pub const IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER: ::WORD = 12; +pub const IMAGE_SUBSYSTEM_EFI_ROM: ::WORD = 13; +pub const IMAGE_SUBSYSTEM_XBOX: ::WORD = 14; +pub const IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION: ::WORD = 16; +pub const IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA: ::WORD = 0x0020; +pub const IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: ::WORD = 0x0040; +pub const IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY: ::WORD = 0x0080; +pub const IMAGE_DLLCHARACTERISTICS_NX_COMPAT: ::WORD = 0x0100; +pub const IMAGE_DLLCHARACTERISTICS_NO_ISOLATION: ::WORD = 0x0200; +pub const IMAGE_DLLCHARACTERISTICS_NO_SEH: ::WORD = 0x0400; +pub const IMAGE_DLLCHARACTERISTICS_NO_BIND: ::WORD = 0x0800; +pub const IMAGE_DLLCHARACTERISTICS_APPCONTAINER: ::WORD = 0x1000; +pub const IMAGE_DLLCHARACTERISTICS_WDM_DRIVER: ::WORD = 0x2000; +pub const IMAGE_DLLCHARACTERISTICS_GUARD_CF: ::WORD = 0x4000; +pub const IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE: ::WORD = 0x8000; +pub const IMAGE_DIRECTORY_ENTRY_EXPORT: ::WORD = 0; +pub const IMAGE_DIRECTORY_ENTRY_IMPORT: ::WORD = 1; +pub const IMAGE_DIRECTORY_ENTRY_RESOURCE: ::WORD = 2; +pub const IMAGE_DIRECTORY_ENTRY_EXCEPTION: ::WORD = 3; +pub const IMAGE_DIRECTORY_ENTRY_SECURITY: ::WORD = 4; +pub const IMAGE_DIRECTORY_ENTRY_BASERELOC: ::WORD = 5; +pub const IMAGE_DIRECTORY_ENTRY_DEBUG: ::WORD = 6; +pub const IMAGE_DIRECTORY_ENTRY_ARCHITECTURE: ::WORD = 7; +pub const IMAGE_DIRECTORY_ENTRY_GLOBALPTR: ::WORD = 8; +pub const IMAGE_DIRECTORY_ENTRY_TLS: ::WORD = 9; +pub const IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG: ::WORD = 10; +pub const IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT: ::WORD = 11; +pub const IMAGE_DIRECTORY_ENTRY_IAT: ::WORD = 12; +pub const IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT: ::WORD = 13; +pub const IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR: ::WORD = 14; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ANON_OBJECT_HEADER { + pub Sig1: ::WORD, + pub Sig2: ::WORD, + pub Version: ::WORD, + pub Machine: ::WORD, + pub TimeDateStamp: ::DWORD, + pub ClassID: ::CLSID, + pub SizeOfData: ::DWORD, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ANON_OBJECT_HEADER_V2 { + pub Sig1: ::WORD, + pub Sig2: ::WORD, + pub Version: ::WORD, + pub Machine: ::WORD, + pub TimeDateStamp: ::DWORD, + pub ClassID: ::CLSID, + pub SizeOfData: ::DWORD, + pub Flags: ::DWORD, + pub MetaDataSize: ::DWORD, + pub MetaDataOffset: ::DWORD, +} +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ANON_OBJECT_HEADER_BIGOBJ { + pub Sig1: ::WORD, + pub Sig2: ::WORD, + pub Version: ::WORD, + pub Machine: ::WORD, + pub TimeDateStamp: ::DWORD, + pub ClassID: ::CLSID, + pub SizeOfData: ::DWORD, + pub Flags: ::DWORD, + pub MetaDataSize: ::DWORD, + pub MetaDataOffset: ::DWORD, + pub NumberOfSections: ::DWORD, + pub PointerToSymbolTable: ::DWORD, + pub NumberOfSymbols: ::DWORD, +} +pub const IMAGE_SIZEOF_SHORT_NAME: usize = 8; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_SECTION_HEADER { + pub Name: [::BYTE; IMAGE_SIZEOF_SHORT_NAME], + pub PhysicalAddressOrVirtualSize: ::DWORD, + pub VirtualAddress: ::DWORD, + pub SizeOfRawData: ::DWORD, + pub PointerToRawData: ::DWORD, + pub PointerToRelocations: ::DWORD, + pub PointerToLinenumbers: ::DWORD, + pub NumberOfRelocations: ::WORD, + pub NumberOfLinenumbers: ::WORD, + pub Characteristics: ::DWORD, +} +pub type PIMAGE_SECTION_HEADER = *mut IMAGE_SECTION_HEADER; +pub const IMAGE_SIZEOF_SECTION_HEADER: usize = 40; +pub const IMAGE_SCN_TYPE_NO_PAD: ::DWORD = 0x00000008; +pub const IMAGE_SCN_CNT_CODE: ::DWORD = 0x00000020; +pub const IMAGE_SCN_CNT_INITIALIZED_DATA: ::DWORD = 0x00000040; +pub const IMAGE_SCN_CNT_UNINITIALIZED_DATA: ::DWORD = 0x00000080; +pub const IMAGE_SCN_LNK_OTHER: ::DWORD = 0x00000100; +pub const IMAGE_SCN_LNK_INFO: ::DWORD = 0x00000200; +pub const IMAGE_SCN_LNK_REMOVE: ::DWORD = 0x00000800; +pub const IMAGE_SCN_LNK_COMDAT: ::DWORD = 0x00001000; +pub const IMAGE_SCN_NO_DEFER_SPEC_EXC: ::DWORD = 0x00004000; +pub const IMAGE_SCN_GPREL: ::DWORD = 0x00008000; +pub const IMAGE_SCN_MEM_FARDATA: ::DWORD = 0x00008000; +pub const IMAGE_SCN_MEM_PURGEABLE: ::DWORD = 0x00020000; +pub const IMAGE_SCN_MEM_16BIT: ::DWORD = 0x00020000; +pub const IMAGE_SCN_MEM_LOCKED: ::DWORD = 0x00040000; +pub const IMAGE_SCN_MEM_PRELOAD: ::DWORD = 0x00080000; +pub const IMAGE_SCN_ALIGN_1BYTES: ::DWORD = 0x00100000; +pub const IMAGE_SCN_ALIGN_2BYTES: ::DWORD = 0x00200000; +pub const IMAGE_SCN_ALIGN_4BYTES: ::DWORD = 0x00300000; +pub const IMAGE_SCN_ALIGN_8BYTES: ::DWORD = 0x00400000; +pub const IMAGE_SCN_ALIGN_16BYTES: ::DWORD = 0x00500000; +pub const IMAGE_SCN_ALIGN_32BYTES: ::DWORD = 0x00600000; +pub const IMAGE_SCN_ALIGN_64BYTES: ::DWORD = 0x00700000; +pub const IMAGE_SCN_ALIGN_128BYTES: ::DWORD = 0x00800000; +pub const IMAGE_SCN_ALIGN_256BYTES: ::DWORD = 0x00900000; +pub const IMAGE_SCN_ALIGN_512BYTES: ::DWORD = 0x00A00000; +pub const IMAGE_SCN_ALIGN_1024BYTES: ::DWORD = 0x00B00000; +pub const IMAGE_SCN_ALIGN_2048BYTES: ::DWORD = 0x00C00000; +pub const IMAGE_SCN_ALIGN_4096BYTES: ::DWORD = 0x00D00000; +pub const IMAGE_SCN_ALIGN_8192BYTES: ::DWORD = 0x00E00000; +pub const IMAGE_SCN_ALIGN_MASK: ::DWORD = 0x00F00000; +pub const IMAGE_SCN_LNK_NRELOC_OVFL: ::DWORD = 0x01000000; +pub const IMAGE_SCN_MEM_DISCARDABLE: ::DWORD = 0x02000000; +pub const IMAGE_SCN_MEM_NOT_CACHED: ::DWORD = 0x04000000; +pub const IMAGE_SCN_MEM_NOT_PAGED: ::DWORD = 0x08000000; +pub const IMAGE_SCN_MEM_SHARED: ::DWORD = 0x10000000; +pub const IMAGE_SCN_MEM_EXECUTE: ::DWORD = 0x20000000; +pub const IMAGE_SCN_MEM_READ: ::DWORD = 0x40000000; +pub const IMAGE_SCN_MEM_WRITE: ::DWORD = 0x80000000; +pub const IMAGE_SCN_SCALE_INDEX: ::DWORD = 0x00000001; +//16590 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_DEBUG_DIRECTORY { + pub Characteristics: ::DWORD, + pub TimeDateStamp: ::DWORD, + pub MajorVersion: ::WORD, + pub MinorVersion: ::WORD, + pub Type: ::DWORD, + pub SizeOfData: ::DWORD, + pub AddressOfRawData: ::DWORD, + pub PointerToRawData: ::DWORD, +} +pub type PIMAGE_DEBUG_DIRECTORY = *mut IMAGE_DEBUG_DIRECTORY; +pub const IMAGE_DEBUG_TYPE_UNKNOWN: ::DWORD = 0; +pub const IMAGE_DEBUG_TYPE_COFF: ::DWORD = 1; +pub const IMAGE_DEBUG_TYPE_CODEVIEW: ::DWORD = 2; +pub const IMAGE_DEBUG_TYPE_FPO: ::DWORD = 3; +pub const IMAGE_DEBUG_TYPE_MISC: ::DWORD = 4; +pub const IMAGE_DEBUG_TYPE_EXCEPTION: ::DWORD = 5; +pub const IMAGE_DEBUG_TYPE_FIXUP: ::DWORD = 6; +pub const IMAGE_DEBUG_TYPE_OMAP_TO_SRC: ::DWORD = 7; +pub const IMAGE_DEBUG_TYPE_OMAP_FROM_SRC: ::DWORD = 8; +pub const IMAGE_DEBUG_TYPE_BORLAND: ::DWORD = 9; +pub const IMAGE_DEBUG_TYPE_RESERVED10: ::DWORD = 10; +pub const IMAGE_DEBUG_TYPE_CLSID: ::DWORD = 11; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_COFF_SYMBOLS_HEADER { + pub NumberOfSymbols: ::DWORD, + pub LvaToFirstSymbol: ::DWORD, + pub NumberOfLinenumbers: ::DWORD, + pub LvaToFirstLinenumber: ::DWORD, + pub RvaToFirstByteOfCode: ::DWORD, + pub RvaToLastByteOfCode: ::DWORD, + pub RvaToFirstByteOfData: ::DWORD, + pub RvaToLastByteOfData: ::DWORD, +} +pub type PIMAGE_COFF_SYMBOLS_HEADER = *mut IMAGE_COFF_SYMBOLS_HEADER; +pub const FRAME_FPO: ::WORD = 0; +pub const FRAME_TRAP: ::WORD = 1; +pub const FRAME_TSS: ::WORD = 2; +pub const FRAME_NONFPO: ::WORD = 3; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FPO_DATA { + pub ulOffStart: ::DWORD, + pub cbProcSize: ::DWORD, + pub cdwLocals: ::DWORD, + pub cdwParams: ::WORD, + pub bitfield: ::WORD, +} +pub type PFPO_DATA = *mut FPO_DATA; +pub const SIZEOF_RFPO_DATA: usize = 16; +pub const IMAGE_DEBUG_MISC_EXENAME: ::DWORD = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_DEBUG_MISC { + pub DataType: ::DWORD, + pub Length: ::DWORD, + pub Unicode: ::BOOLEAN, + pub Reserved: [::BYTE; 3], + pub Data: [::BYTE; 0], +} +pub type PIMAGE_DEBUG_MISC = *mut IMAGE_DEBUG_MISC; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_FUNCTION_ENTRY { + pub StartingAddress: ::DWORD, + pub EndingAddress: ::DWORD, + pub EndOfPrologue: ::DWORD, +} +pub type PIMAGE_FUNCTION_ENTRY = *mut IMAGE_FUNCTION_ENTRY; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct IMAGE_FUNCTION_ENTRY64 { + pub StartingAddress: ::ULONGLONG, + pub EndingAddress: ::ULONGLONG, + pub EndOfPrologueOrUnwindInfoAddress: ::ULONGLONG, +} +pub type PIMAGE_FUNCTION_ENTRY64 = *mut IMAGE_FUNCTION_ENTRY64; +//18145 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RTL_CRITICAL_SECTION_DEBUG { + pub Type: ::WORD, + pub CreatorBackTraceIndex: ::WORD, + pub CriticalSection: *mut ::RTL_CRITICAL_SECTION, + pub ProcessLocksList: ::LIST_ENTRY, + pub EntryCount: ::DWORD, + pub ContentionCount: ::DWORD, + pub Flags: ::DWORD, + pub CreatorBackTraceIndexHigh: ::WORD, + pub SpareWORD: ::WORD, +} +pub type PRTL_CRITICAL_SECTION_DEBUG = *mut RTL_CRITICAL_SECTION_DEBUG; +pub type RTL_RESOURCE_DEBUG = RTL_CRITICAL_SECTION_DEBUG; +pub type PRTL_RESOURCE_DEBUG = *mut RTL_CRITICAL_SECTION_DEBUG; +pub const RTL_CRITSECT_TYPE: ::WORD = 0; +pub const RTL_RESOURCE_TYPE: ::WORD = 1; +pub const RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO: ::ULONG_PTR = 0x01000000; +pub const RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN: ::ULONG_PTR = 0x02000000; +pub const RTL_CRITICAL_SECTION_FLAG_STATIC_INIT: ::ULONG_PTR = 0x04000000; +pub const RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE: ::ULONG_PTR = 0x08000000; +pub const RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO: ::ULONG_PTR = 0x10000000; +pub const RTL_CRITICAL_SECTION_ALL_FLAG_BITS: ::ULONG_PTR = 0xFF000000; +pub const RTL_CRITICAL_SECTION_FLAG_RESERVED: ::ULONG_PTR = RTL_CRITICAL_SECTION_ALL_FLAG_BITS & !(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO | RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN | RTL_CRITICAL_SECTION_FLAG_STATIC_INIT | RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE | RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); +pub const RTL_CRITICAL_SECTION_DEBUG_FLAG_STATIC_INIT: ::DWORD = 0x00000001; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RTL_CRITICAL_SECTION { + pub DebugInfo: ::PRTL_CRITICAL_SECTION_DEBUG, + pub LockCount: ::LONG, + pub RecursionCount: ::LONG, + pub OwningThread: ::HANDLE, + pub LockSemaphore: ::HANDLE, + pub SpinCount: ::ULONG_PTR, +} +pub type PRTL_CRITICAL_SECTION = *mut RTL_CRITICAL_SECTION; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RTL_SRWLOCK { + pub Ptr: ::PVOID, +} +pub type PRTL_SRWLOCK = *mut RTL_SRWLOCK; +pub const RTL_SRWLOCK_INIT: RTL_SRWLOCK = RTL_SRWLOCK { Ptr: 0 as PVOID }; +//18204 +pub type PAPCFUNC = Option<unsafe extern "system" fn(Parameter: ::ULONG_PTR)>; +pub type PVECTORED_EXCEPTION_HANDLER = Option<unsafe extern "system" fn( + ExceptionInfo: *mut EXCEPTION_POINTERS, +) -> ::LONG>; +#[repr(i32)] #[derive(Clone, Copy, Debug)] #[allow(unused_qualifications)] +pub enum HEAP_INFORMATION_CLASS { + HeapCompatibilityInformation = 0, + HeapEnableTerminationOnCorruption = 1, + HeapOptimizeResources = 3, +} +pub use self::HEAP_INFORMATION_CLASS::*; +pub const HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION: ::DWORD = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HEAP_OPTIMIZE_RESOURCES_INFORMATION { + Version: ::DWORD, + Flags: ::DWORD, +} +pub type PHEAP_OPTIMIZE_RESOURCES_INFORMATION = *mut HEAP_OPTIMIZE_RESOURCES_INFORMATION; +pub const WT_EXECUTEDEFAULT: ::ULONG = 0x00000000; +pub const WT_EXECUTEINIOTHREAD: ::ULONG = 0x00000001; +pub const WT_EXECUTEINUITHREAD: ::ULONG = 0x00000002; +pub const WT_EXECUTEINWAITTHREAD: ::ULONG = 0x00000004; +pub const WT_EXECUTEONLYONCE: ::ULONG = 0x00000008; +pub const WT_EXECUTEINTIMERTHREAD: ::ULONG = 0x00000020; +pub const WT_EXECUTELONGFUNCTION: ::ULONG = 0x00000010; +pub const WT_EXECUTEINPERSISTENTIOTHREAD: ::ULONG = 0x00000040; +pub const WT_EXECUTEINPERSISTENTTHREAD: ::ULONG = 0x00000080; +pub const WT_TRANSFER_IMPERSONATION: ::ULONG = 0x00000100; +pub type WAITORTIMERCALLBACKFUNC = Option<unsafe extern "system" fn(::PVOID, ::BOOLEAN)>; +pub type WORKERCALLBACKFUNC = Option<unsafe extern "system" fn(::PVOID)>; +pub type APC_CALLBACK_FUNCTION = Option<unsafe extern "system" fn(::DWORD, ::PVOID, ::PVOID)>; +pub type WAITORTIMERCALLBACK = WAITORTIMERCALLBACKFUNC; +pub type PFLS_CALLBACK_FUNCTION = Option<unsafe extern "system" fn(lpFlsData: ::PVOID)>; +pub type PSECURE_MEMORY_CACHE_CALLBACK = Option<unsafe extern "system" fn( + Addr: ::PVOID, Range: ::SIZE_T, +) -> ::BOOLEAN>; +pub const WT_EXECUTEINLONGTHREAD: ::ULONG = 0x00000010; +pub const WT_EXECUTEDELETEWAIT: ::ULONG = 0x00000008; +//18570 +pub const KEY_QUERY_VALUE: ::REGSAM = 0x0001; +pub const KEY_SET_VALUE: ::REGSAM = 0x0002; +pub const KEY_CREATE_SUB_KEY: ::REGSAM = 0x0004; +pub const KEY_ENUMERATE_SUB_KEYS: ::REGSAM = 0x0008; +pub const KEY_NOTIFY: ::REGSAM = 0x0010; +pub const KEY_CREATE_LINK: ::REGSAM = 0x0020; +pub const KEY_WOW64_32KEY: ::REGSAM = 0x0200; +pub const KEY_WOW64_64KEY: ::REGSAM = 0x0100; +pub const KEY_WOW64_RES: ::REGSAM = 0x0300; + +pub const KEY_READ: ::REGSAM = ( + STANDARD_RIGHTS_READ | + KEY_QUERY_VALUE | + KEY_ENUMERATE_SUB_KEYS | + KEY_NOTIFY + ) & (!SYNCHRONIZE); +pub const KEY_WRITE: ::REGSAM = (STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (!SYNCHRONIZE); +pub const KEY_EXECUTE: ::REGSAM = KEY_READ & (!SYNCHRONIZE); +pub const KEY_ALL_ACCESS: ::REGSAM = ( + STANDARD_RIGHTS_ALL | + KEY_QUERY_VALUE | + KEY_SET_VALUE | + KEY_CREATE_SUB_KEY | + KEY_ENUMERATE_SUB_KEYS | + KEY_NOTIFY | + KEY_CREATE_LINK + ) & (!SYNCHRONIZE); + +pub const REG_CREATED_NEW_KEY: ::DWORD = 0x00000001; +pub const REG_OPENED_EXISTING_KEY: ::DWORD = 0x00000002; + +pub const REG_NOTIFY_CHANGE_NAME: ::DWORD = 0x00000001; +pub const REG_NOTIFY_CHANGE_ATTRIBUTES: ::DWORD = 0x00000002; +pub const REG_NOTIFY_CHANGE_LAST_SET: ::DWORD = 0x00000004; +pub const REG_NOTIFY_CHANGE_SECURITY: ::DWORD = 0x00000008; + +pub const REG_LEGAL_CHANGE_FILTER: ::DWORD = REG_NOTIFY_CHANGE_NAME | + REG_NOTIFY_CHANGE_ATTRIBUTES | + REG_NOTIFY_CHANGE_LAST_SET | + REG_NOTIFY_CHANGE_SECURITY; + +pub const REG_NOTIFY_THREAD_AGNOSTIC: ::DWORD = 0x10000000; //supported only on Windows 8 and later + +pub const REG_OPTION_RESERVED: ::DWORD = 0x00000000; +pub const REG_OPTION_NON_VOLATILE: ::DWORD = 0x00000000; +pub const REG_OPTION_VOLATILE: ::DWORD = 0x00000001; +pub const REG_OPTION_CREATE_LINK: ::DWORD = 0x00000002; +pub const REG_OPTION_BACKUP_RESTORE: ::DWORD = 0x00000004; +pub const REG_OPTION_OPEN_LINK: ::DWORD = 0x00000008; + +pub const REG_NONE: ::DWORD = 0; +pub const REG_SZ: ::DWORD = 1; +pub const REG_EXPAND_SZ: ::DWORD = 2; +pub const REG_BINARY: ::DWORD = 3; +pub const REG_DWORD: ::DWORD = 4; +pub const REG_DWORD_LITTLE_ENDIAN: ::DWORD = 4; +pub const REG_DWORD_BIG_ENDIAN: ::DWORD = 5; +pub const REG_LINK: ::DWORD = 6; +pub const REG_MULTI_SZ: ::DWORD = 7; +pub const REG_RESOURCE_LIST: ::DWORD = 8; +pub const REG_FULL_RESOURCE_DESCRIPTOR: ::DWORD = 9; +pub const REG_RESOURCE_REQUIREMENTS_LIST: ::DWORD = 10; +pub const REG_QWORD: ::DWORD = 11; +pub const REG_QWORD_LITTLE_ENDIAN: ::DWORD = 11; +//18720 +pub const SERVICE_KERNEL_DRIVER: ::DWORD = 0x00000001; +pub const SERVICE_FILE_SYSTEM_DRIVER: ::DWORD = 0x00000002; +pub const SERVICE_ADAPTER: ::DWORD = 0x00000004; +pub const SERVICE_RECOGNIZER_DRIVER: ::DWORD = 0x00000008; +pub const SERVICE_DRIVER: ::DWORD = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER + | SERVICE_RECOGNIZER_DRIVER; +pub const SERVICE_WIN32_OWN_PROCESS: ::DWORD = 0x00000010; +pub const SERVICE_WIN32_SHARE_PROCESS: ::DWORD = 0x00000020; +pub const SERVICE_WIN32: ::DWORD = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS; +pub const SERVICE_INTERACTIVE_PROCESS: ::DWORD = 0x00000100; +pub const SERVICE_TYPE_ALL: ::DWORD = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER + | SERVICE_INTERACTIVE_PROCESS; diff --git a/deps/winapi-0.1.23/src/winsock2.rs b/deps/winapi-0.1.23/src/winsock2.rs new file mode 100644 index 000000000..cca4ae802 --- /dev/null +++ b/deps/winapi-0.1.23/src/winsock2.rs @@ -0,0 +1,24 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! definitions to be used with the WinSock 2 DLL and WinSock 2 applications. +//! +//! This header file corresponds to version 2.2.x of the WinSock API specification. +pub const WINSOCK_VERSION: ::WORD = 2 | (2 << 8); +pub type u_char = ::c_uchar; +pub type u_short = ::c_ushort; +pub type u_int = ::c_uint; +pub type u_long = ::c_ulong; +pub type u_int64 = ::__uint64; +pub type SOCKET = ::UINT_PTR; +pub const FD_SETSIZE: usize = 64; +#[repr(C)] #[derive(Copy)] +pub struct fd_set { + pub fd_count: u_int, + pub fd_array: [SOCKET; FD_SETSIZE], +} +impl Clone for fd_set { fn clone(&self) -> fd_set { *self } } +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct timeval { + pub tv_sec: ::c_long, + pub tv_usec: ::c_long, +} diff --git a/deps/winapi-0.1.23/src/winsvc.rs b/deps/winapi-0.1.23/src/winsvc.rs new file mode 100644 index 000000000..ab167867d --- /dev/null +++ b/deps/winapi-0.1.23/src/winsvc.rs @@ -0,0 +1,209 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! Header file for the Service Control Manager +//80 +pub const SERVICE_NO_CHANGE: ::DWORD = 0xffffffff; +pub const SERVICE_ACTIVE: ::DWORD = 0x00000001; +pub const SERVICE_INACTIVE: ::DWORD = 0x00000002; +pub const SERVICE_STATE_ALL: ::DWORD = SERVICE_ACTIVE | SERVICE_INACTIVE; +pub const SERVICE_CONTROL_STOP: ::DWORD = 0x00000001; +pub const SERVICE_CONTROL_PAUSE: ::DWORD = 0x00000002; +pub const SERVICE_CONTROL_CONTINUE: ::DWORD = 0x00000003; +pub const SERVICE_CONTROL_INTERROGATE: ::DWORD = 0x00000004; +pub const SERVICE_CONTROL_SHUTDOWN: ::DWORD = 0x00000005; +pub const SERVICE_CONTROL_PARAMCHANGE: ::DWORD = 0x00000006; +pub const SERVICE_CONTROL_NETBINDADD: ::DWORD = 0x00000007; +pub const SERVICE_CONTROL_NETBINDREMOVE: ::DWORD = 0x00000008; +pub const SERVICE_CONTROL_NETBINDENABLE: ::DWORD = 0x00000009; +pub const SERVICE_CONTROL_NETBINDDISABLE: ::DWORD = 0x0000000A; +pub const SERVICE_CONTROL_DEVICEEVENT: ::DWORD = 0x0000000B; +pub const SERVICE_CONTROL_HARDWAREPROFILECHANGE: ::DWORD = 0x0000000C; +pub const SERVICE_CONTROL_POWEREVENT: ::DWORD = 0x0000000D; +pub const SERVICE_CONTROL_SESSIONCHANGE: ::DWORD = 0x0000000E; +pub const SERVICE_CONTROL_PRESHUTDOWN: ::DWORD = 0x0000000F; +pub const SERVICE_CONTROL_TIMECHANGE: ::DWORD = 0x00000010; +pub const SERVICE_CONTROL_TRIGGEREVENT: ::DWORD = 0x00000020; +pub const SERVICE_STOPPED: ::DWORD = 0x00000001; +pub const SERVICE_START_PENDING: ::DWORD = 0x00000002; +pub const SERVICE_STOP_PENDING: ::DWORD = 0x00000003; +pub const SERVICE_RUNNING: ::DWORD = 0x00000004; +pub const SERVICE_CONTINUE_PENDING: ::DWORD = 0x00000005; +pub const SERVICE_PAUSE_PENDING: ::DWORD = 0x00000006; +pub const SERVICE_PAUSED: ::DWORD = 0x00000007; +pub const SERVICE_ACCEPT_STOP: ::DWORD = 0x00000001; +pub const SERVICE_ACCEPT_PAUSE_CONTINUE: ::DWORD = 0x00000002; +pub const SERVICE_ACCEPT_SHUTDOWN: ::DWORD = 0x00000004; +pub const SERVICE_ACCEPT_PARAMCHANGE: ::DWORD = 0x00000008; +pub const SERVICE_ACCEPT_NETBINDCHANGE: ::DWORD = 0x00000010; +pub const SERVICE_ACCEPT_HARDWAREPROFILECHANGE: ::DWORD = 0x00000020; +pub const SERVICE_ACCEPT_POWEREVENT: ::DWORD = 0x00000040; +pub const SERVICE_ACCEPT_SESSIONCHANGE: ::DWORD = 0x00000080; +pub const SERVICE_ACCEPT_PRESHUTDOWN: ::DWORD = 0x00000100; +pub const SERVICE_ACCEPT_TIMECHANGE: ::DWORD = 0x00000200; +pub const SERVICE_ACCEPT_TRIGGEREVENT: ::DWORD = 0x00000400; +pub const SC_MANAGER_CONNECT: ::DWORD = 0x0001; +pub const SC_MANAGER_CREATE_SERVICE: ::DWORD = 0x0002; +pub const SC_MANAGER_ENUMERATE_SERVICE: ::DWORD = 0x0004; +pub const SC_MANAGER_LOCK: ::DWORD = 0x0008; +pub const SC_MANAGER_QUERY_LOCK_STATUS: ::DWORD = 0x0010; +pub const SC_MANAGER_MODIFY_BOOT_CONFIG: ::DWORD = 0x0020; +pub const SC_MANAGER_ALL_ACCESS: ::DWORD = ::STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT + | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK + | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG; +pub const SERVICE_QUERY_CONFIG: ::DWORD = 0x0001; +pub const SERVICE_CHANGE_CONFIG: ::DWORD = 0x0002; +pub const SERVICE_QUERY_STATUS: ::DWORD = 0x0004; +pub const SERVICE_ENUMERATE_DEPENDENTS: ::DWORD = 0x0008; +pub const SERVICE_START: ::DWORD = 0x0010; +pub const SERVICE_STOP: ::DWORD = 0x0020; +pub const SERVICE_PAUSE_CONTINUE: ::DWORD = 0x0040; +pub const SERVICE_INTERROGATE: ::DWORD = 0x0080; +pub const SERVICE_USER_DEFINED_CONTROL: ::DWORD = 0x0100; +pub const SERVICE_ALL_ACCESS: ::DWORD = ::STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG + | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START + | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL; +pub const SERVICE_RUNS_IN_SYSTEM_PROCESS: ::DWORD = 0x00000001; +pub const SERVICE_CONFIG_DESCRIPTION: ::DWORD = 1; +pub const SERVICE_CONFIG_FAILURE_ACTIONS: ::DWORD = 2; +pub const SERVICE_CONFIG_DELAYED_AUTO_START_INFO: ::DWORD = 3; +pub const SERVICE_CONFIG_FAILURE_ACTIONS_FLAG: ::DWORD = 4; +pub const SERVICE_CONFIG_SERVICE_SID_INFO: ::DWORD = 5; +pub const SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO: ::DWORD = 6; +pub const SERVICE_CONFIG_PRESHUTDOWN_INFO: ::DWORD = 7; +pub const SERVICE_CONFIG_TRIGGER_INFO: ::DWORD = 8; +pub const SERVICE_CONFIG_PREFERRED_NODE: ::DWORD = 9; +pub const SERVICE_CONFIG_LAUNCH_PROTECTED: ::DWORD = 12; +pub const SERVICE_NOTIFY_STATUS_CHANGE_1: ::DWORD = 1; +pub const SERVICE_NOTIFY_STATUS_CHANGE_2: ::DWORD = 2; +pub const SERVICE_NOTIFY_STATUS_CHANGE: ::DWORD = SERVICE_NOTIFY_STATUS_CHANGE_2; +pub const SERVICE_NOTIFY_STOPPED: ::DWORD = 0x00000001; +pub const SERVICE_NOTIFY_START_PENDING: ::DWORD = 0x00000002; +pub const SERVICE_NOTIFY_STOP_PENDING: ::DWORD = 0x00000004; +pub const SERVICE_NOTIFY_RUNNING: ::DWORD = 0x00000008; +pub const SERVICE_NOTIFY_CONTINUE_PENDING: ::DWORD = 0x00000010; +pub const SERVICE_NOTIFY_PAUSE_PENDING: ::DWORD = 0x00000020; +pub const SERVICE_NOTIFY_PAUSED: ::DWORD = 0x00000040; +pub const SERVICE_NOTIFY_CREATED: ::DWORD = 0x00000080; +pub const SERVICE_NOTIFY_DELETED: ::DWORD = 0x00000100; +pub const SERVICE_NOTIFY_DELETE_PENDING: ::DWORD = 0x00000200; +pub const SERVICE_STOP_REASON_FLAG_MIN: ::DWORD = 0x00000000; +pub const SERVICE_STOP_REASON_FLAG_UNPLANNED: ::DWORD = 0x10000000; +pub const SERVICE_STOP_REASON_FLAG_CUSTOM: ::DWORD = 0x20000000; +pub const SERVICE_STOP_REASON_FLAG_PLANNED: ::DWORD = 0x40000000; +pub const SERVICE_STOP_REASON_FLAG_MAX: ::DWORD = 0x80000000; +pub const SERVICE_STOP_REASON_MAJOR_MIN: ::DWORD = 0x00000000; +pub const SERVICE_STOP_REASON_MAJOR_OTHER: ::DWORD = 0x00010000; +pub const SERVICE_STOP_REASON_MAJOR_HARDWARE: ::DWORD = 0x00020000; +pub const SERVICE_STOP_REASON_MAJOR_OPERATINGSYSTEM: ::DWORD = 0x00030000; +pub const SERVICE_STOP_REASON_MAJOR_SOFTWARE: ::DWORD = 0x00040000; +pub const SERVICE_STOP_REASON_MAJOR_APPLICATION: ::DWORD = 0x00050000; +pub const SERVICE_STOP_REASON_MAJOR_NONE: ::DWORD = 0x00060000; +pub const SERVICE_STOP_REASON_MAJOR_MAX: ::DWORD = 0x00070000; +pub const SERVICE_STOP_REASON_MAJOR_MIN_CUSTOM: ::DWORD = 0x00400000; +pub const SERVICE_STOP_REASON_MAJOR_MAX_CUSTOM: ::DWORD = 0x00ff0000; +pub const SERVICE_STOP_REASON_MINOR_MIN: ::DWORD = 0x00000000; +pub const SERVICE_STOP_REASON_MINOR_OTHER: ::DWORD = 0x00000001; +pub const SERVICE_STOP_REASON_MINOR_MAINTENANCE: ::DWORD = 0x00000002; +pub const SERVICE_STOP_REASON_MINOR_INSTALLATION: ::DWORD = 0x00000003; +pub const SERVICE_STOP_REASON_MINOR_UPGRADE: ::DWORD = 0x00000004; +pub const SERVICE_STOP_REASON_MINOR_RECONFIG: ::DWORD = 0x00000005; +pub const SERVICE_STOP_REASON_MINOR_HUNG: ::DWORD = 0x00000006; +pub const SERVICE_STOP_REASON_MINOR_UNSTABLE: ::DWORD = 0x00000007; +pub const SERVICE_STOP_REASON_MINOR_DISK: ::DWORD = 0x00000008; +pub const SERVICE_STOP_REASON_MINOR_NETWORKCARD: ::DWORD = 0x00000009; +pub const SERVICE_STOP_REASON_MINOR_ENVIRONMENT: ::DWORD = 0x0000000a; +pub const SERVICE_STOP_REASON_MINOR_HARDWARE_DRIVER: ::DWORD = 0x0000000b; +pub const SERVICE_STOP_REASON_MINOR_OTHERDRIVER: ::DWORD = 0x0000000c; +pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK: ::DWORD = 0x0000000d; +pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE: ::DWORD = 0x0000000e; +pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX: ::DWORD = 0x0000000f; +pub const SERVICE_STOP_REASON_MINOR_SECURITY: ::DWORD = 0x00000010; +pub const SERVICE_STOP_REASON_MINOR_NETWORK_CONNECTIVITY: ::DWORD = 0x00000011; +pub const SERVICE_STOP_REASON_MINOR_WMI: ::DWORD = 0x00000012; +pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK_UNINSTALL: ::DWORD = 0x00000013; +pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE_UNINSTALL: ::DWORD = 0x00000014; +pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX_UNINSTALL: ::DWORD = 0x00000015; +pub const SERVICE_STOP_REASON_MINOR_MMC: ::DWORD = 0x00000016; +pub const SERVICE_STOP_REASON_MINOR_NONE: ::DWORD = 0x00000017; +pub const SERVICE_STOP_REASON_MINOR_MAX: ::DWORD = 0x00000018; +pub const SERVICE_STOP_REASON_MINOR_MIN_CUSTOM: ::DWORD = 0x00000100; +pub const SERVICE_STOP_REASON_MINOR_MAX_CUSTOM: ::DWORD = 0x0000FFFF; +pub const SERVICE_CONTROL_STATUS_REASON_INFO: ::DWORD = 1; +pub const SERVICE_SID_TYPE_NONE: ::DWORD = 0x00000000; +pub const SERVICE_SID_TYPE_UNRESTRICTED: ::DWORD = 0x00000001; +pub const SERVICE_SID_TYPE_RESTRICTED: ::DWORD = 0x00000002 | SERVICE_SID_TYPE_UNRESTRICTED; +pub const SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL: ::DWORD = 1; +pub const SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY: ::DWORD = 2; +pub const SERVICE_TRIGGER_TYPE_DOMAIN_JOIN: ::DWORD = 3; +pub const SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT: ::DWORD = 4; +pub const SERVICE_TRIGGER_TYPE_GROUP_POLICY: ::DWORD = 5; +pub const SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT: ::DWORD = 6; +pub const SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE: ::DWORD = 7; +pub const SERVICE_TRIGGER_TYPE_CUSTOM: ::DWORD = 20; +pub const SERVICE_TRIGGER_DATA_TYPE_BINARY: ::DWORD = 1; +pub const SERVICE_TRIGGER_DATA_TYPE_STRING: ::DWORD = 2; +pub const SERVICE_TRIGGER_DATA_TYPE_LEVEL: ::DWORD = 3; +pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY: ::DWORD = 4; +pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL: ::DWORD = 5; +pub const SERVICE_START_REASON_DEMAND: ::DWORD = 0x00000001; +pub const SERVICE_START_REASON_AUTO: ::DWORD = 0x00000002; +pub const SERVICE_START_REASON_TRIGGER: ::DWORD = 0x00000004; +pub const SERVICE_START_REASON_RESTART_ON_FAILURE: ::DWORD = 0x00000008; +pub const SERVICE_START_REASON_DELAYEDAUTO: ::DWORD = 0x00000010; +pub const SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON: ::DWORD = 1; +pub const SERVICE_LAUNCH_PROTECTED_NONE: ::DWORD = 0; +pub const SERVICE_LAUNCH_PROTECTED_WINDOWS: ::DWORD = 1; +pub const SERVICE_LAUNCH_PROTECTED_WINDOWS_LIGHT: ::DWORD = 2; +pub const SERVICE_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT: ::DWORD = 3; +//678 +DECLARE_HANDLE!(SC_HANDLE, SC_HANDLE__); +pub type LPSC_HANDLE = *mut SC_HANDLE; +DECLARE_HANDLE!(SERVICE_STATUS_HANDLE, SERVICE_STATUS_HANDLE__); +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum SC_STATUS_TYPE { + SC_STATUS_PROCESS_INFO = 0, + __, // FIXME - Univariant enums +} +#[repr(i32)] #[derive(Clone, Copy, Debug)] +pub enum _SC_ENUM_TYPE { + SC_ENUM_PROCESS_INFO = 0, + __, // FIXME - Univariant enums +} +//700 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SERVICE_STATUS { + pub dwServiceType: ::DWORD, + pub dwCurrentState: ::DWORD, + pub dwControlsAccepted: ::DWORD, + pub dwWin32ExitCode: ::DWORD, + pub dwServiceSpecificExitCode: ::DWORD, + pub dwCheckPoint: ::DWORD, + pub dwWaitHint: ::DWORD, +} +pub type LPSERVICE_STATUS = *mut SERVICE_STATUS; +//848 +pub type LPSERVICE_MAIN_FUNCTIONW = Option<unsafe extern "system" fn( + dwNumServicesArgs: ::DWORD, lpServiceArgVectors: *mut ::LPWSTR, +)>; +pub type LPSERVICE_MAIN_FUNCTIONA = Option<unsafe extern "system" fn( + dwNumServicesArgs: ::DWORD, lpServiceArgVectors: *mut ::LPSTR, +)>; +#[repr(C)] #[derive(Copy)] +pub struct SERVICE_TABLE_ENTRYA { + pub lpServiceName: ::LPCSTR, + pub lpServiceProc: LPSERVICE_MAIN_FUNCTIONA, +} +impl Clone for SERVICE_TABLE_ENTRYA { fn clone(&self) -> SERVICE_TABLE_ENTRYA { *self } } +pub type LPSERVICE_TABLE_ENTRYA = *mut SERVICE_TABLE_ENTRYA; +#[repr(C)] #[derive(Copy)] +pub struct SERVICE_TABLE_ENTRYW { + pub lpServiceName: ::LPCWSTR, + pub lpServiceProc: LPSERVICE_MAIN_FUNCTIONW, +} +impl Clone for SERVICE_TABLE_ENTRYW { fn clone(&self) -> SERVICE_TABLE_ENTRYW { *self } } +pub type LPSERVICE_TABLE_ENTRYW = *mut SERVICE_TABLE_ENTRYW; +//900 +pub type LPHANDLER_FUNCTION = Option<unsafe extern "system" fn(dwControl: ::DWORD)>; +pub type LPHANDLER_FUNCTION_EX = Option<unsafe extern "system" fn( + dwControl: ::DWORD, dwEventType: ::DWORD, lpEventData: ::LPVOID, lpContext: ::LPVOID, +) -> ::DWORD>; diff --git a/deps/winapi-0.1.23/src/winuser.rs b/deps/winapi-0.1.23/src/winuser.rs new file mode 100644 index 000000000..9e77154b3 --- /dev/null +++ b/deps/winapi-0.1.23/src/winuser.rs @@ -0,0 +1,654 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! USER procedure declarations, constant definitions and macros +pub type HDWP = *mut ::HANDLE; +//2193 +pub const WHEEL_DELTA: ::DWORD = 120; +//2206 +pub const XBUTTON1: ::DWORD = 0x0001; +pub const XBUTTON2: ::DWORD = 0x0002; +//2392 +pub const MK_LBUTTON: ::WPARAM = 0x0001; +pub const MK_RBUTTON: ::WPARAM = 0x0002; +pub const MK_SHIFT: ::WPARAM = 0x0004; +pub const MK_CONTROL: ::WPARAM = 0x0008; +pub const MK_MBUTTON: ::WPARAM = 0x0010; +pub const MK_XBUTTON1: ::WPARAM = 0x0020; +pub const MK_XBUTTON2: ::WPARAM = 0x0040; +//2408 +pub const TME_HOVER: ::DWORD = 0x0000_0001; +pub const TME_LEAVE: ::DWORD = 0x0000_0002; +pub const TME_NONCLIENT: ::DWORD = 0x0000_0010; +pub const TME_QUERY: ::DWORD = 0x4000_0000; +pub const TME_CANCEL: ::DWORD = 0x8000_0000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct TRACKMOUSEEVENT { + pub cbSize: ::DWORD, + pub dwFlags: ::DWORD, + pub hwndTrack: ::HWND, + pub dwHoverTime: ::DWORD, +} +pub type LPTRACKMOUSEEVENT = *mut TRACKMOUSEEVENT; +//2575 +/// lParam of WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct WINDOWPOS { + pub hwnd: ::HWND, + /// hwnd or HWND_BOTTOM, HWND_NOTOPMOST, HWND_TOP, HWND_TOPMOST + pub hwndInsertAfter: ::HWND, + pub x: ::c_int, + pub y: ::c_int, + pub cx: ::c_int, + pub cy: ::c_int, + /// SWP_\* + pub flags: ::UINT, +} +pub type LPWINDOWPOS = *mut WINDOWPOS; +pub type PWINDOWPOS = *mut WINDOWPOS; +//3082 +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREATESTRUCTA { + pub lpCreateParams: ::LPVOID, + pub hInstance: ::HINSTANCE, + pub hMenu: ::HMENU, + pub hwndParent: ::HWND, + pub cy: ::c_int, + pub cx: ::c_int, + pub y: ::c_int, + pub x: ::c_int, + pub style: ::LONG, + pub lpszName: ::LPCSTR, + pub lpszClass: ::LPCSTR, + pub dwExStyle: ::DWORD, +} +pub type LPCREATESTRUCTA = *mut CREATESTRUCTA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CREATESTRUCTW { + pub lpCreateParams: ::LPVOID, + pub hInstance: ::HINSTANCE, + pub hMenu: ::HMENU, + pub hwndParent: ::HWND, + pub cy: ::c_int, + pub cx: ::c_int, + pub y: ::c_int, + pub x: ::c_int, + pub style: ::LONG, + pub lpszName: ::LPCWSTR, + pub lpszClass: ::LPCWSTR, + pub dwExStyle: ::DWORD, +} +pub type LPCREATESTRUCTW = *mut CREATESTRUCTW; +//3145 +#[repr(C)] #[derive(Clone, Copy, Debug)] +/// The lParam of the WM_NOTIFY message is a pointer to this structure +pub struct NMHDR { + pub hwndFrom: ::HWND, + pub idFrom: ::UINT_PTR, + pub code: ::UINT, // NM_ code +} + +//3400 +pub const PM_NOREMOVE: ::UINT = 0x0000; +pub const PM_REMOVE: ::UINT = 0x0001; +pub const PM_NOYIELD: ::UINT = 0x0002; +pub const PM_QS_INPUT: ::UINT = QS_INPUT << 16; +pub const PM_QS_POSTMESSAGE: ::UINT = (QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16; +pub const PM_QS_PAINT: ::UINT = QS_PAINT << 16; +pub const PM_QS_SENDMESSAGE: ::UINT = QS_SENDMESSAGE << 16; +//4054 (Win 7 SDK) +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct FLASHWINFO { + pub cbSize: ::UINT, + pub hwnd: ::HWND, + pub dwFlags: ::DWORD, + pub uCount: ::UINT, + pub dwTimeout: ::DWORD, +} +pub type PFLASHWINFO = *mut FLASHWINFO; +pub const FLASHW_STOP: ::DWORD = 0; +pub const FLASHW_CAPTION: ::DWORD = 0x00000001; +pub const FLASHW_TRAY: ::DWORD = 0x00000002; +pub const FLASHW_ALL: ::DWORD = FLASHW_CAPTION | FLASHW_TRAY; +pub const FLASHW_TIMER: ::DWORD = 0x00000004; +pub const FLASHW_TIMERNOFG: ::DWORD = 0x0000000C; +//5741 +pub const KEYEVENTF_EXTENDEDKEY: ::DWORD = 0x0001; +pub const KEYEVENTF_KEYUP: ::DWORD = 0x0002; +pub const KEYEVENTF_UNICODE: ::DWORD = 0x0004; +pub const KEYEVENTF_SCANCODE: ::DWORD = 0x0008; +pub const MOUSEEVENTF_MOVE: ::DWORD = 0x0001; +pub const MOUSEEVENTF_LEFTDOWN: ::DWORD = 0x0002; +pub const MOUSEEVENTF_LEFTUP: ::DWORD = 0x0004; +pub const MOUSEEVENTF_RIGHTDOWN: ::DWORD = 0x0008; +pub const MOUSEEVENTF_RIGHTUP: ::DWORD = 0x0010; +pub const MOUSEEVENTF_MIDDLEDOWN: ::DWORD = 0x0020; +pub const MOUSEEVENTF_MIDDLEUP: ::DWORD = 0x0040; +pub const MOUSEEVENTF_XDOWN: ::DWORD = 0x0080; +pub const MOUSEEVENTF_XUP: ::DWORD = 0x0100; +pub const MOUSEEVENTF_WHEEL: ::DWORD = 0x0800; +pub const MOUSEEVENTF_HWHEEL: ::DWORD = 0x01000; +pub const MOUSEEVENTF_MOVE_NOCOALESCE: ::DWORD = 0x2000; +pub const MOUSEEVENTF_VIRTUALDESK: ::DWORD = 0x4000; +pub const MOUSEEVENTF_ABSOLUTE: ::DWORD = 0x8000; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MOUSEINPUT { + pub dx: ::LONG, + pub dy: ::LONG, + pub mouseData: ::DWORD, + pub dwFlags: ::DWORD, + pub time: ::DWORD, + pub dwExtraInfo: ::ULONG_PTR, +} +pub type PMOUSEINPUT = *mut MOUSEINPUT; +pub type LPMOUSEINPUT = *mut MOUSEINPUT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct KEYBDINPUT { + pub wVk: ::WORD, + pub wScan: ::WORD, + pub dwFlags: ::DWORD, + pub time: ::DWORD, + pub dwExtraInfo: ::ULONG_PTR, +} +pub type PKEYBDINPUT = *mut KEYBDINPUT; +pub type LPKEYBDINPUT = *mut KEYBDINPUT; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct HARDWAREINPUT { + pub uMsg: ::DWORD, + pub wParamL: ::WORD, + pub wParamH: ::WORD, +} +pub type PHARDWAREINPUT = *mut HARDWAREINPUT; +pub type LPHARDWAREINPUT= *mut HARDWAREINPUT; +pub const INPUT_MOUSE: ::DWORD = 0; +pub const INPUT_KEYBOARD: ::DWORD = 1; +pub const INPUT_HARDWARE: ::DWORD = 2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct INPUT { + pub type_: ::DWORD, + pub union_: MOUSEINPUT, // FIXME - Untagged unions +} +#[test] +fn test_INPUT() { + use std::mem::{size_of, min_align_of}; + assert!(size_of::<MOUSEINPUT>() >= size_of::<HARDWAREINPUT>()); + assert!(size_of::<MOUSEINPUT>() >= size_of::<KEYBDINPUT>()); + assert!(min_align_of::<MOUSEINPUT>() >= min_align_of::<HARDWAREINPUT>()); + assert!(min_align_of::<MOUSEINPUT>() >= min_align_of::<KEYBDINPUT>()); +} +pub type PINPUT = *mut INPUT; +pub type LPINPUT = *mut INPUT; +//Indices for GetWindowLong etc. +pub const GWL_EXSTYLE: ::c_int = -20; +pub const GWL_STYLE: ::c_int = -16; +pub const GWL_WNDPROC: ::c_int = -4; +pub const GWLP_WNDPROC: ::c_int = -4; +pub const GWL_HINSTANCE: ::c_int = -6; +pub const GWLP_HINSTANCE: ::c_int = -6; +pub const GWL_HWNDPARENT: ::c_int = -8; +pub const GWLP_HWNDPARENT: ::c_int = -8; +pub const GWL_ID: ::c_int = -12; +pub const GWLP_ID: ::c_int = -12; +pub const GWL_USERDATA: ::c_int = -21; +pub const GWLP_USERDATA: ::c_int = -21; +//6566 +// flags for MsgWaitForMultipleObjectsEx +pub const MWMO_WAITALL: ::DWORD = 0x0001; +pub const MWMO_ALERTABLE: ::DWORD = 0x0002; +pub const MWMO_INPUTAVAILABLE: ::DWORD = 0x0004; +//6573 +pub const QS_KEY: ::UINT = 0x0001; +pub const QS_MOUSEMOVE: ::UINT = 0x0002; +pub const QS_MOUSEBUTTON: ::UINT = 0x0004; +pub const QS_POSTMESSAGE: ::UINT = 0x0008; +pub const QS_TIMER: ::UINT = 0x0010; +pub const QS_PAINT: ::UINT = 0x0020; +pub const QS_SENDMESSAGE: ::UINT = 0x0040; +pub const QS_HOTKEY: ::UINT = 0x0080; +pub const QS_ALLPOSTMESSAGE: ::UINT = 0x0100; +pub const QS_RAWINPUT: ::UINT = 0x0400; +pub const QS_TOUCH: ::UINT = 0x0800; +pub const QS_POINTER: ::UINT = 0x1000; +pub const QS_MOUSE: ::UINT = QS_MOUSEMOVE | QS_MOUSEBUTTON; +pub const QS_INPUT: ::UINT = QS_MOUSE | QS_KEY | QS_RAWINPUT | QS_TOUCH | QS_POINTER; +pub const QS_ALLEVENTS: ::UINT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY; +pub const QS_ALLINPUT: ::UINT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER + | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE; +//6789 +pub const SM_CXSCREEN: ::c_int = 0; +pub const SM_CYSCREEN: ::c_int = 1; +pub const SM_CXVSCROLL: ::c_int = 2; +pub const SM_CYHSCROLL: ::c_int = 3; +pub const SM_CYCAPTION: ::c_int = 4; +pub const SM_CXBORDER: ::c_int = 5; +pub const SM_CYBORDER: ::c_int = 6; +pub const SM_CXDLGFRAME: ::c_int = 7; +pub const SM_CYDLGFRAME: ::c_int = 8; +pub const SM_CYVTHUMB: ::c_int = 9; +pub const SM_CXHTHUMB: ::c_int = 10; +pub const SM_CXICON: ::c_int = 11; +pub const SM_CYICON: ::c_int = 12; +pub const SM_CXCURSOR: ::c_int = 13; +pub const SM_CYCURSOR: ::c_int = 14; +pub const SM_CYMENU: ::c_int = 15; +pub const SM_CXFULLSCREEN: ::c_int = 16; +pub const SM_CYFULLSCREEN: ::c_int = 17; +pub const SM_CYKANJIWINDOW: ::c_int = 18; +pub const SM_MOUSEPRESENT: ::c_int = 19; +pub const SM_CYVSCROLL: ::c_int = 20; +pub const SM_CXHSCROLL: ::c_int = 21; +pub const SM_DEBUG: ::c_int = 22; +pub const SM_SWAPBUTTON: ::c_int = 23; +pub const SM_RESERVED1: ::c_int = 24; +pub const SM_RESERVED2: ::c_int = 25; +pub const SM_RESERVED3: ::c_int = 26; +pub const SM_RESERVED4: ::c_int = 27; +pub const SM_CXMIN: ::c_int = 28; +pub const SM_CYMIN: ::c_int = 29; +pub const SM_CXSIZE: ::c_int = 30; +pub const SM_CYSIZE: ::c_int = 31; +pub const SM_CXFRAME: ::c_int = 32; +pub const SM_CYFRAME: ::c_int = 33; +pub const SM_CXMINTRACK: ::c_int = 34; +pub const SM_CYMINTRACK: ::c_int = 35; +pub const SM_CXDOUBLECLK: ::c_int = 36; +pub const SM_CYDOUBLECLK: ::c_int = 37; +pub const SM_CXICONSPACING: ::c_int = 38; +pub const SM_CYICONSPACING: ::c_int = 39; +pub const SM_MENUDROPALIGNMENT: ::c_int = 40; +pub const SM_PENWINDOWS: ::c_int = 41; +pub const SM_DBCSENABLED: ::c_int = 42; +pub const SM_CMOUSEBUTTONS: ::c_int = 43; +pub const SM_CXFIXEDFRAME: ::c_int = SM_CXDLGFRAME; +pub const SM_CYFIXEDFRAME: ::c_int = SM_CYDLGFRAME; +pub const SM_CXSIZEFRAME: ::c_int = SM_CXFRAME; +pub const SM_CYSIZEFRAME: ::c_int = SM_CYFRAME; +pub const SM_SECURE: ::c_int = 44; +pub const SM_CXEDGE: ::c_int = 45; +pub const SM_CYEDGE: ::c_int = 46; +pub const SM_CXMINSPACING: ::c_int = 47; +pub const SM_CYMINSPACING: ::c_int = 48; +pub const SM_CXSMICON: ::c_int = 49; +pub const SM_CYSMICON: ::c_int = 50; +pub const SM_CYSMCAPTION: ::c_int = 51; +pub const SM_CXSMSIZE: ::c_int = 52; +pub const SM_CYSMSIZE: ::c_int = 53; +pub const SM_CXMENUSIZE: ::c_int = 54; +pub const SM_CYMENUSIZE: ::c_int = 55; +pub const SM_ARRANGE: ::c_int = 56; +pub const SM_CXMINIMIZED: ::c_int = 57; +pub const SM_CYMINIMIZED: ::c_int = 58; +pub const SM_CXMAXTRACK: ::c_int = 59; +pub const SM_CYMAXTRACK: ::c_int = 60; +pub const SM_CXMAXIMIZED: ::c_int = 61; +pub const SM_CYMAXIMIZED: ::c_int = 62; +pub const SM_NETWORK: ::c_int = 63; +pub const SM_CLEANBOOT: ::c_int = 67; +pub const SM_CXDRAG: ::c_int = 68; +pub const SM_CYDRAG: ::c_int = 69; +pub const SM_SHOWSOUNDS: ::c_int = 70; +pub const SM_CXMENUCHECK: ::c_int = 71; +pub const SM_CYMENUCHECK: ::c_int = 72; +pub const SM_SLOWMACHINE: ::c_int = 73; +pub const SM_MIDEASTENABLED: ::c_int = 74; +pub const SM_MOUSEWHEELPRESENT: ::c_int = 75; +pub const SM_XVIRTUALSCREEN: ::c_int = 76; +pub const SM_YVIRTUALSCREEN: ::c_int = 77; +pub const SM_CXVIRTUALSCREEN: ::c_int = 78; +pub const SM_CYVIRTUALSCREEN: ::c_int = 79; +pub const SM_CMONITORS: ::c_int = 80; +pub const SM_SAMEDISPLAYFORMAT: ::c_int = 81; +pub const SM_IMMENABLED: ::c_int = 82; +pub const SM_CXFOCUSBORDER: ::c_int = 83; +pub const SM_CYFOCUSBORDER: ::c_int = 84; +pub const SM_TABLETPC: ::c_int = 86; +pub const SM_MEDIACENTER: ::c_int = 87; +pub const SM_STARTER: ::c_int = 88; +pub const SM_SERVERR2: ::c_int = 89; +pub const SM_MOUSEHORIZONTALWHEELPRESENT: ::c_int = 91; +pub const SM_CXPADDEDBORDER: ::c_int = 92; +pub const SM_DIGITIZER: ::c_int = 94; +pub const SM_MAXIMUMTOUCHES: ::c_int = 95; +pub const SM_CMETRICS: ::c_int = 97; +pub const SM_REMOTESESSION: ::c_int = 0x1000; +pub const SM_SHUTTINGDOWN: ::c_int = 0x2000; +pub const SM_REMOTECONTROL: ::c_int = 0x2001; +pub const SM_CARETBLINKINGENABLED: ::c_int = 0x2002; +pub const SM_CONVERTIBLESLATEMODE: ::c_int = 0x2003; +pub const SM_SYSTEMDOCKED: ::c_int = 0x2004; +//8855 (Win 7 SDK) +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct ICONINFO { + pub fIcon: ::BOOL, + pub xHotspot: ::DWORD, + pub yHotspot: ::DWORD, + pub hbmMask: ::HBITMAP, + pub hbmColor: ::HBITMAP, +} +pub type PICONINFO = *mut ICONINFO; +//9066 +// Color indexes for use in GetSysColor and SetSysColor +// 0-18 (after incrementing) are also valid in RegisterClass's WNDCLASS +pub const COLOR_SCROLLBAR: ::c_int = 0; +pub const COLOR_BACKGROUND: ::c_int = 1; +pub const COLOR_ACTIVECAPTION: ::c_int = 2; +pub const COLOR_INACTIVECAPTION: ::c_int = 3; +pub const COLOR_MENU: ::c_int = 4; +pub const COLOR_WINDOW: ::c_int = 5; +pub const COLOR_WINDOWFRAME: ::c_int = 6; +pub const COLOR_MENUTEXT: ::c_int = 7; +pub const COLOR_WINDOWTEXT: ::c_int = 8; +pub const COLOR_CAPTIONTEXT: ::c_int = 9; +pub const COLOR_ACTIVEBORDER: ::c_int = 10; +pub const COLOR_INACTIVEBORDER: ::c_int = 11; +pub const COLOR_APPWORKSPACE: ::c_int = 12; +pub const COLOR_HIGHLIGHT: ::c_int = 13; +pub const COLOR_HIGHLIGHTTEXT: ::c_int = 14; +pub const COLOR_BTNFACE: ::c_int = 15; +pub const COLOR_BTNSHADOW: ::c_int = 16; +pub const COLOR_GRAYTEXT: ::c_int = 17; +pub const COLOR_BTNTEXT: ::c_int = 18; +pub const COLOR_INACTIVECAPTIONTEXT: ::c_int = 19; +pub const COLOR_BTNHIGHLIGHT: ::c_int = 20; +// Introduced in Windows 95 (winver 0x0400): +pub const COLOR_3DDKSHADOW: ::c_int = 21; +pub const COLOR_3DLIGHT: ::c_int = 22; +pub const COLOR_INFOTEXT: ::c_int = 23; +pub const COLOR_INFOBK: ::c_int = 24; +pub const COLOR_DESKTOP: ::c_int = COLOR_BACKGROUND; +pub const COLOR_3DFACE: ::c_int = COLOR_BTNFACE; +pub const COLOR_3DSHADOW: ::c_int = COLOR_BTNSHADOW; +pub const COLOR_3DHIGHLIGHT: ::c_int = COLOR_BTNHIGHLIGHT; +pub const COLOR_3DHILIGHT: ::c_int = COLOR_BTNHIGHLIGHT; +pub const COLOR_BTNHILIGHT: ::c_int = COLOR_BTNHIGHLIGHT; +// Introduced in Windows 2000 (winver 0x0500) +pub const COLOR_HOTLIGHT: ::c_int = 26; +pub const COLOR_GRADIENTACTIVECAPTION: ::c_int = 27; +pub const COLOR_GRADIENTINACTIVECAPTION: ::c_int = 28; +// Introduced in Windows XP (winver 0x0501) +pub const COLOR_MENUHILIGHT: ::c_int = 29; +pub const COLOR_MENUBAR: ::c_int = 30; + +//10069 +pub const IDC_ARROW: ::LPCWSTR = 32512 as ::LPCWSTR; +pub const IDC_IBEAM: ::LPCWSTR = 32513 as ::LPCWSTR; +pub const IDC_WAIT: ::LPCWSTR = 32514 as ::LPCWSTR; +pub const IDC_CROSS: ::LPCWSTR = 32515 as ::LPCWSTR; +pub const IDC_UPARROW: ::LPCWSTR = 32516 as ::LPCWSTR; +pub const IDC_SIZE: ::LPCWSTR = 32640 as ::LPCWSTR; +pub const IDC_ICON: ::LPCWSTR = 32641 as ::LPCWSTR; +pub const IDC_SIZENWSE: ::LPCWSTR = 32642 as ::LPCWSTR; +pub const IDC_SIZENESW: ::LPCWSTR = 32643 as ::LPCWSTR; +pub const IDC_SIZEWE: ::LPCWSTR = 32644 as ::LPCWSTR; +pub const IDC_SIZENS: ::LPCWSTR = 32645 as ::LPCWSTR; +pub const IDC_SIZEALL: ::LPCWSTR = 32646 as ::LPCWSTR; +pub const IDC_NO: ::LPCWSTR = 32648 as ::LPCWSTR; +pub const IDC_HAND: ::LPCWSTR = 32649 as ::LPCWSTR; +pub const IDC_APPSTARTING: ::LPCWSTR = 32650 as ::LPCWSTR; +pub const IDC_HELP: ::LPCWSTR = 32651 as ::LPCWSTR; + +//10492 +pub const IDI_APPLICATION: ::LPCWSTR = 32512 as ::LPCWSTR; +pub const IDI_HAND: ::LPCWSTR = 32513 as ::LPCWSTR; +pub const IDI_QUESTION: ::LPCWSTR = 32514 as ::LPCWSTR; +pub const IDI_EXCLAMATION: ::LPCWSTR = 32515 as ::LPCWSTR; +pub const IDI_ASTERISK: ::LPCWSTR = 32516 as ::LPCWSTR; +pub const IDI_WINLOGO: ::LPCWSTR = 32517 as ::LPCWSTR; +pub const IDI_SHIELD: ::LPCWSTR = 32518 as ::LPCWSTR; + +pub const IDI_WARNING: ::LPCWSTR = IDI_EXCLAMATION; +pub const IDI_ERROR: ::LPCWSTR = IDI_HAND; +pub const IDI_INFORMATION: ::LPCWSTR = IDI_ASTERISK; + +//11813 +pub const SPI_GETNONCLIENTMETRICS: ::UINT = 0x29; + +//12141 +#[repr(C)] #[derive(Clone, Copy)] +pub struct NONCLIENTMETRICSA { + pub cbSize: ::UINT, + pub iBorderWidth: ::c_int, + pub iScrollWidth: ::c_int, + pub iScrollHeight: ::c_int, + pub iCaptionWidth: ::c_int, + pub iCaptionHeight: ::c_int, + pub lfCaptionFont: ::LOGFONTA, + pub iSmCaptionWidth: ::c_int, + pub iSmCaptionHeight: ::c_int, + pub lfSmCaptionFont: ::LOGFONTA, + pub iMenuWidth: ::c_int, + pub iMenuHeight: ::c_int, + pub lfMenuFont: ::LOGFONTA, + pub lfStatusFont: ::LOGFONTA, + pub lfMessageFont: ::LOGFONTA, + pub iPaddedBorderWidth: ::c_int, +} +pub type LPNONCLIENTMETRICSA = *mut NONCLIENTMETRICSA; + +#[repr(C)] #[derive(Clone, Copy)] +pub struct NONCLIENTMETRICSW { + pub cbSize: ::UINT, + pub iBorderWidth: ::c_int, + pub iScrollWidth: ::c_int, + pub iScrollHeight: ::c_int, + pub iCaptionWidth: ::c_int, + pub iCaptionHeight: ::c_int, + pub lfCaptionFont: ::LOGFONTW, + pub iSmCaptionWidth: ::c_int, + pub iSmCaptionHeight: ::c_int, + pub lfSmCaptionFont: ::LOGFONTW, + pub iMenuWidth: ::c_int, + pub iMenuHeight: ::c_int, + pub lfMenuFont: ::LOGFONTW, + pub lfStatusFont: ::LOGFONTW, + pub lfMessageFont: ::LOGFONTW, + pub iPaddedBorderWidth: ::c_int, +} +pub type LPNONCLIENTMETRICSW = *mut NONCLIENTMETRICSW; + +//12900 +pub const MONITORINFOF_PRIMARY: ::DWORD = 1; +pub const CCHDEVICENAME: usize = 32; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MONITORINFO { + pub cbSize: ::DWORD, + pub rcMonitor: ::RECT, + pub rcWork: ::RECT, + pub dwFlags: ::DWORD, +} +pub type LPMONITORINFO = *mut MONITORINFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MONITORINFOEXA { + pub cbSize: ::DWORD, + pub rcMonitor: ::RECT, + pub rcWork: ::RECT, + pub dwFlags: ::DWORD, + pub szDevice: [::CHAR; ::CCHDEVICENAME], +} +pub type LPMONITORINFOEXA = *mut MONITORINFOEXA; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct MONITORINFOEXW { + pub cbSize: ::DWORD, + pub rcMonitor: ::RECT, + pub rcWork: ::RECT, + pub dwFlags: ::DWORD, + pub szDevice: [::WCHAR; ::CCHDEVICENAME], +} +pub type LPMONITORINFOEXW = *mut MONITORINFOEXW; +//12971 +pub type MONITORENUMPROC = Option<unsafe extern "system" fn( + ::HMONITOR, ::HDC, ::LPRECT, ::LPARAM, +) -> ::BOOL>; +//14098 +DECLARE_HANDLE!(HRAWINPUT, HRAWINPUT__); +pub fn GET_RAWINPUT_CODE_WPARAM(wParam: ::WPARAM) -> ::WPARAM { wParam & 0xff } +pub const RIM_INPUT: ::WPARAM = 0; +pub const RIM_INPUTSINK: ::WPARAM = 1; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RAWINPUTHEADER { + pub dwType: ::DWORD, + pub dwSize: ::DWORD, + pub hDevice: ::HANDLE, + pub wParam: ::WPARAM, +} +pub type PRAWINPUTHEADER = *mut RAWINPUTHEADER; +pub type LPRAWINPUTHEADER = *mut RAWINPUTHEADER; +pub const RIM_TYPEMOUSE: ::DWORD = 0; +pub const RIM_TYPEKEYBOARD: ::DWORD = 1; +pub const RIM_TYPEHID: ::DWORD = 2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RAWMOUSE { + pub usFlags: ::USHORT, + pub usButtonFlags: ::USHORT, + pub usButtonData: ::USHORT, + pub ulRawButtons: ::ULONG, + pub lLastX: ::LONG, + pub lLastY: ::LONG, + pub ulExtraInformation: ::ULONG, +} +pub type PRAWMOUSE = *mut RAWMOUSE; +pub type LPRAWMOUSE = *mut RAWMOUSE; +pub const RI_MOUSE_LEFT_BUTTON_DOWN: ::USHORT = 0x0001; +pub const RI_MOUSE_LEFT_BUTTON_UP: ::USHORT = 0x0002; +pub const RI_MOUSE_RIGHT_BUTTON_DOWN: ::USHORT = 0x0004; +pub const RI_MOUSE_RIGHT_BUTTON_UP: ::USHORT = 0x0008; +pub const RI_MOUSE_MIDDLE_BUTTON_DOWN: ::USHORT = 0x0010; +pub const RI_MOUSE_MIDDLE_BUTTON_UP: ::USHORT = 0x0020; +pub const RI_MOUSE_BUTTON_1_DOWN: ::USHORT = RI_MOUSE_LEFT_BUTTON_DOWN; +pub const RI_MOUSE_BUTTON_1_UP: ::USHORT = RI_MOUSE_LEFT_BUTTON_UP; +pub const RI_MOUSE_BUTTON_2_DOWN: ::USHORT = RI_MOUSE_RIGHT_BUTTON_DOWN; +pub const RI_MOUSE_BUTTON_2_UP: ::USHORT = RI_MOUSE_RIGHT_BUTTON_UP; +pub const RI_MOUSE_BUTTON_3_DOWN: ::USHORT = RI_MOUSE_MIDDLE_BUTTON_DOWN; +pub const RI_MOUSE_BUTTON_3_UP: ::USHORT = RI_MOUSE_MIDDLE_BUTTON_UP; +pub const RI_MOUSE_BUTTON_4_DOWN: ::USHORT = 0x0040; +pub const RI_MOUSE_BUTTON_4_UP: ::USHORT = 0x0080; +pub const RI_MOUSE_BUTTON_5_DOWN: ::USHORT = 0x0100; +pub const RI_MOUSE_BUTTON_5_UP: ::USHORT = 0x0200; +pub const RI_MOUSE_WHEEL: ::USHORT = 0x0400; +pub const MOUSE_MOVE_RELATIVE: ::USHORT = 0; +pub const MOUSE_MOVE_ABSOLUTE: ::USHORT = 1; +pub const MOUSE_VIRTUAL_DESKTOP: ::USHORT = 0x02; +pub const MOUSE_ATTRIBUTES_CHANGED: ::USHORT = 0x04; +pub const MOUSE_MOVE_NOCOALESCE: ::USHORT = 0x08; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RAWKEYBOARD { + pub MakeCode: ::USHORT, + pub Flags: ::USHORT, + pub Reserved: ::USHORT, + pub VKey: ::USHORT, + pub Message: ::UINT, + pub ExtraInformation: ::ULONG, +} +pub type PRAWKEYBOARD = *mut RAWKEYBOARD; +pub type LPRAWKEYBOARD = *mut RAWKEYBOARD; +pub const KEYBOARD_OVERRUN_MAKE_CODE: ::DWORD = 0xFF; +pub const RI_KEY_MAKE: ::DWORD = 0; +pub const RI_KEY_BREAK: ::DWORD = 1; +pub const RI_KEY_E0: ::DWORD = 2; +pub const RI_KEY_E1: ::DWORD = 4; +pub const RI_KEY_TERMSRV_SET_LED: ::DWORD = 8; +pub const RI_KEY_TERMSRV_SHADOW: ::DWORD = 0x10; +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct RAWHID { + pub dwSizeHid: ::DWORD, + pub dwCount: ::DWORD, + pub bRawData: [::BYTE; 0], +} +pub type PRAWHID = *mut RAWHID; +pub type LPRAWHID = *mut RAWHID; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RAWINPUT { + pub header: RAWINPUTHEADER, + pub mouse: RAWMOUSE, // FIXME untagged union +} +#[test] +fn test_RAWINPUT() { + use std::mem::{size_of, min_align_of}; + assert!(size_of::<RAWMOUSE>() >= size_of::<RAWMOUSE>()); + assert!(size_of::<RAWMOUSE>() >= size_of::<RAWKEYBOARD>()); + assert!(size_of::<RAWMOUSE>() >= size_of::<RAWHID>()); + assert!(min_align_of::<RAWMOUSE>() >= min_align_of::<RAWMOUSE>()); + assert!(min_align_of::<RAWMOUSE>() >= min_align_of::<RAWKEYBOARD>()); + assert!(min_align_of::<RAWMOUSE>() >= min_align_of::<RAWHID>()); +} +pub type PRAWINPUT = *mut RAWINPUT; +pub type LPRAWINPUT = *mut RAWINPUT; +pub const RID_INPUT: ::DWORD = 0x10000003; +pub const RID_HEADER: ::DWORD = 0x10000005; +pub const RIDI_PREPARSEDDATA: ::DWORD = 0x20000005; +pub const RIDI_DEVICENAME: ::DWORD = 0x20000007; +pub const RIDI_DEVICEINFO: ::DWORD = 0x2000000b; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RID_DEVICE_INFO_MOUSE { + pub dwId: ::DWORD, + pub dwNumberOfButtons: ::DWORD, + pub dwSampleRate: ::DWORD, + pub fHasHorizontalWheel: ::BOOL, +} +pub type PRID_DEVICE_INFO_MOUSE = *mut RID_DEVICE_INFO_MOUSE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RID_DEVICE_INFO_KEYBOARD { + pub dwType: ::DWORD, + pub dwSubType: ::DWORD, + pub dwKeyboardMode: ::DWORD, + pub dwNumberOfFunctionKeys: ::DWORD, + pub dwNumberOfIndicators: ::DWORD, + pub dwNumberOfKeysTotal: ::DWORD, +} +pub type PRID_DEVICE_INFO_KEYBOARD = *mut RID_DEVICE_INFO_KEYBOARD; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RID_DEVICE_INFO_HID { + pub dwVendorId: ::DWORD, + pub dwProductId: ::DWORD, + pub dwVersionNumber: ::DWORD, + pub usUsagePage: ::USHORT, + pub usUsage: ::USHORT, +} +pub type PRID_DEVICE_INFO_HID = *mut RID_DEVICE_INFO_HID; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RID_DEVICE_INFO { + pub cbSize: ::DWORD, + pub dwType: ::DWORD, + pub keyboard: RID_DEVICE_INFO_KEYBOARD, // FIXME untagged union +} +#[test] +fn test_RID_DEVICE_INFO() { + use std::mem::{size_of, min_align_of}; + assert!(size_of::<RID_DEVICE_INFO_KEYBOARD>() >= size_of::<RID_DEVICE_INFO_MOUSE>()); + assert!(size_of::<RID_DEVICE_INFO_KEYBOARD>() >= size_of::<RID_DEVICE_INFO_KEYBOARD>()); + assert!(size_of::<RID_DEVICE_INFO_KEYBOARD>() >= size_of::<RID_DEVICE_INFO_HID>()); + assert!(min_align_of::<RID_DEVICE_INFO_KEYBOARD>() >= min_align_of::<RID_DEVICE_INFO_MOUSE>()); + assert!(min_align_of::<RID_DEVICE_INFO_KEYBOARD>() + >= min_align_of::<RID_DEVICE_INFO_KEYBOARD>()); + assert!(min_align_of::<RID_DEVICE_INFO_KEYBOARD>() >= min_align_of::<RID_DEVICE_INFO_HID>()); +} +pub type PRID_DEVICE_INFO = *mut RID_DEVICE_INFO; +pub type LPRID_DEVICE_INFO = *mut RID_DEVICE_INFO; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RAWINPUTDEVICE { + pub usUsagePage: ::USHORT, + pub usUsage: ::USHORT, + pub dwFlags: ::DWORD, + pub hwndTarget: ::HWND, +} +pub type PRAWINPUTDEVICE = *mut RAWINPUTDEVICE; +pub type LPRAWINPUTDEVICE = *mut RAWINPUTDEVICE; +pub type PCRAWINPUTDEVICE = *const RAWINPUTDEVICE; +pub const RIDEV_REMOVE: ::DWORD = 0x00000001; +pub const RIDEV_EXCLUDE: ::DWORD = 0x00000010; +pub const RIDEV_PAGEONLY: ::DWORD = 0x00000020; +pub const RIDEV_NOLEGACY: ::DWORD = 0x00000030; +pub const RIDEV_INPUTSINK: ::DWORD = 0x00000100; +pub const RIDEV_CAPTUREMOUSE: ::DWORD = 0x00000200; +pub const RIDEV_NOHOTKEYS: ::DWORD = 0x00000200; +pub const RIDEV_APPKEYS: ::DWORD = 0x00000400; +pub const RIDEV_EXINPUTSINK: ::DWORD = 0x00001000; +pub const RIDEV_DEVNOTIFY: ::DWORD = 0x00002000; +pub const RIDEV_EXMODEMASK: ::DWORD = 0x000000F0; +pub const GIDC_ARRIVAL: ::DWORD = 1; +pub const GIDC_REMOVAL: ::DWORD = 2; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct RAWINPUTDEVICELIST { + pub hDevice: ::HANDLE, + pub dwType: ::DWORD, +} +pub type PRAWINPUTDEVICELIST = *mut RAWINPUTDEVICELIST; diff --git a/deps/winapi-0.1.23/src/ws2def.rs b/deps/winapi-0.1.23/src/ws2def.rs new file mode 100644 index 000000000..ee8b22e0f --- /dev/null +++ b/deps/winapi-0.1.23/src/ws2def.rs @@ -0,0 +1,176 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//! This file contains the core definitions for the Winsock2 specification that can be used by +//! both user-mode and kernel mode modules. +pub type ADDRESS_FAMILY = ::USHORT; +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_IMPLINK: ::c_int = 3; +pub const AF_PUP: ::c_int = 4; +pub const AF_CHAOS: ::c_int = 5; +pub const AF_NS: ::c_int = 6; +pub const AF_IPX: ::c_int = AF_NS; +pub const AF_ISO: ::c_int = 7; +pub const AF_OSI: ::c_int = AF_ISO; +pub const AF_ECMA: ::c_int = 8; +pub const AF_DATAKIT: ::c_int = 9; +pub const AF_CCITT: ::c_int = 10; +pub const AF_SNA: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_DLI: ::c_int = 13; +pub const AF_LAT: ::c_int = 14; +pub const AF_HYLINK: ::c_int = 15; +pub const AF_APPLETALK: ::c_int = 16; +pub const AF_NETBIOS: ::c_int = 17; +pub const AF_VOICEVIEW: ::c_int = 18; +pub const AF_FIREFOX: ::c_int = 19; +pub const AF_UNKNOWN1: ::c_int = 20; +pub const AF_BAN: ::c_int = 21; +pub const AF_ATM: ::c_int = 22; +pub const AF_INET6: ::c_int = 23; +pub const AF_CLUSTER: ::c_int = 24; +pub const AF_12844: ::c_int = 25; +pub const AF_IRDA: ::c_int = 26; +pub const AF_NETDES: ::c_int = 28; +pub const AF_TCNPROCESS: ::c_int = 29; +pub const AF_TCNMESSAGE: ::c_int = 30; +pub const AF_ICLFXBM: ::c_int = 31; +pub const AF_BTH: ::c_int = 32; +pub const AF_LINK: ::c_int = 33; +pub const AF_MAX: ::c_int = 34; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SO_DEBUG: ::c_int = 0x0001; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_DONTLINGER: ::c_int = !SO_LINGER; +pub const SO_EXCLUSIVEADDRUSE: ::c_int = !SO_REUSEADDR; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_BSP_STATE: ::c_int = 0x1009; +pub const SO_GROUP_ID: ::c_int = 0x2001; +pub const SO_GROUP_PRIORITY: ::c_int = 0x2002; +pub const SO_MAX_MSG_SIZE: ::c_int = 0x2003; +pub const SO_CONDITIONAL_ACCEPT: ::c_int = 0x3002; +pub const SO_PAUSE_ACCEPT: ::c_int = 0x3003; +pub const SO_COMPARTMENT_ID: ::c_int = 0x3004; +pub const SO_RANDOMIZE_PORT: ::c_int = 0x3005; +pub const SO_PORT_SCALABILITY: ::c_int = 0x3006; +pub const WSK_SO_BASE: ::c_int = 0x4000; +pub const TCP_NODELAY: ::c_int = 0x0001; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SOCKADDR { + pub sa_family: ADDRESS_FAMILY, + pub sa_data: [::CHAR; 14], +} +pub type PSOCKADDR = *mut SOCKADDR; +pub type LPSOCKADDR = *mut SOCKADDR; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SOCKET_ADDRESS { + pub lpSockaddr: LPSOCKADDR, + pub iSockaddrLength: ::INT, +} +pub type PSOCKET_ADDRESS = *mut SOCKET_ADDRESS; +pub type LPSOCKET_ADDRESS = *mut SOCKET_ADDRESS; +#[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] +pub struct SOCKET_ADDRESS_LIST { + pub iAddressCount: ::INT, + pub Address: [SOCKET_ADDRESS; 0], +} +pub type PSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST; +pub type LPSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct CSADDR_INFO { + pub LocalAddr: SOCKET_ADDRESS, + pub RemoteAddr: SOCKET_ADDRESS, + pub iSocketType: ::INT, + pub iProtocol: ::INT, +} +pub type PCSADDR_INFO = *mut CSADDR_INFO; +pub type LPCSADDR_INFO = *mut CSADDR_INFO; +#[repr(C)] #[derive(Copy)] +pub struct SOCKADDR_STORAGE_LH { + ss_family: ADDRESS_FAMILY, + __ss_pad1: [::CHAR; 6], + __ss_align: ::__int64, + __ss_pad2: [::CHAR; 112], +} +impl Clone for SOCKADDR_STORAGE_LH { fn clone(&self) -> SOCKADDR_STORAGE_LH { *self } } +pub type PSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH; +pub type LPSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH; +#[repr(C)] #[derive(Copy)] +pub struct SOCKADDR_STORAGE_XP { + ss_family: ::c_short, + __ss_pad1: [::CHAR; 6], + __ss_align: ::__int64, + __ss_pad2: [::CHAR; 112], +} +impl Clone for SOCKADDR_STORAGE_XP { fn clone(&self) -> SOCKADDR_STORAGE_XP { *self } } +pub type PSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP; +pub type LPSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP; +pub type SOCKADDR_STORAGE = SOCKADDR_STORAGE_LH; +pub type PSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE; +pub type LPSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE; +#[repr(C)] #[derive(Clone, Copy, Debug)] +pub struct SOCKET_PROCESSOR_AFFINITY { + Processor: ::PROCESSOR_NUMBER, + NumaNodeId: ::USHORT, + Reserved: ::USHORT, +} +pub type PSOCKET_PROCESSOR_AFFINITY = *mut SOCKET_PROCESSOR_AFFINITY; +pub const IOC_UNIX: ::DWORD = 0x00000000; +pub const IOC_WS2: ::DWORD = 0x08000000; +pub const IOC_PROTOCOL: ::DWORD = 0x10000000; +pub const IOC_VENDOR: ::DWORD = 0x18000000; +pub const IOC_WSK: ::DWORD = IOC_WS2 | 0x07000000; +macro_rules! _WSAIO { ($x:expr, $y:expr) => { IOC_VOID | $x | $y } } +macro_rules! _WSAIOR { ($x:expr, $y:expr) => { IOC_OUT | $x | $y } } +macro_rules! _WSAIOW { ($x:expr, $y:expr) => { IOC_IN | $x | $y } } +macro_rules! _WSAIORW { ($x:expr, $y:expr) => { IOC_INOUT | $x | $y } } +pub const SIO_ASSOCIATE_HANDLE: ::DWORD = _WSAIOW!(IOC_WS2, 1); +pub const SIO_ENABLE_CIRCULAR_QUEUEING: ::DWORD = _WSAIO!(IOC_WS2, 2); +pub const SIO_FIND_ROUTE: ::DWORD = _WSAIOR!(IOC_WS2, 3); +pub const SIO_FLUSH: ::DWORD = _WSAIO!(IOC_WS2, 4); +pub const SIO_GET_BROADCAST_ADDRESS: ::DWORD = _WSAIOR!(IOC_WS2, 5); +pub const SIO_GET_EXTENSION_FUNCTION_POINTER: ::DWORD = _WSAIORW!(IOC_WS2, 6); +pub const SIO_GET_QOS: ::DWORD = _WSAIORW!(IOC_WS2, 7); +pub const SIO_GET_GROUP_QOS: ::DWORD = _WSAIORW!(IOC_WS2, 8); +pub const SIO_MULTIPOINT_LOOPBACK: ::DWORD = _WSAIOW!(IOC_WS2, 9); +pub const SIO_MULTICAST_SCOPE: ::DWORD = _WSAIOW!(IOC_WS2, 10); +pub const SIO_SET_QOS: ::DWORD = _WSAIOW!(IOC_WS2, 11); +pub const SIO_SET_GROUP_QOS: ::DWORD = _WSAIOW!(IOC_WS2, 12); +pub const SIO_TRANSLATE_HANDLE: ::DWORD = _WSAIORW!(IOC_WS2, 13); +pub const SIO_ROUTING_INTERFACE_QUERY: ::DWORD = _WSAIORW!(IOC_WS2, 20); +pub const SIO_ROUTING_INTERFACE_CHANGE: ::DWORD = _WSAIOW!(IOC_WS2, 21); +pub const SIO_ADDRESS_LIST_QUERY: ::DWORD = _WSAIOR!(IOC_WS2, 22); +pub const SIO_ADDRESS_LIST_CHANGE: ::DWORD = _WSAIO!(IOC_WS2, 23); +pub const SIO_QUERY_TARGET_PNP_HANDLE: ::DWORD = _WSAIOR!(IOC_WS2, 24); +pub const SIO_QUERY_RSS_PROCESSOR_INFO: ::DWORD = _WSAIOR!(IOC_WS2, 37); +pub const SIO_ADDRESS_LIST_SORT: ::DWORD = _WSAIORW!(IOC_WS2, 25); +pub const SIO_RESERVED_1: ::DWORD = _WSAIOW!(IOC_WS2, 26); +pub const SIO_RESERVED_2: ::DWORD = _WSAIOW!(IOC_WS2, 33); +pub const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER: ::DWORD = _WSAIORW!(IOC_WS2, 36); + +//645 +pub const IOCPARM_MASK: ::DWORD = 0x7f; +pub const IOC_VOID: ::DWORD = 0x20000000; +pub const IOC_OUT: ::DWORD = 0x40000000; +pub const IOC_IN: ::DWORD = 0x80000000; +pub const IOC_INOUT: ::DWORD = IOC_IN | IOC_OUT; diff --git a/deps/winapi-0.1.23/src/wtypesbase.rs b/deps/winapi-0.1.23/src/wtypesbase.rs new file mode 100644 index 000000000..72ffe6653 --- /dev/null +++ b/deps/winapi-0.1.23/src/wtypesbase.rs @@ -0,0 +1,9 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +//114 +pub type OLECHAR = ::WCHAR; +pub type LPOLESTR = *mut OLECHAR; +pub type LPCOLESTR = *const OLECHAR; +//281 +pub type SCODE = ::LONG; +pub type PSCODE = *mut SCODE; diff --git a/deps/winapi-0.1.23/tests/advapi32.rs b/deps/winapi-0.1.23/tests/advapi32.rs new file mode 100644 index 000000000..be2db0b26 --- /dev/null +++ b/deps/winapi-0.1.23/tests/advapi32.rs @@ -0,0 +1,95 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate advapi32; +use advapi32::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(AdjustTokenPrivileges); + bb(CloseServiceHandle); + bb(ControlService); + bb(CreateServiceA); + bb(CreateServiceW); + bb(CredDeleteA); + bb(CredDeleteW); + bb(CredFree); + bb(CredReadA); + bb(CredReadW); + bb(CredWriteA); + bb(CredWriteW); + bb(CryptAcquireContextA); + bb(CryptAcquireContextW); + bb(CryptCreateHash); + bb(CryptDestroyHash); + bb(CryptGetHashParam); + bb(CryptHashData); + bb(CryptReleaseContext); + bb(DeleteService); + bb(OpenProcessToken); + bb(OpenSCManagerA); + bb(OpenSCManagerW); + bb(OpenServiceA); + bb(OpenServiceW); + bb(QueryServiceStatus); + bb(QueryServiceStatusEx); + bb(RegCloseKey); + bb(RegConnectRegistryA); + bb(RegConnectRegistryW); + bb(RegCopyTreeA); + bb(RegCopyTreeW); + bb(RegCreateKeyExA); + bb(RegCreateKeyExW); + bb(RegCreateKeyTransactedA); + bb(RegCreateKeyTransactedW); + bb(RegDeleteKeyA); + bb(RegDeleteKeyExA); + bb(RegDeleteKeyExW); + bb(RegDeleteKeyTransactedA); + bb(RegDeleteKeyTransactedW); + bb(RegDeleteKeyValueA); + bb(RegDeleteKeyValueW); + bb(RegDeleteKeyW); + bb(RegDeleteTreeA); + bb(RegDeleteTreeW); + bb(RegDeleteValueA); + bb(RegDeleteValueW); + bb(RegDisablePredefinedCache); + bb(RegDisablePredefinedCacheEx); + bb(RegDisableReflectionKey); + bb(RegEnableReflectionKey); + bb(RegEnumKeyExA); + bb(RegEnumKeyExW); + bb(RegEnumValueA); + bb(RegEnumValueW); + bb(RegFlushKey); + bb(RegGetValueA); + bb(RegGetValueW); + bb(RegLoadMUIStringW); + bb(RegNotifyChangeKeyValue); + bb(RegOpenCurrentUser); + bb(RegOpenKeyExA); + bb(RegOpenKeyExW); + bb(RegOpenKeyTransactedA); + bb(RegOpenKeyTransactedW); + bb(RegOpenUserClassesRoot); + bb(RegOverridePredefKey); + bb(RegQueryInfoKeyA); + bb(RegQueryInfoKeyW); + bb(RegQueryMultipleValuesA); + bb(RegQueryMultipleValuesW); + bb(RegQueryReflectionKey); + bb(RegQueryValueExA); + bb(RegQueryValueExW); + bb(RegSetKeyValueA); + bb(RegSetValueExA); + bb(RegSetValueExW); + bb(RegSetKeyValueW); + bb(RegisterServiceCtrlHandlerA); + bb(RegisterServiceCtrlHandlerExA); + bb(RegisterServiceCtrlHandlerExW); + bb(RegisterServiceCtrlHandlerW); + bb(SetServiceStatus); + bb(StartServiceCtrlDispatcherA); + bb(StartServiceCtrlDispatcherW); +} diff --git a/deps/winapi-0.1.23/tests/dwmapi.rs b/deps/winapi-0.1.23/tests/dwmapi.rs new file mode 100644 index 000000000..2a9201ecc --- /dev/null +++ b/deps/winapi-0.1.23/tests/dwmapi.rs @@ -0,0 +1,10 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate dwmapi; +use dwmapi::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(DwmEnableBlurBehindWindow); +} diff --git a/deps/winapi-0.1.23/tests/gdi32.rs b/deps/winapi-0.1.23/tests/gdi32.rs new file mode 100644 index 000000000..b2242bc2c --- /dev/null +++ b/deps/winapi-0.1.23/tests/gdi32.rs @@ -0,0 +1,36 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate gdi32; +use gdi32::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(Chord); + bb(CreateBitmap); + bb(CreateBitmapIndirect); + bb(CreateDIBitmap); + bb(CreateDIBSection); + bb(Ellipse); + bb(GetDIBits); + // Not in MingGW yet + // bb(Pie); + bb(Polygon); + bb(PolyPolygon); + bb(RoundRect); + bb(AngleArc); + bb(Arc); + bb(ArcTo); + bb(GetArcDirection); + bb(LineDDA); + bb(LineTo); + bb(MoveToEx); + bb(PolyBezier); + bb(PolyBezierTo); + bb(PolyDraw); + bb(PolyPolygon); + bb(PolyPolyline); + bb(Polyline); + bb(PolylineTo); + bb(SetArcDirection); +} diff --git a/deps/winapi-0.1.23/tests/kernel32.rs b/deps/winapi-0.1.23/tests/kernel32.rs new file mode 100644 index 000000000..004babc71 --- /dev/null +++ b/deps/winapi-0.1.23/tests/kernel32.rs @@ -0,0 +1,11 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate kernel32; +use kernel32::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(GetStartupInfoA); + bb(GetStartupInfoW); +} diff --git a/deps/winapi-0.1.23/tests/ktmw32.rs b/deps/winapi-0.1.23/tests/ktmw32.rs new file mode 100644 index 000000000..c69a0f932 --- /dev/null +++ b/deps/winapi-0.1.23/tests/ktmw32.rs @@ -0,0 +1,12 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate ktmw32; +use ktmw32::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(CommitTransaction); + bb(CreateTransaction); + bb(RollbackTransaction); +} diff --git a/deps/winapi-0.1.23/tests/mpr.rs b/deps/winapi-0.1.23/tests/mpr.rs new file mode 100644 index 000000000..c87f0726f --- /dev/null +++ b/deps/winapi-0.1.23/tests/mpr.rs @@ -0,0 +1,48 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate mpr; +use mpr::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(MultinetGetConnectionPerformanceA); + bb(MultinetGetConnectionPerformanceW); + bb(WNetAddConnection2A); + bb(WNetAddConnection2W); + bb(WNetAddConnection3A); + bb(WNetAddConnection3W); + bb(WNetCancelConnectionA); + bb(WNetCancelConnectionW); + bb(WNetCancelConnection2A); + bb(WNetCancelConnection2W); + bb(WNetCloseEnum); + bb(WNetConnectionDialog); + bb(WNetConnectionDialog1A); + bb(WNetConnectionDialog1W); + bb(WNetDisconnectDialog); + bb(WNetDisconnectDialog1A); + bb(WNetDisconnectDialog1W); + bb(WNetEnumResourceA); + bb(WNetEnumResourceW); + bb(WNetGetConnectionA); + bb(WNetGetConnectionW); + bb(WNetGetLastErrorA); + bb(WNetGetLastErrorW); + bb(WNetGetNetworkInformationA); + bb(WNetGetNetworkInformationW); + bb(WNetGetProviderNameA); + bb(WNetGetProviderNameW); + bb(WNetGetResourceInformationA); + bb(WNetGetResourceInformationW); + bb(WNetGetResourceParentA); + bb(WNetGetResourceParentW); + bb(WNetGetUniversalNameA); + bb(WNetGetUniversalNameW); + bb(WNetGetUserA); + bb(WNetGetUserW); + bb(WNetOpenEnumA); + bb(WNetOpenEnumW); + bb(WNetUseConnectionA); + bb(WNetUseConnectionW); +} diff --git a/deps/winapi-0.1.23/tests/shell32.rs b/deps/winapi-0.1.23/tests/shell32.rs new file mode 100644 index 000000000..a0677e6f1 --- /dev/null +++ b/deps/winapi-0.1.23/tests/shell32.rs @@ -0,0 +1,35 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate shell32; +use shell32::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(SHCloneSpecialIDList); + bb(SHCreateDirectory); + bb(SHCreateDirectoryExA); + bb(SHCreateDirectoryExW); + bb(SHCreateShellItem); + bb(SHFlushSFCache); + bb(SHGetFolderLocation); + bb(SHGetFolderPathA); + bb(SHGetFolderPathAndSubDirA); + bb(SHGetFolderPathAndSubDirW); + bb(SHGetFolderPathW); + bb(SHGetIconOverlayIndexA); + bb(SHGetIconOverlayIndexW); + bb(SHGetKnownFolderIDList); + bb(SHGetKnownFolderItem); + bb(SHGetKnownFolderPath); + bb(SHGetPathFromIDListA); + bb(SHGetPathFromIDListEx); + bb(SHGetPathFromIDListW); + bb(SHGetSpecialFolderLocation); + bb(SHGetSpecialFolderPathA); + bb(SHGetSpecialFolderPathW); + bb(SHOpenFolderAndSelectItems); + bb(SHSetFolderPathA); + bb(SHSetFolderPathW); + bb(SHSetKnownFolderPath); +} diff --git a/deps/winapi-0.1.23/tests/user32.rs b/deps/winapi-0.1.23/tests/user32.rs new file mode 100644 index 000000000..1150c9b42 --- /dev/null +++ b/deps/winapi-0.1.23/tests/user32.rs @@ -0,0 +1,200 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate user32; +use user32::*; +#[inline(never)] fn bb<T>(_: T) {} +#[cfg(target_arch = "x86_64")] +#[test] +fn functions_x64() { + bb(GetClassLongPtrA); + bb(GetClassLongPtrW); + bb(GetWindowLongPtrA); + bb(GetWindowLongPtrW); + bb(SetClassLongPtrA); + bb(SetClassLongPtrW); + bb(SetWindowLongPtrA); + bb(SetWindowLongPtrW); +} +#[test] +fn functions() { + bb(ActivateKeyboardLayout); + // bb(AddClipboardFormatListener); + bb(AdjustWindowRect); + bb(AdjustWindowRectEx); + bb(AllowSetForegroundWindow); + bb(AnimateWindow); + bb(AnyPopup); + bb(ArrangeIconicWindows); + bb(AttachThreadInput); + bb(BeginPaint); + bb(BlockInput); + bb(BringWindowToTop); + // bb(CalculatePopupWindowPosition); + bb(CascadeWindows); + bb(ChangeClipboardChain); + bb(ChangeDisplaySettingsExW); + bb(ChangeDisplaySettingsW); + bb(ChildWindowFromPoint); + bb(ChildWindowFromPointEx); + bb(ClipCursor); + bb(CloseClipboard); + bb(CloseDesktop); + bb(CloseWindow); + bb(CloseWindowStation); + bb(CountClipboardFormats); + bb(CreateCaret); + bb(CreateCursor); + bb(CreateIconIndirect); + bb(CreateWindowExW); + bb(DefWindowProcW); + bb(DeferWindowPos); + bb(DeleteMenu); + bb(DeregisterShellHookWindow); + bb(DestroyAcceleratorTable); + bb(DestroyCaret); + bb(DestroyCursor); + bb(DestroyIcon); + bb(DestroyMenu); + bb(DestroyWindow); + bb(DispatchMessageW); + bb(EmptyClipboard); + bb(EnableScrollBar); + bb(EnableWindow); + bb(EndPaint); + bb(EndTask); + bb(EnumClipboardFormats); + bb(EnumDisplayDevicesW); + bb(EnumDisplaySettingsExW); + bb(EnumThreadWindows); + bb(EnumWindows); + bb(FillRect); + bb(FindWindowA ); + bb(FindWindowExA); + bb(FindWindowExW); + bb(FindWindowW); + bb(FlashWindowEx); + bb(GetActiveWindow); + bb(GetAncestor); + bb(GetAsyncKeyState); + bb(GetCaretBlinkTime); + bb(GetCaretPos); + bb(GetClassInfoExW); + bb(GetClassInfoW); + bb(GetClassLongA); + bb(GetClassLongW); + bb(GetClassWord); + bb(GetClientRect); + bb(GetClipCursor); + bb(GetClipboardData); + bb(GetClipboardFormatNameA); + bb(GetClipboardFormatNameW); + bb(GetClipboardOwner); + bb(GetClipboardSequenceNumber); + bb(GetClipboardViewer); + bb(GetCursor); + bb(GetCursorPos); + bb(GetDC); + bb(GetDesktopWindow); + bb(GetDoubleClickTime); + bb(GetFocus); + bb(GetForegroundWindow); + bb(GetIconInfo); + bb(GetKBCodePage); + bb(GetKeyNameTextA); + bb(GetKeyNameTextW); + bb(GetKeyState); + bb(GetKeyboardLayout); + bb(GetKeyboardLayoutList); + bb(GetKeyboardLayoutNameA); + bb(GetKeyboardLayoutNameW); + bb(GetKeyboardState); + bb(GetKeyboardType); + bb(GetMessageW); + bb(GetOpenClipboardWindow); + bb(GetParent); + bb(GetQueueStatus); + // bb(GetPhysicalCursorPos); + bb(GetScrollPos); + bb(GetScrollRange); + bb(GetShellWindow); + bb(GetSysColor); + bb(GetSysColorBrush); + bb(GetSystemMetrics); + bb(GetThreadDesktop); + // bb(GetUpdatedClipboardFormats); + bb(GetWindow); + bb(GetWindowLongA); + bb(GetWindowLongW); + bb(GetWindowModuleFileNameA); + bb(GetWindowModuleFileNameW); + bb(GetWindowPlacement); + bb(GetWindowRect); + bb(GetWindowTextA); + bb(GetWindowTextLengthA); + bb(GetWindowTextLengthW); + bb(GetWindowTextW); + bb(HideCaret); + bb(InvalidateRect); + bb(IsClipboardFormatAvailable); + bb(IsIconic); + bb(IsWindow); + bb(IsWindowEnabled); + bb(IsWindowVisible); + bb(LoadCursorFromFileW); + bb(LoadCursorW); + bb(LoadImageA); + bb(LoadImageW); + bb(MessageBoxA); + bb(MessageBoxExA); + bb(MessageBoxExW); + bb(MessageBoxW); + bb(MsgWaitForMultipleObjects); + bb(MsgWaitForMultipleObjectsEx); + bb(OpenClipboard); + bb(PeekMessageW); + bb(PostMessageW); + bb(PostQuitMessage); + bb(RegisterClassExW); + bb(RegisterClipboardFormatA); + bb(RegisterClipboardFormatW); + bb(ReleaseDC); + bb(ScrollDC); + bb(ScrollWindow); + bb(ScrollWindowEx); + bb(SendInput); + bb(SendMessageA); + bb(SendMessageTimeoutA); + bb(SendMessageTimeoutW); + bb(SendMessageW); + bb(SendNotifyMessageA); + bb(SendNotifyMessageW); + bb(SetActiveWindow); + bb(SetCaretBlinkTime); + bb(SetCaretPos); + bb(SetClassLongA); + bb(SetClassLongW); + bb(SetClassWord); + bb(SetClipboardViewer); + bb(SetCursor); + bb(SetCursorPos); + bb(SetFocus); + bb(SetForegroundWindow); + // bb(SetPhysicalCursorPos); + bb(SetScrollPos); + bb(SetScrollRange); + bb(SetSystemCursor); + bb(SetWindowLongA); + bb(SetWindowLongW); + bb(SetWindowPos); + bb(SetWindowTextW); + bb(ShowCaret); + bb(ShowCursor); + bb(ShowWindow); + bb(ShowWindowAsync); + bb(TranslateMessage); + bb(UnregisterClassA); + bb(UnregisterClassW); + bb(UpdateWindow); + bb(WaitMessage); +} diff --git a/deps/winapi-0.1.23/tests/uuid.rs b/deps/winapi-0.1.23/tests/uuid.rs new file mode 100644 index 000000000..2140eaa85 --- /dev/null +++ b/deps/winapi-0.1.23/tests/uuid.rs @@ -0,0 +1,127 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate uuid; +use uuid::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn statics() { + bb(FOLDERID_AccountPictures); + bb(FOLDERID_AddNewPrograms); + bb(FOLDERID_AdminTools); + bb(FOLDERID_AppUpdates); + bb(FOLDERID_ApplicationShortcuts); + bb(FOLDERID_AppsFolder); + bb(FOLDERID_CDBurning); + // bb(FOLDERID_CameraRoll); + bb(FOLDERID_ChangeRemovePrograms); + bb(FOLDERID_CommonAdminTools); + bb(FOLDERID_CommonOEMLinks); + bb(FOLDERID_CommonPrograms); + bb(FOLDERID_CommonStartMenu); + bb(FOLDERID_CommonStartup); + bb(FOLDERID_CommonTemplates); + bb(FOLDERID_ComputerFolder); + bb(FOLDERID_ConflictFolder); + bb(FOLDERID_ConnectionsFolder); + bb(FOLDERID_Contacts); + bb(FOLDERID_ControlPanelFolder); + bb(FOLDERID_Cookies); + bb(FOLDERID_Desktop); + bb(FOLDERID_DeviceMetadataStore); + bb(FOLDERID_Documents); + bb(FOLDERID_DocumentsLibrary); + bb(FOLDERID_Downloads); + bb(FOLDERID_Favorites); + bb(FOLDERID_Fonts); + bb(FOLDERID_GameTasks); + bb(FOLDERID_Games); + bb(FOLDERID_History); + bb(FOLDERID_HomeGroup); + bb(FOLDERID_HomeGroupCurrentUser); + bb(FOLDERID_ImplicitAppShortcuts); + bb(FOLDERID_InternetCache); + bb(FOLDERID_InternetFolder); + bb(FOLDERID_Libraries); + bb(FOLDERID_Links); + bb(FOLDERID_LocalAppData); + bb(FOLDERID_LocalAppDataLow); + bb(FOLDERID_LocalizedResourcesDir); + bb(FOLDERID_Music); + bb(FOLDERID_MusicLibrary); + bb(FOLDERID_NetHood); + bb(FOLDERID_NetworkFolder); + bb(FOLDERID_OriginalImages); + bb(FOLDERID_PhotoAlbums); + bb(FOLDERID_Pictures); + bb(FOLDERID_PicturesLibrary); + bb(FOLDERID_Playlists); + bb(FOLDERID_PrintHood); + bb(FOLDERID_PrintersFolder); + bb(FOLDERID_Profile); + bb(FOLDERID_ProgramData); + bb(FOLDERID_ProgramFiles); + bb(FOLDERID_ProgramFilesCommon); + bb(FOLDERID_ProgramFilesCommonX64); + bb(FOLDERID_ProgramFilesCommonX86); + bb(FOLDERID_ProgramFilesX64); + bb(FOLDERID_ProgramFilesX86); + bb(FOLDERID_Programs); + bb(FOLDERID_Public); + bb(FOLDERID_PublicDesktop); + bb(FOLDERID_PublicDocuments); + bb(FOLDERID_PublicDownloads); + bb(FOLDERID_PublicGameTasks); + bb(FOLDERID_PublicLibraries); + bb(FOLDERID_PublicMusic); + bb(FOLDERID_PublicPictures); + bb(FOLDERID_PublicRingtones); + bb(FOLDERID_PublicUserTiles); + bb(FOLDERID_PublicVideos); + bb(FOLDERID_QuickLaunch); + bb(FOLDERID_Recent); + bb(FOLDERID_RecordedTVLibrary); + bb(FOLDERID_RecycleBinFolder); + bb(FOLDERID_ResourceDir); + bb(FOLDERID_Ringtones); + bb(FOLDERID_RoamedTileImages); + bb(FOLDERID_RoamingAppData); + bb(FOLDERID_RoamingTiles); + bb(FOLDERID_SEARCH_CSC); + bb(FOLDERID_SEARCH_MAPI); + bb(FOLDERID_SampleMusic); + bb(FOLDERID_SamplePictures); + bb(FOLDERID_SamplePlaylists); + bb(FOLDERID_SampleVideos); + bb(FOLDERID_SavedGames); + bb(FOLDERID_SavedSearches); + bb(FOLDERID_Screenshots); + // bb(FOLDERID_SearchHistory); + bb(FOLDERID_SearchHome); + // bb(FOLDERID_SearchTemplates); + bb(FOLDERID_SendTo); + bb(FOLDERID_SidebarDefaultParts); + bb(FOLDERID_SidebarParts); + // bb(FOLDERID_SkyDrive); + // bb(FOLDERID_SkyDriveCameraRoll); + // bb(FOLDERID_SkyDriveDocuments); + // bb(FOLDERID_SkyDriveMusic); + // bb(FOLDERID_SkyDrivePictures); + bb(FOLDERID_StartMenu); + bb(FOLDERID_Startup); + bb(FOLDERID_SyncManagerFolder); + bb(FOLDERID_SyncResultsFolder); + bb(FOLDERID_SyncSetupFolder); + bb(FOLDERID_System); + bb(FOLDERID_SystemX86); + bb(FOLDERID_Templates); + bb(FOLDERID_UserPinned); + bb(FOLDERID_UserProfiles); + bb(FOLDERID_UserProgramFiles); + bb(FOLDERID_UserProgramFilesCommon); + bb(FOLDERID_UsersFiles); + bb(FOLDERID_UsersLibraries); + bb(FOLDERID_Videos); + bb(FOLDERID_VideosLibrary); + bb(FOLDERID_Windows); +} diff --git a/deps/winapi-0.1.23/tests/winmm.rs b/deps/winapi-0.1.23/tests/winmm.rs new file mode 100644 index 000000000..2b0013311 --- /dev/null +++ b/deps/winapi-0.1.23/tests/winmm.rs @@ -0,0 +1,50 @@ +// Copyright © 2015, Jordan Miner +// Licensed under the MIT License <LICENSE.md> +#![cfg(windows)] +extern crate winmm; +use winmm::*; +#[inline(never)] fn bb<T>(_: T) {} +#[test] +fn functions() { + bb(PlaySoundA); + bb(PlaySoundW); + bb(sndPlaySoundA); + bb(sndPlaySoundW); + bb(timeBeginPeriod); + bb(timeEndPeriod); + bb(timeGetDevCaps); + bb(timeGetTime); + bb(waveInAddBuffer); + bb(waveInClose); + bb(waveInGetDevCapsW); + bb(waveInGetErrorTextW); + bb(waveInGetNumDevs); + bb(waveInGetPosition); + bb(waveInMessage); + bb(waveInOpen); + bb(waveInPrepareHeader); + bb(waveInReset); + bb(waveInStart); + bb(waveInStop); + bb(waveInUnprepareHeader); + bb(waveOutBreakLoop); + bb(waveOutClose); + bb(waveOutGetDevCapsW); + bb(waveOutGetErrorTextW); + bb(waveOutGetNumDevs); + bb(waveOutGetPitch); + bb(waveOutGetPlaybackRate); + bb(waveOutGetPosition); + bb(waveOutGetVolume); + bb(waveOutMessage); + bb(waveOutOpen); + bb(waveOutPause); + bb(waveOutPrepareHeader); + bb(waveOutReset); + bb(waveOutRestart); + bb(waveOutSetPitch); + bb(waveOutSetPlaybackRate); + bb(waveOutSetVolume); + bb(waveOutUnprepareHeader); + bb(waveOutWrite); +} diff --git a/deps/winapi-build-0.1.0/Cargo.toml b/deps/winapi-build-0.1.0/Cargo.toml new file mode 100644 index 000000000..283c71002 --- /dev/null +++ b/deps/winapi-build-0.1.0/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "winapi-build" +version = "0.1.0" +authors = ["Peter Atashian <retep998@gmail.com>"] +description = "Common code for build.rs in WinAPI -sys crates." +repository = "https://github.com/retep998/winapi-rs" +keywords = ["Windows", "FFI", "WinSDK"] +license = "MIT" + +[lib] +name = "build" diff --git a/deps/winapi-build-0.1.0/src/lib.rs b/deps/winapi-build-0.1.0/src/lib.rs new file mode 100644 index 000000000..f0db0b0ca --- /dev/null +++ b/deps/winapi-build-0.1.0/src/lib.rs @@ -0,0 +1,14 @@ +// Copyright © 2015, Peter Atashian +// Licensed under the MIT License <LICENSE.md> +pub fn link(name: &str, bundled: bool) { + use std::env::var; + let target = var("TARGET").unwrap(); + let target: Vec<_> = target.split('-').collect(); + if target[2] == "windows" { + println!("cargo:rustc-link-lib=dylib={}", name); + if bundled && target[3] == "gnu" { + let dir = var("CARGO_MANIFEST_DIR").unwrap(); + println!("cargo:rustc-link-search=native={}/{}", dir, target[0]); + } + } +} -- 2.30.2

+Â